@cleocode/core 2026.3.42 → 2026.3.44
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/dist/adapters/adapter-registry.d.ts +29 -0
- package/dist/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/adapters/discovery.d.ts +18 -0
- package/dist/adapters/discovery.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +10 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/manager.d.ts +81 -0
- package/dist/adapters/manager.d.ts.map +1 -0
- package/dist/admin/export-tasks.d.ts +30 -0
- package/dist/admin/export-tasks.d.ts.map +1 -0
- package/dist/admin/export.d.ts +28 -0
- package/dist/admin/export.d.ts.map +1 -0
- package/dist/admin/help.d.ts +74 -0
- package/dist/admin/help.d.ts.map +1 -0
- package/dist/admin/import-tasks.d.ts +43 -0
- package/dist/admin/import-tasks.d.ts.map +1 -0
- package/dist/admin/import.d.ts +33 -0
- package/dist/admin/import.d.ts.map +1 -0
- package/dist/admin/index.d.ts +14 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/adrs/find.d.ts +24 -0
- package/dist/adrs/find.d.ts.map +1 -0
- package/dist/adrs/index.d.ts +18 -0
- package/dist/adrs/index.d.ts.map +1 -0
- package/dist/adrs/link-pipeline.d.ts +35 -0
- package/dist/adrs/link-pipeline.d.ts.map +1 -0
- package/dist/adrs/list.d.ts +16 -0
- package/dist/adrs/list.d.ts.map +1 -0
- package/dist/adrs/parse.d.ts +18 -0
- package/dist/adrs/parse.d.ts.map +1 -0
- package/dist/adrs/show.d.ts +11 -0
- package/dist/adrs/show.d.ts.map +1 -0
- package/dist/adrs/sync.d.ts +20 -0
- package/dist/adrs/sync.d.ts.map +1 -0
- package/dist/adrs/types.d.ts +67 -0
- package/dist/adrs/types.d.ts.map +1 -0
- package/dist/adrs/validate.d.ts +24 -0
- package/dist/adrs/validate.d.ts.map +1 -0
- package/dist/agents/agent-schema.d.ts +358 -0
- package/dist/agents/agent-schema.d.ts.map +1 -0
- package/dist/agents/capacity.d.ts +57 -0
- package/dist/agents/capacity.d.ts.map +1 -0
- package/dist/agents/index.d.ts +17 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/registry.d.ts +115 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/retry.d.ts +83 -0
- package/dist/agents/retry.d.ts.map +1 -0
- package/dist/audit-prune.d.ts +35 -0
- package/dist/audit-prune.d.ts.map +1 -0
- package/dist/audit.d.ts +49 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/bootstrap.d.ts +44 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/caamp/adapter.d.ts +130 -0
- package/dist/caamp/adapter.d.ts.map +1 -0
- package/dist/caamp/capability-check.d.ts +27 -0
- package/dist/caamp/capability-check.d.ts.map +1 -0
- package/dist/caamp/index.d.ts +12 -0
- package/dist/caamp/index.d.ts.map +1 -0
- package/dist/caamp-init.d.ts +2 -0
- package/dist/caamp-init.d.ts.map +1 -0
- package/dist/cleo.d.ts +295 -0
- package/dist/cleo.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/architecture.d.ts +7 -0
- package/dist/codebase-map/analyzers/architecture.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/concerns.d.ts +6 -0
- package/dist/codebase-map/analyzers/concerns.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/conventions.d.ts +8 -0
- package/dist/codebase-map/analyzers/conventions.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/integrations.d.ts +7 -0
- package/dist/codebase-map/analyzers/integrations.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/stack.d.ts +8 -0
- package/dist/codebase-map/analyzers/stack.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/structure.d.ts +6 -0
- package/dist/codebase-map/analyzers/structure.d.ts.map +1 -0
- package/dist/codebase-map/analyzers/testing.d.ts +8 -0
- package/dist/codebase-map/analyzers/testing.d.ts.map +1 -0
- package/dist/codebase-map/index.d.ts +94 -0
- package/dist/codebase-map/index.d.ts.map +1 -0
- package/dist/codebase-map/store.d.ts +13 -0
- package/dist/codebase-map/store.d.ts.map +1 -0
- package/dist/codebase-map/summary.d.ts +7 -0
- package/dist/codebase-map/summary.d.ts.map +1 -0
- package/dist/compliance/index.d.ts +38 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/protocol-enforcement.d.ts +106 -0
- package/dist/compliance/protocol-enforcement.d.ts.map +1 -0
- package/dist/compliance/protocol-rules.d.ts +55 -0
- package/dist/compliance/protocol-rules.d.ts.map +1 -0
- package/dist/compliance/protocol-types.d.ts +109 -0
- package/dist/compliance/protocol-types.d.ts.map +1 -0
- package/dist/compliance/store.d.ts +19 -0
- package/dist/compliance/store.d.ts.map +1 -0
- package/dist/config/build-config.d.ts +31 -0
- package/dist/config/build-config.d.ts.map +1 -0
- package/dist/config.d.ts +53 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/context/index.d.ts +20 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/engine-result.d.ts +31 -0
- package/dist/engine-result.d.ts.map +1 -0
- package/dist/error-catalog.d.ts +49 -0
- package/dist/error-catalog.d.ts.map +1 -0
- package/dist/error-registry.d.ts +58 -0
- package/dist/error-registry.d.ts.map +1 -0
- package/dist/errors.d.ts +66 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/hooks/handlers/error-hooks.d.ts +18 -0
- package/dist/hooks/handlers/error-hooks.d.ts.map +1 -0
- package/dist/hooks/handlers/file-hooks.d.ts +20 -0
- package/dist/hooks/handlers/file-hooks.d.ts.map +1 -0
- package/dist/hooks/handlers/index.d.ts +17 -0
- package/dist/hooks/handlers/index.d.ts.map +1 -0
- package/dist/hooks/handlers/mcp-hooks.d.ts +22 -0
- package/dist/hooks/handlers/mcp-hooks.d.ts.map +1 -0
- package/dist/hooks/handlers/session-hooks.d.ts +16 -0
- package/dist/hooks/handlers/session-hooks.d.ts.map +1 -0
- package/dist/hooks/handlers/task-hooks.d.ts +16 -0
- package/dist/hooks/handlers/task-hooks.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +15 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/payload-schemas.d.ts +214 -0
- package/dist/hooks/payload-schemas.d.ts.map +1 -0
- package/dist/hooks/provider-hooks.d.ts +27 -0
- package/dist/hooks/provider-hooks.d.ts.map +1 -0
- package/dist/hooks/registry.d.ts +111 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/types.d.ts +299 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks.d.ts +46 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16443 -2160
- package/dist/index.js.map +4 -4
- package/dist/init.d.ts +137 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/inject/index.d.ts +26 -0
- package/dist/inject/index.d.ts.map +1 -0
- package/dist/injection.d.ts +69 -0
- package/dist/injection.d.ts.map +1 -0
- package/dist/intelligence/impact.d.ts +51 -0
- package/dist/intelligence/impact.d.ts.map +1 -0
- package/dist/intelligence/index.d.ts +15 -0
- package/dist/intelligence/index.d.ts.map +1 -0
- package/dist/intelligence/patterns.d.ts +66 -0
- package/dist/intelligence/patterns.d.ts.map +1 -0
- package/dist/intelligence/prediction.d.ts +51 -0
- package/dist/intelligence/prediction.d.ts.map +1 -0
- package/dist/intelligence/types.d.ts +221 -0
- package/dist/intelligence/types.d.ts.map +1 -0
- package/dist/internal.d.ts +209 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/issue/create.d.ts +43 -0
- package/dist/issue/create.d.ts.map +1 -0
- package/dist/issue/diagnostics.d.ts +18 -0
- package/dist/issue/diagnostics.d.ts.map +1 -0
- package/dist/issue/index.d.ts +12 -0
- package/dist/issue/index.d.ts.map +1 -0
- package/dist/issue/template-parser.d.ts +54 -0
- package/dist/issue/template-parser.d.ts.map +1 -0
- package/dist/json-schema-validator.d.ts +20 -0
- package/dist/json-schema-validator.d.ts.map +1 -0
- package/dist/lifecycle/chain-composition.d.ts +30 -0
- package/dist/lifecycle/chain-composition.d.ts.map +1 -0
- package/dist/lifecycle/chain-store.d.ts +70 -0
- package/dist/lifecycle/chain-store.d.ts.map +1 -0
- package/dist/lifecycle/consolidate-rcasd.d.ts +81 -0
- package/dist/lifecycle/consolidate-rcasd.d.ts.map +1 -0
- package/dist/lifecycle/default-chain.d.ts +33 -0
- package/dist/lifecycle/default-chain.d.ts.map +1 -0
- package/dist/lifecycle/evidence.d.ts +71 -0
- package/dist/lifecycle/evidence.d.ts.map +1 -0
- package/dist/lifecycle/frontmatter.d.ts +104 -0
- package/dist/lifecycle/frontmatter.d.ts.map +1 -0
- package/dist/lifecycle/index.d.ts +228 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/pipeline.d.ts +335 -0
- package/dist/lifecycle/pipeline.d.ts.map +1 -0
- package/dist/lifecycle/rcasd-index.d.ts +168 -0
- package/dist/lifecycle/rcasd-index.d.ts.map +1 -0
- package/dist/lifecycle/rcasd-paths.d.ts +103 -0
- package/dist/lifecycle/rcasd-paths.d.ts.map +1 -0
- package/dist/lifecycle/resume.d.ts +501 -0
- package/dist/lifecycle/resume.d.ts.map +1 -0
- package/dist/lifecycle/stage-artifacts.d.ts +23 -0
- package/dist/lifecycle/stage-artifacts.d.ts.map +1 -0
- package/dist/lifecycle/stages.d.ts +323 -0
- package/dist/lifecycle/stages.d.ts.map +1 -0
- package/dist/lifecycle/state-machine.d.ts +327 -0
- package/dist/lifecycle/state-machine.d.ts.map +1 -0
- package/dist/lifecycle/tessera-engine.d.ts +48 -0
- package/dist/lifecycle/tessera-engine.d.ts.map +1 -0
- package/dist/logger.d.ts +54 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +42 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/memory/auto-extract.d.ts +34 -0
- package/dist/memory/auto-extract.d.ts.map +1 -0
- package/dist/memory/brain-embedding.d.ts +42 -0
- package/dist/memory/brain-embedding.d.ts.map +1 -0
- package/dist/memory/brain-lifecycle.d.ts +57 -0
- package/dist/memory/brain-lifecycle.d.ts.map +1 -0
- package/dist/memory/brain-links.d.ts +75 -0
- package/dist/memory/brain-links.d.ts.map +1 -0
- package/dist/memory/brain-migration.d.ts +30 -0
- package/dist/memory/brain-migration.d.ts.map +1 -0
- package/dist/memory/brain-reasoning.d.ts +54 -0
- package/dist/memory/brain-reasoning.d.ts.map +1 -0
- package/dist/memory/brain-retrieval.d.ts +157 -0
- package/dist/memory/brain-retrieval.d.ts.map +1 -0
- package/dist/memory/brain-row-types.d.ts +79 -0
- package/dist/memory/brain-row-types.d.ts.map +1 -0
- package/dist/memory/brain-search.d.ts +91 -0
- package/dist/memory/brain-search.d.ts.map +1 -0
- package/dist/memory/brain-similarity.d.ts +33 -0
- package/dist/memory/brain-similarity.d.ts.map +1 -0
- package/dist/memory/claude-mem-migration.d.ts +45 -0
- package/dist/memory/claude-mem-migration.d.ts.map +1 -0
- package/dist/memory/decisions.d.ts +72 -0
- package/dist/memory/decisions.d.ts.map +1 -0
- package/dist/memory/engine-compat.d.ts +144 -0
- package/dist/memory/engine-compat.d.ts.map +1 -0
- package/dist/memory/index.d.ts +305 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/learnings.d.ts +74 -0
- package/dist/memory/learnings.d.ts.map +1 -0
- package/dist/memory/memory-bridge.d.ts +50 -0
- package/dist/memory/memory-bridge.d.ts.map +1 -0
- package/dist/memory/patterns.d.ts +87 -0
- package/dist/memory/patterns.d.ts.map +1 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts +83 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -0
- package/dist/memory/session-memory.d.ts +88 -0
- package/dist/memory/session-memory.d.ts.map +1 -0
- package/dist/metrics/ab-test.d.ts +52 -0
- package/dist/metrics/ab-test.d.ts.map +1 -0
- package/dist/metrics/aggregation.d.ts +41 -0
- package/dist/metrics/aggregation.d.ts.map +1 -0
- package/dist/metrics/common.d.ts +30 -0
- package/dist/metrics/common.d.ts.map +1 -0
- package/dist/metrics/enums.d.ts +68 -0
- package/dist/metrics/enums.d.ts.map +1 -0
- package/dist/metrics/index.d.ts +17 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/model-provider-registry.d.ts +17 -0
- package/dist/metrics/model-provider-registry.d.ts.map +1 -0
- package/dist/metrics/otel-integration.d.ts +49 -0
- package/dist/metrics/otel-integration.d.ts.map +1 -0
- package/dist/metrics/provider-detection.d.ts +20 -0
- package/dist/metrics/provider-detection.d.ts.map +1 -0
- package/dist/metrics/token-estimation.d.ts +70 -0
- package/dist/metrics/token-estimation.d.ts.map +1 -0
- package/dist/metrics/token-service.d.ts +107 -0
- package/dist/metrics/token-service.d.ts.map +1 -0
- package/dist/migration/agent-outputs.d.ts +70 -0
- package/dist/migration/agent-outputs.d.ts.map +1 -0
- package/dist/migration/checksum.d.ts +55 -0
- package/dist/migration/checksum.d.ts.map +1 -0
- package/dist/migration/index.d.ts +79 -0
- package/dist/migration/index.d.ts.map +1 -0
- package/dist/migration/logger.d.ts +161 -0
- package/dist/migration/logger.d.ts.map +1 -0
- package/dist/migration/preflight.d.ts +10 -0
- package/dist/migration/preflight.d.ts.map +1 -0
- package/dist/migration/state.d.ts +186 -0
- package/dist/migration/state.d.ts.map +1 -0
- package/dist/migration/validate.d.ts +57 -0
- package/dist/migration/validate.d.ts.map +1 -0
- package/dist/nexus/deps.d.ts +98 -0
- package/dist/nexus/deps.d.ts.map +1 -0
- package/dist/nexus/discover.d.ts +66 -0
- package/dist/nexus/discover.d.ts.map +1 -0
- package/dist/nexus/hash.d.ts +7 -0
- package/dist/nexus/hash.d.ts.map +1 -0
- package/dist/nexus/index.d.ts +17 -0
- package/dist/nexus/index.d.ts.map +1 -0
- package/dist/nexus/migrate-json-to-sqlite.d.ts +23 -0
- package/dist/nexus/migrate-json-to-sqlite.d.ts.map +1 -0
- package/dist/nexus/permissions.d.ts +60 -0
- package/dist/nexus/permissions.d.ts.map +1 -0
- package/dist/nexus/query.d.ts +53 -0
- package/dist/nexus/query.d.ts.map +1 -0
- package/dist/nexus/registry.d.ts +126 -0
- package/dist/nexus/registry.d.ts.map +1 -0
- package/dist/nexus/sharing/index.d.ts +39 -0
- package/dist/nexus/sharing/index.d.ts.map +1 -0
- package/dist/observability/index.d.ts +32 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/log-filter.d.ts +31 -0
- package/dist/observability/log-filter.d.ts.map +1 -0
- package/dist/observability/log-parser.d.ts +26 -0
- package/dist/observability/log-parser.d.ts.map +1 -0
- package/dist/observability/log-reader.d.ts +35 -0
- package/dist/observability/log-reader.d.ts.map +1 -0
- package/dist/observability/types.d.ts +112 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/orchestration/analyze.d.ts +57 -0
- package/dist/orchestration/analyze.d.ts.map +1 -0
- package/dist/orchestration/bootstrap.d.ts +12 -0
- package/dist/orchestration/bootstrap.d.ts.map +1 -0
- package/dist/orchestration/context.d.ts +38 -0
- package/dist/orchestration/context.d.ts.map +1 -0
- package/dist/orchestration/critical-path.d.ts +22 -0
- package/dist/orchestration/critical-path.d.ts.map +1 -0
- package/dist/orchestration/index.d.ts +116 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/parallel.d.ts +35 -0
- package/dist/orchestration/parallel.d.ts.map +1 -0
- package/dist/orchestration/protocol-validators.d.ts +96 -0
- package/dist/orchestration/protocol-validators.d.ts.map +1 -0
- package/dist/orchestration/skill-ops.d.ts +29 -0
- package/dist/orchestration/skill-ops.d.ts.map +1 -0
- package/dist/orchestration/status.d.ts +92 -0
- package/dist/orchestration/status.d.ts.map +1 -0
- package/dist/orchestration/unblock.d.ts +31 -0
- package/dist/orchestration/unblock.d.ts.map +1 -0
- package/dist/orchestration/validate-spawn.d.ts +19 -0
- package/dist/orchestration/validate-spawn.d.ts.map +1 -0
- package/dist/orchestration/waves.d.ts +26 -0
- package/dist/orchestration/waves.d.ts.map +1 -0
- package/dist/otel/index.d.ts +27 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/output.d.ts +66 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/pagination.d.ts +45 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/paths.d.ts +165 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/phases/deps.d.ts +119 -0
- package/dist/phases/deps.d.ts.map +1 -0
- package/dist/phases/index.d.ts +123 -0
- package/dist/phases/index.d.ts.map +1 -0
- package/dist/pipeline/index.d.ts +10 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/phase.d.ts +36 -0
- package/dist/pipeline/phase.d.ts.map +1 -0
- package/dist/platform.d.ts +103 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/project-info.d.ts +35 -0
- package/dist/project-info.d.ts.map +1 -0
- package/dist/reconciliation/index.d.ts +10 -0
- package/dist/reconciliation/index.d.ts.map +1 -0
- package/dist/reconciliation/link-store.d.ts +44 -0
- package/dist/reconciliation/link-store.d.ts.map +1 -0
- package/dist/reconciliation/reconciliation-engine.d.ts +24 -0
- package/dist/reconciliation/reconciliation-engine.d.ts.map +1 -0
- package/dist/release/artifacts.d.ts +71 -0
- package/dist/release/artifacts.d.ts.map +1 -0
- package/dist/release/changelog-writer.d.ts +26 -0
- package/dist/release/changelog-writer.d.ts.map +1 -0
- package/dist/release/channel.d.ts +54 -0
- package/dist/release/channel.d.ts.map +1 -0
- package/dist/release/ci.d.ts +35 -0
- package/dist/release/ci.d.ts.map +1 -0
- package/dist/release/github-pr.d.ts +63 -0
- package/dist/release/github-pr.d.ts.map +1 -0
- package/dist/release/guards.d.ts +44 -0
- package/dist/release/guards.d.ts.map +1 -0
- package/dist/release/index.d.ts +26 -0
- package/dist/release/index.d.ts.map +1 -0
- package/dist/release/release-config.d.ts +90 -0
- package/dist/release/release-config.d.ts.map +1 -0
- package/dist/release/release-manifest.d.ts +215 -0
- package/dist/release/release-manifest.d.ts.map +1 -0
- package/dist/release/version-bump.d.ts +51 -0
- package/dist/release/version-bump.d.ts.map +1 -0
- package/dist/remote/index.d.ts +81 -0
- package/dist/remote/index.d.ts.map +1 -0
- package/dist/repair.d.ts +30 -0
- package/dist/repair.d.ts.map +1 -0
- package/dist/research/index.d.ts +2 -0
- package/dist/research/index.d.ts.map +1 -0
- package/dist/roadmap/index.d.ts +13 -0
- package/dist/roadmap/index.d.ts.map +1 -0
- package/dist/routing/capability-matrix.d.ts +78 -0
- package/dist/routing/capability-matrix.d.ts.map +1 -0
- package/dist/routing/index.d.ts +10 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/scaffold.d.ts +215 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/schema-management.d.ts +96 -0
- package/dist/schema-management.d.ts.map +1 -0
- package/dist/security/index.d.ts +10 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/input-sanitization.d.ts +93 -0
- package/dist/security/input-sanitization.d.ts.map +1 -0
- package/dist/sequence/index.d.ts +34 -0
- package/dist/sequence/index.d.ts.map +1 -0
- package/dist/sessions/assumptions.d.ts +22 -0
- package/dist/sessions/assumptions.d.ts.map +1 -0
- package/dist/sessions/briefing.d.ts +113 -0
- package/dist/sessions/briefing.d.ts.map +1 -0
- package/dist/sessions/context-alert.d.ts +48 -0
- package/dist/sessions/context-alert.d.ts.map +1 -0
- package/dist/sessions/context-inject.d.ts +31 -0
- package/dist/sessions/context-inject.d.ts.map +1 -0
- package/dist/sessions/context-monitor.d.ts +33 -0
- package/dist/sessions/context-monitor.d.ts.map +1 -0
- package/dist/sessions/decisions.d.ts +29 -0
- package/dist/sessions/decisions.d.ts.map +1 -0
- package/dist/sessions/find.d.ts +38 -0
- package/dist/sessions/find.d.ts.map +1 -0
- package/dist/sessions/handoff.d.ts +137 -0
- package/dist/sessions/handoff.d.ts.map +1 -0
- package/dist/sessions/hitl-warnings.d.ts +58 -0
- package/dist/sessions/hitl-warnings.d.ts.map +1 -0
- package/dist/sessions/index.d.ts +107 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/sessions/session-archive.d.ts +17 -0
- package/dist/sessions/session-archive.d.ts.map +1 -0
- package/dist/sessions/session-cleanup.d.ts +22 -0
- package/dist/sessions/session-cleanup.d.ts.map +1 -0
- package/dist/sessions/session-drift.d.ts +22 -0
- package/dist/sessions/session-drift.d.ts.map +1 -0
- package/dist/sessions/session-enforcement.d.ts +49 -0
- package/dist/sessions/session-enforcement.d.ts.map +1 -0
- package/dist/sessions/session-grade.d.ts +41 -0
- package/dist/sessions/session-grade.d.ts.map +1 -0
- package/dist/sessions/session-history.d.ts +32 -0
- package/dist/sessions/session-history.d.ts.map +1 -0
- package/dist/sessions/session-id.d.ts +34 -0
- package/dist/sessions/session-id.d.ts.map +1 -0
- package/dist/sessions/session-memory-bridge.d.ts +28 -0
- package/dist/sessions/session-memory-bridge.d.ts.map +1 -0
- package/dist/sessions/session-show.d.ts +14 -0
- package/dist/sessions/session-show.d.ts.map +1 -0
- package/dist/sessions/session-stats.d.ts +30 -0
- package/dist/sessions/session-stats.d.ts.map +1 -0
- package/dist/sessions/session-suspend.d.ts +14 -0
- package/dist/sessions/session-suspend.d.ts.map +1 -0
- package/dist/sessions/session-switch.d.ts +14 -0
- package/dist/sessions/session-switch.d.ts.map +1 -0
- package/dist/sessions/session-view.d.ts +41 -0
- package/dist/sessions/session-view.d.ts.map +1 -0
- package/dist/sessions/statusline-setup.d.ts +24 -0
- package/dist/sessions/statusline-setup.d.ts.map +1 -0
- package/dist/sessions/types.d.ts +110 -0
- package/dist/sessions/types.d.ts.map +1 -0
- package/dist/signaldock/claude-code-transport.d.ts +34 -0
- package/dist/signaldock/claude-code-transport.d.ts.map +1 -0
- package/dist/signaldock/factory.d.ts +22 -0
- package/dist/signaldock/factory.d.ts.map +1 -0
- package/dist/signaldock/index.d.ts +13 -0
- package/dist/signaldock/index.d.ts.map +1 -0
- package/dist/signaldock/signaldock-transport.d.ts +45 -0
- package/dist/signaldock/signaldock-transport.d.ts.map +1 -0
- package/dist/signaldock/transport.d.ts +49 -0
- package/dist/signaldock/transport.d.ts.map +1 -0
- package/dist/signaldock/types.d.ts +88 -0
- package/dist/signaldock/types.d.ts.map +1 -0
- package/dist/skills/agents/config.d.ts +39 -0
- package/dist/skills/agents/config.d.ts.map +1 -0
- package/dist/skills/agents/install.d.ts +33 -0
- package/dist/skills/agents/install.d.ts.map +1 -0
- package/dist/skills/agents/registry.d.ts +56 -0
- package/dist/skills/agents/registry.d.ts.map +1 -0
- package/dist/skills/discovery.d.ts +102 -0
- package/dist/skills/discovery.d.ts.map +1 -0
- package/dist/skills/dispatch.d.ts +67 -0
- package/dist/skills/dispatch.d.ts.map +1 -0
- package/dist/skills/dynamic-skill-generator.d.ts +42 -0
- package/dist/skills/dynamic-skill-generator.d.ts.map +1 -0
- package/dist/skills/index.d.ts +38 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/injection/subagent.d.ts +60 -0
- package/dist/skills/injection/subagent.d.ts.map +1 -0
- package/dist/skills/injection/token.d.ts +121 -0
- package/dist/skills/injection/token.d.ts.map +1 -0
- package/dist/skills/install.d.ts +16 -0
- package/dist/skills/install.d.ts.map +1 -0
- package/dist/skills/manifests/contribution.d.ts +74 -0
- package/dist/skills/manifests/contribution.d.ts.map +1 -0
- package/dist/skills/manifests/research.d.ts +73 -0
- package/dist/skills/manifests/research.d.ts.map +1 -0
- package/dist/skills/manifests/resolver.d.ts +40 -0
- package/dist/skills/manifests/resolver.d.ts.map +1 -0
- package/dist/skills/marketplace.d.ts +45 -0
- package/dist/skills/marketplace.d.ts.map +1 -0
- package/dist/skills/orchestrator/spawn.d.ts +66 -0
- package/dist/skills/orchestrator/spawn.d.ts.map +1 -0
- package/dist/skills/orchestrator/startup.d.ts +85 -0
- package/dist/skills/orchestrator/startup.d.ts.map +1 -0
- package/dist/skills/orchestrator/validator.d.ts +40 -0
- package/dist/skills/orchestrator/validator.d.ts.map +1 -0
- package/dist/skills/precedence-integration.d.ts +46 -0
- package/dist/skills/precedence-integration.d.ts.map +1 -0
- package/dist/skills/precedence-types.d.ts +50 -0
- package/dist/skills/precedence-types.d.ts.map +1 -0
- package/dist/skills/routing-table.d.ts +58 -0
- package/dist/skills/routing-table.d.ts.map +1 -0
- package/dist/skills/skill-paths.d.ts +79 -0
- package/dist/skills/skill-paths.d.ts.map +1 -0
- package/dist/skills/test-utility.d.ts +39 -0
- package/dist/skills/test-utility.d.ts.map +1 -0
- package/dist/skills/types.d.ts +347 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/validation.d.ts +46 -0
- package/dist/skills/validation.d.ts.map +1 -0
- package/dist/skills/version.d.ts +31 -0
- package/dist/skills/version.d.ts.map +1 -0
- package/dist/snapshot/index.d.ts +83 -0
- package/dist/snapshot/index.d.ts.map +1 -0
- package/dist/spawn/adapter-registry.d.ts +132 -0
- package/dist/spawn/adapter-registry.d.ts.map +1 -0
- package/dist/spawn/index.d.ts +11 -0
- package/dist/spawn/index.d.ts.map +1 -0
- package/dist/stats/index.d.ts +37 -0
- package/dist/stats/index.d.ts.map +1 -0
- package/dist/sticky/archive.d.ts +18 -0
- package/dist/sticky/archive.d.ts.map +1 -0
- package/dist/sticky/convert.d.ts +73 -0
- package/dist/sticky/convert.d.ts.map +1 -0
- package/dist/sticky/create.d.ts +18 -0
- package/dist/sticky/create.d.ts.map +1 -0
- package/dist/sticky/id.d.ts +18 -0
- package/dist/sticky/id.d.ts.map +1 -0
- package/dist/sticky/index.d.ts +17 -0
- package/dist/sticky/index.d.ts.map +1 -0
- package/dist/sticky/list.d.ts +18 -0
- package/dist/sticky/list.d.ts.map +1 -0
- package/dist/sticky/purge.d.ts +17 -0
- package/dist/sticky/purge.d.ts.map +1 -0
- package/dist/sticky/show.d.ts +18 -0
- package/dist/sticky/show.d.ts.map +1 -0
- package/dist/sticky/types.d.ts +87 -0
- package/dist/sticky/types.d.ts.map +1 -0
- package/dist/store/atomic.d.ts +75 -0
- package/dist/store/atomic.d.ts.map +1 -0
- package/dist/store/backup.d.ts +21 -0
- package/dist/store/backup.d.ts.map +1 -0
- package/dist/store/brain-accessor.d.ts +84 -0
- package/dist/store/brain-accessor.d.ts.map +1 -0
- package/dist/store/brain-schema.d.ts +1339 -0
- package/dist/store/brain-schema.d.ts.map +1 -0
- package/dist/store/brain-sqlite.d.ts +59 -0
- package/dist/store/brain-sqlite.d.ts.map +1 -0
- package/dist/store/cache.d.ts +67 -0
- package/dist/store/cache.d.ts.map +1 -0
- package/dist/store/chain-schema.d.ts +319 -0
- package/dist/store/chain-schema.d.ts.map +1 -0
- package/dist/store/converters.d.ts +19 -0
- package/dist/store/converters.d.ts.map +1 -0
- package/dist/store/data-accessor.d.ts +20 -0
- package/dist/store/data-accessor.d.ts.map +1 -0
- package/dist/store/data-safety-central.d.ts +101 -0
- package/dist/store/data-safety-central.d.ts.map +1 -0
- package/dist/store/data-safety.d.ts +92 -0
- package/dist/store/data-safety.d.ts.map +1 -0
- package/dist/store/db-helpers.d.ts +61 -0
- package/dist/store/db-helpers.d.ts.map +1 -0
- package/dist/store/export.d.ts +88 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/file-utils.d.ts +72 -0
- package/dist/store/file-utils.d.ts.map +1 -0
- package/dist/store/git-checkpoint.d.ts +93 -0
- package/dist/store/git-checkpoint.d.ts.map +1 -0
- package/dist/store/import-logging.d.ts +58 -0
- package/dist/store/import-logging.d.ts.map +1 -0
- package/dist/store/import-remap.d.ts +50 -0
- package/dist/store/import-remap.d.ts.map +1 -0
- package/dist/store/import-sort.d.ts +35 -0
- package/dist/store/import-sort.d.ts.map +1 -0
- package/dist/store/index.d.ts +28 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/json.d.ts +57 -0
- package/dist/store/json.d.ts.map +1 -0
- package/dist/store/lifecycle-store.d.ts +125 -0
- package/dist/store/lifecycle-store.d.ts.map +1 -0
- package/dist/store/lock.d.ts +29 -0
- package/dist/store/lock.d.ts.map +1 -0
- package/dist/store/migration-sqlite.d.ts +67 -0
- package/dist/store/migration-sqlite.d.ts.map +1 -0
- package/dist/store/nexus-schema.d.ts +503 -0
- package/dist/store/nexus-schema.d.ts.map +1 -0
- package/dist/store/nexus-sqlite.d.ts +58 -0
- package/dist/store/nexus-sqlite.d.ts.map +1 -0
- package/dist/store/nexus-validation-schemas.d.ts +970 -0
- package/dist/store/nexus-validation-schemas.d.ts.map +1 -0
- package/dist/store/parsers.d.ts +16 -0
- package/dist/store/parsers.d.ts.map +1 -0
- package/dist/store/project-detect.d.ts +56 -0
- package/dist/store/project-detect.d.ts.map +1 -0
- package/dist/store/provider.d.ts +147 -0
- package/dist/store/provider.d.ts.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +123 -0
- package/dist/store/safety-data-accessor.d.ts.map +1 -0
- package/dist/store/schema.d.ts +7 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/session-store.d.ts +42 -0
- package/dist/store/session-store.d.ts.map +1 -0
- package/dist/store/sqlite-backup.d.ts +34 -0
- package/dist/store/sqlite-backup.d.ts.map +1 -0
- package/dist/store/sqlite-data-accessor.d.ts +26 -0
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -0
- package/dist/store/sqlite.d.ts +106 -0
- package/dist/store/sqlite.d.ts.map +1 -0
- package/dist/store/status-registry.d.ts +9 -0
- package/dist/store/status-registry.d.ts.map +1 -0
- package/dist/store/task-store.d.ts +69 -0
- package/dist/store/task-store.d.ts.map +1 -0
- package/dist/store/tasks-schema.d.ts +4077 -0
- package/dist/store/tasks-schema.d.ts.map +1 -0
- package/dist/store/typed-query.d.ts +12 -0
- package/dist/store/typed-query.d.ts.map +1 -0
- package/dist/store/validation-schemas.d.ts +9042 -0
- package/dist/store/validation-schemas.d.ts.map +1 -0
- package/dist/system/archive-analytics.d.ts +148 -0
- package/dist/system/archive-analytics.d.ts.map +1 -0
- package/dist/system/archive-stats.d.ts +21 -0
- package/dist/system/archive-stats.d.ts.map +1 -0
- package/dist/system/audit.d.ts +25 -0
- package/dist/system/audit.d.ts.map +1 -0
- package/dist/system/backup.d.ts +28 -0
- package/dist/system/backup.d.ts.map +1 -0
- package/dist/system/cleanup.d.ts +20 -0
- package/dist/system/cleanup.d.ts.map +1 -0
- package/dist/system/health.d.ts +124 -0
- package/dist/system/health.d.ts.map +1 -0
- package/dist/system/index.d.ts +31 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/inject-generate.d.ts +13 -0
- package/dist/system/inject-generate.d.ts.map +1 -0
- package/dist/system/labels.d.ts +18 -0
- package/dist/system/labels.d.ts.map +1 -0
- package/dist/system/metrics.d.ts +30 -0
- package/dist/system/metrics.d.ts.map +1 -0
- package/dist/system/migrate.d.ts +19 -0
- package/dist/system/migrate.d.ts.map +1 -0
- package/dist/system/platform-paths.d.ts +61 -0
- package/dist/system/platform-paths.d.ts.map +1 -0
- package/dist/system/runtime.d.ts +38 -0
- package/dist/system/runtime.d.ts.map +1 -0
- package/dist/system/safestop.d.ts +35 -0
- package/dist/system/safestop.d.ts.map +1 -0
- package/dist/system/storage-preflight.d.ts +42 -0
- package/dist/system/storage-preflight.d.ts.map +1 -0
- package/dist/task-work/index.d.ts +58 -0
- package/dist/task-work/index.d.ts.map +1 -0
- package/dist/tasks/add.d.ts +123 -0
- package/dist/tasks/add.d.ts.map +1 -0
- package/dist/tasks/analyze.d.ts +16 -0
- package/dist/tasks/analyze.d.ts.map +1 -0
- package/dist/tasks/archive.d.ts +31 -0
- package/dist/tasks/archive.d.ts.map +1 -0
- package/dist/tasks/atomicity.d.ts +21 -0
- package/dist/tasks/atomicity.d.ts.map +1 -0
- package/dist/tasks/cancel-ops.d.ts +42 -0
- package/dist/tasks/cancel-ops.d.ts.map +1 -0
- package/dist/tasks/complete.d.ts +26 -0
- package/dist/tasks/complete.d.ts.map +1 -0
- package/dist/tasks/crossref-extract.d.ts +39 -0
- package/dist/tasks/crossref-extract.d.ts.map +1 -0
- package/dist/tasks/delete-preview.d.ts +69 -0
- package/dist/tasks/delete-preview.d.ts.map +1 -0
- package/dist/tasks/delete.d.ts +24 -0
- package/dist/tasks/delete.d.ts.map +1 -0
- package/dist/tasks/deletion-strategy.d.ts +46 -0
- package/dist/tasks/deletion-strategy.d.ts.map +1 -0
- package/dist/tasks/dependency-check.d.ts +82 -0
- package/dist/tasks/dependency-check.d.ts.map +1 -0
- package/dist/tasks/deps-ready.d.ts +22 -0
- package/dist/tasks/deps-ready.d.ts.map +1 -0
- package/dist/tasks/find.d.ts +48 -0
- package/dist/tasks/find.d.ts.map +1 -0
- package/dist/tasks/graph-cache.d.ts +70 -0
- package/dist/tasks/graph-cache.d.ts.map +1 -0
- package/dist/tasks/graph-ops.d.ts +36 -0
- package/dist/tasks/graph-ops.d.ts.map +1 -0
- package/dist/tasks/graph-rag.d.ts +49 -0
- package/dist/tasks/graph-rag.d.ts.map +1 -0
- package/dist/tasks/hierarchy-policy.d.ts +61 -0
- package/dist/tasks/hierarchy-policy.d.ts.map +1 -0
- package/dist/tasks/hierarchy.d.ts +85 -0
- package/dist/tasks/hierarchy.d.ts.map +1 -0
- package/dist/tasks/id-generator.d.ts +28 -0
- package/dist/tasks/id-generator.d.ts.map +1 -0
- package/dist/tasks/index.d.ts +14 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/labels.d.ts +19 -0
- package/dist/tasks/labels.d.ts.map +1 -0
- package/dist/tasks/list.d.ts +49 -0
- package/dist/tasks/list.d.ts.map +1 -0
- package/dist/tasks/phase-tracking.d.ts +61 -0
- package/dist/tasks/phase-tracking.d.ts.map +1 -0
- package/dist/tasks/plan.d.ts +53 -0
- package/dist/tasks/plan.d.ts.map +1 -0
- package/dist/tasks/relates.d.ts +18 -0
- package/dist/tasks/relates.d.ts.map +1 -0
- package/dist/tasks/show.d.ts +23 -0
- package/dist/tasks/show.d.ts.map +1 -0
- package/dist/tasks/size-weighting.d.ts +38 -0
- package/dist/tasks/size-weighting.d.ts.map +1 -0
- package/dist/tasks/staleness.d.ts +56 -0
- package/dist/tasks/staleness.d.ts.map +1 -0
- package/dist/tasks/task-ops.d.ts +322 -0
- package/dist/tasks/task-ops.d.ts.map +1 -0
- package/dist/tasks/update.d.ts +41 -0
- package/dist/tasks/update.d.ts.map +1 -0
- package/dist/templates/index.d.ts +11 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/parser.d.ts +84 -0
- package/dist/templates/parser.d.ts.map +1 -0
- package/dist/ui/aliases.d.ts +43 -0
- package/dist/ui/aliases.d.ts.map +1 -0
- package/dist/ui/changelog.d.ts +58 -0
- package/dist/ui/changelog.d.ts.map +1 -0
- package/dist/ui/command-registry.d.ts +44 -0
- package/dist/ui/command-registry.d.ts.map +1 -0
- package/dist/ui/flags.d.ts +34 -0
- package/dist/ui/flags.d.ts.map +1 -0
- package/dist/ui/index.d.ts +16 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/injection-legacy.d.ts +26 -0
- package/dist/ui/injection-legacy.d.ts.map +1 -0
- package/dist/upgrade.d.ts +59 -0
- package/dist/upgrade.d.ts.map +1 -0
- package/dist/validation/chain-validation.d.ts +43 -0
- package/dist/validation/chain-validation.d.ts.map +1 -0
- package/dist/validation/compliance.d.ts +94 -0
- package/dist/validation/compliance.d.ts.map +1 -0
- package/dist/validation/docs-sync.d.ts +66 -0
- package/dist/validation/docs-sync.d.ts.map +1 -0
- package/dist/validation/doctor/checks.d.ts +130 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -0
- package/dist/validation/doctor/index.d.ts +9 -0
- package/dist/validation/doctor/index.d.ts.map +1 -0
- package/dist/validation/doctor/project-cache.d.ts +77 -0
- package/dist/validation/doctor/project-cache.d.ts.map +1 -0
- package/dist/validation/doctor/utils.d.ts +68 -0
- package/dist/validation/doctor/utils.d.ts.map +1 -0
- package/dist/validation/engine.d.ts +171 -0
- package/dist/validation/engine.d.ts.map +1 -0
- package/dist/validation/gap-check.d.ts +74 -0
- package/dist/validation/gap-check.d.ts.map +1 -0
- package/dist/validation/index.d.ts +22 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/manifest.d.ts +81 -0
- package/dist/validation/manifest.d.ts.map +1 -0
- package/dist/validation/operation-gate-validators.d.ts +96 -0
- package/dist/validation/operation-gate-validators.d.ts.map +1 -0
- package/dist/validation/operation-verification-gates.d.ts +274 -0
- package/dist/validation/operation-verification-gates.d.ts.map +1 -0
- package/dist/validation/param-utils.d.ts +121 -0
- package/dist/validation/param-utils.d.ts.map +1 -0
- package/dist/validation/protocol-common.d.ts +85 -0
- package/dist/validation/protocol-common.d.ts.map +1 -0
- package/dist/validation/protocols/consensus.d.ts +28 -0
- package/dist/validation/protocols/consensus.d.ts.map +1 -0
- package/dist/validation/protocols/contribution.d.ts +26 -0
- package/dist/validation/protocols/contribution.d.ts.map +1 -0
- package/dist/validation/protocols/decomposition.d.ts +28 -0
- package/dist/validation/protocols/decomposition.d.ts.map +1 -0
- package/dist/validation/protocols/implementation.d.ts +26 -0
- package/dist/validation/protocols/implementation.d.ts.map +1 -0
- package/dist/validation/protocols/release-protocol.d.ts +27 -0
- package/dist/validation/protocols/release-protocol.d.ts.map +1 -0
- package/dist/validation/protocols/research.d.ts +26 -0
- package/dist/validation/protocols/research.d.ts.map +1 -0
- package/dist/validation/protocols/specification.d.ts +28 -0
- package/dist/validation/protocols/specification.d.ts.map +1 -0
- package/dist/validation/protocols/testing-protocol.d.ts +27 -0
- package/dist/validation/protocols/testing-protocol.d.ts.map +1 -0
- package/dist/validation/protocols/validation-protocol.d.ts +27 -0
- package/dist/validation/protocols/validation-protocol.d.ts.map +1 -0
- package/dist/validation/schema-integrity.d.ts +42 -0
- package/dist/validation/schema-integrity.d.ts.map +1 -0
- package/dist/validation/schema-validator.d.ts +52 -0
- package/dist/validation/schema-validator.d.ts.map +1 -0
- package/dist/validation/validate-ops.d.ts +247 -0
- package/dist/validation/validate-ops.d.ts.map +1 -0
- package/dist/validation/validation-rules.d.ts +85 -0
- package/dist/validation/validation-rules.d.ts.map +1 -0
- package/dist/validation/verification.d.ts +153 -0
- package/dist/validation/verification.d.ts.map +1 -0
- package/migrations/drizzle-tasks/20260320013731_wave0-schema-hardening/migration.sql +84 -0
- package/migrations/drizzle-tasks/20260320013731_wave0-schema-hardening/snapshot.json +4060 -0
- package/migrations/drizzle-tasks/20260320020000_agent-dimension/migration.sql +35 -0
- package/migrations/drizzle-tasks/20260320020000_agent-dimension/snapshot.json +4312 -0
- package/package.json +2 -2
- package/src/admin/export-tasks.ts +2 -5
- package/src/agents/__tests__/capacity.test.ts +219 -0
- package/src/agents/__tests__/registry.test.ts +457 -0
- package/src/agents/__tests__/retry.test.ts +289 -0
- package/src/agents/agent-schema.ts +107 -0
- package/src/agents/capacity.ts +151 -0
- package/src/agents/index.ts +68 -0
- package/src/agents/registry.ts +449 -0
- package/src/agents/retry.ts +255 -0
- package/src/hooks/index.ts +20 -1
- package/src/hooks/payload-schemas.ts +199 -0
- package/src/index.ts +69 -0
- package/src/inject/index.ts +14 -14
- package/src/intelligence/__tests__/impact.test.ts +453 -0
- package/src/intelligence/__tests__/patterns.test.ts +450 -0
- package/src/intelligence/__tests__/prediction.test.ts +418 -0
- package/src/intelligence/impact.ts +638 -0
- package/src/intelligence/index.ts +47 -0
- package/src/intelligence/patterns.ts +621 -0
- package/src/intelligence/prediction.ts +621 -0
- package/src/intelligence/types.ts +273 -0
- package/src/internal.ts +82 -1
- package/src/issue/template-parser.ts +65 -4
- package/src/lifecycle/pipeline.ts +14 -7
- package/src/lifecycle/state-machine.ts +6 -2
- package/src/memory/brain-lifecycle.ts +5 -11
- package/src/memory/brain-retrieval.ts +44 -38
- package/src/memory/brain-row-types.ts +43 -6
- package/src/memory/brain-search.ts +53 -32
- package/src/memory/brain-similarity.ts +9 -8
- package/src/memory/claude-mem-migration.ts +4 -3
- package/src/nexus/__tests__/nexus-e2e.test.ts +1481 -0
- package/src/nexus/discover.ts +1 -0
- package/src/orchestration/bootstrap.ts +11 -17
- package/src/orchestration/skill-ops.ts +52 -32
- package/src/otel/index.ts +48 -4
- package/src/sessions/__tests__/briefing.test.ts +31 -2
- package/src/sessions/briefing.ts +27 -42
- package/src/sessions/handoff.ts +52 -86
- package/src/sessions/index.ts +5 -1
- package/src/sessions/types.ts +9 -43
- package/src/signaldock/signaldock-transport.ts +5 -2
- package/src/skills/injection/subagent.ts +10 -16
- package/src/skills/manifests/contribution.ts +5 -13
- package/src/skills/orchestrator/__tests__/spawn-tier.test.ts +44 -30
- package/src/skills/orchestrator/spawn.ts +18 -31
- package/src/skills/orchestrator/startup.ts +78 -65
- package/src/skills/orchestrator/validator.ts +26 -31
- package/src/skills/precedence-types.ts +24 -1
- package/src/skills/types.ts +72 -5
- package/src/store/__tests__/test-db-helper.d.ts +4 -4
- package/src/store/__tests__/test-db-helper.js +5 -16
- package/src/store/__tests__/test-db-helper.ts +5 -18
- package/src/store/chain-schema.ts +1 -1
- package/src/store/export.ts +22 -12
- package/src/store/tasks-schema.ts +65 -8
- package/src/store/typed-query.ts +17 -0
- package/src/store/validation-schemas.ts +347 -23
- package/src/system/inject-generate.ts +9 -23
- package/src/validation/doctor/checks.ts +24 -2
- package/src/validation/engine.ts +11 -11
- package/src/validation/index.ts +131 -3
- package/src/validation/protocol-common.ts +54 -3
- package/src/tasks/reparent.ts +0 -134
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent instance registry -- runtime tracking of live agent processes.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD operations for the `agent_instances` table:
|
|
5
|
+
* registration, deregistration, heartbeat, status updates, and queries.
|
|
6
|
+
*
|
|
7
|
+
* This is the DB-backed runtime registry for live agent *instances*.
|
|
8
|
+
* The file-based registry in `skills/agents/registry.ts` tracks installed
|
|
9
|
+
* agent *definitions* -- those are complementary, not competing, concepts.
|
|
10
|
+
*
|
|
11
|
+
* @module agents/registry
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { randomBytes } from 'node:crypto';
|
|
15
|
+
import { and, eq, inArray, lt, sql } from 'drizzle-orm';
|
|
16
|
+
import { getDb } from '../store/sqlite.js';
|
|
17
|
+
import {
|
|
18
|
+
type AgentErrorLogRow,
|
|
19
|
+
type AgentErrorType,
|
|
20
|
+
type AgentInstanceRow,
|
|
21
|
+
type AgentInstanceStatus,
|
|
22
|
+
type AgentType,
|
|
23
|
+
agentErrorLog,
|
|
24
|
+
agentInstances,
|
|
25
|
+
} from './agent-schema.js';
|
|
26
|
+
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// ID generation
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generate a unique agent instance ID.
|
|
33
|
+
* Format: `agt_{YYYYMMDDHHmmss}_{6hex}`
|
|
34
|
+
*/
|
|
35
|
+
export function generateAgentId(): string {
|
|
36
|
+
const now = new Date();
|
|
37
|
+
const ts = now.toISOString().replace(/[-:T]/g, '').substring(0, 14);
|
|
38
|
+
const hex = randomBytes(3).toString('hex');
|
|
39
|
+
return `agt_${ts}_${hex}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Registration
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
/** Options for registering a new agent instance. */
|
|
47
|
+
export interface RegisterAgentOptions {
|
|
48
|
+
agentType: AgentType;
|
|
49
|
+
sessionId?: string;
|
|
50
|
+
taskId?: string;
|
|
51
|
+
parentAgentId?: string;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Register a new agent instance in the database.
|
|
57
|
+
* Sets initial status to 'starting' and records the first heartbeat.
|
|
58
|
+
*/
|
|
59
|
+
export async function registerAgent(
|
|
60
|
+
opts: RegisterAgentOptions,
|
|
61
|
+
cwd?: string,
|
|
62
|
+
): Promise<AgentInstanceRow> {
|
|
63
|
+
const db = await getDb(cwd);
|
|
64
|
+
const id = generateAgentId();
|
|
65
|
+
const now = new Date().toISOString();
|
|
66
|
+
|
|
67
|
+
const row: typeof agentInstances.$inferInsert = {
|
|
68
|
+
id,
|
|
69
|
+
agentType: opts.agentType,
|
|
70
|
+
status: 'starting',
|
|
71
|
+
sessionId: opts.sessionId ?? null,
|
|
72
|
+
taskId: opts.taskId ?? null,
|
|
73
|
+
startedAt: now,
|
|
74
|
+
lastHeartbeat: now,
|
|
75
|
+
stoppedAt: null,
|
|
76
|
+
errorCount: 0,
|
|
77
|
+
totalTasksCompleted: 0,
|
|
78
|
+
capacity: '1.0',
|
|
79
|
+
metadataJson: opts.metadata ? JSON.stringify(opts.metadata) : '{}',
|
|
80
|
+
parentAgentId: opts.parentAgentId ?? null,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
await db.insert(agentInstances).values(row);
|
|
84
|
+
return row as AgentInstanceRow;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Deregister (stop) an agent instance.
|
|
89
|
+
* Sets status to 'stopped' and records the stop timestamp.
|
|
90
|
+
*/
|
|
91
|
+
export async function deregisterAgent(id: string, cwd?: string): Promise<AgentInstanceRow | null> {
|
|
92
|
+
const db = await getDb(cwd);
|
|
93
|
+
const now = new Date().toISOString();
|
|
94
|
+
|
|
95
|
+
const existing = await db.select().from(agentInstances).where(eq(agentInstances.id, id)).get();
|
|
96
|
+
if (!existing) return null;
|
|
97
|
+
|
|
98
|
+
// Already stopped -- idempotent
|
|
99
|
+
if (existing.status === 'stopped') return existing;
|
|
100
|
+
|
|
101
|
+
await db
|
|
102
|
+
.update(agentInstances)
|
|
103
|
+
.set({ status: 'stopped', stoppedAt: now })
|
|
104
|
+
.where(eq(agentInstances.id, id));
|
|
105
|
+
|
|
106
|
+
return { ...existing, status: 'stopped', stoppedAt: now };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// Heartbeat
|
|
111
|
+
// ============================================================================
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Record a heartbeat for an agent instance.
|
|
115
|
+
* Updates `last_heartbeat` and returns the current status so the agent
|
|
116
|
+
* can detect if it has been externally marked for shutdown.
|
|
117
|
+
*/
|
|
118
|
+
export async function heartbeat(id: string, cwd?: string): Promise<AgentInstanceStatus | null> {
|
|
119
|
+
const db = await getDb(cwd);
|
|
120
|
+
const now = new Date().toISOString();
|
|
121
|
+
|
|
122
|
+
const existing = await db.select().from(agentInstances).where(eq(agentInstances.id, id)).get();
|
|
123
|
+
if (!existing) return null;
|
|
124
|
+
|
|
125
|
+
// Do not update heartbeat for terminal states
|
|
126
|
+
if (existing.status === 'stopped' || existing.status === 'crashed') {
|
|
127
|
+
return existing.status;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
await db.update(agentInstances).set({ lastHeartbeat: now }).where(eq(agentInstances.id, id));
|
|
131
|
+
|
|
132
|
+
return existing.status;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// Status management
|
|
137
|
+
// ============================================================================
|
|
138
|
+
|
|
139
|
+
/** Options for updating agent status. */
|
|
140
|
+
export interface UpdateStatusOptions {
|
|
141
|
+
status: AgentInstanceStatus;
|
|
142
|
+
error?: string;
|
|
143
|
+
taskId?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Update agent status with optional error tracking.
|
|
148
|
+
* When status is 'error' or 'crashed', increments the error count
|
|
149
|
+
* and logs the error to the agent_error_log table.
|
|
150
|
+
*/
|
|
151
|
+
export async function updateAgentStatus(
|
|
152
|
+
id: string,
|
|
153
|
+
opts: UpdateStatusOptions,
|
|
154
|
+
cwd?: string,
|
|
155
|
+
): Promise<AgentInstanceRow | null> {
|
|
156
|
+
const db = await getDb(cwd);
|
|
157
|
+
|
|
158
|
+
const existing = await db.select().from(agentInstances).where(eq(agentInstances.id, id)).get();
|
|
159
|
+
if (!existing) return null;
|
|
160
|
+
|
|
161
|
+
const updates: Partial<typeof agentInstances.$inferInsert> = {
|
|
162
|
+
status: opts.status,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (opts.taskId !== undefined) {
|
|
166
|
+
updates.taskId = opts.taskId;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// If transitioning to active, update heartbeat
|
|
170
|
+
if (opts.status === 'active') {
|
|
171
|
+
updates.lastHeartbeat = new Date().toISOString();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Track errors
|
|
175
|
+
if (opts.status === 'error' || opts.status === 'crashed') {
|
|
176
|
+
updates.errorCount = existing.errorCount + 1;
|
|
177
|
+
|
|
178
|
+
if (opts.error) {
|
|
179
|
+
const errorType = classifyError(new Error(opts.error));
|
|
180
|
+
await db.insert(agentErrorLog).values({
|
|
181
|
+
agentId: id,
|
|
182
|
+
errorType,
|
|
183
|
+
message: opts.error,
|
|
184
|
+
occurredAt: new Date().toISOString(),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// If stopped, set stoppedAt
|
|
190
|
+
if (opts.status === 'stopped') {
|
|
191
|
+
updates.stoppedAt = new Date().toISOString();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
await db.update(agentInstances).set(updates).where(eq(agentInstances.id, id));
|
|
195
|
+
|
|
196
|
+
return { ...existing, ...updates } as AgentInstanceRow;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Increment the completed task count for an agent.
|
|
201
|
+
*/
|
|
202
|
+
export async function incrementTasksCompleted(id: string, cwd?: string): Promise<void> {
|
|
203
|
+
const db = await getDb(cwd);
|
|
204
|
+
await db
|
|
205
|
+
.update(agentInstances)
|
|
206
|
+
.set({ totalTasksCompleted: sql`${agentInstances.totalTasksCompleted} + 1` })
|
|
207
|
+
.where(eq(agentInstances.id, id));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ============================================================================
|
|
211
|
+
// Queries
|
|
212
|
+
// ============================================================================
|
|
213
|
+
|
|
214
|
+
/** Filters for listing agent instances. */
|
|
215
|
+
export interface ListAgentFilters {
|
|
216
|
+
status?: AgentInstanceStatus | AgentInstanceStatus[];
|
|
217
|
+
agentType?: AgentType | AgentType[];
|
|
218
|
+
sessionId?: string;
|
|
219
|
+
parentAgentId?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* List agent instances with optional filters.
|
|
224
|
+
*/
|
|
225
|
+
export async function listAgentInstances(
|
|
226
|
+
filters?: ListAgentFilters,
|
|
227
|
+
cwd?: string,
|
|
228
|
+
): Promise<AgentInstanceRow[]> {
|
|
229
|
+
const db = await getDb(cwd);
|
|
230
|
+
|
|
231
|
+
const conditions = [];
|
|
232
|
+
|
|
233
|
+
if (filters?.status) {
|
|
234
|
+
const statuses = Array.isArray(filters.status) ? filters.status : [filters.status];
|
|
235
|
+
conditions.push(inArray(agentInstances.status, statuses));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (filters?.agentType) {
|
|
239
|
+
const types = Array.isArray(filters.agentType) ? filters.agentType : [filters.agentType];
|
|
240
|
+
conditions.push(inArray(agentInstances.agentType, types));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (filters?.sessionId) {
|
|
244
|
+
conditions.push(eq(agentInstances.sessionId, filters.sessionId));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (filters?.parentAgentId) {
|
|
248
|
+
conditions.push(eq(agentInstances.parentAgentId, filters.parentAgentId));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (conditions.length === 0) {
|
|
252
|
+
return db.select().from(agentInstances).all();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return db
|
|
256
|
+
.select()
|
|
257
|
+
.from(agentInstances)
|
|
258
|
+
.where(and(...conditions))
|
|
259
|
+
.all();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Get a single agent instance by ID.
|
|
264
|
+
*/
|
|
265
|
+
export async function getAgentInstance(id: string, cwd?: string): Promise<AgentInstanceRow | null> {
|
|
266
|
+
const db = await getDb(cwd);
|
|
267
|
+
const row = await db.select().from(agentInstances).where(eq(agentInstances.id, id)).get();
|
|
268
|
+
return row ?? null;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ============================================================================
|
|
272
|
+
// Error classification
|
|
273
|
+
// ============================================================================
|
|
274
|
+
|
|
275
|
+
/** Patterns indicating retriable errors. */
|
|
276
|
+
const RETRIABLE_PATTERNS = [
|
|
277
|
+
/timeout/i,
|
|
278
|
+
/ECONNREFUSED/,
|
|
279
|
+
/ECONNRESET/,
|
|
280
|
+
/EPIPE/,
|
|
281
|
+
/ETIMEDOUT/,
|
|
282
|
+
/rate.?limit/i,
|
|
283
|
+
/429/,
|
|
284
|
+
/503/,
|
|
285
|
+
/502/,
|
|
286
|
+
/SQLITE_BUSY/i,
|
|
287
|
+
/database is locked/i,
|
|
288
|
+
/temporarily unavailable/i,
|
|
289
|
+
/too many requests/i,
|
|
290
|
+
/network/i,
|
|
291
|
+
/socket hang up/i,
|
|
292
|
+
];
|
|
293
|
+
|
|
294
|
+
/** Patterns indicating permanent (non-retriable) errors. */
|
|
295
|
+
const PERMANENT_PATTERNS = [
|
|
296
|
+
/permission denied/i,
|
|
297
|
+
/EACCES/,
|
|
298
|
+
/authentication/i,
|
|
299
|
+
/unauthorized/i,
|
|
300
|
+
/401/,
|
|
301
|
+
/403/,
|
|
302
|
+
/404/,
|
|
303
|
+
/not found/i,
|
|
304
|
+
/invalid.*token/i,
|
|
305
|
+
/SQLITE_CONSTRAINT/i,
|
|
306
|
+
/syntax error/i,
|
|
307
|
+
/type error/i,
|
|
308
|
+
/reference error/i,
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Classify an error as retriable, permanent, or unknown.
|
|
313
|
+
*
|
|
314
|
+
* Retriable errors are transient conditions (network, rate limits, locks)
|
|
315
|
+
* where a retry may succeed. Permanent errors are structural (auth,
|
|
316
|
+
* not found, constraint violations) where retrying is pointless.
|
|
317
|
+
*/
|
|
318
|
+
export function classifyError(error: unknown): AgentErrorType {
|
|
319
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
320
|
+
|
|
321
|
+
for (const pattern of RETRIABLE_PATTERNS) {
|
|
322
|
+
if (pattern.test(message)) return 'retriable';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
for (const pattern of PERMANENT_PATTERNS) {
|
|
326
|
+
if (pattern.test(message)) return 'permanent';
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return 'unknown';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get the error history for a specific agent.
|
|
334
|
+
*/
|
|
335
|
+
export async function getAgentErrorHistory(
|
|
336
|
+
agentId: string,
|
|
337
|
+
cwd?: string,
|
|
338
|
+
): Promise<AgentErrorLogRow[]> {
|
|
339
|
+
const db = await getDb(cwd);
|
|
340
|
+
return db.select().from(agentErrorLog).where(eq(agentErrorLog.agentId, agentId)).all();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ============================================================================
|
|
344
|
+
// Health Monitoring
|
|
345
|
+
// ============================================================================
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Check agent health by finding instances whose last heartbeat exceeds the threshold.
|
|
349
|
+
* Default threshold: 30000ms (30 seconds) as specified by the BRAIN spec.
|
|
350
|
+
*
|
|
351
|
+
* Returns agents that appear to have crashed (stale heartbeat).
|
|
352
|
+
*/
|
|
353
|
+
export async function checkAgentHealth(
|
|
354
|
+
thresholdMs: number = 30_000,
|
|
355
|
+
cwd?: string,
|
|
356
|
+
): Promise<AgentInstanceRow[]> {
|
|
357
|
+
const db = await getDb(cwd);
|
|
358
|
+
const cutoff = new Date(Date.now() - thresholdMs).toISOString();
|
|
359
|
+
|
|
360
|
+
return db
|
|
361
|
+
.select()
|
|
362
|
+
.from(agentInstances)
|
|
363
|
+
.where(
|
|
364
|
+
and(
|
|
365
|
+
inArray(agentInstances.status, ['active', 'idle', 'starting']),
|
|
366
|
+
lt(agentInstances.lastHeartbeat, cutoff),
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
.all();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Mark an agent instance as crashed.
|
|
374
|
+
* Increments error count and sets status to 'crashed'.
|
|
375
|
+
*/
|
|
376
|
+
export async function markCrashed(
|
|
377
|
+
id: string,
|
|
378
|
+
reason?: string,
|
|
379
|
+
cwd?: string,
|
|
380
|
+
): Promise<AgentInstanceRow | null> {
|
|
381
|
+
return updateAgentStatus(
|
|
382
|
+
id,
|
|
383
|
+
{ status: 'crashed', error: reason ?? 'Heartbeat timeout — agent presumed crashed' },
|
|
384
|
+
cwd,
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Agent health report summary. */
|
|
389
|
+
export interface AgentHealthReport {
|
|
390
|
+
total: number;
|
|
391
|
+
active: number;
|
|
392
|
+
idle: number;
|
|
393
|
+
starting: number;
|
|
394
|
+
error: number;
|
|
395
|
+
crashed: number;
|
|
396
|
+
stopped: number;
|
|
397
|
+
totalErrors: number;
|
|
398
|
+
staleAgents: AgentInstanceRow[];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Generate a health report summarizing all agent instances.
|
|
403
|
+
* Includes counts by status and identifies stale agents.
|
|
404
|
+
*/
|
|
405
|
+
export async function getHealthReport(
|
|
406
|
+
thresholdMs: number = 30_000,
|
|
407
|
+
cwd?: string,
|
|
408
|
+
): Promise<AgentHealthReport> {
|
|
409
|
+
const allAgents = await listAgentInstances(undefined, cwd);
|
|
410
|
+
const staleAgents = await checkAgentHealth(thresholdMs, cwd);
|
|
411
|
+
|
|
412
|
+
const report: AgentHealthReport = {
|
|
413
|
+
total: allAgents.length,
|
|
414
|
+
active: 0,
|
|
415
|
+
idle: 0,
|
|
416
|
+
starting: 0,
|
|
417
|
+
error: 0,
|
|
418
|
+
crashed: 0,
|
|
419
|
+
stopped: 0,
|
|
420
|
+
totalErrors: 0,
|
|
421
|
+
staleAgents,
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
for (const agent of allAgents) {
|
|
425
|
+
switch (agent.status) {
|
|
426
|
+
case 'active':
|
|
427
|
+
report.active++;
|
|
428
|
+
break;
|
|
429
|
+
case 'idle':
|
|
430
|
+
report.idle++;
|
|
431
|
+
break;
|
|
432
|
+
case 'starting':
|
|
433
|
+
report.starting++;
|
|
434
|
+
break;
|
|
435
|
+
case 'error':
|
|
436
|
+
report.error++;
|
|
437
|
+
break;
|
|
438
|
+
case 'crashed':
|
|
439
|
+
report.crashed++;
|
|
440
|
+
break;
|
|
441
|
+
case 'stopped':
|
|
442
|
+
report.stopped++;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
report.totalErrors += agent.errorCount;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return report;
|
|
449
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-healing and retry logic for the Agent dimension.
|
|
3
|
+
*
|
|
4
|
+
* Provides configurable retry policies with exponential backoff + jitter,
|
|
5
|
+
* and recovery mechanisms for crashed agents. Error classification
|
|
6
|
+
* determines whether a retry is appropriate.
|
|
7
|
+
*
|
|
8
|
+
* @module agents/retry
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
checkAgentHealth,
|
|
13
|
+
classifyError,
|
|
14
|
+
listAgentInstances,
|
|
15
|
+
updateAgentStatus,
|
|
16
|
+
} from './registry.js';
|
|
17
|
+
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Retry Policy
|
|
20
|
+
// ============================================================================
|
|
21
|
+
|
|
22
|
+
/** Configuration for retry behavior. */
|
|
23
|
+
export interface RetryPolicy {
|
|
24
|
+
/** Maximum number of retry attempts. Default: 3. */
|
|
25
|
+
maxRetries: number;
|
|
26
|
+
/** Base delay in milliseconds before first retry. Default: 1000. */
|
|
27
|
+
baseDelayMs: number;
|
|
28
|
+
/** Maximum delay in milliseconds between retries. Default: 30000. */
|
|
29
|
+
maxDelayMs: number;
|
|
30
|
+
/** Multiplier for exponential backoff. Default: 2. */
|
|
31
|
+
backoffMultiplier: number;
|
|
32
|
+
/** Whether to add random jitter to delays. Default: true. */
|
|
33
|
+
jitter: boolean;
|
|
34
|
+
/** Whether to retry on 'unknown' error classification. Default: true. */
|
|
35
|
+
retryOnUnknown: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Default retry policy matching the BRAIN specification. */
|
|
39
|
+
export const DEFAULT_RETRY_POLICY: Readonly<RetryPolicy> = Object.freeze({
|
|
40
|
+
maxRetries: 3,
|
|
41
|
+
baseDelayMs: 1_000,
|
|
42
|
+
maxDelayMs: 30_000,
|
|
43
|
+
backoffMultiplier: 2,
|
|
44
|
+
jitter: true,
|
|
45
|
+
retryOnUnknown: true,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a retry policy by merging overrides with the default policy.
|
|
50
|
+
*/
|
|
51
|
+
export function createRetryPolicy(overrides?: Partial<RetryPolicy>): RetryPolicy {
|
|
52
|
+
return { ...DEFAULT_RETRY_POLICY, ...overrides };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Calculate the delay for a given retry attempt using exponential backoff.
|
|
57
|
+
*
|
|
58
|
+
* Formula: min(baseDelay * multiplier^attempt, maxDelay) + jitter
|
|
59
|
+
* Jitter adds 0-25% randomness to prevent thundering herd.
|
|
60
|
+
*/
|
|
61
|
+
export function calculateDelay(attempt: number, policy: RetryPolicy): number {
|
|
62
|
+
const exponentialDelay = policy.baseDelayMs * policy.backoffMultiplier ** attempt;
|
|
63
|
+
const clampedDelay = Math.min(exponentialDelay, policy.maxDelayMs);
|
|
64
|
+
|
|
65
|
+
if (!policy.jitter) return clampedDelay;
|
|
66
|
+
|
|
67
|
+
// Add 0-25% jitter
|
|
68
|
+
const jitterRange = clampedDelay * 0.25;
|
|
69
|
+
const jitterValue = Math.random() * jitterRange;
|
|
70
|
+
return Math.floor(clampedDelay + jitterValue);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Determine whether an error should be retried based on its classification
|
|
75
|
+
* and the retry policy.
|
|
76
|
+
*/
|
|
77
|
+
export function shouldRetry(error: unknown, attempt: number, policy: RetryPolicy): boolean {
|
|
78
|
+
if (attempt >= policy.maxRetries) return false;
|
|
79
|
+
|
|
80
|
+
const classification = classifyError(error);
|
|
81
|
+
|
|
82
|
+
if (classification === 'permanent') return false;
|
|
83
|
+
if (classification === 'retriable') return true;
|
|
84
|
+
|
|
85
|
+
// 'unknown' classification -- policy determines behavior
|
|
86
|
+
return policy.retryOnUnknown;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Retry wrapper
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
93
|
+
/** Result of a retried operation. */
|
|
94
|
+
export interface RetryResult<T> {
|
|
95
|
+
success: boolean;
|
|
96
|
+
value?: T;
|
|
97
|
+
error?: Error;
|
|
98
|
+
attempts: number;
|
|
99
|
+
totalDelayMs: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Wrap an async function with retry logic using configurable exponential backoff.
|
|
104
|
+
*
|
|
105
|
+
* The function will be retried according to the policy when retriable errors
|
|
106
|
+
* occur. Permanent errors cause immediate failure. Unknown errors respect
|
|
107
|
+
* the `retryOnUnknown` policy setting.
|
|
108
|
+
*
|
|
109
|
+
* @param fn - The async function to execute with retries
|
|
110
|
+
* @param policy - Retry policy (uses DEFAULT_RETRY_POLICY if not provided)
|
|
111
|
+
* @returns The result of the operation with retry metadata
|
|
112
|
+
*/
|
|
113
|
+
export async function withRetry<T>(
|
|
114
|
+
fn: () => Promise<T>,
|
|
115
|
+
policy?: Partial<RetryPolicy>,
|
|
116
|
+
): Promise<RetryResult<T>> {
|
|
117
|
+
const effectivePolicy = createRetryPolicy(policy);
|
|
118
|
+
let lastError: Error | undefined;
|
|
119
|
+
let totalDelayMs = 0;
|
|
120
|
+
|
|
121
|
+
for (let attempt = 0; attempt <= effectivePolicy.maxRetries; attempt++) {
|
|
122
|
+
try {
|
|
123
|
+
const value = await fn();
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
value,
|
|
127
|
+
attempts: attempt + 1,
|
|
128
|
+
totalDelayMs,
|
|
129
|
+
};
|
|
130
|
+
} catch (err) {
|
|
131
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
132
|
+
|
|
133
|
+
if (!shouldRetry(err, attempt, effectivePolicy)) {
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
error: lastError,
|
|
137
|
+
attempts: attempt + 1,
|
|
138
|
+
totalDelayMs,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Calculate and apply delay before next attempt
|
|
143
|
+
if (attempt < effectivePolicy.maxRetries) {
|
|
144
|
+
const delay = calculateDelay(attempt, effectivePolicy);
|
|
145
|
+
totalDelayMs += delay;
|
|
146
|
+
await sleep(delay);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: lastError ?? new Error('Retry exhausted without error'),
|
|
154
|
+
attempts: effectivePolicy.maxRetries + 1,
|
|
155
|
+
totalDelayMs,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ============================================================================
|
|
160
|
+
// Recovery
|
|
161
|
+
// ============================================================================
|
|
162
|
+
|
|
163
|
+
/** Result of a recovery attempt for a single agent. */
|
|
164
|
+
export interface AgentRecoveryResult {
|
|
165
|
+
agentId: string;
|
|
166
|
+
recovered: boolean;
|
|
167
|
+
action: 'restarted' | 'abandoned' | 'skipped';
|
|
168
|
+
reason: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Attempt to recover crashed agents.
|
|
173
|
+
*
|
|
174
|
+
* Finds all agents with status 'crashed' and determines if they can be
|
|
175
|
+
* restarted based on their error history. Agents whose last error was
|
|
176
|
+
* classified as 'permanent' are abandoned. Agents with retriable errors
|
|
177
|
+
* are reset to 'starting' for the orchestration layer to re-assign.
|
|
178
|
+
*
|
|
179
|
+
* @param thresholdMs - Heartbeat threshold for crash detection (default: 30000)
|
|
180
|
+
* @param cwd - Working directory
|
|
181
|
+
* @returns Recovery results for each crashed agent
|
|
182
|
+
*/
|
|
183
|
+
export async function recoverCrashedAgents(
|
|
184
|
+
thresholdMs: number = 30_000,
|
|
185
|
+
cwd?: string,
|
|
186
|
+
): Promise<AgentRecoveryResult[]> {
|
|
187
|
+
const results: AgentRecoveryResult[] = [];
|
|
188
|
+
|
|
189
|
+
// Step 1: detect stale agents and mark them crashed
|
|
190
|
+
const staleAgents = await checkAgentHealth(thresholdMs, cwd);
|
|
191
|
+
for (const agent of staleAgents) {
|
|
192
|
+
await updateAgentStatus(
|
|
193
|
+
agent.id,
|
|
194
|
+
{ status: 'crashed', error: 'Heartbeat timeout detected during recovery sweep' },
|
|
195
|
+
cwd,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Step 2: process all crashed agents
|
|
200
|
+
const crashedAgents = await listAgentInstances({ status: 'crashed' }, cwd);
|
|
201
|
+
|
|
202
|
+
for (const agent of crashedAgents) {
|
|
203
|
+
// Check error history to determine recovery action
|
|
204
|
+
const { getAgentErrorHistory } = await import('./registry.js');
|
|
205
|
+
const errors = await getAgentErrorHistory(agent.id, cwd);
|
|
206
|
+
const lastError = errors.length > 0 ? errors[errors.length - 1] : null;
|
|
207
|
+
|
|
208
|
+
// Too many errors -- abandon
|
|
209
|
+
if (agent.errorCount >= 5) {
|
|
210
|
+
await updateAgentStatus(agent.id, { status: 'stopped' }, cwd);
|
|
211
|
+
results.push({
|
|
212
|
+
agentId: agent.id,
|
|
213
|
+
recovered: false,
|
|
214
|
+
action: 'abandoned',
|
|
215
|
+
reason: `Error count (${agent.errorCount}) exceeds threshold (5)`,
|
|
216
|
+
});
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Last error was permanent -- abandon
|
|
221
|
+
if (lastError?.errorType === 'permanent') {
|
|
222
|
+
await updateAgentStatus(agent.id, { status: 'stopped' }, cwd);
|
|
223
|
+
results.push({
|
|
224
|
+
agentId: agent.id,
|
|
225
|
+
recovered: false,
|
|
226
|
+
action: 'abandoned',
|
|
227
|
+
reason: `Permanent error: ${lastError.message}`,
|
|
228
|
+
});
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Retriable or unknown -- attempt restart by resetting to 'starting'
|
|
233
|
+
await updateAgentStatus(agent.id, { status: 'starting' }, cwd);
|
|
234
|
+
results.push({
|
|
235
|
+
agentId: agent.id,
|
|
236
|
+
recovered: true,
|
|
237
|
+
action: 'restarted',
|
|
238
|
+
reason: 'Agent reset to starting for re-assignment',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return results;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ============================================================================
|
|
246
|
+
// Utilities
|
|
247
|
+
// ============================================================================
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Sleep for a given number of milliseconds.
|
|
251
|
+
* Extracted for testability.
|
|
252
|
+
*/
|
|
253
|
+
function sleep(ms: number): Promise<void> {
|
|
254
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
255
|
+
}
|