@nodetool-ai/runtime 0.7.0-rc.22 → 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 (665) hide show
  1. package/README.md +29 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/agent-memory.d.ts +118 -0
  4. package/dist/agent-memory.d.ts.map +1 -0
  5. package/dist/agent-memory.js +186 -0
  6. package/dist/agent-memory.js.map +1 -0
  7. package/dist/async-local-storage.d.ts +20 -0
  8. package/dist/async-local-storage.d.ts.map +1 -0
  9. package/dist/async-local-storage.js +28 -0
  10. package/dist/async-local-storage.js.map +1 -0
  11. package/dist/blender-executor.d.ts +93 -0
  12. package/dist/blender-executor.d.ts.map +1 -0
  13. package/dist/blender-executor.js +294 -0
  14. package/dist/blender-executor.js.map +1 -0
  15. package/dist/comfy-executor.d.ts +23 -1
  16. package/dist/comfy-executor.d.ts.map +1 -1
  17. package/dist/comfy-executor.js +234 -55
  18. package/dist/comfy-executor.js.map +1 -1
  19. package/dist/context-packer.d.ts +1 -1
  20. package/dist/context-packer.d.ts.map +1 -1
  21. package/dist/context-packer.js +23 -25
  22. package/dist/context-packer.js.map +1 -1
  23. package/dist/context.d.ts +954 -127
  24. package/dist/context.d.ts.map +1 -1
  25. package/dist/context.js +2424 -513
  26. package/dist/context.js.map +1 -1
  27. package/dist/cost-reconciler.d.ts +32 -0
  28. package/dist/cost-reconciler.d.ts.map +1 -0
  29. package/dist/cost-reconciler.js +21 -0
  30. package/dist/cost-reconciler.js.map +1 -0
  31. package/dist/entities.d.ts +33 -0
  32. package/dist/entities.d.ts.map +1 -0
  33. package/dist/entities.js +43 -0
  34. package/dist/entities.js.map +1 -0
  35. package/dist/external-media-fetch.d.ts +29 -0
  36. package/dist/external-media-fetch.d.ts.map +1 -0
  37. package/dist/external-media-fetch.js +38 -0
  38. package/dist/external-media-fetch.js.map +1 -0
  39. package/dist/generation-receipt.d.ts +86 -0
  40. package/dist/generation-receipt.d.ts.map +1 -0
  41. package/dist/generation-receipt.js +137 -0
  42. package/dist/generation-receipt.js.map +1 -0
  43. package/dist/generation-registry.d.ts +67 -0
  44. package/dist/generation-registry.d.ts.map +1 -0
  45. package/dist/generation-registry.js +126 -0
  46. package/dist/generation-registry.js.map +1 -0
  47. package/dist/google/client.d.ts +196 -0
  48. package/dist/google/client.d.ts.map +1 -0
  49. package/dist/google/client.js +396 -0
  50. package/dist/google/client.js.map +1 -0
  51. package/dist/google/index.d.ts +3 -0
  52. package/dist/google/index.d.ts.map +1 -0
  53. package/dist/google/index.js +3 -0
  54. package/dist/google/index.js.map +1 -0
  55. package/dist/google/token.d.ts +15 -0
  56. package/dist/google/token.d.ts.map +1 -0
  57. package/dist/google/token.js +24 -0
  58. package/dist/google/token.js.map +1 -0
  59. package/dist/host-binaries.d.ts +106 -0
  60. package/dist/host-binaries.d.ts.map +1 -0
  61. package/dist/host-binaries.js +344 -0
  62. package/dist/host-binaries.js.map +1 -0
  63. package/dist/image-codec.d.ts +74 -0
  64. package/dist/image-codec.d.ts.map +1 -0
  65. package/dist/image-codec.js +273 -0
  66. package/dist/image-codec.js.map +1 -0
  67. package/dist/index.d.ts +56 -6
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +43 -4
  70. package/dist/index.js.map +1 -1
  71. package/dist/invocation-account.d.ts +43 -0
  72. package/dist/invocation-account.d.ts.map +1 -0
  73. package/dist/invocation-account.js +60 -0
  74. package/dist/invocation-account.js.map +1 -0
  75. package/dist/media-ref-bytes.d.ts +19 -0
  76. package/dist/media-ref-bytes.d.ts.map +1 -0
  77. package/dist/media-ref-bytes.js +181 -0
  78. package/dist/media-ref-bytes.js.map +1 -0
  79. package/dist/node-executor.d.ts +113 -2
  80. package/dist/node-executor.d.ts.map +1 -1
  81. package/dist/permission-gate.d.ts +152 -0
  82. package/dist/permission-gate.d.ts.map +1 -0
  83. package/dist/permission-gate.js +87 -0
  84. package/dist/permission-gate.js.map +1 -0
  85. package/dist/prefixed-storage-adapter.d.ts +33 -0
  86. package/dist/prefixed-storage-adapter.d.ts.map +1 -0
  87. package/dist/prefixed-storage-adapter.js +70 -0
  88. package/dist/prefixed-storage-adapter.js.map +1 -0
  89. package/dist/prompt-asset-refs.d.ts +222 -0
  90. package/dist/prompt-asset-refs.d.ts.map +1 -0
  91. package/dist/prompt-asset-refs.js +751 -0
  92. package/dist/prompt-asset-refs.js.map +1 -0
  93. package/dist/provider-cache.d.ts +3 -0
  94. package/dist/provider-cache.d.ts.map +1 -0
  95. package/dist/provider-cache.js +8 -0
  96. package/dist/provider-cache.js.map +1 -0
  97. package/dist/providers/aki-provider.d.ts +33 -10
  98. package/dist/providers/aki-provider.d.ts.map +1 -1
  99. package/dist/providers/aki-provider.js +84 -77
  100. package/dist/providers/aki-provider.js.map +1 -1
  101. package/dist/providers/alibaba-provider.d.ts +39 -0
  102. package/dist/providers/alibaba-provider.d.ts.map +1 -0
  103. package/dist/providers/alibaba-provider.js +86 -0
  104. package/dist/providers/alibaba-provider.js.map +1 -0
  105. package/dist/providers/anthropic-provider.d.ts +52 -3
  106. package/dist/providers/anthropic-provider.d.ts.map +1 -1
  107. package/dist/providers/anthropic-provider.js +1020 -338
  108. package/dist/providers/anthropic-provider.js.map +1 -1
  109. package/dist/providers/atlascloud-provider.d.ts +101 -0
  110. package/dist/providers/atlascloud-provider.d.ts.map +1 -0
  111. package/dist/providers/atlascloud-provider.js +1009 -0
  112. package/dist/providers/atlascloud-provider.js.map +1 -0
  113. package/dist/providers/atlascloud-transport.d.ts +100 -0
  114. package/dist/providers/atlascloud-transport.d.ts.map +1 -0
  115. package/dist/providers/atlascloud-transport.js +364 -0
  116. package/dist/providers/atlascloud-transport.js.map +1 -0
  117. package/dist/providers/atlascloud-webhook-registry.d.ts +35 -0
  118. package/dist/providers/atlascloud-webhook-registry.d.ts.map +1 -0
  119. package/dist/providers/atlascloud-webhook-registry.js +104 -0
  120. package/dist/providers/atlascloud-webhook-registry.js.map +1 -0
  121. package/dist/providers/audio-mime.d.ts +11 -0
  122. package/dist/providers/audio-mime.d.ts.map +1 -0
  123. package/dist/providers/audio-mime.js +46 -0
  124. package/dist/providers/audio-mime.js.map +1 -0
  125. package/dist/providers/base-provider.d.ts +481 -24
  126. package/dist/providers/base-provider.d.ts.map +1 -1
  127. package/dist/providers/base-provider.js +1259 -42
  128. package/dist/providers/base-provider.js.map +1 -1
  129. package/dist/providers/cassette-provider.d.ts +217 -0
  130. package/dist/providers/cassette-provider.d.ts.map +1 -0
  131. package/dist/providers/cassette-provider.js +502 -0
  132. package/dist/providers/cassette-provider.js.map +1 -0
  133. package/dist/providers/cerebras-provider.d.ts +6 -12
  134. package/dist/providers/cerebras-provider.d.ts.map +1 -1
  135. package/dist/providers/cerebras-provider.js +8 -33
  136. package/dist/providers/cerebras-provider.js.map +1 -1
  137. package/dist/providers/claude-agent-provider.d.ts +131 -68
  138. package/dist/providers/claude-agent-provider.d.ts.map +1 -1
  139. package/dist/providers/claude-agent-provider.js +1095 -515
  140. package/dist/providers/claude-agent-provider.js.map +1 -1
  141. package/dist/providers/codex-provider.d.ts +82 -0
  142. package/dist/providers/codex-provider.d.ts.map +1 -0
  143. package/dist/providers/codex-provider.js +492 -0
  144. package/dist/providers/codex-provider.js.map +1 -0
  145. package/dist/providers/cohere-provider.d.ts +5 -2
  146. package/dist/providers/cohere-provider.d.ts.map +1 -1
  147. package/dist/providers/cohere-provider.js +9 -2
  148. package/dist/providers/cohere-provider.js.map +1 -1
  149. package/dist/providers/comfy-cloud-provider.d.ts +30 -0
  150. package/dist/providers/comfy-cloud-provider.d.ts.map +1 -0
  151. package/dist/providers/comfy-cloud-provider.js +42 -0
  152. package/dist/providers/comfy-cloud-provider.js.map +1 -0
  153. package/dist/providers/content-filter.d.ts +46 -0
  154. package/dist/providers/content-filter.d.ts.map +1 -0
  155. package/dist/providers/content-filter.js +92 -0
  156. package/dist/providers/content-filter.js.map +1 -0
  157. package/dist/providers/context-exceeded.d.ts +37 -0
  158. package/dist/providers/context-exceeded.d.ts.map +1 -0
  159. package/dist/providers/context-exceeded.js +114 -0
  160. package/dist/providers/context-exceeded.js.map +1 -0
  161. package/dist/providers/context-window.d.ts +44 -0
  162. package/dist/providers/context-window.d.ts.map +1 -0
  163. package/dist/providers/context-window.js +145 -0
  164. package/dist/providers/context-window.js.map +1 -0
  165. package/dist/providers/contract/index.d.ts +4 -0
  166. package/dist/providers/contract/index.d.ts.map +1 -0
  167. package/dist/providers/contract/index.js +4 -0
  168. package/dist/providers/contract/index.js.map +1 -0
  169. package/dist/providers/contract/probe-manifest.d.ts +75 -0
  170. package/dist/providers/contract/probe-manifest.d.ts.map +1 -0
  171. package/dist/providers/contract/probe-manifest.js +379 -0
  172. package/dist/providers/contract/probe-manifest.js.map +1 -0
  173. package/dist/providers/contract/probe-runner.d.ts +57 -0
  174. package/dist/providers/contract/probe-runner.d.ts.map +1 -0
  175. package/dist/providers/contract/probe-runner.js +180 -0
  176. package/dist/providers/contract/probe-runner.js.map +1 -0
  177. package/dist/providers/contract/redact.d.ts +29 -0
  178. package/dist/providers/contract/redact.d.ts.map +1 -0
  179. package/dist/providers/contract/redact.js +113 -0
  180. package/dist/providers/contract/redact.js.map +1 -0
  181. package/dist/providers/core-tools.d.ts +74 -0
  182. package/dist/providers/core-tools.d.ts.map +1 -0
  183. package/dist/providers/core-tools.js +127 -0
  184. package/dist/providers/core-tools.js.map +1 -0
  185. package/dist/providers/cost-calculator.d.ts +69 -50
  186. package/dist/providers/cost-calculator.d.ts.map +1 -1
  187. package/dist/providers/cost-calculator.js +207 -397
  188. package/dist/providers/cost-calculator.js.map +1 -1
  189. package/dist/providers/credential-check.d.ts +45 -0
  190. package/dist/providers/credential-check.d.ts.map +1 -0
  191. package/dist/providers/credential-check.js +159 -0
  192. package/dist/providers/credential-check.js.map +1 -0
  193. package/dist/providers/custom-model-kinds.d.ts +33 -0
  194. package/dist/providers/custom-model-kinds.d.ts.map +1 -0
  195. package/dist/providers/custom-model-kinds.js +96 -0
  196. package/dist/providers/custom-model-kinds.js.map +1 -0
  197. package/dist/providers/custom-openai-provider.d.ts +81 -0
  198. package/dist/providers/custom-openai-provider.d.ts.map +1 -0
  199. package/dist/providers/custom-openai-provider.js +182 -0
  200. package/dist/providers/custom-openai-provider.js.map +1 -0
  201. package/dist/providers/custom-provider-registry.d.ts +19 -0
  202. package/dist/providers/custom-provider-registry.d.ts.map +1 -0
  203. package/dist/providers/custom-provider-registry.js +52 -0
  204. package/dist/providers/custom-provider-registry.js.map +1 -0
  205. package/dist/providers/deepseek-provider.d.ts +8 -14
  206. package/dist/providers/deepseek-provider.d.ts.map +1 -1
  207. package/dist/providers/deepseek-provider.js +6 -35
  208. package/dist/providers/deepseek-provider.js.map +1 -1
  209. package/dist/providers/defaults.d.ts +12 -0
  210. package/dist/providers/defaults.d.ts.map +1 -0
  211. package/dist/providers/defaults.js +12 -0
  212. package/dist/providers/defaults.js.map +1 -0
  213. package/dist/providers/elevenlabs-provider.d.ts +49 -0
  214. package/dist/providers/elevenlabs-provider.d.ts.map +1 -0
  215. package/dist/providers/elevenlabs-provider.js +142 -0
  216. package/dist/providers/elevenlabs-provider.js.map +1 -0
  217. package/dist/providers/entity-references.d.ts +31 -0
  218. package/dist/providers/entity-references.d.ts.map +1 -0
  219. package/dist/providers/entity-references.js +113 -0
  220. package/dist/providers/entity-references.js.map +1 -0
  221. package/dist/providers/evolink-provider.d.ts +38 -0
  222. package/dist/providers/evolink-provider.d.ts.map +1 -0
  223. package/dist/providers/evolink-provider.js +304 -0
  224. package/dist/providers/evolink-provider.js.map +1 -0
  225. package/dist/providers/fake-provider.d.ts +72 -1
  226. package/dist/providers/fake-provider.d.ts.map +1 -1
  227. package/dist/providers/fake-provider.js +203 -1
  228. package/dist/providers/fake-provider.js.map +1 -1
  229. package/dist/providers/fal-generations.d.ts +106 -0
  230. package/dist/providers/fal-generations.d.ts.map +1 -0
  231. package/dist/providers/fal-generations.js +286 -0
  232. package/dist/providers/fal-generations.js.map +1 -0
  233. package/dist/providers/fal-provider.d.ts +171 -7
  234. package/dist/providers/fal-provider.d.ts.map +1 -1
  235. package/dist/providers/fal-provider.js +1369 -64
  236. package/dist/providers/fal-provider.js.map +1 -1
  237. package/dist/providers/fal-queue.d.ts +47 -0
  238. package/dist/providers/fal-queue.d.ts.map +1 -0
  239. package/dist/providers/fal-queue.js +231 -0
  240. package/dist/providers/fal-queue.js.map +1 -0
  241. package/dist/providers/gemini-provider.d.ts +148 -8
  242. package/dist/providers/gemini-provider.d.ts.map +1 -1
  243. package/dist/providers/gemini-provider.js +1500 -316
  244. package/dist/providers/gemini-provider.js.map +1 -1
  245. package/dist/providers/gmi-provider.d.ts +21 -0
  246. package/dist/providers/gmi-provider.d.ts.map +1 -0
  247. package/dist/providers/gmi-provider.js +34 -0
  248. package/dist/providers/gmi-provider.js.map +1 -0
  249. package/dist/providers/gpt-image-size.d.ts +3 -0
  250. package/dist/providers/gpt-image-size.d.ts.map +1 -0
  251. package/dist/providers/gpt-image-size.js +37 -0
  252. package/dist/providers/gpt-image-size.js.map +1 -0
  253. package/dist/providers/groq-provider.d.ts +9 -12
  254. package/dist/providers/groq-provider.d.ts.map +1 -1
  255. package/dist/providers/groq-provider.js +19 -33
  256. package/dist/providers/groq-provider.js.map +1 -1
  257. package/dist/providers/groq-request.d.ts +38 -0
  258. package/dist/providers/groq-request.d.ts.map +1 -0
  259. package/dist/providers/groq-request.js +138 -0
  260. package/dist/providers/groq-request.js.map +1 -0
  261. package/dist/providers/higgsfield-provider.d.ts +30 -0
  262. package/dist/providers/higgsfield-provider.d.ts.map +1 -0
  263. package/dist/providers/higgsfield-provider.js +131 -0
  264. package/dist/providers/higgsfield-provider.js.map +1 -0
  265. package/dist/providers/higgsfield-transport.d.ts +106 -0
  266. package/dist/providers/higgsfield-transport.d.ts.map +1 -0
  267. package/dist/providers/higgsfield-transport.js +182 -0
  268. package/dist/providers/higgsfield-transport.js.map +1 -0
  269. package/dist/providers/http-transport.d.ts +74 -0
  270. package/dist/providers/http-transport.d.ts.map +1 -0
  271. package/dist/providers/http-transport.js +152 -0
  272. package/dist/providers/http-transport.js.map +1 -0
  273. package/dist/providers/huggingface-provider.d.ts +71 -3
  274. package/dist/providers/huggingface-provider.d.ts.map +1 -1
  275. package/dist/providers/huggingface-provider.js +230 -34
  276. package/dist/providers/huggingface-provider.js.map +1 -1
  277. package/dist/providers/image-mime.d.ts +39 -0
  278. package/dist/providers/image-mime.d.ts.map +1 -0
  279. package/dist/providers/image-mime.js +111 -0
  280. package/dist/providers/image-mime.js.map +1 -0
  281. package/dist/providers/image-ref.d.ts +21 -0
  282. package/dist/providers/image-ref.d.ts.map +1 -0
  283. package/dist/providers/image-ref.js +44 -0
  284. package/dist/providers/image-ref.js.map +1 -0
  285. package/dist/providers/index.d.ts +84 -8
  286. package/dist/providers/index.d.ts.map +1 -1
  287. package/dist/providers/index.js +239 -56
  288. package/dist/providers/index.js.map +1 -1
  289. package/dist/providers/jina-provider.d.ts +10 -2
  290. package/dist/providers/jina-provider.d.ts.map +1 -1
  291. package/dist/providers/jina-provider.js +16 -7
  292. package/dist/providers/jina-provider.js.map +1 -1
  293. package/dist/providers/kie-provider.d.ts +170 -9
  294. package/dist/providers/kie-provider.d.ts.map +1 -1
  295. package/dist/providers/kie-provider.js +1176 -228
  296. package/dist/providers/kie-provider.js.map +1 -1
  297. package/dist/providers/kie-webhook-registry.d.ts +28 -0
  298. package/dist/providers/kie-webhook-registry.d.ts.map +1 -0
  299. package/dist/providers/kie-webhook-registry.js +91 -0
  300. package/dist/providers/kie-webhook-registry.js.map +1 -0
  301. package/dist/providers/llama-provider.d.ts +21 -37
  302. package/dist/providers/llama-provider.d.ts.map +1 -1
  303. package/dist/providers/llama-provider.js +43 -354
  304. package/dist/providers/llama-provider.js.map +1 -1
  305. package/dist/providers/lmstudio-provider.d.ts +4 -7
  306. package/dist/providers/lmstudio-provider.d.ts.map +1 -1
  307. package/dist/providers/lmstudio-provider.js +24 -15
  308. package/dist/providers/lmstudio-provider.js.map +1 -1
  309. package/dist/providers/manifest-models.d.ts +341 -1
  310. package/dist/providers/manifest-models.d.ts.map +1 -1
  311. package/dist/providers/manifest-models.js +1106 -22
  312. package/dist/providers/manifest-models.js.map +1 -1
  313. package/dist/providers/media-mime.d.ts +14 -0
  314. package/dist/providers/media-mime.d.ts.map +1 -0
  315. package/dist/providers/media-mime.js +35 -0
  316. package/dist/providers/media-mime.js.map +1 -0
  317. package/dist/providers/meshy-provider.d.ts +14 -1
  318. package/dist/providers/meshy-provider.d.ts.map +1 -1
  319. package/dist/providers/meshy-provider.js +76 -46
  320. package/dist/providers/meshy-provider.js.map +1 -1
  321. package/dist/providers/meta-provider.d.ts +22 -0
  322. package/dist/providers/meta-provider.d.ts.map +1 -0
  323. package/dist/providers/meta-provider.js +54 -0
  324. package/dist/providers/meta-provider.js.map +1 -0
  325. package/dist/providers/minimax-provider.d.ts +25 -18
  326. package/dist/providers/minimax-provider.d.ts.map +1 -1
  327. package/dist/providers/minimax-provider.js +211 -72
  328. package/dist/providers/minimax-provider.js.map +1 -1
  329. package/dist/providers/mistral-provider.d.ts +6 -12
  330. package/dist/providers/mistral-provider.d.ts.map +1 -1
  331. package/dist/providers/mistral-provider.js +10 -34
  332. package/dist/providers/mistral-provider.js.map +1 -1
  333. package/dist/providers/moonshot-provider.d.ts +11 -15
  334. package/dist/providers/moonshot-provider.d.ts.map +1 -1
  335. package/dist/providers/moonshot-provider.js +33 -23
  336. package/dist/providers/moonshot-provider.js.map +1 -1
  337. package/dist/providers/node-llama-cpp-provider.d.ts +98 -0
  338. package/dist/providers/node-llama-cpp-provider.d.ts.map +1 -0
  339. package/dist/providers/node-llama-cpp-provider.js +479 -0
  340. package/dist/providers/node-llama-cpp-provider.js.map +1 -0
  341. package/dist/providers/nodetool-provider.d.ts +49 -0
  342. package/dist/providers/nodetool-provider.d.ts.map +1 -0
  343. package/dist/providers/nodetool-provider.js +224 -0
  344. package/dist/providers/nodetool-provider.js.map +1 -0
  345. package/dist/providers/oauth/browser-launcher.d.ts +23 -0
  346. package/dist/providers/oauth/browser-launcher.d.ts.map +1 -0
  347. package/dist/providers/oauth/browser-launcher.js +45 -0
  348. package/dist/providers/oauth/browser-launcher.js.map +1 -0
  349. package/dist/providers/oauth/claude-code-credentials.d.ts +74 -0
  350. package/dist/providers/oauth/claude-code-credentials.d.ts.map +1 -0
  351. package/dist/providers/oauth/claude-code-credentials.js +133 -0
  352. package/dist/providers/oauth/claude-code-credentials.js.map +1 -0
  353. package/dist/providers/oauth/claude-code-login.d.ts +124 -0
  354. package/dist/providers/oauth/claude-code-login.d.ts.map +1 -0
  355. package/dist/providers/oauth/claude-code-login.js +230 -0
  356. package/dist/providers/oauth/claude-code-login.js.map +1 -0
  357. package/dist/providers/oauth/claude-code-oauth-client.d.ts +111 -0
  358. package/dist/providers/oauth/claude-code-oauth-client.d.ts.map +1 -0
  359. package/dist/providers/oauth/claude-code-oauth-client.js +207 -0
  360. package/dist/providers/oauth/claude-code-oauth-client.js.map +1 -0
  361. package/dist/providers/oauth/errors.d.ts +54 -0
  362. package/dist/providers/oauth/errors.d.ts.map +1 -0
  363. package/dist/providers/oauth/errors.js +79 -0
  364. package/dist/providers/oauth/errors.js.map +1 -0
  365. package/dist/providers/oauth/index.d.ts +105 -0
  366. package/dist/providers/oauth/index.d.ts.map +1 -0
  367. package/dist/providers/oauth/index.js +167 -0
  368. package/dist/providers/oauth/index.js.map +1 -0
  369. package/dist/providers/oauth/jwt-claims.d.ts +23 -0
  370. package/dist/providers/oauth/jwt-claims.d.ts.map +1 -0
  371. package/dist/providers/oauth/jwt-claims.js +67 -0
  372. package/dist/providers/oauth/jwt-claims.js.map +1 -0
  373. package/dist/providers/oauth/local-callback-server.d.ts +60 -0
  374. package/dist/providers/oauth/local-callback-server.d.ts.map +1 -0
  375. package/dist/providers/oauth/local-callback-server.js +148 -0
  376. package/dist/providers/oauth/local-callback-server.js.map +1 -0
  377. package/dist/providers/oauth/oauth-client.d.ts +55 -0
  378. package/dist/providers/oauth/oauth-client.d.ts.map +1 -0
  379. package/dist/providers/oauth/oauth-client.js +161 -0
  380. package/dist/providers/oauth/oauth-client.js.map +1 -0
  381. package/dist/providers/oauth/openai-oauth-provider.d.ts +129 -0
  382. package/dist/providers/oauth/openai-oauth-provider.d.ts.map +1 -0
  383. package/dist/providers/oauth/openai-oauth-provider.js +265 -0
  384. package/dist/providers/oauth/openai-oauth-provider.js.map +1 -0
  385. package/dist/providers/oauth/pkce-helper.d.ts +43 -0
  386. package/dist/providers/oauth/pkce-helper.d.ts.map +1 -0
  387. package/dist/providers/oauth/pkce-helper.js +57 -0
  388. package/dist/providers/oauth/pkce-helper.js.map +1 -0
  389. package/dist/providers/oauth/redaction.d.ts +22 -0
  390. package/dist/providers/oauth/redaction.d.ts.map +1 -0
  391. package/dist/providers/oauth/redaction.js +59 -0
  392. package/dist/providers/oauth/redaction.js.map +1 -0
  393. package/dist/providers/oauth/secure-credential-store.d.ts +67 -0
  394. package/dist/providers/oauth/secure-credential-store.d.ts.map +1 -0
  395. package/dist/providers/oauth/secure-credential-store.js +73 -0
  396. package/dist/providers/oauth/secure-credential-store.js.map +1 -0
  397. package/dist/providers/oauth/token-store.d.ts +53 -0
  398. package/dist/providers/oauth/token-store.d.ts.map +1 -0
  399. package/dist/providers/oauth/token-store.js +78 -0
  400. package/dist/providers/oauth/token-store.js.map +1 -0
  401. package/dist/providers/oauth/types.d.ts +64 -0
  402. package/dist/providers/oauth/types.d.ts.map +1 -0
  403. package/dist/providers/oauth/types.js +12 -0
  404. package/dist/providers/oauth/types.js.map +1 -0
  405. package/dist/providers/object-tracking.d.ts +47 -0
  406. package/dist/providers/object-tracking.d.ts.map +1 -0
  407. package/dist/providers/object-tracking.js +46 -0
  408. package/dist/providers/object-tracking.js.map +1 -0
  409. package/dist/providers/offline-model-index.d.ts +20 -0
  410. package/dist/providers/offline-model-index.d.ts.map +1 -0
  411. package/dist/providers/offline-model-index.js +112 -0
  412. package/dist/providers/offline-model-index.js.map +1 -0
  413. package/dist/providers/ollama-provider.d.ts +28 -1
  414. package/dist/providers/ollama-provider.d.ts.map +1 -1
  415. package/dist/providers/ollama-provider.js +193 -43
  416. package/dist/providers/ollama-provider.js.map +1 -1
  417. package/dist/providers/openai-compat/client.d.ts +57 -0
  418. package/dist/providers/openai-compat/client.d.ts.map +1 -0
  419. package/dist/providers/openai-compat/client.js +157 -0
  420. package/dist/providers/openai-compat/client.js.map +1 -0
  421. package/dist/providers/openai-compat/decode.d.ts +36 -0
  422. package/dist/providers/openai-compat/decode.d.ts.map +1 -0
  423. package/dist/providers/openai-compat/decode.js +55 -0
  424. package/dist/providers/openai-compat/decode.js.map +1 -0
  425. package/dist/providers/openai-compat/errors.d.ts +54 -0
  426. package/dist/providers/openai-compat/errors.d.ts.map +1 -0
  427. package/dist/providers/openai-compat/errors.js +144 -0
  428. package/dist/providers/openai-compat/errors.js.map +1 -0
  429. package/dist/providers/openai-compat/index.d.ts +8 -0
  430. package/dist/providers/openai-compat/index.d.ts.map +1 -0
  431. package/dist/providers/openai-compat/index.js +5 -0
  432. package/dist/providers/openai-compat/index.js.map +1 -0
  433. package/dist/providers/openai-compat/sse.d.ts +14 -0
  434. package/dist/providers/openai-compat/sse.d.ts.map +1 -0
  435. package/dist/providers/openai-compat/sse.js +69 -0
  436. package/dist/providers/openai-compat/sse.js.map +1 -0
  437. package/dist/providers/openai-compat/types.d.ts +75 -0
  438. package/dist/providers/openai-compat/types.d.ts.map +1 -0
  439. package/dist/providers/openai-compat/types.js +9 -0
  440. package/dist/providers/openai-compat/types.js.map +1 -0
  441. package/dist/providers/openai-compat-provider.d.ts +90 -0
  442. package/dist/providers/openai-compat-provider.d.ts.map +1 -0
  443. package/dist/providers/openai-compat-provider.js +282 -0
  444. package/dist/providers/openai-compat-provider.js.map +1 -0
  445. package/dist/providers/openai-provider.d.ts +89 -26
  446. package/dist/providers/openai-provider.d.ts.map +1 -1
  447. package/dist/providers/openai-provider.js +990 -105
  448. package/dist/providers/openai-provider.js.map +1 -1
  449. package/dist/providers/openrouter-provider.d.ts +6 -12
  450. package/dist/providers/openrouter-provider.d.ts.map +1 -1
  451. package/dist/providers/openrouter-provider.js +24 -53
  452. package/dist/providers/openrouter-provider.js.map +1 -1
  453. package/dist/providers/provider-call-failure.d.ts +39 -0
  454. package/dist/providers/provider-call-failure.d.ts.map +1 -0
  455. package/dist/providers/provider-call-failure.js +132 -0
  456. package/dist/providers/provider-call-failure.js.map +1 -0
  457. package/dist/providers/provider-error.d.ts +59 -0
  458. package/dist/providers/provider-error.d.ts.map +1 -0
  459. package/dist/providers/provider-error.js +165 -0
  460. package/dist/providers/provider-error.js.map +1 -0
  461. package/dist/providers/provider-generations.d.ts +99 -0
  462. package/dist/providers/provider-generations.d.ts.map +1 -0
  463. package/dist/providers/provider-generations.js +71 -0
  464. package/dist/providers/provider-generations.js.map +1 -0
  465. package/dist/providers/provider-queue.d.ts +62 -0
  466. package/dist/providers/provider-queue.d.ts.map +1 -0
  467. package/dist/providers/provider-queue.js +28 -0
  468. package/dist/providers/provider-queue.js.map +1 -0
  469. package/dist/providers/provider-registry.d.ts +33 -14
  470. package/dist/providers/provider-registry.d.ts.map +1 -1
  471. package/dist/providers/provider-registry.js +85 -68
  472. package/dist/providers/provider-registry.js.map +1 -1
  473. package/dist/providers/provider-request-log.d.ts +53 -0
  474. package/dist/providers/provider-request-log.d.ts.map +1 -0
  475. package/dist/providers/provider-request-log.js +157 -0
  476. package/dist/providers/provider-request-log.js.map +1 -0
  477. package/dist/providers/provider-session.d.ts +3 -0
  478. package/dist/providers/provider-session.d.ts.map +1 -0
  479. package/dist/providers/provider-session.js +10 -0
  480. package/dist/providers/provider-session.js.map +1 -0
  481. package/dist/providers/provider-transport.d.ts +11 -0
  482. package/dist/providers/provider-transport.d.ts.map +1 -0
  483. package/dist/providers/provider-transport.js +11 -0
  484. package/dist/providers/provider-transport.js.map +1 -0
  485. package/dist/providers/python-provider.d.ts +20 -12
  486. package/dist/providers/python-provider.d.ts.map +1 -1
  487. package/dist/providers/python-provider.js +185 -25
  488. package/dist/providers/python-provider.js.map +1 -1
  489. package/dist/providers/replicate-provider.d.ts +89 -7
  490. package/dist/providers/replicate-provider.d.ts.map +1 -1
  491. package/dist/providers/replicate-provider.js +801 -65
  492. package/dist/providers/replicate-provider.js.map +1 -1
  493. package/dist/providers/replicate-retry.d.ts +30 -0
  494. package/dist/providers/replicate-retry.d.ts.map +1 -0
  495. package/dist/providers/replicate-retry.js +97 -0
  496. package/dist/providers/replicate-retry.js.map +1 -0
  497. package/dist/providers/responses-api.d.ts +27 -0
  498. package/dist/providers/responses-api.d.ts.map +1 -0
  499. package/dist/providers/responses-api.js +297 -0
  500. package/dist/providers/responses-api.js.map +1 -0
  501. package/dist/providers/reve-provider.d.ts +45 -0
  502. package/dist/providers/reve-provider.d.ts.map +1 -0
  503. package/dist/providers/reve-provider.js +159 -0
  504. package/dist/providers/reve-provider.js.map +1 -0
  505. package/dist/providers/rodin-provider.d.ts +23 -1
  506. package/dist/providers/rodin-provider.d.ts.map +1 -1
  507. package/dist/providers/rodin-provider.js +89 -51
  508. package/dist/providers/rodin-provider.js.map +1 -1
  509. package/dist/providers/safe-url.d.ts +70 -0
  510. package/dist/providers/safe-url.d.ts.map +1 -0
  511. package/dist/providers/safe-url.js +277 -0
  512. package/dist/providers/safe-url.js.map +1 -0
  513. package/dist/providers/scripted-provider.d.ts +9 -0
  514. package/dist/providers/scripted-provider.d.ts.map +1 -1
  515. package/dist/providers/scripted-provider.js +86 -10
  516. package/dist/providers/scripted-provider.js.map +1 -1
  517. package/dist/providers/structured-output.d.ts +42 -0
  518. package/dist/providers/structured-output.d.ts.map +1 -0
  519. package/dist/providers/structured-output.js +83 -0
  520. package/dist/providers/structured-output.js.map +1 -0
  521. package/dist/providers/together-provider.d.ts +19 -16
  522. package/dist/providers/together-provider.d.ts.map +1 -1
  523. package/dist/providers/together-provider.js +103 -225
  524. package/dist/providers/together-provider.js.map +1 -1
  525. package/dist/providers/topaz-provider.d.ts +44 -0
  526. package/dist/providers/topaz-provider.d.ts.map +1 -0
  527. package/dist/providers/topaz-provider.js +239 -0
  528. package/dist/providers/topaz-provider.js.map +1 -0
  529. package/dist/providers/types.d.ts +603 -4
  530. package/dist/providers/types.d.ts.map +1 -1
  531. package/dist/providers/types.js +81 -1
  532. package/dist/providers/types.js.map +1 -1
  533. package/dist/providers/useapi-provider.d.ts +27 -0
  534. package/dist/providers/useapi-provider.d.ts.map +1 -0
  535. package/dist/providers/useapi-provider.js +266 -0
  536. package/dist/providers/useapi-provider.js.map +1 -0
  537. package/dist/providers/video-duration.d.ts +6 -0
  538. package/dist/providers/video-duration.d.ts.map +1 -0
  539. package/dist/providers/video-duration.js +63 -0
  540. package/dist/providers/video-duration.js.map +1 -0
  541. package/dist/providers/video-frame-fallback.d.ts +39 -0
  542. package/dist/providers/video-frame-fallback.d.ts.map +1 -0
  543. package/dist/providers/video-frame-fallback.js +155 -0
  544. package/dist/providers/video-frame-fallback.js.map +1 -0
  545. package/dist/providers/video-frames.d.ts +61 -0
  546. package/dist/providers/video-frames.d.ts.map +1 -0
  547. package/dist/providers/video-frames.js +208 -0
  548. package/dist/providers/video-frames.js.map +1 -0
  549. package/dist/providers/video-mime.d.ts +14 -0
  550. package/dist/providers/video-mime.d.ts.map +1 -0
  551. package/dist/providers/video-mime.js +44 -0
  552. package/dist/providers/video-mime.js.map +1 -0
  553. package/dist/providers/video-to-audio.d.ts +34 -0
  554. package/dist/providers/video-to-audio.d.ts.map +1 -0
  555. package/dist/providers/video-to-audio.js +62 -0
  556. package/dist/providers/video-to-audio.js.map +1 -0
  557. package/dist/providers/vllm-provider.d.ts +22 -8
  558. package/dist/providers/vllm-provider.d.ts.map +1 -1
  559. package/dist/providers/vllm-provider.js +48 -23
  560. package/dist/providers/vllm-provider.js.map +1 -1
  561. package/dist/providers/voyage-provider.d.ts +10 -2
  562. package/dist/providers/voyage-provider.d.ts.map +1 -1
  563. package/dist/providers/voyage-provider.js +16 -7
  564. package/dist/providers/voyage-provider.js.map +1 -1
  565. package/dist/providers/xai-provider.d.ts +54 -13
  566. package/dist/providers/xai-provider.d.ts.map +1 -1
  567. package/dist/providers/xai-provider.js +299 -22
  568. package/dist/providers/xai-provider.js.map +1 -1
  569. package/dist/python-bridge-base.d.ts +358 -0
  570. package/dist/python-bridge-base.d.ts.map +1 -0
  571. package/dist/python-bridge-base.js +1557 -0
  572. package/dist/python-bridge-base.js.map +1 -0
  573. package/dist/python-bridge-codec.d.ts +28 -0
  574. package/dist/python-bridge-codec.d.ts.map +1 -0
  575. package/dist/python-bridge-codec.js +39 -0
  576. package/dist/python-bridge-codec.js.map +1 -0
  577. package/dist/python-bridge-factory.d.ts +52 -0
  578. package/dist/python-bridge-factory.d.ts.map +1 -0
  579. package/dist/python-bridge-factory.js +69 -0
  580. package/dist/python-bridge-factory.js.map +1 -0
  581. package/dist/python-bridge-framing.d.ts +68 -0
  582. package/dist/python-bridge-framing.d.ts.map +1 -0
  583. package/dist/python-bridge-framing.js +91 -0
  584. package/dist/python-bridge-framing.js.map +1 -0
  585. package/dist/python-bridge-types.d.ts +545 -2
  586. package/dist/python-bridge-types.d.ts.map +1 -1
  587. package/dist/python-bridge-types.js +49 -1
  588. package/dist/python-bridge-types.js.map +1 -1
  589. package/dist/python-graph-resolver.d.ts +57 -0
  590. package/dist/python-graph-resolver.d.ts.map +1 -0
  591. package/dist/python-graph-resolver.js +79 -0
  592. package/dist/python-graph-resolver.js.map +1 -0
  593. package/dist/python-node-executor.d.ts +36 -4
  594. package/dist/python-node-executor.d.ts.map +1 -1
  595. package/dist/python-node-executor.js +177 -86
  596. package/dist/python-node-executor.js.map +1 -1
  597. package/dist/python-stdio-bridge.d.ts +18 -37
  598. package/dist/python-stdio-bridge.d.ts.map +1 -1
  599. package/dist/python-stdio-bridge.js +148 -475
  600. package/dist/python-stdio-bridge.js.map +1 -1
  601. package/dist/python-websocket-bridge.d.ts +140 -0
  602. package/dist/python-websocket-bridge.d.ts.map +1 -0
  603. package/dist/python-websocket-bridge.js +561 -0
  604. package/dist/python-websocket-bridge.js.map +1 -0
  605. package/dist/python-worker-stderr.d.ts +4 -0
  606. package/dist/python-worker-stderr.d.ts.map +1 -0
  607. package/dist/python-worker-stderr.js +24 -0
  608. package/dist/python-worker-stderr.js.map +1 -0
  609. package/dist/recommended-models.d.ts +2 -2
  610. package/dist/recommended-models.d.ts.map +1 -1
  611. package/dist/recommended-models.js +24 -4
  612. package/dist/recommended-models.js.map +1 -1
  613. package/dist/recoverable-node-error.d.ts +31 -0
  614. package/dist/recoverable-node-error.d.ts.map +1 -0
  615. package/dist/recoverable-node-error.js +37 -0
  616. package/dist/recoverable-node-error.js.map +1 -0
  617. package/dist/redact-params.d.ts +13 -0
  618. package/dist/redact-params.d.ts.map +1 -0
  619. package/dist/redact-params.js +57 -0
  620. package/dist/redact-params.js.map +1 -0
  621. package/dist/sandbox-module-catalog.d.ts +43 -0
  622. package/dist/sandbox-module-catalog.d.ts.map +1 -0
  623. package/dist/sandbox-module-catalog.js +25 -0
  624. package/dist/sandbox-module-catalog.js.map +1 -0
  625. package/dist/storage-workspace.d.ts +59 -0
  626. package/dist/storage-workspace.d.ts.map +1 -0
  627. package/dist/storage-workspace.js +426 -0
  628. package/dist/storage-workspace.js.map +1 -0
  629. package/dist/swappable-python-bridge.d.ts +83 -0
  630. package/dist/swappable-python-bridge.d.ts.map +1 -0
  631. package/dist/swappable-python-bridge.js +246 -0
  632. package/dist/swappable-python-bridge.js.map +1 -0
  633. package/dist/telemetry.d.ts +7 -0
  634. package/dist/telemetry.d.ts.map +1 -1
  635. package/dist/telemetry.js +23 -0
  636. package/dist/telemetry.js.map +1 -1
  637. package/dist/testing.d.ts +81 -0
  638. package/dist/testing.d.ts.map +1 -0
  639. package/dist/testing.js +130 -0
  640. package/dist/testing.js.map +1 -0
  641. package/dist/token-counter.d.ts +30 -0
  642. package/dist/token-counter.d.ts.map +1 -0
  643. package/dist/token-counter.js +156 -0
  644. package/dist/token-counter.js.map +1 -0
  645. package/dist/trace-exporters.d.ts +10 -0
  646. package/dist/trace-exporters.d.ts.map +1 -1
  647. package/dist/trace-exporters.js +59 -20
  648. package/dist/trace-exporters.js.map +1 -1
  649. package/dist/tracing-helpers.d.ts +45 -4
  650. package/dist/tracing-helpers.d.ts.map +1 -1
  651. package/dist/tracing-helpers.js +62 -19
  652. package/dist/tracing-helpers.js.map +1 -1
  653. package/dist/turn-budget.d.ts +278 -0
  654. package/dist/turn-budget.d.ts.map +1 -0
  655. package/dist/turn-budget.js +365 -0
  656. package/dist/turn-budget.js.map +1 -0
  657. package/dist/variable-channel.d.ts +48 -0
  658. package/dist/variable-channel.d.ts.map +1 -0
  659. package/dist/variable-channel.js +110 -0
  660. package/dist/variable-channel.js.map +1 -0
  661. package/dist/workspace.d.ts +119 -0
  662. package/dist/workspace.d.ts.map +1 -0
  663. package/dist/workspace.js +112 -0
  664. package/dist/workspace.js.map +1 -0
  665. package/package.json +107 -19
