@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
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { readFileSync } from 'node:fs';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
+
import { computeConfigHash } from '../../config-admin/patch.js';
|
|
12
13
|
/**
|
|
13
14
|
* 参与指纹的安全字段(§8.4:jail / escalation / effects / 审计开关 + 作用域面)。
|
|
14
15
|
* 键序无关;值走稳定序列化。
|
|
@@ -33,6 +34,32 @@ const EFFECT_POLICY_SECURITY_KEYS = [
|
|
|
33
34
|
'dangerousCommands',
|
|
34
35
|
];
|
|
35
36
|
const SECURITY_CONFIG_SECURITY_KEYS = ['enforce', 'injectionSensitivity', 'allowedPaths'];
|
|
37
|
+
/**
|
|
38
|
+
* effectPolicy 中**不进热应用**的子字段(§4.3.1:需重启 + 宿主确认)。
|
|
39
|
+
*
|
|
40
|
+
* 判据是 §4.3.1 **明列**的安全闸 + 注释明确「须重启 + 宿主署名」的字段,**不是**整个
|
|
41
|
+
* 指纹范围(EFFECT_POLICY_SECURITY_KEYS)——指纹范围只回答「哪些字段变化算漂移」,
|
|
42
|
+
* 热应用禁区回答「哪些字段改了必须重启确认」,两者不可混用(把 shellEscape 等一并
|
|
43
|
+
* 划入禁区会误拒 WebUI 的合法合并编辑)。
|
|
44
|
+
*
|
|
45
|
+
* `mode` 允许热改(WebUI「安全组」四选一);`shellEscape` / `untrustedAdmission` /
|
|
46
|
+
* `pathContainment` / `toolIsolation` / `network` 是普通配置旋钮,允许热改(仍在指纹内,
|
|
47
|
+
* 改了会重锚)。ApplyEngine 据此拒绝禁区字段(评审 M2 补全此前缺失的拒绝逻辑)。
|
|
48
|
+
*/
|
|
49
|
+
export const EFFECT_POLICY_HOT_BLOCKED_KEYS = [
|
|
50
|
+
// §4.3.1 明列
|
|
51
|
+
'jail',
|
|
52
|
+
'onJailUnavailable',
|
|
53
|
+
'privilegedAck',
|
|
54
|
+
'effects',
|
|
55
|
+
'escalation',
|
|
56
|
+
// §4.3.1「审计开关」;P5 审计外送 = 换见证人
|
|
57
|
+
'opsAudit',
|
|
58
|
+
'opsAuditPath',
|
|
59
|
+
'opsAuditExportPath',
|
|
60
|
+
// ops P4 注释明说「危险命令减速带…须重启 + 宿主署名」
|
|
61
|
+
'dangerousCommands',
|
|
62
|
+
];
|
|
36
63
|
function pickFields(source, keys, prefix) {
|
|
37
64
|
const out = {};
|
|
38
65
|
for (const key of keys) {
|
|
@@ -62,11 +89,28 @@ export function computeSecurityConfigFingerprint(config) {
|
|
|
62
89
|
...pickFields(config.effectPolicy ?? {}, EFFECT_POLICY_SECURITY_KEYS, 'effectPolicy.'),
|
|
63
90
|
...pickFields(config.security ?? {}, SECURITY_CONFIG_SECURITY_KEYS, 'security.'),
|
|
64
91
|
};
|
|
65
|
-
// per-agent
|
|
92
|
+
// per-agent 覆盖与工具面/插件加载授权都是安全面。
|
|
66
93
|
if (config.agents !== undefined)
|
|
67
94
|
fields['agents'] = config.agents;
|
|
68
95
|
if (config.plugins !== undefined && Object.keys(config.plugins).length > 0) {
|
|
69
|
-
|
|
96
|
+
const pluginFields = pickFields(config.plugins, ['loadPaths', 'allowList', 'blockList'], 'plugins.');
|
|
97
|
+
const entries = config.plugins.entries;
|
|
98
|
+
if (typeof entries === 'object' && entries !== null && !Array.isArray(entries)) {
|
|
99
|
+
const enabled = {};
|
|
100
|
+
for (const [id, entry] of Object.entries(entries)) {
|
|
101
|
+
if (typeof entry === 'object' && entry !== null && !Array.isArray(entry)) {
|
|
102
|
+
const value = entry.enabled;
|
|
103
|
+
if (value !== undefined)
|
|
104
|
+
enabled[id] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
pluginFields['plugins.entries.enabled'] = enabled;
|
|
108
|
+
}
|
|
109
|
+
// Business config is hashed, never copied into the diagnostic field projection.
|
|
110
|
+
if (config.plugins.configs !== undefined) {
|
|
111
|
+
pluginFields['plugins.legacyConfigsHash'] = createHash('sha256').update(stableStringify(config.plugins.configs)).digest('hex');
|
|
112
|
+
}
|
|
113
|
+
fields['plugins'] = pluginFields;
|
|
70
114
|
}
|
|
71
115
|
return {
|
|
72
116
|
fingerprint: createHash('sha256').update(stableStringify(fields)).digest('hex'),
|
|
@@ -144,3 +188,65 @@ export function createFileSecurityIntegrity(options) {
|
|
|
144
188
|
return diffSecurityConfigFingerprint(options.anchor, computeSecurityConfigFingerprint(slice));
|
|
145
189
|
};
|
|
146
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* 基于配置文件的可重锚定守卫。
|
|
193
|
+
*
|
|
194
|
+
* @param options.configPath - 配置文件绝对路径
|
|
195
|
+
* @returns 守卫(锚定与复核同口径:都取 raw 文件安全切面)
|
|
196
|
+
* @throws 启动期文件读不到/解析失败(fail-fast,与锚定即拒绝启动的既有语义一致)
|
|
197
|
+
*/
|
|
198
|
+
export function createSecurityIntegrityGuard(options) {
|
|
199
|
+
const readSlice = () => {
|
|
200
|
+
const text = readFileSync(options.configPath, 'utf8');
|
|
201
|
+
return { text, slice: extractSecurityConfigSlice(text) };
|
|
202
|
+
};
|
|
203
|
+
let anchor = computeSecurityConfigFingerprint(readSlice().slice);
|
|
204
|
+
return {
|
|
205
|
+
get fingerprint() {
|
|
206
|
+
return anchor.fingerprint;
|
|
207
|
+
},
|
|
208
|
+
recheck() {
|
|
209
|
+
let slice;
|
|
210
|
+
try {
|
|
211
|
+
slice = extractSecurityConfigSlice(readFileSync(options.configPath, 'utf8'));
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
// 读不到/解析不了 = 无法证明未被篡改,按漂移对待(fail-closed)
|
|
215
|
+
return {
|
|
216
|
+
ok: false,
|
|
217
|
+
changed: [`<config unreadable: ${err instanceof Error ? err.message : String(err)}>`],
|
|
218
|
+
currentFingerprint: '<unreadable>',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return diffSecurityConfigFingerprint(anchor, computeSecurityConfigFingerprint(slice));
|
|
222
|
+
},
|
|
223
|
+
reattest(reattestOptions) {
|
|
224
|
+
// 刚写盘的文件读不到/解析不了 = 内部异常:抛给调用方降级处理(锚不换,fail-closed 保持)
|
|
225
|
+
const { text, slice } = readSlice();
|
|
226
|
+
// 校验一(TOCTOU):写后 hash 与盘上现状不符 = 重锚前有第三方写入
|
|
227
|
+
if (reattestOptions?.expectHash !== undefined) {
|
|
228
|
+
const actualHash = computeConfigHash(text);
|
|
229
|
+
if (actualHash !== reattestOptions.expectHash) {
|
|
230
|
+
throw new Error(`security re-attest refused: config changed on disk since the console write (expected ${reattestOptions.expectHash.slice(0, 8)}, got ${actualHash.slice(0, 8)}); host restart attests instead`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const current = computeSecurityConfigFingerprint(slice);
|
|
234
|
+
const diff = diffSecurityConfigFingerprint(anchor, current);
|
|
235
|
+
// 校验二(防白洗):本次写只应改变它声明的字段;其余安全字段变化 = 既存篡改/越权
|
|
236
|
+
if (reattestOptions?.allowedChanged) {
|
|
237
|
+
const allowed = new Set(reattestOptions.allowedChanged);
|
|
238
|
+
const unexpected = diff.changed.filter((field) => !allowed.has(field.split('.')[0] ?? ''));
|
|
239
|
+
if (unexpected.length > 0) {
|
|
240
|
+
throw new Error(`security re-attest refused: security fields outside this write's scope changed (${unexpected.join(', ')}); refusing to attest them — host restart required`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const previous = anchor;
|
|
244
|
+
anchor = current;
|
|
245
|
+
return {
|
|
246
|
+
previousFingerprint: previous.fingerprint,
|
|
247
|
+
fingerprint: current.fingerprint,
|
|
248
|
+
changed: diff.changed,
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
@@ -49,9 +49,15 @@ export declare function resolveSecurityConfig(config: {
|
|
|
49
49
|
* 从配置中创建 ContextEngine 实例
|
|
50
50
|
*
|
|
51
51
|
* @param config - contextEngine 配置(可空)
|
|
52
|
+
* @param extension - hooks / agentId / sessionsDir(有 sessionsDir 时转换记录落
|
|
53
|
+
* `sessions/<sid>/transform/`;否则进程内账本)
|
|
52
54
|
* @returns ContextEngine
|
|
53
55
|
*/
|
|
54
|
-
export declare function resolveContextEngine(config: ContextEngineConfig | undefined
|
|
56
|
+
export declare function resolveContextEngine(config: ContextEngineConfig | undefined, extension?: {
|
|
57
|
+
hooks?: SessionAwareRunnerConfig['extensionHooks'];
|
|
58
|
+
agentId: string;
|
|
59
|
+
sessionsDir?: string;
|
|
60
|
+
}): ContextEngine;
|
|
55
61
|
/**
|
|
56
62
|
* 从配置中解析 RunGuard
|
|
57
63
|
*
|
|
@@ -80,6 +86,8 @@ export interface AgentWireSpec {
|
|
|
80
86
|
systemPrompt?: string;
|
|
81
87
|
};
|
|
82
88
|
skillDirectory?: string;
|
|
89
|
+
/** Skill 启用清单(agents[].skills,按 skill id);缺省 = 目录内全部启用 */
|
|
90
|
+
skills?: string[];
|
|
83
91
|
/** SEC-2 / E6 工具策略与会话权利天花板 */
|
|
84
92
|
tools?: import('@octopi-agent/core/types.js').ToolPolicy;
|
|
85
93
|
maxSessionRights?: SessionAwareRunnerConfig['agentMaxSessionRights'];
|
|
@@ -95,8 +103,8 @@ export interface AgentWireSpec {
|
|
|
95
103
|
embedding?: ModelsConfig['embedding'];
|
|
96
104
|
};
|
|
97
105
|
contextEngineConfig?: ContextEngineConfig;
|
|
98
|
-
contextAssemblerConfig?: HarnessConfig['contextAssembler'];
|
|
99
|
-
constitutionConfig?: HarnessConfig['constitution'];
|
|
106
|
+
contextAssemblerConfig?: NonNullable<HarnessConfig['context']>['contextAssembler'];
|
|
107
|
+
constitutionConfig?: NonNullable<HarnessConfig['context']>['constitution'];
|
|
100
108
|
memoryConfig?: HarnessConfig['memory'];
|
|
101
109
|
cognitionConfig?: HarnessConfig['cognition'];
|
|
102
110
|
wisdomConfig?: HarnessConfig['wisdom'];
|
|
@@ -18,6 +18,8 @@ import { getOctopiHome } from '../../paths.js';
|
|
|
18
18
|
import { DefaultRunGuard, } from '../run/run-guard/default-run-guard.js';
|
|
19
19
|
import { DefaultContextEngine } from '../context/default-context-engine.js';
|
|
20
20
|
import { DefaultBudgetAllocator } from '../context/budget-allocator.js';
|
|
21
|
+
import { JsonlTransformStore } from '../session/transform-store.js';
|
|
22
|
+
import { initShellParser } from '../governance/security/shell-parser.js';
|
|
21
23
|
// ── 配置解析(唯一实现;供 wire 与公开导出共用) ──
|
|
22
24
|
/**
|
|
23
25
|
* 解析子系统审计目录(docs/autonomous-subsystem.md §10)
|
|
@@ -55,20 +57,33 @@ export function resolveSecurityConfig(config) {
|
|
|
55
57
|
* 从配置中创建 ContextEngine 实例
|
|
56
58
|
*
|
|
57
59
|
* @param config - contextEngine 配置(可空)
|
|
60
|
+
* @param extension - hooks / agentId / sessionsDir(有 sessionsDir 时转换记录落
|
|
61
|
+
* `sessions/<sid>/transform/`;否则进程内账本)
|
|
58
62
|
* @returns ContextEngine
|
|
59
63
|
*/
|
|
60
|
-
export function resolveContextEngine(config) {
|
|
64
|
+
export function resolveContextEngine(config, extension) {
|
|
61
65
|
// 缺省 type = default:只给旋钮(如 proactiveCompactRatio)也必须落到默认引擎
|
|
62
66
|
if (!config || config.type == null || config.type === 'default') {
|
|
63
67
|
return new DefaultContextEngine({
|
|
64
68
|
protectFirstN: config?.protectFirstN ?? 5,
|
|
65
69
|
protectLastN: config?.protectLastN ?? 20,
|
|
70
|
+
midTurnProtectLastN: config?.midTurnProtectLastN,
|
|
66
71
|
summaryBudget: config?.summaryBudget,
|
|
67
72
|
proactiveCompactRatio: config?.proactiveCompactRatio ?? 0.6,
|
|
68
73
|
proactiveCooldownMs: config?.proactiveCooldownMs ?? 30_000,
|
|
74
|
+
summarizeTimeoutMs: config?.summarizeTimeoutMs,
|
|
69
75
|
historyAging: config?.historyAging,
|
|
70
76
|
targetTokens: config?.targetTokens,
|
|
71
77
|
compactFallbackRatio: config?.compactFallbackRatio,
|
|
78
|
+
...(extension?.sessionsDir
|
|
79
|
+
? {
|
|
80
|
+
transformStore: new JsonlTransformStore({ sessionsDir: extension.sessionsDir }),
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
83
|
+
...(extension?.hooks === undefined ? {} : {
|
|
84
|
+
extensionHooks: extension.hooks,
|
|
85
|
+
extensionIdentity: { sessionId: 'default', agentId: extension.agentId },
|
|
86
|
+
}),
|
|
72
87
|
budgetAllocator: new DefaultBudgetAllocator({
|
|
73
88
|
outputRatio: config?.outputRatio ?? 0.20,
|
|
74
89
|
minOutputReserve: config?.minOutputReserve ?? 2000,
|
|
@@ -123,6 +138,8 @@ export function resolveRunGuard(config, providers) {
|
|
|
123
138
|
* @param spec - 标准组装输入
|
|
124
139
|
*/
|
|
125
140
|
export async function wireAgentBuilder(builder, spec) {
|
|
141
|
+
// ── Shell 解析引擎(安全风险评估依赖;失败自动降级 legacy,不阻断组装) ──
|
|
142
|
+
await initShellParser();
|
|
126
143
|
// ── Model ──
|
|
127
144
|
builder.model(spec.model);
|
|
128
145
|
// ── Model call watchdog ──
|
|
@@ -194,7 +211,7 @@ export async function wireAgentBuilder(builder, spec) {
|
|
|
194
211
|
if (skillDir && existsSync(skillDir)) {
|
|
195
212
|
try {
|
|
196
213
|
const { DefaultSkillManager } = await import('../extension/plugin-ecosystem/skills/manager.js');
|
|
197
|
-
skillManager = new DefaultSkillManager();
|
|
214
|
+
skillManager = new DefaultSkillManager(undefined, spec.skills ? { only: spec.skills } : undefined);
|
|
198
215
|
await skillManager.discover(skillDir);
|
|
199
216
|
builder.skills(skillManager);
|
|
200
217
|
}
|
|
@@ -202,7 +219,8 @@ export async function wireAgentBuilder(builder, spec) {
|
|
|
202
219
|
console.warn(`[AgentWire] skill discover failed for ${skillDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
203
220
|
skillManager = undefined;
|
|
204
221
|
}
|
|
205
|
-
// 无 manager 时 builder
|
|
222
|
+
// 无 manager 时 builder 仍可用目录兜底(allowlist 同样生效)
|
|
223
|
+
builder.skillAllowlist(spec.skills);
|
|
206
224
|
builder.skillDirectory(skillDir);
|
|
207
225
|
}
|
|
208
226
|
// ── Memory / Wisdom / Cognition(agent home 下 AgentDatabase) ──
|
|
@@ -226,7 +244,11 @@ export async function wireAgentBuilder(builder, spec) {
|
|
|
226
244
|
wireBudget(builder, spec.budgetConfig);
|
|
227
245
|
}
|
|
228
246
|
// ── Context Engine(缺省也接线:配置面必须有唯一出口) ──
|
|
229
|
-
builder.contextEngine(resolveContextEngine(spec.contextEngineConfig
|
|
247
|
+
builder.contextEngine(resolveContextEngine(spec.contextEngineConfig, {
|
|
248
|
+
hooks: spec.extraRunnerConfig?.extensionHooks,
|
|
249
|
+
agentId: spec.agentId,
|
|
250
|
+
sessionsDir: spec.extraRunnerConfig?.sessionsDir,
|
|
251
|
+
}));
|
|
230
252
|
// ── Context Assembler / Constitution / Memory policy ──
|
|
231
253
|
if (spec.contextAssemblerConfig) {
|
|
232
254
|
builder.contextAssembler(spec.contextAssemblerConfig);
|
|
@@ -281,13 +303,13 @@ export function shouldAutoLoadSubsystems(spec) {
|
|
|
281
303
|
function wireBudget(builder, budgetConfig) {
|
|
282
304
|
const engineConfig = {
|
|
283
305
|
maxWallClockMs: budgetConfig.maxWallClockMs,
|
|
284
|
-
|
|
306
|
+
maxSteps: budgetConfig.maxSteps,
|
|
285
307
|
maxToolCalls: budgetConfig.maxToolCalls,
|
|
286
308
|
};
|
|
287
309
|
builder.budget(engineConfig);
|
|
288
310
|
const wrapUpConfig = {};
|
|
289
|
-
if ('
|
|
290
|
-
wrapUpConfig.
|
|
311
|
+
if ('wrapUpSteps' in budgetConfig && budgetConfig.wrapUpSteps !== undefined) {
|
|
312
|
+
wrapUpConfig.steps = budgetConfig.wrapUpSteps;
|
|
291
313
|
}
|
|
292
314
|
if ('onPolicyHit' in budgetConfig && budgetConfig.onPolicyHit !== undefined) {
|
|
293
315
|
wrapUpConfig.onPolicyHit = budgetConfig.onPolicyHit;
|
|
@@ -346,6 +368,8 @@ async function wireContextStores(builder, input) {
|
|
|
346
368
|
const wis = input.wisdomConfig;
|
|
347
369
|
if (wis?.enabled !== false) {
|
|
348
370
|
builder.wisdomStore(new SqliteWisdomStore(db, { hardCap: wis?.capacity?.hardCap }));
|
|
371
|
+
if (wis?.injection)
|
|
372
|
+
builder.wisdomInjection(wis.injection);
|
|
349
373
|
}
|
|
350
374
|
const cog = input.cognitionConfig;
|
|
351
375
|
if (cog?.enabled !== false) {
|
|
@@ -11,6 +11,11 @@ import type { DocumentPort } from './types.js';
|
|
|
11
11
|
export interface DocumentCapabilityConfig {
|
|
12
12
|
extract?: {
|
|
13
13
|
enabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 档位路由部署缺省(per-call extractOptions.tier 覆盖):
|
|
16
|
+
* `auto`(缺省)= t0→t1→t2 逐档降级;`t0-only` = 钉死本地抽取,不外发增强/云
|
|
17
|
+
*/
|
|
18
|
+
backend?: 'auto' | 't0-only';
|
|
14
19
|
timeoutMs?: number;
|
|
15
20
|
maxFileBytes?: number;
|
|
16
21
|
allowedRoots?: string[];
|
|
@@ -18,6 +18,7 @@ export function createDocumentPortFromConfig(cfg) {
|
|
|
18
18
|
const extract = cfg?.extract;
|
|
19
19
|
const config = {
|
|
20
20
|
enabled: extract?.enabled !== false,
|
|
21
|
+
...(extract?.backend ? { backend: extract.backend } : {}),
|
|
21
22
|
...(extract?.timeoutMs != null ? { timeoutMs: extract.timeoutMs } : {}),
|
|
22
23
|
...(extract?.maxFileBytes != null ? { maxFileBytes: extract.maxFileBytes } : {}),
|
|
23
24
|
...(extract?.allowedRoots?.length ? { allowedRoots: extract.allowedRoots } : {}),
|
|
@@ -111,6 +111,8 @@ export function createDefaultDocumentPort(options = {}) {
|
|
|
111
111
|
const backends = options.backends ?? createDefaultBackends();
|
|
112
112
|
const legacy = options.legacyConverter ?? null;
|
|
113
113
|
const capsTtl = options.capabilitiesTtlMs ?? 5 * 60_000;
|
|
114
|
+
/** 部署缺省档位(documents.extract.backend):t0-only 钉死本地档;probe / hasBackendFor / extract 同判 */
|
|
115
|
+
const defaultTier = config.backend === 't0-only' ? 't0' : undefined;
|
|
114
116
|
let capsCache = null;
|
|
115
117
|
async function availableBackendIds() {
|
|
116
118
|
const ids = new Set();
|
|
@@ -230,7 +232,7 @@ export function createDefaultDocumentPort(options = {}) {
|
|
|
230
232
|
if (LEGACY_FORMATS.has(format) && format !== 'xls') {
|
|
231
233
|
return { format, level: caps.formats[format]?.level ?? 'none' };
|
|
232
234
|
}
|
|
233
|
-
const candidates = pickBackends(format, available,
|
|
235
|
+
const candidates = pickBackends(format, available, tierOrder(defaultTier));
|
|
234
236
|
const first = candidates[0];
|
|
235
237
|
return {
|
|
236
238
|
format,
|
|
@@ -296,11 +298,12 @@ export function createDefaultDocumentPort(options = {}) {
|
|
|
296
298
|
});
|
|
297
299
|
async function hasBackendFor(fmt) {
|
|
298
300
|
const { available } = await loadCapabilities();
|
|
299
|
-
return pickBackends(fmt, available,
|
|
301
|
+
return pickBackends(fmt, available, tierOrder(defaultTier)).length > 0;
|
|
300
302
|
}
|
|
301
303
|
async function runExtract(args) {
|
|
302
304
|
const { available } = await loadCapabilities();
|
|
303
|
-
|
|
305
|
+
// 档位路由:per-call tier > documents.extract.backend 部署缺省(t0-only 钉死不外发)> auto 全档
|
|
306
|
+
const tiers = tierOrder(args.extractOptions.tier ?? defaultTier);
|
|
304
307
|
const candidates = pickBackends(args.formatHint, available, tiers);
|
|
305
308
|
if (candidates.length === 0 && args.formatHint === 'unknown') {
|
|
306
309
|
throw new DocumentExtractError('UNSUPPORTED_FORMAT', 'unable to detect document format');
|
|
@@ -145,6 +145,11 @@ export interface ResolvedExtractSource {
|
|
|
145
145
|
}
|
|
146
146
|
export interface DocumentPortConfig {
|
|
147
147
|
enabled?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* 档位路由部署缺省(per-call ExtractOptions.tier 覆盖):
|
|
150
|
+
* `auto`(缺省)= t0→t1→t2 逐档降级;`t0-only` = 钉死本地抽取(内容不外发)
|
|
151
|
+
*/
|
|
152
|
+
backend?: 'auto' | 't0-only';
|
|
148
153
|
timeoutMs?: number;
|
|
149
154
|
maxFileBytes?: number;
|
|
150
155
|
/** 路径允许根;未设置则不限制(由调用方约束) */
|
|
@@ -16,8 +16,8 @@ export type { SharedDeps, SubsystemRuntimeConfig, SubsystemTriggerResult, Subsys
|
|
|
16
16
|
export { SenseEngine, MetricsStore, SessionLifecycleBridge } from './sense/index.js';
|
|
17
17
|
export { buildAgentInput } from './sense/input-builder.js';
|
|
18
18
|
export { ThinkExecutor, ModelResolver } from './think/index.js';
|
|
19
|
-
export { createSubsystemLLMPort, shouldFallbackModel, DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, DEP_RESOLVED_MODEL, DEP_RESOLVED_MODELS, } from './think/index.js';
|
|
20
|
-
export type { SubsystemLLMPort, SubsystemLLMPortChatRequest, CreateSubsystemLLMPortOptions, } from './think/index.js';
|
|
19
|
+
export { createSubsystemLLMPort, shouldFallbackModel, DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, DEP_RESOLVED_MODEL, DEP_RESOLVED_MODELS, chatForCompleteOutput, } from './think/index.js';
|
|
20
|
+
export type { SubsystemLLMPort, SubsystemLLMPortChatRequest, CreateSubsystemLLMPortOptions, CompletionGuardFailure, CompletionGuardRequest, CompletionGuardResult, } from './think/index.js';
|
|
21
21
|
export { SignalBus } from './signal/index.js';
|
|
22
22
|
export { SubsystemSessionManager, parseTTL } from './session/index.js';
|
|
23
23
|
export { AuditWriter, AuditReader } from './audit/index.js';
|
|
@@ -17,7 +17,7 @@ export { SenseEngine, MetricsStore, SessionLifecycleBridge } from './sense/index
|
|
|
17
17
|
export { buildAgentInput } from './sense/input-builder.js';
|
|
18
18
|
// ── Think ──
|
|
19
19
|
export { ThinkExecutor, ModelResolver } from './think/index.js';
|
|
20
|
-
export { createSubsystemLLMPort, shouldFallbackModel, DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, DEP_RESOLVED_MODEL, DEP_RESOLVED_MODELS, } from './think/index.js';
|
|
20
|
+
export { createSubsystemLLMPort, shouldFallbackModel, DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, DEP_RESOLVED_MODEL, DEP_RESOLVED_MODELS, chatForCompleteOutput, } from './think/index.js';
|
|
21
21
|
// ── Signal ──
|
|
22
22
|
export { SignalBus } from './signal/index.js';
|
|
23
23
|
// ── Session ──
|
|
@@ -277,9 +277,12 @@ async function buildSpec(config, systemPrompt, source, dirPath) {
|
|
|
277
277
|
events: filterRaw.events,
|
|
278
278
|
condition: filterRaw.condition,
|
|
279
279
|
conditionRef: filterRaw.conditionRef,
|
|
280
|
+
minEvents: filterRaw.minEvents,
|
|
280
281
|
emits: filterRaw.emits,
|
|
281
282
|
} : undefined,
|
|
282
283
|
interval: senseRaw.interval,
|
|
284
|
+
runOnStart: senseRaw.runOnStart,
|
|
285
|
+
cooldownMs: senseRaw.cooldownMs,
|
|
283
286
|
isolation: (senseRaw.isolation ?? 'structured'),
|
|
284
287
|
fields: senseRaw.fields,
|
|
285
288
|
},
|
|
@@ -288,7 +291,7 @@ async function buildSpec(config, systemPrompt, source, dirPath) {
|
|
|
288
291
|
implementation: impl,
|
|
289
292
|
systemPrompt: thinkRaw.systemPrompt ?? systemPrompt,
|
|
290
293
|
model: thinkRaw.model ?? config.model,
|
|
291
|
-
|
|
294
|
+
maxSteps: thinkRaw.maxSteps ?? config.maxSteps,
|
|
292
295
|
handler,
|
|
293
296
|
preProcess,
|
|
294
297
|
postProcess,
|
|
@@ -105,7 +105,7 @@ export declare class SenseEngine {
|
|
|
105
105
|
* - 字符串字面量原样保留(不再把 `'recent'` 误识别为变量)
|
|
106
106
|
* - SenseContext 顶层字段(sessionLifecycle / eventData / …)→ `ctx.<field>`
|
|
107
107
|
* - `eventData.x` → `ctx.eventData.x`;`metrics.x` → `ctx.metrics['x']`
|
|
108
|
-
* - 其余标识符 → `ctx.metrics['id']`(兼容 `
|
|
108
|
+
* - 其余标识符 → `ctx.metrics['id']`(兼容 `step.count` 等指标键)
|
|
109
109
|
*/
|
|
110
110
|
private compileConditionExpression;
|
|
111
111
|
}
|
|
@@ -59,6 +59,9 @@ export class SenseEngine {
|
|
|
59
59
|
const entry = {
|
|
60
60
|
spec,
|
|
61
61
|
cooldown: { until: 0 },
|
|
62
|
+
cooldownMs: spec.sense.cooldownMs,
|
|
63
|
+
minEvents: spec.sense.filter?.minEvents ?? 1,
|
|
64
|
+
eventCount: 0,
|
|
62
65
|
evaluator,
|
|
63
66
|
disposables: [],
|
|
64
67
|
};
|
|
@@ -92,6 +95,14 @@ export class SenseEngine {
|
|
|
92
95
|
entry.scheduleTimer.unref?.();
|
|
93
96
|
}
|
|
94
97
|
}
|
|
98
|
+
// 启动首跳:注册完成后补一次 tick(长 interval 首跳跨不过进程生命周期时的保底脉搏;
|
|
99
|
+
// setTimeout(0) 保证 builder 同步注册/依赖注入全部完成后才跑)
|
|
100
|
+
if (spec.sense.runOnStart) {
|
|
101
|
+
const starter = setTimeout(() => {
|
|
102
|
+
void this.onScheduleTick(spec.id, onTrigger);
|
|
103
|
+
}, 0);
|
|
104
|
+
starter.unref?.();
|
|
105
|
+
}
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
/**
|
|
@@ -283,6 +294,11 @@ export class SenseEngine {
|
|
|
283
294
|
const entry = this.subsystems.get(subsystemId);
|
|
284
295
|
if (!entry)
|
|
285
296
|
return;
|
|
297
|
+
// 累积计数先于冷却检查:冷却期只是不触发,增量照样攒(攒够 minEvents 才放行)
|
|
298
|
+
entry.eventCount += 1;
|
|
299
|
+
if (entry.eventCount < entry.minEvents) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
286
302
|
const now = Date.now();
|
|
287
303
|
if (now < entry.cooldown.until || entry.inFlight) {
|
|
288
304
|
return;
|
|
@@ -312,7 +328,8 @@ export class SenseEngine {
|
|
|
312
328
|
}
|
|
313
329
|
}
|
|
314
330
|
this.depthTracker.depth++;
|
|
315
|
-
entry.cooldown.until = Date.now() + this.defaultCooldownMs;
|
|
331
|
+
entry.cooldown.until = Date.now() + (entry.cooldownMs ?? this.defaultCooldownMs);
|
|
332
|
+
entry.eventCount = 0;
|
|
316
333
|
try {
|
|
317
334
|
onTrigger(ctx);
|
|
318
335
|
}
|
|
@@ -350,7 +367,7 @@ export class SenseEngine {
|
|
|
350
367
|
}
|
|
351
368
|
}
|
|
352
369
|
this.depthTracker.depth++;
|
|
353
|
-
entry.cooldown.until = Date.now() + this.defaultCooldownMs;
|
|
370
|
+
entry.cooldown.until = Date.now() + (entry.cooldownMs ?? this.defaultCooldownMs);
|
|
354
371
|
try {
|
|
355
372
|
onTrigger(ctx);
|
|
356
373
|
}
|
|
@@ -417,7 +434,7 @@ export class SenseEngine {
|
|
|
417
434
|
* - 字符串字面量原样保留(不再把 `'recent'` 误识别为变量)
|
|
418
435
|
* - SenseContext 顶层字段(sessionLifecycle / eventData / …)→ `ctx.<field>`
|
|
419
436
|
* - `eventData.x` → `ctx.eventData.x`;`metrics.x` → `ctx.metrics['x']`
|
|
420
|
-
* - 其余标识符 → `ctx.metrics['id']`(兼容 `
|
|
437
|
+
* - 其余标识符 → `ctx.metrics['id']`(兼容 `step.count` 等指标键)
|
|
421
438
|
*/
|
|
422
439
|
compileConditionExpression(expr) {
|
|
423
440
|
const body = rewriteConditionExpression(expr);
|
|
@@ -527,7 +544,7 @@ export function rewriteConditionExpression(expr) {
|
|
|
527
544
|
i = rest;
|
|
528
545
|
continue;
|
|
529
546
|
}
|
|
530
|
-
// 其余标识符:整段 dotted name 作为 metrics key(
|
|
547
|
+
// 其余标识符:整段 dotted name 作为 metrics key(step.count)
|
|
531
548
|
let name = base;
|
|
532
549
|
let rest = j;
|
|
533
550
|
while (rest < expr.length &&
|
|
@@ -21,7 +21,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
21
21
|
input.sessionMetadata = {
|
|
22
22
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
23
23
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
24
|
-
|
|
24
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
25
25
|
sessionLifecycle: ctx.sessionLifecycle,
|
|
26
26
|
lastInteractionAt: ctx.lastInteractionAt,
|
|
27
27
|
idleMs: ctx.idleMs,
|
|
@@ -53,7 +53,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
53
53
|
input.sessionMetadata = {
|
|
54
54
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
55
55
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
56
|
-
|
|
56
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
57
57
|
};
|
|
58
58
|
break;
|
|
59
59
|
case 'token_count':
|
|
@@ -72,7 +72,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
72
72
|
...(input.sessionMetadata ?? {
|
|
73
73
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
74
74
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
75
|
-
|
|
75
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
76
76
|
}),
|
|
77
77
|
sessionLifecycle: ctx.sessionLifecycle,
|
|
78
78
|
lastInteractionAt: ctx.lastInteractionAt,
|
|
@@ -93,7 +93,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
93
93
|
input.sessionMetadata = {
|
|
94
94
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
95
95
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
96
|
-
|
|
96
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
97
97
|
};
|
|
98
98
|
if (ctx.pendingToolCall)
|
|
99
99
|
input.pendingToolCall = ctx.pendingToolCall;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* MetricsStore — 线程安全的指标存储
|
|
11
11
|
*
|
|
12
|
-
* 存储主循环注入的运行时指标(如
|
|
12
|
+
* 存储主循环注入的运行时指标(如 step.count、token.used 等),
|
|
13
13
|
* 供 SenseEngine 的 condition 表达式评估使用。
|
|
14
14
|
*/
|
|
15
15
|
export declare class MetricsStore {
|
|
@@ -17,7 +17,7 @@ export declare class MetricsStore {
|
|
|
17
17
|
/**
|
|
18
18
|
* 更新指标值
|
|
19
19
|
*
|
|
20
|
-
* @param key - 指标名(如 '
|
|
20
|
+
* @param key - 指标名(如 'step.count')
|
|
21
21
|
* @param value - 指标值
|
|
22
22
|
*/
|
|
23
23
|
update(key: string, value: number): void;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* MetricsStore — 线程安全的指标存储
|
|
11
11
|
*
|
|
12
|
-
* 存储主循环注入的运行时指标(如
|
|
12
|
+
* 存储主循环注入的运行时指标(如 step.count、token.used 等),
|
|
13
13
|
* 供 SenseEngine 的 condition 表达式评估使用。
|
|
14
14
|
*/
|
|
15
15
|
export class MetricsStore {
|
|
@@ -17,7 +17,7 @@ export class MetricsStore {
|
|
|
17
17
|
/**
|
|
18
18
|
* 更新指标值
|
|
19
19
|
*
|
|
20
|
-
* @param key - 指标名(如 '
|
|
20
|
+
* @param key - 指标名(如 'step.count')
|
|
21
21
|
* @param value - 指标值
|
|
22
22
|
*/
|
|
23
23
|
update(key, value) {
|
|
@@ -32,6 +32,12 @@ export interface ContextInjection {
|
|
|
32
32
|
messages: Array<{
|
|
33
33
|
role: 'system' | 'user' | 'assistant';
|
|
34
34
|
content: string;
|
|
35
|
+
/** 载体标记(engineHint 等);isTurnAnchor/回放按此判语义 */
|
|
36
|
+
metadata?: {
|
|
37
|
+
source?: string;
|
|
38
|
+
};
|
|
39
|
+
/** 状态快照类注入:同 run 只留最新一份,不落库 */
|
|
40
|
+
ephemeral?: boolean;
|
|
35
41
|
}>;
|
|
36
42
|
/** 是否标记为压缩结果 */
|
|
37
43
|
compressed?: boolean;
|
|
@@ -84,7 +84,12 @@ export class SignalBus {
|
|
|
84
84
|
messages.push({
|
|
85
85
|
...msg,
|
|
86
86
|
timestamp: Date.now(),
|
|
87
|
-
|
|
87
|
+
// P0-B 同范式:统一 engineHint 载体(ENGINE_CARRIER_SOURCES 成员,
|
|
88
|
+
// 不被 isTurnAnchor 认作轮锚点——否则信号更新会钉死老化边界);
|
|
89
|
+
// compressed 快照保留既有标记。上游 metadata 不透传:载体内涵由本转换定义。
|
|
90
|
+
metadata: injection.compressed
|
|
91
|
+
? { compressed: true, source: 'engineHint' }
|
|
92
|
+
: { source: 'engineHint' },
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
95
|
}
|
|
@@ -159,15 +164,31 @@ export class SignalBus {
|
|
|
159
164
|
if (signal.action === 'replace') {
|
|
160
165
|
this.contextQueue.push({
|
|
161
166
|
subsystemId,
|
|
162
|
-
|
|
167
|
+
// 状态快照:engineHint 载体 + ephemeral(同 run 只留最新一份,不落库)
|
|
168
|
+
messages: [
|
|
169
|
+
{
|
|
170
|
+
role: 'user',
|
|
171
|
+
content: signal.reason,
|
|
172
|
+
ephemeral: true,
|
|
173
|
+
metadata: { source: 'engineHint' },
|
|
174
|
+
},
|
|
175
|
+
],
|
|
163
176
|
compressed: true,
|
|
164
177
|
});
|
|
165
178
|
}
|
|
166
179
|
else {
|
|
167
|
-
// suggest / alert →
|
|
180
|
+
// suggest / alert → 注入为引擎提示(user 形态 + engineHint 标记,随历史保留)。
|
|
181
|
+
// 不用 role:'system':非托管 system 会被 provider 适配层拼进 system 字段,
|
|
182
|
+
// 状态变化即前缀整段失效(context-size-accounting.md §1)。
|
|
168
183
|
this.contextQueue.push({
|
|
169
184
|
subsystemId,
|
|
170
|
-
messages: [
|
|
185
|
+
messages: [
|
|
186
|
+
{
|
|
187
|
+
role: 'user',
|
|
188
|
+
content: `[${signal.action}] ${signal.reason}`,
|
|
189
|
+
metadata: { source: 'engineHint' },
|
|
190
|
+
},
|
|
191
|
+
],
|
|
171
192
|
});
|
|
172
193
|
}
|
|
173
194
|
}
|