illuma-agents 1.0.2

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 (437) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/common/enum.cjs +163 -0
  3. package/dist/cjs/common/enum.cjs.map +1 -0
  4. package/dist/cjs/events.cjs +143 -0
  5. package/dist/cjs/events.cjs.map +1 -0
  6. package/dist/cjs/graphs/Graph.cjs +581 -0
  7. package/dist/cjs/graphs/Graph.cjs.map +1 -0
  8. package/dist/cjs/instrumentation.cjs +21 -0
  9. package/dist/cjs/instrumentation.cjs.map +1 -0
  10. package/dist/cjs/llm/anthropic/index.cjs +292 -0
  11. package/dist/cjs/llm/anthropic/index.cjs.map +1 -0
  12. package/dist/cjs/llm/anthropic/types.cjs +50 -0
  13. package/dist/cjs/llm/anthropic/types.cjs.map +1 -0
  14. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +553 -0
  15. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -0
  16. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +218 -0
  17. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -0
  18. package/dist/cjs/llm/anthropic/utils/tools.cjs +29 -0
  19. package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -0
  20. package/dist/cjs/llm/fake.cjs +97 -0
  21. package/dist/cjs/llm/fake.cjs.map +1 -0
  22. package/dist/cjs/llm/google/index.cjs +147 -0
  23. package/dist/cjs/llm/google/index.cjs.map +1 -0
  24. package/dist/cjs/llm/google/utils/common.cjs +490 -0
  25. package/dist/cjs/llm/google/utils/common.cjs.map +1 -0
  26. package/dist/cjs/llm/ollama/index.cjs +70 -0
  27. package/dist/cjs/llm/ollama/index.cjs.map +1 -0
  28. package/dist/cjs/llm/ollama/utils.cjs +158 -0
  29. package/dist/cjs/llm/ollama/utils.cjs.map +1 -0
  30. package/dist/cjs/llm/openai/index.cjs +613 -0
  31. package/dist/cjs/llm/openai/index.cjs.map +1 -0
  32. package/dist/cjs/llm/openai/utils/index.cjs +677 -0
  33. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -0
  34. package/dist/cjs/llm/openrouter/index.cjs +29 -0
  35. package/dist/cjs/llm/openrouter/index.cjs.map +1 -0
  36. package/dist/cjs/llm/providers.cjs +47 -0
  37. package/dist/cjs/llm/providers.cjs.map +1 -0
  38. package/dist/cjs/llm/text.cjs +69 -0
  39. package/dist/cjs/llm/text.cjs.map +1 -0
  40. package/dist/cjs/llm/vertexai/index.cjs +330 -0
  41. package/dist/cjs/llm/vertexai/index.cjs.map +1 -0
  42. package/dist/cjs/main.cjs +127 -0
  43. package/dist/cjs/main.cjs.map +1 -0
  44. package/dist/cjs/messages/core.cjs +359 -0
  45. package/dist/cjs/messages/core.cjs.map +1 -0
  46. package/dist/cjs/messages/format.cjs +455 -0
  47. package/dist/cjs/messages/format.cjs.map +1 -0
  48. package/dist/cjs/messages/ids.cjs +23 -0
  49. package/dist/cjs/messages/ids.cjs.map +1 -0
  50. package/dist/cjs/messages/prune.cjs +398 -0
  51. package/dist/cjs/messages/prune.cjs.map +1 -0
  52. package/dist/cjs/run.cjs +264 -0
  53. package/dist/cjs/run.cjs.map +1 -0
  54. package/dist/cjs/splitStream.cjs +210 -0
  55. package/dist/cjs/splitStream.cjs.map +1 -0
  56. package/dist/cjs/stream.cjs +504 -0
  57. package/dist/cjs/stream.cjs.map +1 -0
  58. package/dist/cjs/tools/CodeExecutor.cjs +192 -0
  59. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -0
  60. package/dist/cjs/tools/ToolNode.cjs +125 -0
  61. package/dist/cjs/tools/ToolNode.cjs.map +1 -0
  62. package/dist/cjs/tools/handlers.cjs +250 -0
  63. package/dist/cjs/tools/handlers.cjs.map +1 -0
  64. package/dist/cjs/tools/search/anthropic.cjs +40 -0
  65. package/dist/cjs/tools/search/anthropic.cjs.map +1 -0
  66. package/dist/cjs/tools/search/content.cjs +140 -0
  67. package/dist/cjs/tools/search/content.cjs.map +1 -0
  68. package/dist/cjs/tools/search/firecrawl.cjs +179 -0
  69. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -0
  70. package/dist/cjs/tools/search/format.cjs +203 -0
  71. package/dist/cjs/tools/search/format.cjs.map +1 -0
  72. package/dist/cjs/tools/search/highlights.cjs +245 -0
  73. package/dist/cjs/tools/search/highlights.cjs.map +1 -0
  74. package/dist/cjs/tools/search/rerankers.cjs +174 -0
  75. package/dist/cjs/tools/search/rerankers.cjs.map +1 -0
  76. package/dist/cjs/tools/search/schema.cjs +70 -0
  77. package/dist/cjs/tools/search/schema.cjs.map +1 -0
  78. package/dist/cjs/tools/search/search.cjs +561 -0
  79. package/dist/cjs/tools/search/search.cjs.map +1 -0
  80. package/dist/cjs/tools/search/serper-scraper.cjs +132 -0
  81. package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -0
  82. package/dist/cjs/tools/search/tool.cjs +331 -0
  83. package/dist/cjs/tools/search/tool.cjs.map +1 -0
  84. package/dist/cjs/tools/search/utils.cjs +66 -0
  85. package/dist/cjs/tools/search/utils.cjs.map +1 -0
  86. package/dist/cjs/utils/graph.cjs +16 -0
  87. package/dist/cjs/utils/graph.cjs.map +1 -0
  88. package/dist/cjs/utils/llm.cjs +28 -0
  89. package/dist/cjs/utils/llm.cjs.map +1 -0
  90. package/dist/cjs/utils/misc.cjs +56 -0
  91. package/dist/cjs/utils/misc.cjs.map +1 -0
  92. package/dist/cjs/utils/run.cjs +69 -0
  93. package/dist/cjs/utils/run.cjs.map +1 -0
  94. package/dist/cjs/utils/title.cjs +111 -0
  95. package/dist/cjs/utils/title.cjs.map +1 -0
  96. package/dist/cjs/utils/tokens.cjs +65 -0
  97. package/dist/cjs/utils/tokens.cjs.map +1 -0
  98. package/dist/esm/common/enum.mjs +163 -0
  99. package/dist/esm/common/enum.mjs.map +1 -0
  100. package/dist/esm/events.mjs +135 -0
  101. package/dist/esm/events.mjs.map +1 -0
  102. package/dist/esm/graphs/Graph.mjs +578 -0
  103. package/dist/esm/graphs/Graph.mjs.map +1 -0
  104. package/dist/esm/instrumentation.mjs +19 -0
  105. package/dist/esm/instrumentation.mjs.map +1 -0
  106. package/dist/esm/llm/anthropic/index.mjs +290 -0
  107. package/dist/esm/llm/anthropic/index.mjs.map +1 -0
  108. package/dist/esm/llm/anthropic/types.mjs +48 -0
  109. package/dist/esm/llm/anthropic/types.mjs.map +1 -0
  110. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +550 -0
  111. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -0
  112. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +216 -0
  113. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -0
  114. package/dist/esm/llm/anthropic/utils/tools.mjs +27 -0
  115. package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -0
  116. package/dist/esm/llm/fake.mjs +94 -0
  117. package/dist/esm/llm/fake.mjs.map +1 -0
  118. package/dist/esm/llm/google/index.mjs +145 -0
  119. package/dist/esm/llm/google/index.mjs.map +1 -0
  120. package/dist/esm/llm/google/utils/common.mjs +484 -0
  121. package/dist/esm/llm/google/utils/common.mjs.map +1 -0
  122. package/dist/esm/llm/ollama/index.mjs +68 -0
  123. package/dist/esm/llm/ollama/index.mjs.map +1 -0
  124. package/dist/esm/llm/ollama/utils.mjs +155 -0
  125. package/dist/esm/llm/ollama/utils.mjs.map +1 -0
  126. package/dist/esm/llm/openai/index.mjs +604 -0
  127. package/dist/esm/llm/openai/index.mjs.map +1 -0
  128. package/dist/esm/llm/openai/utils/index.mjs +671 -0
  129. package/dist/esm/llm/openai/utils/index.mjs.map +1 -0
  130. package/dist/esm/llm/openrouter/index.mjs +27 -0
  131. package/dist/esm/llm/openrouter/index.mjs.map +1 -0
  132. package/dist/esm/llm/providers.mjs +43 -0
  133. package/dist/esm/llm/providers.mjs.map +1 -0
  134. package/dist/esm/llm/text.mjs +67 -0
  135. package/dist/esm/llm/text.mjs.map +1 -0
  136. package/dist/esm/llm/vertexai/index.mjs +328 -0
  137. package/dist/esm/llm/vertexai/index.mjs.map +1 -0
  138. package/dist/esm/main.mjs +20 -0
  139. package/dist/esm/main.mjs.map +1 -0
  140. package/dist/esm/messages/core.mjs +351 -0
  141. package/dist/esm/messages/core.mjs.map +1 -0
  142. package/dist/esm/messages/format.mjs +447 -0
  143. package/dist/esm/messages/format.mjs.map +1 -0
  144. package/dist/esm/messages/ids.mjs +21 -0
  145. package/dist/esm/messages/ids.mjs.map +1 -0
  146. package/dist/esm/messages/prune.mjs +393 -0
  147. package/dist/esm/messages/prune.mjs.map +1 -0
  148. package/dist/esm/run.mjs +261 -0
  149. package/dist/esm/run.mjs.map +1 -0
  150. package/dist/esm/splitStream.mjs +207 -0
  151. package/dist/esm/splitStream.mjs.map +1 -0
  152. package/dist/esm/stream.mjs +500 -0
  153. package/dist/esm/stream.mjs.map +1 -0
  154. package/dist/esm/tools/CodeExecutor.mjs +188 -0
  155. package/dist/esm/tools/CodeExecutor.mjs.map +1 -0
  156. package/dist/esm/tools/ToolNode.mjs +122 -0
  157. package/dist/esm/tools/ToolNode.mjs.map +1 -0
  158. package/dist/esm/tools/handlers.mjs +245 -0
  159. package/dist/esm/tools/handlers.mjs.map +1 -0
  160. package/dist/esm/tools/search/anthropic.mjs +37 -0
  161. package/dist/esm/tools/search/anthropic.mjs.map +1 -0
  162. package/dist/esm/tools/search/content.mjs +119 -0
  163. package/dist/esm/tools/search/content.mjs.map +1 -0
  164. package/dist/esm/tools/search/firecrawl.mjs +176 -0
  165. package/dist/esm/tools/search/firecrawl.mjs.map +1 -0
  166. package/dist/esm/tools/search/format.mjs +201 -0
  167. package/dist/esm/tools/search/format.mjs.map +1 -0
  168. package/dist/esm/tools/search/highlights.mjs +243 -0
  169. package/dist/esm/tools/search/highlights.mjs.map +1 -0
  170. package/dist/esm/tools/search/rerankers.mjs +168 -0
  171. package/dist/esm/tools/search/rerankers.mjs.map +1 -0
  172. package/dist/esm/tools/search/schema.mjs +61 -0
  173. package/dist/esm/tools/search/schema.mjs.map +1 -0
  174. package/dist/esm/tools/search/search.mjs +558 -0
  175. package/dist/esm/tools/search/search.mjs.map +1 -0
  176. package/dist/esm/tools/search/serper-scraper.mjs +129 -0
  177. package/dist/esm/tools/search/serper-scraper.mjs.map +1 -0
  178. package/dist/esm/tools/search/tool.mjs +329 -0
  179. package/dist/esm/tools/search/tool.mjs.map +1 -0
  180. package/dist/esm/tools/search/utils.mjs +61 -0
  181. package/dist/esm/tools/search/utils.mjs.map +1 -0
  182. package/dist/esm/utils/graph.mjs +13 -0
  183. package/dist/esm/utils/graph.mjs.map +1 -0
  184. package/dist/esm/utils/llm.mjs +25 -0
  185. package/dist/esm/utils/llm.mjs.map +1 -0
  186. package/dist/esm/utils/misc.mjs +53 -0
  187. package/dist/esm/utils/misc.mjs.map +1 -0
  188. package/dist/esm/utils/run.mjs +66 -0
  189. package/dist/esm/utils/run.mjs.map +1 -0
  190. package/dist/esm/utils/title.mjs +108 -0
  191. package/dist/esm/utils/title.mjs.map +1 -0
  192. package/dist/esm/utils/tokens.mjs +62 -0
  193. package/dist/esm/utils/tokens.mjs.map +1 -0
  194. package/dist/types/common/enum.d.ts +128 -0
  195. package/dist/types/common/index.d.ts +1 -0
  196. package/dist/types/events.d.ts +29 -0
  197. package/dist/types/graphs/Graph.d.ts +122 -0
  198. package/dist/types/graphs/index.d.ts +1 -0
  199. package/dist/types/index.d.ts +13 -0
  200. package/dist/types/instrumentation.d.ts +1 -0
  201. package/dist/types/llm/anthropic/index.d.ts +39 -0
  202. package/dist/types/llm/anthropic/types.d.ts +37 -0
  203. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +14 -0
  204. package/dist/types/llm/anthropic/utils/message_outputs.d.ts +14 -0
  205. package/dist/types/llm/anthropic/utils/output_parsers.d.ts +22 -0
  206. package/dist/types/llm/anthropic/utils/tools.d.ts +3 -0
  207. package/dist/types/llm/fake.d.ts +31 -0
  208. package/dist/types/llm/google/index.d.ts +14 -0
  209. package/dist/types/llm/google/types.d.ts +32 -0
  210. package/dist/types/llm/google/utils/common.d.ts +19 -0
  211. package/dist/types/llm/google/utils/tools.d.ts +10 -0
  212. package/dist/types/llm/google/utils/zod_to_genai_parameters.d.ts +14 -0
  213. package/dist/types/llm/ollama/index.d.ts +8 -0
  214. package/dist/types/llm/ollama/utils.d.ts +7 -0
  215. package/dist/types/llm/openai/index.d.ts +103 -0
  216. package/dist/types/llm/openai/types.d.ts +10 -0
  217. package/dist/types/llm/openai/utils/index.d.ts +20 -0
  218. package/dist/types/llm/openrouter/index.d.ts +12 -0
  219. package/dist/types/llm/providers.d.ts +5 -0
  220. package/dist/types/llm/text.d.ts +21 -0
  221. package/dist/types/llm/vertexai/index.d.ts +293 -0
  222. package/dist/types/messages/core.d.ts +14 -0
  223. package/dist/types/messages/format.d.ts +113 -0
  224. package/dist/types/messages/ids.d.ts +3 -0
  225. package/dist/types/messages/index.d.ts +4 -0
  226. package/dist/types/messages/prune.d.ts +51 -0
  227. package/dist/types/mockStream.d.ts +32 -0
  228. package/dist/types/prompts/collab.d.ts +1 -0
  229. package/dist/types/prompts/index.d.ts +2 -0
  230. package/dist/types/prompts/taskmanager.d.ts +41 -0
  231. package/dist/types/run.d.ts +30 -0
  232. package/dist/types/scripts/abort.d.ts +1 -0
  233. package/dist/types/scripts/ant_web_search.d.ts +1 -0
  234. package/dist/types/scripts/args.d.ts +7 -0
  235. package/dist/types/scripts/caching.d.ts +1 -0
  236. package/dist/types/scripts/cli.d.ts +1 -0
  237. package/dist/types/scripts/cli2.d.ts +1 -0
  238. package/dist/types/scripts/cli3.d.ts +1 -0
  239. package/dist/types/scripts/cli4.d.ts +1 -0
  240. package/dist/types/scripts/cli5.d.ts +1 -0
  241. package/dist/types/scripts/code_exec.d.ts +1 -0
  242. package/dist/types/scripts/code_exec_files.d.ts +1 -0
  243. package/dist/types/scripts/code_exec_simple.d.ts +1 -0
  244. package/dist/types/scripts/content.d.ts +1 -0
  245. package/dist/types/scripts/empty_input.d.ts +1 -0
  246. package/dist/types/scripts/image.d.ts +1 -0
  247. package/dist/types/scripts/memory.d.ts +1 -0
  248. package/dist/types/scripts/search.d.ts +1 -0
  249. package/dist/types/scripts/simple.d.ts +1 -0
  250. package/dist/types/scripts/stream.d.ts +1 -0
  251. package/dist/types/scripts/thinking.d.ts +1 -0
  252. package/dist/types/scripts/tools.d.ts +1 -0
  253. package/dist/types/specs/spec.utils.d.ts +1 -0
  254. package/dist/types/splitStream.d.ts +37 -0
  255. package/dist/types/stream.d.ts +14 -0
  256. package/dist/types/tools/CodeExecutor.d.ts +23 -0
  257. package/dist/types/tools/ToolNode.d.ts +22 -0
  258. package/dist/types/tools/example.d.ts +78 -0
  259. package/dist/types/tools/handlers.d.ts +19 -0
  260. package/dist/types/tools/search/anthropic.d.ts +16 -0
  261. package/dist/types/tools/search/content.d.ts +4 -0
  262. package/dist/types/tools/search/firecrawl.d.ts +54 -0
  263. package/dist/types/tools/search/format.d.ts +5 -0
  264. package/dist/types/tools/search/highlights.d.ts +13 -0
  265. package/dist/types/tools/search/index.d.ts +2 -0
  266. package/dist/types/tools/search/rerankers.d.ts +38 -0
  267. package/dist/types/tools/search/schema.d.ts +16 -0
  268. package/dist/types/tools/search/search.d.ts +8 -0
  269. package/dist/types/tools/search/serper-scraper.d.ts +59 -0
  270. package/dist/types/tools/search/test.d.ts +1 -0
  271. package/dist/types/tools/search/tool.d.ts +54 -0
  272. package/dist/types/tools/search/types.d.ts +591 -0
  273. package/dist/types/tools/search/utils.d.ts +10 -0
  274. package/dist/types/types/graph.d.ts +138 -0
  275. package/dist/types/types/index.d.ts +5 -0
  276. package/dist/types/types/llm.d.ts +102 -0
  277. package/dist/types/types/run.d.ts +74 -0
  278. package/dist/types/types/stream.d.ts +293 -0
  279. package/dist/types/types/tools.d.ts +61 -0
  280. package/dist/types/utils/graph.d.ts +2 -0
  281. package/dist/types/utils/index.d.ts +5 -0
  282. package/dist/types/utils/llm.d.ts +3 -0
  283. package/dist/types/utils/llmConfig.d.ts +3 -0
  284. package/dist/types/utils/logging.d.ts +1 -0
  285. package/dist/types/utils/misc.d.ts +7 -0
  286. package/dist/types/utils/run.d.ts +27 -0
  287. package/dist/types/utils/title.d.ts +4 -0
  288. package/dist/types/utils/tokens.d.ts +3 -0
  289. package/package.json +145 -0
  290. package/src/common/enum.ts +176 -0
  291. package/src/common/index.ts +2 -0
  292. package/src/events.ts +191 -0
  293. package/src/graphs/Graph.ts +846 -0
  294. package/src/graphs/index.ts +1 -0
  295. package/src/index.ts +24 -0
  296. package/src/instrumentation.ts +22 -0
  297. package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
  298. package/src/llm/anthropic/index.ts +413 -0
  299. package/src/llm/anthropic/llm.spec.ts +1442 -0
  300. package/src/llm/anthropic/types.ts +140 -0
  301. package/src/llm/anthropic/utils/message_inputs.ts +660 -0
  302. package/src/llm/anthropic/utils/message_outputs.ts +289 -0
  303. package/src/llm/anthropic/utils/output_parsers.ts +133 -0
  304. package/src/llm/anthropic/utils/tools.ts +29 -0
  305. package/src/llm/fake.ts +133 -0
  306. package/src/llm/google/index.ts +222 -0
  307. package/src/llm/google/types.ts +43 -0
  308. package/src/llm/google/utils/common.ts +660 -0
  309. package/src/llm/google/utils/tools.ts +160 -0
  310. package/src/llm/google/utils/zod_to_genai_parameters.ts +88 -0
  311. package/src/llm/ollama/index.ts +92 -0
  312. package/src/llm/ollama/utils.ts +193 -0
  313. package/src/llm/openai/index.ts +853 -0
  314. package/src/llm/openai/types.ts +24 -0
  315. package/src/llm/openai/utils/index.ts +918 -0
  316. package/src/llm/openai/utils/isReasoningModel.test.ts +90 -0
  317. package/src/llm/openrouter/index.ts +60 -0
  318. package/src/llm/providers.ts +57 -0
  319. package/src/llm/text.ts +94 -0
  320. package/src/llm/vertexai/index.ts +360 -0
  321. package/src/messages/core.ts +463 -0
  322. package/src/messages/format.ts +625 -0
  323. package/src/messages/formatAgentMessages.test.ts +917 -0
  324. package/src/messages/formatAgentMessages.tools.test.ts +400 -0
  325. package/src/messages/formatMessage.test.ts +693 -0
  326. package/src/messages/ids.ts +26 -0
  327. package/src/messages/index.ts +4 -0
  328. package/src/messages/prune.ts +567 -0
  329. package/src/messages/shiftIndexTokenCountMap.test.ts +81 -0
  330. package/src/mockStream.ts +99 -0
  331. package/src/prompts/collab.ts +6 -0
  332. package/src/prompts/index.ts +2 -0
  333. package/src/prompts/taskmanager.ts +61 -0
  334. package/src/proto/CollabGraph.ts +269 -0
  335. package/src/proto/TaskManager.ts +243 -0
  336. package/src/proto/collab.ts +200 -0
  337. package/src/proto/collab_design.ts +184 -0
  338. package/src/proto/collab_design_v2.ts +224 -0
  339. package/src/proto/collab_design_v3.ts +255 -0
  340. package/src/proto/collab_design_v4.ts +220 -0
  341. package/src/proto/collab_design_v5.ts +251 -0
  342. package/src/proto/collab_graph.ts +181 -0
  343. package/src/proto/collab_original.ts +123 -0
  344. package/src/proto/example.ts +93 -0
  345. package/src/proto/example_new.ts +68 -0
  346. package/src/proto/example_old.ts +201 -0
  347. package/src/proto/example_test.ts +152 -0
  348. package/src/proto/example_test_anthropic.ts +100 -0
  349. package/src/proto/log_stream.ts +202 -0
  350. package/src/proto/main_collab_community_event.ts +133 -0
  351. package/src/proto/main_collab_design_v2.ts +96 -0
  352. package/src/proto/main_collab_design_v4.ts +100 -0
  353. package/src/proto/main_collab_design_v5.ts +135 -0
  354. package/src/proto/main_collab_global_analysis.ts +122 -0
  355. package/src/proto/main_collab_hackathon_event.ts +153 -0
  356. package/src/proto/main_collab_space_mission.ts +153 -0
  357. package/src/proto/main_philosophy.ts +210 -0
  358. package/src/proto/original_script.ts +126 -0
  359. package/src/proto/standard.ts +100 -0
  360. package/src/proto/stream.ts +56 -0
  361. package/src/proto/tasks.ts +118 -0
  362. package/src/proto/tools/global_analysis_tools.ts +86 -0
  363. package/src/proto/tools/space_mission_tools.ts +60 -0
  364. package/src/proto/vertexai.ts +54 -0
  365. package/src/run.ts +381 -0
  366. package/src/scripts/abort.ts +138 -0
  367. package/src/scripts/ant_web_search.ts +158 -0
  368. package/src/scripts/args.ts +48 -0
  369. package/src/scripts/caching.ts +124 -0
  370. package/src/scripts/cli.ts +167 -0
  371. package/src/scripts/cli2.ts +125 -0
  372. package/src/scripts/cli3.ts +178 -0
  373. package/src/scripts/cli4.ts +184 -0
  374. package/src/scripts/cli5.ts +184 -0
  375. package/src/scripts/code_exec.ts +214 -0
  376. package/src/scripts/code_exec_files.ts +193 -0
  377. package/src/scripts/code_exec_simple.ts +129 -0
  378. package/src/scripts/content.ts +120 -0
  379. package/src/scripts/empty_input.ts +137 -0
  380. package/src/scripts/image.ts +178 -0
  381. package/src/scripts/memory.ts +97 -0
  382. package/src/scripts/search.ts +150 -0
  383. package/src/scripts/simple.ts +225 -0
  384. package/src/scripts/stream.ts +122 -0
  385. package/src/scripts/thinking.ts +150 -0
  386. package/src/scripts/tools.ts +155 -0
  387. package/src/specs/anthropic.simple.test.ts +317 -0
  388. package/src/specs/azure.simple.test.ts +316 -0
  389. package/src/specs/openai.simple.test.ts +316 -0
  390. package/src/specs/prune.test.ts +763 -0
  391. package/src/specs/reasoning.test.ts +165 -0
  392. package/src/specs/spec.utils.ts +3 -0
  393. package/src/specs/thinking-prune.test.ts +703 -0
  394. package/src/specs/token-distribution-edge-case.test.ts +316 -0
  395. package/src/specs/tool-error.test.ts +193 -0
  396. package/src/splitStream.test.ts +691 -0
  397. package/src/splitStream.ts +234 -0
  398. package/src/stream.test.ts +94 -0
  399. package/src/stream.ts +651 -0
  400. package/src/tools/CodeExecutor.ts +220 -0
  401. package/src/tools/ToolNode.ts +170 -0
  402. package/src/tools/example.ts +129 -0
  403. package/src/tools/handlers.ts +336 -0
  404. package/src/tools/search/anthropic.ts +51 -0
  405. package/src/tools/search/content.test.ts +173 -0
  406. package/src/tools/search/content.ts +147 -0
  407. package/src/tools/search/firecrawl.ts +210 -0
  408. package/src/tools/search/format.ts +250 -0
  409. package/src/tools/search/highlights.ts +320 -0
  410. package/src/tools/search/index.ts +2 -0
  411. package/src/tools/search/jina-reranker.test.ts +126 -0
  412. package/src/tools/search/output.md +2775 -0
  413. package/src/tools/search/rerankers.ts +242 -0
  414. package/src/tools/search/schema.ts +63 -0
  415. package/src/tools/search/search.ts +759 -0
  416. package/src/tools/search/serper-scraper.ts +155 -0
  417. package/src/tools/search/test.html +884 -0
  418. package/src/tools/search/test.md +643 -0
  419. package/src/tools/search/test.ts +159 -0
  420. package/src/tools/search/tool.ts +471 -0
  421. package/src/tools/search/types.ts +687 -0
  422. package/src/tools/search/utils.ts +79 -0
  423. package/src/types/graph.ts +185 -0
  424. package/src/types/index.ts +6 -0
  425. package/src/types/llm.ts +140 -0
  426. package/src/types/run.ts +89 -0
  427. package/src/types/stream.ts +400 -0
  428. package/src/types/tools.ts +80 -0
  429. package/src/utils/graph.ts +11 -0
  430. package/src/utils/index.ts +5 -0
  431. package/src/utils/llm.ts +27 -0
  432. package/src/utils/llmConfig.ts +183 -0
  433. package/src/utils/logging.ts +48 -0
  434. package/src/utils/misc.ts +57 -0
  435. package/src/utils/run.ts +101 -0
  436. package/src/utils/title.ts +165 -0
  437. package/src/utils/tokens.ts +70 -0
