@animalabs/agent-framework 0.26.2 → 0.28.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 +99 -8
- package/dist/src/agent.d.ts +291 -23
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +596 -61
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +5 -4
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +34 -0
- package/dist/src/auto-continue.d.ts.map +1 -0
- package/dist/src/auto-continue.js +36 -0
- package/dist/src/auto-continue.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +11 -0
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +5 -1
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/cut-off-round.d.ts +24 -0
- package/dist/src/cut-off-round.d.ts.map +1 -0
- package/dist/src/cut-off-round.js +87 -0
- package/dist/src/cut-off-round.js.map +1 -0
- package/dist/src/framework.d.ts +1038 -193
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +5967 -1514
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +405 -46
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +2646 -399
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +3 -2
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +2 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/recipe-reconcile.d.ts +103 -0
- package/dist/src/gate/recipe-reconcile.d.ts.map +1 -0
- package/dist/src/gate/recipe-reconcile.js +325 -0
- package/dist/src/gate/recipe-reconcile.js.map +1 -0
- package/dist/src/gate/reply-judge.d.ts +116 -0
- package/dist/src/gate/reply-judge.d.ts.map +1 -0
- package/dist/src/gate/reply-judge.js +467 -0
- package/dist/src/gate/reply-judge.js.map +1 -0
- package/dist/src/gate/types.d.ts +229 -8
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.d.ts +184 -0
- package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
- package/dist/src/heartbeat/heartbeat.js +752 -0
- package/dist/src/heartbeat/heartbeat.js.map +1 -0
- package/dist/src/heartbeat/reminder-time.d.ts +5 -0
- package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
- package/dist/src/heartbeat/reminder-time.js +107 -0
- package/dist/src/heartbeat/reminder-time.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 +7 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/capability-mask.d.ts.map +1 -1
- package/dist/src/mcpl/capability-mask.js +3 -2
- package/dist/src/mcpl/capability-mask.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +433 -113
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +1154 -435
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +16 -8
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +29 -15
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +14 -2
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts +7 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +32 -7
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +26 -10
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +40 -69
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +5 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +4 -0
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +14 -2
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +73 -28
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/prose-grammar.d.ts +4 -0
- package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
- package/dist/src/mcpl/prose-grammar.js +6 -0
- package/dist/src/mcpl/prose-grammar.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +3 -0
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +20 -2
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +33 -11
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +63 -42
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +177 -145
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +380 -46
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +736 -77
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +93 -4
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +176 -11
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tags.d.ts +9 -2
- package/dist/src/mcpl/tags.d.ts.map +1 -1
- package/dist/src/mcpl/tags.js +12 -2
- package/dist/src/mcpl/tags.js.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.d.ts +11 -0
- package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.js +21 -0
- package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts +311 -0
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -0
- package/dist/src/mcpl/tool-presence.js +697 -0
- package/dist/src/mcpl/tool-presence.js.map +1 -0
- package/dist/src/mcpl/tool-result-normalize.d.ts +9 -3
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.js +14 -6
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +46 -0
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -0
- package/dist/src/mcpl/tool-signature.js +321 -0
- package/dist/src/mcpl/tool-signature.js.map +1 -0
- package/dist/src/mcpl/toolset-host.d.ts +251 -0
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -0
- package/dist/src/mcpl/toolset-host.js +720 -0
- package/dist/src/mcpl/toolset-host.js.map +1 -0
- package/dist/src/mcpl/toolsets-module.d.ts +83 -0
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -0
- package/dist/src/mcpl/toolsets-module.js +523 -0
- package/dist/src/mcpl/toolsets-module.js.map +1 -0
- package/dist/src/mcpl/transport.d.ts +2 -2
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +3 -2
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +24 -2
- 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 +7 -9
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +21 -9
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +27 -9
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +77 -17
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.js +1 -1
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +2 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +73 -28
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +108 -6
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +273 -57
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/answers.d.ts +22 -0
- package/dist/src/modules/workspace/answers.d.ts.map +1 -0
- package/dist/src/modules/workspace/answers.js +123 -0
- package/dist/src/modules/workspace/answers.js.map +1 -0
- package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
- package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
- package/dist/src/modules/workspace/branch-intent.js +6 -2
- package/dist/src/modules/workspace/branch-intent.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts +184 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -0
- package/dist/src/modules/workspace/direct-write.js +417 -0
- package/dist/src/modules/workspace/direct-write.js.map +1 -0
- package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +48 -17
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/edit-text.d.ts +27 -12
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +61 -29
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +10 -0
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +21 -14
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +308 -78
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +2103 -720
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +75 -63
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +366 -180
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts +41 -0
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -0
- package/dist/src/modules/workspace/read-page.js +219 -0
- package/dist/src/modules/workspace/read-page.js.map +1 -0
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +26 -16
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/result-text.d.ts +68 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -0
- package/dist/src/modules/workspace/result-text.js +94 -0
- package/dist/src/modules/workspace/result-text.js.map +1 -0
- package/dist/src/modules/workspace/sync.d.ts +9 -0
- package/dist/src/modules/workspace/sync.d.ts.map +1 -1
- package/dist/src/modules/workspace/sync.js +14 -0
- package/dist/src/modules/workspace/sync.js.map +1 -1
- package/dist/src/modules/workspace/text.d.ts +29 -12
- package/dist/src/modules/workspace/text.d.ts.map +1 -1
- package/dist/src/modules/workspace/text.js +35 -33
- package/dist/src/modules/workspace/text.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +137 -60
- 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 +8 -3
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/prose-drafts.d.ts +4 -3
- package/dist/src/prose-drafts.d.ts.map +1 -1
- package/dist/src/prose-drafts.js +3 -2
- package/dist/src/prose-drafts.js.map +1 -1
- package/dist/src/reasoning-loss-notice.d.ts +23 -0
- package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
- package/dist/src/reasoning-loss-notice.js +50 -0
- package/dist/src/reasoning-loss-notice.js.map +1 -0
- package/dist/src/reasoning-loss.d.ts +24 -0
- package/dist/src/reasoning-loss.d.ts.map +1 -0
- package/dist/src/reasoning-loss.js +102 -0
- package/dist/src/reasoning-loss.js.map +1 -0
- package/dist/src/send-tools.d.ts +3 -2
- package/dist/src/send-tools.d.ts.map +1 -1
- package/dist/src/send-tools.js +3 -2
- package/dist/src/send-tools.js.map +1 -1
- package/dist/src/sent-rows.d.ts +59 -0
- package/dist/src/sent-rows.d.ts.map +1 -0
- package/dist/src/sent-rows.js +145 -0
- package/dist/src/sent-rows.js.map +1 -0
- package/dist/src/silent-heartbeat.d.ts +17 -10
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stable-hash.d.ts +3 -0
- package/dist/src/stable-hash.d.ts.map +1 -0
- package/dist/src/stable-hash.js +15 -0
- package/dist/src/stable-hash.js.map +1 -0
- package/dist/src/stored-injections.d.ts +99 -0
- package/dist/src/stored-injections.d.ts.map +1 -0
- package/dist/src/stored-injections.js +106 -0
- package/dist/src/stored-injections.js.map +1 -0
- package/dist/src/text-as-stored.d.ts +4 -3
- package/dist/src/text-as-stored.d.ts.map +1 -1
- package/dist/src/text-as-stored.js +4 -3
- package/dist/src/text-as-stored.js.map +1 -1
- package/dist/src/thinking-drops.d.ts +74 -0
- package/dist/src/thinking-drops.d.ts.map +1 -0
- package/dist/src/thinking-drops.js +96 -0
- package/dist/src/thinking-drops.js.map +1 -0
- package/dist/src/tool-args.d.ts +12 -0
- package/dist/src/tool-args.d.ts.map +1 -1
- package/dist/src/tool-args.js +35 -1
- package/dist/src/tool-args.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts +9 -8
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +9 -8
- 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 +3 -1
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +12 -6
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +44 -17
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +176 -24
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +411 -91
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +17 -9
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +84 -37
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +4 -1
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/types/agent.d.ts +217 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +33 -9
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +39 -3
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +95 -9
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +91 -3
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/agent.ts +661 -67
- package/src/api/server.ts +5 -4
- package/src/auto-continue.ts +43 -0
- package/src/code-execution/isolate/scripts.ts +11 -3
- package/src/cut-off-round.ts +98 -0
- package/src/framework.ts +6168 -1540
- package/src/gate/event-gate.ts +2895 -405
- package/src/gate/index.ts +10 -1
- package/src/gate/recipe-reconcile.ts +355 -0
- package/src/gate/reply-judge.ts +512 -0
- package/src/gate/types.ts +234 -9
- package/src/heartbeat/heartbeat.ts +804 -0
- package/src/heartbeat/reminder-time.ts +107 -0
- package/src/index.ts +11 -4
- package/src/mcpl/capability-mask.ts +3 -2
- package/src/mcpl/channel-registry.ts +1222 -468
- package/src/mcpl/conversation-router.ts +34 -16
- package/src/mcpl/convert-block.ts +14 -1
- package/src/mcpl/hook-orchestrator.ts +33 -6
- package/src/mcpl/inbound-source.ts +42 -69
- package/src/mcpl/index.ts +6 -1
- package/src/mcpl/inference-router.ts +79 -34
- package/src/mcpl/prose-grammar.ts +7 -0
- package/src/mcpl/protocol-family.ts +2 -0
- package/src/mcpl/push-coalescer.ts +51 -13
- package/src/mcpl/reference-fetcher.ts +201 -162
- package/src/mcpl/references.ts +851 -77
- package/src/mcpl/server-connection.ts +189 -11
- package/src/mcpl/tags.ts +13 -2
- package/src/mcpl/tool-lifecycle.ts +21 -0
- package/src/mcpl/tool-presence.ts +716 -0
- package/src/mcpl/tool-result-normalize.ts +18 -6
- package/src/mcpl/tool-signature.ts +316 -0
- package/src/mcpl/toolset-host.ts +727 -0
- package/src/mcpl/toolsets-module.ts +545 -0
- package/src/mcpl/transport.ts +3 -2
- package/src/mcpl/types.ts +25 -2
- package/src/mcpl/visible-content.ts +22 -9
- package/src/module-registry.ts +85 -26
- package/src/modules/discord/index.ts +1 -1
- package/src/modules/history/index.ts +70 -30
- package/src/modules/history/semantic.ts +308 -54
- package/src/modules/workspace/answers.ts +133 -0
- package/src/modules/workspace/branch-intent.ts +10 -5
- package/src/modules/workspace/direct-write.ts +460 -0
- package/src/modules/workspace/disk-agreement.ts +52 -21
- package/src/modules/workspace/edit-text.ts +84 -35
- package/src/modules/workspace/effects.ts +22 -13
- package/src/modules/workspace/index.ts +2142 -723
- package/src/modules/workspace/observe.ts +381 -177
- package/src/modules/workspace/read-page.ts +228 -0
- package/src/modules/workspace/reconcile.ts +27 -15
- package/src/modules/workspace/result-text.ts +121 -0
- package/src/modules/workspace/sync.ts +16 -0
- package/src/modules/workspace/text.ts +58 -32
- package/src/modules/workspace/types.ts +137 -60
- package/src/modules/workspace/watcher.ts +8 -3
- package/src/prose-drafts.ts +4 -3
- package/src/reasoning-loss-notice.ts +62 -0
- package/src/reasoning-loss.ts +120 -0
- package/src/send-tools.ts +3 -2
- package/src/sent-rows.ts +162 -0
- package/src/silent-heartbeat.ts +17 -10
- package/src/stable-hash.ts +14 -0
- package/src/stored-injections.ts +131 -0
- package/src/text-as-stored.ts +4 -3
- package/src/thinking-drops.ts +135 -0
- package/src/tool-args.ts +34 -1
- package/src/tool-image-ledger.ts +9 -8
- package/src/tool-presentation.ts +3 -1
- package/src/tool-result-guard.ts +45 -17
- package/src/tool-result-history.ts +471 -90
- package/src/tune-out/coordinator.ts +80 -37
- package/src/tune-out/tools.ts +4 -1
- package/src/types/agent.ts +220 -7
- package/src/types/events.ts +33 -9
- package/src/types/framework.ts +36 -3
- package/src/types/module.ts +91 -9
- package/src/types/trace.ts +94 -3
|
@@ -127,6 +127,14 @@ interface DeferredBatch<E> {
|
|
|
127
127
|
latest: CoalescedOccurrence<E>;
|
|
128
128
|
notices: DeferredNotice[];
|
|
129
129
|
dropped: number;
|
|
130
|
+
/** Every notice folded into the batch, a dropped one included, and a
|
|
131
|
+
* plain occurrence a notice displaced unread (Occupant.ambient), was
|
|
132
|
+
* tagged `chat:ambient` (RFC-001), so its render asks nothing of the agent
|
|
133
|
+
* (CoalescerHost.wakeToRead). Snapshots carry it. A batch restored
|
|
134
|
+
* without it, from a snapshot written before it existed or from an
|
|
135
|
+
* acceptance receipt, which doesn't carry it, reads as not all ambient:
|
|
136
|
+
* the side that keeps a wake. */
|
|
137
|
+
allAmbient?: true;
|
|
130
138
|
/** Set on a batch restored from a snapshot whose render may have started. */
|
|
131
139
|
noRender?: boolean;
|
|
132
140
|
/** The batch opened on the agent's first view of its subject: a fresh
|
|
@@ -184,10 +192,22 @@ interface Occupant {
|
|
|
184
192
|
* render that joins a run finds a version placed. In memory only: a
|
|
185
193
|
* snapshot's occupant comes back as read. */
|
|
186
194
|
firstView?: true;
|
|
195
|
+
/** A plain occurrence its server tagged `chat:ambient`. A notice that
|
|
196
|
+
* displaces it unread stands its batch's render in its place, so that
|
|
197
|
+
* render is all ambient only if this was (DeferredBatch.allAmbient). In
|
|
198
|
+
* memory only, as `firstView`: a snapshot's occupant comes back as read,
|
|
199
|
+
* and only an unread one is displaced. */
|
|
200
|
+
ambient?: true;
|
|
187
201
|
/** The run's earlier renders, oldest first, each placed ahead of this one. */
|
|
188
202
|
before?: Array<Omit<Occupant, 'before'>>;
|
|
189
203
|
}
|
|
190
204
|
|
|
205
|
+
/** An occupant's `ambient` mark, for a plain occurrence its server tagged
|
|
206
|
+
* `chat:ambient`. */
|
|
207
|
+
function ambientOccupant(occurrence: { tags?: string[] }): { ambient?: true } {
|
|
208
|
+
return occurrence.tags?.includes('chat:ambient') === true ? { ambient: true } : {};
|
|
209
|
+
}
|
|
210
|
+
|
|
191
211
|
/** The occupant holding a run's renders, given oldest first: the newest,
|
|
192
212
|
* carrying the rest as `before`. */
|
|
193
213
|
function runOf(members: Array<Omit<Occupant, 'before'>>): Occupant | undefined {
|
|
@@ -246,7 +266,7 @@ export interface CoalescingSnapshot {
|
|
|
246
266
|
firstViewEnded?: true;
|
|
247
267
|
/** `firstView` only on a batch that wasn't rendering: one that was may
|
|
248
268
|
* have been shown. */
|
|
249
|
-
batch?: { latest: CoalescedOccurrence<unknown>; notices: DeferredNotice[]; dropped: number; rendering?: boolean; firstView?: true };
|
|
269
|
+
batch?: { latest: CoalescedOccurrence<unknown>; notices: DeferredNotice[]; dropped: number; rendering?: boolean; firstView?: true; allAmbient?: true };
|
|
250
270
|
}>;
|
|
251
271
|
}
|
|
252
272
|
/** One receipt, written synchronously at acceptance (bridges the snapshot throttle). */
|
|
@@ -299,8 +319,11 @@ export interface CoalescerHost<E> {
|
|
|
299
319
|
/** Queue an ordinary push wake for `agent`, under the batch's own wake
|
|
300
320
|
* policy, to read a render of the batch placed in its deferred queue that
|
|
301
321
|
* no request consumed, at `deferredId`. It carries no subject, so the
|
|
302
|
-
* subject's other wakes, and later withdrawals of them, leave it.
|
|
303
|
-
|
|
322
|
+
* subject's other wakes, and later withdrawals of them, leave it.
|
|
323
|
+
* `allAmbient`: every notice the render stands for was tagged
|
|
324
|
+
* `chat:ambient` (DeferredBatch.allAmbient), so the wake is marked
|
|
325
|
+
* ambient. */
|
|
326
|
+
wakeToRead(occurrence: CoalescedOccurrence<E>, agent: string, deferredId?: string, allAmbient?: boolean): Promise<void>;
|
|
304
327
|
/** Withdraw unstarted wakes whose sole cause is this subject. */
|
|
305
328
|
cancelWake(subject: string): void;
|
|
306
329
|
/** The batch's audience still holds the authority it was admitted under. */
|
|
@@ -416,14 +439,20 @@ export function validateCoalescedContent(
|
|
|
416
439
|
/**
|
|
417
440
|
* Whether the converter (`convertBlock` in convert-block.ts, which every lane
|
|
418
441
|
* uses) shows a block as itself, its text or its image or
|
|
419
|
-
* audio source
|
|
442
|
+
* audio source (for MCP's embedded resource, its contents'), or as a
|
|
443
|
+
* reference stub, and not as a placeholder: an
|
|
420
444
|
* unrecognized block, a no-data or no-media-type one, withheld inline data,
|
|
421
445
|
* or a text block whose text isn't a string. This follows its branches in
|
|
422
446
|
* their order.
|
|
423
447
|
*/
|
|
424
448
|
function showsAsItself(b: Record<string, unknown>): boolean {
|
|
425
449
|
if (b.type === 'text') return typeof b.text === 'string';
|
|
426
|
-
if (b.type === 'resource'
|
|
450
|
+
if (b.type === 'resource' || b.type === 'resource_link') {
|
|
451
|
+
const c = classifyBlock(b);
|
|
452
|
+
// MCP's embedded resource shows as the block its contents make.
|
|
453
|
+
if (c.kind === 'embedded') return c.contents.kind === 'block' && showsAsItself(c.contents.block);
|
|
454
|
+
return c.kind === 'reference';
|
|
455
|
+
}
|
|
427
456
|
if (b.type !== 'image' && b.type !== 'audio') return false;
|
|
428
457
|
if (isInlineContradiction(b)) return false;
|
|
429
458
|
if (isFilledString(b.uri) && b.disposition !== undefined) return classifyBlock(b).kind === 'reference';
|
|
@@ -833,7 +862,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
833
862
|
// context that read a version, never a new one (§3.2).
|
|
834
863
|
const placement = await this.deliver({ ...occurrence, deliverTo: state.audienceAgent });
|
|
835
864
|
if (placement) {
|
|
836
|
-
state.occupant = { eventId: occurrence.eventId, placement };
|
|
865
|
+
state.occupant = { eventId: occurrence.eventId, placement, ...ambientOccupant(occurrence) };
|
|
837
866
|
state.audienceAgent = placement.agent;
|
|
838
867
|
}
|
|
839
868
|
return 'noted';
|
|
@@ -858,7 +887,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
858
887
|
...occurrence, deliverTo: prior.placement.agent,
|
|
859
888
|
...(firstView ? { firstView: true } : {}),
|
|
860
889
|
});
|
|
861
|
-
state.occupant = placement ? { eventId: occurrence.eventId, placement, ...(firstView ? { firstView: true as const } : {}) } : undefined;
|
|
890
|
+
state.occupant = placement ? { eventId: occurrence.eventId, placement, ...(firstView ? { firstView: true as const } : {}), ...ambientOccupant(occurrence) } : undefined;
|
|
862
891
|
if (placement) state.audienceAgent = placement.agent;
|
|
863
892
|
return 'replaced';
|
|
864
893
|
}
|
|
@@ -872,7 +901,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
872
901
|
// batch's place (a batch's own first view ends with the subject's).
|
|
873
902
|
const firstView = hadBatch ? batchFirstView && state.history === 'none' : outcome === 'first' && !state.firstViewEnded;
|
|
874
903
|
const placement = await this.deliver(hadBatch && firstView ? { ...occurrence, firstView: true } : occurrence);
|
|
875
|
-
state.occupant = placement ? { eventId: occurrence.eventId, placement, ...(firstView ? { firstView: true as const } : {}) } : undefined;
|
|
904
|
+
state.occupant = placement ? { eventId: occurrence.eventId, placement, ...(firstView ? { firstView: true as const } : {}), ...ambientOccupant(occurrence) } : undefined;
|
|
876
905
|
if (placement) state.audienceAgent = placement.agent;
|
|
877
906
|
return outcome;
|
|
878
907
|
}
|
|
@@ -887,6 +916,10 @@ export class PushCoalescer<E = unknown> {
|
|
|
887
916
|
// batches already open too). A render still under way is weighed when a
|
|
888
917
|
// batch's first delivery is.
|
|
889
918
|
let firstView = state.history === 'none' && !state.firstViewEnded;
|
|
919
|
+
// Whether every notice the batch's render stands for was tagged
|
|
920
|
+
// `chat:ambient` (DeferredBatch.allAmbient): this one, and a plain
|
|
921
|
+
// occurrence it displaces unread, whose place the render takes.
|
|
922
|
+
let ambient = occurrence.tags?.includes('chat:ambient') === true;
|
|
890
923
|
if (occupantUnread && state.occupant?.rendered) {
|
|
891
924
|
// An unread render is a delta the next render builds on (§5.2), not a
|
|
892
925
|
// plain occurrence: it stays, and the batch follows its agent (§3.2), so
|
|
@@ -897,6 +930,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
897
930
|
// §5.1: a notice displaces an unread plain occurrence and opens a batch
|
|
898
931
|
// — in the audience that held the plain occurrence (§3.2).
|
|
899
932
|
if (!this.occupantLeaves(state, state.occupant)) firstView = false;
|
|
933
|
+
if (state.occupant.ambient !== true) ambient = false;
|
|
900
934
|
this.host.audit({ kind: 'displaced', subject, eventId: state.occupant.eventId });
|
|
901
935
|
if (this.host.remove(state.occupant.placement)) {
|
|
902
936
|
outcome = 'replaced';
|
|
@@ -913,10 +947,11 @@ export class PushCoalescer<E = unknown> {
|
|
|
913
947
|
state.batch.notices.push(notice);
|
|
914
948
|
if (state.batch.notices.length > this.maxNotices) { state.batch.notices.shift(); state.batch.dropped++; }
|
|
915
949
|
state.batch.latest = occurrence;
|
|
950
|
+
if (!ambient) delete state.batch.allAmbient;
|
|
916
951
|
outcome = 'replaced';
|
|
917
952
|
} else {
|
|
918
953
|
// Rule 1: a notice during a render opens a NEW batch ("first").
|
|
919
|
-
state.batch = { latest: occurrence, notices: [notice], dropped: 0, ...(firstView ? { firstView: true as const } : {}) };
|
|
954
|
+
state.batch = { latest: occurrence, notices: [notice], dropped: 0, ...(firstView ? { firstView: true as const } : {}), ...(ambient ? { allAmbient: true as const } : {}) };
|
|
920
955
|
}
|
|
921
956
|
await this.host.wakeForBatch(occurrence);
|
|
922
957
|
return outcome;
|
|
@@ -1122,7 +1157,9 @@ export class PushCoalescer<E = unknown> {
|
|
|
1122
1157
|
// agent's wake for this batch; give it an ordinary wake, as any
|
|
1123
1158
|
// delivery during its turn has, beside any wakes a newer batch has,
|
|
1124
1159
|
// so that its next turn reads the content (the wake starts no turn
|
|
1125
|
-
// once
|
|
1160
|
+
// once a request that carried it is answered and, if the wake
|
|
1161
|
+
// carries a channel and the batch wasn't all ambient, the agent has
|
|
1162
|
+
// published there since, or once it's removed).
|
|
1126
1163
|
// The run's renders keep their own records, whatever else an
|
|
1127
1164
|
// occupant carries, a first view's mark included.
|
|
1128
1165
|
let before: Occupant['before'];
|
|
@@ -1136,7 +1173,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
1136
1173
|
await this.host.wakeForBatch(state.batch.latest);
|
|
1137
1174
|
}
|
|
1138
1175
|
state.audienceAgent = placement.agent;
|
|
1139
|
-
await this.host.wakeToRead(occurrence, placement.agent, placement.deferredId);
|
|
1176
|
+
await this.host.wakeToRead(occurrence, placement.agent, placement.deferredId, batch.allAmbient === true);
|
|
1140
1177
|
return;
|
|
1141
1178
|
}
|
|
1142
1179
|
// The materialized occurrence is consumed by the request being
|
|
@@ -1180,6 +1217,7 @@ export class PushCoalescer<E = unknown> {
|
|
|
1180
1217
|
state.batch = {
|
|
1181
1218
|
latest: s.batch.latest as CoalescedOccurrence<E>, notices: s.batch.notices, dropped: s.batch.dropped,
|
|
1182
1219
|
...(s.batch.rendering ? { noRender: true } : s.batch.firstView ? { firstView: true as const } : {}),
|
|
1220
|
+
...(s.batch.allAmbient ? { allAmbient: true as const } : {}),
|
|
1183
1221
|
};
|
|
1184
1222
|
}
|
|
1185
1223
|
this.subjects.set(s.subject, state);
|
|
@@ -1265,8 +1303,8 @@ export class PushCoalescer<E = unknown> {
|
|
|
1265
1303
|
// restore() reads only these. After a restart nothing of the subject
|
|
1266
1304
|
// is tracked as unread, a run included: its history counts as read.
|
|
1267
1305
|
...(s.occupant ? { occupant: { eventId: s.occupant.eventId, placement: s.occupant.placement } } : {}),
|
|
1268
|
-
...(s.batch ? { batch: { latest: s.batch.latest as CoalescedOccurrence<unknown>, notices: s.batch.notices, dropped: s.batch.dropped, ...(s.batch.noRender ? { rendering: true } : s.batch.firstView ? { firstView: true as const } : {}) } }
|
|
1269
|
-
: s.rendering ? { batch: { latest: s.rendering.batch.latest as CoalescedOccurrence<unknown>, notices: s.rendering.batch.notices, dropped: s.rendering.batch.dropped, rendering: true } }
|
|
1306
|
+
...(s.batch ? { batch: { latest: s.batch.latest as CoalescedOccurrence<unknown>, notices: s.batch.notices, dropped: s.batch.dropped, ...(s.batch.noRender ? { rendering: true } : s.batch.firstView ? { firstView: true as const } : {}), ...(s.batch.allAmbient ? { allAmbient: true as const } : {}) } }
|
|
1307
|
+
: s.rendering ? { batch: { latest: s.rendering.batch.latest as CoalescedOccurrence<unknown>, notices: s.rendering.batch.notices, dropped: s.rendering.batch.dropped, rendering: true, ...(s.rendering.batch.allAmbient ? { allAmbient: true as const } : {}) } }
|
|
1270
1308
|
: {}),
|
|
1271
1309
|
})),
|
|
1272
1310
|
};
|