@kortix/sdk 0.13.4 → 0.13.7

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 (380) hide show
  1. package/README.md +63 -6
  2. package/dist/browser/cache/idb-sync-cache.d.ts +19 -1
  3. package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
  4. package/dist/browser/cache/idb-sync-cache.js +39 -4
  5. package/dist/browser/cache/idb-sync-cache.js.map +1 -1
  6. package/dist/browser/session-sync/server-transcript-mirror.d.ts +82 -0
  7. package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -0
  8. package/dist/browser/session-sync/server-transcript-mirror.js +143 -0
  9. package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -0
  10. package/dist/browser/session-sync/session-sync-registry.d.ts +11 -1
  11. package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
  12. package/dist/browser/session-sync/session-sync-registry.js +117 -9
  13. package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
  14. package/dist/browser/session-sync/visibility.d.ts +19 -0
  15. package/dist/browser/session-sync/visibility.d.ts.map +1 -0
  16. package/dist/browser/session-sync/visibility.js +16 -0
  17. package/dist/browser/session-sync/visibility.js.map +1 -0
  18. package/dist/browser/stores/sandbox-connection-store.d.ts +13 -1
  19. package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
  20. package/dist/browser/stores/sandbox-connection-store.js +6 -3
  21. package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
  22. package/dist/browser/stores/session-working-store.d.ts +10 -5
  23. package/dist/browser/stores/session-working-store.d.ts.map +1 -1
  24. package/dist/browser/stores/session-working-store.js +32 -8
  25. package/dist/browser/stores/session-working-store.js.map +1 -1
  26. package/dist/browser/stores/sync-store.d.ts +56 -2
  27. package/dist/browser/stores/sync-store.d.ts.map +1 -1
  28. package/dist/browser/stores/sync-store.js +682 -402
  29. package/dist/browser/stores/sync-store.js.map +1 -1
  30. package/dist/core/auth/app-viewer.d.ts +57 -0
  31. package/dist/core/auth/app-viewer.d.ts.map +1 -0
  32. package/dist/core/auth/app-viewer.js +82 -0
  33. package/dist/core/auth/app-viewer.js.map +1 -0
  34. package/dist/core/auth/session.d.ts +45 -0
  35. package/dist/core/auth/session.d.ts.map +1 -0
  36. package/dist/core/auth/session.js +113 -0
  37. package/dist/core/auth/session.js.map +1 -0
  38. package/dist/core/client/kortix.d.ts +37 -29
  39. package/dist/core/client/kortix.d.ts.map +1 -1
  40. package/dist/core/client/kortix.js +61 -8
  41. package/dist/core/client/kortix.js.map +1 -1
  42. package/dist/core/http/config.d.ts +4 -2
  43. package/dist/core/http/config.d.ts.map +1 -1
  44. package/dist/core/http/config.js.map +1 -1
  45. package/dist/core/http/opencode-errors.d.ts +17 -0
  46. package/dist/core/http/opencode-errors.d.ts.map +1 -1
  47. package/dist/core/http/opencode-errors.js +25 -0
  48. package/dist/core/http/opencode-errors.js.map +1 -1
  49. package/dist/core/rest/platform-client/auth.d.ts +120 -0
  50. package/dist/core/rest/platform-client/auth.d.ts.map +1 -0
  51. package/dist/core/rest/platform-client/auth.js +98 -0
  52. package/dist/core/rest/platform-client/auth.js.map +1 -0
  53. package/dist/core/rest/platform-client/host-boundary.d.ts +5 -0
  54. package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
  55. package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
  56. package/dist/core/rest/projects-client/accounts.d.ts +57 -0
  57. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  58. package/dist/core/rest/projects-client/accounts.js +31 -0
  59. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  60. package/dist/core/rest/projects-client/apps.d.ts +9 -0
  61. package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
  62. package/dist/core/rest/projects-client/apps.js.map +1 -1
  63. package/dist/core/rest/projects-client/billing.d.ts +2 -0
  64. package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
  65. package/dist/core/rest/projects-client/billing.js.map +1 -1
  66. package/dist/core/rest/projects-client/channels.d.ts +0 -3
  67. package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
  68. package/dist/core/rest/projects-client/channels.js +0 -6
  69. package/dist/core/rest/projects-client/channels.js.map +1 -1
  70. package/dist/core/rest/projects-client/connectors.d.ts +104 -19
  71. package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
  72. package/dist/core/rest/projects-client/connectors.js +56 -2
  73. package/dist/core/rest/projects-client/connectors.js.map +1 -1
  74. package/dist/core/rest/projects-client/index.d.ts +1 -2
  75. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  76. package/dist/core/rest/projects-client/index.js +1 -2
  77. package/dist/core/rest/projects-client/index.js.map +1 -1
  78. package/dist/core/rest/projects-client/oauth-clients.d.ts +47 -0
  79. package/dist/core/rest/projects-client/oauth-clients.d.ts.map +1 -0
  80. package/dist/core/rest/projects-client/oauth-clients.js +33 -0
  81. package/dist/core/rest/projects-client/oauth-clients.js.map +1 -0
  82. package/dist/core/rest/projects-client/projects.d.ts +23 -6
  83. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  84. package/dist/core/rest/projects-client/projects.js +6 -3
  85. package/dist/core/rest/projects-client/projects.js.map +1 -1
  86. package/dist/core/rest/projects-client/session-sandbox.d.ts +52 -0
  87. package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
  88. package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
  89. package/dist/core/rest/projects-client/sessions.d.ts +142 -34
  90. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  91. package/dist/core/rest/projects-client/sessions.js +48 -19
  92. package/dist/core/rest/projects-client/sessions.js.map +1 -1
  93. package/dist/core/runtime/attachment-part.d.ts +26 -0
  94. package/dist/core/runtime/attachment-part.d.ts.map +1 -0
  95. package/dist/core/runtime/attachment-part.js +41 -0
  96. package/dist/core/runtime/attachment-part.js.map +1 -0
  97. package/dist/core/runtime/client.d.ts +4 -2
  98. package/dist/core/runtime/client.d.ts.map +1 -1
  99. package/dist/core/runtime/client.js +3 -2
  100. package/dist/core/runtime/client.js.map +1 -1
  101. package/dist/core/runtime/opencode-v2-event-aliases.d.ts +184 -0
  102. package/dist/core/runtime/opencode-v2-event-aliases.d.ts.map +1 -0
  103. package/dist/core/runtime/opencode-v2-event-aliases.js +2 -0
  104. package/dist/core/runtime/opencode-v2-event-aliases.js.map +1 -0
  105. package/dist/core/runtime/pty.d.ts +11 -1
  106. package/dist/core/runtime/pty.d.ts.map +1 -1
  107. package/dist/core/runtime/pty.js +19 -6
  108. package/dist/core/runtime/pty.js.map +1 -1
  109. package/dist/core/session/connection.d.ts +64 -0
  110. package/dist/core/session/connection.d.ts.map +1 -0
  111. package/dist/core/session/connection.js +36 -0
  112. package/dist/core/session/connection.js.map +1 -0
  113. package/dist/core/session/index.d.ts +2 -0
  114. package/dist/core/session/index.d.ts.map +1 -1
  115. package/dist/core/session/index.js +2 -0
  116. package/dist/core/session/index.js.map +1 -1
  117. package/dist/core/session/open-bundle.d.ts +110 -0
  118. package/dist/core/session/open-bundle.d.ts.map +1 -0
  119. package/dist/core/session/open-bundle.js +183 -0
  120. package/dist/core/session/open-bundle.js.map +1 -0
  121. package/dist/core/session/poll-owner.d.ts +35 -0
  122. package/dist/core/session/poll-owner.d.ts.map +1 -0
  123. package/dist/core/session/poll-owner.js +90 -0
  124. package/dist/core/session/poll-owner.js.map +1 -0
  125. package/dist/core/session/preview-auth.d.ts +25 -0
  126. package/dist/core/session/preview-auth.d.ts.map +1 -1
  127. package/dist/core/session/preview-auth.js +31 -1
  128. package/dist/core/session/preview-auth.js.map +1 -1
  129. package/dist/core/session/preview-config.d.ts +26 -0
  130. package/dist/core/session/preview-config.d.ts.map +1 -0
  131. package/dist/core/session/preview-config.js +95 -0
  132. package/dist/core/session/preview-config.js.map +1 -0
  133. package/dist/core/session/preview-options.d.ts +25 -0
  134. package/dist/core/session/preview-options.d.ts.map +1 -0
  135. package/dist/core/session/preview-options.js +45 -0
  136. package/dist/core/session/preview-options.js.map +1 -0
  137. package/dist/core/session/preview.d.ts +8 -3
  138. package/dist/core/session/preview.d.ts.map +1 -1
  139. package/dist/core/session/preview.js +11 -4
  140. package/dist/core/session/preview.js.map +1 -1
  141. package/dist/core/session/rewind.d.ts +67 -24
  142. package/dist/core/session/rewind.d.ts.map +1 -1
  143. package/dist/core/session/rewind.js +74 -26
  144. package/dist/core/session/rewind.js.map +1 -1
  145. package/dist/core/session/server-store/active.d.ts +10 -12
  146. package/dist/core/session/server-store/active.d.ts.map +1 -1
  147. package/dist/core/session/server-store/active.js +11 -9
  148. package/dist/core/session/server-store/active.js.map +1 -1
  149. package/dist/core/session/server-store/url-helpers.d.ts +11 -2
  150. package/dist/core/session/server-store/url-helpers.d.ts.map +1 -1
  151. package/dist/core/session/server-store/url-helpers.js +11 -2
  152. package/dist/core/session/server-store/url-helpers.js.map +1 -1
  153. package/dist/core/session/static-file-preview.d.ts +50 -0
  154. package/dist/core/session/static-file-preview.d.ts.map +1 -0
  155. package/dist/core/session/static-file-preview.js +91 -0
  156. package/dist/core/session/static-file-preview.js.map +1 -0
  157. package/dist/core/session/url.d.ts +25 -2
  158. package/dist/core/session/url.d.ts.map +1 -1
  159. package/dist/core/session/url.js +87 -11
  160. package/dist/core/session/url.js.map +1 -1
  161. package/dist/core/session/wake-escalation.d.ts +188 -0
  162. package/dist/core/session/wake-escalation.d.ts.map +1 -0
  163. package/dist/core/session/wake-escalation.js +241 -0
  164. package/dist/core/session/wake-escalation.js.map +1 -0
  165. package/dist/core/session/working.d.ts +107 -2
  166. package/dist/core/session/working.d.ts.map +1 -1
  167. package/dist/core/session/working.js +206 -7
  168. package/dist/core/session/working.js.map +1 -1
  169. package/dist/core/session-sync/durable-log.d.ts +96 -0
  170. package/dist/core/session-sync/durable-log.d.ts.map +1 -0
  171. package/dist/core/session-sync/durable-log.js +94 -0
  172. package/dist/core/session-sync/durable-log.js.map +1 -0
  173. package/dist/core/session-sync/fragment.d.ts +27 -0
  174. package/dist/core/session-sync/fragment.d.ts.map +1 -0
  175. package/dist/core/session-sync/fragment.js +24 -0
  176. package/dist/core/session-sync/fragment.js.map +1 -0
  177. package/dist/core/session-sync/session-sync-controller.d.ts +117 -11
  178. package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
  179. package/dist/core/session-sync/session-sync-controller.js +278 -26
  180. package/dist/core/session-sync/session-sync-controller.js.map +1 -1
  181. package/dist/core/stream/keepalive.d.ts +17 -0
  182. package/dist/core/stream/keepalive.d.ts.map +1 -0
  183. package/dist/core/stream/keepalive.js +19 -0
  184. package/dist/core/stream/keepalive.js.map +1 -0
  185. package/dist/core/turns/grouping.d.ts.map +1 -1
  186. package/dist/core/turns/grouping.js +73 -23
  187. package/dist/core/turns/grouping.js.map +1 -1
  188. package/dist/core/turns/types.d.ts +5 -0
  189. package/dist/core/turns/types.d.ts.map +1 -1
  190. package/dist/index.d.ts +16 -1
  191. package/dist/index.d.ts.map +1 -1
  192. package/dist/index.js +19 -0
  193. package/dist/index.js.map +1 -1
  194. package/dist/kortix.esm.min.js +25 -25
  195. package/dist/kortix.global.js +25 -25
  196. package/dist/node/app-viewer.d.ts +41 -0
  197. package/dist/node/app-viewer.d.ts.map +1 -0
  198. package/dist/node/app-viewer.js +150 -0
  199. package/dist/node/app-viewer.js.map +1 -0
  200. package/dist/node/auth.d.ts +84 -0
  201. package/dist/node/auth.d.ts.map +1 -0
  202. package/dist/node/auth.js +414 -0
  203. package/dist/node/auth.js.map +1 -0
  204. package/dist/node/server.d.ts +19 -0
  205. package/dist/node/server.d.ts.map +1 -1
  206. package/dist/node/server.js +13 -1
  207. package/dist/node/server.js.map +1 -1
  208. package/dist/platform/auth-core.d.ts +13 -1
  209. package/dist/platform/auth-core.d.ts.map +1 -1
  210. package/dist/platform/auth-core.js +13 -1
  211. package/dist/platform/auth-core.js.map +1 -1
  212. package/dist/react/bedrock-invokable.d.ts +58 -0
  213. package/dist/react/bedrock-invokable.d.ts.map +1 -0
  214. package/dist/react/bedrock-invokable.js +83 -0
  215. package/dist/react/bedrock-invokable.js.map +1 -0
  216. package/dist/react/index.d.ts +3 -0
  217. package/dist/react/index.d.ts.map +1 -1
  218. package/dist/react/index.js +7 -0
  219. package/dist/react/index.js.map +1 -1
  220. package/dist/react/model-flatten.d.ts +14 -1
  221. package/dist/react/model-flatten.d.ts.map +1 -1
  222. package/dist/react/model-flatten.js +3 -4
  223. package/dist/react/model-flatten.js.map +1 -1
  224. package/dist/react/opencode.d.ts +3 -1
  225. package/dist/react/opencode.d.ts.map +1 -1
  226. package/dist/react/opencode.js +5 -1
  227. package/dist/react/opencode.js.map +1 -1
  228. package/dist/react/provider-selection.d.ts +58 -0
  229. package/dist/react/provider-selection.d.ts.map +1 -1
  230. package/dist/react/provider-selection.js +253 -2
  231. package/dist/react/provider-selection.js.map +1 -1
  232. package/dist/react/session-start-giveup.d.ts +12 -0
  233. package/dist/react/session-start-giveup.d.ts.map +1 -0
  234. package/dist/react/session-start-giveup.js +13 -0
  235. package/dist/react/session-start-giveup.js.map +1 -0
  236. package/dist/react/session-title-sync.d.ts.map +1 -1
  237. package/dist/react/session-title-sync.js +15 -5
  238. package/dist/react/session-title-sync.js.map +1 -1
  239. package/dist/react/sign-in-with-kortix.d.ts +346 -0
  240. package/dist/react/sign-in-with-kortix.d.ts.map +1 -0
  241. package/dist/react/sign-in-with-kortix.js +65 -0
  242. package/dist/react/sign-in-with-kortix.js.map +1 -0
  243. package/dist/react/use-admin-accounts.d.ts +36 -1
  244. package/dist/react/use-admin-accounts.d.ts.map +1 -1
  245. package/dist/react/use-admin-accounts.js +19 -0
  246. package/dist/react/use-admin-accounts.js.map +1 -1
  247. package/dist/react/use-gateway-routing-policy.d.ts +1 -0
  248. package/dist/react/use-gateway-routing-policy.d.ts.map +1 -1
  249. package/dist/react/use-gateway-routing-policy.js +12 -1
  250. package/dist/react/use-gateway-routing-policy.js.map +1 -1
  251. package/dist/react/use-kortix-app-viewer.d.ts +13 -0
  252. package/dist/react/use-kortix-app-viewer.d.ts.map +1 -0
  253. package/dist/react/use-kortix-app-viewer.js +29 -0
  254. package/dist/react/use-kortix-app-viewer.js.map +1 -0
  255. package/dist/react/use-model-defaults.d.ts +7 -0
  256. package/dist/react/use-model-defaults.d.ts.map +1 -1
  257. package/dist/react/use-model-defaults.js +7 -1
  258. package/dist/react/use-model-defaults.js.map +1 -1
  259. package/dist/react/use-model-enablement.d.ts.map +1 -1
  260. package/dist/react/use-model-enablement.js +5 -1
  261. package/dist/react/use-model-enablement.js.map +1 -1
  262. package/dist/react/use-model-store.d.ts +31 -0
  263. package/dist/react/use-model-store.d.ts.map +1 -1
  264. package/dist/react/use-model-store.js +31 -2
  265. package/dist/react/use-model-store.js.map +1 -1
  266. package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
  267. package/dist/react/use-opencode-events/handle-event.js +26 -0
  268. package/dist/react/use-opencode-events/handle-event.js.map +1 -1
  269. package/dist/react/use-opencode-events/helpers.d.ts +49 -5
  270. package/dist/react/use-opencode-events/helpers.d.ts.map +1 -1
  271. package/dist/react/use-opencode-events/helpers.js +54 -6
  272. package/dist/react/use-opencode-events/helpers.js.map +1 -1
  273. package/dist/react/use-opencode-events/index.d.ts.map +1 -1
  274. package/dist/react/use-opencode-events/index.js +80 -8
  275. package/dist/react/use-opencode-events/index.js.map +1 -1
  276. package/dist/react/use-opencode-events/rehydrate-targets.d.ts +18 -0
  277. package/dist/react/use-opencode-events/rehydrate-targets.d.ts.map +1 -0
  278. package/dist/react/use-opencode-events/rehydrate-targets.js +20 -0
  279. package/dist/react/use-opencode-events/rehydrate-targets.js.map +1 -0
  280. package/dist/react/use-opencode-events/stream-revival.d.ts +37 -0
  281. package/dist/react/use-opencode-events/stream-revival.d.ts.map +1 -0
  282. package/dist/react/use-opencode-events/stream-revival.js +53 -0
  283. package/dist/react/use-opencode-events/stream-revival.js.map +1 -0
  284. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
  285. package/dist/react/use-opencode-events/use-event-stream-refs.js +14 -2
  286. package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -1
  287. package/dist/react/use-opencode-local.d.ts.map +1 -1
  288. package/dist/react/use-opencode-local.js +27 -8
  289. package/dist/react/use-opencode-local.js.map +1 -1
  290. package/dist/react/use-opencode-pty.d.ts +7 -1
  291. package/dist/react/use-opencode-pty.d.ts.map +1 -1
  292. package/dist/react/use-opencode-pty.js +6 -2
  293. package/dist/react/use-opencode-pty.js.map +1 -1
  294. package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
  295. package/dist/react/use-opencode-sessions/agents.js +13 -2
  296. package/dist/react/use-opencode-sessions/agents.js.map +1 -1
  297. package/dist/react/use-opencode-sessions/commands.d.ts +12 -0
  298. package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
  299. package/dist/react/use-opencode-sessions/commands.js +15 -3
  300. package/dist/react/use-opencode-sessions/commands.js.map +1 -1
  301. package/dist/react/use-opencode-sessions/index.d.ts +1 -0
  302. package/dist/react/use-opencode-sessions/index.d.ts.map +1 -1
  303. package/dist/react/use-opencode-sessions/index.js +1 -0
  304. package/dist/react/use-opencode-sessions/index.js.map +1 -1
  305. package/dist/react/use-opencode-sessions/keys.d.ts +8 -0
  306. package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -1
  307. package/dist/react/use-opencode-sessions/keys.js +8 -0
  308. package/dist/react/use-opencode-sessions/keys.js.map +1 -1
  309. package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
  310. package/dist/react/use-opencode-sessions/providers.js +56 -5
  311. package/dist/react/use-opencode-sessions/providers.js.map +1 -1
  312. package/dist/react/use-opencode-sessions/shared.d.ts +23 -0
  313. package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -1
  314. package/dist/react/use-opencode-sessions/shared.js +31 -0
  315. package/dist/react/use-opencode-sessions/shared.js.map +1 -1
  316. package/dist/react/use-opencode-sessions/vcs.d.ts +28 -0
  317. package/dist/react/use-opencode-sessions/vcs.d.ts.map +1 -0
  318. package/dist/react/use-opencode-sessions/vcs.js +42 -0
  319. package/dist/react/use-opencode-sessions/vcs.js.map +1 -0
  320. package/dist/react/use-poll-owner.d.ts +14 -0
  321. package/dist/react/use-poll-owner.d.ts.map +1 -0
  322. package/dist/react/use-poll-owner.js +32 -0
  323. package/dist/react/use-poll-owner.js.map +1 -0
  324. package/dist/react/use-project-llm-gateway.d.ts +27 -0
  325. package/dist/react/use-project-llm-gateway.d.ts.map +1 -0
  326. package/dist/react/use-project-llm-gateway.js +41 -0
  327. package/dist/react/use-project-llm-gateway.js.map +1 -0
  328. package/dist/react/use-project-models.d.ts +9 -0
  329. package/dist/react/use-project-models.d.ts.map +1 -1
  330. package/dist/react/use-project-models.js +24 -1
  331. package/dist/react/use-project-models.js.map +1 -1
  332. package/dist/react/use-runtime-reconnect.d.ts +11 -0
  333. package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
  334. package/dist/react/use-runtime-reconnect.js +34 -3
  335. package/dist/react/use-runtime-reconnect.js.map +1 -1
  336. package/dist/react/use-session-prompts.d.ts +53 -3
  337. package/dist/react/use-session-prompts.d.ts.map +1 -1
  338. package/dist/react/use-session-prompts.js +133 -21
  339. package/dist/react/use-session-prompts.js.map +1 -1
  340. package/dist/react/use-session-send.d.ts +17 -0
  341. package/dist/react/use-session-send.d.ts.map +1 -1
  342. package/dist/react/use-session-send.js +54 -5
  343. package/dist/react/use-session-send.js.map +1 -1
  344. package/dist/react/use-session-start-give-up.d.ts +20 -0
  345. package/dist/react/use-session-start-give-up.d.ts.map +1 -0
  346. package/dist/react/use-session-start-give-up.js +60 -0
  347. package/dist/react/use-session-start-give-up.js.map +1 -0
  348. package/dist/react/use-session-sync.d.ts +35 -1
  349. package/dist/react/use-session-sync.d.ts.map +1 -1
  350. package/dist/react/use-session-sync.js +135 -53
  351. package/dist/react/use-session-sync.js.map +1 -1
  352. package/dist/react/use-session-working.d.ts +55 -0
  353. package/dist/react/use-session-working.d.ts.map +1 -1
  354. package/dist/react/use-session-working.js +114 -13
  355. package/dist/react/use-session-working.js.map +1 -1
  356. package/dist/react/use-session.d.ts +13 -13
  357. package/dist/react/use-session.d.ts.map +1 -1
  358. package/dist/react/use-session.js +74 -53
  359. package/dist/react/use-session.js.map +1 -1
  360. package/dist/react/use-static-file-preview.d.ts +12 -0
  361. package/dist/react/use-static-file-preview.d.ts.map +1 -0
  362. package/dist/react/use-static-file-preview.js +119 -0
  363. package/dist/react/use-static-file-preview.js.map +1 -0
  364. package/dist/react/use-wake-escalation.d.ts +51 -0
  365. package/dist/react/use-wake-escalation.d.ts.map +1 -0
  366. package/dist/react/use-wake-escalation.js +62 -0
  367. package/dist/react/use-wake-escalation.js.map +1 -0
  368. package/package.json +6 -4
  369. package/dist/browser/session-sync/session-transcript-cache.d.ts +0 -79
  370. package/dist/browser/session-sync/session-transcript-cache.d.ts.map +0 -1
  371. package/dist/browser/session-sync/session-transcript-cache.js +0 -91
  372. package/dist/browser/session-sync/session-transcript-cache.js.map +0 -1
  373. package/dist/core/rest/projects-client/public-voice-join.d.ts +0 -59
  374. package/dist/core/rest/projects-client/public-voice-join.d.ts.map +0 -1
  375. package/dist/core/rest/projects-client/public-voice-join.js +0 -64
  376. package/dist/core/rest/projects-client/public-voice-join.js.map +0 -1
  377. package/dist/core/rest/projects-client/transcription.d.ts +0 -5
  378. package/dist/core/rest/projects-client/transcription.d.ts.map +0 -1
  379. package/dist/core/rest/projects-client/transcription.js +0 -14
  380. package/dist/core/rest/projects-client/transcription.js.map +0 -1
