@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,35 @@
1
+ import { ApiError } from './api/errors.js';
2
+ export { ApiError, AuthError, BillingError, RequestTooLargeError, parseBillingError, isBillingError, formatBillingErrorForUI, type ApiErrorFields, type BillingErrorUI, } from './api/errors.js';
3
+ export interface ErrorContext {
4
+ operation?: string;
5
+ resource?: string;
6
+ silent?: boolean;
7
+ }
8
+ export interface ApiClientOptions {
9
+ showErrors?: boolean;
10
+ errorContext?: ErrorContext;
11
+ timeout?: number;
12
+ }
13
+ export interface ApiResponse<T = any> {
14
+ data?: T;
15
+ error?: ApiError;
16
+ success: boolean;
17
+ }
18
+ export declare function setAdminBypass(enabled: boolean): void;
19
+ export declare function isAdminBypassEnabled(): boolean;
20
+ export declare const supabaseClient: {
21
+ execute<T = any>(queryFn: () => Promise<{
22
+ data: T | null;
23
+ error: any;
24
+ }>, errorContext?: ErrorContext): Promise<ApiResponse<T>>;
25
+ };
26
+ export declare const backendApi: {
27
+ get: <T = any>(endpoint: string, options?: Omit<RequestInit & ApiClientOptions, "method" | "body">) => Promise<ApiResponse<T>>;
28
+ post: <T = any>(endpoint: string, data?: any, options?: Omit<RequestInit & ApiClientOptions, "method">) => Promise<ApiResponse<T>>;
29
+ put: <T = any>(endpoint: string, data?: any, options?: Omit<RequestInit & ApiClientOptions, "method">) => Promise<ApiResponse<T>>;
30
+ patch: <T = any>(endpoint: string, data?: any, options?: Omit<RequestInit & ApiClientOptions, "method">) => Promise<ApiResponse<T>>;
31
+ delete: <T = any>(endpoint: string, options?: Omit<RequestInit & ApiClientOptions, "method" | "body">) => Promise<ApiResponse<T>>;
32
+ upload: <T = any>(endpoint: string, formData: FormData, options?: Omit<RequestInit & ApiClientOptions, "method" | "body">) => Promise<ApiResponse<T>>;
33
+ uploadPut: <T = any>(endpoint: string, formData: FormData, options?: Omit<RequestInit & ApiClientOptions, "method" | "body">) => Promise<ApiResponse<T>>;
34
+ };
35
+ //# sourceMappingURL=api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/platform/api-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAsD,MAAM,cAAc,CAAC;AAQ5F,OAAO,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,KAAK,c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AC,kBAAkB,MAAM,YAAY,IAAI,CAAC,WAAW,GAAG,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAC;aAG5F,CAAC,kBAAkB,MAAM,YAAY,QAAQ,YAAY,IAAI,CAAC,WAAW,GAAG,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAC;gBAa7G,CAAC,kBAAkB,MAAM,YAAY,QAAQ,YAAY,IAAI,CAAC,WAAW,GAAG,gBAAgB,EAAE,QAAQ,GAAG,MAAM,CAAC;CAY7H,CAAC"}
@@ -0,0 +1,279 @@
1
+ import { platformConfig } from './config.js';
2
+ import { getSupabaseAccessTokenWithRetry } from './auth.js';
3
+ import { ApiError, AuthError, parseBillingError, RequestTooLargeError } from './api/errors.js';
4
+ const getApiUrl = () => platformConfig().backendUrl || '';
5
+ // Ported from web's error-handler. User-facing error handling is routed
6
+ // through platformConfig().onError?.() instead of web's handleApiError.
7
+ // The error classes live in ./api/errors — re-exported here so both the
8
+ // root barrel and the `@kortix/sdk/api-client` subpath expose them.
9
+ export { ApiError, AuthError, BillingError, RequestTooLargeError, parseBillingError, isBillingError, formatBillingErrorForUI, } from './api/errors.js';
10
+ // Platform-admin read-only bypass toggle (web only). In-memory, per-tab — never
11
+ // persisted — so it resets on reload and can't linger silently. When on, every
12
+ // request from this client carries `x-kortix-admin-bypass: 1`; the API only
13
+ // honors it for a real platform admin/super_admin on a `read` action (see
14
+ // apps/api/src/projects/lib/access.ts), so this is safe to set unconditionally
15
+ // here rather than threading it through every call site.
16
+ let adminBypassEnabled = false;
17
+ export function setAdminBypass(enabled) {
18
+ adminBypassEnabled = enabled;
19
+ }
20
+ export function isAdminBypassEnabled() {
21
+ return adminBypassEnabled;
22
+ }
23
+ async function makeRequest(url, options = {}) {
24
+ const { showErrors = true, errorContext, timeout = 30000, ...fetchOptions } = options;
25
+ const controller = new AbortController();
26
+ let timeoutId = null;
27
+ let isAborted = false;
28
+ // Tracks whether *our* timer fired the abort, vs. an external abort
29
+ // (client navigation, tab close, dropped connection). Only the former is a
30
+ // real timeout; the latter must not be surfaced as one.
31
+ let didTimeout = false;
32
+ try {
33
+ timeoutId = setTimeout(() => {
34
+ if (!isAborted && !controller.signal.aborted) {
35
+ isAborted = true;
36
+ didTimeout = true;
37
+ controller.abort();
38
+ }
39
+ }, timeout);
40
+ const token = await getSupabaseAccessTokenWithRetry();
41
+ // Don't set Content-Type for FormData - browser will set it automatically with boundary
42
+ const isFormData = fetchOptions.body instanceof FormData;
43
+ const headers = {};
44
+ if (!isFormData) {
45
+ headers['Content-Type'] = 'application/json';
46
+ }
47
+ // Merge with any headers from fetchOptions
48
+ Object.assign(headers, fetchOptions.headers);
49
+ if (adminBypassEnabled) {
50
+ headers['x-kortix-admin-bypass'] = '1';
51
+ }
52
+ if (token) {
53
+ headers['Authorization'] = `Bearer ${token}`;
54
+ }
55
+ else {
56
+ // No session yet — Supabase hasn't hydrated from cookies.
57
+ // Return a silent failure instead of sending a naked request that will 401.
58
+ // Callers gated by `enabled: !!user` should prevent this path, but this
59
+ // is a safety net for any calls that slip through.
60
+ return {
61
+ error: new AuthError(),
62
+ success: false,
63
+ };
64
+ }
65
+ // Note: X-Refresh-Token was removed to reduce header size and prevent HTTP 431 errors.
66
+ // The backend handles token refresh via Supabase directly.
67
+ const response = await fetch(url, {
68
+ ...fetchOptions,
69
+ headers,
70
+ signal: controller.signal,
71
+ // API auth is bearer-token based. Don't send browser cookies to the
72
+ // same-origin /v1 proxy; large localhost cookie jars can trip HTTP 431
73
+ // before the request reaches the API.
74
+ credentials: fetchOptions.credentials ?? 'omit',
75
+ });
76
+ if (timeoutId) {
77
+ clearTimeout(timeoutId);
78
+ timeoutId = null;
79
+ }
80
+ if (!response.ok) {
81
+ let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
82
+ let errorData = null;
83
+ try {
84
+ errorData = await response.json();
85
+ if (errorData.message) {
86
+ errorMessage = errorData.message;
87
+ }
88
+ else if (errorData.error && typeof errorData.error === 'string') {
89
+ errorMessage = errorData.error;
90
+ }
91
+ else if (typeof errorData.detail === 'string') {
92
+ // FastAPI returns {"detail": "error message"}
93
+ errorMessage = errorData.detail;
94
+ }
95
+ else if (errorData.detail?.message) {
96
+ errorMessage = errorData.detail.message;
97
+ }
98
+ }
99
+ catch {
100
+ }
101
+ let error = new ApiError(errorMessage, {
102
+ status: response.status,
103
+ response: response,
104
+ details: errorData || undefined,
105
+ data: errorData,
106
+ detail: errorData?.detail,
107
+ code: errorData?.code || errorData?.error_code || errorData?.detail?.error_code || response.status.toString()
108
+ });
109
+ if (response.status === 402) {
110
+ error = parseBillingError(error);
111
+ }
112
+ // Handle HTTP 431 - Request Header Fields Too Large
113
+ // This typically happens when uploading many files at once
114
+ if (response.status === 431) {
115
+ error = new RequestTooLargeError(431, {
116
+ message: 'Request is too large to process',
117
+ suggestion: 'Try uploading files one at a time, or reduce the number of files attached to your message.',
118
+ });
119
+ }
120
+ if (showErrors) {
121
+ platformConfig().onError?.(error, errorContext);
122
+ }
123
+ return {
124
+ error,
125
+ success: false,
126
+ };
127
+ }
128
+ let data;
129
+ const contentType = response.headers.get('content-type');
130
+ if (contentType?.includes('application/json')) {
131
+ data = await response.json();
132
+ }
133
+ else if (contentType?.includes('text/')) {
134
+ data = await response.text();
135
+ }
136
+ else {
137
+ data = await response.blob();
138
+ }
139
+ return {
140
+ data,
141
+ success: true,
142
+ };
143
+ }
144
+ catch (error) {
145
+ // Always clear timeout on error
146
+ if (timeoutId) {
147
+ clearTimeout(timeoutId);
148
+ timeoutId = null;
149
+ }
150
+ // Check if this is an abort error (timeout or manual abort)
151
+ const isAbortError = error?.name === 'AbortError' ||
152
+ error?.name === 'AbortSignal' ||
153
+ (error instanceof Error && error.message.includes('aborted'));
154
+ // If it was aborted, mark it so we don't try to abort again
155
+ if (isAbortError) {
156
+ isAborted = true;
157
+ }
158
+ let apiError;
159
+ if (isAbortError) {
160
+ // An external abort (Next.js client navigation, tab close, React Query
161
+ // cancelling an in-flight request, a dropped connection) is NOT a
162
+ // timeout — surfacing it as one produced the mysterious, URL-less
163
+ // "Request timeout" toasts/Sentry events. Swallow it silently.
164
+ if (!didTimeout) {
165
+ return {
166
+ error: new ApiError('Request aborted', { name: 'AbortError', code: 'ABORTED' }),
167
+ success: false,
168
+ };
169
+ }
170
+ // Genuine timeout — our timer fired. Attach the endpoint so it's clear
171
+ // *what* timed out (the previous error carried no URL).
172
+ const endpoint = url.replace(getApiUrl(), '') || url;
173
+ apiError = new ApiError(`Request timed out after ${Math.round(timeout / 1000)}s: ${endpoint}`, {
174
+ code: 'TIMEOUT',
175
+ url,
176
+ endpoint,
177
+ timeout,
178
+ });
179
+ // Only show timeout errors if showErrors is true
180
+ // This prevents spam from multiple concurrent timeouts or React Query cancellations
181
+ if (showErrors) {
182
+ platformConfig().onError?.(apiError, errorContext);
183
+ }
184
+ }
185
+ else if (error instanceof Error) {
186
+ apiError = new ApiError(error.message, {
187
+ name: error.name || 'ApiError',
188
+ stack: error.stack,
189
+ });
190
+ if (showErrors) {
191
+ platformConfig().onError?.(apiError, errorContext);
192
+ }
193
+ }
194
+ else {
195
+ apiError = new ApiError(String(error));
196
+ if (showErrors) {
197
+ platformConfig().onError?.(apiError, errorContext);
198
+ }
199
+ }
200
+ return {
201
+ error: apiError,
202
+ success: false,
203
+ };
204
+ }
205
+ }
206
+ export const supabaseClient = {
207
+ async execute(queryFn, errorContext) {
208
+ try {
209
+ const { data, error } = await queryFn();
210
+ if (error) {
211
+ const apiError = new ApiError(error.message || 'Database error', {
212
+ code: error.code,
213
+ details: error,
214
+ });
215
+ platformConfig().onError?.(apiError, errorContext);
216
+ return {
217
+ error: apiError,
218
+ success: false,
219
+ };
220
+ }
221
+ return {
222
+ data: data,
223
+ success: true,
224
+ };
225
+ }
226
+ catch (error) {
227
+ const apiError = error instanceof Error
228
+ ? new ApiError(error.message, { name: error.name || 'ApiError', stack: error.stack })
229
+ : new ApiError(String(error));
230
+ platformConfig().onError?.(apiError, errorContext);
231
+ return {
232
+ error: apiError,
233
+ success: false,
234
+ };
235
+ }
236
+ },
237
+ };
238
+ export const backendApi = {
239
+ get: (endpoint, options) => makeRequest(`${getApiUrl()}${endpoint}`, { ...options, method: 'GET' }),
240
+ post: (endpoint, data, options) => makeRequest(`${getApiUrl()}${endpoint}`, {
241
+ ...options,
242
+ method: 'POST',
243
+ body: data ? JSON.stringify(data) : undefined,
244
+ }),
245
+ put: (endpoint, data, options) => makeRequest(`${getApiUrl()}${endpoint}`, {
246
+ ...options,
247
+ method: 'PUT',
248
+ body: data ? JSON.stringify(data) : undefined,
249
+ }),
250
+ patch: (endpoint, data, options) => makeRequest(`${getApiUrl()}${endpoint}`, {
251
+ ...options,
252
+ method: 'PATCH',
253
+ body: data ? JSON.stringify(data) : undefined,
254
+ }),
255
+ delete: (endpoint, options) => makeRequest(`${getApiUrl()}${endpoint}`, { ...options, method: 'DELETE' }),
256
+ upload: (endpoint, formData, options) => {
257
+ const { headers, ...restOptions } = options || {};
258
+ const uploadHeaders = { ...headers };
259
+ delete uploadHeaders['Content-Type'];
260
+ return makeRequest(`${getApiUrl()}${endpoint}`, {
261
+ ...restOptions,
262
+ method: 'POST',
263
+ body: formData,
264
+ headers: uploadHeaders,
265
+ });
266
+ },
267
+ uploadPut: (endpoint, formData, options) => {
268
+ const { headers, ...restOptions } = options || {};
269
+ const uploadHeaders = { ...headers };
270
+ delete uploadHeaders['Content-Type'];
271
+ return makeRequest(`${getApiUrl()}${endpoint}`, {
272
+ ...restOptions,
273
+ method: 'PUT',
274
+ body: formData,
275
+ headers: uploadHeaders,
276
+ });
277
+ },
278
+ };
279
+ //# sourceMappingURL=api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/platform/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,SAA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C9C,CAAC;IAEJ,MAAM,EAAE,CAAU,QAAgB,EAAE,OAAiE,EAAE,EAAE,CACvG,WAAW,CAAI,GAAG,SAAS,EAAE,GAAG,QAAQ,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAE/E,MAAM,EAAE,CAAU,QAAgB,EAAE,QAAkB,EAAE,OAAiE,EAAE,EAAE;QAC3H,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAClD,MAAM,aAAa,GAAG,EAAE,GAAG,OAAiC,EAAE,CAAC;QAC/D,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC;QAErC,OAAO,WAAW,CAAI,GAAG,SAAS,EAAE,GAAG,QAAQ,EAAE,EAAE;YACjD,GAAG,WAAW;YACd,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;IACL,CAAC;IAED,SAAS,EAAE,CAAU,QAAgB,EAAE,QAAkB,EAAE,OAAiE,EAAE,EAAE;QAC9H,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAClD,MAAM,aAAa,GAAG,EAAE,GAAG,OAAiC,EAAE,CAAC;QAC/D,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC;QAErC,OAAO,WAAW,CAAI,GAAG,SAAS,EAAE,GAAG,QAAQ,EAAE,EAAE;YACjD,GAAG,WAAW;YACd,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Pure, dependency-free building blocks for `auth.ts` — extracted so they can
3
+ * be unit-tested against the REAL implementation regardless of test-file
4
+ * ordering.
5
+ *
6
+ * Why this file exists: several test suites register process-wide
7
+ * `mock.module('../platform/auth', …)` stubs (Bun's `mock.module` replaces a
8
+ * specifier for the remainder of the process, for every importer — see the
9
+ * note in `opencode/client.test.ts`). Any test that wants to exercise the real
10
+ * retry/timeout semantics therefore can't import them from `./auth` — on some
11
+ * Bun versions/orderings it would receive a stub. Nothing mocks THIS module,
12
+ * so `auth-core.test.ts` always tests the genuine article, and `auth.ts` stays
13
+ * a thin delegating shell whose behavior is pinned here.
14
+ */
15
+ /** Options accepted by the token-retry helpers (`getAuthTokenWithRetry` et al). */
16
+ export interface TokenRetryOptions {
17
+ attempts?: number;
18
+ baseDelayMs?: number;
19
+ invalidateBetweenAttempts?: boolean;
20
+ }
21
+ /**
22
+ * Retry `getToken` up to `attempts` times (default 1 = no retry) until it
23
+ * returns a truthy token, waiting `baseDelayMs` between attempts. When
24
+ * `invalidateBetweenAttempts` is set, `onInvalidate` runs before each retry —
25
+ * a host that layers its own cache on `getToken` wires cache invalidation
26
+ * there. Returns the last (possibly falsy) result after exhausting attempts.
27
+ */
28
+ export declare function withTokenRetry(getToken: () => Promise<string | null>, options?: TokenRetryOptions, onInvalidate?: () => void): Promise<string | null>;
29
+ export declare const DEFAULT_FETCH_TIMEOUT_MS = 30000;
30
+ /**
31
+ * The one long-lived streaming call reached through the auth fetch injection
32
+ * point — `openEventStream` (`state/event-stream.ts`) drives the opencode
33
+ * client's `global.event(...)` SSE endpoint (`GET {runtimeUrl}/global/event`).
34
+ * It manages its own lifecycle (heartbeat watchdog + explicit abort/reconnect
35
+ * loop) and must stay open far longer than any request timeout.
36
+ */
37
+ export declare function isStreamingRequest(input: RequestInfo | URL): boolean;
38
+ /**
39
+ * Compose the request's own abort signal with a default 30s timeout, so a
40
+ * hung non-streaming call can't wedge a "Kortix as a Backend" server-side
41
+ * handler forever. The SSE event stream is exempted (see
42
+ * `isStreamingRequest`): its caller signal — if any — passes through
43
+ * untouched. Falls back to the caller's bare signal on a runtime without
44
+ * `AbortSignal.any` (older Node/engines) — guarded so a caller-supplied
45
+ * signal is never silently dropped.
46
+ */
47
+ export declare function withDefaultTimeout(input: RequestInfo | URL, init: RequestInit | undefined, timeoutMs?: number): AbortSignal | undefined;
48
+ /**
49
+ * Build a Headers object from request input + init, injecting the auth token
50
+ * as a Bearer Authorization header (unless one is already present).
51
+ */
52
+ export declare function buildAuthHeaders(input: RequestInfo | URL, init?: RequestInit, token?: string | null): Headers;
53
+ /**
54
+ * The synthetic 401 returned when no token is available — safe for all
55
+ * callers including the OpenCode SDK, which expects fetch() semantics
56
+ * (returns a Response, never throws), and it means the request never goes
57
+ * out on the wire unauthenticated.
58
+ */
59
+ export declare function syntheticUnauthenticatedResponse(): Response;
60
+ //# sourceMappingURL=auth-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-core.d.ts","sourceRoot":"","sources":["../../src/platform/auth-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACpC;AAMD;;;;;;GAMG;AACH,wBAAsB,cAAc,CACnC,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EACtC,OAAO,CAAC,EAAE,iBAAiB,EAC3B,YAAY,CAAC,EAAE,MAAM,IAAI,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,OAAO,CAGpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,SAAS,GAAE,MAAiC,GAC1C,WAAW,GAAG,SAAS,CAUzB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACnB,OAAO,CAWT;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,IAAI,QAAQ,CAK3D"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Pure, dependency-free building blocks for `auth.ts` — extracted so they can
3
+ * be unit-tested against the REAL implementation regardless of test-file
4
+ * ordering.
5
+ *
6
+ * Why this file exists: several test suites register process-wide
7
+ * `mock.module('../platform/auth', …)` stubs (Bun's `mock.module` replaces a
8
+ * specifier for the remainder of the process, for every importer — see the
9
+ * note in `opencode/client.test.ts`). Any test that wants to exercise the real
10
+ * retry/timeout semantics therefore can't import them from `./auth` — on some
11
+ * Bun versions/orderings it would receive a stub. Nothing mocks THIS module,
12
+ * so `auth-core.test.ts` always tests the genuine article, and `auth.ts` stays
13
+ * a thin delegating shell whose behavior is pinned here.
14
+ */
15
+ function delay(ms) {
16
+ return new Promise((resolve) => setTimeout(resolve, ms));
17
+ }
18
+ /**
19
+ * Retry `getToken` up to `attempts` times (default 1 = no retry) until it
20
+ * returns a truthy token, waiting `baseDelayMs` between attempts. When
21
+ * `invalidateBetweenAttempts` is set, `onInvalidate` runs before each retry —
22
+ * a host that layers its own cache on `getToken` wires cache invalidation
23
+ * there. Returns the last (possibly falsy) result after exhausting attempts.
24
+ */
25
+ export async function withTokenRetry(getToken, options, onInvalidate) {
26
+ const attempts = Math.max(1, options?.attempts ?? 1);
27
+ const baseDelayMs = options?.baseDelayMs ?? 0;
28
+ const invalidateBetweenAttempts = options?.invalidateBetweenAttempts ?? false;
29
+ let token = null;
30
+ for (let attempt = 0; attempt < attempts; attempt++) {
31
+ if (attempt > 0) {
32
+ if (invalidateBetweenAttempts)
33
+ onInvalidate?.();
34
+ if (baseDelayMs > 0)
35
+ await delay(baseDelayMs);
36
+ }
37
+ token = await getToken();
38
+ if (token)
39
+ return token;
40
+ }
41
+ return token;
42
+ }
43
+ export const DEFAULT_FETCH_TIMEOUT_MS = 30_000;
44
+ /**
45
+ * The one long-lived streaming call reached through the auth fetch injection
46
+ * point — `openEventStream` (`state/event-stream.ts`) drives the opencode
47
+ * client's `global.event(...)` SSE endpoint (`GET {runtimeUrl}/global/event`).
48
+ * It manages its own lifecycle (heartbeat watchdog + explicit abort/reconnect
49
+ * loop) and must stay open far longer than any request timeout.
50
+ */
51
+ export function isStreamingRequest(input) {
52
+ const url = input instanceof Request ? input.url : String(input);
53
+ return url.includes('/global/event');
54
+ }
55
+ /**
56
+ * Compose the request's own abort signal with a default 30s timeout, so a
57
+ * hung non-streaming call can't wedge a "Kortix as a Backend" server-side
58
+ * handler forever. The SSE event stream is exempted (see
59
+ * `isStreamingRequest`): its caller signal — if any — passes through
60
+ * untouched. Falls back to the caller's bare signal on a runtime without
61
+ * `AbortSignal.any` (older Node/engines) — guarded so a caller-supplied
62
+ * signal is never silently dropped.
63
+ */
64
+ export function withDefaultTimeout(input, init, timeoutMs = DEFAULT_FETCH_TIMEOUT_MS) {
65
+ const callerSignal = input instanceof Request ? input.signal : init?.signal;
66
+ if (isStreamingRequest(input))
67
+ return callerSignal ?? undefined;
68
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
69
+ if (!callerSignal)
70
+ return timeoutSignal;
71
+ if (typeof AbortSignal.any === 'function') {
72
+ return AbortSignal.any([callerSignal, timeoutSignal]);
73
+ }
74
+ return callerSignal;
75
+ }
76
+ /**
77
+ * Build a Headers object from request input + init, injecting the auth token
78
+ * as a Bearer Authorization header (unless one is already present).
79
+ */
80
+ export function buildAuthHeaders(input, init, token) {
81
+ const headers = new Headers(input instanceof Request ? input.headers : undefined);
82
+ if (init?.headers) {
83
+ new Headers(init.headers).forEach((value, key) => {
84
+ headers.set(key, value);
85
+ });
86
+ }
87
+ if (token && !headers.has('Authorization')) {
88
+ headers.set('Authorization', `Bearer ${token}`);
89
+ }
90
+ return headers;
91
+ }
92
+ /**
93
+ * The synthetic 401 returned when no token is available — safe for all
94
+ * callers including the OpenCode SDK, which expects fetch() semantics
95
+ * (returns a Response, never throws), and it means the request never goes
96
+ * out on the wire unauthenticated.
97
+ */
98
+ export function syntheticUnauthenticatedResponse() {
99
+ return new Response(JSON.stringify({ error: 'Not authenticated' }), {
100
+ status: 401,
101
+ headers: { 'Content-Type': 'application/json' },
102
+ });
103
+ }
104
+ //# sourceMappingURL=auth-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-core.js","sourceRoot":"","sources":["../../src/platform/auth-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,SAAS,KAAK,CAAC,EAAU;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,QAAsC,EACtC,OAA2B,EAC3B,YAAyB;IAEzB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,CAAC,CAAC;IAC9C,MAAM,yBAAyB,GAAG,OAAO,EAAE,yBAAyB,IAAI,KAAK,CAAC;IAE9E,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;QACrD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,yBAAyB;gBAAE,YAAY,EAAE,EAAE,CAAC;YAChD,IAAI,WAAW,GAAG,CAAC;gBAAE,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;QACD,KAAK,GAAG,MAAM,QAA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E,OAAO,EAAE,CAAC;QACnB,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAChD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC;IAC/C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,EAAE;QACnE,MAAM,EAAE,GAAG;QACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAC/C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,88 @@
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 { type TokenRetryOptions } from './auth-core.js';
27
+ /**
28
+ * Get the current auth token. Delegates directly to `platformConfig().getToken()`
29
+ * — any caching/deduplication the host wants happens inside that function.
30
+ */
31
+ export declare function getSupabaseAccessToken(): Promise<string | null>;
32
+ /**
33
+ * Retry variant — actually retries now. Previously accepted `attempts`/
34
+ * `baseDelayMs`/`invalidateBetweenAttempts` and silently ignored all three
35
+ * (always a single `getToken()` call), which quietly broke every caller that
36
+ * depended on retry semantics around a flaky/cold token provider (e.g. right
37
+ * after sign-in, before a host's own session has hydrated — see the retry
38
+ * call in `authenticatedFetch`'s 401 handler below).
39
+ *
40
+ * Retries up to `attempts` times (default 1 = no retry) until `getToken()`
41
+ * returns a truthy token, waiting `baseDelayMs` between attempts (default 0).
42
+ * When `invalidateBetweenAttempts` is set, calls `invalidateTokenCache()`
43
+ * before each retry — a no-op in this file (there's no SDK-side cache), but
44
+ * kept as a real call so a host that layers its own cache on `getToken()` (and
45
+ * wires `invalidateTokenCache`/`setCachedAuthToken` to it, per this file's
46
+ * top-of-file doc comment) gets invalidated between attempts as intended.
47
+ */
48
+ export declare function getSupabaseAccessTokenWithRetry(options?: TokenRetryOptions): Promise<string | null>;
49
+ /**
50
+ * Invalidate the cached token (e.g. after a 401 response).
51
+ * The next getSupabaseAccessToken() call will fetch fresh.
52
+ */
53
+ export declare function invalidateTokenCache(): void;
54
+ /**
55
+ * Sync the resolved auth token cache without affecting bootstrap mode.
56
+ */
57
+ export declare function setCachedAuthToken(token: string | null): void;
58
+ /**
59
+ * Seed auth for setup/install flows that receive a JWT from server actions
60
+ * before the browser Supabase client has established local session state.
61
+ */
62
+ export declare function setBootstrapAuthToken(token: string | null): void;
63
+ /**
64
+ * Unified auth token getter.
65
+ *
66
+ * Returns the Supabase JWT. All requests go through kortix-api which
67
+ * authenticates via Supabase JWT — no additional sandbox lock/key needed.
68
+ */
69
+ export declare function getAuthToken(): Promise<string | null>;
70
+ export declare function getAuthTokenWithRetry(options?: TokenRetryOptions): Promise<string | null>;
71
+ /**
72
+ * Shared authenticated fetch — injects auth tokens and handles 401 responses.
73
+ *
74
+ * Centralizes the pattern duplicated across opencode-sdk, use-sandbox-connection,
75
+ * and server-selector. All three auth injection points now go through this.
76
+ *
77
+ * Behavior:
78
+ * 1. Gets the current auth token (Supabase JWT)
79
+ * 2. Injects it as Bearer token on the request
80
+ * 3. On 401: invalidates the token cache, gets fresh, retries once
81
+ *
82
+ * Options:
83
+ * - `retryOnAuthError`: if false, skips stale-token retry (default: true)
84
+ */
85
+ export declare function authenticatedFetch(input: RequestInfo | URL, init?: RequestInit, options?: {
86
+ retryOnAuthError?: boolean;
87
+ }): Promise<Response>;
88
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/platform/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAKN,KAAK,iBAAiB,EACtB,MAAM,aAAa,CAAC;AAGrB;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAErE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,+BAA+B,CACpD,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEhE;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE3D;AAED,wBAAsB,qBAAqB,CAC1C,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAmCD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE;IACR,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GACA,OAAO,CAAC,QAAQ,CAAC,CAuCnB"}