feat: conditional webhook/polling for openclaw compatibility
- Webhook server + notification poller only start when needed: - pi-bot (no GITEA_HOOKS_URL): starts automatically (persistent session) - openclaw (GITEA_HOOKS_URL set): tools only, no server/poller - Override with GITEA_ENABLE_POLLING=1 to force polling in any mode - Tools (20 Gitea tools) always register regardless of mode
This commit is contained in:
@@ -75,6 +75,12 @@ export default function (pi: ExtensionAPI) {
|
||||
|
||||
// ── Lifecycle ────────────────────────────────────────────────────────────
|
||||
|
||||
// GITEA_ENABLE_POLLING=1 opts in to running the webhook server + notification poller.
|
||||
// pi-bot (persistent session): enabled by default
|
||||
// openclaw (ephemeral sessions): disabled by default — events come via openclaw hooks
|
||||
const enablePolling = process.env.GITEA_ENABLE_POLLING === "1" ||
|
||||
(!process.env.GITEA_HOOKS_URL && !process.env.OPENCLAW_HOOKS_URL);
|
||||
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
console.log("[pi-gitea] Session started");
|
||||
|
||||
@@ -108,17 +114,23 @@ export default function (pi: ExtensionAPI) {
|
||||
});
|
||||
}
|
||||
|
||||
if (enablePolling) {
|
||||
try {
|
||||
await startWebhookServer(pi);
|
||||
await startPolling(pi);
|
||||
} catch (err) {
|
||||
console.error("[pi-gitea] Failed to start:", err);
|
||||
console.error("[pi-gitea] Failed to start webhook/polling:", err);
|
||||
}
|
||||
} else {
|
||||
console.log("[pi-gitea] Webhook server + polling disabled (openclaw mode — tools only)");
|
||||
}
|
||||
});
|
||||
|
||||
pi.on("session_shutdown", async () => {
|
||||
console.log("[pi-gitea] Session shutting down");
|
||||
if (enablePolling) {
|
||||
await stopWebhookServer();
|
||||
stopPolling();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user