agentool 1.0.0 → 1.1.1

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 (156) hide show
  1. package/README.md +132 -21
  2. package/dist/ask-user/index.cjs +5 -2
  3. package/dist/ask-user/index.d.cts +10 -1
  4. package/dist/ask-user/index.d.ts +10 -1
  5. package/dist/ask-user/index.js +5 -2
  6. package/dist/bash/index.cjs +5 -2
  7. package/dist/bash/index.d.cts +14 -1
  8. package/dist/bash/index.d.ts +14 -1
  9. package/dist/bash/index.js +5 -2
  10. package/dist/chunk-2JBLVFB7.cjs +74 -0
  11. package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
  12. package/dist/{chunk-XKG2A3EW.js → chunk-2WSZCOJP.js} +54 -18
  13. package/dist/chunk-3FT4ZPB2.cjs +65 -0
  14. package/dist/{chunk-VLNDEVKS.js → chunk-3LGXZLBH.js} +46 -8
  15. package/dist/{chunk-G3ITTPGX.js → chunk-4MXDQEPA.js} +12 -1
  16. package/dist/{chunk-CGTPF6IS.js → chunk-4UUSERSH.js} +31 -7
  17. package/dist/{chunk-I6KFFQPV.cjs → chunk-5T3SQYI4.cjs} +34 -4
  18. package/dist/chunk-6ULQG2W2.cjs +99 -0
  19. package/dist/chunk-ABXTBB2N.cjs +67 -0
  20. package/dist/{chunk-CAEVLIQB.cjs → chunk-BIAODQ2P.cjs} +17 -1
  21. package/dist/chunk-CJA76MKM.js +59 -0
  22. package/dist/chunk-CM3VRCNX.cjs +59 -0
  23. package/dist/{chunk-SUSAPI5W.cjs → chunk-CXBWF5ON.cjs} +51 -4
  24. package/dist/{chunk-U2YMJM25.cjs → chunk-G6ZVJA4V.cjs} +31 -8
  25. package/dist/chunk-GPHCXS2S.js +99 -0
  26. package/dist/chunk-HG5T47NA.cjs +77 -0
  27. package/dist/chunk-HO4NIRU5.js +65 -0
  28. package/dist/{chunk-HZAQRHBT.js → chunk-IBC4QCGR.js} +27 -2
  29. package/dist/chunk-JYTOARJV.cjs +69 -0
  30. package/dist/chunk-KONXT2SF.cjs +8 -0
  31. package/dist/chunk-KUFZFNPT.cjs +61 -0
  32. package/dist/chunk-L7R4UZSK.js +61 -0
  33. package/dist/{chunk-FV2R5FFQ.cjs → chunk-LNAR3NJQ.cjs} +47 -9
  34. package/dist/chunk-M74OQYNK.js +69 -0
  35. package/dist/{chunk-IMZQ7ELK.cjs → chunk-NQIV6LBH.cjs} +51 -14
  36. package/dist/chunk-NTGDU5X3.js +67 -0
  37. package/dist/{chunk-ONBH74ZV.cjs → chunk-OYLTQJXT.cjs} +32 -8
  38. package/dist/{chunk-6PQLFDGT.js → chunk-PWBVB6MN.js} +17 -1
  39. package/dist/{chunk-QEJV2KZ4.cjs → chunk-RIGL3JTS.cjs} +55 -19
  40. package/dist/chunk-SFDZRLSX.cjs +91 -0
  41. package/dist/chunk-T6STO7PS.cjs +126 -0
  42. package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
  43. package/dist/chunk-TM5L4HA5.js +126 -0
  44. package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
  45. package/dist/chunk-UCA6LURO.js +74 -0
  46. package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
  47. package/dist/chunk-VHLY7LQE.js +53 -0
  48. package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
  49. package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
  50. package/dist/chunk-VQSWMGG7.cjs +53 -0
  51. package/dist/{chunk-Y7KOKDFP.js → chunk-VZRXTFS4.js} +29 -6
  52. package/dist/chunk-WCR62UZ3.js +67 -0
  53. package/dist/chunk-X6ZY2KFU.js +8 -0
  54. package/dist/chunk-XGDE7S2D.cjs +67 -0
  55. package/dist/chunk-XPTW45XY.js +77 -0
  56. package/dist/{chunk-YPPPGGLA.cjs → chunk-YCWJVQYO.cjs} +28 -3
  57. package/dist/chunk-YGXLT6SS.js +91 -0
  58. package/dist/{chunk-5NW4OGRI.cjs → chunk-YTPZHJDC.cjs} +12 -1
  59. package/dist/{chunk-6MDPYALY.js → chunk-ZHVRP3EH.js} +49 -12
  60. package/dist/context-compaction/index.cjs +5 -2
  61. package/dist/context-compaction/index.d.cts +11 -1
  62. package/dist/context-compaction/index.d.ts +11 -1
  63. package/dist/context-compaction/index.js +5 -2
  64. package/dist/diff/index.cjs +6 -2
  65. package/dist/diff/index.d.cts +12 -2
  66. package/dist/diff/index.d.ts +12 -2
  67. package/dist/diff/index.js +7 -3
  68. package/dist/edit/index.cjs +7 -3
  69. package/dist/edit/index.d.cts +15 -5
  70. package/dist/edit/index.d.ts +15 -5
  71. package/dist/edit/index.js +8 -4
  72. package/dist/glob/index.cjs +5 -2
  73. package/dist/glob/index.d.cts +13 -3
  74. package/dist/glob/index.d.ts +13 -3
  75. package/dist/glob/index.js +5 -2
  76. package/dist/grep/index.cjs +6 -2
  77. package/dist/grep/index.d.cts +13 -3
  78. package/dist/grep/index.d.ts +13 -3
  79. package/dist/grep/index.js +6 -2
  80. package/dist/http-request/index.cjs +5 -2
  81. package/dist/http-request/index.d.cts +11 -1
  82. package/dist/http-request/index.d.ts +11 -1
  83. package/dist/http-request/index.js +5 -2
  84. package/dist/index.cjs +93 -19
  85. package/dist/index.d.cts +21 -16
  86. package/dist/index.d.ts +21 -16
  87. package/dist/index.js +113 -39
  88. package/dist/lsp/index.cjs +6 -2
  89. package/dist/lsp/index.d.cts +16 -10
  90. package/dist/lsp/index.d.ts +16 -10
  91. package/dist/lsp/index.js +6 -2
  92. package/dist/memory/index.cjs +6 -2
  93. package/dist/memory/index.d.cts +10 -1
  94. package/dist/memory/index.d.ts +10 -1
  95. package/dist/memory/index.js +6 -2
  96. package/dist/multi-edit/index.cjs +7 -4
  97. package/dist/multi-edit/index.d.cts +12 -2
  98. package/dist/multi-edit/index.d.ts +12 -2
  99. package/dist/multi-edit/index.js +7 -4
  100. package/dist/read/index.cjs +6 -3
  101. package/dist/read/index.d.cts +11 -1
  102. package/dist/read/index.d.ts +11 -1
  103. package/dist/read/index.js +6 -3
  104. package/dist/sleep/index.cjs +5 -2
  105. package/dist/sleep/index.d.cts +11 -1
  106. package/dist/sleep/index.d.ts +11 -1
  107. package/dist/sleep/index.js +5 -2
  108. package/dist/task-create/index.cjs +13 -0
  109. package/dist/task-create/index.d.cts +28 -0
  110. package/dist/task-create/index.d.ts +28 -0
  111. package/dist/task-create/index.js +13 -0
  112. package/dist/task-get/index.cjs +13 -0
  113. package/dist/task-get/index.d.cts +24 -0
  114. package/dist/task-get/index.d.ts +24 -0
  115. package/dist/task-get/index.js +13 -0
  116. package/dist/task-list/index.cjs +13 -0
  117. package/dist/task-list/index.d.cts +20 -0
  118. package/dist/task-list/index.d.ts +20 -0
  119. package/dist/task-list/index.js +13 -0
  120. package/dist/task-update/index.cjs +13 -0
  121. package/dist/task-update/index.d.cts +40 -0
  122. package/dist/task-update/index.d.ts +40 -0
  123. package/dist/task-update/index.js +13 -0
  124. package/dist/tool-search/index.cjs +11 -0
  125. package/dist/tool-search/index.d.cts +27 -0
  126. package/dist/tool-search/index.d.ts +27 -0
  127. package/dist/tool-search/index.js +11 -0
  128. package/dist/web-fetch/index.cjs +5 -2
  129. package/dist/web-fetch/index.d.cts +11 -3
  130. package/dist/web-fetch/index.d.ts +11 -3
  131. package/dist/web-fetch/index.js +5 -2
  132. package/dist/web-search/index.cjs +11 -0
  133. package/dist/web-search/index.d.cts +30 -0
  134. package/dist/web-search/index.d.ts +30 -0
  135. package/dist/web-search/index.js +11 -0
  136. package/dist/write/index.cjs +6 -3
  137. package/dist/write/index.d.cts +13 -3
  138. package/dist/write/index.d.ts +13 -3
  139. package/dist/write/index.js +6 -3
  140. package/package.json +31 -6
  141. package/dist/chunk-3EPGFWZV.cjs +0 -30
  142. package/dist/chunk-7QL4BQCH.js +0 -40
  143. package/dist/chunk-FAEGCFTO.js +0 -136
  144. package/dist/chunk-HDKXSKMO.js +0 -30
  145. package/dist/chunk-JCTBB7H2.cjs +0 -40
  146. package/dist/chunk-MF7CJVIZ.js +0 -40
  147. package/dist/chunk-MXFW3XY6.cjs +0 -73
  148. package/dist/chunk-OXLQ7QVL.cjs +0 -40
  149. package/dist/chunk-S6QEY7UY.js +0 -73
  150. package/dist/chunk-TBVHHF3H.cjs +0 -47
  151. package/dist/chunk-XLD2Y3SS.cjs +0 -136
  152. package/dist/chunk-ZHCMEQJJ.js +0 -47
  153. package/dist/task/index.cjs +0 -8
  154. package/dist/task/index.d.cts +0 -67
  155. package/dist/task/index.d.ts +0 -67
  156. package/dist/task/index.js +0 -8
