@kortix/sdk 0.13.30 → 0.13.32

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 (299) hide show
  1. package/README.md +30 -11
  2. package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
  3. package/dist/browser/session-sync/server-transcript-mirror.js +6 -1
  4. package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -1
  5. package/dist/browser/stores/sync-store/delta-event-window.d.ts +10 -0
  6. package/dist/browser/stores/sync-store/delta-event-window.d.ts.map +1 -0
  7. package/dist/browser/stores/sync-store/delta-event-window.js +10 -0
  8. package/dist/browser/stores/sync-store/delta-event-window.js.map +1 -0
  9. package/dist/browser/stores/sync-store.d.ts.map +1 -1
  10. package/dist/browser/stores/sync-store.js +48 -5
  11. package/dist/browser/stores/sync-store.js.map +1 -1
  12. package/dist/core/auth/session.d.ts.map +1 -1
  13. package/dist/core/auth/session.js +56 -15
  14. package/dist/core/auth/session.js.map +1 -1
  15. package/dist/core/client/kortix.d.ts +8 -0
  16. package/dist/core/client/kortix.d.ts.map +1 -1
  17. package/dist/core/client/kortix.js +7 -0
  18. package/dist/core/client/kortix.js.map +1 -1
  19. package/dist/core/files/client.d.ts +30 -9
  20. package/dist/core/files/client.d.ts.map +1 -1
  21. package/dist/core/files/client.js +71 -29
  22. package/dist/core/files/client.js.map +1 -1
  23. package/dist/core/http/api/errors.d.ts +23 -8
  24. package/dist/core/http/api/errors.d.ts.map +1 -1
  25. package/dist/core/http/api/errors.js +44 -23
  26. package/dist/core/http/api/errors.js.map +1 -1
  27. package/dist/core/http/api-client.d.ts +9 -14
  28. package/dist/core/http/api-client.d.ts.map +1 -1
  29. package/dist/core/http/api-client.js +61 -88
  30. package/dist/core/http/api-client.js.map +1 -1
  31. package/dist/core/http/auth.d.ts +12 -15
  32. package/dist/core/http/auth.d.ts.map +1 -1
  33. package/dist/core/http/auth.js +24 -68
  34. package/dist/core/http/auth.js.map +1 -1
  35. package/dist/core/http/transport.d.ts +46 -0
  36. package/dist/core/http/transport.d.ts.map +1 -0
  37. package/dist/core/http/transport.js +135 -0
  38. package/dist/core/http/transport.js.map +1 -0
  39. package/dist/core/rest/platform-client/host-boundary.d.ts +60 -8
  40. package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
  41. package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
  42. package/dist/core/rest/platform-client/instance-admin.d.ts +16 -9
  43. package/dist/core/rest/platform-client/instance-admin.d.ts.map +1 -1
  44. package/dist/core/rest/platform-client/instance-admin.js +21 -25
  45. package/dist/core/rest/platform-client/instance-admin.js.map +1 -1
  46. package/dist/core/rest/platform-client/invites.d.ts +11 -3
  47. package/dist/core/rest/platform-client/invites.d.ts.map +1 -1
  48. package/dist/core/rest/platform-client/invites.js +16 -18
  49. package/dist/core/rest/platform-client/invites.js.map +1 -1
  50. package/dist/core/rest/platform-client/shared.d.ts +0 -7
  51. package/dist/core/rest/platform-client/shared.d.ts.map +1 -1
  52. package/dist/core/rest/platform-client/shared.js +0 -49
  53. package/dist/core/rest/platform-client/shared.js.map +1 -1
  54. package/dist/core/rest/projects-client/audit.d.ts +5 -3
  55. package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
  56. package/dist/core/rest/projects-client/audit.js.map +1 -1
  57. package/dist/core/rest/projects-client/channels.d.ts +32 -0
  58. package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
  59. package/dist/core/rest/projects-client/channels.js +27 -0
  60. package/dist/core/rest/projects-client/channels.js.map +1 -1
  61. package/dist/core/rest/projects-client/connectors.d.ts +31 -0
  62. package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
  63. package/dist/core/rest/projects-client/connectors.js +15 -0
  64. package/dist/core/rest/projects-client/connectors.js.map +1 -1
  65. package/dist/core/rest/projects-client/iam.d.ts +23 -2
  66. package/dist/core/rest/projects-client/iam.d.ts.map +1 -1
  67. package/dist/core/rest/projects-client/iam.js +9 -0
  68. package/dist/core/rest/projects-client/iam.js.map +1 -1
  69. package/dist/core/rest/projects-client/presentations.d.ts +4 -2
  70. package/dist/core/rest/projects-client/presentations.d.ts.map +1 -1
  71. package/dist/core/rest/projects-client/presentations.js +14 -6
  72. package/dist/core/rest/projects-client/presentations.js.map +1 -1
  73. package/dist/core/rest/projects-client/projects.d.ts +8 -10
  74. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  75. package/dist/core/rest/projects-client/projects.js +8 -8
  76. package/dist/core/rest/projects-client/projects.js.map +1 -1
  77. package/dist/core/rest/projects-client/referrals.d.ts +9 -3
  78. package/dist/core/rest/projects-client/referrals.d.ts.map +1 -1
  79. package/dist/core/rest/projects-client/referrals.js +20 -17
  80. package/dist/core/rest/projects-client/referrals.js.map +1 -1
  81. package/dist/core/rest/projects-client/secrets.d.ts +15 -0
  82. package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
  83. package/dist/core/rest/projects-client/secrets.js +1 -0
  84. package/dist/core/rest/projects-client/secrets.js.map +1 -1
  85. package/dist/core/rest/projects-client/session-attachments.d.ts +37 -0
  86. package/dist/core/rest/projects-client/session-attachments.d.ts.map +1 -1
  87. package/dist/core/rest/projects-client/session-attachments.js +134 -0
  88. package/dist/core/rest/projects-client/session-attachments.js.map +1 -1
  89. package/dist/core/rest/projects-client/session-sandbox.d.ts +4 -1
  90. package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
  91. package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
  92. package/dist/core/rest/projects-client/sessions.d.ts +56 -0
  93. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  94. package/dist/core/rest/projects-client/sessions.js.map +1 -1
  95. package/dist/core/rest/projects-client/templates.d.ts +4 -4
  96. package/dist/core/rest/projects-client/templates.d.ts.map +1 -1
  97. package/dist/core/rest/projects-client/templates.js +11 -8
  98. package/dist/core/rest/projects-client/templates.js.map +1 -1
  99. package/dist/core/runtime/attachment-part.d.ts +1 -1
  100. package/dist/core/runtime/attachment-part.js +1 -1
  101. package/dist/core/session/connection.d.ts +1 -1
  102. package/dist/core/session/open-bundle.d.ts +6 -0
  103. package/dist/core/session/open-bundle.d.ts.map +1 -1
  104. package/dist/core/session/open-bundle.js +22 -2
  105. package/dist/core/session/open-bundle.js.map +1 -1
  106. package/dist/core/session/preview-auth.d.ts +3 -2
  107. package/dist/core/session/preview-auth.d.ts.map +1 -1
  108. package/dist/core/session/preview-auth.js +11 -3
  109. package/dist/core/session/preview-auth.js.map +1 -1
  110. package/dist/core/session/preview-config.d.ts +5 -0
  111. package/dist/core/session/preview-config.d.ts.map +1 -1
  112. package/dist/core/session/preview-config.js +7 -0
  113. package/dist/core/session/preview-config.js.map +1 -1
  114. package/dist/core/session/preview-origin-trust.d.ts +24 -0
  115. package/dist/core/session/preview-origin-trust.d.ts.map +1 -0
  116. package/dist/core/session/preview-origin-trust.js +100 -0
  117. package/dist/core/session/preview-origin-trust.js.map +1 -0
  118. package/dist/core/session/preview.d.ts +7 -1
  119. package/dist/core/session/preview.d.ts.map +1 -1
  120. package/dist/core/session/preview.js +10 -2
  121. package/dist/core/session/preview.js.map +1 -1
  122. package/dist/core/session/project-session-read.d.ts +24 -0
  123. package/dist/core/session/project-session-read.d.ts.map +1 -0
  124. package/dist/core/session/project-session-read.js +29 -0
  125. package/dist/core/session/project-session-read.js.map +1 -0
  126. package/dist/core/session/single-flight.d.ts +20 -0
  127. package/dist/core/session/single-flight.d.ts.map +1 -0
  128. package/dist/core/session/single-flight.js +39 -0
  129. package/dist/core/session/single-flight.js.map +1 -0
  130. package/dist/core/session/wake-escalation.d.ts +2 -2
  131. package/dist/core/session/wake-escalation.js +2 -2
  132. package/dist/core/session/wire-message-id.d.ts +73 -0
  133. package/dist/core/session/wire-message-id.d.ts.map +1 -0
  134. package/dist/core/session/wire-message-id.js +120 -0
  135. package/dist/core/session/wire-message-id.js.map +1 -0
  136. package/dist/core/session/working.d.ts +2 -2
  137. package/dist/core/session-sync/saved-transcript.d.ts +49 -0
  138. package/dist/core/session-sync/saved-transcript.d.ts.map +1 -0
  139. package/dist/core/session-sync/saved-transcript.js +40 -0
  140. package/dist/core/session-sync/saved-transcript.js.map +1 -0
  141. package/dist/core/session-sync/session-sync-controller.d.ts +21 -2
  142. package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
  143. package/dist/core/session-sync/session-sync-controller.js +56 -7
  144. package/dist/core/session-sync/session-sync-controller.js.map +1 -1
  145. package/dist/core/stream/event-stream.d.ts +5 -4
  146. package/dist/core/stream/event-stream.d.ts.map +1 -1
  147. package/dist/core/stream/event-stream.js +34 -8
  148. package/dist/core/stream/event-stream.js.map +1 -1
  149. package/dist/core/turns/errors.d.ts +7 -0
  150. package/dist/core/turns/errors.d.ts.map +1 -1
  151. package/dist/core/turns/errors.js +58 -0
  152. package/dist/core/turns/errors.js.map +1 -1
  153. package/dist/core/turns/grouping.d.ts.map +1 -1
  154. package/dist/core/turns/grouping.js +46 -2
  155. package/dist/core/turns/grouping.js.map +1 -1
  156. package/dist/core/turns/state.d.ts +7 -1
  157. package/dist/core/turns/state.d.ts.map +1 -1
  158. package/dist/core/turns/state.js +16 -3
  159. package/dist/core/turns/state.js.map +1 -1
  160. package/dist/index.d.ts +7 -1
  161. package/dist/index.d.ts.map +1 -1
  162. package/dist/index.js +6 -1
  163. package/dist/index.js.map +1 -1
  164. package/dist/kortix.esm.min.js +38 -36
  165. package/dist/kortix.global.js +38 -36
  166. package/dist/node/app-viewer.js +1 -1
  167. package/dist/node/auth.d.ts +8 -1
  168. package/dist/node/auth.d.ts.map +1 -1
  169. package/dist/node/auth.js +21 -3
  170. package/dist/node/auth.js.map +1 -1
  171. package/dist/platform/auth-core.d.ts +1 -6
  172. package/dist/platform/auth-core.d.ts.map +1 -1
  173. package/dist/platform/auth-core.js +1 -21
  174. package/dist/platform/auth-core.js.map +1 -1
  175. package/dist/react/bedrock-invokable.d.ts +2 -2
  176. package/dist/react/bedrock-invokable.js +2 -2
  177. package/dist/react/file-keys.d.ts +15 -7
  178. package/dist/react/file-keys.d.ts.map +1 -1
  179. package/dist/react/file-keys.js +15 -7
  180. package/dist/react/file-keys.js.map +1 -1
  181. package/dist/react/identity-reset-registry.d.ts +3 -0
  182. package/dist/react/identity-reset-registry.d.ts.map +1 -0
  183. package/dist/react/identity-reset-registry.js +22 -0
  184. package/dist/react/identity-reset-registry.js.map +1 -0
  185. package/dist/react/index.d.ts +2 -0
  186. package/dist/react/index.d.ts.map +1 -1
  187. package/dist/react/index.js +6 -0
  188. package/dist/react/index.js.map +1 -1
  189. package/dist/react/opencode.d.ts +2 -0
  190. package/dist/react/opencode.d.ts.map +1 -1
  191. package/dist/react/opencode.js +2 -0
  192. package/dist/react/opencode.js.map +1 -1
  193. package/dist/react/prefetch-session-open.d.ts +20 -0
  194. package/dist/react/prefetch-session-open.d.ts.map +1 -0
  195. package/dist/react/prefetch-session-open.js +54 -0
  196. package/dist/react/prefetch-session-open.js.map +1 -0
  197. package/dist/react/provider-refresh.d.ts.map +1 -1
  198. package/dist/react/provider-refresh.js +24 -14
  199. package/dist/react/provider-refresh.js.map +1 -1
  200. package/dist/react/provider-selection.d.ts +4 -0
  201. package/dist/react/provider-selection.d.ts.map +1 -1
  202. package/dist/react/provider-selection.js +6 -2
  203. package/dist/react/provider-selection.js.map +1 -1
  204. package/dist/react/query-keys.d.ts +7 -5
  205. package/dist/react/query-keys.d.ts.map +1 -1
  206. package/dist/react/query-keys.js +9 -5
  207. package/dist/react/query-keys.js.map +1 -1
  208. package/dist/react/reset-identity-state.d.ts +19 -0
  209. package/dist/react/reset-identity-state.d.ts.map +1 -0
  210. package/dist/react/reset-identity-state.js +35 -0
  211. package/dist/react/reset-identity-state.js.map +1 -0
  212. package/dist/react/retired-endpoint.d.ts +10 -0
  213. package/dist/react/retired-endpoint.d.ts.map +1 -0
  214. package/dist/react/retired-endpoint.js +22 -0
  215. package/dist/react/retired-endpoint.js.map +1 -0
  216. package/dist/react/session-stop.d.ts +101 -0
  217. package/dist/react/session-stop.d.ts.map +1 -0
  218. package/dist/react/session-stop.js +162 -0
  219. package/dist/react/session-stop.js.map +1 -0
  220. package/dist/react/session-transcript-subscription.d.ts +29 -0
  221. package/dist/react/session-transcript-subscription.d.ts.map +1 -0
  222. package/dist/react/session-transcript-subscription.js +94 -0
  223. package/dist/react/session-transcript-subscription.js.map +1 -0
  224. package/dist/react/sign-in-with-kortix.d.ts +1 -1
  225. package/dist/react/use-admin-accounts.d.ts +1 -0
  226. package/dist/react/use-admin-accounts.d.ts.map +1 -1
  227. package/dist/react/use-admin-accounts.js +3 -10
  228. package/dist/react/use-admin-accounts.js.map +1 -1
  229. package/dist/react/use-admin-analytics.d.ts +36 -8
  230. package/dist/react/use-admin-analytics.d.ts.map +1 -1
  231. package/dist/react/use-admin-analytics.js +63 -458
  232. package/dist/react/use-admin-analytics.js.map +1 -1
  233. package/dist/react/use-admin-billing.d.ts +6 -2
  234. package/dist/react/use-admin-billing.d.ts.map +1 -1
  235. package/dist/react/use-admin-billing.js +15 -52
  236. package/dist/react/use-admin-billing.js.map +1 -1
  237. package/dist/react/use-admin-feedback.d.ts +10 -1
  238. package/dist/react/use-admin-feedback.d.ts.map +1 -1
  239. package/dist/react/use-admin-feedback.js +24 -111
  240. package/dist/react/use-admin-feedback.js.map +1 -1
  241. package/dist/react/use-admin-sandboxes.d.ts +13 -5
  242. package/dist/react/use-admin-sandboxes.d.ts.map +1 -1
  243. package/dist/react/use-admin-sandboxes.js +20 -104
  244. package/dist/react/use-admin-sandboxes.js.map +1 -1
  245. package/dist/react/use-authenticated-preview-url.d.ts.map +1 -1
  246. package/dist/react/use-authenticated-preview-url.js +7 -1
  247. package/dist/react/use-authenticated-preview-url.js.map +1 -1
  248. package/dist/react/use-canonical-opencode-session.d.ts +8 -0
  249. package/dist/react/use-canonical-opencode-session.d.ts.map +1 -1
  250. package/dist/react/use-canonical-opencode-session.js +1 -0
  251. package/dist/react/use-canonical-opencode-session.js.map +1 -1
  252. package/dist/react/use-model-store.d.ts +1 -1
  253. package/dist/react/use-model-store.d.ts.map +1 -1
  254. package/dist/react/use-model-store.js +16 -1
  255. package/dist/react/use-model-store.js.map +1 -1
  256. package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
  257. package/dist/react/use-opencode-events/handle-event.js +43 -35
  258. package/dist/react/use-opencode-events/handle-event.js.map +1 -1
  259. package/dist/react/use-opencode-sessions/messages.d.ts +14 -3
  260. package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
  261. package/dist/react/use-opencode-sessions/messages.js +92 -115
  262. package/dist/react/use-opencode-sessions/messages.js.map +1 -1
  263. package/dist/react/use-project-session.d.ts.map +1 -1
  264. package/dist/react/use-project-session.js +10 -2
  265. package/dist/react/use-project-session.js.map +1 -1
  266. package/dist/react/use-session-messages.d.ts +37 -0
  267. package/dist/react/use-session-messages.d.ts.map +1 -0
  268. package/dist/react/use-session-messages.js +83 -0
  269. package/dist/react/use-session-messages.js.map +1 -0
  270. package/dist/react/use-session-prompts.d.ts.map +1 -1
  271. package/dist/react/use-session-prompts.js +11 -2
  272. package/dist/react/use-session-prompts.js.map +1 -1
  273. package/dist/react/use-session-send.d.ts +1 -73
  274. package/dist/react/use-session-send.d.ts.map +1 -1
  275. package/dist/react/use-session-send.js +6 -146
  276. package/dist/react/use-session-send.js.map +1 -1
  277. package/dist/react/use-session-sync.d.ts +17 -0
  278. package/dist/react/use-session-sync.d.ts.map +1 -1
  279. package/dist/react/use-session-sync.js +37 -4
  280. package/dist/react/use-session-sync.js.map +1 -1
  281. package/dist/react/use-session-transcript-history.d.ts +3 -0
  282. package/dist/react/use-session-transcript-history.d.ts.map +1 -1
  283. package/dist/react/use-session-transcript-history.js +7 -1
  284. package/dist/react/use-session-transcript-history.js.map +1 -1
  285. package/dist/react/use-session-working.d.ts.map +1 -1
  286. package/dist/react/use-session-working.js +20 -10
  287. package/dist/react/use-session-working.js.map +1 -1
  288. package/dist/react/use-session.d.ts +36 -2
  289. package/dist/react/use-session.d.ts.map +1 -1
  290. package/dist/react/use-session.js +60 -35
  291. package/dist/react/use-session.js.map +1 -1
  292. package/dist/react/use-static-file-preview.d.ts.map +1 -1
  293. package/dist/react/use-static-file-preview.js +2 -1
  294. package/dist/react/use-static-file-preview.js.map +1 -1
  295. package/dist/react/use-system-status.d.ts +7 -3
  296. package/dist/react/use-system-status.d.ts.map +1 -1
  297. package/dist/react/use-system-status.js +14 -67
  298. package/dist/react/use-system-status.js.map +1 -1
  299. package/package.json +2 -2
