@nodetool-ai/agents 0.8.1 → 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 (361) hide show
  1. package/dist/.nodetool-build-stamp +1 -1
  2. package/dist/analysis/audio-dsp.d.ts +3 -2
  3. package/dist/analysis/audio-dsp.d.ts.map +1 -1
  4. package/dist/analysis/audio-dsp.js +11 -8
  5. package/dist/analysis/audio-dsp.js.map +1 -1
  6. package/dist/analysis/media-decode.d.ts +13 -0
  7. package/dist/analysis/media-decode.d.ts.map +1 -1
  8. package/dist/analysis/media-decode.js +33 -6
  9. package/dist/analysis/media-decode.js.map +1 -1
  10. package/dist/author-graph.d.ts +2 -3
  11. package/dist/author-graph.d.ts.map +1 -1
  12. package/dist/author-graph.js +3 -5
  13. package/dist/author-graph.js.map +1 -1
  14. package/dist/browser-gate.d.ts +2 -2
  15. package/dist/browser-gate.js +2 -2
  16. package/dist/capabilities/GamePublishRequest.d.ts +14 -0
  17. package/dist/capabilities/GamePublishRequest.d.ts.map +1 -0
  18. package/dist/capabilities/GamePublishRequest.js +2 -0
  19. package/dist/capabilities/GamePublishRequest.js.map +1 -0
  20. package/dist/capabilities/adapters.d.ts +4 -13
  21. package/dist/capabilities/adapters.d.ts.map +1 -1
  22. package/dist/capabilities/adapters.js +9 -14
  23. package/dist/capabilities/adapters.js.map +1 -1
  24. package/dist/capabilities/agent-activity.d.ts +27 -0
  25. package/dist/capabilities/agent-activity.d.ts.map +1 -0
  26. package/dist/capabilities/agent-activity.js +103 -0
  27. package/dist/capabilities/agent-activity.js.map +1 -0
  28. package/dist/capabilities/agentic-storyboard-finish.d.ts +67 -0
  29. package/dist/capabilities/agentic-storyboard-finish.d.ts.map +1 -0
  30. package/dist/capabilities/agentic-storyboard-finish.js +1321 -0
  31. package/dist/capabilities/agentic-storyboard-finish.js.map +1 -0
  32. package/dist/capabilities/agents.d.ts +5 -2
  33. package/dist/capabilities/agents.d.ts.map +1 -1
  34. package/dist/capabilities/agents.js +14 -4
  35. package/dist/capabilities/agents.js.map +1 -1
  36. package/dist/capabilities/agents.specs.d.ts +3 -0
  37. package/dist/capabilities/agents.specs.d.ts.map +1 -1
  38. package/dist/capabilities/agents.specs.js +71 -1
  39. package/dist/capabilities/agents.specs.js.map +1 -1
  40. package/dist/capabilities/analysis.d.ts.map +1 -1
  41. package/dist/capabilities/analysis.js +33 -22
  42. package/dist/capabilities/analysis.js.map +1 -1
  43. package/dist/capabilities/analysis.specs.js +2 -2
  44. package/dist/capabilities/analysis.specs.js.map +1 -1
  45. package/dist/capabilities/apps.d.ts.map +1 -1
  46. package/dist/capabilities/apps.js +5 -3
  47. package/dist/capabilities/apps.js.map +1 -1
  48. package/dist/capabilities/args.d.ts +2 -5
  49. package/dist/capabilities/args.d.ts.map +1 -1
  50. package/dist/capabilities/args.js +2 -5
  51. package/dist/capabilities/args.js.map +1 -1
  52. package/dist/capabilities/browser.d.ts +1 -1
  53. package/dist/capabilities/browser.js +1 -1
  54. package/dist/capabilities/browser.specs.d.ts +1 -1
  55. package/dist/capabilities/browser.specs.js +1 -1
  56. package/dist/capabilities/code.d.ts +5 -0
  57. package/dist/capabilities/code.d.ts.map +1 -1
  58. package/dist/capabilities/code.js +128 -89
  59. package/dist/capabilities/code.js.map +1 -1
  60. package/dist/capabilities/errors.d.ts +19 -0
  61. package/dist/capabilities/errors.d.ts.map +1 -0
  62. package/dist/capabilities/errors.js +109 -0
  63. package/dist/capabilities/errors.js.map +1 -0
  64. package/dist/capabilities/errors.specs.d.ts +11 -0
  65. package/dist/capabilities/errors.specs.d.ts.map +1 -0
  66. package/dist/capabilities/errors.specs.js +100 -0
  67. package/dist/capabilities/errors.specs.js.map +1 -0
  68. package/dist/capabilities/example-timelines.d.ts.map +1 -1
  69. package/dist/capabilities/example-timelines.js +52 -10
  70. package/dist/capabilities/example-timelines.js.map +1 -1
  71. package/dist/capabilities/example-timelines.specs.d.ts +1 -0
  72. package/dist/capabilities/example-timelines.specs.d.ts.map +1 -1
  73. package/dist/capabilities/example-timelines.specs.js +21 -3
  74. package/dist/capabilities/example-timelines.specs.js.map +1 -1
  75. package/dist/capabilities/finish-storyboard.d.ts +5 -0
  76. package/dist/capabilities/finish-storyboard.d.ts.map +1 -0
  77. package/dist/capabilities/finish-storyboard.js +278 -0
  78. package/dist/capabilities/finish-storyboard.js.map +1 -0
  79. package/dist/capabilities/game-asset-source.js +1 -1
  80. package/dist/capabilities/game-asset-source.js.map +1 -1
  81. package/dist/capabilities/game.d.ts +14 -2
  82. package/dist/capabilities/game.d.ts.map +1 -1
  83. package/dist/capabilities/game.js +209 -39
  84. package/dist/capabilities/game.js.map +1 -1
  85. package/dist/capabilities/game.specs.d.ts +2 -0
  86. package/dist/capabilities/game.specs.d.ts.map +1 -1
  87. package/dist/capabilities/game.specs.js +25 -11
  88. package/dist/capabilities/game.specs.js.map +1 -1
  89. package/dist/capabilities/game3d.d.ts +17 -0
  90. package/dist/capabilities/game3d.d.ts.map +1 -0
  91. package/dist/capabilities/game3d.js +433 -0
  92. package/dist/capabilities/game3d.js.map +1 -0
  93. package/dist/capabilities/gate-from-context.d.ts +1 -1
  94. package/dist/capabilities/gate-from-context.js +1 -1
  95. package/dist/capabilities/generations.d.ts +2 -0
  96. package/dist/capabilities/generations.d.ts.map +1 -1
  97. package/dist/capabilities/generations.js +7 -2
  98. package/dist/capabilities/generations.js.map +1 -1
  99. package/dist/capabilities/index.d.ts +2 -2
  100. package/dist/capabilities/index.d.ts.map +1 -1
  101. package/dist/capabilities/index.js +2 -2
  102. package/dist/capabilities/index.js.map +1 -1
  103. package/dist/capabilities/invoke.d.ts +14 -25
  104. package/dist/capabilities/invoke.d.ts.map +1 -1
  105. package/dist/capabilities/invoke.js +72 -35
  106. package/dist/capabilities/invoke.js.map +1 -1
  107. package/dist/capabilities/jobs.d.ts.map +1 -1
  108. package/dist/capabilities/jobs.js +47 -3
  109. package/dist/capabilities/jobs.js.map +1 -1
  110. package/dist/capabilities/jobs.specs.d.ts.map +1 -1
  111. package/dist/capabilities/jobs.specs.js +3 -1
  112. package/dist/capabilities/jobs.specs.js.map +1 -1
  113. package/dist/capabilities/js-scripts.d.ts +19 -1
  114. package/dist/capabilities/js-scripts.d.ts.map +1 -1
  115. package/dist/capabilities/js-scripts.js +109 -2
  116. package/dist/capabilities/js-scripts.js.map +1 -1
  117. package/dist/capabilities/js-scripts.specs.d.ts +2 -0
  118. package/dist/capabilities/js-scripts.specs.d.ts.map +1 -1
  119. package/dist/capabilities/js-scripts.specs.js +50 -0
  120. package/dist/capabilities/js-scripts.specs.js.map +1 -1
  121. package/dist/capabilities/lazy-tool.d.ts +23 -24
  122. package/dist/capabilities/lazy-tool.d.ts.map +1 -1
  123. package/dist/capabilities/lazy-tool.js +29 -35
  124. package/dist/capabilities/lazy-tool.js.map +1 -1
  125. package/dist/capabilities/legacy-tools.d.ts +15 -0
  126. package/dist/capabilities/legacy-tools.d.ts.map +1 -0
  127. package/dist/capabilities/legacy-tools.js +98 -0
  128. package/dist/capabilities/legacy-tools.js.map +1 -0
  129. package/dist/capabilities/media.d.ts +0 -9
  130. package/dist/capabilities/media.d.ts.map +1 -1
  131. package/dist/capabilities/media.js +301 -260
  132. package/dist/capabilities/media.js.map +1 -1
  133. package/dist/capabilities/models.d.ts +2 -2
  134. package/dist/capabilities/models.d.ts.map +1 -1
  135. package/dist/capabilities/models.js +5 -3
  136. package/dist/capabilities/models.js.map +1 -1
  137. package/dist/capabilities/registry.d.ts +2 -0
  138. package/dist/capabilities/registry.d.ts.map +1 -1
  139. package/dist/capabilities/registry.js +28 -0
  140. package/dist/capabilities/registry.js.map +1 -1
  141. package/dist/capabilities/run-agent.d.ts +19 -0
  142. package/dist/capabilities/run-agent.d.ts.map +1 -0
  143. package/dist/capabilities/run-agent.js +183 -0
  144. package/dist/capabilities/run-agent.js.map +1 -0
  145. package/dist/capabilities/runs.d.ts +9 -0
  146. package/dist/capabilities/runs.d.ts.map +1 -0
  147. package/dist/capabilities/runs.js +46 -0
  148. package/dist/capabilities/runs.js.map +1 -0
  149. package/dist/capabilities/runs.specs.d.ts +39 -0
  150. package/dist/capabilities/runs.specs.d.ts.map +1 -0
  151. package/dist/capabilities/runs.specs.js +52 -0
  152. package/dist/capabilities/runs.specs.js.map +1 -0
  153. package/dist/capabilities/scripts.d.ts.map +1 -1
  154. package/dist/capabilities/scripts.js +11 -5
  155. package/dist/capabilities/scripts.js.map +1 -1
  156. package/dist/capabilities/sketches.d.ts.map +1 -1
  157. package/dist/capabilities/sketches.js +4 -2
  158. package/dist/capabilities/sketches.js.map +1 -1
  159. package/dist/capabilities/skills.d.ts.map +1 -1
  160. package/dist/capabilities/skills.js +22 -2
  161. package/dist/capabilities/skills.js.map +1 -1
  162. package/dist/capabilities/storyboard-layout-check.d.ts +33 -0
  163. package/dist/capabilities/storyboard-layout-check.d.ts.map +1 -0
  164. package/dist/capabilities/storyboard-layout-check.js +229 -0
  165. package/dist/capabilities/storyboard-layout-check.js.map +1 -0
  166. package/dist/capabilities/storyboard-measured-sources.d.ts +10 -0
  167. package/dist/capabilities/storyboard-measured-sources.d.ts.map +1 -0
  168. package/dist/capabilities/storyboard-measured-sources.js +67 -0
  169. package/dist/capabilities/storyboard-measured-sources.js.map +1 -0
  170. package/dist/capabilities/storyboard-review-times.d.ts +4 -0
  171. package/dist/capabilities/storyboard-review-times.d.ts.map +1 -0
  172. package/dist/capabilities/storyboard-review-times.js +39 -0
  173. package/dist/capabilities/storyboard-review-times.js.map +1 -0
  174. package/dist/capabilities/storyboards.d.ts +2 -18
  175. package/dist/capabilities/storyboards.d.ts.map +1 -1
  176. package/dist/capabilities/storyboards.js +315 -94
  177. package/dist/capabilities/storyboards.js.map +1 -1
  178. package/dist/capabilities/storyboards.specs.d.ts +3 -0
  179. package/dist/capabilities/storyboards.specs.d.ts.map +1 -1
  180. package/dist/capabilities/storyboards.specs.js +42 -3
  181. package/dist/capabilities/storyboards.specs.js.map +1 -1
  182. package/dist/capabilities/timeline-bridge.d.ts +359 -0
  183. package/dist/capabilities/timeline-bridge.d.ts.map +1 -0
  184. package/dist/capabilities/timeline-bridge.js +1016 -0
  185. package/dist/capabilities/timeline-bridge.js.map +1 -0
  186. package/dist/capabilities/timeline-clip-frames.d.ts +17 -0
  187. package/dist/capabilities/timeline-clip-frames.d.ts.map +1 -0
  188. package/dist/capabilities/timeline-clip-frames.js +84 -0
  189. package/dist/capabilities/timeline-clip-frames.js.map +1 -0
  190. package/dist/capabilities/timeline-media-edit.d.ts +8 -0
  191. package/dist/capabilities/timeline-media-edit.d.ts.map +1 -0
  192. package/dist/capabilities/timeline-media-edit.js +94 -0
  193. package/dist/capabilities/timeline-media-edit.js.map +1 -0
  194. package/dist/capabilities/timeline-native-media.d.ts.map +1 -1
  195. package/dist/capabilities/timeline-native-media.js +40 -0
  196. package/dist/capabilities/timeline-native-media.js.map +1 -1
  197. package/dist/capabilities/timelines.d.ts +64 -4
  198. package/dist/capabilities/timelines.d.ts.map +1 -1
  199. package/dist/capabilities/timelines.js +566 -67
  200. package/dist/capabilities/timelines.js.map +1 -1
  201. package/dist/capabilities/timelines.specs.d.ts +8 -0
  202. package/dist/capabilities/timelines.specs.d.ts.map +1 -1
  203. package/dist/capabilities/timelines.specs.js +173 -8
  204. package/dist/capabilities/timelines.specs.js.map +1 -1
  205. package/dist/capabilities/types.d.ts +3 -1
  206. package/dist/capabilities/types.d.ts.map +1 -1
  207. package/dist/capabilities/types.js.map +1 -1
  208. package/dist/capabilities/ui.d.ts.map +1 -1
  209. package/dist/capabilities/ui.js +24 -2
  210. package/dist/capabilities/ui.js.map +1 -1
  211. package/dist/capabilities/workflows.d.ts.map +1 -1
  212. package/dist/capabilities/workflows.js +53 -26
  213. package/dist/capabilities/workflows.js.map +1 -1
  214. package/dist/capabilities/workflows.specs.d.ts.map +1 -1
  215. package/dist/capabilities/workflows.specs.js +7 -1
  216. package/dist/capabilities/workflows.specs.js.map +1 -1
  217. package/dist/codeact/action-diagnostics.d.ts.map +1 -1
  218. package/dist/codeact/action-diagnostics.js +51 -1
  219. package/dist/codeact/action-diagnostics.js.map +1 -1
  220. package/dist/codeact/codeact-executor.d.ts.map +1 -1
  221. package/dist/codeact/codeact-executor.js +16 -8
  222. package/dist/codeact/codeact-executor.js.map +1 -1
  223. package/dist/codeact/compact-ids.d.ts.map +1 -1
  224. package/dist/codeact/compact-ids.js +5 -1
  225. package/dist/codeact/compact-ids.js.map +1 -1
  226. package/dist/codeact/graph-model.d.ts +1 -1
  227. package/dist/codeact/graph-model.d.ts.map +1 -1
  228. package/dist/codeact/graph-model.js +2 -3
  229. package/dist/codeact/graph-model.js.map +1 -1
  230. package/dist/codeact/nodetool-api.d.ts +1 -1
  231. package/dist/codeact/nodetool-api.d.ts.map +1 -1
  232. package/dist/codeact/nodetool-api.js +202 -284
  233. package/dist/codeact/nodetool-api.js.map +1 -1
  234. package/dist/codeact/tool-api.d.ts +6 -3
  235. package/dist/codeact/tool-api.d.ts.map +1 -1
  236. package/dist/codeact/tool-api.js +22 -15
  237. package/dist/codeact/tool-api.js.map +1 -1
  238. package/dist/evals/codeact-api-cases.d.ts.map +1 -1
  239. package/dist/evals/codeact-api-cases.js +2 -0
  240. package/dist/evals/codeact-api-cases.js.map +1 -1
  241. package/dist/evals/codeact-api-runs.d.ts +3 -0
  242. package/dist/evals/codeact-api-runs.d.ts.map +1 -0
  243. package/dist/evals/codeact-api-runs.js +33 -0
  244. package/dist/evals/codeact-api-runs.js.map +1 -0
  245. package/dist/evals/surfaces/sketch.d.ts +2 -0
  246. package/dist/evals/surfaces/sketch.d.ts.map +1 -1
  247. package/dist/evals/surfaces/sketch.js +11 -3
  248. package/dist/evals/surfaces/sketch.js.map +1 -1
  249. package/dist/evals/surfaces/timeline.d.ts +4 -357
  250. package/dist/evals/surfaces/timeline.d.ts.map +1 -1
  251. package/dist/evals/surfaces/timeline.js +9 -2621
  252. package/dist/evals/surfaces/timeline.js.map +1 -1
  253. package/dist/evals/tool-loop-bridge.d.ts +4 -0
  254. package/dist/evals/tool-loop-bridge.d.ts.map +1 -1
  255. package/dist/evals/tool-loop-bridge.js.map +1 -1
  256. package/dist/evals/tool-loop-eval.d.ts +2 -0
  257. package/dist/evals/tool-loop-eval.d.ts.map +1 -1
  258. package/dist/evals/tool-loop-eval.js +6 -1
  259. package/dist/evals/tool-loop-eval.js.map +1 -1
  260. package/dist/evals/tool-loop-permission.d.ts +1 -15
  261. package/dist/evals/tool-loop-permission.d.ts.map +1 -1
  262. package/dist/evals/tool-loop-permission.js +23 -41
  263. package/dist/evals/tool-loop-permission.js.map +1 -1
  264. package/dist/game-authoring.d.ts +4737 -0
  265. package/dist/game-authoring.d.ts.map +1 -0
  266. package/dist/game-authoring.js +146 -0
  267. package/dist/game-authoring.js.map +1 -0
  268. package/dist/game-code-bake.d.ts +26 -0
  269. package/dist/game-code-bake.d.ts.map +1 -0
  270. package/dist/game-code-bake.js +98 -0
  271. package/dist/game-code-bake.js.map +1 -0
  272. package/dist/game-examples.d.ts +872 -16
  273. package/dist/game-examples.d.ts.map +1 -1
  274. package/dist/game-examples.js +5 -4
  275. package/dist/game-examples.js.map +1 -1
  276. package/dist/index.d.ts +15 -4
  277. package/dist/index.d.ts.map +1 -1
  278. package/dist/index.js +13 -3
  279. package/dist/index.js.map +1 -1
  280. package/dist/js-sandbox-worker/engine.d.ts +4 -0
  281. package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
  282. package/dist/js-sandbox-worker/engine.js +45 -0
  283. package/dist/js-sandbox-worker/engine.js.map +1 -0
  284. package/dist/js-sandbox-worker/host.js +1 -1
  285. package/dist/js-sandbox-worker/host.js.map +1 -1
  286. package/dist/js-sandbox-worker/interpreter.d.ts +1 -1
  287. package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -1
  288. package/dist/js-sandbox-worker/interpreter.js +94 -2
  289. package/dist/js-sandbox-worker/interpreter.js.map +1 -1
  290. package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -1
  291. package/dist/js-sandbox-worker/worker-entry.js +3 -2
  292. package/dist/js-sandbox-worker/worker-entry.js.map +1 -1
  293. package/dist/js-sandbox.d.ts +2 -0
  294. package/dist/js-sandbox.d.ts.map +1 -1
  295. package/dist/js-sandbox.js +56 -11
  296. package/dist/js-sandbox.js.map +1 -1
  297. package/dist/js-script-app-runner.d.ts +2 -0
  298. package/dist/js-script-app-runner.d.ts.map +1 -1
  299. package/dist/js-script-app-runner.js +8 -3
  300. package/dist/js-script-app-runner.js.map +1 -1
  301. package/dist/js-script-sandbox.d.ts +12 -18
  302. package/dist/js-script-sandbox.d.ts.map +1 -1
  303. package/dist/js-script-sandbox.js +3 -49
  304. package/dist/js-script-sandbox.js.map +1 -1
  305. package/dist/prompts/product-knowledge.d.ts +1 -1
  306. package/dist/prompts/product-knowledge.d.ts.map +1 -1
  307. package/dist/prompts/product-knowledge.js +82 -41
  308. package/dist/prompts/product-knowledge.js.map +1 -1
  309. package/dist/sandbox-pack-resolution.d.ts +21 -0
  310. package/dist/sandbox-pack-resolution.d.ts.map +1 -0
  311. package/dist/sandbox-pack-resolution.js +42 -0
  312. package/dist/sandbox-pack-resolution.js.map +1 -0
  313. package/dist/sandbox-toolbelt.d.ts +3 -1
  314. package/dist/sandbox-toolbelt.d.ts.map +1 -1
  315. package/dist/sandbox-toolbelt.js +8 -2
  316. package/dist/sandbox-toolbelt.js.map +1 -1
  317. package/dist/skill-prompt.d.ts +11 -1
  318. package/dist/skill-prompt.d.ts.map +1 -1
  319. package/dist/skill-prompt.js +17 -6
  320. package/dist/skill-prompt.js.map +1 -1
  321. package/dist/system-skills.d.ts +7 -1
  322. package/dist/system-skills.d.ts.map +1 -1
  323. package/dist/system-skills.js +2 -2
  324. package/dist/system-skills.js.map +1 -1
  325. package/dist/timeline-capture.d.ts +21 -0
  326. package/dist/timeline-capture.d.ts.map +1 -0
  327. package/dist/timeline-capture.js +564 -0
  328. package/dist/timeline-capture.js.map +1 -0
  329. package/dist/timeline-code-bake.d.ts +75 -0
  330. package/dist/timeline-code-bake.d.ts.map +1 -0
  331. package/dist/timeline-code-bake.js +327 -0
  332. package/dist/timeline-code-bake.js.map +1 -0
  333. package/dist/timeline-preview/frames.d.ts +26 -0
  334. package/dist/timeline-preview/frames.d.ts.map +1 -1
  335. package/dist/timeline-preview/frames.js +155 -70
  336. package/dist/timeline-preview/frames.js.map +1 -1
  337. package/dist/tools/base-tool.d.ts +1 -0
  338. package/dist/tools/base-tool.d.ts.map +1 -1
  339. package/dist/tools/base-tool.js +1 -1
  340. package/dist/tools/base-tool.js.map +1 -1
  341. package/dist/tools/builtin-tools.d.ts.map +1 -1
  342. package/dist/tools/builtin-tools.js +13 -0
  343. package/dist/tools/builtin-tools.js.map +1 -1
  344. package/dist/tools/external-capability-tools.d.ts +1 -1
  345. package/dist/tools/external-capability-tools.js +1 -1
  346. package/dist/tools/mcp-tool-support.d.ts +10 -9
  347. package/dist/tools/mcp-tool-support.d.ts.map +1 -1
  348. package/dist/tools/mcp-tool-support.js +14 -13
  349. package/dist/tools/mcp-tool-support.js.map +1 -1
  350. package/dist/tools/mcp-tools.d.ts +6 -4
  351. package/dist/tools/mcp-tools.d.ts.map +1 -1
  352. package/dist/tools/mcp-tools.js +65 -62
  353. package/dist/tools/mcp-tools.js.map +1 -1
  354. package/dist/tools/tool-permissions.d.ts +1 -1
  355. package/dist/tools/tool-permissions.js +1 -1
  356. package/package.json +24 -22
  357. package/dist/capabilities/gate-tools.d.ts +0 -18
  358. package/dist/capabilities/gate-tools.d.ts.map +0 -1
  359. package/dist/capabilities/gate-tools.js +0 -66
  360. package/dist/capabilities/gate-tools.js.map +0 -1
  361. package/dist/tsconfig.tests.tmp.tsbuildinfo +0 -1
