@animalabs/agent-framework 0.22.1 → 0.22.2
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 +1 -1
- package/dist/src/agent.d.ts +192 -19
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +404 -65
- 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 +50 -26
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/api/types.d.ts +9 -1
- package/dist/src/api/types.d.ts.map +1 -1
- package/dist/src/code-execution/py-runner.d.ts.map +1 -1
- package/dist/src/code-execution/py-runner.js.map +1 -1
- package/dist/src/framework.d.ts +393 -113
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +1748 -582
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts.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 +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- 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 +26 -7
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +102 -22
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.d.ts.map +1 -1
- package/dist/src/mcpl/checkpoint-manager.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts.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 +38 -3
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +81 -16
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +26 -3
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js +87 -23
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +2 -2
- package/dist/src/mcpl/references.d.ts.map +1 -1
- 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 +18 -2
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +66 -11
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/server-registry.d.ts.map +1 -1
- 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 +23 -5
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +103 -10
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +30 -26
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/api/index.d.ts.map +1 -1
- package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
- package/dist/src/modules/discord/discord-js-client.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +4 -2
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/health/index.d.ts.map +1 -1
- package/dist/src/modules/health/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js.map +1 -1
- 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 +22 -4
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +63 -25
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +8 -4
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +39 -12
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +43 -8
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +264 -39
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +17 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +57 -14
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +27 -2
- 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.map +1 -1
- 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/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.map +1 -1
- package/dist/src/recovery/offline-branch.js +29 -24
- 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/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.map +1 -1
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- 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 +42 -6
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +10 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +8 -4
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +61 -10
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/src/usage/usage-tracker.d.ts.map +1 -1
- package/dist/test/agent-runtime-settings.test.js +1139 -3
- package/dist/test/agent-runtime-settings.test.js.map +1 -1
- package/dist/test/batched-wake-locus.test.js.map +1 -1
- package/dist/test/channel-label-history.test.js.map +1 -1
- package/dist/test/code-execution.test.js.map +1 -1
- package/dist/test/conversation-fork-injection-scoping.test.js.map +1 -1
- package/dist/test/conversation-router.test.js.map +1 -1
- package/dist/test/conversation-routing.test.js +240 -6
- package/dist/test/conversation-routing.test.js.map +1 -1
- package/dist/test/discord-awareness-outbox.test.js +104 -0
- package/dist/test/discord-awareness-outbox.test.js.map +1 -1
- package/dist/test/discord-typing-keepalive.test.d.ts +2 -0
- package/dist/test/discord-typing-keepalive.test.d.ts.map +1 -0
- package/dist/test/discord-typing-keepalive.test.js +77 -0
- package/dist/test/discord-typing-keepalive.test.js.map +1 -0
- package/dist/test/ephemeral-settle.test.js.map +1 -1
- package/dist/test/event-gate-passthrough.test.js.map +1 -1
- package/dist/test/event-gate-policy-mutation.test.js.map +1 -1
- package/dist/test/event-gate-rate-limit.test.js.map +1 -1
- package/dist/test/event-gate-script.test.js.map +1 -1
- package/dist/test/event-gate-selfwake.test.js.map +1 -1
- package/dist/test/event-gate-tags.test.js.map +1 -1
- package/dist/test/event-gate.test.js.map +1 -1
- package/dist/test/explicit-prose-routing.test.js +363 -42
- package/dist/test/explicit-prose-routing.test.js.map +1 -1
- package/dist/test/framework.test.js.map +1 -1
- package/dist/test/helpers/coalescing-fixture.d.ts +2 -0
- package/dist/test/helpers/coalescing-fixture.d.ts.map +1 -1
- package/dist/test/helpers/coalescing-fixture.js +8 -2
- package/dist/test/helpers/coalescing-fixture.js.map +1 -1
- package/dist/test/helpers/mock-membrane.d.ts.map +1 -1
- package/dist/test/helpers/mock-membrane.js.map +1 -1
- package/dist/test/hide-then-turn.test.d.ts +2 -0
- package/dist/test/hide-then-turn.test.d.ts.map +1 -0
- package/dist/test/hide-then-turn.test.js +101 -0
- package/dist/test/hide-then-turn.test.js.map +1 -0
- package/dist/test/history-module-overview.test.js.map +1 -1
- package/dist/test/history-module-semantic.test.js.map +1 -1
- package/dist/test/history-module.test.js.map +1 -1
- package/dist/test/history-semantic-review-findings.test.js.map +1 -1
- package/dist/test/host-quiesce.test.js +125 -0
- package/dist/test/host-quiesce.test.js.map +1 -1
- package/dist/test/inference-exhaustion-rewind.test.js +81 -3
- package/dist/test/inference-exhaustion-rewind.test.js.map +1 -1
- package/dist/test/inference-failure-bounds.test.js +1 -0
- package/dist/test/inference-failure-bounds.test.js.map +1 -1
- package/dist/test/kv-unified-open-flight-retry.test.js.map +1 -1
- package/dist/test/liveness-watchdog.test.js.map +1 -1
- package/dist/test/maintenance-timer.test.js +1564 -2
- package/dist/test/maintenance-timer.test.js.map +1 -1
- package/dist/test/mcp-server-bin.test.d.ts +2 -0
- package/dist/test/mcp-server-bin.test.d.ts.map +1 -0
- package/dist/test/mcp-server-bin.test.js +142 -0
- package/dist/test/mcp-server-bin.test.js.map +1 -0
- package/dist/test/mcpl-awareness-barrier.test.js.map +1 -1
- package/dist/test/mcpl-child-env.test.js +1 -1
- package/dist/test/mcpl-child-env.test.js.map +1 -1
- package/dist/test/mcpl-coalesced-content-parity.test.d.ts +2 -0
- package/dist/test/mcpl-coalesced-content-parity.test.d.ts.map +1 -0
- package/dist/test/mcpl-coalesced-content-parity.test.js +532 -0
- package/dist/test/mcpl-coalesced-content-parity.test.js.map +1 -0
- package/dist/test/mcpl-coalescing.test.js.map +1 -1
- package/dist/test/mcpl-config-diagnostics.test.js.map +1 -1
- package/dist/test/mcpl-gate-roundtrip.test.js.map +1 -1
- package/dist/test/mcpl-manifest-changed.test.js.map +1 -1
- package/dist/test/mcpl-reconnect-events.test.js.map +1 -1
- package/dist/test/mcpl-reconnect-reregistration.test.js +2 -0
- package/dist/test/mcpl-reconnect-reregistration.test.js.map +1 -1
- package/dist/test/mcpl-reference-fetcher.test.js.map +1 -1
- package/dist/test/mcpl-reference-fields.test.js.map +1 -1
- package/dist/test/mcpl-rejection-log-lines.test.d.ts +2 -0
- package/dist/test/mcpl-rejection-log-lines.test.d.ts.map +1 -0
- package/dist/test/mcpl-rejection-log-lines.test.js +349 -0
- package/dist/test/mcpl-rejection-log-lines.test.js.map +1 -0
- package/dist/test/mcpl-stderr-tail.test.d.ts +2 -0
- package/dist/test/mcpl-stderr-tail.test.d.ts.map +1 -0
- package/dist/test/mcpl-stderr-tail.test.js +210 -0
- package/dist/test/mcpl-stderr-tail.test.js.map +1 -0
- package/dist/test/mcpl-tool-lifecycle-e2e.test.js.map +1 -1
- package/dist/test/mcpl-tool-lifecycle-emitter.test.js.map +1 -1
- package/dist/test/mcpl-tool-lifecycle-script.test.js.map +1 -1
- package/dist/test/mcpl-tool-lifecycle.test.js.map +1 -1
- package/dist/test/mcpl-transport-close.test.d.ts +2 -0
- package/dist/test/mcpl-transport-close.test.d.ts.map +1 -0
- package/dist/test/mcpl-transport-close.test.js +373 -0
- package/dist/test/mcpl-transport-close.test.js.map +1 -0
- package/dist/test/mcpl-transport-spawn.test.d.ts +2 -0
- package/dist/test/mcpl-transport-spawn.test.d.ts.map +1 -0
- package/dist/test/mcpl-transport-spawn.test.js +58 -0
- package/dist/test/mcpl-transport-spawn.test.js.map +1 -0
- package/dist/test/mcpl-ws-transport.test.js +1 -0
- package/dist/test/mcpl-ws-transport.test.js.map +1 -1
- package/dist/test/offline-recovery-branch.test.js +344 -0
- package/dist/test/offline-recovery-branch.test.js.map +1 -1
- package/dist/test/operator-surgery.test.js +197 -0
- package/dist/test/operator-surgery.test.js.map +1 -1
- package/dist/test/overbudget-drain-breaker.test.js +1 -0
- package/dist/test/overbudget-drain-breaker.test.js.map +1 -1
- package/dist/test/pack-installs-alone.test.d.ts +2 -0
- package/dist/test/pack-installs-alone.test.d.ts.map +1 -0
- package/dist/test/pack-installs-alone.test.js +284 -0
- package/dist/test/pack-installs-alone.test.js.map +1 -0
- package/dist/test/physical-window-restart.test.d.ts +6 -4
- package/dist/test/physical-window-restart.test.d.ts.map +1 -1
- package/dist/test/physical-window-restart.test.js +275 -10
- package/dist/test/physical-window-restart.test.js.map +1 -1
- package/dist/test/placed-reaction-baseline.test.js.map +1 -1
- package/dist/test/present-while-acting.test.js +949 -6
- package/dist/test/present-while-acting.test.js.map +1 -1
- package/dist/test/provider-acceleration-cooldown.test.js.map +1 -1
- package/dist/test/provider-waits.test.js +67 -4
- package/dist/test/provider-waits.test.js.map +1 -1
- package/dist/test/puppet-tool-call.test.js +2 -0
- package/dist/test/puppet-tool-call.test.js.map +1 -1
- package/dist/test/reaction-baseline-platform.test.js.map +1 -1
- package/dist/test/record-journal.test.js.map +1 -1
- package/dist/test/refusal-rewind.test.js +9 -0
- package/dist/test/refusal-rewind.test.js.map +1 -1
- package/dist/test/refusal-single-call.test.js.map +1 -1
- package/dist/test/release-bump.test.d.ts +2 -0
- package/dist/test/release-bump.test.d.ts.map +1 -0
- package/dist/test/release-bump.test.js +248 -0
- package/dist/test/release-bump.test.js.map +1 -0
- package/dist/test/release-changelog.test.js.map +1 -1
- package/dist/test/release-holds.test.d.ts +2 -0
- package/dist/test/release-holds.test.d.ts.map +1 -0
- package/dist/test/release-holds.test.js +456 -0
- package/dist/test/release-holds.test.js.map +1 -0
- package/dist/test/same-round-think-policy.test.js.map +1 -1
- package/dist/test/shutdown-errors.test.js.map +1 -1
- package/dist/test/silent-heartbeat-rows.test.js.map +1 -1
- package/dist/test/stop-with-host-operations.test.d.ts +20 -0
- package/dist/test/stop-with-host-operations.test.d.ts.map +1 -0
- package/dist/test/stop-with-host-operations.test.js +1174 -0
- package/dist/test/stop-with-host-operations.test.js.map +1 -0
- package/dist/test/stop-with-work-in-flight.test.js +162 -50
- package/dist/test/stop-with-work-in-flight.test.js.map +1 -1
- package/dist/test/surgery-marks-receipt.test.js.map +1 -1
- package/dist/test/tool-batch-hook.test.js.map +1 -1
- package/dist/test/tool-result-guard.test.js +131 -9
- package/dist/test/tool-result-guard.test.js.map +1 -1
- package/dist/test/tool-result-spill.test.js.map +1 -1
- package/dist/test/tool-wrapper-prose-guard-integration.test.js.map +1 -1
- package/dist/test/trunk-channel-routing.test.js +330 -7
- package/dist/test/trunk-channel-routing.test.js.map +1 -1
- package/dist/test/tune-out-e2e.test.js.map +1 -1
- package/dist/test/unconvertible-tool-result.test.js.map +1 -1
- package/dist/test/unsent-compiles.test.d.ts +2 -0
- package/dist/test/unsent-compiles.test.d.ts.map +1 -0
- package/dist/test/unsent-compiles.test.js +139 -0
- package/dist/test/unsent-compiles.test.js.map +1 -0
- package/dist/test/workspace-branch-continuation.test.js.map +1 -1
- package/dist/test/workspace-materialize-freshness.test.js.map +1 -1
- package/dist/test/workspace-read-text.test.js.map +1 -1
- package/dist/test/workspace-three-way.test.js +907 -7
- package/dist/test/workspace-three-way.test.js.map +1 -1
- package/dist/test/workspace-watcher.test.js.map +1 -1
- package/dist/test/xml-round-persist.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/src/agent.ts +411 -66
- package/src/api/mcp-server-core.ts +681 -0
- package/src/api/mcp-server.ts +16 -685
- package/src/api/server.ts +51 -29
- package/src/api/types.ts +9 -1
- package/src/framework.ts +1899 -641
- package/src/index.ts +2 -2
- package/src/mcpl/channel-registry.ts +126 -31
- package/src/mcpl/feature-set-manager.ts +4 -3
- package/src/mcpl/log-value.ts +116 -0
- package/src/mcpl/prose-stream-router.ts +6 -6
- package/src/mcpl/push-coalescer.ts +76 -12
- package/src/mcpl/push-handler.ts +95 -23
- package/src/mcpl/refusal-lines.ts +59 -0
- package/src/mcpl/server-connection.ts +70 -11
- package/src/mcpl/tool-classes.ts +3 -2
- package/src/mcpl/transport.ts +105 -14
- package/src/mcpl/types.ts +5 -1
- package/src/modules/discord/index.ts +4 -2
- package/src/modules/workspace/disk-agreement.ts +74 -18
- package/src/modules/workspace/index.ts +41 -11
- package/src/modules/workspace/observe.ts +265 -39
- package/src/modules/workspace/reconcile.ts +71 -14
- package/src/modules/workspace/types.ts +26 -1
- package/src/recovery/offline-branch.ts +32 -28
- package/src/stored-removal.ts +126 -0
- package/src/types/agent.ts +42 -6
- package/src/types/framework.ts +10 -0
- package/src/types/module.ts +8 -4
- package/src/types/trace.ts +62 -11
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JsStore } from '@animalabs/chronicle';
|
|
2
|
-
import { ContextManager } from '@animalabs/context-manager';
|
|
2
|
+
import { ContextManager, continuesBody, type BodyShard } from '@animalabs/context-manager';
|
|
3
|
+
import { removeStoredInterval } from '../stored-removal.js';
|
|
3
4
|
import {
|
|
4
5
|
DEFAULT_DISCORD_AWARENESS_EMOJI,
|
|
5
6
|
DiscordAwarenessOutbox,
|
|
@@ -202,11 +203,12 @@ export async function createOfflineRecoveryBranch(
|
|
|
202
203
|
const createdBranch = contextManager.branchAt(target.id, targetBranch);
|
|
203
204
|
try {
|
|
204
205
|
await contextManager.switchBranch(createdBranch);
|
|
205
|
-
//
|
|
206
|
-
//
|
|
206
|
+
// Each interval is removed by its messages' ids, so the order doesn't
|
|
207
|
+
// change the result. removeStoredInterval takes a single message outside
|
|
208
|
+
// any body through removeMessage, and a shard or a longer interval as a
|
|
209
|
+
// range, which refuses one that splits a body.
|
|
207
210
|
for (const interval of [...suppression.intervals].reverse()) {
|
|
208
|
-
|
|
209
|
-
else contextManager.removeMessages(interval.fromId, interval.toId);
|
|
211
|
+
removeStoredInterval(contextManager, interval.fromId, interval.toId);
|
|
210
212
|
}
|
|
211
213
|
if (batch) outbox.activate(batch.id);
|
|
212
214
|
} catch (error) {
|
|
@@ -238,9 +240,7 @@ interface SuppressionInterval {
|
|
|
238
240
|
|
|
239
241
|
interface MessageLocation {
|
|
240
242
|
first: number;
|
|
241
|
-
last: number;
|
|
242
243
|
firstId: StoredWindowMessage['id'];
|
|
243
|
-
lastId: StoredWindowMessage['id'];
|
|
244
244
|
/** Usually one run; multiple runs tolerate duplicate external metadata. */
|
|
245
245
|
runs: SuppressionInterval[];
|
|
246
246
|
}
|
|
@@ -299,14 +299,15 @@ function validateAnchorBoundary(
|
|
|
299
299
|
total: number,
|
|
300
300
|
target: StoredWindowMessage,
|
|
301
301
|
): void {
|
|
302
|
-
|
|
303
|
-
if (!groupId || targetIndex + 1 >= total) return;
|
|
302
|
+
if (targetIndex + 1 >= total) return;
|
|
304
303
|
const next = contextManager.getMessageWindow(targetIndex + 1, 1, {
|
|
305
304
|
resolveBlobs: false,
|
|
306
|
-
}).messages[0]
|
|
307
|
-
|
|
305
|
+
}).messages[0];
|
|
306
|
+
// A body continues only into a later shard of the same ingestion: a
|
|
307
|
+
// reposted document shares its group id but starts a body of its own.
|
|
308
|
+
if (continuesBody(target as BodyShard, next as BodyShard | undefined)) {
|
|
308
309
|
throw new Error(
|
|
309
|
-
`Recovery anchor ${String(target.id)} splits body group ${
|
|
310
|
+
`Recovery anchor ${String(target.id)} splits body group ${(target as BodyShard).bodyGroupId}; choose its final shard.`,
|
|
310
311
|
);
|
|
311
312
|
}
|
|
312
313
|
}
|
|
@@ -321,7 +322,9 @@ function validateRemovalIntegrity(
|
|
|
321
322
|
index >= interval.start && index <= interval.end);
|
|
322
323
|
const toolUses = new Map<string, boolean>();
|
|
323
324
|
const toolResults = new Map<string, boolean>();
|
|
324
|
-
|
|
325
|
+
// The message before, in store order: a selection splits a body when a
|
|
326
|
+
// message continuing the one before it lands on the other side.
|
|
327
|
+
let previous: { message: BodyShard; removed: boolean } | null = null;
|
|
325
328
|
|
|
326
329
|
for (let offset = 0; offset < total; offset += RECOVERY_SCAN_WINDOW) {
|
|
327
330
|
const messages = contextManager.getMessageWindow(
|
|
@@ -332,16 +335,14 @@ function validateRemovalIntegrity(
|
|
|
332
335
|
for (let i = 0; i < messages.length; i++) {
|
|
333
336
|
const index = offset + i;
|
|
334
337
|
const isRemoved = removed(index);
|
|
335
|
-
const message = messages[i]
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
groupMembership.set(message.bodyGroupId, isRemoved);
|
|
338
|
+
const message = messages[i];
|
|
339
|
+
const shard = message as BodyShard;
|
|
340
|
+
if (previous && previous.removed !== isRemoved && continuesBody(previous.message, shard)) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
`Recovery selection splits body group ${shard.bodyGroupId}; adjust the anchor or suppression boundary.`,
|
|
343
|
+
);
|
|
344
344
|
}
|
|
345
|
+
previous = { message: shard, removed: isRemoved };
|
|
345
346
|
for (const rawBlock of message.content) {
|
|
346
347
|
const block = rawBlock as { type?: unknown; id?: unknown; toolUseId?: unknown };
|
|
347
348
|
if (block.type === 'tool_use' && typeof block.id === 'string') {
|
|
@@ -402,9 +403,7 @@ function buildSuppressionPlan(
|
|
|
402
403
|
};
|
|
403
404
|
locations.set(externalId, {
|
|
404
405
|
first: index,
|
|
405
|
-
last: index,
|
|
406
406
|
firstId: messages[i].id,
|
|
407
|
-
lastId: messages[i].id,
|
|
408
407
|
runs: [run],
|
|
409
408
|
});
|
|
410
409
|
} else {
|
|
@@ -420,8 +419,6 @@ function buildSuppressionPlan(
|
|
|
420
419
|
toId: messages[i].id,
|
|
421
420
|
});
|
|
422
421
|
}
|
|
423
|
-
location.last = index;
|
|
424
|
-
location.lastId = messages[i].id;
|
|
425
422
|
}
|
|
426
423
|
}
|
|
427
424
|
}
|
|
@@ -444,12 +441,19 @@ function buildSuppressionPlan(
|
|
|
444
441
|
const to = locations.get(range.toMessageId)!;
|
|
445
442
|
const earlier = from.first <= to.first ? from : to;
|
|
446
443
|
const later = from.first <= to.first ? to : from;
|
|
444
|
+
// What's between the two messages, after the earlier one began and
|
|
445
|
+
// before the later one began: from the earlier one's first stored copy
|
|
446
|
+
// through the later one's first. Each end is every copy of it besides,
|
|
447
|
+
// as a single suppression is, so a copy stored outside that span (a
|
|
448
|
+
// write cut short and retried later) is taken on its own, and nothing
|
|
449
|
+
// else stored after the later one began is taken.
|
|
447
450
|
intervals.push({
|
|
448
451
|
start: earlier.first,
|
|
449
|
-
end: later.
|
|
452
|
+
end: later.first,
|
|
450
453
|
fromId: earlier.firstId,
|
|
451
|
-
toId: later.
|
|
454
|
+
toId: later.firstId,
|
|
452
455
|
});
|
|
456
|
+
for (const end of [from, to]) intervals.push(...end.runs.map((run) => ({ ...run })));
|
|
453
457
|
}
|
|
454
458
|
|
|
455
459
|
intervals.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { bodyBoundsIn, type BodyShard, type ContextManager, type MessageId } from '@animalabs/context-manager';
|
|
2
|
+
|
|
3
|
+
type StoredLike = BodyShard & { id: MessageId };
|
|
4
|
+
type Removals = Pick<ContextManager, 'removeMessage' | 'removeMessages'>;
|
|
5
|
+
|
|
6
|
+
/** Minimal read surface the live-surgery helpers need from a ContextManager. */
|
|
7
|
+
export interface SurgeryReadableCm {
|
|
8
|
+
getMessageCount(): number;
|
|
9
|
+
getMessageWindow(
|
|
10
|
+
offset: number,
|
|
11
|
+
limit: number,
|
|
12
|
+
opts?: { resolveBlobs?: boolean; alignToBodyGroups?: boolean },
|
|
13
|
+
): { messages: Array<{ id: unknown; bodyGroupId?: string }>; startIndex: number };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SURGERY_SCAN_WINDOW = 500;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Slot index of `messageId` on the active branch, or -1. Scans from the tail
|
|
20
|
+
* in blob-free windows: operator targets are almost always recent, and a
|
|
21
|
+
* full `getAllMessages()` re-inflates every attachment on the branch.
|
|
22
|
+
*/
|
|
23
|
+
export function locateMessageIndex(cm: SurgeryReadableCm, messageId: string): number {
|
|
24
|
+
const hit = locateMessageIndices(cm, new Set([messageId])).get(messageId);
|
|
25
|
+
return hit ? hit.index : -1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Tail-first scan resolving many ids at once; stops as soon as all are found. */
|
|
29
|
+
export function locateMessageIndices(
|
|
30
|
+
cm: SurgeryReadableCm,
|
|
31
|
+
ids: Set<string>,
|
|
32
|
+
): Map<string, { index: number; bodyGroupId?: string }> {
|
|
33
|
+
const found = new Map<string, { index: number; bodyGroupId?: string }>();
|
|
34
|
+
const total = cm.getMessageCount();
|
|
35
|
+
for (let end = total; end > 0 && found.size < ids.size; end -= SURGERY_SCAN_WINDOW) {
|
|
36
|
+
const start = Math.max(0, end - SURGERY_SCAN_WINDOW);
|
|
37
|
+
const { messages, startIndex } = cm.getMessageWindow(start, end - start, { resolveBlobs: false });
|
|
38
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
39
|
+
const id = String(messages[i].id);
|
|
40
|
+
if (ids.has(id) && !found.has(id)) {
|
|
41
|
+
found.set(id, {
|
|
42
|
+
index: startIndex + i,
|
|
43
|
+
...(messages[i].bodyGroupId ? { bodyGroupId: messages[i].bodyGroupId } : {}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Inclusive slot range of the body-group run containing `index` (the slot
|
|
53
|
+
* itself when it is not sharded). Delegates to the store's own
|
|
54
|
+
* `alignToBodyGroups` edge walk — one contiguity assumption, not two.
|
|
55
|
+
*/
|
|
56
|
+
export function bodyGroupRun(
|
|
57
|
+
cm: SurgeryReadableCm,
|
|
58
|
+
index: number,
|
|
59
|
+
): { from: number; to: number; fromId: string; toId: string; group: boolean } {
|
|
60
|
+
const win = cm.getMessageWindow(index, 1, { alignToBodyGroups: true, resolveBlobs: false });
|
|
61
|
+
const from = win.startIndex;
|
|
62
|
+
const to = win.startIndex + win.messages.length - 1;
|
|
63
|
+
return {
|
|
64
|
+
from,
|
|
65
|
+
to,
|
|
66
|
+
fromId: String(win.messages[0].id),
|
|
67
|
+
toId: String(win.messages[win.messages.length - 1].id),
|
|
68
|
+
group: win.messages[0].bodyGroupId !== undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Remove the stored messages `first`..`last` (inclusive, in store order).
|
|
74
|
+
*
|
|
75
|
+
* A single message outside any body goes through `removeMessage`.
|
|
76
|
+
* context-manager's `removeMessage` refuses any message that carries a body
|
|
77
|
+
* group id, a one-shard body's included, so a shard, and any longer interval,
|
|
78
|
+
* goes through `removeMessages`, which refuses an interval that splits a
|
|
79
|
+
* body.
|
|
80
|
+
*/
|
|
81
|
+
export function removeStoredMessages(cm: Removals, first: StoredLike, last: StoredLike): void {
|
|
82
|
+
if (first.id === last.id && !first.bodyGroupId) {
|
|
83
|
+
cm.removeMessage(first.id);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
cm.removeMessages(first.id, last.id);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Remove one stored message by its id, with the rest of its body when it's
|
|
91
|
+
* in one: a module or a coalescer removes a message it added by the id
|
|
92
|
+
* `addMessage` returned, which for a long message stored in shards is its
|
|
93
|
+
* first shard's.
|
|
94
|
+
*/
|
|
95
|
+
export function removeStoredMessage(cm: ContextManager, id: MessageId): void {
|
|
96
|
+
const message = cm.getMessage(id) as StoredLike | null;
|
|
97
|
+
if (!message?.bodyGroupId) {
|
|
98
|
+
cm.removeMessage(id);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Found in blob-free windows: a full read of the branch would inflate every
|
|
102
|
+
// attachment on it, once for each message a sweep removes.
|
|
103
|
+
const index = locateMessageIndex(cm, String(id));
|
|
104
|
+
if (index < 0) {
|
|
105
|
+
cm.removeMessage(id);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const run = bodyGroupRun(cm, index);
|
|
109
|
+
cm.removeMessages(run.fromId as MessageId, run.toId as MessageId);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** removeStoredMessages for an interval known by its ids. */
|
|
113
|
+
export function removeStoredInterval(cm: ContextManager, fromId: MessageId, toId: MessageId): void {
|
|
114
|
+
const first = cm.getMessage(fromId) as StoredLike | null;
|
|
115
|
+
removeStoredMessages(cm, first ?? { id: fromId }, { id: toId });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The first and last positions (inclusive) of the body that holds
|
|
120
|
+
* `messages[index]`, read the way context-manager 0.14.0 reads bodies
|
|
121
|
+
* (`continuesBody`, pairwise in store order). A message outside any body is a
|
|
122
|
+
* body of its own.
|
|
123
|
+
*/
|
|
124
|
+
export function bodyRangeIn(messages: readonly unknown[], index: number): { from: number; to: number } {
|
|
125
|
+
return bodyBoundsIn(messages as readonly (BodyShard | null | undefined)[], index);
|
|
126
|
+
}
|
package/src/types/agent.ts
CHANGED
|
@@ -53,11 +53,14 @@ export interface AgentConfig {
|
|
|
53
53
|
/**
|
|
54
54
|
* The model's PHYSICAL context window (provider hard cap, e.g. 200000).
|
|
55
55
|
* When set, the framework projects each continuation round's real size
|
|
56
|
-
* (cache-inclusive input of the
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
56
|
+
* (cache-inclusive input of the latest call that reported its prompt +
|
|
57
|
+
* that call's output + what the stream has grown by since, if later calls
|
|
58
|
+
* reported none + the blocks about to be appended + reserve for response)
|
|
59
|
+
* and restarts the stream through a fresh compile instead of dispatching a
|
|
60
|
+
* request the provider will 400 (issue #92: a legal compile can walk past
|
|
61
|
+
* the physical window mid-turn). The projection runs once a call on the
|
|
62
|
+
* stream has reported its prompt. Unset → no projection; only the
|
|
63
|
+
* maxStreamTokens restart applies.
|
|
61
64
|
*/
|
|
62
65
|
physicalWindowTokens?: number;
|
|
63
66
|
|
|
@@ -223,7 +226,20 @@ export interface AgentRuntimeSettingsPatch {
|
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
export interface AgentRuntimeSettingsSnapshot {
|
|
229
|
+
/**
|
|
230
|
+
* The budget the agent is set to: while a lower one converges, its target,
|
|
231
|
+
* and while a persisted one the agent couldn't apply is kept, that one.
|
|
232
|
+
*/
|
|
226
233
|
contextBudgetTokens: number;
|
|
234
|
+
/**
|
|
235
|
+
* The budget compiles plan at now: the live budget, or the default when the
|
|
236
|
+
* recipe sets none (the context manager's own default is the same). It
|
|
237
|
+
* equals `contextBudgetTokens` except while a lower budget converges, when
|
|
238
|
+
* it is still the budget the descent started from (context-manager #162),
|
|
239
|
+
* and while a budget the agent couldn't apply is kept, when it is the
|
|
240
|
+
* budget the agent runs at instead.
|
|
241
|
+
*/
|
|
242
|
+
effectiveContextBudgetTokens: number;
|
|
227
243
|
tailTokens?: number;
|
|
228
244
|
transitionPaceTokens?: number;
|
|
229
245
|
sameRoundThinkTextPolicy: SameRoundThinkTextPolicy;
|
|
@@ -233,7 +249,27 @@ export interface AgentRuntimeSettingsSnapshot {
|
|
|
233
249
|
}
|
|
234
250
|
|
|
235
251
|
/** Persisted values differ from recipe defaults; omitted keys inherit config. */
|
|
236
|
-
export type AgentRuntimeSettingsOverrides = AgentRuntimeSettingsPatch
|
|
252
|
+
export type AgentRuntimeSettingsOverrides = AgentRuntimeSettingsPatch & {
|
|
253
|
+
/**
|
|
254
|
+
* The record's own `contextBudgetTokens`, written when a compile at the
|
|
255
|
+
* agent's live budget fits at it, with nothing about the budget changed
|
|
256
|
+
* while it ran (a paced descent's settle included): the store fit that
|
|
257
|
+
* budget. A compile the context manager refuses at it as over budget
|
|
258
|
+
* withdraws it, unless a compile at it that started later has already
|
|
259
|
+
* ended.
|
|
260
|
+
* When it equals `contextBudgetTokens`, a restore applies that budget at
|
|
261
|
+
* once, rather than pacing a descent again from the recipe's budget
|
|
262
|
+
* (context-manager #162), if a preview at boot says it still fits; if not,
|
|
263
|
+
* a budget below the recipe's restores paced, and if a compile at one that
|
|
264
|
+
* the boot applied at once is refused, the agent restores it paced then.
|
|
265
|
+
* Since the store fit it when the field was written, the planner can fold
|
|
266
|
+
* to it at once even if its carried frontier was lost. Any other value is
|
|
267
|
+
* stale (the budget changed since, or an earlier release carried the field
|
|
268
|
+
* forward), and a budget below the recipe's restores paced, as it does
|
|
269
|
+
* without the field. Never part of a patch.
|
|
270
|
+
*/
|
|
271
|
+
contextBudgetReachedTokens?: number;
|
|
272
|
+
};
|
|
237
273
|
|
|
238
274
|
/**
|
|
239
275
|
* Result of running inference.
|
package/src/types/framework.ts
CHANGED
|
@@ -302,6 +302,10 @@ export interface ContextMaintenanceAgentRun {
|
|
|
302
302
|
pendingAfter?: string;
|
|
303
303
|
progressBefore?: Record<string, unknown>;
|
|
304
304
|
progressAfter?: Record<string, unknown>;
|
|
305
|
+
/**
|
|
306
|
+
* The agent's failure in this pass: a tick that threw, or its readiness
|
|
307
|
+
* that couldn't be read, before the ticks or after them.
|
|
308
|
+
*/
|
|
305
309
|
error?: string;
|
|
306
310
|
}
|
|
307
311
|
|
|
@@ -323,6 +327,12 @@ export interface ContextMaintenanceSnapshot {
|
|
|
323
327
|
agentName: string;
|
|
324
328
|
ready: boolean;
|
|
325
329
|
pending?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Why the agent's readiness can't be read: the context manager refuses
|
|
332
|
+
* while its strategy's initialization is pending or has failed, and a
|
|
333
|
+
* strategy can refuse on its own. `ready` is false then.
|
|
334
|
+
*/
|
|
335
|
+
error?: string;
|
|
326
336
|
progress?: Record<string, unknown>;
|
|
327
337
|
}>;
|
|
328
338
|
}
|
package/src/types/module.ts
CHANGED
|
@@ -321,10 +321,14 @@ export interface ModuleContext {
|
|
|
321
321
|
*
|
|
322
322
|
* Modules use this to react to agent lifecycle without polling — e.g. an
|
|
323
323
|
* adapter that wants to show a "typing" indicator can bracket it between
|
|
324
|
-
* `inference:started` and the terminal events
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
324
|
+
* `inference:started` and the terminal events: `inference:completed` (the
|
|
325
|
+
* normal end), `inference:turn_ended` (a tool result ended the turn),
|
|
326
|
+
* `inference:aborted`, `inference:failed` and `inference:exhausted`, all of
|
|
327
|
+
* which carry `agentName`. A turn's tool-call cycles stay inside its
|
|
328
|
+
* stream, so one bracket spans them. A context-budget restart emits
|
|
329
|
+
* `inference:started` again with no terminal event for the stream it
|
|
330
|
+
* replaced, and a failing turn can emit `inference:failed` and then
|
|
331
|
+
* `inference:exhausted`, so a bracket should allow a repeated start or end.
|
|
328
332
|
*
|
|
329
333
|
* Returns an unsubscribe function. Call it in the module's `stop()` to avoid
|
|
330
334
|
* leaking listeners across teardown/recreate (e.g. session switch).
|
package/src/types/trace.ts
CHANGED
|
@@ -41,11 +41,14 @@ export type TraceEvent =
|
|
|
41
41
|
type: 'inference:started';
|
|
42
42
|
agentName: string;
|
|
43
43
|
/**
|
|
44
|
-
* The turn
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
44
|
+
* The turn's locus as this stream starts (locus and hybrid mode): where
|
|
45
|
+
* its unprefixed plain prose is published, unless a hybrid `>>>`
|
|
46
|
+
* destination takes it, or a re-pin or a `channel_open` moves the locus
|
|
47
|
+
* later in the turn. Omitted for a turn with no locus: explicit and
|
|
48
|
+
* disabled mode, a silent turn, and a heartbeat with no default
|
|
49
|
+
* channel. Observability only, like every trace field; lets external
|
|
50
|
+
* taps (e.g. a TTS relay) tag the whole activation with its channel
|
|
51
|
+
* without re-deriving routing.
|
|
49
52
|
*/
|
|
50
53
|
channelId?: string;
|
|
51
54
|
/** True for a control-plane wake that must not surface typing/prose. */
|
|
@@ -60,7 +63,15 @@ export type TraceEvent =
|
|
|
60
63
|
| (TraceEventBase & {
|
|
61
64
|
type: 'inference:aborted';
|
|
62
65
|
agentName: string;
|
|
66
|
+
/** How long this start of the turn ran; after a context-budget restart, from the restart. */
|
|
63
67
|
durationMs: number;
|
|
68
|
+
/**
|
|
69
|
+
* Why the turn ended unfinished: the reason an operator gave
|
|
70
|
+
* `abortInference`, `'quiesce_abandoned'` for a turn an operator quiesce
|
|
71
|
+
* abandoned, or, for a turn dropped before it sent anything (its agent
|
|
72
|
+
* replaced or removed, or the framework stopping or restarted), a
|
|
73
|
+
* sentence saying which.
|
|
74
|
+
*/
|
|
64
75
|
reason?: string;
|
|
65
76
|
})
|
|
66
77
|
| (TraceEventBase & {
|
|
@@ -104,7 +115,9 @@ export type TraceEvent =
|
|
|
104
115
|
blockType: 'text' | 'thinking' | 'tool_call' | 'tool_result';
|
|
105
116
|
/** 0-indexed block position in the current assistant turn. */
|
|
106
117
|
blockIndex: number;
|
|
107
|
-
/**
|
|
118
|
+
/** The channel this stream shows typing in: the turn's locus as the
|
|
119
|
+
* stream started (see inference:started), or in explicit mode the
|
|
120
|
+
* channel the start's wake came from. */
|
|
108
121
|
channelId?: string;
|
|
109
122
|
})
|
|
110
123
|
| (TraceEventBase & {
|
|
@@ -119,7 +132,9 @@ export type TraceEvent =
|
|
|
119
132
|
phase: 'block_start' | 'block_complete';
|
|
120
133
|
blockType: 'text' | 'thinking' | 'tool_call' | 'tool_result';
|
|
121
134
|
blockIndex: number;
|
|
122
|
-
/**
|
|
135
|
+
/** The channel this stream shows typing in: the turn's locus as the
|
|
136
|
+
* stream started (see inference:started), or in explicit mode the
|
|
137
|
+
* channel the start's wake came from. */
|
|
123
138
|
channelId?: string;
|
|
124
139
|
})
|
|
125
140
|
| (TraceEventBase & {
|
|
@@ -236,22 +251,47 @@ export type TraceEvent =
|
|
|
236
251
|
messageId: string;
|
|
237
252
|
source: string;
|
|
238
253
|
})
|
|
239
|
-
/** A push/event refused at the MCPL boundary
|
|
254
|
+
/** A push/event refused at the MCPL boundary: visibly-empty content
|
|
255
|
+
* (`empty-content`, answered -32602, with no `field` or `detail`), or a
|
|
256
|
+
* coalesced occurrence the host refused. A refused occurrence's reason
|
|
257
|
+
* follows the code the producer was answered with: `coalesce-invalid` when
|
|
258
|
+
* the occurrence was the producer's to fix (-32602 malformed; -32017 or
|
|
259
|
+
* -32023 for a channel not permitted or not registered), `coalesce-failed`
|
|
260
|
+
* when the host itself failed (-32000, -32603). Its trace carries the
|
|
261
|
+
* error's message in `detail`, and the failing `field` when the error
|
|
262
|
+
* names one, and `channelId` when the push is refused for its channel
|
|
263
|
+
* (-32017, -32023), so each refusal names its channel even while repeats
|
|
264
|
+
* of its line are held back. An `eventId` that is missing or isn't a
|
|
265
|
+
* string is traced as `''`. A push refused for its feature set, or as a
|
|
266
|
+
* duplicate, gets a `[push-event-rejected]` line and no trace. */
|
|
240
267
|
| (TraceEventBase & {
|
|
241
268
|
type: 'mcpl:push-event-rejected';
|
|
242
269
|
serverId: string;
|
|
243
270
|
eventId: string;
|
|
244
271
|
featureSet: string;
|
|
245
272
|
reason: string;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
273
|
+
field?: string;
|
|
274
|
+
channelId?: string;
|
|
275
|
+
detail?: string;
|
|
276
|
+
})
|
|
277
|
+
/** A channels/incoming message refused at the MCPL boundary: an
|
|
278
|
+
* unregistered channel (`unknown-channel`, §14.5), visibly-empty content
|
|
279
|
+
* (`empty-content`), or a coalesced item the host refused
|
|
280
|
+
* (`coalesce-invalid` / `coalesce-failed`, with `detail`, and `field` when
|
|
281
|
+
* the error names one, as for a push). A coalesced item refused with
|
|
282
|
+
* -32602 (malformed) is answered `coalesce_invalid`, and one refused
|
|
283
|
+
* otherwise (-32000, or an internal error) with the error's own message.
|
|
284
|
+
* `messageId` is set whenever the message carries one. An uncoalesced
|
|
285
|
+
* message without a channelId or messageId is answered `invalid
|
|
286
|
+
* channel/message identity`, with no line and no trace. */
|
|
249
287
|
| (TraceEventBase & {
|
|
250
288
|
type: 'mcpl:channel-incoming-rejected';
|
|
251
289
|
serverId: string;
|
|
252
290
|
channelId: string;
|
|
253
291
|
messageId?: string;
|
|
254
292
|
reason: string;
|
|
293
|
+
field?: string;
|
|
294
|
+
detail?: string;
|
|
255
295
|
})
|
|
256
296
|
/** MCPL content with nothing model-visible reached the store/wake site
|
|
257
297
|
* (module-emitted or coalescer-delivered) and was dropped: no row, no wake. */
|
|
@@ -441,6 +481,12 @@ export type TraceEvent =
|
|
|
441
481
|
type: 'mcpl:server-connect-failed';
|
|
442
482
|
serverId: string;
|
|
443
483
|
error: string;
|
|
484
|
+
/** The last of the server's stderr, when its handshake failed by its
|
|
485
|
+
* transport closing, a transport error or its timeout and it had
|
|
486
|
+
* written any: the server's own text, which `error` never carries. A
|
|
487
|
+
* transport that failed its handshake was never wired, so its lines
|
|
488
|
+
* never reached `mcpl:server-stderr`. */
|
|
489
|
+
stderrTail?: string;
|
|
444
490
|
/** Ordinal of the failed attempt: 0 is the initial connect, N is the Nth background retry. */
|
|
445
491
|
attempt: number;
|
|
446
492
|
/** True when a background reconnect loop will keep retrying. */
|
|
@@ -468,6 +514,11 @@ export type TraceEvent =
|
|
|
468
514
|
code: number | null;
|
|
469
515
|
/** Signal that terminated the child, if any. */
|
|
470
516
|
signal: string | null;
|
|
517
|
+
/** Why the transport closed, in its own words, such as `child process
|
|
518
|
+
* exited, and its pipe failed with write EPIPE` or `closed by host`;
|
|
519
|
+
* null when it gave none, or when its reason is a WebSocket server's
|
|
520
|
+
* own close text, which stays off the trace. */
|
|
521
|
+
reason: string | null;
|
|
471
522
|
/** True when a background reconnect loop will revive the connection. */
|
|
472
523
|
willReconnect: boolean;
|
|
473
524
|
})
|