@sixb/core 0.2.7 → 0.2.8

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 (627) hide show
  1. package/dist/actions/index.js +52 -49
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/request.d.ts.map +1 -1
  4. package/dist/actions/run/context.d.ts.map +1 -1
  5. package/dist/actions/run/execute.d.ts +3 -0
  6. package/dist/actions/run/execute.d.ts.map +1 -1
  7. package/dist/actions/run/executor.d.ts +3 -0
  8. package/dist/actions/run/executor.d.ts.map +1 -1
  9. package/dist/actions/run/normalize.d.ts.map +1 -1
  10. package/dist/actions/run/types.d.ts +6 -0
  11. package/dist/actions/run/types.d.ts.map +1 -1
  12. package/dist/actions/types/context.d.ts +7 -0
  13. package/dist/actions/types/context.d.ts.map +1 -1
  14. package/dist/agents/context/entries.d.ts +17 -0
  15. package/dist/agents/context/entries.d.ts.map +1 -1
  16. package/dist/agents/context/index.js +3 -2
  17. package/dist/agents/context/index.js.map +1 -1
  18. package/dist/agents/context-model.d.ts.map +1 -1
  19. package/dist/agents/context-resolution.d.ts.map +1 -1
  20. package/dist/agents/execution.d.ts +7 -0
  21. package/dist/agents/execution.d.ts.map +1 -1
  22. package/dist/agents/index.js +57 -54
  23. package/dist/agents/index.js.map +1 -1
  24. package/dist/agents/model-call-retry.d.ts +28 -0
  25. package/dist/agents/model-call-retry.d.ts.map +1 -0
  26. package/dist/agents/model-loop.d.ts +4 -2
  27. package/dist/agents/model-loop.d.ts.map +1 -1
  28. package/dist/agents/run-artifacts.d.ts +2 -0
  29. package/dist/agents/run-artifacts.d.ts.map +1 -1
  30. package/dist/agents/run-plan.d.ts +1 -1
  31. package/dist/agents/run-plan.d.ts.map +1 -1
  32. package/dist/agents/run-session-http.d.ts.map +1 -1
  33. package/dist/agents/run-session-serve.d.ts.map +1 -1
  34. package/dist/agents/run-session-wire.d.ts +6 -0
  35. package/dist/agents/run-session-wire.d.ts.map +1 -1
  36. package/dist/agents/thread-access.d.ts +13 -0
  37. package/dist/agents/thread-access.d.ts.map +1 -1
  38. package/dist/agents/tool-files.d.ts.map +1 -1
  39. package/dist/artifacts/caller.d.ts +10 -0
  40. package/dist/artifacts/caller.d.ts.map +1 -0
  41. package/dist/artifacts/comment-place.d.ts +26 -0
  42. package/dist/artifacts/comment-place.d.ts.map +1 -0
  43. package/dist/artifacts/comment-text.d.ts +12 -4
  44. package/dist/artifacts/comment-text.d.ts.map +1 -1
  45. package/dist/artifacts/comments.d.ts +8 -2
  46. package/dist/artifacts/comments.d.ts.map +1 -1
  47. package/dist/artifacts/errors.d.ts +1 -1
  48. package/dist/artifacts/errors.d.ts.map +1 -1
  49. package/dist/artifacts/execution.d.ts +73 -5
  50. package/dist/artifacts/execution.d.ts.map +1 -1
  51. package/dist/artifacts/frames/assets.d.ts +27 -7
  52. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  53. package/dist/artifacts/frames/entries.d.ts +5 -4
  54. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  55. package/dist/artifacts/frames/hyperframes.d.ts +12 -0
  56. package/dist/artifacts/frames/hyperframes.d.ts.map +1 -0
  57. package/dist/artifacts/frames/index.d.ts +3 -1
  58. package/dist/artifacts/frames/index.d.ts.map +1 -1
  59. package/dist/artifacts/frames/index.js +20 -6
  60. package/dist/artifacts/frames/index.js.map +3 -3
  61. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  62. package/dist/artifacts/frames/protocol.d.ts +33 -0
  63. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  64. package/dist/artifacts/frames/video-runtime.d.ts +21 -0
  65. package/dist/artifacts/frames/video-runtime.d.ts.map +1 -0
  66. package/dist/artifacts/html.d.ts +23 -0
  67. package/dist/artifacts/html.d.ts.map +1 -1
  68. package/dist/artifacts/index.d.ts +5 -3
  69. package/dist/artifacts/index.d.ts.map +1 -1
  70. package/dist/artifacts/index.js +71 -10
  71. package/dist/artifacts/index.js.map +4 -4
  72. package/dist/artifacts/kinds.d.ts +1 -1
  73. package/dist/artifacts/kinds.d.ts.map +1 -1
  74. package/dist/artifacts/limits.d.ts +37 -0
  75. package/dist/artifacts/limits.d.ts.map +1 -1
  76. package/dist/artifacts/live/document.d.ts.map +1 -1
  77. package/dist/artifacts/live/index.d.ts +6 -2
  78. package/dist/artifacts/live/index.d.ts.map +1 -1
  79. package/dist/artifacts/live/index.js +3432 -13
  80. package/dist/artifacts/live/index.js.map +6 -3
  81. package/dist/artifacts/live/presence.d.ts +7 -5
  82. package/dist/artifacts/live/presence.d.ts.map +1 -1
  83. package/dist/artifacts/live/protocol.d.ts +4 -2
  84. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  85. package/dist/artifacts/live/server.d.ts +1 -1
  86. package/dist/artifacts/live/server.d.ts.map +1 -1
  87. package/dist/artifacts/live/server.js +36 -31
  88. package/dist/artifacts/live/server.js.map +1 -1
  89. package/dist/artifacts/live/state.d.ts +2 -2
  90. package/dist/artifacts/media/media.d.ts +96 -0
  91. package/dist/artifacts/media/media.d.ts.map +1 -0
  92. package/dist/artifacts/media/transcriber.d.ts +29 -0
  93. package/dist/artifacts/media/transcriber.d.ts.map +1 -0
  94. package/dist/artifacts/outline.d.ts +26 -1
  95. package/dist/artifacts/outline.d.ts.map +1 -1
  96. package/dist/artifacts/publish/files.d.ts +5 -2
  97. package/dist/artifacts/publish/files.d.ts.map +1 -1
  98. package/dist/artifacts/publish/index.d.ts +11 -2
  99. package/dist/artifacts/publish/index.d.ts.map +1 -1
  100. package/dist/artifacts/publish/index.js +110 -33
  101. package/dist/artifacts/publish/index.js.map +1 -1
  102. package/dist/artifacts/publish/pdf.d.ts.map +1 -1
  103. package/dist/artifacts/publish/previews.d.ts +7 -2
  104. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  105. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  106. package/dist/artifacts/publish/validate/html.d.ts +5 -4
  107. package/dist/artifacts/publish/validate/html.d.ts.map +1 -1
  108. package/dist/artifacts/publish/validate/video.d.ts +36 -0
  109. package/dist/artifacts/publish/validate/video.d.ts.map +1 -0
  110. package/dist/artifacts/publish/video.d.ts +79 -0
  111. package/dist/artifacts/publish/video.d.ts.map +1 -0
  112. package/dist/artifacts/resolve.d.ts +9 -0
  113. package/dist/artifacts/resolve.d.ts.map +1 -1
  114. package/dist/artifacts/video/composition.d.ts +183 -0
  115. package/dist/artifacts/video/composition.d.ts.map +1 -0
  116. package/dist/artifacts/video/edit.d.ts +298 -0
  117. package/dist/artifacts/video/edit.d.ts.map +1 -0
  118. package/dist/artifacts/video/export.d.ts +142 -0
  119. package/dist/artifacts/video/export.d.ts.map +1 -0
  120. package/dist/artifacts/video/looks.d.ts +133 -0
  121. package/dist/artifacts/video/looks.d.ts.map +1 -0
  122. package/dist/artifacts/video/project.d.ts +74 -0
  123. package/dist/artifacts/video/project.d.ts.map +1 -0
  124. package/dist/artifacts/video/stills.d.ts +65 -0
  125. package/dist/artifacts/video/stills.d.ts.map +1 -0
  126. package/dist/artifacts/video/timeline.d.ts +153 -0
  127. package/dist/artifacts/video/timeline.d.ts.map +1 -0
  128. package/dist/auth/index.js +9 -8
  129. package/dist/auth/index.js.map +1 -1
  130. package/dist/authorization/index.js +5 -4
  131. package/dist/authorization/index.js.map +1 -1
  132. package/dist/blob-storage/browser.d.ts +1 -1
  133. package/dist/blob-storage/browser.d.ts.map +1 -1
  134. package/dist/blob-storage/browser.js +8 -4
  135. package/dist/blob-storage/browser.js.map +1 -1
  136. package/dist/blob-storage/constants.d.ts +8 -3
  137. package/dist/blob-storage/constants.d.ts.map +1 -1
  138. package/dist/blob-storage/download-urls.d.ts +2 -2
  139. package/dist/blob-storage/download-urls.d.ts.map +1 -1
  140. package/dist/blob-storage/index.d.ts +1 -1
  141. package/dist/blob-storage/index.d.ts.map +1 -1
  142. package/dist/blob-storage/index.js +9 -5
  143. package/dist/blob-storage/index.js.map +1 -1
  144. package/dist/blob-storage/internal.d.ts +2 -2
  145. package/dist/blob-storage/internal.d.ts.map +1 -1
  146. package/dist/blob-storage/internal.js +10 -4
  147. package/dist/blob-storage/internal.js.map +1 -1
  148. package/dist/blob-storage/media-type.d.ts +12 -3
  149. package/dist/blob-storage/media-type.d.ts.map +1 -1
  150. package/dist/bootstrap/index.js +61 -58
  151. package/dist/bootstrap/index.js.map +2 -2
  152. package/dist/{chunk-az95tsh3.js → chunk-0fjryajn.js} +3 -2
  153. package/dist/chunk-0fjryajn.js.map +11 -0
  154. package/dist/{chunk-9tpmfh3n.js → chunk-0mk8qqp9.js} +3 -3
  155. package/dist/{chunk-9tpmfh3n.js.map → chunk-0mk8qqp9.js.map} +3 -3
  156. package/dist/{chunk-88xeh6zx.js → chunk-1g4me5f2.js} +182 -7
  157. package/dist/{chunk-88xeh6zx.js.map → chunk-1g4me5f2.js.map} +3 -3
  158. package/dist/{chunk-7mhbs9yy.js → chunk-1z8ccj53.js} +1 -1
  159. package/dist/{chunk-wkv3h3q7.js → chunk-2138b0ng.js} +115 -8
  160. package/dist/chunk-2138b0ng.js.map +12 -0
  161. package/dist/chunk-23eaayw4.js +3757 -0
  162. package/dist/chunk-23eaayw4.js.map +22 -0
  163. package/dist/{chunk-m1cwncee.js → chunk-2mxq1yd9.js} +45 -40
  164. package/dist/{chunk-m1cwncee.js.map → chunk-2mxq1yd9.js.map} +3 -3
  165. package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
  166. package/dist/chunk-389ybvw9.js.map +2 -2
  167. package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
  168. package/dist/{chunk-06kpaqg4.js → chunk-3d9w8t4n.js} +110 -22
  169. package/dist/{chunk-06kpaqg4.js.map → chunk-3d9w8t4n.js.map} +5 -5
  170. package/dist/chunk-3dvcdn9w.js +8 -0
  171. package/dist/chunk-3dvcdn9w.js.map +10 -0
  172. package/dist/{chunk-fdk0ks9p.js → chunk-3x902cja.js} +3 -3
  173. package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
  174. package/dist/{chunk-9cyq87qa.js → chunk-4tdm3fsj.js} +95 -32
  175. package/dist/{chunk-9cyq87qa.js.map → chunk-4tdm3fsj.js.map} +9 -9
  176. package/dist/{chunk-cpy282b8.js → chunk-4w8qzy9w.js} +6 -6
  177. package/dist/{chunk-c29729me.js → chunk-4z9xtxke.js} +8 -7
  178. package/dist/chunk-4z9xtxke.js.map +12 -0
  179. package/dist/chunk-5278qwax.js +270 -0
  180. package/dist/chunk-5278qwax.js.map +11 -0
  181. package/dist/{chunk-k1g14kk3.js → chunk-6a4hp405.js} +4 -5
  182. package/dist/{chunk-k1g14kk3.js.map → chunk-6a4hp405.js.map} +3 -3
  183. package/dist/{chunk-xavet0qs.js → chunk-6whr25gw.js} +2 -2
  184. package/dist/{chunk-mbwsgjn7.js → chunk-7zygtcqq.js} +14 -2
  185. package/dist/chunk-7zygtcqq.js.map +11 -0
  186. package/dist/chunk-88s9z5pf.js +3 -0
  187. package/dist/{chunk-de5sfbc3.js.map → chunk-88s9z5pf.js.map} +1 -1
  188. package/dist/{chunk-ygvay56w.js → chunk-896te58g.js} +2 -2
  189. package/dist/{chunk-pfdq1ga6.js → chunk-8eqqqc1h.js} +3 -3
  190. package/dist/{chunk-yyj009tv.js → chunk-8tefbhdx.js} +14 -14
  191. package/dist/{chunk-yyj009tv.js.map → chunk-8tefbhdx.js.map} +1 -1
  192. package/dist/{chunk-jka26v8c.js → chunk-8x1bsp68.js} +1 -1
  193. package/dist/{chunk-wzcjhv54.js → chunk-93e4w7te.js} +113 -1
  194. package/dist/chunk-93e4w7te.js.map +11 -0
  195. package/dist/{chunk-phs5fbff.js → chunk-990a5bkc.js} +424 -76
  196. package/dist/chunk-990a5bkc.js.map +21 -0
  197. package/dist/{chunk-6md802cc.js → chunk-9az7kjv4.js} +6 -6
  198. package/dist/{chunk-95ps0k5q.js → chunk-9e5t53z0.js} +1 -1
  199. package/dist/{chunk-js9e6487.js → chunk-9p7kyeqz.js} +4 -4
  200. package/dist/chunk-a68zz4r0.js +537 -0
  201. package/dist/chunk-a68zz4r0.js.map +11 -0
  202. package/dist/{chunk-d7vyc7k6.js → chunk-a700gjc8.js} +10 -2
  203. package/dist/chunk-a700gjc8.js.map +10 -0
  204. package/dist/{chunk-gfdh9kqa.js → chunk-a9qzjaz2.js} +2 -5
  205. package/dist/chunk-a9qzjaz2.js.map +10 -0
  206. package/dist/{chunk-8qmp9fpa.js → chunk-as94vcty.js} +619 -482
  207. package/dist/{chunk-8qmp9fpa.js.map → chunk-as94vcty.js.map} +19 -19
  208. package/dist/{chunk-brybqw5k.js → chunk-bkxm2dzx.js} +1 -1
  209. package/dist/{chunk-ppxf7gw2.js → chunk-d7t9jnym.js} +3 -3
  210. package/dist/{chunk-tapdssb5.js → chunk-e3b1r4d2.js} +8 -7
  211. package/dist/{chunk-tapdssb5.js.map → chunk-e3b1r4d2.js.map} +4 -4
  212. package/dist/{chunk-cg7cygfj.js → chunk-fdmvaz7x.js} +1 -1
  213. package/dist/{chunk-191jz8a6.js → chunk-ff0qdk7z.js} +1 -1
  214. package/dist/{chunk-9vsc919v.js → chunk-fgxvrxx4.js} +22 -2
  215. package/dist/chunk-fgxvrxx4.js.map +10 -0
  216. package/dist/{chunk-wx7smkn2.js → chunk-fq8drkp0.js} +1 -1
  217. package/dist/{chunk-60662fyv.js → chunk-fqms1a8c.js} +132 -4
  218. package/dist/{chunk-60662fyv.js.map → chunk-fqms1a8c.js.map} +8 -6
  219. package/dist/{chunk-v8a1qjzp.js → chunk-hpswfrjj.js} +1 -1
  220. package/dist/{chunk-qttqe1ah.js → chunk-jbg905hn.js} +80 -13
  221. package/dist/chunk-jbg905hn.js.map +25 -0
  222. package/dist/{chunk-bz5bnjjt.js → chunk-jjte0h4p.js} +1 -1
  223. package/dist/{chunk-hvq8xs66.js → chunk-jwjwvzj1.js} +797 -51
  224. package/dist/chunk-jwjwvzj1.js.map +38 -0
  225. package/dist/{chunk-k29rdc3h.js → chunk-k3vd2vyz.js} +6 -2
  226. package/dist/chunk-k3vd2vyz.js.map +10 -0
  227. package/dist/chunk-kcqpk9w1.js.map +2 -2
  228. package/dist/chunk-mvz89age.js.map +2 -2
  229. package/dist/{chunk-xrmbhap8.js → chunk-mwg0nwkb.js} +1 -1
  230. package/dist/{chunk-a3faa34j.js → chunk-nfjt8k8j.js} +1 -1
  231. package/dist/{chunk-394zjzjs.js → chunk-nhgqz3g3.js} +3 -3
  232. package/dist/{chunk-bqr703h4.js → chunk-p0c5kkhn.js} +23 -6
  233. package/dist/{chunk-bqr703h4.js.map → chunk-p0c5kkhn.js.map} +3 -3
  234. package/dist/{chunk-92wrka15.js → chunk-q150fnj9.js} +1 -1
  235. package/dist/{chunk-w3t94hm6.js → chunk-qk3zq25v.js} +1 -1
  236. package/dist/chunk-rtkqczbr.js.map +2 -2
  237. package/dist/{chunk-3qtk0070.js → chunk-ssqbrts1.js} +86 -9
  238. package/dist/chunk-ssqbrts1.js.map +14 -0
  239. package/dist/{chunk-5qqmndhm.js → chunk-szzhrn3e.js} +1 -1
  240. package/dist/{chunk-n1hbwc6y.js → chunk-t6pfch4e.js} +1 -1
  241. package/dist/{chunk-xtztwpkh.js → chunk-v6h4tc2v.js} +86 -5
  242. package/dist/chunk-v6h4tc2v.js.map +12 -0
  243. package/dist/{chunk-brhp9d97.js → chunk-vmqjndb3.js} +2 -2
  244. package/dist/chunk-vtjzwymr.js.map +2 -2
  245. package/dist/{chunk-fycac8e9.js → chunk-wpba6hhd.js} +10 -10
  246. package/dist/{chunk-fycac8e9.js.map → chunk-wpba6hhd.js.map} +1 -1
  247. package/dist/{chunk-t58sktr5.js → chunk-wrb1x1ss.js} +2 -2
  248. package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
  249. package/dist/{chunk-04r2fdsd.js → chunk-x0hqc54n.js} +4 -4
  250. package/dist/{chunk-sgx82nnt.js → chunk-xg31er4p.js} +43 -4
  251. package/dist/chunk-xg31er4p.js.map +10 -0
  252. package/dist/{chunk-3neam1y5.js → chunk-y3qb965a.js} +2 -2
  253. package/dist/{chunk-5pz3htbe.js → chunk-y57eawng.js} +3 -3
  254. package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
  255. package/dist/chunk-yah25st6.js.map +10 -0
  256. package/dist/{chunk-mrs7jy17.js → chunk-ywvxcmqj.js} +106 -13
  257. package/dist/{chunk-mrs7jy17.js.map → chunk-ywvxcmqj.js.map} +8 -7
  258. package/dist/{chunk-44hrfmbk.js → chunk-zmq9xc9s.js} +70 -31
  259. package/dist/{chunk-44hrfmbk.js.map → chunk-zmq9xc9s.js.map} +4 -3
  260. package/dist/datasets/write.js +8 -7
  261. package/dist/datasets/write.js.map +1 -1
  262. package/dist/errors/catalog.d.ts.map +1 -1
  263. package/dist/execution/agent.js +52 -49
  264. package/dist/execution/agent.js.map +1 -1
  265. package/dist/execution/kernel-operation.d.ts +1 -0
  266. package/dist/execution/kernel-operation.d.ts.map +1 -1
  267. package/dist/execution/primitive.js +52 -49
  268. package/dist/execution/primitive.js.map +1 -1
  269. package/dist/execution/request.js +53 -50
  270. package/dist/execution/request.js.map +2 -2
  271. package/dist/execution/types.d.ts +5 -0
  272. package/dist/execution/types.d.ts.map +1 -1
  273. package/dist/http/api-routes.d.ts.map +1 -1
  274. package/dist/http/index.js +1 -1
  275. package/dist/index.d.ts +5 -3
  276. package/dist/index.d.ts.map +1 -1
  277. package/dist/index.js +69 -65
  278. package/dist/index.js.map +1 -1
  279. package/dist/lake-storage/index.js +9 -8
  280. package/dist/lake-storage/index.js.map +1 -1
  281. package/dist/maintenance/index.js +9 -8
  282. package/dist/maintenance/index.js.map +2 -2
  283. package/dist/materializer/index.js +26 -24
  284. package/dist/materializer/index.js.map +1 -1
  285. package/dist/models/audio/runtime.d.ts +3 -1
  286. package/dist/models/audio/runtime.d.ts.map +1 -1
  287. package/dist/models/audio/speech.d.ts +2 -2
  288. package/dist/models/audio/speech.d.ts.map +1 -1
  289. package/dist/models/audio/types.d.ts +23 -3
  290. package/dist/models/audio/types.d.ts.map +1 -1
  291. package/dist/models/calls.d.ts +7 -0
  292. package/dist/models/calls.d.ts.map +1 -1
  293. package/dist/models/catalog.d.ts +5 -0
  294. package/dist/models/catalog.d.ts.map +1 -1
  295. package/dist/models/definitions.d.ts +3 -2
  296. package/dist/models/definitions.d.ts.map +1 -1
  297. package/dist/models/errors.d.ts +5 -3
  298. package/dist/models/errors.d.ts.map +1 -1
  299. package/dist/models/events.d.ts +2 -0
  300. package/dist/models/events.d.ts.map +1 -1
  301. package/dist/models/execution/index.d.ts +1 -0
  302. package/dist/models/execution/index.d.ts.map +1 -1
  303. package/dist/models/execution/index.js +33 -28
  304. package/dist/models/execution/index.js.map +1 -1
  305. package/dist/models/execution/model-call-limits.d.ts.map +1 -1
  306. package/dist/models/execution/model-call-recorder.d.ts +8 -0
  307. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  308. package/dist/models/execution/session.d.ts +12 -0
  309. package/dist/models/execution/session.d.ts.map +1 -1
  310. package/dist/models/execution/usage.d.ts.map +1 -1
  311. package/dist/models/execution.d.ts +1 -1
  312. package/dist/models/execution.d.ts.map +1 -1
  313. package/dist/models/generation-types.d.ts +2 -0
  314. package/dist/models/generation-types.d.ts.map +1 -1
  315. package/dist/models/index.d.ts +4 -2
  316. package/dist/models/index.d.ts.map +1 -1
  317. package/dist/models/index.js +2 -2
  318. package/dist/models/input-file.d.ts.map +1 -1
  319. package/dist/models/pricing.d.ts +2 -1
  320. package/dist/models/pricing.d.ts.map +1 -1
  321. package/dist/models/rate-card.d.ts +6 -0
  322. package/dist/models/rate-card.d.ts.map +1 -1
  323. package/dist/models/tools.d.ts +5 -0
  324. package/dist/models/tools.d.ts.map +1 -1
  325. package/dist/models/video/catalog.d.ts +13 -0
  326. package/dist/models/video/catalog.d.ts.map +1 -0
  327. package/dist/models/video/check.d.ts +76 -0
  328. package/dist/models/video/check.d.ts.map +1 -0
  329. package/dist/models/video/runtime.d.ts +21 -0
  330. package/dist/models/video/runtime.d.ts.map +1 -0
  331. package/dist/models/video/types.d.ts +188 -0
  332. package/dist/models/video/types.d.ts.map +1 -0
  333. package/dist/objects/execution.d.ts.map +1 -1
  334. package/dist/objects/index.js +52 -49
  335. package/dist/objects/index.js.map +1 -1
  336. package/dist/objects/query/index.js +25 -23
  337. package/dist/objects/query/index.js.map +1 -1
  338. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  339. package/dist/ontology/index.js +4 -4
  340. package/dist/ontology/internal.js +4 -4
  341. package/dist/pipelines/index.js +28 -26
  342. package/dist/pipelines/index.js.map +1 -1
  343. package/dist/projections/internal.js +26 -24
  344. package/dist/projections/internal.js.map +1 -1
  345. package/dist/queues/index.d.ts +1 -1
  346. package/dist/queues/index.d.ts.map +1 -1
  347. package/dist/queues/types.d.ts +103 -6
  348. package/dist/queues/types.d.ts.map +1 -1
  349. package/dist/runtime/host.d.ts.map +1 -1
  350. package/dist/runtime/internal.d.ts +3 -1
  351. package/dist/runtime/internal.d.ts.map +1 -1
  352. package/dist/runtime/internal.js +49 -43
  353. package/dist/runtime/internal.js.map +2 -2
  354. package/dist/runtime/sixb.d.ts.map +1 -1
  355. package/dist/sandboxes/index.js +6 -6
  356. package/dist/security/public.d.ts +6 -4
  357. package/dist/security/public.d.ts.map +1 -1
  358. package/dist/security/public.js +5 -3
  359. package/dist/security/public.js.map +1 -1
  360. package/dist/shares/internal.js +25 -23
  361. package/dist/shares/internal.js.map +2 -2
  362. package/dist/storage/agents/in-memory.d.ts +2 -1
  363. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  364. package/dist/storage/agents/index.d.ts +1 -1
  365. package/dist/storage/agents/index.d.ts.map +1 -1
  366. package/dist/storage/agents/provider.js +4 -4
  367. package/dist/storage/agents/types.d.ts +13 -0
  368. package/dist/storage/agents/types.d.ts.map +1 -1
  369. package/dist/storage/ai-cost/analytics.d.ts +1 -0
  370. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  371. package/dist/storage/ai-cost/groups.d.ts +2 -0
  372. package/dist/storage/ai-cost/groups.d.ts.map +1 -1
  373. package/dist/storage/ai-cost/provider.js +5 -5
  374. package/dist/storage/ai-cost/types.d.ts +2 -1
  375. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  376. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  377. package/dist/storage/ai-limits/enforcement.js +3 -3
  378. package/dist/storage/ai-limits/provider.js +2 -2
  379. package/dist/storage/ai-usage/in-memory.d.ts +8 -1
  380. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  381. package/dist/storage/ai-usage/index.d.ts +2 -2
  382. package/dist/storage/ai-usage/index.d.ts.map +1 -1
  383. package/dist/storage/ai-usage/record.d.ts +11 -1
  384. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  385. package/dist/storage/ai-usage/types.d.ts +80 -1
  386. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  387. package/dist/storage/ai-usage/usage.d.ts +1 -1
  388. package/dist/storage/ai-usage/usage.d.ts.map +1 -1
  389. package/dist/storage/artifacts/in-memory.d.ts +25 -2
  390. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  391. package/dist/storage/artifacts/index.d.ts +1 -1
  392. package/dist/storage/artifacts/index.d.ts.map +1 -1
  393. package/dist/storage/artifacts/record.d.ts +12 -1
  394. package/dist/storage/artifacts/record.d.ts.map +1 -1
  395. package/dist/storage/artifacts/types.d.ts +198 -6
  396. package/dist/storage/artifacts/types.d.ts.map +1 -1
  397. package/dist/storage/executions/provider.js +3 -2
  398. package/dist/storage/executions/provider.js.map +1 -1
  399. package/dist/storage/file-upload-sessions/provider.js +10 -9
  400. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  401. package/dist/storage/in-memory/index.d.ts.map +1 -1
  402. package/dist/storage/index.d.ts +4 -4
  403. package/dist/storage/index.d.ts.map +1 -1
  404. package/dist/storage/index.js +24 -22
  405. package/dist/storage/index.js.map +1 -1
  406. package/dist/storage/internal.d.ts +2 -2
  407. package/dist/storage/internal.d.ts.map +1 -1
  408. package/dist/storage/internal.js +34 -14
  409. package/dist/storage/internal.js.map +2 -2
  410. package/dist/storage/workflow-runs/provider.js +10 -9
  411. package/dist/storage/workflow-runs/provider.js.map +1 -1
  412. package/dist/syncs/index.js +29 -27
  413. package/dist/syncs/index.js.map +1 -1
  414. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  415. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  416. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  417. package/dist/testing/artifact-storage-contract.d.ts +3 -0
  418. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  419. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  420. package/dist/testing/index.js +619 -72
  421. package/dist/testing/index.js.map +9 -9
  422. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  423. package/dist/testing/queues-contract.d.ts.map +1 -1
  424. package/dist/webhooks/internal.js +26 -24
  425. package/dist/webhooks/internal.js.map +2 -2
  426. package/dist/workers/index.js +5 -5
  427. package/dist/workers/index.js.map +1 -1
  428. package/dist/workflows/index.js +58 -55
  429. package/dist/workflows/index.js.map +1 -1
  430. package/package.json +3 -1
  431. package/src/actions/request.ts +2 -0
  432. package/src/actions/run/context.ts +1 -0
  433. package/src/actions/run/execute.ts +5 -1
  434. package/src/actions/run/executor.ts +4 -0
  435. package/src/actions/run/normalize.ts +4 -0
  436. package/src/actions/run/types.ts +6 -0
  437. package/src/actions/types/context.ts +7 -0
  438. package/src/agents/README.md +3 -1
  439. package/src/agents/context/entries.ts +63 -9
  440. package/src/agents/context-model.ts +9 -0
  441. package/src/agents/context-resolution.ts +7 -0
  442. package/src/agents/execution.ts +39 -0
  443. package/src/agents/model-call-retry.ts +69 -0
  444. package/src/agents/model-loop.ts +86 -12
  445. package/src/agents/run-artifacts.ts +10 -5
  446. package/src/agents/run-plan.ts +2 -1
  447. package/src/agents/run-session-http.ts +1 -0
  448. package/src/agents/run-session-serve.ts +23 -2
  449. package/src/agents/run-session-wire.ts +45 -0
  450. package/src/agents/thread-access.ts +34 -1
  451. package/src/agents/tool-files.ts +23 -7
  452. package/src/artifacts/caller.ts +42 -0
  453. package/src/artifacts/comment-place.ts +51 -0
  454. package/src/artifacts/comment-text.ts +50 -7
  455. package/src/artifacts/comments.ts +132 -34
  456. package/src/artifacts/errors.ts +1 -0
  457. package/src/artifacts/execution.ts +249 -5
  458. package/src/artifacts/frames/assets.ts +93 -15
  459. package/src/artifacts/frames/entries.ts +7 -4
  460. package/src/artifacts/frames/generated/hyperframes-notices.txt +290 -0
  461. package/src/artifacts/frames/generated/hyperframes.txt +1145 -0
  462. package/src/artifacts/frames/generated.d.ts +5 -0
  463. package/src/artifacts/frames/hyperframes.ts +14 -0
  464. package/src/artifacts/frames/index.ts +5 -0
  465. package/src/artifacts/frames/kit.ts +7 -3
  466. package/src/artifacts/frames/protocol.ts +56 -0
  467. package/src/artifacts/frames/video-runtime.ts +165 -0
  468. package/src/artifacts/html.ts +13 -0
  469. package/src/artifacts/index.ts +7 -0
  470. package/src/artifacts/kinds.ts +9 -1
  471. package/src/artifacts/limits.ts +43 -0
  472. package/src/artifacts/live/document.ts +27 -3
  473. package/src/artifacts/live/index.ts +58 -2
  474. package/src/artifacts/live/presence.ts +17 -5
  475. package/src/artifacts/live/protocol.ts +4 -2
  476. package/src/artifacts/live/server.ts +1 -1
  477. package/src/artifacts/live/state.ts +3 -3
  478. package/src/artifacts/media/README.md +75 -0
  479. package/src/artifacts/media/media.ts +316 -0
  480. package/src/artifacts/media/transcriber.ts +84 -0
  481. package/src/artifacts/outline.ts +28 -0
  482. package/src/artifacts/publish/files.ts +19 -6
  483. package/src/artifacts/publish/index.ts +49 -2
  484. package/src/artifacts/publish/pdf.ts +3 -1
  485. package/src/artifacts/publish/previews.ts +22 -8
  486. package/src/artifacts/publish/publish.ts +4 -1
  487. package/src/artifacts/publish/validate/html.ts +23 -18
  488. package/src/artifacts/publish/validate/video.ts +309 -0
  489. package/src/artifacts/publish/video.ts +235 -0
  490. package/src/artifacts/resolve.ts +45 -0
  491. package/src/artifacts/video/README.md +402 -0
  492. package/src/artifacts/video/composition.ts +898 -0
  493. package/src/artifacts/video/edit.ts +3967 -0
  494. package/src/artifacts/video/export.ts +352 -0
  495. package/src/artifacts/video/looks.ts +694 -0
  496. package/src/artifacts/video/project.ts +198 -0
  497. package/src/artifacts/video/stills.ts +168 -0
  498. package/src/artifacts/video/timeline.ts +658 -0
  499. package/src/blob-storage/browser.ts +1 -1
  500. package/src/blob-storage/constants.ts +9 -3
  501. package/src/blob-storage/download-urls.ts +5 -3
  502. package/src/blob-storage/index.ts +1 -0
  503. package/src/blob-storage/internal.ts +13 -2
  504. package/src/blob-storage/media-type.ts +149 -8
  505. package/src/errors/catalog.ts +2 -1
  506. package/src/execution/authorization.ts +2 -2
  507. package/src/execution/kernel-operation.ts +14 -0
  508. package/src/execution/types.ts +2 -0
  509. package/src/http/api-routes.ts +117 -0
  510. package/src/index.ts +18 -1
  511. package/src/lake-storage/definition-updates.ts +3 -9
  512. package/src/models/audio/runtime.ts +48 -3
  513. package/src/models/audio/speech.ts +2 -2
  514. package/src/models/audio/types.ts +24 -3
  515. package/src/models/calls.ts +35 -18
  516. package/src/models/catalog.ts +9 -2
  517. package/src/models/definitions.ts +4 -2
  518. package/src/models/errors.ts +5 -3
  519. package/src/models/events.ts +2 -0
  520. package/src/models/execution/README.md +68 -2
  521. package/src/models/execution/index.ts +1 -0
  522. package/src/models/execution/model-call-limits.ts +11 -5
  523. package/src/models/execution/model-call-recorder.ts +14 -0
  524. package/src/models/execution/session.ts +52 -23
  525. package/src/models/execution/usage.ts +1 -0
  526. package/src/models/execution.ts +13 -2
  527. package/src/models/generation-types.ts +2 -0
  528. package/src/models/index.ts +20 -1
  529. package/src/models/input-file.ts +7 -2
  530. package/src/models/pricing.ts +19 -1
  531. package/src/models/rate-card.ts +15 -3
  532. package/src/models/tools.ts +5 -0
  533. package/src/models/video/catalog.ts +101 -0
  534. package/src/models/video/check.ts +441 -0
  535. package/src/models/video/runtime.ts +550 -0
  536. package/src/models/video/types.ts +194 -0
  537. package/src/objects/execution.ts +2 -0
  538. package/src/objects/sdk/object-set.ts +2 -0
  539. package/src/queues/index.ts +5 -0
  540. package/src/queues/types.ts +126 -5
  541. package/src/runtime/host.ts +3 -0
  542. package/src/runtime/internal.ts +3 -1
  543. package/src/runtime/sixb.ts +12 -4
  544. package/src/sandboxes/README.md +3 -2
  545. package/src/security/public.ts +6 -4
  546. package/src/storage/agents/in-memory.ts +39 -0
  547. package/src/storage/agents/index.ts +1 -0
  548. package/src/storage/agents/types.ts +14 -0
  549. package/src/storage/ai-cost/analytics.ts +2 -0
  550. package/src/storage/ai-cost/codec.ts +1 -0
  551. package/src/storage/ai-cost/groups.ts +7 -0
  552. package/src/storage/ai-cost/types.ts +2 -0
  553. package/src/storage/ai-cost/validation.ts +2 -0
  554. package/src/storage/ai-usage/in-memory.ts +93 -0
  555. package/src/storage/ai-usage/index.ts +10 -0
  556. package/src/storage/ai-usage/record.ts +106 -0
  557. package/src/storage/ai-usage/types.ts +102 -1
  558. package/src/storage/ai-usage/usage.ts +2 -0
  559. package/src/storage/artifacts/in-memory.ts +108 -11
  560. package/src/storage/artifacts/index.ts +14 -0
  561. package/src/storage/artifacts/record.ts +203 -1
  562. package/src/storage/artifacts/types.ts +199 -6
  563. package/src/storage/executions/validation.ts +2 -2
  564. package/src/storage/in-memory/index.ts +1 -1
  565. package/src/storage/index.ts +22 -1
  566. package/src/storage/internal.ts +9 -0
  567. package/src/testing/agent-storage-contract.ts +108 -0
  568. package/src/testing/ai-cost-storage-contract.ts +1 -0
  569. package/src/testing/ai-usage-storage-contract.ts +145 -1
  570. package/src/testing/artifact-storage-contract.ts +320 -0
  571. package/src/testing/execution-storage-contract.ts +10 -2
  572. package/src/testing/lake-storage-contract.ts +27 -0
  573. package/src/testing/queues-contract.ts +71 -0
  574. package/dist/chunk-3723kgba.js +0 -29
  575. package/dist/chunk-3723kgba.js.map +0 -10
  576. package/dist/chunk-3qtk0070.js.map +0 -14
  577. package/dist/chunk-8ncg20rd.js.map +0 -10
  578. package/dist/chunk-9vsc919v.js.map +0 -10
  579. package/dist/chunk-az95tsh3.js.map +0 -11
  580. package/dist/chunk-c29729me.js.map +0 -12
  581. package/dist/chunk-d7vyc7k6.js.map +0 -10
  582. package/dist/chunk-de5sfbc3.js +0 -3
  583. package/dist/chunk-gfdh9kqa.js.map +0 -11
  584. package/dist/chunk-hvq8xs66.js.map +0 -34
  585. package/dist/chunk-k29rdc3h.js.map +0 -10
  586. package/dist/chunk-mbwsgjn7.js.map +0 -11
  587. package/dist/chunk-phs5fbff.js.map +0 -19
  588. package/dist/chunk-qttqe1ah.js.map +0 -24
  589. package/dist/chunk-sgx82nnt.js.map +0 -10
  590. package/dist/chunk-vs2s3p8n.js +0 -2274
  591. package/dist/chunk-vs2s3p8n.js.map +0 -20
  592. package/dist/chunk-wkv3h3q7.js.map +0 -12
  593. package/dist/chunk-wzcjhv54.js.map +0 -11
  594. package/dist/chunk-xtztwpkh.js.map +0 -12
  595. /package/dist/{chunk-7mhbs9yy.js.map → chunk-1z8ccj53.js.map} +0 -0
  596. /package/dist/{chunk-dmnd9ea6.js.map → chunk-30a0ftnm.js.map} +0 -0
  597. /package/dist/{chunk-qbd282aa.js.map → chunk-39q9ybav.js.map} +0 -0
  598. /package/dist/{chunk-fdk0ks9p.js.map → chunk-3x902cja.js.map} +0 -0
  599. /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
  600. /package/dist/{chunk-cpy282b8.js.map → chunk-4w8qzy9w.js.map} +0 -0
  601. /package/dist/{chunk-xavet0qs.js.map → chunk-6whr25gw.js.map} +0 -0
  602. /package/dist/{chunk-ygvay56w.js.map → chunk-896te58g.js.map} +0 -0
  603. /package/dist/{chunk-pfdq1ga6.js.map → chunk-8eqqqc1h.js.map} +0 -0
  604. /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
  605. /package/dist/{chunk-6md802cc.js.map → chunk-9az7kjv4.js.map} +0 -0
  606. /package/dist/{chunk-95ps0k5q.js.map → chunk-9e5t53z0.js.map} +0 -0
  607. /package/dist/{chunk-js9e6487.js.map → chunk-9p7kyeqz.js.map} +0 -0
  608. /package/dist/{chunk-brybqw5k.js.map → chunk-bkxm2dzx.js.map} +0 -0
  609. /package/dist/{chunk-ppxf7gw2.js.map → chunk-d7t9jnym.js.map} +0 -0
  610. /package/dist/{chunk-cg7cygfj.js.map → chunk-fdmvaz7x.js.map} +0 -0
  611. /package/dist/{chunk-191jz8a6.js.map → chunk-ff0qdk7z.js.map} +0 -0
  612. /package/dist/{chunk-wx7smkn2.js.map → chunk-fq8drkp0.js.map} +0 -0
  613. /package/dist/{chunk-v8a1qjzp.js.map → chunk-hpswfrjj.js.map} +0 -0
  614. /package/dist/{chunk-bz5bnjjt.js.map → chunk-jjte0h4p.js.map} +0 -0
  615. /package/dist/{chunk-xrmbhap8.js.map → chunk-mwg0nwkb.js.map} +0 -0
  616. /package/dist/{chunk-a3faa34j.js.map → chunk-nfjt8k8j.js.map} +0 -0
  617. /package/dist/{chunk-394zjzjs.js.map → chunk-nhgqz3g3.js.map} +0 -0
  618. /package/dist/{chunk-92wrka15.js.map → chunk-q150fnj9.js.map} +0 -0
  619. /package/dist/{chunk-w3t94hm6.js.map → chunk-qk3zq25v.js.map} +0 -0
  620. /package/dist/{chunk-5qqmndhm.js.map → chunk-szzhrn3e.js.map} +0 -0
  621. /package/dist/{chunk-n1hbwc6y.js.map → chunk-t6pfch4e.js.map} +0 -0
  622. /package/dist/{chunk-brhp9d97.js.map → chunk-vmqjndb3.js.map} +0 -0
  623. /package/dist/{chunk-t58sktr5.js.map → chunk-wrb1x1ss.js.map} +0 -0
  624. /package/dist/{chunk-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
  625. /package/dist/{chunk-04r2fdsd.js.map → chunk-x0hqc54n.js.map} +0 -0
  626. /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
  627. /package/dist/{chunk-5pz3htbe.js.map → chunk-y57eawng.js.map} +0 -0
@@ -40,8 +40,8 @@ export interface FileDownloadUrl {
40
40
  /** What issuing and revoking need from the execution that asks. */
41
41
  export interface FileDownloadUrlContext {
42
42
  readonly projectId: string
43
- readonly storage: Storage
44
- readonly blobStorage: BlobStorage
43
+ readonly storage: Pick<Storage, "fileDownloadGrants">
44
+ readonly blobStorage: Pick<BlobStorage, "stat">
45
45
  readonly executionId: string
46
46
  readonly apiPublicOrigin: string | undefined
47
47
  }
@@ -119,7 +119,9 @@ function hashToken(token: string): string {
119
119
  return createHash("sha256").update(token).digest("hex")
120
120
  }
121
121
 
122
- function requireGrantStorage(storage: Storage): FileDownloadGrantStorage {
122
+ function requireGrantStorage(
123
+ storage: Pick<Storage, "fileDownloadGrants">
124
+ ): FileDownloadGrantStorage {
123
125
  if (!storage.fileDownloadGrants) {
124
126
  throw new Error("[Sixb] Download URLs require storage.fileDownloadGrants.")
125
127
  }
@@ -6,6 +6,7 @@ export {
6
6
  fileNameFor,
7
7
  isBlobDigest,
8
8
  isFileRef,
9
+ MAX_FILE_UPLOAD_BYTES,
9
10
  } from "./browser"
10
11
  export { BlobStorageError } from "./errors"
11
12
  export { InMemoryBlobStorage } from "./in-memory"
@@ -1,8 +1,19 @@
1
- export { FILE_DOWNLOAD_ROUTE_PREFIX, resolveFileDownload } from "./download-urls"
1
+ export {
2
+ createFileDownloadUrl,
3
+ FILE_DOWNLOAD_ROUTE_PREFIX,
4
+ type FileDownloadUrlContext,
5
+ resolveFileDownload,
6
+ revokeFileDownloadUrl,
7
+ } from "./download-urls"
2
8
  export {
3
9
  jsonPointerSegment,
4
10
  openFileRef,
5
11
  resolveFileRefAtPath,
6
12
  statFileRef,
7
13
  } from "./file-content"
8
- export { canonicalMediaType, inferFileMediaType, sniffFileMediaType } from "./media-type"
14
+ export {
15
+ canonicalMediaType,
16
+ inferFileMediaType,
17
+ sniffFileMediaType,
18
+ UNTYPED_MEDIA_TYPE,
19
+ } from "./media-type"
@@ -13,7 +13,8 @@ const PARAMETER_PATTERN = new RegExp(PARAMETER, "g")
13
13
  * The canonical form of a single well-formed media type, or `null` for anything else.
14
14
  *
15
15
  * Type, subtype, and parameter names are case-insensitive, so they are lowercased; parameter
16
- * values keep their case. `"Text/Plain; Charset=UTF-8"` becomes `"text/plain;charset=UTF-8"`.
16
+ * values keep their case. `"Text/Plain; Charset=UTF-8"` becomes `"text/plain;charset=UTF-8"`. A
17
+ * common alias becomes the type browsers know: `audio/x-m4a` is `audio/mp4`.
17
18
  */
18
19
  export function canonicalMediaType(value: unknown): string | null {
19
20
  if (typeof value !== "string") return null
@@ -21,17 +22,44 @@ export function canonicalMediaType(value: unknown): string | null {
21
22
  if (!match) return null
22
23
 
23
24
  const [, type, subtype, parameters] = match
24
- let canonical = `${type.toLowerCase()}/${subtype.toLowerCase()}`
25
+ let canonical = unaliasMediaType(`${type.toLowerCase()}/${subtype.toLowerCase()}`)
25
26
  for (const [, name, parameterValue] of parameters.matchAll(PARAMETER_PATTERN)) {
26
27
  canonical += `;${name.toLowerCase()}=${parameterValue}`
27
28
  }
28
29
  return canonical
29
30
  }
30
31
 
32
+ /**
33
+ * A lowercased `type/subtype` under the name browsers know it by. Operating systems and older
34
+ * tools name some formats otherwise, and a browser opens a type it does not know as a download.
35
+ */
36
+ export function unaliasMediaType(mediaType: string): string {
37
+ return MEDIA_TYPE_ALIASES.get(mediaType) ?? mediaType
38
+ }
39
+
40
+ const MEDIA_TYPE_ALIASES: ReadonlyMap<string, string> = new Map([
41
+ ["audio/aacp", "audio/aac"],
42
+ ["audio/m4a", "audio/mp4"],
43
+ ["audio/mp3", "audio/mpeg"],
44
+ ["audio/mpeg3", "audio/mpeg"],
45
+ ["audio/vnd.wave", "audio/wav"],
46
+ ["audio/wave", "audio/wav"],
47
+ ["audio/x-aac", "audio/aac"],
48
+ ["audio/x-flac", "audio/flac"],
49
+ ["audio/x-m4a", "audio/mp4"],
50
+ ["audio/x-mp3", "audio/mpeg"],
51
+ ["audio/x-mpeg", "audio/mpeg"],
52
+ ["audio/x-mpeg-3", "audio/mpeg"],
53
+ ["audio/x-wav", "audio/wav"],
54
+ ["image/jpg", "image/jpeg"],
55
+ ["video/x-m4v", "video/mp4"],
56
+ ])
57
+
31
58
  /**
32
59
  * The media type a file's bytes declare by their leading signature, or `undefined` when they carry
33
- * none this function knows. Only formats with an unambiguous signature are recognized; text formats
34
- * have none and are left to the file name.
60
+ * none this function knows. Only formats with an unambiguous signature are recognized, and MP3 by
61
+ * a frame header whose every field is checked; text formats have none and are left to the file
62
+ * name.
35
63
  */
36
64
  export function sniffFileMediaType(bytes: Uint8Array): string | undefined {
37
65
  if (startsWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])) return "image/png"
@@ -39,9 +67,20 @@ export function sniffFileMediaType(bytes: Uint8Array): string | undefined {
39
67
  if (asciiAt(bytes, 0, "GIF87a") || asciiAt(bytes, 0, "GIF89a")) return "image/gif"
40
68
  if (asciiAt(bytes, 0, "RIFF") && asciiAt(bytes, 8, "WEBP")) return "image/webp"
41
69
  if (asciiAt(bytes, 0, "%PDF-")) return "application/pdf"
42
- return undefined
70
+
71
+ if (asciiAt(bytes, 4, "ftyp")) return MP4_BRANDS.get(ascii(bytes, 8, 4))
72
+ if (startsWith(bytes, [0x1a, 0x45, 0xdf, 0xa3]))
73
+ return MATROSKA_DOC_TYPES.get(matroskaDocType(bytes))
74
+ if (asciiAt(bytes, 0, "OggS")) return oggMediaType(bytes)
75
+ if (asciiAt(bytes, 0, "RIFF") && asciiAt(bytes, 8, "WAVE")) return "audio/wav"
76
+ if (asciiAt(bytes, 0, "fLaC")) return "audio/flac"
77
+ if (asciiAt(bytes, 0, "ID3")) return "audio/mpeg"
78
+ return mpegAudioMediaType(bytes)
43
79
  }
44
80
 
81
+ /** The type that says only "bytes": a file's when nothing tells more, or a client's default. */
82
+ export const UNTYPED_MEDIA_TYPE = "application/octet-stream"
83
+
45
84
  /**
46
85
  * The media type of a file handed over without one: its bytes' signature when they have one, else
47
86
  * its extension, else `application/octet-stream`. Every place that classifies a sandbox or tool file
@@ -49,17 +88,23 @@ export function sniffFileMediaType(bytes: Uint8Array): string | undefined {
49
88
  */
50
89
  export function inferFileMediaType(fileName: string, bytes?: Uint8Array): string {
51
90
  const sniffed = bytes === undefined ? undefined : sniffFileMediaType(bytes)
52
- if (sniffed) return sniffed
53
91
  const dot = fileName.lastIndexOf(".")
54
- const extension = dot < 0 ? "" : fileName.slice(dot).toLowerCase()
55
- return EXTENSION_MEDIA_TYPES[extension] ?? "application/octet-stream"
92
+ const named = EXTENSION_MEDIA_TYPES[dot < 0 ? "" : fileName.slice(dot).toLowerCase()]
93
+
94
+ // An MP4 or a WebM signature names the container, and only the name can say it holds sound
95
+ // alone. An Ogg one names the codec: Theora is video whatever the name says.
96
+ const sound = sniffed === undefined ? undefined : SOUND_OR_VIDEO_CONTAINERS.get(sniffed)
97
+ if (sound !== undefined && sound === named) return sound
98
+ return sniffed ?? named ?? UNTYPED_MEDIA_TYPE
56
99
  }
57
100
 
58
101
  const EXTENSION_MEDIA_TYPES: Readonly<Record<string, string>> = {
102
+ ".aac": "audio/aac",
59
103
  ".bmp": "image/bmp",
60
104
  ".css": "text/css",
61
105
  ".csv": "text/csv",
62
106
  ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
107
+ ".flac": "audio/flac",
63
108
  ".gif": "image/gif",
64
109
  ".htm": "text/html",
65
110
  ".html": "text/html",
@@ -68,15 +113,30 @@ const EXTENSION_MEDIA_TYPES: Readonly<Record<string, string>> = {
68
113
  ".js": "application/javascript",
69
114
  ".json": "application/json",
70
115
  ".jsonl": "application/x-ndjson",
116
+ ".m4a": "audio/mp4",
117
+ ".m4v": "video/mp4",
71
118
  ".markdown": "text/markdown",
72
119
  ".md": "text/markdown",
73
120
  ".mjs": "application/javascript",
121
+ ".mkv": "video/x-matroska",
122
+ ".mov": "video/quicktime",
123
+ ".mp3": "audio/mpeg",
124
+ ".mp4": "video/mp4",
125
+ ".oga": "audio/ogg",
126
+ ".ogg": "audio/ogg",
127
+ ".ogv": "video/ogg",
128
+ ".opus": "audio/ogg",
74
129
  ".pdf": "application/pdf",
75
130
  ".png": "image/png",
76
131
  ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
132
+ ".srt": "application/x-subrip",
77
133
  ".svg": "image/svg+xml",
78
134
  ".tsv": "text/tab-separated-values",
79
135
  ".txt": "text/plain",
136
+ ".vtt": "text/vtt",
137
+ ".wav": "audio/wav",
138
+ ".weba": "audio/webm",
139
+ ".webm": "video/webm",
80
140
  ".webp": "image/webp",
81
141
  ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
82
142
  ".xml": "application/xml",
@@ -85,6 +145,83 @@ const EXTENSION_MEDIA_TYPES: Readonly<Record<string, string>> = {
85
145
  ".zip": "application/zip",
86
146
  }
87
147
 
148
+ // An ISO media file opens with an `ftyp` box whose major brand names its family. Only brands that
149
+ // say what the file is count: an AVIF or a HEIC image is in the same box format.
150
+ const MP4_BRANDS: ReadonlyMap<string, string> = new Map([
151
+ ["avc1", "video/mp4"],
152
+ ["dash", "video/mp4"],
153
+ ["iso2", "video/mp4"],
154
+ ["iso4", "video/mp4"],
155
+ ["iso5", "video/mp4"],
156
+ ["iso6", "video/mp4"],
157
+ ["isom", "video/mp4"],
158
+ ["mp41", "video/mp4"],
159
+ ["mp42", "video/mp4"],
160
+ ["M4V ", "video/mp4"],
161
+ ["M4A ", "audio/mp4"],
162
+ ["M4B ", "audio/mp4"],
163
+ ["qt ", "video/quicktime"],
164
+ ])
165
+
166
+ /** The containers whose signature cannot tell video from sound alone, and their sound type. */
167
+ const SOUND_OR_VIDEO_CONTAINERS: ReadonlyMap<string, string> = new Map([
168
+ ["video/mp4", "audio/mp4"],
169
+ ["video/webm", "audio/webm"],
170
+ ])
171
+
172
+ const MATROSKA_DOC_TYPES: ReadonlyMap<string, string> = new Map([
173
+ ["webm", "video/webm"],
174
+ ["matroska", "video/x-matroska"],
175
+ ])
176
+
177
+ /**
178
+ * A Matroska file's DocType, `webm` or `matroska`, from its EBML header: the element `42 82`, its
179
+ * size as a one-byte variable-length integer, then the name. Writers put it in the first bytes.
180
+ */
181
+ function matroskaDocType(bytes: Uint8Array): string {
182
+ const head = bytes.subarray(0, 64)
183
+ for (let index = 4; index + 2 < head.byteLength; index += 1) {
184
+ if (head[index] !== 0x42 || head[index + 1] !== 0x82) continue
185
+ // A one-byte size has its top bit set; longer ones never hold a DocType this short.
186
+ const size = head[index + 2] ?? 0
187
+ return size & 0x80 ? ascii(head, index + 3, size & 0x7f) : ""
188
+ }
189
+ return ""
190
+ }
191
+
192
+ /** An Ogg stream's first packet names its codec: Theora is video, Opus, Vorbis, or FLAC sound. */
193
+ function oggMediaType(bytes: Uint8Array): string {
194
+ // The first page's 27-byte header, then its segment table, then the packet.
195
+ const packet = 27 + (bytes[26] ?? 0)
196
+ return asciiAt(bytes, packet + 1, "theora") ? "video/ogg" : "audio/ogg"
197
+ }
198
+
199
+ /**
200
+ * MP3, or AAC in ADTS, without an ID3 tag: a frame header, 11 set bits of sync, whose fields must
201
+ * also hold values a real frame can have, so that arbitrary bytes starting with `FF E0` do not pass.
202
+ */
203
+ function mpegAudioMediaType(bytes: Uint8Array): string | undefined {
204
+ const [first = 0, second = 0, third = 0] = bytes
205
+ if (bytes.byteLength < 3 || first !== 0xff || (second & 0xe0) !== 0xe0) return undefined
206
+
207
+ // ADTS: a 12-bit sync, layer 0, and a sampling frequency index under 13.
208
+ const layer = (second >> 1) & 0b11
209
+ if (layer === 0) {
210
+ return (second & 0xf0) === 0xf0 && ((third >> 2) & 0b1111) < 13 ? "audio/aac" : undefined
211
+ }
212
+
213
+ // MP3: layer III, and a version, a bitrate, and a sampling rate that are not the reserved values.
214
+ // Layers I and II are left to the name: `FF FE`, the byte order mark that opens UTF-16 text,
215
+ // reads as a layer I header.
216
+ const version = (second >> 3) & 0b11
217
+ const bitrate = third >> 4
218
+ const sampleRate = (third >> 2) & 0b11
219
+ if (layer !== 0b01 || version === 0b01 || bitrate === 0b1111 || sampleRate === 0b11) {
220
+ return undefined
221
+ }
222
+ return "audio/mpeg"
223
+ }
224
+
88
225
  function startsWith(bytes: Uint8Array, signature: readonly number[]): boolean {
89
226
  return signature.every((byte, index) => bytes[index] === byte)
90
227
  }
@@ -96,3 +233,7 @@ function asciiAt(bytes: Uint8Array, offset: number, value: string): boolean {
96
233
  }
97
234
  return true
98
235
  }
236
+
237
+ function ascii(bytes: Uint8Array, offset: number, length: number): string {
238
+ return String.fromCharCode(...bytes.subarray(offset, offset + length))
239
+ }
@@ -23,7 +23,8 @@ export const SIXB_ERROR_DEFINITIONS = {
23
23
  publicMessage: "Data the Action read changed before its commit.",
24
24
  retryable: true,
25
25
  },
26
- // Not a crash: a validator declined the request, with a message written for the caller.
26
+ // Not a crash: a validator, or a handler throwing an ActionValidationError, declined the request
27
+ // with a message written for the caller.
27
28
  "action.rejected": {
28
29
  publicMessage: "The Action rejected the request.",
29
30
  retryable: false,
@@ -20,7 +20,7 @@ import type {
20
20
  CompiledSelectedObjectReadScope,
21
21
  SelectedObjectReadScope,
22
22
  } from "../storage/objects/types"
23
- import { kernelOperationFromId, kernelOperationId } from "./kernel-operation"
23
+ import { isKernelOperationType, kernelOperationFromId, kernelOperationId } from "./kernel-operation"
24
24
  import { assertScriptPath } from "./script"
25
25
  import {
26
26
  type AuthorizablePrincipal,
@@ -829,7 +829,7 @@ function snapshotTrustedPrimitive(primitive: TrustedPrimitiveRef): TrustedPrimit
829
829
  }
830
830
 
831
831
  function snapshotKernelOperation(operation: KernelOperation): KernelOperation {
832
- if (operation.type !== "ontology.recover" && operation.type !== "ontology.indexVectors") {
832
+ if (!isKernelOperationType(operation.type)) {
833
833
  throw new Error(
834
834
  `[Sixb] Unknown kernel operation '${String((operation as { type?: unknown }).type)}'.`
835
835
  )
@@ -1,11 +1,23 @@
1
1
  import type { KernelOperation } from "./types"
2
2
 
3
+ const KERNEL_OPERATION_TYPES: ReadonlySet<string> = new Set<KernelOperation["type"]>([
4
+ "ontology.recover",
5
+ "ontology.indexVectors",
6
+ "artifacts.transcribeMedia",
7
+ ])
8
+
9
+ export function isKernelOperationType(type: unknown): type is KernelOperation["type"] {
10
+ return typeof type === "string" && KERNEL_OPERATION_TYPES.has(type)
11
+ }
12
+
3
13
  export function kernelOperationId(operation: KernelOperation): string {
4
14
  switch (operation.type) {
5
15
  case "ontology.recover":
6
16
  return operation.recoveryId
7
17
  case "ontology.indexVectors":
8
18
  return operation.indexingId
19
+ case "artifacts.transcribeMedia":
20
+ return operation.digest
9
21
  default:
10
22
  return unknownOperation(operation)
11
23
  }
@@ -17,6 +29,8 @@ export function kernelOperationFromId(type: KernelOperation["type"], id: string)
17
29
  return { type, recoveryId: id }
18
30
  case "ontology.indexVectors":
19
31
  return { type, indexingId: id }
32
+ case "artifacts.transcribeMedia":
33
+ return { type, digest: id }
20
34
  default:
21
35
  return unknownOperation(type)
22
36
  }
@@ -29,6 +29,8 @@ export interface SharedAccessDelegationRef {
29
29
  export type KernelOperation =
30
30
  | { readonly type: "ontology.recover"; readonly recoveryId: string }
31
31
  | { readonly type: "ontology.indexVectors"; readonly indexingId: string }
32
+ /** Transcribing a video or a sound for what Sixb derives from it, by the digest of its bytes. */
33
+ | { readonly type: "artifacts.transcribeMedia"; readonly digest: string }
32
34
 
33
35
  /** Workload currently executing. This is provenance and never grants authority by itself. */
34
36
  export type ExecutionExecutor =
@@ -328,6 +328,49 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
328
328
  agentApi: true,
329
329
  agentEffect: "file",
330
330
  },
331
+ // A file past the simple upload's ceiling is uploaded staged, as `sixb files upload` does: its
332
+ // session is the caller's alone, and its content reaches blob storage without the server
333
+ // holding it.
334
+ {
335
+ operationId: "createFileUpload",
336
+ method: "POST",
337
+ path: "/api/files/uploads",
338
+ accessToken: true,
339
+ agentApi: true,
340
+ agentEffect: "file",
341
+ },
342
+ {
343
+ operationId: "uploadFileContent",
344
+ method: "PUT",
345
+ path: "/api/files/uploads/:uploadId/content",
346
+ accessToken: true,
347
+ agentApi: true,
348
+ agentEffect: "file",
349
+ },
350
+ {
351
+ operationId: "signFileUploadPart",
352
+ method: "POST",
353
+ path: "/api/files/uploads/:uploadId/parts/:partNumber",
354
+ accessToken: true,
355
+ agentApi: true,
356
+ agentEffect: "file",
357
+ },
358
+ {
359
+ operationId: "completeFileUpload",
360
+ method: "POST",
361
+ path: "/api/files/uploads/:uploadId/complete",
362
+ accessToken: true,
363
+ agentApi: true,
364
+ agentEffect: "file",
365
+ },
366
+ {
367
+ operationId: "abortFileUpload",
368
+ method: "POST",
369
+ path: "/api/files/uploads/:uploadId/abort",
370
+ accessToken: true,
371
+ agentApi: true,
372
+ agentEffect: "file",
373
+ },
331
374
  {
332
375
  operationId: "listActionRuns",
333
376
  method: "GET",
@@ -685,6 +728,41 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
685
728
  agentApi: false,
686
729
  sharedSession: true,
687
730
  },
731
+ {
732
+ operationId: "exportArtifactVideo",
733
+ method: "POST",
734
+ path: "/api/artifacts/:artifactId/versions/:version/video",
735
+ accessToken: true,
736
+ agentApi: true,
737
+ // Rendering changes no artifact: its MP4 and segments are kept under what they are made of,
738
+ // shared by every reader who asks, as a canvas's previews are.
739
+ agentEffect: "read",
740
+ sharedSession: true,
741
+ },
742
+ {
743
+ operationId: "getArtifactVideo",
744
+ method: "GET",
745
+ path: "/api/artifacts/:artifactId/versions/:version/video",
746
+ accessToken: true,
747
+ agentApi: true,
748
+ sharedSession: true,
749
+ },
750
+ {
751
+ operationId: "getArtifactVideoStill",
752
+ method: "GET",
753
+ path: "/api/artifacts/:artifactId/versions/:version/scenes/:scene/still",
754
+ accessToken: true,
755
+ agentApi: false,
756
+ sharedSession: true,
757
+ },
758
+ {
759
+ operationId: "getArtifactVideoPoster",
760
+ method: "GET",
761
+ path: "/api/artifacts/:artifactId/versions/:version/poster",
762
+ accessToken: true,
763
+ agentApi: false,
764
+ sharedSession: true,
765
+ },
688
766
  {
689
767
  operationId: "getArtifactBoardPreview",
690
768
  method: "GET",
@@ -725,6 +803,30 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
725
803
  agentApi: false,
726
804
  sharedSession: true,
727
805
  },
806
+ {
807
+ operationId: "getArtifactMedia",
808
+ method: "GET",
809
+ path: "/api/artifacts/:artifactId/versions/:version/media",
810
+ accessToken: true,
811
+ agentApi: true,
812
+ sharedSession: true,
813
+ },
814
+ {
815
+ operationId: "getArtifactMediaContent",
816
+ method: "GET",
817
+ path: "/api/artifacts/:artifactId/versions/:version/media/content",
818
+ accessToken: true,
819
+ agentApi: true,
820
+ sharedSession: true,
821
+ },
822
+ {
823
+ operationId: "headArtifactMediaContent",
824
+ method: "HEAD",
825
+ path: "/api/artifacts/:artifactId/versions/:version/media/content",
826
+ accessToken: true,
827
+ agentApi: false,
828
+ sharedSession: true,
829
+ },
728
830
  {
729
831
  operationId: "searchObjects",
730
832
  method: "GET",
@@ -946,6 +1048,21 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
946
1048
  agentApi: true,
947
1049
  agentEffect: "model",
948
1050
  },
1051
+ {
1052
+ operationId: "startVideoGeneration",
1053
+ method: "POST",
1054
+ path: "/api/models/video/generations",
1055
+ accessToken: true,
1056
+ agentApi: true,
1057
+ agentEffect: "model",
1058
+ },
1059
+ {
1060
+ operationId: "getVideoGeneration",
1061
+ method: "GET",
1062
+ path: "/api/models/video/generations/:callId",
1063
+ accessToken: true,
1064
+ agentApi: true,
1065
+ },
949
1066
  {
950
1067
  operationId: "generateSpeech",
951
1068
  method: "POST",
package/src/index.ts CHANGED
@@ -996,18 +996,20 @@ export type {
996
996
  AgentThreadView,
997
997
  } from "./agents/thread-access"
998
998
  export type { ArtifactAccess } from "./artifacts/access"
999
- export type { ArtifactCommentInput } from "./artifacts/comments"
999
+ export type { ArtifactCommentInput, ArtifactCommentPlaceInput } from "./artifacts/comments"
1000
1000
  export type { ArtifactRequestErrorCode } from "./artifacts/errors"
1001
1001
  export { ArtifactRequestError } from "./artifacts/errors"
1002
1002
  export type {
1003
1003
  ArtifactContentInput,
1004
1004
  ArtifactHolderObject,
1005
1005
  ArtifactHolders,
1006
+ ArtifactMedia,
1006
1007
  ArtifactPdf,
1007
1008
  ArtifactQueryInput,
1008
1009
  ArtifactStateRuntime,
1009
1010
  ArtifactStateValue,
1010
1011
  ArtifactsRuntime,
1012
+ ArtifactVideoExport,
1011
1013
  ListArtifactsRuntimeInput,
1012
1014
  UpdateArtifactRuntimeInput,
1013
1015
  } from "./artifacts/execution"
@@ -1023,6 +1025,7 @@ export type {
1023
1025
  ArtifactQuerySchema,
1024
1026
  } from "./artifacts/queries"
1025
1027
  export type { ArtifactReference } from "./artifacts/references"
1028
+ export type { VideoExportProgress } from "./artifacts/video/export"
1026
1029
  export type { ArtifactWarning } from "./artifacts/warnings"
1027
1030
  export type { CreateFileDownloadUrlOptions, FileDownloadUrl } from "./blob-storage/download-urls"
1028
1031
  export type { BlobsRuntime } from "./blob-storage/execution"
@@ -1328,9 +1331,16 @@ export type {
1328
1331
  } from "./storage/agents"
1329
1332
  export type {
1330
1333
  ArtifactFile,
1334
+ ArtifactMediaFilmstrip,
1335
+ ArtifactMediaLack,
1336
+ ArtifactMediaPart,
1337
+ ArtifactMediaPartName,
1338
+ ArtifactMediaParts,
1339
+ ArtifactMediaProbe,
1331
1340
  ArtifactOrigin,
1332
1341
  ArtifactRecord,
1333
1342
  ArtifactVersionRecord,
1343
+ ArtifactVideoRenderLack,
1334
1344
  ListArtifactsResult,
1335
1345
  ListArtifactVersionsResult,
1336
1346
  } from "./storage/artifacts"
@@ -1428,6 +1438,13 @@ export type {
1428
1438
  ImageGenerateResult,
1429
1439
  ImageModelsRuntime,
1430
1440
  } from "./models/image/types"
1441
+ export type {
1442
+ VideoGenerateInput,
1443
+ VideoGenerateResult,
1444
+ VideoGeneration,
1445
+ VideoGenerationStatus,
1446
+ VideoModelsRuntime,
1447
+ } from "./models/video/types"
1431
1448
  export type {
1432
1449
  ForeignKeyDescriptor,
1433
1450
  LinkProjectionDefinition,
@@ -206,12 +206,6 @@ function mergeDatasetDefinition(
206
206
  requested: DatasetDefinition,
207
207
  addedColumns: readonly DatasetColumnDefinition[]
208
208
  ): DatasetDefinition {
209
- assertCompatibleMetadataField(
210
- requested.id,
211
- "description",
212
- existing.description,
213
- requested.description
214
- )
215
209
  assertCompatibleMetadataField(
216
210
  requested.id,
217
211
  "partitionBy",
@@ -237,9 +231,9 @@ function mergeDatasetDefinition(
237
231
 
238
232
  function assertCompatibleMetadataField(
239
233
  datasetId: string,
240
- field: "description" | "partitionBy",
241
- existing: string | readonly string[] | undefined,
242
- requested: string | readonly string[] | undefined
234
+ field: "partitionBy",
235
+ existing: readonly string[] | undefined,
236
+ requested: readonly string[] | undefined
243
237
  ): void {
244
238
  if (
245
239
  existing === undefined ||
@@ -19,11 +19,18 @@ import type {
19
19
  TranscriptionModelResponseMetadata,
20
20
  TranscriptionModelResult,
21
21
  TranscriptionOutput,
22
+ TranscriptionSegment,
22
23
  TranscriptionWord,
23
24
  } from "./types"
24
25
 
26
+ /** What audio calls read of their runtime: who calls, to admit them. */
27
+ export type AudioRuntimeContext = Pick<
28
+ SixbRuntimeContext,
29
+ "projectId" | "runtimeAuthorization" | "authorization"
30
+ >
31
+
25
32
  export function createAudioRuntime(
26
- runtime: SixbRuntimeContext,
33
+ runtime: AudioRuntimeContext,
27
34
  execution: ExecutionContext,
28
35
  catalog: ModelCatalog | undefined,
29
36
  session: ModelExecutionSession,
@@ -114,9 +121,20 @@ function transcriptOutput(
114
121
 
115
122
  const output = result?.output
116
123
  if (typeof output?.text !== "string") throw refuse()
124
+ if (output.language !== undefined && (typeof output.language !== "string" || !output.language)) {
125
+ throw refuse()
126
+ }
127
+
128
+ const segments = transcriptSegments(output.segments)
129
+ if (segments === null) throw refuse()
130
+ const described = {
131
+ text: output.text,
132
+ ...(segments.length ? { segments } : {}),
133
+ ...(output.language ? { language: output.language } : {}),
134
+ }
117
135
 
118
136
  const words: readonly unknown[] | undefined = output.words
119
- if (words === undefined) return { text: output.text }
137
+ if (words === undefined) return described
120
138
  if (!Array.isArray(words)) throw refuse()
121
139
 
122
140
  const timed: TranscriptionWord[] = []
@@ -141,7 +159,34 @@ function transcriptOutput(
141
159
  }
142
160
 
143
161
  // An empty list says nothing; the absent field is the one way to say "no words".
144
- return timed.length ? { text: output.text, words: timed } : { text: output.text }
162
+ return timed.length ? { ...described, words: timed } : described
163
+ }
164
+
165
+ /** The segments as they were timed; null when one cannot be trusted, as a word cannot. */
166
+ function transcriptSegments(segments: unknown): TranscriptionSegment[] | null {
167
+ if (segments === undefined) return []
168
+ if (!Array.isArray(segments)) return null
169
+
170
+ const timed: TranscriptionSegment[] = []
171
+ for (const segment of segments) {
172
+ const entry = segment as Partial<TranscriptionSegment> | null | undefined
173
+ if (
174
+ typeof entry?.text !== "string" ||
175
+ !isMillisecond(entry.startMs) ||
176
+ !isMillisecond(entry.endMs) ||
177
+ entry.endMs < entry.startMs ||
178
+ (entry.speaker !== undefined && (typeof entry.speaker !== "string" || !entry.speaker))
179
+ ) {
180
+ return null
181
+ }
182
+ timed.push({
183
+ text: entry.text,
184
+ startMs: entry.startMs,
185
+ endMs: entry.endMs,
186
+ ...(entry.speaker === undefined ? {} : { speaker: entry.speaker }),
187
+ })
188
+ }
189
+ return timed
145
190
  }
146
191
 
147
192
  function isMillisecond(value: unknown): value is number {