@athenaintel/react 0.53.1 → 0.55.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.
Files changed (196) hide show
  1. package/README.md +37 -1
  2. package/dist/agent-runtime/src/call-recap.cjs +2 -3
  3. package/dist/agent-runtime/src/call-recap.cjs.map +1 -1
  4. package/dist/agent-runtime/src/call-recap.d.ts +1 -2
  5. package/dist/agent-runtime/src/call-recap.js +1 -2
  6. package/dist/agent-runtime/src/call-recap.js.map +1 -1
  7. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +7 -3
  8. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  9. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +10 -2
  10. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +8 -4
  11. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  12. package/dist/agent-runtime/src/dictation-session.d.ts +158 -0
  13. package/dist/agent-runtime/src/edit-command.cjs +15 -3
  14. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  15. package/dist/agent-runtime/src/edit-command.d.ts +8 -0
  16. package/dist/agent-runtime/src/edit-command.js +15 -3
  17. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  18. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +10 -0
  19. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  20. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +25 -1
  21. package/dist/agent-runtime/src/generated/runconfig-contract.js +10 -0
  22. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  23. package/dist/agent-runtime/src/history-pages.cjs +279 -0
  24. package/dist/agent-runtime/src/history-pages.cjs.map +1 -0
  25. package/dist/agent-runtime/src/history-pages.d.ts +252 -0
  26. package/dist/agent-runtime/src/history-pages.js +279 -0
  27. package/dist/agent-runtime/src/history-pages.js.map +1 -0
  28. package/dist/agent-runtime/src/index.d.ts +8 -7
  29. package/dist/agent-runtime/src/message-window.cjs +111 -7
  30. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  31. package/dist/agent-runtime/src/message-window.d.ts +66 -6
  32. package/dist/agent-runtime/src/message-window.js +112 -8
  33. package/dist/agent-runtime/src/message-window.js.map +1 -1
  34. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  35. package/dist/agent-runtime/src/offline-status.d.ts +64 -2
  36. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  37. package/dist/agent-runtime/src/runtime.d.ts +4 -3
  38. package/dist/agent-runtime/src/subagent-transcripts.cjs +23 -1
  39. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  40. package/dist/agent-runtime/src/subagent-transcripts.js +25 -3
  41. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  42. package/dist/agent-runtime/src/subagents.cjs +112 -0
  43. package/dist/agent-runtime/src/subagents.cjs.map +1 -1
  44. package/dist/agent-runtime/src/subagents.d.ts +103 -0
  45. package/dist/agent-runtime/src/subagents.js +113 -1
  46. package/dist/agent-runtime/src/subagents.js.map +1 -1
  47. package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +37 -9
  48. package/dist/agent-runtime/src/thread-handoff.d.ts +1 -1
  49. package/dist/agent-runtime/src/tool-metadata.cjs +8 -0
  50. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  51. package/dist/agent-runtime/src/tool-metadata.js +8 -0
  52. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  53. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +22 -2
  54. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  55. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +9 -1
  56. package/dist/agent-runtime/src/use-deep-agent-thread.js +23 -3
  57. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  58. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +106 -25
  59. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  60. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +41 -6
  61. package/dist/agent-runtime/src/use-deep-agent-window-sync.js +109 -28
  62. package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -1
  63. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +5 -9
  64. package/dist/agent-runtime/src/voice-presentation.cjs +34 -0
  65. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
  66. package/dist/agent-runtime/src/voice-presentation.d.ts +35 -0
  67. package/dist/agent-runtime/src/voice-presentation.js +34 -0
  68. package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
  69. package/dist/assets/AthenaAssetEmbed.cjs +4 -2
  70. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  71. package/dist/assets/AthenaAssetEmbed.d.ts +17 -8
  72. package/dist/assets/AthenaAssetEmbed.js +4 -2
  73. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  74. package/dist/assets/use-asset-embed.cjs.map +1 -1
  75. package/dist/assets/use-asset-embed.d.ts +7 -5
  76. package/dist/assets/use-asset-embed.js.map +1 -1
  77. package/dist/auth/account-identity.cjs +69 -0
  78. package/dist/auth/account-identity.cjs.map +1 -0
  79. package/dist/auth/account-identity.d.ts +57 -0
  80. package/dist/auth/account-identity.js +69 -0
  81. package/dist/auth/account-identity.js.map +1 -0
  82. package/dist/chat/AthenaChat.cjs +1 -1
  83. package/dist/chat/AthenaChat.cjs.map +1 -1
  84. package/dist/chat/AthenaChat.js +1 -1
  85. package/dist/chat/AthenaChat.js.map +1 -1
  86. package/dist/chat/super-grouping/SuperGroupingCard.cjs +51 -43
  87. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  88. package/dist/chat/super-grouping/SuperGroupingCard.js +51 -43
  89. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  90. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +9 -4
  91. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  92. package/dist/chat/super-grouping/SuperGroupingTranscript.js +9 -4
  93. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  94. package/dist/chat/super-grouping/activity-timeline.cjs +7 -4
  95. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  96. package/dist/chat/super-grouping/activity-timeline.d.ts +10 -1
  97. package/dist/chat/super-grouping/activity-timeline.js +7 -4
  98. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  99. package/dist/chat/super-grouping/earlier-steps-button.cjs +50 -0
  100. package/dist/chat/super-grouping/earlier-steps-button.cjs.map +1 -0
  101. package/dist/chat/super-grouping/earlier-steps-button.d.ts +11 -0
  102. package/dist/chat/super-grouping/earlier-steps-button.js +50 -0
  103. package/dist/chat/super-grouping/earlier-steps-button.js.map +1 -0
  104. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  105. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  106. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  107. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  108. package/dist/chat/super-grouping/use-turn-steps.cjs +28 -0
  109. package/dist/chat/super-grouping/use-turn-steps.cjs.map +1 -0
  110. package/dist/chat/super-grouping/use-turn-steps.d.ts +23 -0
  111. package/dist/chat/super-grouping/use-turn-steps.js +28 -0
  112. package/dist/chat/super-grouping/use-turn-steps.js.map +1 -0
  113. package/dist/chat/use-statewire-approval-request.cjs +5 -5
  114. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  115. package/dist/chat/use-statewire-approval-request.d.ts +7 -0
  116. package/dist/chat/use-statewire-approval-request.js +5 -5
  117. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  118. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +18 -58
  119. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  120. package/dist/chat-ui/mentions/use-account-workspace-id.js +18 -58
  121. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  122. package/dist/chat-ui/messages/voice-delegation-card.cjs +93 -25
  123. package/dist/chat-ui/messages/voice-delegation-card.cjs.map +1 -1
  124. package/dist/chat-ui/messages/voice-delegation-card.d.ts +16 -7
  125. package/dist/chat-ui/messages/voice-delegation-card.js +95 -27
  126. package/dist/chat-ui/messages/voice-delegation-card.js.map +1 -1
  127. package/dist/chat-ui/statewire.cjs +6 -0
  128. package/dist/chat-ui/statewire.cjs.map +1 -1
  129. package/dist/chat-ui/statewire.d.ts +3 -1
  130. package/dist/chat-ui/statewire.js +7 -1
  131. package/dist/chat-ui/statewire.js.map +1 -1
  132. package/dist/chat-ui/thread/handoff-cursor.cjs +2 -2
  133. package/dist/chat-ui/thread/handoff-cursor.cjs.map +1 -1
  134. package/dist/chat-ui/thread/handoff-cursor.js +3 -3
  135. package/dist/chat-ui/thread/handoff-cursor.js.map +1 -1
  136. package/dist/chat-ui/thread/statewire-history-edge.cjs +4 -0
  137. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  138. package/dist/chat-ui/thread/statewire-history-edge.d.ts +11 -1
  139. package/dist/chat-ui/thread/statewire-history-edge.js +5 -1
  140. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  141. package/dist/collab/client.cjs +134 -7
  142. package/dist/collab/client.cjs.map +1 -1
  143. package/dist/collab/client.d.ts +44 -0
  144. package/dist/collab/client.js +134 -7
  145. package/dist/collab/client.js.map +1 -1
  146. package/dist/collab/index.d.ts +1 -1
  147. package/dist/composer/QuoteContext.cjs +3 -3
  148. package/dist/composer/QuoteContext.cjs.map +1 -1
  149. package/dist/composer/QuoteContext.js +3 -3
  150. package/dist/composer/QuoteContext.js.map +1 -1
  151. package/dist/keryx-http/src/initial-sync.cjs +121 -0
  152. package/dist/keryx-http/src/initial-sync.cjs.map +1 -0
  153. package/dist/keryx-http/src/initial-sync.d.ts +77 -0
  154. package/dist/keryx-http/src/initial-sync.js +104 -0
  155. package/dist/keryx-http/src/initial-sync.js.map +1 -0
  156. package/dist/keryx-http/src/unconfirmed-update-attributions.cjs +8 -0
  157. package/dist/keryx-http/src/unconfirmed-update-attributions.cjs.map +1 -1
  158. package/dist/keryx-http/src/unconfirmed-update-attributions.d.ts +6 -0
  159. package/dist/keryx-http/src/unconfirmed-update-attributions.js +8 -0
  160. package/dist/keryx-http/src/unconfirmed-update-attributions.js.map +1 -1
  161. package/dist/provider/AthenaProvider.cjs +11 -3
  162. package/dist/provider/AthenaProvider.cjs.map +1 -1
  163. package/dist/provider/AthenaProvider.js +12 -4
  164. package/dist/provider/AthenaProvider.js.map +1 -1
  165. package/dist/provider/statewire-window-context.cjs +6 -0
  166. package/dist/provider/statewire-window-context.cjs.map +1 -1
  167. package/dist/provider/statewire-window-context.d.ts +10 -1
  168. package/dist/provider/statewire-window-context.js +6 -0
  169. package/dist/provider/statewire-window-context.js.map +1 -1
  170. package/dist/react/package.json.cjs +1 -1
  171. package/dist/react/package.json.js +1 -1
  172. package/dist/runtime/useAthenaStatewireRuntime.cjs +2 -0
  173. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  174. package/dist/runtime/useAthenaStatewireRuntime.d.ts +7 -1
  175. package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
  176. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  177. package/dist/styles.css +1 -1
  178. package/dist/threads/api.cjs +1 -2
  179. package/dist/threads/api.cjs.map +1 -1
  180. package/dist/threads/api.d.ts +3 -2
  181. package/dist/threads/api.js +1 -2
  182. package/dist/threads/api.js.map +1 -1
  183. package/dist/threads/sessions-query.cjs +2 -0
  184. package/dist/threads/sessions-query.cjs.map +1 -1
  185. package/dist/threads/sessions-query.js +2 -0
  186. package/dist/threads/sessions-query.js.map +1 -1
  187. package/dist/threads/statewire-thread-list.cjs +5 -7
  188. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  189. package/dist/threads/statewire-thread-list.js +7 -9
  190. package/dist/threads/statewire-thread-list.js.map +1 -1
  191. package/dist/tools/subagent-task-tool-ui.cjs +15 -5
  192. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
  193. package/dist/tools/subagent-task-tool-ui.d.ts +5 -4
  194. package/dist/tools/subagent-task-tool-ui.js +16 -6
  195. package/dist/tools/subagent-task-tool-ui.js.map +1 -1
  196. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"unconfirmed-update-attributions.js","sources":["../../../../keryx-http/src/unconfirmed-update-attributions.ts"],"sourcesContent":["/**\n * The attributed writes a room has not seen Keryx acknowledge, kept so that a write made while the\n * room's socket is closed still reaches Keryx with its attributions.\n *\n * A write made inside `runWithDocUpdateAttributions` leaves as its own sync update followed by the\n * attributions trailer (`attributingWebSocket`), but only if the room's socket is open as it is\n * made. One made while it is closed (offline, reconnecting, before the first connection) reaches\n * Keryx inside the reconnect's sync step 2: the client's answer to Keryx's sync step 1, everything\n * it holds that Keryx lacks. Keryx reads no trailer after a sync step 2, so it would count the\n * write as the person's edit.\n *\n * So the room keeps the content ids of every write made in a scope, with the scope's attributions,\n * until Keryx sends those ids back: the echo of the update that carried them, or the whole document\n * Keryx sends when a socket opens (`received`; `@y/websocket` confirms its own unconfirmed updates\n * the same way). When the socket sends a sync step 2, each kept write's part of it goes out first,\n * oldest first, as its own sync update with its trailer, and the sync step 2 follows without those\n * ids (`framesFor`). The parts are cut from the sync step 2 itself, which already holds only what\n * Keryx lacks past its state vector. One socket keeps the order, so Keryx appends each marked update\n * before the person's sync step 2.\n *\n * A room Keryx holds nothing of (its sync step 1 names no client: a document created on the device,\n * its first push) is born whole: assets are born as one write of their real initial state, signed by\n * their creator, and housekeeping inside a new room is part of that state, not system work on\n * anyone's content. Its sync step 2 goes out whole, as the creator's write. What the room kept stays\n * kept until Keryx echoes the push, like any write: a push lost with the socket goes out whole again\n * if Keryx still holds nothing when the room reconnects, and is split like any reconnect's if\n * someone wrote to the room meanwhile.\n *\n * That answer waits for Keryx's document (`connect`). Keryx sends its sync step 1 and, in the same\n * cork, its whole document, but `@y/websocket` answers the sync step 1 as it arrives. A kept write\n * Keryx already appended (its echo lost with the socket) is still kept then, and the sync step 2\n * holds the client's whole delete set, so its deletes would go out again as a marked update, which\n * Keryx appends: it drops what it holds from the first sync step 2 only. Held until the next frame,\n * the answer is split once Keryx's document has dropped what it holds.\n *\n * What Keryx records (`patches/@y%2Fhub@0.10.1.patch`):\n * - An update's content map attributes every id it carries, inserts and deletes, read from its\n * bytes: an update that cannot integrate yet (an item next to one the person typed offline, the\n * next clocks of the person's own client) is attributed like any other. Peers hold it until the\n * sync step 2 behind it brings what it needs.\n * - An id is attributed by the first stream entry that carries it (`getDoc`'s `excludeContentMap`),\n * so a later copy changes no merged history. The live change notices read each entry's own\n * content map, though (keryx/src/doc-watcher.ts), and the first sync step 2's strip of what Keryx\n * holds reads the known ids when the frame arrives, possibly before the update ahead of it is in\n * the stream (one whose content map the compute pool builds). A copy inside the sync step 2\n * would then be announced as the person's: the sync step 2 never carries a kept write's ids.\n *\n * Bounded: consecutive writes of one scope merge into one run, and past\n * {@link MAX_ATTRIBUTED_RUNS} runs the oldest is let go (its content then reaches Keryx in a sync\n * step 2, as the person's). A room's local copy keeps them across sessions\n * ({@link unconfirmedAttributedWritesOf}, {@link restoreUnconfirmedAttributedWrites}); without one,\n * a write the room kept is forgotten with the page.\n */\nimport {\n type ContentIds,\n createContentIdsFromUpdate,\n decodeStateVector,\n type Doc,\n excludeContentIds,\n intersectContentIds,\n intersectUpdateWithContentIds,\n mergeContentIds,\n} from '@y/y';\nimport {\n type AttributedWritesSocket,\n readVarUint,\n type UnconfirmedAttributedWrites,\n type UpdateAttribution,\n withUpdateAttributionsTrailer,\n writeVarUint,\n} from './update-attributions.js';\n\n/** y-protocols: a sync message, the sync step 1 (a state vector) and the sub-types that carry content. */\nconst MESSAGE_SYNC = 0;\nconst SYNC_STEP_1 = 0;\nconst SYNC_STEP_2 = 1;\nconst SYNC_UPDATE = 2;\n\n/** Writes made in one attribution scope, by the content ids they wrote (inserts and deletes). */\nexport interface AttributedWrites {\n ids: ContentIds;\n attributions: readonly UpdateAttribution[];\n}\n\n/**\n * The most runs a room keeps; a run is one scope's writes since a write of another scope. Housekeeping\n * all shares one scope, so runs pile up only as Quick Edit steps interleave with it.\n */\nexport const MAX_ATTRIBUTED_RUNS = 64;\n\nfunction noIds(ids: ContentIds): boolean {\n return ids.inserts.isEmpty() && ids.deletes.isEmpty();\n}\n\nfunction sameAttributions(\n a: readonly UpdateAttribution[],\n b: readonly UpdateAttribution[]\n): boolean {\n return (\n a.length === b.length &&\n a.every((pair, index) => pair.k === b[index]?.k && pair.v === b[index]?.v)\n );\n}\n\n/** The sync message `frame` is, when it is exactly one (nothing after its payload). */\nfunction readSyncFrame(frame: Uint8Array): { syncType: number; payload: Uint8Array } | null {\n const type = readVarUint({ bytes: frame, start: 0 });\n if (type?.value !== MESSAGE_SYNC) return null;\n const syncType = readVarUint({ bytes: frame, start: type.next });\n if (syncType === null) return null;\n const length = readVarUint({ bytes: frame, start: syncType.next });\n if (length === null || length.next + length.value !== frame.length) return null;\n return { syncType: syncType.value, payload: frame.subarray(length.next) };\n}\n\n/** A sync message of `syncType` carrying `payload`, as y-protocols writes one. */\nfunction syncFrame({ syncType, payload }: { syncType: number; payload: Uint8Array }): Uint8Array {\n const head: number[] = [];\n writeVarUint({ out: head, value: MESSAGE_SYNC });\n writeVarUint({ out: head, value: syncType });\n writeVarUint({ out: head, value: payload.length });\n const frame = new Uint8Array(head.length + payload.length);\n frame.set(head, 0);\n frame.set(payload, head.length);\n return frame;\n}\n\n/** Whether `stateVector` (a sync step 1's) names no client: Keryx holds nothing of the room. */\nfunction namesNoClient(stateVector: Uint8Array): boolean {\n try {\n return decodeStateVector(stateVector).size === 0;\n } catch {\n return false;\n }\n}\n\n/** The content ids an update carries, or `null` for bytes that are not one. */\nfunction idsOf(update: Uint8Array): ContentIds | null {\n try {\n return createContentIdsFromUpdate(update);\n } catch {\n return null;\n }\n}\n\nfunction copyOf({ ids, attributions }: AttributedWrites): AttributedWrites {\n return { ids, attributions: attributions.map(({ k, v }) => ({ k, v })) };\n}\n\n/** `runs` without the oldest past {@link MAX_ATTRIBUTED_RUNS}. */\nfunction bounded(runs: AttributedWrites[]): AttributedWrites[] {\n return runs.length > MAX_ATTRIBUTED_RUNS ? runs.slice(runs.length - MAX_ATTRIBUTED_RUNS) : runs;\n}\n\n/** What a page reads of a room's tracker, whichever copy of this module made it. */\ninterface KeptWrites {\n readonly pending: readonly AttributedWrites[];\n restore(writes: readonly AttributedWrites[]): void;\n}\n\n/**\n * Each document's tracker in the page, and what a destroyed one still kept for the next tracker made\n * for the same document (a transport rebuilt over a retained document; a local copy read into a\n * document before its room's transport exists). On `globalThis`, not in module scope, for the reason\n * the scopes are (`update-attributions.ts`): the SDK's dist inlines its own copy of this module, and\n * a local copy reading a room through another copy must find the same tracker. Weak: each entry goes\n * with its document.\n */\nconst ROOMS = Symbol.for('@athenaintel/keryx-http/unconfirmed-update-attributions');\n\ninterface Rooms {\n live: WeakMap<object, KeptWrites>;\n left: WeakMap<object, AttributedWrites[]>;\n}\n\ntype RoomsHost = typeof globalThis & {\n [ROOMS]?: Rooms;\n};\n\n// process-local: browser-only, each entry keyed by the document whose writes it holds\nfunction rooms(): Rooms {\n const host = globalThis as RoomsHost;\n return (host[ROOMS] ??= { live: new WeakMap(), left: new WeakMap() });\n}\n\n/**\n * The attributed writes Keryx has not acknowledged for `doc`, oldest first: its room's, or what a\n * destroyed room left for the next. What a room's local copy keeps of them.\n */\nexport function unconfirmedAttributedWritesOf(doc: object): readonly AttributedWrites[] {\n const { live, left } = rooms();\n return live.get(doc)?.pending ?? left.get(doc)?.map(copyOf) ?? [];\n}\n\n/**\n * Hands `doc`'s room attributed writes an earlier session kept (the room's local copy), or keeps\n * them for the next tracker made for it. They are older than anything written since, so they go\n * out first.\n */\nexport function restoreUnconfirmedAttributedWrites({\n doc,\n writes,\n}: {\n doc: object;\n writes: readonly AttributedWrites[];\n}): void {\n if (writes.length === 0) return;\n const { live, left } = rooms();\n const room = live.get(doc);\n if (room) {\n room.restore(writes);\n return;\n }\n left.set(doc, bounded([...writes.map(copyOf), ...(left.get(doc) ?? [])]));\n}\n\n/**\n * The two above, as a page hands them to its local copies (`@athenaintel/local-copy`'s\n * `openLocalCopyStore({ attributedWrites })`, `createLocalCopiesPage({ attributedWrites })`): the\n * copy records a room's kept writes with its edits and restores an ended session's to its room.\n */\nexport const roomAttributedWrites = {\n of: unconfirmedAttributedWritesOf,\n restore: restoreUnconfirmedAttributedWrites,\n};\n\n/**\n * One room's attributed writes Keryx has not acknowledged (see the module comment). Made once per\n * room by its transport, which hands it to every socket it opens (`attributingWebSocket`'s\n * `unconfirmed`) and destroys it with the room; a tracker made for the same document later takes\n * over what it still kept, and what its local copy kept from an earlier session\n * ({@link restoreUnconfirmedAttributedWrites}). Not for a room that only listens: its socket sends\n * nothing to split.\n */\nexport class UnconfirmedUpdateAttributions implements UnconfirmedAttributedWrites, KeptWrites {\n private runs: AttributedWrites[];\n private readonly doc: Doc;\n private readonly attributionsFor: () => readonly UpdateAttribution[] | undefined;\n private readonly isRemoteOrigin: (origin: unknown) => boolean;\n\n constructor({\n doc,\n attributionsFor,\n isRemoteOrigin,\n }: {\n doc: Doc;\n /** The attributions of the update being written now: what the socket's trailer reads. */\n attributionsFor: () => readonly UpdateAttribution[] | undefined;\n /** True for a transaction the transport applied (Keryx's state, a peer's edit). */\n isRemoteOrigin: (origin: unknown) => boolean;\n }) {\n this.doc = doc;\n this.attributionsFor = attributionsFor;\n this.isRemoteOrigin = isRemoteOrigin;\n const { live, left } = rooms();\n this.runs = left.get(doc) ?? [];\n left.delete(doc);\n live.set(doc, this);\n doc.on('update', this.handleUpdate);\n }\n\n private readonly handleUpdate = (update: Uint8Array, origin: unknown): void => {\n if (this.isRemoteOrigin(origin)) return;\n const attributions = this.attributionsFor();\n if (!attributions || attributions.length === 0) return;\n const ids = idsOf(update);\n if (!ids || noIds(ids)) return;\n const last = this.runs.at(-1);\n if (last && sameAttributions(last.attributions, attributions)) {\n last.ids = mergeContentIds([last.ids, ids]);\n return;\n }\n this.runs = bounded([...this.runs, copyOf({ ids, attributions })]);\n };\n\n /** The attributed writes Keryx has not acknowledged, oldest first. */\n get pending(): readonly AttributedWrites[] {\n return this.runs.map(copyOf);\n }\n\n /** Writes an earlier session kept, older than any written here: they go out first. */\n restore(writes: readonly AttributedWrites[]): void {\n this.runs = bounded([...writes.map(copyOf), ...this.runs]);\n }\n\n /**\n * One socket of the room. While the room keeps writes, the socket's sync step 2 (its answer to\n * Keryx's sync step 1) waits for the next frame Keryx sends, its whole document, which drops what\n * Keryx already holds before the answer is split (see the module comment); every frame sent\n * meanwhile waits behind it, in order. When Keryx's sync step 1 names no client, the room is new\n * to Keryx: its answer goes out whole, born as one write, and what the room kept waits for its\n * echo. Nothing kept, or a socket that cannot hear Keryx: every frame goes out as it is sent.\n */\n connect({\n send,\n hears,\n }: {\n send: (frame: Uint8Array) => void;\n hears: boolean;\n }): AttributedWritesSocket {\n let held: Uint8Array[] | null = null;\n /** Keryx's sync step 1 on this socket named no client: it holds nothing of the room. */\n let roomIsNew = false;\n const sendNow = (frame: Uint8Array) => {\n for (const out of this.framesFor(frame)) send(out);\n };\n return {\n received: (frame) => {\n const message = readSyncFrame(frame);\n if (message?.syncType === SYNC_STEP_1) roomIsNew = namesNoClient(message.payload);\n this.received(frame);\n if (held === null) return;\n const waiting = held;\n held = null;\n for (const next of waiting) sendNow(next);\n },\n send: (frame) => {\n if (held !== null) {\n held.push(frame);\n return;\n }\n const syncType = readSyncFrame(frame)?.syncType;\n if (roomIsNew && syncType === SYNC_STEP_2) {\n send(frame);\n return;\n }\n if (hears && this.runs.length > 0 && syncType === SYNC_STEP_2) {\n held = [frame];\n return;\n }\n sendNow(frame);\n },\n };\n }\n\n /** Keryx sent `frame`: the ids it carries are Keryx's, kept no longer. */\n received(frame: Uint8Array): void {\n if (this.runs.length === 0) return;\n const message = readSyncFrame(frame);\n if (message === null) return;\n if (message.syncType !== SYNC_STEP_2 && message.syncType !== SYNC_UPDATE) return;\n const held = idsOf(message.payload);\n if (!held) return;\n this.runs = this.runs\n .map(({ ids, attributions }) => ({ ids: excludeContentIds(ids, held), attributions }))\n .filter((run) => !noIds(run.ids));\n }\n\n /**\n * What goes out in place of `frame`: `[frame]` itself, except a sync step 2 carrying kept writes,\n * which goes out behind each of them as its own marked sync update.\n */\n framesFor(frame: Uint8Array): readonly Uint8Array[] {\n if (this.runs.length === 0) return [frame];\n const message = readSyncFrame(frame);\n if (message === null || message.syncType !== SYNC_STEP_2) return [frame];\n const answer = message.payload;\n const all = idsOf(answer);\n if (!all) return [frame];\n const frames: Uint8Array[] = [];\n const marked: ContentIds[] = [];\n for (const run of this.runs) {\n const part = intersectContentIds(run.ids, all);\n if (noIds(part)) continue;\n frames.push(\n withUpdateAttributionsTrailer({\n message: syncFrame({\n syncType: SYNC_UPDATE,\n payload: intersectUpdateWithContentIds(answer, part),\n }),\n attributions: run.attributions,\n })\n );\n marked.push(part);\n }\n if (marked.length === 0) return [frame];\n const rest = excludeContentIds(all, mergeContentIds(marked));\n frames.push(\n syncFrame({ syncType: SYNC_STEP_2, payload: intersectUpdateWithContentIds(answer, rest) })\n );\n return frames;\n }\n\n /** Stops keeping; what is still kept waits for the next tracker made for the document. */\n destroy(): void {\n this.doc.off('update', this.handleUpdate);\n const { live, left } = rooms();\n if (live.get(this.doc) === this) live.delete(this.doc);\n if (this.runs.length > 0) left.set(this.doc, this.runs);\n this.runs = [];\n }\n}\n"],"names":[],"mappings":";;;;;AAyEA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AAYb,MAAM,sBAAsB;AAEnC,SAAS,MAAM,KAA0B;AACvC,SAAO,IAAI,QAAQ,QAAA,KAAa,IAAI,QAAQ,QAAA;AAC9C;AAEA,SAAS,iBACP,GACA,GACS;AACT,SACE,EAAE,WAAW,EAAE,UACf,EAAE,MAA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AAG;AACrD,QAAI,KAAK,KAAK,SAAS,QAAQ,IAAI,KAAK,KAAK,KAAK,IAAI;AACtD,SAAK,OAAO,CAAA;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"unconfirmed-update-attributions.js","sources":["../../../../keryx-http/src/unconfirmed-update-attributions.ts"],"sourcesContent":["/**\n * The attributed writes a room has not seen Keryx acknowledge, kept so that a write made while the\n * room's socket is closed still reaches Keryx with its attributions.\n *\n * A write made inside `runWithDocUpdateAttributions` leaves as its own sync update followed by the\n * attributions trailer (`attributingWebSocket`), but only if the room's socket is open as it is\n * made. One made while it is closed (offline, reconnecting, before the first connection) reaches\n * Keryx inside the reconnect's sync step 2: the client's answer to Keryx's sync step 1, everything\n * it holds that Keryx lacks. Keryx reads no trailer after a sync step 2, so it would count the\n * write as the person's edit.\n *\n * So the room keeps the content ids of every write made in a scope, with the scope's attributions,\n * until Keryx sends those ids back: the echo of the update that carried them, or the whole document\n * Keryx sends when a socket opens (`received`; `@y/websocket` confirms its own unconfirmed updates\n * the same way). When the socket sends a sync step 2, each kept write's part of it goes out first,\n * oldest first, as its own sync update with its trailer, and the sync step 2 follows without those\n * ids (`framesFor`). The parts are cut from the sync step 2 itself, which already holds only what\n * Keryx lacks past its state vector. One socket keeps the order, so Keryx appends each marked update\n * before the person's sync step 2.\n *\n * A room Keryx holds nothing of (its sync step 1 names no client: a document created on the device,\n * its first push) is born whole: assets are born as one write of their real initial state, signed by\n * their creator, and housekeeping inside a new room is part of that state, not system work on\n * anyone's content. Its sync step 2 goes out whole, as the creator's write. What the room kept stays\n * kept until Keryx echoes the push, like any write: a push lost with the socket goes out whole again\n * if Keryx still holds nothing when the room reconnects, and is split like any reconnect's if\n * someone wrote to the room meanwhile.\n *\n * That answer waits for Keryx's document (`connect`). Keryx sends its sync step 1 and, in the same\n * cork, its whole document, but `@y/websocket` answers the sync step 1 as it arrives. A kept write\n * Keryx already appended (its echo lost with the socket) is still kept then, and the sync step 2\n * holds the client's whole delete set, so its deletes would go out again as a marked update, which\n * Keryx appends: it drops what it holds from the first sync step 2 only. Held until the next frame,\n * the answer is split once Keryx's document has dropped what it holds.\n *\n * What Keryx records (`patches/@y%2Fhub@0.10.1.patch`):\n * - An update's content map attributes every id it carries, inserts and deletes, read from its\n * bytes: an update that cannot integrate yet (an item next to one the person typed offline, the\n * next clocks of the person's own client) is attributed like any other. Peers hold it until the\n * sync step 2 behind it brings what it needs.\n * - An id is attributed by the first stream entry that carries it (`getDoc`'s `excludeContentMap`),\n * so a later copy changes no merged history. The live change notices read each entry's own\n * content map, though (keryx/src/doc-watcher.ts), and the first sync step 2's strip of what Keryx\n * holds reads the known ids when the frame arrives, possibly before the update ahead of it is in\n * the stream (one whose content map the compute pool builds). A copy inside the sync step 2\n * would then be announced as the person's: the sync step 2 never carries a kept write's ids.\n *\n * Bounded: consecutive writes of one scope merge into one run, and past\n * {@link MAX_ATTRIBUTED_RUNS} runs the oldest is let go (its content then reaches Keryx in a sync\n * step 2, as the person's). A room's local copy keeps them across sessions\n * ({@link unconfirmedAttributedWritesOf}, {@link restoreUnconfirmedAttributedWrites}); without one,\n * a write the room kept is forgotten with the page.\n */\nimport {\n type ContentIds,\n createContentIdsFromUpdate,\n decodeStateVector,\n type Doc,\n excludeContentIds,\n intersectContentIds,\n intersectUpdateWithContentIds,\n mergeContentIds,\n} from '@y/y';\nimport {\n type AttributedWritesSocket,\n readVarUint,\n type UnconfirmedAttributedWrites,\n type UpdateAttribution,\n withUpdateAttributionsTrailer,\n writeVarUint,\n} from './update-attributions.js';\n\n/** y-protocols: a sync message, the sync step 1 (a state vector) and the sub-types that carry content. */\nconst MESSAGE_SYNC = 0;\nconst SYNC_STEP_1 = 0;\nconst SYNC_STEP_2 = 1;\nconst SYNC_UPDATE = 2;\n\n/** Writes made in one attribution scope, by the content ids they wrote (inserts and deletes). */\nexport interface AttributedWrites {\n ids: ContentIds;\n attributions: readonly UpdateAttribution[];\n}\n\n/**\n * The most runs a room keeps; a run is one scope's writes since a write of another scope. Housekeeping\n * all shares one scope, so runs pile up only as Quick Edit steps interleave with it.\n */\nexport const MAX_ATTRIBUTED_RUNS = 64;\n\nfunction noIds(ids: ContentIds): boolean {\n return ids.inserts.isEmpty() && ids.deletes.isEmpty();\n}\n\nfunction sameAttributions(\n a: readonly UpdateAttribution[],\n b: readonly UpdateAttribution[]\n): boolean {\n return (\n a.length === b.length &&\n a.every((pair, index) => pair.k === b[index]?.k && pair.v === b[index]?.v)\n );\n}\n\n/** The sync message `frame` is, when it is exactly one (nothing after its payload). */\nfunction readSyncFrame(frame: Uint8Array): { syncType: number; payload: Uint8Array } | null {\n const type = readVarUint({ bytes: frame, start: 0 });\n if (type?.value !== MESSAGE_SYNC) return null;\n const syncType = readVarUint({ bytes: frame, start: type.next });\n if (syncType === null) return null;\n const length = readVarUint({ bytes: frame, start: syncType.next });\n if (length === null || length.next + length.value !== frame.length) return null;\n return { syncType: syncType.value, payload: frame.subarray(length.next) };\n}\n\n/** A sync message of `syncType` carrying `payload`, as y-protocols writes one. */\nfunction syncFrame({ syncType, payload }: { syncType: number; payload: Uint8Array }): Uint8Array {\n const head: number[] = [];\n writeVarUint({ out: head, value: MESSAGE_SYNC });\n writeVarUint({ out: head, value: syncType });\n writeVarUint({ out: head, value: payload.length });\n const frame = new Uint8Array(head.length + payload.length);\n frame.set(head, 0);\n frame.set(payload, head.length);\n return frame;\n}\n\n/** Whether `stateVector` (a sync step 1's) names no client: Keryx holds nothing of the room. */\nfunction namesNoClient(stateVector: Uint8Array): boolean {\n try {\n return decodeStateVector(stateVector).size === 0;\n } catch {\n return false;\n }\n}\n\n/** The content ids an update carries, or `null` for bytes that are not one. */\nfunction idsOf(update: Uint8Array): ContentIds | null {\n try {\n return createContentIdsFromUpdate(update);\n } catch {\n return null;\n }\n}\n\nfunction copyOf({ ids, attributions }: AttributedWrites): AttributedWrites {\n return { ids, attributions: attributions.map(({ k, v }) => ({ k, v })) };\n}\n\n/** `runs` without the oldest past {@link MAX_ATTRIBUTED_RUNS}. */\nfunction bounded(runs: AttributedWrites[]): AttributedWrites[] {\n return runs.length > MAX_ATTRIBUTED_RUNS ? runs.slice(runs.length - MAX_ATTRIBUTED_RUNS) : runs;\n}\n\n/** What a page reads of a room's tracker, whichever copy of this module made it. */\ninterface KeptWrites {\n readonly pending: readonly AttributedWrites[];\n restore(writes: readonly AttributedWrites[]): void;\n}\n\n/**\n * Each document's tracker in the page, and what a destroyed one still kept for the next tracker made\n * for the same document (a transport rebuilt over a retained document; a local copy read into a\n * document before its room's transport exists). On `globalThis`, not in module scope, for the reason\n * the scopes are (`update-attributions.ts`): the SDK's dist inlines its own copy of this module, and\n * a local copy reading a room through another copy must find the same tracker. Weak: each entry goes\n * with its document.\n */\nconst ROOMS = Symbol.for('@athenaintel/keryx-http/unconfirmed-update-attributions');\n\ninterface Rooms {\n live: WeakMap<object, KeptWrites>;\n left: WeakMap<object, AttributedWrites[]>;\n}\n\ntype RoomsHost = typeof globalThis & {\n [ROOMS]?: Rooms;\n};\n\n// process-local: browser-only, each entry keyed by the document whose writes it holds\nfunction rooms(): Rooms {\n const host = globalThis as RoomsHost;\n return (host[ROOMS] ??= { live: new WeakMap(), left: new WeakMap() });\n}\n\n/**\n * The attributed writes Keryx has not acknowledged for `doc`, oldest first: its room's, or what a\n * destroyed room left for the next. What a room's local copy keeps of them.\n */\nexport function unconfirmedAttributedWritesOf(doc: object): readonly AttributedWrites[] {\n const { live, left } = rooms();\n return live.get(doc)?.pending ?? left.get(doc)?.map(copyOf) ?? [];\n}\n\n/**\n * Hands `doc`'s room attributed writes an earlier session kept (the room's local copy), or keeps\n * them for the next tracker made for it. They are older than anything written since, so they go\n * out first.\n */\nexport function restoreUnconfirmedAttributedWrites({\n doc,\n writes,\n}: {\n doc: object;\n writes: readonly AttributedWrites[];\n}): void {\n if (writes.length === 0) return;\n const { live, left } = rooms();\n const room = live.get(doc);\n if (room) {\n room.restore(writes);\n return;\n }\n left.set(doc, bounded([...writes.map(copyOf), ...(left.get(doc) ?? [])]));\n}\n\n/**\n * The two above, as a page hands them to its local copies (`@athenaintel/local-copy`'s\n * `openLocalCopyStore({ attributedWrites })`, `createLocalCopiesPage({ attributedWrites })`): the\n * copy records a room's kept writes with its edits and restores an ended session's to its room.\n */\nexport const roomAttributedWrites = {\n of: unconfirmedAttributedWritesOf,\n restore: restoreUnconfirmedAttributedWrites,\n};\n\n/**\n * One room's attributed writes Keryx has not acknowledged (see the module comment). Made once per\n * room by its transport, which hands it to every socket it opens (`attributingWebSocket`'s\n * `unconfirmed`) and destroys it with the room; a tracker made for the same document later takes\n * over what it still kept, and what its local copy kept from an earlier session\n * ({@link restoreUnconfirmedAttributedWrites}). Not for a room that only listens: its socket sends\n * nothing to split.\n */\nexport class UnconfirmedUpdateAttributions implements UnconfirmedAttributedWrites, KeptWrites {\n private runs: AttributedWrites[];\n private readonly doc: Doc;\n private readonly attributionsFor: () => readonly UpdateAttribution[] | undefined;\n private readonly isRemoteOrigin: (origin: unknown) => boolean;\n\n constructor({\n doc,\n attributionsFor,\n isRemoteOrigin,\n }: {\n doc: Doc;\n /** The attributions of the update being written now: what the socket's trailer reads. */\n attributionsFor: () => readonly UpdateAttribution[] | undefined;\n /** True for a transaction the transport applied (Keryx's state, a peer's edit). */\n isRemoteOrigin: (origin: unknown) => boolean;\n }) {\n this.doc = doc;\n this.attributionsFor = attributionsFor;\n this.isRemoteOrigin = isRemoteOrigin;\n const { live, left } = rooms();\n this.runs = left.get(doc) ?? [];\n left.delete(doc);\n live.set(doc, this);\n doc.on('update', this.handleUpdate);\n }\n\n private readonly handleUpdate = (update: Uint8Array, origin: unknown): void => {\n if (this.isRemoteOrigin(origin)) return;\n const attributions = this.attributionsFor();\n if (!attributions || attributions.length === 0) return;\n const ids = idsOf(update);\n if (!ids || noIds(ids)) return;\n const last = this.runs.at(-1);\n if (last && sameAttributions(last.attributions, attributions)) {\n last.ids = mergeContentIds([last.ids, ids]);\n return;\n }\n this.runs = bounded([...this.runs, copyOf({ ids, attributions })]);\n };\n\n /** The attributed writes Keryx has not acknowledged, oldest first. */\n get pending(): readonly AttributedWrites[] {\n return this.runs.map(copyOf);\n }\n\n /**\n * Whether the room keeps a write Keryx has not acknowledged. Such a room's socket must not ask for\n * a diffed initial sync (`./initial-sync.ts`): it tells which kept writes Keryx already holds from\n * the whole document Keryx sends when the socket opens, and a diff leaves out what it holds.\n */\n get keepsWrites(): boolean {\n return this.runs.length > 0;\n }\n\n /** Writes an earlier session kept, older than any written here: they go out first. */\n restore(writes: readonly AttributedWrites[]): void {\n this.runs = bounded([...writes.map(copyOf), ...this.runs]);\n }\n\n /**\n * One socket of the room. While the room keeps writes, the socket's sync step 2 (its answer to\n * Keryx's sync step 1) waits for the next frame Keryx sends, its whole document, which drops what\n * Keryx already holds before the answer is split (see the module comment); every frame sent\n * meanwhile waits behind it, in order. When Keryx's sync step 1 names no client, the room is new\n * to Keryx: its answer goes out whole, born as one write, and what the room kept waits for its\n * echo. Nothing kept, or a socket that cannot hear Keryx: every frame goes out as it is sent.\n */\n connect({\n send,\n hears,\n }: {\n send: (frame: Uint8Array) => void;\n hears: boolean;\n }): AttributedWritesSocket {\n let held: Uint8Array[] | null = null;\n /** Keryx's sync step 1 on this socket named no client: it holds nothing of the room. */\n let roomIsNew = false;\n const sendNow = (frame: Uint8Array) => {\n for (const out of this.framesFor(frame)) send(out);\n };\n return {\n received: (frame) => {\n const message = readSyncFrame(frame);\n if (message?.syncType === SYNC_STEP_1) roomIsNew = namesNoClient(message.payload);\n this.received(frame);\n if (held === null) return;\n const waiting = held;\n held = null;\n for (const next of waiting) sendNow(next);\n },\n send: (frame) => {\n if (held !== null) {\n held.push(frame);\n return;\n }\n const syncType = readSyncFrame(frame)?.syncType;\n if (roomIsNew && syncType === SYNC_STEP_2) {\n send(frame);\n return;\n }\n if (hears && this.runs.length > 0 && syncType === SYNC_STEP_2) {\n held = [frame];\n return;\n }\n sendNow(frame);\n },\n };\n }\n\n /** Keryx sent `frame`: the ids it carries are Keryx's, kept no longer. */\n received(frame: Uint8Array): void {\n if (this.runs.length === 0) return;\n const message = readSyncFrame(frame);\n if (message === null) return;\n if (message.syncType !== SYNC_STEP_2 && message.syncType !== SYNC_UPDATE) return;\n const held = idsOf(message.payload);\n if (!held) return;\n this.runs = this.runs\n .map(({ ids, attributions }) => ({ ids: excludeContentIds(ids, held), attributions }))\n .filter((run) => !noIds(run.ids));\n }\n\n /**\n * What goes out in place of `frame`: `[frame]` itself, except a sync step 2 carrying kept writes,\n * which goes out behind each of them as its own marked sync update.\n */\n framesFor(frame: Uint8Array): readonly Uint8Array[] {\n if (this.runs.length === 0) return [frame];\n const message = readSyncFrame(frame);\n if (message === null || message.syncType !== SYNC_STEP_2) return [frame];\n const answer = message.payload;\n const all = idsOf(answer);\n if (!all) return [frame];\n const frames: Uint8Array[] = [];\n const marked: ContentIds[] = [];\n for (const run of this.runs) {\n const part = intersectContentIds(run.ids, all);\n if (noIds(part)) continue;\n frames.push(\n withUpdateAttributionsTrailer({\n message: syncFrame({\n syncType: SYNC_UPDATE,\n payload: intersectUpdateWithContentIds(answer, part),\n }),\n attributions: run.attributions,\n })\n );\n marked.push(part);\n }\n if (marked.length === 0) return [frame];\n const rest = excludeContentIds(all, mergeContentIds(marked));\n frames.push(\n syncFrame({ syncType: SYNC_STEP_2, payload: intersectUpdateWithContentIds(answer, rest) })\n );\n return frames;\n }\n\n /** Stops keeping; what is still kept waits for the next tracker made for the document. */\n destroy(): void {\n this.doc.off('update', this.handleUpdate);\n const { live, left } = rooms();\n if (live.get(this.doc) === this) live.delete(this.doc);\n if (this.runs.length > 0) left.set(this.doc, this.runs);\n this.runs = [];\n }\n}\n"],"names":[],"mappings":";;;;;AAyEA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AAYb,MAAM,sBAAsB;AAEnC,SAAS,MAAM,KAA0B;AACvC,SAAO,IAAI,QAAQ,QAAA,KAAa,IAAI,QAAQ,QAAA;AAC9C;AAEA,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AGA,UAAgB;AACd,SAAK,IAAI,IAAI,UAAU,KAAK,YAAY;AACxC,UAAM,EAAE,MAAM,KAAA,IAAS,MAAA;AACvB,QAAI,KAAK,IAAI,KAAK,GAAG,MAAM,KAAM,MAAK,OAAO,KAAK,GAAG;AACrD,QAAI,KAAK,KAAK,SAAS,QAAQ,IAAI,KAAK,KAAK,KAAK,IAAI;AACtD,SAAK,OAAO,CAAA;AAAA,EACd;AACF;"}
