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,790 @@
|
|
|
1
|
+
import { scoreDeadline } from "./drive/drive-scorer.js";
|
|
2
|
+
import { CrossGoalPortfolioConfigSchema, } from "./types/cross-portfolio.js";
|
|
3
|
+
// ─── Helpers ───
|
|
4
|
+
function clamp(value, min, max) {
|
|
5
|
+
return Math.min(Math.max(value, min), max);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* CrossGoalPortfolio manages resource allocation and priority across multiple
|
|
9
|
+
* active goals. It sits above individual PortfolioManager instances and answers
|
|
10
|
+
* the question: "given N active goals, how should overall resources be split?"
|
|
11
|
+
*
|
|
12
|
+
* Responsibilities:
|
|
13
|
+
* - Calculate per-goal priority scores from 4 factors
|
|
14
|
+
* - Allocate resource shares proportionally
|
|
15
|
+
* - Rebalance on 4 trigger types
|
|
16
|
+
* - Recommend strategy templates using vector similarity
|
|
17
|
+
*
|
|
18
|
+
* CrossGoalPortfolio does NOT manage strategies within a single goal —
|
|
19
|
+
* that remains the responsibility of PortfolioManager.
|
|
20
|
+
*/
|
|
21
|
+
export class CrossGoalPortfolio {
|
|
22
|
+
stateManager;
|
|
23
|
+
goalDependencyGraph;
|
|
24
|
+
vectorIndex;
|
|
25
|
+
embeddingClient;
|
|
26
|
+
config;
|
|
27
|
+
/** goalId → cached GoalPriorityFactors from the last calculation */
|
|
28
|
+
lastPriorities = new Map();
|
|
29
|
+
constructor(stateManager, goalDependencyGraph, vectorIndex, embeddingClient, config) {
|
|
30
|
+
this.stateManager = stateManager;
|
|
31
|
+
this.goalDependencyGraph = goalDependencyGraph;
|
|
32
|
+
this.vectorIndex = vectorIndex;
|
|
33
|
+
this.embeddingClient = embeddingClient;
|
|
34
|
+
this.config = CrossGoalPortfolioConfigSchema.parse(config ?? {});
|
|
35
|
+
}
|
|
36
|
+
// ─── Priority Calculation ───
|
|
37
|
+
/**
|
|
38
|
+
* Calculate priority factors for each goal in the provided list.
|
|
39
|
+
*
|
|
40
|
+
* The 4 factors and their weights:
|
|
41
|
+
* w1=0.35 deadline_urgency — how soon the goal must be finished
|
|
42
|
+
* w2=0.25 gap_severity — worst-case normalized gap across dimensions
|
|
43
|
+
* w3=0.25 dependency_weight — how many goals depend on this one
|
|
44
|
+
* w4=0.15 user_priority — user-specified priority (1-5 → 0-1)
|
|
45
|
+
*
|
|
46
|
+
* After the weighted sum is computed, synergy/conflict edges from
|
|
47
|
+
* GoalDependencyGraph adjust the final score before clamping to [0,1].
|
|
48
|
+
*
|
|
49
|
+
* @param goalIds — IDs of goals to evaluate (missing goals are skipped)
|
|
50
|
+
* @returns GoalPriorityFactors[] sorted by computed_priority descending
|
|
51
|
+
*/
|
|
52
|
+
calculateGoalPriorities(goalIds) {
|
|
53
|
+
if (goalIds.length === 0)
|
|
54
|
+
return [];
|
|
55
|
+
const totalGoals = goalIds.length;
|
|
56
|
+
const now = new Date();
|
|
57
|
+
const rawList = [];
|
|
58
|
+
for (const goalId of goalIds) {
|
|
59
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
60
|
+
if (!goal)
|
|
61
|
+
continue;
|
|
62
|
+
// deadline_urgency — use scoreDeadline with maxGap=1 as the
|
|
63
|
+
// normalized_weighted_gap input, then read the urgency value.
|
|
64
|
+
let deadlineUrgency = 0;
|
|
65
|
+
if (goal.deadline) {
|
|
66
|
+
const deadlineMs = new Date(goal.deadline).getTime();
|
|
67
|
+
const timeRemainingHours = (deadlineMs - now.getTime()) / (1000 * 60 * 60);
|
|
68
|
+
const result = scoreDeadline(1, timeRemainingHours);
|
|
69
|
+
// Normalize urgency to [0,1]. scoreDeadline with gap=1 means score == urgency.
|
|
70
|
+
// urgency >= 1 (at minimum). We normalise by capping at the urgency-at-zero cap.
|
|
71
|
+
// Use urgency directly but clamp to [0,1] after dividing by a reasonable max.
|
|
72
|
+
// default urgency_steepness=2, deadline_horizon=168h → urgencyAtZero = exp(2) ≈ 7.39
|
|
73
|
+
const urgencyAtZero = Math.exp(2); // exp(urgency_steepness)
|
|
74
|
+
deadlineUrgency = clamp(result.urgency / urgencyAtZero, 0, 1);
|
|
75
|
+
}
|
|
76
|
+
// gap_severity — max normalized_weighted_gap across all dimensions
|
|
77
|
+
// We approximate by treating each dimension's gap as proportional
|
|
78
|
+
// to how far it is from its threshold relative to a known scale.
|
|
79
|
+
// For simplicity (no GapCalculator instance injected), we derive a
|
|
80
|
+
// rough severity from the dimension values directly.
|
|
81
|
+
let gapSeverity = 0;
|
|
82
|
+
for (const dim of goal.dimensions) {
|
|
83
|
+
const dimGap = this._estimateDimensionGap(dim);
|
|
84
|
+
if (dimGap > gapSeverity) {
|
|
85
|
+
gapSeverity = dimGap;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
gapSeverity = clamp(gapSeverity, 0, 1);
|
|
89
|
+
// dependency_weight — how many goals in the provided list depend on this goal
|
|
90
|
+
const graph = this.goalDependencyGraph.getGraph();
|
|
91
|
+
const dependentCount = graph.edges.filter((e) => e.from_goal_id === goalId &&
|
|
92
|
+
e.type === "prerequisite" &&
|
|
93
|
+
e.status === "active" &&
|
|
94
|
+
goalIds.includes(e.to_goal_id)).length;
|
|
95
|
+
const dependencyWeight = totalGoals > 1 ? dependentCount / (totalGoals - 1) : 0;
|
|
96
|
+
// user_priority — extract from goal constraints or metadata
|
|
97
|
+
// Assume format "priority:N" (N in 1-5) anywhere in constraints
|
|
98
|
+
let userPriority = 0.5; // default
|
|
99
|
+
for (const constraint of goal.constraints) {
|
|
100
|
+
const match = constraint.match(/\bpriority[:\s=]+(\d+)\b/i);
|
|
101
|
+
if (match) {
|
|
102
|
+
const level = parseInt(match[1], 10);
|
|
103
|
+
userPriority = clamp(level / 5, 0, 1);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
rawList.push({
|
|
108
|
+
goalId,
|
|
109
|
+
goal,
|
|
110
|
+
deadlineUrgency,
|
|
111
|
+
gapSeverity,
|
|
112
|
+
dependencyWeight: clamp(dependencyWeight, 0, 1),
|
|
113
|
+
userPriority,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (rawList.length === 0)
|
|
117
|
+
return [];
|
|
118
|
+
// --- Step 2: compute weighted priority ---
|
|
119
|
+
const W1 = 0.35;
|
|
120
|
+
const W2 = 0.25;
|
|
121
|
+
const W3 = 0.25;
|
|
122
|
+
const W4 = 0.15;
|
|
123
|
+
const withBase = rawList.map((r) => {
|
|
124
|
+
const basePriority = W1 * r.deadlineUrgency +
|
|
125
|
+
W2 * r.gapSeverity +
|
|
126
|
+
W3 * r.dependencyWeight +
|
|
127
|
+
W4 * r.userPriority;
|
|
128
|
+
return { ...r, basePriority };
|
|
129
|
+
});
|
|
130
|
+
// --- Step 3: apply synergy / conflict adjustments ---
|
|
131
|
+
const synergyBonus = this.config.synergy_bonus / 2; // split the config bonus equally
|
|
132
|
+
const CONFLICT_PENALTY = 0.15;
|
|
133
|
+
const goalIdSet = new Set(rawList.map((r) => r.goalId));
|
|
134
|
+
// Build a lookup: goalId → index in withBase
|
|
135
|
+
const indexMap = new Map();
|
|
136
|
+
withBase.forEach((r, i) => indexMap.set(r.goalId, i));
|
|
137
|
+
// Adjust scores based on dependency edges between goals in the set
|
|
138
|
+
const adjustments = new Array(withBase.length).fill(0);
|
|
139
|
+
const graph = this.goalDependencyGraph.getGraph();
|
|
140
|
+
const seenPairs = new Set();
|
|
141
|
+
for (const edge of graph.edges) {
|
|
142
|
+
if (edge.status !== "active")
|
|
143
|
+
continue;
|
|
144
|
+
if (!goalIdSet.has(edge.from_goal_id) || !goalIdSet.has(edge.to_goal_id))
|
|
145
|
+
continue;
|
|
146
|
+
const pairKey = [edge.from_goal_id, edge.to_goal_id].sort().join("||");
|
|
147
|
+
if (edge.type === "synergy") {
|
|
148
|
+
if (!seenPairs.has(pairKey)) {
|
|
149
|
+
seenPairs.add(pairKey);
|
|
150
|
+
const idxA = indexMap.get(edge.from_goal_id);
|
|
151
|
+
const idxB = indexMap.get(edge.to_goal_id);
|
|
152
|
+
if (idxA !== undefined)
|
|
153
|
+
adjustments[idxA] += synergyBonus;
|
|
154
|
+
if (idxB !== undefined)
|
|
155
|
+
adjustments[idxB] += synergyBonus;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (edge.type === "conflict") {
|
|
159
|
+
if (!seenPairs.has(pairKey)) {
|
|
160
|
+
seenPairs.add(pairKey);
|
|
161
|
+
// Penalise the lower-priority goal
|
|
162
|
+
const idxA = indexMap.get(edge.from_goal_id);
|
|
163
|
+
const idxB = indexMap.get(edge.to_goal_id);
|
|
164
|
+
if (idxA !== undefined && idxB !== undefined) {
|
|
165
|
+
const scoreA = withBase[idxA].basePriority;
|
|
166
|
+
const scoreB = withBase[idxB].basePriority;
|
|
167
|
+
if (scoreA <= scoreB) {
|
|
168
|
+
adjustments[idxA] -= CONFLICT_PENALTY;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
adjustments[idxB] -= CONFLICT_PENALTY;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// --- Step 4: produce final factors ---
|
|
178
|
+
const result = withBase.map((r, i) => {
|
|
179
|
+
const computedPriority = clamp(r.basePriority + (adjustments[i] ?? 0), 0, 1);
|
|
180
|
+
return {
|
|
181
|
+
goal_id: r.goalId,
|
|
182
|
+
deadline_urgency: r.deadlineUrgency,
|
|
183
|
+
gap_severity: r.gapSeverity,
|
|
184
|
+
dependency_weight: r.dependencyWeight,
|
|
185
|
+
user_priority: r.userPriority,
|
|
186
|
+
computed_priority: computedPriority,
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
// Sort descending by computed_priority
|
|
190
|
+
result.sort((a, b) => b.computed_priority - a.computed_priority);
|
|
191
|
+
// Cache for rebalance
|
|
192
|
+
for (const f of result) {
|
|
193
|
+
this.lastPriorities.set(f.goal_id, f);
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
// ─── Resource Allocation ───
|
|
198
|
+
/**
|
|
199
|
+
* Allocate resource shares across goals based on their priority scores.
|
|
200
|
+
*
|
|
201
|
+
* Rules:
|
|
202
|
+
* 1. If goals > max_concurrent_goals, lowest priority goals get allocation=0
|
|
203
|
+
* and are labelled "waiting".
|
|
204
|
+
* 2. Active goals (up to max_concurrent_goals) share 1.0 proportionally to
|
|
205
|
+
* computed_priority, with a floor of min_goal_share.
|
|
206
|
+
* 3. Sum of active allocations = 1.0.
|
|
207
|
+
*
|
|
208
|
+
* @param priorities — output from calculateGoalPriorities
|
|
209
|
+
* @param strategy — optional AllocationStrategy (default: 'priority')
|
|
210
|
+
* @param momentumMap — goalId → MomentumInfo, required when strategy.type === 'momentum'
|
|
211
|
+
* @param depSchedule — DependencySchedule, required when strategy.type === 'dependency_aware'
|
|
212
|
+
* @returns CrossGoalAllocation[] in the same order as priorities
|
|
213
|
+
*/
|
|
214
|
+
allocateResources(priorities, strategy, momentumMap, depSchedule) {
|
|
215
|
+
if (priorities.length === 0)
|
|
216
|
+
return [];
|
|
217
|
+
const { max_concurrent_goals, min_goal_share } = this.config;
|
|
218
|
+
// Split into active (top N) and waiting (rest), already sorted desc
|
|
219
|
+
const activeCount = Math.min(priorities.length, max_concurrent_goals);
|
|
220
|
+
const activePriorities = priorities.slice(0, activeCount);
|
|
221
|
+
const waitingPriorities = priorities.slice(activeCount);
|
|
222
|
+
// Build allocations for waiting goals (zero share)
|
|
223
|
+
const waitingAllocations = waitingPriorities.map((p) => ({
|
|
224
|
+
goal_id: p.goal_id,
|
|
225
|
+
priority: p.computed_priority,
|
|
226
|
+
resource_share: 0,
|
|
227
|
+
adjustment_reason: `waiting: exceeds max_concurrent_goals (${max_concurrent_goals})`,
|
|
228
|
+
}));
|
|
229
|
+
if (activePriorities.length === 0)
|
|
230
|
+
return waitingAllocations;
|
|
231
|
+
// Single goal gets everything
|
|
232
|
+
if (activePriorities.length === 1) {
|
|
233
|
+
return [
|
|
234
|
+
{
|
|
235
|
+
goal_id: activePriorities[0].goal_id,
|
|
236
|
+
priority: activePriorities[0].computed_priority,
|
|
237
|
+
resource_share: 1.0,
|
|
238
|
+
adjustment_reason: "sole active goal",
|
|
239
|
+
},
|
|
240
|
+
...waitingAllocations,
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
const n = activePriorities.length;
|
|
244
|
+
// --- Strategy-specific weight computation ---
|
|
245
|
+
const strategyType = strategy?.type ?? "priority";
|
|
246
|
+
let weights;
|
|
247
|
+
let strategyReason;
|
|
248
|
+
if (strategyType === "equal") {
|
|
249
|
+
weights = activePriorities.map(() => 1);
|
|
250
|
+
strategyReason = "equal allocation";
|
|
251
|
+
}
|
|
252
|
+
else if (strategyType === "momentum" && momentumMap && momentumMap.size > 0) {
|
|
253
|
+
const momentumWeight = strategy?.momentumWeight ?? 0.5;
|
|
254
|
+
// Blend priority and momentum velocity
|
|
255
|
+
weights = activePriorities.map((p) => {
|
|
256
|
+
const mom = momentumMap.get(p.goal_id);
|
|
257
|
+
const vel = mom ? Math.max(mom.velocity, 0) : 0;
|
|
258
|
+
return (1 - momentumWeight) * p.computed_priority + momentumWeight * vel;
|
|
259
|
+
});
|
|
260
|
+
strategyReason = "momentum-weighted";
|
|
261
|
+
}
|
|
262
|
+
else if (strategyType === "dependency_aware" && depSchedule) {
|
|
263
|
+
// Goals on critical path and unblocked goals get a boost
|
|
264
|
+
const criticalSet = new Set(depSchedule.criticalPath);
|
|
265
|
+
// Determine which goals are currently unblocked (in phase 0 or phase whose blockedBy are empty)
|
|
266
|
+
const unblockedGoals = new Set();
|
|
267
|
+
for (const phase of depSchedule.phases) {
|
|
268
|
+
if (phase.blockedBy.length === 0) {
|
|
269
|
+
for (const id of phase.goalIds)
|
|
270
|
+
unblockedGoals.add(id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
weights = activePriorities.map((p) => {
|
|
274
|
+
let w = p.computed_priority;
|
|
275
|
+
if (criticalSet.has(p.goal_id))
|
|
276
|
+
w *= 1.5;
|
|
277
|
+
if (unblockedGoals.has(p.goal_id))
|
|
278
|
+
w *= 1.2;
|
|
279
|
+
return w;
|
|
280
|
+
});
|
|
281
|
+
strategyReason = "dependency_aware";
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// Default: priority-proportional
|
|
285
|
+
weights = activePriorities.map((p) => p.computed_priority);
|
|
286
|
+
strategyReason = "priority";
|
|
287
|
+
}
|
|
288
|
+
// Proportional allocation with guaranteed min_goal_share floor.
|
|
289
|
+
//
|
|
290
|
+
// Algorithm:
|
|
291
|
+
// 1. Reserve min_goal_share for every active goal.
|
|
292
|
+
// 2. Distribute the remaining budget (1 - n * min_goal_share) proportionally
|
|
293
|
+
// by computed weight.
|
|
294
|
+
// 3. This guarantees every active goal has at least min_goal_share.
|
|
295
|
+
//
|
|
296
|
+
// Edge case: if n * min_goal_share >= 1 (too many goals for the floor to
|
|
297
|
+
// allow proportional distribution), fall back to equal distribution.
|
|
298
|
+
const reservedTotal = n * min_goal_share;
|
|
299
|
+
let finalShares;
|
|
300
|
+
if (reservedTotal >= 1) {
|
|
301
|
+
// No room for proportional top-up — give everyone an equal share
|
|
302
|
+
finalShares = activePriorities.map(() => 1 / n);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
const remainingBudget = 1 - reservedTotal;
|
|
306
|
+
const totalWeight = weights.reduce((sum, w) => sum + w, 0);
|
|
307
|
+
if (totalWeight === 0) {
|
|
308
|
+
// All zero — split remaining budget equally
|
|
309
|
+
finalShares = activePriorities.map(() => min_goal_share + remainingBudget / n);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
finalShares = weights.map((w) => min_goal_share + remainingBudget * (w / totalWeight));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// Track which goals received the floor for reason strings
|
|
316
|
+
const totalWeightForReason = weights.reduce((sum, w) => sum + w, 0);
|
|
317
|
+
const rawShares = totalWeightForReason === 0
|
|
318
|
+
? activePriorities.map(() => 1 / n)
|
|
319
|
+
: weights.map((w) => w / totalWeightForReason);
|
|
320
|
+
const activeAllocations = activePriorities.map((p, i) => {
|
|
321
|
+
const share = finalShares[i];
|
|
322
|
+
const raw = rawShares[i];
|
|
323
|
+
let reason;
|
|
324
|
+
if (raw < min_goal_share) {
|
|
325
|
+
reason = `min_goal_share floor applied (raw=${raw.toFixed(3)}, strategy=${strategyReason})`;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
reason = `${strategyReason}: weight=${weights[i].toFixed(3)}`;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
goal_id: p.goal_id,
|
|
332
|
+
priority: p.computed_priority,
|
|
333
|
+
resource_share: share,
|
|
334
|
+
adjustment_reason: reason,
|
|
335
|
+
};
|
|
336
|
+
});
|
|
337
|
+
return [...activeAllocations, ...waitingAllocations];
|
|
338
|
+
}
|
|
339
|
+
// ─── Rebalancing ───
|
|
340
|
+
/**
|
|
341
|
+
* Recalculate priorities for all currently active goals and produce a new
|
|
342
|
+
* allocation plan.
|
|
343
|
+
*
|
|
344
|
+
* @param trigger — what caused this rebalance
|
|
345
|
+
* @param goalIds — explicit list of goal IDs to consider; if omitted, the
|
|
346
|
+
* IDs from the last calculateGoalPriorities call are used
|
|
347
|
+
*/
|
|
348
|
+
rebalanceGoals(trigger, goalIds) {
|
|
349
|
+
const ids = goalIds ?? Array.from(this.lastPriorities.keys());
|
|
350
|
+
const priorities = this.calculateGoalPriorities(ids);
|
|
351
|
+
const allocations = this.allocateResources(priorities);
|
|
352
|
+
return {
|
|
353
|
+
timestamp: new Date().toISOString(),
|
|
354
|
+
allocations,
|
|
355
|
+
triggered_by: trigger,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
// ─── Template Recommendation ───
|
|
359
|
+
/**
|
|
360
|
+
* Search the VectorIndex for strategy templates that match the given goal.
|
|
361
|
+
*
|
|
362
|
+
* Matching is based on:
|
|
363
|
+
* 1. Semantic similarity between the goal text and template hypothesis_pattern
|
|
364
|
+
* 2. domain_tags overlap (at least 1 tag in common with the goal's domain tags)
|
|
365
|
+
* 3. Final ranking: similarity × effectiveness_score (descending)
|
|
366
|
+
*
|
|
367
|
+
* The caller is responsible for having added StrategyTemplate objects to the
|
|
368
|
+
* VectorIndex with their `template_id` as the entry id and metadata shaped
|
|
369
|
+
* as StrategyTemplate fields.
|
|
370
|
+
*
|
|
371
|
+
* @param goalId — goal for which templates are requested
|
|
372
|
+
* @param vectorIndex — the index to search (typically the instance-level one,
|
|
373
|
+
* but callers may pass a different one for testing)
|
|
374
|
+
* @param limit — number of results to return (default 3)
|
|
375
|
+
*/
|
|
376
|
+
async getRecommendedTemplates(goalId, vectorIndex, limit = 3) {
|
|
377
|
+
const goal = this.stateManager.loadGoal(goalId);
|
|
378
|
+
if (!goal)
|
|
379
|
+
return [];
|
|
380
|
+
// Build a query string from the goal
|
|
381
|
+
const queryText = [goal.title, goal.description, ...goal.constraints]
|
|
382
|
+
.filter(Boolean)
|
|
383
|
+
.join(" ");
|
|
384
|
+
if (!queryText.trim())
|
|
385
|
+
return [];
|
|
386
|
+
// Search index — retrieve more than `limit` so we can filter by domain_tags
|
|
387
|
+
const searchResults = await vectorIndex.search(queryText, limit * 5);
|
|
388
|
+
if (searchResults.length === 0)
|
|
389
|
+
return [];
|
|
390
|
+
// Derive goal domain tags from constraints (format "domain:tag") or title words
|
|
391
|
+
const goalDomainTags = this._extractDomainTags(goal);
|
|
392
|
+
// Filter and score
|
|
393
|
+
const scored = [];
|
|
394
|
+
for (const result of searchResults) {
|
|
395
|
+
const meta = result.metadata;
|
|
396
|
+
// Must have the required StrategyTemplate fields in metadata
|
|
397
|
+
if (typeof meta["template_id"] !== "string" ||
|
|
398
|
+
typeof meta["hypothesis_pattern"] !== "string" ||
|
|
399
|
+
!Array.isArray(meta["domain_tags"]) ||
|
|
400
|
+
typeof meta["effectiveness_score"] !== "number") {
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
const domainTags = meta["domain_tags"];
|
|
404
|
+
const effectivenessScore = meta["effectiveness_score"];
|
|
405
|
+
// Require at least 1 domain tag overlap — unless goal has no tags (then include all)
|
|
406
|
+
if (goalDomainTags.length > 0) {
|
|
407
|
+
const overlap = domainTags.filter((t) => goalDomainTags.includes(t)).length;
|
|
408
|
+
if (overlap < 1)
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const template = {
|
|
412
|
+
template_id: meta["template_id"],
|
|
413
|
+
source_goal_id: typeof meta["source_goal_id"] === "string"
|
|
414
|
+
? meta["source_goal_id"]
|
|
415
|
+
: "",
|
|
416
|
+
source_strategy_id: typeof meta["source_strategy_id"] === "string"
|
|
417
|
+
? meta["source_strategy_id"]
|
|
418
|
+
: "",
|
|
419
|
+
hypothesis_pattern: meta["hypothesis_pattern"],
|
|
420
|
+
domain_tags: domainTags,
|
|
421
|
+
effectiveness_score: effectivenessScore,
|
|
422
|
+
applicable_dimensions: Array.isArray(meta["applicable_dimensions"])
|
|
423
|
+
? meta["applicable_dimensions"]
|
|
424
|
+
: [],
|
|
425
|
+
embedding_id: typeof meta["embedding_id"] === "string"
|
|
426
|
+
? meta["embedding_id"]
|
|
427
|
+
: null,
|
|
428
|
+
created_at: typeof meta["created_at"] === "string"
|
|
429
|
+
? meta["created_at"]
|
|
430
|
+
: new Date().toISOString(),
|
|
431
|
+
};
|
|
432
|
+
const finalScore = result.similarity * effectivenessScore;
|
|
433
|
+
scored.push({ template, finalScore });
|
|
434
|
+
}
|
|
435
|
+
// Sort by finalScore descending and return top `limit`
|
|
436
|
+
scored.sort((a, b) => b.finalScore - a.finalScore);
|
|
437
|
+
return scored.slice(0, limit).map((s) => s.template);
|
|
438
|
+
}
|
|
439
|
+
// ─── Momentum ───
|
|
440
|
+
/**
|
|
441
|
+
* Calculate momentum for a single goal based on recent state snapshots.
|
|
442
|
+
*
|
|
443
|
+
* @param goalId — goal to evaluate
|
|
444
|
+
* @param snapshots — array of recent progress values (0-1), ordered oldest → newest
|
|
445
|
+
* (typically last 5 iterations). Minimum 2 values required.
|
|
446
|
+
* @returns MomentumInfo
|
|
447
|
+
*/
|
|
448
|
+
calculateMomentum(goalId, snapshots) {
|
|
449
|
+
if (snapshots.length === 0) {
|
|
450
|
+
return { goalId, recentProgress: 0, velocity: 0, trend: "stalled" };
|
|
451
|
+
}
|
|
452
|
+
if (snapshots.length === 1) {
|
|
453
|
+
return { goalId, recentProgress: 0, velocity: 0, trend: "stalled" };
|
|
454
|
+
}
|
|
455
|
+
// recentProgress = total delta from first to last snapshot
|
|
456
|
+
const recentProgress = snapshots[snapshots.length - 1] - snapshots[0];
|
|
457
|
+
// velocity = smoothed average per-step delta (EMA-style: weight recent steps more)
|
|
458
|
+
const deltas = [];
|
|
459
|
+
for (let i = 1; i < snapshots.length; i++) {
|
|
460
|
+
deltas.push(snapshots[i] - snapshots[i - 1]);
|
|
461
|
+
}
|
|
462
|
+
// Simple smoothed velocity: weighted average where later deltas have higher weight
|
|
463
|
+
let weightedSum = 0;
|
|
464
|
+
let weightTotal = 0;
|
|
465
|
+
for (let i = 0; i < deltas.length; i++) {
|
|
466
|
+
const w = i + 1; // weight increases for more recent deltas
|
|
467
|
+
weightedSum += deltas[i] * w;
|
|
468
|
+
weightTotal += w;
|
|
469
|
+
}
|
|
470
|
+
const velocity = weightTotal > 0 ? weightedSum / weightTotal : 0;
|
|
471
|
+
// Trend detection:
|
|
472
|
+
// stalled: velocity ≈ 0 (< 0.005)
|
|
473
|
+
// accelerating: later half average > earlier half average
|
|
474
|
+
// decelerating: later half average < earlier half average (by ≥ threshold)
|
|
475
|
+
// steady: otherwise
|
|
476
|
+
let trend;
|
|
477
|
+
const STALL_THRESHOLD = 0.005;
|
|
478
|
+
if (Math.abs(velocity) < STALL_THRESHOLD) {
|
|
479
|
+
trend = "stalled";
|
|
480
|
+
}
|
|
481
|
+
else if (deltas.length >= 2) {
|
|
482
|
+
const mid = Math.floor(deltas.length / 2);
|
|
483
|
+
const earlyAvg = deltas.slice(0, mid).reduce((s, d) => s + d, 0) / mid;
|
|
484
|
+
const lateAvg = deltas.slice(mid).reduce((s, d) => s + d, 0) / (deltas.length - mid);
|
|
485
|
+
const ACCEL_THRESHOLD = 0.002;
|
|
486
|
+
if (lateAvg > earlyAvg + ACCEL_THRESHOLD) {
|
|
487
|
+
trend = "accelerating";
|
|
488
|
+
}
|
|
489
|
+
else if (lateAvg < earlyAvg - ACCEL_THRESHOLD) {
|
|
490
|
+
trend = "decelerating";
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
trend = "steady";
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
// Only 1 delta — classify by sign
|
|
498
|
+
trend = velocity > 0 ? "steady" : "stalled";
|
|
499
|
+
}
|
|
500
|
+
return { goalId, recentProgress, velocity, trend };
|
|
501
|
+
}
|
|
502
|
+
// ─── Dependency Scheduling ───
|
|
503
|
+
/**
|
|
504
|
+
* Build a phased dependency schedule for the given goals using the provided
|
|
505
|
+
* GoalDependencyGraph instance.
|
|
506
|
+
*
|
|
507
|
+
* The schedule uses topological sort to group goals into phases where all
|
|
508
|
+
* goals in a phase can run concurrently. Phase 0 contains goals with no
|
|
509
|
+
* prerequisites; subsequent phases contain goals whose prerequisites are
|
|
510
|
+
* all satisfied by earlier phases.
|
|
511
|
+
*
|
|
512
|
+
* The critical path is the longest chain of prerequisite edges through the
|
|
513
|
+
* DAG (measured in number of nodes).
|
|
514
|
+
*
|
|
515
|
+
* @param goalIds — IDs of goals to schedule
|
|
516
|
+
* @param graph — the GoalDependencyGraph instance to query
|
|
517
|
+
* @returns DependencySchedule
|
|
518
|
+
*/
|
|
519
|
+
buildDependencySchedule(goalIds, graph) {
|
|
520
|
+
if (goalIds.length === 0) {
|
|
521
|
+
return { phases: [], criticalPath: [] };
|
|
522
|
+
}
|
|
523
|
+
const goalSet = new Set(goalIds);
|
|
524
|
+
// Build adjacency: prereqMap[child] = Set of parents that must complete first
|
|
525
|
+
const prereqMap = new Map();
|
|
526
|
+
for (const id of goalIds) {
|
|
527
|
+
prereqMap.set(id, new Set());
|
|
528
|
+
}
|
|
529
|
+
for (const id of goalIds) {
|
|
530
|
+
const blockers = graph.getBlockingGoals(id).filter((b) => goalSet.has(b));
|
|
531
|
+
for (const blocker of blockers) {
|
|
532
|
+
prereqMap.get(id).add(blocker);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// Kahn's algorithm for topological sort into phases
|
|
536
|
+
const phases = [];
|
|
537
|
+
const completed = new Set();
|
|
538
|
+
const remaining = new Set(goalIds);
|
|
539
|
+
let phaseIndex = 0;
|
|
540
|
+
while (remaining.size > 0) {
|
|
541
|
+
// Goals whose all prerequisites are completed
|
|
542
|
+
const readyGoals = [];
|
|
543
|
+
for (const id of remaining) {
|
|
544
|
+
const prereqs = prereqMap.get(id);
|
|
545
|
+
const allSatisfied = [...prereqs].every((p) => completed.has(p));
|
|
546
|
+
if (allSatisfied) {
|
|
547
|
+
readyGoals.push(id);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (readyGoals.length === 0) {
|
|
551
|
+
// Cycle detected or unresolvable — put all remaining in one phase
|
|
552
|
+
const cycleGoals = [...remaining];
|
|
553
|
+
const blockedBy = cycleGoals.flatMap((id) => [...(prereqMap.get(id) ?? [])].filter((p) => !completed.has(p)));
|
|
554
|
+
phases.push({
|
|
555
|
+
phase: phaseIndex,
|
|
556
|
+
goalIds: cycleGoals,
|
|
557
|
+
blockedBy: [...new Set(blockedBy)],
|
|
558
|
+
});
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
// Collect the set of blockers for this phase's goals
|
|
562
|
+
const phaseBlockedBy = readyGoals.flatMap((id) => [...(prereqMap.get(id) ?? [])]);
|
|
563
|
+
phases.push({
|
|
564
|
+
phase: phaseIndex,
|
|
565
|
+
goalIds: readyGoals,
|
|
566
|
+
blockedBy: [...new Set(phaseBlockedBy)],
|
|
567
|
+
});
|
|
568
|
+
for (const id of readyGoals) {
|
|
569
|
+
completed.add(id);
|
|
570
|
+
remaining.delete(id);
|
|
571
|
+
}
|
|
572
|
+
phaseIndex++;
|
|
573
|
+
}
|
|
574
|
+
// Critical path: longest chain of prerequisite edges (BFS/DFS from each node)
|
|
575
|
+
const criticalPath = this._computeCriticalPath(goalIds, prereqMap);
|
|
576
|
+
return { phases, criticalPath };
|
|
577
|
+
}
|
|
578
|
+
// ─── Stall Rebalancing ───
|
|
579
|
+
/**
|
|
580
|
+
* Detect stalled goals and redistribute their resources to progressing goals.
|
|
581
|
+
*
|
|
582
|
+
* A goal is considered stalled if its MomentumInfo.trend === 'stalled'.
|
|
583
|
+
* Resources from stalled goals are redistributed proportionally to
|
|
584
|
+
* non-stalled goals based on their velocity.
|
|
585
|
+
*
|
|
586
|
+
* @param currentAllocations — current CrossGoalAllocation array
|
|
587
|
+
* @param momentumMap — goalId → MomentumInfo
|
|
588
|
+
* @returns array of RebalanceActions taken (empty if no stalled goals)
|
|
589
|
+
*/
|
|
590
|
+
rebalanceOnStall(currentAllocations, momentumMap) {
|
|
591
|
+
const actions = [];
|
|
592
|
+
if (currentAllocations.length === 0)
|
|
593
|
+
return actions;
|
|
594
|
+
const stalled = [];
|
|
595
|
+
const progressing = [];
|
|
596
|
+
for (const alloc of currentAllocations) {
|
|
597
|
+
const mom = momentumMap.get(alloc.goal_id);
|
|
598
|
+
if (!mom || mom.trend === "stalled") {
|
|
599
|
+
stalled.push(alloc);
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
progressing.push(alloc);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (stalled.length === 0)
|
|
606
|
+
return actions;
|
|
607
|
+
// Nothing to redistribute to
|
|
608
|
+
if (progressing.length === 0)
|
|
609
|
+
return actions;
|
|
610
|
+
// Calculate total share to redistribute
|
|
611
|
+
const redistributeTotal = stalled.reduce((s, a) => s + a.resource_share, 0);
|
|
612
|
+
// Compute target shares for progressing goals, weighted by velocity
|
|
613
|
+
const totalVelocity = progressing.reduce((s, a) => {
|
|
614
|
+
const mom = momentumMap.get(a.goal_id);
|
|
615
|
+
return s + Math.max(mom?.velocity ?? 0, 0);
|
|
616
|
+
}, 0);
|
|
617
|
+
for (const alloc of stalled) {
|
|
618
|
+
actions.push({
|
|
619
|
+
goalId: alloc.goal_id,
|
|
620
|
+
action: "reduce",
|
|
621
|
+
reason: "stalled: momentum velocity ≈ 0",
|
|
622
|
+
previousShare: alloc.resource_share,
|
|
623
|
+
newShare: 0,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
for (const alloc of progressing) {
|
|
627
|
+
const mom = momentumMap.get(alloc.goal_id);
|
|
628
|
+
const vel = Math.max(mom?.velocity ?? 0, 0);
|
|
629
|
+
const bonus = totalVelocity > 0
|
|
630
|
+
? redistributeTotal * (vel / totalVelocity)
|
|
631
|
+
: redistributeTotal / progressing.length;
|
|
632
|
+
const newShare = clamp(alloc.resource_share + bonus, 0, 1);
|
|
633
|
+
actions.push({
|
|
634
|
+
goalId: alloc.goal_id,
|
|
635
|
+
action: "increase",
|
|
636
|
+
reason: `received share from stalled goals (velocity=${vel.toFixed(4)})`,
|
|
637
|
+
previousShare: alloc.resource_share,
|
|
638
|
+
newShare,
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
return actions;
|
|
642
|
+
}
|
|
643
|
+
// ─── Private helpers ───
|
|
644
|
+
/**
|
|
645
|
+
* Compute the critical path (longest prerequisite chain) among the given goals.
|
|
646
|
+
* Returns the sequence of goalIds on the critical path.
|
|
647
|
+
*/
|
|
648
|
+
_computeCriticalPath(goalIds, prereqMap) {
|
|
649
|
+
// dp[id] = longest path length ending at id (in nodes)
|
|
650
|
+
const dp = new Map();
|
|
651
|
+
const parent = new Map();
|
|
652
|
+
function longestFrom(id) {
|
|
653
|
+
const cached = dp.get(id);
|
|
654
|
+
if (cached !== undefined)
|
|
655
|
+
return cached;
|
|
656
|
+
const prereqs = prereqMap.get(id) ?? new Set();
|
|
657
|
+
if (prereqs.size === 0) {
|
|
658
|
+
dp.set(id, 1);
|
|
659
|
+
parent.set(id, null);
|
|
660
|
+
return 1;
|
|
661
|
+
}
|
|
662
|
+
let best = 0;
|
|
663
|
+
let bestParent = null;
|
|
664
|
+
for (const p of prereqs) {
|
|
665
|
+
const len = longestFrom(p);
|
|
666
|
+
if (len > best) {
|
|
667
|
+
best = len;
|
|
668
|
+
bestParent = p;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
dp.set(id, best + 1);
|
|
672
|
+
parent.set(id, bestParent);
|
|
673
|
+
return best + 1;
|
|
674
|
+
}
|
|
675
|
+
// Compute for all goals
|
|
676
|
+
for (const id of goalIds) {
|
|
677
|
+
longestFrom(id);
|
|
678
|
+
}
|
|
679
|
+
// Find the goal with the highest dp value
|
|
680
|
+
let maxLen = 0;
|
|
681
|
+
let maxGoal = goalIds[0] ?? "";
|
|
682
|
+
for (const id of goalIds) {
|
|
683
|
+
const len = dp.get(id) ?? 0;
|
|
684
|
+
if (len > maxLen) {
|
|
685
|
+
maxLen = len;
|
|
686
|
+
maxGoal = id;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (maxLen === 0)
|
|
690
|
+
return [];
|
|
691
|
+
// Reconstruct path by following parent pointers
|
|
692
|
+
const path = [];
|
|
693
|
+
let current = maxGoal;
|
|
694
|
+
while (current !== null) {
|
|
695
|
+
path.unshift(current);
|
|
696
|
+
current = parent.get(current) ?? null;
|
|
697
|
+
}
|
|
698
|
+
return path;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Produce a rough [0,1] severity for a single goal dimension.
|
|
702
|
+
*
|
|
703
|
+
* For numeric thresholds we compute gap / scale.
|
|
704
|
+
* For binary thresholds (present/match) we return 0 or 1.
|
|
705
|
+
* Returns 0 when the dimension is already satisfied.
|
|
706
|
+
*/
|
|
707
|
+
_estimateDimensionGap(dim) {
|
|
708
|
+
const { current_value, threshold } = dim;
|
|
709
|
+
if (current_value === null)
|
|
710
|
+
return 1;
|
|
711
|
+
switch (threshold.type) {
|
|
712
|
+
case "min": {
|
|
713
|
+
if (typeof current_value !== "number")
|
|
714
|
+
return 0;
|
|
715
|
+
const gap = threshold.value - current_value;
|
|
716
|
+
if (gap <= 0)
|
|
717
|
+
return 0;
|
|
718
|
+
return threshold.value !== 0 ? clamp(gap / threshold.value, 0, 1) : 1;
|
|
719
|
+
}
|
|
720
|
+
case "max": {
|
|
721
|
+
if (typeof current_value !== "number")
|
|
722
|
+
return 0;
|
|
723
|
+
const gap = current_value - threshold.value;
|
|
724
|
+
if (gap <= 0)
|
|
725
|
+
return 0;
|
|
726
|
+
return threshold.value !== 0 ? clamp(gap / threshold.value, 0, 1) : 1;
|
|
727
|
+
}
|
|
728
|
+
case "range": {
|
|
729
|
+
if (typeof current_value !== "number")
|
|
730
|
+
return 0;
|
|
731
|
+
const span = threshold.high - threshold.low;
|
|
732
|
+
if (current_value < threshold.low) {
|
|
733
|
+
const gap = threshold.low - current_value;
|
|
734
|
+
return span > 0 ? clamp(gap / span, 0, 1) : 1;
|
|
735
|
+
}
|
|
736
|
+
if (current_value > threshold.high) {
|
|
737
|
+
const gap = current_value - threshold.high;
|
|
738
|
+
return span > 0 ? clamp(gap / span, 0, 1) : 1;
|
|
739
|
+
}
|
|
740
|
+
return 0;
|
|
741
|
+
}
|
|
742
|
+
case "present": {
|
|
743
|
+
return current_value ? 0 : 1;
|
|
744
|
+
}
|
|
745
|
+
case "match": {
|
|
746
|
+
return current_value === threshold.value ? 0 : 1;
|
|
747
|
+
}
|
|
748
|
+
default:
|
|
749
|
+
return 0;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Extract domain tags from a goal's constraints and title.
|
|
754
|
+
* Recognises constraints with format "domain:tagname" or "tag:tagname".
|
|
755
|
+
*/
|
|
756
|
+
_extractDomainTags(goal) {
|
|
757
|
+
const tags = [];
|
|
758
|
+
for (const constraint of goal.constraints) {
|
|
759
|
+
const match = constraint.match(/^(?:domain|tag)[:\s]+(.+)$/i);
|
|
760
|
+
if (match) {
|
|
761
|
+
tags.push(match[1].trim().toLowerCase());
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return tags;
|
|
765
|
+
}
|
|
766
|
+
// ─── Allocation Map ───
|
|
767
|
+
/**
|
|
768
|
+
* Get a goal_id → resource_share map for the given goal IDs.
|
|
769
|
+
*
|
|
770
|
+
* Recomputes allocations based on current goal states.
|
|
771
|
+
* Returns a Map suitable for use by PortfolioManager.selectNextStrategyAcrossGoals().
|
|
772
|
+
*/
|
|
773
|
+
getAllocationMap(goalIds) {
|
|
774
|
+
const priorities = this.calculateGoalPriorities(goalIds);
|
|
775
|
+
const allocations = this.allocateResources(priorities);
|
|
776
|
+
const map = new Map();
|
|
777
|
+
for (const alloc of allocations) {
|
|
778
|
+
map.set(alloc.goal_id, alloc.resource_share);
|
|
779
|
+
}
|
|
780
|
+
// Fill in any goal IDs that were not computed (e.g. loadGoal returned null)
|
|
781
|
+
const equalShare = goalIds.length > 0 ? 1.0 / goalIds.length : 0;
|
|
782
|
+
for (const goalId of goalIds) {
|
|
783
|
+
if (!map.has(goalId)) {
|
|
784
|
+
map.set(goalId, equalShare);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return map;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
//# sourceMappingURL=cross-goal-portfolio.js.map
|