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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (665) hide show
  1. package/README.md +29 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/agent-memory.d.ts +118 -0
  4. package/dist/agent-memory.d.ts.map +1 -0
  5. package/dist/agent-memory.js +186 -0
  6. package/dist/agent-memory.js.map +1 -0
  7. package/dist/async-local-storage.d.ts +20 -0
  8. package/dist/async-local-storage.d.ts.map +1 -0
  9. package/dist/async-local-storage.js +28 -0
  10. package/dist/async-local-storage.js.map +1 -0
  11. package/dist/blender-executor.d.ts +93 -0
  12. package/dist/blender-executor.d.ts.map +1 -0
  13. package/dist/blender-executor.js +294 -0
  14. package/dist/blender-executor.js.map +1 -0
  15. package/dist/comfy-executor.d.ts +23 -1
  16. package/dist/comfy-executor.d.ts.map +1 -1
  17. package/dist/comfy-executor.js +234 -55
  18. package/dist/comfy-executor.js.map +1 -1
  19. package/dist/context-packer.d.ts +1 -1
  20. package/dist/context-packer.d.ts.map +1 -1
  21. package/dist/context-packer.js +23 -25
  22. package/dist/context-packer.js.map +1 -1
  23. package/dist/context.d.ts +954 -127
  24. package/dist/context.d.ts.map +1 -1
  25. package/dist/context.js +2424 -513
  26. package/dist/context.js.map +1 -1
  27. package/dist/cost-reconciler.d.ts +32 -0
  28. package/dist/cost-reconciler.d.ts.map +1 -0
  29. package/dist/cost-reconciler.js +21 -0
  30. package/dist/cost-reconciler.js.map +1 -0
  31. package/dist/entities.d.ts +33 -0
  32. package/dist/entities.d.ts.map +1 -0
  33. package/dist/entities.js +43 -0
  34. package/dist/entities.js.map +1 -0
  35. package/dist/external-media-fetch.d.ts +29 -0
  36. package/dist/external-media-fetch.d.ts.map +1 -0
  37. package/dist/external-media-fetch.js +38 -0
  38. package/dist/external-media-fetch.js.map +1 -0
  39. package/dist/generation-receipt.d.ts +86 -0
  40. package/dist/generation-receipt.d.ts.map +1 -0
  41. package/dist/generation-receipt.js +137 -0
  42. package/dist/generation-receipt.js.map +1 -0
  43. package/dist/generation-registry.d.ts +67 -0
  44. package/dist/generation-registry.d.ts.map +1 -0
  45. package/dist/generation-registry.js +126 -0
  46. package/dist/generation-registry.js.map +1 -0
  47. package/dist/google/client.d.ts +196 -0
  48. package/dist/google/client.d.ts.map +1 -0
  49. package/dist/google/client.js +396 -0
  50. package/dist/google/client.js.map +1 -0
  51. package/dist/google/index.d.ts +3 -0
  52. package/dist/google/index.d.ts.map +1 -0
  53. package/dist/google/index.js +3 -0
  54. package/dist/google/index.js.map +1 -0
  55. package/dist/google/token.d.ts +15 -0
  56. package/dist/google/token.d.ts.map +1 -0
  57. package/dist/google/token.js +24 -0
  58. package/dist/google/token.js.map +1 -0
  59. package/dist/host-binaries.d.ts +106 -0
  60. package/dist/host-binaries.d.ts.map +1 -0
  61. package/dist/host-binaries.js +344 -0
  62. package/dist/host-binaries.js.map +1 -0
  63. package/dist/image-codec.d.ts +74 -0
  64. package/dist/image-codec.d.ts.map +1 -0
  65. package/dist/image-codec.js +273 -0
  66. package/dist/image-codec.js.map +1 -0
  67. package/dist/index.d.ts +56 -6
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +43 -4
  70. package/dist/index.js.map +1 -1
  71. package/dist/invocation-account.d.ts +43 -0
  72. package/dist/invocation-account.d.ts.map +1 -0
  73. package/dist/invocation-account.js +60 -0
  74. package/dist/invocation-account.js.map +1 -0
  75. package/dist/media-ref-bytes.d.ts +19 -0
  76. package/dist/media-ref-bytes.d.ts.map +1 -0
  77. package/dist/media-ref-bytes.js +181 -0
  78. package/dist/media-ref-bytes.js.map +1 -0
  79. package/dist/node-executor.d.ts +113 -2
  80. package/dist/node-executor.d.ts.map +1 -1
  81. package/dist/permission-gate.d.ts +152 -0
  82. package/dist/permission-gate.d.ts.map +1 -0
  83. package/dist/permission-gate.js +87 -0
  84. package/dist/permission-gate.js.map +1 -0
  85. package/dist/prefixed-storage-adapter.d.ts +33 -0
  86. package/dist/prefixed-storage-adapter.d.ts.map +1 -0
  87. package/dist/prefixed-storage-adapter.js +70 -0
  88. package/dist/prefixed-storage-adapter.js.map +1 -0
  89. package/dist/prompt-asset-refs.d.ts +222 -0
  90. package/dist/prompt-asset-refs.d.ts.map +1 -0
  91. package/dist/prompt-asset-refs.js +751 -0
  92. package/dist/prompt-asset-refs.js.map +1 -0
  93. package/dist/provider-cache.d.ts +3 -0
  94. package/dist/provider-cache.d.ts.map +1 -0
  95. package/dist/provider-cache.js +8 -0
  96. package/dist/provider-cache.js.map +1 -0
  97. package/dist/providers/aki-provider.d.ts +33 -10
  98. package/dist/providers/aki-provider.d.ts.map +1 -1
  99. package/dist/providers/aki-provider.js +84 -77
  100. package/dist/providers/aki-provider.js.map +1 -1
  101. package/dist/providers/alibaba-provider.d.ts +39 -0
  102. package/dist/providers/alibaba-provider.d.ts.map +1 -0
  103. package/dist/providers/alibaba-provider.js +86 -0
  104. package/dist/providers/alibaba-provider.js.map +1 -0
  105. package/dist/providers/anthropic-provider.d.ts +52 -3
  106. package/dist/providers/anthropic-provider.d.ts.map +1 -1
  107. package/dist/providers/anthropic-provider.js +1020 -338
  108. package/dist/providers/anthropic-provider.js.map +1 -1
  109. package/dist/providers/atlascloud-provider.d.ts +101 -0
  110. package/dist/providers/atlascloud-provider.d.ts.map +1 -0
  111. package/dist/providers/atlascloud-provider.js +1009 -0
  112. package/dist/providers/atlascloud-provider.js.map +1 -0
  113. package/dist/providers/atlascloud-transport.d.ts +100 -0
  114. package/dist/providers/atlascloud-transport.d.ts.map +1 -0
  115. package/dist/providers/atlascloud-transport.js +364 -0
  116. package/dist/providers/atlascloud-transport.js.map +1 -0
  117. package/dist/providers/atlascloud-webhook-registry.d.ts +35 -0
  118. package/dist/providers/atlascloud-webhook-registry.d.ts.map +1 -0
  119. package/dist/providers/atlascloud-webhook-registry.js +104 -0
  120. package/dist/providers/atlascloud-webhook-registry.js.map +1 -0
  121. package/dist/providers/audio-mime.d.ts +11 -0
  122. package/dist/providers/audio-mime.d.ts.map +1 -0
  123. package/dist/providers/audio-mime.js +46 -0
  124. package/dist/providers/audio-mime.js.map +1 -0
  125. package/dist/providers/base-provider.d.ts +481 -24
  126. package/dist/providers/base-provider.d.ts.map +1 -1
  127. package/dist/providers/base-provider.js +1259 -42
  128. package/dist/providers/base-provider.js.map +1 -1
  129. package/dist/providers/cassette-provider.d.ts +217 -0
  130. package/dist/providers/cassette-provider.d.ts.map +1 -0
  131. package/dist/providers/cassette-provider.js +502 -0
  132. package/dist/providers/cassette-provider.js.map +1 -0
  133. package/dist/providers/cerebras-provider.d.ts +6 -12
  134. package/dist/providers/cerebras-provider.d.ts.map +1 -1
  135. package/dist/providers/cerebras-provider.js +8 -33
  136. package/dist/providers/cerebras-provider.js.map +1 -1
  137. package/dist/providers/claude-agent-provider.d.ts +131 -68
  138. package/dist/providers/claude-agent-provider.d.ts.map +1 -1
  139. package/dist/providers/claude-agent-provider.js +1095 -515
  140. package/dist/providers/claude-agent-provider.js.map +1 -1
  141. package/dist/providers/codex-provider.d.ts +82 -0
  142. package/dist/providers/codex-provider.d.ts.map +1 -0
  143. package/dist/providers/codex-provider.js +492 -0
  144. package/dist/providers/codex-provider.js.map +1 -0
  145. package/dist/providers/cohere-provider.d.ts +5 -2
  146. package/dist/providers/cohere-provider.d.ts.map +1 -1
  147. package/dist/providers/cohere-provider.js +9 -2
  148. package/dist/providers/cohere-provider.js.map +1 -1
  149. package/dist/providers/comfy-cloud-provider.d.ts +30 -0
  150. package/dist/providers/comfy-cloud-provider.d.ts.map +1 -0
  151. package/dist/providers/comfy-cloud-provider.js +42 -0
  152. package/dist/providers/comfy-cloud-provider.js.map +1 -0
  153. package/dist/providers/content-filter.d.ts +46 -0
  154. package/dist/providers/content-filter.d.ts.map +1 -0
  155. package/dist/providers/content-filter.js +92 -0
  156. package/dist/providers/content-filter.js.map +1 -0
  157. package/dist/providers/context-exceeded.d.ts +37 -0
  158. package/dist/providers/context-exceeded.d.ts.map +1 -0
  159. package/dist/providers/context-exceeded.js +114 -0
  160. package/dist/providers/context-exceeded.js.map +1 -0
  161. package/dist/providers/context-window.d.ts +44 -0
  162. package/dist/providers/context-window.d.ts.map +1 -0
  163. package/dist/providers/context-window.js +145 -0
  164. package/dist/providers/context-window.js.map +1 -0
  165. package/dist/providers/contract/index.d.ts +4 -0
  166. package/dist/providers/contract/index.d.ts.map +1 -0
  167. package/dist/providers/contract/index.js +4 -0
  168. package/dist/providers/contract/index.js.map +1 -0
  169. package/dist/providers/contract/probe-manifest.d.ts +75 -0
  170. package/dist/providers/contract/probe-manifest.d.ts.map +1 -0
  171. package/dist/providers/contract/probe-manifest.js +379 -0
  172. package/dist/providers/contract/probe-manifest.js.map +1 -0
  173. package/dist/providers/contract/probe-runner.d.ts +57 -0
  174. package/dist/providers/contract/probe-runner.d.ts.map +1 -0
  175. package/dist/providers/contract/probe-runner.js +180 -0
  176. package/dist/providers/contract/probe-runner.js.map +1 -0
  177. package/dist/providers/contract/redact.d.ts +29 -0
  178. package/dist/providers/contract/redact.d.ts.map +1 -0
  179. package/dist/providers/contract/redact.js +113 -0
  180. package/dist/providers/contract/redact.js.map +1 -0
  181. package/dist/providers/core-tools.d.ts +74 -0
  182. package/dist/providers/core-tools.d.ts.map +1 -0
  183. package/dist/providers/core-tools.js +127 -0
  184. package/dist/providers/core-tools.js.map +1 -0
  185. package/dist/providers/cost-calculator.d.ts +69 -50
  186. package/dist/providers/cost-calculator.d.ts.map +1 -1
  187. package/dist/providers/cost-calculator.js +207 -397
  188. package/dist/providers/cost-calculator.js.map +1 -1
  189. package/dist/providers/credential-check.d.ts +45 -0
  190. package/dist/providers/credential-check.d.ts.map +1 -0
  191. package/dist/providers/credential-check.js +159 -0
  192. package/dist/providers/credential-check.js.map +1 -0
  193. package/dist/providers/custom-model-kinds.d.ts +33 -0
  194. package/dist/providers/custom-model-kinds.d.ts.map +1 -0
  195. package/dist/providers/custom-model-kinds.js +96 -0
  196. package/dist/providers/custom-model-kinds.js.map +1 -0
  197. package/dist/providers/custom-openai-provider.d.ts +81 -0
  198. package/dist/providers/custom-openai-provider.d.ts.map +1 -0
  199. package/dist/providers/custom-openai-provider.js +182 -0
  200. package/dist/providers/custom-openai-provider.js.map +1 -0
  201. package/dist/providers/custom-provider-registry.d.ts +19 -0
  202. package/dist/providers/custom-provider-registry.d.ts.map +1 -0
  203. package/dist/providers/custom-provider-registry.js +52 -0
  204. package/dist/providers/custom-provider-registry.js.map +1 -0
  205. package/dist/providers/deepseek-provider.d.ts +8 -14
  206. package/dist/providers/deepseek-provider.d.ts.map +1 -1
  207. package/dist/providers/deepseek-provider.js +6 -35
  208. package/dist/providers/deepseek-provider.js.map +1 -1
  209. package/dist/providers/defaults.d.ts +12 -0
  210. package/dist/providers/defaults.d.ts.map +1 -0
  211. package/dist/providers/defaults.js +12 -0
  212. package/dist/providers/defaults.js.map +1 -0
  213. package/dist/providers/elevenlabs-provider.d.ts +49 -0
  214. package/dist/providers/elevenlabs-provider.d.ts.map +1 -0
  215. package/dist/providers/elevenlabs-provider.js +142 -0
  216. package/dist/providers/elevenlabs-provider.js.map +1 -0
  217. package/dist/providers/entity-references.d.ts +31 -0
  218. package/dist/providers/entity-references.d.ts.map +1 -0
  219. package/dist/providers/entity-references.js +113 -0
  220. package/dist/providers/entity-references.js.map +1 -0
  221. package/dist/providers/evolink-provider.d.ts +38 -0
  222. package/dist/providers/evolink-provider.d.ts.map +1 -0
  223. package/dist/providers/evolink-provider.js +304 -0
  224. package/dist/providers/evolink-provider.js.map +1 -0
  225. package/dist/providers/fake-provider.d.ts +72 -1
  226. package/dist/providers/fake-provider.d.ts.map +1 -1
  227. package/dist/providers/fake-provider.js +203 -1
  228. package/dist/providers/fake-provider.js.map +1 -1
  229. package/dist/providers/fal-generations.d.ts +106 -0
  230. package/dist/providers/fal-generations.d.ts.map +1 -0
  231. package/dist/providers/fal-generations.js +286 -0
  232. package/dist/providers/fal-generations.js.map +1 -0
  233. package/dist/providers/fal-provider.d.ts +171 -7
  234. package/dist/providers/fal-provider.d.ts.map +1 -1
  235. package/dist/providers/fal-provider.js +1369 -64
  236. package/dist/providers/fal-provider.js.map +1 -1
  237. package/dist/providers/fal-queue.d.ts +47 -0
  238. package/dist/providers/fal-queue.d.ts.map +1 -0
  239. package/dist/providers/fal-queue.js +231 -0
  240. package/dist/providers/fal-queue.js.map +1 -0
  241. package/dist/providers/gemini-provider.d.ts +148 -8
  242. package/dist/providers/gemini-provider.d.ts.map +1 -1
  243. package/dist/providers/gemini-provider.js +1500 -316
  244. package/dist/providers/gemini-provider.js.map +1 -1
  245. package/dist/providers/gmi-provider.d.ts +21 -0
  246. package/dist/providers/gmi-provider.d.ts.map +1 -0
  247. package/dist/providers/gmi-provider.js +34 -0
  248. package/dist/providers/gmi-provider.js.map +1 -0
  249. package/dist/providers/gpt-image-size.d.ts +3 -0
  250. package/dist/providers/gpt-image-size.d.ts.map +1 -0
  251. package/dist/providers/gpt-image-size.js +37 -0
  252. package/dist/providers/gpt-image-size.js.map +1 -0
  253. package/dist/providers/groq-provider.d.ts +9 -12
  254. package/dist/providers/groq-provider.d.ts.map +1 -1
  255. package/dist/providers/groq-provider.js +19 -33
  256. package/dist/providers/groq-provider.js.map +1 -1
  257. package/dist/providers/groq-request.d.ts +38 -0
  258. package/dist/providers/groq-request.d.ts.map +1 -0
  259. package/dist/providers/groq-request.js +138 -0
  260. package/dist/providers/groq-request.js.map +1 -0
  261. package/dist/providers/higgsfield-provider.d.ts +30 -0
  262. package/dist/providers/higgsfield-provider.d.ts.map +1 -0
  263. package/dist/providers/higgsfield-provider.js +131 -0
  264. package/dist/providers/higgsfield-provider.js.map +1 -0
  265. package/dist/providers/higgsfield-transport.d.ts +106 -0
  266. package/dist/providers/higgsfield-transport.d.ts.map +1 -0
  267. package/dist/providers/higgsfield-transport.js +182 -0
  268. package/dist/providers/higgsfield-transport.js.map +1 -0
  269. package/dist/providers/http-transport.d.ts +74 -0
  270. package/dist/providers/http-transport.d.ts.map +1 -0
  271. package/dist/providers/http-transport.js +152 -0
  272. package/dist/providers/http-transport.js.map +1 -0
  273. package/dist/providers/huggingface-provider.d.ts +71 -3
  274. package/dist/providers/huggingface-provider.d.ts.map +1 -1
  275. package/dist/providers/huggingface-provider.js +230 -34
  276. package/dist/providers/huggingface-provider.js.map +1 -1
  277. package/dist/providers/image-mime.d.ts +39 -0
  278. package/dist/providers/image-mime.d.ts.map +1 -0
  279. package/dist/providers/image-mime.js +111 -0
  280. package/dist/providers/image-mime.js.map +1 -0
  281. package/dist/providers/image-ref.d.ts +21 -0
  282. package/dist/providers/image-ref.d.ts.map +1 -0
  283. package/dist/providers/image-ref.js +44 -0
  284. package/dist/providers/image-ref.js.map +1 -0
  285. package/dist/providers/index.d.ts +84 -8
  286. package/dist/providers/index.d.ts.map +1 -1
  287. package/dist/providers/index.js +239 -56
  288. package/dist/providers/index.js.map +1 -1
  289. package/dist/providers/jina-provider.d.ts +10 -2
  290. package/dist/providers/jina-provider.d.ts.map +1 -1
  291. package/dist/providers/jina-provider.js +16 -7
  292. package/dist/providers/jina-provider.js.map +1 -1
  293. package/dist/providers/kie-provider.d.ts +170 -9
  294. package/dist/providers/kie-provider.d.ts.map +1 -1
  295. package/dist/providers/kie-provider.js +1176 -228
  296. package/dist/providers/kie-provider.js.map +1 -1
  297. package/dist/providers/kie-webhook-registry.d.ts +28 -0
  298. package/dist/providers/kie-webhook-registry.d.ts.map +1 -0
  299. package/dist/providers/kie-webhook-registry.js +91 -0
  300. package/dist/providers/kie-webhook-registry.js.map +1 -0
  301. package/dist/providers/llama-provider.d.ts +21 -37
  302. package/dist/providers/llama-provider.d.ts.map +1 -1
  303. package/dist/providers/llama-provider.js +43 -354
  304. package/dist/providers/llama-provider.js.map +1 -1
  305. package/dist/providers/lmstudio-provider.d.ts +4 -7
  306. package/dist/providers/lmstudio-provider.d.ts.map +1 -1
  307. package/dist/providers/lmstudio-provider.js +24 -15
  308. package/dist/providers/lmstudio-provider.js.map +1 -1
  309. package/dist/providers/manifest-models.d.ts +341 -1
  310. package/dist/providers/manifest-models.d.ts.map +1 -1
  311. package/dist/providers/manifest-models.js +1106 -22
  312. package/dist/providers/manifest-models.js.map +1 -1
  313. package/dist/providers/media-mime.d.ts +14 -0
  314. package/dist/providers/media-mime.d.ts.map +1 -0
  315. package/dist/providers/media-mime.js +35 -0
  316. package/dist/providers/media-mime.js.map +1 -0
  317. package/dist/providers/meshy-provider.d.ts +14 -1
  318. package/dist/providers/meshy-provider.d.ts.map +1 -1
  319. package/dist/providers/meshy-provider.js +76 -46
  320. package/dist/providers/meshy-provider.js.map +1 -1
  321. package/dist/providers/meta-provider.d.ts +22 -0
  322. package/dist/providers/meta-provider.d.ts.map +1 -0
  323. package/dist/providers/meta-provider.js +54 -0
  324. package/dist/providers/meta-provider.js.map +1 -0
  325. package/dist/providers/minimax-provider.d.ts +25 -18
  326. package/dist/providers/minimax-provider.d.ts.map +1 -1
  327. package/dist/providers/minimax-provider.js +211 -72
  328. package/dist/providers/minimax-provider.js.map +1 -1
  329. package/dist/providers/mistral-provider.d.ts +6 -12
  330. package/dist/providers/mistral-provider.d.ts.map +1 -1
  331. package/dist/providers/mistral-provider.js +10 -34
  332. package/dist/providers/mistral-provider.js.map +1 -1
  333. package/dist/providers/moonshot-provider.d.ts +11 -15
  334. package/dist/providers/moonshot-provider.d.ts.map +1 -1
  335. package/dist/providers/moonshot-provider.js +33 -23
  336. package/dist/providers/moonshot-provider.js.map +1 -1
  337. package/dist/providers/node-llama-cpp-provider.d.ts +98 -0
  338. package/dist/providers/node-llama-cpp-provider.d.ts.map +1 -0
  339. package/dist/providers/node-llama-cpp-provider.js +479 -0
  340. package/dist/providers/node-llama-cpp-provider.js.map +1 -0
  341. package/dist/providers/nodetool-provider.d.ts +49 -0
  342. package/dist/providers/nodetool-provider.d.ts.map +1 -0
  343. package/dist/providers/nodetool-provider.js +224 -0
  344. package/dist/providers/nodetool-provider.js.map +1 -0
  345. package/dist/providers/oauth/browser-launcher.d.ts +23 -0
  346. package/dist/providers/oauth/browser-launcher.d.ts.map +1 -0
  347. package/dist/providers/oauth/browser-launcher.js +45 -0
  348. package/dist/providers/oauth/browser-launcher.js.map +1 -0
  349. package/dist/providers/oauth/claude-code-credentials.d.ts +74 -0
  350. package/dist/providers/oauth/claude-code-credentials.d.ts.map +1 -0
  351. package/dist/providers/oauth/claude-code-credentials.js +133 -0
  352. package/dist/providers/oauth/claude-code-credentials.js.map +1 -0
  353. package/dist/providers/oauth/claude-code-login.d.ts +124 -0
  354. package/dist/providers/oauth/claude-code-login.d.ts.map +1 -0
  355. package/dist/providers/oauth/claude-code-login.js +230 -0
  356. package/dist/providers/oauth/claude-code-login.js.map +1 -0
  357. package/dist/providers/oauth/claude-code-oauth-client.d.ts +111 -0
  358. package/dist/providers/oauth/claude-code-oauth-client.d.ts.map +1 -0
  359. package/dist/providers/oauth/claude-code-oauth-client.js +207 -0
  360. package/dist/providers/oauth/claude-code-oauth-client.js.map +1 -0
  361. package/dist/providers/oauth/errors.d.ts +54 -0
  362. package/dist/providers/oauth/errors.d.ts.map +1 -0
  363. package/dist/providers/oauth/errors.js +79 -0
  364. package/dist/providers/oauth/errors.js.map +1 -0
  365. package/dist/providers/oauth/index.d.ts +105 -0
  366. package/dist/providers/oauth/index.d.ts.map +1 -0
  367. package/dist/providers/oauth/index.js +167 -0
  368. package/dist/providers/oauth/index.js.map +1 -0
  369. package/dist/providers/oauth/jwt-claims.d.ts +23 -0
  370. package/dist/providers/oauth/jwt-claims.d.ts.map +1 -0
  371. package/dist/providers/oauth/jwt-claims.js +67 -0
  372. package/dist/providers/oauth/jwt-claims.js.map +1 -0
  373. package/dist/providers/oauth/local-callback-server.d.ts +60 -0
  374. package/dist/providers/oauth/local-callback-server.d.ts.map +1 -0
  375. package/dist/providers/oauth/local-callback-server.js +148 -0
  376. package/dist/providers/oauth/local-callback-server.js.map +1 -0
  377. package/dist/providers/oauth/oauth-client.d.ts +55 -0
  378. package/dist/providers/oauth/oauth-client.d.ts.map +1 -0
  379. package/dist/providers/oauth/oauth-client.js +161 -0
  380. package/dist/providers/oauth/oauth-client.js.map +1 -0
  381. package/dist/providers/oauth/openai-oauth-provider.d.ts +129 -0
  382. package/dist/providers/oauth/openai-oauth-provider.d.ts.map +1 -0
  383. package/dist/providers/oauth/openai-oauth-provider.js +265 -0
  384. package/dist/providers/oauth/openai-oauth-provider.js.map +1 -0
  385. package/dist/providers/oauth/pkce-helper.d.ts +43 -0
  386. package/dist/providers/oauth/pkce-helper.d.ts.map +1 -0
  387. package/dist/providers/oauth/pkce-helper.js +57 -0
  388. package/dist/providers/oauth/pkce-helper.js.map +1 -0
  389. package/dist/providers/oauth/redaction.d.ts +22 -0
  390. package/dist/providers/oauth/redaction.d.ts.map +1 -0
  391. package/dist/providers/oauth/redaction.js +59 -0
  392. package/dist/providers/oauth/redaction.js.map +1 -0
  393. package/dist/providers/oauth/secure-credential-store.d.ts +67 -0
  394. package/dist/providers/oauth/secure-credential-store.d.ts.map +1 -0
  395. package/dist/providers/oauth/secure-credential-store.js +73 -0
  396. package/dist/providers/oauth/secure-credential-store.js.map +1 -0
  397. package/dist/providers/oauth/token-store.d.ts +53 -0
  398. package/dist/providers/oauth/token-store.d.ts.map +1 -0
  399. package/dist/providers/oauth/token-store.js +78 -0
  400. package/dist/providers/oauth/token-store.js.map +1 -0
  401. package/dist/providers/oauth/types.d.ts +64 -0
  402. package/dist/providers/oauth/types.d.ts.map +1 -0
  403. package/dist/providers/oauth/types.js +12 -0
  404. package/dist/providers/oauth/types.js.map +1 -0
  405. package/dist/providers/object-tracking.d.ts +47 -0
  406. package/dist/providers/object-tracking.d.ts.map +1 -0
  407. package/dist/providers/object-tracking.js +46 -0
  408. package/dist/providers/object-tracking.js.map +1 -0
  409. package/dist/providers/offline-model-index.d.ts +20 -0
  410. package/dist/providers/offline-model-index.d.ts.map +1 -0
  411. package/dist/providers/offline-model-index.js +112 -0
  412. package/dist/providers/offline-model-index.js.map +1 -0
  413. package/dist/providers/ollama-provider.d.ts +28 -1
  414. package/dist/providers/ollama-provider.d.ts.map +1 -1
  415. package/dist/providers/ollama-provider.js +193 -43
  416. package/dist/providers/ollama-provider.js.map +1 -1
  417. package/dist/providers/openai-compat/client.d.ts +57 -0
  418. package/dist/providers/openai-compat/client.d.ts.map +1 -0
  419. package/dist/providers/openai-compat/client.js +157 -0
  420. package/dist/providers/openai-compat/client.js.map +1 -0
  421. package/dist/providers/openai-compat/decode.d.ts +36 -0
  422. package/dist/providers/openai-compat/decode.d.ts.map +1 -0
  423. package/dist/providers/openai-compat/decode.js +55 -0
  424. package/dist/providers/openai-compat/decode.js.map +1 -0
  425. package/dist/providers/openai-compat/errors.d.ts +54 -0
  426. package/dist/providers/openai-compat/errors.d.ts.map +1 -0
  427. package/dist/providers/openai-compat/errors.js +144 -0
  428. package/dist/providers/openai-compat/errors.js.map +1 -0
  429. package/dist/providers/openai-compat/index.d.ts +8 -0
  430. package/dist/providers/openai-compat/index.d.ts.map +1 -0
  431. package/dist/providers/openai-compat/index.js +5 -0
  432. package/dist/providers/openai-compat/index.js.map +1 -0
  433. package/dist/providers/openai-compat/sse.d.ts +14 -0
  434. package/dist/providers/openai-compat/sse.d.ts.map +1 -0
  435. package/dist/providers/openai-compat/sse.js +69 -0
  436. package/dist/providers/openai-compat/sse.js.map +1 -0
  437. package/dist/providers/openai-compat/types.d.ts +75 -0
  438. package/dist/providers/openai-compat/types.d.ts.map +1 -0
  439. package/dist/providers/openai-compat/types.js +9 -0
  440. package/dist/providers/openai-compat/types.js.map +1 -0
  441. package/dist/providers/openai-compat-provider.d.ts +90 -0
  442. package/dist/providers/openai-compat-provider.d.ts.map +1 -0
  443. package/dist/providers/openai-compat-provider.js +282 -0
  444. package/dist/providers/openai-compat-provider.js.map +1 -0
  445. package/dist/providers/openai-provider.d.ts +89 -26
  446. package/dist/providers/openai-provider.d.ts.map +1 -1
  447. package/dist/providers/openai-provider.js +990 -105
  448. package/dist/providers/openai-provider.js.map +1 -1
  449. package/dist/providers/openrouter-provider.d.ts +6 -12
  450. package/dist/providers/openrouter-provider.d.ts.map +1 -1
  451. package/dist/providers/openrouter-provider.js +24 -53
  452. package/dist/providers/openrouter-provider.js.map +1 -1
  453. package/dist/providers/provider-call-failure.d.ts +39 -0
  454. package/dist/providers/provider-call-failure.d.ts.map +1 -0
  455. package/dist/providers/provider-call-failure.js +132 -0
  456. package/dist/providers/provider-call-failure.js.map +1 -0
  457. package/dist/providers/provider-error.d.ts +59 -0
  458. package/dist/providers/provider-error.d.ts.map +1 -0
  459. package/dist/providers/provider-error.js +165 -0
  460. package/dist/providers/provider-error.js.map +1 -0
  461. package/dist/providers/provider-generations.d.ts +99 -0
  462. package/dist/providers/provider-generations.d.ts.map +1 -0
  463. package/dist/providers/provider-generations.js +71 -0
  464. package/dist/providers/provider-generations.js.map +1 -0
  465. package/dist/providers/provider-queue.d.ts +62 -0
  466. package/dist/providers/provider-queue.d.ts.map +1 -0
  467. package/dist/providers/provider-queue.js +28 -0
  468. package/dist/providers/provider-queue.js.map +1 -0
  469. package/dist/providers/provider-registry.d.ts +33 -14
  470. package/dist/providers/provider-registry.d.ts.map +1 -1
  471. package/dist/providers/provider-registry.js +85 -68
  472. package/dist/providers/provider-registry.js.map +1 -1
  473. package/dist/providers/provider-request-log.d.ts +53 -0
  474. package/dist/providers/provider-request-log.d.ts.map +1 -0
  475. package/dist/providers/provider-request-log.js +157 -0
  476. package/dist/providers/provider-request-log.js.map +1 -0
  477. package/dist/providers/provider-session.d.ts +3 -0
  478. package/dist/providers/provider-session.d.ts.map +1 -0
  479. package/dist/providers/provider-session.js +10 -0
  480. package/dist/providers/provider-session.js.map +1 -0
  481. package/dist/providers/provider-transport.d.ts +11 -0
  482. package/dist/providers/provider-transport.d.ts.map +1 -0
  483. package/dist/providers/provider-transport.js +11 -0
  484. package/dist/providers/provider-transport.js.map +1 -0
  485. package/dist/providers/python-provider.d.ts +20 -12
  486. package/dist/providers/python-provider.d.ts.map +1 -1
  487. package/dist/providers/python-provider.js +185 -25
  488. package/dist/providers/python-provider.js.map +1 -1
  489. package/dist/providers/replicate-provider.d.ts +89 -7
  490. package/dist/providers/replicate-provider.d.ts.map +1 -1
  491. package/dist/providers/replicate-provider.js +801 -65
  492. package/dist/providers/replicate-provider.js.map +1 -1
  493. package/dist/providers/replicate-retry.d.ts +30 -0
  494. package/dist/providers/replicate-retry.d.ts.map +1 -0
  495. package/dist/providers/replicate-retry.js +97 -0
  496. package/dist/providers/replicate-retry.js.map +1 -0
  497. package/dist/providers/responses-api.d.ts +27 -0
  498. package/dist/providers/responses-api.d.ts.map +1 -0
  499. package/dist/providers/responses-api.js +297 -0
  500. package/dist/providers/responses-api.js.map +1 -0
  501. package/dist/providers/reve-provider.d.ts +45 -0
  502. package/dist/providers/reve-provider.d.ts.map +1 -0
  503. package/dist/providers/reve-provider.js +159 -0
  504. package/dist/providers/reve-provider.js.map +1 -0
  505. package/dist/providers/rodin-provider.d.ts +23 -1
  506. package/dist/providers/rodin-provider.d.ts.map +1 -1
  507. package/dist/providers/rodin-provider.js +89 -51
  508. package/dist/providers/rodin-provider.js.map +1 -1
  509. package/dist/providers/safe-url.d.ts +70 -0
  510. package/dist/providers/safe-url.d.ts.map +1 -0
  511. package/dist/providers/safe-url.js +277 -0
  512. package/dist/providers/safe-url.js.map +1 -0
  513. package/dist/providers/scripted-provider.d.ts +9 -0
  514. package/dist/providers/scripted-provider.d.ts.map +1 -1
  515. package/dist/providers/scripted-provider.js +86 -10
  516. package/dist/providers/scripted-provider.js.map +1 -1
  517. package/dist/providers/structured-output.d.ts +42 -0
  518. package/dist/providers/structured-output.d.ts.map +1 -0
  519. package/dist/providers/structured-output.js +83 -0
  520. package/dist/providers/structured-output.js.map +1 -0
  521. package/dist/providers/together-provider.d.ts +19 -16
  522. package/dist/providers/together-provider.d.ts.map +1 -1
  523. package/dist/providers/together-provider.js +103 -225
  524. package/dist/providers/together-provider.js.map +1 -1
  525. package/dist/providers/topaz-provider.d.ts +44 -0
  526. package/dist/providers/topaz-provider.d.ts.map +1 -0
  527. package/dist/providers/topaz-provider.js +239 -0
  528. package/dist/providers/topaz-provider.js.map +1 -0
  529. package/dist/providers/types.d.ts +603 -4
  530. package/dist/providers/types.d.ts.map +1 -1
  531. package/dist/providers/types.js +81 -1
  532. package/dist/providers/types.js.map +1 -1
  533. package/dist/providers/useapi-provider.d.ts +27 -0
  534. package/dist/providers/useapi-provider.d.ts.map +1 -0
  535. package/dist/providers/useapi-provider.js +266 -0
  536. package/dist/providers/useapi-provider.js.map +1 -0
  537. package/dist/providers/video-duration.d.ts +6 -0
  538. package/dist/providers/video-duration.d.ts.map +1 -0
  539. package/dist/providers/video-duration.js +63 -0
  540. package/dist/providers/video-duration.js.map +1 -0
  541. package/dist/providers/video-frame-fallback.d.ts +39 -0
  542. package/dist/providers/video-frame-fallback.d.ts.map +1 -0
  543. package/dist/providers/video-frame-fallback.js +155 -0
  544. package/dist/providers/video-frame-fallback.js.map +1 -0
  545. package/dist/providers/video-frames.d.ts +61 -0
  546. package/dist/providers/video-frames.d.ts.map +1 -0
  547. package/dist/providers/video-frames.js +208 -0
  548. package/dist/providers/video-frames.js.map +1 -0
  549. package/dist/providers/video-mime.d.ts +14 -0
  550. package/dist/providers/video-mime.d.ts.map +1 -0
  551. package/dist/providers/video-mime.js +44 -0
  552. package/dist/providers/video-mime.js.map +1 -0
  553. package/dist/providers/video-to-audio.d.ts +34 -0
  554. package/dist/providers/video-to-audio.d.ts.map +1 -0
  555. package/dist/providers/video-to-audio.js +62 -0
  556. package/dist/providers/video-to-audio.js.map +1 -0
  557. package/dist/providers/vllm-provider.d.ts +22 -8
  558. package/dist/providers/vllm-provider.d.ts.map +1 -1
  559. package/dist/providers/vllm-provider.js +48 -23
  560. package/dist/providers/vllm-provider.js.map +1 -1
  561. package/dist/providers/voyage-provider.d.ts +10 -2
  562. package/dist/providers/voyage-provider.d.ts.map +1 -1
  563. package/dist/providers/voyage-provider.js +16 -7
  564. package/dist/providers/voyage-provider.js.map +1 -1
  565. package/dist/providers/xai-provider.d.ts +54 -13
  566. package/dist/providers/xai-provider.d.ts.map +1 -1
  567. package/dist/providers/xai-provider.js +299 -22
  568. package/dist/providers/xai-provider.js.map +1 -1
  569. package/dist/python-bridge-base.d.ts +358 -0
  570. package/dist/python-bridge-base.d.ts.map +1 -0
  571. package/dist/python-bridge-base.js +1557 -0
  572. package/dist/python-bridge-base.js.map +1 -0
  573. package/dist/python-bridge-codec.d.ts +28 -0
  574. package/dist/python-bridge-codec.d.ts.map +1 -0
  575. package/dist/python-bridge-codec.js +39 -0
  576. package/dist/python-bridge-codec.js.map +1 -0
  577. package/dist/python-bridge-factory.d.ts +52 -0
  578. package/dist/python-bridge-factory.d.ts.map +1 -0
  579. package/dist/python-bridge-factory.js +69 -0
  580. package/dist/python-bridge-factory.js.map +1 -0
  581. package/dist/python-bridge-framing.d.ts +68 -0
  582. package/dist/python-bridge-framing.d.ts.map +1 -0
  583. package/dist/python-bridge-framing.js +91 -0
  584. package/dist/python-bridge-framing.js.map +1 -0
  585. package/dist/python-bridge-types.d.ts +545 -2
  586. package/dist/python-bridge-types.d.ts.map +1 -1
  587. package/dist/python-bridge-types.js +49 -1
  588. package/dist/python-bridge-types.js.map +1 -1
  589. package/dist/python-graph-resolver.d.ts +57 -0
  590. package/dist/python-graph-resolver.d.ts.map +1 -0
  591. package/dist/python-graph-resolver.js +79 -0
  592. package/dist/python-graph-resolver.js.map +1 -0
  593. package/dist/python-node-executor.d.ts +36 -4
  594. package/dist/python-node-executor.d.ts.map +1 -1
  595. package/dist/python-node-executor.js +177 -86
  596. package/dist/python-node-executor.js.map +1 -1
  597. package/dist/python-stdio-bridge.d.ts +18 -37
  598. package/dist/python-stdio-bridge.d.ts.map +1 -1
  599. package/dist/python-stdio-bridge.js +148 -475
  600. package/dist/python-stdio-bridge.js.map +1 -1
  601. package/dist/python-websocket-bridge.d.ts +140 -0
  602. package/dist/python-websocket-bridge.d.ts.map +1 -0
  603. package/dist/python-websocket-bridge.js +561 -0
  604. package/dist/python-websocket-bridge.js.map +1 -0
  605. package/dist/python-worker-stderr.d.ts +4 -0
  606. package/dist/python-worker-stderr.d.ts.map +1 -0
  607. package/dist/python-worker-stderr.js +24 -0
  608. package/dist/python-worker-stderr.js.map +1 -0
  609. package/dist/recommended-models.d.ts +2 -2
  610. package/dist/recommended-models.d.ts.map +1 -1
  611. package/dist/recommended-models.js +24 -4
  612. package/dist/recommended-models.js.map +1 -1
  613. package/dist/recoverable-node-error.d.ts +31 -0
  614. package/dist/recoverable-node-error.d.ts.map +1 -0
  615. package/dist/recoverable-node-error.js +37 -0
  616. package/dist/recoverable-node-error.js.map +1 -0
  617. package/dist/redact-params.d.ts +13 -0
  618. package/dist/redact-params.d.ts.map +1 -0
  619. package/dist/redact-params.js +57 -0
  620. package/dist/redact-params.js.map +1 -0
  621. package/dist/sandbox-module-catalog.d.ts +43 -0
  622. package/dist/sandbox-module-catalog.d.ts.map +1 -0
  623. package/dist/sandbox-module-catalog.js +25 -0
  624. package/dist/sandbox-module-catalog.js.map +1 -0
  625. package/dist/storage-workspace.d.ts +59 -0
  626. package/dist/storage-workspace.d.ts.map +1 -0
  627. package/dist/storage-workspace.js +426 -0
  628. package/dist/storage-workspace.js.map +1 -0
  629. package/dist/swappable-python-bridge.d.ts +83 -0
  630. package/dist/swappable-python-bridge.d.ts.map +1 -0
  631. package/dist/swappable-python-bridge.js +246 -0
  632. package/dist/swappable-python-bridge.js.map +1 -0
  633. package/dist/telemetry.d.ts +7 -0
  634. package/dist/telemetry.d.ts.map +1 -1
  635. package/dist/telemetry.js +23 -0
  636. package/dist/telemetry.js.map +1 -1
  637. package/dist/testing.d.ts +81 -0
  638. package/dist/testing.d.ts.map +1 -0
  639. package/dist/testing.js +130 -0
  640. package/dist/testing.js.map +1 -0
  641. package/dist/token-counter.d.ts +30 -0
  642. package/dist/token-counter.d.ts.map +1 -0
  643. package/dist/token-counter.js +156 -0
  644. package/dist/token-counter.js.map +1 -0
  645. package/dist/trace-exporters.d.ts +10 -0
  646. package/dist/trace-exporters.d.ts.map +1 -1
  647. package/dist/trace-exporters.js +59 -20
  648. package/dist/trace-exporters.js.map +1 -1
  649. package/dist/tracing-helpers.d.ts +45 -4
  650. package/dist/tracing-helpers.d.ts.map +1 -1
  651. package/dist/tracing-helpers.js +62 -19
  652. package/dist/tracing-helpers.js.map +1 -1
  653. package/dist/turn-budget.d.ts +278 -0
  654. package/dist/turn-budget.d.ts.map +1 -0
  655. package/dist/turn-budget.js +365 -0
  656. package/dist/turn-budget.js.map +1 -0
  657. package/dist/variable-channel.d.ts +48 -0
  658. package/dist/variable-channel.d.ts.map +1 -0
  659. package/dist/variable-channel.js +110 -0
  660. package/dist/variable-channel.js.map +1 -0
  661. package/dist/workspace.d.ts +119 -0
  662. package/dist/workspace.d.ts.map +1 -0
  663. package/dist/workspace.js +112 -0
  664. package/dist/workspace.js.map +1 -0
  665. package/package.json +107 -19
