@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,11 +9,12 @@
|
|
|
9
9
|
* .model('gpt-5.5')
|
|
10
10
|
* .persona('./personas/my-agent')
|
|
11
11
|
* .tool(myTool)
|
|
12
|
-
* .budget({
|
|
12
|
+
* .budget({ maxSteps: 15 })
|
|
13
13
|
* .build();
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import { DefaultToolBus } from '../extension/plugin-ecosystem/tools/tool-bus.js';
|
|
17
|
+
import * as pluginToolAdapter from '../extension/plugin-ecosystem/tools/plugin-tool.js';
|
|
17
18
|
import { expandHomePath } from '../../paths.js';
|
|
18
19
|
import { createUnconfiguredFileEffects, createUnconfiguredMemoryEffects, } from '../extension/execution-environment/undo-log.js';
|
|
19
20
|
import { JournaledMemoryStore } from '../extension/execution-environment/memory-undo.js';
|
|
@@ -29,6 +30,7 @@ import { createSessionScheduleTools } from '../session/schedules/tools.js';
|
|
|
29
30
|
import { InMemorySessionStore } from '../session/in-memory-store.js';
|
|
30
31
|
import { DefaultEventBus, } from '@octopi-agent/core/primitives/event-bus.js';
|
|
31
32
|
import { DefaultSecurityGuard, } from '../governance/security/default-security-guard.js';
|
|
33
|
+
import { initShellParser } from '../governance/security/shell-parser.js';
|
|
32
34
|
import { BudgetPolicyEngine, } from '../run/budget/budget.js';
|
|
33
35
|
import { PersonaSource } from './persona.js';
|
|
34
36
|
import { getRunScope } from '../run/run-scope.js';
|
|
@@ -61,9 +63,19 @@ export class DefaultErrorStrategy {
|
|
|
61
63
|
if (error.reason === 'content_filter' && attempt < maxAttempts) {
|
|
62
64
|
return { action: 'retry', delayMs: (attempt + 1) * 1000 };
|
|
63
65
|
}
|
|
64
|
-
// ── context_length
|
|
66
|
+
// ── context_length(F 类,arch/overflow-redesign.md T2):重发前 onError 已
|
|
67
|
+
// 回填真值/收缩上界,重装配会砍量后重发;限 2 次防「砍不给力」连环 400。
|
|
68
|
+
// 耗尽后如实收口换 session/model(L3 语义),不再伪装可恢复 ──
|
|
65
69
|
if (error.reason === 'context_length') {
|
|
66
|
-
|
|
70
|
+
if (attempt < maxAttempts) {
|
|
71
|
+
return { action: 'retry', delayMs: (attempt + 1) * 1000 };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
action: 'abort',
|
|
75
|
+
reason: 'Context length exceeded after shrink-and-resend: ' +
|
|
76
|
+
`${error.message}. ` +
|
|
77
|
+
'This session is no longer suitable for continued work, or the current model does not fit the task scale — start a new session or switch to a model with a larger context window.',
|
|
78
|
+
};
|
|
67
79
|
}
|
|
68
80
|
// ── 不可重试错误:认证、计费 ──
|
|
69
81
|
if (error.reason === 'auth') {
|
|
@@ -108,34 +120,17 @@ class RuntimeToolContextProvider {
|
|
|
108
120
|
const unconfigured = createUnconfiguredFileEffects();
|
|
109
121
|
const unconfiguredMemory = createUnconfiguredMemoryEffects();
|
|
110
122
|
if (scope?.toolRuntime) {
|
|
123
|
+
// Spread rather than copy field by field: this list has already dropped a
|
|
124
|
+
// newly added security field twice (refuseFinalSymlink, and the gateway's
|
|
125
|
+
// sibling mapping dropped pathContainment/pathRoots). Enumerating is what
|
|
126
|
+
// makes that failure possible, and it fails silently because the field is
|
|
127
|
+
// optional. Everything on RunToolRuntime is context by construction.
|
|
111
128
|
return {
|
|
112
|
-
|
|
113
|
-
agentId: scope.toolRuntime.agentId,
|
|
129
|
+
...scope.toolRuntime,
|
|
114
130
|
runId: scope.runId,
|
|
115
|
-
messages: scope.toolRuntime.messages,
|
|
116
131
|
cwd: scope.toolRuntime.cwd ?? this.cwd,
|
|
117
|
-
attachmentRoots: scope.toolRuntime.attachmentRoots,
|
|
118
132
|
fileEffects: scope.toolRuntime.fileEffects ?? unconfigured,
|
|
119
133
|
memoryEffects: scope.toolRuntime.memoryEffects ?? unconfiguredMemory,
|
|
120
|
-
pathRoots: scope.toolRuntime.pathRoots,
|
|
121
|
-
undoRoots: scope.toolRuntime.undoRoots,
|
|
122
|
-
networkPolicy: scope.toolRuntime.networkPolicy,
|
|
123
|
-
requireCredentialBindings: scope.toolRuntime.requireCredentialBindings,
|
|
124
|
-
requireJail: scope.toolRuntime.requireJail,
|
|
125
|
-
disableJail: scope.toolRuntime.disableJail,
|
|
126
|
-
homeWrite: scope.toolRuntime.homeWrite,
|
|
127
|
-
noteSecurityDegraded: scope.toolRuntime.noteSecurityDegraded,
|
|
128
|
-
recordOpsEvent: scope.toolRuntime.recordOpsEvent,
|
|
129
|
-
pathContainment: scope.toolRuntime.pathContainment,
|
|
130
|
-
confirmEffect: scope.toolRuntime.confirmEffect,
|
|
131
|
-
effectChannel: scope.toolRuntime.effectChannel,
|
|
132
|
-
escalation: scope.toolRuntime.escalation,
|
|
133
|
-
dangerousCommands: scope.toolRuntime.dangerousCommands,
|
|
134
|
-
sessionParticipants: scope.toolRuntime.sessionParticipants,
|
|
135
|
-
processLimits: scope.toolRuntime.processLimits,
|
|
136
|
-
shellEscape: scope.toolRuntime.shellEscape,
|
|
137
|
-
shellJournal: scope.toolRuntime.shellJournal,
|
|
138
|
-
shellJournalLimit: scope.toolRuntime.shellJournalLimit,
|
|
139
134
|
};
|
|
140
135
|
}
|
|
141
136
|
if (scope) {
|
|
@@ -175,11 +170,16 @@ function convertToAgentTool(tool, contextProvider) {
|
|
|
175
170
|
name: tool.definition.name,
|
|
176
171
|
description: tool.definition.description,
|
|
177
172
|
executionMode: tool.executionMode,
|
|
173
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
178
174
|
parameters: buildToolLlmParameters(tool.definition.parameters),
|
|
179
175
|
execute: async (toolCallId, args, signal, onUpdate) => {
|
|
180
176
|
const startTime = Date.now();
|
|
181
177
|
try {
|
|
182
178
|
const context = contextProvider.get();
|
|
179
|
+
const { isPluginToolPermitted } = await import('../extension/plugin-ecosystem/tools/plugin-tool.js');
|
|
180
|
+
if (!isPluginToolPermitted(tool, context.agentToolPolicy)) {
|
|
181
|
+
throw new Error(`Plugin tool "${tool.definition.name}" is not allowed for this agent`);
|
|
182
|
+
}
|
|
183
183
|
const rawArgs = (args ?? {});
|
|
184
184
|
// schema 已 required purpose;模型漏填时推导,不中断调用
|
|
185
185
|
const purpose = resolveToolCallPurpose(tool.definition.name, rawArgs);
|
|
@@ -204,6 +204,7 @@ function convertToAgentTool(tool, contextProvider) {
|
|
|
204
204
|
name: tool.definition.name,
|
|
205
205
|
content: result,
|
|
206
206
|
purpose,
|
|
207
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
207
208
|
durationMs: Date.now() - startTime,
|
|
208
209
|
};
|
|
209
210
|
}
|
|
@@ -216,6 +217,7 @@ function convertToAgentTool(tool, contextProvider) {
|
|
|
216
217
|
purpose: typeof args?.purpose === 'string'
|
|
217
218
|
? String(args.purpose)
|
|
218
219
|
: '',
|
|
220
|
+
...(tool.source === undefined ? {} : { source: tool.source }),
|
|
219
221
|
durationMs: Date.now() - startTime,
|
|
220
222
|
};
|
|
221
223
|
}
|
|
@@ -351,7 +353,9 @@ export class AgentBuilder {
|
|
|
351
353
|
_toolBus = new DefaultToolBus();
|
|
352
354
|
_contextEngine;
|
|
353
355
|
_summarize;
|
|
354
|
-
/**
|
|
356
|
+
/** 按 session 键控的 context 压力(由 convertToLlm 更新;共享 Agent 下并发会话不串号) */
|
|
357
|
+
_contextPressureBySession = new Map();
|
|
358
|
+
/** 兜底:无 sessionId 的调用方(仅 advisory 用途;并发下可能串号,不得用于持久化) */
|
|
355
359
|
_lastContextPressure;
|
|
356
360
|
/** 为 true 时禁止自动挂默认 summarize(测试/特殊场景) */
|
|
357
361
|
_disableAutoSummarize = false;
|
|
@@ -373,6 +377,8 @@ export class AgentBuilder {
|
|
|
373
377
|
_systemPrompt;
|
|
374
378
|
/** Skill 目录(SKILL.md);build 时 discover 并注入 system prompt 索引 */
|
|
375
379
|
_skillDirectory;
|
|
380
|
+
/** Skill id allowlist(agents[].skills);未设置 = 全部启用 */
|
|
381
|
+
_skillAllowlist;
|
|
376
382
|
_skillManager;
|
|
377
383
|
/** 记忆检索(注入 system prompt MemoryLayer) */
|
|
378
384
|
_memoryStore;
|
|
@@ -392,6 +398,8 @@ export class AgentBuilder {
|
|
|
392
398
|
_knowledgeGrounding;
|
|
393
399
|
/** 智慧(注入 system prompt WisdomLayer) */
|
|
394
400
|
_wisdomStore;
|
|
401
|
+
/** Wisdom 注入策略(wisdom.injection:core/scenario/trial 上限 + trialVisible) */
|
|
402
|
+
_wisdomInjection;
|
|
395
403
|
/** 认知图谱(注入 system prompt CognitionLayer) */
|
|
396
404
|
_cognitionStore;
|
|
397
405
|
/** system prompt 装配器调参 */
|
|
@@ -437,6 +445,8 @@ export class AgentBuilder {
|
|
|
437
445
|
_agentHome;
|
|
438
446
|
/** 逻辑 agentId(观测 / 子系统审计用) */
|
|
439
447
|
_agentId;
|
|
448
|
+
/** Deferred until build so .pluginTools() and .agentId() order is immaterial. */
|
|
449
|
+
_pluginToolRecords = [];
|
|
440
450
|
model(providerOrName) {
|
|
441
451
|
if (typeof providerOrName === 'string') {
|
|
442
452
|
// 字符串形式:创建一个简单的 wrapper(需要外部注册实际 provider)
|
|
@@ -466,6 +476,14 @@ export class AgentBuilder {
|
|
|
466
476
|
this._toolBus.register(tool, { replace: true });
|
|
467
477
|
return this;
|
|
468
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Mount host-owned plugin contributions into this Agent's ToolBus projection.
|
|
481
|
+
* Authorization is applied by ToolBus/RunScope; mounting is not Tool exposure.
|
|
482
|
+
*/
|
|
483
|
+
pluginTools(records) {
|
|
484
|
+
this._pluginToolRecords = [...this._pluginToolRecords, ...records];
|
|
485
|
+
return this;
|
|
486
|
+
}
|
|
469
487
|
/** 批量注册:逐个 try/catch,避免一个工具失败拖垮整表 */
|
|
470
488
|
tools(...tools) {
|
|
471
489
|
for (const t of tools) {
|
|
@@ -568,6 +586,17 @@ export class AgentBuilder {
|
|
|
568
586
|
this._skillDirectory = expandHomePath(dir.trim());
|
|
569
587
|
return this;
|
|
570
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Skill 启用清单(agents[].skills):discover 只保留列出的 skill id。
|
|
591
|
+
* 不调用或传 undefined = 目录内全部启用。
|
|
592
|
+
*
|
|
593
|
+
* @param ids - 允许的 skill id 列表(SKILL.md 目录名)
|
|
594
|
+
* @returns this
|
|
595
|
+
*/
|
|
596
|
+
skillAllowlist(ids) {
|
|
597
|
+
this._skillAllowlist = ids;
|
|
598
|
+
return this;
|
|
599
|
+
}
|
|
571
600
|
/** 直接注入 SkillManager(跳过目录 discover) */
|
|
572
601
|
skills(manager) {
|
|
573
602
|
this._skillManager = manager;
|
|
@@ -625,6 +654,11 @@ export class AgentBuilder {
|
|
|
625
654
|
this._wisdomStore = store;
|
|
626
655
|
return this;
|
|
627
656
|
}
|
|
657
|
+
/** 注入策略(wisdom.injection.*:coreMaxItems/scenarioMaxItems/trialVisible) */
|
|
658
|
+
wisdomInjection(cfg) {
|
|
659
|
+
this._wisdomInjection = cfg;
|
|
660
|
+
return this;
|
|
661
|
+
}
|
|
628
662
|
/** 注入 ConceptGraphStore(spreadingActivate 召回概念子图,进 system prompt CognitionLayer) */
|
|
629
663
|
cognitionStore(store) {
|
|
630
664
|
this._cognitionStore = store;
|
|
@@ -842,6 +876,8 @@ export class AgentBuilder {
|
|
|
842
876
|
const mode = options?.mode ?? 'full';
|
|
843
877
|
const events = this._events ?? new DefaultEventBus();
|
|
844
878
|
this._events = events;
|
|
879
|
+
// Shell 解析引擎(安全风险评估依赖;失败自动降级 legacy,不阻断构建)
|
|
880
|
+
await initShellParser();
|
|
845
881
|
// 并发控制:ProviderPool
|
|
846
882
|
if (this._concurrencyConfig?.providerPool && this._namedProviders.size > 0) {
|
|
847
883
|
const { ProviderPool } = await import('../run/concurrency/provider-pool.js');
|
|
@@ -903,17 +939,32 @@ export class AgentBuilder {
|
|
|
903
939
|
gates: memCfg?.gates?.maxLength
|
|
904
940
|
? { maxLength: memCfg.gates.maxLength }
|
|
905
941
|
: undefined,
|
|
906
|
-
onStored:
|
|
942
|
+
onStored: events
|
|
907
943
|
? (info) => {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
944
|
+
// 概念化请求只在 cognitionStore 存在时发(否则 conceptualize handler 无 store 会抛错)
|
|
945
|
+
if (this._cognitionStore) {
|
|
946
|
+
void import('../memory/cognition-trigger.js')
|
|
947
|
+
.then(({ emitConceptualizeRequest }) => {
|
|
948
|
+
emitConceptualizeRequest(events, {
|
|
949
|
+
memoryId: info.id,
|
|
950
|
+
proposition: info.proposition,
|
|
951
|
+
evidence: info.evidence,
|
|
952
|
+
memoryType: info.type,
|
|
953
|
+
memoryStatus: info.status,
|
|
954
|
+
channel: info.channel,
|
|
955
|
+
sessionId: info.sessionId,
|
|
956
|
+
});
|
|
957
|
+
})
|
|
958
|
+
.catch(() => {
|
|
959
|
+
// 动态加载失败不阻断 memory 写
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
void import('../memory/memory-events.js')
|
|
963
|
+
.then(({ emitMemoryStored }) => {
|
|
964
|
+
emitMemoryStored(events, {
|
|
911
965
|
memoryId: info.id,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
memoryType: info.type,
|
|
915
|
-
memoryStatus: info.status,
|
|
916
|
-
channel: info.channel,
|
|
966
|
+
type: info.type,
|
|
967
|
+
status: info.status,
|
|
917
968
|
sessionId: info.sessionId,
|
|
918
969
|
});
|
|
919
970
|
})
|
|
@@ -973,6 +1024,7 @@ export class AgentBuilder {
|
|
|
973
1024
|
}
|
|
974
1025
|
const runner = new SessionAwareRunner(agent, harness, store, {
|
|
975
1026
|
...this._runnerConfig,
|
|
1027
|
+
defaultIntentProvider: this._model,
|
|
976
1028
|
toolIsolation: this._toolIsolation ?? this._runnerConfig?.toolIsolation,
|
|
977
1029
|
effectPolicy: this._effectPolicy ?? this._runnerConfig?.effectPolicy,
|
|
978
1030
|
confirmEffect: this._confirmEffect ?? this._runnerConfig?.confirmEffect,
|
|
@@ -985,9 +1037,16 @@ export class AgentBuilder {
|
|
|
985
1037
|
sessionTaskService,
|
|
986
1038
|
sessionScheduleService,
|
|
987
1039
|
events,
|
|
988
|
-
eventSink:
|
|
989
|
-
|
|
990
|
-
|
|
1040
|
+
eventSink: (event, ctx) => {
|
|
1041
|
+
// 适配事件上 EventBus:子系统 trigger(filter.events)与总线消费方按事件名
|
|
1042
|
+
// 匹配的通路(2026-11-04 拍板 A)。llm_stream_delta 高频流片不上总线。
|
|
1043
|
+
if (event.type !== 'llm_stream_delta')
|
|
1044
|
+
events.emit(event);
|
|
1045
|
+
if (this._telemetry?.onEvent)
|
|
1046
|
+
this._telemetry.onEvent(event, ctx);
|
|
1047
|
+
else
|
|
1048
|
+
this._runnerConfig?.eventSink?.(event, ctx);
|
|
1049
|
+
},
|
|
991
1050
|
});
|
|
992
1051
|
runner.setToolContextProvider(this._contextProvider);
|
|
993
1052
|
if (this._personaResolver) {
|
|
@@ -1012,6 +1071,10 @@ export class AgentBuilder {
|
|
|
1012
1071
|
knowledgeGroupByScope: this._knowledgeCatalogOpts?.groupByScope,
|
|
1013
1072
|
knowledgeShowProgress: this._knowledgeCatalogOpts?.showProgress,
|
|
1014
1073
|
wisdomStore,
|
|
1074
|
+
wisdomCoreMaxItems: this._wisdomInjection?.coreMaxItems,
|
|
1075
|
+
wisdomScenarioMaxItems: this._wisdomInjection?.scenarioMaxItems,
|
|
1076
|
+
wisdomTrialMaxItems: this._wisdomInjection?.trialMaxItems,
|
|
1077
|
+
wisdomIncludeTrial: this._wisdomInjection?.trialVisible,
|
|
1015
1078
|
cognitionStore,
|
|
1016
1079
|
systemBudgetRatio: assemblerCfg?.systemBudgetRatio,
|
|
1017
1080
|
systemBudgetTokens: assemblerCfg?.systemBudgetTokens,
|
|
@@ -1025,6 +1088,18 @@ export class AgentBuilder {
|
|
|
1025
1088
|
},
|
|
1026
1089
|
});
|
|
1027
1090
|
runner.setSystemPromptAssembler((input) => systemPromptAssembler.assemble(input), (sid) => systemPromptAssembler.clearSession(sid));
|
|
1091
|
+
// Wisdom 归因窗口记账(学习环):run 收尾 → 窗口落库,待判官批量判决
|
|
1092
|
+
if (wisdomStore) {
|
|
1093
|
+
runner.setWisdomAttributionSink(async (info) => {
|
|
1094
|
+
try {
|
|
1095
|
+
const { recordWisdomRunWindow } = await import('../memory/wisdom-attribution.js');
|
|
1096
|
+
await recordWisdomRunWindow(wisdomStore, info);
|
|
1097
|
+
}
|
|
1098
|
+
catch {
|
|
1099
|
+
// 归因记账失败不得拖垮 run 收口
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1028
1103
|
// turn 级 Knowledge grounding(消息插槽 knowledgeGrounding;不进 system)
|
|
1029
1104
|
const groundingPort = this._knowledgeGroundingPort ?? this._knowledgeRetriever;
|
|
1030
1105
|
if (groundingPort) {
|
|
@@ -1136,6 +1211,10 @@ export class AgentBuilder {
|
|
|
1136
1211
|
if (this._cognitionStore) {
|
|
1137
1212
|
subsystemRuntime.registerDependency('conceptGraphStore', this._cognitionStore);
|
|
1138
1213
|
}
|
|
1214
|
+
{
|
|
1215
|
+
// eventBus 注入:steward handler 发 memory.stored 等信号用(可选依赖,缺失时静默跳过)
|
|
1216
|
+
subsystemRuntime.registerDependency('eventBus', events);
|
|
1217
|
+
}
|
|
1139
1218
|
{
|
|
1140
1219
|
const { InMemoryBackfillCoverageStore } = await import('../memory/backfill-coverage.js');
|
|
1141
1220
|
let coverage = this._backfillCoverage;
|
|
@@ -1306,7 +1385,7 @@ export class AgentBuilder {
|
|
|
1306
1385
|
// Skill:目录 discover(或外部注入的 manager)
|
|
1307
1386
|
if (!this._skillManager && this._skillDirectory) {
|
|
1308
1387
|
const { DefaultSkillManager } = await import('../extension/plugin-ecosystem/skills/manager.js');
|
|
1309
|
-
const mgr = new DefaultSkillManager(this._skillDirectory);
|
|
1388
|
+
const mgr = new DefaultSkillManager(this._skillDirectory, this._skillAllowlist ? { only: this._skillAllowlist } : undefined);
|
|
1310
1389
|
try {
|
|
1311
1390
|
await mgr.discover(this._skillDirectory);
|
|
1312
1391
|
this._skillManager = mgr;
|
|
@@ -1322,6 +1401,9 @@ export class AgentBuilder {
|
|
|
1322
1401
|
cwd: this._workspace?.trim() ? this._workspace : undefined,
|
|
1323
1402
|
});
|
|
1324
1403
|
const busAgentId = this._agentId ?? 'default';
|
|
1404
|
+
for (const record of this._pluginToolRecords) {
|
|
1405
|
+
this._toolBus.registerForAgent(busAgentId, pluginToolAdapter.pluginToolToRegisteredTool(record));
|
|
1406
|
+
}
|
|
1325
1407
|
const agentTools = this._toolBus.listForAgent(busAgentId).map(t => convertToAgentTool(t, this._contextProvider));
|
|
1326
1408
|
console.log(`[AgentBuilder] agent tools (${agentTools.length}): ${agentTools.map((t) => t.name).join(', ')}`);
|
|
1327
1409
|
// 创建 Agent
|
|
@@ -1331,6 +1413,7 @@ export class AgentBuilder {
|
|
|
1331
1413
|
model: this._model,
|
|
1332
1414
|
systemPrompt,
|
|
1333
1415
|
tools: agentTools,
|
|
1416
|
+
extensionHooks: this._runnerConfig?.extensionHooks,
|
|
1334
1417
|
observer: loopObserver ?? (this._observer ? {
|
|
1335
1418
|
onLLMStart: (p) => this._observer?.log('info', 'llm.start', p),
|
|
1336
1419
|
onLLMEnd: (p) => this._observer?.log('info', 'llm.end', p),
|
|
@@ -1341,7 +1424,19 @@ export class AgentBuilder {
|
|
|
1341
1424
|
const agent = new Agent(agentOptions);
|
|
1342
1425
|
// ContextEngine 接线:经 convertToLlm 调用 assemble
|
|
1343
1426
|
// 模型快照只读 ALS(Runner 每 run resolve 一次);无 snapshot 时才回退 agent.model
|
|
1344
|
-
const contextEngine = this._contextEngine ?? new DefaultContextEngine(
|
|
1427
|
+
const contextEngine = this._contextEngine ?? new DefaultContextEngine({
|
|
1428
|
+
...(this._runnerConfig?.sessionsDir
|
|
1429
|
+
? {
|
|
1430
|
+
transformStore: new (await import('../session/transform-store.js')).JsonlTransformStore({
|
|
1431
|
+
sessionsDir: this._runnerConfig.sessionsDir,
|
|
1432
|
+
}),
|
|
1433
|
+
}
|
|
1434
|
+
: {}),
|
|
1435
|
+
...(this._runnerConfig?.extensionHooks === undefined ? {} : {
|
|
1436
|
+
extensionHooks: this._runnerConfig.extensionHooks,
|
|
1437
|
+
extensionIdentity: { sessionId: 'default', agentId: busAgentId },
|
|
1438
|
+
}),
|
|
1439
|
+
});
|
|
1345
1440
|
const { getResolvedModel } = await import('../run/model/run-scope.js');
|
|
1346
1441
|
const summarizeFn = this._summarize ??
|
|
1347
1442
|
(!this._disableAutoSummarize && this._model
|
|
@@ -1357,13 +1452,18 @@ export class AgentBuilder {
|
|
|
1357
1452
|
})(messages, opts);
|
|
1358
1453
|
}
|
|
1359
1454
|
: undefined);
|
|
1360
|
-
agent.setConvertToLlm(async (messages) => {
|
|
1455
|
+
agent.setConvertToLlm(async (messages, signal) => {
|
|
1361
1456
|
// I1:身份与 systemPrompt 优先读 RunScope ALS,避免共享 Agent 单例竞态
|
|
1362
1457
|
const scope = getRunScope();
|
|
1363
1458
|
const sessionId = scope?.sessionId ?? agent.contextSessionId;
|
|
1364
1459
|
const agentId = scope?.agentId ?? 'default';
|
|
1365
1460
|
const systemPrompt = scope?.systemPrompt ?? agent.context.systemPrompt;
|
|
1366
|
-
|
|
1461
|
+
// 工具口径与请求同源(2026-11-07):run 级 tools = loop 实际发送的 toolDefs。
|
|
1462
|
+
// M-6:回退止于 []——run context 未带 tools 时 loop 发送的就是 0 个工具,估算也
|
|
1463
|
+
// 必须是 0;回落实例工具面(agent.context.tools)会让估算多算整包 tools(毒样本)。
|
|
1464
|
+
// 实例面只在 run context 本身就是实例 context 时经 scope.tools 自然成立。
|
|
1465
|
+
const toolSource = scope?.tools ?? [];
|
|
1466
|
+
const tools = toolSource.map((t) => ({
|
|
1367
1467
|
type: 'function',
|
|
1368
1468
|
function: {
|
|
1369
1469
|
name: t.name,
|
|
@@ -1381,6 +1481,7 @@ export class AgentBuilder {
|
|
|
1381
1481
|
const result = await contextEngine.assemble({
|
|
1382
1482
|
sessionId,
|
|
1383
1483
|
agentId,
|
|
1484
|
+
modelKey: snapshot?.ref,
|
|
1384
1485
|
messages,
|
|
1385
1486
|
systemPrompt,
|
|
1386
1487
|
tools,
|
|
@@ -1389,7 +1490,12 @@ export class AgentBuilder {
|
|
|
1389
1490
|
maxOutputTokens: snapshot?.maxOutputTokens,
|
|
1390
1491
|
compactTargetTokens: this._contextAssemblerConfig?.compactTargetTokens,
|
|
1391
1492
|
summarize: summarizeFn,
|
|
1493
|
+
// 交接式摘要素材(F8R-05):自动压缩路径也随摘要请求带上活任务快照;
|
|
1494
|
+
// 空串归一为 undefined——引擎口径「无素材」只有一种形状(评审 L3)
|
|
1495
|
+
taskSnapshot: scope?.taskSnapshot?.() || undefined,
|
|
1392
1496
|
loadCompactState: () => agent.getSessionCompactState(sessionId, agentId),
|
|
1497
|
+
// P3:run 中止信号 —— 摘要调用(provider.chat)随之取消;无此透传时 abort 只能干等
|
|
1498
|
+
signal,
|
|
1393
1499
|
// 惰性读 bus:覆盖 buildAgent 之后才 setEvents 的场景
|
|
1394
1500
|
// Observer:ContextEngine 侧事件(context.compact.* 等)不经过 Runner emitObserved,
|
|
1395
1501
|
// 必须在此直采 Hub,否则 timeline 永远看不到 compact。
|
|
@@ -1413,10 +1519,8 @@ export class AgentBuilder {
|
|
|
1413
1519
|
bus.emit(event);
|
|
1414
1520
|
},
|
|
1415
1521
|
});
|
|
1416
|
-
//
|
|
1417
|
-
|
|
1418
|
-
agent.setSessionCompactState(sessionId, agentId, result.compactState);
|
|
1419
|
-
}
|
|
1522
|
+
// 压缩覆盖/摘要正文由转换记录账本持久(记录先落盘后发视图);
|
|
1523
|
+
// 旧 compactState 快照回写已随记录模型退役(迁移读口仍在 run 起点)。
|
|
1420
1524
|
// Observer P1:LLM 实际输入视图(ContextEngine 出口)
|
|
1421
1525
|
// 真源 = hub.recordLlmMessages;事件只带 summarizeLlmMessages,避免双套统计/覆盖全文
|
|
1422
1526
|
if (this._observerHub?.isEnabled() && this._observerHub.getConfig().channels['context.llm']) {
|
|
@@ -1443,23 +1547,29 @@ export class AgentBuilder {
|
|
|
1443
1547
|
},
|
|
1444
1548
|
});
|
|
1445
1549
|
}
|
|
1446
|
-
//
|
|
1447
|
-
|
|
1550
|
+
// 保存 context 压力(供 harness.getContextPressure(sessionId) 使用):
|
|
1551
|
+
// 按 session 键控——共享 Agent 单例下并发会话各取自己的估算,不串号。
|
|
1552
|
+
// readingSource(评审 F5):读数是校准/实测锚定/裸估算——生产日志可判定读数可信度
|
|
1553
|
+
const pressure = {
|
|
1448
1554
|
estimatedTokens: result.estimatedTokens,
|
|
1449
1555
|
contextWindow,
|
|
1556
|
+
readingSource: result.readingSource,
|
|
1450
1557
|
};
|
|
1558
|
+
this._contextPressureBySession.set(sessionId, pressure);
|
|
1559
|
+
this._lastContextPressure = pressure;
|
|
1451
1560
|
// droppedSummary 不得进 system(动态注记打穿前缀缓存)。
|
|
1452
1561
|
// 本轮直接不投递;压缩语义由消息侧 contextSummary 承载。
|
|
1453
1562
|
return result.messages;
|
|
1454
1563
|
});
|
|
1455
|
-
agent.
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1564
|
+
agent.setOnAfterStep(async (identity, usage, step) => {
|
|
1565
|
+
// 身份只信调用方显式传入(40-engineering #8 单源):runner 事件循环跑在 run 的
|
|
1566
|
+
// ALS 窗口外,getRunScope() 会拿到泄漏的外层 scope,agent.contextSessionId 是
|
|
1567
|
+
// 共享可变字段——并发委派子 run 下两者双向串味,错位样本毒化 ratio 校准
|
|
1568
|
+
// (2026-11-09 事故:视图估算 160k vs 实测 314k)。
|
|
1569
|
+
await contextEngine.afterStep?.({
|
|
1570
|
+
sessionId: identity.sessionId,
|
|
1571
|
+
agentId: identity.agentId,
|
|
1572
|
+
step: step ?? [],
|
|
1463
1573
|
usage: usage,
|
|
1464
1574
|
});
|
|
1465
1575
|
});
|
|
@@ -1506,9 +1616,30 @@ export class AgentBuilder {
|
|
|
1506
1616
|
runGuard,
|
|
1507
1617
|
budget,
|
|
1508
1618
|
// P5: Context 压力回调(从 ContextEngine assemble 获取)
|
|
1509
|
-
getContextPressure: () =>
|
|
1619
|
+
getContextPressure: (sessionId) => sessionId !== undefined
|
|
1620
|
+
? builderRef._contextPressureBySession.get(sessionId)
|
|
1621
|
+
: builderRef._lastContextPressure,
|
|
1622
|
+
// 校准状态通道(持久化配套):export 写进 session metadata、restore 时 import——
|
|
1623
|
+
// 重启后第一轮即 anchored/calibrated,消除「跑几轮才校准」冷启动过渡
|
|
1624
|
+
exportCalibration: () => contextEngine.exportCalibration?.(),
|
|
1625
|
+
importCalibration: (data) => {
|
|
1626
|
+
contextEngine.importCalibration?.(data);
|
|
1627
|
+
},
|
|
1510
1628
|
// high 风险确认:有则走人工审批,无则 run-agent 回退 reject
|
|
1511
1629
|
confirmHighRisk: this._confirmHighRisk,
|
|
1630
|
+
// P3 告警通道:F 类反馈环(T2)的症状告警,与 ContextEngine emit 同路(Hub + EventBus)
|
|
1631
|
+
// data 形状与 emit 闭包同源(剥 type/sessionId,其余入 data)
|
|
1632
|
+
onOverflowAlert: (alert) => {
|
|
1633
|
+
const { type, sessionId: sid, ...data } = alert;
|
|
1634
|
+
const event = { type, timestamp: Date.now(), sessionId: sid, data };
|
|
1635
|
+
try {
|
|
1636
|
+
this._observerHub?.ingestEvent(event);
|
|
1637
|
+
}
|
|
1638
|
+
catch {
|
|
1639
|
+
// 观测 fail-open
|
|
1640
|
+
}
|
|
1641
|
+
this._events?.emit(event);
|
|
1642
|
+
},
|
|
1512
1643
|
};
|
|
1513
1644
|
// Agent.run() 需要 harness;Builder 组装期绑定
|
|
1514
1645
|
agent.setHarness(harness);
|
|
@@ -100,8 +100,8 @@ export async function buildFromConfig(config, options) {
|
|
|
100
100
|
const budgetConfig = config.budgetPolicy;
|
|
101
101
|
const runGuardConfig = config.runGuard;
|
|
102
102
|
const contextEngineConfig = config.contextEngine;
|
|
103
|
-
const contextAssemblerConfig = config.context?.contextAssembler
|
|
104
|
-
const constitutionConfig = config.context?.constitution
|
|
103
|
+
const contextAssemblerConfig = config.context?.contextAssembler;
|
|
104
|
+
const constitutionConfig = config.context?.constitution;
|
|
105
105
|
// 2. 加载子系统(三级搜索路径)
|
|
106
106
|
const subsystemSpecs = await resolveSubsystemSpecs();
|
|
107
107
|
// 3. 为每个 agent 构建
|
|
@@ -127,6 +127,7 @@ export async function buildFromConfig(config, options) {
|
|
|
127
127
|
subsystemAllowlist: config.subsystems?.allowlist,
|
|
128
128
|
subsystemDenylist: config.subsystems?.denylist,
|
|
129
129
|
toolIsolation: config.toolIsolation,
|
|
130
|
+
effectPolicy: config.effectPolicy,
|
|
130
131
|
sessionIdleExpiryMs: config.session?.idleExpiryMs,
|
|
131
132
|
modelCallConfig: config.modelCall,
|
|
132
133
|
concurrencyConfig: config.concurrency,
|
|
@@ -184,12 +185,18 @@ async function buildAgent(agentConfig, shared) {
|
|
|
184
185
|
await wireAgentBuilder(builder, {
|
|
185
186
|
model: provider,
|
|
186
187
|
agentId: agentConfig.id,
|
|
188
|
+
// 转换记录账本持久面(评审 F4):sessionsDir 穿到引擎工厂;缺省时引擎为
|
|
189
|
+
// 进程内存 store(首条记录有一次性告警,不静默)
|
|
190
|
+
extraRunnerConfig: shared.runnerConfig?.sessionsDir
|
|
191
|
+
? { sessionsDir: shared.runnerConfig.sessionsDir }
|
|
192
|
+
: undefined,
|
|
187
193
|
workspace: agentConfig.workspace,
|
|
188
194
|
// legacy:string persona 等价 home(config-bridge 显式决定,不进 wire 隐式规则)
|
|
189
195
|
home: agentConfig.home ??
|
|
190
196
|
(typeof agentConfig.persona === 'string' ? agentConfig.persona : undefined),
|
|
191
197
|
persona: agentConfig.persona,
|
|
192
198
|
skillDirectory: agentConfig.skillDirectory,
|
|
199
|
+
skills: agentConfig.skills,
|
|
193
200
|
tools: agentConfig.tools,
|
|
194
201
|
maxSessionRights: agentConfig.maxSessionRights,
|
|
195
202
|
effectPolicy: agentConfig.effectPolicy ?? shared.effectPolicy,
|
|
@@ -22,6 +22,19 @@ export interface SecurityConfigDrift {
|
|
|
22
22
|
/** 当前指纹(审计记录的「新摘要」) */
|
|
23
23
|
currentFingerprint: string;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* effectPolicy 中**不进热应用**的子字段(§4.3.1:需重启 + 宿主确认)。
|
|
27
|
+
*
|
|
28
|
+
* 判据是 §4.3.1 **明列**的安全闸 + 注释明确「须重启 + 宿主署名」的字段,**不是**整个
|
|
29
|
+
* 指纹范围(EFFECT_POLICY_SECURITY_KEYS)——指纹范围只回答「哪些字段变化算漂移」,
|
|
30
|
+
* 热应用禁区回答「哪些字段改了必须重启确认」,两者不可混用(把 shellEscape 等一并
|
|
31
|
+
* 划入禁区会误拒 WebUI 的合法合并编辑)。
|
|
32
|
+
*
|
|
33
|
+
* `mode` 允许热改(WebUI「安全组」四选一);`shellEscape` / `untrustedAdmission` /
|
|
34
|
+
* `pathContainment` / `toolIsolation` / `network` 是普通配置旋钮,允许热改(仍在指纹内,
|
|
35
|
+
* 改了会重锚)。ApplyEngine 据此拒绝禁区字段(评审 M2 补全此前缺失的拒绝逻辑)。
|
|
36
|
+
*/
|
|
37
|
+
export declare const EFFECT_POLICY_HOT_BLOCKED_KEYS: readonly string[];
|
|
25
38
|
/**
|
|
26
39
|
* 计算安全配置指纹(启动期锚定)。
|
|
27
40
|
*
|
|
@@ -70,3 +83,56 @@ export declare function createFileSecurityIntegrity(options: {
|
|
|
70
83
|
configPath: string;
|
|
71
84
|
anchor: SecurityConfigFingerprint;
|
|
72
85
|
}): () => SecurityConfigDrift;
|
|
86
|
+
/**
|
|
87
|
+
* 可重锚定守卫(ops P2 §8.4「WebUI 署名通道」落地):启动锚定 → 每 run 复核 →
|
|
88
|
+
* 受控写通道写盘成功后 {@link SecurityIntegrityGuard.reattest} 重新锚定。
|
|
89
|
+
*
|
|
90
|
+
* 威胁模型边界:reattest 的调用方是宿主的受控写通道(console 管理面,带鉴权),
|
|
91
|
+
* 等价于人工重启的署名确认;agent 绕过通道直改文件依然被 recheck 判漂移(拒新 run 不变)。
|
|
92
|
+
*/
|
|
93
|
+
export interface SecurityIntegrityGuard {
|
|
94
|
+
/** 当前锚定指纹(活视图:reattest 后更新;漂移审计的「旧摘要」读它) */
|
|
95
|
+
readonly fingerprint: string;
|
|
96
|
+
/** 复核当前安全配置(读不到/解析失败按漂移对待,fail-closed) */
|
|
97
|
+
recheck(): SecurityConfigDrift;
|
|
98
|
+
/**
|
|
99
|
+
* 受控写通道写盘成功后重新锚定。
|
|
100
|
+
*
|
|
101
|
+
* 两道校验(缺一不可,评审 M1):
|
|
102
|
+
* - `expectHash`:写盘方给出的写后原文 hash。rename 与重锚之间若有第三方写入
|
|
103
|
+
* (TOCTOU),hash 不符 → 拒绝重锚。
|
|
104
|
+
* - `allowedChanged`:允许被本次写改变的顶层安全字段。changed 超出白名单 =
|
|
105
|
+
* 既存篡改或越权写(正是 §8.4 要防的自提权面)→ 拒绝重锚,防止一次无关的
|
|
106
|
+
* console 写把已存在的漂移「洗白」。
|
|
107
|
+
*
|
|
108
|
+
* 两者任一不符即抛错:调用方降级为 warning,守卫维持漂移态(fail-closed),
|
|
109
|
+
* 直至宿主重启采纳盘上配置。
|
|
110
|
+
*
|
|
111
|
+
* @param options - 校验参数(见上)
|
|
112
|
+
* @returns 旧→新指纹与变化字段
|
|
113
|
+
* @throws 校验不符 / 盘上文件读不到
|
|
114
|
+
*/
|
|
115
|
+
reattest(options?: {
|
|
116
|
+
/** 写后原文 hash(`computeConfigHash`);不符 = TOCTOU,拒绝重锚 */
|
|
117
|
+
expectHash?: string;
|
|
118
|
+
/**
|
|
119
|
+
* 允许变化的顶层安全字段(`'agents'` | `'effectPolicy'` | `'security'` | `'plugins'`)。
|
|
120
|
+
* 省略 = 不限(仅宿主显式全量确认,如重启采纳盘上配置)
|
|
121
|
+
*/
|
|
122
|
+
allowedChanged?: string[];
|
|
123
|
+
}): {
|
|
124
|
+
previousFingerprint: string;
|
|
125
|
+
fingerprint: string;
|
|
126
|
+
changed: string[];
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 基于配置文件的可重锚定守卫。
|
|
131
|
+
*
|
|
132
|
+
* @param options.configPath - 配置文件绝对路径
|
|
133
|
+
* @returns 守卫(锚定与复核同口径:都取 raw 文件安全切面)
|
|
134
|
+
* @throws 启动期文件读不到/解析失败(fail-fast,与锚定即拒绝启动的既有语义一致)
|
|
135
|
+
*/
|
|
136
|
+
export declare function createSecurityIntegrityGuard(options: {
|
|
137
|
+
configPath: string;
|
|
138
|
+
}): SecurityIntegrityGuard;
|