@soederpop/luca 0.1.2 → 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 (366) hide show
  1. package/CLAUDE.md +2 -0
  2. package/assistants/codingAssistant/hooks.ts +1 -5
  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/src/agi/feature.ts +13 -0
  300. package/src/agi/features/assistant.ts +36 -25
  301. package/src/agi/features/assistants-manager.ts +70 -5
  302. package/src/agi/features/autonomous-assistant.ts +1 -5
  303. package/src/agi/features/browser-use.ts +2 -2
  304. package/src/agi/features/claude-code.ts +165 -1
  305. package/src/agi/features/conversation-history.ts +2 -6
  306. package/src/agi/features/conversation.ts +95 -3
  307. package/src/agi/features/docs-reader.ts +2 -1
  308. package/src/agi/features/file-tools.ts +2 -2
  309. package/src/agi/features/luca-coder.ts +1 -5
  310. package/src/agi/features/openai-codex.ts +1 -1
  311. package/src/agi/features/openapi.ts +3 -3
  312. package/src/agi/features/skills-library.ts +87 -6
  313. package/src/agi/lib/interceptor-chain.ts +10 -0
  314. package/src/agi/lib/token-counter.ts +1 -1
  315. package/src/bootstrap/generated.ts +126 -1
  316. package/src/bus.ts +27 -5
  317. package/src/cli/build-info.ts +2 -2
  318. package/src/client.ts +2 -2
  319. package/src/clients/elevenlabs/index.ts +5 -0
  320. package/src/commands/bootstrap.ts +2 -1
  321. package/src/commands/chat.ts +1 -0
  322. package/src/commands/code.ts +4 -2
  323. package/src/commands/prompt.ts +34 -34
  324. package/src/commands/sandbox-mcp.ts +69 -163
  325. package/src/commands/save-api-docs.ts +10 -8
  326. package/src/commands/select.ts +8 -3
  327. package/src/container-describer.ts +70 -84
  328. package/src/container.ts +93 -3
  329. package/src/endpoint.ts +1 -1
  330. package/src/entity.ts +173 -0
  331. package/src/feature.ts +3 -3
  332. package/src/helper.ts +8 -4
  333. package/src/introspection/generated.agi.ts +1246 -798
  334. package/src/introspection/generated.node.ts +892 -798
  335. package/src/introspection/generated.web.ts +95 -3
  336. package/src/introspection/scan.ts +1 -1
  337. package/src/node/container.ts +1 -1
  338. package/src/node/features/content-db.ts +3 -3
  339. package/src/node/features/file-manager.ts +10 -9
  340. package/src/node/features/git.ts +5 -5
  341. package/src/node/features/helpers.ts +1 -1
  342. package/src/node/features/json-tree.ts +1 -1
  343. package/src/node/features/os.ts +3 -3
  344. package/src/node/features/package-finder.ts +1 -1
  345. package/src/node/features/process-manager.ts +1 -1
  346. package/src/node/features/python.ts +3 -3
  347. package/src/node/features/redis.ts +1 -1
  348. package/src/node/features/repl.ts +2 -2
  349. package/src/node/features/transpiler.ts +2 -2
  350. package/src/node/features/ui.ts +1 -1
  351. package/src/node/features/vm.ts +3 -3
  352. package/src/node/features/yaml-tree.ts +1 -1
  353. package/src/node.ts +1 -0
  354. package/src/python/generated.ts +1 -1
  355. package/src/scaffolds/generated.ts +1 -1
  356. package/src/selector.ts +74 -4
  357. package/src/server.ts +2 -2
  358. package/src/servers/mcp.ts +6 -6
  359. package/src/web/features/helpers.ts +1 -1
  360. package/src/web/features/network.ts +1 -0
  361. package/test/conversation.test.ts +220 -0
  362. package/tsconfig.build.json +12 -0
  363. package/tsconfig.json +1 -1
  364. package/scripts/examples/telegram-ink-ui.ts +0 -302
  365. package/scripts/examples/using-openai-codex.ts +0 -23
  366. package/scripts/examples/vm-loading-esm-modules.ts +0 -16
