@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,126 @@
1
+ /**
2
+ * Session transcript formatter — converts session messages into Markdown.
3
+ * Pure (no DOM deps) so any host — web, mobile, CLI — can export a transcript.
4
+ *
5
+ * Ported from the OpenCode TUI:
6
+ * packages/opencode/src/cli/cmd/tui/util/transcript.ts
7
+ */
8
+ export const DEFAULT_TRANSCRIPT_OPTIONS = {
9
+ thinking: false,
10
+ toolDetails: true,
11
+ assistantMetadata: true,
12
+ };
13
+ // ============================================================================
14
+ // Helpers
15
+ // ============================================================================
16
+ function titleCase(str) {
17
+ if (!str)
18
+ return str;
19
+ return str.charAt(0).toUpperCase() + str.slice(1);
20
+ }
21
+ function formatDuration(ms) {
22
+ const seconds = ms / 1000;
23
+ if (seconds < 60)
24
+ return `${seconds.toFixed(1)}s`;
25
+ const minutes = Math.floor(seconds / 60);
26
+ const remaining = seconds % 60;
27
+ return `${minutes}m ${remaining.toFixed(0)}s`;
28
+ }
29
+ // ============================================================================
30
+ // Format individual parts
31
+ // ============================================================================
32
+ function formatPart(part, options) {
33
+ if (part.type === 'text' && !('synthetic' in part && part.synthetic)) {
34
+ return `${part.text}\n\n`;
35
+ }
36
+ if (part.type === 'reasoning') {
37
+ if (options.thinking) {
38
+ return `> _Thinking:_\n>\n> ${(part.text || '').replace(/\n/g, '\n> ')}\n\n`;
39
+ }
40
+ return '';
41
+ }
42
+ if (part.type === 'tool') {
43
+ const toolPart = part;
44
+ let result = `**Tool: ${toolPart.tool}**\n`;
45
+ if (options.toolDetails && toolPart.state?.input) {
46
+ try {
47
+ const inputStr = typeof toolPart.state.input === 'string'
48
+ ? toolPart.state.input
49
+ : JSON.stringify(toolPart.state.input, null, 2);
50
+ result += `\n<details>\n<summary>Input</summary>\n\n\`\`\`json\n${inputStr}\n\`\`\`\n\n</details>\n`;
51
+ }
52
+ catch {
53
+ // skip malformed input
54
+ }
55
+ }
56
+ if (options.toolDetails && toolPart.state?.status === 'completed' && toolPart.state?.output) {
57
+ const output = toolPart.state.output;
58
+ const truncated = output.length > 2000 ? output.slice(0, 2000) + '\n... (truncated)' : output;
59
+ result += `\n<details>\n<summary>Output</summary>\n\n\`\`\`\n${truncated}\n\`\`\`\n\n</details>\n`;
60
+ }
61
+ if (options.toolDetails && toolPart.state?.status === 'error' && toolPart.state?.error) {
62
+ result += `\n**Error:**\n\`\`\`\n${toolPart.state.error}\n\`\`\`\n`;
63
+ }
64
+ result += '\n';
65
+ return result;
66
+ }
67
+ // skip other part types (step-start, step-finish, snapshot, patch, agent, etc.)
68
+ return '';
69
+ }
70
+ // ============================================================================
71
+ // Format a single message
72
+ // ============================================================================
73
+ function formatAssistantHeader(msg, includeMetadata) {
74
+ if (!includeMetadata)
75
+ return `## Assistant\n\n`;
76
+ const agent = msg.agent ? titleCase(msg.agent) : 'Assistant';
77
+ const model = msg.modelID || '';
78
+ let duration = '';
79
+ if (msg.time?.completed && msg.time?.created) {
80
+ duration = formatDuration(msg.time.completed - msg.time.created);
81
+ }
82
+ const meta = [model, duration].filter(Boolean).join(' · ');
83
+ return meta
84
+ ? `## ${agent} (${meta})\n\n`
85
+ : `## ${agent}\n\n`;
86
+ }
87
+ function formatMessage(msg, parts, options) {
88
+ let result = '';
89
+ if (msg.role === 'user') {
90
+ result += `## User\n\n`;
91
+ }
92
+ else {
93
+ result += formatAssistantHeader(msg, options.assistantMetadata);
94
+ }
95
+ for (const part of parts) {
96
+ result += formatPart(part, options);
97
+ }
98
+ return result;
99
+ }
100
+ // ============================================================================
101
+ // Main export
102
+ // ============================================================================
103
+ /**
104
+ * Format an entire session as a Markdown transcript.
105
+ */
106
+ export function formatTranscript(session, messages, options = DEFAULT_TRANSCRIPT_OPTIONS) {
107
+ let transcript = `# ${session.title || 'Untitled Session'}\n\n`;
108
+ transcript += `**Session ID:** \`${session.id}\`\n`;
109
+ transcript += `**Created:** ${new Date(session.time.created).toLocaleString()}\n`;
110
+ transcript += `**Updated:** ${new Date(session.time.updated).toLocaleString()}\n\n`;
111
+ transcript += `---\n\n`;
112
+ for (const msg of messages) {
113
+ transcript += formatMessage(msg.info, msg.parts, options);
114
+ transcript += `---\n\n`;
115
+ }
116
+ return transcript;
117
+ }
118
+ /**
119
+ * Generate a default filename for the transcript.
120
+ * Always keyed off the session id so the file is stable and unambiguous
121
+ * (e.g. `session-<uuid>.md`) rather than a mutable, collision-prone title slug.
122
+ */
123
+ export function getTranscriptFilename(sessionId, _title) {
124
+ return `session-${sessionId}.md`;
125
+ }
126
+ //# sourceMappingURL=transcript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","sourceRoot":"","sources":["../src/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4BH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC;IACrB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,cAAc,CAAC,EAAU;IAChC,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,CAAC;IAC/B,OAAO,GAAG,OAAO,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AAChD,CAAC;AAED,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,SAAS,UAAU,CAAC,IAAU,EAAE,OAA0B;IACxD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACrE,OAAO,GAAI,IAAY,CAAC,IAAI,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,IAAI,CAAC,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CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Exhaustive part classification — the typed model a chat UI renders from.
3
+ *
4
+ * `@opencode-ai/sdk`'s `Part` union has 12 variants (text, subtask, reasoning,
5
+ * file, tool, step-start, step-finish, snapshot, patch, agent, retry,
6
+ * compaction). Before this module, hosts hand-rolled a `switch (part.type)`
7
+ * over the raw wire shape, string-sniffed tool names, and silently dropped
8
+ * whichever variants they hadn't gotten around to yet (subtask/patch/
9
+ * snapshot/agent/retry/compaction, commonly). `classifyPart` normalizes every
10
+ * variant into a `ClassifiedPart` with the fields a renderer actually needs,
11
+ * with a compile-time exhaustiveness check (the `never` assertion in the
12
+ * `default` branch) so a new opencode part type fails the build here instead
13
+ * of silently rendering nothing — plus a runtime 'unknown' fallback so a
14
+ * genuinely unrecognized value at runtime (e.g. an older client talking to a
15
+ * newer server) degrades gracefully instead of throwing.
16
+ *
17
+ * Framework-free — no React/DOM imports. Typed against the concrete
18
+ * `@opencode-ai/sdk` wire types (not the structural `*Like` protocols in
19
+ * `./types`) because exhaustiveness checking only works against the real
20
+ * closed union.
21
+ */
22
+ import type { Part } from '../opencode/client.js';
23
+ import type { MessageWithParts } from '../transcript.js';
24
+ import type { TokenUsageLike } from './types.js';
25
+ export type ToolStatus = 'pending' | 'running' | 'done' | 'error';
26
+ /** Normalized view of a tool part's state, independent of the wire's
27
+ * pending/running/completed/error status-union shape. */
28
+ export interface ToolView {
29
+ name: string;
30
+ title: string;
31
+ status: ToolStatus;
32
+ input?: Record<string, unknown>;
33
+ output?: string;
34
+ error?: string;
35
+ /**
36
+ * `JSON.parse` of a string `output` when it parses as JSON; a non-string
37
+ * output value passes through unchanged (defensive — the wire type is
38
+ * always `string`, but nothing stops a future/plugin tool from handing
39
+ * back a structured value directly). `undefined` when parsing fails or
40
+ * there's no output. Bounded — strings over ~256KB are never parsed (a
41
+ * huge blob is never meaningfully "structured" for view-model purposes,
42
+ * and JSON.parse on it would be wasted work on every render).
43
+ */
44
+ outputParsed?: unknown;
45
+ /** The raw output text, unconditionally — same value as `output` (kept as
46
+ * its own field so `outputParsed`/`outputText` read as a matched pair). */
47
+ outputText?: string;
48
+ }
49
+ export interface ClassifiedTextPart {
50
+ kind: 'text';
51
+ id: string;
52
+ text: string;
53
+ /** Synthetic text parts (e.g. shell-mode's synthetic user prompt) are
54
+ * wire-internal — hosts typically skip rendering them as chat bubbles. */
55
+ synthetic: boolean;
56
+ }
57
+ export interface ClassifiedReasoningPart {
58
+ kind: 'reasoning';
59
+ id: string;
60
+ text: string;
61
+ }
62
+ export interface ClassifiedToolPart {
63
+ kind: 'tool';
64
+ id: string;
65
+ tool: ToolView;
66
+ }
67
+ export interface ClassifiedFilePart {
68
+ kind: 'file';
69
+ id: string;
70
+ filename?: string;
71
+ mime: string;
72
+ url: string;
73
+ /** Mirrors the `isAttachment()` check in index.ts — image/PDF parts are
74
+ * typically rendered inline, everything else as a filename marker. */
75
+ isImage: boolean;
76
+ isPdf: boolean;
77
+ }
78
+ export interface ClassifiedSubtaskPart {
79
+ kind: 'subtask';
80
+ id: string;
81
+ description: string;
82
+ agent: string;
83
+ prompt: string;
84
+ model?: {
85
+ providerID: string;
86
+ modelID: string;
87
+ };
88
+ }
89
+ export interface ClassifiedPatchPart {
90
+ kind: 'patch';
91
+ id: string;
92
+ hash: string;
93
+ files: string[];
94
+ fileCount: number;
95
+ }
96
+ export interface ClassifiedSnapshotPart {
97
+ kind: 'snapshot';
98
+ id: string;
99
+ snapshot: string;
100
+ }
101
+ export interface ClassifiedAgentPart {
102
+ kind: 'agent';
103
+ id: string;
104
+ name: string;
105
+ }
106
+ export interface ClassifiedRetryPart {
107
+ kind: 'retry';
108
+ id: string;
109
+ attempt: number;
110
+ message: string;
111
+ createdAt: number;
112
+ }
113
+ export interface ClassifiedCompactionPart {
114
+ kind: 'compaction';
115
+ id: string;
116
+ auto: boolean;
117
+ overflow: boolean;
118
+ tailStartId?: string;
119
+ }
120
+ export interface ClassifiedStepPart {
121
+ kind: 'step';
122
+ id: string;
123
+ phase: 'start' | 'finish';
124
+ snapshot?: string;
125
+ /** step-finish only. */
126
+ reason?: string;
127
+ cost?: number;
128
+ tokens?: TokenUsageLike;
129
+ }
130
+ /** Forward-compat fallback for any part type this module doesn't know about
131
+ * yet (version skew between client and server). `raw` is the untouched
132
+ * wire value so a host can still attempt best-effort handling. */
133
+ export interface ClassifiedUnknownPart {
134
+ kind: 'unknown';
135
+ raw: unknown;
136
+ }
137
+ export type ClassifiedPart = ClassifiedTextPart | ClassifiedReasoningPart | ClassifiedToolPart | ClassifiedFilePart | ClassifiedSubtaskPart | ClassifiedPatchPart | ClassifiedSnapshotPart | ClassifiedAgentPart | ClassifiedRetryPart | ClassifiedCompactionPart | ClassifiedStepPart | ClassifiedUnknownPart;
138
+ /**
139
+ * Classify a single opencode message part into a `ClassifiedPart`.
140
+ *
141
+ * The `default` branch's `const _exhaustive: never = part` line is a
142
+ * compile-time guard: if opencode's `Part` union grows a new variant and this
143
+ * switch isn't updated to handle it, this file fails to typecheck. At
144
+ * runtime, a value that doesn't match any known `type` (version skew) falls
145
+ * through to `{ kind: 'unknown', raw: part }` instead of throwing.
146
+ */
147
+ export declare function classifyPart(part: Part): ClassifiedPart;
148
+ /** Normalized turn-level error — the "failed turn renders as silence" bug
149
+ * class, solved once here instead of in every host's renderer. */
150
+ export interface TurnError {
151
+ name: string;
152
+ message: string;
153
+ }
154
+ export interface ClassifiedTurn {
155
+ parts: ClassifiedPart[];
156
+ error?: TurnError;
157
+ /** True when the turn has no error and no part with visible content — the
158
+ * case that used to render as silent nothingness. */
159
+ isEmpty: boolean;
160
+ }
161
+ /**
162
+ * Classify every part of a message and normalize its error (assistant
163
+ * messages only carry `info.error`; user messages never do).
164
+ */
165
+ export declare function classifyTurn(message: MessageWithParts): ClassifiedTurn;
166
+ //# sourceMappingURL=classify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/turns/classify.ts"],"names":[],"mapp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AE,MAAM,CAAC;IACX,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,uBAAuB,GACvB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,kBAAkB,GAClB,qBAAqB,CAAC;AA4F1B;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CA+BvD;AAMD;mEACmE;AACnE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AA6BD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;0DACsD;IACtD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAMtE"}
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Exhaustive part classification — the typed model a chat UI renders from.
3
+ *
4
+ * `@opencode-ai/sdk`'s `Part` union has 12 variants (text, subtask, reasoning,
5
+ * file, tool, step-start, step-finish, snapshot, patch, agent, retry,
6
+ * compaction). Before this module, hosts hand-rolled a `switch (part.type)`
7
+ * over the raw wire shape, string-sniffed tool names, and silently dropped
8
+ * whichever variants they hadn't gotten around to yet (subtask/patch/
9
+ * snapshot/agent/retry/compaction, commonly). `classifyPart` normalizes every
10
+ * variant into a `ClassifiedPart` with the fields a renderer actually needs,
11
+ * with a compile-time exhaustiveness check (the `never` assertion in the
12
+ * `default` branch) so a new opencode part type fails the build here instead
13
+ * of silently rendering nothing — plus a runtime 'unknown' fallback so a
14
+ * genuinely unrecognized value at runtime (e.g. an older client talking to a
15
+ * newer server) degrades gracefully instead of throwing.
16
+ *
17
+ * Framework-free — no React/DOM imports. Typed against the concrete
18
+ * `@opencode-ai/sdk` wire types (not the structural `*Like` protocols in
19
+ * `./types`) because exhaustiveness checking only works against the real
20
+ * closed union.
21
+ */
22
+ import { unwrapError } from './errors.js';
23
+ import { toolInfo } from './tool-registry.js';
24
+ /** Never parse (or diff/pretty-print) an output blob larger than this — a
25
+ * cheap circuit breaker against pathological huge tool outputs. */
26
+ const MAX_PARSEABLE_OUTPUT_LENGTH = 256 * 1024;
27
+ function toolStatus(state) {
28
+ switch (state.status) {
29
+ case 'pending':
30
+ return 'pending';
31
+ case 'running':
32
+ return 'running';
33
+ case 'completed':
34
+ return 'done';
35
+ case 'error':
36
+ return 'error';
37
+ default: {
38
+ const _exhaustive = state;
39
+ return _exhaustive;
40
+ }
41
+ }
42
+ }
43
+ function parseToolOutput(rawOutput) {
44
+ if (rawOutput === undefined)
45
+ return {};
46
+ if (rawOutput.length > MAX_PARSEABLE_OUTPUT_LENGTH)
47
+ return { outputText: rawOutput };
48
+ try {
49
+ return { outputParsed: JSON.parse(rawOutput), outputText: rawOutput };
50
+ }
51
+ catch {
52
+ return { outputText: rawOutput };
53
+ }
54
+ }
55
+ /**
56
+ * Detect the "completed but actually failed" shape router/executor tools
57
+ * (web_search, image_search, connector calls) commonly return: the wire's
58
+ * `state.status` says `completed`, but the JSON output body itself carries
59
+ * `success: false` or a top-level `error`. Without this, a real prod failure
60
+ * (e.g. a 402 "Insufficient credits" from the search router) renders as a
61
+ * successful tool call with raw JSON garbage inside.
62
+ */
63
+ function detectEmbeddedFailure(outputParsed) {
64
+ if (typeof outputParsed !== 'object' || outputParsed === null || Array.isArray(outputParsed)) {
65
+ return undefined;
66
+ }
67
+ const obj = outputParsed;
68
+ const failedFlag = obj.success === false;
69
+ const errorField = obj.error;
70
+ const hasErrorField = (typeof errorField === 'string' && errorField.length > 0) ||
71
+ (typeof errorField === 'object' && errorField !== null);
72
+ if (!failedFlag && !hasErrorField)
73
+ return undefined;
74
+ if (hasErrorField)
75
+ return unwrapError(errorField);
76
+ if (typeof obj.message === 'string' && obj.message)
77
+ return obj.message;
78
+ return 'Tool reported failure';
79
+ }
80
+ function classifyToolState(tool, state) {
81
+ const liveTitle = 'title' in state ? state.title : undefined;
82
+ const rawOutput = state.status === 'completed' ? state.output : undefined;
83
+ const { outputParsed, outputText } = parseToolOutput(rawOutput);
84
+ let status = toolStatus(state);
85
+ let error = state.status === 'error' ? state.error : undefined;
86
+ if (status === 'done') {
87
+ const embeddedError = detectEmbeddedFailure(outputParsed);
88
+ if (embeddedError) {
89
+ status = 'error';
90
+ error = embeddedError;
91
+ }
92
+ }
93
+ return {
94
+ name: tool,
95
+ title: liveTitle || toolInfo(tool).label,
96
+ status,
97
+ input: state.input,
98
+ output: rawOutput,
99
+ outputParsed,
100
+ outputText,
101
+ error,
102
+ };
103
+ }
104
+ function classifyText(part) {
105
+ return { kind: 'text', id: part.id, text: part.text, synthetic: !!part.synthetic };
106
+ }
107
+ function classifyReasoning(part) {
108
+ return { kind: 'reasoning', id: part.id, text: part.text };
109
+ }
110
+ function classifyTool(part) {
111
+ return { kind: 'tool', id: part.id, tool: classifyToolState(part.tool, part.state) };
112
+ }
113
+ function classifyFile(part) {
114
+ const mime = part.mime;
115
+ return {
116
+ kind: 'file',
117
+ id: part.id,
118
+ filename: part.filename,
119
+ mime,
120
+ url: part.url,
121
+ isImage: mime.startsWith('image/'),
122
+ isPdf: mime === 'application/pdf',
123
+ };
124
+ }
125
+ function classifySubtask(part) {
126
+ return {
127
+ kind: 'subtask',
128
+ id: part.id,
129
+ description: part.description,
130
+ agent: part.agent,
131
+ prompt: part.prompt,
132
+ model: part.model,
133
+ };
134
+ }
135
+ function classifyPatch(part) {
136
+ return {
137
+ kind: 'patch',
138
+ id: part.id,
139
+ hash: part.hash,
140
+ files: part.files,
141
+ fileCount: part.files.length,
142
+ };
143
+ }
144
+ function classifySnapshot(part) {
145
+ return { kind: 'snapshot', id: part.id, snapshot: part.snapshot };
146
+ }
147
+ function classifyAgent(part) {
148
+ return { kind: 'agent', id: part.id, name: part.name };
149
+ }
150
+ function classifyRetry(part) {
151
+ return {
152
+ kind: 'retry',
153
+ id: part.id,
154
+ attempt: part.attempt,
155
+ message: unwrapError(part.error),
156
+ createdAt: part.time.created,
157
+ };
158
+ }
159
+ function classifyCompaction(part) {
160
+ return {
161
+ kind: 'compaction',
162
+ id: part.id,
163
+ auto: part.auto,
164
+ overflow: !!part.overflow,
165
+ tailStartId: part.tail_start_id,
166
+ };
167
+ }
168
+ function classifyStepStart(part) {
169
+ return { kind: 'step', id: part.id, phase: 'start', snapshot: part.snapshot };
170
+ }
171
+ function classifyStepFinish(part) {
172
+ return {
173
+ kind: 'step',
174
+ id: part.id,
175
+ phase: 'finish',
176
+ snapshot: part.snapshot,
177
+ reason: part.reason,
178
+ cost: part.cost,
179
+ tokens: part.tokens,
180
+ };
181
+ }
182
+ /**
183
+ * Classify a single opencode message part into a `ClassifiedPart`.
184
+ *
185
+ * The `default` branch's `const _exhaustive: never = part` line is a
186
+ * compile-time guard: if opencode's `Part` union grows a new variant and this
187
+ * switch isn't updated to handle it, this file fails to typecheck. At
188
+ * runtime, a value that doesn't match any known `type` (version skew) falls
189
+ * through to `{ kind: 'unknown', raw: part }` instead of throwing.
190
+ */
191
+ export function classifyPart(part) {
192
+ switch (part.type) {
193
+ case 'text':
194
+ return classifyText(part);
195
+ case 'reasoning':
196
+ return classifyReasoning(part);
197
+ case 'tool':
198
+ return classifyTool(part);
199
+ case 'file':
200
+ return classifyFile(part);
201
+ case 'subtask':
202
+ return classifySubtask(part);
203
+ case 'patch':
204
+ return classifyPatch(part);
205
+ case 'snapshot':
206
+ return classifySnapshot(part);
207
+ case 'agent':
208
+ return classifyAgent(part);
209
+ case 'retry':
210
+ return classifyRetry(part);
211
+ case 'compaction':
212
+ return classifyCompaction(part);
213
+ case 'step-start':
214
+ return classifyStepStart(part);
215
+ case 'step-finish':
216
+ return classifyStepFinish(part);
217
+ default: {
218
+ const _exhaustive = part;
219
+ return { kind: 'unknown', raw: _exhaustive };
220
+ }
221
+ }
222
+ }
223
+ function normalizeTurnError(error) {
224
+ if (!error)
225
+ return undefined;
226
+ // (`!error` above already excludes null — no separate null check needed.)
227
+ const name = typeof error === 'object' &&
228
+ 'name' in error &&
229
+ typeof error.name === 'string'
230
+ ? error.name
231
+ : 'Error';
232
+ return { name, message: unwrapError(error) };
233
+ }
234
+ /** Whether a classified part renders any visible content on its own — used
235
+ * to compute `isEmpty` below. step/snapshot markers with no sibling content
236
+ * don't count; a lone empty text/reasoning part doesn't either. */
237
+ function partHasContent(part) {
238
+ switch (part.kind) {
239
+ case 'text':
240
+ case 'reasoning':
241
+ return part.text.trim().length > 0;
242
+ case 'step':
243
+ return false;
244
+ default:
245
+ return true;
246
+ }
247
+ }
248
+ /**
249
+ * Classify every part of a message and normalize its error (assistant
250
+ * messages only carry `info.error`; user messages never do).
251
+ */
252
+ export function classifyTurn(message) {
253
+ const parts = message.parts.map(classifyPart);
254
+ const rawError = message.info.role === 'assistant' ? message.info.error : undefined;
255
+ const error = normalizeTurnError(rawError);
256
+ const isEmpty = !error && !parts.some(partHasContent);
257
+ return { parts, error, isEmpty };
258
+ }
259
+ //# sourceMappingURL=classify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/turns/classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAmBH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAA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C,CAAC;IAC3C,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Error-message unwrapping — extracted from turns/index.ts so it can be
3
+ * shared with classify.ts (classifyTurn's TurnError normalization) without
4
+ * creating an index.ts <-> classify.ts import cycle.
5
+ */
6
+ /**
7
+ * Extract human-readable error message from a raw error value.
8
+ * Matches SolidJS `unwrap()` function — session-turn.tsx:34-81
9
+ */
10
+ export declare function unwrapError(raw: unknown): string;
11
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/turns/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAqChD"}