@octopi-agent/engine 0.65.0 → 0.86.38
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/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +285 -9
- package/dist/config-schema/engine.js +35 -3
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +87 -1
- package/dist/config-schema/substrate.js +114 -0
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +249 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +48 -4
- package/dist/harness/agent/builder.js +206 -55
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +83 -280
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/gate.js +2 -2
- package/dist/harness/context/capabilities/summary/policies.js +5 -5
- package/dist/harness/context/capabilities/summary/registry.js +39 -24
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-health.js +3 -2
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +32 -15
- package/dist/harness/context/layers.js +87 -71
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +33 -0
- package/dist/harness/context/system-prompt-assembler.js +78 -7
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.js +3 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.d.ts +56 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.js +281 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +98 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +250 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.d.ts +124 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.js +372 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +118 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.js +8 -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/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +278 -82
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +39 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +18 -15
- package/dist/harness/index.js +11 -7
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +8 -8
- package/dist/harness/knowledge/retriever.js +1 -1
- package/dist/harness/knowledge/source-store.d.ts +17 -2
- package/dist/harness/knowledge/source-store.js +6 -5
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/cognition-decay.d.ts +36 -0
- package/dist/harness/memory/cognition-decay.js +55 -0
- package/dist/harness/memory/cognition-gates.d.ts +60 -0
- package/dist/harness/memory/cognition-gates.js +191 -0
- package/dist/harness/memory/cognition-trigger.d.ts +30 -0
- package/dist/harness/memory/cognition-trigger.js +41 -0
- package/dist/harness/memory/cognition-types.d.ts +1 -1
- package/dist/harness/memory/cognition.d.ts +40 -8
- package/dist/harness/memory/cognition.js +432 -79
- package/dist/harness/memory/conceptualizer.d.ts +66 -0
- package/dist/harness/memory/conceptualizer.js +246 -0
- package/dist/harness/memory/index.d.ts +17 -2
- package/dist/harness/memory/index.js +12 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +9 -0
- package/dist/harness/memory/sqlite/agent-db.js +120 -15
- package/dist/harness/memory/sqlite/cognition-store.d.ts +55 -16
- package/dist/harness/memory/sqlite/cognition-store.js +591 -144
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +33 -14
- package/dist/harness/memory/sqlite/wisdom-store.js +257 -44
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +343 -16
- package/dist/harness/memory/types.js +49 -0
- package/dist/harness/memory/wisdom-formation.d.ts +101 -0
- package/dist/harness/memory/wisdom-formation.js +304 -0
- package/dist/harness/memory/wisdom-gates.d.ts +50 -0
- package/dist/harness/memory/wisdom-gates.js +204 -0
- package/dist/harness/memory/wisdom-policy.d.ts +107 -0
- package/dist/harness/memory/wisdom-policy.js +220 -0
- package/dist/harness/memory/wisdom-types.d.ts +3 -2
- package/dist/harness/memory/wisdom-types.js +2 -2
- package/dist/harness/memory/wisdom.d.ts +27 -0
- package/dist/harness/memory/wisdom.js +181 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +27 -0
- package/dist/harness/run/agent/agent.js +45 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +116 -20
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +557 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/index.d.ts +1 -0
- package/dist/harness/session/index.js +1 -0
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.d.ts +86 -0
- package/dist/harness/session/title.js +268 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +21 -0
- package/dist/harness/shared/events/agent-event-map.js +1 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.d.ts +9 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +125 -0
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -0
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +12 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.js +93 -0
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +91 -0
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -0
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -0
- package/dist/subsystems/wisdom-steward/formation/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +212 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -0
- package/dist/subsystems/wisdom-steward/govern/handler.d.ts +17 -0
- package/dist/subsystems/wisdom-steward/govern/handler.js +68 -0
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conceptualizer — 命题 + 证据语境 → 概念/关系假设 → 门控入库
|
|
3
|
+
*
|
|
4
|
+
* 唯一概念化入口。禁止 session 全文 ETL / 正则 extractFromText。
|
|
5
|
+
* LLM 判义项与关系假设;本模块做结构解析与持证执法。
|
|
6
|
+
*
|
|
7
|
+
* @module harness/memory/conceptualizer
|
|
8
|
+
*/
|
|
9
|
+
import { CONCEPT_KINDS, CONCEPT_RELATION_TYPES } from './types.js';
|
|
10
|
+
import { evaluateConceptGate, licenseEdge, } from './cognition-gates.js';
|
|
11
|
+
const MAX_NODES = 6;
|
|
12
|
+
const MAX_EDGES = 12;
|
|
13
|
+
function asString(v) {
|
|
14
|
+
return typeof v === 'string' ? v.trim() : '';
|
|
15
|
+
}
|
|
16
|
+
function parseKind(v) {
|
|
17
|
+
const s = asString(v);
|
|
18
|
+
return CONCEPT_KINDS.includes(s) ? s : null;
|
|
19
|
+
}
|
|
20
|
+
function parseRelation(v) {
|
|
21
|
+
const s = asString(v);
|
|
22
|
+
return CONCEPT_RELATION_TYPES.includes(s) ? s : null;
|
|
23
|
+
}
|
|
24
|
+
function parseEvidenceClass(v) {
|
|
25
|
+
const s = asString(v);
|
|
26
|
+
const allowed = ['causal', 'mereonymy', 'negation', 'analogy', 'evolution', 'cooccur'];
|
|
27
|
+
return allowed.includes(s) ? s : null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 从 LLM 文本中提取 JSON 对象(`{nodes,edges}`)。
|
|
31
|
+
*
|
|
32
|
+
* @param text - LLM 输出
|
|
33
|
+
* @returns 解析结果或 null
|
|
34
|
+
*/
|
|
35
|
+
export function parseConceptualizerJson(text) {
|
|
36
|
+
const start = text.indexOf('{');
|
|
37
|
+
if (start === -1)
|
|
38
|
+
return null;
|
|
39
|
+
let depth = 0;
|
|
40
|
+
let inString = false;
|
|
41
|
+
let escape = false;
|
|
42
|
+
for (let i = start; i < text.length; i++) {
|
|
43
|
+
const ch = text[i];
|
|
44
|
+
if (escape) {
|
|
45
|
+
escape = false;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (ch === '\\') {
|
|
49
|
+
escape = true;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === '"') {
|
|
53
|
+
inString = !inString;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (inString)
|
|
57
|
+
continue;
|
|
58
|
+
if (ch === '{')
|
|
59
|
+
depth++;
|
|
60
|
+
else if (ch === '}') {
|
|
61
|
+
depth--;
|
|
62
|
+
if (depth === 0) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(text.slice(start, i + 1));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 解析 + 门控 + 入库(store 可选时只评估不写)。
|
|
76
|
+
*
|
|
77
|
+
* @param raw - LLM 结构化输出或原文
|
|
78
|
+
* @param input - 输入包(须含 contextSlice)
|
|
79
|
+
* @param store - ConceptGraphStore;省略则只跑门控
|
|
80
|
+
*/
|
|
81
|
+
export async function conceptualizeAndAdmit(raw, input, store) {
|
|
82
|
+
const parsed = typeof raw === 'string' ? parseConceptualizerJson(raw) : raw;
|
|
83
|
+
const rejected = [];
|
|
84
|
+
if (!parsed) {
|
|
85
|
+
return { nodes: [], edges: [], rejected: [{ name: '*', reason: 'parse_failed' }] };
|
|
86
|
+
}
|
|
87
|
+
if (!input.contextSlice?.trim() && !input.evidenceText?.trim()) {
|
|
88
|
+
return {
|
|
89
|
+
nodes: [],
|
|
90
|
+
edges: [],
|
|
91
|
+
rejected: [{ name: '*', reason: 'no_context_slice' }],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const evidenceText = input.evidenceText ?? `${input.evidence}\n${input.contextSlice}`;
|
|
95
|
+
const supportBase = 1;
|
|
96
|
+
// 预载既有概念名 → id(跨命题连边)
|
|
97
|
+
const nameToId = new Map();
|
|
98
|
+
if (store) {
|
|
99
|
+
try {
|
|
100
|
+
const full = await store.getFullGraph();
|
|
101
|
+
for (const n of full.nodes) {
|
|
102
|
+
const key = n.name.trim().toLowerCase();
|
|
103
|
+
if (!nameToId.has(key))
|
|
104
|
+
nameToId.set(key, n.id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// 读图失败时仅能连本批节点
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// ── nodes ──
|
|
112
|
+
const rawNodes = Array.isArray(parsed.nodes) ? parsed.nodes : [];
|
|
113
|
+
const nodes = [];
|
|
114
|
+
for (const item of rawNodes.slice(0, MAX_NODES * 2)) {
|
|
115
|
+
if (nodes.length >= MAX_NODES)
|
|
116
|
+
break;
|
|
117
|
+
if (!item || typeof item !== 'object')
|
|
118
|
+
continue;
|
|
119
|
+
const o = item;
|
|
120
|
+
const name = asString(o.name);
|
|
121
|
+
const rawKind = asString(o.kind);
|
|
122
|
+
const kind = parseKind(o.kind);
|
|
123
|
+
if (rawKind && !kind) {
|
|
124
|
+
rejected.push({ name, reason: 'kind_invalid' });
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const resolvedKind = kind ?? 'construct';
|
|
128
|
+
const description = asString(o.description) || undefined;
|
|
129
|
+
const domain = Array.isArray(o.domain)
|
|
130
|
+
? o.domain.filter((d) => typeof d === 'string').map((d) => d.trim()).filter(Boolean)
|
|
131
|
+
: [];
|
|
132
|
+
const gate = evaluateConceptGate({
|
|
133
|
+
name,
|
|
134
|
+
kind: resolvedKind,
|
|
135
|
+
description,
|
|
136
|
+
domain,
|
|
137
|
+
memoryIds: [input.memoryId],
|
|
138
|
+
supportCount: supportBase,
|
|
139
|
+
});
|
|
140
|
+
if (!gate.ok) {
|
|
141
|
+
rejected.push({ name, reason: gate.reason });
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
let admit = {
|
|
145
|
+
action: 'rejected',
|
|
146
|
+
reason: gate.reason,
|
|
147
|
+
message: 'store not provided',
|
|
148
|
+
};
|
|
149
|
+
if (store) {
|
|
150
|
+
admit = await store.admitConcept({
|
|
151
|
+
name,
|
|
152
|
+
kind: resolvedKind,
|
|
153
|
+
description,
|
|
154
|
+
domain,
|
|
155
|
+
memoryIds: [input.memoryId],
|
|
156
|
+
supportCount: supportBase,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
admit = { action: 'created', reason: 'ok' };
|
|
161
|
+
}
|
|
162
|
+
if (admit.id)
|
|
163
|
+
nameToId.set(name.toLowerCase(), admit.id);
|
|
164
|
+
nodes.push({
|
|
165
|
+
name,
|
|
166
|
+
kind: resolvedKind,
|
|
167
|
+
description,
|
|
168
|
+
domain,
|
|
169
|
+
supportCount: supportBase,
|
|
170
|
+
admit,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// ── edges ──
|
|
174
|
+
const rawEdges = Array.isArray(parsed.edges) ? parsed.edges : [];
|
|
175
|
+
const edges = [];
|
|
176
|
+
for (const item of rawEdges.slice(0, MAX_EDGES * 2)) {
|
|
177
|
+
if (edges.length >= MAX_EDGES)
|
|
178
|
+
break;
|
|
179
|
+
if (!item || typeof item !== 'object')
|
|
180
|
+
continue;
|
|
181
|
+
const o = item;
|
|
182
|
+
const fromName = asString(o.fromName ?? o.from ?? o.source);
|
|
183
|
+
const toName = asString(o.toName ?? o.to ?? o.target);
|
|
184
|
+
const requestedType = parseRelation(o.relationType ?? o.relation) ?? 'related';
|
|
185
|
+
const evidenceClass = parseEvidenceClass(o.evidenceClass) ?? 'cooccur';
|
|
186
|
+
const cue = asString(o.cue);
|
|
187
|
+
const license = licenseEdge({
|
|
188
|
+
relationType: requestedType,
|
|
189
|
+
evidenceClass,
|
|
190
|
+
cue,
|
|
191
|
+
evidenceText,
|
|
192
|
+
memoryIds: [input.memoryId],
|
|
193
|
+
memoryStatuses: input.memoryStatus ? [input.memoryStatus] : [],
|
|
194
|
+
});
|
|
195
|
+
const edgeOut = {
|
|
196
|
+
fromName,
|
|
197
|
+
toName,
|
|
198
|
+
requestedType,
|
|
199
|
+
license,
|
|
200
|
+
};
|
|
201
|
+
if (store && license.status !== 'rejected') {
|
|
202
|
+
const sourceId = nameToId.get(fromName.toLowerCase());
|
|
203
|
+
const targetId = nameToId.get(toName.toLowerCase());
|
|
204
|
+
if (!sourceId || !targetId) {
|
|
205
|
+
edgeOut.license = {
|
|
206
|
+
...license,
|
|
207
|
+
status: 'rejected',
|
|
208
|
+
reason: 'cue_mismatch',
|
|
209
|
+
message: 'endpoint concept not admitted',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (license.status === 'candidate_only') {
|
|
213
|
+
await store.addCausalCandidate({
|
|
214
|
+
sourceId,
|
|
215
|
+
targetId,
|
|
216
|
+
memoryIds: [input.memoryId],
|
|
217
|
+
cue,
|
|
218
|
+
note: license.message,
|
|
219
|
+
});
|
|
220
|
+
edgeOut.admit = {
|
|
221
|
+
action: 'candidate_only',
|
|
222
|
+
reason: license.reason,
|
|
223
|
+
message: license.message,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const admit = await store.admitEdge({
|
|
228
|
+
sourceId,
|
|
229
|
+
targetId,
|
|
230
|
+
relationType: license.relationType,
|
|
231
|
+
strength: license.status === 'active' ? 0.7 : 0.4,
|
|
232
|
+
basis: {
|
|
233
|
+
memoryIds: [input.memoryId],
|
|
234
|
+
cue,
|
|
235
|
+
evidenceClass,
|
|
236
|
+
licensedAt: Date.now(),
|
|
237
|
+
},
|
|
238
|
+
evidenceText,
|
|
239
|
+
});
|
|
240
|
+
edgeOut.admit = admit;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
edges.push(edgeOut);
|
|
244
|
+
}
|
|
245
|
+
return { nodes, edges, rejected };
|
|
246
|
+
}
|
|
@@ -4,9 +4,23 @@
|
|
|
4
4
|
* 价值模型:fact / method / norm(见 docs/memory.md、arch/memory-system-redesign.md)。
|
|
5
5
|
* system prompt ContextLayer 契约在 harness/context/。
|
|
6
6
|
*/
|
|
7
|
-
export type { MemoryType, MemoryChannel, MemoryStatus, SoftDeleteReason, MemoryEntry, MemoryQuery, MemoryStats, MemoryStore, MemoryWriteSlot, WisdomEntry, WisdomStore, ConceptNode, ConceptEdge, ConceptGraph, ConceptGraphStore, } from './types.js';
|
|
8
|
-
export { MEMORY_TYPES } from './types.js';
|
|
7
|
+
export type { MemoryType, MemoryChannel, MemoryStatus, SoftDeleteReason, MemoryEntry, MemoryQuery, MemoryStats, MemoryStore, MemoryWriteSlot, WisdomStatus, WisdomOrigin, WisdomKind, WisdomRetireReason, WisdomScenario, WisdomEffect, WisdomDerivation, WisdomCounterevidence, WisdomOutcomes, WisdomEntry, WisdomGateReason, WisdomGateOutcome, AdmitWisdomInput, AdmitWisdomAction, AdmitWisdomResult, WisdomInjectQuery, WisdomInjectPick, WisdomOutcomeSignal, WisdomOutcomeEvent, WisdomStats, WisdomStore, ConceptKind, ConceptRelationType, ConceptStatus, EvidenceClass, EdgeBasis, ConceptNode, ConceptEdge, ConceptGraph, MergeCandidate, EdgeAux, AdmitConceptInput, AdmitConceptResult, AdmitEdgeInput, AdmitEdgeResult, ConceptGateReason, SpreadingActivateOptions, ActivatedGraph, ConceptGraphStats, DecayResult, ConceptGraphStore, } from './types.js';
|
|
8
|
+
export { MEMORY_TYPES, WISDOM_STATUSES, WISDOM_INJECTABLE_STATUSES, WISDOM_ORIGINS, WISDOM_KINDS, CONCEPT_KINDS, CONCEPT_RELATION_TYPES, STRONG_RELATION_TYPES, } from './types.js';
|
|
9
|
+
export { evaluateWisdomGate, resolveInitialWisdomStatus, normalizeStatement, looksOpposed, WISDOM_DEFAULT_MIN_SUPPORT, } from './wisdom-gates.js';
|
|
10
|
+
export { DEFAULT_WISDOM_EVALUATION, DEFAULT_WISDOM_GOVERN, foldOutcomeEvents, planConfidenceUpdate, planWisdomGovern, wisdomUtility, wisdomInjectScore, } from './wisdom-policy.js';
|
|
11
|
+
export type { WisdomEvaluationConfig, WisdomGovernConfig, WisdomConfidenceUpdate, WisdomGoverPlanItem, } from './wisdom-policy.js';
|
|
12
|
+
export { parseWisdomFormationJson, normalizeWisdomFormation, toAdmitWisdomInput, formAndAdmit, scenarioMatchScore, pickForInjection, formatWisdomBody, } from './wisdom-formation.js';
|
|
13
|
+
export type { RawWisdomFormationOutput, ParsedWisdomItem, ParsedWisdomFormation, } from './wisdom-formation.js';
|
|
14
|
+
export { evaluateConceptGate, licenseEdge, edgeBasisFromLicense, normalizeForCue, } from './cognition-gates.js';
|
|
15
|
+
export type { ConceptGateOutcome, EdgeLicenseInput, EdgeLicenseOutcome, } from './cognition-gates.js';
|
|
16
|
+
export { DEFAULT_EDGE_DECAY_PER_DAY, DEFAULT_EDGE_DECAY_FLOOR, DEFAULT_RETRIEVE_STATUSES, decayMultiplier, nextEdgeStrength, hebbianStrengthen, counterEvidenceWeaken, } from './cognition-decay.js';
|
|
17
|
+
export type { EdgeDecayConfig } from './cognition-decay.js';
|
|
18
|
+
export { conceptualizeAndAdmit, parseConceptualizerJson, } from './conceptualizer.js';
|
|
19
|
+
export type { ConceptualizerInput, ConceptualizerResult, ConceptualizerNodeOut, ConceptualizerEdgeOut, RawConceptualizerOutput, } from './conceptualizer.js';
|
|
20
|
+
export { COGNITIZE_REQUEST_EVENT, emitConceptualizeRequest, } from './cognition-trigger.js';
|
|
21
|
+
export type { ConceptualizeRequestPayload } from './cognition-trigger.js';
|
|
9
22
|
export { InMemoryMemoryStore } from './store.js';
|
|
23
|
+
export { InMemoryWisdomStore } from './wisdom.js';
|
|
10
24
|
export { InMemoryConceptGraph } from './cognition.js';
|
|
11
25
|
export { AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider, SqliteBackfillCoverageStore } from './sqlite/index.js';
|
|
12
26
|
export type { AgentDatabaseOptions, SqliteMemoryStoreOptions, SqliteConceptGraphOptions, EmbeddingProvider, EmbeddingConfig } from './sqlite/index.js';
|
|
@@ -29,5 +43,6 @@ export { provisionalConfidence, injectFilter, searchFilter, profileToConfidenceC
|
|
|
29
43
|
export type { ChannelPriors, ConfidenceProfileConfig, MemoryProfileName, ProvisionalInput, ProvisionalResult } from './confidence.js';
|
|
30
44
|
export { evaluateGates, mapLegacyType } from './gates.js';
|
|
31
45
|
export type { GateCandidate, GateConfig, GateOutcome, GateRejectReason } from './gates.js';
|
|
46
|
+
export { formatMemoryClock, formatMemoryTimeSuffix, parseAsOf } from './time-format.js';
|
|
32
47
|
export { admitCandidates, applySoftDeletes, planSoftDeletes, applyBoosts, planBoosts, planPromotionCandidates, resolvePolicy, DEFAULT_SOFT_DELETE_POLICY, MAX_ENTRIES_PER_SOURCE, } from './steward-policy.js';
|
|
33
48
|
export type { SoftDeletePolicyConfig, StewardCandidate, GovernPlanItem, BoostPlanItem, AdmitResult, } from './steward-policy.js';
|
|
@@ -4,9 +4,19 @@
|
|
|
4
4
|
* 价值模型:fact / method / norm(见 docs/memory.md、arch/memory-system-redesign.md)。
|
|
5
5
|
* system prompt ContextLayer 契约在 harness/context/。
|
|
6
6
|
*/
|
|
7
|
-
export { MEMORY_TYPES } from './types.js';
|
|
7
|
+
export { MEMORY_TYPES, WISDOM_STATUSES, WISDOM_INJECTABLE_STATUSES, WISDOM_ORIGINS, WISDOM_KINDS, CONCEPT_KINDS, CONCEPT_RELATION_TYPES, STRONG_RELATION_TYPES, } from './types.js';
|
|
8
|
+
// ── Wisdom 门控 / 策略 / 形成 ──
|
|
9
|
+
export { evaluateWisdomGate, resolveInitialWisdomStatus, normalizeStatement, looksOpposed, WISDOM_DEFAULT_MIN_SUPPORT, } from './wisdom-gates.js';
|
|
10
|
+
export { DEFAULT_WISDOM_EVALUATION, DEFAULT_WISDOM_GOVERN, foldOutcomeEvents, planConfidenceUpdate, planWisdomGovern, wisdomUtility, wisdomInjectScore, } from './wisdom-policy.js';
|
|
11
|
+
export { parseWisdomFormationJson, normalizeWisdomFormation, toAdmitWisdomInput, formAndAdmit, scenarioMatchScore, pickForInjection, formatWisdomBody, } from './wisdom-formation.js';
|
|
12
|
+
// ── Cognition 门控 / 可塑 / 概念化 ──
|
|
13
|
+
export { evaluateConceptGate, licenseEdge, edgeBasisFromLicense, normalizeForCue, } from './cognition-gates.js';
|
|
14
|
+
export { DEFAULT_EDGE_DECAY_PER_DAY, DEFAULT_EDGE_DECAY_FLOOR, DEFAULT_RETRIEVE_STATUSES, decayMultiplier, nextEdgeStrength, hebbianStrengthen, counterEvidenceWeaken, } from './cognition-decay.js';
|
|
15
|
+
export { conceptualizeAndAdmit, parseConceptualizerJson, } from './conceptualizer.js';
|
|
16
|
+
export { COGNITIZE_REQUEST_EVENT, emitConceptualizeRequest, } from './cognition-trigger.js';
|
|
8
17
|
// ── 内存实现 ──
|
|
9
18
|
export { InMemoryMemoryStore } from './store.js';
|
|
19
|
+
export { InMemoryWisdomStore } from './wisdom.js';
|
|
10
20
|
export { InMemoryConceptGraph } from './cognition.js';
|
|
11
21
|
// ── SQLite 实现 ──
|
|
12
22
|
export { AgentDatabase, SqliteMemoryStore, SqliteWisdomStore, SqliteConceptGraph, createEmbeddingProvider, SqliteBackfillCoverageStore } from './sqlite/index.js';
|
|
@@ -24,5 +34,6 @@ export { BackfillTrigger, BACKFILL_REQUEST_EVENT } from './backfill-trigger.js';
|
|
|
24
34
|
// ── 置信度与门控 ──
|
|
25
35
|
export { provisionalConfidence, injectFilter, searchFilter, profileToConfidenceConfig, hasQuoteEvidence, DEFAULT_CHANNEL_PRIORS, } from './confidence.js';
|
|
26
36
|
export { evaluateGates, mapLegacyType } from './gates.js';
|
|
37
|
+
export { formatMemoryClock, formatMemoryTimeSuffix, parseAsOf } from './time-format.js';
|
|
27
38
|
// ── Steward 共享策略(subsystem 从 @octopi-agent/engine 引用) ──
|
|
28
39
|
export { admitCandidates, applySoftDeletes, planSoftDeletes, applyBoosts, planBoosts, planPromotionCandidates, resolvePolicy, DEFAULT_SOFT_DELETE_POLICY, MAX_ENTRIES_PER_SOURCE, } from './steward-policy.js';
|
|
@@ -41,6 +41,15 @@ export declare class AgentDatabase {
|
|
|
41
41
|
get vectorDimensions(): number | null;
|
|
42
42
|
/** 旧库升级:补齐 memories 治理列 + 旧类型映射(必须在依赖新列的 INDEX 之前) */
|
|
43
43
|
private migrateMemoryColumns;
|
|
44
|
+
/**
|
|
45
|
+
* Cognition 表结构一次性重建(概念图未投入生产;发现旧列即 DROP 重建)。
|
|
46
|
+
* 禁止对旧 `concepts(name)` UNIQUE 语义做兼容——义项允许多节点同名。
|
|
47
|
+
*/
|
|
48
|
+
private migrateConceptTables;
|
|
49
|
+
/**
|
|
50
|
+
* Wisdom 一次性重建:旧 content 形态无兼容价值,发现即 DROP(maxim 表随后 CREATE)。
|
|
51
|
+
*/
|
|
52
|
+
private migrateWisdomTable;
|
|
44
53
|
/**
|
|
45
54
|
* 创建所有表结构
|
|
46
55
|
*
|
|
@@ -83,6 +83,7 @@ export class AgentDatabase {
|
|
|
83
83
|
["anchors", "TEXT NOT NULL DEFAULT '[]'"],
|
|
84
84
|
['evidence', 'TEXT'],
|
|
85
85
|
['reinforced_at', 'INTEGER'],
|
|
86
|
+
['as_of', 'INTEGER'],
|
|
86
87
|
['deleted', 'INTEGER NOT NULL DEFAULT 0'],
|
|
87
88
|
['deleted_at', 'INTEGER'],
|
|
88
89
|
['deleted_by', 'TEXT'],
|
|
@@ -111,6 +112,60 @@ export class AgentDatabase {
|
|
|
111
112
|
WHERE type IN ('preference','decision','lesson','discovery','context','relationship')
|
|
112
113
|
`);
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Cognition 表结构一次性重建(概念图未投入生产;发现旧列即 DROP 重建)。
|
|
117
|
+
* 禁止对旧 `concepts(name)` UNIQUE 语义做兼容——义项允许多节点同名。
|
|
118
|
+
*/
|
|
119
|
+
migrateConceptTables() {
|
|
120
|
+
let needsRebuild = false;
|
|
121
|
+
try {
|
|
122
|
+
const cols = this.db.prepare('PRAGMA table_info(concepts)').all();
|
|
123
|
+
const names = new Set(cols.map((c) => c.name));
|
|
124
|
+
if (cols.length > 0 && (!names.has('kind') || !names.has('status') || !names.has('domain'))) {
|
|
125
|
+
needsRebuild = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// table missing — CREATE IF NOT EXISTS will handle
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const edgeCols = this.db.prepare('PRAGMA table_info(concept_edges)').all();
|
|
133
|
+
const edgeNames = new Set(edgeCols.map((c) => c.name));
|
|
134
|
+
if (edgeCols.length > 0 && (!edgeNames.has('status') || !edgeNames.has('basis'))) {
|
|
135
|
+
needsRebuild = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// ignore
|
|
140
|
+
}
|
|
141
|
+
if (!needsRebuild)
|
|
142
|
+
return;
|
|
143
|
+
this.db.exec(`
|
|
144
|
+
DROP TABLE IF EXISTS concept_edges_aux;
|
|
145
|
+
DROP TABLE IF EXISTS concept_merge_candidates;
|
|
146
|
+
DROP TABLE IF EXISTS concept_edges;
|
|
147
|
+
DROP TABLE IF EXISTS concepts;
|
|
148
|
+
`);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Wisdom 一次性重建:旧 content 形态无兼容价值,发现即 DROP(maxim 表随后 CREATE)。
|
|
152
|
+
*/
|
|
153
|
+
migrateWisdomTable() {
|
|
154
|
+
let needsRebuild = false;
|
|
155
|
+
try {
|
|
156
|
+
const cols = this.db.prepare('PRAGMA table_info(wisdom)').all();
|
|
157
|
+
const names = new Set(cols.map((c) => c.name));
|
|
158
|
+
if (cols.length > 0 && (!names.has('statement') || names.has('content') || names.has('derived_from'))) {
|
|
159
|
+
needsRebuild = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// table missing — CREATE IF NOT EXISTS will handle
|
|
164
|
+
}
|
|
165
|
+
if (!needsRebuild)
|
|
166
|
+
return;
|
|
167
|
+
this.db.exec(`DROP TABLE IF EXISTS wisdom`);
|
|
168
|
+
}
|
|
114
169
|
/**
|
|
115
170
|
* 创建所有表结构
|
|
116
171
|
*
|
|
@@ -139,6 +194,7 @@ export class AgentDatabase {
|
|
|
139
194
|
anchors TEXT NOT NULL DEFAULT '[]',
|
|
140
195
|
evidence TEXT,
|
|
141
196
|
reinforced_at INTEGER,
|
|
197
|
+
as_of INTEGER,
|
|
142
198
|
deleted INTEGER NOT NULL DEFAULT 0,
|
|
143
199
|
deleted_at INTEGER,
|
|
144
200
|
deleted_by TEXT,
|
|
@@ -148,6 +204,8 @@ export class AgentDatabase {
|
|
|
148
204
|
`);
|
|
149
205
|
// 旧库可能仍是无 deleted/status 的 schema —— 先补列再建索引
|
|
150
206
|
this.migrateMemoryColumns();
|
|
207
|
+
this.migrateConceptTables();
|
|
208
|
+
this.migrateWisdomTable();
|
|
151
209
|
this.db.exec(`
|
|
152
210
|
CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);
|
|
153
211
|
CREATE INDEX IF NOT EXISTS idx_memories_confidence ON memories(confidence);
|
|
@@ -155,50 +213,89 @@ export class AgentDatabase {
|
|
|
155
213
|
CREATE INDEX IF NOT EXISTS idx_memories_created ON memories(created_at);
|
|
156
214
|
CREATE INDEX IF NOT EXISTS idx_memories_deleted ON memories(deleted);
|
|
157
215
|
|
|
158
|
-
-- ── Concept
|
|
216
|
+
-- ── Concept 表(cognition-graph-formation;义项可同名多节点)──
|
|
159
217
|
CREATE TABLE IF NOT EXISTS concepts (
|
|
160
218
|
id TEXT PRIMARY KEY,
|
|
161
219
|
name TEXT NOT NULL,
|
|
220
|
+
kind TEXT NOT NULL DEFAULT 'construct',
|
|
162
221
|
description TEXT,
|
|
163
222
|
frequency INTEGER NOT NULL DEFAULT 1,
|
|
164
223
|
memory_ids TEXT NOT NULL DEFAULT '[]',
|
|
165
|
-
|
|
224
|
+
domain TEXT NOT NULL DEFAULT '[]',
|
|
225
|
+
status TEXT NOT NULL DEFAULT 'shadow',
|
|
166
226
|
embedding TEXT,
|
|
167
227
|
created_at INTEGER NOT NULL,
|
|
168
228
|
updated_at INTEGER NOT NULL
|
|
169
229
|
);
|
|
170
230
|
|
|
171
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_concepts_name ON concepts(name);
|
|
172
|
-
|
|
173
|
-
-- ── Concept Edge 表 ──
|
|
174
231
|
CREATE TABLE IF NOT EXISTS concept_edges (
|
|
175
232
|
id TEXT PRIMARY KEY,
|
|
176
|
-
source_id TEXT NOT NULL
|
|
177
|
-
target_id TEXT NOT NULL
|
|
233
|
+
source_id TEXT NOT NULL,
|
|
234
|
+
target_id TEXT NOT NULL,
|
|
178
235
|
relation_type TEXT NOT NULL,
|
|
179
236
|
strength REAL NOT NULL DEFAULT 0.5,
|
|
180
237
|
description TEXT,
|
|
181
|
-
|
|
238
|
+
status TEXT NOT NULL DEFAULT 'shadow',
|
|
239
|
+
basis TEXT NOT NULL DEFAULT '{}',
|
|
182
240
|
created_at INTEGER NOT NULL,
|
|
241
|
+
updated_at INTEGER NOT NULL,
|
|
183
242
|
UNIQUE(source_id, target_id, relation_type)
|
|
184
243
|
);
|
|
185
244
|
|
|
245
|
+
CREATE TABLE IF NOT EXISTS concept_merge_candidates (
|
|
246
|
+
id TEXT PRIMARY KEY,
|
|
247
|
+
left_id TEXT NOT NULL,
|
|
248
|
+
right_id TEXT NOT NULL,
|
|
249
|
+
reason TEXT NOT NULL,
|
|
250
|
+
distance REAL,
|
|
251
|
+
fingerprint_diff TEXT NOT NULL DEFAULT '[]',
|
|
252
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
253
|
+
created_at INTEGER NOT NULL,
|
|
254
|
+
resolved_at INTEGER,
|
|
255
|
+
resolved_action TEXT
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
CREATE TABLE IF NOT EXISTS concept_edges_aux (
|
|
259
|
+
id TEXT PRIMARY KEY,
|
|
260
|
+
edge_key TEXT NOT NULL,
|
|
261
|
+
kind TEXT NOT NULL,
|
|
262
|
+
memory_ids TEXT NOT NULL DEFAULT '[]',
|
|
263
|
+
cue TEXT NOT NULL DEFAULT '',
|
|
264
|
+
note TEXT,
|
|
265
|
+
created_at INTEGER NOT NULL
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
CREATE INDEX IF NOT EXISTS idx_concepts_name ON concepts(name);
|
|
269
|
+
CREATE INDEX IF NOT EXISTS idx_concepts_status ON concepts(status);
|
|
270
|
+
CREATE INDEX IF NOT EXISTS idx_concepts_kind ON concepts(kind);
|
|
186
271
|
CREATE INDEX IF NOT EXISTS idx_edges_source ON concept_edges(source_id);
|
|
187
272
|
CREATE INDEX IF NOT EXISTS idx_edges_target ON concept_edges(target_id);
|
|
188
273
|
CREATE INDEX IF NOT EXISTS idx_edges_type ON concept_edges(relation_type);
|
|
274
|
+
CREATE INDEX IF NOT EXISTS idx_edges_status ON concept_edges(status);
|
|
275
|
+
CREATE INDEX IF NOT EXISTS idx_merge_candidates_status ON concept_merge_candidates(status);
|
|
189
276
|
|
|
190
|
-
-- ── Wisdom
|
|
277
|
+
-- ── Wisdom 表(maxim)──旧 content 形态在 migrateWisdomSchema 一次性拆除
|
|
191
278
|
CREATE TABLE IF NOT EXISTS wisdom (
|
|
192
279
|
id TEXT PRIMARY KEY,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
280
|
+
statement TEXT NOT NULL,
|
|
281
|
+
rationale TEXT,
|
|
282
|
+
scenario_json TEXT NOT NULL DEFAULT '{"problemTypes":[]}',
|
|
283
|
+
effect_json TEXT NOT NULL DEFAULT '{}',
|
|
284
|
+
status TEXT NOT NULL DEFAULT 'trial',
|
|
196
285
|
confidence REAL NOT NULL DEFAULT 0.5,
|
|
197
|
-
|
|
198
|
-
|
|
286
|
+
priority INTEGER NOT NULL DEFAULT 30,
|
|
287
|
+
derived_from_json TEXT NOT NULL DEFAULT '{"memoryIds":[]}',
|
|
288
|
+
exceptions_json TEXT NOT NULL DEFAULT '[]',
|
|
289
|
+
counterevidence_json TEXT NOT NULL DEFAULT '[]',
|
|
290
|
+
outcomes_json TEXT NOT NULL DEFAULT '{"applied":0,"cited":0,"assisted":0,"contested":0}',
|
|
291
|
+
origin TEXT NOT NULL DEFAULT 'distilled',
|
|
292
|
+
kind TEXT NOT NULL DEFAULT 'generalize',
|
|
293
|
+
superseded_by TEXT,
|
|
199
294
|
created_at INTEGER NOT NULL,
|
|
200
295
|
updated_at INTEGER NOT NULL
|
|
201
296
|
);
|
|
297
|
+
CREATE INDEX IF NOT EXISTS idx_wisdom_status ON wisdom(status);
|
|
298
|
+
CREATE INDEX IF NOT EXISTS idx_wisdom_priority ON wisdom(priority);
|
|
202
299
|
|
|
203
300
|
-- ── Knowledge Sources 注册表 ──
|
|
204
301
|
CREATE TABLE IF NOT EXISTS knowledge_sources (
|
|
@@ -261,7 +358,15 @@ export class AgentDatabase {
|
|
|
261
358
|
* 统计信息
|
|
262
359
|
*/
|
|
263
360
|
stats() {
|
|
264
|
-
const tables = [
|
|
361
|
+
const tables = [
|
|
362
|
+
'memories',
|
|
363
|
+
'concepts',
|
|
364
|
+
'concept_edges',
|
|
365
|
+
'concept_merge_candidates',
|
|
366
|
+
'concept_edges_aux',
|
|
367
|
+
'wisdom',
|
|
368
|
+
'knowledge_sources',
|
|
369
|
+
];
|
|
265
370
|
const result = {};
|
|
266
371
|
for (const table of tables) {
|
|
267
372
|
try {
|
|
@@ -1,34 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SqliteConceptGraph — SQLite
|
|
2
|
+
* SqliteConceptGraph — SQLite 认知图谱(生产路径)
|
|
3
|
+
*
|
|
4
|
+
* 契约见 arch/cognition-graph-formation.md:
|
|
5
|
+
* 结构同一性合并、持证边、衰减、扩散激活、merge_candidates、causal_candidate。
|
|
3
6
|
*
|
|
4
7
|
* @module
|
|
5
8
|
*/
|
|
6
|
-
import type {
|
|
9
|
+
import type { ActivatedGraph, AdmitConceptInput, AdmitConceptResult, AdmitEdgeInput, AdmitEdgeResult, ConceptGraph, ConceptGraphStats, ConceptGraphStore, DecayResult, MergeCandidate, SpreadingActivateOptions } from '../cognition-types.js';
|
|
7
10
|
import { AgentDatabase } from './agent-db.js';
|
|
8
11
|
import type { EmbeddingProvider } from './embedding.js';
|
|
9
12
|
export interface SqliteConceptGraphOptions {
|
|
10
13
|
embeddingProvider?: EmbeddingProvider | null;
|
|
11
|
-
/**
|
|
14
|
+
/** embedding 自动合并距离上限(仅指纹兼容时);默认 0.20 */
|
|
12
15
|
mergeThreshold?: number;
|
|
16
|
+
/** 近阈带上界;[lo, hi) 写 merge_candidates,默认 0.35 */
|
|
17
|
+
candidateBandHi?: number;
|
|
18
|
+
/** capacity 软顶 */
|
|
19
|
+
warnNodes?: number;
|
|
20
|
+
warnEdges?: number;
|
|
21
|
+
stopNodes?: number;
|
|
22
|
+
stopEdges?: number;
|
|
23
|
+
decayFloor?: number;
|
|
24
|
+
/** causes 最少独立命题(默认 2) */
|
|
25
|
+
causesMinIndependentMemories?: number;
|
|
13
26
|
}
|
|
14
27
|
export declare class SqliteConceptGraph implements ConceptGraphStore {
|
|
15
28
|
private db;
|
|
16
29
|
private embedding;
|
|
17
30
|
private mergeThreshold;
|
|
31
|
+
private candidateBandHi;
|
|
32
|
+
private stopNodes;
|
|
33
|
+
private stopEdges;
|
|
34
|
+
private decayFloor;
|
|
35
|
+
private causesMinIndependentMemories;
|
|
18
36
|
constructor(db: AgentDatabase, options?: SqliteConceptGraphOptions);
|
|
19
|
-
|
|
20
|
-
addEdge(edge: ConceptEdge): Promise<void>;
|
|
21
|
-
queryRelated(conceptName: string, depth?: number): Promise<ConceptGraph>;
|
|
22
|
-
extractFromText(text: string, memoryId: string): Promise<void>;
|
|
23
|
-
getFullGraph(): Promise<ConceptGraph>;
|
|
24
|
-
/**
|
|
25
|
-
* 查找语义相似的概念(用于去重)
|
|
26
|
-
*/
|
|
27
|
-
private findSimilarConcept;
|
|
28
|
-
/**
|
|
29
|
-
* 关联记忆到概念(从外部调用)
|
|
30
|
-
*/
|
|
31
|
-
linkMemory(conceptId: string, memoryId: string): void;
|
|
37
|
+
private get capacityStop();
|
|
32
38
|
private rowToNode;
|
|
33
39
|
private rowToEdge;
|
|
40
|
+
admitConcept(input: AdmitConceptInput): Promise<AdmitConceptResult>;
|
|
41
|
+
private fingerprintConflict;
|
|
42
|
+
private insertConcept;
|
|
43
|
+
private insertMergeCandidate;
|
|
44
|
+
private findSimilarConcept;
|
|
45
|
+
/** 同 pair(无向)已有 memoryIds:边 basis + causal_candidate */
|
|
46
|
+
private collectPairMemoryIds;
|
|
47
|
+
admitEdge(input: AdmitEdgeInput): Promise<AdmitEdgeResult>;
|
|
48
|
+
addCausalCandidate(input: {
|
|
49
|
+
sourceId: string;
|
|
50
|
+
targetId: string;
|
|
51
|
+
memoryIds: string[];
|
|
52
|
+
cue: string;
|
|
53
|
+
note?: string;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
listMergeCandidates(limit?: number): Promise<MergeCandidate[]>;
|
|
56
|
+
resolveMerge(id: string, action: 'merge' | 'keep_split' | 'drop'): Promise<void>;
|
|
57
|
+
reinforce(input: {
|
|
58
|
+
nodeIds?: string[];
|
|
59
|
+
edgeIds?: string[];
|
|
60
|
+
evidenceStrength?: number;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
counterEvidence(input: {
|
|
63
|
+
edgeId: string;
|
|
64
|
+
memoryId?: string;
|
|
65
|
+
markOpposes?: boolean;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
promote(ids: string[], to: 'active' | 'strengthened'): Promise<void>;
|
|
68
|
+
demote(ids: string[], to: 'shadow'): Promise<void>;
|
|
69
|
+
applyDecay(now?: number): Promise<DecayResult>;
|
|
70
|
+
spreadingActivate(seeds: string[], options?: SpreadingActivateOptions): Promise<ActivatedGraph>;
|
|
71
|
+
getFullGraph(): Promise<ConceptGraph>;
|
|
72
|
+
stats(): Promise<ConceptGraphStats>;
|
|
34
73
|
}
|