@5ss/ai-tools 2.11.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 (342) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +21 -0
  3. package/README.md +221 -0
  4. package/dist/ai-sdk/index.d.ts +15 -0
  5. package/dist/ai-sdk/index.d.ts.map +1 -0
  6. package/dist/ai-sdk/index.js +24 -0
  7. package/dist/ai-sdk/index.js.map +1 -0
  8. package/dist/artifact-D064mHfK.js +44 -0
  9. package/dist/artifact-D064mHfK.js.map +1 -0
  10. package/dist/artifacts-O8g-40Pw.js +404 -0
  11. package/dist/artifacts-O8g-40Pw.js.map +1 -0
  12. package/dist/aws-json-CecFqzqX.js +23 -0
  13. package/dist/aws-json-CecFqzqX.js.map +1 -0
  14. package/dist/aws-service-msttbPrz.js +58 -0
  15. package/dist/aws-service-msttbPrz.js.map +1 -0
  16. package/dist/batch-BMM5dXqL.d.ts +22 -0
  17. package/dist/batch-BMM5dXqL.d.ts.map +1 -0
  18. package/dist/batch-Co1ujeAW.js +67 -0
  19. package/dist/batch-Co1ujeAW.js.map +1 -0
  20. package/dist/bedrock-agentcore-browser-a_qOs-NR.js +182 -0
  21. package/dist/bedrock-agentcore-browser-a_qOs-NR.js.map +1 -0
  22. package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js +357 -0
  23. package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js.map +1 -0
  24. package/dist/bytes-BxpimpQx.js +45 -0
  25. package/dist/bytes-BxpimpQx.js.map +1 -0
  26. package/dist/client-CCKGsTeI.js +743 -0
  27. package/dist/client-CCKGsTeI.js.map +1 -0
  28. package/dist/cloudflare/index.d.ts +37 -0
  29. package/dist/cloudflare/index.d.ts.map +1 -0
  30. package/dist/cloudflare/index.js +41 -0
  31. package/dist/cloudflare/index.js.map +1 -0
  32. package/dist/cloudflare-browser-B6Yolpin.js +428 -0
  33. package/dist/cloudflare-browser-B6Yolpin.js.map +1 -0
  34. package/dist/cloudflare-email-Dy0KHeDf.js +197 -0
  35. package/dist/cloudflare-email-Dy0KHeDf.js.map +1 -0
  36. package/dist/cloudflare-sandbox-Dp_uNaqW.js +982 -0
  37. package/dist/cloudflare-sandbox-Dp_uNaqW.js.map +1 -0
  38. package/dist/content-type-CORxaxcv.js +49 -0
  39. package/dist/content-type-CORxaxcv.js.map +1 -0
  40. package/dist/core/index.d.ts +4 -0
  41. package/dist/core/index.js +204 -0
  42. package/dist/core/index.js.map +1 -0
  43. package/dist/define-CvpJ_pNP.js +115 -0
  44. package/dist/define-CvpJ_pNP.js.map +1 -0
  45. package/dist/errors-DoSpNHvs.js +20 -0
  46. package/dist/errors-DoSpNHvs.js.map +1 -0
  47. package/dist/errors-aKhko9T1.d.ts +18 -0
  48. package/dist/errors-aKhko9T1.d.ts.map +1 -0
  49. package/dist/eventbridge-scheduler-Bh6GqZY2.js +349 -0
  50. package/dist/eventbridge-scheduler-Bh6GqZY2.js.map +1 -0
  51. package/dist/framework-context-DVIIY8ZO.js +24 -0
  52. package/dist/framework-context-DVIIY8ZO.js.map +1 -0
  53. package/dist/gotenberg-NuJjxyln.js +291 -0
  54. package/dist/gotenberg-NuJjxyln.js.map +1 -0
  55. package/dist/http/index.d.ts +47 -0
  56. package/dist/http/index.d.ts.map +1 -0
  57. package/dist/http/index.js +3 -0
  58. package/dist/http-service-DDNCO1s4.js +254 -0
  59. package/dist/http-service-DDNCO1s4.js.map +1 -0
  60. package/dist/http-service-T7E5UjP8.d.ts +80 -0
  61. package/dist/http-service-T7E5UjP8.d.ts.map +1 -0
  62. package/dist/imessage-BSAFOI8Z.js +154 -0
  63. package/dist/imessage-BSAFOI8Z.js.map +1 -0
  64. package/dist/index-BU4gmYO8.d.ts +254 -0
  65. package/dist/index-BU4gmYO8.d.ts.map +1 -0
  66. package/dist/index-CCivzmxO.d.ts +188 -0
  67. package/dist/index-CCivzmxO.d.ts.map +1 -0
  68. package/dist/index-CLmTrcu5.d.ts +22 -0
  69. package/dist/index-CLmTrcu5.d.ts.map +1 -0
  70. package/dist/index-CZX5OeOF.d.ts +235 -0
  71. package/dist/index-CZX5OeOF.d.ts.map +1 -0
  72. package/dist/index-CdFmEfZO.d.ts +359 -0
  73. package/dist/index-CdFmEfZO.d.ts.map +1 -0
  74. package/dist/index-Cuh6eMWc.d.ts +285 -0
  75. package/dist/index-Cuh6eMWc.d.ts.map +1 -0
  76. package/dist/index-DuOGj7vc.d.ts +107 -0
  77. package/dist/index-DuOGj7vc.d.ts.map +1 -0
  78. package/dist/index-ccZ1XOHw.d.ts +69 -0
  79. package/dist/index-ccZ1XOHw.d.ts.map +1 -0
  80. package/dist/index-n8JTpNf1.d.ts +247 -0
  81. package/dist/index-n8JTpNf1.d.ts.map +1 -0
  82. package/dist/index-pwW1OsOx.d.ts +134 -0
  83. package/dist/index-pwW1OsOx.d.ts.map +1 -0
  84. package/dist/index-zK1ZwS4m.d.ts +347 -0
  85. package/dist/index-zK1ZwS4m.d.ts.map +1 -0
  86. package/dist/limits-hjrO8zUG.js +80 -0
  87. package/dist/limits-hjrO8zUG.js.map +1 -0
  88. package/dist/mastra/index.d.ts +14 -0
  89. package/dist/mastra/index.d.ts.map +1 -0
  90. package/dist/mastra/index.js +26 -0
  91. package/dist/mastra/index.js.map +1 -0
  92. package/dist/mastra-vector-Dhc6XZ8l.js +234 -0
  93. package/dist/mastra-vector-Dhc6XZ8l.js.map +1 -0
  94. package/dist/mcp/index.d.ts +80 -0
  95. package/dist/mcp/index.d.ts.map +1 -0
  96. package/dist/mcp/index.js +97 -0
  97. package/dist/mcp/index.js.map +1 -0
  98. package/dist/modules/artifacts/index.d.ts +337 -0
  99. package/dist/modules/artifacts/index.d.ts.map +1 -0
  100. package/dist/modules/artifacts/index.js +348 -0
  101. package/dist/modules/artifacts/index.js.map +1 -0
  102. package/dist/modules/browser/index.d.ts +516 -0
  103. package/dist/modules/browser/index.d.ts.map +1 -0
  104. package/dist/modules/browser/index.js +475 -0
  105. package/dist/modules/browser/index.js.map +1 -0
  106. package/dist/modules/calendar/index.d.ts +93 -0
  107. package/dist/modules/calendar/index.d.ts.map +1 -0
  108. package/dist/modules/calendar/index.js +131 -0
  109. package/dist/modules/calendar/index.js.map +1 -0
  110. package/dist/modules/code-sandbox/index.d.ts +317 -0
  111. package/dist/modules/code-sandbox/index.d.ts.map +1 -0
  112. package/dist/modules/code-sandbox/index.js +537 -0
  113. package/dist/modules/code-sandbox/index.js.map +1 -0
  114. package/dist/modules/content-type/index.d.ts +22 -0
  115. package/dist/modules/content-type/index.d.ts.map +1 -0
  116. package/dist/modules/content-type/index.js +66 -0
  117. package/dist/modules/content-type/index.js.map +1 -0
  118. package/dist/modules/crypto/index.d.ts +115 -0
  119. package/dist/modules/crypto/index.d.ts.map +1 -0
  120. package/dist/modules/crypto/index.js +139 -0
  121. package/dist/modules/crypto/index.js.map +1 -0
  122. package/dist/modules/document/index.d.ts +575 -0
  123. package/dist/modules/document/index.d.ts.map +1 -0
  124. package/dist/modules/document/index.js +444 -0
  125. package/dist/modules/document/index.js.map +1 -0
  126. package/dist/modules/document-extract/index.d.ts +438 -0
  127. package/dist/modules/document-extract/index.d.ts.map +1 -0
  128. package/dist/modules/document-extract/index.js +127 -0
  129. package/dist/modules/document-extract/index.js.map +1 -0
  130. package/dist/modules/document-render/index.d.ts +336 -0
  131. package/dist/modules/document-render/index.d.ts.map +1 -0
  132. package/dist/modules/document-render/index.js +155 -0
  133. package/dist/modules/document-render/index.js.map +1 -0
  134. package/dist/modules/email/index.d.ts +311 -0
  135. package/dist/modules/email/index.d.ts.map +1 -0
  136. package/dist/modules/email/index.js +167 -0
  137. package/dist/modules/email/index.js.map +1 -0
  138. package/dist/modules/email-message/index.d.ts +95 -0
  139. package/dist/modules/email-message/index.d.ts.map +1 -0
  140. package/dist/modules/email-message/index.js +264 -0
  141. package/dist/modules/email-message/index.js.map +1 -0
  142. package/dist/modules/file-convert/index.d.ts +273 -0
  143. package/dist/modules/file-convert/index.d.ts.map +1 -0
  144. package/dist/modules/file-convert/index.js +103 -0
  145. package/dist/modules/file-convert/index.js.map +1 -0
  146. package/dist/modules/files/index.d.ts +452 -0
  147. package/dist/modules/files/index.d.ts.map +1 -0
  148. package/dist/modules/files/index.js +733 -0
  149. package/dist/modules/files/index.js.map +1 -0
  150. package/dist/modules/image/index.d.ts +342 -0
  151. package/dist/modules/image/index.d.ts.map +1 -0
  152. package/dist/modules/image/index.js +281 -0
  153. package/dist/modules/image/index.js.map +1 -0
  154. package/dist/modules/messaging/index.d.ts +608 -0
  155. package/dist/modules/messaging/index.d.ts.map +1 -0
  156. package/dist/modules/messaging/index.js +1067 -0
  157. package/dist/modules/messaging/index.js.map +1 -0
  158. package/dist/modules/pdf/index.d.ts +287 -0
  159. package/dist/modules/pdf/index.d.ts.map +1 -0
  160. package/dist/modules/pdf/index.js +259 -0
  161. package/dist/modules/pdf/index.js.map +1 -0
  162. package/dist/modules/presentation/index.d.ts +247 -0
  163. package/dist/modules/presentation/index.d.ts.map +1 -0
  164. package/dist/modules/presentation/index.js +12657 -0
  165. package/dist/modules/presentation/index.js.map +1 -0
  166. package/dist/modules/queue/index.d.ts +129 -0
  167. package/dist/modules/queue/index.d.ts.map +1 -0
  168. package/dist/modules/queue/index.js +131 -0
  169. package/dist/modules/queue/index.js.map +1 -0
  170. package/dist/modules/rag/index.d.ts +250 -0
  171. package/dist/modules/rag/index.d.ts.map +1 -0
  172. package/dist/modules/rag/index.js +366 -0
  173. package/dist/modules/rag/index.js.map +1 -0
  174. package/dist/modules/scheduler/index.d.ts +216 -0
  175. package/dist/modules/scheduler/index.d.ts.map +1 -0
  176. package/dist/modules/scheduler/index.js +153 -0
  177. package/dist/modules/scheduler/index.js.map +1 -0
  178. package/dist/modules/skills/index.d.ts +205 -0
  179. package/dist/modules/skills/index.d.ts.map +1 -0
  180. package/dist/modules/skills/index.js +203 -0
  181. package/dist/modules/skills/index.js.map +1 -0
  182. package/dist/modules/tasks/index.d.ts +287 -0
  183. package/dist/modules/tasks/index.d.ts.map +1 -0
  184. package/dist/modules/tasks/index.js +207 -0
  185. package/dist/modules/tasks/index.js.map +1 -0
  186. package/dist/modules/vector-store/index.d.ts +3 -0
  187. package/dist/modules/vector-store/index.js +3 -0
  188. package/dist/modules/web-fetch/index.d.ts +99 -0
  189. package/dist/modules/web-fetch/index.d.ts.map +1 -0
  190. package/dist/modules/web-fetch/index.js +242 -0
  191. package/dist/modules/web-fetch/index.js.map +1 -0
  192. package/dist/object-artifact-store-CMTzCm_G.d.ts +7 -0
  193. package/dist/object-artifact-store-CMTzCm_G.d.ts.map +1 -0
  194. package/dist/object-artifact-store-wZ2j9cto.js +28 -0
  195. package/dist/object-artifact-store-wZ2j9cto.js.map +1 -0
  196. package/dist/pinecone-umY4t6OF.js +190 -0
  197. package/dist/pinecone-umY4t6OF.js.map +1 -0
  198. package/dist/provider-CgDAlg6K.js +34 -0
  199. package/dist/provider-CgDAlg6K.js.map +1 -0
  200. package/dist/qdrant-DMp4NhKR.js +253 -0
  201. package/dist/qdrant-DMp4NhKR.js.map +1 -0
  202. package/dist/resend-BAC38_dA.js +155 -0
  203. package/dist/resend-BAC38_dA.js.map +1 -0
  204. package/dist/s3-CsOaPWMP.js +955 -0
  205. package/dist/s3-CsOaPWMP.js.map +1 -0
  206. package/dist/schemas-ChOAhdo9.js +192 -0
  207. package/dist/schemas-ChOAhdo9.js.map +1 -0
  208. package/dist/slack-Di5BBNpt.js +1455 -0
  209. package/dist/slack-Di5BBNpt.js.map +1 -0
  210. package/dist/sqs-DCwS1i2N.js +225 -0
  211. package/dist/sqs-DCwS1i2N.js.map +1 -0
  212. package/dist/supabase-vector-Dpp9mmJR.js +218 -0
  213. package/dist/supabase-vector-Dpp9mmJR.js.map +1 -0
  214. package/dist/tanstack/index.d.ts +15 -0
  215. package/dist/tanstack/index.d.ts.map +1 -0
  216. package/dist/tanstack/index.js +28 -0
  217. package/dist/tanstack/index.js.map +1 -0
  218. package/dist/teams-DYAHNb39.js +835 -0
  219. package/dist/teams-DYAHNb39.js.map +1 -0
  220. package/dist/telegram-DDXWzkfL.js +734 -0
  221. package/dist/telegram-DDXWzkfL.js.map +1 -0
  222. package/dist/textract-CPLiB22H.js +554 -0
  223. package/dist/textract-CPLiB22H.js.map +1 -0
  224. package/dist/transport-B4vn-XiQ.js +157 -0
  225. package/dist/transport-B4vn-XiQ.js.map +1 -0
  226. package/dist/transport-i96ACAI_.d.ts +46 -0
  227. package/dist/transport-i96ACAI_.d.ts.map +1 -0
  228. package/dist/types-Ccb0DXY9.d.ts +150 -0
  229. package/dist/types-Ccb0DXY9.d.ts.map +1 -0
  230. package/dist/unique-EwBH1JPB.js +19 -0
  231. package/dist/unique-EwBH1JPB.js.map +1 -0
  232. package/dist/vector-store-C3nEO80e.js +193 -0
  233. package/dist/vector-store-C3nEO80e.js.map +1 -0
  234. package/dist/vendors/amazon-sp-api/index.d.ts +526 -0
  235. package/dist/vendors/amazon-sp-api/index.d.ts.map +1 -0
  236. package/dist/vendors/amazon-sp-api/index.js +975 -0
  237. package/dist/vendors/amazon-sp-api/index.js.map +1 -0
  238. package/dist/vendors/bedrock-agentcore-browser/index.d.ts +2 -0
  239. package/dist/vendors/bedrock-agentcore-browser/index.js +2 -0
  240. package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts +228 -0
  241. package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts.map +1 -0
  242. package/dist/vendors/bedrock-agentcore-code-interpreter/index.js +2 -0
  243. package/dist/vendors/cloudflare-browser/index.d.ts +2 -0
  244. package/dist/vendors/cloudflare-browser/index.js +2 -0
  245. package/dist/vendors/cloudflare-email/index.d.ts +260 -0
  246. package/dist/vendors/cloudflare-email/index.d.ts.map +1 -0
  247. package/dist/vendors/cloudflare-email/index.js +3 -0
  248. package/dist/vendors/cloudflare-sandbox/index.d.ts +565 -0
  249. package/dist/vendors/cloudflare-sandbox/index.d.ts.map +1 -0
  250. package/dist/vendors/cloudflare-sandbox/index.js +2 -0
  251. package/dist/vendors/eventbridge-scheduler/index.d.ts +2 -0
  252. package/dist/vendors/eventbridge-scheduler/index.js +2 -0
  253. package/dist/vendors/gotenberg/index.d.ts +306 -0
  254. package/dist/vendors/gotenberg/index.d.ts.map +1 -0
  255. package/dist/vendors/gotenberg/index.js +2 -0
  256. package/dist/vendors/imessage/index.d.ts +420 -0
  257. package/dist/vendors/imessage/index.d.ts.map +1 -0
  258. package/dist/vendors/imessage/index.js +4 -0
  259. package/dist/vendors/katana/index.d.ts +1570 -0
  260. package/dist/vendors/katana/index.d.ts.map +1 -0
  261. package/dist/vendors/katana/index.js +1639 -0
  262. package/dist/vendors/katana/index.js.map +1 -0
  263. package/dist/vendors/mastra-vector/index.d.ts +120 -0
  264. package/dist/vendors/mastra-vector/index.d.ts.map +1 -0
  265. package/dist/vendors/mastra-vector/index.js +3 -0
  266. package/dist/vendors/pinecone/index.d.ts +75 -0
  267. package/dist/vendors/pinecone/index.d.ts.map +1 -0
  268. package/dist/vendors/pinecone/index.js +3 -0
  269. package/dist/vendors/qdrant/index.d.ts +75 -0
  270. package/dist/vendors/qdrant/index.d.ts.map +1 -0
  271. package/dist/vendors/qdrant/index.js +3 -0
  272. package/dist/vendors/resend/index.d.ts +3 -0
  273. package/dist/vendors/resend/index.js +3 -0
  274. package/dist/vendors/s3/index.d.ts +2 -0
  275. package/dist/vendors/s3/index.js +2 -0
  276. package/dist/vendors/slack/index.d.ts +576 -0
  277. package/dist/vendors/slack/index.d.ts.map +1 -0
  278. package/dist/vendors/slack/index.js +3 -0
  279. package/dist/vendors/sqs/index.d.ts +2 -0
  280. package/dist/vendors/sqs/index.js +2 -0
  281. package/dist/vendors/supabase-vector/index.d.ts +89 -0
  282. package/dist/vendors/supabase-vector/index.d.ts.map +1 -0
  283. package/dist/vendors/supabase-vector/index.js +3 -0
  284. package/dist/vendors/teams/index.d.ts +303 -0
  285. package/dist/vendors/teams/index.d.ts.map +1 -0
  286. package/dist/vendors/teams/index.js +3 -0
  287. package/dist/vendors/telegram/index.d.ts +319 -0
  288. package/dist/vendors/telegram/index.d.ts.map +1 -0
  289. package/dist/vendors/telegram/index.js +3 -0
  290. package/dist/vendors/textract/index.d.ts +2 -0
  291. package/dist/vendors/textract/index.js +2 -0
  292. package/dist/vendors/woocommerce/index.d.ts +1700 -0
  293. package/dist/vendors/woocommerce/index.d.ts.map +1 -0
  294. package/dist/vendors/woocommerce/index.js +1427 -0
  295. package/dist/vendors/woocommerce/index.js.map +1 -0
  296. package/dist/with-auth-CpKqTrGK.js +240 -0
  297. package/dist/with-auth-CpKqTrGK.js.map +1 -0
  298. package/logos/LUCIDE-ATTRIBUTION.txt +4 -0
  299. package/logos/README.md +89 -0
  300. package/logos/amazon.svg +6 -0
  301. package/logos/artifacts.svg +9 -0
  302. package/logos/browser.svg +9 -0
  303. package/logos/calendar.svg +15 -0
  304. package/logos/cloudflare-browser.svg +5 -0
  305. package/logos/cloudflare-email.svg +5 -0
  306. package/logos/cloudflare.svg +4 -0
  307. package/logos/code-sandbox.svg +8 -0
  308. package/logos/content-type.svg +10 -0
  309. package/logos/crypto.svg +7 -0
  310. package/logos/document-extract.svg +12 -0
  311. package/logos/document-render.svg +8 -0
  312. package/logos/document.svg +10 -0
  313. package/logos/email-message.svg +8 -0
  314. package/logos/email.svg +7 -0
  315. package/logos/file-convert.svg +9 -0
  316. package/logos/files.svg +6 -0
  317. package/logos/gotenberg.svg +340 -0
  318. package/logos/image.svg +8 -0
  319. package/logos/imessage.svg +7 -0
  320. package/logos/katana.svg +13 -0
  321. package/logos/mastra.svg +7 -0
  322. package/logos/messaging.svg +7 -0
  323. package/logos/pack-logos.json +48 -0
  324. package/logos/pdf.svg +10 -0
  325. package/logos/pinecone.svg +25 -0
  326. package/logos/presentation.svg +8 -0
  327. package/logos/qdrant.svg +4 -0
  328. package/logos/queue.svg +11 -0
  329. package/logos/rag.svg +18 -0
  330. package/logos/resend.svg +5 -0
  331. package/logos/scheduler.svg +7 -0
  332. package/logos/skills.svg +10 -0
  333. package/logos/slack.svg +14 -0
  334. package/logos/supabase.svg +4 -0
  335. package/logos/tasks.svg +10 -0
  336. package/logos/teams.svg +6 -0
  337. package/logos/telegram.svg +10 -0
  338. package/logos/textract.svg +5 -0
  339. package/logos/vector-store.svg +8 -0
  340. package/logos/web-fetch.svg +8 -0
  341. package/logos/woocommerce.svg +4 -0
  342. package/package.json +373 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudflare-sandbox-Dp_uNaqW.js","names":["#http","#storage","#storageAuth","#putFileBytes","#getFileBytes","#requireStorage"],"sources":["../src/vendors/cloudflare-sandbox/contracts.ts","../src/vendors/cloudflare-sandbox/domain.ts","../src/vendors/cloudflare-sandbox/client.ts","../src/vendors/cloudflare-sandbox/module.ts"],"sourcesContent":["/**\n * Cloudflare Sandbox Bridge HTTP API contracts.\n * Host deploys the bridge Worker; this pack is a Bearer client.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { z } from 'zod'\n\nimport { s3AuthSchema } from '../s3/contracts'\n\nexport const MAX_ARGV = 64\nexport const MAX_ARG_CHARS = 100_000\nexport const MAX_FILE_PATH = 1024\nexport const MAX_FILE_TEXT = 2_000_000\n/** Bridge hard cap is 32 MiB; package tool path uses the same bound. */\nexport const MAX_FILE_BYTES = 32 * 1024 * 1024\nexport const MAX_WRITE_FILES = 20\nexport const MAX_READ_PATHS = 50\nexport const MAX_LIST_FILES = 500\nexport const DEFAULT_EXEC_TIMEOUT_MS = 30_000\nexport const MAX_EXEC_TIMEOUT_MS = 600_000\n\nexport const cloudflareSandboxAuthSchema = z.object({\n\tbase_url: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('Sandbox bridge Worker origin, for example https://sandbox-bridge.example.workers.dev'),\n\tapi_key: z.string().min(1).describe('Bridge SANDBOX_API_KEY Bearer token'),\n\tstorage: s3AuthSchema\n\t\t.optional()\n\t\t.describe('Optional S3-compatible storage for importArtifact / exportArtifact (ArtifactRef)')\n})\n\nexport type CloudflareSandboxAuth = z.infer<typeof cloudflareSandboxAuthSchema>\n\n/** Object-store ArtifactRef for sandbox import/export. */\nexport const sandboxObjectArtifactRefSchema = z.object({\n\tstore: z.literal('object').describe('Object store containing the artifact'),\n\tkey: z.string().min(1).describe('Object key'),\n\tmedia_type: z.string().min(1).optional().describe('MIME or format hint when known'),\n\tfilename: z.string().min(1).optional().describe('Original or display file name'),\n\tbyte_length: z.int().min(0).optional().describe('Size in bytes when known')\n})\n\nexport type SandboxObjectArtifactRef = z.infer<typeof sandboxObjectArtifactRefSchema>\n\nconst sandboxId = z.string().min(1).max(200).describe('Sandbox id returned by create')\n\nexport const sandboxIdInputSchema = z.object({\n\tsandbox_id: sandboxId\n})\n\nexport const createSandboxOutputSchema = z.object({\n\tsandbox_id: z.string().describe('Created sandbox id')\n})\n\nexport const destroySandboxOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tdestroyed: z.literal(true)\n})\n\nexport const runningOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\trunning: z.boolean().describe('Whether the container is live')\n})\n\nexport const healthOutputSchema = z.object({\n\tok: z.boolean()\n})\n\nexport const execInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\targv: z\n\t\t.array(z.string().min(1).max(MAX_ARG_CHARS))\n\t\t.min(1)\n\t\t.max(MAX_ARGV)\n\t\t.describe('Command argv array (not a shell string). Example: [\"python3\",\"-c\",\"print(1)\"]'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tcwd: z.string().min(1).max(MAX_FILE_PATH).optional().describe('Working directory (default /workspace)'),\n\tsession_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional bridge session id for isolated working directory and runtime state'),\n\tenv: z\n\t\t.record(z.string().min(1).max(128), z.string().max(8_192))\n\t\t.optional()\n\t\t.describe('Optional environment variables for the process when the bridge supports env')\n})\n\nexport const execOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tstdout: z.string().describe('Decoded standard output'),\n\tstderr: z.string().describe('Decoded standard error'),\n\texit_code: z.number().int().optional().describe('Process exit code when the stream ends with exit'),\n\tsuccess: z.boolean().describe('True when exit_code is 0'),\n\terror: z.string().optional().describe('Bridge error message when the stream ends with error'),\n\terror_code: z.string().optional().describe('Bridge error code when present')\n})\n\nconst filePathField = z\n\t.string()\n\t.min(1)\n\t.max(MAX_FILE_PATH)\n\t.describe('Path under workspace (with or without /workspace/ prefix)')\n\nconst sessionIdField = z.string().min(1).max(200).optional().describe('Optional Session-Id header')\n\nconst writeFileBodyFields = {\n\ttext: z.string().max(MAX_FILE_TEXT).optional().describe('Utf-8 file contents (omit when body_base64 is set)'),\n\tbody_base64: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Base64 file bytes for binary content (omit when text is set; max 32 MiB decoded)')\n}\n\nfunction refineExactlyOneBody(\n\tval: { text?: string | undefined; body_base64?: string | undefined },\n\tctx: z.RefinementCtx\n): void {\n\tconst hasText = val.text !== undefined\n\tconst hasB64 = val.body_base64 !== undefined\n\tif (hasText === hasB64) {\n\t\tctx.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: 'Provide exactly one of text or body_base64'\n\t\t})\n\t}\n}\n\nexport const writeFileInputSchema = z\n\t.object({\n\t\tsandbox_id: sandboxId,\n\t\tpath: filePathField,\n\t\t...writeFileBodyFields,\n\t\tsession_id: sessionIdField\n\t})\n\t.superRefine(refineExactlyOneBody)\n\nexport const writeFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length written when known')\n})\n\nexport const readFileInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tencoding: z\n\t\t.enum(['utf8', 'base64'])\n\t\t.optional()\n\t\t.describe('Response encoding (default utf8 for text; use base64 for binary)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\ttext: z.string().optional().describe('Utf-8 contents when encoding is utf8 (default)'),\n\tbody_base64: z.string().optional().describe('Base64 contents when encoding is base64'),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length')\n})\n\nexport const writeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tfiles: z\n\t\t.array(\n\t\t\tz\n\t\t\t\t.object({\n\t\t\t\t\tpath: z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'),\n\t\t\t\t\t...writeFileBodyFields\n\t\t\t\t})\n\t\t\t\t.superRefine(refineExactlyOneBody)\n\t\t)\n\t\t.min(1)\n\t\t.max(MAX_WRITE_FILES)\n\t\t.describe('Files to write under workspace (text or body_base64 each)'),\n\tsession_id: sessionIdField\n})\n\nexport const writeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const readFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to read under workspace'),\n\tencoding: z.enum(['utf8', 'base64']).optional().describe('Response encoding for all files (default utf8)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tpath: z.string(),\n\t\t\ttext: z.string().optional(),\n\t\t\tbody_base64: z.string().optional(),\n\t\t\tbyte_length: z.number().int().nonnegative().optional()\n\t\t})\n\t)\n})\n\nexport const listFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tdirectory_path: z.string().max(MAX_FILE_PATH).optional().describe('Directory to list (default /workspace)'),\n\tsession_id: sessionIdField\n})\n\nexport const listFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()).describe('Absolute or workspace-relative file paths found'),\n\traw: z.unknown().optional().describe('Provider listing payload when available')\n})\n\nexport const removeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to remove under workspace'),\n\tsession_id: sessionIdField\n})\n\nexport const removeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const importArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tsource: sandboxObjectArtifactRefSchema.describe('Object-store ArtifactRef to copy into the sandbox'),\n\tsession_id: sessionIdField\n})\n\nexport const importArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative()\n})\n\nexport const exportArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tdestination_key: z.string().min(1).describe('Object key to write under bound storage'),\n\tsession_id: sessionIdField\n})\n\nexport const exportArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tartifact: sandboxObjectArtifactRefSchema\n})\n\nexport const createBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string().describe('Bridge session id for Session-Id header')\n})\n\nexport const deleteBridgeSessionInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tsession_id: z.string().min(1).max(200).describe('Bridge session id to delete')\n})\n\nexport const deleteBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string(),\n\tdeleted: z.literal(true)\n})\n\nexport const executeCodeInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tcode: z.string().min(1).max(MAX_ARG_CHARS).describe('Source code to run'),\n\tlanguage: z\n\t\t.enum(['python', 'javascript', 'typescript', 'shell'])\n\t\t.optional()\n\t\t.describe('Runtime language (default python)'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tsession_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional bridge session id for isolated working directory and runtime state')\n})\n\n/**\n * Mount an S3-compatible bucket into the sandbox filesystem.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n *\n * Two bridge modes:\n * - **R2 binding:** omit `endpoint`; `bucket` is the Worker R2 binding name.\n * - **Remote S3/R2/GCS:** set `endpoint` (+ optional credentials; bridge may use Worker secrets).\n */\nexport const mountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tbucket: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(256)\n\t\t.describe(\n\t\t\t'R2 Worker binding name when endpoint is omitted; otherwise the remote bucket name (e.g. for S3/R2 endpoint mounts)'\n\t\t),\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute path inside the sandbox to mount at (e.g. /data or /mnt/workspace)'),\n\tendpoint: z\n\t\t.url()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'S3-compatible endpoint URL (e.g. https://s3.amazonaws.com or https://ACCOUNT.r2.cloudflarestorage.com). Omit for Worker R2 binding mounts'\n\t\t),\n\tprovider: z\n\t\t.enum(['r2', 's3', 'gcs'])\n\t\t.optional()\n\t\t.describe('Provider hint for s3fs optimizations when using endpoint mounts'),\n\tread_only: z.boolean().optional().describe('Mount read-only (default false)'),\n\tprefix: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.optional()\n\t\t.describe('Bucket prefix/subdirectory to expose at the mount (must start with / when set)'),\n\taccess_key_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Access key for endpoint mounts (maps to bridge credentials.accessKeyId)'),\n\tsecret_access_key: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Secret key for endpoint mounts (maps to bridge credentials.secretAccessKey)'),\n\tcredential_proxy: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'When true, bridge keeps credentials out of the container (egress signing). Endpoint mounts only; requires ContainerProxy on the bridge Worker'\n\t\t),\n\tlocal_bucket: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('When true, use local R2 binding sync (wrangler dev). Mutually exclusive with endpoint'),\n\ts3fs_options: z\n\t\t.array(z.string().min(1).max(256))\n\t\t.max(32)\n\t\t.optional()\n\t\t.describe('Advanced s3fs mount flags (e.g. use_cache=/tmp/cache)')\n})\n\nexport const mountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tbucket: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport const unmountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute mount path previously passed to mount')\n})\n\nexport const unmountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport type SandboxIdInput = z.infer<typeof sandboxIdInputSchema>\nexport type CreateSandboxOutput = z.infer<typeof createSandboxOutputSchema>\nexport type DestroySandboxOutput = z.infer<typeof destroySandboxOutputSchema>\nexport type RunningOutput = z.infer<typeof runningOutputSchema>\nexport type HealthOutput = z.infer<typeof healthOutputSchema>\nexport type ExecInput = z.infer<typeof execInputSchema>\nexport type ExecOutput = z.infer<typeof execOutputSchema>\nexport type WriteFileInput = z.infer<typeof writeFileInputSchema>\nexport type WriteFileOutput = z.infer<typeof writeFileOutputSchema>\nexport type ReadFileInput = z.infer<typeof readFileInputSchema>\nexport type ReadFileOutput = z.infer<typeof readFileOutputSchema>\nexport type WriteFilesInput = z.infer<typeof writeFilesInputSchema>\nexport type WriteFilesOutput = z.infer<typeof writeFilesOutputSchema>\nexport type ReadFilesInput = z.infer<typeof readFilesInputSchema>\nexport type ReadFilesOutput = z.infer<typeof readFilesOutputSchema>\nexport type ListFilesInput = z.infer<typeof listFilesInputSchema>\nexport type ListFilesOutput = z.infer<typeof listFilesOutputSchema>\nexport type RemoveFilesInput = z.infer<typeof removeFilesInputSchema>\nexport type RemoveFilesOutput = z.infer<typeof removeFilesOutputSchema>\nexport type ImportArtifactInput = z.infer<typeof importArtifactInputSchema>\nexport type ImportArtifactOutput = z.infer<typeof importArtifactOutputSchema>\nexport type ExportArtifactInput = z.infer<typeof exportArtifactInputSchema>\nexport type ExportArtifactOutput = z.infer<typeof exportArtifactOutputSchema>\nexport type CreateBridgeSessionOutput = z.infer<typeof createBridgeSessionOutputSchema>\nexport type DeleteBridgeSessionInput = z.infer<typeof deleteBridgeSessionInputSchema>\nexport type DeleteBridgeSessionOutput = z.infer<typeof deleteBridgeSessionOutputSchema>\nexport type ExecuteCodeInput = z.infer<typeof executeCodeInputSchema>\nexport type MountBucketInput = z.infer<typeof mountBucketInputSchema>\nexport type MountBucketOutput = z.infer<typeof mountBucketOutputSchema>\nexport type UnmountBucketInput = z.infer<typeof unmountBucketInputSchema>\nexport type UnmountBucketOutput = z.infer<typeof unmountBucketOutputSchema>\n","/**\n * Cloudflare Sandbox Bridge pure helpers (no HTTP).\n */\n\nimport { isPlainObject, isString } from 'es-toolkit'\n\nimport { ToolError } from '../../core/errors'\nimport { base64ToBytes, utf8ToBytes } from '../../shared/bytes'\nimport { MAX_FILE_BYTES } from './contracts'\n\n/** Normalize a host path to the bridge URL segment under /file/… (no leading slash). */\nexport function workspaceFileKey(path: string): string {\n\tconst trimmed = path.trim()\n\tif (!trimmed) {\n\t\tthrow new ToolError('File path is empty', { code: 'bad_input' })\n\t}\n\tconst noLead = trimmed.replace(/^\\/+/, '')\n\tconst under = noLead.startsWith('workspace/') ? noLead : `workspace/${noLead}`\n\t// Reject traversal\n\tconst parts = under.split('/')\n\tif (parts.some((p) => p === '..' || p === '')) {\n\t\tthrow new ToolError('File path must stay under workspace', {\n\t\t\tcode: 'bad_input',\n\t\t\tdetails: { path: trimmed }\n\t\t})\n\t}\n\treturn under\n}\n\n/** Absolute workspace path for shell list/rm (leading slash). */\nexport function workspaceAbsolutePath(path: string): string {\n\tconst key = workspaceFileKey(path)\n\treturn `/${key}`\n}\n\n/** Shell-safe single-quoted string. */\nexport function shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", `'\\\\''`)}'`\n}\n\n/**\n * Resolve write-file body to raw bytes (text UTF-8 or base64).\n * Enforces MAX_FILE_BYTES (bridge limit).\n */\nexport function resolveWriteFileBytes(input: {\n\ttext?: string | undefined\n\tbody_base64?: string | undefined\n}): Uint8Array {\n\tif (input.body_base64 !== undefined && input.text !== undefined) {\n\t\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n\t}\n\tif (input.body_base64 !== undefined) {\n\t\tconst bytes = base64ToBytes(input.body_base64)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tif (input.text !== undefined) {\n\t\tconst bytes = utf8ToBytes(input.text)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n}\n\nexport type ParsedExecStream = {\n\tstdout: string\n\tstderr: string\n\texit_code?: number\n\terror?: string\n\terror_code?: string\n}\n\nexport type ParseExecSseOptions = {\n\t/** Called for each stdout chunk as the SSE body is walked (buffer may still be complete). */\n\tonStdout?: (chunk: string) => void\n\t/** Called for each stderr chunk as the SSE body is walked. */\n\tonStderr?: (chunk: string) => void\n}\n\n/**\n * Parse bridge /exec text/event-stream body.\n * Events: stdout/stderr (base64 data), exit ({\"exit_code\":N}), error ({\"error\",\"code\"}).\n */\nexport function parseExecSse(body: string, options: ParseExecSseOptions = {}): ParsedExecStream {\n\tconst stdoutChunks: string[] = []\n\tconst stderrChunks: string[] = []\n\tlet exit_code: number | undefined\n\tlet error: string | undefined\n\tlet error_code: string | undefined\n\n\tconst blocks = body.replaceAll('\\r\\n', '\\n').split('\\n\\n')\n\tfor (const block of blocks) {\n\t\tconst lines = block.split('\\n').filter((line) => line.length > 0)\n\t\tif (lines.length === 0) continue\n\t\tlet event = 'message'\n\t\tconst dataLines: string[] = []\n\t\tfor (const line of lines) {\n\t\t\tif (line.startsWith('event:')) {\n\t\t\t\tevent = line.slice(6).trim()\n\t\t\t} else if (line.startsWith('data:')) {\n\t\t\t\tdataLines.push(line.slice(5).trimStart())\n\t\t\t}\n\t\t}\n\t\tconst data = dataLines.join('\\n')\n\t\tif (event === 'stdout' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstdoutChunks.push(chunk)\n\t\t\toptions.onStdout?.(chunk)\n\t\t} else if (event === 'stderr' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstderrChunks.push(chunk)\n\t\t\toptions.onStderr?.(chunk)\n\t\t} else if (event === 'exit' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tconst code = parsed['exit_code']\n\t\t\t\tif (typeof code === 'number' && Number.isFinite(code)) exit_code = code\n\t\t\t}\n\t\t} else if (event === 'error' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tif (isString(parsed['error'])) error = parsed['error']\n\t\t\t\tif (isString(parsed['code'])) error_code = parsed['code']\n\t\t\t} else {\n\t\t\t\terror = data\n\t\t\t}\n\t\t}\n\t}\n\n\tconst out: ParsedExecStream = {\n\t\tstdout: stdoutChunks.join(''),\n\t\tstderr: stderrChunks.join('')\n\t}\n\tif (exit_code !== undefined) out.exit_code = exit_code\n\tif (error !== undefined) out.error = error\n\tif (error_code !== undefined) out.error_code = error_code\n\treturn out\n}\n\nfunction decodeBase64Chunk(data: string): string {\n\ttry {\n\t\t// Bun/Node Buffer or atob\n\t\tif (typeof Buffer !== 'undefined') {\n\t\t\treturn Buffer.from(data, 'base64').toString('utf8')\n\t\t}\n\t\tconst binary = atob(data)\n\t\tconst bytes = new Uint8Array(binary.length)\n\t\tfor (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i)\n\t\treturn new TextDecoder().decode(bytes)\n\t} catch {\n\t\treturn data\n\t}\n}\n\nfunction safeJson(text: string): unknown {\n\ttry {\n\t\tconst value: unknown = JSON.parse(text)\n\t\treturn value\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** Build argv for executeCode over the bridge (no native runCode route). */\nexport function executeCodeArgv(language: string, code: string): string[] {\n\tswitch (language) {\n\t\tcase 'javascript':\n\t\tcase 'typescript':\n\t\t\treturn ['node', '-e', code]\n\t\tcase 'shell':\n\t\t\treturn ['sh', '-lc', code]\n\t\tcase 'python':\n\t\tdefault:\n\t\t\treturn ['python3', '-c', code]\n\t}\n}\n","/**\n * Cloudflare Sandbox Bridge vendor client (HttpService + Bearer).\n * Host: `new CloudflareSandboxClient(auth)`. Agent: `fromContext(ctx)`.\n * Gold: `src/vendors/resend/client.ts` + messaging ArtifactRef storage pattern.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { isPlainObject, isString, trimEnd } from 'es-toolkit'\n\nimport { ToolError } from '../../core/errors'\nimport { requireAuth } from '../../core/provider'\nimport type { ToolContext } from '../../core/types'\nimport { bytesToBase64, bytesToUtf8, toArrayBuffer } from '../../shared/bytes'\nimport { HttpService } from '../../transport/http-service'\nimport type { HttpServiceOptions } from '../../transport/http-service'\nimport { S3Client } from '../s3'\nimport type {\n\tCloudflareSandboxAuth,\n\tCreateBridgeSessionOutput,\n\tCreateSandboxOutput,\n\tDeleteBridgeSessionInput,\n\tDeleteBridgeSessionOutput,\n\tDestroySandboxOutput,\n\tExecInput,\n\tExecOutput,\n\tExecuteCodeInput,\n\tExportArtifactInput,\n\tExportArtifactOutput,\n\tHealthOutput,\n\tImportArtifactInput,\n\tImportArtifactOutput,\n\tListFilesInput,\n\tListFilesOutput,\n\tMountBucketInput,\n\tMountBucketOutput,\n\tReadFileInput,\n\tReadFileOutput,\n\tReadFilesInput,\n\tReadFilesOutput,\n\tRemoveFilesInput,\n\tRemoveFilesOutput,\n\tRunningOutput,\n\tSandboxIdInput,\n\tUnmountBucketInput,\n\tUnmountBucketOutput,\n\tWriteFileInput,\n\tWriteFileOutput,\n\tWriteFilesInput,\n\tWriteFilesOutput\n} from './contracts'\nimport {\n\tDEFAULT_EXEC_TIMEOUT_MS,\n\tMAX_FILE_BYTES,\n\tMAX_LIST_FILES,\n\tcloudflareSandboxAuthSchema,\n\tmountBucketInputSchema,\n\tunmountBucketInputSchema\n} from './contracts'\nimport {\n\texecuteCodeArgv,\n\tparseExecSse,\n\tresolveWriteFileBytes,\n\tshellQuote,\n\tworkspaceAbsolutePath,\n\tworkspaceFileKey\n} from './domain'\n\nexport type CloudflareSandboxClientOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class CloudflareSandboxClient {\n\treadonly #http: HttpService\n\treadonly #storage: S3Client | undefined\n\t/** Optional S3 auth fields for endpoint mount credential fallback (Mastra workspace FS). */\n\treadonly #storageAuth:\n\t\t| {\n\t\t\t\taccess_key_id: string\n\t\t\t\tsecret_access_key: string\n\t\t\t\tendpoint?: string | undefined\n\t\t }\n\t\t| undefined\n\n\tconstructor(auth: CloudflareSandboxAuth, options: CloudflareSandboxClientOptions = {}) {\n\t\tconst parsed = cloudflareSandboxAuthSchema.safeParse(auth)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid Cloudflare Sandbox auth credentials', {\n\t\t\t\tcode: 'bad_auth',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tthis.#http = new HttpService({\n\t\t\tbaseURL: trimEnd(parsed.data.base_url, '/'),\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${parsed.data.api_key}`\n\t\t\t},\n\t\t\ttimeout: 120_000,\n\t\t\tlabel: 'Cloudflare Sandbox',\n\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t...(options.signal && { signal: options.signal })\n\t\t})\n\t\tthis.#storage = parsed.data.storage\n\t\t\t? new S3Client(parsed.data.storage, {\n\t\t\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t\t\t...(options.signal && { signal: options.signal })\n\t\t\t\t})\n\t\t\t: undefined\n\t\tthis.#storageAuth = parsed.data.storage\n\t\t\t? {\n\t\t\t\t\taccess_key_id: parsed.data.storage.access_key_id,\n\t\t\t\t\tsecret_access_key: parsed.data.storage.secret_access_key,\n\t\t\t\t\t...(parsed.data.storage.endpoint && { endpoint: parsed.data.storage.endpoint })\n\t\t\t\t}\n\t\t\t: undefined\n\t}\n\n\tstatic fromContext(ctx: ToolContext): CloudflareSandboxClient {\n\t\treturn new CloudflareSandboxClient(requireAuth(ctx, cloudflareSandboxAuthSchema), {\n\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t})\n\t}\n\n\t/** Liveness probe on the bridge. */\n\tasync health(): Promise<HealthOutput> {\n\t\tconst { data } = await this.#http.get('/health', {\n\t\t\tlabel: 'Cloudflare Sandbox health'\n\t\t})\n\t\tif (isPlainObject(data) && data['ok'] === true) return { ok: true }\n\t\tif (isPlainObject(data) && data['ok'] === false) return { ok: false }\n\t\treturn { ok: true }\n\t}\n\n\tasync create(): Promise<CreateSandboxOutput> {\n\t\tconst { data } = await this.#http.post('/v1/sandbox', undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox create'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create sandbox response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: data['id'] }\n\t}\n\n\tasync destroy(input: SandboxIdInput): Promise<DestroySandboxOutput> {\n\t\tawait this.#http.delete(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}`, {\n\t\t\tlabel: 'Cloudflare Sandbox destroy'\n\t\t})\n\t\treturn { sandbox_id: input.sandbox_id, destroyed: true }\n\t}\n\n\tasync running(input: SandboxIdInput): Promise<RunningOutput> {\n\t\tconst { data } = await this.#http.get(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/running`, {\n\t\t\tlabel: 'Cloudflare Sandbox running'\n\t\t})\n\t\tif (!isPlainObject(data) || typeof data['running'] !== 'boolean') {\n\t\t\tthrow new ToolError('Unexpected running response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, running: data['running'] }\n\t}\n\n\t/**\n\t * Run a command. Bridge returns text/event-stream (stdout/stderr base64 + exit).\n\t * Uses HttpService.bytes so ofetch does not try to JSON-parse the SSE body.\n\t * Optional onStdout/onStderr fire while walking the buffered SSE (not true wire streaming).\n\t */\n\tasync exec(\n\t\tinput: ExecInput,\n\t\tstream: { onStdout?: (chunk: string) => void; onStderr?: (chunk: string) => void } = {}\n\t): Promise<ExecOutput> {\n\t\tconst body: Record<string, unknown> = {\n\t\t\targv: input.argv,\n\t\t\ttimeout_ms: input.timeout_ms ?? DEFAULT_EXEC_TIMEOUT_MS\n\t\t}\n\t\tif (input.cwd) body['cwd'] = input.cwd\n\t\tif (input.env && Object.keys(input.env).length > 0) body['env'] = input.env\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAccept: 'text/event-stream'\n\t\t}\n\t\tif (input.session_id) headers['Session-Id'] = input.session_id\n\n\t\tconst { bytes } = await this.#http.bytes('POST', `/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/exec`, {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tlabel: 'Cloudflare Sandbox exec'\n\t\t})\n\t\tconst text = new TextDecoder().decode(bytes)\n\t\tconst parsed = parseExecSse(text, {\n\t\t\t...(stream.onStdout && { onStdout: stream.onStdout }),\n\t\t\t...(stream.onStderr && { onStderr: stream.onStderr })\n\t\t})\n\t\tif (parsed.error && parsed.exit_code === undefined) {\n\t\t\tthrow new ToolError(parsed.error, {\n\t\t\t\tcode: 'upstream',\n\t\t\t\tdetails: {\n\t\t\t\t\t...(parsed.error_code && { error_code: parsed.error_code }),\n\t\t\t\t\tsandbox_id: input.sandbox_id\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tconst exit_code = parsed.exit_code ?? (parsed.error ? 1 : 0)\n\t\tconst out: ExecOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tstdout: parsed.stdout,\n\t\t\tstderr: parsed.stderr,\n\t\t\texit_code,\n\t\t\tsuccess: exit_code === 0\n\t\t}\n\t\tif (parsed.error) out.error = parsed.error\n\t\tif (parsed.error_code) out.error_code = parsed.error_code\n\t\treturn out\n\t}\n\n\t/** Execute source via python3/node/sh on the bridge (no native runCode route). */\n\tasync executeCode(input: ExecuteCodeInput): Promise<ExecOutput> {\n\t\tconst language = input.language ?? 'python'\n\t\treturn this.exec({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\targv: executeCodeArgv(language, input.code),\n\t\t\t...(input.timeout_ms !== undefined && { timeout_ms: input.timeout_ms }),\n\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t})\n\t}\n\n\tasync writeFile(input: WriteFileInput): Promise<WriteFileOutput> {\n\t\tconst bytes = resolveWriteFileBytes(input)\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\tasync readFile(input: ReadFileInput): Promise<ReadFileOutput> {\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tconst encoding = input.encoding ?? 'utf8'\n\t\tconst out: ReadFileOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t\tif (encoding === 'base64') {\n\t\t\tout.body_base64 = bytesToBase64(bytes)\n\t\t} else {\n\t\t\tout.text = bytesToUtf8(bytes)\n\t\t}\n\t\treturn out\n\t}\n\n\tasync writeFiles(input: WriteFilesInput): Promise<WriteFilesOutput> {\n\t\tconst paths: string[] = []\n\t\tfor (const file of input.files) {\n\t\t\tawait this.writeFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath: file.path,\n\t\t\t\t...(file.text !== undefined && { text: file.text }),\n\t\t\t\t...(file.body_base64 !== undefined && { body_base64: file.body_base64 }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tpaths.push(file.path)\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths, ok: true }\n\t}\n\n\tasync readFiles(input: ReadFilesInput): Promise<ReadFilesOutput> {\n\t\tconst files: ReadFilesOutput['files'] = []\n\t\tfor (const path of input.paths) {\n\t\t\tconst row = await this.readFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath,\n\t\t\t\t...(input.encoding && { encoding: input.encoding }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tfiles.push({\n\t\t\t\tpath: row.path,\n\t\t\t\t...(row.text !== undefined && { text: row.text }),\n\t\t\t\t...(row.body_base64 !== undefined && { body_base64: row.body_base64 }),\n\t\t\t\t...(row.byte_length !== undefined && { byte_length: row.byte_length })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, files }\n\t}\n\n\t/** List files via find in the workspace (bridge has no list route). */\n\tasync listFiles(input: ListFilesInput): Promise<ListFilesOutput> {\n\t\tconst dir = input.directory_path?.trim() || '/workspace'\n\t\tconst abs = dir.startsWith('/') ? dir : workspaceAbsolutePath(dir)\n\t\tconst out = await this.exec({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\targv: ['sh', '-lc', `find ${shellQuote(abs)} -maxdepth 4 -type f 2>/dev/null | head -n ${MAX_LIST_FILES}`],\n\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t})\n\t\tconst paths = out.stdout\n\t\t\t.split('\\n')\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line.length > 0)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpaths,\n\t\t\traw: { stdout: out.stdout, stderr: out.stderr, exit_code: out.exit_code }\n\t\t}\n\t}\n\n\t/** Remove files via rm (bridge has no delete-file route). */\n\tasync removeFiles(input: RemoveFilesInput): Promise<RemoveFilesOutput> {\n\t\tfor (const path of input.paths) {\n\t\t\tconst abs = path.startsWith('/') ? path : workspaceAbsolutePath(path)\n\t\t\tawait this.exec({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\targv: ['rm', '-f', '--', abs],\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths: input.paths, ok: true }\n\t}\n\n\t/**\n\t * Copy an object-store ArtifactRef into the sandbox workspace.\n\t * Requires auth.storage.\n\t */\n\tasync importArtifact(input: ImportArtifactInput): Promise<ImportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('importArtifact')\n\t\tif (input.source.store !== 'object') {\n\t\t\tthrow new ToolError('Sandbox importArtifact only supports store=object ArtifactRefs', {\n\t\t\t\tcode: 'bad_input'\n\t\t\t})\n\t\t}\n\t\tconst bytes = await storage.getBytes(input.source.key, { maxBytes: MAX_FILE_BYTES })\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\t/**\n\t * Copy a sandbox workspace file to object storage and return an ArtifactRef.\n\t * Requires auth.storage.\n\t */\n\tasync exportArtifact(input: ExportArtifactInput): Promise<ExportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('exportArtifact')\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tawait storage.putBytes(input.destination_key, bytes)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tartifact: {\n\t\t\t\tstore: 'object',\n\t\t\t\tkey: input.destination_key,\n\t\t\t\tbyte_length: bytes.byteLength\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createSession(input: SandboxIdInput): Promise<CreateBridgeSessionOutput> {\n\t\tconst { data } = await this.#http.post(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session`, undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox createSession'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create session response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, session_id: data['id'] }\n\t}\n\n\tasync deleteSession(input: DeleteBridgeSessionInput): Promise<DeleteBridgeSessionOutput> {\n\t\tawait this.#http.delete(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session/${encodeURIComponent(input.session_id)}`,\n\t\t\t{ label: 'Cloudflare Sandbox deleteSession' }\n\t\t)\n\t\treturn { sandbox_id: input.sandbox_id, session_id: input.session_id, deleted: true }\n\t}\n\n\t/**\n\t * Mount an S3-compatible bucket (or Worker R2 binding) at an absolute path in the sandbox.\n\t * Bridge: `POST /v1/sandbox/:id/mount`.\n\t * For Mastra / host workspace S3 FS: pass `endpoint` + credentials (or rely on auth.storage).\n\t * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n\t */\n\tasync mount(input: MountBucketInput): Promise<MountBucketOutput> {\n\t\tconst parsed = mountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox mount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tif (data.local_bucket && data.endpoint) {\n\t\t\tthrow new ToolError('local_bucket and endpoint are mutually exclusive on mount', { code: 'bad_input' })\n\t\t}\n\t\tif (data.prefix !== undefined && !data.prefix.startsWith('/')) {\n\t\t\tthrow new ToolError('mount prefix must start with /', { code: 'bad_input' })\n\t\t}\n\n\t\t// Endpoint mounts only: omit endpoint for Worker R2 binding mounts.\n\t\tconst endpoint = data.local_bucket ? undefined : data.endpoint\n\t\t// Credentials: explicit input, else auth.storage when doing an endpoint mount (Mastra S3 FS).\n\t\tconst accessKeyId = data.access_key_id ?? (endpoint !== undefined ? this.#storageAuth?.access_key_id : undefined)\n\t\tconst secretAccessKey =\n\t\t\tdata.secret_access_key ?? (endpoint !== undefined ? this.#storageAuth?.secret_access_key : undefined)\n\n\t\tconst options: Record<string, unknown> = {}\n\t\tif (endpoint) options['endpoint'] = endpoint\n\t\tif (data.provider) options['provider'] = data.provider\n\t\tif (data.read_only !== undefined) options['readOnly'] = data.read_only\n\t\tif (data.prefix) options['prefix'] = data.prefix\n\t\tif (data.credential_proxy !== undefined) options['credentialProxy'] = data.credential_proxy\n\t\tif (data.local_bucket) options['localBucket'] = true\n\t\tif (data.s3fs_options && data.s3fs_options.length > 0) options['s3fsOptions'] = data.s3fs_options\n\t\tif (endpoint && accessKeyId && secretAccessKey) {\n\t\t\toptions['credentials'] = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey\n\t\t\t}\n\t\t}\n\n\t\tconst body: Record<string, unknown> = {\n\t\t\tbucket: data.bucket,\n\t\t\tmountPath: data.mount_path\n\t\t}\n\t\tif (Object.keys(options).length > 0) body['options'] = options\n\n\t\tawait this.#http.post(`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/mount`, body, {\n\t\t\tlabel: 'Cloudflare Sandbox mount'\n\t\t})\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tbucket: data.bucket,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\t/**\n\t * Unmount a previously mounted bucket path.\n\t * Bridge: `POST /v1/sandbox/:id/unmount` with `{ mountPath }`.\n\t * Mounts are also cleared when the sandbox is destroyed.\n\t */\n\tasync unmount(input: UnmountBucketInput): Promise<UnmountBucketOutput> {\n\t\tconst parsed = unmountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox unmount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tawait this.#http.post(\n\t\t\t`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/unmount`,\n\t\t\t{ mountPath: data.mount_path },\n\t\t\t{ label: 'Cloudflare Sandbox unmount' }\n\t\t)\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\t#requireStorage(op: string): S3Client {\n\t\tif (!this.#storage) {\n\t\t\tthrow new ToolError(`${op} requires storage credentials on sandbox auth`, {\n\t\t\t\tcode: 'bad_auth'\n\t\t\t})\n\t\t}\n\t\treturn this.#storage\n\t}\n\n\tasync #putFileBytes(\n\t\tsandboxId: string,\n\t\tpath: string,\n\t\tbytes: Uint8Array,\n\t\tsessionId: string | undefined\n\t): Promise<void> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/octet-stream'\n\t\t}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { data } = await this.#http.put(\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\ttoArrayBuffer(bytes),\n\t\t\t{ headers, label: 'Cloudflare Sandbox writeFile' }\n\t\t)\n\t\tif (isPlainObject(data) && data['ok'] === false) {\n\t\t\tthrow new ToolError('Sandbox writeFile failed', { code: 'upstream' })\n\t\t}\n\t}\n\n\tasync #getFileBytes(sandboxId: string, path: string, sessionId: string | undefined): Promise<Uint8Array> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { bytes } = await this.#http.bytes(\n\t\t\t'GET',\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\t{ headers, label: 'Cloudflare Sandbox readFile', maxBytes: MAX_FILE_BYTES }\n\t\t)\n\t\treturn bytes\n\t}\n}\n","import { z } from 'zod'\n\nimport { defineModule, defineTool } from '../../core/define'\nimport { CloudflareSandboxClient } from './client'\nimport {\n\tcloudflareSandboxAuthSchema,\n\tcreateBridgeSessionOutputSchema,\n\tcreateSandboxOutputSchema,\n\tdeleteBridgeSessionInputSchema,\n\tdeleteBridgeSessionOutputSchema,\n\tdestroySandboxOutputSchema,\n\texecInputSchema,\n\texecOutputSchema,\n\texecuteCodeInputSchema,\n\texportArtifactInputSchema,\n\texportArtifactOutputSchema,\n\thealthOutputSchema,\n\timportArtifactInputSchema,\n\timportArtifactOutputSchema,\n\tlistFilesInputSchema,\n\tlistFilesOutputSchema,\n\treadFileInputSchema,\n\treadFileOutputSchema,\n\treadFilesInputSchema,\n\treadFilesOutputSchema,\n\tremoveFilesInputSchema,\n\tremoveFilesOutputSchema,\n\trunningOutputSchema,\n\tsandboxIdInputSchema,\n\twriteFileInputSchema,\n\twriteFileOutputSchema,\n\twriteFilesInputSchema,\n\twriteFilesOutputSchema\n} from './contracts'\n\nconst id = 'cloudflare-sandbox'\nconst emptyInputSchema = z.object({})\n\nexport const cloudflareSandboxHealthTool = defineTool({\n\tid: `${id}-health`,\n\tname: 'cloudflareSandboxHealth',\n\tdescription:\n\t\t'Check whether the Cloudflare Sandbox bridge is reachable. Use only for explicit availability diagnostics; ordinary sandbox work should begin with cloudflare-sandbox-create.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: healthOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).health()\n})\n\nexport const cloudflareSandboxCreateTool = defineTool({\n\tid: `${id}-create`,\n\tname: 'cloudflareSandboxCreate',\n\tdescription:\n\t\t'Create an isolated Cloudflare sandbox and return sandbox_id. Use only when arbitrary code, commands, or temporary files are required and no purpose-built tool covers the task. Do not create a sandbox to build or edit supported deliverables.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: createSandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).create()\n})\n\nexport const cloudflareSandboxDestroyTool = defineTool({\n\tid: `${id}-destroy`,\n\tname: 'cloudflareSandboxDestroy',\n\tdescription:\n\t\t'Destroy a Cloudflare sandbox by sandbox_id and release its temporary files and resources. Call after the sandbox workflow is complete and any required output file has been exported.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: destroySandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).destroy(input)\n})\n\nexport const cloudflareSandboxRunningTool = defineTool({\n\tid: `${id}-running`,\n\tname: 'cloudflareSandboxRunning',\n\tdescription:\n\t\t'Check whether a Cloudflare sandbox is currently running. Use before continuing work on an existing sandbox_id; this does not execute code or inspect files.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: runningOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).running(input)\n})\n\nexport const cloudflareSandboxExecTool = defineTool({\n\tid: `${id}-exec`,\n\tname: 'cloudflareSandboxExec',\n\tdescription:\n\t\t'One-shot argv exec in a Cloudflare sandbox (stdout/stderr/exit_code). Prefer a host workspace agent for multi-step shell; use tools for workflow one-shots. Optional env when the bridge supports it.',\n\tinputSchema: execInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\ttags: ['exec', 'one-shot', 'compute'],\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exec(input)\n})\n\nexport const cloudflareSandboxExecuteCodeTool = defineTool({\n\tid: `${id}-execute-code`,\n\tname: 'cloudflareSandboxExecuteCode',\n\tdescription:\n\t\t'Execute Python, JavaScript, or shell source in a Cloudflare sandbox. Use as a fallback for computation or automation with no dedicated tool. Do not generate or edit supported documents, spreadsheets, presentations, PDFs, or images here when a purpose-built tool is available.',\n\tinputSchema: executeCodeInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).executeCode(input)\n})\n\nexport const cloudflareSandboxWriteFileTool = defineTool({\n\tid: `${id}-write-file`,\n\tname: 'cloudflareSandboxWriteFile',\n\tdescription:\n\t\t'Write one temporary file under the Cloudflare sandbox workspace from UTF-8 text or base64 bytes, up to 32 MiB decoded. Use for sandbox intermediates. This is not durable delivery; export a genuinely sandbox-produced final file with cloudflare-sandbox-export-artifact.',\n\tinputSchema: writeFileInputSchema,\n\toutputSchema: writeFileOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFile(input)\n})\n\nexport const cloudflareSandboxReadFileTool = defineTool({\n\tid: `${id}-read-file`,\n\tname: 'cloudflareSandboxReadFile',\n\tdescription:\n\t\t'Read one temporary file from the Cloudflare sandbox workspace as UTF-8 or base64. Use for sandbox intermediates; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFileInputSchema,\n\toutputSchema: readFileOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFile(input)\n})\n\nexport const cloudflareSandboxWriteFilesTool = defineTool({\n\tid: `${id}-write-files`,\n\tname: 'cloudflareSandboxWriteFiles',\n\tdescription:\n\t\t'Write multiple temporary files under the Cloudflare sandbox workspace from text or base64. Use for sandbox intermediates, not final document generation. Export only a final file that the sandbox genuinely had to produce.',\n\tinputSchema: writeFilesInputSchema,\n\toutputSchema: writeFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFiles(input)\n})\n\nexport const cloudflareSandboxReadFilesTool = defineTool({\n\tid: `${id}-read-files`,\n\tname: 'cloudflareSandboxReadFiles',\n\tdescription:\n\t\t'Read multiple temporary files from the Cloudflare sandbox workspace as UTF-8 or base64. Use only within an active sandbox workflow; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFilesInputSchema,\n\toutputSchema: readFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFiles(input)\n})\n\nexport const cloudflareSandboxListFilesTool = defineTool({\n\tid: `${id}-list-files`,\n\tname: 'cloudflareSandboxListFiles',\n\tdescription:\n\t\t'List temporary files under a Cloudflare sandbox directory, defaulting to /workspace. Use to locate sandbox intermediates, not durable workspace files or ArtifactRefs.',\n\tinputSchema: listFilesInputSchema,\n\toutputSchema: listFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).listFiles(input)\n})\n\nexport const cloudflareSandboxRemoveFilesTool = defineTool({\n\tid: `${id}-remove-files`,\n\tname: 'cloudflareSandboxRemoveFiles',\n\tdescription:\n\t\t'Remove temporary files from the Cloudflare sandbox workspace by path. Use only for sandbox cleanup; this does not delete durable workspace files or ArtifactRefs.',\n\tinputSchema: removeFilesInputSchema,\n\toutputSchema: removeFilesOutputSchema,\n\tsideEffect: 'delete',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).removeFiles(input)\n})\n\nexport const cloudflareSandboxImportArtifactTool = defineTool({\n\tid: `${id}-import-artifact`,\n\tname: 'cloudflareSandboxImportArtifact',\n\tdescription:\n\t\t'Copy an existing object-store ArtifactRef into a Cloudflare sandbox workspace. Use only when arbitrary sandbox computation must consume that file. Do not import a supported document merely to read or edit it with general code.',\n\tinputSchema: importArtifactInputSchema,\n\toutputSchema: importArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).importArtifact(input)\n})\n\nexport const cloudflareSandboxExportArtifactTool = defineTool({\n\tid: `${id}-export-artifact`,\n\tname: 'cloudflareSandboxExportArtifact',\n\tdescription:\n\t\t'Persist a final file that was genuinely created inside the Cloudflare sandbox and return its ArtifactRef for delivery. Use only after sandbox work. Do not call for files returned by document, presentation, PDF, image, render, or conversion tools; those ArtifactRefs are already final.',\n\tinputSchema: exportArtifactInputSchema,\n\toutputSchema: exportArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exportArtifact(input)\n})\n\nexport const cloudflareSandboxCreateSessionTool = defineTool({\n\tid: `${id}-create-session`,\n\tname: 'cloudflareSandboxCreateSession',\n\tdescription:\n\t\t'Create an isolated execution session inside an existing Cloudflare sandbox and return session_id. Use only when separate working directories or runtime state are needed; pass the id to later command and file calls.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: createBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).createSession(input)\n})\n\nexport const cloudflareSandboxDeleteSessionTool = defineTool({\n\tid: `${id}-delete-session`,\n\tname: 'cloudflareSandboxDeleteSession',\n\tdescription:\n\t\t'Delete an isolated execution session inside a Cloudflare sandbox. Use after session-specific work is complete; this does not destroy the parent sandbox.',\n\tinputSchema: deleteBridgeSessionInputSchema,\n\toutputSchema: deleteBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).deleteSession(input)\n})\n\nexport const cloudflareSandboxModule = defineModule({\n\tid,\n\ttitle: 'Cloudflare Sandbox',\n\tdescription:\n\t\t'Cloudflare sandbox bridge: one-shot exec/files/sessions for workflows. Prefer a host workspace agent for multi-step shell. Client export remains first-class for Workspace hybrids. Prefer purpose-built document tools over sandbox for office formats.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: cloudflareSandboxAuthSchema },\n\tcategories: ['compute', 'sandbox', 'cloudflare'],\n\tclassification: 'standard',\n\ttags: ['exec', 'workspace', 'bridge'],\n\ttools: [\n\t\tcloudflareSandboxHealthTool,\n\t\tcloudflareSandboxCreateTool,\n\t\tcloudflareSandboxDestroyTool,\n\t\tcloudflareSandboxRunningTool,\n\t\tcloudflareSandboxExecTool,\n\t\tcloudflareSandboxExecuteCodeTool,\n\t\tcloudflareSandboxWriteFileTool,\n\t\tcloudflareSandboxReadFileTool,\n\t\tcloudflareSandboxWriteFilesTool,\n\t\tcloudflareSandboxReadFilesTool,\n\t\tcloudflareSandboxListFilesTool,\n\t\tcloudflareSandboxRemoveFilesTool,\n\t\tcloudflareSandboxImportArtifactTool,\n\t\tcloudflareSandboxExportArtifactTool,\n\t\tcloudflareSandboxCreateSessionTool,\n\t\tcloudflareSandboxDeleteSessionTool\n\t]\n})\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,WAAW;AACxB,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;;AAE7B,MAAa,iBAAiB,KAAK,OAAO;AAC1C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAC9B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AAEnC,MAAa,8BAA8B,EAAE,OAAO;CACnD,UAAU,EACR,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,sFAAsF;CACjG,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,qCAAqC;CACzE,SAAS,aACP,SAAS,CAAC,CACV,SAAS,kFAAkF;AAC9F,CAAC;;AAKD,MAAa,iCAAiC,EAAE,OAAO;CACtD,OAAO,EAAE,QAAQ,QAAQ,CAAC,CAAC,SAAS,sCAAsC;CAC1E,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAAY;CAC5C,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,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AAY,GAAG,CAAC,CAAC,eAAe,KAAK;AAC7F,CAAC;AAED,MAAa,sCAAsC,WAAW;CAC7D,IAAI,GAAG,GAAG;CACV,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,wBAAwB,YAAY,GAAG,CAAC,CAAC,eAAe,KAAK;AAC7F,CAAC;AAED,MAAa,qCAAqC,WAAW;CAC5D,IAAI,GAAG,GAAG;CACV,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,wBAAwB,YAAY,GAAG,CAAC,CAAC,cAAc,KAAK;AAC5F,CAAC;AAED,MAAa,qCAAqC,WAAW;CAC5D,IAAI,GAAG,GAAG;CACV,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,wBAAwB,YAAY,GAAG,CAAC,CAAC,cAAc,KAAK;AAC5F,CAAC;AAED,MAAa,0BAA0B,aAAa;CACnD;CACA,OAAO;CACP,aACC;CACD,SAAS;CACT,MAAM;EAAE,MAAM;EAAU,QAAQ;CAA4B;CAC5D,YAAY;EAAC;EAAW;EAAW;CAAY;CAC/C,gBAAgB;CAChB,MAAM;EAAC;EAAQ;EAAa;CAAQ;CACpC,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { isString, trimStart } from "es-toolkit";
