@robota-sdk/agent-tools 3.0.0-beta.61 → 3.0.0-beta.62

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.
@@ -1,60 +1,16 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
29
2
 
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- E2BSandboxClient: () => E2BSandboxClient,
34
- FunctionTool: () => FunctionTool,
35
- InMemorySandboxClient: () => InMemorySandboxClient,
36
- OpenAPITool: () => OpenAPITool,
37
- ToolRegistry: () => ToolRegistry,
38
- applyWorkspaceManifest: () => applyWorkspaceManifest,
39
- bashTool: () => bashTool,
40
- createBashTool: () => createBashTool,
41
- createEditTool: () => createEditTool,
42
- createFunctionTool: () => createFunctionTool,
43
- createOpenAPITool: () => createOpenAPITool,
44
- createReadTool: () => createReadTool,
45
- createWriteTool: () => createWriteTool,
46
- createZodFunctionTool: () => createZodFunctionTool,
47
- editTool: () => editTool,
48
- globTool: () => globTool,
49
- grepTool: () => grepTool,
50
- readTool: () => readTool,
51
- validateWorkspaceManifestPath: () => validateWorkspaceManifestPath,
52
- webFetchTool: () => webFetchTool,
53
- webSearchTool: () => webSearchTool,
54
- writeTool: () => writeTool,
55
- zodToJsonSchema: () => zodToJsonSchema
56
- });
57
- module.exports = __toCommonJS(index_exports);
3
+ var promises = require('fs/promises');
4
+ var path = require('path');
5
+ var agentCore = require('@robota-sdk/agent-core');
6
+ var child_process = require('child_process');
7
+ var zod = require('zod');
8
+ var crypto = require('crypto');
9
+ var fg = require('fast-glob');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var fg__default = /*#__PURE__*/_interopDefault(fg);
58
14
 
59
15
  // src/sandbox/e2b-sandbox-client.ts
60
16
  var E2BSandboxClient = class {
@@ -170,10 +126,6 @@ var InMemorySandboxClient = class {
170
126
  return this.files.get(path);
171
127
  }
172
128
  };
173
-
174
- // src/sandbox/workspace-manifest.ts
175
- var import_promises = require("fs/promises");
176
- var import_node_path = require("path");
177
129
  var DEFAULT_TARGET_ROOT = "/workspace";
178
130
  var WINDOWS_ABSOLUTE_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
179
131
  var SHELL_QUOTE_PATTERN = /'/g;
@@ -251,7 +203,7 @@ function createAppliedEntry(path, type) {
251
203
  }
252
204
  async function copyLocalFile(sandboxClient, source, targetPath, targetRoot, options) {
253
205
  const hostSourcePath = resolveHostSourcePath(source, options.hostRoot);
254
- const content = await (0, import_promises.readFile)(hostSourcePath, "utf8");
206
+ const content = await promises.readFile(hostSourcePath, "utf8");
255
207
  await writeSandboxFile(sandboxClient, targetPath, targetRoot, content);
256
208
  }
