@agntk/core 0.1.0

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 (502) hide show
  1. package/README.md +227 -0
  2. package/dist/advanced/index.d.ts +35 -0
  3. package/dist/advanced/index.d.ts.map +1 -0
  4. package/dist/advanced/index.js +52 -0
  5. package/dist/advanced/index.js.map +1 -0
  6. package/dist/agent.d.ts +46 -0
  7. package/dist/agent.d.ts.map +1 -0
  8. package/dist/agent.js +381 -0
  9. package/dist/agent.js.map +1 -0
  10. package/dist/config/defaults.d.ts +10 -0
  11. package/dist/config/defaults.d.ts.map +1 -0
  12. package/dist/config/defaults.js +34 -0
  13. package/dist/config/defaults.js.map +1 -0
  14. package/dist/config/index.d.ts +7 -0
  15. package/dist/config/index.d.ts.map +1 -0
  16. package/dist/config/index.js +11 -0
  17. package/dist/config/index.js.map +1 -0
  18. package/dist/config/loader.d.ts +54 -0
  19. package/dist/config/loader.d.ts.map +1 -0
  20. package/dist/config/loader.js +222 -0
  21. package/dist/config/loader.js.map +1 -0
  22. package/dist/config/schema.d.ts +912 -0
  23. package/dist/config/schema.d.ts.map +1 -0
  24. package/dist/config/schema.js +119 -0
  25. package/dist/config/schema.js.map +1 -0
  26. package/dist/constants.d.ts +17 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/constants.js +23 -0
  29. package/dist/constants.js.map +1 -0
  30. package/dist/evals/assertions.d.ts +54 -0
  31. package/dist/evals/assertions.d.ts.map +1 -0
  32. package/dist/evals/assertions.js +200 -0
  33. package/dist/evals/assertions.js.map +1 -0
  34. package/dist/evals/index.d.ts +9 -0
  35. package/dist/evals/index.d.ts.map +1 -0
  36. package/dist/evals/index.js +8 -0
  37. package/dist/evals/index.js.map +1 -0
  38. package/dist/evals/runner.d.ts +34 -0
  39. package/dist/evals/runner.d.ts.map +1 -0
  40. package/dist/evals/runner.js +186 -0
  41. package/dist/evals/runner.js.map +1 -0
  42. package/dist/evals/types.d.ts +68 -0
  43. package/dist/evals/types.d.ts.map +1 -0
  44. package/dist/evals/types.js +5 -0
  45. package/dist/evals/types.js.map +1 -0
  46. package/dist/guardrails/built-ins.d.ts +48 -0
  47. package/dist/guardrails/built-ins.d.ts.map +1 -0
  48. package/dist/guardrails/built-ins.js +149 -0
  49. package/dist/guardrails/built-ins.js.map +1 -0
  50. package/dist/guardrails/index.d.ts +8 -0
  51. package/dist/guardrails/index.d.ts.map +1 -0
  52. package/dist/guardrails/index.js +7 -0
  53. package/dist/guardrails/index.js.map +1 -0
  54. package/dist/guardrails/runner.d.ts +49 -0
  55. package/dist/guardrails/runner.d.ts.map +1 -0
  56. package/dist/guardrails/runner.js +148 -0
  57. package/dist/guardrails/runner.js.map +1 -0
  58. package/dist/guardrails/types.d.ts +63 -0
  59. package/dist/guardrails/types.d.ts.map +1 -0
  60. package/dist/guardrails/types.js +22 -0
  61. package/dist/guardrails/types.js.map +1 -0
  62. package/dist/index.d.ts +31 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +35 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/memory/engine.d.ts +130 -0
  67. package/dist/memory/engine.d.ts.map +1 -0
  68. package/dist/memory/engine.js +227 -0
  69. package/dist/memory/engine.js.map +1 -0
  70. package/dist/memory/extraction.d.ts +24 -0
  71. package/dist/memory/extraction.d.ts.map +1 -0
  72. package/dist/memory/extraction.js +130 -0
  73. package/dist/memory/extraction.js.map +1 -0
  74. package/dist/memory/loader.d.ts +20 -0
  75. package/dist/memory/loader.d.ts.map +1 -0
  76. package/dist/memory/loader.js +73 -0
  77. package/dist/memory/loader.js.map +1 -0
  78. package/dist/memory/store.d.ts +42 -0
  79. package/dist/memory/store.d.ts.map +1 -0
  80. package/dist/memory/store.js +120 -0
  81. package/dist/memory/store.js.map +1 -0
  82. package/dist/memory/tools.d.ts +39 -0
  83. package/dist/memory/tools.d.ts.map +1 -0
  84. package/dist/memory/tools.js +225 -0
  85. package/dist/memory/tools.js.map +1 -0
  86. package/dist/memory/types.d.ts +46 -0
  87. package/dist/memory/types.d.ts.map +1 -0
  88. package/dist/memory/types.js +8 -0
  89. package/dist/memory/types.js.map +1 -0
  90. package/dist/memory/vectra-store.d.ts +31 -0
  91. package/dist/memory/vectra-store.d.ts.map +1 -0
  92. package/dist/memory/vectra-store.js +122 -0
  93. package/dist/memory/vectra-store.js.map +1 -0
  94. package/dist/models.d.ts +37 -0
  95. package/dist/models.d.ts.map +1 -0
  96. package/dist/models.js +131 -0
  97. package/dist/models.js.map +1 -0
  98. package/dist/observability/index.d.ts +6 -0
  99. package/dist/observability/index.d.ts.map +1 -0
  100. package/dist/observability/index.js +5 -0
  101. package/dist/observability/index.js.map +1 -0
  102. package/dist/observability/langfuse.d.ts +47 -0
  103. package/dist/observability/langfuse.d.ts.map +1 -0
  104. package/dist/observability/langfuse.js +112 -0
  105. package/dist/observability/langfuse.js.map +1 -0
  106. package/dist/observability/types.d.ts +37 -0
  107. package/dist/observability/types.d.ts.map +1 -0
  108. package/dist/observability/types.js +5 -0
  109. package/dist/observability/types.js.map +1 -0
  110. package/dist/pool/index.d.ts +7 -0
  111. package/dist/pool/index.d.ts.map +1 -0
  112. package/dist/pool/index.js +6 -0
  113. package/dist/pool/index.js.map +1 -0
  114. package/dist/pool/specialist-pool.d.ts +59 -0
  115. package/dist/pool/specialist-pool.d.ts.map +1 -0
  116. package/dist/pool/specialist-pool.js +224 -0
  117. package/dist/pool/specialist-pool.js.map +1 -0
  118. package/dist/pool/tools.d.ts +63 -0
  119. package/dist/pool/tools.d.ts.map +1 -0
  120. package/dist/pool/tools.js +83 -0
  121. package/dist/pool/tools.js.map +1 -0
  122. package/dist/pool/types.d.ts +79 -0
  123. package/dist/pool/types.d.ts.map +1 -0
  124. package/dist/pool/types.js +5 -0
  125. package/dist/pool/types.js.map +1 -0
  126. package/dist/presets/index.d.ts +5 -0
  127. package/dist/presets/index.d.ts.map +1 -0
  128. package/dist/presets/index.js +5 -0
  129. package/dist/presets/index.js.map +1 -0
  130. package/dist/presets/role-registry.d.ts +41 -0
  131. package/dist/presets/role-registry.d.ts.map +1 -0
  132. package/dist/presets/role-registry.js +213 -0
  133. package/dist/presets/role-registry.js.map +1 -0
  134. package/dist/presets/roles.d.ts +105 -0
  135. package/dist/presets/roles.d.ts.map +1 -0
  136. package/dist/presets/roles.js +207 -0
  137. package/dist/presets/roles.js.map +1 -0
  138. package/dist/presets/sub-agent-configs.d.ts +19 -0
  139. package/dist/presets/sub-agent-configs.d.ts.map +1 -0
  140. package/dist/presets/sub-agent-configs.js +71 -0
  141. package/dist/presets/sub-agent-configs.js.map +1 -0
  142. package/dist/presets/tool-preset-registry.d.ts +34 -0
  143. package/dist/presets/tool-preset-registry.d.ts.map +1 -0
  144. package/dist/presets/tool-preset-registry.js +107 -0
  145. package/dist/presets/tool-preset-registry.js.map +1 -0
  146. package/dist/presets/tools.d.ts +278 -0
  147. package/dist/presets/tools.d.ts.map +1 -0
  148. package/dist/presets/tools.js +108 -0
  149. package/dist/presets/tools.js.map +1 -0
  150. package/dist/prompts/context.d.ts +47 -0
  151. package/dist/prompts/context.d.ts.map +1 -0
  152. package/dist/prompts/context.js +187 -0
  153. package/dist/prompts/context.js.map +1 -0
  154. package/dist/prompts/template.d.ts +17 -0
  155. package/dist/prompts/template.d.ts.map +1 -0
  156. package/dist/prompts/template.js +32 -0
  157. package/dist/prompts/template.js.map +1 -0
  158. package/dist/prompts/templates.d.ts +11 -0
  159. package/dist/prompts/templates.d.ts.map +1 -0
  160. package/dist/prompts/templates.js +115 -0
  161. package/dist/prompts/templates.js.map +1 -0
  162. package/dist/reflection.d.ts +48 -0
  163. package/dist/reflection.d.ts.map +1 -0
  164. package/dist/reflection.js +91 -0
  165. package/dist/reflection.js.map +1 -0
  166. package/dist/skills/index.d.ts +6 -0
  167. package/dist/skills/index.d.ts.map +1 -0
  168. package/dist/skills/index.js +5 -0
  169. package/dist/skills/index.js.map +1 -0
  170. package/dist/skills/loader.d.ts +84 -0
  171. package/dist/skills/loader.d.ts.map +1 -0
  172. package/dist/skills/loader.js +400 -0
  173. package/dist/skills/loader.js.map +1 -0
  174. package/dist/skills/types.d.ts +66 -0
  175. package/dist/skills/types.d.ts.map +1 -0
  176. package/dist/skills/types.js +6 -0
  177. package/dist/skills/types.js.map +1 -0
  178. package/dist/streaming/data-parts.d.ts +163 -0
  179. package/dist/streaming/data-parts.d.ts.map +1 -0
  180. package/dist/streaming/data-parts.js +14 -0
  181. package/dist/streaming/data-parts.js.map +1 -0
  182. package/dist/streaming/index.d.ts +8 -0
  183. package/dist/streaming/index.d.ts.map +1 -0
  184. package/dist/streaming/index.js +10 -0
  185. package/dist/streaming/index.js.map +1 -0
  186. package/dist/streaming/transient.d.ts +136 -0
  187. package/dist/streaming/transient.d.ts.map +1 -0
  188. package/dist/streaming/transient.js +201 -0
  189. package/dist/streaming/transient.js.map +1 -0
  190. package/dist/tools/approval.d.ts +67 -0
  191. package/dist/tools/approval.d.ts.map +1 -0
  192. package/dist/tools/approval.js +113 -0
  193. package/dist/tools/approval.js.map +1 -0
  194. package/dist/tools/ast-grep/cli.d.ts +16 -0
  195. package/dist/tools/ast-grep/cli.d.ts.map +1 -0
  196. package/dist/tools/ast-grep/cli.js +198 -0
  197. package/dist/tools/ast-grep/cli.js.map +1 -0
  198. package/dist/tools/ast-grep/constants.d.ts +24 -0
  199. package/dist/tools/ast-grep/constants.d.ts.map +1 -0
  200. package/dist/tools/ast-grep/constants.js +247 -0
  201. package/dist/tools/ast-grep/constants.js.map +1 -0
  202. package/dist/tools/ast-grep/downloader.d.ts +6 -0
  203. package/dist/tools/ast-grep/downloader.d.ts.map +1 -0
  204. package/dist/tools/ast-grep/downloader.js +137 -0
  205. package/dist/tools/ast-grep/downloader.js.map +1 -0
  206. package/dist/tools/ast-grep/index.d.ts +7 -0
  207. package/dist/tools/ast-grep/index.d.ts.map +1 -0
  208. package/dist/tools/ast-grep/index.js +6 -0
  209. package/dist/tools/ast-grep/index.js.map +1 -0
  210. package/dist/tools/ast-grep/tools.d.ts +33 -0
  211. package/dist/tools/ast-grep/tools.d.ts.map +1 -0
  212. package/dist/tools/ast-grep/tools.js +140 -0
  213. package/dist/tools/ast-grep/tools.js.map +1 -0
  214. package/dist/tools/ast-grep/types.d.ts +68 -0
  215. package/dist/tools/ast-grep/types.d.ts.map +1 -0
  216. package/dist/tools/ast-grep/types.js +2 -0
  217. package/dist/tools/ast-grep/types.js.map +1 -0
  218. package/dist/tools/ast-grep/utils.d.ts +4 -0
  219. package/dist/tools/ast-grep/utils.d.ts.map +1 -0
  220. package/dist/tools/ast-grep/utils.js +55 -0
  221. package/dist/tools/ast-grep/utils.js.map +1 -0
  222. package/dist/tools/browser/index.d.ts +6 -0
  223. package/dist/tools/browser/index.d.ts.map +1 -0
  224. package/dist/tools/browser/index.js +5 -0
  225. package/dist/tools/browser/index.js.map +1 -0
  226. package/dist/tools/browser/stream.d.ts +112 -0
  227. package/dist/tools/browser/stream.d.ts.map +1 -0
  228. package/dist/tools/browser/stream.js +228 -0
  229. package/dist/tools/browser/stream.js.map +1 -0
  230. package/dist/tools/browser/tool.d.ts +144 -0
  231. package/dist/tools/browser/tool.d.ts.map +1 -0
  232. package/dist/tools/browser/tool.js +214 -0
  233. package/dist/tools/browser/tool.js.map +1 -0
  234. package/dist/tools/browser/types.d.ts +216 -0
  235. package/dist/tools/browser/types.d.ts.map +1 -0
  236. package/dist/tools/browser/types.js +146 -0
  237. package/dist/tools/browser/types.js.map +1 -0
  238. package/dist/tools/deep-reasoning/constants.d.ts +11 -0
  239. package/dist/tools/deep-reasoning/constants.d.ts.map +1 -0
  240. package/dist/tools/deep-reasoning/constants.js +35 -0
  241. package/dist/tools/deep-reasoning/constants.js.map +1 -0
  242. package/dist/tools/deep-reasoning/engine.d.ts +20 -0
  243. package/dist/tools/deep-reasoning/engine.d.ts.map +1 -0
  244. package/dist/tools/deep-reasoning/engine.js +77 -0
  245. package/dist/tools/deep-reasoning/engine.js.map +1 -0
  246. package/dist/tools/deep-reasoning/index.d.ts +5 -0
  247. package/dist/tools/deep-reasoning/index.d.ts.map +1 -0
  248. package/dist/tools/deep-reasoning/index.js +7 -0
  249. package/dist/tools/deep-reasoning/index.js.map +1 -0
  250. package/dist/tools/deep-reasoning/tools.d.ts +12 -0
  251. package/dist/tools/deep-reasoning/tools.d.ts.map +1 -0
  252. package/dist/tools/deep-reasoning/tools.js +23 -0
  253. package/dist/tools/deep-reasoning/tools.js.map +1 -0
  254. package/dist/tools/deep-reasoning/types.d.ts +66 -0
  255. package/dist/tools/deep-reasoning/types.d.ts.map +1 -0
  256. package/dist/tools/deep-reasoning/types.js +13 -0
  257. package/dist/tools/deep-reasoning/types.js.map +1 -0
  258. package/dist/tools/factory.d.ts +109 -0
  259. package/dist/tools/factory.d.ts.map +1 -0
  260. package/dist/tools/factory.js +166 -0
  261. package/dist/tools/factory.js.map +1 -0
  262. package/dist/tools/file/index.d.ts +8 -0
  263. package/dist/tools/file/index.d.ts.map +1 -0
  264. package/dist/tools/file/index.js +8 -0
  265. package/dist/tools/file/index.js.map +1 -0
  266. package/dist/tools/file/tools.d.ts +45 -0
  267. package/dist/tools/file/tools.d.ts.map +1 -0
  268. package/dist/tools/file/tools.js +206 -0
  269. package/dist/tools/file/tools.js.map +1 -0
  270. package/dist/tools/glob/cli.d.ts +8 -0
  271. package/dist/tools/glob/cli.d.ts.map +1 -0
  272. package/dist/tools/glob/cli.js +168 -0
  273. package/dist/tools/glob/cli.js.map +1 -0
  274. package/dist/tools/glob/constants.d.ts +7 -0
  275. package/dist/tools/glob/constants.d.ts.map +1 -0
  276. package/dist/tools/glob/constants.js +17 -0
  277. package/dist/tools/glob/constants.js.map +1 -0
  278. package/dist/tools/glob/index.d.ts +6 -0
  279. package/dist/tools/glob/index.d.ts.map +1 -0
  280. package/dist/tools/glob/index.js +5 -0
  281. package/dist/tools/glob/index.js.map +1 -0
  282. package/dist/tools/glob/tools.d.ts +15 -0
  283. package/dist/tools/glob/tools.d.ts.map +1 -0
  284. package/dist/tools/glob/tools.js +74 -0
  285. package/dist/tools/glob/tools.js.map +1 -0
  286. package/dist/tools/glob/types.d.ts +20 -0
  287. package/dist/tools/glob/types.d.ts.map +1 -0
  288. package/dist/tools/glob/types.js +2 -0
  289. package/dist/tools/glob/types.js.map +1 -0
  290. package/dist/tools/glob/utils.d.ts +3 -0
  291. package/dist/tools/glob/utils.d.ts.map +1 -0
  292. package/dist/tools/glob/utils.js +20 -0
  293. package/dist/tools/glob/utils.js.map +1 -0
  294. package/dist/tools/grep/cli.d.ts +4 -0
  295. package/dist/tools/grep/cli.d.ts.map +1 -0
  296. package/dist/tools/grep/cli.js +224 -0
  297. package/dist/tools/grep/cli.js.map +1 -0
  298. package/dist/tools/grep/constants.d.ts +19 -0
  299. package/dist/tools/grep/constants.d.ts.map +1 -0
  300. package/dist/tools/grep/constants.js +115 -0
  301. package/dist/tools/grep/constants.js.map +1 -0
  302. package/dist/tools/grep/downloader.d.ts +3 -0
  303. package/dist/tools/grep/downloader.d.ts.map +1 -0
  304. package/dist/tools/grep/downloader.js +164 -0
  305. package/dist/tools/grep/downloader.js.map +1 -0
  306. package/dist/tools/grep/index.d.ts +7 -0
  307. package/dist/tools/grep/index.d.ts.map +1 -0
  308. package/dist/tools/grep/index.js +6 -0
  309. package/dist/tools/grep/index.js.map +1 -0
  310. package/dist/tools/grep/tools.d.ts +19 -0
  311. package/dist/tools/grep/tools.d.ts.map +1 -0
  312. package/dist/tools/grep/tools.js +82 -0
  313. package/dist/tools/grep/tools.js.map +1 -0
  314. package/dist/tools/grep/types.d.ts +37 -0
  315. package/dist/tools/grep/types.d.ts.map +1 -0
  316. package/dist/tools/grep/types.js +2 -0
  317. package/dist/tools/grep/types.js.map +1 -0
  318. package/dist/tools/grep/utils.d.ts +4 -0
  319. package/dist/tools/grep/utils.d.ts.map +1 -0
  320. package/dist/tools/grep/utils.js +41 -0
  321. package/dist/tools/grep/utils.js.map +1 -0
  322. package/dist/tools/index.d.ts +21 -0
  323. package/dist/tools/index.d.ts.map +1 -0
  324. package/dist/tools/index.js +33 -0
  325. package/dist/tools/index.js.map +1 -0
  326. package/dist/tools/model-retry.d.ts +54 -0
  327. package/dist/tools/model-retry.d.ts.map +1 -0
  328. package/dist/tools/model-retry.js +110 -0
  329. package/dist/tools/model-retry.js.map +1 -0
  330. package/dist/tools/plan/constants.d.ts +18 -0
  331. package/dist/tools/plan/constants.d.ts.map +1 -0
  332. package/dist/tools/plan/constants.js +13 -0
  333. package/dist/tools/plan/constants.js.map +1 -0
  334. package/dist/tools/plan/index.d.ts +5 -0
  335. package/dist/tools/plan/index.d.ts.map +1 -0
  336. package/dist/tools/plan/index.js +7 -0
  337. package/dist/tools/plan/index.js.map +1 -0
  338. package/dist/tools/plan/tools.d.ts +16 -0
  339. package/dist/tools/plan/tools.d.ts.map +1 -0
  340. package/dist/tools/plan/tools.js +217 -0
  341. package/dist/tools/plan/tools.js.map +1 -0
  342. package/dist/tools/plan/types.d.ts +75 -0
  343. package/dist/tools/plan/types.d.ts.map +1 -0
  344. package/dist/tools/plan/types.js +16 -0
  345. package/dist/tools/plan/types.js.map +1 -0
  346. package/dist/tools/plan/utils.d.ts +9 -0
  347. package/dist/tools/plan/utils.d.ts.map +1 -0
  348. package/dist/tools/plan/utils.js +27 -0
  349. package/dist/tools/plan/utils.js.map +1 -0
  350. package/dist/tools/progress/index.d.ts +53 -0
  351. package/dist/tools/progress/index.d.ts.map +1 -0
  352. package/dist/tools/progress/index.js +144 -0
  353. package/dist/tools/progress/index.js.map +1 -0
  354. package/dist/tools/provider.d.ts +97 -0
  355. package/dist/tools/provider.d.ts.map +1 -0
  356. package/dist/tools/provider.js +178 -0
  357. package/dist/tools/provider.js.map +1 -0
  358. package/dist/tools/search-skills.d.ts +44 -0
  359. package/dist/tools/search-skills.d.ts.map +1 -0
  360. package/dist/tools/search-skills.js +134 -0
  361. package/dist/tools/search-skills.js.map +1 -0
  362. package/dist/tools/shell/background.d.ts +38 -0
  363. package/dist/tools/shell/background.d.ts.map +1 -0
  364. package/dist/tools/shell/background.js +229 -0
  365. package/dist/tools/shell/background.js.map +1 -0
  366. package/dist/tools/shell/constants.d.ts +10 -0
  367. package/dist/tools/shell/constants.d.ts.map +1 -0
  368. package/dist/tools/shell/constants.js +55 -0
  369. package/dist/tools/shell/constants.js.map +1 -0
  370. package/dist/tools/shell/index.d.ts +7 -0
  371. package/dist/tools/shell/index.d.ts.map +1 -0
  372. package/dist/tools/shell/index.js +5 -0
  373. package/dist/tools/shell/index.js.map +1 -0
  374. package/dist/tools/shell/tools.d.ts +22 -0
  375. package/dist/tools/shell/tools.d.ts.map +1 -0
  376. package/dist/tools/shell/tools.js +70 -0
  377. package/dist/tools/shell/tools.js.map +1 -0
  378. package/dist/tools/shell/types.d.ts +30 -0
  379. package/dist/tools/shell/types.d.ts.map +1 -0
  380. package/dist/tools/shell/types.js +10 -0
  381. package/dist/tools/shell/types.js.map +1 -0
  382. package/dist/tools/shell/utils.d.ts +7 -0
  383. package/dist/tools/shell/utils.d.ts.map +1 -0
  384. package/dist/tools/shell/utils.js +26 -0
  385. package/dist/tools/shell/utils.js.map +1 -0
  386. package/dist/tools/spawn-agent/index.d.ts +96 -0
  387. package/dist/tools/spawn-agent/index.d.ts.map +1 -0
  388. package/dist/tools/spawn-agent/index.js +168 -0
  389. package/dist/tools/spawn-agent/index.js.map +1 -0
  390. package/dist/tools/utils/errors.d.ts +21 -0
  391. package/dist/tools/utils/errors.d.ts.map +1 -0
  392. package/dist/tools/utils/errors.js +29 -0
  393. package/dist/tools/utils/errors.js.map +1 -0
  394. package/dist/tools/utils/shell.d.ts +23 -0
  395. package/dist/tools/utils/shell.d.ts.map +1 -0
  396. package/dist/tools/utils/shell.js +99 -0
  397. package/dist/tools/utils/shell.js.map +1 -0
  398. package/dist/tools/utils/tool-result.d.ts +6 -0
  399. package/dist/tools/utils/tool-result.d.ts.map +1 -0
  400. package/dist/tools/utils/tool-result.js +22 -0
  401. package/dist/tools/utils/tool-result.js.map +1 -0
  402. package/dist/types/agent.d.ts +218 -0
  403. package/dist/types/agent.d.ts.map +1 -0
  404. package/dist/types/agent.js +6 -0
  405. package/dist/types/agent.js.map +1 -0
  406. package/dist/types/index.d.ts +7 -0
  407. package/dist/types/index.d.ts.map +1 -0
  408. package/dist/types/index.js +6 -0
  409. package/dist/types/index.js.map +1 -0
  410. package/dist/types/lifecycle.d.ts +218 -0
  411. package/dist/types/lifecycle.d.ts.map +1 -0
  412. package/dist/types/lifecycle.js +99 -0
  413. package/dist/types/lifecycle.js.map +1 -0
  414. package/dist/types/streaming.d.ts +120 -0
  415. package/dist/types/streaming.d.ts.map +1 -0
  416. package/dist/types/streaming.js +6 -0
  417. package/dist/types/streaming.js.map +1 -0
  418. package/dist/usage-limits.d.ts +63 -0
  419. package/dist/usage-limits.d.ts.map +1 -0
  420. package/dist/usage-limits.js +88 -0
  421. package/dist/usage-limits.js.map +1 -0
  422. package/dist/utils/logger.d.ts +35 -0
  423. package/dist/utils/logger.d.ts.map +1 -0
  424. package/dist/utils/logger.js +149 -0
  425. package/dist/utils/logger.js.map +1 -0
  426. package/dist/workflow/builders/adapt.d.ts +20 -0
  427. package/dist/workflow/builders/adapt.d.ts.map +1 -0
  428. package/dist/workflow/builders/adapt.js +33 -0
  429. package/dist/workflow/builders/adapt.js.map +1 -0
  430. package/dist/workflow/builders/index.d.ts +8 -0
  431. package/dist/workflow/builders/index.d.ts.map +1 -0
  432. package/dist/workflow/builders/index.js +7 -0
  433. package/dist/workflow/builders/index.js.map +1 -0
  434. package/dist/workflow/builders/parallel.d.ts +25 -0
  435. package/dist/workflow/builders/parallel.d.ts.map +1 -0
  436. package/dist/workflow/builders/parallel.js +60 -0
  437. package/dist/workflow/builders/parallel.js.map +1 -0
  438. package/dist/workflow/builders/pipeline.d.ts +22 -0
  439. package/dist/workflow/builders/pipeline.d.ts.map +1 -0
  440. package/dist/workflow/builders/pipeline.js +48 -0
  441. package/dist/workflow/builders/pipeline.js.map +1 -0
  442. package/dist/workflow/builders/types.d.ts +54 -0
  443. package/dist/workflow/builders/types.d.ts.map +1 -0
  444. package/dist/workflow/builders/types.js +5 -0
  445. package/dist/workflow/builders/types.js.map +1 -0
  446. package/dist/workflow/durable-agent.d.ts +128 -0
  447. package/dist/workflow/durable-agent.d.ts.map +1 -0
  448. package/dist/workflow/durable-agent.js +323 -0
  449. package/dist/workflow/durable-agent.js.map +1 -0
  450. package/dist/workflow/durable-tool.d.ts +103 -0
  451. package/dist/workflow/durable-tool.d.ts.map +1 -0
  452. package/dist/workflow/durable-tool.js +173 -0
  453. package/dist/workflow/durable-tool.js.map +1 -0
  454. package/dist/workflow/hooks.d.ts +318 -0
  455. package/dist/workflow/hooks.d.ts.map +1 -0
  456. package/dist/workflow/hooks.js +629 -0
  457. package/dist/workflow/hooks.js.map +1 -0
  458. package/dist/workflow/index.d.ts +17 -0
  459. package/dist/workflow/index.d.ts.map +1 -0
  460. package/dist/workflow/index.js +24 -0
  461. package/dist/workflow/index.js.map +1 -0
  462. package/dist/workflow/schedulers.d.ts +231 -0
  463. package/dist/workflow/schedulers.d.ts.map +1 -0
  464. package/dist/workflow/schedulers.js +250 -0
  465. package/dist/workflow/schedulers.js.map +1 -0
  466. package/dist/workflow/team/create-team.d.ts +34 -0
  467. package/dist/workflow/team/create-team.d.ts.map +1 -0
  468. package/dist/workflow/team/create-team.js +242 -0
  469. package/dist/workflow/team/create-team.js.map +1 -0
  470. package/dist/workflow/team/index.d.ts +9 -0
  471. package/dist/workflow/team/index.d.ts.map +1 -0
  472. package/dist/workflow/team/index.js +8 -0
  473. package/dist/workflow/team/index.js.map +1 -0
  474. package/dist/workflow/team/machines.d.ts +152 -0
  475. package/dist/workflow/team/machines.d.ts.map +1 -0
  476. package/dist/workflow/team/machines.js +197 -0
  477. package/dist/workflow/team/machines.js.map +1 -0
  478. package/dist/workflow/team/task-board.d.ts +47 -0
  479. package/dist/workflow/team/task-board.d.ts.map +1 -0
  480. package/dist/workflow/team/task-board.js +111 -0
  481. package/dist/workflow/team/task-board.js.map +1 -0
  482. package/dist/workflow/team/tools.d.ts +66 -0
  483. package/dist/workflow/team/tools.d.ts.map +1 -0
  484. package/dist/workflow/team/tools.js +100 -0
  485. package/dist/workflow/team/tools.js.map +1 -0
  486. package/dist/workflow/team/types.d.ts +109 -0
  487. package/dist/workflow/team/types.d.ts.map +1 -0
  488. package/dist/workflow/team/types.js +5 -0
  489. package/dist/workflow/team/types.js.map +1 -0
  490. package/dist/workflow/templates.d.ts +71 -0
  491. package/dist/workflow/templates.d.ts.map +1 -0
  492. package/dist/workflow/templates.js +132 -0
  493. package/dist/workflow/templates.js.map +1 -0
  494. package/dist/workflow/utils.d.ts +29 -0
  495. package/dist/workflow/utils.d.ts.map +1 -0
  496. package/dist/workflow/utils.js +84 -0
  497. package/dist/workflow/utils.js.map +1 -0
  498. package/dist/wrappers/best-of-n.d.ts +69 -0
  499. package/dist/wrappers/best-of-n.d.ts.map +1 -0
  500. package/dist/wrappers/best-of-n.js +242 -0
  501. package/dist/wrappers/best-of-n.js.map +1 -0
  502. package/package.json +101 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-parts.d.ts","sourceRoot":"","sources":["../../src/streaming/data-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;IAEvC;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,cAAc,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,cAAc,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;IAElC;;OAEG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;IAEpC;;OAEG;IACH,eAAe,EAAE,gBAAgB,CAAC;CACnC,CAAC;AAMF,gCAAgC;AAChC,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,OAAO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AI,EAAE,CAAC,CAAC;IACR,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CACzB;AAED,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG;KACvB,CAAC,IAAI,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC;CAC9C,CAAC,MAAM,cAAc,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @fileoverview Custom data part types for AI SDK streaming.
