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,954 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GoalSchema } from "./types/goal.js";
|
|
4
|
+
import { ConcretenessScoreSchema, DecompositionQualityMetricsSchema } from "./types/goal-tree.js";
|
|
5
|
+
// ─── LLM Response Schemas ───
|
|
6
|
+
const SpecificityResponseSchema = z.object({
|
|
7
|
+
specificity_score: z.number().min(0).max(1),
|
|
8
|
+
reasoning: z.string(),
|
|
9
|
+
});
|
|
10
|
+
const SubgoalItemSchema = z.object({
|
|
11
|
+
hypothesis: z.string(),
|
|
12
|
+
dimensions: z
|
|
13
|
+
.array(z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
label: z.string(),
|
|
16
|
+
threshold_type: z.enum(["min", "max", "range", "present", "match"]),
|
|
17
|
+
threshold_value: z.union([z.number(), z.string(), z.boolean(), z.null()]).nullable(),
|
|
18
|
+
observation_method_hint: z.string().optional().default(""),
|
|
19
|
+
}))
|
|
20
|
+
.default([]),
|
|
21
|
+
constraints: z.array(z.string()).default([]),
|
|
22
|
+
expected_specificity: z.number().min(0).max(1).optional(),
|
|
23
|
+
});
|
|
24
|
+
const SubgoalsResponseSchema = z.array(SubgoalItemSchema);
|
|
25
|
+
const CoverageResponseSchema = z.object({
|
|
26
|
+
covers_parent: z.boolean(),
|
|
27
|
+
missing_dimensions: z.array(z.string()).default([]),
|
|
28
|
+
reasoning: z.string(),
|
|
29
|
+
});
|
|
30
|
+
const RestructureSuggestionSchema = z.object({
|
|
31
|
+
action: z.enum(["move", "merge", "split", "reorder"]),
|
|
32
|
+
goal_ids: z.array(z.string()),
|
|
33
|
+
reasoning: z.string(),
|
|
34
|
+
});
|
|
35
|
+
const RestructureResponseSchema = z.array(RestructureSuggestionSchema);
|
|
36
|
+
const ConcretenessLLMResponseSchema = z.object({
|
|
37
|
+
hasQuantitativeThreshold: z.boolean(),
|
|
38
|
+
hasObservableOutcome: z.boolean(),
|
|
39
|
+
hasTimebound: z.boolean(),
|
|
40
|
+
hasClearScope: z.boolean(),
|
|
41
|
+
reason: z.string(),
|
|
42
|
+
});
|
|
43
|
+
const QualityEvaluationResponseSchema = z.object({
|
|
44
|
+
coverage: z.number().min(0).max(1),
|
|
45
|
+
overlap: z.number().min(0).max(1),
|
|
46
|
+
actionability: z.number().min(0).max(1),
|
|
47
|
+
reasoning: z.string(),
|
|
48
|
+
});
|
|
49
|
+
// ─── Prompt Builders ───
|
|
50
|
+
function buildSpecificityPrompt(goal) {
|
|
51
|
+
const dimNames = goal.dimensions.map((d) => d.name).join(", ");
|
|
52
|
+
const constraintLines = goal.constraints.length > 0
|
|
53
|
+
? `\nConstraints: ${goal.constraints.join(", ")}`
|
|
54
|
+
: "";
|
|
55
|
+
return `Evaluate the specificity of this goal. A high specificity score (>= 0.7) means the goal is already a single, atomic task with no meaningful sub-components that could be worked on independently. A low score (< 0.7) means it has multiple distinct aspects that should be broken down into separate subgoals.
|
|
56
|
+
|
|
57
|
+
Goal title: ${goal.title}
|
|
58
|
+
Goal description: ${goal.description}
|
|
59
|
+
Dimensions: ${dimNames || "(none defined)"}${constraintLines}
|
|
60
|
+
Current decomposition depth: ${goal.decomposition_depth}
|
|
61
|
+
|
|
62
|
+
Output JSON:
|
|
63
|
+
{
|
|
64
|
+
"specificity_score": <number 0.0 to 1.0>,
|
|
65
|
+
"reasoning": "<brief explanation>"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Return ONLY the JSON object, no other text.`;
|
|
69
|
+
}
|
|
70
|
+
function buildSubgoalPrompt(goal, depth, maxDepth, maxChildren) {
|
|
71
|
+
const constraintLines = goal.constraints.length > 0
|
|
72
|
+
? `Constraints:\n${goal.constraints.map((c) => `- ${c}`).join("\n")}`
|
|
73
|
+
: "Constraints: none";
|
|
74
|
+
const dimLines = goal.dimensions.length > 0
|
|
75
|
+
? `Existing dimensions:\n${goal.dimensions.map((d) => `- ${d.name}: ${d.label}`).join("\n")}`
|
|
76
|
+
: "Existing dimensions: none";
|
|
77
|
+
return `Decompose this goal into ${maxChildren} or fewer concrete subgoals. Each subgoal should address a distinct aspect of the parent goal and be more specific.
|
|
78
|
+
|
|
79
|
+
Parent goal: ${goal.title}
|
|
80
|
+
Description: ${goal.description}
|
|
81
|
+
${dimLines}
|
|
82
|
+
${constraintLines}
|
|
83
|
+
Current depth: ${depth} (max allowed depth: ${maxDepth})
|
|
84
|
+
Remaining decomposition levels: ${maxDepth - depth}
|
|
85
|
+
|
|
86
|
+
For each subgoal, provide:
|
|
87
|
+
- hypothesis: what this subgoal achieves (1-2 sentences)
|
|
88
|
+
- dimensions: array of measurable dimensions with fields:
|
|
89
|
+
- name: string (snake_case identifier)
|
|
90
|
+
- label: string (human-readable)
|
|
91
|
+
- threshold_type: MUST be one of "min" | "max" | "range" | "present" | "match" (no other values allowed)
|
|
92
|
+
- threshold_value: number or string or boolean or null
|
|
93
|
+
- observation_method_hint: string (optional)
|
|
94
|
+
- constraints: array of constraints specific to this subgoal
|
|
95
|
+
- expected_specificity: estimated specificity score after decomposition (0.0-1.0)
|
|
96
|
+
|
|
97
|
+
Output JSON array of subgoal objects. Maximum ${maxChildren} items.
|
|
98
|
+
Return ONLY a JSON array, no other text.`;
|
|
99
|
+
}
|
|
100
|
+
function buildCoveragePrompt(parent, children) {
|
|
101
|
+
const parentDims = parent.dimensions.map((d) => d.name).join(", ");
|
|
102
|
+
const childSummaries = children
|
|
103
|
+
.map((c, i) => ` ${i + 1}. "${c.title}": dimensions=[${c.dimensions.map((d) => d.name).join(", ")}]`)
|
|
104
|
+
.join("\n");
|
|
105
|
+
return `Do these subgoals collectively cover all dimensions of the parent goal?
|
|
106
|
+
|
|
107
|
+
Parent goal: ${parent.title}
|
|
108
|
+
Parent dimensions: ${parentDims || "(none)"}
|
|
109
|
+
|
|
110
|
+
Subgoals:
|
|
111
|
+
${childSummaries}
|
|
112
|
+
|
|
113
|
+
Output JSON:
|
|
114
|
+
{
|
|
115
|
+
"covers_parent": <true|false>,
|
|
116
|
+
"missing_dimensions": ["<dim1>", ...],
|
|
117
|
+
"reasoning": "<brief explanation>"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Return ONLY the JSON object, no other text.`;
|
|
121
|
+
}
|
|
122
|
+
function buildConcretenessPrompt(description) {
|
|
123
|
+
return `Evaluate the concreteness of this goal description on four dimensions.
|
|
124
|
+
|
|
125
|
+
Goal description: "${description}"
|
|
126
|
+
|
|
127
|
+
Answer each question:
|
|
128
|
+
1. hasQuantitativeThreshold: Does the goal specify quantitative/measurable success criteria or thresholds? (e.g., "achieve 80% coverage", "response time < 200ms")
|
|
129
|
+
2. hasObservableOutcome: Does the goal describe an observable, verifiable outcome? (e.g., "a working API endpoint", "passing CI build")
|
|
130
|
+
3. hasTimebound: Does the goal have a time constraint or deadline? (e.g., "by end of sprint", "within 2 weeks")
|
|
131
|
+
4. hasClearScope: Does the goal have a clearly defined scope with no ambiguity about what is included or excluded?
|
|
132
|
+
|
|
133
|
+
Output JSON:
|
|
134
|
+
{
|
|
135
|
+
"hasQuantitativeThreshold": <true|false>,
|
|
136
|
+
"hasObservableOutcome": <true|false>,
|
|
137
|
+
"hasTimebound": <true|false>,
|
|
138
|
+
"hasClearScope": <true|false>,
|
|
139
|
+
"reason": "<brief explanation covering all four dimensions>"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Return ONLY the JSON object, no other text.`;
|
|
143
|
+
}
|
|
144
|
+
function buildQualityEvaluationPrompt(parentDescription, subgoalDescriptions) {
|
|
145
|
+
const subgoalList = subgoalDescriptions
|
|
146
|
+
.map((desc, i) => ` ${i + 1}. "${desc}"`)
|
|
147
|
+
.join("\n");
|
|
148
|
+
return `Evaluate the quality of this goal decomposition.
|
|
149
|
+
|
|
150
|
+
Parent goal: "${parentDescription}"
|
|
151
|
+
|
|
152
|
+
Subgoals:
|
|
153
|
+
${subgoalList}
|
|
154
|
+
|
|
155
|
+
Evaluate:
|
|
156
|
+
1. coverage (0.0-1.0): How well do the subgoals collectively cover all aspects of the parent goal? 1.0 = complete coverage, 0.0 = no coverage.
|
|
157
|
+
2. overlap (0.0-1.0): How much redundancy/overlap exists between subgoals? 0.0 = no overlap (ideal), 1.0 = all subgoals are identical.
|
|
158
|
+
3. actionability (0.0-1.0): Average concreteness/actionability of the subgoals. 1.0 = all are immediately actionable, 0.0 = all are too abstract.
|
|
159
|
+
|
|
160
|
+
Output JSON:
|
|
161
|
+
{
|
|
162
|
+
"coverage": <number 0.0 to 1.0>,
|
|
163
|
+
"overlap": <number 0.0 to 1.0>,
|
|
164
|
+
"actionability": <number 0.0 to 1.0>,
|
|
165
|
+
"reasoning": "<brief explanation>"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Return ONLY the JSON object, no other text.`;
|
|
169
|
+
}
|
|
170
|
+
function buildRestructurePrompt(rootId, treeState, goals) {
|
|
171
|
+
const goalSummaries = goals
|
|
172
|
+
.map((g) => ` - id="${g.id}" title="${g.title}" depth=${g.decomposition_depth} status=${g.status}`)
|
|
173
|
+
.join("\n");
|
|
174
|
+
return `Suggest restructuring actions for this goal tree to improve efficiency.
|
|
175
|
+
|
|
176
|
+
Root goal ID: ${rootId}
|
|
177
|
+
Total nodes: ${treeState.total_nodes}
|
|
178
|
+
Max depth reached: ${treeState.max_depth_reached}
|
|
179
|
+
Active loops: ${treeState.active_loops.length}
|
|
180
|
+
Pruned nodes: ${treeState.pruned_nodes.length}
|
|
181
|
+
|
|
182
|
+
Goals in tree:
|
|
183
|
+
${goalSummaries}
|
|
184
|
+
|
|
185
|
+
Suggest restructuring actions. Each action should specify:
|
|
186
|
+
- action: "move" | "merge" | "split" | "reorder"
|
|
187
|
+
- goal_ids: array of goal IDs involved
|
|
188
|
+
- reasoning: why this restructuring would help
|
|
189
|
+
|
|
190
|
+
Output JSON array. Return empty array [] if no restructuring needed.
|
|
191
|
+
Return ONLY a JSON array, no other text.`;
|
|
192
|
+
}
|
|
193
|
+
// ─── Helper: Build a Goal from subgoal spec ───
|
|
194
|
+
function buildGoalFromSubgoalSpec(spec, parentId, parentDepth, now) {
|
|
195
|
+
const id = randomUUID();
|
|
196
|
+
const dims = spec.dimensions.map((d) => ({
|
|
197
|
+
name: d.name,
|
|
198
|
+
label: d.label,
|
|
199
|
+
current_value: null,
|
|
200
|
+
threshold: {
|
|
201
|
+
type: d.threshold_type,
|
|
202
|
+
value: d.threshold_value ?? null,
|
|
203
|
+
},
|
|
204
|
+
confidence: 0.5,
|
|
205
|
+
observation_method: {
|
|
206
|
+
type: "manual",
|
|
207
|
+
source: "decomposition",
|
|
208
|
+
schedule: null,
|
|
209
|
+
endpoint: null,
|
|
210
|
+
confidence_tier: "self_report",
|
|
211
|
+
},
|
|
212
|
+
last_updated: now,
|
|
213
|
+
history: [],
|
|
214
|
+
weight: 1.0,
|
|
215
|
+
uncertainty_weight: null,
|
|
216
|
+
state_integrity: "ok",
|
|
217
|
+
dimension_mapping: null,
|
|
218
|
+
}));
|
|
219
|
+
return GoalSchema.parse({
|
|
220
|
+
id,
|
|
221
|
+
parent_id: parentId,
|
|
222
|
+
node_type: "subgoal",
|
|
223
|
+
title: spec.hypothesis.slice(0, 200),
|
|
224
|
+
description: spec.hypothesis,
|
|
225
|
+
status: "active",
|
|
226
|
+
dimensions: dims,
|
|
227
|
+
gap_aggregation: "max",
|
|
228
|
+
dimension_mapping: null,
|
|
229
|
+
constraints: spec.constraints,
|
|
230
|
+
children_ids: [],
|
|
231
|
+
target_date: null,
|
|
232
|
+
origin: "decomposition",
|
|
233
|
+
pace_snapshot: null,
|
|
234
|
+
deadline: null,
|
|
235
|
+
confidence_flag: null,
|
|
236
|
+
user_override: false,
|
|
237
|
+
feasibility_note: null,
|
|
238
|
+
uncertainty_weight: 1.0,
|
|
239
|
+
decomposition_depth: parentDepth + 1,
|
|
240
|
+
specificity_score: spec.expected_specificity ?? null,
|
|
241
|
+
loop_status: "idle",
|
|
242
|
+
created_at: now,
|
|
243
|
+
updated_at: now,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
export class GoalTreeManager {
|
|
247
|
+
stateManager;
|
|
248
|
+
llmClient;
|
|
249
|
+
ethicsGate;
|
|
250
|
+
goalDependencyGraph;
|
|
251
|
+
goalNegotiator;
|
|
252
|
+
concretenesThreshold;
|
|
253
|
+
maxDepth;
|
|
254
|
+
pruneHistory = new Map();
|
|
255
|
+
constructor(stateManager, llmClient, ethicsGate, goalDependencyGraph, goalNegotiator, options) {
|
|
256
|
+
this.stateManager = stateManager;
|
|
257
|
+
this.llmClient = llmClient;
|
|
258
|
+
this.ethicsGate = ethicsGate;
|
|
259
|
+
this.goalDependencyGraph = goalDependencyGraph;
|
|
260
|
+
this.goalNegotiator = goalNegotiator;
|
|
261
|
+
// null means concreteness auto-stop is disabled (backward compatible)
|
|
262
|
+
this.concretenesThreshold = options?.concretenesThreshold ?? null;
|
|
263
|
+
this.maxDepth = options?.maxDepth ?? 5;
|
|
264
|
+
}
|
|
265
|
+
// ─── Concreteness Scoring ───
|
|
266
|
+
/**
|
|
267
|
+
* Scores the concreteness of a goal description on four dimensions using an LLM.
|
|
268
|
+
* Score = weighted average of 4 boolean dimensions (each 0.25).
|
|
269
|
+
* Falls back to zero score on LLM/parse failures.
|
|
270
|
+
*/
|
|
271
|
+
async scoreConcreteness(description) {
|
|
272
|
+
if (!description || description.trim() === "") {
|
|
273
|
+
return ConcretenessScoreSchema.parse({
|
|
274
|
+
score: 0,
|
|
275
|
+
dimensions: {
|
|
276
|
+
hasQuantitativeThreshold: false,
|
|
277
|
+
hasObservableOutcome: false,
|
|
278
|
+
hasTimebound: false,
|
|
279
|
+
hasClearScope: false,
|
|
280
|
+
},
|
|
281
|
+
reason: "Empty description provided",
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const prompt = buildConcretenessPrompt(description);
|
|
285
|
+
try {
|
|
286
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
287
|
+
const parsed = this.llmClient.parseJSON(response.content, ConcretenessLLMResponseSchema);
|
|
288
|
+
const dims = {
|
|
289
|
+
hasQuantitativeThreshold: parsed.hasQuantitativeThreshold,
|
|
290
|
+
hasObservableOutcome: parsed.hasObservableOutcome,
|
|
291
|
+
hasTimebound: parsed.hasTimebound,
|
|
292
|
+
hasClearScope: parsed.hasClearScope,
|
|
293
|
+
};
|
|
294
|
+
const trueCount = Object.values(dims).filter(Boolean).length;
|
|
295
|
+
const score = trueCount * 0.25;
|
|
296
|
+
return ConcretenessScoreSchema.parse({
|
|
297
|
+
score,
|
|
298
|
+
dimensions: dims,
|
|
299
|
+
reason: parsed.reason,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return ConcretenessScoreSchema.parse({
|
|
304
|
+
score: 0,
|
|
305
|
+
dimensions: {
|
|
306
|
+
hasQuantitativeThreshold: false,
|
|
307
|
+
hasObservableOutcome: false,
|
|
308
|
+
hasTimebound: false,
|
|
309
|
+
hasClearScope: false,
|
|
310
|
+
},
|
|
311
|
+
reason: "LLM evaluation failed, defaulting to zero score",
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// ─── Decomposition Quality ───
|
|
316
|
+
/**
|
|
317
|
+
* Evaluates the quality of a decomposition using an LLM.
|
|
318
|
+
* Measures coverage, overlap, actionability, and computes depthEfficiency.
|
|
319
|
+
* Logs a warning when quality is poor (coverage < 0.5 or overlap > 0.7).
|
|
320
|
+
*/
|
|
321
|
+
async evaluateDecompositionQuality(parentDescription, subgoalDescriptions) {
|
|
322
|
+
if (subgoalDescriptions.length === 0) {
|
|
323
|
+
const metrics = DecompositionQualityMetricsSchema.parse({
|
|
324
|
+
coverage: 0,
|
|
325
|
+
overlap: 0,
|
|
326
|
+
actionability: 0,
|
|
327
|
+
depthEfficiency: 1,
|
|
328
|
+
});
|
|
329
|
+
console.warn("GoalTreeManager.evaluateDecompositionQuality: no subgoals provided — coverage=0");
|
|
330
|
+
return metrics;
|
|
331
|
+
}
|
|
332
|
+
const prompt = buildQualityEvaluationPrompt(parentDescription, subgoalDescriptions);
|
|
333
|
+
let coverage = 0;
|
|
334
|
+
let overlap = 0;
|
|
335
|
+
let actionability = 0;
|
|
336
|
+
try {
|
|
337
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
338
|
+
const parsed = this.llmClient.parseJSON(response.content, QualityEvaluationResponseSchema);
|
|
339
|
+
coverage = parsed.coverage;
|
|
340
|
+
overlap = parsed.overlap;
|
|
341
|
+
actionability = parsed.actionability;
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
// On failure return conservative metrics
|
|
345
|
+
coverage = 0;
|
|
346
|
+
overlap = 0;
|
|
347
|
+
actionability = 0;
|
|
348
|
+
}
|
|
349
|
+
const depthEfficiency = Math.max(0, Math.min(1, 1 - overlap * 0.5));
|
|
350
|
+
const metrics = DecompositionQualityMetricsSchema.parse({
|
|
351
|
+
coverage,
|
|
352
|
+
overlap,
|
|
353
|
+
actionability,
|
|
354
|
+
depthEfficiency,
|
|
355
|
+
});
|
|
356
|
+
if (coverage < 0.5 || overlap > 0.7) {
|
|
357
|
+
console.warn(`GoalTreeManager.evaluateDecompositionQuality: poor quality detected — coverage=${coverage.toFixed(2)}, overlap=${overlap.toFixed(2)}`);
|
|
358
|
+
}
|
|
359
|
+
return metrics;
|
|
360
|
+
}
|
|
361
|
+
// ─── Specificity Evaluation ───
|
|
362
|
+
/**
|
|
363
|
+
* Evaluates the specificity of a goal using an LLM.
|
|
364
|
+
* Returns a score between 0 (very abstract) and 1 (very concrete).
|
|
365
|
+
* Falls back to 0.5 on parse failures.
|
|
366
|
+
*/
|
|
367
|
+
async evaluateSpecificity(goal) {
|
|
368
|
+
const prompt = buildSpecificityPrompt(goal);
|
|
369
|
+
try {
|
|
370
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
371
|
+
const parsed = this.llmClient.parseJSON(response.content, SpecificityResponseSchema);
|
|
372
|
+
return { score: parsed.specificity_score, reasoning: parsed.reasoning };
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
// Conservative fallback: treat as needing decomposition
|
|
376
|
+
return { score: 0.5, reasoning: "LLM evaluation failed, defaulting to 0.5" };
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// ─── Core Decomposition ───
|
|
380
|
+
/**
|
|
381
|
+
* Recursively decomposes a goal into subgoals until each subgoal either:
|
|
382
|
+
* (a) has specificity_score >= config.min_specificity → leaf node
|
|
383
|
+
* (b) has decomposition_depth >= config.max_depth → forced leaf
|
|
384
|
+
* (c) concreteness score >= concretenesThreshold (auto-stop)
|
|
385
|
+
* (d) current depth >= maxDepth (depth guard)
|
|
386
|
+
*
|
|
387
|
+
* Options override instance-level defaults when provided.
|
|
388
|
+
* Returns a DecompositionResult for the top-level call.
|
|
389
|
+
*/
|
|
390
|
+
async decomposeGoal(goalId, config, options) {
|
|
391
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
392
|
+
if (!goal) {
|
|
393
|
+
throw new Error(`GoalTreeManager.decomposeGoal: goal "${goalId}" not found`);
|
|
394
|
+
}
|
|
395
|
+
const effectiveConcretenesThreshold = options?.concretenesThreshold ?? this.concretenesThreshold;
|
|
396
|
+
const effectiveMaxDepth = options?.maxDepth ?? this.maxDepth;
|
|
397
|
+
// Auto-stop: check concreteness before decomposing (only when threshold is explicitly set)
|
|
398
|
+
if (effectiveConcretenesThreshold !== null) {
|
|
399
|
+
const concretenessResult = await this.scoreConcreteness(goal.description);
|
|
400
|
+
if (concretenessResult.score >= effectiveConcretenesThreshold) {
|
|
401
|
+
const now = new Date().toISOString();
|
|
402
|
+
const leafGoal = {
|
|
403
|
+
...goal,
|
|
404
|
+
node_type: "leaf",
|
|
405
|
+
specificity_score: concretenessResult.score,
|
|
406
|
+
updated_at: now,
|
|
407
|
+
};
|
|
408
|
+
this.stateManager.saveGoal(leafGoal);
|
|
409
|
+
return {
|
|
410
|
+
parent_id: goal.id,
|
|
411
|
+
children: [],
|
|
412
|
+
depth: goal.decomposition_depth,
|
|
413
|
+
specificity_scores: { [goal.id]: concretenessResult.score },
|
|
414
|
+
reasoning: `Auto-stop: concreteness score ${concretenessResult.score.toFixed(2)} >= threshold ${effectiveConcretenesThreshold}. ${concretenessResult.reason}`,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return this._decomposeGoalInternal(goal, config, 0, effectiveMaxDepth);
|
|
419
|
+
}
|
|
420
|
+
async _decomposeGoalInternal(goal, config, retryCount, depthLimit) {
|
|
421
|
+
const now = new Date().toISOString();
|
|
422
|
+
const effectiveMaxDepth = depthLimit ?? config.max_depth;
|
|
423
|
+
// Step 1: Evaluate specificity
|
|
424
|
+
const { score: specificityScore, reasoning } = await this.evaluateSpecificity(goal);
|
|
425
|
+
// Update goal with specificity score
|
|
426
|
+
const updatedGoal = {
|
|
427
|
+
...goal,
|
|
428
|
+
specificity_score: specificityScore,
|
|
429
|
+
updated_at: now,
|
|
430
|
+
};
|
|
431
|
+
// Step 2: Determine if this is a leaf node
|
|
432
|
+
const isLeaf = (goal.decomposition_depth > 0 && specificityScore >= config.min_specificity) ||
|
|
433
|
+
goal.decomposition_depth >= effectiveMaxDepth;
|
|
434
|
+
if (isLeaf) {
|
|
435
|
+
// Mark as leaf node
|
|
436
|
+
const leafGoal = {
|
|
437
|
+
...updatedGoal,
|
|
438
|
+
node_type: "leaf",
|
|
439
|
+
updated_at: now,
|
|
440
|
+
};
|
|
441
|
+
this.stateManager.saveGoal(leafGoal);
|
|
442
|
+
return {
|
|
443
|
+
parent_id: goal.id,
|
|
444
|
+
children: [],
|
|
445
|
+
depth: goal.decomposition_depth,
|
|
446
|
+
specificity_scores: { [goal.id]: specificityScore },
|
|
447
|
+
reasoning: specificityScore >= config.min_specificity
|
|
448
|
+
? `Goal is specific enough (score=${specificityScore.toFixed(2)}): ${reasoning}`
|
|
449
|
+
: `Max depth ${effectiveMaxDepth} reached, forced leaf`,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
// Step 3: Generate subgoals via LLM
|
|
453
|
+
const maxChildren = 5;
|
|
454
|
+
const subgoalPrompt = buildSubgoalPrompt(updatedGoal, goal.decomposition_depth, effectiveMaxDepth, maxChildren);
|
|
455
|
+
let subgoalSpecs = [];
|
|
456
|
+
try {
|
|
457
|
+
const subgoalResponse = await this.llmClient.sendMessage([{ role: "user", content: subgoalPrompt }], { temperature: 0 });
|
|
458
|
+
// Sanitize threshold_type values before schema validation —
|
|
459
|
+
// LLMs sometimes return "exact", "scale", "qualitative" etc.
|
|
460
|
+
const THRESHOLD_TYPE_MAP = {
|
|
461
|
+
exact: "match",
|
|
462
|
+
scale: "min",
|
|
463
|
+
qualitative: "min",
|
|
464
|
+
boolean: "present",
|
|
465
|
+
percentage: "min",
|
|
466
|
+
count: "min",
|
|
467
|
+
};
|
|
468
|
+
const VALID_TYPES = new Set(["min", "max", "range", "present", "match"]);
|
|
469
|
+
const rawContent = subgoalResponse.content;
|
|
470
|
+
const sanitized = rawContent.replace(/"threshold_type"\s*:\s*"([^"]+)"/g, (_match, val) => {
|
|
471
|
+
if (VALID_TYPES.has(val))
|
|
472
|
+
return `"threshold_type": "${val}"`;
|
|
473
|
+
const mapped = THRESHOLD_TYPE_MAP[val] ?? "min";
|
|
474
|
+
return `"threshold_type": "${mapped}"`;
|
|
475
|
+
});
|
|
476
|
+
const parsed = this.llmClient.parseJSON(sanitized, SubgoalsResponseSchema);
|
|
477
|
+
subgoalSpecs = parsed.map((sg) => ({
|
|
478
|
+
...sg,
|
|
479
|
+
dimensions: (sg.dimensions ?? []).map((d) => ({
|
|
480
|
+
...d,
|
|
481
|
+
observation_method_hint: d.observation_method_hint ?? "",
|
|
482
|
+
})),
|
|
483
|
+
constraints: sg.constraints ?? [],
|
|
484
|
+
}));
|
|
485
|
+
// Clamp to max_children_per_node
|
|
486
|
+
subgoalSpecs = subgoalSpecs.slice(0, maxChildren);
|
|
487
|
+
}
|
|
488
|
+
catch (err) {
|
|
489
|
+
// If subgoal generation fails, treat as leaf — but log the error for diagnostics
|
|
490
|
+
console.error(`[GoalTreeManager] Subgoal generation failed for "${goal.id}":`, err instanceof Error ? err.message : String(err));
|
|
491
|
+
const leafGoal = {
|
|
492
|
+
...updatedGoal,
|
|
493
|
+
node_type: "leaf",
|
|
494
|
+
updated_at: now,
|
|
495
|
+
};
|
|
496
|
+
this.stateManager.saveGoal(leafGoal);
|
|
497
|
+
return {
|
|
498
|
+
parent_id: goal.id,
|
|
499
|
+
children: [],
|
|
500
|
+
depth: goal.decomposition_depth,
|
|
501
|
+
specificity_scores: { [goal.id]: specificityScore },
|
|
502
|
+
reasoning: `Subgoal generation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
// Handle empty decomposition
|
|
506
|
+
if (subgoalSpecs.length === 0) {
|
|
507
|
+
const leafGoal = {
|
|
508
|
+
...updatedGoal,
|
|
509
|
+
node_type: "leaf",
|
|
510
|
+
updated_at: now,
|
|
511
|
+
};
|
|
512
|
+
this.stateManager.saveGoal(leafGoal);
|
|
513
|
+
return {
|
|
514
|
+
parent_id: goal.id,
|
|
515
|
+
children: [],
|
|
516
|
+
depth: goal.decomposition_depth,
|
|
517
|
+
specificity_scores: { [goal.id]: specificityScore },
|
|
518
|
+
reasoning: "LLM returned empty subgoal list, treating as leaf",
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
// Step 4: Build child Goal objects
|
|
522
|
+
const childGoals = subgoalSpecs.map((spec) => buildGoalFromSubgoalSpec(spec, goal.id, goal.decomposition_depth, now));
|
|
523
|
+
// Step 5: Build the provisional decomposition result for validation
|
|
524
|
+
const provisionalResult = {
|
|
525
|
+
parent_id: goal.id,
|
|
526
|
+
children: childGoals,
|
|
527
|
+
depth: goal.decomposition_depth,
|
|
528
|
+
specificity_scores: { [goal.id]: specificityScore },
|
|
529
|
+
reasoning,
|
|
530
|
+
};
|
|
531
|
+
// Step 6: Validate decomposition (retry up to 2 times)
|
|
532
|
+
const isValid = await this.validateDecomposition(provisionalResult);
|
|
533
|
+
if (!isValid && retryCount < 2) {
|
|
534
|
+
// Retry decomposition
|
|
535
|
+
return this._decomposeGoalInternal(goal, config, retryCount + 1, depthLimit);
|
|
536
|
+
}
|
|
537
|
+
// Step 7: Save parent goal (updated specificity_score, node_type stays as-is for non-leaf)
|
|
538
|
+
this.stateManager.saveGoal(updatedGoal);
|
|
539
|
+
// Step 8: Save each child goal and update parent's children_ids
|
|
540
|
+
const childIds = [];
|
|
541
|
+
for (const child of childGoals) {
|
|
542
|
+
this.stateManager.saveGoal(child);
|
|
543
|
+
childIds.push(child.id);
|
|
544
|
+
// Register parent->child dependency in GoalDependencyGraph
|
|
545
|
+
try {
|
|
546
|
+
this.goalDependencyGraph.addEdge({
|
|
547
|
+
from_goal_id: goal.id,
|
|
548
|
+
to_goal_id: child.id,
|
|
549
|
+
type: "parent_child", // type extended in 14A
|
|
550
|
+
status: "active",
|
|
551
|
+
condition: null,
|
|
552
|
+
affected_dimensions: child.dimensions.map((d) => d.name),
|
|
553
|
+
mitigation: null,
|
|
554
|
+
detection_confidence: 1.0,
|
|
555
|
+
reasoning: `Parent-child relationship from goal decomposition`,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
catch {
|
|
559
|
+
// Dependency graph may not support parent_child type — skip silently
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
// Update parent goal's children_ids
|
|
563
|
+
const parentWithChildren = {
|
|
564
|
+
...updatedGoal,
|
|
565
|
+
children_ids: [...updatedGoal.children_ids, ...childIds],
|
|
566
|
+
updated_at: now,
|
|
567
|
+
};
|
|
568
|
+
this.stateManager.saveGoal(parentWithChildren);
|
|
569
|
+
// Step 9: Collect specificity scores for result
|
|
570
|
+
const specificityScores = {
|
|
571
|
+
[goal.id]: specificityScore,
|
|
572
|
+
};
|
|
573
|
+
// Step 10: Recursively decompose each child
|
|
574
|
+
for (const child of childGoals) {
|
|
575
|
+
const childResult = await this._decomposeGoalInternal(child, config, 0, depthLimit);
|
|
576
|
+
// Merge child specificity scores
|
|
577
|
+
Object.assign(specificityScores, childResult.specificity_scores);
|
|
578
|
+
// Merge children into child's record
|
|
579
|
+
if (childResult.children.length > 0) {
|
|
580
|
+
const reloadedChild = this.stateManager.loadGoal(child.id);
|
|
581
|
+
if (reloadedChild) {
|
|
582
|
+
// child was saved with updated children_ids from recursive call
|
|
583
|
+
void reloadedChild; // already persisted by recursive call
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
parent_id: goal.id,
|
|
589
|
+
children: childGoals,
|
|
590
|
+
depth: goal.decomposition_depth,
|
|
591
|
+
specificity_scores: specificityScores,
|
|
592
|
+
reasoning,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
// ─── Validation ───
|
|
596
|
+
/**
|
|
597
|
+
* Validates a decomposition result by checking:
|
|
598
|
+
* 1. Coverage: subgoals cover all parent dimensions (LLM)
|
|
599
|
+
* 2. Cycle detection: no circular dependencies introduced
|
|
600
|
+
*
|
|
601
|
+
* Returns true only if both checks pass.
|
|
602
|
+
*/
|
|
603
|
+
async validateDecomposition(result) {
|
|
604
|
+
const parent = this.stateManager.loadGoal(result.parent_id);
|
|
605
|
+
if (!parent)
|
|
606
|
+
return false;
|
|
607
|
+
const children = result.children;
|
|
608
|
+
// Check 1: Coverage validation via LLM
|
|
609
|
+
if (children.length > 0) {
|
|
610
|
+
const coveragePrompt = buildCoveragePrompt(parent, children);
|
|
611
|
+
try {
|
|
612
|
+
const coverageResponse = await this.llmClient.sendMessage([{ role: "user", content: coveragePrompt }], { temperature: 0 });
|
|
613
|
+
const coverage = this.llmClient.parseJSON(coverageResponse.content, CoverageResponseSchema);
|
|
614
|
+
if (!coverage.covers_parent) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
catch {
|
|
619
|
+
// On parse failure, allow decomposition to proceed
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
// Check 2: Cycle detection
|
|
623
|
+
for (const child of children) {
|
|
624
|
+
const wouldCycle = this.goalDependencyGraph.detectCycle(result.parent_id, child.id);
|
|
625
|
+
if (wouldCycle) {
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return true;
|
|
630
|
+
}
|
|
631
|
+
// ─── Pruning ───
|
|
632
|
+
/**
|
|
633
|
+
* Prunes a goal and all its descendants by setting status = "cancelled".
|
|
634
|
+
* Removes the goal from its parent's children_ids.
|
|
635
|
+
* Returns a PruneDecision.
|
|
636
|
+
*/
|
|
637
|
+
pruneGoal(goalId, reason) {
|
|
638
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
639
|
+
if (!goal) {
|
|
640
|
+
throw new Error(`GoalTreeManager.pruneGoal: goal "${goalId}" not found`);
|
|
641
|
+
}
|
|
642
|
+
const now = new Date().toISOString();
|
|
643
|
+
// Cancel the goal and all descendants
|
|
644
|
+
this._cancelGoalAndDescendants(goal, now);
|
|
645
|
+
// Remove from parent's children_ids
|
|
646
|
+
if (goal.parent_id) {
|
|
647
|
+
const parent = this.stateManager.loadGoal(goal.parent_id);
|
|
648
|
+
if (parent) {
|
|
649
|
+
const updatedParent = {
|
|
650
|
+
...parent,
|
|
651
|
+
children_ids: parent.children_ids.filter((id) => id !== goalId),
|
|
652
|
+
updated_at: now,
|
|
653
|
+
};
|
|
654
|
+
this.stateManager.saveGoal(updatedParent);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return {
|
|
658
|
+
goal_id: goalId,
|
|
659
|
+
reason,
|
|
660
|
+
replacement_id: null,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Prunes a subgoal with a free-form reason string for tracking.
|
|
665
|
+
* Records a PruneRecord in the history for the parent goal tree.
|
|
666
|
+
* The parentGoalId is the root goal whose history you want to track.
|
|
667
|
+
*/
|
|
668
|
+
pruneSubgoal(subgoalId, reason, parentGoalId) {
|
|
669
|
+
const goal = this.stateManager.loadGoal(subgoalId);
|
|
670
|
+
if (!goal) {
|
|
671
|
+
throw new Error(`GoalTreeManager.pruneSubgoal: goal "${subgoalId}" not found`);
|
|
672
|
+
}
|
|
673
|
+
const now = new Date().toISOString();
|
|
674
|
+
// Cancel the goal and all descendants
|
|
675
|
+
this._cancelGoalAndDescendants(goal, now);
|
|
676
|
+
// Remove from parent's children_ids
|
|
677
|
+
if (goal.parent_id) {
|
|
678
|
+
const parent = this.stateManager.loadGoal(goal.parent_id);
|
|
679
|
+
if (parent) {
|
|
680
|
+
const updatedParent = {
|
|
681
|
+
...parent,
|
|
682
|
+
children_ids: parent.children_ids.filter((id) => id !== subgoalId),
|
|
683
|
+
updated_at: now,
|
|
684
|
+
};
|
|
685
|
+
this.stateManager.saveGoal(updatedParent);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// Record prune history keyed by parentGoalId or the goal's own parent_id
|
|
689
|
+
const trackingKey = parentGoalId ?? goal.parent_id ?? subgoalId;
|
|
690
|
+
const record = { subgoalId, reason, timestamp: now };
|
|
691
|
+
const existing = this.pruneHistory.get(trackingKey) ?? [];
|
|
692
|
+
this.pruneHistory.set(trackingKey, [...existing, record]);
|
|
693
|
+
return {
|
|
694
|
+
goal_id: subgoalId,
|
|
695
|
+
reason: "user_requested",
|
|
696
|
+
replacement_id: null,
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Returns the prune history for a given goal tree root ID.
|
|
701
|
+
* Returns an empty array if no prunes have been recorded.
|
|
702
|
+
*/
|
|
703
|
+
getPruneHistory(goalId) {
|
|
704
|
+
return this.pruneHistory.get(goalId) ?? [];
|
|
705
|
+
}
|
|
706
|
+
_cancelGoalAndDescendants(goal, now) {
|
|
707
|
+
// Recursively cancel all children first
|
|
708
|
+
for (const childId of goal.children_ids) {
|
|
709
|
+
const child = this.stateManager.loadGoal(childId);
|
|
710
|
+
if (child) {
|
|
711
|
+
this._cancelGoalAndDescendants(child, now);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
// Cancel this goal
|
|
715
|
+
const cancelled = {
|
|
716
|
+
...goal,
|
|
717
|
+
status: "cancelled",
|
|
718
|
+
updated_at: now,
|
|
719
|
+
};
|
|
720
|
+
this.stateManager.saveGoal(cancelled);
|
|
721
|
+
}
|
|
722
|
+
// ─── Dynamic Subgoal Addition ───
|
|
723
|
+
/**
|
|
724
|
+
* Adds a new subgoal to a parent goal.
|
|
725
|
+
* - Validates the parent exists
|
|
726
|
+
* - Saves the new goal with parent_id set
|
|
727
|
+
* - Adds child ID to parent's children_ids
|
|
728
|
+
* - Registers the dependency in GoalDependencyGraph
|
|
729
|
+
* Returns the saved goal.
|
|
730
|
+
*/
|
|
731
|
+
addSubgoal(parentId, goal) {
|
|
732
|
+
const parent = this.stateManager.loadGoal(parentId);
|
|
733
|
+
if (!parent) {
|
|
734
|
+
throw new Error(`GoalTreeManager.addSubgoal: parent goal "${parentId}" not found`);
|
|
735
|
+
}
|
|
736
|
+
const now = new Date().toISOString();
|
|
737
|
+
// Ensure parent_id is set on the new goal
|
|
738
|
+
const goalWithParent = GoalSchema.parse({
|
|
739
|
+
...goal,
|
|
740
|
+
parent_id: parentId,
|
|
741
|
+
updated_at: now,
|
|
742
|
+
});
|
|
743
|
+
// Save the new goal
|
|
744
|
+
this.stateManager.saveGoal(goalWithParent);
|
|
745
|
+
// Update parent's children_ids
|
|
746
|
+
const updatedParent = {
|
|
747
|
+
...parent,
|
|
748
|
+
children_ids: [...parent.children_ids, goalWithParent.id],
|
|
749
|
+
updated_at: now,
|
|
750
|
+
};
|
|
751
|
+
this.stateManager.saveGoal(updatedParent);
|
|
752
|
+
// Register dependency
|
|
753
|
+
try {
|
|
754
|
+
this.goalDependencyGraph.addEdge({
|
|
755
|
+
from_goal_id: parentId,
|
|
756
|
+
to_goal_id: goalWithParent.id,
|
|
757
|
+
type: "parent_child",
|
|
758
|
+
status: "active",
|
|
759
|
+
condition: null,
|
|
760
|
+
affected_dimensions: goalWithParent.dimensions.map((d) => d.name),
|
|
761
|
+
mitigation: null,
|
|
762
|
+
detection_confidence: 1.0,
|
|
763
|
+
reasoning: `Parent-child relationship (dynamic subgoal addition)`,
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
catch {
|
|
767
|
+
// Dependency graph may not support parent_child type — skip silently
|
|
768
|
+
}
|
|
769
|
+
return goalWithParent;
|
|
770
|
+
}
|
|
771
|
+
// ─── Tree Restructure ───
|
|
772
|
+
/**
|
|
773
|
+
* Asks an LLM for restructuring suggestions on the current tree rooted at goalId,
|
|
774
|
+
* then applies them. Currently supports identifying merge/move candidates.
|
|
775
|
+
*
|
|
776
|
+
* After restructuring, evaluates quality of the new structure. If quality
|
|
777
|
+
* metrics do not show improvement (overall score degraded), reverts changes
|
|
778
|
+
* by restoring the snapshot taken before restructuring.
|
|
779
|
+
*
|
|
780
|
+
* Returns the quality metrics of the final (kept) structure.
|
|
781
|
+
*/
|
|
782
|
+
async restructureTree(goalId) {
|
|
783
|
+
const allGoalIdsBefore = this._collectAllDescendantIds(goalId);
|
|
784
|
+
allGoalIdsBefore.unshift(goalId);
|
|
785
|
+
const qualityEnabled = this.concretenesThreshold !== null;
|
|
786
|
+
// Snapshot state before restructuring (needed for quality-based revert)
|
|
787
|
+
const snapshot = new Map();
|
|
788
|
+
if (qualityEnabled) {
|
|
789
|
+
for (const id of allGoalIdsBefore) {
|
|
790
|
+
const g = this.stateManager.loadGoal(id);
|
|
791
|
+
if (g)
|
|
792
|
+
snapshot.set(id, g);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
// Evaluate quality before restructuring (only when concreteness feature is enabled)
|
|
796
|
+
const rootGoalBefore = this.stateManager.loadGoal(goalId);
|
|
797
|
+
let qualityBefore = null;
|
|
798
|
+
if (qualityEnabled) {
|
|
799
|
+
const beforeSubgoalDescs = allGoalIdsBefore
|
|
800
|
+
.slice(1)
|
|
801
|
+
.map((id) => snapshot.get(id)?.description ?? "")
|
|
802
|
+
.filter(Boolean);
|
|
803
|
+
qualityBefore =
|
|
804
|
+
beforeSubgoalDescs.length > 0 && rootGoalBefore
|
|
805
|
+
? await this.evaluateDecompositionQuality(rootGoalBefore.description, beforeSubgoalDescs)
|
|
806
|
+
: null;
|
|
807
|
+
}
|
|
808
|
+
const treeState = this.getTreeState(goalId);
|
|
809
|
+
const goals = [];
|
|
810
|
+
for (const id of allGoalIdsBefore) {
|
|
811
|
+
const g = this.stateManager.loadGoal(id);
|
|
812
|
+
if (g)
|
|
813
|
+
goals.push(g);
|
|
814
|
+
}
|
|
815
|
+
const prompt = buildRestructurePrompt(goalId, treeState, goals);
|
|
816
|
+
let restructuringApplied = false;
|
|
817
|
+
try {
|
|
818
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
819
|
+
const suggestions = this.llmClient.parseJSON(response.content, RestructureResponseSchema);
|
|
820
|
+
const now = new Date().toISOString();
|
|
821
|
+
for (const suggestion of suggestions) {
|
|
822
|
+
if (suggestion.action === "merge" && suggestion.goal_ids.length >= 2) {
|
|
823
|
+
// Merge: cancel all but first goal in the list
|
|
824
|
+
const [keepId, ...mergeIds] = suggestion.goal_ids;
|
|
825
|
+
if (keepId) {
|
|
826
|
+
for (const mergeId of mergeIds) {
|
|
827
|
+
const mergeGoal = this.stateManager.loadGoal(mergeId);
|
|
828
|
+
if (mergeGoal && mergeGoal.status !== "cancelled") {
|
|
829
|
+
this._cancelGoalAndDescendants(mergeGoal, now);
|
|
830
|
+
restructuringApplied = true;
|
|
831
|
+
// Remove from parent
|
|
832
|
+
if (mergeGoal.parent_id) {
|
|
833
|
+
const parent = this.stateManager.loadGoal(mergeGoal.parent_id);
|
|
834
|
+
if (parent) {
|
|
835
|
+
const updatedParent = {
|
|
836
|
+
...parent,
|
|
837
|
+
children_ids: parent.children_ids.filter((id) => id !== mergeId),
|
|
838
|
+
updated_at: now,
|
|
839
|
+
};
|
|
840
|
+
this.stateManager.saveGoal(updatedParent);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
// Other actions (move, split, reorder) are logged but not fully automated in MVP
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
catch {
|
|
851
|
+
// Restructure is best-effort; silently ignore errors
|
|
852
|
+
}
|
|
853
|
+
// Quality evaluation after restructuring (only when concreteness feature is enabled)
|
|
854
|
+
if (!qualityEnabled || !restructuringApplied || !rootGoalBefore) {
|
|
855
|
+
// When quality evaluation is not enabled, return undefined
|
|
856
|
+
// to maintain backward compatibility with pre-M7 void return
|
|
857
|
+
return qualityEnabled ? qualityBefore : undefined;
|
|
858
|
+
}
|
|
859
|
+
const allGoalIdsAfter = this._collectAllDescendantIds(goalId);
|
|
860
|
+
allGoalIdsAfter.unshift(goalId);
|
|
861
|
+
const afterSubgoalDescs = allGoalIdsAfter
|
|
862
|
+
.slice(1)
|
|
863
|
+
.map((id) => {
|
|
864
|
+
const g = this.stateManager.loadGoal(id);
|
|
865
|
+
return g?.description ?? "";
|
|
866
|
+
})
|
|
867
|
+
.filter(Boolean);
|
|
868
|
+
const qualityAfter = afterSubgoalDescs.length > 0
|
|
869
|
+
? await this.evaluateDecompositionQuality(rootGoalBefore.description, afterSubgoalDescs)
|
|
870
|
+
: DecompositionQualityMetricsSchema.parse({
|
|
871
|
+
coverage: 0,
|
|
872
|
+
overlap: 0,
|
|
873
|
+
actionability: 0,
|
|
874
|
+
depthEfficiency: 1,
|
|
875
|
+
});
|
|
876
|
+
// Compute an overall score: higher coverage + lower overlap + higher actionability is better
|
|
877
|
+
const scoreBefore = qualityBefore
|
|
878
|
+
? qualityBefore.coverage * 0.4 +
|
|
879
|
+
(1 - qualityBefore.overlap) * 0.3 +
|
|
880
|
+
qualityBefore.actionability * 0.3
|
|
881
|
+
: 0;
|
|
882
|
+
const scoreAfter = qualityAfter.coverage * 0.4 +
|
|
883
|
+
(1 - qualityAfter.overlap) * 0.3 +
|
|
884
|
+
qualityAfter.actionability * 0.3;
|
|
885
|
+
if (scoreAfter < scoreBefore) {
|
|
886
|
+
// Revert: restore all goals from snapshot
|
|
887
|
+
for (const [, savedGoal] of snapshot) {
|
|
888
|
+
this.stateManager.saveGoal(savedGoal);
|
|
889
|
+
}
|
|
890
|
+
return qualityBefore;
|
|
891
|
+
}
|
|
892
|
+
return qualityAfter;
|
|
893
|
+
}
|
|
894
|
+
// ─── Tree State ───
|
|
895
|
+
/**
|
|
896
|
+
* Computes the current GoalTreeState for the tree rooted at rootId.
|
|
897
|
+
* Traverses all descendants recursively.
|
|
898
|
+
*/
|
|
899
|
+
getTreeState(rootId) {
|
|
900
|
+
const root = this.stateManager.loadGoal(rootId);
|
|
901
|
+
if (!root) {
|
|
902
|
+
return {
|
|
903
|
+
root_id: rootId,
|
|
904
|
+
total_nodes: 0,
|
|
905
|
+
max_depth_reached: 0,
|
|
906
|
+
active_loops: [],
|
|
907
|
+
pruned_nodes: [],
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
let totalNodes = 0;
|
|
911
|
+
let maxDepthReached = 0;
|
|
912
|
+
const activeLoops = [];
|
|
913
|
+
const prunedNodes = [];
|
|
914
|
+
const visit = (goal) => {
|
|
915
|
+
totalNodes++;
|
|
916
|
+
if (goal.decomposition_depth > maxDepthReached) {
|
|
917
|
+
maxDepthReached = goal.decomposition_depth;
|
|
918
|
+
}
|
|
919
|
+
if (goal.loop_status === "running") {
|
|
920
|
+
activeLoops.push(goal.id);
|
|
921
|
+
}
|
|
922
|
+
if (goal.status === "cancelled") {
|
|
923
|
+
prunedNodes.push(goal.id);
|
|
924
|
+
}
|
|
925
|
+
for (const childId of goal.children_ids) {
|
|
926
|
+
const child = this.stateManager.loadGoal(childId);
|
|
927
|
+
if (child) {
|
|
928
|
+
visit(child);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
visit(root);
|
|
933
|
+
return {
|
|
934
|
+
root_id: rootId,
|
|
935
|
+
total_nodes: totalNodes,
|
|
936
|
+
max_depth_reached: maxDepthReached,
|
|
937
|
+
active_loops: activeLoops,
|
|
938
|
+
pruned_nodes: prunedNodes,
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
// ─── Private Helpers ───
|
|
942
|
+
_collectAllDescendantIds(goalId) {
|
|
943
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
944
|
+
if (!goal)
|
|
945
|
+
return [];
|
|
946
|
+
const result = [];
|
|
947
|
+
for (const childId of goal.children_ids) {
|
|
948
|
+
result.push(childId);
|
|
949
|
+
result.push(...this._collectAllDescendantIds(childId));
|
|
950
|
+
}
|
|
951
|
+
return result;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
//# sourceMappingURL=goal-tree-manager.js.map
|