wave-agent-sdk 0.15.1 → 0.15.3

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 (111) hide show
  1. package/builtin/skills/loop/SKILL.md +29 -3
  2. package/dist/agent.d.ts +7 -2
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +34 -11
  5. package/dist/constants/tools.d.ts +3 -0
  6. package/dist/constants/tools.d.ts.map +1 -1
  7. package/dist/constants/tools.js +3 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/managers/aiManager.d.ts +13 -1
  12. package/dist/managers/aiManager.d.ts.map +1 -1
  13. package/dist/managers/aiManager.js +69 -17
  14. package/dist/managers/hookManager.d.ts.map +1 -1
  15. package/dist/managers/hookManager.js +9 -0
  16. package/dist/managers/mcpManager.d.ts +4 -1
  17. package/dist/managers/mcpManager.d.ts.map +1 -1
  18. package/dist/managers/mcpManager.js +25 -5
  19. package/dist/managers/permissionManager.d.ts +0 -2
  20. package/dist/managers/permissionManager.d.ts.map +1 -1
  21. package/dist/managers/permissionManager.js +0 -30
  22. package/dist/managers/slashCommandManager.d.ts +1 -0
  23. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  24. package/dist/managers/slashCommandManager.js +4 -0
  25. package/dist/managers/toolManager.d.ts +6 -0
  26. package/dist/managers/toolManager.d.ts.map +1 -1
  27. package/dist/managers/toolManager.js +41 -1
  28. package/dist/prompts/index.d.ts.map +1 -1
  29. package/dist/prompts/index.js +15 -5
  30. package/dist/services/initializationService.d.ts +0 -2
  31. package/dist/services/initializationService.d.ts.map +1 -1
  32. package/dist/services/initializationService.js +3 -35
  33. package/dist/services/memory.d.ts +6 -0
  34. package/dist/services/memory.d.ts.map +1 -1
  35. package/dist/services/memory.js +27 -14
  36. package/dist/tools/cronCreateTool.d.ts.map +1 -1
  37. package/dist/tools/cronCreateTool.js +71 -6
  38. package/dist/tools/cronDeleteTool.d.ts.map +1 -1
  39. package/dist/tools/cronDeleteTool.js +5 -1
  40. package/dist/tools/cronListTool.d.ts.map +1 -1
  41. package/dist/tools/cronListTool.js +5 -1
  42. package/dist/tools/enterWorktreeTool.d.ts +8 -0
  43. package/dist/tools/enterWorktreeTool.d.ts.map +1 -0
  44. package/dist/tools/enterWorktreeTool.js +144 -0
  45. package/dist/tools/exitWorktreeTool.d.ts +8 -0
  46. package/dist/tools/exitWorktreeTool.d.ts.map +1 -0
  47. package/dist/tools/exitWorktreeTool.js +184 -0
  48. package/dist/tools/taskManagementTools.d.ts.map +1 -1
  49. package/dist/tools/taskManagementTools.js +4 -0
  50. package/dist/tools/toolSearchTool.d.ts +15 -0
  51. package/dist/tools/toolSearchTool.d.ts.map +1 -0
  52. package/dist/tools/toolSearchTool.js +185 -0
  53. package/dist/tools/types.d.ts +19 -0
  54. package/dist/tools/types.d.ts.map +1 -1
  55. package/dist/tools/webFetchTool.d.ts.map +1 -1
  56. package/dist/tools/webFetchTool.js +1 -0
  57. package/dist/types/agent.d.ts +6 -1
  58. package/dist/types/agent.d.ts.map +1 -1
  59. package/dist/types/hooks.d.ts +3 -1
  60. package/dist/types/hooks.d.ts.map +1 -1
  61. package/dist/types/hooks.js +1 -0
  62. package/dist/utils/containerSetup.d.ts.map +1 -1
  63. package/dist/utils/containerSetup.js +4 -6
  64. package/dist/utils/cronToHuman.d.ts +6 -0
  65. package/dist/utils/cronToHuman.d.ts.map +1 -0
  66. package/dist/utils/cronToHuman.js +79 -0
  67. package/dist/utils/isDeferredTool.d.ts +19 -0
  68. package/dist/utils/isDeferredTool.d.ts.map +1 -0
  69. package/dist/utils/isDeferredTool.js +31 -0
  70. package/dist/utils/mcpUtils.d.ts.map +1 -1
  71. package/dist/utils/mcpUtils.js +1 -0
  72. package/dist/utils/parseCronExpression.d.ts +6 -0
  73. package/dist/utils/parseCronExpression.d.ts.map +1 -0
  74. package/dist/utils/parseCronExpression.js +74 -0
  75. package/dist/utils/worktreeSession.d.ts +26 -0
  76. package/dist/utils/worktreeSession.d.ts.map +1 -0
  77. package/dist/utils/worktreeSession.js +14 -0
  78. package/dist/utils/worktreeUtils.d.ts +42 -0
  79. package/dist/utils/worktreeUtils.d.ts.map +1 -0
  80. package/dist/utils/worktreeUtils.js +236 -0
  81. package/package.json +1 -1
  82. package/src/agent.ts +49 -12
  83. package/src/constants/tools.ts +3 -0
  84. package/src/index.ts +1 -0
  85. package/src/managers/aiManager.ts +73 -18
  86. package/src/managers/hookManager.ts +10 -0
  87. package/src/managers/mcpManager.ts +32 -6
  88. package/src/managers/permissionManager.ts +0 -42
  89. package/src/managers/slashCommandManager.ts +6 -0
  90. package/src/managers/toolManager.ts +47 -1
  91. package/src/prompts/index.ts +18 -4
  92. package/src/services/initializationService.ts +2 -41
  93. package/src/services/memory.ts +30 -17
  94. package/src/tools/cronCreateTool.ts +81 -8
  95. package/src/tools/cronDeleteTool.ts +7 -2
  96. package/src/tools/cronListTool.ts +7 -2
  97. package/src/tools/enterWorktreeTool.ts +183 -0
  98. package/src/tools/exitWorktreeTool.ts +242 -0
  99. package/src/tools/taskManagementTools.ts +4 -0
  100. package/src/tools/toolSearchTool.ts +228 -0
  101. package/src/tools/types.ts +19 -0
  102. package/src/tools/webFetchTool.ts +1 -0
  103. package/src/types/agent.ts +6 -0
  104. package/src/types/hooks.ts +4 -0
  105. package/src/utils/containerSetup.ts +7 -8
  106. package/src/utils/cronToHuman.ts +99 -0
  107. package/src/utils/isDeferredTool.ts +36 -0
  108. package/src/utils/mcpUtils.ts +1 -0
  109. package/src/utils/parseCronExpression.ts +78 -0
  110. package/src/utils/worktreeSession.ts +36 -0
  111. package/src/utils/worktreeUtils.ts +288 -0