257
209
  async function copyLocalDirectory(sandboxClient, source, targetPath, options) {
@@ -260,16 +212,16 @@ async function copyLocalDirectory(sandboxClient, source, targetPath, options) {
260
212
  }
261
213
  async function copyLocalDirectoryRecursive(sandboxClient, sourcePath, targetPath) {
262
214
  await createSandboxDirectory(sandboxClient, targetPath);
263
- const entries = await (0, import_promises.readdir)(sourcePath, { withFileTypes: true });
215
+ const entries = await promises.readdir(sourcePath, { withFileTypes: true });
264
216
  for (const entry of entries) {
265
- const childSourcePath = (0, import_node_path.join)(sourcePath, entry.name);
217
+ const childSourcePath = path.join(sourcePath, entry.name);
266
218
  const childTargetPath = joinSandboxPath(targetPath, entry.name);
267
219
  if (entry.isDirectory()) {
268
220
  await copyLocalDirectoryRecursive(sandboxClient, childSourcePath, childTargetPath);
269
221
  continue;
270
222
  }
271
223
  if (entry.isFile()) {
272
- const content = await (0, import_promises.readFile)(childSourcePath, "utf8");
224
+ const content = await promises.readFile(childSourcePath, "utf8");
273
225
  await sandboxClient.writeFile(childTargetPath, content);
274
226
  }
275
227
  }
@@ -283,7 +235,7 @@ async function cloneGitRepository(sandboxClient, entry, targetPath) {
283
235
  );
284
236
  }
285
237
  async function writeSandboxFile(sandboxClient, targetPath, targetRoot, content) {
286
- const parentPath = import_node_path.posix.dirname(targetPath);
238
+ const parentPath = path.posix.dirname(targetPath);
287
239
  if (parentPath !== targetRoot) {
288
240
  await createSandboxDirectory(sandboxClient, parentPath);
289
241
  }
@@ -302,7 +254,7 @@ ${result.stderr ?? result.stdout}`
302
254
  }
303
255
  }
304
256
  function resolveHostSourcePath(source, hostRoot) {
305
- return (0, import_node_path.isAbsolute)(source) ? (0, import_node_path.resolve)(source) : (0, import_node_path.resolve)(hostRoot ?? process.cwd(), source);
257
+ return path.isAbsolute(source) ? path.resolve(source) : path.resolve(hostRoot ?? process.cwd(), source);
306
258
  }
307
259
  function normalizeSandboxRoot(root) {
308
260
  const normalized = root.replace(/\\/g, "/").replace(/\/+$/, "");
@@ -324,10 +276,6 @@ function quoteShellArg(value) {
324
276
  function assertUnreachable(value) {
325
277
  throw new Error(`unsupported workspace manifest entry: ${JSON.stringify(value)}`);
326
278
  }
327
-
328
- // src/registry/tool-registry.ts
329
- var import_agent_core = require("@robota-sdk/agent-core");
330
- var import_agent_core2 = require("@robota-sdk/agent-core");
331
279
  var ToolRegistry = class {
332
280
  tools = /* @__PURE__ */ new Map();
333
281
  /**
@@ -335,18 +283,18 @@ var ToolRegistry = class {
335
283
  */
336
284
  register(tool) {
337
285
  if (!tool.schema?.name) {
338
- throw new import_agent_core.ValidationError("Tool must have a valid schema with name");
286
+ throw new agentCore.ValidationError("Tool must have a valid schema with name");
339
287
  }
340
288
  const toolName = tool.schema.name;
341
289
  this.validateToolSchema(tool.schema);
342
290
  if (this.tools.has(toolName)) {
343
- import_agent_core2.logger.warn(`Tool "${toolName}" is already registered, overriding`, {
291
+ agentCore.logger.warn(`Tool "${toolName}" is already registered, overriding`, {
344
292
  toolName,
345
293
  existingTool: this.tools.get(toolName)?.constructor.name
346
294
  });
347
295
  }
348
296
  this.tools.set(toolName, tool);
349
- import_agent_core2.logger.debug(`Tool "${toolName}" registered successfully`, {
297
+ agentCore.logger.debug(`Tool "${toolName}" registered successfully`, {
350
298
  toolName,
351
299
  toolType: tool.constructor.name,
352
300
  parameters: Object.keys(tool.schema.parameters?.properties || {})
@@ -357,11 +305,11 @@ var ToolRegistry = class {
357
305
  */
358
306
  unregister(name) {
359
307
  if (!this.tools.has(name)) {
360
- import_agent_core2.logger.warn(`Attempted to unregister non-existent tool "${name}"`);
308
+ agentCore.logger.warn(`Attempted to unregister non-existent tool "${name}"`);
361
309
  return;
362
310
  }
363
311
  this.tools.delete(name);
364
- import_agent_core2.logger.debug(`Tool "${name}" unregistered successfully`);
312
+ agentCore.logger.debug(`Tool "${name}" unregistered successfully`);
365
313
  }
366
314
  /**
367
315
  * Get tool by name
@@ -380,7 +328,7 @@ var ToolRegistry = class {
380
328
  */
381
329
  getSchemas() {
382
330
  const tools = this.getAll();
383
- import_agent_core2.logger.debug("[TOOL-FLOW] ToolRegistry.getSchemas() - Tools before schema extraction", {
331
+ agentCore.logger.debug("[TOOL-FLOW] ToolRegistry.getSchemas() - Tools before schema extraction", {
384
332
  count: tools.length,
385
333
  tools: tools.map((t) => ({
386
334
  name: t.schema?.name ?? "unnamed",
@@ -403,7 +351,7 @@ var ToolRegistry = class {
403
351
  clear() {
404
352
  const toolCount = this.tools.size;
405
353
  this.tools.clear();
406
- import_agent_core2.logger.debug(`Cleared ${toolCount} tools from registry`);
354
+ agentCore.logger.debug(`Cleared ${toolCount} tools from registry`);
407
355
  }
408
356
  /**
409
357
  * Get tool names
@@ -429,26 +377,26 @@ var ToolRegistry = class {
429
377
  */
430
378
  validateToolSchema(schema) {
431
379
  if (!schema.name || typeof schema.name !== "string") {
432
- throw new import_agent_core.ValidationError("Tool schema must have a valid name");
380
+ throw new agentCore.ValidationError("Tool schema must have a valid name");
433
381
  }
434
382
  if (!schema.description || typeof schema.description !== "string") {
435
- throw new import_agent_core.ValidationError("Tool schema must have a description");
383
+ throw new agentCore.ValidationError("Tool schema must have a description");
436
384
  }
437
385
  if (!schema.parameters || typeof schema.parameters !== "object" || schema.parameters === null || Array.isArray(schema.parameters)) {
438
- throw new import_agent_core.ValidationError("Tool schema must have parameters object");
386
+ throw new agentCore.ValidationError("Tool schema must have parameters object");
439
387
  }
440
388
  if (schema.parameters.type !== "object") {
441
- throw new import_agent_core.ValidationError('Tool parameters type must be "object"');
389
+ throw new agentCore.ValidationError('Tool parameters type must be "object"');
442
390
  }
443
391
  if (schema.parameters.properties) {
444
392
  for (const propName of Object.keys(schema.parameters.properties)) {
445
393
  const propSchema = schema.parameters.properties[propName];
446
394
  if (!propSchema?.type) {
447
- throw new import_agent_core.ValidationError(`Parameter "${propName}" must have a type`);
395
+ throw new agentCore.ValidationError(`Parameter "${propName}" must have a type`);
448
396
  }
449
397
  const validTypes = ["string", "number", "boolean", "array", "object"];
450
398
  if (!validTypes.includes(propSchema.type)) {
451
- throw new import_agent_core.ValidationError(
399
+ throw new agentCore.ValidationError(
452
400
  `Parameter "${propName}" has invalid type "${propSchema.type}"`
453
401
  );
454
402
  }
@@ -458,7 +406,7 @@ var ToolRegistry = class {
458
406
  const properties = schema.parameters.properties || {};
459
407
  for (const requiredField of schema.parameters.required) {
460
408
  if (!properties[requiredField]) {
461
- throw new import_agent_core.ValidationError(
409
+ throw new agentCore.ValidationError(
462
410
  `Required parameter "${requiredField}" is not defined in properties`
463
411
  );
464
412
  }
@@ -467,9 +415,6 @@ var ToolRegistry = class {
467
415
  }
468
416
  };
469
417
 
470
- // src/implementations/function-tool.ts
471
- var import_agent_core3 = require("@robota-sdk/agent-core");
472
-
473
418
  // src/implementations/function-tool/schema-converter.ts
474
419
  function zodToJsonSchema(schema, options = {}) {
475
420
  const properties = {};
@@ -703,17 +648,17 @@ var FunctionTool = class {
703
648
  this.schema.parameters.properties || {},
704
649
  this.schema.parameters.additionalProperties
705
650
  );
706
- throw new import_agent_core3.ValidationError(`Invalid parameters for tool "${toolName}": ${errors.join(", ")}`);
651
+ throw new agentCore.ValidationError(`Invalid parameters for tool "${toolName}": ${errors.join(", ")}`);
707
652
  }
708
653
  const startTime = Date.now();
709
654
  let result;
710
655
  try {
711
656
  result = await this.fn(parameters, context);
712
657
  } catch (error) {
713
- if (error instanceof import_agent_core3.ToolExecutionError || error instanceof import_agent_core3.ValidationError) {
658
+ if (error instanceof agentCore.ToolExecutionError || error instanceof agentCore.ValidationError) {
714
659
  throw error;
715
660
  }
716
- throw new import_agent_core3.ToolExecutionError(
661
+ throw new agentCore.ToolExecutionError(
717
662
  `Function tool execution failed: ${error instanceof Error ? error.message : String(error)}`,
718
663
  toolName,
719
664
  error instanceof Error ? error : new Error(String(error)),
@@ -767,13 +712,13 @@ var FunctionTool = class {
767
712
  */
768
713
  validateConstructorInputs() {
769
714
  if (!this.schema) {
770
- throw new import_agent_core3.ValidationError("Tool schema is required");
715
+ throw new agentCore.ValidationError("Tool schema is required");
771
716
  }
772
717
  if (!this.fn || typeof this.fn !== "function") {
773
- throw new import_agent_core3.ValidationError("Tool function is required and must be a function");
718
+ throw new agentCore.ValidationError("Tool function is required and must be a function");
774
719
  }
775
720
  if (!this.schema.name) {
776
- throw new import_agent_core3.ValidationError("Tool schema must have a name");
721
+ throw new agentCore.ValidationError("Tool schema must have a name");
777
722
  }
778
723
  }
779
724
  };
@@ -795,7 +740,7 @@ function createZodFunctionTool(name, description, zodSchema, fn) {
795
740
  const wrappedFn = async (parameters2, context) => {
796
741
  const parseResult = zodSchema.safeParse(parameters2);
797
742
  if (!parseResult.success) {
798
- throw new import_agent_core3.ValidationError(`Zod validation failed: ${parseResult.error}`);
743
+ throw new agentCore.ValidationError(`Zod validation failed: ${parseResult.error}`);
799
744
  }
800
745
  const result = await fn(parseResult.data || parameters2, context);
801
746
  return typeof result === "string" ? result : JSON.stringify(result);
@@ -803,9 +748,6 @@ function createZodFunctionTool(name, description, zodSchema, fn) {
803
748
  return new FunctionTool(schema, wrappedFn);
804
749
  }
805
750
 
806
- // src/implementations/openapi-tool.ts
807
- var import_agent_core4 = require("@robota-sdk/agent-core");
808
-
809
751
  // src/implementations/openapi-schema-converter.ts
810
752
  var HTTP_METHODS = [
811
753
  "get",
@@ -957,7 +899,7 @@ var OpenAPITool = class {
957
899
  const toolName = this.schema.name;
958
900
  const validation = this.validateParameters(parameters);
959
901
  if (!validation.isValid) {
960
- throw new import_agent_core4.ValidationError(
902
+ throw new agentCore.ValidationError(
961
903
  `Invalid parameters for OpenAPI tool "${toolName}": ${validation.errors.join(", ")}`
962
904
  );
963
905
  }
@@ -976,11 +918,11 @@ var OpenAPITool = class {
976
918
  }
977
919
  };
978
920
  } catch (error) {
979
- if (error instanceof import_agent_core4.ToolExecutionError || error instanceof import_agent_core4.ValidationError) {
921
+ if (error instanceof agentCore.ToolExecutionError || error instanceof agentCore.ValidationError) {
980
922
  throw error;
981
923
  }
982
924
  const safeError = error instanceof Error ? error : new Error(String(error));
983
- throw new import_agent_core4.ToolExecutionError(
925
+ throw new agentCore.ToolExecutionError(
984
926
  `OpenAPI tool execution failed: ${safeError.message}`,
985
927
  toolName,
986
928
  safeError,
@@ -1127,15 +1069,11 @@ var OpenAPITool = class {
1127
1069
  function createOpenAPITool(config) {
1128
1070
  return new OpenAPITool(config);
1129
1071
  }
1130
-
1131
- // src/builtins/bash-tool.ts
1132
- var import_node_child_process = require("child_process");
1133
- var import_zod = require("zod");
1134
1072
  var DEFAULT_TIMEOUT_MS = 12e4;
1135
- var BashSchema = import_zod.z.object({
1136
- command: import_zod.z.string().describe("The bash command to execute"),
1137
- timeout: import_zod.z.number().optional().describe("Optional timeout in milliseconds (max 600000). Default is 120000 (2 minutes)"),
1138
- workingDirectory: import_zod.z.string().optional().describe("Working directory for the command. Defaults to the current working directory")
1073
+ var BashSchema = zod.z.object({
1074
+ command: zod.z.string().describe("The bash command to execute"),
1075
+ timeout: zod.z.number().optional().describe("Optional timeout in milliseconds (max 600000). Default is 120000 (2 minutes)"),
1076
+ workingDirectory: zod.z.string().optional().describe("Working directory for the command. Defaults to the current working directory")
1139
1077
  });
1140
1078
  async function runBash(args, options = {}) {
1141
1079
  const { command, timeout = DEFAULT_TIMEOUT_MS, workingDirectory } = args;
@@ -1168,7 +1106,7 @@ ${sandboxResult.stderr}` : sandboxResult.stdout;
1168
1106
  const stderrChunks = [];
1169
1107
  let timedOut = false;
1170
1108
  let settled = false;
1171
- const child = (0, import_node_child_process.spawn)("sh", ["-c", command], {
1109
+ const child = child_process.spawn("sh", ["-c", command], {
1172
1110
  cwd: workingDirectory ?? process.cwd(),
1173
1111
  env: process.env,
1174
1112
  stdio: ["pipe", "pipe", "pipe"]
@@ -1236,17 +1174,13 @@ function createBashTool(options = {}) {
1236
1174
  );
1237
1175
  }
1238
1176
  var bashTool = createBashTool();
1239
-
1240
- // src/builtins/read-tool.ts
1241
- var import_promises2 = require("fs/promises");
1242
- var import_zod2 = require("zod");
1243
1177
  var DEFAULT_LIMIT = 2e3;
1244
- var ReadSchema = import_zod2.z.object({
1245
- filePath: import_zod2.z.string().describe("The absolute path to the file to read"),
1246
- offset: import_zod2.z.number().optional().describe(
1178
+ var ReadSchema = zod.z.object({
1179
+ filePath: zod.z.string().describe("The absolute path to the file to read"),
1180
+ offset: zod.z.number().optional().describe(
1247
1181
  "The line number to start reading from (1-based). Only provide if the file is too large to read at once"
1248
1182
  ),
1249
- limit: import_zod2.z.number().optional().describe(
1183
+ limit: zod.z.number().optional().describe(
1250
1184
  `The number of lines to read (default: ${DEFAULT_LIMIT}). Only provide if the file is too large to read at once`
1251
1185
  )
1252
1186
  });
@@ -1302,7 +1236,7 @@ async function readFileTool(args, options = {}) {
1302
1236
  }
1303
1237
  let fileStats;
1304
1238
  try {
1305
- fileStats = await (0, import_promises2.stat)(filePath);
1239
+ fileStats = await promises.stat(filePath);
1306
1240
  } catch (err) {
1307
1241
  const result = {
1308
1242
  success: false,
@@ -1321,7 +1255,7 @@ async function readFileTool(args, options = {}) {
1321
1255
  }
1322
1256
  let buffer;
1323
1257
  try {
1324
- buffer = await (0, import_promises2.readFile)(filePath);
1258
+ buffer = await promises.readFile(filePath);
1325
1259
  } catch (err) {
1326
1260
  const result = {
1327
1261
  success: false,
@@ -1352,26 +1286,18 @@ function createReadTool(options = {}) {
1352
1286
  );
1353
1287
  }
1354
1288
  var readTool = createReadTool();
1355
-
1356
- // src/builtins/write-tool.ts
1357
- var import_zod3 = require("zod");
1358
-
1359
- // src/builtins/atomic-file-write.ts
1360
- var import_node_crypto = require("crypto");
1361
- var import_promises3 = require("fs/promises");
1362
- var import_node_path2 = require("path");
1363
1289
  var TEMP_RANDOM_BYTES = 6;
1364
1290
  var PRESERVED_MODE_BITS = 4095;
1365
1291
  var MISSING_FILE_ERROR_CODE = "ENOENT";
1366
1292
  function createTempFilePath(filePath) {
1367
- const dir = (0, import_node_path2.dirname)(filePath);
1368
- const name = (0, import_node_path2.basename)(filePath);
1369
- const suffix = (0, import_node_crypto.randomBytes)(TEMP_RANDOM_BYTES).toString("hex");
1370
- return (0, import_node_path2.join)(dir, `.${name}.robota-tmp-${process.pid}-${Date.now()}-${suffix}`);
1293
+ const dir = path.dirname(filePath);
1294
+ const name = path.basename(filePath);
1295
+ const suffix = crypto.randomBytes(TEMP_RANDOM_BYTES).toString("hex");
1296
+ return path.join(dir, `.${name}.robota-tmp-${process.pid}-${Date.now()}-${suffix}`);
1371
1297
  }
1372
1298
  async function readExistingMode(filePath) {
1373
1299
  try {
1374
- const fileStats = await (0, import_promises3.stat)(filePath);
1300
+ const fileStats = await promises.stat(filePath);
1375
1301
  return fileStats.mode & PRESERVED_MODE_BITS;
1376
1302
  } catch (error) {
1377
1303
  if (error instanceof Error && hasErrorCode(error, MISSING_FILE_ERROR_CODE)) return void 0;
@@ -1382,26 +1308,26 @@ function hasErrorCode(error, code) {
1382
1308
  return "code" in error && error.code === code;
1383
1309
  }
1384
1310
  async function atomicWriteUtf8File(filePath, content) {
1385
- const dir = (0, import_node_path2.dirname)(filePath);
1386
- await (0, import_promises3.mkdir)(dir, { recursive: true });
1311
+ const dir = path.dirname(filePath);
1312
+ await promises.mkdir(dir, { recursive: true });
1387
1313
  const existingMode = await readExistingMode(filePath);
1388
1314
  const tempFilePath = createTempFilePath(filePath);
1389
1315
  try {
1390
- await (0, import_promises3.writeFile)(tempFilePath, content, "utf8");
1316
+ await promises.writeFile(tempFilePath, content, "utf8");
1391
1317
  if (existingMode !== void 0) {
1392
- await (0, import_promises3.chmod)(tempFilePath, existingMode);
1318
+ await promises.chmod(tempFilePath, existingMode);
1393
1319
  }
1394
- await (0, import_promises3.rename)(tempFilePath, filePath);
1320
+ await promises.rename(tempFilePath, filePath);
1395
1321
  } catch (error) {
1396
- await (0, import_promises3.rm)(tempFilePath, { force: true }).catch(() => void 0);
1322
+ await promises.rm(tempFilePath, { force: true }).catch(() => void 0);
1397
1323
  throw error;
1398
1324
  }
1399
1325
  }
1400
1326
 
1401
1327
  // src/builtins/write-tool.ts
1402
- var WriteSchema = import_zod3.z.object({
1403
- filePath: import_zod3.z.string().describe("The absolute path to the file to write"),
1404
- content: import_zod3.z.string().describe("The content to write to the file")
1328
+ var WriteSchema = zod.z.object({
1329
+ filePath: zod.z.string().describe("The absolute path to the file to write"),
1330
+ content: zod.z.string().describe("The content to write to the file")
1405
1331
  });
1406
1332
  async function writeFileTool(args, options = {}) {
1407
1333
  const { filePath, content } = args;
@@ -1436,15 +1362,11 @@ function createWriteTool(options = {}) {
1436
1362
  );
1437
1363
  }
1438
1364
  var writeTool = createWriteTool();
1439
-
1440
- // src/builtins/edit-tool.ts
1441
- var import_promises4 = require("fs/promises");
1442
- var import_zod4 = require("zod");
1443
- var EditSchema = import_zod4.z.object({
1444
- filePath: import_zod4.z.string().describe("The absolute path to the file to modify"),
1445
- oldString: import_zod4.z.string().describe("The text to replace (must be an exact match of existing content)"),
1446
- newString: import_zod4.z.string().describe("The text to replace it with (must be different from old_string)"),
1447
- replaceAll: import_zod4.z.boolean().optional().describe(
1365
+ var EditSchema = zod.z.object({
1366
+ filePath: zod.z.string().describe("The absolute path to the file to modify"),
1367
+ oldString: zod.z.string().describe("The text to replace (must be an exact match of existing content)"),
1368
+ newString: zod.z.string().describe("The text to replace it with (must be different from old_string)"),
1369
+ replaceAll: zod.z.boolean().optional().describe(
1448
1370
  "Replace all occurrences of old_string (default: false). Useful for renaming variables"
1449
1371
  )
1450
1372
  });
@@ -1452,7 +1374,7 @@ async function editFileTool(args, options = {}) {
1452
1374
  const { filePath, oldString, newString, replaceAll = false } = args;
1453
1375
  let content;
1454
1376
  try {
1455
- content = options.sandboxClient ? await options.sandboxClient.readFile(filePath) : await (0, import_promises4.readFile)(filePath, "utf8");
1377
+ content = options.sandboxClient ? await options.sandboxClient.readFile(filePath) : await promises.readFile(filePath, "utf8");
1456
1378
  } catch (err) {
1457
1379
  const result2 = {
1458
1380
  success: false,
@@ -1518,28 +1440,22 @@ function createEditTool(options = {}) {
1518
1440
  );
1519
1441
  }
1520
1442
  var editTool = createEditTool();
1521
-
1522
- // src/builtins/glob-tool.ts
1523
- var import_promises5 = require("fs/promises");
1524
- var import_node_path3 = require("path");
1525
- var import_fast_glob = __toESM(require("fast-glob"), 1);
1526
- var import_zod5 = require("zod");
1527
1443
  var DEFAULT_MAX_RESULTS = 1e3;
1528
- var GlobSchema = import_zod5.z.object({
1529
- pattern: import_zod5.z.string().describe('The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.tsx")'),
1530
- path: import_zod5.z.string().optional().describe(
1444
+ var GlobSchema = zod.z.object({
1445
+ pattern: zod.z.string().describe('The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.tsx")'),
1446
+ path: zod.z.string().optional().describe(
1531
1447
  "The directory to search in. Defaults to the current working directory. Must be a valid directory path if provided"
1532
1448
  ),
1533
- limit: import_zod5.z.number().optional().describe(
1449
+ limit: zod.z.number().optional().describe(
1534
1450
  "Maximum number of results to return (default: 1000). Use a smaller limit to save context space"
1535
1451
  )
1536
1452
  });
1537
1453
  async function globFileTool(args) {
1538
1454
  const { pattern, path: basePath } = args;
1539
- const cwd = basePath ? (0, import_node_path3.resolve)(basePath) : process.cwd();
1455
+ const cwd = basePath ? path.resolve(basePath) : process.cwd();
1540
1456
  let matches;
1541
1457
  try {
1542
- matches = await (0, import_fast_glob.default)(pattern, {
1458
+ matches = await fg__default.default(pattern, {
1543
1459
  cwd,
1544
1460
  ignore: ["**/node_modules/**", "**/.git/**"],
1545
1461
  dot: true,
@@ -1555,9 +1471,9 @@ async function globFileTool(args) {
1555
1471
  }
1556
1472
  const withMtime = await Promise.all(
1557
1473
  matches.map(async (p) => {
1558
- const absPath = (0, import_node_path3.resolve)(cwd, p);
1474
+ const absPath = path.resolve(cwd, p);
1559
1475
  try {
1560
- const s = await (0, import_promises5.stat)(absPath);
1476
+ const s = await promises.stat(absPath);
1561
1477
  return { path: p, mtime: s.mtimeMs };
1562
1478
  } catch {
1563
1479
  return { path: p, mtime: 0 };
@@ -1590,21 +1506,16 @@ var globTool = createZodFunctionTool(
1590
1506
  return globFileTool(params);
1591
1507
  }
1592
1508
  );
1593
-
1594
- // src/builtins/grep-tool.ts
1595
- var import_promises6 = require("fs/promises");
1596
- var import_node_path4 = require("path");
1597
- var import_zod6 = require("zod");
1598
- var GrepSchema = import_zod6.z.object({
1599
- pattern: import_zod6.z.string().describe("The regular expression pattern to search for in file contents"),
1600
- path: import_zod6.z.string().optional().describe("File or directory to search in. Defaults to the current working directory"),
1601
- glob: import_zod6.z.string().optional().describe(
1509
+ var GrepSchema = zod.z.object({
1510
+ pattern: zod.z.string().describe("The regular expression pattern to search for in file contents"),
1511
+ path: zod.z.string().optional().describe("File or directory to search in. Defaults to the current working directory"),
1512
+ glob: zod.z.string().optional().describe(
1602
1513
  'Glob pattern to filter files (e.g. "*.ts", "*.{ts,tsx}"). Only files matching this pattern will be searched'
1603
1514
  ),
1604
- contextLines: import_zod6.z.number().optional().describe(
1515
+ contextLines: zod.z.number().optional().describe(
1605
1516
  'Number of context lines to show before and after each match. Only applies when outputMode is "content". Default: 0'
1606
1517
  ),
1607
- outputMode: import_zod6.z.enum(["files_with_matches", "content"]).optional().describe(
1518
+ outputMode: zod.z.enum(["files_with_matches", "content"]).optional().describe(
1608
1519
  'Output mode: "files_with_matches" shows only file paths (default), "content" shows matching lines with context'
1609
1520
  )
1610
1521
  });
@@ -1621,16 +1532,16 @@ async function collectFiles(dirPath, glob) {
1621
1532
  async function walk(current) {
1622
1533
  let entryNames;
1623
1534
  try {
1624
- entryNames = await (0, import_promises6.readdir)(current);
1535
+ entryNames = await promises.readdir(current);
1625
1536
  } catch {
1626
1537
  return;
1627
1538
  }
1628
1539
  for (const name of entryNames) {
1629
1540
  if (name === "node_modules" || name === ".git") continue;
1630
- const fullPath = (0, import_node_path4.join)(current, name);
1541
+ const fullPath = path.join(current, name);
1631
1542
  let fileStat;
1632
1543
  try {
1633
- fileStat = await (0, import_promises6.stat)(fullPath);
1544
+ fileStat = await promises.stat(fullPath);
1634
1545
  } catch {
1635
1546
  continue;
1636
1547
  }
@@ -1686,7 +1597,7 @@ async function grepFileTool(args) {
1686
1597
  contextLines = 0,
1687
1598
  outputMode = "files_with_matches"
1688
1599
  } = args;
1689
- const targetPath = searchPath ? (0, import_node_path4.resolve)(searchPath) : process.cwd();
1600
+ const targetPath = searchPath ? path.resolve(searchPath) : process.cwd();
1690
1601
  let regex;
1691
1602
  try {
1692
1603
  regex = new RegExp(pattern);
@@ -1700,7 +1611,7 @@ async function grepFileTool(args) {
1700
1611
  }
1701
1612
  let targetStat;
1702
1613
  try {
1703
- targetStat = await (0, import_promises6.stat)(targetPath);
1614
+ targetStat = await promises.stat(targetPath);
1704
1615
  } catch {
1705
1616
  const result2 = {
1706
1617
  success: false,
@@ -1719,7 +1630,7 @@ async function grepFileTool(args) {
1719
1630
  for (const filePath of files) {
1720
1631
  let content;
1721
1632
  try {
1722
- const buffer = await (0, import_promises6.readFile)(filePath);
1633
+ const buffer = await promises.readFile(filePath);
1723
1634
  const checkLen = Math.min(buffer.length, 8192);
1724
1635
  let hasBinary = false;
1725
1636
  for (let i = 0; i < checkLen; i++) {
@@ -1750,14 +1661,11 @@ var grepTool = createZodFunctionTool(
1750
1661
  return grepFileTool(params);
1751
1662
  }
1752
1663
  );
1753
-
1754
- // src/builtins/web-fetch-tool.ts
1755
- var import_zod7 = require("zod");
1756
1664
  var DEFAULT_TIMEOUT_MS2 = 3e4;
1757
1665
  var MAX_RESPONSE_BYTES = 5e6;
1758
- var WebFetchSchema = import_zod7.z.object({
1759
- url: import_zod7.z.string().describe("The URL to fetch"),
1760
- headers: import_zod7.z.record(import_zod7.z.string()).optional().describe("Optional HTTP headers as key-value pairs")
1666
+ var WebFetchSchema = zod.z.object({
1667
+ url: zod.z.string().describe("The URL to fetch"),
1668
+ headers: zod.z.record(zod.z.string()).optional().describe("Optional HTTP headers as key-value pairs")
1761
1669
  });
1762
1670
  function htmlToText(html) {
1763
1671
  return html.replace(/<script[\s\S]*?<\/script>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "").replace(/<[^>]+>/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
@@ -1818,14 +1726,11 @@ var webFetchTool = createZodFunctionTool(
1818
1726
  WebFetchSchema,
1819
1727
  async (params) => runWebFetch(params)
1820
1728
  );
1821
-
1822
- // src/builtins/web-search-tool.ts
1823
- var import_zod8 = require("zod");
1824
1729
  var DEFAULT_LIMIT2 = 10;
1825
1730
  var DEFAULT_TIMEOUT_MS3 = 15e3;
1826
- var WebSearchSchema = import_zod8.z.object({
1827
- query: import_zod8.z.string().describe("The search query"),
1828
- limit: import_zod8.z.number().optional().describe(`Maximum number of results to return (default: ${DEFAULT_LIMIT2})`)
1731
+ var WebSearchSchema = zod.z.object({
1732
+ query: zod.z.string().describe("The search query"),
1733
+ limit: zod.z.number().optional().describe(`Maximum number of results to return (default: ${DEFAULT_LIMIT2})`)
1829
1734
  });
1830
1735
  async function runWebSearch(args) {
1831
1736
  const { query, limit = DEFAULT_LIMIT2 } = args;
@@ -1882,29 +1787,27 @@ var webSearchTool = createZodFunctionTool(
1882
1787
  WebSearchSchema,
1883
1788
  async (params) => runWebSearch(params)
1884
1789
  );
1885
- // Annotate the CommonJS export names for ESM import in node:
1886
- 0 && (module.exports = {
1887
- E2BSandboxClient,
1888
- FunctionTool,
1889
- InMemorySandboxClient,
1890
- OpenAPITool,
1891
- ToolRegistry,
1892
- applyWorkspaceManifest,
1893
- bashTool,
1894
- createBashTool,
1895
- createEditTool,
1896
- createFunctionTool,
1897
- createOpenAPITool,
1898
- createReadTool,
1899
- createWriteTool,
1900
- createZodFunctionTool,
1901
- editTool,
1902
- globTool,
1903
- grepTool,
1904
- readTool,
1905
- validateWorkspaceManifestPath,
1906
- webFetchTool,
1907
- webSearchTool,
1908
- writeTool,
1909
- zodToJsonSchema
1910
- });
1790
+
1791
+ exports.E2BSandboxClient = E2BSandboxClient;
1792
+ exports.FunctionTool = FunctionTool;
1793
+ exports.InMemorySandboxClient = InMemorySandboxClient;
1794
+ exports.OpenAPITool = OpenAPITool;
1795
+ exports.ToolRegistry = ToolRegistry;
1796
+ exports.applyWorkspaceManifest = applyWorkspaceManifest;
1797
+ exports.bashTool = bashTool;
1798
+ exports.createBashTool = createBashTool;
1799
+ exports.createEditTool = createEditTool;
1800
+ exports.createFunctionTool = createFunctionTool;
1801
+ exports.createOpenAPITool = createOpenAPITool;
1802
+ exports.createReadTool = createReadTool;
1803
+ exports.createWriteTool = createWriteTool;
1804
+ exports.createZodFunctionTool = createZodFunctionTool;
1805
+ exports.editTool = editTool;
1806
+ exports.globTool = globTool;
1807
+ exports.grepTool = grepTool;
1808
+ exports.readTool = readTool;
1809
+ exports.validateWorkspaceManifestPath = validateWorkspaceManifestPath;
1810
+ exports.webFetchTool = webFetchTool;
1811
+ exports.webSearchTool = webSearchTool;
1812
+ exports.writeTool = writeTool;
1813
+ exports.zodToJsonSchema = zodToJsonSchema;