@octopi-agent/engine 0.98.4 → 0.121.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/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +6 -2
- package/dist/config-admin/index.js +3 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +71 -0
- package/dist/config-admin/onboarding-apply.js +235 -0
- package/dist/config-admin/onboarding.d.ts +154 -0
- package/dist/config-admin/onboarding.js +270 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +40 -6
- package/dist/config-schema/agent.js +44 -6
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +12 -37
- package/dist/config-schema/context.js +10 -31
- package/dist/config-schema/engine.d.ts +140 -164
- package/dist/config-schema/engine.js +10 -7
- package/dist/config-schema/governance.d.ts +20 -2
- package/dist/config-schema/governance.js +18 -3
- package/dist/config-schema/models.d.ts +10 -12
- package/dist/config-schema/models.js +16 -3
- package/dist/config-schema/run.d.ts +6 -2
- package/dist/config-schema/run.js +12 -2
- package/dist/config-schema/shared.d.ts +1 -3
- package/dist/config-schema/shared.js +4 -4
- package/dist/config-schema/substrate.d.ts +19 -88
- package/dist/config-schema/substrate.js +30 -107
- package/dist/config.d.ts +161 -123
- package/dist/config.js +109 -7
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +11 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +130 -31
- package/dist/harness/activation/types.d.ts +20 -3
- package/dist/harness/agent/builder.d.ts +36 -3
- package/dist/harness/agent/builder.js +206 -46
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +24 -5
- package/dist/harness/agent/config-integrity.js +19 -2
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +13 -3
- package/dist/harness/agent/wire-agent-builder.js +35 -9
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- 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/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +2 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +14 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +50 -41
- 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/executor.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +7 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +10 -1
- package/dist/harness/collaboration/delegation/child-run.js +38 -6
- 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/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +11 -4
- package/dist/harness/collaboration/delegation/service.js +35 -13
- package/dist/harness/collaboration/delegation/store.d.ts +4 -0
- package/dist/harness/collaboration/delegation/store.js +3 -1
- package/dist/harness/collaboration/delegation/types.d.ts +34 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +12 -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 +44 -11
- package/dist/harness/context/capabilities/compact/engine.js +296 -160
- 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 +7 -2
- package/dist/harness/context/capabilities/compact/index.js +5 -1
- 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 +134 -19
- 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/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +19 -6
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +243 -0
- package/dist/harness/context/default-context-engine.d.ts +290 -120
- package/dist/harness/context/default-context-engine.js +1555 -764
- package/dist/harness/context/index.d.ts +3 -2
- package/dist/harness/context/index.js +2 -1
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +72 -0
- package/dist/harness/context/layer-types.js +87 -2
- package/dist/harness/context/layers.d.ts +17 -15
- package/dist/harness/context/layers.js +54 -17
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +27 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +7 -3
- 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 +109 -16
- package/dist/harness/context/tool-result-aging.js +220 -55
- 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 +196 -119
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- 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/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +28 -2
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -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/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +223 -222
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +218 -203
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +78 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +80 -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 +57 -114
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +279 -282
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +46 -484
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +123 -345
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +50 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +144 -20
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +17 -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/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +36 -8
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- 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 +19 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- 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/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- 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/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +17 -15
- package/dist/harness/index.js +9 -9
- package/dist/harness/knowledge/boot-config.d.ts +57 -0
- package/dist/harness/knowledge/boot-config.js +52 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +77 -9
- package/dist/harness/knowledge/client.js +95 -24
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +112 -41
- 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 +11 -7
- package/dist/harness/knowledge/grounding.js +7 -2
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +117 -25
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- 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 +5 -3
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +25 -4
- package/dist/harness/knowledge/query-service.js +79 -43
- package/dist/harness/knowledge/query-worker-client.d.ts +14 -2
- package/dist/harness/knowledge/query-worker-client.js +8 -3
- package/dist/harness/knowledge/query-worker.js +9 -5
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +14 -3
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +14 -8
- package/dist/harness/knowledge/serve.js +14 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +323 -74
- package/dist/harness/knowledge/start-service-process.d.ts +41 -14
- package/dist/harness/knowledge/start-service-process.js +67 -96
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +55 -11
- package/dist/harness/knowledge/writer-service.js +200 -30
- package/dist/harness/knowledge/writer-worker-client.d.ts +19 -11
- package/dist/harness/knowledge/writer-worker-client.js +40 -5
- package/dist/harness/knowledge/writer-worker.js +20 -5
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +24 -6
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +120 -17
- 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 +67 -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/concurrency/tool-validator.js +4 -3
- 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 +32 -4
- package/dist/harness/run/reliability/run-agent.js +216 -63
- 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-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +48 -4
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +181 -39
- package/dist/harness/run/runner.js +654 -119
- 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/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -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 +11 -15
- package/dist/harness/shared/events/agent-event-map.d.ts +75 -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/types/agent-definition.d.ts +7 -2
- package/dist/index.d.ts +16 -18
- package/dist/index.js +9 -10
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- 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-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +41 -3
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +48 -2
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +57 -3
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +20 -2
- package/dist/integration/storage/archive-manager.js +34 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +10 -1
- package/dist/integration/storage/jsonl.js +155 -54
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +4 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +14 -15
- 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
|
@@ -4,38 +4,111 @@
|
|
|
4
4
|
* @module harness/context/capabilities/compact/types
|
|
5
5
|
*/
|
|
6
6
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
7
|
-
import type { LLMMessage } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
8
|
-
import type { SummaryCoverage, SummaryPolicy
|
|
7
|
+
import type { LLMMessage, LLMToolDefinition } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
8
|
+
import type { SummaryCoverage, SummaryPolicy } from '../summary/types.js';
|
|
9
|
+
import type { ContextSizeSnapshot } from '../../types.js';
|
|
9
10
|
export type CompactMode = 'structure_only' | 'summary_only' | 'head_tail_only' | 'auto';
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* 摘要执行函数(族 A 交接式摘要的唯一执行契约,manual / proactive / overflow 共用)。
|
|
13
|
+
*
|
|
14
|
+
* 契约(迭代式更新):`options.previousSummary` 已按约定嵌入 `messages` 正文
|
|
15
|
+
* ("Previous summary: …" 段),实现方无需再读 opts 拼 prompt;**返回值即完整
|
|
16
|
+
* 更新后的摘要**,调用方不得再与旧摘要拼接。
|
|
17
|
+
*
|
|
18
|
+
* `messages` 的两种形状:① llmPrefix 分支 = 会话同形前缀(system + 折叠视图)+ 尾部
|
|
19
|
+
* 一条指令 user——实现方不得改写/重排前缀字节(前缀缓存);② textify 旁路 = 指令
|
|
20
|
+
* system + 文本化中段。工具面不在 `messages` 里,随 `options.tools` 一并透传给 provider
|
|
21
|
+
* (缓存前缀是 tools → system → messages,缺 tools 会整段 miss)。
|
|
22
|
+
*
|
|
23
|
+
* @param messages - 摘要请求消息(同形前缀或文本化中段;见上)
|
|
24
|
+
* @param options - 摘要选项
|
|
25
|
+
* @returns 完整更新后的摘要文本
|
|
13
26
|
*/
|
|
14
|
-
export type
|
|
27
|
+
export type SummarizeFunction = (messages: LLMMessage[], options?: {
|
|
15
28
|
/** 上次摘要(已嵌入 messages 正文;仅作元信息回传) */
|
|
16
29
|
previousSummary?: string;
|
|
30
|
+
/** 摘要 token 预算 */
|
|
17
31
|
maxTokens?: number;
|
|
32
|
+
/** 自定义指令 */
|
|
18
33
|
instructions?: string;
|
|
34
|
+
/**
|
|
35
|
+
* usage 回传(2026-11-08 outputTokens 真值):摘要请求的 provider 实测输出 tokens。
|
|
36
|
+
* 摘要产物的体量以此为准(真值),估算只作无回传时的兜底——「放着真值用估算」
|
|
37
|
+
* 是压缩计量的口径缺陷(tokensBefore/After 核对,2026-11-08)。
|
|
38
|
+
*/
|
|
39
|
+
onUsage?: (usage: {
|
|
40
|
+
outputTokens?: number;
|
|
41
|
+
}) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 工具面(与会话请求逐字节相同):摘要请求必须同形才能吃到前缀缓存
|
|
44
|
+
*(缓存前缀 = tools → system → messages,2026-11-12 实测缺 tools 导致 0 命中)。
|
|
45
|
+
* 调用方提供的实现应原样透传给 provider,不要裁剪/重排。
|
|
46
|
+
*/
|
|
47
|
+
tools?: LLMToolDefinition[];
|
|
48
|
+
/**
|
|
49
|
+
* 中止信号(P3):run 中止或摘要预算超时都必须能取消在飞请求,
|
|
50
|
+
* 否则 UI 只能干等到 provider 侧超时(2026-11-07 事故:2.13MB 非流式请求挂 20+ 分钟)。
|
|
51
|
+
*/
|
|
52
|
+
signal?: AbortSignal;
|
|
19
53
|
}) => Promise<string>;
|
|
20
54
|
export interface CompactTokenEstimator {
|
|
21
55
|
estimateMessages(messages: Message[]): number;
|
|
22
56
|
estimateText(text: string): number;
|
|
23
57
|
}
|
|
58
|
+
/** CompactEngine 上报事件(唯一出口:调用方把它映射为 agent 事件)。
|
|
59
|
+
*
|
|
60
|
+
* `contamination` 于 2026-11-13 新增:闸门判定必须可观测——事故里一次误判触发
|
|
61
|
+
* 整包 348k token 重发、+59s,但全程零事件,UI 只有「已等待 Ns」,日志无迹可查。 */
|
|
62
|
+
export type CompactEngineEvent = {
|
|
63
|
+
type: 'compact.start';
|
|
64
|
+
reason?: string;
|
|
65
|
+
cached?: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'compact.end';
|
|
68
|
+
reason?: string;
|
|
69
|
+
cached?: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'compact.error';
|
|
72
|
+
reason?: string;
|
|
73
|
+
cached?: boolean;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'compact.summarize_fallback';
|
|
76
|
+
reason?: string;
|
|
77
|
+
cached?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'compact.contamination';
|
|
80
|
+
reason?: string;
|
|
81
|
+
/** 判定结论;clean = 通过 */
|
|
82
|
+
verdict: 'clean' | 'canned_refusal' | 'transcript_shape' | 'verbatim_echo';
|
|
83
|
+
/** 第几次尝试(1=首次,2=strict 重试) */
|
|
84
|
+
attempt: number;
|
|
85
|
+
echoHits?: number;
|
|
86
|
+
echoHitChars?: number;
|
|
87
|
+
textChars?: number;
|
|
88
|
+
};
|
|
24
89
|
export interface CompactOptions {
|
|
25
90
|
protectHead?: number;
|
|
26
91
|
protectTail?: number;
|
|
27
92
|
targetTokens?: number;
|
|
28
93
|
mode?: CompactMode;
|
|
29
|
-
/**
|
|
30
|
-
|
|
94
|
+
/** Hook 归因身份:手动压缩不在 RunScope 内,调用方显式身份优先于 RunScope 回落 */
|
|
95
|
+
sessionId?: string;
|
|
96
|
+
agentId?: string;
|
|
97
|
+
/** conversation 策略或显式 policy / id;经 buildSystemPrompt 产指令,要求 output:'text' 策略 */
|
|
31
98
|
summarizePolicy?: SummaryPolicy | string;
|
|
32
|
-
/**
|
|
33
|
-
summarizeFn?:
|
|
34
|
-
/**
|
|
35
|
-
summaryPort?: SummaryPort;
|
|
99
|
+
/** 注入的摘要执行函数(族 A;契约见 SummarizeFunction) */
|
|
100
|
+
summarizeFn?: SummarizeFunction;
|
|
101
|
+
/** 摘要失败/取消时的降级策略:truncate=裁掉未覆盖中段(宁可瘦不丢坏),keep_partial=保留部分产物 */
|
|
36
102
|
onSummarizeFail?: 'truncate' | 'keep_partial';
|
|
37
103
|
estimator?: CompactTokenEstimator;
|
|
38
104
|
previousSummary?: string;
|
|
105
|
+
/**
|
|
106
|
+
* 摘要增量素材(M-4):上一份摘要覆盖终点之后、保护尾之前的新消息。与 previousSummary
|
|
107
|
+
* 同时给出时,textify 旁路只文本化本段(合并契约:previousSummary + 新消息 = 完整
|
|
108
|
+
* 更新),不再把已覆盖历史以全量 raw middle 复发(2.13MB 事故形状)。缺省 = 全量
|
|
109
|
+
* middle(首次压缩/无摘要兜底)。
|
|
110
|
+
*/
|
|
111
|
+
freshMessages?: Message[];
|
|
39
112
|
maxSummaryTokens?: number;
|
|
40
113
|
/**
|
|
41
114
|
* 摘要软目标预算(P1c 拍板缺省 clamp(2%, 2k, 8k)):写进指令的「尽量控制在 N tokens」,
|
|
@@ -55,25 +128,41 @@ export interface CompactOptions {
|
|
|
55
128
|
* 防止模型只总结眼前最近的尾部、漏掉真正要被折叠的旧中段。
|
|
56
129
|
*/
|
|
57
130
|
foldRange?: {
|
|
131
|
+
/** 本次需要并入摘要的消息条数(既有摘要之后、保护尾之前) */
|
|
58
132
|
replacedCount: number;
|
|
133
|
+
/** 会话消息总数 */
|
|
59
134
|
total: number;
|
|
135
|
+
/** 原样保留的尾部条数 */
|
|
60
136
|
preservedTail: number;
|
|
137
|
+
/** 前缀里上一份摘要已经代表的早期消息条数(0/缺省 = 无既有摘要) */
|
|
138
|
+
coveredCount?: number;
|
|
61
139
|
};
|
|
62
140
|
/** 会话模型窗口(评审 F5):provider 多按 input+max_tokens ≤ window 校验,压缩恰在最满时触发 */
|
|
63
141
|
contextWindow?: number;
|
|
64
142
|
/** 会话模型输出上限(评审 F5):保险丝不得越过模型自身的 max output */
|
|
65
143
|
maxOutputTokens?: number;
|
|
66
144
|
/**
|
|
67
|
-
*
|
|
145
|
+
* 缓存前缀 = **请求视图**(messages + tools 原子单位,见 core `RequestView`)。
|
|
146
|
+
*
|
|
147
|
+
* 为什么是一个字段而不是两个:提示缓存的前缀顺序是 tools → system → messages。
|
|
148
|
+
* 拆成 `llmPrefix` + `llmTools` 两个可选参数时,"只传消息忘了工具"在类型上合法,
|
|
149
|
+
* 摘要请求会静默退化为冷 prefill(2026-11-12 实测:384k 输入 0 命中、203s)。
|
|
150
|
+
* 一个字段 + 必填 tools = 该错误在类型层无法表达。
|
|
151
|
+
*
|
|
68
152
|
* summarizeFn 路径只许尾部追加指令;禁止改写前缀字节。
|
|
69
153
|
*/
|
|
70
|
-
|
|
154
|
+
requestView?: import('@octopi-agent/core/loop/types.js').RequestView;
|
|
155
|
+
/**
|
|
156
|
+
* 回声比对源覆盖(P2):前缀含既有摘要占位时,占位正文不得参与回声判定——
|
|
157
|
+
* 模型复用/续写上一份交接书不是「复读原文」。缺省回落到前缀文本投影。
|
|
158
|
+
*/
|
|
159
|
+
echoSource?: string;
|
|
160
|
+
/**
|
|
161
|
+
* 中止信号(P3):run 中止 / 摘要预算超时 → 取消在飞摘要请求。
|
|
162
|
+
* 取消产生的错误按 onSummarizeFail 降级(调用方另按 signal.aborted 决定是否写记录)。
|
|
163
|
+
*/
|
|
71
164
|
signal?: AbortSignal;
|
|
72
|
-
emit?: (e:
|
|
73
|
-
type: 'compact.start' | 'compact.end' | 'compact.error' | 'compact.summarize_fallback';
|
|
74
|
-
reason?: string;
|
|
75
|
-
cached?: boolean;
|
|
76
|
-
}) => void;
|
|
165
|
+
emit?: (e: CompactEngineEvent) => void;
|
|
77
166
|
}
|
|
78
167
|
export interface CompactOutcome {
|
|
79
168
|
ok: boolean;
|
|
@@ -82,14 +171,41 @@ export interface CompactOutcome {
|
|
|
82
171
|
tokensBefore: number;
|
|
83
172
|
tokensAfter?: number;
|
|
84
173
|
summary?: string;
|
|
174
|
+
/** 摘要覆盖终点(下标,不含)= tailStart:E4 状态推进与重放共用锚点。
|
|
175
|
+
* 手动路径(structuralCompact)产出;失败/未新鲜摘要时携带旧值或留空。 */
|
|
176
|
+
coveredMessageCount?: number;
|
|
85
177
|
/** 本次是否产出了**新的**语义摘要(评审 F1):false 时 summary 只是旧摘要兜底,
|
|
86
178
|
* 调用方不得据此推进覆盖计数/覆盖点(否则未摘要的中段会被记成「已覆盖」)。 */
|
|
87
179
|
fresh?: boolean;
|
|
180
|
+
/** 本次是否真正发起过摘要 LLM 调用(成功/失败均算):冷却时间戳只随 true 推进(F8R-01)。
|
|
181
|
+
* 必填(显式标注,杜绝空值歧义):机械/早退路径
|
|
182
|
+
* (empty、within_target、too_short、head_tail_only)显式 false,不许留空。 */
|
|
183
|
+
summarizeAttempted: boolean;
|
|
184
|
+
/** fresh 摘要响应的 provider 实测输出 tokens(onUsage 回传,2026-11-08):
|
|
185
|
+
* 摘要产物体量的真值;无回传(自定义 summarizeFn/失败)时缺省,计量回落估算。 */
|
|
186
|
+
summaryOutputTokens?: number;
|
|
88
187
|
coverage?: SummaryCoverage;
|
|
188
|
+
/**
|
|
189
|
+
* 当前上下文大小快照(显示槽,压缩后估算口径 = tokensAfter 同值同源):
|
|
190
|
+
* runner 据此持久化 session.metadata.contextSize(web 顶栏唯一取数源)。
|
|
191
|
+
*/
|
|
192
|
+
contextSize?: ContextSizeSnapshot;
|
|
89
193
|
/** Message[] 或纯文本结果,由入口决定 */
|
|
90
194
|
view: Message[] | string;
|
|
91
195
|
droppedSummary?: string;
|
|
92
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* 锁面/传输层结果投影:`CompactOutcome` 去 `view`(大对象,UI 无需,不过锁面)。
|
|
199
|
+
* 新增可选字段自动随契约流动——**禁止**在 runner/gateway 手抄字段表(会静默丢新字段)。
|
|
200
|
+
*/
|
|
201
|
+
export type CompactTransportOutcome = Omit<CompactOutcome, 'view'>;
|
|
202
|
+
/**
|
|
203
|
+
* 把能力结果投影为传输结果(唯一投影实现)。
|
|
204
|
+
*
|
|
205
|
+
* @param result - 能力层压缩结果
|
|
206
|
+
* @returns 剥离 view 后的传输结果
|
|
207
|
+
*/
|
|
208
|
+
export declare function toCompactTransport(result: CompactOutcome): CompactTransportOutcome;
|
|
93
209
|
export interface CompactEngine {
|
|
94
210
|
/**
|
|
95
211
|
* 压缩消息序列(会话 / 旁路)
|
|
@@ -113,6 +229,5 @@ export interface CreateCompactEngineOptions {
|
|
|
113
229
|
defaultProtectTail?: number;
|
|
114
230
|
defaultTargetTokens?: number;
|
|
115
231
|
defaultMode?: CompactMode;
|
|
116
|
-
summaryPort?: SummaryPort;
|
|
117
232
|
estimator?: CompactTokenEstimator;
|
|
118
233
|
}
|
|
@@ -3,4 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module harness/context/capabilities/compact/types
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 把能力结果投影为传输结果(唯一投影实现)。
|
|
8
|
+
*
|
|
9
|
+
* @param result - 能力层压缩结果
|
|
10
|
+
* @returns 剥离 view 后的传输结果
|
|
11
|
+
*/
|
|
12
|
+
export function toCompactTransport(result) {
|
|
13
|
+
const { view: _view, ...rest } = result;
|
|
14
|
+
void _view; // 有意剥离:view 不过锁面
|
|
15
|
+
return rest;
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 切片手术 — 视图边界对齐与语义过滤的唯一实现
|
|
3
|
+
*
|
|
4
|
+
* P3(2026-11-03)自 DefaultContextEngine 迁入:引擎瘦身为触发/状态层,
|
|
5
|
+
* 「怎么切」属执行手术归本模块。**修 #10**:compact 引擎自身的 head/tail 切片
|
|
6
|
+
* 从此也走 `alignViewSplit`(此前裸 slice 会把 tool_call/tool_result 对劈开:
|
|
7
|
+
* head 停在带 toolCalls 的 assistant 上 → 悬空调用;tail 起于 tool 结果 →
|
|
8
|
+
* 孤儿结果,两者都会被严格网关 400)。
|
|
9
|
+
*
|
|
10
|
+
* @module harness/context/capabilities/compact/view-split
|
|
11
|
+
*/
|
|
12
|
+
import type { Message } from '@octopi-agent/core/types.js';
|
|
13
|
+
/**
|
|
14
|
+
* 视图切分边界对齐(不拆 tool_call/tool_result 对)。
|
|
15
|
+
*
|
|
16
|
+
* head 不得停在带 toolCalls 的 assistant 上(其结果落入中间段,视图里会成悬空调用);
|
|
17
|
+
* tail 不得起于 tool 结果(其调用在中间段,会成孤儿结果)。
|
|
18
|
+
*
|
|
19
|
+
* @param messages - 全量消息
|
|
20
|
+
* @param headCount - 期望头部条数
|
|
21
|
+
* @param tailCount - 期望尾部条数
|
|
22
|
+
* @returns 对齐后的 head 终点(不含)与 tail 起点(含);对齐后实际条数可能与期望不同
|
|
23
|
+
*/
|
|
24
|
+
export declare function alignViewSplit(messages: Message[], headCount: number, tailCount: number): {
|
|
25
|
+
headEnd: number;
|
|
26
|
+
tailStart: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 压缩/摘要的语义输入:丢掉托管 system 与 turn 信封元数据
|
|
30
|
+
* (turn_context picks 不进 previousSummary——防陈旧择取固化进摘要);
|
|
31
|
+
* turn_start 只保留 <user_message> 正文。
|
|
32
|
+
*
|
|
33
|
+
* @param messages - 待过滤消息
|
|
34
|
+
* @returns 语义历史(过滤后的消息列表)
|
|
35
|
+
*/
|
|
36
|
+
export declare function semanticHistory(messages: Message[]): Message[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 切片手术 — 视图边界对齐与语义过滤的唯一实现
|
|
3
|
+
*
|
|
4
|
+
* P3(2026-11-03)自 DefaultContextEngine 迁入:引擎瘦身为触发/状态层,
|
|
5
|
+
* 「怎么切」属执行手术归本模块。**修 #10**:compact 引擎自身的 head/tail 切片
|
|
6
|
+
* 从此也走 `alignViewSplit`(此前裸 slice 会把 tool_call/tool_result 对劈开:
|
|
7
|
+
* head 停在带 toolCalls 的 assistant 上 → 悬空调用;tail 起于 tool 结果 →
|
|
8
|
+
* 孤儿结果,两者都会被严格网关 400)。
|
|
9
|
+
*
|
|
10
|
+
* @module harness/context/capabilities/compact/view-split
|
|
11
|
+
*/
|
|
12
|
+
import { extractUserMessageText, isTurnStartContent, } from '../../turn-envelope.js';
|
|
13
|
+
import { isToolResultMessage } from './messages.js';
|
|
14
|
+
/**
|
|
15
|
+
* 视图切分边界对齐(不拆 tool_call/tool_result 对)。
|
|
16
|
+
*
|
|
17
|
+
* head 不得停在带 toolCalls 的 assistant 上(其结果落入中间段,视图里会成悬空调用);
|
|
18
|
+
* tail 不得起于 tool 结果(其调用在中间段,会成孤儿结果)。
|
|
19
|
+
*
|
|
20
|
+
* @param messages - 全量消息
|
|
21
|
+
* @param headCount - 期望头部条数
|
|
22
|
+
* @param tailCount - 期望尾部条数
|
|
23
|
+
* @returns 对齐后的 head 终点(不含)与 tail 起点(含);对齐后实际条数可能与期望不同
|
|
24
|
+
*/
|
|
25
|
+
export function alignViewSplit(messages, headCount, tailCount) {
|
|
26
|
+
let headEnd = Math.max(0, Math.min(headCount, messages.length));
|
|
27
|
+
while (headEnd > 0 && (messages[headEnd - 1]?.toolCalls?.length ?? 0) > 0) {
|
|
28
|
+
headEnd--;
|
|
29
|
+
}
|
|
30
|
+
let tailStart = Math.max(0, messages.length - tailCount);
|
|
31
|
+
// tailCount=0 时 tailStart === messages.length(空尾):不得越界读 messages[len]
|
|
32
|
+
while (tailStart > headEnd &&
|
|
33
|
+
tailStart < messages.length &&
|
|
34
|
+
isToolResultMessage(messages[tailStart])) {
|
|
35
|
+
tailStart--;
|
|
36
|
+
}
|
|
37
|
+
// protectN 总和 > messages.length 时裸值可畸形(headEnd > tailStart):夹回合法切点,
|
|
38
|
+
// 禁止 head/tail 重叠重复出消息(调用方多有过短早退,这里是 API 直调用户的护栏)
|
|
39
|
+
if (tailStart < headEnd) {
|
|
40
|
+
tailStart = headEnd;
|
|
41
|
+
}
|
|
42
|
+
return { headEnd, tailStart };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 压缩/摘要的语义输入:丢掉托管 system 与 turn 信封元数据
|
|
46
|
+
* (turn_context picks 不进 previousSummary——防陈旧择取固化进摘要);
|
|
47
|
+
* turn_start 只保留 <user_message> 正文。
|
|
48
|
+
*
|
|
49
|
+
* @param messages - 待过滤消息
|
|
50
|
+
* @returns 语义历史(过滤后的消息列表)
|
|
51
|
+
*/
|
|
52
|
+
export function semanticHistory(messages) {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const m of messages) {
|
|
55
|
+
if (m.role === 'system' && m.metadata?.source === 'systemPrompt')
|
|
56
|
+
continue;
|
|
57
|
+
if (m.metadata?.source === 'turnEnd')
|
|
58
|
+
continue;
|
|
59
|
+
if (m.metadata?.source === 'knowledgeGrounding')
|
|
60
|
+
continue;
|
|
61
|
+
if (m.metadata?.source === 'runtimeSnapshot')
|
|
62
|
+
continue;
|
|
63
|
+
if (m.metadata?.source === 'sessionAttachment')
|
|
64
|
+
continue;
|
|
65
|
+
if (isTurnStartContent(m.content)) {
|
|
66
|
+
out.push({ ...m, content: extractUserMessageText(m.content) });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
out.push(m);
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module harness/context/capabilities/summary/gate
|
|
5
5
|
*/
|
|
6
|
-
import type { ContentUnit, SummaryGateConfig } from './types.js';
|
|
6
|
+
import type { ContentUnit, L1KeepMode, SummaryGateConfig } from './types.js';
|
|
7
7
|
export declare const DEFAULT_GATE: Required<Pick<SummaryGateConfig, 'minTokens' | 'minBytes' | 'respectPolicyBudget'>>;
|
|
8
8
|
/**
|
|
9
9
|
* 合并 gate 配置
|
|
@@ -28,6 +28,13 @@ export interface L1TruncateResult {
|
|
|
28
28
|
text: string;
|
|
29
29
|
truncated: boolean;
|
|
30
30
|
rawLength: number;
|
|
31
|
+
/**
|
|
32
|
+
* 实际生效的保留策略
|
|
33
|
+
*
|
|
34
|
+
* `head`/`tail`/`both` 原样回传;未声明时按缺省解析为 `head`。
|
|
35
|
+
* 调用方可据此判断「被省略的是哪一端」,无需自己推断。
|
|
36
|
+
*/
|
|
37
|
+
keep: L1KeepMode;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* L1 硬顶截断 + 可操作占位
|
|
@@ -35,9 +42,19 @@ export interface L1TruncateResult {
|
|
|
35
42
|
* `maxChars` 约束**进入 LLM 的最终字符串总长**(正文 + 截断说明 + 续读提示)。
|
|
36
43
|
* 空间不足时优先保留完整 hint(可操作性),正文可为 0。
|
|
37
44
|
*
|
|
45
|
+
* `keep` 决定保留区段:
|
|
46
|
+
*
|
|
47
|
+
* - `head`——保留开头。既有行为,缺省。
|
|
48
|
+
* - `tail`——保留结尾。用于「结论在末尾」的输出(测试汇总、退出信息、日志尾)。
|
|
49
|
+
* - `both`——保头 + 保尾 + 中间省略标记。用于「开头上下文、末尾结论」的混合输出。
|
|
50
|
+
*
|
|
51
|
+
* 三种模式下正文配额相同(`maxChars` 减去通知文本),只是分配方式不同;
|
|
52
|
+
* `both` 各取一半,余数给头部(头部通常承载「这是什么」的语境)。
|
|
53
|
+
*
|
|
38
54
|
* @param raw - 原文或 L2 结果
|
|
39
55
|
* @param maxChars - 最终返回给 LLM 的最大字符数
|
|
40
56
|
* @param hint - 续读提示
|
|
57
|
+
* @param keep - 保留策略(缺省 `head`)
|
|
41
58
|
* @returns 截断结果
|
|
42
59
|
*/
|
|
43
|
-
export declare function applyL1Truncate(raw: string, maxChars: number, hint: string): L1TruncateResult;
|
|
60
|
+
export declare function applyL1Truncate(raw: string, maxChars: number, hint: string, keep?: L1KeepMode): L1TruncateResult;
|
|
@@ -41,29 +41,76 @@ export function shouldProcessUnit(unit, gate, _policyMaxInputTokens) {
|
|
|
41
41
|
* `maxChars` 约束**进入 LLM 的最终字符串总长**(正文 + 截断说明 + 续读提示)。
|
|
42
42
|
* 空间不足时优先保留完整 hint(可操作性),正文可为 0。
|
|
43
43
|
*
|
|
44
|
+
* `keep` 决定保留区段:
|
|
45
|
+
*
|
|
46
|
+
* - `head`——保留开头。既有行为,缺省。
|
|
47
|
+
* - `tail`——保留结尾。用于「结论在末尾」的输出(测试汇总、退出信息、日志尾)。
|
|
48
|
+
* - `both`——保头 + 保尾 + 中间省略标记。用于「开头上下文、末尾结论」的混合输出。
|
|
49
|
+
*
|
|
50
|
+
* 三种模式下正文配额相同(`maxChars` 减去通知文本),只是分配方式不同;
|
|
51
|
+
* `both` 各取一半,余数给头部(头部通常承载「这是什么」的语境)。
|
|
52
|
+
*
|
|
44
53
|
* @param raw - 原文或 L2 结果
|
|
45
54
|
* @param maxChars - 最终返回给 LLM 的最大字符数
|
|
46
55
|
* @param hint - 续读提示
|
|
56
|
+
* @param keep - 保留策略(缺省 `head`)
|
|
47
57
|
* @returns 截断结果
|
|
48
58
|
*/
|
|
49
|
-
export function applyL1Truncate(raw, maxChars, hint) {
|
|
59
|
+
export function applyL1Truncate(raw, maxChars, hint, keep = 'head') {
|
|
50
60
|
const rawLength = raw.length;
|
|
51
61
|
if (rawLength <= maxChars) {
|
|
52
|
-
return { text: raw, truncated: false, rawLength };
|
|
62
|
+
return { text: raw, truncated: false, rawLength, keep };
|
|
63
|
+
}
|
|
64
|
+
const headNotice = (shown) => `[truncated: showing first ${shown} of ${rawLength} chars] ${hint}`;
|
|
65
|
+
if (keep === 'tail') {
|
|
66
|
+
const tailNotice = (shown) => `[truncated: showing last ${shown} of ${rawLength} chars] ${hint}`;
|
|
67
|
+
// 在总长约束下取最大的 shown,使 notice + '\n' + tail ≤ maxChars
|
|
68
|
+
for (let shown = Math.min(rawLength, maxChars); shown >= 0; shown--) {
|
|
69
|
+
const candidate = `${tailNotice(shown)}\n${raw.slice(rawLength - shown)}`;
|
|
70
|
+
if (candidate.length <= maxChars) {
|
|
71
|
+
return { text: candidate, truncated: true, rawLength, keep };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const fallback = tailNotice(0);
|
|
75
|
+
return {
|
|
76
|
+
text: fallback.length <= maxChars ? fallback : fallback.slice(0, maxChars),
|
|
77
|
+
truncated: true,
|
|
78
|
+
rawLength,
|
|
79
|
+
keep,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (keep === 'both') {
|
|
83
|
+
const bothNotice = (head, tail) => `[truncated: showing first ${head} + last ${tail} of ${rawLength} chars, ${rawLength - head - tail} omitted] ${hint}`;
|
|
84
|
+
// 通知文本比 head 模式长(含两段计数与省略量),先按最坏情况预留,再放大配额
|
|
85
|
+
for (let total = Math.min(rawLength, maxChars); total >= 0; total--) {
|
|
86
|
+
const head = Math.ceil(total / 2);
|
|
87
|
+
const tail = total - head;
|
|
88
|
+
const candidate = `${raw.slice(0, head)}\n${bothNotice(head, tail)}\n${raw.slice(rawLength - tail)}`;
|
|
89
|
+
if (candidate.length <= maxChars) {
|
|
90
|
+
return { text: candidate, truncated: true, rawLength, keep };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const fallback = bothNotice(0, 0);
|
|
94
|
+
return {
|
|
95
|
+
text: fallback.length <= maxChars ? fallback : fallback.slice(0, maxChars),
|
|
96
|
+
truncated: true,
|
|
97
|
+
rawLength,
|
|
98
|
+
keep,
|
|
99
|
+
};
|
|
53
100
|
}
|
|
54
|
-
const notice = (shown) => `[truncated: showing first ${shown} of ${rawLength} chars] ${hint}`;
|
|
55
101
|
// 在总长约束下取最大的 shown,使 head + '\n' + notice ≤ maxChars
|
|
56
102
|
for (let shown = Math.min(rawLength, maxChars); shown >= 0; shown--) {
|
|
57
|
-
const candidate = `${raw.slice(0, shown)}\n${
|
|
103
|
+
const candidate = `${raw.slice(0, shown)}\n${headNotice(shown)}`;
|
|
58
104
|
if (candidate.length <= maxChars) {
|
|
59
|
-
return { text: candidate, truncated: true, rawLength };
|
|
105
|
+
return { text: candidate, truncated: true, rawLength, keep };
|
|
60
106
|
}
|
|
61
107
|
}
|
|
62
108
|
// 极小 maxChars:至少保留可操作 hint(必要时截断 hint 本身)
|
|
63
|
-
const fallback =
|
|
109
|
+
const fallback = headNotice(0);
|
|
64
110
|
return {
|
|
65
111
|
text: fallback.length <= maxChars ? fallback : fallback.slice(0, maxChars),
|
|
66
112
|
truncated: true,
|
|
67
113
|
rawLength,
|
|
114
|
+
keep,
|
|
68
115
|
};
|
|
69
116
|
}
|
|
@@ -22,7 +22,6 @@ export function createSummaryPort(options) {
|
|
|
22
22
|
providers: options.providers,
|
|
23
23
|
levelMap: options.levelMap,
|
|
24
24
|
fallbackProvider: options.fallbackProvider,
|
|
25
|
-
legacySummaryModel: options.legacySummaryModel,
|
|
26
25
|
explicitModel: options.model,
|
|
27
26
|
modelLevel: options.modelLevel,
|
|
28
27
|
policyModel,
|
|
@@ -139,6 +139,8 @@ export function createDefaultToolBindings() {
|
|
|
139
139
|
// code 默认不 L2,保护「需要可编辑原文」的场景
|
|
140
140
|
informationalKinds: ['document', 'log', 'file_text', 'web_page'],
|
|
141
141
|
onFail: 'truncate_l1',
|
|
142
|
+
// 保头:后续用 offset 续读,头部才是入口
|
|
143
|
+
l1Keep: 'head',
|
|
142
144
|
},
|
|
143
145
|
// 列表/命令输出:L1 必须生效(CONTRIBUTING);L2 对 opaque 无益,关掉省调用
|
|
144
146
|
file_list: {
|
|
@@ -148,6 +150,8 @@ export function createDefaultToolBindings() {
|
|
|
148
150
|
kindFromSource: false,
|
|
149
151
|
informationalKinds: [],
|
|
150
152
|
onFail: 'truncate_l1',
|
|
153
|
+
// 保头:路径树前缀一致,头部信息密度最高
|
|
154
|
+
l1Keep: 'head',
|
|
151
155
|
},
|
|
152
156
|
// 搜索结果 = 定位符清单 + 预览体:L1 结构化收口在工具内(file+line 全保),
|
|
153
157
|
// L2 永不改写(摘要丢 file:line 保真度)
|
|
@@ -158,7 +162,10 @@ export function createDefaultToolBindings() {
|
|
|
158
162
|
kindFromSource: false,
|
|
159
163
|
informationalKinds: [],
|
|
160
164
|
onFail: 'truncate_l1',
|
|
165
|
+
// 保头:定位符清单从头部开始,尾部是可丢弃的低优先级命中
|
|
166
|
+
l1Keep: 'head',
|
|
161
167
|
},
|
|
168
|
+
// 命令输出:结论在末尾(测试汇总、构建结果、错误堆栈收尾)
|
|
162
169
|
shell: {
|
|
163
170
|
tool: 'shell',
|
|
164
171
|
mode: 'never',
|
|
@@ -166,6 +173,19 @@ export function createDefaultToolBindings() {
|
|
|
166
173
|
kindFromSource: false,
|
|
167
174
|
informationalKinds: [],
|
|
168
175
|
onFail: 'truncate_l1',
|
|
176
|
+
// 2026-11-13:head 会丢掉测试汇总/失败结论(project_run 43 次里仅 4 次见到
|
|
177
|
+
// 「Tests N passed」)。shell 类输出开头是命令回显与进度、末尾才是结论。
|
|
178
|
+
l1Keep: 'tail',
|
|
179
|
+
},
|
|
180
|
+
// 同 shell:脚本输出结论在末尾
|
|
181
|
+
project_run: {
|
|
182
|
+
tool: 'project_run',
|
|
183
|
+
mode: 'never',
|
|
184
|
+
maxReturnChars: 8000,
|
|
185
|
+
kindFromSource: false,
|
|
186
|
+
informationalKinds: [],
|
|
187
|
+
onFail: 'truncate_l1',
|
|
188
|
+
l1Keep: 'tail',
|
|
169
189
|
},
|
|
170
190
|
};
|
|
171
191
|
}
|
|
@@ -27,7 +27,7 @@ export declare function resolvePolicyForUnit(unit: ContentUnit, registry: Record
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function buildPolicyRegistry(overrides?: Record<string, SummaryPolicy>): Record<string, SummaryPolicy>;
|
|
29
29
|
/**
|
|
30
|
-
* 解析摘要用 ModelProvider(priority: policy.model → policy.modelLevel → explicit → level(缺省 mini) →
|
|
30
|
+
* 解析摘要用 ModelProvider(priority: policy.model → policy.modelLevel → explicit → level(缺省 mini) → mini → standard → fallback)
|
|
31
31
|
*
|
|
32
32
|
* @param input - providers / levelMap / 显式与兼容配置
|
|
33
33
|
* @returns 解析结果
|
|
@@ -76,7 +76,7 @@ function parseProviderModel(ref) {
|
|
|
76
76
|
return { provider: ref.slice(0, slash), model: ref.slice(slash + 1) };
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* 解析摘要用 ModelProvider(priority: policy.model → policy.modelLevel → explicit → level(缺省 mini) →
|
|
79
|
+
* 解析摘要用 ModelProvider(priority: policy.model → policy.modelLevel → explicit → level(缺省 mini) → mini → standard → fallback)
|
|
80
80
|
*
|
|
81
81
|
* @param input - providers / levelMap / 显式与兼容配置
|
|
82
82
|
* @returns 解析结果
|
|
@@ -126,11 +126,6 @@ export function resolveSummaryModel(input) {
|
|
|
126
126
|
const summaryLevel = pickLevel(levelName);
|
|
127
127
|
if (summaryLevel)
|
|
128
128
|
return { ...summaryLevel, from: 'level' };
|
|
129
|
-
if (input.legacySummaryModel) {
|
|
130
|
-
const r = tryModelRef(input.legacySummaryModel, 'legacy');
|
|
131
|
-
if (r)
|
|
132
|
-
return r;
|
|
133
|
-
}
|
|
134
129
|
const mini = pickLevel('mini');
|
|
135
130
|
if (mini)
|
|
136
131
|
return { ...mini, from: 'mini' };
|
|
@@ -72,7 +72,7 @@ export interface ApplyToolOutputGateOutput {
|
|
|
72
72
|
structuredError?: string;
|
|
73
73
|
};
|
|
74
74
|
/** Summary LLM 调用的 usage(用于 UsageLedger 归因;仅 L2) */
|
|
75
|
-
usage?: import('@octopi-agent/core/types/
|
|
75
|
+
usage?: import('@octopi-agent/core/types/step.js').TokenUsage;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* 工具结果出口门控:**L1 硬顶(永远)+ 可选 L2 摘要**
|
|
@@ -67,6 +67,10 @@ export async function applyToolOutputGate(input) {
|
|
|
67
67
|
summary,
|
|
68
68
|
usage,
|
|
69
69
|
});
|
|
70
|
+
// L1 唯一入口:保留策略由 binding 声明(缺省 head,与既有行为一致)。
|
|
71
|
+
// 全部 6 个分支共用,避免逐分支传入时漂移。
|
|
72
|
+
const l1Keep = binding.l1Keep ?? 'head';
|
|
73
|
+
const l1 = (raw) => applyL1Truncate(raw, maxChars, input.truncateHint, l1Keep);
|
|
70
74
|
// L2 决策(L1 在所有分支末尾都会做)
|
|
71
75
|
let runL2 = false;
|
|
72
76
|
if (mode === 'never' || arg === 'off') {
|
|
@@ -90,16 +94,16 @@ export async function applyToolOutputGate(input) {
|
|
|
90
94
|
try {
|
|
91
95
|
const r = await port.extract(unit, { previousSummary: undefined });
|
|
92
96
|
if (r.skipped) {
|
|
93
|
-
const
|
|
94
|
-
return finish(
|
|
97
|
+
const trunc = l1(input.rawBody);
|
|
98
|
+
return finish(trunc.text, trunc.truncated, {
|
|
95
99
|
applied: false,
|
|
96
100
|
skipped: true,
|
|
97
101
|
skipReason: r.skipReason,
|
|
98
102
|
kind,
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
|
-
const
|
|
102
|
-
return finish(
|
|
105
|
+
const trunc = l1(r.text);
|
|
106
|
+
return finish(trunc.text, trunc.truncated, {
|
|
103
107
|
applied: true,
|
|
104
108
|
policyId: r.policyId,
|
|
105
109
|
kind: r.kind,
|
|
@@ -112,8 +116,8 @@ export async function applyToolOutputGate(input) {
|
|
|
112
116
|
catch (err) {
|
|
113
117
|
if (binding.onFail === 'error')
|
|
114
118
|
throw err;
|
|
115
|
-
const
|
|
116
|
-
return finish(
|
|
119
|
+
const trunc = l1(input.rawBody);
|
|
120
|
+
return finish(trunc.text, trunc.truncated, {
|
|
117
121
|
applied: false,
|
|
118
122
|
failed: true,
|
|
119
123
|
kind,
|
|
@@ -121,8 +125,8 @@ export async function applyToolOutputGate(input) {
|
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
127
|
else {
|
|
124
|
-
const
|
|
125
|
-
return finish(
|
|
128
|
+
const trunc = l1(input.rawBody);
|
|
129
|
+
return finish(trunc.text, trunc.truncated, {
|
|
126
130
|
applied: false,
|
|
127
131
|
skipped: true,
|
|
128
132
|
skipReason: 'below_gate',
|
|
@@ -131,8 +135,8 @@ export async function applyToolOutputGate(input) {
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
else if (runL2 && !port) {
|
|
134
|
-
const
|
|
135
|
-
return finish(
|
|
138
|
+
const trunc = l1(input.rawBody);
|
|
139
|
+
return finish(trunc.text, trunc.truncated, {
|
|
136
140
|
applied: false,
|
|
137
141
|
skipped: true,
|
|
138
142
|
skipReason: 'no_summary_port',
|
|
@@ -140,8 +144,8 @@ export async function applyToolOutputGate(input) {
|
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
146
|
// L1 only(mode never / summarize off / 无 L2 路径)
|
|
143
|
-
const
|
|
144
|
-
return finish(
|
|
147
|
+
const trunc = l1(input.rawBody);
|
|
148
|
+
return finish(trunc.text, trunc.truncated, {
|
|
145
149
|
applied: false,
|
|
146
150
|
skipped: true,
|
|
147
151
|
skipReason: arg === 'off' ? 'summarize_off' : mode === 'never' ? 'mode_never' : 'l1_only',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* resolveSummaryToolBindings — `config.summary.tools` → tool 名绑定覆盖表。
|
|
3
|
+
*
|
|
4
|
+
* 自 src/cli/daemon.ts 迁入(B1 工具面单源化:装配工厂与 CLI 共用)。
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolSummaryBinding } from './index.js';
|
|
7
|
+
/**
|
|
8
|
+
* 解析 `config.summary.tools` 的 per-tool 绑定覆盖表(跳过 maxReturnChars 标量)。
|
|
9
|
+
*
|
|
10
|
+
* @param toolsCfg - `config.summary.tools`(形状经 config-schema 校验)
|
|
11
|
+
* @returns tool 名 → binding 覆盖表
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveSummaryToolBindings(toolsCfg: Record<string, unknown> | undefined): Record<string, Partial<ToolSummaryBinding>>;
|