@nodetool-ai/protocol 0.7.0-rc.23 → 0.8.1

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 (419) hide show
  1. package/README.md +56 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/ai-video-production.d.ts +249 -0
  4. package/dist/ai-video-production.d.ts.map +1 -0
  5. package/dist/ai-video-production.js +131 -0
  6. package/dist/ai-video-production.js.map +1 -0
  7. package/dist/api-schemas/agent-access.d.ts +134 -0
  8. package/dist/api-schemas/agent-access.d.ts.map +1 -0
  9. package/dist/api-schemas/agent-access.js +93 -0
  10. package/dist/api-schemas/agent-access.js.map +1 -0
  11. package/dist/api-schemas/api-error-code.d.ts +11 -1
  12. package/dist/api-schemas/api-error-code.d.ts.map +1 -1
  13. package/dist/api-schemas/api-error-code.js +10 -0
  14. package/dist/api-schemas/api-error-code.js.map +1 -1
  15. package/dist/api-schemas/applications.d.ts +1411 -0
  16. package/dist/api-schemas/applications.d.ts.map +1 -0
  17. package/dist/api-schemas/applications.js +333 -0
  18. package/dist/api-schemas/applications.js.map +1 -0
  19. package/dist/api-schemas/assets.d.ts +230 -0
  20. package/dist/api-schemas/assets.d.ts.map +1 -1
  21. package/dist/api-schemas/assets.js +131 -5
  22. package/dist/api-schemas/assets.js.map +1 -1
  23. package/dist/api-schemas/code-gen.d.ts +176 -0
  24. package/dist/api-schemas/code-gen.d.ts.map +1 -0
  25. package/dist/api-schemas/code-gen.js +205 -0
  26. package/dist/api-schemas/code-gen.js.map +1 -0
  27. package/dist/api-schemas/collections.d.ts.map +1 -1
  28. package/dist/api-schemas/collections.js +3 -4
  29. package/dist/api-schemas/collections.js.map +1 -1
  30. package/dist/api-schemas/costs.d.ts +179 -0
  31. package/dist/api-schemas/costs.d.ts.map +1 -1
  32. package/dist/api-schemas/costs.js +100 -4
  33. package/dist/api-schemas/costs.js.map +1 -1
  34. package/dist/api-schemas/credits.d.ts +42 -0
  35. package/dist/api-schemas/credits.d.ts.map +1 -0
  36. package/dist/api-schemas/credits.js +43 -0
  37. package/dist/api-schemas/credits.js.map +1 -0
  38. package/dist/api-schemas/documents.d.ts +163 -0
  39. package/dist/api-schemas/documents.d.ts.map +1 -0
  40. package/dist/api-schemas/documents.js +75 -0
  41. package/dist/api-schemas/documents.js.map +1 -0
  42. package/dist/api-schemas/files.d.ts +13 -0
  43. package/dist/api-schemas/files.d.ts.map +1 -1
  44. package/dist/api-schemas/files.js +8 -0
  45. package/dist/api-schemas/files.js.map +1 -1
  46. package/dist/api-schemas/fonts.d.ts +17 -1
  47. package/dist/api-schemas/fonts.d.ts.map +1 -1
  48. package/dist/api-schemas/fonts.js +19 -3
  49. package/dist/api-schemas/fonts.js.map +1 -1
  50. package/dist/api-schemas/index.d.ts +23 -1
  51. package/dist/api-schemas/index.d.ts.map +1 -1
  52. package/dist/api-schemas/index.js +23 -1
  53. package/dist/api-schemas/index.js.map +1 -1
  54. package/dist/api-schemas/jobs.d.ts +12 -0
  55. package/dist/api-schemas/jobs.d.ts.map +1 -1
  56. package/dist/api-schemas/jobs.js +12 -2
  57. package/dist/api-schemas/jobs.js.map +1 -1
  58. package/dist/api-schemas/js-scripts.d.ts +364 -0
  59. package/dist/api-schemas/js-scripts.d.ts.map +1 -0
  60. package/dist/api-schemas/js-scripts.js +333 -0
  61. package/dist/api-schemas/js-scripts.js.map +1 -0
  62. package/dist/api-schemas/mcp-config.d.ts.map +1 -1
  63. package/dist/api-schemas/mcp-config.js +3 -1
  64. package/dist/api-schemas/mcp-config.js.map +1 -1
  65. package/dist/api-schemas/memories.d.ts +84 -0
  66. package/dist/api-schemas/memories.d.ts.map +1 -0
  67. package/dist/api-schemas/memories.js +54 -0
  68. package/dist/api-schemas/memories.js.map +1 -0
  69. package/dist/api-schemas/messages.d.ts +1 -0
  70. package/dist/api-schemas/messages.d.ts.map +1 -1
  71. package/dist/api-schemas/messages.js +4 -4
  72. package/dist/api-schemas/messages.js.map +1 -1
  73. package/dist/api-schemas/models.d.ts +156 -0
  74. package/dist/api-schemas/models.d.ts.map +1 -1
  75. package/dist/api-schemas/models.js +51 -6
  76. package/dist/api-schemas/models.js.map +1 -1
  77. package/dist/api-schemas/nodes.d.ts +97 -0
  78. package/dist/api-schemas/nodes.d.ts.map +1 -1
  79. package/dist/api-schemas/nodes.js +89 -0
  80. package/dist/api-schemas/nodes.js.map +1 -1
  81. package/dist/api-schemas/projects.d.ts +427 -0
  82. package/dist/api-schemas/projects.d.ts.map +1 -0
  83. package/dist/api-schemas/projects.js +224 -0
  84. package/dist/api-schemas/projects.js.map +1 -0
  85. package/dist/api-schemas/recipes.d.ts +172 -0
  86. package/dist/api-schemas/recipes.d.ts.map +1 -0
  87. package/dist/api-schemas/recipes.js +144 -0
  88. package/dist/api-schemas/recipes.js.map +1 -0
  89. package/dist/api-schemas/resources.d.ts +112 -0
  90. package/dist/api-schemas/resources.d.ts.map +1 -0
  91. package/dist/api-schemas/resources.js +44 -0
  92. package/dist/api-schemas/resources.js.map +1 -0
  93. package/dist/api-schemas/scripts.d.ts +1571 -0
  94. package/dist/api-schemas/scripts.d.ts.map +1 -0
  95. package/dist/api-schemas/scripts.js +153 -0
  96. package/dist/api-schemas/scripts.js.map +1 -0
  97. package/dist/api-schemas/sdk-execution-v1.d.ts +467 -0
  98. package/dist/api-schemas/sdk-execution-v1.d.ts.map +1 -0
  99. package/dist/api-schemas/sdk-execution-v1.js +115 -0
  100. package/dist/api-schemas/sdk-execution-v1.js.map +1 -0
  101. package/dist/api-schemas/sdk-lifecycle-v1.d.ts +217 -0
  102. package/dist/api-schemas/sdk-lifecycle-v1.d.ts.map +1 -0
  103. package/dist/api-schemas/sdk-lifecycle-v1.js +117 -0
  104. package/dist/api-schemas/sdk-lifecycle-v1.js.map +1 -0
  105. package/dist/api-schemas/sdk-models-v1.d.ts +181 -0
  106. package/dist/api-schemas/sdk-models-v1.d.ts.map +1 -0
  107. package/dist/api-schemas/sdk-models-v1.js +108 -0
  108. package/dist/api-schemas/sdk-models-v1.js.map +1 -0
  109. package/dist/api-schemas/sdk-v1-http-operations.d.ts +941 -0
  110. package/dist/api-schemas/sdk-v1-http-operations.d.ts.map +1 -0
  111. package/dist/api-schemas/sdk-v1-http-operations.js +465 -0
  112. package/dist/api-schemas/sdk-v1-http-operations.js.map +1 -0
  113. package/dist/api-schemas/sdk-v1-operations.d.ts +151 -0
  114. package/dist/api-schemas/sdk-v1-operations.d.ts.map +1 -0
  115. package/dist/api-schemas/sdk-v1-operations.js +97 -0
  116. package/dist/api-schemas/sdk-v1-operations.js.map +1 -0
  117. package/dist/api-schemas/sdk-v1-websocket-operations.d.ts +97 -0
  118. package/dist/api-schemas/sdk-v1-websocket-operations.d.ts.map +1 -0
  119. package/dist/api-schemas/sdk-v1-websocket-operations.js +96 -0
  120. package/dist/api-schemas/sdk-v1-websocket-operations.js.map +1 -0
  121. package/dist/api-schemas/sdk-v1.d.ts +15 -0
  122. package/dist/api-schemas/sdk-v1.d.ts.map +1 -0
  123. package/dist/api-schemas/sdk-v1.js +22 -0
  124. package/dist/api-schemas/sdk-v1.js.map +1 -0
  125. package/dist/api-schemas/segmentation.d.ts +75 -0
  126. package/dist/api-schemas/segmentation.d.ts.map +1 -0
  127. package/dist/api-schemas/segmentation.js +54 -0
  128. package/dist/api-schemas/segmentation.js.map +1 -0
  129. package/dist/api-schemas/settings.d.ts +159 -0
  130. package/dist/api-schemas/settings.d.ts.map +1 -1
  131. package/dist/api-schemas/settings.js +70 -0
  132. package/dist/api-schemas/settings.js.map +1 -1
  133. package/dist/api-schemas/sketch.d.ts +847 -0
  134. package/dist/api-schemas/sketch.d.ts.map +1 -0
  135. package/dist/api-schemas/sketch.js +544 -0
  136. package/dist/api-schemas/sketch.js.map +1 -0
  137. package/dist/api-schemas/skills.d.ts +27 -14
  138. package/dist/api-schemas/skills.d.ts.map +1 -1
  139. package/dist/api-schemas/skills.js +64 -11
  140. package/dist/api-schemas/skills.js.map +1 -1
  141. package/dist/api-schemas/storage.d.ts +8 -0
  142. package/dist/api-schemas/storage.d.ts.map +1 -1
  143. package/dist/api-schemas/storage.js +7 -0
  144. package/dist/api-schemas/storage.js.map +1 -1
  145. package/dist/api-schemas/storyboards.d.ts +7026 -0
  146. package/dist/api-schemas/storyboards.d.ts.map +1 -0
  147. package/dist/api-schemas/storyboards.js +393 -0
  148. package/dist/api-schemas/storyboards.js.map +1 -0
  149. package/dist/api-schemas/threads.d.ts +12 -4
  150. package/dist/api-schemas/threads.d.ts.map +1 -1
  151. package/dist/api-schemas/threads.js +12 -4
  152. package/dist/api-schemas/threads.js.map +1 -1
  153. package/dist/api-schemas/timeline-tool-contracts.d.ts +1650 -0
  154. package/dist/api-schemas/timeline-tool-contracts.d.ts.map +1 -0
  155. package/dist/api-schemas/timeline-tool-contracts.js +725 -0
  156. package/dist/api-schemas/timeline-tool-contracts.js.map +1 -0
  157. package/dist/api-schemas/timeline-tool-params.d.ts +1237 -0
  158. package/dist/api-schemas/timeline-tool-params.d.ts.map +1 -0
  159. package/dist/api-schemas/timeline-tool-params.js +1518 -0
  160. package/dist/api-schemas/timeline-tool-params.js.map +1 -0
  161. package/dist/api-schemas/timeline.d.ts +12803 -0
  162. package/dist/api-schemas/timeline.d.ts.map +1 -0
  163. package/dist/api-schemas/timeline.js +1838 -0
  164. package/dist/api-schemas/timeline.js.map +1 -0
  165. package/dist/api-schemas/ui-tool-contract.d.ts +35 -0
  166. package/dist/api-schemas/ui-tool-contract.d.ts.map +1 -0
  167. package/dist/api-schemas/ui-tool-contract.js +31 -0
  168. package/dist/api-schemas/ui-tool-contract.js.map +1 -0
  169. package/dist/api-schemas/workflows.d.ts +852 -18
  170. package/dist/api-schemas/workflows.d.ts.map +1 -1
  171. package/dist/api-schemas/workflows.js +484 -6
  172. package/dist/api-schemas/workflows.js.map +1 -1
  173. package/dist/api-schemas/workspace.d.ts +45 -0
  174. package/dist/api-schemas/workspace.d.ts.map +1 -1
  175. package/dist/api-schemas/workspace.js +47 -1
  176. package/dist/api-schemas/workspace.js.map +1 -1
  177. package/dist/api-types.d.ts +621 -27
  178. package/dist/api-types.d.ts.map +1 -1
  179. package/dist/api-types.js +246 -1
  180. package/dist/api-types.js.map +1 -1
  181. package/dist/app-deployment.d.ts +37 -0
  182. package/dist/app-deployment.d.ts.map +1 -0
  183. package/dist/app-deployment.js +42 -0
  184. package/dist/app-deployment.js.map +1 -0
  185. package/dist/asset-generation.d.ts +58 -0
  186. package/dist/asset-generation.d.ts.map +1 -0
  187. package/dist/asset-generation.js +147 -0
  188. package/dist/asset-generation.js.map +1 -0
  189. package/dist/blend-modes.d.ts +20 -0
  190. package/dist/blend-modes.d.ts.map +1 -0
  191. package/dist/blend-modes.js +33 -0
  192. package/dist/blend-modes.js.map +1 -0
  193. package/dist/bridge-frames.d.ts +654 -0
  194. package/dist/bridge-frames.d.ts.map +1 -0
  195. package/dist/bridge-frames.js +448 -0
  196. package/dist/bridge-frames.js.map +1 -0
  197. package/dist/bridge-frames.schema.json +862 -0
  198. package/dist/bridge-protocol.d.ts +57 -20
  199. package/dist/bridge-protocol.d.ts.map +1 -1
  200. package/dist/bridge-protocol.js +57 -20
  201. package/dist/bridge-protocol.js.map +1 -1
  202. package/dist/builtin-packs.d.ts +45 -0
  203. package/dist/builtin-packs.d.ts.map +1 -0
  204. package/dist/builtin-packs.js +115 -0
  205. package/dist/builtin-packs.js.map +1 -0
  206. package/dist/caption-word.d.ts +15 -0
  207. package/dist/caption-word.d.ts.map +1 -0
  208. package/dist/caption-word.js +10 -0
  209. package/dist/caption-word.js.map +1 -0
  210. package/dist/cloud-profile.d.ts +187 -0
  211. package/dist/cloud-profile.d.ts.map +1 -0
  212. package/dist/cloud-profile.js +281 -0
  213. package/dist/cloud-profile.js.map +1 -0
  214. package/dist/creative.d.ts +486 -0
  215. package/dist/creative.d.ts.map +1 -0
  216. package/dist/creative.js +269 -0
  217. package/dist/creative.js.map +1 -0
  218. package/dist/custom-providers.d.ts +70 -0
  219. package/dist/custom-providers.d.ts.map +1 -0
  220. package/dist/custom-providers.js +125 -0
  221. package/dist/custom-providers.js.map +1 -0
  222. package/dist/document-ops.d.ts +15 -0
  223. package/dist/document-ops.d.ts.map +1 -0
  224. package/dist/document-ops.js +2 -0
  225. package/dist/document-ops.js.map +1 -0
  226. package/dist/game-assets.d.ts +344 -0
  227. package/dist/game-assets.d.ts.map +1 -0
  228. package/dist/game-assets.js +297 -0
  229. package/dist/game-assets.js.map +1 -0
  230. package/dist/game-design.d.ts +90 -0
  231. package/dist/game-design.d.ts.map +1 -0
  232. package/dist/game-design.js +417 -0
  233. package/dist/game-design.js.map +1 -0
  234. package/dist/game-flow-prompt.d.ts +68 -0
  235. package/dist/game-flow-prompt.d.ts.map +1 -0
  236. package/dist/game-flow-prompt.js +121 -0
  237. package/dist/game-flow-prompt.js.map +1 -0
  238. package/dist/game-graph.d.ts +96 -0
  239. package/dist/game-graph.d.ts.map +1 -0
  240. package/dist/game-graph.js +481 -0
  241. package/dist/game-graph.js.map +1 -0
  242. package/dist/game-migration.d.ts +4 -0
  243. package/dist/game-migration.d.ts.map +1 -0
  244. package/dist/game-migration.js +6 -0
  245. package/dist/game-migration.js.map +1 -0
  246. package/dist/game-slot-prompt.d.ts +90 -0
  247. package/dist/game-slot-prompt.d.ts.map +1 -0
  248. package/dist/game-slot-prompt.js +237 -0
  249. package/dist/game-slot-prompt.js.map +1 -0
  250. package/dist/game.d.ts +1663 -0
  251. package/dist/game.d.ts.map +1 -0
  252. package/dist/game.js +228 -0
  253. package/dist/game.js.map +1 -0
  254. package/dist/graph.d.ts +191 -5
  255. package/dist/graph.d.ts.map +1 -1
  256. package/dist/graph.js +497 -0
  257. package/dist/graph.js.map +1 -1
  258. package/dist/index.d.ts +47 -2
  259. package/dist/index.d.ts.map +1 -1
  260. package/dist/index.js +46 -2
  261. package/dist/index.js.map +1 -1
  262. package/dist/loop.d.ts +38 -0
  263. package/dist/loop.d.ts.map +1 -0
  264. package/dist/loop.js +69 -0
  265. package/dist/loop.js.map +1 -0
  266. package/dist/mcp-server-config.d.ts +113 -0
  267. package/dist/mcp-server-config.d.ts.map +1 -0
  268. package/dist/mcp-server-config.js +147 -0
  269. package/dist/mcp-server-config.js.map +1 -0
  270. package/dist/messages.d.ts +1565 -243
  271. package/dist/messages.d.ts.map +1 -1
  272. package/dist/messages.js +709 -22
  273. package/dist/messages.js.map +1 -1
  274. package/dist/model-selection.d.ts +20 -0
  275. package/dist/model-selection.d.ts.map +1 -0
  276. package/dist/model-selection.js +27 -0
  277. package/dist/model-selection.js.map +1 -0
  278. package/dist/nodetool-models.d.ts +71 -0
  279. package/dist/nodetool-models.d.ts.map +1 -0
  280. package/dist/nodetool-models.js +138 -0
  281. package/dist/nodetool-models.js.map +1 -0
  282. package/dist/package-assets.d.ts +39 -0
  283. package/dist/package-assets.d.ts.map +1 -0
  284. package/dist/package-assets.js +63 -0
  285. package/dist/package-assets.js.map +1 -0
  286. package/dist/platform.d.ts +66 -0
  287. package/dist/platform.d.ts.map +1 -0
  288. package/dist/platform.js +68 -0
  289. package/dist/platform.js.map +1 -0
  290. package/dist/predicates.d.ts +43 -0
  291. package/dist/predicates.d.ts.map +1 -0
  292. package/dist/predicates.js +65 -0
  293. package/dist/predicates.js.map +1 -0
  294. package/dist/processing-messages.schema.json +2525 -0
  295. package/dist/production-authoring.d.ts +757 -0
  296. package/dist/production-authoring.d.ts.map +1 -0
  297. package/dist/production-authoring.js +736 -0
  298. package/dist/production-authoring.js.map +1 -0
  299. package/dist/render-record.d.ts +86 -0
  300. package/dist/render-record.d.ts.map +1 -0
  301. package/dist/render-record.js +133 -0
  302. package/dist/render-record.js.map +1 -0
  303. package/dist/resource-id.d.ts +22 -0
  304. package/dist/resource-id.d.ts.map +1 -0
  305. package/dist/resource-id.js +32 -0
  306. package/dist/resource-id.js.map +1 -0
  307. package/dist/resource-uri.d.ts +15 -0
  308. package/dist/resource-uri.d.ts.map +1 -0
  309. package/dist/resource-uri.js +88 -0
  310. package/dist/resource-uri.js.map +1 -0
  311. package/dist/sandbox-capability.d.ts +86 -0
  312. package/dist/sandbox-capability.d.ts.map +1 -0
  313. package/dist/sandbox-capability.js +106 -0
  314. package/dist/sandbox-capability.js.map +1 -0
  315. package/dist/sandbox-host.d.ts +98 -0
  316. package/dist/sandbox-host.d.ts.map +1 -0
  317. package/dist/sandbox-host.js +311 -0
  318. package/dist/sandbox-host.js.map +1 -0
  319. package/dist/sandbox-package.d.ts +674 -0
  320. package/dist/sandbox-package.d.ts.map +1 -0
  321. package/dist/sandbox-package.js +622 -0
  322. package/dist/sandbox-package.js.map +1 -0
  323. package/dist/sandbox-wasm.d.ts +84 -0
  324. package/dist/sandbox-wasm.d.ts.map +1 -0
  325. package/dist/sandbox-wasm.js +139 -0
  326. package/dist/sandbox-wasm.js.map +1 -0
  327. package/dist/screenplay-authoring.d.ts +69 -0
  328. package/dist/screenplay-authoring.d.ts.map +1 -0
  329. package/dist/screenplay-authoring.js +351 -0
  330. package/dist/screenplay-authoring.js.map +1 -0
  331. package/dist/script-authoring.d.ts +161 -0
  332. package/dist/script-authoring.d.ts.map +1 -0
  333. package/dist/script-authoring.js +503 -0
  334. package/dist/script-authoring.js.map +1 -0
  335. package/dist/script-fill.d.ts +39 -0
  336. package/dist/script-fill.d.ts.map +1 -0
  337. package/dist/script-fill.js +67 -0
  338. package/dist/script-fill.js.map +1 -0
  339. package/dist/script-link.d.ts +110 -0
  340. package/dist/script-link.d.ts.map +1 -0
  341. package/dist/script-link.js +252 -0
  342. package/dist/script-link.js.map +1 -0
  343. package/dist/sha256.d.ts +11 -0
  344. package/dist/sha256.d.ts.map +1 -0
  345. package/dist/sha256.js +110 -0
  346. package/dist/sha256.js.map +1 -0
  347. package/dist/shot-prompt.d.ts +78 -0
  348. package/dist/shot-prompt.d.ts.map +1 -0
  349. package/dist/shot-prompt.js +120 -0
  350. package/dist/shot-prompt.js.map +1 -0
  351. package/dist/skill-document.d.ts +36 -0
  352. package/dist/skill-document.d.ts.map +1 -0
  353. package/dist/skill-document.js +137 -0
  354. package/dist/skill-document.js.map +1 -0
  355. package/dist/style-presets.d.ts +73 -0
  356. package/dist/style-presets.d.ts.map +1 -0
  357. package/dist/style-presets.js +147 -0
  358. package/dist/style-presets.js.map +1 -0
  359. package/dist/supervisor.d.ts +227 -0
  360. package/dist/supervisor.d.ts.map +1 -0
  361. package/dist/supervisor.js +116 -0
  362. package/dist/supervisor.js.map +1 -0
  363. package/dist/token-providers.d.ts +31 -0
  364. package/dist/token-providers.d.ts.map +1 -0
  365. package/dist/token-providers.js +52 -0
  366. package/dist/token-providers.js.map +1 -0
  367. package/dist/toolSchemas.d.ts +10 -14
  368. package/dist/toolSchemas.d.ts.map +1 -1
  369. package/dist/toolSchemas.js +13 -23
  370. package/dist/toolSchemas.js.map +1 -1
  371. package/dist/triggers.d.ts +41 -0
  372. package/dist/triggers.d.ts.map +1 -0
  373. package/dist/triggers.js +50 -0
  374. package/dist/triggers.js.map +1 -0
  375. package/dist/trpc-policy.d.ts +3 -0
  376. package/dist/trpc-policy.d.ts.map +1 -0
  377. package/dist/trpc-policy.js +3 -0
  378. package/dist/trpc-policy.js.map +1 -0
  379. package/dist/type-metadata.d.ts +5 -0
  380. package/dist/type-metadata.d.ts.map +1 -1
  381. package/dist/type-metadata.js +17 -8
  382. package/dist/type-metadata.js.map +1 -1
  383. package/dist/typecheck.d.ts.map +1 -1
  384. package/dist/typecheck.js +5 -4
  385. package/dist/typecheck.js.map +1 -1
  386. package/dist/wasm-binary.d.ts +61 -0
  387. package/dist/wasm-binary.d.ts.map +1 -0
  388. package/dist/wasm-binary.js +215 -0
  389. package/dist/wasm-binary.js.map +1 -0
  390. package/dist/workflow-plan.d.ts +197 -0
  391. package/dist/workflow-plan.d.ts.map +1 -0
  392. package/dist/workflow-plan.js +438 -0
  393. package/dist/workflow-plan.js.map +1 -0
  394. package/dist/wrap-primitives.d.ts +0 -11
  395. package/dist/wrap-primitives.d.ts.map +1 -1
  396. package/dist/wrap-primitives.js +3 -9
  397. package/dist/wrap-primitives.js.map +1 -1
  398. package/dist/ws-commands.d.ts +665 -0
  399. package/dist/ws-commands.d.ts.map +1 -0
  400. package/dist/ws-commands.js +610 -0
  401. package/dist/ws-commands.js.map +1 -0
  402. package/dist/zod-schema.d.ts +20 -0
  403. package/dist/zod-schema.d.ts.map +1 -0
  404. package/dist/zod-schema.js +298 -0
  405. package/dist/zod-schema.js.map +1 -0
  406. package/package.json +84 -7
  407. package/schema/sdk-v1.asyncapi.implemented.json +65 -0
  408. package/schema/sdk-v1.asyncapi.json +65 -0
  409. package/schema/sdk-v1.discovery.schema.json +1218 -0
  410. package/schema/sdk-v1.execution.schema.json +2792 -0
  411. package/schema/sdk-v1.lifecycle.schema.json +1031 -0
  412. package/schema/sdk-v1.manifest.json +71 -0
  413. package/schema/sdk-v1.openapi.implemented.json +730 -0
  414. package/schema/sdk-v1.openapi.json +730 -0
  415. package/schema/sdk-v1.operations.json +732 -0
  416. package/dist/agent-protocol.d.ts +0 -217
  417. package/dist/agent-protocol.d.ts.map +0 -1
  418. package/dist/agent-protocol.js +0 -85
  419. package/dist/agent-protocol.js.map +0 -1