@@ -1,11 +1,14 @@
1
- import { backendApi } from '../../http/api-client.js';
2
- import { unwrap } from './shared.js';
3
- /** Public — template detail + a requirement preview (built against an empty project). */
4
- export async function getTemplate(id) {
5
- return unwrap(await backendApi.get(`/templates/${encodeURIComponent(id)}`));
1
+ /**
2
+ * Project templates. The API never mounted `/v1/templates`; these exports
3
+ * remain for import compatibility until the next major.
4
+ */
5
+ import { retiredEndpointError } from '../../http/api/errors.js';
6
+ /** @deprecated The API does not serve templates. Always rejects with `ENDPOINT_RETIRED`. */
7
+ export async function getTemplate(_id) {
8
+ throw retiredEndpointError('getTemplate');
6
9
  }
7
- /** Apply a template into a project: renders inputs, merges the manifest, commits. */
8
- export async function installTemplate(id, body) {
9
- return unwrap(await backendApi.post(`/templates/${encodeURIComponent(id)}/install`, body));
10
+ /** @deprecated The API does not serve templates. Always rejects with `ENDPOINT_RETIRED`. */
11
+ export async function installTemplate(_id, _body) {
12
+ throw retiredEndpointError('installTemplate');
10
13
  }
11
14
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/core/rest/projects-client/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA0ClC,yFAAyF;AACzF,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAU;IAC1C,OAAO,MAAM,CAAC,MAAM,UAAU,CAAC,GAAG,CAAiB,cAAc,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAU,EACV,IAA4D;IAE5D,OAAO,MAAM,CACX,MAAM,UAAU,CAAC,IAAI,CAAwB,cAAc,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CACnG,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/core/rest/projects-client/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA0C7D,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,oBAAoB,CAAC,aAAa,CAAC,CAAC;AAC5C,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAW,EACX,KAA6D;IAE7D,MAAM,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAChD,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * proxy, for sandboxes on an older daemon) swaps every oversized `data:` url
6
6
  * in a file part for `/kortix/part/:sessionID/:messageID/:partID`, so a session
7
7
  * with hundreds of image reads lists in kilobytes instead of tens of megabytes.
8
- * Measured before the change (essentia, 2026-08-24): 20 messages = 7-19 MB,
8
+ * Measured before the change (sampleco, 2026-08-24): 20 messages = 7-19 MB,
9
9
  * reads dying on the 30 s fetch deadline, a retry re-issuing the whole thing.
10
10
  *
11
11
  * The bytes are fetched here, per part, when a row is on screen — through the
@@ -7,7 +7,7 @@ import { getActiveOpenCodeUrl } from '../session/server-store/active.js';
7
7
  * proxy, for sandboxes on an older daemon) swaps every oversized `data:` url
