@llm-dev-ops/agentics-cli 1.4.59 → 1.4.68
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/README.md +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +167 -0
- package/dist/commands/agents.js.map +1 -1
- package/dist/pipeline/auto-chain.d.ts +1 -0
- package/dist/pipeline/auto-chain.d.ts.map +1 -1
- package/dist/pipeline/auto-chain.js +124 -37
- package/dist/pipeline/auto-chain.js.map +1 -1
- package/dist/pipeline/execution-context.d.ts.map +1 -1
- package/dist/pipeline/execution-context.js +12 -37
- package/dist/pipeline/execution-context.js.map +1 -1
- package/dist/pipeline/phase2/phases/adr-generator.d.ts.map +1 -1
- package/dist/pipeline/phase2/phases/adr-generator.js +160 -1
- package/dist/pipeline/phase2/phases/adr-generator.js.map +1 -1
- package/dist/pipeline/phase2/phases/ddd-generator.d.ts.map +1 -1
- package/dist/pipeline/phase2/phases/ddd-generator.js +400 -3
- package/dist/pipeline/phase2/phases/ddd-generator.js.map +1 -1
- package/dist/pipeline/phase2/phases/ddd-quality-gate.d.ts +43 -0
- package/dist/pipeline/phase2/phases/ddd-quality-gate.d.ts.map +1 -0
- package/dist/pipeline/phase2/phases/ddd-quality-gate.js +413 -0
- package/dist/pipeline/phase2/phases/ddd-quality-gate.js.map +1 -0
- package/dist/pipeline/phase2/phases/research-dossier.d.ts +0 -13
- package/dist/pipeline/phase2/phases/research-dossier.d.ts.map +1 -1
- package/dist/pipeline/phase2/phases/research-dossier.js +114 -1
- package/dist/pipeline/phase2/phases/research-dossier.js.map +1 -1
- package/dist/pipeline/phase2/phases/research-quality-gate.d.ts +48 -0
- package/dist/pipeline/phase2/phases/research-quality-gate.d.ts.map +1 -0
- package/dist/pipeline/phase2/phases/research-quality-gate.js +322 -0
- package/dist/pipeline/phase2/phases/research-quality-gate.js.map +1 -0
- package/dist/pipeline/phase2/phases/sparc-quality-gate.d.ts +41 -0
- package/dist/pipeline/phase2/phases/sparc-quality-gate.d.ts.map +1 -0
- package/dist/pipeline/phase2/phases/sparc-quality-gate.js +350 -0
- package/dist/pipeline/phase2/phases/sparc-quality-gate.js.map +1 -0
- package/dist/pipeline/phase2/phases/sparc-specification.d.ts +14 -0
- package/dist/pipeline/phase2/phases/sparc-specification.d.ts.map +1 -1
- package/dist/pipeline/phase2/phases/sparc-specification.js +500 -10
- package/dist/pipeline/phase2/phases/sparc-specification.js.map +1 -1
- package/dist/pipeline/phase2/phases/tdd-plan-generator.js +1 -1
- package/dist/pipeline/phase2/phases/tdd-plan-generator.js.map +1 -1
- package/dist/pipeline/phase2/phases/tech-stack-detector.d.ts +72 -0
- package/dist/pipeline/phase2/phases/tech-stack-detector.d.ts.map +1 -0
- package/dist/pipeline/phase2/phases/tech-stack-detector.js +332 -0
- package/dist/pipeline/phase2/phases/tech-stack-detector.js.map +1 -0
- package/dist/pipeline/phase2/types.d.ts +2 -0
- package/dist/pipeline/phase2/types.d.ts.map +1 -1
- package/dist/pipeline/phase3/phases/domain-codegen.d.ts.map +1 -1
- package/dist/pipeline/phase3/phases/domain-codegen.js +169 -4
- package/dist/pipeline/phase3/phases/domain-codegen.js.map +1 -1
- package/dist/pipeline/phase3/phases/test-generator.d.ts.map +1 -1
- package/dist/pipeline/phase3/phases/test-generator.js +12 -2
- package/dist/pipeline/phase3/phases/test-generator.js.map +1 -1
- package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.d.ts.map +1 -1
- package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js +99 -1
- package/dist/pipeline/phase3-sparc/phase3-sparc-coordinator.js.map +1 -1
- package/dist/pipeline/phase4/phases/deployment-generator.d.ts +17 -4
- package/dist/pipeline/phase4/phases/deployment-generator.d.ts.map +1 -1
- package/dist/pipeline/phase4/phases/deployment-generator.js +364 -44
- package/dist/pipeline/phase4/phases/deployment-generator.js.map +1 -1
- package/dist/pipeline/phase4/phases/erp-client-generator.d.ts.map +1 -1
- package/dist/pipeline/phase4/phases/erp-client-generator.js +27 -15
- package/dist/pipeline/phase4/phases/erp-client-generator.js.map +1 -1
- package/dist/pipeline/phase4/phases/erp-target-resolver.d.ts.map +1 -1
- package/dist/pipeline/phase4/phases/erp-target-resolver.js +49 -2
- package/dist/pipeline/phase4/phases/erp-target-resolver.js.map +1 -1
- package/dist/pipeline/phase4/phases/http-server-generator.d.ts.map +1 -1
- package/dist/pipeline/phase4/phases/http-server-generator.js +263 -3
- package/dist/pipeline/phase4/phases/http-server-generator.js.map +1 -1
- package/dist/pipeline/phase4/phases/infra-adapter-generator.d.ts.map +1 -1
- package/dist/pipeline/phase4/phases/infra-adapter-generator.js +335 -37
- package/dist/pipeline/phase4/phases/infra-adapter-generator.js.map +1 -1
- package/dist/pipeline/phase4/types.d.ts +3 -1
- package/dist/pipeline/phase4/types.d.ts.map +1 -1
- package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.d.ts.map +1 -1
- package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js +211 -2
- package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js.map +1 -1
- package/dist/pipeline/phase5-build/phases/implementation-quality-gate.d.ts +54 -0
- package/dist/pipeline/phase5-build/phases/implementation-quality-gate.d.ts.map +1 -0
- package/dist/pipeline/phase5-build/phases/implementation-quality-gate.js +417 -0
- package/dist/pipeline/phase5-build/phases/implementation-quality-gate.js.map +1 -0
- package/dist/pipeline/phases/prompt-generator.js +1 -1
- package/dist/pipeline/phases/prompt-generator.js.map +1 -1
- package/dist/pipeline/ruflo-phase-executor.d.ts +116 -1
- package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
- package/dist/pipeline/ruflo-phase-executor.js +666 -159
- package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
- package/dist/pipeline/swarm-orchestrator.d.ts.map +1 -1
- package/dist/pipeline/swarm-orchestrator.js +62 -6
- package/dist/pipeline/swarm-orchestrator.js.map +1 -1
- package/dist/routing/capability-classifier.d.ts +43 -0
- package/dist/routing/capability-classifier.d.ts.map +1 -0
- package/dist/routing/capability-classifier.js +157 -0
- package/dist/routing/capability-classifier.js.map +1 -0
- package/dist/routing/composition-engine.d.ts +77 -0
- package/dist/routing/composition-engine.d.ts.map +1 -0
- package/dist/routing/composition-engine.js +249 -0
- package/dist/routing/composition-engine.js.map +1 -0
- package/dist/routing/graph-federation.d.ts +71 -0
- package/dist/routing/graph-federation.d.ts.map +1 -0
- package/dist/routing/graph-federation.js +210 -0
- package/dist/routing/graph-federation.js.map +1 -0
- package/dist/routing/graph-loader.d.ts +74 -0
- package/dist/routing/graph-loader.d.ts.map +1 -0
- package/dist/routing/graph-loader.js +383 -0
- package/dist/routing/graph-loader.js.map +1 -0
- package/dist/routing/graph-router.d.ts +103 -0
- package/dist/routing/graph-router.d.ts.map +1 -0
- package/dist/routing/graph-router.js +415 -0
- package/dist/routing/graph-router.js.map +1 -0
- package/dist/routing/graph-validator.d.ts +44 -0
- package/dist/routing/graph-validator.d.ts.map +1 -0
- package/dist/routing/graph-validator.js +329 -0
- package/dist/routing/graph-validator.js.map +1 -0
- package/dist/routing/index.d.ts +52 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +68 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/outcome-recorder.d.ts +71 -0
- package/dist/routing/outcome-recorder.d.ts.map +1 -0
- package/dist/routing/outcome-recorder.js +133 -0
- package/dist/routing/outcome-recorder.js.map +1 -0
- package/dist/routing/weight-adjuster.d.ts +59 -0
- package/dist/routing/weight-adjuster.d.ts.map +1 -0
- package/dist/routing/weight-adjuster.js +167 -0
- package/dist/routing/weight-adjuster.js.map +1 -0
- package/dist/routing/weighted-resolver.d.ts +55 -0
- package/dist/routing/weighted-resolver.d.ts.map +1 -0
- package/dist/routing/weighted-resolver.js +133 -0
- package/dist/routing/weighted-resolver.js.map +1 -0
- package/dist/synthesis/ask-artifact-writer.d.ts.map +1 -1
- package/dist/synthesis/ask-artifact-writer.js +8 -0
- package/dist/synthesis/ask-artifact-writer.js.map +1 -1
- package/dist/synthesis/simulation-artifact-generator.d.ts +14 -0
- package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
- package/dist/synthesis/simulation-artifact-generator.js +224 -1
- package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
- package/dist/synthesis/simulation-renderers.d.ts.map +1 -1
- package/dist/synthesis/simulation-renderers.js +211 -40
- package/dist/synthesis/simulation-renderers.js.map +1 -1
- package/package.json +1 -1
- package/dist/bundled-agents/connector-hub-agents/package-lock.json +0 -11697
- package/dist/bundled-agents/connector-hub-agents/package.json +0 -75
- package/dist/bundled-agents/connector-hub-agents/tsconfig.build.json +0 -22
- package/dist/bundled-agents/connector-hub-agents/tsconfig.json +0 -57
- package/dist/bundled-agents/copilot-agents/functions/.gcloudignore +0 -17
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.d.ts +0 -14
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.js +0 -35
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/cors.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.d.ts +0 -55
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.js +0 -40
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/envelope.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.d.ts +0 -22
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.js +0 -38
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/health.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.d.ts +0 -34
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.js +0 -186
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.d.ts +0 -36
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.js +0 -121
- package/dist/bundled-agents/copilot-agents/functions/dist/functions/src/router.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.d.ts +0 -157
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.js +0 -948
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/config-validation-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.d.ts +0 -9
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.js +0 -27
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/config-validation/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.d.ts +0 -23
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.js +0 -50
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/agent-span-wrapper.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.d.ts +0 -214
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.js +0 -91
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/base-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.d.ts +0 -1166
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.js +0 -308
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/config-validation-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.d.ts +0 -59
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.js +0 -62
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decision-event.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.d.ts +0 -400
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.js +0 -113
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/decomposer-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.d.ts +0 -250
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.js +0 -169
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/execution-graph.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.d.ts +0 -17
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.js +0 -97
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.d.ts +0 -1674
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.js +0 -246
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intelligence-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.d.ts +0 -1085
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.js +0 -218
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/intent-classifier-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.d.ts +0 -949
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.js +0 -253
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/meta-reasoner-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.d.ts +0 -657
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.js +0 -205
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/objective-clarifier-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.d.ts +0 -285
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.js +0 -106
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/pipeline-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.d.ts +0 -581
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.js +0 -136
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/planner-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.d.ts +0 -791
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.js +0 -225
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/contracts/reflection-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.d.ts +0 -120
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.js +0 -535
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/decomposer-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.d.ts +0 -9
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.js +0 -18
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/decomposer/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.d.ts +0 -4
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.js +0 -9
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.d.ts +0 -123
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.js +0 -609
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/intent-classifier/intent-classifier-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.d.ts +0 -10
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.d.ts +0 -111
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.js +0 -686
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/meta-reasoner-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/meta-reasoner/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.d.ts +0 -6
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.js +0 -15
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.d.ts +0 -126
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.js +0 -780
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/objective-clarifier-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.d.ts +0 -49
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.js +0 -125
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.d.ts +0 -73
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.js +0 -192
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/objective-clarifier/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.d.ts +0 -127
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.js +0 -483
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/planner-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.d.ts +0 -49
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.js +0 -125
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.d.ts +0 -73
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.js +0 -192
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/planner/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.js +0 -27
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.d.ts +0 -122
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.js +0 -645
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/reflection-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.d.ts +0 -59
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.js +0 -156
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.d.ts +0 -88
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.js +0 -246
- package/dist/bundled-agents/copilot-agents/functions/dist/services/agents/reflection/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/index.js +0 -4
- package/dist/bundled-agents/copilot-agents/functions/jest.config.js +0 -29
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.d.ts +0 -14
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.js +0 -35
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/cors.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.d.ts +0 -27
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.js +0 -21
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/envelope.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.d.ts +0 -22
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.js +0 -38
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/health.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.d.ts +0 -34
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.js +0 -174
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.d.ts +0 -27
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.js +0 -107
- package/dist/bundled-agents/copilot-agents/functions/lib/functions/src/router.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.d.ts +0 -157
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.js +0 -941
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/config-validation-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.d.ts +0 -9
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.js +0 -27
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/config-validation/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.d.ts +0 -23
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.js +0 -50
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/agent-span-wrapper.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.d.ts +0 -185
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.js +0 -86
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/base-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.d.ts +0 -1081
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.js +0 -305
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/config-validation-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.d.ts +0 -59
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.js +0 -62
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decision-event.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.d.ts +0 -315
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.js +0 -110
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/decomposer-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.d.ts +0 -250
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.js +0 -169
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/execution-graph.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.d.ts +0 -16
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.js +0 -88
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.d.ts +0 -1674
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.js +0 -246
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intelligence-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.d.ts +0 -1000
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.js +0 -215
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/intent-classifier-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.d.ts +0 -864
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.js +0 -250
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/meta-reasoner-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.d.ts +0 -572
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.js +0 -202
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/objective-clarifier-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.d.ts +0 -496
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.js +0 -133
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/planner-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.d.ts +0 -706
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.js +0 -222
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/contracts/reflection-schemas.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.d.ts +0 -107
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.js +0 -360
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/decomposer-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.d.ts +0 -9
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.js +0 -18
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/decomposer/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.d.ts +0 -4
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.js +0 -9
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.d.ts +0 -123
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.js +0 -609
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/intent-classifier/intent-classifier-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.d.ts +0 -10
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.d.ts +0 -111
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.js +0 -686
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/meta-reasoner-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/meta-reasoner/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.d.ts +0 -6
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.js +0 -15
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.d.ts +0 -126
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.js +0 -780
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/objective-clarifier-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.d.ts +0 -49
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.js +0 -125
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.d.ts +0 -73
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.js +0 -192
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/objective-clarifier/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.js +0 -25
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.d.ts +0 -119
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.js +0 -421
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/planner-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.d.ts +0 -49
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.js +0 -125
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.d.ts +0 -73
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.js +0 -192
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/planner/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.d.ts +0 -11
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.js +0 -27
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/index.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.d.ts +0 -122
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.js +0 -645
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/reflection-agent.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.d.ts +0 -59
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.js +0 -156
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/ruvector-persistence.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.d.ts +0 -88
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.js +0 -246
- package/dist/bundled-agents/copilot-agents/functions/lib/services/agents/reflection/telemetry.js.map +0 -1
- package/dist/bundled-agents/copilot-agents/functions/package-lock.json +0 -5473
- package/dist/bundled-agents/copilot-agents/functions/package.json +0 -40
- package/dist/bundled-agents/copilot-agents/functions/src/claude.ts +0 -71
- package/dist/bundled-agents/copilot-agents/functions/src/cors.ts +0 -36
- package/dist/bundled-agents/copilot-agents/functions/src/envelope.ts +0 -77
- package/dist/bundled-agents/copilot-agents/functions/src/handler.test.ts +0 -340
- package/dist/bundled-agents/copilot-agents/functions/src/health.ts +0 -53
- package/dist/bundled-agents/copilot-agents/functions/src/index.ts +0 -201
- package/dist/bundled-agents/copilot-agents/functions/src/router.ts +0 -148
- package/dist/bundled-agents/copilot-agents/functions/tsconfig.json +0 -31
- package/dist/bundled-agents/copilot-agents/package-lock.json +0 -11825
- package/dist/bundled-agents/copilot-agents/package.json +0 -5
- package/dist/bundled-agents/governance-dashboard-agents/package-lock.json +0 -8282
- package/dist/bundled-agents/governance-dashboard-agents/package.json +0 -13
- package/dist/bundled-agents/orchestrator-agents/functions/contracts/index.js +0 -590
- package/dist/bundled-agents/orchestrator-agents/functions/index.js +0 -442
- package/dist/bundled-agents/orchestrator-agents/functions/test.js +0 -325
- package/dist/bundled-agents/orchestrator-agents/index.js +0 -6
- package/dist/bundled-agents/orchestrator-agents/package-lock.json +0 -13254
- package/dist/bundled-agents/orchestrator-agents/package.json +0 -20
- package/dist/bundled-agents/platform-agents/package-lock.json +0 -1723
- package/dist/bundled-agents/platform-agents/package.json +0 -22
- package/dist/bundled-agents/platform-agents/src/agents/decision-memo.ts +0 -463
- package/dist/bundled-agents/platform-agents/src/agents/decision.ts +0 -234
- package/dist/bundled-agents/platform-agents/src/agents/executive-summary.ts +0 -229
- package/dist/bundled-agents/platform-agents/src/agents/risk-score.ts +0 -327
- package/dist/bundled-agents/platform-agents/src/claude.ts +0 -71
- package/dist/bundled-agents/platform-agents/src/cors.ts +0 -24
- package/dist/bundled-agents/platform-agents/src/envelope.ts +0 -37
- package/dist/bundled-agents/platform-agents/src/health.ts +0 -20
- package/dist/bundled-agents/platform-agents/src/index.ts +0 -171
- package/dist/bundled-agents/platform-agents/src/router.ts +0 -38
- package/dist/bundled-agents/platform-agents/src/text-analysis.ts +0 -238
- package/dist/bundled-agents/platform-agents/tsconfig.json +0 -19
- package/dist/bundled-agents/sentinel-agents/lib/agents/alert.d.ts +0 -3
- package/dist/bundled-agents/sentinel-agents/lib/agents/alert.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/alert.js +0 -43
- package/dist/bundled-agents/sentinel-agents/lib/agents/alert.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.d.ts +0 -3
- package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.js +0 -30
- package/dist/bundled-agents/sentinel-agents/lib/agents/anomaly.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.d.ts +0 -3
- package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.js +0 -53
- package/dist/bundled-agents/sentinel-agents/lib/agents/correlation.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/drift.d.ts +0 -3
- package/dist/bundled-agents/sentinel-agents/lib/agents/drift.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/drift.js +0 -51
- package/dist/bundled-agents/sentinel-agents/lib/agents/drift.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/rca.d.ts +0 -3
- package/dist/bundled-agents/sentinel-agents/lib/agents/rca.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/agents/rca.js +0 -36
- package/dist/bundled-agents/sentinel-agents/lib/agents/rca.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/index.d.ts +0 -2
- package/dist/bundled-agents/sentinel-agents/lib/index.d.ts.map +0 -1
- package/dist/bundled-agents/sentinel-agents/lib/index.js +0 -70
- package/dist/bundled-agents/sentinel-agents/lib/index.js.map +0 -1
- package/dist/bundled-agents/sentinel-agents/package-lock.json +0 -12591
- package/dist/bundled-agents/sentinel-agents/package.json +0 -62
- package/dist/bundled-agents/sentinel-agents/src/agents/alert.ts +0 -46
- package/dist/bundled-agents/sentinel-agents/src/agents/anomaly.ts +0 -33
- package/dist/bundled-agents/sentinel-agents/src/agents/correlation.ts +0 -56
- package/dist/bundled-agents/sentinel-agents/src/agents/drift.ts +0 -54
- package/dist/bundled-agents/sentinel-agents/src/agents/rca.ts +0 -38
- package/dist/bundled-agents/sentinel-agents/src/claude.ts +0 -71
- package/dist/bundled-agents/sentinel-agents/src/index.ts +0 -77
- package/dist/bundled-agents/sentinel-agents/tsconfig.json +0 -20
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome Recorder (ADR-031 Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* Records execution outcomes to a local JSONL file for telemetry feedback.
|
|
5
|
+
* Outcomes are used by the weight adjuster to improve routing precision.
|
|
6
|
+
*
|
|
7
|
+
* Storage: .agentics/telemetry/outcomes.jsonl (append-only)
|
|
8
|
+
* Format: One JSON object per line (JSONL)
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
import * as crypto from 'node:crypto';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Constants
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const DEFAULT_TELEMETRY_DIR = '.agentics/telemetry';
|
|
17
|
+
const OUTCOMES_FILE = 'outcomes.jsonl';
|
|
18
|
+
const MAX_RECORDS = 1000;
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Recording
|
|
21
|
+
// ============================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Record an execution outcome to the telemetry JSONL file.
|
|
24
|
+
* Creates the telemetry directory if it doesn't exist.
|
|
25
|
+
*/
|
|
26
|
+
export function recordOutcome(record, options) {
|
|
27
|
+
const basePath = options?.basePath ?? process.cwd();
|
|
28
|
+
const telemetryDir = path.join(basePath, DEFAULT_TELEMETRY_DIR);
|
|
29
|
+
const filePath = path.join(telemetryDir, OUTCOMES_FILE);
|
|
30
|
+
// Ensure directory exists
|
|
31
|
+
fs.mkdirSync(telemetryDir, { recursive: true });
|
|
32
|
+
// Append record as JSONL
|
|
33
|
+
const line = JSON.stringify(record) + '\n';
|
|
34
|
+
fs.appendFileSync(filePath, line, 'utf-8');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build an outcome record from execution data.
|
|
38
|
+
*/
|
|
39
|
+
export function buildOutcomeRecord(params) {
|
|
40
|
+
return {
|
|
41
|
+
timestamp: new Date().toISOString(),
|
|
42
|
+
prompt_hash: hashPrompt(params.prompt),
|
|
43
|
+
capabilities_used: [...params.capabilities],
|
|
44
|
+
agents_selected: [...params.agents],
|
|
45
|
+
outcome: params.outcome,
|
|
46
|
+
user_rating: params.userRating ?? null,
|
|
47
|
+
execution_time_ms: params.executionTimeMs,
|
|
48
|
+
agent_contributions: params.contributions ?? buildDefaultContributions(params.agents, params.outcome),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Loading
|
|
53
|
+
// ============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Load all outcome records from the telemetry file.
|
|
56
|
+
* Returns empty array if file doesn't exist.
|
|
57
|
+
*/
|
|
58
|
+
export function loadOutcomes(options) {
|
|
59
|
+
const basePath = options?.basePath ?? process.cwd();
|
|
60
|
+
const filePath = path.join(basePath, DEFAULT_TELEMETRY_DIR, OUTCOMES_FILE);
|
|
61
|
+
if (!fs.existsSync(filePath)) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
65
|
+
const lines = content.split('\n').filter(line => line.trim().length > 0);
|
|
66
|
+
const records = [];
|
|
67
|
+
for (const line of lines) {
|
|
68
|
+
try {
|
|
69
|
+
records.push(JSON.parse(line));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Skip malformed lines
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return records;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Load the most recent N outcome records.
|
|
79
|
+
*/
|
|
80
|
+
export function loadRecentOutcomes(count, options) {
|
|
81
|
+
const all = loadOutcomes(options);
|
|
82
|
+
return all.slice(-count);
|
|
83
|
+
}
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Maintenance
|
|
86
|
+
// ============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Rotate the outcomes file, keeping only the most recent records.
|
|
89
|
+
* This prevents unbounded file growth.
|
|
90
|
+
*/
|
|
91
|
+
export function rotateOutcomes(maxRecords, options) {
|
|
92
|
+
const limit = maxRecords ?? MAX_RECORDS;
|
|
93
|
+
const basePath = options?.basePath ?? process.cwd();
|
|
94
|
+
const filePath = path.join(basePath, DEFAULT_TELEMETRY_DIR, OUTCOMES_FILE);
|
|
95
|
+
if (!fs.existsSync(filePath)) {
|
|
96
|
+
return { kept: 0, removed: 0 };
|
|
97
|
+
}
|
|
98
|
+
const records = loadOutcomes(options);
|
|
99
|
+
if (records.length <= limit) {
|
|
100
|
+
return { kept: records.length, removed: 0 };
|
|
101
|
+
}
|
|
102
|
+
const kept = records.slice(-limit);
|
|
103
|
+
const removed = records.length - kept.length;
|
|
104
|
+
// Rewrite file with only recent records
|
|
105
|
+
const content = kept.map(r => JSON.stringify(r)).join('\n') + '\n';
|
|
106
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
107
|
+
return { kept: kept.length, removed };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the path to the outcomes file.
|
|
111
|
+
*/
|
|
112
|
+
export function getOutcomesFilePath(basePath) {
|
|
113
|
+
return path.join(basePath ?? process.cwd(), DEFAULT_TELEMETRY_DIR, OUTCOMES_FILE);
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Utilities
|
|
117
|
+
// ============================================================================
|
|
118
|
+
function hashPrompt(prompt) {
|
|
119
|
+
const hash = crypto.createHash('sha256').update(prompt).digest('hex').slice(0, 12);
|
|
120
|
+
return `sha256:${hash}`;
|
|
121
|
+
}
|
|
122
|
+
function buildDefaultContributions(agents, outcome) {
|
|
123
|
+
const contributions = {};
|
|
124
|
+
const succeeded = outcome === 'success' || outcome === 'partial';
|
|
125
|
+
for (const agent of agents) {
|
|
126
|
+
contributions[agent] = {
|
|
127
|
+
produced_output: succeeded,
|
|
128
|
+
output_used: outcome === 'success',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return contributions;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=outcome-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-recorder.js","sourceRoot":"","sources":["../../src/routing/outcome-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAwBtC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AACpD,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAqB,EACrB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,OAAO,EAAE,Q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ACnF,OAAO,UAAU,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,yBAAyB,CAChC,MAAyB,EACzB,OAAsB;IAEtB,MAAM,aAAa,GAAsC,EAAE,CAAC;IAC5D,MAAM,SAAS,GAAG,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,CAAC;IAEjE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,aAAa,CAAC,KAAK,CAAC,GAAG;YACrB,eAAe,EAAE,SAAS;YAC1B,WAAW,EAAE,OAAO,KAAK,SAAS;SACnC,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weight Adjuster (ADR-031 Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* Calculates adjusted agent weights from telemetry outcome records.
|
|
5
|
+
* Uses exponential moving average (EMA) for gradual weight adaptation.
|
|
6
|
+
*
|
|
7
|
+
* Weight adjustments are written to a separate overlay file
|
|
8
|
+
* (docs/ecosystem.graph.weights.json) that does not modify the
|
|
9
|
+
* curated base graph.
|
|
10
|
+
*/
|
|
11
|
+
import type { OutcomeRecord } from './outcome-recorder.js';
|
|
12
|
+
import type { WeightedAgent } from './weighted-resolver.js';
|
|
13
|
+
export interface WeightOverlay {
|
|
14
|
+
readonly generated_at: string;
|
|
15
|
+
readonly total_outcomes: number;
|
|
16
|
+
readonly adjustments: readonly WeightAdjustment[];
|
|
17
|
+
}
|
|
18
|
+
export interface WeightAdjustment {
|
|
19
|
+
readonly capability: string;
|
|
20
|
+
readonly agent: string;
|
|
21
|
+
readonly original_weight: number;
|
|
22
|
+
readonly adjusted_weight: number;
|
|
23
|
+
readonly success_rate: number;
|
|
24
|
+
readonly usage_rate: number;
|
|
25
|
+
readonly sample_count: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Calculate adjusted weights for agents in a capability based on outcomes.
|
|
29
|
+
*
|
|
30
|
+
* Uses exponential moving average:
|
|
31
|
+
* new_weight = old_weight * (1 - alpha) + observed_score * alpha
|
|
32
|
+
*
|
|
33
|
+
* Requires minimum sample count before adjusting.
|
|
34
|
+
*/
|
|
35
|
+
export declare function calculateAdjustedWeights(capability: string, agents: readonly WeightedAgent[], outcomes: readonly OutcomeRecord[]): WeightAdjustment[];
|
|
36
|
+
/**
|
|
37
|
+
* Write weight adjustments to the overlay file.
|
|
38
|
+
* Does NOT modify the base ecosystem.graph.json.
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeWeightOverlay(adjustments: readonly WeightAdjustment[], totalOutcomes: number, options?: {
|
|
41
|
+
basePath?: string;
|
|
42
|
+
}): string;
|
|
43
|
+
/**
|
|
44
|
+
* Load weight adjustments from the overlay file.
|
|
45
|
+
* Returns null if the file doesn't exist.
|
|
46
|
+
*/
|
|
47
|
+
export declare function loadWeightOverlay(options?: {
|
|
48
|
+
basePath?: string;
|
|
49
|
+
}): WeightOverlay | null;
|
|
50
|
+
/**
|
|
51
|
+
* Apply weight overlay adjustments to a set of agents.
|
|
52
|
+
* Returns agents with updated weights from the overlay.
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyWeightOverlay(capability: string, agents: readonly WeightedAgent[], overlay: WeightOverlay): WeightedAgent[];
|
|
55
|
+
/**
|
|
56
|
+
* Format weight adjustments as a human-readable report.
|
|
57
|
+
*/
|
|
58
|
+
export declare function formatAdjustmentReport(adjustments: readonly WeightAdjustment[]): string;
|
|
59
|
+
//# sourceMappingURL=weight-adjuster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weight-adjuster.d.ts","sourceRoot":"","sources":["../../src/routing/weight-adjuster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAM5D,MAAM,WA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
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weight Adjuster (ADR-031 Phase 2)
|
|
3
|
+
*
|
|
4
|
+
* Calculates adjusted agent weights from telemetry outcome records.
|
|
5
|
+
* Uses exponential moving average (EMA) for gradual weight adaptation.
|
|
6
|
+
*
|
|
7
|
+
* Weight adjustments are written to a separate overlay file
|
|
8
|
+
* (docs/ecosystem.graph.weights.json) that does not modify the
|
|
9
|
+
* curated base graph.
|
|
10
|
+
*/
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Constants
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const MIN_SAMPLES = 20;
|
|
17
|
+
const ALPHA = 0.1; // EMA smoothing factor (slow adaptation)
|
|
18
|
+
const MIN_WEIGHT = 0.05;
|
|
19
|
+
const MAX_WEIGHT = 1.0;
|
|
20
|
+
const WEIGHT_OVERLAY_FILE = 'ecosystem.graph.weights.json';
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Weight Calculation
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Calculate adjusted weights for agents in a capability based on outcomes.
|
|
26
|
+
*
|
|
27
|
+
* Uses exponential moving average:
|
|
28
|
+
* new_weight = old_weight * (1 - alpha) + observed_score * alpha
|
|
29
|
+
*
|
|
30
|
+
* Requires minimum sample count before adjusting.
|
|
31
|
+
*/
|
|
32
|
+
export function calculateAdjustedWeights(capability, agents, outcomes) {
|
|
33
|
+
// Filter outcomes that used this capability
|
|
34
|
+
const relevantOutcomes = outcomes.filter(o => o.capabilities_used.includes(capability));
|
|
35
|
+
if (relevantOutcomes.length < MIN_SAMPLES) {
|
|
36
|
+
return []; // Not enough data
|
|
37
|
+
}
|
|
38
|
+
const adjustments = [];
|
|
39
|
+
for (const agent of agents) {
|
|
40
|
+
// Count how many times this agent was selected
|
|
41
|
+
const selections = relevantOutcomes.filter(o => o.agents_selected.includes(agent.name));
|
|
42
|
+
if (selections.length === 0)
|
|
43
|
+
continue;
|
|
44
|
+
// Calculate success rate
|
|
45
|
+
const successes = selections.filter(o => o.outcome === 'success').length;
|
|
46
|
+
const successRate = successes / selections.length;
|
|
47
|
+
// Calculate usage rate (output was actually consumed)
|
|
48
|
+
const usages = selections.filter(o => {
|
|
49
|
+
const contrib = o.agent_contributions[agent.name];
|
|
50
|
+
return contrib?.output_used === true;
|
|
51
|
+
}).length;
|
|
52
|
+
const usageRate = usages / selections.length;
|
|
53
|
+
// Combined score (equal weight to success and usage)
|
|
54
|
+
const observedScore = successRate * 0.5 + usageRate * 0.5;
|
|
55
|
+
// EMA adjustment
|
|
56
|
+
const adjustedWeight = clampWeight(agent.weight * (1 - ALPHA) + observedScore * ALPHA);
|
|
57
|
+
adjustments.push({
|
|
58
|
+
capability,
|
|
59
|
+
agent: agent.name,
|
|
60
|
+
original_weight: agent.weight,
|
|
61
|
+
adjusted_weight: adjustedWeight,
|
|
62
|
+
success_rate: round(successRate, 4),
|
|
63
|
+
usage_rate: round(usageRate, 4),
|
|
64
|
+
sample_count: selections.length,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return adjustments;
|
|
68
|
+
}
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Overlay File Management
|
|
71
|
+
// ============================================================================
|
|
72
|
+
/**
|
|
73
|
+
* Write weight adjustments to the overlay file.
|
|
74
|
+
* Does NOT modify the base ecosystem.graph.json.
|
|
75
|
+
*/
|
|
76
|
+
export function writeWeightOverlay(adjustments, totalOutcomes, options) {
|
|
77
|
+
const basePath = options?.basePath ?? process.cwd();
|
|
78
|
+
const filePath = path.join(basePath, 'docs', WEIGHT_OVERLAY_FILE);
|
|
79
|
+
const overlay = {
|
|
80
|
+
generated_at: new Date().toISOString(),
|
|
81
|
+
total_outcomes: totalOutcomes,
|
|
82
|
+
adjustments: [...adjustments],
|
|
83
|
+
};
|
|
84
|
+
fs.writeFileSync(filePath, JSON.stringify(overlay, null, 2) + '\n', 'utf-8');
|
|
85
|
+
return filePath;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Load weight adjustments from the overlay file.
|
|
89
|
+
* Returns null if the file doesn't exist.
|
|
90
|
+
*/
|
|
91
|
+
export function loadWeightOverlay(options) {
|
|
92
|
+
const basePath = options?.basePath ?? process.cwd();
|
|
93
|
+
const filePath = path.join(basePath, 'docs', WEIGHT_OVERLAY_FILE);
|
|
94
|
+
if (!fs.existsSync(filePath)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
99
|
+
return JSON.parse(content);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Apply weight overlay adjustments to a set of agents.
|
|
107
|
+
* Returns agents with updated weights from the overlay.
|
|
108
|
+
*/
|
|
109
|
+
export function applyWeightOverlay(capability, agents, overlay) {
|
|
110
|
+
const adjustmentMap = new Map();
|
|
111
|
+
for (const adj of overlay.adjustments) {
|
|
112
|
+
if (adj.capability === capability) {
|
|
113
|
+
adjustmentMap.set(adj.agent, adj.adjusted_weight);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (adjustmentMap.size === 0) {
|
|
117
|
+
return [...agents];
|
|
118
|
+
}
|
|
119
|
+
return agents.map(agent => {
|
|
120
|
+
const adjustedWeight = adjustmentMap.get(agent.name);
|
|
121
|
+
if (adjustedWeight !== undefined) {
|
|
122
|
+
return { ...agent, weight: adjustedWeight };
|
|
123
|
+
}
|
|
124
|
+
return agent;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Format weight adjustments as a human-readable report.
|
|
129
|
+
*/
|
|
130
|
+
export function formatAdjustmentReport(adjustments) {
|
|
131
|
+
if (adjustments.length === 0) {
|
|
132
|
+
return 'No weight adjustments calculated (insufficient data or no changes).';
|
|
133
|
+
}
|
|
134
|
+
const lines = ['Weight Adjustment Report', '='.repeat(50)];
|
|
135
|
+
// Group by capability
|
|
136
|
+
const byCapability = new Map();
|
|
137
|
+
for (const adj of adjustments) {
|
|
138
|
+
const existing = byCapability.get(adj.capability);
|
|
139
|
+
if (existing) {
|
|
140
|
+
existing.push(adj);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
byCapability.set(adj.capability, [adj]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const [capability, adjs] of byCapability) {
|
|
147
|
+
lines.push(`\n ${capability}:`);
|
|
148
|
+
for (const adj of adjs) {
|
|
149
|
+
const delta = adj.adjusted_weight - adj.original_weight;
|
|
150
|
+
const direction = delta >= 0 ? '+' : '';
|
|
151
|
+
lines.push(` ${adj.agent}: ${adj.original_weight.toFixed(2)} → ${adj.adjusted_weight.toFixed(2)} (${direction}${delta.toFixed(3)})` +
|
|
152
|
+
` [success=${(adj.success_rate * 100).toFixed(0)}%, usage=${(adj.usage_rate * 100).toFixed(0)}%, n=${adj.sample_count}]`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return lines.join('\n');
|
|
156
|
+
}
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// Utilities
|
|
159
|
+
// ============================================================================
|
|
160
|
+
function clampWeight(w) {
|
|
161
|
+
return Math.max(MIN_WEIGHT, Math.min(MAX_WEIGHT, w));
|
|
162
|
+
}
|
|
163
|
+
function round(n, decimals) {
|
|
164
|
+
const factor = Math.pow(10, decimals);
|
|
165
|
+
return Math.round(n * factor) / factor;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=weight-adjuster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weight-adjuster.js","sourceRoot":"","sources":["../../src/routing/weight-adjuster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAA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AC,eAAe,CAAC;YACxD,MAAM,SAAS,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CACR,OAAO,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;gBAC3H,cAAc,CAAC,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,YAAY,GAAG,CAC1H,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,KAAK,CAAC,CAAS,EAAE,QAAgB;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weighted Agent Resolver (ADR-031 Phase 1)
|
|
3
|
+
*
|
|
4
|
+
* Weight-aware agent selection that replaces flat agent lists with
|
|
5
|
+
* prioritized selection based on weight scores and role classification.
|
|
6
|
+
*
|
|
7
|
+
* Backward compatible: plain string agents are treated as
|
|
8
|
+
* { name: string, weight: 1.0, role: "primary" }.
|
|
9
|
+
*/
|
|
10
|
+
export type AgentRole = 'primary' | 'secondary' | 'specialist';
|
|
11
|
+
export interface WeightedAgent {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly weight: number;
|
|
14
|
+
readonly role: AgentRole;
|
|
15
|
+
}
|
|
16
|
+
/** Input can be either a plain string or a weighted agent object. */
|
|
17
|
+
export type AgentInput = string | WeightedAgent;
|
|
18
|
+
/**
|
|
19
|
+
* Normalize an agent input (string or weighted object) into a WeightedAgent.
|
|
20
|
+
* Plain strings get weight 1.0 and role "primary".
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeAgent(input: AgentInput): WeightedAgent;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize an array of agent inputs into weighted agents.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeAgents(inputs: readonly AgentInput[]): WeightedAgent[];
|
|
27
|
+
/**
|
|
28
|
+
* Extract the agent name from any agent input form.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAgentName(input: AgentInput): string;
|
|
31
|
+
export interface WeightedSelectionOptions {
|
|
32
|
+
/** Maximum number of agents to select. */
|
|
33
|
+
readonly budget: number;
|
|
34
|
+
/** Tags from the user prompt for specialist matching. */
|
|
35
|
+
readonly promptTags?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Select agents from a capability using weight-aware prioritization.
|
|
39
|
+
*
|
|
40
|
+
* Algorithm:
|
|
41
|
+
* 1. Select all primary agents (sorted by weight descending)
|
|
42
|
+
* 2. Fill remaining budget with secondary agents (by weight)
|
|
43
|
+
* 3. Add specialists only when prompt tags match capability tags
|
|
44
|
+
* 4. Enforce budget ceiling
|
|
45
|
+
*/
|
|
46
|
+
export declare function selectWeightedAgents(agents: readonly AgentInput[], options: WeightedSelectionOptions): WeightedAgent[];
|
|
47
|
+
/**
|
|
48
|
+
* Validate agent input format. Returns error messages or empty array.
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateAgentInput(input: unknown, path: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Check if an agent input is in weighted object format.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isWeightedAgent(input: unknown): input is WeightedAgent;
|
|
55
|
+
//# sourceMappingURL=weighted-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weighted-resolver.d.ts","sourceRoot":"","sources":["../../src/routing/weighted-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,CAAC;AAMhD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAS/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,aAAa,EAAE,CAE9E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEtD;AAMD,MAAM,WAAW,wBAAwB;IACvC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,EAAE,wBAAwB,GAChC,aAAa,EAAE,CAuCjB;AAQD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkCzE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAItE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weighted Agent Resolver (ADR-031 Phase 1)
|
|
3
|
+
*
|
|
4
|
+
* Weight-aware agent selection that replaces flat agent lists with
|
|
5
|
+
* prioritized selection based on weight scores and role classification.
|
|
6
|
+
*
|
|
7
|
+
* Backward compatible: plain string agents are treated as
|
|
8
|
+
* { name: string, weight: 1.0, role: "primary" }.
|
|
9
|
+
*/
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Normalization
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Normalize an agent input (string or weighted object) into a WeightedAgent.
|
|
15
|
+
* Plain strings get weight 1.0 and role "primary".
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeAgent(input) {
|
|
18
|
+
if (typeof input === 'string') {
|
|
19
|
+
return { name: input, weight: 1.0, role: 'primary' };
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
name: input.name,
|
|
23
|
+
weight: clampWeight(input.weight),
|
|
24
|
+
role: input.role ?? 'primary',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Normalize an array of agent inputs into weighted agents.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeAgents(inputs) {
|
|
31
|
+
return inputs.map(normalizeAgent);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extract the agent name from any agent input form.
|
|
35
|
+
*/
|
|
36
|
+
export function getAgentName(input) {
|
|
37
|
+
return typeof input === 'string' ? input : input.name;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Select agents from a capability using weight-aware prioritization.
|
|
41
|
+
*
|
|
42
|
+
* Algorithm:
|
|
43
|
+
* 1. Select all primary agents (sorted by weight descending)
|
|
44
|
+
* 2. Fill remaining budget with secondary agents (by weight)
|
|
45
|
+
* 3. Add specialists only when prompt tags match capability tags
|
|
46
|
+
* 4. Enforce budget ceiling
|
|
47
|
+
*/
|
|
48
|
+
export function selectWeightedAgents(agents, options) {
|
|
49
|
+
const normalized = normalizeAgents(agents);
|
|
50
|
+
const { budget, promptTags } = options;
|
|
51
|
+
if (budget <= 0)
|
|
52
|
+
return [];
|
|
53
|
+
if (normalized.length === 0)
|
|
54
|
+
return [];
|
|
55
|
+
// Sort all agents by weight descending
|
|
56
|
+
const sorted = [...normalized].sort((a, b) => b.weight - a.weight);
|
|
57
|
+
// Step 1: Select primary agents
|
|
58
|
+
const primary = sorted.filter(a => a.role === 'primary');
|
|
59
|
+
const selected = primary.slice(0, budget);
|
|
60
|
+
// Step 2: Fill with secondary agents
|
|
61
|
+
if (selected.length < budget) {
|
|
62
|
+
const secondary = sorted.filter(a => a.role === 'secondary');
|
|
63
|
+
const remaining = budget - selected.length;
|
|
64
|
+
selected.push(...secondary.slice(0, remaining));
|
|
65
|
+
}
|
|
66
|
+
// Step 3: Add matching specialists (can exceed budget by specialist count)
|
|
67
|
+
if (promptTags && promptTags.length > 0) {
|
|
68
|
+
const tagSet = new Set(promptTags.map(t => t.toLowerCase()));
|
|
69
|
+
const specialists = sorted.filter(a => a.role === 'specialist' && !selected.some(s => s.name === a.name));
|
|
70
|
+
for (const spec of specialists) {
|
|
71
|
+
// Specialist name tokens are matched against prompt tags
|
|
72
|
+
const nameTokens = spec.name.toLowerCase().split(/[\s\-_]+/);
|
|
73
|
+
const hasMatch = nameTokens.some(t => tagSet.has(t));
|
|
74
|
+
if (hasMatch) {
|
|
75
|
+
selected.push(spec);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Step 4: Enforce hard budget (specialists can push over)
|
|
80
|
+
return selected.slice(0, Math.max(budget, selected.length));
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Validation
|
|
84
|
+
// ============================================================================
|
|
85
|
+
const VALID_ROLES = new Set(['primary', 'secondary', 'specialist']);
|
|
86
|
+
/**
|
|
87
|
+
* Validate agent input format. Returns error messages or empty array.
|
|
88
|
+
*/
|
|
89
|
+
export function validateAgentInput(input, path) {
|
|
90
|
+
const errors = [];
|
|
91
|
+
if (typeof input === 'string') {
|
|
92
|
+
if (input.length === 0) {
|
|
93
|
+
errors.push(`${path}: agent name must be non-empty`);
|
|
94
|
+
}
|
|
95
|
+
return errors;
|
|
96
|
+
}
|
|
97
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
|
|
98
|
+
errors.push(`${path}: agent must be a string or { name, weight, role } object`);
|
|
99
|
+
return errors;
|
|
100
|
+
}
|
|
101
|
+
const obj = input;
|
|
102
|
+
if (typeof obj['name'] !== 'string' || obj['name'].length === 0) {
|
|
103
|
+
errors.push(`${path}.name: must be a non-empty string`);
|
|
104
|
+
}
|
|
105
|
+
if (typeof obj['weight'] !== 'number') {
|
|
106
|
+
errors.push(`${path}.weight: must be a number`);
|
|
107
|
+
}
|
|
108
|
+
else if (obj['weight'] < 0 || obj['weight'] > 1) {
|
|
109
|
+
errors.push(`${path}.weight: must be between 0.0 and 1.0, got ${obj['weight']}`);
|
|
110
|
+
}
|
|
111
|
+
if ('role' in obj && obj['role'] !== undefined) {
|
|
112
|
+
if (typeof obj['role'] !== 'string' || !VALID_ROLES.has(obj['role'])) {
|
|
113
|
+
errors.push(`${path}.role: must be "primary", "secondary", or "specialist", got "${String(obj['role'])}"`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return errors;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if an agent input is in weighted object format.
|
|
120
|
+
*/
|
|
121
|
+
export function isWeightedAgent(input) {
|
|
122
|
+
if (typeof input !== 'object' || input === null)
|
|
123
|
+
return false;
|
|
124
|
+
const obj = input;
|
|
125
|
+
return typeof obj['name'] === 'string' && typeof obj['weight'] === 'number';
|
|
126
|
+
}
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Utilities
|
|
129
|
+
// ============================================================================
|
|
130
|
+
function clampWeight(w) {
|
|
131
|
+
return Math.max(0, Math.min(1, w));
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=weighted-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weighted-resolver.js","sourceRoot":"","sources":["../../src/routing/weighted-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiBH,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACvD,CAAC;IACD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,SAAS;KAC9B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAA6B;IAC3D,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AACxD,CAAC;AAaD;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA6B,EAC7B,OAAiC;IAEjC,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,U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C;IAC7C,OAAO,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC;AAC9E,CAAC;AAED,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-artifact-writer.d.ts","sourceRoot":"","sources":["../../src/synthesis/ask-artifact-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"ask-artifact-writer.d.ts","sourceRoot":"","sources":["../../src/synthesis/ask-artifact-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,uBAAuB,CAAC;AAa/B,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAg5BD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI,CAmBjF;AAoED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CA2E9D"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* All persistence is NON-FATAL — errors warn but never block result display.
|
|
14
14
|
*/
|
|
15
|
+
import { execSync } from 'node:child_process';
|
|
15
16
|
import * as fs from 'node:fs';
|
|
16
17
|
import * as path from 'node:path';
|
|
17
18
|
import * as os from 'node:os';
|
|
@@ -862,6 +863,13 @@ function persistProjectMode(input, execCtx) {
|
|
|
862
863
|
const msg = err instanceof Error ? err.message : String(err);
|
|
863
864
|
console.error(` [WARN] Failed to commit artifacts: ${msg}`);
|
|
864
865
|
}
|
|
866
|
+
// Push the branch to remote so the GitHub URL is valid
|
|
867
|
+
try {
|
|
868
|
+
execSync(`git push -u origin ${branch}`, { stdio: 'pipe', timeout: 30000 });
|
|
869
|
+
}
|
|
870
|
+
catch {
|
|
871
|
+
console.error(' [WARN] Could not push artifacts branch to remote');
|
|
872
|
+
}
|
|
865
873
|
// Return to original branch
|
|
866
874
|
checkoutBranch(originalBranch);
|
|
867
875
|
// Build GitHub URL
|