@kortix/sdk 0.12.7 → 0.13.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 (287) hide show
  1. package/README.md +13 -6
  2. package/dist/browser/session-sync/session-sync-registry.d.ts +7 -2
  3. package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
  4. package/dist/browser/session-sync/session-sync-registry.js +33 -44
  5. package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
  6. package/dist/browser/stores/opencode-compaction-store.d.ts +9 -3
  7. package/dist/browser/stores/opencode-compaction-store.d.ts.map +1 -1
  8. package/dist/browser/stores/opencode-compaction-store.js +5 -12
  9. package/dist/browser/stores/opencode-compaction-store.js.map +1 -1
  10. package/dist/browser/stores/sandbox-connection-store.d.ts +28 -17
  11. package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
  12. package/dist/browser/stores/sandbox-connection-store.js +32 -84
  13. package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
  14. package/dist/browser/stores/session-working-store.d.ts +73 -0
  15. package/dist/browser/stores/session-working-store.d.ts.map +1 -0
  16. package/dist/browser/stores/session-working-store.js +86 -0
  17. package/dist/browser/stores/session-working-store.js.map +1 -0
  18. package/dist/browser/stores/sync-store/types.d.ts +14 -4
  19. package/dist/browser/stores/sync-store/types.d.ts.map +1 -1
  20. package/dist/browser/stores/sync-store.d.ts +140 -3
  21. package/dist/browser/stores/sync-store.d.ts.map +1 -1
  22. package/dist/browser/stores/sync-store.js +425 -36
  23. package/dist/browser/stores/sync-store.js.map +1 -1
  24. package/dist/core/client/kortix.d.ts +102 -1
  25. package/dist/core/client/kortix.d.ts.map +1 -1
  26. package/dist/core/client/kortix.js +78 -0
  27. package/dist/core/client/kortix.js.map +1 -1
  28. package/dist/core/files/client.d.ts +50 -2
  29. package/dist/core/files/client.d.ts.map +1 -1
  30. package/dist/core/files/client.js +253 -44
  31. package/dist/core/files/client.js.map +1 -1
  32. package/dist/core/files/types.d.ts +11 -0
  33. package/dist/core/files/types.d.ts.map +1 -1
  34. package/dist/core/http/abort-error.d.ts +89 -0
  35. package/dist/core/http/abort-error.d.ts.map +1 -0
  36. package/dist/core/http/abort-error.js +190 -0
  37. package/dist/core/http/abort-error.js.map +1 -0
  38. package/dist/core/http/api-client.d.ts.map +1 -1
  39. package/dist/core/http/api-client.js +28 -4
  40. package/dist/core/http/api-client.js.map +1 -1
  41. package/dist/core/http/impersonation.d.ts +58 -0
  42. package/dist/core/http/impersonation.d.ts.map +1 -0
  43. package/dist/core/http/impersonation.js +174 -0
  44. package/dist/core/http/impersonation.js.map +1 -0
  45. package/dist/core/rest/platform-client/github-app.d.ts +13 -0
  46. package/dist/core/rest/platform-client/github-app.d.ts.map +1 -1
  47. package/dist/core/rest/platform-client/github-app.js +2 -0
  48. package/dist/core/rest/platform-client/github-app.js.map +1 -1
  49. package/dist/core/rest/platform-client/members.d.ts +10 -64
  50. package/dist/core/rest/platform-client/members.d.ts.map +1 -1
  51. package/dist/core/rest/platform-client/members.js +10 -28
  52. package/dist/core/rest/platform-client/members.js.map +1 -1
  53. package/dist/core/rest/projects-client/accounts.d.ts +30 -1
  54. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  55. package/dist/core/rest/projects-client/accounts.js +1 -1
  56. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  57. package/dist/core/rest/projects-client/agent-config.d.ts +21 -0
  58. package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
  59. package/dist/core/rest/projects-client/agent-config.js +14 -0
  60. package/dist/core/rest/projects-client/agent-config.js.map +1 -1
  61. package/dist/core/rest/projects-client/apps.d.ts +13 -0
  62. package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
  63. package/dist/core/rest/projects-client/apps.js.map +1 -1
  64. package/dist/core/rest/projects-client/assignments.d.ts +114 -0
  65. package/dist/core/rest/projects-client/assignments.d.ts.map +1 -0
  66. package/dist/core/rest/projects-client/assignments.js +91 -0
  67. package/dist/core/rest/projects-client/assignments.js.map +1 -0
  68. package/dist/core/rest/projects-client/billing.d.ts +80 -1
  69. package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
  70. package/dist/core/rest/projects-client/billing.js +61 -2
  71. package/dist/core/rest/projects-client/billing.js.map +1 -1
  72. package/dist/core/rest/projects-client/connectors.d.ts +2 -0
  73. package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
  74. package/dist/core/rest/projects-client/connectors.js.map +1 -1
  75. package/dist/core/rest/projects-client/files.js +2 -2
  76. package/dist/core/rest/projects-client/files.js.map +1 -1
  77. package/dist/core/rest/projects-client/gateway.d.ts +51 -0
  78. package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
  79. package/dist/core/rest/projects-client/gateway.js.map +1 -1
  80. package/dist/core/rest/projects-client/iam.d.ts +51 -3
  81. package/dist/core/rest/projects-client/iam.d.ts.map +1 -1
  82. package/dist/core/rest/projects-client/iam.js +18 -1
  83. package/dist/core/rest/projects-client/iam.js.map +1 -1
  84. package/dist/core/rest/projects-client/index.d.ts +1 -0
  85. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  86. package/dist/core/rest/projects-client/index.js +1 -0
  87. package/dist/core/rest/projects-client/index.js.map +1 -1
  88. package/dist/core/rest/projects-client/projects.d.ts +1 -1
  89. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  90. package/dist/core/rest/projects-client/projects.js +3 -0
  91. package/dist/core/rest/projects-client/projects.js.map +1 -1
  92. package/dist/core/rest/projects-client/secrets.d.ts +11 -0
  93. package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
  94. package/dist/core/rest/projects-client/secrets.js +1 -1
  95. package/dist/core/rest/projects-client/secrets.js.map +1 -1
  96. package/dist/core/rest/projects-client/session-costs.d.ts +33 -0
  97. package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
  98. package/dist/core/rest/projects-client/session-costs.js.map +1 -1
  99. package/dist/core/rest/projects-client/sessions.d.ts +253 -4
  100. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  101. package/dist/core/rest/projects-client/sessions.js +101 -4
  102. package/dist/core/rest/projects-client/sessions.js.map +1 -1
  103. package/dist/core/rest/projects-client/shared.d.ts +10 -1
  104. package/dist/core/rest/projects-client/shared.d.ts.map +1 -1
  105. package/dist/core/rest/projects-client/shared.js.map +1 -1
  106. package/dist/core/rest/projects-client/tokens.d.ts +13 -1
  107. package/dist/core/rest/projects-client/tokens.d.ts.map +1 -1
  108. package/dist/core/rest/projects-client/tokens.js +7 -2
  109. package/dist/core/rest/projects-client/tokens.js.map +1 -1
  110. package/dist/core/rest/projects-client/triggers.d.ts +69 -2
  111. package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
  112. package/dist/core/rest/projects-client/triggers.js +1 -1
  113. package/dist/core/rest/projects-client/triggers.js.map +1 -1
  114. package/dist/core/session/compaction.d.ts +98 -0
  115. package/dist/core/session/compaction.d.ts.map +1 -0
  116. package/dist/core/session/compaction.js +108 -0
  117. package/dist/core/session/compaction.js.map +1 -0
  118. package/dist/core/session/health.d.ts +22 -0
  119. package/dist/core/session/health.d.ts.map +1 -1
  120. package/dist/core/session/health.js +31 -5
  121. package/dist/core/session/health.js.map +1 -1
  122. package/dist/core/session/index.d.ts +2 -0
  123. package/dist/core/session/index.d.ts.map +1 -1
  124. package/dist/core/session/index.js +2 -0
  125. package/dist/core/session/index.js.map +1 -1
  126. package/dist/core/session/message-queue.d.ts +79 -15
  127. package/dist/core/session/message-queue.d.ts.map +1 -1
  128. package/dist/core/session/message-queue.js +73 -27
  129. package/dist/core/session/message-queue.js.map +1 -1
  130. package/dist/core/session/rewind.d.ts +76 -10
  131. package/dist/core/session/rewind.d.ts.map +1 -1
  132. package/dist/core/session/rewind.js +68 -11
  133. package/dist/core/session/rewind.js.map +1 -1
  134. package/dist/core/session/working.d.ts +241 -0
  135. package/dist/core/session/working.d.ts.map +1 -0
  136. package/dist/core/session/working.js +261 -0
  137. package/dist/core/session/working.js.map +1 -0
  138. package/dist/core/session-sync/session-sync-controller.d.ts +35 -20
  139. package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
  140. package/dist/core/session-sync/session-sync-controller.js +48 -115
  141. package/dist/core/session-sync/session-sync-controller.js.map +1 -1
  142. package/dist/core/stream/event-stream.d.ts +22 -0
  143. package/dist/core/stream/event-stream.d.ts.map +1 -1
  144. package/dist/core/stream/event-stream.js +132 -36
  145. package/dist/core/stream/event-stream.js.map +1 -1
  146. package/dist/core/turns/classify.d.ts +5 -2
  147. package/dist/core/turns/classify.d.ts.map +1 -1
  148. package/dist/core/turns/classify.js +1 -0
  149. package/dist/core/turns/classify.js.map +1 -1
  150. package/dist/core/turns/errors.d.ts +11 -0
  151. package/dist/core/turns/errors.d.ts.map +1 -1
  152. package/dist/core/turns/errors.js +49 -2
  153. package/dist/core/turns/errors.js.map +1 -1
  154. package/dist/core/turns/grouping.d.ts +32 -2
  155. package/dist/core/turns/grouping.d.ts.map +1 -1
  156. package/dist/core/turns/grouping.js +31 -2
  157. package/dist/core/turns/grouping.js.map +1 -1
  158. package/dist/core/turns/index.d.ts +1 -0
  159. package/dist/core/turns/index.d.ts.map +1 -1
  160. package/dist/core/turns/index.js +1 -0
  161. package/dist/core/turns/index.js.map +1 -1
  162. package/dist/core/turns/open-turn.d.ts +81 -0
  163. package/dist/core/turns/open-turn.d.ts.map +1 -0
  164. package/dist/core/turns/open-turn.js +77 -0
  165. package/dist/core/turns/open-turn.js.map +1 -0
  166. package/dist/core/turns/state.d.ts +1 -1
  167. package/dist/core/turns/state.d.ts.map +1 -1
  168. package/dist/core/turns/state.js +29 -27
  169. package/dist/core/turns/state.js.map +1 -1
  170. package/dist/core/turns/types.d.ts +8 -0
  171. package/dist/core/turns/types.d.ts.map +1 -1
  172. package/dist/index.d.ts +3 -1
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/index.js +3 -1
  175. package/dist/index.js.map +1 -1
  176. package/dist/kortix.esm.min.js +25 -25
  177. package/dist/kortix.global.js +25 -25
  178. package/dist/node/server.d.ts.map +1 -1
  179. package/dist/node/server.js +14 -2
  180. package/dist/node/server.js.map +1 -1
  181. package/dist/react/index.d.ts +3 -1
  182. package/dist/react/index.d.ts.map +1 -1
  183. package/dist/react/index.js +8 -1
  184. package/dist/react/index.js.map +1 -1
  185. package/dist/react/initial-session-pin.d.ts +17 -0
  186. package/dist/react/initial-session-pin.d.ts.map +1 -1
  187. package/dist/react/initial-session-pin.js +58 -0
  188. package/dist/react/initial-session-pin.js.map +1 -1
  189. package/dist/react/opencode.d.ts +6 -2
  190. package/dist/react/opencode.d.ts.map +1 -1
  191. package/dist/react/opencode.js +5 -1
  192. package/dist/react/opencode.js.map +1 -1
  193. package/dist/react/prefetch-session-start.d.ts +10 -4
  194. package/dist/react/prefetch-session-start.d.ts.map +1 -1
  195. package/dist/react/prefetch-session-start.js +10 -4
  196. package/dist/react/prefetch-session-start.js.map +1 -1
  197. package/dist/react/query-keys.d.ts +8 -2
  198. package/dist/react/query-keys.d.ts.map +1 -1
  199. package/dist/react/query-keys.js +8 -2
  200. package/dist/react/query-keys.js.map +1 -1
  201. package/dist/react/session-start-stash.d.ts +25 -0
  202. package/dist/react/session-start-stash.d.ts.map +1 -1
  203. package/dist/react/session-start-stash.js +34 -3
  204. package/dist/react/session-start-stash.js.map +1 -1
  205. package/dist/react/session-title-sync.d.ts +5 -1
  206. package/dist/react/session-title-sync.d.ts.map +1 -1
  207. package/dist/react/session-title-sync.js +16 -4
  208. package/dist/react/session-title-sync.js.map +1 -1
  209. package/dist/react/use-admin-accounts.d.ts +121 -0
  210. package/dist/react/use-admin-accounts.d.ts.map +1 -1
  211. package/dist/react/use-admin-accounts.js +92 -0
  212. package/dist/react/use-admin-accounts.js.map +1 -1
  213. package/dist/react/use-can.d.ts +105 -0
  214. package/dist/react/use-can.d.ts.map +1 -0
  215. package/dist/react/use-can.js +190 -0
  216. package/dist/react/use-can.js.map +1 -0
  217. package/dist/react/use-canonical-opencode-session.d.ts +6 -1
  218. package/dist/react/use-canonical-opencode-session.d.ts.map +1 -1
  219. package/dist/react/use-canonical-opencode-session.js +46 -3
  220. package/dist/react/use-canonical-opencode-session.js.map +1 -1
  221. package/dist/react/use-impersonation.d.ts +54 -0
  222. package/dist/react/use-impersonation.d.ts.map +1 -0
  223. package/dist/react/use-impersonation.js +91 -0
  224. package/dist/react/use-impersonation.js.map +1 -0
  225. package/dist/react/use-opencode-events/handle-event.d.ts +10 -0
  226. package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
  227. package/dist/react/use-opencode-events/handle-event.js +76 -7
  228. package/dist/react/use-opencode-events/handle-event.js.map +1 -1
  229. package/dist/react/use-opencode-events/helpers.d.ts +21 -8
  230. package/dist/react/use-opencode-events/helpers.d.ts.map +1 -1
  231. package/dist/react/use-opencode-events/helpers.js +25 -26
  232. package/dist/react/use-opencode-events/helpers.js.map +1 -1
  233. package/dist/react/use-opencode-events/index.d.ts.map +1 -1
  234. package/dist/react/use-opencode-events/index.js +43 -26
  235. package/dist/react/use-opencode-events/index.js.map +1 -1
  236. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
  237. package/dist/react/use-opencode-events/use-event-stream-refs.js +66 -3
  238. package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -1
  239. package/dist/react/use-opencode-local.d.ts +17 -0
  240. package/dist/react/use-opencode-local.d.ts.map +1 -1
  241. package/dist/react/use-opencode-local.js +41 -7
  242. package/dist/react/use-opencode-local.js.map +1 -1
  243. package/dist/react/use-opencode-sessions/messages.d.ts +101 -1
  244. package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
  245. package/dist/react/use-opencode-sessions/messages.js +481 -63
  246. package/dist/react/use-opencode-sessions/messages.js.map +1 -1
  247. package/dist/react/use-project-apps.d.ts +24 -1
  248. package/dist/react/use-project-apps.d.ts.map +1 -1
  249. package/dist/react/use-project-apps.js +5 -3
  250. package/dist/react/use-project-apps.js.map +1 -1
  251. package/dist/react/use-runtime-boot-stalled.d.ts +32 -0
  252. package/dist/react/use-runtime-boot-stalled.d.ts.map +1 -0
  253. package/dist/react/use-runtime-boot-stalled.js +48 -0
  254. package/dist/react/use-runtime-boot-stalled.js.map +1 -0
  255. package/dist/react/use-runtime-reconnect.d.ts +67 -1
  256. package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
  257. package/dist/react/use-runtime-reconnect.js +116 -18
  258. package/dist/react/use-runtime-reconnect.js.map +1 -1
  259. package/dist/react/use-session-prompts.d.ts +113 -0
  260. package/dist/react/use-session-prompts.d.ts.map +1 -0
  261. package/dist/react/use-session-prompts.js +242 -0
  262. package/dist/react/use-session-prompts.js.map +1 -0
  263. package/dist/react/use-session-send.d.ts +169 -20
  264. package/dist/react/use-session-send.d.ts.map +1 -1
  265. package/dist/react/use-session-send.js +178 -29
  266. package/dist/react/use-session-send.js.map +1 -1
  267. package/dist/react/use-session-sync.d.ts +35 -2
  268. package/dist/react/use-session-sync.d.ts.map +1 -1
  269. package/dist/react/use-session-sync.js +46 -9
  270. package/dist/react/use-session-sync.js.map +1 -1
  271. package/dist/react/use-session-working.d.ts +57 -0
  272. package/dist/react/use-session-working.d.ts.map +1 -0
  273. package/dist/react/use-session-working.js +178 -0
  274. package/dist/react/use-session-working.js.map +1 -0
  275. package/dist/react/use-session.d.ts +122 -5
  276. package/dist/react/use-session.d.ts.map +1 -1
  277. package/dist/react/use-session.js +343 -69
  278. package/dist/react/use-session.js.map +1 -1
  279. package/package.json +2 -2
  280. package/dist/browser/stores/tab-store.d.ts +0 -91
  281. package/dist/browser/stores/tab-store.d.ts.map +0 -1
  282. package/dist/browser/stores/tab-store.js +0 -369
  283. package/dist/browser/stores/tab-store.js.map +0 -1
  284. package/dist/core/session/send-queue.d.ts +0 -70
  285. package/dist/core/session/send-queue.d.ts.map +0 -1
  286. package/dist/core/session/send-queue.js +0 -116
  287. package/dist/core/session/send-queue.js.map +0 -1
