@kortix/sdk 0.9.98

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 (618) hide show
  1. package/README.md +313 -0
  2. package/dist/files/client.d.ts +96 -0
  3. package/dist/files/client.d.ts.map +1 -0
  4. package/dist/files/client.js +346 -0
  5. package/dist/files/client.js.map +1 -0
  6. package/dist/files/types.d.ts +82 -0
  7. package/dist/files/types.d.ts.map +1 -0
  8. package/dist/files/types.js +6 -0
  9. package/dist/files/types.js.map +1 -0
  10. package/dist/index.d.ts +119 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +93 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/kortix.d.ts +897 -0
  15. package/dist/kortix.d.ts.map +1 -0
  16. package/dist/kortix.js +772 -0
  17. package/dist/kortix.js.map +1 -0
  18. package/dist/opencode/client.d.ts +89 -0
  19. package/dist/opencode/client.d.ts.map +1 -0
  20. package/dist/opencode/client.js +191 -0
  21. package/dist/opencode/client.js.map +1 -0
  22. package/dist/opencode/env.d.ts +13 -0
  23. package/dist/opencode/env.d.ts.map +1 -0
  24. package/dist/opencode/env.js +63 -0
  25. package/dist/opencode/env.js.map +1 -0
  26. package/dist/opencode/kortix-master.d.ts +487 -0
  27. package/dist/opencode/kortix-master.d.ts.map +1 -0
  28. package/dist/opencode/kortix-master.js +313 -0
  29. package/dist/opencode/kortix-master.js.map +1 -0
  30. package/dist/opencode/triggers.d.ts +6 -0
  31. package/dist/opencode/triggers.d.ts.map +1 -0
  32. package/dist/opencode/triggers.js +34 -0
  33. package/dist/opencode/triggers.js.map +1 -0
  34. package/dist/platform/api/errors.d.ts +106 -0
  35. package/dist/platform/api/errors.d.ts.map +1 -0
  36. package/dist/platform/api/errors.js +137 -0
  37. package/dist/platform/api/errors.js.map +1 -0
  38. package/dist/platform/api-client.d.ts +35 -0
  39. package/dist/platform/api-client.d.ts.map +1 -0
  40. package/dist/platform/api-client.js +279 -0
  41. package/dist/platform/api-client.js.map +1 -0
  42. package/dist/platform/auth-core.d.ts +60 -0
  43. package/dist/platform/auth-core.d.ts.map +1 -0
  44. package/dist/platform/auth-core.js +104 -0
  45. package/dist/platform/auth-core.js.map +1 -0
  46. package/dist/platform/auth.d.ts +88 -0
  47. package/dist/platform/auth.d.ts.map +1 -0
  48. package/dist/platform/auth.js +161 -0
  49. package/dist/platform/auth.js.map +1 -0
  50. package/dist/platform/config-node.d.ts +33 -0
  51. package/dist/platform/config-node.d.ts.map +1 -0
  52. package/dist/platform/config-node.js +63 -0
  53. package/dist/platform/config-node.js.map +1 -0
  54. package/dist/platform/config.d.ts +77 -0
  55. package/dist/platform/config.d.ts.map +1 -0
  56. package/dist/platform/config.js +62 -0
  57. package/dist/platform/config.js.map +1 -0
  58. package/dist/platform/feature-flags.d.ts +25 -0
  59. package/dist/platform/feature-flags.d.ts.map +1 -0
  60. package/dist/platform/feature-flags.js +114 -0
  61. package/dist/platform/feature-flags.js.map +1 -0
  62. package/dist/platform/fresh-sessions.d.ts +4 -0
  63. package/dist/platform/fresh-sessions.d.ts.map +1 -0
  64. package/dist/platform/fresh-sessions.js +22 -0
  65. package/dist/platform/fresh-sessions.js.map +1 -0
  66. package/dist/platform/instance-routes.d.ts +17 -0
  67. package/dist/platform/instance-routes.d.ts.map +1 -0
  68. package/dist/platform/instance-routes.js +105 -0
  69. package/dist/platform/instance-routes.js.map +1 -0
  70. package/dist/platform/logger.d.ts +20 -0
  71. package/dist/platform/logger.d.ts.map +1 -0
  72. package/dist/platform/logger.js +44 -0
  73. package/dist/platform/logger.js.map +1 -0
  74. package/dist/platform/opencode-errors.d.ts +20 -0
  75. package/dist/platform/opencode-errors.d.ts.map +1 -0
  76. package/dist/platform/opencode-errors.js +71 -0
  77. package/dist/platform/opencode-errors.js.map +1 -0
  78. package/dist/platform/platform-client/backups.d.ts +22 -0
  79. package/dist/platform/platform-client/backups.d.ts.map +1 -0
  80. package/dist/platform/platform-client/backups.js +16 -0
  81. package/dist/platform/platform-client/backups.js.map +1 -0
  82. package/dist/platform/platform-client/index.d.ts +21 -0
  83. package/dist/platform/platform-client/index.d.ts.map +1 -0
  84. package/dist/platform/platform-client/index.js +21 -0
  85. package/dist/platform/platform-client/index.js.map +1 -0
  86. package/dist/platform/platform-client/instance-admin.d.ts +67 -0
  87. package/dist/platform/platform-client/instance-admin.d.ts.map +1 -0
  88. package/dist/platform/platform-client/instance-admin.js +59 -0
  89. package/dist/platform/platform-client/instance-admin.js.map +1 -0
  90. package/dist/platform/platform-client/invites.d.ts +35 -0
  91. package/dist/platform/platform-client/invites.d.ts.map +1 -0
  92. package/dist/platform/platform-client/invites.js +25 -0
  93. package/dist/platform/platform-client/invites.js.map +1 -0
  94. package/dist/platform/platform-client/lifecycle.d.ts +78 -0
  95. package/dist/platform/platform-client/lifecycle.d.ts.map +1 -0
  96. package/dist/platform/platform-client/lifecycle.js +151 -0
  97. package/dist/platform/platform-client/lifecycle.js.map +1 -0
  98. package/dist/platform/platform-client/members.d.ts +81 -0
  99. package/dist/platform/platform-client/members.d.ts.map +1 -0
  100. package/dist/platform/platform-client/members.js +59 -0
  101. package/dist/platform/platform-client/members.js.map +1 -0
  102. package/dist/platform/platform-client/shared.d.ts +44 -0
  103. package/dist/platform/platform-client/shared.d.ts.map +1 -0
  104. package/dist/platform/platform-client/shared.js +177 -0
  105. package/dist/platform/platform-client/shared.js.map +1 -0
  106. package/dist/platform/platform-client/ssh.d.ts +29 -0
  107. package/dist/platform/platform-client/ssh.d.ts.map +1 -0
  108. package/dist/platform/platform-client/ssh.js +14 -0
  109. package/dist/platform/platform-client/ssh.js.map +1 -0
  110. package/dist/platform/platform-client/types.d.ts +56 -0
  111. package/dist/platform/platform-client/types.d.ts.map +1 -0
  112. package/dist/platform/platform-client/types.js +19 -0
  113. package/dist/platform/platform-client/types.js.map +1 -0
  114. package/dist/platform/platform-client/updates.d.ts +117 -0
  115. package/dist/platform/platform-client/updates.d.ts.map +1 -0
  116. package/dist/platform/platform-client/updates.js +97 -0
  117. package/dist/platform/platform-client/updates.js.map +1 -0
  118. package/dist/platform/platform-client/urls.d.ts +18 -0
  119. package/dist/platform/platform-client/urls.d.ts.map +1 -0
  120. package/dist/platform/platform-client/urls.js +31 -0
  121. package/dist/platform/platform-client/urls.js.map +1 -0
  122. package/dist/platform/projects-client/access.d.ts +273 -0
  123. package/dist/platform/projects-client/access.d.ts.map +1 -0
  124. package/dist/platform/projects-client/access.js +89 -0
  125. package/dist/platform/projects-client/access.js.map +1 -0
  126. package/dist/platform/projects-client/accounts.d.ts +184 -0
  127. package/dist/platform/projects-client/accounts.d.ts.map +1 -0
  128. package/dist/platform/projects-client/accounts.js +78 -0
  129. package/dist/platform/projects-client/accounts.js.map +1 -0
  130. package/dist/platform/projects-client/agent-config.d.ts +58 -0
  131. package/dist/platform/projects-client/agent-config.d.ts.map +1 -0
  132. package/dist/platform/projects-client/agent-config.js +9 -0
  133. package/dist/platform/projects-client/agent-config.js.map +1 -0
  134. package/dist/platform/projects-client/agent-scope.d.ts +12 -0
  135. package/dist/platform/projects-client/agent-scope.d.ts.map +1 -0
  136. package/dist/platform/projects-client/agent-scope.js +6 -0
  137. package/dist/platform/projects-client/agent-scope.js.map +1 -0
  138. package/dist/platform/projects-client/apps.d.ts +98 -0
  139. package/dist/platform/projects-client/apps.d.ts.map +1 -0
  140. package/dist/platform/projects-client/apps.js +29 -0
  141. package/dist/platform/projects-client/apps.js.map +1 -0
  142. package/dist/platform/projects-client/audit.d.ts +85 -0
  143. package/dist/platform/projects-client/audit.d.ts.map +1 -0
  144. package/dist/platform/projects-client/audit.js +51 -0
  145. package/dist/platform/projects-client/audit.js.map +1 -0
  146. package/dist/platform/projects-client/billing.d.ts +336 -0
  147. package/dist/platform/projects-client/billing.d.ts.map +1 -0
  148. package/dist/platform/projects-client/billing.js +260 -0
  149. package/dist/platform/projects-client/billing.js.map +1 -0
  150. package/dist/platform/projects-client/change-requests.d.ts +119 -0
  151. package/dist/platform/projects-client/change-requests.d.ts.map +1 -0
  152. package/dist/platform/projects-client/change-requests.js +56 -0
  153. package/dist/platform/projects-client/change-requests.js.map +1 -0
  154. package/dist/platform/projects-client/channels.d.ts +135 -0
  155. package/dist/platform/projects-client/channels.d.ts.map +1 -0
  156. package/dist/platform/projects-client/channels.js +103 -0
  157. package/dist/platform/projects-client/channels.js.map +1 -0
  158. package/dist/platform/projects-client/connectors.d.ts +148 -0
  159. package/dist/platform/projects-client/connectors.d.ts.map +1 -0
  160. package/dist/platform/projects-client/connectors.js +66 -0
  161. package/dist/platform/projects-client/connectors.js.map +1 -0
  162. package/dist/platform/projects-client/files.d.ts +37 -0
  163. package/dist/platform/projects-client/files.d.ts.map +1 -0
  164. package/dist/platform/projects-client/files.js +58 -0
  165. package/dist/platform/projects-client/files.js.map +1 -0
  166. package/dist/platform/projects-client/gateway.d.ts +177 -0
  167. package/dist/platform/projects-client/gateway.d.ts.map +1 -0
  168. package/dist/platform/projects-client/gateway.js +59 -0
  169. package/dist/platform/projects-client/gateway.js.map +1 -0
  170. package/dist/platform/projects-client/git-history.d.ts +74 -0
  171. package/dist/platform/projects-client/git-history.d.ts.map +1 -0
  172. package/dist/platform/projects-client/git-history.js +40 -0
  173. package/dist/platform/projects-client/git-history.js.map +1 -0
  174. package/dist/platform/projects-client/github.d.ts +62 -0
  175. package/dist/platform/projects-client/github.d.ts.map +1 -0
  176. package/dist/platform/projects-client/github.js +30 -0
  177. package/dist/platform/projects-client/github.js.map +1 -0
  178. package/dist/platform/projects-client/index.d.ts +32 -0
  179. package/dist/platform/projects-client/index.d.ts.map +1 -0
  180. package/dist/platform/projects-client/index.js +34 -0
  181. package/dist/platform/projects-client/index.js.map +1 -0
  182. package/dist/platform/projects-client/marketplace-catalog.d.ts +76 -0
  183. package/dist/platform/projects-client/marketplace-catalog.d.ts.map +1 -0
  184. package/dist/platform/projects-client/marketplace-catalog.js +48 -0
  185. package/dist/platform/projects-client/marketplace-catalog.js.map +1 -0
  186. package/dist/platform/projects-client/marketplace.d.ts +80 -0
  187. package/dist/platform/projects-client/marketplace.d.ts.map +1 -0
  188. package/dist/platform/projects-client/marketplace.js +52 -0
  189. package/dist/platform/projects-client/marketplace.js.map +1 -0
  190. package/dist/platform/projects-client/model-defaults.d.ts +36 -0
  191. package/dist/platform/projects-client/model-defaults.d.ts.map +1 -0
  192. package/dist/platform/projects-client/model-defaults.js +16 -0
  193. package/dist/platform/projects-client/model-defaults.js.map +1 -0
  194. package/dist/platform/projects-client/policies.d.ts +21 -0
  195. package/dist/platform/projects-client/policies.d.ts.map +1 -0
  196. package/dist/platform/projects-client/policies.js +10 -0
  197. package/dist/platform/projects-client/policies.js.map +1 -0
  198. package/dist/platform/projects-client/projects.d.ts +235 -0
  199. package/dist/platform/projects-client/projects.d.ts.map +1 -0
  200. package/dist/platform/projects-client/projects.js +161 -0
  201. package/dist/platform/projects-client/projects.js.map +1 -0
  202. package/dist/platform/projects-client/public-session-shares.d.ts +52 -0
  203. package/dist/platform/projects-client/public-session-shares.d.ts.map +1 -0
  204. package/dist/platform/projects-client/public-session-shares.js +54 -0
  205. package/dist/platform/projects-client/public-session-shares.js.map +1 -0
  206. package/dist/platform/projects-client/review.d.ts +57 -0
  207. package/dist/platform/projects-client/review.d.ts.map +1 -0
  208. package/dist/platform/projects-client/review.js +28 -0
  209. package/dist/platform/projects-client/review.js.map +1 -0
  210. package/dist/platform/projects-client/sandbox-shares.d.ts +25 -0
  211. package/dist/platform/projects-client/sandbox-shares.d.ts.map +1 -0
  212. package/dist/platform/projects-client/sandbox-shares.js +29 -0
  213. package/dist/platform/projects-client/sandbox-shares.js.map +1 -0
  214. package/dist/platform/projects-client/sandbox.d.ts +123 -0
  215. package/dist/platform/projects-client/sandbox.d.ts.map +1 -0
  216. package/dist/platform/projects-client/sandbox.js +45 -0
  217. package/dist/platform/projects-client/sandbox.js.map +1 -0
  218. package/dist/platform/projects-client/secrets.d.ts +122 -0
  219. package/dist/platform/projects-client/secrets.d.ts.map +1 -0
  220. package/dist/platform/projects-client/secrets.js +34 -0
  221. package/dist/platform/projects-client/secrets.js.map +1 -0
  222. package/dist/platform/projects-client/session-sandbox.d.ts +61 -0
  223. package/dist/platform/projects-client/session-sandbox.d.ts.map +1 -0
  224. package/dist/platform/projects-client/session-sandbox.js +82 -0
  225. package/dist/platform/projects-client/session-sandbox.js.map +1 -0
  226. package/dist/platform/projects-client/sessions.d.ts +216 -0
  227. package/dist/platform/projects-client/sessions.d.ts.map +1 -0
  228. package/dist/platform/projects-client/sessions.js +74 -0
  229. package/dist/platform/projects-client/sessions.js.map +1 -0
  230. package/dist/platform/projects-client/setup-links.d.ts +35 -0
  231. package/dist/platform/projects-client/setup-links.d.ts.map +1 -0
  232. package/dist/platform/projects-client/setup-links.js +24 -0
  233. package/dist/platform/projects-client/setup-links.js.map +1 -0
  234. package/dist/platform/projects-client/shared.d.ts +66 -0
  235. package/dist/platform/projects-client/shared.d.ts.map +1 -0
  236. package/dist/platform/projects-client/shared.js +44 -0
  237. package/dist/platform/projects-client/shared.js.map +1 -0
  238. package/dist/platform/projects-client/tokens.d.ts +77 -0
  239. package/dist/platform/projects-client/tokens.d.ts.map +1 -0
  240. package/dist/platform/projects-client/tokens.js +43 -0
  241. package/dist/platform/projects-client/tokens.js.map +1 -0
  242. package/dist/platform/projects-client/transcription.d.ts +5 -0
  243. package/dist/platform/projects-client/transcription.d.ts.map +1 -0
  244. package/dist/platform/projects-client/transcription.js +14 -0
  245. package/dist/platform/projects-client/transcription.js.map +1 -0
  246. package/dist/platform/projects-client/triggers.d.ts +102 -0
  247. package/dist/platform/projects-client/triggers.d.ts.map +1 -0
  248. package/dist/platform/projects-client/triggers.js +27 -0
  249. package/dist/platform/projects-client/triggers.js.map +1 -0
  250. package/dist/platform/session-id.d.ts +9 -0
  251. package/dist/platform/session-id.d.ts.map +1 -0
  252. package/dist/platform/session-id.js +23 -0
  253. package/dist/platform/session-id.js.map +1 -0
  254. package/dist/platform/storage/managed-storage.d.ts +97 -0
  255. package/dist/platform/storage/managed-storage.d.ts.map +1 -0
  256. package/dist/platform/storage/managed-storage.js +271 -0
  257. package/dist/platform/storage/managed-storage.js.map +1 -0
  258. package/dist/platform/strings.d.ts +12 -0
  259. package/dist/platform/strings.d.ts.map +1 -0
  260. package/dist/platform/strings.js +17 -0
  261. package/dist/platform/strings.js.map +1 -0
  262. package/dist/platform/ui.d.ts +11 -0
  263. package/dist/platform/ui.d.ts.map +1 -0
  264. package/dist/platform/ui.js +22 -0
  265. package/dist/platform/ui.js.map +1 -0
  266. package/dist/react/chat/index.d.ts +3 -0
  267. package/dist/react/chat/index.d.ts.map +1 -0
  268. package/dist/react/chat/index.js +7 -0
  269. package/dist/react/chat/index.js.map +1 -0
  270. package/dist/react/chat/render-parts.d.ts +39 -0
  271. package/dist/react/chat/render-parts.d.ts.map +1 -0
  272. package/dist/react/chat/render-parts.js +34 -0
  273. package/dist/react/chat/render-parts.js.map +1 -0
  274. package/dist/react/chat/use-chat-turns.d.ts +19 -0
  275. package/dist/react/chat/use-chat-turns.d.ts.map +1 -0
  276. package/dist/react/chat/use-chat-turns.js +27 -0
  277. package/dist/react/chat/use-chat-turns.js.map +1 -0
  278. package/dist/react/file-keys.d.ts +18 -0
  279. package/dist/react/file-keys.d.ts.map +1 -0
  280. package/dist/react/file-keys.js +18 -0
  281. package/dist/react/file-keys.js.map +1 -0
  282. package/dist/react/index.d.ts +12 -0
  283. package/dist/react/index.d.ts.map +1 -0
  284. package/dist/react/index.js +49 -0
  285. package/dist/react/index.js.map +1 -0
  286. package/dist/react/model-flatten.d.ts +33 -0
  287. package/dist/react/model-flatten.d.ts.map +1 -0
  288. package/dist/react/model-flatten.js +59 -0
  289. package/dist/react/model-flatten.js.map +1 -0
  290. package/dist/react/opencode.d.ts +43 -0
  291. package/dist/react/opencode.d.ts.map +1 -0
  292. package/dist/react/opencode.js +100 -0
  293. package/dist/react/opencode.js.map +1 -0
  294. package/dist/react/prefetch-session-start.d.ts +10 -0
  295. package/dist/react/prefetch-session-start.d.ts.map +1 -0
  296. package/dist/react/prefetch-session-start.js +17 -0
  297. package/dist/react/prefetch-session-start.js.map +1 -0
  298. package/dist/react/provider-refresh.d.ts +7 -0
  299. package/dist/react/provider-refresh.d.ts.map +1 -0
  300. package/dist/react/provider-refresh.js +28 -0
  301. package/dist/react/provider-refresh.js.map +1 -0
  302. package/dist/react/provider-selection.d.ts +31 -0
  303. package/dist/react/provider-selection.d.ts.map +1 -0
  304. package/dist/react/provider-selection.js +135 -0
  305. package/dist/react/provider-selection.js.map +1 -0
  306. package/dist/react/route-project.d.ts +7 -0
  307. package/dist/react/route-project.d.ts.map +1 -0
  308. package/dist/react/route-project.js +19 -0
  309. package/dist/react/route-project.js.map +1 -0
  310. package/dist/react/session-start-stash.d.ts +56 -0
  311. package/dist/react/session-start-stash.d.ts.map +1 -0
  312. package/dist/react/session-start-stash.js +202 -0
  313. package/dist/react/session-start-stash.js.map +1 -0
  314. package/dist/react/use-canonical-opencode-session.d.ts +35 -0
  315. package/dist/react/use-canonical-opencode-session.d.ts.map +1 -0
  316. package/dist/react/use-canonical-opencode-session.js +52 -0
  317. package/dist/react/use-canonical-opencode-session.js.map +1 -0
  318. package/dist/react/use-change-requests.d.ts +321 -0
  319. package/dist/react/use-change-requests.d.ts.map +1 -0
  320. package/dist/react/use-change-requests.js +43 -0
  321. package/dist/react/use-change-requests.js.map +1 -0
  322. package/dist/react/use-current-runtime.d.ts +8 -0
  323. package/dist/react/use-current-runtime.d.ts.map +1 -0
  324. package/dist/react/use-current-runtime.js +12 -0
  325. package/dist/react/use-current-runtime.js.map +1 -0
  326. package/dist/react/use-gateway-catalog-sync.d.ts +2 -0
  327. package/dist/react/use-gateway-catalog-sync.d.ts.map +1 -0
  328. package/dist/react/use-gateway-catalog-sync.js +39 -0
  329. package/dist/react/use-gateway-catalog-sync.js.map +1 -0
  330. package/dist/react/use-kortix-master.d.ts +384 -0
  331. package/dist/react/use-kortix-master.d.ts.map +1 -0
  332. package/dist/react/use-kortix-master.js +958 -0
  333. package/dist/react/use-kortix-master.js.map +1 -0
  334. package/dist/react/use-model-store.d.ts +71 -0
  335. package/dist/react/use-model-store.d.ts.map +1 -0
  336. package/dist/react/use-model-store.js +411 -0
  337. package/dist/react/use-model-store.js.map +1 -0
  338. package/dist/react/use-opencode-config.d.ts +15 -0
  339. package/dist/react/use-opencode-config.d.ts.map +1 -0
  340. package/dist/react/use-opencode-config.js +79 -0
  341. package/dist/react/use-opencode-config.js.map +1 -0
  342. package/dist/react/use-opencode-events/diagnostics.d.ts +11 -0
  343. package/dist/react/use-opencode-events/diagnostics.d.ts.map +1 -0
  344. package/dist/react/use-opencode-events/diagnostics.js +58 -0
  345. package/dist/react/use-opencode-events/diagnostics.js.map +1 -0
  346. package/dist/react/use-opencode-events/handle-event.d.ts +20 -0
  347. package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -0
  348. package/dist/react/use-opencode-events/handle-event.js +450 -0
  349. package/dist/react/use-opencode-events/handle-event.js.map +1 -0
  350. package/dist/react/use-opencode-events/helpers.d.ts +30 -0
  351. package/dist/react/use-opencode-events/helpers.d.ts.map +1 -0
  352. package/dist/react/use-opencode-events/helpers.js +93 -0
  353. package/dist/react/use-opencode-events/helpers.js.map +1 -0
  354. package/dist/react/use-opencode-events/index.d.ts +25 -0
  355. package/dist/react/use-opencode-events/index.d.ts.map +1 -0
  356. package/dist/react/use-opencode-events/index.js +242 -0
  357. package/dist/react/use-opencode-events/index.js.map +1 -0
  358. package/dist/react/use-opencode-events/types.d.ts +10 -0
  359. package/dist/react/use-opencode-events/types.d.ts.map +1 -0
  360. package/dist/react/use-opencode-events/types.js +2 -0
  361. package/dist/react/use-opencode-events/types.js.map +1 -0
  362. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +22 -0
  363. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -0
  364. package/dist/react/use-opencode-events/use-event-stream-refs.js +158 -0
  365. package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -0
  366. package/dist/react/use-opencode-local.d.ts +139 -0
  367. package/dist/react/use-opencode-local.d.ts.map +1 -0
  368. package/dist/react/use-opencode-local.js +484 -0
  369. package/dist/react/use-opencode-local.js.map +1 -0
  370. package/dist/react/use-opencode-mcp.d.ts +34 -0
  371. package/dist/react/use-opencode-mcp.d.ts.map +1 -0
  372. package/dist/react/use-opencode-mcp.js +190 -0
  373. package/dist/react/use-opencode-mcp.js.map +1 -0
  374. package/dist/react/use-opencode-pty.d.ts +30 -0
  375. package/dist/react/use-opencode-pty.d.ts.map +1 -0
  376. package/dist/react/use-opencode-pty.js +126 -0
  377. package/dist/react/use-opencode-pty.js.map +1 -0
  378. package/dist/react/use-opencode-sessions/agents.d.ts +14 -0
  379. package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -0
  380. package/dist/react/use-opencode-sessions/agents.js +82 -0
  381. package/dist/react/use-opencode-sessions/agents.js.map +1 -0
  382. package/dist/react/use-opencode-sessions/commands.d.ts +8 -0
  383. package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -0
  384. package/dist/react/use-opencode-sessions/commands.js +46 -0
  385. package/dist/react/use-opencode-sessions/commands.js.map +1 -0
  386. package/dist/react/use-opencode-sessions/files.d.ts +2 -0
  387. package/dist/react/use-opencode-sessions/files.d.ts.map +1 -0
  388. package/dist/react/use-opencode-sessions/files.js +181 -0
  389. package/dist/react/use-opencode-sessions/files.js.map +1 -0
  390. package/dist/react/use-opencode-sessions/index.d.ts +15 -0
  391. package/dist/react/use-opencode-sessions/index.d.ts.map +1 -0
  392. package/dist/react/use-opencode-sessions/index.js +21 -0
  393. package/dist/react/use-opencode-sessions/index.js.map +1 -0
  394. package/dist/react/use-opencode-sessions/keys.d.ts +94 -0
  395. package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -0
  396. package/dist/react/use-opencode-sessions/keys.js +39 -0
  397. package/dist/react/use-opencode-sessions/keys.js.map +1 -0
  398. package/dist/react/use-opencode-sessions/mcp.d.ts +3 -0
  399. package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -0
  400. package/dist/react/use-opencode-sessions/mcp.js +23 -0
  401. package/dist/react/use-opencode-sessions/mcp.js.map +1 -0
  402. package/dist/react/use-opencode-sessions/messages.d.ts +75 -0
  403. package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -0
  404. package/dist/react/use-opencode-sessions/messages.js +319 -0
  405. package/dist/react/use-opencode-sessions/messages.js.map +1 -0
  406. package/dist/react/use-opencode-sessions/parts.d.ts +23 -0
  407. package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -0
  408. package/dist/react/use-opencode-sessions/parts.js +49 -0
  409. package/dist/react/use-opencode-sessions/parts.js.map +1 -0
  410. package/dist/react/use-opencode-sessions/permissions.d.ts +17 -0
  411. package/dist/react/use-opencode-sessions/permissions.d.ts.map +1 -0
  412. package/dist/react/use-opencode-sessions/permissions.js +66 -0
  413. package/dist/react/use-opencode-sessions/permissions.js.map +1 -0
  414. package/dist/react/use-opencode-sessions/projects.d.ts +5 -0
  415. package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -0
  416. package/dist/react/use-opencode-sessions/projects.js +54 -0
  417. package/dist/react/use-opencode-sessions/projects.js.map +1 -0
  418. package/dist/react/use-opencode-sessions/providers.d.ts +10 -0
  419. package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -0
  420. package/dist/react/use-opencode-sessions/providers.js +98 -0
  421. package/dist/react/use-opencode-sessions/providers.js.map +1 -0
  422. package/dist/react/use-opencode-sessions/sessions.d.ts +35 -0
  423. package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -0
  424. package/dist/react/use-opencode-sessions/sessions.js +380 -0
  425. package/dist/react/use-opencode-sessions/sessions.js.map +1 -0
  426. package/dist/react/use-opencode-sessions/shared.d.ts +43 -0
  427. package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -0
  428. package/dist/react/use-opencode-sessions/shared.js +109 -0
  429. package/dist/react/use-opencode-sessions/shared.js.map +1 -0
  430. package/dist/react/use-opencode-sessions/sharing.d.ts +4 -0
  431. package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -0
  432. package/dist/react/use-opencode-sessions/sharing.js +57 -0
  433. package/dist/react/use-opencode-sessions/sharing.js.map +1 -0
  434. package/dist/react/use-opencode-sessions/tools.d.ts +5 -0
  435. package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -0
  436. package/dist/react/use-opencode-sessions/tools.js +54 -0
  437. package/dist/react/use-opencode-sessions/tools.js.map +1 -0
  438. package/dist/react/use-permission-self-heal.d.ts +45 -0
  439. package/dist/react/use-permission-self-heal.d.ts.map +1 -0
  440. package/dist/react/use-permission-self-heal.js +144 -0
  441. package/dist/react/use-permission-self-heal.js.map +1 -0
  442. package/dist/react/use-project-config.d.ts +11 -0
  443. package/dist/react/use-project-config.d.ts.map +1 -0
  444. package/dist/react/use-project-config.js +22 -0
  445. package/dist/react/use-project-config.js.map +1 -0
  446. package/dist/react/use-project-models.d.ts +11 -0
  447. package/dist/react/use-project-models.d.ts.map +1 -0
  448. package/dist/react/use-project-models.js +25 -0
  449. package/dist/react/use-project-models.js.map +1 -0
  450. package/dist/react/use-project-secrets.d.ts +265 -0
  451. package/dist/react/use-project-secrets.d.ts.map +1 -0
  452. package/dist/react/use-project-secrets.js +41 -0
  453. package/dist/react/use-project-secrets.js.map +1 -0
  454. package/dist/react/use-project-triggers.d.ts +228 -0
  455. package/dist/react/use-project-triggers.d.ts.map +1 -0
  456. package/dist/react/use-project-triggers.js +42 -0
  457. package/dist/react/use-project-triggers.js.map +1 -0
  458. package/dist/react/use-question-self-heal.d.ts +36 -0
  459. package/dist/react/use-question-self-heal.d.ts.map +1 -0
  460. package/dist/react/use-question-self-heal.js +95 -0
  461. package/dist/react/use-question-self-heal.js.map +1 -0
  462. package/dist/react/use-runtime-phase.d.ts +9 -0
  463. package/dist/react/use-runtime-phase.d.ts.map +1 -0
  464. package/dist/react/use-runtime-phase.js +20 -0
  465. package/dist/react/use-runtime-phase.js.map +1 -0
  466. package/dist/react/use-runtime-reconnect.d.ts +90 -0
  467. package/dist/react/use-runtime-reconnect.d.ts.map +1 -0
  468. package/dist/react/use-runtime-reconnect.js +234 -0
  469. package/dist/react/use-runtime-reconnect.js.map +1 -0
  470. package/dist/react/use-session-picks.d.ts +17 -0
  471. package/dist/react/use-session-picks.d.ts.map +1 -0
  472. package/dist/react/use-session-picks.js +36 -0
  473. package/dist/react/use-session-picks.js.map +1 -0
  474. package/dist/react/use-session-prefetch.d.ts +18 -0
  475. package/dist/react/use-session-prefetch.d.ts.map +1 -0
  476. package/dist/react/use-session-prefetch.js +84 -0
  477. package/dist/react/use-session-prefetch.js.map +1 -0
  478. package/dist/react/use-session-send.d.ts +183 -0
  479. package/dist/react/use-session-send.d.ts.map +1 -0
  480. package/dist/react/use-session-send.js +287 -0
  481. package/dist/react/use-session-send.js.map +1 -0
  482. package/dist/react/use-session-sync.d.ts +24 -0
  483. package/dist/react/use-session-sync.d.ts.map +1 -0
  484. package/dist/react/use-session-sync.js +375 -0
  485. package/dist/react/use-session-sync.js.map +1 -0
  486. package/dist/react/use-session.d.ts +171 -0
  487. package/dist/react/use-session.d.ts.map +1 -0
  488. package/dist/react/use-session.js +396 -0
  489. package/dist/react/use-session.js.map +1 -0
  490. package/dist/react/use-visible-agents.d.ts +22 -0
  491. package/dist/react/use-visible-agents.d.ts.map +1 -0
  492. package/dist/react/use-visible-agents.js +45 -0
  493. package/dist/react/use-visible-agents.js.map +1 -0
  494. package/dist/server.d.ts +55 -0
  495. package/dist/server.d.ts.map +1 -0
  496. package/dist/server.js +122 -0
  497. package/dist/server.js.map +1 -0
  498. package/dist/session/health.d.ts +49 -0
  499. package/dist/session/health.d.ts.map +1 -0
  500. package/dist/session/health.js +57 -0
  501. package/dist/session/health.js.map +1 -0
  502. package/dist/session/index.d.ts +19 -0
  503. package/dist/session/index.d.ts.map +1 -0
  504. package/dist/session/index.js +19 -0
  505. package/dist/session/index.js.map +1 -0
  506. package/dist/session/preview.d.ts +24 -0
  507. package/dist/session/preview.d.ts.map +1 -0
  508. package/dist/session/preview.js +85 -0
  509. package/dist/session/preview.js.map +1 -0
  510. package/dist/session/url.d.ts +160 -0
  511. package/dist/session/url.d.ts.map +1 -0
  512. package/dist/session/url.js +522 -0
  513. package/dist/session/url.js.map +1 -0
  514. package/dist/state/chat-events.d.ts +141 -0
  515. package/dist/state/chat-events.d.ts.map +1 -0
  516. package/dist/state/chat-events.js +135 -0
  517. package/dist/state/chat-events.js.map +1 -0
  518. package/dist/state/current-runtime.d.ts +44 -0
  519. package/dist/state/current-runtime.d.ts.map +1 -0
  520. package/dist/state/current-runtime.js +44 -0
  521. package/dist/state/current-runtime.js.map +1 -0
  522. package/dist/state/diagnostics-store.d.ts +114 -0
  523. package/dist/state/diagnostics-store.d.ts.map +1 -0
  524. package/dist/state/diagnostics-store.js +319 -0
  525. package/dist/state/diagnostics-store.js.map +1 -0
  526. package/dist/state/event-stream.d.ts +134 -0
  527. package/dist/state/event-stream.d.ts.map +1 -0
  528. package/dist/state/event-stream.js +424 -0
  529. package/dist/state/event-stream.js.map +1 -0
  530. package/dist/state/idb-sync-cache.d.ts +18 -0
  531. package/dist/state/idb-sync-cache.d.ts.map +1 -0
  532. package/dist/state/idb-sync-cache.js +209 -0
  533. package/dist/state/idb-sync-cache.js.map +1 -0
  534. package/dist/state/opencode-compaction-store.d.ts +10 -0
  535. package/dist/state/opencode-compaction-store.d.ts.map +1 -0
  536. package/dist/state/opencode-compaction-store.js +32 -0
  537. package/dist/state/opencode-compaction-store.js.map +1 -0
  538. package/dist/state/opencode-pending-store.d.ts +19 -0
  539. package/dist/state/opencode-pending-store.d.ts.map +1 -0
  540. package/dist/state/opencode-pending-store.js +76 -0
  541. package/dist/state/opencode-pending-store.js.map +1 -0
  542. package/dist/state/sandbox-connection-store.d.ts +62 -0
  543. package/dist/state/sandbox-connection-store.d.ts.map +1 -0
  544. package/dist/state/sandbox-connection-store.js +290 -0
  545. package/dist/state/sandbox-connection-store.js.map +1 -0
  546. package/dist/state/server-store/active.d.ts +49 -0
  547. package/dist/state/server-store/active.d.ts.map +1 -0
  548. package/dist/state/server-store/active.js +76 -0
  549. package/dist/state/server-store/active.js.map +1 -0
  550. package/dist/state/server-store/types.d.ts +12 -0
  551. package/dist/state/server-store/types.d.ts.map +1 -0
  552. package/dist/state/server-store/types.js +2 -0
  553. package/dist/state/server-store/types.js.map +1 -0
  554. package/dist/state/server-store/url-helpers.d.ts +33 -0
  555. package/dist/state/server-store/url-helpers.d.ts.map +1 -0
  556. package/dist/state/server-store/url-helpers.js +55 -0
  557. package/dist/state/server-store/url-helpers.js.map +1 -0
  558. package/dist/state/server-store.d.ts +18 -0
  559. package/dist/state/server-store.d.ts.map +1 -0
  560. package/dist/state/server-store.js +23 -0
  561. package/dist/state/server-store.js.map +1 -0
  562. package/dist/state/session-runtime-registry.d.ts +49 -0
  563. package/dist/state/session-runtime-registry.d.ts.map +1 -0
  564. package/dist/state/session-runtime-registry.js +85 -0
  565. package/dist/state/session-runtime-registry.js.map +1 -0
  566. package/dist/state/sync-store/ascending-id.d.ts +2 -0
  567. package/dist/state/sync-store/ascending-id.d.ts.map +1 -0
  568. package/dist/state/sync-store/ascending-id.js +21 -0
  569. package/dist/state/sync-store/ascending-id.js.map +1 -0
  570. package/dist/state/sync-store/binary.d.ts +7 -0
  571. package/dist/state/sync-store/binary.d.ts.map +1 -0
  572. package/dist/state/sync-store/binary.js +21 -0
  573. package/dist/state/sync-store/binary.js.map +1 -0
  574. package/dist/state/sync-store/stream-cache.d.ts +2 -0
  575. package/dist/state/sync-store/stream-cache.d.ts.map +1 -0
  576. package/dist/state/sync-store/stream-cache.js +29 -0
  577. package/dist/state/sync-store/stream-cache.js.map +1 -0
  578. package/dist/state/sync-store/types.d.ts +29 -0
  579. package/dist/state/sync-store/types.d.ts.map +1 -0
  580. package/dist/state/sync-store/types.js +2 -0
  581. package/dist/state/sync-store/types.js.map +1 -0
  582. package/dist/state/sync-store.d.ts +39 -0
  583. package/dist/state/sync-store.d.ts.map +1 -0
  584. package/dist/state/sync-store.js +692 -0
  585. package/dist/state/sync-store.js.map +1 -0
  586. package/dist/state/tab-store.d.ts +91 -0
  587. package/dist/state/tab-store.d.ts.map +1 -0
  588. package/dist/state/tab-store.js +369 -0
  589. package/dist/state/tab-store.js.map +1 -0
  590. package/dist/transcript.d.ts +40 -0
  591. package/dist/transcript.d.ts.map +1 -0
  592. package/dist/transcript.js +126 -0
  593. package/dist/transcript.js.map +1 -0
  594. package/dist/turns/classify.d.ts +166 -0
  595. package/dist/turns/classify.d.ts.map +1 -0
  596. package/dist/turns/classify.js +259 -0
  597. package/dist/turns/classify.js.map +1 -0
  598. package/dist/turns/errors.d.ts +11 -0
  599. package/dist/turns/errors.d.ts.map +1 -0
  600. package/dist/turns/errors.js +85 -0
  601. package/dist/turns/errors.js.map +1 -0
  602. package/dist/turns/index.d.ts +264 -0
  603. package/dist/turns/index.d.ts.map +1 -0
  604. package/dist/turns/index.js +1243 -0
  605. package/dist/turns/index.js.map +1 -0
  606. package/dist/turns/tool-registry.d.ts +33 -0
  607. package/dist/turns/tool-registry.d.ts.map +1 -0
  608. package/dist/turns/tool-registry.js +108 -0
  609. package/dist/turns/tool-registry.js.map +1 -0
  610. package/dist/turns/types.d.ts +125 -0
  611. package/dist/turns/types.d.ts.map +1 -0
  612. package/dist/turns/types.js +12 -0
  613. package/dist/turns/types.js.map +1 -0
  614. package/dist/turns/view-model.d.ts +127 -0
  615. package/dist/turns/view-model.d.ts.map +1 -0
  616. package/dist/turns/view-model.js +401 -0
  617. package/dist/turns/view-model.js.map +1 -0
  618. package/package.json +155 -0