2
+ import mime from "mime";
3
+ //#region src/shared/content-type.ts
4
+ /** Last path segment after `/`. */
5
+ function baseName(key) {
6
+ const i = key.lastIndexOf("/");
7
+ return i === -1 ? key : key.slice(i + 1);
8
+ }
9
+ /** Extension including leading `.` (empty if none). Posix object-key semantics. */
10
+ function extName(key) {
11
+ const base = baseName(key);
12
+ const i = base.lastIndexOf(".");
13
+ return i > 0 ? base.slice(i) : "";
14
+ }
15
+ /** MIME type for a path or extension, or `undefined` when unknown. */
16
+ function mediaTypeFromPath(pathOrExtension) {
17
+ return mime.getType(pathOrExtension) ?? void 0;
18
+ }
19
+ /** Preferred file extension for a MIME type (charset stripped), or `undefined` when unknown. */
20
+ function extensionFromMediaType(type) {
21
+ return mime.getExtension(type) ?? void 0;
22
+ }
23
+ /** All known extensions for a MIME type. */
24
+ function allExtensionsFromMediaType(type) {
25
+ return [...mime.getAllExtensions(type) ?? []];
26
+ }
27
+ /**
28
+ * Resolve an upload filename extension: prefer path ext, then bare format
29
+ * (`pdf`), then `mime.getExtension(mediaType)`, else fallback.
30
+ */
31
+ function resolveFileExtension(options) {
32
+ const fallback = options.fallback ?? "bin";
33
+ const filename = options.filename;
34
+ if (isString(filename) && filename.length > 0) {
35
+ const ext = extName(filename);
36
+ if (ext.length > 1) return trimStart(ext, ".").toLowerCase();
37
+ }
38
+ const mediaType = options.mediaType;
39
+ if (isString(mediaType) && mediaType.length > 0) {
40
+ if (!mediaType.includes("/")) return mediaType.toLowerCase();
41
+ const fromMime = extensionFromMediaType(mediaType);
42
+ if (fromMime) return fromMime;
43
+ }
44
+ return fallback;
45
+ }
46
+ //#endregion
47
+ export { resolveFileExtension as i, extensionFromMediaType as n, mediaTypeFromPath as r, allExtensionsFromMediaType as t };
48
+
49
+ //# sourceMappingURL=content-type-CORxaxcv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-type-CORxaxcv.js","names":[],"sources":["../src/shared/content-type.ts"],"sourcesContent":["import { isString, trimStart } from 'es-toolkit'\nimport mime from 'mime'\n\n/** Last path segment after `/`. */\nfunction baseName(key: string): string {\n\tconst i = key.lastIndexOf('/')\n\treturn i === -1 ? key : key.slice(i + 1)\n}\n\n/** Extension including leading `.` (empty if none). Posix object-key semantics. */\nfunction extName(key: string): string {\n\tconst base = baseName(key)\n\tconst i = base.lastIndexOf('.')\n\treturn i > 0 ? base.slice(i) : ''\n}\n\n/** MIME type for a path or extension, or `undefined` when unknown. */\nexport function mediaTypeFromPath(pathOrExtension: string): string | undefined {\n\treturn mime.getType(pathOrExtension) ?? undefined\n}\n\n/** Preferred file extension for a MIME type (charset stripped), or `undefined` when unknown. */\nexport function extensionFromMediaType(type: string): string | undefined {\n\treturn mime.getExtension(type) ?? undefined\n}\n\n/** All known extensions for a MIME type. */\nexport function allExtensionsFromMediaType(type: string): readonly string[] {\n\tconst set = mime.getAllExtensions(type)\n\treturn [...(set ?? [])]\n}\n\n/**\n * Resolve an upload filename extension: prefer path ext, then bare format\n * (`pdf`), then `mime.getExtension(mediaType)`, else fallback.\n */\nexport function resolveFileExtension(options: {\n\tfilename?: string | undefined\n\tmediaType?: string | undefined\n\tfallback?: string\n}): string {\n\tconst fallback = options.fallback ?? 'bin'\n\tconst filename = options.filename\n\tif (isString(filename) && filename.length > 0) {\n\t\tconst ext = extName(filename)\n\t\tif (ext.length > 1) return trimStart(ext, '.').toLowerCase()\n\t}\n\n\tconst mediaType = options.mediaType\n\tif (isString(mediaType) && mediaType.length > 0) {\n\t\tif (!mediaType.includes('/')) return mediaType.toLowerCase()\n\t\tconst fromMime = extensionFromMediaType(mediaType)\n\t\tif (fromMime) return fromMime\n\t}\n\n\treturn fallback\n}\n\n/** Replace or append the extension of an object key (posix path semantics). */\nexport function deriveOutputKey(sourceKey: string, outputFormat: string, outputKey: string | undefined): string {\n\tif (isString(outputKey) && outputKey.length > 0) return outputKey\n\n\tconst ext = trimStart(outputFormat, '.').toLowerCase()\n\tconst slash = sourceKey.lastIndexOf('/')\n\tconst dir = slash === -1 ? '' : sourceKey.slice(0, slash + 1)\n\tconst stem = baseName(sourceKey)\n\tconst stemExt = extName(stem)\n\tconst base = stemExt.length > 0 ? stem.slice(0, -stemExt.length) : stem\n\treturn `${dir}${base}.${ext}`\n}\n"],"mappings":";;;;AAIA,SAAS,SAAS,KAAqB;CACtC,MAAM,IAAI,IAAI,YAAY,GAAG;CAC7B,OAAO,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,CAAC;AACxC;;AAGA,SAAS,QAAQ,KAAqB;CACrC,MAAM,OAAO,SAAS,GAAG;CACzB,MAAM,IAAI,KAAK,YAAY,GAAG;CAC9B,OAAO,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI;AAChC;;AAGA,SAAgB,kBAAkB,iBAA6C;CAC9E,OAAO,KAAK,QAAQ,eAAe,KAAK,KAAA;AACzC;;AAGA,SAAgB,uBAAuB,MAAkC;CACxE,OAAO,KAAK,aAAa,IAAI,KAAK,KAAA;AACnC;;AAGA,SAAgB,2BAA2B,MAAiC;CAE3E,OAAO,CAAC,GADI,KAAK,iBAAiB,IACpB,KAAK,CAAC,CAAE;AACvB;;;;;AAMA,SAAgB,qBAAqB,SAI1B;CACV,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,WAAW,QAAQ;CACzB,IAAI,SAAS,QAAQ,KAAK,SAAS,SAAS,GAAG;EAC9C,MAAM,MAAM,QAAQ,QAAQ;EAC5B,IAAI,IAAI,SAAS,GAAG,OAAO,UAAU,KAAK,GAAG,CAAC,CAAC,YAAY;CAC5D;CAEA,MAAM,YAAY,QAAQ;CAC1B,IAAI,SAAS,SAAS,KAAK,UAAU,SAAS,GAAG;EAChD,IAAI,CAAC,UAAU,SAAS,GAAG,GAAG,OAAO,UAAU,YAAY;EAC3D,MAAM,WAAW,uBAAuB,SAAS;EACjD,IAAI,UAAU,OAAO;CACtB;CAEA,OAAO;AACR"}
@@ -0,0 +1,4 @@
1
+ import { a as ModuleDefinition, c as ToolExecute, d as ToolHookToolRef, f as ToolHooks, g as ToolSource, h as ToolSideEffect, i as ModuleClassification, m as ToolRuntime, n as AuthDefinition, o as ToolContext, p as ToolMeta, r as FetchLike, s as ToolDefinition, t as ArtifactHookEvent, u as ToolHookEvent } from "../types-Ccb0DXY9.js";
2
+ import { A as assertContracts, B as ExceptToolsFilter, C as defineTool, D as toToolCatalogEntry, E as toModuleCatalogEntry, F as bindModule, G as exceptTools, H as OnlyToolsFilter, I as bindTool, K as filterModuleTools, L as toolRef, M as validateTool, N as mergeToolContext, O as ContractIssue, P as BindModuleOptions, R as withHooks, S as defineModule, T as ToolCatalogEntry, U as ToolIdFilter, V as ModuleToolId, W as ToolSelection, _ as logoForModuleId, a as withAuthTool, b as DefineToolOptions, c as firstDuplicateBy, d as resolveTools, f as ProviderAuthBase, g as resolveProvider, h as requireAuth, i as withAuth, j as validateModule, k as ContractResult, l as filterToolsByRuntime, m as defineProvider, n as listTools, o as assertUniqueBy, p as ProviderDefinition, q as onlyTools, r as runTool, s as duplicatesBy, t as WithAuthOptions, u as isToolArray, v as packLogosByModuleId, w as ModuleCatalogEntry, x as asAnyTool, y as DefineModuleOptions, z as withHooksTool } from "../index-CZX5OeOF.js";
3
+ import { i as isToolError, n as ToolErrorCode, r as ToolErrorOptions, t as ToolError } from "../errors-aKhko9T1.js";
4
+ export { type ArtifactHookEvent, type AuthDefinition, type BindModuleOptions, type ContractIssue, type ContractResult, type DefineModuleOptions, type DefineToolOptions, type ExceptToolsFilter, type FetchLike, type ModuleCatalogEntry, type ModuleClassification, type ModuleDefinition, type ModuleToolId, type OnlyToolsFilter, type ProviderAuthBase, type ProviderDefinition, type ToolCatalogEntry, type ToolContext, type ToolDefinition, ToolError, type ToolErrorCode, type ToolErrorOptions, type ToolExecute, type ToolHookEvent, type ToolHookToolRef, type ToolHooks, type ToolIdFilter, type ToolMeta, type ToolRuntime, type ToolSelection, type ToolSideEffect, type ToolSource, type WithAuthOptions, asAnyTool, assertContracts, assertUniqueBy, bindModule, bindTool, defineModule, defineProvider, defineTool, duplicatesBy, exceptTools, filterModuleTools, filterToolsByRuntime, firstDuplicateBy, isToolArray, isToolError, listTools, logoForModuleId, mergeToolContext, onlyTools, packLogosByModuleId, requireAuth, resolveProvider, resolveTools, runTool, toModuleCatalogEntry, toToolCatalogEntry, toolRef, validateModule, validateTool, withAuth, withAuthTool, withHooks, withHooksTool };
@@ -0,0 +1,204 @@
1
+ import { a as filterToolsByRuntime, c as toolRef, d as exceptTools, f as filterModuleTools, i as withAuthTool, l as withHooks, m as mergeToolContext, n as runTool, o as isToolArray, p as onlyTools, r as withAuth, s as resolveTools, t as listTools, u as withHooksTool } from "../with-auth-CpKqTrGK.js";
2
+ import { n as isToolError, t as ToolError } from "../errors-DoSpNHvs.js";
3
+ import { n as duplicatesBy, r as firstDuplicateBy, t as assertUniqueBy } from "../unique-EwBH1JPB.js";
4
+ import { a as packLogosByModuleId, i as logoForModuleId, n as defineModule, r as defineTool, t as asAnyTool } from "../define-CvpJ_pNP.js";
5
+ import { n as requireAuth, r as resolveProvider, t as defineProvider } from "../provider-CgDAlg6K.js";
6
+ import { flatMap, isPlainObject, isString } from "es-toolkit";
7
+ import { isArray } from "es-toolkit/compat";
8
+ import { toJSONSchema } from "zod";
9
+ //#region src/core/bind.ts
10
+ /**
11
+ * Per-invocation auth/context bind for multi-tenant hosts.
12
+ */
13
+ function assertAuth(auth, value) {
14
+ if (auth.type === "none") {
15
+ if (value !== void 0) throw new ToolError("This tool does not accept auth", { code: "bad_auth" });
16
+ return;
17
+ }
18
+ const parsed = auth.schema.safeParse(value);
19
+ if (!parsed.success) throw new ToolError("Invalid auth credentials", {
20
+ code: "bad_auth",
21
+ details: { issues: parsed.error.issues.map((i) => i.message) }
22
+ });
23
+ return parsed.data;
24
+ }
25
+ async function resolveBoundContext(moduleAuth, incoming, options) {
26
+ const base = options.resolveContext ? mergeToolContext(incoming, await options.resolveContext(incoming)) : { ...incoming };
27
+ if (moduleAuth.type === "none") return base;
28
+ if (!options.resolveAuth) throw new ToolError("resolveAuth is required for modules that declare auth", { code: "bad_auth" });
29
+ const auth = assertAuth(moduleAuth, await options.resolveAuth(base));
30
+ return {
31
+ ...base,
32
+ ...auth !== void 0 && { auth }
33
+ };
34
+ }
35
+ function bindTool(tool, moduleAuth, options) {
36
+ const previous = tool.execution ?? { run: tool.execute };
37
+ const bindContext = async (ctx) => {
38
+ return resolveBoundContext(moduleAuth, previous.bindContext ? await previous.bindContext(ctx) : ctx, options);
39
+ };
40
+ const execution = {
41
+ ...previous,
42
+ bindContext,
43
+ ...options.hooks && { hooks: options.hooks }
44
+ };
45
+ return {
46
+ ...tool,
47
+ execution,
48
+ execute: async (input, ctx) => execution.run(input, await bindContext(ctx))
49
+ };
50
+ }
51
+ function bindModule(module, options) {
52
+ if (module.auth.type !== "none" && !options.resolveAuth) throw new ToolError(`Module ${module.id} requires resolveAuth`, { code: "bad_auth" });
53
+ const scoped = options.tools !== void 0 ? filterModuleTools(module, options.tools) : module;
54
+ return {
55
+ ...scoped,
56
+ tools: scoped.tools.map((tool) => bindTool(tool, scoped.auth, options))
57
+ };
58
+ }
59
+ //#endregion
60
+ //#region src/generated/module-keys.ts
61
+ /** Capability seams under src/modules (brand-neutral model copy). */
62
+ const moduleSeamKeys = [
63
+ "artifacts",
64
+ "browser",
65
+ "calendar",
66
+ "code-sandbox",
67
+ "content-type",
68
+ "crypto",
69
+ "document",
70
+ "document-extract",
71
+ "document-render",
72
+ "email",
73
+ "email-message",
74
+ "file-convert",
75
+ "files",
76
+ "image",
77
+ "messaging",
78
+ "pdf",
79
+ "presentation",
80
+ "queue",
81
+ "rag",
82
+ "scheduler",
83
+ "skills",
84
+ "tasks",
85
+ "vector-store",
86
+ "web-fetch"
87
+ ];
88
+ //#endregion
89
+ //#region src/core/contracts.ts
90
+ const FORBIDDEN_MODEL_COPY = /\b(api[_ ]?key|apiKey|bearer token|process\.env|vault|secret key|authorization header|withAuth)\b/i;
91
+ /**
92
+ * Brand / vendor product names banned on **capability seam** model-facing copy
93
+ * (module + tool description and input .describe()). Vendors may name their product.
94
+ * Keep list brand-focused; avoid bare words like "teams" that appear in normal English.
95
+ */
96
+ const FORBIDDEN_SEAM_BRAND_COPY = /\b(Telegram|Slack|iMessage|Resend|Cloudflare|Textract|Gotenberg|Pinecone|Qdrant|Supabase|WooCommerce|Katana|Amazon|Bot Framework|Microsoft Teams|Photon|Spectrum|Mastra|PgVector|OpenAI)\b|\bS3\b|\bR2\b/;
97
+ /** Seam module ids from codegen (`src/modules/*` only — not hand-maintained). */
98
+ const SEAM_MODULE_IDS = new Set(moduleSeamKeys);
99
+ const KEBAB_ID = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
100
+ function issue(path, code, message) {
101
+ return {
102
+ path,
103
+ code,
104
+ message
105
+ };
106
+ }
107
+ function checkModelCopy(path, text, issues, options = {}) {
108
+ const trimmed = text.trim();
109
+ if (!trimmed) {
110
+ issues.push(issue(path, "empty_description", "Model-facing description is empty"));
111
+ return;
112
+ }
113
+ if (FORBIDDEN_MODEL_COPY.test(trimmed)) issues.push(issue(path, "forbidden_model_copy", "Model-facing copy must not mention credentials, env vars, vaults, or host wiring"));
114
+ if (options.seam && FORBIDDEN_SEAM_BRAND_COPY.test(trimmed)) issues.push(issue(path, "forbidden_model_copy", "Seam model-facing copy must not name vendors or products (use channel / bound store / provider-neutral language)"));
115
+ }
116
+ function fieldDescribes(schema, path, issues, options = {}) {
117
+ checkFieldDescriptions(toJSONSchema(schema), `${path}.input`, issues, options);
118
+ }
119
+ function checkFieldDescriptions(schema, path, issues, options) {
120
+ if (!isPlainObject(schema)) return;
121
+ const properties = schema["properties"];
122
+ if (isPlainObject(properties)) for (const [key, value] of Object.entries(properties)) {
123
+ if (!isPlainObject(value)) continue;
124
+ const fieldPath = `${path}.${key}`;
125
+ const description = value["description"];
126
+ if (!isString(description) || description.trim().length === 0) issues.push(issue(fieldPath, "empty_field_description", `Input field "${key}" is missing a .describe() for the model`));
127
+ else checkModelCopy(fieldPath, description, issues, options);
128
+ checkFieldDescriptions(value, fieldPath, issues, options);
129
+ }
130
+ for (const [key, value] of Object.entries(schema)) {
131
+ if (key === "properties") continue;
132
+ if (isArray(value)) {
133
+ for (const [index, item] of value.entries()) checkFieldDescriptions(item, `${path}.${key}[${index}]`, issues, options);
134
+ continue;
135
+ }
136
+ checkFieldDescriptions(value, `${path}.${key}`, issues, options);
137
+ }
138
+ }
139
+ function validateTool(tool, pathPrefix = tool.id, options = {}) {
140
+ const issues = [];
141
+ if (!tool.id.trim() || !KEBAB_ID.test(tool.id)) issues.push(issue(`${pathPrefix}.id`, "invalid_tool_id", `Tool id must be kebab-case (got "${tool.id}")`));
142
+ if (!tool.name.trim()) issues.push(issue(`${pathPrefix}.name`, "missing_name", "Tool name is required"));
143
+ checkModelCopy(`${pathPrefix}.description`, tool.description, issues, options);
144
+ fieldDescribes(tool.inputSchema, pathPrefix, issues, options);
145
+ return {
146
+ ok: issues.length === 0,
147
+ issues
148
+ };
149
+ }
150
+ function validateModule(module) {
151
+ const issues = [];
152
+ const copyOpts = SEAM_MODULE_IDS.has(module.id) ? { seam: true } : {};
153
+ checkModelCopy(`module.${module.id}.description`, module.description, issues, copyOpts);
154
+ for (const id of duplicatesBy(module.tools, (tool) => tool.id)) issues.push(issue(`module.${module.id}.tools.${id}`, "duplicate_tool_id", `Duplicate tool id "${id}"`));
155
+ issues.push(...flatMap(module.tools, (tool) => validateTool(tool, `module.${module.id}.tools.${tool.id}`, copyOpts).issues));
156
+ return {
157
+ ok: issues.length === 0,
158
+ issues
159
+ };
160
+ }
161
+ function assertContracts(result, label = "contract") {
162
+ if (result.ok) return;
163
+ const detail = result.issues.map((i) => `${i.path}: ${i.message}`).join("\n");
164
+ throw new Error(`${label} failed:\n${detail}`);
165
+ }
166
+ //#endregion
167
+ //#region src/core/catalog.ts
168
+ function toToolCatalogEntry(tool) {
169
+ return {
170
+ id: tool.id,
171
+ name: tool.name,
172
+ description: tool.description,
173
+ runtime: tool.meta.runtime,
174
+ sideEffect: tool.meta.sideEffect,
175
+ tags: tool.meta.tags ?? [],
176
+ idempotent: tool.meta.idempotent,
177
+ longRunning: tool.meta.longRunning,
178
+ requiresConfirmation: tool.meta.requiresConfirmation,
179
+ supportsCancel: tool.meta.supportsCancel,
180
+ supportsProgress: tool.meta.supportsProgress,
181
+ network: tool.meta.network,
182
+ artifacts: tool.meta.artifacts,
183
+ inputJsonSchema: toJSONSchema(tool.inputSchema),
184
+ outputJsonSchema: toJSONSchema(tool.outputSchema)
185
+ };
186
+ }
187
+ function toModuleCatalogEntry(module) {
188
+ return {
189
+ id: module.id,
190
+ title: module.title,
191
+ description: module.description,
192
+ runtime: module.runtime,
193
+ authType: module.auth.type,
194
+ tools: module.tools.map(toToolCatalogEntry),
195
+ categories: module.categories,
196
+ tags: module.tags ?? [],
197
+ ...module.classification !== void 0 && { classification: module.classification },
198
+ ...module.logo !== void 0 && { logo: module.logo }
199
+ };
200
+ }
201
+ //#endregion
202
+ export { ToolError, asAnyTool, assertContracts, assertUniqueBy, bindModule, bindTool, defineModule, defineProvider, defineTool, duplicatesBy, exceptTools, filterModuleTools, filterToolsByRuntime, firstDuplicateBy, isToolArray, isToolError, listTools, logoForModuleId, mergeToolContext, onlyTools, packLogosByModuleId, requireAuth, resolveProvider, resolveTools, runTool, toModuleCatalogEntry, toToolCatalogEntry, toolRef, validateModule, validateTool, withAuth, withAuthTool, withHooks, withHooksTool };
203
+
204
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/core/bind.ts","../../src/generated/module-keys.ts","../../src/core/contracts.ts","../../src/core/catalog.ts"],"sourcesContent":["/**\n * Per-invocation auth/context bind for multi-tenant hosts.\n */\n\nimport { mergeToolContext } from './context'\nimport type { ToolSelection } from './filter-tools'\nimport { filterModuleTools } from './filter-tools'\nimport type { ToolHooks } from './hooks'\nimport { ToolError } from './errors'\nimport type { AuthDefinition, ModuleDefinition, ToolContext, ToolDefinition, ToolExecution } from './types'\n\nfunction assertAuth<TAuth>(auth: AuthDefinition<TAuth>, value: unknown): TAuth | undefined {\n\tif (auth.type === 'none') {\n\t\tif (value !== undefined) throw new ToolError('This tool does not accept auth', { code: 'bad_auth' })\n\t\treturn undefined\n\t}\n\tconst parsed = auth.schema.safeParse(value)\n\tif (!parsed.success) {\n\t\tthrow new ToolError('Invalid auth credentials', {\n\t\t\tcode: 'bad_auth',\n\t\t\tdetails: { issues: parsed.error.issues.map((i) => i.message) }\n\t\t})\n\t}\n\treturn parsed.data\n}\n\nexport type BindModuleOptions<TAuth = unknown> = {\n\tresolveAuth?: (ctx: ToolContext) => TAuth | Promise<TAuth>\n\tresolveContext?: (ctx: ToolContext) => ToolContext | Promise<ToolContext>\n\thooks?: ToolHooks\n\t/**\n\t * Restrict the tool surface after bind.\n\t * Prefer composable `onlyTools` / `exceptTools` when filtering outside bind.\n\t */\n\ttools?: ToolSelection\n}\n\nasync function resolveBoundContext<TAuth>(\n\tmoduleAuth: AuthDefinition<TAuth>,\n\tincoming: ToolContext,\n\toptions: BindModuleOptions<TAuth>\n): Promise<ToolContext> {\n\tconst base = options.resolveContext\n\t\t? mergeToolContext(incoming, await options.resolveContext(incoming))\n\t\t: { ...incoming }\n\tif (moduleAuth.type === 'none') return base\n\tif (!options.resolveAuth) {\n\t\tthrow new ToolError('resolveAuth is required for modules that declare auth', { code: 'bad_auth' })\n\t}\n\tconst auth = assertAuth(moduleAuth, await options.resolveAuth(base))\n\treturn {\n\t\t...base,\n\t\t...(auth !== undefined && { auth })\n\t}\n}\n\nexport function bindTool<TInput, TOutput, TAuth = unknown>(\n\ttool: ToolDefinition<TInput, TOutput>,\n\tmoduleAuth: AuthDefinition<TAuth>,\n\toptions: BindModuleOptions<TAuth>\n): ToolDefinition<TInput, TOutput> {\n\tconst previous = tool.execution ?? { run: tool.execute }\n\tconst bindContext = async (ctx: ToolContext): Promise<ToolContext> => {\n\t\tconst base = previous.bindContext ? await previous.bindContext(ctx) : ctx\n\t\treturn resolveBoundContext(moduleAuth, base, options)\n\t}\n\tconst execution: ToolExecution = {\n\t\t...previous,\n\t\tbindContext,\n\t\t...(options.hooks && { hooks: options.hooks })\n\t}\n\treturn {\n\t\t...tool,\n\t\texecution,\n\t\texecute: async (input, ctx) => execution.run(input, await bindContext(ctx))\n\t}\n}\n\nexport function bindModule<TAuth>(\n\tmodule: ModuleDefinition<TAuth>,\n\toptions: BindModuleOptions<TAuth>\n): ModuleDefinition<TAuth> {\n\tif (module.auth.type !== 'none' && !options.resolveAuth) {\n\t\tthrow new ToolError(`Module ${module.id} requires resolveAuth`, { code: 'bad_auth' })\n\t}\n\tconst scoped = options.tools !== undefined ? filterModuleTools(module, options.tools) : module\n\treturn {\n\t\t...scoped,\n\t\ttools: scoped.tools.map((tool) => bindTool(tool, scoped.auth, options))\n\t}\n}\n","// AUTO-GENERATED by `bun run codegen`. Do not edit by hand.\n/** Flat public export keys under src/{modules,vendors}. */\nexport const moduleKeys = [\n\t'amazon-sp-api',\n\t'artifacts',\n\t'bedrock-agentcore-browser',\n\t'bedrock-agentcore-code-interpreter',\n\t'browser',\n\t'calendar',\n\t'cloudflare-browser',\n\t'cloudflare-email',\n\t'cloudflare-sandbox',\n\t'code-sandbox',\n\t'content-type',\n\t'crypto',\n\t'document',\n\t'document-extract',\n\t'document-render',\n\t'email',\n\t'email-message',\n\t'eventbridge-scheduler',\n\t'file-convert',\n\t'files',\n\t'gotenberg',\n\t'image',\n\t'imessage',\n\t'katana',\n\t'mastra-vector',\n\t'messaging',\n\t'pdf',\n\t'pinecone',\n\t'presentation',\n\t'qdrant',\n\t'queue',\n\t'rag',\n\t'resend',\n\t's3',\n\t'scheduler',\n\t'skills',\n\t'slack',\n\t'sqs',\n\t'supabase-vector',\n\t'tasks',\n\t'teams',\n\t'telegram',\n\t'textract',\n\t'vector-store',\n\t'web-fetch',\n\t'woocommerce'\n] as const\n\nexport type ModuleKey = (typeof moduleKeys)[number]\n\n/** Capability seams under src/modules (brand-neutral model copy). */\nexport const moduleSeamKeys = [\n\t'artifacts',\n\t'browser',\n\t'calendar',\n\t'code-sandbox',\n\t'content-type',\n\t'crypto',\n\t'document',\n\t'document-extract',\n\t'document-render',\n\t'email',\n\t'email-message',\n\t'file-convert',\n\t'files',\n\t'image',\n\t'messaging',\n\t'pdf',\n\t'presentation',\n\t'queue',\n\t'rag',\n\t'scheduler',\n\t'skills',\n\t'tasks',\n\t'vector-store',\n\t'web-fetch'\n] as const\n\nexport type ModuleSeamKey = (typeof moduleSeamKeys)[number]\n","import { flatMap, isPlainObject, isString } from 'es-toolkit'\nimport { isArray } from 'es-toolkit/compat'\nimport { toJSONSchema } from 'zod'\n\nimport { moduleSeamKeys } from '../generated/module-keys'\nimport type { ModuleDefinition, ToolDefinition } from './types'\nimport { duplicatesBy } from './unique'\n\nconst FORBIDDEN_MODEL_COPY =\n\t/\\b(api[_ ]?key|apiKey|bearer token|process\\.env|vault|secret key|authorization header|withAuth)\\b/i\n\n/**\n * Brand / vendor product names banned on **capability seam** model-facing copy\n * (module + tool description and input .describe()). Vendors may name their product.\n * Keep list brand-focused; avoid bare words like \"teams\" that appear in normal English.\n */\nconst FORBIDDEN_SEAM_BRAND_COPY =\n\t/\\b(Telegram|Slack|iMessage|Resend|Cloudflare|Textract|Gotenberg|Pinecone|Qdrant|Supabase|WooCommerce|Katana|Amazon|Bot Framework|Microsoft Teams|Photon|Spectrum|Mastra|PgVector|OpenAI)\\b|\\bS3\\b|\\bR2\\b/\n\n/** Seam module ids from codegen (`src/modules/*` only — not hand-maintained). */\nconst SEAM_MODULE_IDS = new Set<string>(moduleSeamKeys)\n\nconst KEBAB_ID = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/\n\nexport type ContractIssue = {\n\tcode:\n\t\t| 'duplicate_tool_id'\n\t\t| 'empty_description'\n\t\t| 'empty_field_description'\n\t\t| 'forbidden_model_copy'\n\t\t| 'invalid_tool_id'\n\t\t| 'missing_name'\n\tmessage: string\n\tpath: string\n}\n\nexport type ContractResult = {\n\tok: boolean\n\tissues: ContractIssue[]\n}\n\nexport type CheckModelCopyOptions = {\n\t/** When true, also ban vendor brand names (capability seams). */\n\tseam?: boolean\n}\n\nfunction issue(path: string, code: ContractIssue['code'], message: string): ContractIssue {\n\treturn { path, code, message }\n}\n\nfunction checkModelCopy(\n\tpath: string,\n\ttext: string,\n\tissues: ContractIssue[],\n\toptions: CheckModelCopyOptions = {}\n): void {\n\tconst trimmed = text.trim()\n\tif (!trimmed) {\n\t\tissues.push(issue(path, 'empty_description', 'Model-facing description is empty'))\n\t\treturn\n\t}\n\tif (FORBIDDEN_MODEL_COPY.test(trimmed)) {\n\t\tissues.push(\n\t\t\tissue(\n\t\t\t\tpath,\n\t\t\t\t'forbidden_model_copy',\n\t\t\t\t'Model-facing copy must not mention credentials, env vars, vaults, or host wiring'\n\t\t\t)\n\t\t)\n\t}\n\tif (options.seam && FORBIDDEN_SEAM_BRAND_COPY.test(trimmed)) {\n\t\tissues.push(\n\t\t\tissue(\n\t\t\t\tpath,\n\t\t\t\t'forbidden_model_copy',\n\t\t\t\t'Seam model-facing copy must not name vendors or products (use channel / bound store / provider-neutral language)'\n\t\t\t)\n\t\t)\n\t}\n}\n\nfunction fieldDescribes(\n\tschema: ToolDefinition['inputSchema'],\n\tpath: string,\n\tissues: ContractIssue[],\n\toptions: CheckModelCopyOptions = {}\n): void {\n\tcheckFieldDescriptions(toJSONSchema(schema), `${path}.input`, issues, options)\n}\n\nfunction checkFieldDescriptions(\n\tschema: unknown,\n\tpath: string,\n\tissues: ContractIssue[],\n\toptions: CheckModelCopyOptions\n): void {\n\tif (!isPlainObject(schema)) return\n\tconst properties = schema['properties']\n\tif (isPlainObject(properties)) {\n\t\tfor (const [key, value] of Object.entries(properties)) {\n\t\t\tif (!isPlainObject(value)) continue\n\t\t\tconst fieldPath = `${path}.${key}`\n\t\t\tconst description = value['description']\n\t\t\tif (!isString(description) || description.trim().length === 0) {\n\t\t\t\tissues.push(\n\t\t\t\t\tissue(fieldPath, 'empty_field_description', `Input field \"${key}\" is missing a .describe() for the model`)\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tcheckModelCopy(fieldPath, description, issues, options)\n\t\t\t}\n\t\t\tcheckFieldDescriptions(value, fieldPath, issues, options)\n\t\t}\n\t}\n\n\tfor (const [key, value] of Object.entries(schema)) {\n\t\tif (key === 'properties') continue\n\t\tif (isArray(value)) {\n\t\t\tfor (const [index, item] of value.entries()) {\n\t\t\t\tcheckFieldDescriptions(item, `${path}.${key}[${index}]`, issues, options)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tcheckFieldDescriptions(value, `${path}.${key}`, issues, options)\n\t}\n}\n\nexport function validateTool(\n\ttool: ToolDefinition,\n\tpathPrefix = tool.id,\n\toptions: CheckModelCopyOptions = {}\n): ContractResult {\n\tconst issues: ContractIssue[] = []\n\n\tif (!tool.id.trim() || !KEBAB_ID.test(tool.id)) {\n\t\tissues.push(issue(`${pathPrefix}.id`, 'invalid_tool_id', `Tool id must be kebab-case (got \"${tool.id}\")`))\n\t}\n\tif (!tool.name.trim()) {\n\t\tissues.push(issue(`${pathPrefix}.name`, 'missing_name', 'Tool name is required'))\n\t}\n\tcheckModelCopy(`${pathPrefix}.description`, tool.description, issues, options)\n\tfieldDescribes(tool.inputSchema, pathPrefix, issues, options)\n\n\treturn { ok: issues.length === 0, issues }\n}\n\nexport function validateModule(module: ModuleDefinition): ContractResult {\n\tconst issues: ContractIssue[] = []\n\tconst seam = SEAM_MODULE_IDS.has(module.id)\n\tconst copyOpts: CheckModelCopyOptions = seam ? { seam: true } : {}\n\n\tcheckModelCopy(`module.${module.id}.description`, module.description, issues, copyOpts)\n\n\tfor (const id of duplicatesBy(module.tools, (tool) => tool.id)) {\n\t\tissues.push(issue(`module.${module.id}.tools.${id}`, 'duplicate_tool_id', `Duplicate tool id \"${id}\"`))\n\t}\n\n\tissues.push(\n\t\t...flatMap(module.tools, (tool) => validateTool(tool, `module.${module.id}.tools.${tool.id}`, copyOpts).issues)\n\t)\n\n\treturn { ok: issues.length === 0, issues }\n}\n\nexport function assertContracts(result: ContractResult, label = 'contract'): void {\n\tif (result.ok) return\n\tconst detail = result.issues.map((i) => `${i.path}: ${i.message}`).join('\\n')\n\tthrow new Error(`${label} failed:\\n${detail}`)\n}\n","import { toJSONSchema } from 'zod'\n\nimport type { AuthDefinition, ModuleDefinition, ToolDefinition } from './types'\n\nexport type ToolCatalogEntry = {\n\tdescription: string\n\tid: string\n\tinputJsonSchema: Record<string, unknown>\n\tname: string\n\toutputJsonSchema: Record<string, unknown>\n\truntime: ToolDefinition['meta']['runtime']\n\tsideEffect: ToolDefinition['meta']['sideEffect']\n\ttags: readonly string[]\n\tidempotent?: boolean | undefined\n\tlongRunning?: boolean | undefined\n\trequiresConfirmation?: boolean | undefined\n\tsupportsCancel?: boolean | undefined\n\tsupportsProgress?: boolean | undefined\n\tnetwork?: boolean | undefined\n\tartifacts?: boolean | undefined\n}\n\nexport type ModuleCatalogEntry = {\n\tauthType: AuthDefinition<unknown>['type']\n\tdescription: string\n\tid: string\n\truntime: ModuleDefinition['runtime']\n\ttitle: string\n\ttools: ToolCatalogEntry[]\n\t/** Inline SVG when the pack has a logo. */\n\tlogo?: string | undefined\n\tcategories: readonly string[]\n\tclassification?: ModuleDefinition['classification']\n\ttags: readonly string[]\n}\n\nexport function toToolCatalogEntry(tool: ToolDefinition): ToolCatalogEntry {\n\treturn {\n\t\tid: tool.id,\n\t\tname: tool.name,\n\t\tdescription: tool.description,\n\t\truntime: tool.meta.runtime,\n\t\tsideEffect: tool.meta.sideEffect,\n\t\ttags: tool.meta.tags ?? [],\n\t\tidempotent: tool.meta.idempotent,\n\t\tlongRunning: tool.meta.longRunning,\n\t\trequiresConfirmation: tool.meta.requiresConfirmation,\n\t\tsupportsCancel: tool.meta.supportsCancel,\n\t\tsupportsProgress: tool.meta.supportsProgress,\n\t\tnetwork: tool.meta.network,\n\t\tartifacts: tool.meta.artifacts,\n\t\tinputJsonSchema: toJSONSchema(tool.inputSchema),\n\t\toutputJsonSchema: toJSONSchema(tool.outputSchema)\n\t}\n}\n\nexport function toModuleCatalogEntry(module: ModuleDefinition): ModuleCatalogEntry {\n\treturn {\n\t\tid: module.id,\n\t\ttitle: module.title,\n\t\tdescription: module.description,\n\t\truntime: module.runtime,\n\t\tauthType: module.auth.type,\n\t\ttools: module.tools.map(toToolCatalogEntry),\n\t\tcategories: module.categories,\n\t\ttags: module.tags ?? [],\n\t\t...(module.classification !== undefined && { classification: module.classification }),\n\t\t...(module.logo !== undefined && { logo: module.logo })\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAS,WAAkB,MAA6B,OAAmC;CAC1F,IAAI,KAAK,SAAS,QAAQ;EACzB,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,UAAU,kCAAkC,EAAE,MAAM,WAAW,CAAC;EACnG;CACD;CACA,MAAM,SAAS,KAAK,OAAO,UAAU,KAAK;CAC1C,IAAI,CAAC,OAAO,SACX,MAAM,IAAI,UAAU,4BAA4B;EAC/C,MAAM;EACN,SAAS,EAAE,QAAQ,OAAO,MAAM,OAAO,KAAK,MAAM,EAAE,OAAO,EAAE;CAC9D,CAAC;CAEF,OAAO,OAAO;AACf;AAaA,eAAe,oBACd,YACA,UACA,SACuB;CACvB,MAAM,OAAO,QAAQ,iBAClB,iBAAiB,UAAU,MAAM,QAAQ,eAAe,QAAQ,CAAC,IACjE,EAAE,GAAG,SAAS;CACjB,IAAI,WAAW,SAAS,QAAQ,OAAO;CACvC,IAAI,CAAC,QAAQ,aACZ,MAAM,IAAI,UAAU,yDAAyD,EAAE,MAAM,WAAW,CAAC;CAElG,MAAM,OAAO,WAAW,YAAY,MAAM,QAAQ,YAAY,IAAI,CAAC;CACnE,OAAO;EACN,GAAG;EACH,GAAI,SAAS,KAAA,KAAa,EAAE,KAAK;CAClC;AACD;AAEA,SAAgB,SACf,MACA,YACA,SACkC;CAClC,MAAM,WAAW,KAAK,aAAa,EAAE,KAAK,KAAK,QAAQ;CACvD,MAAM,cAAc,OAAO,QAA2C;EAErE,OAAO,oBAAoB,YADd,SAAS,cAAc,MAAM,SAAS,YAAY,GAAG,IAAI,KACzB,OAAO;CACrD;CACA,MAAM,YAA2B;EAChC,GAAG;EACH;EACA,GAAI,QAAQ,SAAS,EAAE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