8
8
  * in a file part for `/kortix/part/:sessionID/:messageID/:partID`, so a session
9
9
  * with hundreds of image reads lists in kilobytes instead of tens of megabytes.
10
- * Measured before the change (essentia, 2026-08-24): 20 messages = 7-19 MB,
10
+ * Measured before the change (sampleco, 2026-08-24): 20 messages = 7-19 MB,
11
11
  * reads dying on the 30 s fetch deadline, a retry re-issuing the whole thing.
12
12
  *
13
13
  * The bytes are fetched here, per part, when a row is on screen — through the
@@ -15,7 +15,7 @@
15
15
  * Worse, the composer's notice treated the ABSENCE of an answer as an answer.
16
16
  * A page reload of a session whose sandbox is up and mid-turn showed "Waking
17
17
  * this session up…" for seconds before the runtime replied (screen recording,
18
- * essentia 2026-08-24) — a negative claim asserted from having asked nobody.
18
+ * sampleco 2026-08-24) — a negative claim asserted from having asked nobody.
19
19
  *
20
20
  * ## The rule
21
21
  *
@@ -107,5 +107,11 @@ export declare function openBundleQueue(bundle: SessionOpenBundle): SessionPromp
107
107
  * paint a snapshot, and a second paint over a store the runtime has already