@@ -0,0 +1,65 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkVQSWMGG7cjs = require('./chunk-VQSWMGG7.cjs');
5
+
6
+
7
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
8
+
9
+ // src/task-list/index.ts
10
+ var _ai = require('ai');
11
+ var _zod = require('zod');
12
+ var _path = require('path');
13
+
14
+ // src/task-list/prompt.ts
15
+ function getPrompt() {
16
+ return `List all tasks with their status, owner, and dependencies.
17
+
18
+ ## When to Use
19
+ - To see what tasks are available to work on (status: pending, not blocked)
20
+ - To check overall progress on the current work
21
+ - To find tasks that are blocked and need dependencies resolved
22
+ - After completing a task \u2014 check for newly unblocked work
23
+ - Before creating new tasks \u2014 check for duplicates
24
+
25
+ ## Output Format
26
+ Returns a summary of each non-deleted task:
27
+ - **id**: Task identifier (use with task-get or task-update)
28
+ - **status**: pending, in_progress, or completed
29
+ - **subject**: Brief description of the task
30
+ - **owner**: Who is assigned (if set)
31
+ - **blockedBy**: Tasks that must complete before this one can start
32
+
33
+ ## Tips
34
+ - Tasks with non-empty \`blockedBy\` lists cannot be started until their dependencies are resolved
35
+ - Use task-get with a specific ID to see full details including description and metadata
36
+ - After marking a task completed, call this tool to find the next available task`;
37
+ }
38
+
39
+ // src/task-list/index.ts
40
+ function createTaskList(config = {}) {
41
+ const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
42
+ const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
43
+ return _ai.tool.call(void 0, {
44
+ description: _nullishCoalesce(config.description, () => ( getPrompt())),
45
+ inputSchema: _zod.z.object({}),
46
+ execute: async () => {
47
+ try {
48
+ const tasks = await _chunkVQSWMGG7cjs.loadTasks.call(void 0, tasksFile);
49
+ const visible = tasks.filter((t) => t.status !== "deleted");
50
+ if (visible.length === 0) return "No tasks found.";
51
+ return visible.map(_chunkVQSWMGG7cjs.formatTaskSummary).join("\n");
52
+ } catch (error) {
53
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
54
+ return `Error [task-list]: ${msg}`;
55
+ }
56
+ }
57
+ });
58
+ }
59
+ var taskList = createTaskList();
60
+
61
+
62
+
63
+
64
+
65
+ exports.getPrompt = getPrompt; exports.createTaskList = createTaskList; exports.taskList = taskList;
@@ -1,12 +1,50 @@
1
+ import {
2
+ listDirectory,
3
+ readTextContent,
4
+ removeFile,
5
+ writeTextContent
6
+ } from "./chunk-PWBVB6MN.js";
1
7
  import {
2
8
  containsPathTraversal
3
9
  } from "./chunk-I3ONDY7P.js";
