@kortix/sdk 0.9.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (618) hide show
  1. package/README.md +313 -0
  2. package/dist/files/client.d.ts +96 -0
  3. package/dist/files/client.d.ts.map +1 -0
  4. package/dist/files/client.js +346 -0
  5. package/dist/files/client.js.map +1 -0
  6. package/dist/files/types.d.ts +82 -0
  7. package/dist/files/types.d.ts.map +1 -0
  8. package/dist/files/types.js +6 -0
  9. package/dist/files/types.js.map +1 -0
  10. package/dist/index.d.ts +119 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +93 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/kortix.d.ts +897 -0
  15. package/dist/kortix.d.ts.map +1 -0
  16. package/dist/kortix.js +772 -0
  17. package/dist/kortix.js.map +1 -0
  18. package/dist/opencode/client.d.ts +89 -0
  19. package/dist/opencode/client.d.ts.map +1 -0
  20. package/dist/opencode/client.js +191 -0
  21. package/dist/opencode/client.js.map +1 -0
  22. package/dist/opencode/env.d.ts +13 -0
  23. package/dist/opencode/env.d.ts.map +1 -0
  24. package/dist/opencode/env.js +63 -0
  25. package/dist/opencode/env.js.map +1 -0
  26. package/dist/opencode/kortix-master.d.ts +487 -0
  27. package/dist/opencode/kortix-master.d.ts.map +1 -0
  28. package/dist/opencode/kortix-master.js +313 -0
  29. package/dist/opencode/kortix-master.js.map +1 -0
  30. package/dist/opencode/triggers.d.ts +6 -0
  31. package/dist/opencode/triggers.d.ts.map +1 -0
  32. package/dist/opencode/triggers.js +34 -0
  33. package/dist/opencode/triggers.js.map +1 -0
  34. package/dist/platform/api/errors.d.ts +106 -0
  35. package/dist/platform/api/errors.d.ts.map +1 -0
  36. package/dist/platform/api/errors.js +137 -0
  37. package/dist/platform/api/errors.js.map +1 -0
  38. package/dist/platform/api-client.d.ts +35 -0
  39. package/dist/platform/api-client.d.ts.map +1 -0
  40. package/dist/platform/api-client.js +279 -0
  41. package/dist/platform/api-client.js.map +1 -0
  42. package/dist/platform/auth-core.d.ts +60 -0
  43. package/dist/platform/auth-core.d.ts.map +1 -0
  44. package/dist/platform/auth-core.js +104 -0
  45. package/dist/platform/auth-core.js.map +1 -0
  46. package/dist/platform/auth.d.ts +88 -0
  47. package/dist/platform/auth.d.ts.map +1 -0
  48. package/dist/platform/auth.js +161 -0
  49. package/dist/platform/auth.js.map +1 -0
  50. package/dist/platform/config-node.d.ts +33 -0
  51. package/dist/platform/config-node.d.ts.map +1 -0
  52. package/dist/platform/config-node.js +63 -0
  53. package/dist/platform/config-node.js.map +1 -0
  54. package/dist/platform/config.d.ts +77 -0
  55. package/dist/platform/config.d.ts.map +1 -0
  56. package/dist/platform/config.js +62 -0
  57. package/dist/platform/config.js.map +1 -0
  58. package/dist/platform/feature-flags.d.ts +25 -0
  59. package/dist/platform/feature-flags.d.ts.map +1 -0
  60. package/dist/platform/feature-flags.js +114 -0
  61. package/dist/platform/feature-flags.js.map +1 -0
  62. package/dist/platform/fresh-sessions.d.ts +4 -0
  63. package/dist/platform/fresh-sessions.d.ts.map +1 -0
  64. package/dist/platform/fresh-sessions.js +22 -0
  65. package/dist/platform/fresh-sessions.js.map +1 -0
  66. package/dist/platform/instance-routes.d.ts +17 -0
  67. package/dist/platform/instance-routes.d.ts.map +1 -0
  68. package/dist/platform/instance-routes.js +105 -0
  69. package/dist/platform/instance-routes.js.map +1 -0
  70. package/dist/platform/logger.d.ts +20 -0
  71. package/dist/platform/logger.d.ts.map +1 -0
  72. package/dist/platform/logger.js +44 -0
  73. package/dist/platform/logger.js.map +1 -0
  74. package/dist/platform/opencode-errors.d.ts +20 -0
  75. package/dist/platform/opencode-errors.d.ts.map +1 -0
  76. package/dist/platform/opencode-errors.js +71 -0
  77. package/dist/platform/opencode-errors.js.map +1 -0
  78. package/dist/platform/platform-client/backups.d.ts +22 -0
  79. package/dist/platform/platform-client/backups.d.ts.map +1 -0
  80. package/dist/platform/platform-client/backups.js +16 -0
  81. package/dist/platform/platform-client/backups.js.map +1 -0
  82. package/dist/platform/platform-client/index.d.ts +21 -0
  83. package/dist/platform/platform-client/index.d.ts.map +1 -0
  84. package/dist/platform/platform-client/index.js +21 -0
  85. package/dist/platform/platform-client/index.js.map +1 -0
  86. package/dist/platform/platform-client/instance-admin.d.ts +67 -0
  87. package/dist/platform/platform-client/instance-admin.d.ts.map +1 -0
  88. package/dist/platform/platform-client/instance-admin.js +59 -0
  89. package/dist/platform/platform-client/instance-admin.js.map +1 -0
  90. package/dist/platform/platform-client/invites.d.ts +35 -0
  91. package/dist/platform/platform-client/invites.d.ts.map +1 -0
  92. package/dist/platform/platform-client/invites.js +25 -0
  93. package/dist/platform/platform-client/invites.js.map +1 -0
  94. package/dist/platform/platform-client/lifecycle.d.ts +78 -0
  95. package/dist/platform/platform-client/lifecycle.d.ts.map +1 -0
  96. package/dist/platform/platform-client/lifecycle.js +151 -0
  97. package/dist/platform/platform-client/lifecycle.js.map +1 -0
  98. package/dist/platform/platform-client/members.d.ts +81 -0
  99. package/dist/platform/platform-client/members.d.ts.map +1 -0
  100. package/dist/platform/platform-client/members.js +59 -0
  101. package/dist/platform/platform-client/members.js.map +1 -0
  102. package/dist/platform/platform-client/shared.d.ts +44 -0
  103. package/dist/platform/platform-client/shared.d.ts.map +1 -0
  104. package/dist/platform/platform-client/shared.js +177 -0
  105. package/dist/platform/platform-client/shared.js.map +1 -0
  106. package/dist/platform/platform-client/ssh.d.ts +29 -0
  107. package/dist/platform/platform-client/ssh.d.ts.map +1 -0
  108. package/dist/platform/platform-client/ssh.js +14 -0
  109. package/dist/platform/platform-client/ssh.js.map +1 -0
  110. package/dist/platform/platform-client/types.d.ts +56 -0
  111. package/dist/platform/platform-client/types.d.ts.map +1 -0
  112. package/dist/platform/platform-client/types.js +19 -0
  113. package/dist/platform/platform-client/types.js.map +1 -0
  114. package/dist/platform/platform-client/updates.d.ts +117 -0
  115. package/dist/platform/platform-client/updates.d.ts.map +1 -0
  116. package/dist/platform/platform-client/updates.js +97 -0
  117. package/dist/platform/platform-client/updates.js.map +1 -0
  118. package/dist/platform/platform-client/urls.d.ts +18 -0
  119. package/dist/platform/platform-client/urls.d.ts.map +1 -0
  120. package/dist/platform/platform-client/urls.js +31 -0
  121. package/dist/platform/platform-client/urls.js.map +1 -0
  122. package/dist/platform/projects-client/access.d.ts +273 -0
  123. package/dist/platform/projects-client/access.d.ts.map +1 -0
  124. package/dist/platform/projects-client/access.js +89 -0
  125. package/dist/platform/projects-client/access.js.map +1 -0
  126. package/dist/platform/projects-client/accounts.d.ts +184 -0
  127. package/dist/platform/projects-client/accounts.d.ts.map +1 -0
  128. package/dist/platform/projects-client/accounts.js +78 -0
  129. package/dist/platform/projects-client/accounts.js.map +1 -0
  130. package/dist/platform/projects-client/agent-config.d.ts +58 -0
  131. package/dist/platform/projects-client/agent-config.d.ts.map +1 -0
  132. package/dist/platform/projects-client/agent-config.js +9 -0
  133. package/dist/platform/projects-client/agent-config.js.map +1 -0
  134. package/dist/platform/projects-client/agent-scope.d.ts +12 -0
  135. package/dist/platform/projects-client/agent-scope.d.ts.map +1 -0
  136. package/dist/platform/projects-client/agent-scope.js +6 -0
  137. package/dist/platform/projects-client/agent-scope.js.map +1 -0
  138. package/dist/platform/projects-client/apps.d.ts +98 -0
  139. package/dist/platform/projects-client/apps.d.ts.map +1 -0
  140. package/dist/platform/projects-client/apps.js +29 -0
  141. package/dist/platform/projects-client/apps.js.map +1 -0
  142. package/dist/platform/projects-client/audit.d.ts +85 -0
  143. package/dist/platform/projects-client/audit.d.ts.map +1 -0
  144. package/dist/platform/projects-client/audit.js +51 -0
  145. package/dist/platform/projects-client/audit.js.map +1 -0
  146. package/dist/platform/projects-client/billing.d.ts +336 -0
  147. package/dist/platform/projects-client/billing.d.ts.map +1 -0
  148. package/dist/platform/projects-client/billing.js +260 -0
  149. package/dist/platform/projects-client/billing.js.map +1 -0
  150. package/dist/platform/projects-client/change-requests.d.ts +119 -0
  151. package/dist/platform/projects-client/change-requests.d.ts.map +1 -0
  152. package/dist/platform/projects-client/change-requests.js +56 -0
  153. package/dist/platform/projects-client/change-requests.js.map +1 -0
  154. package/dist/platform/projects-client/channels.d.ts +135 -0
  155. package/dist/platform/projects-client/channels.d.ts.map +1 -0
  156. package/dist/platform/projects-client/channels.js +103 -0
  157. package/dist/platform/projects-client/channels.js.map +1 -0
  158. package/dist/platform/projects-client/connectors.d.ts +148 -0
  159. package/dist/platform/projects-client/connectors.d.ts.map +1 -0
  160. package/dist/platform/projects-client/connectors.js +66 -0
  161. package/dist/platform/projects-client/connectors.js.map +1 -0
  162. package/dist/platform/projects-client/files.d.ts +37 -0
  163. package/dist/platform/projects-client/files.d.ts.map +1 -0
  164. package/dist/platform/projects-client/files.js +58 -0
  165. package/dist/platform/projects-client/files.js.map +1 -0
  166. package/dist/platform/projects-client/gateway.d.ts +177 -0
  167. package/dist/platform/projects-client/gateway.d.ts.map +1 -0
  168. package/dist/platform/projects-client/gateway.js +59 -0
  169. package/dist/platform/projects-client/gateway.js.map +1 -0
  170. package/dist/platform/projects-client/git-history.d.ts +74 -0
  171. package/dist/platform/projects-client/git-history.d.ts.map +1 -0
  172. package/dist/platform/projects-client/git-history.js +40 -0
  173. package/dist/platform/projects-client/git-history.js.map +1 -0
  174. package/dist/platform/projects-client/github.d.ts +62 -0
  175. package/dist/platform/projects-client/github.d.ts.map +1 -0
  176. package/dist/platform/projects-client/github.js +30 -0
  177. package/dist/platform/projects-client/github.js.map +1 -0
  178. package/dist/platform/projects-client/index.d.ts +32 -0
  179. package/dist/platform/projects-client/index.d.ts.map +1 -0
  180. package/dist/platform/projects-client/index.js +34 -0
  181. package/dist/platform/projects-client/index.js.map +1 -0
  182. package/dist/platform/projects-client/marketplace-catalog.d.ts +76 -0
  183. package/dist/platform/projects-client/marketplace-catalog.d.ts.map +1 -0
  184. package/dist/platform/projects-client/marketplace-catalog.js +48 -0
  185. package/dist/platform/projects-client/marketplace-catalog.js.map +1 -0
  186. package/dist/platform/projects-client/marketplace.d.ts +80 -0
  187. package/dist/platform/projects-client/marketplace.d.ts.map +1 -0
  188. package/dist/platform/projects-client/marketplace.js +52 -0
  189. package/dist/platform/projects-client/marketplace.js.map +1 -0
  190. package/dist/platform/projects-client/model-defaults.d.ts +36 -0
  191. package/dist/platform/projects-client/model-defaults.d.ts.map +1 -0
  192. package/dist/platform/projects-client/model-defaults.js +16 -0
  193. package/dist/platform/projects-client/model-defaults.js.map +1 -0
  194. package/dist/platform/projects-client/policies.d.ts +21 -0
  195. package/dist/platform/projects-client/policies.d.ts.map +1 -0
  196. package/dist/platform/projects-client/policies.js +10 -0
  197. package/dist/platform/projects-client/policies.js.map +1 -0
  198. package/dist/platform/projects-client/projects.d.ts +235 -0
  199. package/dist/platform/projects-client/projects.d.ts.map +1 -0
  200. package/dist/platform/projects-client/projects.js +161 -0
  201. package/dist/platform/projects-client/projects.js.map +1 -0
  202. package/dist/platform/projects-client/public-session-shares.d.ts +52 -0
  203. package/dist/platform/projects-client/public-session-shares.d.ts.map +1 -0
  204. package/dist/platform/projects-client/public-session-shares.js +54 -0
  205. package/dist/platform/projects-client/public-session-shares.js.map +1 -0
  206. package/dist/platform/projects-client/review.d.ts +57 -0
  207. package/dist/platform/projects-client/review.d.ts.map +1 -0
  208. package/dist/platform/projects-client/review.js +28 -0
  209. package/dist/platform/projects-client/review.js.map +1 -0
  210. package/dist/platform/projects-client/sandbox-shares.d.ts +25 -0
  211. package/dist/platform/projects-client/sandbox-shares.d.ts.map +1 -0
  212. package/dist/platform/projects-client/sandbox-shares.js +29 -0
  213. package/dist/platform/projects-client/sandbox-shares.js.map +1 -0
  214. package/dist/platform/projects-client/sandbox.d.ts +123 -0
  215. package/dist/platform/projects-client/sandbox.d.ts.map +1 -0
  216. package/dist/platform/projects-client/sandbox.js +45 -0
  217. package/dist/platform/projects-client/sandbox.js.map +1 -0
  218. package/dist/platform/projects-client/secrets.d.ts +122 -0
  219. package/dist/platform/projects-client/secrets.d.ts.map +1 -0
  220. package/dist/platform/projects-client/secrets.js +34 -0
  221. package/dist/platform/projects-client/secrets.js.map +1 -0
  222. package/dist/platform/projects-client/session-sandbox.d.ts +61 -0
  223. package/dist/platform/projects-client/session-sandbox.d.ts.map +1 -0
  224. package/dist/platform/projects-client/session-sandbox.js +82 -0
  225. package/dist/platform/projects-client/session-sandbox.js.map +1 -0
  226. package/dist/platform/projects-client/sessions.d.ts +216 -0
  227. package/dist/platform/projects-client/sessions.d.ts.map +1 -0
  228. package/dist/platform/projects-client/sessions.js +74 -0
  229. package/dist/platform/projects-client/sessions.js.map +1 -0
  230. package/dist/platform/projects-client/setup-links.d.ts +35 -0
  231. package/dist/platform/projects-client/setup-links.d.ts.map +1 -0
  232. package/dist/platform/projects-client/setup-links.js +24 -0
  233. package/dist/platform/projects-client/setup-links.js.map +1 -0
  234. package/dist/platform/projects-client/shared.d.ts +66 -0
  235. package/dist/platform/projects-client/shared.d.ts.map +1 -0
  236. package/dist/platform/projects-client/shared.js +44 -0
  237. package/dist/platform/projects-client/shared.js.map +1 -0
  238. package/dist/platform/projects-client/tokens.d.ts +77 -0
  239. package/dist/platform/projects-client/tokens.d.ts.map +1 -0
  240. package/dist/platform/projects-client/tokens.js +43 -0
  241. package/dist/platform/projects-client/tokens.js.map +1 -0
  242. package/dist/platform/projects-client/transcription.d.ts +5 -0
  243. package/dist/platform/projects-client/transcription.d.ts.map +1 -0
  244. package/dist/platform/projects-client/transcription.js +14 -0
  245. package/dist/platform/projects-client/transcription.js.map +1 -0
  246. package/dist/platform/projects-client/triggers.d.ts +102 -0
  247. package/dist/platform/projects-client/triggers.d.ts.map +1 -0
  248. package/dist/platform/projects-client/triggers.js +27 -0
  249. package/dist/platform/projects-client/triggers.js.map +1 -0
  250. package/dist/platform/session-id.d.ts +9 -0
  251. package/dist/platform/session-id.d.ts.map +1 -0
  252. package/dist/platform/session-id.js +23 -0
  253. package/dist/platform/session-id.js.map +1 -0
  254. package/dist/platform/storage/managed-storage.d.ts +97 -0
  255. package/dist/platform/storage/managed-storage.d.ts.map +1 -0
  256. package/dist/platform/storage/managed-storage.js +271 -0
  257. package/dist/platform/storage/managed-storage.js.map +1 -0
  258. package/dist/platform/strings.d.ts +12 -0
  259. package/dist/platform/strings.d.ts.map +1 -0
  260. package/dist/platform/strings.js +17 -0
  261. package/dist/platform/strings.js.map +1 -0
  262. package/dist/platform/ui.d.ts +11 -0
  263. package/dist/platform/ui.d.ts.map +1 -0
  264. package/dist/platform/ui.js +22 -0
  265. package/dist/platform/ui.js.map +1 -0
  266. package/dist/react/chat/index.d.ts +3 -0
  267. package/dist/react/chat/index.d.ts.map +1 -0
  268. package/dist/react/chat/index.js +7 -0
  269. package/dist/react/chat/index.js.map +1 -0
  270. package/dist/react/chat/render-parts.d.ts +39 -0
  271. package/dist/react/chat/render-parts.d.ts.map +1 -0
  272. package/dist/react/chat/render-parts.js +34 -0
  273. package/dist/react/chat/render-parts.js.map +1 -0
  274. package/dist/react/chat/use-chat-turns.d.ts +19 -0
  275. package/dist/react/chat/use-chat-turns.d.ts.map +1 -0
  276. package/dist/react/chat/use-chat-turns.js +27 -0
  277. package/dist/react/chat/use-chat-turns.js.map +1 -0
  278. package/dist/react/file-keys.d.ts +18 -0
  279. package/dist/react/file-keys.d.ts.map +1 -0
  280. package/dist/react/file-keys.js +18 -0
  281. package/dist/react/file-keys.js.map +1 -0
  282. package/dist/react/index.d.ts +12 -0
  283. package/dist/react/index.d.ts.map +1 -0
  284. package/dist/react/index.js +49 -0
  285. package/dist/react/index.js.map +1 -0
  286. package/dist/react/model-flatten.d.ts +33 -0
  287. package/dist/react/model-flatten.d.ts.map +1 -0
  288. package/dist/react/model-flatten.js +59 -0
  289. package/dist/react/model-flatten.js.map +1 -0
  290. package/dist/react/opencode.d.ts +43 -0
  291. package/dist/react/opencode.d.ts.map +1 -0
  292. package/dist/react/opencode.js +100 -0
  293. package/dist/react/opencode.js.map +1 -0
  294. package/dist/react/prefetch-session-start.d.ts +10 -0
  295. package/dist/react/prefetch-session-start.d.ts.map +1 -0
  296. package/dist/react/prefetch-session-start.js +17 -0
  297. package/dist/react/prefetch-session-start.js.map +1 -0
  298. package/dist/react/provider-refresh.d.ts +7 -0
  299. package/dist/react/provider-refresh.d.ts.map +1 -0
  300. package/dist/react/provider-refresh.js +28 -0
  301. package/dist/react/provider-refresh.js.map +1 -0
  302. package/dist/react/provider-selection.d.ts +31 -0
  303. package/dist/react/provider-selection.d.ts.map +1 -0
  304. package/dist/react/provider-selection.js +135 -0
  305. package/dist/react/provider-selection.js.map +1 -0
  306. package/dist/react/route-project.d.ts +7 -0
  307. package/dist/react/route-project.d.ts.map +1 -0
  308. package/dist/react/route-project.js +19 -0
  309. package/dist/react/route-project.js.map +1 -0
  310. package/dist/react/session-start-stash.d.ts +56 -0
  311. package/dist/react/session-start-stash.d.ts.map +1 -0
  312. package/dist/react/session-start-stash.js +202 -0
  313. package/dist/react/session-start-stash.js.map +1 -0
  314. package/dist/react/use-canonical-opencode-session.d.ts +35 -0
  315. package/dist/react/use-canonical-opencode-session.d.ts.map +1 -0
  316. package/dist/react/use-canonical-opencode-session.js +52 -0
  317. package/dist/react/use-canonical-opencode-session.js.map +1 -0
  318. package/dist/react/use-change-requests.d.ts +321 -0
  319. package/dist/react/use-change-requests.d.ts.map +1 -0
  320. package/dist/react/use-change-requests.js +43 -0
  321. package/dist/react/use-change-requests.js.map +1 -0
  322. package/dist/react/use-current-runtime.d.ts +8 -0
  323. package/dist/react/use-current-runtime.d.ts.map +1 -0
  324. package/dist/react/use-current-runtime.js +12 -0
  325. package/dist/react/use-current-runtime.js.map +1 -0
  326. package/dist/react/use-gateway-catalog-sync.d.ts +2 -0
  327. package/dist/react/use-gateway-catalog-sync.d.ts.map +1 -0
  328. package/dist/react/use-gateway-catalog-sync.js +39 -0
  329. package/dist/react/use-gateway-catalog-sync.js.map +1 -0
  330. package/dist/react/use-kortix-master.d.ts +384 -0
  331. package/dist/react/use-kortix-master.d.ts.map +1 -0
  332. package/dist/react/use-kortix-master.js +958 -0
  333. package/dist/react/use-kortix-master.js.map +1 -0
  334. package/dist/react/use-model-store.d.ts +71 -0
  335. package/dist/react/use-model-store.d.ts.map +1 -0
  336. package/dist/react/use-model-store.js +411 -0
  337. package/dist/react/use-model-store.js.map +1 -0
  338. package/dist/react/use-opencode-config.d.ts +15 -0
  339. package/dist/react/use-opencode-config.d.ts.map +1 -0
  340. package/dist/react/use-opencode-config.js +79 -0
  341. package/dist/react/use-opencode-config.js.map +1 -0
  342. package/dist/react/use-opencode-events/diagnostics.d.ts +11 -0
  343. package/dist/react/use-opencode-events/diagnostics.d.ts.map +1 -0
  344. package/dist/react/use-opencode-events/diagnostics.js +58 -0
  345. package/dist/react/use-opencode-events/diagnostics.js.map +1 -0
  346. package/dist/react/use-opencode-events/handle-event.d.ts +20 -0
  347. package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -0
  348. package/dist/react/use-opencode-events/handle-event.js +450 -0
  349. package/dist/react/use-opencode-events/handle-event.js.map +1 -0
  350. package/dist/react/use-opencode-events/helpers.d.ts +30 -0
  351. package/dist/react/use-opencode-events/helpers.d.ts.map +1 -0
  352. package/dist/react/use-opencode-events/helpers.js +93 -0
  353. package/dist/react/use-opencode-events/helpers.js.map +1 -0
  354. package/dist/react/use-opencode-events/index.d.ts +25 -0
  355. package/dist/react/use-opencode-events/index.d.ts.map +1 -0
  356. package/dist/react/use-opencode-events/index.js +242 -0
  357. package/dist/react/use-opencode-events/index.js.map +1 -0
  358. package/dist/react/use-opencode-events/types.d.ts +10 -0
  359. package/dist/react/use-opencode-events/types.d.ts.map +1 -0
  360. package/dist/react/use-opencode-events/types.js +2 -0
  361. package/dist/react/use-opencode-events/types.js.map +1 -0
  362. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +22 -0
  363. package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -0
  364. package/dist/react/use-opencode-events/use-event-stream-refs.js +158 -0
  365. package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -0
  366. package/dist/react/use-opencode-local.d.ts +139 -0
  367. package/dist/react/use-opencode-local.d.ts.map +1 -0
  368. package/dist/react/use-opencode-local.js +484 -0
  369. package/dist/react/use-opencode-local.js.map +1 -0
  370. package/dist/react/use-opencode-mcp.d.ts +34 -0
  371. package/dist/react/use-opencode-mcp.d.ts.map +1 -0
  372. package/dist/react/use-opencode-mcp.js +190 -0
  373. package/dist/react/use-opencode-mcp.js.map +1 -0
  374. package/dist/react/use-opencode-pty.d.ts +30 -0
  375. package/dist/react/use-opencode-pty.d.ts.map +1 -0
  376. package/dist/react/use-opencode-pty.js +126 -0
  377. package/dist/react/use-opencode-pty.js.map +1 -0
  378. package/dist/react/use-opencode-sessions/agents.d.ts +14 -0
  379. package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -0
  380. package/dist/react/use-opencode-sessions/agents.js +82 -0
  381. package/dist/react/use-opencode-sessions/agents.js.map +1 -0
  382. package/dist/react/use-opencode-sessions/commands.d.ts +8 -0
  383. package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -0
  384. package/dist/react/use-opencode-sessions/commands.js +46 -0
  385. package/dist/react/use-opencode-sessions/commands.js.map +1 -0
  386. package/dist/react/use-opencode-sessions/files.d.ts +2 -0
  387. package/dist/react/use-opencode-sessions/files.d.ts.map +1 -0
  388. package/dist/react/use-opencode-sessions/files.js +181 -0
  389. package/dist/react/use-opencode-sessions/files.js.map +1 -0
  390. package/dist/react/use-opencode-sessions/index.d.ts +15 -0
  391. package/dist/react/use-opencode-sessions/index.d.ts.map +1 -0
  392. package/dist/react/use-opencode-sessions/index.js +21 -0
  393. package/dist/react/use-opencode-sessions/index.js.map +1 -0
  394. package/dist/react/use-opencode-sessions/keys.d.ts +94 -0
  395. package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -0
  396. package/dist/react/use-opencode-sessions/keys.js +39 -0
  397. package/dist/react/use-opencode-sessions/keys.js.map +1 -0
  398. package/dist/react/use-opencode-sessions/mcp.d.ts +3 -0
  399. package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -0
  400. package/dist/react/use-opencode-sessions/mcp.js +23 -0
  401. package/dist/react/use-opencode-sessions/mcp.js.map +1 -0
  402. package/dist/react/use-opencode-sessions/messages.d.ts +75 -0
  403. package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -0
  404. package/dist/react/use-opencode-sessions/messages.js +319 -0
  405. package/dist/react/use-opencode-sessions/messages.js.map +1 -0
  406. package/dist/react/use-opencode-sessions/parts.d.ts +23 -0
  407. package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -0
  408. package/dist/react/use-opencode-sessions/parts.js +49 -0
  409. package/dist/react/use-opencode-sessions/parts.js.map +1 -0
  410. package/dist/react/use-opencode-sessions/permissions.d.ts +17 -0
  411. package/dist/react/use-opencode-sessions/permissions.d.ts.map +1 -0
  412. package/dist/react/use-opencode-sessions/permissions.js +66 -0
  413. package/dist/react/use-opencode-sessions/permissions.js.map +1 -0
  414. package/dist/react/use-opencode-sessions/projects.d.ts +5 -0
  415. package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -0
  416. package/dist/react/use-opencode-sessions/projects.js +54 -0
  417. package/dist/react/use-opencode-sessions/projects.js.map +1 -0
  418. package/dist/react/use-opencode-sessions/providers.d.ts +10 -0
  419. package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -0
  420. package/dist/react/use-opencode-sessions/providers.js +98 -0
  421. package/dist/react/use-opencode-sessions/providers.js.map +1 -0
  422. package/dist/react/use-opencode-sessions/sessions.d.ts +35 -0
  423. package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -0
  424. package/dist/react/use-opencode-sessions/sessions.js +380 -0
  425. package/dist/react/use-opencode-sessions/sessions.js.map +1 -0
  426. package/dist/react/use-opencode-sessions/shared.d.ts +43 -0
  427. package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -0
  428. package/dist/react/use-opencode-sessions/shared.js +109 -0
  429. package/dist/react/use-opencode-sessions/shared.js.map +1 -0
  430. package/dist/react/use-opencode-sessions/sharing.d.ts +4 -0
  431. package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -0
  432. package/dist/react/use-opencode-sessions/sharing.js +57 -0
  433. package/dist/react/use-opencode-sessions/sharing.js.map +1 -0
  434. package/dist/react/use-opencode-sessions/tools.d.ts +5 -0
  435. package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -0
  436. package/dist/react/use-opencode-sessions/tools.js +54 -0
  437. package/dist/react/use-opencode-sessions/tools.js.map +1 -0
  438. package/dist/react/use-permission-self-heal.d.ts +45 -0
  439. package/dist/react/use-permission-self-heal.d.ts.map +1 -0
  440. package/dist/react/use-permission-self-heal.js +144 -0
  441. package/dist/react/use-permission-self-heal.js.map +1 -0
  442. package/dist/react/use-project-config.d.ts +11 -0
  443. package/dist/react/use-project-config.d.ts.map +1 -0
  444. package/dist/react/use-project-config.js +22 -0
  445. package/dist/react/use-project-config.js.map +1 -0
  446. package/dist/react/use-project-models.d.ts +11 -0
  447. package/dist/react/use-project-models.d.ts.map +1 -0
  448. package/dist/react/use-project-models.js +25 -0
  449. package/dist/react/use-project-models.js.map +1 -0
  450. package/dist/react/use-project-secrets.d.ts +265 -0
  451. package/dist/react/use-project-secrets.d.ts.map +1 -0
  452. package/dist/react/use-project-secrets.js +41 -0
  453. package/dist/react/use-project-secrets.js.map +1 -0
  454. package/dist/react/use-project-triggers.d.ts +228 -0
  455. package/dist/react/use-project-triggers.d.ts.map +1 -0
  456. package/dist/react/use-project-triggers.js +42 -0
  457. package/dist/react/use-project-triggers.js.map +1 -0
  458. package/dist/react/use-question-self-heal.d.ts +36 -0
  459. package/dist/react/use-question-self-heal.d.ts.map +1 -0
  460. package/dist/react/use-question-self-heal.js +95 -0
  461. package/dist/react/use-question-self-heal.js.map +1 -0
  462. package/dist/react/use-runtime-phase.d.ts +9 -0
  463. package/dist/react/use-runtime-phase.d.ts.map +1 -0
  464. package/dist/react/use-runtime-phase.js +20 -0
  465. package/dist/react/use-runtime-phase.js.map +1 -0
  466. package/dist/react/use-runtime-reconnect.d.ts +90 -0
  467. package/dist/react/use-runtime-reconnect.d.ts.map +1 -0
  468. package/dist/react/use-runtime-reconnect.js +234 -0
  469. package/dist/react/use-runtime-reconnect.js.map +1 -0
  470. package/dist/react/use-session-picks.d.ts +17 -0
  471. package/dist/react/use-session-picks.d.ts.map +1 -0
  472. package/dist/react/use-session-picks.js +36 -0
  473. package/dist/react/use-session-picks.js.map +1 -0
  474. package/dist/react/use-session-prefetch.d.ts +18 -0
  475. package/dist/react/use-session-prefetch.d.ts.map +1 -0
  476. package/dist/react/use-session-prefetch.js +84 -0
  477. package/dist/react/use-session-prefetch.js.map +1 -0
  478. package/dist/react/use-session-send.d.ts +183 -0
  479. package/dist/react/use-session-send.d.ts.map +1 -0
  480. package/dist/react/use-session-send.js +287 -0
  481. package/dist/react/use-session-send.js.map +1 -0
  482. package/dist/react/use-session-sync.d.ts +24 -0
  483. package/dist/react/use-session-sync.d.ts.map +1 -0
  484. package/dist/react/use-session-sync.js +375 -0
  485. package/dist/react/use-session-sync.js.map +1 -0
  486. package/dist/react/use-session.d.ts +171 -0
  487. package/dist/react/use-session.d.ts.map +1 -0
  488. package/dist/react/use-session.js +396 -0
  489. package/dist/react/use-session.js.map +1 -0
  490. package/dist/react/use-visible-agents.d.ts +22 -0
  491. package/dist/react/use-visible-agents.d.ts.map +1 -0
  492. package/dist/react/use-visible-agents.js +45 -0
  493. package/dist/react/use-visible-agents.js.map +1 -0
  494. package/dist/server.d.ts +55 -0
  495. package/dist/server.d.ts.map +1 -0
  496. package/dist/server.js +122 -0
  497. package/dist/server.js.map +1 -0
  498. package/dist/session/health.d.ts +49 -0
  499. package/dist/session/health.d.ts.map +1 -0
  500. package/dist/session/health.js +57 -0
  501. package/dist/session/health.js.map +1 -0
  502. package/dist/session/index.d.ts +19 -0
  503. package/dist/session/index.d.ts.map +1 -0
  504. package/dist/session/index.js +19 -0
  505. package/dist/session/index.js.map +1 -0
  506. package/dist/session/preview.d.ts +24 -0
  507. package/dist/session/preview.d.ts.map +1 -0
  508. package/dist/session/preview.js +85 -0
  509. package/dist/session/preview.js.map +1 -0
  510. package/dist/session/url.d.ts +160 -0
  511. package/dist/session/url.d.ts.map +1 -0
  512. package/dist/session/url.js +522 -0
  513. package/dist/session/url.js.map +1 -0
  514. package/dist/state/chat-events.d.ts +141 -0
  515. package/dist/state/chat-events.d.ts.map +1 -0
  516. package/dist/state/chat-events.js +135 -0
  517. package/dist/state/chat-events.js.map +1 -0
  518. package/dist/state/current-runtime.d.ts +44 -0
  519. package/dist/state/current-runtime.d.ts.map +1 -0
  520. package/dist/state/current-runtime.js +44 -0
  521. package/dist/state/current-runtime.js.map +1 -0
  522. package/dist/state/diagnostics-store.d.ts +114 -0
  523. package/dist/state/diagnostics-store.d.ts.map +1 -0
  524. package/dist/state/diagnostics-store.js +319 -0
  525. package/dist/state/diagnostics-store.js.map +1 -0
  526. package/dist/state/event-stream.d.ts +134 -0
  527. package/dist/state/event-stream.d.ts.map +1 -0
  528. package/dist/state/event-stream.js +424 -0
  529. package/dist/state/event-stream.js.map +1 -0
  530. package/dist/state/idb-sync-cache.d.ts +18 -0
  531. package/dist/state/idb-sync-cache.d.ts.map +1 -0
  532. package/dist/state/idb-sync-cache.js +209 -0
  533. package/dist/state/idb-sync-cache.js.map +1 -0
  534. package/dist/state/opencode-compaction-store.d.ts +10 -0
  535. package/dist/state/opencode-compaction-store.d.ts.map +1 -0
  536. package/dist/state/opencode-compaction-store.js +32 -0
  537. package/dist/state/opencode-compaction-store.js.map +1 -0
  538. package/dist/state/opencode-pending-store.d.ts +19 -0
  539. package/dist/state/opencode-pending-store.d.ts.map +1 -0
  540. package/dist/state/opencode-pending-store.js +76 -0
  541. package/dist/state/opencode-pending-store.js.map +1 -0
  542. package/dist/state/sandbox-connection-store.d.ts +62 -0
  543. package/dist/state/sandbox-connection-store.d.ts.map +1 -0
  544. package/dist/state/sandbox-connection-store.js +290 -0
  545. package/dist/state/sandbox-connection-store.js.map +1 -0
  546. package/dist/state/server-store/active.d.ts +49 -0
  547. package/dist/state/server-store/active.d.ts.map +1 -0
  548. package/dist/state/server-store/active.js +76 -0
  549. package/dist/state/server-store/active.js.map +1 -0
  550. package/dist/state/server-store/types.d.ts +12 -0
  551. package/dist/state/server-store/types.d.ts.map +1 -0
  552. package/dist/state/server-store/types.js +2 -0
  553. package/dist/state/server-store/types.js.map +1 -0
  554. package/dist/state/server-store/url-helpers.d.ts +33 -0
  555. package/dist/state/server-store/url-helpers.d.ts.map +1 -0
  556. package/dist/state/server-store/url-helpers.js +55 -0
  557. package/dist/state/server-store/url-helpers.js.map +1 -0
  558. package/dist/state/server-store.d.ts +18 -0
  559. package/dist/state/server-store.d.ts.map +1 -0
  560. package/dist/state/server-store.js +23 -0
  561. package/dist/state/server-store.js.map +1 -0
  562. package/dist/state/session-runtime-registry.d.ts +49 -0
  563. package/dist/state/session-runtime-registry.d.ts.map +1 -0
  564. package/dist/state/session-runtime-registry.js +85 -0
  565. package/dist/state/session-runtime-registry.js.map +1 -0
  566. package/dist/state/sync-store/ascending-id.d.ts +2 -0
  567. package/dist/state/sync-store/ascending-id.d.ts.map +1 -0
  568. package/dist/state/sync-store/ascending-id.js +21 -0
  569. package/dist/state/sync-store/ascending-id.js.map +1 -0
  570. package/dist/state/sync-store/binary.d.ts +7 -0
  571. package/dist/state/sync-store/binary.d.ts.map +1 -0
  572. package/dist/state/sync-store/binary.js +21 -0
  573. package/dist/state/sync-store/binary.js.map +1 -0
  574. package/dist/state/sync-store/stream-cache.d.ts +2 -0
  575. package/dist/state/sync-store/stream-cache.d.ts.map +1 -0
  576. package/dist/state/sync-store/stream-cache.js +29 -0
  577. package/dist/state/sync-store/stream-cache.js.map +1 -0
  578. package/dist/state/sync-store/types.d.ts +29 -0
  579. package/dist/state/sync-store/types.d.ts.map +1 -0
  580. package/dist/state/sync-store/types.js +2 -0
  581. package/dist/state/sync-store/types.js.map +1 -0
  582. package/dist/state/sync-store.d.ts +39 -0
  583. package/dist/state/sync-store.d.ts.map +1 -0
  584. package/dist/state/sync-store.js +692 -0
  585. package/dist/state/sync-store.js.map +1 -0
  586. package/dist/state/tab-store.d.ts +91 -0
  587. package/dist/state/tab-store.d.ts.map +1 -0
  588. package/dist/state/tab-store.js +369 -0
  589. package/dist/state/tab-store.js.map +1 -0
  590. package/dist/transcript.d.ts +40 -0
  591. package/dist/transcript.d.ts.map +1 -0
  592. package/dist/transcript.js +126 -0
  593. package/dist/transcript.js.map +1 -0
  594. package/dist/turns/classify.d.ts +166 -0
  595. package/dist/turns/classify.d.ts.map +1 -0
  596. package/dist/turns/classify.js +259 -0
  597. package/dist/turns/classify.js.map +1 -0
  598. package/dist/turns/errors.d.ts +11 -0
  599. package/dist/turns/errors.d.ts.map +1 -0
  600. package/dist/turns/errors.js +85 -0
  601. package/dist/turns/errors.js.map +1 -0
  602. package/dist/turns/index.d.ts +264 -0
  603. package/dist/turns/index.d.ts.map +1 -0
  604. package/dist/turns/index.js +1243 -0
  605. package/dist/turns/index.js.map +1 -0
  606. package/dist/turns/tool-registry.d.ts +33 -0
  607. package/dist/turns/tool-registry.d.ts.map +1 -0
  608. package/dist/turns/tool-registry.js +108 -0
  609. package/dist/turns/tool-registry.js.map +1 -0
  610. package/dist/turns/types.d.ts +125 -0
  611. package/dist/turns/types.d.ts.map +1 -0
  612. package/dist/turns/types.js +12 -0
  613. package/dist/turns/types.js.map +1 -0
  614. package/dist/turns/view-model.d.ts +127 -0
  615. package/dist/turns/view-model.d.ts.map +1 -0
  616. package/dist/turns/view-model.js +401 -0
  617. package/dist/turns/view-model.js.map +1 -0
  618. package/package.json +155 -0