108
108
  * filled is how a transcript grows ghosts.
109
109
  */
110
+ /**
111
+ * Did this open's bundle answer "the server holds no saved copy"? ONCE, like
112
+ * the stash: a later read asks the server again, since a turn may have ended
113
+ * and written one since.
114
+ */
115
+ export declare function takeOpenBundleTranscriptAbsence(projectId: string, sessionId: string, nowMs?: number): boolean;
110
116
  export declare function takeOpenBundleTranscript(projectId: string, sessionId: string, nowMs?: number): SessionTranscriptSyncEnvelope | null;
111
117
  //# sourceMappingURL=open-bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"open-bundle.d.ts","sourceRoot":"","sources":["../../../src/core/session/open-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAExB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C;;kEAEkE;AAClE,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAEpD;0CAC0C;AAC1C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAyB/C;gDACgD;AAChD,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED,MAAM,WAAW,wBAAwB;IACvC;oDACgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,wBAA6B,GACrC,IAAI,CAyBN;AASD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAmB,GACzB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,IAAI,CAU1C;AAED;;8EAE8E;AAC9E,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,yBAAyB,GAAG,IAAI,CAU1F;AAED;gEACgE;AAChE,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,EAAE,GAAG,IAAI,CAIjF;AAYD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAmB,GACzB,6BAA6B,GAAG,IAAI,CAOtC"}
