@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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.evaluate — 弱归因结局入账 + 状态迁移
|
|
3
|
+
*
|
|
4
|
+
* payload.events 为可选 WisdomOutcomeEvent[];无事件时对存活条目做批量
|
|
5
|
+
* confidence/状态规划(只基于已入账 outcomes)。不写 Memory / Cognition。
|
|
6
|
+
*/
|
|
7
|
+
import { planConfidenceUpdate, } from '../../../harness/memory/wisdom-policy.js';
|
|
8
|
+
const DEP_WISDOM = 'wisdomStore';
|
|
9
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
10
|
+
function isOutcomeEvent(v) {
|
|
11
|
+
if (!v || typeof v !== 'object')
|
|
12
|
+
return false;
|
|
13
|
+
const o = v;
|
|
14
|
+
return (typeof o.wisdomId === 'string' &&
|
|
15
|
+
typeof o.signal === 'string' &&
|
|
16
|
+
['applied', 'cited', 'assisted', 'contested', 'ignored'].includes(o.signal));
|
|
17
|
+
}
|
|
18
|
+
async function handler(input, deps) {
|
|
19
|
+
const store = deps?.[DEP_WISDOM];
|
|
20
|
+
if (!store)
|
|
21
|
+
throw new Error('wisdom.steward.evaluate: wisdomStore not injected');
|
|
22
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
23
|
+
const dryRun = config.dryRun ?? false;
|
|
24
|
+
const payload = (input.payload ?? {});
|
|
25
|
+
const rawEvents = Array.isArray(payload.events) ? payload.events : [];
|
|
26
|
+
const events = rawEvents.filter(isOutcomeEvent);
|
|
27
|
+
if (events.length > 0 && !dryRun) {
|
|
28
|
+
await store.recordOutcomes(events);
|
|
29
|
+
}
|
|
30
|
+
const entries = await store.listForGovern({ includeRetired: false });
|
|
31
|
+
let updated = 0;
|
|
32
|
+
let statusChanges = 0;
|
|
33
|
+
const planned = [];
|
|
34
|
+
for (const e of entries) {
|
|
35
|
+
// 终态不再评估(superseded 链已封;retired 由 govern 处理)
|
|
36
|
+
if (e.status === 'superseded' || e.status === 'retired')
|
|
37
|
+
continue;
|
|
38
|
+
// recordOutcomes 已增量更新过的条目:水位对齐后 plan 为 null 或仅状态迁移
|
|
39
|
+
const plan = planConfidenceUpdate(e, config);
|
|
40
|
+
if (!plan)
|
|
41
|
+
continue;
|
|
42
|
+
planned.push({
|
|
43
|
+
id: plan.id,
|
|
44
|
+
status: plan.status,
|
|
45
|
+
confidence: plan.confidence,
|
|
46
|
+
reason: plan.reason,
|
|
47
|
+
});
|
|
48
|
+
if (!dryRun) {
|
|
49
|
+
await store.update(plan.id, {
|
|
50
|
+
confidence: plan.confidence,
|
|
51
|
+
status: plan.status,
|
|
52
|
+
outcomes: {
|
|
53
|
+
...e.outcomes,
|
|
54
|
+
evalAssisted: plan.evalAssisted,
|
|
55
|
+
evalContested: plan.evalContested,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
updated++;
|
|
59
|
+
}
|
|
60
|
+
if (plan.status !== e.status)
|
|
61
|
+
statusChanges++;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
act: {
|
|
65
|
+
mode: 'inject',
|
|
66
|
+
status: 'success',
|
|
67
|
+
target: 'wisdom-store',
|
|
68
|
+
messages: [{
|
|
69
|
+
role: 'system',
|
|
70
|
+
content: `wisdom.steward.evaluated events=${events.length} updated=${updated} statusChanges=${statusChanges} dryRun=${dryRun}`,
|
|
71
|
+
}],
|
|
72
|
+
},
|
|
73
|
+
signals: [{
|
|
74
|
+
action: 'suggest',
|
|
75
|
+
reason: 'evaluation_completed',
|
|
76
|
+
data: {
|
|
77
|
+
events: events.length,
|
|
78
|
+
updated,
|
|
79
|
+
statusChanges,
|
|
80
|
+
dryRun,
|
|
81
|
+
planned: planned.slice(0, 20),
|
|
82
|
+
},
|
|
83
|
+
}],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export default {
|
|
87
|
+
handler,
|
|
88
|
+
contract: { input: 'WisdomEvaluateInput', output: 'WisdomEvaluateResult' },
|
|
89
|
+
dependencies: [DEP_WISDOM],
|
|
90
|
+
};
|
|
91
|
+
export { handler };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# wisdom.steward.formation
|
|
2
|
+
|
|
3
|
+
把 **多条稳定 Memory 命题** 压缩成 **一条判断范式(maxim)**。
|
|
4
|
+
|
|
5
|
+
## 任务
|
|
6
|
+
|
|
7
|
+
输入是 method/norm 命题包(及可选概念线索),输出 0–N 条 maxim。
|
|
8
|
+
|
|
9
|
+
## 输出 JSON(只输出 JSON)
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"items": [
|
|
14
|
+
{
|
|
15
|
+
"statement": "面对…时,先…",
|
|
16
|
+
"rationale": "为何这样想(一句话,不是步骤)",
|
|
17
|
+
"problemTypes": ["验证型宣称", "失败排查"],
|
|
18
|
+
"signals": ["工具已调用但未核对结果"],
|
|
19
|
+
"antiScenarios": ["用户明确要求假设成功"],
|
|
20
|
+
"questions": ["证据在哪里?"],
|
|
21
|
+
"biases": ["把过程当结果"],
|
|
22
|
+
"posture": "先证伪再扩展",
|
|
23
|
+
"memoryIds": ["m1", "m2"],
|
|
24
|
+
"conceptIds": [],
|
|
25
|
+
"exceptions": [],
|
|
26
|
+
"kind": "corrective"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"droppedNotes": ["不足以形成范式的主题说明"]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 硬规则
|
|
34
|
+
|
|
35
|
+
1. **单位是范式**:改「该怎么想」,不要写步骤(method)或行为开关(norm)。
|
|
36
|
+
2. **多源**:每条至少 2 个 memoryIds(不同命题)。
|
|
37
|
+
3. **有操作效应**:questions / biases / posture 至少一项。
|
|
38
|
+
4. **有适用域**:problemTypes 非空;写清 antiScenarios。
|
|
39
|
+
5. 不输出 secrets、统计句、人格/宪法句。
|
|
40
|
+
6. 无合格范式时输出 `{"items":[],"droppedNotes":["…"]}`,不要硬凑。
|
|
41
|
+
|
|
42
|
+
kind ∈ `generalize | corrective | selection | boundary`。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
id: wisdom.steward.formation
|
|
2
|
+
name: Wisdom Steward Formation
|
|
3
|
+
description: 从 Memory/Cognition 稳定结构炼制判断范式(maxim;多源门控;不写 Memory/Cognition)
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: schedule
|
|
7
|
+
interval: 86400000
|
|
8
|
+
filter:
|
|
9
|
+
condition: "true"
|
|
10
|
+
events: ['wisdom.steward.formation.request']
|
|
11
|
+
emits: ['wisdom.steward.formed', 'wisdom.steward.formation.failed']
|
|
12
|
+
isolation: isolated
|
|
13
|
+
|
|
14
|
+
think:
|
|
15
|
+
implementation: llm
|
|
16
|
+
strategy: single
|
|
17
|
+
model: summary
|
|
18
|
+
maxIterations: 1
|
|
19
|
+
|
|
20
|
+
act:
|
|
21
|
+
mode: inject
|
|
22
|
+
|
|
23
|
+
signal:
|
|
24
|
+
severity: info
|
|
25
|
+
channel: [event]
|
|
26
|
+
|
|
27
|
+
boundary:
|
|
28
|
+
visibility: isolated
|
|
29
|
+
authority: act
|
|
30
|
+
security: trusted
|
|
31
|
+
|
|
32
|
+
tools:
|
|
33
|
+
mode: none
|
|
34
|
+
|
|
35
|
+
session:
|
|
36
|
+
mode: ephemeral
|
|
37
|
+
scope: agent
|
|
38
|
+
|
|
39
|
+
lifecycle:
|
|
40
|
+
maxConcurrent: 1
|
|
41
|
+
maxDurationMs: 60000
|
|
42
|
+
|
|
43
|
+
runtimeInject:
|
|
44
|
+
requires: ['wisdomStore', 'memoryStore']
|
|
45
|
+
|
|
46
|
+
observability:
|
|
47
|
+
eventPrefix: wisdom.steward.formation
|
|
48
|
+
|
|
49
|
+
metadata:
|
|
50
|
+
config:
|
|
51
|
+
maxItemsPerRun: 2
|
|
52
|
+
minMemorySupport: 2
|
|
53
|
+
minClusterSize: 5
|
|
54
|
+
maxEvidenceChars: 6000
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.formation — Memory/Cognition 稳定结构 → 判断范式
|
|
3
|
+
*
|
|
4
|
+
* 失败语义:缺 store/llmPort、LLM 错误、解析失败 → act.status=failed。
|
|
5
|
+
* 只写 WisdomStore(E3);不写 Memory / Cognition / 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
|
+
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 };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.formation — Memory/Cognition 稳定结构 → 判断范式
|
|
3
|
+
*
|
|
4
|
+
* 失败语义:缺 store/llmPort、LLM 错误、解析失败 → act.status=failed。
|
|
5
|
+
* 只写 WisdomStore(E3);不写 Memory / Cognition / 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 { formAndAdmit, planPromotionCandidates } from '../../../harness/memory/index.js';
|
|
12
|
+
const DEP_WISDOM = 'wisdomStore';
|
|
13
|
+
const DEP_MEMORY = 'memoryStore';
|
|
14
|
+
const DEP_CONCEPT = 'conceptGraphStore';
|
|
15
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
16
|
+
function resolveSubsystemPrompt(deps, llmPort) {
|
|
17
|
+
const fromDeps = deps?.[DEP_SUBSYSTEM_PROMPT];
|
|
18
|
+
if (typeof fromDeps === 'string' && fromDeps.trim())
|
|
19
|
+
return fromDeps;
|
|
20
|
+
if (llmPort?.cognitivePrompt?.trim())
|
|
21
|
+
return llmPort.cognitivePrompt;
|
|
22
|
+
try {
|
|
23
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
return readFileSync(join(here, 'SUBSYSTEM.md'), 'utf8');
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function failOutput(message, reason) {
|
|
31
|
+
return {
|
|
32
|
+
act: {
|
|
33
|
+
mode: 'inject',
|
|
34
|
+
status: 'failed',
|
|
35
|
+
error: message,
|
|
36
|
+
target: 'wisdom-store',
|
|
37
|
+
messages: [{ role: 'system', content: `wisdom.steward.formation.failed reason=${reason}` }],
|
|
38
|
+
},
|
|
39
|
+
signals: [{ action: 'alert', reason: message, data: { reason } }],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 聚合炼制原料:promotion 候选 + 同型 method/norm 簇。
|
|
44
|
+
*
|
|
45
|
+
* @param memoryStore - MemoryStore
|
|
46
|
+
* @param minCluster - 触发阈值
|
|
47
|
+
* @param maxChars - 证据包字符上限
|
|
48
|
+
* @returns 证据包文本与 memoryIds
|
|
49
|
+
*/
|
|
50
|
+
async function buildEvidencePack(memoryStore, minCluster, maxChars) {
|
|
51
|
+
const all = await memoryStore.listForGovern({ includeDeleted: false });
|
|
52
|
+
const alive = all.filter((e) => !e.deleted && (e.status ?? 'active') !== 'shadow');
|
|
53
|
+
const promotions = planPromotionCandidates(alive, 20);
|
|
54
|
+
// 按 type+首 tag 聚簇(代码侧选择;语义归 LLM)
|
|
55
|
+
const clusters = new Map();
|
|
56
|
+
for (const e of alive) {
|
|
57
|
+
if (e.type !== 'method' && e.type !== 'norm')
|
|
58
|
+
continue;
|
|
59
|
+
const key = `${e.type}:${e.tags[0] ?? 'general'}`;
|
|
60
|
+
const list = clusters.get(key) ?? [];
|
|
61
|
+
list.push(e);
|
|
62
|
+
clusters.set(key, list);
|
|
63
|
+
}
|
|
64
|
+
const bigClusters = [...clusters.entries()]
|
|
65
|
+
.filter(([, list]) => list.length >= minCluster)
|
|
66
|
+
.sort((a, b) => b[1].length - a[1].length)
|
|
67
|
+
.slice(0, 4);
|
|
68
|
+
const parts = [];
|
|
69
|
+
const ids = new Set();
|
|
70
|
+
if (promotions.length) {
|
|
71
|
+
parts.push('## 晋升候选(method/norm)');
|
|
72
|
+
for (const p of promotions.slice(0, 10)) {
|
|
73
|
+
parts.push(`- [${p.type}] (${p.id}) ${p.content}`);
|
|
74
|
+
ids.add(p.id);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const [key, list] of bigClusters) {
|
|
78
|
+
parts.push(`## 簇 ${key}(n=${list.length})`);
|
|
79
|
+
for (const e of list.slice(0, 8)) {
|
|
80
|
+
parts.push(`- [${e.type}] (${e.id}) ${e.content}`);
|
|
81
|
+
if (e.evidence)
|
|
82
|
+
parts.push(` 证据: ${e.evidence.slice(0, 180)}`);
|
|
83
|
+
ids.add(e.id);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let text = parts.join('\n');
|
|
87
|
+
if (text.length > maxChars)
|
|
88
|
+
text = text.slice(0, maxChars);
|
|
89
|
+
return {
|
|
90
|
+
text,
|
|
91
|
+
memoryIds: [...ids],
|
|
92
|
+
clusterHits: bigClusters.length,
|
|
93
|
+
promotionCount: promotions.length,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function handler(_input, deps) {
|
|
97
|
+
const wisdomStore = deps?.[DEP_WISDOM];
|
|
98
|
+
const memoryStore = deps?.[DEP_MEMORY];
|
|
99
|
+
if (!wisdomStore)
|
|
100
|
+
throw new Error('wisdom.steward.formation: wisdomStore not injected');
|
|
101
|
+
if (!memoryStore)
|
|
102
|
+
throw new Error('wisdom.steward.formation: memoryStore not injected');
|
|
103
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
104
|
+
const minCluster = config.minClusterSize ?? 5;
|
|
105
|
+
const maxChars = config.maxEvidenceChars ?? 6000;
|
|
106
|
+
const maxItems = config.maxItemsPerRun ?? 2;
|
|
107
|
+
const dryRun = config.dryRun ?? false;
|
|
108
|
+
const minPromotionStack = config.minPromotionStack ?? 3;
|
|
109
|
+
const pack = await buildEvidencePack(memoryStore, minCluster, maxChars);
|
|
110
|
+
// 触发器(防「见者有份」):真实簇 或 晋升候选堆叠;仅有零散材料不打 LLM
|
|
111
|
+
const hasCluster = pack.clusterHits > 0;
|
|
112
|
+
const hasStackedPromotions = pack.promotionCount >= minPromotionStack;
|
|
113
|
+
if (!pack.text.trim() || pack.memoryIds.length < (config.minMemorySupport ?? 2) || (!hasCluster && !hasStackedPromotions)) {
|
|
114
|
+
return {
|
|
115
|
+
act: {
|
|
116
|
+
mode: 'inject',
|
|
117
|
+
status: 'success',
|
|
118
|
+
target: 'wisdom-store',
|
|
119
|
+
messages: [{
|
|
120
|
+
role: 'system',
|
|
121
|
+
content: `wisdom.steward.formation.skipped reason=no_trigger memoryIds=${pack.memoryIds.length} ` +
|
|
122
|
+
`clusters=${pack.clusterHits} promotions=${pack.promotionCount}`,
|
|
123
|
+
}],
|
|
124
|
+
},
|
|
125
|
+
signals: [{
|
|
126
|
+
action: 'suggest',
|
|
127
|
+
reason: 'no_trigger',
|
|
128
|
+
data: {
|
|
129
|
+
memoryIds: pack.memoryIds.length,
|
|
130
|
+
clusterHits: pack.clusterHits,
|
|
131
|
+
promotionCount: pack.promotionCount,
|
|
132
|
+
},
|
|
133
|
+
}],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const llmPort = deps?.[DEP_LLM_PORT];
|
|
137
|
+
if (!llmPort?.chat) {
|
|
138
|
+
return failOutput('llmPort missing', 'llm_port_missing');
|
|
139
|
+
}
|
|
140
|
+
const systemPrompt = resolveSubsystemPrompt(deps, llmPort);
|
|
141
|
+
// 概念线索(可选;缺失不失败)
|
|
142
|
+
let conceptHint = '';
|
|
143
|
+
const conceptStore = deps?.[DEP_CONCEPT];
|
|
144
|
+
if (conceptStore) {
|
|
145
|
+
try {
|
|
146
|
+
const graph = await conceptStore.getFullGraph();
|
|
147
|
+
const names = graph.nodes
|
|
148
|
+
.filter((n) => n.status !== 'shadow')
|
|
149
|
+
.slice(0, 20)
|
|
150
|
+
.map((n) => n.name);
|
|
151
|
+
if (names.length)
|
|
152
|
+
conceptHint = `\n概念线索: ${names.join('、')}`;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// 图不可用不阻断炼制
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let llmText = '';
|
|
159
|
+
try {
|
|
160
|
+
const res = await llmPort.chat({
|
|
161
|
+
systemPrompt: systemPrompt || undefined,
|
|
162
|
+
messages: [{ role: 'user', content: `${pack.text}${conceptHint}` }],
|
|
163
|
+
temperature: 0.3,
|
|
164
|
+
maxTokens: 2048,
|
|
165
|
+
});
|
|
166
|
+
if (res.finishReason === 'error') {
|
|
167
|
+
return failOutput(res.content || 'llm chat error', 'llm_error');
|
|
168
|
+
}
|
|
169
|
+
llmText = res.content ?? '';
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
return failOutput(err instanceof Error ? err.message : String(err), 'llm_error');
|
|
173
|
+
}
|
|
174
|
+
const allowedMemoryIds = new Set(pack.memoryIds);
|
|
175
|
+
const { results, droppedNotes } = await formAndAdmit(llmText, wisdomStore, {
|
|
176
|
+
origin: 'distilled',
|
|
177
|
+
maxItems,
|
|
178
|
+
allowedMemoryIds,
|
|
179
|
+
dryRun,
|
|
180
|
+
});
|
|
181
|
+
const created = results.filter((r) => r.action === 'created' || r.action === 'superseded');
|
|
182
|
+
const rejected = results.filter((r) => r.action === 'rejected');
|
|
183
|
+
return {
|
|
184
|
+
act: {
|
|
185
|
+
mode: 'inject',
|
|
186
|
+
status: 'success',
|
|
187
|
+
target: 'wisdom-store',
|
|
188
|
+
messages: [{
|
|
189
|
+
role: 'system',
|
|
190
|
+
content: `wisdom.steward.formed created=${created.length} rejected=${rejected.length} ` +
|
|
191
|
+
`dropped=${droppedNotes.length} dryRun=${dryRun}`,
|
|
192
|
+
}],
|
|
193
|
+
},
|
|
194
|
+
signals: [{
|
|
195
|
+
action: 'suggest',
|
|
196
|
+
reason: 'formation_completed',
|
|
197
|
+
data: {
|
|
198
|
+
created: created.map((r) => r.id),
|
|
199
|
+
rejected: rejected.map((r) => ({ reason: r.reason, message: r.message })),
|
|
200
|
+
droppedNotes,
|
|
201
|
+
sourceMemoryIds: pack.memoryIds.slice(0, 30),
|
|
202
|
+
dryRun,
|
|
203
|
+
},
|
|
204
|
+
}],
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export default {
|
|
208
|
+
handler,
|
|
209
|
+
contract: { input: 'WisdomFormationInput', output: 'WisdomFormationResult' },
|
|
210
|
+
dependencies: [DEP_WISDOM, DEP_MEMORY],
|
|
211
|
+
};
|
|
212
|
+
export { handler };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
id: wisdom.steward.govern
|
|
2
|
+
name: Wisdom Steward Govern
|
|
3
|
+
description: 范式库治理:零应用衰减、容量演化、软退休(不污染主会话)
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: schedule
|
|
7
|
+
interval: 3600000
|
|
8
|
+
filter:
|
|
9
|
+
condition: "true"
|
|
10
|
+
events: ['wisdom.steward.govern.request']
|
|
11
|
+
emits: ['wisdom.steward.governed']
|
|
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: ['wisdomStore']
|
|
44
|
+
|
|
45
|
+
observability:
|
|
46
|
+
eventPrefix: wisdom.steward.govern
|
|
47
|
+
|
|
48
|
+
metadata:
|
|
49
|
+
config:
|
|
50
|
+
dryRun: false
|
|
51
|
+
softCap: 50
|
|
52
|
+
hardCap: 80
|
|
53
|
+
zeroApplyIdleMs: 2592000000
|
|
54
|
+
priorityDecayStep: 5
|
|
55
|
+
priorityFloor: 5
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.govern — 零应用衰减 + 容量演化 + 软退休
|
|
3
|
+
*
|
|
4
|
+
* 只写 WisdomStore;可 dryRun。不写 Memory / Cognition。
|
|
5
|
+
*/
|
|
6
|
+
import type { SubsystemInput, SubsystemOutput, InjectedDependencies } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/types.js';
|
|
7
|
+
declare function handler(_input: SubsystemInput, deps?: InjectedDependencies): Promise<SubsystemOutput>;
|
|
8
|
+
declare const _default: {
|
|
9
|
+
handler: typeof handler;
|
|
10
|
+
contract: {
|
|
11
|
+
input: string;
|
|
12
|
+
output: string;
|
|
13
|
+
};
|
|
14
|
+
dependencies: string[];
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
17
|
+
export { handler };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.govern — 零应用衰减 + 容量演化 + 软退休
|
|
3
|
+
*
|
|
4
|
+
* 只写 WisdomStore;可 dryRun。不写 Memory / Cognition。
|
|
5
|
+
*/
|
|
6
|
+
import { planWisdomGovern, wisdomUtility, } from '../../../harness/memory/wisdom-policy.js';
|
|
7
|
+
const DEP_WISDOM = 'wisdomStore';
|
|
8
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
9
|
+
async function handler(_input, deps) {
|
|
10
|
+
const store = deps?.[DEP_WISDOM];
|
|
11
|
+
if (!store)
|
|
12
|
+
throw new Error('wisdom.steward.govern: wisdomStore not injected');
|
|
13
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
14
|
+
const dryRun = config.dryRun ?? false;
|
|
15
|
+
const entries = await store.listForGovern({ includeRetired: false });
|
|
16
|
+
const plan = planWisdomGovern(entries, config);
|
|
17
|
+
let decayed = 0;
|
|
18
|
+
let retired = 0;
|
|
19
|
+
if (!dryRun) {
|
|
20
|
+
for (const item of plan) {
|
|
21
|
+
if (item.action === 'decay_priority' && item.priority != null) {
|
|
22
|
+
await store.update(item.id, { priority: item.priority });
|
|
23
|
+
decayed++;
|
|
24
|
+
}
|
|
25
|
+
else if (item.action === 'retire') {
|
|
26
|
+
await store.softRetire(item.id, { by: 'wisdom.steward.govern', reason: item.reason });
|
|
27
|
+
retired++;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
decayed = plan.filter((p) => p.action === 'decay_priority').length;
|
|
33
|
+
retired = plan.filter((p) => p.action === 'retire').length;
|
|
34
|
+
}
|
|
35
|
+
const stats = await store.stats();
|
|
36
|
+
return {
|
|
37
|
+
act: {
|
|
38
|
+
mode: 'inject',
|
|
39
|
+
status: 'success',
|
|
40
|
+
target: 'wisdom-store',
|
|
41
|
+
messages: [{
|
|
42
|
+
role: 'system',
|
|
43
|
+
content: `wisdom.steward.governed decayed=${decayed} retired=${retired} total=${stats.total} ` +
|
|
44
|
+
`live=${stats.byStatus.trial + stats.byStatus.active + stats.byStatus.strengthened} dryRun=${dryRun}`,
|
|
45
|
+
}],
|
|
46
|
+
},
|
|
47
|
+
signals: [{
|
|
48
|
+
action: 'suggest',
|
|
49
|
+
reason: 'govern_completed',
|
|
50
|
+
data: {
|
|
51
|
+
decayed,
|
|
52
|
+
retired,
|
|
53
|
+
dryRun,
|
|
54
|
+
plan: plan.slice(0, 30),
|
|
55
|
+
stats,
|
|
56
|
+
utilities: entries
|
|
57
|
+
.slice(0, 10)
|
|
58
|
+
.map((e) => ({ id: e.id, utility: wisdomUtility(e), status: e.status })),
|
|
59
|
+
},
|
|
60
|
+
}],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export default {
|
|
64
|
+
handler,
|
|
65
|
+
contract: { input: 'WisdomGovernInput', output: 'WisdomGovernResult' },
|
|
66
|
+
dependencies: [DEP_WISDOM],
|
|
67
|
+
};
|
|
68
|
+
export { handler };
|