@animalabs/agent-framework 0.22.1 → 0.22.3
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/README.md +4 -2
- package/dist/src/agent.d.ts +266 -28
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +539 -104
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.d.ts +41 -0
- package/dist/src/api/mcp-server-core.d.ts.map +1 -0
- package/dist/src/api/mcp-server-core.js +593 -0
- package/dist/src/api/mcp-server-core.js.map +1 -0
- package/dist/src/api/mcp-server.d.ts +2 -36
- package/dist/src/api/mcp-server.d.ts.map +1 -1
- package/dist/src/api/mcp-server.js +15 -595
- package/dist/src/api/mcp-server.js.map +1 -1
- package/dist/src/api/server.d.ts +9 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +55 -27
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/api/types.d.ts +10 -2
- package/dist/src/api/types.d.ts.map +1 -1
- package/dist/src/branch-names.d.ts +14 -0
- package/dist/src/branch-names.d.ts.map +1 -0
- package/dist/src/branch-names.js +22 -0
- package/dist/src/branch-names.js.map +1 -0
- package/dist/src/closest-names.d.ts +28 -0
- package/dist/src/closest-names.d.ts.map +1 -0
- package/dist/src/closest-names.js +98 -0
- package/dist/src/closest-names.js.map +1 -0
- package/dist/src/code-execution/py-runner.d.ts +16 -5
- package/dist/src/code-execution/py-runner.d.ts.map +1 -1
- package/dist/src/code-execution/py-runner.js +186 -74
- package/dist/src/code-execution/py-runner.js.map +1 -1
- package/dist/src/code-execution/runtime-py.d.ts.map +1 -1
- package/dist/src/code-execution/runtime-py.js +49 -3
- package/dist/src/code-execution/runtime-py.js.map +1 -1
- package/dist/src/code-execution/tool-definition.d.ts +12 -1
- package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
- package/dist/src/code-execution/tool-definition.js +21 -3
- package/dist/src/code-execution/tool-definition.js.map +1 -1
- package/dist/src/config-checks.d.ts +28 -0
- package/dist/src/config-checks.d.ts.map +1 -0
- package/dist/src/config-checks.js +52 -0
- package/dist/src/config-checks.js.map +1 -0
- package/dist/src/deadline-timer.d.ts +21 -0
- package/dist/src/deadline-timer.d.ts.map +1 -0
- package/dist/src/deadline-timer.js +43 -0
- package/dist/src/deadline-timer.js.map +1 -0
- package/dist/src/error-message.d.ts +30 -0
- package/dist/src/error-message.d.ts.map +1 -0
- package/dist/src/error-message.js +50 -0
- package/dist/src/error-message.js.map +1 -0
- package/dist/src/framework.d.ts +1212 -192
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +6686 -1835
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +8 -0
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +27 -3
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/gate-script.d.ts.map +1 -1
- package/dist/src/gate/gate-script.js.map +1 -1
- package/dist/src/index.d.ts +5 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/capability-grant.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +170 -13
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +499 -258
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.d.ts +21 -1
- package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.js +91 -30
- package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +19 -3
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +23 -8
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts +20 -0
- package/dist/src/mcpl/convert-block.d.ts.map +1 -0
- package/dist/src/mcpl/convert-block.js +89 -0
- package/dist/src/mcpl/convert-block.js.map +1 -0
- package/dist/src/mcpl/errors.d.ts +13 -0
- package/dist/src/mcpl/errors.d.ts.map +1 -1
- package/dist/src/mcpl/errors.js +28 -0
- package/dist/src/mcpl/errors.js.map +1 -1
- package/dist/src/mcpl/feature-set-manager.d.ts.map +1 -1
- package/dist/src/mcpl/feature-set-manager.js +4 -3
- package/dist/src/mcpl/feature-set-manager.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts +23 -0
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +83 -72
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +114 -0
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -0
- package/dist/src/mcpl/inbound-source.js +83 -0
- package/dist/src/mcpl/inbound-source.js.map +1 -0
- package/dist/src/mcpl/index.d.ts +3 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +3 -1
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +15 -11
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +153 -84
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/log-value.d.ts +54 -0
- package/dist/src/mcpl/log-value.d.ts.map +1 -0
- package/dist/src/mcpl/log-value.js +109 -0
- package/dist/src/mcpl/log-value.js.map +1 -0
- package/dist/src/mcpl/prose-stream-router.d.ts +6 -6
- package/dist/src/mcpl/prose-stream-router.d.ts.map +1 -1
- package/dist/src/mcpl/prose-stream-router.js +4 -4
- package/dist/src/mcpl/prose-stream-router.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +64 -7
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +121 -24
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +38 -8
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js +77 -78
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +14 -2
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +72 -30
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +49 -14
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +74 -21
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/refusal-lines.d.ts +37 -0
- package/dist/src/mcpl/refusal-lines.d.ts.map +1 -0
- package/dist/src/mcpl/refusal-lines.js +61 -0
- package/dist/src/mcpl/refusal-lines.js.map +1 -0
- package/dist/src/mcpl/scope-manager.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +107 -12
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +470 -139
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/server-registry.d.ts +10 -1
- package/dist/src/mcpl/server-registry.d.ts.map +1 -1
- package/dist/src/mcpl/server-registry.js +14 -3
- package/dist/src/mcpl/server-registry.js.map +1 -1
- package/dist/src/mcpl/skip-reply-wake.d.ts +36 -0
- package/dist/src/mcpl/skip-reply-wake.d.ts.map +1 -0
- package/dist/src/mcpl/skip-reply-wake.js +55 -0
- package/dist/src/mcpl/skip-reply-wake.js.map +1 -0
- package/dist/src/mcpl/tool-classes.d.ts +1 -1
- package/dist/src/mcpl/tool-classes.d.ts.map +1 -1
- package/dist/src/mcpl/tool-classes.js +3 -2
- package/dist/src/mcpl/tool-classes.js.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
- package/dist/src/mcpl/transport.d.ts +74 -7
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +209 -22
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +43 -28
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/mcpl/visible-content.d.ts +15 -0
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +25 -0
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +19 -1
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +54 -25
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/api/index.d.ts.map +1 -1
- package/dist/src/modules/api/index.js +1 -1
- package/dist/src/modules/api/index.js.map +1 -1
- package/dist/src/modules/discord/discord-js-client.d.ts +1 -0
- package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
- package/dist/src/modules/discord/discord-js-client.js +25 -9
- package/dist/src/modules/discord/discord-js-client.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts +29 -3
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +383 -145
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/discord/types.d.ts +14 -1
- package/dist/src/modules/discord/types.d.ts.map +1 -1
- package/dist/src/modules/health/index.d.ts.map +1 -1
- package/dist/src/modules/health/index.js +2 -1
- package/dist/src/modules/health/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +3 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +359 -127
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +28 -1
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +177 -32
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/unknown-tool.d.ts +10 -0
- package/dist/src/modules/unknown-tool.d.ts.map +1 -0
- package/dist/src/modules/unknown-tool.js +17 -0
- package/dist/src/modules/unknown-tool.js.map +1 -0
- package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
- package/dist/src/modules/workspace/branch-intent.js.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.d.ts +54 -6
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +93 -27
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +64 -6
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +291 -44
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +127 -27
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +821 -248
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +117 -15
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +436 -51
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +75 -8
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +576 -68
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +42 -3
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/modules/workspace/watcher.d.ts +7 -2
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js +28 -4
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/operator-log.d.ts.map +1 -1
- package/dist/src/operator-log.js.map +1 -1
- package/dist/src/prose-drafts.d.ts +240 -0
- package/dist/src/prose-drafts.d.ts.map +1 -0
- package/dist/src/prose-drafts.js +362 -0
- package/dist/src/prose-drafts.js.map +1 -0
- package/dist/src/prose-segments.d.ts +21 -2
- package/dist/src/prose-segments.d.ts.map +1 -1
- package/dist/src/prose-segments.js +46 -9
- package/dist/src/prose-segments.js.map +1 -1
- package/dist/src/provider-waits.d.ts.map +1 -1
- package/dist/src/provider-waits.js.map +1 -1
- package/dist/src/queue.d.ts.map +1 -1
- package/dist/src/record-journal.d.ts.map +1 -1
- package/dist/src/record-journal.js.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
- package/dist/src/recovery/offline-branch.d.ts +1 -0
- package/dist/src/recovery/offline-branch.d.ts.map +1 -1
- package/dist/src/recovery/offline-branch.js +32 -25
- package/dist/src/recovery/offline-branch.js.map +1 -1
- package/dist/src/recovery/recover-cli.js.map +1 -1
- package/dist/src/runtime/liveness-watchdog.d.ts.map +1 -1
- package/dist/src/runtime/liveness-watchdog.js.map +1 -1
- package/dist/src/safe-slice.d.ts +5 -1
- package/dist/src/safe-slice.d.ts.map +1 -1
- package/dist/src/safe-slice.js +9 -1
- package/dist/src/safe-slice.js.map +1 -1
- package/dist/src/shutdown.d.ts.map +1 -1
- package/dist/src/shutdown.js.map +1 -1
- package/dist/src/stored-removal.d.ts +73 -0
- package/dist/src/stored-removal.d.ts.map +1 -0
- package/dist/src/stored-removal.js +100 -0
- package/dist/src/stored-removal.js.map +1 -0
- package/dist/src/thinking-token-stamp.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts +87 -19
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +135 -32
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts +9 -0
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +257 -60
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +7 -10
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +32 -3
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +106 -19
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +25 -1
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +260 -65
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +1 -1
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/types/agent.d.ts +59 -11
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +17 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +31 -5
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/inference-log.d.ts +1 -1
- package/dist/src/types/inference-log.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +30 -7
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +151 -11
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/src/usage/usage-tracker.d.ts +5 -0
- package/dist/src/usage/usage-tracker.d.ts.map +1 -1
- package/dist/src/usage/usage-tracker.js +35 -8
- package/dist/src/usage/usage-tracker.js.map +1 -1
- package/package.json +10 -9
- package/src/agent.ts +572 -105
- package/src/api/mcp-server-core.ts +681 -0
- package/src/api/mcp-server.ts +16 -685
- package/src/api/server.ts +55 -30
- package/src/api/types.ts +10 -2
- package/src/branch-names.ts +19 -0
- package/src/closest-names.ts +94 -0
- package/src/code-execution/py-runner.ts +200 -76
- package/src/code-execution/runtime-py.ts +49 -3
- package/src/code-execution/tool-definition.ts +28 -4
- package/src/config-checks.ts +48 -0
- package/src/deadline-timer.ts +44 -0
- package/src/error-message.ts +48 -0
- package/src/framework.ts +7158 -1936
- package/src/gate/event-gate.ts +28 -3
- package/src/index.ts +12 -3
- package/src/mcpl/channel-registry.ts +615 -289
- package/src/mcpl/checkpoint-manager.ts +104 -29
- package/src/mcpl/conversation-router.ts +28 -8
- package/src/mcpl/convert-block.ts +97 -0
- package/src/mcpl/errors.ts +28 -0
- package/src/mcpl/feature-set-manager.ts +4 -3
- package/src/mcpl/hook-orchestrator.ts +84 -77
- package/src/mcpl/inbound-source.ts +156 -0
- package/src/mcpl/index.ts +10 -1
- package/src/mcpl/inference-router.ts +174 -99
- package/src/mcpl/log-value.ts +116 -0
- package/src/mcpl/prose-stream-router.ts +6 -6
- package/src/mcpl/push-coalescer.ts +124 -24
- package/src/mcpl/push-handler.ts +86 -84
- package/src/mcpl/reference-fetcher.ts +71 -26
- package/src/mcpl/references.ts +81 -22
- package/src/mcpl/refusal-lines.ts +59 -0
- package/src/mcpl/server-connection.ts +496 -142
- package/src/mcpl/server-registry.ts +15 -4
- package/src/mcpl/skip-reply-wake.ts +73 -0
- package/src/mcpl/tool-classes.ts +3 -2
- package/src/mcpl/transport.ts +219 -26
- package/src/mcpl/types.ts +18 -3
- package/src/mcpl/visible-content.ts +27 -0
- package/src/module-registry.ts +58 -23
- package/src/modules/api/index.ts +1 -1
- package/src/modules/discord/discord-js-client.ts +26 -10
- package/src/modules/discord/index.ts +395 -160
- package/src/modules/discord/types.ts +15 -2
- package/src/modules/health/index.ts +2 -1
- package/src/modules/history/index.ts +410 -120
- package/src/modules/history/semantic.ts +189 -32
- package/src/modules/unknown-tool.ts +16 -0
- package/src/modules/workspace/disk-agreement.ts +125 -21
- package/src/modules/workspace/effects.ts +279 -35
- package/src/modules/workspace/index.ts +841 -261
- package/src/modules/workspace/observe.ts +456 -56
- package/src/modules/workspace/reconcile.ts +688 -76
- package/src/modules/workspace/types.ts +41 -2
- package/src/modules/workspace/watcher.ts +27 -4
- package/src/prose-drafts.ts +481 -0
- package/src/prose-segments.ts +51 -8
- package/src/recovery/offline-branch.ts +36 -29
- package/src/safe-slice.ts +9 -1
- package/src/stored-removal.ts +126 -0
- package/src/tool-image-ledger.ts +153 -34
- package/src/tool-presentation.ts +224 -40
- package/src/tool-result-guard.ts +7 -8
- package/src/tool-result-history.ts +124 -20
- package/src/tune-out/coordinator.ts +259 -65
- package/src/types/agent.ts +59 -13
- package/src/types/events.ts +17 -0
- package/src/types/framework.ts +31 -5
- package/src/types/inference-log.ts +1 -1
- package/src/types/module.ts +31 -7
- package/src/types/trace.ts +158 -12
- package/src/usage/usage-tracker.ts +32 -8
- package/dist/test/activation-request-sanitize.test.d.ts +0 -2
- package/dist/test/activation-request-sanitize.test.d.ts.map +0 -1
- package/dist/test/activation-request-sanitize.test.js +0 -89
- package/dist/test/activation-request-sanitize.test.js.map +0 -1
- package/dist/test/agent-cache-ttl.test.d.ts +0 -2
- package/dist/test/agent-cache-ttl.test.d.ts.map +0 -1
- package/dist/test/agent-cache-ttl.test.js +0 -41
- package/dist/test/agent-cache-ttl.test.js.map +0 -1
- package/dist/test/agent-runtime-settings.test.d.ts +0 -2
- package/dist/test/agent-runtime-settings.test.d.ts.map +0 -1
- package/dist/test/agent-runtime-settings.test.js +0 -462
- package/dist/test/agent-runtime-settings.test.js.map +0 -1
- package/dist/test/api-admin-gate.test.d.ts +0 -2
- package/dist/test/api-admin-gate.test.d.ts.map +0 -1
- package/dist/test/api-admin-gate.test.js +0 -116
- package/dist/test/api-admin-gate.test.js.map +0 -1
- package/dist/test/assistant-persist-refusal.test.d.ts +0 -2
- package/dist/test/assistant-persist-refusal.test.d.ts.map +0 -1
- package/dist/test/assistant-persist-refusal.test.js +0 -63
- package/dist/test/assistant-persist-refusal.test.js.map +0 -1
- package/dist/test/batched-wake-locus.test.d.ts +0 -2
- package/dist/test/batched-wake-locus.test.d.ts.map +0 -1
- package/dist/test/batched-wake-locus.test.js +0 -166
- package/dist/test/batched-wake-locus.test.js.map +0 -1
- package/dist/test/busy-agent-scheduler.test.d.ts +0 -2
- package/dist/test/busy-agent-scheduler.test.d.ts.map +0 -1
- package/dist/test/busy-agent-scheduler.test.js +0 -92
- package/dist/test/busy-agent-scheduler.test.js.map +0 -1
- package/dist/test/channel-incoming-targeting.test.d.ts +0 -2
- package/dist/test/channel-incoming-targeting.test.d.ts.map +0 -1
- package/dist/test/channel-incoming-targeting.test.js +0 -81
- package/dist/test/channel-incoming-targeting.test.js.map +0 -1
- package/dist/test/channel-label-history.test.d.ts +0 -2
- package/dist/test/channel-label-history.test.d.ts.map +0 -1
- package/dist/test/channel-label-history.test.js +0 -424
- package/dist/test/channel-label-history.test.js.map +0 -1
- package/dist/test/channel-lifecycle-provenance.test.d.ts +0 -2
- package/dist/test/channel-lifecycle-provenance.test.d.ts.map +0 -1
- package/dist/test/channel-lifecycle-provenance.test.js +0 -47
- package/dist/test/channel-lifecycle-provenance.test.js.map +0 -1
- package/dist/test/channel-registry-routing.test.d.ts +0 -2
- package/dist/test/channel-registry-routing.test.d.ts.map +0 -1
- package/dist/test/channel-registry-routing.test.js +0 -446
- package/dist/test/channel-registry-routing.test.js.map +0 -1
- package/dist/test/channel-registry-typing.test.d.ts +0 -2
- package/dist/test/channel-registry-typing.test.d.ts.map +0 -1
- package/dist/test/channel-registry-typing.test.js +0 -91
- package/dist/test/channel-registry-typing.test.js.map +0 -1
- package/dist/test/channels-changed-respond-first.test.d.ts +0 -2
- package/dist/test/channels-changed-respond-first.test.d.ts.map +0 -1
- package/dist/test/channels-changed-respond-first.test.js +0 -74
- package/dist/test/channels-changed-respond-first.test.js.map +0 -1
- package/dist/test/checkpoint-attribution.test.d.ts +0 -2
- package/dist/test/checkpoint-attribution.test.d.ts.map +0 -1
- package/dist/test/checkpoint-attribution.test.js +0 -200
- package/dist/test/checkpoint-attribution.test.js.map +0 -1
- package/dist/test/code-execution.test.d.ts +0 -11
- package/dist/test/code-execution.test.d.ts.map +0 -1
- package/dist/test/code-execution.test.js +0 -1272
- package/dist/test/code-execution.test.js.map +0 -1
- package/dist/test/component-defaults.test.d.ts +0 -2
- package/dist/test/component-defaults.test.d.ts.map +0 -1
- package/dist/test/component-defaults.test.js +0 -54
- package/dist/test/component-defaults.test.js.map +0 -1
- package/dist/test/conversation-fork-injection-scoping.test.d.ts +0 -2
- package/dist/test/conversation-fork-injection-scoping.test.d.ts.map +0 -1
- package/dist/test/conversation-fork-injection-scoping.test.js +0 -200
- package/dist/test/conversation-fork-injection-scoping.test.js.map +0 -1
- package/dist/test/conversation-router.test.d.ts +0 -2
- package/dist/test/conversation-router.test.d.ts.map +0 -1
- package/dist/test/conversation-router.test.js +0 -174
- package/dist/test/conversation-router.test.js.map +0 -1
- package/dist/test/conversation-routing.test.d.ts +0 -7
- package/dist/test/conversation-routing.test.d.ts.map +0 -1
- package/dist/test/conversation-routing.test.js +0 -387
- package/dist/test/conversation-routing.test.js.map +0 -1
- package/dist/test/deferred-wake-integrity.test.d.ts +0 -29
- package/dist/test/deferred-wake-integrity.test.d.ts.map +0 -1
- package/dist/test/deferred-wake-integrity.test.js +0 -320
- package/dist/test/deferred-wake-integrity.test.js.map +0 -1
- package/dist/test/discord-awareness-outbox.test.d.ts +0 -2
- package/dist/test/discord-awareness-outbox.test.d.ts.map +0 -1
- package/dist/test/discord-awareness-outbox.test.js +0 -267
- package/dist/test/discord-awareness-outbox.test.js.map +0 -1
- package/dist/test/discord-history-delete-window.test.d.ts +0 -2
- package/dist/test/discord-history-delete-window.test.d.ts.map +0 -1
- package/dist/test/discord-history-delete-window.test.js +0 -81
- package/dist/test/discord-history-delete-window.test.js.map +0 -1
- package/dist/test/discord-history-sync.test.d.ts +0 -2
- package/dist/test/discord-history-sync.test.d.ts.map +0 -1
- package/dist/test/discord-history-sync.test.js +0 -56
- package/dist/test/discord-history-sync.test.js.map +0 -1
- package/dist/test/ephemeral-settle.test.d.ts +0 -2
- package/dist/test/ephemeral-settle.test.d.ts.map +0 -1
- package/dist/test/ephemeral-settle.test.js +0 -354
- package/dist/test/ephemeral-settle.test.js.map +0 -1
- package/dist/test/event-gate-passthrough.test.d.ts +0 -15
- package/dist/test/event-gate-passthrough.test.d.ts.map +0 -1
- package/dist/test/event-gate-passthrough.test.js +0 -289
- package/dist/test/event-gate-passthrough.test.js.map +0 -1
- package/dist/test/event-gate-policy-mutation.test.d.ts +0 -2
- package/dist/test/event-gate-policy-mutation.test.d.ts.map +0 -1
- package/dist/test/event-gate-policy-mutation.test.js +0 -137
- package/dist/test/event-gate-policy-mutation.test.js.map +0 -1
- package/dist/test/event-gate-rate-limit.test.d.ts +0 -2
- package/dist/test/event-gate-rate-limit.test.d.ts.map +0 -1
- package/dist/test/event-gate-rate-limit.test.js +0 -627
- package/dist/test/event-gate-rate-limit.test.js.map +0 -1
- package/dist/test/event-gate-script.test.d.ts +0 -2
- package/dist/test/event-gate-script.test.d.ts.map +0 -1
- package/dist/test/event-gate-script.test.js +0 -95
- package/dist/test/event-gate-script.test.js.map +0 -1
- package/dist/test/event-gate-selfwake.test.d.ts +0 -15
- package/dist/test/event-gate-selfwake.test.d.ts.map +0 -1
- package/dist/test/event-gate-selfwake.test.js +0 -125
- package/dist/test/event-gate-selfwake.test.js.map +0 -1
- package/dist/test/event-gate-tags.test.d.ts +0 -2
- package/dist/test/event-gate-tags.test.d.ts.map +0 -1
- package/dist/test/event-gate-tags.test.js +0 -76
- package/dist/test/event-gate-tags.test.js.map +0 -1
- package/dist/test/event-gate.test.d.ts +0 -2
- package/dist/test/event-gate.test.d.ts.map +0 -1
- package/dist/test/event-gate.test.js +0 -919
- package/dist/test/event-gate.test.js.map +0 -1
- package/dist/test/explicit-prose-routing.test.d.ts +0 -11
- package/dist/test/explicit-prose-routing.test.d.ts.map +0 -1
- package/dist/test/explicit-prose-routing.test.js +0 -1394
- package/dist/test/explicit-prose-routing.test.js.map +0 -1
- package/dist/test/framework.test.d.ts +0 -5
- package/dist/test/framework.test.d.ts.map +0 -1
- package/dist/test/framework.test.js +0 -1048
- package/dist/test/framework.test.js.map +0 -1
- package/dist/test/gather-context-timeout.test.d.ts +0 -2
- package/dist/test/gather-context-timeout.test.d.ts.map +0 -1
- package/dist/test/gather-context-timeout.test.js +0 -120
- package/dist/test/gather-context-timeout.test.js.map +0 -1
- package/dist/test/health-snapshot.test.d.ts +0 -2
- package/dist/test/health-snapshot.test.d.ts.map +0 -1
- package/dist/test/health-snapshot.test.js +0 -74
- package/dist/test/health-snapshot.test.js.map +0 -1
- package/dist/test/helpers/coalescing-fixture.d.ts +0 -72
- package/dist/test/helpers/coalescing-fixture.d.ts.map +0 -1
- package/dist/test/helpers/coalescing-fixture.js +0 -146
- package/dist/test/helpers/coalescing-fixture.js.map +0 -1
- package/dist/test/helpers/coalescing-kill-child.d.ts +0 -2
- package/dist/test/helpers/coalescing-kill-child.d.ts.map +0 -1
- package/dist/test/helpers/coalescing-kill-child.js +0 -24
- package/dist/test/helpers/coalescing-kill-child.js.map +0 -1
- package/dist/test/helpers/mock-membrane.d.ts +0 -53
- package/dist/test/helpers/mock-membrane.d.ts.map +0 -1
- package/dist/test/helpers/mock-membrane.js +0 -168
- package/dist/test/helpers/mock-membrane.js.map +0 -1
- package/dist/test/helpers/pytc-stop-rows.d.ts +0 -11
- package/dist/test/helpers/pytc-stop-rows.d.ts.map +0 -1
- package/dist/test/helpers/pytc-stop-rows.js +0 -143
- package/dist/test/helpers/pytc-stop-rows.js.map +0 -1
- package/dist/test/helpers/quiesce-crash-child.d.ts +0 -2
- package/dist/test/helpers/quiesce-crash-child.d.ts.map +0 -1
- package/dist/test/helpers/quiesce-crash-child.js +0 -156
- package/dist/test/helpers/quiesce-crash-child.js.map +0 -1
- package/dist/test/history-module-overview.test.d.ts +0 -2
- package/dist/test/history-module-overview.test.d.ts.map +0 -1
- package/dist/test/history-module-overview.test.js +0 -711
- package/dist/test/history-module-overview.test.js.map +0 -1
- package/dist/test/history-module-realstore.test.d.ts +0 -2
- package/dist/test/history-module-realstore.test.d.ts.map +0 -1
- package/dist/test/history-module-realstore.test.js +0 -363
- package/dist/test/history-module-realstore.test.js.map +0 -1
- package/dist/test/history-module-semantic.test.d.ts +0 -2
- package/dist/test/history-module-semantic.test.d.ts.map +0 -1
- package/dist/test/history-module-semantic.test.js +0 -213
- package/dist/test/history-module-semantic.test.js.map +0 -1
- package/dist/test/history-module-ux.test.d.ts +0 -2
- package/dist/test/history-module-ux.test.d.ts.map +0 -1
- package/dist/test/history-module-ux.test.js +0 -304
- package/dist/test/history-module-ux.test.js.map +0 -1
- package/dist/test/history-module.test.d.ts +0 -2
- package/dist/test/history-module.test.d.ts.map +0 -1
- package/dist/test/history-module.test.js +0 -619
- package/dist/test/history-module.test.js.map +0 -1
- package/dist/test/history-semantic-review-findings.test.d.ts +0 -2
- package/dist/test/history-semantic-review-findings.test.d.ts.map +0 -1
- package/dist/test/history-semantic-review-findings.test.js +0 -338
- package/dist/test/history-semantic-review-findings.test.js.map +0 -1
- package/dist/test/history-semantic-sync-converges.test.d.ts +0 -2
- package/dist/test/history-semantic-sync-converges.test.d.ts.map +0 -1
- package/dist/test/history-semantic-sync-converges.test.js +0 -109
- package/dist/test/history-semantic-sync-converges.test.js.map +0 -1
- package/dist/test/host-quiesce.test.d.ts +0 -2
- package/dist/test/host-quiesce.test.d.ts.map +0 -1
- package/dist/test/host-quiesce.test.js +0 -863
- package/dist/test/host-quiesce.test.js.map +0 -1
- package/dist/test/inference-exhaustion-rewind.test.d.ts +0 -2
- package/dist/test/inference-exhaustion-rewind.test.d.ts.map +0 -1
- package/dist/test/inference-exhaustion-rewind.test.js +0 -309
- package/dist/test/inference-exhaustion-rewind.test.js.map +0 -1
- package/dist/test/inference-failure-bounds.test.d.ts +0 -2
- package/dist/test/inference-failure-bounds.test.d.ts.map +0 -1
- package/dist/test/inference-failure-bounds.test.js +0 -1201
- package/dist/test/inference-failure-bounds.test.js.map +0 -1
- package/dist/test/inference-failure-observability.test.d.ts +0 -2
- package/dist/test/inference-failure-observability.test.d.ts.map +0 -1
- package/dist/test/inference-failure-observability.test.js +0 -84
- package/dist/test/inference-failure-observability.test.js.map +0 -1
- package/dist/test/journal-tool.test.d.ts +0 -2
- package/dist/test/journal-tool.test.d.ts.map +0 -1
- package/dist/test/journal-tool.test.js +0 -33
- package/dist/test/journal-tool.test.js.map +0 -1
- package/dist/test/kv-unified-open-flight-retry.test.d.ts +0 -2
- package/dist/test/kv-unified-open-flight-retry.test.d.ts.map +0 -1
- package/dist/test/kv-unified-open-flight-retry.test.js +0 -189
- package/dist/test/kv-unified-open-flight-retry.test.js.map +0 -1
- package/dist/test/kv-unified-wiring.test.d.ts +0 -2
- package/dist/test/kv-unified-wiring.test.d.ts.map +0 -1
- package/dist/test/kv-unified-wiring.test.js +0 -95
- package/dist/test/kv-unified-wiring.test.js.map +0 -1
- package/dist/test/late-events-after-stop.test.d.ts +0 -2
- package/dist/test/late-events-after-stop.test.d.ts.map +0 -1
- package/dist/test/late-events-after-stop.test.js +0 -122
- package/dist/test/late-events-after-stop.test.js.map +0 -1
- package/dist/test/liveness-watchdog.test.d.ts +0 -2
- package/dist/test/liveness-watchdog.test.d.ts.map +0 -1
- package/dist/test/liveness-watchdog.test.js +0 -94
- package/dist/test/liveness-watchdog.test.js.map +0 -1
- package/dist/test/machine-close-provenance.test.d.ts +0 -2
- package/dist/test/machine-close-provenance.test.d.ts.map +0 -1
- package/dist/test/machine-close-provenance.test.js +0 -116
- package/dist/test/machine-close-provenance.test.js.map +0 -1
- package/dist/test/maintenance-timer.test.d.ts +0 -2
- package/dist/test/maintenance-timer.test.d.ts.map +0 -1
- package/dist/test/maintenance-timer.test.js +0 -265
- package/dist/test/maintenance-timer.test.js.map +0 -1
- package/dist/test/mcpl-access-provider.test.d.ts +0 -2
- package/dist/test/mcpl-access-provider.test.d.ts.map +0 -1
- package/dist/test/mcpl-access-provider.test.js +0 -20
- package/dist/test/mcpl-access-provider.test.js.map +0 -1
- package/dist/test/mcpl-awareness-barrier.test.d.ts +0 -2
- package/dist/test/mcpl-awareness-barrier.test.d.ts.map +0 -1
- package/dist/test/mcpl-awareness-barrier.test.js +0 -769
- package/dist/test/mcpl-awareness-barrier.test.js.map +0 -1
- package/dist/test/mcpl-capability-grant.test.d.ts +0 -10
- package/dist/test/mcpl-capability-grant.test.d.ts.map +0 -1
- package/dist/test/mcpl-capability-grant.test.js +0 -111
- package/dist/test/mcpl-capability-grant.test.js.map +0 -1
- package/dist/test/mcpl-capability-scoping.test.d.ts +0 -2
- package/dist/test/mcpl-capability-scoping.test.d.ts.map +0 -1
- package/dist/test/mcpl-capability-scoping.test.js +0 -266
- package/dist/test/mcpl-capability-scoping.test.js.map +0 -1
- package/dist/test/mcpl-child-env.test.d.ts +0 -2
- package/dist/test/mcpl-child-env.test.d.ts.map +0 -1
- package/dist/test/mcpl-child-env.test.js +0 -158
- package/dist/test/mcpl-child-env.test.js.map +0 -1
- package/dist/test/mcpl-coalescing.test.d.ts +0 -2
- package/dist/test/mcpl-coalescing.test.d.ts.map +0 -1
- package/dist/test/mcpl-coalescing.test.js +0 -1125
- package/dist/test/mcpl-coalescing.test.js.map +0 -1
- package/dist/test/mcpl-config-diagnostics.test.d.ts +0 -2
- package/dist/test/mcpl-config-diagnostics.test.d.ts.map +0 -1
- package/dist/test/mcpl-config-diagnostics.test.js +0 -452
- package/dist/test/mcpl-config-diagnostics.test.js.map +0 -1
- package/dist/test/mcpl-empty-content.test.d.ts +0 -2
- package/dist/test/mcpl-empty-content.test.d.ts.map +0 -1
- package/dist/test/mcpl-empty-content.test.js +0 -368
- package/dist/test/mcpl-empty-content.test.js.map +0 -1
- package/dist/test/mcpl-gate-roundtrip.test.d.ts +0 -2
- package/dist/test/mcpl-gate-roundtrip.test.d.ts.map +0 -1
- package/dist/test/mcpl-gate-roundtrip.test.js +0 -285
- package/dist/test/mcpl-gate-roundtrip.test.js.map +0 -1
- package/dist/test/mcpl-list-status.test.d.ts +0 -2
- package/dist/test/mcpl-list-status.test.d.ts.map +0 -1
- package/dist/test/mcpl-list-status.test.js +0 -82
- package/dist/test/mcpl-list-status.test.js.map +0 -1
- package/dist/test/mcpl-manifest-changed.test.d.ts +0 -2
- package/dist/test/mcpl-manifest-changed.test.d.ts.map +0 -1
- package/dist/test/mcpl-manifest-changed.test.js +0 -178
- package/dist/test/mcpl-manifest-changed.test.js.map +0 -1
- package/dist/test/mcpl-push-convert.test.d.ts +0 -2
- package/dist/test/mcpl-push-convert.test.d.ts.map +0 -1
- package/dist/test/mcpl-push-convert.test.js +0 -42
- package/dist/test/mcpl-push-convert.test.js.map +0 -1
- package/dist/test/mcpl-reconnect-events.test.d.ts +0 -2
- package/dist/test/mcpl-reconnect-events.test.d.ts.map +0 -1
- package/dist/test/mcpl-reconnect-events.test.js +0 -144
- package/dist/test/mcpl-reconnect-events.test.js.map +0 -1
- package/dist/test/mcpl-reconnect-reregistration.test.d.ts +0 -2
- package/dist/test/mcpl-reconnect-reregistration.test.d.ts.map +0 -1
- package/dist/test/mcpl-reconnect-reregistration.test.js +0 -236
- package/dist/test/mcpl-reconnect-reregistration.test.js.map +0 -1
- package/dist/test/mcpl-reference-fetcher.test.d.ts +0 -2
- package/dist/test/mcpl-reference-fetcher.test.d.ts.map +0 -1
- package/dist/test/mcpl-reference-fetcher.test.js +0 -427
- package/dist/test/mcpl-reference-fetcher.test.js.map +0 -1
- package/dist/test/mcpl-reference-fields.test.d.ts +0 -2
- package/dist/test/mcpl-reference-fields.test.d.ts.map +0 -1
- package/dist/test/mcpl-reference-fields.test.js +0 -149
- package/dist/test/mcpl-reference-fields.test.js.map +0 -1
- package/dist/test/mcpl-request-timeout.test.d.ts +0 -2
- package/dist/test/mcpl-request-timeout.test.d.ts.map +0 -1
- package/dist/test/mcpl-request-timeout.test.js +0 -138
- package/dist/test/mcpl-request-timeout.test.js.map +0 -1
- package/dist/test/mcpl-runtime-lifecycle.test.d.ts +0 -7
- package/dist/test/mcpl-runtime-lifecycle.test.d.ts.map +0 -1
- package/dist/test/mcpl-runtime-lifecycle.test.js +0 -142
- package/dist/test/mcpl-runtime-lifecycle.test.js.map +0 -1
- package/dist/test/mcpl-tool-class-listing.test.d.ts +0 -2
- package/dist/test/mcpl-tool-class-listing.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-class-listing.test.js +0 -147
- package/dist/test/mcpl-tool-class-listing.test.js.map +0 -1
- package/dist/test/mcpl-tool-classes.test.d.ts +0 -7
- package/dist/test/mcpl-tool-classes.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-classes.test.js +0 -80
- package/dist/test/mcpl-tool-classes.test.js.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-e2e.test.d.ts +0 -2
- package/dist/test/mcpl-tool-lifecycle-e2e.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-e2e.test.js +0 -237
- package/dist/test/mcpl-tool-lifecycle-e2e.test.js.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-emitter.test.d.ts +0 -11
- package/dist/test/mcpl-tool-lifecycle-emitter.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-emitter.test.js +0 -412
- package/dist/test/mcpl-tool-lifecycle-emitter.test.js.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-script.test.d.ts +0 -2
- package/dist/test/mcpl-tool-lifecycle-script.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-lifecycle-script.test.js +0 -288
- package/dist/test/mcpl-tool-lifecycle-script.test.js.map +0 -1
- package/dist/test/mcpl-tool-lifecycle.test.d.ts +0 -11
- package/dist/test/mcpl-tool-lifecycle.test.d.ts.map +0 -1
- package/dist/test/mcpl-tool-lifecycle.test.js +0 -270
- package/dist/test/mcpl-tool-lifecycle.test.js.map +0 -1
- package/dist/test/mcpl-ws-transport.test.d.ts +0 -2
- package/dist/test/mcpl-ws-transport.test.d.ts.map +0 -1
- package/dist/test/mcpl-ws-transport.test.js +0 -258
- package/dist/test/mcpl-ws-transport.test.js.map +0 -1
- package/dist/test/module-context-integration.test.d.ts +0 -18
- package/dist/test/module-context-integration.test.d.ts.map +0 -1
- package/dist/test/module-context-integration.test.js +0 -181
- package/dist/test/module-context-integration.test.js.map +0 -1
- package/dist/test/offline-recovery-branch.test.d.ts +0 -2
- package/dist/test/offline-recovery-branch.test.d.ts.map +0 -1
- package/dist/test/offline-recovery-branch.test.js +0 -226
- package/dist/test/offline-recovery-branch.test.js.map +0 -1
- package/dist/test/operator-surgery.test.d.ts +0 -2
- package/dist/test/operator-surgery.test.d.ts.map +0 -1
- package/dist/test/operator-surgery.test.js +0 -398
- package/dist/test/operator-surgery.test.js.map +0 -1
- package/dist/test/ops-alert.test.d.ts +0 -2
- package/dist/test/ops-alert.test.d.ts.map +0 -1
- package/dist/test/ops-alert.test.js +0 -153
- package/dist/test/ops-alert.test.js.map +0 -1
- package/dist/test/overbudget-drain-breaker.test.d.ts +0 -2
- package/dist/test/overbudget-drain-breaker.test.d.ts.map +0 -1
- package/dist/test/overbudget-drain-breaker.test.js +0 -197
- package/dist/test/overbudget-drain-breaker.test.js.map +0 -1
- package/dist/test/per-agent-delivery.test.d.ts +0 -2
- package/dist/test/per-agent-delivery.test.d.ts.map +0 -1
- package/dist/test/per-agent-delivery.test.js +0 -108
- package/dist/test/per-agent-delivery.test.js.map +0 -1
- package/dist/test/physical-window-restart.test.d.ts +0 -14
- package/dist/test/physical-window-restart.test.d.ts.map +0 -1
- package/dist/test/physical-window-restart.test.js +0 -222
- package/dist/test/physical-window-restart.test.js.map +0 -1
- package/dist/test/placed-reaction-baseline.test.d.ts +0 -2
- package/dist/test/placed-reaction-baseline.test.d.ts.map +0 -1
- package/dist/test/placed-reaction-baseline.test.js +0 -312
- package/dist/test/placed-reaction-baseline.test.js.map +0 -1
- package/dist/test/present-while-acting.test.d.ts +0 -19
- package/dist/test/present-while-acting.test.d.ts.map +0 -1
- package/dist/test/present-while-acting.test.js +0 -706
- package/dist/test/present-while-acting.test.js.map +0 -1
- package/dist/test/prose-segments.test.d.ts +0 -2
- package/dist/test/prose-segments.test.d.ts.map +0 -1
- package/dist/test/prose-segments.test.js +0 -52
- package/dist/test/prose-segments.test.js.map +0 -1
- package/dist/test/prose-stream-router.test.d.ts +0 -2
- package/dist/test/prose-stream-router.test.d.ts.map +0 -1
- package/dist/test/prose-stream-router.test.js +0 -171
- package/dist/test/prose-stream-router.test.js.map +0 -1
- package/dist/test/provider-acceleration-cooldown.test.d.ts +0 -2
- package/dist/test/provider-acceleration-cooldown.test.d.ts.map +0 -1
- package/dist/test/provider-acceleration-cooldown.test.js +0 -435
- package/dist/test/provider-acceleration-cooldown.test.js.map +0 -1
- package/dist/test/provider-waits.test.d.ts +0 -2
- package/dist/test/provider-waits.test.d.ts.map +0 -1
- package/dist/test/provider-waits.test.js +0 -2196
- package/dist/test/provider-waits.test.js.map +0 -1
- package/dist/test/puppet-tool-call.test.d.ts +0 -2
- package/dist/test/puppet-tool-call.test.d.ts.map +0 -1
- package/dist/test/puppet-tool-call.test.js +0 -224
- package/dist/test/puppet-tool-call.test.js.map +0 -1
- package/dist/test/puppet-turn-reservation.test.d.ts +0 -2
- package/dist/test/puppet-turn-reservation.test.d.ts.map +0 -1
- package/dist/test/puppet-turn-reservation.test.js +0 -139
- package/dist/test/puppet-turn-reservation.test.js.map +0 -1
- package/dist/test/reaction-baseline-platform.test.d.ts +0 -2
- package/dist/test/reaction-baseline-platform.test.d.ts.map +0 -1
- package/dist/test/reaction-baseline-platform.test.js +0 -124
- package/dist/test/reaction-baseline-platform.test.js.map +0 -1
- package/dist/test/record-journal.test.d.ts +0 -6
- package/dist/test/record-journal.test.d.ts.map +0 -1
- package/dist/test/record-journal.test.js +0 -269
- package/dist/test/record-journal.test.js.map +0 -1
- package/dist/test/refusal-reaction-baseline.test.d.ts +0 -2
- package/dist/test/refusal-reaction-baseline.test.d.ts.map +0 -1
- package/dist/test/refusal-reaction-baseline.test.js +0 -81
- package/dist/test/refusal-reaction-baseline.test.js.map +0 -1
- package/dist/test/refusal-rewind.test.d.ts +0 -2
- package/dist/test/refusal-rewind.test.d.ts.map +0 -1
- package/dist/test/refusal-rewind.test.js +0 -108
- package/dist/test/refusal-rewind.test.js.map +0 -1
- package/dist/test/refusal-single-call.test.d.ts +0 -2
- package/dist/test/refusal-single-call.test.d.ts.map +0 -1
- package/dist/test/refusal-single-call.test.js +0 -177
- package/dist/test/refusal-single-call.test.js.map +0 -1
- package/dist/test/release-changelog.test.d.ts +0 -2
- package/dist/test/release-changelog.test.d.ts.map +0 -1
- package/dist/test/release-changelog.test.js +0 -159
- package/dist/test/release-changelog.test.js.map +0 -1
- package/dist/test/same-round-think-policy.test.d.ts +0 -2
- package/dist/test/same-round-think-policy.test.d.ts.map +0 -1
- package/dist/test/same-round-think-policy.test.js +0 -853
- package/dist/test/same-round-think-policy.test.js.map +0 -1
- package/dist/test/save-recent-image.test.d.ts +0 -26
- package/dist/test/save-recent-image.test.d.ts.map +0 -1
- package/dist/test/save-recent-image.test.js +0 -974
- package/dist/test/save-recent-image.test.js.map +0 -1
- package/dist/test/shutdown-errors.test.d.ts +0 -2
- package/dist/test/shutdown-errors.test.d.ts.map +0 -1
- package/dist/test/shutdown-errors.test.js +0 -662
- package/dist/test/shutdown-errors.test.js.map +0 -1
- package/dist/test/silent-heartbeat-rows.test.d.ts +0 -2
- package/dist/test/silent-heartbeat-rows.test.d.ts.map +0 -1
- package/dist/test/silent-heartbeat-rows.test.js +0 -451
- package/dist/test/silent-heartbeat-rows.test.js.map +0 -1
- package/dist/test/silent-heartbeat.test.d.ts +0 -2
- package/dist/test/silent-heartbeat.test.d.ts.map +0 -1
- package/dist/test/silent-heartbeat.test.js +0 -165
- package/dist/test/silent-heartbeat.test.js.map +0 -1
- package/dist/test/state-scaling-e2e.test.d.ts +0 -22
- package/dist/test/state-scaling-e2e.test.d.ts.map +0 -1
- package/dist/test/state-scaling-e2e.test.js +0 -206
- package/dist/test/state-scaling-e2e.test.js.map +0 -1
- package/dist/test/state-scaling.test.d.ts +0 -12
- package/dist/test/state-scaling.test.d.ts.map +0 -1
- package/dist/test/state-scaling.test.js +0 -251
- package/dist/test/state-scaling.test.js.map +0 -1
- package/dist/test/stop-with-work-in-flight.test.d.ts +0 -23
- package/dist/test/stop-with-work-in-flight.test.d.ts.map +0 -1
- package/dist/test/stop-with-work-in-flight.test.js +0 -672
- package/dist/test/stop-with-work-in-flight.test.js.map +0 -1
- package/dist/test/surgery-marks-receipt.test.d.ts +0 -2
- package/dist/test/surgery-marks-receipt.test.d.ts.map +0 -1
- package/dist/test/surgery-marks-receipt.test.js +0 -540
- package/dist/test/surgery-marks-receipt.test.js.map +0 -1
- package/dist/test/thinking-token-stamp.test.d.ts +0 -12
- package/dist/test/thinking-token-stamp.test.d.ts.map +0 -1
- package/dist/test/thinking-token-stamp.test.js +0 -129
- package/dist/test/thinking-token-stamp.test.js.map +0 -1
- package/dist/test/timezone.test.d.ts +0 -2
- package/dist/test/timezone.test.d.ts.map +0 -1
- package/dist/test/timezone.test.js +0 -18
- package/dist/test/timezone.test.js.map +0 -1
- package/dist/test/tool-batch-hook.test.d.ts +0 -8
- package/dist/test/tool-batch-hook.test.d.ts.map +0 -1
- package/dist/test/tool-batch-hook.test.js +0 -275
- package/dist/test/tool-batch-hook.test.js.map +0 -1
- package/dist/test/tool-policy.test.d.ts +0 -2
- package/dist/test/tool-policy.test.d.ts.map +0 -1
- package/dist/test/tool-policy.test.js +0 -51
- package/dist/test/tool-policy.test.js.map +0 -1
- package/dist/test/tool-presentation.test.d.ts +0 -2
- package/dist/test/tool-presentation.test.d.ts.map +0 -1
- package/dist/test/tool-presentation.test.js +0 -268
- package/dist/test/tool-presentation.test.js.map +0 -1
- package/dist/test/tool-result-content.test.d.ts +0 -2
- package/dist/test/tool-result-content.test.d.ts.map +0 -1
- package/dist/test/tool-result-content.test.js +0 -37
- package/dist/test/tool-result-content.test.js.map +0 -1
- package/dist/test/tool-result-guard.test.d.ts +0 -2
- package/dist/test/tool-result-guard.test.d.ts.map +0 -1
- package/dist/test/tool-result-guard.test.js +0 -3607
- package/dist/test/tool-result-guard.test.js.map +0 -1
- package/dist/test/tool-result-history.test.d.ts +0 -7
- package/dist/test/tool-result-history.test.d.ts.map +0 -1
- package/dist/test/tool-result-history.test.js +0 -156
- package/dist/test/tool-result-history.test.js.map +0 -1
- package/dist/test/tool-result-spill.test.d.ts +0 -13
- package/dist/test/tool-result-spill.test.d.ts.map +0 -1
- package/dist/test/tool-result-spill.test.js +0 -586
- package/dist/test/tool-result-spill.test.js.map +0 -1
- package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts +0 -2
- package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts.map +0 -1
- package/dist/test/tool-wrapper-prose-guard-integration.test.js +0 -485
- package/dist/test/tool-wrapper-prose-guard-integration.test.js.map +0 -1
- package/dist/test/tool-wrapper-prose-guard.test.d.ts +0 -2
- package/dist/test/tool-wrapper-prose-guard.test.d.ts.map +0 -1
- package/dist/test/tool-wrapper-prose-guard.test.js +0 -34
- package/dist/test/tool-wrapper-prose-guard.test.js.map +0 -1
- package/dist/test/tools-observe-parser-conformance.test.d.ts +0 -2
- package/dist/test/tools-observe-parser-conformance.test.d.ts.map +0 -1
- package/dist/test/tools-observe-parser-conformance.test.js +0 -129
- package/dist/test/tools-observe-parser-conformance.test.js.map +0 -1
- package/dist/test/trunk-channel-routing.test.d.ts +0 -19
- package/dist/test/trunk-channel-routing.test.d.ts.map +0 -1
- package/dist/test/trunk-channel-routing.test.js +0 -329
- package/dist/test/trunk-channel-routing.test.js.map +0 -1
- package/dist/test/tune-out-e2e.test.d.ts +0 -2
- package/dist/test/tune-out-e2e.test.d.ts.map +0 -1
- package/dist/test/tune-out-e2e.test.js +0 -142
- package/dist/test/tune-out-e2e.test.js.map +0 -1
- package/dist/test/tune-out-gate-composition.test.d.ts +0 -2
- package/dist/test/tune-out-gate-composition.test.d.ts.map +0 -1
- package/dist/test/tune-out-gate-composition.test.js +0 -221
- package/dist/test/tune-out-gate-composition.test.js.map +0 -1
- package/dist/test/tune-out-lifecycle.test.d.ts +0 -2
- package/dist/test/tune-out-lifecycle.test.d.ts.map +0 -1
- package/dist/test/tune-out-lifecycle.test.js +0 -121
- package/dist/test/tune-out-lifecycle.test.js.map +0 -1
- package/dist/test/turn-trigger-provenance.test.d.ts +0 -2
- package/dist/test/turn-trigger-provenance.test.d.ts.map +0 -1
- package/dist/test/turn-trigger-provenance.test.js +0 -137
- package/dist/test/turn-trigger-provenance.test.js.map +0 -1
- package/dist/test/unconvertible-tool-result.test.d.ts +0 -2
- package/dist/test/unconvertible-tool-result.test.d.ts.map +0 -1
- package/dist/test/unconvertible-tool-result.test.js +0 -358
- package/dist/test/unconvertible-tool-result.test.js.map +0 -1
- package/dist/test/usage-accounting.test.d.ts +0 -2
- package/dist/test/usage-accounting.test.d.ts.map +0 -1
- package/dist/test/usage-accounting.test.js +0 -13
- package/dist/test/usage-accounting.test.js.map +0 -1
- package/dist/test/usage-tracker.test.d.ts +0 -2
- package/dist/test/usage-tracker.test.d.ts.map +0 -1
- package/dist/test/usage-tracker.test.js +0 -129
- package/dist/test/usage-tracker.test.js.map +0 -1
- package/dist/test/utils-surface.test.d.ts +0 -2
- package/dist/test/utils-surface.test.d.ts.map +0 -1
- package/dist/test/utils-surface.test.js +0 -145
- package/dist/test/utils-surface.test.js.map +0 -1
- package/dist/test/workspace-branch-continuation.test.d.ts +0 -15
- package/dist/test/workspace-branch-continuation.test.d.ts.map +0 -1
- package/dist/test/workspace-branch-continuation.test.js +0 -183
- package/dist/test/workspace-branch-continuation.test.js.map +0 -1
- package/dist/test/workspace-materialize-freshness.test.d.ts +0 -16
- package/dist/test/workspace-materialize-freshness.test.d.ts.map +0 -1
- package/dist/test/workspace-materialize-freshness.test.js +0 -252
- package/dist/test/workspace-materialize-freshness.test.js.map +0 -1
- package/dist/test/workspace-path-containment.test.d.ts +0 -19
- package/dist/test/workspace-path-containment.test.d.ts.map +0 -1
- package/dist/test/workspace-path-containment.test.js +0 -91
- package/dist/test/workspace-path-containment.test.js.map +0 -1
- package/dist/test/workspace-read-file-from-disk.test.d.ts +0 -17
- package/dist/test/workspace-read-file-from-disk.test.d.ts.map +0 -1
- package/dist/test/workspace-read-file-from-disk.test.js +0 -174
- package/dist/test/workspace-read-file-from-disk.test.js.map +0 -1
- package/dist/test/workspace-read-image.test.d.ts +0 -2
- package/dist/test/workspace-read-image.test.d.ts.map +0 -1
- package/dist/test/workspace-read-image.test.js +0 -597
- package/dist/test/workspace-read-image.test.js.map +0 -1
- package/dist/test/workspace-read-text.test.d.ts +0 -2
- package/dist/test/workspace-read-text.test.d.ts.map +0 -1
- package/dist/test/workspace-read-text.test.js +0 -101
- package/dist/test/workspace-read-text.test.js.map +0 -1
- package/dist/test/workspace-restore-order.test.d.ts +0 -16
- package/dist/test/workspace-restore-order.test.d.ts.map +0 -1
- package/dist/test/workspace-restore-order.test.js +0 -140
- package/dist/test/workspace-restore-order.test.js.map +0 -1
- package/dist/test/workspace-three-way.test.d.ts +0 -12
- package/dist/test/workspace-three-way.test.d.ts.map +0 -1
- package/dist/test/workspace-three-way.test.js +0 -3194
- package/dist/test/workspace-three-way.test.js.map +0 -1
- package/dist/test/workspace-watcher.test.d.ts +0 -2
- package/dist/test/workspace-watcher.test.d.ts.map +0 -1
- package/dist/test/workspace-watcher.test.js +0 -281
- package/dist/test/workspace-watcher.test.js.map +0 -1
- package/dist/test/xml-round-persist.test.d.ts +0 -19
- package/dist/test/xml-round-persist.test.d.ts.map +0 -1
- package/dist/test/xml-round-persist.test.js +0 -235
- package/dist/test/xml-round-persist.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/src/agent.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { isAbortedResponse } from '@animalabs/membrane';
|
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import type { CacheWireReceipt, KvUnifiedRequestHooks } from './kv-unified-wire.js';
|
|
5
5
|
import { ToolResultGuard } from './tool-result-guard.js';
|
|
6
|
+
import { assertBooleanSetting, holdsSettings } from './config-checks.js';
|
|
6
7
|
import {
|
|
7
8
|
indexSilentTickRows,
|
|
8
9
|
separateSilentHeartbeatTicks,
|
|
@@ -20,6 +21,9 @@ import {
|
|
|
20
21
|
export interface ActivationRequestOptions {
|
|
21
22
|
/** The silent heartbeat tick this request answers, if any. */
|
|
22
23
|
silentHeartbeat?: SilentHeartbeatTick;
|
|
24
|
+
/** A request that will never be sent (a preview): compile it as a dry
|
|
25
|
+
* run (see `compileWithInjections` for what that leaves alone). */
|
|
26
|
+
dryRun?: boolean;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export interface StartStreamResult {
|
|
@@ -72,6 +76,53 @@ const DEFAULT_CONTEXT_BUDGET_TOKENS = 100_000;
|
|
|
72
76
|
const DEFAULT_TRANSITION_PACE_TOKENS = 16_000;
|
|
73
77
|
const DEFAULT_SAME_ROUND_THINK_TEXT_POLICY: SameRoundThinkTextPolicy = 'public';
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Refuse an agent config whose `promptCaching`, `toolResultGuard`,
|
|
81
|
+
* `toolWrapperProseGuard`, `thinking.enabled` or `refusalHandling.autoRewind`
|
|
82
|
+
* holds anything but true or false (assertBooleanSetting), or whose `thinking`
|
|
83
|
+
* or `refusalHandling` is anything but an object, null or false
|
|
84
|
+
* (holdsSettings). The constructor runs it first, so the rule holds wherever
|
|
85
|
+
* an Agent is built. `create()` also runs it for each of its agents before
|
|
86
|
+
* anything opens, and `createEphemeralAgent` before it reserves the name, so a
|
|
87
|
+
* refusal there leaves nothing behind. Membrane reads `thinking.enabled`, and
|
|
88
|
+
* the refusal is here because the setting is AgentConfig's.
|
|
89
|
+
*/
|
|
90
|
+
export function assertAgentSwitches(config: AgentConfig): void {
|
|
91
|
+
const agent = `Agent "${config.name}"`;
|
|
92
|
+
assertBooleanSetting(
|
|
93
|
+
`${agent} promptCaching`,
|
|
94
|
+
config.promptCaching,
|
|
95
|
+
'true or leaving it out marks requests for prompt caching, and false leaves the markers off, for transports that refuse them',
|
|
96
|
+
);
|
|
97
|
+
if (holdsSettings(`${agent} thinking`, config.thinking, '{ enabled: true }')) {
|
|
98
|
+
assertBooleanSetting(
|
|
99
|
+
`${agent} thinking.enabled`,
|
|
100
|
+
config.thinking.enabled,
|
|
101
|
+
'true asks the provider for extended thinking, and false or leaving it out doesn\'t',
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (holdsSettings(`${agent} refusalHandling`, config.refusalHandling, '{ autoRewind: true }')) {
|
|
105
|
+
assertBooleanSetting(
|
|
106
|
+
`${agent} refusalHandling.autoRewind`,
|
|
107
|
+
config.refusalHandling.autoRewind,
|
|
108
|
+
'true redacts the turn that tripped a refusal and runs again, up to maxRewinds times, ' +
|
|
109
|
+
'and false or leaving it out doesn\'t',
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
assertBooleanSetting(
|
|
113
|
+
`${agent} toolResultGuard`,
|
|
114
|
+
config.toolResultGuard,
|
|
115
|
+
'true turns on tool-output admission, with one guarded retry after a provider refusal, ' +
|
|
116
|
+
'and false or leaving it out doesn\'t',
|
|
117
|
+
);
|
|
118
|
+
assertBooleanSetting(
|
|
119
|
+
`${agent} toolWrapperProseGuard`,
|
|
120
|
+
config.toolWrapperProseGuard,
|
|
121
|
+
'true keeps a response whose whole prose is a tool-call-shaped wrapper from running or entering the agent\'s history, ' +
|
|
122
|
+
'and false or leaving it out doesn\'t',
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
75
126
|
/**
|
|
76
127
|
* An agent wraps a context manager and manages inference state.
|
|
77
128
|
*/
|
|
@@ -120,15 +171,38 @@ export class Agent {
|
|
|
120
171
|
* closure) so the next activation can close whatever its predecessor left
|
|
121
172
|
* open — see failOpenKvSubmissions. */
|
|
122
173
|
private kvOpenQueue: Array<{ submissionId: string; wireReceipt: CacheWireReceipt }> | null = null;
|
|
174
|
+
/** The current stream's fresh input so far, as membrane's usage event
|
|
175
|
+
* reports it (cumulative across the tool loop): what the maxStreamTokens
|
|
176
|
+
* budget checks. */
|
|
123
177
|
lastStreamInputTokens = 0;
|
|
124
|
-
/** Real
|
|
125
|
-
*
|
|
126
|
-
*
|
|
178
|
+
/** Real prompt size of the stream's latest provider call that reported a
|
|
179
|
+
* prompt, which is what the provider billed it: fresh + cache creation +
|
|
180
|
+
* cache read. A call that reports none leaves it as it was (see
|
|
181
|
+
* lastStreamUnreportedTokens). Membrane's usage events are cumulative, so
|
|
182
|
+
* this is the call's share of its event (cumulativeDelta): the whole event
|
|
183
|
+
* for a stream's first call, and the event's own value where a counter
|
|
184
|
+
* went back. THE window-shaped number — `lastStreamInputTokens` alone
|
|
185
|
+
* omits cached tokens, which are most of a warm stream's window. 0 until a
|
|
186
|
+
* call on this stream reports a prompt, and the physical-window
|
|
187
|
+
* projection runs only once one has. */
|
|
127
188
|
lastStreamRealInputTokens = 0;
|
|
128
|
-
/** Output tokens of the
|
|
129
|
-
*
|
|
130
|
-
*
|
|
189
|
+
/** Output tokens of the same call as lastStreamRealInputTokens, or
|
|
190
|
+
* maxTokens, the bound on them, when it reported none (a call that ends at
|
|
191
|
+
* a tool boundary wrote a tool_use, so a 0 is a count left unreported) —
|
|
192
|
+
* the prior round's generated thinking/text/tool_use, which becomes part
|
|
193
|
+
* of the NEXT round's input and so belongs in the physical-window
|
|
194
|
+
* projection. */
|
|
131
195
|
lastStreamOutputTokens = 0;
|
|
196
|
+
/** What the stream has grown by since the call lastStreamRealInputTokens
|
|
197
|
+
* describes, for the physical-window projection: the blocks appended at
|
|
198
|
+
* each boundary the stream continued past (counted only for an agent with
|
|
199
|
+
* physicalWindowTokens, whose projection is this field's one reader), and
|
|
200
|
+
* the output of each call that reported no prompt (its reported output,
|
|
201
|
+
* or maxTokens, the bound on it, when it reported none either). After
|
|
202
|
+
* calls that report no prompt, the next request holds the prompt and
|
|
203
|
+
* output of the call lastStreamRealInputTokens describes, plus this. 0 at
|
|
204
|
+
* stream start and whenever a call reports a prompt. */
|
|
205
|
+
lastStreamUnreportedTokens = 0;
|
|
132
206
|
maxStreamTokens: number;
|
|
133
207
|
/** Provider hard context cap (see AgentConfig.physicalWindowTokens). */
|
|
134
208
|
readonly physicalWindowTokens?: number;
|
|
@@ -141,7 +215,52 @@ export class Agent {
|
|
|
141
215
|
private readonly configuredTransitionPaceTokens?: number;
|
|
142
216
|
private readonly configuredSameRoundThinkTextPolicy?: SameRoundThinkTextPolicy;
|
|
143
217
|
private contextBudgetTargetTokens?: number;
|
|
144
|
-
private runtimeSettingsOverrides:
|
|
218
|
+
private runtimeSettingsOverrides: AgentRuntimeSettingsPatch = {};
|
|
219
|
+
/**
|
|
220
|
+
* Counts changes of the live budget (an update, a reset, a restore, a
|
|
221
|
+
* settle). A compile speaks for the budget it planned at only if the live
|
|
222
|
+
* budget didn't change while it ran, and what it showed stands only until
|
|
223
|
+
* the next change.
|
|
224
|
+
*/
|
|
225
|
+
private liveBudgetEpoch = 0;
|
|
226
|
+
/**
|
|
227
|
+
* Counts changes of the descent (each arm of one, the same target included,
|
|
228
|
+
* a reset, a cancel, a settle). A settle proves its target only to a
|
|
229
|
+
* compile that began under that same descent.
|
|
230
|
+
*/
|
|
231
|
+
private descentEpoch = 0;
|
|
232
|
+
/** The live budget the last compile planned at, whether it fit, and the live budget's epoch then. */
|
|
233
|
+
private lastCompiledBudget?: { budget: number; fit: boolean; epoch: number };
|
|
234
|
+
/** Counts compiles at the live budget as they start. */
|
|
235
|
+
private compilesStarted = 0;
|
|
236
|
+
/** The start numbers of the compiles at the live budget still running. */
|
|
237
|
+
private readonly compilesRunning = new Set<number>();
|
|
238
|
+
/**
|
|
239
|
+
* For each budget, the start of the latest-started compile that has ended
|
|
240
|
+
* there with a fit or a refusal, whether or not what it showed was
|
|
241
|
+
* credited. Of two compiles at one budget, the later-started one planned
|
|
242
|
+
* at the newer store, so an earlier-started one that ends after it is
|
|
243
|
+
* ignored. That rests on the context manager selecting at the start of
|
|
244
|
+
* `compile`, before anything it awaits, so start order is selection order;
|
|
245
|
+
* a context manager that awaits before its select breaks it. (Injections
|
|
246
|
+
* are added after the select, so compiles with and without them plan
|
|
247
|
+
* alike.) An entry is
|
|
248
|
+
* kept only while a compile that started before it is still running, the
|
|
249
|
+
* only kind it can turn away, so the map is empty whenever no compile
|
|
250
|
+
* runs.
|
|
251
|
+
*/
|
|
252
|
+
private readonly latestEndedStart = new Map<number, number>();
|
|
253
|
+
/** The last outcome the listener recorded; a failed record is told again, and so is any after a change. */
|
|
254
|
+
private recordedCompiledBudget?: { budget: number; fit: boolean; epoch: number };
|
|
255
|
+
/**
|
|
256
|
+
* A boot restore applied a proven budget below the live one at once. Until
|
|
257
|
+
* the budget is next written (an update that carries one, or a reset of
|
|
258
|
+
* it) or a compile at it fits, a refusal of a compile at it restores it
|
|
259
|
+
* paced instead.
|
|
260
|
+
*/
|
|
261
|
+
private restoredAtOnce = false;
|
|
262
|
+
/** Told when that changes (the framework records it beside the persisted budget). */
|
|
263
|
+
private compiledBudgetListener?: (budget: number, fit: boolean) => boolean;
|
|
145
264
|
private contextManager: ContextManager;
|
|
146
265
|
private membrane: Membrane;
|
|
147
266
|
|
|
@@ -150,6 +269,7 @@ export class Agent {
|
|
|
150
269
|
contextManager: ContextManager,
|
|
151
270
|
membrane: Membrane
|
|
152
271
|
) {
|
|
272
|
+
assertAgentSwitches(config);
|
|
153
273
|
this.name = config.name;
|
|
154
274
|
this.model = config.model;
|
|
155
275
|
this.systemPrompt = config.systemPrompt;
|
|
@@ -159,11 +279,11 @@ export class Agent {
|
|
|
159
279
|
this.temperature = config.temperature;
|
|
160
280
|
this.thinking = config.thinking;
|
|
161
281
|
this.refusalHandling = config.refusalHandling;
|
|
162
|
-
this.toolResultGuard = new ToolResultGuard(config.name, contextManager, config.toolResultGuard);
|
|
282
|
+
this.toolResultGuard = new ToolResultGuard(config.name, contextManager, config.toolResultGuard === true);
|
|
163
283
|
this.proseRouting = config.proseRouting ?? 'locus';
|
|
164
|
-
this.toolWrapperProseGuard = config.toolWrapperProseGuard
|
|
284
|
+
this.toolWrapperProseGuard = config.toolWrapperProseGuard === true;
|
|
165
285
|
this.cacheTtl = config.cacheTtl ?? '1h';
|
|
166
|
-
this.promptCaching = config.promptCaching
|
|
286
|
+
this.promptCaching = config.promptCaching !== false;
|
|
167
287
|
this.prefillUserMessage = config.prefillUserMessage;
|
|
168
288
|
this.providerParams = config.providerParams;
|
|
169
289
|
this.sameRoundThinkTextPolicy = config.sameRoundThinkTextPolicy;
|
|
@@ -280,10 +400,16 @@ export class Agent {
|
|
|
280
400
|
getRuntimeSettings(): AgentRuntimeSettingsSnapshot {
|
|
281
401
|
const hot = this.getHotContextSettings();
|
|
282
402
|
return {
|
|
403
|
+
// The budget it's set to: the override, where there is one. That is
|
|
404
|
+
// the target of a descent toward it, or else the live budget, except
|
|
405
|
+
// while it's kept unapplied: at boot (keepRuntimeSettings), or after a
|
|
406
|
+
// refused at-once budget couldn't be restored paced (compileAtLiveBudget).
|
|
283
407
|
contextBudgetTokens:
|
|
408
|
+
this.runtimeSettingsOverrides.contextBudgetTokens ??
|
|
284
409
|
this.contextBudgetTargetTokens ??
|
|
285
410
|
this.contextBudgetTokens ??
|
|
286
411
|
DEFAULT_CONTEXT_BUDGET_TOKENS,
|
|
412
|
+
effectiveContextBudgetTokens: this.contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS,
|
|
287
413
|
...(hot ? { tailTokens: hot.tailTokens } : {}),
|
|
288
414
|
...(hot?.transitionPaceTokens !== undefined
|
|
289
415
|
? { transitionPaceTokens: hot.transitionPaceTokens }
|
|
@@ -307,6 +433,179 @@ export class Agent {
|
|
|
307
433
|
return { ...this.runtimeSettingsOverrides };
|
|
308
434
|
}
|
|
309
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Set (or clear) the one listener told when a compile at the live budget
|
|
438
|
+
* comes out differently from the last: it fit at a budget the last one
|
|
439
|
+
* didn't plan at (after a settle, the target), or the context manager
|
|
440
|
+
* refused a budget the last one fit at.
|
|
441
|
+
*/
|
|
442
|
+
onContextBudgetCompiled(listener: ((budget: number, fit: boolean) => boolean) | undefined): void {
|
|
443
|
+
this.compiledBudgetListener = listener;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The live budget the last compile planned at and fit, if it fit and the
|
|
448
|
+
* live budget hasn't changed since.
|
|
449
|
+
*/
|
|
450
|
+
getProvenContextBudgetTokens(): number | undefined {
|
|
451
|
+
const last = this.lastCompiledBudget;
|
|
452
|
+
return last?.fit && last.epoch === this.liveBudgetEpoch ? last.budget : undefined;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Set the live budget and the descent target, counting a change of each.
|
|
457
|
+
* `armed` counts a descent armed here as a change even when its target is
|
|
458
|
+
* the one already set: a compile that began under the earlier arm isn't
|
|
459
|
+
* credited with this one's settle.
|
|
460
|
+
*/
|
|
461
|
+
private setContextBudget(budget: number | undefined, target: number | undefined, armed = false): void {
|
|
462
|
+
if (budget !== this.contextBudgetTokens) this.liveBudgetEpoch++;
|
|
463
|
+
if (armed || target !== this.contextBudgetTargetTokens) this.descentEpoch++;
|
|
464
|
+
this.contextBudgetTokens = budget;
|
|
465
|
+
this.contextBudgetTargetTokens = target;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Claim the place of the latest compile to end at `budget` for the one that
|
|
470
|
+
* started as the `started`th, and say whether it got it: a compile that
|
|
471
|
+
* started before one that has already ended there is ignored, whichever
|
|
472
|
+
* finishes last.
|
|
473
|
+
*/
|
|
474
|
+
private claimLatestAt(budget: number, started: number): boolean {
|
|
475
|
+
if (started < (this.latestEndedStart.get(budget) ?? 0)) return false;
|
|
476
|
+
this.latestEndedStart.set(budget, started);
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Note what a compile at `budget`, planned at the live budget's `epoch`,
|
|
482
|
+
* showed. It speaks for the live budget only if that hasn't changed since;
|
|
483
|
+
* the listener is told either way, so a refusal withdraws the record's
|
|
484
|
+
* marker for the budget it planned at whatever changed meanwhile.
|
|
485
|
+
*/
|
|
486
|
+
private noteCompiledBudget(budget: number, fit: boolean, epoch: number): void {
|
|
487
|
+
if (epoch === this.liveBudgetEpoch) this.lastCompiledBudget = { budget, fit, epoch };
|
|
488
|
+
const recorded = this.recordedCompiledBudget;
|
|
489
|
+
if (recorded?.budget === budget && recorded.fit === fit && recorded.epoch === epoch) return;
|
|
490
|
+
// A listener that couldn't record it returns false: nothing is assumed
|
|
491
|
+
// recorded then, so the next compile tells it again whatever it shows.
|
|
492
|
+
this.recordedCompiledBudget = this.compiledBudgetListener?.(budget, fit) !== false ? { budget, fit, epoch } : undefined;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/** Compile at the live budget (no explicit one), noting whether it fit. */
|
|
496
|
+
private async compileAtLiveBudget(compile: () => Promise<CompileResult>): Promise<CompileResult> {
|
|
497
|
+
const started = ++this.compilesStarted;
|
|
498
|
+
this.compilesRunning.add(started);
|
|
499
|
+
try {
|
|
500
|
+
return await this.compileAtLiveBudgetNoting(compile, started);
|
|
501
|
+
} finally {
|
|
502
|
+
this.compilesRunning.delete(started);
|
|
503
|
+
const earliest = Math.min(...this.compilesRunning);
|
|
504
|
+
for (const [budget, start] of this.latestEndedStart) {
|
|
505
|
+
if (start < earliest) this.latestEndedStart.delete(budget);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** The compile at the live budget that started as the `started`th, and what it showed. */
|
|
511
|
+
private async compileAtLiveBudgetNoting(compile: () => Promise<CompileResult>, started: number): Promise<CompileResult> {
|
|
512
|
+
// The budget this compile plans at, and the descent under way when it
|
|
513
|
+
// started: a change of either while it runs is no part of what it shows.
|
|
514
|
+
const live = this.contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS;
|
|
515
|
+
const epoch = this.liveBudgetEpoch;
|
|
516
|
+
const descent = this.descentEpoch;
|
|
517
|
+
let result: CompileResult;
|
|
518
|
+
try {
|
|
519
|
+
result = await compile();
|
|
520
|
+
} catch (error) {
|
|
521
|
+
if ((error as { name?: unknown } | null)?.name !== 'OverBudgetError') throw error;
|
|
522
|
+
// A refusal shows the budget it planned at doesn't fit, whatever
|
|
523
|
+
// changed while it ran: the record's marker for it is withdrawn, and
|
|
524
|
+
// nothing is credited, unless a compile that started later has already
|
|
525
|
+
// ended at that budget.
|
|
526
|
+
if (this.claimLatestAt(live, started)) this.noteCompiledBudget(live, false, epoch);
|
|
527
|
+
// A budget a boot restore applied at once, refused at its first test,
|
|
528
|
+
// before anything wrote the budget: restore it paced instead, as the
|
|
529
|
+
// boot would have without its proof, and compile again from the
|
|
530
|
+
// recipe's budget. (While restoredAtOnce holds, the live budget is the
|
|
531
|
+
// one the boot applied: every write of the budget clears it, and no
|
|
532
|
+
// compile runs before the boot's restore.)
|
|
533
|
+
if (!this.restoredAtOnce) throw error;
|
|
534
|
+
this.restoredAtOnce = false;
|
|
535
|
+
// The persisted budget stays in the overrides, so if it can't be
|
|
536
|
+
// restored paced, no later write erases it.
|
|
537
|
+
this.setContextBudget(this.configuredContextBudgetTokens, undefined);
|
|
538
|
+
let outcome: string;
|
|
539
|
+
try {
|
|
540
|
+
this.updateRuntimeSettings({ contextBudgetTokens: live });
|
|
541
|
+
outcome = 'restored it as a paced descent from the recipe\'s budget';
|
|
542
|
+
} catch (fallback) {
|
|
543
|
+
outcome = `couldn't restore it paced (${fallback instanceof Error ? fallback.message : String(fallback)}), ` +
|
|
544
|
+
`so it compiles at the recipe's budget, with contextBudgetTokens=${live} kept set`;
|
|
545
|
+
}
|
|
546
|
+
console.error(
|
|
547
|
+
`[agent-settings] ${this.name}: the context manager refused contextBudgetTokens=${live}, which the boot ` +
|
|
548
|
+
`applied at once; ${outcome}`,
|
|
549
|
+
);
|
|
550
|
+
return this.compileAtLiveBudget(compile);
|
|
551
|
+
}
|
|
552
|
+
this.restoredAtOnce = false;
|
|
553
|
+
// A settle, here, of the descent this compile began under proves its
|
|
554
|
+
// target: the frontier fits the window prepared for it. Without a settle,
|
|
555
|
+
// the compile proves the budget it planned at. Either only if the live
|
|
556
|
+
// budget didn't change while it ran; a settle of a descent armed while it
|
|
557
|
+
// ran proves nothing (the next compile at the target does).
|
|
558
|
+
// A compile that ends here with a fit takes its place in the start order
|
|
559
|
+
// at the budget it planned at, credited or not; a settle credits its
|
|
560
|
+
// target only from the latest compile to end there.
|
|
561
|
+
const latest = this.claimLatestAt(live, started);
|
|
562
|
+
const sameLive = this.liveBudgetEpoch === epoch;
|
|
563
|
+
const sameDescent = this.descentEpoch === descent;
|
|
564
|
+
const settled = this.settleRuntimeSettingsTransition();
|
|
565
|
+
if (latest && sameLive && settled && sameDescent && this.claimLatestAt(this.contextBudgetTokens!, started)) {
|
|
566
|
+
this.noteCompiledBudget(this.contextBudgetTokens!, true, this.liveBudgetEpoch);
|
|
567
|
+
} else if (latest && sameLive && !settled) this.noteCompiledBudget(live, true, epoch);
|
|
568
|
+
return result;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The budget compiles plan at, the path a patch's budget takes from it, and
|
|
573
|
+
* whether a descent is in flight, from the agent's own state alone: what a
|
|
574
|
+
* runtime-settings preview can still say while the context manager refuses
|
|
575
|
+
* its queries.
|
|
576
|
+
* @internal For the framework's runtime-settings preview; not a host API.
|
|
577
|
+
*/
|
|
578
|
+
runtimeBudgetPath(patch?: AgentRuntimeSettingsPatch): {
|
|
579
|
+
liveBudgetTokens: number;
|
|
580
|
+
path: 'immediate' | 'paced' | 'none';
|
|
581
|
+
transition: 'stable' | 'converging';
|
|
582
|
+
} {
|
|
583
|
+
const live = this.contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS;
|
|
584
|
+
const budget = patch?.contextBudgetTokens;
|
|
585
|
+
return {
|
|
586
|
+
liveBudgetTokens: live,
|
|
587
|
+
path: budget === undefined ? 'none' : budget >= live || patch?.immediate ? 'immediate' : 'paced',
|
|
588
|
+
transition: this.contextBudgetTargetTokens === undefined ? 'stable' : 'converging',
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Whether the context manager answers its queries, as its readiness says.
|
|
594
|
+
* It refuses them while its strategy's initialization is pending or has
|
|
595
|
+
* failed, until a switchBranch or setStrategy succeeds, and a strategy can
|
|
596
|
+
* refuse its readiness on its own, as the autobiographical one does for a
|
|
597
|
+
* branch it hasn't reloaded.
|
|
598
|
+
* @internal For the framework's runtime-settings preview; not a host API.
|
|
599
|
+
*/
|
|
600
|
+
contextManagerAnswers(): boolean {
|
|
601
|
+
try {
|
|
602
|
+
this.contextManager.isReady();
|
|
603
|
+
return true;
|
|
604
|
+
} catch {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
310
609
|
/**
|
|
311
610
|
* Read-only mirror of `updateRuntimeSettings`' budget semantics: derive what
|
|
312
611
|
* the next compile would actually plan at if `patch` were applied, WITHOUT
|
|
@@ -323,11 +622,17 @@ export class Agent {
|
|
|
323
622
|
* - `path: 'none'` — patch absent or budget untouched.
|
|
324
623
|
*
|
|
325
624
|
* `overrides` uses strategy-config names (`recentWindowTokens`,
|
|
326
|
-
* `kvStableReachTokens`) suitable for `previewContext`.
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
625
|
+
* `kvStableReachTokens`) suitable for `previewContext`. The reach is the one
|
|
626
|
+
* the next compile plans at (context-manager's kv-stable picker): a
|
|
627
|
+
* descent's pace while a window is prepared for it, one this patch arms (a
|
|
628
|
+
* paced decrease) or one in flight that it leaves alone (a patch without a
|
|
629
|
+
* budget), and the configured reach otherwise. Config is a preview's only
|
|
630
|
+
* lever: `preparedWindowTokens` and the live runtime pace are strategy
|
|
631
|
+
* instance state, which a preview can't set. So a preview taken during a
|
|
632
|
+
* descent plans under that descent's prepared window, and at its live pace
|
|
633
|
+
* whenever the strategy carries one, which the picker reads before the
|
|
634
|
+
* configured reach. A boot restore's preflight never meets this: a new
|
|
635
|
+
* strategy has no window.
|
|
331
636
|
*/
|
|
332
637
|
planRuntimeSettings(patch?: AgentRuntimeSettingsPatch): {
|
|
333
638
|
effectiveBudgetTokens: number;
|
|
@@ -343,34 +648,33 @@ export class Agent {
|
|
|
343
648
|
this.validateRuntimeSettingsPatch(patch);
|
|
344
649
|
}
|
|
345
650
|
const hot = this.getHotContextSettings();
|
|
346
|
-
const live = this.
|
|
651
|
+
const { liveBudgetTokens: live, path } = this.runtimeBudgetPath(patch);
|
|
652
|
+
const budget = patch?.contextBudgetTokens;
|
|
347
653
|
|
|
348
654
|
const overrides: Record<string, unknown> = {};
|
|
349
655
|
if (patch?.tailTokens !== undefined) {
|
|
350
656
|
overrides.recentWindowTokens = patch.tailTokens;
|
|
351
657
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
658
|
+
// A window is prepared at the next compile when this patch arms a
|
|
659
|
+
// descent, or leaves one in flight alone; an immediate change clears it.
|
|
660
|
+
const prepared = hot !== null && (path === 'paced' || (path === 'none' && hot.preparedWindowTokens !== undefined));
|
|
661
|
+
const reach = prepared
|
|
662
|
+
? patch?.transitionPaceTokens ?? hot.transitionPaceTokens ?? DEFAULT_TRANSITION_PACE_TOKENS
|
|
663
|
+
: this.configuredTransitionPaceTokens;
|
|
664
|
+
if (reach !== undefined && reach !== this.configuredTransitionPaceTokens) {
|
|
665
|
+
overrides.kvStableReachTokens = reach;
|
|
357
666
|
}
|
|
358
667
|
|
|
359
|
-
if (
|
|
668
|
+
if (budget === undefined) {
|
|
360
669
|
return { effectiveBudgetTokens: live, liveBudgetTokens: live, path: 'none', overrides };
|
|
361
670
|
}
|
|
362
|
-
if (
|
|
363
|
-
return {
|
|
364
|
-
effectiveBudgetTokens: patch.contextBudgetTokens,
|
|
365
|
-
liveBudgetTokens: live,
|
|
366
|
-
path: 'immediate',
|
|
367
|
-
overrides,
|
|
368
|
-
};
|
|
671
|
+
if (path === 'immediate') {
|
|
672
|
+
return { effectiveBudgetTokens: budget, liveBudgetTokens: live, path, overrides };
|
|
369
673
|
}
|
|
370
674
|
return {
|
|
371
675
|
effectiveBudgetTokens: live,
|
|
372
676
|
liveBudgetTokens: live,
|
|
373
|
-
advisoryTargetTokens:
|
|
677
|
+
advisoryTargetTokens: budget,
|
|
374
678
|
path: 'paced',
|
|
375
679
|
overrides,
|
|
376
680
|
};
|
|
@@ -397,6 +701,8 @@ export class Agent {
|
|
|
397
701
|
let nextContextBudget = this.contextBudgetTokens;
|
|
398
702
|
let nextContextTarget = this.contextBudgetTargetTokens;
|
|
399
703
|
let appliedDefaultPace = false;
|
|
704
|
+
// A paced decrease arms a descent, even to the target already set.
|
|
705
|
+
let armed = false;
|
|
400
706
|
const hotPatch: {
|
|
401
707
|
tailTokens?: number;
|
|
402
708
|
transitionPaceTokens?: number | null;
|
|
@@ -428,21 +734,24 @@ export class Agent {
|
|
|
428
734
|
}
|
|
429
735
|
hotPatch.preparedWindowTokens = patch.contextBudgetTokens - this.maxTokens;
|
|
430
736
|
nextContextTarget = patch.contextBudgetTokens;
|
|
737
|
+
armed = true;
|
|
431
738
|
}
|
|
432
739
|
}
|
|
433
740
|
|
|
434
741
|
if (Object.keys(hotPatch).length > 0) {
|
|
435
742
|
this.updateHotContextSettings(hotPatch);
|
|
436
743
|
}
|
|
437
|
-
this.
|
|
438
|
-
|
|
744
|
+
this.setContextBudget(nextContextBudget, nextContextTarget, armed);
|
|
745
|
+
// A budget written here is a decision about it, whatever its value: the
|
|
746
|
+
// boot's at-once fallback (restoredAtOnce) no longer speaks for it.
|
|
747
|
+
if (patch.contextBudgetTokens !== undefined) this.restoredAtOnce = false;
|
|
439
748
|
if (appliedDefaultPace) {
|
|
440
749
|
this.runtimeSettingsOverrides.transitionPaceTokens = DEFAULT_TRANSITION_PACE_TOKENS;
|
|
441
750
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if (
|
|
751
|
+
// Only settings reach the override map: `immediate` is a mode for this
|
|
752
|
+
// apply, and nothing else a caller passes is a setting.
|
|
753
|
+
for (const key of ['contextBudgetTokens', 'tailTokens', 'transitionPaceTokens'] as const) {
|
|
754
|
+
if (patch[key] !== undefined) this.runtimeSettingsOverrides[key] = patch[key];
|
|
446
755
|
}
|
|
447
756
|
if (patch.sameRoundThinkTextPolicy !== undefined) {
|
|
448
757
|
this.runtimeSettingsOverrides.sameRoundThinkTextPolicy = patch.sameRoundThinkTextPolicy;
|
|
@@ -454,6 +763,8 @@ export class Agent {
|
|
|
454
763
|
const reset = new Set(keys ?? ['contextBudgetTokens', 'tailTokens', 'transitionPaceTokens', 'sameRoundThinkTextPolicy']);
|
|
455
764
|
let nextContextBudget = this.contextBudgetTokens;
|
|
456
765
|
let nextContextTarget = this.contextBudgetTargetTokens;
|
|
766
|
+
// A reset to a recipe budget below the live one arms a descent to it.
|
|
767
|
+
let armed = false;
|
|
457
768
|
const hotPatch: {
|
|
458
769
|
tailTokens?: number;
|
|
459
770
|
transitionPaceTokens?: number | null;
|
|
@@ -471,6 +782,7 @@ export class Agent {
|
|
|
471
782
|
hotPatch.transitionPaceTokens = DEFAULT_TRANSITION_PACE_TOKENS;
|
|
472
783
|
}
|
|
473
784
|
nextContextTarget = configured;
|
|
785
|
+
armed = true;
|
|
474
786
|
} else {
|
|
475
787
|
nextContextBudget = this.configuredContextBudgetTokens;
|
|
476
788
|
nextContextTarget = undefined;
|
|
@@ -487,9 +799,11 @@ export class Agent {
|
|
|
487
799
|
: this.configuredTransitionPaceTokens ?? null;
|
|
488
800
|
}
|
|
489
801
|
if (Object.keys(hotPatch).length > 0) this.updateHotContextSettings(hotPatch);
|
|
490
|
-
this.
|
|
491
|
-
|
|
492
|
-
|
|
802
|
+
this.setContextBudget(nextContextBudget, nextContextTarget, armed);
|
|
803
|
+
if (reset.has('contextBudgetTokens')) {
|
|
804
|
+
delete this.runtimeSettingsOverrides.contextBudgetTokens;
|
|
805
|
+
this.restoredAtOnce = false;
|
|
806
|
+
}
|
|
493
807
|
if (reset.has('tailTokens')) delete this.runtimeSettingsOverrides.tailTokens;
|
|
494
808
|
if (reset.has('transitionPaceTokens')) {
|
|
495
809
|
delete this.runtimeSettingsOverrides.transitionPaceTokens;
|
|
@@ -503,7 +817,7 @@ export class Agent {
|
|
|
503
817
|
cancelRuntimeSettingsTransition(): AgentRuntimeSettingsSnapshot {
|
|
504
818
|
if (this.contextBudgetTargetTokens !== undefined) {
|
|
505
819
|
this.updateHotContextSettings({ preparedWindowTokens: null });
|
|
506
|
-
this.
|
|
820
|
+
this.setContextBudget(this.contextBudgetTokens, undefined);
|
|
507
821
|
const live = this.contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS;
|
|
508
822
|
if (live === (this.configuredContextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS)) {
|
|
509
823
|
delete this.runtimeSettingsOverrides.contextBudgetTokens;
|
|
@@ -514,11 +828,56 @@ export class Agent {
|
|
|
514
828
|
return this.getRuntimeSettings();
|
|
515
829
|
}
|
|
516
830
|
|
|
517
|
-
|
|
518
|
-
|
|
831
|
+
/**
|
|
832
|
+
* Apply persisted settings at construction. `provenBudget` is a budget the
|
|
833
|
+
* caller has shown fits (the framework, from the record and a preflight),
|
|
834
|
+
* applied at once: it stands as the last compile's until a compile here
|
|
835
|
+
* says otherwise. When it's below the live budget, where the proof is what
|
|
836
|
+
* took the restore off the paced path, a refusal of a compile at it
|
|
837
|
+
* restores it paced instead, until the budget is next written or a compile
|
|
838
|
+
* at it fits. At or above the live budget, the restore is at once either
|
|
839
|
+
* way, and a refusal has nothing to fall back to.
|
|
840
|
+
*/
|
|
841
|
+
restoreRuntimeSettings(
|
|
842
|
+
settings: AgentRuntimeSettingsPatch,
|
|
843
|
+
opts?: { provenBudget?: number },
|
|
844
|
+
): AgentRuntimeSettingsSnapshot {
|
|
845
|
+
if (Object.keys(settings).length === 0) return this.getRuntimeSettings();
|
|
846
|
+
const live = this.contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS;
|
|
847
|
+
const snapshot = this.updateRuntimeSettings(settings);
|
|
848
|
+
if (opts?.provenBudget !== undefined) {
|
|
849
|
+
this.lastCompiledBudget = { budget: opts.provenBudget, fit: true, epoch: this.liveBudgetEpoch };
|
|
850
|
+
this.restoredAtOnce = opts.provenBudget < live;
|
|
851
|
+
}
|
|
852
|
+
return snapshot;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Keep a persisted budget, tail or pace that couldn't be applied at
|
|
857
|
+
* construction: it stays in the override map, unapplied, so a later
|
|
858
|
+
* persisting write keeps it in the record. A budget is reported as the one
|
|
859
|
+
* set (`contextBudgetTokens`) beside the one compiles plan at
|
|
860
|
+
* (`effectiveContextBudgetTokens`); a tail or pace stays the strategy's.
|
|
861
|
+
*/
|
|
862
|
+
keepRuntimeSettings(settings: Pick<AgentRuntimeSettingsPatch, 'contextBudgetTokens' | 'tailTokens' | 'transitionPaceTokens'>): void {
|
|
863
|
+
for (const key of ['contextBudgetTokens', 'tailTokens', 'transitionPaceTokens'] as const) {
|
|
864
|
+
if (settings[key] !== undefined) this.runtimeSettingsOverrides[key] = settings[key];
|
|
865
|
+
}
|
|
519
866
|
}
|
|
520
867
|
|
|
521
868
|
private validateRuntimeSettingsPatch(patch: AgentRuntimeSettingsPatch): void {
|
|
869
|
+
this.checkRuntimeSettingsPatch(patch);
|
|
870
|
+
if ((patch.tailTokens !== undefined || patch.transitionPaceTokens !== undefined) &&
|
|
871
|
+
!this.getHotContextSettings()) {
|
|
872
|
+
throw new Error('The active context strategy does not support live tail/transition settings');
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* The checks of a runtime-settings patch that need nothing from the context manager.
|
|
878
|
+
* @internal For the framework's runtime-settings preview; not a host API.
|
|
879
|
+
*/
|
|
880
|
+
checkRuntimeSettingsPatch(patch: AgentRuntimeSettingsPatch): void {
|
|
522
881
|
if (Object.keys(patch).length === 0) throw new Error('At least one setting is required');
|
|
523
882
|
if (patch.contextBudgetTokens !== undefined) {
|
|
524
883
|
if (!Number.isSafeInteger(patch.contextBudgetTokens) || patch.contextBudgetTokens <= this.maxTokens) {
|
|
@@ -538,37 +897,56 @@ export class Agent {
|
|
|
538
897
|
patch.sameRoundThinkTextPolicy !== 'private') {
|
|
539
898
|
throw new Error("sameRoundThinkTextPolicy must be 'public' or 'private'");
|
|
540
899
|
}
|
|
541
|
-
if ((patch.tailTokens !== undefined || patch.transitionPaceTokens !== undefined) &&
|
|
542
|
-
!this.getHotContextSettings()) {
|
|
543
|
-
throw new Error('The active context strategy does not support live tail/transition settings');
|
|
544
|
-
}
|
|
545
900
|
}
|
|
546
901
|
|
|
547
|
-
|
|
548
|
-
|
|
902
|
+
/** Settle a converging budget once the window is prepared; true if it settled. */
|
|
903
|
+
private settleRuntimeSettingsTransition(): boolean {
|
|
904
|
+
if (this.contextBudgetTargetTokens === undefined) return false;
|
|
549
905
|
const hot = this.getHotContextSettings();
|
|
550
|
-
if (!hot?.prepared) return;
|
|
551
|
-
this.
|
|
552
|
-
this.contextBudgetTargetTokens = undefined;
|
|
906
|
+
if (!hot?.prepared) return false;
|
|
907
|
+
this.setContextBudget(this.contextBudgetTargetTokens, undefined);
|
|
553
908
|
this.updateHotContextSettings({ preparedWindowTokens: null });
|
|
909
|
+
return true;
|
|
554
910
|
}
|
|
555
911
|
|
|
556
912
|
/**
|
|
557
913
|
* RFC-006 consumed watermark: the newest stored message at the last compile
|
|
558
|
-
* of a model request,
|
|
914
|
+
* of a model request, or at the last tool boundary that injected messages
|
|
915
|
+
* into a live one, per branch. Everything above it has never been in a
|
|
559
916
|
* request and may still be replaced or withdrawn in place by its sender.
|
|
560
917
|
*/
|
|
561
918
|
private consumedWatermark: { branch: string; sequence: number } | null = null;
|
|
919
|
+
/** Counts marks: a compile writes its watermark back only if no mark was
|
|
920
|
+
* made while it ran (a tool boundary's, or another compile's). */
|
|
921
|
+
private watermarkMarks = 0;
|
|
562
922
|
|
|
563
923
|
getConsumedWatermark(): { branch: string; sequence: number } | null {
|
|
564
924
|
return this.consumedWatermark;
|
|
565
925
|
}
|
|
566
926
|
|
|
567
|
-
/** Mark everything currently stored as consumed (
|
|
927
|
+
/** Mark everything currently stored as consumed (the agent's creation, at
|
|
928
|
+
* boot or later, and a tool boundary that injected messages into the live
|
|
929
|
+
* stream). */
|
|
568
930
|
markContextConsumed(): void {
|
|
569
931
|
// Tolerates partial context-manager doubles (tests build Agents over
|
|
570
932
|
// stubs): without a watermark nothing is ever treated as unread.
|
|
571
933
|
this.consumedWatermark = this.pendingWatermark();
|
|
934
|
+
this.watermarkMarks++;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* A finished compile's watermark, taken before it awaited. Within a branch
|
|
939
|
+
* the watermark only advances: if a mark was made while the compile ran,
|
|
940
|
+
* the compile's (older) one is applied only where it is later on that
|
|
941
|
+
* mark's branch, so a boundary's mark is never rolled back by a compile
|
|
942
|
+
* that started before it (a preview during a live turn).
|
|
943
|
+
*/
|
|
944
|
+
private applyCompileWatermark(watermark: { branch: string; sequence: number }, marksBefore: number): void {
|
|
945
|
+
const current = this.consumedWatermark;
|
|
946
|
+
if (this.watermarkMarks !== marksBefore && current
|
|
947
|
+
&& (current.branch !== watermark.branch || current.sequence >= watermark.sequence)) return;
|
|
948
|
+
this.consumedWatermark = watermark;
|
|
949
|
+
this.watermarkMarks++;
|
|
572
950
|
}
|
|
573
951
|
|
|
574
952
|
/** The watermark a successful compile will establish (taken before, applied after). */
|
|
@@ -591,32 +969,61 @@ export class Agent {
|
|
|
591
969
|
}
|
|
592
970
|
}
|
|
593
971
|
|
|
972
|
+
/** A committing compile, as for a request that is sent: the context
|
|
973
|
+
* manager commits what it commits for one, the consumed watermark moves,
|
|
974
|
+
* and a prepared budget change settles. To inspect what the agent would
|
|
975
|
+
* see, use the framework's `previewActivation`, which compiles as a dry
|
|
976
|
+
* run. */
|
|
594
977
|
async compileContext(budget?: TokenBudget): Promise<CompileResult> {
|
|
595
978
|
// RFC-006 §3.3: consumption is determined at assembly — a compile that
|
|
596
979
|
// fails assembled nothing, so the watermark moves only on success.
|
|
597
980
|
const watermark = this.pendingWatermark();
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
981
|
+
const marksBefore = this.watermarkMarks;
|
|
982
|
+
const compile = () => this.contextManager.compile(this.compileBudget(budget));
|
|
983
|
+
const result = budget ? await compile() : await this.compileAtLiveBudget(compile);
|
|
984
|
+
if (watermark) this.applyCompileWatermark(watermark, marksBefore);
|
|
601
985
|
return result;
|
|
602
986
|
}
|
|
603
987
|
|
|
604
988
|
/**
|
|
605
|
-
* Compile the context with injections.
|
|
606
|
-
*
|
|
607
|
-
*
|
|
989
|
+
* Compile the context with injections (e.g. from MCPL servers), which the
|
|
990
|
+
* context manager merges into the compiled messages. Without
|
|
991
|
+
* `opts.dryRun` it commits as `compileContext` does: the consumed
|
|
992
|
+
* watermark moves, and a compile at the live window settles a prepared
|
|
993
|
+
* budget change. With `opts.dryRun`, for a compile that will never be
|
|
994
|
+
* sent, it does neither (see below).
|
|
608
995
|
*/
|
|
609
996
|
async compileWithInjections(
|
|
610
997
|
budget?: TokenBudget,
|
|
611
998
|
injections?: ContextInjection[],
|
|
612
|
-
opts?: { kvUnifiedImmutablePrefixHash?: string },
|
|
999
|
+
opts?: { kvUnifiedImmutablePrefixHash?: string; dryRun?: boolean },
|
|
613
1000
|
): Promise<CompileResult> {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
)
|
|
618
|
-
|
|
619
|
-
|
|
1001
|
+
// A dry run is a compile that will never be sent. The context manager
|
|
1002
|
+
// persists no fold resolutions for it and queues none of the compression
|
|
1003
|
+
// or merge work its fold plan calls for. Its thinking binding
|
|
1004
|
+
// (context-manager#160, not yet released) will commit stamps and add a
|
|
1005
|
+
// compile awaiting acceptance for a committing compile only. Here nothing
|
|
1006
|
+
// moves either: the agent never read what a dry run assembled, so the
|
|
1007
|
+
// consumed watermark stays. A dry run proves nothing about the budget
|
|
1008
|
+
// either, so it goes straight to the compile, around
|
|
1009
|
+
// compileAtLiveBudget: it settles no descent (a prepared budget change
|
|
1010
|
+
// waits for the compile that is sent), notes no compiled budget, and
|
|
1011
|
+
// restores nothing the boot applied at once, whether it fits or is
|
|
1012
|
+
// refused.
|
|
1013
|
+
//
|
|
1014
|
+
// Context-manager 0.14 leaves what a select leaves behind as the last
|
|
1015
|
+
// committing compile left it, on every path out of a dry run, throws
|
|
1016
|
+
// included: no chunk record and no compression queued for a chunk the
|
|
1017
|
+
// dry run closes, no calibration, and none of the bookkeeping the next
|
|
1018
|
+
// compile or an observer reads (its `SelectOptions.dryRun` gives the
|
|
1019
|
+
// contract). The one thing a dry run can still leave is the release of a
|
|
1020
|
+
// compression hold whose deadline has passed, which `compile` does for
|
|
1021
|
+
// any compile before it selects.
|
|
1022
|
+
const watermark = opts?.dryRun ? null : this.pendingWatermark();
|
|
1023
|
+
const marksBefore = this.watermarkMarks;
|
|
1024
|
+
const compile = () => this.contextManager.compile(this.compileBudget(budget), injections, opts as never);
|
|
1025
|
+
const result = budget || opts?.dryRun ? await compile() : await this.compileAtLiveBudget(compile);
|
|
1026
|
+
if (watermark) this.applyCompileWatermark(watermark, marksBefore);
|
|
620
1027
|
return result;
|
|
621
1028
|
}
|
|
622
1029
|
|
|
@@ -692,15 +1099,8 @@ export class Agent {
|
|
|
692
1099
|
return {
|
|
693
1100
|
messages: this.toolResultGuard.prepareRequest(messages, true),
|
|
694
1101
|
system: this.buildSystemPrompt(systemInjections),
|
|
695
|
-
config: {
|
|
696
|
-
model: this.model,
|
|
697
|
-
maxTokens: this.maxTokens,
|
|
698
|
-
...(this.temperature !== undefined && { temperature: this.temperature }),
|
|
699
|
-
...(this.thinking !== undefined && { thinking: this.thinking }),
|
|
700
|
-
},
|
|
701
1102
|
tools: tools.length > 0 ? tools : undefined,
|
|
702
|
-
...
|
|
703
|
-
assistantParticipant: this.name,
|
|
1103
|
+
...this.requestSettings(),
|
|
704
1104
|
};
|
|
705
1105
|
};
|
|
706
1106
|
const request = await assemble();
|
|
@@ -780,7 +1180,12 @@ export class Agent {
|
|
|
780
1180
|
|
|
781
1181
|
// If all tools done, transition to ready
|
|
782
1182
|
if (this._state.pending.size === 0) {
|
|
783
|
-
this._state = {
|
|
1183
|
+
this._state = {
|
|
1184
|
+
status: 'ready',
|
|
1185
|
+
toolResults: this._state.completed,
|
|
1186
|
+
stream: this._state.stream,
|
|
1187
|
+
supportsInjectedMessages: this._state.supportsInjectedMessages,
|
|
1188
|
+
};
|
|
784
1189
|
}
|
|
785
1190
|
}
|
|
786
1191
|
|
|
@@ -799,12 +1204,18 @@ export class Agent {
|
|
|
799
1204
|
* Build the membrane-normalized request that WOULD be emitted for this
|
|
800
1205
|
* agent's next activation, given the supplied tools and injections.
|
|
801
1206
|
*
|
|
802
|
-
* This is the single source of truth for
|
|
803
|
-
* real activation path (`startStreamWithInjections`) and
|
|
804
|
-
* tooling (`Framework.previewActivation`). It
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
1207
|
+
* This is the single source of truth for a framework turn's request,
|
|
1208
|
+
* shared by the real activation path (`startStreamWithInjections`) and
|
|
1209
|
+
* debug/preview tooling (`Framework.previewActivation`). It does not call
|
|
1210
|
+
* the membrane. The direct API (`runInferenceWithInjections`) assembles its
|
|
1211
|
+
* own messages, system prompt and tools, and both take the agent's
|
|
1212
|
+
* settings from `requestSettings()`.
|
|
1213
|
+
* A compile that is sent commits what the context manager commits for it
|
|
1214
|
+
* (fold resolutions, the compression its fold plan calls for, the consumed
|
|
1215
|
+
* watermark); a preview passes `options.dryRun`, so its compile commits
|
|
1216
|
+
* none of that (see `compileWithInjections` for what a dry run still
|
|
1217
|
+
* leaves). Either way the context manager is handed the compression tool
|
|
1218
|
+
* definitions. Safe to call regardless of the agent's current status.
|
|
808
1219
|
* It doesn't wait for the tool-result guard's annotations, so a preview
|
|
809
1220
|
* never waits on a workspace write (rollback, undo and redo report one), and
|
|
810
1221
|
* may show a withheld stub before its place is added; the activation waits
|
|
@@ -845,7 +1256,12 @@ export class Agent {
|
|
|
845
1256
|
let { messages, systemInjections } = await this.compileWithInjections(
|
|
846
1257
|
budget,
|
|
847
1258
|
injections,
|
|
848
|
-
immutablePrefixHash
|
|
1259
|
+
immutablePrefixHash || options.dryRun
|
|
1260
|
+
? {
|
|
1261
|
+
...(immutablePrefixHash ? { kvUnifiedImmutablePrefixHash: immutablePrefixHash } : {}),
|
|
1262
|
+
...(options.dryRun ? { dryRun: true } : {}),
|
|
1263
|
+
}
|
|
1264
|
+
: undefined,
|
|
849
1265
|
);
|
|
850
1266
|
|
|
851
1267
|
// Sanitize: strip empty/whitespace text blocks and drop messages left with
|
|
@@ -897,15 +1313,30 @@ export class Agent {
|
|
|
897
1313
|
return {
|
|
898
1314
|
messages: this.toolResultGuard.prepareRequest(messages),
|
|
899
1315
|
system: this.buildSystemPrompt(systemInjections),
|
|
1316
|
+
tools: availableTools.length > 0 ? availableTools : undefined,
|
|
1317
|
+
...this.requestSettings(),
|
|
1318
|
+
...(kvUnified ? { cacheMarkers: 'cm-owned' as const } : {}),
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* The request fields that come from this agent's own settings: its model
|
|
1324
|
+
* config, prompt caching and cache TTL, prefill message, provider
|
|
1325
|
+
* parameters and participant name. Every request the agent sends takes
|
|
1326
|
+
* them from here, a framework turn's (buildActivationRequest) and the
|
|
1327
|
+
* direct API's (runInferenceWithInjections), so a setting reaches both or
|
|
1328
|
+
* neither.
|
|
1329
|
+
*/
|
|
1330
|
+
private requestSettings(): Pick<NormalizedRequest,
|
|
1331
|
+
'config' | 'promptCaching' | 'cacheTtl' | 'prefillUserMessage' | 'providerParams' | 'assistantParticipant'> {
|
|
1332
|
+
return {
|
|
900
1333
|
config: {
|
|
901
1334
|
model: this.model,
|
|
902
1335
|
maxTokens: this.maxTokens,
|
|
903
1336
|
...(this.temperature !== undefined && { temperature: this.temperature }),
|
|
904
1337
|
...(this.thinking !== undefined && { thinking: this.thinking }),
|
|
905
1338
|
},
|
|
906
|
-
tools: availableTools.length > 0 ? availableTools : undefined,
|
|
907
1339
|
promptCaching: this.promptCaching,
|
|
908
|
-
...(kvUnified ? { cacheMarkers: 'cm-owned' as const } : {}),
|
|
909
1340
|
cacheTtl: this.cacheTtl,
|
|
910
1341
|
...(this.prefillUserMessage && { prefillUserMessage: this.prefillUserMessage }),
|
|
911
1342
|
...(this.providerParams && { providerParams: this.providerParams }),
|
|
@@ -966,16 +1397,28 @@ export class Agent {
|
|
|
966
1397
|
this.failOpenKvSubmissions();
|
|
967
1398
|
|
|
968
1399
|
this._streamId++;
|
|
1400
|
+
// A pending cancel belongs to the stream that was live when cancelStream()
|
|
1401
|
+
// ran. The stream driver collects it on that stream's terminal event, or
|
|
1402
|
+
// at the loop's end when the iterator closed without one, while the
|
|
1403
|
+
// stream still owns the agent. This clear is for the records no driver
|
|
1404
|
+
// collects: a dropped turn's, whose stream no driver iterates; one whose
|
|
1405
|
+
// stream's terminal came after another stream took the agent; or a
|
|
1406
|
+
// cancel after the stream's complete event. A fresh stream must not
|
|
1407
|
+
// inherit one and read its own later error as a deliberate stop.
|
|
1408
|
+
this._pendingCancel = undefined;
|
|
969
1409
|
this._inferenceStartedAt = Date.now();
|
|
970
1410
|
this.lastStreamInputTokens = 0;
|
|
971
1411
|
// Reset the cache-inclusive counters too: a new stream must not inherit
|
|
972
1412
|
// the prior stream's window size — on the physical-window restart path
|
|
973
1413
|
// that inherited value IS the oversized number that caused the restart,
|
|
974
1414
|
// and projecting on it before this stream's first usage event would
|
|
975
|
-
// restart again (loop). The `> 0` guard downstream means "no
|
|
976
|
-
//
|
|
1415
|
+
// restart again (loop). The `> 0` guard downstream means "no call on
|
|
1416
|
+
// THIS stream has reported a prompt yet" only because of this reset (a
|
|
1417
|
+
// call that reports none leaves these as they were, and adds to
|
|
1418
|
+
// lastStreamUnreportedTokens instead).
|
|
977
1419
|
this.lastStreamRealInputTokens = 0;
|
|
978
1420
|
this.lastStreamOutputTokens = 0;
|
|
1421
|
+
this.lastStreamUnreportedTokens = 0;
|
|
979
1422
|
|
|
980
1423
|
// Compiled only once each withheld stub's annotation has finished,
|
|
981
1424
|
// including one that began during the compile, and after a stub edit that
|
|
@@ -1063,9 +1506,10 @@ export class Agent {
|
|
|
1063
1506
|
|
|
1064
1507
|
/**
|
|
1065
1508
|
* Transition to waiting_for_tools when stream yields tool calls.
|
|
1066
|
-
* Called by framework's driveStream
|
|
1509
|
+
* Called by framework's driveStream, with what the stream declared about
|
|
1510
|
+
* carrying injected messages with this round's results (see AgentState).
|
|
1067
1511
|
*/
|
|
1068
|
-
enterWaitingForTools(calls: ToolCall[], stream: YieldingStream): void {
|
|
1512
|
+
enterWaitingForTools(calls: ToolCall[], stream: YieldingStream, supportsInjectedMessages?: boolean): void {
|
|
1069
1513
|
const pending = new Map<ToolCallId, PendingToolCall>();
|
|
1070
1514
|
for (const call of calls) {
|
|
1071
1515
|
pending.set(call.id, {
|
|
@@ -1075,7 +1519,7 @@ export class Agent {
|
|
|
1075
1519
|
startedAt: Date.now(),
|
|
1076
1520
|
});
|
|
1077
1521
|
}
|
|
1078
|
-
this._state = { status: 'waiting_for_tools', pending, completed: [], stream };
|
|
1522
|
+
this._state = { status: 'waiting_for_tools', pending, completed: [], stream, supportsInjectedMessages };
|
|
1079
1523
|
}
|
|
1080
1524
|
|
|
1081
1525
|
/**
|
|
@@ -1118,18 +1562,42 @@ export class Agent {
|
|
|
1118
1562
|
this._state = { status: 'streaming', stream };
|
|
1119
1563
|
}
|
|
1120
1564
|
|
|
1565
|
+
/** The most recent cancelStream() of a live stream, until the stream
|
|
1566
|
+
* driver collects it on that stream's terminal event. Its presence is
|
|
1567
|
+
* the signal (a reasonless Stop is still a deliberate stop); its reason
|
|
1568
|
+
* is the caller's own word. Membrane reports every cancel() as reason
|
|
1569
|
+
* 'user' — the call, not the actor — and a stream implementation may
|
|
1570
|
+
* report the cancel as `error` with no reason at all, so this record is
|
|
1571
|
+
* the only provenance a host-side cancel has. */
|
|
1572
|
+
private _pendingCancel: { reason?: string } | undefined;
|
|
1573
|
+
|
|
1121
1574
|
/**
|
|
1122
|
-
* Cancel
|
|
1575
|
+
* Cancel the stream this agent's state holds (streaming, waiting on its
|
|
1576
|
+
* tools, or ready at a tool boundary with every result in), and reset to
|
|
1577
|
+
* idle. `reason` is provenance for the framework's inference:aborted trace
|
|
1578
|
+
* and marker metadata (e.g. 'zombie_reclaim', 'subagent_cancel'); it never
|
|
1579
|
+
* reaches the provider.
|
|
1123
1580
|
*/
|
|
1124
|
-
cancelStream(): void {
|
|
1125
|
-
if (this._state
|
|
1126
|
-
this.
|
|
1127
|
-
} else if (this._state.status === 'waiting_for_tools' && this._state.stream) {
|
|
1581
|
+
cancelStream(reason?: string): void {
|
|
1582
|
+
if ('stream' in this._state && this._state.stream) {
|
|
1583
|
+
this._pendingCancel = { reason };
|
|
1128
1584
|
this._state.stream.cancel();
|
|
1129
1585
|
}
|
|
1130
1586
|
this._state = { status: 'idle' };
|
|
1131
1587
|
}
|
|
1132
1588
|
|
|
1589
|
+
/** Collect (and clear) the cancel that ended the current stream, if this
|
|
1590
|
+
* side issued one. The stream driver calls it once, while the stream
|
|
1591
|
+
* still owns the agent, at the stream's terminal event (`aborted`
|
|
1592
|
+
* normally, `error` for implementations that report cancel() that way)
|
|
1593
|
+
* or at the loop's end when the stream closed without one. A record no
|
|
1594
|
+
* driver collects is cleared when the agent's next stream starts. */
|
|
1595
|
+
takeCancel(): { reason?: string } | undefined {
|
|
1596
|
+
const c = this._pendingCancel;
|
|
1597
|
+
this._pendingCancel = undefined;
|
|
1598
|
+
return c;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1133
1601
|
/**
|
|
1134
1602
|
* Check if agent has pending tool calls.
|
|
1135
1603
|
*/
|
|
@@ -1162,20 +1630,20 @@ export class Agent {
|
|
|
1162
1630
|
}
|
|
1163
1631
|
|
|
1164
1632
|
/**
|
|
1165
|
-
* Build the effective system prompt, appending any system-position
|
|
1633
|
+
* Build the effective system prompt, appending any system-position
|
|
1634
|
+
* injections, their blocks joined by line breaks. The system prompt is
|
|
1635
|
+
* text, so a block of another type, such as an image a server or module
|
|
1636
|
+
* injected there, can't go in it: a line in its place says so. The hook
|
|
1637
|
+
* orchestrator tells a server's operator once per server and namespace,
|
|
1638
|
+
* and the module registry tells a module's once per module and namespace.
|
|
1166
1639
|
*/
|
|
1167
1640
|
private buildSystemPrompt(systemInjections: ContentBlock[]): string {
|
|
1168
1641
|
if (systemInjections.length === 0) {
|
|
1169
1642
|
return this.systemPrompt;
|
|
1170
1643
|
}
|
|
1171
1644
|
|
|
1172
|
-
const injectedText = systemInjections
|
|
1173
|
-
.
|
|
1174
|
-
.map((block) => block.text);
|
|
1175
|
-
|
|
1176
|
-
if (injectedText.length === 0) {
|
|
1177
|
-
return this.systemPrompt;
|
|
1178
|
-
}
|
|
1645
|
+
const injectedText = systemInjections.map((block) =>
|
|
1646
|
+
block.type === 'text' ? block.text : `[${block.type} block not shown: the system prompt carries text only.]`);
|
|
1179
1647
|
|
|
1180
1648
|
return this.systemPrompt + '\n' + injectedText.join('\n');
|
|
1181
1649
|
}
|
|
@@ -1187,10 +1655,9 @@ export class Agent {
|
|
|
1187
1655
|
return { aborted: true, durationMs };
|
|
1188
1656
|
}
|
|
1189
1657
|
|
|
1190
|
-
if (this._state
|
|
1191
|
-
(this._state.status === 'waiting_for_tools' && this._state.stream)) {
|
|
1658
|
+
if ('stream' in this._state && this._state.stream) {
|
|
1192
1659
|
const durationMs = Date.now() - this._inferenceStartedAt;
|
|
1193
|
-
this.cancelStream();
|
|
1660
|
+
this.cancelStream(reason);
|
|
1194
1661
|
return { aborted: true, durationMs };
|
|
1195
1662
|
}
|
|
1196
1663
|
|