@athenaintel/react 0.41.3 → 0.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. package/README.md +132 -10
  2. package/dist/agent-runtime/src/asset-attachment.d.ts +98 -0
  3. package/dist/agent-runtime/src/athena-asset-drag.d.ts +32 -0
  4. package/dist/agent-runtime/src/auth-denial.d.ts +29 -0
  5. package/dist/agent-runtime/src/chat-outbox-attachments.cjs +41 -0
  6. package/dist/agent-runtime/src/chat-outbox-attachments.cjs.map +1 -0
  7. package/dist/agent-runtime/src/chat-outbox-attachments.d.ts +38 -0
  8. package/dist/agent-runtime/src/chat-outbox-attachments.js +41 -0
  9. package/dist/agent-runtime/src/chat-outbox-attachments.js.map +1 -0
  10. package/dist/agent-runtime/src/chat-outbox-signals.cjs +63 -0
  11. package/dist/agent-runtime/src/chat-outbox-signals.cjs.map +1 -0
  12. package/dist/agent-runtime/src/chat-outbox-signals.d.ts +12 -0
  13. package/dist/agent-runtime/src/chat-outbox-signals.js +63 -0
  14. package/dist/agent-runtime/src/chat-outbox-signals.js.map +1 -0
  15. package/dist/agent-runtime/src/chat-outbox-store.cjs +509 -0
  16. package/dist/agent-runtime/src/chat-outbox-store.cjs.map +1 -0
  17. package/dist/agent-runtime/src/chat-outbox-store.d.ts +203 -0
  18. package/dist/agent-runtime/src/chat-outbox-store.js +509 -0
  19. package/dist/agent-runtime/src/chat-outbox-store.js.map +1 -0
  20. package/dist/agent-runtime/src/chat-outbox-thread.cjs +136 -0
  21. package/dist/agent-runtime/src/chat-outbox-thread.cjs.map +1 -0
  22. package/dist/agent-runtime/src/chat-outbox-thread.d.ts +118 -0
  23. package/dist/agent-runtime/src/chat-outbox-thread.js +136 -0
  24. package/dist/agent-runtime/src/chat-outbox-thread.js.map +1 -0
  25. package/dist/agent-runtime/src/chat-outbox.cjs +696 -0
  26. package/dist/agent-runtime/src/chat-outbox.cjs.map +1 -0
  27. package/dist/agent-runtime/src/chat-outbox.d.ts +285 -0
  28. package/dist/agent-runtime/src/chat-outbox.js +696 -0
  29. package/dist/agent-runtime/src/chat-outbox.js.map +1 -0
  30. package/dist/agent-runtime/src/chat-socket-reachability.d.ts +45 -0
  31. package/dist/agent-runtime/src/client-tool-bridge.d.ts +152 -0
  32. package/dist/agent-runtime/src/client-tools.d.ts +133 -0
  33. package/dist/agent-runtime/src/composer-markdown.cjs +10 -0
  34. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  35. package/dist/agent-runtime/src/composer-markdown.d.ts +108 -0
  36. package/dist/agent-runtime/src/composer-markdown.js +10 -0
  37. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  38. package/dist/agent-runtime/src/config-mutations.d.ts +51 -0
  39. package/dist/agent-runtime/src/conversation-index.d.ts +110 -0
  40. package/dist/agent-runtime/src/conversation-list.d.ts +343 -0
  41. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +3 -2
  42. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  43. package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +166 -0
  44. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -2
  45. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  46. package/dist/agent-runtime/src/desktop-handoff.d.ts +139 -0
  47. package/dist/agent-runtime/src/durable-thread-snapshot-cache.d.ts +60 -0
  48. package/dist/agent-runtime/src/edit-command.d.ts +156 -0
  49. package/dist/agent-runtime/src/errors.d.ts +174 -0
  50. package/dist/agent-runtime/src/execute-output.d.ts +31 -0
  51. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +16 -2
  52. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  53. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +202 -0
  54. package/dist/agent-runtime/src/generated/runconfig-contract.js +16 -2
  55. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  56. package/dist/agent-runtime/src/github-wake-event.d.ts +77 -0
  57. package/dist/agent-runtime/src/index.d.ts +74 -0
  58. package/dist/agent-runtime/src/interrupts.cjs +17 -0
  59. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  60. package/dist/agent-runtime/src/interrupts.d.ts +348 -0
  61. package/dist/agent-runtime/src/interrupts.js +17 -0
  62. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  63. package/dist/agent-runtime/src/lane-follow.d.ts +121 -0
  64. package/dist/agent-runtime/src/lane-history.cjs +209 -0
  65. package/dist/agent-runtime/src/lane-history.cjs.map +1 -0
  66. package/dist/agent-runtime/src/lane-history.d.ts +175 -0
  67. package/dist/agent-runtime/src/lane-history.js +209 -0
  68. package/dist/agent-runtime/src/lane-history.js.map +1 -0
  69. package/dist/agent-runtime/src/lane-images.d.ts +184 -0
  70. package/dist/agent-runtime/src/message-author.d.ts +43 -0
  71. package/dist/agent-runtime/src/message-text.cjs +15 -0
  72. package/dist/agent-runtime/src/message-text.cjs.map +1 -0
  73. package/dist/agent-runtime/src/message-text.d.ts +47 -0
  74. package/dist/agent-runtime/src/message-text.js +15 -0
  75. package/dist/agent-runtime/src/message-text.js.map +1 -0
  76. package/dist/agent-runtime/src/message-window.cjs +15 -1
  77. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  78. package/dist/agent-runtime/src/message-window.d.ts +159 -0
  79. package/dist/agent-runtime/src/message-window.js +16 -2
  80. package/dist/agent-runtime/src/message-window.js.map +1 -1
  81. package/dist/agent-runtime/src/messages.cjs +123 -8
  82. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  83. package/dist/agent-runtime/src/messages.d.ts +621 -0
  84. package/dist/agent-runtime/src/messages.js +123 -8
  85. package/dist/agent-runtime/src/messages.js.map +1 -1
  86. package/dist/agent-runtime/src/model-context.d.ts +22 -0
  87. package/dist/agent-runtime/src/offline-status.d.ts +157 -0
  88. package/dist/agent-runtime/src/optimistic-content.d.ts +21 -0
  89. package/dist/agent-runtime/src/protocol.cjs +12 -4
  90. package/dist/agent-runtime/src/protocol.cjs.map +1 -1
  91. package/dist/agent-runtime/src/protocol.d.ts +119 -0
  92. package/dist/agent-runtime/src/protocol.js +13 -5
  93. package/dist/agent-runtime/src/protocol.js.map +1 -1
  94. package/dist/agent-runtime/src/ptc-subcalls.d.ts +51 -0
  95. package/dist/agent-runtime/src/queue.d.ts +138 -0
  96. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +10 -0
  97. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  98. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +161 -0
  99. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +10 -0
  100. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  101. package/dist/agent-runtime/src/running-tool-placeholder.cjs +11 -0
  102. package/dist/agent-runtime/src/running-tool-placeholder.cjs.map +1 -0
  103. package/dist/agent-runtime/src/running-tool-placeholder.d.ts +25 -0
  104. package/dist/agent-runtime/src/running-tool-placeholder.js +11 -0
  105. package/dist/agent-runtime/src/running-tool-placeholder.js.map +1 -0
  106. package/dist/agent-runtime/src/runtime-messages.d.ts +104 -0
  107. package/dist/agent-runtime/src/screen-point.d.ts +151 -0
  108. package/dist/agent-runtime/src/sealed-idb.cjs +112 -0
  109. package/dist/agent-runtime/src/sealed-idb.cjs.map +1 -0
  110. package/dist/agent-runtime/src/sealed-idb.d.ts +106 -0
  111. package/dist/agent-runtime/src/sealed-idb.js +112 -0
  112. package/dist/agent-runtime/src/sealed-idb.js.map +1 -0
  113. package/dist/agent-runtime/src/send-recovery.d.ts +40 -0
  114. package/dist/agent-runtime/src/session-lane-scope.cjs +25 -0
  115. package/dist/agent-runtime/src/session-lane-scope.cjs.map +1 -0
  116. package/dist/agent-runtime/src/session-lane-scope.d.ts +59 -0
  117. package/dist/agent-runtime/src/session-lane-scope.js +25 -0
  118. package/dist/agent-runtime/src/session-lane-scope.js.map +1 -0
  119. package/dist/agent-runtime/src/statewire-attach-observer.d.ts +194 -0
  120. package/dist/agent-runtime/src/statewire-diagnostics.d.ts +74 -0
  121. package/dist/agent-runtime/src/statewire-state.d.ts +29 -0
  122. package/dist/agent-runtime/src/statewire-suspended.cjs.map +1 -1
  123. package/dist/agent-runtime/src/statewire-suspended.d.ts +27 -0
  124. package/dist/agent-runtime/src/statewire-suspended.js.map +1 -1
  125. package/dist/agent-runtime/src/statewire-transport.d.ts +40 -0
  126. package/dist/agent-runtime/src/streaming-markdown.d.ts +46 -0
  127. package/dist/agent-runtime/src/subagent-transcripts.cjs +209 -0
  128. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -0
  129. package/dist/agent-runtime/src/subagent-transcripts.d.ts +71 -0
  130. package/dist/agent-runtime/src/subagent-transcripts.js +209 -0
  131. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -0
  132. package/dist/agent-runtime/src/subagents.cjs +253 -0
  133. package/dist/agent-runtime/src/subagents.cjs.map +1 -0
  134. package/dist/agent-runtime/src/subagents.d.ts +311 -0
  135. package/dist/agent-runtime/src/subagents.js +253 -0
  136. package/dist/agent-runtime/src/subagents.js.map +1 -0
  137. package/dist/agent-runtime/src/subscription-wake-event.d.ts +111 -0
  138. package/dist/agent-runtime/src/thread-extras.d.ts +43 -0
  139. package/dist/agent-runtime/src/thread-handoff.d.ts +364 -0
  140. package/dist/agent-runtime/src/thread-prewarm-controller.d.ts +76 -0
  141. package/dist/agent-runtime/src/thread-prewarm.d.ts +118 -0
  142. package/dist/agent-runtime/src/thread-snapshot-cache.d.ts +99 -0
  143. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs +46 -117
  144. package/dist/agent-runtime/src/thread-snapshot-mirror.cjs.map +1 -1
  145. package/dist/agent-runtime/src/thread-snapshot-mirror.d.ts +101 -0
  146. package/dist/agent-runtime/src/thread-snapshot-mirror.js +17 -88
  147. package/dist/agent-runtime/src/thread-snapshot-mirror.js.map +1 -1
  148. package/dist/agent-runtime/src/thread-status.d.ts +53 -0
  149. package/dist/agent-runtime/src/tool-metadata.d.ts +146 -0
  150. package/dist/agent-runtime/src/tool-names.cjs +71 -0
  151. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  152. package/dist/agent-runtime/src/tool-names.d.ts +67 -0
  153. package/dist/agent-runtime/src/tool-names.js +72 -1
  154. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  155. package/dist/agent-runtime/src/tool-outputs.d.ts +35 -0
  156. package/dist/agent-runtime/src/tool-result.cjs +1 -0
  157. package/dist/agent-runtime/src/tool-result.cjs.map +1 -1
  158. package/dist/agent-runtime/src/tool-result.d.ts +126 -0
  159. package/dist/agent-runtime/src/tool-result.js +1 -0
  160. package/dist/agent-runtime/src/tool-result.js.map +1 -1
  161. package/dist/agent-runtime/src/types.d.ts +159 -0
  162. package/dist/agent-runtime/src/use-conversation-list.d.ts +76 -0
  163. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs +136 -0
  164. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.cjs.map +1 -0
  165. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.d.ts +64 -0
  166. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js +136 -0
  167. package/dist/agent-runtime/src/use-deep-agent-chat-outbox.js.map +1 -0
  168. package/dist/agent-runtime/src/use-deep-agent-config.d.ts +169 -0
  169. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs +13 -0
  170. package/dist/agent-runtime/src/use-deep-agent-edit-submit.cjs.map +1 -1
  171. package/dist/agent-runtime/src/use-deep-agent-edit-submit.d.ts +22 -0
  172. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js +13 -0
  173. package/dist/agent-runtime/src/use-deep-agent-edit-submit.js.map +1 -1
  174. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +37 -2
  175. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  176. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +177 -0
  177. package/dist/agent-runtime/src/use-deep-agent-runtime.js +38 -3
  178. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  179. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +39 -13
  180. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  181. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +352 -0
  182. package/dist/agent-runtime/src/use-deep-agent-thread.js +39 -13
  183. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  184. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +1019 -0
  185. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -0
  186. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +409 -0
  187. package/dist/agent-runtime/src/use-deep-agent-voice.js +1019 -0
  188. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -0
  189. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +102 -0
  190. package/dist/agent-runtime/src/use-historical-edit-attachments.d.ts +2 -0
  191. package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +84 -0
  192. package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
  193. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
  194. package/dist/agent-runtime/src/voice-presentation.d.ts +80 -0
  195. package/dist/agent-runtime/src/voice-presentation.js +2 -0
  196. package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
  197. package/dist/agent-runtime/src/voice-turn-grouping.d.ts +28 -0
  198. package/dist/agent-runtime/src/voice-wire-types.d.ts +15 -0
  199. package/dist/agent-runtime/src/withdrawn-turns.d.ts +97 -0
  200. package/dist/catalog/runtime-catalog.js +1 -1
  201. package/dist/chat/AthenaChat.cjs +192 -103
  202. package/dist/chat/AthenaChat.cjs.map +1 -1
  203. package/dist/chat/AthenaChat.d.ts +9 -0
  204. package/dist/chat/AthenaChat.js +194 -105
  205. package/dist/chat/AthenaChat.js.map +1 -1
  206. package/dist/chat/StatewireApprovalCard.d.ts +1 -1
  207. package/dist/chat/StatewireClientToolBridge.d.ts +1 -1
  208. package/dist/chat/StatewireQueuedMessages.cjs +11 -4
  209. package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
  210. package/dist/chat/StatewireQueuedMessages.d.ts +1 -1
  211. package/dist/chat/StatewireQueuedMessages.js +11 -4
  212. package/dist/chat/StatewireQueuedMessages.js.map +1 -1
  213. package/dist/chat/chat-outbox-rows.cjs +223 -0
  214. package/dist/chat/chat-outbox-rows.cjs.map +1 -0
  215. package/dist/chat/chat-outbox-rows.d.ts +29 -0
  216. package/dist/chat/chat-outbox-rows.js +223 -0
  217. package/dist/chat/chat-outbox-rows.js.map +1 -0
  218. package/dist/chat/chat-voice-controls.cjs +128 -0
  219. package/dist/chat/chat-voice-controls.cjs.map +1 -0
  220. package/dist/chat/chat-voice-controls.d.ts +19 -0
  221. package/dist/chat/chat-voice-controls.js +128 -0
  222. package/dist/chat/chat-voice-controls.js.map +1 -0
  223. package/dist/chat/statewire-approval.d.ts +1 -1
  224. package/dist/chat/statewire-client-tools.d.ts +1 -1
  225. package/dist/chat/super-grouping/SuperGroupingCard.cjs +3 -1
  226. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  227. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +7 -1
  228. package/dist/chat/super-grouping/SuperGroupingCard.js +3 -1
  229. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  230. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +7 -2
  231. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  232. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +2 -2
  233. package/dist/chat/super-grouping/SuperGroupingTranscript.js +7 -2
  234. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  235. package/dist/chat/super-grouping/activity-timeline.cjs +15 -8
  236. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  237. package/dist/chat/super-grouping/activity-timeline.d.ts +18 -8
  238. package/dist/chat/super-grouping/activity-timeline.js +15 -8
  239. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  240. package/dist/chat/use-statewire-approval-request.cjs +36 -0
  241. package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
  242. package/dist/chat/use-statewire-approval-request.d.ts +49 -1
  243. package/dist/chat/use-statewire-approval-request.js +39 -3
  244. package/dist/chat/use-statewire-approval-request.js.map +1 -1
  245. package/dist/chat-ui/composer/tiptap-composer.cjs +133 -14
  246. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  247. package/dist/chat-ui/composer/tiptap-composer.d.ts +33 -1
  248. package/dist/chat-ui/composer/tiptap-composer.js +135 -16
  249. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  250. package/dist/chat-ui/header/conversation-history-panel.d.ts +1 -1
  251. package/dist/chat-ui/index.d.ts +1 -1
  252. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
  253. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  254. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -1
  255. package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
  256. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  257. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +29 -51
  258. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  259. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +2 -2
  260. package/dist/chat-ui/mentions/use-account-workspace-id.js +30 -52
  261. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  262. package/dist/chat-ui/messages/message-components.cjs +15 -0
  263. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  264. package/dist/chat-ui/messages/message-components.js +15 -0
  265. package/dist/chat-ui/messages/message-components.js.map +1 -1
  266. package/dist/chat-ui/messages/runtime-message.d.ts +1 -1
  267. package/dist/chat-ui/messages/statewire-continue-run.d.ts +1 -1
  268. package/dist/chat-ui/messages/user-edit-composer.cjs +15 -2
  269. package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
  270. package/dist/chat-ui/messages/user-edit-composer.d.ts +4 -2
  271. package/dist/chat-ui/messages/user-edit-composer.js +15 -2
  272. package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
  273. package/dist/chat-ui/messages/wake-marker.d.ts +1 -1
  274. package/dist/chat-ui/rich-text/chat-text-schema.cjs +1 -0
  275. package/dist/chat-ui/rich-text/chat-text-schema.cjs.map +1 -1
  276. package/dist/chat-ui/rich-text/chat-text-schema.d.ts +3 -0
  277. package/dist/chat-ui/rich-text/chat-text-schema.js +1 -0
  278. package/dist/chat-ui/rich-text/chat-text-schema.js.map +1 -1
  279. package/dist/chat-ui/statewire.cjs +1 -0
  280. package/dist/chat-ui/statewire.cjs.map +1 -1
  281. package/dist/chat-ui/statewire.d.ts +2 -2
  282. package/dist/chat-ui/statewire.js +2 -1
  283. package/dist/chat-ui/thread/composer-send-or-stop.cjs +2 -1
  284. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  285. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +2 -0
  286. package/dist/chat-ui/thread/composer-send-or-stop.js +2 -1
  287. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  288. package/dist/chat-ui/thread/statewire-history-edge.d.ts +1 -1
  289. package/dist/composer/AttachmentContext.cjs +8 -4
  290. package/dist/composer/AttachmentContext.cjs.map +1 -1
  291. package/dist/composer/AttachmentContext.d.ts +7 -0
  292. package/dist/composer/AttachmentContext.js +8 -4
  293. package/dist/composer/AttachmentContext.js.map +1 -1
  294. package/dist/composer/build-composed-message.cjs +34 -0
  295. package/dist/composer/build-composed-message.cjs.map +1 -1
  296. package/dist/composer/build-composed-message.d.ts +20 -0
  297. package/dist/composer/build-composed-message.js +35 -1
  298. package/dist/composer/build-composed-message.js.map +1 -1
  299. package/dist/composer/composer-handoff.cjs +39 -2
  300. package/dist/composer/composer-handoff.cjs.map +1 -1
  301. package/dist/composer/composer-handoff.d.ts +28 -3
  302. package/dist/composer/composer-handoff.js +39 -2
  303. package/dist/composer/composer-handoff.js.map +1 -1
  304. package/dist/composer/useAttachFiles.cjs +15 -2
  305. package/dist/composer/useAttachFiles.cjs.map +1 -1
  306. package/dist/composer/useAttachFiles.d.ts +11 -0
  307. package/dist/composer/useAttachFiles.js +15 -2
  308. package/dist/composer/useAttachFiles.js.map +1 -1
  309. package/dist/composer/useSendMessage.cjs.map +1 -1
  310. package/dist/composer/useSendMessage.d.ts +4 -3
  311. package/dist/composer/useSendMessage.js.map +1 -1
  312. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  313. package/dist/diagnostics/athena-diagnostics.d.ts +3 -1
  314. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  315. package/dist/index.cjs +13 -0
  316. package/dist/index.cjs.map +1 -1
  317. package/dist/index.d.ts +14 -7
  318. package/dist/index.js +14 -1
  319. package/dist/index.js.map +1 -1
  320. package/dist/offline/chat-outbox.cjs +57 -0
  321. package/dist/offline/chat-outbox.cjs.map +1 -0
  322. package/dist/offline/chat-outbox.d.ts +80 -0
  323. package/dist/offline/chat-outbox.js +57 -0
  324. package/dist/offline/chat-outbox.js.map +1 -0
  325. package/dist/offline/offline-history.d.ts +1 -1
  326. package/dist/provider/AthenaProvider.cjs +162 -8
  327. package/dist/provider/AthenaProvider.cjs.map +1 -1
  328. package/dist/provider/AthenaProvider.d.ts +15 -1
  329. package/dist/provider/AthenaProvider.js +163 -9
  330. package/dist/provider/AthenaProvider.js.map +1 -1
  331. package/dist/provider/statewire-window-context.d.ts +1 -1
  332. package/dist/react/package.json.cjs +1 -1
  333. package/dist/react/package.json.js +1 -1
  334. package/dist/references/src/anchors/file-line-range.d.ts +58 -0
  335. package/dist/references/src/anchors/format.d.ts +21 -0
  336. package/dist/references/src/anchors/message-anchors.d.ts +71 -0
  337. package/dist/references/src/anchors/parse.d.ts +8 -0
  338. package/dist/references/src/anchors/registry-contract.d.ts +24 -0
  339. package/dist/references/src/anchors/registry.d.ts +19 -0
  340. package/dist/references/src/anchors/schemas.d.ts +194 -0
  341. package/dist/references/src/anchors/serialize.d.ts +8 -0
  342. package/dist/references/src/anchors/time.d.ts +78 -0
  343. package/dist/references/src/anchors/types.d.ts +474 -0
  344. package/dist/references/src/asset-bounds.d.ts +27 -0
  345. package/dist/references/src/asset-links.d.ts +23 -0
  346. package/dist/references/src/asset-reference.d.ts +16 -0
  347. package/dist/references/src/formats/format-catalog.d.ts +79 -0
  348. package/dist/references/src/formats/markdown/parse-reference-markdown.d.ts +28 -0
  349. package/dist/references/src/formats/markdown/reference-display-name.d.ts +6 -0
  350. package/dist/references/src/formats/object/asset-object.d.ts +9 -0
  351. package/dist/references/src/formats/object/callable-object.d.ts +6 -0
  352. package/dist/references/src/formats/object/decode-reference-object-payload.d.ts +3 -0
  353. package/dist/references/src/formats/object/external-url-object.d.ts +9 -0
  354. package/dist/references/src/formats/object/group-object.d.ts +9 -0
  355. package/dist/references/src/formats/object/navigation-object.d.ts +9 -0
  356. package/dist/references/src/formats/object/parse-reference-object.d.ts +11 -0
  357. package/dist/references/src/formats/object/person-object.d.ts +9 -0
  358. package/dist/references/src/formats/uri/asset-mention-uri.d.ts +9 -0
  359. package/dist/references/src/formats/uri/asset-spaces-url.d.ts +9 -0
  360. package/dist/references/src/formats/uri/callable-mention-uris.d.ts +9 -0
  361. package/dist/references/src/formats/uri/detect-uri-wire.d.ts +9 -0
  362. package/dist/references/src/formats/uri/group-mention-uri.d.ts +12 -0
  363. package/dist/references/src/formats/uri/navigation-spaces-url.d.ts +14 -0
  364. package/dist/references/src/formats/uri/parse-reference-uri.d.ts +20 -0
  365. package/dist/references/src/formats/uri/person-mention-uri.d.ts +9 -0
  366. package/dist/references/src/formats/uri/template-placeholder.d.ts +12 -0
  367. package/dist/references/src/index.d.ts +47 -0
  368. package/dist/references/src/legacy/index.d.ts +14 -0
  369. package/dist/references/src/legacy/pre-reference-asset-url.d.ts +57 -0
  370. package/dist/references/src/legacy/pre-reference-citation-bridge.d.ts +22 -0
  371. package/dist/references/src/legacy/pre-reference-citation.d.ts +138 -0
  372. package/dist/references/src/legacy/pre-reference-external-url.d.ts +31 -0
  373. package/dist/references/src/legacy/pre-reference-format.d.ts +8 -0
  374. package/dist/references/src/legacy/pre-reference-mention.d.ts +27 -0
  375. package/dist/references/src/legacy/pre-reference-object.d.ts +8 -0
  376. package/dist/references/src/legacy/pre-reference-uri.d.ts +12 -0
  377. package/dist/references/src/legacy.d.ts +2 -0
  378. package/dist/references/src/mention-href-patterns.d.ts +19 -0
  379. package/dist/references/src/mention-node/index.d.ts +5 -0
  380. package/dist/references/src/mention-node/mention-node.d.ts +31 -0
  381. package/dist/references/src/mention-node/resolve-node-attrs.d.ts +27 -0
  382. package/dist/references/src/parse-reference.d.ts +23 -0
  383. package/dist/references/src/schemas.d.ts +463 -0
  384. package/dist/references/src/serialize-reference.d.ts +50 -0
  385. package/dist/references/src/sheet-name.d.ts +10 -0
  386. package/dist/references/src/tool-option-schemas.d.ts +597 -0
  387. package/dist/references/src/types.d.ts +125 -0
  388. package/dist/references/src/version-ref.d.ts +30 -0
  389. package/dist/runtime/statewire-lifecycle.d.ts +1 -1
  390. package/dist/runtime/statewire-model-lane.d.ts +1 -1
  391. package/dist/runtime/statewire-server-lane-context.d.ts +1 -1
  392. package/dist/runtime/statewire-session-key.cjs +7 -0
  393. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  394. package/dist/runtime/statewire-session-key.d.ts +19 -0
  395. package/dist/runtime/statewire-session-key.js +8 -1
  396. package/dist/runtime/statewire-session-key.js.map +1 -1
  397. package/dist/runtime/statewire-session-lane.cjs +48 -0
  398. package/dist/runtime/statewire-session-lane.cjs.map +1 -0
  399. package/dist/runtime/statewire-session-lane.d.ts +29 -0
  400. package/dist/runtime/statewire-session-lane.js +48 -0
  401. package/dist/runtime/statewire-session-lane.js.map +1 -0
  402. package/dist/runtime/statewire-thread-config-lane.d.ts +1 -1
  403. package/dist/runtime/useAthenaStatewireRuntime.cjs +19 -5
  404. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  405. package/dist/runtime/useAthenaStatewireRuntime.d.ts +15 -1
  406. package/dist/runtime/useAthenaStatewireRuntime.js +20 -6
  407. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  408. package/dist/styles.css +1 -1
  409. package/dist/threads/api.d.ts +1 -1
  410. package/dist/threads/conversation-list-fetcher.d.ts +1 -1
  411. package/dist/threads/index-triggered-refresh.cjs +164 -0
  412. package/dist/threads/index-triggered-refresh.cjs.map +1 -0
  413. package/dist/threads/index-triggered-refresh.d.ts +70 -0
  414. package/dist/threads/index-triggered-refresh.js +164 -0
  415. package/dist/threads/index-triggered-refresh.js.map +1 -0
  416. package/dist/threads/offline-session-list.d.ts +1 -1
  417. package/dist/threads/pull-request-display.d.ts +1 -1
  418. package/dist/threads/session-list-model.d.ts +1 -1
  419. package/dist/threads/session-list-tab-share.cjs +150 -0
  420. package/dist/threads/session-list-tab-share.cjs.map +1 -0
  421. package/dist/threads/session-list-tab-share.d.ts +73 -0
  422. package/dist/threads/session-list-tab-share.js +150 -0
  423. package/dist/threads/session-list-tab-share.js.map +1 -0
  424. package/dist/threads/session-row-parts.d.ts +1 -1
  425. package/dist/threads/sessions-query.d.ts +1 -1
  426. package/dist/threads/statewire-thread-list.cjs +42 -16
  427. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  428. package/dist/threads/statewire-thread-list.d.ts +11 -2
  429. package/dist/threads/statewire-thread-list.js +43 -17
  430. package/dist/threads/statewire-thread-list.js.map +1 -1
  431. package/dist/threads/thread-prefetcher.d.ts +1 -1
  432. package/dist/threads/use-athena-session-attention.d.ts +1 -1
  433. package/dist/threads/use-athena-sessions.cjs +32 -22
  434. package/dist/threads/use-athena-sessions.cjs.map +1 -1
  435. package/dist/threads/use-athena-sessions.js +33 -23
  436. package/dist/threads/use-athena-sessions.js.map +1 -1
  437. package/dist/threads/use-rest-conversation-history.d.ts +1 -1
  438. package/dist/threads/use-statewire-conversation-history.d.ts +5 -5
  439. package/dist/tiptap-markdown-table/src/markdown-table-serializer.d.ts +56 -0
  440. package/dist/tools/NestedPtcMessages.cjs +14 -9
  441. package/dist/tools/NestedPtcMessages.cjs.map +1 -1
  442. package/dist/tools/NestedPtcMessages.d.ts +9 -0
  443. package/dist/tools/NestedPtcMessages.js +6 -1
  444. package/dist/tools/NestedPtcMessages.js.map +1 -1
  445. package/dist/tools/index.d.ts +1 -1
  446. package/dist/tools/primitives.d.ts +1 -1
  447. package/dist/tools/subagent-task-tool-ui.cjs +494 -0
  448. package/dist/tools/subagent-task-tool-ui.cjs.map +1 -0
  449. package/dist/tools/subagent-task-tool-ui.d.ts +109 -0
  450. package/dist/tools/subagent-task-tool-ui.js +494 -0
  451. package/dist/tools/subagent-task-tool-ui.js.map +1 -0
  452. package/dist/tools/tool-fallback.d.ts +1 -1
  453. package/dist/tools/tool-icons.d.ts +1 -1
  454. package/dist/tools/tool-summary.d.ts +1 -1
  455. package/dist/tools/tool-uis.cjs +4 -0
  456. package/dist/tools/tool-uis.cjs.map +1 -1
  457. package/dist/tools/tool-uis.js +4 -0
  458. package/dist/tools/tool-uis.js.map +1 -1
  459. package/dist/voice/chat.cjs +6 -0
  460. package/dist/voice/chat.cjs.map +1 -0
  461. package/dist/voice/chat.d.ts +2 -0
  462. package/dist/voice/chat.js +6 -0
  463. package/dist/voice/chat.js.map +1 -0
  464. package/dist/voice/livekit-join.cjs +119 -0
  465. package/dist/voice/livekit-join.cjs.map +1 -0
  466. package/dist/voice/livekit-join.d.ts +8 -0
  467. package/dist/voice/livekit-join.js +119 -0
  468. package/dist/voice/livekit-join.js.map +1 -0
  469. package/dist/voice/livekit.cjs +32 -0
  470. package/dist/voice/livekit.cjs.map +1 -0
  471. package/dist/voice/livekit.d.ts +80 -0
  472. package/dist/voice/livekit.js +32 -0
  473. package/dist/voice/livekit.js.map +1 -0
  474. package/dist/voice/use-chat-voice-enabled.cjs +43 -0
  475. package/dist/voice/use-chat-voice-enabled.cjs.map +1 -0
  476. package/dist/voice/use-chat-voice-enabled.d.ts +9 -0
  477. package/dist/voice/use-chat-voice-enabled.js +43 -0
  478. package/dist/voice/use-chat-voice-enabled.js.map +1 -0
  479. package/package.json +22 -16
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The backend's running-tool placeholder: the ToolMessage a long-running tool's
3
+ * card shows until the tool returns — a `task` subagent's live transcript, a
4
+ * tool's preliminary result (Studio and Python execution progress, deep
5
+ * research, image descriptions, drive indexing, AOP progress), or a
6
+ * programmatic-tool-calling execution's sub-call log. Agora's
7
+ * `running_tool_placeholder` builds all three: id `tool-running-<tool_call_id>`
8
+ * and `additional_kwargs.streaming`. The tool's real ToolMessage replaces it by
9
+ * `tool_call_id`, with its own id and no such flag.
10
+ *
11
+ * A placeholder is a `tool` message, so its mere presence gives the call a
12
+ * defined `result`: read the flag before counting a call as done.
13
+ *
14
+ * Self-contained on purpose: the message converter imports it, so whatever it
15
+ * imports ships in every surface's startup bundle (the Office pane's startup
16
+ * budget has no room for `tool-result.ts`, which only tool cards need).
17
+ */
18
+ /** Whether a raw wire message is a running tool's placeholder rather than its result. */
19
+ export declare function isRunningToolPlaceholder(message: unknown): boolean;
20
+ /**
21
+ * Whether a converted tool-call part's `artifact` comes from a running tool's
22
+ * placeholder: the converter lifts a ToolMessage's `additional_kwargs` into
23
+ * `artifact._tool_message_metadata`, the marker included.
24
+ */
25
+ export declare function isRunningToolPlaceholderArtifact(artifact: unknown): boolean;
@@ -0,0 +1,11 @@
1
+ const RUNNING_PLACEHOLDER_KWARG = "streaming";
2
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
+ function isRunningToolPlaceholderArtifact(artifact) {
4
+ if (!isRecord(artifact)) return false;
5
+ const metadata = artifact._tool_message_metadata;
6
+ return isRecord(metadata) && metadata[RUNNING_PLACEHOLDER_KWARG] === true;
7
+ }
8
+ export {
9
+ isRunningToolPlaceholderArtifact
10
+ };
11
+ //# sourceMappingURL=running-tool-placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"running-tool-placeholder.js","sources":["../../../../agent-runtime/src/running-tool-placeholder.ts"],"sourcesContent":["/**\n * The backend's running-tool placeholder: the ToolMessage a long-running tool's\n * card shows until the tool returns — a `task` subagent's live transcript, a\n * tool's preliminary result (Studio and Python execution progress, deep\n * research, image descriptions, drive indexing, AOP progress), or a\n * programmatic-tool-calling execution's sub-call log. Agora's\n * `running_tool_placeholder` builds all three: id `tool-running-<tool_call_id>`\n * and `additional_kwargs.streaming`. The tool's real ToolMessage replaces it by\n * `tool_call_id`, with its own id and no such flag.\n *\n * A placeholder is a `tool` message, so its mere presence gives the call a\n * defined `result`: read the flag before counting a call as done.\n *\n * Self-contained on purpose: the message converter imports it, so whatever it\n * imports ships in every surface's startup bundle (the Office pane's startup\n * budget has no room for `tool-result.ts`, which only tool cards need).\n */\n\nconst RUNNING_PLACEHOLDER_KWARG = 'streaming';\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/** Whether a raw wire message is a running tool's placeholder rather than its result. */\nexport function isRunningToolPlaceholder(message: unknown): boolean {\n if (!isRecord(message) || message.type !== 'tool') return false;\n const kwargs = message.additional_kwargs;\n return isRecord(kwargs) && kwargs[RUNNING_PLACEHOLDER_KWARG] === true;\n}\n\n/**\n * Whether a converted tool-call part's `artifact` comes from a running tool's\n * placeholder: the converter lifts a ToolMessage's `additional_kwargs` into\n * `artifact._tool_message_metadata`, the marker included.\n */\nexport function isRunningToolPlaceholderArtifact(artifact: unknown): boolean {\n if (!isRecord(artifact)) return false;\n const metadata = artifact._tool_message_metadata;\n return isRecord(metadata) && metadata[RUNNING_PLACEHOLDER_KWARG] === true;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,4BAA4B;AAElC,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAc9D,SAAS,iCAAiC,UAA4B;AAC3E,MAAI,CAAC,SAAS,QAAQ,EAAG,QAAO;AAChC,QAAM,WAAW,SAAS;AAC1B,SAAO,SAAS,QAAQ,KAAK,SAAS,yBAAyB,MAAM;AACvE;"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Typed runtime messages — the one description of "the runtime ended this run"
3
+ * that every chat surface renders from.
4
+ *
5
+ * The deep-agent backend records how a run ended in two shapes that ride
6
+ * ordinary `ai` messages (a new LangChain message type would crash the shipped
7
+ * converter, whose convertible set is closed):
8
+ *
9
+ * - a **run-lifecycle marker** (`athena_run_marker`: `cancelled` / `failed`,
10
+ * plus `athena_run_marker_source`) — see {@link readRunMarkerFromSourceMessages};
11
+ * - a **handoff message** (`athena_handoff: true`) — the closing summary the
12
+ * runtime asked the model to write when a guard or the step budget ended the
13
+ * run, instead of fabricating an internal sentence.
14
+ *
15
+ * Both now carry the canonical `athena_termination_reason`
16
+ * (`agora/graphs/athena_deep_agent/termination.py`). This module reads all of
17
+ * that into one {@link AthenaRuntimeMessage} so Olympus, mobile, the Chrome
18
+ * extension, and the Office add-in agree on kind, severity, copy, and the
19
+ * sole-vs-grouped distinction — the last of which is load-bearing: a marker
20
+ * appended after the assistant's own work is chunked into that message, and
21
+ * replacing the whole row would hide completed prose and tool cards.
22
+ */
23
+ import { getExternalStoreMessages } from '@assistant-ui/core';
24
+ /** The backend's canonical reason vocabulary (`KNOWN_TERMINATION_REASONS`). */
25
+ export declare const TERMINATION_REASONS: readonly ['completed', 'user_stop', 'send_now', 'voice_steer', 'transport_cancel', 'pod_drain', 'fence_lost', 'instance_closed', 'unattributed_stop', 'recursion_limit', 'step_budget', 'duplicate_call_guard', 'synthetic_stop', 'ended_after_tools', 'error', 'model_refusal', 'abandoned'];
26
+ export type AthenaTerminationReason = (typeof TERMINATION_REASONS)[number];
27
+ /**
28
+ * How a runtime ending renders:
29
+ * - `stopped` — a cancellation the user (or a client action) asked for;
30
+ * - `paused` — a pod-drain pause; the run resumes from its checkpoint;
31
+ * - `failed` — the graph raised, hit the recursion limit, or was abandoned;
32
+ * - `handoff` — the runtime ended the run and the model wrote a closing
33
+ * summary (the message text), which renders as prose under a banner.
34
+ */
35
+ export type AthenaRuntimeMessageKind = 'stopped' | 'paused' | 'failed' | 'handoff';
36
+ export type AthenaRuntimeMessageSeverity = 'info' | 'warning' | 'error';
37
+ export interface TerminationDescription {
38
+ /** Short label for the banner / status row. */
39
+ title: string;
40
+ /** One sentence of reason-specific explanation, when it adds information. */
41
+ detail: string | undefined;
42
+ }
43
+ export interface AthenaRuntimeMessage {
44
+ kind: AthenaRuntimeMessageKind;
45
+ /** Canonical reason (may be a value newer than this client knows). */
46
+ reason: string | undefined;
47
+ severity: AthenaRuntimeMessageSeverity;
48
+ title: string;
49
+ detail: string | undefined;
50
+ /** The message's own text: a marker's backend copy, or the handoff summary. */
51
+ text: string | undefined;
52
+ /**
53
+ * A `send_now` promotion cancels the live run as plumbing, not as a
54
+ * user-visible stop: keep it in the data, paint nothing.
55
+ */
56
+ silent: boolean;
57
+ /**
58
+ * True when the runtime message is the ONLY source message behind this
59
+ * thread message (it owns the whole row). False when the chunk also holds
60
+ * the assistant's own work, which must keep rendering.
61
+ */
62
+ isSoleSourceMessage: boolean;
63
+ }
64
+ /**
65
+ * Copy for a runtime ending. Reasons this client does not know fall back to
66
+ * the kind's generic title, so a newer backend never renders as an empty row.
67
+ */
68
+ export declare function describeTerminationReason(kind: AthenaRuntimeMessageKind, reason: string | undefined): TerminationDescription;
69
+ type Kwargs = Record<string, unknown> | undefined;
70
+ /** The termination reason stamped on `additional_kwargs` (top-level or mirror). */
71
+ export declare function readTerminationReason(kwargs: Kwargs): string | undefined;
72
+ /**
73
+ * Read the runtime ending behind a thread message, from its bound source
74
+ * messages first (a marker or handoff chunked after the assistant's own turn
75
+ * is never the first source, so the joined `metadata.custom` would miss it —
76
+ * see {@link readRunMarkerFromSourceMessages}), then from joined metadata for
77
+ * surfaces without bound sources.
78
+ */
79
+ export declare function readRuntimeMessageFromSourceMessages(message: Parameters<typeof getExternalStoreMessages>[0] & {
80
+ metadata?: {
81
+ custom?: Record<string, unknown> | undefined;
82
+ } | undefined;
83
+ content?: unknown;
84
+ }): AthenaRuntimeMessage | undefined;
85
+ /**
86
+ * The backend marker copy worth showing under a runtime card, or `undefined`.
87
+ *
88
+ * A failure marker's text carries the specific error ("The run failed:
89
+ * provider returned 502"), so it is shown when no reason-specific detail
90
+ * exists. Stop/pause copy only restates the title, and a handoff's text is the
91
+ * message body itself, so neither is repeated. Marker copy leads with an emoji
92
+ * for raw-transcript readers; the card's icon plays that role, so it is
93
+ * stripped. Shared by every presenter so mobile and DOM cannot drift.
94
+ */
95
+ export declare function runtimeMessageMarkerText(message: AthenaRuntimeMessage): string | undefined;
96
+ /**
97
+ * The runtime message's kind when it owns the whole row, else `undefined`.
98
+ *
99
+ * Returns a primitive so it is safe as a `useAuiState` selector (the reader
100
+ * above builds a fresh object per call; an object snapshot would loop the
101
+ * render under `Object.is` comparison).
102
+ */
103
+ export declare function readSoleRuntimeMessageKind(message: Parameters<typeof readRuntimeMessageFromSourceMessages>[0]): AthenaRuntimeMessageKind | undefined;
104
+ export {};
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Screen points: the agent's on-screen coordinates as structured, renderable
3
+ * data.
4
+ *
5
+ * Browser agents already speak in `[x, y]` pairs — the `coordinate` argument
6
+ * of `chrome_computer` / `device_computer` / `computer` is a pixel in the
7
+ * screenshot the model was shown. In prose those pairs arrive as free text
8
+ * ("Delete at ~(1038, 81)"), which no surface can render as anything but
9
+ * characters. A screen point is that same pair written as a markdown link
10
+ * whose destination carries the pair *and the dimensions of the screenshot it
11
+ * was read from*:
12
+ *
13
+ * [Delete](athena-point://screenshot?x=1038&y=81&w=1280&h=720&tab=8811)
14
+ *
15
+ * The agent keeps its native vocabulary (the coordinate it already has, the
16
+ * screenshot size it was told) and does no arithmetic; every chat surface
17
+ * that understands the scheme renders the link as a chip and, because the
18
+ * basis dimensions travel with the point, can place a marker at the right
19
+ * relative spot on any later rendition of that screenshot however the
20
+ * transcript is laid out or the user's window is resized. Surfaces that do
21
+ * not understand the scheme show the label as plain text (a link with an
22
+ * unknown protocol), which is exactly the prose we have today — the format
23
+ * degrades to the status quo, never below it.
24
+ *
25
+ * Pure string and number work, UI-library-free, shared by every chat surface
26
+ * (Olympus, the React SDK hosts, the Chrome extension side panel) so a point
27
+ * that is valid on one surface is valid on all of them.
28
+ */
29
+ /** URL scheme of a screen-point link. */
30
+ export declare const SCREEN_POINT_PROTOCOL = "athena-point:";
31
+ /** Host of a screen-point link: the coordinate space the pair lives in. */
32
+ export declare const SCREEN_POINT_HOST = "screenshot";
33
+ /** `href.startsWith(SCREEN_POINT_HREF_PREFIX)` is the cheap pre-check every renderer runs. */
34
+ export declare const SCREEN_POINT_HREF_PREFIX = "athena-point://";
35
+ /**
36
+ * The largest coordinate or dimension a point may carry. No screenshot the
37
+ * runtime delivers approaches this; anything larger is a typo or a unit mix-up.
38
+ */
39
+ export declare const SCREEN_POINT_MAX_EXTENT = 32767;
40
+ /**
41
+ * The model-facing CUA screenshot size the Chrome extension emits by default
42
+ * (`athena-in-chrome/extension/src/background.ts`, `CHROME_DEFAULT_WIDTH` /
43
+ * `CHROME_DEFAULT_HEIGHT` in `chrome_browser_tools.py`). Surfaces may offer
44
+ * it as the fallback basis for a point that omits `w`/`h`, clearly labelled
45
+ * as assumed.
46
+ */
47
+ export declare const DEFAULT_CUA_SCREENSHOT_SIZE: {
48
+ readonly width: 1280;
49
+ readonly height: 720;
50
+ };
51
+ /** Width and height of a coordinate space, in that space's pixels. */
52
+ export interface ScreenSize {
53
+ width: number;
54
+ height: number;
55
+ }
56
+ /**
57
+ * A point in screenshot space. `basis` is the size of the screenshot the pair
58
+ * was read from; `null` when the link omitted it, in which case the point can
59
+ * be shown but not placed. `tabId` is the Chrome tab the screenshot came from
60
+ * when the agent had one.
61
+ */
62
+ export interface ScreenPoint {
63
+ x: number;
64
+ y: number;
65
+ basis: ScreenSize | null;
66
+ tabId: number | null;
67
+ }
68
+ /**
69
+ * Why a link that starts with the scheme could not become a point. Rendered
70
+ * surfaces show the label as text with the reason in a tooltip, so a broken
71
+ * link never becomes an interactive marker that points nowhere.
72
+ */
73
+ export type ScreenPointParseError = "not-screen-point" | "missing-coordinate" | "non-finite-number" | "negative-number" | "degenerate-basis" | "out-of-bounds" | "extent-too-large";
74
+ export type ScreenPointParseResult = {
75
+ ok: true;
76
+ point: ScreenPoint;
77
+ } | {
78
+ ok: false;
79
+ error: ScreenPointParseError;
80
+ };
81
+ /** Whether `href` is a screen-point link at all (the cheap pre-check). */
82
+ export declare function isScreenPointHref(href: string | null | undefined): href is string;
83
+ /**
84
+ * Parse a screen-point link. Accepts the canonical form
85
+ * `athena-point://screenshot?x=…&y=…&w=…&h=…&tab=…` and tolerates what a
86
+ * model plausibly writes instead: `width`/`height` for `w`/`h`, `tab_id` for
87
+ * `tab`, decimals, a leading `~`, and an empty or different host. Rejects,
88
+ * with a reason, anything that would place a marker in the wrong spot:
89
+ * non-finite or negative numbers, a zero or negative basis, a point outside
90
+ * its basis, and absurd extents.
91
+ */
92
+ export declare function parseScreenPointHref(href: string | null | undefined): ScreenPointParseResult;
93
+ /** The canonical link for a point — what the prompt teaches the agent to write. */
94
+ export declare function serializeScreenPointHref(point: ScreenPoint): string;
95
+ /**
96
+ * Where the point sits as a fraction of its basis, `0..1` on each axis, or
97
+ * `null` when the point has no basis to be relative to. This is the only
98
+ * number a renderer needs: `left: ${fx * 100}%` places the marker on any
99
+ * rendition of the screenshot, whatever size it is drawn at.
100
+ */
101
+ export declare function screenPointFraction(point: ScreenPoint): {
102
+ fx: number;
103
+ fy: number;
104
+ } | null;
105
+ /** Whether two sizes are the same to within the few-pixel jitter a resize or scrollbar introduces. */
106
+ export declare function sameScreenSize({ a, b, tolerancePx, }: {
107
+ a: ScreenSize;
108
+ b: ScreenSize;
109
+ tolerancePx?: number;
110
+ }): boolean;
111
+ /**
112
+ * How a point's basis relates to the screenshot it is about to be drawn on.
113
+ * Mirrors the runtime's dispatch contract (`browser_coordinate_contract.json`):
114
+ * the same size or a few pixels of jitter is `identity`; a uniform ratio on
115
+ * both axes (browser zoom, a resized window at the same aspect) is
116
+ * `uniform-scale` and the fraction still lands on the same element; anything
117
+ * else is a `mismatch` — a different aspect ratio means the screenshot shows a
118
+ * different framing (chrome headroom, a rotated device, a different tab) and
119
+ * a fraction placed on it would point at the wrong thing.
120
+ */
121
+ export type ScreenBasisFit = {
122
+ kind: "identity";
123
+ } | {
124
+ kind: "uniform-scale";
125
+ scale: number;
126
+ } | {
127
+ kind: "mismatch";
128
+ aspectDelta: number;
129
+ };
130
+ export declare function fitScreenBasis({ basis, target, aspectTolerance, }: {
131
+ basis: ScreenSize;
132
+ target: ScreenSize;
133
+ aspectTolerance?: number;
134
+ }): ScreenBasisFit;
135
+ /** Human-readable point for tooltips and accessible names: `(1038, 81) in a 1280×720 screenshot`. */
136
+ export declare function formatScreenPoint(point: ScreenPoint): string;
137
+ /** The sentence a surface shows for a link that failed to parse. */
138
+ export declare function describeScreenPointError(error: ScreenPointParseError): string;
139
+ /**
140
+ * Screen points written into a text block, in order. Used by surfaces that
141
+ * work on the raw markdown (the static message body's node parser, the
142
+ * extension's plain-text composer) and by tests. Only the link form is
143
+ * recognised — a bare `(1038, 81)` in prose is text, never a point, so a
144
+ * model that was not taught the scheme changes nothing.
145
+ */
146
+ export declare function findScreenPointLinks(text: string): Array<{
147
+ start: number;
148
+ end: number;
149
+ label: string;
150
+ href: string;
151
+ }>;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const idbGlobals = globalThis;
4
+ const SEALED_IV_BYTES = 12;
5
+ const encoder = new TextEncoder();
6
+ const decoder = new TextDecoder();
7
+ async function sha256Hex(value) {
8
+ const digest = await crypto.subtle.digest("SHA-256", encoder.encode(value));
9
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
10
+ }
11
+ async function sealJson({
12
+ key,
13
+ value,
14
+ aad
15
+ }) {
16
+ const iv = crypto.getRandomValues(new Uint8Array(SEALED_IV_BYTES));
17
+ const ciphertext = new Uint8Array(
18
+ await crypto.subtle.encrypt(
19
+ { name: "AES-GCM", iv, additionalData: encoder.encode(aad) },
20
+ key,
21
+ encoder.encode(JSON.stringify(value))
22
+ )
23
+ );
24
+ const sealed = new Uint8Array(SEALED_IV_BYTES + ciphertext.byteLength);
25
+ sealed.set(iv, 0);
26
+ sealed.set(ciphertext, SEALED_IV_BYTES);
27
+ return sealed;
28
+ }
29
+ async function openJson({
30
+ key,
31
+ sealed,
32
+ aad
33
+ }) {
34
+ const iv = sealed.subarray(0, SEALED_IV_BYTES);
35
+ const plaintext = await crypto.subtle.decrypt(
36
+ { name: "AES-GCM", iv, additionalData: encoder.encode(aad) },
37
+ key,
38
+ sealed.subarray(SEALED_IV_BYTES)
39
+ );
40
+ return JSON.parse(decoder.decode(plaintext));
41
+ }
42
+ function requestToPromise(request) {
43
+ return new Promise((resolve, reject) => {
44
+ request.onsuccess = () => resolve(request.result);
45
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
46
+ });
47
+ }
48
+ function transactionDone(tx) {
49
+ return new Promise((resolve, reject) => {
50
+ tx.oncomplete = () => resolve();
51
+ tx.onabort = () => reject(tx.error ?? new Error("IndexedDB transaction aborted"));
52
+ tx.onerror = () => reject(tx.error ?? new Error("IndexedDB transaction failed"));
53
+ });
54
+ }
55
+ function openSealedDatabase({
56
+ factory,
57
+ name,
58
+ version,
59
+ upgrade
60
+ }) {
61
+ return new Promise((resolve) => {
62
+ try {
63
+ const request = factory.open(name, version);
64
+ request.onupgradeneeded = () => upgrade(request.result);
65
+ request.onsuccess = () => {
66
+ const db = request.result;
67
+ db.onversionchange = () => db.close();
68
+ resolve(db);
69
+ };
70
+ request.onerror = () => resolve(null);
71
+ request.onblocked = () => resolve(null);
72
+ } catch {
73
+ resolve(null);
74
+ }
75
+ });
76
+ }
77
+ function lazySealedDatabase({
78
+ factory,
79
+ name,
80
+ version,
81
+ upgrade
82
+ }) {
83
+ let databasePromise = null;
84
+ return () => {
85
+ if (!factory || typeof crypto === "undefined" || !crypto.subtle) return Promise.resolve(null);
86
+ databasePromise ?? (databasePromise = openSealedDatabase({ factory, name, version, upgrade }).then(
87
+ (db) => {
88
+ if (db) {
89
+ const forget = () => {
90
+ databasePromise = null;
91
+ };
92
+ db.addEventListener("versionchange", forget);
93
+ db.addEventListener("close", forget);
94
+ } else {
95
+ databasePromise = null;
96
+ }
97
+ return db;
98
+ }
99
+ ));
100
+ return databasePromise;
101
+ };
102
+ }
103
+ exports.SEALED_IV_BYTES = SEALED_IV_BYTES;
104
+ exports.idbGlobals = idbGlobals;
105
+ exports.lazySealedDatabase = lazySealedDatabase;
106
+ exports.openJson = openJson;
107
+ exports.openSealedDatabase = openSealedDatabase;
108
+ exports.requestToPromise = requestToPromise;
109
+ exports.sealJson = sealJson;
110
+ exports.sha256Hex = sha256Hex;
111
+ exports.transactionDone = transactionDone;
112
+ //# sourceMappingURL=sealed-idb.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sealed-idb.cjs","sources":["../../../../agent-runtime/src/sealed-idb.ts"],"sourcesContent":["/**\n * The sealed-record toolkit the device stores in this package share (the thread snapshot mirror,\n * the chat outbox): AES-GCM-256 sealing with a fresh IV and additional data that binds a record to\n * where it is stored, SHA-256 names so a database names no one, and the part of IndexedDB they use.\n *\n * This package compiles without the DOM lib (React Native honesty, `globals.d.ts`), so IndexedDB is\n * described structurally here; the stores run only where it exists and degrade to nothing where it\n * does not.\n */\n\nexport type IdbListener = ((event?: unknown) => void) | null;\n\nexport interface IdbRequest<T> {\n readonly result: T;\n readonly error: unknown;\n onsuccess: IdbListener;\n onerror: IdbListener;\n}\n\nexport interface IdbOpenRequest extends IdbRequest<IdbDatabase> {\n onupgradeneeded: IdbListener;\n onblocked: IdbListener;\n}\n\nexport interface IdbFactory {\n open(name: string, version?: number): IdbOpenRequest;\n}\n\nexport interface IdbCursor {\n readonly primaryKey: unknown;\n continue(): void;\n}\n\nexport interface IdbIndex {\n getAll(query?: unknown): IdbRequest<unknown[]>;\n getAllKeys(query?: unknown): IdbRequest<unknown[]>;\n openKeyCursor(range?: unknown, direction?: string): IdbRequest<IdbCursor | null>;\n}\n\nexport interface IdbObjectStore {\n put(value: unknown): IdbRequest<unknown>;\n get(key: unknown): IdbRequest<unknown>;\n delete(key: unknown): IdbRequest<unknown>;\n clear(): IdbRequest<unknown>;\n index(name: string): IdbIndex;\n createIndex(name: string, keyPath: string | string[], options?: { unique?: boolean }): unknown;\n}\n\nexport interface IdbTransaction {\n objectStore(name: string): IdbObjectStore;\n readonly error: unknown;\n oncomplete: IdbListener;\n onabort: IdbListener;\n onerror: IdbListener;\n}\n\nexport interface IdbDatabase {\n readonly objectStoreNames: { contains(name: string): boolean };\n transaction(stores: string | string[], mode?: \"readonly\" | \"readwrite\"): IdbTransaction;\n createObjectStore(name: string, options?: { keyPath: string }): IdbObjectStore;\n onversionchange: IdbListener;\n addEventListener(type: string, listener: () => void): void;\n close(): void;\n}\n\nexport interface IdbKeyRangeStatic {\n bound(lower: unknown, upper: unknown): unknown;\n}\n\nexport const idbGlobals = globalThis as { indexedDB?: object; IDBKeyRange?: IdbKeyRangeStatic };\n\n/** The AES-GCM IV length, prefixed to every sealed payload. */\nexport const SEALED_IV_BYTES = 12;\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport async function sha256Hex(value: string): Promise<string> {\n const digest = await crypto.subtle.digest(\"SHA-256\", encoder.encode(value));\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/** `value` as JSON, sealed under `key` with a fresh IV; `aad` binds it to where it is stored. */\nexport async function sealJson({\n key,\n value,\n aad,\n}: {\n key: CryptoKey;\n value: unknown;\n aad: string;\n}): Promise<Uint8Array> {\n const iv = crypto.getRandomValues(new Uint8Array(SEALED_IV_BYTES));\n const ciphertext = new Uint8Array(\n await crypto.subtle.encrypt(\n { name: \"AES-GCM\", iv, additionalData: encoder.encode(aad) },\n key,\n encoder.encode(JSON.stringify(value)),\n ),\n );\n const sealed = new Uint8Array(SEALED_IV_BYTES + ciphertext.byteLength);\n sealed.set(iv, 0);\n sealed.set(ciphertext, SEALED_IV_BYTES);\n return sealed;\n}\n\n/** Opens what {@link sealJson} sealed; throws for the wrong key, the wrong `aad`, or a damaged record. */\nexport async function openJson({\n key,\n sealed,\n aad,\n}: {\n key: CryptoKey;\n sealed: Uint8Array;\n aad: string;\n}): Promise<unknown> {\n const iv = sealed.subarray(0, SEALED_IV_BYTES) as Uint8Array<ArrayBuffer>;\n const plaintext = await crypto.subtle.decrypt(\n { name: \"AES-GCM\", iv, additionalData: encoder.encode(aad) },\n key,\n sealed.subarray(SEALED_IV_BYTES) as Uint8Array<ArrayBuffer>,\n );\n return JSON.parse(decoder.decode(plaintext)) as unknown;\n}\n\nexport function requestToPromise<T>(request: IdbRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error ?? new Error(\"IndexedDB request failed\"));\n });\n}\n\nexport function transactionDone(tx: IdbTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n tx.oncomplete = () => resolve();\n tx.onabort = () => reject(tx.error ?? new Error(\"IndexedDB transaction aborted\"));\n tx.onerror = () => reject(tx.error ?? new Error(\"IndexedDB transaction failed\"));\n });\n}\n\n/**\n * Opens `name` at `version`, creating what `upgrade` creates. Resolves `null` instead of failing:\n * a database a newer build upgraded past this version, a blocked open, or no IndexedDB at all\n * (private browsing, SSR) all mean \"no store here\".\n */\nexport function openSealedDatabase({\n factory,\n name,\n version,\n upgrade,\n}: {\n factory: IdbFactory;\n name: string;\n version: number;\n upgrade: (db: IdbDatabase) => void;\n}): Promise<IdbDatabase | null> {\n return new Promise((resolve) => {\n try {\n const request = factory.open(name, version);\n request.onupgradeneeded = () => upgrade(request.result);\n request.onsuccess = () => {\n const db = request.result;\n // Another page deleting or upgrading the database: step aside.\n db.onversionchange = () => db.close();\n resolve(db);\n };\n request.onerror = () => resolve(null);\n request.onblocked = () => resolve(null);\n } catch {\n resolve(null);\n }\n });\n}\n\n/**\n * A lazily opened database handle that reopens after the browser (or another page's upgrade or\n * delete) closes it. `null` while there is no IndexedDB or Web Crypto here.\n */\nexport function lazySealedDatabase({\n factory,\n name,\n version,\n upgrade,\n}: {\n factory: object | undefined;\n name: string;\n version: number;\n upgrade: (db: IdbDatabase) => void;\n}): () => Promise<IdbDatabase | null> {\n let databasePromise: Promise<IdbDatabase | null> | null = null;\n return () => {\n if (!factory || typeof crypto === \"undefined\" || !crypto.subtle) return Promise.resolve(null);\n databasePromise ??= openSealedDatabase({ factory: factory as IdbFactory, name, version, upgrade }).then(\n (db) => {\n if (db) {\n const forget = () => {\n databasePromise = null;\n };\n db.addEventListener(\"versionchange\", forget);\n db.addEventListener(\"close\", forget);\n } else {\n databasePromise = null;\n }\n return db;\n },\n );\n return databasePromise;\n };\n}\n"],"names":[],"mappings":";;AAqEO,MAAM,aAAa;AAGnB,MAAM,kBAAkB;AAE/B,MAAM,UAAU,IAAI,YAAA;AACpB,MAAM,UAAU,IAAI,YAAA;AAEpB,eAAsB,UAAU,OAAgC;AAC9D,QAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,QAAQ,OAAO,KAAK,CAAC;AAC1E,SAAO,MAAM,KAAK,IAAI,WAAW,MAAM,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACjG;AAGA,eAAsB,SAAS;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIwB;AACtB,QAAM,KAAK,OAAO,gBAAgB,IAAI,WAAW,eAAe,CAAC;AACjE,QAAM,aAAa,IAAI;AAAA,IACrB,MAAM,OAAO,OAAO;AAAA,MAClB,EAAE,MAAM,WAAW,IAAI,gBAAgB,QAAQ,OAAO,GAAG,EAAA;AAAA,MACzD;AAAA,MACA,QAAQ,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IAAA;AAAA,EACtC;AAEF,QAAM,SAAS,IAAI,WAAW,kBAAkB,WAAW,UAAU;AACrE,SAAO,IAAI,IAAI,CAAC;AAChB,SAAO,IAAI,YAAY,eAAe;AACtC,SAAO;AACT;AAGA,eAAsB,SAAS;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACF,GAIqB;AACnB,QAAM,KAAK,OAAO,SAAS,GAAG,eAAe;AAC7C,QAAM,YAAY,MAAM,OAAO,OAAO;AAAA,IACpC,EAAE,MAAM,WAAW,IAAI,gBAAgB,QAAQ,OAAO,GAAG,EAAA;AAAA,IACzD;AAAA,IACA,OAAO,SAAS,eAAe;AAAA,EAAA;AAEjC,SAAO,KAAK,MAAM,QAAQ,OAAO,SAAS,CAAC;AAC7C;AAEO,SAAS,iBAAoB,SAAoC;AACtE,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,YAAQ,YAAY,MAAM,QAAQ,QAAQ,MAAM;AAChD,YAAQ,UAAU,MAAM,OAAO,QAAQ,SAAS,IAAI,MAAM,0BAA0B,CAAC;AAAA,EACvF,CAAC;AACH;AAEO,SAAS,gBAAgB,IAAmC;AACjE,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,OAAG,aAAa,MAAM,QAAA;AACtB,OAAG,UAAU,MAAM,OAAO,GAAG,SAAS,IAAI,MAAM,+BAA+B,CAAC;AAChF,OAAG,UAAU,MAAM,OAAO,GAAG,SAAS,IAAI,MAAM,8BAA8B,CAAC;AAAA,EACjF,CAAC;AACH;AAOO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKgC;AAC9B,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI;AACF,YAAM,UAAU,QAAQ,KAAK,MAAM,OAAO;AAC1C,cAAQ,kBAAkB,MAAM,QAAQ,QAAQ,MAAM;AACtD,cAAQ,YAAY,MAAM;AACxB,cAAM,KAAK,QAAQ;AAEnB,WAAG,kBAAkB,MAAM,GAAG,MAAA;AAC9B,gBAAQ,EAAE;AAAA,MACZ;AACA,cAAQ,UAAU,MAAM,QAAQ,IAAI;AACpC,cAAQ,YAAY,MAAM,QAAQ,IAAI;AAAA,IACxC,QAAQ;AACN,cAAQ,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACH;AAMO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKsC;AACpC,MAAI,kBAAsD;AAC1D,SAAO,MAAM;AACX,QAAI,CAAC,WAAW,OAAO,WAAW,eAAe,CAAC,OAAO,OAAQ,QAAO,QAAQ,QAAQ,IAAI;AAC5F,0CAAoB,mBAAmB,EAAE,SAAgC,MAAM,SAAS,QAAA,CAAS,EAAE;AAAA,MACjG,CAAC,OAAO;AACN,YAAI,IAAI;AACN,gBAAM,SAAS,MAAM;AACnB,8BAAkB;AAAA,UACpB;AACA,aAAG,iBAAiB,iBAAiB,MAAM;AAC3C,aAAG,iBAAiB,SAAS,MAAM;AAAA,QACrC,OAAO;AACL,4BAAkB;AAAA,QACpB;AACA,eAAO;AAAA,MACT;AAAA,IAAA;AAEF,WAAO;AAAA,EACT;AACF;;;;;;;;;;"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * The sealed-record toolkit the device stores in this package share (the thread snapshot mirror,
3
+ * the chat outbox): AES-GCM-256 sealing with a fresh IV and additional data that binds a record to
4
+ * where it is stored, SHA-256 names so a database names no one, and the part of IndexedDB they use.
5
+ *
6
+ * This package compiles without the DOM lib (React Native honesty, `globals.d.ts`), so IndexedDB is
7
+ * described structurally here; the stores run only where it exists and degrade to nothing where it
8
+ * does not.
9
+ */
10
+ export type IdbListener = ((event?: unknown) => void) | null;
11
+ export interface IdbRequest<T> {
12
+ readonly result: T;
13
+ readonly error: unknown;
14
+ onsuccess: IdbListener;
15
+ onerror: IdbListener;
16
+ }
17
+ export interface IdbOpenRequest extends IdbRequest<IdbDatabase> {
18
+ onupgradeneeded: IdbListener;
19
+ onblocked: IdbListener;
20
+ }
21
+ export interface IdbFactory {
22
+ open(name: string, version?: number): IdbOpenRequest;
23
+ }
24
+ export interface IdbCursor {
25
+ readonly primaryKey: unknown;
26
+ continue(): void;
27
+ }
28
+ export interface IdbIndex {
29
+ getAll(query?: unknown): IdbRequest<unknown[]>;
30
+ getAllKeys(query?: unknown): IdbRequest<unknown[]>;
31
+ openKeyCursor(range?: unknown, direction?: string): IdbRequest<IdbCursor | null>;
32
+ }
33
+ export interface IdbObjectStore {
34
+ put(value: unknown): IdbRequest<unknown>;
35
+ get(key: unknown): IdbRequest<unknown>;
36
+ delete(key: unknown): IdbRequest<unknown>;
37
+ clear(): IdbRequest<unknown>;
38
+ index(name: string): IdbIndex;
39
+ createIndex(name: string, keyPath: string | string[], options?: {
40
+ unique?: boolean;
41
+ }): unknown;
42
+ }
43
+ export interface IdbTransaction {
44
+ objectStore(name: string): IdbObjectStore;
45
+ readonly error: unknown;
46
+ oncomplete: IdbListener;
47
+ onabort: IdbListener;
48
+ onerror: IdbListener;
49
+ }
50
+ export interface IdbDatabase {
51
+ readonly objectStoreNames: {
52
+ contains(name: string): boolean;
53
+ };
54
+ transaction(stores: string | string[], mode?: "readonly" | "readwrite"): IdbTransaction;
55
+ createObjectStore(name: string, options?: {
56
+ keyPath: string;
57
+ }): IdbObjectStore;
58
+ onversionchange: IdbListener;
59
+ addEventListener(type: string, listener: () => void): void;
60
+ close(): void;
61
+ }
62
+ export interface IdbKeyRangeStatic {
63
+ bound(lower: unknown, upper: unknown): unknown;
64
+ }
65
+ export declare const idbGlobals: {
66
+ indexedDB?: object;
67
+ IDBKeyRange?: IdbKeyRangeStatic;
68
+ };
69
+ /** The AES-GCM IV length, prefixed to every sealed payload. */
70
+ export declare const SEALED_IV_BYTES = 12;
71
+ export declare function sha256Hex(value: string): Promise<string>;
72
+ /** `value` as JSON, sealed under `key` with a fresh IV; `aad` binds it to where it is stored. */
73
+ export declare function sealJson({ key, value, aad, }: {
74
+ key: CryptoKey;
75
+ value: unknown;
76
+ aad: string;
77
+ }): Promise<Uint8Array>;
78
+ /** Opens what {@link sealJson} sealed; throws for the wrong key, the wrong `aad`, or a damaged record. */
79
+ export declare function openJson({ key, sealed, aad, }: {
80
+ key: CryptoKey;
81
+ sealed: Uint8Array;
82
+ aad: string;
83
+ }): Promise<unknown>;
84
+ export declare function requestToPromise<T>(request: IdbRequest<T>): Promise<T>;
85
+ export declare function transactionDone(tx: IdbTransaction): Promise<void>;
86
+ /**
87
+ * Opens `name` at `version`, creating what `upgrade` creates. Resolves `null` instead of failing:
88
+ * a database a newer build upgraded past this version, a blocked open, or no IndexedDB at all
89
+ * (private browsing, SSR) all mean "no store here".
90
+ */
91
+ export declare function openSealedDatabase({ factory, name, version, upgrade, }: {
92
+ factory: IdbFactory;
93
+ name: string;
94
+ version: number;
95
+ upgrade: (db: IdbDatabase) => void;
96
+ }): Promise<IdbDatabase | null>;
97
+ /**
98
+ * A lazily opened database handle that reopens after the browser (or another page's upgrade or
99
+ * delete) closes it. `null` while there is no IndexedDB or Web Crypto here.
100
+ */
101
+ export declare function lazySealedDatabase({ factory, name, version, upgrade, }: {
102
+ factory: object | undefined;
103
+ name: string;
104
+ version: number;
105
+ upgrade: (db: IdbDatabase) => void;
106
+ }): () => Promise<IdbDatabase | null>;
@@ -0,0 +1,112 @@
1
+ const idbGlobals = globalThis;
2
+ const SEALED_IV_BYTES = 12;
3
+ const encoder = new TextEncoder();
4
+ const decoder = new TextDecoder();
5
+ async function sha256Hex(value) {
6
+ const digest = await crypto.subtle.digest("SHA-256", encoder.encode(value));
7
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
8
+ }
9
+ async function sealJson({
10
+ key,
11
+ value,
12
+ aad
13
+ }) {
14
+ const iv = crypto.getRandomValues(new Uint8Array(SEALED_IV_BYTES));
15
+ const ciphertext = new Uint8Array(
16
+ await crypto.subtle.encrypt(
17
+ { name: "AES-GCM", iv, additionalData: encoder.encode(aad) },
18
+ key,
19
+ encoder.encode(JSON.stringify(value))
20
+ )
21
+ );
22
+ const sealed = new Uint8Array(SEALED_IV_BYTES + ciphertext.byteLength);
23
+ sealed.set(iv, 0);
24
+ sealed.set(ciphertext, SEALED_IV_BYTES);
25
+ return sealed;
26
+ }
27
+ async function openJson({
28
+ key,
29
+ sealed,
30
+ aad
31
+ }) {
32
+ const iv = sealed.subarray(0, SEALED_IV_BYTES);
33
+ const plaintext = await crypto.subtle.decrypt(
34
+ { name: "AES-GCM", iv, additionalData: encoder.encode(aad) },
35
+ key,
36
+ sealed.subarray(SEALED_IV_BYTES)
37
+ );
38
+ return JSON.parse(decoder.decode(plaintext));
39
+ }
40
+ function requestToPromise(request) {
41
+ return new Promise((resolve, reject) => {
42
+ request.onsuccess = () => resolve(request.result);
43
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
44
+ });
45
+ }
46
+ function transactionDone(tx) {
47
+ return new Promise((resolve, reject) => {
48
+ tx.oncomplete = () => resolve();
49
+ tx.onabort = () => reject(tx.error ?? new Error("IndexedDB transaction aborted"));
50
+ tx.onerror = () => reject(tx.error ?? new Error("IndexedDB transaction failed"));
51
+ });
52
+ }
53
+ function openSealedDatabase({
54
+ factory,
55
+ name,
56
+ version,
57
+ upgrade
58
+ }) {
59
+ return new Promise((resolve) => {
60
+ try {
61
+ const request = factory.open(name, version);
62
+ request.onupgradeneeded = () => upgrade(request.result);
63
+ request.onsuccess = () => {
64
+ const db = request.result;
65
+ db.onversionchange = () => db.close();
66
+ resolve(db);
67
+ };
68
+ request.onerror = () => resolve(null);
69
+ request.onblocked = () => resolve(null);
70
+ } catch {
71
+ resolve(null);
72
+ }
73
+ });
74
+ }
75
+ function lazySealedDatabase({
76
+ factory,
77
+ name,
78
+ version,
79
+ upgrade
80
+ }) {
81
+ let databasePromise = null;
82
+ return () => {
83
+ if (!factory || typeof crypto === "undefined" || !crypto.subtle) return Promise.resolve(null);
84
+ databasePromise ?? (databasePromise = openSealedDatabase({ factory, name, version, upgrade }).then(
85
+ (db) => {
86
+ if (db) {
87
+ const forget = () => {
88
+ databasePromise = null;
89
+ };
90
+ db.addEventListener("versionchange", forget);
91
+ db.addEventListener("close", forget);
92
+ } else {
93
+ databasePromise = null;
94
+ }
95
+ return db;
96
+ }
97
+ ));
98
+ return databasePromise;
99
+ };
100
+ }
101
+ export {
102
+ SEALED_IV_BYTES,
103
+ idbGlobals,
104
+ lazySealedDatabase,
105
+ openJson,
106
+ openSealedDatabase,
107
+ requestToPromise,
108
+ sealJson,
109
+ sha256Hex,
110
+ transactionDone
111
+ };
112
+ //# sourceMappingURL=sealed-idb.js.map