@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
|
@@ -7,12 +7,41 @@
|
|
|
7
7
|
* P2.d:可选 FTS5(trigram)。短词(<3 码点,常见二字中文)trigram 命不中,
|
|
8
8
|
* 自动回落 LIKE;FTS 不可用时整库 LIKE。
|
|
9
9
|
*/
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
10
11
|
import { extractSearchableFields } from '@octopi-agent/engine/harness/session/history/score.js';
|
|
11
12
|
/** 单字段入库切片;更长文本可能在预筛中漏检 → prefilter 返回 null 回退扫描 */
|
|
12
13
|
const INDEX_TEXT_SLICE = 2000;
|
|
13
14
|
const SCHEMA_VERSION = 2;
|
|
14
15
|
/** trigram 最少 3 码点;更短走 LIKE */
|
|
15
16
|
const TRIGRAM_MIN_CHARS = 3;
|
|
17
|
+
/**
|
|
18
|
+
* transient 消息(每轮剥旧插新的托管注入块)不是 Discourse 内容:
|
|
19
|
+
* UI 与 LLM 窗口都过滤它,索引同样排除——否则增量/全量两条路径口径漂移,
|
|
20
|
+
* 且剥离后残留幽灵词条。口径变更:session_search 不再命中临时注入块。
|
|
21
|
+
*/
|
|
22
|
+
function isTransientMessage(msg) {
|
|
23
|
+
const src = msg.metadata?.source;
|
|
24
|
+
return (src === 'knowledgeGrounding' ||
|
|
25
|
+
src === 'sessionAttachment' ||
|
|
26
|
+
// E8 易变快照:日志保留(审计)但非 Discourse 发言,索引不收(防幽灵词条/归因错误)
|
|
27
|
+
src === 'runtimeSnapshot');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 已索引持久消息尾指纹:增量快路径的前缀未变判据。
|
|
31
|
+
*
|
|
32
|
+
* 消息内容不可变、历史只追加/截断,尾指纹一致 ⇒ 前缀未换(截断会使尾指纹
|
|
33
|
+
* 变化或条数变小,从而回退全量重建)。只 hash 可搜字段,成本 O(单条消息)。
|
|
34
|
+
*/
|
|
35
|
+
function tailFingerprint(msg) {
|
|
36
|
+
const h = createHash('sha1');
|
|
37
|
+
for (const f of extractSearchableFields(msg, true)) {
|
|
38
|
+
h.update(f.field);
|
|
39
|
+
h.update('\u0000');
|
|
40
|
+
h.update(f.text);
|
|
41
|
+
h.update('\u0000');
|
|
42
|
+
}
|
|
43
|
+
return h.digest('hex');
|
|
44
|
+
}
|
|
16
45
|
/**
|
|
17
46
|
* 创建 SQLite 会话投影索引(node:sqlite,Node >= 24)。
|
|
18
47
|
*
|
|
@@ -97,6 +126,14 @@ class SqliteSessionIndex {
|
|
|
97
126
|
.prepare(`INSERT INTO index_meta (key, value) VALUES ('schema_version', ?)`)
|
|
98
127
|
.run(String(SCHEMA_VERSION));
|
|
99
128
|
}
|
|
129
|
+
// v2→v3 列迁移:增量 upsert 状态(indexed_count = 已索引持久消息条数,tail_fp = 尾指纹)
|
|
130
|
+
const cols = this.db.prepare(`PRAGMA table_info(sessions)`).all();
|
|
131
|
+
if (!cols.some((c) => c.name === 'indexed_count')) {
|
|
132
|
+
this.db.exec(`ALTER TABLE sessions ADD COLUMN indexed_count INTEGER`);
|
|
133
|
+
}
|
|
134
|
+
if (!cols.some((c) => c.name === 'tail_fp')) {
|
|
135
|
+
this.db.exec(`ALTER TABLE sessions ADD COLUMN tail_fp TEXT`);
|
|
136
|
+
}
|
|
100
137
|
}
|
|
101
138
|
tryEnableFts() {
|
|
102
139
|
try {
|
|
@@ -145,23 +182,41 @@ class SqliteSessionIndex {
|
|
|
145
182
|
message_count = excluded.message_count,
|
|
146
183
|
source = excluded.source`)
|
|
147
184
|
.run(sessionId, data.agentId ?? meta.agentId ?? 'default', data.primaryAgentId ?? meta.primaryAgentId ?? null, data.preferredAgentId ?? meta.preferredAgentId ?? null, JSON.stringify(participantIds ?? []), lifecycle, meta.createdAt ?? null, meta.updatedAt ?? Date.now(), data.lifecycle?.endedAt ?? meta.endedAt ?? null, data.lifecycle?.archivedAt ?? meta.archivedAt ?? null, messages.length, source);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
185
|
+
// 增量快路径:持久消息序列只追加且尾指纹未变 → 只插新增;
|
|
186
|
+
// 否则(截断 / 尾指纹不符 / 首次)全量重建该会话。
|
|
187
|
+
// msg_index = 持久序列下标(transient 之外的稳定序号);prefilter 只消费
|
|
188
|
+
// sessionId,msg_index 仅供内部定位,不等于 session.messages 全文下标。
|
|
189
|
+
const persisted = messages.filter((m) => !isTransientMessage(m));
|
|
190
|
+
const prevRow = this.db
|
|
191
|
+
.prepare(`SELECT indexed_count, tail_fp FROM sessions WHERE session_id = ?`)
|
|
192
|
+
.get(sessionId);
|
|
193
|
+
const prevCount = prevRow?.indexed_count ?? 0;
|
|
194
|
+
const prefixIntact = persisted.length >= prevCount &&
|
|
195
|
+
(prevCount === 0 || tailFingerprint(persisted[prevCount - 1]) === prevRow?.tail_fp);
|
|
152
196
|
const insert = this.db.prepare(`INSERT OR REPLACE INTO messages (session_id, msg_index, role, agent_id, timestamp, field, text)
|
|
153
197
|
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
154
198
|
const insertFts = this.fts
|
|
155
199
|
? this.db.prepare(`INSERT INTO messages_fts (text, session_id, msg_index, field) VALUES (?, ?, ?, ?)`)
|
|
156
200
|
: null;
|
|
157
|
-
|
|
158
|
-
|
|
201
|
+
const start = prefixIntact ? prevCount : 0;
|
|
202
|
+
if (!prefixIntact) {
|
|
203
|
+
this.db.prepare(`DELETE FROM messages WHERE session_id = ?`).run(sessionId);
|
|
204
|
+
if (this.fts) {
|
|
205
|
+
this.db.prepare(`DELETE FROM messages_fts WHERE session_id = ?`).run(sessionId);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
for (let j = start; j < persisted.length; j++) {
|
|
209
|
+
const msg = persisted[j];
|
|
159
210
|
for (const f of extractSearchableFields(msg, true)) {
|
|
160
211
|
const text = f.text.slice(0, INDEX_TEXT_SLICE);
|
|
161
|
-
insert.run(sessionId,
|
|
162
|
-
insertFts?.run(text, sessionId,
|
|
212
|
+
insert.run(sessionId, j, msg.role, msg.agentId ?? null, msg.timestamp ?? null, f.field, text);
|
|
213
|
+
insertFts?.run(text, sessionId, j, f.field);
|
|
163
214
|
}
|
|
164
215
|
}
|
|
216
|
+
const newFp = persisted.length ? tailFingerprint(persisted[persisted.length - 1]) : null;
|
|
217
|
+
this.db
|
|
218
|
+
.prepare(`UPDATE sessions SET indexed_count = ?, tail_fp = ? WHERE session_id = ?`)
|
|
219
|
+
.run(persisted.length, newFp, sessionId);
|
|
165
220
|
this.db.exec('COMMIT');
|
|
166
221
|
}
|
|
167
222
|
catch (err) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Cognition Steward Conceptualize
|
|
2
|
+
|
|
3
|
+
你是概念化助手。从**命题 + 证据语境**中提取可复用概念与关系假设,输出结构化 JSON。
|
|
4
|
+
|
|
5
|
+
本文是 system 认知指令;用户消息仅提供 Memory 命题与 contextSlice。不要复述本文规则。
|
|
6
|
+
|
|
7
|
+
## 输出
|
|
8
|
+
|
|
9
|
+
严格 JSON 对象:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"nodes": [
|
|
14
|
+
{
|
|
15
|
+
"name": "会话租约",
|
|
16
|
+
"kind": "construct",
|
|
17
|
+
"description": "sessionId 级互斥租约",
|
|
18
|
+
"domain": ["session", "concurrency"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"edges": [
|
|
22
|
+
{
|
|
23
|
+
"fromName": "会话租约",
|
|
24
|
+
"toName": "Session",
|
|
25
|
+
"relationType": "part_of",
|
|
26
|
+
"evidenceClass": "mereonymy",
|
|
27
|
+
"cue": "证据中的原句片段"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"rejected": []
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 规则
|
|
35
|
+
|
|
36
|
+
- 概念是**可复用判别单元**(entity/construct/method/problem/constraint),不是每个名词
|
|
37
|
+
- `relationType`:causes / part_of / opposes / similar_to / evolves_to / related
|
|
38
|
+
- `evidenceClass`:causal / mereonymy / negation / analogy / evolution / cooccur
|
|
39
|
+
- **强关系必须给 cue**(证据原句片段);无把握时只用 `related` + `cooccur`
|
|
40
|
+
- 禁止假因果:非因果证据不得标 causes
|
|
41
|
+
- 两个义项不同时**禁止合并成一个 name**;宁可拆开
|
|
42
|
+
- 没有值得记的概念返回 `{"nodes":[],"edges":[],"rejected":[]}`
|
|
43
|
+
- kind 只能是 entity / construct / method / problem / constraint
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
id: cognition.steward.conceptualize
|
|
2
|
+
name: Cognition Steward Conceptualize
|
|
3
|
+
description: 命题+语境 → 概念图谱(持证关系;写 concepts/concept_edges)
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: eventBus
|
|
7
|
+
filter:
|
|
8
|
+
condition: "true"
|
|
9
|
+
events: ['cognition.conceptualize.request']
|
|
10
|
+
emits: ['cognition.conceptualized']
|
|
11
|
+
isolation: isolated
|
|
12
|
+
|
|
13
|
+
think:
|
|
14
|
+
implementation: llm
|
|
15
|
+
strategy: single
|
|
16
|
+
maxIterations: 1
|
|
17
|
+
|
|
18
|
+
act:
|
|
19
|
+
mode: inject
|
|
20
|
+
|
|
21
|
+
signal:
|
|
22
|
+
severity: info
|
|
23
|
+
channel: [event]
|
|
24
|
+
|
|
25
|
+
boundary:
|
|
26
|
+
visibility: isolated
|
|
27
|
+
authority: act
|
|
28
|
+
security: trusted
|
|
29
|
+
|
|
30
|
+
tools:
|
|
31
|
+
mode: none
|
|
32
|
+
|
|
33
|
+
session:
|
|
34
|
+
mode: ephemeral
|
|
35
|
+
scope: agent
|
|
36
|
+
|
|
37
|
+
lifecycle:
|
|
38
|
+
maxConcurrent: 1
|
|
39
|
+
maxDurationMs: 30000
|
|
40
|
+
|
|
41
|
+
runtimeInject:
|
|
42
|
+
requires: ['conceptGraphStore']
|
|
43
|
+
|
|
44
|
+
observability:
|
|
45
|
+
eventPrefix: cognition.steward.conceptualize
|
|
46
|
+
|
|
47
|
+
metadata:
|
|
48
|
+
config:
|
|
49
|
+
maxNodesPerProposition: 6
|
|
50
|
+
maxEdgesPerProposition: 12
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cognition.steward.conceptualize — 命题 + contextSlice → 概念/边(持证)
|
|
3
|
+
*
|
|
4
|
+
* 失败语义:缺 llmPort / LLM 错误 / 解析失败 → act.status=failed。
|
|
5
|
+
* 只写 ConceptGraphStore(E3);不写 Memory / Wisdom / Knowledge。
|
|
6
|
+
*/
|
|
7
|
+
import type { SubsystemInput, SubsystemOutput, InjectedDependencies } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/types.js';
|
|
8
|
+
declare function handler(input: SubsystemInput, deps?: InjectedDependencies): Promise<SubsystemOutput>;
|
|
9
|
+
export default handler;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cognition.steward.conceptualize — 命题 + contextSlice → 概念/边(持证)
|
|
3
|
+
*
|
|
4
|
+
* 失败语义:缺 llmPort / LLM 错误 / 解析失败 → act.status=failed。
|
|
5
|
+
* 只写 ConceptGraphStore(E3);不写 Memory / Wisdom / Knowledge。
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from 'node:fs';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
11
|
+
import { conceptualizeAndAdmit, parseConceptualizerJson, } from '../../../harness/memory/conceptualizer.js';
|
|
12
|
+
const DEP_CONCEPT_GRAPH = 'conceptGraphStore';
|
|
13
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
14
|
+
function resolveSubsystemPrompt(deps, llmPort) {
|
|
15
|
+
const fromDeps = deps?.[DEP_SUBSYSTEM_PROMPT];
|
|
16
|
+
if (typeof fromDeps === 'string' && fromDeps.trim())
|
|
17
|
+
return fromDeps;
|
|
18
|
+
if (llmPort?.cognitivePrompt?.trim())
|
|
19
|
+
return llmPort.cognitivePrompt;
|
|
20
|
+
try {
|
|
21
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
return readFileSync(join(here, 'SUBSYSTEM.md'), 'utf8');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function failOutput(message, reason) {
|
|
29
|
+
return {
|
|
30
|
+
act: {
|
|
31
|
+
mode: 'inject',
|
|
32
|
+
status: 'failed',
|
|
33
|
+
error: message,
|
|
34
|
+
target: 'concept-graph',
|
|
35
|
+
messages: [{ role: 'system', content: `cognition.steward.conceptualize.failed reason=${reason}` }],
|
|
36
|
+
},
|
|
37
|
+
signals: [{ action: 'alert', reason: message, data: { reason } }],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function handler(input, deps) {
|
|
41
|
+
const store = deps?.[DEP_CONCEPT_GRAPH];
|
|
42
|
+
if (!store) {
|
|
43
|
+
throw new Error('cognition.steward.conceptualize: conceptGraphStore not injected');
|
|
44
|
+
}
|
|
45
|
+
const llmPort = deps?.[DEP_LLM_PORT];
|
|
46
|
+
if (!llmPort?.chat) {
|
|
47
|
+
return failOutput('llmPort missing', 'llm_port_missing');
|
|
48
|
+
}
|
|
49
|
+
const payload = (input.payload ?? {});
|
|
50
|
+
const proposition = String(payload.proposition ?? '').trim();
|
|
51
|
+
const memoryId = String(payload.memoryId ?? '');
|
|
52
|
+
const evidence = String(payload.evidence ?? '');
|
|
53
|
+
const contextSlice = String(payload.contextSlice ?? payload.context_slice ?? '');
|
|
54
|
+
const memoryType = String(payload.memoryType ?? payload.type ?? 'fact');
|
|
55
|
+
const memoryStatus = payload.memoryStatus ?? undefined;
|
|
56
|
+
if (!proposition || !memoryId) {
|
|
57
|
+
return failOutput('missing proposition/memoryId', 'bad_payload');
|
|
58
|
+
}
|
|
59
|
+
if (!contextSlice.trim() && !evidence.trim()) {
|
|
60
|
+
return failOutput('no context slice', 'no_context_slice');
|
|
61
|
+
}
|
|
62
|
+
const systemPrompt = resolveSubsystemPrompt(deps, llmPort);
|
|
63
|
+
const userText = [
|
|
64
|
+
`memoryType: ${memoryType}`,
|
|
65
|
+
`proposition: ${proposition}`,
|
|
66
|
+
`evidence: ${evidence}`,
|
|
67
|
+
`contextSlice: ${contextSlice}`,
|
|
68
|
+
].join('\n');
|
|
69
|
+
let llmText = '';
|
|
70
|
+
try {
|
|
71
|
+
const res = await llmPort.chat({
|
|
72
|
+
systemPrompt: systemPrompt || undefined,
|
|
73
|
+
messages: [{ role: 'user', content: userText }],
|
|
74
|
+
temperature: 0.2,
|
|
75
|
+
maxTokens: 2048,
|
|
76
|
+
});
|
|
77
|
+
if (res.finishReason === 'error') {
|
|
78
|
+
return failOutput(res.content || 'llm chat error', 'llm_error');
|
|
79
|
+
}
|
|
80
|
+
llmText = res.content ?? '';
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
return failOutput(err instanceof Error ? err.message : String(err), 'llm_error');
|
|
84
|
+
}
|
|
85
|
+
const parsed = parseConceptualizerJson(llmText);
|
|
86
|
+
if (!parsed) {
|
|
87
|
+
return failOutput('parse_failed', 'parse_failed');
|
|
88
|
+
}
|
|
89
|
+
const result = await conceptualizeAndAdmit(parsed, {
|
|
90
|
+
proposition,
|
|
91
|
+
memoryId,
|
|
92
|
+
memoryType,
|
|
93
|
+
evidence,
|
|
94
|
+
contextSlice,
|
|
95
|
+
memoryStatus,
|
|
96
|
+
}, store);
|
|
97
|
+
const created = result.nodes.filter((n) => n.admit.action === 'created' || n.admit.action === 'merged').length;
|
|
98
|
+
const edgesIn = result.edges.filter((e) => e.admit && e.admit.action !== 'rejected').length;
|
|
99
|
+
return {
|
|
100
|
+
act: {
|
|
101
|
+
mode: 'inject',
|
|
102
|
+
status: 'success',
|
|
103
|
+
target: 'concept-graph',
|
|
104
|
+
messages: [
|
|
105
|
+
{
|
|
106
|
+
role: 'system',
|
|
107
|
+
content: `cognition.steward.conceptualized nodes=${created} edges=${edgesIn} rejected=${result.rejected.length}`,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
signals: [
|
|
112
|
+
{
|
|
113
|
+
action: 'suggest',
|
|
114
|
+
reason: 'conceptualized',
|
|
115
|
+
data: {
|
|
116
|
+
memoryId,
|
|
117
|
+
nodes: created,
|
|
118
|
+
edges: edgesIn,
|
|
119
|
+
rejected: result.rejected,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export default handler;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
id: cognition.steward.consolidate
|
|
2
|
+
name: Cognition Steward Consolidate
|
|
3
|
+
description: 概念图巩固:衰减、晋升、GC、容量检查(事件+TTL)
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: schedule
|
|
7
|
+
interval: 86400000
|
|
8
|
+
filter:
|
|
9
|
+
condition: "true"
|
|
10
|
+
events: ['cognition.consolidate.request', 'session.ended', 'memory.steward.governed']
|
|
11
|
+
emits: ['cognition.consolidated']
|
|
12
|
+
isolation: isolated
|
|
13
|
+
|
|
14
|
+
think:
|
|
15
|
+
implementation: code
|
|
16
|
+
strategy: deterministic
|
|
17
|
+
maxIterations: 1
|
|
18
|
+
|
|
19
|
+
act:
|
|
20
|
+
mode: inject
|
|
21
|
+
|
|
22
|
+
signal:
|
|
23
|
+
severity: info
|
|
24
|
+
channel: [event]
|
|
25
|
+
|
|
26
|
+
boundary:
|
|
27
|
+
visibility: isolated
|
|
28
|
+
authority: act
|
|
29
|
+
security: trusted
|
|
30
|
+
|
|
31
|
+
tools:
|
|
32
|
+
mode: none
|
|
33
|
+
|
|
34
|
+
session:
|
|
35
|
+
mode: ephemeral
|
|
36
|
+
scope: agent
|
|
37
|
+
|
|
38
|
+
lifecycle:
|
|
39
|
+
maxConcurrent: 1
|
|
40
|
+
maxDurationMs: 15000
|
|
41
|
+
|
|
42
|
+
runtimeInject:
|
|
43
|
+
requires: ['conceptGraphStore']
|
|
44
|
+
|
|
45
|
+
observability:
|
|
46
|
+
eventPrefix: cognition.steward.consolidate
|
|
47
|
+
|
|
48
|
+
metadata:
|
|
49
|
+
config:
|
|
50
|
+
promoteMinSupport: 3
|
|
51
|
+
warnNodes: 5000
|
|
52
|
+
warnEdges: 20000
|
|
53
|
+
stopNodes: 10000
|
|
54
|
+
stopEdges: 40000
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cognition.steward.consolidate — 概念图巩固批
|
|
3
|
+
*
|
|
4
|
+
* 本轮实现:衰减 → 指纹冲突 keep_split → 按支撑晋升 → 容量水位。
|
|
5
|
+
* 未实现步骤(LLM 合并裁决 / causal_candidate 转正 / Wisdom 信号 / anchor:missing GC)
|
|
6
|
+
* 显式记入 skipped,不得假装完成规格 §7.2 全部步骤。
|
|
7
|
+
*
|
|
8
|
+
* 只写 ConceptGraphStore;不写 Memory / Wisdom。
|
|
9
|
+
*/
|
|
10
|
+
import type { SubsystemInput, SubsystemOutput, InjectedDependencies } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/types.js';
|
|
11
|
+
declare function handler(_input: SubsystemInput, deps?: InjectedDependencies): Promise<SubsystemOutput>;
|
|
12
|
+
export default handler;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cognition.steward.consolidate — 概念图巩固批
|
|
3
|
+
*
|
|
4
|
+
* 本轮实现:衰减 → 指纹冲突 keep_split → 按支撑晋升 → 容量水位。
|
|
5
|
+
* 未实现步骤(LLM 合并裁决 / causal_candidate 转正 / Wisdom 信号 / anchor:missing GC)
|
|
6
|
+
* 显式记入 skipped,不得假装完成规格 §7.2 全部步骤。
|
|
7
|
+
*
|
|
8
|
+
* 只写 ConceptGraphStore;不写 Memory / Wisdom。
|
|
9
|
+
*/
|
|
10
|
+
const DEP_CONCEPT_GRAPH = 'conceptGraphStore';
|
|
11
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
12
|
+
/** 本 handler 已声明但未执行的规格步骤 */
|
|
13
|
+
const SKIPPED_STEPS = [
|
|
14
|
+
'merge_llm_adjudication',
|
|
15
|
+
'causal_candidate_promotion',
|
|
16
|
+
'counter_evidence_scan',
|
|
17
|
+
'wisdom_promotion_signal',
|
|
18
|
+
'anchor_missing_gc',
|
|
19
|
+
];
|
|
20
|
+
async function handler(_input, deps) {
|
|
21
|
+
const store = deps?.[DEP_CONCEPT_GRAPH];
|
|
22
|
+
if (!store) {
|
|
23
|
+
throw new Error('cognition.steward.consolidate: conceptGraphStore not injected');
|
|
24
|
+
}
|
|
25
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
26
|
+
const promoteMinSupport = config.promoteMinSupport ?? 3;
|
|
27
|
+
// 1. 衰减 + 无支撑 GC(store 内)
|
|
28
|
+
const decay = await store.applyDecay();
|
|
29
|
+
// 2. merge candidates:指纹冲突保守 keep_split(禁假合并)
|
|
30
|
+
const candidates = await store.listMergeCandidates(100);
|
|
31
|
+
let keptSplit = 0;
|
|
32
|
+
if (config.autoKeepSplitConflicts !== false) {
|
|
33
|
+
for (const c of candidates) {
|
|
34
|
+
if (c.reason.includes('conflict') ||
|
|
35
|
+
c.reason === 'domain_disjoint' ||
|
|
36
|
+
c.reason === 'fingerprint_conflict') {
|
|
37
|
+
await store.resolveMerge(c.id, 'keep_split');
|
|
38
|
+
keptSplit += 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// 3. 晋升:memoryIds 支撑 ≥ promoteMinSupport 的 shadow 节点
|
|
43
|
+
const graph = await store.getFullGraph();
|
|
44
|
+
const toPromote = graph.nodes
|
|
45
|
+
.filter((n) => n.status === 'shadow' && n.memoryIds.length >= promoteMinSupport)
|
|
46
|
+
.map((n) => n.id);
|
|
47
|
+
if (toPromote.length) {
|
|
48
|
+
await store.promote(toPromote, 'active');
|
|
49
|
+
}
|
|
50
|
+
// 4. 容量水位
|
|
51
|
+
const stats = await store.stats();
|
|
52
|
+
const warnNodes = config.warnNodes ?? 5000;
|
|
53
|
+
const warnEdges = config.warnEdges ?? 20_000;
|
|
54
|
+
const stopNodes = config.stopNodes ?? 10_000;
|
|
55
|
+
const stopEdges = config.stopEdges ?? 40_000;
|
|
56
|
+
const capacity = stats.nodes >= stopNodes || stats.edges >= stopEdges
|
|
57
|
+
? 'admit_stop'
|
|
58
|
+
: stats.nodes >= warnNodes || stats.edges >= warnEdges
|
|
59
|
+
? 'warn'
|
|
60
|
+
: 'ok';
|
|
61
|
+
return {
|
|
62
|
+
act: {
|
|
63
|
+
mode: 'inject',
|
|
64
|
+
status: 'success',
|
|
65
|
+
target: 'concept-graph',
|
|
66
|
+
messages: [
|
|
67
|
+
{
|
|
68
|
+
role: 'system',
|
|
69
|
+
content: `cognition.steward.consolidated decayed=${decay.decayedEdges} gcNodes=${decay.gcNodes} ` +
|
|
70
|
+
`promoted=${toPromote.length} keptSplit=${keptSplit} capacity=${capacity} ` +
|
|
71
|
+
`nodes=${stats.nodes} edges=${stats.edges} ` +
|
|
72
|
+
`skipped=[${SKIPPED_STEPS.join(',')}]`,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
signals: [
|
|
77
|
+
{
|
|
78
|
+
action: 'suggest',
|
|
79
|
+
reason: 'consolidated_partial',
|
|
80
|
+
data: {
|
|
81
|
+
decay,
|
|
82
|
+
promoted: toPromote.length,
|
|
83
|
+
keptSplit,
|
|
84
|
+
capacity,
|
|
85
|
+
stats,
|
|
86
|
+
openMergeCandidates: stats.openMergeCandidates,
|
|
87
|
+
skippedSteps: [...SKIPPED_STEPS],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export default handler;
|
|
@@ -94,6 +94,15 @@ function messagesToText(session, maxChars = 8000) {
|
|
|
94
94
|
const kind = m?.metadata?.kind;
|
|
95
95
|
if (kind === 'command' || kind === 'command_result')
|
|
96
96
|
continue;
|
|
97
|
+
// 引擎载体插槽(快照/grounding/附件/摘要)不是实质 user/assistant 发言,
|
|
98
|
+
// 不得作为记忆抽取证据(快照含记忆原文回显,入证据即自我复制)
|
|
99
|
+
const src = m?.metadata?.source;
|
|
100
|
+
if (src === 'runtimeSnapshot' ||
|
|
101
|
+
src === 'knowledgeGrounding' ||
|
|
102
|
+
src === 'sessionAttachment' ||
|
|
103
|
+
src === 'contextSummary') {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
97
106
|
const role = m?.role;
|
|
98
107
|
if (role !== 'user' && role !== 'assistant')
|
|
99
108
|
continue;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
id: wisdom.steward.evaluate
|
|
2
|
+
name: Wisdom Steward Evaluate
|
|
3
|
+
description: 弱归因结局入账 + confidence/状态迁移(可 dryRun;不写 Memory/Cognition)
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: eventBus
|
|
7
|
+
filter:
|
|
8
|
+
condition: "true"
|
|
9
|
+
events: ['wisdom.steward.evaluate.request']
|
|
10
|
+
emits: ['wisdom.steward.evaluated']
|
|
11
|
+
isolation: isolated
|
|
12
|
+
|
|
13
|
+
think:
|
|
14
|
+
implementation: code
|
|
15
|
+
strategy: deterministic
|
|
16
|
+
maxIterations: 1
|
|
17
|
+
|
|
18
|
+
act:
|
|
19
|
+
mode: inject
|
|
20
|
+
|
|
21
|
+
signal:
|
|
22
|
+
severity: info
|
|
23
|
+
channel: [event]
|
|
24
|
+
|
|
25
|
+
boundary:
|
|
26
|
+
visibility: isolated
|
|
27
|
+
authority: act
|
|
28
|
+
security: trusted
|
|
29
|
+
|
|
30
|
+
tools:
|
|
31
|
+
mode: none
|
|
32
|
+
|
|
33
|
+
session:
|
|
34
|
+
mode: ephemeral
|
|
35
|
+
scope: agent
|
|
36
|
+
|
|
37
|
+
lifecycle:
|
|
38
|
+
maxConcurrent: 1
|
|
39
|
+
maxDurationMs: 15000
|
|
40
|
+
|
|
41
|
+
runtimeInject:
|
|
42
|
+
requires: ['wisdomStore']
|
|
43
|
+
|
|
44
|
+
observability:
|
|
45
|
+
eventPrefix: wisdom.steward.evaluate
|
|
46
|
+
|
|
47
|
+
metadata:
|
|
48
|
+
config:
|
|
49
|
+
dryRun: false
|
|
50
|
+
minAppliesForActive: 3
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.evaluate — 弱归因结局入账 + 状态迁移
|
|
3
|
+
*
|
|
4
|
+
* payload.events 为可选 WisdomOutcomeEvent[];无事件时对存活条目做批量
|
|
5
|
+
* confidence/状态规划(只基于已入账 outcomes)。不写 Memory / Cognition。
|
|
6
|
+
*/
|
|
7
|
+
import type { SubsystemInput, SubsystemOutput, InjectedDependencies } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/types.js';
|
|
8
|
+
declare function handler(input: SubsystemInput, deps?: InjectedDependencies): Promise<SubsystemOutput>;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
handler: typeof handler;
|
|
11
|
+
contract: {
|
|
12
|
+
input: string;
|
|
13
|
+
output: string;
|
|
14
|
+
};
|
|
15
|
+
dependencies: string[];
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
18
|
+
export { handler };
|