@octopi-agent/engine 0.98.4 → 0.121.10
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/dist/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +6 -2
- package/dist/config-admin/index.js +3 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +71 -0
- package/dist/config-admin/onboarding-apply.js +235 -0
- package/dist/config-admin/onboarding.d.ts +154 -0
- package/dist/config-admin/onboarding.js +270 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +40 -6
- package/dist/config-schema/agent.js +44 -6
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +12 -37
- package/dist/config-schema/context.js +10 -31
- package/dist/config-schema/engine.d.ts +140 -164
- package/dist/config-schema/engine.js +10 -7
- package/dist/config-schema/governance.d.ts +20 -2
- package/dist/config-schema/governance.js +18 -3
- package/dist/config-schema/models.d.ts +10 -12
- package/dist/config-schema/models.js +16 -3
- package/dist/config-schema/run.d.ts +6 -2
- package/dist/config-schema/run.js +12 -2
- package/dist/config-schema/shared.d.ts +1 -3
- package/dist/config-schema/shared.js +4 -4
- package/dist/config-schema/substrate.d.ts +19 -88
- package/dist/config-schema/substrate.js +30 -107
- package/dist/config.d.ts +161 -123
- package/dist/config.js +109 -7
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +11 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +130 -31
- package/dist/harness/activation/types.d.ts +20 -3
- package/dist/harness/agent/builder.d.ts +36 -3
- package/dist/harness/agent/builder.js +206 -46
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +24 -5
- package/dist/harness/agent/config-integrity.js +19 -2
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +13 -3
- package/dist/harness/agent/wire-agent-builder.js +35 -9
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +2 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +14 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +50 -41
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +7 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +10 -1
- package/dist/harness/collaboration/delegation/child-run.js +38 -6
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +11 -4
- package/dist/harness/collaboration/delegation/service.js +35 -13
- package/dist/harness/collaboration/delegation/store.d.ts +4 -0
- package/dist/harness/collaboration/delegation/store.js +3 -1
- package/dist/harness/collaboration/delegation/types.d.ts +34 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +12 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -11
- package/dist/harness/context/capabilities/compact/engine.js +296 -160
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +7 -2
- package/dist/harness/context/capabilities/compact/index.js +5 -1
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +134 -19
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +19 -6
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +243 -0
- package/dist/harness/context/default-context-engine.d.ts +290 -120
- package/dist/harness/context/default-context-engine.js +1555 -764
- package/dist/harness/context/index.d.ts +3 -2
- package/dist/harness/context/index.js +2 -1
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +72 -0
- package/dist/harness/context/layer-types.js +87 -2
- package/dist/harness/context/layers.d.ts +17 -15
- package/dist/harness/context/layers.js +54 -17
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +27 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +7 -3
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +109 -16
- package/dist/harness/context/tool-result-aging.js +220 -55
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +196 -119
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +28 -2
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +223 -222
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +218 -203
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +78 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +80 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +57 -114
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +279 -282
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +46 -484
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +123 -345
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +50 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +144 -20
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +17 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +36 -8
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +19 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- package/dist/harness/governance/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
- package/dist/harness/governance/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +17 -15
- package/dist/harness/index.js +9 -9
- package/dist/harness/knowledge/boot-config.d.ts +57 -0
- package/dist/harness/knowledge/boot-config.js +52 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +77 -9
- package/dist/harness/knowledge/client.js +95 -24
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +112 -41
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +11 -7
- package/dist/harness/knowledge/grounding.js +7 -2
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +117 -25
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +5 -3
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +25 -4
- package/dist/harness/knowledge/query-service.js +79 -43
- package/dist/harness/knowledge/query-worker-client.d.ts +14 -2
- package/dist/harness/knowledge/query-worker-client.js +8 -3
- package/dist/harness/knowledge/query-worker.js +9 -5
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +14 -3
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +14 -8
- package/dist/harness/knowledge/serve.js +14 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +323 -74
- package/dist/harness/knowledge/start-service-process.d.ts +41 -14
- package/dist/harness/knowledge/start-service-process.js +67 -96
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +55 -11
- package/dist/harness/knowledge/writer-service.js +200 -30
- package/dist/harness/knowledge/writer-worker-client.d.ts +19 -11
- package/dist/harness/knowledge/writer-worker-client.js +40 -5
- package/dist/harness/knowledge/writer-worker.js +20 -5
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +24 -6
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +120 -17
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +67 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +32 -4
- package/dist/harness/run/reliability/run-agent.js +216 -63
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- package/dist/harness/run/run-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +48 -4
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +181 -39
- package/dist/harness/run/runner.js +654 -119
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- package/dist/harness/session/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -0
- package/dist/harness/session/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +11 -15
- package/dist/harness/shared/events/agent-event-map.d.ts +75 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/types/agent-definition.d.ts +7 -2
- package/dist/index.d.ts +16 -18
- package/dist/index.js +9 -10
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- package/dist/integration/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +41 -3
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +48 -2
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +57 -3
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +20 -2
- package/dist/integration/storage/archive-manager.js +34 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +10 -1
- package/dist/integration/storage/jsonl.js +155 -54
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +4 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +14 -15
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -28,9 +28,7 @@ async function main() {
|
|
|
28
28
|
throw new Error('knowledge writer worker requires parentPort');
|
|
29
29
|
const db = await KnowledgeDatabase.create({
|
|
30
30
|
dbPath: boot.dbPath,
|
|
31
|
-
sqliteVec: boot.
|
|
32
|
-
? { extensionPath: boot.sqliteVecExtensionPath }
|
|
33
|
-
: true,
|
|
31
|
+
sqliteVec: boot.sqliteVec ?? true,
|
|
34
32
|
});
|
|
35
33
|
let embeddingProvider = null;
|
|
36
34
|
if (boot.testEmbeddingStub) {
|
|
@@ -46,6 +44,9 @@ async function main() {
|
|
|
46
44
|
documentConfig: boot.documentConfig ?? null,
|
|
47
45
|
embeddingProvider: embeddingProvider,
|
|
48
46
|
embed: boot.embed ?? null,
|
|
47
|
+
allowPublic: boot.allowPublic ?? false,
|
|
48
|
+
ingest: boot.ingest ?? null,
|
|
49
|
+
autoDescribe: boot.autoDescribe,
|
|
49
50
|
});
|
|
50
51
|
write.onProgress((evt) => {
|
|
51
52
|
port.postMessage({ type: 'progress', evt });
|
|
@@ -105,7 +106,13 @@ async function main() {
|
|
|
105
106
|
data = await write.removeSource(identity, String(args.sourceId));
|
|
106
107
|
break;
|
|
107
108
|
case 'describeSource':
|
|
108
|
-
data = await write.describeSource(identity, String(args.sourceId));
|
|
109
|
+
data = await write.describeSource(identity, String(args.sourceId), args.input);
|
|
110
|
+
break;
|
|
111
|
+
case 'describeSample':
|
|
112
|
+
data = await write.describeSample(identity, String(args.sourceId));
|
|
113
|
+
break;
|
|
114
|
+
case 'listDescribePending':
|
|
115
|
+
data = await write.listDescribePending(identity);
|
|
109
116
|
break;
|
|
110
117
|
case 'reindexSource':
|
|
111
118
|
await write.reindexSource(String(args.sourceId));
|
|
@@ -145,6 +152,14 @@ async function main() {
|
|
|
145
152
|
await write.unhideSource(identity, String(args.agentId), String(args.sourceId));
|
|
146
153
|
data = null;
|
|
147
154
|
break;
|
|
155
|
+
case 'mountSource':
|
|
156
|
+
await write.mountSource(identity, String(args.agentId), String(args.sourceId));
|
|
157
|
+
data = null;
|
|
158
|
+
break;
|
|
159
|
+
case 'unmountSource':
|
|
160
|
+
await write.unmountSource(identity, String(args.agentId), String(args.sourceId));
|
|
161
|
+
data = null;
|
|
162
|
+
break;
|
|
148
163
|
case 'replaceSessionVisibility':
|
|
149
164
|
data = await write.replaceSessionVisibility(identity, String(args.agentId), String(args.sessionId), args.items ?? []);
|
|
150
165
|
break;
|
|
@@ -153,7 +168,7 @@ async function main() {
|
|
|
153
168
|
data = null;
|
|
154
169
|
break;
|
|
155
170
|
case 'clearSessionVisibility':
|
|
156
|
-
await write.clearSessionVisibility(identity, String(args.sessionId), args.target);
|
|
171
|
+
await write.clearSessionVisibility(identity, String(args.sessionId), args.target, args.op);
|
|
157
172
|
data = null;
|
|
158
173
|
break;
|
|
159
174
|
case 'isSourceOwner':
|
|
@@ -47,13 +47,20 @@ export declare class BackfillTrigger {
|
|
|
47
47
|
private readonly maxEvidenceChars;
|
|
48
48
|
private readonly now;
|
|
49
49
|
private activity;
|
|
50
|
-
private idleTimer?;
|
|
51
|
-
private gapTimer?;
|
|
52
50
|
private disposables;
|
|
53
51
|
private disposed;
|
|
54
52
|
constructor(options: BackfillTriggerOptions);
|
|
55
|
-
/** 订阅 lifecycle
|
|
53
|
+
/** 订阅 lifecycle 事件(硬收敛=执行面尾,随事件驱动保留)。
|
|
54
|
+
* 周期扫描(idle/gap)不再 self-arm——由 gateway 脉搏调度器经 `pulse()` 单发驱动
|
|
55
|
+
* (P0c A′:run 实例零常驻触发器,arch/service-topology-p0c.md §3)。 */
|
|
56
56
|
start(): void;
|
|
57
|
+
/** 脉搏声明(P0c A′):供装配层聚合成实例级 PulseSpec 列表 */
|
|
58
|
+
pulseSpecs(): Array<{
|
|
59
|
+
key: string;
|
|
60
|
+
intervalMs: number;
|
|
61
|
+
}>;
|
|
62
|
+
/** 脉搏入口:gateway 单发驱动一次周期扫描。未知 key fail-loud。 */
|
|
63
|
+
pulse(key: string): Promise<number>;
|
|
57
64
|
stop(): void;
|
|
58
65
|
dispose(): void;
|
|
59
66
|
/** 记录活跃(每轮 handle / lifecycle active) */
|
|
@@ -26,8 +26,6 @@ export class BackfillTrigger {
|
|
|
26
26
|
maxEvidenceChars;
|
|
27
27
|
now;
|
|
28
28
|
activity = new Map();
|
|
29
|
-
idleTimer;
|
|
30
|
-
gapTimer;
|
|
31
29
|
disposables = [];
|
|
32
30
|
disposed = false;
|
|
33
31
|
constructor(options) {
|
|
@@ -43,7 +41,9 @@ export class BackfillTrigger {
|
|
|
43
41
|
this.maxEvidenceChars = options.maxEvidenceChars ?? 8000;
|
|
44
42
|
this.now = options.now ?? (() => Date.now());
|
|
45
43
|
}
|
|
46
|
-
/** 订阅 lifecycle
|
|
44
|
+
/** 订阅 lifecycle 事件(硬收敛=执行面尾,随事件驱动保留)。
|
|
45
|
+
* 周期扫描(idle/gap)不再 self-arm——由 gateway 脉搏调度器经 `pulse()` 单发驱动
|
|
46
|
+
* (P0c A′:run 实例零常驻触发器,arch/service-topology-p0c.md §3)。 */
|
|
47
47
|
start() {
|
|
48
48
|
if (this.disposed)
|
|
49
49
|
return;
|
|
@@ -67,24 +67,24 @@ export class BackfillTrigger {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
}));
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
}
|
|
71
|
+
/** 脉搏声明(P0c A′):供装配层聚合成实例级 PulseSpec 列表 */
|
|
72
|
+
pulseSpecs() {
|
|
73
|
+
return [
|
|
74
|
+
{ key: 'backfill.idle', intervalMs: this.idleScanMs },
|
|
75
|
+
{ key: 'backfill.gap', intervalMs: this.gapScanMs },
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
/** 脉搏入口:gateway 单发驱动一次周期扫描。未知 key fail-loud。 */
|
|
79
|
+
async pulse(key) {
|
|
80
|
+
if (key === 'backfill.idle')
|
|
81
|
+
return this.scanIdle();
|
|
82
|
+
if (key === 'backfill.gap')
|
|
83
|
+
return this.scanGaps();
|
|
84
|
+
throw new Error(`backfill-trigger: unknown pulse key "${key}"`);
|
|
78
85
|
}
|
|
79
86
|
stop() {
|
|
80
|
-
|
|
81
|
-
clearInterval(this.idleTimer);
|
|
82
|
-
this.idleTimer = undefined;
|
|
83
|
-
}
|
|
84
|
-
if (this.gapTimer) {
|
|
85
|
-
clearInterval(this.gapTimer);
|
|
86
|
-
this.gapTimer = undefined;
|
|
87
|
-
}
|
|
87
|
+
// P0c A′:周期扫描已改脉搏驱动,无 self-arm 定时器可停。
|
|
88
88
|
}
|
|
89
89
|
dispose() {
|
|
90
90
|
this.stop();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognition 召回种子 — 种子推导与双向匹配(CognitionLayer 与两个 ConceptGraphStore 共用单源)
|
|
3
|
+
*
|
|
4
|
+
* 切词复用记忆检索的分词内核({@link tokenizeKeywordDetail})——全库唯一一套切词语义;
|
|
5
|
+
* 这里只承载概念召回的种子策略(强 token、上限、整句兜底)与匹配谓词。
|
|
6
|
+
*
|
|
7
|
+
* 单字概念名仅精确命中可召回(不参与包含/反向匹配,防单字误锚)。
|
|
8
|
+
*
|
|
9
|
+
* @module harness/memory/cognition-seeds
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* 概念名归一(指纹与召回匹配共用;唯一实现,store 内不得另抄)。
|
|
13
|
+
*
|
|
14
|
+
* @param name - 原始概念名
|
|
15
|
+
* @returns trim + 小写
|
|
16
|
+
*/
|
|
17
|
+
export declare function normName(name: string): string;
|
|
18
|
+
export interface DeriveQuerySeedsOptions {
|
|
19
|
+
/** 每个 token 最少字符数(默认 2,与分词内核一致) */
|
|
20
|
+
minTokenLength?: number;
|
|
21
|
+
/** 子句种子上限(默认 8;<1 按 1) */
|
|
22
|
+
maxSeeds?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 从查询文本推导词面种子:空白/标点切分后的强 token(CJK 滑窗二元组不算种子,防误锚)。
|
|
26
|
+
* 子句超上限时截断并**追加整句兜底种子**——句内任意位置直呼概念名的反向覆盖面不因截断丢失;
|
|
27
|
+
* 切不出 token 时回退整句。
|
|
28
|
+
*
|
|
29
|
+
* @param query - 原始查询文本
|
|
30
|
+
* @param options - 上限与最小长度
|
|
31
|
+
* @returns 种子列表(截断时 ≤ maxSeeds + 1;空查询返回空数组)
|
|
32
|
+
*/
|
|
33
|
+
export declare function deriveQuerySeeds(query: string, options?: DeriveQuerySeedsOptions): string[];
|
|
34
|
+
export type SeedMatcher = (name: string, description?: string | null) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 构造种子命中谓词(两个 store 实现共用,禁止各写一份)。
|
|
37
|
+
*
|
|
38
|
+
* 命中 = name 精确等于 token | name 含 token | token 含 name | description 含 token。
|
|
39
|
+
* 包含匹配要求「针」≥2 字(正向/描述=token,反向=name 归一后),防单字误锚;
|
|
40
|
+
* 单字概念名仅精确命中可召回。
|
|
41
|
+
*
|
|
42
|
+
* @param seeds - 原始种子(内部经 {@link normName} 归一,空种子忽略)
|
|
43
|
+
* @returns 命中谓词
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSeedMatcher(seeds: readonly string[]): SeedMatcher;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognition 召回种子 — 种子推导与双向匹配(CognitionLayer 与两个 ConceptGraphStore 共用单源)
|
|
3
|
+
*
|
|
4
|
+
* 切词复用记忆检索的分词内核({@link tokenizeKeywordDetail})——全库唯一一套切词语义;
|
|
5
|
+
* 这里只承载概念召回的种子策略(强 token、上限、整句兜底)与匹配谓词。
|
|
6
|
+
*
|
|
7
|
+
* 单字概念名仅精确命中可召回(不参与包含/反向匹配,防单字误锚)。
|
|
8
|
+
*
|
|
9
|
+
* @module harness/memory/cognition-seeds
|
|
10
|
+
*/
|
|
11
|
+
import { tokenizeKeywordDetail } from './sqlite/keyword-search.js';
|
|
12
|
+
/**
|
|
13
|
+
* 概念名归一(指纹与召回匹配共用;唯一实现,store 内不得另抄)。
|
|
14
|
+
*
|
|
15
|
+
* @param name - 原始概念名
|
|
16
|
+
* @returns trim + 小写
|
|
17
|
+
*/
|
|
18
|
+
export function normName(name) {
|
|
19
|
+
return name.trim().toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 从查询文本推导词面种子:空白/标点切分后的强 token(CJK 滑窗二元组不算种子,防误锚)。
|
|
23
|
+
* 子句超上限时截断并**追加整句兜底种子**——句内任意位置直呼概念名的反向覆盖面不因截断丢失;
|
|
24
|
+
* 切不出 token 时回退整句。
|
|
25
|
+
*
|
|
26
|
+
* @param query - 原始查询文本
|
|
27
|
+
* @param options - 上限与最小长度
|
|
28
|
+
* @returns 种子列表(截断时 ≤ maxSeeds + 1;空查询返回空数组)
|
|
29
|
+
*/
|
|
30
|
+
export function deriveQuerySeeds(query, options) {
|
|
31
|
+
const minLen = options?.minTokenLength ?? 2;
|
|
32
|
+
const maxSeeds = Math.max(1, options?.maxSeeds ?? 8);
|
|
33
|
+
const strong = tokenizeKeywordDetail(query).strong.filter((t) => t.length >= minLen);
|
|
34
|
+
const whole = query.trim();
|
|
35
|
+
if (strong.length > maxSeeds) {
|
|
36
|
+
return [...strong.slice(0, maxSeeds), whole];
|
|
37
|
+
}
|
|
38
|
+
return strong.length ? strong : whole ? [whole] : [];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 构造种子命中谓词(两个 store 实现共用,禁止各写一份)。
|
|
42
|
+
*
|
|
43
|
+
* 命中 = name 精确等于 token | name 含 token | token 含 name | description 含 token。
|
|
44
|
+
* 包含匹配要求「针」≥2 字(正向/描述=token,反向=name 归一后),防单字误锚;
|
|
45
|
+
* 单字概念名仅精确命中可召回。
|
|
46
|
+
*
|
|
47
|
+
* @param seeds - 原始种子(内部经 {@link normName} 归一,空种子忽略)
|
|
48
|
+
* @returns 命中谓词
|
|
49
|
+
*/
|
|
50
|
+
export function createSeedMatcher(seeds) {
|
|
51
|
+
const keys = seeds.map((s) => normName(s)).filter((s) => s.length > 0);
|
|
52
|
+
return (name, description) => {
|
|
53
|
+
const nameKey = normName(name);
|
|
54
|
+
for (const s of keys) {
|
|
55
|
+
if (nameKey === s)
|
|
56
|
+
return true;
|
|
57
|
+
if (s.length >= 2 && nameKey.includes(s))
|
|
58
|
+
return true;
|
|
59
|
+
if (nameKey.length >= 2 && s.includes(nameKey))
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (!description)
|
|
63
|
+
return false;
|
|
64
|
+
const descKey = normName(description);
|
|
65
|
+
return keys.some((s) => s.length >= 2 && descKey.includes(s));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module harness/memory/cognition
|
|
8
8
|
*/
|
|
9
|
-
import type { ActivatedGraph, AdmitConceptInput, AdmitConceptResult, AdmitEdgeInput, AdmitEdgeResult, ConceptGraph, ConceptGraphStats, ConceptGraphStore, DecayResult, MergeCandidate, SpreadingActivateOptions } from './cognition-types.js';
|
|
9
|
+
import type { ActivatedGraph, AdmitConceptInput, AdmitConceptResult, AdmitEdgeInput, AdmitEdgeResult, ConceptGraph, ConceptGraphStats, ConceptGraphStore, ConceptKind, DecayResult, MergeCandidate, SpreadingActivateOptions } from './cognition-types.js';
|
|
10
10
|
export declare class InMemoryConceptGraph implements ConceptGraphStore {
|
|
11
11
|
private nodes;
|
|
12
12
|
private edges;
|
|
@@ -15,7 +15,7 @@ export declare class InMemoryConceptGraph implements ConceptGraphStore {
|
|
|
15
15
|
private get capacityStop();
|
|
16
16
|
admitConcept(input: AdmitConceptInput): Promise<AdmitConceptResult>;
|
|
17
17
|
private insertNode;
|
|
18
|
-
/**
|
|
18
|
+
/** 义项指纹冲突:仅 kind 不同。domain 是多值标签不参与义项判定(同名同 kind 合并且 domain 取并集) */
|
|
19
19
|
private fingerprintConflict;
|
|
20
20
|
private pushMergeCandidate;
|
|
21
21
|
private collectPairMemoryIds;
|
|
@@ -28,7 +28,16 @@ export declare class InMemoryConceptGraph implements ConceptGraphStore {
|
|
|
28
28
|
note?: string;
|
|
29
29
|
}): Promise<void>;
|
|
30
30
|
listMergeCandidates(limit?: number): Promise<MergeCandidate[]>;
|
|
31
|
-
|
|
31
|
+
/** 无向量能力(InMemory 不注 embedding):语义种子恒空,调用方据 supportsSemanticSeeds 降级纯词面 */
|
|
32
|
+
readonly supportsSemanticSeeds = false;
|
|
33
|
+
/**
|
|
34
|
+
* 与 ConceptGraphStore 契约同签名:query/k 收下但不使用(无向量能力,调用方据 supportsSemanticSeeds 降级)。
|
|
35
|
+
* @returns 恒空数组——InMemory 无向量,语义种子不可用(能力缺失,非数据为空)
|
|
36
|
+
*/
|
|
37
|
+
semanticSeeds(_query: string, _k?: number): Promise<string[]>;
|
|
38
|
+
resolveMerge(id: string, action: 'merge' | 'keep_split' | 'drop', options?: {
|
|
39
|
+
canonicalKind?: ConceptKind;
|
|
40
|
+
}): Promise<void>;
|
|
32
41
|
reinforce(input: {
|
|
33
42
|
nodeIds?: string[];
|
|
34
43
|
edgeIds?: string[];
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
10
|
import { counterEvidenceWeaken, DEFAULT_EDGE_DECAY_FLOOR, DEFAULT_RETRIEVE_STATUSES, hebbianStrengthen, nextEdgeStrength, } from './cognition-decay.js';
|
|
11
11
|
import { evaluateConceptGate, licenseEdge } from './cognition-gates.js';
|
|
12
|
-
|
|
13
|
-
return name.trim().toLowerCase();
|
|
14
|
-
}
|
|
12
|
+
import { createSeedMatcher, normName } from './cognition-seeds.js';
|
|
15
13
|
function daysBetween(a, b) {
|
|
16
14
|
return Math.max(0, (b - a) / 86_400_000);
|
|
17
15
|
}
|
|
@@ -31,13 +29,13 @@ export class InMemoryConceptGraph {
|
|
|
31
29
|
return { action: 'rejected', reason: gate.reason, message: gate.message };
|
|
32
30
|
}
|
|
33
31
|
const key = normName(input.name);
|
|
34
|
-
const
|
|
35
|
-
|
|
32
|
+
const sameNames = [...this.nodes.values()].filter((n) => normName(n.name) === key);
|
|
33
|
+
const conflicts = [];
|
|
34
|
+
for (const sameName of sameNames) {
|
|
36
35
|
const conflict = this.fingerprintConflict(sameName, input);
|
|
37
36
|
if (conflict) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return { action: 'merge_candidate', id, candidateId, reason: 'fingerprint_conflict' };
|
|
37
|
+
conflicts.push({ node: sameName, reason: conflict });
|
|
38
|
+
continue;
|
|
41
39
|
}
|
|
42
40
|
// 指纹兼容 → 合并
|
|
43
41
|
sameName.frequency += 1;
|
|
@@ -46,15 +44,21 @@ export class InMemoryConceptGraph {
|
|
|
46
44
|
if (!sameName.memoryIds.includes(mid))
|
|
47
45
|
sameName.memoryIds.push(mid);
|
|
48
46
|
}
|
|
49
|
-
|
|
47
|
+
for (const d of input.domain ?? []) {
|
|
48
|
+
if (!sameName.domain.includes(d))
|
|
49
|
+
sameName.domain.push(d);
|
|
50
|
+
}
|
|
51
|
+
if (input.description && sameName.description == null) {
|
|
50
52
|
sameName.description = input.description;
|
|
51
53
|
}
|
|
52
54
|
return { action: 'merged', id: sameName.id, reason: 'ok' };
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if (conflicts.length) {
|
|
57
|
+
const id = this.insertNode(input);
|
|
58
|
+
const candidateId = this.pushMergeCandidate(conflicts[0].node.id, id, conflicts[0].reason);
|
|
59
|
+
return { action: 'merge_candidate', id, candidateId, reason: 'fingerprint_conflict' };
|
|
57
60
|
}
|
|
61
|
+
// 无 embedding 注入的近邻候选不在此实现(有向量的近邻路径在 SqliteConceptGraph)
|
|
58
62
|
const id = this.insertNode(input);
|
|
59
63
|
return { action: 'created', id, reason: 'ok' };
|
|
60
64
|
}
|
|
@@ -67,8 +71,8 @@ export class InMemoryConceptGraph {
|
|
|
67
71
|
kind: input.kind,
|
|
68
72
|
description: input.description,
|
|
69
73
|
frequency: 1,
|
|
70
|
-
memoryIds: [...(input.memoryIds ?? [])],
|
|
71
|
-
domain: [...(input.domain ?? [])],
|
|
74
|
+
memoryIds: [...new Set(input.memoryIds ?? [])],
|
|
75
|
+
domain: [...new Set(input.domain ?? [])],
|
|
72
76
|
status: 'shadow',
|
|
73
77
|
embedding: null,
|
|
74
78
|
createdAt: now,
|
|
@@ -76,17 +80,10 @@ export class InMemoryConceptGraph {
|
|
|
76
80
|
});
|
|
77
81
|
return id;
|
|
78
82
|
}
|
|
79
|
-
/**
|
|
83
|
+
/** 义项指纹冲突:仅 kind 不同。domain 是多值标签不参与义项判定(同名同 kind 合并且 domain 取并集) */
|
|
80
84
|
fingerprintConflict(existing, input) {
|
|
81
85
|
if (existing.kind !== input.kind)
|
|
82
86
|
return `kind:${existing.kind}≠${input.kind}`;
|
|
83
|
-
const a = new Set(existing.domain);
|
|
84
|
-
const b = new Set(input.domain ?? []);
|
|
85
|
-
if (a.size > 0 && b.size > 0) {
|
|
86
|
-
const overlap = [...b].some((d) => a.has(d));
|
|
87
|
-
if (!overlap)
|
|
88
|
-
return 'domain_disjoint';
|
|
89
|
-
}
|
|
90
87
|
return null;
|
|
91
88
|
}
|
|
92
89
|
pushMergeCandidate(existingId, newId, reason) {
|
|
@@ -220,25 +217,52 @@ export class InMemoryConceptGraph {
|
|
|
220
217
|
.filter((c) => c.status === 'open')
|
|
221
218
|
.slice(0, limit);
|
|
222
219
|
}
|
|
223
|
-
|
|
220
|
+
/** 无向量能力(InMemory 不注 embedding):语义种子恒空,调用方据 supportsSemanticSeeds 降级纯词面 */
|
|
221
|
+
supportsSemanticSeeds = false;
|
|
222
|
+
/**
|
|
223
|
+
* 与 ConceptGraphStore 契约同签名:query/k 收下但不使用(无向量能力,调用方据 supportsSemanticSeeds 降级)。
|
|
224
|
+
* @returns 恒空数组——InMemory 无向量,语义种子不可用(能力缺失,非数据为空)
|
|
225
|
+
*/
|
|
226
|
+
async semanticSeeds(_query, _k) {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
async resolveMerge(id, action, options) {
|
|
224
230
|
const cand = this.mergeCandidates.get(id);
|
|
225
231
|
if (!cand)
|
|
226
232
|
return;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (action !== 'merge')
|
|
233
|
+
if (action !== 'merge') {
|
|
234
|
+
cand.status = action === 'keep_split' ? 'kept_split' : 'dropped';
|
|
235
|
+
cand.resolvedAt = Date.now();
|
|
236
|
+
cand.resolvedAction = action;
|
|
232
237
|
return;
|
|
238
|
+
}
|
|
233
239
|
const left = this.nodes.get(cand.leftId);
|
|
234
240
|
const right = this.nodes.get(cand.rightId);
|
|
235
|
-
if (!left || !right || left.id === right.id)
|
|
241
|
+
if (!left || !right || left.id === right.id) {
|
|
242
|
+
// 与 Sqlite 同构:端点缺失/悬空记 drop_missing_endpoint,不假记 merged
|
|
243
|
+
cand.status = 'dropped';
|
|
244
|
+
cand.resolvedAt = Date.now();
|
|
245
|
+
cand.resolvedAction = 'drop_missing_endpoint';
|
|
236
246
|
return;
|
|
247
|
+
}
|
|
248
|
+
cand.status = 'merged';
|
|
249
|
+
cand.resolvedAt = Date.now();
|
|
250
|
+
cand.resolvedAction = 'merge';
|
|
237
251
|
left.frequency += right.frequency;
|
|
238
252
|
for (const mid of right.memoryIds) {
|
|
239
253
|
if (!left.memoryIds.includes(mid))
|
|
240
254
|
left.memoryIds.push(mid);
|
|
241
255
|
}
|
|
256
|
+
for (const d of right.domain) {
|
|
257
|
+
if (!left.domain.includes(d))
|
|
258
|
+
left.domain.push(d);
|
|
259
|
+
}
|
|
260
|
+
if (left.description == null && right.description) {
|
|
261
|
+
left.description = right.description;
|
|
262
|
+
}
|
|
263
|
+
if (options?.canonicalKind && left.kind !== options.canonicalKind) {
|
|
264
|
+
left.kind = options.canonicalKind;
|
|
265
|
+
}
|
|
242
266
|
// 迁移边;同 pair 同类型去重,丢自环
|
|
243
267
|
const seen = new Set();
|
|
244
268
|
for (const e of [...this.edges.values()]) {
|
|
@@ -362,15 +386,11 @@ export class InMemoryConceptGraph {
|
|
|
362
386
|
const statuses = new Set(options?.statuses ?? DEFAULT_RETRIEVE_STATUSES);
|
|
363
387
|
const seedIds = [];
|
|
364
388
|
const activation = new Map();
|
|
365
|
-
const
|
|
389
|
+
const seedMatcher = createSeedMatcher(seeds);
|
|
366
390
|
for (const n of this.nodes.values()) {
|
|
367
391
|
if (!statuses.has(n.status))
|
|
368
392
|
continue;
|
|
369
|
-
|
|
370
|
-
const hit = seedSet.has(key) ||
|
|
371
|
-
[...seedSet].some((s) => key.includes(s) || s.includes(key)) ||
|
|
372
|
-
[...seedSet].some((s) => (n.description ?? '').toLowerCase().includes(s));
|
|
373
|
-
if (hit) {
|
|
393
|
+
if (seedMatcher(n.name, n.description)) {
|
|
374
394
|
seedIds.push(n.id);
|
|
375
395
|
activation.set(n.id, 1);
|
|
376
396
|
}
|
|
@@ -17,7 +17,10 @@ export interface ConceptualizerInput {
|
|
|
17
17
|
/** 证据周边语境(±N 消息或 anchor span);缺失时拒绝概念化 */
|
|
18
18
|
contextSlice: string;
|
|
19
19
|
memoryStatus?: MemoryStatus;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* 用于 cue 校验的拼接文本(默认 evidence + contextSlice)。
|
|
22
|
+
* 仅当调用方已把语境切片并入本字段时可替代 contextSlice(evidence 单独不算语境)。
|
|
23
|
+
*/
|
|
21
24
|
evidenceText?: string;
|
|
22
25
|
}
|
|
23
26
|
/** LLM 原始候选(解析前) */
|
|
@@ -56,6 +59,13 @@ export interface ConceptualizerResult {
|
|
|
56
59
|
* @returns 解析结果或 null
|
|
57
60
|
*/
|
|
58
61
|
export declare function parseConceptualizerJson(text: string): RawConceptualizerOutput | null;
|
|
62
|
+
/**
|
|
63
|
+
* 语境充分性判定 — handler 前置检查与 admit 门共用(唯一判定点)。
|
|
64
|
+
*
|
|
65
|
+
* @param input - contextSlice 或调用方预合并的 evidenceText 任一非空即有语境
|
|
66
|
+
* @returns 是否具备概念化所需的证据语境
|
|
67
|
+
*/
|
|
68
|
+
export declare function hasSufficientContext(input: Pick<ConceptualizerInput, 'contextSlice' | 'evidenceText'>): boolean;
|
|
59
69
|
/**
|
|
60
70
|
* 解析 + 门控 + 入库(store 可选时只评估不写)。
|
|
61
71
|
*
|
|
@@ -71,6 +71,15 @@ export function parseConceptualizerJson(text) {
|
|
|
71
71
|
}
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* 语境充分性判定 — handler 前置检查与 admit 门共用(唯一判定点)。
|
|
76
|
+
*
|
|
77
|
+
* @param input - contextSlice 或调用方预合并的 evidenceText 任一非空即有语境
|
|
78
|
+
* @returns 是否具备概念化所需的证据语境
|
|
79
|
+
*/
|
|
80
|
+
export function hasSufficientContext(input) {
|
|
81
|
+
return Boolean(input.contextSlice?.trim() || input.evidenceText?.trim());
|
|
82
|
+
}
|
|
74
83
|
/**
|
|
75
84
|
* 解析 + 门控 + 入库(store 可选时只评估不写)。
|
|
76
85
|
*
|
|
@@ -84,7 +93,7 @@ export async function conceptualizeAndAdmit(raw, input, store) {
|
|
|
84
93
|
if (!parsed) {
|
|
85
94
|
return { nodes: [], edges: [], rejected: [{ name: '*', reason: 'parse_failed' }] };
|
|
86
95
|
}
|
|
87
|
-
if (!
|
|
96
|
+
if (!hasSufficientContext(input)) {
|
|
88
97
|
return {
|
|
89
98
|
nodes: [],
|
|
90
99
|
edges: [],
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextSlice 提取 — session 消息 + evidence 锚定 → 证据周边语境(±N 条消息)
|
|
3
|
+
*
|
|
4
|
+
* 概念化输入包要求 contextSlice(arch/cognition-graph-formation.md D1)。
|
|
5
|
+
* evidence 多为缩略引文(「…」截断、句读改写),整串精确匹配常失败,
|
|
6
|
+
* 因此按省略号/句读拆片段、以最长命中片段定位锚点消息,再截两侧窗口。
|
|
7
|
+
* 找不到锚点返回空串,由调用方显式失败——禁止用无关窗口冒充语境。
|
|
8
|
+
*
|
|
9
|
+
* 锚定域:user / assistant / tool 的文本消息(evidence 可能引用工具输出,
|
|
10
|
+
* 如文件路径与命令结果)。引擎载体插槽经 `isEngineCarrierSource` 单源过滤。
|
|
11
|
+
*
|
|
12
|
+
* @module harness/memory/context-slice
|
|
13
|
+
*/
|
|
14
|
+
/** 缺省窗口:锚点两侧各取的实质消息条数 */
|
|
15
|
+
export declare const DEFAULT_CONTEXT_WINDOW_MESSAGES = 2;
|
|
16
|
+
/** 缺省切片字符预算(软上限;elision 标记会略超,见 {@link extractContextSlice}) */
|
|
17
|
+
export declare const DEFAULT_CONTEXT_SLICE_MAX_CHARS = 4000;
|
|
18
|
+
export interface ContextSliceOptions {
|
|
19
|
+
/** 会话消息序列(SessionData.messages 结构;容忍未知形状) */
|
|
20
|
+
messages: readonly unknown[];
|
|
21
|
+
/** 记忆证据原文(可含缩略) */
|
|
22
|
+
evidence: string;
|
|
23
|
+
/** 锚点两侧各取的实质消息条数;缺省 {@link DEFAULT_CONTEXT_WINDOW_MESSAGES} */
|
|
24
|
+
windowMessages?: number;
|
|
25
|
+
/** 切片字符预算(软上限);缺省 {@link DEFAULT_CONTEXT_SLICE_MAX_CHARS} */
|
|
26
|
+
maxChars?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 从会话消息中提取 evidence 周边语境切片。
|
|
30
|
+
*
|
|
31
|
+
* 定位策略:evidence 拆片段后取「能命中某条实质消息的最长片段」(等长片段取
|
|
32
|
+
* evidence 中先出现者),同一片段取最后一次出现的消息(贴近记忆产生时的活跃
|
|
33
|
+
* 语境),锚点 ±windowMessages 条实质消息。
|
|
34
|
+
*
|
|
35
|
+
* 截断:锚点行优先保留,两侧邻居按余量裁剪并以 elision 标记标注。
|
|
36
|
+
* maxChars 为软上限(标记文本会略超)。锚点行自身超预算时保头尾两段,
|
|
37
|
+
* 行内中段(含命中片段本身)可能被裁。
|
|
38
|
+
*
|
|
39
|
+
* @param options - 消息序列 + evidence + 窗口/预算
|
|
40
|
+
* @returns `[role] text` 行拼接的语境切片;无锚点或无实质消息时返回空串
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractContextSlice(options: ContextSliceOptions): string;
|