cognitive-core 0.0.2 → 0.1.2
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/.claude/settings.json +88 -0
- package/.claude/settings.local.json +11 -0
- package/.entire/settings.json +4 -0
- package/README.md +563 -107
- package/SKILL.md +193 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/mock-provider.d.ts +23 -0
- package/dist/agents/mock-provider.d.ts.map +1 -0
- package/dist/agents/mock-provider.js +71 -0
- package/dist/agents/mock-provider.js.map +1 -0
- package/dist/agents/types.d.ts +98 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +44 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/atlas.d.ts +334 -0
- package/dist/atlas.d.ts.map +1 -0
- package/dist/atlas.js +702 -0
- package/dist/atlas.js.map +1 -0
- package/dist/bin/cognitive-core.d.ts +18 -0
- package/dist/bin/cognitive-core.d.ts.map +1 -0
- package/dist/bin/cognitive-core.js +419 -0
- package/dist/bin/cognitive-core.js.map +1 -0
- package/dist/embeddings/bm25.d.ts +104 -0
- package/dist/embeddings/bm25.d.ts.map +1 -0
- package/dist/embeddings/bm25.js +264 -0
- package/dist/embeddings/bm25.js.map +1 -0
- package/dist/embeddings/index.d.ts +12 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +16 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/manager.d.ts +112 -0
- package/dist/embeddings/manager.d.ts.map +1 -0
- package/dist/embeddings/manager.js +215 -0
- package/dist/embeddings/manager.js.map +1 -0
- package/dist/embeddings/provider.d.ts +101 -0
- package/dist/embeddings/provider.d.ts.map +1 -0
- package/dist/embeddings/provider.js +235 -0
- package/dist/embeddings/provider.js.map +1 -0
- package/dist/embeddings/vector-store.d.ts +101 -0
- package/dist/embeddings/vector-store.d.ts.map +1 -0
- package/dist/embeddings/vector-store.js +256 -0
- package/dist/embeddings/vector-store.js.map +1 -0
- package/dist/factory.d.ts +193 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +109 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +32 -453
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -509
- package/dist/index.js.map +1 -0
- package/dist/learning/analyzer.d.ts +110 -0
- package/dist/learning/analyzer.d.ts.map +1 -0
- package/dist/learning/analyzer.js +213 -0
- package/dist/learning/analyzer.js.map +1 -0
- package/dist/learning/effectiveness.d.ts +158 -0
- package/dist/learning/effectiveness.d.ts.map +1 -0
- package/dist/learning/effectiveness.js +251 -0
- package/dist/learning/effectiveness.js.map +1 -0
- package/dist/learning/index.d.ts +12 -0
- package/dist/learning/index.d.ts.map +1 -0
- package/dist/learning/index.js +17 -0
- package/dist/learning/index.js.map +1 -0
- package/dist/learning/knowledge-extractor.d.ts +56 -0
- package/dist/learning/knowledge-extractor.d.ts.map +1 -0
- package/dist/learning/knowledge-extractor.js +336 -0
- package/dist/learning/knowledge-extractor.js.map +1 -0
- package/dist/learning/llm-extractor.d.ts +88 -0
- package/dist/learning/llm-extractor.d.ts.map +1 -0
- package/dist/learning/llm-extractor.js +372 -0
- package/dist/learning/llm-extractor.js.map +1 -0
- package/dist/learning/meta-learner.d.ts +87 -0
- package/dist/learning/meta-learner.d.ts.map +1 -0
- package/dist/learning/meta-learner.js +398 -0
- package/dist/learning/meta-learner.js.map +1 -0
- package/dist/learning/pipeline.d.ts +89 -0
- package/dist/learning/pipeline.d.ts.map +1 -0
- package/dist/learning/pipeline.js +236 -0
- package/dist/learning/pipeline.js.map +1 -0
- package/dist/learning/playbook-extractor.d.ts +113 -0
- package/dist/learning/playbook-extractor.d.ts.map +1 -0
- package/dist/learning/playbook-extractor.js +523 -0
- package/dist/learning/playbook-extractor.js.map +1 -0
- package/dist/learning/team-ingester.d.ts +152 -0
- package/dist/learning/team-ingester.d.ts.map +1 -0
- package/dist/learning/team-ingester.js +333 -0
- package/dist/learning/team-ingester.js.map +1 -0
- package/dist/learning/team-meta-learner.d.ts +50 -0
- package/dist/learning/team-meta-learner.d.ts.map +1 -0
- package/dist/learning/team-meta-learner.js +417 -0
- package/dist/learning/team-meta-learner.js.map +1 -0
- package/dist/learning/team-pipeline.d.ts +76 -0
- package/dist/learning/team-pipeline.d.ts.map +1 -0
- package/dist/learning/team-pipeline.js +266 -0
- package/dist/learning/team-pipeline.js.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts +41 -0
- package/dist/learning/trajectory-sources/dataclaw.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/dataclaw.js +330 -0
- package/dist/learning/trajectory-sources/dataclaw.js.map +1 -0
- package/dist/learning/trajectory-sources/entire.d.ts +28 -0
- package/dist/learning/trajectory-sources/entire.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/entire.js +182 -0
- package/dist/learning/trajectory-sources/entire.js.map +1 -0
- package/dist/learning/trajectory-sources/file.d.ts +23 -0
- package/dist/learning/trajectory-sources/file.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/file.js +101 -0
- package/dist/learning/trajectory-sources/file.js.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts +36 -0
- package/dist/learning/trajectory-sources/huggingface.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/huggingface.js +157 -0
- package/dist/learning/trajectory-sources/huggingface.js.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts +21 -0
- package/dist/learning/trajectory-sources/in-memory.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/in-memory.js +43 -0
- package/dist/learning/trajectory-sources/in-memory.js.map +1 -0
- package/dist/learning/trajectory-sources/index.d.ts +7 -0
- package/dist/learning/trajectory-sources/index.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/index.js +7 -0
- package/dist/learning/trajectory-sources/index.js.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts +24 -0
- package/dist/learning/trajectory-sources/pipeline.d.ts.map +1 -0
- package/dist/learning/trajectory-sources/pipeline.js +47 -0
- package/dist/learning/trajectory-sources/pipeline.js.map +1 -0
- package/dist/learning/usage-inference.d.ts +82 -0
- package/dist/learning/usage-inference.d.ts.map +1 -0
- package/dist/learning/usage-inference.js +261 -0
- package/dist/learning/usage-inference.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +6 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/playbook-server.d.ts +120 -0
- package/dist/mcp/playbook-server.d.ts.map +1 -0
- package/dist/mcp/playbook-server.js +427 -0
- package/dist/mcp/playbook-server.js.map +1 -0
- package/dist/memory/curated-loader.d.ts +62 -0
- package/dist/memory/curated-loader.d.ts.map +1 -0
- package/dist/memory/curated-loader.js +106 -0
- package/dist/memory/curated-loader.js.map +1 -0
- package/dist/memory/experience.d.ts +122 -0
- package/dist/memory/experience.d.ts.map +1 -0
- package/dist/memory/experience.js +392 -0
- package/dist/memory/experience.js.map +1 -0
- package/dist/memory/graph-layers/base.d.ts +29 -0
- package/dist/memory/graph-layers/base.d.ts.map +1 -0
- package/dist/memory/graph-layers/base.js +143 -0
- package/dist/memory/graph-layers/base.js.map +1 -0
- package/dist/memory/graph-layers/causal.d.ts +14 -0
- package/dist/memory/graph-layers/causal.d.ts.map +1 -0
- package/dist/memory/graph-layers/causal.js +14 -0
- package/dist/memory/graph-layers/causal.js.map +1 -0
- package/dist/memory/graph-layers/entity.d.ts +14 -0
- package/dist/memory/graph-layers/entity.d.ts.map +1 -0
- package/dist/memory/graph-layers/entity.js +14 -0
- package/dist/memory/graph-layers/entity.js.map +1 -0
- package/dist/memory/graph-layers/index.d.ts +6 -0
- package/dist/memory/graph-layers/index.d.ts.map +1 -0
- package/dist/memory/graph-layers/index.js +6 -0
- package/dist/memory/graph-layers/index.js.map +1 -0
- package/dist/memory/graph-layers/semantic.d.ts +14 -0
- package/dist/memory/graph-layers/semantic.d.ts.map +1 -0
- package/dist/memory/graph-layers/semantic.js +14 -0
- package/dist/memory/graph-layers/semantic.js.map +1 -0
- package/dist/memory/graph-layers/temporal.d.ts +14 -0
- package/dist/memory/graph-layers/temporal.d.ts.map +1 -0
- package/dist/memory/graph-layers/temporal.js +14 -0
- package/dist/memory/graph-layers/temporal.js.map +1 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +19 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/knowledge-bank.d.ts +220 -0
- package/dist/memory/knowledge-bank.d.ts.map +1 -0
- package/dist/memory/knowledge-bank.js +1003 -0
- package/dist/memory/knowledge-bank.js.map +1 -0
- package/dist/memory/knowledge-defrag.d.ts +49 -0
- package/dist/memory/knowledge-defrag.d.ts.map +1 -0
- package/dist/memory/knowledge-defrag.js +257 -0
- package/dist/memory/knowledge-defrag.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +41 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +273 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- package/dist/memory/meta.d.ts +90 -0
- package/dist/memory/meta.d.ts.map +1 -0
- package/dist/memory/meta.js +362 -0
- package/dist/memory/meta.js.map +1 -0
- package/dist/memory/playbook.d.ts +133 -0
- package/dist/memory/playbook.d.ts.map +1 -0
- package/dist/memory/playbook.js +357 -0
- package/dist/memory/playbook.js.map +1 -0
- package/dist/memory/search-provider.d.ts +31 -0
- package/dist/memory/search-provider.d.ts.map +1 -0
- package/dist/memory/search-provider.js +2 -0
- package/dist/memory/search-provider.js.map +1 -0
- package/dist/memory/search-providers/index.d.ts +3 -0
- package/dist/memory/search-providers/index.d.ts.map +1 -0
- package/dist/memory/search-providers/index.js +3 -0
- package/dist/memory/search-providers/index.js.map +1 -0
- package/dist/memory/search-providers/minimem.d.ts +43 -0
- package/dist/memory/search-providers/minimem.d.ts.map +1 -0
- package/dist/memory/search-providers/minimem.js +56 -0
- package/dist/memory/search-providers/minimem.js.map +1 -0
- package/dist/memory/search-providers/text-similarity.d.ts +15 -0
- package/dist/memory/search-providers/text-similarity.d.ts.map +1 -0
- package/dist/memory/search-providers/text-similarity.js +21 -0
- package/dist/memory/search-providers/text-similarity.js.map +1 -0
- package/dist/memory/skill-exporter.d.ts +75 -0
- package/dist/memory/skill-exporter.d.ts.map +1 -0
- package/dist/memory/skill-exporter.js +248 -0
- package/dist/memory/skill-exporter.js.map +1 -0
- package/dist/memory/system.d.ts +179 -0
- package/dist/memory/system.d.ts.map +1 -0
- package/dist/memory/system.js +421 -0
- package/dist/memory/system.js.map +1 -0
- package/dist/memory/team-experience.d.ts +298 -0
- package/dist/memory/team-experience.d.ts.map +1 -0
- package/dist/memory/team-experience.js +355 -0
- package/dist/memory/team-experience.js.map +1 -0
- package/dist/runtime/backends/acp-protocol.d.ts +49 -0
- package/dist/runtime/backends/acp-protocol.d.ts.map +1 -0
- package/dist/runtime/backends/acp-protocol.js +166 -0
- package/dist/runtime/backends/acp-protocol.js.map +1 -0
- package/dist/runtime/backends/acp.d.ts +67 -0
- package/dist/runtime/backends/acp.d.ts.map +1 -0
- package/dist/runtime/backends/acp.js +166 -0
- package/dist/runtime/backends/acp.js.map +1 -0
- package/dist/runtime/backends/index.d.ts +7 -0
- package/dist/runtime/backends/index.d.ts.map +1 -0
- package/dist/runtime/backends/index.js +8 -0
- package/dist/runtime/backends/index.js.map +1 -0
- package/dist/runtime/backends/macro-agent.d.ts +104 -0
- package/dist/runtime/backends/macro-agent.d.ts.map +1 -0
- package/dist/runtime/backends/macro-agent.js +107 -0
- package/dist/runtime/backends/macro-agent.js.map +1 -0
- package/dist/runtime/backends/mock.d.ts +67 -0
- package/dist/runtime/backends/mock.d.ts.map +1 -0
- package/dist/runtime/backends/mock.js +153 -0
- package/dist/runtime/backends/mock.js.map +1 -0
- package/dist/runtime/backends/subprocess.d.ts +56 -0
- package/dist/runtime/backends/subprocess.d.ts.map +1 -0
- package/dist/runtime/backends/subprocess.js +260 -0
- package/dist/runtime/backends/subprocess.js.map +1 -0
- package/dist/runtime/compute-provider.d.ts +87 -0
- package/dist/runtime/compute-provider.d.ts.map +1 -0
- package/dist/runtime/compute-provider.js +87 -0
- package/dist/runtime/compute-provider.js.map +1 -0
- package/dist/runtime/flows/learning.d.ts +73 -0
- package/dist/runtime/flows/learning.d.ts.map +1 -0
- package/dist/runtime/flows/learning.js +116 -0
- package/dist/runtime/flows/learning.js.map +1 -0
- package/dist/runtime/flows/validation.d.ts +122 -0
- package/dist/runtime/flows/validation.d.ts.map +1 -0
- package/dist/runtime/flows/validation.js +223 -0
- package/dist/runtime/flows/validation.js.map +1 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/manager.d.ts +149 -0
- package/dist/runtime/manager.d.ts.map +1 -0
- package/dist/runtime/manager.js +535 -0
- package/dist/runtime/manager.js.map +1 -0
- package/dist/runtime/types.d.ts +176 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/search/evaluator.d.ts +109 -0
- package/dist/search/evaluator.d.ts.map +1 -0
- package/dist/search/evaluator.js +372 -0
- package/dist/search/evaluator.js.map +1 -0
- package/dist/search/index.d.ts +8 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +13 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/refinement-loop.d.ts +90 -0
- package/dist/search/refinement-loop.d.ts.map +1 -0
- package/dist/search/refinement-loop.js +316 -0
- package/dist/search/refinement-loop.js.map +1 -0
- package/dist/search/refinement-types.d.ts +154 -0
- package/dist/search/refinement-types.d.ts.map +1 -0
- package/dist/search/refinement-types.js +99 -0
- package/dist/search/refinement-types.js.map +1 -0
- package/dist/search/router.d.ts +61 -0
- package/dist/search/router.d.ts.map +1 -0
- package/dist/search/router.js +197 -0
- package/dist/search/router.js.map +1 -0
- package/dist/search/solver.d.ts +75 -0
- package/dist/search/solver.d.ts.map +1 -0
- package/dist/search/solver.js +216 -0
- package/dist/search/solver.js.map +1 -0
- package/dist/search/team-router.d.ts +91 -0
- package/dist/search/team-router.d.ts.map +1 -0
- package/dist/search/team-router.js +315 -0
- package/dist/search/team-router.js.map +1 -0
- package/dist/search/verification-runner.d.ts +125 -0
- package/dist/search/verification-runner.d.ts.map +1 -0
- package/dist/search/verification-runner.js +440 -0
- package/dist/search/verification-runner.js.map +1 -0
- package/dist/session-bank/git-reader.d.ts +39 -0
- package/dist/session-bank/git-reader.d.ts.map +1 -0
- package/dist/session-bank/git-reader.js +165 -0
- package/dist/session-bank/git-reader.js.map +1 -0
- package/dist/session-bank/index.d.ts +5 -0
- package/dist/session-bank/index.d.ts.map +1 -0
- package/dist/session-bank/index.js +4 -0
- package/dist/session-bank/index.js.map +1 -0
- package/dist/session-bank/parser.d.ts +39 -0
- package/dist/session-bank/parser.d.ts.map +1 -0
- package/dist/session-bank/parser.js +231 -0
- package/dist/session-bank/parser.js.map +1 -0
- package/dist/session-bank/session-bank.d.ts +35 -0
- package/dist/session-bank/session-bank.d.ts.map +1 -0
- package/dist/session-bank/session-bank.js +326 -0
- package/dist/session-bank/session-bank.js.map +1 -0
- package/dist/session-bank/types.d.ts +129 -0
- package/dist/session-bank/types.d.ts.map +1 -0
- package/dist/session-bank/types.js +7 -0
- package/dist/session-bank/types.js.map +1 -0
- package/dist/surfacing/index.d.ts +6 -0
- package/dist/surfacing/index.d.ts.map +1 -0
- package/dist/surfacing/index.js +5 -0
- package/dist/surfacing/index.js.map +1 -0
- package/dist/surfacing/publisher.d.ts +22 -0
- package/dist/surfacing/publisher.d.ts.map +1 -0
- package/dist/surfacing/publisher.js +9 -0
- package/dist/surfacing/publisher.js.map +1 -0
- package/dist/surfacing/skill-library.d.ts +170 -0
- package/dist/surfacing/skill-library.d.ts.map +1 -0
- package/dist/surfacing/skill-library.js +455 -0
- package/dist/surfacing/skill-library.js.map +1 -0
- package/dist/surfacing/skill-publisher.d.ts +43 -0
- package/dist/surfacing/skill-publisher.d.ts.map +1 -0
- package/dist/surfacing/skill-publisher.js +197 -0
- package/dist/surfacing/skill-publisher.js.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts +42 -0
- package/dist/surfacing/sqlite-storage-adapter.d.ts.map +1 -0
- package/dist/surfacing/sqlite-storage-adapter.js +207 -0
- package/dist/surfacing/sqlite-storage-adapter.js.map +1 -0
- package/dist/surfacing/team-skill-library.d.ts +180 -0
- package/dist/surfacing/team-skill-library.d.ts.map +1 -0
- package/dist/surfacing/team-skill-library.js +384 -0
- package/dist/surfacing/team-skill-library.js.map +1 -0
- package/dist/types/config.d.ts +2287 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +490 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dataclaw.d.ts +286 -0
- package/dist/types/dataclaw.d.ts.map +1 -0
- package/dist/types/dataclaw.js +84 -0
- package/dist/types/dataclaw.js.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +26 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge-graph.d.ts +148 -0
- package/dist/types/knowledge-graph.d.ts.map +1 -0
- package/dist/types/knowledge-graph.js +40 -0
- package/dist/types/knowledge-graph.js.map +1 -0
- package/dist/types/knowledge.d.ts +280 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +191 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/memory.d.ts +339 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +207 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/meta.d.ts +146 -0
- package/dist/types/meta.d.ts.map +1 -0
- package/dist/types/meta.js +51 -0
- package/dist/types/meta.js.map +1 -0
- package/dist/types/outcome.d.ts +42 -0
- package/dist/types/outcome.d.ts.map +1 -0
- package/dist/types/outcome.js +50 -0
- package/dist/types/outcome.js.map +1 -0
- package/dist/types/playbook.d.ts +119 -0
- package/dist/types/playbook.d.ts.map +1 -0
- package/dist/types/playbook.js +71 -0
- package/dist/types/playbook.js.map +1 -0
- package/dist/types/step.d.ts +44 -0
- package/dist/types/step.d.ts.map +1 -0
- package/dist/types/step.js +32 -0
- package/dist/types/step.js.map +1 -0
- package/dist/types/task.d.ts +91 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +39 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/team-meta.d.ts +160 -0
- package/dist/types/team-meta.d.ts.map +1 -0
- package/dist/types/team-meta.js +42 -0
- package/dist/types/team-meta.js.map +1 -0
- package/dist/types/team-playbook.d.ts +276 -0
- package/dist/types/team-playbook.d.ts.map +1 -0
- package/dist/types/team-playbook.js +85 -0
- package/dist/types/team-playbook.js.map +1 -0
- package/dist/types/team-trajectory.d.ts +305 -0
- package/dist/types/team-trajectory.d.ts.map +1 -0
- package/dist/types/team-trajectory.js +304 -0
- package/dist/types/team-trajectory.js.map +1 -0
- package/dist/types/trajectory-source.d.ts +39 -0
- package/dist/types/trajectory-source.d.ts.map +1 -0
- package/dist/types/trajectory-source.js +2 -0
- package/dist/types/trajectory-source.js.map +1 -0
- package/dist/types/trajectory.d.ts +221 -0
- package/dist/types/trajectory.d.ts.map +1 -0
- package/dist/types/trajectory.js +60 -0
- package/dist/types/trajectory.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +34 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +93 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/similarity.d.ts +31 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/utils/similarity.js +107 -0
- package/dist/utils/similarity.js.map +1 -0
- package/dist/utils/storage.d.ts +106 -0
- package/dist/utils/storage.d.ts.map +1 -0
- package/dist/utils/storage.js +203 -0
- package/dist/utils/storage.js.map +1 -0
- package/dist/utils/validation.d.ts +129 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +171 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/workspace/index.d.ts +6 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +11 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/runner.d.ts +50 -0
- package/dist/workspace/runner.d.ts.map +1 -0
- package/dist/workspace/runner.js +219 -0
- package/dist/workspace/runner.js.map +1 -0
- package/dist/workspace/skill-converter.d.ts +18 -0
- package/dist/workspace/skill-converter.d.ts.map +1 -0
- package/dist/workspace/skill-converter.js +257 -0
- package/dist/workspace/skill-converter.js.map +1 -0
- package/dist/workspace/templates/index.d.ts +11 -0
- package/dist/workspace/templates/index.d.ts.map +1 -0
- package/dist/workspace/templates/index.js +21 -0
- package/dist/workspace/templates/index.js.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts +25 -0
- package/dist/workspace/templates/knowledge-defrag.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-defrag.js +154 -0
- package/dist/workspace/templates/knowledge-defrag.js.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts +25 -0
- package/dist/workspace/templates/knowledge-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/knowledge-extraction.js +246 -0
- package/dist/workspace/templates/knowledge-extraction.js.map +1 -0
- package/dist/workspace/templates/meta-reflection.d.ts +47 -0
- package/dist/workspace/templates/meta-reflection.d.ts.map +1 -0
- package/dist/workspace/templates/meta-reflection.js +135 -0
- package/dist/workspace/templates/meta-reflection.js.map +1 -0
- package/dist/workspace/templates/playbook-extraction.d.ts +20 -0
- package/dist/workspace/templates/playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/playbook-extraction.js +189 -0
- package/dist/workspace/templates/playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/refinement-analysis.d.ts +31 -0
- package/dist/workspace/templates/refinement-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/refinement-analysis.js +107 -0
- package/dist/workspace/templates/refinement-analysis.js.map +1 -0
- package/dist/workspace/templates/solution-evaluation.d.ts +21 -0
- package/dist/workspace/templates/solution-evaluation.d.ts.map +1 -0
- package/dist/workspace/templates/solution-evaluation.js +131 -0
- package/dist/workspace/templates/solution-evaluation.js.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts +44 -0
- package/dist/workspace/templates/team-playbook-extraction.d.ts.map +1 -0
- package/dist/workspace/templates/team-playbook-extraction.js +497 -0
- package/dist/workspace/templates/team-playbook-extraction.js.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/team-trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/team-trajectory-analysis.js +442 -0
- package/dist/workspace/templates/team-trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts +19 -0
- package/dist/workspace/templates/trajectory-analysis.d.ts.map +1 -0
- package/dist/workspace/templates/trajectory-analysis.js +170 -0
- package/dist/workspace/templates/trajectory-analysis.js.map +1 -0
- package/dist/workspace/templates/usage-inference.d.ts +19 -0
- package/dist/workspace/templates/usage-inference.d.ts.map +1 -0
- package/dist/workspace/templates/usage-inference.js +125 -0
- package/dist/workspace/templates/usage-inference.js.map +1 -0
- package/dist/workspace/types.d.ts +145 -0
- package/dist/workspace/types.d.ts.map +1 -0
- package/dist/workspace/types.js +17 -0
- package/dist/workspace/types.js.map +1 -0
- package/docs/DESIGN-agentic-workspace.md +2057 -0
- package/docs/DESIGN-semantic-memory-knowledge-bank.md +1789 -0
- package/docs/DESIGN-session-bank.md +1134 -0
- package/docs/DESIGN-team-extraction-pipeline.md +1369 -0
- package/docs/DESIGN-workspace-migration.md +1079 -0
- package/docs/PLAN-agentic-workspace-implementation.md +717 -0
- package/docs/PLAN-graph-migration.md +299 -0
- package/docs/PLAN-session-bank-implementation.md +474 -0
- package/docs/PROPOSAL-team-aware-learning.md +1080 -0
- package/docs/RESEARCH-semantic-memory-knowledge-structures.md +517 -0
- package/docs/RESEARCH-team-trajectory-learning.md +553 -0
- package/gaps.md +204 -0
- package/package.json +67 -33
- package/references/agent-workspace/CLAUDE.md +74 -0
- package/references/agent-workspace/README.md +587 -0
- package/references/agent-workspace/media/banner.png +0 -0
- package/references/agent-workspace/package-lock.json +2061 -0
- package/references/agent-workspace/package.json +54 -0
- package/references/agent-workspace/src/handle.ts +122 -0
- package/references/agent-workspace/src/index.ts +32 -0
- package/references/agent-workspace/src/manager.ts +102 -0
- package/references/agent-workspace/src/readers/json.ts +71 -0
- package/references/agent-workspace/src/readers/markdown.ts +37 -0
- package/references/agent-workspace/src/readers/raw.ts +27 -0
- package/references/agent-workspace/src/types.ts +68 -0
- package/references/agent-workspace/src/validation.ts +93 -0
- package/references/agent-workspace/src/writers/json.ts +17 -0
- package/references/agent-workspace/src/writers/markdown.ts +27 -0
- package/references/agent-workspace/src/writers/raw.ts +22 -0
- package/references/agent-workspace/tests/errors.test.ts +652 -0
- package/references/agent-workspace/tests/handle.test.ts +144 -0
- package/references/agent-workspace/tests/manager.test.ts +124 -0
- package/references/agent-workspace/tests/readers.test.ts +205 -0
- package/references/agent-workspace/tests/validation.test.ts +196 -0
- package/references/agent-workspace/tests/writers.test.ts +108 -0
- package/references/agent-workspace/tsconfig.json +20 -0
- package/references/agent-workspace/tsup.config.ts +9 -0
- package/references/minimem/.claude/settings.json +7 -0
- package/references/minimem/.sudocode/issues.jsonl +18 -0
- package/references/minimem/.sudocode/specs.jsonl +1 -0
- package/references/minimem/CLAUDE.md +310 -0
- package/references/minimem/README.md +556 -0
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +10 -0
- package/references/minimem/claude-plugin/.mcp.json +7 -0
- package/references/minimem/claude-plugin/README.md +158 -0
- package/references/minimem/claude-plugin/commands/recall.md +47 -0
- package/references/minimem/claude-plugin/commands/remember.md +41 -0
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +272 -0
- package/references/minimem/claude-plugin/hooks/hooks.json +27 -0
- package/references/minimem/claude-plugin/hooks/session-end.sh +86 -0
- package/references/minimem/claude-plugin/hooks/session-start.sh +85 -0
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +108 -0
- package/references/minimem/package-lock.json +5373 -0
- package/references/minimem/package.json +60 -0
- package/references/minimem/scripts/postbuild.js +35 -0
- package/references/minimem/src/__tests__/edge-cases.test.ts +371 -0
- package/references/minimem/src/__tests__/errors.test.ts +265 -0
- package/references/minimem/src/__tests__/helpers.ts +199 -0
- package/references/minimem/src/__tests__/internal.test.ts +407 -0
- package/references/minimem/src/__tests__/knowledge.test.ts +287 -0
- package/references/minimem/src/__tests__/minimem.integration.test.ts +1127 -0
- package/references/minimem/src/__tests__/session.test.ts +190 -0
- package/references/minimem/src/cli/__tests__/commands.test.ts +759 -0
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +141 -0
- package/references/minimem/src/cli/commands/append.ts +76 -0
- package/references/minimem/src/cli/commands/config.ts +262 -0
- package/references/minimem/src/cli/commands/conflicts.ts +413 -0
- package/references/minimem/src/cli/commands/daemon.ts +169 -0
- package/references/minimem/src/cli/commands/index.ts +12 -0
- package/references/minimem/src/cli/commands/init.ts +88 -0
- package/references/minimem/src/cli/commands/mcp.ts +177 -0
- package/references/minimem/src/cli/commands/push-pull.ts +213 -0
- package/references/minimem/src/cli/commands/search.ts +158 -0
- package/references/minimem/src/cli/commands/status.ts +84 -0
- package/references/minimem/src/cli/commands/sync-init.ts +290 -0
- package/references/minimem/src/cli/commands/sync.ts +70 -0
- package/references/minimem/src/cli/commands/upsert.ts +197 -0
- package/references/minimem/src/cli/config.ts +584 -0
- package/references/minimem/src/cli/index.ts +264 -0
- package/references/minimem/src/cli/shared.ts +161 -0
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +152 -0
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +209 -0
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +118 -0
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +207 -0
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +476 -0
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +363 -0
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +255 -0
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +193 -0
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +178 -0
- package/references/minimem/src/cli/sync/central.ts +292 -0
- package/references/minimem/src/cli/sync/conflicts.ts +204 -0
- package/references/minimem/src/cli/sync/daemon.ts +407 -0
- package/references/minimem/src/cli/sync/detection.ts +138 -0
- package/references/minimem/src/cli/sync/index.ts +107 -0
- package/references/minimem/src/cli/sync/operations.ts +373 -0
- package/references/minimem/src/cli/sync/registry.ts +279 -0
- package/references/minimem/src/cli/sync/state.ts +355 -0
- package/references/minimem/src/cli/sync/validation.ts +206 -0
- package/references/minimem/src/cli/sync/watcher.ts +234 -0
- package/references/minimem/src/cli/version.ts +34 -0
- package/references/minimem/src/core/index.ts +9 -0
- package/references/minimem/src/core/indexer.ts +628 -0
- package/references/minimem/src/core/searcher.ts +221 -0
- package/references/minimem/src/db/schema.ts +183 -0
- package/references/minimem/src/db/sqlite-vec.ts +24 -0
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +431 -0
- package/references/minimem/src/embeddings/batch-gemini.ts +392 -0
- package/references/minimem/src/embeddings/batch-openai.ts +409 -0
- package/references/minimem/src/embeddings/embeddings.ts +434 -0
- package/references/minimem/src/index.ts +109 -0
- package/references/minimem/src/internal.ts +299 -0
- package/references/minimem/src/minimem.ts +1276 -0
- package/references/minimem/src/search/__tests__/hybrid.test.ts +247 -0
- package/references/minimem/src/search/graph.ts +234 -0
- package/references/minimem/src/search/hybrid.ts +151 -0
- package/references/minimem/src/search/search.ts +256 -0
- package/references/minimem/src/server/__tests__/mcp.test.ts +341 -0
- package/references/minimem/src/server/__tests__/tools.test.ts +364 -0
- package/references/minimem/src/server/mcp.ts +326 -0
- package/references/minimem/src/server/tools.ts +720 -0
- package/references/minimem/src/session.ts +460 -0
- package/references/minimem/tsconfig.json +19 -0
- package/references/minimem/tsup.config.ts +26 -0
- package/references/minimem/vitest.config.ts +24 -0
- package/references/skill-tree/.claude/settings.json +6 -0
- package/references/skill-tree/.sudocode/issues.jsonl +11 -0
- package/references/skill-tree/.sudocode/specs.jsonl +1 -0
- package/references/skill-tree/CLAUDE.md +150 -0
- package/references/skill-tree/README.md +324 -0
- package/references/skill-tree/docs/GAPS_v1.md +221 -0
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +467 -0
- package/references/skill-tree/docs/TODOS.md +91 -0
- package/references/skill-tree/docs/anthropic_skill_guide.md +1364 -0
- package/references/skill-tree/docs/design/federated-skill-trees.md +524 -0
- package/references/skill-tree/docs/design/multi-agent-sync.md +759 -0
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +583 -0
- package/references/skill-tree/docs/scraper/POC_PLAN.md +420 -0
- package/references/skill-tree/docs/scraper/README.md +170 -0
- package/references/skill-tree/examples/basic-usage.ts +190 -0
- package/references/skill-tree/package-lock.json +1509 -0
- package/references/skill-tree/package.json +66 -0
- package/references/skill-tree/scraper/README.md +123 -0
- package/references/skill-tree/scraper/docs/DESIGN.md +683 -0
- package/references/skill-tree/scraper/docs/PLAN.md +336 -0
- package/references/skill-tree/scraper/drizzle.config.ts +10 -0
- package/references/skill-tree/scraper/package-lock.json +6329 -0
- package/references/skill-tree/scraper/package.json +68 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +27 -0
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +21 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +54 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +24 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +93 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +22 -0
- package/references/skill-tree/scraper/tsup.config.ts +14 -0
- package/references/skill-tree/scraper/vitest.config.ts +17 -0
- package/references/skill-tree/scripts/convert-to-vitest.ts +166 -0
- package/references/skill-tree/skills/skill-writer/SKILL.md +339 -0
- package/references/skill-tree/skills/skill-writer/references/examples.md +326 -0
- package/references/skill-tree/skills/skill-writer/references/patterns.md +210 -0
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +123 -0
- package/references/skill-tree/test/run-all.ts +106 -0
- package/references/skill-tree/test/utils.ts +128 -0
- package/references/skill-tree/vitest.config.ts +16 -0
- package/scripts/migrate-to-playbooks.ts +307 -0
- package/src/agents/index.ts +14 -0
- package/src/agents/mock-provider.ts +93 -0
- package/src/agents/types.ts +137 -0
- package/src/atlas.ts +1072 -0
- package/src/bin/cognitive-core.ts +470 -0
- package/src/embeddings/bm25.ts +337 -0
- package/src/embeddings/index.ts +39 -0
- package/src/embeddings/manager.ts +288 -0
- package/src/embeddings/provider.ts +318 -0
- package/src/embeddings/vector-store.ts +353 -0
- package/src/factory.ts +263 -0
- package/src/index.ts +368 -0
- package/src/learning/analyzer.ts +335 -0
- package/src/learning/effectiveness.ts +428 -0
- package/src/learning/index.ts +93 -0
- package/src/learning/knowledge-extractor.ts +470 -0
- package/src/learning/meta-learner.ts +570 -0
- package/src/learning/pipeline.ts +323 -0
- package/src/learning/playbook-extractor.ts +702 -0
- package/src/learning/team-ingester.ts +499 -0
- package/src/learning/team-meta-learner.ts +558 -0
- package/src/learning/team-pipeline.ts +364 -0
- package/src/learning/trajectory-sources/dataclaw.ts +403 -0
- package/src/learning/trajectory-sources/entire.ts +240 -0
- package/src/learning/trajectory-sources/file.ts +136 -0
- package/src/learning/trajectory-sources/huggingface.ts +248 -0
- package/src/learning/trajectory-sources/in-memory.ts +61 -0
- package/src/learning/trajectory-sources/index.ts +15 -0
- package/src/learning/trajectory-sources/pipeline.ts +69 -0
- package/src/learning/usage-inference.ts +372 -0
- package/src/mcp/index.ts +12 -0
- package/src/mcp/playbook-server.ts +565 -0
- package/src/memory/curated-loader.ts +160 -0
- package/src/memory/experience.ts +515 -0
- package/src/memory/graph-layers/base.ts +184 -0
- package/src/memory/graph-layers/causal.ts +16 -0
- package/src/memory/graph-layers/entity.ts +16 -0
- package/src/memory/graph-layers/index.ts +5 -0
- package/src/memory/graph-layers/semantic.ts +16 -0
- package/src/memory/graph-layers/temporal.ts +16 -0
- package/src/memory/index.ts +72 -0
- package/src/memory/knowledge-bank.ts +1260 -0
- package/src/memory/knowledge-defrag.ts +329 -0
- package/src/memory/knowledge-graph.ts +361 -0
- package/src/memory/meta.ts +506 -0
- package/src/memory/playbook.ts +493 -0
- package/src/memory/search-provider.ts +35 -0
- package/src/memory/search-providers/index.ts +3 -0
- package/src/memory/search-providers/minimem.ts +84 -0
- package/src/memory/search-providers/text-similarity.ts +35 -0
- package/src/memory/skill-exporter.ts +357 -0
- package/src/memory/system.ts +604 -0
- package/src/memory/team-experience.ts +604 -0
- package/src/runtime/backends/acp-protocol.ts +231 -0
- package/src/runtime/backends/acp.ts +239 -0
- package/src/runtime/backends/index.ts +38 -0
- package/src/runtime/backends/macro-agent.ts +177 -0
- package/src/runtime/backends/mock.ts +218 -0
- package/src/runtime/backends/subprocess.ts +356 -0
- package/src/runtime/compute-provider.ts +206 -0
- package/src/runtime/flows/learning.ts +183 -0
- package/src/runtime/flows/validation.ts +381 -0
- package/src/runtime/index.ts +75 -0
- package/src/runtime/manager.ts +685 -0
- package/src/runtime/types.ts +198 -0
- package/src/search/evaluator.ts +499 -0
- package/src/search/index.ts +68 -0
- package/src/search/refinement-loop.ts +457 -0
- package/src/search/refinement-types.ts +159 -0
- package/src/search/router.ts +261 -0
- package/src/search/solver.ts +303 -0
- package/src/search/team-router.ts +459 -0
- package/src/search/verification-runner.ts +570 -0
- package/src/session-bank/git-reader.ts +190 -0
- package/src/session-bank/index.ts +24 -0
- package/src/session-bank/parser.ts +366 -0
- package/src/session-bank/session-bank.ts +464 -0
- package/src/session-bank/types.ts +173 -0
- package/src/surfacing/index.ts +29 -0
- package/src/surfacing/publisher.ts +23 -0
- package/src/surfacing/skill-library.ts +625 -0
- package/src/surfacing/skill-publisher.ts +223 -0
- package/src/surfacing/sqlite-storage-adapter.ts +301 -0
- package/src/surfacing/team-skill-library.ts +610 -0
- package/src/types/config.ts +585 -0
- package/src/types/dataclaw.ts +99 -0
- package/src/types/huggingface-transformers.d.ts +12 -0
- package/src/types/index.ts +286 -0
- package/src/types/knowledge-graph.ts +246 -0
- package/src/types/knowledge.ts +388 -0
- package/src/types/memory.ts +270 -0
- package/src/types/meta.ts +218 -0
- package/src/types/outcome.ts +66 -0
- package/src/types/playbook.ts +196 -0
- package/src/types/step.ts +40 -0
- package/src/types/task.ts +52 -0
- package/src/types/team-meta.ts +212 -0
- package/src/types/team-playbook.ts +384 -0
- package/src/types/team-trajectory.ts +673 -0
- package/src/types/trajectory-source.ts +47 -0
- package/src/types/trajectory.ts +80 -0
- package/src/utils/frontmatter.ts +118 -0
- package/src/utils/index.ts +45 -0
- package/src/utils/similarity.ts +139 -0
- package/src/utils/storage.ts +249 -0
- package/src/utils/validation.ts +286 -0
- package/src/workspace/index.ts +48 -0
- package/src/workspace/runner.ts +281 -0
- package/src/workspace/skill-converter.ts +288 -0
- package/src/workspace/templates/index.ts +64 -0
- package/src/workspace/templates/knowledge-defrag.ts +223 -0
- package/src/workspace/templates/knowledge-extraction.ts +337 -0
- package/src/workspace/templates/meta-reflection.ts +208 -0
- package/src/workspace/templates/playbook-extraction.ts +240 -0
- package/src/workspace/templates/refinement-analysis.ts +162 -0
- package/src/workspace/templates/solution-evaluation.ts +199 -0
- package/src/workspace/templates/team-playbook-extraction.ts +631 -0
- package/src/workspace/templates/team-trajectory-analysis.ts +564 -0
- package/src/workspace/templates/trajectory-analysis.ts +234 -0
- package/src/workspace/templates/usage-inference.ts +163 -0
- package/src/workspace/types.ts +233 -0
- package/tests/atlas-knowledge.test.ts +165 -0
- package/tests/embeddings/bm25.test.ts +130 -0
- package/tests/embeddings/manager.test.ts +205 -0
- package/tests/gap-fixes.test.ts +1103 -0
- package/tests/integration/atlas.test.ts +266 -0
- package/tests/integration/dataclaw-e2e.test.ts +559 -0
- package/tests/integration/e2e.test.ts +1336 -0
- package/tests/integration/entire-e2e.test.ts +187 -0
- package/tests/integration/huggingface-e2e.test.ts +627 -0
- package/tests/integration/session-bank.test.ts +225 -0
- package/tests/integration/skill-tree-wiring.test.ts +152 -0
- package/tests/learning/analyzer.test.ts +426 -0
- package/tests/learning/dataclaw-trajectory-source.test.ts +642 -0
- package/tests/learning/effectiveness.test.ts +542 -0
- package/tests/learning/entire-trajectory-source.test.ts +380 -0
- package/tests/learning/huggingface-trajectory-source.test.ts +817 -0
- package/tests/learning/knowledge-extractor.test.ts +491 -0
- package/tests/learning/pipeline.test.ts +176 -0
- package/tests/learning/playbook-extractor-provenance.test.ts +114 -0
- package/tests/learning/team-ingester.test.ts +349 -0
- package/tests/learning/team-meta-learner.test.ts +618 -0
- package/tests/learning/team-pipeline.test.ts +334 -0
- package/tests/learning/trajectory-sources.test.ts +312 -0
- package/tests/learning/usage-inference.test.ts +254 -0
- package/tests/mcp/playbook-server.test.ts +252 -0
- package/tests/memory/experience.test.ts +198 -0
- package/tests/memory/graph-layers/semantic.test.ts +219 -0
- package/tests/memory/knowledge-bank-extraction.test.ts +558 -0
- package/tests/memory/knowledge-bank.test.ts +705 -0
- package/tests/memory/knowledge-defrag.test.ts +366 -0
- package/tests/memory/knowledge-evolution.test.ts +563 -0
- package/tests/memory/knowledge-graph.test.ts +492 -0
- package/tests/memory/knowledge-inbox.test.ts +258 -0
- package/tests/memory/knowledge-minimem.test.ts +251 -0
- package/tests/memory/playbook.test.ts +338 -0
- package/tests/memory/provenance.test.ts +639 -0
- package/tests/memory/skill-exporter.test.ts +470 -0
- package/tests/memory/system.test.ts +325 -0
- package/tests/memory/team-experience.test.ts +411 -0
- package/tests/runtime/agent-manager.test.ts +512 -0
- package/tests/runtime/compute-provider.test.ts +288 -0
- package/tests/runtime/delegate.test.ts +349 -0
- package/tests/runtime/macro-agent-backend.test.ts +266 -0
- package/tests/runtime/mock-backend.test.ts +248 -0
- package/tests/search/refinement-loop.test.ts +468 -0
- package/tests/search/refinement.test.ts +267 -0
- package/tests/search/router.test.ts +427 -0
- package/tests/search/team-router.test.ts +376 -0
- package/tests/session-bank/fixtures/multi-tool-session/full.jsonl +12 -0
- package/tests/session-bank/fixtures/multi-tool-session/metadata.json +28 -0
- package/tests/session-bank/fixtures/root-metadata.json +18 -0
- package/tests/session-bank/fixtures/simple-session/full.jsonl +6 -0
- package/tests/session-bank/fixtures/simple-session/metadata.json +38 -0
- package/tests/session-bank/git-reader.test.ts +232 -0
- package/tests/session-bank/parser.test.ts +321 -0
- package/tests/session-bank/session-bank.test.ts +546 -0
- package/tests/surfacing/skill-library.test.ts +292 -0
- package/tests/surfacing/skill-publisher.test.ts +398 -0
- package/tests/surfacing/sqlite-storage-adapter.test.ts +218 -0
- package/tests/surfacing/team-skill-library.test.ts +444 -0
- package/tests/types/outcome.test.ts +147 -0
- package/tests/types/step.test.ts +133 -0
- package/tests/types/task.test.ts +158 -0
- package/tests/types/team-meta.test.ts +147 -0
- package/tests/types/team-playbook.test.ts +246 -0
- package/tests/types/team-trajectory.test.ts +557 -0
- package/tests/types/trajectory.test.ts +253 -0
- package/tests/utils/frontmatter.test.ts +208 -0
- package/tests/utils/similarity.test.ts +188 -0
- package/tests/utils/validation.test.ts +252 -0
- package/tests/workspace/full-flow.test.ts +839 -0
- package/tests/workspace/manager.test.ts +215 -0
- package/tests/workspace/runner.test.ts +330 -0
- package/tests/workspace/skill-converter.test.ts +205 -0
- package/tests/workspace/templates/knowledge-extraction.test.ts +235 -0
- package/tests/workspace/templates/team-playbook-extraction.test.ts +341 -0
- package/tests/workspace/templates/team-trajectory-analysis.test.ts +417 -0
- package/tsconfig.json +25 -0
- package/vitest.config.ts +22 -0
- package/dist/index.d.mts +0 -466
- package/dist/index.mjs +0 -478
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
# Design: Workspace Migration & Modular Compute
|
|
2
|
+
|
|
3
|
+
**Status:** Draft
|
|
4
|
+
**Supersedes:** Portions of `DESIGN-agentic-workspace.md` (Phase 3–4: migration path)
|
|
5
|
+
**Builds on:** `DESIGN-agentic-workspace.md` (infrastructure), `DESIGN-team-extraction-pipeline.md` (team analysis)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Problem
|
|
10
|
+
|
|
11
|
+
cognitive-core has three structural issues:
|
|
12
|
+
|
|
13
|
+
1. **~10 analysis tasks use brittle heuristics** (word overlap, regex, exponential decay) for work that requires semantic understanding. The `AgenticTaskTemplate` + `AgenticTaskRunner` infrastructure now exists but no tasks have been migrated to use it.
|
|
14
|
+
|
|
15
|
+
2. **Three major subsystems are implemented but disconnected from the core flow.** `MetaLearner`, `LearningEffectivenessTracker`, and `LLMPlaybookExtractor` are never called from `Atlas.solve()` or `LearningPipeline`. Their outputs are lost.
|
|
16
|
+
|
|
17
|
+
3. **Compute is tightly coupled.** `AgentManager` maps agent types to backends via name matching. `ACPBackend` conflates the ACP wire protocol with local process spawning. There is no way to route the same agent type to different compute sources based on cost, availability, or requirements.
|
|
18
|
+
|
|
19
|
+
This document specifies the concrete migration of all analysis tasks to workspace-based execution, the wiring of disconnected subsystems, and a modular compute provider abstraction.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Scope
|
|
24
|
+
|
|
25
|
+
| In Scope | Out of Scope |
|
|
26
|
+
|----------|-------------|
|
|
27
|
+
| Migrating existing heuristic analysis tasks to `AgenticTaskTemplate` | New team trajectory types (covered by `DESIGN-team-extraction-pipeline.md`) |
|
|
28
|
+
| Wiring disconnected subsystems into `Atlas.solve()` | Changes to the memory system internals |
|
|
29
|
+
| `ComputeProvider` abstraction for modular backend selection | Implementing specific remote compute backends |
|
|
30
|
+
| Updated `LearningPipeline` orchestration | Changes to the `agent-workspace` package itself |
|
|
31
|
+
| Configuration schema additions | UI/CLI changes |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Part 1: Task Inventory and Migration Plan
|
|
36
|
+
|
|
37
|
+
### 1.1 Complete Task Map
|
|
38
|
+
|
|
39
|
+
Every analysis point, its current implementation, and its migration target:
|
|
40
|
+
|
|
41
|
+
| # | Task | File | Current Impl | Migration | Priority |
|
|
42
|
+
|---|------|------|-------------|-----------|----------|
|
|
43
|
+
| 1 | Credit assignment | `learning/analyzer.ts:70-84` | Exponential decay / outcome-based | Template: `trajectory-analysis` | A |
|
|
44
|
+
| 2 | Key step identification | `learning/analyzer.ts:154-157` | Attribution threshold (≥ 0.15) | Merged into `trajectory-analysis` | A |
|
|
45
|
+
| 3 | Error pattern detection | `learning/analyzer.ts:188-237` | Regex matching + repetition counting | Merged into `trajectory-analysis` | A |
|
|
46
|
+
| 4 | Abstractability assessment | `learning/analyzer.ts:242-263` | Heuristic (success + key steps ≥ 2) | Merged into `trajectory-analysis` | A |
|
|
47
|
+
| 5 | Playbook extraction | `learning/playbook-extractor.ts:68-108` | Action normalization + frequency + text similarity | Template: `playbook-extraction` | A |
|
|
48
|
+
| 6 | LLM playbook extraction | `learning/llm-extractor.ts:67-135` | Single LLM call, JSON parsing | Absorbed into `playbook-extraction` template | A |
|
|
49
|
+
| 7 | Usage inference | `learning/usage-inference.ts:71-107` | Keyword extraction + word overlap | Template: `usage-inference` | A |
|
|
50
|
+
| 8 | Meta-learning reflection | `learning/meta-learner.ts:68-130` | Word overlap, heuristic outcome quality | Template: `meta-reflection` | B |
|
|
51
|
+
| 9 | Solution evaluation | `search/evaluator.ts` | Tiered: agent + heuristic | Template: `solution-evaluation` | B |
|
|
52
|
+
| 10 | Refinement strategy | `search/refinement-loop.ts:112-217` | Issue listing + retry with same config | Template: `refinement-analysis` | B |
|
|
53
|
+
| 11 | Routing decision | `search/router.ts:106-161` | Threshold-based rules on similarity scores | Template: `routing-decision` | C |
|
|
54
|
+
| 12 | Effectiveness tracking | `learning/effectiveness.ts` | Counting / aggregation | **No migration** — pure metrics, heuristic is correct | — |
|
|
55
|
+
| 13 | Team trajectory analysis | *new* | N/A | Template: `team-analysis` | D |
|
|
56
|
+
| 14 | Team playbook extraction | *new* | N/A | Template: `team-playbook-extraction` | D |
|
|
57
|
+
|
|
58
|
+
**Priority key:**
|
|
59
|
+
- **A** — High-value migrations. Heuristics doing semantic work. Migrate first.
|
|
60
|
+
- **B** — Medium-value. Current implementations work but are limited.
|
|
61
|
+
- **C** — Lower value. Threshold-based routing is adequate for now.
|
|
62
|
+
- **D** — New capabilities. Depend on team trajectory types from separate design.
|
|
63
|
+
|
|
64
|
+
### 1.2 Template Consolidation
|
|
65
|
+
|
|
66
|
+
Tasks 1–4 (`TrajectoryAnalyzer`) are currently a single method (`analyze()`). Rather than four separate templates, they become **one template** (`trajectory-analysis`) where the agent performs all four analyses in a single workspace session. This matches the current call pattern and avoids spawning four agents per trajectory.
|
|
67
|
+
|
|
68
|
+
Tasks 5–6 (`PlaybookExtractor` + `LLMPlaybookExtractor`) consolidate into a **single template** (`playbook-extraction`). The LLM extractor currently exists but is never called from `LearningPipeline` — the template replaces both.
|
|
69
|
+
|
|
70
|
+
### 1.3 Templates to Implement
|
|
71
|
+
|
|
72
|
+
Seven templates total (plus two from team design):
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
workspace/templates/
|
|
76
|
+
├── trajectory-analysis.ts # Replaces TrajectoryAnalyzer (tasks 1-4)
|
|
77
|
+
├── playbook-extraction.ts # Replaces PlaybookExtractor + LLMPlaybookExtractor (tasks 5-6)
|
|
78
|
+
├── usage-inference.ts # Replaces PlaybookUsageInference (task 7)
|
|
79
|
+
├── meta-reflection.ts # Replaces MetaLearner.generateReflection() (task 8)
|
|
80
|
+
├── solution-evaluation.ts # Enhances evaluator.ts (task 9)
|
|
81
|
+
├── refinement-analysis.ts # Enhances refinement-loop.ts (task 10)
|
|
82
|
+
├── routing-decision.ts # Enhances router.ts (task 11)
|
|
83
|
+
├── team-analysis.ts # New (task 13, from team design)
|
|
84
|
+
└── team-playbook-extraction.ts # New (task 14, from team design)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Each template file exports an `AgenticTaskTemplate<TInput, TOutput>` conforming to the interface defined in `workspace/types.ts`.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Part 2: Core Flow Adjustments
|
|
92
|
+
|
|
93
|
+
### 2.1 Current Flow (with disconnections marked)
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
Atlas.solve(task)
|
|
97
|
+
├─ TaskRouter.route(task) # threshold heuristic
|
|
98
|
+
├─ SkillLibrary.getSkillsForAgent(task) # tier-based injection
|
|
99
|
+
├─ AgentManager.spawn(config) # execute task
|
|
100
|
+
│
|
|
101
|
+
│ ╌╌╌ POST-EXECUTION ╌╌╌
|
|
102
|
+
│
|
|
103
|
+
├─ PlaybookUsageInference.inferUsage(traj, pbs) # word overlap
|
|
104
|
+
├─ SkillLibrary.recordOutcome(...) # update tiers
|
|
105
|
+
│
|
|
106
|
+
│ ✗ MetaLearner.generateReflection() ← NEVER CALLED
|
|
107
|
+
│ ✗ EffectivenessTracker.annotate() ← NEVER CALLED
|
|
108
|
+
│
|
|
109
|
+
├─ LearningPipeline.processTrajectory(traj)
|
|
110
|
+
│ ├─ MemorySystem.storeTrajectory(traj)
|
|
111
|
+
│ ├─ TrajectoryAnalyzer.analyze(traj) # exp decay + regex
|
|
112
|
+
│ └─ accumulate for batch
|
|
113
|
+
│
|
|
114
|
+
└─ [batch threshold] → LearningPipeline.runBatchLearning()
|
|
115
|
+
├─ PlaybookExtractor.extract(trajs, analyses) # frequency counting
|
|
116
|
+
│
|
|
117
|
+
│ ✗ LLMPlaybookExtractor ← EXISTS BUT NEVER CALLED
|
|
118
|
+
│
|
|
119
|
+
└─ Memory.playbooks.add/update
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 2.2 Updated Flow
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Atlas.solve(task)
|
|
126
|
+
├─ TaskRouter.route(task)
|
|
127
|
+
├─ SkillLibrary.getSkillsForAgent(task)
|
|
128
|
+
├─ AgentManager.spawn(config) # execute task
|
|
129
|
+
│
|
|
130
|
+
│ ╌╌╌ POST-EXECUTION (workspace-based) ╌╌╌
|
|
131
|
+
│
|
|
132
|
+
├─ taskRunner.run(usageInferenceTemplate, {...}) # MIGRATED: semantic matching
|
|
133
|
+
├─ SkillLibrary.recordOutcome(...)
|
|
134
|
+
├─ taskRunner.run(metaReflectionTemplate, {...}) # WIRED UP: was disconnected
|
|
135
|
+
├─ EffectivenessTracker.annotate(...) # WIRED UP: was disconnected
|
|
136
|
+
│
|
|
137
|
+
├─ LearningPipeline.processTrajectory(traj)
|
|
138
|
+
│ ├─ MemorySystem.storeTrajectory(traj)
|
|
139
|
+
│ ├─ taskRunner.run(trajectoryAnalysisTemplate, {...}) # MIGRATED
|
|
140
|
+
│ └─ accumulate for batch
|
|
141
|
+
│
|
|
142
|
+
└─ [batch threshold] → LearningPipeline.runBatchLearning()
|
|
143
|
+
├─ taskRunner.run(playbookExtractionTemplate, {...}) # MIGRATED (unifies both extractors)
|
|
144
|
+
└─ Memory.playbooks.add/update
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 2.3 Specific Wiring Changes
|
|
148
|
+
|
|
149
|
+
#### 2.3.1 Wire MetaLearner into Atlas
|
|
150
|
+
|
|
151
|
+
`Atlas` currently never creates a `MetaLearner`. Add:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// In Atlas constructor or init()
|
|
155
|
+
this.metaLearner = createMetaLearner(this.memory.meta);
|
|
156
|
+
this.router.setMetaLearner(this.metaLearner);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
In `Atlas.solve()`, after usage inference:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Generate meta-reflection (workspace-based for complex cases, heuristic for simple)
|
|
163
|
+
const metaResult = await this.taskRunner.run(metaReflectionTemplate, {
|
|
164
|
+
trajectory: result.trajectory,
|
|
165
|
+
routingDecision: routing,
|
|
166
|
+
playbooksUsed: injectedPlaybooks,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Feed reflection back to meta-learner for strategy generation
|
|
170
|
+
await this.metaLearner.recordObservation(metaResult.output);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### 2.3.2 Wire EffectivenessTracker into Atlas
|
|
174
|
+
|
|
175
|
+
`Atlas` currently never calls `annotate()`. Add after usage inference:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// In Atlas.solve(), after usage inference completes
|
|
179
|
+
const appliedPlaybookIds = (result.playbookUsage ?? [])
|
|
180
|
+
.filter(u => u.wasUsed)
|
|
181
|
+
.map(u => u.playbookId);
|
|
182
|
+
|
|
183
|
+
await this.effectivenessTracker.annotate(
|
|
184
|
+
result.trajectory,
|
|
185
|
+
routing.memoryContext.playbooks, // surfaced
|
|
186
|
+
routing.memoryContext.experiences.map(e => e.experience.id), // surfaced experiences
|
|
187
|
+
appliedPlaybookIds, // applied
|
|
188
|
+
);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### 2.3.3 LearningPipeline Accepts AgenticTaskRunner
|
|
192
|
+
|
|
193
|
+
`LearningPipeline` currently instantiates `TrajectoryAnalyzer` and `PlaybookExtractor` directly. Change to accept and use `AgenticTaskRunner`:
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
class LearningPipeline {
|
|
197
|
+
private taskRunner: AgenticTaskRunner | null = null;
|
|
198
|
+
|
|
199
|
+
// Existing analyzer/extractor kept as heuristic fallbacks
|
|
200
|
+
private analyzer: TrajectoryAnalyzer;
|
|
201
|
+
private playbookExtractor: PlaybookExtractor;
|
|
202
|
+
|
|
203
|
+
setTaskRunner(runner: AgenticTaskRunner): void {
|
|
204
|
+
this.taskRunner = runner;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async processTrajectory(trajectory: Trajectory): Promise<ProcessResult> {
|
|
208
|
+
await this.memory.storeTrajectory(trajectory);
|
|
209
|
+
|
|
210
|
+
let analysis: AnalysisResult;
|
|
211
|
+
if (this.taskRunner) {
|
|
212
|
+
// Workspace-based analysis (with built-in heuristic fallback)
|
|
213
|
+
const result = await this.taskRunner.run(trajectoryAnalysisTemplate, {
|
|
214
|
+
trajectory,
|
|
215
|
+
creditStrategy: this.config.creditStrategy,
|
|
216
|
+
});
|
|
217
|
+
analysis = result.output;
|
|
218
|
+
} else {
|
|
219
|
+
// Direct heuristic (no runner configured)
|
|
220
|
+
analysis = await this.analyzer.analyze(trajectory);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.accumulated.push(trajectory);
|
|
224
|
+
this.accumulatedAnalyses.push(analysis);
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
trajectoryId: trajectory.id,
|
|
228
|
+
stored: true,
|
|
229
|
+
analysis,
|
|
230
|
+
abstractable: analysis.abstractable,
|
|
231
|
+
playbookExtracted: false,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async runBatchLearning(): Promise<BatchResult> {
|
|
236
|
+
// ... existing guard clauses ...
|
|
237
|
+
|
|
238
|
+
let playbookExtraction: ExtractedPlaybooks;
|
|
239
|
+
if (this.taskRunner) {
|
|
240
|
+
const result = await this.taskRunner.run(playbookExtractionTemplate, {
|
|
241
|
+
trajectories: this.accumulated,
|
|
242
|
+
analyses: this.accumulatedAnalyses,
|
|
243
|
+
existingPlaybooks: await this.memory.playbooks.getAll(),
|
|
244
|
+
});
|
|
245
|
+
playbookExtraction = result.output;
|
|
246
|
+
} else {
|
|
247
|
+
playbookExtraction = await this.playbookExtractor.extract(
|
|
248
|
+
this.accumulated,
|
|
249
|
+
this.accumulatedAnalyses,
|
|
250
|
+
await this.memory.playbooks.getAll(),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ... rest of method (add playbooks, prune, etc.) unchanged ...
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### 2.4 Heuristic Fallback Guarantee
|
|
260
|
+
|
|
261
|
+
Every template's `assessComplexity()` routes simple cases to the `heuristicFallback()` which calls the **existing implementation unchanged**. This means:
|
|
262
|
+
|
|
263
|
+
- No functionality is lost during migration
|
|
264
|
+
- Simple cases (short successful trajectories, few playbooks, clear outcomes) stay fast and free
|
|
265
|
+
- Agent analysis is reserved for cases where semantic understanding provides value
|
|
266
|
+
- The system can run in "heuristic-only" mode if no `AgenticTaskRunner` is configured
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Part 3: Modular Compute Provider
|
|
271
|
+
|
|
272
|
+
### 3.1 Problem
|
|
273
|
+
|
|
274
|
+
The current `AgentManager.findBackend()` at `runtime/manager.ts:471-480` does this:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
private findBackend(agentType: string): AgentBackend | undefined {
|
|
278
|
+
for (const backend of this.backends.values()) {
|
|
279
|
+
if (backend.supportedTypes.includes(agentType)) {
|
|
280
|
+
return backend; // First match wins
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return this.backends.get(agentType);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
This has three limitations:
|
|
288
|
+
1. **First-match wins.** If two backends support `claude-code`, the first registered one always wins.
|
|
289
|
+
2. **No cost/requirements routing.** A lightweight analysis task and a thorough team analysis both get the same backend.
|
|
290
|
+
3. **`ACPBackend` conflates protocol and compute.** The class at `runtime/backends/acp.ts` handles ACP update processing (`processUpdate`, session management) AND local process lifecycle (`AgentFactory.spawn`). Adding a remote ACP endpoint means duplicating the protocol handling code.
|
|
291
|
+
|
|
292
|
+
### 3.2 Design
|
|
293
|
+
|
|
294
|
+
Introduce a `ComputeProvider` that sits between `AgentManager` and the backend registry:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
AgenticTaskRunner
|
|
298
|
+
→ AgentManager.spawn(config)
|
|
299
|
+
→ ComputeProvider.resolve(agentType, requirements)
|
|
300
|
+
→ returns ComputeTarget { backend, overrides }
|
|
301
|
+
→ backend.spawn(mergedConfig)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### 3.2.1 New Types
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// src/runtime/compute-provider.ts
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Requirements for compute resolution.
|
|
311
|
+
* Templates express preferences; the provider resolves them to concrete backends.
|
|
312
|
+
*/
|
|
313
|
+
export interface ComputeRequirements {
|
|
314
|
+
/** Preferred execution location */
|
|
315
|
+
mode?: 'local' | 'remote' | 'any';
|
|
316
|
+
/** Maximum cost budget in cents (for cost-aware routing) */
|
|
317
|
+
maxCostCents?: number;
|
|
318
|
+
/** Required agent capabilities */
|
|
319
|
+
capabilities?: string[];
|
|
320
|
+
/** Timeout hint (provider may select faster backends for short timeouts) */
|
|
321
|
+
timeout?: number;
|
|
322
|
+
/** Complexity hint from template */
|
|
323
|
+
complexity?: AnalysisComplexity;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Resolution result: which backend to use and any config overrides.
|
|
328
|
+
*/
|
|
329
|
+
export interface ComputeTarget {
|
|
330
|
+
/** The resolved backend */
|
|
331
|
+
backend: AgentBackend;
|
|
332
|
+
/** Config overrides for this resolution (e.g., different timeout, env vars) */
|
|
333
|
+
overrides?: Partial<AgentSpawnConfig>;
|
|
334
|
+
/** Source identifier for logging/metrics */
|
|
335
|
+
source: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Registered compute source with metadata.
|
|
340
|
+
*/
|
|
341
|
+
export interface ComputeSource {
|
|
342
|
+
/** Unique name for this source */
|
|
343
|
+
name: string;
|
|
344
|
+
/** Underlying backend */
|
|
345
|
+
backend: AgentBackend;
|
|
346
|
+
/** Cost tier for routing decisions */
|
|
347
|
+
costTier: 'free' | 'low' | 'medium' | 'high';
|
|
348
|
+
/** Execution location */
|
|
349
|
+
location: 'local' | 'remote';
|
|
350
|
+
/** Priority (lower = preferred, for tie-breaking) */
|
|
351
|
+
priority: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Resolves agent type + requirements to a concrete compute target.
|
|
356
|
+
*/
|
|
357
|
+
export interface ComputeProvider {
|
|
358
|
+
/** Resolve an agent execution request to a backend */
|
|
359
|
+
resolve(
|
|
360
|
+
agentType: string,
|
|
361
|
+
requirements?: ComputeRequirements
|
|
362
|
+
): Promise<ComputeTarget>;
|
|
363
|
+
|
|
364
|
+
/** Register a compute source */
|
|
365
|
+
register(source: ComputeSource): void;
|
|
366
|
+
|
|
367
|
+
/** List available compute sources */
|
|
368
|
+
listSources(): ComputeSource[];
|
|
369
|
+
|
|
370
|
+
/** Check if any source supports the given agent type */
|
|
371
|
+
supports(agentType: string): boolean;
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
#### 3.2.2 Default Implementation
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// src/runtime/compute-provider.ts
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Default compute provider.
|
|
382
|
+
* Replicates current first-match behavior, with optional cost/location routing.
|
|
383
|
+
*/
|
|
384
|
+
export class DefaultComputeProvider implements ComputeProvider {
|
|
385
|
+
private sources: ComputeSource[] = [];
|
|
386
|
+
|
|
387
|
+
register(source: ComputeSource): void {
|
|
388
|
+
this.sources.push(source);
|
|
389
|
+
// Keep sorted by priority
|
|
390
|
+
this.sources.sort((a, b) => a.priority - b.priority);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
listSources(): ComputeSource[] {
|
|
394
|
+
return [...this.sources];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
supports(agentType: string): boolean {
|
|
398
|
+
return this.sources.some(s => s.backend.supportedTypes.includes(agentType));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async resolve(
|
|
402
|
+
agentType: string,
|
|
403
|
+
requirements?: ComputeRequirements
|
|
404
|
+
): Promise<ComputeTarget> {
|
|
405
|
+
// Filter to sources that support this agent type
|
|
406
|
+
let candidates = this.sources.filter(
|
|
407
|
+
s => s.backend.supportedTypes.includes(agentType)
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
if (candidates.length === 0) {
|
|
411
|
+
throw new Error(
|
|
412
|
+
`No compute source supports agent type '${agentType}'. ` +
|
|
413
|
+
`Available sources: ${this.sources.map(s => s.name).join(', ')}`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Apply requirements filters
|
|
418
|
+
if (requirements?.mode && requirements.mode !== 'any') {
|
|
419
|
+
const locationFiltered = candidates.filter(
|
|
420
|
+
s => s.location === requirements.mode
|
|
421
|
+
);
|
|
422
|
+
if (locationFiltered.length > 0) {
|
|
423
|
+
candidates = locationFiltered;
|
|
424
|
+
}
|
|
425
|
+
// If no match for preferred mode, fall back to all candidates
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (requirements?.maxCostCents !== undefined) {
|
|
429
|
+
const costOrder: Record<string, number> = {
|
|
430
|
+
free: 0, low: 1, medium: 5, high: 20,
|
|
431
|
+
};
|
|
432
|
+
const budgetFiltered = candidates.filter(
|
|
433
|
+
s => costOrder[s.costTier] <= (requirements.maxCostCents ?? Infinity)
|
|
434
|
+
);
|
|
435
|
+
if (budgetFiltered.length > 0) {
|
|
436
|
+
candidates = budgetFiltered;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Check availability (first available wins, respecting priority order)
|
|
441
|
+
for (const source of candidates) {
|
|
442
|
+
if (await source.backend.isAvailable()) {
|
|
443
|
+
return {
|
|
444
|
+
backend: source.backend,
|
|
445
|
+
source: source.name,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Fallback: return first candidate regardless of availability
|
|
451
|
+
return {
|
|
452
|
+
backend: candidates[0].backend,
|
|
453
|
+
source: candidates[0].name,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### 3.2.3 AgentManager Integration
|
|
460
|
+
|
|
461
|
+
Modify `AgentManager` to use `ComputeProvider` instead of direct backend lookup:
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
// src/runtime/manager.ts
|
|
465
|
+
|
|
466
|
+
export class AgentManager {
|
|
467
|
+
private computeProvider: ComputeProvider;
|
|
468
|
+
// ... existing fields ...
|
|
469
|
+
|
|
470
|
+
constructor(
|
|
471
|
+
memory: MemorySystem,
|
|
472
|
+
options?: {
|
|
473
|
+
injector?: KnowledgeInjector;
|
|
474
|
+
extractor?: TrajectoryExtractor;
|
|
475
|
+
computeProvider?: ComputeProvider;
|
|
476
|
+
}
|
|
477
|
+
) {
|
|
478
|
+
this.memory = memory;
|
|
479
|
+
this.injector = options?.injector ?? new DefaultKnowledgeInjector();
|
|
480
|
+
this.extractor = options?.extractor ?? new DefaultTrajectoryExtractor();
|
|
481
|
+
this.computeProvider = options?.computeProvider ?? new DefaultComputeProvider();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Register a backend as a compute source.
|
|
486
|
+
* Wraps the backend in a ComputeSource with defaults.
|
|
487
|
+
*/
|
|
488
|
+
registerBackend(backend: AgentBackend, options?: {
|
|
489
|
+
costTier?: ComputeSource['costTier'];
|
|
490
|
+
location?: ComputeSource['location'];
|
|
491
|
+
priority?: number;
|
|
492
|
+
}): void {
|
|
493
|
+
this.computeProvider.register({
|
|
494
|
+
name: backend.name,
|
|
495
|
+
backend,
|
|
496
|
+
costTier: options?.costTier ?? 'low',
|
|
497
|
+
location: options?.location ?? 'local',
|
|
498
|
+
priority: options?.priority ?? 10,
|
|
499
|
+
});
|
|
500
|
+
// Keep backwards-compatible backends map
|
|
501
|
+
this.backends.set(backend.name, backend);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async spawn(config: AgentSpawnConfig): Promise<AgentResult> {
|
|
505
|
+
// Resolve compute target
|
|
506
|
+
const target = await this.computeProvider.resolve(
|
|
507
|
+
config.agentType,
|
|
508
|
+
config.computeRequirements,
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
// Merge overrides from compute resolution
|
|
512
|
+
const resolvedConfig = target.overrides
|
|
513
|
+
? { ...config, ...target.overrides }
|
|
514
|
+
: config;
|
|
515
|
+
|
|
516
|
+
// ... rest of spawn logic uses target.backend instead of findBackend() ...
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
#### 3.2.4 AgenticTaskTemplate Gets ComputeRequirements
|
|
522
|
+
|
|
523
|
+
Add an optional field to the template interface:
|
|
524
|
+
|
|
525
|
+
```typescript
|
|
526
|
+
// src/workspace/types.ts (addition to AgenticTaskTemplate)
|
|
527
|
+
|
|
528
|
+
export interface AgenticTaskTemplate<TInput, TOutput> {
|
|
529
|
+
// ... existing fields ...
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Compute requirements for this template.
|
|
533
|
+
* Used by ComputeProvider to select appropriate backend.
|
|
534
|
+
* If not specified, defaults are used.
|
|
535
|
+
*/
|
|
536
|
+
computeRequirements?: ComputeRequirements;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Dynamic compute requirements based on input and complexity.
|
|
540
|
+
* Overrides static computeRequirements when provided.
|
|
541
|
+
*/
|
|
542
|
+
getComputeRequirements?(
|
|
543
|
+
input: TInput,
|
|
544
|
+
complexity: AnalysisComplexity
|
|
545
|
+
): ComputeRequirements;
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
The `AgenticTaskRunner` passes these through when spawning:
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
// In AgenticTaskRunner.run(), when building spawn config:
|
|
553
|
+
const requirements = template.getComputeRequirements
|
|
554
|
+
? template.getComputeRequirements(input, complexity)
|
|
555
|
+
: template.computeRequirements;
|
|
556
|
+
|
|
557
|
+
const agentResult = await this.agentManager.spawn({
|
|
558
|
+
agentType: template.agentType ?? 'claude-code',
|
|
559
|
+
task,
|
|
560
|
+
cwd: handle.path,
|
|
561
|
+
injectedKnowledge: knowledge,
|
|
562
|
+
computeRequirements: requirements,
|
|
563
|
+
// ...
|
|
564
|
+
});
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
#### 3.2.5 ACPBackend Split
|
|
568
|
+
|
|
569
|
+
Split the current monolithic `ACPBackend` into two concerns:
|
|
570
|
+
|
|
571
|
+
```
|
|
572
|
+
Current:
|
|
573
|
+
ACPBackend
|
|
574
|
+
├─ ACP wire protocol (processUpdate, session streaming)
|
|
575
|
+
└─ Local process lifecycle (AgentFactory.spawn, close)
|
|
576
|
+
|
|
577
|
+
After:
|
|
578
|
+
ACPProtocolMixin (or base class)
|
|
579
|
+
└─ processUpdate(), runPrompt(), session state management
|
|
580
|
+
|
|
581
|
+
LocalACPBackend extends ACPProtocolMixin
|
|
582
|
+
└─ AgentFactory.spawn() for local processes
|
|
583
|
+
|
|
584
|
+
RemoteACPBackend extends ACPProtocolMixin (future)
|
|
585
|
+
└─ HTTP/WebSocket connection to remote ACP endpoint
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
The `ACPProtocolMixin` extracts the `processUpdate()` method at `acp.ts:169-270` and `runPrompt()` at `acp.ts:138-163` into a reusable piece. Backend implementations only need to provide `spawn()` and `terminate()` for their specific compute environment.
|
|
589
|
+
|
|
590
|
+
### 3.3 AgentSpawnConfig Addition
|
|
591
|
+
|
|
592
|
+
```typescript
|
|
593
|
+
// src/runtime/types.ts (addition to AgentSpawnConfig)
|
|
594
|
+
|
|
595
|
+
export interface AgentSpawnConfig {
|
|
596
|
+
// ... existing fields ...
|
|
597
|
+
|
|
598
|
+
/** Compute requirements for provider-based resolution */
|
|
599
|
+
computeRequirements?: ComputeRequirements;
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### 3.4 Configuration Addition
|
|
604
|
+
|
|
605
|
+
```typescript
|
|
606
|
+
// src/types/config.ts (additions)
|
|
607
|
+
|
|
608
|
+
export const ComputeProviderConfigSchema = z.object({
|
|
609
|
+
/** Default cost tier preference */
|
|
610
|
+
defaultCostTier: z.enum(['free', 'low', 'medium', 'high']).default('low'),
|
|
611
|
+
/** Default location preference */
|
|
612
|
+
defaultLocation: z.enum(['local', 'remote', 'any']).default('local'),
|
|
613
|
+
/** Fallback to any available source if preferred not available */
|
|
614
|
+
allowFallback: z.boolean().default(true),
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
export type ComputeProviderConfig = z.infer<typeof ComputeProviderConfigSchema>;
|
|
618
|
+
|
|
619
|
+
// Add to AtlasConfigSchema:
|
|
620
|
+
// compute: ComputeProviderConfigSchema.default({}),
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## Part 4: Template Specifications
|
|
626
|
+
|
|
627
|
+
Each template follows the `AgenticTaskTemplate<TInput, TOutput>` interface from `workspace/types.ts`. Below are the input/output types and complexity rules for each.
|
|
628
|
+
|
|
629
|
+
### 4.1 Trajectory Analysis Template
|
|
630
|
+
|
|
631
|
+
**Replaces:** `TrajectoryAnalyzer` (tasks 1–4)
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
// workspace/templates/trajectory-analysis.ts
|
|
635
|
+
|
|
636
|
+
interface TrajectoryAnalysisInput {
|
|
637
|
+
trajectory: Trajectory;
|
|
638
|
+
creditStrategy: CreditStrategy;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Output reuses the existing AnalysisResult type from learning/analyzer.ts
|
|
642
|
+
// No schema changes needed — the agent produces the same shape.
|
|
643
|
+
|
|
644
|
+
const trajectoryAnalysisTemplate: AgenticTaskTemplate<
|
|
645
|
+
TrajectoryAnalysisInput,
|
|
646
|
+
AnalysisResult
|
|
647
|
+
> = {
|
|
648
|
+
taskType: 'trajectory-analysis',
|
|
649
|
+
domain: 'trajectory-analysis',
|
|
650
|
+
description: 'Analyze agent trajectory for credit assignment, key steps, and error patterns',
|
|
651
|
+
|
|
652
|
+
assessComplexity(input) {
|
|
653
|
+
const { trajectory } = input;
|
|
654
|
+
// Short successful trajectories → heuristic (existing analyzer is fine)
|
|
655
|
+
if (trajectory.steps.length <= 5 && trajectory.outcome.success) {
|
|
656
|
+
return 'heuristic';
|
|
657
|
+
}
|
|
658
|
+
// Failed trajectories benefit most from semantic analysis
|
|
659
|
+
if (!trajectory.outcome.success) return 'standard';
|
|
660
|
+
// Long trajectories need agent to identify what actually mattered
|
|
661
|
+
if (trajectory.steps.length > 20) return 'standard';
|
|
662
|
+
return 'lightweight';
|
|
663
|
+
},
|
|
664
|
+
|
|
665
|
+
async heuristicFallback(input) {
|
|
666
|
+
// Delegates to existing TrajectoryAnalyzer — zero cost path
|
|
667
|
+
const analyzer = createAnalyzer(input.creditStrategy);
|
|
668
|
+
return analyzer.analyze(input.trajectory);
|
|
669
|
+
},
|
|
670
|
+
|
|
671
|
+
// Workspace: input/context.md + input/trajectories/execution.jsonl
|
|
672
|
+
// Output: output/analysis.json (AnalysisResult schema)
|
|
673
|
+
|
|
674
|
+
computeRequirements: { mode: 'local', complexity: 'lightweight' },
|
|
675
|
+
};
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
**Workspace layout:**
|
|
679
|
+
```
|
|
680
|
+
input/
|
|
681
|
+
context.md # YAML frontmatter: taskId, domain, outcome, stepCount, wallTime
|
|
682
|
+
trajectories/
|
|
683
|
+
execution.jsonl # One step per line (thought, action, observation, metadata)
|
|
684
|
+
skills/ # Analysis playbooks converted to SKILL.md
|
|
685
|
+
output/
|
|
686
|
+
analysis.json # AnalysisResult (validated against existing schema)
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### 4.2 Playbook Extraction Template
|
|
690
|
+
|
|
691
|
+
**Replaces:** `PlaybookExtractor` + `LLMPlaybookExtractor` (tasks 5–6)
|
|
692
|
+
|
|
693
|
+
```typescript
|
|
694
|
+
// workspace/templates/playbook-extraction.ts
|
|
695
|
+
|
|
696
|
+
interface PlaybookExtractionInput {
|
|
697
|
+
trajectories: Trajectory[];
|
|
698
|
+
analyses: AnalysisResult[];
|
|
699
|
+
existingPlaybooks: Playbook[];
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Output reuses ExtractedPlaybooks from learning/playbook-extractor.ts
|
|
703
|
+
|
|
704
|
+
const playbookExtractionTemplate: AgenticTaskTemplate<
|
|
705
|
+
PlaybookExtractionInput,
|
|
706
|
+
ExtractedPlaybooks
|
|
707
|
+
> = {
|
|
708
|
+
taskType: 'playbook-extraction',
|
|
709
|
+
domain: 'playbook-extraction',
|
|
710
|
+
description: 'Extract reusable playbooks from trajectory batch',
|
|
711
|
+
timeout: 300_000,
|
|
712
|
+
|
|
713
|
+
assessComplexity(input) {
|
|
714
|
+
if (input.trajectories.length <= 3) return 'heuristic';
|
|
715
|
+
if (input.trajectories.length > 10) return 'thorough';
|
|
716
|
+
return 'standard';
|
|
717
|
+
},
|
|
718
|
+
|
|
719
|
+
async heuristicFallback(input) {
|
|
720
|
+
const extractor = createPlaybookExtractor();
|
|
721
|
+
return extractor.extract(input.trajectories, input.analyses, input.existingPlaybooks);
|
|
722
|
+
},
|
|
723
|
+
|
|
724
|
+
computeRequirements: { mode: 'local', complexity: 'standard' },
|
|
725
|
+
};
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
**Workspace layout:**
|
|
729
|
+
```
|
|
730
|
+
input/
|
|
731
|
+
summary.md # YAML: batchSize, domains[], successRate
|
|
732
|
+
trajectories/
|
|
733
|
+
{trajectoryId}.jsonl # One per trajectory, one step per line
|
|
734
|
+
analyses/
|
|
735
|
+
{trajectoryId}.json # Pre-computed analysis from template 4.1
|
|
736
|
+
existing-playbooks/
|
|
737
|
+
{playbookName}.json # For deduplication
|
|
738
|
+
skills/ # Extraction playbooks → SKILL.md
|
|
739
|
+
output/
|
|
740
|
+
playbooks/ # New playbooks (JSON)
|
|
741
|
+
updates/ # Updates to existing playbooks (JSON)
|
|
742
|
+
extraction-summary.json # Required: counts, patterns found, confidence
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
### 4.3 Usage Inference Template
|
|
746
|
+
|
|
747
|
+
**Replaces:** `PlaybookUsageInference` (task 7)
|
|
748
|
+
|
|
749
|
+
```typescript
|
|
750
|
+
// workspace/templates/usage-inference.ts
|
|
751
|
+
|
|
752
|
+
interface UsageInferenceInput {
|
|
753
|
+
trajectory: Trajectory;
|
|
754
|
+
injectedPlaybooks: Playbook[];
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// Output: PlaybookUsageResult[] from learning/usage-inference.ts
|
|
758
|
+
|
|
759
|
+
const usageInferenceTemplate: AgenticTaskTemplate<
|
|
760
|
+
UsageInferenceInput,
|
|
761
|
+
PlaybookUsageResult[]
|
|
762
|
+
> = {
|
|
763
|
+
taskType: 'usage-inference',
|
|
764
|
+
domain: 'usage-inference',
|
|
765
|
+
description: 'Determine which injected playbooks were actually followed',
|
|
766
|
+
|
|
767
|
+
assessComplexity(input) {
|
|
768
|
+
if (input.injectedPlaybooks.length === 0) return 'heuristic';
|
|
769
|
+
if (input.injectedPlaybooks.length <= 2 && input.trajectory.steps.length <= 10) {
|
|
770
|
+
return 'heuristic';
|
|
771
|
+
}
|
|
772
|
+
return 'lightweight';
|
|
773
|
+
},
|
|
774
|
+
|
|
775
|
+
async heuristicFallback(input) {
|
|
776
|
+
const inference = createUsageInference();
|
|
777
|
+
return inference.inferUsage(input.trajectory, input.injectedPlaybooks);
|
|
778
|
+
},
|
|
779
|
+
|
|
780
|
+
computeRequirements: { mode: 'local', complexity: 'lightweight' },
|
|
781
|
+
};
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
### 4.4 Meta-Reflection Template
|
|
785
|
+
|
|
786
|
+
**Replaces:** `MetaLearner.generateReflection()` (task 8)
|
|
787
|
+
|
|
788
|
+
```typescript
|
|
789
|
+
// workspace/templates/meta-reflection.ts
|
|
790
|
+
|
|
791
|
+
interface MetaReflectionInput {
|
|
792
|
+
trajectory: Trajectory;
|
|
793
|
+
routingDecision: RoutingDecision;
|
|
794
|
+
playbooksUsed: Playbook[];
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Output: MetaObservation from types/meta.ts
|
|
798
|
+
|
|
799
|
+
const metaReflectionTemplate: AgenticTaskTemplate<
|
|
800
|
+
MetaReflectionInput,
|
|
801
|
+
MetaObservation
|
|
802
|
+
> = {
|
|
803
|
+
taskType: 'meta-reflection',
|
|
804
|
+
domain: 'meta-reflection',
|
|
805
|
+
description: 'Reflect on task execution to generate meta-learning observations',
|
|
806
|
+
|
|
807
|
+
assessComplexity(input) {
|
|
808
|
+
// Clear success with high confidence routing → heuristic
|
|
809
|
+
if (input.trajectory.outcome.success && input.routingDecision.confidence > 0.8) {
|
|
810
|
+
return 'heuristic';
|
|
811
|
+
}
|
|
812
|
+
return 'lightweight';
|
|
813
|
+
},
|
|
814
|
+
|
|
815
|
+
async heuristicFallback(input) {
|
|
816
|
+
// Existing MetaLearner logic (word overlap, outcome quality heuristics)
|
|
817
|
+
// Extract from MetaLearner.generateReflection() into standalone function
|
|
818
|
+
},
|
|
819
|
+
|
|
820
|
+
computeRequirements: { mode: 'local', complexity: 'lightweight' },
|
|
821
|
+
};
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### 4.5 Solution Evaluation Template
|
|
825
|
+
|
|
826
|
+
**Replaces:** `SolutionEvaluator` Tier 2 (task 9)
|
|
827
|
+
|
|
828
|
+
```typescript
|
|
829
|
+
// workspace/templates/solution-evaluation.ts
|
|
830
|
+
|
|
831
|
+
interface SolutionEvaluationInput {
|
|
832
|
+
trajectory: Trajectory;
|
|
833
|
+
task: Task;
|
|
834
|
+
solution?: unknown;
|
|
835
|
+
codebasePath?: string;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// Output: EvaluationResult from search/refinement-types.ts
|
|
839
|
+
|
|
840
|
+
const solutionEvaluationTemplate: AgenticTaskTemplate<
|
|
841
|
+
SolutionEvaluationInput,
|
|
842
|
+
EvaluationResult
|
|
843
|
+
> = {
|
|
844
|
+
taskType: 'solution-evaluation',
|
|
845
|
+
domain: 'solution-evaluation',
|
|
846
|
+
description: 'Evaluate solution quality from trajectory',
|
|
847
|
+
|
|
848
|
+
assessComplexity(input) {
|
|
849
|
+
// Programmatic verification available → use that (Tier 1)
|
|
850
|
+
if (input.task.verification) return 'heuristic';
|
|
851
|
+
if (input.trajectory.outcome.success && input.trajectory.steps.length <= 10) {
|
|
852
|
+
return 'lightweight';
|
|
853
|
+
}
|
|
854
|
+
return 'standard';
|
|
855
|
+
},
|
|
856
|
+
|
|
857
|
+
getResources(input) {
|
|
858
|
+
// Symlink codebase for verification if available
|
|
859
|
+
if (input.codebasePath) {
|
|
860
|
+
return [{ path: 'codebase', type: 'symlink', source: input.codebasePath }];
|
|
861
|
+
}
|
|
862
|
+
return [];
|
|
863
|
+
},
|
|
864
|
+
|
|
865
|
+
computeRequirements: { mode: 'local', complexity: 'standard' },
|
|
866
|
+
};
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
### 4.6 Refinement Analysis Template
|
|
870
|
+
|
|
871
|
+
**Replaces:** inline refinement prompt building in `RefinementLoop` (task 10)
|
|
872
|
+
|
|
873
|
+
```typescript
|
|
874
|
+
// workspace/templates/refinement-analysis.ts
|
|
875
|
+
|
|
876
|
+
interface RefinementAnalysisInput {
|
|
877
|
+
trajectory: Trajectory;
|
|
878
|
+
task: Task;
|
|
879
|
+
evaluation: EvaluationResult;
|
|
880
|
+
previousAttempts: number;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
interface RefinementPlan {
|
|
884
|
+
rootCauses: string[];
|
|
885
|
+
strategy: string;
|
|
886
|
+
steps: string[];
|
|
887
|
+
avoidPatterns: string[];
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
const refinementAnalysisTemplate: AgenticTaskTemplate<
|
|
891
|
+
RefinementAnalysisInput,
|
|
892
|
+
RefinementPlan
|
|
893
|
+
> = {
|
|
894
|
+
taskType: 'refinement-analysis',
|
|
895
|
+
domain: 'refinement-analysis',
|
|
896
|
+
description: 'Analyze failure and plan refinement strategy',
|
|
897
|
+
|
|
898
|
+
assessComplexity(input) {
|
|
899
|
+
// First failure → lightweight analysis
|
|
900
|
+
if (input.previousAttempts <= 1) return 'lightweight';
|
|
901
|
+
// Repeated failures → deeper analysis
|
|
902
|
+
return 'standard';
|
|
903
|
+
},
|
|
904
|
+
|
|
905
|
+
// No heuristic fallback — refinement analysis always benefits from semantic reasoning
|
|
906
|
+
|
|
907
|
+
computeRequirements: { mode: 'local', complexity: 'lightweight' },
|
|
908
|
+
};
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
---
|
|
912
|
+
|
|
913
|
+
## Part 5: File Changes
|
|
914
|
+
|
|
915
|
+
### 5.1 New Files
|
|
916
|
+
|
|
917
|
+
| File | Purpose |
|
|
918
|
+
|------|---------|
|
|
919
|
+
| `src/runtime/compute-provider.ts` | `ComputeProvider` interface + `DefaultComputeProvider` |
|
|
920
|
+
| `src/workspace/templates/trajectory-analysis.ts` | Template for tasks 1–4 |
|
|
921
|
+
| `src/workspace/templates/playbook-extraction.ts` | Template for tasks 5–6 |
|
|
922
|
+
| `src/workspace/templates/usage-inference.ts` | Template for task 7 |
|
|
923
|
+
| `src/workspace/templates/meta-reflection.ts` | Template for task 8 |
|
|
924
|
+
| `src/workspace/templates/solution-evaluation.ts` | Template for task 9 |
|
|
925
|
+
| `src/workspace/templates/refinement-analysis.ts` | Template for task 10 |
|
|
926
|
+
| `src/workspace/templates/index.ts` | Barrel export |
|
|
927
|
+
|
|
928
|
+
### 5.2 Modified Files
|
|
929
|
+
|
|
930
|
+
| File | Change |
|
|
931
|
+
|------|--------|
|
|
932
|
+
| `src/runtime/manager.ts` | Accept `ComputeProvider`, use in `spawn()` instead of `findBackend()` |
|
|
933
|
+
| `src/runtime/types.ts` | Add `computeRequirements` to `AgentSpawnConfig` |
|
|
934
|
+
| `src/runtime/backends/acp.ts` | Extract protocol handling into `ACPProtocolMixin` |
|
|
935
|
+
| `src/workspace/types.ts` | Add `computeRequirements` and `getComputeRequirements` to template interface |
|
|
936
|
+
| `src/workspace/runner.ts` | Pass compute requirements through to `AgentManager.spawn()` |
|
|
937
|
+
| `src/learning/pipeline.ts` | Accept `AgenticTaskRunner`, delegate to templates when available |
|
|
938
|
+
| `src/atlas.ts` | Wire `MetaLearner`, `EffectivenessTracker`, use templates in post-execution |
|
|
939
|
+
| `src/types/config.ts` | Add `ComputeProviderConfigSchema` to `AtlasConfigSchema` |
|
|
940
|
+
|
|
941
|
+
### 5.3 Unchanged Files
|
|
942
|
+
|
|
943
|
+
| File | Reason |
|
|
944
|
+
|------|--------|
|
|
945
|
+
| `src/learning/analyzer.ts` | Kept as heuristic fallback, called by `trajectoryAnalysisTemplate.heuristicFallback()` |
|
|
946
|
+
| `src/learning/playbook-extractor.ts` | Kept as heuristic fallback, called by `playbookExtractionTemplate.heuristicFallback()` |
|
|
947
|
+
| `src/learning/usage-inference.ts` | Kept as heuristic fallback |
|
|
948
|
+
| `src/learning/meta-learner.ts` | Kept as heuristic fallback + strategy generation logic |
|
|
949
|
+
| `src/learning/effectiveness.ts` | No migration needed (pure metrics) |
|
|
950
|
+
| `src/search/router.ts` | Low priority migration (C), functional as-is |
|
|
951
|
+
| `src/search/evaluator.ts` | Kept as heuristic fallback for Tier 1/3 |
|
|
952
|
+
| `src/search/refinement-loop.ts` | Structure preserved, inner analysis delegated to template |
|
|
953
|
+
|
|
954
|
+
---
|
|
955
|
+
|
|
956
|
+
## Part 6: Implementation Order
|
|
957
|
+
|
|
958
|
+
### Phase 1: Compute Provider (no behavior change)
|
|
959
|
+
|
|
960
|
+
1. Create `src/runtime/compute-provider.ts` with `DefaultComputeProvider`
|
|
961
|
+
2. Add `computeRequirements` to `AgentSpawnConfig`
|
|
962
|
+
3. Update `AgentManager` to use `ComputeProvider` (default provider replicates current behavior exactly)
|
|
963
|
+
4. Update `registerBackend()` to wrap backends in `ComputeSource`
|
|
964
|
+
|
|
965
|
+
**Verification:** All existing tests pass unchanged. No behavioral difference.
|
|
966
|
+
|
|
967
|
+
### Phase 2: Wire Disconnected Subsystems
|
|
968
|
+
|
|
969
|
+
1. Create `MetaLearner` in `Atlas.init()`, connect to `TaskRouter`
|
|
970
|
+
2. Call `EffectivenessTracker.annotate()` in `Atlas.solve()` post-execution
|
|
971
|
+
3. Ensure `LearningEffectivenessTracker` is initialized in `Atlas.init()`
|
|
972
|
+
|
|
973
|
+
**Verification:** New integration tests confirm meta-observations are recorded and effectiveness annotations are created.
|
|
974
|
+
|
|
975
|
+
### Phase 3: First Template Migration (trajectory analysis)
|
|
976
|
+
|
|
977
|
+
1. Create `workspace/templates/trajectory-analysis.ts`
|
|
978
|
+
2. Add `setTaskRunner()` to `LearningPipeline`
|
|
979
|
+
3. Update `LearningPipeline.processTrajectory()` to delegate when runner is available
|
|
980
|
+
4. Wire `taskRunner` into `LearningPipeline` via `Atlas.setAgentManager()`
|
|
981
|
+
|
|
982
|
+
**Verification:** Existing `LearningPipeline` tests pass. New tests confirm:
|
|
983
|
+
- Simple trajectories hit `heuristicFallback()` (fast, free)
|
|
984
|
+
- Complex trajectories spawn an agent in a workspace
|
|
985
|
+
- Output validates against `AnalysisResult` schema
|
|
986
|
+
|
|
987
|
+
### Phase 4: Remaining Priority-A Templates
|
|
988
|
+
|
|
989
|
+
1. `playbook-extraction.ts` — update `LearningPipeline.runBatchLearning()`
|
|
990
|
+
2. `usage-inference.ts` — update `Atlas.solve()` post-execution
|
|
991
|
+
3. Delete `LLMPlaybookExtractor` (absorbed into playbook extraction template)
|
|
992
|
+
|
|
993
|
+
**Verification:** Each template has its own test suite. Integration tests confirm the full `solve() → learn → extract` flow.
|
|
994
|
+
|
|
995
|
+
### Phase 5: Priority-B Templates
|
|
996
|
+
|
|
997
|
+
1. `meta-reflection.ts` — update `Atlas.solve()` to use template instead of direct `MetaLearner`
|
|
998
|
+
2. `solution-evaluation.ts` — update `SolutionEvaluator` to delegate when runner available
|
|
999
|
+
3. `refinement-analysis.ts` — update `RefinementLoop` to use template for failure analysis
|
|
1000
|
+
|
|
1001
|
+
### Phase 6: ACPBackend Split
|
|
1002
|
+
|
|
1003
|
+
1. Extract `ACPProtocolMixin` from `ACPBackend`
|
|
1004
|
+
2. Create `LocalACPBackend extends ACPProtocolMixin`
|
|
1005
|
+
3. (Future) `RemoteACPBackend extends ACPProtocolMixin`
|
|
1006
|
+
|
|
1007
|
+
**This phase is independent** and can happen in parallel with template migrations.
|
|
1008
|
+
|
|
1009
|
+
---
|
|
1010
|
+
|
|
1011
|
+
## Part 7: Cost Model
|
|
1012
|
+
|
|
1013
|
+
### 7.1 Per-Template Estimates
|
|
1014
|
+
|
|
1015
|
+
| Template | Heuristic Path | Lightweight | Standard | Thorough |
|
|
1016
|
+
|----------|---------------|-------------|----------|----------|
|
|
1017
|
+
| trajectory-analysis | ~0 tokens | ~2K | ~5K | — |
|
|
1018
|
+
| playbook-extraction | ~0 tokens | — | ~8K | ~15K |
|
|
1019
|
+
| usage-inference | ~0 tokens | ~1K | — | — |
|
|
1020
|
+
| meta-reflection | ~0 tokens | ~2K | — | — |
|
|
1021
|
+
| solution-evaluation | ~0 tokens | ~2K | ~5K | — |
|
|
1022
|
+
| refinement-analysis | — | ~2K | ~4K | — |
|
|
1023
|
+
|
|
1024
|
+
### 7.2 Typical Flow Cost
|
|
1025
|
+
|
|
1026
|
+
For a single `Atlas.solve()` call on a moderate task:
|
|
1027
|
+
|
|
1028
|
+
| Step | Complexity Hit | Cost |
|
|
1029
|
+
|------|---------------|------|
|
|
1030
|
+
| Task execution (the actual agent work) | — | ~10-50K tokens |
|
|
1031
|
+
| Usage inference (2 playbooks, 8 steps) | heuristic | 0 |
|
|
1032
|
+
| Meta-reflection (clear success, high confidence) | heuristic | 0 |
|
|
1033
|
+
| Trajectory analysis (8 steps, success) | heuristic | 0 |
|
|
1034
|
+
| **Total overhead from learning** | | **~0 tokens** |
|
|
1035
|
+
|
|
1036
|
+
For a complex failed task:
|
|
1037
|
+
|
|
1038
|
+
| Step | Complexity Hit | Cost |
|
|
1039
|
+
|------|---------------|------|
|
|
1040
|
+
| Task execution | — | ~30-100K tokens |
|
|
1041
|
+
| Usage inference (5 playbooks, 25 steps) | lightweight | ~1K |
|
|
1042
|
+
| Meta-reflection (failure, low confidence) | lightweight | ~2K |
|
|
1043
|
+
| Trajectory analysis (25 steps, failure) | standard | ~5K |
|
|
1044
|
+
| **Total overhead from learning** | | **~8K tokens** |
|
|
1045
|
+
|
|
1046
|
+
Batch learning (triggered every ~10 trajectories):
|
|
1047
|
+
|
|
1048
|
+
| Step | Complexity Hit | Cost |
|
|
1049
|
+
|------|---------------|------|
|
|
1050
|
+
| Playbook extraction (10 trajectories) | standard | ~8K |
|
|
1051
|
+
| **Total batch cost** | | **~8K tokens** |
|
|
1052
|
+
|
|
1053
|
+
The heuristic fallback path ensures that the common case (simple successful tasks) adds zero cost. Semantic analysis is reserved for the ~20% of cases where it matters: failures, complex trajectories, batch extraction.
|
|
1054
|
+
|
|
1055
|
+
---
|
|
1056
|
+
|
|
1057
|
+
## Appendix A: Existing Code to Preserve as Heuristic Fallbacks
|
|
1058
|
+
|
|
1059
|
+
These implementations remain in the codebase, called by `heuristicFallback()` on their respective templates:
|
|
1060
|
+
|
|
1061
|
+
| Implementation | Call Path |
|
|
1062
|
+
|----------------|-----------|
|
|
1063
|
+
| `TrajectoryAnalyzer.analyze()` | `trajectoryAnalysisTemplate.heuristicFallback()` |
|
|
1064
|
+
| `PlaybookExtractor.extract()` | `playbookExtractionTemplate.heuristicFallback()` |
|
|
1065
|
+
| `PlaybookUsageInference.inferUsage()` | `usageInferenceTemplate.heuristicFallback()` |
|
|
1066
|
+
| `MetaLearner.generateReflection()` logic | `metaReflectionTemplate.heuristicFallback()` |
|
|
1067
|
+
| `SolutionEvaluator` Tier 1+3 | `solutionEvaluationTemplate.heuristicFallback()` |
|
|
1068
|
+
|
|
1069
|
+
No existing code is deleted during migration. The heuristic implementations are the fallback path and continue to be tested independently.
|
|
1070
|
+
|
|
1071
|
+
## Appendix B: Backwards Compatibility
|
|
1072
|
+
|
|
1073
|
+
| Scenario | Behavior |
|
|
1074
|
+
|----------|----------|
|
|
1075
|
+
| `Atlas` with no `AgentManager` | `LearningPipeline` uses heuristic analyzers directly (no `taskRunner`) |
|
|
1076
|
+
| `Atlas` with `AgentManager` but no workspace templates registered | `LearningPipeline` uses heuristic analyzers (taskRunner exists but templates not wired) |
|
|
1077
|
+
| `AgentManager` with single backend | `DefaultComputeProvider` resolves to that backend (current behavior) |
|
|
1078
|
+
| `registerBackend()` called without `ComputeSource` options | Backend wrapped with default cost/location/priority |
|
|
1079
|
+
| Template with no `computeRequirements` | `ComputeProvider.resolve()` called with no requirements (returns highest-priority available) |
|