@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,187 @@
1
+ /**
2
+ * @agntk/core - System Context Builder
3
+ * Builds dynamic context information for agent system prompts
4
+ */
5
+ import { createLogger } from '@agntk/logger';
6
+ import { GEOLOCATION_API_URL, GEOLOCATION_ENABLED_DEFAULT } from '../constants.js';
7
+ const log = createLogger('@agntk/core:context');
8
+ // ============================================================================
9
+ // Runtime Detection
10
+ // ============================================================================
11
+ const isNode = typeof process !== 'undefined' && process.versions?.node;
12
+ async function getNodeInfo() {
13
+ if (!isNode) {
14
+ return {
15
+ platform: 'browser',
16
+ hostname: 'browser',
17
+ username: 'user',
18
+ };
19
+ }
20
+ const os = await import('node:os');
21
+ return {
22
+ platform: os.platform(),
23
+ hostname: os.hostname(),
24
+ username: os.userInfo().username,
25
+ };
26
+ }
27
+ function getLocale() {
28
+ if (typeof Intl !== 'undefined') {
29
+ return Intl.DateTimeFormat().resolvedOptions().locale;
30
+ }
31
+ return 'en-US';
32
+ }
33
+ // ============================================================================
34
+ // Location (Optional)
35
+ // ============================================================================
36
+ async function fetchUserLocation() {
37
+ try {
38
+ const response = await fetch(GEOLOCATION_API_URL);
39
+ if (!response.ok)
40
+ return undefined;
41
+ const data = await response.json();
42
+ return {
43
+ city: data.city,
44
+ region: data.regionName,
45
+ country: data.country,
46
+ countryCode: data.countryCode,
47
+ timezone: data.timezone,
48
+ };
49
+ }
50
+ catch {
51
+ return undefined;
52
+ }
53
+ }
54
+ // ============================================================================
55
+ // Workspace Map
56
+ // ============================================================================
57
+ async function generateWorkspaceMap(workspaceRoot) {
58
+ if (!isNode)
59
+ return '';
60
+ try {
61
+ const fs = await import('node:fs');
62
+ const path = await import('node:path');
63
+ if (!fs.existsSync(workspaceRoot))
64
+ return '';
65
+ const entries = fs.readdirSync(workspaceRoot);
66
+ const topLevel = entries
67
+ .filter(e => !e.startsWith('.'))
68
+ .slice(0, 20)
69
+ .map(e => {
70
+ const fullPath = path.join(workspaceRoot, e);
71
+ const isDir = fs.statSync(fullPath).isDirectory();
72
+ if (isDir) {
73
+ const children = fs.readdirSync(fullPath).filter(c => !c.startsWith('.')).slice(0, 5);
74
+ return `${e}/: ${children.join(', ')}${children.length >= 5 ? '...' : ''}`;
75
+ }
76
+ return e;
77
+ });
78
+ return topLevel.join('\n');
79
+ }
80
+ catch {
81
+ return '';
82
+ }
83
+ }
84
+ // ============================================================================
85
+ // Context Builder
86
+ // ============================================================================
87
+ export async function buildSystemContext(options = {}) {
88
+ const { workspaceRoot, includeWorkspaceMap = false, userLocation, userPreferences, fetchLocation = GEOLOCATION_ENABLED_DEFAULT, } = options;
89
+ const now = new Date();
90
+ const nodeInfo = await getNodeInfo();
91
+ // Optionally fetch location
92
+ let location = userLocation;
93
+ if (!location && fetchLocation) {
94
+ location = await fetchUserLocation();
95
+ }
96
+ const preferences = userPreferences;
97
+ const context = {
98
+ currentTime: now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true }),
99
+ currentDate: now.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }),
100
+ timezone: location?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
101
+ platform: nodeInfo.platform,
102
+ hostname: nodeInfo.hostname,
103
+ username: nodeInfo.username,
104
+ locale: getLocale(),
105
+ workspaceRoot,
106
+ userLocation: location,
107
+ userPreferences: preferences,
108
+ };
109
+ if (includeWorkspaceMap && workspaceRoot) {
110
+ context.workspaceMap = await generateWorkspaceMap(workspaceRoot);
111
+ }
112
+ return context;
113
+ }
114
+ // ============================================================================
115
+ // Formatting
116
+ // ============================================================================
117
+ export function formatSystemContextBlock(context) {
118
+ const lines = [
119
+ '# Current Environment',
120
+ '',
121
+ `- **Date**: ${context.currentDate}`,
122
+ `- **Time**: ${context.currentTime} (${context.timezone})`,
123
+ `- **Locale**: ${context.locale}`,
124
+ `- **Platform**: ${context.platform}`,
125
+ `- **User**: ${context.username}`,
126
+ ];
127
+ // Location
128
+ if (context.userLocation) {
129
+ const loc = context.userLocation;
130
+ const locationParts = [loc.city, loc.region, loc.country].filter(Boolean);
131
+ if (locationParts.length > 0) {
132
+ lines.push(`- **Location**: ${locationParts.join(', ')}`);
133
+ }
134
+ }
135
+ // Workspace
136
+ if (context.workspaceRoot) {
137
+ lines.push(`- **Workspace**: ${context.workspaceRoot}`);
138
+ }
139
+ if (context.workspaceMap) {
140
+ lines.push('');
141
+ lines.push('## Workspace Structure');
142
+ lines.push('```');
143
+ lines.push(context.workspaceMap);
144
+ lines.push('```');
145
+ }
146
+ // User Preferences
147
+ if (context.userPreferences) {
148
+ const prefs = context.userPreferences;
149
+ lines.push('');
150
+ lines.push('## User Preferences');
151
+ if (prefs.name)
152
+ lines.push(`- **Name**: ${prefs.name}`);
153
+ if (prefs.language)
154
+ lines.push(`- **Preferred Language**: ${prefs.language}`);
155
+ if (prefs.communicationStyle)
156
+ lines.push(`- **Communication Style**: ${prefs.communicationStyle}`);
157
+ if (prefs.codeStyle) {
158
+ lines.push('- **Code Style**:');
159
+ if (prefs.codeStyle.indentation)
160
+ lines.push(` - Indentation: ${prefs.codeStyle.indentation}`);
161
+ if (prefs.codeStyle.indentSize)
162
+ lines.push(` - Indent Size: ${prefs.codeStyle.indentSize}`);
163
+ if (prefs.codeStyle.quoteStyle)
164
+ lines.push(` - Quote Style: ${prefs.codeStyle.quoteStyle}`);
165
+ }
166
+ if (prefs.customPreferences && Object.keys(prefs.customPreferences).length > 0) {
167
+ for (const [key, value] of Object.entries(prefs.customPreferences)) {
168
+ lines.push(`- **${key}**: ${String(value)}`);
169
+ }
170
+ }
171
+ }
172
+ // Appended profile block (from memory system)
173
+ if (context.userProfileBlock) {
174
+ lines.push('');
175
+ lines.push(context.userProfileBlock);
176
+ }
177
+ return lines.join('\n');
178
+ }
179
+ // ============================================================================
180
+ // Convenience Function
181
+ // ============================================================================
182
+ export async function buildDynamicSystemPrompt(basePrompt, options = {}) {
183
+ const context = await buildSystemContext(options);
184
+ const contextBlock = formatSystemContextBlock(context);
185
+ return `${basePrompt}\n\n${contextBlock}`;
186
+ }
187
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/prompts/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhF,MAAM,GAAG,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AA2DhD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;AAExE,KAAK,UAAU,WAAW;IACxB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,QAAQ,EAAE,SAAS;YACnB,QA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G,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACnE,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,UAAkB,EAClB,UAA0B,EAAE;IAE5B,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO,GAAG,UAAU,OAAO,YAAY,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @fileoverview Template engine for variable substitution in prompts.
3
+ */
4
+ interface TemplateContext {
5
+ [key: string]: string | number | boolean | undefined;
6
+ }
7
+ /**
8
+ * Apply template variables to a string.
9
+ * Replaces {{variableName}} with the value from context.
10
+ *
11
+ * @example
12
+ * applyTemplate('Hello {{name}}!', { name: 'World' })
13
+ * // => 'Hello World!'
14
+ */
15
+ export declare function applyTemplate(template: string, context?: TemplateContext): string;
16
+ export {};
17
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,UAAU,eAAe;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAMD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,CAcrF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview Template engine for variable substitution in prompts.
3
+ */
4
+ import { createLogger } from '@agntk/logger';
5
+ import { getConfig } from '../config/index.js';
6
+ const log = createLogger('@agntk/core:templates');
7
+ // ============================================================================
8
+ // Template Engine
9
+ // ============================================================================
10
+ /**
11
+ * Apply template variables to a string.
12
+ * Replaces {{variableName}} with the value from context.
13
+ *
14
+ * @example
15
+ * applyTemplate('Hello {{name}}!', { name: 'World' })
16
+ * // => 'Hello World!'
17
+ */
18
+ export function applyTemplate(template, context = {}) {
19
+ // Merge config variables with explicit context (explicit takes precedence)
20
+ const config = getConfig();
21
+ const configVars = config.templates;
22
+ const mergedContext = { ...configVars?.variables, ...context };
23
+ return template.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
24
+ const value = mergedContext[varName];
25
+ if (value === undefined) {
26
+ log.debug('Template variable not found', { variable: varName });
27
+ return match; // Leave unreplaced if not found
28
+ }
29
+ return String(value);
30
+ });
31
+ }
32
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,GAAG,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAUlD,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,UAA2B,EAAE;IAC3E,2EAA2E;IAC3E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAI,MAAkC,CAAC,SAAwD,CAAC;IAChH,MAAM,aAAa,GAAG,EAAE,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;IAE/D,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3D,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,GAAG,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAChE,OAAO,KAAK,CAAC,CAAC,gCAAgC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @agntk/core - System Prompt Templates
3
+ * Core system prompts for agent behavior
4
+ *
5
+ * @deprecated Use `presets/role-registry.ts` instead. That module is the canonical
6
+ * source of truth for role prompts, used by `createAgent()` via `getRole()`.
7
+ * This file is kept for backward compatibility of public exports only.
8
+ */
9
+ export declare const systemPrompt = "You are an autonomous agent. Your purpose is to accomplish the user's goal using whatever approach makes sense.\n\n# Philosophy\n\nYou have a mind and you have tools. Tools extend your thinking - use them fluidly as part of reasoning, not as separate mechanical steps.\n\nThere is no single correct workflow. Match your approach to the problem:\n- Reason through it, gather information, reason more, then act\n- Act immediately if the path is obvious\n- Start one approach, realize it's wrong, switch to another\n- Call multiple tools in parallel when they don't depend on each other\n\nWhen something doesn't work, adapt. When you need information, go get it. When uncertain, reason carefully. When clear, act directly.\n\nWhen errors occur, read them carefully. The error message usually points to the fix.\n\n# Action\n\nDo things, don't announce them. Instead of \"I'll search for X\", just search.\n\nBe autonomous. Complete tasks without asking permission at every step. Only ask the user when you genuinely need information only they can provide.\n\n# Thinking Out Loud\n\nBefore each action, briefly state:\n- **Goal**: What am I trying to accomplish?\n- **Approach**: Why is this the right tool/action?\n- **Risk**: What could go wrong?\n\nKeep it concise (1-2 sentences each). This helps the user understand your decisions.\n\n# Efficiency\n\nComplete tasks in the fewest steps possible:\n- Think first: What's the most direct path to the goal?\n- Use the right tool: Each tool's description explains when to use it\n- Chain when independent: Call multiple tools in parallel when they don't depend on each other\n- No random exploration: Every action should have a purpose\n\n# Tools\n\nYou have access to consolidated tools with multiple actions. Use the action parameter to specify what to do:\n\n**fs** - All file operations (read, write, edit, list, glob, grep, move, delete, info, mkdir)\n**shell** - Execute shell commands (with allowlisting for repeated commands)\n**web** - Search the internet (search) or fetch page content (fetch)\n**memory** - Knowledge graph operations (add, search, episodes, fact, entity, related)\n\n**delegate** - Parallel work: tool chains (steps), sub-agents (agent), or background processes (background)\n**task** - Manage background tasks (status, output, cancel, list, cleanup)\n\nAdditional tools: plan, ask_user, task_complete\n\nEach tool's description provides detailed guidance on when and how to use it. Read the descriptions to understand capabilities and constraints.\n\n# Delegation\n\nFor complex work, use the delegate tool:\n- **steps**: Execute multiple tool calls in sequence with dependency handling\n- **agent**: Spawn a specialized sub-agent (coder/researcher/analyst)\n- **background**: Start a long-running shell command\n\nAfter delegating, use the task tool to monitor progress and retrieve output.\n\n# Completion\n\nCall task_complete when you have fully accomplished what the user asked for.\n\nOnly call task_complete when truly done - not planned, not partially done, but actually complete.\n";
10
+ export declare const rolePrompts: Record<string, string>;
11
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,+/FAqExB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsC9C,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @agntk/core - System Prompt Templates
3
+ * Core system prompts for agent behavior
4
+ *
5
+ * @deprecated Use `presets/role-registry.ts` instead. That module is the canonical
6
+ * source of truth for role prompts, used by `createAgent()` via `getRole()`.
7
+ * This file is kept for backward compatibility of public exports only.
8
+ */
9
+ export const systemPrompt = `You are an autonomous agent. Your purpose is to accomplish the user's goal using whatever approach makes sense.
10
+
11
+ # Philosophy
12
+
13
+ You have a mind and you have tools. Tools extend your thinking - use them fluidly as part of reasoning, not as separate mechanical steps.
14
+
15
+ There is no single correct workflow. Match your approach to the problem:
16
+ - Reason through it, gather information, reason more, then act
17
+ - Act immediately if the path is obvious
18
+ - Start one approach, realize it's wrong, switch to another
19
+ - Call multiple tools in parallel when they don't depend on each other
20
+
21
+ When something doesn't work, adapt. When you need information, go get it. When uncertain, reason carefully. When clear, act directly.
22
+
23
+ When errors occur, read them carefully. The error message usually points to the fix.
24
+
25
+ # Action
26
+
27
+ Do things, don't announce them. Instead of "I'll search for X", just search.
28
+
29
+ Be autonomous. Complete tasks without asking permission at every step. Only ask the user when you genuinely need information only they can provide.
30
+
31
+ # Thinking Out Loud
32
+
33
+ Before each action, briefly state:
34
+ - **Goal**: What am I trying to accomplish?
35
+ - **Approach**: Why is this the right tool/action?
36
+ - **Risk**: What could go wrong?
37
+
38
+ Keep it concise (1-2 sentences each). This helps the user understand your decisions.
39
+
40
+ # Efficiency
41
+
42
+ Complete tasks in the fewest steps possible:
43
+ - Think first: What's the most direct path to the goal?
44
+ - Use the right tool: Each tool's description explains when to use it
45
+ - Chain when independent: Call multiple tools in parallel when they don't depend on each other
46
+ - No random exploration: Every action should have a purpose
47
+
48
+ # Tools
49
+
50
+ You have access to consolidated tools with multiple actions. Use the action parameter to specify what to do:
51
+
52
+ **fs** - All file operations (read, write, edit, list, glob, grep, move, delete, info, mkdir)
53
+ **shell** - Execute shell commands (with allowlisting for repeated commands)
54
+ **web** - Search the internet (search) or fetch page content (fetch)
55
+ **memory** - Knowledge graph operations (add, search, episodes, fact, entity, related)
56
+
57
+ **delegate** - Parallel work: tool chains (steps), sub-agents (agent), or background processes (background)
58
+ **task** - Manage background tasks (status, output, cancel, list, cleanup)
59
+
60
+ Additional tools: plan, ask_user, task_complete
61
+
62
+ Each tool's description provides detailed guidance on when and how to use it. Read the descriptions to understand capabilities and constraints.
63
+
64
+ # Delegation
65
+
66
+ For complex work, use the delegate tool:
67
+ - **steps**: Execute multiple tool calls in sequence with dependency handling
68
+ - **agent**: Spawn a specialized sub-agent (coder/researcher/analyst)
69
+ - **background**: Start a long-running shell command
70
+
71
+ After delegating, use the task tool to monitor progress and retrieve output.
72
+
73
+ # Completion
74
+
75
+ Call task_complete when you have fully accomplished what the user asked for.
76
+
77
+ Only call task_complete when truly done - not planned, not partially done, but actually complete.
78
+ `;
79
+ export const rolePrompts = {
80
+ generic: systemPrompt,
81
+ coder: `${systemPrompt}
82
+
83
+ # Specialized Role: Code Implementation
84
+
85
+ You are a code implementation specialist. Your focus areas:
86
+ - Writing clean, maintainable code
87
+ - Following existing patterns in the codebase
88
+ - Making minimal, targeted changes
89
+ - Running tests to verify your changes work
90
+
91
+ Always read relevant code before making changes. Match the existing style.`,
92
+ researcher: `${systemPrompt}
93
+
94
+ # Specialized Role: Research
95
+
96
+ You are a research specialist. Your focus areas:
97
+ - Gathering comprehensive information on topics
98
+ - Evaluating source credibility
99
+ - Synthesizing findings into clear summaries
100
+ - Identifying key insights and patterns
101
+
102
+ Be thorough but efficient. Focus on actionable information.`,
103
+ analyst: `${systemPrompt}
104
+
105
+ # Specialized Role: Analysis
106
+
107
+ You are an analysis specialist. Your focus areas:
108
+ - Breaking down complex problems
109
+ - Identifying patterns and relationships
110
+ - Evaluating trade-offs and options
111
+ - Providing data-driven recommendations
112
+
113
+ Be systematic and logical. Support conclusions with evidence.`,
114
+ };
115
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqE3B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,OAAO,EAAE,YAAY;IAErB,KAAK,EAAE,GAAG,YAAY;;;;;;;;;;2EAUmD;IAEzE,UAAU,EAAE,GAAG,YAAY;;;;;;;;;;4DAU+B;IAE1D,OAAO,EAAE,GAAG,YAAY;;;;;;;;;;8DAUoC;CAC7D,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @agntk/core - Reflection Strategies
3
+ *
4
+ * Implements reflection strategies that inject goal-state prompts between
5
+ * agent steps, improving multi-step task completion (+27.7% success in research).
6
+ *
7
+ * Uses the AI SDK's `prepareStep` hook to augment the system prompt with
8
+ * reflection instructions — no extra LLM calls required.
9
+ */
10
+ import type { Tool, StepResult } from 'ai';
11
+ /** Available reflection strategies. */
12
+ export type ReflectionStrategy = 'none' | 'reflact' | 'periodic';
13
+ /** Configuration for the reflection system. */
14
+ export interface ReflectionConfig {
15
+ /** Which strategy to use. Default: 'none' */
16
+ strategy: ReflectionStrategy;
17
+ /** For 'periodic' strategy: reflect every N steps. Default: 3 */
18
+ frequency?: number;
19
+ /** Custom reflection prompt template. Uses {goal} placeholder. */
20
+ promptTemplate?: string;
21
+ }
22
+ /** Input to the prepareStep hook from the AI SDK. */
23
+ export interface PrepareStepInput<TOOLS extends Record<string, Tool> = Record<string, Tool>> {
24
+ steps: Array<StepResult<TOOLS>>;
25
+ stepNumber: number;
26
+ }
27
+ /**
28
+ * Build a reflection prompt for the given step, or return undefined if
29
+ * no reflection should be injected at this step.
30
+ */
31
+ export declare function buildReflectionPrompt(config: ReflectionConfig, stepNumber: number): string | undefined;
32
+ /**
33
+ * Create a `prepareStep` function for the AI SDK that injects reflection
34
+ * prompts into the system message at appropriate steps.
35
+ *
36
+ * @param baseSystem - The original system prompt to augment.
37
+ * @param config - The reflection configuration.
38
+ * @returns A prepareStep function compatible with AI SDK's ToolLoopAgent.
39
+ */
40
+ export declare function createReflectionPrepareStep<TOOLS extends Record<string, Tool> = Record<string, Tool>>(baseSystem: string, config: ReflectionConfig): (input: PrepareStepInput<TOOLS>) => {
41
+ system?: string;
42
+ } | undefined;
43
+ /**
44
+ * Estimate the token overhead of a reflection injection.
45
+ * Rough estimate: ~4 chars per token for English text.
46
+ */
47
+ export declare function estimateReflectionTokens(config: ReflectionConfig): number;
48
+ //# sourceMappingURL=reflection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflection.d.ts","sourceRoot":"","sources":["../src/reflection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAM3C,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,EAAE,kBAAkB,CAAC;IAE7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IACzF,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AA4BD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACnG,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,GACvB,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAerE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAQzE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @agntk/core - Reflection Strategies
3
+ *
4
+ * Implements reflection strategies that inject goal-state prompts between
5
+ * agent steps, improving multi-step task completion (+27.7% success in research).
6
+ *
7
+ * Uses the AI SDK's `prepareStep` hook to augment the system prompt with
8
+ * reflection instructions — no extra LLM calls required.
9
+ */
10
+ // ============================================================================
11
+ // Defaults
12
+ // ============================================================================
13
+ const DEFAULT_FREQUENCY = 3;
14
+ const DEFAULT_REFLACT_TEMPLATE = `<reflection>
15
+ Before proceeding, reflect on your progress:
16
+ 1. What is the user's original goal?
17
+ 2. What have you accomplished so far?
18
+ 3. What is the most important next action to take?
19
+ 4. Are you on track, or do you need to adjust your approach?
20
+ </reflection>`;
21
+ const DEFAULT_PERIODIC_TEMPLATE = `<reflection>
22
+ Checkpoint — pause and evaluate:
23
+ 1. Revisit the user's original request. Are you still aligned with their goal?
24
+ 2. Summarize what you have done so far.
25
+ 3. Identify any dead ends or wasted steps.
26
+ 4. Plan your next 2-3 actions to reach completion efficiently.
27
+ </reflection>`;
28
+ // ============================================================================
29
+ // Reflection Builder
30
+ // ============================================================================
31
+ /**
32
+ * Build a reflection prompt for the given step, or return undefined if
33
+ * no reflection should be injected at this step.
34
+ */
35
+ export function buildReflectionPrompt(config, stepNumber) {
36
+ const { strategy } = config;
37
+ if (strategy === 'none') {
38
+ return undefined;
39
+ }
40
+ if (strategy === 'reflact') {
41
+ // reflact: inject after every step except the first (step 0 = initial call)
42
+ if (stepNumber === 0)
43
+ return undefined;
44
+ return config.promptTemplate ?? DEFAULT_REFLACT_TEMPLATE;
45
+ }
46
+ if (strategy === 'periodic') {
47
+ const frequency = config.frequency ?? DEFAULT_FREQUENCY;
48
+ // Inject at step N, 2N, 3N... (never step 0)
49
+ if (stepNumber === 0 || stepNumber % frequency !== 0)
50
+ return undefined;
51
+ return config.promptTemplate ?? DEFAULT_PERIODIC_TEMPLATE;
52
+ }
53
+ return undefined;
54
+ }
55
+ /**
56
+ * Create a `prepareStep` function for the AI SDK that injects reflection
57
+ * prompts into the system message at appropriate steps.
58
+ *
59
+ * @param baseSystem - The original system prompt to augment.
60
+ * @param config - The reflection configuration.
61
+ * @returns A prepareStep function compatible with AI SDK's ToolLoopAgent.
62
+ */
63
+ export function createReflectionPrepareStep(baseSystem, config) {
64
+ // If no reflection, return a no-op
65
+ if (config.strategy === 'none') {
66
+ return () => undefined;
67
+ }
68
+ return ({ stepNumber }) => {
69
+ const reflection = buildReflectionPrompt(config, stepNumber);
70
+ if (!reflection)
71
+ return undefined;
72
+ // Augment the system prompt with the reflection block
73
+ return {
74
+ system: `${baseSystem}\n\n${reflection}`,
75
+ };
76
+ };
77
+ }
78
+ /**
79
+ * Estimate the token overhead of a reflection injection.
80
+ * Rough estimate: ~4 chars per token for English text.
81
+ */
82
+ export function estimateReflectionTokens(config) {
83
+ const template = config.strategy === 'reflact'
84
+ ? (config.promptTemplate ?? DEFAULT_REFLACT_TEMPLATE)
85
+ : config.strategy === 'periodic'
86
+ ? (config.promptTemplate ?? DEFAULT_PERIODIC_TEMPLATE)
87
+ : '';
88
+ // ~4 chars per token, rough estimate
89
+ return Math.ceil(template.length / 4);
90
+ }
91
+ //# sourceMappingURL=reflection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflection.js","sourceRoot":"","sources":["../src/reflection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6BH,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/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ACtD,OAAO;YACL,MAAM,EAAE,GAAG,UAAU,OAAO,UAAU,EAAE;SACzC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAwB;IAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC5C,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,IAAI,wBAAwB,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,UAAU;YAChC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,IAAI,yBAAyB,CAAC;YACtD,CAAC,CAAC,EAAE,CAAC;IACP,qCAAqC;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Skills module public API.
3
+ */
4
+ export type { SkillMeta, SkillContent, SkillsConfig, SkillRequirements } from './types.js';
5
+ export { type ParsedSkillFrontmatter, type SkillSearchResult, discoverSkills, loadSkillContent, loadSkills, loadSkillsFromPaths, parseSkillFrontmatter, buildSkillsSystemPrompt, searchSkills, filterEligibleSkills, isSkillEligible, } from './loader.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @fileoverview Skills module public API.
3
+ */
4
+ export { discoverSkills, loadSkillContent, loadSkills, loadSkillsFromPaths, parseSkillFrontmatter, buildSkillsSystemPrompt, searchSkills, filterEligibleSkills, isSkillEligible, } from './loader.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @fileoverview Skills discovery and loading.
3
+ * Scans directories for SKILL.md files, parses YAML frontmatter,
4
+ * and builds system prompt injections.
5
+ */
6
+ import type { SkillMeta, SkillContent, SkillsConfig, SkillRequirements } from './types.js';
7
+ export interface ParsedSkillFrontmatter {
8
+ name?: string;
9
+ description?: string;
10
+ tags?: string[];
11
+ whenToUse?: string;
12
+ model?: 'fast' | 'standard' | 'reasoning' | 'powerful';
13
+ maxSteps?: number;
14
+ requires?: SkillRequirements;
15
+ license?: string;
16
+ compatibility?: string;
17
+ metadata?: Record<string, string>;
18
+ allowedTools?: string[];
19
+ toolsDeny?: string[];
20
+ extra?: Record<string, unknown>;
21
+ body: string;
22
+ }
23
+ /**
24
+ * Parse YAML frontmatter from a SKILL.md file.
25
+ * Accepts both native and skills.sh fields. Unknown fields are preserved in `extra`.
26
+ *
27
+ * Expects format:
28
+ * ---
29
+ * name: skill-name
30
+ * description: Short description
31
+ * license: MIT
32
+ * allowed-tools: [glob, grep, shell]
33
+ * ---
34
+ * ... markdown content ...
35
+ */
36
+ export declare function parseSkillFrontmatter(content: string): ParsedSkillFrontmatter;
37
+ /**
38
+ * Discover SKILL.md files in the given directories.
39
+ * Returns metadata for each discovered skill.
40
+ */
41
+ export declare function discoverSkills(directories?: string[], basePath?: string): SkillMeta[];
42
+ /**
43
+ * Load the full content of a skill, including the markdown body.
44
+ */
45
+ export declare function loadSkillContent(meta: SkillMeta): SkillContent;
46
+ /**
47
+ * Load skills based on configuration.
48
+ * Supports both explicit paths and auto-discovery.
49
+ */
50
+ export declare function loadSkills(config: SkillsConfig, basePath?: string): SkillContent[];
51
+ /**
52
+ * Load skills from explicit directory paths (each path IS the skill directory).
53
+ */
54
+ export declare function loadSkillsFromPaths(paths: string[]): SkillContent[];
55
+ /**
56
+ * Build a system prompt section from loaded skills.
57
+ * Injects skill descriptions and instructions for the LLM.
58
+ */
59
+ export declare function buildSkillsSystemPrompt(skills: SkillContent[]): string;
60
+ /** A skill search result with relevance score. */
61
+ export interface SkillSearchResult {
62
+ skill: SkillMeta;
63
+ score: number;
64
+ }
65
+ /**
66
+ * Search skills by keyword against name, description, tags, and whenToUse.
67
+ * Returns top matches ranked by relevance score.
68
+ */
69
+ export declare function searchSkills(skills: SkillMeta[], query: string, limit?: number): SkillSearchResult[];
70
+ /**
71
+ * Filter skills to only those whose runtime requirements are met.
72
+ *
73
+ * Checks:
74
+ * - `requires.binaries`: each binary is found on PATH
75
+ * - `requires.env`: each env var is defined in process.env
76
+ *
77
+ * Skills with no requirements are always eligible.
78
+ */
79
+ export declare function filterEligibleSkills(skills: SkillMeta[]): SkillMeta[];
80
+ /**
81
+ * Check if a single skill's runtime requirements are met.
82
+ */
83
+ export declare function isSkillEligible(skill: SkillMeta): boolean;
84
+ //# sourceMappingURL=loader.d.ts.map