@@ -0,0 +1,564 @@
1
+ /**
2
+ * The capture step of timeline code capture (docs/timeline-code-capture.md).
3
+ *
4
+ * Guest code that imports `@nodetool-ai/sandbox-timeline` passes through
5
+ * {@link captureTimelineScenes} before it runs. Each
6
+ * `<receiver>.scene(name, seconds, fn, extra?)` call gets one more argument,
7
+ * a capture record, which tells the pack what `fn` needs to be rebuilt
8
+ * without the rest of the script: the declarations to keep as source text,
9
+ * the pack imports, and the values to snapshot when the scene is built.
10
+ * `v.save()` prints the retained program from these records.
11
+ *
12
+ * The transform only appends text inside existing lines, so every line of
13
+ * the guest code keeps its number and stack positions stay correct.
14
+ */
15
+ import * as acorn from "acorn";
16
+ import { analyze } from "eslint-scope";
17
+ const PACK_PREFIX = "@nodetool-ai/sandbox-";
18
+ const TIMELINE_PACK = "@nodetool-ai/sandbox-timeline";
19
+ /** Globals a kept callback may use. They exist in every sandbox, including the hermetic bake. */
20
+ const SAFE_GLOBALS = new Set([
21
+ "Math", "JSON", "Number", "String", "Boolean", "Array", "Object", "Symbol",
22
+ "Map", "Set", "WeakMap", "WeakSet", "Error", "TypeError", "RangeError",
23
+ "RegExp", "Date", "Promise", "Intl", "BigInt", "Reflect", "Proxy",
24
+ "Infinity", "NaN", "undefined", "isFinite", "isNaN", "parseFloat",
25
+ "parseInt", "encodeURIComponent", "decodeURIComponent", "encodeURI",
26
+ "decodeURI", "console", "globalThis", "structuredClone", "Uint8Array",
27
+ "Float32Array", "Float64Array", "Int32Array", "Uint32Array",
28
+ "ArrayBuffer", "DataView", "TextEncoder", "TextDecoder"
29
+ ]);
30
+ /** Methods that change the object they are called on. A `const` used this way is not its initializer any more. */
31
+ const MUTATING_METHODS = new Set([
32
+ "push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill",
33
+ "copyWithin", "set", "add", "delete", "clear"
34
+ ]);
35
+ /**
36
+ * Add a capture record to each `.scene()` call in `code`. Returns `code`
37
+ * unchanged when it does not import the timeline pack, cannot be parsed,
38
+ * or has no scene call to capture.
39
+ */
40
+ export function captureTimelineScenes(code) {
41
+ if (!code.includes(TIMELINE_PACK))
42
+ return code;
43
+ let program;
44
+ try {
45
+ program = acorn.parse(code, {
46
+ ecmaVersion: "latest",
47
+ sourceType: "module",
48
+ allowAwaitOutsideFunction: true,
49
+ allowReturnOutsideFunction: true,
50
+ // eslint-scope reads `range` to resolve references inside a function.
51
+ ranges: true
52
+ });
53
+ }
54
+ catch {
55
+ return code;
56
+ }
57
+ const packImport = program.body.find((node) => node.type === "ImportDeclaration" && node.source.value === TIMELINE_PACK);
58
+ if (!packImport)
59
+ return code;
60
+ let analysis;
61
+ try {
62
+ analysis = analyze(program, { ecmaVersion: 2022, sourceType: "module" });
63
+ }
64
+ catch {
65
+ return code;
66
+ }
67
+ return new Capture(code, program, analysis, packImport.start).run();
68
+ }
69
+ class Capture {
70
+ code;
71
+ program;
72
+ analysis;
73
+ hostBoundary;
74
+ parents = new WeakMap();
75
+ references;
76
+ classes = new Map();
77
+ /** The top-level binding `video(...)` is assigned to, which prints the scene calls. */
78
+ videoBinding = null;
79
+ /**
80
+ * @param hostBoundary Offset of the pack import. A host prepends its
81
+ * prelude (`nodetool`, `tools`, `finish`, …) to the guest's code, so every
82
+ * top-level binding above the import is the host's, not the author's.
83
+ */
84
+ constructor(code, program, analysis, hostBoundary) {
85
+ this.code = code;
86
+ this.program = program;
87
+ this.analysis = analysis;
88
+ this.hostBoundary = hostBoundary;
89
+ forEachNode(program, (node, parent) => {
90
+ if (parent)
91
+ this.parents.set(node, parent);
92
+ });
93
+ this.references = analysis.scopes.flatMap((scope) => scope.references);
94
+ }
95
+ run() {
96
+ for (const statement of this.program["body"]) {
97
+ if (statement.type !== "VariableDeclaration")
98
+ continue;
99
+ for (const declarator of statement["declarations"]) {
100
+ const id = declarator["id"];
101
+ const init = declarator["init"];
102
+ if (id.type === "Identifier" && init && this.isVideoCall(init)) {
103
+ this.videoBinding = String(id["name"]);
104
+ }
105
+ }
106
+ }
107
+ const inserts = [];
108
+ forEachNode(this.program, (node) => {
109
+ const insert = this.sceneCall(node);
110
+ if (insert)
111
+ inserts.push(insert);
112
+ });
113
+ if (inserts.length === 0)
114
+ return this.code;
115
+ let out = this.code;
116
+ for (const { at, text } of inserts.sort((a, b) => b.at - a.at)) {
117
+ out = out.slice(0, at) + text + out.slice(at);
118
+ }
119
+ return out;
120
+ }
121
+ /** The text to insert for one `.scene(name, seconds, fn, extra?)` call, or null. */
122
+ sceneCall(node) {
123
+ if (node.type !== "CallExpression")
124
+ return null;
125
+ const callee = node["callee"];
126
+ if (callee.type !== "MemberExpression" ||
127
+ callee["computed"] ||
128
+ callee["property"]["name"] !== "scene") {
129
+ return null;
130
+ }
131
+ const args = node["arguments"];
132
+ if (args.length !== 3 && args.length !== 4)
133
+ return null;
134
+ if (args.some((arg) => arg.type === "SpreadElement"))
135
+ return null;
136
+ const fn = args[2];
137
+ const record = this.record(fn);
138
+ if (!record)
139
+ return null;
140
+ const text = (args.length === 3 ? ", undefined, " : ", ") + printRecord(record);
141
+ return { at: args[args.length - 1].end, text };
142
+ }
143
+ record(fn) {
144
+ const isFunction = fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression";
145
+ if (!isFunction && fn.type !== "Identifier")
146
+ return null;
147
+ const record = {
148
+ src: isFunction ? this.code.slice(fn.start, fn.end) : String(fn["name"]),
149
+ video: this.videoBinding,
150
+ decls: [],
151
+ imports: [],
152
+ snap: [],
153
+ errors: []
154
+ };
155
+ const callScope = isFunction
156
+ ? this.analysis.acquire(fn)?.upper ?? null
157
+ : this.referenceAt(fn)?.from ?? null;
158
+ if (!callScope)
159
+ return null;
160
+ // Whether each visited variable prints at the top of the program. A
161
+ // variable still being visited (a cycle) counts as top.
162
+ const topOf = new Map();
163
+ const snapshots = new Set();
164
+ const declsAt = new Map();
165
+ const imports = new Map();
166
+ const errors = new Set();
167
+ const visit = (dependency) => {
168
+ if ("global" in dependency) {
169
+ const message = this.globalProblem(dependency.global, dependency.node);
170
+ if (message)
171
+ errors.add(message);
172
+ return true;
173
+ }
174
+ const variable = dependency.variable;
175
+ const known = topOf.get(variable);
176
+ if (known !== undefined)
177
+ return known;
178
+ topOf.set(variable, true);
179
+ const cls = this.classify(variable);
180
+ switch (cls.kind) {
181
+ case "import":
182
+ imports.set(`${cls.module}\u0000${cls.local}`, cls);
183
+ return true;
184
+ case "video":
185
+ record.video = variable.name;
186
+ return true;
187
+ case "snapshot":
188
+ snapshots.add(variable);
189
+ topOf.set(variable, false);
190
+ return false;
191
+ case "error":
192
+ errors.add(cls.message);
193
+ return true;
194
+ case "decl": {
195
+ let top = variable.scope.type === "module";
196
+ for (const dep of cls.deps) {
197
+ if (!visit(dep))
198
+ top = false;
199
+ }
200
+ declsAt.set(cls.at, { top, src: cls.src });
201
+ topOf.set(variable, top);
202
+ return top;
203
+ }
204
+ }
205
+ };
206
+ const roots = isFunction
207
+ ? this.freeDependencies(fn)
208
+ : this.dependencyFor(fn);
209
+ for (const root of roots)
210
+ visit(root);
211
+ for (const message of this.randomnessProblems(fn))
212
+ errors.add(message);
213
+ for (const variable of snapshots) {
214
+ if (resolveName(callScope, variable.name) !== variable) {
215
+ errors.add(`\`${variable.name}\` is shadowed where the scene is built, so its ` +
216
+ "value cannot be captured there. Rename one of the two.");
217
+ continue;
218
+ }
219
+ record.snap.push(variable.name);
220
+ }
221
+ record.decls = [...declsAt.entries()]
222
+ .sort(([a], [b]) => a - b)
223
+ .map(([at, decl]) => ({ at, ...decl }));
224
+ record.imports = [...imports.values()].map((imp) => ({
225
+ m: imp.module,
226
+ i: imp.imported,
227
+ l: imp.local
228
+ }));
229
+ record.errors = [...errors];
230
+ return record;
231
+ }
232
+ classify(variable) {
233
+ const cached = this.classes.get(variable);
234
+ if (cached)
235
+ return cached;
236
+ // A placeholder breaks cycles: a recursive helper refers to itself.
237
+ this.classes.set(variable, { kind: "snapshot" });
238
+ const cls = this.classifyUncached(variable);
239
+ this.classes.set(variable, cls);
240
+ return cls;
241
+ }
242
+ classifyUncached(variable) {
243
+ const def = variable.defs[0];
244
+ if (!def)
245
+ return { kind: "snapshot" };
246
+ const node = def.node;
247
+ if (variable.scope.type === "module" &&
248
+ def.type !== "ImportBinding" &&
249
+ node.start < this.hostBoundary) {
250
+ return {
251
+ kind: "error",
252
+ message: `\`${variable.name}\` belongs to the host and is not available when ` +
253
+ "the timeline is rebaked. Call it at the top level, before the " +
254
+ "scene, and use its result."
255
+ };
256
+ }
257
+ switch (def.type) {
258
+ case "ImportBinding": {
259
+ const declaration = def.parent;
260
+ const module = String(declaration["source"]["value"]);
261
+ if (!module.startsWith(PACK_PREFIX)) {
262
+ return {
263
+ kind: "error",
264
+ message: `\`${variable.name}\` comes from "${module}", which a rebake cannot import.`
265
+ };
266
+ }
267
+ const imported = node.type === "ImportNamespaceSpecifier"
268
+ ? "*"
269
+ : node.type === "ImportDefaultSpecifier"
270
+ ? "default"
271
+ : String(node["imported"]["name"] ??
272
+ node["imported"]["value"]);
273
+ return { kind: "import", module, imported, local: variable.name };
274
+ }
275
+ case "Variable": {
276
+ const declaration = def.parent;
277
+ const init = node["init"];
278
+ if (declaration["kind"] !== "const" || !init)
279
+ return { kind: "snapshot" };
280
+ if (this.isVideoCall(init))
281
+ return { kind: "video" };
282
+ if (init.type === "ArrowFunctionExpression" ||
283
+ init.type === "FunctionExpression") {
284
+ return this.classifyFunction(variable, init, node, `const ${this.code.slice(node.start, node.end)};`);
285
+ }
286
+ if (containsAwait(init) || this.isMutated(variable, node)) {
287
+ return { kind: "snapshot" };
288
+ }
289
+ if (this.randomnessProblems(init).length > 0)
290
+ return { kind: "snapshot" };
291
+ const deps = this.freeDependencies(init, node);
292
+ // A value computed from a snapshot is itself snapshotted: the
293
+ // program keeps `headline`, not the whole fetch result it came from.
294
+ if (deps.some((dep) => this.blocksKeeping(dep) || this.isSnapshot(dep))) {
295
+ return { kind: "snapshot" };
296
+ }
297
+ return {
298
+ kind: "decl",
299
+ at: node.start,
300
+ src: `const ${this.code.slice(node.start, node.end)};`,
301
+ deps
302
+ };
303
+ }
304
+ case "FunctionName":
305
+ case "ClassName":
306
+ return this.classifyFunction(variable, node, node, this.code.slice(node.start, node.end));
307
+ default:
308
+ return { kind: "snapshot" };
309
+ }
310
+ }
311
+ /**
312
+ * A function or class is kept as source text. It may read a snapshot: the
313
+ * snapshot is printed before it, inside the scene's block, so a shared
314
+ * counter it increments starts where it stood when the scene was built.
315
+ */
316
+ classifyFunction(variable, fn, declaration, src) {
317
+ const what = fn.type === "ClassDeclaration" ? "class" : "function";
318
+ if (fn["async"] || fn["generator"]) {
319
+ return {
320
+ kind: "error",
321
+ message: `\`${variable.name}\` is an async or generator ${what}, which a scene cannot keep.`
322
+ };
323
+ }
324
+ const writes = variable.references.filter((ref) => ref.isWrite() && !ref.init);
325
+ if (writes.length > 0) {
326
+ return {
327
+ kind: "error",
328
+ message: `\`${variable.name}\` is reassigned, so its source text is not its value.`
329
+ };
330
+ }
331
+ const random = this.randomnessProblems(fn);
332
+ if (random.length > 0)
333
+ return { kind: "error", message: random[0] };
334
+ const deps = this.freeDependencies(fn, declaration);
335
+ for (const dep of deps) {
336
+ if (this.blocksKeeping(dep)) {
337
+ const name = "global" in dep ? dep.global : dep.variable.name;
338
+ return {
339
+ kind: "error",
340
+ message: `The ${what} \`${variable.name}\` uses \`${name}\`, which a rebake ` +
341
+ "cannot reach. Pass the value in as an argument instead."
342
+ };
343
+ }
344
+ }
345
+ return { kind: "decl", at: declaration.start, src, deps };
346
+ }
347
+ /**
348
+ * True when a declaration that depends on `dep` cannot be kept as source
349
+ * text: the dependency is an error, or a capability global.
350
+ */
351
+ blocksKeeping(dep) {
352
+ if ("global" in dep)
353
+ return !SAFE_GLOBALS.has(dep.global);
354
+ const cls = this.classify(dep.variable);
355
+ return cls.kind === "error";
356
+ }
357
+ isSnapshot(dep) {
358
+ return "variable" in dep && this.classify(dep.variable).kind === "snapshot";
359
+ }
360
+ globalProblem(name, node) {
361
+ if (SAFE_GLOBALS.has(name))
362
+ return null;
363
+ const line = lineOf(this.code, node.start);
364
+ return (`\`${name}\` (line ${line}) is not available when the timeline is ` +
365
+ "rebaked. Call it at the top level, before the scene, and use its result.");
366
+ }
367
+ /** Direct uses of `Math.random()` / `Date.now()` / `new Date()` inside `node`. */
368
+ randomnessProblems(node) {
369
+ const problems = [];
370
+ forEachNode(node, (child) => {
371
+ const target = child.type === "CallExpression" || child.type === "NewExpression"
372
+ ? child["callee"]
373
+ : null;
374
+ if (!target)
375
+ return;
376
+ const text = this.code.slice(target.start, target.end);
377
+ const isRandom = text === "Math.random" || text === "Date.now";
378
+ const isNewDate = child.type === "NewExpression" && text === "Date";
379
+ if (!isRandom && !isNewDate)
380
+ return;
381
+ const ref = this.referenceAt((target.type === "MemberExpression" ? target["object"] : target));
382
+ if (ref?.resolved)
383
+ return;
384
+ problems.push(`\`${text}()\` (line ${lineOf(this.code, child.start)}) gives a different ` +
385
+ "value on every rebake. Use hash(n) or noise(seed) from the pack, or " +
386
+ "compute the value at the top level.");
387
+ });
388
+ return problems;
389
+ }
390
+ isVideoCall(init) {
391
+ if (init.type !== "CallExpression")
392
+ return false;
393
+ const callee = init["callee"];
394
+ if (callee.type !== "Identifier")
395
+ return false;
396
+ const variable = this.referenceAt(callee)?.resolved;
397
+ const def = variable?.defs[0];
398
+ if (!def || def.type !== "ImportBinding")
399
+ return false;
400
+ const source = def.parent["source"];
401
+ const spec = def.node;
402
+ return (source["value"] === TIMELINE_PACK &&
403
+ spec.type === "ImportSpecifier" &&
404
+ spec["imported"]["name"] === "video");
405
+ }
406
+ /**
407
+ * True when code outside the initializer changes the object `variable`
408
+ * holds, so the initializer text no longer describes the value.
409
+ */
410
+ isMutated(variable, declarator) {
411
+ for (const ref of variable.references) {
412
+ const id = ref.identifier;
413
+ if (id.start >= declarator.start && id.end <= declarator.end)
414
+ continue;
415
+ let current = id;
416
+ let parent = this.parents.get(current);
417
+ let isMember = false;
418
+ while (parent &&
419
+ parent.type === "MemberExpression" &&
420
+ parent["object"] === current) {
421
+ isMember = true;
422
+ current = parent;
423
+ parent = this.parents.get(current);
424
+ }
425
+ if (!parent)
426
+ continue;
427
+ if (isMember) {
428
+ if (parent.type === "AssignmentExpression" && parent["left"] === current)
429
+ return true;
430
+ if (parent.type === "UpdateExpression")
431
+ return true;
432
+ if (parent.type === "UnaryExpression" && parent["operator"] === "delete")
433
+ return true;
434
+ if (parent.type === "CallExpression" && parent["callee"] === current) {
435
+ const property = current["property"];
436
+ if (MUTATING_METHODS.has(String(property["name"])))
437
+ return true;
438
+ }
439
+ }
440
+ else if (parent.type === "CallExpression" &&
441
+ parent["arguments"][0] === id &&
442
+ this.code.slice(parent["callee"].start, parent["callee"].end) === "Object.assign") {
443
+ return true;
444
+ }
445
+ }
446
+ return false;
447
+ }
448
+ /**
449
+ * The variables and globals `node` refers to that are declared outside
450
+ * it. `self` (a declarator) is excluded, so a recursive arrow does not
451
+ * depend on itself.
452
+ */
453
+ freeDependencies(node, self) {
454
+ const deps = new Map();
455
+ for (const ref of this.references) {
456
+ const id = ref.identifier;
457
+ if (id.start < node.start || id.end > node.end)
458
+ continue;
459
+ const variable = ref.resolved;
460
+ if (!variable) {
461
+ const name = ref.identifier.name;
462
+ if (!deps.has(name))
463
+ deps.set(name, { global: name, node: id });
464
+ continue;
465
+ }
466
+ const declared = variable.identifiers[0];
467
+ if (declared && declared.start >= node.start && declared.end <= node.end) {
468
+ continue;
469
+ }
470
+ if (self && declared && declared.start >= self.start && declared.end <= self.end) {
471
+ continue;
472
+ }
473
+ if (!deps.has(variable))
474
+ deps.set(variable, { variable });
475
+ }
476
+ return [...deps.values()];
477
+ }
478
+ dependencyFor(identifier) {
479
+ const ref = this.referenceAt(identifier);
480
+ if (!ref)
481
+ return [];
482
+ return ref.resolved
483
+ ? [{ variable: ref.resolved }]
484
+ : [{ global: ref.identifier.name, node: identifier }];
485
+ }
486
+ referenceAt(identifier) {
487
+ return this.references.find((ref) => ref.identifier.start === identifier.start);
488
+ }
489
+ }
490
+ function resolveName(scope, name) {
491
+ for (let current = scope; current; current = current.upper) {
492
+ const variable = current.set.get(name);
493
+ if (variable)
494
+ return variable;
495
+ }
496
+ return null;
497
+ }
498
+ /** True when `node` awaits or yields, not counting nested functions. */
499
+ function containsAwait(node) {
500
+ let found = false;
501
+ forEachNode(node, (child) => {
502
+ if (child.type === "AwaitExpression" || child.type === "YieldExpression") {
503
+ found = true;
504
+ }
505
+ }, true);
506
+ return found;
507
+ }
508
+ function lineOf(code, offset) {
509
+ let line = 1;
510
+ for (let i = 0; i < offset; i++)
511
+ if (code.charCodeAt(i) === 10)
512
+ line++;
513
+ return line;
514
+ }
515
+ function isNode(value) {
516
+ return (value !== null &&
517
+ typeof value === "object" &&
518
+ typeof value.type === "string");
519
+ }
520
+ const FUNCTION_TYPES = new Set([
521
+ "FunctionDeclaration",
522
+ "FunctionExpression",
523
+ "ArrowFunctionExpression"
524
+ ]);
525
+ /** Visit `root` and every node below it. `skipFunctions` stops at nested functions. */
526
+ function forEachNode(root, visit, skipFunctions = false) {
527
+ const stack = [[root, null]];
528
+ while (stack.length > 0) {
529
+ const [node, parent] = stack.pop();
530
+ visit(node, parent);
531
+ if (skipFunctions && node !== root && FUNCTION_TYPES.has(node.type))
532
+ continue;
533
+ for (const key of Object.keys(node)) {
534
+ if (key === "type" || key === "start" || key === "end")
535
+ continue;
536
+ const value = node[key];
537
+ if (Array.isArray(value)) {
538
+ for (const item of value)
539
+ if (isNode(item))
540
+ stack.push([item, node]);
541
+ }
542
+ else if (isNode(value)) {
543
+ stack.push([value, node]);
544
+ }
545
+ }
546
+ }
547
+ }
548
+ /**
549
+ * Print a capture record as a JS object literal on one line. The snapshot
550
+ * thunks are real code: each one reads its variable where the scene is
551
+ * built. The pack calls each thunk inside its own `try`, so a variable
552
+ * still in its temporal dead zone gives an error, not a crash.
553
+ */
554
+ function printRecord(record) {
555
+ const snap = record.snap
556
+ .map((name) => `[${JSON.stringify(name)},()=>${name}]`)
557
+ .join(",");
558
+ return (`{__ntCapture:1,src:${JSON.stringify(record.src)},` +
559
+ `video:${JSON.stringify(record.video)},` +
560
+ `decls:${JSON.stringify(record.decls)},` +
561
+ `imports:${JSON.stringify(record.imports)},` +
562
+ `snap:[${snap}],errors:${JSON.stringify(record.errors)}}`);
563
+ }
564
+ //# sourceMappingURL=timeline-capture.js.map
@@ -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"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Bake a timeline's authoring code: run an `@nodetool-ai/sandbox-timeline`
3
+ * program once and hand back the `TimelineDocument` it built, without
4
+ * writing anywhere.
5
+ *
6
+ * The stored code is a retained program (docs/timeline-code-capture.md):
7
+ * research, generation and every other capability call ran once, in the
8
+ * author's run, and their results are literals in the program. So a bake is
9
+ * hermetic by construction. It gets no network, no secrets and no
10
+ * capability except a stub for `nodetool.timelines`:
11
+ *
12
+ * - `create`/`setDocument` capture the document `v.save()` hands them.
13
+ * - `validate` answers `ok: true`. The caller writes the result through the
14
+ * real `set_timeline_document` path afterward, which validates for real.
15
+ * - `edit` records `v.save()`'s `ops`. This function applies them afterward
16
+ * with `applyOps`, the pure op applier `edit_timeline` uses, over an
17
+ * in-memory `TimelineSequence` that is never saved.
18
+ * - `code.set` answers that nothing was attached, so the `v.save()` inside
19
+ * a bake does not start a second bake.
20
+ * - `bakeAudioAnimation` (`el.react()`) needs a real decode and is refused.
21
+ *
22
+ * Any other capability call fails the bake and names the call. The bake runs
23
+ * on a copy of the context with no workspace, and `applyOps` runs without
24
+ * the hooks that write (a 3D render, a retargeted sequence). A bake reads
25
+ * assets and runs custom animation bodies. It writes nothing.
26
+ */
27
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
28
+ import { type TimelineDocumentLike } from "@nodetool-ai/timeline";
29
+ /** Wall-clock ceiling on a bake. Building a document is arithmetic over a
30
+ * bounded scene list; anything slower is a runaway script, and a caller
31
+ * (an agent, or the editor) is waiting on this call. */
32
+ export declare const TIMELINE_CODE_BAKE_TIMEOUT_SECONDS = 20;
33
+ export interface BakeTimelineCodeResult {
34
+ ok: boolean;
35
+ /** Present only when `ok`. */
36
+ document?: TimelineDocumentLike;
37
+ logs: string[];
38
+ error?: string;
39
+ duration_ms: number;
40
+ /**
41
+ * The retained program the code's own `v.save()` printed, when capture
42
+ * ran. Baking this program gives the same document again.
43
+ */
44
+ retainedProgram?: string;
45
+ }
46
+ /**
47
+ * `context` with every path to the run's workspace removed. The sandbox then
48
+ * gives the guest a `workspace` that refuses every call, and so does the
49
+ * sandbox a custom animation body runs in.
50
+ */
51
+ export declare function hermeticBakeContext(context: ProcessingContext): ProcessingContext;
52
+ /**
53
+ * Run one timeline authoring script and return the document its `v.save()`
54
+ * call wrote. Returns rather than throws: a script that fails is a result to
55
+ * report to the caller (and, through it, the agent that wrote the code).
56
+ */
57
+ export declare function bakeTimelineCode(hostContext: ProcessingContext, code: string): Promise<BakeTimelineCodeResult>;
58
+ /**
59
+ * Whether `baked` — a fresh hermetic rebuild of some code — is the same
60
+ * timeline `saved` already is: every scene the two share hashes the same
61
+ * (`hashSceneSubtree`, the same identity check `mergeTimelineSource` uses to
62
+ * tell an untouched scene from a hand-edited one), the two name the same
63
+ * scenes, and everything outside a scene (passthrough clips, tracks, markers,
64
+ * tempo, camera2d, setup, mediaTracks) matches after the same normalization
65
+ * a bake already applies (`normalizeAuthoredDocument`, inside
66
+ * {@link bakeTimelineCode}).
67
+ *
68
+ * This is the gate for attaching the retained program `v.save()` printed:
69
+ * only when a hermetic bake of that program reproduces what was saved is it
70
+ * a faithful record of the document. A mismatch means the capture missed
71
+ * something (a scene clip changed after `v.series()`, a value computed with
72
+ * `Math.random()` or `Date.now()`).
73
+ */
74
+ export declare function bakedDocumentMatchesSaved(saved: TimelineDocumentLike, baked: TimelineDocumentLike): boolean;
75
+ //# sourceMappingURL=timeline-code-bake.d.ts.map