typed-agents 1.0.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 (127) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +201 -0
  3. package/dist/agents/agent.decorator.d.ts +19 -0
  4. package/dist/agents/agent.decorator.d.ts.map +1 -0
  5. package/dist/agents/agent.decorator.js +38 -0
  6. package/dist/agents/agent.decorator.js.map +1 -0
  7. package/dist/agents/agent.runtime.d.ts +133 -0
  8. package/dist/agents/agent.runtime.d.ts.map +1 -0
  9. package/dist/agents/agent.runtime.js +593 -0
  10. package/dist/agents/agent.runtime.js.map +1 -0
  11. package/dist/agents/agent.types.d.ts +245 -0
  12. package/dist/agents/agent.types.d.ts.map +1 -0
  13. package/dist/agents/agent.types.js +27 -0
  14. package/dist/agents/agent.types.js.map +1 -0
  15. package/dist/agents/behavior-engine/behavior.types.d.ts +23 -0
  16. package/dist/agents/behavior-engine/behavior.types.d.ts.map +1 -0
  17. package/dist/agents/behavior-engine/behavior.types.js +3 -0
  18. package/dist/agents/behavior-engine/behavior.types.js.map +1 -0
  19. package/dist/agents/behavior-engine/build-system-prompt.d.ts +12 -0
  20. package/dist/agents/behavior-engine/build-system-prompt.d.ts.map +1 -0
  21. package/dist/agents/behavior-engine/build-system-prompt.js +29 -0
  22. package/dist/agents/behavior-engine/build-system-prompt.js.map +1 -0
  23. package/dist/agents/behavior-engine/index.d.ts +7 -0
  24. package/dist/agents/behavior-engine/index.d.ts.map +1 -0
  25. package/dist/agents/behavior-engine/index.js +23 -0
  26. package/dist/agents/behavior-engine/index.js.map +1 -0
  27. package/dist/agents/behavior-engine/load-behavior.d.ts +16 -0
  28. package/dist/agents/behavior-engine/load-behavior.d.ts.map +1 -0
  29. package/dist/agents/behavior-engine/load-behavior.js +36 -0
  30. package/dist/agents/behavior-engine/load-behavior.js.map +1 -0
  31. package/dist/agents/behavior-engine/merge-behavior.d.ts +12 -0
  32. package/dist/agents/behavior-engine/merge-behavior.d.ts.map +1 -0
  33. package/dist/agents/behavior-engine/merge-behavior.js +33 -0
  34. package/dist/agents/behavior-engine/merge-behavior.js.map +1 -0
  35. package/dist/agents/behavior-engine/parse-behavior.d.ts +10 -0
  36. package/dist/agents/behavior-engine/parse-behavior.d.ts.map +1 -0
  37. package/dist/agents/behavior-engine/parse-behavior.js +66 -0
  38. package/dist/agents/behavior-engine/parse-behavior.js.map +1 -0
  39. package/dist/agents/behavior-engine/watch-behavior.d.ts +10 -0
  40. package/dist/agents/behavior-engine/watch-behavior.d.ts.map +1 -0
  41. package/dist/agents/behavior-engine/watch-behavior.js +34 -0
  42. package/dist/agents/behavior-engine/watch-behavior.js.map +1 -0
  43. package/dist/agents/compose.d.ts +41 -0
  44. package/dist/agents/compose.d.ts.map +1 -0
  45. package/dist/agents/compose.js +29 -0
  46. package/dist/agents/compose.js.map +1 -0
  47. package/dist/agents/index.d.ts +7 -0
  48. package/dist/agents/index.d.ts.map +1 -0
  49. package/dist/agents/index.js +25 -0
  50. package/dist/agents/index.js.map +1 -0
  51. package/dist/agents/runtime-engine/build-tool-map.d.ts +16 -0
  52. package/dist/agents/runtime-engine/build-tool-map.d.ts.map +1 -0
  53. package/dist/agents/runtime-engine/build-tool-map.js +88 -0
  54. package/dist/agents/runtime-engine/build-tool-map.js.map +1 -0
  55. package/dist/agents/runtime-engine/convert-zod-to-tool-schema.d.ts +13 -0
  56. package/dist/agents/runtime-engine/convert-zod-to-tool-schema.d.ts.map +1 -0
  57. package/dist/agents/runtime-engine/convert-zod-to-tool-schema.js +26 -0
  58. package/dist/agents/runtime-engine/convert-zod-to-tool-schema.js.map +1 -0
  59. package/dist/agents/runtime-engine/execute-tool.d.ts +19 -0
  60. package/dist/agents/runtime-engine/execute-tool.d.ts.map +1 -0
  61. package/dist/agents/runtime-engine/execute-tool.js +100 -0
  62. package/dist/agents/runtime-engine/execute-tool.js.map +1 -0
  63. package/dist/agents/runtime-engine/index.d.ts +7 -0
  64. package/dist/agents/runtime-engine/index.d.ts.map +1 -0
  65. package/dist/agents/runtime-engine/index.js +23 -0
  66. package/dist/agents/runtime-engine/index.js.map +1 -0
  67. package/dist/agents/runtime-engine/parse-tool-arguments.d.ts +12 -0
  68. package/dist/agents/runtime-engine/parse-tool-arguments.d.ts.map +1 -0
  69. package/dist/agents/runtime-engine/parse-tool-arguments.js +42 -0
  70. package/dist/agents/runtime-engine/parse-tool-arguments.js.map +1 -0
  71. package/dist/agents/runtime-engine/retry.utils.d.ts +26 -0
  72. package/dist/agents/runtime-engine/retry.utils.d.ts.map +1 -0
  73. package/dist/agents/runtime-engine/retry.utils.js +55 -0
  74. package/dist/agents/runtime-engine/retry.utils.js.map +1 -0
  75. package/dist/agents/runtime-engine/state-persistence.d.ts +56 -0
  76. package/dist/agents/runtime-engine/state-persistence.d.ts.map +1 -0
  77. package/dist/agents/runtime-engine/state-persistence.js +70 -0
  78. package/dist/agents/runtime-engine/state-persistence.js.map +1 -0
  79. package/dist/clients/index.d.ts +3 -0
  80. package/dist/clients/index.d.ts.map +1 -0
  81. package/dist/clients/index.js +19 -0
  82. package/dist/clients/index.js.map +1 -0
  83. package/dist/clients/llm.client.d.ts +48 -0
  84. package/dist/clients/llm.client.d.ts.map +1 -0
  85. package/dist/clients/llm.client.js +3 -0
  86. package/dist/clients/llm.client.js.map +1 -0
  87. package/dist/clients/ollama.client.d.ts +20 -0
  88. package/dist/clients/ollama.client.d.ts.map +1 -0
  89. package/dist/clients/ollama.client.js +85 -0
  90. package/dist/clients/ollama.client.js.map +1 -0
  91. package/dist/core/logger/index.d.ts +2 -0
  92. package/dist/core/logger/index.d.ts.map +1 -0
  93. package/dist/core/logger/index.js +18 -0
  94. package/dist/core/logger/index.js.map +1 -0
  95. package/dist/core/logger/logger.d.ts +7 -0
  96. package/dist/core/logger/logger.d.ts.map +1 -0
  97. package/dist/core/logger/logger.js +19 -0
  98. package/dist/core/logger/logger.js.map +1 -0
  99. package/dist/index.d.ts +6 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +22 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/runtime/agent.runner.d.ts +29 -0
  104. package/dist/runtime/agent.runner.d.ts.map +1 -0
  105. package/dist/runtime/agent.runner.js +39 -0
  106. package/dist/runtime/agent.runner.js.map +1 -0
  107. package/dist/runtime/index.d.ts +2 -0
  108. package/dist/runtime/index.d.ts.map +1 -0
  109. package/dist/runtime/index.js +18 -0
  110. package/dist/runtime/index.js.map +1 -0
  111. package/dist/tools/index.d.ts +4 -0
  112. package/dist/tools/index.d.ts.map +1 -0
  113. package/dist/tools/index.js +20 -0
  114. package/dist/tools/index.js.map +1 -0
  115. package/dist/tools/registry.d.ts +128 -0
  116. package/dist/tools/registry.d.ts.map +1 -0
  117. package/dist/tools/registry.js +140 -0
  118. package/dist/tools/registry.js.map +1 -0
  119. package/dist/tools/tool.decorator.d.ts +71 -0
  120. package/dist/tools/tool.decorator.d.ts.map +1 -0
  121. package/dist/tools/tool.decorator.js +98 -0
  122. package/dist/tools/tool.decorator.js.map +1 -0
  123. package/dist/tools/tool.types.d.ts +231 -0
  124. package/dist/tools/tool.types.d.ts.map +1 -0
  125. package/dist/tools/tool.types.js +3 -0
  126. package/dist/tools/tool.types.js.map +1 -0
  127. package/package.json +45 -0
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.watchBehaviors = watchBehaviors;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const parse_behavior_1 = require("./parse-behavior");
10
+ const logger_1 = require("../../core/logger/logger");
11
+ let watcher = null;
12
+ /**
13
+ * Sets up file watching for behavior files in a directory.
14
+ *
15
+ * Watches for changes to .md files and clears the behavior cache on changes,
16
+ * enabling hot-reload of behaviors during development.
17
+ *
18
+ * @param dir - Directory path to watch for behavior files.
19
+ */
20
+ function watchBehaviors(dir) {
21
+ const fullPath = path_1.default.resolve(dir);
22
+ if (watcher)
23
+ return;
24
+ logger_1.Logger.info(`👀 Watching behaviors in: ${fullPath}`);
25
+ watcher = fs_1.default.watch(fullPath, { recursive: true }, (eventType, filename) => {
26
+ if (!filename)
27
+ return;
28
+ if (!filename.endsWith(".md"))
29
+ return;
30
+ logger_1.Logger.warn(`♻️ Behavior changed: ${filename}`);
31
+ (0, parse_behavior_1.clearBehaviorCache)();
32
+ });
33
+ }
34
+ //# sourceMappingURL=watch-behavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-behavior.js","sourceRoot":"","sources":["../../../src/agents/behavior-engine/watch-behavior.ts"],"names":[],"mappings":";;;;;AAeA,wCAmBC;AAlCD,4CAAoB;AACpB,gDAAwB;AACxB,qDAAsD;AACtD,qDAAkD;AAElD,IAAI,OAAO,GAAwB,IAAI,CAAC;AAExC;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEnC,IAAI,OAAO;QAAE,OAAO;IAEpB,eAAM,CAAC,IAAI,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;IAErD,OAAO,GAAG,YAAE,CAAC,KAAK,CAChB,QAAQ,EACR,EAAE,SAAS,EAAE,IAAI,EAAE,EACnB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;QACtB,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAEtC,eAAM,CAAC,IAAI,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QAChD,IAAA,mCAAkB,GAAE,CAAC;IACvB,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { ToolDependency } from "./agent.types";
2
+ /**
3
+ * Represents a tool that wraps a dedicated agent class for composable execution.
4
+ * When invoked, it runs the agent as a sub-agent within the parent agent's context.
5
+ */
6
+ export interface ComposableTool {
7
+ /** Marker property to identify composable tools. Always true. */
8
+ __isComposable: true;
9
+ /** The agent class to instantiate and run when the tool is called. */
10
+ AgentClass: new () => object;
11
+ /** Optional name for the tool (defaults to agent name). */
12
+ name?: string;
13
+ /** Optional description of what the tool does. */
14
+ description?: string;
15
+ /** Key in the input object that contains the task/prompt for the sub-agent. */
16
+ inputKey: string;
17
+ /** Maximum steps the sub-agent is allowed to take. */
18
+ maxSteps?: number;
19
+ }
20
+ /**
21
+ * Creates a composable tool from an agent class.
22
+ *
23
+ * This allows an agent to be used as a tool within another agent, enabling
24
+ * hierarchical multi-agent workflows. The composed agent will be run as a
25
+ * sub-agent when the tool is invoked.
26
+ *
27
+ * @param AgentClass - The agent class to compose into a tool.
28
+ * @param options - Configuration options for the composable tool.
29
+ * @param options.name - Optional name for the tool (defaults to agent's name).
30
+ * @param options.description - Optional description of the tool's purpose.
31
+ * @param options.inputKey - Key for the input task (defaults to "task").
32
+ * @param options.maxSteps - Maximum steps for the sub-agent.
33
+ * @returns A ToolDependency that can be used in agent options.
34
+ */
35
+ export declare function compose<T extends new () => object>(AgentClass: T, options?: {
36
+ name?: string;
37
+ description?: string;
38
+ inputKey?: string;
39
+ maxSteps?: number;
40
+ }): ToolDependency;
41
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/agents/compose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,cAAc,EAAE,IAAI,CAAC;IACrB,sEAAsE;IACtE,UAAU,EAAE,UAAU,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,MAAM,EAChD,UAAU,EAAE,CAAC,EACb,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,cAAc,CAShB"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compose = compose;
4
+ /**
5
+ * Creates a composable tool from an agent class.
6
+ *
7
+ * This allows an agent to be used as a tool within another agent, enabling
8
+ * hierarchical multi-agent workflows. The composed agent will be run as a
9
+ * sub-agent when the tool is invoked.
10
+ *
11
+ * @param AgentClass - The agent class to compose into a tool.
12
+ * @param options - Configuration options for the composable tool.
13
+ * @param options.name - Optional name for the tool (defaults to agent's name).
14
+ * @param options.description - Optional description of the tool's purpose.
15
+ * @param options.inputKey - Key for the input task (defaults to "task").
16
+ * @param options.maxSteps - Maximum steps for the sub-agent.
17
+ * @returns A ToolDependency that can be used in agent options.
18
+ */
19
+ function compose(AgentClass, options = {}) {
20
+ return {
21
+ __isComposable: true,
22
+ AgentClass,
23
+ name: options.name,
24
+ description: options.description,
25
+ inputKey: options.inputKey ?? "task",
26
+ maxSteps: options.maxSteps,
27
+ };
28
+ }
29
+ //# sourceMappingURL=compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/agents/compose.ts"],"names":[],"mappings":";;AAoCA,0BAiBC;AAhCD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,OAAO,CACrB,UAAa,EACb,UAKI,EAAE;IAEN,OAAO;QACL,cAAc,EAAE,IAAI;QACpB,UAAU;QACV,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,MAAM;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KACT,CAAC;AACtB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './agent.decorator';
2
+ export * from './agent.types';
3
+ export * from './agent.runtime';
4
+ export { compose } from './compose';
5
+ export * from './runtime-engine';
6
+ export * from './behavior-engine';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.compose = void 0;
18
+ __exportStar(require("./agent.decorator"), exports);
19
+ __exportStar(require("./agent.types"), exports);
20
+ __exportStar(require("./agent.runtime"), exports);
21
+ var compose_1 = require("./compose");
22
+ Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.compose; } });
23
+ __exportStar(require("./runtime-engine"), exports);
24
+ __exportStar(require("./behavior-engine"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,gDAA8B;AAC9B,kDAAgC;AAChC,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,mDAAiC;AACjC,oDAAkC"}
@@ -0,0 +1,16 @@
1
+ import type { ToolDefinition } from "../../tools/tool.types";
2
+ import { ToolMapEntry } from "../../tools/tool.types";
3
+ import type { ToolDependency } from "../agent.types";
4
+ /**
5
+ * Builds the tool dispatch map and LLM tool definitions from agent tool dependencies.
6
+ *
7
+ * Processes each ToolDependency: for "auto", fetches all registered tools; for classes/instances,
8
+ * extracts registered methods; for composable tools, creates synthetic tool entries.
9
+ * Populates the toolMap for runtime dispatch and llmTools for LLM API calls.
10
+ *
11
+ * @param tools - Array of tool dependencies from agent options.
12
+ * @param toolMap - Map to populate with tool name -> ToolMapEntry for execution.
13
+ * @param llmTools - Array to populate with ToolDefinition objects for LLM.
14
+ */
15
+ export declare const buildToolMap: (tools: ToolDependency[], toolMap: Map<string, ToolMapEntry>, llmTools: ToolDefinition[]) => void;
16
+ //# sourceMappingURL=build-tool-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-tool-map.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/build-tool-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,cAAc,EAAE,EACvB,SAAS,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAClC,UAAU,cAAc,EAAE,SA8E3B,CAAC"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildToolMap = void 0;
4
+ const registry_1 = require("../../tools/registry");
5
+ const convert_zod_to_tool_schema_1 = require("./convert-zod-to-tool-schema");
6
+ const agent_types_1 = require("../agent.types");
7
+ const agent_decorator_1 = require("../agent.decorator");
8
+ const zod_1 = require("zod");
9
+ /**
10
+ * Builds the tool dispatch map and LLM tool definitions from agent tool dependencies.
11
+ *
12
+ * Processes each ToolDependency: for "auto", fetches all registered tools; for classes/instances,
13
+ * extracts registered methods; for composable tools, creates synthetic tool entries.
14
+ * Populates the toolMap for runtime dispatch and llmTools for LLM API calls.
15
+ *
16
+ * @param tools - Array of tool dependencies from agent options.
17
+ * @param toolMap - Map to populate with tool name -> ToolMapEntry for execution.
18
+ * @param llmTools - Array to populate with ToolDefinition objects for LLM.
19
+ */
20
+ const buildToolMap = (tools, toolMap, llmTools) => {
21
+ const processedTools = tools.flatMap((t) => t === "auto" ? registry_1.ToolRegistry.getAllRegisteredClasses() : [t]);
22
+ for (const t of processedTools) {
23
+ if (!(0, agent_types_1.isComposableTool)(t)) {
24
+ const isInstance = typeof t === "object";
25
+ const instance = isInstance ? t : new t();
26
+ const cls = isInstance ? t.constructor : t;
27
+ const registryTools = registry_1.ToolRegistry.getTools(cls);
28
+ for (const rt of registryTools) {
29
+ if (toolMap.has(rt.metadata.name))
30
+ continue;
31
+ toolMap.set(rt.metadata.name, {
32
+ instance,
33
+ method: rt.method,
34
+ metadata: rt.metadata,
35
+ });
36
+ llmTools.push({
37
+ type: "function",
38
+ function: {
39
+ name: rt.metadata.name,
40
+ description: rt.metadata.description,
41
+ parameters: rt.metadata.inputSchema
42
+ ? (0, convert_zod_to_tool_schema_1.convertZodToToolSchema)(rt.metadata.inputSchema)
43
+ : { type: "object", properties: {} },
44
+ },
45
+ });
46
+ }
47
+ continue;
48
+ }
49
+ const comp = t;
50
+ const agentMeta = (0, agent_decorator_1.getAgentMetadata)(comp.AgentClass);
51
+ if (!agentMeta)
52
+ continue;
53
+ const toolName = comp.name ?? agentMeta.name;
54
+ if (toolMap.has(toolName))
55
+ continue;
56
+ const inputKey = comp.inputKey;
57
+ const inputSchema = zod_1.z.object({
58
+ [inputKey]: zod_1.z.string().describe("Task/prompt for the sub-agent"),
59
+ });
60
+ toolMap.set(toolName, {
61
+ instance: null,
62
+ method: "__run_composable__",
63
+ metadata: {
64
+ name: toolName,
65
+ description: comp.description ??
66
+ `Delegates task to specialized agent "${toolName}"`,
67
+ inputSchema,
68
+ isComposable: true,
69
+ agentClass: comp.AgentClass,
70
+ maxSteps: comp.maxSteps,
71
+ },
72
+ });
73
+ llmTools.push({
74
+ type: "function",
75
+ function: {
76
+ name: toolName,
77
+ description: comp.description ?? `Call the ${toolName} agent`,
78
+ parameters: {
79
+ type: "object",
80
+ properties: { [inputKey]: { type: "string" } },
81
+ required: [inputKey],
82
+ },
83
+ },
84
+ });
85
+ }
86
+ };
87
+ exports.buildToolMap = buildToolMap;
88
+ //# sourceMappingURL=build-tool-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-tool-map.js","sourceRoot":"","sources":["../../../src/agents/runtime-engine/build-tool-map.ts"],"names":[],"mappings":";;;AAAA,mDAAoD;AACpD,6EAAsE;AAItE,gDAAkD;AAClD,wDAAsD;AACtD,6BAAwB;AAExB;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAC1B,KAAuB,EACvB,OAAkC,EAClC,QAA0B,EAC1B,EAAE;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACzC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,uBAAY,CAAC,uBAAuB,EAAE,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jFW,QAAA,YAAY,gBAiFvB"}
@@ -0,0 +1,13 @@
1
+ import { ZodType } from "zod";
2
+ import type { ToolParameterSchema } from "../../tools/tool.types";
3
+ /**
4
+ * Converts a Zod schema to a JSON Schema compatible with LLM tool definitions.
5
+ *
6
+ * Uses zod-to-json-schema to transform the Zod type into a JSON Schema object,
7
+ * stripping metadata like $schema and definitions for cleaner tool parameters.
8
+ *
9
+ * @param zodSchema - The Zod schema to convert.
10
+ * @returns A ToolParameterSchema object for LLM tool parameters.
11
+ */
12
+ export declare const convertZodToToolSchema: (zodSchema: ZodType) => ToolParameterSchema;
13
+ //# sourceMappingURL=convert-zod-to-tool-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-zod-to-tool-schema.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/convert-zod-to-tool-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,OAAO,KACjB,mBAWF,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.convertZodToToolSchema = void 0;
7
+ const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
8
+ /**
9
+ * Converts a Zod schema to a JSON Schema compatible with LLM tool definitions.
10
+ *
11
+ * Uses zod-to-json-schema to transform the Zod type into a JSON Schema object,
12
+ * stripping metadata like $schema and definitions for cleaner tool parameters.
13
+ *
14
+ * @param zodSchema - The Zod schema to convert.
15
+ * @returns A ToolParameterSchema object for LLM tool parameters.
16
+ */
17
+ const convertZodToToolSchema = (zodSchema) => {
18
+ const jsonSchema = (0, zod_to_json_schema_1.default)(zodSchema);
19
+ const { $schema, definitions, ...rest } = jsonSchema;
20
+ return {
21
+ type: "object",
22
+ ...rest,
23
+ };
24
+ };
25
+ exports.convertZodToToolSchema = convertZodToToolSchema;
26
+ //# sourceMappingURL=convert-zod-to-tool-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-zod-to-tool-schema.js","sourceRoot":"","sources":["../../../src/agents/runtime-engine/convert-zod-to-tool-schema.ts"],"names":[],"mappings":";;;;;;AAAA,4EAAiD;AAIjD;;;;;;;;GAQG;AACI,MAAM,sBAAsB,GAAG,CACpC,SAAkB,EACG,EAAE;IACvB,MAAM,UAAU,GAAG,IAAA,4BAAe,EAChC,SAA6D,CACnC,CAAC;IAE7B,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAC;IAErD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,GAAI,IAA0C;KAC/C,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC"}
@@ -0,0 +1,19 @@
1
+ import { ToolMapEntry } from "../../tools/tool.types";
2
+ import type { RunOptions, ToolResult } from "../agent.types";
3
+ /**
4
+ * Executes a tool by name using the provided arguments and tool map.
5
+ *
6
+ * Handles both regular tool methods (calling instance methods) and composable sub-agents
7
+ * (running dedicated agent classes). Performs argument parsing, input validation,
8
+ * caching for sub-agents, and output validation. Returns a structured ToolResult
9
+ * indicating success or failure.
10
+ *
11
+ * @param name - The tool name to execute.
12
+ * @param rawArgs - Raw arguments from the LLM tool call.
13
+ * @param toolMap - Map of tool names to ToolMapEntry for dispatch.
14
+ * @param subAgentOptions - Options for sub-agent execution (maxSteps, etc.).
15
+ * @param subAgentCache - Cache map for sub-agent results to avoid re-execution.
16
+ * @returns A ToolResult with success value or error details.
17
+ */
18
+ export declare const executeTool: (name: string, rawArgs: unknown, toolMap: Map<string, ToolMapEntry>, subAgentOptions?: RunOptions, subAgentCache?: Map<string, string>) => Promise<ToolResult>;
19
+ //# sourceMappingURL=execute-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-tool.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/execute-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI7D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,SAAS,OAAO,EAChB,SAAS,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAClC,kBAAiB,UAAe,EAChC,gBAAe,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,KAC7C,OAAO,CAAC,UAAU,CAkGpB,CAAC"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.executeTool = void 0;
7
+ const parse_tool_arguments_1 = require("./parse-tool-arguments");
8
+ const agent_runner_1 = require("../../runtime/agent.runner");
9
+ const agent_types_1 = require("../agent.types");
10
+ const crypto_1 = __importDefault(require("crypto"));
11
+ /**
12
+ * Executes a tool by name using the provided arguments and tool map.
13
+ *
14
+ * Handles both regular tool methods (calling instance methods) and composable sub-agents
15
+ * (running dedicated agent classes). Performs argument parsing, input validation,
16
+ * caching for sub-agents, and output validation. Returns a structured ToolResult
17
+ * indicating success or failure.
18
+ *
19
+ * @param name - The tool name to execute.
20
+ * @param rawArgs - Raw arguments from the LLM tool call.
21
+ * @param toolMap - Map of tool names to ToolMapEntry for dispatch.
22
+ * @param subAgentOptions - Options for sub-agent execution (maxSteps, etc.).
23
+ * @param subAgentCache - Cache map for sub-agent results to avoid re-execution.
24
+ * @returns A ToolResult with success value or error details.
25
+ */
26
+ const executeTool = async (name, rawArgs, toolMap, subAgentOptions = {}, subAgentCache = new Map()) => {
27
+ const entry = toolMap.get(name);
28
+ if (!entry) {
29
+ return (0, agent_types_1.toolFailure)(name, `Tool "${name}" not found in tool map.`);
30
+ }
31
+ const { instance, method, metadata } = entry;
32
+ // P2: parsing errors are now surfaced, not silently swallowed
33
+ let parsedInput;
34
+ try {
35
+ parsedInput = (0, parse_tool_arguments_1.parseToolArguments)(rawArgs);
36
+ }
37
+ catch (err) {
38
+ return (0, agent_types_1.toolFailure)(name, `Argument parsing failed: ${String(err)}`);
39
+ }
40
+ // Input validation via Zod schema
41
+ if (metadata.inputSchema) {
42
+ const validation = metadata.inputSchema.safeParse(parsedInput);
43
+ if (!validation.success) {
44
+ return (0, agent_types_1.toolFailure)(name, `Input validation failed: ${validation.error.message}`);
45
+ }
46
+ parsedInput = validation.data;
47
+ }
48
+ // ── Composable sub-agent execution ──────────────────────────────────────
49
+ if (metadata.isComposable && metadata.agentClass) {
50
+ const inputKey = Object.keys(metadata.inputSchema?.shape ?? {})[0] ?? "task";
51
+ const task = parsedInput?.[inputKey] ??
52
+ (typeof parsedInput === "string"
53
+ ? parsedInput
54
+ : JSON.stringify(parsedInput));
55
+ const cacheKey = crypto_1.default
56
+ .createHash("sha256")
57
+ .update(name + JSON.stringify(task))
58
+ .digest("hex");
59
+ if (subAgentCache.has(cacheKey)) {
60
+ return (0, agent_types_1.toolSuccess)(subAgentCache.get(cacheKey));
61
+ }
62
+ try {
63
+ const result = await (0, agent_runner_1.runAgent)(metadata.agentClass, task, false, undefined, {
64
+ maxSteps: metadata.maxSteps ?? subAgentOptions.maxSteps ?? 1,
65
+ temperature: subAgentOptions.temperature ?? 0,
66
+ maxRetries: subAgentOptions.maxRetries ?? 3,
67
+ retryDelayMs: subAgentOptions.retryDelayMs ?? 800,
68
+ backoff: subAgentOptions.backoff ?? true,
69
+ persist: subAgentOptions.persist ?? { mode: "none" },
70
+ });
71
+ subAgentCache.set(cacheKey, result);
72
+ return (0, agent_types_1.toolSuccess)(result);
73
+ }
74
+ catch (err) {
75
+ return (0, agent_types_1.toolFailure)(name, `Sub-agent execution failed: ${String(err)}`);
76
+ }
77
+ }
78
+ // ── Regular tool method execution ────────────────────────────────────────
79
+ if (!instance) {
80
+ return (0, agent_types_1.toolFailure)(name, `Tool instance is null for "${name}".`);
81
+ }
82
+ try {
83
+ const fn = instance[method];
84
+ const output = await fn.call(instance, parsedInput);
85
+ // Optional output validation — soft warn, do not fail
86
+ if (metadata.outputSchema) {
87
+ const outValidation = metadata.outputSchema.safeParse(output);
88
+ if (!outValidation.success) {
89
+ console.warn(`[Tool:${name}] Output schema mismatch: ${outValidation.error.message}`);
90
+ }
91
+ }
92
+ const stringOutput = typeof output === "string" ? output : JSON.stringify(output);
93
+ return (0, agent_types_1.toolSuccess)(stringOutput);
94
+ }
95
+ catch (err) {
96
+ return (0, agent_types_1.toolFailure)(name, String(err));
97
+ }
98
+ };
99
+ exports.executeTool = executeTool;
100
+ //# sourceMappingURL=execute-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-tool.js","sourceRoot":"","sources":["../../../src/agents/runtime-engine/execute-tool.ts"],"names":[],"mappings":";;;;;;AACA,iEAA4D;AAC5D,6DAAsD;AAEtD,gDAA0D;AAC1D,oDAA4B;AAE5B;;;;;;;;;;;;;;GAcG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,IAAY,EACZ,OAAgB,EAChB,OAAkC,EAClC,kBAA8B,EAAE,EAChC,gBAAqC,IAAI,GAAG,EAAE,EACzB,EAAE;IACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAA,yBAAW,EAAC,IAAI,EAAE,SAAS,IAAI,0BAA0B,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE7C,8DAA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MAAM,aAAa,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC9D,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;gBAC3B,OAAO,CAAC,IAAI,CACV,SAAS,IAAI,6BAA6B,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CACxE,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,YAAY,GAChB,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC/D,OAAO,IAAA,yBAAW,EAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,IAAA,yBAAW,EAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,CAAC;AACH,CAAC,CAAC;AAxGW,QAAA,WAAW,eAwGtB"}
@@ -0,0 +1,7 @@
1
+ export * from './build-tool-map';
2
+ export * from './convert-zod-to-tool-schema';
3
+ export * from './execute-tool';
4
+ export * from './parse-tool-arguments';
5
+ export * from './retry.utils';
6
+ export * from './state-persistence';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./build-tool-map"), exports);
18
+ __exportStar(require("./convert-zod-to-tool-schema"), exports);
19
+ __exportStar(require("./execute-tool"), exports);
20
+ __exportStar(require("./parse-tool-arguments"), exports);
21
+ __exportStar(require("./retry.utils"), exports);
22
+ __exportStar(require("./state-persistence"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/runtime-engine/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,+DAA6C;AAC7C,iDAA+B;AAC/B,yDAAuC;AACvC,gDAA8B;AAC9B,sDAAoC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Safely coerces tool arguments into a plain Record<string, unknown>.
3
+ *
4
+ * Handles all shapes the LLM may produce:
5
+ * - already a plain object → returned as-is
6
+ * - JSON string → parsed
7
+ * - non-JSON string → wrapped as { input: "<value>" }
8
+ * - scalar (number/boolean) → wrapped as { input: <value> }
9
+ * - array / null / undefined → empty object {}
10
+ */
11
+ export declare function parseToolArguments(args: unknown): Record<string, unknown>;
12
+ //# sourceMappingURL=parse-tool-arguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-tool-arguments.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/parse-tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+BzE"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseToolArguments = parseToolArguments;
4
+ /**
5
+ * Safely coerces tool arguments into a plain Record<string, unknown>.
6
+ *
7
+ * Handles all shapes the LLM may produce:
8
+ * - already a plain object → returned as-is
9
+ * - JSON string → parsed
10
+ * - non-JSON string → wrapped as { input: "<value>" }
11
+ * - scalar (number/boolean) → wrapped as { input: <value> }
12
+ * - array / null / undefined → empty object {}
13
+ */
14
+ function parseToolArguments(args) {
15
+ if (args !== null && typeof args === "object" && !Array.isArray(args)) {
16
+ return args;
17
+ }
18
+ if (typeof args === "string") {
19
+ const trimmed = args.trim();
20
+ if (trimmed === "" || trimmed === "{}")
21
+ return {};
22
+ try {
23
+ const parsed = JSON.parse(trimmed);
24
+ if (parsed !== null &&
25
+ typeof parsed === "object" &&
26
+ !Array.isArray(parsed)) {
27
+ return parsed;
28
+ }
29
+ // JSON parsed to a scalar or array — wrap it
30
+ return { input: parsed };
31
+ }
32
+ catch {
33
+ // Raw string, not JSON — treat as single-input payload
34
+ return { input: trimmed };
35
+ }
36
+ }
37
+ if (typeof args === "number" || typeof args === "boolean") {
38
+ return { input: args };
39
+ }
40
+ return {};
41
+ }
42
+ //# sourceMappingURL=parse-tool-arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-tool-arguments.js","sourceRoot":"","sources":["../../../src/agents/runtime-engine/parse-tool-arguments.ts"],"names":[],"mappings":";;AAUA,gDA+BC;AAzCD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,IAAa;IAC9C,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACtE,OAAO,IAA+B,CAAC;IACzC,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAElD,IAAI,CAAC;YACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5C,IACE,MAAM,KAAK,IAAI;gBACf,OAAO,MAAM,KAAK,QAAQ;gBAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACtB,CAAC;gBACD,OAAO,MAAiC,CAAC;YAC3C,CAAC;YACD,6CAA6C;YAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,uDAAuD;YACvD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Sleeps for the specified number of milliseconds.
3
+ *
4
+ * @param ms - Milliseconds to sleep.
5
+ * @returns A promise that resolves after the delay.
6
+ */
7
+ export declare const sleep: (ms: number) => Promise<unknown>;
8
+ /**
9
+ * Executes a function with retry logic, emitting events on failures.
10
+ *
11
+ * Retries up to maxRetries times with exponential backoff if enabled.
12
+ * Emits "retry:attempt" events for each failure, and throws on final failure.
13
+ *
14
+ * @param fn - The async function to execute and retry.
15
+ * @param maxRetries - Maximum number of retry attempts.
16
+ * @param baseDelay - Base delay in ms between retries.
17
+ * @param backoff - Whether to use exponential backoff.
18
+ * @param emit - Event emitter function for retry events.
19
+ * @param context - Context object with a "name" for logging.
20
+ * @returns The result of the successful function call.
21
+ * @throws The last error if all retries fail.
22
+ */
23
+ export declare function withRetry<T>(fn: () => Promise<T>, maxRetries: number, baseDelay: number, backoff: boolean, emit: (event: any) => void, context: {
24
+ name: string;
25
+ }): Promise<T>;
26
+ //# sourceMappingURL=retry.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.utils.d.ts","sourceRoot":"","sources":["../../../src/agents/runtime-engine/retry.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAA0C,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,EAC1B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACxB,OAAO,CAAC,CAAC,CAAC,CA0BZ"}