@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
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* transport 管"怎么把请求送到目标"(进程内 / 将来跨进程);
|
|
18
18
|
* 本端口管"目标本地怎么起 Run"。两者不可互相渗透。
|
|
19
19
|
*/
|
|
20
|
-
import { emptyTokenUsage } from '@octopi-agent/core/types/
|
|
20
|
+
import { emptyTokenUsage } from '@octopi-agent/core/types/step.js';
|
|
21
|
+
import { DEFAULT_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
21
22
|
/**
|
|
22
|
-
* 累加
|
|
23
|
+
* 累加 step 级 usage 到总账(决策 C2:归集到父的 run 账)
|
|
23
24
|
*
|
|
24
25
|
* @param total - 累计账本(原地更新)
|
|
25
26
|
* @param add - 本轮 usage
|
|
@@ -83,6 +84,9 @@ export class RunnerChildRunPort {
|
|
|
83
84
|
sessionId: childSessionId,
|
|
84
85
|
// D3:委派权利天花板,Runner 会与模板天花板取交集
|
|
85
86
|
rightsCeiling: input.rightsCeiling,
|
|
87
|
+
// §9.1-6:子 run principal 归属 = 父会话租户(mergePrincipal 与子 agent
|
|
88
|
+
// 归属冲突时 fail-loud——同租户闸已在 dispatch,这里是纵深防线)
|
|
89
|
+
...(input.tenantId === undefined ? {} : { principal: { actorType: 'agent', tenantId: input.tenantId } }),
|
|
86
90
|
};
|
|
87
91
|
const usage = emptyTokenUsage();
|
|
88
92
|
let output;
|
|
@@ -92,7 +96,7 @@ export class RunnerChildRunPort {
|
|
|
92
96
|
try {
|
|
93
97
|
for await (const event of target.runner.handle(childSessionId, userMessage, runConfig, signal)) {
|
|
94
98
|
switch (event.type) {
|
|
95
|
-
case '
|
|
99
|
+
case 'step.end': {
|
|
96
100
|
const data = event.data;
|
|
97
101
|
// 失败尝试的 content 是中断残句,不是委派结果;error 布尔标记也不是错误文本
|
|
98
102
|
//(String(true)='true' 会占位并挡住后面 engine.error 的真消息)
|
|
@@ -148,23 +152,46 @@ export class RunnerChildRunPort {
|
|
|
148
152
|
/** 构造带 `spawnBy` 的 child session 骨架 */
|
|
149
153
|
newChildSession(sessionId, input) {
|
|
150
154
|
const timestamp = Date.now();
|
|
155
|
+
// 委派标题落三键:子会话不再一律「新会话」。
|
|
156
|
+
// 权威在 metadata 三键(写端恒打三键);meta.title 仅镜像——只写 meta.title
|
|
157
|
+
// 会被 readTitleState 投影覆盖为 undefined(曾是「新会话」的根因)。
|
|
158
|
+
// 显式标题按 user 语义保护(不被自动标题覆盖——"设了就是设了");
|
|
159
|
+
// 任务派生为临时(snippet,可被自动标题升级)——shouldUpdateTitle 既有仲裁
|
|
160
|
+
const title = delegationSessionTitle(input);
|
|
161
|
+
const titleSource = input.title?.trim() ? 'user' : 'snippet';
|
|
151
162
|
return {
|
|
152
163
|
id: sessionId,
|
|
153
164
|
agentId: input.childAgentId,
|
|
165
|
+
tenantId: input.tenantId ?? DEFAULT_TENANT_ID,
|
|
154
166
|
primaryAgentId: input.childAgentId,
|
|
155
167
|
spawnBy: { ...input.spawnBy },
|
|
156
168
|
meta: {
|
|
157
|
-
|
|
169
|
+
tenantId: input.tenantId ?? DEFAULT_TENANT_ID,
|
|
170
|
+
title,
|
|
171
|
+
titleSource,
|
|
172
|
+
titleUpdatedAt: timestamp,
|
|
158
173
|
createdAt: timestamp,
|
|
159
174
|
updatedAt: timestamp,
|
|
160
175
|
status: 'idle',
|
|
161
176
|
},
|
|
162
177
|
messages: [],
|
|
163
|
-
|
|
164
|
-
metadata: {
|
|
178
|
+
steps: [],
|
|
179
|
+
metadata: {
|
|
180
|
+
delegationId: input.delegationId,
|
|
181
|
+
title,
|
|
182
|
+
titleSource,
|
|
183
|
+
titleUpdatedAt: timestamp,
|
|
184
|
+
},
|
|
165
185
|
};
|
|
166
186
|
}
|
|
167
187
|
}
|
|
188
|
+
/** 委派 → 子会话标题(单一来源,委派单记录与子会话同用此值):显式 title 优先(压单行、截 120);缺省退任务派生(delegation: 前缀,兼容直连 API 老调用方) */
|
|
189
|
+
export function delegationSessionTitle(input) {
|
|
190
|
+
const explicit = input.title?.replace(/\s+/g, ' ').trim();
|
|
191
|
+
if (explicit)
|
|
192
|
+
return explicit.slice(0, 120);
|
|
193
|
+
return `delegation: ${input.task.replace(/\s+/g, ' ').trim()}`.slice(0, 120);
|
|
194
|
+
}
|
|
168
195
|
/**
|
|
169
196
|
* 渲染 fork 模式的父历史前缀(§9.4:显式 `context: 'fork'` 才继承)
|
|
170
197
|
*
|
|
@@ -224,10 +251,15 @@ export function createChildRunExecutor(port, options, resolvePersona) {
|
|
|
224
251
|
const output = await port.run({
|
|
225
252
|
delegationId: request.delegationId,
|
|
226
253
|
childAgentId,
|
|
254
|
+
// §8 委派继承位:子 run 归属 = 父 run 归属(租户内委派闸在 dispatch)
|
|
255
|
+
...(request.from.tenantId === undefined
|
|
256
|
+
? {}
|
|
257
|
+
: { tenantId: request.from.tenantId }),
|
|
227
258
|
// D7:id 由服务方在起 Run 前生成并落库,此处透传
|
|
228
259
|
childSessionId: request.childSessionId,
|
|
229
260
|
childRunId: request.childRunId,
|
|
230
261
|
task: request.task,
|
|
262
|
+
title: request.title,
|
|
231
263
|
input: request.input,
|
|
232
264
|
context: request.context,
|
|
233
265
|
parentMessages: request.parentMessages,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* + `AgentHandle`(D2 寻址)+ `DelegateTransport`(唯一分布式缝)。
|
|
9
9
|
*/
|
|
10
10
|
export type { Delegation, DelegationBudget, DelegationContextMode, DelegationEventType, DelegationParentRef, DelegationStatus, DelegationTarget, DelegateRequest, DelegateResult, AgentHandle, } from './types.js';
|
|
11
|
-
export { DELEGATION_SCHEMA_VERSION, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
11
|
+
export { DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
12
12
|
export type { AgentRegistry, AgentInfo, AgentQuery, AgentRelation, AgentRelationType, AgentDelegationPolicy, } from './registry-types.js';
|
|
13
13
|
export { AgentRegistryEvents } from './registry-types.js';
|
|
14
14
|
export { DefaultAgentRegistry } from './registry.js';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* L2 委派契约层:`DelegateRequest` / `DelegateResult`(纯 JSON,D1/D5)
|
|
8
8
|
* + `AgentHandle`(D2 寻址)+ `DelegateTransport`(唯一分布式缝)。
|
|
9
9
|
*/
|
|
10
|
-
export { DELEGATION_SCHEMA_VERSION, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
10
|
+
export { DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
11
11
|
export { AgentRegistryEvents } from './registry-types.js';
|
|
12
12
|
// ── Registry 实现 ──
|
|
13
13
|
export { DefaultAgentRegistry } from './registry.js';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* 禁止在调用链上 await(`arch/agent-runtime.md` 重入策略)。
|
|
15
15
|
*/
|
|
16
16
|
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
17
|
-
import type
|
|
17
|
+
import { type Delegation } from './types.js';
|
|
18
18
|
import type { DelegationNotifier } from './service.js';
|
|
19
19
|
/** notify 投递器配置 */
|
|
20
20
|
export interface DelegationNotifierConfig {
|
|
@@ -26,6 +26,11 @@ export interface DelegationNotifierConfig {
|
|
|
26
26
|
/**
|
|
27
27
|
* 渲染委派终态通知(§7.1:`<delegation_completed …/>`)
|
|
28
28
|
*
|
|
29
|
+
* `<output>` 截断上限按委派单 `maxOutputChars`(缺省 {@link DEFAULT_DELEGATION_OUTPUT_CHARS})——
|
|
30
|
+
* 只影响自动送达的 notice;`delegate_get` 全文取回不受此限。上限计量**原始 output 字符**
|
|
31
|
+
* (截断补 `…`,实体最多 max+1 字符);escapeText 后投递文本可因转义膨胀(最坏 5×,
|
|
32
|
+
* 上限约束内容量不约束投递字节——2026-11-09 评审 m5 记债)。
|
|
33
|
+
*
|
|
29
34
|
* @param delegation - 终态委派单
|
|
30
35
|
* @returns 通知文本
|
|
31
36
|
*/
|
|
@@ -13,10 +13,16 @@
|
|
|
13
13
|
* 不打断父 Run:同 session 运行中再来 Trigger 由 Runner FIFO 锁排队,
|
|
14
14
|
* 禁止在调用链上 await(`arch/agent-runtime.md` 重入策略)。
|
|
15
15
|
*/
|
|
16
|
+
import { DEFAULT_DELEGATION_OUTPUT_CHARS } from './types.js';
|
|
16
17
|
import { emitAgentSignal, hasAgentSignalReceiver, } from '../../activation/sources/agent-signal.js';
|
|
17
18
|
/**
|
|
18
19
|
* 渲染委派终态通知(§7.1:`<delegation_completed …/>`)
|
|
19
20
|
*
|
|
21
|
+
* `<output>` 截断上限按委派单 `maxOutputChars`(缺省 {@link DEFAULT_DELEGATION_OUTPUT_CHARS})——
|
|
22
|
+
* 只影响自动送达的 notice;`delegate_get` 全文取回不受此限。上限计量**原始 output 字符**
|
|
23
|
+
* (截断补 `…`,实体最多 max+1 字符);escapeText 后投递文本可因转义膨胀(最坏 5×,
|
|
24
|
+
* 上限约束内容量不约束投递字节——2026-11-09 评审 m5 记债)。
|
|
25
|
+
*
|
|
20
26
|
* @param delegation - 终态委派单
|
|
21
27
|
* @returns 通知文本
|
|
22
28
|
*/
|
|
@@ -31,7 +37,8 @@ export function renderDelegationNotice(delegation) {
|
|
|
31
37
|
];
|
|
32
38
|
const body = [];
|
|
33
39
|
if (delegation.output) {
|
|
34
|
-
|
|
40
|
+
const maxOutputChars = delegation.maxOutputChars ?? DEFAULT_DELEGATION_OUTPUT_CHARS;
|
|
41
|
+
body.push(`<output>${escapeText(truncate(delegation.output, maxOutputChars))}</output>`);
|
|
35
42
|
}
|
|
36
43
|
if (delegation.error) {
|
|
37
44
|
body.push(`<error>${escapeText(truncate(delegation.error, 1000))}</error>`);
|
|
@@ -49,6 +49,8 @@ export interface AgentDelegationPolicy {
|
|
|
49
49
|
export interface AgentInfo {
|
|
50
50
|
/** Agent 唯一 ID */
|
|
51
51
|
id: string;
|
|
52
|
+
/** Agent 归属租户(arch/multi-tenancy.md §8 委派限本租户);缺省 = DEFAULT 存量域 */
|
|
53
|
+
tenantId?: string;
|
|
52
54
|
/** Agent 名称(人类可读) */
|
|
53
55
|
name: string;
|
|
54
56
|
/** Agent 描述 */
|
|
@@ -39,7 +39,11 @@ export interface DispatchDelegationInput {
|
|
|
39
39
|
*/
|
|
40
40
|
parentRights?: import('../../governance/session-acl/types.js').SessionRights;
|
|
41
41
|
task: string;
|
|
42
|
+
/** 子会话显示标题(工具面必填;写入委派单与子会话标题三键) */
|
|
43
|
+
title?: string;
|
|
42
44
|
input: string;
|
|
45
|
+
/** 自动返回通知 `<output>` 截断上限(chars);缺省 = DEFAULT_DELEGATION_OUTPUT_CHARS(B 方案 2026-11-09) */
|
|
46
|
+
maxOutputChars?: number;
|
|
43
47
|
context?: DelegationContextMode;
|
|
44
48
|
/** 父消息历史(仅 context='fork' 时携带) */
|
|
45
49
|
parentMessages?: import('@octopi-agent/core/types.js').Message[];
|
|
@@ -101,10 +105,10 @@ export interface ResolutionAvailability {
|
|
|
101
105
|
}>;
|
|
102
106
|
}
|
|
103
107
|
export declare class DelegateResolutionError extends Error {
|
|
104
|
-
readonly reason: 'not_found' | 'not_callable' | 'forbidden' | 'depth_exceeded' | 'too_many_active';
|
|
108
|
+
readonly reason: 'not_found' | 'not_callable' | 'forbidden' | 'depth_exceeded' | 'too_many_active' | 'cross_tenant';
|
|
105
109
|
/** 解析失败时的可用目标(可选;让调用方不必瞎猜) */
|
|
106
110
|
readonly available?: ResolutionAvailability | undefined;
|
|
107
|
-
constructor(message: string, reason: 'not_found' | 'not_callable' | 'forbidden' | 'depth_exceeded' | 'too_many_active',
|
|
111
|
+
constructor(message: string, reason: 'not_found' | 'not_callable' | 'forbidden' | 'depth_exceeded' | 'too_many_active' | 'cross_tenant',
|
|
108
112
|
/** 解析失败时的可用目标(可选;让调用方不必瞎猜) */
|
|
109
113
|
available?: ResolutionAvailability | undefined);
|
|
110
114
|
}
|
|
@@ -183,14 +187,17 @@ export declare class DelegateService {
|
|
|
183
187
|
*
|
|
184
188
|
* @param target - 目标寻址
|
|
185
189
|
* @param callerAgentId - 调用方 agentId(校验 callableBy)
|
|
190
|
+
* @param callerTenantId - 调用方归属租户(§8 委派限本租户;trait 选人先按域过滤——
|
|
191
|
+
* 否则他租户候选会抢走选择或硬拒本可成立的委派,T4b 评审 MAJ-8)
|
|
186
192
|
* @returns 解析出的 AgentHandle
|
|
187
193
|
* @throws 目标不可达 / 不可被委派 / 策略拒绝
|
|
188
194
|
*/
|
|
189
195
|
private resolveTarget;
|
|
190
196
|
/**
|
|
191
|
-
*
|
|
197
|
+
* 列出**可用委派目标**(失败时回传,供调用方自愈)——按调用方租户域收口
|
|
192
198
|
*
|
|
193
|
-
* @
|
|
199
|
+
* @param callerTenant - 调用方归属租户(缺省 = DEFAULT 存量域)
|
|
200
|
+
* @returns 本域可用 traits 与 agent 概要
|
|
194
201
|
*/
|
|
195
202
|
private describeTargets;
|
|
196
203
|
/** 校验委派策略并转 AgentHandle */
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
* **非阻塞**(§7):`dispatch()` 建单后立即返回 `delegationId`,不等子 Run 结束。
|
|
17
17
|
*/
|
|
18
18
|
import { randomUUID } from 'node:crypto';
|
|
19
|
+
import { DEFAULT_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
19
20
|
import { DELEGATION_SCHEMA_VERSION, DelegationEvents, isTerminalDelegationStatus } from './types.js';
|
|
21
|
+
import { delegationSessionTitle } from './child-run.js';
|
|
20
22
|
import { tightenSessionRights } from '../../governance/session-acl/rights.js';
|
|
21
23
|
import { effectiveDelegationPolicy } from './registry-types.js';
|
|
22
24
|
export class DelegateResolutionError extends Error {
|
|
@@ -66,7 +68,7 @@ export function intersectBudget(requested, ceiling) {
|
|
|
66
68
|
return Math.min(a, b);
|
|
67
69
|
};
|
|
68
70
|
return {
|
|
69
|
-
|
|
71
|
+
maxSteps: pick(requested?.maxSteps, ceiling?.maxSteps),
|
|
70
72
|
maxTokens: pick(requested?.maxTokens, ceiling?.maxTokens),
|
|
71
73
|
timeoutMs: pick(requested?.timeoutMs, ceiling?.timeoutMs),
|
|
72
74
|
};
|
|
@@ -94,8 +96,15 @@ export class DelegateService {
|
|
|
94
96
|
* @throws 目标不可达 / 不可被委派 / 深度超限 / 未闭合委派过多
|
|
95
97
|
*/
|
|
96
98
|
async dispatch(input) {
|
|
97
|
-
// 1. 解析目标(D2)
|
|
98
|
-
const handle = this.resolveTarget(input.target, input.parent.agentId);
|
|
99
|
+
// 1. 解析目标(D2);trait 选人按父域过滤(MAJ-8)
|
|
100
|
+
const handle = this.resolveTarget(input.target, input.parent.agentId, input.parent.tenantId);
|
|
101
|
+
// 1b. 租户闸(arch/multi-tenancy.md §8,T4b):委派限本租户——跨租户 = 数据外泄 +
|
|
102
|
+
// 目标执行环境不受本租户控制。缺省(config agent / 存量)= DEFAULT 存量域,彼此可派。
|
|
103
|
+
const parentTenant = input.parent.tenantId ?? DEFAULT_TENANT_ID;
|
|
104
|
+
const targetTenant = handle.tenantId ?? DEFAULT_TENANT_ID;
|
|
105
|
+
if (parentTenant !== targetTenant) {
|
|
106
|
+
throw new DelegateResolutionError(`delegate cross-tenant: ${input.parent.agentId} (${parentTenant}) -> ${handle.agentId} (${targetTenant})`, 'cross_tenant');
|
|
107
|
+
}
|
|
99
108
|
// 2. 递归深度闸(§10.4)
|
|
100
109
|
const parentDepth = input.parentDepth ?? this.config.resolveParentDepth?.(input.parent.sessionId) ?? 0;
|
|
101
110
|
const depth = parentDepth + 1;
|
|
@@ -128,7 +137,9 @@ export class DelegateService {
|
|
|
128
137
|
parent: input.parent,
|
|
129
138
|
target: input.target,
|
|
130
139
|
task: input.task,
|
|
140
|
+
title: delegationSessionTitle(input),
|
|
131
141
|
input: input.input,
|
|
142
|
+
maxOutputChars: input.maxOutputChars,
|
|
132
143
|
context: input.context,
|
|
133
144
|
budget,
|
|
134
145
|
deadlineAt,
|
|
@@ -257,14 +268,17 @@ export class DelegateService {
|
|
|
257
268
|
*
|
|
258
269
|
* @param target - 目标寻址
|
|
259
270
|
* @param callerAgentId - 调用方 agentId(校验 callableBy)
|
|
271
|
+
* @param callerTenantId - 调用方归属租户(§8 委派限本租户;trait 选人先按域过滤——
|
|
272
|
+
* 否则他租户候选会抢走选择或硬拒本可成立的委派,T4b 评审 MAJ-8)
|
|
260
273
|
* @returns 解析出的 AgentHandle
|
|
261
274
|
* @throws 目标不可达 / 不可被委派 / 策略拒绝
|
|
262
275
|
*/
|
|
263
|
-
resolveTarget(target, callerAgentId) {
|
|
276
|
+
resolveTarget(target, callerAgentId, callerTenantId) {
|
|
277
|
+
const callerTenant = callerTenantId ?? DEFAULT_TENANT_ID;
|
|
264
278
|
if (target.agentId) {
|
|
265
279
|
const info = this.registry.get(target.agentId);
|
|
266
280
|
if (!info) {
|
|
267
|
-
throw new DelegateResolutionError(`delegate target not found: ${target.agentId}`, 'not_found', this.describeTargets());
|
|
281
|
+
throw new DelegateResolutionError(`delegate target not found: ${target.agentId}`, 'not_found', this.describeTargets(callerTenant));
|
|
268
282
|
}
|
|
269
283
|
return this.toHandle(info, callerAgentId);
|
|
270
284
|
}
|
|
@@ -273,26 +287,32 @@ export class DelegateService {
|
|
|
273
287
|
//(否则第一个不可委派的命中会让整次委派失败,而不是落到下一个可用候选)
|
|
274
288
|
const candidates = this.registry
|
|
275
289
|
.findByTrait(target.trait)
|
|
290
|
+
.filter((info) => (info.tenantId ?? DEFAULT_TENANT_ID) === callerTenant)
|
|
276
291
|
.filter((info) => effectiveDelegationPolicy(info.delegation).callable)
|
|
277
292
|
.filter((info) => this.isCallableBy(info, callerAgentId));
|
|
278
293
|
const picked = candidates[0];
|
|
279
294
|
if (!picked) {
|
|
280
|
-
//
|
|
281
|
-
|
|
295
|
+
// 失败时回传**本域可用目标**,让调用方(LLM)一次就能改对,而不是瞎猜
|
|
296
|
+
//(跨租户 agent id/traits 不经 available_targets 泄漏,T4b 评审 MIN-1)
|
|
297
|
+
throw new DelegateResolutionError(`no callable agent for trait: ${target.trait}`, 'not_found', this.describeTargets(callerTenant));
|
|
282
298
|
}
|
|
283
299
|
return this.toHandle(picked, callerAgentId);
|
|
284
300
|
}
|
|
285
|
-
throw new DelegateResolutionError('delegate target must set agentId or trait', 'not_found', this.describeTargets());
|
|
301
|
+
throw new DelegateResolutionError('delegate target must set agentId or trait', 'not_found', this.describeTargets(callerTenant));
|
|
286
302
|
}
|
|
287
303
|
/**
|
|
288
|
-
*
|
|
304
|
+
* 列出**可用委派目标**(失败时回传,供调用方自愈)——按调用方租户域收口
|
|
289
305
|
*
|
|
290
|
-
* @
|
|
306
|
+
* @param callerTenant - 调用方归属租户(缺省 = DEFAULT 存量域)
|
|
307
|
+
* @returns 本域可用 traits 与 agent 概要
|
|
291
308
|
*/
|
|
292
|
-
describeTargets() {
|
|
309
|
+
describeTargets(callerTenant = DEFAULT_TENANT_ID) {
|
|
310
|
+
const visible = this.registry
|
|
311
|
+
.list()
|
|
312
|
+
.filter((a) => (a.tenantId ?? DEFAULT_TENANT_ID) === callerTenant);
|
|
293
313
|
return {
|
|
294
|
-
traits: [...new Set(
|
|
295
|
-
agents:
|
|
314
|
+
traits: [...new Set(visible.flatMap((a) => a.traits))].sort(),
|
|
315
|
+
agents: visible.map((a) => ({
|
|
296
316
|
id: a.id,
|
|
297
317
|
traits: [...a.traits],
|
|
298
318
|
callable: effectiveDelegationPolicy(a.delegation).callable,
|
|
@@ -310,6 +330,7 @@ export class DelegateService {
|
|
|
310
330
|
}
|
|
311
331
|
return {
|
|
312
332
|
agentId: info.id,
|
|
333
|
+
tenantId: info.tenantId,
|
|
313
334
|
traits: info.traits,
|
|
314
335
|
rightsCeiling: policy.rightsCeiling,
|
|
315
336
|
budget: policy.budget,
|
|
@@ -339,6 +360,7 @@ export class DelegateService {
|
|
|
339
360
|
childSessionId,
|
|
340
361
|
childRunId,
|
|
341
362
|
task: input.task,
|
|
363
|
+
title: delegationSessionTitle(input),
|
|
342
364
|
input: input.input,
|
|
343
365
|
context: input.context ?? 'clean',
|
|
344
366
|
parentMessages: input.context === 'fork' ? input.parentMessages : undefined,
|
|
@@ -23,7 +23,11 @@ export interface CreateDelegationInput {
|
|
|
23
23
|
parent: DelegationParentRef;
|
|
24
24
|
target: DelegationTarget;
|
|
25
25
|
task: string;
|
|
26
|
+
/** 子会话显示标题(工具面必填;缺省时子 Run 侧退任务派生) */
|
|
27
|
+
title?: string;
|
|
26
28
|
input: string;
|
|
29
|
+
/** 自动返回通知 `<output>` 截断上限(chars);缺省 = DEFAULT_DELEGATION_OUTPUT_CHARS */
|
|
30
|
+
maxOutputChars?: number;
|
|
27
31
|
context?: DelegationContextMode;
|
|
28
32
|
budget?: DelegationBudget;
|
|
29
33
|
/** 绝对截止时刻(D4);由 budget.timeoutMs 换算或调用方直接给 */
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* 但接口形状按可持久化设计(`Delegation` 全字段可序列化,D1/D5)。
|
|
18
18
|
*/
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
|
-
import { DELEGATION_SCHEMA_VERSION, DelegationEvents, isTerminalDelegationStatus, } from './types.js';
|
|
20
|
+
import { DELEGATION_SCHEMA_VERSION, DelegationEvents, isTerminalDelegationStatus, normalizeMaxOutputChars, } from './types.js';
|
|
21
21
|
function now() {
|
|
22
22
|
return Date.now();
|
|
23
23
|
}
|
|
@@ -67,7 +67,9 @@ export class DelegationStore {
|
|
|
67
67
|
parent: { ...input.parent },
|
|
68
68
|
target: { ...input.target },
|
|
69
69
|
task: input.task,
|
|
70
|
+
title: input.title,
|
|
70
71
|
input: input.input,
|
|
72
|
+
maxOutputChars: normalizeMaxOutputChars(input.maxOutputChars),
|
|
71
73
|
context: input.context ?? 'clean',
|
|
72
74
|
status: 'queued',
|
|
73
75
|
depth: input.depth ?? 1,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 因此本文件的**所有**类型必须可 `JSON.stringify` 无损往返;
|
|
13
13
|
* 不得出现 `AbortSignal` / `Agent` 实例 / 函数 / class 实例等非序列化值。
|
|
14
14
|
*/
|
|
15
|
-
import type { TokenUsage } from '@octopi-agent/core/types/
|
|
15
|
+
import type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
16
16
|
import type { SessionRights } from '../../governance/session-acl/types.js';
|
|
17
17
|
/**
|
|
18
18
|
* 委派消息 schema 版本(D1/⑤:跨进程契约必须版本化)。
|
|
@@ -59,7 +59,7 @@ export interface DelegationTarget {
|
|
|
59
59
|
*/
|
|
60
60
|
export interface DelegationBudget {
|
|
61
61
|
/** 子 Run 最大轮次 */
|
|
62
|
-
|
|
62
|
+
maxSteps?: number;
|
|
63
63
|
/** 子 Run 最大 token */
|
|
64
64
|
maxTokens?: number;
|
|
65
65
|
/** 委派超时(毫秒);换算为 deadlineAt */
|
|
@@ -72,9 +72,26 @@ export interface DelegationParentRef {
|
|
|
72
72
|
agentId: string;
|
|
73
73
|
sessionId: string;
|
|
74
74
|
runId: string;
|
|
75
|
+
/** 父 run 归属租户(§8 委派限本租户);缺省 = DEFAULT 存量域 */
|
|
76
|
+
tenantId?: string;
|
|
75
77
|
}
|
|
76
78
|
/** 结果送达父的状态机(§7.1 送达语义) */
|
|
77
79
|
export type DelegationDeliveryState = 'pending' | 'delivering' | 'surfaced';
|
|
80
|
+
/** 自动返回通知(`<delegation_result>`)`<output>` 默认截断上限(chars)。
|
|
81
|
+
* B 方案(2026-11-09 拍板):默认 16k,可按委派 `max_output_chars` 覆盖;
|
|
82
|
+
* 只影响自动送达 notice,`delegate_get` 全文取回不受此限。 */
|
|
83
|
+
export declare const DEFAULT_DELEGATION_OUTPUT_CHARS = 16000;
|
|
84
|
+
/**
|
|
85
|
+
* 校验/归一化自动返回截断上限(单源;`DelegationStore.create` 唯一写入口消费)。
|
|
86
|
+
*
|
|
87
|
+
* fail loud:非法值(非有限数 / 非正整数)直接抛错,不静默丢结果也不静默禁用截断
|
|
88
|
+
* (NaN 会产出空 `<output>`、负数丢尾部、Infinity 关闭截断——2026-11-09 评审 M2 实测)。
|
|
89
|
+
*
|
|
90
|
+
* @param value - 待校验上限(chars);undefined = 未指定(渲染侧回落默认)
|
|
91
|
+
* @returns 归一化后的上限(undefined = 未指定)
|
|
92
|
+
* @throws 非有限数、非正整数
|
|
93
|
+
*/
|
|
94
|
+
export declare function normalizeMaxOutputChars(value: number | undefined): number | undefined;
|
|
78
95
|
/**
|
|
79
96
|
* 委派单 —— 一次委派的全程记录
|
|
80
97
|
*
|
|
@@ -90,6 +107,11 @@ export interface Delegation {
|
|
|
90
107
|
resolvedAgentId?: string;
|
|
91
108
|
/** 任务描述(进子的 user 消息) */
|
|
92
109
|
task: string;
|
|
110
|
+
/**
|
|
111
|
+
* 子会话显示标题(委派时显式给定,落 child session 标题三键)。
|
|
112
|
+
* 缺省时子 Run 侧退化为任务派生标题(不产生「新会话」)。
|
|
113
|
+
*/
|
|
114
|
+
title?: string;
|
|
93
115
|
/** 显式输入(不传父上下文,D6/⑥) */
|
|
94
116
|
input: string;
|
|
95
117
|
/** 上下文传递模式(默认 clean) */
|
|
@@ -100,6 +122,12 @@ export interface Delegation {
|
|
|
100
122
|
childRunId?: string;
|
|
101
123
|
/** 子的最后一轮 assistant 文本 = 结论(D5) */
|
|
102
124
|
output?: string;
|
|
125
|
+
/**
|
|
126
|
+
* 自动返回通知(`<delegation_result>`)中 `<output>` 的截断上限(chars)。
|
|
127
|
+
* 只影响 notify 自动送达;`delegate_get` 全文取回不受此限。
|
|
128
|
+
* 缺省 = {@link DEFAULT_DELEGATION_OUTPUT_CHARS}(B 方案 2026-11-09)。
|
|
129
|
+
*/
|
|
130
|
+
maxOutputChars?: number;
|
|
103
131
|
/** 子产出的文件路径(D5/D6:不共享文件系统,显式声明) */
|
|
104
132
|
artifacts?: string[];
|
|
105
133
|
/** 子 Run 的 token 消耗(归集到父的 run 账,决策 C2) */
|
|
@@ -150,6 +178,8 @@ export interface DelegateRequest {
|
|
|
150
178
|
childSessionId: string;
|
|
151
179
|
childRunId: string;
|
|
152
180
|
task: string;
|
|
181
|
+
/** 子会话显示标题(工具面必填;缺省时子 Run 侧退任务派生标题) */
|
|
182
|
+
title?: string;
|
|
153
183
|
input: string;
|
|
154
184
|
/** 上下文传递模式 */
|
|
155
185
|
context: DelegationContextMode;
|
|
@@ -194,6 +224,8 @@ export interface DelegateResult {
|
|
|
194
224
|
export interface AgentHandle {
|
|
195
225
|
/** 解析出的 agentId */
|
|
196
226
|
agentId: string;
|
|
227
|
+
/** 目标 agent 归属租户(§8 委派限本租户的执行点);缺省 = DEFAULT 存量域 */
|
|
228
|
+
tenantId?: string;
|
|
197
229
|
/** 特质标签(供调用方核对是否命中意图) */
|
|
198
230
|
traits: string[];
|
|
199
231
|
/** 被委派时的权利天花板(D3:只能收紧) */
|
|
@@ -45,6 +45,28 @@ export const DELEGATION_ACTIVE_STATUSES = ['queued', 'running'];
|
|
|
45
45
|
export function isActiveDelegationStatus(status) {
|
|
46
46
|
return DELEGATION_ACTIVE_STATUSES.includes(status);
|
|
47
47
|
}
|
|
48
|
+
/** 自动返回通知(`<delegation_result>`)`<output>` 默认截断上限(chars)。
|
|
49
|
+
* B 方案(2026-11-09 拍板):默认 16k,可按委派 `max_output_chars` 覆盖;
|
|
50
|
+
* 只影响自动送达 notice,`delegate_get` 全文取回不受此限。 */
|
|
51
|
+
export const DEFAULT_DELEGATION_OUTPUT_CHARS = 16_000;
|
|
52
|
+
/**
|
|
53
|
+
* 校验/归一化自动返回截断上限(单源;`DelegationStore.create` 唯一写入口消费)。
|
|
54
|
+
*
|
|
55
|
+
* fail loud:非法值(非有限数 / 非正整数)直接抛错,不静默丢结果也不静默禁用截断
|
|
56
|
+
* (NaN 会产出空 `<output>`、负数丢尾部、Infinity 关闭截断——2026-11-09 评审 M2 实测)。
|
|
57
|
+
*
|
|
58
|
+
* @param value - 待校验上限(chars);undefined = 未指定(渲染侧回落默认)
|
|
59
|
+
* @returns 归一化后的上限(undefined = 未指定)
|
|
60
|
+
* @throws 非有限数、非正整数
|
|
61
|
+
*/
|
|
62
|
+
export function normalizeMaxOutputChars(value) {
|
|
63
|
+
if (value === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) {
|
|
66
|
+
throw new Error(`maxOutputChars must be a positive integer (got ${value})`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
48
70
|
// ── 事件(§7) ──
|
|
49
71
|
/**
|
|
50
72
|
* 委派事件常量。
|
|
@@ -101,6 +101,7 @@ export function createDelegationRuntime(options) {
|
|
|
101
101
|
id: agent.agentId,
|
|
102
102
|
name: agent.agentId,
|
|
103
103
|
traits: agent.traits ?? [],
|
|
104
|
+
...(agent.tenantId === undefined ? {} : { tenantId: agent.tenantId }),
|
|
104
105
|
delegation: effectiveDelegationPolicy(agent.delegation),
|
|
105
106
|
status: 'idle',
|
|
106
107
|
});
|
|
@@ -118,8 +119,18 @@ export function createDelegationRuntime(options) {
|
|
|
118
119
|
if (!sessionId)
|
|
119
120
|
return [];
|
|
120
121
|
const hint = service.renderStatusHint(sessionId);
|
|
122
|
+
// B0/引擎提示范式:engineHint 载体(user 形态),不进 provider system 字段——
|
|
123
|
+
// role:'system' 会被适配层拼进 system 前缀,状态翻转即整段重买(§1 烧缓存实锤)。
|
|
121
124
|
return hint
|
|
122
|
-
? [
|
|
125
|
+
? [
|
|
126
|
+
{
|
|
127
|
+
role: 'user',
|
|
128
|
+
content: hint,
|
|
129
|
+
timestamp: Date.now(),
|
|
130
|
+
ephemeral: true,
|
|
131
|
+
metadata: { source: 'engineHint' },
|
|
132
|
+
},
|
|
133
|
+
]
|
|
123
134
|
: [];
|
|
124
135
|
});
|
|
125
136
|
}
|
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DefaultBudgetAllocator —
|
|
2
|
+
* DefaultBudgetAllocator — 不变量驱动的预算分配
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* - 系统提示词
|
|
6
|
-
* - 工具定义
|
|
7
|
-
* - 消息历史
|
|
8
|
-
* - 模型输出预留
|
|
4
|
+
* 唯一硬不变量(provider 侧事实):
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* input_tokens + max_tokens ≤ contextWindow
|
|
7
|
+
*
|
|
8
|
+
* 因此分配顺序是「先扣输出,再扣固定开销,剩下的才是消息」:
|
|
9
|
+
*
|
|
10
|
+
* outputReserve = maxOutputTokens(模型能力上限;未知时比例回退)
|
|
11
|
+
* inputLimit = effectiveLimit − outputReserve ← 硬
|
|
12
|
+
* messagesLimit = inputLimit − system − tools − 信封 ← 硬(强制点用它)
|
|
13
|
+
* messagesBudget= messagesLimit ← 软(压缩策略提示)
|
|
14
|
+
*
|
|
15
|
+
* 历史实现的缺陷(本次修正):`outputReserve = clamp(window × 20%, 2k, 8k)`
|
|
16
|
+
* 与请求真实的 `max_tokens` 完全脱节——mimo-v2.6-pro(窗口 1,048,576 /
|
|
17
|
+
* maxTokens 131,072)会算出 1,040,076 的输入上限,加上 131,072 输出共
|
|
18
|
+
* 1,171,148,超出窗口 122,572,且无任何环节察觉。
|
|
14
19
|
*/
|
|
15
20
|
import type { BudgetAllocator, BudgetAllocateParams, BudgetAllocateResult } from './types.js';
|
|
16
21
|
export declare class DefaultBudgetAllocator implements BudgetAllocator {
|
|
17
22
|
private outputRatio;
|
|
18
23
|
private minOutputReserve;
|
|
19
24
|
private maxOutputReserve;
|
|
20
|
-
private
|
|
25
|
+
private requestEnvelopeTokens;
|
|
21
26
|
constructor(options?: {
|
|
22
27
|
outputRatio?: number;
|
|
23
28
|
minOutputReserve?: number;
|
|
24
29
|
maxOutputReserve?: number;
|
|
25
|
-
|
|
30
|
+
requestEnvelopeTokens?: number;
|
|
26
31
|
});
|
|
27
32
|
/**
|
|
28
33
|
* 分配 token 预算
|
|
29
34
|
*
|
|
30
|
-
* @param params -
|
|
31
|
-
* @returns
|
|
35
|
+
* @param params - 分配参数(窗口、模型输出上限、固定开销)
|
|
36
|
+
* @returns 硬上限(inputLimit / messagesLimit)、软目标(messagesBudget)与输出预留
|
|
32
37
|
*/
|
|
33
38
|
allocate(params: BudgetAllocateParams): BudgetAllocateResult;
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
40
|
+
* 解析输出预留
|
|
41
|
+
*
|
|
42
|
+
* 有模型输出上限时按**硬预留**(不变量要求,不得打折);缺失时按窗口比例回退。
|
|
36
43
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
44
|
+
* @param effectiveLimit - 实际可用上限
|
|
45
|
+
* @param maxOutputTokens - 模型单次输出上限(可选)
|
|
46
|
+
* @returns 输出预留 token 数
|
|
39
47
|
*/
|
|
40
|
-
private
|
|
48
|
+
private resolveOutputReserve;
|
|
41
49
|
}
|