@soederpop/luca 0.1.1 → 0.1.3

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 (369) hide show
  1. package/CLAUDE.md +2 -0
  2. package/assistants/codingAssistant/hooks.ts +3 -0
  3. package/assistants/inkbot/CORE.md +69 -0
  4. package/assistants/inkbot/hooks.ts +14 -0
  5. package/assistants/inkbot/tools.ts +47 -0
  6. package/commands/inkbot.ts +353 -0
  7. package/dist/agi/container.server.d.ts +63 -0
  8. package/dist/agi/container.server.d.ts.map +1 -0
  9. package/dist/agi/endpoints/ask.d.ts +20 -0
  10. package/dist/agi/endpoints/ask.d.ts.map +1 -0
  11. package/dist/agi/endpoints/conversations/[id].d.ts +27 -0
  12. package/dist/agi/endpoints/conversations/[id].d.ts.map +1 -0
  13. package/dist/agi/endpoints/conversations.d.ts +18 -0
  14. package/dist/agi/endpoints/conversations.d.ts.map +1 -0
  15. package/dist/agi/endpoints/experts.d.ts +8 -0
  16. package/dist/agi/endpoints/experts.d.ts.map +1 -0
  17. package/dist/agi/feature.d.ts +9 -0
  18. package/dist/agi/feature.d.ts.map +1 -0
  19. package/dist/agi/features/assistant.d.ts +509 -0
  20. package/dist/agi/features/assistant.d.ts.map +1 -0
  21. package/dist/agi/features/assistants-manager.d.ts +236 -0
  22. package/dist/agi/features/assistants-manager.d.ts.map +1 -0
  23. package/dist/agi/features/autonomous-assistant.d.ts +281 -0
  24. package/dist/agi/features/autonomous-assistant.d.ts.map +1 -0
  25. package/dist/agi/features/browser-use.d.ts +479 -0
  26. package/dist/agi/features/browser-use.d.ts.map +1 -0
  27. package/dist/agi/features/claude-code.d.ts +824 -0
  28. package/dist/agi/features/claude-code.d.ts.map +1 -0
  29. package/dist/agi/features/conversation-history.d.ts +245 -0
  30. package/dist/agi/features/conversation-history.d.ts.map +1 -0
  31. package/dist/agi/features/conversation.d.ts +464 -0
  32. package/dist/agi/features/conversation.d.ts.map +1 -0
  33. package/dist/agi/features/docs-reader.d.ts +72 -0
  34. package/dist/agi/features/docs-reader.d.ts.map +1 -0
  35. package/dist/agi/features/file-tools.d.ts +110 -0
  36. package/dist/agi/features/file-tools.d.ts.map +1 -0
  37. package/dist/agi/features/luca-coder.d.ts +323 -0
  38. package/dist/agi/features/luca-coder.d.ts.map +1 -0
  39. package/dist/agi/features/openai-codex.d.ts +381 -0
  40. package/dist/agi/features/openai-codex.d.ts.map +1 -0
  41. package/dist/agi/features/openapi.d.ts +200 -0
  42. package/dist/agi/features/openapi.d.ts.map +1 -0
  43. package/dist/agi/features/skills-library.d.ts +167 -0
  44. package/dist/agi/features/skills-library.d.ts.map +1 -0
  45. package/dist/agi/index.d.ts +5 -0
  46. package/dist/agi/index.d.ts.map +1 -0
  47. package/dist/agi/lib/interceptor-chain.d.ts +44 -0
  48. package/dist/agi/lib/interceptor-chain.d.ts.map +1 -0
  49. package/dist/agi/lib/token-counter.d.ts +13 -0
  50. package/dist/agi/lib/token-counter.d.ts.map +1 -0
  51. package/dist/bootstrap/generated.d.ts +5 -0
  52. package/dist/bootstrap/generated.d.ts.map +1 -0
  53. package/dist/browser.d.ts +12 -0
  54. package/dist/browser.d.ts.map +1 -0
  55. package/dist/bus.d.ts +29 -0
  56. package/dist/bus.d.ts.map +1 -0
  57. package/dist/cli/build-info.d.ts +4 -0
  58. package/dist/cli/build-info.d.ts.map +1 -0
  59. package/dist/cli/cli.d.ts +3 -0
  60. package/dist/cli/cli.d.ts.map +1 -0
  61. package/dist/client.d.ts +60 -0
  62. package/dist/client.d.ts.map +1 -0
  63. package/dist/clients/civitai/index.d.ts +472 -0
  64. package/dist/clients/civitai/index.d.ts.map +1 -0
  65. package/dist/clients/client-template.d.ts +30 -0
  66. package/dist/clients/client-template.d.ts.map +1 -0
  67. package/dist/clients/comfyui/index.d.ts +281 -0
  68. package/dist/clients/comfyui/index.d.ts.map +1 -0
  69. package/dist/clients/elevenlabs/index.d.ts +197 -0
  70. package/dist/clients/elevenlabs/index.d.ts.map +1 -0
  71. package/dist/clients/graph.d.ts +64 -0
  72. package/dist/clients/graph.d.ts.map +1 -0
  73. package/dist/clients/openai/index.d.ts +247 -0
  74. package/dist/clients/openai/index.d.ts.map +1 -0
  75. package/dist/clients/rest.d.ts +92 -0
  76. package/dist/clients/rest.d.ts.map +1 -0
  77. package/dist/clients/supabase/index.d.ts +176 -0
  78. package/dist/clients/supabase/index.d.ts.map +1 -0
  79. package/dist/clients/websocket.d.ts +127 -0
  80. package/dist/clients/websocket.d.ts.map +1 -0
  81. package/dist/command.d.ts +163 -0
  82. package/dist/command.d.ts.map +1 -0
  83. package/dist/commands/bootstrap.d.ts +20 -0
  84. package/dist/commands/bootstrap.d.ts.map +1 -0
  85. package/dist/commands/chat.d.ts +37 -0
  86. package/dist/commands/chat.d.ts.map +1 -0
  87. package/dist/commands/code.d.ts +28 -0
  88. package/dist/commands/code.d.ts.map +1 -0
  89. package/dist/commands/console.d.ts +22 -0
  90. package/dist/commands/console.d.ts.map +1 -0
  91. package/dist/commands/describe.d.ts +50 -0
  92. package/dist/commands/describe.d.ts.map +1 -0
  93. package/dist/commands/eval.d.ts +23 -0
  94. package/dist/commands/eval.d.ts.map +1 -0
  95. package/dist/commands/help.d.ts +25 -0
  96. package/dist/commands/help.d.ts.map +1 -0
  97. package/dist/commands/index.d.ts +18 -0
  98. package/dist/commands/index.d.ts.map +1 -0
  99. package/dist/commands/introspect.d.ts +24 -0
  100. package/dist/commands/introspect.d.ts.map +1 -0
  101. package/dist/commands/mcp.d.ts +35 -0
  102. package/dist/commands/mcp.d.ts.map +1 -0
  103. package/dist/commands/prompt.d.ts +38 -0
  104. package/dist/commands/prompt.d.ts.map +1 -0
  105. package/dist/commands/run.d.ts +24 -0
  106. package/dist/commands/run.d.ts.map +1 -0
  107. package/dist/commands/sandbox-mcp.d.ts +34 -0
  108. package/dist/commands/sandbox-mcp.d.ts.map +1 -0
  109. package/dist/commands/save-api-docs.d.ts +21 -0
  110. package/dist/commands/save-api-docs.d.ts.map +1 -0
  111. package/dist/commands/scaffold.d.ts +24 -0
  112. package/dist/commands/scaffold.d.ts.map +1 -0
  113. package/dist/commands/select.d.ts +22 -0
  114. package/dist/commands/select.d.ts.map +1 -0
  115. package/dist/commands/serve.d.ts +29 -0
  116. package/dist/commands/serve.d.ts.map +1 -0
  117. package/dist/container-describer.d.ts +144 -0
  118. package/dist/container-describer.d.ts.map +1 -0
  119. package/dist/container.d.ts +451 -0
  120. package/dist/container.d.ts.map +1 -0
  121. package/dist/endpoint.d.ts +113 -0
  122. package/dist/endpoint.d.ts.map +1 -0
  123. package/dist/feature.d.ts +47 -0
  124. package/dist/feature.d.ts.map +1 -0
  125. package/dist/graft.d.ts +29 -0
  126. package/dist/graft.d.ts.map +1 -0
  127. package/dist/hash-object.d.ts +8 -0
  128. package/dist/hash-object.d.ts.map +1 -0
  129. package/dist/helper.d.ts +209 -0
  130. package/dist/helper.d.ts.map +1 -0
  131. package/dist/introspection/generated.node.d.ts +44623 -0
  132. package/dist/introspection/generated.node.d.ts.map +1 -0
  133. package/dist/introspection/generated.web.d.ts +1412 -0
  134. package/dist/introspection/generated.web.d.ts.map +1 -0
  135. package/dist/introspection/index.d.ts +156 -0
  136. package/dist/introspection/index.d.ts.map +1 -0
  137. package/dist/introspection/scan.d.ts +147 -0
  138. package/dist/introspection/scan.d.ts.map +1 -0
  139. package/dist/node/container.d.ts +256 -0
  140. package/dist/node/container.d.ts.map +1 -0
  141. package/dist/node/feature.d.ts +9 -0
  142. package/dist/node/feature.d.ts.map +1 -0
  143. package/dist/node/features/container-link.d.ts +213 -0
  144. package/dist/node/features/container-link.d.ts.map +1 -0
  145. package/dist/node/features/content-db.d.ts +354 -0
  146. package/dist/node/features/content-db.d.ts.map +1 -0
  147. package/dist/node/features/disk-cache.d.ts +236 -0
  148. package/dist/node/features/disk-cache.d.ts.map +1 -0
  149. package/dist/node/features/dns.d.ts +511 -0
  150. package/dist/node/features/dns.d.ts.map +1 -0
  151. package/dist/node/features/docker.d.ts +485 -0
  152. package/dist/node/features/docker.d.ts.map +1 -0
  153. package/dist/node/features/downloader.d.ts +73 -0
  154. package/dist/node/features/downloader.d.ts.map +1 -0
  155. package/dist/node/features/figlet-fonts.d.ts +4 -0
  156. package/dist/node/features/figlet-fonts.d.ts.map +1 -0
  157. package/dist/node/features/file-manager.d.ts +177 -0
  158. package/dist/node/features/file-manager.d.ts.map +1 -0
  159. package/dist/node/features/fs.d.ts +635 -0
  160. package/dist/node/features/fs.d.ts.map +1 -0
  161. package/dist/node/features/git.d.ts +329 -0
  162. package/dist/node/features/git.d.ts.map +1 -0
  163. package/dist/node/features/google-auth.d.ts +200 -0
  164. package/dist/node/features/google-auth.d.ts.map +1 -0
  165. package/dist/node/features/google-calendar.d.ts +194 -0
  166. package/dist/node/features/google-calendar.d.ts.map +1 -0
  167. package/dist/node/features/google-docs.d.ts +138 -0
  168. package/dist/node/features/google-docs.d.ts.map +1 -0
  169. package/dist/node/features/google-drive.d.ts +202 -0
  170. package/dist/node/features/google-drive.d.ts.map +1 -0
  171. package/dist/node/features/google-mail.d.ts +221 -0
  172. package/dist/node/features/google-mail.d.ts.map +1 -0
  173. package/dist/node/features/google-sheets.d.ts +157 -0
  174. package/dist/node/features/google-sheets.d.ts.map +1 -0
  175. package/dist/node/features/grep.d.ts +207 -0
  176. package/dist/node/features/grep.d.ts.map +1 -0
  177. package/dist/node/features/helpers.d.ts +236 -0
  178. package/dist/node/features/helpers.d.ts.map +1 -0
  179. package/dist/node/features/ink.d.ts +332 -0
  180. package/dist/node/features/ink.d.ts.map +1 -0
  181. package/dist/node/features/ipc-socket.d.ts +298 -0
  182. package/dist/node/features/ipc-socket.d.ts.map +1 -0
  183. package/dist/node/features/json-tree.d.ts +140 -0
  184. package/dist/node/features/json-tree.d.ts.map +1 -0
  185. package/dist/node/features/networking.d.ts +373 -0
  186. package/dist/node/features/networking.d.ts.map +1 -0
  187. package/dist/node/features/nlp.d.ts +125 -0
  188. package/dist/node/features/nlp.d.ts.map +1 -0
  189. package/dist/node/features/opener.d.ts +93 -0
  190. package/dist/node/features/opener.d.ts.map +1 -0
  191. package/dist/node/features/os.d.ts +168 -0
  192. package/dist/node/features/os.d.ts.map +1 -0
  193. package/dist/node/features/package-finder.d.ts +419 -0
  194. package/dist/node/features/package-finder.d.ts.map +1 -0
  195. package/dist/node/features/postgres.d.ts +173 -0
  196. package/dist/node/features/postgres.d.ts.map +1 -0
  197. package/dist/node/features/proc.d.ts +285 -0
  198. package/dist/node/features/proc.d.ts.map +1 -0
  199. package/dist/node/features/process-manager.d.ts +427 -0
  200. package/dist/node/features/process-manager.d.ts.map +1 -0
  201. package/dist/node/features/python.d.ts +477 -0
  202. package/dist/node/features/python.d.ts.map +1 -0
  203. package/dist/node/features/redis.d.ts +247 -0
  204. package/dist/node/features/redis.d.ts.map +1 -0
  205. package/dist/node/features/repl.d.ts +84 -0
  206. package/dist/node/features/repl.d.ts.map +1 -0
  207. package/dist/node/features/runpod.d.ts +527 -0
  208. package/dist/node/features/runpod.d.ts.map +1 -0
  209. package/dist/node/features/secure-shell.d.ts +145 -0
  210. package/dist/node/features/secure-shell.d.ts.map +1 -0
  211. package/dist/node/features/semantic-search.d.ts +207 -0
  212. package/dist/node/features/semantic-search.d.ts.map +1 -0
  213. package/dist/node/features/sqlite.d.ts +180 -0
  214. package/dist/node/features/sqlite.d.ts.map +1 -0
  215. package/dist/node/features/telegram.d.ts +173 -0
  216. package/dist/node/features/telegram.d.ts.map +1 -0
  217. package/dist/node/features/transpiler.d.ts +51 -0
  218. package/dist/node/features/transpiler.d.ts.map +1 -0
  219. package/dist/node/features/tts.d.ts +108 -0
  220. package/dist/node/features/tts.d.ts.map +1 -0
  221. package/dist/node/features/ui.d.ts +562 -0
  222. package/dist/node/features/ui.d.ts.map +1 -0
  223. package/dist/node/features/vault.d.ts +90 -0
  224. package/dist/node/features/vault.d.ts.map +1 -0
  225. package/dist/node/features/vm.d.ts +285 -0
  226. package/dist/node/features/vm.d.ts.map +1 -0
  227. package/dist/node/features/yaml-tree.d.ts +118 -0
  228. package/dist/node/features/yaml-tree.d.ts.map +1 -0
  229. package/dist/node/features/yaml.d.ts +127 -0
  230. package/dist/node/features/yaml.d.ts.map +1 -0
  231. package/dist/node.d.ts +67 -0
  232. package/dist/node.d.ts.map +1 -0
  233. package/dist/python/generated.d.ts +2 -0
  234. package/dist/python/generated.d.ts.map +1 -0
  235. package/dist/react/index.d.ts +36 -0
  236. package/dist/react/index.d.ts.map +1 -0
  237. package/dist/registry.d.ts +97 -0
  238. package/dist/registry.d.ts.map +1 -0
  239. package/dist/scaffolds/generated.d.ts +13 -0
  240. package/dist/scaffolds/generated.d.ts.map +1 -0
  241. package/dist/scaffolds/template.d.ts +11 -0
  242. package/dist/scaffolds/template.d.ts.map +1 -0
  243. package/dist/schemas/base.d.ts +254 -0
  244. package/dist/schemas/base.d.ts.map +1 -0
  245. package/dist/selector.d.ts +130 -0
  246. package/dist/selector.d.ts.map +1 -0
  247. package/dist/server.d.ts +89 -0
  248. package/dist/server.d.ts.map +1 -0
  249. package/dist/servers/express.d.ts +104 -0
  250. package/dist/servers/express.d.ts.map +1 -0
  251. package/dist/servers/mcp.d.ts +201 -0
  252. package/dist/servers/mcp.d.ts.map +1 -0
  253. package/dist/servers/socket.d.ts +121 -0
  254. package/dist/servers/socket.d.ts.map +1 -0
  255. package/dist/state.d.ts +24 -0
  256. package/dist/state.d.ts.map +1 -0
  257. package/dist/web/clients/socket.d.ts +37 -0
  258. package/dist/web/clients/socket.d.ts.map +1 -0
  259. package/dist/web/container.d.ts +55 -0
  260. package/dist/web/container.d.ts.map +1 -0
  261. package/dist/web/extension.d.ts +4 -0
  262. package/dist/web/extension.d.ts.map +1 -0
  263. package/dist/web/feature.d.ts +8 -0
  264. package/dist/web/feature.d.ts.map +1 -0
  265. package/dist/web/features/asset-loader.d.ts +35 -0
  266. package/dist/web/features/asset-loader.d.ts.map +1 -0
  267. package/dist/web/features/container-link.d.ts +167 -0
  268. package/dist/web/features/container-link.d.ts.map +1 -0
  269. package/dist/web/features/esbuild.d.ts +51 -0
  270. package/dist/web/features/esbuild.d.ts.map +1 -0
  271. package/dist/web/features/helpers.d.ts +140 -0
  272. package/dist/web/features/helpers.d.ts.map +1 -0
  273. package/dist/web/features/network.d.ts +69 -0
  274. package/dist/web/features/network.d.ts.map +1 -0
  275. package/dist/web/features/speech.d.ts +71 -0
  276. package/dist/web/features/speech.d.ts.map +1 -0
  277. package/dist/web/features/vault.d.ts +62 -0
  278. package/dist/web/features/vault.d.ts.map +1 -0
  279. package/dist/web/features/vm.d.ts +48 -0
  280. package/dist/web/features/vm.d.ts.map +1 -0
  281. package/dist/web/features/voice-recognition.d.ts +96 -0
  282. package/dist/web/features/voice-recognition.d.ts.map +1 -0
  283. package/dist/web/shims/isomorphic-vm.d.ts +22 -0
  284. package/dist/web/shims/isomorphic-vm.d.ts.map +1 -0
  285. package/docs/apis/features/agi/assistant.md +1 -0
  286. package/docs/apis/features/agi/assistants-manager.md +62 -2
  287. package/docs/apis/features/agi/auto-assistant.md +11 -109
  288. package/docs/apis/features/agi/claude-code.md +138 -0
  289. package/docs/apis/features/agi/conversation.md +60 -31
  290. package/docs/apis/features/agi/luca-coder.md +407 -0
  291. package/docs/apis/features/agi/openapi.md +2 -2
  292. package/docs/apis/features/agi/skills-library.md +12 -0
  293. package/docs/apis/features/node/python.md +81 -11
  294. package/docs/apis/features/node/transpiler.md +74 -0
  295. package/docs/apis/features/web/esbuild.md +0 -6
  296. package/docs/apis/servers/mcp.md +2 -2
  297. package/docs/examples/entity.md +124 -0
  298. package/package.json +73 -21
  299. package/scripts/test-assistant-hooks.ts +13 -0
  300. package/src/agi/feature.ts +13 -0
  301. package/src/agi/features/assistant.ts +36 -25
  302. package/src/agi/features/assistants-manager.ts +70 -5
  303. package/src/agi/features/autonomous-assistant.ts +1 -5
  304. package/src/agi/features/browser-use.ts +2 -2
  305. package/src/agi/features/claude-code.ts +165 -1
  306. package/src/agi/features/conversation-history.ts +2 -6
  307. package/src/agi/features/conversation.ts +95 -3
  308. package/src/agi/features/docs-reader.ts +2 -1
  309. package/src/agi/features/file-tools.ts +2 -2
  310. package/src/agi/features/luca-coder.ts +1 -5
  311. package/src/agi/features/openai-codex.ts +1 -1
  312. package/src/agi/features/openapi.ts +3 -3
  313. package/src/agi/features/skills-library.ts +90 -2
  314. package/src/agi/lib/interceptor-chain.ts +10 -0
  315. package/src/agi/lib/token-counter.ts +1 -1
  316. package/src/bootstrap/generated.ts +126 -1
  317. package/src/bus.ts +27 -5
  318. package/src/cli/build-info.ts +2 -2
  319. package/src/client.ts +2 -2
  320. package/src/clients/elevenlabs/index.ts +5 -0
  321. package/src/commands/bootstrap.ts +2 -1
  322. package/src/commands/chat.ts +1 -0
  323. package/src/commands/code.ts +4 -2
  324. package/src/commands/prompt.ts +34 -34
  325. package/src/commands/sandbox-mcp.ts +69 -163
  326. package/src/commands/save-api-docs.ts +10 -8
  327. package/src/commands/select.ts +8 -3
  328. package/src/container-describer.ts +70 -84
  329. package/src/container.ts +93 -3
  330. package/src/endpoint.ts +1 -1
  331. package/src/entity.ts +173 -0
  332. package/src/feature.ts +3 -3
  333. package/src/helper.ts +8 -4
  334. package/src/introspection/generated.agi.ts +1403 -929
  335. package/src/introspection/generated.node.ts +127 -33
  336. package/src/introspection/generated.web.ts +95 -3
  337. package/src/introspection/scan.ts +1 -1
  338. package/src/node/container.ts +1 -1
  339. package/src/node/features/content-db.ts +3 -3
  340. package/src/node/features/file-manager.ts +10 -9
  341. package/src/node/features/git.ts +5 -5
  342. package/src/node/features/helpers.ts +1 -1
  343. package/src/node/features/json-tree.ts +1 -1
  344. package/src/node/features/os.ts +3 -3
  345. package/src/node/features/package-finder.ts +1 -1
  346. package/src/node/features/process-manager.ts +1 -1
  347. package/src/node/features/python.ts +3 -3
  348. package/src/node/features/redis.ts +1 -1
  349. package/src/node/features/repl.ts +2 -2
  350. package/src/node/features/transpiler.ts +34 -9
  351. package/src/node/features/ui.ts +1 -1
  352. package/src/node/features/vm.ts +6 -5
  353. package/src/node/features/yaml-tree.ts +1 -1
  354. package/src/node.ts +1 -0
  355. package/src/python/generated.ts +1 -1
  356. package/src/scaffolds/generated.ts +1 -1
  357. package/src/selector.ts +74 -4
  358. package/src/server.ts +2 -2
  359. package/src/servers/mcp.ts +6 -6
  360. package/src/web/features/helpers.ts +1 -1
  361. package/src/web/features/network.ts +1 -0
  362. package/test/assistant.test.ts +72 -0
  363. package/test/conversation.test.ts +220 -0
  364. package/test/vm-loadmodule.test.ts +213 -0
  365. package/tsconfig.build.json +12 -0
  366. package/tsconfig.json +1 -1
  367. package/scripts/examples/telegram-ink-ui.ts +0 -302
  368. package/scripts/examples/using-openai-codex.ts +0 -23
  369. package/scripts/examples/vm-loading-esm-modules.ts +0 -16
