@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,850 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Instance Manager (DASH-6).
|
|
3
|
+
*
|
|
4
|
+
* Higher-level orchestrator on top of RuntimeManager that adds:
|
|
5
|
+
* - Restart (terminate + respawn with same config)
|
|
6
|
+
* - Garbage collection for terminated instances
|
|
7
|
+
* - Load-balanced spawn placement
|
|
8
|
+
* - Isolation / sandboxing enforcement
|
|
9
|
+
* - Instance health scoring and automatic recovery
|
|
10
|
+
* - Lifecycle history tracking per instance
|
|
11
|
+
* - Batch operations (pause/terminate by tag, origin, etc.)
|
|
12
|
+
* - RuntimeBus event integration for metrics
|
|
13
|
+
*/
|
|
14
|
+
import { unlink } from "node:fs/promises";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { TERMINAL_STATES } from "./runtime/types.js";
|
|
17
|
+
import { RuntimeError, ErrorCodes } from "./runtime/errors.js";
|
|
18
|
+
import { TASKS_DIR, LOGS_DIR } from "./store.js";
|
|
19
|
+
import { logActivity } from "../activity/log.js";
|
|
20
|
+
import { createLogger } from "../utils/logger.js";
|
|
21
|
+
const log = createLogger("agent-instance-mgr");
|
|
22
|
+
const DEFAULT_CONFIG = {
|
|
23
|
+
gcIntervalMs: 30_000,
|
|
24
|
+
gcTtlMs: 5 * 60_000,
|
|
25
|
+
healthCheckIntervalMs: 30_000,
|
|
26
|
+
unhealthyThreshold: 3,
|
|
27
|
+
maxHistoryPerInstance: 50,
|
|
28
|
+
autoRecover: true,
|
|
29
|
+
maxAutoRestarts: 2,
|
|
30
|
+
sandboxRoot: "brain/agents/sandboxes",
|
|
31
|
+
gcBatchSize: 100,
|
|
32
|
+
gcMinIntervalMs: 5_000,
|
|
33
|
+
};
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Instance Manager
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
export class AgentInstanceManager {
|
|
38
|
+
config;
|
|
39
|
+
runtime;
|
|
40
|
+
meta = new Map();
|
|
41
|
+
gcTimer = null;
|
|
42
|
+
gcAdaptiveTimer = null;
|
|
43
|
+
healthTimer = null;
|
|
44
|
+
destroyed = false;
|
|
45
|
+
gcRunning = false;
|
|
46
|
+
gcMetrics = {
|
|
47
|
+
totalCycles: 0,
|
|
48
|
+
totalCollected: 0,
|
|
49
|
+
totalTimeMs: 0,
|
|
50
|
+
peakCollected: 0,
|
|
51
|
+
peakTimeMs: 0,
|
|
52
|
+
cappedCycles: 0,
|
|
53
|
+
adaptiveRuns: 0,
|
|
54
|
+
peakFileDeleteMs: 0,
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Cached terminal states array — avoids spreading the Set every GC cycle.
|
|
58
|
+
* TERMINAL_STATES is a ReadonlySet that never changes at runtime.
|
|
59
|
+
*/
|
|
60
|
+
terminalStatesArray = [...TERMINAL_STATES];
|
|
61
|
+
/**
|
|
62
|
+
* Hard limit on pending terminal instances before forcing synchronous
|
|
63
|
+
* collection outside the normal GC schedule (B-010).
|
|
64
|
+
*/
|
|
65
|
+
static BACKLOG_HARD_LIMIT = 500;
|
|
66
|
+
constructor(runtime, config) {
|
|
67
|
+
this.runtime = runtime;
|
|
68
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
69
|
+
}
|
|
70
|
+
// -------------------------------------------------------------------------
|
|
71
|
+
// Initialization & shutdown
|
|
72
|
+
// -------------------------------------------------------------------------
|
|
73
|
+
/** Attach to RuntimeBus events, start GC and health timers. */
|
|
74
|
+
async init() {
|
|
75
|
+
log.info("Initializing instance manager", { gcIntervalMs: this.config.gcIntervalMs, healthCheckIntervalMs: this.config.healthCheckIntervalMs });
|
|
76
|
+
this.attachBusListeners();
|
|
77
|
+
this.startGc();
|
|
78
|
+
this.startHealthChecks();
|
|
79
|
+
// Metadata is created lazily by ensureMeta() on first access per instance
|
|
80
|
+
// (via bus listeners, health checks, or spawn/restart calls), so there's
|
|
81
|
+
// no need for an eager bootstrap loop over all existing instances.
|
|
82
|
+
logActivity({
|
|
83
|
+
source: "agent",
|
|
84
|
+
summary: "Instance manager initialized",
|
|
85
|
+
detail: `GC every ${this.config.gcIntervalMs}ms, health every ${this.config.healthCheckIntervalMs}ms`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Stop timers, detach listeners, clear metadata. */
|
|
89
|
+
async shutdown() {
|
|
90
|
+
if (this.destroyed)
|
|
91
|
+
return;
|
|
92
|
+
this.destroyed = true;
|
|
93
|
+
this.stopGc();
|
|
94
|
+
this.stopHealthChecks();
|
|
95
|
+
this.meta.clear();
|
|
96
|
+
logActivity({
|
|
97
|
+
source: "agent",
|
|
98
|
+
summary: "Instance manager shut down",
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Get cumulative GC performance metrics. */
|
|
102
|
+
getGcMetrics() {
|
|
103
|
+
return { ...this.gcMetrics };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Force an immediate GC cycle, bypassing the timer schedule.
|
|
107
|
+
* Useful when external code detects a backlog of terminal instances.
|
|
108
|
+
* No-op if a GC cycle is already running.
|
|
109
|
+
*/
|
|
110
|
+
async forceGc() {
|
|
111
|
+
if (this.gcRunning || this.destroyed)
|
|
112
|
+
return;
|
|
113
|
+
await this.runGc();
|
|
114
|
+
}
|
|
115
|
+
// -------------------------------------------------------------------------
|
|
116
|
+
// Lifecycle operations (delegate + enhance)
|
|
117
|
+
// -------------------------------------------------------------------------
|
|
118
|
+
/** Spawn a new agent instance with load-balanced resource selection. */
|
|
119
|
+
async spawn(request) {
|
|
120
|
+
// Apply isolation enforcement
|
|
121
|
+
const config = this.enforceIsolation(request);
|
|
122
|
+
// Load-balance: adjust resource allocation based on current utilization
|
|
123
|
+
const resources = this.balanceResources(request.resources);
|
|
124
|
+
const enrichedRequest = {
|
|
125
|
+
...request,
|
|
126
|
+
config,
|
|
127
|
+
resources,
|
|
128
|
+
};
|
|
129
|
+
const instance = await this.runtime.spawn(enrichedRequest);
|
|
130
|
+
// Track the original request for restart capability
|
|
131
|
+
const meta = this.ensureMeta(instance.id);
|
|
132
|
+
meta.originalRequest = request;
|
|
133
|
+
return instance;
|
|
134
|
+
}
|
|
135
|
+
/** Pause a running instance. */
|
|
136
|
+
async pause(instanceId, reason) {
|
|
137
|
+
return this.runtime.pause(instanceId, reason);
|
|
138
|
+
}
|
|
139
|
+
/** Resume a paused instance. */
|
|
140
|
+
async resume(instanceId) {
|
|
141
|
+
return this.runtime.resume(instanceId);
|
|
142
|
+
}
|
|
143
|
+
/** Terminate an instance. */
|
|
144
|
+
async terminate(instanceId, reason) {
|
|
145
|
+
return this.runtime.terminate(instanceId, reason);
|
|
146
|
+
}
|
|
147
|
+
/** Restart timing metrics from last restart call. */
|
|
148
|
+
lastRestartTiming;
|
|
149
|
+
/** Get timing breakdown from the most recent restart(). */
|
|
150
|
+
getLastRestartTiming() {
|
|
151
|
+
return this.lastRestartTiming;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Restart an instance: terminate, then respawn with the same configuration.
|
|
155
|
+
* Returns the new instance (new ID, fresh state).
|
|
156
|
+
*
|
|
157
|
+
* Optimized: prepares spawn request concurrently with termination,
|
|
158
|
+
* and uses fast-terminate (skips redundant task store update since the
|
|
159
|
+
* task will be re-used by the new instance).
|
|
160
|
+
*/
|
|
161
|
+
async restart(instanceId, reason) {
|
|
162
|
+
const restartStart = Date.now();
|
|
163
|
+
const timing = {
|
|
164
|
+
terminateMs: 0,
|
|
165
|
+
spawnPrepMs: 0,
|
|
166
|
+
spawnMs: 0,
|
|
167
|
+
totalMs: 0,
|
|
168
|
+
};
|
|
169
|
+
const instance = this.runtime.getInstance(instanceId);
|
|
170
|
+
if (!instance) {
|
|
171
|
+
throw new RuntimeError(ErrorCodes.AGENT_NOT_FOUND, `Cannot restart: instance not found: ${instanceId}`);
|
|
172
|
+
}
|
|
173
|
+
const meta = this.ensureMeta(instanceId);
|
|
174
|
+
const originalRequest = meta.originalRequest;
|
|
175
|
+
// Prepare spawn request concurrently with termination — no I/O needed
|
|
176
|
+
const prepStart = Date.now();
|
|
177
|
+
const spawnRequest = originalRequest ?? {
|
|
178
|
+
taskId: instance.taskId,
|
|
179
|
+
label: instance.metadata.label,
|
|
180
|
+
prompt: "", // Will be re-read from task store by driver
|
|
181
|
+
origin: instance.metadata.origin,
|
|
182
|
+
parentId: instance.metadata.parentId,
|
|
183
|
+
tags: instance.metadata.tags,
|
|
184
|
+
config: instance.config,
|
|
185
|
+
resources: instance.resources,
|
|
186
|
+
};
|
|
187
|
+
timing.spawnPrepMs = Date.now() - prepStart;
|
|
188
|
+
// Terminate if still active (uses fast terminate — skips task store update
|
|
189
|
+
// since the task will be re-used by the new instance)
|
|
190
|
+
if (!TERMINAL_STATES.has(instance.state)) {
|
|
191
|
+
const termStart = Date.now();
|
|
192
|
+
await this.runtime.terminate(instanceId, reason ?? "Restarting");
|
|
193
|
+
timing.terminateMs = Date.now() - termStart;
|
|
194
|
+
}
|
|
195
|
+
const spawnStart = Date.now();
|
|
196
|
+
const newInstance = await this.runtime.spawn(spawnRequest);
|
|
197
|
+
timing.spawnMs = Date.now() - spawnStart;
|
|
198
|
+
// Transfer metadata to new instance
|
|
199
|
+
const newMeta = this.ensureMeta(newInstance.id);
|
|
200
|
+
newMeta.restartCount = meta.restartCount + 1;
|
|
201
|
+
newMeta.originalRequest = originalRequest;
|
|
202
|
+
newMeta.consecutiveFailures = 0;
|
|
203
|
+
timing.totalMs = Date.now() - restartStart;
|
|
204
|
+
this.lastRestartTiming = timing;
|
|
205
|
+
logActivity({
|
|
206
|
+
source: "agent",
|
|
207
|
+
summary: `Agent restarted: ${instance.metadata.label}`,
|
|
208
|
+
detail: `${instanceId} → ${newInstance.id}, restart #${newMeta.restartCount}, ${timing.totalMs}ms [term:${timing.terminateMs} prep:${timing.spawnPrepMs} spawn:${timing.spawnMs}]`,
|
|
209
|
+
});
|
|
210
|
+
return newInstance;
|
|
211
|
+
}
|
|
212
|
+
// -------------------------------------------------------------------------
|
|
213
|
+
// Batch operations
|
|
214
|
+
// -------------------------------------------------------------------------
|
|
215
|
+
/** Pause all instances matching a filter. Returns count paused. */
|
|
216
|
+
async pauseMatching(filter, reason) {
|
|
217
|
+
const targets = this.filterInstances(filter).filter((i) => i.state === "running");
|
|
218
|
+
let count = 0;
|
|
219
|
+
const failed = [];
|
|
220
|
+
for (const inst of targets) {
|
|
221
|
+
try {
|
|
222
|
+
await this.runtime.pause(inst.id, reason ?? "Batch pause");
|
|
223
|
+
count++;
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
failed.push(`${inst.id}:${err instanceof Error ? err.message : String(err)}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
logActivity({
|
|
230
|
+
source: "agent",
|
|
231
|
+
summary: `Batch pause: ${count}/${targets.length} agents paused${failed.length > 0 ? `, ${failed.length} failed` : ""}`,
|
|
232
|
+
detail: failed.length > 0 ? `Failed: ${failed.join("; ")}` : undefined,
|
|
233
|
+
});
|
|
234
|
+
return count;
|
|
235
|
+
}
|
|
236
|
+
/** Terminate all instances matching a filter. Returns count terminated. */
|
|
237
|
+
async terminateMatching(filter, reason) {
|
|
238
|
+
const targets = this.filterInstances(filter).filter((i) => !TERMINAL_STATES.has(i.state));
|
|
239
|
+
let count = 0;
|
|
240
|
+
const failed = [];
|
|
241
|
+
for (const inst of targets) {
|
|
242
|
+
try {
|
|
243
|
+
await this.runtime.terminate(inst.id, reason ?? "Batch terminate");
|
|
244
|
+
count++;
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
failed.push(`${inst.id}:${err instanceof Error ? err.message : String(err)}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
logActivity({
|
|
251
|
+
source: "agent",
|
|
252
|
+
summary: `Batch terminate: ${count}/${targets.length} agents terminated${failed.length > 0 ? `, ${failed.length} failed` : ""}`,
|
|
253
|
+
detail: failed.length > 0 ? `Failed: ${failed.join("; ")}` : `Reason: ${reason ?? "batch operation"}`,
|
|
254
|
+
});
|
|
255
|
+
return count;
|
|
256
|
+
}
|
|
257
|
+
// -------------------------------------------------------------------------
|
|
258
|
+
// Queries
|
|
259
|
+
// -------------------------------------------------------------------------
|
|
260
|
+
/** Get an instance by ID. */
|
|
261
|
+
getInstance(id) {
|
|
262
|
+
return this.runtime.getInstance(id);
|
|
263
|
+
}
|
|
264
|
+
/** List all instances, optionally filtered. */
|
|
265
|
+
listInstances(filter) {
|
|
266
|
+
if (!filter)
|
|
267
|
+
return this.runtime.listInstances();
|
|
268
|
+
return this.filterInstances(filter);
|
|
269
|
+
}
|
|
270
|
+
/** Get lifecycle history for an instance. */
|
|
271
|
+
getHistory(instanceId) {
|
|
272
|
+
return this.meta.get(instanceId)?.history ?? [];
|
|
273
|
+
}
|
|
274
|
+
/** Get the restart count for an instance. */
|
|
275
|
+
getRestartCount(instanceId) {
|
|
276
|
+
return this.meta.get(instanceId)?.restartCount ?? 0;
|
|
277
|
+
}
|
|
278
|
+
/** Get current resource snapshot. */
|
|
279
|
+
getResourceSnapshot() {
|
|
280
|
+
return this.runtime.getResourceSnapshot();
|
|
281
|
+
}
|
|
282
|
+
/** Get state counts across all instances. */
|
|
283
|
+
getStateCounts() {
|
|
284
|
+
return this.runtime.getStateCounts();
|
|
285
|
+
}
|
|
286
|
+
// -------------------------------------------------------------------------
|
|
287
|
+
// Health monitoring
|
|
288
|
+
// -------------------------------------------------------------------------
|
|
289
|
+
/** Assess health of a single instance. */
|
|
290
|
+
assessHealth(instanceId) {
|
|
291
|
+
const instance = this.runtime.getInstance(instanceId);
|
|
292
|
+
if (!instance) {
|
|
293
|
+
return {
|
|
294
|
+
instanceId,
|
|
295
|
+
label: "unknown",
|
|
296
|
+
state: "terminated",
|
|
297
|
+
healthy: false,
|
|
298
|
+
score: 0,
|
|
299
|
+
uptime: 0,
|
|
300
|
+
restartCount: 0,
|
|
301
|
+
consecutiveFailures: 0,
|
|
302
|
+
lastChecked: new Date().toISOString(),
|
|
303
|
+
issues: ["Instance not found"],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const meta = this.ensureMeta(instanceId);
|
|
307
|
+
const now = Date.now();
|
|
308
|
+
const issues = [];
|
|
309
|
+
let score = 100;
|
|
310
|
+
// Terminal states aren't unhealthy — they're just done
|
|
311
|
+
if (TERMINAL_STATES.has(instance.state)) {
|
|
312
|
+
const isFailed = instance.state === "failed";
|
|
313
|
+
return {
|
|
314
|
+
instanceId,
|
|
315
|
+
label: instance.metadata.label,
|
|
316
|
+
state: instance.state,
|
|
317
|
+
healthy: !isFailed,
|
|
318
|
+
score: isFailed ? 0 : 100,
|
|
319
|
+
uptime: 0,
|
|
320
|
+
restartCount: meta.restartCount,
|
|
321
|
+
consecutiveFailures: meta.consecutiveFailures,
|
|
322
|
+
lastChecked: new Date().toISOString(),
|
|
323
|
+
issues: isFailed ? [`Failed: ${instance.error?.message ?? "unknown"}`] : [],
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// Uptime calculation
|
|
327
|
+
const createdAt = new Date(instance.createdAt).getTime();
|
|
328
|
+
const uptime = now - createdAt;
|
|
329
|
+
// Time decay: older events count less. Uses exponential decay with 30min half-life.
|
|
330
|
+
// A retry 30min ago contributes half the penalty of a retry just now.
|
|
331
|
+
const DECAY_HALF_LIFE_MS = 30 * 60 * 1000;
|
|
332
|
+
const decay = Math.pow(0.5, uptime / DECAY_HALF_LIFE_MS);
|
|
333
|
+
// Check: high retry count (decayed by instance age)
|
|
334
|
+
if (instance.retryCount > 0) {
|
|
335
|
+
score -= Math.round(instance.retryCount * 15 * decay);
|
|
336
|
+
issues.push(`${instance.retryCount} retries`);
|
|
337
|
+
}
|
|
338
|
+
// Check: many restarts (decayed)
|
|
339
|
+
if (meta.restartCount > 2) {
|
|
340
|
+
score -= Math.round((meta.restartCount - 2) * 10 * decay);
|
|
341
|
+
issues.push(`${meta.restartCount} restarts`);
|
|
342
|
+
}
|
|
343
|
+
// Check: consecutive failures (NOT decayed — recent failures always matter)
|
|
344
|
+
if (meta.consecutiveFailures > 0) {
|
|
345
|
+
score -= meta.consecutiveFailures * 20;
|
|
346
|
+
issues.push(`${meta.consecutiveFailures} consecutive failures`);
|
|
347
|
+
}
|
|
348
|
+
// Check: stuck in initializing for too long (>30s)
|
|
349
|
+
if (instance.state === "initializing" && uptime > 30_000) {
|
|
350
|
+
score -= 25;
|
|
351
|
+
issues.push("Stuck in initializing");
|
|
352
|
+
}
|
|
353
|
+
// Check: paused for a long time (>5min)
|
|
354
|
+
if (instance.state === "paused" && instance.pausedAt) {
|
|
355
|
+
const pausedDuration = now - new Date(instance.pausedAt).getTime();
|
|
356
|
+
if (pausedDuration > 5 * 60_000) {
|
|
357
|
+
score -= 10;
|
|
358
|
+
issues.push(`Paused for ${Math.round(pausedDuration / 60_000)}min`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Check: approaching timeout
|
|
362
|
+
if (instance.state === "running") {
|
|
363
|
+
const timeoutMs = instance.config.timeoutMs;
|
|
364
|
+
const elapsed = now - createdAt;
|
|
365
|
+
if (elapsed > timeoutMs * 0.8) {
|
|
366
|
+
score -= 20;
|
|
367
|
+
issues.push("Approaching timeout");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
score = Math.max(0, Math.min(100, score));
|
|
371
|
+
const healthy = score >= 50 && meta.consecutiveFailures < this.config.unhealthyThreshold;
|
|
372
|
+
const result = {
|
|
373
|
+
instanceId,
|
|
374
|
+
label: instance.metadata.label,
|
|
375
|
+
state: instance.state,
|
|
376
|
+
healthy,
|
|
377
|
+
score,
|
|
378
|
+
uptime,
|
|
379
|
+
restartCount: meta.restartCount,
|
|
380
|
+
consecutiveFailures: meta.consecutiveFailures,
|
|
381
|
+
lastChecked: new Date().toISOString(),
|
|
382
|
+
issues,
|
|
383
|
+
};
|
|
384
|
+
// Update meta
|
|
385
|
+
meta.lastHealthCheck = result.lastChecked;
|
|
386
|
+
if (healthy)
|
|
387
|
+
meta.lastHealthy = result.lastChecked;
|
|
388
|
+
return result;
|
|
389
|
+
}
|
|
390
|
+
/** Get aggregate health summary. */
|
|
391
|
+
getHealthSummary() {
|
|
392
|
+
const instances = this.runtime.listInstances();
|
|
393
|
+
const assessments = instances
|
|
394
|
+
.filter((i) => !TERMINAL_STATES.has(i.state))
|
|
395
|
+
.map((i) => this.assessHealth(i.id));
|
|
396
|
+
const healthyCount = assessments.filter((a) => a.healthy).length;
|
|
397
|
+
const avgScore = assessments.length > 0
|
|
398
|
+
? assessments.reduce((sum, a) => sum + a.score, 0) / assessments.length
|
|
399
|
+
: 100;
|
|
400
|
+
return {
|
|
401
|
+
totalInstances: instances.length,
|
|
402
|
+
activeInstances: assessments.length,
|
|
403
|
+
healthyInstances: healthyCount,
|
|
404
|
+
unhealthyInstances: assessments.length - healthyCount,
|
|
405
|
+
averageScore: Math.round(avgScore),
|
|
406
|
+
resources: this.runtime.getResourceSnapshot(),
|
|
407
|
+
instances: assessments,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
// -------------------------------------------------------------------------
|
|
411
|
+
// Inter-agent messaging (passthrough)
|
|
412
|
+
// -------------------------------------------------------------------------
|
|
413
|
+
sendMessage(from, to, type, payload) {
|
|
414
|
+
return this.runtime.sendMessage(from, to, type, payload);
|
|
415
|
+
}
|
|
416
|
+
async requestResponse(from, to, type, payload, timeoutMs) {
|
|
417
|
+
return this.runtime.requestResponse(from, to, type, payload, timeoutMs);
|
|
418
|
+
}
|
|
419
|
+
subscribeAgent(agentId, handler) {
|
|
420
|
+
this.runtime.subscribeAgent(agentId, handler);
|
|
421
|
+
}
|
|
422
|
+
// -------------------------------------------------------------------------
|
|
423
|
+
// Event subscriptions (passthrough)
|
|
424
|
+
// -------------------------------------------------------------------------
|
|
425
|
+
onLifecycle(handler) {
|
|
426
|
+
this.runtime.onLifecycle(handler);
|
|
427
|
+
}
|
|
428
|
+
onError(handler) {
|
|
429
|
+
this.runtime.onError(handler);
|
|
430
|
+
}
|
|
431
|
+
onResourceWarning(handler) {
|
|
432
|
+
this.runtime.onResourceWarning(handler);
|
|
433
|
+
}
|
|
434
|
+
// -------------------------------------------------------------------------
|
|
435
|
+
// Internal: RuntimeBus event listeners
|
|
436
|
+
// -------------------------------------------------------------------------
|
|
437
|
+
attachBusListeners() {
|
|
438
|
+
// Track lifecycle events in per-instance history
|
|
439
|
+
this.runtime.bus.on("agent:lifecycle", (event) => {
|
|
440
|
+
const meta = this.ensureMeta(event.agentId);
|
|
441
|
+
meta.history.push({
|
|
442
|
+
timestamp: event.timestamp,
|
|
443
|
+
previousState: event.previousState,
|
|
444
|
+
newState: event.newState,
|
|
445
|
+
reason: event.reason,
|
|
446
|
+
});
|
|
447
|
+
// Trim history if over limit
|
|
448
|
+
if (meta.history.length > this.config.maxHistoryPerInstance) {
|
|
449
|
+
meta.history = meta.history.slice(-this.config.maxHistoryPerInstance);
|
|
450
|
+
}
|
|
451
|
+
// Reset consecutive failures on successful transition to running
|
|
452
|
+
if (event.newState === "running") {
|
|
453
|
+
meta.consecutiveFailures = 0;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
// Track failures for auto-recovery decisions
|
|
457
|
+
this.runtime.bus.on("agent:failed", (data) => {
|
|
458
|
+
const meta = this.ensureMeta(data.agentId);
|
|
459
|
+
meta.consecutiveFailures++;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
// -------------------------------------------------------------------------
|
|
463
|
+
// Internal: load balancing
|
|
464
|
+
// -------------------------------------------------------------------------
|
|
465
|
+
/**
|
|
466
|
+
* Adjust resource allocation based on current system load.
|
|
467
|
+
* When utilization is high, reduce per-instance allocation to fit more agents.
|
|
468
|
+
* When low, let them use default or requested amounts.
|
|
469
|
+
*/
|
|
470
|
+
balanceResources(requested) {
|
|
471
|
+
if (!requested)
|
|
472
|
+
return undefined;
|
|
473
|
+
const snapshot = this.runtime.getResourceSnapshot();
|
|
474
|
+
const memoryUtilization = snapshot.totalMemoryMB / snapshot.maxMemoryMB;
|
|
475
|
+
const agentUtilization = snapshot.activeAgents / snapshot.maxAgents;
|
|
476
|
+
// If utilization is under 60%, use requested values as-is
|
|
477
|
+
if (memoryUtilization < 0.6 && agentUtilization < 0.6) {
|
|
478
|
+
return requested;
|
|
479
|
+
}
|
|
480
|
+
// Under pressure: scale down memory to fit
|
|
481
|
+
const memoryLimit = requested.memoryLimitMB;
|
|
482
|
+
if (memoryLimit && memoryUtilization > 0.8) {
|
|
483
|
+
const available = snapshot.maxMemoryMB - snapshot.totalMemoryMB;
|
|
484
|
+
const scaled = Math.min(memoryLimit, Math.max(128, available * 0.8));
|
|
485
|
+
return { ...requested, memoryLimitMB: Math.round(scaled) };
|
|
486
|
+
}
|
|
487
|
+
return requested;
|
|
488
|
+
}
|
|
489
|
+
// -------------------------------------------------------------------------
|
|
490
|
+
// Internal: isolation enforcement
|
|
491
|
+
// -------------------------------------------------------------------------
|
|
492
|
+
/**
|
|
493
|
+
* Enforce isolation settings on spawn requests.
|
|
494
|
+
* For sandboxed instances, assign a unique working directory and
|
|
495
|
+
* strip environment variables that could leak across agents.
|
|
496
|
+
*/
|
|
497
|
+
enforceIsolation(request) {
|
|
498
|
+
const isolation = request.config?.isolation;
|
|
499
|
+
if (isolation !== "sandboxed")
|
|
500
|
+
return request.config;
|
|
501
|
+
const sanitizedEnv = {};
|
|
502
|
+
const allowedPrefixes = ["CORE_", "DASH_", "NODE_", "PATH"];
|
|
503
|
+
if (request.config?.env) {
|
|
504
|
+
for (const [key, value] of Object.entries(request.config.env)) {
|
|
505
|
+
if (allowedPrefixes.some((p) => key.startsWith(p))) {
|
|
506
|
+
sanitizedEnv[key] = value;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
...request.config,
|
|
512
|
+
env: sanitizedEnv,
|
|
513
|
+
isolation: "sandboxed",
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
// -------------------------------------------------------------------------
|
|
517
|
+
// Internal: garbage collection
|
|
518
|
+
// -------------------------------------------------------------------------
|
|
519
|
+
/**
|
|
520
|
+
* Start the GC loop using chained setTimeout with random jitter (B-010).
|
|
521
|
+
* Jitter (0–10s) prevents thundering herd when multiple timers align.
|
|
522
|
+
* Uses setTimeout chain instead of setInterval so each cycle's delay
|
|
523
|
+
* is independent and includes fresh jitter.
|
|
524
|
+
*/
|
|
525
|
+
startGc() {
|
|
526
|
+
if (this.gcTimer)
|
|
527
|
+
return;
|
|
528
|
+
this.scheduleNextGc();
|
|
529
|
+
}
|
|
530
|
+
scheduleNextGc() {
|
|
531
|
+
if (this.destroyed)
|
|
532
|
+
return;
|
|
533
|
+
const jitter = Math.floor(Math.random() * 10_000); // 0–10s
|
|
534
|
+
this.gcTimer = setTimeout(() => {
|
|
535
|
+
this.runGc()
|
|
536
|
+
.catch((err) => {
|
|
537
|
+
logActivity({
|
|
538
|
+
source: "agent",
|
|
539
|
+
summary: "Instance GC error",
|
|
540
|
+
detail: err.message,
|
|
541
|
+
});
|
|
542
|
+
})
|
|
543
|
+
.finally(() => {
|
|
544
|
+
this.scheduleNextGc();
|
|
545
|
+
});
|
|
546
|
+
}, this.config.gcIntervalMs + jitter);
|
|
547
|
+
}
|
|
548
|
+
stopGc() {
|
|
549
|
+
if (this.gcTimer) {
|
|
550
|
+
clearTimeout(this.gcTimer);
|
|
551
|
+
this.gcTimer = null;
|
|
552
|
+
}
|
|
553
|
+
if (this.gcAdaptiveTimer) {
|
|
554
|
+
clearTimeout(this.gcAdaptiveTimer);
|
|
555
|
+
this.gcAdaptiveTimer = null;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Schedule an accelerated GC cycle when the regular cycle found more work
|
|
560
|
+
* than it could handle (batch-capped). Uses gcMinIntervalMs to avoid
|
|
561
|
+
* thrashing. Skipped if a regular GC timer tick will fire sooner.
|
|
562
|
+
*/
|
|
563
|
+
scheduleAdaptiveGc(remainingEligible) {
|
|
564
|
+
if (this.gcAdaptiveTimer || this.destroyed)
|
|
565
|
+
return;
|
|
566
|
+
// Scale delay: more backlog → shorter delay (floor at gcMinIntervalMs)
|
|
567
|
+
const urgency = Math.min(1, remainingEligible / this.config.gcBatchSize);
|
|
568
|
+
const delay = Math.max(this.config.gcMinIntervalMs, this.config.gcIntervalMs * (1 - urgency * 0.8));
|
|
569
|
+
this.gcAdaptiveTimer = setTimeout(() => {
|
|
570
|
+
this.gcAdaptiveTimer = null;
|
|
571
|
+
this.gcMetrics.adaptiveRuns++;
|
|
572
|
+
this.runGc().catch((err) => {
|
|
573
|
+
logActivity({
|
|
574
|
+
source: "agent",
|
|
575
|
+
summary: "Adaptive GC error",
|
|
576
|
+
detail: err.message,
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}, delay);
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Remove terminated/completed/failed instances that have exceeded the GC TTL.
|
|
583
|
+
* Cleans up both the registry and local metadata, plus associated task files.
|
|
584
|
+
*
|
|
585
|
+
* Optimizations (DASH-139 / DASH-141):
|
|
586
|
+
* - Filter at registry level to avoid scanning non-terminal instances
|
|
587
|
+
* - Use ISO string comparison instead of Date parsing in hot loop
|
|
588
|
+
* - Batch file deletions in chunks to reduce NTFS directory lock contention
|
|
589
|
+
* - Concurrent-run guard prevents overlapping GC cycles
|
|
590
|
+
* - Adaptive scheduling runs sooner when batch-capped
|
|
591
|
+
* - Top-level imports (no dynamic import overhead per cycle)
|
|
592
|
+
* - GC metrics tracking for observability
|
|
593
|
+
*/
|
|
594
|
+
async runGc() {
|
|
595
|
+
// Prevent overlapping GC cycles (adaptive + regular timer can race)
|
|
596
|
+
if (this.gcRunning)
|
|
597
|
+
return;
|
|
598
|
+
this.gcRunning = true;
|
|
599
|
+
const start = Date.now();
|
|
600
|
+
try {
|
|
601
|
+
await this.runGcInner(start);
|
|
602
|
+
}
|
|
603
|
+
finally {
|
|
604
|
+
this.gcRunning = false;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
async runGcInner(start) {
|
|
608
|
+
const timing = {
|
|
609
|
+
scanMs: 0,
|
|
610
|
+
metaCleanupMs: 0,
|
|
611
|
+
registryRemoveMs: 0,
|
|
612
|
+
fileDeleteMs: 0,
|
|
613
|
+
pruneMs: 0,
|
|
614
|
+
totalMs: 0,
|
|
615
|
+
};
|
|
616
|
+
// Phase 1: query only terminal instances using cached array (avoids
|
|
617
|
+
// spreading TERMINAL_STATES into a new array every cycle)
|
|
618
|
+
const terminal = this.runtime.listInstances({
|
|
619
|
+
states: this.terminalStatesArray,
|
|
620
|
+
});
|
|
621
|
+
if (terminal.length === 0)
|
|
622
|
+
return;
|
|
623
|
+
// Pre-compute ISO cutoff string — lexicographic comparison avoids Date parsing
|
|
624
|
+
const cutoffMs = start - this.config.gcTtlMs;
|
|
625
|
+
const cutoff = new Date(cutoffMs).toISOString();
|
|
626
|
+
// Phase 2: identify eligible instances, counting total for adaptive scheduling
|
|
627
|
+
const eligible = [];
|
|
628
|
+
let totalEligible = 0;
|
|
629
|
+
// When backlog exceeds hard limit, bypass batch cap for this cycle (B-010).
|
|
630
|
+
// This prevents unbounded accumulation when instances terminate faster
|
|
631
|
+
// than GC can drain at normal batch size.
|
|
632
|
+
const effectiveBatchSize = terminal.length > AgentInstanceManager.BACKLOG_HARD_LIMIT
|
|
633
|
+
? terminal.length // uncapped — drain everything
|
|
634
|
+
: this.config.gcBatchSize;
|
|
635
|
+
for (const inst of terminal) {
|
|
636
|
+
const finishedAt = inst.terminatedAt ?? inst.updatedAt;
|
|
637
|
+
if (finishedAt < cutoff) {
|
|
638
|
+
totalEligible++;
|
|
639
|
+
if (eligible.length < effectiveBatchSize) {
|
|
640
|
+
eligible.push({ id: inst.id, taskId: inst.taskId });
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (eligible.length === 0)
|
|
645
|
+
return;
|
|
646
|
+
timing.scanMs = Date.now() - start;
|
|
647
|
+
// Phase 3: clear local metadata (sync, fast)
|
|
648
|
+
const metaStart = Date.now();
|
|
649
|
+
for (const { id } of eligible) {
|
|
650
|
+
this.meta.delete(id);
|
|
651
|
+
}
|
|
652
|
+
timing.metaCleanupMs = Date.now() - metaStart;
|
|
653
|
+
// Yield to event loop between phases so GC doesn't block other work
|
|
654
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
655
|
+
// Phase 4+5 (merged): remove from registry in-memory, then delete ALL
|
|
656
|
+
// files (registry + task + logs) in a single chunked pass.
|
|
657
|
+
const registryStart = Date.now();
|
|
658
|
+
const ids = eligible.map((e) => e.id);
|
|
659
|
+
const { removed: collected, filePaths: allFiles } = this.runtime.removeInstancesInMemory(ids);
|
|
660
|
+
// Append task + log file paths for instances that have a taskId
|
|
661
|
+
for (const { taskId } of eligible) {
|
|
662
|
+
if (!taskId)
|
|
663
|
+
continue;
|
|
664
|
+
allFiles.push(join(TASKS_DIR, `${taskId}.json`));
|
|
665
|
+
allFiles.push(join(LOGS_DIR, `${taskId}.stdout.log`));
|
|
666
|
+
allFiles.push(join(LOGS_DIR, `${taskId}.stderr.log`));
|
|
667
|
+
allFiles.push(join(LOGS_DIR, `${taskId}.prompt.txt`));
|
|
668
|
+
}
|
|
669
|
+
timing.registryRemoveMs = Date.now() - registryStart;
|
|
670
|
+
// Single-pass chunked deletion for all file types.
|
|
671
|
+
// Chunk size 40 balances parallelism vs NTFS directory lock contention.
|
|
672
|
+
const deleteStart = Date.now();
|
|
673
|
+
let failCount = 0;
|
|
674
|
+
if (allFiles.length > 0) {
|
|
675
|
+
const CHUNK = 40;
|
|
676
|
+
for (let i = 0; i < allFiles.length; i += CHUNK) {
|
|
677
|
+
const results = await Promise.allSettled(allFiles.slice(i, i + CHUNK).map((f) => unlink(f)));
|
|
678
|
+
for (const r of results) {
|
|
679
|
+
if (r.status === "rejected") {
|
|
680
|
+
const err = r.reason;
|
|
681
|
+
// ENOENT is expected (not all log types exist for every task)
|
|
682
|
+
if (err?.code !== "ENOENT")
|
|
683
|
+
failCount++;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
timing.fileDeleteMs = Date.now() - deleteStart;
|
|
689
|
+
if (failCount > 0) {
|
|
690
|
+
logActivity({
|
|
691
|
+
source: "agent",
|
|
692
|
+
summary: `Instance GC: ${failCount} file deletions failed`,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
// Phase 6: prune stale metadata entries for instances no longer in registry.
|
|
696
|
+
// Prevents the meta map from growing unboundedly when instances are removed
|
|
697
|
+
// externally or through other code paths.
|
|
698
|
+
const pruneStart = Date.now();
|
|
699
|
+
if (this.meta.size > this.config.gcBatchSize) {
|
|
700
|
+
this.pruneOrphanedMeta();
|
|
701
|
+
}
|
|
702
|
+
timing.pruneMs = Date.now() - pruneStart;
|
|
703
|
+
const elapsed = Date.now() - start;
|
|
704
|
+
timing.totalMs = elapsed;
|
|
705
|
+
const wasCapped = totalEligible > eligible.length;
|
|
706
|
+
const wasBacklogForced = terminal.length > AgentInstanceManager.BACKLOG_HARD_LIMIT;
|
|
707
|
+
// Update GC metrics
|
|
708
|
+
this.gcMetrics.totalCycles++;
|
|
709
|
+
this.gcMetrics.totalCollected += collected;
|
|
710
|
+
this.gcMetrics.totalTimeMs += elapsed;
|
|
711
|
+
this.gcMetrics.lastRunAt = new Date(start).toISOString();
|
|
712
|
+
this.gcMetrics.lastPhaseTiming = timing;
|
|
713
|
+
if (collected > this.gcMetrics.peakCollected)
|
|
714
|
+
this.gcMetrics.peakCollected = collected;
|
|
715
|
+
if (elapsed > this.gcMetrics.peakTimeMs)
|
|
716
|
+
this.gcMetrics.peakTimeMs = elapsed;
|
|
717
|
+
if (timing.fileDeleteMs > this.gcMetrics.peakFileDeleteMs)
|
|
718
|
+
this.gcMetrics.peakFileDeleteMs = timing.fileDeleteMs;
|
|
719
|
+
if (wasCapped)
|
|
720
|
+
this.gcMetrics.cappedCycles++;
|
|
721
|
+
log.debug("GC cycle complete", { collected, totalEligible, terminal: terminal.length, elapsed, wasCapped, cycle: this.gcMetrics.totalCycles });
|
|
722
|
+
logActivity({
|
|
723
|
+
source: "agent",
|
|
724
|
+
summary: `Instance GC: collected ${collected} of ${totalEligible} eligible (${terminal.length} terminal)`,
|
|
725
|
+
detail: `${elapsed}ms [scan:${timing.scanMs} meta:${timing.metaCleanupMs} reg:${timing.registryRemoveMs} del:${timing.fileDeleteMs} prune:${timing.pruneMs}] ${allFiles.length} files, cycle #${this.gcMetrics.totalCycles}${wasCapped ? ', BATCH CAPPED' : ''}${wasBacklogForced ? ', BACKLOG FORCED' : ''}`,
|
|
726
|
+
});
|
|
727
|
+
// If we hit the batch cap, there's more work to do — schedule an early cycle
|
|
728
|
+
if (wasCapped) {
|
|
729
|
+
this.scheduleAdaptiveGc(totalEligible - eligible.length);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Prune metadata entries for instances that no longer exist in the registry.
|
|
734
|
+
* Uses a Set of current instance IDs for O(1) lookups instead of calling
|
|
735
|
+
* getInstance() per entry (which scans the registry map each time).
|
|
736
|
+
*/
|
|
737
|
+
pruneOrphanedMeta() {
|
|
738
|
+
// Build a Set of all known instance IDs (single pass over registry)
|
|
739
|
+
const knownIds = new Set(this.runtime.listInstances().map((i) => i.id));
|
|
740
|
+
for (const id of this.meta.keys()) {
|
|
741
|
+
if (!knownIds.has(id)) {
|
|
742
|
+
this.meta.delete(id);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
// -------------------------------------------------------------------------
|
|
747
|
+
// Internal: health checks
|
|
748
|
+
// -------------------------------------------------------------------------
|
|
749
|
+
startHealthChecks() {
|
|
750
|
+
if (this.healthTimer)
|
|
751
|
+
return;
|
|
752
|
+
this.healthTimer = setInterval(() => {
|
|
753
|
+
this.runHealthChecks().catch((err) => {
|
|
754
|
+
logActivity({
|
|
755
|
+
source: "agent",
|
|
756
|
+
summary: "Health check error",
|
|
757
|
+
detail: err.message,
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
}, this.config.healthCheckIntervalMs);
|
|
761
|
+
}
|
|
762
|
+
stopHealthChecks() {
|
|
763
|
+
if (this.healthTimer) {
|
|
764
|
+
clearInterval(this.healthTimer);
|
|
765
|
+
this.healthTimer = null;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Run health checks on all active instances.
|
|
770
|
+
* If auto-recovery is enabled, restart instances that exceed the
|
|
771
|
+
* unhealthy threshold.
|
|
772
|
+
*/
|
|
773
|
+
async runHealthChecks() {
|
|
774
|
+
const active = this.runtime.listActive();
|
|
775
|
+
for (const inst of active) {
|
|
776
|
+
const health = this.assessHealth(inst.id);
|
|
777
|
+
if (!health.healthy && this.config.autoRecover) {
|
|
778
|
+
const meta = this.ensureMeta(inst.id);
|
|
779
|
+
if (meta.consecutiveFailures >= this.config.unhealthyThreshold) {
|
|
780
|
+
// Cap total auto-restarts to prevent infinite restart loops
|
|
781
|
+
if (meta.restartCount >= this.config.maxAutoRestarts) {
|
|
782
|
+
logActivity({
|
|
783
|
+
source: "agent",
|
|
784
|
+
summary: `Auto-recovery skipped (max restarts ${this.config.maxAutoRestarts} reached): ${inst.metadata.label}`,
|
|
785
|
+
detail: `Restarts: ${meta.restartCount}, failures: ${meta.consecutiveFailures}`,
|
|
786
|
+
});
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
logActivity({
|
|
790
|
+
source: "agent",
|
|
791
|
+
summary: `Auto-recovering unhealthy agent: ${inst.metadata.label}`,
|
|
792
|
+
detail: `Score: ${health.score}, failures: ${meta.consecutiveFailures}, restarts: ${meta.restartCount}/${this.config.maxAutoRestarts}`,
|
|
793
|
+
});
|
|
794
|
+
try {
|
|
795
|
+
await this.restart(inst.id, "Auto-recovery: unhealthy threshold exceeded");
|
|
796
|
+
}
|
|
797
|
+
catch (err) {
|
|
798
|
+
logActivity({
|
|
799
|
+
source: "agent",
|
|
800
|
+
summary: `Auto-recovery failed: ${inst.metadata.label}`,
|
|
801
|
+
detail: err.message,
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
// -------------------------------------------------------------------------
|
|
809
|
+
// Internal: filter instances
|
|
810
|
+
// -------------------------------------------------------------------------
|
|
811
|
+
filterInstances(filter) {
|
|
812
|
+
let instances = this.runtime.listInstances();
|
|
813
|
+
if (filter.states) {
|
|
814
|
+
const states = new Set(filter.states);
|
|
815
|
+
instances = instances.filter((i) => states.has(i.state));
|
|
816
|
+
}
|
|
817
|
+
if (filter.tags) {
|
|
818
|
+
const tags = new Set(filter.tags);
|
|
819
|
+
instances = instances.filter((i) => i.metadata.tags.some((t) => tags.has(t)));
|
|
820
|
+
}
|
|
821
|
+
if (filter.origin) {
|
|
822
|
+
instances = instances.filter((i) => i.metadata.origin === filter.origin);
|
|
823
|
+
}
|
|
824
|
+
if (filter.labelPattern) {
|
|
825
|
+
const re = new RegExp(filter.labelPattern, "i");
|
|
826
|
+
instances = instances.filter((i) => re.test(i.metadata.label));
|
|
827
|
+
}
|
|
828
|
+
if (filter.olderThanMs) {
|
|
829
|
+
const cutoff = Date.now() - filter.olderThanMs;
|
|
830
|
+
instances = instances.filter((i) => new Date(i.createdAt).getTime() < cutoff);
|
|
831
|
+
}
|
|
832
|
+
return instances;
|
|
833
|
+
}
|
|
834
|
+
// -------------------------------------------------------------------------
|
|
835
|
+
// Internal: metadata helpers
|
|
836
|
+
// -------------------------------------------------------------------------
|
|
837
|
+
ensureMeta(instanceId) {
|
|
838
|
+
let meta = this.meta.get(instanceId);
|
|
839
|
+
if (!meta) {
|
|
840
|
+
meta = {
|
|
841
|
+
history: [],
|
|
842
|
+
restartCount: 0,
|
|
843
|
+
consecutiveFailures: 0,
|
|
844
|
+
};
|
|
845
|
+
this.meta.set(instanceId, meta);
|
|
846
|
+
}
|
|
847
|
+
return meta;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
//# sourceMappingURL=instance-manager.js.map
|