3
+ * These types define the shape of transient data streamed during agent execution.
4
+ *
5
+ * Usage with AI SDK:
6
+ * ```typescript
7
+ * import type { DataStreamWriter } from 'ai';
8
+ *
9
+ * const writer: DataStreamWriter = ...;
10
+ * writer.writeData({ type: 'file-content', data: { path: '/foo.ts', content: '...', truncated: false } });
11
+ * ```
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=data-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-parts.js","sourceRoot":"","sources":["../../src/streaming/data-parts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @agntk/core - Streaming Module
3
+ *
4
+ * Exports for transient streaming and custom data parts.
5
+ */
6
+ export { type AgentDataParts, type SubAgentStreamData, type SearchResultData, type FileContentData, type ShellOutputData, type ToolProgressData, type ReasoningStepData, type MemoryResultData, type DataPartType, type TypedDataPart, type AnyDataPart, } from './data-parts.js';
7
+ export { withTransientStreaming, writeTransient, streamTransient, streamFileContent, streamShellOutput, streamSearchResult, streamProgress, streamReasoningStep, streamSubAgent, type TransientStreamWriter, type TransientToolContext, } from './transient.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @agntk/core - Streaming Module
3
+ *
4
+ * Exports for transient streaming and custom data parts.
5
+ */
6
+ // Data part types
7
+ export {} from './data-parts.js';
8
+ // Transient streaming
9
+ export { withTransientStreaming, writeTransient, streamTransient, streamFileContent, streamShellOutput, streamSearchResult, streamProgress, streamReasoningStep, streamSubAgent, } from './transient.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kBAAkB;AAClB,OAAO,EAYN,MAAM,cAAc,CAAC;AAEtB,sBAAsB;AACtB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,cAAc,GAGf,MAAM,aAAa,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @agntk/core - Transient Streaming Infrastructure
3
+ *
4
+ * Enables tools to stream data to the UI without persisting to conversation context.
5
+ * This keeps the context window lean while providing rich UI feedback.
6
+ */
7
+ import type { Tool } from 'ai';
8
+ import type { ToolContext } from '../types/lifecycle.js';
9
+ import type { AgentDataParts } from './data-parts.js';
10
+ /**
11
+ * Interface for UI stream writer.
12
+ * Compatible with AI SDK's DataStreamWriter.
13
+ */
14
+ export interface TransientStreamWriter {
15
+ writeData(data: unknown): void;
16
+ }
17
+ /**
18
+ * Enhanced tool context with transient streaming capabilities.
19
+ * Uses intersection type to extend ToolContext without conflicts.
20
+ */
21
+ export type TransientToolContext = ToolContext & {
22
+ /** Helper to stream typed transient data */
23
+ stream: <K extends keyof AgentDataParts>(type: K, data: AgentDataParts[K]) => void;
24
+ };
25
+ /**
26
+ * Tool set is a record of tools keyed by name.
27
+ */
28
+ type ToolSet = Record<string, Tool>;
29
+ /**
30
+ * Wrap tools to enable transient streaming.
31
+ *
32
+ * Tools wrapped with this function will have access to a `stream()` helper
33
+ * in their context that allows streaming data to the UI without adding
34
+ * it to the conversation context.
35
+ *
36
+ * @param tools - Record of tools to wrap
37
+ * @param writer - Stream writer for sending data to the client
38
+ * @returns Wrapped tools with transient streaming enabled
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const wrappedTools = withTransientStreaming(myTools, dataStream);
43
+ *
44
+ * // Inside a tool's execute function:
45
+ * execute: async (input, ctx) => {
46
+ * ctx.stream('file-content', {
47
+ * path: input.path,
48
+ * content: fileContent,
49
+ * truncated: false,
50
+ * });
51
+ * return `Read ${input.path}`;
52
+ * }
53
+ * ```
54
+ */
55
+ export declare function withTransientStreaming(tools: ToolSet, writer: TransientStreamWriter): ToolSet;
56
+ /**
57
+ * Stream typed transient data to the UI.
58
+ *
59
+ * @param writer - Stream writer instance
60
+ * @param type - Data part type
61
+ * @param data - Data to stream
62
+ */
63
+ export declare function writeTransient<K extends keyof AgentDataParts>(writer: TransientStreamWriter, type: K, data: AgentDataParts[K]): void;
64
+ /**
65
+ * Helper for tools to stream transient data from within their execute function.
66
+ *
67
+ * @param ctx - Tool context (must have writer)
68
+ * @param type - Data part type
69
+ * @param data - Data to stream
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // Inside a tool's execute function:
74
+ * streamTransient(ctx, 'shell-output', {
75
+ * command: 'npm test',
76
+ * output: result.stdout,
77
+ * exitCode: result.code,
78
+ * });
79
+ * ```
80
+ */
81
+ export declare function streamTransient<K extends keyof AgentDataParts>(ctx: ToolContext, type: K, data: AgentDataParts[K]): void;
82
+ /**
83
+ * Stream file content transiently.
84
+ */
85
+ export declare function streamFileContent(ctx: ToolContext, path: string, content: string, options?: {
86
+ truncated?: boolean;
87
+ totalBytes?: number;
88
+ language?: string;
89
+ lineRange?: {
90
+ start: number;
91
+ end: number;
92
+ };
93
+ }): void;
94
+ /**
95
+ * Stream shell output transiently.
96
+ */
97
+ export declare function streamShellOutput(ctx: ToolContext, command: string, output: string, exitCode: number, options?: {
98
+ cwd?: string;
99
+ truncated?: boolean;
100
+ durationMs?: number;
101
+ }): void;
102
+ /**
103
+ * Stream search results transiently.
104
+ */
105
+ export declare function streamSearchResult(ctx: ToolContext, path: string, content: string, matches: number, options?: {
106
+ line?: number;
107
+ pattern?: string;
108
+ }): void;
109
+ /**
110
+ * Stream tool progress update transiently.
111
+ */
112
+ export declare function streamProgress(ctx: ToolContext, toolName: string, progress: number, message: string, options?: {
113
+ estimatedRemaining?: number;
114
+ step?: {
115
+ current: number;
116
+ total: number;
117
+ };
118
+ }): void;
119
+ /**
120
+ * Stream reasoning step transiently.
121
+ *
122
+ * @internal Forward-designed for CLI streaming feature. No production callers yet.
123
+ */
124
+ export declare function streamReasoningStep(ctx: ToolContext, stepNumber: number, totalSteps: number, thought: string, options?: {
125
+ isRevision?: boolean;
126
+ revisesThought?: number;
127
+ branchId?: string;
128
+ }): void;
129
+ /**
130
+ * Stream sub-agent output transiently.
131
+ *
132
+ * @internal Forward-designed for CLI streaming feature. No production callers yet.
133
+ */
134
+ export declare function streamSubAgent(ctx: ToolContext, agentId: string, role: string, text: string, status: 'streaming' | 'complete' | 'error', error?: string): void;
135
+ export {};
136
+ //# sourceMappingURL=transient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transient.d.ts","sourceRoot":"","sources":["../../src/streaming/transient.ts"],"names":[],"mappings":"AAAA;;;;;GA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AQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,EAC1C,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAQN"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @agntk/core - Transient Streaming Infrastructure
3
+ *
4
+ * Enables tools to stream data to the UI without persisting to conversation context.
5
+ * This keeps the context window lean while providing rich UI feedback.
6
+ */
7
+ import { createLogger } from '@agntk/logger';
8
+ const log = createLogger('@agntk/core:streaming');
9
+ // ============================================================================
10
+ // Main API: withTransientStreaming
11
+ // ============================================================================
12
+ /**
13
+ * Wrap tools to enable transient streaming.
14
+ *
15
+ * Tools wrapped with this function will have access to a `stream()` helper
16
+ * in their context that allows streaming data to the UI without adding
17
+ * it to the conversation context.
18
+ *
19
+ * @param tools - Record of tools to wrap
20
+ * @param writer - Stream writer for sending data to the client
21
+ * @returns Wrapped tools with transient streaming enabled
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const wrappedTools = withTransientStreaming(myTools, dataStream);
26
+ *
27
+ * // Inside a tool's execute function:
28
+ * execute: async (input, ctx) => {
29
+ * ctx.stream('file-content', {
30
+ * path: input.path,
31
+ * content: fileContent,
32
+ * truncated: false,
33
+ * });
34
+ * return `Read ${input.path}`;
35
+ * }
36
+ * ```
37
+ */
38
+ export function withTransientStreaming(tools, writer) {
39
+ const wrappedTools = {};
40
+ for (const [name, tool] of Object.entries(tools)) {
41
+ wrappedTools[name] = wrapToolWithTransient(tool, writer, name);
42
+ }
43
+ return wrappedTools;
44
+ }
45
+ // ============================================================================
46
+ // Tool Wrapping
47
+ // ============================================================================
48
+ /**
49
+ * Wrap a single tool with transient streaming capabilities.
50
+ */
51
+ function wrapToolWithTransient(tool, writer, toolName) {
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ const originalExecute = tool.execute;
54
+ if (!originalExecute) {
55
+ return tool;
56
+ }
57
+ return {
58
+ ...tool,
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ execute: async (input, options) => {
61
+ // Create enhanced context with streaming helper
62
+ const enhancedContext = {
63
+ ...(options || {}),
64
+ agentId: options?.agentId || 'unknown',
65
+ stepNumber: options?.stepNumber || 0,
66
+ writer,
67
+ stream: (type, data) => {
68
+ writeTransient(writer, type, data);
69
+ },
70
+ };
71
+ return originalExecute(input, enhancedContext);
72
+ },
73
+ };
74
+ }
75
+ // ============================================================================
76
+ // Transient Data Writers
77
+ // ============================================================================
78
+ /**
79
+ * Stream typed transient data to the UI.
80
+ *
81
+ * @param writer - Stream writer instance
82
+ * @param type - Data part type
83
+ * @param data - Data to stream
84
+ */
85
+ export function writeTransient(writer, type, data) {
86
+ const dataPart = {
87
+ type,
88
+ data,
89
+ };
90
+ writer.writeData({
91
+ ...dataPart,
92
+ transient: true,
93
+ });
94
+ }
95
+ /**
96
+ * Helper for tools to stream transient data from within their execute function.
97
+ *
98
+ * @param ctx - Tool context (must have writer)
99
+ * @param type - Data part type
100
+ * @param data - Data to stream
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // Inside a tool's execute function:
105
+ * streamTransient(ctx, 'shell-output', {
106
+ * command: 'npm test',
107
+ * output: result.stdout,
108
+ * exitCode: result.code,
109
+ * });
110
+ * ```
111
+ */
112
+ export function streamTransient(ctx, type, data) {
113
+ // Cast to TransientStreamWriter - they have compatible interfaces
114
+ const writer = ctx.writer;
115
+ if (writer) {
116
+ writeTransient(writer, type, data);
117
+ }
118
+ }
119
+ // ============================================================================
120
+ // Specialized Streamers
121
+ // ============================================================================
122
+ /**
123
+ * Stream file content transiently.
124
+ */
125
+ export function streamFileContent(ctx, path, content, options = {}) {
126
+ streamTransient(ctx, 'file-content', {
127
+ path,
128
+ content,
129
+ truncated: options.truncated ?? false,
130
+ totalBytes: options.totalBytes,
131
+ language: options.language,
132
+ lineRange: options.lineRange,
133
+ });
134
+ }
135
+ /**
136
+ * Stream shell output transiently.
137
+ */
138
+ export function streamShellOutput(ctx, command, output, exitCode, options = {}) {
139
+ streamTransient(ctx, 'shell-output', {
140
+ command,
141
+ output,
142
+ exitCode,
143
+ cwd: options.cwd,
144
+ truncated: options.truncated,
145
+ durationMs: options.durationMs,
146
+ });
147
+ }
148
+ /**
149
+ * Stream search results transiently.
150
+ */
151
+ export function streamSearchResult(ctx, path, content, matches, options = {}) {
152
+ streamTransient(ctx, 'search-result', {
153
+ path,
154
+ content,
155
+ matches,
156
+ line: options.line,
157
+ pattern: options.pattern,
158
+ });
159
+ }
160
+ /**
161
+ * Stream tool progress update transiently.
162
+ */
163
+ export function streamProgress(ctx, toolName, progress, message, options = {}) {
164
+ streamTransient(ctx, 'tool-progress', {
165
+ toolName,
166
+ progress,
167
+ message,
168
+ estimatedRemaining: options.estimatedRemaining,
169
+ step: options.step,
170
+ });
171
+ }
172
+ /**
173
+ * Stream reasoning step transiently.
174
+ *
175
+ * @internal Forward-designed for CLI streaming feature. No production callers yet.
176
+ */
177
+ export function streamReasoningStep(ctx, stepNumber, totalSteps, thought, options = {}) {
178
+ streamTransient(ctx, 'reasoning-step', {
179
+ stepNumber,
180
+ totalSteps,
181
+ thought,
182
+ isRevision: options.isRevision,
183
+ revisesThought: options.revisesThought,
184
+ branchId: options.branchId,
185
+ });
186
+ }
187
+ /**
188
+ * Stream sub-agent output transiently.
189
+ *
190
+ * @internal Forward-designed for CLI streaming feature. No production callers yet.
191
+ */
192
+ export function streamSubAgent(ctx, agentId, role, text, status, error) {
193
+ streamTransient(ctx, 'sub-agent-stream', {
194
+ agentId,
195
+ role,
196
+ text,
197
+ status,
198
+ error,
199
+ });
200
+ }
201
+ //# sourceMappingURL=transient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transient.js","sourceRoot":"","sources":["../../src/strea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J,IAAI;QACJ,MAAM;QACN,KAAK;KACN,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @agntk/core - Tool Approval System
3
+ *
4
+ * Wraps tools with AI SDK's native `needsApproval` flag for human-in-the-loop
5
+ * safety. When `approval: true` is set on the agent, dangerous tools
6
+ * (shell, browser, file_write, file_edit) automatically require approval.
7
+ *
8
+ * Supports:
9
+ * - Auto-flagging dangerous tools
10
+ * - Typed approval payloads via Zod schemas
11
+ * - Timeout with default values (approve/deny after N ms)
12
+ * - Custom approval handlers
13
+ */
14
+ import type { Tool, ToolSet } from 'ai';
15
+ /** Configuration for the approval system. */
16
+ export interface ApprovalConfig {
17
+ /** Enable approval for dangerous tools. Default: false */
18
+ enabled: boolean;
19
+ /** Tool names that require approval. If not set, uses DANGEROUS_TOOLS. */
20
+ tools?: string[];
21
+ /** Default timeout in ms before auto-resolution. Default: none (wait forever) */
22
+ timeout?: number;
23
+ /** Default action when timeout expires. Default: 'deny' */
24
+ timeoutAction?: 'approve' | 'deny';
25
+ /** Custom handler called when a tool needs approval.
26
+ * Return true to approve, false to deny.
27
+ * If not provided, uses the AI SDK's built-in approval mechanism. */
28
+ handler?: ApprovalHandler;
29
+ }
30
+ /** Custom approval handler function. */
31
+ export type ApprovalHandler = (request: ApprovalRequest) => Promise<boolean> | boolean;
32
+ /** Details about a tool call requiring approval. */
33
+ export interface ApprovalRequest {
34
+ toolName: string;
35
+ input: unknown;
36
+ toolCallId: string;
37
+ }
38
+ /** Default set of tool names considered dangerous and requiring approval. */
39
+ export declare const DANGEROUS_TOOLS: Set<string>;
40
+ /**
41
+ * Check if a tool name is considered dangerous.
42
+ */
43
+ export declare function isDangerousTool(toolName: string, customList?: string[]): boolean;
44
+ /**
45
+ * Wrap a single tool with `needsApproval`, applying timeout + default action
46
+ * if configured.
47
+ */
48
+ export declare function wrapToolWithApproval<T extends Tool>(toolName: string, tool: T, config: ApprovalConfig): T;
49
+ /**
50
+ * Apply approval to all dangerous tools in a toolset.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const tools = createToolPreset('standard', { workspaceRoot });
55
+ * const approvedTools = applyApproval(tools, { enabled: true });
56
+ * ```
57
+ */
58
+ export declare function applyApproval(tools: ToolSet, config: ApprovalConfig): ToolSet;
59
+ /**
60
+ * Create an approval config from agent options shorthand.
61
+ *
62
+ * Supports:
63
+ * - `approval: true` → enable with defaults
64
+ * - `approval: { tools: [...], timeout: 30000 }` → custom config
65
+ */
66
+ export declare function resolveApprovalConfig(input: boolean | ApprovalConfig | undefined): ApprovalConfig | undefined;
67
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/tools/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AASxC,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC;IAEjB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAEnC;;yEAEqE;IACrE,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEvF,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,6EAA6E;AAC7E,eAAO,MAAM,eAAe,aAM1B,CAAC;AAMH;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAKhF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,IAAI,EACjD,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,cAAc,GACrB,CAAC,CAoCH;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,cAAc,GACrB,OAAO,CAgBT;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,GAC1C,cAAc,GAAG,SAAS,CAI5B"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @agntk/core - Tool Approval System
3
+ *
4
+ * Wraps tools with AI SDK's native `needsApproval` flag for human-in-the-loop
5
+ * safety. When `approval: true` is set on the agent, dangerous tools
6
+ * (shell, browser, file_write, file_edit) automatically require approval.
7
+ *
8
+ * Supports:
9
+ * - Auto-flagging dangerous tools
10
+ * - Typed approval payloads via Zod schemas
11
+ * - Timeout with default values (approve/deny after N ms)
12
+ * - Custom approval handlers
13
+ */
14
+ import { createLogger } from '@agntk/logger';
15
+ const log = createLogger('@agntk/core:approval');
16
+ // ============================================================================
17
+ // Constants
18
+ // ============================================================================
19
+ /** Default set of tool names considered dangerous and requiring approval. */
20
+ export const DANGEROUS_TOOLS = new Set([
21
+ 'shell',
22
+ 'browser',
23
+ 'file_write',
24
+ 'file_edit',
25
+ 'file_create',
26
+ ]);
27
+ // ============================================================================
28
+ // Core Functions
29
+ // ============================================================================
30
+ /**
31
+ * Check if a tool name is considered dangerous.
32
+ */
33
+ export function isDangerousTool(toolName, customList) {
34
+ if (customList) {
35
+ return customList.includes(toolName);
36
+ }
37
+ return DANGEROUS_TOOLS.has(toolName);
38
+ }
39
+ /**
40
+ * Wrap a single tool with `needsApproval`, applying timeout + default action
41
+ * if configured.
42
+ */
43
+ export function wrapToolWithApproval(toolName, tool, config) {
44
+ const { handler, timeout, timeoutAction = 'deny' } = config;
45
+ if (handler) {
46
+ // Use a custom handler via needsApproval function
47
+ const wrappedTool = {
48
+ ...tool,
49
+ needsApproval: async (input) => {
50
+ const request = {
51
+ toolName,
52
+ input,
53
+ toolCallId: `approval-${Date.now()}`,
54
+ };
55
+ if (timeout) {
56
+ // Race handler against timeout
57
+ const result = await Promise.race([
58
+ handler(request),
59
+ new Promise((resolve) => setTimeout(() => {
60
+ log.warn('Approval timed out', { toolName, timeout, action: timeoutAction });
61
+ resolve(timeoutAction === 'approve');
62
+ }, timeout)),
63
+ ]);
64
+ return result;
65
+ }
66
+ return handler(request);
67
+ },
68
+ };
69
+ return wrappedTool;
70
+ }
71
+ // Use simple boolean flag — the AI SDK will handle the approval UI
72
+ return { ...tool, needsApproval: true };
73
+ }
74
+ /**
75
+ * Apply approval to all dangerous tools in a toolset.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const tools = createToolPreset('standard', { workspaceRoot });
80
+ * const approvedTools = applyApproval(tools, { enabled: true });
81
+ * ```
82
+ */
83
+ export function applyApproval(tools, config) {
84
+ if (!config.enabled)
85
+ return tools;
86
+ const result = {};
87
+ const dangerousList = config.tools;
88
+ for (const [name, tool] of Object.entries(tools)) {
89
+ if (isDangerousTool(name, dangerousList)) {
90
+ log.debug('Applying approval to tool', { tool: name });
91
+ result[name] = wrapToolWithApproval(name, tool, config);
92
+ }
93
+ else {
94
+ result[name] = tool;
95
+ }
96
+ }
97
+ return result;
98
+ }
99
+ /**
100
+ * Create an approval config from agent options shorthand.
101
+ *
102
+ * Supports:
103
+ * - `approval: true` → enable with defaults
104
+ * - `approval: { tools: [...], timeout: 30000 }` → custom config
105
+ */
106
+ export function resolveApprovalConfig(input) {
107
+ if (!input)
108
+ return undefined;
109
+ if (input === true)
110
+ return { enabled: true };
111
+ return input;
112
+ }
113
+ //# sourceMappingURL=approval.js.map
@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AACH,MAAM,UAAU,qBAAqB,CACnC,KAA2C;IAE3C,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { SgResult, CliLanguage } from './types.js';
2
+ export interface RunOptions {
3
+ pattern: string;
4
+ lang: CliLanguage;
5
+ paths?: string[];
6
+ globs?: string[];
7
+ rewrite?: string;
8
+ context?: number;
9
+ updateAll?: boolean;
10
+ }
11
+ export declare function getAstGrepPath(): Promise<string | null>;
12
+ export declare function startBackgroundInit(): void;
13
+ export declare function runSg(options: RunOptions): Promise<SgResult>;
14
+ export declare function isCliAvailable(): boolean;
15
+ export declare function ensureCliAvailable(): Promise<boolean>;
16
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/tools/ast-grep/cli.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAY,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAKD,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4B7D;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8KlE;AAED,wBAAgB,cAAc,IAAI,OAAO,CAGxC;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG3D"}