10
+ import {
11
+ extractErrorMessage
12
+ } from "./chunk-X6ZY2KFU.js";
4
13
 
5
14
  // src/memory/index.ts
6
15
  import { tool } from "ai";
7
16
  import { z } from "zod";
8
- import { mkdir, readFile, readdir, unlink, writeFile } from "fs/promises";
9
17
  import { join } from "path";
18
+
19
+ // src/memory/prompt.ts
20
+ function getPrompt() {
21
+ return `File-based key-value memory store for persisting notes, context, or any text data across conversations.
22
+
23
+ Entries are stored as individual .md files in the memory directory.
24
+
25
+ ## Operations
26
+ - **write**: Store content under a key (creates or overwrites)
27
+ - **read**: Retrieve content by key
28
+ - **list**: List all stored keys
29
+ - **delete**: Remove a key and its content
30
+
31
+ ## When to Use
32
+ - To persist information that should survive across conversations or sessions
33
+ - To store user preferences, project notes, or context summaries
34
+ - To keep a running log of decisions, findings, or important details
35
+
36
+ ## When NOT to Use
37
+ - For temporary data within a single conversation \u2014 just keep it in context
38
+ - For structured task tracking \u2014 use the task management tools instead
39
+
40
+ ## Usage Guidelines
41
+ - Keys are sanitized to prevent path traversal (no ../ allowed)
42
+ - The \`key\` parameter is required for read, write, and delete operations
43
+ - The \`content\` parameter is required for write operations
44
+ - Use descriptive key names for easy discovery (e.g., "user-preferences", "project-architecture")`;
45
+ }
46
+
47
+ // src/memory/index.ts
10
48
  function sanitizeKey(key) {
11
49
  if (!key || key.trim() === "") {
12
50
  return { err: "Error [memory]: Key must not be empty." };
@@ -24,7 +62,7 @@ function createMemory(config = {}) {
24
62
  const cwd = config.cwd ?? process.cwd();
25
63
  const memoryDir = config.memoryDir ?? join(cwd, ".agentool", "memory");
26
64
  return tool({
27
- description: "File-based key-value memory store. Use this to persist notes, context, or any text data across conversations. Supports write, read, list, and delete operations.",
65
+ description: config.description ?? getPrompt(),
28
66
  inputSchema: z.object({
29
67
  action: z.enum(["read", "write", "list", "delete"]).describe(
30
68
  "The operation to perform: read, write, list, or delete"
@@ -55,7 +93,7 @@ function createMemory(config = {}) {
55
93
  return `Error [memory]: Unknown action "${String(action)}".`;
56
94
  }
57
95
  } catch (error) {
58
- const msg = error instanceof Error ? error.message : String(error);
96
+ const msg = extractErrorMessage(error);
59
97
  return `Error [memory]: ${msg}`;
60
98
  }
61
99
  }
@@ -65,20 +103,19 @@ async function writeEntry(dir, key, content) {
65
103
  if (!content && content !== "") {
66
104
  return "Error [memory]: Content is required for write action.";
67
105
  }
68
- await mkdir(dir, { recursive: true });
69
- await writeFile(join(dir, `${key}.md`), content, "utf-8");
106
+ await writeTextContent(join(dir, `${key}.md`), content);
70
107
  return `Saved memory "${key}".`;
71
108
  }
72
109
  async function readEntry(dir, key) {
73
110
  try {
74
- return await readFile(join(dir, `${key}.md`), "utf-8");
111
+ return await readTextContent(join(dir, `${key}.md`));
75
112
  } catch {
76
113
  return `Error [memory]: Key "${key}" not found.`;
77
114
  }
78
115
  }
79
116
  async function listKeys(dir) {
80
117
  try {
81
- const files = await readdir(dir);
118
+ const files = await listDirectory(dir);
82
119
  const keys = files.filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3));
83
120
  if (keys.length === 0) return "No memory entries found.";
84
121
  return keys.join("\n");
@@ -88,7 +125,7 @@ async function listKeys(dir) {
88
125
  }
89
126
  async function deleteEntry(dir, key) {
90
127
  try {
91
- await unlink(join(dir, `${key}.md`));
128
+ await removeFile(join(dir, `${key}.md`));
92
129
  return `Deleted memory "${key}".`;
93
130
  } catch {
94
131
  return `Error [memory]: Key "${key}" not found.`;
@@ -97,6 +134,7 @@ async function deleteEntry(dir, key) {
97
134
  var memory = createMemory();
98
135
 
99
136
  export {
137
+ getPrompt,
100
138
  createMemory,
101
139
  memory
102
140
  };
@@ -47,6 +47,16 @@ function applyEditToFile(originalContent, oldString, newString, replaceAll = fal
47
47
  const stripTrailingNewline = !oldString.endsWith("\n") && originalContent.includes(oldString + "\n");
48
48
  return stripTrailingNewline ? f(originalContent, oldString + "\n", newString) : f(originalContent, oldString, newString);
49
49
  }
50
+ function countOccurrences(text, search) {
51
+ if (search.length === 0) return 0;
52
+ let count = 0;
53
+ let pos = 0;
54
+ while ((pos = text.indexOf(search, pos)) !== -1) {
55
+ count++;
56
+ pos += search.length;
57
+ }
58
+ return count;
59
+ }
50
60
  function isOpeningContext(chars, index) {
51
61
  if (index === 0) {
52
62
  return true;
@@ -95,5 +105,6 @@ function applyCurlySingleQuotes(str) {
95
105
  export {
96
106
  findActualString,
97
107
  preserveQuoteStyle,
98
- applyEditToFile
108
+ applyEditToFile,
109
+ countOccurrences
99
110
  };
@@ -1,14 +1,18 @@
1
+ import {
2
+ readTextContent
3
+ } from "./chunk-PWBVB6MN.js";
1
4
  import {
2
5
  expandPath
3
6
  } from "./chunk-I3ONDY7P.js";
7
+ import {
8
+ extractErrorMessage
9
+ } from "./chunk-X6ZY2KFU.js";
4
10
 
5
11
  // src/diff/index.ts
6
- import { readFile as readFile2 } from "fs/promises";
7
12
  import { tool } from "ai";
8
13
  import { z } from "zod";
9
14
 
10
15
  // src/shared/diff.ts
11
- import { readFile } from "fs/promises";
12
16
  import { createTwoFilesPatch } from "diff";
13
17
  function diffStrings(oldContent, newContent, options) {
14
18
  if (oldContent === newContent) {
@@ -29,8 +33,8 @@ function diffStrings(oldContent, newContent, options) {
29
33
  }
30
34
  async function diffFiles(oldFilePath, newFilePath, options) {
31
35
  const [oldContent, newContent] = await Promise.all([
32
- readFile(oldFilePath, "utf-8"),
33
- readFile(newFilePath, "utf-8")
36
+ readTextContent(oldFilePath),
37
+ readTextContent(newFilePath)
34
38
  ]);
35
39
  return diffStrings(oldContent, newContent, {
36
40
  ...options,
@@ -39,11 +43,30 @@ async function diffFiles(oldFilePath, newFilePath, options) {
39
43
  });
40
44
  }
41
45
 
46
+ // src/diff/prompt.ts
47
+ function getPrompt() {
48
+ return `Generate a unified diff between two files or two strings.
49
+
50
+ Supports three modes:
51
+ 1. **Two file paths**: \`file_path\` + \`other_file_path\` \u2014 compares the contents of both files
52
+ 2. **Two strings**: \`old_content\` + \`new_content\` \u2014 compares the provided strings directly
53
+ 3. **File + string**: \`file_path\` + \`old_content\` or \`new_content\` \u2014 compares a file against provided content
54
+
55
+ ## When to Use
56
+ - To preview what changes would look like before making edits
57
+ - To compare two versions of a file or text
58
+ - To generate a diff for review or documentation purposes
59
+
60
+ ## When NOT to Use
61
+ - To actually apply changes to a file \u2014 use the file editing tool instead
62
+ - To read file contents \u2014 use the file reading tool instead`;
63
+ }
64
+
42
65
  // src/diff/index.ts
43
66
  function createDiff(config = {}) {
44
67
  const cwd = config.cwd ?? process.cwd();
45
68
  return tool({
46
- description: "Generate a unified diff between two files or two strings. Provide file_path + other_file_path to compare files, or old_content + new_content to compare strings. You can also provide file_path with old_content or new_content to compare a file against provided content.",
69
+ description: config.description ?? getPrompt(),
47
70
  inputSchema: z.object({
48
71
  file_path: z.string().optional().describe("Path to the first file (absolute or relative to cwd)"),
49
72
  other_file_path: z.string().optional().describe("Path to the second file (absolute or relative to cwd)"),
@@ -62,7 +85,7 @@ function createDiff(config = {}) {
62
85
  }
63
86
  if (file_path && (old_content !== void 0 || new_content !== void 0)) {
64
87
  const resolvedPath = expandPath(file_path, cwd);
65
- const fileContent = await readFile2(resolvedPath, "utf-8");
88
+ const fileContent = await readTextContent(resolvedPath);
66
89
  if (old_content !== void 0) {
67
90
  return diffStrings(old_content, fileContent, {
68
91
  oldLabel: "provided",
@@ -76,7 +99,7 @@ function createDiff(config = {}) {
76
99
  }
77
100
  return "Error [diff]: Insufficient parameters. Provide either: (1) file_path + other_file_path, (2) old_content + new_content, or (3) file_path + old_content/new_content.";
78
101
  } catch (error) {
79
- const msg = error instanceof Error ? error.message : String(error);
102
+ const msg = extractErrorMessage(error);
80
103
  return `Error [diff]: ${msg}`;
81
104
  }
82
105
  }
@@ -85,6 +108,7 @@ function createDiff(config = {}) {
85
108
  var diff = createDiff();
86
109
 
87
110
  export {
111
+ getPrompt,
88
112
  createDiff,
89
113
  diff
90
114
  };
@@ -1,9 +1,38 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/http-request/index.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
4
+
5
+ // src/http-request/index.ts
2
6
  var _ai = require('ai');
3
7
  var _zod = require('zod');
8
+
9
+ // src/http-request/prompt.ts
10
+ function getPrompt(config = {}) {
11
+ const timeout = _nullishCoalesce(config.timeout, () => ( 3e4));
12
+ return `Make an HTTP request to a URL. Returns the raw response status, headers, and body as JSON.
13
+
14
+ Supports GET, POST, PUT, PATCH, DELETE, and HEAD methods.
15
+
16
+ ## When to Use
17
+ - For API interactions: REST calls, webhook triggers, service health checks
18
+ - When you need full control over HTTP method, headers, and request body
19
+ - When you need the raw response (status codes, headers) not just content
20
+
21
+ ## When NOT to Use
22
+ - To read a web page for its content \u2014 use the web fetch tool instead (it converts HTML to markdown)
23
+ - To search the web \u2014 use the web search tool instead
24
+
25
+ ## Usage Guidelines
26
+ - Default timeout: ${timeout}ms. Override with the timeout parameter.
27
+ - Request body is sent for POST, PUT, and PATCH methods
28
+ - Response is returned as JSON with status, statusText, headers, and body fields
29
+ - Default headers from config are merged with per-request headers (per-request takes precedence)`;
30
+ }
31
+
32
+ // src/http-request/index.ts
4
33
  function createHttpRequest(config = {}) {
5
34
  return _ai.tool.call(void 0, {
6
- description: "Make an HTTP request to a URL. Returns the response status, headers, and body. Use this for API interactions, webhook calls, and service health checks. Unlike web-fetch, this returns raw response data without markdown conversion.",
35
+ description: _nullishCoalesce(config.description, () => ( getPrompt(config))),
7
36
  inputSchema: _zod.z.object({
8
37
  method: _zod.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]).describe("HTTP method"),
9
38
  url: _zod.z.string().describe("The URL to send the request to"),
@@ -44,7 +73,7 @@ function createHttpRequest(config = {}) {
44
73
  if (error instanceof Error && error.name === "AbortError") {
45
74
  return `Error [http-request]: Request timed out after ${effectiveTimeout}ms for ${method} ${url}. Try increasing the timeout or verify the server is responsive.`;
46
75
  }
47
- const msg = error instanceof Error ? error.message : String(error);
76
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
48
77
  return `Error [http-request]: ${method} ${url} failed: ${msg}. Verify the URL is correct and the server is reachable.`;
49
78
  }
50
79
  }
@@ -55,4 +84,5 @@ var httpRequest = createHttpRequest();
55
84
 
56
85
 
57
86
 
58
- exports.createHttpRequest = createHttpRequest; exports.httpRequest = httpRequest;
87
+
88
+ exports.getPrompt = getPrompt; exports.createHttpRequest = createHttpRequest; exports.httpRequest = httpRequest;
@@ -0,0 +1,99 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+
5
+
6
+ var _chunkYTPZHJDCcjs = require('./chunk-YTPZHJDC.cjs');
7
+
8
+
9
+
10
+ var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
11
+
12
+
13
+ var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
14
+
15
+
16
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
17
+
18
+ // src/edit/index.ts
19
+ var _ai = require('ai');
20
+ var _zod = require('zod');
21
+
22
+ // src/edit/prompt.ts
23
+ function getPrompt() {
24
+ return `Perform an exact string replacement in a file. Locates old_string and replaces it with new_string.
25
+
26
+ Supports absolute paths, relative paths, and tilde (~) expansion. Includes curly-quote fallback matching and quote-style preservation.
27
+
28
+ ## When to Use
29
+ - To make targeted changes to existing files
30
+ - To rename variables, update configuration values, or fix bugs
31
+ - Prefer this over the file writing tool for modifying existing files \u2014 it only changes what you specify
32
+
33
+ ## When NOT to Use
34
+ - To create a new file from scratch \u2014 use the file writing tool instead
35
+ - To make many changes at once \u2014 consider the multi-edit tool for batch operations
36
+
37
+ ## Usage Guidelines
38
+ - The edit will fail if \`old_string\` is not found in the file
39
+ - When \`replace_all\` is false (default), \`old_string\` must appear exactly once in the file. If it appears multiple times, provide more surrounding context to make it unique, or set \`replace_all: true\`
40
+ - Use \`replace_all: true\` for renaming a variable or string across the entire file
41
+ - Preserve exact indentation (tabs/spaces) from the original file in both old_string and new_string
42
+ - old_string and new_string must be different`;
43
+ }
44
+
45
+ // src/edit/index.ts
46
+ function createEdit(config = {}) {
47
+ return _ai.tool.call(void 0, {
48
+ description: _nullishCoalesce(config.description, () => ( getPrompt())),
49
+ inputSchema: _zod.z.object({
50
+ file_path: _zod.z.string().describe("The absolute path to the file to modify"),
51
+ old_string: _zod.z.string().describe("The exact string to find and replace"),
52
+ new_string: _zod.z.string().describe("The replacement string"),
53
+ replace_all: _zod.z.boolean().default(false).optional().describe("Replace all occurrences (default: false)")
54
+ }),
55
+ execute: async ({ file_path, old_string, new_string, replace_all }) => {
56
+ try {
57
+ const resolved = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, config.cwd);
58
+ let content;
59
+ try {
60
+ content = await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, resolved);
61
+ } catch (err) {
62
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, err);
63
+ return `Error [edit]: Cannot read file "${resolved}": ${msg}`;
64
+ }
65
+ if (old_string === new_string) {
66
+ return "Error [edit]: old_string and new_string are identical \u2014 nothing to change.";
67
+ }
68
+ const actualOld = _chunkYTPZHJDCcjs.findActualString.call(void 0, content, old_string);
69
+ if (actualOld === null) {
70
+ const preview = content.slice(0, 200);
71
+ return `Error [edit]: old_string not found in "${resolved}". File starts with:
72
+ ${preview}`;
73
+ }
74
+ if (!replace_all) {
75
+ const count = _chunkYTPZHJDCcjs.countOccurrences.call(void 0, content, actualOld);
76
+ if (count > 1) {
77
+ return `Error [edit]: old_string appears ${count} times in "${resolved}". Use replace_all to replace every occurrence, or provide a more specific string.`;
78
+ }
79
+ }
80
+ const styledNew = _chunkYTPZHJDCcjs.preserveQuoteStyle.call(void 0, old_string, actualOld, new_string);
81
+ const updated = _chunkYTPZHJDCcjs.applyEditToFile.call(void 0, content, actualOld, styledNew, replace_all);
82
+ await _chunkBIAODQ2Pcjs.writeTextContent.call(void 0, resolved, updated);
83
+ const snippet = styledNew.length > 0 ? styledNew.slice(0, 200) : "(deletion)";
84
+ return `Successfully edited "${resolved}". Replacement snippet:
85
+ ${snippet}`;
86
+ } catch (error) {
87
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
88
+ return `Error [edit]: ${msg}`;
89
+ }
90
+ }
91
+ });
92
+ }
93
+ var edit = createEdit();
94
+
95
+
96
+
97
+
98
+
99
+ exports.getPrompt = getPrompt; exports.createEdit = createEdit; exports.edit = edit;
@@ -0,0 +1,67 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
5
+
6
+
7
+ var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
8
+
9
+
10
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
11
+
12
+ // src/write/index.ts
13
+ var _ai = require('ai');
14
+ var _zod = require('zod');
15
+
16
+ // src/write/prompt.ts
17
+ function getPrompt() {
18
+ return `Write text content to a file, creating parent directories as needed. If the file already exists it is overwritten entirely.
19
+
20
+ Supports absolute paths, relative paths, and tilde (~) expansion.
21
+
22
+ ## When to Use
23
+ - To create new files that don't exist yet
24
+ - To completely rewrite an existing file's content
25
+ - When the changes are so extensive that targeted editing would be impractical
26
+
27
+ ## When NOT to Use
28
+ - To make small, targeted changes to an existing file \u2014 use the file editing tool instead (it only changes what you specify and is less error-prone)
29
+ - Prefer the editing tool for modifications; reserve this tool for creating new files or complete rewrites
30
+
31
+ ## Usage Guidelines
32
+ - This tool overwrites the entire file \u2014 make sure you include all desired content, not just the changes
33
+ - Parent directories are created automatically if they don't exist
34
+ - Read the existing file first before overwriting it, so you don't accidentally lose content`;
35
+ }
36
+
37
+ // src/write/index.ts
38
+ function createWrite(config = {}) {
39
+ const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
40
+ return _ai.tool.call(void 0, {
41
+ description: _nullishCoalesce(config.description, () => ( getPrompt())),
42
+ inputSchema: _zod.z.object({
43
+ file_path: _zod.z.string().describe("The absolute path to the file to write (must be absolute, not relative)"),
44
+ content: _zod.z.string().describe("Text content to write to the file")
45
+ }),
46
+ execute: async ({ file_path, content }) => {
47
+ try {
48
+ const absolutePath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
49
+ const existed = await _chunkBIAODQ2Pcjs.pathExists.call(void 0, absolutePath);
50
+ await _chunkBIAODQ2Pcjs.writeTextContent.call(void 0, absolutePath, content);
51
+ const bytes = Buffer.byteLength(content, "utf-8");
52
+ const verb = existed ? "Updated" : "Created";
53
+ return `${verb} file: ${absolutePath} (${bytes} bytes)`;
54
+ } catch (error) {
55
+ const message = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
56
+ return `Error [write]: Failed to write file: ${message}`;
57
+ }
58
+ }
59
+ });
60
+ }
61
+ var write = createWrite();
62
+
63
+
64
+
65
+
66
+
67
+ exports.getPrompt = getPrompt; exports.createWrite = createWrite; exports.write = write;
@@ -25,6 +25,18 @@ async function pathExists(path) {
25
25
  return false;
26
26
  }
27
27
  }
28
+ async function readTextContent(filePath) {
29
+ return _promises.readFile.call(void 0, filePath, "utf-8");
30
+ }
31
+ async function listDirectory(dirPath) {
32
+ return _promises.readdir.call(void 0, dirPath);
33
+ }
34
+ async function removeFile(filePath) {
35
+ await _promises.unlink.call(void 0, filePath);
36
+ }
37
+ async function getFileStats(filePath) {
38
+ return _promises.stat.call(void 0, filePath);
39
+ }
28
40
  async function readFileInRange(filePath, offset = 0, maxLines) {
29
41
  const stats = await _promises.stat.call(void 0, filePath);
30
42
  if (stats.isDirectory()) {
@@ -114,4 +126,8 @@ function readFileInRangeStreaming(filePath, offset, maxLines) {
114
126
 
115
127
 
116
128
 
117
- exports.addLineNumbers = addLineNumbers; exports.writeTextContent = writeTextContent; exports.pathExists = pathExists; exports.readFileInRange = readFileInRange;
129
+
130
+
131
+
132
+
133
+ exports.addLineNumbers = addLineNumbers; exports.writeTextContent = writeTextContent; exports.pathExists = pathExists; exports.readTextContent = readTextContent; exports.listDirectory = listDirectory; exports.removeFile = removeFile; exports.getFileStats = getFileStats; exports.readFileInRange = readFileInRange;
@@ -0,0 +1,59 @@
1
+ import {
2
+ extractErrorMessage
3
+ } from "./chunk-X6ZY2KFU.js";
4
+
5
+ // src/web-search/index.ts
6
+ import { tool } from "ai";
7
+ import { z } from "zod";
8
+
9
+ // src/web-search/prompt.ts
10
+ function getPrompt() {
11
+ return `Search the web for information using a search query. Results can be filtered by allowed or blocked domains.
12
+
13
+ Requires an onSearch callback to be configured \u2014 the application provides the actual search implementation.
14
+
15
+ ## When to Use
16
+ - To find current information beyond the model's training data
17
+ - To look up documentation, recent news, or real-time data
18
+ - To verify facts or find authoritative sources
19
+
20
+ ## When NOT to Use
21
+ - To read a specific URL whose address you already know \u2014 use the web fetch tool instead
22
+ - To search file contents in the local codebase \u2014 use the dedicated content search tool instead
23
+
24
+ ## Usage Guidelines
25
+ - After answering a question using search results, include a "Sources:" section listing the relevant URLs
26
+ - Use the current year when searching for recent information or documentation
27
+ - Use \`allowed_domains\` to restrict results to specific sites (e.g., ["docs.python.org"])
28
+ - Use \`blocked_domains\` to exclude specific sites from results`;
29
+ }
30
+
31
+ // src/web-search/index.ts
32
+ function createWebSearch(config = {}) {
33
+ return tool({
34
+ description: config.description ?? getPrompt(),
35
+ inputSchema: z.object({
36
+ query: z.string().min(2).describe("The search query to use"),
37
+ allowed_domains: z.array(z.string()).optional().describe("Only include search results from these domains"),
38
+ blocked_domains: z.array(z.string()).optional().describe("Never include search results from these domains")
39
+ }),
40
+ execute: async ({ query, allowed_domains, blocked_domains }) => {
41
+ try {
42
+ if (!config.onSearch) {
43
+ return "Error [web-search]: No search callback configured. Provide onSearch via createWebSearch({ onSearch: async (query, opts) => ... })";
44
+ }
45
+ return await config.onSearch(query, { allowed_domains, blocked_domains });
46
+ } catch (error) {
47
+ const msg = extractErrorMessage(error);
48
+ return `Error [web-search]: ${msg}`;
49
+ }
50
+ }
51
+ });
52
+ }
53
+ var webSearch = createWebSearch();
54
+
55
+ export {
56
+ getPrompt,
57
+ createWebSearch,
58
+ webSearch
59
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
4
+
5
+ // src/web-search/index.ts
6
+ var _ai = require('ai');
7
+ var _zod = require('zod');
8
+
9
+ // src/web-search/prompt.ts
10
+ function getPrompt() {
11
+ return `Search the web for information using a search query. Results can be filtered by allowed or blocked domains.
12
+
13
+ Requires an onSearch callback to be configured \u2014 the application provides the actual search implementation.
14
+
15
+ ## When to Use
16
+ - To find current information beyond the model's training data
17
+ - To look up documentation, recent news, or real-time data
18
+ - To verify facts or find authoritative sources
19
+
20
+ ## When NOT to Use
21
+ - To read a specific URL whose address you already know \u2014 use the web fetch tool instead
22
+ - To search file contents in the local codebase \u2014 use the dedicated content search tool instead
23
+
24
+ ## Usage Guidelines
25
+ - After answering a question using search results, include a "Sources:" section listing the relevant URLs
26
+ - Use the current year when searching for recent information or documentation
27
+ - Use \`allowed_domains\` to restrict results to specific sites (e.g., ["docs.python.org"])
28
+ - Use \`blocked_domains\` to exclude specific sites from results`;
29
+ }
30
+
31
+ // src/web-search/index.ts
32
+ function createWebSearch(config = {}) {
33
+ return _ai.tool.call(void 0, {
34
+ description: _nullishCoalesce(config.description, () => ( getPrompt())),
35
+ inputSchema: _zod.z.object({
36
+ query: _zod.z.string().min(2).describe("The search query to use"),
37
+ allowed_domains: _zod.z.array(_zod.z.string()).optional().describe("Only include search results from these domains"),
38
+ blocked_domains: _zod.z.array(_zod.z.string()).optional().describe("Never include search results from these domains")
39
+ }),
40
+ execute: async ({ query, allowed_domains, blocked_domains }) => {
41
+ try {
42
+ if (!config.onSearch) {
43
+ return "Error [web-search]: No search callback configured. Provide onSearch via createWebSearch({ onSearch: async (query, opts) => ... })";
44
+ }
45
+ return await config.onSearch(query, { allowed_domains, blocked_domains });
46
+ } catch (error) {
47
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
48
+ return `Error [web-search]: ${msg}`;
49
+ }
50
+ }
51
+ });
52
+ }
53
+ var webSearch = createWebSearch();
54
+
55
+
56
+
57
+
58
+
59
+ exports.getPrompt = getPrompt; exports.createWebSearch = createWebSearch; exports.webSearch = webSearch;