@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,62 @@
1
+ /**
2
+ * AgentExecutor -- value-based task execution using LLM interactions.
3
+ *
4
+ * Port of src/nodetool/agents/agent_executor.py
5
+ *
6
+ * A simplified executor that operates on Python/JS values instead of files.
7
+ * Maintains output type handling while removing file operations.
8
+ */
9
+ import type { BaseProvider, ProcessingContext, ToolCall } from "@nodetool-ai/runtime";
10
+ import type { Chunk } from "@nodetool-ai/protocol";
11
+ import { Tool } from "./tools/base-tool.js";
12
+ export declare function jsonSchemaForOutputType(type: string): Record<string, unknown>;
13
+ export declare class FinishTool extends Tool {
14
+ readonly name = "finish_task";
15
+ readonly description = "Finish the task by providing the final result value and metadata.";
16
+ readonly inputSchema: Record<string, unknown>;
17
+ constructor(outputType: string, outputSchema: Record<string, unknown> | null);
18
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
19
+ }
20
+ export interface AgentExecutorOptions {
21
+ provider: BaseProvider;
22
+ model: string;
23
+ context: ProcessingContext;
24
+ tools: Tool[];
25
+ systemPrompt?: string;
26
+ maxIterations?: number;
27
+ outputType?: string;
28
+ outputSchema?: Record<string, unknown> | null;
29
+ threadId?: string;
30
+ }
31
+ export declare class AgentExecutor {
32
+ private readonly provider;
33
+ private readonly model;
34
+ private readonly context;
35
+ private readonly tools;
36
+ private readonly finishTool;
37
+ private readonly maxIterations;
38
+ private readonly outputType;
39
+ private readonly systemPrompt;
40
+ private readonly threadId?;
41
+ private history;
42
+ private iterations;
43
+ private completed;
44
+ private _result;
45
+ private _metadata;
46
+ constructor(options: AgentExecutorOptions);
47
+ private createSystemPrompt;
48
+ /**
49
+ * Check if the provider supports native agentic tool execution.
50
+ */
51
+ private isAgenticProvider;
52
+ execute(objective: string, inputs?: Record<string, unknown>): AsyncGenerator<Chunk | ToolCall>;
53
+ /**
54
+ * Agentic execution: single provider call handles all tool calls via MCP.
55
+ * The onToolCall callback executes tools natively; finish_task signals completion.
56
+ */
57
+ private executeAgentic;
58
+ private handleToolCall;
59
+ getResult(): unknown;
60
+ getMetadata(): Record<string, unknown> | null;
61
+ }
62
+ //# sourceMappingURL=agent-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-executor.d.ts","sourceRoot":"","sources":["../src/agent-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EAEjB,QAAQ,EAET,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAe5C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkB7E;AAED,qBAAa,UAAW,SAAQ,IAAI;IAClC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,uEACkD;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAG5C,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAgBxC,OAAO,CACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;CAGpB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YAuGf,cAAc;IAa5B,SAAS,IAAI,OAAO;IAIpB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAG9C"}
@@ -0,0 +1,324 @@
1
+ /**
2
+ * AgentExecutor -- value-based task execution using LLM interactions.
3
+ *
4
+ * Port of src/nodetool/agents/agent_executor.py
5
+ *
6
+ * A simplified executor that operates on Python/JS values instead of files.
7
+ * Maintains output type handling while removing file operations.
8
+ */
9
+ import { Tool } from "./tools/base-tool.js";
10
+ const DEFAULT_MAX_ITERATIONS = 10;
11
+ const METADATA_SCHEMA = {
12
+ type: "object",
13
+ properties: {
14
+ title: { type: "string" },
15
+ description: { type: "string" },
16
+ sources: { type: "array", items: { type: "string" } }
17
+ },
18
+ required: ["title", "description"],
19
+ additionalProperties: true
20
+ };
21
+ export function jsonSchemaForOutputType(type) {
22
+ const schemas = {
23
+ json: { type: "object", description: "JSON object" },
24
+ list: { type: "array", description: "Array of values" },
25
+ string: { type: "string", description: "Text string" },
26
+ number: { type: "number", description: "Numeric value" },
27
+ boolean: { type: "boolean", description: "Boolean value" },
28
+ markdown: { type: "string", description: "Markdown formatted text" },
29
+ html: { type: "string", description: "HTML markup" },
30
+ csv: { type: "string", description: "CSV formatted data" },
31
+ yaml: { type: "string", description: "YAML formatted data" }
32
+ };
33
+ return (schemas[type] ?? {
34
+ type: "string",
35
+ description: `Output of type ${type}`
36
+ });
37
+ }
38
+ export class FinishTool extends Tool {
39
+ name = "finish_task";
40
+ description = "Finish the task by providing the final result value and metadata.";
41
+ inputSchema;
42
+ constructor(outputType, outputSchema) {
43
+ super();
44
+ const resultSchema = outputSchema ?? jsonSchemaForOutputType(outputType);
45
+ this.inputSchema = {
46
+ type: "object",
47
+ properties: {
48
+ result: resultSchema,
49
+ metadata: METADATA_SCHEMA
50
+ },
51
+ required: ["result", "metadata"],
52
+ additionalProperties: false
53
+ };
54
+ }
55
+ async process(_context, params) {
56
+ return params;
57
+ }
58
+ }
59
+ export class AgentExecutor {
60
+ provider;
61
+ model;
62
+ context;
63
+ tools;
64
+ finishTool;
65
+ maxIterations;
66
+ outputType;
67
+ systemPrompt;
68
+ threadId;
69
+ history;
70
+ iterations = 0;
71
+ completed = false;
72
+ _result = null;
73
+ _metadata = null;
74
+ constructor(options) {
75
+ this.provider = options.provider;
76
+ this.model = options.model;
77
+ this.context = options.context;
78
+ this.outputType = options.outputType ?? "string";
79
+ this.threadId = options.threadId;
80
+ this.maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
81
+ this.finishTool = new FinishTool(this.outputType, options.outputSchema ?? null);
82
+ this.tools = [...options.tools, this.finishTool];
83
+ this.systemPrompt = options.systemPrompt ?? this.createSystemPrompt("");
84
+ this.history = [{ role: "system", content: this.systemPrompt }];
85
+ }
86
+ createSystemPrompt(objective) {
87
+ return `You are an AI agent executing a focused objective. Produce a result of type '${this.outputType}'.
88
+
89
+ ## Operating Mode
90
+ - Keep going until the objective is completed; do not hand back early.
91
+ - Resolve ambiguity by making reasonable assumptions and record them in \`metadata.notes\`.
92
+ - Prefer tool calls and concrete actions over clarifying questions.
93
+ - Do not reveal chain-of-thought; output only tool calls and required fields.
94
+
95
+ ## Communication Pattern (Tool Preambles)
96
+ - First assistant message: restate the objective in one sentence and list a 1-3 step plan.
97
+ - Before each tool call, add a one-sentence rationale describing what and why.
98
+ - After tool results, update the plan only if it materially changes.
99
+
100
+ ## Execution Protocol
101
+ 1. Focus on the objective: ${objective}
102
+ 2. Use the provided input values efficiently.
103
+ 3. Perform the minimal steps required to generate the result.
104
+ 4. Ensure the final result matches the expected output type: ${this.outputType}.
105
+ 5. Call \`finish_task\` exactly once at the end with final \`result\` and \`metadata\` (title, description, sources, notes).
106
+
107
+ ## Output Discipline
108
+ - Prefer deterministic, structured outputs over prose.
109
+ - Do not include multi-paragraph docstrings, multi-line comment blocks, or planning documents unless explicitly requested.`;
110
+ }
111
+ /**
112
+ * Check if the provider supports native agentic tool execution.
113
+ */
114
+ isAgenticProvider() {
115
+ return (this.provider.provider ===
116
+ "claude_agent");
117
+ }
118
+ async *execute(objective, inputs) {
119
+ const promptParts = [`**Objective:**\n${objective}\n`];
120
+ if (inputs && Object.keys(inputs).length > 0) {
121
+ const inputStr = Object.entries(inputs)
122
+ .map(([key, val]) => `- ${key}: ${formatValue(val)}`)
123
+ .join("\n");
124
+ promptParts.push(`**Input Values:**\n${inputStr}\n`);
125
+ }
126
+ promptParts.push("Please complete the objective using the provided input values.");
127
+ this.history.push({
128
+ role: "user",
129
+ content: promptParts.join("\n")
130
+ });
131
+ const providerTools = this.tools.map((t) => t.toProviderTool());
132
+ // --- Agentic provider fast-path ---
133
+ // The provider handles the full tool loop in a single call via MCP.
134
+ if (this.isAgenticProvider()) {
135
+ yield* this.executeAgentic(providerTools);
136
+ return;
137
+ }
138
+ // --- Standard multi-iteration loop (for non-agentic providers) ---
139
+ while (!this.completed && this.iterations < this.maxIterations) {
140
+ this.iterations += 1;
141
+ const response = await this.provider.generateMessageTraced({
142
+ messages: this.history,
143
+ model: this.model,
144
+ tools: providerTools,
145
+ threadId: this.threadId
146
+ });
147
+ if (response.content) {
148
+ yield {
149
+ type: "chunk",
150
+ content: String(response.content)
151
+ };
152
+ }
153
+ const assistantMessage = {
154
+ role: "assistant",
155
+ content: response.content,
156
+ toolCalls: response.toolCalls ?? undefined
157
+ };
158
+ this.history.push(assistantMessage);
159
+ if (response.toolCalls) {
160
+ for (const toolCall of response.toolCalls) {
161
+ yield toolCall;
162
+ const result = await this.handleToolCall(toolCall);
163
+ let serialized;
164
+ if (result == null) {
165
+ serialized = "Tool returned no output.";
166
+ }
167
+ else {
168
+ try {
169
+ serialized = JSON.stringify(result);
170
+ }
171
+ catch {
172
+ serialized = JSON.stringify({
173
+ error: "Failed to serialize tool result",
174
+ result_repr: String(result)
175
+ });
176
+ }
177
+ }
178
+ this.history.push({
179
+ role: "tool",
180
+ content: serialized,
181
+ toolCallId: toolCall.id
182
+ });
183
+ if (toolCall.name === "finish_task") {
184
+ this.completed = true;
185
+ this._result = toolCall.args.result ?? null;
186
+ this._metadata =
187
+ toolCall.args.metadata ?? null;
188
+ break;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ if (!this.completed) {
194
+ this.completed = true;
195
+ this._result = `Task incomplete after ${this.maxIterations} iterations`;
196
+ this._metadata = {
197
+ title: "Incomplete Task",
198
+ description: "Task did not complete within iteration limit",
199
+ sources: []
200
+ };
201
+ }
202
+ }
203
+ /**
204
+ * Agentic execution: single provider call handles all tool calls via MCP.
205
+ * The onToolCall callback executes tools natively; finish_task signals completion.
206
+ */
207
+ async *executeAgentic(providerTools) {
208
+ const finishTaskState = { args: null };
209
+ const getFinishTaskArgs = () => finishTaskState.args;
210
+ const onToolCall = async (name, args) => {
211
+ if (name === "finish_task") {
212
+ finishTaskState.args = args;
213
+ return JSON.stringify({ status: "finished" });
214
+ }
215
+ const tool = this.tools.find((t) => t.name === name);
216
+ if (!tool)
217
+ return JSON.stringify({ error: `Unknown tool: ${name}` });
218
+ try {
219
+ const result = await tool.process(this.context, args);
220
+ const raw = typeof result === "string" ? result : JSON.stringify(result ?? null);
221
+ if (raw.length > 25_000) {
222
+ return (raw.slice(0, 25_000) +
223
+ `\n...[truncated ${raw.length - 25_000} chars]`);
224
+ }
225
+ return raw;
226
+ }
227
+ catch (e) {
228
+ return JSON.stringify({ error: String(e) });
229
+ }
230
+ };
231
+ const response = await this.provider.generateMessageTraced({
232
+ messages: this.history,
233
+ model: this.model,
234
+ tools: providerTools,
235
+ threadId: this.threadId,
236
+ onToolCall
237
+ });
238
+ if (response.content) {
239
+ yield { type: "chunk", content: String(response.content) };
240
+ }
241
+ // Yield tool calls for tracking
242
+ if (response.toolCalls) {
243
+ for (const tc of response.toolCalls) {
244
+ yield tc;
245
+ }
246
+ }
247
+ // Check if finish_task was called via MCP
248
+ const initialFinishTaskArgs = getFinishTaskArgs();
249
+ if (initialFinishTaskArgs) {
250
+ this.completed = true;
251
+ this._result = initialFinishTaskArgs.result ?? null;
252
+ this._metadata = initialFinishTaskArgs.metadata ?? null;
253
+ return;
254
+ }
255
+ // Fallback: send a nudge to call finish_task
256
+ const nudgeMessages = [
257
+ ...this.history,
258
+ { role: "assistant", content: String(response.content ?? "") },
259
+ {
260
+ role: "user",
261
+ content: `Now call finish_task with the final result and metadata. The result type should be '${this.outputType}'.`
262
+ }
263
+ ];
264
+ finishTaskState.args = null;
265
+ const nudgeResponse = await this.provider.generateMessageTraced({
266
+ messages: nudgeMessages,
267
+ model: this.model,
268
+ tools: providerTools,
269
+ threadId: this.threadId,
270
+ onToolCall
271
+ });
272
+ if (nudgeResponse.content) {
273
+ yield { type: "chunk", content: String(nudgeResponse.content) };
274
+ }
275
+ if (nudgeResponse.toolCalls) {
276
+ for (const tc of nudgeResponse.toolCalls) {
277
+ yield tc;
278
+ }
279
+ }
280
+ const nudgedFinishTaskArgs = getFinishTaskArgs();
281
+ if (nudgedFinishTaskArgs) {
282
+ this.completed = true;
283
+ this._result = nudgedFinishTaskArgs.result ?? null;
284
+ this._metadata = nudgedFinishTaskArgs.metadata ?? null;
285
+ }
286
+ else {
287
+ this.completed = true;
288
+ this._result = String(response.content ?? "Task incomplete");
289
+ this._metadata = {
290
+ title: "Incomplete Task",
291
+ description: "finish_task was not called"
292
+ };
293
+ }
294
+ }
295
+ async handleToolCall(toolCall) {
296
+ const tool = this.tools.find((t) => t.name === toolCall.name);
297
+ if (!tool) {
298
+ return { error: `Tool ${toolCall.name} not found` };
299
+ }
300
+ try {
301
+ return await tool.process(this.context, toolCall.args);
302
+ }
303
+ catch (e) {
304
+ return { error: String(e) };
305
+ }
306
+ }
307
+ getResult() {
308
+ return this._result;
309
+ }
310
+ getMetadata() {
311
+ return this._metadata;
312
+ }
313
+ }
314
+ function formatValue(value) {
315
+ if (typeof value === "string") {
316
+ return value.length > 200 ? value.slice(0, 200) + "..." : value;
317
+ }
318
+ if (typeof value === "object" && value !== null) {
319
+ const formatted = JSON.stringify(value, null, 2);
320
+ return formatted.length > 200 ? formatted.slice(0, 200) + "..." : formatted;
321
+ }
322
+ return String(value);
323
+ }
324
+ //# sourceMappingURL=agent-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-executor.js","sourceRoot":"","sources":["../src/agent-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,eAAe,GAA4B;IAC/C,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/B,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;KACtD;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;IAClC,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,MAAM,OAAO,GAA4C;QACvD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;QACpD,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE;QACvD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;QACtD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE;QACxD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE;QAC1D,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;QACpE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;QACpD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AAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACjD,OAAO,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * AgentStepExecutor -- a NodeExecutor adapter that wraps StepExecutor.
3
+ *
4
+ * This bridges the agent system into the kernel: when WorkflowRunner encounters
5
+ * a node of type "nodetool.agents.AgentStep", it resolves to this executor.
6
+ * The executor creates a StepExecutor internally, runs the LLM tool-calling
7
+ * loop, forwards ProcessingMessages via context.emit(), and returns the
8
+ * final result as a Record for downstream kernel routing.
9
+ */
10
+ import type { NodeExecutor } from "@nodetool-ai/runtime";
11
+ import type { ProcessingContext, BaseProvider } from "@nodetool-ai/runtime";
12
+ import type { NodeDescriptor } from "@nodetool-ai/protocol";
13
+ import type { Tool } from "./tools/base-tool.js";
14
+ export interface AgentStepExecutorOptions {
15
+ provider: BaseProvider;
16
+ model: string;
17
+ tools: Tool[];
18
+ systemPrompt?: string;
19
+ maxTokenLimit?: number;
20
+ maxIterations?: number;
21
+ }
22
+ export declare class AgentStepExecutor implements NodeExecutor {
23
+ private readonly node;
24
+ private readonly opts;
25
+ constructor(node: NodeDescriptor, opts: AgentStepExecutorOptions);
26
+ process(inputs: Record<string, unknown>, context?: ProcessingContext): Promise<Record<string, unknown>>;
27
+ }
28
+ //# sourceMappingURL=agent-step-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-step-executor.d.ts","sourceRoot":"","sources":["../src/agent-step-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA4CD,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;gBAEpC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,wBAAwB;IAK1D,OAAO,CACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAoDpC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * AgentStepExecutor -- a NodeExecutor adapter that wraps StepExecutor.
3
+ *
4
+ * This bridges the agent system into the kernel: when WorkflowRunner encounters
5
+ * a node of type "nodetool.agents.AgentStep", it resolves to this executor.
6
+ * The executor creates a StepExecutor internally, runs the LLM tool-calling
7
+ * loop, forwards ProcessingMessages via context.emit(), and returns the
8
+ * final result as a Record for downstream kernel routing.
9
+ */
10
+ import { StepExecutor } from "./step-executor.js";
11
+ import { randomUUID } from "node:crypto";
12
+ /**
13
+ * Build a Step object from a NodeDescriptor with AgentStep properties.
14
+ */
15
+ function stepFromDescriptor(node) {
16
+ const props = (node.properties ?? {});
17
+ return {
18
+ id: node.id,
19
+ instructions: typeof props["instructions"] === "string" ? props["instructions"] : "",
20
+ completed: false,
21
+ dependsOn: [],
22
+ outputSchema: typeof props["output_schema"] === "string"
23
+ ? props["output_schema"]
24
+ : undefined,
25
+ tools: Array.isArray(props["tools"])
26
+ ? props["tools"]
27
+ : undefined,
28
+ logs: []
29
+ };
30
+ }
31
+ /**
32
+ * Format upstream inputs (arriving via kernel edges) into a context string
33
+ * that gets prepended to the step instructions.
34
+ */
35
+ function formatUpstreamContext(inputs) {
36
+ const entries = Object.entries(inputs).filter(([, v]) => v !== undefined && v !== null);
37
+ if (entries.length === 0)
38
+ return "";
39
+ const sections = entries.map(([key, value]) => {
40
+ const serialized = typeof value === "string" ? value : JSON.stringify(value, null, 2);
41
+ return `## Input "${key}":\n${serialized}`;
42
+ });
43
+ return ("# Upstream Results\n\n" + sections.join("\n\n") + "\n\n---\n\n");
44
+ }
45
+ export class AgentStepExecutor {
46
+ node;
47
+ opts;
48
+ constructor(node, opts) {
49
+ this.node = node;
50
+ this.opts = opts;
51
+ }
52
+ async process(inputs, context) {
53
+ const step = stepFromDescriptor(this.node);
54
+ const task = {
55
+ id: randomUUID(),
56
+ title: step.instructions.slice(0, 80),
57
+ steps: [step]
58
+ };
59
+ // Prepend upstream results to step instructions
60
+ const upstreamContext = formatUpstreamContext(inputs);
61
+ if (upstreamContext) {
62
+ step.instructions = upstreamContext + step.instructions;
63
+ }
64
+ // Filter tools if the step specifies a subset
65
+ let tools = this.opts.tools;
66
+ if (step.tools && step.tools.length > 0) {
67
+ const allowedNames = new Set(step.tools);
68
+ tools = tools.filter((t) => allowedNames.has(t.name));
69
+ }
70
+ const executor = new StepExecutor({
71
+ task,
72
+ step,
73
+ context: context,
74
+ provider: this.opts.provider,
75
+ model: this.opts.model,
76
+ tools,
77
+ systemPrompt: this.opts.systemPrompt,
78
+ maxTokenLimit: this.opts.maxTokenLimit,
79
+ maxIterations: this.opts.maxIterations
80
+ });
81
+ let result = null;
82
+ for await (const msg of executor.execute()) {
83
+ // Forward processing messages for UI updates
84
+ if (context) {
85
+ context.emit(msg);
86
+ }
87
+ if (msg.type === "step_result") {
88
+ result = msg.result;
89
+ }
90
+ }
91
+ // Also store in context for backwards compat with code reading from context
92
+ if (context) {
93
+ context.set(this.node.id, result);
94
+ }
95
+ // Use "output" as the handle name so downstream nodes can connect via .output
96
+ return { output: result, result };
97
+ }
98
+ }
99
+ //# sourceMappingURL=agent-step-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-step-executor.js","sourceRoot":"","sources":["../src/agent-step-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAoB;IAC9C,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAA4B,CAAC;IACjE,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,YAAY,EACV,OAAO,KAAK,CAAC,cAAc,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE;QACxE,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,EAAE;QACb,YAAY,EACV,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,QAAQ;YACxC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;YACxB,CAAC,CAAC,SAAS;QACf,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC,CAAE,KAAK,CAAC,OAAO,CAAc;YAC9B,CAAC,CAAC,SAAS;QACb,IAAI,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C/B,MAAM,GAAI,GAAkB,CAAC,MAAM,CAAC;YACtC,CAAC;QACH,CAAC;QAED,4EAA4E;QAC5E,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAED,8EAA8E;QAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * AgentWorkflowRunner -- executes a graph plan via the kernel's WorkflowRunner.
3
+ *
4
+ * Takes a GraphData (produced by GraphPlanner) and runs it through the kernel.
5
+ * Agent step nodes are resolved via AgentStepExecutor; deterministic nodes
6
+ * are resolved via the provided NodeRegistry.
7
+ */
8
+ import type { NodeRegistry } from "@nodetool-ai/node-sdk";
9
+ import type { BaseProvider, ProcessingContext } from "@nodetool-ai/runtime";
10
+ import type { GraphData, ProcessingMessage } from "@nodetool-ai/protocol";
11
+ import type { Tool } from "./tools/base-tool.js";
12
+ export interface AgentWorkflowRunnerOptions {
13
+ provider: BaseProvider;
14
+ model: string;
15
+ registry: NodeRegistry;
16
+ tools: Tool[];
17
+ context: ProcessingContext;
18
+ systemPrompt?: string;
19
+ maxTokenLimit?: number;
20
+ maxStepIterations?: number;
21
+ inputs?: Record<string, unknown>;
22
+ }
23
+ export declare class AgentWorkflowRunner {
24
+ private readonly opts;
25
+ constructor(opts: AgentWorkflowRunnerOptions);
26
+ /**
27
+ * Execute a graph plan and yield ProcessingMessages live as the kernel emits them.
28
+ */
29
+ execute(graphData: GraphData): AsyncGenerator<ProcessingMessage>;
30
+ }
31
+ //# sourceMappingURL=agent-workflow-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-workflow-runner.d.ts","sourceRoot":"","sources":["../src/agent-workflow-runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EAGlB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAKjD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;gBAEtC,IAAI,EAAE,0BAA0B;IAI5C;;OAEG;IACI,OAAO,CACZ,SAAS,EAAE,SAAS,GACnB,cAAc,CAAC,iBAAiB,CAAC;CAmHrC"}