@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
|
@@ -52,8 +52,8 @@ const TIMELINE_TYPES = new Set([
|
|
|
52
52
|
'engine.error',
|
|
53
53
|
// 模型重试:排查「为什么等了这么久」时,时间线必须能看出重试发生与次数
|
|
54
54
|
'engine.model_retry',
|
|
55
|
-
'
|
|
56
|
-
'
|
|
55
|
+
'step.start',
|
|
56
|
+
'step.end',
|
|
57
57
|
'tool.exec.start',
|
|
58
58
|
'tool.exec.end',
|
|
59
59
|
'budget.exceeded',
|
|
@@ -63,6 +63,11 @@ const TIMELINE_TYPES = new Set([
|
|
|
63
63
|
'context.compact.end',
|
|
64
64
|
'context.compact.error',
|
|
65
65
|
'context.compact.summarize_fallback',
|
|
66
|
+
// m-2:progress 必须落 timeline——manual/慢请求的「已发出多少、等了多久」是
|
|
67
|
+
// 卡死归因的唯一线索(丢弃 = 观测静默失明)
|
|
68
|
+
'context.compact.progress',
|
|
69
|
+
// P3 红线 7:overflow 症状告警(proactive 失效 / 配置漂移缺失)——罕见异常信号必须落 timeline
|
|
70
|
+
'context.overflow.alert',
|
|
66
71
|
'context.layers.assembled',
|
|
67
72
|
'persona.resolve.failed',
|
|
68
73
|
'injection.detected',
|
|
@@ -191,7 +196,7 @@ export class ObserverHub {
|
|
|
191
196
|
? endedAt - record.lifecycle.startedAt
|
|
192
197
|
: undefined,
|
|
193
198
|
// timeline 事件缺失时从 Guard / messages 摘要回填,避免面板全空
|
|
194
|
-
|
|
199
|
+
steps: record.lifecycle.steps ?? g?.steps,
|
|
195
200
|
toolCalls: record.lifecycle.toolCalls ?? g?.totalToolCalls,
|
|
196
201
|
};
|
|
197
202
|
if (input.messages && this.config.channels['run.messages']) {
|
|
@@ -207,8 +212,8 @@ export class ObserverHub {
|
|
|
207
212
|
if (built.cloned) {
|
|
208
213
|
record.messageClones = { ...record.messageClones, final: built.cloned };
|
|
209
214
|
}
|
|
210
|
-
if (record.lifecycle.
|
|
211
|
-
record.lifecycle.
|
|
215
|
+
if (record.lifecycle.steps == null && record.guardMetrics?.steps != null) {
|
|
216
|
+
record.lifecycle.steps = record.guardMetrics.steps;
|
|
212
217
|
}
|
|
213
218
|
if (record.lifecycle.toolCalls == null && record.guardMetrics?.totalToolCalls != null) {
|
|
214
219
|
record.lifecycle.toolCalls = record.guardMetrics.totalToolCalls;
|
|
@@ -253,6 +258,62 @@ export class ObserverHub {
|
|
|
253
258
|
this.warn('recordRunEnd', err);
|
|
254
259
|
}
|
|
255
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* 跨进程镜像面补建 run 记录:run.scope.ready 事件自带 scope View(recordRunStart
|
|
263
|
+
* 的产物投影),gateway 侧 hub 只收到事件流时以此为据建 record,使后续
|
|
264
|
+
* timeline/guard 事件有归属。单进程 recordRunStart 已建记录时不会走到这里
|
|
265
|
+
* (ingestEvent 先命中既有 record)。
|
|
266
|
+
*
|
|
267
|
+
* @param event - run.scope.ready 事件(data: { runId, sessionId, agentId, scope, messages })
|
|
268
|
+
* @returns 补建的记录;事件形状不符返回 undefined
|
|
269
|
+
*/
|
|
270
|
+
adoptRunScopeReady(event) {
|
|
271
|
+
try {
|
|
272
|
+
const d = event.data;
|
|
273
|
+
if (!d?.runId || !d.scope || !d.sessionId)
|
|
274
|
+
return undefined;
|
|
275
|
+
const capturedAt = d.scope.capturedAt ?? event.timestamp;
|
|
276
|
+
const record = {
|
|
277
|
+
runId: d.runId,
|
|
278
|
+
sessionId: d.sessionId,
|
|
279
|
+
agentId: d.agentId ?? '',
|
|
280
|
+
scope: d.scope,
|
|
281
|
+
lifecycle: { startedAt: capturedAt },
|
|
282
|
+
timeline: [],
|
|
283
|
+
securityEvents: [],
|
|
284
|
+
memoryActivity: emptyMemoryActivity(),
|
|
285
|
+
toolEffect: {
|
|
286
|
+
sessionId: d.sessionId,
|
|
287
|
+
agentId: d.agentId ?? '',
|
|
288
|
+
runId: d.runId,
|
|
289
|
+
cwd: d.scope.toolRuntime?.cwd,
|
|
290
|
+
isolation: d.scope.toolRuntime?.isolation,
|
|
291
|
+
tools: [],
|
|
292
|
+
},
|
|
293
|
+
updatedAt: capturedAt,
|
|
294
|
+
};
|
|
295
|
+
if (d.messages) {
|
|
296
|
+
record.messages = {
|
|
297
|
+
entry: {
|
|
298
|
+
sessionId: d.sessionId,
|
|
299
|
+
agentId: d.agentId,
|
|
300
|
+
runId: d.runId,
|
|
301
|
+
runCapturedAt: capturedAt,
|
|
302
|
+
view: 'workspace',
|
|
303
|
+
phase: 'entry',
|
|
304
|
+
summary: d.messages,
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
this.appendRun(record);
|
|
309
|
+
this.activeRunBySession.set(record.sessionId, record.runId);
|
|
310
|
+
return record;
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
this.warn('adoptRunScopeReady', err);
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
256
317
|
/**
|
|
257
318
|
* ContextEngine assemble 出口:LLM 实际输入
|
|
258
319
|
*/
|
|
@@ -366,16 +427,47 @@ export class ObserverHub {
|
|
|
366
427
|
!this.config.channels.memory &&
|
|
367
428
|
!this.config.channels['tool.effect'] &&
|
|
368
429
|
event.type !== 'run.guard.metrics' &&
|
|
369
|
-
event.type !== 'run.scope.llm'
|
|
430
|
+
event.type !== 'run.scope.llm' &&
|
|
431
|
+
event.type !== 'run.scope.ready') {
|
|
370
432
|
return;
|
|
371
433
|
}
|
|
372
434
|
if (!event.sessionId)
|
|
373
435
|
return;
|
|
374
436
|
try {
|
|
375
437
|
const runId = this.activeRunBySession.get(event.sessionId);
|
|
376
|
-
|
|
438
|
+
let record = runId ? this.runById.get(runId) : this.latestRun(event.sessionId);
|
|
439
|
+
// run.scope.ready 生命周期特判(跨进程镜像面):run 记录由 recordRunStart 建立,
|
|
440
|
+
// 但 gateway 侧 hub 只收到事件流——按事件自带 runId 补建记录(scope View 全量),
|
|
441
|
+
// 使后续 timeline/guard 事件有归属。**按 runId 归属**(不是 !record):同 session
|
|
442
|
+
// 第二轮 run 时 latestRun 兜底会命中上一轮旧记录,只判 !record 会让第二轮起全部
|
|
443
|
+
// 事件误挂旧记录(MAJ-1)。单进程 recordRunStart 已建记录 → runById 命中,幂等 no-op。
|
|
444
|
+
if (event.type === 'run.scope.ready') {
|
|
445
|
+
const d = event.data;
|
|
446
|
+
const byRunId = d?.runId ? this.runById.get(d.runId) : undefined;
|
|
447
|
+
record = byRunId ?? this.adoptRunScopeReady(event) ?? record;
|
|
448
|
+
}
|
|
377
449
|
if (!record)
|
|
378
450
|
return;
|
|
451
|
+
// run.scope.messages(跨进程镜像面):entry/final messages 摘要落 record.messages——
|
|
452
|
+
// 单进程由 recordRunEnd/recordLlmMessages 写,镜像面靠此事件(emitObserved 已过线)。
|
|
453
|
+
if (event.type === 'run.scope.messages') {
|
|
454
|
+
const d = event.data;
|
|
455
|
+
if (d?.messages && d.phase) {
|
|
456
|
+
record.messages = {
|
|
457
|
+
...record.messages,
|
|
458
|
+
[d.phase]: {
|
|
459
|
+
sessionId: d.sessionId ?? record.sessionId,
|
|
460
|
+
agentId: d.agentId ?? record.agentId,
|
|
461
|
+
runId: d.runId ?? record.runId,
|
|
462
|
+
runCapturedAt: event.timestamp,
|
|
463
|
+
view: 'workspace',
|
|
464
|
+
phase: d.phase,
|
|
465
|
+
summary: d.messages,
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
379
471
|
if (event.type === 'run.guard.metrics' && this.config.channels['run.guard']) {
|
|
380
472
|
const d = event.data;
|
|
381
473
|
record.guardMetrics = {
|
|
@@ -473,8 +565,8 @@ export class ObserverHub {
|
|
|
473
565
|
}
|
|
474
566
|
}
|
|
475
567
|
const life = record.lifecycle;
|
|
476
|
-
if (event.type === '
|
|
477
|
-
life.
|
|
568
|
+
if (event.type === 'step.end') {
|
|
569
|
+
life.steps = (life.steps ?? 0) + 1;
|
|
478
570
|
}
|
|
479
571
|
else if (event.type === 'tool.exec.end') {
|
|
480
572
|
life.toolCalls = (life.toolCalls ?? 0) + 1;
|
|
@@ -497,6 +589,12 @@ export class ObserverHub {
|
|
|
497
589
|
life.durationMs = event.timestamp - life.startedAt;
|
|
498
590
|
}
|
|
499
591
|
}
|
|
592
|
+
// run 终态清 active 归属(跨进程镜像面无 recordRunEnd 调用;单进程 recordRunEnd
|
|
593
|
+
// 随后再清,幂等)。不清会让下一轮 run.scope.ready 前的事件归到旧 run。
|
|
594
|
+
if ((event.type === 'engine.end' || event.type === 'engine.error') &&
|
|
595
|
+
this.activeRunBySession.get(record.sessionId) === record.runId) {
|
|
596
|
+
this.activeRunBySession.delete(record.sessionId);
|
|
597
|
+
}
|
|
500
598
|
this.mergeGuardFlags(record, event);
|
|
501
599
|
record.updatedAt = Date.now();
|
|
502
600
|
}
|
|
@@ -616,7 +714,7 @@ export class ObserverHub {
|
|
|
616
714
|
}
|
|
617
715
|
else if (d?.usageLedger) {
|
|
618
716
|
record.guardMetrics = {
|
|
619
|
-
|
|
717
|
+
steps: 0,
|
|
620
718
|
totalToolCalls: 0,
|
|
621
719
|
nominalTotalTokens: 0,
|
|
622
720
|
elapsedMs: 0,
|
|
@@ -636,7 +734,7 @@ export class ObserverHub {
|
|
|
636
734
|
if (event.type === 'budget.wrap_up') {
|
|
637
735
|
const d = event.data;
|
|
638
736
|
record.guardMetrics = {
|
|
639
|
-
|
|
737
|
+
steps: record.guardMetrics?.steps ?? 0,
|
|
640
738
|
totalToolCalls: record.guardMetrics?.totalToolCalls ?? 0,
|
|
641
739
|
nominalTotalTokens: record.guardMetrics?.nominalTotalTokens ?? 0,
|
|
642
740
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
@@ -651,13 +749,13 @@ export class ObserverHub {
|
|
|
651
749
|
...record.guardMetrics,
|
|
652
750
|
wrapUpActive: true,
|
|
653
751
|
wrapUpReason: d.reason,
|
|
654
|
-
|
|
752
|
+
wrapUpStepsRemaining: d.stepsRemaining,
|
|
655
753
|
};
|
|
656
754
|
}
|
|
657
755
|
if (event.type === 'budget.exceeded') {
|
|
658
756
|
const reason = event.data?.reason;
|
|
659
757
|
record.guardMetrics = {
|
|
660
|
-
|
|
758
|
+
steps: 0,
|
|
661
759
|
totalToolCalls: record.lifecycle.toolCalls ?? 0,
|
|
662
760
|
nominalTotalTokens: 0,
|
|
663
761
|
elapsedMs: record.lifecycle.durationMs ?? 0,
|
|
@@ -676,7 +774,7 @@ export class ObserverHub {
|
|
|
676
774
|
else if (event.type === 'run_guard.stopped') {
|
|
677
775
|
const reason = event.data?.reason;
|
|
678
776
|
record.guardMetrics = {
|
|
679
|
-
|
|
777
|
+
steps: record.guardMetrics?.steps ?? 0,
|
|
680
778
|
totalToolCalls: record.guardMetrics?.totalToolCalls ?? 0,
|
|
681
779
|
nominalTotalTokens: record.guardMetrics?.nominalTotalTokens ?? 0,
|
|
682
780
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
@@ -695,7 +793,7 @@ export class ObserverHub {
|
|
|
695
793
|
else if (event.type === 'run_guard.recovered') {
|
|
696
794
|
const d = event.data;
|
|
697
795
|
record.guardMetrics = {
|
|
698
|
-
|
|
796
|
+
steps: record.guardMetrics?.steps ?? 0,
|
|
699
797
|
totalToolCalls: record.guardMetrics?.totalToolCalls ?? 0,
|
|
700
798
|
nominalTotalTokens: record.guardMetrics?.nominalTotalTokens ?? 0,
|
|
701
799
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
@@ -797,7 +895,7 @@ export class ObserverHub {
|
|
|
797
895
|
const g = record.guardMetrics;
|
|
798
896
|
const lifecycle = {
|
|
799
897
|
...record.lifecycle,
|
|
800
|
-
|
|
898
|
+
steps: record.lifecycle.steps ?? g?.steps,
|
|
801
899
|
toolCalls: record.lifecycle.toolCalls ?? g?.totalToolCalls,
|
|
802
900
|
durationMs: record.lifecycle.durationMs ?? g?.elapsedMs,
|
|
803
901
|
};
|
|
@@ -936,7 +1034,10 @@ function stripLayerPayload(snapshot, payload) {
|
|
|
936
1034
|
}
|
|
937
1035
|
function toTimelineNode(event) {
|
|
938
1036
|
const data = (event.data ?? {});
|
|
939
|
-
//
|
|
1037
|
+
// P3 告警可见性:symptom/message 原样带出(红线 7 展示层不得只剩裸 type)
|
|
1038
|
+
const symptom = typeof data.symptom === 'string' ? data.symptom : undefined;
|
|
1039
|
+
const message = typeof data.message === 'string' ? data.message : undefined;
|
|
1040
|
+
// F3 计时段:step.end 带 llmTiming(LLM 调用计时);run.timing 带 wait/build/run_end 分段
|
|
940
1041
|
const timing = data.llmTiming ??
|
|
941
1042
|
(event.type === 'run.timing'
|
|
942
1043
|
? {
|
|
@@ -962,5 +1063,7 @@ function toTimelineNode(event) {
|
|
|
962
1063
|
reason: (data.reason ?? data.fallbackError),
|
|
963
1064
|
usage: data.usage,
|
|
964
1065
|
timing,
|
|
1066
|
+
symptom,
|
|
1067
|
+
message,
|
|
965
1068
|
};
|
|
966
1069
|
}
|
|
@@ -169,7 +169,7 @@ export interface RunMessagesSummary {
|
|
|
169
169
|
export interface RunGuardMetricsView {
|
|
170
170
|
sessionId?: string;
|
|
171
171
|
agentId?: string;
|
|
172
|
-
|
|
172
|
+
steps: number;
|
|
173
173
|
totalToolCalls: number;
|
|
174
174
|
/** 诊断 nominal Σ(非 spend hard) */
|
|
175
175
|
nominalTotalTokens: number;
|
|
@@ -197,7 +197,7 @@ export interface RunGuardMetricsView {
|
|
|
197
197
|
/** P2 wrap-up 状态 */
|
|
198
198
|
wrapUpActive?: boolean;
|
|
199
199
|
wrapUpReason?: 'context' | 'policy';
|
|
200
|
-
|
|
200
|
+
wrapUpStepsRemaining?: number;
|
|
201
201
|
guardStoppedReason?: string;
|
|
202
202
|
guardRecovered?: {
|
|
203
203
|
reason: string;
|
|
@@ -265,14 +265,18 @@ export interface RunTimelineEventView {
|
|
|
265
265
|
hasError?: boolean;
|
|
266
266
|
durationMs?: number;
|
|
267
267
|
reason?: string;
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
/** P3 告警可见性:overflow 症状(红线 7 的 proactive 失效语义在展示层可见) */
|
|
269
|
+
symptom?: string;
|
|
270
|
+
/** 人类可读文本(告警/审计消息) */
|
|
271
|
+
message?: string;
|
|
272
|
+
usage?: import('@octopi-agent/core/types/step.js').TokenUsage;
|
|
273
|
+
/** F3 计时段(step.end 的 LLM 计时 / run.timing 的 wait/build/run_end 分段) */
|
|
270
274
|
timing?: {
|
|
271
275
|
stage?: string;
|
|
272
276
|
waitMs?: number;
|
|
273
277
|
buildMs?: number;
|
|
274
278
|
durMs?: number;
|
|
275
|
-
/** LLM 调用总耗时(
|
|
279
|
+
/** LLM 调用总耗时(step.end.llmTiming) */
|
|
276
280
|
durationMs?: number;
|
|
277
281
|
/** LLM 调用标识(可关联 model.call.end 行) */
|
|
278
282
|
callId?: string;
|
|
@@ -295,7 +299,7 @@ export interface RunLifecycleView {
|
|
|
295
299
|
endedAt?: number;
|
|
296
300
|
endReason?: string;
|
|
297
301
|
durationMs?: number;
|
|
298
|
-
|
|
302
|
+
steps?: number;
|
|
299
303
|
toolCalls?: number;
|
|
300
304
|
error?: string;
|
|
301
305
|
}
|
|
@@ -10,11 +10,23 @@
|
|
|
10
10
|
* 因此可以合法依赖 reliability,而不让 Loop 反向依赖策略。
|
|
11
11
|
*/
|
|
12
12
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
13
|
+
import type { ContextCompactSnapshot } from '../../context/types.js';
|
|
13
14
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
14
15
|
import type { AgentContext, AgentLoopConfig, AgentLoopEvent, AgentTool } from '@octopi-agent/core/loop/types.js';
|
|
15
16
|
import type { ReliabilityHarness } from '../reliability/run-agent.js';
|
|
17
|
+
import type { ExtensionHookPort } from '../../extension/plugin-ecosystem/hooks/types.js';
|
|
16
18
|
import type { ResolvedModel } from '../model/types.js';
|
|
17
19
|
import type { HarnessLoopEvent } from '../reliability/harness-events.js';
|
|
20
|
+
/**
|
|
21
|
+
* Run 身份(afterStep 等跨层回调的显式归属,I1)。
|
|
22
|
+
*
|
|
23
|
+
* 回调触发点可能在 run 的 ALS 窗口之外(runner 事件循环),且共享 Agent 实例上
|
|
24
|
+
* 的 `contextSessionId` 是多会话竞态字段——身份必须由调用方显式携带,禁止环境推断。
|
|
25
|
+
*/
|
|
26
|
+
export interface RunIdentity {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
}
|
|
18
30
|
export interface AgentOptions {
|
|
19
31
|
/** 模型提供者(唯一必需的运行时依赖) */
|
|
20
32
|
model: ModelProvider;
|
|
@@ -32,9 +44,12 @@ export interface AgentOptions {
|
|
|
32
44
|
beforeToolCall?: AgentLoopConfig['beforeToolCall'];
|
|
33
45
|
afterToolCall?: AgentLoopConfig['afterToolCall'];
|
|
34
46
|
toolExecution?: 'parallel' | 'sequential';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
shouldStopAfterStep?: AgentLoopConfig['shouldStopAfterStep'];
|
|
48
|
+
onStepComplete?: AgentLoopConfig['onStepComplete'];
|
|
49
|
+
beforeStep?: AgentLoopConfig['beforeStep'];
|
|
50
|
+
prepareNextStep?: AgentLoopConfig['prepareNextStep'];
|
|
51
|
+
/** Host injection: a narrow extension boundary, not a plugin registry. */
|
|
52
|
+
extensionHooks?: ExtensionHookPort;
|
|
38
53
|
onToolUpdate?: AgentLoopConfig['onToolUpdate'];
|
|
39
54
|
onError?: AgentLoopConfig['onError'];
|
|
40
55
|
getSteeringMessages?: AgentLoopConfig['getSteeringMessages'];
|
|
@@ -47,6 +62,7 @@ export declare class Agent {
|
|
|
47
62
|
private _context;
|
|
48
63
|
private _config;
|
|
49
64
|
private _harness;
|
|
65
|
+
private readonly _extensionHooks?;
|
|
50
66
|
/**
|
|
51
67
|
* ContextEngine 按 session 维护 CompactState。
|
|
52
68
|
* SessionAwareRunner 在 handle() 开始时注入真实 sessionId,避免多会话串味。
|
|
@@ -54,7 +70,7 @@ export declare class Agent {
|
|
|
54
70
|
private _contextSessionId;
|
|
55
71
|
/** sessionId → 压缩状态快照;Runner 从 Session 播种,assemble 后回写 Session */
|
|
56
72
|
private _sessionCompactStates;
|
|
57
|
-
private
|
|
73
|
+
private _onAfterStep?;
|
|
58
74
|
/** Client Tool 会话可见性;undefined = 全部可见 */
|
|
59
75
|
private _toolVisibilityFilter?;
|
|
60
76
|
constructor(options: AgentOptions);
|
|
@@ -99,12 +115,7 @@ export declare class Agent {
|
|
|
99
115
|
* @param agentId - 产出/消费该 compact 视图的 agent
|
|
100
116
|
* @param state - 快照;undefined 清除
|
|
101
117
|
*/
|
|
102
|
-
setSessionCompactState(sessionId: string, agentId: string, state:
|
|
103
|
-
summary?: string;
|
|
104
|
-
lastProactiveMessageCount?: number;
|
|
105
|
-
lastProactiveCoverEnd?: number;
|
|
106
|
-
lastProactiveTokens?: number;
|
|
107
|
-
} | undefined): void;
|
|
118
|
+
setSessionCompactState(sessionId: string, agentId: string, state: ContextCompactSnapshot | undefined): void;
|
|
108
119
|
/**
|
|
109
120
|
* 读取会话压缩状态快照(E4 键)
|
|
110
121
|
*
|
|
@@ -112,20 +123,28 @@ export declare class Agent {
|
|
|
112
123
|
* @param agentId - 目标 agent
|
|
113
124
|
* @returns 快照;无则 undefined
|
|
114
125
|
*/
|
|
115
|
-
getSessionCompactState(sessionId: string, agentId: string):
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
getSessionCompactState(sessionId: string, agentId: string): ContextCompactSnapshot | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* 每轮结束后通知 ContextEngine(afterStep 校准等)。
|
|
129
|
+
*
|
|
130
|
+
* @param fn - 回调 `(identity, usage, step)`:identity = 本 run 权威身份(首位);
|
|
131
|
+
* usage = 本步新鲜 usage(可缺,缺则不喂校准);step = 本轮增量消息。
|
|
132
|
+
* ⚠️ 2026-11-09 签名变更(Breaking):identity 插入首位,旧 `(usage, step)` 回调
|
|
133
|
+
* 会静默错位读参,外部注册方须同步迁移(见 CHANGELOG v0.102.10)。
|
|
134
|
+
*/
|
|
135
|
+
setOnAfterStep(fn?: (identity: RunIdentity, usage?: import('@octopi-agent/core/types/step.js').TokenUsage, step?: Message[]) => Promise<void>): void;
|
|
136
|
+
/**
|
|
137
|
+
* 由 Runner 在 step 结束后调用。
|
|
138
|
+
*
|
|
139
|
+
* @param identity - 本 run 的权威身份(显式传递;调用点在 ALS 窗口外,禁止环境推断)
|
|
140
|
+
* @param usage - 本步新鲜 usage(缺 usage 的失败/重试/中止步传 undefined)
|
|
141
|
+
* @param step - 本轮增量消息
|
|
142
|
+
*/
|
|
143
|
+
notifyAfterStep(identity: RunIdentity, usage?: import('@octopi-agent/core/types/step.js').TokenUsage, step?: Message[]): Promise<void>;
|
|
125
144
|
/** 动态替换 convertToLlm(ContextEngine 接线等) */
|
|
126
145
|
setConvertToLlm(fn?: AgentLoopConfig['convertToLlm']): void;
|
|
127
146
|
/**
|
|
128
|
-
* 动态替换 getSteeringMessages(当前
|
|
147
|
+
* 动态替换 getSteeringMessages(当前 step 结束后注入的提示)
|
|
129
148
|
*
|
|
130
149
|
* 晚绑定入口:一个 Agent 实例服务多 session,回调必须经
|
|
131
150
|
* `getRunScope()` / `getRunSessionId()` 取**本 Run** 的身份,
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
import { runAgentWithReliability } from '../reliability/run-agent.js';
|
|
13
13
|
import { withResolvedModel } from '../model/run-scope.js';
|
|
14
14
|
import { withRunScope } from '../run-scope.js';
|
|
15
|
+
import { integrateAgentHooks, voteAgentToolCall, withAgentRunHooks } from '../../extension/plugin-ecosystem/hooks/run-integration.js';
|
|
15
16
|
import { compactStateKey } from '../../context/compact-key.js';
|
|
16
17
|
// ── Agent 类 ──
|
|
17
18
|
export class Agent {
|
|
18
19
|
_context;
|
|
19
20
|
_config;
|
|
20
21
|
_harness;
|
|
22
|
+
_extensionHooks;
|
|
21
23
|
/**
|
|
22
24
|
* ContextEngine 按 session 维护 CompactState。
|
|
23
25
|
* SessionAwareRunner 在 handle() 开始时注入真实 sessionId,避免多会话串味。
|
|
@@ -25,7 +27,7 @@ export class Agent {
|
|
|
25
27
|
_contextSessionId = 'default';
|
|
26
28
|
/** sessionId → 压缩状态快照;Runner 从 Session 播种,assemble 后回写 Session */
|
|
27
29
|
_sessionCompactStates = new Map();
|
|
28
|
-
|
|
30
|
+
_onAfterStep;
|
|
29
31
|
/** Client Tool 会话可见性;undefined = 全部可见 */
|
|
30
32
|
_toolVisibilityFilter;
|
|
31
33
|
constructor(options) {
|
|
@@ -35,6 +37,7 @@ export class Agent {
|
|
|
35
37
|
tools: options.tools ?? [],
|
|
36
38
|
};
|
|
37
39
|
this._harness = options.harness;
|
|
40
|
+
this._extensionHooks = options.extensionHooks;
|
|
38
41
|
this._config = {
|
|
39
42
|
model: options.model,
|
|
40
43
|
convertToLlm: options.convertToLlm,
|
|
@@ -42,9 +45,10 @@ export class Agent {
|
|
|
42
45
|
beforeToolCall: options.beforeToolCall,
|
|
43
46
|
afterToolCall: options.afterToolCall,
|
|
44
47
|
onToolUpdate: options.onToolUpdate,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
shouldStopAfterStep: options.shouldStopAfterStep,
|
|
49
|
+
onStepComplete: options.onStepComplete,
|
|
50
|
+
beforeStep: options.beforeStep,
|
|
51
|
+
prepareNextStep: options.prepareNextStep,
|
|
48
52
|
onError: options.onError,
|
|
49
53
|
observer: options.observer,
|
|
50
54
|
getSteeringMessages: options.getSteeringMessages,
|
|
@@ -149,14 +153,27 @@ export class Agent {
|
|
|
149
153
|
getSessionCompactState(sessionId, agentId) {
|
|
150
154
|
return this._sessionCompactStates.get(compactStateKey(sessionId, agentId));
|
|
151
155
|
}
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
/**
|
|
157
|
+
* 每轮结束后通知 ContextEngine(afterStep 校准等)。
|
|
158
|
+
*
|
|
159
|
+
* @param fn - 回调 `(identity, usage, step)`:identity = 本 run 权威身份(首位);
|
|
160
|
+
* usage = 本步新鲜 usage(可缺,缺则不喂校准);step = 本轮增量消息。
|
|
161
|
+
* ⚠️ 2026-11-09 签名变更(Breaking):identity 插入首位,旧 `(usage, step)` 回调
|
|
162
|
+
* 会静默错位读参,外部注册方须同步迁移(见 CHANGELOG v0.102.10)。
|
|
163
|
+
*/
|
|
164
|
+
setOnAfterStep(fn) {
|
|
165
|
+
this._onAfterStep = fn;
|
|
155
166
|
}
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
/**
|
|
168
|
+
* 由 Runner 在 step 结束后调用。
|
|
169
|
+
*
|
|
170
|
+
* @param identity - 本 run 的权威身份(显式传递;调用点在 ALS 窗口外,禁止环境推断)
|
|
171
|
+
* @param usage - 本步新鲜 usage(缺 usage 的失败/重试/中止步传 undefined)
|
|
172
|
+
* @param step - 本轮增量消息
|
|
173
|
+
*/
|
|
174
|
+
async notifyAfterStep(identity, usage, step) {
|
|
175
|
+
if (this._onAfterStep) {
|
|
176
|
+
await this._onAfterStep(identity, usage, step);
|
|
160
177
|
}
|
|
161
178
|
}
|
|
162
179
|
/** 动态替换 convertToLlm(ContextEngine 接线等) */
|
|
@@ -164,7 +181,7 @@ export class Agent {
|
|
|
164
181
|
this._config = { ...this._config, convertToLlm: fn };
|
|
165
182
|
}
|
|
166
183
|
/**
|
|
167
|
-
* 动态替换 getSteeringMessages(当前
|
|
184
|
+
* 动态替换 getSteeringMessages(当前 step 结束后注入的提示)
|
|
168
185
|
*
|
|
169
186
|
* 晚绑定入口:一个 Agent 实例服务多 session,回调必须经
|
|
170
187
|
* `getRunScope()` / `getRunSessionId()` 取**本 Run** 的身份,
|
|
@@ -230,13 +247,50 @@ export class Agent {
|
|
|
230
247
|
sessionId: options?.runScope?.sessionId ?? this._contextSessionId,
|
|
231
248
|
agentId: options?.runScope?.agentId ?? harness.agentId ?? 'default',
|
|
232
249
|
runId: options?.runScope?.runId,
|
|
250
|
+
principal: options?.runScope?.principal,
|
|
251
|
+
prompt: options?.runScope?.prompt,
|
|
252
|
+
resolvedModel: resolved,
|
|
253
|
+
resolveConfiguredModel: options?.runScope?.resolveConfiguredModel,
|
|
254
|
+
thinkingLevel: options?.runScope?.thinkingLevel,
|
|
255
|
+
extensionSnapshotBudgetTokens: options?.runScope?.extensionSnapshotBudgetTokens,
|
|
256
|
+
iteration: options?.runScope?.iteration,
|
|
233
257
|
systemPrompt: options?.runScope?.systemPrompt ?? context.systemPrompt,
|
|
258
|
+
// 与请求工具面同源:ContextEngine 的请求视图(RequestView.tools)由同一批
|
|
259
|
+
// AgentTool 解析;loop 以视图为准,仅在旧签名(数组)时回落
|
|
260
|
+
// buildToolDefinitions(currentContext.tools)。
|
|
261
|
+
// M-6:活读(getter)而非快照——beforeStep 可 Object.assign 替换 tools 数组,
|
|
262
|
+
// 快照会让估算按 run 起点工具面、请求按 run 中途工具面(错位估算 = 毒样本)。
|
|
263
|
+
// Nit 3(评审 del-e1ee43ef):不回退 options.runScope.tools——那是「宿主宣告清单」,
|
|
264
|
+
// 请求实发的是 context.tools,分叉即毒样本;runScope.tools 仅是外部 withRunScope
|
|
265
|
+
// 桥接场景的携带字段(builder 读 scope?.tools ?? []),不参与 agent.run 估算口径。
|
|
266
|
+
get tools() {
|
|
267
|
+
return context.tools;
|
|
268
|
+
},
|
|
234
269
|
grounding: options?.runScope?.grounding,
|
|
235
270
|
toolRuntime: options?.runScope?.toolRuntime,
|
|
236
271
|
agentRevision: options?.runScope?.agentRevision,
|
|
272
|
+
taskSnapshot: options?.runScope?.taskSnapshot,
|
|
237
273
|
};
|
|
238
|
-
|
|
274
|
+
const hookState = integrateAgentHooks(this._extensionHooks, config, () => runScope);
|
|
275
|
+
if (hookState) {
|
|
276
|
+
const existingBeforeToolCall = config.beforeToolCall;
|
|
277
|
+
config.prepareToolArguments = hookState.callbacks().prepareToolArguments;
|
|
278
|
+
config.onToolCallComplete = hookState.callbacks().onToolCallComplete;
|
|
279
|
+
config.beforeToolCall = async (ctx, toolSignal) => {
|
|
280
|
+
const existing = await existingBeforeToolCall?.(ctx, toolSignal);
|
|
281
|
+
if (existing?.block)
|
|
282
|
+
return existing;
|
|
283
|
+
return voteAgentToolCall(this._extensionHooks, ctx, hookState.originalToolParams, toolSignal);
|
|
284
|
+
};
|
|
285
|
+
config.beforeStep = hookState.callbacks().beforeStep;
|
|
286
|
+
config.onStepComplete = hookState.callbacks().onStepComplete;
|
|
287
|
+
config.transformLlmMessages = hookState.transformLlmMessages.bind(hookState);
|
|
288
|
+
}
|
|
289
|
+
let gen = runAgentWithReliability(context, config, harness, signal, {
|
|
290
|
+
toolRuntime: runScope.toolRuntime,
|
|
291
|
+
});
|
|
239
292
|
gen = withRunScope(runScope, gen);
|
|
293
|
+
gen = withAgentRunHooks(this._extensionHooks, runScope, context, signal, gen);
|
|
240
294
|
if (resolved) {
|
|
241
295
|
return withResolvedModel(resolved, gen);
|
|
242
296
|
}
|
|
@@ -7,46 +7,53 @@
|
|
|
7
7
|
* - 出厂 **不** 因 Σ nominalTotalTokens(nominal spend)停止 Run
|
|
8
8
|
* - soft / 续租 / maxTokens 硬顶已删除
|
|
9
9
|
* - 默认仅 wall-clock 安全阀(6h,可配)
|
|
10
|
-
* -
|
|
10
|
+
* - maxSteps / maxToolCalls 仅显式配置时硬停
|
|
11
11
|
* - 成本/配额策略见后续 budgetPolicy(P3);账本见 UsageLedger(P1)
|
|
12
|
+
*
|
|
13
|
+
* wall-clock 口径(2026-11-01):安全阀管的是「引擎活跃运行时长」,不是 run 的
|
|
14
|
+
* 存续时长。ask_user 等阻塞式人机工具经 addHumanWaitMs 回传的等待时长从
|
|
15
|
+
* elapsedMs 中扣除——等人不算运行,与「ask_user 无超时」(2026-10-26 拍板)一致。
|
|
12
16
|
*/
|
|
13
17
|
/** Run 安全阀配置(实现侧;JSON 见 config.BudgetPolicyJsonConfig) */
|
|
14
18
|
export interface BudgetPolicyConfig {
|
|
15
19
|
/**
|
|
16
20
|
* 最大迭代次数。仅当显式设置时作为硬停。
|
|
17
|
-
* 默认省略:长任务不靠
|
|
21
|
+
* 默认省略:长任务不靠 steps 卡死;行为跑飞由 RunGuard 负责。
|
|
18
22
|
*/
|
|
19
|
-
|
|
23
|
+
maxSteps?: number;
|
|
20
24
|
/** 最大工具调用次数。仅当显式设置时作为硬停。 */
|
|
21
25
|
maxToolCalls?: number;
|
|
22
26
|
/** 硬顶:最大 wall-clock(毫秒)。出厂默认见 DEFAULT_BUDGET。 */
|
|
23
27
|
maxWallClockMs: number;
|
|
24
28
|
}
|
|
25
29
|
/** 预算状态(无 soft;tokens 轴已移除) */
|
|
26
|
-
export type BudgetStatus = 'ok' | '
|
|
30
|
+
export type BudgetStatus = 'ok' | 'step_limit' | 'tool_call_limit' | 'timeout';
|
|
27
31
|
/** 评估结果 */
|
|
28
32
|
export interface BudgetEvaluation {
|
|
29
33
|
status: 'ok' | 'hard';
|
|
30
|
-
reason?: 'wall_clock' | '
|
|
34
|
+
reason?: 'wall_clock' | 'steps' | 'tool_calls';
|
|
31
35
|
legacyStatus: BudgetStatus;
|
|
32
36
|
report: BudgetReport;
|
|
33
37
|
}
|
|
34
38
|
/** 预算消耗报告(观测用;nominal tokens 不参与 hard) */
|
|
35
39
|
export interface BudgetReport {
|
|
36
40
|
status: BudgetStatus;
|
|
37
|
-
|
|
41
|
+
steps: number;
|
|
38
42
|
toolCalls: number;
|
|
39
43
|
/** 诊断累计(Σ nominalTotalTokens);**禁止**作为默认 hard 单位 */
|
|
40
44
|
nominalTokens: number;
|
|
45
|
+
/** 活跃运行时长(已扣除人类输入等待);wall-clock 裁决口径 */
|
|
41
46
|
elapsedMs: number;
|
|
47
|
+
/** 已扣除的人类输入等待时长(ask_user 等阻塞式人机工具回传) */
|
|
48
|
+
humanWaitMs: number;
|
|
42
49
|
remaining: {
|
|
43
|
-
|
|
50
|
+
steps: number | null;
|
|
44
51
|
toolCalls: number | null;
|
|
45
52
|
wallClockMs: number;
|
|
46
53
|
};
|
|
47
54
|
hard: {
|
|
48
55
|
wallClockMs: number;
|
|
49
|
-
|
|
56
|
+
steps: number | null;
|
|
50
57
|
toolCalls: number | null;
|
|
51
58
|
};
|
|
52
59
|
}
|
|
@@ -59,9 +66,10 @@ export declare const DEFAULT_BUDGET: BudgetPolicyConfig;
|
|
|
59
66
|
*/
|
|
60
67
|
export declare class BudgetPolicyEngine {
|
|
61
68
|
private config;
|
|
62
|
-
private
|
|
69
|
+
private steps;
|
|
63
70
|
private toolCalls;
|
|
64
71
|
private nominalTokens;
|
|
72
|
+
private humanWaitMs;
|
|
65
73
|
private startTime;
|
|
66
74
|
constructor(config?: Partial<BudgetPolicyConfig>);
|
|
67
75
|
/** 重置计数(Gateway 长驻每请求调用);保留配置 */
|
|
@@ -84,10 +92,20 @@ export declare class BudgetPolicyEngine {
|
|
|
84
92
|
* 兼容 API:返回字符串状态。
|
|
85
93
|
*/
|
|
86
94
|
check(_hasProgress?: boolean): BudgetStatus;
|
|
87
|
-
|
|
95
|
+
recordStep(): void;
|
|
88
96
|
recordToolCall(n?: number): void;
|
|
89
97
|
/** 仅记账/诊断;**不**触发 hard */
|
|
90
98
|
consumeTokens(tokens: number): void;
|
|
99
|
+
/**
|
|
100
|
+
* 记录人类输入等待时长(ask_user 等阻塞式人机工具回传)。
|
|
101
|
+
* 从 wall-clock 计量中扣除:等人不算引擎运行时长。
|
|
102
|
+
* 累计以存续时长封顶(等待是存续的子集;并行等待/超报不得把安全阀静默归零)。
|
|
103
|
+
*
|
|
104
|
+
* @param ms - 本次等待时长(毫秒)
|
|
105
|
+
*/
|
|
106
|
+
addHumanWaitMs(ms: number): void;
|
|
107
|
+
/** 活跃运行时长 = 存续时长 - 人类输入等待(不小于 0) */
|
|
108
|
+
private activeElapsedMs;
|
|
91
109
|
report(): BudgetReport;
|
|
92
110
|
getConfig(): BudgetPolicyConfig;
|
|
93
111
|
private buildReport;
|