package/dist/context.d.ts CHANGED
@@ -9,13 +9,40 @@
9
9
  * - Output normalization (sanitize memory URIs, etc.).
10
10
  * - Asset handling with pluggable storage adapters.
11
11
  */
12
- import type { AssetRef, ProcessingMessage } from "@nodetool-ai/protocol";
12
+ import type { AssetRef, Entity, EntityKind, EntitySource, GenerationOrigin, GenerationReceipt, ProcessingMessage, ProviderCost } from "@nodetool-ai/protocol";
13
+ import { AgentMemory } from "./agent-memory.js";
14
+ import { VariableChannel } from "./variable-channel.js";
15
+ import { type GenerationProviderRequestOptions, type GenerationReceiptScopeOptions } from "./generation-receipt.js";
16
+ import type { StorageAdapter } from "@nodetool-ai/storage";
17
+ import type { Workspace } from "./workspace.js";
18
+ /**
19
+ * ProcessingContext variable key carrying the provider/model the currently
20
+ * running agent loop is itself talking to. Every loop that executes tools
21
+ * (chat turns, `StepExecutor` sub-agents) stamps it, so a tool that launches
22
+ * another harness inherits the caller's model by default instead of demanding
23
+ * one or falling back to a server env default.
24
+ */
25
+ export declare const ACTIVE_MODEL_CONTEXT_KEY = "active_agent_model";
26
+ /** The value stored under {@link ACTIVE_MODEL_CONTEXT_KEY}. */
27
+ export interface ActiveModelSelection {
28
+ provider: string;
29
+ model: string;
30
+ }
13
31
  import type { BaseProvider } from "./providers/base-provider.js";
