@runcore-sh/runcore 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +353 -0
- package/dist/activity/log.d.ts +37 -0
- package/dist/activity/log.d.ts.map +1 -0
- package/dist/activity/log.js +259 -0
- package/dist/activity/log.js.map +1 -0
- package/dist/adapters/storage/gdrive-backup.d.ts +20 -0
- package/dist/adapters/storage/gdrive-backup.d.ts.map +1 -0
- package/dist/adapters/storage/gdrive-backup.js +244 -0
- package/dist/adapters/storage/gdrive-backup.js.map +1 -0
- package/dist/adapters/storage/local.d.ts +19 -0
- package/dist/adapters/storage/local.d.ts.map +1 -0
- package/dist/adapters/storage/local.js +101 -0
- package/dist/adapters/storage/local.js.map +1 -0
- package/dist/adapters/storage/types.d.ts +44 -0
- package/dist/adapters/storage/types.d.ts.map +1 -0
- package/dist/adapters/storage/types.js +6 -0
- package/dist/adapters/storage/types.js.map +1 -0
- package/dist/agents/autonomous.d.ts +67 -0
- package/dist/agents/autonomous.d.ts.map +1 -0
- package/dist/agents/autonomous.js +710 -0
- package/dist/agents/autonomous.js.map +1 -0
- package/dist/agents/commit.d.ts +22 -0
- package/dist/agents/commit.d.ts.map +1 -0
- package/dist/agents/commit.js +120 -0
- package/dist/agents/commit.js.map +1 -0
- package/dist/agents/continue.d.ts +19 -0
- package/dist/agents/continue.d.ts.map +1 -0
- package/dist/agents/continue.js +158 -0
- package/dist/agents/continue.js.map +1 -0
- package/dist/agents/cooldown.d.ts +127 -0
- package/dist/agents/cooldown.d.ts.map +1 -0
- package/dist/agents/cooldown.js +396 -0
- package/dist/agents/cooldown.js.map +1 -0
- package/dist/agents/dedup-guard.d.ts +15 -0
- package/dist/agents/dedup-guard.d.ts.map +1 -0
- package/dist/agents/dedup-guard.js +128 -0
- package/dist/agents/dedup-guard.js.map +1 -0
- package/dist/agents/index.d.ts +34 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +51 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/instance-manager.d.ts +262 -0
- package/dist/agents/instance-manager.d.ts.map +1 -0
- package/dist/agents/instance-manager.js +850 -0
- package/dist/agents/instance-manager.js.map +1 -0
- package/dist/agents/locks.d.ts +81 -0
- package/dist/agents/locks.d.ts.map +1 -0
- package/dist/agents/locks.js +234 -0
- package/dist/agents/locks.js.map +1 -0
- package/dist/agents/memory.d.ts +37 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +92 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/monitor.d.ts +16 -0
- package/dist/agents/monitor.d.ts.map +1 -0
- package/dist/agents/monitor.js +235 -0
- package/dist/agents/monitor.js.map +1 -0
- package/dist/agents/orchestration.d.ts +218 -0
- package/dist/agents/orchestration.d.ts.map +1 -0
- package/dist/agents/orchestration.js +715 -0
- package/dist/agents/orchestration.js.map +1 -0
- package/dist/agents/recover.d.ts +30 -0
- package/dist/agents/recover.d.ts.map +1 -0
- package/dist/agents/recover.js +166 -0
- package/dist/agents/recover.js.map +1 -0
- package/dist/agents/reflection.d.ts +36 -0
- package/dist/agents/reflection.d.ts.map +1 -0
- package/dist/agents/reflection.js +198 -0
- package/dist/agents/reflection.js.map +1 -0
- package/dist/agents/runtime/bus.d.ts +46 -0
- package/dist/agents/runtime/bus.d.ts.map +1 -0
- package/dist/agents/runtime/bus.js +174 -0
- package/dist/agents/runtime/bus.js.map +1 -0
- package/dist/agents/runtime/config.d.ts +14 -0
- package/dist/agents/runtime/config.d.ts.map +1 -0
- package/dist/agents/runtime/config.js +100 -0
- package/dist/agents/runtime/config.js.map +1 -0
- package/dist/agents/runtime/driver.d.ts +25 -0
- package/dist/agents/runtime/driver.d.ts.map +1 -0
- package/dist/agents/runtime/driver.js +215 -0
- package/dist/agents/runtime/driver.js.map +1 -0
- package/dist/agents/runtime/errors.d.ts +30 -0
- package/dist/agents/runtime/errors.d.ts.map +1 -0
- package/dist/agents/runtime/errors.js +40 -0
- package/dist/agents/runtime/errors.js.map +1 -0
- package/dist/agents/runtime/index.d.ts +29 -0
- package/dist/agents/runtime/index.d.ts.map +1 -0
- package/dist/agents/runtime/index.js +54 -0
- package/dist/agents/runtime/index.js.map +1 -0
- package/dist/agents/runtime/lifecycle.d.ts +46 -0
- package/dist/agents/runtime/lifecycle.d.ts.map +1 -0
- package/dist/agents/runtime/lifecycle.js +116 -0
- package/dist/agents/runtime/lifecycle.js.map +1 -0
- package/dist/agents/runtime/manager.d.ts +129 -0
- package/dist/agents/runtime/manager.d.ts.map +1 -0
- package/dist/agents/runtime/manager.js +947 -0
- package/dist/agents/runtime/manager.js.map +1 -0
- package/dist/agents/runtime/registry.d.ts +66 -0
- package/dist/agents/runtime/registry.d.ts.map +1 -0
- package/dist/agents/runtime/registry.js +195 -0
- package/dist/agents/runtime/registry.js.map +1 -0
- package/dist/agents/runtime/resources.d.ts +49 -0
- package/dist/agents/runtime/resources.d.ts.map +1 -0
- package/dist/agents/runtime/resources.js +146 -0
- package/dist/agents/runtime/resources.js.map +1 -0
- package/dist/agents/runtime/types.d.ts +168 -0
- package/dist/agents/runtime/types.d.ts.map +1 -0
- package/dist/agents/runtime/types.js +24 -0
- package/dist/agents/runtime/types.js.map +1 -0
- package/dist/agents/runtime.d.ts +240 -0
- package/dist/agents/runtime.d.ts.map +1 -0
- package/dist/agents/runtime.js +577 -0
- package/dist/agents/runtime.js.map +1 -0
- package/dist/agents/spawn.d.ts +49 -0
- package/dist/agents/spawn.d.ts.map +1 -0
- package/dist/agents/spawn.js +975 -0
- package/dist/agents/spawn.js.map +1 -0
- package/dist/agents/store.d.ts +29 -0
- package/dist/agents/store.d.ts.map +1 -0
- package/dist/agents/store.js +174 -0
- package/dist/agents/store.js.map +1 -0
- package/dist/agents/triage.d.ts +23 -0
- package/dist/agents/triage.d.ts.map +1 -0
- package/dist/agents/triage.js +81 -0
- package/dist/agents/triage.js.map +1 -0
- package/dist/agents/types.d.ts +37 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/agents/workflow.d.ts +137 -0
- package/dist/agents/workflow.d.ts.map +1 -0
- package/dist/agents/workflow.js +542 -0
- package/dist/agents/workflow.js.map +1 -0
- package/dist/auth/crypto.d.ts +22 -0
- package/dist/auth/crypto.d.ts.map +1 -0
- package/dist/auth/crypto.js +42 -0
- package/dist/auth/crypto.js.map +1 -0
- package/dist/auth/identity.d.ts +89 -0
- package/dist/auth/identity.d.ts.map +1 -0
- package/dist/auth/identity.js +264 -0
- package/dist/auth/identity.js.map +1 -0
- package/dist/avatar/client.d.ts +34 -0
- package/dist/avatar/client.d.ts.map +1 -0
- package/dist/avatar/client.js +172 -0
- package/dist/avatar/client.js.map +1 -0
- package/dist/avatar/sidecar.d.ts +16 -0
- package/dist/avatar/sidecar.d.ts.map +1 -0
- package/dist/avatar/sidecar.js +125 -0
- package/dist/avatar/sidecar.js.map +1 -0
- package/dist/board/provider.d.ts +13 -0
- package/dist/board/provider.d.ts.map +1 -0
- package/dist/board/provider.js +19 -0
- package/dist/board/provider.js.map +1 -0
- package/dist/board/types.d.ts +76 -0
- package/dist/board/types.d.ts.map +1 -0
- package/dist/board/types.js +7 -0
- package/dist/board/types.js.map +1 -0
- package/dist/brain/skills.d.ts +177 -0
- package/dist/brain/skills.d.ts.map +1 -0
- package/dist/brain/skills.js +452 -0
- package/dist/brain/skills.js.map +1 -0
- package/dist/brain.d.ts +42 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +98 -0
- package/dist/brain.js.map +1 -0
- package/dist/browser/sessions.d.ts +23 -0
- package/dist/browser/sessions.d.ts.map +1 -0
- package/dist/browser/sessions.js +121 -0
- package/dist/browser/sessions.js.map +1 -0
- package/dist/cache/file.d.ts +56 -0
- package/dist/cache/file.d.ts.map +1 -0
- package/dist/cache/file.js +176 -0
- package/dist/cache/file.js.map +1 -0
- package/dist/cache/index.d.ts +64 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +108 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/keys.d.ts +29 -0
- package/dist/cache/keys.d.ts.map +1 -0
- package/dist/cache/keys.js +52 -0
- package/dist/cache/keys.js.map +1 -0
- package/dist/cache/llm-cache.d.ts +70 -0
- package/dist/cache/llm-cache.d.ts.map +1 -0
- package/dist/cache/llm-cache.js +165 -0
- package/dist/cache/llm-cache.js.map +1 -0
- package/dist/cache/memory.d.ts +53 -0
- package/dist/cache/memory.d.ts.map +1 -0
- package/dist/cache/memory.js +114 -0
- package/dist/cache/memory.js.map +1 -0
- package/dist/calendar/google-adapter.d.ts +16 -0
- package/dist/calendar/google-adapter.d.ts.map +1 -0
- package/dist/calendar/google-adapter.js +163 -0
- package/dist/calendar/google-adapter.js.map +1 -0
- package/dist/calendar/index.d.ts +8 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/index.js +7 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/calendar/routes.d.ts +7 -0
- package/dist/calendar/routes.d.ts.map +1 -0
- package/dist/calendar/routes.js +199 -0
- package/dist/calendar/routes.js.map +1 -0
- package/dist/calendar/store.d.ts +73 -0
- package/dist/calendar/store.d.ts.map +1 -0
- package/dist/calendar/store.js +373 -0
- package/dist/calendar/store.js.map +1 -0
- package/dist/calendar/types.d.ts +99 -0
- package/dist/calendar/types.d.ts.map +1 -0
- package/dist/calendar/types.js +7 -0
- package/dist/calendar/types.js.map +1 -0
- package/dist/capabilities/definitions/board.d.ts +7 -0
- package/dist/capabilities/definitions/board.d.ts.map +1 -0
- package/dist/capabilities/definitions/board.js +232 -0
- package/dist/capabilities/definitions/board.js.map +1 -0
- package/dist/capabilities/definitions/browser.d.ts +18 -0
- package/dist/capabilities/definitions/browser.d.ts.map +1 -0
- package/dist/capabilities/definitions/browser.js +242 -0
- package/dist/capabilities/definitions/browser.js.map +1 -0
- package/dist/capabilities/definitions/calendar-context.d.ts +8 -0
- package/dist/capabilities/definitions/calendar-context.d.ts.map +1 -0
- package/dist/capabilities/definitions/calendar-context.js +41 -0
- package/dist/capabilities/definitions/calendar-context.js.map +1 -0
- package/dist/capabilities/definitions/calendar.d.ts +7 -0
- package/dist/capabilities/definitions/calendar.d.ts.map +1 -0
- package/dist/capabilities/definitions/calendar.js +173 -0
- package/dist/capabilities/definitions/calendar.js.map +1 -0
- package/dist/capabilities/definitions/docs.d.ts +6 -0
- package/dist/capabilities/definitions/docs.d.ts.map +1 -0
- package/dist/capabilities/definitions/docs.js +62 -0
- package/dist/capabilities/definitions/docs.js.map +1 -0
- package/dist/capabilities/definitions/email-context.d.ts +7 -0
- package/dist/capabilities/definitions/email-context.d.ts.map +1 -0
- package/dist/capabilities/definitions/email-context.js +55 -0
- package/dist/capabilities/definitions/email-context.js.map +1 -0
- package/dist/capabilities/definitions/email.d.ts +7 -0
- package/dist/capabilities/definitions/email.d.ts.map +1 -0
- package/dist/capabilities/definitions/email.js +94 -0
- package/dist/capabilities/definitions/email.js.map +1 -0
- package/dist/capabilities/definitions/task-done.d.ts +10 -0
- package/dist/capabilities/definitions/task-done.d.ts.map +1 -0
- package/dist/capabilities/definitions/task-done.js +83 -0
- package/dist/capabilities/definitions/task-done.js.map +1 -0
- package/dist/capabilities/definitions/vault-context.d.ts +12 -0
- package/dist/capabilities/definitions/vault-context.d.ts.map +1 -0
- package/dist/capabilities/definitions/vault-context.js +62 -0
- package/dist/capabilities/definitions/vault-context.js.map +1 -0
- package/dist/capabilities/definitions/web-search-context.d.ts +22 -0
- package/dist/capabilities/definitions/web-search-context.d.ts.map +1 -0
- package/dist/capabilities/definitions/web-search-context.js +60 -0
- package/dist/capabilities/definitions/web-search-context.js.map +1 -0
- package/dist/capabilities/index.d.ts +18 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +21 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/registry.d.ts +84 -0
- package/dist/capabilities/registry.d.ts.map +1 -0
- package/dist/capabilities/registry.js +248 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/capabilities/types.d.ts +157 -0
- package/dist/capabilities/types.d.ts.map +1 -0
- package/dist/capabilities/types.js +35 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/channels/whatsapp.d.ts +88 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js +200 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli/backup.d.ts +13 -0
- package/dist/cli/backup.d.ts.map +1 -0
- package/dist/cli/backup.js +176 -0
- package/dist/cli/backup.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +231 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/defaults.d.ts +45 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +54 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/contacts/index.d.ts +3 -0
- package/dist/contacts/index.d.ts.map +1 -0
- package/dist/contacts/index.js +2 -0
- package/dist/contacts/index.js.map +1 -0
- package/dist/contacts/store.d.ts +58 -0
- package/dist/contacts/store.d.ts.map +1 -0
- package/dist/contacts/store.js +278 -0
- package/dist/contacts/store.js.map +1 -0
- package/dist/contacts/types.d.ts +47 -0
- package/dist/contacts/types.d.ts.map +1 -0
- package/dist/contacts/types.js +5 -0
- package/dist/contacts/types.js.map +1 -0
- package/dist/context/assembler.d.ts +26 -0
- package/dist/context/assembler.d.ts.map +1 -0
- package/dist/context/assembler.js +65 -0
- package/dist/context/assembler.js.map +1 -0
- package/dist/context/compaction.d.ts +34 -0
- package/dist/context/compaction.d.ts.map +1 -0
- package/dist/context/compaction.js +84 -0
- package/dist/context/compaction.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/core/registry/index.d.ts +12 -0
- package/dist/core/registry/index.d.ts.map +1 -0
- package/dist/core/registry/index.js +14 -0
- package/dist/core/registry/index.js.map +1 -0
- package/dist/core/registry/publisher.d.ts +22 -0
- package/dist/core/registry/publisher.d.ts.map +1 -0
- package/dist/core/registry/publisher.js +195 -0
- package/dist/core/registry/publisher.js.map +1 -0
- package/dist/core/registry/registry.d.ts +92 -0
- package/dist/core/registry/registry.d.ts.map +1 -0
- package/dist/core/registry/registry.js +254 -0
- package/dist/core/registry/registry.js.map +1 -0
- package/dist/core/registry/search.d.ts +12 -0
- package/dist/core/registry/search.d.ts.map +1 -0
- package/dist/core/registry/search.js +132 -0
- package/dist/core/registry/search.js.map +1 -0
- package/dist/core/registry/store.d.ts +55 -0
- package/dist/core/registry/store.d.ts.map +1 -0
- package/dist/core/registry/store.js +185 -0
- package/dist/core/registry/store.js.map +1 -0
- package/dist/core/registry/types.d.ts +141 -0
- package/dist/core/registry/types.d.ts.map +1 -0
- package/dist/core/registry/types.js +30 -0
- package/dist/core/registry/types.js.map +1 -0
- package/dist/core/registry/versions.d.ts +56 -0
- package/dist/core/registry/versions.d.ts.map +1 -0
- package/dist/core/registry/versions.js +101 -0
- package/dist/core/registry/versions.js.map +1 -0
- package/dist/credentials/store.d.ts +59 -0
- package/dist/credentials/store.d.ts.map +1 -0
- package/dist/credentials/store.js +178 -0
- package/dist/credentials/store.js.map +1 -0
- package/dist/files/agent-api.d.ts +50 -0
- package/dist/files/agent-api.d.ts.map +1 -0
- package/dist/files/agent-api.js +126 -0
- package/dist/files/agent-api.js.map +1 -0
- package/dist/files/compress.d.ts +20 -0
- package/dist/files/compress.d.ts.map +1 -0
- package/dist/files/compress.js +83 -0
- package/dist/files/compress.js.map +1 -0
- package/dist/files/extract.d.ts +11 -0
- package/dist/files/extract.d.ts.map +1 -0
- package/dist/files/extract.js +33 -0
- package/dist/files/extract.js.map +1 -0
- package/dist/files/gdrive.d.ts +56 -0
- package/dist/files/gdrive.d.ts.map +1 -0
- package/dist/files/gdrive.js +246 -0
- package/dist/files/gdrive.js.map +1 -0
- package/dist/files/ingest-folder.d.ts +22 -0
- package/dist/files/ingest-folder.d.ts.map +1 -0
- package/dist/files/ingest-folder.js +71 -0
- package/dist/files/ingest-folder.js.map +1 -0
- package/dist/files/ingest.d.ts +13 -0
- package/dist/files/ingest.d.ts.map +1 -0
- package/dist/files/ingest.js +127 -0
- package/dist/files/ingest.js.map +1 -0
- package/dist/files/manager.d.ts +117 -0
- package/dist/files/manager.d.ts.map +1 -0
- package/dist/files/manager.js +306 -0
- package/dist/files/manager.js.map +1 -0
- package/dist/files/store.d.ts +41 -0
- package/dist/files/store.d.ts.map +1 -0
- package/dist/files/store.js +271 -0
- package/dist/files/store.js.map +1 -0
- package/dist/files/templates.d.ts +45 -0
- package/dist/files/templates.d.ts.map +1 -0
- package/dist/files/templates.js +179 -0
- package/dist/files/templates.js.map +1 -0
- package/dist/files/types.d.ts +115 -0
- package/dist/files/types.d.ts.map +1 -0
- package/dist/files/types.js +20 -0
- package/dist/files/types.js.map +1 -0
- package/dist/files/validate.d.ts +15 -0
- package/dist/files/validate.d.ts.map +1 -0
- package/dist/files/validate.js +213 -0
- package/dist/files/validate.js.map +1 -0
- package/dist/files/version.d.ts +31 -0
- package/dist/files/version.d.ts.map +1 -0
- package/dist/files/version.js +129 -0
- package/dist/files/version.js.map +1 -0
- package/dist/github/client.d.ts +83 -0
- package/dist/github/client.d.ts.map +1 -0
- package/dist/github/client.js +408 -0
- package/dist/github/client.js.map +1 -0
- package/dist/github/commit-analysis.d.ts +30 -0
- package/dist/github/commit-analysis.d.ts.map +1 -0
- package/dist/github/commit-analysis.js +276 -0
- package/dist/github/commit-analysis.js.map +1 -0
- package/dist/github/contributor-stats.d.ts +18 -0
- package/dist/github/contributor-stats.d.ts.map +1 -0
- package/dist/github/contributor-stats.js +119 -0
- package/dist/github/contributor-stats.js.map +1 -0
- package/dist/github/issue-sla.d.ts +25 -0
- package/dist/github/issue-sla.d.ts.map +1 -0
- package/dist/github/issue-sla.js +220 -0
- package/dist/github/issue-sla.js.map +1 -0
- package/dist/github/issue-triage.d.ts +49 -0
- package/dist/github/issue-triage.d.ts.map +1 -0
- package/dist/github/issue-triage.js +286 -0
- package/dist/github/issue-triage.js.map +1 -0
- package/dist/github/pr-readiness.d.ts +18 -0
- package/dist/github/pr-readiness.d.ts.map +1 -0
- package/dist/github/pr-readiness.js +197 -0
- package/dist/github/pr-readiness.js.map +1 -0
- package/dist/github/pr-review.d.ts +17 -0
- package/dist/github/pr-review.d.ts.map +1 -0
- package/dist/github/pr-review.js +410 -0
- package/dist/github/pr-review.js.map +1 -0
- package/dist/github/release-notes.d.ts +32 -0
- package/dist/github/release-notes.d.ts.map +1 -0
- package/dist/github/release-notes.js +227 -0
- package/dist/github/release-notes.js.map +1 -0
- package/dist/github/repo-health.d.ts +17 -0
- package/dist/github/repo-health.d.ts.map +1 -0
- package/dist/github/repo-health.js +303 -0
- package/dist/github/repo-health.js.map +1 -0
- package/dist/github/retry.d.ts +39 -0
- package/dist/github/retry.d.ts.map +1 -0
- package/dist/github/retry.js +117 -0
- package/dist/github/retry.js.map +1 -0
- package/dist/github/types.d.ts +527 -0
- package/dist/github/types.d.ts.map +1 -0
- package/dist/github/types.js +8 -0
- package/dist/github/types.js.map +1 -0
- package/dist/github/webhooks.d.ts +36 -0
- package/dist/github/webhooks.d.ts.map +1 -0
- package/dist/github/webhooks.js +153 -0
- package/dist/github/webhooks.js.map +1 -0
- package/dist/goals/loop.d.ts +27 -0
- package/dist/goals/loop.d.ts.map +1 -0
- package/dist/goals/loop.js +239 -0
- package/dist/goals/loop.js.map +1 -0
- package/dist/goals/notifications.d.ts +20 -0
- package/dist/goals/notifications.d.ts.map +1 -0
- package/dist/goals/notifications.js +101 -0
- package/dist/goals/notifications.js.map +1 -0
- package/dist/goals/timer.d.ts +21 -0
- package/dist/goals/timer.d.ts.map +1 -0
- package/dist/goals/timer.js +60 -0
- package/dist/goals/timer.js.map +1 -0
- package/dist/google/auth.d.ts +84 -0
- package/dist/google/auth.d.ts.map +1 -0
- package/dist/google/auth.js +323 -0
- package/dist/google/auth.js.map +1 -0
- package/dist/google/calendar-timer.d.ts +20 -0
- package/dist/google/calendar-timer.d.ts.map +1 -0
- package/dist/google/calendar-timer.js +91 -0
- package/dist/google/calendar-timer.js.map +1 -0
- package/dist/google/calendar.d.ts +126 -0
- package/dist/google/calendar.d.ts.map +1 -0
- package/dist/google/calendar.js +270 -0
- package/dist/google/calendar.js.map +1 -0
- package/dist/google/docs.d.ts +87 -0
- package/dist/google/docs.d.ts.map +1 -0
- package/dist/google/docs.js +309 -0
- package/dist/google/docs.js.map +1 -0
- package/dist/google/gmail-send.d.ts +58 -0
- package/dist/google/gmail-send.d.ts.map +1 -0
- package/dist/google/gmail-send.js +219 -0
- package/dist/google/gmail-send.js.map +1 -0
- package/dist/google/gmail-timer.d.ts +34 -0
- package/dist/google/gmail-timer.d.ts.map +1 -0
- package/dist/google/gmail-timer.js +223 -0
- package/dist/google/gmail-timer.js.map +1 -0
- package/dist/google/gmail.d.ts +172 -0
- package/dist/google/gmail.d.ts.map +1 -0
- package/dist/google/gmail.js +470 -0
- package/dist/google/gmail.js.map +1 -0
- package/dist/google/tasks-timer.d.ts +20 -0
- package/dist/google/tasks-timer.d.ts.map +1 -0
- package/dist/google/tasks-timer.js +107 -0
- package/dist/google/tasks-timer.js.map +1 -0
- package/dist/google/tasks.d.ts +167 -0
- package/dist/google/tasks.d.ts.map +1 -0
- package/dist/google/tasks.js +331 -0
- package/dist/google/tasks.js.map +1 -0
- package/dist/google/temporal.d.ts +76 -0
- package/dist/google/temporal.d.ts.map +1 -0
- package/dist/google/temporal.js +176 -0
- package/dist/google/temporal.js.map +1 -0
- package/dist/health/alert-defaults.d.ts +12 -0
- package/dist/health/alert-defaults.d.ts.map +1 -0
- package/dist/health/alert-defaults.js +88 -0
- package/dist/health/alert-defaults.js.map +1 -0
- package/dist/health/alert-types.d.ts +97 -0
- package/dist/health/alert-types.d.ts.map +1 -0
- package/dist/health/alert-types.js +8 -0
- package/dist/health/alert-types.js.map +1 -0
- package/dist/health/alerting.d.ts +66 -0
- package/dist/health/alerting.d.ts.map +1 -0
- package/dist/health/alerting.js +373 -0
- package/dist/health/alerting.js.map +1 -0
- package/dist/health/checker.d.ts +32 -0
- package/dist/health/checker.d.ts.map +1 -0
- package/dist/health/checker.js +138 -0
- package/dist/health/checker.js.map +1 -0
- package/dist/health/checks/openrouter.d.ts +29 -0
- package/dist/health/checks/openrouter.d.ts.map +1 -0
- package/dist/health/checks/openrouter.js +75 -0
- package/dist/health/checks/openrouter.js.map +1 -0
- package/dist/health/checks.d.ts +26 -0
- package/dist/health/checks.d.ts.map +1 -0
- package/dist/health/checks.js +122 -0
- package/dist/health/checks.js.map +1 -0
- package/dist/health/components.d.ts +38 -0
- package/dist/health/components.d.ts.map +1 -0
- package/dist/health/components.js +112 -0
- package/dist/health/components.js.map +1 -0
- package/dist/health/index.d.ts +19 -0
- package/dist/health/index.d.ts.map +1 -0
- package/dist/health/index.js +23 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/recovery.d.ts +42 -0
- package/dist/health/recovery.d.ts.map +1 -0
- package/dist/health/recovery.js +138 -0
- package/dist/health/recovery.js.map +1 -0
- package/dist/health/types.d.ts +68 -0
- package/dist/health/types.d.ts.map +1 -0
- package/dist/health/types.js +5 -0
- package/dist/health/types.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/instance.d.ts +24 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +48 -0
- package/dist/instance.js.map +1 -0
- package/dist/integrations/github.d.ts +83 -0
- package/dist/integrations/github.d.ts.map +1 -0
- package/dist/integrations/github.js +331 -0
- package/dist/integrations/github.js.map +1 -0
- package/dist/integrations/google-tasks.d.ts +232 -0
- package/dist/integrations/google-tasks.d.ts.map +1 -0
- package/dist/integrations/google-tasks.js +432 -0
- package/dist/integrations/google-tasks.js.map +1 -0
- package/dist/learning/extractor.d.ts +28 -0
- package/dist/learning/extractor.d.ts.map +1 -0
- package/dist/learning/extractor.js +135 -0
- package/dist/learning/extractor.js.map +1 -0
- package/dist/lib/BasePlugin.d.ts +58 -0
- package/dist/lib/BasePlugin.d.ts.map +1 -0
- package/dist/lib/BasePlugin.js +181 -0
- package/dist/lib/BasePlugin.js.map +1 -0
- package/dist/lib/PluginRegistry.d.ts +56 -0
- package/dist/lib/PluginRegistry.d.ts.map +1 -0
- package/dist/lib/PluginRegistry.js +172 -0
- package/dist/lib/PluginRegistry.js.map +1 -0
- package/dist/lib/brain-io.d.ts +60 -0
- package/dist/lib/brain-io.d.ts.map +1 -0
- package/dist/lib/brain-io.js +180 -0
- package/dist/lib/brain-io.js.map +1 -0
- package/dist/lib/encryption-config.d.ts +16 -0
- package/dist/lib/encryption-config.d.ts.map +1 -0
- package/dist/lib/encryption-config.js +40 -0
- package/dist/lib/encryption-config.js.map +1 -0
- package/dist/lib/encryption.d.ts +19 -0
- package/dist/lib/encryption.d.ts.map +1 -0
- package/dist/lib/encryption.js +65 -0
- package/dist/lib/encryption.js.map +1 -0
- package/dist/lib/key-store.d.ts +24 -0
- package/dist/lib/key-store.d.ts.map +1 -0
- package/dist/lib/key-store.js +38 -0
- package/dist/lib/key-store.js.map +1 -0
- package/dist/lib/schema-migration.d.ts +34 -0
- package/dist/lib/schema-migration.d.ts.map +1 -0
- package/dist/lib/schema-migration.js +77 -0
- package/dist/lib/schema-migration.js.map +1 -0
- package/dist/library/brain-shadow.d.ts +10 -0
- package/dist/library/brain-shadow.d.ts.map +1 -0
- package/dist/library/brain-shadow.js +158 -0
- package/dist/library/brain-shadow.js.map +1 -0
- package/dist/library/index.d.ts +7 -0
- package/dist/library/index.d.ts.map +1 -0
- package/dist/library/index.js +6 -0
- package/dist/library/index.js.map +1 -0
- package/dist/library/routes.d.ts +7 -0
- package/dist/library/routes.d.ts.map +1 -0
- package/dist/library/routes.js +473 -0
- package/dist/library/routes.js.map +1 -0
- package/dist/library/store.d.ts +54 -0
- package/dist/library/store.d.ts.map +1 -0
- package/dist/library/store.js +403 -0
- package/dist/library/store.js.map +1 -0
- package/dist/library/types.d.ts +56 -0
- package/dist/library/types.d.ts.map +1 -0
- package/dist/library/types.js +12 -0
- package/dist/library/types.js.map +1 -0
- package/dist/llm/cache.d.ts +42 -0
- package/dist/llm/cache.d.ts.map +1 -0
- package/dist/llm/cache.js +104 -0
- package/dist/llm/cache.js.map +1 -0
- package/dist/llm/complete.d.ts +24 -0
- package/dist/llm/complete.d.ts.map +1 -0
- package/dist/llm/complete.js +56 -0
- package/dist/llm/complete.js.map +1 -0
- package/dist/llm/errors.d.ts +28 -0
- package/dist/llm/errors.d.ts.map +1 -0
- package/dist/llm/errors.js +82 -0
- package/dist/llm/errors.js.map +1 -0
- package/dist/llm/ollama.d.ts +21 -0
- package/dist/llm/ollama.d.ts.map +1 -0
- package/dist/llm/ollama.js +116 -0
- package/dist/llm/ollama.js.map +1 -0
- package/dist/llm/openrouter.d.ts +13 -0
- package/dist/llm/openrouter.d.ts.map +1 -0
- package/dist/llm/openrouter.js +105 -0
- package/dist/llm/openrouter.js.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +8 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.js +189 -0
- package/dist/llm/providers/anthropic.js.map +1 -0
- package/dist/llm/providers/index.d.ts +20 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +47 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/ollama.d.ts +13 -0
- package/dist/llm/providers/ollama.d.ts.map +1 -0
- package/dist/llm/providers/ollama.js +188 -0
- package/dist/llm/providers/ollama.js.map +1 -0
- package/dist/llm/providers/openai.d.ts +8 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/providers/openai.js +144 -0
- package/dist/llm/providers/openai.js.map +1 -0
- package/dist/llm/providers/openrouter.d.ts +7 -0
- package/dist/llm/providers/openrouter.d.ts.map +1 -0
- package/dist/llm/providers/openrouter.js +158 -0
- package/dist/llm/providers/openrouter.js.map +1 -0
- package/dist/llm/providers/types.d.ts +29 -0
- package/dist/llm/providers/types.d.ts.map +1 -0
- package/dist/llm/providers/types.js +6 -0
- package/dist/llm/providers/types.js.map +1 -0
- package/dist/llm/retry.d.ts +29 -0
- package/dist/llm/retry.d.ts.map +1 -0
- package/dist/llm/retry.js +139 -0
- package/dist/llm/retry.js.map +1 -0
- package/dist/memory/file-backed.d.ts +36 -0
- package/dist/memory/file-backed.d.ts.map +1 -0
- package/dist/memory/file-backed.js +178 -0
- package/dist/memory/file-backed.js.map +1 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +6 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/long-term.d.ts +38 -0
- package/dist/memory/long-term.d.ts.map +1 -0
- package/dist/memory/long-term.js +58 -0
- package/dist/memory/long-term.js.map +1 -0
- package/dist/memory/vector-index.d.ts +55 -0
- package/dist/memory/vector-index.d.ts.map +1 -0
- package/dist/memory/vector-index.js +207 -0
- package/dist/memory/vector-index.js.map +1 -0
- package/dist/memory/visual.d.ts +53 -0
- package/dist/memory/visual.d.ts.map +1 -0
- package/dist/memory/visual.js +218 -0
- package/dist/memory/visual.js.map +1 -0
- package/dist/memory/working.d.ts +12 -0
- package/dist/memory/working.d.ts.map +1 -0
- package/dist/memory/working.js +34 -0
- package/dist/memory/working.js.map +1 -0
- package/dist/metrics/aggregator.d.ts +58 -0
- package/dist/metrics/aggregator.d.ts.map +1 -0
- package/dist/metrics/aggregator.js +253 -0
- package/dist/metrics/aggregator.js.map +1 -0
- package/dist/metrics/collector.d.ts +26 -0
- package/dist/metrics/collector.d.ts.map +1 -0
- package/dist/metrics/collector.js +346 -0
- package/dist/metrics/collector.js.map +1 -0
- package/dist/metrics/firewall-metrics.d.ts +95 -0
- package/dist/metrics/firewall-metrics.d.ts.map +1 -0
- package/dist/metrics/firewall-metrics.js +261 -0
- package/dist/metrics/firewall-metrics.js.map +1 -0
- package/dist/metrics/index.d.ts +20 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +23 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instruments.d.ts +89 -0
- package/dist/metrics/instruments.d.ts.map +1 -0
- package/dist/metrics/instruments.js +172 -0
- package/dist/metrics/instruments.js.map +1 -0
- package/dist/metrics/middleware.d.ts +12 -0
- package/dist/metrics/middleware.d.ts.map +1 -0
- package/dist/metrics/middleware.js +47 -0
- package/dist/metrics/middleware.js.map +1 -0
- package/dist/metrics/prometheus.d.ts +39 -0
- package/dist/metrics/prometheus.d.ts.map +1 -0
- package/dist/metrics/prometheus.js +115 -0
- package/dist/metrics/prometheus.js.map +1 -0
- package/dist/metrics/registry.d.ts +58 -0
- package/dist/metrics/registry.d.ts.map +1 -0
- package/dist/metrics/registry.js +145 -0
- package/dist/metrics/registry.js.map +1 -0
- package/dist/metrics/reporter.d.ts +21 -0
- package/dist/metrics/reporter.d.ts.map +1 -0
- package/dist/metrics/reporter.js +207 -0
- package/dist/metrics/reporter.js.map +1 -0
- package/dist/metrics/store.d.ts +47 -0
- package/dist/metrics/store.d.ts.map +1 -0
- package/dist/metrics/store.js +209 -0
- package/dist/metrics/store.js.map +1 -0
- package/dist/metrics/system.d.ts +20 -0
- package/dist/metrics/system.d.ts.map +1 -0
- package/dist/metrics/system.js +109 -0
- package/dist/metrics/system.js.map +1 -0
- package/dist/metrics/types.d.ts +101 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +6 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/modules/index.d.ts +6 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +6 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/registry.d.ts +36 -0
- package/dist/modules/registry.d.ts.map +1 -0
- package/dist/modules/registry.js +155 -0
- package/dist/modules/registry.js.map +1 -0
- package/dist/modules/types.d.ts +37 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +9 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/notifications/channel.d.ts +25 -0
- package/dist/notifications/channel.d.ts.map +1 -0
- package/dist/notifications/channel.js +83 -0
- package/dist/notifications/channel.js.map +1 -0
- package/dist/notifications/email.d.ts +27 -0
- package/dist/notifications/email.d.ts.map +1 -0
- package/dist/notifications/email.js +72 -0
- package/dist/notifications/email.js.map +1 -0
- package/dist/notifications/index.d.ts +16 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +12 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/phone.d.ts +16 -0
- package/dist/notifications/phone.d.ts.map +1 -0
- package/dist/notifications/phone.js +48 -0
- package/dist/notifications/phone.js.map +1 -0
- package/dist/notifications/sms.d.ts +26 -0
- package/dist/notifications/sms.d.ts.map +1 -0
- package/dist/notifications/sms.js +65 -0
- package/dist/notifications/sms.js.map +1 -0
- package/dist/notifications/webhook.d.ts +28 -0
- package/dist/notifications/webhook.d.ts.map +1 -0
- package/dist/notifications/webhook.js +65 -0
- package/dist/notifications/webhook.js.map +1 -0
- package/dist/openloop/foldback.d.ts +24 -0
- package/dist/openloop/foldback.d.ts.map +1 -0
- package/dist/openloop/foldback.js +127 -0
- package/dist/openloop/foldback.js.map +1 -0
- package/dist/openloop/index.d.ts +11 -0
- package/dist/openloop/index.d.ts.map +1 -0
- package/dist/openloop/index.js +9 -0
- package/dist/openloop/index.js.map +1 -0
- package/dist/openloop/lifecycle.d.ts +16 -0
- package/dist/openloop/lifecycle.d.ts.map +1 -0
- package/dist/openloop/lifecycle.js +304 -0
- package/dist/openloop/lifecycle.js.map +1 -0
- package/dist/openloop/resolution-scanner.d.ts +17 -0
- package/dist/openloop/resolution-scanner.d.ts.map +1 -0
- package/dist/openloop/resolution-scanner.js +551 -0
- package/dist/openloop/resolution-scanner.js.map +1 -0
- package/dist/openloop/scanner.d.ts +28 -0
- package/dist/openloop/scanner.d.ts.map +1 -0
- package/dist/openloop/scanner.js +587 -0
- package/dist/openloop/scanner.js.map +1 -0
- package/dist/openloop/store.d.ts +41 -0
- package/dist/openloop/store.d.ts.map +1 -0
- package/dist/openloop/store.js +154 -0
- package/dist/openloop/store.js.map +1 -0
- package/dist/openloop/types.d.ts +94 -0
- package/dist/openloop/types.d.ts.map +1 -0
- package/dist/openloop/types.js +6 -0
- package/dist/openloop/types.js.map +1 -0
- package/dist/plugins/google-tasks/index.d.ts +55 -0
- package/dist/plugins/google-tasks/index.d.ts.map +1 -0
- package/dist/plugins/google-tasks/index.js +135 -0
- package/dist/plugins/google-tasks/index.js.map +1 -0
- package/dist/pulse/activation-event.d.ts +66 -0
- package/dist/pulse/activation-event.d.ts.map +1 -0
- package/dist/pulse/activation-event.js +139 -0
- package/dist/pulse/activation-event.js.map +1 -0
- package/dist/pulse/activation-log.d.ts +37 -0
- package/dist/pulse/activation-log.d.ts.map +1 -0
- package/dist/pulse/activation-log.js +101 -0
- package/dist/pulse/activation-log.js.map +1 -0
- package/dist/pulse/index.d.ts +11 -0
- package/dist/pulse/index.d.ts.map +1 -0
- package/dist/pulse/index.js +13 -0
- package/dist/pulse/index.js.map +1 -0
- package/dist/pulse/pressure.d.ts +69 -0
- package/dist/pulse/pressure.d.ts.map +1 -0
- package/dist/pulse/pressure.js +304 -0
- package/dist/pulse/pressure.js.map +1 -0
- package/dist/pulse/types.d.ts +89 -0
- package/dist/pulse/types.d.ts.map +1 -0
- package/dist/pulse/types.js +6 -0
- package/dist/pulse/types.js.map +1 -0
- package/dist/queue/grooming.d.ts +16 -0
- package/dist/queue/grooming.d.ts.map +1 -0
- package/dist/queue/grooming.js +269 -0
- package/dist/queue/grooming.js.map +1 -0
- package/dist/queue/provider.d.ts +50 -0
- package/dist/queue/provider.d.ts.map +1 -0
- package/dist/queue/provider.js +131 -0
- package/dist/queue/provider.js.map +1 -0
- package/dist/queue/store.d.ts +97 -0
- package/dist/queue/store.d.ts.map +1 -0
- package/dist/queue/store.js +448 -0
- package/dist/queue/store.js.map +1 -0
- package/dist/queue/types.d.ts +47 -0
- package/dist/queue/types.d.ts.map +1 -0
- package/dist/queue/types.js +22 -0
- package/dist/queue/types.js.map +1 -0
- package/dist/rate-limit.d.ts +26 -0
- package/dist/rate-limit.d.ts.map +1 -0
- package/dist/rate-limit.js +74 -0
- package/dist/rate-limit.js.map +1 -0
- package/dist/registry/discovery.d.ts +30 -0
- package/dist/registry/discovery.d.ts.map +1 -0
- package/dist/registry/discovery.js +171 -0
- package/dist/registry/discovery.js.map +1 -0
- package/dist/registry/index.d.ts +14 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +18 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/installer.d.ts +45 -0
- package/dist/registry/installer.d.ts.map +1 -0
- package/dist/registry/installer.js +175 -0
- package/dist/registry/installer.js.map +1 -0
- package/dist/registry/registry.d.ts +70 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +153 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/registry/store.d.ts +69 -0
- package/dist/registry/store.d.ts.map +1 -0
- package/dist/registry/store.js +242 -0
- package/dist/registry/store.js.map +1 -0
- package/dist/registry/types.d.ts +116 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +9 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/registry/validator.d.ts +24 -0
- package/dist/registry/validator.d.ts.map +1 -0
- package/dist/registry/validator.js +203 -0
- package/dist/registry/validator.js.map +1 -0
- package/dist/scheduling/index.d.ts +4 -0
- package/dist/scheduling/index.d.ts.map +1 -0
- package/dist/scheduling/index.js +3 -0
- package/dist/scheduling/index.js.map +1 -0
- package/dist/scheduling/store.d.ts +41 -0
- package/dist/scheduling/store.d.ts.map +1 -0
- package/dist/scheduling/store.js +237 -0
- package/dist/scheduling/store.js.map +1 -0
- package/dist/scheduling/timer.d.ts +25 -0
- package/dist/scheduling/timer.d.ts.map +1 -0
- package/dist/scheduling/timer.js +118 -0
- package/dist/scheduling/timer.js.map +1 -0
- package/dist/scheduling/types.d.ts +43 -0
- package/dist/scheduling/types.d.ts.map +1 -0
- package/dist/scheduling/types.js +5 -0
- package/dist/scheduling/types.js.map +1 -0
- package/dist/search/brain-docs.d.ts +20 -0
- package/dist/search/brain-docs.d.ts.map +1 -0
- package/dist/search/brain-docs.js +103 -0
- package/dist/search/brain-docs.js.map +1 -0
- package/dist/search/browse.d.ts +45 -0
- package/dist/search/browse.d.ts.map +1 -0
- package/dist/search/browse.js +225 -0
- package/dist/search/browse.js.map +1 -0
- package/dist/search/classify.d.ts +23 -0
- package/dist/search/classify.d.ts.map +1 -0
- package/dist/search/classify.js +132 -0
- package/dist/search/classify.js.map +1 -0
- package/dist/search/client.d.ts +32 -0
- package/dist/search/client.d.ts.map +1 -0
- package/dist/search/client.js +72 -0
- package/dist/search/client.js.map +1 -0
- package/dist/search/perplexity.d.ts +13 -0
- package/dist/search/perplexity.d.ts.map +1 -0
- package/dist/search/perplexity.js +41 -0
- package/dist/search/perplexity.js.map +1 -0
- package/dist/search/sidecar.d.ts +20 -0
- package/dist/search/sidecar.d.ts.map +1 -0
- package/dist/search/sidecar.js +103 -0
- package/dist/search/sidecar.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +4851 -0
- package/dist/server.js.map +1 -0
- package/dist/services/backlogReview.d.ts +66 -0
- package/dist/services/backlogReview.d.ts.map +1 -0
- package/dist/services/backlogReview.js +285 -0
- package/dist/services/backlogReview.js.map +1 -0
- package/dist/services/backup.d.ts +43 -0
- package/dist/services/backup.d.ts.map +1 -0
- package/dist/services/backup.js +334 -0
- package/dist/services/backup.js.map +1 -0
- package/dist/services/credit-monitor.d.ts +40 -0
- package/dist/services/credit-monitor.d.ts.map +1 -0
- package/dist/services/credit-monitor.js +147 -0
- package/dist/services/credit-monitor.js.map +1 -0
- package/dist/services/morningBriefing.d.ts +125 -0
- package/dist/services/morningBriefing.d.ts.map +1 -0
- package/dist/services/morningBriefing.js +660 -0
- package/dist/services/morningBriefing.js.map +1 -0
- package/dist/services/routine-patterns.d.ts +21 -0
- package/dist/services/routine-patterns.d.ts.map +1 -0
- package/dist/services/routine-patterns.js +46 -0
- package/dist/services/routine-patterns.js.map +1 -0
- package/dist/services/traceInsights.d.ts +53 -0
- package/dist/services/traceInsights.d.ts.map +1 -0
- package/dist/services/traceInsights.js +762 -0
- package/dist/services/traceInsights.js.map +1 -0
- package/dist/services/training.d.ts +63 -0
- package/dist/services/training.d.ts.map +1 -0
- package/dist/services/training.js +697 -0
- package/dist/services/training.js.map +1 -0
- package/dist/services/whatsapp.d.ts +45 -0
- package/dist/services/whatsapp.d.ts.map +1 -0
- package/dist/services/whatsapp.js +194 -0
- package/dist/services/whatsapp.js.map +1 -0
- package/dist/sessions/store.d.ts +21 -0
- package/dist/sessions/store.d.ts.map +1 -0
- package/dist/sessions/store.js +47 -0
- package/dist/sessions/store.js.map +1 -0
- package/dist/settings.d.ts +111 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +256 -0
- package/dist/settings.js.map +1 -0
- package/dist/skills/index.d.ts +10 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +11 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loader.d.ts +22 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +65 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/registry.d.ts +161 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +664 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/types.d.ts +83 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +31 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/skills/validator.d.ts +36 -0
- package/dist/skills/validator.d.ts.map +1 -0
- package/dist/skills/validator.js +114 -0
- package/dist/skills/validator.js.map +1 -0
- package/dist/slack/channels.d.ts +102 -0
- package/dist/slack/channels.d.ts.map +1 -0
- package/dist/slack/channels.js +277 -0
- package/dist/slack/channels.js.map +1 -0
- package/dist/slack/client.d.ts +151 -0
- package/dist/slack/client.d.ts.map +1 -0
- package/dist/slack/client.js +468 -0
- package/dist/slack/client.js.map +1 -0
- package/dist/slack/retry.d.ts +36 -0
- package/dist/slack/retry.d.ts.map +1 -0
- package/dist/slack/retry.js +100 -0
- package/dist/slack/retry.js.map +1 -0
- package/dist/slack/types.d.ts +271 -0
- package/dist/slack/types.d.ts.map +1 -0
- package/dist/slack/types.js +52 -0
- package/dist/slack/types.js.map +1 -0
- package/dist/slack/webhooks.d.ts +55 -0
- package/dist/slack/webhooks.d.ts.map +1 -0
- package/dist/slack/webhooks.js +285 -0
- package/dist/slack/webhooks.js.map +1 -0
- package/dist/stt/client.d.ts +18 -0
- package/dist/stt/client.d.ts.map +1 -0
- package/dist/stt/client.js +66 -0
- package/dist/stt/client.js.map +1 -0
- package/dist/stt/sidecar.d.ts +16 -0
- package/dist/stt/sidecar.d.ts.map +1 -0
- package/dist/stt/sidecar.js +115 -0
- package/dist/stt/sidecar.js.map +1 -0
- package/dist/tracing/bridge.d.ts +14 -0
- package/dist/tracing/bridge.d.ts.map +1 -0
- package/dist/tracing/bridge.js +70 -0
- package/dist/tracing/bridge.js.map +1 -0
- package/dist/tracing/correlation.d.ts +34 -0
- package/dist/tracing/correlation.d.ts.map +1 -0
- package/dist/tracing/correlation.js +49 -0
- package/dist/tracing/correlation.js.map +1 -0
- package/dist/tracing/index.d.ts +15 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +18 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/init.d.ts +42 -0
- package/dist/tracing/init.d.ts.map +1 -0
- package/dist/tracing/init.js +81 -0
- package/dist/tracing/init.js.map +1 -0
- package/dist/tracing/instrument.d.ts +39 -0
- package/dist/tracing/instrument.d.ts.map +1 -0
- package/dist/tracing/instrument.js +145 -0
- package/dist/tracing/instrument.js.map +1 -0
- package/dist/tracing/middleware.d.ts +18 -0
- package/dist/tracing/middleware.d.ts.map +1 -0
- package/dist/tracing/middleware.js +69 -0
- package/dist/tracing/middleware.js.map +1 -0
- package/dist/tracing/tracer.d.ts +105 -0
- package/dist/tracing/tracer.d.ts.map +1 -0
- package/dist/tracing/tracer.js +327 -0
- package/dist/tracing/tracer.js.map +1 -0
- package/dist/tts/client.d.ts +18 -0
- package/dist/tts/client.d.ts.map +1 -0
- package/dist/tts/client.js +48 -0
- package/dist/tts/client.js.map +1 -0
- package/dist/tts/sidecar.d.ts +16 -0
- package/dist/tts/sidecar.d.ts.map +1 -0
- package/dist/tts/sidecar.js +148 -0
- package/dist/tts/sidecar.js.map +1 -0
- package/dist/twilio/call.d.ts +22 -0
- package/dist/twilio/call.d.ts.map +1 -0
- package/dist/twilio/call.js +79 -0
- package/dist/twilio/call.js.map +1 -0
- package/dist/types/plugin.d.ts +342 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +10 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/logger.d.ts +53 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +169 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/vault/matcher.d.ts +39 -0
- package/dist/vault/matcher.d.ts.map +1 -0
- package/dist/vault/matcher.js +197 -0
- package/dist/vault/matcher.js.map +1 -0
- package/dist/vault/personal.d.ts +60 -0
- package/dist/vault/personal.d.ts.map +1 -0
- package/dist/vault/personal.js +162 -0
- package/dist/vault/personal.js.map +1 -0
- package/dist/vault/store.d.ts +39 -0
- package/dist/vault/store.d.ts.map +1 -0
- package/dist/vault/store.js +111 -0
- package/dist/vault/store.js.map +1 -0
- package/dist/webhooks/config.d.ts +64 -0
- package/dist/webhooks/config.d.ts.map +1 -0
- package/dist/webhooks/config.js +214 -0
- package/dist/webhooks/config.js.map +1 -0
- package/dist/webhooks/event-log.d.ts +90 -0
- package/dist/webhooks/event-log.d.ts.map +1 -0
- package/dist/webhooks/event-log.js +132 -0
- package/dist/webhooks/event-log.js.map +1 -0
- package/dist/webhooks/handler.d.ts +92 -0
- package/dist/webhooks/handler.d.ts.map +1 -0
- package/dist/webhooks/handler.js +103 -0
- package/dist/webhooks/handler.js.map +1 -0
- package/dist/webhooks/handlers.d.ts +100 -0
- package/dist/webhooks/handlers.d.ts.map +1 -0
- package/dist/webhooks/handlers.js +178 -0
- package/dist/webhooks/handlers.js.map +1 -0
- package/dist/webhooks/index.d.ts +29 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +33 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/mount.d.ts +77 -0
- package/dist/webhooks/mount.d.ts.map +1 -0
- package/dist/webhooks/mount.js +400 -0
- package/dist/webhooks/mount.js.map +1 -0
- package/dist/webhooks/registry.d.ts +52 -0
- package/dist/webhooks/registry.d.ts.map +1 -0
- package/dist/webhooks/registry.js +143 -0
- package/dist/webhooks/registry.js.map +1 -0
- package/dist/webhooks/relay.d.ts +25 -0
- package/dist/webhooks/relay.d.ts.map +1 -0
- package/dist/webhooks/relay.js +53 -0
- package/dist/webhooks/relay.js.map +1 -0
- package/dist/webhooks/retry.d.ts +92 -0
- package/dist/webhooks/retry.d.ts.map +1 -0
- package/dist/webhooks/retry.js +270 -0
- package/dist/webhooks/retry.js.map +1 -0
- package/dist/webhooks/router.d.ts +94 -0
- package/dist/webhooks/router.d.ts.map +1 -0
- package/dist/webhooks/router.js +290 -0
- package/dist/webhooks/router.js.map +1 -0
- package/dist/webhooks/twilio.d.ts +63 -0
- package/dist/webhooks/twilio.d.ts.map +1 -0
- package/dist/webhooks/twilio.js +129 -0
- package/dist/webhooks/twilio.js.map +1 -0
- package/dist/webhooks/types.d.ts +142 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/types.js +8 -0
- package/dist/webhooks/types.js.map +1 -0
- package/dist/webhooks/verify.d.ts +51 -0
- package/dist/webhooks/verify.d.ts.map +1 -0
- package/dist/webhooks/verify.js +98 -0
- package/dist/webhooks/verify.js.map +1 -0
- package/package.json +70 -0
- package/public/board.html +1316 -0
- package/public/browser.html +600 -0
- package/public/help.html +655 -0
- package/public/index.html +4689 -0
- package/public/library.html +3642 -0
- package/public/observatory.html +1693 -0
- package/public/ops.html +1129 -0
- package/public/share-modal.js +211 -0
- package/skills/README.md +34 -0
- package/skills/core-architecture.md +33 -0
- package/skills/form-fill.md +98 -0
- package/skills/form-review.md +110 -0
- package/skills/form-scout.md +94 -0
- package/skills/log-decision.md +27 -0
- package/skills/onboard.md +98 -0
- package/skills/voice-guide.md +22 -0
- package/skills/write-blog.md +43 -0
|
@@ -0,0 +1,975 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { writeTask, updateTask, readTask, readTaskOutput, listTasks, LOGS_DIR } from "./store.js";
|
|
5
|
+
import { pushNotification } from "../goals/notifications.js";
|
|
6
|
+
import { logActivity } from "../activity/log.js";
|
|
7
|
+
import { rememberTaskOutcome, recordScar } from "./memory.js";
|
|
8
|
+
import { makeCall } from "../twilio/call.js";
|
|
9
|
+
import { attemptRecovery, recordRecoveryFailure } from "./recover.js";
|
|
10
|
+
import { TaskCooldownManager } from "./cooldown.js";
|
|
11
|
+
import { triageAgentOutput } from "./triage.js";
|
|
12
|
+
import { releaseLocks } from "./locks.js";
|
|
13
|
+
import { recordAgentSpawn, recordAgentCompletion } from "../metrics/collector.js";
|
|
14
|
+
import { recordSpawnRateBlock, recordBridgeReport as recordBridgeReportMetric } from "../metrics/firewall-metrics.js";
|
|
15
|
+
import { traceAgentSpawn } from "../tracing/instrument.js";
|
|
16
|
+
import { getCorrelationId } from "../tracing/correlation.js";
|
|
17
|
+
import { completeChat } from "../llm/complete.js";
|
|
18
|
+
import { resolveProvider, resolveUtilityModel } from "../settings.js";
|
|
19
|
+
import { createLogger } from "../utils/logger.js";
|
|
20
|
+
import { resolveEnv, getInstanceName, getInstanceNameLower, getAlertEmailFrom } from "../instance.js";
|
|
21
|
+
import { getSkillRegistry } from "../skills/registry.js";
|
|
22
|
+
import { getBoardProvider } from "../board/provider.js";
|
|
23
|
+
const log = createLogger("agent-spawn");
|
|
24
|
+
/**
|
|
25
|
+
* Update a board task's state/assignee. Best-effort — failures are logged, not thrown.
|
|
26
|
+
* Used to move board items through in_progress → done/todo as agents work.
|
|
27
|
+
* Exported so the monitor can also update board state on recovered completions.
|
|
28
|
+
*/
|
|
29
|
+
export async function updateBoardTaskState(boardTaskId, changes) {
|
|
30
|
+
try {
|
|
31
|
+
const bp = getBoardProvider();
|
|
32
|
+
const store = bp?.getStore?.();
|
|
33
|
+
if (store) {
|
|
34
|
+
await store.update(boardTaskId, changes);
|
|
35
|
+
log.debug(`Board task ${boardTaskId} updated: ${JSON.stringify(changes)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
log.warn(`Failed to update board task ${boardTaskId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Track recent failures — email first, phone only as last resort. */
|
|
43
|
+
const recentFailures = [];
|
|
44
|
+
const FAILURE_WINDOW_MS = 5 * 60 * 1000; // 5 minutes
|
|
45
|
+
const EMAIL_THRESHOLD = 2; // 2+ failures in window → email
|
|
46
|
+
const CALL_THRESHOLD = 5; // 5+ failures in window → phone (last resort)
|
|
47
|
+
let lastEmailTime = 0;
|
|
48
|
+
let lastCallTime = 0;
|
|
49
|
+
const EMAIL_COOLDOWN_MS = 10 * 60 * 1000; // Don't email more than once per 10 min
|
|
50
|
+
const CALL_COOLDOWN_MS = 30 * 60 * 1000; // Don't call more than once per 30 min
|
|
51
|
+
/**
|
|
52
|
+
* Global spawn rate limiter — prevents burst-spawning agents.
|
|
53
|
+
* Tracks timestamps of recent spawns and enforces minimum spacing.
|
|
54
|
+
*/
|
|
55
|
+
const recentSpawnTimestamps = [];
|
|
56
|
+
const SPAWN_RATE_WINDOW_MS = 60_000; // 1 minute window
|
|
57
|
+
const MAX_SPAWNS_PER_WINDOW = 10; // Max 10 spawns per minute
|
|
58
|
+
function isSpawnRateLimited() {
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
// Prune old entries
|
|
61
|
+
while (recentSpawnTimestamps.length > 0 && recentSpawnTimestamps[0] < now - SPAWN_RATE_WINDOW_MS) {
|
|
62
|
+
recentSpawnTimestamps.shift();
|
|
63
|
+
}
|
|
64
|
+
return recentSpawnTimestamps.length >= MAX_SPAWNS_PER_WINDOW;
|
|
65
|
+
}
|
|
66
|
+
function recordSpawn() {
|
|
67
|
+
recentSpawnTimestamps.push(Date.now());
|
|
68
|
+
}
|
|
69
|
+
// ─── Skill Enrichment ─────────────────────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* Enrich a task's prompt with matched skill instructions from the SkillRegistry.
|
|
72
|
+
* Transparent: if the registry isn't initialized or no skills match, returns the
|
|
73
|
+
* original prompt unchanged.
|
|
74
|
+
*/
|
|
75
|
+
async function enrichPromptWithSkills(task) {
|
|
76
|
+
const registry = getSkillRegistry();
|
|
77
|
+
if (!registry)
|
|
78
|
+
return task.prompt;
|
|
79
|
+
try {
|
|
80
|
+
const matches = registry.matchSkills({ description: task.label });
|
|
81
|
+
if (matches.length === 0)
|
|
82
|
+
return task.prompt;
|
|
83
|
+
// Load bodies and collect formatted prompts (cap at 3 to avoid bloat)
|
|
84
|
+
const skillPrompts = [];
|
|
85
|
+
for (const match of matches.slice(0, 3)) {
|
|
86
|
+
await registry.loadBody(match.skill.meta.name);
|
|
87
|
+
const formatted = registry.getSkillPrompt(match.skill.meta.name);
|
|
88
|
+
if (formatted) {
|
|
89
|
+
skillPrompts.push(formatted);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (skillPrompts.length === 0)
|
|
93
|
+
return task.prompt;
|
|
94
|
+
const skillNames = matches.slice(0, 3).filter((m) => {
|
|
95
|
+
const s = registry.getSkillPrompt(m.skill.meta.name);
|
|
96
|
+
return s !== null;
|
|
97
|
+
}).map((m) => m.skill.meta.name);
|
|
98
|
+
log.info(`Enriching agent "${task.label}" with ${skillPrompts.length} skill(s): ${skillNames.join(", ")}`, { taskId: task.id });
|
|
99
|
+
return [
|
|
100
|
+
task.prompt,
|
|
101
|
+
"",
|
|
102
|
+
"---",
|
|
103
|
+
"## Relevant Skills",
|
|
104
|
+
"",
|
|
105
|
+
...skillPrompts,
|
|
106
|
+
].join("\n");
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
log.warn(`Skill enrichment failed for "${task.label}", using original prompt: ${err instanceof Error ? err.message : String(err)}`, { taskId: task.id });
|
|
110
|
+
return task.prompt;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Map of task ID → spawned ChildProcess (only for tasks we spawned this session). */
|
|
114
|
+
const activeProcesses = new Map();
|
|
115
|
+
/** Tasks that fell back from pool to direct — skip recovery to prevent double-retry. */
|
|
116
|
+
const poolFallbackTasks = new Set();
|
|
117
|
+
/** Track batch membership: sessionId → set of task IDs spawned together. */
|
|
118
|
+
const sessionBatches = new Map();
|
|
119
|
+
/** Collect results from each agent as they finish (sessionId → results[]) */
|
|
120
|
+
const batchResults = new Map();
|
|
121
|
+
/** Callback invoked when all agents from a session batch have completed. */
|
|
122
|
+
let onBatchComplete = null;
|
|
123
|
+
/** Register a callback for when an agent batch finishes. */
|
|
124
|
+
export function setOnBatchComplete(cb) {
|
|
125
|
+
onBatchComplete = cb;
|
|
126
|
+
}
|
|
127
|
+
/** Map of task ID → timeout timer. */
|
|
128
|
+
const activeTimers = new Map();
|
|
129
|
+
export { activeProcesses };
|
|
130
|
+
/** Check if any agents are currently running (active processes or pending batches). */
|
|
131
|
+
export function isAgentsBusy() {
|
|
132
|
+
return activeProcesses.size > 0 || sessionBatches.size > 0;
|
|
133
|
+
}
|
|
134
|
+
/** Number of currently active agent processes. */
|
|
135
|
+
export function activeAgentCount() {
|
|
136
|
+
return activeProcesses.size;
|
|
137
|
+
}
|
|
138
|
+
/** Reference to the runtime pool. Set via setAgentPool() when the pool is initialized. */
|
|
139
|
+
let agentPool = null;
|
|
140
|
+
/** Wire the runtime pool into spawn.ts so spawnAgent delegates to it. */
|
|
141
|
+
export function setAgentPool(pool) {
|
|
142
|
+
agentPool = pool;
|
|
143
|
+
}
|
|
144
|
+
/** Check if the runtime pool is active. */
|
|
145
|
+
export function hasAgentPool() {
|
|
146
|
+
return agentPool !== null && !agentPool.isShuttingDown;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Spawn the claude CLI for a task.
|
|
150
|
+
*
|
|
151
|
+
* When the runtime AgentPool is available, delegates to it for lifecycle
|
|
152
|
+
* management, resource tracking, circuit breakers, and isolation.
|
|
153
|
+
* Falls back to direct process spawning when the pool isn't initialized.
|
|
154
|
+
*
|
|
155
|
+
* Mutates task in-place (status, pid, startedAt) and writes to disk.
|
|
156
|
+
*/
|
|
157
|
+
export async function spawnAgent(task) {
|
|
158
|
+
return traceAgentSpawn(task.id, task.label, task.origin, async (span) => {
|
|
159
|
+
const correlationId = getCorrelationId();
|
|
160
|
+
if (correlationId) {
|
|
161
|
+
span.setAttribute("dash.correlation_id", correlationId);
|
|
162
|
+
}
|
|
163
|
+
if (task.sessionId) {
|
|
164
|
+
span.setAttribute("agent.session_id", task.sessionId);
|
|
165
|
+
}
|
|
166
|
+
log.info(`Spawning agent: ${task.label}`, { taskId: task.id, origin: task.origin, sessionId: task.sessionId });
|
|
167
|
+
// Enrich prompt with matched skill instructions (transparent — no-op if registry unavailable)
|
|
168
|
+
task.prompt = await enrichPromptWithSkills(task);
|
|
169
|
+
// Global spawn rate limiter — prevent burst-spawning
|
|
170
|
+
if (isSpawnRateLimited()) {
|
|
171
|
+
log.warn(`Spawn rate-limited, skipping: ${task.label}`, { taskId: task.id });
|
|
172
|
+
span.setAttribute("agent.rate_limited", true);
|
|
173
|
+
recordSpawnRateBlock();
|
|
174
|
+
logActivity({
|
|
175
|
+
source: "agent",
|
|
176
|
+
summary: `Spawn rate-limited, skipping: ${task.label}`,
|
|
177
|
+
detail: `Max ${MAX_SPAWNS_PER_WINDOW} spawns per ${SPAWN_RATE_WINDOW_MS / 1000}s`,
|
|
178
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
179
|
+
reason: "spawn rate limit exceeded",
|
|
180
|
+
});
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
recordSpawn();
|
|
184
|
+
// Delegate to runtime pool when available
|
|
185
|
+
if (agentPool && !agentPool.isShuttingDown) {
|
|
186
|
+
log.debug(`Using pool spawn for: ${task.label}`, { taskId: task.id });
|
|
187
|
+
span.setAttribute("agent.spawn_mode", "pool");
|
|
188
|
+
return spawnViaPool(task);
|
|
189
|
+
}
|
|
190
|
+
// Fallback: direct process spawning (original behavior)
|
|
191
|
+
log.debug(`Using direct spawn for: ${task.label}`, { taskId: task.id });
|
|
192
|
+
span.setAttribute("agent.spawn_mode", "direct");
|
|
193
|
+
return spawnDirect(task);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Spawn through the AgentPool runtime.
|
|
198
|
+
* The pool handles resource allocation, circuit breakers, isolation, and monitoring.
|
|
199
|
+
*/
|
|
200
|
+
async function spawnViaPool(task) {
|
|
201
|
+
try {
|
|
202
|
+
const instance = await agentPool.spawn({
|
|
203
|
+
taskId: task.id,
|
|
204
|
+
label: task.label,
|
|
205
|
+
prompt: task.prompt,
|
|
206
|
+
cwd: task.cwd,
|
|
207
|
+
origin: task.origin,
|
|
208
|
+
tags: task.sessionId ? [`session:${task.sessionId}`] : [],
|
|
209
|
+
config: {
|
|
210
|
+
timeoutMs: task.timeoutMs ?? 600000,
|
|
211
|
+
maxRetries: 2,
|
|
212
|
+
backoffMs: 2000,
|
|
213
|
+
backoffMultiplier: 2,
|
|
214
|
+
maxBackoffMs: 30000,
|
|
215
|
+
env: {},
|
|
216
|
+
isolation: "shared",
|
|
217
|
+
priority: 50,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
// Sync task state from runtime instance
|
|
221
|
+
task.status = "running";
|
|
222
|
+
task.pid = instance.pid;
|
|
223
|
+
task.startedAt = new Date().toISOString();
|
|
224
|
+
await writeTask(task);
|
|
225
|
+
// Move board task to in_progress and write back the agent task ID for causal backrefs
|
|
226
|
+
if (task.boardTaskId) {
|
|
227
|
+
updateBoardTaskState(task.boardTaskId, { state: "in_progress", assignee: `${getInstanceNameLower()}-agent`, agentTaskId: task.id });
|
|
228
|
+
}
|
|
229
|
+
// Track batch membership (still needed for continuation)
|
|
230
|
+
if (task.sessionId) {
|
|
231
|
+
if (!sessionBatches.has(task.sessionId)) {
|
|
232
|
+
sessionBatches.set(task.sessionId, new Set());
|
|
233
|
+
}
|
|
234
|
+
sessionBatches.get(task.sessionId).add(task.id);
|
|
235
|
+
}
|
|
236
|
+
// Listen for completion via the runtime bus
|
|
237
|
+
// Use .on() with self-removal instead of .once() to avoid race conditions
|
|
238
|
+
// where another agent's event consumes this listener
|
|
239
|
+
const onCompleted = (data) => {
|
|
240
|
+
if (data.agentId === instance.id) {
|
|
241
|
+
agentPool?.runtimeManager.bus.off("agent:completed", onCompleted);
|
|
242
|
+
agentPool?.runtimeManager.bus.off("agent:failed", onFailed);
|
|
243
|
+
handlePoolCompletion(task, "completed", data.exitCode ?? 0);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
const onFailed = (data) => {
|
|
247
|
+
if (data.agentId === instance.id) {
|
|
248
|
+
agentPool?.runtimeManager.bus.off("agent:completed", onCompleted);
|
|
249
|
+
agentPool?.runtimeManager.bus.off("agent:failed", onFailed);
|
|
250
|
+
handlePoolCompletion(task, "failed", null);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
agentPool.runtimeManager.bus.on("agent:completed", onCompleted);
|
|
254
|
+
agentPool.runtimeManager.bus.on("agent:failed", onFailed);
|
|
255
|
+
recordAgentSpawn();
|
|
256
|
+
logActivity({
|
|
257
|
+
source: "agent",
|
|
258
|
+
summary: `Spawned agent via pool: ${task.label}`,
|
|
259
|
+
detail: `Instance ${instance.id}, PID ${instance.pid}, task ${task.id}`,
|
|
260
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
261
|
+
reason: task.origin === "ai" ? "planner selected from backlog" : "user chat triggered agent",
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
// Pool rejected the spawn (circuit breaker, resources, etc.)
|
|
266
|
+
// Fall back to direct spawning, but mark task to skip recovery
|
|
267
|
+
// (pool already handles retries — don't double up with recovery agents)
|
|
268
|
+
poolFallbackTasks.add(task.id);
|
|
269
|
+
logActivity({
|
|
270
|
+
source: "agent",
|
|
271
|
+
summary: `Pool spawn failed, falling back to direct (no recovery): ${task.label}`,
|
|
272
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
273
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
274
|
+
reason: "pool spawn failed, falling back",
|
|
275
|
+
});
|
|
276
|
+
return spawnDirect(task);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/** Handle completion callbacks when spawned via pool. */
|
|
280
|
+
async function handlePoolCompletion(task, status, exitCode) {
|
|
281
|
+
log.info(`Agent ${status}: ${task.label}`, { taskId: task.id, exitCode, sessionId: task.sessionId });
|
|
282
|
+
// Release file locks held by this agent
|
|
283
|
+
releaseLocks(task.id).catch((err) => {
|
|
284
|
+
log.warn(`Failed to release locks for agent ${task.id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
285
|
+
});
|
|
286
|
+
// Record agent completion metric
|
|
287
|
+
if (task.startedAt) {
|
|
288
|
+
const durationMs = Date.now() - new Date(task.startedAt).getTime();
|
|
289
|
+
recordAgentCompletion(durationMs, status === "completed");
|
|
290
|
+
}
|
|
291
|
+
// DASH-143: Record cooldown IMMEDIATELY on failure — before setting
|
|
292
|
+
// board task back to "todo". This closes the race window where the
|
|
293
|
+
// autonomous loop re-plans the same task before batch-level cooldown fires.
|
|
294
|
+
if (status === "failed" && task.boardTaskId) {
|
|
295
|
+
TaskCooldownManager.getInstance().recordFailure(task.boardTaskId, task.label, `Pool terminal failure (exit ${exitCode})`);
|
|
296
|
+
}
|
|
297
|
+
// Update board task state: done on success, back to todo on failure
|
|
298
|
+
if (task.boardTaskId) {
|
|
299
|
+
if (status === "completed") {
|
|
300
|
+
await updateBoardTaskState(task.boardTaskId, { state: "done" });
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
// Failed: move back to todo and clear assignee so it can be retried
|
|
304
|
+
await updateBoardTaskState(task.boardTaskId, { state: "todo", assignee: null });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const output = await readTaskOutput(task.id).catch(() => "");
|
|
308
|
+
const resultSummary = output.trim().slice(0, 1000) || undefined;
|
|
309
|
+
// Notifications
|
|
310
|
+
const outputSnippet = resultSummary ? `\nOutput:\n${resultSummary}` : "";
|
|
311
|
+
pushNotification({
|
|
312
|
+
timestamp: new Date().toISOString(),
|
|
313
|
+
source: "agent",
|
|
314
|
+
message: `Agent task "${task.label}" ${status} (exit ${exitCode}).${outputSnippet}`,
|
|
315
|
+
});
|
|
316
|
+
// Triage: check if agent surfaced questions for the human
|
|
317
|
+
const needsHuman = await triageAgentOutput({ ...task, status, exitCode: exitCode ?? undefined }, output).catch(() => false);
|
|
318
|
+
// On failure via pool: the RuntimeManager already handles retries at the
|
|
319
|
+
// instance level (maybeRetry with exponential backoff). Don't also spawn
|
|
320
|
+
// a recovery agent — that creates double-retry fan-out. Only track for
|
|
321
|
+
// phone alerts and record if this was a recovery task that failed.
|
|
322
|
+
if (status === "failed") {
|
|
323
|
+
if (task.label.startsWith("Fix: ")) {
|
|
324
|
+
recordRecoveryFailure();
|
|
325
|
+
}
|
|
326
|
+
if (!needsHuman) {
|
|
327
|
+
trackFailureForAlert(task.label);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Post-completion reflection for autonomous tasks (skip for recovery agents —
|
|
331
|
+
// session-level reflection already covers them, and per-agent LLM calls add latency)
|
|
332
|
+
if (!task.label.startsWith("Fix: ")) {
|
|
333
|
+
reflectOnCompletion({ ...task, status, exitCode: exitCode ?? undefined }, output).catch(() => { });
|
|
334
|
+
}
|
|
335
|
+
// Scar evaluation for successful Fix: agents — check if the repair qualifies as a scar
|
|
336
|
+
if (task.label.startsWith("Fix: ") && status === "completed") {
|
|
337
|
+
evaluateScar({ ...task, status, exitCode: exitCode ?? undefined }, output).catch(() => { });
|
|
338
|
+
}
|
|
339
|
+
// Batch continuation
|
|
340
|
+
if (task.sessionId && sessionBatches.has(task.sessionId)) {
|
|
341
|
+
const batch = sessionBatches.get(task.sessionId);
|
|
342
|
+
batch.delete(task.id);
|
|
343
|
+
if (!batchResults.has(task.sessionId)) {
|
|
344
|
+
batchResults.set(task.sessionId, []);
|
|
345
|
+
}
|
|
346
|
+
batchResults.get(task.sessionId).push({ label: task.label, status });
|
|
347
|
+
if (batch.size === 0) {
|
|
348
|
+
sessionBatches.delete(task.sessionId);
|
|
349
|
+
const allResults = batchResults.get(task.sessionId) ?? [{ label: task.label, status }];
|
|
350
|
+
batchResults.delete(task.sessionId);
|
|
351
|
+
if (onBatchComplete) {
|
|
352
|
+
const sid = task.sessionId;
|
|
353
|
+
// 500ms settlement: task store writes are sync, just need metadata flush
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
logActivity({ source: "agent", summary: `Agent batch complete for session ${sid} (${allResults.length} agents)`, actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED", reason: "agent batch completed" });
|
|
356
|
+
Promise.resolve(onBatchComplete(sid, allResults)).catch((err) => {
|
|
357
|
+
logActivity({ source: "agent", summary: `Auto-continue callback error: ${err instanceof Error ? err.message : String(err)}`, actionLabel: "AUTONOMOUS", reason: "batch continuation error" });
|
|
358
|
+
});
|
|
359
|
+
}, 500);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/** Send agent failure alert email via Resend (fire-and-forget). */
|
|
365
|
+
async function sendFailureEmail(count, names) {
|
|
366
|
+
const apiKey = process.env.RESEND_API_KEY;
|
|
367
|
+
if (!apiKey) {
|
|
368
|
+
log.warn("No RESEND_API_KEY — skipping agent failure email");
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
const res = await fetch("https://api.resend.com/emails", {
|
|
373
|
+
method: "POST",
|
|
374
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` },
|
|
375
|
+
body: JSON.stringify({
|
|
376
|
+
from: `${getInstanceName()} <${getAlertEmailFrom()}>`,
|
|
377
|
+
to: [resolveEnv("ALERT_EMAIL_TO") ?? ""].filter(Boolean),
|
|
378
|
+
subject: `[AGENT ALERT] ${count} agent failures in the last few minutes`,
|
|
379
|
+
html: `<div style="font-family:sans-serif;max-width:600px;">
|
|
380
|
+
<div style="background:#f59e0b;color:white;padding:16px;border-radius:8px 8px 0 0;">
|
|
381
|
+
<h2 style="margin:0;">Agent Failures</h2>
|
|
382
|
+
</div>
|
|
383
|
+
<div style="border:1px solid #e5e7eb;border-top:none;padding:16px;border-radius:0 0 8px 8px;">
|
|
384
|
+
<p><strong>${count} agents</strong> failed within a 5-minute window.</p>
|
|
385
|
+
<p><strong>Agents:</strong> ${names}</p>
|
|
386
|
+
<p style="color:#6b7280;font-size:12px;">Check the agent logs at /ops for details. A phone call will follow only if failures continue to escalate.</p>
|
|
387
|
+
</div>
|
|
388
|
+
</div>`,
|
|
389
|
+
}),
|
|
390
|
+
});
|
|
391
|
+
if (res.ok) {
|
|
392
|
+
logActivity({ source: "agent", summary: `Emailed you about ${count} agent failures` });
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
log.error("Agent failure email failed", { status: res.status });
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
catch (err) {
|
|
399
|
+
log.error("Agent failure email exception", { error: String(err) });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/** Track failure — email first, phone only as last resort. */
|
|
403
|
+
function trackFailureForAlert(label) {
|
|
404
|
+
const now = Date.now();
|
|
405
|
+
recentFailures.push({ label, time: now });
|
|
406
|
+
while (recentFailures.length > 0 && recentFailures[0].time < now - FAILURE_WINDOW_MS) {
|
|
407
|
+
recentFailures.shift();
|
|
408
|
+
}
|
|
409
|
+
const count = recentFailures.length;
|
|
410
|
+
const names = recentFailures.map((f) => f.label).join(", ");
|
|
411
|
+
// Tier 1: Email at 2+ failures
|
|
412
|
+
if (count >= EMAIL_THRESHOLD && now - lastEmailTime > EMAIL_COOLDOWN_MS) {
|
|
413
|
+
lastEmailTime = now;
|
|
414
|
+
sendFailureEmail(count, names).catch(() => { });
|
|
415
|
+
}
|
|
416
|
+
// Tier 2: Phone call at 5+ failures (last resort, after email)
|
|
417
|
+
if (count >= CALL_THRESHOLD && now - lastCallTime > CALL_COOLDOWN_MS) {
|
|
418
|
+
lastCallTime = now;
|
|
419
|
+
makeCall({
|
|
420
|
+
message: `Hey, it's ${getInstanceName()}. ${count} agents have failed in the last few minutes. I already sent you an email with details. This is getting serious — please check the logs.`,
|
|
421
|
+
}).then((r) => {
|
|
422
|
+
logActivity({ source: "agent", summary: r.ok ? `Called you about ${count} agent failures (escalated from email)` : `Failed to call: ${r.message}` });
|
|
423
|
+
}).catch(() => { });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/** Direct process spawning — original behavior without runtime pool. */
|
|
427
|
+
async function spawnDirect(task) {
|
|
428
|
+
const stdoutPath = join(LOGS_DIR, `${task.id}.stdout.log`);
|
|
429
|
+
const stderrPath = join(LOGS_DIR, `${task.id}.stderr.log`);
|
|
430
|
+
const promptPath = join(LOGS_DIR, `${task.id}.prompt.txt`);
|
|
431
|
+
// Write prompt to file to avoid shell escaping issues
|
|
432
|
+
writeFileSync(promptPath, task.prompt, "utf-8");
|
|
433
|
+
// Clean environment: remove CLAUDECODE to allow nested Claude Code sessions.
|
|
434
|
+
// Claude CLI refuses to run inside another session if this env var is set.
|
|
435
|
+
const cleanEnv = { ...process.env };
|
|
436
|
+
delete cleanEnv.CLAUDECODE;
|
|
437
|
+
// Use node as the wrapper — avoids all shell encoding/escaping issues.
|
|
438
|
+
// spawnSync with windowsHide prevents claude from opening a console window.
|
|
439
|
+
const wrapperScript = `
|
|
440
|
+
const fs = require("fs");
|
|
441
|
+
const { spawnSync } = require("child_process");
|
|
442
|
+
const prompt = fs.readFileSync(${JSON.stringify(promptPath)}, "utf-8");
|
|
443
|
+
const r = spawnSync("claude", [
|
|
444
|
+
"--print", "--output-format", "text", "--dangerously-skip-permissions", prompt
|
|
445
|
+
], {
|
|
446
|
+
cwd: ${JSON.stringify(task.cwd)},
|
|
447
|
+
encoding: "utf-8",
|
|
448
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
449
|
+
timeout: ${task.timeoutMs ?? 600000},
|
|
450
|
+
windowsHide: true
|
|
451
|
+
});
|
|
452
|
+
fs.writeFileSync(${JSON.stringify(stdoutPath)}, r.stdout || "", "utf-8");
|
|
453
|
+
fs.writeFileSync(${JSON.stringify(stderrPath)}, r.stderr || "", "utf-8");
|
|
454
|
+
process.exit(r.status || 0);
|
|
455
|
+
`;
|
|
456
|
+
const child = spawn(process.execPath, ["--eval", wrapperScript], {
|
|
457
|
+
cwd: task.cwd,
|
|
458
|
+
detached: true,
|
|
459
|
+
stdio: "ignore",
|
|
460
|
+
env: cleanEnv,
|
|
461
|
+
windowsHide: true,
|
|
462
|
+
});
|
|
463
|
+
// Let the instance exit without killing the child
|
|
464
|
+
child.unref();
|
|
465
|
+
task.status = "running";
|
|
466
|
+
task.pid = child.pid;
|
|
467
|
+
task.startedAt = new Date().toISOString();
|
|
468
|
+
await writeTask(task);
|
|
469
|
+
activeProcesses.set(task.id, child);
|
|
470
|
+
// Move board task to in_progress and write back the agent task ID for causal backrefs
|
|
471
|
+
if (task.boardTaskId) {
|
|
472
|
+
updateBoardTaskState(task.boardTaskId, { state: "in_progress", assignee: `${getInstanceNameLower()}-agent`, agentTaskId: task.id });
|
|
473
|
+
}
|
|
474
|
+
// Track batch: group tasks by sessionId so we know when a batch finishes
|
|
475
|
+
if (task.sessionId) {
|
|
476
|
+
if (!sessionBatches.has(task.sessionId)) {
|
|
477
|
+
sessionBatches.set(task.sessionId, new Set());
|
|
478
|
+
}
|
|
479
|
+
sessionBatches.get(task.sessionId).add(task.id);
|
|
480
|
+
}
|
|
481
|
+
recordAgentSpawn();
|
|
482
|
+
logActivity({
|
|
483
|
+
source: "agent",
|
|
484
|
+
summary: `Spawned agent: ${task.label}`,
|
|
485
|
+
detail: `PID ${child.pid}, task ${task.id}`,
|
|
486
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
487
|
+
reason: task.origin === "ai" ? "planner selected from backlog" : "user chat triggered agent",
|
|
488
|
+
});
|
|
489
|
+
// Exit handler
|
|
490
|
+
child.on("exit", async (code) => {
|
|
491
|
+
log.info(`Agent process exited: ${task.label}`, { taskId: task.id, exitCode: code, pid: child.pid });
|
|
492
|
+
activeProcesses.delete(task.id);
|
|
493
|
+
clearTaskTimer(task.id);
|
|
494
|
+
// Release file locks held by this agent
|
|
495
|
+
releaseLocks(task.id).catch((err) => {
|
|
496
|
+
log.warn(`Failed to release locks for agent ${task.id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
497
|
+
});
|
|
498
|
+
// Brief delay to ensure file buffers are flushed.
|
|
499
|
+
// writeFileSync in the wrapper script guarantees data is on disk,
|
|
500
|
+
// but the OS may still be updating file metadata. 100ms is sufficient.
|
|
501
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
502
|
+
const output = await readTaskOutput(task.id);
|
|
503
|
+
const resultSummary = output.trim().slice(0, 1000) || undefined;
|
|
504
|
+
// Determine success: exit 0 is clean success, but a null/non-zero exit code
|
|
505
|
+
// with substantial output likely means the agent did its work but the process
|
|
506
|
+
// exited uncleanly (signal, timeout, claude CLI quirk). Trust the output.
|
|
507
|
+
const hasSubstantialOutput = output.trim().length > 100;
|
|
508
|
+
const finalStatus = code === 0 || (code == null && hasSubstantialOutput)
|
|
509
|
+
? "completed"
|
|
510
|
+
: "failed";
|
|
511
|
+
// Record agent completion metric
|
|
512
|
+
if (task.startedAt) {
|
|
513
|
+
const durationMs = Date.now() - new Date(task.startedAt).getTime();
|
|
514
|
+
recordAgentCompletion(durationMs, finalStatus === "completed");
|
|
515
|
+
}
|
|
516
|
+
await updateTask(task.id, {
|
|
517
|
+
status: finalStatus,
|
|
518
|
+
exitCode: code ?? undefined,
|
|
519
|
+
finishedAt: new Date().toISOString(),
|
|
520
|
+
resultSummary,
|
|
521
|
+
});
|
|
522
|
+
// DASH-143: Record cooldown IMMEDIATELY on failure — before setting
|
|
523
|
+
// board task back to "todo". Prevents autonomous re-planning race.
|
|
524
|
+
if (finalStatus === "failed" && task.boardTaskId) {
|
|
525
|
+
TaskCooldownManager.getInstance().recordFailure(task.boardTaskId, task.label, `Direct spawn failure (exit ${code})`);
|
|
526
|
+
}
|
|
527
|
+
// Update board task state: done on success, back to todo on failure
|
|
528
|
+
if (task.boardTaskId) {
|
|
529
|
+
if (finalStatus === "completed") {
|
|
530
|
+
await updateBoardTaskState(task.boardTaskId, { state: "done" });
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
await updateBoardTaskState(task.boardTaskId, { state: "todo", assignee: null });
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
// Durable memory — survives restarts, retrievable by future turns
|
|
537
|
+
rememberTaskOutcome({ ...task, status: finalStatus, exitCode: code ?? undefined }, output).catch(() => { });
|
|
538
|
+
// Post-completion reflection for autonomous tasks (skip for recovery agents —
|
|
539
|
+
// session-level reflection already covers them, and per-agent LLM calls add latency)
|
|
540
|
+
if (!task.label.startsWith("Fix: ")) {
|
|
541
|
+
reflectOnCompletion({ ...task, status: finalStatus, exitCode: code ?? undefined }, output).catch(() => { });
|
|
542
|
+
}
|
|
543
|
+
// Scar evaluation for successful Fix: agents — check if the repair qualifies as a scar
|
|
544
|
+
if (task.label.startsWith("Fix: ") && finalStatus === "completed") {
|
|
545
|
+
evaluateScar({ ...task, status: finalStatus, exitCode: code ?? undefined }, output).catch(() => { });
|
|
546
|
+
}
|
|
547
|
+
logActivity({
|
|
548
|
+
source: "agent",
|
|
549
|
+
summary: `Agent ${finalStatus}: ${task.label}`,
|
|
550
|
+
detail: `Exit code ${code}, task ${task.id}`,
|
|
551
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
552
|
+
reason: `agent ${finalStatus}`,
|
|
553
|
+
});
|
|
554
|
+
const outputSnippet = resultSummary
|
|
555
|
+
? `\nOutput:\n${resultSummary}`
|
|
556
|
+
: "";
|
|
557
|
+
pushNotification({
|
|
558
|
+
timestamp: new Date().toISOString(),
|
|
559
|
+
source: "agent",
|
|
560
|
+
message: `Agent task "${task.label}" ${finalStatus} (exit ${code}).${outputSnippet}`,
|
|
561
|
+
});
|
|
562
|
+
// Triage: check if agent surfaced questions for the human
|
|
563
|
+
const needsHuman = await triageAgentOutput({ ...task, status: finalStatus, exitCode: code ?? undefined }, output).catch(() => false);
|
|
564
|
+
// On failure: attempt recovery ONLY if not blocked on human questions
|
|
565
|
+
// and not a pool-fallback task (pool already handles retries)
|
|
566
|
+
if (finalStatus === "failed" && !needsHuman) {
|
|
567
|
+
// Record if this was itself a recovery agent that failed
|
|
568
|
+
if (task.label.startsWith("Fix: ")) {
|
|
569
|
+
recordRecoveryFailure();
|
|
570
|
+
}
|
|
571
|
+
const isPoolFallback = poolFallbackTasks.has(task.id);
|
|
572
|
+
if (isPoolFallback) {
|
|
573
|
+
poolFallbackTasks.delete(task.id);
|
|
574
|
+
logActivity({
|
|
575
|
+
source: "agent",
|
|
576
|
+
summary: `Skipping recovery for pool-fallback task: ${task.label}`,
|
|
577
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
578
|
+
reason: "pool-fallback task — no double retry",
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
attemptRecovery({ ...task, status: "failed", exitCode: code ?? undefined }, output).catch(() => { });
|
|
583
|
+
}
|
|
584
|
+
trackFailureForAlert(task.label);
|
|
585
|
+
}
|
|
586
|
+
// Check if this was the last agent in a batch → trigger continuation
|
|
587
|
+
if (task.sessionId && sessionBatches.has(task.sessionId)) {
|
|
588
|
+
const batch = sessionBatches.get(task.sessionId);
|
|
589
|
+
batch.delete(task.id);
|
|
590
|
+
// Collect this agent's result
|
|
591
|
+
if (!batchResults.has(task.sessionId)) {
|
|
592
|
+
batchResults.set(task.sessionId, []);
|
|
593
|
+
}
|
|
594
|
+
batchResults.get(task.sessionId).push({ label: task.label, status: finalStatus });
|
|
595
|
+
if (batch.size === 0) {
|
|
596
|
+
sessionBatches.delete(task.sessionId);
|
|
597
|
+
const allResults = batchResults.get(task.sessionId) ?? [{ label: task.label, status: finalStatus }];
|
|
598
|
+
batchResults.delete(task.sessionId);
|
|
599
|
+
// All agents done — pass all results to continuation
|
|
600
|
+
if (onBatchComplete) {
|
|
601
|
+
const sid = task.sessionId;
|
|
602
|
+
// 500ms settlement: task store writes are sync, just need metadata flush
|
|
603
|
+
setTimeout(() => {
|
|
604
|
+
logActivity({ source: "agent", summary: `Agent batch complete for session ${sid} (${allResults.length} agents)`, actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED", reason: "agent batch completed" });
|
|
605
|
+
Promise.resolve(onBatchComplete(sid, allResults)).catch((err) => {
|
|
606
|
+
logActivity({ source: "agent", summary: `Auto-continue callback error: ${err instanceof Error ? err.message : String(err)}`, actionLabel: "AUTONOMOUS", reason: "batch continuation error" });
|
|
607
|
+
});
|
|
608
|
+
}, 500);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
// Error handler (spawn failure)
|
|
614
|
+
child.on("error", async (err) => {
|
|
615
|
+
activeProcesses.delete(task.id);
|
|
616
|
+
clearTaskTimer(task.id);
|
|
617
|
+
poolFallbackTasks.delete(task.id);
|
|
618
|
+
// Record agent failure metric — balances the in-flight gauge from recordAgentSpawn()
|
|
619
|
+
if (task.startedAt) {
|
|
620
|
+
const durationMs = Date.now() - new Date(task.startedAt).getTime();
|
|
621
|
+
recordAgentCompletion(durationMs, false);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
// Spawned but never got startedAt — still need to decrement in-flight
|
|
625
|
+
recordAgentCompletion(0, false);
|
|
626
|
+
}
|
|
627
|
+
// Release file locks held by this agent
|
|
628
|
+
releaseLocks(task.id).catch(() => { });
|
|
629
|
+
await updateTask(task.id, {
|
|
630
|
+
status: "failed",
|
|
631
|
+
error: err.message,
|
|
632
|
+
finishedAt: new Date().toISOString(),
|
|
633
|
+
});
|
|
634
|
+
rememberTaskOutcome({ ...task, status: "failed", error: err.message }).catch(() => { });
|
|
635
|
+
logActivity({
|
|
636
|
+
source: "agent",
|
|
637
|
+
summary: `Agent spawn error: ${task.label}`,
|
|
638
|
+
detail: err.message,
|
|
639
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
640
|
+
reason: "agent spawn error",
|
|
641
|
+
});
|
|
642
|
+
pushNotification({
|
|
643
|
+
timestamp: new Date().toISOString(),
|
|
644
|
+
source: "agent",
|
|
645
|
+
message: `Agent task "${task.label}" failed to spawn: ${err.message}`,
|
|
646
|
+
});
|
|
647
|
+
// Clean up batch membership so batch completion isn't stuck
|
|
648
|
+
if (task.sessionId && sessionBatches.has(task.sessionId)) {
|
|
649
|
+
const batch = sessionBatches.get(task.sessionId);
|
|
650
|
+
batch.delete(task.id);
|
|
651
|
+
if (!batchResults.has(task.sessionId)) {
|
|
652
|
+
batchResults.set(task.sessionId, []);
|
|
653
|
+
}
|
|
654
|
+
batchResults.get(task.sessionId).push({ label: task.label, status: "failed" });
|
|
655
|
+
if (batch.size === 0) {
|
|
656
|
+
sessionBatches.delete(task.sessionId);
|
|
657
|
+
const allResults = batchResults.get(task.sessionId) ?? [{ label: task.label, status: "failed" }];
|
|
658
|
+
batchResults.delete(task.sessionId);
|
|
659
|
+
if (onBatchComplete) {
|
|
660
|
+
const sid = task.sessionId;
|
|
661
|
+
setTimeout(() => {
|
|
662
|
+
Promise.resolve(onBatchComplete(sid, allResults)).catch(() => { });
|
|
663
|
+
}, 2000);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
// Timeout
|
|
669
|
+
if (task.timeoutMs && task.timeoutMs > 0) {
|
|
670
|
+
const timer = setTimeout(() => {
|
|
671
|
+
if (activeProcesses.has(task.id)) {
|
|
672
|
+
logActivity({
|
|
673
|
+
source: "agent",
|
|
674
|
+
summary: `Agent timed out: ${task.label}`,
|
|
675
|
+
detail: `Killing PID ${child.pid} after ${task.timeoutMs}ms`,
|
|
676
|
+
actionLabel: task.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
677
|
+
reason: "agent timeout exceeded",
|
|
678
|
+
});
|
|
679
|
+
try {
|
|
680
|
+
if (process.platform === "win32" && child.pid) {
|
|
681
|
+
spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { shell: true });
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
child.kill("SIGTERM");
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
catch { }
|
|
688
|
+
}
|
|
689
|
+
}, task.timeoutMs);
|
|
690
|
+
activeTimers.set(task.id, timer);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
/** Cancel a running agent task. Tries pool first, then direct process kill. */
|
|
694
|
+
export async function cancelAgent(taskId) {
|
|
695
|
+
// Try cancelling via pool (it tracks runtime instances by taskId)
|
|
696
|
+
if (agentPool) {
|
|
697
|
+
const instance = agentPool.runtimeManager.getByTaskId(taskId);
|
|
698
|
+
if (instance) {
|
|
699
|
+
try {
|
|
700
|
+
await agentPool.terminate(instance.id, "Cancelled by user");
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
// Fall through to direct cancellation
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
// Direct process kill (for legacy/direct spawns)
|
|
708
|
+
const child = activeProcesses.get(taskId);
|
|
709
|
+
if (child) {
|
|
710
|
+
activeProcesses.delete(taskId);
|
|
711
|
+
clearTaskTimer(taskId);
|
|
712
|
+
try {
|
|
713
|
+
if (process.platform === "win32" && child.pid) {
|
|
714
|
+
spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { shell: true });
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
child.kill("SIGTERM");
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
catch { }
|
|
721
|
+
}
|
|
722
|
+
// Release file locks held by this agent
|
|
723
|
+
releaseLocks(taskId).catch((err) => {
|
|
724
|
+
log.warn(`Failed to release locks on cancel for ${taskId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
725
|
+
});
|
|
726
|
+
// Record cancellation as a failed completion to keep in-flight gauge accurate
|
|
727
|
+
const taskRecord = await readTask(taskId);
|
|
728
|
+
if (taskRecord?.startedAt) {
|
|
729
|
+
const durationMs = Date.now() - new Date(taskRecord.startedAt).getTime();
|
|
730
|
+
recordAgentCompletion(durationMs, false);
|
|
731
|
+
}
|
|
732
|
+
const updated = await updateTask(taskId, {
|
|
733
|
+
status: "cancelled",
|
|
734
|
+
finishedAt: new Date().toISOString(),
|
|
735
|
+
});
|
|
736
|
+
if (updated) {
|
|
737
|
+
logActivity({
|
|
738
|
+
source: "agent",
|
|
739
|
+
summary: `Agent cancelled: ${updated.label}`,
|
|
740
|
+
detail: `Task ${taskId}`,
|
|
741
|
+
actionLabel: updated.origin === "ai" ? "AUTONOMOUS" : "PROMPTED",
|
|
742
|
+
reason: "agent cancelled by user",
|
|
743
|
+
});
|
|
744
|
+
pushNotification({
|
|
745
|
+
timestamp: new Date().toISOString(),
|
|
746
|
+
source: "agent",
|
|
747
|
+
message: `Agent task "${updated.label}" was cancelled.`,
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
return updated !== null;
|
|
751
|
+
}
|
|
752
|
+
// ─── Reflection ───────────────────────────────────────────────────────────────
|
|
753
|
+
const reflectionLog = createLogger("reflection");
|
|
754
|
+
const REFLECTION_PROMPT = `You are reflecting on a completed autonomous agent task. Answer concisely in JSON:
|
|
755
|
+
{
|
|
756
|
+
"movedGoalForward": true/false,
|
|
757
|
+
"hitGuardrail": true/false,
|
|
758
|
+
"adjustment": "what to do differently next time, or null if nothing",
|
|
759
|
+
"summary": "1 sentence: what happened and was it useful?"
|
|
760
|
+
}
|
|
761
|
+
Be honest. If the task failed or produced nothing useful, say so.`;
|
|
762
|
+
async function reflectOnCompletion(task, output) {
|
|
763
|
+
// Only reflect on autonomous actions
|
|
764
|
+
if (task.origin !== "ai")
|
|
765
|
+
return;
|
|
766
|
+
try {
|
|
767
|
+
// Tier 1: Micro-reflection for routine successes — skip LLM call
|
|
768
|
+
const isRoutineSuccess = task.exitCode === 0 && output.trim().length > 100;
|
|
769
|
+
if (isRoutineSuccess) {
|
|
770
|
+
const microReflection = {
|
|
771
|
+
movedGoalForward: true,
|
|
772
|
+
hitGuardrail: false,
|
|
773
|
+
adjustment: undefined,
|
|
774
|
+
summary: `Completed "${task.label}" successfully.`,
|
|
775
|
+
};
|
|
776
|
+
await updateTask(task.id, { reflection: microReflection });
|
|
777
|
+
reflectionLog.info(`Micro-reflection (routine success): "${task.label}"`);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
// Tier 2: Full LLM reflection for non-routine completions
|
|
781
|
+
const provider = resolveProvider();
|
|
782
|
+
const model = resolveUtilityModel();
|
|
783
|
+
const response = await completeChat({
|
|
784
|
+
messages: [
|
|
785
|
+
{ role: "system", content: REFLECTION_PROMPT },
|
|
786
|
+
{ role: "user", content: JSON.stringify({
|
|
787
|
+
label: task.label,
|
|
788
|
+
status: task.status,
|
|
789
|
+
output: output.slice(0, 1000),
|
|
790
|
+
exitCode: task.exitCode,
|
|
791
|
+
}) },
|
|
792
|
+
],
|
|
793
|
+
model,
|
|
794
|
+
provider,
|
|
795
|
+
});
|
|
796
|
+
// Parse JSON response — strip markdown fences if present
|
|
797
|
+
const jsonStr = response.replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/i, "").trim();
|
|
798
|
+
const reflection = JSON.parse(jsonStr);
|
|
799
|
+
// Write reflection to task record
|
|
800
|
+
await updateTask(task.id, { reflection });
|
|
801
|
+
// Log reflective activity entry (only for non-routine cases that warranted LLM analysis)
|
|
802
|
+
logActivity({
|
|
803
|
+
source: "agent",
|
|
804
|
+
summary: `Reflection on "${task.label}": ${reflection.summary}`,
|
|
805
|
+
actionLabel: "REFLECTIVE",
|
|
806
|
+
reason: "post-completion autonomous reflection",
|
|
807
|
+
backref: task.id,
|
|
808
|
+
});
|
|
809
|
+
reflectionLog.info(`Reflected on "${task.label}": ${reflection.summary}`);
|
|
810
|
+
}
|
|
811
|
+
catch (err) {
|
|
812
|
+
reflectionLog.warn(`Reflection failed for "${task.label}": ${err instanceof Error ? err.message : String(err)}`);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
// ─── Scar Evaluation ──────────────────────────────────────────────────────────
|
|
816
|
+
const SCAR_EVAL_PROMPT = `You are evaluating whether a completed "Fix:" agent's work qualifies as a scar — a self-repair proven by code, tests, and validation.
|
|
817
|
+
|
|
818
|
+
A fix qualifies as a scar ONLY if the output shows ALL of these:
|
|
819
|
+
1. A clear root cause was identified (the "anchor")
|
|
820
|
+
2. Code was changed to correct the defect
|
|
821
|
+
3. Tests or validation were added/run to prove the fix works
|
|
822
|
+
|
|
823
|
+
Respond in JSON:
|
|
824
|
+
{
|
|
825
|
+
"isScar": true/false,
|
|
826
|
+
"anchor": "root cause description (or null if not a scar)",
|
|
827
|
+
"woundSummary": "one-line description of the original failure (or null)",
|
|
828
|
+
"artifacts": {
|
|
829
|
+
"prevention": ["measures added to prevent recurrence"],
|
|
830
|
+
"detection": ["signals added to detect the issue earlier"],
|
|
831
|
+
"correction": ["code changes that corrected the defect"],
|
|
832
|
+
"regressionTests": ["test files/cases that guard against regression"]
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
If the fix was partial, untested, or just a workaround, set isScar to false.`;
|
|
837
|
+
/**
|
|
838
|
+
* Evaluate whether a completed Fix: agent produced a scar-worthy repair.
|
|
839
|
+
* Called for successful Fix: agents after completion.
|
|
840
|
+
*/
|
|
841
|
+
async function evaluateScar(task, output) {
|
|
842
|
+
// Only evaluate successful Fix: agents
|
|
843
|
+
if (!task.label.startsWith("Fix: "))
|
|
844
|
+
return;
|
|
845
|
+
if (task.status !== "completed")
|
|
846
|
+
return;
|
|
847
|
+
try {
|
|
848
|
+
const provider = resolveProvider();
|
|
849
|
+
const model = resolveUtilityModel();
|
|
850
|
+
const response = await completeChat({
|
|
851
|
+
messages: [
|
|
852
|
+
{ role: "system", content: SCAR_EVAL_PROMPT },
|
|
853
|
+
{ role: "user", content: JSON.stringify({
|
|
854
|
+
label: task.label,
|
|
855
|
+
output: output.slice(0, 2000),
|
|
856
|
+
exitCode: task.exitCode,
|
|
857
|
+
}) },
|
|
858
|
+
],
|
|
859
|
+
model,
|
|
860
|
+
provider,
|
|
861
|
+
});
|
|
862
|
+
const jsonStr = response.replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/i, "").trim();
|
|
863
|
+
const evaluation = JSON.parse(jsonStr);
|
|
864
|
+
if (!evaluation.isScar) {
|
|
865
|
+
reflectionLog.info(`Fix "${task.label}" did not qualify as scar`);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
await recordScar({
|
|
869
|
+
anchor: evaluation.anchor,
|
|
870
|
+
woundSummary: evaluation.woundSummary,
|
|
871
|
+
healedAt: new Date().toISOString(),
|
|
872
|
+
agentId: task.id,
|
|
873
|
+
artifacts: {
|
|
874
|
+
prevention: evaluation.artifacts?.prevention ?? [],
|
|
875
|
+
detection: evaluation.artifacts?.detection ?? [],
|
|
876
|
+
correction: evaluation.artifacts?.correction ?? [],
|
|
877
|
+
regressionTests: evaluation.artifacts?.regressionTests ?? [],
|
|
878
|
+
},
|
|
879
|
+
});
|
|
880
|
+
logActivity({
|
|
881
|
+
source: "agent",
|
|
882
|
+
summary: `Scar recorded for "${task.label}": ${evaluation.woundSummary}`,
|
|
883
|
+
actionLabel: "REFLECTIVE",
|
|
884
|
+
reason: "fix agent produced validated self-repair",
|
|
885
|
+
backref: task.id,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
catch (err) {
|
|
889
|
+
reflectionLog.warn(`Scar evaluation failed for "${task.label}": ${err instanceof Error ? err.message : String(err)}`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Generate a consolidated handoff report when a board task hits 3+ failures.
|
|
894
|
+
* Persists to brain/agents/bridge-reports/ and pushes a notification.
|
|
895
|
+
*/
|
|
896
|
+
export async function generateBridgeReport(boardTaskId, taskLabel, failureCount) {
|
|
897
|
+
try {
|
|
898
|
+
const allTasks = await listTasks();
|
|
899
|
+
const related = allTasks
|
|
900
|
+
.filter((t) => t.label === taskLabel || t.label === `Fix: ${taskLabel}`)
|
|
901
|
+
.sort((a, b) => (a.createdAt ?? "").localeCompare(b.createdAt ?? ""));
|
|
902
|
+
const attempts = related
|
|
903
|
+
.filter((t) => t.label === taskLabel)
|
|
904
|
+
.map((t, i) => ({
|
|
905
|
+
round: i + 1,
|
|
906
|
+
exitCode: t.exitCode ?? null,
|
|
907
|
+
outputSnippet: (t.resultSummary ?? "").slice(0, 300),
|
|
908
|
+
timestamp: t.finishedAt ?? t.createdAt ?? "",
|
|
909
|
+
}));
|
|
910
|
+
const recoveryAttempts = related
|
|
911
|
+
.filter((t) => t.label.startsWith("Fix: "))
|
|
912
|
+
.map((t) => `Recovery ${t.status}: ${(t.resultSummary ?? "").slice(0, 200)}`);
|
|
913
|
+
const rootCauses = [];
|
|
914
|
+
for (const t of related) {
|
|
915
|
+
if (t.reflection?.adjustment)
|
|
916
|
+
rootCauses.push(t.reflection.adjustment);
|
|
917
|
+
}
|
|
918
|
+
const report = {
|
|
919
|
+
taskId: boardTaskId,
|
|
920
|
+
taskLabel,
|
|
921
|
+
failureCount,
|
|
922
|
+
attempts,
|
|
923
|
+
rootCauses: [...new Set(rootCauses)],
|
|
924
|
+
recoveryAttempts,
|
|
925
|
+
recommendation: rootCauses.length > 0
|
|
926
|
+
? `Repeated root cause: ${rootCauses[0]}. Manual investigation needed.`
|
|
927
|
+
: `${failureCount} failures with no clear root cause. Check agent logs for ${taskLabel}.`,
|
|
928
|
+
};
|
|
929
|
+
const reportText = [
|
|
930
|
+
`## Bridge Report: "${taskLabel}"`,
|
|
931
|
+
`**${failureCount} consecutive failures** — handing off to human.`,
|
|
932
|
+
``,
|
|
933
|
+
`### Attempts`,
|
|
934
|
+
...attempts.map((a) => `- Round ${a.round} (exit ${a.exitCode}): ${a.outputSnippet.slice(0, 100)}...`),
|
|
935
|
+
``,
|
|
936
|
+
`### Root Causes Identified`,
|
|
937
|
+
...(rootCauses.length > 0 ? rootCauses.map((r) => `- ${r}`) : ["- No root causes identified by reflection"]),
|
|
938
|
+
``,
|
|
939
|
+
`### Recovery Attempts`,
|
|
940
|
+
...(recoveryAttempts.length > 0 ? recoveryAttempts.map((r) => `- ${r}`) : ["- None"]),
|
|
941
|
+
``,
|
|
942
|
+
`### Recommendation`,
|
|
943
|
+
report.recommendation,
|
|
944
|
+
].join("\n");
|
|
945
|
+
pushNotification({
|
|
946
|
+
timestamp: new Date().toISOString(),
|
|
947
|
+
source: "agent",
|
|
948
|
+
message: reportText,
|
|
949
|
+
});
|
|
950
|
+
recordBridgeReportMetric();
|
|
951
|
+
logActivity({
|
|
952
|
+
source: "agent",
|
|
953
|
+
summary: `Bridge report generated for "${taskLabel}" (${failureCount} failures)`,
|
|
954
|
+
detail: JSON.stringify(report),
|
|
955
|
+
actionLabel: "AUTONOMOUS",
|
|
956
|
+
reason: "structural impasse — repeated same-task failures",
|
|
957
|
+
});
|
|
958
|
+
// Persist as brain document for future reference
|
|
959
|
+
const reportsDir = join(resolveEnv("BRAIN_DIR") ?? join(process.cwd(), "brain"), "agents", "bridge-reports");
|
|
960
|
+
mkdirSync(reportsDir, { recursive: true });
|
|
961
|
+
const reportPath = join(reportsDir, `${boardTaskId}-${Date.now()}.md`);
|
|
962
|
+
writeFileSync(reportPath, reportText, "utf-8");
|
|
963
|
+
}
|
|
964
|
+
catch (err) {
|
|
965
|
+
reflectionLog.warn(`Bridge report failed for "${taskLabel}": ${err instanceof Error ? err.message : String(err)}`);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function clearTaskTimer(taskId) {
|
|
969
|
+
const timer = activeTimers.get(taskId);
|
|
970
|
+
if (timer) {
|
|
971
|
+
clearTimeout(timer);
|
|
972
|
+
activeTimers.delete(taskId);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
//# sourceMappingURL=spawn.js.map
|