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,1044 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GoalSchema } from "./types/goal.js";
|
|
4
|
+
import { DimensionDecompositionSchema, NegotiationLogSchema, FeasibilityResultSchema, CapabilityCheckLogSchema, } from "./types/negotiation.js";
|
|
5
|
+
import { DEFAULT_CHARACTER_CONFIG } from "./types/character.js";
|
|
6
|
+
// ─── Constants ───
|
|
7
|
+
const FEASIBILITY_RATIO_THRESHOLD_REALISTIC = 1.5;
|
|
8
|
+
// FEASIBILITY_RATIO_THRESHOLD_AMBITIOUS is now dynamic — see getFeasibilityThreshold()
|
|
9
|
+
const REALISTIC_TARGET_ACCELERATION_FACTOR = 1.3;
|
|
10
|
+
const DEFAULT_TIME_HORIZON_DAYS = 90;
|
|
11
|
+
// ─── Error class ───
|
|
12
|
+
export class EthicsRejectedError extends Error {
|
|
13
|
+
verdict;
|
|
14
|
+
constructor(verdict) {
|
|
15
|
+
super(`Goal rejected by ethics gate: ${verdict.reasoning}`);
|
|
16
|
+
this.verdict = verdict;
|
|
17
|
+
this.name = "EthicsRejectedError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// ─── Prompts ───
|
|
21
|
+
function buildDecompositionPrompt(description, constraints, availableDataSources) {
|
|
22
|
+
const constraintsSection = constraints.length > 0
|
|
23
|
+
? `\nConstraints:\n${constraints.map((c) => `- ${c}`).join("\n")}`
|
|
24
|
+
: "";
|
|
25
|
+
const dataSourcesSection = availableDataSources && availableDataSources.length > 0
|
|
26
|
+
? `CRITICAL CONSTRAINT: For dimensions that overlap with the available data sources below, you MUST use those exact dimension names so mechanical measurements can be wired automatically. However, you SHOULD ALSO add additional quality-oriented and semantic dimensions that directly reflect the goal description (e.g., readability, correctness, completeness) — do NOT limit yourself to only DataSource dimensions.
|
|
27
|
+
|
|
28
|
+
Available Data Sources and their exact dimension names:
|
|
29
|
+
${availableDataSources.map((ds) => `- "${ds.name}" provides: ${ds.dimensions.join(", ")}`).join("\n")}
|
|
30
|
+
|
|
31
|
+
`
|
|
32
|
+
: "";
|
|
33
|
+
return `${dataSourcesSection}Decompose the following goal into measurable dimensions.
|
|
34
|
+
|
|
35
|
+
Goal: ${description}${constraintsSection}
|
|
36
|
+
|
|
37
|
+
For each dimension, provide:
|
|
38
|
+
- name: a snake_case identifier (use an exact DataSource dimension name if one fits, otherwise use a descriptive custom name)
|
|
39
|
+
- label: human-readable label
|
|
40
|
+
- threshold_type: one of "min", "max", "range", "present", "match"
|
|
41
|
+
- threshold_value: the target value (number, string, or boolean), or null if not yet determined
|
|
42
|
+
- observation_method_hint: how to measure this dimension
|
|
43
|
+
|
|
44
|
+
IMPORTANT — Dimension quality rules:
|
|
45
|
+
1. Do NOT create only "present" type dimensions. Goals about quality, correctness, or completeness MUST have quality-scoring dimensions with "min" type thresholds (0.0-1.0 scale).
|
|
46
|
+
2. "present" type is ONLY appropriate for pure existence checks (e.g., "does the file exist at all?"). If the goal mentions quality, content, correctness, completeness, or any qualitative attribute, use "min" type with a 0.0-1.0 score instead.
|
|
47
|
+
3. For every existence dimension you create, ask: "Does the goal also care about the QUALITY of this thing?" If yes, add a separate quality dimension with "min" type.
|
|
48
|
+
4. Quality dimensions should evaluate specific aspects mentioned in the goal (e.g., correctness of fields, quality of documentation sections, completeness of configuration).
|
|
49
|
+
|
|
50
|
+
Return a JSON array of dimension objects. Example:
|
|
51
|
+
[
|
|
52
|
+
{
|
|
53
|
+
"name": "test_coverage",
|
|
54
|
+
"label": "Test Coverage",
|
|
55
|
+
"threshold_type": "min",
|
|
56
|
+
"threshold_value": 80,
|
|
57
|
+
"observation_method_hint": "Run test suite and check coverage report"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "readme_installation_quality",
|
|
61
|
+
"label": "README Installation Section Quality",
|
|
62
|
+
"threshold_type": "min",
|
|
63
|
+
"threshold_value": 0.7,
|
|
64
|
+
"observation_method_hint": "Evaluate if README has clear installation instructions with code examples, covering npm install, basic setup, and common configurations. Score 0.0-1.0."
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "package_json_exports_valid",
|
|
68
|
+
"label": "package.json exports/main/types Correctness",
|
|
69
|
+
"threshold_type": "min",
|
|
70
|
+
"threshold_value": 0.8,
|
|
71
|
+
"observation_method_hint": "Check that package.json has correct bin, main, exports, and types fields pointing to valid paths. Score 0.0-1.0."
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "license_file_exists",
|
|
75
|
+
"label": "License File Exists",
|
|
76
|
+
"threshold_type": "present",
|
|
77
|
+
"threshold_value": true,
|
|
78
|
+
"observation_method_hint": "Check if LICENSE or LICENSE.md file exists in the project root"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
Return ONLY a JSON array, no other text.`;
|
|
83
|
+
}
|
|
84
|
+
function buildFeasibilityPrompt(dimension, description, baselineValue, thresholdValue, timeHorizonDays) {
|
|
85
|
+
return `Assess the feasibility of achieving this dimension target.
|
|
86
|
+
|
|
87
|
+
Dimension: ${dimension}
|
|
88
|
+
Goal context: ${description}
|
|
89
|
+
Current baseline: ${baselineValue === null ? "unknown" : String(baselineValue)}
|
|
90
|
+
Target value: ${thresholdValue === null ? "not yet determined" : String(thresholdValue)}
|
|
91
|
+
Time horizon: ${timeHorizonDays} days
|
|
92
|
+
|
|
93
|
+
Return a JSON object with:
|
|
94
|
+
{
|
|
95
|
+
"assessment": "realistic" | "ambitious" | "infeasible",
|
|
96
|
+
"confidence": "high" | "medium" | "low",
|
|
97
|
+
"reasoning": "brief explanation",
|
|
98
|
+
"key_assumptions": ["assumption1", ...],
|
|
99
|
+
"main_risks": ["risk1", ...]
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Return ONLY a JSON object, no other text.`;
|
|
103
|
+
}
|
|
104
|
+
function buildResponsePrompt(description, responseType, feasibilityResults, counterProposal) {
|
|
105
|
+
const feasibilitySummary = feasibilityResults
|
|
106
|
+
.map((r) => `- ${r.dimension}: ${r.assessment} (confidence: ${r.confidence})`)
|
|
107
|
+
.join("\n");
|
|
108
|
+
let instruction = "";
|
|
109
|
+
if (responseType === "accept") {
|
|
110
|
+
instruction = "Generate an encouraging acceptance message for the user.";
|
|
111
|
+
}
|
|
112
|
+
else if (responseType === "counter_propose") {
|
|
113
|
+
instruction = `Generate a counter-proposal message. The realistic target is ${counterProposal?.realistic_target}. Reasoning: ${counterProposal?.reasoning}. Suggest this as a safer alternative.`;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
instruction =
|
|
117
|
+
"Generate a message flagging this goal as ambitious. List the risks and suggest the user review carefully.";
|
|
118
|
+
}
|
|
119
|
+
return `Goal: ${description}
|
|
120
|
+
|
|
121
|
+
Feasibility assessment:
|
|
122
|
+
${feasibilitySummary}
|
|
123
|
+
|
|
124
|
+
${instruction}
|
|
125
|
+
|
|
126
|
+
Return a brief, user-facing message (1-3 sentences). Return ONLY the message text, no JSON.`;
|
|
127
|
+
}
|
|
128
|
+
function buildSuggestGoalsPrompt(context, maxSuggestions, existingGoals) {
|
|
129
|
+
const existingGoalsSection = existingGoals.length > 0
|
|
130
|
+
? `\nExisting goals (do NOT suggest duplicates):\n${existingGoals.map((g) => `- ${g}`).join("\n")}`
|
|
131
|
+
: "";
|
|
132
|
+
return `You are a goal advisor for a software project. Given the project context below, suggest concrete, measurable improvement goals.
|
|
133
|
+
|
|
134
|
+
Each goal should:
|
|
135
|
+
1. Be specific and achievable (not vague like "improve code quality")
|
|
136
|
+
2. Have clear success criteria that can be measured
|
|
137
|
+
3. Include 2-4 dimension hints (what to measure)
|
|
138
|
+
4. Be independent of other suggestions
|
|
139
|
+
|
|
140
|
+
Context:
|
|
141
|
+
${context}${existingGoalsSection}
|
|
142
|
+
|
|
143
|
+
Return a JSON array of up to ${maxSuggestions} suggestions:
|
|
144
|
+
[
|
|
145
|
+
{
|
|
146
|
+
"title": "Short descriptive title",
|
|
147
|
+
"description": "Detailed description suitable for goal negotiation",
|
|
148
|
+
"rationale": "Why this goal matters",
|
|
149
|
+
"dimensions_hint": ["dimension_name_1", "dimension_name_2"]
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
Return ONLY a JSON array, no other text.`;
|
|
154
|
+
}
|
|
155
|
+
function buildCapabilityCheckPrompt(goalDescription, dimensions, adapterCapabilities) {
|
|
156
|
+
const dimensionsList = dimensions
|
|
157
|
+
.map((d) => `- ${d.name}: ${d.label} (threshold_type: ${d.threshold_type}, observation_hint: ${d.observation_method_hint})`)
|
|
158
|
+
.join("\n");
|
|
159
|
+
const capabilitiesList = adapterCapabilities
|
|
160
|
+
.map((ac) => `- ${ac.adapterType}: ${ac.capabilities.join(", ")}`)
|
|
161
|
+
.join("\n");
|
|
162
|
+
return `You are assessing whether an agent can achieve each dimension of a goal given its available capabilities.
|
|
163
|
+
|
|
164
|
+
Goal: ${goalDescription}
|
|
165
|
+
|
|
166
|
+
Dimensions to achieve:
|
|
167
|
+
${dimensionsList}
|
|
168
|
+
|
|
169
|
+
Available adapter capabilities:
|
|
170
|
+
${capabilitiesList}
|
|
171
|
+
|
|
172
|
+
For each dimension that requires a capability NOT available in the listed adapters, report it as a gap.
|
|
173
|
+
Also indicate whether the missing capability is acquirable (i.e., can the agent learn or install it during execution).
|
|
174
|
+
|
|
175
|
+
Return a JSON object:
|
|
176
|
+
{
|
|
177
|
+
"gaps": [
|
|
178
|
+
{
|
|
179
|
+
"dimension": "dimension_name",
|
|
180
|
+
"required_capability": "capability_name",
|
|
181
|
+
"acquirable": false,
|
|
182
|
+
"reason": "brief explanation why this capability is missing and whether it can be acquired"
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
If all dimensions can be achieved with the available capabilities, return { "gaps": [] }.
|
|
188
|
+
Return ONLY a JSON object, no other text.`;
|
|
189
|
+
}
|
|
190
|
+
function buildSubgoalDecompositionPrompt(parentGoal) {
|
|
191
|
+
const dimensionsList = parentGoal.dimensions
|
|
192
|
+
.map((d) => `- ${d.label} (${d.name}): target=${JSON.stringify(d.threshold)}`)
|
|
193
|
+
.join("\n");
|
|
194
|
+
return `Break down this goal into actionable subgoals.
|
|
195
|
+
|
|
196
|
+
Goal: ${parentGoal.title}
|
|
197
|
+
Description: ${parentGoal.description}
|
|
198
|
+
Dimensions:
|
|
199
|
+
${dimensionsList}
|
|
200
|
+
|
|
201
|
+
For each subgoal, provide:
|
|
202
|
+
- title: a clear subgoal title
|
|
203
|
+
- description: what needs to be achieved
|
|
204
|
+
- dimensions: array of dimension decompositions (same format as goal dimensions)
|
|
205
|
+
|
|
206
|
+
Return a JSON array of subgoal objects:
|
|
207
|
+
[
|
|
208
|
+
{
|
|
209
|
+
"title": "Subgoal Title",
|
|
210
|
+
"description": "What to achieve",
|
|
211
|
+
"dimensions": [
|
|
212
|
+
{
|
|
213
|
+
"name": "dimension_name",
|
|
214
|
+
"label": "Dimension Label",
|
|
215
|
+
"threshold_type": "min",
|
|
216
|
+
"threshold_value": 50,
|
|
217
|
+
"observation_method_hint": "How to measure"
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
Return ONLY a JSON array, no other text.`;
|
|
224
|
+
}
|
|
225
|
+
// ─── Goal Suggestion schemas ───
|
|
226
|
+
const GoalSuggestionSchema = z.object({
|
|
227
|
+
title: z.string(),
|
|
228
|
+
description: z.string(),
|
|
229
|
+
rationale: z.string(),
|
|
230
|
+
dimensions_hint: z.array(z.string()),
|
|
231
|
+
});
|
|
232
|
+
const GoalSuggestionListSchema = z.array(GoalSuggestionSchema);
|
|
233
|
+
// ─── Capability check schema for LLM parsing ───
|
|
234
|
+
const CapabilityCheckResultSchema = z.object({
|
|
235
|
+
gaps: z.array(z.object({
|
|
236
|
+
dimension: z.string(),
|
|
237
|
+
required_capability: z.string(),
|
|
238
|
+
acquirable: z.boolean(),
|
|
239
|
+
reason: z.string(),
|
|
240
|
+
})),
|
|
241
|
+
});
|
|
242
|
+
// ─── Subgoal schema for LLM parsing ───
|
|
243
|
+
const SubgoalLLMSchema = z.object({
|
|
244
|
+
title: z.string(),
|
|
245
|
+
description: z.string(),
|
|
246
|
+
dimensions: z.array(DimensionDecompositionSchema),
|
|
247
|
+
});
|
|
248
|
+
const SubgoalListSchema = z.array(SubgoalLLMSchema);
|
|
249
|
+
// ─── Qualitative feasibility schema for LLM parsing ───
|
|
250
|
+
const QualitativeFeasibilitySchema = z.object({
|
|
251
|
+
assessment: z.enum(["realistic", "ambitious", "infeasible"]),
|
|
252
|
+
confidence: z.enum(["high", "medium", "low"]),
|
|
253
|
+
reasoning: z.string(),
|
|
254
|
+
key_assumptions: z.array(z.string()),
|
|
255
|
+
main_risks: z.array(z.string()),
|
|
256
|
+
});
|
|
257
|
+
// ─── Helper: convert DimensionDecomposition to Dimension ───
|
|
258
|
+
function decompositionToDimension(d) {
|
|
259
|
+
const threshold = buildThreshold(d.threshold_type, d.threshold_value);
|
|
260
|
+
return {
|
|
261
|
+
name: d.name,
|
|
262
|
+
label: d.label,
|
|
263
|
+
current_value: null,
|
|
264
|
+
threshold,
|
|
265
|
+
confidence: 0,
|
|
266
|
+
observation_method: {
|
|
267
|
+
type: "llm_review",
|
|
268
|
+
source: d.observation_method_hint,
|
|
269
|
+
schedule: null,
|
|
270
|
+
endpoint: null,
|
|
271
|
+
confidence_tier: "self_report",
|
|
272
|
+
},
|
|
273
|
+
last_updated: null,
|
|
274
|
+
history: [],
|
|
275
|
+
weight: 1.0,
|
|
276
|
+
uncertainty_weight: null,
|
|
277
|
+
state_integrity: "ok",
|
|
278
|
+
dimension_mapping: null,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function buildThreshold(thresholdType, thresholdValue) {
|
|
282
|
+
switch (thresholdType) {
|
|
283
|
+
case "min":
|
|
284
|
+
return { type: "min", value: typeof thresholdValue === "number" ? thresholdValue : 0 };
|
|
285
|
+
case "max":
|
|
286
|
+
return { type: "max", value: typeof thresholdValue === "number" ? thresholdValue : 100 };
|
|
287
|
+
case "range": {
|
|
288
|
+
if (Array.isArray(thresholdValue)) {
|
|
289
|
+
const low = typeof thresholdValue[0] === "number" ? thresholdValue[0] : 0;
|
|
290
|
+
const high = typeof thresholdValue[1] === "number" ? thresholdValue[1] : 100;
|
|
291
|
+
return { type: "range", low, high };
|
|
292
|
+
}
|
|
293
|
+
return { type: "range", low: 0, high: typeof thresholdValue === "number" ? thresholdValue : 100 };
|
|
294
|
+
}
|
|
295
|
+
case "present":
|
|
296
|
+
return { type: "present" };
|
|
297
|
+
case "match":
|
|
298
|
+
return {
|
|
299
|
+
type: "match",
|
|
300
|
+
value: thresholdValue !== null && !Array.isArray(thresholdValue)
|
|
301
|
+
? thresholdValue
|
|
302
|
+
: "",
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// ─── Helper: deduplicate dimension keys ───
|
|
307
|
+
/**
|
|
308
|
+
* When the LLM returns multiple dimensions with the same `name` (key),
|
|
309
|
+
* append `_2`, `_3`, … suffixes to the duplicates so every key is unique.
|
|
310
|
+
* All dimensions are preserved — none are dropped.
|
|
311
|
+
*/
|
|
312
|
+
function deduplicateDimensionKeys(dimensions) {
|
|
313
|
+
const seen = new Map(); // key → count so far
|
|
314
|
+
for (const dim of dimensions) {
|
|
315
|
+
const base = dim.name;
|
|
316
|
+
const count = seen.get(base) ?? 0;
|
|
317
|
+
seen.set(base, count + 1);
|
|
318
|
+
if (count > 0) {
|
|
319
|
+
// Second occurrence → `_2`, third → `_3`, etc.
|
|
320
|
+
dim.name = `${base}_${count + 1}`;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return dimensions;
|
|
324
|
+
}
|
|
325
|
+
// ─── GoalNegotiator ───
|
|
326
|
+
export class GoalNegotiator {
|
|
327
|
+
stateManager;
|
|
328
|
+
llmClient;
|
|
329
|
+
ethicsGate;
|
|
330
|
+
observationEngine;
|
|
331
|
+
characterConfig;
|
|
332
|
+
satisficingJudge;
|
|
333
|
+
goalTreeManager;
|
|
334
|
+
adapterCapabilities;
|
|
335
|
+
constructor(stateManager, llmClient, ethicsGate, observationEngine, characterConfig, satisficingJudge, // Phase 2: auto-mapping proposals
|
|
336
|
+
goalTreeManager, adapterCapabilities) {
|
|
337
|
+
this.stateManager = stateManager;
|
|
338
|
+
this.llmClient = llmClient;
|
|
339
|
+
this.ethicsGate = ethicsGate;
|
|
340
|
+
this.observationEngine = observationEngine;
|
|
341
|
+
this.characterConfig = characterConfig ?? DEFAULT_CHARACTER_CONFIG;
|
|
342
|
+
this.satisficingJudge = satisficingJudge;
|
|
343
|
+
this.goalTreeManager = goalTreeManager;
|
|
344
|
+
this.adapterCapabilities = adapterCapabilities;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Compute the feasibility ratio threshold for "ambitious" vs "infeasible".
|
|
348
|
+
* Driven by caution_level (1=conservative/strict → 2.0, 5=ambitious → 4.0).
|
|
349
|
+
* Formula: threshold = 1.5 + (caution_level * 0.5)
|
|
350
|
+
*/
|
|
351
|
+
getFeasibilityThreshold() {
|
|
352
|
+
return 1.5 + this.characterConfig.caution_level * 0.5;
|
|
353
|
+
}
|
|
354
|
+
// ─── negotiate() — 6-step flow ───
|
|
355
|
+
async negotiate(rawGoalDescription, options) {
|
|
356
|
+
const goalId = randomUUID();
|
|
357
|
+
const deadline = options?.deadline ?? null;
|
|
358
|
+
const constraints = options?.constraints ?? [];
|
|
359
|
+
const timeHorizonDays = options?.timeHorizonDays ?? DEFAULT_TIME_HORIZON_DAYS;
|
|
360
|
+
const now = new Date().toISOString();
|
|
361
|
+
// Initialize negotiation log
|
|
362
|
+
const log = NegotiationLogSchema.parse({
|
|
363
|
+
goal_id: goalId,
|
|
364
|
+
timestamp: now,
|
|
365
|
+
is_renegotiation: false,
|
|
366
|
+
renegotiation_trigger: null,
|
|
367
|
+
});
|
|
368
|
+
// Step 0: Ethics Gate
|
|
369
|
+
const ethicsVerdict = await this.ethicsGate.check("goal", goalId, rawGoalDescription);
|
|
370
|
+
if (ethicsVerdict.verdict === "reject") {
|
|
371
|
+
throw new EthicsRejectedError(ethicsVerdict);
|
|
372
|
+
}
|
|
373
|
+
const ethicsFlags = ethicsVerdict.verdict === "flag" ? ethicsVerdict.risks : undefined;
|
|
374
|
+
// Step 1: Goal Intake
|
|
375
|
+
// (parsed from options above)
|
|
376
|
+
// Step 2: Dimension Decomposition (LLM)
|
|
377
|
+
const availableDataSources = this.observationEngine.getAvailableDimensionInfo();
|
|
378
|
+
const decompositionPrompt = buildDecompositionPrompt(rawGoalDescription, constraints, availableDataSources);
|
|
379
|
+
const decompositionResponse = await this.llmClient.sendMessage([{ role: "user", content: decompositionPrompt }], { temperature: 0 });
|
|
380
|
+
const dimensions = this.llmClient.parseJSON(decompositionResponse.content, z.array(DimensionDecompositionSchema));
|
|
381
|
+
// Post-process: map dimension names to DataSource dimensions when similar
|
|
382
|
+
if (availableDataSources.length > 0) {
|
|
383
|
+
const allDsNames = availableDataSources.flatMap(ds => ds.dimensions);
|
|
384
|
+
for (const dim of dimensions) {
|
|
385
|
+
if (!allDsNames.includes(dim.name)) {
|
|
386
|
+
// Try to find a similar DataSource dimension
|
|
387
|
+
const match = findBestDimensionMatch(dim.name, allDsNames);
|
|
388
|
+
if (match) {
|
|
389
|
+
dim.name = match;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// R3-4: Warn if all dimensions were remapped to DataSource dimensions
|
|
394
|
+
const allRemapped = dimensions.length > 0 && dimensions.every(dim => allDsNames.includes(dim.name));
|
|
395
|
+
if (allRemapped) {
|
|
396
|
+
console.warn("[GoalNegotiator] Warning: all dimensions were remapped to DataSource dimensions. " +
|
|
397
|
+
"Quality-specific dimensions may be missing. Consider adding dimensions that directly " +
|
|
398
|
+
"measure the goal's quality aspects.");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Post-process: ensure all dimension keys are unique (LLM may return duplicates)
|
|
402
|
+
deduplicateDimensionKeys(dimensions);
|
|
403
|
+
log.step2_decomposition = {
|
|
404
|
+
dimensions,
|
|
405
|
+
method: "llm",
|
|
406
|
+
};
|
|
407
|
+
// Step 3: Baseline Observation
|
|
408
|
+
const baselineObservations = [];
|
|
409
|
+
for (const dim of dimensions) {
|
|
410
|
+
// For new goals, we don't have observation setup yet
|
|
411
|
+
// Record null baseline with 0 confidence
|
|
412
|
+
baselineObservations.push({
|
|
413
|
+
dimension: dim.name,
|
|
414
|
+
value: null,
|
|
415
|
+
confidence: 0,
|
|
416
|
+
method: "initial_baseline",
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
log.step3_baseline = { observations: baselineObservations };
|
|
420
|
+
// Step 4: Feasibility Evaluation (Hybrid)
|
|
421
|
+
const feasibilityResults = [];
|
|
422
|
+
let overallPath = "qualitative";
|
|
423
|
+
for (const dim of dimensions) {
|
|
424
|
+
const baseline = baselineObservations.find((o) => o.dimension === dim.name);
|
|
425
|
+
const baselineValue = baseline?.value ?? null;
|
|
426
|
+
// Determine feasibility path
|
|
427
|
+
if (typeof baselineValue === "number" &&
|
|
428
|
+
typeof dim.threshold_value === "number") {
|
|
429
|
+
// Quantitative path
|
|
430
|
+
overallPath = overallPath === "qualitative" ? "hybrid" : overallPath;
|
|
431
|
+
// No observed_change_rate available for new goals, fallback to qualitative
|
|
432
|
+
const result = await this.evaluateQualitatively(dim.name, rawGoalDescription, baselineValue, dim.threshold_value, timeHorizonDays);
|
|
433
|
+
feasibilityResults.push(result);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
// Qualitative path (LLM assessment)
|
|
437
|
+
const result = await this.evaluateQualitatively(dim.name, rawGoalDescription, baselineValue, dim.threshold_value, timeHorizonDays);
|
|
438
|
+
feasibilityResults.push(result);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
log.step4_evaluation = {
|
|
442
|
+
path: overallPath,
|
|
443
|
+
dimensions: feasibilityResults,
|
|
444
|
+
};
|
|
445
|
+
// Step 4b: Capability Check
|
|
446
|
+
if (this.adapterCapabilities && this.adapterCapabilities.length > 0) {
|
|
447
|
+
try {
|
|
448
|
+
const capCheckPrompt = buildCapabilityCheckPrompt(rawGoalDescription, dimensions, this.adapterCapabilities);
|
|
449
|
+
const capCheckResponse = await this.llmClient.sendMessage([{ role: "user", content: capCheckPrompt }], { temperature: 0 });
|
|
450
|
+
const capCheckResult = this.llmClient.parseJSON(capCheckResponse.content, CapabilityCheckResultSchema);
|
|
451
|
+
const allCapabilities = this.adapterCapabilities.flatMap((ac) => ac.capabilities);
|
|
452
|
+
const infeasibleDimensions = [];
|
|
453
|
+
for (const gap of capCheckResult.gaps) {
|
|
454
|
+
if (!gap.acquirable) {
|
|
455
|
+
const existing = feasibilityResults.find((r) => r.dimension === gap.dimension);
|
|
456
|
+
if (existing) {
|
|
457
|
+
existing.assessment = "infeasible";
|
|
458
|
+
existing.reasoning = `Capability gap: ${gap.reason}`;
|
|
459
|
+
}
|
|
460
|
+
infeasibleDimensions.push(gap.dimension);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
log.step4_capability_check = CapabilityCheckLogSchema.parse({
|
|
464
|
+
capabilities_available: allCapabilities,
|
|
465
|
+
gaps_detected: capCheckResult.gaps.map((g) => ({
|
|
466
|
+
dimension: g.dimension,
|
|
467
|
+
required_capability: g.required_capability,
|
|
468
|
+
acquirable: g.acquirable,
|
|
469
|
+
})),
|
|
470
|
+
infeasible_dimensions: infeasibleDimensions,
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
catch {
|
|
474
|
+
// Non-critical: capability check failure should not block negotiation
|
|
475
|
+
console.warn("[GoalNegotiator] Step 4b capability check failed, continuing without it");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
// Step 5: Response Generation
|
|
479
|
+
const { responseType, counterProposal, initialConfidence } = this.determineResponseType(feasibilityResults, baselineObservations, timeHorizonDays);
|
|
480
|
+
// Generate user-facing message via LLM
|
|
481
|
+
const responsePrompt = buildResponsePrompt(rawGoalDescription, responseType, feasibilityResults, counterProposal);
|
|
482
|
+
const responseMessage = await this.llmClient.sendMessage([{ role: "user", content: responsePrompt }], { temperature: 0 });
|
|
483
|
+
const negotiationResponse = {
|
|
484
|
+
type: responseType,
|
|
485
|
+
message: responseMessage.content.trim(),
|
|
486
|
+
accepted: responseType === "accept" || responseType === "flag_as_ambitious",
|
|
487
|
+
initial_confidence: initialConfidence,
|
|
488
|
+
...(counterProposal ? { counter_proposal: counterProposal } : {}),
|
|
489
|
+
...(ethicsFlags ? { flags: ethicsFlags } : {}),
|
|
490
|
+
};
|
|
491
|
+
log.step5_response = {
|
|
492
|
+
type: responseType,
|
|
493
|
+
accepted: negotiationResponse.accepted,
|
|
494
|
+
initial_confidence: initialConfidence,
|
|
495
|
+
user_acknowledged: false,
|
|
496
|
+
counter_proposal: counterProposal
|
|
497
|
+
? {
|
|
498
|
+
realistic_target: counterProposal.realistic_target,
|
|
499
|
+
reasoning: counterProposal.reasoning,
|
|
500
|
+
alternatives: counterProposal.alternatives,
|
|
501
|
+
}
|
|
502
|
+
: null,
|
|
503
|
+
};
|
|
504
|
+
// Build Goal object
|
|
505
|
+
const goalDimensions = dimensions.map(decompositionToDimension);
|
|
506
|
+
const goal = GoalSchema.parse({
|
|
507
|
+
id: goalId,
|
|
508
|
+
parent_id: null,
|
|
509
|
+
node_type: "goal",
|
|
510
|
+
title: rawGoalDescription,
|
|
511
|
+
description: rawGoalDescription,
|
|
512
|
+
status: "active",
|
|
513
|
+
dimensions: goalDimensions,
|
|
514
|
+
gap_aggregation: "max",
|
|
515
|
+
dimension_mapping: null,
|
|
516
|
+
constraints,
|
|
517
|
+
children_ids: [],
|
|
518
|
+
target_date: null,
|
|
519
|
+
origin: "negotiation",
|
|
520
|
+
pace_snapshot: null,
|
|
521
|
+
deadline,
|
|
522
|
+
confidence_flag: initialConfidence === "low" ? "low" : initialConfidence === "medium" ? "medium" : "high",
|
|
523
|
+
user_override: false,
|
|
524
|
+
feasibility_note: responseType === "counter_propose"
|
|
525
|
+
? `Counter-proposal: target=${counterProposal?.realistic_target}`
|
|
526
|
+
: null,
|
|
527
|
+
uncertainty_weight: 1.0,
|
|
528
|
+
created_at: now,
|
|
529
|
+
updated_at: now,
|
|
530
|
+
});
|
|
531
|
+
// Persist
|
|
532
|
+
this.stateManager.saveGoal(goal);
|
|
533
|
+
this.saveNegotiationLog(goalId, log);
|
|
534
|
+
return { goal, response: negotiationResponse, log };
|
|
535
|
+
}
|
|
536
|
+
// ─── decompose() ───
|
|
537
|
+
async decompose(goalId, parentGoal) {
|
|
538
|
+
// Step 1: LLM generates subgoals
|
|
539
|
+
const prompt = buildSubgoalDecompositionPrompt(parentGoal);
|
|
540
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
541
|
+
const subgoalSpecs = this.llmClient.parseJSON(response.content, SubgoalListSchema);
|
|
542
|
+
const subgoals = [];
|
|
543
|
+
const rejectedSubgoals = [];
|
|
544
|
+
let hasCriticalRejection = false;
|
|
545
|
+
// Step 2: Ethics check each subgoal
|
|
546
|
+
for (const spec of subgoalSpecs) {
|
|
547
|
+
const subgoalId = randomUUID();
|
|
548
|
+
const verdict = await this.ethicsGate.check("subgoal", subgoalId, spec.description, `Parent goal: ${parentGoal.title}`);
|
|
549
|
+
if (verdict.verdict === "reject") {
|
|
550
|
+
rejectedSubgoals.push({
|
|
551
|
+
description: spec.title,
|
|
552
|
+
reason: verdict.reasoning,
|
|
553
|
+
});
|
|
554
|
+
hasCriticalRejection = true;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
const now = new Date().toISOString();
|
|
558
|
+
const dimensions = spec.dimensions.map(decompositionToDimension);
|
|
559
|
+
const subgoal = GoalSchema.parse({
|
|
560
|
+
id: subgoalId,
|
|
561
|
+
parent_id: goalId,
|
|
562
|
+
node_type: "subgoal",
|
|
563
|
+
title: spec.title,
|
|
564
|
+
description: spec.description,
|
|
565
|
+
status: "active",
|
|
566
|
+
dimensions,
|
|
567
|
+
gap_aggregation: "max",
|
|
568
|
+
dimension_mapping: null,
|
|
569
|
+
constraints: [],
|
|
570
|
+
children_ids: [],
|
|
571
|
+
target_date: null,
|
|
572
|
+
origin: "decomposition",
|
|
573
|
+
pace_snapshot: null,
|
|
574
|
+
deadline: null,
|
|
575
|
+
confidence_flag: verdict.verdict === "flag" ? "medium" : "high",
|
|
576
|
+
user_override: false,
|
|
577
|
+
feasibility_note: null,
|
|
578
|
+
uncertainty_weight: 1.0,
|
|
579
|
+
created_at: now,
|
|
580
|
+
updated_at: now,
|
|
581
|
+
});
|
|
582
|
+
subgoals.push(subgoal);
|
|
583
|
+
this.stateManager.saveGoal(subgoal);
|
|
584
|
+
}
|
|
585
|
+
// Phase 2: Auto-propose dimension mappings
|
|
586
|
+
if (this.satisficingJudge) {
|
|
587
|
+
for (const subgoal of subgoals) {
|
|
588
|
+
try {
|
|
589
|
+
const proposals = await this.satisficingJudge.proposeDimensionMapping(subgoal.dimensions.map(d => ({ name: d.name })), parentGoal.dimensions.map(d => ({ name: d.name })));
|
|
590
|
+
// Apply proposals to subgoal dimensions that don't already have mappings
|
|
591
|
+
for (const proposal of proposals) {
|
|
592
|
+
const dim = subgoal.dimensions.find(d => d.name === proposal.subgoal_dimension);
|
|
593
|
+
if (dim && !dim.dimension_mapping) {
|
|
594
|
+
dim.dimension_mapping = {
|
|
595
|
+
parent_dimension: proposal.parent_dimension,
|
|
596
|
+
aggregation: proposal.suggested_aggregation,
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (proposals.length > 0) {
|
|
601
|
+
await this.stateManager.saveGoal(subgoal);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch {
|
|
605
|
+
// Non-critical: auto-mapping failure should not block decomposition
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
// Step 4: If critical subgoal rejected, warn (but still return what we can)
|
|
610
|
+
if (hasCriticalRejection && subgoals.length === 0) {
|
|
611
|
+
// All subgoals rejected — caller should consider rejecting parent goal
|
|
612
|
+
}
|
|
613
|
+
return { subgoals, rejectedSubgoals };
|
|
614
|
+
}
|
|
615
|
+
// ─── renegotiate() ───
|
|
616
|
+
async renegotiate(goalId, trigger, context) {
|
|
617
|
+
const existingGoal = this.stateManager.loadGoal(goalId);
|
|
618
|
+
if (existingGoal === null) {
|
|
619
|
+
throw new Error(`renegotiate: goal "${goalId}" not found`);
|
|
620
|
+
}
|
|
621
|
+
const now = new Date().toISOString();
|
|
622
|
+
// Initialize renegotiation log
|
|
623
|
+
const log = NegotiationLogSchema.parse({
|
|
624
|
+
goal_id: goalId,
|
|
625
|
+
timestamp: now,
|
|
626
|
+
is_renegotiation: true,
|
|
627
|
+
renegotiation_trigger: trigger,
|
|
628
|
+
});
|
|
629
|
+
// Step 0: Ethics re-check
|
|
630
|
+
const ethicsVerdict = await this.ethicsGate.check("goal", goalId, existingGoal.description, context);
|
|
631
|
+
if (ethicsVerdict.verdict === "reject") {
|
|
632
|
+
throw new EthicsRejectedError(ethicsVerdict);
|
|
633
|
+
}
|
|
634
|
+
const ethicsFlags = ethicsVerdict.verdict === "flag" ? ethicsVerdict.risks : undefined;
|
|
635
|
+
// Step 2: Re-decompose dimensions (LLM) using existing goal + context
|
|
636
|
+
const availableDataSources = this.observationEngine.getAvailableDimensionInfo();
|
|
637
|
+
const redecompPrompt = buildDecompositionPrompt(`${existingGoal.description}${context ? ` (Renegotiation context: ${context})` : ""}`, existingGoal.constraints, availableDataSources);
|
|
638
|
+
const decompositionResponse = await this.llmClient.sendMessage([{ role: "user", content: redecompPrompt }], { temperature: 0 });
|
|
639
|
+
const dimensions = this.llmClient.parseJSON(decompositionResponse.content, z.array(DimensionDecompositionSchema));
|
|
640
|
+
// Post-process: map dimension names to DataSource dimensions when similar
|
|
641
|
+
if (availableDataSources.length > 0) {
|
|
642
|
+
const allDsNames = availableDataSources.flatMap(ds => ds.dimensions);
|
|
643
|
+
for (const dim of dimensions) {
|
|
644
|
+
if (!allDsNames.includes(dim.name)) {
|
|
645
|
+
// Try to find a similar DataSource dimension
|
|
646
|
+
const match = findBestDimensionMatch(dim.name, allDsNames);
|
|
647
|
+
if (match) {
|
|
648
|
+
dim.name = match;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
// Post-process: ensure all dimension keys are unique (LLM may return duplicates)
|
|
654
|
+
deduplicateDimensionKeys(dimensions);
|
|
655
|
+
log.step2_decomposition = { dimensions, method: "llm" };
|
|
656
|
+
// Step 3: Baseline from existing goal state
|
|
657
|
+
const baselineObservations = dimensions.map((dim) => {
|
|
658
|
+
const existingDim = existingGoal.dimensions.find((d) => d.name === dim.name);
|
|
659
|
+
return {
|
|
660
|
+
dimension: dim.name,
|
|
661
|
+
value: existingDim?.current_value ?? null,
|
|
662
|
+
confidence: existingDim?.confidence ?? 0,
|
|
663
|
+
method: "existing_observation",
|
|
664
|
+
};
|
|
665
|
+
});
|
|
666
|
+
log.step3_baseline = { observations: baselineObservations };
|
|
667
|
+
// Step 4: Feasibility re-evaluation
|
|
668
|
+
const feasibilityResults = [];
|
|
669
|
+
const timeHorizonDays = DEFAULT_TIME_HORIZON_DAYS;
|
|
670
|
+
for (const dim of dimensions) {
|
|
671
|
+
const baseline = baselineObservations.find((o) => o.dimension === dim.name);
|
|
672
|
+
const baselineValue = baseline?.value ?? null;
|
|
673
|
+
// Check for quantitative path with change rate from history
|
|
674
|
+
const existingDim = existingGoal.dimensions.find((d) => d.name === dim.name);
|
|
675
|
+
const changeRate = existingDim ? this.estimateChangeRate(existingDim) : null;
|
|
676
|
+
if (typeof baselineValue === "number" &&
|
|
677
|
+
typeof dim.threshold_value === "number" &&
|
|
678
|
+
changeRate !== null &&
|
|
679
|
+
changeRate > 0) {
|
|
680
|
+
// Quantitative path
|
|
681
|
+
const necessaryChangeRate = Math.abs(dim.threshold_value - baselineValue) / timeHorizonDays;
|
|
682
|
+
const feasibilityRatio = necessaryChangeRate / changeRate;
|
|
683
|
+
let assessment;
|
|
684
|
+
if (feasibilityRatio <= FEASIBILITY_RATIO_THRESHOLD_REALISTIC) {
|
|
685
|
+
assessment = "realistic";
|
|
686
|
+
}
|
|
687
|
+
else if (feasibilityRatio <= this.getFeasibilityThreshold()) {
|
|
688
|
+
assessment = "ambitious";
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
assessment = "infeasible";
|
|
692
|
+
}
|
|
693
|
+
feasibilityResults.push(FeasibilityResultSchema.parse({
|
|
694
|
+
dimension: dim.name,
|
|
695
|
+
path: "quantitative",
|
|
696
|
+
feasibility_ratio: feasibilityRatio,
|
|
697
|
+
assessment,
|
|
698
|
+
confidence: assessment === "realistic" ? "high" : assessment === "ambitious" ? "medium" : "low",
|
|
699
|
+
reasoning: `Feasibility ratio: ${feasibilityRatio.toFixed(2)}`,
|
|
700
|
+
key_assumptions: [`Change rate: ${changeRate.toFixed(4)}/day`],
|
|
701
|
+
main_risks: assessment === "infeasible" ? ["Target may be unreachable in time horizon"] : [],
|
|
702
|
+
}));
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
// Qualitative fallback
|
|
706
|
+
const result = await this.evaluateQualitatively(dim.name, existingGoal.description, baselineValue, dim.threshold_value, timeHorizonDays);
|
|
707
|
+
feasibilityResults.push(result);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
log.step4_evaluation = {
|
|
711
|
+
path: feasibilityResults.some((r) => r.path === "quantitative") ? "hybrid" : "qualitative",
|
|
712
|
+
dimensions: feasibilityResults,
|
|
713
|
+
};
|
|
714
|
+
// Step 4b: Capability Check
|
|
715
|
+
if (this.adapterCapabilities && this.adapterCapabilities.length > 0) {
|
|
716
|
+
try {
|
|
717
|
+
const capCheckPrompt = buildCapabilityCheckPrompt(existingGoal.description, dimensions, this.adapterCapabilities);
|
|
718
|
+
const capCheckResponse = await this.llmClient.sendMessage([{ role: "user", content: capCheckPrompt }], { temperature: 0 });
|
|
719
|
+
const capCheckResult = this.llmClient.parseJSON(capCheckResponse.content, CapabilityCheckResultSchema);
|
|
720
|
+
const allCapabilities = this.adapterCapabilities.flatMap((ac) => ac.capabilities);
|
|
721
|
+
const infeasibleDimensions = [];
|
|
722
|
+
for (const gap of capCheckResult.gaps) {
|
|
723
|
+
if (!gap.acquirable) {
|
|
724
|
+
const existing = feasibilityResults.find((r) => r.dimension === gap.dimension);
|
|
725
|
+
if (existing) {
|
|
726
|
+
existing.assessment = "infeasible";
|
|
727
|
+
existing.reasoning = `Capability gap: ${gap.reason}`;
|
|
728
|
+
}
|
|
729
|
+
infeasibleDimensions.push(gap.dimension);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
log.step4_capability_check = CapabilityCheckLogSchema.parse({
|
|
733
|
+
capabilities_available: allCapabilities,
|
|
734
|
+
gaps_detected: capCheckResult.gaps.map((g) => ({
|
|
735
|
+
dimension: g.dimension,
|
|
736
|
+
required_capability: g.required_capability,
|
|
737
|
+
acquirable: g.acquirable,
|
|
738
|
+
})),
|
|
739
|
+
infeasible_dimensions: infeasibleDimensions,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
catch {
|
|
743
|
+
// Non-critical: capability check failure should not block renegotiation
|
|
744
|
+
console.warn("[GoalNegotiator] Step 4b capability check failed, continuing without it");
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
// Step 5: Response generation
|
|
748
|
+
const { responseType, counterProposal, initialConfidence } = this.determineResponseType(feasibilityResults, baselineObservations, timeHorizonDays);
|
|
749
|
+
const responsePrompt = buildResponsePrompt(existingGoal.description, responseType, feasibilityResults, counterProposal);
|
|
750
|
+
const responseMessage = await this.llmClient.sendMessage([{ role: "user", content: responsePrompt }], { temperature: 0 });
|
|
751
|
+
const negotiationResponse = {
|
|
752
|
+
type: responseType,
|
|
753
|
+
message: responseMessage.content.trim(),
|
|
754
|
+
accepted: responseType === "accept" || responseType === "flag_as_ambitious",
|
|
755
|
+
initial_confidence: initialConfidence,
|
|
756
|
+
...(counterProposal ? { counter_proposal: counterProposal } : {}),
|
|
757
|
+
...(ethicsFlags ? { flags: ethicsFlags } : {}),
|
|
758
|
+
};
|
|
759
|
+
log.step5_response = {
|
|
760
|
+
type: responseType,
|
|
761
|
+
accepted: negotiationResponse.accepted,
|
|
762
|
+
initial_confidence: initialConfidence,
|
|
763
|
+
user_acknowledged: false,
|
|
764
|
+
counter_proposal: counterProposal
|
|
765
|
+
? {
|
|
766
|
+
realistic_target: counterProposal.realistic_target,
|
|
767
|
+
reasoning: counterProposal.reasoning,
|
|
768
|
+
alternatives: counterProposal.alternatives,
|
|
769
|
+
}
|
|
770
|
+
: null,
|
|
771
|
+
};
|
|
772
|
+
// Update goal
|
|
773
|
+
const goalDimensions = dimensions.map(decompositionToDimension);
|
|
774
|
+
const updatedGoal = GoalSchema.parse({
|
|
775
|
+
...existingGoal,
|
|
776
|
+
dimensions: goalDimensions,
|
|
777
|
+
confidence_flag: initialConfidence === "low" ? "low" : initialConfidence === "medium" ? "medium" : "high",
|
|
778
|
+
feasibility_note: responseType === "counter_propose"
|
|
779
|
+
? `Renegotiation counter-proposal: target=${counterProposal?.realistic_target}`
|
|
780
|
+
: null,
|
|
781
|
+
updated_at: now,
|
|
782
|
+
});
|
|
783
|
+
this.stateManager.saveGoal(updatedGoal);
|
|
784
|
+
this.saveNegotiationLog(goalId, log);
|
|
785
|
+
return { goal: updatedGoal, response: negotiationResponse, log };
|
|
786
|
+
}
|
|
787
|
+
// ─── decomposeIntoSubgoals() ───
|
|
788
|
+
/**
|
|
789
|
+
* Decompose a negotiated goal into subgoals using GoalTreeManager.
|
|
790
|
+
* For depth >= 2, skip negotiation and auto-accept.
|
|
791
|
+
* Returns null if goalTreeManager is not injected.
|
|
792
|
+
*/
|
|
793
|
+
async decomposeIntoSubgoals(goalId, config) {
|
|
794
|
+
if (this.goalTreeManager === undefined) {
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
798
|
+
if (!goal) {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
const resolvedConfig = config ?? {
|
|
802
|
+
max_depth: 5,
|
|
803
|
+
min_specificity: 0.7,
|
|
804
|
+
auto_prune_threshold: 0.3,
|
|
805
|
+
parallel_loop_limit: 3,
|
|
806
|
+
};
|
|
807
|
+
return this.goalTreeManager.decomposeGoal(goalId, resolvedConfig);
|
|
808
|
+
}
|
|
809
|
+
// ─── suggestGoals() ───
|
|
810
|
+
/**
|
|
811
|
+
* Suggest measurable improvement goals based on the given context.
|
|
812
|
+
* Does NOT save goals — it only suggests. Use negotiate() to register a suggestion.
|
|
813
|
+
*/
|
|
814
|
+
async suggestGoals(context, options) {
|
|
815
|
+
const maxSuggestions = options?.maxSuggestions ?? 5;
|
|
816
|
+
const existingGoals = options?.existingGoals ?? [];
|
|
817
|
+
if (!context || context.trim().length === 0) {
|
|
818
|
+
return [];
|
|
819
|
+
}
|
|
820
|
+
const prompt = buildSuggestGoalsPrompt(context, maxSuggestions, existingGoals);
|
|
821
|
+
let rawContent;
|
|
822
|
+
try {
|
|
823
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0.3 });
|
|
824
|
+
rawContent = response.content;
|
|
825
|
+
}
|
|
826
|
+
catch {
|
|
827
|
+
return [];
|
|
828
|
+
}
|
|
829
|
+
let suggestions;
|
|
830
|
+
try {
|
|
831
|
+
suggestions = this.llmClient.parseJSON(rawContent, GoalSuggestionListSchema);
|
|
832
|
+
}
|
|
833
|
+
catch {
|
|
834
|
+
return [];
|
|
835
|
+
}
|
|
836
|
+
// Apply ethics filtering — remove rejected suggestions
|
|
837
|
+
const ethicsFiltered = [];
|
|
838
|
+
for (const suggestion of suggestions) {
|
|
839
|
+
try {
|
|
840
|
+
const verdict = await this.ethicsGate.check("goal", randomUUID(), suggestion.description);
|
|
841
|
+
if (verdict.verdict === "reject") {
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
ethicsFiltered.push(suggestion);
|
|
845
|
+
}
|
|
846
|
+
catch {
|
|
847
|
+
// Non-critical: if ethics check fails, include the suggestion
|
|
848
|
+
ethicsFiltered.push(suggestion);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return await this.filterSuggestions(ethicsFiltered, options?.existingGoals || [], options?.capabilityDetector);
|
|
852
|
+
}
|
|
853
|
+
async filterSuggestions(suggestions, existingGoals, capabilityDetector) {
|
|
854
|
+
const filtered = [];
|
|
855
|
+
for (const suggestion of suggestions) {
|
|
856
|
+
// 1. Dedup: skip if similar to existing goal (case-insensitive substring match)
|
|
857
|
+
const isDuplicate = existingGoals.some(existing => {
|
|
858
|
+
const existingLower = existing.toLowerCase();
|
|
859
|
+
const titleLower = suggestion.title.toLowerCase();
|
|
860
|
+
return existingLower.includes(titleLower) || titleLower.includes(existingLower);
|
|
861
|
+
});
|
|
862
|
+
if (isDuplicate) {
|
|
863
|
+
console.log(`[GoalNegotiator] Filtered duplicate suggestion: "${suggestion.title}"`);
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
// 2. Feasibility check via CapabilityDetector (if available)
|
|
867
|
+
if (capabilityDetector) {
|
|
868
|
+
try {
|
|
869
|
+
const gap = await capabilityDetector.detectGoalCapabilityGap(suggestion.description, this.adapterCapabilities?.map(a => a.capabilities).flat() || []);
|
|
870
|
+
if (gap && !gap.acquirable) {
|
|
871
|
+
console.log(`[GoalNegotiator] Filtered infeasible suggestion: "${suggestion.title}" — ${gap.gap.reason}`);
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
catch (err) {
|
|
876
|
+
// Non-blocking: if capability check fails, keep the suggestion
|
|
877
|
+
console.warn(`[GoalNegotiator] Capability check failed for "${suggestion.title}": ${err}`);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
filtered.push(suggestion);
|
|
881
|
+
}
|
|
882
|
+
return filtered;
|
|
883
|
+
}
|
|
884
|
+
// ─── getNegotiationLog() ───
|
|
885
|
+
getNegotiationLog(goalId) {
|
|
886
|
+
const raw = this.stateManager.readRaw(`goals/${goalId}/negotiation-log.json`);
|
|
887
|
+
if (raw === null)
|
|
888
|
+
return null;
|
|
889
|
+
return NegotiationLogSchema.parse(raw);
|
|
890
|
+
}
|
|
891
|
+
// ─── Private helpers ───
|
|
892
|
+
saveNegotiationLog(goalId, log) {
|
|
893
|
+
const parsed = NegotiationLogSchema.parse(log);
|
|
894
|
+
this.stateManager.writeRaw(`goals/${goalId}/negotiation-log.json`, parsed);
|
|
895
|
+
}
|
|
896
|
+
async evaluateQualitatively(dimensionName, goalDescription, baselineValue, thresholdValue, timeHorizonDays) {
|
|
897
|
+
const prompt = buildFeasibilityPrompt(dimensionName, goalDescription, baselineValue, thresholdValue, timeHorizonDays);
|
|
898
|
+
const response = await this.llmClient.sendMessage([{ role: "user", content: prompt }], { temperature: 0 });
|
|
899
|
+
try {
|
|
900
|
+
const parsed = this.llmClient.parseJSON(response.content, QualitativeFeasibilitySchema);
|
|
901
|
+
return FeasibilityResultSchema.parse({
|
|
902
|
+
dimension: dimensionName,
|
|
903
|
+
path: "qualitative",
|
|
904
|
+
feasibility_ratio: null,
|
|
905
|
+
assessment: parsed.assessment,
|
|
906
|
+
confidence: parsed.confidence,
|
|
907
|
+
reasoning: parsed.reasoning,
|
|
908
|
+
key_assumptions: parsed.key_assumptions,
|
|
909
|
+
main_risks: parsed.main_risks,
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
catch {
|
|
913
|
+
// Conservative fallback on parse failure
|
|
914
|
+
return FeasibilityResultSchema.parse({
|
|
915
|
+
dimension: dimensionName,
|
|
916
|
+
path: "qualitative",
|
|
917
|
+
feasibility_ratio: null,
|
|
918
|
+
assessment: "ambitious",
|
|
919
|
+
confidence: "low",
|
|
920
|
+
reasoning: "Failed to parse feasibility assessment, defaulting to ambitious.",
|
|
921
|
+
key_assumptions: [],
|
|
922
|
+
main_risks: ["Unable to assess feasibility"],
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
determineResponseType(feasibilityResults, baselineObservations, timeHorizonDays) {
|
|
927
|
+
const hasInfeasible = feasibilityResults.some((r) => r.assessment === "infeasible");
|
|
928
|
+
const hasLowConfidence = feasibilityResults.some((r) => r.confidence === "low");
|
|
929
|
+
const allRealisticOrAmbitious = feasibilityResults.every((r) => r.assessment === "realistic" || r.assessment === "ambitious");
|
|
930
|
+
let initialConfidence;
|
|
931
|
+
if (hasLowConfidence) {
|
|
932
|
+
initialConfidence = "low";
|
|
933
|
+
}
|
|
934
|
+
else if (feasibilityResults.some((r) => r.confidence === "medium")) {
|
|
935
|
+
initialConfidence = "medium";
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
initialConfidence = "high";
|
|
939
|
+
}
|
|
940
|
+
if (hasInfeasible) {
|
|
941
|
+
// Find the first infeasible dimension to build counter-proposal
|
|
942
|
+
const infeasible = feasibilityResults.find((r) => r.assessment === "infeasible");
|
|
943
|
+
const baseline = baselineObservations.find((o) => o.dimension === infeasible.dimension);
|
|
944
|
+
const baselineValue = typeof baseline?.value === "number" ? baseline.value : 0;
|
|
945
|
+
// Calculate realistic target
|
|
946
|
+
// If we have a feasibility_ratio, we can compute a change rate
|
|
947
|
+
// realistic_target = baseline + (observed_change_rate * timeHorizonDays * 1.3)
|
|
948
|
+
// Since observed_change_rate = necessary_change_rate / feasibility_ratio
|
|
949
|
+
// and necessary_change_rate = |target - baseline| / timeHorizonDays
|
|
950
|
+
// realistic_target = baseline + (|target - baseline| / feasibility_ratio) * 1.3
|
|
951
|
+
let realisticTarget;
|
|
952
|
+
if (infeasible.feasibility_ratio !== null && infeasible.feasibility_ratio > 0) {
|
|
953
|
+
const gap = infeasible.feasibility_ratio > 0
|
|
954
|
+
? (timeHorizonDays * REALISTIC_TARGET_ACCELERATION_FACTOR) / infeasible.feasibility_ratio
|
|
955
|
+
: 0;
|
|
956
|
+
// Actually: observed_change_rate = necessary_rate / ratio
|
|
957
|
+
// necessary_rate = |target - baseline| / timeHorizon
|
|
958
|
+
// observed * timeHorizon * 1.3 = (necessary_rate / ratio) * timeHorizon * 1.3
|
|
959
|
+
// = (|target - baseline| / ratio) * 1.3
|
|
960
|
+
// Not exactly right without knowing the target. Let's use a simpler formula.
|
|
961
|
+
// From the spec: realistic_target = baseline + (observed_change_rate * timeHorizonDays * 1.3)
|
|
962
|
+
// observed_change_rate is not available for new goals. Use qualitative fallback.
|
|
963
|
+
realisticTarget = baselineValue;
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
realisticTarget = baselineValue;
|
|
967
|
+
}
|
|
968
|
+
return {
|
|
969
|
+
responseType: "counter_propose",
|
|
970
|
+
counterProposal: {
|
|
971
|
+
realistic_target: realisticTarget,
|
|
972
|
+
reasoning: infeasible.reasoning,
|
|
973
|
+
alternatives: infeasible.main_risks.length > 0
|
|
974
|
+
? [`Address risks: ${infeasible.main_risks.join(", ")}`]
|
|
975
|
+
: ["Consider reducing scope or extending timeline"],
|
|
976
|
+
},
|
|
977
|
+
initialConfidence: "low",
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
if (hasLowConfidence && allRealisticOrAmbitious) {
|
|
981
|
+
return {
|
|
982
|
+
responseType: "flag_as_ambitious",
|
|
983
|
+
initialConfidence: "low",
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
if (allRealisticOrAmbitious) {
|
|
987
|
+
return {
|
|
988
|
+
responseType: "accept",
|
|
989
|
+
initialConfidence,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
return {
|
|
993
|
+
responseType: "accept",
|
|
994
|
+
initialConfidence,
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Estimate daily change rate from dimension history.
|
|
999
|
+
* Returns null if insufficient data.
|
|
1000
|
+
*/
|
|
1001
|
+
estimateChangeRate(dimension) {
|
|
1002
|
+
const history = dimension.history;
|
|
1003
|
+
if (history.length < 2)
|
|
1004
|
+
return null;
|
|
1005
|
+
const numericEntries = history.filter((h) => typeof h.value === "number");
|
|
1006
|
+
if (numericEntries.length < 2)
|
|
1007
|
+
return null;
|
|
1008
|
+
const first = numericEntries[0];
|
|
1009
|
+
const last = numericEntries[numericEntries.length - 1];
|
|
1010
|
+
const timeDiffMs = new Date(last.timestamp).getTime() - new Date(first.timestamp).getTime();
|
|
1011
|
+
const timeDiffDays = timeDiffMs / (1000 * 60 * 60 * 24);
|
|
1012
|
+
if (timeDiffDays <= 0)
|
|
1013
|
+
return null;
|
|
1014
|
+
return Math.abs(last.value - first.value) / timeDiffDays;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Calculate counter-proposal target given baseline, change rate, and time horizon.
|
|
1018
|
+
* Uses acceleration factor from character.md.
|
|
1019
|
+
*/
|
|
1020
|
+
static calculateRealisticTarget(baseline, changeRate, timeHorizonDays) {
|
|
1021
|
+
return baseline + changeRate * timeHorizonDays * REALISTIC_TARGET_ACCELERATION_FACTOR;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Find the best matching DataSource dimension name for a given dimension name.
|
|
1026
|
+
* Uses simple keyword overlap matching.
|
|
1027
|
+
*/
|
|
1028
|
+
function findBestDimensionMatch(name, candidates) {
|
|
1029
|
+
const nameTokens = name.toLowerCase().split(/[_\s-]+/);
|
|
1030
|
+
let bestMatch = null;
|
|
1031
|
+
let bestScore = 0;
|
|
1032
|
+
for (const candidate of candidates) {
|
|
1033
|
+
const candidateTokens = candidate.toLowerCase().split(/[_\s-]+/);
|
|
1034
|
+
// Count overlapping tokens
|
|
1035
|
+
const overlap = nameTokens.filter(t => candidateTokens.includes(t)).length;
|
|
1036
|
+
const score = overlap / Math.max(nameTokens.length, candidateTokens.length);
|
|
1037
|
+
if (score > bestScore && score >= 0.6) { // At least 60% token overlap
|
|
1038
|
+
bestScore = score;
|
|
1039
|
+
bestMatch = candidate;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return bestMatch;
|
|
1043
|
+
}
|
|
1044
|
+
//# sourceMappingURL=goal-negotiator.js.map
|