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

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