conatus 0.1.0
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 +189 -0
- package/dist/adapter-layer.d.ts +67 -0
- package/dist/adapter-layer.d.ts.map +1 -0
- package/dist/adapter-layer.js +50 -0
- package/dist/adapter-layer.js.map +1 -0
- package/dist/adapters/a2a-adapter.d.ts +49 -0
- package/dist/adapters/a2a-adapter.d.ts.map +1 -0
- package/dist/adapters/a2a-adapter.js +211 -0
- package/dist/adapters/a2a-adapter.js.map +1 -0
- package/dist/adapters/a2a-client.d.ts +28 -0
- package/dist/adapters/a2a-client.d.ts.map +1 -0
- package/dist/adapters/a2a-client.js +178 -0
- package/dist/adapters/a2a-client.js.map +1 -0
- package/dist/adapters/browser-use-cli.d.ts +19 -0
- package/dist/adapters/browser-use-cli.d.ts.map +1 -0
- package/dist/adapters/browser-use-cli.js +112 -0
- package/dist/adapters/browser-use-cli.js.map +1 -0
- package/dist/adapters/claude-api.d.ts +10 -0
- package/dist/adapters/claude-api.d.ts.map +1 -0
- package/dist/adapters/claude-api.js +63 -0
- package/dist/adapters/claude-api.js.map +1 -0
- package/dist/adapters/claude-code-cli.d.ts +14 -0
- package/dist/adapters/claude-code-cli.d.ts.map +1 -0
- package/dist/adapters/claude-code-cli.js +99 -0
- package/dist/adapters/claude-code-cli.js.map +1 -0
- package/dist/adapters/file-existence-datasource.d.ts +16 -0
- package/dist/adapters/file-existence-datasource.d.ts.map +1 -0
- package/dist/adapters/file-existence-datasource.js +71 -0
- package/dist/adapters/file-existence-datasource.js.map +1 -0
- package/dist/adapters/github-issue-datasource.d.ts +45 -0
- package/dist/adapters/github-issue-datasource.d.ts.map +1 -0
- package/dist/adapters/github-issue-datasource.js +329 -0
- package/dist/adapters/github-issue-datasource.js.map +1 -0
- package/dist/adapters/github-issue.d.ts +87 -0
- package/dist/adapters/github-issue.d.ts.map +1 -0
- package/dist/adapters/github-issue.js +497 -0
- package/dist/adapters/github-issue.js.map +1 -0
- package/dist/adapters/openai-codex.d.ts +26 -0
- package/dist/adapters/openai-codex.d.ts.map +1 -0
- package/dist/adapters/openai-codex.js +112 -0
- package/dist/adapters/openai-codex.js.map +1 -0
- package/dist/adapters/shell-datasource.d.ts +36 -0
- package/dist/adapters/shell-datasource.d.ts.map +1 -0
- package/dist/adapters/shell-datasource.js +138 -0
- package/dist/adapters/shell-datasource.js.map +1 -0
- package/dist/capability-detector.d.ts +124 -0
- package/dist/capability-detector.d.ts.map +1 -0
- package/dist/capability-detector.js +576 -0
- package/dist/capability-detector.js.map +1 -0
- package/dist/character-config.d.ts +34 -0
- package/dist/character-config.d.ts.map +1 -0
- package/dist/character-config.js +53 -0
- package/dist/character-config.js.map +1 -0
- package/dist/cli/cli-logger.d.ts +3 -0
- package/dist/cli/cli-logger.d.ts.map +1 -0
- package/dist/cli/cli-logger.js +12 -0
- package/dist/cli/cli-logger.js.map +1 -0
- package/dist/cli/commands/config.d.ts +12 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +345 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/daemon.d.ts +6 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +99 -0
- package/dist/cli/commands/daemon.js.map +1 -0
- package/dist/cli/commands/goal-raw.d.ts +7 -0
- package/dist/cli/commands/goal-raw.d.ts.map +1 -0
- package/dist/cli/commands/goal-raw.js +93 -0
- package/dist/cli/commands/goal-raw.js.map +1 -0
- package/dist/cli/commands/goal-utils.d.ts +41 -0
- package/dist/cli/commands/goal-utils.d.ts.map +1 -0
- package/dist/cli/commands/goal-utils.js +184 -0
- package/dist/cli/commands/goal-utils.js.map +1 -0
- package/dist/cli/commands/goal.d.ts +22 -0
- package/dist/cli/commands/goal.d.ts.map +1 -0
- package/dist/cli/commands/goal.js +382 -0
- package/dist/cli/commands/goal.js.map +1 -0
- package/dist/cli/commands/plugin.d.ts +9 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +336 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +29 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/run.d.ts +10 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +159 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/suggest.d.ts +7 -0
- package/dist/cli/commands/suggest.d.ts.map +1 -0
- package/dist/cli/commands/suggest.js +466 -0
- package/dist/cli/commands/suggest.js.map +1 -0
- package/dist/cli/ensure-api-key.d.ts +14 -0
- package/dist/cli/ensure-api-key.d.ts.map +1 -0
- package/dist/cli/ensure-api-key.js +28 -0
- package/dist/cli/ensure-api-key.js.map +1 -0
- package/dist/cli/setup.d.ts +18 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +147 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/utils.d.ts +9 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +113 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/cli-runner.d.ts +32 -0
- package/dist/cli-runner.d.ts.map +1 -0
- package/dist/cli-runner.js +467 -0
- package/dist/cli-runner.js.map +1 -0
- package/dist/codex-llm-client.d.ts +47 -0
- package/dist/codex-llm-client.d.ts.map +1 -0
- package/dist/codex-llm-client.js +193 -0
- package/dist/codex-llm-client.js.map +1 -0
- package/dist/context-provider.d.ts +16 -0
- package/dist/context-provider.d.ts.map +1 -0
- package/dist/context-provider.js +107 -0
- package/dist/context-provider.js.map +1 -0
- package/dist/context-providers/workspace-context.d.ts +8 -0
- package/dist/context-providers/workspace-context.d.ts.map +1 -0
- package/dist/context-providers/workspace-context.js +217 -0
- package/dist/context-providers/workspace-context.js.map +1 -0
- package/dist/core/suggest/repo-context.d.ts +8 -0
- package/dist/core/suggest/repo-context.d.ts.map +1 -0
- package/dist/core/suggest/repo-context.js +154 -0
- package/dist/core/suggest/repo-context.js.map +1 -0
- package/dist/core-loop.d.ts +63 -0
- package/dist/core-loop.d.ts.map +1 -0
- package/dist/core-loop.js +521 -0
- package/dist/core-loop.js.map +1 -0
- package/dist/cross-goal-portfolio.d.ts +153 -0
- package/dist/cross-goal-portfolio.d.ts.map +1 -0
- package/dist/cross-goal-portfolio.js +790 -0
- package/dist/cross-goal-portfolio.js.map +1 -0
- package/dist/curiosity-engine.d.ts +177 -0
- package/dist/curiosity-engine.d.ts.map +1 -0
- package/dist/curiosity-engine.js +736 -0
- package/dist/curiosity-engine.js.map +1 -0
- package/dist/daemon-runner.d.ts +109 -0
- package/dist/daemon-runner.d.ts.map +1 -0
- package/dist/daemon-runner.js +389 -0
- package/dist/daemon-runner.js.map +1 -0
- package/dist/data-source-adapter.d.ts +42 -0
- package/dist/data-source-adapter.d.ts.map +1 -0
- package/dist/data-source-adapter.js +223 -0
- package/dist/data-source-adapter.js.map +1 -0
- package/dist/drive/drive-scorer.d.ts +96 -0
- package/dist/drive/drive-scorer.d.ts.map +1 -0
- package/dist/drive/drive-scorer.js +240 -0
- package/dist/drive/drive-scorer.js.map +1 -0
- package/dist/drive/drive-system.d.ts +99 -0
- package/dist/drive/drive-system.d.ts.map +1 -0
- package/dist/drive/drive-system.js +344 -0
- package/dist/drive/drive-system.js.map +1 -0
- package/dist/drive/gap-calculator.d.ts +80 -0
- package/dist/drive/gap-calculator.d.ts.map +1 -0
- package/dist/drive/gap-calculator.js +219 -0
- package/dist/drive/gap-calculator.js.map +1 -0
- package/dist/drive/reward-log.d.ts +51 -0
- package/dist/drive/reward-log.d.ts.map +1 -0
- package/dist/drive/reward-log.js +48 -0
- package/dist/drive/reward-log.js.map +1 -0
- package/dist/drive/satisficing-helpers.d.ts +28 -0
- package/dist/drive/satisficing-helpers.d.ts.map +1 -0
- package/dist/drive/satisficing-helpers.js +111 -0
- package/dist/drive/satisficing-helpers.js.map +1 -0
- package/dist/drive/satisficing-judge.d.ts +140 -0
- package/dist/drive/satisficing-judge.d.ts.map +1 -0
- package/dist/drive/satisficing-judge.js +432 -0
- package/dist/drive/satisficing-judge.js.map +1 -0
- package/dist/drive/satisficing-propagation.d.ts +30 -0
- package/dist/drive/satisficing-propagation.d.ts.map +1 -0
- package/dist/drive/satisficing-propagation.js +196 -0
- package/dist/drive/satisficing-propagation.js.map +1 -0
- package/dist/drive/stall-detector.d.ts +113 -0
- package/dist/drive/stall-detector.d.ts.map +1 -0
- package/dist/drive/stall-detector.js +378 -0
- package/dist/drive/stall-detector.js.map +1 -0
- package/dist/drive-scorer.d.ts +96 -0
- package/dist/drive-scorer.d.ts.map +1 -0
- package/dist/drive-scorer.js +235 -0
- package/dist/drive-scorer.js.map +1 -0
- package/dist/drive-system.d.ts +92 -0
- package/dist/drive-system.d.ts.map +1 -0
- package/dist/drive-system.js +325 -0
- package/dist/drive-system.js.map +1 -0
- package/dist/embedding-client.d.ts +49 -0
- package/dist/embedding-client.d.ts.map +1 -0
- package/dist/embedding-client.js +141 -0
- package/dist/embedding-client.js.map +1 -0
- package/dist/ethics-gate.d.ts +70 -0
- package/dist/ethics-gate.d.ts.map +1 -0
- package/dist/ethics-gate.js +567 -0
- package/dist/ethics-gate.js.map +1 -0
- package/dist/event-server.d.ts +23 -0
- package/dist/event-server.d.ts.map +1 -0
- package/dist/event-server.js +69 -0
- package/dist/event-server.js.map +1 -0
- package/dist/execution/adapter-layer.d.ts +88 -0
- package/dist/execution/adapter-layer.d.ts.map +1 -0
- package/dist/execution/adapter-layer.js +123 -0
- package/dist/execution/adapter-layer.js.map +1 -0
- package/dist/execution/checkpoint-manager.d.ts +49 -0
- package/dist/execution/checkpoint-manager.d.ts.map +1 -0
- package/dist/execution/checkpoint-manager.js +143 -0
- package/dist/execution/checkpoint-manager.js.map +1 -0
- package/dist/execution/context-budget.d.ts +35 -0
- package/dist/execution/context-budget.d.ts.map +1 -0
- package/dist/execution/context-budget.js +73 -0
- package/dist/execution/context-budget.js.map +1 -0
- package/dist/execution/dimension-selector.d.ts +22 -0
- package/dist/execution/dimension-selector.d.ts.map +1 -0
- package/dist/execution/dimension-selector.js +57 -0
- package/dist/execution/dimension-selector.js.map +1 -0
- package/dist/execution/impact-analyzer.d.ts +24 -0
- package/dist/execution/impact-analyzer.d.ts.map +1 -0
- package/dist/execution/impact-analyzer.js +88 -0
- package/dist/execution/impact-analyzer.js.map +1 -0
- package/dist/execution/parallel-executor.d.ts +35 -0
- package/dist/execution/parallel-executor.d.ts.map +1 -0
- package/dist/execution/parallel-executor.js +162 -0
- package/dist/execution/parallel-executor.js.map +1 -0
- package/dist/execution/pipeline-executor.d.ts +54 -0
- package/dist/execution/pipeline-executor.d.ts.map +1 -0
- package/dist/execution/pipeline-executor.js +250 -0
- package/dist/execution/pipeline-executor.js.map +1 -0
- package/dist/execution/reflection-generator.d.ts +24 -0
- package/dist/execution/reflection-generator.d.ts.map +1 -0
- package/dist/execution/reflection-generator.js +143 -0
- package/dist/execution/reflection-generator.js.map +1 -0
- package/dist/execution/result-reconciler.d.ts +23 -0
- package/dist/execution/result-reconciler.d.ts.map +1 -0
- package/dist/execution/result-reconciler.js +109 -0
- package/dist/execution/result-reconciler.js.map +1 -0
- package/dist/execution/session-manager.d.ts +182 -0
- package/dist/execution/session-manager.d.ts.map +1 -0
- package/dist/execution/session-manager.js +506 -0
- package/dist/execution/session-manager.js.map +1 -0
- package/dist/execution/task-approval-check.d.ts +9 -0
- package/dist/execution/task-approval-check.d.ts.map +1 -0
- package/dist/execution/task-approval-check.js +14 -0
- package/dist/execution/task-approval-check.js.map +1 -0
- package/dist/execution/task-approval.d.ts +37 -0
- package/dist/execution/task-approval.d.ts.map +1 -0
- package/dist/execution/task-approval.js +147 -0
- package/dist/execution/task-approval.js.map +1 -0
- package/dist/execution/task-execution-types.d.ts +14 -0
- package/dist/execution/task-execution-types.d.ts.map +1 -0
- package/dist/execution/task-execution-types.js +2 -0
- package/dist/execution/task-execution-types.js.map +1 -0
- package/dist/execution/task-executor.d.ts +30 -0
- package/dist/execution/task-executor.d.ts.map +1 -0
- package/dist/execution/task-executor.js +196 -0
- package/dist/execution/task-executor.js.map +1 -0
- package/dist/execution/task-generation.d.ts +154 -0
- package/dist/execution/task-generation.d.ts.map +1 -0
- package/dist/execution/task-generation.js +406 -0
- package/dist/execution/task-generation.js.map +1 -0
- package/dist/execution/task-health-check.d.ts +38 -0
- package/dist/execution/task-health-check.d.ts.map +1 -0
- package/dist/execution/task-health-check.js +66 -0
- package/dist/execution/task-health-check.js.map +1 -0
- package/dist/execution/task-lifecycle.d.ts +122 -0
- package/dist/execution/task-lifecycle.d.ts.map +1 -0
- package/dist/execution/task-lifecycle.js +303 -0
- package/dist/execution/task-lifecycle.js.map +1 -0
- package/dist/execution/task-pipeline-cycle.d.ts +45 -0
- package/dist/execution/task-pipeline-cycle.d.ts.map +1 -0
- package/dist/execution/task-pipeline-cycle.js +134 -0
- package/dist/execution/task-pipeline-cycle.js.map +1 -0
- package/dist/execution/task-prompt-builder.d.ts +9 -0
- package/dist/execution/task-prompt-builder.d.ts.map +1 -0
- package/dist/execution/task-prompt-builder.js +165 -0
- package/dist/execution/task-prompt-builder.js.map +1 -0
- package/dist/execution/task-verifier.d.ts +112 -0
- package/dist/execution/task-verifier.d.ts.map +1 -0
- package/dist/execution/task-verifier.js +782 -0
- package/dist/execution/task-verifier.js.map +1 -0
- package/dist/gap-calculator.d.ts +80 -0
- package/dist/gap-calculator.d.ts.map +1 -0
- package/dist/gap-calculator.js +218 -0
- package/dist/gap-calculator.js.map +1 -0
- package/dist/goal/goal-decomposer.d.ts +30 -0
- package/dist/goal/goal-decomposer.d.ts.map +1 -0
- package/dist/goal/goal-decomposer.js +167 -0
- package/dist/goal/goal-decomposer.js.map +1 -0
- package/dist/goal/goal-dependency-graph.d.ts +119 -0
- package/dist/goal/goal-dependency-graph.d.ts.map +1 -0
- package/dist/goal/goal-dependency-graph.js +322 -0
- package/dist/goal/goal-dependency-graph.js.map +1 -0
- package/dist/goal/goal-negotiator.d.ts +66 -0
- package/dist/goal/goal-negotiator.d.ts.map +1 -0
- package/dist/goal/goal-negotiator.js +260 -0
- package/dist/goal/goal-negotiator.js.map +1 -0
- package/dist/goal/goal-suggest.d.ts +85 -0
- package/dist/goal/goal-suggest.d.ts.map +1 -0
- package/dist/goal/goal-suggest.js +178 -0
- package/dist/goal/goal-suggest.js.map +1 -0
- package/dist/goal/goal-tree-manager.d.ts +71 -0
- package/dist/goal/goal-tree-manager.d.ts.map +1 -0
- package/dist/goal/goal-tree-manager.js +580 -0
- package/dist/goal/goal-tree-manager.js.map +1 -0
- package/dist/goal/goal-tree-pruner.d.ts +25 -0
- package/dist/goal/goal-tree-pruner.d.ts.map +1 -0
- package/dist/goal/goal-tree-pruner.js +93 -0
- package/dist/goal/goal-tree-pruner.js.map +1 -0
- package/dist/goal/goal-tree-quality.d.ts +22 -0
- package/dist/goal/goal-tree-quality.d.ts.map +1 -0
- package/dist/goal/goal-tree-quality.js +183 -0
- package/dist/goal/goal-tree-quality.js.map +1 -0
- package/dist/goal/goal-validation.d.ts +20 -0
- package/dist/goal/goal-validation.d.ts.map +1 -0
- package/dist/goal/goal-validation.js +93 -0
- package/dist/goal/goal-validation.js.map +1 -0
- package/dist/goal/negotiator-context.d.ts +13 -0
- package/dist/goal/negotiator-context.d.ts.map +1 -0
- package/dist/goal/negotiator-context.js +119 -0
- package/dist/goal/negotiator-context.js.map +1 -0
- package/dist/goal/negotiator-prompts.d.ts +31 -0
- package/dist/goal/negotiator-prompts.d.ts.map +1 -0
- package/dist/goal/negotiator-prompts.js +65 -0
- package/dist/goal/negotiator-prompts.js.map +1 -0
- package/dist/goal/negotiator-steps.d.ts +59 -0
- package/dist/goal/negotiator-steps.d.ts.map +1 -0
- package/dist/goal/negotiator-steps.js +269 -0
- package/dist/goal/negotiator-steps.js.map +1 -0
- package/dist/goal/state-aggregator.d.ts +89 -0
- package/dist/goal/state-aggregator.d.ts.map +1 -0
- package/dist/goal/state-aggregator.js +292 -0
- package/dist/goal/state-aggregator.js.map +1 -0
- package/dist/goal/tree-loop-orchestrator.d.ts +79 -0
- package/dist/goal/tree-loop-orchestrator.d.ts.map +1 -0
- package/dist/goal/tree-loop-orchestrator.js +230 -0
- package/dist/goal/tree-loop-orchestrator.js.map +1 -0
- package/dist/goal-dependency-graph.d.ts +112 -0
- package/dist/goal-dependency-graph.d.ts.map +1 -0
- package/dist/goal-dependency-graph.js +291 -0
- package/dist/goal-dependency-graph.js.map +1 -0
- package/dist/goal-negotiator.d.ts +109 -0
- package/dist/goal-negotiator.d.ts.map +1 -0
- package/dist/goal-negotiator.js +1044 -0
- package/dist/goal-negotiator.js.map +1 -0
- package/dist/goal-tree-manager.d.ts +120 -0
- package/dist/goal-tree-manager.d.ts.map +1 -0
- package/dist/goal-tree-manager.js +954 -0
- package/dist/goal-tree-manager.js.map +1 -0
- package/dist/guardrail-runner.d.ts +29 -0
- package/dist/guardrail-runner.d.ts.map +1 -0
- package/dist/guardrail-runner.js +81 -0
- package/dist/guardrail-runner.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/drive-score-adapter.d.ts +39 -0
- package/dist/knowledge/drive-score-adapter.d.ts.map +1 -0
- package/dist/knowledge/drive-score-adapter.js +32 -0
- package/dist/knowledge/drive-score-adapter.js.map +1 -0
- package/dist/knowledge/embedding-client.d.ts +49 -0
- package/dist/knowledge/embedding-client.d.ts.map +1 -0
- package/dist/knowledge/embedding-client.js +141 -0
- package/dist/knowledge/embedding-client.js.map +1 -0
- package/dist/knowledge/knowledge-decisions.d.ts +41 -0
- package/dist/knowledge/knowledge-decisions.d.ts.map +1 -0
- package/dist/knowledge/knowledge-decisions.js +191 -0
- package/dist/knowledge/knowledge-decisions.js.map +1 -0
- package/dist/knowledge/knowledge-graph.d.ts +74 -0
- package/dist/knowledge/knowledge-graph.d.ts.map +1 -0
- package/dist/knowledge/knowledge-graph.js +207 -0
- package/dist/knowledge/knowledge-graph.js.map +1 -0
- package/dist/knowledge/knowledge-manager.d.ts +138 -0
- package/dist/knowledge/knowledge-manager.d.ts.map +1 -0
- package/dist/knowledge/knowledge-manager.js +497 -0
- package/dist/knowledge/knowledge-manager.js.map +1 -0
- package/dist/knowledge/knowledge-revalidation.d.ts +27 -0
- package/dist/knowledge/knowledge-revalidation.d.ts.map +1 -0
- package/dist/knowledge/knowledge-revalidation.js +130 -0
- package/dist/knowledge/knowledge-revalidation.js.map +1 -0
- package/dist/knowledge/knowledge-search.d.ts +49 -0
- package/dist/knowledge/knowledge-search.d.ts.map +1 -0
- package/dist/knowledge/knowledge-search.js +108 -0
- package/dist/knowledge/knowledge-search.js.map +1 -0
- package/dist/knowledge/knowledge-transfer-prompts.d.ts +45 -0
- package/dist/knowledge/knowledge-transfer-prompts.d.ts.map +1 -0
- package/dist/knowledge/knowledge-transfer-prompts.js +72 -0
- package/dist/knowledge/knowledge-transfer-prompts.js.map +1 -0
- package/dist/knowledge/knowledge-transfer.d.ts +148 -0
- package/dist/knowledge/knowledge-transfer.d.ts.map +1 -0
- package/dist/knowledge/knowledge-transfer.js +718 -0
- package/dist/knowledge/knowledge-transfer.js.map +1 -0
- package/dist/knowledge/learning-cross-goal.d.ts +19 -0
- package/dist/knowledge/learning-cross-goal.d.ts.map +1 -0
- package/dist/knowledge/learning-cross-goal.js +173 -0
- package/dist/knowledge/learning-cross-goal.js.map +1 -0
- package/dist/knowledge/learning-feedback.d.ts +26 -0
- package/dist/knowledge/learning-feedback.d.ts.map +1 -0
- package/dist/knowledge/learning-feedback.js +183 -0
- package/dist/knowledge/learning-feedback.js.map +1 -0
- package/dist/knowledge/learning-pipeline-prompts.d.ts +134 -0
- package/dist/knowledge/learning-pipeline-prompts.d.ts.map +1 -0
- package/dist/knowledge/learning-pipeline-prompts.js +103 -0
- package/dist/knowledge/learning-pipeline-prompts.js.map +1 -0
- package/dist/knowledge/learning-pipeline.d.ts +108 -0
- package/dist/knowledge/learning-pipeline.d.ts.map +1 -0
- package/dist/knowledge/learning-pipeline.js +467 -0
- package/dist/knowledge/learning-pipeline.js.map +1 -0
- package/dist/knowledge/memory-compression.d.ts +44 -0
- package/dist/knowledge/memory-compression.d.ts.map +1 -0
- package/dist/knowledge/memory-compression.js +289 -0
- package/dist/knowledge/memory-compression.js.map +1 -0
- package/dist/knowledge/memory-distill.d.ts +31 -0
- package/dist/knowledge/memory-distill.d.ts.map +1 -0
- package/dist/knowledge/memory-distill.js +170 -0
- package/dist/knowledge/memory-distill.js.map +1 -0
- package/dist/knowledge/memory-index.d.ts +11 -0
- package/dist/knowledge/memory-index.d.ts.map +1 -0
- package/dist/knowledge/memory-index.js +134 -0
- package/dist/knowledge/memory-index.js.map +1 -0
- package/dist/knowledge/memory-lifecycle.d.ts +172 -0
- package/dist/knowledge/memory-lifecycle.d.ts.map +1 -0
- package/dist/knowledge/memory-lifecycle.js +398 -0
- package/dist/knowledge/memory-lifecycle.js.map +1 -0
- package/dist/knowledge/memory-persistence.d.ts +30 -0
- package/dist/knowledge/memory-persistence.d.ts.map +1 -0
- package/dist/knowledge/memory-persistence.js +120 -0
- package/dist/knowledge/memory-persistence.js.map +1 -0
- package/dist/knowledge/memory-phases.d.ts +14 -0
- package/dist/knowledge/memory-phases.d.ts.map +1 -0
- package/dist/knowledge/memory-phases.js +14 -0
- package/dist/knowledge/memory-phases.js.map +1 -0
- package/dist/knowledge/memory-query.d.ts +4 -0
- package/dist/knowledge/memory-query.d.ts.map +1 -0
- package/dist/knowledge/memory-query.js +64 -0
- package/dist/knowledge/memory-query.js.map +1 -0
- package/dist/knowledge/memory-selection.d.ts +80 -0
- package/dist/knowledge/memory-selection.d.ts.map +1 -0
- package/dist/knowledge/memory-selection.js +356 -0
- package/dist/knowledge/memory-selection.js.map +1 -0
- package/dist/knowledge/memory-stats.d.ts +7 -0
- package/dist/knowledge/memory-stats.d.ts.map +1 -0
- package/dist/knowledge/memory-stats.js +162 -0
- package/dist/knowledge/memory-stats.js.map +1 -0
- package/dist/knowledge/memory-tier.d.ts +47 -0
- package/dist/knowledge/memory-tier.d.ts.map +1 -0
- package/dist/knowledge/memory-tier.js +212 -0
- package/dist/knowledge/memory-tier.js.map +1 -0
- package/dist/knowledge/transfer-trust.d.ts +40 -0
- package/dist/knowledge/transfer-trust.d.ts.map +1 -0
- package/dist/knowledge/transfer-trust.js +137 -0
- package/dist/knowledge/transfer-trust.js.map +1 -0
- package/dist/knowledge/vector-index.d.ts +65 -0
- package/dist/knowledge/vector-index.d.ts.map +1 -0
- package/dist/knowledge/vector-index.js +153 -0
- package/dist/knowledge/vector-index.js.map +1 -0
- package/dist/knowledge-graph.d.ts +70 -0
- package/dist/knowledge-graph.d.ts.map +1 -0
- package/dist/knowledge-graph.js +194 -0
- package/dist/knowledge-graph.js.map +1 -0
- package/dist/knowledge-manager.d.ts +110 -0
- package/dist/knowledge-manager.d.ts.map +1 -0
- package/dist/knowledge-manager.js +544 -0
- package/dist/knowledge-manager.js.map +1 -0
- package/dist/knowledge-transfer.d.ts +101 -0
- package/dist/knowledge-transfer.d.ts.map +1 -0
- package/dist/knowledge-transfer.js +484 -0
- package/dist/knowledge-transfer.js.map +1 -0
- package/dist/learning-pipeline.d.ts +107 -0
- package/dist/learning-pipeline.d.ts.map +1 -0
- package/dist/learning-pipeline.js +840 -0
- package/dist/learning-pipeline.js.map +1 -0
- package/dist/llm/base-llm-client.d.ts +20 -0
- package/dist/llm/base-llm-client.d.ts.map +1 -0
- package/dist/llm/base-llm-client.js +48 -0
- package/dist/llm/base-llm-client.js.map +1 -0
- package/dist/llm/codex-llm-client.d.ts +41 -0
- package/dist/llm/codex-llm-client.d.ts.map +1 -0
- package/dist/llm/codex-llm-client.js +188 -0
- package/dist/llm/codex-llm-client.js.map +1 -0
- package/dist/llm/llm-client.d.ts +54 -0
- package/dist/llm/llm-client.d.ts.map +1 -0
- package/dist/llm/llm-client.js +148 -0
- package/dist/llm/llm-client.js.map +1 -0
- package/dist/llm/ollama-client.d.ts +24 -0
- package/dist/llm/ollama-client.d.ts.map +1 -0
- package/dist/llm/ollama-client.js +94 -0
- package/dist/llm/ollama-client.js.map +1 -0
- package/dist/llm/openai-client.d.ts +34 -0
- package/dist/llm/openai-client.d.ts.map +1 -0
- package/dist/llm/openai-client.js +140 -0
- package/dist/llm/openai-client.js.map +1 -0
- package/dist/llm/provider-config.d.ts +55 -0
- package/dist/llm/provider-config.d.ts.map +1 -0
- package/dist/llm/provider-config.js +136 -0
- package/dist/llm/provider-config.js.map +1 -0
- package/dist/llm/provider-factory.d.ts +25 -0
- package/dist/llm/provider-factory.d.ts.map +1 -0
- package/dist/llm/provider-factory.js +111 -0
- package/dist/llm/provider-factory.js.map +1 -0
- package/dist/llm-client.d.ts +65 -0
- package/dist/llm-client.d.ts.map +1 -0
- package/dist/llm-client.js +151 -0
- package/dist/llm-client.js.map +1 -0
- package/dist/logger.d.ts +30 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +121 -0
- package/dist/logger.js.map +1 -0
- package/dist/loop/core-loop-capability.d.ts +19 -0
- package/dist/loop/core-loop-capability.d.ts.map +1 -0
- package/dist/loop/core-loop-capability.js +107 -0
- package/dist/loop/core-loop-capability.js.map +1 -0
- package/dist/loop/core-loop-learning.d.ts +34 -0
- package/dist/loop/core-loop-learning.d.ts.map +1 -0
- package/dist/loop/core-loop-learning.js +78 -0
- package/dist/loop/core-loop-learning.js.map +1 -0
- package/dist/loop/core-loop-phases-b.d.ts +25 -0
- package/dist/loop/core-loop-phases-b.d.ts.map +1 -0
- package/dist/loop/core-loop-phases-b.js +510 -0
- package/dist/loop/core-loop-phases-b.js.map +1 -0
- package/dist/loop/core-loop-phases.d.ts +40 -0
- package/dist/loop/core-loop-phases.d.ts.map +1 -0
- package/dist/loop/core-loop-phases.js +228 -0
- package/dist/loop/core-loop-phases.js.map +1 -0
- package/dist/loop/core-loop-types.d.ts +202 -0
- package/dist/loop/core-loop-types.d.ts.map +1 -0
- package/dist/loop/core-loop-types.js +38 -0
- package/dist/loop/core-loop-types.js.map +1 -0
- package/dist/loop/tree-loop-runner.d.ts +24 -0
- package/dist/loop/tree-loop-runner.d.ts.map +1 -0
- package/dist/loop/tree-loop-runner.js +116 -0
- package/dist/loop/tree-loop-runner.js.map +1 -0
- package/dist/memory-lifecycle.d.ts +244 -0
- package/dist/memory-lifecycle.d.ts.map +1 -0
- package/dist/memory-lifecycle.js +1328 -0
- package/dist/memory-lifecycle.js.map +1 -0
- package/dist/notification-dispatcher.d.ts +36 -0
- package/dist/notification-dispatcher.d.ts.map +1 -0
- package/dist/notification-dispatcher.js +363 -0
- package/dist/notification-dispatcher.js.map +1 -0
- package/dist/observation/capability-dependencies.d.ts +45 -0
- package/dist/observation/capability-dependencies.d.ts.map +1 -0
- package/dist/observation/capability-dependencies.js +208 -0
- package/dist/observation/capability-dependencies.js.map +1 -0
- package/dist/observation/capability-detector.d.ts +72 -0
- package/dist/observation/capability-detector.d.ts.map +1 -0
- package/dist/observation/capability-detector.js +372 -0
- package/dist/observation/capability-detector.js.map +1 -0
- package/dist/observation/capability-registry.d.ts +48 -0
- package/dist/observation/capability-registry.d.ts.map +1 -0
- package/dist/observation/capability-registry.js +131 -0
- package/dist/observation/capability-registry.js.map +1 -0
- package/dist/observation/context-provider.d.ts +39 -0
- package/dist/observation/context-provider.d.ts.map +1 -0
- package/dist/observation/context-provider.js +177 -0
- package/dist/observation/context-provider.js.map +1 -0
- package/dist/observation/data-source-adapter.d.ts +42 -0
- package/dist/observation/data-source-adapter.d.ts.map +1 -0
- package/dist/observation/data-source-adapter.js +227 -0
- package/dist/observation/data-source-adapter.js.map +1 -0
- package/dist/observation/observation-apply.d.ts +18 -0
- package/dist/observation/observation-apply.d.ts.map +1 -0
- package/dist/observation/observation-apply.js +138 -0
- package/dist/observation/observation-apply.js.map +1 -0
- package/dist/observation/observation-datasource.d.ts +21 -0
- package/dist/observation/observation-datasource.d.ts.map +1 -0
- package/dist/observation/observation-datasource.js +96 -0
- package/dist/observation/observation-datasource.js.map +1 -0
- package/dist/observation/observation-engine.d.ts +156 -0
- package/dist/observation/observation-engine.d.ts.map +1 -0
- package/dist/observation/observation-engine.js +359 -0
- package/dist/observation/observation-engine.js.map +1 -0
- package/dist/observation/observation-helpers.d.ts +112 -0
- package/dist/observation/observation-helpers.d.ts.map +1 -0
- package/dist/observation/observation-helpers.js +173 -0
- package/dist/observation/observation-helpers.js.map +1 -0
- package/dist/observation/observation-llm.d.ts +46 -0
- package/dist/observation/observation-llm.d.ts.map +1 -0
- package/dist/observation/observation-llm.js +220 -0
- package/dist/observation/observation-llm.js.map +1 -0
- package/dist/observation/observation-task.d.ts +29 -0
- package/dist/observation/observation-task.d.ts.map +1 -0
- package/dist/observation/observation-task.js +51 -0
- package/dist/observation/observation-task.js.map +1 -0
- package/dist/observation/workspace-context.d.ts +8 -0
- package/dist/observation/workspace-context.d.ts.map +1 -0
- package/dist/observation/workspace-context.js +229 -0
- package/dist/observation/workspace-context.js.map +1 -0
- package/dist/observation-engine.d.ts +218 -0
- package/dist/observation-engine.d.ts.map +1 -0
- package/dist/observation-engine.js +711 -0
- package/dist/observation-engine.js.map +1 -0
- package/dist/ollama-client.d.ts +30 -0
- package/dist/ollama-client.d.ts.map +1 -0
- package/dist/ollama-client.js +112 -0
- package/dist/ollama-client.js.map +1 -0
- package/dist/openai-client.d.ts +40 -0
- package/dist/openai-client.d.ts.map +1 -0
- package/dist/openai-client.js +155 -0
- package/dist/openai-client.js.map +1 -0
- package/dist/pid-manager.d.ts +18 -0
- package/dist/pid-manager.d.ts.map +1 -0
- package/dist/pid-manager.js +64 -0
- package/dist/pid-manager.js.map +1 -0
- package/dist/portfolio-manager.d.ts +147 -0
- package/dist/portfolio-manager.d.ts.map +1 -0
- package/dist/portfolio-manager.js +371 -0
- package/dist/portfolio-manager.js.map +1 -0
- package/dist/portfolio-rebalance.d.ts +75 -0
- package/dist/portfolio-rebalance.d.ts.map +1 -0
- package/dist/portfolio-rebalance.js +254 -0
- package/dist/portfolio-rebalance.js.map +1 -0
- package/dist/prompt/context-assembler.d.ts +70 -0
- package/dist/prompt/context-assembler.d.ts.map +1 -0
- package/dist/prompt/context-assembler.js +346 -0
- package/dist/prompt/context-assembler.js.map +1 -0
- package/dist/prompt/formatters.d.ts +49 -0
- package/dist/prompt/formatters.d.ts.map +1 -0
- package/dist/prompt/formatters.js +136 -0
- package/dist/prompt/formatters.js.map +1 -0
- package/dist/prompt/gateway.d.ts +30 -0
- package/dist/prompt/gateway.d.ts.map +1 -0
- package/dist/prompt/gateway.js +43 -0
- package/dist/prompt/gateway.js.map +1 -0
- package/dist/prompt/index.d.ts +12 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +9 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/purposes/capability.d.ts +64 -0
- package/dist/prompt/purposes/capability.d.ts.map +1 -0
- package/dist/prompt/purposes/capability.js +38 -0
- package/dist/prompt/purposes/capability.js.map +1 -0
- package/dist/prompt/purposes/checkpoint.d.ts +22 -0
- package/dist/prompt/purposes/checkpoint.d.ts.map +1 -0
- package/dist/prompt/purposes/checkpoint.js +17 -0
- package/dist/prompt/purposes/checkpoint.js.map +1 -0
- package/dist/prompt/purposes/curiosity.d.ts +41 -0
- package/dist/prompt/purposes/curiosity.d.ts.map +1 -0
- package/dist/prompt/purposes/curiosity.js +20 -0
- package/dist/prompt/purposes/curiosity.js.map +1 -0
- package/dist/prompt/purposes/dependency.d.ts +34 -0
- package/dist/prompt/purposes/dependency.d.ts.map +1 -0
- package/dist/prompt/purposes/dependency.js +21 -0
- package/dist/prompt/purposes/dependency.js.map +1 -0
- package/dist/prompt/purposes/ethics.d.ts +47 -0
- package/dist/prompt/purposes/ethics.d.ts.map +1 -0
- package/dist/prompt/purposes/ethics.js +89 -0
- package/dist/prompt/purposes/ethics.js.map +1 -0
- package/dist/prompt/purposes/final-migration.d.ts +15 -0
- package/dist/prompt/purposes/final-migration.d.ts.map +1 -0
- package/dist/prompt/purposes/final-migration.js +15 -0
- package/dist/prompt/purposes/final-migration.js.map +1 -0
- package/dist/prompt/purposes/goal-decomposition.d.ts +46 -0
- package/dist/prompt/purposes/goal-decomposition.d.ts.map +1 -0
- package/dist/prompt/purposes/goal-decomposition.js +20 -0
- package/dist/prompt/purposes/goal-decomposition.js.map +1 -0
- package/dist/prompt/purposes/goal-quality.d.ts +61 -0
- package/dist/prompt/purposes/goal-quality.d.ts.map +1 -0
- package/dist/prompt/purposes/goal-quality.js +37 -0
- package/dist/prompt/purposes/goal-quality.js.map +1 -0
- package/dist/prompt/purposes/index.d.ts +29 -0
- package/dist/prompt/purposes/index.d.ts.map +1 -0
- package/dist/prompt/purposes/index.js +320 -0
- package/dist/prompt/purposes/index.js.map +1 -0
- package/dist/prompt/purposes/knowledge-transfer.d.ts +81 -0
- package/dist/prompt/purposes/knowledge-transfer.d.ts.map +1 -0
- package/dist/prompt/purposes/knowledge-transfer.js +33 -0
- package/dist/prompt/purposes/knowledge-transfer.js.map +1 -0
- package/dist/prompt/purposes/knowledge.d.ts +88 -0
- package/dist/prompt/purposes/knowledge.d.ts.map +1 -0
- package/dist/prompt/purposes/knowledge.js +59 -0
- package/dist/prompt/purposes/knowledge.js.map +1 -0
- package/dist/prompt/purposes/learning.d.ts +70 -0
- package/dist/prompt/purposes/learning.d.ts.map +1 -0
- package/dist/prompt/purposes/learning.js +32 -0
- package/dist/prompt/purposes/learning.js.map +1 -0
- package/dist/prompt/purposes/memory-distill.d.ts +75 -0
- package/dist/prompt/purposes/memory-distill.d.ts.map +1 -0
- package/dist/prompt/purposes/memory-distill.js +27 -0
- package/dist/prompt/purposes/memory-distill.js.map +1 -0
- package/dist/prompt/purposes/observation.d.ts +25 -0
- package/dist/prompt/purposes/observation.d.ts.map +1 -0
- package/dist/prompt/purposes/observation.js +17 -0
- package/dist/prompt/purposes/observation.js.map +1 -0
- package/dist/prompt/purposes/strategy-template.d.ts +57 -0
- package/dist/prompt/purposes/strategy-template.d.ts.map +1 -0
- package/dist/prompt/purposes/strategy-template.js +31 -0
- package/dist/prompt/purposes/strategy-template.js.map +1 -0
- package/dist/prompt/purposes/strategy.d.ts +41 -0
- package/dist/prompt/purposes/strategy.d.ts.map +1 -0
- package/dist/prompt/purposes/strategy.js +19 -0
- package/dist/prompt/purposes/strategy.js.map +1 -0
- package/dist/prompt/purposes/task-generation.d.ts +26 -0
- package/dist/prompt/purposes/task-generation.d.ts.map +1 -0
- package/dist/prompt/purposes/task-generation.js +22 -0
- package/dist/prompt/purposes/task-generation.js.map +1 -0
- package/dist/prompt/purposes/verification.d.ts +25 -0
- package/dist/prompt/purposes/verification.d.ts.map +1 -0
- package/dist/prompt/purposes/verification.js +17 -0
- package/dist/prompt/purposes/verification.js.map +1 -0
- package/dist/prompt/slot-definitions 2.d.ts +33 -0
- package/dist/prompt/slot-definitions 2.d.ts.map +1 -0
- package/dist/prompt/slot-definitions 2.js +332 -0
- package/dist/prompt/slot-definitions 2.js.map +1 -0
- package/dist/prompt/slot-definitions.d.ts +33 -0
- package/dist/prompt/slot-definitions.d.ts.map +1 -0
- package/dist/prompt/slot-definitions.js +383 -0
- package/dist/prompt/slot-definitions.js.map +1 -0
- package/dist/provider-config.d.ts +43 -0
- package/dist/provider-config.d.ts.map +1 -0
- package/dist/provider-config.js +131 -0
- package/dist/provider-config.js.map +1 -0
- package/dist/provider-factory.d.ts +23 -0
- package/dist/provider-factory.d.ts.map +1 -0
- package/dist/provider-factory.js +83 -0
- package/dist/provider-factory.js.map +1 -0
- package/dist/reporting-engine.d.ts +58 -0
- package/dist/reporting-engine.d.ts.map +1 -0
- package/dist/reporting-engine.js +592 -0
- package/dist/reporting-engine.js.map +1 -0
- package/dist/runtime/daemon-runner.d.ts +147 -0
- package/dist/runtime/daemon-runner.d.ts.map +1 -0
- package/dist/runtime/daemon-runner.js +549 -0
- package/dist/runtime/daemon-runner.js.map +1 -0
- package/dist/runtime/event-server.d.ts +50 -0
- package/dist/runtime/event-server.d.ts.map +1 -0
- package/dist/runtime/event-server.js +192 -0
- package/dist/runtime/event-server.js.map +1 -0
- package/dist/runtime/logger.d.ts +57 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +254 -0
- package/dist/runtime/logger.js.map +1 -0
- package/dist/runtime/notification-dispatcher.d.ts +49 -0
- package/dist/runtime/notification-dispatcher.d.ts.map +1 -0
- package/dist/runtime/notification-dispatcher.js +444 -0
- package/dist/runtime/notification-dispatcher.js.map +1 -0
- package/dist/runtime/notifier-registry.d.ts +26 -0
- package/dist/runtime/notifier-registry.d.ts.map +1 -0
- package/dist/runtime/notifier-registry.js +36 -0
- package/dist/runtime/notifier-registry.js.map +1 -0
- package/dist/runtime/pid-manager.d.ts +18 -0
- package/dist/runtime/pid-manager.d.ts.map +1 -0
- package/dist/runtime/pid-manager.js +61 -0
- package/dist/runtime/pid-manager.js.map +1 -0
- package/dist/runtime/plugin-loader.d.ts +78 -0
- package/dist/runtime/plugin-loader.d.ts.map +1 -0
- package/dist/runtime/plugin-loader.js +349 -0
- package/dist/runtime/plugin-loader.js.map +1 -0
- package/dist/satisficing-judge.d.ts +113 -0
- package/dist/satisficing-judge.d.ts.map +1 -0
- package/dist/satisficing-judge.js +592 -0
- package/dist/satisficing-judge.js.map +1 -0
- package/dist/session-manager.d.ts +159 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +458 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/stall-detector.d.ts +100 -0
- package/dist/stall-detector.d.ts.map +1 -0
- package/dist/stall-detector.js +306 -0
- package/dist/stall-detector.js.map +1 -0
- package/dist/state-aggregator.d.ts +89 -0
- package/dist/state-aggregator.d.ts.map +1 -0
- package/dist/state-aggregator.js +290 -0
- package/dist/state-aggregator.js.map +1 -0
- package/dist/state-manager.d.ts +121 -0
- package/dist/state-manager.d.ts.map +1 -0
- package/dist/state-manager.js +547 -0
- package/dist/state-manager.js.map +1 -0
- package/dist/strategy/cross-goal-portfolio.d.ts +118 -0
- package/dist/strategy/cross-goal-portfolio.d.ts.map +1 -0
- package/dist/strategy/cross-goal-portfolio.js +431 -0
- package/dist/strategy/cross-goal-portfolio.js.map +1 -0
- package/dist/strategy/portfolio-allocation.d.ts +36 -0
- package/dist/strategy/portfolio-allocation.d.ts.map +1 -0
- package/dist/strategy/portfolio-allocation.js +215 -0
- package/dist/strategy/portfolio-allocation.js.map +1 -0
- package/dist/strategy/portfolio-momentum.d.ts +11 -0
- package/dist/strategy/portfolio-momentum.d.ts.map +1 -0
- package/dist/strategy/portfolio-momentum.js +64 -0
- package/dist/strategy/portfolio-momentum.js.map +1 -0
- package/dist/strategy/portfolio-scheduling.d.ts +25 -0
- package/dist/strategy/portfolio-scheduling.d.ts.map +1 -0
- package/dist/strategy/portfolio-scheduling.js +133 -0
- package/dist/strategy/portfolio-scheduling.js.map +1 -0
- package/dist/strategy/strategy-helpers.d.ts +109 -0
- package/dist/strategy/strategy-helpers.d.ts.map +1 -0
- package/dist/strategy/strategy-helpers.js +125 -0
- package/dist/strategy/strategy-helpers.js.map +1 -0
- package/dist/strategy/strategy-manager-base.d.ts +95 -0
- package/dist/strategy/strategy-manager-base.d.ts.map +1 -0
- package/dist/strategy/strategy-manager-base.js +363 -0
- package/dist/strategy/strategy-manager-base.js.map +1 -0
- package/dist/strategy/strategy-manager.d.ts +65 -0
- package/dist/strategy/strategy-manager.d.ts.map +1 -0
- package/dist/strategy/strategy-manager.js +226 -0
- package/dist/strategy/strategy-manager.js.map +1 -0
- package/dist/strategy/strategy-template-registry.d.ts +84 -0
- package/dist/strategy/strategy-template-registry.d.ts.map +1 -0
- package/dist/strategy/strategy-template-registry.js +350 -0
- package/dist/strategy/strategy-template-registry.js.map +1 -0
- package/dist/strategy-manager.d.ts +128 -0
- package/dist/strategy-manager.d.ts.map +1 -0
- package/dist/strategy-manager.js +579 -0
- package/dist/strategy-manager.js.map +1 -0
- package/dist/strategy-template-registry.d.ts +80 -0
- package/dist/strategy-template-registry.d.ts.map +1 -0
- package/dist/strategy-template-registry.js +320 -0
- package/dist/strategy-template-registry.js.map +1 -0
- package/dist/task-lifecycle.d.ts +167 -0
- package/dist/task-lifecycle.d.ts.map +1 -0
- package/dist/task-lifecycle.js +1161 -0
- package/dist/task-lifecycle.js.map +1 -0
- package/dist/traits/character-config.d.ts +34 -0
- package/dist/traits/character-config.d.ts.map +1 -0
- package/dist/traits/character-config.js +53 -0
- package/dist/traits/character-config.js.map +1 -0
- package/dist/traits/curiosity-engine.d.ts +185 -0
- package/dist/traits/curiosity-engine.d.ts.map +1 -0
- package/dist/traits/curiosity-engine.js +530 -0
- package/dist/traits/curiosity-engine.js.map +1 -0
- package/dist/traits/curiosity-proposals.d.ts +38 -0
- package/dist/traits/curiosity-proposals.d.ts.map +1 -0
- package/dist/traits/curiosity-proposals.js +259 -0
- package/dist/traits/curiosity-proposals.js.map +1 -0
- package/dist/traits/curiosity-transfer.d.ts +27 -0
- package/dist/traits/curiosity-transfer.d.ts.map +1 -0
- package/dist/traits/curiosity-transfer.js +50 -0
- package/dist/traits/curiosity-transfer.js.map +1 -0
- package/dist/traits/ethics-gate.d.ts +72 -0
- package/dist/traits/ethics-gate.d.ts.map +1 -0
- package/dist/traits/ethics-gate.js +591 -0
- package/dist/traits/ethics-gate.js.map +1 -0
- package/dist/traits/trust-manager.d.ts +90 -0
- package/dist/traits/trust-manager.d.ts.map +1 -0
- package/dist/traits/trust-manager.js +276 -0
- package/dist/traits/trust-manager.js.map +1 -0
- package/dist/tree-loop-orchestrator.d.ts +79 -0
- package/dist/tree-loop-orchestrator.d.ts.map +1 -0
- package/dist/tree-loop-orchestrator.js +225 -0
- package/dist/tree-loop-orchestrator.js.map +1 -0
- package/dist/trust-manager.d.ts +67 -0
- package/dist/trust-manager.d.ts.map +1 -0
- package/dist/trust-manager.js +201 -0
- package/dist/trust-manager.js.map +1 -0
- package/dist/tui/actions.d.ts +38 -0
- package/dist/tui/actions.d.ts.map +1 -0
- package/dist/tui/actions.js +229 -0
- package/dist/tui/actions.js.map +1 -0
- package/dist/tui/app.d.ts +24 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +159 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/approval-overlay.d.ts +8 -0
- package/dist/tui/approval-overlay.d.ts.map +1 -0
- package/dist/tui/approval-overlay.js +20 -0
- package/dist/tui/approval-overlay.js.map +1 -0
- package/dist/tui/chat.d.ts +15 -0
- package/dist/tui/chat.d.ts.map +1 -0
- package/dist/tui/chat.js +196 -0
- package/dist/tui/chat.js.map +1 -0
- package/dist/tui/dashboard.d.ts +9 -0
- package/dist/tui/dashboard.d.ts.map +1 -0
- package/dist/tui/dashboard.js +69 -0
- package/dist/tui/dashboard.js.map +1 -0
- package/dist/tui/entry.d.ts +3 -0
- package/dist/tui/entry.d.ts.map +1 -0
- package/dist/tui/entry.js +222 -0
- package/dist/tui/entry.js.map +1 -0
- package/dist/tui/fuzzy.d.ts +22 -0
- package/dist/tui/fuzzy.d.ts.map +1 -0
- package/dist/tui/fuzzy.js +66 -0
- package/dist/tui/fuzzy.js.map +1 -0
- package/dist/tui/help-overlay.d.ts +6 -0
- package/dist/tui/help-overlay.d.ts.map +1 -0
- package/dist/tui/help-overlay.js +12 -0
- package/dist/tui/help-overlay.js.map +1 -0
- package/dist/tui/intent-recognizer.d.ts +19 -0
- package/dist/tui/intent-recognizer.d.ts.map +1 -0
- package/dist/tui/intent-recognizer.js +125 -0
- package/dist/tui/intent-recognizer.js.map +1 -0
- package/dist/tui/markdown-renderer.d.ts +37 -0
- package/dist/tui/markdown-renderer.d.ts.map +1 -0
- package/dist/tui/markdown-renderer.js +220 -0
- package/dist/tui/markdown-renderer.js.map +1 -0
- package/dist/tui/report-view.d.ts +6 -0
- package/dist/tui/report-view.d.ts.map +1 -0
- package/dist/tui/report-view.js +79 -0
- package/dist/tui/report-view.js.map +1 -0
- package/dist/tui/use-loop.d.ts +54 -0
- package/dist/tui/use-loop.d.ts.map +1 -0
- package/dist/tui/use-loop.js +185 -0
- package/dist/tui/use-loop.js.map +1 -0
- package/dist/types/a2a.d.ts +972 -0
- package/dist/types/a2a.d.ts.map +1 -0
- package/dist/types/a2a.js +130 -0
- package/dist/types/a2a.js.map +1 -0
- package/dist/types/capability.d.ts +292 -0
- package/dist/types/capability.d.ts.map +1 -0
- package/dist/types/capability.js +53 -0
- package/dist/types/capability.js.map +1 -0
- package/dist/types/character.d.ts +20 -0
- package/dist/types/character.d.ts.map +1 -0
- package/dist/types/character.js +10 -0
- package/dist/types/character.js.map +1 -0
- package/dist/types/checkpoint.d.ts +109 -0
- package/dist/types/checkpoint.d.ts.map +1 -0
- package/dist/types/checkpoint.js +27 -0
- package/dist/types/checkpoint.js.map +1 -0
- package/dist/types/core.d.ts +175 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +154 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/cross-portfolio.d.ts +378 -0
- package/dist/types/cross-portfolio.d.ts.map +1 -0
- package/dist/types/cross-portfolio.js +155 -0
- package/dist/types/cross-portfolio.js.map +1 -0
- package/dist/types/curiosity.d.ts +443 -0
- package/dist/types/curiosity.d.ts.map +1 -0
- package/dist/types/curiosity.js +86 -0
- package/dist/types/curiosity.js.map +1 -0
- package/dist/types/daemon.d.ts +111 -0
- package/dist/types/daemon.d.ts.map +1 -0
- package/dist/types/daemon.js +37 -0
- package/dist/types/daemon.js.map +1 -0
- package/dist/types/data-source.d.ts +311 -0
- package/dist/types/data-source.d.ts.map +1 -0
- package/dist/types/data-source.js +53 -0
- package/dist/types/data-source.js.map +1 -0
- package/dist/types/dependency.d.ts +108 -0
- package/dist/types/dependency.d.ts.map +1 -0
- package/dist/types/dependency.js +21 -0
- package/dist/types/dependency.js.map +1 -0
- package/dist/types/drive.d.ts +194 -0
- package/dist/types/drive.d.ts.map +1 -0
- package/dist/types/drive.js +77 -0
- package/dist/types/drive.js.map +1 -0
- package/dist/types/embedding.d.ts +59 -0
- package/dist/types/embedding.d.ts.map +1 -0
- package/dist/types/embedding.js +22 -0
- package/dist/types/embedding.js.map +1 -0
- package/dist/types/ethics.d.ts +169 -0
- package/dist/types/ethics.d.ts.map +1 -0
- package/dist/types/ethics.js +47 -0
- package/dist/types/ethics.js.map +1 -0
- package/dist/types/gap.d.ts +146 -0
- package/dist/types/gap.d.ts.map +1 -0
- package/dist/types/gap.js +41 -0
- package/dist/types/gap.js.map +1 -0
- package/dist/types/goal-tree.d.ts +180 -0
- package/dist/types/goal-tree.d.ts.map +1 -0
- package/dist/types/goal-tree.js +73 -0
- package/dist/types/goal-tree.js.map +1 -0
- package/dist/types/goal.d.ts +1233 -0
- package/dist/types/goal.d.ts.map +1 -0
- package/dist/types/goal.js +119 -0
- package/dist/types/goal.js.map +1 -0
- package/dist/types/guardrail.d.ts +104 -0
- package/dist/types/guardrail.d.ts.map +1 -0
- package/dist/types/guardrail.js +34 -0
- package/dist/types/guardrail.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +31 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge.d.ts +402 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +116 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/learning.d.ts +292 -0
- package/dist/types/learning.d.ts.map +1 -0
- package/dist/types/learning.js +120 -0
- package/dist/types/learning.js.map +1 -0
- package/dist/types/memory-lifecycle.d.ts +617 -0
- package/dist/types/memory-lifecycle.d.ts.map +1 -0
- package/dist/types/memory-lifecycle.js +159 -0
- package/dist/types/memory-lifecycle.js.map +1 -0
- package/dist/types/negotiation.d.ts +450 -0
- package/dist/types/negotiation.d.ts.map +1 -0
- package/dist/types/negotiation.js +84 -0
- package/dist/types/negotiation.js.map +1 -0
- package/dist/types/notification.d.ts +879 -0
- package/dist/types/notification.d.ts.map +1 -0
- package/dist/types/notification.js +75 -0
- package/dist/types/notification.js.map +1 -0
- package/dist/types/pipeline.d.ts +191 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +62 -0
- package/dist/types/pipeline.js.map +1 -0
- package/dist/types/plugin.d.ts +335 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +61 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/portfolio.d.ts +146 -0
- package/dist/types/portfolio.d.ts.map +1 -0
- package/dist/types/portfolio.js +55 -0
- package/dist/types/portfolio.js.map +1 -0
- package/dist/types/reflection.d.ts +34 -0
- package/dist/types/reflection.d.ts.map +1 -0
- package/dist/types/reflection.js +14 -0
- package/dist/types/reflection.js.map +1 -0
- package/dist/types/report.d.ts +205 -0
- package/dist/types/report.d.ts.map +1 -0
- package/dist/types/report.js +59 -0
- package/dist/types/report.js.map +1 -0
- package/dist/types/satisficing.d.ts +130 -0
- package/dist/types/satisficing.d.ts.map +1 -0
- package/dist/types/satisficing.js +54 -0
- package/dist/types/satisficing.js.map +1 -0
- package/dist/types/session.d.ts +95 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +36 -0
- package/dist/types/session.js.map +1 -0
- package/dist/types/stall.d.ts +68 -0
- package/dist/types/stall.d.ts.map +1 -0
- package/dist/types/stall.js +28 -0
- package/dist/types/stall.js.map +1 -0
- package/dist/types/state.d.ts +245 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/state.js +36 -0
- package/dist/types/state.js.map +1 -0
- package/dist/types/strategy.d.ts +541 -0
- package/dist/types/strategy.d.ts.map +1 -0
- package/dist/types/strategy.js +55 -0
- package/dist/types/strategy.js.map +1 -0
- package/dist/types/suggest.d.ts +92 -0
- package/dist/types/suggest.d.ts.map +1 -0
- package/dist/types/suggest.js +15 -0
- package/dist/types/suggest.js.map +1 -0
- package/dist/types/task-group.d.ts +231 -0
- package/dist/types/task-group.d.ts.map +1 -0
- package/dist/types/task-group.js +14 -0
- package/dist/types/task-group.js.map +1 -0
- package/dist/types/task.d.ts +258 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +66 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/trust.d.ts +126 -0
- package/dist/types/trust.d.ts.map +1 -0
- package/dist/types/trust.js +38 -0
- package/dist/types/trust.js.map +1 -0
- package/dist/utils/errors.d.ts +17 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +34 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/json-io.d.ts +28 -0
- package/dist/utils/json-io.d.ts.map +1 -0
- package/dist/utils/json-io.js +71 -0
- package/dist/utils/json-io.js.map +1 -0
- package/dist/utils/paths.d.ts +14 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +38 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/sleep.d.ts +2 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +4 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/vector-index.d.ts +39 -0
- package/dist/vector-index.d.ts.map +1 -0
- package/dist/vector-index.js +111 -0
- package/dist/vector-index.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,1161 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { execFileSync as _execFileSync } from "node:child_process";
|
|
3
|
+
import * as _fs from "node:fs";
|
|
4
|
+
import * as _path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { scoreAllDimensions, rankDimensions } from "./drive/drive-scorer.js";
|
|
7
|
+
import { TaskSchema, VerificationResultSchema } from "./types/task.js";
|
|
8
|
+
import { AdapterRegistry } from "./adapter-layer.js";
|
|
9
|
+
export { AdapterRegistry };
|
|
10
|
+
const DEBUG = process.env.MOTIVA_DEBUG === "true";
|
|
11
|
+
// ─── Schema for LLM-generated task fields ───
|
|
12
|
+
const LLMGeneratedTaskSchema = z.object({
|
|
13
|
+
work_description: z.string(),
|
|
14
|
+
rationale: z.string(),
|
|
15
|
+
approach: z.string(),
|
|
16
|
+
success_criteria: z.array(z.object({
|
|
17
|
+
description: z.string(),
|
|
18
|
+
verification_method: z.string(),
|
|
19
|
+
is_blocking: z.boolean().default(true),
|
|
20
|
+
})),
|
|
21
|
+
scope_boundary: z.object({
|
|
22
|
+
in_scope: z.array(z.string()),
|
|
23
|
+
out_of_scope: z.array(z.string()),
|
|
24
|
+
blast_radius: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
constraints: z.array(z.string()),
|
|
27
|
+
reversibility: z.enum(["reversible", "irreversible", "unknown"]).default("reversible"),
|
|
28
|
+
estimated_duration: z
|
|
29
|
+
.object({
|
|
30
|
+
value: z.number(),
|
|
31
|
+
unit: z.enum(["minutes", "hours", "days", "weeks"]),
|
|
32
|
+
})
|
|
33
|
+
.nullable()
|
|
34
|
+
.default(null),
|
|
35
|
+
});
|
|
36
|
+
// ─── TaskLifecycle ───
|
|
37
|
+
/**
|
|
38
|
+
* TaskLifecycle manages the full lifecycle of tasks:
|
|
39
|
+
* select target dimension -> generate task -> approval check -> execute -> verify -> handle verdict.
|
|
40
|
+
*/
|
|
41
|
+
export class TaskLifecycle {
|
|
42
|
+
stateManager;
|
|
43
|
+
llmClient;
|
|
44
|
+
sessionManager;
|
|
45
|
+
trustManager;
|
|
46
|
+
strategyManager;
|
|
47
|
+
stallDetector;
|
|
48
|
+
approvalFn;
|
|
49
|
+
ethicsGate;
|
|
50
|
+
capabilityDetector;
|
|
51
|
+
logger;
|
|
52
|
+
adapterRegistry;
|
|
53
|
+
healthCheckEnabled;
|
|
54
|
+
execFileSyncFn;
|
|
55
|
+
onTaskComplete;
|
|
56
|
+
constructor(stateManager, llmClient, sessionManager, trustManager, strategyManager, stallDetector, options) {
|
|
57
|
+
this.stateManager = stateManager;
|
|
58
|
+
this.llmClient = llmClient;
|
|
59
|
+
this.sessionManager = sessionManager;
|
|
60
|
+
this.trustManager = trustManager;
|
|
61
|
+
this.strategyManager = strategyManager;
|
|
62
|
+
this.stallDetector = stallDetector;
|
|
63
|
+
this.approvalFn = options?.approvalFn ?? ((_task) => Promise.resolve(false));
|
|
64
|
+
this.ethicsGate = options?.ethicsGate;
|
|
65
|
+
this.capabilityDetector = options?.capabilityDetector;
|
|
66
|
+
this.logger = options?.logger;
|
|
67
|
+
this.adapterRegistry = options?.adapterRegistry;
|
|
68
|
+
this.healthCheckEnabled = options?.healthCheckEnabled ?? false;
|
|
69
|
+
this.execFileSyncFn = options?.execFileSyncFn ?? _execFileSync;
|
|
70
|
+
}
|
|
71
|
+
// ─── setOnTaskComplete ───
|
|
72
|
+
/**
|
|
73
|
+
* Register a callback to be invoked when a task completes successfully.
|
|
74
|
+
* Used by PortfolioManager to track task completion times per strategy.
|
|
75
|
+
*/
|
|
76
|
+
setOnTaskComplete(callback) {
|
|
77
|
+
this.onTaskComplete = callback;
|
|
78
|
+
}
|
|
79
|
+
// ─── selectTargetDimension ───
|
|
80
|
+
/**
|
|
81
|
+
* Select the highest-priority dimension to work on based on drive scoring.
|
|
82
|
+
*
|
|
83
|
+
* @param gapVector - current gap state for the goal
|
|
84
|
+
* @param driveContext - per-dimension timing/deadline/opportunity context
|
|
85
|
+
* @returns the name of the top-ranked dimension
|
|
86
|
+
* @throws if gapVector has no gaps (empty)
|
|
87
|
+
*/
|
|
88
|
+
selectTargetDimension(gapVector, driveContext) {
|
|
89
|
+
if (gapVector.gaps.length === 0) {
|
|
90
|
+
throw new Error("selectTargetDimension: gapVector has no gaps (empty gap vector)");
|
|
91
|
+
}
|
|
92
|
+
const scores = scoreAllDimensions(gapVector, driveContext);
|
|
93
|
+
const ranked = rankDimensions(scores);
|
|
94
|
+
// ranked is sorted descending by final_score; take the top one
|
|
95
|
+
return ranked[0].dimension_name;
|
|
96
|
+
}
|
|
97
|
+
// ─── generateTask ───
|
|
98
|
+
/**
|
|
99
|
+
* Generate a task for the given goal and target dimension via LLM.
|
|
100
|
+
*
|
|
101
|
+
* @param goalId - the goal this task belongs to
|
|
102
|
+
* @param targetDimension - the dimension this task should improve
|
|
103
|
+
* @param strategyId - optional override; if not provided, uses active strategy
|
|
104
|
+
* @returns the generated and persisted Task
|
|
105
|
+
*/
|
|
106
|
+
async generateTask(goalId, targetDimension, strategyId, knowledgeContext, adapterType, existingTasks, workspaceContext) {
|
|
107
|
+
const prompt = this.buildTaskGenerationPrompt(goalId, targetDimension, knowledgeContext, adapterType, existingTasks, workspaceContext);
|
|
108
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], {
|
|
109
|
+
system: "You are a task generation assistant. Given a goal and target dimension, generate a concrete, actionable task. Respond with a JSON object inside a markdown code block.",
|
|
110
|
+
max_tokens: 2048,
|
|
111
|
+
});
|
|
112
|
+
let generated;
|
|
113
|
+
try {
|
|
114
|
+
generated = this.llmClient.parseJSON(response.content, LLMGeneratedTaskSchema);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
this.logger?.error("Task generation failed: LLM response did not match expected schema.", { rawResponse: response.content.substring(0, 500) });
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
// Resolve strategy_id
|
|
121
|
+
const activeStrategy = this.strategyManager.getActiveStrategy(goalId);
|
|
122
|
+
const resolvedStrategyId = strategyId ?? activeStrategy?.id ?? null;
|
|
123
|
+
const taskId = randomUUID();
|
|
124
|
+
const now = new Date().toISOString();
|
|
125
|
+
const task = TaskSchema.parse({
|
|
126
|
+
id: taskId,
|
|
127
|
+
goal_id: goalId,
|
|
128
|
+
strategy_id: resolvedStrategyId,
|
|
129
|
+
target_dimensions: [targetDimension],
|
|
130
|
+
primary_dimension: targetDimension,
|
|
131
|
+
work_description: generated.work_description,
|
|
132
|
+
rationale: generated.rationale,
|
|
133
|
+
approach: generated.approach,
|
|
134
|
+
success_criteria: generated.success_criteria,
|
|
135
|
+
scope_boundary: generated.scope_boundary,
|
|
136
|
+
constraints: generated.constraints,
|
|
137
|
+
reversibility: generated.reversibility,
|
|
138
|
+
estimated_duration: generated.estimated_duration,
|
|
139
|
+
status: "pending",
|
|
140
|
+
created_at: now,
|
|
141
|
+
});
|
|
142
|
+
// Persist
|
|
143
|
+
this.stateManager.writeRaw(`tasks/${goalId}/${taskId}.json`, task);
|
|
144
|
+
return task;
|
|
145
|
+
}
|
|
146
|
+
// ─── checkIrreversibleApproval ───
|
|
147
|
+
/**
|
|
148
|
+
* Check whether the task requires human approval and, if so, request it.
|
|
149
|
+
*
|
|
150
|
+
* @param task - the task to check
|
|
151
|
+
* @param confidence - observation confidence for the approval check (default 0.5)
|
|
152
|
+
* @returns true if approved or approval not needed; false if approval was denied
|
|
153
|
+
*/
|
|
154
|
+
async checkIrreversibleApproval(task, confidence = 0.5) {
|
|
155
|
+
const domain = task.task_category;
|
|
156
|
+
const needsApproval = this.trustManager.requiresApproval(task.reversibility, domain, confidence, task.task_category);
|
|
157
|
+
if (!needsApproval) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
const approved = await this.approvalFn(task);
|
|
161
|
+
return approved;
|
|
162
|
+
}
|
|
163
|
+
// ─── executeTask ───
|
|
164
|
+
/**
|
|
165
|
+
* Execute a task via the given adapter.
|
|
166
|
+
*
|
|
167
|
+
* Creates a session, builds context, converts to AgentTask, executes
|
|
168
|
+
* via adapter, ends session, and updates task status based on result.
|
|
169
|
+
*/
|
|
170
|
+
async executeTask(task, adapter) {
|
|
171
|
+
// Create execution session
|
|
172
|
+
const session = this.sessionManager.createSession("task_execution", task.goal_id, task.id);
|
|
173
|
+
// Build context
|
|
174
|
+
const contextSlots = this.sessionManager.buildTaskExecutionContext(task.goal_id, task.id);
|
|
175
|
+
// Convert to AgentTask
|
|
176
|
+
let prompt;
|
|
177
|
+
if (adapter.adapterType === "github_issue") {
|
|
178
|
+
// For github_issue adapter, format as a structured JSON block so
|
|
179
|
+
// GitHubIssueAdapter.parsePrompt extracts a proper title instead of
|
|
180
|
+
// picking up the context-slot label as the issue title.
|
|
181
|
+
const titleLine = task.work_description.split("\n")[0]?.trim() ?? task.work_description;
|
|
182
|
+
const title = titleLine.length > 120 ? titleLine.slice(0, 117) + "..." : titleLine;
|
|
183
|
+
const issuePayload = JSON.stringify({ title, body: task.work_description });
|
|
184
|
+
prompt = `\`\`\`github-issue\n${issuePayload}\n\`\`\``;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// Build prompt with task description as primary content
|
|
188
|
+
const taskDescription = `You are an AI agent executing a task.\n\nTask: ${task.work_description}\n\nApproach: ${task.approach}\n\nSuccess Criteria:\n${task.success_criteria.map((c) => `- ${c.description}`).join("\n")}`;
|
|
189
|
+
const contextContent = contextSlots
|
|
190
|
+
.filter((slot) => slot.content.trim().length > 0) // Skip empty slots
|
|
191
|
+
.sort((a, b) => a.priority - b.priority)
|
|
192
|
+
.map((slot) => `[${slot.label}]\n${slot.content}`)
|
|
193
|
+
.join("\n\n");
|
|
194
|
+
prompt = contextContent
|
|
195
|
+
? `${taskDescription}\n\n--- Context ---\n${contextContent}`
|
|
196
|
+
: taskDescription;
|
|
197
|
+
}
|
|
198
|
+
const timeoutMs = task.estimated_duration
|
|
199
|
+
? this.durationToMs(task.estimated_duration)
|
|
200
|
+
: 30 * 60 * 1000; // default 30 minutes
|
|
201
|
+
const agentTask = {
|
|
202
|
+
prompt,
|
|
203
|
+
timeout_ms: timeoutMs,
|
|
204
|
+
adapter_type: adapter.adapterType,
|
|
205
|
+
};
|
|
206
|
+
// Update task status to running
|
|
207
|
+
const runningTask = { ...task, status: "running", started_at: new Date().toISOString() };
|
|
208
|
+
this.stateManager.writeRaw(`tasks/${task.goal_id}/${task.id}.json`, runningTask);
|
|
209
|
+
// Execute
|
|
210
|
+
let result;
|
|
211
|
+
try {
|
|
212
|
+
// Generic dedup check — any adapter may optionally implement checkDuplicate
|
|
213
|
+
if ('checkDuplicate' in adapter && typeof adapter.checkDuplicate === 'function') {
|
|
214
|
+
try {
|
|
215
|
+
const isDuplicate = await adapter.checkDuplicate(agentTask);
|
|
216
|
+
if (isDuplicate) {
|
|
217
|
+
// Return synthetic result — task already exists, skip execution
|
|
218
|
+
result = {
|
|
219
|
+
success: true,
|
|
220
|
+
output: 'Skipped: duplicate task detected by adapter',
|
|
221
|
+
error: null,
|
|
222
|
+
exit_code: 0,
|
|
223
|
+
elapsed_ms: 0,
|
|
224
|
+
stopped_reason: 'completed',
|
|
225
|
+
};
|
|
226
|
+
// End session and update task status without calling adapter.execute
|
|
227
|
+
const skipSummary = 'Task skipped: duplicate detected by adapter';
|
|
228
|
+
this.sessionManager.endSession(session.id, skipSummary);
|
|
229
|
+
const skipNow = new Date().toISOString();
|
|
230
|
+
const skippedTask = { ...runningTask, status: 'completed', completed_at: skipNow };
|
|
231
|
+
this.stateManager.writeRaw(`tasks/${task.goal_id}/${task.id}.json`, skippedTask);
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch { /* non-fatal: proceed with execution if dedup check fails */ }
|
|
236
|
+
}
|
|
237
|
+
result = await adapter.execute(agentTask);
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
result = {
|
|
241
|
+
success: false,
|
|
242
|
+
output: "",
|
|
243
|
+
error: err instanceof Error ? err.message : String(err),
|
|
244
|
+
exit_code: null,
|
|
245
|
+
elapsed_ms: 0,
|
|
246
|
+
stopped_reason: "error",
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// Post-execution: check whether any files were actually modified via git diff --stat.
|
|
250
|
+
// This is a diagnostic annotation only — it does NOT fail the task.
|
|
251
|
+
if (result.success) {
|
|
252
|
+
try {
|
|
253
|
+
const diffStat = this.execFileSyncFn("git", ["diff", "--stat"], {
|
|
254
|
+
cwd: process.cwd(),
|
|
255
|
+
encoding: "utf-8",
|
|
256
|
+
});
|
|
257
|
+
result.filesChanged = diffStat.trim().length > 0;
|
|
258
|
+
if (!result.filesChanged) {
|
|
259
|
+
if (DEBUG) {
|
|
260
|
+
console.warn("[TaskLifecycle] Adapter reported success but no files were modified");
|
|
261
|
+
}
|
|
262
|
+
this.logger?.warn("[TaskLifecycle] Adapter reported success but no files were modified", { taskId: task.id });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// Not a git repo or git is unavailable — skip the check silently
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// End session
|
|
270
|
+
const summary = result.success
|
|
271
|
+
? `Task completed successfully. Output length: ${result.output.length}`
|
|
272
|
+
: `Task failed: ${result.stopped_reason}. Error: ${result.error ?? "unknown"}`;
|
|
273
|
+
this.sessionManager.endSession(session.id, summary);
|
|
274
|
+
// Update task status based on result
|
|
275
|
+
const now = new Date().toISOString();
|
|
276
|
+
let newStatus;
|
|
277
|
+
if (result.stopped_reason === "timeout") {
|
|
278
|
+
newStatus = "timed_out";
|
|
279
|
+
}
|
|
280
|
+
else if (result.stopped_reason === "error" || !result.success) {
|
|
281
|
+
newStatus = "error";
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
newStatus = "completed";
|
|
285
|
+
}
|
|
286
|
+
const updatedTask = {
|
|
287
|
+
...runningTask,
|
|
288
|
+
status: newStatus,
|
|
289
|
+
completed_at: now,
|
|
290
|
+
...(newStatus === "timed_out" ? { timeout_at: now } : {}),
|
|
291
|
+
};
|
|
292
|
+
this.stateManager.writeRaw(`tasks/${task.goal_id}/${task.id}.json`, updatedTask);
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
// ─── verifyTask ───
|
|
296
|
+
/**
|
|
297
|
+
* Verify task execution results using 3-layer verification.
|
|
298
|
+
*
|
|
299
|
+
* Layer 1: Mechanical verification (via adapter in review session)
|
|
300
|
+
* Layer 2: LLM task reviewer (independent, no self-report)
|
|
301
|
+
* Layer 3: Executor self-report (reference only)
|
|
302
|
+
*
|
|
303
|
+
* Contradiction resolution:
|
|
304
|
+
* - L1 PASS + L2 PASS → pass
|
|
305
|
+
* - L1 PASS + L2 FAIL → re-review; if still FAIL → fail
|
|
306
|
+
* - L1 FAIL + L2 PASS → fail (mechanical priority)
|
|
307
|
+
* - L1 FAIL + L2 FAIL → fail
|
|
308
|
+
* - L1 SKIP → use L2 only (lower confidence)
|
|
309
|
+
*/
|
|
310
|
+
async verifyTask(task, executionResult) {
|
|
311
|
+
// ─── Short-circuit: GitHub issue URL evidence ───
|
|
312
|
+
// When execution succeeded and output contains a GitHub issue URL,
|
|
313
|
+
// treat as mechanical pass without running full L1/L2 verification.
|
|
314
|
+
// Dimension updates are left to ObservationEngine (next loop iteration).
|
|
315
|
+
const githubIssueUrlPattern = /github\.com\/.+\/issues\/\d+/;
|
|
316
|
+
if (executionResult.success === true &&
|
|
317
|
+
executionResult.output &&
|
|
318
|
+
githubIssueUrlPattern.test(executionResult.output)) {
|
|
319
|
+
const scResult = VerificationResultSchema.parse({
|
|
320
|
+
task_id: task.id,
|
|
321
|
+
verdict: "pass",
|
|
322
|
+
confidence: 0.95,
|
|
323
|
+
evidence: [
|
|
324
|
+
{
|
|
325
|
+
layer: "mechanical",
|
|
326
|
+
description: "GitHub issue URL found in execution output — mechanical evidence of successful issue creation",
|
|
327
|
+
confidence: 0.95,
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
dimension_updates: [],
|
|
331
|
+
timestamp: new Date().toISOString(),
|
|
332
|
+
});
|
|
333
|
+
return scResult;
|
|
334
|
+
}
|
|
335
|
+
// ─── Layer 1: Mechanical verification ───
|
|
336
|
+
const l1Result = await this.runMechanicalVerification(task);
|
|
337
|
+
// ─── Layer 2: LLM task reviewer (independent) ───
|
|
338
|
+
const l2Result = await this.runLLMReview(task, executionResult);
|
|
339
|
+
// ─── Layer 3: Executor self-report (reference only) ───
|
|
340
|
+
const executorReport = this.parseExecutorReport(executionResult);
|
|
341
|
+
// ─── Contradiction resolution ───
|
|
342
|
+
let verdict;
|
|
343
|
+
let confidence;
|
|
344
|
+
let l2Retry;
|
|
345
|
+
if (l1Result.applicable) {
|
|
346
|
+
if (l1Result.passed && l2Result.passed) {
|
|
347
|
+
verdict = "pass";
|
|
348
|
+
confidence = 0.9;
|
|
349
|
+
}
|
|
350
|
+
else if (l1Result.passed && l2Result.partial) {
|
|
351
|
+
// L1 pass + L2 partial → partial
|
|
352
|
+
verdict = "partial";
|
|
353
|
+
confidence = 0.7;
|
|
354
|
+
}
|
|
355
|
+
else if (l1Result.passed && !l2Result.passed && !l2Result.partial) {
|
|
356
|
+
// L1 pass + L2 fail → re-review
|
|
357
|
+
l2Retry = await this.runLLMReview(task, executionResult);
|
|
358
|
+
if (l2Retry.passed) {
|
|
359
|
+
verdict = "pass";
|
|
360
|
+
confidence = 0.75;
|
|
361
|
+
}
|
|
362
|
+
else if (l2Retry.partial) {
|
|
363
|
+
verdict = "partial";
|
|
364
|
+
confidence = 0.65;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
verdict = "fail";
|
|
368
|
+
confidence = 0.8;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else if (!l1Result.passed && l2Result.passed) {
|
|
372
|
+
// Mechanical verification takes priority
|
|
373
|
+
verdict = "fail";
|
|
374
|
+
confidence = 0.85;
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
// Both fail (or L1 fail + L2 partial → fail, mechanical priority)
|
|
378
|
+
verdict = "fail";
|
|
379
|
+
confidence = 0.9;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
// L1 skipped — use L2 only with lower confidence
|
|
384
|
+
if (l2Result.passed) {
|
|
385
|
+
verdict = "pass";
|
|
386
|
+
confidence = 0.6;
|
|
387
|
+
}
|
|
388
|
+
else if (l2Result.partial) {
|
|
389
|
+
verdict = "partial";
|
|
390
|
+
confidence = 0.5;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
verdict = "fail";
|
|
394
|
+
confidence = 0.6;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// Handle partial from L2 when L1 is applicable but didn't fail
|
|
398
|
+
if (l1Result.applicable && l2Result.partial && verdict !== "fail") {
|
|
399
|
+
verdict = "partial";
|
|
400
|
+
}
|
|
401
|
+
// Use retry result for evidence when a retry occurred, to keep audit trail accurate
|
|
402
|
+
const effectiveL2 = l2Retry ?? l2Result;
|
|
403
|
+
const now = new Date().toISOString();
|
|
404
|
+
const evidence = [
|
|
405
|
+
...(l1Result.applicable
|
|
406
|
+
? [
|
|
407
|
+
{
|
|
408
|
+
layer: "mechanical",
|
|
409
|
+
description: l1Result.description,
|
|
410
|
+
confidence: l1Result.passed ? 0.9 : 0.9,
|
|
411
|
+
},
|
|
412
|
+
]
|
|
413
|
+
: []),
|
|
414
|
+
{
|
|
415
|
+
layer: "independent_review",
|
|
416
|
+
description: effectiveL2.description,
|
|
417
|
+
confidence: effectiveL2.confidence,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
layer: "self_report",
|
|
421
|
+
description: executorReport.summary,
|
|
422
|
+
confidence: 0.3, // self-report has lowest confidence
|
|
423
|
+
},
|
|
424
|
+
];
|
|
425
|
+
// Build dimension_updates from task's target dimensions based on verdict.
|
|
426
|
+
// pass: significant progress (+0.2), partial: moderate progress (+0.15), fail: no update.
|
|
427
|
+
const progressByVerdict = {
|
|
428
|
+
pass: 0.2,
|
|
429
|
+
partial: 0.15,
|
|
430
|
+
fail: 0,
|
|
431
|
+
};
|
|
432
|
+
const progressDelta = progressByVerdict[verdict] ?? 0;
|
|
433
|
+
// Read goal state to get actual current dimension values for previous_value / new_value.
|
|
434
|
+
const goalDataForUpdate = this.stateManager.readRaw(`goals/${task.goal_id}/goal.json`);
|
|
435
|
+
const goalDimsForUpdate = goalDataForUpdate && typeof goalDataForUpdate === "object"
|
|
436
|
+
? goalDataForUpdate.dimensions
|
|
437
|
+
: undefined;
|
|
438
|
+
const dimension_updates = verdict === "fail"
|
|
439
|
+
? []
|
|
440
|
+
: task.target_dimensions.map((dimName) => {
|
|
441
|
+
const dim = goalDimsForUpdate?.find((d) => d.name === dimName);
|
|
442
|
+
const prevVal = dim !== undefined && typeof dim.current_value === "number"
|
|
443
|
+
? dim.current_value
|
|
444
|
+
: null;
|
|
445
|
+
const newVal = prevVal !== null
|
|
446
|
+
? Math.min(1, Math.max(0, prevVal + progressDelta))
|
|
447
|
+
: progressDelta;
|
|
448
|
+
return {
|
|
449
|
+
dimension_name: dimName,
|
|
450
|
+
previous_value: prevVal,
|
|
451
|
+
new_value: newVal,
|
|
452
|
+
confidence,
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
const verificationResult = VerificationResultSchema.parse({
|
|
456
|
+
task_id: task.id,
|
|
457
|
+
verdict,
|
|
458
|
+
confidence,
|
|
459
|
+
evidence,
|
|
460
|
+
dimension_updates,
|
|
461
|
+
timestamp: now,
|
|
462
|
+
});
|
|
463
|
+
// Persist verification result
|
|
464
|
+
this.stateManager.writeRaw(`verification/${task.id}/verification-result.json`, verificationResult);
|
|
465
|
+
return verificationResult;
|
|
466
|
+
}
|
|
467
|
+
// ─── handleVerdict ───
|
|
468
|
+
/**
|
|
469
|
+
* Handle a verification verdict (pass/partial/fail).
|
|
470
|
+
*/
|
|
471
|
+
async handleVerdict(task, verificationResult) {
|
|
472
|
+
switch (verificationResult.verdict) {
|
|
473
|
+
case "pass": {
|
|
474
|
+
// Record success
|
|
475
|
+
this.trustManager.recordSuccess(task.task_category);
|
|
476
|
+
const now = new Date().toISOString();
|
|
477
|
+
// Reset consecutive failure count
|
|
478
|
+
const completedTask = {
|
|
479
|
+
...task,
|
|
480
|
+
consecutive_failure_count: 0,
|
|
481
|
+
status: "completed",
|
|
482
|
+
completed_at: now,
|
|
483
|
+
};
|
|
484
|
+
this.stateManager.writeRaw(`tasks/${task.goal_id}/${task.id}.json`, completedTask);
|
|
485
|
+
// Apply dimension_updates and update last_updated for the primary dimension.
|
|
486
|
+
const goalData = this.stateManager.readRaw(`goals/${task.goal_id}/goal.json`);
|
|
487
|
+
if (goalData && typeof goalData === "object") {
|
|
488
|
+
const goal = goalData;
|
|
489
|
+
const dimensions = goal.dimensions;
|
|
490
|
+
if (dimensions) {
|
|
491
|
+
for (const dim of dimensions) {
|
|
492
|
+
// Apply current_value updates from verification result
|
|
493
|
+
const update = verificationResult.dimension_updates.find((u) => u.dimension_name === dim.name);
|
|
494
|
+
if (update !== undefined && typeof update.new_value === "number") {
|
|
495
|
+
dim.current_value = update.new_value;
|
|
496
|
+
}
|
|
497
|
+
// Update last_updated for the primary dimension
|
|
498
|
+
if (dim.name === task.primary_dimension) {
|
|
499
|
+
dim.last_updated = now;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
this.stateManager.writeRaw(`goals/${task.goal_id}/goal.json`, goal);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
// Update task history
|
|
506
|
+
this.appendTaskHistory(task.goal_id, completedTask);
|
|
507
|
+
// Notify portfolio manager of task completion
|
|
508
|
+
if (this.onTaskComplete && completedTask.strategy_id) {
|
|
509
|
+
this.onTaskComplete(completedTask.strategy_id);
|
|
510
|
+
}
|
|
511
|
+
return { action: "completed", task: completedTask };
|
|
512
|
+
}
|
|
513
|
+
case "partial": {
|
|
514
|
+
// Check direction from evidence
|
|
515
|
+
const directionCorrect = this.isDirectionCorrect(verificationResult);
|
|
516
|
+
if (directionCorrect) {
|
|
517
|
+
// Apply partial dimension_updates to goal state
|
|
518
|
+
const goalDataPartial = this.stateManager.readRaw(`goals/${task.goal_id}/goal.json`);
|
|
519
|
+
if (goalDataPartial && typeof goalDataPartial === "object") {
|
|
520
|
+
const goal = goalDataPartial;
|
|
521
|
+
const dimensions = goal.dimensions;
|
|
522
|
+
if (dimensions) {
|
|
523
|
+
for (const dim of dimensions) {
|
|
524
|
+
const update = verificationResult.dimension_updates.find((u) => u.dimension_name === dim.name);
|
|
525
|
+
if (update !== undefined && typeof update.new_value === "number") {
|
|
526
|
+
dim.current_value = update.new_value;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
this.stateManager.writeRaw(`goals/${task.goal_id}/goal.json`, goal);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
this.appendTaskHistory(task.goal_id, task);
|
|
533
|
+
return { action: "keep", task };
|
|
534
|
+
}
|
|
535
|
+
// Direction wrong — delegate to handleFailure
|
|
536
|
+
return this.handleFailure(task, verificationResult);
|
|
537
|
+
}
|
|
538
|
+
case "fail": {
|
|
539
|
+
return this.handleFailure(task, verificationResult);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
// ─── handleFailure ───
|
|
544
|
+
/**
|
|
545
|
+
* Handle a task failure: increment failure count, record failure,
|
|
546
|
+
* decide keep/discard/escalate.
|
|
547
|
+
*/
|
|
548
|
+
async handleFailure(task, verificationResult) {
|
|
549
|
+
// Increment consecutive_failure_count
|
|
550
|
+
const updatedTask = {
|
|
551
|
+
...task,
|
|
552
|
+
consecutive_failure_count: task.consecutive_failure_count + 1,
|
|
553
|
+
};
|
|
554
|
+
// Record failure with TrustManager
|
|
555
|
+
this.trustManager.recordFailure(task.task_category);
|
|
556
|
+
// Persist updated task
|
|
557
|
+
this.stateManager.writeRaw(`tasks/${task.goal_id}/${task.id}.json`, updatedTask);
|
|
558
|
+
// Check escalation threshold
|
|
559
|
+
if (updatedTask.consecutive_failure_count >= 3) {
|
|
560
|
+
this.stallDetector.checkConsecutiveFailures(task.goal_id, task.primary_dimension, updatedTask.consecutive_failure_count);
|
|
561
|
+
this.appendTaskHistory(task.goal_id, updatedTask);
|
|
562
|
+
return { action: "escalate", task: updatedTask };
|
|
563
|
+
}
|
|
564
|
+
// Direction check
|
|
565
|
+
const directionCorrect = this.isDirectionCorrect(verificationResult);
|
|
566
|
+
if (directionCorrect) {
|
|
567
|
+
this.appendTaskHistory(task.goal_id, updatedTask);
|
|
568
|
+
return { action: "keep", task: updatedTask };
|
|
569
|
+
}
|
|
570
|
+
// Direction wrong
|
|
571
|
+
if (updatedTask.reversibility === "reversible") {
|
|
572
|
+
// Attempt revert
|
|
573
|
+
const revertSuccess = await this.attemptRevert(updatedTask);
|
|
574
|
+
if (revertSuccess) {
|
|
575
|
+
this.appendTaskHistory(task.goal_id, updatedTask);
|
|
576
|
+
return { action: "discard", task: updatedTask };
|
|
577
|
+
}
|
|
578
|
+
// Revert failed — set state_integrity to "uncertain" and escalate
|
|
579
|
+
this.setDimensionIntegrity(task.goal_id, task.primary_dimension, "uncertain");
|
|
580
|
+
this.appendTaskHistory(task.goal_id, updatedTask);
|
|
581
|
+
return { action: "escalate", task: updatedTask };
|
|
582
|
+
}
|
|
583
|
+
// irreversible or unknown → escalate
|
|
584
|
+
this.appendTaskHistory(task.goal_id, updatedTask);
|
|
585
|
+
return { action: "escalate", task: updatedTask };
|
|
586
|
+
}
|
|
587
|
+
// ─── runTaskCycle ───
|
|
588
|
+
/**
|
|
589
|
+
* Run a full task cycle: select → generate → approve → execute → verify → verdict.
|
|
590
|
+
*/
|
|
591
|
+
async runTaskCycle(goalId, gapVector, driveContext, adapter, knowledgeContext, existingTasks, workspaceContext) {
|
|
592
|
+
// 1. Select target dimension
|
|
593
|
+
const targetDimension = this.selectTargetDimension(gapVector, driveContext);
|
|
594
|
+
// 2. Generate task (optionally with injected knowledge context)
|
|
595
|
+
const task = await this.generateTask(goalId, targetDimension, undefined, knowledgeContext, adapter.adapterType, existingTasks, workspaceContext);
|
|
596
|
+
// 3a. Ethics means check (reject → skip, flag → require approval, pass → proceed)
|
|
597
|
+
if (this.ethicsGate) {
|
|
598
|
+
const ethicsVerdict = await this.ethicsGate.checkMeans(task.id, task.work_description, task.approach);
|
|
599
|
+
if (ethicsVerdict.verdict === "reject") {
|
|
600
|
+
const rejectedResult = VerificationResultSchema.parse({
|
|
601
|
+
task_id: task.id,
|
|
602
|
+
verdict: "fail",
|
|
603
|
+
confidence: 1.0,
|
|
604
|
+
evidence: [
|
|
605
|
+
{
|
|
606
|
+
layer: "mechanical",
|
|
607
|
+
description: `Ethics gate rejected task: ${ethicsVerdict.reasoning}`,
|
|
608
|
+
confidence: 1.0,
|
|
609
|
+
},
|
|
610
|
+
],
|
|
611
|
+
dimension_updates: [],
|
|
612
|
+
timestamp: new Date().toISOString(),
|
|
613
|
+
});
|
|
614
|
+
return { task, verificationResult: rejectedResult, action: "discard" };
|
|
615
|
+
}
|
|
616
|
+
if (ethicsVerdict.verdict === "flag") {
|
|
617
|
+
// Treat flag as requiring human approval via the existing approvalFn
|
|
618
|
+
const approved = await this.approvalFn(task);
|
|
619
|
+
if (!approved) {
|
|
620
|
+
const flagDeniedResult = VerificationResultSchema.parse({
|
|
621
|
+
task_id: task.id,
|
|
622
|
+
verdict: "fail",
|
|
623
|
+
confidence: 1.0,
|
|
624
|
+
evidence: [
|
|
625
|
+
{
|
|
626
|
+
layer: "mechanical",
|
|
627
|
+
description: `Ethics flag: approval denied. Reasoning: ${ethicsVerdict.reasoning}`,
|
|
628
|
+
confidence: 1.0,
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
dimension_updates: [],
|
|
632
|
+
timestamp: new Date().toISOString(),
|
|
633
|
+
});
|
|
634
|
+
return { task, verificationResult: flagDeniedResult, action: "approval_denied" };
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
// verdict === "pass" → fall through
|
|
638
|
+
}
|
|
639
|
+
// 3b. Capability check
|
|
640
|
+
// Skip for capability_acquisition tasks to prevent infinite delegation loops.
|
|
641
|
+
if (this.capabilityDetector && task.task_category !== "capability_acquisition") {
|
|
642
|
+
const gap = await this.capabilityDetector.detectDeficiency(task);
|
|
643
|
+
if (gap !== null) {
|
|
644
|
+
const capabilityResult = VerificationResultSchema.parse({
|
|
645
|
+
task_id: task.id,
|
|
646
|
+
verdict: "fail",
|
|
647
|
+
confidence: 1.0,
|
|
648
|
+
evidence: [
|
|
649
|
+
{
|
|
650
|
+
layer: "mechanical",
|
|
651
|
+
description: `Capability deficiency: ${gap.missing_capability.name} — ${gap.reason}`,
|
|
652
|
+
confidence: 1.0,
|
|
653
|
+
},
|
|
654
|
+
],
|
|
655
|
+
dimension_updates: [],
|
|
656
|
+
timestamp: new Date().toISOString(),
|
|
657
|
+
});
|
|
658
|
+
// Determine acquisition method. Permissions always require human approval.
|
|
659
|
+
const acquisitionTask = this.capabilityDetector.planAcquisition(gap);
|
|
660
|
+
if (acquisitionTask.method === "permission_request") {
|
|
661
|
+
// Permissions cannot be autonomously acquired — escalate to human.
|
|
662
|
+
return { task, verificationResult: capabilityResult, action: "escalate" };
|
|
663
|
+
}
|
|
664
|
+
// For tool_creation and service_setup: mark as acquiring and delegate.
|
|
665
|
+
await this.capabilityDetector.setCapabilityStatus(gap.missing_capability.name, gap.missing_capability.type, "acquiring");
|
|
666
|
+
return {
|
|
667
|
+
action: "capability_acquiring",
|
|
668
|
+
task,
|
|
669
|
+
verificationResult: capabilityResult,
|
|
670
|
+
acquisition_task: acquisitionTask,
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// 3c. Check irreversible approval
|
|
675
|
+
const approved = await this.checkIrreversibleApproval(task);
|
|
676
|
+
if (!approved) {
|
|
677
|
+
// Build a minimal verification result for the cycle result
|
|
678
|
+
const deniedResult = VerificationResultSchema.parse({
|
|
679
|
+
task_id: task.id,
|
|
680
|
+
verdict: "fail",
|
|
681
|
+
confidence: 1.0,
|
|
682
|
+
evidence: [
|
|
683
|
+
{
|
|
684
|
+
layer: "mechanical",
|
|
685
|
+
description: "Approval denied by human",
|
|
686
|
+
confidence: 1.0,
|
|
687
|
+
},
|
|
688
|
+
],
|
|
689
|
+
dimension_updates: [],
|
|
690
|
+
timestamp: new Date().toISOString(),
|
|
691
|
+
});
|
|
692
|
+
return {
|
|
693
|
+
task,
|
|
694
|
+
verificationResult: deniedResult,
|
|
695
|
+
action: "approval_denied",
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
// 4. Execute task
|
|
699
|
+
if (DEBUG)
|
|
700
|
+
console.log(`[DEBUG-TL] Executing task ${task.id} via adapter ${adapter.adapterType}`);
|
|
701
|
+
const executionResult = await this.executeTask(task, adapter);
|
|
702
|
+
if (DEBUG)
|
|
703
|
+
console.log(`[DEBUG-TL] Execution result: success=${executionResult.success}, stopped=${executionResult.stopped_reason}, error=${executionResult.error}, output=${executionResult.output?.substring(0, 200)}`);
|
|
704
|
+
// 4b. Post-execution health check (opt-in)
|
|
705
|
+
if (executionResult.success && this.healthCheckEnabled) {
|
|
706
|
+
const healthCheck = await this.runPostExecutionHealthCheck(adapter, task);
|
|
707
|
+
if (!healthCheck.healthy) {
|
|
708
|
+
console.warn(`[TaskLifecycle] Post-execution health check FAILED: ${healthCheck.output}`);
|
|
709
|
+
executionResult.success = false;
|
|
710
|
+
executionResult.output = (executionResult.output || "") +
|
|
711
|
+
`\n\n[Health Check Failed]\n${healthCheck.output}`;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
// Reload task from disk to get accurate status/started_at/completed_at set by executeTask
|
|
715
|
+
let taskForVerification = task;
|
|
716
|
+
try {
|
|
717
|
+
const raw = this.stateManager.readRaw(`tasks/${task.goal_id}/${task.id}.json`);
|
|
718
|
+
if (raw)
|
|
719
|
+
taskForVerification = TaskSchema.parse(raw);
|
|
720
|
+
}
|
|
721
|
+
catch { /* fall back to in-memory task */ }
|
|
722
|
+
// 5. Verify task
|
|
723
|
+
const verificationResult = await this.verifyTask(taskForVerification, executionResult);
|
|
724
|
+
if (DEBUG)
|
|
725
|
+
console.log(`[DEBUG-TL] Verification: verdict=${verificationResult.verdict}, evidence=${verificationResult.evidence.map(e => e.description).join('; ').substring(0, 300)}`);
|
|
726
|
+
// 6. Handle verdict
|
|
727
|
+
const verdictResult = await this.handleVerdict(taskForVerification, verificationResult);
|
|
728
|
+
return {
|
|
729
|
+
task: verdictResult.task,
|
|
730
|
+
verificationResult,
|
|
731
|
+
action: verdictResult.action,
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
// ─── Private Helpers ───
|
|
735
|
+
buildTaskGenerationPrompt(goalId, targetDimension, knowledgeContext, adapterType, existingTasks, workspaceContext) {
|
|
736
|
+
// Load goal context to enrich the prompt
|
|
737
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
738
|
+
const dim = goal?.dimensions.find((d) => d.name === targetDimension);
|
|
739
|
+
// Build goal context section
|
|
740
|
+
let goalSection;
|
|
741
|
+
if (goal) {
|
|
742
|
+
const titleLine = `Goal: ${goal.title}`;
|
|
743
|
+
const descLine = goal.description ? `Description: ${goal.description}` : "";
|
|
744
|
+
goalSection = [titleLine, descLine].filter(Boolean).join("\n");
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
goalSection = `Goal ID: ${goalId}`;
|
|
748
|
+
}
|
|
749
|
+
// Build dimension context section
|
|
750
|
+
let dimensionSection;
|
|
751
|
+
if (dim) {
|
|
752
|
+
const currentVal = dim.current_value !== null && dim.current_value !== undefined
|
|
753
|
+
? String(dim.current_value)
|
|
754
|
+
: "unknown";
|
|
755
|
+
const threshold = dim.threshold;
|
|
756
|
+
let targetDesc;
|
|
757
|
+
if (threshold.type === "min") {
|
|
758
|
+
targetDesc = `at least ${threshold.value}`;
|
|
759
|
+
}
|
|
760
|
+
else if (threshold.type === "max") {
|
|
761
|
+
targetDesc = `at most ${threshold.value}`;
|
|
762
|
+
}
|
|
763
|
+
else if (threshold.type === "range") {
|
|
764
|
+
targetDesc = `between ${threshold.low} and ${threshold.high}`;
|
|
765
|
+
}
|
|
766
|
+
else if (threshold.type === "present") {
|
|
767
|
+
targetDesc = "present (non-null)";
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
targetDesc = `equal to ${threshold.value}`;
|
|
771
|
+
}
|
|
772
|
+
const gapDesc = (() => {
|
|
773
|
+
if (threshold.type === "min") {
|
|
774
|
+
const val = typeof dim.current_value === "number" ? dim.current_value : null;
|
|
775
|
+
if (val !== null)
|
|
776
|
+
return `${threshold.value - val} below minimum`;
|
|
777
|
+
return "current value unknown";
|
|
778
|
+
}
|
|
779
|
+
else if (threshold.type === "max") {
|
|
780
|
+
const val = typeof dim.current_value === "number" ? dim.current_value : null;
|
|
781
|
+
if (val !== null)
|
|
782
|
+
return `${val - threshold.value} above maximum`;
|
|
783
|
+
return "current value unknown";
|
|
784
|
+
}
|
|
785
|
+
else if (threshold.type === "present") {
|
|
786
|
+
return dim.current_value == null ? "value is absent (needs to be set)" : "value is present";
|
|
787
|
+
}
|
|
788
|
+
return "gap exists";
|
|
789
|
+
})();
|
|
790
|
+
dimensionSection = `Dimension to improve: "${targetDimension}" (label: ${dim.label})
|
|
791
|
+
|
|
792
|
+
Gap Analysis:
|
|
793
|
+
- Current value: ${currentVal}
|
|
794
|
+
- Target threshold: ${targetDesc}
|
|
795
|
+
- Gap: ${gapDesc}`;
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
dimensionSection = `Dimension to improve: "${targetDimension}"`;
|
|
799
|
+
}
|
|
800
|
+
// Build adapter context section
|
|
801
|
+
let adapterSection = "";
|
|
802
|
+
if (adapterType === "github_issue") {
|
|
803
|
+
adapterSection = `\nExecution context: This task will be executed via GitHub issue creation.\nIMPORTANT: The work_description should contain the issue title on the first line, followed by the issue body. Generate a SPECIFIC, actionable issue — not a vague review task.\n`;
|
|
804
|
+
}
|
|
805
|
+
else if (adapterType === "openai_codex_cli" || adapterType === "claude_code_cli") {
|
|
806
|
+
adapterSection = `\nExecution context: This task will be executed via the "${adapterType}" adapter (a CLI-based code agent).
|
|
807
|
+
IMPORTANT constraints for success_criteria:
|
|
808
|
+
- The agent runs in a sandbox and CANNOT perform git commit, git push, or merge operations.
|
|
809
|
+
- Success criteria MUST focus on file creation/modification only (e.g., "file X exists with content Y").
|
|
810
|
+
- Do NOT include "merged into repository", "committed", or "pushed" as success criteria.
|
|
811
|
+
- The verification_method should check file existence or content (e.g., "test -f README.md").\n`;
|
|
812
|
+
}
|
|
813
|
+
else if (adapterType) {
|
|
814
|
+
adapterSection = `\nExecution context: This task will be executed via the "${adapterType}" adapter.\n`;
|
|
815
|
+
}
|
|
816
|
+
const knowledgeSection = knowledgeContext
|
|
817
|
+
? `\nRelevant domain knowledge:\n${knowledgeContext}\n`
|
|
818
|
+
: "";
|
|
819
|
+
// Read package.json for project identity (best-effort, no throw)
|
|
820
|
+
let projectName = "";
|
|
821
|
+
let projectDescription = "";
|
|
822
|
+
try {
|
|
823
|
+
const pkgPath = _path.join(process.cwd(), "package.json");
|
|
824
|
+
if (_fs.existsSync(pkgPath)) {
|
|
825
|
+
const pkg = JSON.parse(_fs.readFileSync(pkgPath, "utf-8"));
|
|
826
|
+
projectName = pkg.name ?? "";
|
|
827
|
+
projectDescription = pkg.description ?? "";
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
catch {
|
|
831
|
+
// silently ignore — repo context is best-effort
|
|
832
|
+
}
|
|
833
|
+
const repoContextParts = [];
|
|
834
|
+
if (projectName)
|
|
835
|
+
repoContextParts.push(`Project name: ${projectName}`);
|
|
836
|
+
if (projectDescription)
|
|
837
|
+
repoContextParts.push(`Project description: ${projectDescription}`);
|
|
838
|
+
const repoSection = repoContextParts.length > 0
|
|
839
|
+
? `\nRepository context:\n${repoContextParts.join("\n")}\n`
|
|
840
|
+
: "";
|
|
841
|
+
const existingTasksSection = existingTasks && existingTasks.length > 0
|
|
842
|
+
? `\n=== Previously Generated Tasks (avoid duplication) ===\n${existingTasks.join("\n")}\nGenerate a task that addresses a DIFFERENT aspect of the goal than the existing tasks above.\n`
|
|
843
|
+
: "";
|
|
844
|
+
const workspaceSection = workspaceContext
|
|
845
|
+
? `\n=== Current Workspace State ===\n${workspaceContext}\n`
|
|
846
|
+
: "\n=== Current Workspace State ===\nNo workspace context available.\n";
|
|
847
|
+
return `${goalSection}
|
|
848
|
+
${dimensionSection}
|
|
849
|
+
${repoSection}${adapterSection}${knowledgeSection}${workspaceSection}${existingTasksSection}
|
|
850
|
+
IMPORTANT: Generate a task that is SPECIFIC to the actual project described above (goal title, description, and repository context). Do NOT suggest generic software improvements (e.g., user authentication, social media login, unrelated features) unless they are explicitly mentioned in the goal description. Base the task entirely on what the goal and project are actually about.
|
|
851
|
+
|
|
852
|
+
Generate ONE specific, concrete, actionable task that will directly improve the "${targetDimension}" dimension toward its target. The task should produce a single measurable output achievable in a single work session. Do not generate vague review or triage tasks — generate a task with a precise, well-defined deliverable.
|
|
853
|
+
|
|
854
|
+
IMPORTANT: The task's work_description MUST include:
|
|
855
|
+
1. Target file path(s) to modify or create
|
|
856
|
+
2. Specific changes (not "improve X" but "add section Y to file Z")
|
|
857
|
+
3. Completion criteria that can be verified
|
|
858
|
+
|
|
859
|
+
Return a JSON object with the following schema:
|
|
860
|
+
{
|
|
861
|
+
"work_description": "string — what to do",
|
|
862
|
+
"rationale": "string — why this task matters",
|
|
863
|
+
"approach": "string — how to accomplish it",
|
|
864
|
+
"success_criteria": [
|
|
865
|
+
{
|
|
866
|
+
"description": "string — what success looks like",
|
|
867
|
+
"verification_method": "string — how to verify",
|
|
868
|
+
"is_blocking": true
|
|
869
|
+
}
|
|
870
|
+
],
|
|
871
|
+
"scope_boundary": {
|
|
872
|
+
"in_scope": ["string — what is included"],
|
|
873
|
+
"out_of_scope": ["string — what is excluded"],
|
|
874
|
+
"blast_radius": "string — what could be affected"
|
|
875
|
+
},
|
|
876
|
+
"constraints": ["string — any constraints"],
|
|
877
|
+
"reversibility": "reversible" | "irreversible" | "unknown",
|
|
878
|
+
"estimated_duration": { "value": number, "unit": "minutes" | "hours" | "days" | "weeks" } | null
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
Respond with only the JSON object inside a markdown code block.`;
|
|
882
|
+
}
|
|
883
|
+
// ─── Verification Helpers ───
|
|
884
|
+
async runMechanicalVerification(task) {
|
|
885
|
+
// Mechanical prefixes that indicate a command can be run directly
|
|
886
|
+
const mechanicalPrefixes = ["npm", "npx", "pytest", "sh", "bash", "node", "make", "cargo", "go ", "gh "];
|
|
887
|
+
// Find the first success criterion with a mechanically-verifiable verification_method
|
|
888
|
+
const mechanicalCriterion = task.success_criteria.find((c) => {
|
|
889
|
+
const method = c.verification_method.toLowerCase().trim();
|
|
890
|
+
return mechanicalPrefixes.some((prefix) => method.startsWith(prefix));
|
|
891
|
+
});
|
|
892
|
+
if (!mechanicalCriterion) {
|
|
893
|
+
return {
|
|
894
|
+
applicable: false,
|
|
895
|
+
passed: false,
|
|
896
|
+
description: "No mechanical verification criteria applicable",
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
// If no adapter registry is available, fall back to assumed pass (backward compat)
|
|
900
|
+
if (!this.adapterRegistry) {
|
|
901
|
+
return {
|
|
902
|
+
applicable: true,
|
|
903
|
+
passed: true,
|
|
904
|
+
description: "Mechanical verification criteria detected (no adapter: assumed pass)",
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
// Select the first available adapter from the registry for command execution
|
|
908
|
+
const availableAdapters = this.adapterRegistry.listAdapters();
|
|
909
|
+
if (availableAdapters.length === 0) {
|
|
910
|
+
return {
|
|
911
|
+
applicable: true,
|
|
912
|
+
passed: true,
|
|
913
|
+
description: "Mechanical verification criteria detected (no adapters registered: assumed pass)",
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
const adapterType = availableAdapters[0];
|
|
917
|
+
let adapter;
|
|
918
|
+
try {
|
|
919
|
+
adapter = this.adapterRegistry.getAdapter(adapterType);
|
|
920
|
+
}
|
|
921
|
+
catch {
|
|
922
|
+
return {
|
|
923
|
+
applicable: true,
|
|
924
|
+
passed: true,
|
|
925
|
+
description: "Mechanical verification criteria detected (adapter lookup failed: assumed pass)",
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
// Execute the verification command via the adapter
|
|
929
|
+
const verificationCommand = mechanicalCriterion.verification_method.trim();
|
|
930
|
+
const verificationTimeoutMs = 30_000; // 30 seconds default for L1 mechanical checks
|
|
931
|
+
const agentTask = {
|
|
932
|
+
prompt: verificationCommand,
|
|
933
|
+
timeout_ms: verificationTimeoutMs,
|
|
934
|
+
adapter_type: adapterType,
|
|
935
|
+
};
|
|
936
|
+
let result;
|
|
937
|
+
try {
|
|
938
|
+
result = await adapter.execute(agentTask);
|
|
939
|
+
}
|
|
940
|
+
catch (err) {
|
|
941
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
942
|
+
this.logger?.error("runMechanicalVerification: adapter.execute() threw", { error: errMsg });
|
|
943
|
+
return {
|
|
944
|
+
applicable: true,
|
|
945
|
+
passed: false,
|
|
946
|
+
description: `Mechanical verification command threw: ${errMsg}`,
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
if (result.stopped_reason === "timeout") {
|
|
950
|
+
return {
|
|
951
|
+
applicable: true,
|
|
952
|
+
passed: false,
|
|
953
|
+
description: `Mechanical verification timed out after ${verificationTimeoutMs}ms (command: ${verificationCommand})`,
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
const passed = result.exit_code === 0 && result.success;
|
|
957
|
+
const description = passed
|
|
958
|
+
? `Mechanical verification passed (exit 0): ${verificationCommand}`
|
|
959
|
+
: `Mechanical verification failed (exit ${result.exit_code ?? "null"}): ${verificationCommand}${result.error ? ` — ${result.error}` : ""}`;
|
|
960
|
+
return { applicable: true, passed, description };
|
|
961
|
+
}
|
|
962
|
+
async runLLMReview(task, executionResult) {
|
|
963
|
+
// Create review session
|
|
964
|
+
const reviewSession = this.sessionManager.createSession("task_review", task.goal_id, task.id);
|
|
965
|
+
// Build review context (excludes executor self-report for bias prevention)
|
|
966
|
+
const reviewContext = this.sessionManager.buildTaskReviewContext(task.goal_id, task.id);
|
|
967
|
+
const criteriaList = task.success_criteria
|
|
968
|
+
.map((c, i) => `${i + 1}. ${c.description} (blocking: ${c.is_blocking}, method: ${c.verification_method})`)
|
|
969
|
+
.join("\n");
|
|
970
|
+
const prompt = `Evaluate this task execution result against the success criteria.
|
|
971
|
+
|
|
972
|
+
Task: ${task.work_description}
|
|
973
|
+
Approach: ${task.approach}
|
|
974
|
+
|
|
975
|
+
Success Criteria:
|
|
976
|
+
${criteriaList}
|
|
977
|
+
|
|
978
|
+
Execution Output (first 2000 chars):
|
|
979
|
+
${executionResult.output.slice(0, 2000)}
|
|
980
|
+
|
|
981
|
+
Execution Status: ${executionResult.stopped_reason}
|
|
982
|
+
Execution Success: ${executionResult.success}
|
|
983
|
+
|
|
984
|
+
Context: ${reviewContext.map((s) => s.content).join(" ")}
|
|
985
|
+
|
|
986
|
+
Evaluate whether the task output satisfies the success criteria. Respond with JSON:
|
|
987
|
+
{"verdict": "pass" | "partial" | "fail", "reasoning": "explanation", "criteria_met": number, "criteria_total": number}`;
|
|
988
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], {
|
|
989
|
+
system: "You are an independent task reviewer. Evaluate task results objectively against success criteria. Do NOT consider the executor's self-assessment.",
|
|
990
|
+
max_tokens: 1024,
|
|
991
|
+
});
|
|
992
|
+
try {
|
|
993
|
+
const parsed = JSON.parse(response.content.replace(/```json\n?/g, "").replace(/```/g, "").trim());
|
|
994
|
+
const verdictStr = parsed.verdict ?? "fail";
|
|
995
|
+
const result = {
|
|
996
|
+
passed: verdictStr === "pass",
|
|
997
|
+
partial: verdictStr === "partial",
|
|
998
|
+
description: parsed.reasoning ?? "LLM review completed",
|
|
999
|
+
confidence: verdictStr === "pass" ? 0.8 : verdictStr === "partial" ? 0.6 : 0.8,
|
|
1000
|
+
};
|
|
1001
|
+
this.sessionManager.endSession(reviewSession.id, `LLM review: ${verdictStr}`);
|
|
1002
|
+
return result;
|
|
1003
|
+
}
|
|
1004
|
+
catch {
|
|
1005
|
+
this.sessionManager.endSession(reviewSession.id, "Failed to parse LLM review result");
|
|
1006
|
+
return {
|
|
1007
|
+
passed: false,
|
|
1008
|
+
partial: false,
|
|
1009
|
+
description: "Failed to parse LLM review result",
|
|
1010
|
+
confidence: 0.3,
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
parseExecutorReport(executionResult) {
|
|
1015
|
+
// Parse executor's output for self-assessment (reference only)
|
|
1016
|
+
return {
|
|
1017
|
+
completed: executionResult.success,
|
|
1018
|
+
summary: executionResult.output.slice(0, 500),
|
|
1019
|
+
partial_results: [],
|
|
1020
|
+
blockers: executionResult.error ? [executionResult.error] : [],
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
isDirectionCorrect(verificationResult) {
|
|
1024
|
+
// Direction is correct when the verdict is "partial" (some criteria met)
|
|
1025
|
+
// Direction is wrong when the verdict is "fail" (no criteria met / wrong approach)
|
|
1026
|
+
return verificationResult.verdict === "partial";
|
|
1027
|
+
}
|
|
1028
|
+
async attemptRevert(task) {
|
|
1029
|
+
// Attempt to revert a task's changes
|
|
1030
|
+
// In MVP, we create a revert prompt and check if it succeeds
|
|
1031
|
+
// This is called only for reversible tasks
|
|
1032
|
+
try {
|
|
1033
|
+
const revertSession = this.sessionManager.createSession("task_execution", task.goal_id, task.id);
|
|
1034
|
+
const revertPrompt = `Revert the changes made by task "${task.work_description}". Undo all modifications within scope: ${task.scope_boundary.in_scope.join(", ")}.
|
|
1035
|
+
|
|
1036
|
+
After completing the revert, respond with a JSON object:
|
|
1037
|
+
{"success": true/false, "reason": "explanation of what was done or why it failed"}`;
|
|
1038
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: revertPrompt }], { system: "You are reverting a failed task. Undo all changes. Respond with JSON: {\"success\": boolean, \"reason\": string}", max_tokens: 512 });
|
|
1039
|
+
this.sessionManager.endSession(revertSession.id, response.content);
|
|
1040
|
+
// Parse structured JSON response
|
|
1041
|
+
try {
|
|
1042
|
+
const parsed = this.llmClient.parseJSON(response.content, z.object({ success: z.boolean(), reason: z.string() }));
|
|
1043
|
+
return parsed.success;
|
|
1044
|
+
}
|
|
1045
|
+
catch {
|
|
1046
|
+
// If parse fails, assume revert failed
|
|
1047
|
+
return false;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
catch {
|
|
1051
|
+
return false;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
setDimensionIntegrity(goalId, dimensionName, integrity) {
|
|
1055
|
+
// Attempt to update the dimension's state_integrity flag
|
|
1056
|
+
// Read the goal, find the dimension, update integrity
|
|
1057
|
+
const goalData = this.stateManager.readRaw(`goals/${goalId}/goal.json`);
|
|
1058
|
+
if (goalData && typeof goalData === "object") {
|
|
1059
|
+
const goal = goalData;
|
|
1060
|
+
const dimensions = goal.dimensions;
|
|
1061
|
+
if (dimensions) {
|
|
1062
|
+
for (const dim of dimensions) {
|
|
1063
|
+
if (dim.name === dimensionName) {
|
|
1064
|
+
dim.state_integrity = integrity;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
this.stateManager.writeRaw(`goals/${goalId}/goal.json`, goal);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
appendTaskHistory(goalId, task) {
|
|
1072
|
+
const historyPath = `tasks/${goalId}/task-history.json`;
|
|
1073
|
+
const existing = this.stateManager.readRaw(historyPath);
|
|
1074
|
+
const history = Array.isArray(existing) ? existing : [];
|
|
1075
|
+
const actual_elapsed_ms = task.started_at && task.completed_at
|
|
1076
|
+
? new Date(task.completed_at).getTime() - new Date(task.started_at).getTime()
|
|
1077
|
+
: null;
|
|
1078
|
+
const estimated_duration_ms = task.estimated_duration
|
|
1079
|
+
? this.durationToMs(task.estimated_duration)
|
|
1080
|
+
: null;
|
|
1081
|
+
history.push({
|
|
1082
|
+
task_id: task.id,
|
|
1083
|
+
status: task.status,
|
|
1084
|
+
primary_dimension: task.primary_dimension,
|
|
1085
|
+
consecutive_failure_count: task.consecutive_failure_count,
|
|
1086
|
+
completed_at: task.completed_at ?? new Date().toISOString(),
|
|
1087
|
+
actual_elapsed_ms,
|
|
1088
|
+
estimated_duration_ms,
|
|
1089
|
+
});
|
|
1090
|
+
this.stateManager.writeRaw(historyPath, history);
|
|
1091
|
+
}
|
|
1092
|
+
durationToMs(duration) {
|
|
1093
|
+
const multipliers = {
|
|
1094
|
+
minutes: 60 * 1000,
|
|
1095
|
+
hours: 60 * 60 * 1000,
|
|
1096
|
+
days: 24 * 60 * 60 * 1000,
|
|
1097
|
+
weeks: 7 * 24 * 60 * 60 * 1000,
|
|
1098
|
+
};
|
|
1099
|
+
return duration.value * (multipliers[duration.unit] ?? 60 * 60 * 1000);
|
|
1100
|
+
}
|
|
1101
|
+
// ─── Post-Execution Health Check ───
|
|
1102
|
+
/**
|
|
1103
|
+
* Run build and test checks after successful task execution to verify
|
|
1104
|
+
* the codebase remains healthy. Opt-in via healthCheckEnabled constructor option.
|
|
1105
|
+
*/
|
|
1106
|
+
async runPostExecutionHealthCheck(_adapter, _task) {
|
|
1107
|
+
// Run build check
|
|
1108
|
+
try {
|
|
1109
|
+
const buildResult = await this.runShellCommand(["npm", "run", "build"], {
|
|
1110
|
+
timeout: 60000,
|
|
1111
|
+
cwd: process.cwd(),
|
|
1112
|
+
});
|
|
1113
|
+
if (!buildResult.success) {
|
|
1114
|
+
return {
|
|
1115
|
+
healthy: false,
|
|
1116
|
+
output: `Build failed: ${buildResult.stderr || buildResult.stdout}`,
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
catch (err) {
|
|
1121
|
+
return { healthy: false, output: `Build check error: ${err}` };
|
|
1122
|
+
}
|
|
1123
|
+
// Run quick test check (just verify tests still pass)
|
|
1124
|
+
try {
|
|
1125
|
+
const testResult = await this.runShellCommand(["npx", "vitest", "run", "--reporter=dot"], { timeout: 120000, cwd: process.cwd() });
|
|
1126
|
+
if (!testResult.success) {
|
|
1127
|
+
return {
|
|
1128
|
+
healthy: false,
|
|
1129
|
+
output: `Tests failed: ${testResult.stderr || testResult.stdout}`,
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
catch (err) {
|
|
1134
|
+
return { healthy: false, output: `Test check error: ${err}` };
|
|
1135
|
+
}
|
|
1136
|
+
return { healthy: true, output: "Build and tests passed" };
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Run a shell command safely using execFile (not exec) to avoid shell injection.
|
|
1140
|
+
*/
|
|
1141
|
+
async runShellCommand(argv, options) {
|
|
1142
|
+
const { execFile } = await import("child_process");
|
|
1143
|
+
const { promisify } = await import("util");
|
|
1144
|
+
const execFileAsync = promisify(execFile);
|
|
1145
|
+
try {
|
|
1146
|
+
const { stdout, stderr } = await execFileAsync(argv[0], argv.slice(1), {
|
|
1147
|
+
timeout: options.timeout,
|
|
1148
|
+
cwd: options.cwd,
|
|
1149
|
+
});
|
|
1150
|
+
return { success: true, stdout, stderr };
|
|
1151
|
+
}
|
|
1152
|
+
catch (err) {
|
|
1153
|
+
if (typeof err === "object" && err !== null && "stdout" in err) {
|
|
1154
|
+
const e = err;
|
|
1155
|
+
return { success: false, stdout: e.stdout || "", stderr: e.stderr || "" };
|
|
1156
|
+
}
|
|
1157
|
+
return { success: false, stdout: "", stderr: String(err) };
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
//# sourceMappingURL=task-lifecycle.js.map
|