@animalabs/agent-framework 0.22.2 → 0.23.0
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 +108 -4
- package/dist/src/agent.d.ts +108 -17
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +207 -67
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.js +1 -1
- package/dist/src/api/mcp-server-core.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +5 -1
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/api/types.d.ts +1 -1
- 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/index.d.ts +1 -1
- package/dist/src/code-execution/index.d.ts.map +1 -1
- package/dist/src/code-execution/index.js.map +1 -1
- package/dist/src/code-execution/py-runner.d.ts +50 -7
- package/dist/src/code-execution/py-runner.d.ts.map +1 -1
- package/dist/src/code-execution/py-runner.js +258 -90
- package/dist/src/code-execution/py-runner.js.map +1 -1
- package/dist/src/code-execution/runtime-py.d.ts +3 -2
- package/dist/src/code-execution/runtime-py.d.ts.map +1 -1
- package/dist/src/code-execution/runtime-py.js +94 -8
- package/dist/src/code-execution/runtime-py.js.map +1 -1
- package/dist/src/code-execution/tool-definition.d.ts +17 -1
- package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
- package/dist/src/code-execution/tool-definition.js +72 -6
- 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 +56 -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 +1529 -165
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +8264 -1939
- 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 +36 -5
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/held-writes.d.ts +16 -0
- package/dist/src/held-writes.d.ts.map +1 -0
- package/dist/src/held-writes.js +56 -0
- package/dist/src/held-writes.js.map +1 -0
- package/dist/src/index.d.ts +10 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/capability-grant.d.ts +4 -0
- package/dist/src/mcpl/capability-grant.d.ts.map +1 -1
- package/dist/src/mcpl/capability-grant.js +1 -1
- package/dist/src/mcpl/capability-grant.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +233 -18
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +975 -386
- 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 +88 -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/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 +7 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +5 -1
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +19 -13
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +155 -87
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/log-value.d.ts +7 -0
- package/dist/src/mcpl/log-value.d.ts.map +1 -1
- package/dist/src/mcpl/log-value.js +9 -0
- package/dist/src/mcpl/log-value.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts +227 -0
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -0
- package/dist/src/mcpl/modern-connection.js +1088 -0
- package/dist/src/mcpl/modern-connection.js.map +1 -0
- package/dist/src/mcpl/prefix-rule.d.ts +18 -0
- package/dist/src/mcpl/prefix-rule.d.ts.map +1 -0
- package/dist/src/mcpl/prefix-rule.js +25 -0
- package/dist/src/mcpl/prefix-rule.js.map +1 -0
- package/dist/src/mcpl/protocol-family.d.ts +179 -0
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -0
- package/dist/src/mcpl/protocol-family.js +697 -0
- package/dist/src/mcpl/protocol-family.js.map +1 -0
- package/dist/src/mcpl/push-coalescer.d.ts +58 -17
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +93 -32
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +16 -9
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js +18 -83
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +76 -13
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +275 -66
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +98 -18
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +170 -32
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +406 -31
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +1331 -272
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/server-registry.d.ts +35 -6
- package/dist/src/mcpl/server-registry.d.ts.map +1 -1
- package/dist/src/mcpl/server-registry.js +63 -13
- 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-result-normalize.d.ts +54 -0
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -0
- package/dist/src/mcpl/tool-result-normalize.js +232 -0
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -0
- package/dist/src/mcpl/transport.d.ts +104 -12
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +315 -85
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +76 -19
- 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 +16 -0
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +26 -0
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +34 -6
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +119 -31
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/api/index.d.ts +1 -1
- package/dist/src/modules/api/index.d.ts.map +1 -1
- package/dist/src/modules/api/index.js +3 -2
- package/dist/src/modules/api/index.js.map +1 -1
- package/dist/src/modules/discord/discord-js-client.d.ts +43 -2
- package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
- package/dist/src/modules/discord/discord-js-client.js +286 -67
- package/dist/src/modules/discord/discord-js-client.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts +53 -5
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +712 -186
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/discord/refusal.d.ts +14 -0
- package/dist/src/modules/discord/refusal.d.ts.map +1 -0
- package/dist/src/modules/discord/refusal.js +14 -0
- package/dist/src/modules/discord/refusal.js.map +1 -0
- package/dist/src/modules/discord/types.d.ts +27 -4
- 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 +8 -3
- 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/index.d.ts +1 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.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/disk-agreement.d.ts +57 -4
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +75 -7
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +66 -7
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +303 -46
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +313 -45
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +1404 -304
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +315 -16
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +727 -37
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +58 -7
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +521 -56
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +28 -5
- 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 +49 -2
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js +158 -29
- package/dist/src/modules/workspace/watcher.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/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 +3 -1
- package/dist/src/recovery/offline-branch.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/silent-heartbeat.d.ts +112 -39
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js +100 -29
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/tool-args.d.ts +40 -0
- package/dist/src/tool-args.d.ts.map +1 -0
- package/dist/src/tool-args.js +207 -0
- package/dist/src/tool-args.js.map +1 -0
- 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 +266 -62
- 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/types/agent.d.ts +44 -22
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +25 -0
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +38 -7
- 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 +77 -14
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +97 -8
- 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 +5 -4
- package/src/agent.ts +257 -72
- package/src/api/mcp-server-core.ts +1 -1
- package/src/api/server.ts +4 -1
- package/src/api/types.ts +1 -1
- package/src/branch-names.ts +19 -0
- package/src/closest-names.ts +94 -0
- package/src/code-execution/index.ts +1 -0
- package/src/code-execution/py-runner.ts +304 -93
- package/src/code-execution/runtime-py.ts +94 -8
- package/src/code-execution/tool-definition.ts +85 -7
- package/src/config-checks.ts +50 -0
- package/src/deadline-timer.ts +44 -0
- package/src/error-message.ts +48 -0
- package/src/framework.ts +8625 -1984
- package/src/gate/event-gate.ts +38 -5
- package/src/held-writes.ts +59 -0
- package/src/index.ts +29 -5
- package/src/mcpl/capability-grant.ts +1 -1
- package/src/mcpl/channel-registry.ts +1095 -411
- package/src/mcpl/checkpoint-manager.ts +104 -29
- package/src/mcpl/conversation-router.ts +28 -8
- package/src/mcpl/convert-block.ts +105 -0
- package/src/mcpl/errors.ts +28 -0
- package/src/mcpl/hook-orchestrator.ts +84 -77
- package/src/mcpl/inbound-source.ts +156 -0
- package/src/mcpl/index.ts +23 -1
- package/src/mcpl/inference-router.ts +179 -103
- package/src/mcpl/log-value.ts +10 -0
- package/src/mcpl/modern-connection.ts +1182 -0
- package/src/mcpl/prefix-rule.ts +32 -0
- package/src/mcpl/protocol-family.ts +691 -0
- package/src/mcpl/push-coalescer.ts +110 -36
- package/src/mcpl/push-handler.ts +20 -90
- package/src/mcpl/reference-fetcher.ts +318 -67
- package/src/mcpl/references.ts +183 -34
- package/src/mcpl/server-connection.ts +1404 -280
- package/src/mcpl/server-registry.ts +63 -14
- package/src/mcpl/skip-reply-wake.ts +73 -0
- package/src/mcpl/tool-result-normalize.ts +294 -0
- package/src/mcpl/transport.ts +320 -76
- package/src/mcpl/types.ts +77 -19
- package/src/mcpl/visible-content.ts +28 -0
- package/src/module-registry.ts +126 -36
- package/src/modules/api/index.ts +3 -2
- package/src/modules/discord/discord-js-client.ts +306 -74
- package/src/modules/discord/index.ts +737 -201
- package/src/modules/discord/refusal.ts +13 -0
- package/src/modules/discord/types.ts +27 -6
- package/src/modules/health/index.ts +8 -3
- package/src/modules/history/index.ts +410 -120
- package/src/modules/history/semantic.ts +189 -32
- package/src/modules/index.ts +1 -1
- package/src/modules/unknown-tool.ts +16 -0
- package/src/modules/workspace/disk-agreement.ts +97 -8
- package/src/modules/workspace/effects.ts +291 -36
- package/src/modules/workspace/index.ts +1469 -321
- package/src/modules/workspace/observe.ts +784 -41
- package/src/modules/workspace/reconcile.ts +619 -64
- package/src/modules/workspace/types.ts +28 -5
- package/src/modules/workspace/watcher.ts +154 -30
- package/src/prose-drafts.ts +481 -0
- package/src/prose-segments.ts +51 -8
- package/src/recovery/offline-branch.ts +4 -1
- package/src/safe-slice.ts +9 -1
- package/src/silent-heartbeat.ts +184 -59
- package/src/tool-args.ts +213 -0
- package/src/tool-image-ledger.ts +153 -34
- package/src/tool-presentation.ts +233 -42
- 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 +44 -24
- package/src/types/events.ts +25 -0
- package/src/types/framework.ts +38 -7
- package/src/types/inference-log.ts +1 -1
- package/src/types/module.ts +79 -14
- package/src/types/trace.ts +103 -8
- 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 -1598
- 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 -621
- 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 -371
- 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/discord-typing-keepalive.test.d.ts +0 -2
- package/dist/test/discord-typing-keepalive.test.d.ts.map +0 -1
- package/dist/test/discord-typing-keepalive.test.js +0 -77
- package/dist/test/discord-typing-keepalive.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 -1715
- 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 -74
- package/dist/test/helpers/coalescing-fixture.d.ts.map +0 -1
- package/dist/test/helpers/coalescing-fixture.js +0 -152
- 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/hide-then-turn.test.d.ts +0 -2
- package/dist/test/hide-then-turn.test.d.ts.map +0 -1
- package/dist/test/hide-then-turn.test.js +0 -101
- package/dist/test/hide-then-turn.test.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 -988
- 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 -387
- 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 -1202
- 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 -1827
- package/dist/test/maintenance-timer.test.js.map +0 -1
- package/dist/test/mcp-server-bin.test.d.ts +0 -2
- package/dist/test/mcp-server-bin.test.d.ts.map +0 -1
- package/dist/test/mcp-server-bin.test.js +0 -142
- package/dist/test/mcp-server-bin.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-coalesced-content-parity.test.d.ts +0 -2
- package/dist/test/mcpl-coalesced-content-parity.test.d.ts.map +0 -1
- package/dist/test/mcpl-coalesced-content-parity.test.js +0 -532
- package/dist/test/mcpl-coalesced-content-parity.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 -238
- 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-rejection-log-lines.test.d.ts +0 -2
- package/dist/test/mcpl-rejection-log-lines.test.d.ts.map +0 -1
- package/dist/test/mcpl-rejection-log-lines.test.js +0 -349
- package/dist/test/mcpl-rejection-log-lines.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-stderr-tail.test.d.ts +0 -2
- package/dist/test/mcpl-stderr-tail.test.d.ts.map +0 -1
- package/dist/test/mcpl-stderr-tail.test.js +0 -210
- package/dist/test/mcpl-stderr-tail.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-transport-close.test.d.ts +0 -2
- package/dist/test/mcpl-transport-close.test.d.ts.map +0 -1
- package/dist/test/mcpl-transport-close.test.js +0 -373
- package/dist/test/mcpl-transport-close.test.js.map +0 -1
- package/dist/test/mcpl-transport-spawn.test.d.ts +0 -2
- package/dist/test/mcpl-transport-spawn.test.d.ts.map +0 -1
- package/dist/test/mcpl-transport-spawn.test.js +0 -58
- package/dist/test/mcpl-transport-spawn.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 -259
- 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 -570
- 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 -595
- 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 -198
- package/dist/test/overbudget-drain-breaker.test.js.map +0 -1
- package/dist/test/pack-installs-alone.test.d.ts +0 -2
- package/dist/test/pack-installs-alone.test.d.ts.map +0 -1
- package/dist/test/pack-installs-alone.test.js +0 -284
- package/dist/test/pack-installs-alone.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 -16
- package/dist/test/physical-window-restart.test.d.ts.map +0 -1
- package/dist/test/physical-window-restart.test.js +0 -487
- 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 -1649
- 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 -2259
- 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 -226
- 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 -117
- 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-bump.test.d.ts +0 -2
- package/dist/test/release-bump.test.d.ts.map +0 -1
- package/dist/test/release-bump.test.js +0 -248
- package/dist/test/release-bump.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/release-holds.test.d.ts +0 -2
- package/dist/test/release-holds.test.d.ts.map +0 -1
- package/dist/test/release-holds.test.js +0 -456
- package/dist/test/release-holds.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-host-operations.test.d.ts +0 -20
- package/dist/test/stop-with-host-operations.test.d.ts.map +0 -1
- package/dist/test/stop-with-host-operations.test.js +0 -1174
- package/dist/test/stop-with-host-operations.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 -784
- 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 -3729
- 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 -652
- 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/unsent-compiles.test.d.ts +0 -2
- package/dist/test/unsent-compiles.test.d.ts.map +0 -1
- package/dist/test/unsent-compiles.test.js +0 -139
- package/dist/test/unsent-compiles.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 -4094
- 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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Held prose drafts: a resident's plain speech that was not sent.
|
|
3
|
+
*
|
|
4
|
+
* Plain speech is held back for reasons that are right in themselves: an
|
|
5
|
+
* explicit send in the same round suppresses the round's prose (so a "sent
|
|
6
|
+
* it" postscript is not posted twice), a turn may have no destination, and a
|
|
7
|
+
* malformed or unresolvable routing prefix bounces. Before drafts, the held words were
|
|
8
|
+
* kept only as a count (or, in explicit mode, as one in-memory latest-wins
|
|
9
|
+
* clipboard): the law was right, and the penalty was amnesia. A draft keeps
|
|
10
|
+
* the exact words until the resident resends or dismisses them, or the
|
|
11
|
+
* retention below lets it go.
|
|
12
|
+
*
|
|
13
|
+
* The boundary is publication and agency, not visibility: a draft is never
|
|
14
|
+
* published except by its resident's explicit resend (or `{{unsent}}`), and
|
|
15
|
+
* only that resident can list or act on it. Its notices go into the
|
|
16
|
+
* resident's own history — which residents that share one message slot
|
|
17
|
+
* (#197) share, as they already share the assistant turn the words came
|
|
18
|
+
* from.
|
|
19
|
+
*
|
|
20
|
+
* Durability is outside the conversation. Drafts live in a RecordJournal of
|
|
21
|
+
* typed Chronicle records, which do not follow branch switches: undo,
|
|
22
|
+
* rollback, suppression and branch moves never touch them. A draft written
|
|
23
|
+
* in a turn that is later undone stays usable (the words were genuinely
|
|
24
|
+
* written and held back), and a delivered draft stays delivered. The
|
|
25
|
+
* notices that name a draft are conversation, so they do follow the branch: a draft counts as
|
|
26
|
+
* named while a message naming it is on the current branch, and one a
|
|
27
|
+
* rollback or branch move has left unnamed is named again.
|
|
28
|
+
*
|
|
29
|
+
* Drafts are kept, not hoarded. Each resident's KEEP_NEWEST newest drafts
|
|
30
|
+
* are always kept; an older one, in any state, is let go at the journal's
|
|
31
|
+
* next checkpoint once nothing has happened to it (held, named, attempted,
|
|
32
|
+
* answered, dismissed) for KEEP_IDLE_MS. The journal checkpoints what it
|
|
33
|
+
* keeps every CHECKPOINT_EVERY entries, so opening it replays only what came
|
|
34
|
+
* after, and a resident whose drafts change rarely keeps its older ones
|
|
35
|
+
* until then. The words stay in the resident's history either way.
|
|
36
|
+
*
|
|
37
|
+
* A delivery attempt is journaled durably BEFORE its request leaves the
|
|
38
|
+
* host, and its outcome after: an attempt with no recorded outcome (a crash
|
|
39
|
+
* mid-send) reads as unknown, never as unsent. A delivered draft carries a
|
|
40
|
+
* historical receipt — confirmed at a time, to a destination, with the
|
|
41
|
+
* connector's message id when it names one — not a claim that the message
|
|
42
|
+
* still exists. A draft is sent only by its resident's explicit resend or
|
|
43
|
+
* an envelope's {{unsent}}; nothing replays at boot or on a branch move.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
import { randomInt } from 'node:crypto';
|
|
47
|
+
import type { JsStore } from '@animalabs/chronicle';
|
|
48
|
+
import { RecordJournal } from './record-journal.js';
|
|
49
|
+
import type { PublishDestination, PublishOutcome } from './mcpl/channel-registry.js';
|
|
50
|
+
|
|
51
|
+
/** Chronicle record type of the drafts journal. */
|
|
52
|
+
export const PROSE_DRAFT_RECORD_TYPE = 'framework/prose-draft';
|
|
53
|
+
|
|
54
|
+
/** Why words were held instead of sent. */
|
|
55
|
+
export type DraftReason =
|
|
56
|
+
/** An explicit send in the same round suppressed the round's plain speech. */
|
|
57
|
+
| 'explicit-send'
|
|
58
|
+
/** The speech had no destination (no route this turn, or a failed envelope). */
|
|
59
|
+
| 'no-destination'
|
|
60
|
+
/** An explicit/hybrid routing prefix was missing, malformed or unresolvable. */
|
|
61
|
+
| 'bounced';
|
|
62
|
+
|
|
63
|
+
export interface DraftAttemptOutcome {
|
|
64
|
+
status: PublishOutcome['status'];
|
|
65
|
+
at: number;
|
|
66
|
+
messageId?: string;
|
|
67
|
+
reason?: string;
|
|
68
|
+
detail?: unknown;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface DraftAttempt {
|
|
72
|
+
attemptId: string;
|
|
73
|
+
at: number;
|
|
74
|
+
destination: PublishDestination;
|
|
75
|
+
/** How the words went out: the drafts tool, or a `{{unsent}}` envelope (explicit or hybrid). */
|
|
76
|
+
via: 'resend' | 'unsent-token';
|
|
77
|
+
/** The resident resent knowing an earlier attempt may have been posted. */
|
|
78
|
+
confirmedDuplicate?: true;
|
|
79
|
+
/** Absent until recorded; an attempt without one reads as unknown. */
|
|
80
|
+
outcome?: DraftAttemptOutcome;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A draft held with words copied from another draft that may already have
|
|
85
|
+
* been posted (`{{unsent}}` re-bounced while that draft was unconfirmed or in
|
|
86
|
+
* flight). The new draft keeps the whole authored text and carries the same
|
|
87
|
+
* duplication risk: it reads `unconfirmed` until a confirmed delivery.
|
|
88
|
+
*/
|
|
89
|
+
export interface InheritedRisk {
|
|
90
|
+
/** The draft whose words were copied in. */
|
|
91
|
+
draftId: string;
|
|
92
|
+
/** The draft whose attempt is the uncertain one, when the copied draft
|
|
93
|
+
* itself carried inherited risk (a chain of re-bounces): the evidence is
|
|
94
|
+
* that original attempt's, never re-invented. */
|
|
95
|
+
sourceDraftId?: string;
|
|
96
|
+
/** That uncertain attempt, when there was one (absent: it was in flight). */
|
|
97
|
+
destination?: PublishDestination;
|
|
98
|
+
at?: number;
|
|
99
|
+
reason: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface Draft {
|
|
103
|
+
id: string;
|
|
104
|
+
agent: string;
|
|
105
|
+
/** The held words, byte for byte as a resend publishes them: a run an
|
|
106
|
+
* explicit send suppressed exactly as written; a bounce or a hold with no
|
|
107
|
+
* destination, its envelope as routing read it (surrounding whitespace
|
|
108
|
+
* trimmed). */
|
|
109
|
+
text: string;
|
|
110
|
+
reason: DraftReason;
|
|
111
|
+
/** Words copied in from a draft that may already have been posted. */
|
|
112
|
+
inheritedRisk?: InheritedRisk;
|
|
113
|
+
/** Short context for the resident: the bounce reason, or the competing conversations. */
|
|
114
|
+
note?: string;
|
|
115
|
+
heldAt: number;
|
|
116
|
+
attempts: DraftAttempt[];
|
|
117
|
+
dismissedAt?: number;
|
|
118
|
+
/** The messages whose notices named this draft, by id. It counts as named
|
|
119
|
+
* while one of them is on the current branch. */
|
|
120
|
+
noticedIn?: string[];
|
|
121
|
+
/** When a notice last named it. */
|
|
122
|
+
noticedAt?: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* - `held`: no inherited risk, and never attempted or every attempt
|
|
127
|
+
* definitely failed — resend freely;
|
|
128
|
+
* - `unconfirmed`: no attempt was confirmed and the draft is not dismissed;
|
|
129
|
+
* either an attempt's outcome is unknown (or was never recorded), or the
|
|
130
|
+
* words carry inherited risk regardless of their own attempts. A resend
|
|
131
|
+
* needs explicit confirmation. A later attempt that fails does not resolve
|
|
132
|
+
* an earlier one that may have landed — the uncertainty stays;
|
|
133
|
+
* - `delivered`: an attempt was confirmed — its receipt is historical;
|
|
134
|
+
* - `dismissed`: the resident set it aside.
|
|
135
|
+
*/
|
|
136
|
+
export type DraftState = 'held' | 'unconfirmed' | 'delivered' | 'dismissed';
|
|
137
|
+
|
|
138
|
+
export function draftState(draft: Draft): DraftState {
|
|
139
|
+
if (draft.attempts.some((a) => a.outcome?.status === 'delivered')) return 'delivered';
|
|
140
|
+
if (draft.dismissedAt !== undefined) return 'dismissed';
|
|
141
|
+
return uncertainAttempt(draft) || draft.inheritedRisk ? 'unconfirmed' : 'held';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The most recent attempt that may have been posted (unknown or unrecorded
|
|
145
|
+
* outcome), when no attempt was confirmed. */
|
|
146
|
+
export function uncertainAttempt(draft: Draft): DraftAttempt | undefined {
|
|
147
|
+
if (draft.attempts.some((a) => a.outcome?.status === 'delivered')) return undefined;
|
|
148
|
+
for (let i = draft.attempts.length - 1; i >= 0; i--) {
|
|
149
|
+
const attempt = draft.attempts[i]!;
|
|
150
|
+
if (!attempt.outcome || attempt.outcome.status === 'unknown') return attempt;
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
type DraftEntry =
|
|
156
|
+
| { op: 'held'; draft: Omit<Draft, 'attempts' | 'dismissedAt' | 'noticedIn' | 'noticedAt'> }
|
|
157
|
+
| { op: 'attempt'; agent: string; id: string; attemptId: string; at: number; destination: PublishDestination; via: DraftAttempt['via']; confirmedDuplicate?: true }
|
|
158
|
+
| { op: 'outcome'; agent: string; id: string; attemptId: string; outcome: DraftAttemptOutcome }
|
|
159
|
+
| { op: 'dismissed'; agent: string; id: string; at: number }
|
|
160
|
+
/** A notice naming these drafts is in the history as message `messageId`.
|
|
161
|
+
* (A record without one names nowhere the drafts can be found again, so
|
|
162
|
+
* they are named once more.) */
|
|
163
|
+
| { op: 'noticed'; agent: string; ids: string[]; at: number; messageId?: string };
|
|
164
|
+
|
|
165
|
+
/** What a checkpoint keeps: every kept draft, in hold order, and each
|
|
166
|
+
* resident's latest bounce, which `{{unsent}}` means whatever became of it. */
|
|
167
|
+
interface DraftSnapshot {
|
|
168
|
+
v: 1;
|
|
169
|
+
drafts: Draft[];
|
|
170
|
+
latestBounces: Record<string, string>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Unambiguous lowercase alphabet for short ids (no i/l/o/0/1). */
|
|
174
|
+
const ID_ALPHABET = 'abcdefghjkmnpqrstuvwxyz23456789';
|
|
175
|
+
/**
|
|
176
|
+
* Characters after `d-` in a draft's id: 31^7, about 2.75 × 10^10 ids, so a
|
|
177
|
+
* mistyped id almost never names a real draft, and an id retention let go is
|
|
178
|
+
* given again only rarely (see newId).
|
|
179
|
+
*/
|
|
180
|
+
const ID_LENGTH = 7;
|
|
181
|
+
|
|
182
|
+
/** Each resident's newest drafts, by hold order, that are always kept. */
|
|
183
|
+
export const KEEP_NEWEST = 100;
|
|
184
|
+
/** How long an older draft is kept after the last thing that happened to it. */
|
|
185
|
+
export const KEEP_IDLE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
186
|
+
/** Entries the journal takes between checkpoints. */
|
|
187
|
+
export const CHECKPOINT_EVERY = 500;
|
|
188
|
+
|
|
189
|
+
/** The store's retention, KEEP_NEWEST, KEEP_IDLE_MS and CHECKPOINT_EVERY
|
|
190
|
+
* unless given (tests give smaller ones). */
|
|
191
|
+
export interface DraftRetention {
|
|
192
|
+
keepNewest: number;
|
|
193
|
+
keepIdleMs: number;
|
|
194
|
+
checkpointEvery: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The last time anything happened to a draft: held, named, attempted,
|
|
198
|
+
* answered or dismissed. */
|
|
199
|
+
function lastActivity(draft: Draft): number {
|
|
200
|
+
let last = Math.max(draft.heldAt, draft.noticedAt ?? 0, draft.dismissedAt ?? 0);
|
|
201
|
+
for (const attempt of draft.attempts) last = Math.max(last, attempt.at, attempt.outcome?.at ?? 0);
|
|
202
|
+
return last;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class ProseDraftStore {
|
|
206
|
+
private readonly journal: RecordJournal<DraftEntry, DraftSnapshot>;
|
|
207
|
+
/** agent → draft id → draft, in journal (hold) order. */
|
|
208
|
+
private drafts = new Map<string, Map<string, Draft>>();
|
|
209
|
+
/** agent → the id of its latest bounce, kept or not. */
|
|
210
|
+
private latestBounces = new Map<string, string>();
|
|
211
|
+
private readonly retention: DraftRetention;
|
|
212
|
+
|
|
213
|
+
constructor(store: JsStore, retention: Partial<DraftRetention> = {}) {
|
|
214
|
+
this.journal = new RecordJournal<DraftEntry, DraftSnapshot>(store, { type: PROSE_DRAFT_RECORD_TYPE });
|
|
215
|
+
this.retention = {
|
|
216
|
+
keepNewest: retention.keepNewest ?? KEEP_NEWEST,
|
|
217
|
+
keepIdleMs: retention.keepIdleMs ?? KEEP_IDLE_MS,
|
|
218
|
+
checkpointEvery: retention.checkpointEvery ?? CHECKPOINT_EVERY,
|
|
219
|
+
};
|
|
220
|
+
this.reload();
|
|
221
|
+
this.checkpointIfDue();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Rebuild the projection from the journal (at open, and to reconcile):
|
|
225
|
+
* the latest checkpoint's drafts, then the entries after it. */
|
|
226
|
+
reload(): void {
|
|
227
|
+
const { snapshot, entries } = this.journal.load();
|
|
228
|
+
this.drafts = new Map();
|
|
229
|
+
this.latestBounces = new Map(Object.entries(snapshot?.latestBounces ?? {}));
|
|
230
|
+
for (const draft of snapshot?.drafts ?? []) this.agentDrafts(draft.agent).set(draft.id, draft);
|
|
231
|
+
for (const { entry } of entries) this.reduce(entry);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Write a checkpoint once CHECKPOINT_EVERY entries have been appended since
|
|
236
|
+
* the last one, letting go of the drafts that aren't kept (see the module
|
|
237
|
+
* header). The projection drops them only once the checkpoint is written,
|
|
238
|
+
* so a failed one changes nothing, and the next write tries again.
|
|
239
|
+
*/
|
|
240
|
+
private checkpointIfDue(): void {
|
|
241
|
+
const { keepNewest, keepIdleMs, checkpointEvery } = this.retention;
|
|
242
|
+
if (this.journal.entriesSinceCheckpoint < checkpointEvery) return;
|
|
243
|
+
const now = Date.now();
|
|
244
|
+
const kept = new Map<string, Map<string, Draft>>();
|
|
245
|
+
for (const [agent, drafts] of this.drafts) {
|
|
246
|
+
const all = [...drafts.values()];
|
|
247
|
+
const keep = new Map<string, Draft>();
|
|
248
|
+
all.forEach((draft, i) => {
|
|
249
|
+
if (i >= all.length - keepNewest || now - lastActivity(draft) < keepIdleMs) keep.set(draft.id, draft);
|
|
250
|
+
});
|
|
251
|
+
if (keep.size > 0) kept.set(agent, keep);
|
|
252
|
+
}
|
|
253
|
+
const snapshot: DraftSnapshot = {
|
|
254
|
+
v: 1,
|
|
255
|
+
drafts: [...kept.values()].flatMap((m) => [...m.values()]),
|
|
256
|
+
latestBounces: Object.fromEntries(this.latestBounces),
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
this.journal.checkpoint(snapshot);
|
|
260
|
+
} catch (err) {
|
|
261
|
+
console.error('[drafts] checkpoint failed; the next write tries again:', err);
|
|
262
|
+
if (this.journal.needsReconcile) this.reload();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.drafts = kept;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private reduce(entry: DraftEntry): void {
|
|
269
|
+
if (entry.op === 'held') {
|
|
270
|
+
this.agentDrafts(entry.draft.agent).set(entry.draft.id, { ...entry.draft, attempts: [] });
|
|
271
|
+
if (entry.draft.reason === 'bounced') this.latestBounces.set(entry.draft.agent, entry.draft.id);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (entry.op === 'noticed') {
|
|
275
|
+
if (entry.messageId === undefined) return;
|
|
276
|
+
for (const id of entry.ids) {
|
|
277
|
+
const draft = this.drafts.get(entry.agent)?.get(id);
|
|
278
|
+
if (!draft) continue;
|
|
279
|
+
draft.noticedIn ??= [];
|
|
280
|
+
if (!draft.noticedIn.includes(entry.messageId)) draft.noticedIn.push(entry.messageId);
|
|
281
|
+
draft.noticedAt = Math.max(draft.noticedAt ?? 0, entry.at);
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const draft = this.drafts.get(entry.agent)?.get(entry.id);
|
|
286
|
+
if (!draft) return;
|
|
287
|
+
if (entry.op === 'dismissed') {
|
|
288
|
+
draft.dismissedAt ??= entry.at;
|
|
289
|
+
} else if (entry.op === 'attempt') {
|
|
290
|
+
draft.attempts.push({
|
|
291
|
+
attemptId: entry.attemptId,
|
|
292
|
+
at: entry.at,
|
|
293
|
+
destination: entry.destination,
|
|
294
|
+
via: entry.via,
|
|
295
|
+
...(entry.confirmedDuplicate ? { confirmedDuplicate: true as const } : {}),
|
|
296
|
+
});
|
|
297
|
+
} else if (entry.op === 'outcome') {
|
|
298
|
+
const attempt = draft.attempts.find((a) => a.attemptId === entry.attemptId);
|
|
299
|
+
if (attempt) attempt.outcome = entry.outcome;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Journal and apply one entry. A write that fails after the store's append
|
|
305
|
+
* returned leaves the journal unreconciled: rebuild from it before
|
|
306
|
+
* rethrowing, so the projection never disagrees with what the journal
|
|
307
|
+
* holds. An append that fails inside the store can't be read back until
|
|
308
|
+
* the store is reopened: the journal then refuses every write until the
|
|
309
|
+
* next start, which replays that entry, so until then each write throws,
|
|
310
|
+
* no new draft is kept, and the projection lacks that entry.
|
|
311
|
+
*/
|
|
312
|
+
private write(entry: DraftEntry, durable: boolean, afterCommittedState = false): void {
|
|
313
|
+
try {
|
|
314
|
+
this.journal.append(entry, { durable, afterCommittedState });
|
|
315
|
+
} catch (err) {
|
|
316
|
+
if (this.journal.needsReconcile) this.reload();
|
|
317
|
+
throw err;
|
|
318
|
+
}
|
|
319
|
+
this.reduce(entry);
|
|
320
|
+
this.checkpointIfDue();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private agentDrafts(agent: string): Map<string, Draft> {
|
|
324
|
+
let map = this.drafts.get(agent);
|
|
325
|
+
if (!map) {
|
|
326
|
+
map = new Map();
|
|
327
|
+
this.drafts.set(agent, map);
|
|
328
|
+
}
|
|
329
|
+
return map;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** A new id, unique among the resident's kept drafts and never its latest
|
|
333
|
+
* bounce's. One that retention let go can be given again: after N more
|
|
334
|
+
* of its resident's drafts, a given let-go id has come back with a
|
|
335
|
+
* probability of about N in 2.75 × 10^10 (ID_LENGTH), and a request naming
|
|
336
|
+
* it then reaches the newer draft rather than being refused. */
|
|
337
|
+
private newId(agent: string): string {
|
|
338
|
+
const existing = this.agentDrafts(agent);
|
|
339
|
+
const latestBounce = this.latestBounces.get(agent);
|
|
340
|
+
for (;;) {
|
|
341
|
+
let id = 'd-';
|
|
342
|
+
for (let i = 0; i < ID_LENGTH; i++) id += ID_ALPHABET[randomInt(ID_ALPHABET.length)];
|
|
343
|
+
if (!existing.has(id) && id !== latestBounce) return id;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Hold words as drafts, in order, each journaled durably before this
|
|
349
|
+
* returns. If the journal refuses a write (after reconciling), the drafts
|
|
350
|
+
* already written stand and the rest are reported as not held: their words
|
|
351
|
+
* remain in the resident's history only. A draft whose record reached the
|
|
352
|
+
* store before its write failed (its sync did) is in the reconciled
|
|
353
|
+
* journal, so it is held, and counted so. When the store's append itself
|
|
354
|
+
* threw, the record may still be in its log: the draft is reported as not
|
|
355
|
+
* held, and the journal refuses further writes until a reload, which
|
|
356
|
+
* replays it as held if it is there.
|
|
357
|
+
*/
|
|
358
|
+
hold(
|
|
359
|
+
agent: string,
|
|
360
|
+
segments: Array<{ text: string; note?: string; inheritedRisk?: InheritedRisk }>,
|
|
361
|
+
reason: DraftReason,
|
|
362
|
+
note?: string,
|
|
363
|
+
): { held: Draft[]; notHeld?: { count: number; error: string } } {
|
|
364
|
+
const held: Draft[] = [];
|
|
365
|
+
for (let i = 0; i < segments.length; i++) {
|
|
366
|
+
const segment = segments[i]!;
|
|
367
|
+
const segmentNote = segment.note ?? note;
|
|
368
|
+
const draft = {
|
|
369
|
+
id: this.newId(agent),
|
|
370
|
+
agent,
|
|
371
|
+
text: segment.text,
|
|
372
|
+
reason,
|
|
373
|
+
...(segmentNote ? { note: segmentNote } : {}),
|
|
374
|
+
...(segment.inheritedRisk ? { inheritedRisk: segment.inheritedRisk } : {}),
|
|
375
|
+
heldAt: Date.now(),
|
|
376
|
+
};
|
|
377
|
+
try {
|
|
378
|
+
this.write({ op: 'held', draft }, true);
|
|
379
|
+
} catch (err) {
|
|
380
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
381
|
+
const landed = this.get(agent, draft.id);
|
|
382
|
+
if (landed) {
|
|
383
|
+
console.error(`[drafts] ${agent}: ${landed.id} reached the journal, but its write then failed (${error}); it is held`);
|
|
384
|
+
held.push(landed);
|
|
385
|
+
}
|
|
386
|
+
const count = segments.length - i - (landed ? 1 : 0);
|
|
387
|
+
return { held, ...(count > 0 ? { notHeld: { count, error } } : {}) };
|
|
388
|
+
}
|
|
389
|
+
held.push(this.get(agent, draft.id)!);
|
|
390
|
+
}
|
|
391
|
+
return { held };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
get(agent: string, id: string): Draft | undefined {
|
|
395
|
+
return this.drafts.get(agent)?.get(id);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Held and unconfirmed drafts, newest first (journal order, which is
|
|
399
|
+
* exact even for segments held in the same millisecond). */
|
|
400
|
+
open(agent: string): Draft[] {
|
|
401
|
+
return [...(this.drafts.get(agent)?.values() ?? [])]
|
|
402
|
+
.filter((d) => { const s = draftState(d); return s === 'held' || s === 'unconfirmed'; })
|
|
403
|
+
.reverse();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Open drafts, newest first, that no notice on the current branch names:
|
|
408
|
+
* none was recorded (a crash before the notice), or a rollback or branch
|
|
409
|
+
* move took away every message that named them. `onBranch` says whether a
|
|
410
|
+
* message, by id, is on the current branch.
|
|
411
|
+
*/
|
|
412
|
+
unnoticed(agent: string, onBranch: (messageId: string) => boolean): Draft[] {
|
|
413
|
+
return this.open(agent).filter((d) => !d.noticedIn?.some(onBranch));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Record that message `messageId`, a notice naming these drafts, is in the
|
|
418
|
+
* resident's history. The notice is conversation state, buffered until the
|
|
419
|
+
* store syncs, while this record reaches the OS at once: so the store is
|
|
420
|
+
* synced FIRST (afterCommittedState), and a notice that never became
|
|
421
|
+
* durable can't leave a record that suppresses the crash catch-up.
|
|
422
|
+
*/
|
|
423
|
+
markNoticed(agent: string, ids: string[], messageId: string): void {
|
|
424
|
+
if (ids.length === 0) return;
|
|
425
|
+
this.write({ op: 'noticed', agent, ids, at: Date.now(), messageId }, true, true);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
dismiss(agent: string, id: string): void {
|
|
429
|
+
this.write({ op: 'dismissed', agent, id, at: Date.now() }, true);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Journal a delivery attempt durably, BEFORE the request leaves the host.
|
|
434
|
+
* Throws (having reconciled) when it cannot be made durable: the caller
|
|
435
|
+
* must then not send.
|
|
436
|
+
*/
|
|
437
|
+
beginAttempt(
|
|
438
|
+
agent: string,
|
|
439
|
+
id: string,
|
|
440
|
+
destination: PublishDestination,
|
|
441
|
+
via: DraftAttempt['via'],
|
|
442
|
+
confirmedDuplicate: boolean,
|
|
443
|
+
): string {
|
|
444
|
+
const attemptId = `a-${Date.now().toString(36)}-${randomInt(36 ** 4).toString(36)}`;
|
|
445
|
+
this.write({
|
|
446
|
+
op: 'attempt', agent, id, attemptId, at: Date.now(), destination, via,
|
|
447
|
+
...(confirmedDuplicate ? { confirmedDuplicate: true as const } : {}),
|
|
448
|
+
}, true);
|
|
449
|
+
return attemptId;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** Journal what an attempt established. */
|
|
453
|
+
recordOutcome(agent: string, id: string, attemptId: string, outcome: PublishOutcome): void {
|
|
454
|
+
this.write({
|
|
455
|
+
op: 'outcome', agent, id, attemptId,
|
|
456
|
+
outcome: {
|
|
457
|
+
status: outcome.status,
|
|
458
|
+
at: outcome.at,
|
|
459
|
+
...(outcome.messageId ? { messageId: outcome.messageId } : {}),
|
|
460
|
+
...(outcome.reason ? { reason: outcome.reason } : {}),
|
|
461
|
+
...(outcome.detail !== undefined ? { detail: outcome.detail } : {}),
|
|
462
|
+
},
|
|
463
|
+
}, true);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Explicit and hybrid mode's `{{unsent}}`: the most recent bounce, while
|
|
468
|
+
* that draft is still open (held or unconfirmed — the caller must not
|
|
469
|
+
* resend an unconfirmed one without the resident's confirmation).
|
|
470
|
+
* Latest-wins, like the clipboard it replaces: once the latest bounce is
|
|
471
|
+
* delivered, dismissed or let go there is nothing to substitute, even if
|
|
472
|
+
* older bounces are still held (they stay in the collection, by id).
|
|
473
|
+
*/
|
|
474
|
+
latestBounce(agent: string): Draft | undefined {
|
|
475
|
+
const id = this.latestBounces.get(agent);
|
|
476
|
+
const latest = id === undefined ? undefined : this.get(agent, id);
|
|
477
|
+
if (!latest) return undefined;
|
|
478
|
+
const state = draftState(latest);
|
|
479
|
+
return state === 'held' || state === 'unconfirmed' ? latest : undefined;
|
|
480
|
+
}
|
|
481
|
+
}
|
package/src/prose-segments.ts
CHANGED
|
@@ -10,26 +10,40 @@
|
|
|
10
10
|
* collapsing those distinct messages into one (item 4). This helper instead
|
|
11
11
|
* yields each contiguous run of text — the segments a surface should deliver as
|
|
12
12
|
* separate, ordered messages. Contiguous text blocks merge into one segment;
|
|
13
|
-
* `tool_use` / `tool_result` blocks are segment boundaries
|
|
13
|
+
* `tool_use` / `tool_result` blocks are segment boundaries, as are XML tool
|
|
14
|
+
* mode's `tool_attempt` / `tool_notice` (a refused attempt and the harness's
|
|
15
|
+
* notice end a round just as a call and its results do); empty or
|
|
14
16
|
* whitespace-only runs are dropped.
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
import type { ContentBlock } from '@animalabs/membrane';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The runs exactly as written: contiguous text blocks joined with a newline,
|
|
23
|
+
* nothing trimmed. Whitespace-only runs are dropped. Held drafts keep these,
|
|
24
|
+
* so a draft's words (indentation included) are the resident's own, byte for
|
|
25
|
+
* byte; speech routes each run trimmed of surrounding whitespace.
|
|
26
|
+
*/
|
|
27
|
+
export function splitProseRuns(content: readonly ContentBlock[]): string[] {
|
|
28
|
+
const runs: string[] = [];
|
|
21
29
|
let buf: string[] = [];
|
|
22
30
|
|
|
23
31
|
const flush = (): void => {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
32
|
+
const run = buf.join('\n');
|
|
33
|
+
if (run.trim()) runs.push(run);
|
|
26
34
|
buf = [];
|
|
27
35
|
};
|
|
28
36
|
|
|
29
37
|
for (const block of content) {
|
|
30
|
-
|
|
38
|
+
const type = block.type as string;
|
|
39
|
+
if (type === 'text') {
|
|
31
40
|
buf.push((block as ContentBlock & { type: 'text' }).text);
|
|
32
|
-
} else if (
|
|
41
|
+
} else if (
|
|
42
|
+
type === 'tool_use' ||
|
|
43
|
+
type === 'tool_result' ||
|
|
44
|
+
type === 'tool_attempt' ||
|
|
45
|
+
type === 'tool_notice'
|
|
46
|
+
) {
|
|
33
47
|
flush();
|
|
34
48
|
}
|
|
35
49
|
// Other block types (thinking, redacted_thinking, image, …) are neither
|
|
@@ -38,5 +52,34 @@ export function splitProseSegments(content: readonly ContentBlock[]): string[] {
|
|
|
38
52
|
}
|
|
39
53
|
flush();
|
|
40
54
|
|
|
41
|
-
return
|
|
55
|
+
return runs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A turn's content without the prose of some of its tool rounds, the turn's
|
|
60
|
+
* rounds counted from 0 in order. A round's prose is its text
|
|
61
|
+
* before its calls, and a round starts at the first block after the previous
|
|
62
|
+
* round's `tool_result` blocks. So a round with no prose still counts, two
|
|
63
|
+
* calls of one round (their `tool_use` blocks come before any result) stay
|
|
64
|
+
* one round, and a round is found by its place, whatever its text holds.
|
|
65
|
+
* Other rounds' text, every non-text block and the text after the last round
|
|
66
|
+
* stay.
|
|
67
|
+
*/
|
|
68
|
+
export function withoutRoundsProse(
|
|
69
|
+
content: readonly ContentBlock[],
|
|
70
|
+
rounds: ReadonlySet<number>,
|
|
71
|
+
): ContentBlock[] {
|
|
72
|
+
let round = 0;
|
|
73
|
+
let afterResults = false;
|
|
74
|
+
return content.filter((block) => {
|
|
75
|
+
if (block.type === 'tool_result') {
|
|
76
|
+
afterResults = true;
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (afterResults) {
|
|
80
|
+
round++;
|
|
81
|
+
afterResults = false;
|
|
82
|
+
}
|
|
83
|
+
return !(block.type === 'text' && rounds.has(round));
|
|
84
|
+
});
|
|
42
85
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JsStore } from '@animalabs/chronicle';
|
|
2
2
|
import { ContextManager, continuesBody, type BodyShard } from '@animalabs/context-manager';
|
|
3
3
|
import { removeStoredInterval } from '../stored-removal.js';
|
|
4
|
+
import { firstFreeBranchName } from '../branch-names.js';
|
|
4
5
|
import {
|
|
5
6
|
DEFAULT_DISCORD_AWARENESS_EMOJI,
|
|
6
7
|
DiscordAwarenessOutbox,
|
|
@@ -22,6 +23,7 @@ export interface OfflineRecoveryBranchOptions {
|
|
|
22
23
|
suppressMessageIds?: string[];
|
|
23
24
|
/** Inclusive context-order ranges between Discord message endpoints. */
|
|
24
25
|
suppressRanges?: Array<{ fromMessageId: string; toMessageId: string }>;
|
|
26
|
+
/** Defaults to `recovery/{agentName}/{ms}`, or with `-2`, `-3`, … appended when the store already holds that name. */
|
|
25
27
|
branchName?: string;
|
|
26
28
|
/** Defaults to the primary-agent namespace `agents/{agentName}`. */
|
|
27
29
|
namespace?: string;
|
|
@@ -161,8 +163,9 @@ export async function createOfflineRecoveryBranch(
|
|
|
161
163
|
refs = dedupeDiscordRefs([...refs, ...suppression.refs]);
|
|
162
164
|
|
|
163
165
|
const sourceBranch = store.currentBranch().name;
|
|
166
|
+
const held = new Set(store.listBranches().map((branch) => branch.name));
|
|
164
167
|
const targetBranch = options.branchName
|
|
165
|
-
?? `recovery/${options.agentName}/${Date.now()}
|
|
168
|
+
?? firstFreeBranchName(`recovery/${options.agentName}/${Date.now()}`, (name) => held.has(name));
|
|
166
169
|
if (targetBranch === sourceBranch) {
|
|
167
170
|
throw new Error('Recovery branch name must differ from the active source branch');
|
|
168
171
|
}
|
package/src/safe-slice.ts
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
* Slice a string without splitting surrogate pairs.
|
|
3
3
|
*
|
|
4
4
|
* Regular String.prototype.slice can cut in the middle of a surrogate pair,
|
|
5
|
-
* producing invalid UTF-16.
|
|
5
|
+
* producing invalid UTF-16. Here no half of a pair faces a cut: a start on a
|
|
6
|
+
* low surrogate moves forward past it, and an end just after a high surrogate
|
|
7
|
+
* moves back before it, whether or not the other half is there. A start of 0
|
|
8
|
+
* and an end at or past the length cut nothing, so the string's own first and
|
|
9
|
+
* last units stay as they are.
|
|
6
10
|
*/
|
|
7
11
|
export function safeSlice(str: string, start: number, end: number): string {
|
|
12
|
+
// A low surrogate where the start cuts is a pair's second half, or a lone half: either way, skip it
|
|
13
|
+
const first = str.charCodeAt(start);
|
|
14
|
+
if (start > 0 && first >= 0xdc00 && first <= 0xdfff) start += 1;
|
|
15
|
+
|
|
8
16
|
if (end >= str.length) return str.slice(start);
|
|
9
17
|
|
|
10
18
|
// If we're about to cut between a high and low surrogate, back up one char
|