@ixo/oracle-runtime 0.0.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 (583) hide show
  1. package/dist/bootstrap/ambient-factory.d.ts +32 -0
  2. package/dist/bootstrap/ambient-factory.d.ts.map +1 -0
  3. package/dist/bootstrap/ambient-factory.js +128 -0
  4. package/dist/bootstrap/create-oracle-app.d.ts +112 -0
  5. package/dist/bootstrap/create-oracle-app.d.ts.map +1 -0
  6. package/dist/bootstrap/create-oracle-app.js +530 -0
  7. package/dist/bootstrap/graceful-shutdown.d.ts +20 -0
  8. package/dist/bootstrap/graceful-shutdown.d.ts.map +1 -0
  9. package/dist/bootstrap/graceful-shutdown.js +61 -0
  10. package/dist/bootstrap/index.d.ts +13 -0
  11. package/dist/bootstrap/index.d.ts.map +1 -0
  12. package/dist/bootstrap/index.js +6 -0
  13. package/dist/bootstrap/inspect.d.ts +74 -0
  14. package/dist/bootstrap/inspect.d.ts.map +1 -0
  15. package/dist/bootstrap/inspect.js +111 -0
  16. package/dist/bootstrap/plugin-loader.d.ts +50 -0
  17. package/dist/bootstrap/plugin-loader.d.ts.map +1 -0
  18. package/dist/bootstrap/plugin-loader.js +119 -0
  19. package/dist/bootstrap/runtime-app-module.d.ts +38 -0
  20. package/dist/bootstrap/runtime-app-module.d.ts.map +1 -0
  21. package/dist/bootstrap/runtime-app-module.js +114 -0
  22. package/dist/bootstrap/schema-composer.d.ts +46 -0
  23. package/dist/bootstrap/schema-composer.d.ts.map +1 -0
  24. package/dist/bootstrap/schema-composer.js +65 -0
  25. package/dist/config/base-env-config.d.ts +31 -0
  26. package/dist/config/base-env-config.d.ts.map +1 -0
  27. package/dist/config/base-env-config.js +70 -0
  28. package/dist/config/base-env-schema.d.ts +77 -0
  29. package/dist/config/base-env-schema.d.ts.map +1 -0
  30. package/dist/config/base-env-schema.js +102 -0
  31. package/dist/events/scoped-emitter.d.ts +33 -0
  32. package/dist/events/scoped-emitter.d.ts.map +1 -0
  33. package/dist/events/scoped-emitter.js +32 -0
  34. package/dist/graph/index.d.ts +8 -0
  35. package/dist/graph/index.d.ts.map +1 -0
  36. package/dist/graph/index.js +6 -0
  37. package/dist/graph/main-agent-types.d.ts +88 -0
  38. package/dist/graph/main-agent-types.d.ts.map +1 -0
  39. package/dist/graph/main-agent-types.js +20 -0
  40. package/dist/graph/main-agent.d.ts +16 -0
  41. package/dist/graph/main-agent.d.ts.map +1 -0
  42. package/dist/graph/main-agent.js +251 -0
  43. package/dist/graph/middlewares/capability-gate-middleware.d.ts +35 -0
  44. package/dist/graph/middlewares/capability-gate-middleware.d.ts.map +1 -0
  45. package/dist/graph/middlewares/capability-gate-middleware.js +54 -0
  46. package/dist/graph/middlewares/index.d.ts +7 -0
  47. package/dist/graph/middlewares/index.d.ts.map +1 -0
  48. package/dist/graph/middlewares/index.js +6 -0
  49. package/dist/graph/middlewares/page-context-middleware.d.ts +23 -0
  50. package/dist/graph/middlewares/page-context-middleware.d.ts.map +1 -0
  51. package/dist/graph/middlewares/page-context-middleware.js +68 -0
  52. package/dist/graph/middlewares/safety-guardrail-middleware.d.ts +26 -0
  53. package/dist/graph/middlewares/safety-guardrail-middleware.d.ts.map +1 -0
  54. package/dist/graph/middlewares/safety-guardrail-middleware.js +88 -0
  55. package/dist/graph/middlewares/summarization-middleware.d.ts +17 -0
  56. package/dist/graph/middlewares/summarization-middleware.d.ts.map +1 -0
  57. package/dist/graph/middlewares/summarization-middleware.js +62 -0
  58. package/dist/graph/middlewares/tool-repetition-guard-middleware.d.ts +24 -0
  59. package/dist/graph/middlewares/tool-repetition-guard-middleware.d.ts.map +1 -0
  60. package/dist/graph/middlewares/tool-repetition-guard-middleware.js +112 -0
  61. package/dist/graph/middlewares/tool-validation-middleware.d.ts +24 -0
  62. package/dist/graph/middlewares/tool-validation-middleware.d.ts.map +1 -0
  63. package/dist/graph/middlewares/tool-validation-middleware.js +61 -0
  64. package/dist/graph/prompt-composer.d.ts +69 -0
  65. package/dist/graph/prompt-composer.d.ts.map +1 -0
  66. package/dist/graph/prompt-composer.js +315 -0
  67. package/dist/graph/state.d.ts +65 -0
  68. package/dist/graph/state.d.ts.map +1 -0
  69. package/dist/graph/state.js +60 -0
  70. package/dist/graph/sub-agent-fallback.d.ts +56 -0
  71. package/dist/graph/sub-agent-fallback.d.ts.map +1 -0
  72. package/dist/graph/sub-agent-fallback.js +79 -0
  73. package/dist/graph/subagent-as-tool.d.ts +77 -0
  74. package/dist/graph/subagent-as-tool.d.ts.map +1 -0
  75. package/dist/graph/subagent-as-tool.js +197 -0
  76. package/dist/graph/wrap-plugin-tool.d.ts +28 -0
  77. package/dist/graph/wrap-plugin-tool.d.ts.map +1 -0
  78. package/dist/graph/wrap-plugin-tool.js +30 -0
  79. package/dist/index.d.ts +33 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +28 -0
  82. package/dist/llm/index.d.ts +2 -0
  83. package/dist/llm/index.d.ts.map +1 -0
  84. package/dist/llm/index.js +1 -0
  85. package/dist/llm/llm-provider.d.ts +41 -0
  86. package/dist/llm/llm-provider.d.ts.map +1 -0
  87. package/dist/llm/llm-provider.js +130 -0
  88. package/dist/manifest/index.d.ts +6 -0
  89. package/dist/manifest/index.d.ts.map +1 -0
  90. package/dist/manifest/index.js +3 -0
  91. package/dist/manifest/schema.d.ts +31 -0
  92. package/dist/manifest/schema.d.ts.map +1 -0
  93. package/dist/manifest/schema.js +44 -0
  94. package/dist/manifest/tier1-renderer.d.ts +31 -0
  95. package/dist/manifest/tier1-renderer.d.ts.map +1 -0
  96. package/dist/manifest/tier1-renderer.js +68 -0
  97. package/dist/manifest/validator.d.ts +34 -0
  98. package/dist/manifest/validator.d.ts.map +1 -0
  99. package/dist/manifest/validator.js +111 -0
  100. package/dist/matrix/checkpointer/matrix-upload-utils.d.ts +66 -0
  101. package/dist/matrix/checkpointer/matrix-upload-utils.d.ts.map +1 -0
  102. package/dist/matrix/checkpointer/matrix-upload-utils.js +228 -0
  103. package/dist/matrix/checkpointer/type.d.ts +4 -0
  104. package/dist/matrix/checkpointer/type.d.ts.map +1 -0
  105. package/dist/matrix/checkpointer/type.js +1 -0
  106. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.d.ts +3 -0
  107. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.d.ts.map +1 -0
  108. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.module.js +22 -0
  109. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.d.ts +93 -0
  110. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.d.ts.map +1 -0
  111. package/dist/matrix/checkpointer/user-matrix-sqlite-sync-service.service.js +856 -0
  112. package/dist/matrix/room-membership.d.ts +11 -0
  113. package/dist/matrix/room-membership.d.ts.map +1 -0
  114. package/dist/matrix/room-membership.js +33 -0
  115. package/dist/meta-tools/index.d.ts +28 -0
  116. package/dist/meta-tools/index.d.ts.map +1 -0
  117. package/dist/meta-tools/index.js +24 -0
  118. package/dist/meta-tools/list-capabilities.d.ts +12 -0
  119. package/dist/meta-tools/list-capabilities.d.ts.map +1 -0
  120. package/dist/meta-tools/list-capabilities.js +55 -0
  121. package/dist/meta-tools/load-capability.d.ts +24 -0
  122. package/dist/meta-tools/load-capability.d.ts.map +1 -0
  123. package/dist/meta-tools/load-capability.js +82 -0
  124. package/dist/modules/auth/auth-header.middleware.d.ts +37 -0
  125. package/dist/modules/auth/auth-header.middleware.d.ts.map +1 -0
  126. package/dist/modules/auth/auth-header.middleware.js +115 -0
  127. package/dist/modules/auth/auth.module.d.ts +9 -0
  128. package/dist/modules/auth/auth.module.d.ts.map +1 -0
  129. package/dist/modules/auth/auth.module.js +27 -0
  130. package/dist/modules/auth/index.d.ts +3 -0
  131. package/dist/modules/auth/index.d.ts.map +1 -0
  132. package/dist/modules/auth/index.js +2 -0
  133. package/dist/modules/auth/validate-ucan-delegation.d.ts +31 -0
  134. package/dist/modules/auth/validate-ucan-delegation.d.ts.map +1 -0
  135. package/dist/modules/auth/validate-ucan-delegation.js +36 -0
  136. package/dist/modules/blob-store/blob-store.module.d.ts +10 -0
  137. package/dist/modules/blob-store/blob-store.module.d.ts.map +1 -0
  138. package/dist/modules/blob-store/blob-store.module.js +25 -0
  139. package/dist/modules/blob-store/blob-store.service.d.ts +66 -0
  140. package/dist/modules/blob-store/blob-store.service.d.ts.map +1 -0
  141. package/dist/modules/blob-store/blob-store.service.js +108 -0
  142. package/dist/modules/blob-store/index.d.ts +3 -0
  143. package/dist/modules/blob-store/index.d.ts.map +1 -0
  144. package/dist/modules/blob-store/index.js +2 -0
  145. package/dist/modules/health/health.controller.d.ts +18 -0
  146. package/dist/modules/health/health.controller.d.ts.map +1 -0
  147. package/dist/modules/health/health.controller.js +48 -0
  148. package/dist/modules/health/health.module.d.ts +8 -0
  149. package/dist/modules/health/health.module.d.ts.map +1 -0
  150. package/dist/modules/health/health.module.js +21 -0
  151. package/dist/modules/index.d.ts +8 -0
  152. package/dist/modules/index.d.ts.map +1 -0
  153. package/dist/modules/index.js +6 -0
  154. package/dist/modules/messages/__test-fixtures__/deps.d.ts +41 -0
  155. package/dist/modules/messages/__test-fixtures__/deps.d.ts.map +1 -0
  156. package/dist/modules/messages/__test-fixtures__/deps.js +73 -0
  157. package/dist/modules/messages/__test-fixtures__/fake-agent.d.ts +27 -0
  158. package/dist/modules/messages/__test-fixtures__/fake-agent.d.ts.map +1 -0
  159. package/dist/modules/messages/__test-fixtures__/fake-agent.js +41 -0
  160. package/dist/modules/messages/__test-fixtures__/fake-response.d.ts +29 -0
  161. package/dist/modules/messages/__test-fixtures__/fake-response.d.ts.map +1 -0
  162. package/dist/modules/messages/__test-fixtures__/fake-response.js +55 -0
  163. package/dist/modules/messages/agent-builder.d.ts +64 -0
  164. package/dist/modules/messages/agent-builder.d.ts.map +1 -0
  165. package/dist/modules/messages/agent-builder.js +219 -0
  166. package/dist/modules/messages/batch-invoker.d.ts +36 -0
  167. package/dist/modules/messages/batch-invoker.d.ts.map +1 -0
  168. package/dist/modules/messages/batch-invoker.js +58 -0
  169. package/dist/modules/messages/dto/list-messages.dto.d.ts +4 -0
  170. package/dist/modules/messages/dto/list-messages.dto.d.ts.map +1 -0
  171. package/dist/modules/messages/dto/list-messages.dto.js +17 -0
  172. package/dist/modules/messages/dto/send-message.dto.d.ts +73 -0
  173. package/dist/modules/messages/dto/send-message.dto.d.ts.map +1 -0
  174. package/dist/modules/messages/dto/send-message.dto.js +318 -0
  175. package/dist/modules/messages/file-processing-credit-sink.port.d.ts +20 -0
  176. package/dist/modules/messages/file-processing-credit-sink.port.d.ts.map +1 -0
  177. package/dist/modules/messages/file-processing-credit-sink.port.js +1 -0
  178. package/dist/modules/messages/file-processing.service.d.ts +195 -0
  179. package/dist/modules/messages/file-processing.service.d.ts.map +1 -0
  180. package/dist/modules/messages/file-processing.service.js +1278 -0
  181. package/dist/modules/messages/homeserver-cache.d.ts +11 -0
  182. package/dist/modules/messages/homeserver-cache.d.ts.map +1 -0
  183. package/dist/modules/messages/homeserver-cache.js +31 -0
  184. package/dist/modules/messages/matrix-listener-bridge.d.ts +63 -0
  185. package/dist/modules/messages/matrix-listener-bridge.d.ts.map +1 -0
  186. package/dist/modules/messages/matrix-listener-bridge.js +280 -0
  187. package/dist/modules/messages/messages.controller.d.ts +13 -0
  188. package/dist/modules/messages/messages.controller.d.ts.map +1 -0
  189. package/dist/modules/messages/messages.controller.js +95 -0
  190. package/dist/modules/messages/messages.module.d.ts +3 -0
  191. package/dist/modules/messages/messages.module.d.ts.map +1 -0
  192. package/dist/modules/messages/messages.module.js +75 -0
  193. package/dist/modules/messages/messages.service.d.ts +112 -0
  194. package/dist/modules/messages/messages.service.d.ts.map +1 -0
  195. package/dist/modules/messages/messages.service.js +279 -0
  196. package/dist/modules/messages/oracle-runtime-bundle.d.ts +38 -0
  197. package/dist/modules/messages/oracle-runtime-bundle.d.ts.map +1 -0
  198. package/dist/modules/messages/oracle-runtime-bundle.js +40 -0
  199. package/dist/modules/messages/post-message-syncer.d.ts +30 -0
  200. package/dist/modules/messages/post-message-syncer.d.ts.map +1 -0
  201. package/dist/modules/messages/post-message-syncer.js +73 -0
  202. package/dist/modules/messages/request-preparer.d.ts +53 -0
  203. package/dist/modules/messages/request-preparer.d.ts.map +1 -0
  204. package/dist/modules/messages/request-preparer.js +139 -0
  205. package/dist/modules/messages/sse-stream-runner.d.ts +73 -0
  206. package/dist/modules/messages/sse-stream-runner.d.ts.map +1 -0
  207. package/dist/modules/messages/sse-stream-runner.js +352 -0
  208. package/dist/modules/messages/sse.utils.d.ts +29 -0
  209. package/dist/modules/messages/sse.utils.d.ts.map +1 -0
  210. package/dist/modules/messages/sse.utils.js +77 -0
  211. package/dist/modules/messages/user-context-fetcher.d.ts +41 -0
  212. package/dist/modules/messages/user-context-fetcher.d.ts.map +1 -0
  213. package/dist/modules/messages/user-context-fetcher.js +117 -0
  214. package/dist/modules/secrets/index.d.ts +2 -0
  215. package/dist/modules/secrets/index.d.ts.map +1 -0
  216. package/dist/modules/secrets/index.js +1 -0
  217. package/dist/modules/secrets/secrets.service.d.ts +29 -0
  218. package/dist/modules/secrets/secrets.service.d.ts.map +1 -0
  219. package/dist/modules/secrets/secrets.service.js +107 -0
  220. package/dist/modules/sessions/dto/create-session.dto.d.ts +6 -0
  221. package/dist/modules/sessions/dto/create-session.dto.d.ts.map +1 -0
  222. package/dist/modules/sessions/dto/create-session.dto.js +5 -0
  223. package/dist/modules/sessions/dto/delete-session.dto.d.ts +6 -0
  224. package/dist/modules/sessions/dto/delete-session.dto.d.ts.map +1 -0
  225. package/dist/modules/sessions/dto/delete-session.dto.js +5 -0
  226. package/dist/modules/sessions/dto/list-sessions.dto.d.ts +7 -0
  227. package/dist/modules/sessions/dto/list-sessions.dto.d.ts.map +1 -0
  228. package/dist/modules/sessions/dto/list-sessions.dto.js +6 -0
  229. package/dist/modules/sessions/session-history-processor.service.d.ts +48 -0
  230. package/dist/modules/sessions/session-history-processor.service.d.ts.map +1 -0
  231. package/dist/modules/sessions/session-history-processor.service.js +254 -0
  232. package/dist/modules/sessions/sessions.controller.d.ts +13 -0
  233. package/dist/modules/sessions/sessions.controller.d.ts.map +1 -0
  234. package/dist/modules/sessions/sessions.controller.js +113 -0
  235. package/dist/modules/sessions/sessions.module.d.ts +3 -0
  236. package/dist/modules/sessions/sessions.module.d.ts.map +1 -0
  237. package/dist/modules/sessions/sessions.module.js +49 -0
  238. package/dist/modules/sessions/sessions.service.d.ts +23 -0
  239. package/dist/modules/sessions/sessions.service.d.ts.map +1 -0
  240. package/dist/modules/sessions/sessions.service.js +168 -0
  241. package/dist/modules/subscription/subscription.middleware.d.ts +37 -0
  242. package/dist/modules/subscription/subscription.middleware.d.ts.map +1 -0
  243. package/dist/modules/subscription/subscription.middleware.js +141 -0
  244. package/dist/modules/subscription/subscription.module.d.ts +12 -0
  245. package/dist/modules/subscription/subscription.module.d.ts.map +1 -0
  246. package/dist/modules/subscription/subscription.module.js +26 -0
  247. package/dist/modules/throttler/throttler.module.d.ts +11 -0
  248. package/dist/modules/throttler/throttler.module.d.ts.map +1 -0
  249. package/dist/modules/throttler/throttler.module.js +32 -0
  250. package/dist/modules/ucan/index.d.ts +7 -0
  251. package/dist/modules/ucan/index.d.ts.map +1 -0
  252. package/dist/modules/ucan/index.js +6 -0
  253. package/dist/modules/ucan/ucan.config.d.ts +87 -0
  254. package/dist/modules/ucan/ucan.config.d.ts.map +1 -0
  255. package/dist/modules/ucan/ucan.config.js +114 -0
  256. package/dist/modules/ucan/ucan.module.d.ts +29 -0
  257. package/dist/modules/ucan/ucan.module.d.ts.map +1 -0
  258. package/dist/modules/ucan/ucan.module.js +46 -0
  259. package/dist/modules/ucan/ucan.service.d.ts +129 -0
  260. package/dist/modules/ucan/ucan.service.d.ts.map +1 -0
  261. package/dist/modules/ucan/ucan.service.js +582 -0
  262. package/dist/modules/ws/emitter.d.ts +12 -0
  263. package/dist/modules/ws/emitter.d.ts.map +1 -0
  264. package/dist/modules/ws/emitter.js +12 -0
  265. package/dist/modules/ws/ws.gateway.d.ts +34 -0
  266. package/dist/modules/ws/ws.gateway.d.ts.map +1 -0
  267. package/dist/modules/ws/ws.gateway.js +241 -0
  268. package/dist/modules/ws/ws.module.d.ts +3 -0
  269. package/dist/modules/ws/ws.module.d.ts.map +1 -0
  270. package/dist/modules/ws/ws.module.js +21 -0
  271. package/dist/modules/ws/ws.service.d.ts +25 -0
  272. package/dist/modules/ws/ws.service.d.ts.map +1 -0
  273. package/dist/modules/ws/ws.service.js +113 -0
  274. package/dist/plugin-api/define-plugin.d.ts +19 -0
  275. package/dist/plugin-api/define-plugin.d.ts.map +1 -0
  276. package/dist/plugin-api/define-plugin.js +25 -0
  277. package/dist/plugin-api/oracle-plugin.d.ts +92 -0
  278. package/dist/plugin-api/oracle-plugin.d.ts.map +1 -0
  279. package/dist/plugin-api/oracle-plugin.js +15 -0
  280. package/dist/plugin-api/tool-helper.d.ts +33 -0
  281. package/dist/plugin-api/tool-helper.d.ts.map +1 -0
  282. package/dist/plugin-api/tool-helper.js +40 -0
  283. package/dist/plugin-api/types.d.ts +378 -0
  284. package/dist/plugin-api/types.d.ts.map +1 -0
  285. package/dist/plugin-api/types.js +1 -0
  286. package/dist/plugins/agui/agui-agent.d.ts +10 -0
  287. package/dist/plugins/agui/agui-agent.d.ts.map +1 -0
  288. package/dist/plugins/agui/agui-agent.js +110 -0
  289. package/dist/plugins/agui/agui.plugin.d.ts +16 -0
  290. package/dist/plugins/agui/agui.plugin.d.ts.map +1 -0
  291. package/dist/plugins/agui/agui.plugin.js +117 -0
  292. package/dist/plugins/agui/index.d.ts +3 -0
  293. package/dist/plugins/agui/index.d.ts.map +1 -0
  294. package/dist/plugins/agui/index.js +2 -0
  295. package/dist/plugins/composio/composio-tools.d.ts +59 -0
  296. package/dist/plugins/composio/composio-tools.d.ts.map +1 -0
  297. package/dist/plugins/composio/composio-tools.js +88 -0
  298. package/dist/plugins/composio/composio-ucan.d.ts +14 -0
  299. package/dist/plugins/composio/composio-ucan.d.ts.map +1 -0
  300. package/dist/plugins/composio/composio-ucan.js +32 -0
  301. package/dist/plugins/composio/composio.plugin.d.ts +45 -0
  302. package/dist/plugins/composio/composio.plugin.d.ts.map +1 -0
  303. package/dist/plugins/composio/composio.plugin.js +116 -0
  304. package/dist/plugins/composio/index.d.ts +4 -0
  305. package/dist/plugins/composio/index.d.ts.map +1 -0
  306. package/dist/plugins/composio/index.js +3 -0
  307. package/dist/plugins/credits/claim-processing.module.d.ts +28 -0
  308. package/dist/plugins/credits/claim-processing.module.d.ts.map +1 -0
  309. package/dist/plugins/credits/claim-processing.module.js +37 -0
  310. package/dist/plugins/credits/claim-processing.service.d.ts +92 -0
  311. package/dist/plugins/credits/claim-processing.service.d.ts.map +1 -0
  312. package/dist/plugins/credits/claim-processing.service.js +406 -0
  313. package/dist/plugins/credits/credits-middleware.d.ts +23 -0
  314. package/dist/plugins/credits/credits-middleware.d.ts.map +1 -0
  315. package/dist/plugins/credits/credits-middleware.js +154 -0
  316. package/dist/plugins/credits/credits.plugin.d.ts +55 -0
  317. package/dist/plugins/credits/credits.plugin.d.ts.map +1 -0
  318. package/dist/plugins/credits/credits.plugin.js +95 -0
  319. package/dist/plugins/credits/file-processing-sink.module.d.ts +18 -0
  320. package/dist/plugins/credits/file-processing-sink.module.d.ts.map +1 -0
  321. package/dist/plugins/credits/file-processing-sink.module.js +56 -0
  322. package/dist/plugins/credits/index.d.ts +8 -0
  323. package/dist/plugins/credits/index.d.ts.map +1 -0
  324. package/dist/plugins/credits/index.js +7 -0
  325. package/dist/plugins/credits/subscription-sink.module.d.ts +23 -0
  326. package/dist/plugins/credits/subscription-sink.module.d.ts.map +1 -0
  327. package/dist/plugins/credits/subscription-sink.module.js +54 -0
  328. package/dist/plugins/credits/token-limiter.d.ts +139 -0
  329. package/dist/plugins/credits/token-limiter.d.ts.map +1 -0
  330. package/dist/plugins/credits/token-limiter.js +302 -0
  331. package/dist/plugins/domain-indexer/domain-indexer-agent.d.ts +7 -0
  332. package/dist/plugins/domain-indexer/domain-indexer-agent.d.ts.map +1 -0
  333. package/dist/plugins/domain-indexer/domain-indexer-agent.js +48 -0
  334. package/dist/plugins/domain-indexer/domain-indexer-tools.d.ts +8 -0
  335. package/dist/plugins/domain-indexer/domain-indexer-tools.d.ts.map +1 -0
  336. package/dist/plugins/domain-indexer/domain-indexer-tools.js +194 -0
  337. package/dist/plugins/domain-indexer/domain-indexer.plugin.d.ts +20 -0
  338. package/dist/plugins/domain-indexer/domain-indexer.plugin.d.ts.map +1 -0
  339. package/dist/plugins/domain-indexer/domain-indexer.plugin.js +78 -0
  340. package/dist/plugins/domain-indexer/index.d.ts +2 -0
  341. package/dist/plugins/domain-indexer/index.d.ts.map +1 -0
  342. package/dist/plugins/domain-indexer/index.js +1 -0
  343. package/dist/plugins/editor/apply-sandbox-output.d.ts +33 -0
  344. package/dist/plugins/editor/apply-sandbox-output.d.ts.map +1 -0
  345. package/dist/plugins/editor/apply-sandbox-output.js +302 -0
  346. package/dist/plugins/editor/block-actions.d.ts +84 -0
  347. package/dist/plugins/editor/block-actions.d.ts.map +1 -0
  348. package/dist/plugins/editor/block-actions.js +471 -0
  349. package/dist/plugins/editor/blocknote-helper.d.ts +147 -0
  350. package/dist/plugins/editor/blocknote-helper.d.ts.map +1 -0
  351. package/dist/plugins/editor/blocknote-helper.js +542 -0
  352. package/dist/plugins/editor/blocknote-tools.d.ts +364 -0
  353. package/dist/plugins/editor/blocknote-tools.d.ts.map +1 -0
  354. package/dist/plugins/editor/blocknote-tools.js +2123 -0
  355. package/dist/plugins/editor/editor-agent.d.ts +47 -0
  356. package/dist/plugins/editor/editor-agent.d.ts.map +1 -0
  357. package/dist/plugins/editor/editor-agent.js +158 -0
  358. package/dist/plugins/editor/editor-mx.d.ts +56 -0
  359. package/dist/plugins/editor/editor-mx.d.ts.map +1 -0
  360. package/dist/plugins/editor/editor-mx.js +100 -0
  361. package/dist/plugins/editor/editor.plugin.d.ts +32 -0
  362. package/dist/plugins/editor/editor.plugin.d.ts.map +1 -0
  363. package/dist/plugins/editor/editor.plugin.js +189 -0
  364. package/dist/plugins/editor/index.d.ts +6 -0
  365. package/dist/plugins/editor/index.d.ts.map +1 -0
  366. package/dist/plugins/editor/index.js +5 -0
  367. package/dist/plugins/editor/mint-invocation-tool.d.ts +72 -0
  368. package/dist/plugins/editor/mint-invocation-tool.d.ts.map +1 -0
  369. package/dist/plugins/editor/mint-invocation-tool.js +173 -0
  370. package/dist/plugins/editor/page-functions.d.ts +100 -0
  371. package/dist/plugins/editor/page-functions.d.ts.map +1 -0
  372. package/dist/plugins/editor/page-functions.js +317 -0
  373. package/dist/plugins/editor/page-tools.d.ts +75 -0
  374. package/dist/plugins/editor/page-tools.d.ts.map +1 -0
  375. package/dist/plugins/editor/page-tools.js +238 -0
  376. package/dist/plugins/editor/prompts.d.ts +22 -0
  377. package/dist/plugins/editor/prompts.d.ts.map +1 -0
  378. package/dist/plugins/editor/prompts.js +451 -0
  379. package/dist/plugins/editor/provider.d.ts +101 -0
  380. package/dist/plugins/editor/provider.d.ts.map +1 -0
  381. package/dist/plugins/editor/provider.js +249 -0
  382. package/dist/plugins/editor/standalone-editor-tool.d.ts +17 -0
  383. package/dist/plugins/editor/standalone-editor-tool.d.ts.map +1 -0
  384. package/dist/plugins/editor/standalone-editor-tool.js +136 -0
  385. package/dist/plugins/editor/survey-helpers.d.ts +112 -0
  386. package/dist/plugins/editor/survey-helpers.d.ts.map +1 -0
  387. package/dist/plugins/editor/survey-helpers.js +358 -0
  388. package/dist/plugins/firecrawl/firecrawl-agent.d.ts +7 -0
  389. package/dist/plugins/firecrawl/firecrawl-agent.d.ts.map +1 -0
  390. package/dist/plugins/firecrawl/firecrawl-agent.js +84 -0
  391. package/dist/plugins/firecrawl/firecrawl-tools.d.ts +37 -0
  392. package/dist/plugins/firecrawl/firecrawl-tools.d.ts.map +1 -0
  393. package/dist/plugins/firecrawl/firecrawl-tools.js +129 -0
  394. package/dist/plugins/firecrawl/firecrawl.plugin.d.ts +32 -0
  395. package/dist/plugins/firecrawl/firecrawl.plugin.d.ts.map +1 -0
  396. package/dist/plugins/firecrawl/firecrawl.plugin.js +69 -0
  397. package/dist/plugins/firecrawl/index.d.ts +3 -0
  398. package/dist/plugins/firecrawl/index.d.ts.map +1 -0
  399. package/dist/plugins/firecrawl/index.js +2 -0
  400. package/dist/plugins/index.d.ts +47 -0
  401. package/dist/plugins/index.d.ts.map +1 -0
  402. package/dist/plugins/index.js +69 -0
  403. package/dist/plugins/matrix-group-chats/channel-memory.module.d.ts +7 -0
  404. package/dist/plugins/matrix-group-chats/channel-memory.module.d.ts.map +1 -0
  405. package/dist/plugins/matrix-group-chats/channel-memory.module.js +22 -0
  406. package/dist/plugins/matrix-group-chats/channel-memory.repo.d.ts +62 -0
  407. package/dist/plugins/matrix-group-chats/channel-memory.repo.d.ts.map +1 -0
  408. package/dist/plugins/matrix-group-chats/channel-memory.repo.js +311 -0
  409. package/dist/plugins/matrix-group-chats/channel-memory.service.d.ts +89 -0
  410. package/dist/plugins/matrix-group-chats/channel-memory.service.d.ts.map +1 -0
  411. package/dist/plugins/matrix-group-chats/channel-memory.service.js +565 -0
  412. package/dist/plugins/matrix-group-chats/channel-memory.summarizer.d.ts +18 -0
  413. package/dist/plugins/matrix-group-chats/channel-memory.summarizer.d.ts.map +1 -0
  414. package/dist/plugins/matrix-group-chats/channel-memory.summarizer.js +128 -0
  415. package/dist/plugins/matrix-group-chats/channel-memory.types.d.ts +50 -0
  416. package/dist/plugins/matrix-group-chats/channel-memory.types.d.ts.map +1 -0
  417. package/dist/plugins/matrix-group-chats/channel-memory.types.js +2 -0
  418. package/dist/plugins/matrix-group-chats/guard.d.ts +83 -0
  419. package/dist/plugins/matrix-group-chats/guard.d.ts.map +1 -0
  420. package/dist/plugins/matrix-group-chats/guard.js +138 -0
  421. package/dist/plugins/matrix-group-chats/index.d.ts +59 -0
  422. package/dist/plugins/matrix-group-chats/index.d.ts.map +1 -0
  423. package/dist/plugins/matrix-group-chats/index.js +140 -0
  424. package/dist/plugins/matrix-group-chats/middleware.d.ts +31 -0
  425. package/dist/plugins/matrix-group-chats/middleware.d.ts.map +1 -0
  426. package/dist/plugins/matrix-group-chats/middleware.js +186 -0
  427. package/dist/plugins/matrix-group-chats/power-levels.d.ts +15 -0
  428. package/dist/plugins/matrix-group-chats/power-levels.d.ts.map +1 -0
  429. package/dist/plugins/matrix-group-chats/power-levels.js +36 -0
  430. package/dist/plugins/matrix-group-chats/room-info.d.ts +23 -0
  431. package/dist/plugins/matrix-group-chats/room-info.d.ts.map +1 -0
  432. package/dist/plugins/matrix-group-chats/room-info.js +34 -0
  433. package/dist/plugins/matrix-group-chats/tools.d.ts +8 -0
  434. package/dist/plugins/matrix-group-chats/tools.d.ts.map +1 -0
  435. package/dist/plugins/matrix-group-chats/tools.js +154 -0
  436. package/dist/plugins/memory/index.d.ts +5 -0
  437. package/dist/plugins/memory/index.d.ts.map +1 -0
  438. package/dist/plugins/memory/index.js +3 -0
  439. package/dist/plugins/memory/memory-tools.d.ts +52 -0
  440. package/dist/plugins/memory/memory-tools.d.ts.map +1 -0
  441. package/dist/plugins/memory/memory-tools.js +88 -0
  442. package/dist/plugins/memory/memory-ucan.d.ts +17 -0
  443. package/dist/plugins/memory/memory-ucan.d.ts.map +1 -0
  444. package/dist/plugins/memory/memory-ucan.js +43 -0
  445. package/dist/plugins/memory/memory.plugin.d.ts +51 -0
  446. package/dist/plugins/memory/memory.plugin.d.ts.map +1 -0
  447. package/dist/plugins/memory/memory.plugin.js +76 -0
  448. package/dist/plugins/memory/types.d.ts +75 -0
  449. package/dist/plugins/memory/types.d.ts.map +1 -0
  450. package/dist/plugins/memory/types.js +2 -0
  451. package/dist/plugins/portal/index.d.ts +3 -0
  452. package/dist/plugins/portal/index.d.ts.map +1 -0
  453. package/dist/plugins/portal/index.js +2 -0
  454. package/dist/plugins/portal/portal-agent.d.ts +9 -0
  455. package/dist/plugins/portal/portal-agent.d.ts.map +1 -0
  456. package/dist/plugins/portal/portal-agent.js +70 -0
  457. package/dist/plugins/portal/portal.plugin.d.ts +16 -0
  458. package/dist/plugins/portal/portal.plugin.d.ts.map +1 -0
  459. package/dist/plugins/portal/portal.plugin.js +115 -0
  460. package/dist/plugins/sandbox/index.d.ts +3 -0
  461. package/dist/plugins/sandbox/index.d.ts.map +1 -0
  462. package/dist/plugins/sandbox/index.js +2 -0
  463. package/dist/plugins/sandbox/sandbox-mcp.d.ts +46 -0
  464. package/dist/plugins/sandbox/sandbox-mcp.d.ts.map +1 -0
  465. package/dist/plugins/sandbox/sandbox-mcp.js +80 -0
  466. package/dist/plugins/sandbox/sandbox-write-blob.d.ts +22 -0
  467. package/dist/plugins/sandbox/sandbox-write-blob.d.ts.map +1 -0
  468. package/dist/plugins/sandbox/sandbox-write-blob.js +80 -0
  469. package/dist/plugins/sandbox/sandbox.plugin.d.ts +80 -0
  470. package/dist/plugins/sandbox/sandbox.plugin.d.ts.map +1 -0
  471. package/dist/plugins/sandbox/sandbox.plugin.js +204 -0
  472. package/dist/plugins/skills/index.d.ts +3 -0
  473. package/dist/plugins/skills/index.d.ts.map +1 -0
  474. package/dist/plugins/skills/index.js +2 -0
  475. package/dist/plugins/skills/skills-tools.d.ts +20 -0
  476. package/dist/plugins/skills/skills-tools.d.ts.map +1 -0
  477. package/dist/plugins/skills/skills-tools.js +204 -0
  478. package/dist/plugins/skills/skills-ucan.d.ts +24 -0
  479. package/dist/plugins/skills/skills-ucan.d.ts.map +1 -0
  480. package/dist/plugins/skills/skills-ucan.js +28 -0
  481. package/dist/plugins/skills/skills.plugin.d.ts +37 -0
  482. package/dist/plugins/skills/skills.plugin.d.ts.map +1 -0
  483. package/dist/plugins/skills/skills.plugin.js +82 -0
  484. package/dist/plugins/slack/index.d.ts +4 -0
  485. package/dist/plugins/slack/index.d.ts.map +1 -0
  486. package/dist/plugins/slack/index.js +3 -0
  487. package/dist/plugins/slack/slack.module.d.ts +9 -0
  488. package/dist/plugins/slack/slack.module.d.ts.map +1 -0
  489. package/dist/plugins/slack/slack.module.js +27 -0
  490. package/dist/plugins/slack/slack.plugin.d.ts +30 -0
  491. package/dist/plugins/slack/slack.plugin.d.ts.map +1 -0
  492. package/dist/plugins/slack/slack.plugin.js +40 -0
  493. package/dist/plugins/slack/slack.service.d.ts +32 -0
  494. package/dist/plugins/slack/slack.service.d.ts.map +1 -0
  495. package/dist/plugins/slack/slack.service.js +157 -0
  496. package/dist/plugins/user-preferences/index.d.ts +4 -0
  497. package/dist/plugins/user-preferences/index.d.ts.map +1 -0
  498. package/dist/plugins/user-preferences/index.js +3 -0
  499. package/dist/plugins/user-preferences/service/user-preferences.service.d.ts +61 -0
  500. package/dist/plugins/user-preferences/service/user-preferences.service.d.ts.map +1 -0
  501. package/dist/plugins/user-preferences/service/user-preferences.service.js +105 -0
  502. package/dist/plugins/user-preferences/user-preferences-http.module.d.ts +10 -0
  503. package/dist/plugins/user-preferences/user-preferences-http.module.d.ts.map +1 -0
  504. package/dist/plugins/user-preferences/user-preferences-http.module.js +23 -0
  505. package/dist/plugins/user-preferences/user-preferences-tool.d.ts +22 -0
  506. package/dist/plugins/user-preferences/user-preferences-tool.d.ts.map +1 -0
  507. package/dist/plugins/user-preferences/user-preferences-tool.js +103 -0
  508. package/dist/plugins/user-preferences/user-preferences.controller.d.ts +18 -0
  509. package/dist/plugins/user-preferences/user-preferences.controller.d.ts.map +1 -0
  510. package/dist/plugins/user-preferences/user-preferences.controller.js +72 -0
  511. package/dist/plugins/user-preferences/user-preferences.plugin.d.ts +27 -0
  512. package/dist/plugins/user-preferences/user-preferences.plugin.d.ts.map +1 -0
  513. package/dist/plugins/user-preferences/user-preferences.plugin.js +66 -0
  514. package/dist/registries/config-schema-registry.d.ts +24 -0
  515. package/dist/registries/config-schema-registry.d.ts.map +1 -0
  516. package/dist/registries/config-schema-registry.js +27 -0
  517. package/dist/registries/index.d.ts +13 -0
  518. package/dist/registries/index.d.ts.map +1 -0
  519. package/dist/registries/index.js +6 -0
  520. package/dist/registries/manifest-registry.d.ts +49 -0
  521. package/dist/registries/manifest-registry.d.ts.map +1 -0
  522. package/dist/registries/manifest-registry.js +53 -0
  523. package/dist/registries/middleware-registry.d.ts +41 -0
  524. package/dist/registries/middleware-registry.d.ts.map +1 -0
  525. package/dist/registries/middleware-registry.js +52 -0
  526. package/dist/registries/shared-state-registry.d.ts +41 -0
  527. package/dist/registries/shared-state-registry.d.ts.map +1 -0
  528. package/dist/registries/shared-state-registry.js +65 -0
  529. package/dist/registries/subagent-registry.d.ts +55 -0
  530. package/dist/registries/subagent-registry.d.ts.map +1 -0
  531. package/dist/registries/subagent-registry.js +106 -0
  532. package/dist/registries/test-fixtures.d.ts +47 -0
  533. package/dist/registries/test-fixtures.d.ts.map +1 -0
  534. package/dist/registries/test-fixtures.js +168 -0
  535. package/dist/registries/tool-registry.d.ts +74 -0
  536. package/dist/registries/tool-registry.d.ts.map +1 -0
  537. package/dist/registries/tool-registry.js +130 -0
  538. package/dist/runtime-context/ambient.d.ts +118 -0
  539. package/dist/runtime-context/ambient.d.ts.map +1 -0
  540. package/dist/runtime-context/ambient.js +1 -0
  541. package/dist/runtime-context/build-plugin.d.ts +20 -0
  542. package/dist/runtime-context/build-plugin.d.ts.map +1 -0
  543. package/dist/runtime-context/build-plugin.js +16 -0
  544. package/dist/runtime-context/build-runtime.d.ts +60 -0
  545. package/dist/runtime-context/build-runtime.d.ts.map +1 -0
  546. package/dist/runtime-context/build-runtime.js +81 -0
  547. package/dist/testing/create-test-runtime.d.ts +95 -0
  548. package/dist/testing/create-test-runtime.d.ts.map +1 -0
  549. package/dist/testing/create-test-runtime.js +302 -0
  550. package/dist/testing/index.d.ts +5 -0
  551. package/dist/testing/index.d.ts.map +1 -0
  552. package/dist/testing/index.js +5 -0
  553. package/dist/testing/integration/chat-client.d.ts +143 -0
  554. package/dist/testing/integration/chat-client.d.ts.map +1 -0
  555. package/dist/testing/integration/chat-client.js +238 -0
  556. package/dist/testing/integration/harness.d.ts +189 -0
  557. package/dist/testing/integration/harness.d.ts.map +1 -0
  558. package/dist/testing/integration/harness.js +461 -0
  559. package/dist/testing/integration/index.d.ts +14 -0
  560. package/dist/testing/integration/index.d.ts.map +1 -0
  561. package/dist/testing/integration/index.js +18 -0
  562. package/dist/testing/integration/setup.d.ts +2 -0
  563. package/dist/testing/integration/setup.d.ts.map +1 -0
  564. package/dist/testing/integration/setup.js +41 -0
  565. package/dist/testing/integration/sse-parser.d.ts +99 -0
  566. package/dist/testing/integration/sse-parser.d.ts.map +1 -0
  567. package/dist/testing/integration/sse-parser.js +125 -0
  568. package/dist/testing/integration/ucan.d.ts +74 -0
  569. package/dist/testing/integration/ucan.d.ts.map +1 -0
  570. package/dist/testing/integration/ucan.js +95 -0
  571. package/dist/testing/integration/wait-for-matrix-loaded.d.ts +19 -0
  572. package/dist/testing/integration/wait-for-matrix-loaded.d.ts.map +1 -0
  573. package/dist/testing/integration/wait-for-matrix-loaded.js +31 -0
  574. package/dist/testing/mocks.d.ts +64 -0
  575. package/dist/testing/mocks.d.ts.map +1 -0
  576. package/dist/testing/mocks.js +141 -0
  577. package/dist/testing/nest-doubles.d.ts +10 -0
  578. package/dist/testing/nest-doubles.d.ts.map +1 -0
  579. package/dist/testing/nest-doubles.js +19 -0
  580. package/dist/utils/emoji.d.ts +3 -0
  581. package/dist/utils/emoji.d.ts.map +1 -0
  582. package/dist/utils/emoji.js +36 -0
  583. package/package.json +102 -0
