@nodetool-ai/agents 0.7.0-rc.11

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 (281) hide show
  1. package/dist/agent-executor.d.ts +62 -0
  2. package/dist/agent-executor.d.ts.map +1 -0
  3. package/dist/agent-executor.js +324 -0
  4. package/dist/agent-executor.js.map +1 -0
  5. package/dist/agent-step-executor.d.ts +28 -0
  6. package/dist/agent-step-executor.d.ts.map +1 -0
  7. package/dist/agent-step-executor.js +99 -0
  8. package/dist/agent-step-executor.js.map +1 -0
  9. package/dist/agent-workflow-runner.d.ts +31 -0
  10. package/dist/agent-workflow-runner.d.ts.map +1 -0
  11. package/dist/agent-workflow-runner.js +124 -0
  12. package/dist/agent-workflow-runner.js.map +1 -0
  13. package/dist/agent.d.ts +115 -0
  14. package/dist/agent.d.ts.map +1 -0
  15. package/dist/agent.js +587 -0
  16. package/dist/agent.js.map +1 -0
  17. package/dist/base-agent.d.ts +42 -0
  18. package/dist/base-agent.d.ts.map +1 -0
  19. package/dist/base-agent.js +29 -0
  20. package/dist/base-agent.js.map +1 -0
  21. package/dist/constants.d.ts +8 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/constants.js +8 -0
  24. package/dist/constants.js.map +1 -0
  25. package/dist/graph-builder.d.ts +49 -0
  26. package/dist/graph-builder.d.ts.map +1 -0
  27. package/dist/graph-builder.js +206 -0
  28. package/dist/graph-builder.js.map +1 -0
  29. package/dist/graph-planner.d.ts +56 -0
  30. package/dist/graph-planner.d.ts.map +1 -0
  31. package/dist/graph-planner.js +311 -0
  32. package/dist/graph-planner.js.map +1 -0
  33. package/dist/index.d.ts +79 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +81 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/js-sandbox.d.ts +84 -0
  38. package/dist/js-sandbox.d.ts.map +1 -0
  39. package/dist/js-sandbox.js +654 -0
  40. package/dist/js-sandbox.js.map +1 -0
  41. package/dist/multi-mode-agent.d.ts +86 -0
  42. package/dist/multi-mode-agent.d.ts.map +1 -0
  43. package/dist/multi-mode-agent.js +476 -0
  44. package/dist/multi-mode-agent.js.map +1 -0
  45. package/dist/output-format.d.ts +10 -0
  46. package/dist/output-format.d.ts.map +1 -0
  47. package/dist/output-format.js +17 -0
  48. package/dist/output-format.js.map +1 -0
  49. package/dist/parallel-task-executor.d.ts +87 -0
  50. package/dist/parallel-task-executor.d.ts.map +1 -0
  51. package/dist/parallel-task-executor.js +332 -0
  52. package/dist/parallel-task-executor.js.map +1 -0
  53. package/dist/prompts/graph-planner-prompt.d.ts +48 -0
  54. package/dist/prompts/graph-planner-prompt.d.ts.map +1 -0
  55. package/dist/prompts/graph-planner-prompt.js +180 -0
  56. package/dist/prompts/graph-planner-prompt.js.map +1 -0
  57. package/dist/reject-agentic-provider.d.ts +21 -0
  58. package/dist/reject-agentic-provider.d.ts.map +1 -0
  59. package/dist/reject-agentic-provider.js +32 -0
  60. package/dist/reject-agentic-provider.js.map +1 -0
  61. package/dist/simple-agent.d.ts +29 -0
  62. package/dist/simple-agent.d.ts.map +1 -0
  63. package/dist/simple-agent.js +54 -0
  64. package/dist/simple-agent.js.map +1 -0
  65. package/dist/step-executor.d.ts +162 -0
  66. package/dist/step-executor.d.ts.map +1 -0
  67. package/dist/step-executor.js +1114 -0
  68. package/dist/step-executor.js.map +1 -0
  69. package/dist/sub-agent-planner.d.ts +33 -0
  70. package/dist/sub-agent-planner.d.ts.map +1 -0
  71. package/dist/sub-agent-planner.js +203 -0
  72. package/dist/sub-agent-planner.js.map +1 -0
  73. package/dist/task-executor.d.ts +89 -0
  74. package/dist/task-executor.d.ts.map +1 -0
  75. package/dist/task-executor.js +359 -0
  76. package/dist/task-executor.js.map +1 -0
  77. package/dist/task-planner.d.ts +44 -0
  78. package/dist/task-planner.d.ts.map +1 -0
  79. package/dist/task-planner.js +532 -0
  80. package/dist/task-planner.js.map +1 -0
  81. package/dist/team/db-task-board.d.ts +54 -0
  82. package/dist/team/db-task-board.d.ts.map +1 -0
  83. package/dist/team/db-task-board.js +361 -0
  84. package/dist/team/db-task-board.js.map +1 -0
  85. package/dist/team/edge-message-bus.d.ts +51 -0
  86. package/dist/team/edge-message-bus.d.ts.map +1 -0
  87. package/dist/team/edge-message-bus.js +169 -0
  88. package/dist/team/edge-message-bus.js.map +1 -0
  89. package/dist/team/edge-task-board.d.ts +77 -0
  90. package/dist/team/edge-task-board.d.ts.map +1 -0
  91. package/dist/team/edge-task-board.js +140 -0
  92. package/dist/team/edge-task-board.js.map +1 -0
  93. package/dist/team/index.d.ts +16 -0
  94. package/dist/team/index.d.ts.map +1 -0
  95. package/dist/team/index.js +17 -0
  96. package/dist/team/index.js.map +1 -0
  97. package/dist/team/message-bus.d.ts +58 -0
  98. package/dist/team/message-bus.d.ts.map +1 -0
  99. package/dist/team/message-bus.js +151 -0
  100. package/dist/team/message-bus.js.map +1 -0
  101. package/dist/team/task-board.d.ts +106 -0
  102. package/dist/team/task-board.d.ts.map +1 -0
  103. package/dist/team/task-board.js +370 -0
  104. package/dist/team/task-board.js.map +1 -0
  105. package/dist/team/team-executor.d.ts +72 -0
  106. package/dist/team/team-executor.d.ts.map +1 -0
  107. package/dist/team/team-executor.js +466 -0
  108. package/dist/team/team-executor.js.map +1 -0
  109. package/dist/team/team-tools.d.ts +252 -0
  110. package/dist/team/team-tools.d.ts.map +1 -0
  111. package/dist/team/team-tools.js +412 -0
  112. package/dist/team/team-tools.js.map +1 -0
  113. package/dist/team/types.d.ts +198 -0
  114. package/dist/team/types.d.ts.map +1 -0
  115. package/dist/team/types.js +8 -0
  116. package/dist/team/types.js.map +1 -0
  117. package/dist/tools/add-edge-tool.d.ts +18 -0
  118. package/dist/tools/add-edge-tool.d.ts.map +1 -0
  119. package/dist/tools/add-edge-tool.js +92 -0
  120. package/dist/tools/add-edge-tool.js.map +1 -0
  121. package/dist/tools/add-node-tool.d.ts +22 -0
  122. package/dist/tools/add-node-tool.d.ts.map +1 -0
  123. package/dist/tools/add-node-tool.js +128 -0
  124. package/dist/tools/add-node-tool.js.map +1 -0
  125. package/dist/tools/asset-tools.d.ts +58 -0
  126. package/dist/tools/asset-tools.d.ts.map +1 -0
  127. package/dist/tools/asset-tools.js +191 -0
  128. package/dist/tools/asset-tools.js.map +1 -0
  129. package/dist/tools/base-tool.d.ts +25 -0
  130. package/dist/tools/base-tool.d.ts.map +1 -0
  131. package/dist/tools/base-tool.js +24 -0
  132. package/dist/tools/base-tool.js.map +1 -0
  133. package/dist/tools/browser-tools.d.ts +32 -0
  134. package/dist/tools/browser-tools.d.ts.map +1 -0
  135. package/dist/tools/browser-tools.js +208 -0
  136. package/dist/tools/browser-tools.js.map +1 -0
  137. package/dist/tools/calculator-tool.d.ts +24 -0
  138. package/dist/tools/calculator-tool.d.ts.map +1 -0
  139. package/dist/tools/calculator-tool.js +64 -0
  140. package/dist/tools/calculator-tool.js.map +1 -0
  141. package/dist/tools/claude-code-tools.d.ts +96 -0
  142. package/dist/tools/claude-code-tools.d.ts.map +1 -0
  143. package/dist/tools/claude-code-tools.js +463 -0
  144. package/dist/tools/claude-code-tools.js.map +1 -0
  145. package/dist/tools/code-tools.d.ts +26 -0
  146. package/dist/tools/code-tools.d.ts.map +1 -0
  147. package/dist/tools/code-tools.js +82 -0
  148. package/dist/tools/code-tools.js.map +1 -0
  149. package/dist/tools/control-tool.d.ts +47 -0
  150. package/dist/tools/control-tool.d.ts.map +1 -0
  151. package/dist/tools/control-tool.js +101 -0
  152. package/dist/tools/control-tool.js.map +1 -0
  153. package/dist/tools/create-plan-tool.d.ts +29 -0
  154. package/dist/tools/create-plan-tool.d.ts.map +1 -0
  155. package/dist/tools/create-plan-tool.js +355 -0
  156. package/dist/tools/create-plan-tool.js.map +1 -0
  157. package/dist/tools/create-task-tool.d.ts +28 -0
  158. package/dist/tools/create-task-tool.d.ts.map +1 -0
  159. package/dist/tools/create-task-tool.js +254 -0
  160. package/dist/tools/create-task-tool.js.map +1 -0
  161. package/dist/tools/dataseo-tools.d.ts +38 -0
  162. package/dist/tools/dataseo-tools.d.ts.map +1 -0
  163. package/dist/tools/dataseo-tools.js +329 -0
  164. package/dist/tools/dataseo-tools.js.map +1 -0
  165. package/dist/tools/email-tools.d.ts +76 -0
  166. package/dist/tools/email-tools.d.ts.map +1 -0
  167. package/dist/tools/email-tools.js +259 -0
  168. package/dist/tools/email-tools.js.map +1 -0
  169. package/dist/tools/filesystem-tools.d.ts +77 -0
  170. package/dist/tools/filesystem-tools.d.ts.map +1 -0
  171. package/dist/tools/filesystem-tools.js +334 -0
  172. package/dist/tools/filesystem-tools.js.map +1 -0
  173. package/dist/tools/find-model-tool.d.ts +25 -0
  174. package/dist/tools/find-model-tool.d.ts.map +1 -0
  175. package/dist/tools/find-model-tool.js +236 -0
  176. package/dist/tools/find-model-tool.js.map +1 -0
  177. package/dist/tools/finish-graph-tool.d.ts +23 -0
  178. package/dist/tools/finish-graph-tool.d.ts.map +1 -0
  179. package/dist/tools/finish-graph-tool.js +46 -0
  180. package/dist/tools/finish-graph-tool.js.map +1 -0
  181. package/dist/tools/finish-step-tool.d.ts +16 -0
  182. package/dist/tools/finish-step-tool.d.ts.map +1 -0
  183. package/dist/tools/finish-step-tool.js +68 -0
  184. package/dist/tools/finish-step-tool.js.map +1 -0
  185. package/dist/tools/google-tools.d.ts +44 -0
  186. package/dist/tools/google-tools.d.ts.map +1 -0
  187. package/dist/tools/google-tools.js +176 -0
  188. package/dist/tools/google-tools.js.map +1 -0
  189. package/dist/tools/http-tools.d.ts +56 -0
  190. package/dist/tools/http-tools.d.ts.map +1 -0
  191. package/dist/tools/http-tools.js +180 -0
  192. package/dist/tools/http-tools.js.map +1 -0
  193. package/dist/tools/js-code-tool.d.ts +30 -0
  194. package/dist/tools/js-code-tool.d.ts.map +1 -0
  195. package/dist/tools/js-code-tool.js +98 -0
  196. package/dist/tools/js-code-tool.js.map +1 -0
  197. package/dist/tools/local-get-node-info-tool.d.ts +19 -0
  198. package/dist/tools/local-get-node-info-tool.d.ts.map +1 -0
  199. package/dist/tools/local-get-node-info-tool.js +75 -0
  200. package/dist/tools/local-get-node-info-tool.js.map +1 -0
  201. package/dist/tools/local-list-nodes-tool.d.ts +19 -0
  202. package/dist/tools/local-list-nodes-tool.d.ts.map +1 -0
  203. package/dist/tools/local-list-nodes-tool.js +69 -0
  204. package/dist/tools/local-list-nodes-tool.js.map +1 -0
  205. package/dist/tools/local-search-nodes-tool.d.ts +21 -0
  206. package/dist/tools/local-search-nodes-tool.d.ts.map +1 -0
  207. package/dist/tools/local-search-nodes-tool.js +111 -0
  208. package/dist/tools/local-search-nodes-tool.js.map +1 -0
  209. package/dist/tools/math-tools.d.ts +156 -0
  210. package/dist/tools/math-tools.d.ts.map +1 -0
  211. package/dist/tools/math-tools.js +422 -0
  212. package/dist/tools/math-tools.js.map +1 -0
  213. package/dist/tools/mcp-tools.d.ts +413 -0
  214. package/dist/tools/mcp-tools.d.ts.map +1 -0
  215. package/dist/tools/mcp-tools.js +618 -0
  216. package/dist/tools/mcp-tools.js.map +1 -0
  217. package/dist/tools/media-tools.d.ts +277 -0
  218. package/dist/tools/media-tools.d.ts.map +1 -0
  219. package/dist/tools/media-tools.js +682 -0
  220. package/dist/tools/media-tools.js.map +1 -0
  221. package/dist/tools/model-tools.d.ts +25 -0
  222. package/dist/tools/model-tools.d.ts.map +1 -0
  223. package/dist/tools/model-tools.js +48 -0
  224. package/dist/tools/model-tools.js.map +1 -0
  225. package/dist/tools/openai-tools.d.ts +73 -0
  226. package/dist/tools/openai-tools.d.ts.map +1 -0
  227. package/dist/tools/openai-tools.js +193 -0
  228. package/dist/tools/openai-tools.js.map +1 -0
  229. package/dist/tools/pdf-tools.d.ts +152 -0
  230. package/dist/tools/pdf-tools.d.ts.map +1 -0
  231. package/dist/tools/pdf-tools.js +339 -0
  232. package/dist/tools/pdf-tools.js.map +1 -0
  233. package/dist/tools/plan-builder-tools.d.ts +72 -0
  234. package/dist/tools/plan-builder-tools.d.ts.map +1 -0
  235. package/dist/tools/plan-builder-tools.js +438 -0
  236. package/dist/tools/plan-builder-tools.js.map +1 -0
  237. package/dist/tools/search-tools.d.ts +39 -0
  238. package/dist/tools/search-tools.d.ts.map +1 -0
  239. package/dist/tools/search-tools.js +218 -0
  240. package/dist/tools/search-tools.js.map +1 -0
  241. package/dist/tools/serp-providers/dataforseo-provider.d.ts +14 -0
  242. package/dist/tools/serp-providers/dataforseo-provider.d.ts.map +1 -0
  243. package/dist/tools/serp-providers/dataforseo-provider.js +114 -0
  244. package/dist/tools/serp-providers/dataforseo-provider.js.map +1 -0
  245. package/dist/tools/serp-providers/index.d.ts +35 -0
  246. package/dist/tools/serp-providers/index.d.ts.map +1 -0
  247. package/dist/tools/serp-providers/index.js +14 -0
  248. package/dist/tools/serp-providers/index.js.map +1 -0
  249. package/dist/tools/serp-providers/serpapi-provider.d.ts +18 -0
  250. package/dist/tools/serp-providers/serpapi-provider.d.ts.map +1 -0
  251. package/dist/tools/serp-providers/serpapi-provider.js +66 -0
  252. package/dist/tools/serp-providers/serpapi-provider.js.map +1 -0
  253. package/dist/tools/tool-registry.d.ts +9 -0
  254. package/dist/tools/tool-registry.d.ts.map +1 -0
  255. package/dist/tools/tool-registry.js +17 -0
  256. package/dist/tools/tool-registry.js.map +1 -0
  257. package/dist/tools/vector-tools.d.ts +224 -0
  258. package/dist/tools/vector-tools.d.ts.map +1 -0
  259. package/dist/tools/vector-tools.js +582 -0
  260. package/dist/tools/vector-tools.js.map +1 -0
  261. package/dist/tools/workspace-tools.d.ts +58 -0
  262. package/dist/tools/workspace-tools.d.ts.map +1 -0
  263. package/dist/tools/workspace-tools.js +152 -0
  264. package/dist/tools/workspace-tools.js.map +1 -0
  265. package/dist/types.d.ts +65 -0
  266. package/dist/types.d.ts.map +1 -0
  267. package/dist/types.js +5 -0
  268. package/dist/types.js.map +1 -0
  269. package/dist/utils/json-parser.d.ts +15 -0
  270. package/dist/utils/json-parser.d.ts.map +1 -0
  271. package/dist/utils/json-parser.js +78 -0
  272. package/dist/utils/json-parser.js.map +1 -0
  273. package/dist/utils/remove-base64-images.d.ts +12 -0
  274. package/dist/utils/remove-base64-images.d.ts.map +1 -0
  275. package/dist/utils/remove-base64-images.js +20 -0
  276. package/dist/utils/remove-base64-images.js.map +1 -0
  277. package/dist/utils/wrap-generators-parallel.d.ts +11 -0
  278. package/dist/utils/wrap-generators-parallel.d.ts.map +1 -0
  279. package/dist/utils/wrap-generators-parallel.js +38 -0
  280. package/dist/utils/wrap-generators-parallel.js.map +1 -0
  281. package/package.json +65 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Code execution tool — runs JavaScript in a QuickJS sandbox.