@@ -0,0 +1,181 @@
1
+ import { isPackageAssetUri, isRawRgbaImage } from "@nodetool-ai/protocol";
2
+ import { getNodeBuiltinSync } from "@nodetool-ai/config";
3
+ import { fetchExternalMedia } from "./external-media-fetch.js";
4
+ import { encodeRawRgbaToPng } from "./image-codec.js";
5
+ import { isNonEmptyString } from "@nodetool-ai/protocol";
6
+ const _nodeFsP = getNodeBuiltinSync("node:fs/promises");
7
+ const _nodeUrl = getNodeBuiltinSync("node:url");
8
+ const readFile = (...args) => _nodeFsP
9
+ ? _nodeFsP.readFile(...args)
10
+ : Promise.reject(new Error("node:fs/promises.readFile requires Node"));
11
+ const fileURLToPath = (u) => {
12
+ if (!_nodeUrl)
13
+ throw new Error("node:url.fileURLToPath requires Node");
14
+ return _nodeUrl.fileURLToPath(u);
15
+ };
16
+ /**
17
+ * Decode base64 → bytes without requiring the `Buffer` global. This module is
18
+ * shared with the browser bundle (the in-browser runner loads it inside a Web
19
+ * Worker, which has no `Buffer`), so prefer `Buffer` on Node for speed and fall
20
+ * back to `atob` everywhere else.
21
+ */
22
+ function decodeBase64(b64) {
23
+ if (typeof Buffer !== "undefined") {
24
+ return new Uint8Array(Buffer.from(b64, "base64"));
25
+ }
26
+ const binary = atob(b64);
27
+ const out = new Uint8Array(binary.length);
28
+ for (let i = 0; i < binary.length; i += 1)
29
+ out[i] = binary.charCodeAt(i);
30
+ return out;
31
+ }
32
+ /** Encode bytes → base64 without requiring the `Buffer` global. */
33
+ export function encodeBase64(bytes) {
34
+ if (typeof Buffer !== "undefined") {
35
+ return Buffer.from(bytes).toString("base64");
36
+ }
37
+ const chunks = [];
38
+ const CHUNK = 0x8000;
39
+ for (let i = 0; i < bytes.length; i += CHUNK) {
40
+ chunks.push(String.fromCharCode(...bytes.subarray(i, i + CHUNK)));
41
+ }
42
+ return btoa(chunks.join(""));
43
+ }
44
+ /** Encode a UTF-8 string → bytes without requiring the `Buffer` global. */
45
+ function encodeUtf8(text) {
46
+ if (typeof Buffer !== "undefined") {
47
+ return new Uint8Array(Buffer.from(text, "utf-8"));
48
+ }
49
+ return new TextEncoder().encode(text);
50
+ }
51
+ const ASSET_ID_EXTENSION_CANDIDATES = {
52
+ image: ["png", "jpg", "jpeg", "webp", "gif", "bmp", "svg"],
53
+ audio: ["wav", "mp3", "ogg", "m4a", "aac", "flac"],
54
+ video: ["mp4", "webm", "mov", "avi", "mpeg", "mkv"],
55
+ model3d: ["glb", "gltf", "obj", "fbx"]
56
+ };
57
+ export function isAbsoluteFilePath(uri) {
58
+ return (/^[A-Za-z]:[\\/]/.test(uri) || uri.startsWith("\\\\") || uri.startsWith("/"));
59
+ }
60
+ /** Decode a `data:` URI's payload, honoring the `;base64` header flag. */
61
+ function decodeDataUri(uri) {
62
+ // Split on the FIRST comma only: the header ends there and everything after
63
+ // is payload. `split(",", 2)` would discard payload past a second comma,
64
+ // corrupting non-base64 data (SVG path data, CSV, text) that contains commas.
65
+ const comma = uri.indexOf(",");
66
+ if (comma < 0) {
67
+ return null;
68
+ }
69
+ const header = uri.slice(0, comma);
70
+ const data = uri.slice(comma + 1);
71
+ try {
72
+ // decodeURIComponent throws URIError on a malformed percent-escape; the
73
+ // resolver contract is null-on-failure, so never let that escape.
74
+ return header.includes(";base64")
75
+ ? decodeBase64(data)
76
+ : encodeUtf8(decodeURIComponent(data));
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
82
+ async function readUriBytes(uri) {
83
+ if (uri.startsWith("data:")) {
84
+ return decodeDataUri(uri);
85
+ }
86
+ if (uri.startsWith("file://")) {
87
+ try {
88
+ return await readFile(fileURLToPath(uri));
89
+ }
90
+ catch {
91
+ return null;
92
+ }
93
+ }
94
+ if (isAbsoluteFilePath(uri)) {
95
+ try {
96
+ return await readFile(uri);
97
+ }
98
+ catch {
99
+ return null;
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+ /**
105
+ * Resolve bytes for an image/audio/video/model ref.
106
+ * Shared by the Python bridge and TS nodes (e.g. Save Image).
107
+ */
108
+ export async function loadMediaRefBytes(value, context) {
109
+ if (isRawRgbaImage(value)) {
110
+ return encodeRawRgbaToPng(value.data, value.width, value.height);
111
+ }
112
+ const data = value.data;
113
+ if (isNonEmptyString(data)) {
114
+ return data.startsWith("data:") ? decodeDataUri(data) : decodeBase64(data);
115
+ }
116
+ if (data instanceof Uint8Array && data.length > 0) {
117
+ return data;
118
+ }
119
+ const uri = value.uri;
120
+ if (!uri && !value.asset_id) {
121
+ return null;
122
+ }
123
+ if (uri && (uri.startsWith("asset://") || isPackageAssetUri(uri)) && context) {
124
+ const { bytes } = await context.resolveAssetBytes(uri);
125
+ if (bytes) {
126
+ return bytes;
127
+ }
128
+ }
129
+ // No usable uri but an asset_id is present: resolve the asset directly by id.
130
+ // The early-return above only bails when both uri and asset_id are absent, so
131
+ // an empty-uri ref like `{ asset_id, uri: "" }` still reaches this path.
132
+ if (!uri && value.asset_id && context) {
133
+ const { bytes } = await context.resolveAssetBytes(`asset://${value.asset_id}`);
134
+ if (bytes) {
135
+ return bytes;
136
+ }
137
+ }
138
+ if (context?.storage) {
139
+ const candidates = new Set();
140
+ if (uri) {
141
+ candidates.add(uri);
142
+ }
143
+ if (value.asset_id) {
144
+ const refType = (value.type ?? "").toLowerCase();
145
+ const extensions = ASSET_ID_EXTENSION_CANDIDATES[refType] ?? ["bin"];
146
+ for (const extension of extensions) {
147
+ candidates.add(`/api/storage/${value.asset_id}.${extension}`);
148
+ }
149
+ }
150
+ for (const candidate of candidates) {
151
+ const stored = await context.storage.retrieve(candidate);
152
+ if (stored !== null) {
153
+ return stored;
154
+ }
155
+ }
156
+ }
157
+ if (!uri) {
158
+ return null;
159
+ }
160
+ const fromUri = await readUriBytes(uri);
161
+ if (fromUri !== null) {
162
+ return fromUri;
163
+ }
164
+ if (uri.startsWith("http://") || uri.startsWith("https://")) {
165
+ // Last resort, and the only branch that opens a socket: the uri is caller
166
+ // data, so it goes through the media-ref egress policy rather than a bare
167
+ // fetch. A refusal throws and lands in the catch, which is this function's
168
+ // contract for "no bytes" either way.
169
+ try {
170
+ const response = await fetchExternalMedia(uri);
171
+ if (response.ok) {
172
+ return new Uint8Array(await response.arrayBuffer());
173
+ }
174
+ }
175
+ catch {
176
+ // fall through
177
+ }
178
+ }
179
+ return null;
180
+ }
181
+ //# sourceMappingURL=media-ref-bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-ref-bytes.js","sourceRoot":"","sources":["../src/media-ref-bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,QAAQ,GAAG,kBAAkB,CACjC,kBAAkB,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,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5D,0EAA0E;QAC1E,0EAA0E;QAC1E,2EAA2E;QAC3E,sCAAsC;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAC/C,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;gBAChB,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -6,28 +6,126 @@
6
6
  * interface for backward compatibility.
7
7
  */
8
8
  import type { ProcessingContext } from "./context.js";
9
+ import type { CorrelationLineage } from "@nodetool-ai/protocol";
9
10
  /**
10
11
  * Read-side interface for streaming input nodes.
11
12
  * Nodes call stream() or any() to consume incoming data.
13
+ *
14
+ * The `*WithEnvelope` variants expose correlation lineage and source edge
15
+ * ids; explicit join nodes (Zip/Cross) and forwarding nodes use them to
16
+ * preserve §3 lineage downstream.
12
17
  */
13
18
  export interface StreamingInputs {
14
19
  /** Yield items for a single handle until EOS. */
15
20
  stream(name: string): AsyncGenerator<unknown>;
21
+ /** Yield MessageEnvelopes for a single handle until EOS. §5. */
22
+ streamWithEnvelope(name: string): AsyncGenerator<MessageEnvelopeLike>;
16
23
  /** Yield [handle, item] tuples in arrival order across all handles. */
17
24
  any(): AsyncGenerator<[string, unknown]>;
18
- /** Return the first available item for a handle, or default if EOS. */
25
+ /** Yield [handle, MessageEnvelope] tuples in arrival order. */
26
+ anyWithEnvelope(): AsyncGenerator<[string, MessageEnvelopeLike]>;
27
+ /**
28
+ * Return the first available item for a handle, or default if EOS.
29
+ *
30
+ * HOLDOUT (anti-slop/no-unknown-returns): the item is an arbitrary workflow
31
+ * value, the same open domain `stream()` and `any()` yield.
32
+ */
19
33
  first(name: string, defaultValue?: unknown): Promise<unknown>;
34
+ /**
35
+ * Static scope (ordered iteration roots, outermost first) for a connected
36
+ * input handle. Returns `[]` if the handle has no static scope (constant /
37
+ * config edge), or if correlation analysis was not run.
38
+ *
39
+ * Used by join nodes (§7) to identify each side's differing iteration root
40
+ * and project to the common parent prefix.
41
+ */
42
+ scopeFor(handle: string): ReadonlyArray<string>;
43
+ /**
44
+ * The node's invocation scope — the largest non-empty input scope under the
45
+ * legacy comparable-prefix rule, or the longest common parent prefix on
46
+ * join nodes (§7). `[]` when analysis is off or the node has no inputs.
47
+ */
48
+ invocationScope(): ReadonlyArray<string>;
49
+ /**
50
+ * True if the handle has at least one open upstream source. Distinguishes
51
+ * patched from unpatched optional streaming inputs (upstream counts are
52
+ * registered before actors start, so this is race-free at the top of
53
+ * `run()`).
54
+ */
55
+ hasStream(name: string): boolean;
56
+ /**
57
+ * True if the handle has items already queued and not yet consumed.
58
+ * Optional: the kernel's `NodeInputs` implements it, hand-rolled test
59
+ * doubles need not. Together with {@link hasStream} it answers "could a
60
+ * take on this handle still produce a value?" — what the Code node's
61
+ * `stream.open(name)` reports to the guest.
62
+ */
63
+ hasBuffered?(name: string): boolean;
64
+ /**
65
+ * Aborted when the run is cancelled. Producers that emit without waiting
66
+ * on inputs (generators, wall-clock pacers) must observe it — inbox
67
+ * closure only unblocks consumers, it does not stop a producing loop.
68
+ */
69
+ readonly signal: AbortSignal;
70
+ }
71
+ /**
72
+ * Minimal MessageEnvelope shape visible to nodes. Mirrors
73
+ * `kernel/inbox.MessageEnvelope` without forcing runtime to import kernel
74
+ * (kernel depends on runtime, not the other way around).
75
+ */
76
+ export interface MessageEnvelopeLike {
77
+ data: unknown;
78
+ metadata: Record<string, unknown>;
79
+ timestamp: number;
80
+ event_id: string;
81
+ correlation_lineage: CorrelationLineage;
82
+ source_edge_id: string;
20
83
  }
21
84
  /**
22
85
  * Write-side interface for streaming output from within a run() method.
23
86
  * Nodes call emit() to push partial results downstream immediately.
87
+ *
88
+ * `forward` copies an envelope's correlation lineage onto the emitted value
89
+ * — essential for stream nodes that act as filters/passthroughs. `drop`
90
+ * sends `lineage_done` for the source key so downstream joins do not wait
91
+ * on a key that was deliberately not emitted. §5.
24
92
  */
25
93
  export interface StreamingOutputs {
26
94
  /** Emit a value to a named output slot. */
27
- emit(slot: string, value: unknown): Promise<void>;
95
+ emit(slot: string, value: unknown, opts?: {
96
+ lineage?: CorrelationLineage;
97
+ }): Promise<void>;
98
+ /**
99
+ * Emit a frame of grouped values atomically. Every sibling handle that
100
+ * shares an iteration group (same root id) receives the **same** minted
101
+ * token, so a Zip pair (`{ left, right, index }`) is one logical item
102
+ * downstream — not three independent items with different tokens. §1.
103
+ *
104
+ * Non-iteration handles in `values` inherit the supplied `opts.lineage`
105
+ * (or the actor's ambient invocation lineage if omitted).
106
+ */
107
+ emitGroup(values: Record<string, unknown>, opts?: {
108
+ lineage?: CorrelationLineage;
109
+ }): Promise<void>;
110
+ /** Forward an envelope's lineage to `slot`. §5. */
111
+ forward(slot: string, envelope: MessageEnvelopeLike, ...overrideValue: [] | [unknown]): Promise<void>;
112
+ /** Send `lineage_done` for `slot` at the envelope's projected key. §5. */
113
+ drop(slot: string, envelope: MessageEnvelopeLike): Promise<void>;
28
114
  /** Signal early end-of-stream for a specific output slot. */
29
115
  complete(slot: string): void;
30
116
  }
117
+ /**
118
+ * A durably stored trigger input delivered into a run. Mirrors
119
+ * `RunJobRequest.trigger_event` and `ProcessingContext.triggerEvent`.
120
+ * `node_id` names the trigger node the event targets; `payload` is the
121
+ * adapter-captured event data; `input_id` is the idempotency key of the
122
+ * `trigger_inputs` row that produced this run.
123
+ */
124
+ export interface TriggerEvent {
125
+ node_id: string;
126
+ payload: unknown;
127
+ input_id: string;
128
+ }
31
129
  export interface NodeExecutor {
32
130
  /** One-shot processing (buffered mode). */
33
131
  process(inputs: Record<string, unknown>, context?: ProcessingContext): Promise<Record<string, unknown>>;
@@ -43,11 +141,24 @@ export interface NodeExecutor {
43
141
  * pushes results via `outputs.emit()`.
44
142
  */
45
143
  run?(inputs: StreamingInputs, outputs: StreamingOutputs, context?: ProcessingContext): Promise<void>;
144
+ /**
145
+ * Apply property updates to a live executor instance. Long-running
146
+ * streaming nodes (synth generators, realtime effects) that read their
147
+ * properties per chunk pick the new values up on the next chunk —
148
+ * the basis for live parameter changes while a patch is running.
149
+ */
150
+ applyProperties?(properties: Record<string, unknown>): void;
46
151
  /** Called before process/genProcess. */
47
152
  preProcess?(): Promise<void>;
48
153
  /** Called after process/genProcess completes. */
49
154
  finalize?(): Promise<void>;
50
155
  /** Called once during graph initialization. */
51
156
  initialize?(): Promise<void>;
157
+ /**
158
+ * Trigger entry point. Called instead of genProcess()/run() when the run
159
+ * carries a `trigger_event` targeting this node: emit the event payload
160
+ * on the declared output slots and return — no live listening.
161
+ */
162
+ emitTriggerEvent?(event: TriggerEvent, outputs: StreamingOutputs): Promise<void>;
52
163
  }
53
164
  //# sourceMappingURL=node-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-executor.d.ts","sourceRoot":"","sources":["../src/node-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMtD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9C,uEAAuE;IACvE,GAAG,IAAI,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,uEAAuE;IACvE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/D;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,E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GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,eAAe,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE5D,wCAAwC;IACxC,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B,iDAAiD;IACjD,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3B,+CAA+C;IAC/C,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;OAIG;IACH,gBAAgB,CAAC,CACf,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * The permission gate contract: the mode, the category, the decision matrix,
3
+ * the approval callback, and the context key a host publishes its gate under.
4
+ *
5
+ * It lives here rather than in `@nodetool-ai/agents` because the hosts that
6
+ * run a workflow (`@nodetool-ai/execution`, the headless job runner) sit
7
+ * below `agents` in the package graph and still have to set a gate on the
8
+ * context they build. The ladder that reads the gate, the classification of
9
+ * tool names, and the loops that gate through it stay in `agents`; this is
10
+ * only what a host needs to say "this run is headless".
11
+ *
12
+ * Design: docs/AGENTS.md § "The permission gate",
13
+ * packages/agents/AGENTS.md § "Where the permission gate is set".
14
+ */
15
+ /**
16
+ * ProcessingContext variable key under which a host publishes the
17
+ * `PermissionGateOptions` every loop under it must gate through.
18
+ *
19
+ * The gate has to reach loops the host never constructs: an `AgentNode` a chat
20
+ * turn started through `run_node`, a JS script, a sub-agent several levels
21
+ * down. The context bag is the one channel all of them already carry, and
22
+ * `ProcessingContext.copy()` shallow-copies it, so a child context shares the
23
+ * host's gate object rather than a clone — which is what makes
24
+ * `set_permission_mode` mid-turn reach a node that started before it
25
+ * (invariant I-1).
26
+ *
27
+ * Read it with `gateFromContext` in `@nodetool-ai/agents`, never directly: a
28
+ * context with no gate on it is a host that forgot to set one, and the answer
29
+ * there is a gate that denies every call past read, not "ungated".
30
+ */
31
+ export declare const PERMISSION_GATE_CONTEXT_KEY = "nodetool_permission_gate";
32
+ /** How risky a tool is, independent of the active mode. */
33
+ export type PermissionCategory = "read" | "write" | "execute" | "external";
34
+ /** The user-selected permission mode for a chat turn. */
35
+ export type PermissionMode = "plan" | "default" | "auto";
36
+ /** What the gate decides to do with a single call before any user prompt. */
37
+ export type PermissionDecision = "allow" | "ask" | "block";
38
+ /** The user's answer to an approval prompt. */
39
+ export type ApprovalDecision = "allow" | "allow_for_chat" | "deny";
40
+ /**
41
+ * The matrix: `read` always runs; in `auto` everything runs; in `plan`
42
+ * anything actionable is blocked; in `default` actionable calls ask.
43
+ */
44
+ export declare function decidePermission(mode: PermissionMode, category: PermissionCategory): PermissionDecision;
45
+ export interface ApprovalRequest {
46
+ toolName: string;
47
+ category: PermissionCategory;
48
+ /** Tool arguments, with the reserved `_message` field stripped. */
49
+ args: Record<string, unknown>;
50
+ /** Resolved user-facing status (LLM `_message` or the tool's template). */
51
+ message: string;
52
+ /**
53
+ * What the call will do, in plain sentences, for the approval dialog to ask
54
+ * about. A high-risk code action supplies one (`execute_code`'s
55
+ * `description`); most calls have none and the dialog shows `message`.
56
+ */
57
+ description?: string;
58
+ }
59
+ export type RequestApproval = (request: ApprovalRequest) => Promise<ApprovalDecision>;
60
+ /**
61
+ * One actionable call, as the security monitor sees it. Structurally the
62
+ * `PendingAction` the monitor in `@nodetool-ai/agents` evaluates; declared
63
+ * here so the gate carries no dependency on the monitor.
64
+ */
65
+ export interface PermissionGateAction {
66
+ /** Tool name about to run. */
67
+ name: string;
68
+ /** Permission category of the tool. */
69
+ category: PermissionCategory;
70
+ /** Tool arguments (with the reserved `_message` field already stripped). */
71
+ args: Record<string, unknown>;
72
+ /** Recent transcript text, used to evaluate user-intent clearing of SOFT blocks. */
73
+ transcript?: string;
74
+ }
75
+ /**
76
+ * What the monitor answers. The ladder reads `block`, `reason`, and the two
77
+ * labels it prints; the monitor's own narrower unions satisfy this shape.
78
+ */
79
+ export interface PermissionGateVerdict {
80
+ block: boolean;
81
+ reason: string;
82
+ severity: string;
83
+ tier: string;
84
+ }
85
+ /**
86
+ * A guest clock the gate can stop while a prompt is open. Structurally the
87
+ * sandbox's `SandboxClock`; declared here so the gate carries no dependency
88
+ * on the sandbox.
89
+ */
90
+ export interface PermissionGateClock {
91
+ /** Stop the guest's budget until the returned function is called. */
92
+ suspend(): () => void;
93
+ /** Milliseconds suspended so far, including a suspension still open. */
94
+ suspendedMs(): number;
95
+ }
96
+ export interface PermissionGateOptions {
97
+ mode: PermissionMode;
98
+ /**
99
+ * Tool names the user has approved for the rest of the chat. Shared (by
100
+ * reference) across a thread so "Allow for this chat" sticks between turns.
101
+ */
102
+ sessionAllow: Set<string>;
103
+ /** Round-trips an approval prompt to the UI and resolves with the answer. */
104
+ requestApproval: RequestApproval;
105
+ /**
106
+ * Opt-in LLM-judge consult. When set, every actionable (non-read) tool call
107
+ * that the mode/approval logic would otherwise run is first vetted by the
108
+ * monitor; a `block` verdict stops execution with a structured error. This
109
+ * is a plain callback (NOT the monitor class) so the gate carries no
110
+ * provider/LLM dependency. Default undefined → the gate behaves exactly as
111
+ * before, byte-for-byte. Read-class tools are NEVER consulted, even when set.
112
+ */
113
+ securityMonitor?: (action: PermissionGateAction) => Promise<PermissionGateVerdict>;
114
+ /**
115
+ * The sandbox clock a code action runs on, when the call comes from one. The
116
+ * gate stops it for the length of an approval prompt or a monitor consult:
117
+ * that wait is the user's (or another model's), not the guest program's, and
118
+ * charging it to the action's wall clock kills the program that asked.
119
+ */
120
+ clock?: PermissionGateClock;
121
+ /**
122
+ * Optional accessor for the recent transcript text, forwarded into the
123
+ * monitor's {@link PermissionGateAction.transcript} so SOFT-block
124
+ * user-intent clearing has evidence to reason over. Defaults to undefined →
125
+ * empty transcript. Only invoked when {@link securityMonitor} is set.
126
+ */
127
+ recentTranscript?: () => string;
128
+ }
129
+ /**
130
+ * Why a headless host refuses an escalation, in one sentence naming it.
131
+ *
132
+ * Exported because two callers need the same words: the gate reports it when
133
+ * it denies, and a host that runs headless on purpose (the CLI behind a pipe)
134
+ * prints it once up front so the user is not left guessing why a later call
135
+ * was refused.
136
+ */
137
+ export declare function headlessDenialReason(hostName: string): string;
138
+ /**
139
+ * The gate for a host with nobody to ask: `auto`, denying every escalation.
140
+ *
141
+ * `decidePermission` allows read, write, execute and external outright in
142
+ * `auto`, so this approver is reached only by a request the ladder itself
143
+ * raises — a security-monitor consult, or a category that starts asking in
144
+ * `auto` later. Denying is the only answer a host with no user can give
145
+ * honestly: resolving `"allow"` would grant exactly what the escalation was
146
+ * raised to withhold, and never resolving would hang the run (invariant I-4).
147
+ *
148
+ * `hostName` names the caller so the refusal says which host had no one to
149
+ * ask, rather than only that something was refused.
150
+ */
151
+ export declare function headlessGate(hostName: string): PermissionGateOptions;
152
+ //# sourceMappingURL=permission-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-gate.d.ts","sourceRoot":"","sources":["../src/permission-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AAEtE,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzD,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAE3D,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,kBAAkB,GAC3B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OAKG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,MAAM,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAapE"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The permission gate contract: the mode, the category, the decision matrix,
3
+ * the approval callback, and the context key a host publishes its gate under.
4
+ *
5
+ * It lives here rather than in `@nodetool-ai/agents` because the hosts that
6
+ * run a workflow (`@nodetool-ai/execution`, the headless job runner) sit
7
+ * below `agents` in the package graph and still have to set a gate on the
8
+ * context they build. The ladder that reads the gate, the classification of
9
+ * tool names, and the loops that gate through it stay in `agents`; this is
10
+ * only what a host needs to say "this run is headless".
11
+ *
12
+ * Design: docs/AGENTS.md § "The permission gate",
13
+ * packages/agents/AGENTS.md § "Where the permission gate is set".
14
+ */
15
+ /**
16
+ * ProcessingContext variable key under which a host publishes the
17
+ * `PermissionGateOptions` every loop under it must gate through.
18
+ *
19
+ * The gate has to reach loops the host never constructs: an `AgentNode` a chat
20
+ * turn started through `run_node`, a JS script, a sub-agent several levels
21
+ * down. The context bag is the one channel all of them already carry, and
22
+ * `ProcessingContext.copy()` shallow-copies it, so a child context shares the
23
+ * host's gate object rather than a clone — which is what makes
24
+ * `set_permission_mode` mid-turn reach a node that started before it
25
+ * (invariant I-1).
26
+ *
27
+ * Read it with `gateFromContext` in `@nodetool-ai/agents`, never directly: a
28
+ * context with no gate on it is a host that forgot to set one, and the answer
29
+ * there is a gate that denies every call past read, not "ungated".
30
+ */
31
+ export const PERMISSION_GATE_CONTEXT_KEY = "nodetool_permission_gate";
32
+ /**
33
+ * The matrix: `read` always runs; in `auto` everything runs; in `plan`
34
+ * anything actionable is blocked; in `default` actionable calls ask.
35
+ */
36
+ export function decidePermission(mode, category) {
37
+ if (category === "read") {
38
+ return "allow";
39
+ }
40
+ if (mode === "auto") {
41
+ return "allow";
42
+ }
43
+ if (mode === "plan") {
44
+ return "block";
45
+ }
46
+ return "ask";
47
+ }
48
+ /**
49
+ * Why a headless host refuses an escalation, in one sentence naming it.
50
+ *
51
+ * Exported because two callers need the same words: the gate reports it when
52
+ * it denies, and a host that runs headless on purpose (the CLI behind a pipe)
53
+ * prints it once up front so the user is not left guessing why a later call
54
+ * was refused.
55
+ */
56
+ export function headlessDenialReason(hostName) {
57
+ return (`${hostName} runs without a user to ask, so calls the permission ladder ` +
58
+ `escalates are denied.`);
59
+ }
60
+ /**
61
+ * The gate for a host with nobody to ask: `auto`, denying every escalation.
62
+ *
63
+ * `decidePermission` allows read, write, execute and external outright in
64
+ * `auto`, so this approver is reached only by a request the ladder itself
65
+ * raises — a security-monitor consult, or a category that starts asking in
66
+ * `auto` later. Denying is the only answer a host with no user can give
67
+ * honestly: resolving `"allow"` would grant exactly what the escalation was
68
+ * raised to withhold, and never resolving would hang the run (invariant I-4).
69
+ *
70
+ * `hostName` names the caller so the refusal says which host had no one to
71
+ * ask, rather than only that something was refused.
72
+ */
73
+ export function headlessGate(hostName) {
74
+ const reason = headlessDenialReason(hostName);
75
+ const headlessDeny = async (request) => {
76
+ // Loud on the refusal (I-4): a denial nobody can see reads as a tool that
77
+ // silently did nothing.
78
+ console.warn(`Denied \`${request.toolName}\` without asking: ${reason}`);
79
+ return "deny";
80
+ };
81
+ return {
82
+ mode: "auto",
83
+ sessionAllow: new Set(),
84
+ requestApproval: headlessDeny
85
+ };
86
+ }
87
+ //# sourceMappingURL=permission-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-gate.js","sourceRoot":"","sources":["../src/permission-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AActE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAoB,EACpB,QAA4B;IAE5B,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAgGD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO,CACL,GAAG,QAAQ,8DAA8D;QACzE,uBAAuB,CACxB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAoB,KAAK,EAAE,OAAO,EAAE,EAAE;QACtD,0EAA0E;QAC1E,wBAAwB;QACxB,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,QAAQ,sBAAsB,MAAM,EAAE,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,IAAI,GAAG,EAAU;QAC/B,eAAe,EAAE,YAAY;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type StorageAdapter, type StorageListResult, type StorageStat } from "./context.js";
2
+ /**
3
+ * A `StorageAdapter` that carves a key prefix out of another one.
4
+ *
5
+ * Cloud deployments keep one bucket. Giving each user a workspace inside it
6
+ * means their keys have to be namespaced, and the namespacing has to be
7
+ * invisible to whatever holds the adapter — a caller that stores `notes.md`
8
+ * must read it back as `notes.md`, not as `workspaces/u1/notes.md`. Every key
9
+ * going in gains the prefix and every key coming out loses it again.
10
+ *
11
+ * The prefix is applied to *keys*, never to URIs: a URI is opaque and already
12
+ * carries the full key, so it passes through untouched.
13
+ */
14
+ export declare class PrefixedStorageAdapter implements StorageAdapter {
15
+ private readonly inner;
16
+ /** Normalized prefix with no trailing slash. */
17
+ readonly prefix: string;
18
+ constructor(inner: StorageAdapter, prefix: string);
19
+ private scope;
20
+ /** Strip the prefix from a key the inner adapter reported. */
21
+ private unscope;
22
+ store(key: string, data: Uint8Array, contentType?: string): Promise<string>;
23
+ retrieve(uri: string): Promise<Uint8Array | null>;
24
+ exists(uri: string): Promise<boolean>;
25
+ uriForKey(key: string): string;
26
+ list(prefix: string, opts?: {
27
+ delimiter?: string;
28
+ }): Promise<StorageListResult>;
29
+ delete(uri: string): Promise<boolean>;
30
+ stat(uri: string): Promise<StorageStat | null>;
31
+ localPath(uri: string): Promise<string | null>;
32
+ }
33
+ //# sourceMappingURL=prefixed-storage-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefixed-storage-adapter.d.ts","sourceRoot":"","sources":["../src/prefixed-storage-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,YAAW,cAAc;IAKzD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YACmB,KAAK,EAAE,cAAc,EACtC,MAAM,EAAE,MAAM,EAGf;IAED,OAAO,CAAC,KAAK;IAIb,8DAA8D;IAC9D,OAAO,CAAC,OAAO;IAKf,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1E;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAEhD;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpC;IAED,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7B;IAEK,IAAI,CACR,MAAM,EAAE,MAAM,EACd,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAe5B;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpC;IAEK,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAKnD;IAED,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE7C;CACF"}