@@ -0,0 +1,130 @@
1
+ import { Helper } from './helper.js';
2
+ import type { Container, ContainerContext } from './container.js';
3
+ import { Registry } from './registry.js';
4
+ import { SelectorStateSchema, SelectorOptionsSchema, type SelectorRunResult } from './schemas/base.js';
5
+ import { z } from 'zod';
6
+ export type { SelectorRunResult };
7
+ export type SelectorState = z.infer<typeof SelectorStateSchema>;
8
+ export type SelectorOptions = z.infer<typeof SelectorOptionsSchema>;
9
+ export interface AvailableSelectors {
10
+ }
11
+ export type SelectorFactory = <T extends keyof AvailableSelectors>(key: T, options?: ConstructorParameters<AvailableSelectors[T]>[0]) => NonNullable<InstanceType<AvailableSelectors[T]>>;
12
+ export interface SelectorsInterface {
13
+ selectors: SelectorsRegistry;
14
+ select: SelectorFactory;
15
+ }
16
+ /**
17
+ * Type helper for module-augmentation of AvailableSelectors when using the
18
+ * module-based pattern.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * declare module '@soederpop/luca' {
23
+ * interface AvailableSelectors {
24
+ * packageInfo: SimpleSelector<typeof argsSchema>
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export type SimpleSelector<Schema extends z.ZodType = z.ZodType> = typeof Selector & {
30
+ argsSchema: Schema;
31
+ };
32
+ /**
33
+ * A Selector is a helper that returns data. Where Commands perform actions,
34
+ * Selectors query and return structured results with built-in caching.
35
+ *
36
+ * Module authors export a `run(args, context)` function that returns data.
37
+ * The `select()` dispatch method wraps `run()` with cache check/store and
38
+ * returns `{ data, cached, cacheKey }`.
39
+ *
40
+ * Caching is on by default and keyed by `hashObject({ selectorName, args, gitSha })`.
41
+ * Export a `cacheKey(args, context)` function to customize, or set `cacheable = false`
42
+ * to disable.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // selectors/package-info.ts
47
+ * export const description = 'Returns parsed package.json data'
48
+ * export const argsSchema = z.object({ field: z.string().optional() })
49
+ *
50
+ * export function cacheKey(args, context) {
51
+ * return context.container.git.sha
52
+ * }
53
+ *
54
+ * export async function run(args, context) {
55
+ * const manifest = context.container.manifest
56
+ * return args.field ? manifest[args.field] : manifest
57
+ * }
58
+ * ```
59
+ */
60
+ export declare class Selector<T extends SelectorState = SelectorState, K extends SelectorOptions = SelectorOptions> extends Helper<T, K> {
61
+ static shortcut: string;
62
+ static description: string;
63
+ static stateSchema: z.ZodObject<{
64
+ running: z.ZodDefault<z.ZodBoolean>;
65
+ lastRanAt: z.ZodOptional<z.ZodNumber>;
66
+ }, z.core.$loose>;
67
+ static optionsSchema: z.ZodObject<{
68
+ name: z.ZodOptional<z.ZodString>;
69
+ _cacheKey: z.ZodOptional<z.ZodString>;
70
+ dispatchSource: z.ZodDefault<z.ZodEnum<{
71
+ cli: "cli";
72
+ headless: "headless";
73
+ mcp: "mcp";
74
+ rpc: "rpc";
75
+ }>>;
76
+ }, z.core.$strip>;
77
+ static eventsSchema: z.ZodObject<{
78
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
79
+ started: z.ZodTuple<[], null>;
80
+ completed: z.ZodTuple<[z.ZodAny], null>;
81
+ failed: z.ZodTuple<[z.ZodAny], null>;
82
+ }, z.core.$strip>;
83
+ static selectorDescription: string;
84
+ static argsSchema: z.ZodType;
85
+ static cacheable: boolean;
86
+ /** Self-register a Selector subclass from a static initialization block. */
87
+ static register: (SubClass: typeof Selector, id?: string) => typeof Selector;
88
+ get initialState(): T;
89
+ /**
90
+ * The user-defined selector payload. Override this in module-based selectors
91
+ * by exporting a `run` function.
92
+ *
93
+ * Receives validated args and the container context. Must return data.
94
+ */
95
+ run(_args: any, _context: ContainerContext): Promise<any>;
96
+ /**
97
+ * Compute the cache key for a given set of args.
98
+ * Override by exporting a `cacheKey(args, context)` function in the module.
99
+ *
100
+ * Default: hashObject({ selectorName, args, gitSha })
101
+ */
102
+ resolveCacheKey(args: any, _context: ContainerContext): string;
103
+ /**
104
+ * The public dispatch method. Checks cache, calls run(), stores result.
105
+ *
106
+ * @returns `{ data, cached, cacheKey }` — the result and cache metadata
107
+ */
108
+ select(args?: Record<string, any>): Promise<SelectorRunResult>;
109
+ /** Lazily access diskCache. */
110
+ private _getCache;
111
+ static attach(container: Container<any> & SelectorsInterface): Container<any, any> & SelectorsInterface;
112
+ }
113
+ export declare class SelectorsRegistry extends Registry<Selector<any>> {
114
+ scope: string;
115
+ baseClass: any;
116
+ /**
117
+ * Discover and register selectors from a directory.
118
+ * Detection order:
119
+ * 1. Default export is a class extending Selector -> register directly
120
+ * 2. Module exports a `run` function -> graft as SimpleSelector
121
+ */
122
+ discover(options: {
123
+ directory: string;
124
+ }): Promise<void>;
125
+ }
126
+ export declare const selectors: SelectorsRegistry;
127
+ export declare const selectorHelperCache: Map<any, any>;
128
+ export { graftModule, isNativeHelperClass } from './graft.js';
129
+ export default Selector;
130
+ //# sourceMappingURL=selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../src/selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC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{ Registry } from './registry.js';
4
+ import { z } from 'zod';
5
+ import { ServerStateSchema, ServerOptionsSchema } from './schemas/base.js';
6
+ export type ServerState = z.infer<typeof ServerStateSchema>;
7
+ export type ServerOptions = z.infer<typeof ServerOptionsSchema>;
8
+ export type StartOptions = {
9
+ port?: number;
10
+ host?: string;
11
+ };
12
+ export type ServerFactory = <T extends keyof AvailableServers>(key: T, options?: ConstructorParameters<AvailableServers[T]>[0]) => NonNullable<InstanceType<AvailableServers[T]>>;
13
+ export interface ServersInterface {
14
+ servers: ServersRegistry;
15
+ server: ServerFactory;
16
+ }
17
+ export interface AvailableServers {
18
+ }
19
+ export declare class Server<T extends ServerState = ServerState, K extends ServerOptions = ServerOptions> extends Helper<T, K> {
20
+ static stateSchema: z.ZodObject<{
21
+ port: z.ZodOptional<z.ZodNumber>;
22
+ listening: z.ZodDefault<z.ZodBoolean>;
23
+ configured: z.ZodDefault<z.ZodBoolean>;
24
+ stopped: z.ZodDefault<z.ZodBoolean>;
25
+ }, z.core.$loose>;
26
+ static optionsSchema: z.ZodObject<{
27
+ name: z.ZodOptional<z.ZodString>;
28
+ _cacheKey: z.ZodOptional<z.ZodString>;
29
+ port: z.ZodOptional<z.ZodNumber>;
30
+ host: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ static eventsSchema: z.ZodObject<{
33
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
34
+ }, z.core.$strip>;
35
+ /** Self-register a Server subclass from a static initialization block. */
36
+ static register: (SubClass: typeof Server, id?: string) => typeof Server;
37
+ get initialState(): T;
38
+ get options(): K;
39
+ static attach(container: NodeContainer & ServersInterface): NodeContainer<import("./node.js").NodeFeatures, {
40
+ started: boolean;
41
+ enabledFeatures: string[];
42
+ registries: string[];
43
+ factories: string[];
44
+ }> & ServersInterface;
45
+ get container(): NodeContainer;
46
+ /** Async functions passed to `.use()` before `start()` — drained in `start()`. */
47
+ _pendingPlugins: Promise<void>[];
48
+ /**
49
+ * Register a setup function against this server. The function receives the
50
+ * server instance and can configure it however it likes.
51
+ *
52
+ * - If the server hasn't started yet, async return values are queued and
53
+ * awaited when `start()` is called.
54
+ * - If the server is already listening, the function is fire-and-forget.
55
+ * - Always returns `this` synchronously for chaining.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * server
60
+ * .use((s) => s.app.use(cors()))
61
+ * .use(async (s) => { await loadRoutes(s) })
62
+ * await server.start()
63
+ * ```
64
+ */
65
+ use(fn: (server: this) => void | Promise<void>): this;
66
+ /** Drain all pending `.use()` promises. Subclasses should call this at the top of `start()`. */
67
+ protected _drainPendingPlugins(): Promise<void>;
68
+ get isListening(): boolean;
69
+ get isConfigured(): boolean;
70
+ get isStopped(): boolean;
71
+ /** The port this server will bind to. Reads from state first (set by start() or configure()), then constructor options, then defaults to 3000. */
72
+ get port(): number;
73
+ stop(): Promise<this>;
74
+ /**
75
+ * Start the server. Runtime options override constructor options and update state
76
+ * so that `server.port` always reflects the actual listening port.
77
+ *
78
+ * @param options - Optional runtime overrides for port and host
79
+ */
80
+ start(options?: StartOptions): Promise<this>;
81
+ configure(): Promise<this>;
82
+ }
83
+ export declare class ServersRegistry extends Registry<Server<any>> {
84
+ scope: string;
85
+ baseClass: typeof Server;
86
+ }
87
+ export declare const servers: ServersRegistry;
88
+ export declare const helperCache: Map<any, any>;
89
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAsB,MAAM,mBAAmB,CAAA;AAE9F,MAAM,MAAM,WAAW,GAAG,C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AAK;IAErC;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAUrD,gGAAgG;cAChF,oBAAoB;IAOpC,IAAI,WAAW,YAEd;IAED,IAAI,YAAY,YAEf;IAED,IAAI,SAAS,YAEZ;IAED,kJAAkJ;IAClJ,IAAI,IAAI,WAEP;IAEK,IAAI;IAUV;;;;;OAKG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAgB5B,SAAS;CAWlB;AAED,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/C,KAAK,SAAY;IACjB,SAAS,gBAAS;CAC5B;AAED,eAAO,MAAM,OAAO,iBAAwB,CAAA;AAE5C,eAAO,MAAM,WAAW,eAAY,CAAA"}
@@ -0,0 +1,104 @@
1
+ import express from 'express';
2
+ import type { Express } from 'express';
3
+ import { z } from 'zod';
4
+ import { type StartOptions, Server, type ServerState } from '../server.js';
5
+ import { Endpoint, type EndpointModule } from '../endpoint.js';
6
+ declare module '../server' {
7
+ interface AvailableServers {
8
+ express: typeof ExpressServer;
9
+ }
10
+ }
11
+ export declare const ExpressServerOptionsSchema: z.ZodObject<{
12
+ name: z.ZodOptional<z.ZodString>;
13
+ _cacheKey: z.ZodOptional<z.ZodString>;
14
+ port: z.ZodOptional<z.ZodNumber>;
15
+ host: z.ZodOptional<z.ZodString>;
16
+ cors: z.ZodOptional<z.ZodBoolean>;
17
+ static: z.ZodOptional<z.ZodString>;
18
+ historyFallback: z.ZodOptional<z.ZodBoolean>;
19
+ create: z.ZodOptional<z.ZodAny>;
20
+ beforeStart: z.ZodOptional<z.ZodAny>;
21
+ }, z.core.$strip>;
22
+ export type ExpressServerOptions = z.infer<typeof ExpressServerOptionsSchema>;
23
+ /**
24
+ * Express.js HTTP server with automatic endpoint mounting, CORS, and SPA history fallback.
25
+ *
26
+ * Wraps an Express application with convention-based endpoint discovery. Endpoints
27
+ * defined as modules are automatically mounted as routes. Supports static file serving,
28
+ * CORS configuration, and single-page app history fallback out of the box.
29
+ *
30
+ * @extends Server
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const server = container.server('express', { cors: true, static: './public' })
35
+ * await server.start({ port: 3000 })
36
+ *
37
+ * // Mount endpoints programmatically
38
+ * server.mount(myEndpoint)
39
+ *
40
+ * // Access the underlying Express app
41
+ * server.app.get('/health', (req, res) => res.json({ ok: true }))
42
+ * ```
43
+ */
44
+ export declare class ExpressServer<T extends ServerState = ServerState, K extends ExpressServerOptions = ExpressServerOptions> extends Server<T, K> {
45
+ static shortcut: "servers.express";
46
+ static stateSchema: z.ZodObject<{
47
+ port: z.ZodOptional<z.ZodNumber>;
48
+ listening: z.ZodDefault<z.ZodBoolean>;
49
+ configured: z.ZodDefault<z.ZodBoolean>;
50
+ stopped: z.ZodDefault<z.ZodBoolean>;
51
+ }, z.core.$loose>;
52
+ static optionsSchema: z.ZodObject<{
53
+ name: z.ZodOptional<z.ZodString>;
54
+ _cacheKey: z.ZodOptional<z.ZodString>;
55
+ port: z.ZodOptional<z.ZodNumber>;
56
+ host: z.ZodOptional<z.ZodString>;
57
+ cors: z.ZodOptional<z.ZodBoolean>;
58
+ static: z.ZodOptional<z.ZodString>;
59
+ historyFallback: z.ZodOptional<z.ZodBoolean>;
60
+ create: z.ZodOptional<z.ZodAny>;
61
+ beforeStart: z.ZodOptional<z.ZodAny>;
62
+ }, z.core.$strip>;
63
+ _app?: Express;
64
+ _listener?: any;
65
+ _mountedEndpoints: Endpoint[];
66
+ get express(): typeof express;
67
+ get hooks(): {
68
+ create: (app: Express, server: Server) => Express;
69
+ beforeStart: (options: any, server: Server) => any;
70
+ };
71
+ get app(): Express;
72
+ /**
73
+ * Start the Express HTTP server. A runtime `port` overrides the constructor
74
+ * option and is written to state so `server.port` always reflects reality.
75
+ *
76
+ * @param options - Optional runtime overrides for port and host
77
+ */
78
+ start(options?: StartOptions): Promise<this>;
79
+ stop(): Promise<this>;
80
+ configure(): Promise<this>;
81
+ useEndpoint(endpoint: Endpoint): this;
82
+ useEndpoints(dir: string): Promise<this>;
83
+ /**
84
+ * Reload a mounted endpoint by its file path. Re-reads the module through
85
+ * the helpers VM loader so the next request picks up the new handlers.
86
+ *
87
+ * @param filePath - Absolute path to the endpoint file
88
+ * @returns The reloaded Endpoint, or null if no mounted endpoint matches
89
+ */
90
+ reloadEndpoint(filePath: string): Promise<Endpoint | null>;
91
+ useEndpointModules(modules: EndpointModule[]): Promise<this>;
92
+ serveOpenAPISpec(options?: {
93
+ title?: string;
94
+ version?: string;
95
+ description?: string;
96
+ }): this;
97
+ generateOpenAPISpec(options?: {
98
+ title?: string;
99
+ version?: string;
100
+ description?: string;
101
+ }): Record<string, any>;
102
+ }
103
+ export default ExpressServer;
104
+ //# sourceMappingURL=express.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/servers/express.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAsB,MAAM,gBAAgB,CAAA;AAElF,OAAO,QAAQ,WAAW,CAAC;IACzB,UAAU,gBAAgB;QACxB,OAAO,EAAE,OAAO,aAAa,CAAA;KAC9B;CACF;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;iBAMrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAI7E;;;;;;;;;;;;;;;;;;;;GAoBG;AAC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C,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;IAQhG,mBAAmB,CAAC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAkBrH;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,201 @@
1
+ import type { NodeContainer } from '../node/container.js';
2
+ import { z } from 'zod';
3
+ import { MCPServerStateSchema, MCPServerOptionsSchema } from '../schemas/base.js';
4
+ import { Server } from '../server.js';
5
+ import { Server as MCPProtocolServer } from '@modelcontextprotocol/sdk/server/index.js';
6
+ declare module '../server' {
7
+ interface AvailableServers {
8
+ mcp: typeof MCPServer;
9
+ }
10
+ }
11
+ export type MCPServerOptions = z.infer<typeof MCPServerOptionsSchema>;
12
+ export type MCPServerState = z.infer<typeof MCPServerStateSchema>;
13
+ /** Context object passed to all MCP tool, resource, and prompt handlers. */
14
+ export type MCPContext = {
15
+ container: NodeContainer;
16
+ };
17
+ /** A registered MCP tool with its schema, handler, and pre-computed JSON Schema. */
18
+ export interface RegisteredTool {
19
+ name: string;
20
+ description?: string;
21
+ schema?: z.ZodObject<any>;
22
+ jsonSchema?: Record<string, any>;
23
+ handler: (args: any, ctx: MCPContext) => any;
24
+ }
25
+ /** A registered MCP resource with its URI, metadata, and handler. */
26
+ export interface RegisteredResource {
27
+ uri: string;
28
+ name?: string;
29
+ description?: string;
30
+ mimeType?: string;
31
+ handler: (uri: string, ctx: MCPContext) => Promise<string> | string;
32
+ }
33
+ /** A registered MCP prompt with its argument schemas and handler. */
34
+ export interface RegisteredPrompt {
35
+ name: string;
36
+ description?: string;
37
+ args?: Record<string, z.ZodType>;
38
+ handler: (args: Record<string, string | undefined>, ctx: MCPContext) => Promise<PromptMessage[]> | PromptMessage[];
39
+ }
40
+ export type PromptMessage = {
41
+ role: 'user' | 'assistant';
42
+ content: string;
43
+ };
44
+ type ToolRegistrationOptions = {
45
+ schema?: z.ZodObject<any>;
46
+ description?: string;
47
+ handler: (args: any, ctx: MCPContext) => any;
48
+ };
49
+ type ResourceRegistrationOptions = {
50
+ name?: string;
51
+ description?: string;
52
+ mimeType?: string;
53
+ handler: (uri: string, ctx: MCPContext) => Promise<string> | string;
54
+ };
55
+ type PromptRegistrationOptions = {
56
+ description?: string;
57
+ args?: Record<string, z.ZodType>;
58
+ handler: (args: Record<string, string | undefined>, ctx: MCPContext) => Promise<PromptMessage[]> | PromptMessage[];
59
+ };
60
+ type MCPCompatMode = 'standard' | 'codex';
61
+ type StdioCompatMode = 'standard' | 'codex' | 'auto';
62
+ /**
63
+ * MCP (Model Context Protocol) server for exposing tools, resources, and prompts
64
+ * to AI clients like Claude Code. Uses the low-level MCP SDK Server class directly
65
+ * with Zod 4 native JSON Schema conversion.
66
+ *
67
+ * Register tools, resources, and prompts programmatically, then start the server
68
+ * over stdio (for CLI integration) or HTTP (for remote access).
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const mcp = container.server('mcp', { serverName: 'my-server', serverVersion: '1.0.0' })
73
+ *
74
+ * mcp.tool('search_files', {
75
+ * schema: z.object({ pattern: z.string() }),
76
+ * description: 'Search for files',
77
+ * handler: async (args, ctx) => {
78
+ * return ctx.container.feature('fs').walk('.', { include: [args.pattern] }).files.join('\n')
79
+ * }
80
+ * })
81
+ *
82
+ * await mcp.start()
83
+ * ```
84
+ */
85
+ export declare class MCPServer extends Server<MCPServerState, MCPServerOptions> {
86
+ static shortcut: "servers.mcp";
87
+ static stateSchema: z.ZodObject<{
88
+ port: z.ZodOptional<z.ZodNumber>;
89
+ listening: z.ZodDefault<z.ZodBoolean>;
90
+ configured: z.ZodDefault<z.ZodBoolean>;
91
+ stopped: z.ZodDefault<z.ZodBoolean>;
92
+ transport: z.ZodOptional<z.ZodString>;
93
+ toolCount: z.ZodDefault<z.ZodNumber>;
94
+ resourceCount: z.ZodDefault<z.ZodNumber>;
95
+ promptCount: z.ZodDefault<z.ZodNumber>;
96
+ }, z.core.$loose>;
97
+ static optionsSchema: z.ZodObject<{
98
+ name: z.ZodOptional<z.ZodString>;
99
+ _cacheKey: z.ZodOptional<z.ZodString>;
100
+ port: z.ZodOptional<z.ZodNumber>;
101
+ host: z.ZodOptional<z.ZodString>;
102
+ transport: z.ZodOptional<z.ZodEnum<{
103
+ stdio: "stdio";
104
+ http: "http";
105
+ }>>;
106
+ serverName: z.ZodOptional<z.ZodString>;
107
+ serverVersion: z.ZodOptional<z.ZodString>;
108
+ mcpCompat: z.ZodOptional<z.ZodEnum<{
109
+ standard: "standard";
110
+ codex: "codex";
111
+ }>>;
112
+ stdioCompat: z.ZodOptional<z.ZodEnum<{
113
+ standard: "standard";
114
+ codex: "codex";
115
+ auto: "auto";
116
+ }>>;
117
+ }, z.core.$strip>;
118
+ static eventsSchema: z.ZodObject<{
119
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
120
+ toolRegistered: z.ZodTuple<[z.ZodString], null>;
121
+ resourceRegistered: z.ZodTuple<[z.ZodString], null>;
122
+ promptRegistered: z.ZodTuple<[z.ZodString], null>;
123
+ toolCalled: z.ZodTuple<[z.ZodString, z.ZodAny], null>;
124
+ }, z.core.$strip>;
125
+ _mcpServer?: MCPProtocolServer;
126
+ _tools: Map<string, RegisteredTool>;
127
+ _resources: Map<string, RegisteredResource>;
128
+ _prompts: Map<string, RegisteredPrompt>;
129
+ get initialState(): MCPServerState;
130
+ /** The underlying MCP protocol server instance. Created during configure(). */
131
+ get mcpServer(): MCPProtocolServer;
132
+ /** The handler context passed to all tool, resource, and prompt handlers. */
133
+ get handlerContext(): MCPContext;
134
+ /**
135
+ * Register an MCP tool. The tool's Zod schema is converted to JSON Schema
136
+ * for the protocol listing, and used for runtime argument validation.
137
+ *
138
+ * Tool handlers can return a string (auto-wrapped as text content) or a
139
+ * full CallToolResult object for advanced responses (images, errors, etc).
140
+ *
141
+ * @param name - Unique tool name
142
+ * @param options - Tool schema, description, and handler
143
+ */
144
+ tool(name: string, options: ToolRegistrationOptions): this;
145
+ /**
146
+ * Register an MCP resource. Resources expose data (files, configs, etc)
147
+ * that AI clients can read by URI.
148
+ *
149
+ * Accepts either a handler function directly or an options object with
150
+ * additional metadata (name, description, mimeType).
151
+ *
152
+ * @param uri - Unique resource URI (e.g. "project://readme")
153
+ * @param handlerOrOptions - Handler function or options object with handler
154
+ */
155
+ resource(uri: string, handlerOrOptions: ResourceRegistrationOptions['handler'] | ResourceRegistrationOptions): this;
156
+ /**
157
+ * Register an MCP prompt. Prompts are reusable message templates that
158
+ * AI clients can invoke with optional string arguments.
159
+ *
160
+ * @param name - Unique prompt name
161
+ * @param options - Prompt handler, optional args schema, and description
162
+ */
163
+ prompt(name: string, options: PromptRegistrationOptions): this;
164
+ /**
165
+ * Configure the MCP protocol server and register all protocol handlers.
166
+ * Called automatically before start() if not already configured.
167
+ */
168
+ configure(): Promise<this>;
169
+ /**
170
+ * Start the MCP server with the specified transport.
171
+ *
172
+ * @param options - Transport configuration. Defaults to stdio.
173
+ * @param options.transport - 'stdio' for CLI integration, 'http' for remote access
174
+ * @param options.port - Port for HTTP transport (default 3001)
175
+ */
176
+ start(options?: {
177
+ transport?: 'stdio' | 'http';
178
+ port?: number;
179
+ host?: string;
180
+ mcpCompat?: MCPCompatMode;
181
+ stdioCompat?: StdioCompatMode;
182
+ }): Promise<this>;
183
+ /**
184
+ * Stop the MCP server and close all connections.
185
+ */
186
+ stop(): Promise<this>;
187
+ /** Register tools/list and tools/call protocol handlers on the MCP server. */
188
+ private _registerToolHandlers;
189
+ /** Register resources/list and resources/read protocol handlers on the MCP server. */
190
+ private _registerResourceHandlers;
191
+ /** Register prompts/list and prompts/get protocol handlers on the MCP server. */
192
+ private _registerPromptHandlers;
193
+ /** Start an HTTP transport using StreamableHTTPServerTransport. */
194
+ private _startHTTPTransport;
195
+ private _resolveMCPCompat;
196
+ private _resolveStdioCompat;
197
+ private _normalizeCodexRequest;
198
+ private _ensureJSONContentType;
199
+ }
200
+ export default MCPServer;
201
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/servers/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAyB,MAAM,oBAAoB,CAAA;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAavF,OAAO,QAAQ,WAAW,CAAC;IACzB,UAAU,gBAAgB;QACxB,GAAG,EAAE,OAAO,SAAS,CAAA;KACtB;CACF;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,aAAa,CAAA;CACzB,CAAA;AAED,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,KAAK,GAAG,CAAA;CAC7C;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,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BP;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAe9D;;;OAGG;IACY,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BzC;;;;;;OAMG;IACY,KAAK,CAAC,OAAO,CAAC,EAAE;QAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;QAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,SAAS,CAAC,EAAE,aAAa,CAAA;QACzB,WAAW,CAAC,EAAE,eAAe,CAAA;KAC9B,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BjB;;OAEG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAYpC,8EAA8E;IAC9E,OAAO,CAAC,qBAAqB;IAgD7B,sFAAsF;IACtF,OAAO,CAAC,yBAAyB;IAgCjC,iFAAiF;IACjF,OAAO,CAAC,uBAAuB;IAoC/B,mEAAmE;YACrD,mBAAmB;IAkDjC,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,sBAAsB;IA2B9B,OAAO,CAAC,sBAAsB;CAmD/B;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,121 @@
1
+ import { z } from 'zod';
2
+ import { type StartOptions, Server, type ServerState } from '../server.js';
3
+ import { WebSocketServer as BaseServer } from 'ws';
4
+ import type { PendingRequest } from '../clients/websocket.js';
5
+ declare module '../server' {
6
+ interface AvailableServers {
7
+ websocket: typeof WebsocketServer;
8
+ }
9
+ }
10
+ export declare const SocketServerOptionsSchema: z.ZodObject<{
11
+ name: z.ZodOptional<z.ZodString>;
12
+ _cacheKey: z.ZodOptional<z.ZodString>;
13
+ port: z.ZodOptional<z.ZodNumber>;
14
+ host: z.ZodOptional<z.ZodString>;
15
+ json: z.ZodOptional<z.ZodBoolean>;
16
+ }, z.core.$strip>;
17
+ export type SocketServerOptions = z.infer<typeof SocketServerOptionsSchema>;
18
+ export declare const SocketServerEventsSchema: z.ZodObject<{
19
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
20
+ connection: z.ZodTuple<[z.ZodAny], null>;
21
+ message: z.ZodTuple<[z.ZodAny, z.ZodAny], null>;
22
+ }, z.core.$strip>;
23
+ /**
24
+ * WebSocket server built on the `ws` library with optional JSON message framing.
25
+ *
26
+ * Manages WebSocket connections, tracks connected clients, and bridges
27
+ * messages to Luca's event bus. When `json` mode is enabled, incoming
28
+ * messages are automatically JSON-parsed (with `.toString()` for Buffer data)
29
+ * and outgoing messages via `send()` / `broadcast()` are JSON-stringified.
30
+ * When `json` mode is disabled, raw message data is emitted as-is and
31
+ * `send()` / `broadcast()` still JSON-stringify for safety.
32
+ *
33
+ * Supports ask/reply semantics when paired with the Luca WebSocket client.
34
+ * The server can `ask(ws, type, data)` a connected client and await a typed
35
+ * response, or handle incoming asks from clients by listening for messages
36
+ * with a `requestId` and replying via `send(ws, { replyTo, data })`.
37
+ * Requests time out if no reply arrives within the configurable window.
38
+ *
39
+ * @extends Server
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const ws = container.server('websocket', { json: true })
44
+ * await ws.start({ port: 8080 })
45
+ *
46
+ * ws.on('message', (data, client) => {
47
+ * console.log('Received:', data)
48
+ * ws.broadcast({ echo: data })
49
+ * })
50
+ *
51
+ * // ask/reply: request info from a connected client
52
+ * ws.on('connection', async (client) => {
53
+ * const info = await ws.ask(client, 'identify')
54
+ * console.log('Client says:', info)
55
+ * })
56
+ * ```
57
+ */
58
+ export declare class WebsocketServer<T extends ServerState = ServerState, K extends SocketServerOptions = SocketServerOptions> extends Server<T, K> {
59
+ static shortcut: "servers.websocket";
60
+ static stateSchema: z.ZodObject<{
61
+ port: z.ZodOptional<z.ZodNumber>;
62
+ listening: z.ZodDefault<z.ZodBoolean>;
63
+ configured: z.ZodDefault<z.ZodBoolean>;
64
+ stopped: z.ZodDefault<z.ZodBoolean>;
65
+ }, z.core.$loose>;
66
+ static optionsSchema: z.ZodObject<{
67
+ name: z.ZodOptional<z.ZodString>;
68
+ _cacheKey: z.ZodOptional<z.ZodString>;
69
+ port: z.ZodOptional<z.ZodNumber>;
70
+ host: z.ZodOptional<z.ZodString>;
71
+ json: z.ZodOptional<z.ZodBoolean>;
72
+ }, z.core.$strip>;
73
+ static eventsSchema: z.ZodObject<{
74
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
75
+ connection: z.ZodTuple<[z.ZodAny], null>;
76
+ message: z.ZodTuple<[z.ZodAny, z.ZodAny], null>;
77
+ }, z.core.$strip>;
78
+ _wss?: BaseServer;
79
+ get wss(): BaseServer;
80
+ connections: Set<any>;
81
+ _pending: Map<string, PendingRequest<any>>;
82
+ broadcast(message: any): Promise<this>;
83
+ send(ws: any, message: any): Promise<this>;
84
+ /**
85
+ * Send a request to a specific client and wait for a correlated response.
86
+ * The client is expected to reply with a message whose `replyTo` matches
87
+ * the `requestId` of this message.
88
+ *
89
+ * @param ws - The WebSocket client to ask
90
+ * @param type - A string identifying the request type
91
+ * @param data - Optional payload
92
+ * @param timeout - How long to wait (default 10 000 ms)
93
+ * @returns The `data` field of the response
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * ws.on('connection', async (client) => {
98
+ * const info = await ws.ask(client, 'identify')
99
+ * console.log('Client says:', info)
100
+ * })
101
+ * ```
102
+ */
103
+ ask<R = any>(ws: any, type: string, data?: any, timeout?: number): Promise<R>;
104
+ /** @internal Resolve a pending ask() if the incoming message has a replyTo field. Returns true if handled. */
105
+ _handleReply(message: any): boolean;
106
+ /** @internal Reject all pending ask() calls — used on stop. */
107
+ _rejectAllPending(reason: string): void;
108
+ /**
109
+ * Start the WebSocket server. A runtime `port` overrides the constructor
110
+ * option and is written to state before the underlying `ws.Server` is created,
111
+ * so the server binds to the correct port.
112
+ *
113
+ * @param options - Optional runtime overrides for port and host
114
+ */
115
+ start(options?: StartOptions): Promise<this>;
116
+ stop(): Promise<this>;
117
+ /** The port this server will bind to. Defaults to 8081 if not set via constructor options or start(). */
118
+ get port(): number;
119
+ }
120
+ export default WebsocketServer;
121
+ //# sourceMappingURL=socket.d.ts.map