3
+ *
4
+ * Only JavaScript is supported. TypeScript, Python, and Bash have been
5
+ * removed for security (no subprocess spawning).
6
+ */
7
+ import { Tool } from "./base-tool.js";
8
+ import { runInSandbox } from "../js-sandbox.js";
9
+ const DEFAULT_TIMEOUT_MS = 30_000;
10
+ export class RunCodeTool extends Tool {
11
+ name = "run_code";
12
+ description = "Execute JavaScript code in a sandboxed QuickJS environment. Only javascript is supported.";
13
+ inputSchema = {
14
+ type: "object",
15
+ properties: {
16
+ language: {
17
+ type: "string",
18
+ enum: ["javascript"],
19
+ description: "The language to use. Only 'javascript' is supported."
20
+ },
21
+ code: {
22
+ type: "string",
23
+ description: "JavaScript source code to execute."
24
+ }
25
+ },
26
+ required: ["language", "code"]
27
+ };
28
+ timeoutMs;
29
+ constructor(options) {
30
+ super();
31
+ this.timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32
+ }
33
+ async process(context, params) {
34
+ const language = params.language;
35
+ const code = params.code;
36
+ if (!code || typeof code !== "string" || !code.trim()) {
37
+ return { stdout: "", stderr: "No code provided.", exitCode: 1 };
38
+ }
39
+ if (language !== "javascript") {
40
+ return {
41
+ stdout: "",
42
+ stderr: `Unsupported language: ${language}. Only 'javascript' is supported.`,
43
+ exitCode: 1
44
+ };
45
+ }
46
+ const result = await runInSandbox({
47
+ code,
48
+ context,
49
+ timeoutMs: this.timeoutMs
50
+ });
51
+ const logs = result.logs?.join("\n") ?? "";
52
+ if (result.success) {
53
+ const output = result.result !== undefined && result.result !== null
54
+ ? typeof result.result === "string"
55
+ ? result.result
56
+ : JSON.stringify(result.result, null, 2)
57
+ : "";
58
+ const stdout = logs ? `${logs}\n${output}`.trim() : output;
59
+ return { stdout, stderr: "", exitCode: 0 };
60
+ }
61
+ const errorParts = [];
62
+ if (logs)
63
+ errorParts.push(logs);
64
+ if (result.error)
65
+ errorParts.push(result.error);
66
+ if (result.stack)
67
+ errorParts.push(result.stack);
68
+ return {
69
+ stdout: "",
70
+ stderr: errorParts.join("\n").trim(),
71
+ exitCode: 1
72
+ };
73
+ }
74
+ userMessage(params) {
75
+ const code = params.code ?? "";
76
+ if (code.length > 0 && code.length < 50) {
77
+ return `Executing javascript: '${code.slice(0, 40)}...'`;
78
+ }
79
+ return "Executing javascript...";
80
+ }
81
+ }
82
+ //# sourceMappingURL=code-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../src/tools/code-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAQlC,MAAM,OAAO,WAAY,SAAQ,IAAI;IAC1B,IAAI,GAAG,UAAU,CAAC;IAClB,WAAW,GAClB,2FAA2F,CAAC;IACrF,WAAW,GAA4B;QAC9C,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,YAAY,CAAC;gBACpB,WAAW,EAAE,sDAAsD;aACpE;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;aAClD;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M,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1C,CAAC,CAAC,EAAE,CAAC;YACT,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QAC7C,CAAC;QAED,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,IAAI,IAAI;YAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,MAAM,CAAC,KAAK;YAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,KAAK;YAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAEhD,OAAO;YACL,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YACpC,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,MAA+B;QACzC,MAAM,IAAI,GAAI,MAAM,CAAC,IAAe,IAAI,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACxC,OAAO,0BAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;QAC3D,CAAC;QACD,OAAO,yBAAyB,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Control Node Tool for Agent-based Control Edge System
3
+ *
4
+ * Port of src/nodetool/agents/tools/control_tool.py
5
+ *
6
+ * When an agent has outgoing control edges, ControlNodeTool instances are
7
+ * automatically added to its tool list. When the agent calls a control tool,
8
+ * it creates a RunEvent for dispatch to the controlled node.
9
+ */
10
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
11
+ import type { ControlEvent } from "@nodetool-ai/protocol";
12
+ import { Tool } from "./base-tool.js";
13
+ /**
14
+ * Convert a node title to a valid tool name (snake_case, max 64 chars).
15
+ */
16
+ export declare function sanitizeToolName(name: string): string;
17
+ export interface ControlNodeInfo {
18
+ node_id: string;
19
+ node_type: string;
20
+ node_title: string;
21
+ node_description?: string;
22
+ control_actions?: Record<string, {
23
+ properties?: Record<string, Record<string, unknown>>;
24
+ }>;
25
+ properties?: Record<string, unknown>;
26
+ upstream_data?: Record<string, unknown>;
27
+ }
28
+ export declare class ControlNodeTool extends Tool {
29
+ readonly name: string;
30
+ readonly description: string;
31
+ readonly inputSchema: Record<string, unknown>;
32
+ readonly targetNodeId: string;
33
+ readonly nodeInfo: ControlNodeInfo;
34
+ constructor(targetNodeId: string, nodeInfo: ControlNodeInfo);
35
+ /**
36
+ * Create a control event from tool arguments.
37
+ */
38
+ createControlEvent(args: Record<string, unknown>): ControlEvent;
39
+ userMessage(params: Record<string, unknown>): string;
40
+ /**
41
+ * Stub process method for tool interface compatibility.
42
+ * In the normal control flow, control tools are intercepted by the
43
+ * execution loop and converted to control events.
44
+ */
45
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
46
+ }
47
+ //# sourceMappingURL=control-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-tool.d.ts","sourceRoot":"","sources":["../../src/tools/control-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBrD;A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control edges, ControlNodeTool instances are
7
+ * automatically added to its tool list. When the agent calls a control tool,
8
+ * it creates a RunEvent for dispatch to the controlled node.
9
+ */
10
+ import { Tool } from "./base-tool.js";
11
+ /**
12
+ * Convert a node title to a valid tool name (snake_case, max 64 chars).
13
+ */
14
+ export function sanitizeToolName(name) {
15
+ if (typeof name !== "string" || !name)
16
+ return "control_node";
17
+ let s = name
18
+ // Replace non-alphanumeric with underscores
19
+ .replace(/[^a-zA-Z0-9]/g, "_")
20
+ // camelCase → snake_case
21
+ .replace(/([a-z])([A-Z])/g, "$1_$2")
22
+ .toLowerCase()
23
+ // Collapse consecutive underscores
24
+ .replace(/_+/g, "_")
25
+ // Strip leading/trailing underscores
26
+ .replace(/^_+|_+$/g, "");
27
+ if (!s)
28
+ return "control_node";
29
+ if (s.length > 64)
30
+ s = s.slice(0, 64);
31
+ return s;
32
+ }
33
+ export class ControlNodeTool extends Tool {
34
+ name;
35
+ description;
36
+ inputSchema;
37
+ targetNodeId;
38
+ nodeInfo;
39
+ constructor(targetNodeId, nodeInfo) {
40
+ super();
41
+ this.targetNodeId = targetNodeId;
42
+ this.nodeInfo = nodeInfo;
43
+ // Build schema from the "run" action properties
44
+ const actions = nodeInfo.control_actions ?? {};
45
+ const runAction = actions["run"] ?? {};
46
+ const rawProperties = runAction.properties ?? {};
47
+ const properties = {};
48
+ for (const [key, schema] of Object.entries(rawProperties)) {
49
+ if (typeof schema === "object" && schema !== null) {
50
+ properties[key] = { ...schema };
51
+ }
52
+ else {
53
+ properties[key] = { type: "string", description: String(schema) };
54
+ }
55
+ }
56
+ this.inputSchema = {
57
+ type: "object",
58
+ properties,
59
+ required: []
60
+ };
61
+ // Set name from normalized node title
62
+ const nodeTitle = nodeInfo.node_title || targetNodeId;
63
+ this.name = sanitizeToolName(nodeTitle);
64
+ // Set description
65
+ if (nodeInfo.node_description) {
66
+ this.description = nodeInfo.node_description;
67
+ }
68
+ else {
69
+ let desc = `Control ${nodeTitle}: trigger execution with optional property overrides`;
70
+ const propNames = Object.keys(properties);
71
+ if (propNames.length > 0) {
72
+ desc += `. Available properties: ${propNames.join(", ")}`;
73
+ }
74
+ this.description = desc;
75
+ }
76
+ }
77
+ /**
78
+ * Create a control event from tool arguments.
79
+ */
80
+ createControlEvent(args) {
81
+ return { event_type: "run", properties: args };
82
+ }
83
+ userMessage(params) {
84
+ const nodeTitle = this.nodeInfo.node_title || this.targetNodeId;
85
+ if (params && Object.keys(params).length > 0) {
86
+ return `Triggering ${nodeTitle} with properties: ${Object.keys(params).join(", ")}`;
87
+ }
88
+ return `Triggering ${nodeTitle}`;
89
+ }
90
+ /**
91
+ * Stub process method for tool interface compatibility.
92
+ * In the normal control flow, control tools are intercepted by the
93
+ * execution loop and converted to control events.
94
+ */
95
+ async process(_context, params) {
96
+ const event = this.createControlEvent(params);
97
+ const nodeTitle = this.nodeInfo.node_title || this.targetNodeId;
98
+ return `Created ${event.event_type} event for ${nodeTitle} with properties: ${Object.keys(params).join(", ")}`;
99
+ }
100
+ }
101
+ //# sourceMappingURL=control-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-tool.js","sourceRoot":"","sources":["../../src/tools/control-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI;QAAE,OAAO,cAAc,CAAC;IAE7D,IAAI,CAAC,GAAG,IAAI;QACV,4CAA4C;SAC3C,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;QAC9B,yBAAyB;SACxB,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,WAAW,EAAE;QACd,mCAAmC;SAClC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACpB,qCAAqC;SACpC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;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CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI,CAAC,YAAY,CAAC;QAChE,OAAO,WAAW,KAAK,CAAC,UAAU,cAAc,SAAS,qBAAqB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACjH,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Tool for creating and validating a multi-task execution plan.
3
+ *
4
+ * Used by TaskPlanner to let the LLM produce a validated TaskPlan
5
+ * through the standard agent tool-calling loop.
6
+ */
7
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
8
+ import { Tool } from "./base-tool.js";
9
+ import type { TaskPlan } from "../types.js";
10
+ export declare class CreatePlanTool extends Tool {
11
+ readonly name = "create_plan";
12
+ readonly description: string;
13
+ readonly inputSchema: Record<string, unknown>;
14
+ /** Captured validated plan, or null if not yet created. */
15
+ private _plan;
16
+ /** Input keys for dependency validation. */
17
+ private readonly inputKeys;
18
+ constructor(inputs?: Record<string, unknown>);
19
+ get plan(): TaskPlan | null;
20
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
21
+ userMessage(params: Record<string, unknown>): string;
22
+ private buildTaskPlan;
23
+ private validateTaskPlan;
24
+ private checkForTaskCycles;
25
+ private checkForStepCycles;
26
+ private validatePlanSemantics;
27
+ private applySchemaOverrides;
28
+ }
29
+ //# sourceMappingURL=create-plan-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-plan-tool.d.ts","sourceRoot":"","sources":["../../src/tools/create-plan-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkDxD,qBAAa,cAAe,SAAQ,IAAI;IACtC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,SAEsD;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAA4B;IAEzE,2DAA2D;IAC3D,OAAO,CAAC,KAAK,CAAyB;IAEtC,4CAA4C;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAE5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAK5C,IAAI,IAAI,IAAI,QAAQ,GAAG,IAAI,CAE1B;IAEK,OAAO,CACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;IAyBnB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAUpD,OAAO,CAAC,aAAa;IA+DrB,OAAO,CAAC,gBAAgB;IA8ExB,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,qBAAqB;IAgF7B,OAAO,CAAC,oBAAoB;CAmB7B"}
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Tool for creating and validating a multi-task execution plan.
3
+ *
4
+ * Used by TaskPlanner to let the LLM produce a validated TaskPlan
5
+ * through the standard agent tool-calling loop.
6
+ */
7
+ import { Tool } from "./base-tool.js";
8
+ import { randomUUID } from "node:crypto";
9
+ /**
10
+ * JSON Schema for the create_plan tool input.
11
+ */
12
+ const CREATE_PLAN_INPUT_SCHEMA = {
13
+ type: "object",
14
+ properties: {
15
+ title: { type: "string", description: "Overall plan title" },
16
+ tasks: {
17
+ type: "array",
18
+ description: "Independent tasks to execute in parallel. Each task runs as its own sub-agent.",
19
+ items: {
20
+ type: "object",
21
+ properties: {
22
+ id: { type: "string", description: "Unique task identifier" },
23
+ title: { type: "string", description: "Task title" },
24
+ depends_on: {
25
+ type: "array",
26
+ items: { type: "string" },
27
+ description: "Task IDs this task depends on ([] for independent)"
28
+ },
29
+ steps: {
30
+ type: "array",
31
+ items: {
32
+ type: "object",
33
+ properties: {
34
+ id: { type: "string" },
35
+ instructions: { type: "string" },
36
+ depends_on: {
37
+ type: "array",
38
+ items: { type: "string" },
39
+ description: "Step IDs within this task"
40
+ },
41
+ output_schema: { type: "string" },
42
+ tools: { type: "array", items: { type: "string" } }
43
+ },
44
+ required: ["id", "instructions", "depends_on"]
45
+ }
46
+ }
47
+ },
48
+ required: ["id", "title", "depends_on", "steps"]
49
+ }
50
+ }
51
+ },
52
+ required: ["title", "tasks"]
53
+ };
54
+ export class CreatePlanTool extends Tool {
55
+ name = "create_plan";
56
+ description = "Create a parallel execution plan with multiple independent tasks. " +
57
+ "Each task runs as its own sub-agent. Tasks form a DAG via depends_on.";
58
+ inputSchema = CREATE_PLAN_INPUT_SCHEMA;
59
+ /** Captured validated plan, or null if not yet created. */
60
+ _plan = null;
61
+ /** Input keys for dependency validation. */
62
+ inputKeys;
63
+ constructor(inputs) {
64
+ super();
65
+ this.inputKeys = new Set(Object.keys(inputs ?? {}));
66
+ }
67
+ get plan() {
68
+ return this._plan;
69
+ }
70
+ async process(_context, params) {
71
+ const taskPlan = this.buildTaskPlan(params);
72
+ const errors = this.validateTaskPlan(taskPlan);
73
+ if (errors.length > 0) {
74
+ return {
75
+ status: "validation_failed",
76
+ errors
77
+ };
78
+ }
79
+ // Apply schema normalization to all task steps
80
+ for (const task of taskPlan.tasks) {
81
+ this.applySchemaOverrides(task.steps);
82
+ }
83
+ this._plan = taskPlan;
84
+ return {
85
+ status: "plan_created",
86
+ title: taskPlan.title,
87
+ tasks: taskPlan.tasks.length,
88
+ totalSteps: taskPlan.tasks.reduce((sum, t) => sum + t.steps.length, 0)
89
+ };
90
+ }
91
+ userMessage(params) {
92
+ const title = typeof params["title"] === "string" ? params["title"] : "plan";
93
+ return `Creating plan: ${title}`;
94
+ }
95
+ // ---------------------------------------------------------------------------
96
+ // Build
97
+ // ---------------------------------------------------------------------------
98
+ buildTaskPlan(data) {
99
+ const title = typeof data["title"] === "string" ? data["title"] : "Untitled Plan";
100
+ const rawTasks = Array.isArray(data["tasks"]) ? data["tasks"] : [];
101
+ const tasks = rawTasks.map((t) => {
102
+ const rawTask = t;
103
+ const taskId = typeof rawTask["id"] === "string" ? rawTask["id"] : randomUUID();
104
+ const taskTitle = typeof rawTask["title"] === "string"
105
+ ? rawTask["title"]
106
+ : "Untitled Task";
107
+ const taskDependsOn = Array.isArray(rawTask["depends_on"])
108
+ ? rawTask["depends_on"]
109
+ : Array.isArray(rawTask["dependsOn"])
110
+ ? rawTask["dependsOn"]
111
+ : [];
112
+ const rawSteps = Array.isArray(rawTask["steps"])
113
+ ? rawTask["steps"]
114
+ : [];
115
+ const steps = rawSteps.map((s) => {
116
+ const raw = s;
117
+ return {
118
+ id: typeof raw["id"] === "string" ? raw["id"] : randomUUID(),
119
+ instructions: typeof raw["instructions"] === "string" ? raw["instructions"] : "",
120
+ completed: false,
121
+ dependsOn: Array.isArray(raw["depends_on"])
122
+ ? raw["depends_on"]
123
+ : Array.isArray(raw["dependsOn"])
124
+ ? raw["dependsOn"]
125
+ : [],
126
+ outputSchema: typeof raw["output_schema"] === "string"
127
+ ? raw["output_schema"]
128
+ : typeof raw["outputSchema"] === "string"
129
+ ? raw["outputSchema"]
130
+ : undefined,
131
+ tools: Array.isArray(raw["tools"])
132
+ ? raw["tools"]
133
+ : undefined,
134
+ logs: []
135
+ };
136
+ });
137
+ return {
138
+ id: taskId,
139
+ title: taskTitle,
140
+ dependsOn: taskDependsOn,
141
+ completed: false,
142
+ steps
143
+ };
144
+ });
145
+ return { title, tasks };
146
+ }
147
+ // ---------------------------------------------------------------------------
148
+ // Validation
149
+ // ---------------------------------------------------------------------------
150
+ validateTaskPlan(taskPlan) {
151
+ const errors = [];
152
+ const taskIds = new Set(taskPlan.tasks.map((t) => t.id));
153
+ // Check for duplicate task IDs
154
+ const seenTaskIds = new Set();
155
+ for (const task of taskPlan.tasks) {
156
+ if (seenTaskIds.has(task.id)) {
157
+ errors.push(`Duplicate task ID: '${task.id}'.`);
158
+ }
159
+ seenTaskIds.add(task.id);
160
+ }
161
+ // Check task-level dependencies
162
+ for (const task of taskPlan.tasks) {
163
+ for (const dep of task.dependsOn ?? []) {
164
+ if (!taskIds.has(dep)) {
165
+ errors.push(`Task '${task.id}' depends on '${dep}' which does not exist as a task ID.`);
166
+ }
167
+ }
168
+ }
169
+ // Check for cycles at the task level
170
+ if (!this.checkForTaskCycles(taskPlan)) {
171
+ errors.push("Circular dependency detected among tasks.");
172
+ }
173
+ // Collect all step IDs across all tasks for uniqueness check
174
+ const allStepIds = new Set();
175
+ for (const task of taskPlan.tasks) {
176
+ for (const step of task.steps) {
177
+ if (allStepIds.has(step.id)) {
178
+ errors.push(`Duplicate step ID '${step.id}' found across tasks.`);
179
+ }
180
+ allStepIds.add(step.id);
181
+ }
182
+ }
183
+ // Validate each task's internal steps
184
+ for (const task of taskPlan.tasks) {
185
+ const stepIds = new Set(task.steps.map((s) => s.id));
186
+ for (const step of task.steps) {
187
+ for (const dep of step.dependsOn) {
188
+ if (!stepIds.has(dep) && !this.inputKeys.has(dep)) {
189
+ errors.push(`Step '${step.id}' in task '${task.id}' depends on '${dep}' which does not exist within that task or as an input key.`);
190
+ }
191
+ }
192
+ }
193
+ // Check for step-level cycles within this task
194
+ if (!this.checkForStepCycles(task)) {
195
+ errors.push(`Circular dependency detected in steps of task '${task.id}'.`);
196
+ }
197
+ // Validate semantics within each task
198
+ const semanticErrors = this.validatePlanSemantics(task.steps);
199
+ for (const err of semanticErrors) {
200
+ errors.push(`Task '${task.id}': ${err}`);
201
+ }
202
+ }
203
+ // Must have at least one task
204
+ if (taskPlan.tasks.length === 0) {
205
+ errors.push("Plan must contain at least one task.");
206
+ }
207
+ return errors;
208
+ }
209
+ checkForTaskCycles(taskPlan) {
210
+ const taskIds = new Set(taskPlan.tasks.map((t) => t.id));
211
+ const visited = new Set();
212
+ const inStack = new Set();
213
+ const taskMap = new Map(taskPlan.tasks.map((t) => [t.id, t]));
214
+ const hasCycle = (id) => {
215
+ if (inStack.has(id))
216
+ return true;
217
+ if (visited.has(id))
218
+ return false;
219
+ visited.add(id);
220
+ inStack.add(id);
221
+ const task = taskMap.get(id);
222
+ if (task) {
223
+ for (const dep of task.dependsOn ?? []) {
224
+ if (taskIds.has(dep) && hasCycle(dep))
225
+ return true;
226
+ }
227
+ }
228
+ inStack.delete(id);
229
+ return false;
230
+ };
231
+ for (const task of taskPlan.tasks) {
232
+ if (hasCycle(task.id))
233
+ return false;
234
+ }
235
+ return true;
236
+ }
237
+ checkForStepCycles(task) {
238
+ const stepIds = new Set(task.steps.map((s) => s.id));
239
+ const visited = new Set();
240
+ const inStack = new Set();
241
+ const stepMap = new Map(task.steps.map((s) => [s.id, s]));
242
+ const hasCycle = (id) => {
243
+ if (inStack.has(id))
244
+ return true;
245
+ if (visited.has(id))
246
+ return false;
247
+ visited.add(id);
248
+ inStack.add(id);
249
+ const step = stepMap.get(id);
250
+ if (step) {
251
+ for (const dep of step.dependsOn) {
252
+ if (stepIds.has(dep) && hasCycle(dep))
253
+ return true;
254
+ }
255
+ }
256
+ inStack.delete(id);
257
+ return false;
258
+ };
259
+ for (const step of task.steps) {
260
+ if (hasCycle(step.id))
261
+ return false;
262
+ }
263
+ return true;
264
+ }
265
+ validatePlanSemantics(steps) {
266
+ const errors = [];
267
+ const loopingPhrases = [
268
+ "for each",
269
+ "for every",
270
+ "iterate over",
271
+ "loop over",
272
+ "for all"
273
+ ];
274
+ const aggregatorPatterns = [
275
+ "aggregate",
276
+ "compile",
277
+ "combine",
278
+ "merge",
279
+ "final",
280
+ "report"
281
+ ];
282
+ const aggregatorIds = new Set();
283
+ for (const step of steps) {
284
+ const sid = step.id.toLowerCase();
285
+ if (aggregatorPatterns.some((p) => sid.includes(p))) {
286
+ aggregatorIds.add(step.id);
287
+ }
288
+ }
289
+ // Check non-aggregator steps for looping language
290
+ for (const step of steps) {
291
+ if (aggregatorIds.has(step.id))
292
+ continue;
293
+ const content = step.instructions.toLowerCase();
294
+ for (const phrase of loopingPhrases) {
295
+ if (content.includes(phrase)) {
296
+ errors.push(`Step '${step.id}' contains looping phrase '${phrase}'. Emit one step per item (fan-out) instead.`);
297
+ break;
298
+ }
299
+ }
300
+ }
301
+ // Check aggregator wiring
302
+ const extractorPatterns = [
303
+ "extract",
304
+ "fetch",
305
+ "scrape",
306
+ "crawl",
307
+ "parse",
308
+ "process"
309
+ ];
310
+ const extractorIds = [];
311
+ for (const step of steps) {
312
+ const sid = step.id.toLowerCase();
313
+ if (extractorPatterns.some((p) => sid.includes(p))) {
314
+ extractorIds.push(step.id);
315
+ }
316
+ }
317
+ if (aggregatorIds.size > 0 && extractorIds.length > 0) {
318
+ for (const aggId of aggregatorIds) {
319
+ const agg = steps.find((s) => s.id === aggId);
320
+ if (!agg)
321
+ continue;
322
+ const declaredDeps = new Set(agg.dependsOn);
323
+ const missing = extractorIds.filter((eid) => !declaredDeps.has(eid));
324
+ if (missing.length > 0) {
325
+ errors.push(`Aggregator '${aggId}' must depend on all extractor steps. Missing: ${missing.join(", ")}`);
326
+ }
327
+ }
328
+ }
329
+ return errors;
330
+ }
331
+ // ---------------------------------------------------------------------------
332
+ // Schema normalization
333
+ // ---------------------------------------------------------------------------
334
+ applySchemaOverrides(steps) {
335
+ for (const step of steps) {
336
+ if (!step.outputSchema)
337
+ continue;
338
+ try {
339
+ const parsed = typeof step.outputSchema === "string"
340
+ ? JSON.parse(step.outputSchema)
341
+ : step.outputSchema;
342
+ if (typeof parsed === "object" && parsed !== null) {
343
+ if (!("type" in parsed)) {
344
+ parsed["type"] = "object";
345
+ step.outputSchema = JSON.stringify(parsed);
346
+ }
347
+ }
348
+ }
349
+ catch {
350
+ step.outputSchema = undefined;
351
+ }
352
+ }
353
+ }
354
+ }
355
+ //# sourceMappingURL=create-plan-tool.js.map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