@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,315 @@
1
+ import { PromptTemplate } from '@langchain/core/prompts';
2
+ /**
3
+ * The Slack constraints text. Identical to apps/app — kept here so the
4
+ * runtime owns its own copy and the prompt composer is self-contained.
5
+ */
6
+ export const SLACK_FORMATTING_CONSTRAINTS_CONTENT = `## Slack Formatting
7
+
8
+ Slack doesn't render markdown tables. When responding in a Slack session:
9
+ - Use bullet lists with bold labels ("• **Name:** value") instead of tables
10
+ - Use numbered lists for sequential data
11
+ - When delegating to sub-agents, ask them for list-based formatting (no tables)
12
+
13
+ `;
14
+ /** Headers used for each populated memory-context sub-section. */
15
+ const CONTEXT_SECTION_LABELS = {
16
+ identity: 'Personal identity',
17
+ work: 'Work & professional',
18
+ goals: 'Goals & aspirations',
19
+ interests: 'Interests & expertise',
20
+ relationships: 'Relationships & social',
21
+ recent: 'Recent activity',
22
+ };
23
+ /**
24
+ * Format a single memory-engine context section as mid-density rich content.
25
+ *
26
+ * Goal: enough high-level signal that the agent can converse without re-querying,
27
+ * but compact enough that six categorical sections don't blow up the prompt.
28
+ * The agent can always deep-dive via the search_memory_engine tool.
29
+ *
30
+ * Layout per section (in priority order):
31
+ * 1. **Key entities** with summaries — entity.summary contains the richest
32
+ * multi-fact synthesis graphiti produces (e.g. "user had a 1:1 with Carlos
33
+ * at 2pm today; user agreed to do the database migration in three phases").
34
+ * 2. **Facts** — short relationship-level bullets for breadth.
35
+ * 3. **Recent episodes** — raw source text, only when `includeEpisodes` is on.
36
+ *
37
+ * Returns `null` when the slot has no usable content — composer drops the
38
+ * sub-section entirely rather than emitting an empty header.
39
+ */
40
+ /**
41
+ * Render a single SearchEnhancedResponse slot. Dumps everything the memory
42
+ * engine returned — entities (with their multi-fact summaries), facts,
43
+ * episodes (raw source text), and communities (topic clusters). The server
44
+ * already caps result counts via per-query max_* settings, so no further
45
+ * truncation is needed here.
46
+ *
47
+ * Returns `null` for an empty/missing slot so the composer can skip the
48
+ * sub-section entirely instead of printing a bare header.
49
+ */
50
+ function formatContextSection(data) {
51
+ if (!data)
52
+ return null;
53
+ const { entities, facts, episodes, communities } = data;
54
+ if (!entities?.length &&
55
+ !facts?.length &&
56
+ !episodes?.length &&
57
+ !communities?.length) {
58
+ return null;
59
+ }
60
+ const lines = [];
61
+ if (entities?.length) {
62
+ lines.push('_Key entities:_');
63
+ for (const e of entities) {
64
+ const labels = e.labels.filter((l) => l !== 'Entity').join('/');
65
+ const tag = labels ? ` (${labels})` : '';
66
+ const summary = e.summary?.trim();
67
+ lines.push(summary ? `- **${e.name}**${tag}: ${summary}` : `- **${e.name}**${tag}`);
68
+ }
69
+ }
70
+ if (facts?.length) {
71
+ if (lines.length)
72
+ lines.push('');
73
+ lines.push('_Facts:_');
74
+ for (const f of facts) {
75
+ const text = f.fact?.trim();
76
+ if (text)
77
+ lines.push(`- ${text}`);
78
+ }
79
+ }
80
+ if (episodes?.length) {
81
+ if (lines.length)
82
+ lines.push('');
83
+ lines.push('_Episodes (raw):_');
84
+ for (const ep of episodes) {
85
+ const content = ep.content?.trim();
86
+ if (!content)
87
+ continue;
88
+ const date = ep.created_at?.slice(0, 10) ?? '';
89
+ lines.push(date ? `- *${date}* — ${content}` : `- ${content}`);
90
+ }
91
+ }
92
+ if (communities?.length) {
93
+ if (lines.length)
94
+ lines.push('');
95
+ lines.push('_Topic clusters:_');
96
+ for (const c of communities) {
97
+ const summary = c.summary?.trim();
98
+ lines.push(summary ? `- **${c.name}**: ${summary}` : `- **${c.name}**`);
99
+ }
100
+ }
101
+ return lines.length ? lines.join('\n') : null;
102
+ }
103
+ /**
104
+ * Render the memory-context block — empty string when nothing is populated.
105
+ *
106
+ * The runtime always feeds in the strongly-typed UserContextData shape from
107
+ * @ixo/common (see memory-engine.service.ts gatherUserContext), but the
108
+ * plugin-api surface keeps it as `Record<string, unknown>` to avoid forcing
109
+ * plugins to depend on the common package. Cast once at this boundary.
110
+ */
111
+ function buildContextBlock(userContext) {
112
+ if (!userContext)
113
+ return '';
114
+ const typed = userContext;
115
+ const sections = [];
116
+ for (const key of Object.keys(CONTEXT_SECTION_LABELS)) {
117
+ const formatted = formatContextSection(typed[key]);
118
+ if (formatted) {
119
+ sections.push(`**${CONTEXT_SECTION_LABELS[key]}**\n${formatted}`);
120
+ }
121
+ }
122
+ return sections.join('\n\n');
123
+ }
124
+ /** Render user preferences as a bullet list for the prompt. */
125
+ export function formatUserPreferences(prefs) {
126
+ if (!prefs)
127
+ return '';
128
+ const lines = [];
129
+ if (prefs.agentName)
130
+ lines.push(`- **Preferred agent name:** ${prefs.agentName}`);
131
+ if (prefs.language)
132
+ lines.push(`- **Preferred language:** ${prefs.language}`);
133
+ if (prefs.tone)
134
+ lines.push(`- **Tone:** ${prefs.tone}`);
135
+ if (prefs.formality)
136
+ lines.push(`- **Formality:** ${prefs.formality}`);
137
+ if (prefs.customInstructions)
138
+ lines.push(`- **Custom instructions:** ${prefs.customInstructions}`);
139
+ return lines.join('\n');
140
+ }
141
+ /**
142
+ * Build the oracle identity preamble. When `identity.prompt.opening` is set
143
+ * it replaces the generated text verbatim; otherwise the composer assembles
144
+ * a sentence from `name`/`org`/`description`. Never claims the oracle is a
145
+ * "companion" or "skills-native" — those framings belong to specific plugins.
146
+ */
147
+ export function buildOracleSection(input) {
148
+ const { oracleName, orgName, description, customOpening } = input;
149
+ if (customOpening && customOpening.trim().length > 0) {
150
+ return customOpening.trim();
151
+ }
152
+ const hasOrg = orgName && orgName.length > 0;
153
+ const hasDescription = description && description.length > 0;
154
+ if (hasOrg && hasDescription) {
155
+ return `You are ${oracleName}, an AI agent operated by ${orgName}. ${description}.`;
156
+ }
157
+ if (hasOrg) {
158
+ return `You are ${oracleName}, an AI agent operated by ${orgName}.`;
159
+ }
160
+ if (hasDescription) {
161
+ return `You are ${oracleName}. ${description}.`;
162
+ }
163
+ return `You are ${oracleName}, an AI agent built on QiForge.`;
164
+ }
165
+ const TEMPLATE = `{{{ORACLE_SECTION}}}
166
+
167
+ {{#CAPABILITIES_NOTE}}
168
+ {{{CAPABILITIES_NOTE}}}
169
+
170
+ {{/CAPABILITIES_NOTE}}
171
+ {{#CAPABILITY_BLOCK}}
172
+ {{{CAPABILITY_BLOCK}}}
173
+
174
+ {{/CAPABILITY_BLOCK}}
175
+ ## Operating principles
176
+
177
+ - The user's current message is your primary instruction. Background context (what you already know about them) is for adapting tone and suggestions, not for overriding their intent.
178
+ - **Search first, build second.** Before doing any non-trivial task, you MUST run discovery before producing the answer yourself. That means:
179
+ 1. Call \`search_skills\` against the user's request whenever a packaged skill could plausibly do the job (anything that involves generating a file, document, report, page, integration, calculation, lookup, or multi-step workflow).
180
+ 2. Call \`list_capabilities\` to scan loaded + on-demand plugins when the task could be served by a plugin you haven't loaded yet.
181
+ Do this proactively — even when the task wording doesn't literally match a capability's \`whenToUse\`. Tell the user in ONE short sentence what you're checking ("Checking the skills registry for an invoice generator…") before the search call, not after. If something fits, use it (load + run). If nothing fits after the search, say so in one short sentence and only THEN build from scratch. Reusing a vetted capability is almost always better than reinventing it; silently skipping discovery is the worst failure mode.
182
+ - Being proactive does **not** mean charging ahead blind. Pause and ask the user a short clarifying question when: (a) the request has multiple plausible interpretations and picking wrong would waste their time, (b) a capability scan surfaces several equally-good fits and you can't tell which they want, (c) you're about to take an irreversible or costly action (deleting data, sending a message, publishing, spending tokens on a long job), or (d) a required input is missing and you'd have to guess. One clarifying question beats five minutes of wrong work — but don't ask for things you can reasonably infer from context.
183
+ - When a tool or sub-agent succeeds, report the result. Never refuse after a successful tool call — including for credentials, tokens, identity data, or block/document operations.
184
+ - When a tool or sub-agent fails, surface the failure to the user and ask how to proceed. Don't silently retry.
185
+ - When delegating to a sub-agent, give it scope, intent, and the context it needs — sub-agents have no access to your conversation history.
186
+ - Match the user's communication style. Be concise. Use Unicode emoji directly (\`🔥\`), never text shortcodes (\`:fire:\`).
187
+ - When a capability turns out to be a strong fit for the user's recurring work, surface it explicitly and — if memory tools are available — offer to save the pattern for next time. Don't save silently; ask first.
188
+ - Complete the user's request and stop. Don't add unrequested follow-on steps. "Checking capabilities first" is part of doing the request, not a follow-on.
189
+ {{#COMMUNICATION_STYLE}}
190
+
191
+ {{{COMMUNICATION_STYLE}}}
192
+ {{/COMMUNICATION_STYLE}}
193
+
194
+ ## Working with files
195
+
196
+ When users send files (images, documents, audio, video), the runtime extracts content automatically and embeds the text or description inline in this conversation — the file content is already here.
197
+
198
+ Use \`process_file\` only when:
199
+ - The user mentions a URL or link in chat that isn't an attachment
200
+ - You need a file that isn't already in the conversation history
201
+ {{#CONTEXT_BLOCK}}
202
+
203
+ ## What you know about the user
204
+
205
+ {{{CONTEXT_BLOCK}}}
206
+ {{/CONTEXT_BLOCK}}
207
+
208
+ **Current time:** {{TIME_CONTEXT}}
209
+ {{#CURRENT_ENTITY_DID}}
210
+
211
+ **Current entity:** {{CURRENT_ENTITY_DID}}
212
+ {{/CURRENT_ENTITY_DID}}
213
+ {{#USER_SECRETS_CONTEXT}}
214
+
215
+ ## Available user secrets
216
+
217
+ The user has configured secrets injected as environment variables when executing skills in the sandbox:
218
+ {{USER_SECRETS_CONTEXT}}
219
+ These are auto-injected — don't ask the user for them. If a skill needs a secret that's not listed, tell the user to add it in Settings → Agents.
220
+ {{/USER_SECRETS_CONTEXT}}
221
+ {{#USER_PREFERENCES_CONTEXT}}
222
+
223
+ ## User preferences
224
+
225
+ {{{USER_PREFERENCES_CONTEXT}}}
226
+ {{/USER_PREFERENCES_CONTEXT}}
227
+
228
+ ## Operational mode
229
+
230
+ {{{OPERATIONAL_MODE}}}
231
+ {{#COMPOSIO_CONTEXT}}
232
+
233
+ {{{COMPOSIO_CONTEXT}}}
234
+ {{/COMPOSIO_CONTEXT}}
235
+ {{#EDITOR_SECTION}}
236
+
237
+ {{{EDITOR_SECTION}}}
238
+ {{/EDITOR_SECTION}}
239
+ {{#SLACK_FORMATTING_CONSTRAINTS}}
240
+
241
+ {{{SLACK_FORMATTING_CONSTRAINTS}}}
242
+ {{/SLACK_FORMATTING_CONSTRAINTS}}
243
+ `;
244
+ const PROMPT_TEMPLATE = new PromptTemplate({
245
+ template: TEMPLATE,
246
+ inputVariables: [
247
+ 'ORACLE_SECTION',
248
+ 'CAPABILITIES_NOTE',
249
+ 'CAPABILITY_BLOCK',
250
+ 'COMMUNICATION_STYLE',
251
+ 'CONTEXT_BLOCK',
252
+ 'TIME_CONTEXT',
253
+ 'CURRENT_ENTITY_DID',
254
+ 'OPERATIONAL_MODE',
255
+ 'EDITOR_SECTION',
256
+ 'SLACK_FORMATTING_CONSTRAINTS',
257
+ 'USER_SECRETS_CONTEXT',
258
+ 'COMPOSIO_CONTEXT',
259
+ 'USER_PREFERENCES_CONTEXT',
260
+ ],
261
+ templateFormat: 'mustache',
262
+ });
263
+ /**
264
+ * Compose the runtime's system prompt. Slots split into:
265
+ * - **identity** — from `OracleConfig` (custom opening or generated).
266
+ * - **capabilities** — author note (config.prompt.capabilities) + Tier-1 block.
267
+ * - **operating principles** — fixed + optional `communicationStyle` from config.
268
+ * - **working with files** — runtime-universal (FileProcessingService).
269
+ * - **context** — only populated memory sub-sections render; empty ones skipped.
270
+ * - **operational mode / composio / editor / slack** — existing plugin hooks.
271
+ */
272
+ export async function composePrompt(input) {
273
+ const oracleName = input.oracleNameOverride ?? input.identity.name;
274
+ const oracleSection = buildOracleSection({
275
+ oracleName,
276
+ orgName: input.identity.org,
277
+ description: input.identity.description,
278
+ customOpening: input.identity.prompt?.opening,
279
+ });
280
+ const capabilitiesNote = input.identity.prompt?.capabilities?.trim() ?? '';
281
+ const communicationStyle = input.identity.prompt?.communicationStyle?.trim() ?? '';
282
+ const rendered = await PROMPT_TEMPLATE.format({
283
+ ORACLE_SECTION: oracleSection,
284
+ CAPABILITIES_NOTE: capabilitiesNote,
285
+ CAPABILITY_BLOCK: input.capabilityBlock,
286
+ COMMUNICATION_STYLE: communicationStyle,
287
+ CONTEXT_BLOCK: buildContextBlock(input.userContext),
288
+ TIME_CONTEXT: input.timeContext,
289
+ CURRENT_ENTITY_DID: input.currentEntityDid,
290
+ OPERATIONAL_MODE: input.operationalMode,
291
+ EDITOR_SECTION: input.editorSection,
292
+ SLACK_FORMATTING_CONSTRAINTS: input.slackFormattingConstraints,
293
+ USER_SECRETS_CONTEXT: input.userSecretsContext,
294
+ COMPOSIO_CONTEXT: input.composioContext,
295
+ USER_PREFERENCES_CONTEXT: input.userPreferencesContext,
296
+ });
297
+ if (input.degradedServicesBlock && input.degradedServicesBlock.length > 0) {
298
+ return `${rendered}\n\n---\n\n## Degraded services\n\n${input.degradedServicesBlock}\n`;
299
+ }
300
+ return rendered;
301
+ }
302
+ /**
303
+ * Format a (timezone, currentTime) pair into a stable prompt block. Public so
304
+ * forks driving their own `composePrompt` calls can re-use it.
305
+ */
306
+ export function formatTimeContext(timezone, currentTime) {
307
+ if (!timezone && !currentTime)
308
+ return 'Not available.';
309
+ const parts = [];
310
+ if (currentTime)
311
+ parts.push(currentTime);
312
+ if (timezone)
313
+ parts.push(`(${timezone})`);
314
+ return parts.join(' ') || 'Not available.';
315
+ }
@@ -0,0 +1,65 @@
1
+ import { type BaseMessage } from '@langchain/core/messages';
2
+ import type { UserContextData } from '../plugin-api/types.js';
3
+ /**
4
+ * Per-user preferences stored alongside the thread state. Mirrors the apps/app
5
+ * shape but is kept loose so plugins can extend the contract via declaration
6
+ * merging without touching this schema.
7
+ */
8
+ export interface UserPreferences {
9
+ agentName?: string;
10
+ language?: string;
11
+ tone?: string;
12
+ formality?: string;
13
+ customInstructions?: string;
14
+ [key: string]: unknown;
15
+ }
16
+ /** Browser-side tool descriptor injected per request from the client. */
17
+ export interface BrowserToolCall {
18
+ name: string;
19
+ description: string;
20
+ schema: Record<string, unknown>;
21
+ }
22
+ /** AG-UI action descriptor injected per request from the client. */
23
+ export interface AgAction {
24
+ name: string;
25
+ description: string;
26
+ schema: Record<string, unknown>;
27
+ hasRender?: boolean;
28
+ }
29
+ /**
30
+ * Master annotation state for the runtime's main agent. Mirrors the inlined
31
+ * state schema previously living in apps/app — the runtime is the single
32
+ * source of truth now.
33
+ *
34
+ * Plugin-owned state (e.g. `editorRoomId`, `spaceId`) stays in this schema
35
+ * for now to preserve behaviour parity. Plugins read it through their own
36
+ * middlewares; the runtime never branches on these fields directly.
37
+ */
38
+ export declare const MainAgentGraphState: import("@langchain/langgraph").AnnotationRoot<{
39
+ config: import("@langchain/langgraph").BaseChannel<{
40
+ wsId?: string;
41
+ did: string;
42
+ }, {
43
+ wsId?: string;
44
+ did: string;
45
+ } | import("@langchain/langgraph").OverwriteValue<{
46
+ wsId?: string;
47
+ did: string;
48
+ }>, unknown>;
49
+ client: import("@langchain/langgraph").BaseChannel<"portal" | "matrix" | "slack", "portal" | "matrix" | "slack" | import("@langchain/langgraph").OverwriteValue<"portal" | "matrix" | "slack">, unknown>;
50
+ messages: import("@langchain/langgraph").BaseChannel<BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[], BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[] | import("@langchain/langgraph").OverwriteValue<BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[]>, unknown>;
51
+ editorRoomId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
52
+ spaceId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
53
+ currentEntityDid: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
54
+ browserTools: import("@langchain/langgraph").BaseChannel<BrowserToolCall[] | undefined, BrowserToolCall[] | import("@langchain/langgraph").OverwriteValue<BrowserToolCall[] | undefined> | undefined, unknown>;
55
+ agActions: import("@langchain/langgraph").BaseChannel<AgAction[] | undefined, AgAction[] | import("@langchain/langgraph").OverwriteValue<AgAction[] | undefined> | undefined, unknown>;
56
+ userContext: import("@langchain/langgraph").BaseChannel<UserContextData, UserContextData | import("@langchain/langgraph").OverwriteValue<UserContextData>, unknown>;
57
+ userPreferences: import("@langchain/langgraph").BaseChannel<UserPreferences | undefined, UserPreferences | import("@langchain/langgraph").OverwriteValue<UserPreferences | undefined> | undefined, unknown>;
58
+ /**
59
+ * Names of plugins the agent has loaded for this thread via
60
+ * `load_capability`. Set-union reducer: plugins are added, never removed.
61
+ */
62
+ loadedPlugins: import("@langchain/langgraph").BaseChannel<string[], string[] | import("@langchain/langgraph").OverwriteValue<string[]>, unknown>;
63
+ }>;
64
+ export type TMainAgentGraphState = typeof MainAgentGraphState.State;
65
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/graph/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;;eAErB,MAAM;aACR,MAAM;;eADJ,MAAM;aACR,MAAM;;eADJ,MAAM;aACR,MAAM;;;;;;;;;;;IAmDb;;;OAGG;;EAMH,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,OAAO,mBAAmB,CAAC,KAAK,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { Annotation, messagesStateReducer } from '@langchain/langgraph';
2
+ /**
3
+ * Master annotation state for the runtime's main agent. Mirrors the inlined
4
+ * state schema previously living in apps/app — the runtime is the single
5
+ * source of truth now.
6
+ *
7
+ * Plugin-owned state (e.g. `editorRoomId`, `spaceId`) stays in this schema
8
+ * for now to preserve behaviour parity. Plugins read it through their own
9
+ * middlewares; the runtime never branches on these fields directly.
10
+ */
11
+ export const MainAgentGraphState = Annotation.Root({
12
+ config: Annotation({
13
+ default: () => ({ did: '', wsId: '' }),
14
+ reducer: (prev, curr) => ({ ...prev, ...curr }),
15
+ }),
16
+ client: Annotation({
17
+ default: () => 'portal',
18
+ reducer: (_, curr) => curr,
19
+ }),
20
+ messages: Annotation({
21
+ reducer: messagesStateReducer,
22
+ default: () => [],
23
+ }),
24
+ editorRoomId: Annotation({
25
+ default: () => undefined,
26
+ reducer: (_, curr) => curr,
27
+ }),
28
+ spaceId: Annotation({
29
+ default: () => undefined,
30
+ reducer: (_, curr) => curr,
31
+ }),
32
+ currentEntityDid: Annotation({
33
+ default: () => undefined,
34
+ reducer: (_, curr) => curr,
35
+ }),
36
+ browserTools: Annotation({
37
+ default: () => [],
38
+ reducer: (_, curr) => curr,
39
+ }),
40
+ agActions: Annotation({
41
+ default: () => [],
42
+ reducer: (_, curr) => curr,
43
+ }),
44
+ userContext: Annotation({
45
+ default: () => ({}),
46
+ reducer: (prev, curr) => ({ ...prev, ...curr }),
47
+ }),
48
+ userPreferences: Annotation({
49
+ default: () => undefined,
50
+ reducer: (_, curr) => curr,
51
+ }),
52
+ /**
53
+ * Names of plugins the agent has loaded for this thread via
54
+ * `load_capability`. Set-union reducer: plugins are added, never removed.
55
+ */
56
+ loadedPlugins: Annotation({
57
+ reducer: (current, update) => Array.from(new Set([...(current ?? []), ...(update ?? [])])),
58
+ default: () => [],
59
+ }),
60
+ });
@@ -0,0 +1,56 @@
1
+ import type { StructuredTool } from 'langchain';
2
+ import type { PluginContext, PluginSubAgent, RuntimeContext } from '../plugin-api/types.js';
3
+ import type { RegisteredSubAgent, SubAgentRegistry } from '../registries/subagent-registry.js';
4
+ import type { AmbientServices } from '../runtime-context/ambient.js';
5
+ import type { RuntimeStateInput } from '../runtime-context/build-runtime.js';
6
+ import { type AgentSpec } from './subagent-as-tool.js';
7
+ /** Inputs for collecting and wrapping sub-agents. */
8
+ export interface CollectSubAgentsInput {
9
+ registry: SubAgentRegistry;
10
+ buildCtx: PluginContext;
11
+ ambient: AmbientServices;
12
+ /** Snapshot of state used when handlers need to build a `RuntimeContext`. */
13
+ state: RuntimeStateInput;
14
+ /** User DID — used for thread-scoped checkpointing. */
15
+ userDid: string;
16
+ /** Session ID — used for thread/run scoping. */
17
+ sessionId: string;
18
+ /**
19
+ * Optional per-request runtime context. Plumbed through to
20
+ * `SubAgentRegistry.collect` so plugins implementing `getRequestSubAgents`
21
+ * can branch on live state (e.g. AG-UI actions).
22
+ */
23
+ rtCtx?: RuntimeContext;
24
+ /**
25
+ * Optional adaptor turning a `PluginSubAgent` into the `AgentSpec` shape
26
+ * understood by `createSubagentAsTool`. Default wraps each `PluginTool`
27
+ * via `wrapPluginTool` so its handler receives a real `RuntimeContext`,
28
+ * and resolves the sub-agent's `model` role via `ambient.llm.get(...)`.
29
+ */
30
+ toAgentSpec?: (subAgent: PluginSubAgent, buildCtx: PluginContext, ambient: AmbientServices, state: RuntimeStateInput) => AgentSpec;
31
+ /**
32
+ * Tools the runtime wants every sub-agent to be able to call (e.g. the
33
+ * non-destructive memory CRUD tools the memory plugin contributes to the
34
+ * main agent). Appended to each sub-agent's own tool list when the inner
35
+ * `createAgent` is built — the sub-agent's tools take precedence in name
36
+ * collisions.
37
+ */
38
+ passthroughTools?: StructuredTool[];
39
+ /**
40
+ * Optional pre-collected sub-agent list. When provided, the registry is not
41
+ * queried — callers that need to filter the entries (e.g. by visibility +
42
+ * `loadedPlugins`) collect from the registry themselves, apply the filter,
43
+ * and pass the result here.
44
+ */
45
+ subAgents?: RegisteredSubAgent[];
46
+ }
47
+ /**
48
+ * Collect sub-agents from the registry and wrap each as a LangChain tool
49
+ * using `createSubagentAsTool`. A failure inside any one sub-agent's
50
+ * conversion logs via `ambient.logger` and is dropped from the list — the
51
+ * graph still builds with the others, matching apps/app's `Promise.allSettled`
52
+ * pattern.
53
+ */
54
+ export declare function collectSubAgentsWithFallback(input: CollectSubAgentsInput): Promise<StructuredTool[]>;
55
+ export type { RuntimeContext };
56
+ //# sourceMappingURL=sub-agent-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sub-agent-fallback.d.ts","sourceRoot":"","sources":["../../src/graph/sub-agent-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEd,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7E,qDAAqD;AACrD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,6EAA6E;IAC7E,KAAK,EAAE,iBAAiB,CAAC;IACzB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CACZ,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,iBAAiB,KACrB,SAAS,CAAC;IACf;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAiED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAmD3B;AAGD,YAAY,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { createSubagentAsTool } from './subagent-as-tool.js';
2
+ import { wrapPluginTool } from './wrap-plugin-tool.js';
3
+ /**
4
+ * Default adaptor — turns a `PluginSubAgent` into the `AgentSpec` shape
5
+ * required by `createSubagentAsTool`.
6
+ *
7
+ * Plugin sub-agent tools are `PluginTool[]` with `(args, ctx)` handlers; the
8
+ * sub-agent runs them inside its own `createAgent` call where LangChain
9
+ * supplies a `ToolRuntime`, not a `RuntimeContext`. Each tool is wrapped via
10
+ * `wrapPluginTool` so its handler observes a fully-built `RuntimeContext`
11
+ * (same bridge the main agent uses).
12
+ *
13
+ * The sub-agent's `model` role (default `'subagent'`) is resolved via the
14
+ * ambient LLM adapter and propagated to `AgentSpec.model` so the wrapping
15
+ * `createSubagentAsTool` can actually run a `createAgent` instead of
16
+ * returning the "no model configured" error path.
17
+ */
18
+ function defaultToAgentSpec(subAgent, buildCtx, ambient, state, userDid, sessionId) {
19
+ const systemPrompt = typeof subAgent.systemPrompt === 'function'
20
+ ? subAgent.systemPrompt(buildCtx)
21
+ : subAgent.systemPrompt;
22
+ const pluginTools = Array.isArray(subAgent.tools)
23
+ ? subAgent.tools
24
+ : subAgent.tools(buildCtx);
25
+ const tools = pluginTools.map((t) => wrapPluginTool(t, { ambient, state }));
26
+ const model = ambient.llm.get(subAgent.model ?? 'subagent');
27
+ // Normalize `forwardTools`:
28
+ // true → all of this sub-agent's own tool names
29
+ // string[] → as-is
30
+ // false/undef → undefined (nothing forwarded)
31
+ // Passthrough tools are NOT included — they're already on the main agent.
32
+ let forwardTools;
33
+ if (subAgent.forwardTools === true) {
34
+ forwardTools = pluginTools.map((t) => t.name);
35
+ }
36
+ else if (Array.isArray(subAgent.forwardTools)) {
37
+ forwardTools = subAgent.forwardTools;
38
+ }
39
+ return {
40
+ name: subAgent.name,
41
+ description: subAgent.description,
42
+ systemPrompt,
43
+ tools,
44
+ model,
45
+ middleware: subAgent.middlewares,
46
+ userDid,
47
+ sessionId,
48
+ ...(forwardTools ? { forwardTools } : {}),
49
+ };
50
+ }
51
+ /**
52
+ * Collect sub-agents from the registry and wrap each as a LangChain tool
53
+ * using `createSubagentAsTool`. A failure inside any one sub-agent's
54
+ * conversion logs via `ambient.logger` and is dropped from the list — the
55
+ * graph still builds with the others, matching apps/app's `Promise.allSettled`
56
+ * pattern.
57
+ */
58
+ export async function collectSubAgentsWithFallback(input) {
59
+ const { registry, buildCtx, ambient, state, userDid, sessionId, rtCtx, toAgentSpec, passthroughTools, subAgents, } = input;
60
+ const entries = subAgents ?? (await registry.collect(buildCtx, rtCtx));
61
+ const results = await Promise.allSettled(entries.map(async ({ pluginName, subAgent }) => {
62
+ try {
63
+ const spec = toAgentSpec
64
+ ? toAgentSpec(subAgent, buildCtx, ambient, state)
65
+ : defaultToAgentSpec(subAgent, buildCtx, ambient, state, userDid, sessionId);
66
+ const withPassthrough = passthroughTools?.length
67
+ ? { ...spec, passthroughTools }
68
+ : spec;
69
+ return createSubagentAsTool(withPassthrough, withPassthrough.forwardTools
70
+ ? { forwardTools: withPassthrough.forwardTools }
71
+ : undefined);
72
+ }
73
+ catch (err) {
74
+ ambient.logger.error({ pluginName, err: err instanceof Error ? err.message : String(err) }, 'sub-agent init failed; skipping');
75
+ return null;
76
+ }
77
+ }));
78
+ return results.flatMap((r) => r.status === 'fulfilled' && r.value ? [r.value] : []);
79
+ }
@@ -0,0 +1,77 @@
1
+ import type { BaseCheckpointSaver } from '@langchain/langgraph';
2
+ import { type BaseMessage } from '@langchain/core/messages';
3
+ import { createAgent, type AgentMiddleware, type StructuredTool } from 'langchain';
4
+ import type { Logger } from '../plugin-api/types.js';
5
+ /**
6
+ * Spec for an agent that runs as a one-shot sub-agent (called by a parent
7
+ * agent through `createSubagentAsTool`).
8
+ *
9
+ * `tools` is optional so plugin-defined sub-agents that contribute only
10
+ * routing logic (no tools) can still be wrapped.
11
+ *
12
+ * `passthroughTools` are runtime-injected tools (e.g. memory CRUD) that
13
+ * every sub-agent should be able to call regardless of which plugin owns the
14
+ * sub-agent. They are concatenated after `tools` when building the inner
15
+ * agent so the sub-agent's own tools take precedence in collisions.
16
+ */
17
+ export interface AgentSpec {
18
+ name: string;
19
+ description: string;
20
+ tools?: StructuredTool[];
21
+ passthroughTools?: StructuredTool[];
22
+ systemPrompt: string;
23
+ model?: Parameters<typeof createAgent>[0]['model'];
24
+ middleware?: AgentMiddleware[];
25
+ userDid: string;
26
+ sessionId: string;
27
+ /** Appended to thread_id to scope the agent's conversation (e.g. a room ID). */
28
+ threadSuffix?: string;
29
+ /**
30
+ * Checkpointer (or a factory resolved per-invocation given the userDid).
31
+ * Sub-agents normally share the parent's per-user SQLite store; the runtime
32
+ * resolves it once and passes it through here so the runtime package stays
33
+ * decoupled from any specific storage service.
34
+ */
35
+ checkpointer?: BaseCheckpointSaver | ((userDid: string) => Promise<BaseCheckpointSaver>);
36
+ /** Optional logger; defaults to a no-op. */
37
+ logger?: Logger;
38
+ /**
39
+ * Tool names whose AIMessage(tool_calls) + ToolMessage results should be
40
+ * forwarded into the parent graph's messages via Command. Surfaced on the
41
+ * spec so adaptors (e.g. plugin → spec conversion) can resolve a plugin's
42
+ * declared `forwardTools` once and let the wrapper pick it up downstream.
43
+ */
44
+ forwardTools?: string[];
45
+ }
46
+ /**
47
+ * Options for createSubagentAsTool — controlled by the oracle, not the agent.
48
+ */
49
+ export interface SubagentToolOptions {
50
+ /**
51
+ * Tool names whose AIMessage(tool_calls) + ToolMessage results should be
52
+ * forwarded into the parent graph's messages via Command.
53
+ * The SSE stream will pick them up as regular tool call events.
54
+ */
55
+ forwardTools?: string[];
56
+ /** Called after subagent completes with the full message history. Fire-and-forget. */
57
+ onComplete?: (messages: BaseMessage[], task: string) => void;
58
+ }
59
+ /**
60
+ * Wraps an AgentSpec as a LangChain tool. When the parent agent calls this
61
+ * tool with a task, an ephemeral agent runs (model + tools + systemPrompt)
62
+ * and the final reply text is returned.
63
+ *
64
+ * @param options.forwardTools — tool names whose calls should be pushed into
65
+ * the parent graph's messages via Command (decided by the oracle).
66
+ */
67
+ /**
68
+ * Compute the tool name the agent will see for a sub-agent given its
69
+ * authored name. Single source of truth — used by `createSubagentAsTool` to
70
+ * actually create the tool AND by the manifest validator to know what the
71
+ * agent will see. Keeping these in lockstep prevents silent drift.
72
+ *
73
+ * Example: `"Portal Agent"` → `"call_portal_agent"`.
74
+ */
75
+ export declare function computeSubAgentToolName(subAgentName: string): string;
76
+ export declare function createSubagentAsTool(spec: AgentSpec, options?: SubagentToolOptions): StructuredTool;
77
+ //# sourceMappingURL=subagent-as-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-as-tool.d.ts","sourceRoot":"","sources":["../../src/graph/subagent-as-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAQrD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EACT,mBAAmB,GACnB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACxD,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,sFAAsF;IACtF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9D;AAsGD;;;;;;;GAOG;AACH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,cAAc,CA8HhB"}