@octopi-agent/engine 0.97.15 → 0.102.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-schema/agent.d.ts +37 -5
- package/dist/config-schema/agent.js +24 -4
- package/dist/config-schema/context.d.ts +6 -36
- package/dist/config-schema/context.js +4 -28
- package/dist/config-schema/engine.d.ts +61 -160
- package/dist/config-schema/engine.js +1 -5
- package/dist/config-schema/governance.d.ts +10 -1
- package/dist/config-schema/governance.js +38 -1
- package/dist/config-schema/models.d.ts +2 -8
- package/dist/config-schema/models.js +0 -2
- package/dist/config-schema/run.d.ts +2 -2
- package/dist/config-schema/run.js +2 -2
- package/dist/config-schema/shared.d.ts +0 -3
- package/dist/config-schema/shared.js +0 -2
- package/dist/config-schema/substrate.d.ts +14 -88
- package/dist/config-schema/substrate.js +22 -107
- package/dist/config.d.ts +45 -113
- package/dist/config.js +8 -2
- package/dist/harness/activation/dispatcher.js +7 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/runtime.js +13 -5
- package/dist/harness/activation/types.d.ts +2 -2
- package/dist/harness/agent/builder.d.ts +34 -2
- package/dist/harness/agent/builder.js +189 -58
- package/dist/harness/agent/config-bridge.js +9 -2
- package/dist/harness/agent/config-integrity.d.ts +66 -0
- package/dist/harness/agent/config-integrity.js +108 -2
- package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
- package/dist/harness/agent/wire-agent-builder.js +31 -7
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- package/dist/harness/collaboration/autonomous-subsystem/index.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +21 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.d.ts +40 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.js +59 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +2 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +12 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
- package/dist/harness/collaboration/delegation/child-run.js +4 -4
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/service.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.js +2 -1
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +2 -1
- package/dist/harness/collaboration/delegation/types.d.ts +23 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.js +11 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +0 -6
- package/dist/harness/context/capabilities/compact/engine.js +169 -121
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +5 -1
- package/dist/harness/context/capabilities/compact/index.js +4 -0
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +76 -11
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +4 -9
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/types.d.ts +4 -7
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +236 -0
- package/dist/harness/context/default-context-engine.d.ts +195 -119
- package/dist/harness/context/default-context-engine.js +1241 -743
- package/dist/harness/context/index.d.ts +2 -2
- package/dist/harness/context/index.js +1 -1
- package/dist/harness/context/layer-types.d.ts +15 -0
- package/dist/harness/context/layer-types.js +14 -1
- package/dist/harness/context/layers.d.ts +16 -19
- package/dist/harness/context/layers.js +42 -14
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/summarize.d.ts +3 -3
- package/dist/harness/context/summarize.js +11 -4
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +3 -1
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +6 -1
- package/dist/harness/context/tool-result-aging.js +16 -5
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +127 -117
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +24 -2
- package/dist/harness/extension/execution-environment/effect-policy.js +30 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +7 -3
- package/dist/harness/extension/execution-environment/ops-audit.js +11 -12
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/undo-log.d.ts +6 -2
- package/dist/harness/extension/execution-environment/undo-log.js +31 -10
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +83 -249
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +50 -117
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +17 -24
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +3 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +3 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +9 -5
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +9 -130
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +122 -14
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +4 -13
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +25 -11
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +168 -62
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +11 -2
- package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-risk-policy.d.ts +1 -0
- package/dist/harness/governance/security/default-risk-policy.js +1 -0
- package/dist/harness/governance/security/default-security-guard.js +9 -0
- package/dist/harness/governance/security/index.d.ts +1 -0
- package/dist/harness/governance/security/index.js +2 -0
- package/dist/harness/governance/security/risk-evaluator.js +13 -0
- package/dist/harness/governance/security/risk-types.d.ts +12 -0
- package/dist/harness/governance/security/shell-parser-fallback.d.ts +29 -0
- package/dist/harness/governance/security/shell-parser-fallback.js +410 -0
- package/dist/harness/governance/security/shell-parser-shared.d.ts +83 -0
- package/dist/harness/governance/security/shell-parser-shared.js +188 -0
- package/dist/harness/governance/security/shell-parser-treesitter.d.ts +52 -0
- package/dist/harness/governance/security/shell-parser-treesitter.js +370 -0
- package/dist/harness/governance/security/shell-parser.d.ts +23 -10
- package/dist/harness/governance/security/shell-parser.js +37 -496
- package/dist/harness/governance/security/vendor/README.md +24 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.LICENSE.txt +21 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.wasm +0 -0
- package/dist/harness/index.d.ts +12 -12
- package/dist/harness/index.js +7 -7
- package/dist/harness/knowledge/boot-config.d.ts +55 -0
- package/dist/harness/knowledge/boot-config.js +50 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +24 -2
- package/dist/harness/knowledge/client.js +19 -5
- package/dist/harness/knowledge/db.js +5 -0
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +6 -0
- package/dist/harness/knowledge/grounding.js +3 -1
- package/dist/harness/knowledge/http-app.js +35 -4
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +3 -0
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +13 -2
- package/dist/harness/knowledge/query-service.js +4 -2
- package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -2
- package/dist/harness/knowledge/query-worker.js +4 -2
- package/dist/harness/knowledge/read-http.js +5 -1
- package/dist/harness/knowledge/serve.d.ts +8 -7
- package/dist/harness/knowledge/serve.js +9 -0
- package/dist/harness/knowledge/source-store.js +26 -3
- package/dist/harness/knowledge/start-service-process.d.ts +15 -7
- package/dist/harness/knowledge/start-service-process.js +21 -9
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +37 -9
- package/dist/harness/knowledge/writer-service.js +120 -14
- package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
- package/dist/harness/knowledge/writer-worker-client.js +20 -2
- package/dist/harness/knowledge/writer-worker.js +9 -1
- package/dist/harness/memory/index.d.ts +6 -2
- package/dist/harness/memory/index.js +4 -1
- package/dist/harness/memory/memory-events.d.ts +25 -0
- package/dist/harness/memory/memory-events.js +38 -0
- package/dist/harness/memory/sqlite/agent-db.js +15 -0
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +7 -2
- package/dist/harness/memory/sqlite/wisdom-store.js +86 -12
- package/dist/harness/memory/steward-policy.d.ts +3 -0
- package/dist/harness/memory/steward-policy.js +1 -1
- package/dist/harness/memory/types.d.ts +47 -7
- package/dist/harness/memory/wisdom-attribution.d.ts +136 -0
- package/dist/harness/memory/wisdom-attribution.js +287 -0
- package/dist/harness/memory/wisdom-events.d.ts +37 -0
- package/dist/harness/memory/wisdom-events.js +61 -0
- package/dist/harness/memory/wisdom-formation.d.ts +31 -1
- package/dist/harness/memory/wisdom-formation.js +130 -33
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.d.ts +7 -2
- package/dist/harness/memory/wisdom.js +49 -2
- package/dist/harness/observability/observer/hub.js +25 -15
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +66 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +10 -4
- package/dist/harness/run/reliability/run-agent.js +137 -53
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- package/dist/harness/run/run-scope.d.ts +41 -4
- package/dist/harness/run/runner.d.ts +71 -31
- package/dist/harness/run/runner.js +368 -106
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- package/dist/harness/session/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +2 -2
- package/dist/harness/shared/events/agent-event-map.d.ts +46 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/paths/glob.d.ts +52 -0
- package/dist/harness/shared/paths/glob.js +218 -0
- package/dist/harness/shared/paths/index.d.ts +84 -0
- package/dist/harness/shared/paths/index.js +179 -0
- package/dist/harness/shared/types/agent-definition.d.ts +1 -2
- package/dist/index.d.ts +14 -17
- package/dist/index.js +7 -9
- package/dist/integration/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- package/dist/integration/providers/anthropic.js +14 -1
- package/dist/integration/providers/openai.js +7 -1
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump.d.ts +1 -1
- package/dist/integration/storage/archive-manager.d.ts +6 -0
- package/dist/integration/storage/archive-manager.js +10 -0
- package/dist/integration/storage/jsonl.d.ts +1 -1
- package/dist/integration/storage/jsonl.js +18 -16
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +4 -2
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +12 -20
- package/dist/subsystems/memory-steward/backfill/config.yaml +4 -2
- package/dist/subsystems/memory-steward/backfill/handler.js +44 -52
- package/dist/subsystems/wisdom-steward/attribute/SUBSYSTEM.md +24 -0
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +60 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.d.ts +23 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.js +167 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +3 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +13 -5
- package/dist/subsystems/wisdom-steward/formation/handler.js +39 -23
- package/dist/subsystems/wisdom-steward/govern/config.yaml +1 -1
- package/dist/subsystems/wisdom-steward/govern/handler.js +4 -0
- package/package.json +16 -14
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -36,11 +36,12 @@ session:
|
|
|
36
36
|
|
|
37
37
|
lifecycle:
|
|
38
38
|
maxConcurrent: 1
|
|
39
|
-
maxDurationMs:
|
|
39
|
+
maxDurationMs: 120000
|
|
40
40
|
|
|
41
41
|
runtimeInject:
|
|
42
42
|
# backfillCoverage 可选:未注入时 handler 跳过覆盖回写(协调器仍可自记 pending)
|
|
43
|
-
|
|
43
|
+
# eventBus 可选:memory.stored 增量信号(未注入时静默跳过)
|
|
44
|
+
requires: ['memoryStore', 'sessionStore', 'constitution', 'backfillCoverage', 'eventBus']
|
|
44
45
|
|
|
45
46
|
observability:
|
|
46
47
|
eventPrefix: memory.steward.backfill
|
|
@@ -48,4 +49,5 @@ observability:
|
|
|
48
49
|
metadata:
|
|
49
50
|
config:
|
|
50
51
|
maxCandidatesPerSession: 8
|
|
52
|
+
maxTokens: 8192
|
|
51
53
|
maxEvidenceChars: 8000
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { readFileSync } from 'node:fs';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
-
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
10
|
+
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, chatForCompleteOutput, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
11
11
|
import { admitCandidates } from '../../../harness/memory/steward-policy.js';
|
|
12
12
|
import { measureSessionDensity, } from '@octopi-agent/engine/harness/memory/backfill-coverage.js';
|
|
13
13
|
const DEP_MEMORY_STORE = 'memoryStore';
|
|
@@ -248,67 +248,59 @@ async function handler(input, deps) {
|
|
|
248
248
|
? `\n## Operating constitution (extract under these rules)\n${constitution.slice(0, 4000)}\n`
|
|
249
249
|
: '';
|
|
250
250
|
const systemPrompt = `${subsystemPrompt}${constitutionBlock}`.trim() || undefined;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (res.finishReason === 'error') {
|
|
263
|
-
await markCoverage(deps, {
|
|
264
|
-
sessionId,
|
|
265
|
-
agentId,
|
|
266
|
-
fingerprint: coverageFingerprint,
|
|
267
|
-
status: 'failed',
|
|
268
|
-
reason: 'llm_error',
|
|
269
|
-
trigger: triggerKind,
|
|
270
|
-
});
|
|
271
|
-
return failOutput('llm_error', res.content || 'backfill failed: LLM chat error', sessionId, { agentId });
|
|
272
|
-
}
|
|
273
|
-
rawContent = res.content ?? '';
|
|
274
|
-
}
|
|
275
|
-
catch (err) {
|
|
276
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
277
|
-
await markCoverage(deps, {
|
|
278
|
-
sessionId,
|
|
279
|
-
agentId,
|
|
280
|
-
fingerprint: coverageFingerprint,
|
|
281
|
-
status: 'failed',
|
|
282
|
-
reason: 'llm_error',
|
|
283
|
-
trigger: triggerKind,
|
|
284
|
-
});
|
|
285
|
-
return failOutput('llm_error', `backfill failed: ${msg}`, sessionId, { agentId });
|
|
286
|
-
}
|
|
287
|
-
if (!rawContent.trim()) {
|
|
288
|
-
await markCoverage(deps, {
|
|
289
|
-
sessionId,
|
|
290
|
-
agentId,
|
|
291
|
-
fingerprint: coverageFingerprint,
|
|
292
|
-
status: 'failed',
|
|
293
|
-
reason: 'llm_empty',
|
|
294
|
-
trigger: triggerKind,
|
|
295
|
-
});
|
|
296
|
-
return failOutput('llm_empty', 'backfill failed: empty LLM content', sessionId, { agentId });
|
|
297
|
-
}
|
|
298
|
-
const parsed = extractJsonArray(rawContent);
|
|
299
|
-
if (!parsed) {
|
|
251
|
+
// maxTokens 只是生成配额(LLM 传参):截断(finish=length)或解析失败都放大配额重试
|
|
252
|
+
// 一次,仍失败显式上报——业务完整性优先,禁止静默半截结果
|
|
253
|
+
const outcome = await chatForCompleteOutput(llmPort, {
|
|
254
|
+
systemPrompt,
|
|
255
|
+
messages: [{
|
|
256
|
+
role: 'user',
|
|
257
|
+
content: `## Session evidence (session=${sessionId})\n${sessionText}\n\nExtract long-term memory propositions. Output strict JSON array only.`,
|
|
258
|
+
}],
|
|
259
|
+
maxTokens: config.maxTokens ?? 8192,
|
|
260
|
+
}, (text) => extractJsonArray(text));
|
|
261
|
+
if (!outcome.ok) {
|
|
300
262
|
await markCoverage(deps, {
|
|
301
263
|
sessionId,
|
|
302
264
|
agentId,
|
|
303
265
|
fingerprint: coverageFingerprint,
|
|
304
266
|
status: 'failed',
|
|
305
|
-
reason:
|
|
267
|
+
reason: outcome.reason,
|
|
306
268
|
trigger: triggerKind,
|
|
307
269
|
});
|
|
308
|
-
return failOutput(
|
|
270
|
+
return failOutput(outcome.reason, `backfill failed: ${outcome.message}`, sessionId, { agentId });
|
|
309
271
|
}
|
|
272
|
+
const parsed = outcome.parsed;
|
|
310
273
|
const candidates = parseCandidates(parsed, maxCandidates);
|
|
311
274
|
const result = await admitCandidates(memoryStore, candidates, `session:${sessionId};via:backfill`);
|
|
275
|
+
// 每条新记忆发 memory.stored(wisdom.steward.formation 增量触发)+
|
|
276
|
+
// cognition.conceptualize.request(概念化触发);信号失败不得拖垮 backfill 主流程
|
|
277
|
+
try {
|
|
278
|
+
const { emitMemoryStored } = await import('../../../harness/memory/memory-events.js');
|
|
279
|
+
const { emitConceptualizeRequest } = await import('../../../harness/memory/cognition-trigger.js');
|
|
280
|
+
const eventBus = deps?.eventBus;
|
|
281
|
+
for (const item of result.accepted) {
|
|
282
|
+
emitMemoryStored(eventBus, {
|
|
283
|
+
memoryId: item.id,
|
|
284
|
+
type: item.type,
|
|
285
|
+
status: item.status,
|
|
286
|
+
sessionId,
|
|
287
|
+
agentId,
|
|
288
|
+
});
|
|
289
|
+
emitConceptualizeRequest(eventBus, {
|
|
290
|
+
memoryId: item.id,
|
|
291
|
+
proposition: item.proposition,
|
|
292
|
+
evidence: item.evidence ?? '',
|
|
293
|
+
memoryType: item.type,
|
|
294
|
+
memoryStatus: item.status,
|
|
295
|
+
channel: item.channel,
|
|
296
|
+
sessionId,
|
|
297
|
+
agentId,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// 模块加载/总线异常:跳过信号,admit 结果照常上报
|
|
303
|
+
}
|
|
312
304
|
await markCoverage(deps, {
|
|
313
305
|
sessionId,
|
|
314
306
|
agentId,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# wisdom.steward.attribute
|
|
2
|
+
|
|
3
|
+
你是**判断范式(maxim)的弱归因判官**。输入是若干「范式 × 任务窗口」候选(digest),你判断每个候选里范式在该窗口**是否真的起了作用**。
|
|
4
|
+
|
|
5
|
+
## 证据标准
|
|
6
|
+
|
|
7
|
+
- **assisted**:引用摘录显示范式真实影响了决策/行为——推理中引用其 id 或整句、按其姿态行动且改变了走向。任务结局只是辅助上下文。
|
|
8
|
+
- **contested**:有明确反例——摘录显示范式把方向带错,或其后出现与范式相反的事实/用户纠正。
|
|
9
|
+
- **unclear**:证据不足(仅在墙上、例行公事式引用、摘录看不出影响)。**宁可不判也不污染**。
|
|
10
|
+
|
|
11
|
+
任务成功 ≠ 范式有功;任务失败 ≠ 范式有过。只依据摘录中的行为证据下判断。
|
|
12
|
+
|
|
13
|
+
## 输出 JSON(只输出 JSON)
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"items": [
|
|
18
|
+
{ "pair": 1, "verdict": "assisted", "reason": "一句话依据" },
|
|
19
|
+
{ "pair": 2, "verdict": "unclear" }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
硬规则:每个候选有且仅有一条判决;`verdict` ∈ `assisted | contested | unclear`;`pair` 用候选的 P 序号;无证据就判 `unclear`,不要硬凑。
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
id: wisdom.steward.attribute
|
|
2
|
+
name: Wisdom Steward Attribute
|
|
3
|
+
description: 弱归因判决:归因窗口 digest 批量 LLM 判决(assisted/contested/unclear),判决事件交 evaluate 入账
|
|
4
|
+
|
|
5
|
+
sense:
|
|
6
|
+
source: schedule
|
|
7
|
+
# 每日一次兜底脉搏;挂 govern 脉搏(governed 事件)+ 显式 attribute.request 增量触发
|
|
8
|
+
interval: 86400000
|
|
9
|
+
runOnStart: false
|
|
10
|
+
cooldownMs: 86400000
|
|
11
|
+
filter:
|
|
12
|
+
condition: "true"
|
|
13
|
+
events: ['wisdom.steward.governed', 'wisdom.steward.attribute.request']
|
|
14
|
+
emits: ['wisdom.steward.attributed', 'wisdom.steward.attribute.failed', 'wisdom.steward.evaluate.request']
|
|
15
|
+
isolation: isolated
|
|
16
|
+
|
|
17
|
+
think:
|
|
18
|
+
# code = 调 handler.ts 确定性实现(digest 构建 + LLM 判决解析;判决语义归 LLM)
|
|
19
|
+
implementation: code
|
|
20
|
+
strategy: deterministic
|
|
21
|
+
model: mini
|
|
22
|
+
maxIterations: 1
|
|
23
|
+
|
|
24
|
+
act:
|
|
25
|
+
mode: inject
|
|
26
|
+
|
|
27
|
+
signal:
|
|
28
|
+
severity: info
|
|
29
|
+
channel: [event]
|
|
30
|
+
|
|
31
|
+
boundary:
|
|
32
|
+
visibility: isolated
|
|
33
|
+
authority: act
|
|
34
|
+
security: trusted
|
|
35
|
+
|
|
36
|
+
tools:
|
|
37
|
+
mode: none
|
|
38
|
+
|
|
39
|
+
session:
|
|
40
|
+
mode: ephemeral
|
|
41
|
+
scope: agent
|
|
42
|
+
|
|
43
|
+
lifecycle:
|
|
44
|
+
maxConcurrent: 1
|
|
45
|
+
maxDurationMs: 120000
|
|
46
|
+
|
|
47
|
+
runtimeInject:
|
|
48
|
+
requires: ['wisdomStore', 'eventBus']
|
|
49
|
+
|
|
50
|
+
observability:
|
|
51
|
+
eventPrefix: wisdom.steward.attribute
|
|
52
|
+
|
|
53
|
+
metadata:
|
|
54
|
+
config:
|
|
55
|
+
dryRun: false
|
|
56
|
+
maxPairs: 40
|
|
57
|
+
sampleMax: 2
|
|
58
|
+
maxWindows: 500
|
|
59
|
+
maxTokens: 4096
|
|
60
|
+
windowRetentionMs: 2592000000
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.attribute — 弱归因判决(digest 批量 LLM 判决)
|
|
3
|
+
*
|
|
4
|
+
* 输入:归因窗口(run 收尾记账);判决只出自 LLM(digest + 引用摘录)。
|
|
5
|
+
* 输出:assisted/contested 事件 → `wisdom.steward.evaluate.request`(evaluate 入账)。
|
|
6
|
+
* 失败语义:缺 store/llmPort、LLM 错误、解析失败/覆盖率不符 → act.status=failed,
|
|
7
|
+
* **窗口保持 pending**(下批再判);宁可整批失败重试,不静默吞窗口。
|
|
8
|
+
* 只写 WisdomStore(E3);不写 Memory / Cognition / Knowledge。
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { SubsystemInput, SubsystemOutput, InjectedDependencies } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/types.js';
|
|
13
|
+
declare function handler(_input: SubsystemInput, deps?: InjectedDependencies): Promise<SubsystemOutput>;
|
|
14
|
+
declare const _default: {
|
|
15
|
+
handler: typeof handler;
|
|
16
|
+
contract: {
|
|
17
|
+
input: string;
|
|
18
|
+
output: string;
|
|
19
|
+
};
|
|
20
|
+
dependencies: string[];
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
23
|
+
export { handler };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wisdom.steward.attribute — 弱归因判决(digest 批量 LLM 判决)
|
|
3
|
+
*
|
|
4
|
+
* 输入:归因窗口(run 收尾记账);判决只出自 LLM(digest + 引用摘录)。
|
|
5
|
+
* 输出:assisted/contested 事件 → `wisdom.steward.evaluate.request`(evaluate 入账)。
|
|
6
|
+
* 失败语义:缺 store/llmPort、LLM 错误、解析失败/覆盖率不符 → act.status=failed,
|
|
7
|
+
* **窗口保持 pending**(下批再判);宁可整批失败重试,不静默吞窗口。
|
|
8
|
+
* 只写 WisdomStore(E3);不写 Memory / Cognition / Knowledge。
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from 'node:fs';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, chatForCompleteOutput, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
16
|
+
import { buildAttributionDigest, emitWisdomEvaluateRequest, parseAttributionVerdicts, planAttributionBatch, verdictsToOutcomeEvents, } from '../../../harness/memory/index.js';
|
|
17
|
+
const DEP_WISDOM = 'wisdomStore';
|
|
18
|
+
const DEP_EVENT_BUS = 'eventBus';
|
|
19
|
+
const DEP_CONFIG = '__subsystem_config__';
|
|
20
|
+
function resolveSubsystemPrompt(deps, llmPort) {
|
|
21
|
+
const fromDeps = deps?.[DEP_SUBSYSTEM_PROMPT];
|
|
22
|
+
if (typeof fromDeps === 'string' && fromDeps.trim())
|
|
23
|
+
return fromDeps;
|
|
24
|
+
if (llmPort?.cognitivePrompt?.trim())
|
|
25
|
+
return llmPort.cognitivePrompt;
|
|
26
|
+
try {
|
|
27
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
return readFileSync(join(here, 'SUBSYSTEM.md'), 'utf8');
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function failOutput(message, reason) {
|
|
35
|
+
return {
|
|
36
|
+
act: {
|
|
37
|
+
mode: 'inject',
|
|
38
|
+
status: 'failed',
|
|
39
|
+
error: message,
|
|
40
|
+
target: 'wisdom-store',
|
|
41
|
+
messages: [{ role: 'system', content: `wisdom.steward.attribute.failed reason=${reason}` }],
|
|
42
|
+
},
|
|
43
|
+
signals: [{ action: 'alert', reason: message, data: { reason } }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function skipOutput(detail, data) {
|
|
47
|
+
return {
|
|
48
|
+
act: {
|
|
49
|
+
mode: 'inject',
|
|
50
|
+
status: 'success',
|
|
51
|
+
target: 'wisdom-store',
|
|
52
|
+
messages: [{ role: 'system', content: `wisdom.steward.attribute.skipped ${detail}` }],
|
|
53
|
+
},
|
|
54
|
+
signals: [{ action: 'suggest', reason: 'attribute_skipped', data }],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function handler(_input, deps) {
|
|
58
|
+
const wisdomStore = deps?.[DEP_WISDOM];
|
|
59
|
+
if (!wisdomStore)
|
|
60
|
+
throw new Error('wisdom.steward.attribute: wisdomStore not injected');
|
|
61
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
62
|
+
const dryRun = config.dryRun ?? false;
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
// 保留期清理放入口:所有退出路径都执行(含提前返回/失败)
|
|
65
|
+
if (!dryRun) {
|
|
66
|
+
await wisdomStore.pruneWindows(now - (config.windowRetentionMs ?? 2592000000));
|
|
67
|
+
}
|
|
68
|
+
const windows = await wisdomStore.listPendingWindows(config.maxWindows ?? 500);
|
|
69
|
+
if (windows.length === 0)
|
|
70
|
+
return skipOutput('reason=no_pending_windows', {});
|
|
71
|
+
const alive = await wisdomStore.listForGovern({ includeRetired: false });
|
|
72
|
+
const batch = planAttributionBatch(windows, alive, {
|
|
73
|
+
sampleMax: config.sampleMax ?? 2,
|
|
74
|
+
maxPairs: config.maxPairs ?? 40,
|
|
75
|
+
});
|
|
76
|
+
if (batch.selected.length === 0) {
|
|
77
|
+
// 无候选或抽样未中:按设计关闭(判无可判);被 maxPairs 推迟的保持 pending
|
|
78
|
+
if (!dryRun)
|
|
79
|
+
await wisdomStore.markWindowsJudged(batch.closableWindowIds, now);
|
|
80
|
+
return skipOutput(`reason=no_candidates windows=${windows.length} closed=${batch.closableWindowIds.length} deferred=${batch.deferredWindowIds.length}`, {
|
|
81
|
+
windows: windows.length,
|
|
82
|
+
closedNoCandidate: batch.closableWindowIds.length,
|
|
83
|
+
cutByMaxPairs: batch.deferredWindowIds.length,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const llmPort = deps?.[DEP_LLM_PORT];
|
|
87
|
+
if (!llmPort?.chat)
|
|
88
|
+
return failOutput('llmPort missing', 'llm_port_missing');
|
|
89
|
+
const { text: digest, pairRefs } = buildAttributionDigest(batch.selected);
|
|
90
|
+
const expectedPairs = batch.selected.map((_, i) => i + 1);
|
|
91
|
+
const outcome = await chatForCompleteOutput(llmPort, {
|
|
92
|
+
systemPrompt: resolveSubsystemPrompt(deps, llmPort) || undefined,
|
|
93
|
+
messages: [{ role: 'user', content: digest }],
|
|
94
|
+
maxTokens: config.maxTokens ?? 4096,
|
|
95
|
+
}, (text) => parseAttributionVerdicts(text, expectedPairs));
|
|
96
|
+
// parse_failed 已含覆盖率不符(缺项/重复/空 items):窗口保持 pending,下批再判
|
|
97
|
+
if (!outcome.ok)
|
|
98
|
+
return failOutput(outcome.message, outcome.reason);
|
|
99
|
+
const verdicts = outcome.parsed.items;
|
|
100
|
+
const events = verdictsToOutcomeEvents(verdicts, pairRefs, now);
|
|
101
|
+
const judgeWindowIds = [...new Set(batch.selected.map((c) => c.window.id))];
|
|
102
|
+
const closeIds = [...new Set([...judgeWindowIds, ...batch.closableWindowIds])];
|
|
103
|
+
if (dryRun) {
|
|
104
|
+
// 演练:不标记、不发事件、不清理——一切消费性操作全关
|
|
105
|
+
return {
|
|
106
|
+
act: {
|
|
107
|
+
mode: 'inject',
|
|
108
|
+
status: 'success',
|
|
109
|
+
target: 'wisdom-store',
|
|
110
|
+
messages: [{
|
|
111
|
+
role: 'system',
|
|
112
|
+
content: `wisdom.steward.attributed dryRun=true pairs=${batch.selected.length} ` +
|
|
113
|
+
`events=${events.length} deferred=${batch.deferredWindowIds.length}`,
|
|
114
|
+
}],
|
|
115
|
+
},
|
|
116
|
+
signals: [{
|
|
117
|
+
action: 'suggest',
|
|
118
|
+
reason: 'attribute_dry_run',
|
|
119
|
+
data: {
|
|
120
|
+
pairs: batch.selected.length,
|
|
121
|
+
verdicts: verdicts.map((v) => ({ pair: v.pair, verdict: v.verdict })),
|
|
122
|
+
events,
|
|
123
|
+
cutByMaxPairs: batch.deferredWindowIds.length,
|
|
124
|
+
dryRun: true,
|
|
125
|
+
},
|
|
126
|
+
}],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// 先标记 judged 再发判决事件:宁丢勿重(重复入账会污染 confidence / contestRate)。
|
|
130
|
+
// 只对本次真正标记到的窗口发事件(markWindowsJudged 返回值):跨进程重复判决不双记。
|
|
131
|
+
const newlyJudged = await wisdomStore.markWindowsJudged(closeIds, now);
|
|
132
|
+
const claimed = new Set(newlyJudged);
|
|
133
|
+
const emitEvents = events.filter((e) => e.ref && claimed.has(e.ref));
|
|
134
|
+
if (emitEvents.length > 0) {
|
|
135
|
+
emitWisdomEvaluateRequest(deps?.[DEP_EVENT_BUS], { events: emitEvents });
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
act: {
|
|
139
|
+
mode: 'inject',
|
|
140
|
+
status: 'success',
|
|
141
|
+
target: 'wisdom-store',
|
|
142
|
+
messages: [{
|
|
143
|
+
role: 'system',
|
|
144
|
+
content: `wisdom.steward.attributed pairs=${batch.selected.length} events=${emitEvents.length} ` +
|
|
145
|
+
`closed=${newlyJudged.length} deferred=${batch.deferredWindowIds.length}`,
|
|
146
|
+
}],
|
|
147
|
+
},
|
|
148
|
+
signals: [{
|
|
149
|
+
action: 'suggest',
|
|
150
|
+
reason: 'attribute_completed',
|
|
151
|
+
data: {
|
|
152
|
+
pairs: batch.selected.length,
|
|
153
|
+
verdicts: verdicts.map((v) => ({ pair: v.pair, verdict: v.verdict })),
|
|
154
|
+
events: emitEvents,
|
|
155
|
+
closed: newlyJudged.length,
|
|
156
|
+
cutByMaxPairs: batch.deferredWindowIds.length,
|
|
157
|
+
dryRun: false,
|
|
158
|
+
},
|
|
159
|
+
}],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
export default {
|
|
163
|
+
handler,
|
|
164
|
+
contract: { input: 'WisdomAttributeInput', output: 'WisdomAttributeResult' },
|
|
165
|
+
dependencies: [DEP_WISDOM],
|
|
166
|
+
};
|
|
167
|
+
export { handler };
|
|
@@ -25,7 +25,9 @@ async function handler(input, deps) {
|
|
|
25
25
|
const rawEvents = Array.isArray(payload.events) ? payload.events : [];
|
|
26
26
|
const events = rawEvents.filter(isOutcomeEvent);
|
|
27
27
|
if (events.length > 0 && !dryRun) {
|
|
28
|
-
|
|
28
|
+
// config 必须透传:recordOutcomes 内部推进 confidence/状态迁移,
|
|
29
|
+
// 否则 evaluation.* 配置在事件路径上被默认值绕过(评审 F4)
|
|
30
|
+
await store.recordOutcomes(events, config);
|
|
29
31
|
}
|
|
30
32
|
const entries = await store.listForGovern({ includeRetired: false });
|
|
31
33
|
let updated = 0;
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"memoryIds": ["m1", "m2"],
|
|
24
24
|
"conceptIds": [],
|
|
25
25
|
"exceptions": [],
|
|
26
|
-
"kind": "corrective"
|
|
26
|
+
"kind": "corrective",
|
|
27
|
+
"supersedesId": null
|
|
27
28
|
}
|
|
28
29
|
],
|
|
29
30
|
"droppedNotes": ["不足以形成范式的主题说明"]
|
|
@@ -38,5 +39,11 @@
|
|
|
38
39
|
4. **有适用域**:problemTypes 非空;写清 antiScenarios。
|
|
39
40
|
5. 不输出 secrets、统计句、人格/宪法句。
|
|
40
41
|
6. 无合格范式时输出 `{"items":[],"droppedNotes":["…"]}`,不要硬凑。
|
|
42
|
+
7. **对照「库内已有范式」去重**:同主题已有范式时不输出新条目;确有实质改进时输出 `supersedesId`(值为被取代条目 id)取代之,不要新增同主题条目。
|
|
43
|
+
|
|
44
|
+
## 标签粒度(影响召回匹配,必须遵守)
|
|
45
|
+
|
|
46
|
+
- `problemTypes`:2–6 字短语标签(如「缓存优化」「验证型宣称」),不用整句。
|
|
47
|
+
- `signals`:2–6 个短词标签,每个 ≤12 字(如「缓存 miss」「任务快照过期」),不用整句长描述。
|
|
41
48
|
|
|
42
49
|
kind ∈ `generalize | corrective | selection | boundary`。
|
|
@@ -4,17 +4,23 @@ description: 从 Memory/Cognition 稳定结构炼制判断范式(maxim;多
|
|
|
4
4
|
|
|
5
5
|
sense:
|
|
6
6
|
source: schedule
|
|
7
|
-
|
|
7
|
+
# 8h 兜底脉搏;启动首跳 + memory.stored 增量触发补足响应速度
|
|
8
|
+
interval: 28800000
|
|
9
|
+
runOnStart: true
|
|
10
|
+
cooldownMs: 3600000
|
|
8
11
|
filter:
|
|
9
12
|
condition: "true"
|
|
10
|
-
|
|
13
|
+
# minEvents 对订阅事件统一累积:攒 5 条新记忆才放行;显式触发请走 trigger API
|
|
14
|
+
minEvents: 5
|
|
15
|
+
events: ['wisdom.steward.formation.request', 'memory.stored']
|
|
11
16
|
emits: ['wisdom.steward.formed', 'wisdom.steward.formation.failed']
|
|
12
17
|
isolation: isolated
|
|
13
18
|
|
|
14
19
|
think:
|
|
15
|
-
|
|
20
|
+
# code = 调 handler.ts 确定性实现(llm 模式是自由 decide,handler 从未执行——2026-10-30 修复)
|
|
21
|
+
implementation: code
|
|
16
22
|
strategy: single
|
|
17
|
-
model:
|
|
23
|
+
model: mini
|
|
18
24
|
maxIterations: 1
|
|
19
25
|
|
|
20
26
|
act:
|
|
@@ -38,7 +44,7 @@ session:
|
|
|
38
44
|
|
|
39
45
|
lifecycle:
|
|
40
46
|
maxConcurrent: 1
|
|
41
|
-
maxDurationMs:
|
|
47
|
+
maxDurationMs: 120000
|
|
42
48
|
|
|
43
49
|
runtimeInject:
|
|
44
50
|
requires: ['wisdomStore', 'memoryStore']
|
|
@@ -52,3 +58,5 @@ metadata:
|
|
|
52
58
|
minMemorySupport: 2
|
|
53
59
|
minClusterSize: 5
|
|
54
60
|
maxEvidenceChars: 6000
|
|
61
|
+
maxDigestItems: 30
|
|
62
|
+
maxTokens: 8192
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { readFileSync } from 'node:fs';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
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';
|
|
10
|
+
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, chatForCompleteOutput, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
11
|
+
import { formAndAdmit, parseWisdomFormationJson, planPromotionCandidates, } from '../../../harness/memory/index.js';
|
|
12
12
|
const DEP_WISDOM = 'wisdomStore';
|
|
13
13
|
const DEP_MEMORY = 'memoryStore';
|
|
14
14
|
const DEP_CONCEPT = 'conceptGraphStore';
|
|
@@ -40,16 +40,29 @@ function failOutput(message, reason) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* 聚合炼制原料:promotion 候选 + 同型 method/norm
|
|
43
|
+
* 聚合炼制原料:promotion 候选 + 同型 method/norm 簇 + 库内已有范式清单。
|
|
44
44
|
*
|
|
45
45
|
* @param memoryStore - MemoryStore
|
|
46
|
+
* @param wisdomStore - WisdomStore(库内范式清单 + 已覆盖语料过滤)
|
|
46
47
|
* @param minCluster - 触发阈值
|
|
47
|
-
* @param maxChars -
|
|
48
|
+
* @param maxChars - 证据段字符上限
|
|
49
|
+
* @param maxDigestItems - 库内范式清单条数上限(独立预算)
|
|
48
50
|
* @returns 证据包文本与 memoryIds
|
|
49
51
|
*/
|
|
50
|
-
async function buildEvidencePack(memoryStore, minCluster, maxChars) {
|
|
52
|
+
async function buildEvidencePack(memoryStore, wisdomStore, minCluster, maxChars, maxDigestItems) {
|
|
51
53
|
const all = await memoryStore.listForGovern({ includeDeleted: false });
|
|
52
|
-
const
|
|
54
|
+
const livingWisdom = (await wisdomStore.listForGovern()).filter((w) => w.status !== 'retired' && w.status !== 'superseded');
|
|
55
|
+
// 语料去覆盖:只统计 trial/active/strengthened 范式的 derivedFrom——
|
|
56
|
+
// candidate/contested 不锁语料(contested 可能被修反,同批证据要能炼出修正版)。
|
|
57
|
+
// 同源材料反复炼制是重复条目的燃料,已消化材料由下方「库内已有范式」清单代表
|
|
58
|
+
const covered = new Set();
|
|
59
|
+
for (const w of livingWisdom) {
|
|
60
|
+
if (w.status !== 'trial' && w.status !== 'active' && w.status !== 'strengthened')
|
|
61
|
+
continue;
|
|
62
|
+
for (const id of w.derivedFrom?.memoryIds ?? [])
|
|
63
|
+
covered.add(id);
|
|
64
|
+
}
|
|
65
|
+
const alive = all.filter((e) => !e.deleted && (e.status ?? 'active') !== 'shadow' && !covered.has(e.id));
|
|
53
66
|
const promotions = planPromotionCandidates(alive, 20);
|
|
54
67
|
// 按 type+首 tag 聚簇(代码侧选择;语义归 LLM)
|
|
55
68
|
const clusters = new Map();
|
|
@@ -86,6 +99,14 @@ async function buildEvidencePack(memoryStore, minCluster, maxChars) {
|
|
|
86
99
|
let text = parts.join('\n');
|
|
87
100
|
if (text.length > maxChars)
|
|
88
101
|
text = text.slice(0, maxChars);
|
|
102
|
+
// 库内已有范式清单:LLM 级语义去重的输入(同主题勿重复炼制;实质改进走 supersedesId 取代)。
|
|
103
|
+
// 受 maxDigestItems 单独约束(maxChars 只管证据段,两者共同构成有界提示);截断如实上报
|
|
104
|
+
if (livingWisdom.length) {
|
|
105
|
+
const shown = livingWisdom.slice(0, maxDigestItems);
|
|
106
|
+
const hidden = livingWisdom.length - shown.length;
|
|
107
|
+
const digestLines = shown.map((w) => `- (${w.id}) ${w.statement.slice(0, 80)}`).join('\n');
|
|
108
|
+
text += `\n## 库内已有范式(同主题勿重复炼制;确有实质改进则输出 supersedesId 取代,不要新增${hidden ? `;另有 ${hidden} 条未列出` : ''})\n${digestLines}`;
|
|
109
|
+
}
|
|
89
110
|
return {
|
|
90
111
|
text,
|
|
91
112
|
memoryIds: [...ids],
|
|
@@ -103,10 +124,11 @@ async function handler(_input, deps) {
|
|
|
103
124
|
const config = deps?.[DEP_CONFIG] ?? {};
|
|
104
125
|
const minCluster = config.minClusterSize ?? 5;
|
|
105
126
|
const maxChars = config.maxEvidenceChars ?? 6000;
|
|
127
|
+
const maxDigestItems = config.maxDigestItems ?? 30;
|
|
106
128
|
const maxItems = config.maxItemsPerRun ?? 2;
|
|
107
129
|
const dryRun = config.dryRun ?? false;
|
|
108
130
|
const minPromotionStack = config.minPromotionStack ?? 3;
|
|
109
|
-
const pack = await buildEvidencePack(memoryStore, minCluster, maxChars);
|
|
131
|
+
const pack = await buildEvidencePack(memoryStore, wisdomStore, minCluster, maxChars, maxDigestItems);
|
|
110
132
|
// 触发器(防「见者有份」):真实簇 或 晋升候选堆叠;仅有零散材料不打 LLM
|
|
111
133
|
const hasCluster = pack.clusterHits > 0;
|
|
112
134
|
const hasStackedPromotions = pack.promotionCount >= minPromotionStack;
|
|
@@ -155,24 +177,18 @@ async function handler(_input, deps) {
|
|
|
155
177
|
// 图不可用不阻断炼制
|
|
156
178
|
}
|
|
157
179
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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');
|
|
180
|
+
// maxTokens 只是生成配额(LLM 传参):截断(finish=length)或解析失败都放大配额重试
|
|
181
|
+
// 一次,仍失败显式上报——业务完整性优先,禁止静默半截结果
|
|
182
|
+
const outcome = await chatForCompleteOutput(llmPort, {
|
|
183
|
+
systemPrompt: systemPrompt || undefined,
|
|
184
|
+
messages: [{ role: 'user', content: `${pack.text}${conceptHint}` }],
|
|
185
|
+
maxTokens: config.maxTokens ?? 8192,
|
|
186
|
+
}, (text) => parseWisdomFormationJson(text));
|
|
187
|
+
if (!outcome.ok) {
|
|
188
|
+
return failOutput(outcome.message, outcome.reason);
|
|
173
189
|
}
|
|
174
190
|
const allowedMemoryIds = new Set(pack.memoryIds);
|
|
175
|
-
const { results, droppedNotes } = await formAndAdmit(
|
|
191
|
+
const { results, droppedNotes } = await formAndAdmit(outcome.raw, wisdomStore, {
|
|
176
192
|
origin: 'distilled',
|
|
177
193
|
maxItems,
|
|
178
194
|
allowedMemoryIds,
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* 只写 WisdomStore;可 dryRun。不写 Memory / Cognition。
|
|
5
5
|
*/
|
|
6
6
|
import { planWisdomGovern, wisdomUtility, } from '../../../harness/memory/wisdom-policy.js';
|
|
7
|
+
import { emitWisdomGoverned } from '../../../harness/memory/wisdom-events.js';
|
|
7
8
|
const DEP_WISDOM = 'wisdomStore';
|
|
9
|
+
const DEP_EVENT_BUS = 'eventBus';
|
|
8
10
|
const DEP_CONFIG = '__subsystem_config__';
|
|
9
11
|
async function handler(_input, deps) {
|
|
10
12
|
const store = deps?.[DEP_WISDOM];
|
|
@@ -33,6 +35,8 @@ async function handler(_input, deps) {
|
|
|
33
35
|
retired = plan.filter((p) => p.action === 'retire').length;
|
|
34
36
|
}
|
|
35
37
|
const stats = await store.stats();
|
|
38
|
+
// 治理脉搏:判官(wisdom.steward.attribute)等维护动作挂此脉搏;发射失败不影响 govern
|
|
39
|
+
emitWisdomGoverned(deps?.[DEP_EVENT_BUS]);
|
|
36
40
|
return {
|
|
37
41
|
act: {
|
|
38
42
|
mode: 'inject',
|