package/README.md ADDED
@@ -0,0 +1,313 @@
1
+ # @kortix/sdk
2
+
3
+ The **single, opinionated data layer** for the Kortix agent platform. One typed
4
+ client wraps both the **Kortix REST API** and the **OpenCode v2 runtime** so a
5
+ host app — web, mobile, reference — imports **only `@kortix/sdk`** and never
6
+ `@opencode-ai/sdk` directly. (The no-raw-`backendApi`/`authenticatedFetch` rule
7
+ below is the target state, not yet fully true of apps/web — see Rules of the
8
+ road.)
9
+
10
+ > Philosophy: **one Kortix token, one client, every action a method.** Keys never
11
+ > leave the server; mutations own their side-effects there; the host states intent.
12
+
13
+ 📖 **Full documentation:** [kortix.com/docs/sdk](https://kortix.com/docs/sdk) —
14
+ getting started, the full client, sessions, React hooks, and the subpath modules.
15
+ The REST API has an auto-generated reference at
16
+ [api.kortix.com/v1/docs](https://api.kortix.com/v1/docs).
17
+
18
+ ---
19
+
20
+ ## Quick start
21
+
22
+ ```ts
23
+ import { createKortix } from '@kortix/sdk';
24
+
25
+ const kortix = createKortix({
26
+ backendUrl: 'https://api.kortix.ai/v1',
27
+ getToken: () => supabase.auth.getSession().then(s => s.data.session?.access_token ?? null),
28
+ });
29
+
30
+ // Projects
31
+ const projects = await kortix.projects.list();
32
+ const detail = await kortix.project(pid).detail();
33
+ await kortix.project(pid).secrets.upsert({ name: 'STRIPE_API_KEY', value });
34
+
35
+ // Sessions (id-bound handle)
36
+ const s = kortix.session(pid, sid);
37
+ await s.send('Build me a widget'); // provisions/resumes if needed, then prompts
38
+ await s.previews();
39
+
40
+ // Lower level: the typed opencode client for THIS session's runtime.
41
+ // `.runtime` throws until the runtime is resolved, and the runtime is keyed by
42
+ // the OpenCode session id (NOT the Kortix `sid`) — resolve both via ensureReady.
43
+ const { opencodeSessionId } = await s.ensureReady();
44
+ await s.runtime.session.prompt({ sessionID: opencodeSessionId, parts });
45
+ ```
46
+
47
+ ## The facade surface
48
+
49
+ `createKortix(config)` returns one client. The table below is illustrative, not
50
+ exhaustive — see `API-MAP.md` for the full per-domain surface:
51
+
52
+ | namespace | what |
53
+ |---|---|
54
+ | `kortix.projects` | list · get · detail · create · provision · update · archive · llmCatalog · sandboxTemplates · sessions (+ more: `listForAccount`, `sandboxHealth`, `createSession`) |
55
+ | `kortix.accounts` | list · get · create · members · invites · `tokens.{list,create,revoke}` (account-scoped CLI PATs, `kortix_pat_…`) · `audit.{log,export,webhooks.*}` (Enterprise audit trail) (+ more: `updateName`, `leave`, `invite`, `removeMember`, `updateMemberRole`) |
56
+ | `kortix.billing` | entitlement/usage reads: `accountState` · `accountStateMinimal` · `transactions` · `transactionsSummary` · `creditBreakdown` · `usageHistory` · `tierConfigurations` — plus a curated mutation surface: `checkout.{createSession,confirmSession}` · `subscription.{createPortalSession,cancel,reactivate,scheduleDowngrade,cancelScheduledChange,prorationPreview}` · `credits.{purchase,autoTopupSettings,configureAutoTopup}` |
57
+ | `kortix.marketplace` | public marketplace catalog browse + sources (not project-scoped): `items` · `item` · `itemFile` · `marketplaces` · `featured` · `sources.{list,add,remove}` — distinct from the install-scoped `project(id).marketplace` |
58
+ | `kortix.validateToken()` | pasted-API-key validation helper — `GET /accounts/me`, never throws, resolves `{valid, identity?, error?}` |
59
+ | `kortix.project(id)` | id-bound handle: `.secrets` · `.access` · `.connectors` · `.policies` · `.triggers` · `.files` · `.git` · `.changeRequests` (incl. `requestChanges`) · `.sessions` · `.tokens` (project-scoped CLI PATs — the `KORTIX_TOKEN` shape) · `.marketplace` / `.registry` (install/update/remove catalog items) · `.setupLinks.{requestSecret,requestConnector}` (agent-minted secret-entry / connector links) · `.validateManifest` · `.gitToken` · `.session(sid)` (+ more namespaces: `.review`, `.approvals`, `.gateway` (incl. `.playground`), `.channels`, `.apps`, `.modelDefaults`, `.sandbox`) |
60
+ | `kortix.session(pid, sid)` | id-bound handle: lifecycle (`get`/`update`/`delete`/`start`/`restart`/`stop`/`setSharing`/`previews`/`commit`/`publicShares`/`ensureReady`) · `send`/`abort`/`setModel`/`setAgent` (opinionated prompt wrappers) · `stream()` (live SSE, framework-free) · `transcript()` (compact server-side transcript read) · `.files` (the 12-op workspace-files surface, bound to THIS session's own runtime) · **its own runtime** (`health`/`previewUrl`/`proxyUrl` — sandbox resolved for you) + `.runtime` (the typed opencode client) |
61
+ | `kortix.runtime()` | the opencode v2 client for the active sandbox (escape hatch) |
62
+
63
+ Runnable, self-contained scripts for the highest-value flows live in
64
+ [`examples/`](./examples): list projects with a PAT, send + stream, the
65
+ multi-tenant server-wrapper pattern, headless transcript rendering, cost
66
+ pass-through / re-billing, and session files + project secrets. Each file's
67
+ header comment states the env vars and the exact `bun run examples/….ts`
68
+ invocation.
69
+
70
+ `session.stream()` is a thin facade over the framework-free `openEventStream`
71
+ primitive (also exported directly, for hosts that want to manage the client
72
+ themselves): it resolves THIS handle's own runtime (`ensureReady()`), connects
73
+ to that runtime's SSE endpoint, and hands you a `close()`-able handle. No React
74
+ required — safe to call from a server-side "Kortix as a Backend" wrapper
75
+ (Node/Bun), a worker, or a CLI:
76
+
77
+ ```ts
78
+ const handle = await kortix.session(pid, sid).stream({
79
+ onEvent: (event) => console.log(event.type, event),
80
+ onGapRehydrate: (gapMs) => console.warn(`reconnected after a ${gapMs}ms gap`),
81
+ });
82
+ // later, to stop:
83
+ handle.close();
84
+ ```
85
+
86
+ `@kortix/sdk/react`'s `useOpenCodeEventStream` uses the exact same primitive
87
+ under the hood — it just also writes into the React Query cache.
88
+
89
+ ## Kortix as a Backend (server-side)
90
+
91
+ `createKortix()` stores its config — crucially, the bearer-token getter — in a
92
+ process-wide singleton. That's correct for a host with one config for its whole
93
+ lifetime (a browser tab, a CLI, a single-tenant server), but **unsafe for a
94
+ server process handling concurrent requests for different end users**: two
95
+ in-flight requests racing through `createKortix()`/`configureKortix()` with
96
+ different tokens clobber each other, and the last write wins for every other
97
+ in-flight request.
98
+
99
+ `@kortix/sdk/server` (Node/Bun only — never import it from a browser bundle;
100
+ it statically imports `node:async_hooks`) fixes this with `AsyncLocalStorage`:
101
+
102
+ ```ts
103
+ import { createScopedKortix } from '@kortix/sdk/server';
104
+
105
+ // Express/Hono/Bun.serve — any per-request handler. One scoped client PER
106
+ // REQUEST; each end user's token stays isolated to that request's own async
107
+ // call tree, even across `await`s, even under concurrency.
108
+ app.get('/projects', async (req, res) => {
109
+ const kortix = createScopedKortix({
110
+ backendUrl: process.env.KORTIX_API_URL!,
111
+ getToken: async () => resolveKortixTokenFor(req), // per-end-user PAT/token
112
+ });
113
+ res.json(await kortix.projects.list());
114
+ });
115
+ ```
116
+
117
+ `createScopedKortix(config)` has the same shape as `createKortix(config)` —
118
+ every method call (including calls through `.project(id)` / `.session(pid, sid)`
119
+ handles minted at call time) automatically runs inside that config's scope, and
120
+ it never writes the process-global singleton. For middleware-style wrapping of
121
+ an entire request body instead, use the lower-level primitive:
122
+
123
+ ```ts
124
+ import { runWithKortix } from '@kortix/sdk/server';
125
+
126
+ app.use(async (req, res, next) => {
127
+ await runWithKortix(
128
+ { backendUrl, getToken: async () => resolveKortixTokenFor(req) },
129
+ async () => {
130
+ await next(); // every Kortix call anywhere in this request sees THIS config
131
+ },
132
+ );
133
+ });
134
+ ```
135
+
136
+ A runnable version of the pattern is `examples/03-server-wrapper.ts`, and the
137
+ full production-shaped reference (per-user project isolation, route policy,
138
+ rate limiting, cost markup for re-billing) is `apps/whitelabel-demo` in wrapper
139
+ mode — see its README.
140
+
141
+ ## Rendering chat (the headless chat kit)
142
+
143
+ Everything needed to render an agent transcript without adopting any Kortix
144
+ UI: `classifyPart`/`classifyTurn` (`@kortix/sdk/turns`, framework-free)
145
+ normalize all twelve opencode part types (text, reasoning, tool, file,
146
+ subtask, patch, snapshot, agent, retry, compaction, step, + a forward-compat
147
+ `unknown`) into a typed `ClassifiedPart`, and normalize a failed assistant
148
+ turn's `info.error` into a `{ name, message }` `TurnError` — so "assistant
149
+ message with zero parts but an error" renders as a failure, not silence.
150
+ `renderParts` (`@kortix/sdk/react`, though it has no React import) requires a
151
+ renderer for **every** part kind at compile time, so a new part type is a
152
+ build error at your call site instead of a silent drop in production:
153
+
154
+ ```tsx
155
+ import { renderParts, type PartRenderers } from '@kortix/sdk/react';
156
+ import { classifyTurn } from '@kortix/sdk/turns';
157
+
158
+ const renderers: PartRenderers<React.ReactNode> = {
159
+ text: (p) => <Markdown>{p.text}</Markdown>,
160
+ reasoning: (p) => <Thinking text={p.text} />,
161
+ tool: (p) => <ToolCard name={p.tool.name} status={p.tool.status} />,
162
+ file: (p) => <Attachment name={p.filename ?? p.url} />,
163
+ subtask: (p) => <Delegated agent={p.agent} />,
164
+ patch: (p) => <DiffStat files={p.fileCount} />,
165
+ retry: (p) => <Note>{`retrying (attempt ${p.attempt})`}</Note>,
166
+ compaction: () => <Note>context compacted</Note>,
167
+ snapshot: () => null, // internal checkpoint hash — nothing to show
168
+ agent: () => null, // inline @mention, already in the sibling text
169
+ step: () => null, // model-step bookkeeping
170
+ unknown: () => null, // forward-compat: newer server than client
171
+ };
172
+
173
+ function Turn({ message }: { message: MessageWithParts }) {
174
+ const { parts, error, isEmpty } = classifyTurn(message);
175
+ if (isEmpty && !error) return null;
176
+ return <>{renderParts(parts, renderers)}{error && <TurnFailed {...error} />}</>;
177
+ }
178
+ ```
179
+
180
+ The living reference is
181
+ `apps/whitelabel-demo/src/components/chat/message-view.tsx` — one deliberate
182
+ rendering decision per part kind, with the rationale for each `null`. For a
183
+ memoized message-list binding use `useChatTurns(messages)` (`@kortix/sdk/react`);
184
+ for a no-React plain-text version of the same classification see
185
+ `examples/04-render-transcript.ts`. On the live side, `narrowChatEvent`
186
+ (root barrel) narrows the raw ~50-variant SSE union from `session.stream()` /
187
+ `openEventStream` down to the curated `KortixChatEvent` union (~14 members) a
188
+ chat UI actually dispatches on.
189
+
190
+ ## Errors
191
+
192
+ One typed hierarchy, produced by **every** HTTP layer — `backendApi`, the
193
+ platform client's `platformFetch`, `authenticatedFetch`, the files client, the
194
+ opencode client, and `ensureReady()` all throw/return the same classes (from
195
+ the root barrel or `@kortix/sdk/api-client`; `@kortix/sdk/react` re-exports
196
+ them too). They're real classes: `instanceof` works across every host, and
197
+ `name`/shape are preserved for legacy `error.name === 'ApiError'` sniffers.
198
+
199
+ - `ApiError` — any failed request; branch on `.status` / `.code` (e.g.
200
+ `'TIMEOUT'`, `'RUNTIME_UNAVAILABLE'`, `'ABORTED'`). Timeout errors carry
201
+ `.url` / `.endpoint` / `.timeout`.
202
+ - `AuthError extends ApiError` — `getToken()` returned null; the request was
203
+ never sent (`code: 'NO_SESSION'`).
204
+ - `BillingError` — HTTP 402, with the backend's payload on `.detail`.
205
+ - `RequestTooLargeError` — HTTP 431 (usually a too-large upload batch), with a
206
+ `.detail.suggestion`.
207
+ - `SessionNotReadyError` (root barrel) — a session handle's runtime-scoped
208
+ member (`.runtime`, `.previewUrl()`, `.proxyUrl()`) was touched before
209
+ `ensureReady()` resolved this session's own sandbox.
210
+
211
+ The canonical server-side wrapper shape — catch a 402 and pass the payload
212
+ through to your own client for re-billing, instead of leaking a Kortix error:
213
+
214
+ ```ts
215
+ import { ApiError, AuthError, BillingError } from '@kortix/sdk';
216
+
217
+ try {
218
+ await kortix.session(pid, sid).send(prompt);
219
+ } catch (err) {
220
+ if (err instanceof BillingError) {
221
+ // 402 — surface the upgrade/cost payload under YOUR billing story.
222
+ return res.status(402).json({ reason: 'quota', detail: err.detail });
223
+ }
224
+ if (err instanceof AuthError) return res.status(401).json({ error: 'not authenticated' });
225
+ if (err instanceof ApiError) return res.status(err.status ?? 502).json({ error: err.message });
226
+ throw err;
227
+ }
228
+ ```
229
+
230
+ Every non-streaming request also carries a **30s default timeout** (the
231
+ long-lived SSE event stream is exempt), so a hung sandbox/daemon call can't
232
+ wedge a server-side handler forever — it surfaces as an `ApiError` with
233
+ `code: 'TIMEOUT'` instead.
234
+
235
+ ## Subpath modules
236
+
237
+ Stable, tree-shakeable surfaces (also reachable via the facade). Not exhaustive
238
+ — see `package.json`'s `exports` field for the complete list (it also includes
239
+ `./config`, `./api-client`, `./feature-flags`, `./fresh-sessions`,
240
+ `./instance-routes`, `./opencode-errors`, `./platform-client`, `./event-stream`,
241
+ `./sandbox-connection-store`, `./opencode-pending-store`, `./session/url`,
242
+ `./idb-sync-cache`):
243
+
244
+ | import | provides |
245
+ |---|---|
246
+ | `@kortix/sdk` | `createKortix`, `configureKortix`, `files`, the error classes, `classifyPart`/`classifyTurn`, `narrowChatEvent`, `openEventStream`, domain result types |
247
+ | `@kortix/sdk/server` | **Node/Bun only** — `runWithKortix`, `createScopedKortix`, `getScopedConfig` (per-request config isolation; see "Kortix as a Backend") |
248
+ | `@kortix/sdk/react` | every `useOpenCode*` hook + providers (reactive data), `useSession`, `useChatTurns`/`renderParts`, domain hooks (`useProjectSecrets`/`useProjectTriggers`/`useChangeRequests`) |
249
+ | `@kortix/sdk/turns` | framework-free part/turn classification (`classifyPart`, `classifyTurn`, `toolInfo`, turn grouping/cost helpers) |
250
+ | `@kortix/sdk/files` | workspace file ops (daemon `/file` + `/find`): `listFiles`, `readFile`, `readBlob`, `getFileStatus`, `findFiles`, `findText`, `uploadFile`, `deleteFile`, `mkdir`, `renameFile`, … |
251
+ | `@kortix/sdk/session` | a session's runtime surface — `getSessionHealth`/`isRuntimeReady` + proxy/preview URL builders (`rewriteLocalhostUrl`, `proxyLocalhostUrl`, `detectLocalhostUrls`, …) + preview-auth helpers. **No "sandbox" in the public surface** — a session owns its runtime |
252
+ | `@kortix/sdk/opencode-client` | `getClient`, `getClientForUrl` + the **full opencode v2 type surface** (`Event`, `Part`, `Message`, `Session`, `Pty`, `Config`, …) |
253
+ | `@kortix/sdk/projects-client` | the raw REST functions (the facade wraps these) |
254
+ | `@kortix/sdk/auth` | `authenticatedFetch`, token accessors |
255
+ | `@kortix/sdk/api-client` | the raw `backendApi` primitive — host code should go through the facade or another subpath module instead of calling this directly |
256
+ | `@kortix/sdk/server-store` · `@kortix/sdk/sync-store` | active-sandbox state · live message/part/status store |
257
+
258
+ ## Configuration
259
+
260
+ `configureKortix(config)` (called for you by `createKortix`) wires one seam:
261
+
262
+ ```ts
263
+ interface KortixPlatformConfig {
264
+ backendUrl: string;
265
+ getToken: () => Promise<string | null>;
266
+ getUserId?: () => Promise<string | null>;
267
+ billingEnabled?: boolean;
268
+ sandboxId?: string | null;
269
+ onError?: (error: unknown, context?: unknown) => void;
270
+ onToast?: (level, message, options?) => void;
271
+ onNotify?: (event) => void;
272
+ featureFlags?: KortixFeatureFlagOverrides; // per-flag overrides for non-Next.js hosts
273
+ }
274
+ ```
275
+
276
+ The SDK is host-agnostic: no Next.js / web coupling in the core. The host injects
277
+ its token getter and toast/notify sinks; the SDK does the rest. Today that's proven
278
+ in React DOM (`apps/web` and the `apps/whitelabel-demo` reference app are the
279
+ `configureKortix`/`@kortix/sdk/react` consumers).
280
+ The framework-free core modules — `turns`, `session/url`, `session` (health),
281
+ `projects-client`, `files`, `transcript` — have no React or DOM dependency and are
282
+ usable from any JS host; `apps/mobile` already imports `@kortix/sdk/turns` this way.
283
+ React Native adoption of the full client/hooks is planned but not done — mobile
284
+ currently ships its own parallel data layer (`apps/mobile/lib/opencode/`) rather
285
+ than `@kortix/sdk/react`.
286
+
287
+ ## Rules of the road
288
+
289
+ - **No `@opencode-ai/sdk` in host code.** Import opencode types/client from
290
+ `@kortix/sdk/opencode-client`. The SDK is the sole owner of that dependency.
291
+ (Holds today — no host imports it.)
292
+ - **No raw `backendApi` / `authenticatedFetch` in host code.** Use the facade or a
293
+ subpath module. (Aspirational: apps/web still calls `backendApi` via its
294
+ `@/lib/api-client` re-export in ~30 files and keeps a parallel
295
+ `authenticatedFetch` in `apps/web/src/lib/auth-token.ts` — migration pending.)
296
+ - **React data** comes from `@kortix/sdk/react` hooks; **imperative actions** from
297
+ the `createKortix` facade.
298
+
299
+ ## Auth
300
+
301
+ `Authorization: Bearer <token>` — a Supabase JWT (user sessions) or a Kortix PAT
302
+ (`kortix_pat_…`) for server-side / automation use, supplied via `getToken`.
303
+
304
+ ## Tests
305
+
306
+ ```sh
307
+ pnpm --filter @kortix/sdk typecheck # package + examples/ (examples/tsconfig.json)
308
+ pnpm --filter @kortix/sdk test # facade, files, react hooks, turns, transcript, session url/health, projects-client domains
309
+ ```
310
+
311
+ See **`API-MAP.md`** for the complete endpoint catalogue (REST + opencode runtime)
312
+ and per-domain SDK coverage status, and **`CHANGELOG.md`** for what changed per
313
+ release.
@@ -0,0 +1,96 @@
1
+ import type { FileContent, FileNode, FindMatch, GitFileStatus, OpenCodeProjectInfo, ServerHealth, UploadResult } from './types.js';
2
+ export type * from './types.js';
3
+ /**
4
+ * Sandbox filesystem roots the daemon serves (mirrors DEFAULT_ALLOWED_ROOTS in
5
+ * kortix-sandbox-agent-server). The daemon re-validates every path server-side;
6
+ * this mirror only keeps hosts from mangling non-workspace paths client-side.
7
+ */
8
+ export declare const SANDBOX_FS_ROOTS: readonly ["/workspace", "/tmp", "/home", "/opt"];
9
+ /** Whether a path is absolute under one of the daemon's allowed roots. */
10
+ export declare function isUnderSandboxRoot(filePath: string): boolean;
11
+ /**
12
+ * Resolve any host path to an absolute sandbox path — paths already under an
13
+ * allowed root pass through, everything else anchors beneath /workspace.
14
+ */
15
+ export declare function toSandboxAbsolutePath(filePath: string): string;
16
+ /**
17
+ * Convert a host path to the daemon query path. /workspace paths become
18
+ * worktree-relative ("" = root); the other allowed roots (/tmp, /home, /opt)
19
+ * stay absolute — the daemon resolves absolutes against its own allow-list.
20
+ * Any other absolute path keeps the legacy leading-slash strip, so
21
+ * "/README.md"-style pseudo-relative paths still resolve under /workspace.
22
+ */
23
+ export declare function toDaemonPath(filePath: string): string;
24
+ /** @deprecated Use {@link toDaemonPath} — non-workspace roots now pass through absolute. */
25
+ export declare const toWorkspaceRelative: typeof toDaemonPath;
26
+ /**
27
+ * List files/directories at a path. Daemon `GET /file`. `baseUrl` defaults to
28
+ * the module-global "active" sandbox; pass one explicitly to target a
29
+ * specific session's runtime (see `kortix.session(pid, sid).files`).
30
+ */
31
+ export declare function listFiles(dirPath: string, baseUrl?: string): Promise<FileNode[]>;
32
+ /** Read a file's content (text, or base64 for binaries). Daemon `GET /file/content`. */
33
+ export declare function readFile(filePath: string, baseUrl?: string): Promise<FileContent>;
34
+ /** Read a file as a Blob — prefers `/file/raw`, falls back to base64 `/file/content`. */
35
+ export declare function readBlob(filePath: string, baseUrl?: string): Promise<Blob>;
36
+ /** Git file status — uncommitted changes. Daemon `GET /file/status`. */
37
+ export declare function getFileStatus(baseUrl?: string): Promise<GitFileStatus[]>;
38
+ /**
39
+ * Find files/directories by name (fuzzy). Daemon `GET /find/file`.
40
+ *
41
+ * Throws `ApiError` on failure — like every other op in this module. This
42
+ * USED TO swallow every failure to `[]`, which silently hid daemon/network
43
+ * errors from callers. The only real caller of this SDK export
44
+ * (`apps/web/src/features/files/search/workspace-search-service.ts`) already
45
+ * wraps each call in its own `.catch(() => [])`, and there are no callers
46
+ * under `@kortix/sdk/react`, so removing the internal swallow here is
47
+ * non-breaking — verified by grepping every `findFiles(` call site in the
48
+ * monorepo before making this change.
49
+ */
50
+ export declare function findFiles(query: string, options?: {
51
+ type?: 'file' | 'directory';
52
+ limit?: number;
53
+ }, baseUrl?: string): Promise<string[]>;
54
+ /** Ripgrep text search. Daemon `GET /find`. Tolerates flat + nested rg-JSON. */
55
+ export declare function findText(pattern: string, baseUrl?: string): Promise<FindMatch[]>;
56
+ /**
57
+ * Upload a file. Daemon `POST /file/upload`. `baseUrl` defaults to the
58
+ * module-global "active" sandbox; pass one explicitly to target a specific
59
+ * session's runtime.
60
+ */
61
+ export declare function uploadFile(file: File | Blob, targetPath?: string, filename?: string, baseUrl?: string): Promise<UploadResult[]>;
62
+ /** Create an empty file at a path. */
63
+ export declare function createFile(filePath: string, baseUrl?: string): Promise<UploadResult[]>;
64
+ /** Copy a file (read source bytes → upload to dest). */
65
+ export declare function copyFile(sourcePath: string, destPath: string, baseUrl?: string): Promise<UploadResult[]>;
66
+ /** Delete a file/dir (recursive). Daemon `DELETE /file`. */
67
+ export declare function deleteFile(filePath: string, baseUrl?: string): Promise<boolean>;
68
+ /** Create a directory (recursive, idempotent). Daemon `POST /file/mkdir`. */
69
+ export declare function mkdir(dirPath: string, baseUrl?: string): Promise<boolean>;
70
+ /** Rename/move a file or directory. Daemon `POST /file/rename`. */
71
+ export declare function renameFile(from: string, to: string, baseUrl?: string): Promise<boolean>;
72
+ export declare function getCurrentProject(): Promise<OpenCodeProjectInfo>;
73
+ export declare function getServerHealth(): Promise<ServerHealth>;
74
+ export declare function isServerReachable(): Promise<boolean>;
75
+ /** Grouped namespace for ergonomic use (also available as named exports). */
76
+ export declare const files: {
77
+ list: typeof listFiles;
78
+ read: typeof readFile;
79
+ readBlob: typeof readBlob;
80
+ status: typeof getFileStatus;
81
+ findFiles: typeof findFiles;
82
+ findText: typeof findText;
83
+ upload: typeof uploadFile;
84
+ create: typeof createFile;
85
+ copy: typeof copyFile;
86
+ remove: typeof deleteFile;
87
+ mkdir: typeof mkdir;
88
+ rename: typeof renameFile;
89
+ currentProject: typeof getCurrentProject;
90
+ health: typeof getServerHealth;
91
+ isReachable: typeof isServerReachable;
92
+ toDaemonPath: typeof toDaemonPath;
93
+ toSandboxAbsolutePath: typeof toSandboxAbsolutePath;
94
+ toWorkspaceRelative: typeof toDaemonPath;
95
+ };
96
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/files/client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAIjB,mBAAmB,SAAS,CAAC;AA8C7B;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kDAAmD,CAAC;AAIjF,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,qBAAe,CAAC;AAEhD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAI9G;AAED,wFAAwF;AACxF,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,WAAW,CAAC,CAO/G;AAwBD,yFAAyF;AACzF,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAUxG;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAEhG;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACzD,OAAO,GAAE,MAA+B,GACvC,OAAO,CAAC,MAAM,EAAE,CAAC,CAKnB;AAED,gFAAgF;AAChF,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAS9G;AA+CD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE,MAA+B,GACvC,OAAO,CAAC,YAAY,EAAE,CAAC,CAYzB;AAmBD,sCAAsC;AACtC,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAO9G;AAED,wDAAwD;AACxD,wBAAsB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtI;AAED,4DAA4D;AAC5D,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,OAAO,CAAC,CAU7G;AAED,6EAA6E;AAC7E,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,OAAO,CAAC,CAUvG;AAED,mEAAmE;AACnE,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,MAA+B,GAAG,OAAO,CAAC,OAAO,CAAC,CAUrH;AAGD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAEtE;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAE7D;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAM1D;AAED,6EAA6E;AAC7E,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;CAmBjB,CAAC"}