@@ -60,6 +60,7 @@ export class McpManager {
60
60
  this.configPath = "";
61
61
  this.workdir = "";
62
62
  this.callbacks = options.callbacks || {};
63
+ this.mcpServers = options.mcpServers;
63
64
  }
64
65
  /**
65
66
  * Initialize MCP manager with working directory and optionally auto-connect
@@ -67,10 +68,17 @@ export class McpManager {
67
68
  async initialize(workdir, autoConnect = false) {
68
69
  this.configPath = join(workdir, ".mcp.json");
69
70
  this.workdir = workdir;
71
+ // Register constructor-provided servers before loading .mcp.json
72
+ if (this.mcpServers) {
73
+ for (const [name, config] of Object.entries(this.mcpServers)) {
74
+ this.addServer(name, config);
75
+ }
76
+ }
70
77
  if (autoConnect) {
71
78
  logger?.debug("Initializing MCP servers...");
72
- // Ensure MCP configuration is loaded
73
- const config = await this.ensureConfigLoaded();
79
+ // Load workspace MCP configuration (always read, merge with any plugin servers already added)
80
+ await this.loadConfig();
81
+ const config = this.config;
74
82
  if (config && config.mcpServers) {
75
83
  // Connect to all configured servers in background to avoid blocking agent initialization
76
84
  Object.keys(config.mcpServers).forEach((serverName) => {
@@ -91,7 +99,7 @@ export class McpManager {
91
99
  }
92
100
  logger?.debug("MCP servers initialization started in background");
93
101
  // Trigger state change callback after starting initialization
94
- this.callbacks.onServersChange?.(this.getAllServers());
102
+ this.callbacks.onMcpServersChange?.(this.getAllServers());
95
103
  }
96
104
  }
97
105
  async ensureConfigLoaded() {
@@ -107,7 +115,19 @@ export class McpManager {
107
115
  }
108
116
  try {
109
117
  const configContent = await fs.readFile(this.configPath, "utf-8");
110
- this.config = resolveMcpConfig(JSON.parse(configContent));
118
+ const workspaceConfig = resolveMcpConfig(JSON.parse(configContent));
119
+ // Merge workspace config with any existing config (e.g., from plugins or constructor)
120
+ // Constructor-provided servers take precedence, then workspace config, then existing config
121
+ const merged = { mcpServers: {} };
122
+ if (this.config) {
123
+ Object.assign(merged.mcpServers, this.config.mcpServers);
124
+ }
125
+ Object.assign(merged.mcpServers, workspaceConfig.mcpServers);
126
+ // Constructor-provided servers override both for same names
127
+ if (this.mcpServers) {
128
+ Object.assign(merged.mcpServers, this.mcpServers);
129
+ }
130
+ this.config = merged;
111
131
  // Initialize server statuses (preserve existing status for already known servers)
112
132
  if (this.config) {
113
133
  for (const [name, config] of Object.entries(this.config.mcpServers)) {
@@ -164,7 +184,7 @@ export class McpManager {
164
184
  if (server) {
165
185
  this.servers.set(name, { ...server, ...updates });
166
186
  // Trigger state change callback
167
- this.callbacks.onServersChange?.(this.getAllServers());
187
+ this.callbacks.onMcpServersChange?.(this.getAllServers());
168
188
  }
169
189
  }
170
190
  addServer(name, config) {
@@ -39,8 +39,6 @@ export declare class PermissionManager {
39
39
  private additionalDirectories;
40
40
  private systemAdditionalDirectories;
41
41
  private planFilePath?;
42
- private worktreeName?;
43
- private mainRepoRoot?;
44
42
  private workdir?;
45
43
  private onConfiguredPermissionModeChange?;
46
44
  private _logger?;
@@ -1 +1 @@
1
- {"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAkBhD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiElD,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,wBAAwB,CAAC,EAAE,cAAc,CAAC;IAC1C,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,gEAAgE;IAChE,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,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.addSystemAdditionalDirectory(dir);
93
93
  }
94
- this.worktreeName = this.container.get("WorktreeName");
95
- this.mainRepoRoot = this.container.get("MainRepoRoot");
96
94
  this.workdir = this.container.get("Workdir");
97
95
  }
98
96
  /**
@@ -327,34 +325,6 @@ export class PermissionManager {
327
325
  };
328
326
  }
329
327
  }
330
- // 0. Check worktree safety for Write and Edit tools
331
- const currentWorkdir = this.getWorkdir();
332
- if (this.worktreeName &&
333
- this.mainRepoRoot &&
334
- currentWorkdir &&
335
- (context.toolName === WRITE_TOOL_NAME ||
336
- context.toolName === EDIT_TOOL_NAME)) {
337
- const targetPath = context.toolInput?.file_path;
338
- if (targetPath) {
339
- const absoluteTargetPath = path.resolve(currentWorkdir, targetPath);
340
- const isInsideMainRepo = isPathInside(absoluteTargetPath, this.mainRepoRoot);
341
- const isInsideWorktree = isPathInside(absoluteTargetPath, currentWorkdir);
342
- // If it's inside the main repo but NOT inside the current worktree
343
- if (isInsideMainRepo && !isInsideWorktree) {
344
- logger?.warn("Worktree safety violation", {
345
- toolName: context.toolName,
346
- targetPath,
347
- worktreeName: this.worktreeName,
348
- mainRepoRoot: this.mainRepoRoot,
349
- workdir: currentWorkdir,
350
- });
351
- return {
352
- behavior: "deny",
353
- message: `Access denied: You are currently in a worktree session ("${this.worktreeName}"). Modifying files in the main repository (outside the worktree) is not allowed. Please only modify files within the worktree directory: ${currentWorkdir}`,
354
- };
355
- }
356
- }
357
- }
358
328
  // 0. Check denied rules first - Deny always takes precedence
359
329
  for (const rule of this.deniedRules) {
360
330
  if (this.matchesRule(context, rule)) {
@@ -19,6 +19,7 @@ export declare class SlashCommandManager {
19
19
  private get taskManager();
20
20
  private get skillManager();
21
21
  private get subagentManager();
22
+ private get memoryService();
22
23
  private initializeBuiltinCommands;
23
24
  /**
24
25
  * Load custom commands from filesystem
@@ -1 +1 @@
1
- {"version":3,"file":"slashCommandManager.d.ts","sourceRoot":"","sources":["../../src/managers/slashCommandManager.ts"],"names":[],"mappings":"AAIA,OA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AO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,yBAAyB;IAejC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA2C1B;;OAEG;IACI,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IAmM3D;;OAEG;IACI,sBAAsB,CAC3B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,kBAAkB,EAAE,GAC7B,IAAI;IA0CP;;OAEG;IACI,oBAAoB,IAAI,IAAI;IAWnC;;OAEG;IACI,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAInD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACI,WAAW,IAAI,YAAY,EAAE;IAIpC;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI9D;;OAEG;IACU,cAAc,CACzB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC;IA2BnB;;;OAGG;IACI,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG;QAClD,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAeD;;OAEG;IACI,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI7C;;OAEG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAI1E;;OAEG;IACI,iBAAiB,IAAI,kBAAkB,EAAE;IAIhD;;OAEG;YACW,+BAA+B;IAuD7C;;OAEG;IACI,mBAAmB,IAAI,IAAI;CAQnC"}
@@ -41,6 +41,9 @@ export class SlashCommandManager {
41
41
  get subagentManager() {
42
42
  return this.container.get("SubagentManager");
43
43
  }
44
+ get memoryService() {
45
+ return this.container.get("MemoryService");
46
+ }
44
47
  initializeBuiltinCommands() {
45
48
  // Register built-in clear command
46
49
  this.registerCommand({
@@ -50,6 +53,7 @@ export class SlashCommandManager {
50
53
  handler: async () => {
51
54
  this.aiManager.abortAIMessage();
52
55
  this.messageManager.clearMessages();
56
+ this.memoryService.clearCache();
53
57
  await this.taskManager.syncWithSession();
54
58
  },
55
59
  });
@@ -74,6 +74,8 @@ declare class ToolManager {
74
74
  availableSkills?: SkillMetadata[];
75
75
  workdir?: string;
76
76
  isSubagent?: boolean;
77
+ /** Set of discovered deferred tool names to include in the API call */
78
+ discoveredTools?: Set<string>;
77
79
  }): ChatCompletionFunctionTool[];