@@ -0,0 +1,464 @@
1
+ import { z } from 'zod';
2
+ import { Feature } from '../feature.js';
3
+ import type { OpenAIClient } from '../../clients/openai';
4
+ import type OpenAI from 'openai';
5
+ import type { ConversationHistory } from './conversation-history';
6
+ declare module '@soederpop/luca/feature' {
7
+ interface AvailableFeatures {
8
+ conversation: typeof Conversation;
9
+ }
10
+ }
11
+ export type Message = OpenAI.Chat.Completions.ChatCompletionMessageParam;
12
+ export type ContentPart = {
13
+ type: 'text';
14
+ text: string;
15
+ } | {
16
+ type: 'image_url';
17
+ image_url: {
18
+ url: string;
19
+ detail?: 'low' | 'high' | 'auto';
20
+ };
21
+ } | {
22
+ type: 'input_audio';
23
+ data: string;
24
+ format: 'mp3' | 'wav';
25
+ } | {
26
+ type: 'input_file';
27
+ file_data: string;
28
+ filename: string;
29
+ };
30
+ export interface ConversationTool {
31
+ handler: (...args: any[]) => Promise<any>;
32
+ description: string;
33
+ parameters: Record<string, any>;
34
+ }
35
+ export interface ConversationMCPServer {
36
+ url: string;
37
+ headers?: Record<string, string>;
38
+ allowedTools?: string[] | {
39
+ tool_names?: string[];
40
+ };
41
+ requireApproval?: 'always' | 'never' | {
42
+ always?: {
43
+ tool_names?: string[];
44
+ };
45
+ never?: {
46
+ tool_names?: string[];
47
+ };
48
+ };
49
+ }
50
+ export declare const ConversationOptionsSchema: z.ZodObject<{
51
+ name: z.ZodOptional<z.ZodString>;
52
+ _cacheKey: z.ZodOptional<z.ZodString>;
53
+ cached: z.ZodOptional<z.ZodBoolean>;
54
+ enable: z.ZodOptional<z.ZodBoolean>;
55
+ id: z.ZodOptional<z.ZodString>;
56
+ title: z.ZodOptional<z.ZodString>;
57
+ thread: z.ZodOptional<z.ZodString>;
58
+ model: z.ZodOptional<z.ZodString>;
59
+ history: z.ZodOptional<z.ZodArray<z.ZodAny>>;
60
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
61
+ mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
62
+ api: z.ZodOptional<z.ZodEnum<{
63
+ auto: "auto";
64
+ responses: "responses";
65
+ chat: "chat";
66
+ }>>;
67
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
68
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
69
+ clientOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
70
+ local: z.ZodOptional<z.ZodBoolean>;
71
+ maxTokens: z.ZodOptional<z.ZodNumber>;
72
+ temperature: z.ZodOptional<z.ZodNumber>;
73
+ topP: z.ZodOptional<z.ZodNumber>;
74
+ topK: z.ZodOptional<z.ZodNumber>;
75
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
76
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
77
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
78
+ autoCompact: z.ZodOptional<z.ZodBoolean>;
79
+ compactThreshold: z.ZodOptional<z.ZodNumber>;
80
+ contextWindow: z.ZodOptional<z.ZodNumber>;
81
+ compactKeepRecent: z.ZodOptional<z.ZodNumber>;
82
+ }, z.core.$strip>;
83
+ export declare const ConversationStateSchema: z.ZodObject<{
84
+ enabled: z.ZodDefault<z.ZodBoolean>;
85
+ id: z.ZodString;
86
+ thread: z.ZodString;
87
+ model: z.ZodString;
88
+ messages: z.ZodArray<z.ZodAny>;
89
+ streaming: z.ZodBoolean;
90
+ lastResponse: z.ZodString;
91
+ toolCalls: z.ZodNumber;
92
+ api: z.ZodEnum<{
93
+ responses: "responses";
94
+ chat: "chat";
95
+ }>;
96
+ lastResponseId: z.ZodNullable<z.ZodString>;
97
+ tokenUsage: z.ZodObject<{
98
+ prompt: z.ZodNumber;
99
+ completion: z.ZodNumber;
100
+ total: z.ZodNumber;
101
+ }, z.core.$strip>;
102
+ estimatedInputTokens: z.ZodNumber;
103
+ compactionCount: z.ZodNumber;
104
+ contextWindow: z.ZodNumber;
105
+ tools: z.ZodRecord<z.ZodString, z.ZodAny>;
106
+ callMaxTokens: z.ZodNullable<z.ZodNumber>;
107
+ }, z.core.$loose>;
108
+ export declare const ConversationEventsSchema: z.ZodObject<{
109
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
110
+ enabled: z.ZodTuple<[], null>;
111
+ userMessage: z.ZodTuple<[z.ZodAny], null>;
112
+ turnStart: z.ZodTuple<[z.ZodObject<{
113
+ turn: z.ZodNumber;
114
+ isFollowUp: z.ZodBoolean;
115
+ }, z.core.$strip>], null>;
116
+ turnEnd: z.ZodTuple<[z.ZodObject<{
117
+ turn: z.ZodNumber;
118
+ hasToolCalls: z.ZodBoolean;
119
+ }, z.core.$strip>], null>;
120
+ toolCallsStart: z.ZodTuple<[z.ZodAny], null>;
121
+ toolCall: z.ZodTuple<[z.ZodString, z.ZodAny], null>;
122
+ toolResult: z.ZodTuple<[z.ZodString, z.ZodString], null>;
123
+ toolError: z.ZodTuple<[z.ZodString, z.ZodAny], null>;
124
+ toolCallsEnd: z.ZodTuple<[], null>;
125
+ chunk: z.ZodTuple<[z.ZodString], null>;
126
+ preview: z.ZodTuple<[z.ZodString], null>;
127
+ response: z.ZodTuple<[z.ZodString], null>;
128
+ responseCompleted: z.ZodTuple<[z.ZodAny], null>;
129
+ rawEvent: z.ZodTuple<[z.ZodAny], null>;
130
+ mcpEvent: z.ZodTuple<[z.ZodAny], null>;
131
+ summarizeStart: z.ZodTuple<[], null>;
132
+ summarizeEnd: z.ZodTuple<[z.ZodString], null>;
133
+ compactStart: z.ZodTuple<[z.ZodObject<{
134
+ messageCount: z.ZodNumber;
135
+ keepRecent: z.ZodNumber;
136
+ }, z.core.$strip>], null>;
137
+ compactEnd: z.ZodTuple<[z.ZodObject<{
138
+ summary: z.ZodString;
139
+ removedCount: z.ZodNumber;
140
+ estimatedTokens: z.ZodNumber;
141
+ compactionCount: z.ZodNumber;
142
+ }, z.core.$strip>], null>;
143
+ autoCompactTriggered: z.ZodTuple<[z.ZodObject<{
144
+ estimated: z.ZodNumber;
145
+ limit: z.ZodNumber;
146
+ contextWindow: z.ZodNumber;
147
+ }, z.core.$strip>], null>;
148
+ }, z.core.$strip>;
149
+ export type ConversationOptions = z.infer<typeof ConversationOptionsSchema>;
150
+ export type ConversationState = z.infer<typeof ConversationStateSchema>;
151
+ export type AskOptions = {
152
+ maxTokens?: number;
153
+ /**
154
+ * When provided, enables OpenAI Structured Outputs. The model is constrained
155
+ * to return JSON matching this Zod schema. The return value of ask() will be
156
+ * the parsed object instead of a raw string.
157
+ */
158
+ schema?: z.ZodType;
159
+ };
160
+ /**
161
+ * A self-contained conversation with OpenAI that supports streaming,
162
+ * tool calling, and message state management.
163
+ *
164
+ * @extends Feature
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const conversation = container.feature('conversation', {
169
+ * model: 'gpt-4.1',
170
+ * tools: myToolMap,
171
+ * history: [{ role: 'system', content: 'You are a helpful assistant.' }]
172
+ * })
173
+ * const reply = await conversation.ask('What is the meaning of life?')
174
+ * ```
175
+ */
176
+ export declare class Conversation extends Feature<ConversationState, ConversationOptions> {
177
+ static stateSchema: z.ZodObject<{
178
+ enabled: z.ZodDefault<z.ZodBoolean>;
179
+ id: z.ZodString;
180
+ thread: z.ZodString;
181
+ model: z.ZodString;
182
+ messages: z.ZodArray<z.ZodAny>;
183
+ streaming: z.ZodBoolean;
184
+ lastResponse: z.ZodString;
185
+ toolCalls: z.ZodNumber;
186
+ api: z.ZodEnum<{
187
+ responses: "responses";
188
+ chat: "chat";
189
+ }>;
190
+ lastResponseId: z.ZodNullable<z.ZodString>;
191
+ tokenUsage: z.ZodObject<{
192
+ prompt: z.ZodNumber;
193
+ completion: z.ZodNumber;
194
+ total: z.ZodNumber;
195
+ }, z.core.$strip>;
196
+ estimatedInputTokens: z.ZodNumber;
197
+ compactionCount: z.ZodNumber;
198
+ contextWindow: z.ZodNumber;
199
+ tools: z.ZodRecord<z.ZodString, z.ZodAny>;
200
+ callMaxTokens: z.ZodNullable<z.ZodNumber>;
201
+ }, z.core.$loose>;
202
+ static optionsSchema: z.ZodObject<{
203
+ name: z.ZodOptional<z.ZodString>;
204
+ _cacheKey: z.ZodOptional<z.ZodString>;
205
+ cached: z.ZodOptional<z.ZodBoolean>;
206
+ enable: z.ZodOptional<z.ZodBoolean>;
207
+ id: z.ZodOptional<z.ZodString>;
208
+ title: z.ZodOptional<z.ZodString>;
209
+ thread: z.ZodOptional<z.ZodString>;
210
+ model: z.ZodOptional<z.ZodString>;
211
+ history: z.ZodOptional<z.ZodArray<z.ZodAny>>;
212
+ tools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
213
+ mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
214
+ api: z.ZodOptional<z.ZodEnum<{
215
+ auto: "auto";
216
+ responses: "responses";
217
+ chat: "chat";
218
+ }>>;
219
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
220
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
221
+ clientOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
222
+ local: z.ZodOptional<z.ZodBoolean>;
223
+ maxTokens: z.ZodOptional<z.ZodNumber>;
224
+ temperature: z.ZodOptional<z.ZodNumber>;
225
+ topP: z.ZodOptional<z.ZodNumber>;
226
+ topK: z.ZodOptional<z.ZodNumber>;
227
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
228
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
229
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
230
+ autoCompact: z.ZodOptional<z.ZodBoolean>;
231
+ compactThreshold: z.ZodOptional<z.ZodNumber>;
232
+ contextWindow: z.ZodOptional<z.ZodNumber>;
233
+ compactKeepRecent: z.ZodOptional<z.ZodNumber>;
234
+ }, z.core.$strip>;
235
+ static eventsSchema: z.ZodObject<{
236
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
237
+ enabled: z.ZodTuple<[], null>;
238
+ userMessage: z.ZodTuple<[z.ZodAny], null>;
239
+ turnStart: z.ZodTuple<[z.ZodObject<{
240
+ turn: z.ZodNumber;
241
+ isFollowUp: z.ZodBoolean;
242
+ }, z.core.$strip>], null>;
243
+ turnEnd: z.ZodTuple<[z.ZodObject<{
244
+ turn: z.ZodNumber;
245
+ hasToolCalls: z.ZodBoolean;
246
+ }, z.core.$strip>], null>;
247
+ toolCallsStart: z.ZodTuple<[z.ZodAny], null>;
248
+ toolCall: z.ZodTuple<[z.ZodString, z.ZodAny], null>;
249
+ toolResult: z.ZodTuple<[z.ZodString, z.ZodString], null>;
250
+ toolError: z.ZodTuple<[z.ZodString, z.ZodAny], null>;
251
+ toolCallsEnd: z.ZodTuple<[], null>;
252
+ chunk: z.ZodTuple<[z.ZodString], null>;
253
+ preview: z.ZodTuple<[z.ZodString], null>;
254
+ response: z.ZodTuple<[z.ZodString], null>;
255
+ responseCompleted: z.ZodTuple<[z.ZodAny], null>;
256
+ rawEvent: z.ZodTuple<[z.ZodAny], null>;
257
+ mcpEvent: z.ZodTuple<[z.ZodAny], null>;
258
+ summarizeStart: z.ZodTuple<[], null>;
259
+ summarizeEnd: z.ZodTuple<[z.ZodString], null>;
260
+ compactStart: z.ZodTuple<[z.ZodObject<{
261
+ messageCount: z.ZodNumber;
262
+ keepRecent: z.ZodNumber;
263
+ }, z.core.$strip>], null>;
264
+ compactEnd: z.ZodTuple<[z.ZodObject<{
265
+ summary: z.ZodString;
266
+ removedCount: z.ZodNumber;
267
+ estimatedTokens: z.ZodNumber;
268
+ compactionCount: z.ZodNumber;
269
+ }, z.core.$strip>], null>;
270
+ autoCompactTriggered: z.ZodTuple<[z.ZodObject<{
271
+ estimated: z.ZodNumber;
272
+ limit: z.ZodNumber;
273
+ contextWindow: z.ZodNumber;
274
+ }, z.core.$strip>], null>;
275
+ }, z.core.$strip>;
276
+ static shortcut: "features.conversation";
277
+ /**
278
+ * Pluggable tool executor. Called for each tool invocation with the tool
279
+ * name, parsed args, and the default handler. Return the serialized result string.
280
+ * The Assistant replaces this to wire in beforeToolCall/afterToolCall interceptors.
281
+ */
282
+ toolExecutor: ((name: string, args: Record<string, any>, handler: (...args: any[]) => Promise<any>) => Promise<string>) | null;
283
+ /** The active structured output schema for the current ask() call, if any. */
284
+ private _activeSchema;
285
+ /** Registered stubs: matched against user input to short-circuit the API with a canned response. */
286
+ private _stubs;
287
+ /** Resolved max tokens: per-call override > options-level > default 512. */
288
+ private get maxTokens();
289
+ /** @returns Default state seeded from options: id, thread, model, initial history, and zero token usage. */
290
+ get initialState(): ConversationState;
291
+ /** Returns the registered tools available for the model to call. */
292
+ get tools(): Record<string, ConversationTool>;
293
+ get availableTools(): string[];
294
+ /**
295
+ * Add or replace a single tool by name.
296
+ * Uses the same format as tools passed at construction time.
297
+ */
298
+ addTool(name: string, tool: ConversationTool): this;
299
+ /**
300
+ * Remove a tool by name.
301
+ */
302
+ removeTool(name: string): this;
303
+ /**
304
+ * Merge new tools into the conversation, replacing any with the same name.
305
+ * Accepts the same Record<string, ConversationTool> format used at construction time.
306
+ */
307
+ updateTools(tools: Record<string, ConversationTool>): this;
308
+ /**
309
+ * Register a hardcoded stub response that bypasses the API when the user's message matches.
310
+ * Streaming is still simulated — chunk/preview events fire word-by-word.
311
+ *
312
+ * @param matcher - Exact string match, substring, or RegExp tested against user input
313
+ * @param response - The text to stream back, or a zero-arg function that returns it
314
+ *
315
+ * @example
316
+ * conversation.stub('hello', 'Hi there!')
317
+ * conversation.stub(/weather/i, () => 'Sunny and 72°F.')
318
+ */
319
+ stub(matcher: string | RegExp, response: string | (() => string)): this;
320
+ /** Returns configured remote MCP servers keyed by server label. */
321
+ get mcpServers(): Record<string, ConversationMCPServer>;
322
+ /** Returns the full message history of the conversation. */
323
+ get messages(): Message[];
324
+ /** Returns the OpenAI model name being used for completions. */
325
+ get model(): string;
326
+ /** Returns the active completion API mode after resolving auto/local behavior. */
327
+ get apiMode(): 'responses' | 'chat';
328
+ /** Whether a streaming response is currently in progress. */
329
+ get isStreaming(): boolean;
330
+ /**
331
+ * Returns the correct parameter name for limiting output tokens.
332
+ * Local models (LM Studio, Ollama) and legacy OpenAI models use max_tokens.
333
+ * Newer OpenAI models (gpt-4o+, gpt-4.1, gpt-5, o1, o3, o4) require max_completion_tokens.
334
+ */
335
+ private get maxTokensParam();
336
+ /** The context window size for the current model (from options override or auto-detected). */
337
+ get contextWindow(): number;
338
+ /** Whether the conversation is approaching the context limit. */
339
+ get isNearContextLimit(): boolean;
340
+ /**
341
+ * Estimate the input token count for the current messages array
342
+ * using the js-tiktoken tokenizer. Updates state.
343
+ */
344
+ estimateTokens(): number;
345
+ /**
346
+ * Generate a summary of the conversation so far using the LLM.
347
+ * Read-only — does not modify messages.
348
+ */
349
+ summarize(): Promise<string>;
350
+ /**
351
+ * Compact the conversation by summarizing old messages and replacing them
352
+ * with a summary message. Keeps the system message (if any) and the most
353
+ * recent N messages.
354
+ */
355
+ compact(options?: {
356
+ keepRecent?: number;
357
+ }): Promise<{
358
+ summary: string;
359
+ removedCount: number;
360
+ estimatedTokens: number;
361
+ }>;
362
+ /**
363
+ * Get the OpenAI-formatted tools array from the registered tools.
364
+ *
365
+ * @returns {OpenAI.Chat.Completions.ChatCompletionTool[]} The tools formatted for OpenAI
366
+ */
367
+ private get openaiTools();
368
+ /**
369
+ * Get the OpenAI Responses-formatted tools array from local function tools
370
+ * plus configured remote MCP servers.
371
+ */
372
+ private get responseTools();
373
+ /** Returns the first system/developer text message to use as Responses instructions. */
374
+ private get responsesInstructions();
375
+ /**
376
+ * Send a message and get a streamed response. Automatically handles
377
+ * tool calls by invoking the registered handlers and feeding results
378
+ * back to the model until a final text response is produced.
379
+ *
380
+ * @param {string | ContentPart[]} content - The user message, either a string or array of content parts (text + images)
381
+ * @returns {Promise<string>} The assistant's final text response
382
+ *
383
+ * @example
384
+ * const reply = await conversation.ask("What's the weather in SF?")
385
+ * // With image:
386
+ * const reply = await conversation.ask([
387
+ * { type: 'text', text: 'What is in this diagram?' },
388
+ * { type: 'image_url', image_url: { url: 'data:image/png;base64,...' } }
389
+ * ])
390
+ */
391
+ ask(content: string | ContentPart[], options?: AskOptions): Promise<string>;
392
+ /** Convert user content into a Responses API input message item. */
393
+ private toResponsesUserMessage;
394
+ /**
395
+ * Convert the full Chat Completions message history into Responses API input items.
396
+ * Used when resuming a conversation without a previous_response_id.
397
+ */
398
+ private messagesToResponsesInput;
399
+ /**
400
+ * Build the OpenAI response_format / text.format config from the active Zod schema.
401
+ * Returns undefined when no schema is active.
402
+ */
403
+ private get structuredOutputConfig();
404
+ /** Returns the OpenAI client instance from the container. */
405
+ get openai(): OpenAIClient;
406
+ /** Returns the conversationHistory feature for persistence. */
407
+ get history(): ConversationHistory;
408
+ /**
409
+ * Persist this conversation to disk via conversationHistory.
410
+ * Creates a new record if this conversation hasn't been saved before,
411
+ * or updates the existing one.
412
+ *
413
+ * @param opts - Optional overrides for title, tags, thread, or metadata
414
+ * @returns The saved conversation record
415
+ */
416
+ save(opts?: {
417
+ title?: string;
418
+ tags?: string[];
419
+ thread?: string;
420
+ metadata?: Record<string, any>;
421
+ }): Promise<import("./conversation-history").ConversationRecord>;
422
+ /**
423
+ * Execute a single tool call, routing through the pluggable toolExecutor
424
+ * if one is set (e.g. by the Assistant's interceptor chain).
425
+ */
426
+ private executeTool;
427
+ /** Check registered stubs against user input. Returns the response text, or null if no match. */
428
+ private _matchStub;
429
+ /**
430
+ * Simulate a streaming response for a hardcoded stub text.
431
+ * Emits chunk/preview events word-by-word, yielding between each to keep the event loop alive.
432
+ */
433
+ private _streamStub;
434
+ /**
435
+ * Runs the streaming Responses API loop. Handles local function calls by
436
+ * executing handlers and submitting `function_call_output` items until
437
+ * the model produces a final text response.
438
+ */
439
+ private runResponsesLoop;
440
+ /** Apply Responses API usage stats to this conversation's token usage counters. */
441
+ private applyResponsesUsage;
442
+ /**
443
+ * Runs the streaming completion loop. If the model requests tool calls,
444
+ * executes them and loops again until a text response is produced.
445
+ *
446
+ * @returns {Promise<string>} The final assistant text response
447
+ */
448
+ /**
449
+ * Runs the streaming completion loop. If the model requests tool calls,
450
+ * executes them and loops again until a text response is produced.
451
+ *
452
+ * @param context - Turn tracking: turn number and text accumulated across all turns
453
+ * @returns {Promise<string>} The final assistant text response (accumulated across all turns)
454
+ */
455
+ private runChatCompletionLoop;
456
+ /**
457
+ * Append a message to the conversation state.
458
+ *
459
+ * @param {Message} message - The message to append
460
+ */
461
+ pushMessage(message: Message): void;
462
+ }
463
+ export default Conversation;
464
+ //# sourceMappingURL=conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/agi/features/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,iBAAiB;QAC1B,YAAY,EAAE,OAAO,YAAY,CAAA;KACjC;CACD;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC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AC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IA4C7H;;;;OAIG;IACH,OAAO,KAAK,WAAW,GAStB;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAqBxB;IAED,wFAAwF;IACxF,OAAO,KAAK,qBAAqB,GAOhC;IAED;;;;;;;;;;;;;;;OAeG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAoEjF,oEAAoE;IACpE,OAAO,CAAC,sBAAsB;IAkC9B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IA2ChC;;;OAGG;IACH,OAAO,KAAK,sBAAsB,GAgBjC;IAED,6DAA6D;IAC7D,IAAI,MAAM,IAWH,YAAY,CAClB;IAED,+DAA+D;IAC/D,IAAI,OAAO,IAAI,mBAAmB,CAEjC;IAED;;;;;;;OAOG;IACG,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE;IA8BtG;;;OAGG;YACW,WAAW;IAqCzB,iGAAiG;IACjG,OAAO,CAAC,UAAU;IAYlB;;;OAGG;YACW,WAAW;IA2BzB;;;;OAIG;YACW,gBAAgB;IAkI9B,mFAAmF;IACnF,OAAO,CAAC,mBAAmB;IAU3B;;;;;OAKG;IACH;;;;;;OAMG;YACW,qBAAqB;IAuHnC;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO;CAG5B;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ import { Feature } from '../feature.js';
3
+ import type { ContentDb } from '@/node.js';
4
+ import type Assistant from './assistant.js';
5
+ declare module '@soederpop/luca/feature' {
6
+ interface AvailableFeatures {
7
+ docsReader: typeof DocsReader;
8
+ }
9
+ }
10
+ export declare const DocsReaderStateSchema: z.ZodObject<{
11
+ enabled: z.ZodDefault<z.ZodBoolean>;
12
+ started: z.ZodBoolean;
13
+ }, z.core.$loose>;
14
+ export declare const DocsReaderOptionsSchema: z.ZodObject<{
15
+ name: z.ZodOptional<z.ZodString>;
16
+ _cacheKey: z.ZodOptional<z.ZodString>;
17
+ cached: z.ZodOptional<z.ZodBoolean>;
18
+ enable: z.ZodOptional<z.ZodBoolean>;
19
+ contentDb: z.ZodUnion<readonly [z.ZodString, z.ZodAny]>;
20
+ model: z.ZodDefault<z.ZodString>;
21
+ local: z.ZodDefault<z.ZodBoolean>;
22
+ }, z.core.$loose>;
23
+ export declare const DocsReaderEventsSchema: z.ZodObject<{
24
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
25
+ enabled: z.ZodTuple<[], null>;
26
+ loaded: z.ZodTuple<[], null>;
27
+ }, z.core.$strip>;
28
+ export type DocsReaderState = z.infer<typeof DocsReaderStateSchema>;
29
+ export type DocsReaderOptions = z.infer<typeof DocsReaderOptionsSchema>;
30
+ /**
31
+ * The DocsReader feature is an AI Assisted wrapper around a ContentDB feature.
32
+ *
33
+ * You can ask it questions about the content, and it will use the ContentDB to find the answers
34
+ * from the documents.
35
+ */
36
+ export declare class DocsReader extends Feature<DocsReaderState, DocsReaderOptions> {
37
+ static stateSchema: z.ZodObject<{
38
+ enabled: z.ZodDefault<z.ZodBoolean>;
39
+ started: z.ZodBoolean;
40
+ }, z.core.$loose>;
41
+ static optionsSchema: z.ZodObject<{
42
+ name: z.ZodOptional<z.ZodString>;
43
+ _cacheKey: z.ZodOptional<z.ZodString>;
44
+ cached: z.ZodOptional<z.ZodBoolean>;
45
+ enable: z.ZodOptional<z.ZodBoolean>;
46
+ contentDb: z.ZodUnion<readonly [z.ZodString, z.ZodAny]>;
47
+ model: z.ZodDefault<z.ZodString>;
48
+ local: z.ZodDefault<z.ZodBoolean>;
49
+ }, z.core.$loose>;
50
+ static eventsSchema: z.ZodObject<{
51
+ stateChange: z.ZodTuple<[z.ZodAny], null>;
52
+ enabled: z.ZodTuple<[], null>;
53
+ loaded: z.ZodTuple<[], null>;
54
+ }, z.core.$strip>;
55
+ static shortcut: "features.docsReader";
56
+ /** @returns Default state with started=false. */
57
+ get initialState(): DocsReaderState;
58
+ /** Whether the docs reader has been started. */
59
+ get isStarted(): boolean;
60
+ calculateCacheKeyForQuestion(question: string): string;
61
+ get answerCache(): import("@/node.js").DiskCache;
62
+ get contentDb(): ContentDb;
63
+ ask(question: string): Promise<string>;
64
+ askCached(question: string): Promise<any>;
65
+ assistant?: Assistant;
66
+ private generateSpecificCollectionExplainer;
67
+ /** Start the docs reader by loading the contentDb and wiring its tools into an assistant. */
68
+ start(): Promise<DocsReader>;
69
+ }
70
+ export default DocsReader;
71
+ export declare const CONTENT_DB_SYSTEM_PROMPT = "You answer questions using a collection of structured documents. Follow this workflow:\n\n1. Start with getCollectionOverview to understand the collection structure, available models, and document counts\n2. Use listDocuments or queryDocuments to find relevant documents by model, glob pattern, or metadata filters\n3. Use searchContent for text/regex search or semanticSearch for natural language queries\n4. Use readDocument to read specific documents \u2014 use include/exclude to focus on relevant sections and avoid loading unnecessary content\n5. Synthesize your answer from the documents you've read\n\nBe precise: read only what you need, use section filtering to stay focused, and cite document IDs in your answers.";
72
+ //# sourceMappingURL=docs-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-reader.d.ts","sourceRoot":"","sources":["../../../src/agi/features/docs-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,iBAAiB;QAC1B,UAAU,EAAE,OAAO,UAAU,CAAA;KAC7B;CACD;AAED,eAAO,MAAM,qBAAqB;;;iBAEhC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;iBAO1B,CAAA;AAEV,eAAO,MAAM,sBAAsB;;;;iBAEH,CAAA;AAEhC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE;;;;;EAKE;AACF,qBAAa,UAAW,SAAQ,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC;IAC1E,OAAgB,WAAW;;;sBAAwB;IACnD,OAAgB,aAAa;;;;;;;;sBAA0B;IACvD,OAAgB,YAAY;;;;sBAAyB;IACrD,OAAgB,QAAQ,EAAG,qBAAqB,CAAS;IAIzD,iDAAiD;IACjD,IAAa,YAAY,IAAI,eAAe,CAK3C;IAED,gDAAgD;IAChD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,4BAA4B,CAAC,QAAQ,EAAE,MAAM;IAO7C,IAAI,WAAW,kCAEd;IAED,IAAI,SAAS,IAAK,SAAS,CAI1B;IAEK,GAAG,CAAC,QAAQ,EAAE,MAAM;IAYpB,SAAS,CAAC,QAAQ,EAAE,MAAM;IAoBhC,SAAS,CAAC,EAAE,SAAS,CAAA;IAGrB,OAAO,CAAC,mCAAmC;IAsB3C,6FAA6F;IACvF,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;CAmBlC;AAED,eAAe,UAAU,CAAA;AAEzB,eAAO,MAAM,wBAAwB,ytBAQ8E,CAAA"}
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod';
2
+ import { Feature } from '../feature.js';
3
+ import type { Helper } from '../../helper.js';
4
+ declare module '@soederpop/luca/feature' {
5
+ interface AvailableFeatures {
6
+ fileTools: typeof FileTools;
7
+ }
8
+ }
9
+ export declare const FileToolsStateSchema: z.ZodObject<{
10
+ enabled: z.ZodDefault<z.ZodBoolean>;
11
+ }, z.core.$loose>;
12
+ export declare const FileToolsOptionsSchema: z.ZodObject<{
13
+ name: z.ZodOptional<z.ZodString>;
14
+ _cacheKey: z.ZodOptional<z.ZodString>;
15
+ cached: z.ZodOptional<z.ZodBoolean>;
16
+ enable: z.ZodOptional<z.ZodBoolean>;
17
+ }, z.core.$strip>;
18
+ /**
19
+ * Curated file-system and code-search tools for AI assistants.
20
+ *
21
+ * Wraps the container's `fs` and `grep` features into a focused tool surface
22
+ * modeled on the tools that coding assistants (Claude Code, Cursor, etc.) rely on:
23
+ * read, write, edit, list, search, find, stat, mkdir, move, copy, delete.
24
+ *
25
+ * Usage:
26
+ * ```typescript
27
+ * const fileTools = container.feature('fileTools')
28
+ * assistant.use(fileTools)
29
+ * // or selectively:
30
+ * assistant.use(fileTools.toTools({ only: ['readFile', 'searchFiles', 'listDirectory'] }))
31
+ * ```
32
+ *
33
+ * @extends Feature
34
+ */
35
+ export declare class FileTools extends Feature {
36
+ static shortcut: "features.fileTools";
37
+ static stateSchema: z.ZodObject<{
38
+ enabled: z.ZodDefault<z.ZodBoolean>;
39
+ }, z.core.$loose>;
40
+ static optionsSchema: z.ZodObject<{
41
+ name: z.ZodOptional<z.ZodString>;
42
+ _cacheKey: z.ZodOptional<z.ZodString>;
43
+ cached: z.ZodOptional<z.ZodBoolean>;
44
+ enable: z.ZodOptional<z.ZodBoolean>;
45
+ }, z.core.$strip>;
46
+ static tools: Record<string, {
47
+ schema: z.ZodType;
48
+ description?: string;
49
+ }>;
50
+ private get fs();
51
+ private get grep();
52
+ readFile(args: {
53
+ path: string;
54
+ offset?: number;
55
+ limit?: number;
56
+ }): Promise<string>;
57
+ writeFile(args: {
58
+ path: string;
59
+ content: string;
60
+ }): Promise<string>;
61
+ editFile(args: {
62
+ path: string;
63
+ oldString: string;
64
+ newString: string;
65
+ replaceAll?: boolean;
66
+ }): Promise<string>;
67
+ listDirectory(args: {
68
+ path?: string;
69
+ recursive?: boolean;
70
+ include?: string;
71
+ exclude?: string;
72
+ }): Promise<string>;
73
+ searchFiles(args: {
74
+ pattern: string;
75
+ path?: string;
76
+ include?: string;
77
+ exclude?: string;
78
+ ignoreCase?: boolean;
79
+ maxResults?: number;
80
+ }): Promise<string>;
81
+ findFiles(args: {
82
+ pattern: string;
83
+ path?: string;
84
+ exclude?: string;
85
+ }): Promise<string>;
86
+ fileInfo(args: {
87
+ path: string;
88
+ }): Promise<string>;
89
+ createDirectory(args: {
90
+ path: string;
91
+ }): Promise<string>;
92
+ moveFile(args: {
93
+ source: string;
94
+ destination: string;
95
+ }): Promise<string>;
96
+ copyFile(args: {
97
+ source: string;
98
+ destination: string;
99
+ }): Promise<string>;
100
+ deleteFile(args: {
101
+ path: string;
102
+ }): Promise<string>;
103
+ /**
104
+ * When an assistant uses fileTools, inject system prompt guidance
105
+ * about how to use the tools effectively.
106
+ */
107
+ setupToolsConsumer(consumer: Helper): void;
108
+ }
109
+ export default FileTools;
110
+ //# sourceMappingURL=file-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../../src/agi/features/file-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,iBAAiB;QAC1B,SAAS,EAAE,OAAO,SAAS,CAAA;KAC3B;CACD;AAED,eAAO,MAAM,oBAAoB;;iBAAgC,CAAA;AACjE,eAAO,MAAM,sBAAsB;;;;;iBAAkC,CAAA;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAU,SAAQ,OAAO;IACrC,OAAgB,QAAQ,EAAG,oBAAoB,CAA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