@@ -3,6 +3,7 @@ import { useMutation } from '@tanstack/react-query';
3
3
  import { useEffect } from 'react';
4
4
  import { getClient } from '../../core/runtime/client.js';
5
5
  import { logger } from '../../core/http/logger.js';
6
+ import { isAbortError } from '../../core/http/abort-error.js';
6
7
  import { useSyncStore } from '../../browser/stores/sync-store.js';
7
8
  import { canQueryOpenCodeSession, unwrap } from './shared.js';
8
9
  // ============================================================================
@@ -159,6 +160,17 @@ export function useOpenCodeMessages(sessionId) {
159
160
  * Generate a monotonic ascending ID compatible with the server's Identifier.ascending().
160
161
  * Server format: prefix + "_" + 12-char hex timestamp + 14-char random base62 = prefix_<26 chars>
161
162
  * Server validates: z.string().startsWith("msg") for messages, "prt" for parts.
163
+ *
164
+ * ⚠️ **The time field is NOT comparable with a server-minted id, despite the
165
+ * name.** opencode encodes the LOW 6 bytes of `Date.now() * 0x1000 + counter`;
166
+ * this keeps the HIGH 12 hex digits of the same number (`.slice(0, 12)` of a
167
+ * 14-digit string, i.e. a divide by 256). Today that yields `msg_19ff…` where
168
+ * opencode mints `msg_fa4a…`, so EVERY id from here sorts before EVERY id from
169
+ * the server. Local-only ids (an optimistic message a host renders while its
170
+ * prompt is in flight) do not care. **Anything that goes on the wire does** —
171
+ * use `mintPromptMessageId` below, which encodes the field the way opencode
172
+ * does. Left as-is on purpose: this is a published export, and hosts key
173
+ * optimistic state on the exact strings it returns.
162
174
  */
163
175
  let lastIdTimestamp = 0;
164
176
  let idCounter = 0;
@@ -177,6 +189,308 @@ export function ascendingId(prefix = 'msg') {
177
189
  rand += chars[Math.floor(Math.random() * 62)];
178
190
  return `${prefix}_${hex}${rand}`;
179
191
  }
192
+ // ─────────────────────────────────────────────────────────────────────────────
193
+ // One prompt submission = one client-minted `messageID`.
194
+ //
195
+ // The Kortix sandbox proxy refuses to deliver a prompt body it may already have
196
+ // delivered. It identifies a delivery, in precedence order, by the caller's
197
+ // `Idempotency-Key` header (never set by a browser — not on the API's CORS
198
+ // allow-list); THEN by the wire `messageID` this module mints below, when the
199
+ // body carries one; and only when neither is present, by a sha256 of the
200
+ // request body. The dedupe cache holds a claim for 10 minutes — long enough to
201
+ // outlive a sandbox wake from auto-stop, which routinely exceeds the 60s this
202
+ // TTL used to be
203
+ // (`apps/api/src/sandbox-proxy/prompt-dedupe.ts`, `promptDeliveryKey`,
204
+ // `claimPromptDelivery`). A repeat is answered
205
+ // `200 {"status":"duplicate","deduplicated":true}` and never reaches opencode.
206
+ //
207
+ // Because the dedupe key is now the id, not the bytes, a RETRY of one
208
+ // submission (same messageID, body possibly re-serialized) is still recognized
209
+ // as the same delivery, AND a genuinely new submission with byte-identical text
210
+ // (a user sending "continue" twice on purpose) is never mistaken for a repeat
211
+ // just because the words match — it mints its own fresh id and goes through.
212
+ // Before this module existed, the payload below was built from the session id,
213
+ // the mapped parts (whose client ids are dropped), and the model/agent picks —
214
+ // nothing else — so sending the same text twice produced a BYTE-IDENTICAL body,
215
+ // and the second submission was silently lost: no error, no turn, nothing on
216
+ // screen. Minting a per-submission id fixes that at the source; keying the
217
+ // proxy's dedupe on that id (rather than the bytes) is the second half — it
218
+ // means the fix holds even if two submissions' bodies ever happen to collide
219
+ // for a reason that has nothing to do with the user's intent.
220
+ //
221
+ // "One submission" is bigger than one call. The internal retry loop is only the
222
+ // retry the SDK owns; a host retries too — apps/web's message queue re-dispatches
223
+ // a failed entry through `retry` → `sendQueuedMessage` → `handleSend` →
224
+ // `sendParts`, which lands here as a FRESH call. Minting per call there would
225
+ // deliver a prompt that reached opencode but reported failure a SECOND time, and
226
+ // the second prompt aborts the turn the first one started. So the caller may
227
+ // name its submission with `clientMessageId` — the queue entry's own stable key
228
+ // (`QueuedMessageInput.clientMessageId`) — and every dispatch of that submission
229
+ // resolves to the one wire id.
230
+ //
231
+ // The caller names the submission; this module still owns the wire FORMAT.
232
+ // A host id (`cm_12`, or `ascendingId`'s `msg_19ff…`, which encodes the wrong
233
+ // bits — see the warning on it) cannot be used on the wire: opencode orders by
234
+ // the id's clock prefix, so a badly-shaped id reads as already-answered and the
235
+ // turn never runs.
236
+ // ─────────────────────────────────────────────────────────────────────────────
237
+ // `BigInt(0x…)` rather than the `0x…n` literal, throughout. This package is
238
+ // typechecked by its consumers as well as by itself, and apps/web's tsconfig
239
+ // targets below ES2020, where the literal syntax is `TS2737: BigInt literals
240
+ // are not available`. The call form compiles under every target and is exact —
241
+ // each value below is far inside `Number.MAX_SAFE_INTEGER`.
242
+ /** opencode keeps the low 6 bytes of its id clock, so the field wraps ~every 2.2y. */
243
+ const WIRE_ID_TIME_MASK = BigInt(0xffffffffffff);
244
+ /** Sub-millisecond slots per millisecond in that clock (`Date.now() * 0x1000`). */
245
+ const WIRE_ID_TIME_SCALE = BigInt(0x1000);
246
+ /**
247
+ * Ceiling on the correction taken from the session's own transcript: 1h of
248
+ * clock. Large enough to absorb any realistic browser-vs-sandbox skew, small
249
+ * enough that one wrapped or malformed id cannot drag every later id weeks into
250
+ * the future.
251
+ */
252
+ const MAX_WIRE_ID_CLOCK_CORRECTION = BigInt(60 * 60 * 1000) * WIRE_ID_TIME_SCALE;
253
+ /**
254
+ * How far back to date a mint before the correction below lifts it into place.
255
+ *
256
+ * The two clocks are not the same clock. opencode mints the ASSISTANT reply
257
+ * from the sandbox's clock; this mints the USER message from the browser's. The
258
+ * sync store sorts the transcript by raw id, so a browser running fast puts the
259
+ * prompt ABOVE the reply that answers it — and it is self-sustaining, because
260
+ * the next mint corrects off the user's own future-dated message. Every reply
261
+ * then lands above its prompt, for as long as the clock is wrong.
262
+ *
263
+ * The fix is an asymmetry rather than a skew estimate, because the two error
264
+ * directions do NOT cost the same:
265
+ *
266
+ * - too EARLY is self-correcting. `newestKnownMessageTime` lifts the mint
267
+ * above everything already on record, which is exactly where it belongs.
268
+ * - too LATE is the bug, and nothing downstream can detect it.
269
+ *
270
+ * So never trust the browser clock forward. Backdate it past any ordinary
271
+ * drift, then let the transcript place the id. In a session with history the
272
+ * value barely matters — the lift decides the answer. It only decides anything
273
+ * for the FIRST message of a session, where there is no history to lift above
274
+ * and the reply is the only thing to sort against.
275
+ *
276
+ * 2 minutes: comfortably past unsynced-clock drift (Windows re-syncs weekly and
277
+ * can be tens of seconds out), and far under `MAX_WIRE_ID_CLOCK_CORRECTION` so
278
+ * the lift still engages.
279
+ */
280
+ const CLOCK_SKEW_BACKDATE_MS = 2 * 60 * 1000;
281
+ const WIRE_MESSAGE_ID_TIME = /^msg_([0-9a-f]{12})/;
282
+ const BASE62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
283
+ // Monotonic tie-break for two submissions inside the same millisecond. Scoped
284
+ // to the LAST session deliberately: a skew correction learned from one
285
+ // session's transcript must not follow the user into another session, where it
286
+ // would push a fresh user message past assistant replies that come after it.
287
+ let lastMintedSessionId = '';
288
+ let lastMintedWireId = BigInt(0);
289
+ /**
290
+ * The highest id-clock value this session's transcript already shows that a
291
+ * mint may place itself above, or null.
292
+ *
293
+ * `ceiling` is what makes this a bounded scan rather than a plain max, and it
294
+ * is load-bearing. The same store also holds ids that are NOT opencode wire
295
+ * ids: every send inserts an OPTIMISTIC user message keyed by `ascendingId`,
296
+ * which keeps the HIGH hex digits of the id clock (`msg_1a01…`) where opencode
297
+ * keeps the LOW ones (`msg_0141…`) — about 2.8e13 above every real id, and it
298
+ * still matches the 12-hex shape. Taking the max over everything therefore
299
+ * returned that optimistic id, the correction bound then refused it, and the
300
+ * lift never engaged AT ALL in the real app. A prompt sent inside
301
+ * {@link CLOCK_SKEW_BACKDATE_MS} of the previous reply then went out with a
302
+ * wire id BELOW that reply, opencode read it as already answered, and the turn
303
+ * never ran — no error, nothing on screen. (Reproduced in the browser on the
304
+ * worktree stack: reply at T, prompt at T+70s, id 50s below it, no assistant
305
+ * message ever created.)
306
+ *
307
+ * So an id this mint could not possibly have to sort against is skipped, not
308
+ * allowed to veto the correction for the whole session. A wrapped or garbage
309
+ * id is handled by the same rule, which is what the bound was for originally.
310
+ */
311
+ function newestKnownMessageTime(sessionId, ceiling) {
312
+ const messages = useSyncStore.getState().messages[sessionId];
313
+ if (!messages?.length)
314
+ return null;
315
+ let newest = null;
316
+ for (const message of messages) {
317
+ const match = WIRE_MESSAGE_ID_TIME.exec(message?.id ?? '');
318
+ if (!match)
319
+ continue;
320
+ const encoded = BigInt(`0x${match[1]}`);
321
+ if (encoded > ceiling)
322
+ continue;
323
+ if (newest === null || encoded > newest)
324
+ newest = encoded;
325
+ }
326
+ return newest;
327
+ }
328
+ /**
329
+ * Mint the `messageID` for ONE prompt submission, in opencode's own
330
+ * `Identifier.ascending("message")` wire format: `msg_` + the low 48 bits of
331
+ * `Date.now() * 0x1000` as 12 hex chars + 14 random base62 chars.
332
+ *
333
+ * Ordering is load-bearing, which is why this does not reuse `ascendingId`
334
+ * (see the warning on it): opencode resolves "has this prompt already been
335
+ * answered?" by id order, so a user message that sorts before the assistant
336
+ * replies already on record is read as answered and the turn never runs — the
337
+ * same silent loss this whole change exists to remove. Two guards keep the
338
+ * minted id above everything already known:
339
+ *
340
+ * 1. If this session's transcript already holds a HIGHER id — the browser
341
+ * clock lags the sandbox's — start just above it, bounded by
342
+ * {@link MAX_WIRE_ID_CLOCK_CORRECTION}.
343
+ * 2. Never repeat or go below the previous id minted for this same session,
344
+ * so two submissions inside one millisecond still order.
345
+ */
346
+ function mintPromptMessageId(sessionId) {
347
+ let encoded = (BigInt(Date.now() - CLOCK_SKEW_BACKDATE_MS) * WIRE_ID_TIME_SCALE) & WIRE_ID_TIME_MASK;
348
+ // The bound lives in the scan, so one unplaceable id skips itself instead of
349
+ // cancelling the correction for every id in the transcript.
350
+ const newest = newestKnownMessageTime(sessionId, encoded + MAX_WIRE_ID_CLOCK_CORRECTION);
351
+ if (newest !== null && newest >= encoded) {
352
+ encoded = newest + BigInt(1);
353
+ }
354
+ if (sessionId === lastMintedSessionId && encoded <= lastMintedWireId) {
355
+ encoded = lastMintedWireId + BigInt(1);
356
+ }
357
+ encoded &= WIRE_ID_TIME_MASK;
358
+ lastMintedSessionId = sessionId;
359
+ lastMintedWireId = encoded;
360
+ let random = '';
361
+ for (let i = 0; i < 14; i++)
362
+ random += BASE62[Math.floor(Math.random() * 62)];
363
+ return `msg_${encoded.toString(16).padStart(12, '0')}${random}`;
364
+ }
365
+ /**
366
+ * How many submissions' wire ids to remember. One `Map` entry per queued
367
+ * message, so a long-lived tab must not keep them all. Past the window the
368
+ * oldest submission re-mints on its next dispatch — i.e. it degrades to exactly
369
+ * the per-call behaviour, never to a wrong id — and 256 entries is far more than
370
+ * the 60s the proxy's dedupe actually spans.
371
+ */
372
+ const MAX_REMEMBERED_SUBMISSIONS = 256;
373
+ const submissionWireIds = new Map();
374
+ /**
375
+ * The wire `messageID` for ONE submission: minted on first dispatch, then reused
376
+ * for every later dispatch of the same `clientMessageId` in the same session.
377
+ *
378
+ * Keyed by session as well as by the caller's id because a host mints queue keys
379
+ * per session store, not globally, and an id has to sort against ITS session's
380
+ * transcript — `mintPromptMessageId` reads that transcript to place it.
381
+ */
382
+ function submissionWireId(sessionId, clientMessageId) {
383
+ if (!clientMessageId)
384
+ return mintPromptMessageId(sessionId);
385
+ const key = `${sessionId}${clientMessageId}`;
386
+ const known = submissionWireIds.get(key);
387
+ if (known)
388
+ return known;
389
+ const minted = mintPromptMessageId(sessionId);
390
+ submissionWireIds.set(key, minted);
391
+ // `Map` iterates in insertion order, so the first key is the oldest.
392
+ while (submissionWireIds.size > MAX_REMEMBERED_SUBMISSIONS) {
393
+ const oldest = submissionWireIds.keys().next().value;
394
+ if (oldest === undefined)
395
+ break;
396
+ submissionWireIds.delete(oldest);
397
+ }
398
+ return minted;
399
+ }
400
+ /**
401
+ * The wire `messageID` for one submission, for a host that does NOT send
402
+ * through `promptOpenCodeMessage`.
403
+ *
404
+ * The server-side prompt inbox (`createSessionPrompt`) needs the id up front:
405
+ * the control plane cannot mint one, because placing an id correctly means
406
+ * reading THIS session's transcript, and only this process holds it. Do not
407
+ * substitute `ascendingId('msg')` — it encodes the HIGH bits of the id clock,
408
+ * so it sorts below every server-minted id and OpenCode reads the prompt as
409
+ * already answered. See the warning on `ascendingId`.
410
+ *
411
+ * Same memo as an in-band send: one `clientMessageId` always resolves to one
412
+ * wire id, so a retry of a submission keeps the id the proxy's delivery claim
413
+ * is keyed on.
414
+ */
415
+ export function mintSessionWireMessageId(sessionId, clientMessageId) {
416
+ return submissionWireId(sessionId, clientMessageId);
417
+ }
418
+ // ============================================================================
419
+ // T9 — cancel() cancels in-flight delivery.
420
+ //
421
+ // Before this, `promptOpenCodeMessage`'s boot/wake retry loop (below) had no
422
+ // `AbortSignal` at all: a prompt still retrying its ~30s backoff when the
423
+ // user hit Stop kept going, and — if the sandbox woke up mid-retry — landed
424
+ // AFTER the abort and ran the stale text. This registry lets `cancel()`
425
+ // reach every in-flight delivery for a session and stop it before its next
426
+ // attempt, whether that attempt is mid-network-call (aborts the underlying
427
+ // `fetch` via `signal`) or mid-backoff-sleep (rejects the sleep immediately
428
+ // instead of waiting it out).
429
+ //
430
+ // Scoped by session, not global: aborting one session's Stop must never touch
431
+ // another session's in-flight send (two tabs, or two sessions polling
432
+ // concurrently).
433
+ // ============================================================================
434
+ const inFlightDeliveries = new Map();
435
+ /** Register one delivery's controller under its session; returns the
436
+ * unregister function to call once the delivery settles (success, failure,
437
+ * or abort) so a finished delivery is never reachable by a later abort. */
438
+ function registerDelivery(sessionId, controller) {
439
+ let set = inFlightDeliveries.get(sessionId);
440
+ if (!set) {
441
+ set = new Set();
442
+ inFlightDeliveries.set(sessionId, set);
443
+ }
444
+ set.add(controller);
445
+ return () => {
446
+ set?.delete(controller);
447
+ if (set && set.size === 0)
448
+ inFlightDeliveries.delete(sessionId);
449
+ };
450
+ }
451
+ /**
452
+ * Abort every in-flight `promptOpenCodeMessage` delivery for a session — the
453
+ * primary effect `cancel()`/`stop()` need before the abort even reaches the
454
+ * server: a delivery that has not yet started its next attempt when this
455
+ * runs never starts one, and a delivery mid-network-call gets its underlying
456
+ * `fetch` aborted via `signal`.
457
+ *
458
+ * Returns the number of deliveries this call aborted (0 when none were in
459
+ * flight for the session — not an error, just nothing to do).
460
+ */
461
+ export function abortInFlightDeliveries(sessionId) {
462
+ const set = inFlightDeliveries.get(sessionId);
463
+ if (!set || set.size === 0)
464
+ return 0;
465
+ const controllers = [...set];
466
+ for (const controller of controllers)
467
+ controller.abort();
468
+ return controllers.length;
469
+ }
470
+ /** The shape `isAbortError` (`@kortix/sdk` core) recognizes on identity alone
471
+ * — matches a real `AbortController`/`fetch` abort's `.name`. */
472
+ function deliveryAbortError() {
473
+ const err = new Error('The operation was aborted.');
474
+ err.name = 'AbortError';
475
+ return err;
476
+ }
477
+ /** A `setTimeout` that rejects immediately (with the abort error, not a
478
+ * timeout) when `signal` aborts, instead of waiting out the full delay. */
479
+ function abortableDelay(ms, signal) {
480
+ if (signal.aborted)
481
+ return Promise.reject(deliveryAbortError());
482
+ return new Promise((resolve, reject) => {
483
+ const timer = setTimeout(() => {
484
+ signal.removeEventListener('abort', onAbort);
485
+ resolve();
486
+ }, ms);
487
+ const onAbort = () => {
488
+ clearTimeout(timer);
489
+ reject(deliveryAbortError());
490
+ };
491
+ signal.addEventListener('abort', onAbort, { once: true });
492
+ });
493
+ }
180
494
  /**
181
495
  * Send a prompt to a session via `session.promptAsync()` — the server accepts
182
496
  * the prompt and returns immediately (204); the actual turn streams back over
@@ -198,7 +512,7 @@ export function ascendingId(prefix = 'msg') {
198
512
  * Extracted from `useSendOpenCodeMessage`'s mutationFn so it's a plain async
199
513
  * function callable — and unit-testable — without a mutation/hook context.
200
514
  */
201
- export async function promptOpenCodeMessage({ sessionId, parts, options, messageID, }) {
515
+ export async function promptOpenCodeMessage({ sessionId, parts, options, messageID, clientMessageId, }) {
202
516
  const mappedParts = parts.map((p) => {
203
517
  if (p.type === 'file')
204
518
  return { type: 'file', mime: p.mime, url: p.url, filename: p.filename, source: p.source };
@@ -206,87 +520,191 @@ export async function promptOpenCodeMessage({ sessionId, parts, options, message
206
520
  return { type: 'agent', name: p.name, source: p.source };
207
521
  return { type: 'text', text: p.text };
208
522
  });
523
+ // Resolved ONCE, here, outside the retry loop below — every attempt of this
524
+ // submission re-sends the same id, so the proxy's dedupe still short-circuits
525
+ // a genuine retry, while the NEXT submission gets a fresh id and can never be
526
+ // mistaken for this one. `clientMessageId` extends "this submission" past the
527
+ // loop to the host's own retry of the same queue entry; without it a fresh
528
+ // call always means a fresh id.
529
+ const promptMessageId = messageID ?? submissionWireId(sessionId, clientMessageId);
209
530
  const payload = {
210
531
  sessionID: sessionId,
211
532
  parts: mappedParts,
212
- ...(messageID && { messageID }),
533
+ messageID: promptMessageId,
213
534
  ...(options?.directory && { directory: options.directory }),
214
535
  ...(options?.model && { model: options.model }),
215
536
  ...(options?.agent && { agent: options.agent }),
216
537
  ...(options?.variant && { variant: options.variant }),
217
538
  };
218
- for (let attempt = 1;; attempt++) {
219
- let status;
220
- let error;
221
- try {
222
- // Resolve the client INSIDE the retry loop, not once before it. During
223
- // the sandbox-loading window `getClient()` throws "Server URL not
224
- // ready" (see opencode/client.ts) — that's a boot-phase condition
225
- // exactly like the proxy's 503 "opencode not ready" below, so it must
226
- // participate in the SAME boot/wake retry window rather than propagate
227
- // instantly with zero retries. A brand-new session's very first prompt
228
- // can race the runtime url being pinned; without this the send throws
229
- // before a single retry and the prompt is dropped.
230
- const client = getClient();
231
- // The SDK resolves (not rejects) on HTTP errors, returning
232
- // { error, response } instead of throwing.
233
- const result = await client.session.promptAsync(payload);
234
- if (!result?.error)
235
- return; // 204 server accepted the prompt.
236
- error = result.error;
237
- status = result.response?.status;
238
- }
239
- catch (err) {
240
- error = err; // thrown = transport failure (no status) OR getClient() not-ready.
241
- }
242
- const delay = getSendRetryDelayMs(attempt, status, error);
243
- if (delay === null) {
244
- const err = error && typeof error === 'object' ? error : undefined;
245
- const errData = err?.data && typeof err.data === 'object' ? err.data : undefined;
246
- const message = errData?.message || err?.message || 'Failed to send message';
247
- const wrapped = new Error(typeof message === 'string' ? message : 'Failed to send message');
248
- if (status) {
249
- wrapped.status = status;
250
- wrapped.response = { status };
539
+ // One controller per delivery, registered under the session so
540
+ // `abortInFlightDeliveries` (called by `cancel()`/`stop()`) can reach it —
541
+ // and unregistered as soon as this delivery settles, so a finished delivery
542
+ // is never reachable by a LATER abort call for the same session.
543
+ const controller = new AbortController();
544
+ const unregister = registerDelivery(sessionId, controller);
545
+ try {
546
+ for (let attempt = 1;; attempt++) {
547
+ if (controller.signal.aborted)
548
+ throw deliveryAbortError();
549
+ let status;
550
+ let error;
551
+ try {
552
+ // Resolve the client INSIDE the retry loop, not once before it. During
553
+ // the sandbox-loading window `getClient()` throws "Server URL not
554
+ // ready" (see opencode/client.ts) — that's a boot-phase condition
555
+ // exactly like the proxy's 503 "opencode not ready" below, so it must
556
+ // participate in the SAME boot/wake retry window rather than propagate
557
+ // instantly with zero retries. A brand-new session's very first prompt
558
+ // can race the runtime url being pinned; without this the send throws
559
+ // before a single retry and the prompt is dropped.
560
+ const client = getClient();
561
+ // The SDK resolves (not rejects) on HTTP errors, returning
562
+ // { error, response } instead of throwing. The `signal` here reaches
563
+ // the underlying `fetch` (the generated client's `Config` extends
564
+ // `RequestInit`) an abort mid-network-call actually cancels the
565
+ // in-flight request, not just the SDK-side bookkeeping.
566
+ const result = await client.session.promptAsync(payload, { signal: controller.signal });
567
+ if (!result?.error)
568
+ return; // 204 server accepted the prompt.
569
+ error = result.error;
570
+ status = result.response?.status;
571
+ }
572
+ catch (err) {
573
+ if (controller.signal.aborted || isAbortError(err))
574
+ throw deliveryAbortError();
575
+ error = err; // thrown = transport failure (no status) OR getClient() not-ready.
251
576
  }
252
- wrapped.data = err?.data ?? err;
253
- throw wrapped;
577
+ const delay = getSendRetryDelayMs(attempt, status, error);
578
+ if (delay === null) {
579
+ const err = error && typeof error === 'object' ? error : undefined;
580
+ const errData = err?.data && typeof err.data === 'object' ? err.data : undefined;
581
+ const message = errData?.message || err?.message || 'Failed to send message';
582
+ const wrapped = new Error(typeof message === 'string' ? message : 'Failed to send message');
583
+ if (status) {
584
+ wrapped.status = status;
585
+ wrapped.response = { status };
586
+ }
587
+ wrapped.data = err?.data ?? err;
588
+ throw wrapped;
589
+ }
590
+ logger.warn('promptOpenCodeMessage retrying send', { sessionId, attempt, status });
591
+ // Abortable — a cancel arriving while this delivery is waiting out its
592
+ // backoff must reject IMMEDIATELY, not wait out the remaining delay.
593
+ await abortableDelay(delay, controller.signal);
254
594
  }
255
- logger.warn('promptOpenCodeMessage retrying send', { sessionId, attempt, status });
256
- await new Promise((resolve) => setTimeout(resolve, delay));
595
+ }
596
+ finally {
597
+ unregister();
257
598
  }
258
599
  }
259
600
  export function useSendOpenCodeMessage() {
260
- return useMutation({ mutationFn: promptOpenCodeMessage });
601
+ return useMutation({
602
+ mutationFn: promptOpenCodeMessage,
603
+ // Same rationale as `useExecuteOpenCodeCommand`: this POSTs `prompt_async`,
604
+ // which CREATES a user message. Retrying it sends the prompt twice.
605
+ //
606
+ // It is stated here rather than left to the host because a host default
607
+ // cannot know that. apps/web's is
608
+ // `error?.status >= 400 && error?.status < 500 ? false : failureCount < 1`,
609
+ // which reads like "don't retry client errors" but lets every 5xx through —
610
+ // and a 502 from the sandbox proxy is exactly the case where opencode may
611
+ // already hold the message. The proxy's content-hash dedupe has been
612
+ // absorbing that, which is the same "one layer relying on another's guard"
613
+ // shape that let a `/command` execute four times.
614
+ //
615
+ // `promptOpenCodeMessage` already runs its own bounded boot-window retry
616
+ // for the states that ARE safe to repeat (`opencode not ready`, sandbox
617
+ // still waking), so nothing is lost by switching the outer one off.
618
+ retry: false,
619
+ });
620
+ }
621
+ /**
622
+ * POST the abort to the runtime for a session, then re-read server status and
623
+ * force-update the store if it still reports busy (the SSE `session.idle`
624
+ * event should arrive on its own; this is the fallback for a missed one).
625
+ *
626
+ * Extracted from `useAbortOpenCodeSession`'s mutationFn — same reasoning as
627
+ * `promptOpenCodeMessage`: a plain async function is directly testable
628
+ * without a mutation/hook context, and `awaitAbortSettlement` below calls it
629
+ * (via the mutation's `mutateAsync`, so retry/pending state stay react-query-
630
+ * driven) without needing to render a hook to prove the failure path.
631
+ *
632
+ * Throws on a genuine abort failure — the caller (the mutation's `retry: 2`,
633
+ * then `awaitAbortSettlement`) decides what to do with that; this function
634
+ * itself never swallows it.
635
+ */
636
+ export async function abortOpenCodeSession(sessionId) {
637
+ const client = getClient();
638
+ const result = await client.session.abort({ sessionID: sessionId });
639
+ unwrap(result);
640
+ // After abort succeeds, the SSE stream should deliver session.idle event.
641
+ // If the UI stays stuck, it means the SSE event wasn't received/processed.
642
+ // The optimistic idle status we set in handleStop should handle this, but
643
+ // if for some reason the abort HTTP call returned but SSE didn't update,
644
+ // we force-refresh the session status from the server.
645
+ try {
646
+ const statusResult = await client.session.status();
647
+ const statuses = statusResult.data;
648
+ const serverStatus = statuses?.[sessionId];
649
+ if (serverStatus && serverStatus.type !== 'idle') {
650
+ // Server still thinks we're busy - update the store with server's view
651
+ // This can happen if SSE events were missed
652
+ useSyncStore.getState().setStatus(sessionId, serverStatus);
653
+ }
654
+ }
655
+ catch {
656
+ // Non-critical — SSE will eventually deliver the correct status
657
+ }
261
658
  }
262
659
  export function useAbortOpenCodeSession() {
263
660
  return useMutation({
264
- mutationFn: async (sessionId) => {
265
- const client = getClient();
266
- const result = await client.session.abort({ sessionID: sessionId });
267
- unwrap(result);
268
- // After abort succeeds, the SSE stream should deliver session.idle event.
269
- // If the UI stays stuck, it means the SSE event wasn't received/processed.
270
- // The optimistic idle status we set in handleStop should handle this, but
271
- // if for some reason the abort HTTP call returned but SSE didn't update,
272
- // we force-refresh the session status from the server.
273
- try {
274
- const statusResult = await client.session.status();
275
- const statuses = statusResult.data;
276
- const serverStatus = statuses?.[sessionId];
277
- if (serverStatus && serverStatus.type !== 'idle') {
278
- // Server still thinks we're busy - update the store with server's view
279
- // This can happen if SSE events were missed
280
- useSyncStore.getState().setStatus(sessionId, serverStatus);
281
- }
282
- }
283
- catch {
284
- // Non-critical — SSE will eventually deliver the correct status
285
- }
286
- },
661
+ mutationFn: abortOpenCodeSession,
287
662
  retry: 2,
288
663
  retryDelay: 300,
664
+ // Kept — apps/web's `session-chat.tsx` calls `.mutate(sessionId)`
665
+ // fire-and-forget at two call sites and does not want a global
666
+ // mutation-cache error handler to fire for an abort that the UI already
667
+ // shows as idle optimistically. This does NOT re-introduce the silent
668
+ // swallow `awaitAbortSettlement` exists to fix: `cancel()`/`stop()` below
669
+ // call `mutateAsync` and read the real settlement (success, the thrown
670
+ // error, or a bounded timeout) — `onError` is a side-effect callback only,
671
+ // it never prevents `mutateAsync`'s returned promise from rejecting.
289
672
  onError: () => { },
290
673
  });
291
674
  }
675
+ const DEFAULT_ABORT_SETTLEMENT_TIMEOUT_MS = 5000;
676
+ /**
677
+ * Await an abort call's settlement — success, a real failure, or a bounded
678
+ * timeout — instead of the fire-and-forget `.mutate()` `cancel()`/`stop()`
679
+ * used to do. `runAbort` is normally `() => abortMutation.mutateAsync(sessionId)`
680
+ * (keeps react-query's own retry/`isPending` state); this takes it as a plain
681
+ * callback so it's directly testable without rendering a hook.
682
+ *
683
+ * Never rejects: every branch resolves to a distinguishable `AbortSettlement`
684
+ * the caller can read, which is the point — a swallowed `onError` used to
685
+ * mean a failed abort left the UI's optimistic idle state as the only signal,
686
+ * with nothing to tell a caller whether the server actually agreed.
687
+ */
688
+ export async function awaitAbortSettlement(runAbort, timeoutMs = DEFAULT_ABORT_SETTLEMENT_TIMEOUT_MS) {
689
+ let timer;
690
+ const timedOut = new Promise((resolve) => {
691
+ timer = setTimeout(() => resolve({ status: 'timed-out' }), timeoutMs);
692
+ });
693
+ const settled = (async () => {
694
+ try {
695
+ await runAbort();
696
+ return { status: 'aborted' };
697
+ }
698
+ catch (error) {
699
+ return { status: 'failed', error };
700
+ }
701
+ })();
702
+ try {
703
+ return await Promise.race([settled, timedOut]);
704
+ }
705
+ finally {
706
+ if (timer !== undefined)
707
+ clearTimeout(timer);
708
+ }
709
+ }
292
710
  //# sourceMappingURL=messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/react/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