14
- import type { ProviderStreamItem } from "./providers/types.js";
32
+ import type { EncodedAudioResult, Message, ProviderStreamItem } from "./providers/types.js";
15
33
  import type { NodeExecutor } from "./node-executor.js";
34
+ import { type SandboxModuleCatalog } from "./sandbox-module-catalog.js";
35
+ export type { SandboxModuleCatalog } from "./sandbox-module-catalog.js";
36
+ /**
37
+ * A key/value cache for node results.
38
+ *
39
+ * One instance holds the results of many different nodes, so the value type
40
+ * belongs to the key, not to the cache: each caller names the type it stored
41
+ * under that key.
42
+ */
16
43
  export interface CacheAdapter {
17
- get(key: string): Promise<unknown | undefined>;
18
- set(key: string, value: unknown, ttlSeconds?: number): Promise<void>;
44
+ get<TValue>(key: string): Promise<TValue | undefined>;
45
+ set<TValue>(key: string, value: TValue, ttlSeconds?: number): Promise<void>;
19
46
  has(key: string): Promise<boolean>;
20
47
  delete(key: string): Promise<void>;
21
48
  }
@@ -24,21 +51,50 @@ export interface CacheAdapter {
24
51
  */
25
52
  export declare class MemoryCache implements CacheAdapter {
26
53
  private _store;
27
- get(key: string): Promise<unknown | undefined>;
28
- set(key: string, value: unknown, ttlSeconds?: number): Promise<void>;
54
+ get<TValue>(key: string): Promise<TValue | undefined>;
55
+ set<TValue>(key: string, value: TValue, ttlSeconds?: number): Promise<void>;
29
56
  has(key: string): Promise<boolean>;
30
57
  delete(key: string): Promise<void>;
31
58
  }
32
- export interface StorageAdapter {
33
- /** Store an asset and return a URI. */
34
- store(key: string, data: Uint8Array, contentType?: string): Promise<string>;
35
- /** Retrieve an asset by URI. */
36
- retrieve(uri: string): Promise<Uint8Array | null>;
37
- /** Check if an asset exists. */
38
- exists(uri: string): Promise<boolean>;
39
- }
40
- export type AssetOutputMode = "python" | "data_uri" | "temp_url" | "storage_url" | "workspace" | "raw";
41
- export type ProviderCapability = "generate_message" | "generate_messages" | "text_to_image" | "image_to_image" | "text_to_video" | "image_to_video" | "text_to_speech" | "automatic_speech_recognition" | "generate_embedding";
59
+ /**
60
+ * The storage contract lives in `@nodetool-ai/storage`; it is re-exported here
61
+ * so `@nodetool-ai/runtime/context` — the browser/Edge entry point — keeps
62
+ * naming it without pulling that package's Node-only implementations in.
63
+ */
64
+ export type { StorageAdapter, StorageEntry, StorageListResult, StorageStat } from "@nodetool-ai/storage";
65
+ /**
66
+ * Controls how asset-like values (ImageRef / AudioRef / VideoRef) are
67
+ * materialized when {@link ProcessingContext.normalizeOutputValue} runs.
68
+ *
69
+ * Pick the mode by where the consumer lives:
70
+ * - `native`: in-process JS/TS code that knows how to handle the live
71
+ * object as-is (DSL, tests, kernel-internal handoffs). Inline `data`
72
+ * bytes stay attached.
73
+ * - `data_uri`: anything that renders a `data:image/png;base64,...` URI
74
+ * inline (markdown, simple HTML).
75
+ * - `temp_url`: HTTP-fetching client over a short-lived URL — bytes are
76
+ * uploaded to the temp storage adapter and `data` is dropped.
77
+ * - `storage_url`: same as `temp_url` but persistent storage.
78
+ * - `workspace`: write the bytes to a file inside `workspaceDir` and
79
+ * return that file URI.
80
+ * - `raw`: keep bytes embedded in the asset's `data` field.
81
+ *
82
+ * NOTE: this used to be called `"python"` (mirroring the Python enum,
83
+ * where it accurately meant "Python-native object"). The rename to
84
+ * `"native"` makes the contract language-agnostic and matches what the
85
+ * mode actually does in the TS runtime.
86
+ */
87
+ export type AssetOutputMode = "native" | "data_uri" | "temp_url" | "storage_url" | "workspace" | "raw";
88
+ export type ProviderCapability = "generate_message" | "generate_messages" | "text_to_image" | "image_to_image" | "inpainting" | "outpaint_image" | "upscale_image" | "remove_background" | "relight_image" | "segment_image" | "vectorize_image" | "text_to_video" | "image_to_video" | "reference_to_video" | "video_to_video" | "extend_video" | "upscale_video" | "interpolate_video" | "outpaint_video" | "lip_sync" | "text_to_speech" | "text_to_music" | "audio_to_audio" | "video_to_audio" | "automatic_speech_recognition" | "generate_embedding" | "text_to_3d" | "image_to_3d" | "render_model3d"
89
+ /** A timeline 3D clip rendered to video through Blender (design §D6). */
90
+ | "bake_model3d_clip"
91
+ /**
92
+ * Subject/object tracking through a clip's source (P0 AI Video, Phase 2):
93
+ * an initial box plus a direction in, samples of the subject's position out
94
+ * — the async half of the `track_object` capability
95
+ * (`timeline-track-object.ts`).
96
+ */
97
+ | "track_object";
42
98
  export type ProviderPredictionRequest = {
43
99
  provider: string;
44
100
  capability: ProviderCapability;
@@ -47,6 +103,89 @@ export type ProviderPredictionRequest = {
47
103
  workflowId?: string | null;
48
104
  params?: Record<string, unknown>;
49
105
  };
106
+ /**
107
+ * A generation: one provider call that produces media, tracked from before
108
+ * the call to its terminal state (docs/media-generation-tracking-design.md).
109
+ */
110
+ export interface GenerationRequest extends ProviderPredictionRequest {
111
+ /**
112
+ * The generation id, when the caller minted it. A background caller needs
113
+ * the id before the call settles; everyone else lets the seam mint one.
114
+ */
115
+ id?: string;
116
+ /** Who asked. Fields left unset default from the context (§5.1). */
117
+ origin?: Partial<GenerationOrigin>;
118
+ /**
119
+ * Save the result as an asset before `completed` is emitted, so the row and
120
+ * the asset name each other. Needs the `createAsset` model interface; a host
121
+ * without one gets the bytes back and `assets: []`.
122
+ */
123
+ persist?: {
124
+ name?: string;
125
+ mime?: string;
126
+ parentId?: string | null;
127
+ };
128
+ /** Caller-side cancellation, chained with `cancel_generation`'s. */
129
+ signal?: AbortSignal;
130
+ /** Optional destination attachment intent retained for durable recovery. */
131
+ destination?: {
132
+ document_id?: string | null;
133
+ target_type: string;
134
+ target_id: string;
135
+ selected?: boolean;
136
+ };
137
+ }
138
+ export interface GenerationResult<T = ProviderPredictionResult> {
139
+ /** The row id and the message id: one identity end to end. */
140
+ id: string;
141
+ output: T;
142
+ /** Assets the seam persisted; empty when `persist` was unset or unavailable. */
143
+ assets: AssetRef[];
144
+ receipt: GenerationReceipt | null;
145
+ duration_ms: number;
146
+ }
147
+ /** Raised by a durable host when an idempotent request is already owned. */
148
+ export declare class GenerationAlreadyAcceptedError extends Error {
149
+ readonly generationId: string;
150
+ constructor(generationId: string);
151
+ }
152
+ export interface GenerationRunOptions {
153
+ /** A receipt known only after persistence finishes. */
154
+ receiptAfterPersist?: () => Partial<GenerationReceipt> | null;
155
+ /** A host-local generation, such as a Blender render, has no provider. */
156
+ withoutProvider?: true;
157
+ /**
158
+ * Durable host acceptance. When provided, this completes before the first
159
+ * provider call, including the paid queue POST. Without it the run is
160
+ * explicitly ephemeral and only the in-memory receipt is available.
161
+ */
162
+ onGenerationAccepted?: (input: {
163
+ readonly generationId: string;
164
+ readonly request: GenerationRequest;
165
+ }) => void | GenerationProviderRequestOptions | Promise<void | GenerationProviderRequestOptions>;
166
+ /** Persist the terminal provider outcome after the live result is decoded. */
167
+ onGenerationTerminal?: (input: {
168
+ readonly generationId: string;
169
+ readonly request: GenerationRequest;
170
+ readonly status: "completed" | "failed" | "cancelled" | "recovering";
171
+ readonly output?: unknown;
172
+ readonly error?: string;
173
+ readonly receipt: GenerationReceipt | null;
174
+ /** Positional media asset ids. Null preserves a failed save's index. */
175
+ readonly assetIds: readonly (string | null)[];
176
+ }) => void | Promise<void>;
177
+ /** Awaitable host hooks at the provider queue acceptance/binding boundary. */
178
+ onProviderRequestAccepted?: GenerationReceiptScopeOptions["onProviderRequestAccepted"];
179
+ onProviderRequestBound?: GenerationReceiptScopeOptions["onProviderRequestBound"];
180
+ }
181
+ /** Host-owned durable lifecycle callbacks injected into a context. */
182
+ export type GenerationLifecycleHooks = Pick<GenerationRunOptions, "onGenerationAccepted" | "onProviderRequestAccepted" | "onProviderRequestBound" | "onGenerationTerminal">;
183
+ /**
184
+ * What a provider prediction answers with: the result of whichever capability
185
+ * the request selected, as {@link ProcessingContext.dispatchCapability} routes
186
+ * it.
187
+ */
188
+ export type ProviderPredictionResult = Awaited<ReturnType<BaseProvider["generateMessageTraced" | "textToImage" | "imageToImage" | "inpaint" | "outpaintImage" | "textToVideo" | "imageToVideo" | "referenceToVideo" | "upscaleImage" | "removeBackground" | "relightImage" | "segmentImage" | "vectorizeImage" | "videoToVideo" | "trackObject" | "extendVideo" | "upscaleVideo" | "interpolateVideo" | "outpaintVideo" | "lipSync" | "textToMusic" | "audioToAudio" | "videoToAudio" | "automaticSpeechRecognition" | "generateEmbedding" | "textTo3D" | "imageTo3D"]>>;
50
189
  export type HttpRetryOptions = {
51
190
  maxRetries?: number;
52
191
  backoffMs?: number;
@@ -75,22 +214,116 @@ export interface AssetCreateParamsLike {
75
214
  userId: string;
76
215
  workflowId: string | null;
77
216
  jobId: string;
217
+ projectId?: string | null;
78
218
  name: string;
79
219
  contentType: string;
80
220
  content: Uint8Array;
81
221
  parentId?: string | null;
82
222
  nodeId?: string | null;
223
+ /** Stored on the asset row; the generation seam stamps `generation_id`. */
224
+ metadata?: Record<string, unknown> | null;
225
+ }
226
+ /** A non-folder asset surfaced when listing a folder's contents. */
227
+ export interface FolderAssetEntry {
228
+ id: string;
229
+ content_type: string;
230
+ name: string;
231
+ }
232
+ /** An asset's identity + metadata, as surfaced by {@link ProcessingContext.getAssetInfo}. */
233
+ export interface AssetInfoEntry {
234
+ id: string;
235
+ content_type: string;
236
+ name: string;
237
+ metadata: Record<string, unknown> | null;
238
+ }
239
+ /**
240
+ * An executable tool the run's owner injects into the context for agent nodes
241
+ * to pick up by name. Structurally satisfied by the agent system's `Tool` base
242
+ * class, which lives in a package `runtime` cannot depend on.
243
+ */
244
+ export interface InjectedTool {
245
+ name: string;
246
+ description?: string;
247
+ inputSchema?: Record<string, unknown>;
248
+ /**
249
+ * HOLDOUT (anti-slop/no-unknown-returns): this contract is satisfied
250
+ * structurally by `Tool` in `@nodetool-ai/agents`, whose `process` returns
251
+ * `Promise<unknown>`; narrowing here would stop every tool from fitting.
252
+ */
253
+ process: (context: ProcessingContext, params: Record<string, unknown>) => Promise<unknown>;
254
+ /**
255
+ * Preferred entry point when present: strips reserved fields and coerces
256
+ * params against the tool's schema before dispatching to `process`.
257
+ */
258
+ execute?: (context: ProcessingContext, params: Record<string, unknown>, options?: {
259
+ toolCallId?: string;
260
+ }) => Promise<unknown>;
261
+ }
262
+ /**
263
+ * A record the host's persistence layer answers with.
264
+ *
265
+ * The row and response types live in `@nodetool-ai/models`, which sits above
266
+ * `runtime`, so the port names the field every caller reads — the record's
267
+ * identity — and each caller re-reads the document fields it knows how to
268
+ * interpret.
269
+ */
270
+ export interface PersistedRecordLike {
271
+ id: string;
83
272
  }
84
273
  export interface ProcessingContextModelInterfaces {
274
+ /** Read a non-secret setting owned by the current user. */
275
+ getSetting?: (args: {
276
+ userId: string;
277
+ key: string;
278
+ }) => Promise<string | null>;
85
279
  getJob?: (args: {
86
280
  userId: string;
87
281
  jobId: string;
88
- }) => Promise<unknown | null>;
282
+ }) => Promise<PersistedRecordLike | null>;
283
+ /**
284
+ * HOLDOUT (anti-slop/no-unknown-returns): narrowing this to the created
285
+ * record's shape breaks the `as Record<string, unknown>` assertions on the
286
+ * result in `image-nodes` and `audio-nodes` — an interface without an index
287
+ * signature is not comparable to that type. Typing it honestly means editing
288
+ * those call sites too.
289
+ */
89
290
  createAsset?: (args: AssetCreateParamsLike) => Promise<unknown>;
291
+ /**
292
+ * Replace an existing asset's bytes in place, keeping its id. Returns `null`
293
+ * when the asset does not exist or is not owned by the user.
294
+ *
295
+ * An editing loop needs this: creating a new asset per save would give the
296
+ * caller a different id after every edit, and the handles it already handed
297
+ * out would point at a stale version.
298
+ */
299
+ updateAssetBytes?: (args: {
300
+ userId: string;
301
+ assetId: string;
302
+ content: Uint8Array;
303
+ contentType?: string;
304
+ name?: string;
305
+ }) => Promise<AssetInfoEntry | null>;
306
+ /**
307
+ * Recursively list the non-folder assets contained in `folderId`. Returns
308
+ * `null` when the id is not a folder (or does not exist) so callers can tell
309
+ * "not a folder" apart from "empty folder" (`[]`).
310
+ */
311
+ listFolderAssets?: (args: {
312
+ userId: string;
313
+ folderId: string;
314
+ }) => Promise<FolderAssetEntry[] | null>;
315
+ /**
316
+ * Look up one owned asset's identity + metadata (no bytes). Returns `null`
317
+ * when the asset does not exist or is not owned by the user.
318
+ */
319
+ getAssetInfo?: (args: {
320
+ userId: string;
321
+ assetId: string;
322
+ }) => Promise<AssetInfoEntry | null>;
90
323
  createMessage?: (args: {
91
324
  userId: string;
92
325
  req: MessageCreateRequestLike;
93
- }) => Promise<unknown>;
326
+ }) => Promise<PersistedRecordLike>;
94
327
  getMessages?: (args: {
95
328
  userId: string;
96
329
  threadId: string;
@@ -98,65 +331,162 @@ export interface ProcessingContextModelInterfaces {
98
331
  startKey?: string | null;
99
332
  reverse?: boolean;
100
333
  }) => Promise<ThreadMessagesResultLike>;
334
+ /** Load a persisted sketch (image document) by id; null when missing or not owned. */
335
+ getImageDocument?: (args: {
336
+ userId: string;
337
+ id: string;
338
+ }) => Promise<PersistedRecordLike | null>;
339
+ /** Create a persisted sketch (image document); returns the created document response. */
340
+ createImageDocument?: (args: {
341
+ userId: string;
342
+ name: string;
343
+ projectId?: string;
344
+ width: number;
345
+ height: number;
346
+ document: unknown;
347
+ }) => Promise<PersistedRecordLike>;
348
+ /** Load a persisted timeline sequence by id; null when missing or not owned. */
349
+ getTimelineSequence?: (args: {
350
+ userId: string;
351
+ id: string;
352
+ }) => Promise<PersistedRecordLike | null>;
353
+ /** Create a persisted timeline sequence from a full sequence document. */
354
+ createTimelineSequence?: (args: {
355
+ userId: string;
356
+ sequence: unknown;
357
+ }) => Promise<PersistedRecordLike>;
358
+ /** Replace a persisted timeline sequence's document; null when missing or not owned. */
359
+ updateTimelineSequence?: (args: {
360
+ userId: string;
361
+ id: string;
362
+ sequence: unknown;
363
+ }) => Promise<PersistedRecordLike | null>;
364
+ /** Load a persisted script by id; null when missing or not owned. */
365
+ getScript?: (args: {
366
+ userId: string;
367
+ id: string;
368
+ }) => Promise<PersistedRecordLike | null>;
369
+ /** Create a persisted script from a name + document. */
370
+ createScript?: (args: {
371
+ userId: string;
372
+ name?: string;
373
+ projectId?: string;
374
+ document: unknown;
375
+ }) => Promise<PersistedRecordLike>;
376
+ /** Replace a persisted script's document (and optional timeline link); null when missing or not owned. */
377
+ updateScript?: (args: {
378
+ userId: string;
379
+ id: string;
380
+ document?: unknown;
381
+ timelineId?: string | null;
382
+ baseUpdatedAt?: string;
383
+ }) => Promise<PersistedRecordLike | null>;
384
+ /** Load a persisted storyboard by id; null when missing or not owned. */
385
+ getStoryboard?: (args: {
386
+ userId: string;
387
+ id: string;
388
+ }) => Promise<PersistedRecordLike | null>;
389
+ /** The caller's storyboards, optionally narrowed by project. */
390
+ listStoryboards?: (args: {
391
+ userId: string;
392
+ projectId?: string;
393
+ limit?: number;
394
+ }) => Promise<PersistedRecordLike[]>;
395
+ /**
396
+ * The copy a previous run derived from `templateId` for that `recastKey`;
397
+ * null when there is none. Scoped rather than listed, because a listing is
398
+ * windowed and a batch bigger than the window would keep re-deriving — and
399
+ * re-rendering — copies it already has.
400
+ */
401
+ findRecastStoryboard?: (args: {
402
+ userId: string;
403
+ projectId?: string;
404
+ templateId: string;
405
+ recastKey: string;
406
+ }) => Promise<PersistedRecordLike | null>;
407
+ /** Create a persisted storyboard from a name + document. */
408
+ createStoryboard?: (args: {
409
+ userId: string;
410
+ name?: string;
411
+ projectId?: string;
412
+ document: unknown;
413
+ }) => Promise<PersistedRecordLike>;
414
+ /** Replace a persisted storyboard's document (and optional timeline link); null when missing or not owned. */
415
+ updateStoryboard?: (args: {
416
+ userId: string;
417
+ id: string;
418
+ document?: unknown;
419
+ timelineId?: string | null;
420
+ baseUpdatedAt?: string;
421
+ }) => Promise<PersistedRecordLike | null>;
422
+ /** The caller's entity library, optionally narrowed by project, kind, tags or name. */
423
+ listEntities?: (args: {
424
+ userId: string;
425
+ projectId?: string;
426
+ kind?: EntityKind;
427
+ tags?: string[];
428
+ nameContains?: string;
429
+ limit?: number;
430
+ }) => Promise<Entity[]>;
431
+ /** Read one owned entity by id; null when missing, not owned, or not tagged. */
432
+ getEntity?: (args: {
433
+ userId: string;
434
+ id: string;
435
+ }) => Promise<Entity | null>;
436
+ /**
437
+ * Create or update one entity, identified by `source.key` when given and by
438
+ * (project, kind, name) otherwise. A re-run of the same graph therefore
439
+ * updates the entity it made last time instead of growing the library.
440
+ */
441
+ upsertEntity?: (args: EntityUpsertArgs) => Promise<EntityUpsertResult>;
442
+ }
443
+ /** The arguments {@link ProcessingContextModelInterfaces.upsertEntity} takes. */
444
+ export interface EntityUpsertArgs {
445
+ userId: string;
446
+ projectId?: string;
447
+ kind: EntityKind;
448
+ name: string;
449
+ descriptor: string;
450
+ /** The image asset the entity shows; also the row a new entity is tagged on. */
451
+ imageAssetId: string;
452
+ description?: string;
453
+ tags?: string[];
454
+ voiceId?: string | null;
455
+ /** Stored verbatim on the marker, so a re-run finds its own row. */
456
+ source?: EntitySource;
101
457
  }
