@octopi-agent/engine 0.97.15 → 0.102.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-schema/agent.d.ts +37 -5
- package/dist/config-schema/agent.js +24 -4
- package/dist/config-schema/context.d.ts +6 -36
- package/dist/config-schema/context.js +4 -28
- package/dist/config-schema/engine.d.ts +61 -160
- package/dist/config-schema/engine.js +1 -5
- package/dist/config-schema/governance.d.ts +10 -1
- package/dist/config-schema/governance.js +38 -1
- package/dist/config-schema/models.d.ts +2 -8
- package/dist/config-schema/models.js +0 -2
- package/dist/config-schema/run.d.ts +2 -2
- package/dist/config-schema/run.js +2 -2
- package/dist/config-schema/shared.d.ts +0 -3
- package/dist/config-schema/shared.js +0 -2
- package/dist/config-schema/substrate.d.ts +14 -88
- package/dist/config-schema/substrate.js +22 -107
- package/dist/config.d.ts +45 -113
- package/dist/config.js +8 -2
- package/dist/harness/activation/dispatcher.js +7 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/runtime.js +13 -5
- package/dist/harness/activation/types.d.ts +2 -2
- package/dist/harness/agent/builder.d.ts +34 -2
- package/dist/harness/agent/builder.js +189 -58
- package/dist/harness/agent/config-bridge.js +9 -2
- package/dist/harness/agent/config-integrity.d.ts +66 -0
- package/dist/harness/agent/config-integrity.js +108 -2
- package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
- package/dist/harness/agent/wire-agent-builder.js +31 -7
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- package/dist/harness/collaboration/autonomous-subsystem/index.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +21 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.d.ts +40 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.js +59 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +2 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +12 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
- package/dist/harness/collaboration/delegation/child-run.js +4 -4
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/service.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.js +2 -1
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +2 -1
- package/dist/harness/collaboration/delegation/types.d.ts +23 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.js +11 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +0 -6
- package/dist/harness/context/capabilities/compact/engine.js +169 -121
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +5 -1
- package/dist/harness/context/capabilities/compact/index.js +4 -0
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +76 -11
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +4 -9
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/types.d.ts +4 -7
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +236 -0
- package/dist/harness/context/default-context-engine.d.ts +195 -119
- package/dist/harness/context/default-context-engine.js +1241 -743
- package/dist/harness/context/index.d.ts +2 -2
- package/dist/harness/context/index.js +1 -1
- package/dist/harness/context/layer-types.d.ts +15 -0
- package/dist/harness/context/layer-types.js +14 -1
- package/dist/harness/context/layers.d.ts +16 -19
- package/dist/harness/context/layers.js +42 -14
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/summarize.d.ts +3 -3
- package/dist/harness/context/summarize.js +11 -4
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +3 -1
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +6 -1
- package/dist/harness/context/tool-result-aging.js +16 -5
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +127 -117
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +24 -2
- package/dist/harness/extension/execution-environment/effect-policy.js +30 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +7 -3
- package/dist/harness/extension/execution-environment/ops-audit.js +11 -12
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/undo-log.d.ts +6 -2
- package/dist/harness/extension/execution-environment/undo-log.js +31 -10
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +83 -249
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +50 -117
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +17 -24
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +3 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +3 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +9 -5
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +9 -130
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +122 -14
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +4 -13
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +25 -11
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +168 -62
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +11 -2
- package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-risk-policy.d.ts +1 -0
- package/dist/harness/governance/security/default-risk-policy.js +1 -0
- package/dist/harness/governance/security/default-security-guard.js +9 -0
- package/dist/harness/governance/security/index.d.ts +1 -0
- package/dist/harness/governance/security/index.js +2 -0
- package/dist/harness/governance/security/risk-evaluator.js +13 -0
- package/dist/harness/governance/security/risk-types.d.ts +12 -0
- package/dist/harness/governance/security/shell-parser-fallback.d.ts +29 -0
- package/dist/harness/governance/security/shell-parser-fallback.js +410 -0
- package/dist/harness/governance/security/shell-parser-shared.d.ts +83 -0
- package/dist/harness/governance/security/shell-parser-shared.js +188 -0
- package/dist/harness/governance/security/shell-parser-treesitter.d.ts +52 -0
- package/dist/harness/governance/security/shell-parser-treesitter.js +370 -0
- package/dist/harness/governance/security/shell-parser.d.ts +23 -10
- package/dist/harness/governance/security/shell-parser.js +37 -496
- package/dist/harness/governance/security/vendor/README.md +24 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.LICENSE.txt +21 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.wasm +0 -0
- package/dist/harness/index.d.ts +12 -12
- package/dist/harness/index.js +7 -7
- package/dist/harness/knowledge/boot-config.d.ts +55 -0
- package/dist/harness/knowledge/boot-config.js +50 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +24 -2
- package/dist/harness/knowledge/client.js +19 -5
- package/dist/harness/knowledge/db.js +5 -0
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +6 -0
- package/dist/harness/knowledge/grounding.js +3 -1
- package/dist/harness/knowledge/http-app.js +35 -4
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +3 -0
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +13 -2
- package/dist/harness/knowledge/query-service.js +4 -2
- package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -2
- package/dist/harness/knowledge/query-worker.js +4 -2
- package/dist/harness/knowledge/read-http.js +5 -1
- package/dist/harness/knowledge/serve.d.ts +8 -7
- package/dist/harness/knowledge/serve.js +9 -0
- package/dist/harness/knowledge/source-store.js +26 -3
- package/dist/harness/knowledge/start-service-process.d.ts +15 -7
- package/dist/harness/knowledge/start-service-process.js +21 -9
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +37 -9
- package/dist/harness/knowledge/writer-service.js +120 -14
- package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
- package/dist/harness/knowledge/writer-worker-client.js +20 -2
- package/dist/harness/knowledge/writer-worker.js +9 -1
- package/dist/harness/memory/index.d.ts +6 -2
- package/dist/harness/memory/index.js +4 -1
- package/dist/harness/memory/memory-events.d.ts +25 -0
- package/dist/harness/memory/memory-events.js +38 -0
- package/dist/harness/memory/sqlite/agent-db.js +15 -0
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +7 -2
- package/dist/harness/memory/sqlite/wisdom-store.js +86 -12
- package/dist/harness/memory/steward-policy.d.ts +3 -0
- package/dist/harness/memory/steward-policy.js +1 -1
- package/dist/harness/memory/types.d.ts +47 -7
- package/dist/harness/memory/wisdom-attribution.d.ts +136 -0
- package/dist/harness/memory/wisdom-attribution.js +287 -0
- package/dist/harness/memory/wisdom-events.d.ts +37 -0
- package/dist/harness/memory/wisdom-events.js +61 -0
- package/dist/harness/memory/wisdom-formation.d.ts +31 -1
- package/dist/harness/memory/wisdom-formation.js +130 -33
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.d.ts +7 -2
- package/dist/harness/memory/wisdom.js +49 -2
- package/dist/harness/observability/observer/hub.js +25 -15
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +66 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +10 -4
- package/dist/harness/run/reliability/run-agent.js +137 -53
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- package/dist/harness/run/run-scope.d.ts +41 -4
- package/dist/harness/run/runner.d.ts +71 -31
- package/dist/harness/run/runner.js +368 -106
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- package/dist/harness/session/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +2 -2
- package/dist/harness/shared/events/agent-event-map.d.ts +46 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/paths/glob.d.ts +52 -0
- package/dist/harness/shared/paths/glob.js +218 -0
- package/dist/harness/shared/paths/index.d.ts +84 -0
- package/dist/harness/shared/paths/index.js +179 -0
- package/dist/harness/shared/types/agent-definition.d.ts +1 -2
- package/dist/index.d.ts +14 -17
- package/dist/index.js +7 -9
- package/dist/integration/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- package/dist/integration/providers/anthropic.js +14 -1
- package/dist/integration/providers/openai.js +7 -1
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump.d.ts +1 -1
- package/dist/integration/storage/archive-manager.d.ts +6 -0
- package/dist/integration/storage/archive-manager.js +10 -0
- package/dist/integration/storage/jsonl.d.ts +1 -1
- package/dist/integration/storage/jsonl.js +18 -16
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +4 -2
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +12 -20
- package/dist/subsystems/memory-steward/backfill/config.yaml +4 -2
- package/dist/subsystems/memory-steward/backfill/handler.js +44 -52
- package/dist/subsystems/wisdom-steward/attribute/SUBSYSTEM.md +24 -0
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +60 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.d.ts +23 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.js +167 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +3 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +13 -5
- package/dist/subsystems/wisdom-steward/formation/handler.js +39 -23
- package/dist/subsystems/wisdom-steward/govern/config.yaml +1 -1
- package/dist/subsystems/wisdom-steward/govern/handler.js +4 -0
- package/package.json +16 -14
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -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,49 @@ 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
|
+
// 与请求 toolDefs 同源:loop 实发 = buildToolDefinitions(currentContext.tools)
|
|
259
|
+
// (agent-loop;undefined = 0 工具)。
|
|
260
|
+
// M-6:活读(getter)而非快照——beforeStep 可 Object.assign 替换 tools 数组,
|
|
261
|
+
// 快照会让估算按 run 起点工具面、请求按 run 中途工具面(错位估算 = 毒样本)。
|
|
262
|
+
// Nit 3(评审 del-e1ee43ef):不回退 options.runScope.tools——那是「宿主宣告清单」,
|
|
263
|
+
// 请求实发的是 context.tools,分叉即毒样本;runScope.tools 仅是外部 withRunScope
|
|
264
|
+
// 桥接场景的携带字段(builder 读 scope?.tools ?? []),不参与 agent.run 估算口径。
|
|
265
|
+
get tools() {
|
|
266
|
+
return context.tools;
|
|
267
|
+
},
|
|
234
268
|
grounding: options?.runScope?.grounding,
|
|
235
269
|
toolRuntime: options?.runScope?.toolRuntime,
|
|
236
270
|
agentRevision: options?.runScope?.agentRevision,
|
|
271
|
+
taskSnapshot: options?.runScope?.taskSnapshot,
|
|
237
272
|
};
|
|
238
|
-
|
|
273
|
+
const hookState = integrateAgentHooks(this._extensionHooks, config, () => runScope);
|
|
274
|
+
if (hookState) {
|
|
275
|
+
const existingBeforeToolCall = config.beforeToolCall;
|
|
276
|
+
config.prepareToolArguments = hookState.callbacks().prepareToolArguments;
|
|
277
|
+
config.onToolCallComplete = hookState.callbacks().onToolCallComplete;
|
|
278
|
+
config.beforeToolCall = async (ctx, toolSignal) => {
|
|
279
|
+
const existing = await existingBeforeToolCall?.(ctx, toolSignal);
|
|
280
|
+
if (existing?.block)
|
|
281
|
+
return existing;
|
|
282
|
+
return voteAgentToolCall(this._extensionHooks, ctx, hookState.originalToolParams, toolSignal);
|
|
283
|
+
};
|
|
284
|
+
config.beforeStep = hookState.callbacks().beforeStep;
|
|
285
|
+
config.onStepComplete = hookState.callbacks().onStepComplete;
|
|
286
|
+
config.transformLlmMessages = hookState.transformLlmMessages.bind(hookState);
|
|
287
|
+
}
|
|
288
|
+
let gen = runAgentWithReliability(context, config, harness, signal, {
|
|
289
|
+
toolRuntime: runScope.toolRuntime,
|
|
290
|
+
});
|
|
239
291
|
gen = withRunScope(runScope, gen);
|
|
292
|
+
gen = withAgentRunHooks(this._extensionHooks, runScope, context, signal, gen);
|
|
240
293
|
if (resolved) {
|
|
241
294
|
return withResolvedModel(resolved, gen);
|
|
242
295
|
}
|
|
@@ -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;
|
|
@@ -7,8 +7,12 @@
|
|
|
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
|
// ── 默认配置 ──
|
|
14
18
|
export const DEFAULT_BUDGET = {
|
|
@@ -24,9 +28,10 @@ export const DEFAULT_BUDGET = {
|
|
|
24
28
|
*/
|
|
25
29
|
export class BudgetPolicyEngine {
|
|
26
30
|
config;
|
|
27
|
-
|
|
31
|
+
steps = 0;
|
|
28
32
|
toolCalls = 0;
|
|
29
33
|
nominalTokens = 0;
|
|
34
|
+
humanWaitMs = 0;
|
|
30
35
|
startTime;
|
|
31
36
|
constructor(config) {
|
|
32
37
|
this.config = { ...DEFAULT_BUDGET, ...config };
|
|
@@ -34,23 +39,24 @@ export class BudgetPolicyEngine {
|
|
|
34
39
|
}
|
|
35
40
|
/** 重置计数(Gateway 长驻每请求调用);保留配置 */
|
|
36
41
|
reset() {
|
|
37
|
-
this.
|
|
42
|
+
this.steps = 0;
|
|
38
43
|
this.toolCalls = 0;
|
|
39
44
|
this.nominalTokens = 0;
|
|
45
|
+
this.humanWaitMs = 0;
|
|
40
46
|
this.startTime = Date.now();
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
49
|
* 仅检查 hard(无 soft 路径)。
|
|
44
50
|
*/
|
|
45
51
|
checkHardOnly() {
|
|
46
|
-
const elapsedMs =
|
|
52
|
+
const elapsedMs = this.activeElapsedMs();
|
|
47
53
|
if (elapsedMs >= this.config.maxWallClockMs) {
|
|
48
54
|
return { status: 'hard', reason: 'wall_clock', report: this.buildReport('timeout') };
|
|
49
55
|
}
|
|
50
|
-
if (this.config.
|
|
51
|
-
this.config.
|
|
52
|
-
this.
|
|
53
|
-
return { status: 'hard', reason: '
|
|
56
|
+
if (this.config.maxSteps !== undefined &&
|
|
57
|
+
this.config.maxSteps > 0 &&
|
|
58
|
+
this.steps >= this.config.maxSteps) {
|
|
59
|
+
return { status: 'hard', reason: 'steps', report: this.buildReport('step_limit') };
|
|
54
60
|
}
|
|
55
61
|
if (this.config.maxToolCalls !== undefined &&
|
|
56
62
|
this.config.maxToolCalls > 0 &&
|
|
@@ -80,8 +86,8 @@ export class BudgetPolicyEngine {
|
|
|
80
86
|
return this.checkHardOnly().report.status;
|
|
81
87
|
}
|
|
82
88
|
// 注:用户可见停止走 reliability yield `budget_exceeded` → Runner 桥接。
|
|
83
|
-
|
|
84
|
-
this.
|
|
89
|
+
recordStep() {
|
|
90
|
+
this.steps++;
|
|
85
91
|
}
|
|
86
92
|
recordToolCall(n = 1) {
|
|
87
93
|
this.toolCalls += n;
|
|
@@ -91,6 +97,22 @@ export class BudgetPolicyEngine {
|
|
|
91
97
|
if (tokens > 0)
|
|
92
98
|
this.nominalTokens += tokens;
|
|
93
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 记录人类输入等待时长(ask_user 等阻塞式人机工具回传)。
|
|
102
|
+
* 从 wall-clock 计量中扣除:等人不算引擎运行时长。
|
|
103
|
+
* 累计以存续时长封顶(等待是存续的子集;并行等待/超报不得把安全阀静默归零)。
|
|
104
|
+
*
|
|
105
|
+
* @param ms - 本次等待时长(毫秒)
|
|
106
|
+
*/
|
|
107
|
+
addHumanWaitMs(ms) {
|
|
108
|
+
if (ms > 0) {
|
|
109
|
+
this.humanWaitMs = Math.min(this.humanWaitMs + ms, Date.now() - this.startTime);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** 活跃运行时长 = 存续时长 - 人类输入等待(不小于 0) */
|
|
113
|
+
activeElapsedMs() {
|
|
114
|
+
return Math.max(0, Date.now() - this.startTime - this.humanWaitMs);
|
|
115
|
+
}
|
|
94
116
|
report() {
|
|
95
117
|
return this.checkHardOnly().report;
|
|
96
118
|
}
|
|
@@ -98,16 +120,17 @@ export class BudgetPolicyEngine {
|
|
|
98
120
|
return { ...this.config };
|
|
99
121
|
}
|
|
100
122
|
buildReport(status) {
|
|
101
|
-
const elapsedMs =
|
|
123
|
+
const elapsedMs = this.activeElapsedMs();
|
|
102
124
|
return {
|
|
103
125
|
status,
|
|
104
|
-
|
|
126
|
+
steps: this.steps,
|
|
105
127
|
toolCalls: this.toolCalls,
|
|
106
128
|
nominalTokens: this.nominalTokens,
|
|
107
129
|
elapsedMs,
|
|
130
|
+
humanWaitMs: this.humanWaitMs,
|
|
108
131
|
remaining: {
|
|
109
|
-
|
|
110
|
-
? Math.max(0, this.config.
|
|
132
|
+
steps: this.config.maxSteps !== undefined
|
|
133
|
+
? Math.max(0, this.config.maxSteps - this.steps)
|
|
111
134
|
: null,
|
|
112
135
|
toolCalls: this.config.maxToolCalls !== undefined
|
|
113
136
|
? Math.max(0, this.config.maxToolCalls - this.toolCalls)
|
|
@@ -116,7 +139,7 @@ export class BudgetPolicyEngine {
|
|
|
116
139
|
},
|
|
117
140
|
hard: {
|
|
118
141
|
wallClockMs: this.config.maxWallClockMs,
|
|
119
|
-
|
|
142
|
+
steps: this.config.maxSteps ?? null,
|
|
120
143
|
toolCalls: this.config.maxToolCalls ?? null,
|
|
121
144
|
},
|
|
122
145
|
};
|
|
@@ -6,4 +6,6 @@
|
|
|
6
6
|
export type { ResolvedModel, ModelCatalogEntry, ModelCapabilitySource, } from './types.js';
|
|
7
7
|
export { parseModelRef, bindModelName, lookupModelCapability, resolveModel, resolveModelRef, resolveCatalogEntry, lookupDeclaredContextWindow, } from './resolver.js';
|
|
8
8
|
export type { ParsedModelRef, ResolveModelInput } from './resolver.js';
|
|
9
|
-
export { withResolvedModel, getResolvedModel, getRunModelProvider, getRunContextWindow, getRunModelName, } from './run-scope.js';
|
|
9
|
+
export { withResolvedModel, getResolvedModel, updateResolvedModel, getRunModelProvider, getRunContextWindow, getRunModelName, } from './run-scope.js';
|
|
10
|
+
export { recordWindowTruth, getWindowTruth, resetWindowTruth } from './window-truth.js';
|
|
11
|
+
export type { WindowTruthEntry } from './window-truth.js';
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
* @module harness/run/model
|
|
5
5
|
*/
|
|
6
6
|
export { parseModelRef, bindModelName, lookupModelCapability, resolveModel, resolveModelRef, resolveCatalogEntry, lookupDeclaredContextWindow, } from './resolver.js';
|
|
7
|
-
export { withResolvedModel, getResolvedModel, getRunModelProvider, getRunContextWindow, getRunModelName, } from './run-scope.js';
|
|
7
|
+
export { withResolvedModel, getResolvedModel, updateResolvedModel, getRunModelProvider, getRunContextWindow, getRunModelName, } from './run-scope.js';
|
|
8
|
+
export { recordWindowTruth, getWindowTruth, resetWindowTruth } from './window-truth.js';
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* 设计约定(架构收口,见 docs/architecture.md):
|
|
5
5
|
* 1. 每个 run / 每个 catalog 条目只 resolve 一次
|
|
6
6
|
* 2. 下游只读 ResolvedModel,禁止二次回退
|
|
7
|
-
* 3. **contextWindow
|
|
7
|
+
* 3. **contextWindow 认显式配置,或 provider 测量真值(F 类回填)**;两者皆无 = unknown,不猜测
|
|
8
8
|
* 4. 会话覆盖到另一模型时,不继承 agent 默认模型的窗口
|
|
9
9
|
*
|
|
10
10
|
* @module harness/run/model/resolver
|
|
11
11
|
*/
|
|
12
12
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
13
13
|
import type { ModelCatalogEntry, ModelCapabilitySource, ResolvedModel } from './types.js';
|
|
14
|
+
import type { ModelInputType } from '@octopi-agent/core/types/agent-definition.js';
|
|
14
15
|
export interface ParsedModelRef {
|
|
15
16
|
provider?: string;
|
|
16
17
|
model: string;
|
|
@@ -51,6 +52,8 @@ export declare function lookupModelCapability(input: {
|
|
|
51
52
|
}): {
|
|
52
53
|
contextWindow?: number;
|
|
53
54
|
maxOutputTokens?: number;
|
|
55
|
+
reasoning?: boolean;
|
|
56
|
+
input?: ModelInputType[];
|
|
54
57
|
source: ModelCapabilitySource;
|
|
55
58
|
known: boolean;
|
|
56
59
|
};
|