@nodetool-ai/agents 0.7.0-rc.23 → 0.8.2

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 (1645) hide show
  1. package/README.md +35 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/analysis/audio-dsp.d.ts +224 -0
  4. package/dist/analysis/audio-dsp.d.ts.map +1 -0
  5. package/dist/analysis/audio-dsp.js +645 -0
  6. package/dist/analysis/audio-dsp.js.map +1 -0
  7. package/dist/analysis/media-decode.d.ts +98 -0
  8. package/dist/analysis/media-decode.d.ts.map +1 -0
  9. package/dist/analysis/media-decode.js +226 -0
  10. package/dist/analysis/media-decode.js.map +1 -0
  11. package/dist/analysis/mediabunny-runtime.d.ts +15 -0
  12. package/dist/analysis/mediabunny-runtime.d.ts.map +1 -0
  13. package/dist/analysis/mediabunny-runtime.js +30 -0
  14. package/dist/analysis/mediabunny-runtime.js.map +1 -0
  15. package/dist/analysis/video-frames.d.ts +120 -0
  16. package/dist/analysis/video-frames.d.ts.map +1 -0
  17. package/dist/analysis/video-frames.js +288 -0
  18. package/dist/analysis/video-frames.js.map +1 -0
  19. package/dist/apify/assets.d.ts +80 -0
  20. package/dist/apify/assets.d.ts.map +1 -0
  21. package/dist/apify/assets.js +192 -0
  22. package/dist/apify/assets.js.map +1 -0
  23. package/dist/apify/catalog.d.ts +44 -0
  24. package/dist/apify/catalog.d.ts.map +1 -0
  25. package/dist/apify/catalog.js +108 -0
  26. package/dist/apify/catalog.js.map +1 -0
  27. package/dist/apify/client.d.ts +137 -0
  28. package/dist/apify/client.d.ts.map +1 -0
  29. package/dist/apify/client.js +346 -0
  30. package/dist/apify/client.js.map +1 -0
  31. package/dist/apify/errors.d.ts +85 -0
  32. package/dist/apify/errors.d.ts.map +1 -0
  33. package/dist/apify/errors.js +90 -0
  34. package/dist/apify/errors.js.map +1 -0
  35. package/dist/apify/normalize.d.ts +131 -0
  36. package/dist/apify/normalize.d.ts.map +1 -0
  37. package/dist/apify/normalize.js +202 -0
  38. package/dist/apify/normalize.js.map +1 -0
  39. package/dist/apify/policy.d.ts +136 -0
  40. package/dist/apify/policy.d.ts.map +1 -0
  41. package/dist/apify/policy.js +223 -0
  42. package/dist/apify/policy.js.map +1 -0
  43. package/dist/apify/run.d.ts +86 -0
  44. package/dist/apify/run.d.ts.map +1 -0
  45. package/dist/apify/run.js +158 -0
  46. package/dist/apify/run.js.map +1 -0
  47. package/dist/app-build/author.d.ts +67 -0
  48. package/dist/app-build/author.d.ts.map +1 -0
  49. package/dist/app-build/author.js +231 -0
  50. package/dist/app-build/author.js.map +1 -0
  51. package/dist/app-build/bridge.d.ts +130 -0
  52. package/dist/app-build/bridge.d.ts.map +1 -0
  53. package/dist/app-build/bridge.js +647 -0
  54. package/dist/app-build/bridge.js.map +1 -0
  55. package/dist/app-build/build-service.d.ts +66 -0
  56. package/dist/app-build/build-service.d.ts.map +1 -0
  57. package/dist/app-build/build-service.js +249 -0
  58. package/dist/app-build/build-service.js.map +1 -0
  59. package/dist/app-build/build.d.ts +115 -0
  60. package/dist/app-build/build.d.ts.map +1 -0
  61. package/dist/app-build/build.js +901 -0
  62. package/dist/app-build/build.js.map +1 -0
  63. package/dist/app-build/interactions.d.ts +20 -0
  64. package/dist/app-build/interactions.d.ts.map +1 -0
  65. package/dist/app-build/interactions.js +121 -0
  66. package/dist/app-build/interactions.js.map +1 -0
  67. package/dist/app-build/judge.d.ts +113 -0
  68. package/dist/app-build/judge.d.ts.map +1 -0
  69. package/dist/app-build/judge.js +318 -0
  70. package/dist/app-build/judge.js.map +1 -0
  71. package/dist/app-build/markdown.d.ts +10 -0
  72. package/dist/app-build/markdown.d.ts.map +1 -0
  73. package/dist/app-build/markdown.js +65 -0
  74. package/dist/app-build/markdown.js.map +1 -0
  75. package/dist/app-build/spec.d.ts +228 -0
  76. package/dist/app-build/spec.d.ts.map +1 -0
  77. package/dist/app-build/spec.js +651 -0
  78. package/dist/app-build/spec.js.map +1 -0
  79. package/dist/app-build/tool-loop.d.ts +84 -0
  80. package/dist/app-build/tool-loop.d.ts.map +1 -0
  81. package/dist/app-build/tool-loop.js +113 -0
  82. package/dist/app-build/tool-loop.js.map +1 -0
  83. package/dist/app-build/types.d.ts +215 -0
  84. package/dist/app-build/types.d.ts.map +1 -0
  85. package/dist/app-build/types.js +28 -0
  86. package/dist/app-build/types.js.map +1 -0
  87. package/dist/author-graph.d.ts +90 -0
  88. package/dist/author-graph.d.ts.map +1 -0
  89. package/dist/author-graph.js +317 -0
  90. package/dist/author-graph.js.map +1 -0
  91. package/dist/background-subtasks.d.ts +79 -0
  92. package/dist/background-subtasks.d.ts.map +1 -0
  93. package/dist/background-subtasks.js +139 -0
  94. package/dist/background-subtasks.js.map +1 -0
  95. package/dist/blender-gate.d.ts +21 -0
  96. package/dist/blender-gate.d.ts.map +1 -0
  97. package/dist/blender-gate.js +27 -0
  98. package/dist/blender-gate.js.map +1 -0
  99. package/dist/browser-gate.d.ts +28 -0
  100. package/dist/browser-gate.d.ts.map +1 -0
  101. package/dist/browser-gate.js +34 -0
  102. package/dist/browser-gate.js.map +1 -0
  103. package/dist/capabilities/GamePublishRequest.d.ts +14 -0
  104. package/dist/capabilities/GamePublishRequest.d.ts.map +1 -0
  105. package/dist/capabilities/GamePublishRequest.js +2 -0
  106. package/dist/capabilities/GamePublishRequest.js.map +1 -0
  107. package/dist/capabilities/adapters.d.ts +27 -0
  108. package/dist/capabilities/adapters.d.ts.map +1 -0
  109. package/dist/capabilities/adapters.js +39 -0
  110. package/dist/capabilities/adapters.js.map +1 -0
  111. package/dist/capabilities/agent-activity.d.ts +27 -0
  112. package/dist/capabilities/agent-activity.d.ts.map +1 -0
  113. package/dist/capabilities/agent-activity.js +103 -0
  114. package/dist/capabilities/agent-activity.js.map +1 -0
  115. package/dist/capabilities/agentic-storyboard-finish.d.ts +67 -0
  116. package/dist/capabilities/agentic-storyboard-finish.d.ts.map +1 -0
  117. package/dist/capabilities/agentic-storyboard-finish.js +1321 -0
  118. package/dist/capabilities/agentic-storyboard-finish.js.map +1 -0
  119. package/dist/capabilities/agents.d.ts +81 -0
  120. package/dist/capabilities/agents.d.ts.map +1 -0
  121. package/dist/capabilities/agents.js +376 -0
  122. package/dist/capabilities/agents.js.map +1 -0
  123. package/dist/capabilities/agents.specs.d.ts +30 -0
  124. package/dist/capabilities/agents.specs.d.ts.map +1 -0
  125. package/dist/capabilities/agents.specs.js +313 -0
  126. package/dist/capabilities/agents.specs.js.map +1 -0
  127. package/dist/capabilities/analysis.d.ts +93 -0
  128. package/dist/capabilities/analysis.d.ts.map +1 -0
  129. package/dist/capabilities/analysis.js +823 -0
  130. package/dist/capabilities/analysis.js.map +1 -0
  131. package/dist/capabilities/analysis.specs.d.ts +39 -0
  132. package/dist/capabilities/analysis.specs.d.ts.map +1 -0
  133. package/dist/capabilities/analysis.specs.js +217 -0
  134. package/dist/capabilities/analysis.specs.js.map +1 -0
  135. package/dist/capabilities/apify.d.ts +34 -0
  136. package/dist/capabilities/apify.d.ts.map +1 -0
  137. package/dist/capabilities/apify.js +449 -0
  138. package/dist/capabilities/apify.js.map +1 -0
  139. package/dist/capabilities/apify.specs.d.ts +28 -0
  140. package/dist/capabilities/apify.specs.d.ts.map +1 -0
  141. package/dist/capabilities/apify.specs.js +232 -0
  142. package/dist/capabilities/apify.specs.js.map +1 -0
  143. package/dist/capabilities/apps.d.ts +40 -0
  144. package/dist/capabilities/apps.d.ts.map +1 -0
  145. package/dist/capabilities/apps.js +415 -0
  146. package/dist/capabilities/apps.js.map +1 -0
  147. package/dist/capabilities/apps.specs.d.ts +23 -0
  148. package/dist/capabilities/apps.specs.d.ts.map +1 -0
  149. package/dist/capabilities/apps.specs.js +236 -0
  150. package/dist/capabilities/apps.specs.js.map +1 -0
  151. package/dist/capabilities/args.d.ts +62 -0
  152. package/dist/capabilities/args.d.ts.map +1 -0
  153. package/dist/capabilities/args.js +215 -0
  154. package/dist/capabilities/args.js.map +1 -0
  155. package/dist/capabilities/assets.d.ts +45 -0
  156. package/dist/capabilities/assets.d.ts.map +1 -0
  157. package/dist/capabilities/assets.js +952 -0
  158. package/dist/capabilities/assets.js.map +1 -0
  159. package/dist/capabilities/assets.specs.d.ts +54 -0
  160. package/dist/capabilities/assets.specs.d.ts.map +1 -0
  161. package/dist/capabilities/assets.specs.js +291 -0
  162. package/dist/capabilities/assets.specs.js.map +1 -0
  163. package/dist/capabilities/background-generation.d.ts +14 -0
  164. package/dist/capabilities/background-generation.d.ts.map +1 -0
  165. package/dist/capabilities/background-generation.js +29 -0
  166. package/dist/capabilities/background-generation.js.map +1 -0
  167. package/dist/capabilities/browser.d.ts +30 -0
  168. package/dist/capabilities/browser.d.ts.map +1 -0
  169. package/dist/capabilities/browser.js +250 -0
  170. package/dist/capabilities/browser.js.map +1 -0
  171. package/dist/capabilities/browser.specs.d.ts +37 -0
  172. package/dist/capabilities/browser.specs.d.ts.map +1 -0
  173. package/dist/capabilities/browser.specs.js +173 -0
  174. package/dist/capabilities/browser.specs.js.map +1 -0
  175. package/dist/capabilities/code-grading.d.ts +68 -0
  176. package/dist/capabilities/code-grading.d.ts.map +1 -0
  177. package/dist/capabilities/code-grading.js +75 -0
  178. package/dist/capabilities/code-grading.js.map +1 -0
  179. package/dist/capabilities/code.d.ts +61 -0
  180. package/dist/capabilities/code.d.ts.map +1 -0
  181. package/dist/capabilities/code.js +366 -0
  182. package/dist/capabilities/code.js.map +1 -0
  183. package/dist/capabilities/code.specs.d.ts +22 -0
  184. package/dist/capabilities/code.specs.d.ts.map +1 -0
  185. package/dist/capabilities/code.specs.js +175 -0
  186. package/dist/capabilities/code.specs.js.map +1 -0
  187. package/dist/capabilities/collections.d.ts +44 -0
  188. package/dist/capabilities/collections.d.ts.map +1 -0
  189. package/dist/capabilities/collections.js +432 -0
  190. package/dist/capabilities/collections.js.map +1 -0
  191. package/dist/capabilities/collections.specs.d.ts +25 -0
  192. package/dist/capabilities/collections.specs.d.ts.map +1 -0
  193. package/dist/capabilities/collections.specs.js +299 -0
  194. package/dist/capabilities/collections.specs.js.map +1 -0
  195. package/dist/capabilities/compositions.d.ts +57 -0
  196. package/dist/capabilities/compositions.d.ts.map +1 -0
  197. package/dist/capabilities/compositions.js +384 -0
  198. package/dist/capabilities/compositions.js.map +1 -0
  199. package/dist/capabilities/compositions.specs.d.ts +22 -0
  200. package/dist/capabilities/compositions.specs.d.ts.map +1 -0
  201. package/dist/capabilities/compositions.specs.js +126 -0
  202. package/dist/capabilities/compositions.specs.js.map +1 -0
  203. package/dist/capabilities/concurrency.d.ts +12 -0
  204. package/dist/capabilities/concurrency.d.ts.map +1 -0
  205. package/dist/capabilities/concurrency.js +30 -0
  206. package/dist/capabilities/concurrency.js.map +1 -0
  207. package/dist/capabilities/costs.d.ts +20 -0
  208. package/dist/capabilities/costs.d.ts.map +1 -0
  209. package/dist/capabilities/costs.js +40 -0
  210. package/dist/capabilities/costs.js.map +1 -0
  211. package/dist/capabilities/costs.specs.d.ts +12 -0
  212. package/dist/capabilities/costs.specs.d.ts.map +1 -0
  213. package/dist/capabilities/costs.specs.js +35 -0
  214. package/dist/capabilities/costs.specs.js.map +1 -0
  215. package/dist/capabilities/dispatcher.d.ts +57 -0
  216. package/dist/capabilities/dispatcher.d.ts.map +1 -0
  217. package/dist/capabilities/dispatcher.js +117 -0
  218. package/dist/capabilities/dispatcher.js.map +1 -0
  219. package/dist/capabilities/documents.d.ts +25 -0
  220. package/dist/capabilities/documents.d.ts.map +1 -0
  221. package/dist/capabilities/documents.js +278 -0
  222. package/dist/capabilities/documents.js.map +1 -0
  223. package/dist/capabilities/documents.specs.d.ts +18 -0
  224. package/dist/capabilities/documents.specs.d.ts.map +1 -0
  225. package/dist/capabilities/documents.specs.js +201 -0
  226. package/dist/capabilities/documents.specs.js.map +1 -0
  227. package/dist/capabilities/email.d.ts +23 -0
  228. package/dist/capabilities/email.d.ts.map +1 -0
  229. package/dist/capabilities/email.js +226 -0
  230. package/dist/capabilities/email.js.map +1 -0
  231. package/dist/capabilities/email.specs.d.ts +16 -0
  232. package/dist/capabilities/email.specs.d.ts.map +1 -0
  233. package/dist/capabilities/email.specs.js +102 -0
  234. package/dist/capabilities/email.specs.js.map +1 -0
  235. package/dist/capabilities/entities.d.ts +52 -0
  236. package/dist/capabilities/entities.d.ts.map +1 -0
  237. package/dist/capabilities/entities.js +478 -0
  238. package/dist/capabilities/entities.js.map +1 -0
  239. package/dist/capabilities/entities.specs.d.ts +25 -0
  240. package/dist/capabilities/entities.specs.d.ts.map +1 -0
  241. package/dist/capabilities/entities.specs.js +247 -0
  242. package/dist/capabilities/entities.specs.js.map +1 -0
  243. package/dist/capabilities/errors.d.ts +19 -0
  244. package/dist/capabilities/errors.d.ts.map +1 -0
  245. package/dist/capabilities/errors.js +109 -0
  246. package/dist/capabilities/errors.js.map +1 -0
  247. package/dist/capabilities/errors.specs.d.ts +11 -0
  248. package/dist/capabilities/errors.specs.d.ts.map +1 -0
  249. package/dist/capabilities/errors.specs.js +100 -0
  250. package/dist/capabilities/errors.specs.js.map +1 -0
  251. package/dist/capabilities/example-timelines.d.ts +3 -0
  252. package/dist/capabilities/example-timelines.d.ts.map +1 -0
  253. package/dist/capabilities/example-timelines.js +233 -0
  254. package/dist/capabilities/example-timelines.js.map +1 -0
  255. package/dist/capabilities/example-timelines.specs.d.ts +6 -0
  256. package/dist/capabilities/example-timelines.specs.d.ts.map +1 -0
  257. package/dist/capabilities/example-timelines.specs.js +71 -0
  258. package/dist/capabilities/example-timelines.specs.js.map +1 -0
  259. package/dist/capabilities/files.d.ts +53 -0
  260. package/dist/capabilities/files.d.ts.map +1 -0
  261. package/dist/capabilities/files.js +1172 -0
  262. package/dist/capabilities/files.js.map +1 -0
  263. package/dist/capabilities/files.specs.d.ts +28 -0
  264. package/dist/capabilities/files.specs.d.ts.map +1 -0
  265. package/dist/capabilities/files.specs.js +259 -0
  266. package/dist/capabilities/files.specs.js.map +1 -0
  267. package/dist/capabilities/finish-storyboard.d.ts +5 -0
  268. package/dist/capabilities/finish-storyboard.d.ts.map +1 -0
  269. package/dist/capabilities/finish-storyboard.js +278 -0
  270. package/dist/capabilities/finish-storyboard.js.map +1 -0
  271. package/dist/capabilities/flow.d.ts +93 -0
  272. package/dist/capabilities/flow.d.ts.map +1 -0
  273. package/dist/capabilities/flow.js +285 -0
  274. package/dist/capabilities/flow.js.map +1 -0
  275. package/dist/capabilities/flow.specs.d.ts +25 -0
  276. package/dist/capabilities/flow.specs.d.ts.map +1 -0
  277. package/dist/capabilities/flow.specs.js +114 -0
  278. package/dist/capabilities/flow.specs.js.map +1 -0
  279. package/dist/capabilities/game-asset-source.d.ts +31 -0
  280. package/dist/capabilities/game-asset-source.d.ts.map +1 -0
  281. package/dist/capabilities/game-asset-source.js +81 -0
  282. package/dist/capabilities/game-asset-source.js.map +1 -0
  283. package/dist/capabilities/game.d.ts +24 -0
  284. package/dist/capabilities/game.d.ts.map +1 -0
  285. package/dist/capabilities/game.js +1432 -0
  286. package/dist/capabilities/game.js.map +1 -0
  287. package/dist/capabilities/game.specs.d.ts +5 -0
  288. package/dist/capabilities/game.specs.d.ts.map +1 -0
  289. package/dist/capabilities/game.specs.js +110 -0
  290. package/dist/capabilities/game.specs.js.map +1 -0
  291. package/dist/capabilities/game3d.d.ts +17 -0
  292. package/dist/capabilities/game3d.d.ts.map +1 -0
  293. package/dist/capabilities/game3d.js +433 -0
  294. package/dist/capabilities/game3d.js.map +1 -0
  295. package/dist/capabilities/gate-from-context.d.ts +39 -0
  296. package/dist/capabilities/gate-from-context.d.ts.map +1 -0
  297. package/dist/capabilities/gate-from-context.js +97 -0
  298. package/dist/capabilities/gate-from-context.js.map +1 -0
  299. package/dist/capabilities/generations.d.ts +81 -0
  300. package/dist/capabilities/generations.d.ts.map +1 -0
  301. package/dist/capabilities/generations.js +387 -0
  302. package/dist/capabilities/generations.js.map +1 -0
  303. package/dist/capabilities/generations.specs.d.ts +62 -0
  304. package/dist/capabilities/generations.specs.d.ts.map +1 -0
  305. package/dist/capabilities/generations.specs.js +230 -0
  306. package/dist/capabilities/generations.specs.js.map +1 -0
  307. package/dist/capabilities/google.d.ts +50 -0
  308. package/dist/capabilities/google.d.ts.map +1 -0
  309. package/dist/capabilities/google.js +246 -0
  310. package/dist/capabilities/google.js.map +1 -0
  311. package/dist/capabilities/google.specs.d.ts +52 -0
  312. package/dist/capabilities/google.specs.d.ts.map +1 -0
  313. package/dist/capabilities/google.specs.js +391 -0
  314. package/dist/capabilities/google.specs.js.map +1 -0
  315. package/dist/capabilities/html-text.d.ts +28 -0
  316. package/dist/capabilities/html-text.d.ts.map +1 -0
  317. package/dist/capabilities/html-text.js +76 -0
  318. package/dist/capabilities/html-text.js.map +1 -0
  319. package/dist/capabilities/index.d.ts +19 -0
  320. package/dist/capabilities/index.d.ts.map +1 -0
  321. package/dist/capabilities/index.js +14 -0
  322. package/dist/capabilities/index.js.map +1 -0
  323. package/dist/capabilities/invoke.d.ts +78 -0
  324. package/dist/capabilities/invoke.d.ts.map +1 -0
  325. package/dist/capabilities/invoke.js +251 -0
  326. package/dist/capabilities/invoke.js.map +1 -0
  327. package/dist/capabilities/jobs.d.ts +32 -0
  328. package/dist/capabilities/jobs.d.ts.map +1 -0
  329. package/dist/capabilities/jobs.js +167 -0
  330. package/dist/capabilities/jobs.js.map +1 -0
  331. package/dist/capabilities/jobs.specs.d.ts +20 -0
  332. package/dist/capabilities/jobs.specs.d.ts.map +1 -0
  333. package/dist/capabilities/jobs.specs.js +105 -0
  334. package/dist/capabilities/jobs.specs.js.map +1 -0
  335. package/dist/capabilities/js-scripts.d.ts +108 -0
  336. package/dist/capabilities/js-scripts.d.ts.map +1 -0
  337. package/dist/capabilities/js-scripts.js +807 -0
  338. package/dist/capabilities/js-scripts.js.map +1 -0
  339. package/dist/capabilities/js-scripts.specs.d.ts +52 -0
  340. package/dist/capabilities/js-scripts.specs.d.ts.map +1 -0
  341. package/dist/capabilities/js-scripts.specs.js +394 -0
  342. package/dist/capabilities/js-scripts.specs.js.map +1 -0
  343. package/dist/capabilities/lazy-tool.d.ts +41 -0
  344. package/dist/capabilities/lazy-tool.d.ts.map +1 -0
  345. package/dist/capabilities/lazy-tool.js +82 -0
  346. package/dist/capabilities/lazy-tool.js.map +1 -0
  347. package/dist/capabilities/legacy-tools.d.ts +15 -0
  348. package/dist/capabilities/legacy-tools.d.ts.map +1 -0
  349. package/dist/capabilities/legacy-tools.js +98 -0
  350. package/dist/capabilities/legacy-tools.js.map +1 -0
  351. package/dist/capabilities/local-browser.d.ts +24 -0
  352. package/dist/capabilities/local-browser.d.ts.map +1 -0
  353. package/dist/capabilities/local-browser.js +105 -0
  354. package/dist/capabilities/local-browser.js.map +1 -0
  355. package/dist/capabilities/media.d.ts +112 -0
  356. package/dist/capabilities/media.d.ts.map +1 -0
  357. package/dist/capabilities/media.js +2258 -0
  358. package/dist/capabilities/media.js.map +1 -0
  359. package/dist/capabilities/media.specs.d.ts +65 -0
  360. package/dist/capabilities/media.specs.d.ts.map +1 -0
  361. package/dist/capabilities/media.specs.js +779 -0
  362. package/dist/capabilities/media.specs.js.map +1 -0
  363. package/dist/capabilities/memory.d.ts +31 -0
  364. package/dist/capabilities/memory.d.ts.map +1 -0
  365. package/dist/capabilities/memory.js +403 -0
  366. package/dist/capabilities/memory.js.map +1 -0
  367. package/dist/capabilities/memory.specs.d.ts +55 -0
  368. package/dist/capabilities/memory.specs.d.ts.map +1 -0
  369. package/dist/capabilities/memory.specs.js +208 -0
  370. package/dist/capabilities/memory.specs.js.map +1 -0
  371. package/dist/capabilities/model3d.d.ts +29 -0
  372. package/dist/capabilities/model3d.d.ts.map +1 -0
  373. package/dist/capabilities/model3d.js +482 -0
  374. package/dist/capabilities/model3d.js.map +1 -0
  375. package/dist/capabilities/model3d.specs.d.ts +28 -0
  376. package/dist/capabilities/model3d.specs.d.ts.map +1 -0
  377. package/dist/capabilities/model3d.specs.js +305 -0
  378. package/dist/capabilities/model3d.specs.js.map +1 -0
  379. package/dist/capabilities/models.d.ts +138 -0
  380. package/dist/capabilities/models.d.ts.map +1 -0
  381. package/dist/capabilities/models.js +805 -0
  382. package/dist/capabilities/models.js.map +1 -0
  383. package/dist/capabilities/models.specs.d.ts +21 -0
  384. package/dist/capabilities/models.specs.d.ts.map +1 -0
  385. package/dist/capabilities/models.specs.js +141 -0
  386. package/dist/capabilities/models.specs.js.map +1 -0
  387. package/dist/capabilities/nodes.d.ts +26 -0
  388. package/dist/capabilities/nodes.d.ts.map +1 -0
  389. package/dist/capabilities/nodes.js +266 -0
  390. package/dist/capabilities/nodes.js.map +1 -0
  391. package/dist/capabilities/nodes.specs.d.ts +20 -0
  392. package/dist/capabilities/nodes.specs.d.ts.map +1 -0
  393. package/dist/capabilities/nodes.specs.js +106 -0
  394. package/dist/capabilities/nodes.specs.js.map +1 -0
  395. package/dist/capabilities/packs.d.ts +69 -0
  396. package/dist/capabilities/packs.d.ts.map +1 -0
  397. package/dist/capabilities/packs.js +246 -0
  398. package/dist/capabilities/packs.js.map +1 -0
  399. package/dist/capabilities/packs.specs.d.ts +27 -0
  400. package/dist/capabilities/packs.specs.d.ts.map +1 -0
  401. package/dist/capabilities/packs.specs.js +64 -0
  402. package/dist/capabilities/packs.specs.js.map +1 -0
  403. package/dist/capabilities/project-scope.d.ts +12 -0
  404. package/dist/capabilities/project-scope.d.ts.map +1 -0
  405. package/dist/capabilities/project-scope.js +19 -0
  406. package/dist/capabilities/project-scope.js.map +1 -0
  407. package/dist/capabilities/projects.d.ts +23 -0
  408. package/dist/capabilities/projects.d.ts.map +1 -0
  409. package/dist/capabilities/projects.js +206 -0
  410. package/dist/capabilities/projects.js.map +1 -0
  411. package/dist/capabilities/projects.specs.d.ts +23 -0
  412. package/dist/capabilities/projects.specs.d.ts.map +1 -0
  413. package/dist/capabilities/projects.specs.js +118 -0
  414. package/dist/capabilities/projects.specs.js.map +1 -0
  415. package/dist/capabilities/registry.d.ts +111 -0
  416. package/dist/capabilities/registry.d.ts.map +1 -0
  417. package/dist/capabilities/registry.js +473 -0
  418. package/dist/capabilities/registry.js.map +1 -0
  419. package/dist/capabilities/run-agent.d.ts +19 -0
  420. package/dist/capabilities/run-agent.d.ts.map +1 -0
  421. package/dist/capabilities/run-agent.js +183 -0
  422. package/dist/capabilities/run-agent.js.map +1 -0
  423. package/dist/capabilities/runs.d.ts +9 -0
  424. package/dist/capabilities/runs.d.ts.map +1 -0
  425. package/dist/capabilities/runs.js +46 -0
  426. package/dist/capabilities/runs.js.map +1 -0
  427. package/dist/capabilities/runs.specs.d.ts +39 -0
  428. package/dist/capabilities/runs.specs.d.ts.map +1 -0
  429. package/dist/capabilities/runs.specs.js +52 -0
  430. package/dist/capabilities/runs.specs.js.map +1 -0
  431. package/dist/capabilities/script-link.d.ts +22 -0
  432. package/dist/capabilities/script-link.d.ts.map +1 -0
  433. package/dist/capabilities/script-link.js +35 -0
  434. package/dist/capabilities/script-link.js.map +1 -0
  435. package/dist/capabilities/scripts.d.ts +43 -0
  436. package/dist/capabilities/scripts.d.ts.map +1 -0
  437. package/dist/capabilities/scripts.js +1795 -0
  438. package/dist/capabilities/scripts.js.map +1 -0
  439. package/dist/capabilities/scripts.specs.d.ts +40 -0
  440. package/dist/capabilities/scripts.specs.d.ts.map +1 -0
  441. package/dist/capabilities/scripts.specs.js +319 -0
  442. package/dist/capabilities/scripts.specs.js.map +1 -0
  443. package/dist/capabilities/serpapi.d.ts +42 -0
  444. package/dist/capabilities/serpapi.d.ts.map +1 -0
  445. package/dist/capabilities/serpapi.js +262 -0
  446. package/dist/capabilities/serpapi.js.map +1 -0
  447. package/dist/capabilities/serpapi.specs.d.ts +24 -0
  448. package/dist/capabilities/serpapi.specs.d.ts.map +1 -0
  449. package/dist/capabilities/serpapi.specs.js +174 -0
  450. package/dist/capabilities/serpapi.specs.js.map +1 -0
  451. package/dist/capabilities/settings.d.ts +48 -0
  452. package/dist/capabilities/settings.d.ts.map +1 -0
  453. package/dist/capabilities/settings.js +226 -0
  454. package/dist/capabilities/settings.js.map +1 -0
  455. package/dist/capabilities/settings.specs.d.ts +42 -0
  456. package/dist/capabilities/settings.specs.d.ts.map +1 -0
  457. package/dist/capabilities/settings.specs.js +126 -0
  458. package/dist/capabilities/settings.specs.js.map +1 -0
  459. package/dist/capabilities/shared.d.ts +35 -0
  460. package/dist/capabilities/shared.d.ts.map +1 -0
  461. package/dist/capabilities/shared.js +165 -0
  462. package/dist/capabilities/shared.js.map +1 -0
  463. package/dist/capabilities/shared.specs.d.ts +19 -0
  464. package/dist/capabilities/shared.specs.d.ts.map +1 -0
  465. package/dist/capabilities/shared.specs.js +134 -0
  466. package/dist/capabilities/shared.specs.js.map +1 -0
  467. package/dist/capabilities/sketches.d.ts +52 -0
  468. package/dist/capabilities/sketches.d.ts.map +1 -0
  469. package/dist/capabilities/sketches.js +1165 -0
  470. package/dist/capabilities/sketches.js.map +1 -0
  471. package/dist/capabilities/sketches.specs.d.ts +44 -0
  472. package/dist/capabilities/sketches.specs.d.ts.map +1 -0
  473. package/dist/capabilities/sketches.specs.js +392 -0
  474. package/dist/capabilities/sketches.specs.js.map +1 -0
  475. package/dist/capabilities/skills.d.ts +28 -0
  476. package/dist/capabilities/skills.d.ts.map +1 -0
  477. package/dist/capabilities/skills.js +289 -0
  478. package/dist/capabilities/skills.js.map +1 -0
  479. package/dist/capabilities/skills.specs.d.ts +17 -0
  480. package/dist/capabilities/skills.specs.d.ts.map +1 -0
  481. package/dist/capabilities/skills.specs.js +108 -0
  482. package/dist/capabilities/skills.specs.js.map +1 -0
  483. package/dist/capabilities/storyboard-layout-check.d.ts +33 -0
  484. package/dist/capabilities/storyboard-layout-check.d.ts.map +1 -0
  485. package/dist/capabilities/storyboard-layout-check.js +229 -0
  486. package/dist/capabilities/storyboard-layout-check.js.map +1 -0
  487. package/dist/capabilities/storyboard-measured-sources.d.ts +10 -0
  488. package/dist/capabilities/storyboard-measured-sources.d.ts.map +1 -0
  489. package/dist/capabilities/storyboard-measured-sources.js +67 -0
  490. package/dist/capabilities/storyboard-measured-sources.js.map +1 -0
  491. package/dist/capabilities/storyboard-review-times.d.ts +4 -0
  492. package/dist/capabilities/storyboard-review-times.d.ts.map +1 -0
  493. package/dist/capabilities/storyboard-review-times.js +39 -0
  494. package/dist/capabilities/storyboard-review-times.js.map +1 -0
  495. package/dist/capabilities/storyboards.d.ts +52 -0
  496. package/dist/capabilities/storyboards.d.ts.map +1 -0
  497. package/dist/capabilities/storyboards.js +2467 -0
  498. package/dist/capabilities/storyboards.js.map +1 -0
  499. package/dist/capabilities/storyboards.specs.d.ts +45 -0
  500. package/dist/capabilities/storyboards.specs.d.ts.map +1 -0
  501. package/dist/capabilities/storyboards.specs.js +457 -0
  502. package/dist/capabilities/storyboards.specs.js.map +1 -0
  503. package/dist/capabilities/threads.d.ts +25 -0
  504. package/dist/capabilities/threads.d.ts.map +1 -0
  505. package/dist/capabilities/threads.js +240 -0
  506. package/dist/capabilities/threads.js.map +1 -0
  507. package/dist/capabilities/threads.specs.d.ts +26 -0
  508. package/dist/capabilities/threads.specs.d.ts.map +1 -0
  509. package/dist/capabilities/threads.specs.js +108 -0
  510. package/dist/capabilities/threads.specs.js.map +1 -0
  511. package/dist/capabilities/timeline-audio-bake.d.ts +114 -0
  512. package/dist/capabilities/timeline-audio-bake.d.ts.map +1 -0
  513. package/dist/capabilities/timeline-audio-bake.js +188 -0
  514. package/dist/capabilities/timeline-audio-bake.js.map +1 -0
  515. package/dist/capabilities/timeline-bake.d.ts +21 -0
  516. package/dist/capabilities/timeline-bake.d.ts.map +1 -0
  517. package/dist/capabilities/timeline-bake.js +118 -0
  518. package/dist/capabilities/timeline-bake.js.map +1 -0
  519. package/dist/capabilities/timeline-bridge.d.ts +359 -0
  520. package/dist/capabilities/timeline-bridge.d.ts.map +1 -0
  521. package/dist/capabilities/timeline-bridge.js +1016 -0
  522. package/dist/capabilities/timeline-bridge.js.map +1 -0
  523. package/dist/capabilities/timeline-clip-frames.d.ts +17 -0
  524. package/dist/capabilities/timeline-clip-frames.d.ts.map +1 -0
  525. package/dist/capabilities/timeline-clip-frames.js +84 -0
  526. package/dist/capabilities/timeline-clip-frames.js.map +1 -0
  527. package/dist/capabilities/timeline-isolate-subject.d.ts +157 -0
  528. package/dist/capabilities/timeline-isolate-subject.d.ts.map +1 -0
  529. package/dist/capabilities/timeline-isolate-subject.js +293 -0
  530. package/dist/capabilities/timeline-isolate-subject.js.map +1 -0
  531. package/dist/capabilities/timeline-media-edit.d.ts +8 -0
  532. package/dist/capabilities/timeline-media-edit.d.ts.map +1 -0
  533. package/dist/capabilities/timeline-media-edit.js +94 -0
  534. package/dist/capabilities/timeline-media-edit.js.map +1 -0
  535. package/dist/capabilities/timeline-native-media.d.ts +4 -0
  536. package/dist/capabilities/timeline-native-media.d.ts.map +1 -0
  537. package/dist/capabilities/timeline-native-media.js +960 -0
  538. package/dist/capabilities/timeline-native-media.js.map +1 -0
  539. package/dist/capabilities/timeline-track-object.d.ts +83 -0
  540. package/dist/capabilities/timeline-track-object.d.ts.map +1 -0
  541. package/dist/capabilities/timeline-track-object.js +195 -0
  542. package/dist/capabilities/timeline-track-object.js.map +1 -0
  543. package/dist/capabilities/timelines.d.ts +250 -0
  544. package/dist/capabilities/timelines.d.ts.map +1 -0
  545. package/dist/capabilities/timelines.js +2825 -0
  546. package/dist/capabilities/timelines.js.map +1 -0
  547. package/dist/capabilities/timelines.specs.d.ts +142 -0
  548. package/dist/capabilities/timelines.specs.d.ts.map +1 -0
  549. package/dist/capabilities/timelines.specs.js +1527 -0
  550. package/dist/capabilities/timelines.specs.js.map +1 -0
  551. package/dist/capabilities/types.d.ts +199 -0
  552. package/dist/capabilities/types.d.ts.map +1 -0
  553. package/dist/capabilities/types.js +19 -0
  554. package/dist/capabilities/types.js.map +1 -0
  555. package/dist/capabilities/ui.d.ts +38 -0
  556. package/dist/capabilities/ui.d.ts.map +1 -0
  557. package/dist/capabilities/ui.js +150 -0
  558. package/dist/capabilities/ui.js.map +1 -0
  559. package/dist/capabilities/ui.specs.d.ts +22 -0
  560. package/dist/capabilities/ui.specs.d.ts.map +1 -0
  561. package/dist/capabilities/ui.specs.js +59 -0
  562. package/dist/capabilities/ui.specs.js.map +1 -0
  563. package/dist/capabilities/video-production-acceptance.d.ts +27 -0
  564. package/dist/capabilities/video-production-acceptance.d.ts.map +1 -0
  565. package/dist/capabilities/video-production-acceptance.js +41 -0
  566. package/dist/capabilities/video-production-acceptance.js.map +1 -0
  567. package/dist/capabilities/video-production.d.ts +179 -0
  568. package/dist/capabilities/video-production.d.ts.map +1 -0
  569. package/dist/capabilities/video-production.js +1492 -0
  570. package/dist/capabilities/video-production.js.map +1 -0
  571. package/dist/capabilities/video-production.specs.d.ts +13 -0
  572. package/dist/capabilities/video-production.specs.d.ts.map +1 -0
  573. package/dist/capabilities/video-production.specs.js +256 -0
  574. package/dist/capabilities/video-production.specs.js.map +1 -0
  575. package/dist/capabilities/web.d.ts +86 -0
  576. package/dist/capabilities/web.d.ts.map +1 -0
  577. package/dist/capabilities/web.js +850 -0
  578. package/dist/capabilities/web.js.map +1 -0
  579. package/dist/capabilities/web.specs.d.ts +33 -0
  580. package/dist/capabilities/web.specs.d.ts.map +1 -0
  581. package/dist/capabilities/web.specs.js +286 -0
  582. package/dist/capabilities/web.specs.js.map +1 -0
  583. package/dist/capabilities/workflows.d.ts +58 -0
  584. package/dist/capabilities/workflows.d.ts.map +1 -0
  585. package/dist/capabilities/workflows.js +1557 -0
  586. package/dist/capabilities/workflows.js.map +1 -0
  587. package/dist/capabilities/workflows.specs.d.ts +63 -0
  588. package/dist/capabilities/workflows.specs.d.ts.map +1 -0
  589. package/dist/capabilities/workflows.specs.js +858 -0
  590. package/dist/capabilities/workflows.specs.js.map +1 -0
  591. package/dist/code-gen/analyze.d.ts +26 -0
  592. package/dist/code-gen/analyze.d.ts.map +1 -0
  593. package/dist/code-gen/analyze.js +79 -0
  594. package/dist/code-gen/analyze.js.map +1 -0
  595. package/dist/code-gen/port-types.d.ts +58 -0
  596. package/dist/code-gen/port-types.d.ts.map +1 -0
  597. package/dist/code-gen/port-types.js +115 -0
  598. package/dist/code-gen/port-types.js.map +1 -0
  599. package/dist/code-gen/prompt.d.ts +37 -0
  600. package/dist/code-gen/prompt.d.ts.map +1 -0
  601. package/dist/code-gen/prompt.js +129 -0
  602. package/dist/code-gen/prompt.js.map +1 -0
  603. package/dist/code-gen/sandbox-manifest.d.ts +120 -0
  604. package/dist/code-gen/sandbox-manifest.d.ts.map +1 -0
  605. package/dist/code-gen/sandbox-manifest.js +1023 -0
  606. package/dist/code-gen/sandbox-manifest.js.map +1 -0
  607. package/dist/code-gen/sandbox-prompt.d.ts +26 -0
  608. package/dist/code-gen/sandbox-prompt.d.ts.map +1 -0
  609. package/dist/code-gen/sandbox-prompt.js +126 -0
  610. package/dist/code-gen/sandbox-prompt.js.map +1 -0
  611. package/dist/code-planner.d.ts +72 -0
  612. package/dist/code-planner.d.ts.map +1 -0
  613. package/dist/code-planner.js +271 -0
  614. package/dist/code-planner.js.map +1 -0
  615. package/dist/codeact/action-diagnostics.d.ts +35 -0
  616. package/dist/codeact/action-diagnostics.d.ts.map +1 -0
  617. package/dist/codeact/action-diagnostics.js +197 -0
  618. package/dist/codeact/action-diagnostics.js.map +1 -0
  619. package/dist/codeact/capability-modules.d.ts +66 -0
  620. package/dist/codeact/capability-modules.d.ts.map +1 -0
  621. package/dist/codeact/capability-modules.js +278 -0
  622. package/dist/codeact/capability-modules.js.map +1 -0
  623. package/dist/codeact/chat-codeact.d.ts +104 -0
  624. package/dist/codeact/chat-codeact.d.ts.map +1 -0
  625. package/dist/codeact/chat-codeact.js +424 -0
  626. package/dist/codeact/chat-codeact.js.map +1 -0
  627. package/dist/codeact/codeact-executor.d.ts +247 -0
  628. package/dist/codeact/codeact-executor.d.ts.map +1 -0
  629. package/dist/codeact/codeact-executor.js +1184 -0
  630. package/dist/codeact/codeact-executor.js.map +1 -0
  631. package/dist/codeact/compact-ids.d.ts +28 -0
  632. package/dist/codeact/compact-ids.d.ts.map +1 -0
  633. package/dist/codeact/compact-ids.js +81 -0
  634. package/dist/codeact/compact-ids.js.map +1 -0
  635. package/dist/codeact/execute-code-contract.d.ts +97 -0
  636. package/dist/codeact/execute-code-contract.d.ts.map +1 -0
  637. package/dist/codeact/execute-code-contract.js +225 -0
  638. package/dist/codeact/execute-code-contract.js.map +1 -0
  639. package/dist/codeact/fabric-package.d.ts +29 -0
  640. package/dist/codeact/fabric-package.d.ts.map +1 -0
  641. package/dist/codeact/fabric-package.js +62 -0
  642. package/dist/codeact/fabric-package.js.map +1 -0
  643. package/dist/codeact/flow-package.d.ts +31 -0
  644. package/dist/codeact/flow-package.d.ts.map +1 -0
  645. package/dist/codeact/flow-package.js +80 -0
  646. package/dist/codeact/flow-package.js.map +1 -0
  647. package/dist/codeact/graph-dsl-package.d.ts +42 -0
  648. package/dist/codeact/graph-dsl-package.d.ts.map +1 -0
  649. package/dist/codeact/graph-dsl-package.js +100 -0
  650. package/dist/codeact/graph-dsl-package.js.map +1 -0
  651. package/dist/codeact/graph-model.d.ts +30 -0
  652. package/dist/codeact/graph-model.d.ts.map +1 -0
  653. package/dist/codeact/graph-model.js +407 -0
  654. package/dist/codeact/graph-model.js.map +1 -0
  655. package/dist/codeact/mcp-guest-contract.d.ts +66 -0
  656. package/dist/codeact/mcp-guest-contract.d.ts.map +1 -0
  657. package/dist/codeact/mcp-guest-contract.js +108 -0
  658. package/dist/codeact/mcp-guest-contract.js.map +1 -0
  659. package/dist/codeact/nodetool-api.d.ts +60 -0
  660. package/dist/codeact/nodetool-api.d.ts.map +1 -0
  661. package/dist/codeact/nodetool-api.js +1974 -0
  662. package/dist/codeact/nodetool-api.js.map +1 -0
  663. package/dist/codeact/prompt.d.ts +88 -0
  664. package/dist/codeact/prompt.d.ts.map +1 -0
  665. package/dist/codeact/prompt.js +326 -0
  666. package/dist/codeact/prompt.js.map +1 -0
  667. package/dist/codeact/sandbox-package-docs.d.ts +48 -0
  668. package/dist/codeact/sandbox-package-docs.d.ts.map +1 -0
  669. package/dist/codeact/sandbox-package-docs.js +55 -0
  670. package/dist/codeact/sandbox-package-docs.js.map +1 -0
  671. package/dist/codeact/sandbox-package-listing.d.ts +81 -0
  672. package/dist/codeact/sandbox-package-listing.d.ts.map +1 -0
  673. package/dist/codeact/sandbox-package-listing.js +101 -0
  674. package/dist/codeact/sandbox-package-listing.js.map +1 -0
  675. package/dist/codeact/sandbox-packages.d.ts +72 -0
  676. package/dist/codeact/sandbox-packages.d.ts.map +1 -0
  677. package/dist/codeact/sandbox-packages.js +230 -0
  678. package/dist/codeact/sandbox-packages.js.map +1 -0
  679. package/dist/codeact/timeline-package.d.ts +5 -0
  680. package/dist/codeact/timeline-package.d.ts.map +1 -0
  681. package/dist/codeact/timeline-package.js +10 -0
  682. package/dist/codeact/timeline-package.js.map +1 -0
  683. package/dist/codeact/tool-api.d.ts +200 -0
  684. package/dist/codeact/tool-api.d.ts.map +1 -0
  685. package/dist/codeact/tool-api.js +452 -0
  686. package/dist/codeact/tool-api.js.map +1 -0
  687. package/dist/codeact/tools-prelude.d.ts +32 -0
  688. package/dist/codeact/tools-prelude.d.ts.map +1 -0
  689. package/dist/codeact/tools-prelude.js +65 -0
  690. package/dist/codeact/tools-prelude.js.map +1 -0
  691. package/dist/constants.d.ts +47 -2
  692. package/dist/constants.d.ts.map +1 -1
  693. package/dist/constants.js +64 -2
  694. package/dist/constants.js.map +1 -1
  695. package/dist/custom-animation-bake.d.ts +57 -0
  696. package/dist/custom-animation-bake.d.ts.map +1 -0
  697. package/dist/custom-animation-bake.js +88 -0
  698. package/dist/custom-animation-bake.js.map +1 -0
  699. package/dist/dynamic-slots.d.ts +72 -0
  700. package/dist/dynamic-slots.d.ts.map +1 -0
  701. package/dist/dynamic-slots.js +0 -0
  702. package/dist/dynamic-slots.js.map +1 -0
  703. package/dist/evals/app-build-cases.d.ts +35 -0
  704. package/dist/evals/app-build-cases.d.ts.map +1 -0
  705. package/dist/evals/app-build-cases.js +722 -0
  706. package/dist/evals/app-build-cases.js.map +1 -0
  707. package/dist/evals/app-build-eval.d.ts +208 -0
  708. package/dist/evals/app-build-eval.d.ts.map +1 -0
  709. package/dist/evals/app-build-eval.js +518 -0
  710. package/dist/evals/app-build-eval.js.map +1 -0
  711. package/dist/evals/app-build-plan.d.ts +76 -0
  712. package/dist/evals/app-build-plan.d.ts.map +1 -0
  713. package/dist/evals/app-build-plan.js +140 -0
  714. package/dist/evals/app-build-plan.js.map +1 -0
  715. package/dist/evals/code-gen-cases.d.ts +13 -0
  716. package/dist/evals/code-gen-cases.d.ts.map +1 -0
  717. package/dist/evals/code-gen-cases.js +124 -0
  718. package/dist/evals/code-gen-cases.js.map +1 -0
  719. package/dist/evals/code-gen-eval.d.ts +109 -0
  720. package/dist/evals/code-gen-eval.d.ts.map +1 -0
  721. package/dist/evals/code-gen-eval.js +299 -0
  722. package/dist/evals/code-gen-eval.js.map +1 -0
  723. package/dist/evals/codeact-api-cases.d.ts +14 -0
  724. package/dist/evals/codeact-api-cases.d.ts.map +1 -0
  725. package/dist/evals/codeact-api-cases.js +31 -0
  726. package/dist/evals/codeact-api-cases.js.map +1 -0
  727. package/dist/evals/codeact-api-core.d.ts +23 -0
  728. package/dist/evals/codeact-api-core.d.ts.map +1 -0
  729. package/dist/evals/codeact-api-core.js +1411 -0
  730. package/dist/evals/codeact-api-core.js.map +1 -0
  731. package/dist/evals/codeact-api-runs.d.ts +3 -0
  732. package/dist/evals/codeact-api-runs.d.ts.map +1 -0
  733. package/dist/evals/codeact-api-runs.js +33 -0
  734. package/dist/evals/codeact-api-runs.js.map +1 -0
  735. package/dist/evals/codeact-api-surfaces.d.ts +25 -0
  736. package/dist/evals/codeact-api-surfaces.d.ts.map +1 -0
  737. package/dist/evals/codeact-api-surfaces.js +2191 -0
  738. package/dist/evals/codeact-api-surfaces.js.map +1 -0
  739. package/dist/evals/codeact-cases.d.ts +76 -0
  740. package/dist/evals/codeact-cases.d.ts.map +1 -0
  741. package/dist/evals/codeact-cases.js +151 -0
  742. package/dist/evals/codeact-cases.js.map +1 -0
  743. package/dist/evals/codeact-eval.d.ts +66 -0
  744. package/dist/evals/codeact-eval.d.ts.map +1 -0
  745. package/dist/evals/codeact-eval.js +250 -0
  746. package/dist/evals/codeact-eval.js.map +1 -0
  747. package/dist/evals/codeact-sandbox-pack-cases.d.ts +31 -0
  748. package/dist/evals/codeact-sandbox-pack-cases.d.ts.map +1 -0
  749. package/dist/evals/codeact-sandbox-pack-cases.js +219 -0
  750. package/dist/evals/codeact-sandbox-pack-cases.js.map +1 -0
  751. package/dist/evals/escalation-cases.d.ts +22 -0
  752. package/dist/evals/escalation-cases.d.ts.map +1 -0
  753. package/dist/evals/escalation-cases.js +343 -0
  754. package/dist/evals/escalation-cases.js.map +1 -0
  755. package/dist/evals/escalation.d.ts +92 -0
  756. package/dist/evals/escalation.d.ts.map +1 -0
  757. package/dist/evals/escalation.js +152 -0
  758. package/dist/evals/escalation.js.map +1 -0
  759. package/dist/evals/goal-judge.d.ts +51 -0
  760. package/dist/evals/goal-judge.d.ts.map +1 -0
  761. package/dist/evals/goal-judge.js +152 -0
  762. package/dist/evals/goal-judge.js.map +1 -0
  763. package/dist/evals/graph-e2e-cases.d.ts +21 -0
  764. package/dist/evals/graph-e2e-cases.d.ts.map +1 -0
  765. package/dist/evals/graph-e2e-cases.js +262 -0
  766. package/dist/evals/graph-e2e-cases.js.map +1 -0
  767. package/dist/evals/graph-e2e-eval.d.ts +202 -0
  768. package/dist/evals/graph-e2e-eval.d.ts.map +1 -0
  769. package/dist/evals/graph-e2e-eval.js +438 -0
  770. package/dist/evals/graph-e2e-eval.js.map +1 -0
  771. package/dist/evals/graph-planner-cases.d.ts +12 -0
  772. package/dist/evals/graph-planner-cases.d.ts.map +1 -0
  773. package/dist/evals/graph-planner-cases.js +256 -0
  774. package/dist/evals/graph-planner-cases.js.map +1 -0
  775. package/dist/evals/graph-planner-eval.d.ts +178 -0
  776. package/dist/evals/graph-planner-eval.d.ts.map +1 -0
  777. package/dist/evals/graph-planner-eval.js +495 -0
  778. package/dist/evals/graph-planner-eval.js.map +1 -0
  779. package/dist/evals/planner-tools.d.ts +21 -0
  780. package/dist/evals/planner-tools.d.ts.map +1 -0
  781. package/dist/evals/planner-tools.js +66 -0
  782. package/dist/evals/planner-tools.js.map +1 -0
  783. package/dist/evals/subtask-cases.d.ts +88 -0
  784. package/dist/evals/subtask-cases.d.ts.map +1 -0
  785. package/dist/evals/subtask-cases.js +322 -0
  786. package/dist/evals/subtask-cases.js.map +1 -0
  787. package/dist/evals/subtask-eval.d.ts +129 -0
  788. package/dist/evals/subtask-eval.d.ts.map +1 -0
  789. package/dist/evals/subtask-eval.js +397 -0
  790. package/dist/evals/subtask-eval.js.map +1 -0
  791. package/dist/evals/surfaces/app.d.ts +19 -0
  792. package/dist/evals/surfaces/app.d.ts.map +1 -0
  793. package/dist/evals/surfaces/app.js +341 -0
  794. package/dist/evals/surfaces/app.js.map +1 -0
  795. package/dist/evals/surfaces/creative-pipeline.d.ts +203 -0
  796. package/dist/evals/surfaces/creative-pipeline.d.ts.map +1 -0
  797. package/dist/evals/surfaces/creative-pipeline.js +909 -0
  798. package/dist/evals/surfaces/creative-pipeline.js.map +1 -0
  799. package/dist/evals/surfaces/game.d.ts +5 -0
  800. package/dist/evals/surfaces/game.d.ts.map +1 -0
  801. package/dist/evals/surfaces/game.js +42 -0
  802. package/dist/evals/surfaces/game.js.map +1 -0
  803. package/dist/evals/surfaces/js-script.d.ts +66 -0
  804. package/dist/evals/surfaces/js-script.d.ts.map +1 -0
  805. package/dist/evals/surfaces/js-script.js +407 -0
  806. package/dist/evals/surfaces/js-script.js.map +1 -0
  807. package/dist/evals/surfaces/memory.d.ts +34 -0
  808. package/dist/evals/surfaces/memory.d.ts.map +1 -0
  809. package/dist/evals/surfaces/memory.js +264 -0
  810. package/dist/evals/surfaces/memory.js.map +1 -0
  811. package/dist/evals/surfaces/model3d.d.ts +45 -0
  812. package/dist/evals/surfaces/model3d.d.ts.map +1 -0
  813. package/dist/evals/surfaces/model3d.js +346 -0
  814. package/dist/evals/surfaces/model3d.js.map +1 -0
  815. package/dist/evals/surfaces/script.d.ts +96 -0
  816. package/dist/evals/surfaces/script.d.ts.map +1 -0
  817. package/dist/evals/surfaces/script.js +709 -0
  818. package/dist/evals/surfaces/script.js.map +1 -0
  819. package/dist/evals/surfaces/sketch.d.ts +126 -0
  820. package/dist/evals/surfaces/sketch.d.ts.map +1 -0
  821. package/dist/evals/surfaces/sketch.js +1306 -0
  822. package/dist/evals/surfaces/sketch.js.map +1 -0
  823. package/dist/evals/surfaces/storyboard.d.ts +97 -0
  824. package/dist/evals/surfaces/storyboard.d.ts.map +1 -0
  825. package/dist/evals/surfaces/storyboard.js +693 -0
  826. package/dist/evals/surfaces/storyboard.js.map +1 -0
  827. package/dist/evals/surfaces/timeline.d.ts +63 -0
  828. package/dist/evals/surfaces/timeline.d.ts.map +1 -0
  829. package/dist/evals/surfaces/timeline.js +655 -0
  830. package/dist/evals/surfaces/timeline.js.map +1 -0
  831. package/dist/evals/task-planner-cases.d.ts +57 -0
  832. package/dist/evals/task-planner-cases.d.ts.map +1 -0
  833. package/dist/evals/task-planner-cases.js +117 -0
  834. package/dist/evals/task-planner-cases.js.map +1 -0
  835. package/dist/evals/task-planner-eval.d.ts +101 -0
  836. package/dist/evals/task-planner-eval.d.ts.map +1 -0
  837. package/dist/evals/task-planner-eval.js +380 -0
  838. package/dist/evals/task-planner-eval.js.map +1 -0
  839. package/dist/evals/tool-loop-bridge.d.ts +61 -0
  840. package/dist/evals/tool-loop-bridge.d.ts.map +1 -0
  841. package/dist/evals/tool-loop-bridge.js +129 -0
  842. package/dist/evals/tool-loop-bridge.js.map +1 -0
  843. package/dist/evals/tool-loop-cases.d.ts +21 -0
  844. package/dist/evals/tool-loop-cases.d.ts.map +1 -0
  845. package/dist/evals/tool-loop-cases.js +401 -0
  846. package/dist/evals/tool-loop-cases.js.map +1 -0
  847. package/dist/evals/tool-loop-eval.d.ts +236 -0
  848. package/dist/evals/tool-loop-eval.d.ts.map +1 -0
  849. package/dist/evals/tool-loop-eval.js +378 -0
  850. package/dist/evals/tool-loop-eval.js.map +1 -0
  851. package/dist/evals/tool-loop-permission.d.ts +29 -0
  852. package/dist/evals/tool-loop-permission.d.ts.map +1 -0
  853. package/dist/evals/tool-loop-permission.js +58 -0
  854. package/dist/evals/tool-loop-permission.js.map +1 -0
  855. package/dist/game-authoring.d.ts +4737 -0
  856. package/dist/game-authoring.d.ts.map +1 -0
  857. package/dist/game-authoring.js +146 -0
  858. package/dist/game-authoring.js.map +1 -0
  859. package/dist/game-code-bake.d.ts +26 -0
  860. package/dist/game-code-bake.d.ts.map +1 -0
  861. package/dist/game-code-bake.js +98 -0
  862. package/dist/game-code-bake.js.map +1 -0
  863. package/dist/game-examples.d.ts +1303 -0
  864. package/dist/game-examples.d.ts.map +1 -0
  865. package/dist/game-examples.js +188 -0
  866. package/dist/game-examples.js.map +1 -0
  867. package/dist/graph-builder.d.ts +55 -3
  868. package/dist/graph-builder.d.ts.map +1 -1
  869. package/dist/graph-builder.js +159 -4
  870. package/dist/graph-builder.js.map +1 -1
  871. package/dist/graph-dsl-core.d.ts +25 -0
  872. package/dist/graph-dsl-core.d.ts.map +1 -0
  873. package/dist/graph-dsl-core.js +312 -0
  874. package/dist/graph-dsl-core.js.map +1 -0
  875. package/dist/graph-dsl.d.ts +30 -0
  876. package/dist/graph-dsl.d.ts.map +1 -0
  877. package/dist/graph-dsl.js +116 -0
  878. package/dist/graph-dsl.js.map +1 -0
  879. package/dist/host-binaries.d.ts +6 -0
  880. package/dist/host-binaries.d.ts.map +1 -0
  881. package/dist/host-binaries.js +6 -0
  882. package/dist/host-binaries.js.map +1 -0
  883. package/dist/host-binary-guard.d.ts +100 -0
  884. package/dist/host-binary-guard.d.ts.map +1 -0
  885. package/dist/host-binary-guard.js +205 -0
  886. package/dist/host-binary-guard.js.map +1 -0
  887. package/dist/host-modules/aws.d.ts +57 -0
  888. package/dist/host-modules/aws.d.ts.map +1 -0
  889. package/dist/host-modules/aws.js +309 -0
  890. package/dist/host-modules/aws.js.map +1 -0
  891. package/dist/host-modules/chrono.d.ts +15 -0
  892. package/dist/host-modules/chrono.d.ts.map +1 -0
  893. package/dist/host-modules/chrono.js +35 -0
  894. package/dist/host-modules/chrono.js.map +1 -0
  895. package/dist/host-modules/csv.d.ts +17 -0
  896. package/dist/host-modules/csv.d.ts.map +1 -0
  897. package/dist/host-modules/csv.js +64 -0
  898. package/dist/host-modules/csv.js.map +1 -0
  899. package/dist/host-modules/diff.d.ts +9 -0
  900. package/dist/host-modules/diff.d.ts.map +1 -0
  901. package/dist/host-modules/diff.js +26 -0
  902. package/dist/host-modules/diff.js.map +1 -0
  903. package/dist/host-modules/dispatcher.d.ts +41 -0
  904. package/dist/host-modules/dispatcher.d.ts.map +1 -0
  905. package/dist/host-modules/dispatcher.js +99 -0
  906. package/dist/host-modules/dispatcher.js.map +1 -0
  907. package/dist/host-modules/docx.d.ts +19 -0
  908. package/dist/host-modules/docx.d.ts.map +1 -0
  909. package/dist/host-modules/docx.js +120 -0
  910. package/dist/host-modules/docx.js.map +1 -0
  911. package/dist/host-modules/epub.d.ts +48 -0
  912. package/dist/host-modules/epub.d.ts.map +1 -0
  913. package/dist/host-modules/epub.js +100 -0
  914. package/dist/host-modules/epub.js.map +1 -0
  915. package/dist/host-modules/exif.d.ts +8 -0
  916. package/dist/host-modules/exif.d.ts.map +1 -0
  917. package/dist/host-modules/exif.js +19 -0
  918. package/dist/host-modules/exif.js.map +1 -0
  919. package/dist/host-modules/expr.d.ts +16 -0
  920. package/dist/host-modules/expr.d.ts.map +1 -0
  921. package/dist/host-modules/expr.js +18 -0
  922. package/dist/host-modules/expr.js.map +1 -0
  923. package/dist/host-modules/fabric.d.ts +46 -0
  924. package/dist/host-modules/fabric.d.ts.map +1 -0
  925. package/dist/host-modules/fabric.js +178 -0
  926. package/dist/host-modules/fabric.js.map +1 -0
  927. package/dist/host-modules/html.d.ts +51 -0
  928. package/dist/host-modules/html.d.ts.map +1 -0
  929. package/dist/host-modules/html.js +198 -0
  930. package/dist/host-modules/html.js.map +1 -0
  931. package/dist/host-modules/ics.d.ts +9 -0
  932. package/dist/host-modules/ics.d.ts.map +1 -0
  933. package/dist/host-modules/ics.js +35 -0
  934. package/dist/host-modules/ics.js.map +1 -0
  935. package/dist/host-modules/limits.d.ts +41 -0
  936. package/dist/host-modules/limits.d.ts.map +1 -0
  937. package/dist/host-modules/limits.js +76 -0
  938. package/dist/host-modules/limits.js.map +1 -0
  939. package/dist/host-modules/mammoth.d.ts +11 -0
  940. package/dist/host-modules/mammoth.d.ts.map +1 -0
  941. package/dist/host-modules/mammoth.js +29 -0
  942. package/dist/host-modules/mammoth.js.map +1 -0
  943. package/dist/host-modules/notion.d.ts +45 -0
  944. package/dist/host-modules/notion.d.ts.map +1 -0
  945. package/dist/host-modules/notion.js +128 -0
  946. package/dist/host-modules/notion.js.map +1 -0
  947. package/dist/host-modules/ocr.d.ts +25 -0
  948. package/dist/host-modules/ocr.d.ts.map +1 -0
  949. package/dist/host-modules/ocr.js +74 -0
  950. package/dist/host-modules/ocr.js.map +1 -0
  951. package/dist/host-modules/pdf.d.ts +21 -0
  952. package/dist/host-modules/pdf.d.ts.map +1 -0
  953. package/dist/host-modules/pdf.js +53 -0
  954. package/dist/host-modules/pdf.js.map +1 -0
  955. package/dist/host-modules/pdflib.d.ts +17 -0
  956. package/dist/host-modules/pdflib.d.ts.map +1 -0
  957. package/dist/host-modules/pdflib.js +138 -0
  958. package/dist/host-modules/pdflib.js.map +1 -0
  959. package/dist/host-modules/pptx.d.ts +19 -0
  960. package/dist/host-modules/pptx.d.ts.map +1 -0
  961. package/dist/host-modules/pptx.js +67 -0
  962. package/dist/host-modules/pptx.js.map +1 -0
  963. package/dist/host-modules/pptxgen.d.ts +13 -0
  964. package/dist/host-modules/pptxgen.d.ts.map +1 -0
  965. package/dist/host-modules/pptxgen.js +98 -0
  966. package/dist/host-modules/pptxgen.js.map +1 -0
  967. package/dist/host-modules/prepared-request.d.ts +41 -0
  968. package/dist/host-modules/prepared-request.d.ts.map +1 -0
  969. package/dist/host-modules/prepared-request.js +104 -0
  970. package/dist/host-modules/prepared-request.js.map +1 -0
  971. package/dist/host-modules/registry.d.ts +31 -0
  972. package/dist/host-modules/registry.d.ts.map +1 -0
  973. package/dist/host-modules/registry.js +193 -0
  974. package/dist/host-modules/registry.js.map +1 -0
  975. package/dist/host-modules/subtitle.d.ts +15 -0
  976. package/dist/host-modules/subtitle.d.ts.map +1 -0
  977. package/dist/host-modules/subtitle.js +45 -0
  978. package/dist/host-modules/subtitle.js.map +1 -0
  979. package/dist/host-modules/supabase.d.ts +42 -0
  980. package/dist/host-modules/supabase.d.ts.map +1 -0
  981. package/dist/host-modules/supabase.js +141 -0
  982. package/dist/host-modules/supabase.js.map +1 -0
  983. package/dist/host-modules/tfjs.d.ts +42 -0
  984. package/dist/host-modules/tfjs.d.ts.map +1 -0
  985. package/dist/host-modules/tfjs.js +186 -0
  986. package/dist/host-modules/tfjs.js.map +1 -0
  987. package/dist/host-modules/tokens.d.ts +17 -0
  988. package/dist/host-modules/tokens.d.ts.map +1 -0
  989. package/dist/host-modules/tokens.js +74 -0
  990. package/dist/host-modules/tokens.js.map +1 -0
  991. package/dist/host-modules/twilio.d.ts +34 -0
  992. package/dist/host-modules/twilio.d.ts.map +1 -0
  993. package/dist/host-modules/twilio.js +67 -0
  994. package/dist/host-modules/twilio.js.map +1 -0
  995. package/dist/host-modules/xlsx.d.ts +26 -0
  996. package/dist/host-modules/xlsx.d.ts.map +1 -0
  997. package/dist/host-modules/xlsx.js +323 -0
  998. package/dist/host-modules/xlsx.js.map +1 -0
  999. package/dist/host-modules/xml.d.ts +23 -0
  1000. package/dist/host-modules/xml.d.ts.map +1 -0
  1001. package/dist/host-modules/xml.js +38 -0
  1002. package/dist/host-modules/xml.js.map +1 -0
  1003. package/dist/host-modules/zip.d.ts +24 -0
  1004. package/dist/host-modules/zip.d.ts.map +1 -0
  1005. package/dist/host-modules/zip.js +70 -0
  1006. package/dist/host-modules/zip.js.map +1 -0
  1007. package/dist/index.d.ts +208 -60
  1008. package/dist/index.d.ts.map +1 -1
  1009. package/dist/index.js +163 -60
  1010. package/dist/index.js.map +1 -1
  1011. package/dist/js-sandbox-worker/engine.d.ts +4 -0
  1012. package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
  1013. package/dist/js-sandbox-worker/engine.js +45 -0
  1014. package/dist/js-sandbox-worker/engine.js.map +1 -0
  1015. package/dist/js-sandbox-worker/host.d.ts +136 -0
  1016. package/dist/js-sandbox-worker/host.d.ts.map +1 -0
  1017. package/dist/js-sandbox-worker/host.js +482 -0
  1018. package/dist/js-sandbox-worker/host.js.map +1 -0
  1019. package/dist/js-sandbox-worker/interpreter.d.ts +276 -0
  1020. package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -0
  1021. package/dist/js-sandbox-worker/interpreter.js +1293 -0
  1022. package/dist/js-sandbox-worker/interpreter.js.map +1 -0
  1023. package/dist/js-sandbox-worker/protocol.d.ts +168 -0
  1024. package/dist/js-sandbox-worker/protocol.d.ts.map +1 -0
  1025. package/dist/js-sandbox-worker/protocol.js +217 -0
  1026. package/dist/js-sandbox-worker/protocol.js.map +1 -0
  1027. package/dist/js-sandbox-worker/worker-entry.d.ts +26 -0
  1028. package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -0
  1029. package/dist/js-sandbox-worker/worker-entry.js +308 -0
  1030. package/dist/js-sandbox-worker/worker-entry.js.map +1 -0
  1031. package/dist/js-sandbox.d.ts +457 -15
  1032. package/dist/js-sandbox.d.ts.map +1 -1
  1033. package/dist/js-sandbox.js +2008 -311
  1034. package/dist/js-sandbox.js.map +1 -1
  1035. package/dist/js-script-app-runner.d.ts +11 -0
  1036. package/dist/js-script-app-runner.d.ts.map +1 -0
  1037. package/dist/js-script-app-runner.js +54 -0
  1038. package/dist/js-script-app-runner.js.map +1 -0
  1039. package/dist/js-script-sandbox.d.ts +27 -0
  1040. package/dist/js-script-sandbox.d.ts.map +1 -0
  1041. package/dist/js-script-sandbox.js +36 -0
  1042. package/dist/js-script-sandbox.js.map +1 -0
  1043. package/dist/jtbd/friction.d.ts +26 -0
  1044. package/dist/jtbd/friction.d.ts.map +1 -0
  1045. package/dist/jtbd/friction.js +169 -0
  1046. package/dist/jtbd/friction.js.map +1 -0
  1047. package/dist/jtbd/index.d.ts +6 -0
  1048. package/dist/jtbd/index.d.ts.map +1 -0
  1049. package/dist/jtbd/index.js +6 -0
  1050. package/dist/jtbd/index.js.map +1 -0
  1051. package/dist/jtbd/optimize.d.ts +71 -0
  1052. package/dist/jtbd/optimize.d.ts.map +1 -0
  1053. package/dist/jtbd/optimize.js +176 -0
  1054. package/dist/jtbd/optimize.js.map +1 -0
  1055. package/dist/jtbd/registry.d.ts +29 -0
  1056. package/dist/jtbd/registry.d.ts.map +1 -0
  1057. package/dist/jtbd/registry.js +451 -0
  1058. package/dist/jtbd/registry.js.map +1 -0
  1059. package/dist/jtbd/run.d.ts +70 -0
  1060. package/dist/jtbd/run.d.ts.map +1 -0
  1061. package/dist/jtbd/run.js +177 -0
  1062. package/dist/jtbd/run.js.map +1 -0
  1063. package/dist/jtbd/types.d.ts +141 -0
  1064. package/dist/jtbd/types.d.ts.map +1 -0
  1065. package/dist/jtbd/types.js +25 -0
  1066. package/dist/jtbd/types.js.map +1 -0
  1067. package/dist/model-prompting-skills.d.ts +45 -0
  1068. package/dist/model-prompting-skills.d.ts.map +1 -0
  1069. package/dist/model-prompting-skills.js +116 -0
  1070. package/dist/model-prompting-skills.js.map +1 -0
  1071. package/dist/network-guard.d.ts +50 -0
  1072. package/dist/network-guard.d.ts.map +1 -0
  1073. package/dist/network-guard.js +106 -0
  1074. package/dist/network-guard.js.map +1 -0
  1075. package/dist/normalize-model-properties.d.ts +26 -0
  1076. package/dist/normalize-model-properties.d.ts.map +1 -0
  1077. package/dist/normalize-model-properties.js +58 -0
  1078. package/dist/normalize-model-properties.js.map +1 -0
  1079. package/dist/output-format.d.ts +5 -1
  1080. package/dist/output-format.d.ts.map +1 -1
  1081. package/dist/output-format.js.map +1 -1
  1082. package/dist/parallel-task-executor.d.ts +68 -37
  1083. package/dist/parallel-task-executor.d.ts.map +1 -1
  1084. package/dist/parallel-task-executor.js +234 -203
  1085. package/dist/parallel-task-executor.js.map +1 -1
  1086. package/dist/prompts/background-subtask-prompt.d.ts +14 -0
  1087. package/dist/prompts/background-subtask-prompt.d.ts.map +1 -0
  1088. package/dist/prompts/background-subtask-prompt.js +64 -0
  1089. package/dist/prompts/background-subtask-prompt.js.map +1 -0
  1090. package/dist/prompts/product-knowledge.d.ts +3 -0
  1091. package/dist/prompts/product-knowledge.d.ts.map +1 -0
  1092. package/dist/prompts/product-knowledge.js +120 -0
  1093. package/dist/prompts/product-knowledge.js.map +1 -0
  1094. package/dist/prompts/read-only-search-prompt.d.ts +33 -0
  1095. package/dist/prompts/read-only-search-prompt.d.ts.map +1 -0
  1096. package/dist/prompts/read-only-search-prompt.js +109 -0
  1097. package/dist/prompts/read-only-search-prompt.js.map +1 -0
  1098. package/dist/prompts/sandbox-pack-catalog.d.ts +23 -0
  1099. package/dist/prompts/sandbox-pack-catalog.d.ts.map +1 -0
  1100. package/dist/prompts/sandbox-pack-catalog.js +40 -0
  1101. package/dist/prompts/sandbox-pack-catalog.js.map +1 -0
  1102. package/dist/prompts/security-monitor-prompt.d.ts +32 -0
  1103. package/dist/prompts/security-monitor-prompt.d.ts.map +1 -0
  1104. package/dist/prompts/security-monitor-prompt.js +99 -0
  1105. package/dist/prompts/security-monitor-prompt.js.map +1 -0
  1106. package/dist/prompts/workflow-authoring-knowledge.d.ts +77 -0
  1107. package/dist/prompts/workflow-authoring-knowledge.d.ts.map +1 -0
  1108. package/dist/prompts/workflow-authoring-knowledge.js +319 -0
  1109. package/dist/prompts/workflow-authoring-knowledge.js.map +1 -0
  1110. package/dist/run-policy.d.ts +25 -0
  1111. package/dist/run-policy.d.ts.map +1 -0
  1112. package/dist/run-policy.js +54 -0
  1113. package/dist/run-policy.js.map +1 -0
  1114. package/dist/sandbox-av-media.d.ts +33 -0
  1115. package/dist/sandbox-av-media.d.ts.map +1 -0
  1116. package/dist/sandbox-av-media.js +666 -0
  1117. package/dist/sandbox-av-media.js.map +1 -0
  1118. package/dist/sandbox-bootstrap-modules.d.ts +54 -0
  1119. package/dist/sandbox-bootstrap-modules.d.ts.map +1 -0
  1120. package/dist/sandbox-bootstrap-modules.js +104 -0
  1121. package/dist/sandbox-bootstrap-modules.js.map +1 -0
  1122. package/dist/sandbox-bytes.d.ts +43 -0
  1123. package/dist/sandbox-bytes.d.ts.map +1 -0
  1124. package/dist/sandbox-bytes.js +61 -0
  1125. package/dist/sandbox-bytes.js.map +1 -0
  1126. package/dist/sandbox-canvas-api.d.ts +30 -0
  1127. package/dist/sandbox-canvas-api.d.ts.map +1 -0
  1128. package/dist/sandbox-canvas-api.js +81 -0
  1129. package/dist/sandbox-canvas-api.js.map +1 -0
  1130. package/dist/sandbox-constants.d.ts +5 -0
  1131. package/dist/sandbox-constants.d.ts.map +1 -0
  1132. package/dist/sandbox-constants.js +13 -0
  1133. package/dist/sandbox-constants.js.map +1 -0
  1134. package/dist/sandbox-json-transport.d.ts +107 -0
  1135. package/dist/sandbox-json-transport.d.ts.map +1 -0
  1136. package/dist/sandbox-json-transport.js +324 -0
  1137. package/dist/sandbox-json-transport.js.map +1 -0
  1138. package/dist/sandbox-media-handle.d.ts +78 -0
  1139. package/dist/sandbox-media-handle.d.ts.map +1 -0
  1140. package/dist/sandbox-media-handle.js +114 -0
  1141. package/dist/sandbox-media-handle.js.map +1 -0
  1142. package/dist/sandbox-media-ref.d.ts +134 -0
  1143. package/dist/sandbox-media-ref.d.ts.map +1 -0
  1144. package/dist/sandbox-media-ref.js +442 -0
  1145. package/dist/sandbox-media-ref.js.map +1 -0
  1146. package/dist/sandbox-media.d.ts +177 -0
  1147. package/dist/sandbox-media.d.ts.map +1 -0
  1148. package/dist/sandbox-media.js +963 -0
  1149. package/dist/sandbox-media.js.map +1 -0
  1150. package/dist/sandbox-module-fixtures.d.ts +445 -0
  1151. package/dist/sandbox-module-fixtures.d.ts.map +1 -0
  1152. package/dist/sandbox-module-fixtures.js +214 -0
  1153. package/dist/sandbox-module-fixtures.js.map +1 -0
  1154. package/dist/sandbox-pack-resolution.d.ts +21 -0
  1155. package/dist/sandbox-pack-resolution.d.ts.map +1 -0
  1156. package/dist/sandbox-pack-resolution.js +42 -0
  1157. package/dist/sandbox-pack-resolution.js.map +1 -0
  1158. package/dist/sandbox-toolbelt.d.ts +15 -0
  1159. package/dist/sandbox-toolbelt.d.ts.map +1 -0
  1160. package/dist/sandbox-toolbelt.js +70 -0
  1161. package/dist/sandbox-toolbelt.js.map +1 -0
  1162. package/dist/security-monitor.d.ts +89 -0
  1163. package/dist/security-monitor.d.ts.map +1 -0
  1164. package/dist/security-monitor.js +307 -0
  1165. package/dist/security-monitor.js.map +1 -0
  1166. package/dist/serpapi/catalog.d.ts +101 -0
  1167. package/dist/serpapi/catalog.d.ts.map +1 -0
  1168. package/dist/serpapi/catalog.js +246 -0
  1169. package/dist/serpapi/catalog.js.map +1 -0
  1170. package/dist/serpapi/client.d.ts +81 -0
  1171. package/dist/serpapi/client.d.ts.map +1 -0
  1172. package/dist/serpapi/client.js +228 -0
  1173. package/dist/serpapi/client.js.map +1 -0
  1174. package/dist/serpapi/errors.d.ts +49 -0
  1175. package/dist/serpapi/errors.d.ts.map +1 -0
  1176. package/dist/serpapi/errors.js +64 -0
  1177. package/dist/serpapi/errors.js.map +1 -0
  1178. package/dist/serpapi/normalize.d.ts +58 -0
  1179. package/dist/serpapi/normalize.d.ts.map +1 -0
  1180. package/dist/serpapi/normalize.js +140 -0
  1181. package/dist/serpapi/normalize.js.map +1 -0
  1182. package/dist/skill-prompt.d.ts +37 -0
  1183. package/dist/skill-prompt.d.ts.map +1 -0
  1184. package/dist/skill-prompt.js +72 -0
  1185. package/dist/skill-prompt.js.map +1 -0
  1186. package/dist/step-executor.d.ts +90 -77
  1187. package/dist/step-executor.d.ts.map +1 -1
  1188. package/dist/step-executor.js +384 -690
  1189. package/dist/step-executor.js.map +1 -1
  1190. package/dist/subagent.d.ts +275 -0
  1191. package/dist/subagent.d.ts.map +1 -0
  1192. package/dist/subagent.js +444 -0
  1193. package/dist/subagent.js.map +1 -0
  1194. package/dist/supervisor/prompt.d.ts +12 -0
  1195. package/dist/supervisor/prompt.d.ts.map +1 -0
  1196. package/dist/supervisor/prompt.js +51 -0
  1197. package/dist/supervisor/prompt.js.map +1 -0
  1198. package/dist/supervisor/supervisor-agent.d.ts +72 -0
  1199. package/dist/supervisor/supervisor-agent.d.ts.map +1 -0
  1200. package/dist/supervisor/supervisor-agent.js +185 -0
  1201. package/dist/supervisor/supervisor-agent.js.map +1 -0
  1202. package/dist/supervisor/tools.d.ts +56 -0
  1203. package/dist/supervisor/tools.d.ts.map +1 -0
  1204. package/dist/supervisor/tools.js +83 -0
  1205. package/dist/supervisor/tools.js.map +1 -0
  1206. package/dist/supervisor/verdict-schema.d.ts +18 -0
  1207. package/dist/supervisor/verdict-schema.d.ts.map +1 -0
  1208. package/dist/supervisor/verdict-schema.js +58 -0
  1209. package/dist/supervisor/verdict-schema.js.map +1 -0
  1210. package/dist/system-skills.d.ts +74 -0
  1211. package/dist/system-skills.d.ts.map +1 -0
  1212. package/dist/system-skills.js +168 -0
  1213. package/dist/system-skills.js.map +1 -0
  1214. package/dist/task-executor.d.ts +90 -40
  1215. package/dist/task-executor.d.ts.map +1 -1
  1216. package/dist/task-executor.js +259 -282
  1217. package/dist/task-executor.js.map +1 -1
  1218. package/dist/task-planner.d.ts +18 -12
  1219. package/dist/task-planner.d.ts.map +1 -1
  1220. package/dist/task-planner.js +342 -328
  1221. package/dist/task-planner.js.map +1 -1
  1222. package/dist/timeline-capture.d.ts +21 -0
  1223. package/dist/timeline-capture.d.ts.map +1 -0
  1224. package/dist/timeline-capture.js +564 -0
  1225. package/dist/timeline-capture.js.map +1 -0
  1226. package/dist/timeline-code-bake.d.ts +75 -0
  1227. package/dist/timeline-code-bake.d.ts.map +1 -0
  1228. package/dist/timeline-code-bake.js +327 -0
  1229. package/dist/timeline-code-bake.js.map +1 -0
  1230. package/dist/timeline-preview/compare.d.ts +27 -0
  1231. package/dist/timeline-preview/compare.d.ts.map +1 -0
  1232. package/dist/timeline-preview/compare.js +71 -0
  1233. package/dist/timeline-preview/compare.js.map +1 -0
  1234. package/dist/timeline-preview/frames.d.ts +193 -0
  1235. package/dist/timeline-preview/frames.d.ts.map +1 -0
  1236. package/dist/timeline-preview/frames.js +731 -0
  1237. package/dist/timeline-preview/frames.js.map +1 -0
  1238. package/dist/timeline-preview/model3d.d.ts +67 -0
  1239. package/dist/timeline-preview/model3d.d.ts.map +1 -0
  1240. package/dist/timeline-preview/model3d.js +165 -0
  1241. package/dist/timeline-preview/model3d.js.map +1 -0
  1242. package/dist/timeline-preview/rasterize.d.ts +33 -0
  1243. package/dist/timeline-preview/rasterize.d.ts.map +1 -0
  1244. package/dist/timeline-preview/rasterize.js +83 -0
  1245. package/dist/timeline-preview/rasterize.js.map +1 -0
  1246. package/dist/timeline-preview/sheet.d.ts +38 -0
  1247. package/dist/timeline-preview/sheet.d.ts.map +1 -0
  1248. package/dist/timeline-preview/sheet.js +72 -0
  1249. package/dist/timeline-preview/sheet.js.map +1 -0
  1250. package/dist/tools/asset-persist.d.ts +29 -0
  1251. package/dist/tools/asset-persist.d.ts.map +1 -0
  1252. package/dist/tools/asset-persist.js +78 -0
  1253. package/dist/tools/asset-persist.js.map +1 -0
  1254. package/dist/tools/base-tool.d.ts +53 -5
  1255. package/dist/tools/base-tool.d.ts.map +1 -1
  1256. package/dist/tools/base-tool.js +180 -3
  1257. package/dist/tools/base-tool.js.map +1 -1
  1258. package/dist/tools/binary-output.d.ts +54 -0
  1259. package/dist/tools/binary-output.d.ts.map +1 -0
  1260. package/dist/tools/binary-output.js +127 -0
  1261. package/dist/tools/binary-output.js.map +1 -0
  1262. package/dist/tools/browser-tools.d.ts +5 -29
  1263. package/dist/tools/browser-tools.d.ts.map +1 -1
  1264. package/dist/tools/browser-tools.js +5 -205
  1265. package/dist/tools/browser-tools.js.map +1 -1
  1266. package/dist/tools/builtin-tools.d.ts +52 -0
  1267. package/dist/tools/builtin-tools.d.ts.map +1 -0
  1268. package/dist/tools/builtin-tools.js +289 -0
  1269. package/dist/tools/builtin-tools.js.map +1 -0
  1270. package/dist/tools/control-tool.d.ts +2 -5
  1271. package/dist/tools/control-tool.d.ts.map +1 -1
  1272. package/dist/tools/control-tool.js +18 -15
  1273. package/dist/tools/control-tool.js.map +1 -1
  1274. package/dist/tools/dataseo-tools.d.ts +34 -32
  1275. package/dist/tools/dataseo-tools.d.ts.map +1 -1
  1276. package/dist/tools/dataseo-tools.js +148 -233
  1277. package/dist/tools/dataseo-tools.js.map +1 -1
  1278. package/dist/tools/external-capability-tools.d.ts +36 -0
  1279. package/dist/tools/external-capability-tools.d.ts.map +1 -0
  1280. package/dist/tools/external-capability-tools.js +41 -0
  1281. package/dist/tools/external-capability-tools.js.map +1 -0
  1282. package/dist/tools/external-mcp-tools.d.ts +139 -0
  1283. package/dist/tools/external-mcp-tools.d.ts.map +1 -0
  1284. package/dist/tools/external-mcp-tools.js +552 -0
  1285. package/dist/tools/external-mcp-tools.js.map +1 -0
  1286. package/dist/tools/finish-step-tool.d.ts +1 -1
  1287. package/dist/tools/finish-step-tool.d.ts.map +1 -1
  1288. package/dist/tools/finish-step-tool.js +3 -3
  1289. package/dist/tools/finish-step-tool.js.map +1 -1
  1290. package/dist/tools/google-tools.d.ts +28 -39
  1291. package/dist/tools/google-tools.d.ts.map +1 -1
  1292. package/dist/tools/google-tools.js +51 -164
  1293. package/dist/tools/google-tools.js.map +1 -1
  1294. package/dist/tools/google-workspace-tools.d.ts +23 -0
  1295. package/dist/tools/google-workspace-tools.d.ts.map +1 -0
  1296. package/dist/tools/google-workspace-tools.js +26 -0
  1297. package/dist/tools/google-workspace-tools.js.map +1 -0
  1298. package/dist/tools/graph-validation-registry.d.ts +33 -0
  1299. package/dist/tools/graph-validation-registry.d.ts.map +1 -0
  1300. package/dist/tools/graph-validation-registry.js +54 -0
  1301. package/dist/tools/graph-validation-registry.js.map +1 -0
  1302. package/dist/tools/http-tools.d.ts +5 -53
  1303. package/dist/tools/http-tools.d.ts.map +1 -1
  1304. package/dist/tools/http-tools.js +5 -177
  1305. package/dist/tools/http-tools.js.map +1 -1
  1306. package/dist/tools/image-injection.d.ts +51 -0
  1307. package/dist/tools/image-injection.d.ts.map +1 -0
  1308. package/dist/tools/image-injection.js +85 -0
  1309. package/dist/tools/image-injection.js.map +1 -0
  1310. package/dist/tools/mcp-tool-support.d.ts +204 -0
  1311. package/dist/tools/mcp-tool-support.d.ts.map +1 -0
  1312. package/dist/tools/mcp-tool-support.js +537 -0
  1313. package/dist/tools/mcp-tool-support.js.map +1 -0
  1314. package/dist/tools/mcp-tools.d.ts +106 -390
  1315. package/dist/tools/mcp-tools.d.ts.map +1 -1
  1316. package/dist/tools/mcp-tools.js +132 -601
  1317. package/dist/tools/mcp-tools.js.map +1 -1
  1318. package/dist/tools/media-tools.d.ts +9 -272
  1319. package/dist/tools/media-tools.d.ts.map +1 -1
  1320. package/dist/tools/media-tools.js +11 -676
  1321. package/dist/tools/media-tools.js.map +1 -1
  1322. package/dist/tools/memory-tools.d.ts +36 -0
  1323. package/dist/tools/memory-tools.d.ts.map +1 -0
  1324. package/dist/tools/memory-tools.js +52 -0
  1325. package/dist/tools/memory-tools.js.map +1 -0
  1326. package/dist/tools/openai-tools.d.ts +28 -68
  1327. package/dist/tools/openai-tools.d.ts.map +1 -1
  1328. package/dist/tools/openai-tools.js +51 -181
  1329. package/dist/tools/openai-tools.js.map +1 -1
  1330. package/dist/tools/plan-builder-tools.d.ts +141 -7
  1331. package/dist/tools/plan-builder-tools.d.ts.map +1 -1
  1332. package/dist/tools/plan-builder-tools.js +159 -86
  1333. package/dist/tools/plan-builder-tools.js.map +1 -1
  1334. package/dist/tools/run-search-tool.d.ts +82 -0
  1335. package/dist/tools/run-search-tool.d.ts.map +1 -0
  1336. package/dist/tools/run-search-tool.js +121 -0
  1337. package/dist/tools/run-search-tool.js.map +1 -0
  1338. package/dist/tools/run-subtask-tool.d.ts +49 -0
  1339. package/dist/tools/run-subtask-tool.d.ts.map +1 -0
  1340. package/dist/tools/run-subtask-tool.js +88 -0
  1341. package/dist/tools/run-subtask-tool.js.map +1 -0
  1342. package/dist/tools/search-tools.d.ts +5 -36
  1343. package/dist/tools/search-tools.d.ts.map +1 -1
  1344. package/dist/tools/search-tools.js +5 -215
  1345. package/dist/tools/search-tools.js.map +1 -1
  1346. package/dist/tools/serp-providers/apify-provider.d.ts +18 -0
  1347. package/dist/tools/serp-providers/apify-provider.d.ts.map +1 -0
  1348. package/dist/tools/serp-providers/apify-provider.js +93 -0
  1349. package/dist/tools/serp-providers/apify-provider.js.map +1 -0
  1350. package/dist/tools/serp-providers/brave-provider.d.ts +34 -0
  1351. package/dist/tools/serp-providers/brave-provider.d.ts.map +1 -0
  1352. package/dist/tools/serp-providers/brave-provider.js +86 -0
  1353. package/dist/tools/serp-providers/brave-provider.js.map +1 -0
  1354. package/dist/tools/serp-providers/dataforseo-provider.d.ts +14 -1
  1355. package/dist/tools/serp-providers/dataforseo-provider.d.ts.map +1 -1
  1356. package/dist/tools/serp-providers/dataforseo-provider.js +0 -9
  1357. package/dist/tools/serp-providers/dataforseo-provider.js.map +1 -1
  1358. package/dist/tools/serp-providers/gemini-provider.d.ts +45 -0
  1359. package/dist/tools/serp-providers/gemini-provider.d.ts.map +1 -0
  1360. package/dist/tools/serp-providers/gemini-provider.js +148 -0
  1361. package/dist/tools/serp-providers/gemini-provider.js.map +1 -0
  1362. package/dist/tools/serp-providers/index.d.ts +61 -0
  1363. package/dist/tools/serp-providers/index.d.ts.map +1 -1
  1364. package/dist/tools/serp-providers/index.js +119 -3
  1365. package/dist/tools/serp-providers/index.js.map +1 -1
  1366. package/dist/tools/serp-providers/openai-provider.d.ts +58 -0
  1367. package/dist/tools/serp-providers/openai-provider.d.ts.map +1 -0
  1368. package/dist/tools/serp-providers/openai-provider.js +113 -0
  1369. package/dist/tools/serp-providers/openai-provider.js.map +1 -0
  1370. package/dist/tools/serp-providers/serpapi-provider.d.ts +9 -5
  1371. package/dist/tools/serp-providers/serpapi-provider.d.ts.map +1 -1
  1372. package/dist/tools/serp-providers/serpapi-provider.js +26 -44
  1373. package/dist/tools/serp-providers/serpapi-provider.js.map +1 -1
  1374. package/dist/tools/serp-tool-factory.d.ts +27 -0
  1375. package/dist/tools/serp-tool-factory.d.ts.map +1 -0
  1376. package/dist/tools/serp-tool-factory.js +56 -0
  1377. package/dist/tools/serp-tool-factory.js.map +1 -0
  1378. package/dist/tools/shared-tools.d.ts +33 -0
  1379. package/dist/tools/shared-tools.d.ts.map +1 -0
  1380. package/dist/tools/shared-tools.js +39 -0
  1381. package/dist/tools/shared-tools.js.map +1 -0
  1382. package/dist/tools/start-subtask-tool.d.ts +51 -0
  1383. package/dist/tools/start-subtask-tool.d.ts.map +1 -0
  1384. package/dist/tools/start-subtask-tool.js +189 -0
  1385. package/dist/tools/start-subtask-tool.js.map +1 -0
  1386. package/dist/tools/submit-code-tool.d.ts +159 -0
  1387. package/dist/tools/submit-code-tool.d.ts.map +1 -0
  1388. package/dist/tools/submit-code-tool.js +209 -0
  1389. package/dist/tools/submit-code-tool.js.map +1 -0
  1390. package/dist/tools/subtask-fields.d.ts +11 -0
  1391. package/dist/tools/subtask-fields.d.ts.map +1 -0
  1392. package/dist/tools/subtask-fields.js +11 -0
  1393. package/dist/tools/subtask-fields.js.map +1 -0
  1394. package/dist/tools/todo-tools.d.ts +15 -0
  1395. package/dist/tools/todo-tools.d.ts.map +1 -0
  1396. package/dist/tools/todo-tools.js +15 -0
  1397. package/dist/tools/todo-tools.js.map +1 -0
  1398. package/dist/tools/tool-permissions.d.ts +40 -0
  1399. package/dist/tools/tool-permissions.d.ts.map +1 -0
  1400. package/dist/tools/tool-permissions.js +52 -0
  1401. package/dist/tools/tool-permissions.js.map +1 -0
  1402. package/dist/tools/tool-search.d.ts +39 -0
  1403. package/dist/tools/tool-search.d.ts.map +1 -0
  1404. package/dist/tools/tool-search.js +108 -0
  1405. package/dist/tools/tool-search.js.map +1 -0
  1406. package/dist/tools/vector-tool-support.d.ts +15 -0
  1407. package/dist/tools/vector-tool-support.d.ts.map +1 -0
  1408. package/dist/tools/vector-tool-support.js +133 -0
  1409. package/dist/tools/vector-tool-support.js.map +1 -0
  1410. package/dist/tools/vector-tools.d.ts +13 -220
  1411. package/dist/tools/vector-tools.d.ts.map +1 -1
  1412. package/dist/tools/vector-tools.js +7 -578
  1413. package/dist/tools/vector-tools.js.map +1 -1
  1414. package/dist/tools/wait-subtasks-tool.d.ts +27 -0
  1415. package/dist/tools/wait-subtasks-tool.d.ts.map +1 -0
  1416. package/dist/tools/wait-subtasks-tool.js +66 -0
  1417. package/dist/tools/wait-subtasks-tool.js.map +1 -0
  1418. package/dist/types.d.ts +16 -31
  1419. package/dist/types.d.ts.map +1 -1
  1420. package/dist/types.js +8 -1
  1421. package/dist/types.js.map +1 -1
  1422. package/dist/utils/dag-scheduler.d.ts +85 -0
  1423. package/dist/utils/dag-scheduler.d.ts.map +1 -0
  1424. package/dist/utils/dag-scheduler.js +180 -0
  1425. package/dist/utils/dag-scheduler.js.map +1 -0
  1426. package/dist/utils/json-parser.d.ts +32 -1
  1427. package/dist/utils/json-parser.d.ts.map +1 -1
  1428. package/dist/utils/json-parser.js +145 -10
  1429. package/dist/utils/json-parser.js.map +1 -1
  1430. package/dist/utils/json-schema-validate.d.ts +29 -0
  1431. package/dist/utils/json-schema-validate.d.ts.map +1 -0
  1432. package/dist/utils/json-schema-validate.js +228 -0
  1433. package/dist/utils/json-schema-validate.js.map +1 -0
  1434. package/dist/utils/link-abort.d.ts +13 -0
  1435. package/dist/utils/link-abort.d.ts.map +1 -0
  1436. package/dist/utils/link-abort.js +23 -0
  1437. package/dist/utils/link-abort.js.map +1 -0
  1438. package/dist/utils/merge-generators.d.ts +58 -0
  1439. package/dist/utils/merge-generators.d.ts.map +1 -0
  1440. package/dist/utils/merge-generators.js +148 -0
  1441. package/dist/utils/merge-generators.js.map +1 -0
  1442. package/dist/utils/remove-base64-images.d.ts +0 -5
  1443. package/dist/utils/remove-base64-images.d.ts.map +1 -1
  1444. package/dist/utils/remove-base64-images.js.map +1 -1
  1445. package/dist/utils/step-failure.d.ts +20 -0
  1446. package/dist/utils/step-failure.d.ts.map +1 -0
  1447. package/dist/utils/step-failure.js +43 -0
  1448. package/dist/utils/step-failure.js.map +1 -0
  1449. package/dist/utils/think-tags.d.ts +16 -0
  1450. package/dist/utils/think-tags.d.ts.map +1 -0
  1451. package/dist/utils/think-tags.js +23 -0
  1452. package/dist/utils/think-tags.js.map +1 -0
  1453. package/dist/utils/type-guards.d.ts +26 -0
  1454. package/dist/utils/type-guards.d.ts.map +1 -0
  1455. package/dist/utils/type-guards.js +44 -0
  1456. package/dist/utils/type-guards.js.map +1 -0
  1457. package/dist/utils/ui-event-buffer.d.ts +18 -0
  1458. package/dist/utils/ui-event-buffer.d.ts.map +1 -0
  1459. package/dist/utils/ui-event-buffer.js +18 -0
  1460. package/dist/utils/ui-event-buffer.js.map +1 -0
  1461. package/dist/utils/wrap-generators-parallel.d.ts +0 -5
  1462. package/dist/utils/wrap-generators-parallel.d.ts.map +1 -1
  1463. package/dist/utils/wrap-generators-parallel.js +3 -6
  1464. package/dist/utils/wrap-generators-parallel.js.map +1 -1
  1465. package/dist/wasm-sandbox/host.d.ts +106 -0
  1466. package/dist/wasm-sandbox/host.d.ts.map +1 -0
  1467. package/dist/wasm-sandbox/host.js +409 -0
  1468. package/dist/wasm-sandbox/host.js.map +1 -0
  1469. package/dist/wasm-sandbox/workers.d.ts +43 -0
  1470. package/dist/wasm-sandbox/workers.d.ts.map +1 -0
  1471. package/dist/wasm-sandbox/workers.js +150 -0
  1472. package/dist/wasm-sandbox/workers.js.map +1 -0
  1473. package/dist/workspace-paths.d.ts +40 -0
  1474. package/dist/workspace-paths.d.ts.map +1 -0
  1475. package/dist/workspace-paths.js +102 -0
  1476. package/dist/workspace-paths.js.map +1 -0
  1477. package/dist/yt-dlp-gate.d.ts +19 -0
  1478. package/dist/yt-dlp-gate.d.ts.map +1 -0
  1479. package/dist/yt-dlp-gate.js +22 -0
  1480. package/dist/yt-dlp-gate.js.map +1 -0
  1481. package/package.json +114 -14
  1482. package/dist/agent-executor.d.ts +0 -62
  1483. package/dist/agent-executor.d.ts.map +0 -1
  1484. package/dist/agent-executor.js +0 -324
  1485. package/dist/agent-executor.js.map +0 -1
  1486. package/dist/agent-step-executor.d.ts +0 -28
  1487. package/dist/agent-step-executor.d.ts.map +0 -1
  1488. package/dist/agent-step-executor.js +0 -99
  1489. package/dist/agent-step-executor.js.map +0 -1
  1490. package/dist/agent-workflow-runner.d.ts +0 -31
  1491. package/dist/agent-workflow-runner.d.ts.map +0 -1
  1492. package/dist/agent-workflow-runner.js +0 -124
  1493. package/dist/agent-workflow-runner.js.map +0 -1
  1494. package/dist/agent.d.ts +0 -115
  1495. package/dist/agent.d.ts.map +0 -1
  1496. package/dist/agent.js +0 -587
  1497. package/dist/agent.js.map +0 -1
  1498. package/dist/base-agent.d.ts +0 -42
  1499. package/dist/base-agent.d.ts.map +0 -1
  1500. package/dist/base-agent.js +0 -29
  1501. package/dist/base-agent.js.map +0 -1
  1502. package/dist/graph-planner.d.ts +0 -56
  1503. package/dist/graph-planner.d.ts.map +0 -1
  1504. package/dist/graph-planner.js +0 -311
  1505. package/dist/graph-planner.js.map +0 -1
  1506. package/dist/multi-mode-agent.d.ts +0 -86
  1507. package/dist/multi-mode-agent.d.ts.map +0 -1
  1508. package/dist/multi-mode-agent.js +0 -476
  1509. package/dist/multi-mode-agent.js.map +0 -1
  1510. package/dist/prompts/graph-planner-prompt.d.ts +0 -48
  1511. package/dist/prompts/graph-planner-prompt.d.ts.map +0 -1
  1512. package/dist/prompts/graph-planner-prompt.js +0 -180
  1513. package/dist/prompts/graph-planner-prompt.js.map +0 -1
  1514. package/dist/reject-agentic-provider.d.ts +0 -21
  1515. package/dist/reject-agentic-provider.d.ts.map +0 -1
  1516. package/dist/reject-agentic-provider.js +0 -32
  1517. package/dist/reject-agentic-provider.js.map +0 -1
  1518. package/dist/simple-agent.d.ts +0 -29
  1519. package/dist/simple-agent.d.ts.map +0 -1
  1520. package/dist/simple-agent.js +0 -54
  1521. package/dist/simple-agent.js.map +0 -1
  1522. package/dist/sub-agent-planner.d.ts +0 -33
  1523. package/dist/sub-agent-planner.d.ts.map +0 -1
  1524. package/dist/sub-agent-planner.js +0 -203
  1525. package/dist/sub-agent-planner.js.map +0 -1
  1526. package/dist/team/db-task-board.d.ts +0 -54
  1527. package/dist/team/db-task-board.d.ts.map +0 -1
  1528. package/dist/team/db-task-board.js +0 -361
  1529. package/dist/team/db-task-board.js.map +0 -1
  1530. package/dist/team/edge-message-bus.d.ts +0 -51
  1531. package/dist/team/edge-message-bus.d.ts.map +0 -1
  1532. package/dist/team/edge-message-bus.js +0 -169
  1533. package/dist/team/edge-message-bus.js.map +0 -1
  1534. package/dist/team/edge-task-board.d.ts +0 -77
  1535. package/dist/team/edge-task-board.d.ts.map +0 -1
  1536. package/dist/team/edge-task-board.js +0 -140
  1537. package/dist/team/edge-task-board.js.map +0 -1
  1538. package/dist/team/index.d.ts +0 -16
  1539. package/dist/team/index.d.ts.map +0 -1
  1540. package/dist/team/index.js +0 -17
  1541. package/dist/team/index.js.map +0 -1
  1542. package/dist/team/message-bus.d.ts +0 -58
  1543. package/dist/team/message-bus.d.ts.map +0 -1
  1544. package/dist/team/message-bus.js +0 -151
  1545. package/dist/team/message-bus.js.map +0 -1
  1546. package/dist/team/task-board.d.ts +0 -106
  1547. package/dist/team/task-board.d.ts.map +0 -1
  1548. package/dist/team/task-board.js +0 -370
  1549. package/dist/team/task-board.js.map +0 -1
  1550. package/dist/team/team-executor.d.ts +0 -72
  1551. package/dist/team/team-executor.d.ts.map +0 -1
  1552. package/dist/team/team-executor.js +0 -466
  1553. package/dist/team/team-executor.js.map +0 -1
  1554. package/dist/team/team-tools.d.ts +0 -252
  1555. package/dist/team/team-tools.d.ts.map +0 -1
  1556. package/dist/team/team-tools.js +0 -412
  1557. package/dist/team/team-tools.js.map +0 -1
  1558. package/dist/team/types.d.ts +0 -198
  1559. package/dist/team/types.d.ts.map +0 -1
  1560. package/dist/team/types.js +0 -8
  1561. package/dist/team/types.js.map +0 -1
  1562. package/dist/tools/add-edge-tool.d.ts +0 -18
  1563. package/dist/tools/add-edge-tool.d.ts.map +0 -1
  1564. package/dist/tools/add-edge-tool.js +0 -92
  1565. package/dist/tools/add-edge-tool.js.map +0 -1
  1566. package/dist/tools/add-node-tool.d.ts +0 -22
  1567. package/dist/tools/add-node-tool.d.ts.map +0 -1
  1568. package/dist/tools/add-node-tool.js +0 -128
  1569. package/dist/tools/add-node-tool.js.map +0 -1
  1570. package/dist/tools/asset-tools.d.ts +0 -58
  1571. package/dist/tools/asset-tools.d.ts.map +0 -1
  1572. package/dist/tools/asset-tools.js +0 -191
  1573. package/dist/tools/asset-tools.js.map +0 -1
  1574. package/dist/tools/calculator-tool.d.ts +0 -24
  1575. package/dist/tools/calculator-tool.d.ts.map +0 -1
  1576. package/dist/tools/calculator-tool.js +0 -64
  1577. package/dist/tools/calculator-tool.js.map +0 -1
  1578. package/dist/tools/claude-code-tools.d.ts +0 -96
  1579. package/dist/tools/claude-code-tools.d.ts.map +0 -1
  1580. package/dist/tools/claude-code-tools.js +0 -463
  1581. package/dist/tools/claude-code-tools.js.map +0 -1
  1582. package/dist/tools/code-tools.d.ts +0 -26
  1583. package/dist/tools/code-tools.d.ts.map +0 -1
  1584. package/dist/tools/code-tools.js +0 -82
  1585. package/dist/tools/code-tools.js.map +0 -1
  1586. package/dist/tools/create-plan-tool.d.ts +0 -29
  1587. package/dist/tools/create-plan-tool.d.ts.map +0 -1
  1588. package/dist/tools/create-plan-tool.js +0 -355
  1589. package/dist/tools/create-plan-tool.js.map +0 -1
  1590. package/dist/tools/create-task-tool.d.ts +0 -28
  1591. package/dist/tools/create-task-tool.d.ts.map +0 -1
  1592. package/dist/tools/create-task-tool.js +0 -254
  1593. package/dist/tools/create-task-tool.js.map +0 -1
  1594. package/dist/tools/email-tools.d.ts +0 -76
  1595. package/dist/tools/email-tools.d.ts.map +0 -1
  1596. package/dist/tools/email-tools.js +0 -259
  1597. package/dist/tools/email-tools.js.map +0 -1
  1598. package/dist/tools/filesystem-tools.d.ts +0 -77
  1599. package/dist/tools/filesystem-tools.d.ts.map +0 -1
  1600. package/dist/tools/filesystem-tools.js +0 -334
  1601. package/dist/tools/filesystem-tools.js.map +0 -1
  1602. package/dist/tools/find-model-tool.d.ts +0 -25
  1603. package/dist/tools/find-model-tool.d.ts.map +0 -1
  1604. package/dist/tools/find-model-tool.js +0 -236
  1605. package/dist/tools/find-model-tool.js.map +0 -1
  1606. package/dist/tools/finish-graph-tool.d.ts +0 -23
  1607. package/dist/tools/finish-graph-tool.d.ts.map +0 -1
  1608. package/dist/tools/finish-graph-tool.js +0 -46
  1609. package/dist/tools/finish-graph-tool.js.map +0 -1
  1610. package/dist/tools/js-code-tool.d.ts +0 -30
  1611. package/dist/tools/js-code-tool.d.ts.map +0 -1
  1612. package/dist/tools/js-code-tool.js +0 -98
  1613. package/dist/tools/js-code-tool.js.map +0 -1
  1614. package/dist/tools/local-get-node-info-tool.d.ts +0 -19
  1615. package/dist/tools/local-get-node-info-tool.d.ts.map +0 -1
  1616. package/dist/tools/local-get-node-info-tool.js +0 -75
  1617. package/dist/tools/local-get-node-info-tool.js.map +0 -1
  1618. package/dist/tools/local-list-nodes-tool.d.ts +0 -19
  1619. package/dist/tools/local-list-nodes-tool.d.ts.map +0 -1
  1620. package/dist/tools/local-list-nodes-tool.js +0 -69
  1621. package/dist/tools/local-list-nodes-tool.js.map +0 -1
  1622. package/dist/tools/local-search-nodes-tool.d.ts +0 -21
  1623. package/dist/tools/local-search-nodes-tool.d.ts.map +0 -1
  1624. package/dist/tools/local-search-nodes-tool.js +0 -111
  1625. package/dist/tools/local-search-nodes-tool.js.map +0 -1
  1626. package/dist/tools/math-tools.d.ts +0 -156
  1627. package/dist/tools/math-tools.d.ts.map +0 -1
  1628. package/dist/tools/math-tools.js +0 -422
  1629. package/dist/tools/math-tools.js.map +0 -1
  1630. package/dist/tools/model-tools.d.ts +0 -25
  1631. package/dist/tools/model-tools.d.ts.map +0 -1
  1632. package/dist/tools/model-tools.js +0 -48
  1633. package/dist/tools/model-tools.js.map +0 -1
  1634. package/dist/tools/pdf-tools.d.ts +0 -152
  1635. package/dist/tools/pdf-tools.d.ts.map +0 -1
  1636. package/dist/tools/pdf-tools.js +0 -339
  1637. package/dist/tools/pdf-tools.js.map +0 -1
  1638. package/dist/tools/tool-registry.d.ts +0 -9
  1639. package/dist/tools/tool-registry.d.ts.map +0 -1
  1640. package/dist/tools/tool-registry.js +0 -17
  1641. package/dist/tools/tool-registry.js.map +0 -1
  1642. package/dist/tools/workspace-tools.d.ts +0 -58
  1643. package/dist/tools/workspace-tools.d.ts.map +0 -1
  1644. package/dist/tools/workspace-tools.js +0 -152
  1645. package/dist/tools/workspace-tools.js.map +0 -1