102
458
  /**
103
- * In-memory storage adapter useful for tests and single-process ephemeral runs.
459
+ * What an upsert did. The host owns the match rule (`source.key`, then
460
+ * project/kind/name), so it is the only place that can say whether the row is
461
+ * new — a caller re-deriving that from a probe duplicates the rule and drifts
462
+ * from it the moment the host's changes.
104
463
  */
105
- export declare class InMemoryStorageAdapter implements StorageAdapter {
106
- private _store;
107
- store(key: string, data: Uint8Array, _contentType?: string): Promise<string>;
108
- retrieve(uri: string): Promise<Uint8Array | null>;
109
- exists(uri: string): Promise<boolean>;
464
+ export interface EntityUpsertResult {
465
+ entity: Entity;
466
+ created: boolean;
110
467
  }
111
468
  /**
112
- * File-system storage adapter rooted to a single base directory.
469
+ * The arguments one model interface takes, minus the `userId` every
470
+ * {@link ProcessingContext} forwarder binds from the run. Derived so the shape
471
+ * is declared once, on the interface.
113
472
  */
114
- export declare class FileStorageAdapter implements StorageAdapter {
115
- readonly rootDir: string;
116
- constructor(rootDir: string);
117
- private resolvePathFromKey;
118
- private resolvePathFromUri;
119
- store(key: string, data: Uint8Array, _contentType?: string): Promise<string>;
120
- retrieve(uri: string): Promise<Uint8Array | null>;
121
- exists(uri: string): Promise<boolean>;
122
- }
123
- export interface S3Client {
124
- putObject(input: {
125
- bucket: string;
126
- key: string;
127
- body: Uint8Array;
128
- contentType?: string;
129
- }): Promise<void>;
130
- getObject(input: {
131
- bucket: string;
132
- key: string;
133
- }): Promise<Uint8Array | null>;
134
- headObject(input: {
135
- bucket: string;
136
- key: string;
137
- }): Promise<boolean>;
138
- }
473
+ type ModelInterfaceArgs<K extends keyof ProcessingContextModelInterfaces> = Omit<Parameters<NonNullable<ProcessingContextModelInterfaces[K]>>[0], "userId">;
139
474
  /**
140
- * S3-backed storage adapter with injected client operations.
475
+ * Install the model interfaces every context in this process falls back to.
141
476
  *
142
- * This avoids hard-coupling runtime to any specific SDK while providing
143
- * predictable URI behavior (`s3://bucket/key`).
477
+ * A host installs its persistence once at startup instead of each entrance
478
+ * remembering to wire it onto the context it builds. That forgetting is a
479
+ * defect generator: `nodetool debug` wired none while `workflows run` wired
480
+ * four, so a workflow that saves an image ran under one command and threw
481
+ * under the other. A context that sets its own interfaces still wins — this
482
+ * is the floor, not an override.
483
+ *
484
+ * Pass `null` to uninstall (a test restoring global state).
144
485
  */
145
- export declare class S3StorageAdapter implements StorageAdapter {
146
- readonly bucket: string;
147
- readonly prefix: string | null;
148
- readonly client: S3Client;
149
- constructor(opts: {
150
- bucket: string;
151
- client: S3Client;
152
- prefix?: string;
153
- });
154
- private keyForStore;
155
- private parseUri;
156
- store(key: string, data: Uint8Array, contentType?: string): Promise<string>;
157
- retrieve(uri: string): Promise<Uint8Array | null>;
158
- exists(uri: string): Promise<boolean>;
159
- }
486
+ export declare function setDefaultModelInterfaces(interfaces: ProcessingContextModelInterfaces | null): void;
487
+ /** The process-wide default, or null when no host installed one. */
488
+ export declare function getDefaultModelInterfaces(): ProcessingContextModelInterfaces | null;
489
+ export declare function normalizeStorageKey(key: string): string;
160
490
  /**
161
491
  * Resolve paths relative to a configured workspace root.
162
492
  *
@@ -167,29 +497,137 @@ export declare class S3StorageAdapter implements StorageAdapter {
167
497
  * - relative paths
168
498
  */
169
499
  export declare function resolveWorkspacePath(workspaceDir: string | null | undefined, path: string): string;
500
+ /**
501
+ * Build the run's workspace from whatever the host supplied.
502
+ *
503
+ * Hosts are migrating from `workspaceDir` (a real folder) and `workspaceStorage`
504
+ * (a bare adapter) to `workspace`. Accepting all three keeps the call sites
505
+ * working while they move, and means a consumer only ever reads
506
+ * `context.workspace`. Constructed lazily through a setter the storage module
507
+ * installs, so `context.ts` does not import the implementation and stays
508
+ * loadable off Node.
509
+ */
510
+ type WorkspaceFactory = (opts: {
511
+ workspace?: Workspace | null;
512
+ workspaceDir?: string | null;
513
+ workspaceStorage?: StorageAdapter | null;
514
+ }) => Workspace | null;
515
+ /** Installed once by `storage-workspace.ts`; see {@link ProcessingContext.workspace}. */
516
+ export declare function setWorkspaceFactory(factory: WorkspaceFactory): void;
170
517
  export declare class ProcessingContext {
171
518
  readonly jobId: string;
172
519
  readonly workflowId: string | null;
520
+ /** Chat thread id, when this context is serving a chat-driven agent run. */
521
+ readonly threadId: string | null;
173
522
  readonly userId: string;
174
523
  readonly workspaceDir: string | null;
175
524
  readonly assetOutputMode: AssetOutputMode;
525
+ /**
526
+ * Whether Output nodes should turn transient media into durable Asset rows.
527
+ * Hosts can disable this for explicitly temporary SDK executions.
528
+ */
529
+ readonly persistOutputAssets: boolean;
176
530
  readonly environment: Record<string, string>;
531
+ /** Bearer token for authenticated calls back to the owning NodeTool API. */
532
+ readonly authToken: string | null;
533
+ /** Read-only sandbox module catalog supplied by the execution host. */
534
+ readonly sandboxModuleCatalog: SandboxModuleCatalog | null;
535
+ /**
536
+ * Run-level cancellation. Set by the kernel to the signal
537
+ * `WorkflowRunner.cancel()` aborts, so long-running node work (agent loops,
538
+ * provider calls) can be interrupted rather than merely having its result
539
+ * discarded. Nodes reached through the streaming `run()` path can also read
540
+ * the same signal via `inputs.signal`.
541
+ *
542
+ * Defaults to a never-aborted signal so contexts built outside a kernel run
543
+ * (tools, tests, CLI) need not supply one.
544
+ */
545
+ signal: AbortSignal;
546
+ /**
547
+ * Wake-up payload for a trigger-driven run. Set by the kernel
548
+ * (`WorkflowRunner._runImpl`) from `RunJobRequest.trigger_event` at the
549
+ * start of each run, alongside {@link signal} — so it must be a mutable
550
+ * property, not a constructor-only value. The trigger node's actor reads
551
+ * `triggerEvent?.node_id === this.id` to enter its event-emitting entry
552
+ * point instead of the normal streaming path. `null` for interactive/
553
+ * live-test runs.
554
+ */
555
+ triggerEvent: {
556
+ node_id: string;
557
+ payload: unknown;
558
+ input_id: string;
559
+ } | null;
177
560
  /** Message queue: all emitted processing messages. */
178
561
  private _messages;
562
+ /** Whether emit() feeds the pull queue (see constructor option). */
563
+ private _retainMessageQueue;
179
564
  /** Latest node status by node id. */
180
565
  private _nodeStatuses;
181
566
  /** Latest edge status by edge id. */
182
567
  private _edgeStatuses;
183
- /** Optional message listener (for real-time streaming). */
184
- private _onMessage;
568
+ /** Message listeners (for real-time streaming). */
569
+ private _messageListeners;
570
+ /**
571
+ * One media object can appear in both a live output_update and the
572
+ * authoritative terminal result. Reuse its materialization within this
573
+ * execution instead of encoding/storing the same large payload twice.
574
+ */
575
+ private readonly _normalizedOutputAssets;
185
576
  /** Cache adapter. */
186
577
  readonly cache: CacheAdapter;
187
578
  /** Storage adapter (optional, for asset handling). */
188
579
  readonly storage: StorageAdapter | null;
580
+ /**
581
+ * Asset storage adapter — where user assets (`asset://<id>.<ext>`) live.
582
+ * Separate from {@link storage}, which servers point at the *temp* store:
583
+ * without this, an `asset://` reference could only be resolved over HTTP
584
+ * through `/api/storage`, which authorizes by `x-user-id` and 404s for
585
+ * anyone but user `1`. Null falls back to {@link storage}.
586
+ */
587
+ readonly assetStorage: StorageAdapter | null;
588
+ /**
589
+ * Workspace storage adapter — the agent's working directory abstracted
590
+ * behind {@link StorageAdapter}. Tools that read/write/list files use
591
+ * this adapter so the same code paths work locally (FS-backed) and in
592
+ * cloud deployments (S3/Supabase-backed).
593
+ *
594
+ * If null, file-tool operations should return a clear error rather than
595
+ * fall back to direct FS access — there is no implicit workspace.
596
+ */
597
+ /**
598
+ * @deprecated Use {@link workspace}, which works on a cloud deployment too.
599
+ * Only set when a host passed a bare adapter; a host that passes a
600
+ * `workspace` leaves this null.
601
+ */
602
+ readonly workspaceStorage: StorageAdapter | null;
603
+ /**
604
+ * The run's workspace as an interface — the way to read and write run files.
605
+ *
606
+ * Null when the host wired none, in which case a file operation must report
607
+ * that plainly rather than reaching for the process working directory.
608
+ * Prefer this over {@link workspaceDir}, which is only non-null when the
609
+ * workspace happens to be a real folder: a cloud run's workspace lives in
610
+ * object storage and has no path.
611
+ */
612
+ readonly workspace: Workspace | null;
613
+ /** Project captured when this run started. */
614
+ readonly projectId: string | null;
615
+ /**
616
+ * Unified, structured agent memory. The single source of truth for results
617
+ * shared between agents, tasks, steps and tools. Keys use the namespaces
618
+ * `step:`, `task:`, `input:`, `shared:` (see {@link memoryKeys}).
619
+ */
620
+ readonly memory: AgentMemory;
189
621
  /** Variables shared across node execution. */
190
622
  private _variables;
623
+ /** Named async channels backing Set/Get Variable (see {@link getChannel}). */
624
+ private _channels;
625
+ /** Remaining Set Variable writers per channel; channel closes at zero. */
626
+ private _channelWriters;
191
627
  /** Optional async secret resolver. */
192
628
  private _secretResolver;
629
+ /** Every secret value the resolver handed out this run (see {@link ProcessingContext.getResolvedSecretValues}). */
630
+ private _resolvedSecrets;
193
631
  /** Fetch function used by HTTP helpers. */
194
632
  private _fetch;
195
633
  /** Optional temporary URL resolver for stored assets. */
@@ -200,10 +638,21 @@ export declare class ProcessingContext {
200
638
  private _modelInterfaces;
201
639
  /** Provider cache keyed by provider id. */
202
640
  private _providers;
641
+ private _providerPromises;
203
642
  /** In-context memory URI cache (memory:// key-value objects). */
204
643
  private _memory;
205
644
  /** Optional control event dispatcher (set by workflow runner). */
206
645
  private _sendControlEvent;
646
+ /**
647
+ * Executable tools supplied by the caller that owns this run (set by the
648
+ * agent workflow runner). Agent nodes merge these into their own tool list
649
+ * by name, so a node that selects `read_file` gets the caller's live,
650
+ * fully-wired tool instead of a builtin stub. Tools the caller does not
651
+ * provide fall back to builtin hydration.
652
+ */
653
+ private _injectedTools;
654
+ /** Provider charge (USD) reported by the current node execution (e.g. FAL/KIE generation). */
655
+ private _providerCost;
207
656
  /** Optional executor resolver for sub-workflow execution. */
208
657
  private _resolveExecutor;
209
658
  /** Optional node type resolver for sub-workflow graph hydration. */
@@ -212,25 +661,116 @@ export declare class ProcessingContext {
212
661
  private _totalCost;
213
662
  /** Per-operation cost entries. */
214
663
  private _operationCosts;
664
+ private readonly _generationLifecycle;
215
665
  constructor(opts: {
216
666
  jobId: string;
217
667
  workflowId?: string | null;
668
+ projectId?: string | null;
669
+ threadId?: string | null;
218
670
  userId?: string;
219
671
  workspaceDir?: string | null;
220
672
  assetOutputMode?: AssetOutputMode;
673
+ persistOutputAssets?: boolean;
221
674
  cache?: CacheAdapter;
222
675
  storage?: StorageAdapter | null;
676
+ assetStorage?: StorageAdapter | null;
677
+ workspaceStorage?: StorageAdapter | null;
678
+ /**
679
+ * The run's workspace. Preferred over `workspaceDir`/`workspaceStorage`,
680
+ * which are kept for hosts that still hand over a directory or a bare
681
+ * adapter — either one is wrapped into a Workspace here so every consumer
682
+ * sees the same interface whatever the host passed.
683
+ */
684
+ workspace?: Workspace | null;
223
685
  onMessage?: (msg: ProcessingMessage) => void;
224
686
  variables?: Record<string, unknown>;
225
687
  environment?: Record<string, string>;
688
+ authToken?: string | null;
689
+ sandboxModuleCatalog?: SandboxModuleCatalog | null;
226
690
  secretResolver?: (key: string, userId: string) => Promise<string | null | undefined> | string | null | undefined;
227
691
  fetchFn?: (input: string, init?: RequestInit) => Promise<Response>;
228
692
  tempUrlResolver?: (uri: string) => Promise<string> | string;
229
693
  modelInterfaces?: ProcessingContextModelInterfaces;
694
+ /**
695
+ * Wake-up payload for a trigger-driven run. Usually left unset at
696
+ * construction and assigned later by the kernel (see {@link triggerEvent});
697
+ * accepted here too so tests and single-node harnesses can construct a
698
+ * context with it directly.
699
+ */
700
+ triggerEvent?: {
701
+ node_id: string;
702
+ payload: unknown;
703
+ input_id: string;
704
+ } | null;
705
+ /**
706
+ * Keep emitted messages in the pull queue (popMessage/waitMessage).
707
+ * Consumers that stream via message listeners instead (the browser/
708
+ * workflow-runner path) should pass false — with nothing draining the
709
+ * queue, an infinite realtime stream otherwise retains every chunk
710
+ * payload for the lifetime of the run. Default true (server paths pull
711
+ * from the queue).
712
+ */
713
+ retainMessageQueue?: boolean;
714
+ /** Optional durable lifecycle owned by the host. */
715
+ generationLifecycle?: GenerationLifecycleHooks;
230
716
  });
231
- copy(): ProcessingContext;
717
+ /**
718
+ * Derive a child context.
719
+ *
720
+ * Defaults to full isolation: fresh agent memory, fresh message queue, the
721
+ * parent's message listeners inherited. Two opt-ins exist because a child
722
+ * that must *not* be isolated in one respect should not have to reach around
723
+ * the copy:
724
+ *
725
+ * - `shareMemory` shares the parent's {@link AgentMemory} instance, so a
726
+ * scoped run (own injected tools, own emit fan-out) still reads and
727
+ * writes the same step/task results.
728
+ * - `inheritMessageListeners: false` drops the parent's listeners, for a
729
+ * child that forwards messages itself and would otherwise double-notify.
730
+ *
731
+ * The run-level cancellation {@link signal} always carries over: a child that
732
+ * cannot observe the parent's Stop keeps burning provider calls after the
733
+ * user cancelled.
734
+ */
735
+ copy(opts?: {
736
+ shareMemory?: boolean;
737
+ inheritMessageListeners?: boolean;
738
+ }): ProcessingContext;
232
739
  setProviderResolver(resolver: (providerId: string) => Promise<BaseProvider> | BaseProvider): void;
740
+ /**
741
+ * Whether this context serves providers from an injected resolver rather
742
+ * than the process-wide registry.
743
+ *
744
+ * When it does, {@link getProvider} never reaches the registry and never
745
+ * reads a credential — so a credential the run will not use is not a reason
746
+ * to refuse the run. The execution preflight reads this to decide whether
747
+ * its credential check applies at all.
748
+ */
749
+ get hasProviderResolver(): boolean;
233
750
  setModelInterfaces(modelInterfaces: ProcessingContextModelInterfaces): void;
751
+ /**
752
+ * The interfaces this context answers with: its own when a caller wired
753
+ * them, else the host's process-wide default.
754
+ *
755
+ * The default is what keeps a run from depending on which entrance built
756
+ * its context. Six hosts assembled these by hand and three of them forgot
757
+ * `createAsset`, so the same workflow saved an image under `workflows run`
758
+ * and died under `debug` with "model interface is not configured".
759
+ *
760
+ * The two compose key by key, the context's own winning, so wiring one
761
+ * interface does not uninstall the rest of the floor.
762
+ */
763
+ private modelInterfaces;
764
+ /**
765
+ * Whether a given model interface is wired for this context — its own or
766
+ * the host default. Lets callers decide between the DB-backed path
767
+ * (interface present — let errors propagate) and an in-memory fallback
768
+ * (interface absent — hermetic CLI runs, tests) without invoking a method
769
+ * that would throw when unwired.
770
+ */
771
+ hasModelInterface(name: keyof ProcessingContextModelInterfaces): boolean;
772
+ /** Read a user setting, falling back to this run's environment. */
773
+ getSetting(key: string): Promise<string | null>;
234
774
  /**
235
775
  * Set the control event dispatcher (called by the workflow runner).
236
776
  * This allows agent nodes to dispatch control events to controlled nodes
@@ -242,6 +782,15 @@ export declare class ProcessingContext {
242
782
  * Returns null if no control event dispatcher is configured.
243
783
  */
244
784
  sendControlEvent(targetNodeId: string, properties: Record<string, unknown>): Promise<Record<string, unknown> | null>;
785
+ /**
786
+ * Supply the live tool set for this run. Agent nodes match their selected
787
+ * tool names against these and prefer them over builtin hydration, so tools
788
+ * that only the caller can wire (MCP, workspace, skills, security-gated
789
+ * wrappers) reach nodes the caller did not author.
790
+ */
791
+ setInjectedTools(tools: InjectedTool[]): void;
792
+ /** Injected tool matching `name`, or null when the caller supplied none. */
793
+ getInjectedTool(name: string): InjectedTool | null;
245
794
  setResolveExecutor(fn: (node: {
246
795
  id: string;
247
796
  type: string;
@@ -256,59 +805,118 @@ export declare class ProcessingContext {
256
805
  nodeType: string;
257
806
  propertyTypes?: Record<string, string>;
258
807
  outputs?: Record<string, string>;
259
- isDynamic?: boolean;
808
+ supportsDynamicInputs?: boolean;
260
809
  descriptorDefaults?: Record<string, unknown>;
261
810
  } | null>): void;
262
811
  get resolveNodeType(): ((nodeType: string) => Promise<{
263
812
  nodeType: string;
264
813
  propertyTypes?: Record<string, string>;
265
814
  outputs?: Record<string, string>;
266
- isDynamic?: boolean;
815
+ supportsDynamicInputs?: boolean;
267
816
  descriptorDefaults?: Record<string, unknown>;
268
817
  } | null>) | null;
269
- /**
270
- * Check if control event dispatch is available.
271
- */
272
818
  get hasControlEventSupport(): boolean;
273
819
  registerProvider(providerId: string, provider: BaseProvider): void;
274
820
  getProvider(providerId: string): Promise<BaseProvider>;
275
- get_provider(providerId: string): Promise<BaseProvider>;
821
+ /**
822
+ * Check whether a registered provider has all required credentials
823
+ * resolvable through this context (DB/keychain/env).
824
+ */
825
+ isProviderConfigured(providerId: string): Promise<boolean>;
276
826
  setSecretResolver(resolver: (key: string, userId: string) => Promise<string | null | undefined> | string | null | undefined): void;
277
827
  setTempUrlResolver(resolver: (uri: string) => Promise<string> | string): void;
828
+ /**
829
+ * Resolve a raw storage URI (e.g. `file:///.../storage/<key>`) to a URL the
830
+ * UI can fetch (e.g. `/api/storage/<key>`). Falls back to returning the URI
831
+ * unchanged when no resolver is wired (DSL / tests).
832
+ *
833
+ * Use this from tools that write binary output via `context.storage.store()`
834
+ * and want to surface a UI-renderable URL in their result.
835
+ */
836
+ resolveTempUrl(uri: string): Promise<string>;
837
+ /**
838
+ * Whether this run can reach a secret store at all.
839
+ *
840
+ * {@link getSecret} answers `null` both for "no store is wired" and for "the
841
+ * store does not hold this key", which a caller asking *which* of a list of
842
+ * credentials exists cannot tell apart — and reporting every declared
843
+ * credential as missing because no store was reachable is exactly the
844
+ * false alarm the graph validator's `missing_secret` check refuses to raise.
845
+ * A host installs the availability callback only when this is true.
846
+ */
847
+ get hasSecretResolver(): boolean;
278
848
  getSecret(key: string): Promise<string | null>;
849
+ /**
850
+ * Every secret value handed out during this run. The supervisor's escalation
851
+ * constructor masks against this set — without it, "mask every secret" has no
852
+ * subject, because the resolver forgets each key as soon as it answers.
853
+ * Values shorter than `MIN_MASKABLE_SECRET_LENGTH` are not recorded: masking
854
+ * a two-character value would redact unrelated text everywhere it occurs.
855
+ */
856
+ getResolvedSecretValues(): ReadonlySet<string>;
279
857
  getSecretRequired(key: string): Promise<string>;
280
- get_secret(key: string): Promise<string | null>;
281
- get_secret_required(key: string): Promise<string>;
282
858
  get<T = unknown>(key: string, defaultValue?: T): T;
283
859
  set(key: string, value: unknown): void;
860
+ /** Whether a shared variable with this name has been set. */
861
+ hasVariable(key: string): boolean;
862
+ /**
863
+ * Snapshot of all shared variables (name → value). Used by nodes that
864
+ * resolve variable references against the workflow's shared context — e.g.
865
+ * the Prompt node merges these into its `{{ name }}` template variables so a
866
+ * Set Variable node upstream can supply values without an explicit wire.
867
+ */
868
+ getVariables(): {
869
+ [x: string]: unknown;
870
+ };
871
+ /**
872
+ * Declare how many Set Variable nodes write to `name`. The runner calls this
873
+ * before any actor runs so a channel with no writers can close immediately
874
+ * (readers get end-of-stream instead of hanging).
875
+ */
876
+ registerChannelWriters(name: string, count: number): void;
877
+ /**
878
+ * Get (or lazily create) the named variable channel. A channel created for a
879
+ * name with no registered writers is returned already closed, so a reader
880
+ * referencing an undefined variable resolves immediately rather than waiting
881
+ * forever.
882
+ */
883
+ getChannel<T = unknown>(name: string): VariableChannel<T>;
884
+ /**
885
+ * Record that one Set Variable writer for `name` has finished. When the last
886
+ * writer finishes, the channel closes — readers drain the buffered values
887
+ * then end. The runner calls this from each Set Variable actor's completion.
888
+ */
889
+ markChannelWriterDone(name: string): void;
890
+ /** Close every channel — a teardown backstop so no reader is left waiting. */
891
+ closeAllChannels(): void;
892
+ /** Whether any Set Variable node was registered as writing to `name`. */
893
+ hasChannelWriters(name: string): boolean;
284
894
  storeStepResult(key: string, value: unknown): Promise<string>;
285
895
  loadStepResult<T = unknown>(key: string, defaultValue?: T): Promise<T>;
286
- private workspacePathFor;
287
- private persistVariableIfNeeded;
288
896
  generateNodeCacheKey(nodeType: string, nodeProps: unknown): string;
289
- getCachedResult(nodeType: string, nodeProps: unknown): Promise<unknown>;
290
- cacheResult(nodeType: string, nodeProps: unknown, result: unknown, ttlSeconds?: number): Promise<void>;
897
+ getCachedResult<TResult>(nodeType: string, nodeProps: unknown): Promise<TResult | undefined>;
898
+ cacheResult<TResult>(nodeType: string, nodeProps: unknown, result: TResult, ttlSeconds?: number): Promise<void>;
899
+ addMessageListener(listener: (msg: ProcessingMessage) => void): () => void;
291
900
  /**
292
901
  * Emit a processing message.
293
- * Appended to the internal queue and forwarded to listener if set.
902
+ * Appended to the internal queue and forwarded to listeners if set.
294
903
  */
295
904
  emit(msg: ProcessingMessage): void;
296
905
  postMessage(msg: ProcessingMessage): void;
297
- post_message(msg: ProcessingMessage): void;
298
- /** Get all emitted messages. */
906
+ /** Record actual provider charge for the current node run (attached to completed NodeUpdate). */
907
+ setProviderCost(provider: string, amount: number, unit: string, details?: Pick<ProviderCost, "model" | "billing_unit" | "quantity" | "unit_price" | "currency" | "provider_request_id" | "input_tokens" | "output_tokens" | "cached_tokens">): void;
908
+ getProviderCost(): ProviderCost | null;
909
+ clearProviderCost(): void;
299
910
  getMessages(): ReadonlyArray<ProcessingMessage>;
300
911
  hasMessages(): boolean;
301
912
  popMessage(): ProcessingMessage | undefined;
302
- private _messageResolve;
913
+ private _messageWaiters;
303
914
  /** Notify that a new message has been pushed. */
304
915
  private _notifyMessage;
305
916
  popMessageAsync(): Promise<ProcessingMessage>;
306
- pop_message_async(): Promise<ProcessingMessage>;
307
917
  getNodeStatuses(): Readonly<Record<string, ProcessingMessage>>;
308
918
  getEdgeStatuses(): Readonly<Record<string, ProcessingMessage>>;
309
- /** Clear the message queue. */
310
919
  clearMessages(): void;
311
- clear_messages(): void;
312
920
  trackOperationCost(operation: string, cost: number, metadata?: Record<string, unknown>): void;
313
921
  addToTotalCost(cost: number): void;
314
922
  resetTotalCost(): void;
@@ -319,65 +927,265 @@ export declare class ProcessingContext {
319
927
  total: number;
320
928
  byPrefix: Record<string, number>;
321
929
  };
322
- private httpRequestWithRetries;
930
+ /**
931
+ * Issue an HTTP request with the retry/backoff policy every node shares.
932
+ * `httpGet` is the GET shorthand; other verbs go through this directly.
933
+ */
934
+ httpRequestWithRetries(method: string, url: string, opts?: HttpRequestOptions): Promise<Response>;
323
935
  httpGet(url: string, opts?: HttpRequestOptions): Promise<Response>;
324
- httpPost(url: string, opts?: HttpRequestOptions): Promise<Response>;
325
- httpPatch(url: string, opts?: HttpRequestOptions): Promise<Response>;
326
- httpPut(url: string, opts?: HttpRequestOptions): Promise<Response>;
327
- httpDelete(url: string, opts?: HttpRequestOptions): Promise<Response>;
328
- httpHead(url: string, opts?: HttpRequestOptions): Promise<Response>;
329
936
  downloadFile(url: string, opts?: HttpRequestOptions): Promise<Uint8Array>;
330
- downloadText(url: string, opts?: HttpRequestOptions): Promise<string>;
331
- http_get(url: string, opts?: HttpRequestOptions): Promise<Response>;
332
- http_post(url: string, opts?: HttpRequestOptions): Promise<Response>;
333
- http_patch(url: string, opts?: HttpRequestOptions): Promise<Response>;
334
- http_put(url: string, opts?: HttpRequestOptions): Promise<Response>;
335
- http_delete(url: string, opts?: HttpRequestOptions): Promise<Response>;
336
- http_head(url: string, opts?: HttpRequestOptions): Promise<Response>;
337
937
  private requireModelInterface;
338
- getJob(jobId: string): Promise<unknown | null>;
339
- get_job(jobId: string): Promise<unknown | null>;
340
- createAsset(args: {
341
- name: string;
342
- contentType: string;
343
- content?: Uint8Array | null;
344
- parentId?: string | null;
345
- instructions?: Uint8Array | null;
346
- nodeId?: string | null;
347
- }): Promise<unknown>;
348
- create_asset(args: {
349
- name: string;
350
- contentType: string;
938
+ getJob(jobId: string): Promise<PersistedRecordLike | null>;
939
+ /**
940
+ * HOLDOUT (anti-slop/no-unknown-returns): see the `createAsset` port above —
941
+ * narrowing the result breaks the `as Record<string, unknown>` assertions in
942
+ * `image-nodes` and `audio-nodes`.
943
+ */
944
+ createAsset(args: Omit<ModelInterfaceArgs<"createAsset">, "workflowId" | "jobId" | "content"> & {
351
945
  content?: Uint8Array | null;
352
- parentId?: string | null;
946
+ /** Legacy name for `content`; used when `content` is absent. */
353
947
  instructions?: Uint8Array | null;
354
- nodeId?: string | null;
355
948
  }): Promise<unknown>;
949
+ /**
950
+ * Replace an owned asset's bytes, keeping its id. Null when the asset is
951
+ * missing or belongs to someone else.
952
+ */
953
+ updateAssetBytes(args: ModelInterfaceArgs<"updateAssetBytes">): Promise<AssetInfoEntry | null>;
954
+ /** Load a persisted sketch (image document) owned by the current user. */
955
+ getImageDocument(id: string): Promise<PersistedRecordLike | null>;
956
+ /** Create a persisted sketch (image document) owned by the current user. */
957
+ createImageDocument(args: ModelInterfaceArgs<"createImageDocument">): Promise<PersistedRecordLike>;
958
+ /** Load a persisted timeline sequence owned by the current user. */
959
+ getTimelineSequence(id: string): Promise<PersistedRecordLike | null>;
960
+ /** Create a persisted timeline sequence owned by the current user. */
961
+ createTimelineSequence(sequence: unknown): Promise<PersistedRecordLike>;
962
+ /** Replace a persisted timeline sequence's document. */
963
+ updateTimelineSequence(id: string, sequence: unknown): Promise<PersistedRecordLike | null>;
964
+ /** Load a persisted script owned by the current user. */
965
+ getScript(id: string): Promise<PersistedRecordLike | null>;
966
+ /** Create a persisted script owned by the current user. */
967
+ createScript(args: ModelInterfaceArgs<"createScript">): Promise<PersistedRecordLike>;
968
+ /** Replace a persisted script's document (and optional timeline link). */
969
+ updateScript(id: string, args: Omit<ModelInterfaceArgs<"updateScript">, "id">): Promise<PersistedRecordLike | null>;
970
+ /** Load a persisted storyboard owned by the current user. */
971
+ getStoryboard(id: string): Promise<PersistedRecordLike | null>;
972
+ /** The current user's storyboards, narrowed by the given filters. */
973
+ listStoryboards(args?: ModelInterfaceArgs<"listStoryboards">): Promise<PersistedRecordLike[]>;
974
+ /** The copy this user derived from a template for one recast mapping. */
975
+ findRecastStoryboard(args: ModelInterfaceArgs<"findRecastStoryboard">): Promise<PersistedRecordLike | null>;
976
+ /** Create a persisted storyboard owned by the current user. */
977
+ createStoryboard(args: ModelInterfaceArgs<"createStoryboard">): Promise<PersistedRecordLike>;
978
+ /** Replace a persisted storyboard's document (and optional timeline link). */
979
+ updateStoryboard(id: string, args: Omit<ModelInterfaceArgs<"updateStoryboard">, "id">): Promise<PersistedRecordLike | null>;
980
+ /** The current user's entity library, narrowed by the given filters. */
981
+ listEntities(args?: ModelInterfaceArgs<"listEntities">): Promise<Entity[]>;
982
+ /** Read one entity owned by the current user. */
983
+ getEntity(id: string): Promise<Entity | null>;
984
+ /** Create or update one entity in the current user's library. */
985
+ upsertEntity(args: ModelInterfaceArgs<"upsertEntity">): Promise<EntityUpsertResult>;
986
+ /**
987
+ * Recursively list the non-folder assets in `folderId`, or `null` when the id
988
+ * is not a folder. Backed by the optional `listFolderAssets` model interface;
989
+ * returns `null` when that interface is not configured.
990
+ */
991
+ listFolderAssets(folderId: string): Promise<FolderAssetEntry[] | null>;
992
+ /**
993
+ * Look up one owned asset's identity + metadata, or `null` when missing /
994
+ * not owned. Backed by the optional `getAssetInfo` model interface; returns
995
+ * `null` when that interface is not configured.
996
+ */
997
+ getAssetInfo(assetId: string): Promise<AssetInfoEntry | null>;
356
998
  private resolveSandboxFilePath;
357
999
  private static guessMimeFromPath;
358
1000
  private static assetTypeForMime;
359
1001
  private parseAssetIdCandidates;
1002
+ /**
1003
+ * The adapters an asset reference is looked up in. Assets live in the asset
1004
+ * store; `this.storage` is the *temp* store on server paths. The asset
1005
+ * adapter goes first and the temp adapter stays as the fallback so
1006
+ * runtime-materialized refs still resolve.
1007
+ */
1008
+ private assetAdapters;
1009
+ /**
1010
+ * Keys an asset id candidate may be stored under: `<userId>/<id>.<ext>`
1011
+ * (uploads — the current owner-prefixed layout), `<id>.<ext>` (the flat
1012
+ * legacy layout) and `assets/<id>` (runtime-materialized refs). The
1013
+ * owner-prefixed key goes first: without it every reference misses all the
1014
+ * exact lookups and falls through to the prefix listing, which degrades to
1015
+ * `list("")` — a full recursive walk / whole-bucket `listObjectsV2` across
1016
+ * every tenant, on every asset reference.
1017
+ */
1018
+ private assetKeysFor;
1019
+ /**
1020
+ * Prefixes to list, narrowest first, when no exact key matched.
1021
+ *
1022
+ * S3 treats `list(<owner>/<bareId>)` as a raw-string prefix match — bounded
1023
+ * to a handful of entries. `list("")` is the last resort: it is a
1024
+ * multi-thousand-object scan on production S3 backends, and on Supabase it
1025
+ * lists only the bucket's immediate children — which under the
1026
+ * owner-prefixed layout are folders, so it never sees an asset at all.
1027
+ *
1028
+ * The owner prefix is what makes this work for uploads. They are stored at
1029
+ * `<userId>/<id>.<ext>`, and a ref that carries no extension (`asset://<id>`,
1030
+ * or a bare `asset_id`) misses every exact-key lookup. Listing the owner's
1031
+ * own folder finds it on every adapter: hierarchical ones
1032
+ * (file/supabase/memory) list its children, and prefix-matching ones (S3)
1033
+ * stay scoped to that one user.
1034
+ */
1035
+ private assetListingPrefixes;
1036
+ /**
1037
+ * Resolve an asset reference to a local file holding its bytes — the path
1038
+ * counterpart of {@link resolveAssetBytes}, for callers such as ffmpeg that
1039
+ * read a file in place instead of loading it into memory.
1040
+ *
1041
+ * Looks the reference up in the same adapters and under the same keys,
1042
+ * including the extension-tolerant listing, and asks each adapter for
1043
+ * `localPath`. That finds a managed file under the local asset root and an
1044
+ * external asset's in-place file. Returns null when no adapter keeps a local
1045
+ * file for it (object stores, the in-memory store, HTTP-only and
1046
+ * `package://` references); the caller then falls back to
1047
+ * {@link resolveAssetBytes}. The path is for reading only, and it is an
1048
+ * asset-store path, not a workspace file.
1049
+ */
1050
+ localPath(uri: string): Promise<string | null>;
1051
+ /**
1052
+ * Resolve an `asset://<id>[.ext]` reference (or bare id / storage URI) to its
1053
+ * raw bytes.
1054
+ *
1055
+ * Server-uploaded assets are stored under the key `<id>.<ext>` and served at
1056
+ * `/api/storage/<id>.<ext>`; runtime-materialized refs live under `assets/`.
1057
+ * Resolution order: the in-process storage adapter (file/s3/supabase/memory),
1058
+ * a prefix listing that tolerates extension mismatches, then an HTTP download
1059
+ * from the server's `/api/storage` route. Returns the bytes plus an `attempts`
1060
+ * trail for callers that build detailed errors; `null` bytes means unresolved.
1061
+ */
1062
+ resolveAssetBytes(assetId: string): Promise<{
1063
+ bytes: Uint8Array | null;
1064
+ attempts: string[];
1065
+ }>;
360
1066
  assetToSandbox(assetId: string, path: string): Promise<string>;
361
- asset_to_sandbox(asset_id: string, path: string): Promise<string>;
362
1067
  sandboxToAsset(path: string): Promise<AssetRef>;
363
- sandbox_to_asset(path: string): Promise<AssetRef>;
364
- createMessage(req: MessageCreateRequestLike): Promise<unknown>;
365
- create_message(req: MessageCreateRequestLike): Promise<unknown>;
1068
+ createMessage(req: MessageCreateRequestLike): Promise<PersistedRecordLike>;
366
1069
  getThreadMessages(threadId: string, limit?: number, startKey?: string | null, reverse?: boolean): Promise<ThreadMessagesResultLike>;
367
- get_messages(thread_id: string, limit?: number, start_key?: string | null, reverse?: boolean): Promise<ThreadMessagesResultLike>;
368
1070
  assetsToDataUri(value: unknown): Promise<unknown>;
369
1071
  assetsToStorageUrl(value: unknown): Promise<unknown>;
370
1072
  assetsToWorkspaceFiles(value: unknown): Promise<unknown>;
371
1073
  uploadAssetsToTemp(value: unknown): Promise<unknown>;
372
1074
  private emitPrediction;
373
1075
  /**
374
- * Resolve /api/storage/ URIs in message content to data URIs so providers
375
- * can fetch them without needing a base URL.
1076
+ * Who asked, defaulted from the context: a chat turn names its thread, a
1077
+ * run names its job and node. A capability passes `surface` and its
1078
+ * `tool_call_id` explicitly, the one id the context does not hold.
1079
+ */
1080
+ private generationOrigin;
1081
+ /**
1082
+ * Retrieve raw bytes for a media URI referenced in message content. Handles
1083
+ * the `asset://<id>` reference scheme (via {@link resolveAssetBytes}) as well
1084
+ * as opaque storage URIs (memory/file/s3) via the storage adapter.
376
1085
  */
377
- private resolveMessageMediaUris;
1086
+ private retrieveMediaBytes;
1087
+ /**
1088
+ * Resolve non-data, non-http media URIs in message content to data URIs so
1089
+ * providers can consume them directly. Covers `/api/storage/` and other
1090
+ * storage URIs as well as the `asset://<id>` reference scheme (assets
1091
+ * mentioned inline in a prompt). Text parts that contain `asset://<id>.<ext>`
1092
+ * image / audio tokens are first split into proper blocks via
1093
+ * {@link expandAssetReferences} so the same provider path handles chat
1094
+ * surfaces (where the user typed / dropped a reference) and workflow node
1095
+ * surfaces (where the agent node builds the message). Text document mentions
1096
+ * (`asset://doc.md`, `.txt`, `.csv`, …) are inlined as their decoded
1097
+ * contents in place of the token.
1098
+ */
1099
+ resolveMessageMediaUris(messages: Message[]): Promise<Message[]>;
378
1100
  private dispatchCapability;
1101
+ /**
1102
+ * HOLDOUT (anti-slop/no-unknown-returns): the honest return type is
1103
+ * {@link ProviderPredictionResult} (see {@link dispatchCapability}), but the
1104
+ * node and capability call sites assert their own capability's result off it
1105
+ * (`as Uint8Array`, `as number[][]`, …), and those assertions do not compile
1106
+ * against the union. Typing it means editing every one of them. `text-nodes`
1107
+ * is done — it parses each result with a predicate instead.
1108
+ */
379
1109
  runProviderPrediction(req: ProviderPredictionRequest): Promise<unknown>;
380
- streamProviderPrediction(req: ProviderPredictionRequest): AsyncGenerator<ProviderStreamItem | unknown>;
1110
+ /**
1111
+ * Run one generation: open the record, call the provider inside a receipt
1112
+ * scope, persist what came back, close the record. Every terminal state is
1113
+ * a message — `completed`, `failed`, `cancelled` — and the tracker turns
1114
+ * those into the row. Design: docs/media-generation-tracking-design.md § 5.
1115
+ */
1116
+ runGeneration(req: GenerationRequest): Promise<GenerationResult>;
1117
+ /**
1118
+ * The generation envelope around an arbitrary provider call: the same
1119
+ * record, receipt scope, persistence and terminal messages as
1120
+ * {@link runGeneration}, for a caller whose call shape the capability
1121
+ * switch has no case for — N images in one request, streamed PCM wrapped
1122
+ * into a WAV. `call` receives the provider and the generation's abort
1123
+ * signal; what it returns is the output, and its media buffers are what
1124
+ * `persist` saves.
1125
+ */
1126
+ runGenerationWith<T>(req: GenerationRequest, call: (provider: BaseProvider | null, signal: AbortSignal) => Promise<T>, opts?: GenerationRunOptions): Promise<GenerationResult<T>>;
1127
+ /**
1128
+ * Save a generation's media output as assets, stamping the generation id
1129
+ * on each. Bytes only: a segmentation result, a transcript or an embedding
1130
+ * is a result and stays on the message.
1131
+ */
1132
+ private persistGenerationBytes;
1133
+ /**
1134
+ * Run a prediction, retrying a content-filter refusal a bounded number of
1135
+ * times. The filter is non-deterministic — Veo refused one shot of a
1136
+ * five-shot trailer on an ordinary cinematic prompt and passed the same
1137
+ * prompt on retry — and a refused take is not charged, so the cheap answer to
1138
+ * a refusal is to ask again before failing the node that asked.
1139
+ *
1140
+ * A refusal that survives the retries is rethrown as-is, so the kernel can
1141
+ * still drop the item rather than the run.
1142
+ */
1143
+ private retryContentFilterRefusal;
1144
+ /**
1145
+ * Whether a provider streams raw PCM for text-to-speech. When false, the
1146
+ * caller should use {@link textToSpeechEncoded} (the provider returns an
1147
+ * encoded audio file rather than samples).
1148
+ */
1149
+ providerSupportsStreamingTTS(providerId: string): Promise<boolean>;
1150
+ /**
1151
+ * Whether a provider's chat API accepts a `video` content part. Lets a
1152
+ * caller refuse before paying for a prediction that the provider would
1153
+ * reject while resolving the message, which is where the video bytes have
1154
+ * already been fetched and inlined.
1155
+ */
1156
+ providerSupportsVideoInput(providerId: string): Promise<boolean>;
1157
+ /**
1158
+ * Generate speech as an encoded audio file (mp3/wav/…). Returns null when the
1159
+ * provider doesn't implement the encoded path. Used for providers (FAL, KIE,
1160
+ * ElevenLabs) that return audio files instead of streaming PCM.
1161
+ */
1162
+ textToSpeechEncoded(req: GenerationRequest): Promise<EncodedAudioResult | null>;
1163
+ /**
1164
+ * The generation lifecycle for the encoded-audio paths: same id on every
1165
+ * message, origin on `running`, the receipt on the terminal message,
1166
+ * `cancelled` on abort. These return an encoded result rather than bytes,
1167
+ * so the caller persists.
1168
+ */
1169
+ private runEncodedGeneration;
1170
+ /**
1171
+ * Generate music as an encoded audio file (mp3/wav/flac). Mirrors
1172
+ * {@link textToSpeechEncoded} for the `text_to_music` capability — the
1173
+ * provider returns a fully-encoded audio file rather than streaming PCM.
1174
+ */
1175
+ textToMusic(req: GenerationRequest): Promise<EncodedAudioResult>;
1176
+ /**
1177
+ * Rewrite a recording into another one. Mirrors {@link textToMusic} for the
1178
+ * `audio_to_audio` capability: the provider hands back an encoded file, and
1179
+ * the source bytes ride in `params.audio`.
1180
+ */
1181
+ audioToAudio(req: GenerationRequest): Promise<EncodedAudioResult>;
1182
+ /**
1183
+ * Generate an audio result conditioned on a captured video window and scene
1184
+ * context. The encoded-audio lifecycle persists the result without touching
1185
+ * the source video's soundtrack or timeline placement.
1186
+ */
1187
+ videoToAudio(req: GenerationRequest): Promise<EncodedAudioResult>;
1188
+ streamProviderPrediction(req: GenerationRequest): AsyncGenerator<ProviderStreamItem | unknown>;
381
1189
  /**
382
1190
  * Sanitize memory URIs from output values before sending to client.
383
1191
  * Replaces internal memory:// URIs with safe placeholders.
@@ -391,9 +1199,17 @@ export declare class ProcessingContext {
391
1199
  */
392
1200
  resolveWorkspacePath(path: string): string;
393
1201
  private static isAssetLike;
1202
+ /**
1203
+ * `mimeType` comes first because it is the field `ImageRef` declares — this
1204
+ * used to read only `mime_type`, which nothing sets, so a node's sniffed
1205
+ * `image/webp` was discarded and every provider's WebP stored as PNG.
1206
+ * `image/unknown` is `image-nodes` reporting its own sniff found nothing, so
1207
+ * it counts as undeclared here rather than as a type to forward.
1208
+ */
394
1209
  private static guessAssetMime;
395
1210
  private static extForMime;
396
1211
  private static decodeAssetData;
1212
+ private static isClientFetchableResolvedAssetUri;
397
1213
  private getAssetBytes;
398
1214
  private materializeAsset;
399
1215
  /**
@@ -402,4 +1218,15 @@ export declare class ProcessingContext {
402
1218
  */
403
1219
  normalizeOutputValue(value: unknown, mode?: AssetOutputMode): Promise<unknown>;
404
1220
  }
1221
+ /**
1222
+ * The media resolver to hand `BaseProvider.generateLoop`, or undefined when
1223
+ * this context cannot dereference one.
1224
+ *
1225
+ * `view_image` answers with an `asset://` reference and the loop turns it into
1226
+ * pixels for the one request that needs them, so every host that drives a tool
1227
+ * loop passes this. A partial context — a test double, a host object built
1228
+ * from a subset of the interface — has no method to call, and the loop then
1229
+ * sends the reference through untouched rather than throwing mid-turn.
1230
+ */
1231
+ export declare function mediaResolverFor(context: Pick<ProcessingContext, "resolveMessageMediaUris"> | undefined | null): ((messages: Message[]) => Promise<Message[]>) | undefined;
405
1232
  //# sourceMappingURL=context.d.ts.map