Commit Graph

9 Commits

Author SHA1 Message Date
a34be3ef36 fix: getClaimStatus checks serverOwned flag, not just session id match 2026-03-14 14:10:37 -07:00
b83a245202 fix: use $HOME for state file path instead of hardcoded /home/pibot 2026-03-14 13:59:56 -07:00
ba88fa50f9 feat: multi-session webhook claim system with EADDRINUSE handling
- Server gracefully handles EADDRINUSE (logs notice, continues without server)
- POST /claim endpoint with referral-based async handoff:
  202 (pending) -> poll with referral_id -> 200/401/408
- GET /claim shows current owner and pending queue
- DOS protection: 503 when MAX_PENDING_CLAIMS (10) reached
- Claims expire after 5 minutes
- Pi commands: /webhook:status, /webhook:claim, /webhook:release
2026-03-14 13:47:40 -07:00
0389ae0b88 refactor: drop old env var fallbacks, GITEA_ prefix only
Removed PI_WEBHOOK_*, PI_BOT_POLL_INTERVAL, PI_NOTIF_POLL_INTERVAL,
PI_GIT_USER, OPENCLAW_* fallbacks. Only GITEA_* vars now.
GITEA_TOKEN still falls back to PI_GIT_TOKEN in client.ts for CLI compat.
2026-03-13 18:28:28 -07:00
c07bcca417 refactor: consolidate env vars under GITEA_ prefix
All env vars now use GITEA_ prefix with fallback to old names:
- GITEA_TOKEN (was PI_GIT_TOKEN)
- GITEA_USER (was PI_GIT_USER)
- GITEA_WEBHOOK_HOST/PORT/TOKEN/URL (was PI_WEBHOOK_*)
- GITEA_POLL_INTERVAL (was PI_BOT_POLL_INTERVAL)
- GITEA_NOTIF_INTERVAL (was PI_NOTIF_POLL_INTERVAL)
- GITEA_HOOKS_URL/PATH/TOKEN (was OPENCLAW_HOOKS_*)

Old names still work as fallbacks for backward compat.
2026-03-13 18:24:22 -07:00
83a42de9e2 feat: @mention routing via Gitea notifications API
- Replace per-repo event polling with notification-based polling
- Collab repos default to mention-only mode (respond only when @mentioned)
- Own repos default to all-events mode (respond to everything)
- Parse @mentions and extract directive text for focused LLM context
- Notification poll interval: 30s (configurable via PI_NOTIF_POLL_INTERVAL)
- Mark notifications as read after processing (no ID tracking needed)
- Add gitea_repo_config tool to switch repos between 'all' and 'mention' modes
- Add gitea_tracked_repos tool to show all repos and their response modes
- Persist per-repo configs to disk across reloads
- Multi-bot coordination: issues can @mention different bots with directives
2026-03-13 17:52:47 -07:00
b868ad4df5 fix: POST for file creation (Gitea 1.25+), add edit_issue tool, persist poll state
- files.ts: Use POST for new files, PUT for updates (Gitea 1.25 requires this)
- issues.ts: Add editIssue() for state/title/body changes
- write-tools.ts: Add gitea_edit_issue tool (open/close/edit issues)
- webhook/server.ts: Persist lastPollAt to disk to prevent duplicate
  events on reload; use followUp delivery to queue events during LLM turns
- index.ts: Use deliverAs:'followUp' for sendUserMessage
2026-03-13 17:14:06 -07:00
578e2f91cb feat: hybrid webhook + polling for collab repos
- Repos with admin access get webhooks auto-installed
- Collab repos (403 on webhook install) fall back to event polling
- Poll every 60s for new issues, PRs, and comments
- Use Date objects for timestamp comparison (fixes TZ offset issues)
- Skip events from the bot's own user
- Clean startup/shutdown with state reset on reload
- Health endpoint reports webhook_repos + poll_only_repos counts
2026-03-13 16:47:07 -07:00
25e49db155 feat: consolidated Gitea API client and pi extension
- Pure fetch-based API client (src/) with zero external dependencies
- Pi extension adapter (pi-extension/) registering 17 tools
- Standalone CLI (cli.ts) replacing gitea-scripts/gitea.js
- Token auth everywhere (no HMAC secrets)
- SKILL.md for agent auto-discovery
- TOOL.md with full parameter reference

Consolidates pi-bot/extensions/pi-gitea and clawbot/gitea-scripts
into a single shared package.
2026-03-13 14:49:55 -07:00