@soleri/core 2.12.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/flows/build.flow.yaml +128 -0
- package/data/flows/deliver.flow.yaml +110 -0
- package/data/flows/design.flow.yaml +108 -0
- package/data/flows/enhance.flow.yaml +90 -0
- package/data/flows/explore.flow.yaml +84 -0
- package/data/flows/fix.flow.yaml +90 -0
- package/data/flows/plan.flow.yaml +87 -0
- package/data/flows/review.flow.yaml +90 -0
- package/dist/agency/agency-manager.d.ts +27 -1
- package/dist/agency/agency-manager.d.ts.map +1 -1
- package/dist/agency/agency-manager.js +180 -9
- package/dist/agency/agency-manager.js.map +1 -1
- package/dist/agency/default-rules.d.ts +7 -0
- package/dist/agency/default-rules.d.ts.map +1 -0
- package/dist/agency/default-rules.js +79 -0
- package/dist/agency/default-rules.js.map +1 -0
- package/dist/agency/types.d.ts +48 -0
- package/dist/agency/types.d.ts.map +1 -1
- package/dist/brain/brain.d.ts +17 -2
- package/dist/brain/brain.d.ts.map +1 -1
- package/dist/brain/brain.js +118 -8
- package/dist/brain/brain.js.map +1 -1
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +16 -2
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/brain/knowledge-synthesizer.d.ts +37 -0
- package/dist/brain/knowledge-synthesizer.d.ts.map +1 -0
- package/dist/brain/knowledge-synthesizer.js +161 -0
- package/dist/brain/knowledge-synthesizer.js.map +1 -0
- package/dist/brain/learning-radar.d.ts +96 -0
- package/dist/brain/learning-radar.d.ts.map +1 -0
- package/dist/brain/learning-radar.js +202 -0
- package/dist/brain/learning-radar.js.map +1 -0
- package/dist/brain/types.d.ts +15 -0
- package/dist/brain/types.d.ts.map +1 -1
- package/dist/capabilities/chain-mapping.d.ts +21 -0
- package/dist/capabilities/chain-mapping.d.ts.map +1 -0
- package/dist/capabilities/chain-mapping.js +86 -0
- package/dist/capabilities/chain-mapping.js.map +1 -0
- package/dist/capabilities/index.d.ts +10 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +8 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/registry.d.ts +95 -0
- package/dist/capabilities/registry.d.ts.map +1 -0
- package/dist/capabilities/registry.js +227 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/capabilities/types.d.ts +106 -0
- package/dist/capabilities/types.d.ts.map +1 -0
- package/dist/capabilities/types.js +12 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/context/context-engine.d.ts.map +1 -1
- package/dist/context/context-engine.js +82 -17
- package/dist/context/context-engine.js.map +1 -1
- package/dist/context/types.d.ts +5 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/control/intent-router.d.ts +12 -1
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +126 -2
- package/dist/control/intent-router.js.map +1 -1
- package/dist/control/types.d.ts +17 -0
- package/dist/control/types.d.ts.map +1 -1
- package/dist/curator/classifier.d.ts +18 -0
- package/dist/curator/classifier.d.ts.map +1 -0
- package/dist/curator/classifier.js +61 -0
- package/dist/curator/classifier.js.map +1 -0
- package/dist/curator/quality-gate.d.ts +29 -0
- package/dist/curator/quality-gate.d.ts.map +1 -0
- package/dist/curator/quality-gate.js +88 -0
- package/dist/curator/quality-gate.js.map +1 -0
- package/dist/domain-packs/index.d.ts +8 -0
- package/dist/domain-packs/index.d.ts.map +1 -0
- package/dist/domain-packs/index.js +8 -0
- package/dist/domain-packs/index.js.map +1 -0
- package/dist/domain-packs/inject-rules.d.ts +24 -0
- package/dist/domain-packs/inject-rules.d.ts.map +1 -0
- package/dist/domain-packs/inject-rules.js +65 -0
- package/dist/domain-packs/inject-rules.js.map +1 -0
- package/dist/domain-packs/knowledge-installer.d.ts +27 -0
- package/dist/domain-packs/knowledge-installer.d.ts.map +1 -0
- package/dist/domain-packs/knowledge-installer.js +89 -0
- package/dist/domain-packs/knowledge-installer.js.map +1 -0
- package/dist/domain-packs/loader.d.ts +28 -0
- package/dist/domain-packs/loader.d.ts.map +1 -0
- package/dist/domain-packs/loader.js +105 -0
- package/dist/domain-packs/loader.js.map +1 -0
- package/dist/domain-packs/pack-runtime.d.ts +80 -0
- package/dist/domain-packs/pack-runtime.d.ts.map +1 -0
- package/dist/domain-packs/pack-runtime.js +36 -0
- package/dist/domain-packs/pack-runtime.js.map +1 -0
- package/dist/domain-packs/skills-installer.d.ts +21 -0
- package/dist/domain-packs/skills-installer.d.ts.map +1 -0
- package/dist/domain-packs/skills-installer.js +38 -0
- package/dist/domain-packs/skills-installer.js.map +1 -0
- package/dist/domain-packs/token-resolver.d.ts +37 -0
- package/dist/domain-packs/token-resolver.d.ts.map +1 -0
- package/dist/domain-packs/token-resolver.js +109 -0
- package/dist/domain-packs/token-resolver.js.map +1 -0
- package/dist/domain-packs/types.d.ts +91 -0
- package/dist/domain-packs/types.d.ts.map +1 -0
- package/dist/domain-packs/types.js +122 -0
- package/dist/domain-packs/types.js.map +1 -0
- package/dist/engine/bin/soleri-engine.d.ts +12 -0
- package/dist/engine/bin/soleri-engine.d.ts.map +1 -0
- package/dist/engine/bin/soleri-engine.js +184 -0
- package/dist/engine/bin/soleri-engine.js.map +1 -0
- package/dist/engine/core-ops.d.ts +27 -0
- package/dist/engine/core-ops.d.ts.map +1 -0
- package/dist/engine/core-ops.js +159 -0
- package/dist/engine/core-ops.js.map +1 -0
- package/dist/engine/index.d.ts +19 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +17 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/register-engine.d.ts +54 -0
- package/dist/engine/register-engine.d.ts.map +1 -0
- package/dist/engine/register-engine.js +270 -0
- package/dist/engine/register-engine.js.map +1 -0
- package/dist/engine/test-helpers.d.ts +30 -0
- package/dist/engine/test-helpers.d.ts.map +1 -0
- package/dist/engine/test-helpers.js +59 -0
- package/dist/engine/test-helpers.js.map +1 -0
- package/dist/events/event-bus.d.ts +30 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +51 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/flows/chain-runner.d.ts +46 -0
- package/dist/flows/chain-runner.d.ts.map +1 -0
- package/dist/flows/chain-runner.js +271 -0
- package/dist/flows/chain-runner.js.map +1 -0
- package/dist/flows/chain-types.d.ts +103 -0
- package/dist/flows/chain-types.d.ts.map +1 -0
- package/dist/flows/chain-types.js +23 -0
- package/dist/flows/chain-types.js.map +1 -0
- package/dist/flows/context-router.d.ts +39 -0
- package/dist/flows/context-router.d.ts.map +1 -0
- package/dist/flows/context-router.js +206 -0
- package/dist/flows/context-router.js.map +1 -0
- package/dist/flows/dispatch-registry.d.ts +24 -0
- package/dist/flows/dispatch-registry.d.ts.map +1 -0
- package/dist/flows/dispatch-registry.js +70 -0
- package/dist/flows/dispatch-registry.js.map +1 -0
- package/dist/flows/epilogue.d.ts +24 -0
- package/dist/flows/epilogue.d.ts.map +1 -0
- package/dist/flows/epilogue.js +52 -0
- package/dist/flows/epilogue.js.map +1 -0
- package/dist/flows/executor.d.ts +25 -0
- package/dist/flows/executor.d.ts.map +1 -0
- package/dist/flows/executor.js +153 -0
- package/dist/flows/executor.js.map +1 -0
- package/dist/flows/gate-evaluator.d.ts +26 -0
- package/dist/flows/gate-evaluator.d.ts.map +1 -0
- package/dist/flows/gate-evaluator.js +162 -0
- package/dist/flows/gate-evaluator.js.map +1 -0
- package/dist/flows/index.d.ts +14 -0
- package/dist/flows/index.d.ts.map +1 -0
- package/dist/flows/index.js +20 -0
- package/dist/flows/index.js.map +1 -0
- package/dist/flows/loader.d.ts +17 -0
- package/dist/flows/loader.d.ts.map +1 -0
- package/dist/flows/loader.js +61 -0
- package/dist/flows/loader.js.map +1 -0
- package/dist/flows/plan-builder.d.ts +40 -0
- package/dist/flows/plan-builder.d.ts.map +1 -0
- package/dist/flows/plan-builder.js +213 -0
- package/dist/flows/plan-builder.js.map +1 -0
- package/dist/flows/probes.d.ts +11 -0
- package/dist/flows/probes.d.ts.map +1 -0
- package/dist/flows/probes.js +62 -0
- package/dist/flows/probes.js.map +1 -0
- package/dist/flows/types.d.ts +950 -0
- package/dist/flows/types.d.ts.map +1 -0
- package/dist/flows/types.js +105 -0
- package/dist/flows/types.js.map +1 -0
- package/dist/health/doctor-checks.d.ts +15 -0
- package/dist/health/doctor-checks.d.ts.map +1 -0
- package/dist/health/doctor-checks.js +98 -0
- package/dist/health/doctor-checks.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/intake/text-ingester.d.ts +52 -0
- package/dist/intake/text-ingester.d.ts.map +1 -0
- package/dist/intake/text-ingester.js +181 -0
- package/dist/intake/text-ingester.js.map +1 -0
- package/dist/intelligence/loader.d.ts +19 -0
- package/dist/intelligence/loader.d.ts.map +1 -1
- package/dist/intelligence/loader.js +35 -0
- package/dist/intelligence/loader.js.map +1 -1
- package/dist/intelligence/types.d.ts +1 -0
- package/dist/intelligence/types.d.ts.map +1 -1
- package/dist/llm/llm-client.d.ts.map +1 -1
- package/dist/llm/llm-client.js +37 -1
- package/dist/llm/llm-client.js.map +1 -1
- package/dist/llm/oauth-discovery.d.ts +26 -0
- package/dist/llm/oauth-discovery.d.ts.map +1 -0
- package/dist/llm/oauth-discovery.js +149 -0
- package/dist/llm/oauth-discovery.js.map +1 -0
- package/dist/packs/types.d.ts +58 -19
- package/dist/packs/types.d.ts.map +1 -1
- package/dist/packs/types.js +14 -0
- package/dist/packs/types.js.map +1 -1
- package/dist/planning/evidence-collector.d.ts +41 -0
- package/dist/planning/evidence-collector.d.ts.map +1 -0
- package/dist/planning/evidence-collector.js +194 -0
- package/dist/planning/evidence-collector.js.map +1 -0
- package/dist/planning/planner.d.ts +4 -0
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +11 -0
- package/dist/planning/planner.js.map +1 -1
- package/dist/playbooks/generic/onboarding.d.ts +9 -0
- package/dist/playbooks/generic/onboarding.d.ts.map +1 -0
- package/dist/playbooks/generic/onboarding.js +74 -0
- package/dist/playbooks/generic/onboarding.js.map +1 -0
- package/dist/playbooks/playbook-registry.d.ts.map +1 -1
- package/dist/playbooks/playbook-registry.js +2 -0
- package/dist/playbooks/playbook-registry.js.map +1 -1
- package/dist/queue/job-queue.d.ts +92 -0
- package/dist/queue/job-queue.d.ts.map +1 -0
- package/dist/queue/job-queue.js +180 -0
- package/dist/queue/job-queue.js.map +1 -0
- package/dist/queue/pipeline-runner.d.ts +62 -0
- package/dist/queue/pipeline-runner.d.ts.map +1 -0
- package/dist/queue/pipeline-runner.js +126 -0
- package/dist/queue/pipeline-runner.js.map +1 -0
- package/dist/runtime/admin-extra-ops.d.ts.map +1 -1
- package/dist/runtime/admin-extra-ops.js +15 -9
- package/dist/runtime/admin-extra-ops.js.map +1 -1
- package/dist/runtime/admin-ops.js +4 -4
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/admin-setup-ops.d.ts +20 -0
- package/dist/runtime/admin-setup-ops.d.ts.map +1 -0
- package/dist/runtime/admin-setup-ops.js +583 -0
- package/dist/runtime/admin-setup-ops.js.map +1 -0
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +33 -1
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/chain-ops.d.ts +9 -0
- package/dist/runtime/chain-ops.d.ts.map +1 -0
- package/dist/runtime/chain-ops.js +107 -0
- package/dist/runtime/chain-ops.js.map +1 -0
- package/dist/runtime/claude-md-helpers.d.ts +65 -0
- package/dist/runtime/claude-md-helpers.d.ts.map +1 -0
- package/dist/runtime/claude-md-helpers.js +173 -0
- package/dist/runtime/claude-md-helpers.js.map +1 -0
- package/dist/runtime/curator-extra-ops.d.ts +3 -2
- package/dist/runtime/curator-extra-ops.d.ts.map +1 -1
- package/dist/runtime/curator-extra-ops.js +81 -3
- package/dist/runtime/curator-extra-ops.js.map +1 -1
- package/dist/runtime/domain-ops.d.ts +21 -5
- package/dist/runtime/domain-ops.d.ts.map +1 -1
- package/dist/runtime/domain-ops.js +64 -6
- package/dist/runtime/domain-ops.js.map +1 -1
- package/dist/runtime/facades/admin-facade.d.ts.map +1 -1
- package/dist/runtime/facades/admin-facade.js +4 -0
- package/dist/runtime/facades/admin-facade.js.map +1 -1
- package/dist/runtime/facades/agency-facade.d.ts.map +1 -1
- package/dist/runtime/facades/agency-facade.js +64 -0
- package/dist/runtime/facades/agency-facade.js.map +1 -1
- package/dist/runtime/facades/brain-facade.d.ts.map +1 -1
- package/dist/runtime/facades/brain-facade.js +122 -1
- package/dist/runtime/facades/brain-facade.js.map +1 -1
- package/dist/runtime/facades/cognee-facade.d.ts.map +1 -1
- package/dist/runtime/facades/cognee-facade.js +3 -1
- package/dist/runtime/facades/cognee-facade.js.map +1 -1
- package/dist/runtime/facades/control-facade.d.ts.map +1 -1
- package/dist/runtime/facades/control-facade.js +42 -0
- package/dist/runtime/facades/control-facade.js.map +1 -1
- package/dist/runtime/facades/index.d.ts.map +1 -1
- package/dist/runtime/facades/index.js +10 -6
- package/dist/runtime/facades/index.js.map +1 -1
- package/dist/runtime/facades/memory-facade.d.ts.map +1 -1
- package/dist/runtime/facades/memory-facade.js +20 -2
- package/dist/runtime/facades/memory-facade.js.map +1 -1
- package/dist/runtime/facades/plan-facade.d.ts.map +1 -1
- package/dist/runtime/facades/plan-facade.js +2 -0
- package/dist/runtime/facades/plan-facade.js.map +1 -1
- package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
- package/dist/runtime/facades/vault-facade.js +27 -5
- package/dist/runtime/facades/vault-facade.js.map +1 -1
- package/dist/runtime/intake-ops.d.ts +7 -5
- package/dist/runtime/intake-ops.d.ts.map +1 -1
- package/dist/runtime/intake-ops.js +98 -5
- package/dist/runtime/intake-ops.js.map +1 -1
- package/dist/runtime/memory-extra-ops.d.ts +6 -3
- package/dist/runtime/memory-extra-ops.d.ts.map +1 -1
- package/dist/runtime/memory-extra-ops.js +292 -4
- package/dist/runtime/memory-extra-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts +8 -7
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +217 -61
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
- package/dist/runtime/planning-extra-ops.js +85 -0
- package/dist/runtime/planning-extra-ops.js.map +1 -1
- package/dist/runtime/playbook-ops.js +1 -1
- package/dist/runtime/playbook-ops.js.map +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +165 -18
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/session-briefing.d.ts +23 -0
- package/dist/runtime/session-briefing.d.ts.map +1 -0
- package/dist/runtime/session-briefing.js +140 -0
- package/dist/runtime/session-briefing.js.map +1 -0
- package/dist/runtime/types.d.ts +29 -2
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-linking-ops.d.ts +13 -0
- package/dist/runtime/vault-linking-ops.d.ts.map +1 -0
- package/dist/runtime/vault-linking-ops.js +365 -0
- package/dist/runtime/vault-linking-ops.js.map +1 -0
- package/dist/vault/linking.d.ts +46 -0
- package/dist/vault/linking.d.ts.map +1 -0
- package/dist/vault/linking.js +275 -0
- package/dist/vault/linking.js.map +1 -0
- package/dist/vault/vault-types.d.ts +37 -0
- package/dist/vault/vault-types.d.ts.map +1 -1
- package/dist/vault/vault.d.ts +37 -0
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +152 -9
- package/dist/vault/vault.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/admin-extra-ops.test.ts +1 -1
- package/src/__tests__/admin-ops.test.ts +2 -1
- package/src/__tests__/admin-setup-ops.test.ts +355 -0
- package/src/__tests__/async-infrastructure.test.ts +307 -0
- package/src/__tests__/cognee-client-gaps.test.ts +474 -0
- package/src/__tests__/cognee-hybrid-search.test.ts +492 -0
- package/src/__tests__/cognee-sync-manager-deep.test.ts +654 -0
- package/src/__tests__/cognee-sync-manager.test.ts +1 -0
- package/src/__tests__/core-ops.test.ts +9 -61
- package/src/__tests__/curator-extra-ops.test.ts +6 -2
- package/src/__tests__/curator-pipeline-e2e.test.ts +358 -0
- package/src/__tests__/domain-packs.test.ts +421 -0
- package/src/__tests__/flows.test.ts +604 -0
- package/src/__tests__/memory-extra-ops.test.ts +2 -2
- package/src/__tests__/planning-extra-ops.test.ts +2 -2
- package/src/__tests__/playbook-registry.test.ts +2 -2
- package/src/__tests__/playbook-seeder.test.ts +8 -8
- package/src/__tests__/playbook.test.ts +5 -5
- package/src/__tests__/second-brain-features.test.ts +583 -0
- package/src/__tests__/token-resolver.test.ts +79 -0
- package/src/agency/agency-manager.ts +217 -9
- package/src/agency/default-rules.ts +83 -0
- package/src/agency/types.ts +61 -0
- package/src/brain/brain.ts +110 -8
- package/src/brain/intelligence.ts +21 -2
- package/src/brain/knowledge-synthesizer.ts +218 -0
- package/src/brain/learning-radar.ts +340 -0
- package/src/brain/types.ts +16 -0
- package/src/capabilities/chain-mapping.ts +93 -0
- package/src/capabilities/index.ts +21 -0
- package/src/capabilities/registry.ts +290 -0
- package/src/capabilities/types.ts +143 -0
- package/src/context/context-engine.ts +114 -15
- package/src/context/types.ts +5 -0
- package/src/control/intent-router.ts +153 -2
- package/src/control/types.ts +10 -0
- package/src/curator/classifier.ts +88 -0
- package/src/curator/quality-gate.ts +129 -0
- package/src/domain-packs/index.ts +27 -0
- package/src/domain-packs/inject-rules.ts +74 -0
- package/src/domain-packs/knowledge-installer.ts +116 -0
- package/src/domain-packs/loader.ts +124 -0
- package/src/domain-packs/pack-runtime.ts +99 -0
- package/src/domain-packs/skills-installer.ts +56 -0
- package/src/domain-packs/token-resolver.ts +126 -0
- package/src/domain-packs/types.ts +229 -0
- package/src/engine/__tests__/register-engine.test.ts +104 -0
- package/src/engine/bin/soleri-engine.ts +218 -0
- package/src/engine/core-ops.ts +178 -0
- package/src/engine/index.ts +19 -0
- package/src/engine/register-engine.ts +385 -0
- package/src/engine/test-helpers.ts +83 -0
- package/src/events/event-bus.ts +58 -0
- package/src/flows/chain-runner.ts +369 -0
- package/src/flows/chain-types.ts +57 -0
- package/src/flows/context-router.ts +257 -0
- package/src/flows/dispatch-registry.ts +80 -0
- package/src/flows/epilogue.ts +65 -0
- package/src/flows/executor.ts +182 -0
- package/src/flows/gate-evaluator.ts +171 -0
- package/src/flows/index.ts +52 -0
- package/src/flows/loader.ts +63 -0
- package/src/flows/plan-builder.ts +250 -0
- package/src/flows/probes.ts +70 -0
- package/src/flows/types.ts +217 -0
- package/src/health/doctor-checks.ts +115 -0
- package/src/index.ts +68 -1
- package/src/intake/text-ingester.ts +234 -0
- package/src/intelligence/loader.ts +38 -0
- package/src/intelligence/types.ts +1 -0
- package/src/llm/llm-client.ts +38 -1
- package/src/llm/oauth-discovery.ts +169 -0
- package/src/packs/types.ts +19 -0
- package/src/planning/evidence-collector.ts +247 -0
- package/src/planning/planner.ts +11 -0
- package/src/playbooks/generic/onboarding.ts +79 -0
- package/src/playbooks/playbook-registry.ts +2 -0
- package/src/queue/job-queue.ts +281 -0
- package/src/queue/pipeline-runner.ts +149 -0
- package/src/runtime/admin-extra-ops.ts +14 -8
- package/src/runtime/admin-ops.ts +4 -4
- package/src/runtime/admin-setup-ops.ts +664 -0
- package/src/runtime/capture-ops.ts +40 -1
- package/src/runtime/chain-ops.ts +121 -0
- package/src/runtime/claude-md-helpers.ts +236 -0
- package/src/runtime/curator-extra-ops.ts +86 -3
- package/src/runtime/domain-ops.ts +71 -5
- package/src/runtime/facades/admin-facade.ts +4 -0
- package/src/runtime/facades/agency-facade.ts +68 -0
- package/src/runtime/facades/brain-facade.ts +142 -1
- package/src/runtime/facades/cognee-facade.ts +3 -1
- package/src/runtime/facades/control-facade.ts +45 -0
- package/src/runtime/facades/index.ts +12 -6
- package/src/runtime/facades/memory-facade.ts +20 -2
- package/src/runtime/facades/plan-facade.ts +2 -0
- package/src/runtime/facades/vault-facade.ts +30 -5
- package/src/runtime/intake-ops.ts +107 -5
- package/src/runtime/memory-extra-ops.ts +312 -4
- package/src/runtime/orchestrate-ops.ts +261 -65
- package/src/runtime/planning-extra-ops.ts +94 -0
- package/src/runtime/playbook-ops.ts +1 -1
- package/src/runtime/runtime.ts +164 -19
- package/src/runtime/session-briefing.ts +161 -0
- package/src/runtime/types.ts +29 -2
- package/src/runtime/vault-linking-ops.ts +452 -0
- package/src/vault/linking.ts +333 -0
- package/src/vault/vault-types.ts +46 -0
- package/src/vault/vault.ts +173 -11
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability Registry — runtime resolution engine for the three-layer architecture.
|
|
3
|
+
*
|
|
4
|
+
* Maps capability IDs (domain.action) to pack handlers. Resolves dependencies,
|
|
5
|
+
* checks availability, and supports graceful degradation when capabilities are
|
|
6
|
+
* missing.
|
|
7
|
+
*
|
|
8
|
+
* Registration flow:
|
|
9
|
+
* 1. Pack manifest declares capabilities (static, serializable)
|
|
10
|
+
* 2. Pack's onActivate() provides handlers (runtime, async)
|
|
11
|
+
* 3. registerPack() reconciles declarations with handlers
|
|
12
|
+
*
|
|
13
|
+
* @see docs/architecture/capability-packs.md
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type {
|
|
17
|
+
CapabilityDefinition,
|
|
18
|
+
CapabilityHandler,
|
|
19
|
+
RegisteredCapability,
|
|
20
|
+
ResolvedCapability,
|
|
21
|
+
PackSuggestion,
|
|
22
|
+
FlowValidation,
|
|
23
|
+
} from './types.js';
|
|
24
|
+
import { chainToCapability } from './chain-mapping.js';
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Flow shape accepted by validateFlow — intentionally minimal so callers
|
|
28
|
+
// don't need to import the full Flow type from ../flows/types.js.
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
export interface FlowForValidation {
|
|
32
|
+
steps: Array<{
|
|
33
|
+
needs?: string[];
|
|
34
|
+
chains?: string[];
|
|
35
|
+
}>;
|
|
36
|
+
onMissingCapability?: {
|
|
37
|
+
default?: string;
|
|
38
|
+
blocking?: string[];
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Registry
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
export class CapabilityRegistry {
|
|
47
|
+
private capabilities = new Map<string, RegisteredCapability>();
|
|
48
|
+
private packs = new Map<string, { id: string; capabilities: CapabilityDefinition[] }>();
|
|
49
|
+
|
|
50
|
+
// -----------------------------------------------------------------------
|
|
51
|
+
// Registration
|
|
52
|
+
// -----------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Register all capabilities from an installed pack.
|
|
56
|
+
*
|
|
57
|
+
* For each definition in `definitions`, the corresponding handler is looked
|
|
58
|
+
* up in `handlers`. If no handler is found the capability is skipped with a
|
|
59
|
+
* warning. When multiple packs provide the same capability, providers are
|
|
60
|
+
* sorted by priority (descending) — highest priority wins on resolve().
|
|
61
|
+
*
|
|
62
|
+
* @param packId - Unique identifier for the pack
|
|
63
|
+
* @param definitions - Capability definitions from the pack manifest
|
|
64
|
+
* @param handlers - Map of capabilityId → handler from onActivate()
|
|
65
|
+
* @param priority - Higher = preferred (core=100, user=75, domain=50, fallback=0)
|
|
66
|
+
*/
|
|
67
|
+
registerPack(
|
|
68
|
+
packId: string,
|
|
69
|
+
definitions: CapabilityDefinition[],
|
|
70
|
+
handlers: Map<string, CapabilityHandler>,
|
|
71
|
+
priority: number = 0,
|
|
72
|
+
): void {
|
|
73
|
+
for (const definition of definitions) {
|
|
74
|
+
const handler = handlers.get(definition.id);
|
|
75
|
+
if (!handler) {
|
|
76
|
+
console.warn(
|
|
77
|
+
`Pack "${packId}" declares capability "${definition.id}" but no handler provided — skipping`,
|
|
78
|
+
);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const existing = this.capabilities.get(definition.id);
|
|
83
|
+
if (existing) {
|
|
84
|
+
// Add as additional provider, keep sorted by priority descending
|
|
85
|
+
existing.providers.push({ packId, handler, priority });
|
|
86
|
+
existing.providers.sort((a, b) => b.priority - a.priority);
|
|
87
|
+
} else {
|
|
88
|
+
this.capabilities.set(definition.id, {
|
|
89
|
+
definition,
|
|
90
|
+
providers: [{ packId, handler, priority }],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Store pack metadata for suggestPacksFor() lookups
|
|
96
|
+
this.packs.set(packId, { id: packId, capabilities: definitions });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// -----------------------------------------------------------------------
|
|
100
|
+
// Query
|
|
101
|
+
// -----------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check if a capability is registered (has at least one provider).
|
|
105
|
+
*/
|
|
106
|
+
has(capabilityId: string): boolean {
|
|
107
|
+
return this.capabilities.has(capabilityId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Resolve a capability — returns the highest-priority handler, knowledge
|
|
112
|
+
* refs, and provider list. If the capability is missing or has unsatisfied
|
|
113
|
+
* dependencies, returns `available: false` with suggestions.
|
|
114
|
+
*/
|
|
115
|
+
resolve(capabilityId: string): ResolvedCapability {
|
|
116
|
+
const registered = this.capabilities.get(capabilityId);
|
|
117
|
+
|
|
118
|
+
if (!registered) {
|
|
119
|
+
return {
|
|
120
|
+
available: false,
|
|
121
|
+
capabilityId,
|
|
122
|
+
suggestion: this.suggestPacksFor([capabilityId]),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check dependency satisfaction
|
|
127
|
+
const depends = registered.definition.depends ?? [];
|
|
128
|
+
const missingDeps = depends.filter((dep) => !this.capabilities.has(dep));
|
|
129
|
+
|
|
130
|
+
if (missingDeps.length > 0) {
|
|
131
|
+
return {
|
|
132
|
+
available: false,
|
|
133
|
+
capabilityId,
|
|
134
|
+
missingDependencies: missingDeps,
|
|
135
|
+
suggestion: this.suggestPacksFor(missingDeps),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Resolved — return the highest-priority provider (index 0 after sort)
|
|
140
|
+
const primary = registered.providers[0];
|
|
141
|
+
return {
|
|
142
|
+
available: true,
|
|
143
|
+
capabilityId,
|
|
144
|
+
handler: primary.handler,
|
|
145
|
+
providers: registered.providers.map((p) => p.packId),
|
|
146
|
+
knowledge: registered.definition.knowledge ?? [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* List all registered capabilities grouped by domain.
|
|
152
|
+
*
|
|
153
|
+
* Domain is derived from the first segment of the capability ID
|
|
154
|
+
* (e.g., "color" from "color.validate").
|
|
155
|
+
*/
|
|
156
|
+
list(): Map<string, CapabilityDefinition[]> {
|
|
157
|
+
const grouped = new Map<string, CapabilityDefinition[]>();
|
|
158
|
+
|
|
159
|
+
for (const [id, registered] of this.capabilities) {
|
|
160
|
+
const domain = id.split('.')[0];
|
|
161
|
+
const group = grouped.get(domain) ?? [];
|
|
162
|
+
group.push(registered.definition);
|
|
163
|
+
grouped.set(domain, group);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return grouped;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Search registered packs for capabilities matching the requested IDs.
|
|
171
|
+
*
|
|
172
|
+
* This searches ALL packs (not just capabilities currently registered with
|
|
173
|
+
* handlers) — useful for suggesting which packs to install when a capability
|
|
174
|
+
* is missing.
|
|
175
|
+
*/
|
|
176
|
+
suggestPacksFor(capabilityIds: string[]): PackSuggestion[] {
|
|
177
|
+
if (capabilityIds.length === 0) return [];
|
|
178
|
+
|
|
179
|
+
const idSet = new Set(capabilityIds);
|
|
180
|
+
const suggestions: PackSuggestion[] = [];
|
|
181
|
+
|
|
182
|
+
for (const [, pack] of this.packs) {
|
|
183
|
+
const provides = pack.capabilities.filter((cap) => idSet.has(cap.id)).map((cap) => cap.id);
|
|
184
|
+
|
|
185
|
+
if (provides.length > 0) {
|
|
186
|
+
suggestions.push({ packId: pack.id, provides });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return suggestions;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// -----------------------------------------------------------------------
|
|
194
|
+
// Validation
|
|
195
|
+
// -----------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Validate a flow's capability requirements against installed packs.
|
|
199
|
+
*
|
|
200
|
+
* Reads both `needs` (v2 preferred) and `chains` (v1 deprecated) fields.
|
|
201
|
+
* For v1 chains, attempts best-effort mapping via chainToCapability().
|
|
202
|
+
*
|
|
203
|
+
* Missing capabilities are classified as either "blocking" or "degraded"
|
|
204
|
+
* based on the flow's onMissingCapability config.
|
|
205
|
+
*/
|
|
206
|
+
validateFlow(flow: FlowForValidation): FlowValidation {
|
|
207
|
+
// Collect all capability IDs needed across all steps
|
|
208
|
+
const needed = new Set<string>();
|
|
209
|
+
|
|
210
|
+
for (const step of flow.steps) {
|
|
211
|
+
// v2: needs field (preferred)
|
|
212
|
+
if (step.needs) {
|
|
213
|
+
for (const cap of step.needs) {
|
|
214
|
+
needed.add(cap);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// v1: chains field (deprecated, best-effort mapping)
|
|
219
|
+
if (step.chains) {
|
|
220
|
+
for (const chain of step.chains) {
|
|
221
|
+
const capId = chainToCapability(chain);
|
|
222
|
+
if (capId) needed.add(capId);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Partition into available vs missing
|
|
228
|
+
const available: string[] = [];
|
|
229
|
+
const missing: string[] = [];
|
|
230
|
+
|
|
231
|
+
for (const capId of needed) {
|
|
232
|
+
if (this.has(capId)) {
|
|
233
|
+
available.push(capId);
|
|
234
|
+
} else {
|
|
235
|
+
missing.push(capId);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Classify missing capabilities by impact
|
|
240
|
+
const blockingSet = new Set(flow.onMissingCapability?.blocking ?? []);
|
|
241
|
+
|
|
242
|
+
const degraded = missing.map((capability) => ({
|
|
243
|
+
capability,
|
|
244
|
+
impact: blockingSet.has(capability) ? ('blocking' as const) : ('degraded' as const),
|
|
245
|
+
suggestion: this.suggestPacksFor([capability]),
|
|
246
|
+
}));
|
|
247
|
+
|
|
248
|
+
const hasBlocker = degraded.some((d) => d.impact === 'blocking');
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
valid: missing.length === 0,
|
|
252
|
+
available,
|
|
253
|
+
missing,
|
|
254
|
+
degraded,
|
|
255
|
+
canRunPartially: !hasBlocker,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// -----------------------------------------------------------------------
|
|
260
|
+
// Inspection (useful for debugging / CLI commands)
|
|
261
|
+
// -----------------------------------------------------------------------
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Total number of registered capabilities.
|
|
265
|
+
*/
|
|
266
|
+
get size(): number {
|
|
267
|
+
return this.capabilities.size;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Total number of registered packs.
|
|
272
|
+
*/
|
|
273
|
+
get packCount(): number {
|
|
274
|
+
return this.packs.size;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Get all registered capability IDs.
|
|
279
|
+
*/
|
|
280
|
+
ids(): string[] {
|
|
281
|
+
return [...this.capabilities.keys()];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get the RegisteredCapability for a given ID, or undefined.
|
|
286
|
+
*/
|
|
287
|
+
get(capabilityId: string): RegisteredCapability | undefined {
|
|
288
|
+
return this.capabilities.get(capabilityId);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability type system for Soleri's three-layer architecture.
|
|
3
|
+
*
|
|
4
|
+
* Capabilities are the atomic unit of agent functionality — what the agent
|
|
5
|
+
* CAN DO, not which tool it calls. Flows reference capabilities by intent
|
|
6
|
+
* (e.g., "color.validate"), and the registry resolves them to pack handlers
|
|
7
|
+
* at runtime.
|
|
8
|
+
*
|
|
9
|
+
* @see docs/architecture/capability-packs.md
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { PackRuntime } from '../domain-packs/pack-runtime.js';
|
|
13
|
+
import type { IntelligenceEntry } from '../intelligence/types.js';
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Capability definition & handler
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export interface CapabilityDefinition {
|
|
20
|
+
/** Namespaced ID: domain.action (e.g., "color.validate", "token.check") */
|
|
21
|
+
id: string;
|
|
22
|
+
|
|
23
|
+
/** Human-readable description of what this capability does */
|
|
24
|
+
description: string;
|
|
25
|
+
|
|
26
|
+
/** What this capability produces (output contract) */
|
|
27
|
+
provides: string[];
|
|
28
|
+
|
|
29
|
+
/** What this capability requires as input */
|
|
30
|
+
requires: string[];
|
|
31
|
+
|
|
32
|
+
/** Other capabilities that must be available (auto-resolved) */
|
|
33
|
+
depends?: string[];
|
|
34
|
+
|
|
35
|
+
/** Vault knowledge entry IDs to auto-load when this capability runs */
|
|
36
|
+
knowledge?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Capability handler — the actual implementation.
|
|
41
|
+
*
|
|
42
|
+
* Declared separately from CapabilityDefinition because:
|
|
43
|
+
* - Manifest declares the definition (static, serializable)
|
|
44
|
+
* - Pack's onActivate() registers the handler (runtime, async)
|
|
45
|
+
*/
|
|
46
|
+
export type CapabilityHandler = (
|
|
47
|
+
params: Record<string, unknown>,
|
|
48
|
+
context: CapabilityContext,
|
|
49
|
+
) => Promise<CapabilityResult>;
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Capability context & result
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* CapabilityContext — extends PackRuntime with knowledge and composition.
|
|
57
|
+
*
|
|
58
|
+
* PackRuntime already provides: vault, getProject, listProjects, createCheck,
|
|
59
|
+
* validateCheck, validateAndConsume. This adds:
|
|
60
|
+
* - knowledge: auto-loaded from pack bundle + user vault
|
|
61
|
+
* - brain: recommendations from the learning loop
|
|
62
|
+
* - invoke: call another capability (composition)
|
|
63
|
+
*/
|
|
64
|
+
export interface CapabilityContext {
|
|
65
|
+
/** Pack runtime (vault, projects, checks) — from existing PackRuntime */
|
|
66
|
+
runtime: PackRuntime;
|
|
67
|
+
|
|
68
|
+
/** Auto-loaded knowledge from pack + user vault */
|
|
69
|
+
knowledge: KnowledgeContext;
|
|
70
|
+
|
|
71
|
+
/** Brain recommendations for this capability */
|
|
72
|
+
brain: BrainRecommendation[];
|
|
73
|
+
|
|
74
|
+
/** Request another capability (for composition) */
|
|
75
|
+
invoke: (capabilityId: string, params: Record<string, unknown>) => Promise<CapabilityResult>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface CapabilityResult {
|
|
79
|
+
success: boolean;
|
|
80
|
+
data: Record<string, unknown>;
|
|
81
|
+
/** Which "provides" fields were actually produced */
|
|
82
|
+
produced: string[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Knowledge & brain
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
export interface KnowledgeContext {
|
|
90
|
+
/** Entries from the pack's bundled knowledge (IntelligenceBundle) */
|
|
91
|
+
pack: IntelligenceEntry[];
|
|
92
|
+
/** Entries from user's project vault (searched by capability's knowledge[] IDs) */
|
|
93
|
+
vault: IntelligenceEntry[];
|
|
94
|
+
/** Combined, deduplicated, ranked by relevance */
|
|
95
|
+
merged: IntelligenceEntry[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface BrainRecommendation {
|
|
99
|
+
pattern: string;
|
|
100
|
+
strength: number;
|
|
101
|
+
source: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Registry types
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
export interface RegisteredCapability {
|
|
109
|
+
definition: CapabilityDefinition;
|
|
110
|
+
providers: Array<{
|
|
111
|
+
packId: string;
|
|
112
|
+
handler: CapabilityHandler;
|
|
113
|
+
/** Higher = preferred (see Multi-Provider Resolution in RFC) */
|
|
114
|
+
priority: number;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ResolvedCapability {
|
|
119
|
+
available: boolean;
|
|
120
|
+
capabilityId: string;
|
|
121
|
+
handler?: CapabilityHandler;
|
|
122
|
+
providers?: string[];
|
|
123
|
+
knowledge?: string[];
|
|
124
|
+
missingDependencies?: string[];
|
|
125
|
+
suggestion?: PackSuggestion[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface PackSuggestion {
|
|
129
|
+
packId: string;
|
|
130
|
+
provides: string[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface FlowValidation {
|
|
134
|
+
valid: boolean;
|
|
135
|
+
available: string[];
|
|
136
|
+
missing: string[];
|
|
137
|
+
degraded: Array<{
|
|
138
|
+
capability: string;
|
|
139
|
+
impact: 'blocking' | 'degraded' | 'optional';
|
|
140
|
+
suggestion: PackSuggestion[];
|
|
141
|
+
}>;
|
|
142
|
+
canRunPartially: boolean;
|
|
143
|
+
}
|
|
@@ -71,11 +71,34 @@ const STOP_PATTERNS = new Set([
|
|
|
71
71
|
'out-of-the-box',
|
|
72
72
|
]);
|
|
73
73
|
|
|
74
|
-
// ───
|
|
74
|
+
// ─── Scoring Constants (tunable) ────────────────────────────────────
|
|
75
75
|
|
|
76
|
+
/** Confidence thresholds for discrete levels. */
|
|
76
77
|
const HIGH_CONFIDENCE = 0.75;
|
|
77
78
|
const MEDIUM_CONFIDENCE = 0.45;
|
|
78
79
|
|
|
80
|
+
/** Weights for knowledge item multi-signal scoring. */
|
|
81
|
+
const KNOWLEDGE_WEIGHTS = {
|
|
82
|
+
/** Base FTS/vector score weight. */
|
|
83
|
+
baseScore: 0.4,
|
|
84
|
+
/** Title keyword overlap weight. */
|
|
85
|
+
titleMatch: 0.25,
|
|
86
|
+
/** Tag overlap weight. */
|
|
87
|
+
tagOverlap: 0.2,
|
|
88
|
+
/** Intent/domain alignment weight. */
|
|
89
|
+
intentBoost: 0.15,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Weights for confidence computation. */
|
|
93
|
+
const CONFIDENCE_WEIGHTS = {
|
|
94
|
+
entitySignalPerEntity: 0.08,
|
|
95
|
+
entitySignalMax: 0.4,
|
|
96
|
+
actionSignal: 0.2,
|
|
97
|
+
knowledgeSignalMultiplier: 0.3,
|
|
98
|
+
sourceDiversityPerExtra: 0.05,
|
|
99
|
+
sourceDiversityMax: 0.1,
|
|
100
|
+
};
|
|
101
|
+
|
|
79
102
|
// ─── Class ──────────────────────────────────────────────────────────
|
|
80
103
|
|
|
81
104
|
export class ContextEngine {
|
|
@@ -120,7 +143,13 @@ export class ContextEngine {
|
|
|
120
143
|
if (seen.has(key)) continue;
|
|
121
144
|
if (type === 'pattern' && STOP_PATTERNS.has(value)) continue;
|
|
122
145
|
seen.add(key);
|
|
123
|
-
entities.push({
|
|
146
|
+
entities.push({
|
|
147
|
+
type,
|
|
148
|
+
value,
|
|
149
|
+
confidence,
|
|
150
|
+
start: match.index,
|
|
151
|
+
end: match.index + match[0].length,
|
|
152
|
+
});
|
|
124
153
|
}
|
|
125
154
|
}
|
|
126
155
|
|
|
@@ -147,15 +176,31 @@ export class ContextEngine {
|
|
|
147
176
|
domain,
|
|
148
177
|
limit: this.config.vaultSearchLimit,
|
|
149
178
|
});
|
|
150
|
-
// Normalize FTS5 -rank scores to 0-1 range
|
|
179
|
+
// Normalize FTS5 -rank scores to 0-1 range, then apply multi-signal scoring
|
|
151
180
|
const maxScore = vaultResults.length > 0 ? Math.max(...vaultResults.map((r) => r.score)) : 1;
|
|
181
|
+
const promptTokens = new Set(
|
|
182
|
+
prompt
|
|
183
|
+
.toLowerCase()
|
|
184
|
+
.split(/\s+/)
|
|
185
|
+
.filter((t) => t.length >= 3),
|
|
186
|
+
);
|
|
152
187
|
for (const r of vaultResults) {
|
|
188
|
+
const baseScore = maxScore > 0 ? r.score / maxScore : 0.5;
|
|
189
|
+
const enrichedScore = scoreKnowledgeItem(
|
|
190
|
+
baseScore,
|
|
191
|
+
r.entry.title,
|
|
192
|
+
r.entry.tags,
|
|
193
|
+
promptTokens,
|
|
194
|
+
domain,
|
|
195
|
+
r.entry.domain,
|
|
196
|
+
);
|
|
153
197
|
items.push({
|
|
154
198
|
id: r.entry.id,
|
|
155
199
|
title: r.entry.title,
|
|
156
|
-
score:
|
|
200
|
+
score: enrichedScore,
|
|
157
201
|
source: 'vault',
|
|
158
202
|
domain: r.entry.domain,
|
|
203
|
+
tags: r.entry.tags,
|
|
159
204
|
});
|
|
160
205
|
vaultHits++;
|
|
161
206
|
}
|
|
@@ -252,25 +297,29 @@ export class ContextEngine {
|
|
|
252
297
|
): number {
|
|
253
298
|
let score = 0;
|
|
254
299
|
|
|
255
|
-
// Entity signal
|
|
300
|
+
// Entity signal: more entities = clearer prompt
|
|
256
301
|
const entityCount = entities.entities.length;
|
|
257
|
-
|
|
258
|
-
|
|
302
|
+
score += Math.min(
|
|
303
|
+
CONFIDENCE_WEIGHTS.entitySignalMax,
|
|
304
|
+
entityCount * CONFIDENCE_WEIGHTS.entitySignalPerEntity,
|
|
305
|
+
);
|
|
259
306
|
|
|
260
|
-
// Action signal
|
|
307
|
+
// Action signal: explicit actions boost confidence
|
|
261
308
|
const actions = entities.byType.action ?? [];
|
|
262
|
-
if (actions.length > 0) score +=
|
|
309
|
+
if (actions.length > 0) score += CONFIDENCE_WEIGHTS.actionSignal;
|
|
263
310
|
|
|
264
|
-
// Knowledge signal
|
|
311
|
+
// Knowledge signal: relevant knowledge found
|
|
265
312
|
if (knowledge.items.length > 0) {
|
|
266
|
-
|
|
267
|
-
score += topScore * 0.3;
|
|
313
|
+
score += knowledge.items[0].score * CONFIDENCE_WEIGHTS.knowledgeSignalMultiplier;
|
|
268
314
|
}
|
|
269
315
|
|
|
270
|
-
// Source diversity bonus
|
|
316
|
+
// Source diversity bonus: multiple sources = more confident
|
|
271
317
|
const sources = new Set(knowledge.items.map((i) => i.source));
|
|
272
|
-
|
|
273
|
-
|
|
318
|
+
const diversityBonus = Math.min(
|
|
319
|
+
CONFIDENCE_WEIGHTS.sourceDiversityMax,
|
|
320
|
+
Math.max(0, sources.size - 1) * CONFIDENCE_WEIGHTS.sourceDiversityPerExtra,
|
|
321
|
+
);
|
|
322
|
+
score += diversityBonus;
|
|
274
323
|
|
|
275
324
|
return Math.min(1, score);
|
|
276
325
|
}
|
|
@@ -300,3 +349,53 @@ export class ContextEngine {
|
|
|
300
349
|
return [...domains];
|
|
301
350
|
}
|
|
302
351
|
}
|
|
352
|
+
|
|
353
|
+
// ─── Multi-Signal Knowledge Scoring ─────────────────────────────────
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Score a knowledge item using multiple signals:
|
|
357
|
+
* - baseScore: FTS5 rank or vector similarity (0-1)
|
|
358
|
+
* - titleMatch: keyword overlap between prompt and entry title
|
|
359
|
+
* - tagOverlap: how many prompt tokens appear in entry tags
|
|
360
|
+
* - intentBoost: domain alignment between query domain and entry domain
|
|
361
|
+
*/
|
|
362
|
+
function scoreKnowledgeItem(
|
|
363
|
+
baseScore: number,
|
|
364
|
+
title: string,
|
|
365
|
+
tags: string[],
|
|
366
|
+
promptTokens: Set<string>,
|
|
367
|
+
queryDomain: string | undefined,
|
|
368
|
+
entryDomain: string | undefined,
|
|
369
|
+
): number {
|
|
370
|
+
// Title match: fraction of prompt tokens found in title
|
|
371
|
+
const titleTokens = new Set(
|
|
372
|
+
title
|
|
373
|
+
.toLowerCase()
|
|
374
|
+
.split(/\s+/)
|
|
375
|
+
.filter((t) => t.length >= 3),
|
|
376
|
+
);
|
|
377
|
+
let titleOverlap = 0;
|
|
378
|
+
for (const t of promptTokens) {
|
|
379
|
+
if (titleTokens.has(t)) titleOverlap++;
|
|
380
|
+
}
|
|
381
|
+
const titleMatch = promptTokens.size > 0 ? titleOverlap / promptTokens.size : 0;
|
|
382
|
+
|
|
383
|
+
// Tag overlap: fraction of tags that match prompt tokens
|
|
384
|
+
const lowerTags = tags.map((t) => t.toLowerCase());
|
|
385
|
+
let tagHits = 0;
|
|
386
|
+
for (const tag of lowerTags) {
|
|
387
|
+
if (promptTokens.has(tag)) tagHits++;
|
|
388
|
+
}
|
|
389
|
+
const tagOverlap = lowerTags.length > 0 ? tagHits / lowerTags.length : 0;
|
|
390
|
+
|
|
391
|
+
// Intent boost: 1.0 if domains match, 0.0 otherwise
|
|
392
|
+
const intentBoost = queryDomain && entryDomain && queryDomain === entryDomain ? 1.0 : 0.0;
|
|
393
|
+
|
|
394
|
+
return Math.min(
|
|
395
|
+
1.0,
|
|
396
|
+
baseScore * KNOWLEDGE_WEIGHTS.baseScore +
|
|
397
|
+
titleMatch * KNOWLEDGE_WEIGHTS.titleMatch +
|
|
398
|
+
tagOverlap * KNOWLEDGE_WEIGHTS.tagOverlap +
|
|
399
|
+
intentBoost * KNOWLEDGE_WEIGHTS.intentBoost,
|
|
400
|
+
);
|
|
401
|
+
}
|
package/src/context/types.ts
CHANGED
|
@@ -10,6 +10,10 @@ export interface ExtractedEntity {
|
|
|
10
10
|
type: EntityType;
|
|
11
11
|
value: string;
|
|
12
12
|
confidence: number;
|
|
13
|
+
/** Start offset in the original prompt. */
|
|
14
|
+
start?: number;
|
|
15
|
+
/** End offset in the original prompt. */
|
|
16
|
+
end?: number;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface EntityExtractionResult {
|
|
@@ -25,6 +29,7 @@ export interface KnowledgeItem {
|
|
|
25
29
|
score: number;
|
|
26
30
|
source: 'vault' | 'cognee' | 'brain';
|
|
27
31
|
domain?: string;
|
|
32
|
+
tags?: string[];
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
export interface KnowledgeRetrievalResult {
|