@@ -0,0 +1,736 @@
1
+ import { z } from "zod";
2
+ import { captionWord } from "./caption-word.js";
3
+ import { isObjectLike } from "./predicates.js";
4
+ /** Version for the optional production authoring fields. */
5
+ export const PRODUCTION_AUTHORING_SCHEMA_VERSION = 1;
6
+ /** Version for the immutable inputs captured before a generation dispatch. */
7
+ export const PRODUCTION_SNAPSHOT_SCHEMA_VERSION = 1;
8
+ const identifier = z.string().trim().min(1);
9
+ const nonEmptyText = z.string().trim().min(1);
10
+ export const productionReferenceKind = z.enum([
11
+ "product",
12
+ "character",
13
+ "location",
14
+ "style"
15
+ ]);
16
+ /** An asset binding. Authorization is checked by the server resolving it. */
17
+ export const productionReferenceBinding = z
18
+ .object({
19
+ kind: productionReferenceKind,
20
+ asset_id: identifier,
21
+ entity_id: identifier.optional(),
22
+ label: nonEmptyText.optional()
23
+ })
24
+ .passthrough();
25
+ /** An explicit media reference and the revision used to direct a take. */
26
+ export const productionReference = z
27
+ .object({
28
+ uri: nonEmptyText,
29
+ name: nonEmptyText.optional(),
30
+ revision: nonEmptyText.optional()
31
+ })
32
+ .passthrough();
33
+ /** Creative context shared by the existing Video, Storyboard, and Script documents. */
34
+ export const creativeContext = z
35
+ .object({
36
+ schema_version: z
37
+ .literal(PRODUCTION_AUTHORING_SCHEMA_VERSION)
38
+ .default(PRODUCTION_AUTHORING_SCHEMA_VERSION),
39
+ product_name: nonEmptyText.optional(),
40
+ product_description: nonEmptyText.optional(),
41
+ audience: nonEmptyText.optional(),
42
+ objective: nonEmptyText.optional(),
43
+ tone: nonEmptyText.optional(),
44
+ approved_claims: z.array(nonEmptyText).max(64).optional(),
45
+ prohibited_claims: z.array(nonEmptyText).max(64).optional(),
46
+ reference_bindings: z.array(productionReferenceBinding).max(32).optional(),
47
+ origin: z
48
+ .object({
49
+ document_id: identifier,
50
+ document_kind: z.enum(["timeline", "storyboard", "script"]),
51
+ authoring_fingerprint: identifier.optional()
52
+ })
53
+ .optional()
54
+ })
55
+ .passthrough();
56
+ export const productionEditorialPurpose = z.enum([
57
+ "hook",
58
+ "problem",
59
+ "demonstration",
60
+ "proof",
61
+ "cta",
62
+ "story"
63
+ ]);
64
+ export const productionVisualTreatment = z.enum([
65
+ "actor_to_camera",
66
+ "product_close_up",
67
+ "lifestyle_b_roll",
68
+ "generated_scene"
69
+ ]);
70
+ export const productionSpeechMode = z.enum(["none", "off_camera", "on_camera"]);
71
+ /** Local or linked speech context. The Script still owns linked line text. */
72
+ export const productionSpeechBinding = z
73
+ .object({
74
+ script_line_id: identifier.optional(),
75
+ speaker_id: identifier.optional(),
76
+ text: nonEmptyText.optional(),
77
+ direction: nonEmptyText.optional(),
78
+ audio_asset_id: identifier.optional(),
79
+ /** Unresolved voice selection carried by older clients. */
80
+ voice_id: identifier.optional(),
81
+ voice: z
82
+ .object({
83
+ provider: identifier,
84
+ model: identifier,
85
+ voice: identifier,
86
+ settings: z.record(z.string(), z.unknown()).optional()
87
+ })
88
+ .passthrough()
89
+ .optional()
90
+ })
91
+ .passthrough()
92
+ .superRefine((binding, context) => {
93
+ if (binding.script_line_id !== undefined && binding.text !== undefined) {
94
+ context.addIssue({
95
+ code: "custom",
96
+ path: ["text"],
97
+ message: "Linked speech text is owned by the Script line."
98
+ });
99
+ }
100
+ if (binding.script_line_id === undefined &&
101
+ binding.text === undefined &&
102
+ binding.audio_asset_id === undefined) {
103
+ context.addIssue({
104
+ code: "custom",
105
+ message: "Speech binding needs script_line_id, text, or audio_asset_id."
106
+ });
107
+ }
108
+ });
109
+ /** Editable production intent attached to one timeline beat or storyboard shot. */
110
+ export const productionRequirement = z
111
+ .object({
112
+ schema_version: z
113
+ .literal(PRODUCTION_AUTHORING_SCHEMA_VERSION)
114
+ .default(PRODUCTION_AUTHORING_SCHEMA_VERSION),
115
+ editorial_purpose: productionEditorialPurpose.optional(),
116
+ visual_treatment: productionVisualTreatment.optional(),
117
+ speech_mode: productionSpeechMode.default("none"),
118
+ speech_binding: productionSpeechBinding.optional(),
119
+ reference_bindings: z.array(productionReferenceBinding).max(32).optional(),
120
+ references: z.array(productionReference).max(32).optional(),
121
+ duration_ms: z.number().int().positive().optional(),
122
+ speech_duration_ms: z.number().int().positive().optional(),
123
+ local_direction: nonEmptyText.optional(),
124
+ requested_take_count: z.number().int().min(1).max(3).default(1)
125
+ })
126
+ .passthrough()
127
+ .superRefine((requirement, context) => {
128
+ if (requirement.speech_mode === "none" &&
129
+ requirement.speech_binding !== undefined) {
130
+ context.addIssue({
131
+ code: "custom",
132
+ path: ["speech_binding"],
133
+ message: "speech_binding is only valid when speech_mode is enabled."
134
+ });
135
+ }
136
+ if (requirement.speech_mode !== "none" &&
137
+ requirement.speech_binding === undefined) {
138
+ context.addIssue({
139
+ code: "custom",
140
+ path: ["speech_binding"],
141
+ message: "Speech modes other than none need speech_binding."
142
+ });
143
+ }
144
+ });
145
+ export const productionDestinationKind = z.enum([
146
+ "timeline_clip",
147
+ "storyboard_shot",
148
+ "script_line"
149
+ ]);
150
+ export const productionOperation = z.enum([
151
+ "initial_generation",
152
+ "new_take",
153
+ "change_line_delivery",
154
+ "edit_video"
155
+ ]);
156
+ /** Source-local milliseconds, with unused handles outside the playable window. */
157
+ export const productionPlayableWindow = z
158
+ .object({
159
+ startMs: z.number().nonnegative(),
160
+ endMs: z.number().positive()
161
+ })
162
+ .refine((window) => window.endMs > window.startMs, {
163
+ path: ["endMs"],
164
+ message: "The playable window must have positive duration."
165
+ });
166
+ /** Measured outputs belong to the result, never the submitted snapshot. */
167
+ export const productionCandidateResult = z
168
+ .object({
169
+ sourceDurationMs: z.number().positive(),
170
+ playableWindow: productionPlayableWindow,
171
+ audio: z
172
+ .object({
173
+ assetId: identifier,
174
+ durationMs: z.number().positive(),
175
+ /** Choose one playback source to avoid playing embedded speech twice. */
176
+ playback: z.enum(["embedded", "separate"]),
177
+ /** Relative to the audio start, aligned with the playable window start. */
178
+ words: z.array(captionWord)
179
+ })
180
+ .optional()
181
+ })
182
+ .superRefine((result, context) => {
183
+ if (result.playableWindow.endMs > result.sourceDurationMs) {
184
+ context.addIssue({
185
+ code: "custom",
186
+ path: ["playableWindow"],
187
+ message: "The playable window exceeds the source duration."
188
+ });
189
+ }
190
+ if (result.audio) {
191
+ const duration = result.playableWindow.endMs - result.playableWindow.startMs;
192
+ if (result.audio.durationMs > duration) {
193
+ context.addIssue({
194
+ code: "custom",
195
+ path: ["audio", "durationMs"],
196
+ message: "Speech must fit without truncation."
197
+ });
198
+ }
199
+ for (const [index, word] of result.audio.words.entries()) {
200
+ if (word.startMs < 0 ||
201
+ word.endMs < word.startMs ||
202
+ word.endMs > result.audio.durationMs) {
203
+ context.addIssue({
204
+ code: "custom",
205
+ path: ["audio", "words", index],
206
+ message: "Word timing must lie within the authoritative audio."
207
+ });
208
+ }
209
+ }
210
+ }
211
+ });
212
+ const productionSourceContext = z
213
+ .object({
214
+ sequenceId: identifier,
215
+ clipId: identifier,
216
+ sourceAssetId: identifier,
217
+ sourceTakeId: identifier.optional(),
218
+ sourceStartMs: z.number().nonnegative(),
219
+ sourceEndMs: z.number().positive(),
220
+ timelineStartMs: z.number().nonnegative(),
221
+ timelineDurationMs: z.number().positive(),
222
+ speedMultiplier: z.number().positive()
223
+ })
224
+ .refine((source) => source.sourceEndMs > source.sourceStartMs, {
225
+ path: ["sourceEndMs"],
226
+ message: "The edit source window must have positive duration."
227
+ });
228
+ /** Frozen inputs for one candidate, captured before provider dispatch. */
229
+ export const productionGenerationSnapshot = z
230
+ .object({
231
+ schemaVersion: z
232
+ .literal(PRODUCTION_SNAPSHOT_SCHEMA_VERSION)
233
+ .default(PRODUCTION_SNAPSHOT_SCHEMA_VERSION),
234
+ batchId: identifier,
235
+ requestId: identifier,
236
+ candidateId: identifier,
237
+ variationId: identifier,
238
+ variationIndex: z.number().int().min(1).max(3),
239
+ destinationKind: productionDestinationKind,
240
+ destinationId: identifier,
241
+ ownerId: identifier.optional(),
242
+ projectId: identifier.optional(),
243
+ documentId: identifier.optional(),
244
+ targetVersion: z.number().int().nonnegative().optional(),
245
+ originatingBeatId: identifier.optional(),
246
+ originatingShotId: identifier.optional(),
247
+ operation: productionOperation,
248
+ authoringFingerprint: identifier.optional(),
249
+ entityIds: z.array(identifier).optional(),
250
+ referenceAssetIds: z.array(identifier).optional(),
251
+ references: z
252
+ .array(z.object({
253
+ kind: productionReferenceKind,
254
+ assetId: identifier,
255
+ entityId: identifier.optional(),
256
+ descriptor: nonEmptyText,
257
+ revision: identifier.optional()
258
+ }))
259
+ .optional(),
260
+ requiredCapabilities: z.array(identifier).min(1).optional(),
261
+ executionRoute: identifier.optional(),
262
+ prompt: nonEmptyText.optional(),
263
+ speech: z
264
+ .object({
265
+ text: nonEmptyText.optional(),
266
+ direction: nonEmptyText.optional(),
267
+ voice: z.record(z.string(), z.json()).optional(),
268
+ audioAssetId: identifier.optional(),
269
+ scriptId: identifier.optional(),
270
+ scriptLineId: identifier.optional(),
271
+ speakerId: identifier.optional(),
272
+ takeId: identifier.optional(),
273
+ durationMs: z.number().positive().optional()
274
+ })
275
+ .catchall(z.json())
276
+ .optional(),
277
+ provider: identifier.optional(),
278
+ model: identifier.optional(),
279
+ parameters: z.record(z.string(), z.json()).optional(),
280
+ outputFormat: z.string().trim().min(1).optional(),
281
+ requestedDurationMs: z.number().int().positive().optional(),
282
+ playableWindow: productionPlayableWindow.optional(),
283
+ parentTakeId: identifier.optional(),
284
+ sourceContext: productionSourceContext.optional()
285
+ })
286
+ .catchall(z.json())
287
+ .superRefine((snapshot, context) => {
288
+ if (snapshot.playableWindow &&
289
+ snapshot.requestedDurationMs !== undefined &&
290
+ snapshot.playableWindow.endMs - snapshot.playableWindow.startMs !==
291
+ snapshot.requestedDurationMs) {
292
+ context.addIssue({
293
+ code: "custom",
294
+ path: ["playableWindow"],
295
+ message: "The playable window must cover the requested duration without stretching."
296
+ });
297
+ }
298
+ if (snapshot.speech?.durationMs !== undefined &&
299
+ snapshot.requestedDurationMs !== undefined &&
300
+ snapshot.speech.durationMs > snapshot.requestedDurationMs) {
301
+ context.addIssue({
302
+ code: "custom",
303
+ path: ["speech", "durationMs"],
304
+ message: "Speech must fit before dependent video dispatch."
305
+ });
306
+ }
307
+ });
308
+ /** Capture complete dispatch inputs. Legacy partial records remain readable. */
309
+ export function captureProductionGenerationSnapshot(input) {
310
+ const snapshot = productionGenerationSnapshot
311
+ .safeExtend({
312
+ ownerId: identifier,
313
+ projectId: identifier,
314
+ documentId: identifier,
315
+ authoringFingerprint: identifier,
316
+ prompt: nonEmptyText,
317
+ provider: identifier,
318
+ model: identifier,
319
+ requiredCapabilities: z.array(identifier).min(1),
320
+ executionRoute: identifier,
321
+ outputFormat: nonEmptyText,
322
+ requestedDurationMs: z.number().int().positive(),
323
+ playableWindow: productionPlayableWindow
324
+ })
325
+ .parse(input);
326
+ productionVariationIdentitySchema.parse(snapshot);
327
+ if (snapshot.operation === "edit_video" &&
328
+ (!snapshot.parentTakeId || !snapshot.sourceContext)) {
329
+ throw new Error("Edit video requires a parent take and source context.");
330
+ }
331
+ if (snapshot.executionRoute === "audio_driven_performance" &&
332
+ (!snapshot.speech?.audioAssetId ||
333
+ !snapshot.speech.text ||
334
+ snapshot.speech.durationMs === undefined)) {
335
+ throw new Error("An audio-driven performance requires resolved speech audio and timing.");
336
+ }
337
+ const captured = structuredClone(snapshot);
338
+ freezeSnapshotValue(captured);
339
+ return captured;
340
+ }
341
+ function freezeSnapshotValue(value) {
342
+ if (!isObjectLike(value)) {
343
+ return;
344
+ }
345
+ for (const child of Object.values(value)) {
346
+ freezeSnapshotValue(child);
347
+ }
348
+ Object.freeze(value);
349
+ }
350
+ export const productionCandidateStatus = z.enum([
351
+ "planned",
352
+ "queued",
353
+ "generating",
354
+ "ready",
355
+ "failed",
356
+ "cancelled"
357
+ ]);
358
+ export const productionVariationIdentitySchema = z
359
+ .object({
360
+ batchId: identifier,
361
+ destinationKind: productionDestinationKind,
362
+ destinationId: identifier,
363
+ variationIndex: z.number().int().min(1).max(3),
364
+ variationId: identifier,
365
+ candidateId: identifier,
366
+ requestId: identifier
367
+ })
368
+ .superRefine((identity, context) => {
369
+ const expectedVariationId = [
370
+ "variation",
371
+ identity.batchId,
372
+ identity.destinationKind,
373
+ identity.destinationId,
374
+ identity.variationIndex
375
+ ].join(":");
376
+ if (identity.variationId !== expectedVariationId) {
377
+ context.addIssue({
378
+ code: "custom",
379
+ path: ["variationId"],
380
+ message: "variationId must be derived from the variation identity."
381
+ });
382
+ }
383
+ if (identity.candidateId !== `candidate:${expectedVariationId}`) {
384
+ context.addIssue({
385
+ code: "custom",
386
+ path: ["candidateId"],
387
+ message: "candidateId must be derived from variationId."
388
+ });
389
+ }
390
+ if (identity.requestId !== `request:${identity.candidateId}`) {
391
+ context.addIssue({
392
+ code: "custom",
393
+ path: ["requestId"],
394
+ message: "requestId must be derived from candidateId."
395
+ });
396
+ }
397
+ });
398
+ /**
399
+ * Build deterministic identities before provider dispatch. Provider task ids
400
+ * are deliberately not part of this identity because they can change during
401
+ * retries or recovery.
402
+ */
403
+ export function productionVariationIdentity(input) {
404
+ const batchId = input.batchId.trim();
405
+ const destinationId = input.destinationId.trim();
406
+ if (!batchId || !destinationId) {
407
+ throw new Error("batchId and destinationId must be non-empty.");
408
+ }
409
+ if (!Number.isInteger(input.variationIndex) || input.variationIndex < 1) {
410
+ throw new Error("variationIndex must be a positive integer.");
411
+ }
412
+ const variationId = [
413
+ "variation",
414
+ batchId,
415
+ input.destinationKind,
416
+ destinationId,
417
+ input.variationIndex
418
+ ].join(":");
419
+ const candidateId = `candidate:${variationId}`;
420
+ return productionVariationIdentitySchema.parse({
421
+ batchId,
422
+ destinationKind: input.destinationKind,
423
+ destinationId,
424
+ variationIndex: input.variationIndex,
425
+ variationId,
426
+ candidateId,
427
+ requestId: `request:${candidateId}`
428
+ });
429
+ }
430
+ const candidateTransitions = {
431
+ planned: ["queued", "cancelled"],
432
+ queued: ["generating", "cancelled"],
433
+ generating: ["ready", "failed", "cancelled"],
434
+ ready: [],
435
+ failed: [],
436
+ cancelled: []
437
+ };
438
+ /** Whether a candidate may move from one lifecycle state to another. */
439
+ export function canTransitionProductionCandidate(from, to) {
440
+ return candidateTransitions[from].includes(to);
441
+ }
442
+ /** Whether a candidate has reached a state that cannot be advanced. */
443
+ export function isTerminalProductionCandidateStatus(status) {
444
+ return candidateTransitions[status].length === 0;
445
+ }
446
+ /** Apply a valid lifecycle transition to an already validated candidate. */
447
+ export function transitionProductionCandidate(candidate, status) {
448
+ if (!canTransitionProductionCandidate(candidate.status, status)) {
449
+ throw new Error(`Cannot transition candidate ${candidate.candidateId} from ${candidate.status} to ${status}.`);
450
+ }
451
+ return productionCandidate.parse({ ...candidate, status });
452
+ }
453
+ /** Optional shared context and per-beat/per-shot authoring contracts. */
454
+ export const production = productionRequirement;
455
+ export const creativeContextSchema = creativeContext;
456
+ export const productionSchema = productionRequirement;
457
+ /** Transport record for a candidate before or after it becomes a timeline take. */
458
+ export const productionCandidate = z
459
+ .object({
460
+ candidateId: identifier,
461
+ batchId: identifier,
462
+ requestId: identifier,
463
+ variationId: identifier,
464
+ variationIndex: z.number().int().min(1).max(3),
465
+ destinationKind: productionDestinationKind,
466
+ destinationId: identifier,
467
+ documentId: identifier.optional(),
468
+ targetVersion: z.number().int().nonnegative().optional(),
469
+ status: productionCandidateStatus,
470
+ assetId: identifier.optional(),
471
+ takeId: identifier.optional(),
472
+ error: nonEmptyText.optional(),
473
+ active: z.boolean().default(false),
474
+ accepted: z.boolean().default(false),
475
+ result: productionCandidateResult.optional(),
476
+ /** Absent for legacy candidates without replayable provenance. */
477
+ snapshot: productionGenerationSnapshot.optional()
478
+ })
479
+ .passthrough()
480
+ .superRefine((candidate, context) => {
481
+ const identity = productionVariationIdentitySchema.safeParse({
482
+ ...candidate,
483
+ requestId: `request:${candidate.candidateId}`
484
+ });
485
+ if (!identity.success) {
486
+ for (const issue of identity.error.issues) {
487
+ context.addIssue({
488
+ code: "custom",
489
+ path: issue.path,
490
+ message: issue.message
491
+ });
492
+ }
493
+ }
494
+ if (candidate.snapshot) {
495
+ for (const key of [
496
+ "candidateId",
497
+ "batchId",
498
+ "requestId",
499
+ "variationId",
500
+ "variationIndex",
501
+ "destinationKind",
502
+ "destinationId",
503
+ "documentId",
504
+ "targetVersion"
505
+ ]) {
506
+ if (candidate.snapshot[key] !== candidate[key]) {
507
+ context.addIssue({
508
+ code: "custom",
509
+ path: ["snapshot", key],
510
+ message: "Candidate and snapshot identities must match."
511
+ });
512
+ }
513
+ }
514
+ if (candidate.result &&
515
+ candidate.snapshot.requestedDurationMs !== undefined &&
516
+ candidate.result.playableWindow.endMs -
517
+ candidate.result.playableWindow.startMs !==
518
+ candidate.snapshot.requestedDurationMs) {
519
+ context.addIssue({
520
+ code: "custom",
521
+ path: ["result", "playableWindow"],
522
+ message: "The result must cover the requested duration."
523
+ });
524
+ }
525
+ if (candidate.status === "ready" &&
526
+ candidate.snapshot.requestedDurationMs !== undefined &&
527
+ !candidate.result) {
528
+ context.addIssue({
529
+ code: "custom",
530
+ path: ["result"],
531
+ message: "A ready timed candidate needs measured media."
532
+ });
533
+ }
534
+ if (candidate.result &&
535
+ candidate.snapshot.playableWindow &&
536
+ (candidate.result.playableWindow.startMs !==
537
+ candidate.snapshot.playableWindow.startMs ||
538
+ candidate.result.playableWindow.endMs !==
539
+ candidate.snapshot.playableWindow.endMs)) {
540
+ context.addIssue({
541
+ code: "custom",
542
+ path: ["result", "playableWindow"],
543
+ message: "The result must preserve the submitted source mapping."
544
+ });
545
+ }
546
+ if (candidate.result?.audio &&
547
+ candidate.snapshot.speech?.durationMs !== undefined &&
548
+ candidate.result.audio.durationMs !==
549
+ candidate.snapshot.speech.durationMs) {
550
+ context.addIssue({
551
+ code: "custom",
552
+ path: ["result", "audio", "durationMs"],
553
+ message: "The result must preserve the submitted audio timing."
554
+ });
555
+ }
556
+ if (candidate.snapshot.speech?.audioAssetId &&
557
+ candidate.result?.audio?.assetId !==
558
+ candidate.snapshot.speech.audioAssetId &&
559
+ candidate.status === "ready") {
560
+ context.addIssue({
561
+ code: "custom",
562
+ path: ["result", "audio"],
563
+ message: "The result must identify the submitted authoritative audio."
564
+ });
565
+ }
566
+ }
567
+ if (candidate.accepted !== candidate.active ||
568
+ (candidate.active && candidate.status !== "ready")) {
569
+ context.addIssue({
570
+ code: "custom",
571
+ path: ["active"],
572
+ message: "Only a ready accepted candidate can be active."
573
+ });
574
+ }
575
+ if (candidate.status === "ready" && candidate.assetId === undefined) {
576
+ context.addIssue({
577
+ code: "custom",
578
+ path: ["assetId"],
579
+ message: "A ready candidate needs assetId."
580
+ });
581
+ }
582
+ });
583
+ /** Optional provenance carried by native takes during handoff and persistence. */
584
+ export const productionTakeMetadata = z.object({
585
+ candidateId: identifier.optional(),
586
+ batchId: identifier.optional(),
587
+ requestId: identifier.optional(),
588
+ variationId: identifier.optional(),
589
+ variationIndex: z.number().int().min(1).max(3).optional(),
590
+ productionSnapshot: productionGenerationSnapshot.optional(),
591
+ productionResult: productionCandidateResult.optional()
592
+ });
593
+ /** Landing never activates a result. Repeated delivery preserves acceptance. */
594
+ export function landProductionCandidateInactive(candidate, assetId) {
595
+ const parsed = productionCandidate.parse(candidate);
596
+ const resolvedAssetId = identifier.parse(assetId);
597
+ if (parsed.status === "ready") {
598
+ if (parsed.assetId !== resolvedAssetId) {
599
+ throw new Error("A landed candidate cannot be replaced by a different output.");
600
+ }
601
+ return parsed;
602
+ }
603
+ if (parsed.status === "failed" || parsed.status === "cancelled") {
604
+ throw new Error("A terminal candidate requires an explicit retry.");
605
+ }
606
+ return productionCandidate.parse({
607
+ ...parsed,
608
+ status: "ready",
609
+ assetId: resolvedAssetId
610
+ });
611
+ }
612
+ /** Temporary selection only. Pending selections stay explicit and unresolved. */
613
+ export function selectProductionPreview(candidates, selection, expected) {
614
+ const scoped = candidates.filter((candidate) => candidate.batchId === expected.batchId &&
615
+ candidate.documentId === expected.documentId);
616
+ const byId = new Map(scoped.map((candidate) => [candidate.candidateId, candidate]));
617
+ if (byId.size !== scoped.length) {
618
+ throw new Error("Duplicate candidate identities are ambiguous.");
619
+ }
620
+ const unresolved = new Set(scoped.map((candidate) => candidate.destinationId));
621
+ for (const [destinationId, candidateId] of Object.entries(selection)) {
622
+ const candidate = byId.get(candidateId);
623
+ if (!candidate || candidate.destinationId !== destinationId) {
624
+ throw new Error(`Invalid preview candidate for destination ${destinationId}.`);
625
+ }
626
+ if (candidate.status === "ready" &&
627
+ productionCandidate.safeParse(candidate).success) {
628
+ unresolved.delete(destinationId);
629
+ }
630
+ }
631
+ return {
632
+ ...expected,
633
+ selections: { ...selection },
634
+ unresolvedDestinationIds: [...unresolved]
635
+ };
636
+ }
637
+ /**
638
+ * Validate a complete acceptance selection against the live destinations.
639
+ * Selection keys are checked in both directions so a destination deleted
640
+ * after generation cannot be accepted just because its candidate still exists.
641
+ */
642
+ export function validateProductionAcceptance(input) {
643
+ const byId = new Map(input.candidates.map((candidate) => [candidate.candidateId, candidate]));
644
+ const liveTargets = new Map();
645
+ const liveDestinationIds = new Set();
646
+ const issues = [];
647
+ const selected = [];
648
+ if (Object.keys(input.selection).length === 0) {
649
+ issues.push("A production draft needs at least one candidate selection.");
650
+ }
651
+ if (byId.size !== input.candidates.length) {
652
+ issues.push("Duplicate candidate identities are ambiguous.");
653
+ }
654
+ const selectedIds = new Set(Object.values(input.selection));
655
+ const documentId = input.documentId ??
656
+ input.candidates.find((candidate) => selectedIds.has(candidate.candidateId) &&
657
+ candidate.documentId !== undefined)?.documentId;
658
+ for (const target of input.targets) {
659
+ const targetKey = target.destinationId;
660
+ if (liveTargets.has(targetKey)) {
661
+ issues.push(`${target.destinationId}: duplicate acceptance target`);
662
+ continue;
663
+ }
664
+ liveTargets.set(targetKey, target);
665
+ liveDestinationIds.add(target.destinationId);
666
+ const candidateId = Object.hasOwn(input.selection, target.destinationId)
667
+ ? input.selection[target.destinationId]
668
+ : undefined;
669
+ if (candidateId === undefined || candidateId.trim() === "") {
670
+ issues.push(`${target.destinationId}: no candidate selected`);
671
+ continue;
672
+ }
673
+ const candidate = byId.get(candidateId);
674
+ if (candidate === undefined) {
675
+ issues.push(`${target.destinationId}: candidate is missing`);
676
+ continue;
677
+ }
678
+ let candidateIsValid = true;
679
+ if (!productionCandidate.safeParse(candidate).success) {
680
+ issues.push(`${target.destinationId}: candidate has invalid provenance or timing`);
681
+ candidateIsValid = false;
682
+ }
683
+ if (!candidate.snapshot) {
684
+ issues.push(`${target.destinationId}: candidate has no captured inputs`);
685
+ candidateIsValid = false;
686
+ }
687
+ if ((documentId !== undefined && candidate.documentId !== documentId) ||
688
+ (target.documentId !== undefined && target.documentId !== documentId)) {
689
+ issues.push(`${target.destinationId}: candidate belongs to another document`);
690
+ candidateIsValid = false;
691
+ }
692
+ if (candidate.batchId !== input.batchId) {
693
+ issues.push(`${target.destinationId}: candidate belongs to another production`);
694
+ candidateIsValid = false;
695
+ }
696
+ if ((target.destinationKind !== undefined &&
697
+ candidate.destinationKind !== target.destinationKind) ||
698
+ candidate.destinationId !== target.destinationId) {
699
+ issues.push(`${target.destinationId}: candidate targets another destination`);
700
+ candidateIsValid = false;
701
+ }
702
+ if (candidate.status !== "ready" || candidate.assetId === undefined) {
703
+ issues.push(`${target.destinationId}: candidate is not ready`);
704
+ candidateIsValid = false;
705
+ }
706
+ if (candidate.active ||
707
+ candidate.accepted ||
708
+ target.acceptedCandidateId !== undefined ||
709
+ target.acceptedAssetId !== undefined ||
710
+ target.acceptedTakeId !== undefined) {
711
+ issues.push(`${target.destinationId}: target already has accepted media`);
712
+ candidateIsValid = false;
713
+ }
714
+ if (((target.targetVersion !== undefined ||
715
+ candidate.targetVersion !== undefined) &&
716
+ candidate.targetVersion !== target.targetVersion) ||
717
+ (target.authoringFingerprint !== undefined &&
718
+ candidate.snapshot?.authoringFingerprint !==
719
+ target.authoringFingerprint)) {
720
+ issues.push(`${target.destinationId}: target changed since generation`);
721
+ candidateIsValid = false;
722
+ }
723
+ if (candidateIsValid) {
724
+ selected.push(candidate);
725
+ }
726
+ }
727
+ for (const destinationId of Object.keys(input.selection)) {
728
+ if (!liveDestinationIds.has(destinationId)) {
729
+ issues.push(`${destinationId}: selected destination is missing`);
730
+ }
731
+ }
732
+ return issues.length > 0
733
+ ? { valid: false, issues }
734
+ : { valid: true, candidates: selected };
735
+ }
736
+ //# sourceMappingURL=production-authoring.js.map