1
+ {"version":3,"file":"open-bundle.d.ts","sourceRoot":"","sources":["../../../src/core/session/open-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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AE,GAAG,IAAI,CAIjF;AAiBD;;;;;;GAMG;AACH;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAmB,GACzB,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAmB,GACzB,6BAA6B,GAAG,IAAI,CAOtC"}
@@ -58,6 +58,8 @@ export const OPEN_BUNDLE_TRANSCRIPT_TTL_MS = 60_000;
58
58
  export const OPEN_BUNDLE_TRANSCRIPT_LIMIT = 40;
59
59
  const entries = new Map();
60
60
  const transcripts = new Map();
61
+ /** When an open's bundle answered its transcript leg with NO saved copy. */
62
+ const absentTranscripts = new Map();
61
63
  function scopeKey(projectId, sessionId) {
62
64
  return `${projectId}/${sessionId}`;
63
65
  }
@@ -66,6 +68,7 @@ function scopeKey(projectId, sessionId) {
66
68
  export function resetSessionOpenBundles() {
67
69
  entries.clear();
68
70
  transcripts.clear();
71
+ absentTranscripts.clear();
69
72
  }
70
73
  /**
71
74
  * Start the session-open read for `(projectId, sessionId)`.
@@ -158,9 +161,13 @@ function stashTranscript(key, bundle, nowMs) {
158
161
  if (!transcript || transcript.known !== true || transcript.requested !== true)
159
162
  return;
160
163
  // An unavailable mirror is not a transcript. Stashing it would let a hydrate
161
- // paint an empty thread as a complete one.
162
- if (!transcript.available || transcript.messages.length === 0)
164
+ // paint an empty thread as a complete one. It IS an answer, though: the
165
+ // server holds no saved copy. Recorded separately, so the mirror read does
166
+ // not spend a second round trip asking the transcript route the same thing.
167
+ if (!transcript.available || transcript.messages.length === 0) {
168
+ absentTranscripts.set(key, nowMs);
163
169
  return;
170
+ }
164
171
  const { known: _known, requested: _requested, ...envelope } = transcript;
165
172
  transcripts.set(key, { envelope, stashedAtMs: nowMs });
166
173
  }
@@ -171,6 +178,19 @@ function stashTranscript(key, bundle, nowMs) {
171
178
  * paint a snapshot, and a second paint over a store the runtime has already
172
179
  * filled is how a transcript grows ghosts.
173
180
  */
181
+ /**
182
+ * Did this open's bundle answer "the server holds no saved copy"? ONCE, like
183
+ * the stash: a later read asks the server again, since a turn may have ended
184
+ * and written one since.
185
+ */
186
+ export function takeOpenBundleTranscriptAbsence(projectId, sessionId, nowMs = Date.now()) {
187
+ const key = scopeKey(projectId, sessionId);
188
+ const answeredAtMs = absentTranscripts.get(key);
189
+ if (answeredAtMs === undefined)
190
+ return false;
191
+ absentTranscripts.delete(key);
192
+ return nowMs - answeredAtMs <= OPEN_BUNDLE_TRANSCRIPT_TTL_MS;
193
+ }
174
194
  export function takeOpenBundleTranscript(projectId, sessionId, nowMs = Date.now()) {
175
195
  const key = scopeKey(projectId, sessionId);
176
196
  const stash = transcripts.get(key);
@@ -1 +1 @@
1
- {"version":3,"file":"open-bundle.js","sourceRoot":"","sources":["../../../src/core/session/open-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAOL,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;kEAEkE;AAClE,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEpD;0CAC0C;AAC1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAkB/C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEvD,SAAS,QAAQ,CAAC,SAAiB,EAAE,SAAiB;IACpD,OAAO,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;AACrC,CAAC;AAED;gDACgD;AAChD,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,WAAW,CAAC,KAAK,EAAE,C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AC;IACxB,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,KAAK,GAAG,KAAK,CAAC,WAAW,GAAG,6BAA6B;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC"}
@@ -47,8 +47,9 @@ export declare function ensurePreviewSessionCookie(previewUrl: string, options?:
47
47
  * - Path proxy (`/v1/p/{sandbox}/{port}/…`): same origin as the API, so the
48
48
  * cookie works; mint it and return the URL untouched.
49
49
  *
50
- * Never throws. With no token, or for a URL that is not a preview at all, the
51
- * input is returned unchanged — the destination then answers for itself, which
50
+ * Never throws. With no token, for a URL that is not a preview at all, or for
51
+ * a preview-shaped host this deployment does not serve, the input is returned
52
+ * unchanged — the destination then answers for itself, which
52
53
  * is more honest than fabricating a URL that cannot work.
53
54
  */
54
55
  export declare function authorizePreviewUrl(previewUrl: string, options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"preview-auth.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,MAAM,CAAC,CAOjB"}
1
+ {"version":3,"file":"preview-auth.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,OAAO,CAAC,CAwBlB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,MAAM,CAAC,CAUjB"}
@@ -18,7 +18,9 @@
18
18
  * reloaded, bookmarked, or sent to anyone.
19
19
  */
20
20
  import { getAuthToken } from '../http/auth.js';
21
+ import { platformConfig } from '../http/config.js';
21
22
  import { appendPreviewToken, buildPreviewAuthEndpoint, isSubdomainPreviewUrl } from './preview.js';
23
+ import { shouldAttachPreviewToken } from './preview-origin-trust.js';
22
24
  /**
23
25
  * Mint the `__preview_session` cookie for `previewUrl`'s proxy origin.
24
26
  *
@@ -29,7 +31,8 @@ import { appendPreviewToken, buildPreviewAuthEndpoint, isSubdomainPreviewUrl } f
29
31
  * tolerates a failed refresh.
30
32
  */
31
33
  export async function ensurePreviewSessionCookie(previewUrl, options = {}) {
32
- const authEndpoint = buildPreviewAuthEndpoint(previewUrl, options.serverUrl);
34
+ // The configured backend is the trusted origin when the caller names none.
35
+ const authEndpoint = buildPreviewAuthEndpoint(previewUrl, options.serverUrl || platformConfig().backendUrl || undefined);
33
36
  if (!authEndpoint)
34
37
  return false;
35
38
  const token = await getAuthToken();
@@ -68,12 +71,17 @@ export async function ensurePreviewSessionCookie(previewUrl, options = {}) {
68
71
  * - Path proxy (`/v1/p/{sandbox}/{port}/…`): same origin as the API, so the
69
72
  * cookie works; mint it and return the URL untouched.
70
73
  *
71
- * Never throws. With no token, or for a URL that is not a preview at all, the
72
- * input is returned unchanged — the destination then answers for itself, which
74
+ * Never throws. With no token, for a URL that is not a preview at all, or for
75
+ * a preview-shaped host this deployment does not serve, the input is returned
76
+ * unchanged — the destination then answers for itself, which
73
77
  * is more honest than fabricating a URL that cannot work.
74
78
  */
75
79
  export async function authorizePreviewUrl(previewUrl, options = {}) {
76
80
  if (isSubdomainPreviewUrl(previewUrl)) {
81
+ // The shape alone proves nothing: only an origin this deployment serves
82
+ // may receive the credential. Anything else opens bare.
83
+ if (!(await shouldAttachPreviewToken(previewUrl, options)))
84
+ return previewUrl;
77
85
  const token = await getAuthToken();
78
86
  return token ? appendPreviewToken(previewUrl, token) : previewUrl;
79
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"preview-auth.js","sourceRoot":"","sources":["../../../src/core/session/preview-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEhG;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,UAAkC,EAAE;IAEpC,MAAM,YAAY,GAAG,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7E,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IAEhC,MAAM,KAAK,GAAG,MAAM,YAAY,EAAE,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE;YACzC,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,SAAS;YACtB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CA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aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,UAAkC,EAAE;IAEpC,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,wEAAwE;QACxE,wDAAwD;QACxD,IAAI,CAAC,CAAC,MAAM,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAAE,OAAO,UAAU,CAAC;QAC9E,MAAM,KAAK,GAAG,MAAM,YAAY,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACpE,CAAC;IACD,MAAM,0BAA0B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -4,6 +4,11 @@
4
4
  * which is why they need no distinction at the call site.
5
5
  */
6
6
  export declare function cachedPreviewUrlTemplate(backendUrl: string): string | null;
7
+ /**
8
+ * Every preview template a configured backend has advertised. The credential
9
+ * rule (`preview-origin-trust.ts`) trusts only origins these build.
10
+ */
11
+ export declare function knownPreviewUrlTemplates(): string[];
7
12
  /**
8
13
  * Whether this backend has ANSWERED yet — as opposed to "answered null", which
9
14
  * is a real answer meaning "this deployment serves no preview domain".
@@ -1 +1 @@
1
- {"version":3,"file":"preview-config.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview-config.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgCvF;AAED,iFAAiF;AACjF,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
1
+ {"version":3,"file":"preview-config.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview-config.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAEnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgCvF;AAED,iFAAiF;AACjF,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
@@ -33,6 +33,13 @@ function key(backendUrl) {
33
33
  export function cachedPreviewUrlTemplate(backendUrl) {
34
34
  return templates.get(key(backendUrl)) ?? null;
35
35
  }
36
+ /**
37
+ * Every preview template a configured backend has advertised. The credential
38
+ * rule (`preview-origin-trust.ts`) trusts only origins these build.
39
+ */
40
+ export function knownPreviewUrlTemplates() {
41
+ return [...templates.values()].filter((template) => typeof template === 'string');
42
+ }
36
43
  /**
37
44
  * Whether this backend has ANSWERED yet — as opposed to "answered null", which
38
45
  * is a real answer meaning "this deployment serves no preview domain".
@@ -1 +1 @@
1
- {"version":3,"file":"preview-config.js","sourceRoot":"","sources":["../../../src/core/session/preview-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CA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,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,IAAI,EAAE;aACjE,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YACnC,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,EAAE,oBAAoB,KAAK,QAAQ;gBACtE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,oBAAoB;gBACpC,CAAC,CAAC,IAAI,CAAC;YACT,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAClC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;YACvE,8DAA8D;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,uBAAuB;IACrC,SAAS,CAAC,KAAK,EAAE,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Pure trust decision for a preview-origin URL.
3
+ *
4
+ * - Deployed form: the URL's origin must be one an advertised template builds.
5
+ * - Local form: `p{port}-{sandbox}.localhost` on the SAME port as a configured
6
+ * local backend — that host resolves to the viewer's own machine, where the
7
+ * local API serves it.
8
+ */
9
+ export declare function isTrustedPreviewOrigin(candidateUrl: string, input: {
10
+ templates: readonly string[];
11
+ backendUrls: readonly string[];
12
+ }): boolean;
13
+ /**
14
+ * Whether `previewUrl` should carry the one-shot `?token`.
15
+ *
16
+ * Asks the configured backend for its preview template first when it has not
17
+ * answered yet. A URL that has the preview shape but no deployment behind it
18
+ * gets no credential; the caller opens it bare and the destination answers for
19
+ * itself.
20
+ */
21
+ export declare function shouldAttachPreviewToken(previewUrl: string, options?: {
22
+ serverUrl?: string;
23
+ }): Promise<boolean>;
24
+ //# sourceMappingURL=preview-origin-trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-origin-trust.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview-origin-trust.ts"],"names":[],"mappings":"AAyDA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE;IAAE,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACtE,OAAO,CAiBT;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,OAAO,CAAC,CAQlB"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Which preview origins may receive the caller's credential.
3
+ *
4
+ * A preview ORIGIN (`{env}-p{port}-{sandbox}.{domain}`, or the local
5
+ * `p{port}-{sandbox}.localhost:{port}`) cannot see the API's host-only
6
+ * `__preview_session` cookie, so its first request carries the bearer as a
7
+ * one-shot `?token`. That token is a full account credential, so the decision
8
+ * to attach it must rest on the deployment's own answer — the template from
9
+ * `GET /v1/p/config`, or the configured local backend — and never on the shape
10
+ * of the hostname alone. Any host can be named `p3000-something.example`.
11
+ *
12
+ * Internal: not exported from a public entry point.
13
+ */
14
+ import { platformConfig } from '../http/config.js';
15
+ import { isSubdomainPreviewUrl } from './preview.js';
16
+ import { knownPreviewUrlTemplates, loadPreviewUrlTemplate } from './preview-config.js';
17
+ const LOCAL_PREVIEW_HOST = /^p\d{1,5}-[a-z0-9-]+\.localhost$/;
18
+ function escapeRegExp(value) {
19
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
20
+ }
21
+ /**
22
+ * Whether `origin` (scheme + host + port, no path) is one the template builds.
23
+ * The template's literal text must match exactly; `{port}` matches digits and
24
+ * `{sandbox}` one hostname label.
25
+ */
26
+ function originMatchesTemplate(origin, template) {
27
+ if (!template.includes('{port}') || !template.includes('{sandbox}'))
28
+ return false;
29
+ const schemeEnd = template.indexOf('://');
30
+ if (schemeEnd <= 0)
31
+ return false;
32
+ const scheme = template.slice(0, schemeEnd).toLowerCase();
33
+ if (scheme !== 'https' && scheme !== 'http')
34
+ return false;
35
+ // Compare origins only: a path or trailing slash in the template is ignored.
36
+ const authority = (template.slice(schemeEnd + 3).split('/')[0] ?? '').toLowerCase();
37
+ const source = `${scheme}://${authority}`
38
+ .split('{port}')
39
+ .map((part) => part.split('{sandbox}').map(escapeRegExp).join('[a-z0-9-]+'))
40
+ .join('\\d{1,5}');
41
+ return new RegExp(`^${source}$`).test(origin);
42
+ }
43
+ function isLocalBackend(backendUrl) {
44
+ try {
45
+ const url = new URL(backendUrl);
46
+ return url.hostname === 'localhost' || url.hostname === '127.0.0.1' ? url : null;
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ function effectivePort(url) {
53
+ if (url.port)
54
+ return url.port;
55
+ return url.protocol === 'https:' ? '443' : '80';
56
+ }
57
+ /**
58
+ * Pure trust decision for a preview-origin URL.
59
+ *
60
+ * - Deployed form: the URL's origin must be one an advertised template builds.
61
+ * - Local form: `p{port}-{sandbox}.localhost` on the SAME port as a configured
62
+ * local backend — that host resolves to the viewer's own machine, where the
63
+ * local API serves it.
64
+ */
65
+ export function isTrustedPreviewOrigin(candidateUrl, input) {
66
+ let url;
67
+ try {
68
+ url = new URL(candidateUrl);
69
+ }
70
+ catch {
71
+ return false;
72
+ }
73
+ if (url.protocol !== 'https:' && url.protocol !== 'http:')
74
+ return false;
75
+ if (LOCAL_PREVIEW_HOST.test(url.hostname)) {
76
+ return input.backendUrls.some((backendUrl) => {
77
+ const backend = isLocalBackend(backendUrl);
78
+ return backend !== null && effectivePort(backend) === effectivePort(url);
79
+ });
80
+ }
81
+ return input.templates.some((template) => originMatchesTemplate(url.origin, template));
82
+ }
83
+ /**
84
+ * Whether `previewUrl` should carry the one-shot `?token`.
85
+ *
86
+ * Asks the configured backend for its preview template first when it has not
87
+ * answered yet. A URL that has the preview shape but no deployment behind it
88
+ * gets no credential; the caller opens it bare and the destination answers for
89
+ * itself.
90
+ */
91
+ export async function shouldAttachPreviewToken(previewUrl, options = {}) {
92
+ if (!isSubdomainPreviewUrl(previewUrl))
93
+ return false;
94
+ const backendUrl = platformConfig().backendUrl;
95
+ if (backendUrl)
96
+ await loadPreviewUrlTemplate(backendUrl).catch(() => null);
97
+ const backendUrls = [backendUrl, options.serverUrl].filter((value) => typeof value === 'string' && value.length > 0);
98
+ return isTrustedPreviewOrigin(previewUrl, { templates: knownPreviewUrlTemplates(), backendUrls });
99
+ }
100
+ //# sourceMappingURL=preview-origin-trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-origin-trust.js","sourceRoot":"","sources":["../../../src/core/session/preview-origin-trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AAE9D,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,MAAc,EAAE,QAAgB;IAC7D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAClF,MAAM,S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,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CACxD,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAC1E,CAAC;IACF,OAAO,sBAAsB,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AACpG,CAAC"}
@@ -10,13 +10,19 @@
10
10
  /**
11
11
  * Resolve the `POST /…/p/auth` endpoint that sets the `__preview_session`
12
12
  * cookie for a given preview URL. Returns null when the URL isn't a trusted
13
- * preview-proxy URL.
13
+ * preview-proxy URL. Trusted means the origin of `serverUrl` or, in a browser,
14
+ * the page's own origin; with neither known, nothing is trusted.
14
15
  */
15
16
  export declare function buildPreviewAuthEndpoint(previewUrl: string, serverUrl?: string): string | null;
16
17
  /**
17
18
  * Preview ORIGIN form: `p{port}-{sandbox}.{host}` locally, or the deployed
18
19
  * `{env}-p{port}-{sandbox}.{domain}`.
19
20
  *
21
+ * A SHAPE test only. It says which credential form a preview would need, not
22
+ * whether a host may receive one: any host can carry this shape. The SDK's own
23
+ * token paths (`authorizePreviewUrl`, `useAuthenticatedPreviewUrl`) also require
24
+ * the origin to match the deployment's advertised preview template.
25
+ *
20
26
  * These can't use the host-only `/v1/p/` session cookie — it never reaches
21
27
  * another hostname — so they authenticate the FIRST request with a one-shot
22
28
  * `?token`, which the proxy exchanges for a cookie on the preview origin and
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6CH;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAUnE;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA+CH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAUnE;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ5E"}
@@ -41,7 +41,9 @@ function isPreviewProxyUrl(candidateUrl, serverUrl) {
41
41
  if (typeof window !== 'undefined') {
42
42
  trustedOrigins.add(window.location.origin);
43
43
  }
44
- return trustedOrigins.size === 0 || trustedOrigins.has(url.origin);
44
+ // No known origin means nothing can be trusted: the bearer is never sent
45
+ // to an origin the caller did not name.
46
+ return trustedOrigins.has(url.origin);
45
47
  }
46
48
  catch {
47
49
  return false;
@@ -50,7 +52,8 @@ function isPreviewProxyUrl(candidateUrl, serverUrl) {
50
52
  /**
51
53
  * Resolve the `POST /…/p/auth` endpoint that sets the `__preview_session`
52
54
  * cookie for a given preview URL. Returns null when the URL isn't a trusted
53
- * preview-proxy URL.
55
+ * preview-proxy URL. Trusted means the origin of `serverUrl` or, in a browser,
56
+ * the page's own origin; with neither known, nothing is trusted.
54
57
  */
55
58
  export function buildPreviewAuthEndpoint(previewUrl, serverUrl) {
56
59
  if (!isPreviewProxyUrl(previewUrl, serverUrl))
@@ -62,6 +65,11 @@ export function buildPreviewAuthEndpoint(previewUrl, serverUrl) {
62
65
  * Preview ORIGIN form: `p{port}-{sandbox}.{host}` locally, or the deployed
63
66
  * `{env}-p{port}-{sandbox}.{domain}`.
64
67
  *
68
+ * A SHAPE test only. It says which credential form a preview would need, not
69
+ * whether a host may receive one: any host can carry this shape. The SDK's own
70
+ * token paths (`authorizePreviewUrl`, `useAuthenticatedPreviewUrl`) also require
71
+ * the origin to match the deployment's advertised preview template.
72
+ *
65
73
  * These can't use the host-only `/v1/p/` session cookie — it never reaches
66
74
  * another hostname — so they authenticate the FIRST request with a one-shot
67
75
  * `?token`, which the proxy exchanges for a cookie on the preview origin and
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/core/session/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,SAAS,yBAAyB,CAAC,YAAoB;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAElC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,OAAO,GAAG,GAAG,CAAC,MAAM,YAAY,CAAC;QACnC,CAAC;QAED,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC;QACtE,CAAC;QAED,OAAO,GAAG,GAAG,CAAC,MAAM,YAAY,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,YAAoB,EAAE,SAAkB;IACjE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,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AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3C,OAAO,CACL,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC;eAC3B,kDAAkD,CAAC,IAAI,CAAC,QAAQ,CAAC,CACrE,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAE,KAAa;IAClE,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * One read of a Kortix session row, riding the session-open bundle on the
3
+ * open path.
4
+ *
5
+ * The bundle's `session` leg is the row `GET .../sessions/:id` serves (the API
6
+ * builds both with `serializeSession`; the bundle omits `owner_email`, which no
7
+ * single-row reader renders). On a cold open the session page needs the row
8
+ * for the OpenCode root id before it can paint the transcript, so a separate
9
+ * row request sat on that path beside the bundle that already carried it.
10
+ *
11
+ * Same claim rule as `/turn` and `/prompts`: only the FIRST read — no row
12
+ * cached yet — may be answered by the bundle. Anything after that is a read
13
+ * issued because something changed, and it asks the endpoint.
14
+ *
15
+ * Internal: not exported from any public entry point.
16
+ */
17
+ import { getProjectSession, type ProjectSession } from '../rest/projects-client/sessions.js';
18
+ export declare function readProjectSessionRow(projectId: string, sessionId: string, options: {
19
+ bundle: boolean;
20
+ /** The row endpoint. Injected so a host-level test double of the REST
21
+ * barrel reaches this read too. */
22
+ fetchRow?: typeof getProjectSession;
23
+ }): Promise<ProjectSession>;
24
+ //# sourceMappingURL=project-session-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-session-read.d.ts","sourceRoot":"","sources":["../../../src/core/session/project-session-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAG1F,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IACP,MAAM,EAAE,OAAO,CAAC;IAChB;wCACoC;IACpC,QAAQ,CAAC,EAAE,OAAO,iBAAiB,CAAC;CACrC,GACA,OAAO,CAAC,cAAc,CAAC,CAQzB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * One read of a Kortix session row, riding the session-open bundle on the
3
+ * open path.
4
+ *
5
+ * The bundle's `session` leg is the row `GET .../sessions/:id` serves (the API
6
+ * builds both with `serializeSession`; the bundle omits `owner_email`, which no
7
+ * single-row reader renders). On a cold open the session page needs the row
8
+ * for the OpenCode root id before it can paint the transcript, so a separate
9
+ * row request sat on that path beside the bundle that already carried it.
10
+ *
11
+ * Same claim rule as `/turn` and `/prompts`: only the FIRST read — no row
12
+ * cached yet — may be answered by the bundle. Anything after that is a read
13
+ * issued because something changed, and it asks the endpoint.
14
+ *
15
+ * Internal: not exported from any public entry point.
16
+ */
17
+ import { getProjectSession } from '../rest/projects-client/sessions.js';
18
+ import { claimOpenBundle } from './open-bundle.js';
19
+ export async function readProjectSessionRow(projectId, sessionId, options) {
20
+ const claimed = options.bundle ? claimOpenBundle(projectId, sessionId) : null;
21
+ if (claimed) {
22
+ const bundle = await claimed;
23
+ if (bundle?.session)
24
+ return bundle.session;
25
+ }
26
+ const fetchRow = options.fetchRow ?? getProjectSession;
27
+ return fetchRow(projectId, sessionId, { showErrors: false });
28
+ }
29
+ //# sourceMappingURL=project-session-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-session-read.js","sourceRoot":"","sources":["../../../src/core/session/project-session-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,SAAiB,EACjB,SAAiB,EACjB,OAKC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9E,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;QAC7B,IAAI,MAAM,EAAE,OAAO;YAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAC7C,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACvD,OAAO,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Same-tick single-flight: callers that ask for the same key inside ONE
3
+ * macrotask share one request.
4
+ *
5
+ * WHY "same tick" and not "while in flight". A read of server truth answers
6
+ * the question as of the instant it was ISSUED. A trigger that arrives while a
7
+ * read is already on the wire — a status frame, a queue drain — is news that
8
+ * read cannot contain, so joining it would hand the new trigger a stale answer.
9
+ * Callers inside the same macrotask were caused by the same event (several
10
+ * components' effects in one React commit), so one read answers all of them.
11
+ *
12
+ * The window closes on the next macrotask (`setTimeout(0)`), not on settle, so
13
+ * a slow request cannot widen it. The entry is dropped on settle either way.
14
+ *
15
+ * Internal: not exported from any public entry point.
16
+ */
17
+ type Schedule = (callback: () => void) => void;
18
+ export declare function createTickSingleFlight<T>(schedule?: Schedule): (key: string, read: () => Promise<T>) => Promise<T>;
19
+ export {};
20
+ //# sourceMappingURL=single-flight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-flight.d.ts","sourceRoot":"","sources":["../../../src/core/session/single-flight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,KAAK,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAW/C,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,QAAQ,GAAE,QAA0B,IAExD,KAAK,MAAM,EAAE,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC,CAcrE"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Same-tick single-flight: callers that ask for the same key inside ONE
3
+ * macrotask share one request.
4
+ *
5
+ * WHY "same tick" and not "while in flight". A read of server truth answers
6
+ * the question as of the instant it was ISSUED. A trigger that arrives while a
7
+ * read is already on the wire — a status frame, a queue drain — is news that
8
+ * read cannot contain, so joining it would hand the new trigger a stale answer.
9
+ * Callers inside the same macrotask were caused by the same event (several
10
+ * components' effects in one React commit), so one read answers all of them.
11
+ *
12
+ * The window closes on the next macrotask (`setTimeout(0)`), not on settle, so
13
+ * a slow request cannot widen it. The entry is dropped on settle either way.
14
+ *
15
+ * Internal: not exported from any public entry point.
16
+ */
17
+ const defaultSchedule = (callback) => {
18
+ setTimeout(callback, 0);
19
+ };
20
+ export function createTickSingleFlight(schedule = defaultSchedule) {
21
+ const flights = new Map();
22
+ return function run(key, read) {
23
+ const current = flights.get(key);
24
+ if (current?.joinable)
25
+ return current.promise;
26
+ const flight = { promise: read(), joinable: true };
27
+ flights.set(key, flight);
28
+ schedule(() => {
29
+ flight.joinable = false;
30
+ });
31
+ const drop = () => {
32
+ if (flights.get(key) === flight)
33
+ flights.delete(key);
34
+ };
35
+ flight.promise.then(drop, drop);
36
+ return flight.promise;
37
+ };
38
+ }
39
+ //# sourceMappingURL=single-flight.js.map