package/dist/server.js ADDED
@@ -0,0 +1,122 @@
1
+ /**
2
+ * `@kortix/sdk/server` — Node/Bun-only request-scoped config isolation for
3
+ * "Kortix as a Backend": a third-party server process that wraps Kortix on
4
+ * behalf of multiple end users/tenants concurrently.
5
+ *
6
+ * NEVER import this subpath from a browser bundle. It statically imports
7
+ * `config-node.ts`, which statically imports `node:async_hooks` — most
8
+ * browser bundlers choke if that appears anywhere in their graph. The root
9
+ * `@kortix/sdk` entry point and `@kortix/sdk/react` never import this file,
10
+ * so a web host's bundle is unaffected either way; this subpath exists
11
+ * specifically for the non-browser "backend" case.
12
+ *
13
+ * Why this exists: `configureKortix()`/`createKortix()` (the root `@kortix/sdk`
14
+ * seam) store the platform config — crucially, the bearer token getter — in a
15
+ * single process-wide module-global (see `platform/config.ts`). That's fine
16
+ * for a host with exactly one config for its whole lifetime (a browser tab, a
17
+ * CLI, a single-tenant server). It is UNSAFE for a server process handling
18
+ * concurrent requests on behalf of different users: two in-flight requests
19
+ * racing through `configureKortix()` with different tokens clobber each
20
+ * other — whichever call landed last wins for every other in-flight request
21
+ * (see the warning on `ServerTokenOptions` in
22
+ * `platform/projects-client/shared.ts`).
23
+ *
24
+ * `runWithKortix`/`createScopedKortix` fix that using Node's
25
+ * `AsyncLocalStorage`: the config passed to one call is visible ONLY inside
26
+ * that call's async continuation (every `await` inside it), correctly
27
+ * isolated from any other concurrent call in the same process.
28
+ */
29
+ import { createKortix } from './kortix.js';
30
+ import { runScoped, runWithKortix, getScopedConfig } from './platform/config-node.js';
31
+ export { runWithKortix, getScopedConfig };
32
+ const MAX_WRAP_DEPTH = 12;
33
+ function isPlainObject(value) {
34
+ if (value === null || typeof value !== 'object')
35
+ return false;
36
+ const proto = Object.getPrototypeOf(value);
37
+ return proto === Object.prototype || proto === null;
38
+ }
39
+ /**
40
+ * Recursively wrap every function (including function-valued getters)
41
+ * reachable from `value` so calling it runs inside `runScoped(config, ...)`.
42
+ * Also wraps a wrapped function's OWN return value (sync, or the resolved
43
+ * value of a returned Promise) — this is what makes id-bound handles minted
44
+ * AT CALL TIME (`kortix.project(id)`, `kortix.session(pid, sid)`) come back
45
+ * fully scoped too, not just the static shape of `createKortix()`'s top-level
46
+ * return.
47
+ *
48
+ * Recurses into plain objects/arrays only — class instances and built-ins
49
+ * (`Error`/`Date`/`Map`/`Set`/`Blob`/`Response`/async iterables/…) pass
50
+ * through untouched, so this never mis-clones a vendor object whose
51
+ * correctness depends on its prototype/internal slots (e.g. the escape-hatch
52
+ * `OpencodeClient` from `.runtime`, or a `Response`/Blob returned by a file
53
+ * read). A depth cap + a per-branch `WeakSet` guards against accidental
54
+ * cycles or pathologically deep payloads.
55
+ */
56
+ function wrapScoped(value, config, seen, depth = 0) {
57
+ if (depth > MAX_WRAP_DEPTH)
58
+ return value;
59
+ if (typeof value === 'function') {
60
+ const fn = value;
61
+ const wrapped = (...args) => {
62
+ const result = runScoped(config, () => fn(...args));
63
+ if (result instanceof Promise) {
64
+ return result.then((resolved) => wrapScoped(resolved, config, new WeakSet(), 0));
65
+ }
66
+ return wrapScoped(result, config, new WeakSet(), 0);
67
+ };
68
+ return wrapped;
69
+ }
70
+ if (Array.isArray(value)) {
71
+ if (seen.has(value))
72
+ return value;
73
+ seen.add(value);
74
+ return value.map((item) => wrapScoped(item, config, seen, depth + 1));
75
+ }
76
+ if (isPlainObject(value)) {
77
+ if (seen.has(value))
78
+ return value;
79
+ seen.add(value);
80
+ const out = {};
81
+ for (const key of Object.keys(value)) {
82
+ const desc = Object.getOwnPropertyDescriptor(value, key);
83
+ if (desc.get) {
84
+ Object.defineProperty(out, key, {
85
+ enumerable: true,
86
+ get: () => wrapScoped(desc.get.call(value), config, new WeakSet(), 0),
87
+ });
88
+ }
89
+ else {
90
+ out[key] = wrapScoped(desc.value, config, seen, depth + 1);
91
+ }
92
+ }
93
+ return out;
94
+ }
95
+ return value;
96
+ }
97
+ /**
98
+ * Same shape as `createKortix(config)`, but every method call — including
99
+ * calls reached through `.project(id)`/`.session(pid, sid)` handles minted at
100
+ * call time — automatically runs inside `runWithKortix(config, ...)`. This
101
+ * handle never writes to (or is affected by) the process-global config
102
+ * singleton other `createKortix()`/`configureKortix()` callers in the same
103
+ * process share. Safe to construct one per incoming request in a multi-tenant
104
+ * server:
105
+ *
106
+ * import { createScopedKortix } from '@kortix/sdk/server';
107
+ *
108
+ * app.get('/projects', async (req, res) => {
109
+ * const kortix = createScopedKortix({ backendUrl, getToken: () => tokenFor(req) });
110
+ * res.json(await kortix.projects.list());
111
+ * });
112
+ *
113
+ * Two concurrent requests each calling `createScopedKortix` with a different
114
+ * token never see each other's config, even though both run in the same
115
+ * process — unlike two concurrent `createKortix()` calls, which share (and
116
+ * race on) the global singleton.
117
+ */
118
+ export function createScopedKortix(config) {
119
+ const inner = createKortix(config, { global: false });
120
+ return wrapScoped(inner, config, new WeakSet());
121
+ }
122
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,YAAY,EAAe,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGnF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAE1C,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,UAAU,CAAI,KAAQ,EAAE,MAA4B,EAAE,IAAqB,EAAE,KAAK,GAAG,CAAC;IAC7F,IAAI,KAAK,GAAG,cAAc;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,KAAwC,CAAC;QACpD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAe,EAAW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AAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE;oBAC9B,UAAU,EAAE,IAAI;oBAChB,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;iBACvE,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,OAAO,GAAQ,CAAC;IAClB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA4B;IAC7D,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACtD,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Session runtime health — `GET /kortix/health` on the session's runtime.
3
+ *
4
+ * The host asks a session whether its runtime is ready; it never reasons about
5
+ * "the sandbox" directly. This is the liveness probe used to gate "runtime
6
+ * active" vs "OpenCode ready". The runtime-ready parsing rule lives here so
7
+ * every consumer interprets a payload identically. It never throws on a non-ok
8
+ * HTTP status — it surfaces `status`/`ok` so the caller applies its own failure
9
+ * thresholds.
10
+ *
11
+ * NOTE: the legacy `GET /kortix/ports` endpoint is intentionally NOT wrapped —
12
+ * the current agent server (rewritten 2026-05) serves no such route; port
13
+ * mappings come from the platform API, and live port access is the
14
+ * `/proxy/:port/*` reverse proxy (see `./url`).
15
+ */
16
+ export type SessionHealthResponse = {
17
+ status?: string;
18
+ runtimeReady?: boolean;
19
+ version?: string;
20
+ opencode?: string | boolean;
21
+ boot_error?: string | null;
22
+ reason?: string | null;
23
+ message?: string | null;
24
+ };
25
+ export interface SessionHealthResult {
26
+ /** HTTP status of the probe (0 when there is no active runtime URL). */
27
+ status: number;
28
+ ok: boolean;
29
+ /** Parsed health body, or null when the response wasn't JSON. */
30
+ health: SessionHealthResponse | null;
31
+ /** Raw response text — useful for non-ok diagnostics. */
32
+ body: string;
33
+ }
34
+ /** Whether a health payload indicates the OpenCode runtime is ready. */
35
+ export declare function isRuntimeReady(health: SessionHealthResponse | null): boolean;
36
+ /**
37
+ * `GET /kortix/health` — returns the HTTP status plus the parsed body. Never
38
+ * throws on a non-ok status; callers decide what a given status means.
39
+ *
40
+ * `runtimeUrl` OMITTED (`undefined`) falls back to the module-global "active"
41
+ * runtime, for callers that don't scope to a specific session. Passing `null`
42
+ * or `''` EXPLICITLY means "this session has no resolved runtime yet" and
43
+ * short-circuits to the graceful `{ status: 0, ok: false }` shape WITHOUT
44
+ * falling back to the active runtime — a per-session handle (e.g.
45
+ * `kortix.session(pid, sid).health()`) must never silently probe whichever
46
+ * DIFFERENT session's sandbox happens to be globally active.
47
+ */
48
+ export declare function getSessionHealth(runtimeUrl?: string | null, init?: RequestInit): Promise<SessionHealthResult>;
49
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/session/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;IACZ,iEAAiE;IACjE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,OAAO,CAU5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAC1B,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAgB9B"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Session runtime health — `GET /kortix/health` on the session's runtime.
3
+ *
4
+ * The host asks a session whether its runtime is ready; it never reasons about
5
+ * "the sandbox" directly. This is the liveness probe used to gate "runtime
6
+ * active" vs "OpenCode ready". The runtime-ready parsing rule lives here so
7
+ * every consumer interprets a payload identically. It never throws on a non-ok
8
+ * HTTP status — it surfaces `status`/`ok` so the caller applies its own failure
9
+ * thresholds.
10
+ *
11
+ * NOTE: the legacy `GET /kortix/ports` endpoint is intentionally NOT wrapped —
12
+ * the current agent server (rewritten 2026-05) serves no such route; port
13
+ * mappings come from the platform API, and live port access is the
14
+ * `/proxy/:port/*` reverse proxy (see `./url`).
15
+ */
16
+ import { authenticatedFetch } from '../platform/auth.js';
17
+ import { getActiveOpenCodeUrl } from '../state/server-store/active.js';
18
+ /** Whether a health payload indicates the OpenCode runtime is ready. */
19
+ export function isRuntimeReady(health) {
20
+ if (!health)
21
+ return false;
22
+ if (health.runtimeReady !== undefined)
23
+ return health.runtimeReady === true;
24
+ if (health.opencode !== undefined)
25
+ return health.opencode === 'ok' || health.opencode === true;
26
+ return (health.status !== 'starting' &&
27
+ health.status !== 'down' &&
28
+ health.status !== 'error');
29
+ }
30
+ /**
31
+ * `GET /kortix/health` — returns the HTTP status plus the parsed body. Never
32
+ * throws on a non-ok status; callers decide what a given status means.
33
+ *
34
+ * `runtimeUrl` OMITTED (`undefined`) falls back to the module-global "active"
35
+ * runtime, for callers that don't scope to a specific session. Passing `null`
36
+ * or `''` EXPLICITLY means "this session has no resolved runtime yet" and
37
+ * short-circuits to the graceful `{ status: 0, ok: false }` shape WITHOUT
38
+ * falling back to the active runtime — a per-session handle (e.g.
39
+ * `kortix.session(pid, sid).health()`) must never silently probe whichever
40
+ * DIFFERENT session's sandbox happens to be globally active.
41
+ */
42
+ export async function getSessionHealth(runtimeUrl, init) {
43
+ const url = (runtimeUrl === undefined ? getActiveOpenCodeUrl() : runtimeUrl) || null;
44
+ if (!url)
45
+ return { status: 0, ok: false, health: null, body: '' };
46
+ const res = await authenticatedFetch(`${url}/kortix/health`, { method: 'GET', ...init }, { retryOnAuthError: false });
47
+ const body = await res.text().catch(() => '');
48
+ let health = null;
49
+ try {
50
+ health = body ? JSON.parse(body) : null;
51
+ }
52
+ catch {
53
+ health = null;
54
+ }
55
+ return { status: res.status, ok: res.ok, health, body };
56
+ }
57
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/session/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAsBpE,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,MAAoC;IACjE,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC;IAC3E,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;QA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D,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@kortix/sdk/session` — a session's runtime surface.
3
+ *
4
+ * The host thinks in sessions, never in sandboxes: a session owns its runtime,
5
+ * so health + preview/proxy URLs hang off the session. Most hosts reach these
6
+ * through the `createKortix(...).session(pid, sid)` handle (`.health()`,
7
+ * `.previewUrl()`, `.proxyUrl()`); these named exports exist for stateless use
8
+ * (e.g. detecting/parsing localhost URLs in agent output during rendering).
9
+ *
10
+ * Verified against the current agent server (rewritten 2026-05): proxy/preview/
11
+ * web-proxy URL building (`/proxy/:port`, `/web-proxy`, path + subdomain forms),
12
+ * the `/kortix/health` liveness probe, and the preview-proxy auth helpers. Dead
13
+ * legacy endpoints (`/kortix/ports`, `/env` CRUD, `/kortix/services`, the board)
14
+ * are excluded.
15
+ */
16
+ export * from './url.js';
17
+ export * from './health.js';
18
+ export * from './preview.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@kortix/sdk/session` — a session's runtime surface.
3
+ *
4
+ * The host thinks in sessions, never in sandboxes: a session owns its runtime,
5
+ * so health + preview/proxy URLs hang off the session. Most hosts reach these
6
+ * through the `createKortix(...).session(pid, sid)` handle (`.health()`,
7
+ * `.previewUrl()`, `.proxyUrl()`); these named exports exist for stateless use
8
+ * (e.g. detecting/parsing localhost URLs in agent output during rendering).
9
+ *
10
+ * Verified against the current agent server (rewritten 2026-05): proxy/preview/
11
+ * web-proxy URL building (`/proxy/:port`, `/web-proxy`, path + subdomain forms),
12
+ * the `/kortix/health` liveness probe, and the preview-proxy auth helpers. Dead
13
+ * legacy endpoints (`/kortix/ports`, `/env` CRUD, `/kortix/services`, the board)
14
+ * are excluded.
15
+ */
16
+ export * from './url.js';
17
+ export * from './health.js';
18
+ export * from './preview.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Preview-proxy auth helpers (pure).
3
+ *
4
+ * A host hook drives the cookie/token exchange against the preview proxy; these
5
+ * helpers decide the auth endpoint and the token-append rule so the proxy auth
6
+ * scheme lives in exactly one place. They target the current proxy surface:
7
+ * path-based `/v1/p/{sandbox}/{port}/…`, the daemon `/proxy/{port}/…`, and the
8
+ * subdomain `p{port}-{sandbox}.{host}/…` form.
9
+ */
10
+ /**
11
+ * Resolve the `POST /…/p/auth` endpoint that sets the `__preview_session`
12
+ * cookie for a given preview URL. Returns null when the URL isn't a trusted
13
+ * preview-proxy URL.
14
+ */
15
+ export declare function buildPreviewAuthEndpoint(previewUrl: string, serverUrl?: string): string | null;
16
+ /**
17
+ * Subdomain preview form: `p{port}-{sandbox}.{host}/…`. These can't use the
18
+ * host-only `/v1/p/` session cookie (it never reaches the preview subdomain),
19
+ * so they authenticate via a one-shot `?token` on the first request.
20
+ */
21
+ export declare function isSubdomainPreviewUrl(candidateUrl: string): boolean;
22
+ /** Append a one-shot `?token` to a (subdomain) preview URL. */
23
+ export declare function appendPreviewToken(previewUrl: string, token: string): string;
24
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Preview-proxy auth helpers (pure).
3
+ *
4
+ * A host hook drives the cookie/token exchange against the preview proxy; these
5
+ * helpers decide the auth endpoint and the token-append rule so the proxy auth
6
+ * scheme lives in exactly one place. They target the current proxy surface:
7
+ * path-based `/v1/p/{sandbox}/{port}/…`, the daemon `/proxy/{port}/…`, and the
8
+ * subdomain `p{port}-{sandbox}.{host}/…` form.
9
+ */
10
+ function derivePreviewAuthEndpoint(candidateUrl) {
11
+ try {
12
+ const url = new URL(candidateUrl);
13
+ if (/^\/proxy\/\d+(?:\/|$)/.test(url.pathname)) {
14
+ return `${url.origin}/v1/p/auth`;
15
+ }
16
+ const previewIndex = url.pathname.indexOf('/p/');
17
+ if (previewIndex !== -1) {
18
+ return `${url.origin}${url.pathname.slice(0, previewIndex)}/p/auth`;
19
+ }
20
+ return `${url.origin}/v1/p/auth`;
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }
26
+ function isPreviewProxyUrl(candidateUrl, serverUrl) {
27
+ try {
28
+ const url = new URL(candidateUrl);
29
+ const path = url.pathname;
30
+ const isPreviewPath = /^\/v1\/p\/[^/]+\/\d+(?:\/|$)/.test(path) ||
31
+ /^\/proxy\/\d+(?:\/|$)/.test(path);
32
+ if (!isPreviewPath)
33
+ return false;
34
+ const trustedOrigins = new Set();
35
+ if (serverUrl) {
36
+ try {
37
+ trustedOrigins.add(new URL(serverUrl).origin);
38
+ }
39
+ catch { }
40
+ }
41
+ if (typeof window !== 'undefined') {
42
+ trustedOrigins.add(window.location.origin);
43
+ }
44
+ return trustedOrigins.size === 0 || trustedOrigins.has(url.origin);
45
+ }
46
+ catch {
47
+ return false;
48
+ }
49
+ }
50
+ /**
51
+ * Resolve the `POST /…/p/auth` endpoint that sets the `__preview_session`
52
+ * cookie for a given preview URL. Returns null when the URL isn't a trusted
53
+ * preview-proxy URL.
54
+ */
55
+ export function buildPreviewAuthEndpoint(previewUrl, serverUrl) {
56
+ if (!isPreviewProxyUrl(previewUrl, serverUrl))
57
+ return null;
58
+ return ((serverUrl ? derivePreviewAuthEndpoint(serverUrl) : null) ??
59
+ derivePreviewAuthEndpoint(previewUrl));
60
+ }
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.
65
+ */
66
+ export function isSubdomainPreviewUrl(candidateUrl) {
67
+ try {
68
+ return /^p\d+-[^.]+\./.test(new URL(candidateUrl).hostname);
69
+ }
70
+ catch {
71
+ return false;
72
+ }
73
+ }
74
+ /** Append a one-shot `?token` to a (subdomain) preview URL. */
75
+ export function appendPreviewToken(previewUrl, token) {
76
+ try {
77
+ const u = new URL(previewUrl);
78
+ u.searchParams.set('token', token);
79
+ return u.toString();
80
+ }
81
+ catch {
82
+ return previewUrl;
83
+ }
84
+ }
85
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/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;Q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,SAAkB;IAElB,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,OAAO,CACL,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,yBAAyB,CAAC,UAAU,CAAC,CACtC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC9D,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,160 @@
1
+ /**
2
+ * Sandbox URL detection and rewriting utilities.
3
+ *
4
+ * Detects localhost URLs in agent output (e.g. "Website is live at http://localhost:8080")
5
+ * and rewrites them to subdomain-based preview URLs (like ngrok):
6
+ *
7
+ * http://p{port}-{sandboxId}.localhost:{backendPort}/{path}
8
+ *
9
+ * The subdomain scheme means the proxied app thinks it's at root `/` — absolute
10
+ * paths, Service Workers, WebSocket connections all work without any rewriting.
11
+ * Auth is handled via a cookie set on the first `?token=` authenticated request.
12
+ */
13
+ export interface DetectedLocalhostUrl {
14
+ /** The original full URL found in text (e.g. "http://localhost:8080/api/docs") */
15
+ originalUrl: string;
16
+ /** The port number */
17
+ port: number;
18
+ /** The path portion after the port (e.g. "/api/docs") */
19
+ path: string;
20
+ /** Start index in the source text */
21
+ startIndex: number;
22
+ /** End index in the source text */
23
+ endIndex: number;
24
+ /** Whether the URL was found inside a markdown code block or inline code span */
25
+ inCodeBlock: boolean;
26
+ }
27
+ export interface ParsedLocalhostUrl {
28
+ /** Canonicalized localhost URL (http(s)://localhost:PORT/path?query#hash) */
29
+ originalUrl: string;
30
+ /** Parsed port number */
31
+ port: number;
32
+ /** Parsed path + query + hash (always starts with /) */
33
+ path: string;
34
+ }
35
+ /** Options for proxy URL generation */
36
+ export interface SubdomainUrlOptions {
37
+ /** Sandbox ID (the sandbox's external id — the Daytona sandbox ID). */
38
+ sandboxId: string;
39
+ /** Backend port (e.g. 8008) — the port kortix-api listens on */
40
+ backendPort: number;
41
+ /**
42
+ * The public-facing API base URL (e.g. 'https://e2e-test.kortix.cloud/v1').
43
+ * When the user's browser is NOT on localhost, path-based proxy URLs are
44
+ * generated from this:
45
+ * https://e2e-test.kortix.cloud/v1/p/{sandboxId}/{port}/{path}
46
+ *
47
+ * This makes proxy URLs work on VPS/self-hosted deployments where
48
+ * *.localhost subdomain DNS resolution isn't available.
49
+ */
50
+ apiBaseUrl: string;
51
+ }
52
+ export declare function isAppRouteUrl(rawUrl: string | undefined): boolean;
53
+ /**
54
+ * Parse a localhost URL in one place so all consumers share identical rules.
55
+ *
56
+ * Handles a special case: `http://localhost:8000/proxy/{port}/{path}` URLs
57
+ * from inside the sandbox (Kortix Master). These are rewritten to appear as
58
+ * `localhost:{port}/{path}` so they get proxied correctly.
59
+ */
60
+ export declare function parseLocalhostUrl(rawUrl: string | undefined): ParsedLocalhostUrl | null;
61
+ /**
62
+ * Detect all localhost URLs in a text string.
63
+ * Tags each result with `inCodeBlock` so consumers can render URLs found
64
+ * inside markdown code blocks / inline code differently (e.g. compact chips
65
+ * instead of full preview cards with iframes).
66
+ */
67
+ export declare function detectLocalhostUrls(text: string): DetectedLocalhostUrl[];
68
+ /**
69
+ * Check if a string contains any localhost URLs worth rewriting.
70
+ */
71
+ export declare function hasLocalhostUrls(text: string): boolean;
72
+ /**
73
+ * Build a preview proxy URL for a sandbox service port.
74
+ *
75
+ * Both modes are proxy URLs — neither connects to the user's raw localhost.
76
+ * The provider is irrelevant; the only thing that matters is whether kortix-api
77
+ * is running on the user's local machine, because that determines whether
78
+ * *.localhost DNS can reach it.
79
+ *
80
+ * - **Subdomain** (backend local): `http://p{port}-{sandboxId}.localhost:{backendPort}/{path}`
81
+ * Transparent mode — the proxied app thinks it's at root `/`. Only works
82
+ * when kortix-api is on 127.0.0.1.
83
+ *
84
+ * - **Path-based** (backend remote): `{apiBaseUrl}/p/{sandboxId}/{port}/{path}`
85
+ * Goes through Caddy → API → sandbox. Used for all deployed setups.
86
+ *
87
+ * @example
88
+ * // Local dev: → 'http://p3210-sb-abc123.localhost:8008/viewer.html'
89
+ * // Deployed back: → 'https://e2e-test.kortix.cloud/v1/p/sb-abc123/3210/viewer.html'
90
+ */
91
+ export declare function rewriteLocalhostUrl(port: number, path: string, subdomainOpts: SubdomainUrlOptions): string;
92
+ /**
93
+ * Build the proxy base URL for a given port (without path).
94
+ * Used for opening preview tabs.
95
+ */
96
+ export declare function getProxyBaseUrl(port: number, subdomainOpts: SubdomainUrlOptions): string;
97
+ /**
98
+ * Check if a URL is a localhost URL that we can proxy.
99
+ * Excludes infrastructure ports AND the current app's own port so we never
100
+ * rewrite the frontend's own navigation links.
101
+ * Also excludes URLs that are already subdomain preview URLs.
102
+ */
103
+ export declare function isProxiableLocalhostUrl(url: string): boolean;
104
+ /**
105
+ * If the given URL points to localhost:PORT, rewrite it through the sandbox
106
+ * proxy layer. Returns the original URL unchanged when it doesn't match or
107
+ * targets an excluded infrastructure port.
108
+ *
109
+ * This is the catch-all intended for use inside markdown renderers so that
110
+ * every `<a href>`, `<img src>`, etc. that references a sandbox service
111
+ * automatically gets proxied.
112
+ */
113
+ export declare function proxyLocalhostUrl(url: string | undefined, subdomainOpts: SubdomainUrlOptions): string | undefined;
114
+ /**
115
+ * Build the internal (container-side) localhost URL for a given port + path.
116
+ * This is what the user sees as the "real" address inside the sandbox.
117
+ *
118
+ * @example toInternalUrl(8080, '/api/docs') → 'http://localhost:8080/api/docs'
119
+ */
120
+ export declare function toInternalUrl(port: number, path?: string): string;
121
+ /**
122
+ * Parse a preview proxy URL back to its components.
123
+ * Handles both subdomain and path-based formats:
124
+ *
125
+ * Subdomain: http://p3210-sb-abc123.localhost:8008/viewer.html
126
+ * Path: https://e2e-test.kortix.cloud/v1/p/sb-abc123/3210/viewer.html
127
+ */
128
+ export declare function parseSubdomainUrl(url: string): {
129
+ port: number;
130
+ sandboxId: string;
131
+ backendPort: number;
132
+ path: string;
133
+ } | null;
134
+ /**
135
+ * Try to reverse-map a proxy URL back to its internal localhost equivalent.
136
+ *
137
+ * Handles `http://p{port}-{sandboxId}.localhost:{backendPort}/{path}` →
138
+ * `http://localhost:{port}{path}`.
139
+ *
140
+ * Returns null if the URL can't be reverse-mapped.
141
+ */
142
+ export declare function proxyUrlToInternal(proxyUrl: string): string | null;
143
+ /**
144
+ * Check if a URL is already a preview proxy URL (subdomain or path-based).
145
+ * Use this to prevent double-proxying.
146
+ */
147
+ export declare function isPreviewUrl(url: string): boolean;
148
+ /**
149
+ * Build a web proxy URL that routes through the Kortix Master (port 8000)
150
+ * which hosts the /web-proxy/ forward proxy.
151
+ *
152
+ * The web proxy lives on Kortix Master, NOT the OpenCode server, so we
153
+ * construct a URL targeting port 8000 via the standard sandbox preview proxy.
154
+ */
155
+ export declare function buildWebProxyUrl(targetUrl: string, subdomainOpts: SubdomainUrlOptions): string | null;
156
+ export declare function parseWebProxyUrl(proxyUrl: string): string | null;
157
+ export declare function isWebProxyUrl(url: string): boolean;
158
+ export declare function isExternalUrl(rawUrl: string): boolean;
159
+ export declare function normalizeExternalInput(input: string): string | null;
160
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
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