@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
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Shared auth token helpers.
3
+ *
4
+ * Every function below is a thin delegate to `platformConfig().getToken()` —
5
+ * the SDK holds no token state of its own. Token acquisition (Supabase
6
+ * getSession/refreshSession or any other provider), caching, deduplicating
7
+ * concurrent callers (SSE, health check, session fetch, etc. all racing for a
8
+ * token on page load), and the install/bootstrap seam are entirely the host
9
+ * app's responsibility, implemented inside the `getToken` it passes to
10
+ * `configureKortix`/`createKortix`. A host that wants the old 30s-TTL +
11
+ * inflight-dedup behavior re-implements it in its own `getToken`; the SDK
12
+ * itself does not cache, dedupe, or retry beyond calling `getToken()` again.
13
+ *
14
+ * `getAuthToken()` is the unified getter: returns whatever token the host's
15
+ * `getToken()` resolves. `getSupabaseAccessToken()` is kept as an alias for
16
+ * callers that historically asked for "the Supabase token" specifically —
17
+ * same delegate, same value.
18
+ *
19
+ * `invalidateTokenCache()` / `setCachedAuthToken()` / `setBootstrapAuthToken()`
20
+ * are no-ops here (there is no SDK-side cache to invalidate or seed); they're
21
+ * kept as exported names so existing call sites compile unchanged, and a host
22
+ * that layers its own caching on top of `getToken()` can wire these to that
23
+ * cache if it wants the "invalidate on 401" / "seed before hydration" hooks to
24
+ * do something.
25
+ */
26
+ import { buildAuthHeaders, syntheticUnauthenticatedResponse, withDefaultTimeout, withTokenRetry, } from './auth-core.js';
27
+ import { platformConfig } from './config.js';
28
+ /**
29
+ * Get the current auth token. Delegates directly to `platformConfig().getToken()`
30
+ * — any caching/deduplication the host wants happens inside that function.
31
+ */
32
+ export async function getSupabaseAccessToken() {
33
+ return platformConfig().getToken();
34
+ }
35
+ /**
36
+ * Retry variant — actually retries now. Previously accepted `attempts`/
37
+ * `baseDelayMs`/`invalidateBetweenAttempts` and silently ignored all three
38
+ * (always a single `getToken()` call), which quietly broke every caller that
39
+ * depended on retry semantics around a flaky/cold token provider (e.g. right
40
+ * after sign-in, before a host's own session has hydrated — see the retry
41
+ * call in `authenticatedFetch`'s 401 handler below).
42
+ *
43
+ * Retries up to `attempts` times (default 1 = no retry) until `getToken()`
44
+ * returns a truthy token, waiting `baseDelayMs` between attempts (default 0).
45
+ * When `invalidateBetweenAttempts` is set, calls `invalidateTokenCache()`
46
+ * before each retry — a no-op in this file (there's no SDK-side cache), but
47
+ * kept as a real call so a host that layers its own cache on `getToken()` (and
48
+ * wires `invalidateTokenCache`/`setCachedAuthToken` to it, per this file's
49
+ * top-of-file doc comment) gets invalidated between attempts as intended.
50
+ */
51
+ export async function getSupabaseAccessTokenWithRetry(options) {
52
+ // The retry loop itself lives in `auth-core.ts` (pure, un-mockable in
53
+ // tests) — this delegate just binds it to the live platform config.
54
+ return withTokenRetry(() => platformConfig().getToken(), options, invalidateTokenCache);
55
+ }
56
+ /**
57
+ * Invalidate the cached token (e.g. after a 401 response).
58
+ * The next getSupabaseAccessToken() call will fetch fresh.
59
+ */
60
+ export function invalidateTokenCache() {
61
+ setCachedAuthToken(null);
62
+ }
63
+ /**
64
+ * Sync the resolved auth token cache without affecting bootstrap mode.
65
+ */
66
+ export function setCachedAuthToken(token) {
67
+ // Token caching/refresh is owned by the host via platformConfig().getToken().
68
+ }
69
+ /**
70
+ * Seed auth for setup/install flows that receive a JWT from server actions
71
+ * before the browser Supabase client has established local session state.
72
+ */
73
+ export function setBootstrapAuthToken(token) {
74
+ // Token acquisition is owned by the host via platformConfig().getToken().
75
+ }
76
+ /**
77
+ * Unified auth token getter.
78
+ *
79
+ * Returns the Supabase JWT. All requests go through kortix-api which
80
+ * authenticates via Supabase JWT — no additional sandbox lock/key needed.
81
+ */
82
+ export async function getAuthToken() {
83
+ return getSupabaseAccessToken();
84
+ }
85
+ export async function getAuthTokenWithRetry(options) {
86
+ return getSupabaseAccessTokenWithRetry(options);
87
+ }
88
+ // ── Shared auth-injecting fetch ──
89
+ /**
90
+ * Execute fetch with auth headers, properly handling Request objects.
91
+ *
92
+ * When `input` is a Request (e.g. from the OpenCode SDK), we construct a new
93
+ * Request with the auth headers merged in, rather than passing headers via the
94
+ * second `init` argument. This avoids a production-only issue where
95
+ * `fetch(Request, { headers })` silently drops the init headers.
96
+ */
97
+ function fetchWithAuth(input, init, headers, signal) {
98
+ if (input instanceof Request) {
99
+ // Clone the Request with our auth headers baked in.
100
+ // This guarantees Authorization is part of the Request itself,
101
+ // not relying on fetch's init-merge behavior.
102
+ const authedRequest = new Request(input, {
103
+ headers,
104
+ ...(signal ? { signal } : {}),
105
+ });
106
+ return fetch(authedRequest);
107
+ }
108
+ return fetch(input, { ...init, headers, ...(signal ? { signal } : {}) });
109
+ }
110
+ // Timeout composition, streaming exemption, and header building live in
111
+ // `auth-core.ts` (pure + directly unit-tested there); this file wires them to
112
+ // the live token seam.
113
+ /**
114
+ * Shared authenticated fetch — injects auth tokens and handles 401 responses.
115
+ *
116
+ * Centralizes the pattern duplicated across opencode-sdk, use-sandbox-connection,
117
+ * and server-selector. All three auth injection points now go through this.
118
+ *
119
+ * Behavior:
120
+ * 1. Gets the current auth token (Supabase JWT)
121
+ * 2. Injects it as Bearer token on the request
122
+ * 3. On 401: invalidates the token cache, gets fresh, retries once
123
+ *
124
+ * Options:
125
+ * - `retryOnAuthError`: if false, skips stale-token retry (default: true)
126
+ */
127
+ export async function authenticatedFetch(input, init, options) {
128
+ const { retryOnAuthError = true } = options ?? {};
129
+ const token = await getAuthTokenWithRetry();
130
+ // Still no token — return a synthetic 401 response instead of sending a
131
+ // naked request. Safe for all callers including the OpenCode SDK which
132
+ // expects fetch() semantics (returns Response, never throws).
133
+ if (!token) {
134
+ return syntheticUnauthenticatedResponse();
135
+ }
136
+ const headers = buildAuthHeaders(input, init, token);
137
+ // 30s default timeout for everything EXCEPT the long-lived SSE event
138
+ // stream (see `withDefaultTimeout`) — a "Kortix as a Backend" wrapper must
139
+ // never have a hung sandbox/daemon request wedge its handler forever.
140
+ const signal = withDefaultTimeout(input, init);
141
+ // When the OpenCode SDK passes a Request object (single arg, no init),
142
+ // we must construct a new Request with the auth headers baked in.
143
+ // Relying on fetch(Request, { headers }) to override headers is unreliable
144
+ // in production builds — Next.js's patched fetch and certain browser
145
+ // implementations don't properly merge init.headers onto an existing
146
+ // Request, causing the Authorization header to be silently dropped.
147
+ const response = await fetchWithAuth(input, init, headers, signal);
148
+ if (response.status === 401) {
149
+ // The cached token is stale. Retry once with fresh token.
150
+ if (retryOnAuthError && token) {
151
+ invalidateTokenCache();
152
+ const newToken = await getAuthTokenWithRetry({ attempts: 2, baseDelayMs: 200 });
153
+ if (newToken && newToken !== token) {
154
+ const retryHeaders = buildAuthHeaders(input, init, newToken);
155
+ return fetchWithAuth(input, init, retryHeaders, signal);
156
+ }
157
+ }
158
+ }
159
+ return response;
160
+ }
161
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/platform/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACN,gBAAgB,EAChB,gCAAgC,EAChC,kBAAkB,EAClB,cAAc,GAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC3C,OAAO,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACpD,OAA2B;IAE3B,sEAAsE;IACtE,oEAAoE;IACpE,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC;AACzF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IACnC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAoB;IACtD,8EAA8E;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACzD,0EAA0E;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,OAAO,sBAAsB,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,OAA2B;IAE3B,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,oCAAoC;AAEpC;;;;;;;GAOG;AACH,SAAS,aAAa,CACpB,KAAwB,EACxB,IAA6B,EAC7B,OAAgB,EAChB,MAAoB;IAEpB,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;QAC7B,oDAAoD;QACpD,+DAA+D;QAC/D,8CAA8C;QAC9C,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE;YACvC,OAAO;YACP,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9B,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,wEAAwE;AACxE,8EAA8E;AAC9E,uBAAuB;AAEvB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAwB,EACxB,IAAkB,EAClB,OAEC;IAED,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAElD,MAAM,KAAK,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAE5C,wEAAwE;IACxE,uEAAuE;IACvE,8DAA8D;IAC9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,gCAAgC,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrD,qEAAqE;IACrE,2EAA2E;IAC3E,sEAAsE;IACtE,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAE/C,uEAAuE;IACvE,kEAAkE;IAClE,2EAA2E;IAC3E,qEAAqE;IACrE,qEAAqE;IACrE,oEAAoE;IACpE,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAEnE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,0DAA0D;QAC1D,IAAI,gBAAgB,IAAI,KAAK,EAAE,CAAC;YAC9B,oBAAoB,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;YAChF,IAAI,QAAQ,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;gBACnC,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC7D,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type KortixPlatformConfig } from './config.js';
2
+ /**
3
+ * Run `fn` (or any synchronous callback) with `config` as the platform config
4
+ * for its entire call tree — every `platformConfig()` read reached from
5
+ * inside it (facade calls, `backendApi`, `authenticatedFetch`, the files
6
+ * client, event streams, …) sees THIS config, including across `await`s,
7
+ * isolated from any other concurrent `runScoped`/`runWithKortix` call.
8
+ *
9
+ * Internal primitive: preserves whatever `fn` returns (sync value or Promise)
10
+ * without coercing it, so `@kortix/sdk/server`'s `createScopedKortix` can wrap
11
+ * both sync (`setModel`) and async (`ensureReady`) facade methods uniformly.
12
+ */
13
+ export declare function runScoped<T>(config: KortixPlatformConfig, fn: () => T): T;
14
+ /**
15
+ * Run `fn` with `config` as the platform config for its entire async call
16
+ * tree (see `runScoped`). This is the public primitive re-exported from
17
+ * `@kortix/sdk/server` — use it to wrap one incoming request's handler body
18
+ * when you're not using the `createScopedKortix` facade wrapper.
19
+ *
20
+ * import { runWithKortix } from '@kortix/sdk/server';
21
+ *
22
+ * app.use(async (req, res, next) => {
23
+ * await runWithKortix({ backendUrl, getToken: () => resolveTokenFor(req) }, async () => {
24
+ * // every Kortix call made anywhere in this request's async chain
25
+ * // (including inside `next()`) sees THIS request's config.
26
+ * await next();
27
+ * });
28
+ * });
29
+ */
30
+ export declare function runWithKortix<T>(config: KortixPlatformConfig, fn: () => Promise<T>): Promise<T>;
31
+ /** The config active on the current async context, if any (for diagnostics/tests). */
32
+ export declare function getScopedConfig(): KortixPlatformConfig | undefined;
33
+ //# sourceMappingURL=config-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-node.d.ts","sourceRoot":"","sources":["../../src/platform/config-node.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAK1E;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEzE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,MAAM,EAAE,oBAAoB,EAC5B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,sFAAsF;AACtF,wBAAgB,eAAe,IAAI,oBAAoB,GAAG,SAAS,CAElE"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Node-only `AsyncLocalStorage` layer for per-request platform-config
3
+ * isolation. Reachable ONLY through the `@kortix/sdk/server` subpath — never
4
+ * imported by the root `@kortix/sdk` entry point, `@kortix/sdk/react`, or any
5
+ * other browser-safe subpath — so `node:async_hooks` never enters a browser
6
+ * bundle's module graph. If this file's static `import` ever gets pulled into
7
+ * an isomorphic/browser-facing subpath, that's a bug: keep it behind
8
+ * `@kortix/sdk/server`.
9
+ *
10
+ * This is the fix for the SDK's single biggest concurrency hazard: the
11
+ * `configureKortix()` seam (`./config.ts`) stores the platform config in a
12
+ * process-wide module-global. A "Kortix as a Backend" server — any Node/Bun
13
+ * process fronting Kortix on behalf of multiple end users/requests
14
+ * concurrently — can't safely call `configureKortix()` once per request: two
15
+ * in-flight requests with different tokens race on the same global and the
16
+ * second write wins for both. `runWithKortix` fixes that by threading the
17
+ * config through Node's `AsyncLocalStorage`, which — unlike a plain variable —
18
+ * stays correctly scoped to one call's entire async continuation (every
19
+ * `await` inside it) while remaining isolated from any other concurrent call
20
+ * in the same process.
21
+ */
22
+ import { AsyncLocalStorage } from 'node:async_hooks';
23
+ import { __setConfigResolver } from './config.js';
24
+ const als = new AsyncLocalStorage();
25
+ __setConfigResolver(() => als.getStore());
26
+ /**
27
+ * Run `fn` (or any synchronous callback) with `config` as the platform config
28
+ * for its entire call tree — every `platformConfig()` read reached from
29
+ * inside it (facade calls, `backendApi`, `authenticatedFetch`, the files
30
+ * client, event streams, …) sees THIS config, including across `await`s,
31
+ * isolated from any other concurrent `runScoped`/`runWithKortix` call.
32
+ *
33
+ * Internal primitive: preserves whatever `fn` returns (sync value or Promise)
34
+ * without coercing it, so `@kortix/sdk/server`'s `createScopedKortix` can wrap
35
+ * both sync (`setModel`) and async (`ensureReady`) facade methods uniformly.
36
+ */
37
+ export function runScoped(config, fn) {
38
+ return als.run(config, fn);
39
+ }
40
+ /**
41
+ * Run `fn` with `config` as the platform config for its entire async call
42
+ * tree (see `runScoped`). This is the public primitive re-exported from
43
+ * `@kortix/sdk/server` — use it to wrap one incoming request's handler body
44
+ * when you're not using the `createScopedKortix` facade wrapper.
45
+ *
46
+ * import { runWithKortix } from '@kortix/sdk/server';
47
+ *
48
+ * app.use(async (req, res, next) => {
49
+ * await runWithKortix({ backendUrl, getToken: () => resolveTokenFor(req) }, async () => {
50
+ * // every Kortix call made anywhere in this request's async chain
51
+ * // (including inside `next()`) sees THIS request's config.
52
+ * await next();
53
+ * });
54
+ * });
55
+ */
56
+ export async function runWithKortix(config, fn) {
57
+ return runScoped(config, fn);
58
+ }
59
+ /** The config active on the current async context, if any (for diagnostics/tests). */
60
+ export function getScopedConfig() {
61
+ return als.getStore();
62
+ }
63
+ //# sourceMappingURL=config-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-node.js","sourceRoot":"","sources":["../../src/platform/config-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAA6B,MAAM,UAAU,CAAC;AAE1E,MAAM,GAAG,GAAG,IAAI,iBAAiB,EAAwB,CAAC;AAC1D,mBAAmB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAI,MAA4B,EAAE,EAAW;IACpE,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,EAAoB;IAEpB,OAAO,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe;IAC7B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Per-flag overrides for `@kortix/sdk/feature-flags`. A host that isn't Next.js
3
+ * (no `NEXT_PUBLIC_*` build-time env, e.g. React Native, a bare browser bundle,
4
+ * or a CLI) has no other way to flip these — `configureKortix({ featureFlags })`
5
+ * is the portable seam. Omitted flags fall back to the legacy `NEXT_PUBLIC_*`
6
+ * env var (so web keeps working unchanged), then to the flag's own default. See
7
+ * `feature-flags.ts` for what each flag does.
8
+ */
9
+ export interface KortixFeatureFlagOverrides {
10
+ disableMobileAdvertising?: boolean;
11
+ enableDinoGame?: boolean;
12
+ enableProjects?: boolean;
13
+ enableAutoModel?: boolean;
14
+ }
15
+ /**
16
+ * The single app-specific seam. Everything else in the SDK is portable; this is
17
+ * the one place a host app injects its identity + backend. Web wires its
18
+ * Supabase token here; the demo/CLI wire a PAT. Call `configureKortix()` once at
19
+ * startup before any data-layer call.
20
+ */
21
+ export interface KortixPlatformConfig {
22
+ /** Absolute backend base URL incl. version prefix, e.g. `http://localhost:8008/v1`. */
23
+ backendUrl: string;
24
+ /** Returns the current bearer (Supabase JWT, PAT, or API key) — or null if unauthenticated. */
25
+ getToken: () => Promise<string | null>;
26
+ /** Optional UI error sink (toast/log). No-op by default. */
27
+ onError?: (error: unknown, context?: unknown) => void;
28
+ /** Default sandbox id for local/single-sandbox hosts (was `getEnv().SANDBOX_ID`). */
29
+ sandboxId?: string | null;
30
+ /** Whether billing gates are active (was `isBillingEnabled()`). */
31
+ billingEnabled?: boolean;
32
+ /** Current user id, used to scope the offline message cache. */
33
+ getUserId?: () => Promise<string | null>;
34
+ /** Toast sink — the host renders it. */
35
+ onToast?: (level: 'info' | 'success' | 'error' | 'warning', message: string, options?: unknown) => void;
36
+ /** OS/web-notification sink — the host renders it. */
37
+ onNotify?: (event: {
38
+ kind: string;
39
+ sessionId: string;
40
+ [key: string]: unknown;
41
+ }) => void;
42
+ /** Explicit per-flag overrides for `@kortix/sdk/feature-flags` (portable path). */
43
+ featureFlags?: KortixFeatureFlagOverrides;
44
+ }
45
+ /** @internal Registration seam for `@kortix/sdk/server`. Not for host use. */
46
+ export declare function __setConfigResolver(fn: (() => KortixPlatformConfig | undefined) | null): void;
47
+ /** @internal Test-only introspection, so a test file that flips the resolver
48
+ * (e.g. to exercise the no-resolver fallback path) can snapshot + restore
49
+ * whatever was registered before it, instead of clobbering a resolver another
50
+ * test file registered in the same process (bun runs all `src/**\/*.test.ts`
51
+ * files in one process, sharing this module's state). */
52
+ export declare function __getConfigResolver(): (() => KortixPlatformConfig | undefined) | null;
53
+ /**
54
+ * Wire the platform seam. `current` is a process-wide singleton — safe for a
55
+ * host with exactly one config for its whole lifetime (a browser tab, a CLI,
56
+ * a single-tenant server), but UNSAFE for a server process that must serve
57
+ * concurrent requests carrying different tokens (see the warning on
58
+ * `ServerTokenOptions` in `projects-client/shared.ts`): the last caller to
59
+ * `configureKortix()`/`createKortix()` wins for every other in-flight request.
60
+ * For that "Kortix as a Backend" shape, use `runWithKortix`/`createScopedKortix`
61
+ * from `@kortix/sdk/server` instead — they isolate each call's config in a
62
+ * Node `AsyncLocalStorage` context instead of this shared global.
63
+ *
64
+ * `opts.global === false` (used internally by `createScopedKortix`) skips the
65
+ * global write entirely, so a scoped client never touches/clobbers `current`.
66
+ */
67
+ export declare function configureKortix(config: KortixPlatformConfig, opts?: {
68
+ global?: boolean;
69
+ }): void;
70
+ /**
71
+ * The platform config in effect for THIS call: an active `runWithKortix`/
72
+ * `createScopedKortix` scope if one is on the current async context, else the
73
+ * process-global `current` set by `configureKortix()`, else the inert default.
74
+ */
75
+ export declare function platformConfig(): KortixPlatformConfig;
76
+ export declare function isConfigured(): boolean;
77
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/platform/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACzC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,4DAA4D;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mEAAmE;IACnE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,wCAAwC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACxG,sDAAsD;IACtD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACxF,mFAAmF;IACnF,YAAY,CAAC,EAAE,0BAA0B,CAAC;CAC3C;AAwBD,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAE7F;AAED;;;;0DAI0D;AAC1D,wBAAgB,mBAAmB,IAAI,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,GAAG,IAAI,CAErF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAG/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAErD;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Inert default so module-eval / SSR (which touch SDK modules before the host's
3
+ * provider runs) never crash. The host's `configureKortix` overrides it before
4
+ * any real data call — an unauthenticated default just yields no token / no URL.
5
+ */
6
+ const DEFAULT = {
7
+ backendUrl: '',
8
+ getToken: async () => null,
9
+ };
10
+ let current = null;
11
+ /**
12
+ * Per-request override hook, registered ONLY by `@kortix/sdk/server`'s
13
+ * Node-only `AsyncLocalStorage` layer (`config-node.ts`) — see `runWithKortix`/
14
+ * `createScopedKortix` there. A browser bundle never imports that subpath, so
15
+ * this stays `null` for it and `platformConfig()` behaves exactly as before
16
+ * (reads the process-global `current`). Not part of the public API — do not
17
+ * call `__setConfigResolver` directly; use `runWithKortix`/`createScopedKortix`.
18
+ */
19
+ let configResolver = null;
20
+ /** @internal Registration seam for `@kortix/sdk/server`. Not for host use. */
21
+ export function __setConfigResolver(fn) {
22
+ configResolver = fn;
23
+ }
24
+ /** @internal Test-only introspection, so a test file that flips the resolver
25
+ * (e.g. to exercise the no-resolver fallback path) can snapshot + restore
26
+ * whatever was registered before it, instead of clobbering a resolver another
27
+ * test file registered in the same process (bun runs all `src/**\/*.test.ts`
28
+ * files in one process, sharing this module's state). */
29
+ export function __getConfigResolver() {
30
+ return configResolver;
31
+ }
32
+ /**
33
+ * Wire the platform seam. `current` is a process-wide singleton — safe for a
34
+ * host with exactly one config for its whole lifetime (a browser tab, a CLI,
35
+ * a single-tenant server), but UNSAFE for a server process that must serve
36
+ * concurrent requests carrying different tokens (see the warning on
37
+ * `ServerTokenOptions` in `projects-client/shared.ts`): the last caller to
38
+ * `configureKortix()`/`createKortix()` wins for every other in-flight request.
39
+ * For that "Kortix as a Backend" shape, use `runWithKortix`/`createScopedKortix`
40
+ * from `@kortix/sdk/server` instead — they isolate each call's config in a
41
+ * Node `AsyncLocalStorage` context instead of this shared global.
42
+ *
43
+ * `opts.global === false` (used internally by `createScopedKortix`) skips the
44
+ * global write entirely, so a scoped client never touches/clobbers `current`.
45
+ */
46
+ export function configureKortix(config, opts) {
47
+ if (opts?.global === false)
48
+ return;
49
+ current = config;
50
+ }
51
+ /**
52
+ * The platform config in effect for THIS call: an active `runWithKortix`/
53
+ * `createScopedKortix` scope if one is on the current async context, else the
54
+ * process-global `current` set by `configureKortix()`, else the inert default.
55
+ */
56
+ export function platformConfig() {
57
+ return configResolver?.() ?? current ?? DEFAULT;
58
+ }
59
+ export function isConfigured() {
60
+ return current !== null || configResolver?.() !== undefined;
61
+ }
62
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/platform/config.ts"],"names":[],"mappings":"AA0CA;;;;GAIG;AACH,MAAM,OAAO,GAAyB;IACpC,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;CAC3B,CAAC;AAEF,IAAI,OAAO,GAAgC,IAAI,CAAC;AAEhD;;;;;;;GAOG;AACH,IAAI,cAAc,GAAoD,IAAI,CAAC;AAE3E,8EAA8E;AAC9E,MAAM,UAAU,mBAAmB,CAAC,EAAmD;IACrF,cAAc,GAAG,EAAE,CAAC;AACtB,CAAC;AAED;;;;0DAI0D;AAC1D,MAAM,UAAU,mBAAmB;IACjC,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,MAA4B,EAAE,IAA2B;IACvF,IAAI,IAAI,EAAE,MAAM,KAAK,KAAK;QAAE,OAAO;IACnC,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,EAAE,EAAE,IAAI,OAAO,IAAI,OAAO,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,KAAK,IAAI,IAAI,cAAc,EAAE,EAAE,KAAK,SAAS,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Parse a raw env string into a flag override: recognized truthy/falsy values
3
+ * map to true/false, anything else (including unset) is `undefined` = "no
4
+ * opinion, fall through". Exported for hosts that wire literal
5
+ * `process.env.NEXT_PUBLIC_*` reads into `configureKortix({ featureFlags })` —
6
+ * required on Next.js, whose client bundles only inline LITERAL dotted
7
+ * `process.env.NEXT_PUBLIC_X` expressions; the dynamic `safeEnv(name)` lookup
8
+ * here can never be inlined and always yields undefined in the browser.
9
+ */
10
+ export declare function parseFlagOverride(value: string | undefined): boolean | undefined;
11
+ export interface FeatureFlags {
12
+ disableMobileAdvertising: boolean;
13
+ enableDinoGame: boolean;
14
+ enableProjects: boolean;
15
+ enableAutoModel: boolean;
16
+ }
17
+ /**
18
+ * Every property below is a getter, so it's resolved lazily on each read
19
+ * rather than frozen at module-eval time — a host's `configureKortix({
20
+ * featureFlags })` is honored immediately, even if it runs after this module
21
+ * was first imported (module eval on non-Next hosts has no guaranteed order
22
+ * relative to the host's own startup/provider code).
23
+ */
24
+ export declare const featureFlags: FeatureFlags;
25
+ //# sourceMappingURL=feature-flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../src/platform/feature-flags.ts"],"names":[],"mappings":"AAyBA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAMhF;AAaD,MAAM,WAAW,YAAY;IAC3B,wBAAwB,EAAE,OAAO,CAAC;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,YA8D1B,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { AUTO_MODEL_ENABLED } from '@kortix/llm-catalog';
2
+ import { platformConfig } from './config.js';
3
+ function parseEnvBoolean(value, defaultValue) {
4
+ if (value == null)
5
+ return defaultValue;
6
+ const normalized = value.trim().toLowerCase();
7
+ if (['1', 'true', 'yes', 'y', 'on'].includes(normalized))
8
+ return true;
9
+ if (['0', 'false', 'no', 'n', 'off'].includes(normalized))
10
+ return false;
11
+ return defaultValue;
12
+ }
13
+ /**
14
+ * Safe `process.env.<name>` read. Non-Next hosts (React Native, a bare browser
15
+ * bundle, a CLI) may not define a `process` global at all — touching
16
+ * `process.env` there throws a ReferenceError, not just returns `undefined`.
17
+ */
18
+ function safeEnv(name) {
19
+ try {
20
+ return typeof process !== 'undefined' ? process.env?.[name] : undefined;
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ /**
27
+ * Parse a raw env string into a flag override: recognized truthy/falsy values
28
+ * map to true/false, anything else (including unset) is `undefined` = "no
29
+ * opinion, fall through". Exported for hosts that wire literal
30
+ * `process.env.NEXT_PUBLIC_*` reads into `configureKortix({ featureFlags })` —
31
+ * required on Next.js, whose client bundles only inline LITERAL dotted
32
+ * `process.env.NEXT_PUBLIC_X` expressions; the dynamic `safeEnv(name)` lookup
33
+ * here can never be inlined and always yields undefined in the browser.
34
+ */
35
+ export function parseFlagOverride(value) {
36
+ if (value == null)
37
+ return undefined;
38
+ const normalized = value.trim().toLowerCase();
39
+ if (['1', 'true', 'yes', 'y', 'on'].includes(normalized))
40
+ return true;
41
+ if (['0', 'false', 'no', 'n', 'off'].includes(normalized))
42
+ return false;
43
+ return undefined;
44
+ }
45
+ /**
46
+ * Resolve one flag: an explicit `configureKortix({ featureFlags })` override
47
+ * wins (the portable path — works on any host); otherwise fall back to the
48
+ * legacy `NEXT_PUBLIC_*` build-time env var (so web keeps working unchanged
49
+ * without calling `configureKortix` for this at all); otherwise the default.
50
+ */
51
+ function resolveFlag(override, envName, defaultValue) {
52
+ if (override !== undefined)
53
+ return override;
54
+ return parseEnvBoolean(safeEnv(envName), defaultValue);
55
+ }
56
+ /**
57
+ * Every property below is a getter, so it's resolved lazily on each read
58
+ * rather than frozen at module-eval time — a host's `configureKortix({
59
+ * featureFlags })` is honored immediately, even if it runs after this module
60
+ * was first imported (module eval on non-Next hosts has no guaranteed order
61
+ * relative to the host's own startup/provider code).
62
+ */
63
+ export const featureFlags = {
64
+ /**
65
+ * When true, hide any mobile app download / install advertising across the web app.
66
+ *
67
+ * Default: false (shown)
68
+ * Set NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING=true, or
69
+ * configureKortix({ featureFlags: { disableMobileAdvertising: true } }), to hide.
70
+ */
71
+ get disableMobileAdvertising() {
72
+ return resolveFlag(platformConfig().featureFlags?.disableMobileAdvertising, 'NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING', false);
73
+ },
74
+ /** When true, show the dino game easter egg during provisioning. Default: false. */
75
+ get enableDinoGame() {
76
+ return resolveFlag(platformConfig().featureFlags?.enableDinoGame, 'NEXT_PUBLIC_ENABLE_DINO_GAME', false);
77
+ },
78
+ /**
79
+ * Multi-project paradigm.
80
+ *
81
+ * Default: false. The product ships in single-workspace mode — no Projects
82
+ * section, no project picker, no /projects/[id] view, no project-scoped
83
+ * channel/trigger UI, no @project mentions, no `Add to board` triggers.
84
+ *
85
+ * When true (via NEXT_PUBLIC_ENABLE_PROJECTS=true or
86
+ * configureKortix({ featureFlags: { enableProjects: true } })), the legacy
87
+ * project UI (board, milestones, members, project agents/credentials/templates)
88
+ * is surfaced. The sandbox MUST also have KORTIX_PROJECTS_ENABLED=true for the
89
+ * LLM-side project/ticket tools to register; without that the UI exists but
90
+ * tool calls 503.
91
+ */
92
+ get enableProjects() {
93
+ return resolveFlag(platformConfig().featureFlags?.enableProjects, 'NEXT_PUBLIC_ENABLE_PROJECTS', false);
94
+ },
95
+ /**
96
+ * Expose the AUTO model (the gateway's smart router) in the model picker.
97
+ *
98
+ * Default: AUTO_MODEL_ENABLED (false). While off, the picker hides the "Auto"
99
+ * toggle entirely and every session opts into an explicit model — GLM 5.2 by
100
+ * default (see AUTO_DEFAULT_MODEL_ID in @kortix/llm-catalog). The gateway
101
+ * still resolves `auto` server-side, so this only controls the UI: flip it
102
+ * (via NEXT_PUBLIC_ENABLE_AUTO_MODEL=true or
103
+ * configureKortix({ featureFlags: { enableAutoModel: true } })) to bring the
104
+ * toggle back later.
105
+ */
106
+ get enableAutoModel() {
107
+ return resolveFlag(platformConfig().featureFlags?.enableAutoModel, 'NEXT_PUBLIC_ENABLE_AUTO_MODEL', AUTO_MODEL_ENABLED);
108
+ },
109
+ };
110
+ // Debug: uncomment to inspect feature flags during development
111
+ // if (safeEnv('NODE_ENV') !== 'production') {
112
+ // console.log('[featureFlags]', { ...featureFlags });
113
+ // }
114
+ //# sourceMappingURL=feature-flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../../src/platform/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,SAAS,eAAe,CAAC,KAAyB,EAAE,YAAqB;IACvE,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,YAAY,CAAC;IACvC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IACtE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IACxE,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,CAAC;QACH,OAAO,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IACtE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IACxE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAA6B,EAAE,OAAe,EAAE,YAAqB;IACxF,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,OAAO,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC;AACzD,CAAC;AASD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC;;;;;;OAMG;IACH,IAAI,wBAAwB;QAC1B,OAAO,WAAW,CAChB,cAAc,EAAE,CAAC,YAAY,EAAE,wBAAwB,EACvD,wCAAwC,EACxC,KAAK,CACN,CAAC;IACJ,CAAC;IACD,oFAAoF;IACpF,IAAI,cAAc;QAChB,OAAO,WAAW,CAChB,cAAc,EAAE,CAAC,YAAY,EAAE,cAAc,EAC7C,8BAA8B,EAC9B,KAAK,CACN,CAAC;IACJ,CAAC;IACD;;;;;;;;;;;;;OAaG;IACH,IAAI,cAAc;QAChB,OAAO,WAAW,CAChB,cAAc,EAAE,CAAC,YAAY,EAAE,cAAc,EAC7C,6BAA6B,EAC7B,KAAK,CACN,CAAC;IACJ,CAAC;IACD;;;;;;;;;;OAUG;IACH,IAAI,eAAe;QACjB,OAAO,WAAW,CAChB,cAAc,EAAE,CAAC,YAAY,EAAE,eAAe,EAC9C,+BAA+B,EAC/B,kBAAkB,CACnB,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,+DAA+D;AAC/D,8CAA8C;AAC9C,wDAAwD;AACxD,IAAI"}
@@ -0,0 +1,4 @@
1
+ export declare function markSessionFresh(id: string | null | undefined): void;
2
+ export declare function isSessionFresh(id: string | null | undefined): boolean;
3
+ export declare function clearSessionFresh(id: string | null | undefined): void;
4
+ //# sourceMappingURL=fresh-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fresh-sessions.d.ts","sourceRoot":"","sources":["../../src/platform/fresh-sessions.ts"],"names":[],"mappings":"AAWA,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAEpE;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAErE;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAErE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tracks sessions that were just created in THIS browser session, so the session
3
+ * page can show the instant typeable shell (not the resume loader) for them.
4
+ *
5
+ * An in-memory Set — not sessionStorage — because creation and the subsequent
6
+ * navigation happen in the same JS context (SPA pushState / client nav), so this
7
+ * is immune to serialization, key-encoding, and write-ordering quirks. A hard
8
+ * reload clears it, which is correct: a reloaded session is a resume, not new.
9
+ */
10
+ const freshSessions = new Set();
11
+ export function markSessionFresh(id) {
12
+ if (id)
13
+ freshSessions.add(id);
14
+ }
15
+ export function isSessionFresh(id) {
16
+ return !!id && freshSessions.has(id);
17
+ }
18
+ export function clearSessionFresh(id) {
19
+ if (id)
20
+ freshSessions.delete(id);
21
+ }
22
+ //# sourceMappingURL=fresh-sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fresh-sessions.js","sourceRoot":"","sources":["../../src/platform/fresh-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;AAExC,MAAM,UAAU,gBAAgB,CAAC,EAA6B;IAC5D,IAAI,EAAE;QAAE,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAA6B;IAC1D,OAAO,CAAC,CAAC,EAAE,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAA6B;IAC7D,IAAI,EAAE;QAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare const ACTIVE_INSTANCE_COOKIE = "kortix-active-instance";
2
+ export declare const INSTANCE_SCOPED_ROUTES: readonly ["/dashboard", "/agents", "/p", "/workspace", "/settings", "/browser", "/desktop", "/services", "/sessions", "/terminal", "/files", "/scheduled-tasks", "/commands", "/tools", "/configuration", "/changelog", "/legacy", "/credits-explained"];
3
+ export declare function isInstanceScopedAppPath(pathname: string): boolean;
4
+ export declare function extractInstanceRoute(pathname: string): {
5
+ instanceId: string;
6
+ innerPath: string;
7
+ } | null;
8
+ export declare function isInstanceDetailPath(pathname: string): boolean;
9
+ export declare function stripInstancePrefix(pathname: string): string;
10
+ export declare function buildInstancePath(instanceId: string, pathname: string): string;
11
+ export declare function getCurrentInstanceIdFromPathname(pathname: string | null | undefined): string | null;
12
+ export declare function getCurrentInstanceIdFromWindow(): string | null;
13
+ export declare function getActiveInstanceIdFromCookie(): string | null;
14
+ export declare function setActiveInstanceCookie(instanceId?: string | null): void;
15
+ export declare function toInstanceAwarePath(pathname: string, instanceId?: string | null): string;
16
+ export declare function normalizeAppPathname(pathname: string): string;
17
+ //# sourceMappingURL=instance-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-routes.d.ts","sourceRoot":"","sources":["../../src/platform/instance-routes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,eAAO,MAAM,sBAAsB,0PAmBzB,CAAC;AAEX,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASvG;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9E;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGnG;AAED,wBAAgB,8BAA8B,IAAI,MAAM,GAAG,IAAI,CAI9D;AAED,wBAAgB,6BAA6B,IAAI,MAAM,GAAG,IAAI,CAI7D;AAED,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAmBxE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAExF;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI7D"}