@@ -23,6 +23,8 @@ const mintThreadId = require("../threads/mint-thread-id.cjs");
23
23
  const statewireLifecycleContext = require("./statewire-lifecycle-context.cjs");
24
24
  const composerHandoff = require("../composer/composer-handoff.cjs");
25
25
  const statewireHistoryContext = require("./statewire-history-context.cjs");
26
+ const earlierStepsButton = require("../chat/super-grouping/earlier-steps-button.cjs");
27
+ const useTurnSteps = require("../chat/super-grouping/use-turn-steps.cjs");
26
28
  const statewireWindowContext = require("./statewire-window-context.cjs");
27
29
  const StatewireClientToolBridge = require("../chat/StatewireClientToolBridge.cjs");
28
30
  const StatewireThreadConfigLaneSync = require("../runtime/StatewireThreadConfigLaneSync.cjs");
@@ -47,6 +49,7 @@ const durableThreadSnapshotCache = require("../agent-runtime/src/durable-thread-
47
49
  const threadSnapshotCache = require("../agent-runtime/src/thread-snapshot-cache.cjs");
48
50
  const chatOutboxAttachments = require("../agent-runtime/src/chat-outbox-attachments.cjs");
49
51
  const toolOutputs = require("../agent-runtime/src/tool-outputs.cjs");
52
+ const historyPages = require("../agent-runtime/src/history-pages.cjs");
50
53
  const threadStatus = require("../agent-runtime/src/thread-status.cjs");
51
54
  const useDeepAgentChatOutbox = require("../agent-runtime/src/use-deep-agent-chat-outbox.cjs");
52
55
  const useDeepAgentConfig = require("../agent-runtime/src/use-deep-agent-config.cjs");
@@ -149,6 +152,7 @@ function AthenaStatewireRuntimeMount({
149
152
  extraRunConfig,
150
153
  snapshotCache,
151
154
  toolOutputs: toolOutputs2,
155
+ historyPages: historyPages2,
152
156
  chatOutbox: chatOutbox2 = null,
153
157
  sessionLane,
154
158
  subagentLaneHistory
@@ -206,6 +210,7 @@ function AthenaStatewireRuntimeMount({
206
210
  extraRunConfig,
207
211
  snapshotCache,
208
212
  toolOutputs: toolOutputs2,
213
+ historyPages: historyPages2,
209
214
  subagentLaneHistory,
210
215
  // The runtime already records every transport error on the diagnostics
211
216
  // bus (with the channel-teardown split), so this layer only maps it to
@@ -416,7 +421,7 @@ function AthenaStatewireStandalone({
416
421
  // eslint-disable-next-line react-hooks/exhaustive-deps
417
422
  [modeKey, modeScope, modePicks, sessionChannels, published, setModePick, setSessionChannel]
418
423
  );
419
- const scope = published && /* @__PURE__ */ jsxRuntime.jsx(react.AuiProvider, { value: published.client, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(threadIdContext.AthenaStatewireThreadIdContext.Provider, { value: published.threadId, children: /* @__PURE__ */ jsxRuntime.jsx(statewireLifecycleContext.AthenaStatewireLifecycleContext.Provider, { value: published.lifecycle, children: /* @__PURE__ */ jsxRuntime.jsx(threadStatus.DeepAgentConnectionContext.Provider, { value: published.lifecycle.connection, children: /* @__PURE__ */ jsxRuntime.jsx(statewireServerLaneContext.AthenaStatewireServerLaneContext.Provider, { value: published.serverLane, children: /* @__PURE__ */ jsxRuntime.jsx(statewireWindowContext.StatewireToolOutputsContext.Provider, { value: runtimeProps.toolOutputs, children: /* @__PURE__ */ jsxRuntime.jsx(statewireHistoryContext.StatewireHistoryContext.Provider, { value: runtimeProps.historyStore, children: /* @__PURE__ */ jsxRuntime.jsxs(tooltip.TooltipProvider, { children: [
424
+ const scope = published && /* @__PURE__ */ jsxRuntime.jsx(react.AuiProvider, { value: published.client, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(threadIdContext.AthenaStatewireThreadIdContext.Provider, { value: published.threadId, children: /* @__PURE__ */ jsxRuntime.jsx(statewireLifecycleContext.AthenaStatewireLifecycleContext.Provider, { value: published.lifecycle, children: /* @__PURE__ */ jsxRuntime.jsx(threadStatus.DeepAgentConnectionContext.Provider, { value: published.lifecycle.connection, children: /* @__PURE__ */ jsxRuntime.jsx(statewireServerLaneContext.AthenaStatewireServerLaneContext.Provider, { value: published.serverLane, children: /* @__PURE__ */ jsxRuntime.jsx(statewireWindowContext.StatewireToolOutputsContext.Provider, { value: runtimeProps.toolOutputs, children: /* @__PURE__ */ jsxRuntime.jsx(statewireWindowContext.StatewireHistoryPagesContext.Provider, { value: runtimeProps.historyPages, children: /* @__PURE__ */ jsxRuntime.jsx(useTurnSteps.TurnStepsControlContext.Provider, { value: earlierStepsButton.EarlierStepsButton, children: /* @__PURE__ */ jsxRuntime.jsx(statewireHistoryContext.StatewireHistoryContext.Provider, { value: runtimeProps.historyStore, children: /* @__PURE__ */ jsxRuntime.jsxs(tooltip.TooltipProvider, { children: [
420
425
  /* @__PURE__ */ jsxRuntime.jsx(StatewireClientToolBridge.StatewireClientToolBridge, { tools: clientTools, threadId: published.threadId }),
421
426
  /* @__PURE__ */ jsxRuntime.jsx(
422
427
  StatewireThreadConfigLaneSync.StatewireThreadConfigLaneSync,
@@ -436,7 +441,7 @@ function AthenaStatewireStandalone({
436
441
  children
437
442
  }
438
443
  ) }) })
439
- ] }) }) }) }) }) }) }) }) });
444
+ ] }) }) }) }) }) }) }) }) }) }) });
440
445
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
441
446
  /* @__PURE__ */ jsxRuntime.jsx(
442
447
  AthenaStatewireRuntimeMount,
@@ -742,12 +747,14 @@ function AthenaProvider({
742
747
  );
743
748
  const [composerHandoff$1] = require$$0.useState(composerHandoff.createComposerHandoffStore);
744
749
  const [toolOutputs$1] = require$$0.useState(() => toolOutputs.createDeepAgentToolOutputStore());
750
+ const [historyPages$1] = require$$0.useState(() => historyPages.createDeepAgentHistoryStore());
745
751
  const [historyStore] = require$$0.useState(statewireHistoryContext.createStatewireHistoryStore);
746
752
  const principal = ((_a = authContext == null ? void 0 : authContext.user) == null ? void 0 : _a.userId) ?? "";
747
753
  require$$0.useEffect(() => {
748
754
  snapshotCache.clear();
749
755
  toolOutputs$1.clear();
750
- }, [snapshotCache, toolOutputs$1, principal, configuredApiKey]);
756
+ historyPages$1.clear();
757
+ }, [snapshotCache, toolOutputs$1, historyPages$1, principal, configuredApiKey]);
751
758
  const sessionPrincipal = statewireSessionKey.statewireSessionPrincipal(authContext);
752
759
  const [sessionLane] = require$$0.useState(
753
760
  () => statewireSessionLane.createStatewireSessionLaneGate({ pending: sessionPrincipal === null })
@@ -830,6 +837,7 @@ function AthenaProvider({
830
837
  extraRunConfig: configuredExtraRunConfig,
831
838
  snapshotCache,
832
839
  toolOutputs: toolOutputs$1,
840
+ historyPages: historyPages$1,
833
841
  historyStore,
834
842
  chatOutbox: chatOutboxHost,
835
843
  sessionLane,