78
80
  /**
79
81
  * Get the list of registered tool plugins
@@ -92,6 +94,10 @@ declare class ToolManager {
92
94
  * Get the permission manager
93
95
  */
94
96
  getPermissionManager(): PermissionManager | undefined;
97
+ /**
98
+ * Get the names of all deferred tools (those that require ToolSearch to discover).
99
+ */
100
+ getDeferredToolNames(): string[];
95
101
  /**
96
102
  * Get the task manager
97
103
  */
@@ -1 +1 @@
1
- {"version":3,"file":"toolManager.d.ts","sourceRoot":"","sources":["../../src/managers/toolManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA0B7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,4C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AAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,uEAAuE;QACvE,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;KAC/B,GAAG,0BAA0B,EAAE;IAgEhC;;OAEG;IACI,QAAQ,IAAI,UAAU,EAAE;IAI/B;;OAEG;IACI,iBAAiB,IAAI,cAAc;IAa1C;;;OAGG;IACI,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAIpD;;OAEG;IACI,oBAAoB,IAAI,iBAAiB,GAAG,SAAS;IAI5D;;OAEG;IACI,oBAAoB,IAAI,MAAM,EAAE;IAcvC;;OAEG;IACI,cAAc,IACjB,OAAO,4BAA4B,EAAE,WAAW,GAChD,SAAS;CAKd;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -17,8 +17,12 @@ import { lspTool } from "../tools/lspTool.js";
17
17
  import { agentTool } from "../tools/agentTool.js";
18
18
  import { skillTool } from "../tools/skillTool.js";
19
19
  import { taskCreateTool, taskGetTool, taskUpdateTool, taskListTool, } from "../tools/taskManagementTools.js";
20
+ import { enterWorktreeTool } from "../tools/enterWorktreeTool.js";
21
+ import { exitWorktreeTool } from "../tools/exitWorktreeTool.js";
20
22
  import * as aiService from "../services/aiService.js";
21
23
  import { logger } from "../utils/globalLogger.js";
24
+ import { toolSearchTool } from "../tools/toolSearchTool.js";
25
+ import { isDeferredTool } from "../utils/isDeferredTool.js";
22
26
  /**
23
27
  * Tool Manager
24
28
  *
@@ -86,6 +90,9 @@ class ToolManager {
86
90
  cronDeleteTool,
87
91
  cronListTool,
88
92
  webFetchTool,
93
+ enterWorktreeTool,
94
+ exitWorktreeTool,
95
+ toolSearchTool,
89
96
  ];
90
97
  for (const tool of builtInTools) {
91
98
  if (this.shouldEnableTool(tool.name)) {
@@ -138,6 +145,7 @@ class ToolManager {
138
145
  permissionMode: effectivePermissionMode,
139
146
  canUseToolCallback,
140
147
  permissionManager,
148
+ toolManager: this, // Allow ToolSearchTool to access the tool manager
141
149
  taskManager: this.container.get("TaskManager"),
142
150
  reversionManager: this.container.get("ReversionManager"),
143
151
  backgroundTaskManager: this.container.get("BackgroundTaskManager"),
@@ -158,6 +166,9 @@ class ToolManager {
158
166
  : undefined,
159
167
  aiService: aiService,
160
168
  messageManager: this.container.get("MessageManager"),
169
+ hookManager: this.container.has("HookManager")
170
+ ? this.container.get("HookManager")
171
+ : undefined,
161
172
  sessionId: context.sessionId,
162
173
  toolCallId: context.toolCallId,
163
174
  };
@@ -207,6 +218,7 @@ class ToolManager {
207
218
  getToolsConfig(options) {
208
219
  const permissionManager = this.container.get("PermissionManager");
209
220
  const effectivePermissionMode = this.getPermissionMode();
221
+ const discoveredTools = options?.discoveredTools;
210
222
  const builtInToolsConfig = Array.from(this.toolsRegistry.values())
211
223
  .filter((tool) => {
212
224
  // If tool is explicitly denied by name in permission rules, filter it out
@@ -227,6 +239,10 @@ class ToolManager {
227
239
  return (effectivePermissionMode !== "plan" &&
228
240
  effectivePermissionMode !== "bypassPermissions");
229
241
  }
242
+ // Exclude deferred tools that haven't been discovered yet
243
+ if (isDeferredTool(tool) && !discoveredTools?.has(tool.name)) {
244
+ return false;
245
+ }
230
246
  return true;
231
247
  })
232
248
  .map((tool) => {
@@ -245,7 +261,16 @@ class ToolManager {
245
261
  });
246
262
  const mcpToolsConfig = this.mcpManager
247
263
  .getMcpToolsConfig()
248
- .filter((tool) => !permissionManager?.isToolDenied(tool.function.name));
264
+ .filter((tool) => {
265
+ if (permissionManager?.isToolDenied(tool.function.name)) {
266
+ return false;
267
+ }
268
+ // Exclude MCP tools that haven't been discovered yet
269
+ if (discoveredTools && !discoveredTools.has(tool.function.name)) {
270
+ return false;
271
+ }
272
+ return true;
273
+ });
249
274
  return [...builtInToolsConfig, ...mcpToolsConfig];
250
275
  }
251
276
  /**
@@ -280,6 +305,21 @@ class ToolManager {
280
305
  getPermissionManager() {
281
306
  return this.container.get("PermissionManager");
282
307
  }
308
+ /**
309
+ * Get the names of all deferred tools (those that require ToolSearch to discover).
310
+ */
311
+ getDeferredToolNames() {
312
+ const permissionManager = this.container.get("PermissionManager");
313
+ const builtInDeferred = Array.from(this.toolsRegistry.values())
314
+ .filter((tool) => isDeferredTool(tool))
315
+ .filter((tool) => !permissionManager?.isToolDenied(tool.name))
316
+ .map((tool) => tool.name);
317
+ const mcpDeferred = this.mcpManager
318
+ .getMcpToolsConfig()
319
+ .filter((tool) => !permissionManager?.isToolDenied(tool.function.name))
320
+ .map((tool) => tool.function.name);
321
+ return [...builtInDeferred, ...mcpDeferred];
322
+ }
283
323
  /**
284
324
  * Get the task manager
285
325
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAiBzD,eAAO,MAAM,kBAAkB,oKAAoK,CAAC;AAEpM,eAAO,MAAM,kBAAkB,opIAcqQ,CAAC;AAErS,eAAO,MAAM,wBAAwB,25DASqmB,CAAC;AAE3oB,eAAO,MAAM,WAAW,8hDAWqH,CAAC;AAE9I;;GAEG;AACH,eAAO,MAAM,wBAAwB,+uBAWiH,CAAC;AAEvJ,eAAO,MAAM,qBAAqB,6sBAMuL,CAAC;AAE1N,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,oKAAqB,CAAC;AAExD,eAAO,MAAM,8BAA8B,44DA8CI,CAAC;AAEhD,eAAO,MAAM,yBAAyB,wHAAwH,CAAC;AAC/J,eAAO,MAAM,iBAAiB,qWAG4B,CAAC;AAE3D,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,U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4B,CAAC;AAE3D,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,CAAC,EAAE,cAAc,CAAC;CAC5B,GACL,MAAM,CAuER;AAED,wBAAgB,iCAAiC,CAC/C,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,CAkCR"}
@@ -1,8 +1,10 @@
1
1
  import * as os from "node:os";
2
2
  import { isGitRepository } from "../utils/gitUtils.js";
3
+ import { getCurrentWorktreeSession } from "../utils/worktreeSession.js";
3
4
  import { buildAutoMemoryPrompt } from "./autoMemory.js";
4
5
  import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
5
- import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, BASH_TOOL_NAME, READ_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, } from "../constants/tools.js";
6
+ import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, BASH_TOOL_NAME, READ_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, TOOL_SEARCH_TOOL_NAME, } from "../constants/tools.js";
7
+ import { isDeferredTool } from "../utils/isDeferredTool.js";
6
8
  export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.`;
7
9
  export const DOING_TASKS_PROMPT = `# Doing tasks
8
10
  - The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change "methodName" to snake case, do not reply with just "method_name", instead find the method in the code and modify the code.
@@ -205,13 +207,19 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
205
207
  if (tools.length > 0) {
206
208
  prompt += `\n\n${TOOL_POLICY}`;
207
209
  }
210
+ // List available deferred tool names so the model knows they exist
211
+ // Matching Claude Code: deferred tools appear by name, not loaded until fetched.
212
+ const deferredToolNames = tools.filter(isDeferredTool).map((t) => t.name);
213
+ if (deferredToolNames.length > 0) {
214
+ prompt += `\n\n<available-deferred-tools>${deferredToolNames.join(" ")}\nThese tools are NOT loaded yet — call ${TOOL_SEARCH_TOOL_NAME} first to discover their schemas before invoking them.</available-deferred-tools>`;
215
+ }
208
216
  prompt += `\n\n${OUTPUT_EFFICIENCY_PROMPT}`;
209
217
  prompt += `\n\n${TONE_AND_STYLE_PROMPT}`;
210
218
  if (options.permissionMode === "dontAsk") {
211
219
  prompt += `\n\n# Permission Mode\nThe user has selected the 'dontAsk' permission mode. In this mode, any restricted tool call that does not match a pre-approved rule in 'permissions.allow' or 'temporaryRules' will be automatically denied without prompting the user. You will receive a 'Permission denied' error for such calls. This is intended to prevent interruptions for untrusted tools while allowing pre-approved ones to run seamlessly.`;
212
220
  }
213
221
  if (options.language) {
214
- prompt += `\n\n# Language\nAlways respond in ${options.language}. Technical terms (e.g., code, tool names, file paths) should remain in their original language or English where appropriate.`;
222
+ prompt += `\n\n# Language\nAlways respond in ${options.language}. Use ${options.language} for all explanations, comments, and communications with the user. Technical terms and code identifiers should remain in their original form.`;
215
223
  }
216
224
  if (options.planMode) {
217
225
  prompt += `\n\n${buildPlanModePrompt(options.planMode.planFilePath, options.planMode.planExists, options.isSubagent)}`;
@@ -227,11 +235,12 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
227
235
  : shell.includes("bash")
228
236
  ? "bash"
229
237
  : shell;
238
+ const worktreeSession = getCurrentWorktreeSession();
230
239
  prompt += `
231
240
 
232
241
  Here is useful information about the environment you are running in:
233
242
  <env>
234
- Working directory: ${options.workdir}
243
+ Working directory: ${options.workdir}${worktreeSession ? `\nThis is a git worktree — an isolated copy of the repository. Run all commands from this directory. Do NOT \`cd\` to the original repository root at ${worktreeSession.originalCwd}.` : ""}
235
244
  Is directory a git repo: ${isGitRepo}
236
245
  Platform: ${platform}
237
246
  Shell: ${shellName}
@@ -262,8 +271,9 @@ export function enhanceSystemPromptWithEnvDetails(existingSystemPrompt, workdir)
262
271
  : shell.includes("bash")
263
272
  ? "bash"
264
273
  : shell;
274
+ const worktreeSession = getCurrentWorktreeSession();
265
275
  const notes = `Notes:
266
- - Agent threads always have their cwd reset between bash calls, as a result please only use absolute file paths.
276
+ - Agent threads always have their cwd reset between bash calls, as a result please only use absolute file paths.${worktreeSession ? `\n- You are in a git worktree at ${worktreeSession.worktreePath} (branch: ${worktreeSession.worktreeBranch}). Absolute paths from prior context may refer to the original repo at ${worktreeSession.originalCwd}; translate them to your worktree. Do NOT edit files outside this worktree.` : ""}
267
277
  - In your final response, share file paths (always absolute, never relative) that are relevant to the task. Include code snippets only when the exact text is load-bearing (e.g., a bug you found, a function signature the caller asked for) — do not recap code you merely read.
268
278
  - For clear communication with the user the assistant MUST avoid using emojis.
269
279
  - Do not use a colon before tool calls. Text like "Let me read the file:" followed by a read tool call should just be "Let me read the file." with a period.`;
@@ -273,7 +283,7 @@ ${notes}
273
283
 
274
284
  Here is useful information about the environment you are running in:
275
285
  <env>
276
- Working directory: ${workdir}
286
+ Working directory: ${workdir}${worktreeSession ? `\nThis is a git worktree — an isolated copy of the repository. Run all commands from this directory. Do NOT \`cd\` to the original repository root at ${worktreeSession.originalCwd}.` : ""}
277
287
  Is directory a git repo: ${isGitRepo}
278
288
  Platform: ${platform}
279
289
  Shell: ${shellName}
@@ -30,8 +30,6 @@ export interface InitializationContext {
30
30
  memoryRuleManager: MemoryRuleManager;
31
31
  liveConfigManager: LiveConfigManager;
32
32
  taskManager: TaskManager;
33
- setProjectMemory: (content: string) => void;
34
- setUserMemory: (content: string) => void;
35
33
  resolveAndValidateConfig: () => void;
36
34
  }
37
35
  export declare class InitializationService {
@@ -1 +1 @@
1
- {"version":3,"file":"initializationService.d.ts","sourceRoot":"","sources":["../../src/services/initializationService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,wBAAwB,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,qBAAa,qBAAqB;WACZ,UAAU,CAC5B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE;QACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC;CAyTjB"}
1
+ {"version":3,"file":"initializationService.d.ts","sourceRoot":"","sources":["../../src/services/initializationService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAA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AiB,EAAE,iBAAiB,CAAC;IACrC,WAAW,EAAE,WAAW,CAAC;IACzB,wBAAwB,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,qBAAa,qBAAqB;WACZ,UAAU,CAC5B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE;QACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC;CAqRjB"}
@@ -4,7 +4,7 @@ import { LspManager } from "../managers/lspManager.js";
4
4
  import { USER_MEMORY_FILE } from "../utils/constants.js";
5
5
  export class InitializationService {
6
6
  static async initialize(context, options) {
7
- const { skillManager, subagentManager, container, toolManager, pluginManager, options: agentOptions, slashCommandManager, logger, mcpManager, workdir, lspManager, configurationService, hookManager, messageManager, memoryRuleManager, liveConfigManager, taskManager, setProjectMemory, setUserMemory, resolveAndValidateConfig, } = context;
7
+ const { skillManager, subagentManager, container, toolManager, pluginManager, options: agentOptions, slashCommandManager, logger, mcpManager, workdir, lspManager, configurationService, hookManager, messageManager, memoryRuleManager, liveConfigManager, taskManager, resolveAndValidateConfig, } = context;
8
8
  const startTime = performance.now();
9
9
  // Initialize managers first
10
10
  try {
@@ -162,40 +162,8 @@ export class InitializationService {
162
162
  logger?.error("Failed to initialize live configuration reload:", error);
163
163
  // Don't throw error to prevent app startup failure - continue without live reload
164
164
  }
165
- // Load memory files during initialization
166
- try {
167
- const phaseStart = performance.now();
168
- const memoryService = container.get("MemoryService");
169
- if (!memoryService) {
170
- throw new Error("MemoryService not found in container");
171
- }
172
- // Load project memory from AGENTS.md
173
- try {
174
- const projectMemoryContent = await memoryService.readMemoryFile(workdir);
175
- setProjectMemory(projectMemoryContent);
176
- }
177
- catch (error) {
178
- logger?.warn("Failed to load project memory file:", error);
179
- setProjectMemory("");
180
- }
181
- // Load user memory
182
- try {
183
- const userMemoryContent = await memoryService.getUserMemoryContent();
184
- setUserMemory(userMemoryContent);
185
- }
186
- catch (error) {
187
- logger?.warn("Failed to load user memory file:", error);
188
- setUserMemory("");
189
- }
190
- logger?.debug(`Initialization Phase [Memory Files Loading] took ${(performance.now() - phaseStart).toFixed(2)}ms`);
191
- }
192
- catch (error) {
193
- // Ensure memory is always initialized even if loading fails
194
- setProjectMemory("");
195
- setUserMemory("");
196
- logger?.error("Failed to load memory files:", error);
197
- // Don't throw error to prevent app startup failure
198
- }
165
+ // Memory is lazy-cached on first getCombinedMemoryContent call
166
+ // No explicit loading needed during initialization
199
167
  // Handle session restoration or set provided messages
200
168
  const sessionPhaseStart = performance.now();
201
169
  if (options?.messages) {
@@ -1,7 +1,13 @@
1
1
  import { Container } from "../utils/container.js";
2
2
  export declare class MemoryService {
3
3
  private container;
4
+ private _cachedProjectMemory;
5
+ private _cachedUserMemory;
6
+ private _cachedCombinedMemory;
4
7
  constructor(container: Container);
8
+ get cachedProjectMemory(): string;
9
+ get cachedUserMemory(): string;
10
+ clearCache(): void;
5
11
  /**
6
12
  * Get the project-specific auto-memory directory.
7
13
  * Uses the git common directory to ensure worktrees share the same memory.
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/services/memory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,qBAAa,aAAa;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAU/C;;OAEG;IACG,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B/D;;OAEG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBtD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BrC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAevC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBhD,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBjE"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/services/memory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,qBAAa,aAAa;IAKZ,OAAO,CAAC,SAAS;IAJ7B,OAAO,CAAC,oBAAoB,CAAc;IAC1C,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,qBAAqB,CAAuB;gBAEhC,SAAS,EAAE,SAAS;IAExC,IAAW,mBAAmB,IAAI,MAAM,CAEvC;IAED,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAEM,UAAU,IAAI,IAAI;IAMzB;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAU/C;;OAEG;IACG,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B/D;;OAEG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBtD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BrC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAevC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBhD,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAgBjE"}
@@ -8,6 +8,20 @@ import { pathEncoder } from "../utils/pathEncoder.js";
8
8
  export class MemoryService {
9
9
  constructor(container) {
10
10
  this.container = container;
11
+ this._cachedProjectMemory = "";
12
+ this._cachedUserMemory = "";
13
+ this._cachedCombinedMemory = null;
14
+ }
15
+ get cachedProjectMemory() {
16
+ return this._cachedProjectMemory;
17
+ }
18
+ get cachedUserMemory() {
19
+ return this._cachedUserMemory;
20
+ }
21
+ clearCache() {
22
+ this._cachedProjectMemory = "";
23
+ this._cachedUserMemory = "";
24
+ this._cachedCombinedMemory = null;
11
25
  }
12
26
  /**
13
27
  * Get the project-specific auto-memory directory.
@@ -133,21 +147,20 @@ export class MemoryService {
133
147
  }
134
148
  }
135
149
  async getCombinedMemoryContent(workdir) {
136
- // Read memory file content
137
- const memoryContent = await this.readMemoryFile(workdir);
138
- // Read user-level memory content
139
- const userMemoryContent = await this.getUserMemoryContent();
140
- // Merge project memory and user memory
141
- let combinedMemory = "";
142
- if (memoryContent.trim()) {
143
- combinedMemory += memoryContent;
150
+ if (this._cachedCombinedMemory !== null) {
151
+ return this._cachedCombinedMemory;
144
152
  }
145
- if (userMemoryContent.trim()) {
146
- if (combinedMemory) {
147
- combinedMemory += "\n\n";
148
- }
149
- combinedMemory += userMemoryContent;
153
+ this._cachedProjectMemory = await this.readMemoryFile(workdir);
154
+ this._cachedUserMemory = await this.getUserMemoryContent();
155
+ let combined = "";
156
+ if (this._cachedProjectMemory.trim())
157
+ combined += this._cachedProjectMemory;
158
+ if (this._cachedUserMemory.trim()) {
159
+ if (combined)
160
+ combined += "\n\n";
161
+ combined += this._cachedUserMemory;
150
162
  }
151
- return combinedMemory;
163
+ this._cachedCombinedMemory = combined;
164
+ return combined;
152
165
  }
153
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cronCreateTool.d.ts","sourceRoot":"","sources":["../../src/tools/cronCreateTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGjE,eAAO,MAAM,cAAc,EAAE,UAqE5B,CAAC"}
1
+ {"version":3,"file":"cronCreateTool.d.ts","sourceRoot":"","sources":["../../src/tools/cronCreateTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA+CjE,eAAO,MAAM,cAAc,EAAE,UAkG5B,CAAC"}