@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,474 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogneeClient gap tests — covers behaviors missing from the original test suite.
|
|
3
|
+
*
|
|
4
|
+
* Source of truth: these tests define expected behavior.
|
|
5
|
+
* Code adapts to fulfill them.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, afterEach, vi, beforeEach } from 'vitest';
|
|
9
|
+
import { CogneeClient } from '../cognee/client.js';
|
|
10
|
+
import type { IntelligenceEntry } from '../intelligence/types.js';
|
|
11
|
+
|
|
12
|
+
// ─── Helpers ──────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
function makeEntry(overrides: Partial<IntelligenceEntry> = {}): IntelligenceEntry {
|
|
15
|
+
return {
|
|
16
|
+
id: overrides.id ?? 'test-1',
|
|
17
|
+
type: overrides.type ?? 'pattern',
|
|
18
|
+
domain: overrides.domain ?? 'testing',
|
|
19
|
+
title: overrides.title ?? 'Test Pattern',
|
|
20
|
+
severity: overrides.severity ?? 'warning',
|
|
21
|
+
description: overrides.description ?? 'A test pattern for unit tests.',
|
|
22
|
+
tags: overrides.tags ?? ['testing', 'assertions'],
|
|
23
|
+
...(overrides.context !== undefined ? { context: overrides.context } : {}),
|
|
24
|
+
...(overrides.example !== undefined ? { example: overrides.example } : {}),
|
|
25
|
+
...(overrides.why !== undefined ? { why: overrides.why } : {}),
|
|
26
|
+
...(overrides.counterExample !== undefined ? { counterExample: overrides.counterExample } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isHealthCheck(url: string, init?: RequestInit): boolean {
|
|
31
|
+
return url.endsWith(':8000/') || (url.endsWith('/') && (!init?.method || init.method === 'GET'));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isAuthCall(url: string): boolean {
|
|
35
|
+
return url.includes('/api/v1/auth/');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function mockWithAuth(apiHandler?: (url: string, init?: RequestInit) => Promise<Response>) {
|
|
39
|
+
const mock = vi.fn(async (url: string, init?: RequestInit) => {
|
|
40
|
+
if (isHealthCheck(url, init)) return new Response('ok', { status: 200 });
|
|
41
|
+
if (isAuthCall(url)) {
|
|
42
|
+
if (url.includes('/login')) {
|
|
43
|
+
return new Response(JSON.stringify({ access_token: 'test-jwt' }), { status: 200 });
|
|
44
|
+
}
|
|
45
|
+
if (url.includes('/register')) {
|
|
46
|
+
return new Response(JSON.stringify({ id: 'new-user' }), { status: 200 });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (apiHandler) return apiHandler(url, init);
|
|
50
|
+
return new Response('ok', { status: 200 });
|
|
51
|
+
});
|
|
52
|
+
vi.stubGlobal('fetch', mock);
|
|
53
|
+
return mock;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ─── Tests ────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
describe('CogneeClient — gap coverage', () => {
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
vi.restoreAllMocks();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// ─── deleteEntries ────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
describe('deleteEntries', () => {
|
|
66
|
+
it('should call POST /api/v1/delete with dataset and entryIds', async () => {
|
|
67
|
+
let capturedBody = '';
|
|
68
|
+
mockWithAuth(async (_url, init) => {
|
|
69
|
+
capturedBody = init?.body as string;
|
|
70
|
+
return new Response('ok', { status: 200 });
|
|
71
|
+
});
|
|
72
|
+
const client = new CogneeClient({ dataset: 'my-ds' });
|
|
73
|
+
await client.healthCheck();
|
|
74
|
+
const result = await client.deleteEntries(['e1', 'e2']);
|
|
75
|
+
expect(result.deleted).toBe(2);
|
|
76
|
+
const parsed = JSON.parse(capturedBody);
|
|
77
|
+
expect(parsed.datasetName).toBe('my-ds');
|
|
78
|
+
expect(parsed.entryIds).toEqual(['e1', 'e2']);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should return 0 when not available', async () => {
|
|
82
|
+
const client = new CogneeClient();
|
|
83
|
+
const result = await client.deleteEntries(['e1']);
|
|
84
|
+
expect(result.deleted).toBe(0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should return 0 for empty entryIds', async () => {
|
|
88
|
+
mockWithAuth();
|
|
89
|
+
const client = new CogneeClient();
|
|
90
|
+
await client.healthCheck();
|
|
91
|
+
const result = await client.deleteEntries([]);
|
|
92
|
+
expect(result.deleted).toBe(0);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should return 0 on HTTP error without throwing', async () => {
|
|
96
|
+
mockWithAuth(async () => new Response('error', { status: 500 }));
|
|
97
|
+
const client = new CogneeClient();
|
|
98
|
+
await client.healthCheck();
|
|
99
|
+
const result = await client.deleteEntries(['e1']);
|
|
100
|
+
expect(result.deleted).toBe(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should return 0 on network error without throwing', async () => {
|
|
104
|
+
mockWithAuth(async () => {
|
|
105
|
+
throw new Error('ECONNRESET');
|
|
106
|
+
});
|
|
107
|
+
const client = new CogneeClient();
|
|
108
|
+
await client.healthCheck();
|
|
109
|
+
const result = await client.deleteEntries(['e1']);
|
|
110
|
+
expect(result.deleted).toBe(0);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ─── Entry serialization ──────────────────────────────────────
|
|
115
|
+
|
|
116
|
+
describe('entry serialization (via addEntries FormData)', () => {
|
|
117
|
+
it('should include vault-id prefix in serialized text', async () => {
|
|
118
|
+
let capturedText = '';
|
|
119
|
+
mockWithAuth(async (_url, init) => {
|
|
120
|
+
const body = init?.body as FormData;
|
|
121
|
+
if (body instanceof FormData) {
|
|
122
|
+
const file = body.get('data') as File;
|
|
123
|
+
if (file) capturedText = await file.text();
|
|
124
|
+
}
|
|
125
|
+
return new Response('ok', { status: 200 });
|
|
126
|
+
});
|
|
127
|
+
const client = new CogneeClient();
|
|
128
|
+
await client.healthCheck();
|
|
129
|
+
await client.addEntries([makeEntry({ id: 'my-entry-42', title: 'My Title' })]);
|
|
130
|
+
expect(capturedText).toContain('[vault-id:my-entry-42]');
|
|
131
|
+
expect(capturedText).toContain('My Title');
|
|
132
|
+
client.resetPendingCognify();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should include description in serialized text', async () => {
|
|
136
|
+
let capturedText = '';
|
|
137
|
+
mockWithAuth(async (_url, init) => {
|
|
138
|
+
const body = init?.body as FormData;
|
|
139
|
+
if (body instanceof FormData) {
|
|
140
|
+
const file = body.get('data') as File;
|
|
141
|
+
if (file) capturedText = await file.text();
|
|
142
|
+
}
|
|
143
|
+
return new Response('ok', { status: 200 });
|
|
144
|
+
});
|
|
145
|
+
const client = new CogneeClient();
|
|
146
|
+
await client.healthCheck();
|
|
147
|
+
await client.addEntries([makeEntry({ description: 'Unique description text here' })]);
|
|
148
|
+
expect(capturedText).toContain('Unique description text here');
|
|
149
|
+
client.resetPendingCognify();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should include context when present', async () => {
|
|
153
|
+
let capturedText = '';
|
|
154
|
+
mockWithAuth(async (_url, init) => {
|
|
155
|
+
const body = init?.body as FormData;
|
|
156
|
+
if (body instanceof FormData) {
|
|
157
|
+
const file = body.get('data') as File;
|
|
158
|
+
if (file) capturedText = await file.text();
|
|
159
|
+
}
|
|
160
|
+
return new Response('ok', { status: 200 });
|
|
161
|
+
});
|
|
162
|
+
const client = new CogneeClient();
|
|
163
|
+
await client.healthCheck();
|
|
164
|
+
await client.addEntries([makeEntry({ context: 'Apply in production code only' })]);
|
|
165
|
+
expect(capturedText).toContain('Apply in production code only');
|
|
166
|
+
client.resetPendingCognify();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should include tags when present', async () => {
|
|
170
|
+
let capturedText = '';
|
|
171
|
+
mockWithAuth(async (_url, init) => {
|
|
172
|
+
const body = init?.body as FormData;
|
|
173
|
+
if (body instanceof FormData) {
|
|
174
|
+
const file = body.get('data') as File;
|
|
175
|
+
if (file) capturedText = await file.text();
|
|
176
|
+
}
|
|
177
|
+
return new Response('ok', { status: 200 });
|
|
178
|
+
});
|
|
179
|
+
const client = new CogneeClient();
|
|
180
|
+
await client.healthCheck();
|
|
181
|
+
await client.addEntries([makeEntry({ tags: ['react', 'performance'] })]);
|
|
182
|
+
expect(capturedText).toContain('Tags: react, performance');
|
|
183
|
+
client.resetPendingCognify();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should not include Tags line when tags are empty', async () => {
|
|
187
|
+
let capturedText = '';
|
|
188
|
+
mockWithAuth(async (_url, init) => {
|
|
189
|
+
const body = init?.body as FormData;
|
|
190
|
+
if (body instanceof FormData) {
|
|
191
|
+
const file = body.get('data') as File;
|
|
192
|
+
if (file) capturedText = await file.text();
|
|
193
|
+
}
|
|
194
|
+
return new Response('ok', { status: 200 });
|
|
195
|
+
});
|
|
196
|
+
const client = new CogneeClient();
|
|
197
|
+
await client.healthCheck();
|
|
198
|
+
await client.addEntries([makeEntry({ tags: [] })]);
|
|
199
|
+
expect(capturedText).not.toContain('Tags:');
|
|
200
|
+
client.resetPendingCognify();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should use entry.id as filename', async () => {
|
|
204
|
+
let capturedFilename = '';
|
|
205
|
+
mockWithAuth(async (_url, init) => {
|
|
206
|
+
const body = init?.body as FormData;
|
|
207
|
+
if (body instanceof FormData) {
|
|
208
|
+
const file = body.get('data') as File;
|
|
209
|
+
if (file) capturedFilename = file.name;
|
|
210
|
+
}
|
|
211
|
+
return new Response('ok', { status: 200 });
|
|
212
|
+
});
|
|
213
|
+
const client = new CogneeClient();
|
|
214
|
+
await client.healthCheck();
|
|
215
|
+
await client.addEntries([makeEntry({ id: 'pattern-arch-123' })]);
|
|
216
|
+
expect(capturedFilename).toBe('pattern-arch-123.txt');
|
|
217
|
+
client.resetPendingCognify();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// ─── Debounce sliding window ──────────────────────────────────
|
|
222
|
+
|
|
223
|
+
describe('cognify debounce — sliding window', () => {
|
|
224
|
+
beforeEach(() => {
|
|
225
|
+
vi.useFakeTimers();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
afterEach(() => {
|
|
229
|
+
vi.useRealTimers();
|
|
230
|
+
vi.restoreAllMocks();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should extend debounce window on rapid ingests (sliding, not fixed)', async () => {
|
|
234
|
+
let cognifyCount = 0;
|
|
235
|
+
mockWithAuth(async (url) => {
|
|
236
|
+
if (url.includes('/cognify')) cognifyCount++;
|
|
237
|
+
return new Response('ok', { status: 200 });
|
|
238
|
+
});
|
|
239
|
+
const client = new CogneeClient({ cognifyDebounceMs: 100 });
|
|
240
|
+
await client.healthCheck();
|
|
241
|
+
|
|
242
|
+
// First ingest at t=0
|
|
243
|
+
await client.addEntries([makeEntry({ id: 'e1' })]);
|
|
244
|
+
// Advance 80ms (within window), second ingest resets the timer
|
|
245
|
+
await vi.advanceTimersByTimeAsync(80);
|
|
246
|
+
await client.addEntries([makeEntry({ id: 'e2' })]);
|
|
247
|
+
// Advance 80ms (within the RESET window) — cognify should NOT have fired yet
|
|
248
|
+
await vi.advanceTimersByTimeAsync(80);
|
|
249
|
+
expect(cognifyCount).toBe(0);
|
|
250
|
+
|
|
251
|
+
// Advance past the reset window (another 30ms = 110ms from second ingest)
|
|
252
|
+
await vi.advanceTimersByTimeAsync(30);
|
|
253
|
+
expect(cognifyCount).toBe(1);
|
|
254
|
+
client.resetPendingCognify();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should fire separate cognify for different datasets', async () => {
|
|
258
|
+
const cognifyDatasets: string[][] = [];
|
|
259
|
+
mockWithAuth(async (url, init) => {
|
|
260
|
+
if (url.includes('/cognify')) {
|
|
261
|
+
const body = JSON.parse(init?.body as string);
|
|
262
|
+
cognifyDatasets.push(body.datasets);
|
|
263
|
+
}
|
|
264
|
+
return new Response('ok', { status: 200 });
|
|
265
|
+
});
|
|
266
|
+
// Two clients with different datasets
|
|
267
|
+
const client1 = new CogneeClient({ dataset: 'ds-alpha', cognifyDebounceMs: 50 });
|
|
268
|
+
const client2 = new CogneeClient({ dataset: 'ds-beta', cognifyDebounceMs: 50 });
|
|
269
|
+
await client1.healthCheck();
|
|
270
|
+
await client2.healthCheck();
|
|
271
|
+
|
|
272
|
+
await client1.addEntries([makeEntry({ id: 'a1' })]);
|
|
273
|
+
await client2.addEntries([makeEntry({ id: 'b1' })]);
|
|
274
|
+
|
|
275
|
+
await vi.advanceTimersByTimeAsync(60);
|
|
276
|
+
|
|
277
|
+
// Each dataset should cognify independently
|
|
278
|
+
expect(cognifyDatasets).toHaveLength(2);
|
|
279
|
+
const allDatasets = cognifyDatasets.flat();
|
|
280
|
+
expect(allDatasets).toContain('ds-alpha');
|
|
281
|
+
expect(allDatasets).toContain('ds-beta');
|
|
282
|
+
|
|
283
|
+
client1.resetPendingCognify();
|
|
284
|
+
client2.resetPendingCognify();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('should coalesce multiple ingests to same dataset into one cognify', async () => {
|
|
288
|
+
let cognifyCount = 0;
|
|
289
|
+
mockWithAuth(async (url) => {
|
|
290
|
+
if (url.includes('/cognify')) cognifyCount++;
|
|
291
|
+
return new Response('ok', { status: 200 });
|
|
292
|
+
});
|
|
293
|
+
const client = new CogneeClient({ cognifyDebounceMs: 50 });
|
|
294
|
+
await client.healthCheck();
|
|
295
|
+
|
|
296
|
+
await client.addEntries([makeEntry({ id: 'e1' })]);
|
|
297
|
+
await client.addEntries([makeEntry({ id: 'e2' })]);
|
|
298
|
+
await client.addEntries([makeEntry({ id: 'e3' })]);
|
|
299
|
+
|
|
300
|
+
await vi.advanceTimersByTimeAsync(60);
|
|
301
|
+
|
|
302
|
+
expect(cognifyCount).toBe(1);
|
|
303
|
+
client.resetPendingCognify();
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// ─── Concurrent operations ────────────────────────────────────
|
|
308
|
+
|
|
309
|
+
describe('concurrent operations', () => {
|
|
310
|
+
it('should handle parallel addEntries without interference', async () => {
|
|
311
|
+
mockWithAuth();
|
|
312
|
+
const client = new CogneeClient();
|
|
313
|
+
await client.healthCheck();
|
|
314
|
+
|
|
315
|
+
const results = await Promise.all([
|
|
316
|
+
client.addEntries([makeEntry({ id: 'p1' })]),
|
|
317
|
+
client.addEntries([makeEntry({ id: 'p2' })]),
|
|
318
|
+
client.addEntries([makeEntry({ id: 'p3' })]),
|
|
319
|
+
client.addEntries([makeEntry({ id: 'p4' })]),
|
|
320
|
+
client.addEntries([makeEntry({ id: 'p5' })]),
|
|
321
|
+
]);
|
|
322
|
+
|
|
323
|
+
expect(results.every((r) => r.added === 1)).toBe(true);
|
|
324
|
+
client.resetPendingCognify();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should handle parallel search calls', async () => {
|
|
328
|
+
mockWithAuth(
|
|
329
|
+
async () =>
|
|
330
|
+
new Response(JSON.stringify([{ id: 'r1', text: 'Result', score: 0.9 }]), { status: 200 }),
|
|
331
|
+
);
|
|
332
|
+
const client = new CogneeClient();
|
|
333
|
+
await client.healthCheck();
|
|
334
|
+
|
|
335
|
+
const results = await Promise.all([
|
|
336
|
+
client.search('query 1'),
|
|
337
|
+
client.search('query 2'),
|
|
338
|
+
client.search('query 3'),
|
|
339
|
+
]);
|
|
340
|
+
|
|
341
|
+
expect(results.every((r) => r.length === 1)).toBe(true);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ─── Search edge cases ────────────────────────────────────────
|
|
346
|
+
|
|
347
|
+
describe('search edge cases', () => {
|
|
348
|
+
it('should handle empty string query gracefully', async () => {
|
|
349
|
+
mockWithAuth(async () => new Response(JSON.stringify([]), { status: 200 }));
|
|
350
|
+
const client = new CogneeClient();
|
|
351
|
+
await client.healthCheck();
|
|
352
|
+
const results = await client.search('');
|
|
353
|
+
expect(Array.isArray(results)).toBe(true);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('should handle results with non-string text field', async () => {
|
|
357
|
+
mockWithAuth(
|
|
358
|
+
async () =>
|
|
359
|
+
new Response(
|
|
360
|
+
JSON.stringify([
|
|
361
|
+
{ id: 'r1', text: 42, score: 0.8 },
|
|
362
|
+
{ id: 'r2', score: 0.7 },
|
|
363
|
+
]),
|
|
364
|
+
{ status: 200 },
|
|
365
|
+
),
|
|
366
|
+
);
|
|
367
|
+
const client = new CogneeClient();
|
|
368
|
+
await client.healthCheck();
|
|
369
|
+
const results = await client.search('query');
|
|
370
|
+
// text should be coerced to string
|
|
371
|
+
expect(typeof results[0].text).toBe('string');
|
|
372
|
+
expect(typeof results[1].text).toBe('string');
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('should handle null/undefined text field', async () => {
|
|
376
|
+
mockWithAuth(
|
|
377
|
+
async () =>
|
|
378
|
+
new Response(JSON.stringify([{ id: 'r1', text: null, score: 0.5 }]), { status: 200 }),
|
|
379
|
+
);
|
|
380
|
+
const client = new CogneeClient();
|
|
381
|
+
await client.healthCheck();
|
|
382
|
+
const results = await client.search('query');
|
|
383
|
+
expect(typeof results[0].text).toBe('string');
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// ─── Auth edge cases ──────────────────────────────────────────
|
|
388
|
+
|
|
389
|
+
describe('auth edge cases', () => {
|
|
390
|
+
it('should cache auth token across multiple API calls', async () => {
|
|
391
|
+
let loginCount = 0;
|
|
392
|
+
const mock = vi.fn(async (url: string, init?: RequestInit) => {
|
|
393
|
+
if (isHealthCheck(url, init)) return new Response('ok', { status: 200 });
|
|
394
|
+
if (url.includes('/auth/login')) {
|
|
395
|
+
loginCount++;
|
|
396
|
+
return new Response(JSON.stringify({ access_token: 'cached-jwt' }), { status: 200 });
|
|
397
|
+
}
|
|
398
|
+
return new Response(JSON.stringify([]), { status: 200 });
|
|
399
|
+
});
|
|
400
|
+
vi.stubGlobal('fetch', mock);
|
|
401
|
+
|
|
402
|
+
const client = new CogneeClient();
|
|
403
|
+
await client.healthCheck();
|
|
404
|
+
|
|
405
|
+
// Multiple API calls should reuse the same token
|
|
406
|
+
await client.search('q1');
|
|
407
|
+
await client.search('q2');
|
|
408
|
+
await client.cognify();
|
|
409
|
+
|
|
410
|
+
expect(loginCount).toBe(1);
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// ─── Position scoring ─────────────────────────────────────────
|
|
415
|
+
|
|
416
|
+
describe('position-based scoring', () => {
|
|
417
|
+
it('should give first result score 1.0 and last result score 0.05', async () => {
|
|
418
|
+
const items = Array.from({ length: 10 }, (_, i) => ({
|
|
419
|
+
id: `r${i}`,
|
|
420
|
+
text: `Result ${i}`,
|
|
421
|
+
}));
|
|
422
|
+
mockWithAuth(async () => new Response(JSON.stringify(items), { status: 200 }));
|
|
423
|
+
const client = new CogneeClient();
|
|
424
|
+
await client.healthCheck();
|
|
425
|
+
const results = await client.search('query', { limit: 10 });
|
|
426
|
+
expect(results[0].score).toBe(1.0);
|
|
427
|
+
expect(results[results.length - 1].score).toBeCloseTo(0.05, 2);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('should produce monotonically decreasing scores', async () => {
|
|
431
|
+
const items = Array.from({ length: 5 }, (_, i) => ({
|
|
432
|
+
id: `r${i}`,
|
|
433
|
+
text: `Result ${i}`,
|
|
434
|
+
}));
|
|
435
|
+
mockWithAuth(async () => new Response(JSON.stringify(items), { status: 200 }));
|
|
436
|
+
const client = new CogneeClient();
|
|
437
|
+
await client.healthCheck();
|
|
438
|
+
const results = await client.search('query', { limit: 5 });
|
|
439
|
+
for (let i = 1; i < results.length; i++) {
|
|
440
|
+
expect(results[i].score).toBeLessThan(results[i - 1].score);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it('should give single result score 1.0', async () => {
|
|
445
|
+
mockWithAuth(
|
|
446
|
+
async () =>
|
|
447
|
+
new Response(JSON.stringify([{ id: 'only', text: 'Sole result' }]), { status: 200 }),
|
|
448
|
+
);
|
|
449
|
+
const client = new CogneeClient();
|
|
450
|
+
await client.healthCheck();
|
|
451
|
+
const results = await client.search('query');
|
|
452
|
+
expect(results[0].score).toBe(1.0);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('should prefer explicit Cognee scores over position', async () => {
|
|
456
|
+
mockWithAuth(
|
|
457
|
+
async () =>
|
|
458
|
+
new Response(
|
|
459
|
+
JSON.stringify([
|
|
460
|
+
{ id: 'r1', text: 'First', score: 0.3 },
|
|
461
|
+
{ id: 'r2', text: 'Second', score: 0.9 },
|
|
462
|
+
]),
|
|
463
|
+
{ status: 200 },
|
|
464
|
+
),
|
|
465
|
+
);
|
|
466
|
+
const client = new CogneeClient();
|
|
467
|
+
await client.healthCheck();
|
|
468
|
+
const results = await client.search('query');
|
|
469
|
+
// Explicit scores should be used, not position
|
|
470
|
+
expect(results[0].score).toBe(0.3);
|
|
471
|
+
expect(results[1].score).toBe(0.9);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
});
|