@@ -0,0 +1,2258 @@
1
+ /**
2
+ * The `media` capability module — provider-backed generation, plus the vision
3
+ * judges that grade what it produced.
4
+ *
5
+ * These capabilities replace the generation tools in `../tools/media-tools.ts`
6
+ * and the judging tools in `../tools/creative-critique-tools.ts`. Wire names,
7
+ * descriptions and schemas are unchanged; `getAllMcpTools` builds them through
8
+ * `toolFromCapability`.
9
+ *
10
+ * Every generation capability is a thin wrapper around
11
+ * `ProcessingContext.runProviderPrediction` (or `streamProviderPrediction`
12
+ * where the capability requires it), so it dispatches to whichever
13
+ * `BaseProvider` the id names and needs nothing on the run beyond its context.
14
+ *
15
+ * Outputs are saved as assets when the context exposes a `createAsset` model
16
+ * interface, and fall back to the caller-supplied `output_file` under the
17
+ * workspace when it does not.
18
+ *
19
+ * Design: docs/tool-class-retirement-design.md § Migration.
20
+ */
21
+ import { Buffer } from "node:buffer";
22
+ import { randomInt, randomUUID } from "node:crypto";
23
+ import { mkdir, readFile } from "node:fs/promises";
24
+ import path from "node:path";
25
+ import { currentGenerationReceipt, loadMediaRefBytes } from "@nodetool-ai/runtime";
26
+ import { getMaxLocalUploadBytes } from "@nodetool-ai/storage";
27
+ import { backgroundGenerationLimitError, startBackgroundGeneration } from "./background-generation.js";
28
+ import { HostBinaryMissingError, clampTimeoutSeconds, mimeFromFilename, runHostBinary } from "../host-binaries.js";
29
+ import { MAX_DOWNLOAD_BYTES, buildYtDlpArgv, confineArgvToWorkspace, hardenFfmpegArgv, refuseFlagLikeValue } from "../host-binary-guard.js";
30
+ import { assertFetchUrlAllowed, assertResolvedHostAllowed } from "../network-guard.js";
31
+ import { encodeBase64 as encodeMediaBase64 } from "../sandbox-bytes.js";
32
+ import { imagePixelSize, sniffImageFormat } from "../sandbox-media.js";
33
+ import { DEFAULT_MIME, MAX_MEDIA_REF_BYTES, filesystemPathForUri, mimeForRef } from "../sandbox-media-ref.js";
34
+ import { MIME_TO_EXT, inferImageMime, persistOutput, timestampedName } from "../tools/asset-persist.js";
35
+ import { persistBinaryOutput } from "../tools/binary-output.js";
36
+ import { extractJSON, extractJSONAllowingTruncation } from "../utils/json-parser.js";
37
+ import { isYtDlpEnabled } from "../yt-dlp-gate.js";
38
+ import { isFunction, isNonBlankString, isNonEmptyString, isObjectLike, isRecord, isString } from "../utils/type-guards.js";
39
+ import { generateTextSpec, generateImageSpec, editImageSpec, segmentImageSpec, generateVideoSpec, animateImageSpec, videoFromReferencesSpec, generateSpeechSpec, generateMusicSpec, transcribeAudioSpec, embedTextSpec, readMediaBytesSpec, critiqueImageSpec, compareImagesSpec, scoreImageAdherenceSpec, understandVideoSpec, ffmpegSpec, ffprobeSpec, ytDlpSpec, DEFAULT_UNDERSTAND_VIDEO_TOKENS, DEFAULT_VIDEO_PROMPT, MAX_COMPARE_IMAGES, MAX_UNDERSTAND_VIDEO_TOKENS } from "./media.specs.js";
40
+ const MAX_INLINE_TEXT_PREVIEW = 500;
41
+ const MAX_ADHERENCE_QUESTIONS = 12;
42
+ const JUDGE_MAX_TOKENS = 1500;
43
+ const generateText = {
44
+ spec: generateTextSpec,
45
+ impl: async (run, params) => {
46
+ const m = parseModelArgs(params);
47
+ if ("error" in m)
48
+ return m;
49
+ const prompt = params["prompt"];
50
+ if (!isNonEmptyString(prompt))
51
+ return { error: "prompt is required" };
52
+ const imageValues = params["images"];
53
+ if (imageValues !== undefined && !Array.isArray(imageValues)) {
54
+ return { error: "images must be an array of strings" };
55
+ }
56
+ const images = (imageValues ?? []).filter(isNonEmptyString);
57
+ if (images.length !== (imageValues ?? []).length) {
58
+ return { error: "images must contain only non-empty strings" };
59
+ }
60
+ const content = [
61
+ ...images.map(imagePart),
62
+ textPart(prompt)
63
+ ];
64
+ const messages = [];
65
+ const system = params["system"];
66
+ if (isNonEmptyString(system)) {
67
+ messages.push({ role: "system", content: system });
68
+ }
69
+ messages.push({ role: "user", content });
70
+ const maxTokens = Math.max(1, Math.min(16384, Number(params["max_tokens"]) || 2048));
71
+ try {
72
+ const result = (await run.context.runProviderPrediction({
73
+ provider: m.provider,
74
+ capability: "generate_message",
75
+ model: m.model,
76
+ params: {
77
+ messages,
78
+ max_tokens: maxTokens,
79
+ temperature: typeof params["temperature"] === "number"
80
+ ? params["temperature"]
81
+ : 0
82
+ }
83
+ }));
84
+ return {
85
+ type: "text",
86
+ provider: m.provider,
87
+ model: m.model,
88
+ text: messageText(result)
89
+ };
90
+ }
91
+ catch (error) {
92
+ return predictionError("generate_message", m, error);
93
+ }
94
+ }
95
+ };
96
+ function readModelId(value) {
97
+ return isNonEmptyString(value) ? value : undefined;
98
+ }
99
+ /**
100
+ * Read a provider+model from the shapes find_model actually returns: a hit
101
+ * (`provider` + `model_id` + `ref`), its `.ref` (`provider` + `id`), or the
102
+ * documented `{provider, model}` pair. Nested `model` objects win over the
103
+ * top-level pair so `generate_video({prompt, model: hit.ref})` works.
104
+ */
105
+ function modelFromRecord(value) {
106
+ if (!isRecord(value))
107
+ return null;
108
+ if (isRecord(value.ref)) {
109
+ const fromRef = modelFromRecord(value.ref);
110
+ if (fromRef !== null)
111
+ return fromRef;
112
+ }
113
+ const provider = readModelId(value.provider);
114
+ const id = readModelId(value.model_id) ??
115
+ (isNonEmptyString(value.model) ? value.model : undefined) ??
116
+ readModelId(value.id);
117
+ if (provider !== undefined && id !== undefined) {
118
+ return { provider, model: id };
119
+ }
120
+ return null;
121
+ }
122
+ /**
123
+ * A provider rejection, with the model that was called in it.
124
+ *
125
+ * "text_to_video failed: Unprocessable Entity" told a live session nothing:
126
+ * the model it had picked was an image-to-video endpoint, and the message
127
+ * named neither the model nor the way out. `find_model` now filters by
128
+ * direction, and when a provider still refuses, the error says which model to
129
+ * re-pick.
130
+ */
131
+ function predictionError(capability, m, e) {
132
+ const detail = e instanceof Error ? e.message : String(e);
133
+ return {
134
+ error: `${capability} failed for ${m.provider}:${m.model} — ${detail}. ` +
135
+ `If the model does not do ${capability}, pick another with ` +
136
+ `find_model({capability: "${capability}"}).`
137
+ };
138
+ }
139
+ function parseModelArgs(params) {
140
+ const fromModel = modelFromRecord(params.model);
141
+ if (fromModel !== null)
142
+ return fromModel;
143
+ if (isRecord(params.model) && isNonEmptyString(params.provider)) {
144
+ const nested = params.model;
145
+ const id = readModelId(nested.model_id) ??
146
+ readModelId(nested.id) ??
147
+ (isNonEmptyString(nested.model) ? nested.model : undefined);
148
+ if (id !== undefined) {
149
+ return { provider: params.provider, model: id };
150
+ }
151
+ }
152
+ const fromParams = modelFromRecord(params);
153
+ if (fromParams !== null)
154
+ return fromParams;
155
+ if (isNonEmptyString(params.model) && params.model.includes("/")) {
156
+ const slash = params.model.indexOf("/");
157
+ return {
158
+ provider: params.model.slice(0, slash),
159
+ model: params.model.slice(slash + 1)
160
+ };
161
+ }
162
+ if (!isNonEmptyString(params.provider)) {
163
+ return { error: "provider must be a non-empty string (use find_model)" };
164
+ }
165
+ if (!isNonEmptyString(params.model)) {
166
+ return { error: "model must be a non-empty string (use find_model)" };
167
+ }
168
+ return { provider: params.provider, model: params.model };
169
+ }
170
+ async function readWorkspaceOrAssetFile(context, inputFile) {
171
+ // asset:// URIs are the primary handle the generate_* capabilities return (an
172
+ // asset is created with no workspace copy), and the docs advertise asset://
173
+ // sources. Route them through the asset resolver — the workspace treats them
174
+ // as literal keys (asset://id.png → key "asset:/id.png") and fails.
175
+ if (inputFile.startsWith("asset://")) {
176
+ const { bytes } = await context.resolveAssetBytes(inputFile);
177
+ if (!bytes) {
178
+ throw new Error(`Asset not found: ${inputFile}`);
179
+ }
180
+ return bytes;
181
+ }
182
+ // Read through the workspace so a cloud deployment behaves like a local one.
183
+ if (!context.workspace) {
184
+ throw new Error("No workspace configured — cannot read input file.");
185
+ }
186
+ const bytes = await context.workspace.read(inputFile);
187
+ if (!bytes) {
188
+ throw new Error(`Input file not found in workspace: ${inputFile}`);
189
+ }
190
+ return bytes;
191
+ }
192
+ /**
193
+ * A generation that produced no handle is a failure, not a success.
194
+ *
195
+ * A run whose bytes never became an asset (no asset interface, `createAsset`
196
+ * threw, no workspace to fall back to) used to return `{type, provider, model,
197
+ * bytes, mime_type}` — success-shaped, with `asset_uri` undefined, which an
198
+ * agent printed as "OK undefined" and carried on from. Report what was missing
199
+ * instead.
200
+ */
201
+ function outputError(capability, m, missing) {
202
+ return {
203
+ error: `${capability} for ${m.provider}:${m.model} returned no usable output — ${missing}.`
204
+ };
205
+ }
206
+ /** The provider's bytes, or null when it produced none. */
207
+ function generatedBytes(result) {
208
+ return result instanceof Uint8Array && result.length > 0 ? result : null;
209
+ }
210
+ /** Whether a persisted output carries a handle the caller can read back. */
211
+ function hasOutputHandle(persisted) {
212
+ return (isNonEmptyString(persisted.asset_uri) || isNonEmptyString(persisted.path));
213
+ }
214
+ // ---------------------------------------------------------------------------
215
+ // The generation seam, as the capabilities use it
216
+ // ---------------------------------------------------------------------------
217
+ function toolCallIdOf(params) {
218
+ const id = params["_tool_call_id"];
219
+ return isNonEmptyString(id) ? id : null;
220
+ }
221
+ function outputFileOf(params) {
222
+ return isString(params["output_file"]) ? params["output_file"] : undefined;
223
+ }
224
+ /** The request every media capability hands `runGeneration`. */
225
+ function generationRequest(id, params, spec) {
226
+ const outputFile = outputFileOf(params);
227
+ const persist = {};
228
+ if (outputFile)
229
+ persist.name = path.basename(outputFile);
230
+ if (spec.mime)
231
+ persist.mime = spec.mime;
232
+ return {
233
+ id,
234
+ provider: spec.m.provider,
235
+ capability: spec.capability,
236
+ model: spec.m.model,
237
+ params: spec.params,
238
+ origin: { surface: "capability", tool_call_id: toolCallIdOf(params) },
239
+ persist
240
+ };
241
+ }
242
+ /**
243
+ * Write the bytes where the caller can read them back: the asset the seam
244
+ * saved when it could, plus a workspace copy when `output_file` was named or
245
+ * no asset exists. `persistOutput` handles the no-asset case as before.
246
+ */
247
+ async function finishOutput(context, bytes, assets, opts) {
248
+ const first = assets[0];
249
+ if (!first || !isNonEmptyString(first.asset_id)) {
250
+ return persistOutput(context, bytes, opts);
251
+ }
252
+ const result = {
253
+ bytes: bytes.length,
254
+ mime_type: opts.mime,
255
+ asset_id: first.asset_id,
256
+ asset_uri: first.uri,
257
+ url: first.uri
258
+ };
259
+ if (opts.outputFile && context.workspace) {
260
+ try {
261
+ await context.workspace.write(opts.outputFile, bytes, opts.mime);
262
+ result.path = opts.outputFile;
263
+ }
264
+ catch {
265
+ // Non-fatal — the asset is the handle.
266
+ }
267
+ }
268
+ return result;
269
+ }
270
+ /** What a `background: true` call answers with. */
271
+ function backgroundReceipt(id, spec) {
272
+ return {
273
+ type: spec.type,
274
+ generation_id: id,
275
+ status: "running",
276
+ background: true,
277
+ provider: spec.m.provider,
278
+ model: spec.m.model,
279
+ capability: spec.capability,
280
+ next: "Call await_generation with this generation_id to collect the asset, or get_generation to check on it."
281
+ };
282
+ }
283
+ /**
284
+ * Start a generation without waiting for it. The seam records the row and
285
+ * saves the asset whether or not anyone awaits; the count is bounded so a
286
+ * loop cannot open an unbounded number of paid calls.
287
+ */
288
+ function startMediaBackgroundGeneration(context, req, spec, params) {
289
+ const outputFile = outputFileOf(params);
290
+ const started = startBackgroundGeneration(context, async () => {
291
+ const result = await context.runGeneration(req);
292
+ const bytes = generatedBytes(result.output);
293
+ if (bytes && outputFile && context.workspace) {
294
+ await context.workspace.write(outputFile, bytes, spec.mime ?? inferImageMime(bytes));
295
+ }
296
+ });
297
+ if (!started) {
298
+ return backgroundGenerationLimitError();
299
+ }
300
+ return backgroundReceipt(req.id ?? "", spec);
301
+ }
302
+ /**
303
+ * Run one media generation through the seam and answer with the handle:
304
+ * the asset (and workspace path) plus the `generation_id` the `generations`
305
+ * capabilities take.
306
+ */
307
+ async function runMediaGeneration(run, params, spec) {
308
+ const context = run.context;
309
+ const id = randomUUID();
310
+ const req = generationRequest(id, params, spec);
311
+ if (params["background"] === true) {
312
+ return startMediaBackgroundGeneration(context, req, spec, params);
313
+ }
314
+ try {
315
+ const result = await context.runGeneration(req);
316
+ const bytes = generatedBytes(result.output);
317
+ if (!bytes) {
318
+ return {
319
+ ...outputError(spec.capability, spec.m, `the provider returned no ${spec.type} data`),
320
+ generation_id: id
321
+ };
322
+ }
323
+ const persisted = await finishOutput(context, bytes, result.assets, {
324
+ namePrefix: spec.namePrefix,
325
+ mime: spec.mime ?? inferImageMime(bytes),
326
+ outputFile: outputFileOf(params)
327
+ });
328
+ if (!hasOutputHandle(persisted)) {
329
+ return {
330
+ ...outputError(spec.capability, spec.m, `the ${persisted.bytes}-byte result could not be stored (no asset was created and no workspace file was written)`),
331
+ generation_id: id
332
+ };
333
+ }
334
+ return {
335
+ type: spec.type,
336
+ provider: spec.m.provider,
337
+ model: spec.m.model,
338
+ generation_id: id,
339
+ ...persisted
340
+ };
341
+ }
342
+ catch (e) {
343
+ return {
344
+ ...predictionError(spec.capability, spec.m, e),
345
+ generation_id: id
346
+ };
347
+ }
348
+ }
349
+ const generateImage = {
350
+ spec: generateImageSpec,
351
+ impl: async (run, params) => {
352
+ const m = parseModelArgs(params);
353
+ if ("error" in m)
354
+ return m;
355
+ const prompt = params["prompt"];
356
+ if (!isNonEmptyString(prompt))
357
+ return { error: "prompt is required" };
358
+ return runMediaGeneration(run, params, {
359
+ capability: "text_to_image",
360
+ m,
361
+ type: "image",
362
+ namePrefix: "generated-image",
363
+ params: {
364
+ prompt,
365
+ negative_prompt: params["negative_prompt"],
366
+ width: params["width"],
367
+ height: params["height"],
368
+ quality: params["quality"]
369
+ }
370
+ });
371
+ }
372
+ };
373
+ const editImage = {
374
+ spec: editImageSpec,
375
+ impl: async (run, params) => {
376
+ const context = run.context;
377
+ const m = parseModelArgs(params);
378
+ if ("error" in m)
379
+ return m;
380
+ const inputFile = params["input_file"];
381
+ const prompt = params["prompt"];
382
+ if (!isNonEmptyString(inputFile))
383
+ return { error: "input_file is required" };
384
+ if (!isNonEmptyString(prompt))
385
+ return { error: "prompt is required" };
386
+ const referenceFiles = params["reference_files"];
387
+ if (referenceFiles !== undefined && !Array.isArray(referenceFiles))
388
+ return { error: "reference_files must be an array of strings" };
389
+ const references = (referenceFiles ?? []).filter(isNonEmptyString);
390
+ let images;
391
+ try {
392
+ images = await Promise.all([inputFile, ...references].map((file) => readWorkspaceOrAssetFile(context, file)));
393
+ }
394
+ catch (e) {
395
+ return predictionError("image_to_image", m, e);
396
+ }
397
+ return runMediaGeneration(run, params, {
398
+ capability: "image_to_image",
399
+ m,
400
+ type: "image",
401
+ namePrefix: "edited-image",
402
+ params: {
403
+ // `coerceImageList` reads the list; the source image stays first so a
404
+ // provider that treats one input as the canvas and the rest as style
405
+ // references gets them in that order.
406
+ images,
407
+ prompt,
408
+ negative_prompt: params["negative_prompt"],
409
+ target_width: params["target_width"],
410
+ target_height: params["target_height"],
411
+ strength: params["strength"]
412
+ }
413
+ });
414
+ }
415
+ };
416
+ /** Coerce one `points` entry from the model's arguments. */
417
+ function parseSegmentPoint(value) {
418
+ if (!isRecord(value))
419
+ return null;
420
+ const x = value["x"];
421
+ const y = value["y"];
422
+ if (typeof x !== "number" || typeof y !== "number")
423
+ return null;
424
+ return { x, y, include: value["include"] !== false };
425
+ }
426
+ function parseSegmentBox(value) {
427
+ if (!isRecord(value))
428
+ return null;
429
+ const { x, y, width, height } = value;
430
+ if (typeof x !== "number" ||
431
+ typeof y !== "number" ||
432
+ typeof width !== "number" ||
433
+ typeof height !== "number") {
434
+ return null;
435
+ }
436
+ return { x, y, width, height };
437
+ }
438
+ const segmentImage = {
439
+ spec: segmentImageSpec,
440
+ impl: async (run, params) => {
441
+ const context = run.context;
442
+ const m = parseModelArgs(params);
443
+ if ("error" in m)
444
+ return m;
445
+ const inputFile = params["input_file"];
446
+ if (!isNonEmptyString(inputFile))
447
+ return { error: "input_file is required" };
448
+ const rawPoints = params["points"];
449
+ const points = Array.isArray(rawPoints)
450
+ ? rawPoints
451
+ .map(parseSegmentPoint)
452
+ .filter((p) => p !== null)
453
+ : [];
454
+ try {
455
+ const image = await readWorkspaceOrAssetFile(context, inputFile);
456
+ const masks = (await context.runProviderPrediction({
457
+ provider: m.provider,
458
+ capability: "segment_image",
459
+ model: m.model,
460
+ params: {
461
+ image,
462
+ prompt: params["prompt"],
463
+ points: points.length > 0 ? points : undefined,
464
+ box: parseSegmentBox(params["box"]) ?? undefined,
465
+ max_masks: params["max_masks"],
466
+ min_confidence: params["min_confidence"]
467
+ }
468
+ }));
469
+ const saved = [];
470
+ for (const [index, found] of masks.entries()) {
471
+ const persisted = await persistOutput(context, found.mask, {
472
+ namePrefix: `segment-mask-${index + 1}`,
473
+ mime: found.mimeType || inferImageMime(found.mask)
474
+ });
475
+ saved.push({
476
+ label: found.label ?? null,
477
+ confidence: found.confidence ?? null,
478
+ box: found.box ?? null,
479
+ width: found.width ?? null,
480
+ height: found.height ?? null,
481
+ ...persisted
482
+ });
483
+ }
484
+ return {
485
+ type: "segmentation",
486
+ provider: m.provider,
487
+ model: m.model,
488
+ // An empty list is the model's answer, not a failure — say so, because
489
+ // a bare `[]` reads as a broken call.
490
+ found: saved.length,
491
+ masks: saved
492
+ };
493
+ }
494
+ catch (e) {
495
+ return predictionError("segment_image", m, e);
496
+ }
497
+ }
498
+ };
499
+ /**
500
+ * Read a generation parameter under any of the spellings a caller reaches for.
501
+ *
502
+ * The schemas are snake_case, the JS guest API takes an options bag, and the
503
+ * `TextToVideo` node's own property is `duration` — so a build asked for a
504
+ * 15-second clip with `{duration: 15}`, was billed for the model's 5-second
505
+ * default, and had nothing in the result saying the argument had been dropped.
506
+ * A silently ignored parameter on a call that spends money is the expensive
507
+ * kind of typo, and every one of these spellings means one thing.
508
+ */
509
+ function aliased(params, canonical, ...aliases) {
510
+ for (const key of [canonical, ...aliases]) {
511
+ const value = params[key];
512
+ if (value !== undefined && value !== null)
513
+ return value;
514
+ }
515
+ return undefined;
516
+ }
517
+ /** The generation parameters every video capability forwards, de-aliased. */
518
+ function videoShapeParams(params) {
519
+ return {
520
+ num_frames: aliased(params, "num_frames", "numFrames", "frames"),
521
+ duration_seconds: aliased(params, "duration_seconds", "durationSeconds", "duration"),
522
+ aspect_ratio: aliased(params, "aspect_ratio", "aspectRatio", "aspect"),
523
+ resolution: aliased(params, "resolution")
524
+ };
525
+ }
526
+ /** The aspect ratios the video providers name, as width/height. */
527
+ const ASPECT_RATIOS = [
528
+ ["21:9", 21 / 9],
529
+ ["16:9", 16 / 9],
530
+ ["4:3", 4 / 3],
531
+ ["1:1", 1],
532
+ ["3:4", 3 / 4],
533
+ ["9:16", 9 / 16]
534
+ ];
535
+ /** The listed ratio closest to `width/height`, or null for a bad size. */
536
+ export function nearestAspectRatio(width, height) {
537
+ if (!Number.isFinite(width) || !Number.isFinite(height))
538
+ return null;
539
+ if (width <= 0 || height <= 0)
540
+ return null;
541
+ const target = width / height;
542
+ let best = ASPECT_RATIOS[0];
543
+ for (const candidate of ASPECT_RATIOS) {
544
+ if (Math.abs(candidate[1] - target) < Math.abs(best[1] - target)) {
545
+ best = candidate;
546
+ }
547
+ }
548
+ return best[0];
549
+ }
550
+ const generateVideo = {
551
+ spec: generateVideoSpec,
552
+ impl: async (run, params) => {
553
+ const m = parseModelArgs(params);
554
+ if ("error" in m)
555
+ return m;
556
+ const prompt = params["prompt"];
557
+ if (!isNonEmptyString(prompt))
558
+ return { error: "prompt is required" };
559
+ return runMediaGeneration(run, params, {
560
+ capability: "text_to_video",
561
+ m,
562
+ type: "video",
563
+ namePrefix: "generated-video",
564
+ mime: "video/mp4",
565
+ params: {
566
+ prompt,
567
+ negative_prompt: aliased(params, "negative_prompt", "negativePrompt"),
568
+ ...videoShapeParams(params)
569
+ }
570
+ });
571
+ }
572
+ };
573
+ const animateImage = {
574
+ spec: animateImageSpec,
575
+ impl: async (run, params) => {
576
+ const context = run.context;
577
+ const m = parseModelArgs(params);
578
+ if ("error" in m)
579
+ return m;
580
+ const inputFile = params["input_file"];
581
+ if (!isNonEmptyString(inputFile))
582
+ return { error: "input_file is required" };
583
+ let image;
584
+ try {
585
+ image = await readWorkspaceOrAssetFile(context, inputFile);
586
+ }
587
+ catch (e) {
588
+ return predictionError("image_to_video", m, e);
589
+ }
590
+ const shape = videoShapeParams(params);
591
+ // A vertical still animated at the provider's default aspect comes back
592
+ // 16:9, cropped or padded, and the caller finds out when the ad is cut:
593
+ // three 1280x720 beds under a 1080x1920 sequence. The source image is the
594
+ // best statement of intent available, so it sets the ratio when the call
595
+ // does not.
596
+ if (shape.aspect_ratio === undefined) {
597
+ const size = imagePixelSize(image);
598
+ const derived = size ? nearestAspectRatio(size.width, size.height) : null;
599
+ if (derived)
600
+ shape.aspect_ratio = derived;
601
+ }
602
+ return runMediaGeneration(run, params, {
603
+ capability: "image_to_video",
604
+ m,
605
+ type: "video",
606
+ namePrefix: "animated-video",
607
+ mime: "video/mp4",
608
+ params: { image, prompt: params["prompt"], ...shape }
609
+ });
610
+ }
611
+ };
612
+ /** Extensions that state a reference's kind without reading its bytes. */
613
+ const IMAGE_EXTENSIONS = new Set([
614
+ "png",
615
+ "jpg",
616
+ "jpeg",
617
+ "gif",
618
+ "bmp",
619
+ "webp",
620
+ "avif",
621
+ "heic",
622
+ "heif",
623
+ "tif",
624
+ "tiff"
625
+ ]);
626
+ const VIDEO_EXTENSIONS = new Set([
627
+ "mp4",
628
+ "m4v",
629
+ "mov",
630
+ "webm",
631
+ "mkv",
632
+ "avi",
633
+ "mpeg",
634
+ "mpg",
635
+ "wmv"
636
+ ]);
637
+ /**
638
+ * Whether a reference is an image or a video. The provider takes the two in
639
+ * separate lists — a video handed over as an image is rejected with an opaque
640
+ * provider error — so the kind has to be settled here.
641
+ *
642
+ * The extension decides when it says anything, because it is what the caller
643
+ * stated. Otherwise the bytes do: the image sniffer first (it owns the
644
+ * `ftyp`-based AVIF/HEIC cases), then the three video containers. A reference
645
+ * neither names nor looks like either is null, and the call refuses it rather
646
+ * than guessing.
647
+ */
648
+ export function classifyReferenceMedia(file, bytes) {
649
+ const dot = file.lastIndexOf(".");
650
+ const ext = dot > -1 ? file.slice(dot + 1).toLowerCase() : "";
651
+ if (IMAGE_EXTENSIONS.has(ext))
652
+ return "image";
653
+ if (VIDEO_EXTENSIONS.has(ext))
654
+ return "video";
655
+ if (sniffImageFormat(bytes) !== "unknown")
656
+ return "image";
657
+ const at = (i) => bytes[i] ?? -1;
658
+ const tag = (offset, text) => [...text].every((ch, i) => at(offset + i) === ch.charCodeAt(0));
659
+ if (tag(4, "ftyp"))
660
+ return "video";
661
+ // Matroska / WebM EBML header.
662
+ if (at(0) === 0x1a && at(1) === 0x45 && at(2) === 0xdf && at(3) === 0xa3) {
663
+ return "video";
664
+ }
665
+ if (tag(0, "RIFF") && tag(8, "AVI "))
666
+ return "video";
667
+ return null;
668
+ }
669
+ const videoFromReferences = {
670
+ spec: videoFromReferencesSpec,
671
+ impl: async (run, params) => {
672
+ const context = run.context;
673
+ const m = parseModelArgs(params);
674
+ if ("error" in m)
675
+ return m;
676
+ const referenceFiles = params["reference_files"];
677
+ if (!Array.isArray(referenceFiles)) {
678
+ return { error: "reference_files must be an array of strings" };
679
+ }
680
+ const files = referenceFiles.filter(isNonEmptyString);
681
+ if (files.length === 0) {
682
+ return { error: "reference_files must name at least one reference" };
683
+ }
684
+ const images = [];
685
+ const videos = [];
686
+ for (const file of files) {
687
+ let bytes;
688
+ try {
689
+ bytes = await readWorkspaceOrAssetFile(context, file);
690
+ }
691
+ catch (e) {
692
+ return predictionError("reference_to_video", m, e);
693
+ }
694
+ const kind = classifyReferenceMedia(file, bytes);
695
+ if (kind === null) {
696
+ return {
697
+ error: `${file} is neither an image nor a video — reference_to_video takes only those`
698
+ };
699
+ }
700
+ (kind === "image" ? images : videos).push(bytes);
701
+ }
702
+ const useReferenceVideoAudio = aliased(params, "use_reference_video_audio", "useReferenceVideoAudio");
703
+ if (useReferenceVideoAudio === true && videos.length === 0) {
704
+ return {
705
+ error: "use_reference_video_audio needs a reference video to take the audio from"
706
+ };
707
+ }
708
+ const shape = videoShapeParams(params);
709
+ // Same reasoning as animate_image: a vertical reference rendered at the
710
+ // provider's default lands 16:9 and the crop is found at the cut. The
711
+ // first image reference states the intended shape when the call does not.
712
+ if (shape.aspect_ratio === undefined && images.length > 0) {
713
+ const size = imagePixelSize(images[0]);
714
+ const derived = size ? nearestAspectRatio(size.width, size.height) : null;
715
+ if (derived)
716
+ shape.aspect_ratio = derived;
717
+ }
718
+ return runMediaGeneration(run, params, {
719
+ capability: "reference_to_video",
720
+ m,
721
+ type: "video",
722
+ namePrefix: "reference-video",
723
+ mime: "video/mp4",
724
+ params: {
725
+ reference_images: images,
726
+ reference_videos: videos,
727
+ prompt: params["prompt"],
728
+ negative_prompt: aliased(params, "negative_prompt", "negativePrompt"),
729
+ use_reference_video_audio: useReferenceVideoAudio,
730
+ ...shape
731
+ }
732
+ });
733
+ }
734
+ };
735
+ // ---------------------------------------------------------------------------
736
+ // generate_speech
737
+ // ---------------------------------------------------------------------------
738
+ function int16ToUint8(samples) {
739
+ const bytes = new Uint8Array(samples.byteLength);
740
+ const view = new DataView(bytes.buffer);
741
+ for (let i = 0; i < samples.length; i++) {
742
+ view.setInt16(i * 2, samples[i], true);
743
+ }
744
+ return bytes;
745
+ }
746
+ /**
747
+ * Wrap raw little-endian int16 PCM bytes in a minimal RIFF/WAVE container so
748
+ * the file is playable. Defaults match OpenAI's TTS PCM stream (24 kHz mono).
749
+ */
750
+ function wrapPcmAsWav(pcm, sampleRate = 24000, channels = 1) {
751
+ const bitsPerSample = 16;
752
+ const byteRate = (sampleRate * channels * bitsPerSample) / 8;
753
+ const blockAlign = (channels * bitsPerSample) / 8;
754
+ const header = new Uint8Array(44);
755
+ const v = new DataView(header.buffer);
756
+ const w = (s, off) => {
757
+ for (let i = 0; i < s.length; i++)
758
+ v.setUint8(off + i, s.charCodeAt(i));
759
+ };
760
+ w("RIFF", 0);
761
+ v.setUint32(4, 36 + pcm.length, true);
762
+ w("WAVE", 8);
763
+ w("fmt ", 12);
764
+ v.setUint32(16, 16, true); // PCM chunk size
765
+ v.setUint16(20, 1, true); // PCM format
766
+ v.setUint16(22, channels, true);
767
+ v.setUint32(24, sampleRate, true);
768
+ v.setUint32(28, byteRate, true);
769
+ v.setUint16(32, blockAlign, true);
770
+ v.setUint16(34, bitsPerSample, true);
771
+ w("data", 36);
772
+ v.setUint32(40, pcm.length, true);
773
+ const out = new Uint8Array(header.length + pcm.length);
774
+ out.set(header, 0);
775
+ out.set(pcm, header.length);
776
+ return out;
777
+ }
778
+ const AUDIO_EXT_TO_FORMAT = {
779
+ mp3: "mp3",
780
+ wav: "wav",
781
+ flac: "flac",
782
+ opus: "opus",
783
+ ogg: "opus",
784
+ aac: "aac",
785
+ m4a: "aac"
786
+ };
787
+ function audioFormatFromOutputFile(outputFile) {
788
+ if (!outputFile)
789
+ return null;
790
+ const ext = path.extname(outputFile).slice(1).toLowerCase();
791
+ return AUDIO_EXT_TO_FORMAT[ext] ?? null;
792
+ }
793
+ function concatUint8(parts) {
794
+ let total = 0;
795
+ for (const p of parts)
796
+ total += p.length;
797
+ const out = new Uint8Array(total);
798
+ let offset = 0;
799
+ for (const p of parts) {
800
+ out.set(p, offset);
801
+ offset += p.length;
802
+ }
803
+ return out;
804
+ }
805
+ /**
806
+ * Ask for fully-encoded speech through whichever seam this context has.
807
+ *
808
+ * `context.textToSpeechEncoded` is the one `nodetool.audio.TextToSpeech` uses,
809
+ * and the one that emits the prediction events a run is billed and traced by,
810
+ * so it is tried first. Reaching past it to `getProvider` was the only path
811
+ * before, and it cost every FAL and KIE voice on a context that carries the
812
+ * prediction seams but not `getProvider`: the TypeError landed in the caller's
813
+ * catch, and the streaming fallback then reported "fal_ai does not support
814
+ * textToSpeech" — of a provider whose entire TTS catalog is encoded.
815
+ */
816
+ async function encodedSpeech(context, m, params, generation) {
817
+ if (isFunction(context.textToSpeechEncoded)) {
818
+ return await context.textToSpeechEncoded({
819
+ ...generation,
820
+ provider: m.provider,
821
+ capability: "text_to_speech",
822
+ model: m.model,
823
+ params: {
824
+ text: params.text,
825
+ voice: params.voice,
826
+ speed: params.speed,
827
+ audioFormat: params.audioFormat
828
+ }
829
+ });
830
+ }
831
+ if (isFunction(context.getProvider)) {
832
+ const provider = await context.getProvider(m.provider);
833
+ return await provider.textToSpeechEncoded({
834
+ text: params.text,
835
+ model: m.model,
836
+ voice: isString(params.voice) ? params.voice : undefined,
837
+ speed: typeof params.speed === "number" ? params.speed : undefined,
838
+ audioFormat: params.audioFormat
839
+ });
840
+ }
841
+ throw new Error("this runtime's context has no encoded text_to_speech path");
842
+ }
843
+ async function speechAudio(context, provider, m, params, signal, outputFile) {
844
+ signal.throwIfAborted();
845
+ const providerParams = {
846
+ text: params.text,
847
+ model: m.model,
848
+ voice: isString(params.voice) ? params.voice : undefined,
849
+ speed: typeof params.speed === "number" ? params.speed : undefined,
850
+ audioFormat: params.audioFormat,
851
+ signal
852
+ };
853
+ let encodedError;
854
+ try {
855
+ const encoded = provider
856
+ ? await provider.textToSpeechEncoded(providerParams)
857
+ : await encodedSpeech(context, m, params);
858
+ signal.throwIfAborted();
859
+ if (encoded?.data && encoded.data.length > 0) {
860
+ return {
861
+ data: encoded.data,
862
+ mimeType: encoded.mimeType ?? "audio/mpeg",
863
+ outputFile
864
+ };
865
+ }
866
+ }
867
+ catch (error) {
868
+ if (signal.aborted || currentGenerationReceipt()?.provider_request_id) {
869
+ throw error;
870
+ }
871
+ encodedError = error;
872
+ }
873
+ if (currentGenerationReceipt()?.provider_request_id) {
874
+ throw new Error("The accepted speech request returned no audio; recover that request before submitting another.");
875
+ }
876
+ const parts = [];
877
+ let pcmOnly = true;
878
+ let mimeType;
879
+ let sampleRate;
880
+ try {
881
+ const stream = provider
882
+ ? provider.textToSpeech(providerParams)
883
+ : context.streamProviderPrediction({
884
+ provider: m.provider,
885
+ capability: "text_to_speech",
886
+ model: m.model,
887
+ params: { ...providerParams, signal }
888
+ });
889
+ for await (const item of stream) {
890
+ signal.throwIfAborted();
891
+ if (!isRecord(item)) {
892
+ continue;
893
+ }
894
+ const chunk = item;
895
+ if (chunk.data instanceof Uint8Array || isString(chunk.data)) {
896
+ const data = chunk.data instanceof Uint8Array
897
+ ? chunk.data
898
+ : Buffer.from(chunk.data, "base64");
899
+ if (data.length > 0) {
900
+ parts.push(data);
901
+ }
902
+ if (isString(chunk.mimeType)) {
903
+ mimeType = chunk.mimeType;
904
+ }
905
+ pcmOnly = false;
906
+ }
907
+ else {
908
+ if (chunk.sampleRate !== undefined) {
909
+ if (typeof chunk.sampleRate !== "number" ||
910
+ !Number.isInteger(chunk.sampleRate) ||
911
+ chunk.sampleRate <= 0 ||
912
+ chunk.sampleRate > 0xffffffff / 2) {
913
+ throw new Error("TTS returned an invalid PCM sample rate");
914
+ }
915
+ if (sampleRate !== undefined && sampleRate !== chunk.sampleRate) {
916
+ throw new Error("TTS changed PCM sample rate during the stream");
917
+ }
918
+ sampleRate = chunk.sampleRate;
919
+ }
920
+ if (chunk.samples instanceof Int16Array && chunk.samples.length > 0) {
921
+ parts.push(int16ToUint8(chunk.samples));
922
+ }
923
+ }
924
+ }
925
+ }
926
+ catch (error) {
927
+ if (encodedError) {
928
+ throw new Error(`${encodedError instanceof Error ? encodedError.message : String(encodedError)} (the streaming fallback then failed too: ${error instanceof Error ? error.message : String(error)})`);
929
+ }
930
+ throw error;
931
+ }
932
+ signal.throwIfAborted();
933
+ const merged = concatUint8(parts);
934
+ if (merged.length === 0) {
935
+ throw new Error("Provider returned no audio data");
936
+ }
937
+ if (pcmOnly && !mimeType) {
938
+ if (merged.length < 2 || merged.length % 2 !== 0) {
939
+ throw new Error("TTS produced no complete audio samples");
940
+ }
941
+ const finalPath = outputFile
942
+ ? path.join(path.dirname(outputFile), `${path.basename(outputFile, path.extname(outputFile))}.wav`)
943
+ : undefined;
944
+ return {
945
+ data: wrapPcmAsWav(merged, sampleRate ?? 24000),
946
+ mimeType: "audio/wav",
947
+ outputFile: finalPath
948
+ };
949
+ }
950
+ return { data: merged, mimeType: mimeType ?? "audio/mpeg", outputFile };
951
+ }
952
+ function runAudioGeneration(context, req, spec, params, call) {
953
+ const work = async () => {
954
+ let saved;
955
+ const result = await context.runGenerationWith(req, async (provider, signal) => {
956
+ const audio = await call(provider, signal);
957
+ if (audio.outputFile && req.persist) {
958
+ req.persist.name = path.basename(audio.outputFile);
959
+ }
960
+ return audio;
961
+ }, {
962
+ finalizeOutput: async (output, assets) => {
963
+ if (!isRecord(output) ||
964
+ !(output.data instanceof Uint8Array) ||
965
+ !isString(output.mimeType)) {
966
+ throw new Error("Provider returned invalid audio output");
967
+ }
968
+ const mime = output.mimeType;
969
+ const first = assets[0];
970
+ saved = { bytes: output.data.length, mime_type: mime };
971
+ if (first?.asset_id) {
972
+ saved.asset_id = first.asset_id;
973
+ saved.asset_uri = first.uri;
974
+ saved.url = first.uri;
975
+ }
976
+ const outputFile = isString(output.outputFile)
977
+ ? output.outputFile
978
+ : undefined;
979
+ if (outputFile || !saved.asset_id) {
980
+ const destination = outputFile ??
981
+ timestampedName(spec.namePrefix, MIME_TO_EXT[mime] ?? "bin");
982
+ if (!context.workspace) {
983
+ return {
984
+ status: "failed",
985
+ path: destination,
986
+ error: `Could not deliver audio to "${destination}": no workspace is available.`
987
+ };
988
+ }
989
+ try {
990
+ await context.workspace.write(destination, output.data, mime);
991
+ }
992
+ catch (error) {
993
+ return {
994
+ status: "failed",
995
+ path: destination,
996
+ error: error instanceof Error ? error.message : String(error)
997
+ };
998
+ }
999
+ saved.path = destination;
1000
+ return { status: "completed", path: destination };
1001
+ }
1002
+ return { status: "completed" };
1003
+ }
1004
+ });
1005
+ const response = {
1006
+ type: "audio",
1007
+ provider: spec.m.provider,
1008
+ model: spec.m.model,
1009
+ generation_id: result.id,
1010
+ ...saved
1011
+ };
1012
+ if (result.delivery) {
1013
+ response.delivery = result.delivery;
1014
+ }
1015
+ return response;
1016
+ };
1017
+ if (params.background === true) {
1018
+ if (!startBackgroundGeneration(context, work)) {
1019
+ return backgroundGenerationLimitError();
1020
+ }
1021
+ return backgroundReceipt(req.id ?? "", spec);
1022
+ }
1023
+ return work().catch((error) => ({
1024
+ ...predictionError(spec.capability, spec.m, error),
1025
+ generation_id: req.id
1026
+ }));
1027
+ }
1028
+ const generateSpeech = {
1029
+ spec: generateSpeechSpec,
1030
+ impl: async (run, params) => {
1031
+ const m = parseModelArgs(params);
1032
+ if ("error" in m) {
1033
+ return m;
1034
+ }
1035
+ const text = params.text;
1036
+ if (!isNonEmptyString(text)) {
1037
+ return { error: "text is required" };
1038
+ }
1039
+ const outputFile = outputFileOf(params);
1040
+ const speechParams = {
1041
+ text,
1042
+ voice: params.voice,
1043
+ speed: params.speed,
1044
+ audioFormat: audioFormatFromOutputFile(outputFile) ?? "mp3"
1045
+ };
1046
+ const spec = {
1047
+ capability: "text_to_speech",
1048
+ m,
1049
+ type: "audio",
1050
+ namePrefix: "generated-speech",
1051
+ params: { ...speechParams }
1052
+ };
1053
+ const req = generationRequest(randomUUID(), params, spec);
1054
+ return runAudioGeneration(run.context, req, spec, params, (provider, signal) => speechAudio(run.context, provider, m, speechParams, signal, outputFile));
1055
+ }
1056
+ };
1057
+ const generateMusic = {
1058
+ spec: generateMusicSpec,
1059
+ impl: async (run, params) => {
1060
+ const m = parseModelArgs(params);
1061
+ if ("error" in m) {
1062
+ return m;
1063
+ }
1064
+ const prompt = params.prompt;
1065
+ if (!isNonEmptyString(prompt)) {
1066
+ return { error: "prompt is required" };
1067
+ }
1068
+ const outputFile = outputFileOf(params);
1069
+ const musicParams = {
1070
+ prompt,
1071
+ lyrics: params.lyrics,
1072
+ duration_seconds: aliased(params, "duration_seconds", "durationSeconds", "duration"),
1073
+ audioFormat: audioFormatFromOutputFile(outputFile) ?? "mp3"
1074
+ };
1075
+ const spec = {
1076
+ capability: "text_to_music",
1077
+ m,
1078
+ type: "audio",
1079
+ namePrefix: "generated-music",
1080
+ params: musicParams
1081
+ };
1082
+ const req = generationRequest(randomUUID(), params, spec);
1083
+ return runAudioGeneration(run.context, req, spec, params, async (provider, signal) => {
1084
+ signal.throwIfAborted();
1085
+ const encoded = provider
1086
+ ? await provider.textToMusic({
1087
+ prompt,
1088
+ model: { id: m.model, name: m.model, provider: m.provider },
1089
+ lyrics: isString(params.lyrics) ? params.lyrics : undefined,
1090
+ durationSeconds: typeof musicParams.duration_seconds === "number"
1091
+ ? musicParams.duration_seconds
1092
+ : undefined,
1093
+ audioFormat: musicParams.audioFormat,
1094
+ signal
1095
+ })
1096
+ : await run.context.textToMusic(req);
1097
+ signal.throwIfAborted();
1098
+ if (!encoded?.data || encoded.data.length === 0) {
1099
+ throw new Error("Provider returned no audio data");
1100
+ }
1101
+ return {
1102
+ data: encoded.data,
1103
+ mimeType: encoded.mimeType ?? "audio/mpeg",
1104
+ outputFile
1105
+ };
1106
+ });
1107
+ }
1108
+ };
1109
+ const transcribeAudio = {
1110
+ spec: transcribeAudioSpec,
1111
+ impl: async (run, params) => {
1112
+ const context = run.context;
1113
+ const m = parseModelArgs(params);
1114
+ if ("error" in m)
1115
+ return m;
1116
+ const inputFile = params["input_file"];
1117
+ if (!isNonEmptyString(inputFile))
1118
+ return { error: "input_file is required" };
1119
+ try {
1120
+ const audio = await readWorkspaceOrAssetFile(context, inputFile);
1121
+ const result = (await context.runProviderPrediction({
1122
+ provider: m.provider,
1123
+ capability: "automatic_speech_recognition",
1124
+ model: m.model,
1125
+ params: {
1126
+ audio,
1127
+ language: params["language"],
1128
+ prompt: params["prompt"]
1129
+ }
1130
+ }));
1131
+ const text = String(result.text ?? "");
1132
+ return {
1133
+ type: "transcription",
1134
+ provider: m.provider,
1135
+ model: m.model,
1136
+ text: text.length > MAX_INLINE_TEXT_PREVIEW
1137
+ ? text.slice(0, MAX_INLINE_TEXT_PREVIEW) +
1138
+ `… [${text.length - MAX_INLINE_TEXT_PREVIEW} chars truncated]`
1139
+ : text,
1140
+ full_length: text.length,
1141
+ chunks: Array.isArray(result.chunks) ? result.chunks.length : 0
1142
+ };
1143
+ }
1144
+ catch (e) {
1145
+ return {
1146
+ error: `transcribe failed: ${e instanceof Error ? e.message : String(e)}`
1147
+ };
1148
+ }
1149
+ }
1150
+ };
1151
+ const embedText = {
1152
+ spec: embedTextSpec,
1153
+ impl: async (run, params) => {
1154
+ const context = run.context;
1155
+ const m = parseModelArgs(params);
1156
+ if ("error" in m)
1157
+ return m;
1158
+ const text = params["text"];
1159
+ if (!isString(text) && !Array.isArray(text))
1160
+ return { error: "text must be a string or array of strings" };
1161
+ try {
1162
+ const result = (await context.runProviderPrediction({
1163
+ provider: m.provider,
1164
+ capability: "generate_embedding",
1165
+ model: m.model,
1166
+ params: {
1167
+ text,
1168
+ dimensions: params["dimensions"]
1169
+ }
1170
+ }));
1171
+ return {
1172
+ type: "embedding",
1173
+ provider: m.provider,
1174
+ model: m.model,
1175
+ count: result.length,
1176
+ dimensions: result[0]?.length ?? 0,
1177
+ embeddings: result
1178
+ };
1179
+ }
1180
+ catch (e) {
1181
+ return {
1182
+ error: `generate_embedding failed: ${e instanceof Error ? e.message : String(e)}`
1183
+ };
1184
+ }
1185
+ }
1186
+ };
1187
+ function parseJudgeModelArgs(params) {
1188
+ const provider = params["provider"];
1189
+ const model = params["model"];
1190
+ if (!isNonEmptyString(provider)) {
1191
+ return {
1192
+ error: "provider must be a non-empty string (use find_model with a vision-capable chat model)"
1193
+ };
1194
+ }
1195
+ if (!isNonEmptyString(model)) {
1196
+ return {
1197
+ error: "model must be a non-empty string (use find_model with a vision-capable chat model)"
1198
+ };
1199
+ }
1200
+ return { provider, model };
1201
+ }
1202
+ /** Normalize a media source so the context media resolver can inline it. */
1203
+ function normalizeMediaSource(source) {
1204
+ const trimmed = source.trim();
1205
+ if (trimmed.startsWith("data:") ||
1206
+ trimmed.startsWith("asset://") ||
1207
+ /^https?:\/\//i.test(trimmed)) {
1208
+ return trimmed;
1209
+ }
1210
+ // Bare asset ids (what list_images and generate_image return) become
1211
+ // asset:// URIs, which resolveMessageMediaUris inlines as data URIs.
1212
+ return `asset://${trimmed}`;
1213
+ }
1214
+ function imagePart(source) {
1215
+ return {
1216
+ type: "image_url",
1217
+ image: { type: "image", uri: normalizeMediaSource(source) }
1218
+ };
1219
+ }
1220
+ function videoPart(source) {
1221
+ return {
1222
+ type: "video",
1223
+ video: { type: "video", uri: normalizeMediaSource(source) }
1224
+ };
1225
+ }
1226
+ function textPart(text) {
1227
+ return { type: "text", text };
1228
+ }
1229
+ /** Pull the text out of a provider response message. */
1230
+ function messageText(message) {
1231
+ const content = message.content;
1232
+ if (isString(content))
1233
+ return content;
1234
+ if (Array.isArray(content)) {
1235
+ return content
1236
+ .map((part) => (part.type === "text" ? part.text : ""))
1237
+ .filter(Boolean)
1238
+ .join("\n");
1239
+ }
1240
+ return "";
1241
+ }
1242
+ async function judgeCall(context, m, content, maxTokens = JUDGE_MAX_TOKENS, requiredImages) {
1243
+ const result = (await context.runProviderPrediction({
1244
+ provider: m.provider,
1245
+ capability: "generate_message",
1246
+ model: m.model,
1247
+ params: {
1248
+ messages: [{ role: "user", content }],
1249
+ max_tokens: maxTokens,
1250
+ temperature: 0,
1251
+ strict_image_evidence: content.some((part) => part.type === "image_url") ||
1252
+ Boolean(requiredImages?.length),
1253
+ required_images: requiredImages?.map(normalizeMediaSource)
1254
+ }
1255
+ }));
1256
+ return messageText(result);
1257
+ }
1258
+ /**
1259
+ * Whether a model reply reads as cut off rather than merely wrong.
1260
+ *
1261
+ * A judge on a reasoning model spends its ceiling thinking and returns half a
1262
+ * sentence; the caller then sees "did not return parseable JSON" and re-runs
1263
+ * the same call at the same budget. Naming the cause in the error is the
1264
+ * difference between one retry and three.
1265
+ */
1266
+ export function looksTruncated(text) {
1267
+ const trimmed = text.trimEnd();
1268
+ if (trimmed.length === 0)
1269
+ return false;
1270
+ if (/[.!?\]}"]$/.test(trimmed))
1271
+ return false;
1272
+ return true;
1273
+ }
1274
+ function tasteBlock(params) {
1275
+ const profile = params["taste_profile"];
1276
+ if (!isNonBlankString(profile))
1277
+ return "";
1278
+ return `\n\nThe user's known aesthetic preferences (weigh these alongside the brief):\n${profile.trim()}`;
1279
+ }
1280
+ /**
1281
+ * A critique out of a judge reply, whole or cut short.
1282
+ *
1283
+ * The reply is a report, not an instruction: a `verdict` plus two lists whose
1284
+ * entries stand alone. A judge that hits its token ceiling mid-list has still
1285
+ * said everything before the cut, so a truncated reply is salvaged rather than
1286
+ * thrown away — before this, a run lost a usable verdict and every defect the
1287
+ * judge had already named.
1288
+ */
1289
+ function parseCritique(text) {
1290
+ const parsed = extractJSONAllowingTruncation(text);
1291
+ if (!isRecord(parsed)) {
1292
+ return null;
1293
+ }
1294
+ const obj = parsed;
1295
+ const verdict = obj["verdict"] === "pass" ? "pass" : "revise";
1296
+ const defects = Array.isArray(obj["defects"])
1297
+ ? obj["defects"]
1298
+ .filter(isObjectLike)
1299
+ .map((d) => ({
1300
+ defect: String(d["defect"] ?? ""),
1301
+ location: String(d["location"] ?? ""),
1302
+ fix: String(d["fix"] ?? "")
1303
+ }))
1304
+ .filter((d) => d.defect)
1305
+ : [];
1306
+ const strengths = Array.isArray(obj["strengths"])
1307
+ ? obj["strengths"].map(String).filter(Boolean)
1308
+ : [];
1309
+ return { verdict, defects, strengths };
1310
+ }
1311
+ const critiqueImage = {
1312
+ spec: critiqueImageSpec,
1313
+ impl: async (run, params) => {
1314
+ const context = run.context;
1315
+ const m = parseJudgeModelArgs(params);
1316
+ if ("error" in m)
1317
+ return m;
1318
+ const image = params["image"];
1319
+ const brief = params["brief"];
1320
+ if (!isNonEmptyString(image))
1321
+ return { error: "image is required" };
1322
+ if (!isNonEmptyString(brief))
1323
+ return { error: "brief is required" };
1324
+ const prompt = `You are a demanding art director reviewing one image against a brief.` +
1325
+ `\n\nBrief:\n${brief}${tasteBlock(params)}` +
1326
+ `\n\nExamine the image and report only defects you can point at: things that are` +
1327
+ ` wrong, missing relative to the brief, or technically broken (anatomy, geometry,` +
1328
+ ` illegible text, composition, lighting inconsistencies). For each defect say` +
1329
+ ` exactly where it is and the concrete change that fixes it.` +
1330
+ `\n\nRules:` +
1331
+ `\n- Never suggest adding embellishment or "more detail" — only fixes to named problems.` +
1332
+ `\n- If the composition itself is wrong for the brief, say so explicitly; that means` +
1333
+ ` regenerating, not patching.` +
1334
+ `\n- Verdict "pass" only if the image fulfills the brief with no defect a client would notice.` +
1335
+ `\n\nRespond with JSON only:` +
1336
+ `\n{"verdict": "pass" | "revise", "defects": [{"defect": "...", "location": "...",` +
1337
+ ` "fix": "..."}], "strengths": ["..."]}`;
1338
+ try {
1339
+ const text = await judgeCall(context, m, [
1340
+ textPart(prompt),
1341
+ imagePart(image)
1342
+ ]);
1343
+ const critique = parseCritique(text);
1344
+ if (!critique) {
1345
+ return {
1346
+ error: `Judge did not return parseable JSON` +
1347
+ `${looksTruncated(text) ? " (the reply stops mid-sentence — it hit the token ceiling; raise max_tokens or pick a model that does not spend the budget on reasoning)" : ""}` +
1348
+ `: ${text.slice(0, 300)}`
1349
+ };
1350
+ }
1351
+ return {
1352
+ type: "critique",
1353
+ provider: m.provider,
1354
+ model: m.model,
1355
+ ...critique
1356
+ };
1357
+ }
1358
+ catch (e) {
1359
+ return {
1360
+ error: `critique_image failed: ${e instanceof Error ? e.message : String(e)}`
1361
+ };
1362
+ }
1363
+ }
1364
+ };
1365
+ function parsePairVerdict(text) {
1366
+ const parsed = extractJSONAllowingTruncation(text);
1367
+ if (!isRecord(parsed))
1368
+ return null;
1369
+ const obj = parsed;
1370
+ const winner = Number(obj["winner"]);
1371
+ if (winner !== 1 && winner !== 2)
1372
+ return null;
1373
+ return { winner, reason: String(obj["reason"] ?? "") };
1374
+ }
1375
+ const compareImages = {
1376
+ spec: compareImagesSpec,
1377
+ impl: async (run, params) => {
1378
+ const context = run.context;
1379
+ const m = parseJudgeModelArgs(params);
1380
+ if ("error" in m)
1381
+ return m;
1382
+ const images = params["images"];
1383
+ const brief = params["brief"];
1384
+ if (!Array.isArray(images) ||
1385
+ images.length < 2 ||
1386
+ images.some((i) => !isNonEmptyString(i))) {
1387
+ return { error: "images must be an array of 2-8 non-empty strings" };
1388
+ }
1389
+ if (images.length > MAX_COMPARE_IMAGES) {
1390
+ return {
1391
+ error: `images must contain at most ${MAX_COMPARE_IMAGES} candidates`
1392
+ };
1393
+ }
1394
+ if (!isNonEmptyString(brief))
1395
+ return { error: "brief is required" };
1396
+ const prompt = `You are judging which of two images better fulfills a creative brief.` +
1397
+ `\n\nBrief:\n${brief}${tasteBlock(params)}` +
1398
+ `\n\nImage 1 is shown first, image 2 second. Judge fulfillment of the brief and` +
1399
+ ` craft (composition, coherence, technical execution) — not which image is busier` +
1400
+ ` or more embellished. You must pick exactly one winner.` +
1401
+ `\n\nRespond with JSON only: {"winner": 1 | 2, "reason": "one sentence"}`;
1402
+ const judgePair = async (a, b) => {
1403
+ const call = async (first, second) => {
1404
+ const text = await judgeCall(context, m, [textPart(prompt), imagePart(first), imagePart(second)], JUDGE_MAX_TOKENS, images.map(String));
1405
+ const verdict = parsePairVerdict(text);
1406
+ if (!verdict) {
1407
+ throw new Error(`Judge did not return parseable JSON: ${text.slice(0, 200)}`);
1408
+ }
1409
+ return {
1410
+ winner: verdict.winner === 1 ? first : second,
1411
+ reason: verdict.reason
1412
+ };
1413
+ };
1414
+ try {
1415
+ // Same pair, both presentation orders: an order-dependent preference
1416
+ // cancels out; only a stable preference wins outright.
1417
+ const [forward, reversed] = [await call(a, b), await call(b, a)];
1418
+ if (forward.winner === reversed.winner) {
1419
+ return { winner: forward.winner, reason: forward.reason };
1420
+ }
1421
+ // crypto randomInt over Math.random: not security-sensitive (it only
1422
+ // picks the tiebreak presentation order), but it keeps CodeQL's
1423
+ // insecure-randomness rule quiet without an exception.
1424
+ const tiebreak = randomInt(2) === 0 ? await call(a, b) : await call(b, a);
1425
+ return {
1426
+ winner: tiebreak.winner,
1427
+ reason: `(order-sensitive verdict, tiebreak) ${tiebreak.reason}`
1428
+ };
1429
+ }
1430
+ catch (e) {
1431
+ return { error: e instanceof Error ? e.message : String(e) };
1432
+ }
1433
+ };
1434
+ const matches = [];
1435
+ let round = images.map(String);
1436
+ try {
1437
+ while (round.length > 1) {
1438
+ const next = [];
1439
+ for (let i = 0; i + 1 < round.length; i += 2) {
1440
+ const result = await judgePair(round[i], round[i + 1]);
1441
+ if ("error" in result)
1442
+ return { error: `compare_images failed: ${result.error}` };
1443
+ matches.push({
1444
+ a: round[i],
1445
+ b: round[i + 1],
1446
+ winner: result.winner,
1447
+ agreed: !result.reason.startsWith("(order-sensitive"),
1448
+ reason: result.reason
1449
+ });
1450
+ next.push(result.winner);
1451
+ }
1452
+ if (round.length % 2 === 1)
1453
+ next.push(round[round.length - 1]);
1454
+ round = next;
1455
+ }
1456
+ }
1457
+ catch (e) {
1458
+ return {
1459
+ error: `compare_images failed: ${e instanceof Error ? e.message : String(e)}`
1460
+ };
1461
+ }
1462
+ return {
1463
+ type: "comparison",
1464
+ provider: m.provider,
1465
+ model: m.model,
1466
+ winner: round[0],
1467
+ matches,
1468
+ note: "Winner of a pairwise knockout. Other candidates were not deleted — " +
1469
+ "surface them to the user if the pick looks wrong."
1470
+ };
1471
+ }
1472
+ };
1473
+ const scoreImageAdherence = {
1474
+ spec: scoreImageAdherenceSpec,
1475
+ impl: async (run, params) => {
1476
+ const context = run.context;
1477
+ const m = parseJudgeModelArgs(params);
1478
+ if ("error" in m)
1479
+ return m;
1480
+ const image = params["image"];
1481
+ const brief = params["brief"];
1482
+ if (!isNonEmptyString(image))
1483
+ return { error: "image is required" };
1484
+ if (!isNonEmptyString(brief))
1485
+ return { error: "brief is required" };
1486
+ try {
1487
+ let questions = Array.isArray(params["questions"])
1488
+ ? params["questions"].map(String).filter(Boolean)
1489
+ : [];
1490
+ if (questions.length === 0) {
1491
+ const decomposeText = await judgeCall(context, m, [
1492
+ textPart(`Decompose this creative brief into at most ${MAX_ADHERENCE_QUESTIONS} atomic` +
1493
+ ` yes/no questions, each verifiable by looking at a single image. Cover every` +
1494
+ ` explicit requirement (subjects, counts, colors, text, style, composition,` +
1495
+ ` mood). Phrase each so "yes" means the requirement is met. Skip anything not` +
1496
+ ` visually checkable.` +
1497
+ `\n\nBrief:\n${brief}` +
1498
+ `\n\nRespond with JSON only: {"questions": ["..."]}`)
1499
+ ], JUDGE_MAX_TOKENS, [image]);
1500
+ const parsed = extractJSON(decomposeText);
1501
+ const list = isRecord(parsed) ? parsed["questions"] : parsed;
1502
+ questions = Array.isArray(list) ? list.map(String).filter(Boolean) : [];
1503
+ if (questions.length === 0) {
1504
+ return {
1505
+ error: `Could not decompose the brief into checks: ${decomposeText.slice(0, 300)}`
1506
+ };
1507
+ }
1508
+ }
1509
+ questions = questions.slice(0, MAX_ADHERENCE_QUESTIONS);
1510
+ const checks = questions.map((question, i) => ({
1511
+ id: `q${i + 1}`,
1512
+ question
1513
+ }));
1514
+ const answerText = await judgeCall(context, m, [
1515
+ textPart(`Answer each question about the image with a strict yes or no. "yes" only if` +
1516
+ ` the image clearly satisfies it; when unsure, answer "no" and say why in the note.` +
1517
+ `\n\nQuestions:\n${checks.map((q) => `${q.id}: ${q.question}`).join("\n")}` +
1518
+ `\n\nRespond with JSON only:` +
1519
+ `\n{"answers": [{"id": "q1", "question": "...", "answer": "yes" | "no", "note": "..."}]}`),
1520
+ imagePart(image)
1521
+ ]);
1522
+ const parsed = extractJSON(answerText);
1523
+ const rawAnswers = isRecord(parsed) ? parsed["answers"] : null;
1524
+ if (!Array.isArray(rawAnswers) || rawAnswers.length === 0) {
1525
+ return {
1526
+ error: `Judge did not return parseable answers: ${answerText.slice(0, 300)}`,
1527
+ evidence_status: "invalid",
1528
+ total: checks.length,
1529
+ missing_ids: checks.map((check) => check.id)
1530
+ };
1531
+ }
1532
+ const byId = new Map();
1533
+ const invalid = [];
1534
+ for (const raw of rawAnswers) {
1535
+ if (!isRecord(raw)) {
1536
+ invalid.push("answer must be an object");
1537
+ continue;
1538
+ }
1539
+ const id = String(raw["id"] ?? "");
1540
+ const check = checks.find((c) => c.id === id);
1541
+ if (!check || raw["question"] !== check.question) {
1542
+ invalid.push(`unrequested or substituted check: ${id}`);
1543
+ continue;
1544
+ }
1545
+ if (byId.has(id)) {
1546
+ invalid.push(`duplicate check: ${id}`);
1547
+ continue;
1548
+ }
1549
+ if (raw["answer"] !== "yes" && raw["answer"] !== "no") {
1550
+ invalid.push(`invalid answer: ${id}`);
1551
+ continue;
1552
+ }
1553
+ byId.set(id, {
1554
+ id,
1555
+ question: check.question,
1556
+ answer: raw["answer"],
1557
+ note: String(raw["note"] ?? "")
1558
+ });
1559
+ }
1560
+ const missingIds = checks.filter((c) => !byId.has(c.id)).map((c) => c.id);
1561
+ if (invalid.length || missingIds.length) {
1562
+ return {
1563
+ error: "Judge returned invalid or incomplete adherence evidence",
1564
+ evidence_status: "invalid",
1565
+ total: checks.length,
1566
+ missing_ids: missingIds,
1567
+ invalid
1568
+ };
1569
+ }
1570
+ const answers = [];
1571
+ for (const check of checks) {
1572
+ const answer = byId.get(check.id);
1573
+ if (answer) {
1574
+ answers.push(answer);
1575
+ }
1576
+ }
1577
+ const passed = answers.filter((a) => a.answer === "yes").length;
1578
+ return {
1579
+ type: "adherence",
1580
+ evidence_status: "complete",
1581
+ provider: m.provider,
1582
+ model: m.model,
1583
+ score: passed / checks.length,
1584
+ passed,
1585
+ total: checks.length,
1586
+ failed: answers.filter((a) => a.answer === "no"),
1587
+ answers
1588
+ };
1589
+ }
1590
+ catch (e) {
1591
+ return {
1592
+ error: `score_image_adherence failed: ${e instanceof Error ? e.message : String(e)}`
1593
+ };
1594
+ }
1595
+ }
1596
+ };
1597
+ // ---------------------------------------------------------------------------
1598
+ // understand_video
1599
+ // ---------------------------------------------------------------------------
1600
+ /**
1601
+ * Read a video with a multimodal chat model.
1602
+ *
1603
+ * The video rides as a `video` content part next to the instruction; the
1604
+ * context's media resolver inlines an `asset://` URI and the provider decides
1605
+ * whether the bytes go inline or through its files API.
1606
+ *
1607
+ * A provider with no video content part is not refused here any more: the
1608
+ * runtime samples the clip into stills with ffmpeg and sends those. The reply
1609
+ * carries `read_as` so the caller knows which of the two it got — a frame read
1610
+ * has no audio and nothing between the samples, and an answer that depends on
1611
+ * either should be treated as a guess.
1612
+ */
1613
+ const understandVideo = {
1614
+ spec: understandVideoSpec,
1615
+ impl: async (run, params) => {
1616
+ const m = parseJudgeModelArgs(params);
1617
+ if ("error" in m)
1618
+ return m;
1619
+ const video = params["video"];
1620
+ if (!isNonEmptyString(video)) {
1621
+ return { error: "video is required" };
1622
+ }
1623
+ const promptParam = params["prompt"];
1624
+ const prompt = isNonBlankString(promptParam)
1625
+ ? promptParam
1626
+ : DEFAULT_VIDEO_PROMPT;
1627
+ const requested = Number(params["max_tokens"]);
1628
+ const maxTokens = Number.isFinite(requested) && requested > 0
1629
+ ? Math.min(Math.floor(requested), MAX_UNDERSTAND_VIDEO_TOKENS)
1630
+ : DEFAULT_UNDERSTAND_VIDEO_TOKENS;
1631
+ try {
1632
+ const native = await run.context.providerSupportsVideoInput(m.provider);
1633
+ const text = await judgeCall(run.context, m, [textPart(prompt), videoPart(video)], maxTokens);
1634
+ return {
1635
+ text,
1636
+ provider: m.provider,
1637
+ model: m.model,
1638
+ read_as: native ? "video" : "sampled_frames",
1639
+ // A reasoning model spends `max_tokens` on thinking and returns a
1640
+ // fragment. Without this the caller reads half an answer as the whole
1641
+ // answer — one run acted on "the clip shows a man attempting to" and
1642
+ // never learned the sentence had been cut.
1643
+ truncated: looksTruncated(text),
1644
+ max_tokens: maxTokens
1645
+ };
1646
+ }
1647
+ catch (e) {
1648
+ return {
1649
+ error: `understand_video failed: ${e instanceof Error ? e.message : String(e)}`
1650
+ };
1651
+ }
1652
+ }
1653
+ };
1654
+ /**
1655
+ * The gated read behind a media reference.
1656
+ *
1657
+ * The sandbox's own `media.bytes` needs a `ProcessingContext`, which a chat
1658
+ * action deliberately runs without (#4780) — so a chat user could generate an
1659
+ * image and never read it back. This is the same resolution past the
1660
+ * permission gate, with the context the run already carries.
1661
+ *
1662
+ * A filesystem path is refused rather than contained here: `read_file` is the
1663
+ * gated way to a workspace file, and a second containment rule beside
1664
+ * `resolveGuestPath` is the thing worth not having.
1665
+ */
1666
+ const readMediaBytes = {
1667
+ spec: readMediaBytesSpec,
1668
+ impl: async (run, params) => {
1669
+ const uri = params.uri;
1670
+ if (!isNonBlankString(uri)) {
1671
+ return { error: "uri is required and must be a non-empty string" };
1672
+ }
1673
+ const trimmed = uri.trim();
1674
+ if (filesystemPathForUri(trimmed) !== null) {
1675
+ return {
1676
+ error: `read_media_bytes does not read filesystem paths (${trimmed}). Use read_file for a workspace file, or pass an asset:// URI.`
1677
+ };
1678
+ }
1679
+ // A bare id is what an agent reaches for after reading `asset_id` off a
1680
+ // generation result; accept it rather than making that a failed round trip.
1681
+ const ref = trimmed.includes("://")
1682
+ ? { uri: trimmed }
1683
+ : { uri: trimmed, asset_id: trimmed };
1684
+ try {
1685
+ const bytes = await loadMediaRefBytes(ref, run.context);
1686
+ if (!bytes) {
1687
+ return {
1688
+ error: `Could not read ${trimmed}. Pass the asset:// URI a generation returned (its asset_uri), or list_assets to find one.`
1689
+ };
1690
+ }
1691
+ if (bytes.length > MAX_MEDIA_REF_BYTES) {
1692
+ return {
1693
+ error: `${trimmed} is ${bytes.length} bytes, over the ${MAX_MEDIA_REF_BYTES} byte limit`
1694
+ };
1695
+ }
1696
+ return {
1697
+ uri: trimmed,
1698
+ size: bytes.length,
1699
+ mime_type: mimeForRef(ref, DEFAULT_MIME.document),
1700
+ content_base64: encodeMediaBase64(bytes)
1701
+ };
1702
+ }
1703
+ catch (e) {
1704
+ return {
1705
+ error: `read_media_bytes failed: ${e instanceof Error ? e.message : String(e)}`
1706
+ };
1707
+ }
1708
+ }
1709
+ };
1710
+ /**
1711
+ * A real directory a host media binary can run in, plus the workspace it
1712
+ * belongs to.
1713
+ *
1714
+ * A local workspace *is* that directory, so the binary reads and writes the
1715
+ * user's files in place. A cloud workspace has no directory, so the run gets a
1716
+ * scratch one: inputs named in argv are staged into it beforehand
1717
+ * ({@link stageHostBinaryInputs}) and the output is read back out of it
1718
+ * afterwards ({@link persistWorkspaceFile}). Either way the binary sees plain
1719
+ * paths and needs no knowledge of where the workspace actually lives.
1720
+ */
1721
+ async function hostBinaryRoot(context) {
1722
+ const workspace = context.workspace;
1723
+ if (!workspace) {
1724
+ return { error: "a workspace is required to run a host media binary" };
1725
+ }
1726
+ try {
1727
+ return { workspace, cwd: await workspace.scratchDir() };
1728
+ }
1729
+ catch (e) {
1730
+ return {
1731
+ error: `could not prepare a working directory: ${e instanceof Error ? e.message : String(e)}`
1732
+ };
1733
+ }
1734
+ }
1735
+ /**
1736
+ * Copy every argv path that names an existing workspace file into the scratch
1737
+ * directory, so the binary finds its inputs where it expects them.
1738
+ *
1739
+ * A no-op on a local workspace, where the scratch directory is the workspace.
1740
+ * Only whole arguments are staged: an input reaches ffmpeg as its own argv
1741
+ * entry (`-i clip.mp4`), and a path buried inside a filter token names an
1742
+ * output far more often than an input.
1743
+ */
1744
+ async function stageHostBinaryInputs(workspace, argv) {
1745
+ if (workspace.localDir)
1746
+ return;
1747
+ for (const arg of argv) {
1748
+ if (!arg || arg.startsWith("-"))
1749
+ continue;
1750
+ try {
1751
+ if (await workspace.exists(arg))
1752
+ await workspace.materialize(arg);
1753
+ }
1754
+ catch {
1755
+ // Not a workspace path, or not readable — the binary reports it.
1756
+ }
1757
+ }
1758
+ }
1759
+ function stringArgs(raw) {
1760
+ if (!Array.isArray(raw) || raw.length === 0) {
1761
+ return { error: "args must be a non-empty array of strings" };
1762
+ }
1763
+ const args = [];
1764
+ for (const item of raw) {
1765
+ if (!isString(item)) {
1766
+ return { error: "args must be a non-empty array of strings" };
1767
+ }
1768
+ args.push(item);
1769
+ }
1770
+ return args;
1771
+ }
1772
+ /**
1773
+ * Take what the binary produced and put it in the workspace.
1774
+ *
1775
+ * The file is on disk either way — in the workspace folder on a local run, in
1776
+ * the scratch directory on a cloud one — so it is read from there and written
1777
+ * through `persistBinaryOutput`, which stores it in the workspace and (when
1778
+ * asked) as an asset.
1779
+ */
1780
+ async function persistWorkspaceFile(context, workspace, relPath) {
1781
+ let abs;
1782
+ try {
1783
+ const root = workspace.localDir ?? (await workspace.scratchDir());
1784
+ abs = path.join(root, workspace.key(relPath));
1785
+ }
1786
+ catch (e) {
1787
+ return { persist_error: e instanceof Error ? e.message : String(e) };
1788
+ }
1789
+ try {
1790
+ const bytes = await readFile(abs);
1791
+ const persisted = await persistBinaryOutput(context, bytes, {
1792
+ outputFile: relPath,
1793
+ contentType: mimeFromFilename(relPath),
1794
+ uiPrefix: "media"
1795
+ });
1796
+ return { ...persisted };
1797
+ }
1798
+ catch (e) {
1799
+ return { persist_error: e instanceof Error ? e.message : String(e) };
1800
+ }
1801
+ }
1802
+ /**
1803
+ * What a refused `://` in ffmpeg argv should do instead. The guard's default
1804
+ * says "stage it first" without saying how; here there is a parameter for it.
1805
+ */
1806
+ const FFMPEG_REMEDY = 'Pass the ref in `inputs` instead — {"clip.mp4": "asset://<id>.mp4"} ' +
1807
+ "copies it into the workspace, then name `clip.mp4` in args.";
1808
+ /** The same remedy for `ffprobe`, whose one path argument replaces argv. */
1809
+ const FFPROBE_REMEDY = 'Pass the ref in `inputs` instead — {"clip.mp4": "asset://<id>.mp4"} ' +
1810
+ 'copies it into the workspace, then set path to "clip.mp4".';
1811
+ /** Per-file limit for inline, temporary, and non-local staged inputs. */
1812
+ const MAX_STAGED_INPUT_BYTES = 100 * 1024 * 1024;
1813
+ /** Files one `inputs` bag may stage. */
1814
+ const MAX_STAGED_INPUTS = 8;
1815
+ /** Bytes one `inputs` bag may stage in total. */
1816
+ const MAX_STAGED_TOTAL_BYTES = 256 * 1024 * 1024;
1817
+ /**
1818
+ * Copy the refs in `inputs` into the workspace under the names the caller
1819
+ * gave them, so argv can name plain local files.
1820
+ *
1821
+ * ffmpeg opens local files only — a URL or an `asset://` URI in argv is
1822
+ * refused, and rightly so. But chat code has no workspace API of its own, so
1823
+ * before this there was no way to put an asset where ffmpeg could see it: the
1824
+ * capability was on the belt and unusable, and the refusal told the caller to
1825
+ * "download first" with nothing to download with. Staging is that missing
1826
+ * half, and it changes no boundary — the bytes are resolved host-side by the
1827
+ * same resolver `save_asset` uses, and every name still goes through
1828
+ * {@link confineArgvToWorkspace}.
1829
+ */
1830
+ async function stageInputs(context, workspace, cwd, raw) {
1831
+ if (raw === undefined || raw === null)
1832
+ return { staged: {} };
1833
+ if (!isRecord(raw)) {
1834
+ return {
1835
+ error: 'inputs must be an object of {"<workspace-relative name>": "<asset:// URI, /api/storage/ key, or data: URI>"}'
1836
+ };
1837
+ }
1838
+ const entries = Object.entries(raw);
1839
+ if (entries.length > MAX_STAGED_INPUTS) {
1840
+ return {
1841
+ error: `inputs stages at most ${MAX_STAGED_INPUTS} files; ${entries.length} were given.`
1842
+ };
1843
+ }
1844
+ const names = entries.map(([name]) => name);
1845
+ const refusal = await confineArgvToWorkspace(names, cwd);
1846
+ if (refusal)
1847
+ return refusal;
1848
+ const staged = {};
1849
+ let total = 0;
1850
+ const localAssetLimit = workspace.localDir
1851
+ ? getMaxLocalUploadBytes()
1852
+ : undefined;
1853
+ const hasLocalAsset = localAssetLimit !== undefined &&
1854
+ entries.some(([, ref]) => isNonBlankString(ref) && ref.trim().startsWith("asset://"));
1855
+ const totalLimit = hasLocalAsset
1856
+ ? Math.max(MAX_STAGED_TOTAL_BYTES, localAssetLimit ?? 0)
1857
+ : MAX_STAGED_TOTAL_BYTES;
1858
+ for (const [name, ref] of entries) {
1859
+ if (!isNonBlankString(name)) {
1860
+ return { error: "inputs keys must be non-empty workspace paths." };
1861
+ }
1862
+ if (!isNonBlankString(ref)) {
1863
+ return {
1864
+ error: `inputs["${name}"] must be a string ref (asset:// URI, /api/storage/ key, or data: URI).`
1865
+ };
1866
+ }
1867
+ let bytes = null;
1868
+ let readError;
1869
+ try {
1870
+ bytes = await loadMediaRefBytes({ uri: ref.trim() }, context);
1871
+ }
1872
+ catch (e) {
1873
+ // Keep why. Naming only the accepted forms is useless to a caller who
1874
+ // already passed one — an unreachable bucket, a revoked credential and a
1875
+ // typo all arrive here, and only the first two are worth retrying. Told
1876
+ // just "pass an asset:// URI", a model re-sends the ref it has and then
1877
+ // starts guessing at URL shapes.
1878
+ readError = e instanceof Error ? e.message : String(e);
1879
+ }
1880
+ // Zero bytes is a failed read wearing a buffer, the same way it is in
1881
+ // `save_asset` — staging it would hand ffmpeg an empty file and the
1882
+ // failure would surface as an unhelpable decode error.
1883
+ if (!bytes || bytes.byteLength === 0) {
1884
+ return {
1885
+ error: `inputs["${name}"]: could not read ${ref}. ` +
1886
+ (readError
1887
+ ? `Reading it failed: ${readError}. `
1888
+ : "It resolved to no bytes. ") +
1889
+ `Accepted: an asset:// URI, the /api/storage/ key a tool returned, ` +
1890
+ `or a data: URI.`
1891
+ };
1892
+ }
1893
+ const inputLimit = localAssetLimit !== undefined && ref.trim().startsWith("asset://")
1894
+ ? localAssetLimit
1895
+ : MAX_STAGED_INPUT_BYTES;
1896
+ if (bytes.byteLength > inputLimit) {
1897
+ return {
1898
+ error: `inputs["${name}"] is ${bytes.byteLength} bytes, over the ${inputLimit}-byte limit.`
1899
+ };
1900
+ }
1901
+ total += bytes.byteLength;
1902
+ if (total > totalLimit) {
1903
+ return {
1904
+ error: `inputs stages ${total} bytes, over the ${totalLimit}-byte total limit.`
1905
+ };
1906
+ }
1907
+ // Through the workspace, so the staged input is durable and a cloud run
1908
+ // stages at all; then onto disk in `cwd`, because the binary opens a real
1909
+ // path. On a local workspace `materialize` hands back the file just
1910
+ // written, so this is one write, not two.
1911
+ try {
1912
+ await workspace.write(name, bytes);
1913
+ await workspace.materialize(name);
1914
+ }
1915
+ catch (e) {
1916
+ return {
1917
+ error: `inputs["${name}"] could not be staged: ${e instanceof Error ? e.message : String(e)}`
1918
+ };
1919
+ }
1920
+ staged[name] = bytes.byteLength;
1921
+ }
1922
+ return { staged };
1923
+ }
1924
+ const ffmpeg = {
1925
+ spec: ffmpegSpec,
1926
+ impl: async (run, params) => {
1927
+ const root = await hostBinaryRoot(run.context);
1928
+ if ("error" in root)
1929
+ return root;
1930
+ const { workspace, cwd } = root;
1931
+ const args = stringArgs(params["args"]);
1932
+ if ("error" in args)
1933
+ return args;
1934
+ const stagedResult = await stageInputs(run.context, workspace, cwd, params["inputs"]);
1935
+ if ("error" in stagedResult)
1936
+ return stagedResult;
1937
+ const outputFile = isNonBlankString(params["output_file"])
1938
+ ? params["output_file"].trim()
1939
+ : "";
1940
+ const argv = [...args];
1941
+ if (outputFile && !argv.includes(outputFile)) {
1942
+ argv.push(outputFile);
1943
+ }
1944
+ const refusal = await confineArgvToWorkspace(argv, cwd, FFMPEG_REMEDY);
1945
+ if (refusal)
1946
+ return refusal;
1947
+ const hardened = hardenFfmpegArgv(argv);
1948
+ if ("error" in hardened)
1949
+ return hardened;
1950
+ const persistTarget = outputFile ||
1951
+ [...argv].reverse().find((item) => item && !item.startsWith("-")) ||
1952
+ "";
1953
+ const timeoutMs = clampTimeoutSeconds(params["timeout_seconds"], 180, 600) * 1000;
1954
+ const runOptions = { cwd, timeoutMs };
1955
+ // Only a known output path can be watched for size; without one the
1956
+ // wall clock and the capture cap are the run's bounds.
1957
+ if (persistTarget) {
1958
+ runOptions.artifactPath = persistTarget;
1959
+ }
1960
+ try {
1961
+ await stageHostBinaryInputs(workspace, hardened.argv);
1962
+ const result = await runHostBinary("ffmpeg", hardened.argv, runOptions);
1963
+ const persisted = result.exitCode === 0 && persistTarget
1964
+ ? await persistWorkspaceFile(run.context, workspace, persistTarget)
1965
+ : undefined;
1966
+ const report = {
1967
+ success: result.exitCode === 0,
1968
+ stdout: result.stdout,
1969
+ stderr: result.stderr,
1970
+ exit_code: result.exitCode,
1971
+ ...(persisted ?? {})
1972
+ };
1973
+ if (Object.keys(stagedResult.staged).length > 0) {
1974
+ report["staged"] = stagedResult.staged;
1975
+ }
1976
+ return report;
1977
+ }
1978
+ catch (e) {
1979
+ if (e instanceof HostBinaryMissingError) {
1980
+ return { error: e.message };
1981
+ }
1982
+ return {
1983
+ error: `ffmpeg failed: ${e instanceof Error ? e.message : String(e)}`
1984
+ };
1985
+ }
1986
+ }
1987
+ };
1988
+ /**
1989
+ * What ffprobe reports as numbers, as numbers.
1990
+ *
1991
+ * ffprobe's JSON is all strings — `"duration": "8.000000"` — so arithmetic on
1992
+ * it silently produces `"8.000000".toFixed is not a function`, or worse, a
1993
+ * concatenation. The raw payload stays exactly as ffprobe wrote it; this is a
1994
+ * second, typed view of the four fields a caller actually plans a cut with.
1995
+ */
1996
+ export function ffprobeSummary(parsed) {
1997
+ const format = isObjectLike(parsed["format"]) ? parsed["format"] : {};
1998
+ const streams = Array.isArray(parsed["streams"]) ? parsed["streams"] : [];
1999
+ const numeric = (value) => {
2000
+ const n = typeof value === "number" ? value : Number(value);
2001
+ return Number.isFinite(n) ? n : null;
2002
+ };
2003
+ const ofKind = (kind) => streams.find((s) => isObjectLike(s) && s["codec_type"] === kind);
2004
+ const video = ofKind("video");
2005
+ const audio = ofKind("audio");
2006
+ const summary = {
2007
+ duration_seconds: numeric(format["duration"]) ?? numeric(video?.["duration"]),
2008
+ has_video: video !== undefined,
2009
+ has_audio: audio !== undefined
2010
+ };
2011
+ if (video) {
2012
+ summary["width"] = numeric(video["width"]);
2013
+ summary["height"] = numeric(video["height"]);
2014
+ }
2015
+ return summary;
2016
+ }
2017
+ /**
2018
+ * Refs `ffprobe` stages for itself, rather than refusing.
2019
+ *
2020
+ * These are the forms NodeTool's own tools hand back, so a caller probing a
2021
+ * clip it just generated is passing the string it was given. An http(s) URL is
2022
+ * not here: fetching one is egress, and egress belongs to the surfaces that
2023
+ * declare it.
2024
+ */
2025
+ function isStageableProbeRef(value) {
2026
+ return (value.startsWith("asset://") ||
2027
+ value.startsWith("/api/storage/") ||
2028
+ value.startsWith("data:"));
2029
+ }
2030
+ /** A workspace file name for a staged probe target, from the ref itself. */
2031
+ function probeStagingName(ref) {
2032
+ if (ref.startsWith("data:"))
2033
+ return "ffprobe-input/input";
2034
+ const tail = ref.split("/").pop() ?? "input";
2035
+ const safe = tail.replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 64);
2036
+ return `ffprobe-input/${safe || "input"}`;
2037
+ }
2038
+ /**
2039
+ * ffprobe with an argv NodeTool writes, not the caller.
2040
+ *
2041
+ * Everything a caller can say is one workspace path, so the whole boundary is
2042
+ * the confinement check — there is no flag surface to guard, and no way to ask
2043
+ * ffprobe to open a socket. `inputs` stages assets under workspace names the
2044
+ * same way `ffmpeg`'s does: without it the two halves of one loop disagreed,
2045
+ * and a caller who had just staged a clip for ffmpeg could not ask ffprobe how
2046
+ * long it was without staging it a second time through a no-op ffmpeg copy.
2047
+ */
2048
+ const ffprobe = {
2049
+ spec: ffprobeSpec,
2050
+ impl: async (run, params) => {
2051
+ const root = await hostBinaryRoot(run.context);
2052
+ if ("error" in root)
2053
+ return root;
2054
+ const { workspace, cwd } = root;
2055
+ const target = params["path"];
2056
+ if (!isNonBlankString(target)) {
2057
+ return { error: "path is required" };
2058
+ }
2059
+ const requested = target.trim();
2060
+ // ffprobe's whole argv is this one path, so an `asset://` here can only
2061
+ // mean "probe that": there is no flag to smuggle and nothing else to
2062
+ // confine. Refusing it made the two halves of one loop disagree — the
2063
+ // guest's own `video.info(asset://…)` reads a ref happily — and a caller
2064
+ // who just wanted a duration had to stage the file by hand first.
2065
+ const autoStaged = isStageableProbeRef(requested);
2066
+ const probePath = autoStaged ? probeStagingName(requested) : requested;
2067
+ let toStage = params["inputs"];
2068
+ if (autoStaged) {
2069
+ const extra = isRecord(toStage) ? toStage : {};
2070
+ toStage = { ...extra, [probePath]: requested };
2071
+ }
2072
+ const stagedResult = await stageInputs(run.context, workspace, cwd, toStage);
2073
+ if ("error" in stagedResult)
2074
+ return stagedResult;
2075
+ const refusal = await confineArgvToWorkspace([probePath], cwd, FFPROBE_REMEDY);
2076
+ if (refusal)
2077
+ return refusal;
2078
+ await stageHostBinaryInputs(workspace, [probePath]);
2079
+ const timeoutMs = clampTimeoutSeconds(params["timeout_seconds"], 30, 120) * 1000;
2080
+ try {
2081
+ const result = await runHostBinary("ffprobe", [
2082
+ "-v",
2083
+ "error",
2084
+ "-print_format",
2085
+ "json",
2086
+ "-show_format",
2087
+ "-show_streams",
2088
+ probePath
2089
+ ], { cwd, timeoutMs });
2090
+ if (result.exitCode !== 0) {
2091
+ return {
2092
+ error: `ffprobe failed: ${result.stderr.trim() || `exit ${result.exitCode}`}`
2093
+ };
2094
+ }
2095
+ const parsed = JSON.parse(result.stdout);
2096
+ if (!isObjectLike(parsed)) {
2097
+ return { error: "ffprobe returned no readable JSON" };
2098
+ }
2099
+ const report = {
2100
+ path: requested,
2101
+ ...parsed,
2102
+ summary: ffprobeSummary(parsed)
2103
+ };
2104
+ if (Object.keys(stagedResult.staged).length > 0) {
2105
+ report["staged"] = stagedResult.staged;
2106
+ }
2107
+ return report;
2108
+ }
2109
+ catch (e) {
2110
+ if (e instanceof HostBinaryMissingError) {
2111
+ return { error: e.message };
2112
+ }
2113
+ return {
2114
+ error: `ffprobe failed: ${e instanceof Error ? e.message : String(e)}`
2115
+ };
2116
+ }
2117
+ }
2118
+ };
2119
+ const DEFAULT_YT_DLP_OUTPUT = "downloads/yt-dlp/%(id)s.%(ext)s";
2120
+ const ytDlp = {
2121
+ spec: ytDlpSpec,
2122
+ impl: async (run, params) => {
2123
+ // The cloud profile leaves this off every belt, so a model never sees it.
2124
+ // A host that resolves the capability by name still lands here.
2125
+ if (!isYtDlpEnabled()) {
2126
+ return { error: "yt_dlp is not available on this deployment" };
2127
+ }
2128
+ const root = await hostBinaryRoot(run.context);
2129
+ if ("error" in root)
2130
+ return root;
2131
+ const { workspace, cwd } = root;
2132
+ const url = params["url"];
2133
+ if (!isNonBlankString(url)) {
2134
+ return { error: "url is required" };
2135
+ }
2136
+ // The downloader opens its own sockets from inside the server, so an
2137
+ // http(s) check alone leaves the metadata service and every internal
2138
+ // host reachable. Same guard the sandbox fetch bridge uses, plus the
2139
+ // resolution step a hostname needs.
2140
+ try {
2141
+ assertFetchUrlAllowed(url);
2142
+ await assertResolvedHostAllowed(url, "yt_dlp");
2143
+ }
2144
+ catch (e) {
2145
+ const message = e instanceof Error ? e.message : String(e);
2146
+ return { error: message.replace(/^fetch: /, "yt_dlp: ") };
2147
+ }
2148
+ const outputFile = isNonBlankString(params["output_file"])
2149
+ ? params["output_file"].trim()
2150
+ : DEFAULT_YT_DLP_OUTPUT;
2151
+ const format = isNonBlankString(params["format"])
2152
+ ? params["format"].trim()
2153
+ : "";
2154
+ const timeoutMs = clampTimeoutSeconds(params["timeout_seconds"], 300, 900) * 1000;
2155
+ // The template is the caller's, so it escapes the workspace as easily as
2156
+ // an ffmpeg path does. `format` reaches yt-dlp as a selector, never a path.
2157
+ const refusal = await confineArgvToWorkspace([outputFile], cwd);
2158
+ if (refusal)
2159
+ return refusal;
2160
+ const flagLike = refuseFlagLikeValue(outputFile, "output_file") ??
2161
+ (format ? refuseFlagLikeValue(format, "format") : undefined);
2162
+ if (flagLike)
2163
+ return flagLike;
2164
+ const outDir = path.dirname(outputFile);
2165
+ if (outDir && outDir !== ".") {
2166
+ try {
2167
+ await mkdir(path.join(cwd, outDir), { recursive: true });
2168
+ }
2169
+ catch (e) {
2170
+ return {
2171
+ error: `could not create output directory: ${e instanceof Error ? e.message : String(e)}`
2172
+ };
2173
+ }
2174
+ }
2175
+ const download = { url, outputFile };
2176
+ if (format) {
2177
+ download.format = format;
2178
+ }
2179
+ const argv = buildYtDlpArgv(download);
2180
+ try {
2181
+ const result = await runHostBinary("yt-dlp", argv, {
2182
+ cwd,
2183
+ timeoutMs
2184
+ });
2185
+ const printed = result.stdout.trim().split("\n").filter(Boolean).at(-1);
2186
+ // `--print after_move:filepath` names the finished file. Nothing printed
2187
+ // on a clean exit means nothing was written — which is what an aborted
2188
+ // over-cap download looks like, since `--print` silences the reason.
2189
+ if (result.exitCode === 0 && !printed) {
2190
+ return {
2191
+ success: false,
2192
+ url,
2193
+ error: `yt-dlp wrote no file. The download may have passed the ` +
2194
+ `${MAX_DOWNLOAD_BYTES}-byte limit, or the URL carried nothing to ` +
2195
+ `download.`,
2196
+ stdout: result.stdout,
2197
+ stderr: result.stderr,
2198
+ exit_code: result.exitCode
2199
+ };
2200
+ }
2201
+ const produced = printed && !printed.startsWith("http")
2202
+ ? path.isAbsolute(printed)
2203
+ ? path.relative(cwd, printed)
2204
+ : printed
2205
+ : outputFile.includes("%(")
2206
+ ? ""
2207
+ : outputFile;
2208
+ const persisted = result.exitCode === 0 && produced
2209
+ ? await persistWorkspaceFile(run.context, workspace, produced)
2210
+ : undefined;
2211
+ return {
2212
+ success: result.exitCode === 0,
2213
+ url,
2214
+ output_file: produced || outputFile,
2215
+ stdout: result.stdout,
2216
+ stderr: result.stderr,
2217
+ exit_code: result.exitCode,
2218
+ ...(persisted ?? {})
2219
+ };
2220
+ }
2221
+ catch (e) {
2222
+ if (e instanceof HostBinaryMissingError) {
2223
+ return { error: e.message };
2224
+ }
2225
+ return {
2226
+ error: `yt-dlp failed: ${e instanceof Error ? e.message : String(e)}`
2227
+ };
2228
+ }
2229
+ }
2230
+ };
2231
+ /** Every media capability, in the order `getAllMcpTools` offered them. */
2232
+ export const MEDIA_CAPABILITIES = [
2233
+ generateText,
2234
+ generateImage,
2235
+ editImage,
2236
+ segmentImage,
2237
+ generateVideo,
2238
+ animateImage,
2239
+ videoFromReferences,
2240
+ generateSpeech,
2241
+ generateMusic,
2242
+ transcribeAudio,
2243
+ embedText,
2244
+ readMediaBytes,
2245
+ critiqueImage,
2246
+ compareImages,
2247
+ scoreImageAdherence,
2248
+ understandVideo,
2249
+ ffmpeg,
2250
+ ffprobe,
2251
+ ytDlp
2252
+ ];
2253
+ export const module = {
2254
+ module: "media",
2255
+ exports: MEDIA_CAPABILITIES
2256
+ };
2257
+ export { generateText, generateImage, editImage, segmentImage, generateVideo, animateImage, videoFromReferences, generateSpeech, generateMusic, transcribeAudio, embedText, readMediaBytes, critiqueImage, compareImages, scoreImageAdherence, understandVideo, ffmpeg, ffprobe, ytDlp };
2258
+ //# sourceMappingURL=media.js.map