@@ -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;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAMnE;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;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"}
@@ -59,13 +59,20 @@ export function buildPreviewAuthEndpoint(previewUrl, serverUrl) {
59
59
  derivePreviewAuthEndpoint(previewUrl));
60
60
  }
61
61
  /**
62
- * Subdomain preview form: `p{port}-{sandbox}.{host}/…`. These can't use the
63
- * host-only `/v1/p/` session cookie (it never reaches the preview subdomain),
64
- * so they authenticate via a one-shot `?token` on the first request.
62
+ * Preview ORIGIN form: `p{port}-{sandbox}.{host}` locally, or the deployed
63
+ * `{env}-p{port}-{sandbox}.{domain}`.
64
+ *
65
+ * These can't use the host-only `/v1/p/` session cookie — it never reaches
66
+ * another hostname — so they authenticate the FIRST request with a one-shot
67
+ * `?token`, which the proxy exchanges for a cookie on the preview origin and
68
+ * then strips. Every later request (sub-resources, `fetch`, WebSockets) rides
69
+ * that cookie, which is the only credential an app's own code can carry.
65
70
  */
66
71
  export function isSubdomainPreviewUrl(candidateUrl) {
67
72
  try {
68
- return /^p\d+-[^.]+\./.test(new URL(candidateUrl).hostname);
73
+ const { hostname } = new URL(candidateUrl);
74
+ return (/^p\d+-[^.]+\./.test(hostname)
75
+ || /^(?:dev|staging|prod|preview)-p\d+-[a-z0-9-]+\./i.test(hostname));
69
76
  }
70
77
  catch {
71
78
  return false;
@@ -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,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC1B,MAAM,aAAa,GACjB,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC;YACzC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QAEjC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACzC,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC;gBACH,cAAc,CAAC,GAAG,C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AC,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"}
@@ -9,16 +9,27 @@
9
9
  * 1. Which locally-known messages does a staged rewind hide?
10
10
  * 2. When is a message id inside the range a committed rewind must delete?
11
11
  *
12
- * `watermark` exists to fix a real bug: hiding used to be "everything at-or-
13
- * after the boundary id", recomputed on every render off the CURRENT message
14
- * list. A message minted AFTER staging the user's replacement prompt, its
15
- * answer sorts above the boundary by id exactly like every OTHER later
16
- * message, so it fell inside "everything after the boundary" too and never
17
- * rendered until an unrelated remount flooded the whole transcript back,
18
- * interleaved. `watermark` freezes the upper edge of the hide window at the
19
- * newest message id known AT STAGE TIME, so only messages that were already
20
- * part of the abandoned trajectory are ever hidden anything newer always
21
- * renders.
12
+ * The window is a SET of message ids, captured at stage time. It used to be a
13
+ * lexical id RANGE — `id >= messageId && id <= watermark` which assumed ids
14
+ * ascend with time. OpenCode 1.18.15 retired that invariant outright (turn
15
+ * exit now reads `lastAssistant.parentID === lastUser.id`, and
16
+ * `MessageV2.latest()` orders by `time.created` with the id only as a
17
+ * tie-break), and the range failed in both directions:
18
+ *
19
+ * - **under-delete** a reverted assistant message whose id happens to sort
20
+ * BELOW the boundary falls outside the interval, survives the commit,
21
+ * is orphaned, and reappears at the top of the chat;
22
+ * - **over-delete** — `ascendingId` stubs sit ~2.8e13 above every real id, so
23
+ * a single in-flight optimistic message pushed the watermark to
24
+ * effectively infinity and the interval swallowed the user's replacement
25
+ * prompt and its answer.
26
+ *
27
+ * Membership has neither failure. `hiddenIds` is the exact list of messages
28
+ * that were part of the abandoned trajectory at the moment the rewind was
29
+ * staged: nothing minted afterwards can enter it, and nothing inside it can
30
+ * escape on an id comparison. `watermark` is retained as a published field —
31
+ * it names the newest message known at stage time — and still answers
32
+ * {@link isWithinRewindWindow} for a legacy state that carries no `hiddenIds`.
22
33
  */
23
34
  export interface SessionRewindState {
24
35
  /** The message the rewind pointer sits at — hidden along with everything
@@ -26,10 +37,25 @@ export interface SessionRewindState {
26
37
  messageId: string;
27
38
  /**
28
39
  * The newest message id known locally at the moment this rewind was staged
29
- * (or first observed). The upper bound of the hide window — fixed once,
30
- * never recomputed against a later, larger message list.
40
+ * (or first observed) see {@link newestMessageId}.
41
+ *
42
+ * No longer the upper bound of anything: {@link hiddenIds} is the window.
43
+ * Retained because it is a published field, and because it is the only
44
+ * bound available to a legacy state that carries no `hiddenIds`.
31
45
  */
32
46
  watermark: string;
47
+ /**
48
+ * The exact messages this rewind abandons — the boundary message and
49
+ * everything that followed it in the transcript, captured ONCE at stage
50
+ * time and never recomputed. Membership in this list is the whole of the
51
+ * hide/delete test; see the module comment for the two failures the lexical
52
+ * range it replaced produced.
53
+ *
54
+ * Optional only for backward compatibility: a `SessionRewindState` built by
55
+ * an older consumer (or restored from one) has none, and falls back to the
56
+ * legacy range. Everything in this SDK populates it.
57
+ */
58
+ hiddenIds?: readonly string[];
33
59
  /**
34
60
  * False once the replacement prompt has been sent (or a
35
61
  * `session.next.revert.committed` wire event says the server has). The
@@ -40,32 +66,49 @@ export interface SessionRewindState {
40
66
  */
41
67
  staged: boolean;
42
68
  }
43
- /** Whether `id` falls inside the [messageId, watermark] hide range — both
44
- * bounds inclusive: the boundary message itself is part of what an edit
45
- * replaces, and the watermark is the last message known at stage time. */
69
+ /** Whether `id` is one of the messages this rewind abandons.
70
+ *
71
+ * Membership in the set captured at stage time never a comparison between
72
+ * two id strings, which say nothing about which message came first. The
73
+ * legacy `[messageId, watermark]` range answers only for a state that
74
+ * carries no captured set. */
46
75
  export declare function isWithinRewindWindow(id: string, rewind: SessionRewindState): boolean;
47
76
  /**
48
- * The newest (highest sort-order) message id in `messages`, or `null` for an
49
- * empty list. Deliberately a max-scan, not "the last element" most callers
50
- * pass an ascending-sorted list, but an optimistic entry appended out of
51
- * order must never win the max by position alone.
77
+ * The newest message in `messages`, by `time.created` with the id as the only
78
+ * tie-break the same order the server's own `MessageV2.latest()` uses.
79
+ * `null` for an empty list.
80
+ *
81
+ * Deliberately a max-scan, not "the last element": most callers pass an
82
+ * ordered list, but an optimistic entry appended out of order must never win
83
+ * by position alone. A message with no `time` cannot be dated, so it competes
84
+ * on its id only.
52
85
  */
53
86
  export declare function newestMessageId<T extends {
54
87
  info: {
55
88
  id: string;
89
+ time?: {
90
+ created?: number;
91
+ };
56
92
  };
57
93
  }>(messages: T[]): string | null;
58
94
  /**
59
95
  * Build the state for a freshly staged (or freshly discovered) rewind.
60
- * `watermark` is captured HERE, from the message list at this exact moment —
61
- * never recomputed later. Falls back to `messageId` itself when nothing is
62
- * known locally yet (a cross-tab or reload discovery with no synced messages
63
- * for this session), which hides only the boundary message and nothing
64
- * else the narrowest correct answer with no other information available.
96
+ *
97
+ * The window is captured HERE and never recomputed: `hiddenIds` is the
98
+ * boundary message plus every message that follows it in `messages`, taken in
99
+ * the order the caller holds them which is the server's own
100
+ * `time.created` page order, not an id order. Falls back to `messageId`
101
+ * itself when the boundary is not in the list (a cross-tab or reload
102
+ * discovery with no synced messages for this session), which hides only the
103
+ * boundary message — the narrowest correct answer with no other information
104
+ * available.
65
105
  */
66
106
  export declare function stageSessionRewind<T extends {
67
107
  info: {
68
108
  id: string;
109
+ time?: {
110
+ created?: number;
111
+ };
69
112
  };
70
113
  }>(messages: T[], messageId: string): SessionRewindState;
71
114
  /** Hide the target message and every message up to the staged watermark.
@@ -1 +1 @@
1
- {"version":3,"file":"rewind.d.ts","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,kBAAkB;IACjC;6BACyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,MAAM,EAAE,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wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAGpF;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS;IAAE,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EAC/D,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CA4B9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,SAAS;IAAE,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EAC/D,QAAQ,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAUtD;AAED;;4EAE4E;AAC5E,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACrE,QAAQ,EAAE,CAAC,EAAE,EACb,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAChC,CAAC,EAAE,CAIL;AAED;;;4EAG4E;AAC5E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAChC,kBAAkB,GAAG,IAAI,CAE3B"}
@@ -9,49 +9,97 @@
9
9
  * 1. Which locally-known messages does a staged rewind hide?
10
10
  * 2. When is a message id inside the range a committed rewind must delete?
11
11
  *
12
- * `watermark` exists to fix a real bug: hiding used to be "everything at-or-
13
- * after the boundary id", recomputed on every render off the CURRENT message
14
- * list. A message minted AFTER staging the user's replacement prompt, its
15
- * answer sorts above the boundary by id exactly like every OTHER later
16
- * message, so it fell inside "everything after the boundary" too and never
17
- * rendered until an unrelated remount flooded the whole transcript back,
18
- * interleaved. `watermark` freezes the upper edge of the hide window at the
19
- * newest message id known AT STAGE TIME, so only messages that were already
20
- * part of the abandoned trajectory are ever hidden anything newer always
21
- * renders.
12
+ * The window is a SET of message ids, captured at stage time. It used to be a
13
+ * lexical id RANGE — `id >= messageId && id <= watermark` which assumed ids
14
+ * ascend with time. OpenCode 1.18.15 retired that invariant outright (turn
15
+ * exit now reads `lastAssistant.parentID === lastUser.id`, and
16
+ * `MessageV2.latest()` orders by `time.created` with the id only as a
17
+ * tie-break), and the range failed in both directions:
18
+ *
19
+ * - **under-delete** a reverted assistant message whose id happens to sort
20
+ * BELOW the boundary falls outside the interval, survives the commit,
21
+ * is orphaned, and reappears at the top of the chat;
22
+ * - **over-delete** — `ascendingId` stubs sit ~2.8e13 above every real id, so
23
+ * a single in-flight optimistic message pushed the watermark to
24
+ * effectively infinity and the interval swallowed the user's replacement
25
+ * prompt and its answer.
26
+ *
27
+ * Membership has neither failure. `hiddenIds` is the exact list of messages
28
+ * that were part of the abandoned trajectory at the moment the rewind was
29
+ * staged: nothing minted afterwards can enter it, and nothing inside it can
30
+ * escape on an id comparison. `watermark` is retained as a published field —
31
+ * it names the newest message known at stage time — and still answers
32
+ * {@link isWithinRewindWindow} for a legacy state that carries no `hiddenIds`.
22
33
  */
23
- /** Whether `id` falls inside the [messageId, watermark] hide range — both
24
- * bounds inclusive: the boundary message itself is part of what an edit
25
- * replaces, and the watermark is the last message known at stage time. */
34
+ /** Whether `id` is one of the messages this rewind abandons.
35
+ *
36
+ * Membership in the set captured at stage time never a comparison between
37
+ * two id strings, which say nothing about which message came first. The
38
+ * legacy `[messageId, watermark]` range answers only for a state that
39
+ * carries no captured set. */
26
40
  export function isWithinRewindWindow(id, rewind) {
41
+ if (rewind.hiddenIds)
42
+ return rewind.hiddenIds.includes(id);
27
43
  return id >= rewind.messageId && id <= rewind.watermark;
28
44
  }
29
45
  /**
30
- * The newest (highest sort-order) message id in `messages`, or `null` for an
31
- * empty list. Deliberately a max-scan, not "the last element" most callers
32
- * pass an ascending-sorted list, but an optimistic entry appended out of
33
- * order must never win the max by position alone.
46
+ * The newest message in `messages`, by `time.created` with the id as the only
47
+ * tie-break the same order the server's own `MessageV2.latest()` uses.
48
+ * `null` for an empty list.
49
+ *
50
+ * Deliberately a max-scan, not "the last element": most callers pass an
51
+ * ordered list, but an optimistic entry appended out of order must never win
52
+ * by position alone. A message with no `time` cannot be dated, so it competes
53
+ * on its id only.
34
54
  */
35
55
  export function newestMessageId(messages) {
36
- let max = null;
56
+ let bestId = null;
57
+ let bestCreated;
37
58
  for (const message of messages) {
38
- if (max === null || message.info.id > max)
39
- max = message.info.id;
59
+ const { id } = message.info;
60
+ const created = message.info.time?.created;
61
+ if (bestId === null) {
62
+ bestId = id;
63
+ bestCreated = created;
64
+ continue;
65
+ }
66
+ if (created !== undefined && bestCreated !== undefined) {
67
+ if (created > bestCreated || (created === bestCreated && id > bestId)) {
68
+ bestId = id;
69
+ bestCreated = created;
70
+ }
71
+ continue;
72
+ }
73
+ if (created !== undefined && bestCreated === undefined) {
74
+ bestId = id;
75
+ bestCreated = created;
76
+ continue;
77
+ }
78
+ if (created === undefined && bestCreated === undefined && id > bestId) {
79
+ bestId = id;
80
+ }
40
81
  }
41
- return max;
82
+ return bestId;
42
83
  }
43
84
  /**
44
85
  * Build the state for a freshly staged (or freshly discovered) rewind.
45
- * `watermark` is captured HERE, from the message list at this exact moment —
46
- * never recomputed later. Falls back to `messageId` itself when nothing is
47
- * known locally yet (a cross-tab or reload discovery with no synced messages
48
- * for this session), which hides only the boundary message and nothing
49
- * else the narrowest correct answer with no other information available.
86
+ *
87
+ * The window is captured HERE and never recomputed: `hiddenIds` is the
88
+ * boundary message plus every message that follows it in `messages`, taken in
89
+ * the order the caller holds them which is the server's own
90
+ * `time.created` page order, not an id order. Falls back to `messageId`
91
+ * itself when the boundary is not in the list (a cross-tab or reload
92
+ * discovery with no synced messages for this session), which hides only the
93
+ * boundary message — the narrowest correct answer with no other information
94
+ * available.
50
95
  */
51
96
  export function stageSessionRewind(messages, messageId) {
97
+ const boundary = messages.findIndex((message) => message.info.id === messageId);
98
+ const hiddenIds = boundary === -1 ? [messageId] : messages.slice(boundary).map((message) => message.info.id);
52
99
  return {
53
100
  messageId,
54
101
  watermark: newestMessageId(messages) ?? messageId,
102
+ hiddenIds,
55
103
  staged: true,
56
104
  };
57
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rewind.js","sourceRoot":"","sources":["../../../src/core/session/rewind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuBH;;2EAE2E;AAC3E,MAAM,UAAU,oBAAoB,CAAC,EAAU,EAAE,MAA0B;IACzE,OAAO,EAAE,IAAI,MAAM,CAAC,SAAS,IAAI,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAa;IAEb,IAAI,GAAG,GAAkB,IAAI,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG;YAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAa,EACb,SAAiB;IAEjB,OAAO;QACL,SAAS;QACT,SAAS,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,SAAS;QACjD,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC;AAED;;4EAE4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,QAAa,EACb,MAAiC;IAEjC,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC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Aa,EACb,MAAiC;IAEjC,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1F,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED;;;4EAG4E;AAC5E,MAAM,UAAU,mBAAmB,CACjC,MAAiC;IAEjC,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAChE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type ResolvedPreviewOptions } from '../preview-options.js';
1
2
  /**
2
3
  * Active-runtime resolution, framework-free. These are the read helpers the
3
4
  * isomorphic core (`createKortix`, the opencode client factory) resolves the
@@ -32,18 +33,15 @@ export declare function getActiveDbSandboxId(): string | undefined;
32
33
  */
33
34
  export declare function getBackendPort(): number;
34
35
  /**
35
- * Subdomain URL options for the active runtime (pure-ish function).
36
+ * Preview URL options for the ACTIVE runtime the ambient path, used where no
37
+ * session handle is in scope: `useSandboxProxy`, `proxySandboxUrl`,
38
+ * `buildStaticFilePreviewUrl`, the session panel's app-preview iframe.
36
39
  *
37
- * Always returns a valid options object never undefined. Every provider routes
38
- * through the same backend preview proxy; the `apiBaseUrl` field lets
39
- * `rewriteLocalhostUrl` take the path-based branch on VPS/cloud deployments
40
- * where *.localhost DNS isn't available. The sandbox id comes from the active
41
- * runtime (no legacy 'kortix-sandbox' default — it masked the real cloud sandbox
42
- * and 403'd the preview proxy).
40
+ * A thin binding of the active sandbox id to `resolvePreviewOptions`, which is
41
+ * the single producer of a complete options bag. It deliberately assembles
42
+ * nothing itself: this function once did, and quietly omitted
43
+ * `previewUrlTemplate`, which made every ambient preview fall back to the path
44
+ * proxy. See preview-options.ts.
43
45
  */
44
- export declare function deriveSubdomainOpts(): {
45
- sandboxId: string;
46
- backendPort: number;
47
- apiBaseUrl: string;
48
- };
46
+ export declare function deriveSubdomainOpts(): ResolvedPreviewOptions;
49
47
  //# sourceMappingURL=active.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAMA"}
1
+ {"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAExF;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAOvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,sBAAsB,CAM5D"}
@@ -1,6 +1,7 @@
1
1
  import { platformConfig } from '../../http/config.js';
2
2
  import { getCurrentRuntimeDbSandboxId, getCurrentRuntimeSandboxId, getCurrentRuntimeUrl, } from '../current-runtime.js';
3
3
  import { getBackendUrl, getDefaultSandboxUrl } from './url-helpers.js';
4
+ import { resolvePreviewOptions } from '../preview-options.js';
4
5
  /**
5
6
  * Active-runtime resolution, framework-free. These are the read helpers the
6
7
  * isomorphic core (`createKortix`, the opencode client factory) resolves the
@@ -57,20 +58,21 @@ export function getBackendPort() {
57
58
  }
58
59
  }
59
60
  /**
60
- * Subdomain URL options for the active runtime (pure-ish function).
61
+ * Preview URL options for the ACTIVE runtime the ambient path, used where no
62
+ * session handle is in scope: `useSandboxProxy`, `proxySandboxUrl`,
63
+ * `buildStaticFilePreviewUrl`, the session panel's app-preview iframe.
61
64
  *
62
- * Always returns a valid options object never undefined. Every provider routes
63
- * through the same backend preview proxy; the `apiBaseUrl` field lets
64
- * `rewriteLocalhostUrl` take the path-based branch on VPS/cloud deployments
65
- * where *.localhost DNS isn't available. The sandbox id comes from the active
66
- * runtime (no legacy 'kortix-sandbox' default — it masked the real cloud sandbox
67
- * and 403'd the preview proxy).
65
+ * A thin binding of the active sandbox id to `resolvePreviewOptions`, which is
66
+ * the single producer of a complete options bag. It deliberately assembles
67
+ * nothing itself: this function once did, and quietly omitted
68
+ * `previewUrlTemplate`, which made every ambient preview fall back to the path
69
+ * proxy. See preview-options.ts.
68
70
  */
69
71
  export function deriveSubdomainOpts() {
70
- return {
72
+ return resolvePreviewOptions({
71
73
  sandboxId: getActiveSandboxId() || '',
72
74
  backendPort: getBackendPort(),
73
75
  apiBaseUrl: getBackendUrl(),
74
- };
76
+ });
75
77
  }
76
78
  //# sourceMappingURL=active.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"active.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;A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,CAAC,CAAC,yBAAyB;IACxC,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,qBAAqB,CAAC;QAC3B,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE;QACrC,WAAW,EAAE,cAAc,EAAE;QAC7B,UAAU,EAAE,aAAa,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,15 @@
1
1
  /**
2
- * The backend base URL. All sandbox traffic routes through the backend's
3
- * unified preview proxy: /v1/p/{sandboxId}/{port}/*
2
+ * The backend base URL.
3
+ *
4
+ * CONTROL traffic — the OpenCode/daemon REST channel on port 8000 — routes
5
+ * through the path proxy, `/v1/p/{sandboxId}/{port}/*`, and stays there: it is
6
+ * a programmatic transport with a per-request bearer token, not a browser
7
+ * surface, so a per-preview origin buys it nothing and would put turn delivery
8
+ * behind wildcard DNS, a certificate and an edge Worker.
9
+ *
10
+ * BROWSER traffic goes to the preview ORIGIN this deployment advertises via
11
+ * `GET /v1/p/config` — see core/session/preview-config.ts and `rewriteLocalhostUrl`.
12
+ * Those are the only two forms, and only those two functions choose between them.
4
13
  */
5
14
  export declare function getBackendUrl(): string;
6
15
  export declare function getDefaultSandboxUrl(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"url-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAM7C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E"}
1
+ {"version":3,"file":"url-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAM7C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E"}
@@ -8,8 +8,17 @@ function stripTrailingSlashes(s) {
8
8
  return s.slice(0, end);
9
9
  }
10
10
  /**
11
- * The backend base URL. All sandbox traffic routes through the backend's
12
- * unified preview proxy: /v1/p/{sandboxId}/{port}/*
11
+ * The backend base URL.
12
+ *
13
+ * CONTROL traffic — the OpenCode/daemon REST channel on port 8000 — routes
14
+ * through the path proxy, `/v1/p/{sandboxId}/{port}/*`, and stays there: it is
15
+ * a programmatic transport with a per-request bearer token, not a browser
16
+ * surface, so a per-preview origin buys it nothing and would put turn delivery
17
+ * behind wildcard DNS, a certificate and an edge Worker.
18
+ *
19
+ * BROWSER traffic goes to the preview ORIGIN this deployment advertises via
20
+ * `GET /v1/p/config` — see core/session/preview-config.ts and `rewriteLocalhostUrl`.
21
+ * Those are the only two forms, and only those two functions choose between them.
13
22
  */
14
23
  export function getBackendUrl() {
15
24
  return stripTrailingSlashes(platformConfig().backendUrl || 'http://localhost:8008/v1');
@@ -1 +1 @@
1
- {"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,mEAAmE;AACnE,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,SAAS;QAAE,GAAG,EAAE,CAAC;IAChE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,oBAAoB,CAAC,cAAc,EAAE,CAAC,UAAU,IAAI,0BAA0B,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,4EAA4E;IAC5E,mEAAmE;IACnE,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC,SAAS,CAAC;IAC7C,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAa,EAAE,IAAY;IACnE,OAAO,GAAG,aAAa,EAAE,mBAAmB,KAAK,IAAI,IAAI,EAAE,CAAC;AAC9D,CAAC"}
1
+ {"version":3,"file":"url-helpers.js","sourceRoot":"","sources":["../../../../src/core/session/server-store/url-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,mEAAmE;AACnE,mEAAmE;AACnE,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,SAAS;QAAE,GAAG,EAAE,CAAC;IAChE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,oBAAoB,CAAC,cAAc,EAAE,CAAC,UAAU,IAAI,0BAA0B,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,4EAA4E;IAC5E,mEAAmE;IACnE,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC,SAAS,CAAC;IAC7C,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,GAAG,aAAa,EAAE,MAAM,SAAS,OAAO,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAa,EAAE,IAAY;IACnE,OAAO,GAAG,aAAa,EAAE,mBAAmB,KAAK,IAAI,IAAI,EAAE,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Framing a file from the sandbox's static file server.
3
+ *
4
+ * A host that wants to SHOW an HTML file has exactly one correct move: load it
5
+ * from the server that ships inside the sandbox (port 3211, `/open?path=…`) and
6
+ * frame that URL. The tempting shortcut — hand the file's text to an iframe as
7
+ * `srcDoc` — cannot work, and not for a reason a flag can fix: `srcDoc` gives
8
+ * the document no URL at all, so `./style.css`, `img/logo.png` and `app.js`
9
+ * have no base to resolve against. A page written as a page arrives unstyled.
10
+ *
11
+ * Two rules live here rather than in the hook, because both are decisions and
12
+ * neither needs a network to be reasoned about.
13
+ */
14
+ import { type SubdomainUrlOptions } from './url.js';
15
+ /** Where to frame from, and where to ask whether framing will work yet. */
16
+ export interface StaticFilePreviewTargets {
17
+ /** The proxied `/open?path=…` URL for the file itself. */
18
+ previewUrl: string;
19
+ /** The same service's `/health`, used to wait out a still-booting sandbox. */
20
+ healthUrl: string;
21
+ }
22
+ /**
23
+ * Resolve both URLs for one file, or `null` when there is nothing to address.
24
+ *
25
+ * The `null` is the whole point. `buildStaticFilePreviewUrl` answers with the
26
+ * INTERNAL form — `http://localhost:3211/open?path=…` — when no sandbox is
27
+ * bound, which is honest for a link that will be re-resolved on click and
28
+ * actively wrong for anything that loads or probes it now: that port is on the
29
+ * viewer's own machine. Framing it shows whatever the user happens to be
30
+ * running; probing it can answer `200` and mark a preview "ready" that can
31
+ * never load. A sandbox binds asynchronously, so every caller passes through
32
+ * this state on the way to a working preview — it is the common case, not an
33
+ * edge one.
34
+ */
35
+ export declare function staticFilePreviewTargets(path: string | undefined, options: SubdomainUrlOptions): StaticFilePreviewTargets | null;
36
+ /** Gap between liveness probes, ms. */
37
+ export declare const STATIC_FILE_HEALTH_RETRY_MS = 1500;
38
+ /**
39
+ * How many probes before the wait becomes a reported failure.
40
+ *
41
+ * 20 × 1.5s ≈ 30s. The bound is not a guess about how long a sandbox takes to
42
+ * boot — it is the line past which silence stops being informative. Without it
43
+ * a surface spins "Starting preview server…" for the life of the tab; with it
44
+ * the user gets a sentence and a Retry.
45
+ */
46
+ export declare const STATIC_FILE_HEALTH_MAX_ATTEMPTS = 20;
47
+ /** Whether a caller that has made `attempts` probes should make another. */
48
+ export declare function shouldRetryStaticFileHealth(attempts: number): boolean;
49
+ export declare function authenticatedUrlAddresses(authenticatedUrl: string | null | undefined, previewUrl: string | undefined): boolean;
50
+ //# sourceMappingURL=static-file-preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-file-preview.d.ts","sourceRoot":"","sources":["../../../src/core/session/static-file-preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,OAAO,CAAC;AAEf,2EAA2E;AAC3E,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,mBAAmB,GAC3B,wBAAwB,GAAG,IAAI,CAQjC;AAED,uCAAuC;AACvC,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErE;AAiCD,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAKT"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Framing a file from the sandbox's static file server.
3
+ *
4
+ * A host that wants to SHOW an HTML file has exactly one correct move: load it
5
+ * from the server that ships inside the sandbox (port 3211, `/open?path=…`) and
6
+ * frame that URL. The tempting shortcut — hand the file's text to an iframe as
7
+ * `srcDoc` — cannot work, and not for a reason a flag can fix: `srcDoc` gives
8
+ * the document no URL at all, so `./style.css`, `img/logo.png` and `app.js`
9
+ * have no base to resolve against. A page written as a page arrives unstyled.
10
+ *
11
+ * Two rules live here rather than in the hook, because both are decisions and
12
+ * neither needs a network to be reasoned about.
13
+ */
14
+ import { buildStaticFileHealthPreviewUrl, buildStaticFilePreviewUrl, hasPreviewTarget, } from './url.js';
15
+ /**
16
+ * Resolve both URLs for one file, or `null` when there is nothing to address.
17
+ *
18
+ * The `null` is the whole point. `buildStaticFilePreviewUrl` answers with the
19
+ * INTERNAL form — `http://localhost:3211/open?path=…` — when no sandbox is
20
+ * bound, which is honest for a link that will be re-resolved on click and
21
+ * actively wrong for anything that loads or probes it now: that port is on the
22
+ * viewer's own machine. Framing it shows whatever the user happens to be
23
+ * running; probing it can answer `200` and mark a preview "ready" that can
24
+ * never load. A sandbox binds asynchronously, so every caller passes through
25
+ * this state on the way to a working preview — it is the common case, not an
26
+ * edge one.
27
+ */
28
+ export function staticFilePreviewTargets(path, options) {
29
+ if (!path)
30
+ return null;
31
+ if (!hasPreviewTarget(options))
32
+ return null;
33
+ const previewUrl = buildStaticFilePreviewUrl(path, options);
34
+ if (!previewUrl)
35
+ return null;
36
+ return { previewUrl, healthUrl: buildStaticFileHealthPreviewUrl(options) };
37
+ }
38
+ /** Gap between liveness probes, ms. */
39
+ export const STATIC_FILE_HEALTH_RETRY_MS = 1_500;
40
+ /**
41
+ * How many probes before the wait becomes a reported failure.
42
+ *
43
+ * 20 × 1.5s ≈ 30s. The bound is not a guess about how long a sandbox takes to
44
+ * boot — it is the line past which silence stops being informative. Without it
45
+ * a surface spins "Starting preview server…" for the life of the tab; with it
46
+ * the user gets a sentence and a Retry.
47
+ */
48
+ export const STATIC_FILE_HEALTH_MAX_ATTEMPTS = 20;
49
+ /** Whether a caller that has made `attempts` probes should make another. */
50
+ export function shouldRetryStaticFileHealth(attempts) {
51
+ return attempts < STATIC_FILE_HEALTH_MAX_ATTEMPTS;
52
+ }
53
+ /**
54
+ * Does an authenticated preview URL address the file we are asking for?
55
+ *
56
+ * `useAuthenticatedPreviewUrl` resolves in an effect, so on the render where a
57
+ * viewer switches to a different file it still holds the PREVIOUS file's URL.
58
+ * Framing that shows the page the user just navigated away from.
59
+ *
60
+ * Compare NORMALIZED, never by prefix. The subdomain form authenticates with a
61
+ * one-shot `token` that `appendPreviewToken` adds through `URLSearchParams`,
62
+ * which re-serializes the WHOLE query — and the static file URL is the one
63
+ * preview URL that has a query, so `?path=/workspace/a.html` comes back as
64
+ * `?path=%2Fworkspace%2Fa.html`. No prefix of the original survives that, and a
65
+ * prefix test shipped a preview stuck on "Starting preview server…" forever:
66
+ * the server was up, the URL was authenticated, and the check said it belonged
67
+ * to a different file. A prefix is wrong in the other direction too —
68
+ * `a.html.bak` starts with the URL for `a.html`.
69
+ *
70
+ * Both sides go through the same `URL` round-trip, so both carry the same
71
+ * encoding; `token` is dropped because it is the credential, not the address.
72
+ */
73
+ function normalizeAddress(candidate) {
74
+ try {
75
+ const url = new URL(candidate);
76
+ url.searchParams.delete('token');
77
+ url.searchParams.sort();
78
+ return url.toString();
79
+ }
80
+ catch {
81
+ return null;
82
+ }
83
+ }
84
+ export function authenticatedUrlAddresses(authenticatedUrl, previewUrl) {
85
+ if (!authenticatedUrl || !previewUrl)
86
+ return false;
87
+ const authenticated = normalizeAddress(authenticatedUrl);
88
+ const wanted = normalizeAddress(previewUrl);
89
+ return authenticated !== null && authenticated === wanted;
90
+ }
91
+ //# sourceMappingURL=static-file-preview.js.map