@@ -0,0 +1,22 @@
1
+ import type { PluginTool } from '../../plugin-api/types.js';
2
+ import type { SandboxMcpTool } from './sandbox.plugin.js';
3
+ export interface CreateSandboxWriteBlobToolParams {
4
+ /** Upstream MCP `sandbox_write_file` tool — looked up once per request from
5
+ * the MCP client's tool list. Required; without it the wrapper has nothing
6
+ * to forward to. */
7
+ sandboxWriteFileTool: SandboxMcpTool;
8
+ }
9
+ /**
10
+ * `sandbox_write_blob` — companion to `mint_invocation`. Takes a `blobId`
11
+ * (server-side stored long string) and a sandbox path; looks up the blob in
12
+ * the `BlobStore` and calls the underlying `sandbox_write_file` MCP tool
13
+ * with the value. The LLM only ever passes the short blobId + path — long
14
+ * base64 strings (UCAN CARs etc.) never enter its context, so they can't be
15
+ * corrupted in transit.
16
+ *
17
+ * The plugin must only register this tool when the upstream `sandbox_write_file`
18
+ * tool exists AND the request has a known user DID — without either the
19
+ * wrapper degrades into an always-failing stub, which is worse than absent.
20
+ */
21
+ export declare function createSandboxWriteBlobTool(params: CreateSandboxWriteBlobToolParams): PluginTool;
22
+ //# sourceMappingURL=sandbox-write-blob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-write-blob.d.ts","sourceRoot":"","sources":["../../../src/plugins/sandbox/sandbox-write-blob.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAyB1D,MAAM,WAAW,gCAAgC;IAC/C;;wBAEoB;IACpB,oBAAoB,EAAE,cAAc,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,gCAAgC,GACvC,UAAU,CAqDZ"}
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ import { tool as pluginTool } from '../../plugin-api/tool-helper.js';
3
+ const sandboxWriteBlobSchema = z.object({
4
+ blobId: z
5
+ .string()
6
+ .describe('The blobId returned by the tool that produced the value (e.g. mint_invocation). Format: `blob_<16 hex chars>`.'),
7
+ path: z
8
+ .string()
9
+ .describe('Destination path in the sandbox, e.g. `/workspace/data/<skill>/ucan_token`. Must be under /workspace/data/.'),
10
+ });
11
+ const SANDBOX_WRITE_BLOB_DESCRIPTION = `Write a server-stored blob to a file in the sandbox without ever paste-relaying the value through the LLM.
12
+
13
+ Use this whenever a tool returns a \`blobId\` (e.g. \`mint_invocation\`'s response). Pass the blobId + the destination path; the runtime looks the value up server-side and calls sandbox_write_file with its content. The long opaque value (base64 CARs, JWTs, etc.) never enters the LLM context — eliminates string-corruption-in-relay as a failure mode.
14
+
15
+ Inputs:
16
+ - blobId: short hex identifier returned by the producing tool (format \`blob_<16 hex chars>\`).
17
+ - path: destination path in the sandbox. Must be under \`/workspace/data/\` (the sandbox enforces this; writes elsewhere are rejected).
18
+
19
+ Returns: \`{ success: true, path, bytesWritten }\` on success, \`{ success: false, error }\` on failure. Common errors: blob not found (re-mint and retry — for invocations this can happen on a multi-replica deployment if the lookup lands on a different process), invalid blobId format, path outside /workspace/data/.`;
20
+ /**
21
+ * `sandbox_write_blob` — companion to `mint_invocation`. Takes a `blobId`
22
+ * (server-side stored long string) and a sandbox path; looks up the blob in
23
+ * the `BlobStore` and calls the underlying `sandbox_write_file` MCP tool
24
+ * with the value. The LLM only ever passes the short blobId + path — long
25
+ * base64 strings (UCAN CARs etc.) never enter its context, so they can't be
26
+ * corrupted in transit.
27
+ *
28
+ * The plugin must only register this tool when the upstream `sandbox_write_file`
29
+ * tool exists AND the request has a known user DID — without either the
30
+ * wrapper degrades into an always-failing stub, which is worse than absent.
31
+ */
32
+ export function createSandboxWriteBlobTool(params) {
33
+ return pluginTool(async (rawArgs, ctx) => {
34
+ const { blobId, path } = sandboxWriteBlobSchema.parse(rawArgs);
35
+ if (!ctx.blobStore.isValidBlobId(blobId)) {
36
+ return JSON.stringify({
37
+ success: false,
38
+ error: `Invalid blobId format. Expected blob_<16 hex chars>, got "${blobId}".`,
39
+ });
40
+ }
41
+ if (typeof path !== 'string' || !path.startsWith('/workspace/data/')) {
42
+ return JSON.stringify({
43
+ success: false,
44
+ error: `path must be under /workspace/data/. Got: "${path}".`,
45
+ });
46
+ }
47
+ const userDid = ctx.user.did;
48
+ const blob = await ctx.blobStore.get({ userDid, blobId });
49
+ if (!blob) {
50
+ return JSON.stringify({
51
+ success: false,
52
+ error: `Blob "${blobId}" not found (expired, never existed, or owned by another user). Re-mint and retry — for single-use invocations this is expected if the blob's TTL elapsed.`,
53
+ });
54
+ }
55
+ try {
56
+ const result = await params.sandboxWriteFileTool.invoke({
57
+ path,
58
+ content: blob.value,
59
+ encoding: 'utf8',
60
+ });
61
+ return JSON.stringify({
62
+ success: true,
63
+ path,
64
+ bytesWritten: blob.value.length,
65
+ blobName: blob.name,
66
+ note: typeof result === 'string' ? result : undefined,
67
+ });
68
+ }
69
+ catch (err) {
70
+ return JSON.stringify({
71
+ success: false,
72
+ error: `sandbox_write_file failed: ${err instanceof Error ? err.message : String(err)}`,
73
+ });
74
+ }
75
+ }, {
76
+ name: 'sandbox_write_blob',
77
+ description: SANDBOX_WRITE_BLOB_DESCRIPTION,
78
+ schema: sandboxWriteBlobSchema,
79
+ });
80
+ }
@@ -0,0 +1,80 @@
1
+ import { type ClientConfig } from '@langchain/mcp-adapters';
2
+ import { z } from 'zod';
3
+ import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
4
+ import type { PluginManifest, PluginTool, RuntimeContext } from '../../plugin-api/types.js';
5
+ import { type SandboxAuthBuilder } from './sandbox-mcp.js';
6
+ /** Minimal MCP-client surface — declared structurally so tests can stub it. */
7
+ export interface SandboxMcpClientLike {
8
+ getTools(): Promise<SandboxMcpTool[]>;
9
+ close(): Promise<void>;
10
+ }
11
+ /** Shape of one upstream MCP tool. `@langchain/mcp-adapters` returns this. */
12
+ export interface SandboxMcpTool {
13
+ name: string;
14
+ description: string;
15
+ schema: z.ZodType;
16
+ invoke(input: unknown): Promise<unknown>;
17
+ }
18
+ export type SandboxMcpClientFactory = (config: ClientConfig) => SandboxMcpClientLike;
19
+ export interface SandboxPluginOptions {
20
+ /**
21
+ * Override the auth header builder. Tests inject a stub here to skip the
22
+ * did:web resolution + UCAN mint; production code lets the default builder
23
+ * do the network work.
24
+ */
25
+ authBuilder?: SandboxAuthBuilder;
26
+ /**
27
+ * Override the MCP-client constructor. Tests inject a stub so they can
28
+ * intercept the headers the plugin sends and the tools it gets back without
29
+ * standing up a real `MultiServerMCPClient`.
30
+ */
31
+ mcpClientFactory?: SandboxMcpClientFactory;
32
+ /**
33
+ * Opt-in to the upstream `oracle_*` management tools (`oracle_list`,
34
+ * `oracle_get`, `oracle_health`, `oracle_stop`, `oracle_restart`,
35
+ * `oracle_get_logs`). Off by default — these are operator-grade controls
36
+ * that most user-facing oracles should not surface to the agent. Flip this
37
+ * on for admin / dev-tooling oracles.
38
+ */
39
+ includeOracleManagementTools?: boolean;
40
+ }
41
+ /**
42
+ * Sandbox plugin.
43
+ *
44
+ * Surfaces every upstream sandbox MCP tool — `sandbox_run`, `sandbox_write_file`,
45
+ * the `artifact_*` family, `load_skill`, and the `oracle_*`
46
+ * management tools — to the main agent. Each tool flows through verbatim
47
+ * (name, description, schema all from upstream); the plugin's only job is to
48
+ * authenticate the MCP connection and forward operator + per-user secrets in
49
+ * the request headers.
50
+ *
51
+ * Headers are minted ONCE per request and include:
52
+ * - `Authorization: Bearer <ixo:sandbox UCAN invocation>` + `X-Auth-Type: ucan`
53
+ * - `X-Skills-Invocation` (when `SKILLS_CAPSULES_BASE_URL` is configured)
54
+ * - `x-os-<name>` for each entry in `ORACLE_SECRETS`
55
+ * - `x-us-<name>` for each per-room secret loaded from `SecretsService`
56
+ *
57
+ * Tools are discovered per request via {@link getRequestTools} because the
58
+ * MCP client has to be authenticated as the in-flight user.
59
+ */
60
+ export declare class SandboxPlugin extends OraclePlugin {
61
+ /**
62
+ * Static handle other plugins use to test `availablePlugins.has(...)`
63
+ * without hardcoding the string. Mirrors the precedent set by `MemoryPlugin`.
64
+ */
65
+ static readonly NAME = "sandbox";
66
+ readonly name = "sandbox";
67
+ readonly version = "1.0.0";
68
+ readonly manifest: PluginManifest;
69
+ readonly configSchema: z.ZodObject<{
70
+ SANDBOX_MCP_URL: z.ZodURL;
71
+ }, z.core.$strip>;
72
+ readonly autoDetectHint = "SANDBOX_MCP_URL";
73
+ private readonly authBuilder;
74
+ private readonly mcpClientFactory;
75
+ private readonly includeOracleManagementTools;
76
+ constructor(opts?: SandboxPluginOptions);
77
+ autoDetect(env: NodeJS.ProcessEnv): boolean;
78
+ getRequestTools(rtCtx: RuntimeContext): Promise<PluginTool[]>;
79
+ }
80
+ //# sourceMappingURL=sandbox.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/sandbox/sandbox.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAsG1B,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C;AAED,MAAM,MAAM,uBAAuB,GAAG,CACpC,MAAM,EAAE,YAAY,KACjB,oBAAoB,CAAC;AAK1B,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C;;;;;;OAMG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAa;IAEjC,QAAQ,CAAC,IAAI,aAAsB;IACnC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,QAAQ,iBAAY;IAC7B,SAAkB,YAAY;;sBAAgB;IAC9C,SAAkB,cAAc,qBAAqB;IAErD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IAC3D,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAU;gBAE3C,IAAI,GAAE,oBAAyB;IAWlC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO;IAIrC,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CA+E7E"}
@@ -0,0 +1,204 @@
1
+ import { MultiServerMCPClient, } from '@langchain/mcp-adapters';
2
+ import { z } from 'zod';
3
+ import { OraclePlugin } from '../../plugin-api/oracle-plugin.js';
4
+ import { createDefaultAuthBuilder, parseOracleSecrets, } from './sandbox-mcp.js';
5
+ import { createSandboxWriteBlobTool } from './sandbox-write-blob.js';
6
+ const configSchema = z.object({
7
+ SANDBOX_MCP_URL: z.url(),
8
+ });
9
+ /**
10
+ * Sibling env vars the plugin reads at boot but does not own:
11
+ *
12
+ * - `ORACLE_SECRETS` is declared in the core (Tier-0) base env schema; the
13
+ * sandbox plugin parses it and injects each entry as an `x-os-*` header.
14
+ * - `SKILLS_CAPSULES_BASE_URL` is owned by the skills plugin. When set, the
15
+ * sandbox plugin mints a parallel `ixo:skills` invocation and forwards it
16
+ * as `X-Skills-Invocation` so the sandbox can call the skills service on
17
+ * the user's behalf.
18
+ *
19
+ * Both fields are optional — a missing value simply skips the matching
20
+ * header instead of failing the plugin build.
21
+ */
22
+ const siblingEnvSchema = z.object({
23
+ ORACLE_SECRETS: z.string().optional(),
24
+ SKILLS_CAPSULES_BASE_URL: z.url().optional(),
25
+ });
26
+ const manifest = {
27
+ title: 'Sandbox',
28
+ summary: 'Per-user Linux box for code execution. `sandbox_run` runs shell/python (writes anywhere via shell — incl. `/tmp` for scratch). `sandbox_write_file` writes raw bytes BUT only under `/workspace/data/` — paths like `/tmp/...` or `/workspace/tmp/...` are rejected; use `sandbox_run` for those.',
29
+ whenToUse: [
30
+ "Execute a skill — call `sandbox_run` with `cid` so user + oracle secrets are injected; the skill folder mounts read-only at `/workspace/skills/<skill-name>/` (use the absolute paths from `load_skill`'s `skillFiles`).",
31
+ 'Read a skill file (SKILL.md, scripts, configs) — call `sandbox_run` with `cid` and shell: `cat /workspace/skills/<skill-name>/SKILL.md`, `ls /workspace/skills/<skill-name>/`, `grep -r "<pattern>" /workspace/skills/<skill-name>/`, or `sed -n "1,80p" <file>` for a line range. There is no dedicated `read_skill` tool.',
32
+ 'Hit a JSON/REST API — write curl or python in `sandbox_run`. Never use a web scraper for `/api/`, `/v1/`, `/v2/`, `/v3/` endpoints.',
33
+ 'Generate or transform a file the user (or a later turn) will re-read — write it to `/workspace/data/output/<name>` (alias `/workspace/output/`).',
34
+ 'Re-read an attachment the user sent earlier — it was auto-archived to `/workspace/output/<filename>`; load from there.',
35
+ 'Save a large or escape-sensitive blob (multi-line markdown, structured data) byte-perfect to `/workspace/data/...` — use `sandbox_write_file` so quoting bugs do not corrupt it.',
36
+ "Write a scratch / throwaway file (build artefacts, temp scripts you will execute then delete) — use `sandbox_run` with a here-doc: `cat > /tmp/<name> <<'EOF'\\n<content>\\nEOF`. Never use `sandbox_write_file` for `/tmp` or anywhere outside `/workspace/data/` — it will be rejected.",
37
+ 'Always check the result envelope: `success === true` AND `exitCode === 0` before trusting `output`. On failure, READ the `error` text and change your approach — do not retry the same call with the same args.',
38
+ ],
39
+ whenNotToUse: [
40
+ 'The value is already inline in chat — just use it; opening the sandbox to echo it back wastes a turn.',
41
+ 'Fetching a URL the user just mentioned — prefer `process_file` so it auto-archives to `/workspace/output/`.',
42
+ 'A long human-readable page (blog, article, news) — use the Firecrawl agent.',
43
+ 'Installing native deps in cwd (`pip install -e .`, `bun install`) — `.venv`/`node_modules` get persisted to R2 and slow every future session. Install under `/tmp` (via `sandbox_run`) or inside the skill folder.',
44
+ '`sandbox_write_file` with a path outside `/workspace/data/` (e.g. `/tmp/foo`, `/workspace/tmp/foo`, `/workspace/output-only-if-data-prefix-missing`) — the validator hard-rejects this. For temp/scratch writes, switch to `sandbox_run`.',
45
+ ],
46
+ examples: [
47
+ {
48
+ user: "Read the pptx skill's instructions before generating slides.",
49
+ thought: "After `load_skill`, the SKILL.md path is the absolute path the response returned (e.g. /workspace/skills/pptx/SKILL.md). Cat it directly through sandbox_run — there's no separate read tool. Pass `cid` so the same skill context is in place.",
50
+ tool: 'sandbox_run',
51
+ args: {
52
+ code: 'cat /workspace/skills/pptx/SKILL.md',
53
+ cid: 'cid returned by list_skills / search_skills',
54
+ },
55
+ },
56
+ {
57
+ user: 'Run the price-forecast skill on the Q3 sales data.',
58
+ thought: 'Skill execution → pass the skill CID so user + oracle secrets are injected. Write the forecast to /workspace/data/output/ so the user can re-read it next turn.',
59
+ tool: 'sandbox_run',
60
+ args: {
61
+ code: 'cd /workspace/skills/price-forecast && bash run.sh "/workspace/output/q3-sales.csv" > /workspace/data/output/forecast.json',
62
+ cid: 'cid from list/search skills',
63
+ },
64
+ },
65
+ {
66
+ user: 'Compute monthly totals from the CSV I attached.',
67
+ thought: 'The attachment is at /workspace/output/<filename>. Use uv (preferred over pip in this sandbox) to materialize pandas. Write the result so the user can reuse it next turn.',
68
+ tool: 'sandbox_run',
69
+ args: {
70
+ code: "uv run --with pandas python -c \"import pandas as pd, json; df=pd.read_csv('/workspace/output/sales.csv'); out=df.groupby('month').sum().reset_index(); out.to_csv('/workspace/data/output/monthly_totals.csv', index=False); print(json.dumps({'rows': len(out)}))\"",
71
+ },
72
+ },
73
+ {
74
+ user: 'Save this draft report so I can come back to it tomorrow.',
75
+ thought: 'Multi-line markdown with quotes and code fences → write byte-perfect via sandbox_write_file (no shell-escaping). Persisted under /workspace/data so it survives across sessions.',
76
+ tool: 'sandbox_write_file',
77
+ args: {
78
+ path: '/workspace/data/output/draft-report.md',
79
+ content: '# Q3 Report\n\n## Findings\n\n...',
80
+ },
81
+ },
82
+ {
83
+ user: 'Build a one-off JS script to transform some data and run it.',
84
+ thought: 'Scratch script — runs once, then discarded. /tmp is the right home, but sandbox_write_file refuses anything outside /workspace/data/. Use sandbox_run with a here-doc to write + execute in one shot.',
85
+ tool: 'sandbox_run',
86
+ args: {
87
+ code: "cat > /tmp/transform.js <<'EOF'\nconst fs = require('fs');\nconst rows = JSON.parse(fs.readFileSync('/workspace/output/data.json'));\nconsole.log(JSON.stringify(rows.map(r => ({...r, normalized: r.value / 100}))));\nEOF\nnode /tmp/transform.js > /workspace/data/output/transformed.json",
88
+ },
89
+ },
90
+ ],
91
+ visibility: 'always',
92
+ stability: 'stable',
93
+ category: 'core',
94
+ tags: ['sandbox', 'execution', 'workspace', 'artifacts'],
95
+ };
96
+ /** Per-tool timeout for sandbox MCP calls (matches today's main-agent wiring). */
97
+ const SANDBOX_MCP_TIMEOUT_MS = 180_000;
98
+ /** Prefix the upstream sandbox MCP uses for operator-grade oracle controls. */
99
+ const ORACLE_MANAGEMENT_TOOL_PREFIX = 'oracle_';
100
+ /**
101
+ * Sandbox plugin.
102
+ *
103
+ * Surfaces every upstream sandbox MCP tool — `sandbox_run`, `sandbox_write_file`,
104
+ * the `artifact_*` family, `load_skill`, and the `oracle_*`
105
+ * management tools — to the main agent. Each tool flows through verbatim
106
+ * (name, description, schema all from upstream); the plugin's only job is to
107
+ * authenticate the MCP connection and forward operator + per-user secrets in
108
+ * the request headers.
109
+ *
110
+ * Headers are minted ONCE per request and include:
111
+ * - `Authorization: Bearer <ixo:sandbox UCAN invocation>` + `X-Auth-Type: ucan`
112
+ * - `X-Skills-Invocation` (when `SKILLS_CAPSULES_BASE_URL` is configured)
113
+ * - `x-os-<name>` for each entry in `ORACLE_SECRETS`
114
+ * - `x-us-<name>` for each per-room secret loaded from `SecretsService`
115
+ *
116
+ * Tools are discovered per request via {@link getRequestTools} because the
117
+ * MCP client has to be authenticated as the in-flight user.
118
+ */
119
+ export class SandboxPlugin extends OraclePlugin {
120
+ /**
121
+ * Static handle other plugins use to test `availablePlugins.has(...)`
122
+ * without hardcoding the string. Mirrors the precedent set by `MemoryPlugin`.
123
+ */
124
+ static NAME = 'sandbox';
125
+ name = SandboxPlugin.NAME;
126
+ version = '1.0.0';
127
+ manifest = manifest;
128
+ configSchema = configSchema;
129
+ autoDetectHint = 'SANDBOX_MCP_URL';
130
+ authBuilder;
131
+ mcpClientFactory;
132
+ includeOracleManagementTools;
133
+ constructor(opts = {}) {
134
+ super();
135
+ this.authBuilder = opts.authBuilder ?? createDefaultAuthBuilder();
136
+ this.mcpClientFactory =
137
+ opts.mcpClientFactory ??
138
+ ((config) => new MultiServerMCPClient(config));
139
+ this.includeOracleManagementTools =
140
+ opts.includeOracleManagementTools ?? false;
141
+ }
142
+ autoDetect(env) {
143
+ return Boolean(env.SANDBOX_MCP_URL);
144
+ }
145
+ async getRequestTools(rtCtx) {
146
+ const parsed = configSchema.safeParse(rtCtx.config);
147
+ if (!parsed.success) {
148
+ throw new Error(`sandbox: invalid configuration: ${parsed.error.issues
149
+ .map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`)
150
+ .join('; ')}`);
151
+ }
152
+ const siblings = siblingEnvSchema.safeParse(rtCtx.config);
153
+ const skillsServiceUrl = siblings.success
154
+ ? siblings.data.SKILLS_CAPSULES_BASE_URL
155
+ : undefined;
156
+ const oracleSecretsRaw = siblings.success
157
+ ? (siblings.data.ORACLE_SECRETS ?? '')
158
+ : '';
159
+ const oracleSecrets = parseOracleSecrets(oracleSecretsRaw);
160
+ const userSecretIndex = await rtCtx.secrets.getIndex();
161
+ const userSecretKeys = Object.keys(userSecretIndex);
162
+ const userSecrets = userSecretKeys.length > 0
163
+ ? await rtCtx.secrets.getValues(userSecretKeys)
164
+ : {};
165
+ const headers = await this.authBuilder({
166
+ sandboxMcpUrl: parsed.data.SANDBOX_MCP_URL,
167
+ skillsServiceUrl,
168
+ oracleSecrets,
169
+ userSecrets,
170
+ }, rtCtx);
171
+ const client = this.mcpClientFactory({
172
+ mcpServers: {
173
+ sandbox: {
174
+ type: 'http',
175
+ url: parsed.data.SANDBOX_MCP_URL,
176
+ transport: 'http',
177
+ headers,
178
+ },
179
+ },
180
+ defaultToolTimeout: SANDBOX_MCP_TIMEOUT_MS,
181
+ useStandardContentBlocks: true,
182
+ });
183
+ const upstream = await client.getTools();
184
+ const filtered = this.includeOracleManagementTools
185
+ ? upstream
186
+ : upstream.filter((t) => !t.name.startsWith(ORACLE_MANAGEMENT_TOOL_PREFIX));
187
+ const upstreamTools = filtered.map((tool) => ({
188
+ name: tool.name,
189
+ description: tool.description,
190
+ schema: tool.schema,
191
+ handler: async (args) => tool.invoke(args),
192
+ }));
193
+ // sandbox_write_blob — companion to mint_invocation. Synthetic wrapper
194
+ // that takes a server-stored blobId + a sandbox path, looks the value up
195
+ // server-side, and forwards it to sandbox_write_file. Only registered
196
+ // when sandbox_write_file is present in the upstream toolset AND the
197
+ // request has a known user DID (the blob store is user-DID-namespaced).
198
+ const sandboxWriteFileTool = filtered.find((t) => t.name === 'sandbox_write_file');
199
+ if (sandboxWriteFileTool && rtCtx.user.did) {
200
+ upstreamTools.push(createSandboxWriteBlobTool({ sandboxWriteFileTool }));
201
+ }
202
+ return upstreamTools;
203
+ }
204
+ }
@@ -0,0 +1,3 @@
1
+ export { SkillsPlugin, type SkillsPluginOptions } from './skills.plugin.js';
2
+ export { createDefaultSkillsUcanBuilder, type SkillsUcanBuilder, } from './skills-ucan.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/skills/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,8BAA8B,EAC9B,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SkillsPlugin } from './skills.plugin.js';
2
+ export { createDefaultSkillsUcanBuilder, } from './skills-ucan.js';
@@ -0,0 +1,20 @@
1
+ import type { PluginTool } from '../../plugin-api/types.js';
2
+ import type { SkillsUcanBuilder } from './skills-ucan.js';
3
+ export interface SkillsToolsOptions {
4
+ /** Resolved at boot from the plugin's `configSchema`. */
5
+ baseUrl: string;
6
+ /**
7
+ * Routing hint forwarded to ai-skills as `X-IXO-Network`. Defaults to
8
+ * `mainnet` at the plugin layer when `NETWORK` is absent from config.
9
+ */
10
+ network: string;
11
+ /** Mints the optional `ixo:skills` UCAN per call. */
12
+ ucanBuilder: SkillsUcanBuilder;
13
+ }
14
+ /**
15
+ * Build the two skills tools — `list_skills` and `search_skills`. Both close
16
+ * over the registry base URL but defer UCAN minting to the handler so each
17
+ * call resolves the freshest invocation for the current user.
18
+ */
19
+ export declare function createSkillsTools(opts: SkillsToolsOptions): PluginTool[];
20
+ //# sourceMappingURL=skills-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-tools.d.ts","sourceRoot":"","sources":["../../../src/plugins/skills/skills-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA0M1D,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,UAAU,EAAE,CAkExE"}
@@ -0,0 +1,204 @@
1
+ import { z } from 'zod';
2
+ import { tool } from '../../plugin-api/tool-helper.js';
3
+ /**
4
+ * Raw capsule shape returned by ai-skills. Validated via Zod at the network
5
+ * boundary so a malformed registry response surfaces as a clean parse error
6
+ * rather than a downstream type-confusion bug.
7
+ */
8
+ const capsuleSchema = z.object({
9
+ cid: z.string(),
10
+ name: z.string(),
11
+ description: z.string().default(''),
12
+ license: z.string().nullable().optional(),
13
+ compatibility: z.string().nullable().optional(),
14
+ allowedTools: z.string().nullable().optional(),
15
+ metadata: z.record(z.string(), z.string()).nullable().optional(),
16
+ archiveSize: z.number().optional(),
17
+ createdAt: z.string().optional(),
18
+ // Set by ai-skills when the response row is private (i.e. owned by the
19
+ // caller). Absent for public rows.
20
+ visibility: z.enum(['public', 'private']).optional(),
21
+ ownerDid: z.string().nullable().optional(),
22
+ oracleDid: z.string().nullable().optional(),
23
+ });
24
+ const paginationSchema = z.object({
25
+ total: z.number(),
26
+ limit: z.number(),
27
+ offset: z.number(),
28
+ hasMore: z.boolean(),
29
+ });
30
+ const listResponseSchema = z.object({
31
+ capsules: z.array(capsuleSchema),
32
+ pagination: paginationSchema,
33
+ });
34
+ const searchResponseSchema = z.object({
35
+ query: z.string(),
36
+ count: z.number(),
37
+ capsules: z.array(capsuleSchema),
38
+ });
39
+ const LIST_DESCRIPTION = `List available skills from the IXO skills registry — the caller's **published** private skills first, then public registry skills.
40
+
41
+ Each entry includes:
42
+ - title: skill name
43
+ - description: skill description
44
+ - path: absolute sandbox path to the skill folder
45
+ - source: "private" (your published skill) or "public" (registry)
46
+ - cid: required by load_skill and by sandbox_run (when the run depends on the skill). Never use a CID as a file path.`;
47
+ const SEARCH_DESCRIPTION = `Search the caller's published skills and the public IXO registry by query.
48
+
49
+ Matching published (private) skills come first, then public registry results. Each entry includes title, description, path, source ("private" | "public"), and cid.`;
50
+ const listSchema = z.object({
51
+ limit: z
52
+ .number()
53
+ .min(1)
54
+ .max(100)
55
+ .optional()
56
+ .describe('Optional: number of skills to return (1-100, default: 20).'),
57
+ offset: z
58
+ .number()
59
+ .min(0)
60
+ .optional()
61
+ .describe('Optional: pagination offset (default: 0).'),
62
+ });
63
+ const searchSchema = z.object({
64
+ q: z
65
+ .string()
66
+ .min(1, 'Search query is required')
67
+ .describe('Search query (e.g. "pptx", "invoice", "presentation", "docx"). Required.'),
68
+ limit: z
69
+ .number()
70
+ .min(1)
71
+ .max(50)
72
+ .optional()
73
+ .describe('Optional: max results to return (1-50, default: 10).'),
74
+ });
75
+ function normalizeRegistryCapsule(capsule) {
76
+ return {
77
+ title: capsule.name,
78
+ description: capsule.description ?? '',
79
+ path: `/workspace/skills/${capsule.name}`,
80
+ source: capsule.visibility === 'private' ? 'private' : 'public',
81
+ cid: capsule.cid,
82
+ createdAt: capsule.createdAt
83
+ ? new Date(capsule.createdAt).toISOString()
84
+ : undefined,
85
+ };
86
+ }
87
+ /**
88
+ * Build the auth/network header set for outbound ai-skills requests. When a
89
+ * UCAN invocation is available, ai-skills returns the caller's private
90
+ * skills alongside the public ones; without it, only public rows come back.
91
+ *
92
+ * `X-IXO-Network` is a routing hint for ai-skills' did:ixo resolver, not a
93
+ * capsule-storage axis.
94
+ */
95
+ function buildRegistryHeaders(opts) {
96
+ const headers = {
97
+ 'X-IXO-Network': opts.network,
98
+ };
99
+ if (opts.skillsUcan) {
100
+ headers['Authorization'] = `Bearer ${opts.skillsUcan}`;
101
+ headers['X-Auth-Type'] = 'ucan';
102
+ }
103
+ return headers;
104
+ }
105
+ async function fetchRegistryCapsules(opts, limit, offset) {
106
+ const url = new URL('/capsules', opts.baseUrl);
107
+ url.searchParams.set('limit', limit.toString());
108
+ url.searchParams.set('offset', offset.toString());
109
+ const response = await fetch(url.toString(), {
110
+ headers: buildRegistryHeaders(opts),
111
+ });
112
+ if (!response.ok) {
113
+ throw new Error(`List skills failed: ${response.statusText}`);
114
+ }
115
+ return listResponseSchema.parse(await response.json());
116
+ }
117
+ async function searchRegistryCapsules(opts, q, limit) {
118
+ const url = new URL('/capsules/search', opts.baseUrl);
119
+ url.searchParams.set('q', q);
120
+ url.searchParams.set('limit', limit.toString());
121
+ const response = await fetch(url.toString(), {
122
+ headers: buildRegistryHeaders(opts),
123
+ });
124
+ if (!response.ok) {
125
+ throw new Error(`Search skills failed: ${response.statusText}`);
126
+ }
127
+ const data = searchResponseSchema.parse(await response.json());
128
+ // Dedup by name. When a private (caller-owned) and a public row share a
129
+ // name, prefer the private one — the user's own skill always wins. Among
130
+ // entries of the same source, keep the newest by createdAt.
131
+ const skillsMap = new Map();
132
+ for (const capsule of data.capsules) {
133
+ const existing = skillsMap.get(capsule.name);
134
+ if (!existing) {
135
+ skillsMap.set(capsule.name, capsule);
136
+ continue;
137
+ }
138
+ const incomingPrivate = capsule.visibility === 'private';
139
+ const existingPrivate = existing.visibility === 'private';
140
+ if (incomingPrivate && !existingPrivate) {
141
+ skillsMap.set(capsule.name, capsule);
142
+ continue;
143
+ }
144
+ if (!incomingPrivate && existingPrivate) {
145
+ continue;
146
+ }
147
+ // Same visibility tier — keep the newer one.
148
+ const isNewer = capsule.createdAt && existing.createdAt
149
+ ? new Date(capsule.createdAt).getTime() >
150
+ new Date(existing.createdAt).getTime()
151
+ : false;
152
+ if (isNewer)
153
+ skillsMap.set(capsule.name, capsule);
154
+ }
155
+ return Array.from(skillsMap.values());
156
+ }
157
+ /**
158
+ * Build the two skills tools — `list_skills` and `search_skills`. Both close
159
+ * over the registry base URL but defer UCAN minting to the handler so each
160
+ * call resolves the freshest invocation for the current user.
161
+ */
162
+ export function createSkillsTools(opts) {
163
+ const list = tool(async (rawArgs, runCtx) => {
164
+ const params = listSchema.parse(rawArgs);
165
+ const limit = params.limit ?? 20;
166
+ const offset = params.offset ?? 0;
167
+ const skillsUcan = await opts.ucanBuilder(opts.baseUrl, runCtx);
168
+ const registryResult = await fetchRegistryCapsules({ baseUrl: opts.baseUrl, network: opts.network, skillsUcan }, limit, offset);
169
+ const registry = registryResult.capsules.map(normalizeRegistryCapsule);
170
+ const privateRegistry = registry.filter((s) => s.source === 'private');
171
+ const publicRegistry = registry.filter((s) => s.source === 'public');
172
+ const skills = [...privateRegistry, ...publicRegistry];
173
+ return {
174
+ skills,
175
+ pagination: registryResult.pagination,
176
+ privateSkillCount: privateRegistry.length,
177
+ };
178
+ }, {
179
+ name: 'list_skills',
180
+ description: LIST_DESCRIPTION,
181
+ schema: listSchema,
182
+ });
183
+ const search = tool(async (rawArgs, runCtx) => {
184
+ const params = searchSchema.parse(rawArgs);
185
+ const limit = params.limit ?? 10;
186
+ const skillsUcan = await opts.ucanBuilder(opts.baseUrl, runCtx);
187
+ const capsules = await searchRegistryCapsules({ baseUrl: opts.baseUrl, network: opts.network, skillsUcan }, params.q, limit);
188
+ const registry = capsules.map(normalizeRegistryCapsule);
189
+ const privateRegistry = registry.filter((s) => s.source === 'private');
190
+ const publicRegistry = registry.filter((s) => s.source === 'public');
191
+ const skills = [...privateRegistry, ...publicRegistry];
192
+ return {
193
+ query: params.q,
194
+ count: skills.length,
195
+ privateSkillCount: privateRegistry.length,
196
+ skills,
197
+ };
198
+ }, {
199
+ name: 'search_skills',
200
+ description: SEARCH_DESCRIPTION,
201
+ schema: searchSchema,
202
+ });
203
+ return [list, search];
204
+ }