@@ -0,0 +1,138 @@
1
+ import type { StateGraphArgs, StateGraph, CompiledStateGraph } from '@langchain/langgraph';
2
+ import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
3
+ import type { BaseMessage, AIMessageChunk } from '@langchain/core/messages';
4
+ import type { ChatGenerationChunk } from '@langchain/core/outputs';
5
+ import type { GoogleAIToolType } from '@langchain/google-common';
6
+ import type { RunnableConfig } from '@langchain/core/runnables';
7
+ import type { ToolMap, GenericTool } from '@/types/tools';
8
+ import type { ClientOptions } from '@/types/llm';
9
+ import type { Providers } from '@/common';
10
+ import type { Graph } from '@/graphs';
11
+ export type BaseGraphState = {
12
+ messages: BaseMessage[];
13
+ };
14
+ export type IState = BaseGraphState;
15
+ export interface EventHandler {
16
+ handle(event: string, data: StreamEventData | ModelEndData, metadata?: Record<string, unknown>, graph?: Graph): void;
17
+ }
18
+ export type GraphStateChannels<T extends BaseGraphState> = StateGraphArgs<T>['channels'];
19
+ export type Workflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = StateGraph<T, U, N>;
20
+ export type CompiledWorkflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = CompiledStateGraph<T, U, N>;
21
+ export type EventStreamCallbackHandlerInput = Parameters<CompiledWorkflow['streamEvents']>[2] extends Omit<infer T, 'autoClose'> ? T : never;
22
+ export type StreamChunk = (ChatGenerationChunk & {
23
+ message: AIMessageChunk;
24
+ }) | AIMessageChunk;
25
+ /**
26
+ * Data associated with a StreamEvent.
27
+ */
28
+ export type StreamEventData = {
29
+ /**
30
+ * The input passed to the runnable that generated the event.
31
+ * Inputs will sometimes be available at the *START* of the runnable, and
32
+ * sometimes at the *END* of the runnable.
33
+ * If a runnable is able to stream its inputs, then its input by definition
34
+ * won't be known until the *END* of the runnable when it has finished streaming
35
+ * its inputs.
36
+ */
37
+ input?: unknown;
38
+ /**
39
+ * The output of the runnable that generated the event.
40
+ * Outputs will only be available at the *END* of the runnable.
41
+ * For most runnables, this field can be inferred from the `chunk` field,
42
+ * though there might be some exceptions for special cased runnables (e.g., like
43
+ * chat models), which may return more information.
44
+ */
45
+ output?: unknown;
46
+ /**
47
+ * A streaming chunk from the output that generated the event.
48
+ * chunks support addition in general, and adding them up should result
49
+ * in the output of the runnable that generated the event.
50
+ */
51
+ chunk?: StreamChunk;
52
+ /**
53
+ * Runnable config for invoking other runnables within handlers.
54
+ */
55
+ config?: RunnableConfig;
56
+ /**
57
+ * Custom result from the runnable that generated the event.
58
+ */
59
+ result?: unknown;
60
+ };
61
+ /**
62
+ * A streaming event.
63
+ *
64
+ * Schema of a streaming event which is produced from the streamEvents method.
65
+ */
66
+ export type StreamEvent = {
67
+ /**
68
+ * Event names are of the format: on_[runnable_type]_(start|stream|end).
69
+ *
70
+ * Runnable types are one of:
71
+ * - llm - used by non chat models
72
+ * - chat_model - used by chat models
73
+ * - prompt -- e.g., ChatPromptTemplate
74
+ * - tool -- LangChain tools
75
+ * - chain - most Runnables are of this type
76
+ *
77
+ * Further, the events are categorized as one of:
78
+ * - start - when the runnable starts
79
+ * - stream - when the runnable is streaming
80
+ * - end - when the runnable ends
81
+ *
82
+ * start, stream and end are associated with slightly different `data` payload.
83
+ *
84
+ * Please see the documentation for `EventData` for more details.
85
+ */
86
+ event: string;
87
+ /** The name of the runnable that generated the event. */
88
+ name: string;
89
+ /**
90
+ * An randomly generated ID to keep track of the execution of the given runnable.
91
+ *
92
+ * Each child runnable that gets invoked as part of the execution of a parent runnable
93
+ * is assigned its own unique ID.
94
+ */
95
+ run_id: string;
96
+ /**
97
+ * Tags associated with the runnable that generated this event.
98
+ * Tags are always inherited from parent runnables.
99
+ */
100
+ tags?: string[];
101
+ /** Metadata associated with the runnable that generated this event. */
102
+ metadata: Record<string, unknown>;
103
+ /**
104
+ * Event data.
105
+ *
106
+ * The contents of the event data depend on the event type.
107
+ */
108
+ data: StreamEventData;
109
+ };
110
+ export type GraphConfig = {
111
+ provider: string;
112
+ thread_id?: string;
113
+ run_id?: string;
114
+ };
115
+ export type PartMetadata = {
116
+ progress?: number;
117
+ asset_pointer?: string;
118
+ status?: string;
119
+ action?: boolean;
120
+ output?: string;
121
+ };
122
+ export type ModelEndData = (StreamEventData & {
123
+ output: AIMessageChunk | undefined;
124
+ }) | undefined;
125
+ export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
126
+ export type StandardGraphInput = {
127
+ runId?: string;
128
+ toolEnd?: boolean;
129
+ toolMap?: ToolMap;
130
+ provider: Providers;
131
+ signal?: AbortSignal;
132
+ instructions?: string;
133
+ streamBuffer?: number;
134
+ clientOptions: ClientOptions;
135
+ additional_instructions?: string;
136
+ reasoningKey?: 'reasoning_content' | 'reasoning';
137
+ tools?: GraphTools;
138
+ };
@@ -0,0 +1,5 @@
1
+ export * from './graph';
2
+ export * from './llm';
3
+ export * from './run';
4
+ export * from './stream';
5
+ export * from './tools';
@@ -0,0 +1,102 @@
1
+ import { ChatOllama } from '@langchain/ollama';
2
+ import { ChatAnthropic } from '@langchain/anthropic';
3
+ import { ChatMistralAI } from '@langchain/mistralai';
4
+ import { ChatBedrockConverse } from '@langchain/aws';
5
+ import { BedrockChat } from '@langchain/community/chat_models/bedrock/web';
6
+ import type { BindToolsInput, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
7
+ import type { OpenAIChatInput, ChatOpenAIFields, AzureOpenAIInput, ClientOptions as OAIClientOptions } from '@langchain/openai';
8
+ import type { BedrockChatFields } from '@langchain/community/chat_models/bedrock/web';
9
+ import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
10
+ import type { GeminiGenerationConfig } from '@langchain/google-common';
11
+ import type { ChatVertexAIInput } from '@langchain/google-vertexai';
12
+ import type { ChatDeepSeekCallOptions } from '@langchain/deepseek';
13
+ import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
14
+ import type { ChatBedrockConverseInput } from '@langchain/aws';
15
+ import type { ChatMistralAIInput } from '@langchain/mistralai';
16
+ import type { RequestOptions } from '@google/generative-ai';
17
+ import type { StructuredTool } from '@langchain/core/tools';
18
+ import type { AnthropicInput } from '@langchain/anthropic';
19
+ import type { Runnable } from '@langchain/core/runnables';
20
+ import type { ChatOllamaInput } from '@langchain/ollama';
21
+ import type { OpenAI as OpenAIClient } from 'openai';
22
+ import type { ChatXAIInput } from '@langchain/xai';
23
+ import { AzureChatOpenAI, ChatDeepSeek, ChatOpenAI, ChatXAI } from '@/llm/openai';
24
+ import { CustomChatGoogleGenerativeAI } from '@/llm/google';
25
+ import { ChatOpenRouter } from '@/llm/openrouter';
26
+ import { ChatVertexAI } from '@/llm/vertexai';
27
+ import { Providers } from '@/common';
28
+ export type AzureClientOptions = Partial<OpenAIChatInput> & Partial<AzureOpenAIInput> & {
29
+ openAIApiKey?: string;
30
+ openAIApiVersion?: string;
31
+ openAIBasePath?: string;
32
+ deploymentName?: string;
33
+ } & BaseChatModelParams & {
34
+ configuration?: OAIClientOptions;
35
+ };
36
+ export type ThinkingConfig = AnthropicInput['thinking'];
37
+ export type ChatOpenAIToolType = BindToolsInput | OpenAIClient.ChatCompletionTool;
38
+ export type CommonToolType = StructuredTool | ChatOpenAIToolType;
39
+ export type AnthropicReasoning = {
40
+ thinking?: ThinkingConfig | boolean;
41
+ thinkingBudget?: number;
42
+ };
43
+ export type OpenAIClientOptions = ChatOpenAIFields;
44
+ export type OllamaClientOptions = ChatOllamaInput;
45
+ export type AnthropicClientOptions = AnthropicInput;
46
+ export type MistralAIClientOptions = ChatMistralAIInput;
47
+ export type VertexAIClientOptions = ChatVertexAIInput & {
48
+ includeThoughts?: boolean;
49
+ };
50
+ export type BedrockClientOptions = BedrockChatFields;
51
+ export type BedrockAnthropicInput = ChatBedrockConverseInput & {
52
+ additionalModelRequestFields?: ChatBedrockConverseInput['additionalModelRequestFields'] & AnthropicReasoning;
53
+ };
54
+ export type BedrockConverseClientOptions = ChatBedrockConverseInput;
55
+ export type GoogleClientOptions = GoogleGenerativeAIChatInput & {
56
+ customHeaders?: RequestOptions['customHeaders'];
57
+ thinkingConfig?: GeminiGenerationConfig['thinkingConfig'];
58
+ };
59
+ export type DeepSeekClientOptions = ChatDeepSeekCallOptions;
60
+ export type XAIClientOptions = ChatXAIInput;
61
+ export type ClientOptions = OpenAIClientOptions | AzureClientOptions | OllamaClientOptions | AnthropicClientOptions | MistralAIClientOptions | VertexAIClientOptions | BedrockClientOptions | BedrockConverseClientOptions | GoogleClientOptions | DeepSeekClientOptions | XAIClientOptions;
62
+ export type SharedLLMConfig = {
63
+ provider: Providers;
64
+ };
65
+ export type LLMConfig = SharedLLMConfig & ClientOptions;
66
+ export type ProviderOptionsMap = {
67
+ [Providers.AZURE]: AzureClientOptions;
68
+ [Providers.OPENAI]: OpenAIClientOptions;
69
+ [Providers.OLLAMA]: OllamaClientOptions;
70
+ [Providers.GOOGLE]: GoogleClientOptions;
71
+ [Providers.VERTEXAI]: VertexAIClientOptions;
72
+ [Providers.DEEPSEEK]: DeepSeekClientOptions;
73
+ [Providers.ANTHROPIC]: AnthropicClientOptions;
74
+ [Providers.MISTRALAI]: MistralAIClientOptions;
75
+ [Providers.MISTRAL]: MistralAIClientOptions;
76
+ [Providers.OPENROUTER]: ChatOpenRouterCallOptions;
77
+ [Providers.BEDROCK_LEGACY]: BedrockClientOptions;
78
+ [Providers.BEDROCK]: BedrockConverseClientOptions;
79
+ [Providers.XAI]: XAIClientOptions;
80
+ };
81
+ export type ChatModelMap = {
82
+ [Providers.XAI]: ChatXAI;
83
+ [Providers.OPENAI]: ChatOpenAI;
84
+ [Providers.OLLAMA]: ChatOllama;
85
+ [Providers.AZURE]: AzureChatOpenAI;
86
+ [Providers.DEEPSEEK]: ChatDeepSeek;
87
+ [Providers.VERTEXAI]: ChatVertexAI;
88
+ [Providers.ANTHROPIC]: ChatAnthropic;
89
+ [Providers.MISTRALAI]: ChatMistralAI;
90
+ [Providers.MISTRAL]: ChatMistralAI;
91
+ [Providers.OPENROUTER]: ChatOpenRouter;
92
+ [Providers.BEDROCK_LEGACY]: BedrockChat;
93
+ [Providers.BEDROCK]: ChatBedrockConverse;
94
+ [Providers.GOOGLE]: CustomChatGoogleGenerativeAI;
95
+ };
96
+ export type ChatModelConstructorMap = {
97
+ [P in Providers]: new (config: ProviderOptionsMap[P]) => ChatModelMap[P];
98
+ };
99
+ export type ChatModelInstance = ChatModelMap[Providers];
100
+ export type ModelWithTools = ChatModelInstance & {
101
+ bindTools(tools: CommonToolType[]): Runnable;
102
+ };
@@ -0,0 +1,74 @@
1
+ import type * as z from 'zod';
2
+ import type { BaseMessage } from '@langchain/core/messages';
3
+ import type { StructuredTool } from '@langchain/core/tools';
4
+ import type { RunnableConfig } from '@langchain/core/runnables';
5
+ import type { BaseCallbackHandler, CallbackHandlerMethods } from '@langchain/core/callbacks/base';
6
+ import type * as graph from '@/graphs/Graph';
7
+ import type * as s from '@/types/stream';
8
+ import type * as e from '@/common/enum';
9
+ import type * as g from '@/types/graph';
10
+ import type * as l from '@/types/llm';
11
+ export type ZodObjectAny = z.ZodObject<any, any, any, any>;
12
+ export type BaseGraphConfig = {
13
+ type?: 'standard';
14
+ llmConfig: l.LLMConfig;
15
+ provider?: e.Providers;
16
+ clientOptions?: l.ClientOptions;
17
+ };
18
+ export type StandardGraphConfig = BaseGraphConfig & Omit<g.StandardGraphInput, 'provider' | 'clientOptions'>;
19
+ export type RunTitleOptions = {
20
+ inputText: string;
21
+ provider: e.Providers;
22
+ contentParts: (s.MessageContentComplex | undefined)[];
23
+ titlePrompt?: string;
24
+ skipLanguage?: boolean;
25
+ clientOptions?: l.ClientOptions;
26
+ chainOptions?: Partial<RunnableConfig> | undefined;
27
+ omitOptions?: Set<string>;
28
+ titleMethod?: e.TitleMethod;
29
+ titlePromptTemplate?: string;
30
+ };
31
+ export interface AgentStateChannels {
32
+ messages: BaseMessage[];
33
+ next: string;
34
+ [key: string]: unknown;
35
+ instructions?: string;
36
+ additional_instructions?: string;
37
+ }
38
+ export interface Member {
39
+ name: string;
40
+ systemPrompt: string;
41
+ tools: StructuredTool[];
42
+ llmConfig: l.LLMConfig;
43
+ }
44
+ export type CollaborativeGraphConfig = {
45
+ type: 'collaborative';
46
+ members: Member[];
47
+ supervisorConfig: {
48
+ systemPrompt?: string;
49
+ llmConfig: l.LLMConfig;
50
+ };
51
+ };
52
+ export type TaskManagerGraphConfig = {
53
+ type: 'taskmanager';
54
+ members: Member[];
55
+ supervisorConfig: {
56
+ systemPrompt?: string;
57
+ llmConfig: l.LLMConfig;
58
+ };
59
+ };
60
+ export type RunConfig = {
61
+ runId: string;
62
+ graphConfig: StandardGraphConfig | CollaborativeGraphConfig | TaskManagerGraphConfig;
63
+ customHandlers?: Record<string, g.EventHandler>;
64
+ returnContent?: boolean;
65
+ };
66
+ export type ProvidedCallbacks = (BaseCallbackHandler | CallbackHandlerMethods)[] | undefined;
67
+ export type TokenCounter = (message: BaseMessage) => number;
68
+ export type EventStreamOptions = {
69
+ callbacks?: graph.ClientCallbacks;
70
+ keepContent?: boolean;
71
+ maxContextTokens?: number;
72
+ tokenCounter?: TokenCounter;
73
+ indexTokenCountMap?: Record<string, number>;
74
+ };
@@ -0,0 +1,293 @@
1
+ import type OpenAITypes from 'openai';
2
+ import type { MessageContentImageUrl, MessageContentText, ToolMessage, BaseMessage } from '@langchain/core/messages';
3
+ import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
4
+ import type { LLMResult, Generation } from '@langchain/core/outputs';
5
+ import type { AnthropicContentBlock } from '@/llm/anthropic/types';
6
+ import type { ToolEndEvent } from '@/types/tools';
7
+ import { StepTypes, ContentTypes, GraphEvents } from '@/common/enum';
8
+ export type HandleLLMEnd = (output: LLMResult, runId: string, parentRunId?: string, tags?: string[]) => void;
9
+ export type MetadataAggregatorResult = {
10
+ handleLLMEnd: HandleLLMEnd;
11
+ collected: Record<string, unknown>[];
12
+ };
13
+ export type StreamGeneration = Generation & {
14
+ text?: string;
15
+ message?: BaseMessage;
16
+ };
17
+ /** Event names are of the format: on_[runnable_type]_(start|stream|end).
18
+
19
+ Runnable types are one of:
20
+
21
+ llm - used by non chat models
22
+ chat_model - used by chat models
23
+ prompt -- e.g., ChatPromptTemplate
24
+ tool -- LangChain tools
25
+ chain - most Runnables are of this type
26
+ Further, the events are categorized as one of:
27
+
28
+ start - when the runnable starts
29
+ stream - when the runnable is streaming
30
+ end - when the runnable ends
31
+ start, stream and end are associated with slightly different data payload.
32
+
33
+ Please see the documentation for EventData for more details. */
34
+ export type EventName = string;
35
+ export type RunStep = {
36
+ type: StepTypes;
37
+ id: string;
38
+ runId?: string;
39
+ index: number;
40
+ stepIndex?: number;
41
+ stepDetails: StepDetails;
42
+ usage?: null | object;
43
+ };
44
+ /**
45
+ * Represents a run step delta i.e. any changed fields on a run step during
46
+ * streaming.
47
+ */
48
+ export interface RunStepDeltaEvent {
49
+ /**
50
+ * The identifier of the run step, which can be referenced in API endpoints.
51
+ */
52
+ id: string;
53
+ /**
54
+ * The delta containing the fields that have changed on the run step.
55
+ */
56
+ delta: ToolCallDelta;
57
+ }
58
+ export type StepDetails = MessageCreationDetails | ToolCallsDetails;
59
+ export type StepCompleted = ToolCallCompleted;
60
+ export type MessageCreationDetails = {
61
+ type: StepTypes.MESSAGE_CREATION;
62
+ message_creation: {
63
+ message_id: string;
64
+ };
65
+ };
66
+ export type ToolEndData = {
67
+ input: string | Record<string, unknown>;
68
+ output?: ToolMessage;
69
+ };
70
+ export type ToolErrorData = {
71
+ id: string;
72
+ name: string;
73
+ error?: Error;
74
+ } & Pick<ToolEndData, 'input'>;
75
+ export type ToolEndCallback = (data: ToolEndData, metadata?: Record<string, unknown>) => void;
76
+ export type ProcessedToolCall = {
77
+ name: string;
78
+ args: string | Record<string, unknown>;
79
+ id: string;
80
+ output: string;
81
+ progress: number;
82
+ };
83
+ export type ProcessedContent = {
84
+ type: ContentType;
85
+ text?: string;
86
+ tool_call?: ProcessedToolCall;
87
+ };
88
+ export type ToolCallCompleted = {
89
+ type: 'tool_call';
90
+ tool_call: ProcessedToolCall;
91
+ };
92
+ export type ToolCompleteEvent = ToolCallCompleted & {
93
+ /** The Step Id of the Tool Call */
94
+ id: string;
95
+ /** The content index of the tool call */
96
+ index: number;
97
+ type: 'tool_call';
98
+ };
99
+ export type ToolCallsDetails = {
100
+ type: StepTypes.TOOL_CALLS;
101
+ tool_calls?: AgentToolCall[];
102
+ };
103
+ export type ToolCallDelta = {
104
+ type: StepTypes;
105
+ tool_calls?: ToolCallChunk[];
106
+ };
107
+ export type AgentToolCall = {
108
+ id: string;
109
+ type: 'function';
110
+ function: {
111
+ name: string;
112
+ arguments: string | object;
113
+ };
114
+ } | ToolCall;
115
+ export interface ExtendedMessageContent {
116
+ type?: string;
117
+ text?: string;
118
+ input?: string;
119
+ index?: number;
120
+ id?: string;
121
+ name?: string;
122
+ }
123
+ export type AgentUpdate = {
124
+ type: ContentTypes.AGENT_UPDATE;
125
+ agent_update: {
126
+ index: number;
127
+ runId: string;
128
+ agentId: string;
129
+ };
130
+ };
131
+ /**
132
+ * Represents a message delta i.e. any changed fields on a message during
133
+ * streaming.
134
+ */
135
+ export interface MessageDeltaEvent {
136
+ /**
137
+ * The identifier of the message, which can be referenced in API endpoints.
138
+ */
139
+ id: string;
140
+ /**
141
+ * The delta containing the fields that have changed on the Message.
142
+ */
143
+ delta: MessageDelta;
144
+ }
145
+ /**
146
+ * The delta containing the fields that have changed on the Message.
147
+ */
148
+ export interface MessageDelta {
149
+ /**
150
+ * The content of the message in array of text and/or images.
151
+ */
152
+ content?: MessageContentComplex[];
153
+ /**
154
+ * The tool call ids associated with the message.
155
+ */
156
+ tool_call_ids?: string[];
157
+ }
158
+ /**
159
+ * Represents a reasoning delta i.e. any changed fields on a message during
160
+ * streaming.
161
+ */
162
+ export interface ReasoningDeltaEvent {
163
+ /**
164
+ * The identifier of the message, which can be referenced in API endpoints.
165
+ */
166
+ id: string;
167
+ /**
168
+ * The delta containing the fields that have changed.
169
+ */
170
+ delta: ReasoningDelta;
171
+ }
172
+ /**
173
+ * The reasoning delta containing the fields that have changed on the Message.
174
+ */
175
+ export interface ReasoningDelta {
176
+ /**
177
+ * The content of the message in array of text and/or images.
178
+ */
179
+ content?: MessageContentComplex[];
180
+ }
181
+ export type MessageDeltaUpdate = {
182
+ type: ContentTypes.TEXT;
183
+ text: string;
184
+ tool_call_ids?: string[];
185
+ };
186
+ export type ReasoningDeltaUpdate = {
187
+ type: ContentTypes.THINK;
188
+ think: string;
189
+ };
190
+ export type ContentType = 'text' | 'image_url' | 'tool_call' | 'think' | string;
191
+ export type ReasoningContentText = {
192
+ type: ContentTypes.THINK;
193
+ think: string;
194
+ };
195
+ /** Vertex AI / Google Common - Reasoning Content Block Format */
196
+ export type GoogleReasoningContentText = {
197
+ type: ContentTypes.REASONING;
198
+ reasoning: string;
199
+ };
200
+ /** Anthropic's Reasoning Content Block Format */
201
+ export type ThinkingContentText = {
202
+ type: ContentTypes.THINKING;
203
+ index?: number;
204
+ signature?: string;
205
+ thinking?: string;
206
+ };
207
+ /** Bedrock's Reasoning Content Block Format */
208
+ export type BedrockReasoningContentText = {
209
+ type: ContentTypes.REASONING_CONTENT;
210
+ index?: number;
211
+ reasoningText: {
212
+ text?: string;
213
+ signature?: string;
214
+ };
215
+ };
216
+ /**
217
+ * A call to a tool.
218
+ */
219
+ export type ToolCallPart = {
220
+ /** Type ("tool_call") according to Assistants Tool Call Structure */
221
+ type: ContentTypes.TOOL_CALL;
222
+ /** The name of the tool to be called */
223
+ name: string;
224
+ /** The arguments to the tool call */
225
+ args?: string | Record<string, any>;
226
+ /** If provided, an identifier associated with the tool call */
227
+ id?: string;
228
+ /** If provided, the output of the tool call */
229
+ output?: string;
230
+ /** Auth URL */
231
+ auth?: string;
232
+ /** Expiration time */
233
+ expires_at?: number;
234
+ };
235
+ export type ToolCallContent = {
236
+ type: ContentTypes.TOOL_CALL;
237
+ tool_call?: ToolCallPart;
238
+ };
239
+ export type ToolResultContent = {
240
+ content: string | Record<string, unknown> | Array<string | Record<string, unknown>> | AnthropicContentBlock[];
241
+ type: 'tool_result' | 'web_search_result' | 'web_search_tool_result';
242
+ tool_use_id?: string;
243
+ input?: string | Record<string, unknown>;
244
+ index?: number;
245
+ };
246
+ export type MessageContentComplex = (ToolResultContent | ThinkingContentText | AgentUpdate | ToolCallContent | ReasoningContentText | MessageContentText | MessageContentImageUrl | (Record<string, any> & {
247
+ type?: 'text' | 'image_url' | 'think' | 'thinking' | string;
248
+ }) | (Record<string, any> & {
249
+ type?: never;
250
+ })) & {
251
+ tool_call_ids?: string[];
252
+ };
253
+ export interface TMessage {
254
+ role?: string;
255
+ content?: MessageContentComplex[] | string;
256
+ [key: string]: unknown;
257
+ }
258
+ export type TPayload = Array<Partial<TMessage>>;
259
+ export type CustomChunkDelta = null | undefined | (Partial<OpenAITypes.Chat.Completions.ChatCompletionChunk.Choice.Delta> & {
260
+ reasoning?: string | null;
261
+ reasoning_content?: string | null;
262
+ });
263
+ export type CustomChunkChoice = Partial<Omit<OpenAITypes.Chat.Completions.ChatCompletionChunk.Choice, 'delta'> & {
264
+ delta?: CustomChunkDelta;
265
+ }>;
266
+ export type CustomChunk = Partial<OpenAITypes.ChatCompletionChunk> & {
267
+ choices?: Partial<Array<CustomChunkChoice>>;
268
+ };
269
+ export type SplitStreamHandlers = Partial<{
270
+ [GraphEvents.ON_RUN_STEP]: ({ event, data, }: {
271
+ event: GraphEvents;
272
+ data: RunStep;
273
+ }) => void;
274
+ [GraphEvents.ON_MESSAGE_DELTA]: ({ event, data, }: {
275
+ event: GraphEvents;
276
+ data: MessageDeltaEvent;
277
+ }) => void;
278
+ [GraphEvents.ON_REASONING_DELTA]: ({ event, data, }: {
279
+ event: GraphEvents;
280
+ data: ReasoningDeltaEvent;
281
+ }) => void;
282
+ }>;
283
+ export type ContentAggregator = ({ event, data, }: {
284
+ event: GraphEvents;
285
+ data: RunStep | MessageDeltaEvent | RunStepDeltaEvent | {
286
+ result: ToolEndEvent;
287
+ };
288
+ }) => void;
289
+ export type ContentAggregatorResult = {
290
+ stepMap: Map<string, RunStep | undefined>;
291
+ contentParts: Array<MessageContentComplex | undefined>;
292
+ aggregateContent: ContentAggregator;
293
+ };
@@ -0,0 +1,61 @@
1
+ import type { StructuredToolInterface } from '@langchain/core/tools';
2
+ import type { RunnableToolLike } from '@langchain/core/runnables';
3
+ import type { ToolCall } from '@langchain/core/messages/tool';
4
+ import type { ToolErrorData } from './stream';
5
+ import { EnvVar } from '@/common';
6
+ /** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
7
+ export type CustomToolCall = {
8
+ name: string;
9
+ args: string | Record<string, any>;
10
+ id?: string;
11
+ type?: 'tool_call';
12
+ output?: string;
13
+ };
14
+ export type GenericTool = StructuredToolInterface | RunnableToolLike;
15
+ export type ToolMap = Map<string, GenericTool>;
16
+ export type ToolRefs = {
17
+ tools: GenericTool[];
18
+ toolMap?: ToolMap;
19
+ };
20
+ export type ToolRefGenerator = (tool_calls: ToolCall[]) => ToolRefs;
21
+ export type ToolNodeOptions = {
22
+ name?: string;
23
+ tags?: string[];
24
+ handleToolErrors?: boolean;
25
+ loadRuntimeTools?: ToolRefGenerator;
26
+ toolCallStepIds?: Map<string, string>;
27
+ errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => void;
28
+ };
29
+ export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
30
+ export type ToolEndEvent = {
31
+ /** The Step Id of the Tool Call */
32
+ id: string;
33
+ /** The Completed Tool Call */
34
+ tool_call: ToolCall;
35
+ /** The content index of the tool call */
36
+ index: number;
37
+ };
38
+ export type CodeEnvFile = {
39
+ id: string;
40
+ name: string;
41
+ session_id: string;
42
+ };
43
+ export type CodeExecutionToolParams = undefined | {
44
+ session_id?: string;
45
+ user_id?: string;
46
+ apiKey?: string;
47
+ files?: CodeEnvFile[];
48
+ [EnvVar.CODE_API_KEY]?: string;
49
+ };
50
+ export type FileRef = {
51
+ id: string;
52
+ name: string;
53
+ path?: string;
54
+ };
55
+ export type FileRefs = FileRef[];
56
+ export type ExecuteResult = {
57
+ session_id: string;
58
+ stdout: string;
59
+ stderr: string;
60
+ files?: FileRefs;
61
+ };
@@ -0,0 +1,2 @@
1
+ export declare const resetIfNotEmpty: <T>(value: T, resetValue: T) => T;
2
+ export declare const joinKeys: (args: (string | number | undefined)[]) => string;
@@ -0,0 +1,5 @@
1
+ export * from './graph';
2
+ export * from './llm';
3
+ export * from './misc';
4
+ export * from './run';
5
+ export * from './tokens';
@@ -0,0 +1,3 @@
1
+ import { Providers } from '@/common';
2
+ export declare function isOpenAILike(provider?: string | Providers): boolean;
3
+ export declare function isGoogleLike(provider?: string | Providers): boolean;