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,30 @@
1
+ import * as ai from 'ai';
2
+
3
+ /**
4
+ * Generate the description prompt for the web-search tool.
5
+ *
6
+ * @returns The full description string for the web-search tool.
7
+ */
8
+ declare function getPrompt(): string;
9
+
10
+ interface WebSearchConfig {
11
+ /** Callback to perform the actual search. Users provide their own implementation. */
12
+ onSearch?: (query: string, opts: {
13
+ allowed_domains?: string[];
14
+ blocked_domains?: string[];
15
+ }) => Promise<string>;
16
+ /** Override the default tool description. */
17
+ description?: string;
18
+ }
19
+ declare function createWebSearch(config?: WebSearchConfig): ai.Tool<{
20
+ query: string;
21
+ allowed_domains?: string[] | undefined;
22
+ blocked_domains?: string[] | undefined;
23
+ }, string>;
24
+ declare const webSearch: ai.Tool<{
25
+ query: string;
26
+ allowed_domains?: string[] | undefined;
27
+ blocked_domains?: string[] | undefined;
28
+ }, string>;
29
+
30
+ export { type WebSearchConfig, createWebSearch, webSearch, getPrompt as webSearchPrompt };
@@ -0,0 +1,11 @@
1
+ import {
2
+ createWebSearch,
3
+ getPrompt,
4
+ webSearch
5
+ } from "../chunk-CJA76MKM.js";
6
+ import "../chunk-X6ZY2KFU.js";
7
+ export {
8
+ createWebSearch,
9
+ webSearch,
10
+ getPrompt as webSearchPrompt
11
+ };
@@ -1,10 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkJCTBB7H2cjs = require('../chunk-JCTBB7H2.cjs');
5
- require('../chunk-CAEVLIQB.cjs');
4
+
5
+ var _chunkABXTBB2Ncjs = require('../chunk-ABXTBB2N.cjs');
6
+ require('../chunk-BIAODQ2P.cjs');
6
7
  require('../chunk-QZ5GS6HW.cjs');
8
+ require('../chunk-KONXT2SF.cjs');
9
+
7
10
 
8
11
 
9
12
 
10
- exports.createWrite = _chunkJCTBB7H2cjs.createWrite; exports.write = _chunkJCTBB7H2cjs.write;
13
+ exports.createWrite = _chunkABXTBB2Ncjs.createWrite; exports.write = _chunkABXTBB2Ncjs.write; exports.writePrompt = _chunkABXTBB2Ncjs.getPrompt;
@@ -1,7 +1,17 @@
1
1
  import * as ai from 'ai';
2
2
  import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
3
3
 
4
- type WriteConfig = BaseToolConfig;
4
+ /**
5
+ * Generate the description prompt for the write tool.
6
+ *
7
+ * @returns The full description string for the write tool.
8
+ */
9
+ declare function getPrompt(): string;
10
+
11
+ type WriteConfig = BaseToolConfig & {
12
+ /** Override the default tool description. */
13
+ description?: string;
14
+ };
5
15
  /**
6
16
  * Creates a write tool that writes text content to a file.
7
17
  *
@@ -23,7 +33,7 @@ type WriteConfig = BaseToolConfig;
23
33
  * );
24
34
  * ```
25
35
  */
26
- declare function createWrite(config?: BaseToolConfig): ai.Tool<{
36
+ declare function createWrite(config?: WriteConfig): ai.Tool<{
27
37
  content: string;
28
38
  file_path: string;
29
39
  }, string>;
@@ -44,4 +54,4 @@ declare const write: ai.Tool<{
44
54
  file_path: string;
45
55
  }, string>;
46
56
 
47
- export { type WriteConfig, createWrite, write };
57
+ export { type WriteConfig, createWrite, write, getPrompt as writePrompt };
@@ -1,7 +1,17 @@
1
1
  import * as ai from 'ai';
2
2
  import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
3
3
 
4
- type WriteConfig = BaseToolConfig;
4
+ /**
5
+ * Generate the description prompt for the write tool.
6
+ *
7
+ * @returns The full description string for the write tool.
8
+ */
9
+ declare function getPrompt(): string;
10
+
11
+ type WriteConfig = BaseToolConfig & {
12
+ /** Override the default tool description. */
13
+ description?: string;
14
+ };
5
15
  /**
6
16
  * Creates a write tool that writes text content to a file.
7
17
  *
@@ -23,7 +33,7 @@ type WriteConfig = BaseToolConfig;
23
33
  * );
24
34
  * ```
25
35
  */
26
- declare function createWrite(config?: BaseToolConfig): ai.Tool<{
36
+ declare function createWrite(config?: WriteConfig): ai.Tool<{
27
37
  content: string;
28
38
  file_path: string;
29
39
  }, string>;
@@ -44,4 +54,4 @@ declare const write: ai.Tool<{
44
54
  file_path: string;
45
55
  }, string>;
46
56
 
47
- export { type WriteConfig, createWrite, write };
57
+ export { type WriteConfig, createWrite, write, getPrompt as writePrompt };
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  createWrite,
3
+ getPrompt,
3
4
  write
4
- } from "../chunk-7QL4BQCH.js";
5
- import "../chunk-6PQLFDGT.js";
5
+ } from "../chunk-NTGDU5X3.js";
6
+ import "../chunk-PWBVB6MN.js";
6
7
  import "../chunk-I3ONDY7P.js";
8
+ import "../chunk-X6ZY2KFU.js";
7
9
  export {
8
10
  createWrite,
9
- write
11
+ write,
12
+ getPrompt as writePrompt
10
13
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "agentool",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
- "description": "16 AI agent tools as standalone Vercel AI SDK modules",
5
+ "description": "22 AI agent tools as standalone Vercel AI SDK modules",
6
6
  "author": "Z-M-Huang",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {
@@ -89,10 +89,35 @@
89
89
  "import": "./dist/diff/index.js",
90
90
  "require": "./dist/diff/index.cjs"
91
91
  },
92
- "./task": {
93
- "types": "./dist/task/index.d.ts",
94
- "import": "./dist/task/index.js",
95
- "require": "./dist/task/index.cjs"
92
+ "./task-create": {
93
+ "types": "./dist/task-create/index.d.ts",
94
+ "import": "./dist/task-create/index.js",
95
+ "require": "./dist/task-create/index.cjs"
96
+ },
97
+ "./task-get": {
98
+ "types": "./dist/task-get/index.d.ts",
99
+ "import": "./dist/task-get/index.js",
100
+ "require": "./dist/task-get/index.cjs"
101
+ },
102
+ "./task-update": {
103
+ "types": "./dist/task-update/index.d.ts",
104
+ "import": "./dist/task-update/index.js",
105
+ "require": "./dist/task-update/index.cjs"
106
+ },
107
+ "./task-list": {
108
+ "types": "./dist/task-list/index.d.ts",
109
+ "import": "./dist/task-list/index.js",
110
+ "require": "./dist/task-list/index.cjs"
111
+ },
112
+ "./web-search": {
113
+ "types": "./dist/web-search/index.d.ts",
114
+ "import": "./dist/web-search/index.js",
115
+ "require": "./dist/web-search/index.cjs"
116
+ },
117
+ "./tool-search": {
118
+ "types": "./dist/tool-search/index.d.ts",
119
+ "import": "./dist/tool-search/index.js",
120
+ "require": "./dist/tool-search/index.cjs"
96
121
  },
97
122
  "./lsp": {
98
123
  "types": "./dist/lsp/index.d.ts",
@@ -1,30 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/ask-user/index.ts
2
- var _ai = require('ai');
3
- var _zod = require('zod');
4
- function createAskUser(config = {}) {
5
- return _ai.tool.call(void 0, {
6
- description: "Ask the user a question and wait for their response. Use this when you need clarification, confirmation, or additional information from the user before proceeding.",
7
- inputSchema: _zod.z.object({
8
- question: _zod.z.string().describe("The question to ask the user"),
9
- options: _zod.z.array(_zod.z.string()).optional().describe("Optional list of suggested response options")
10
- }),
11
- execute: async ({ question, options }) => {
12
- if (!config.onQuestion) {
13
- return "Error [ask-user]: No onQuestion callback configured. Provide an onQuestion function in the tool config to enable user interaction.";
14
- }
15
- try {
16
- const response = await config.onQuestion(question, options);
17
- return response;
18
- } catch (error) {
19
- const msg = error instanceof Error ? error.message : String(error);
20
- return `Error [ask-user]: Failed to get user response: ${msg}`;
21
- }
22
- }
23
- });
24
- }
25
- var askUser = createAskUser();
26
-
27
-
28
-
29
-
30
- exports.createAskUser = createAskUser; exports.askUser = askUser;
@@ -1,40 +0,0 @@
1
- import {
2
- pathExists,
3
- writeTextContent
4
- } from "./chunk-6PQLFDGT.js";
5
- import {
6
- expandPath
7
- } from "./chunk-I3ONDY7P.js";
8
-
9
- // src/write/index.ts
10
- import { tool } from "ai";
11
- import { z } from "zod";
12
- function createWrite(config = {}) {
13
- const cwd = config.cwd ?? process.cwd();
14
- return tool({
15
- description: "Write text content to a file, creating parent directories as needed. If the file exists it is overwritten. Use this to create new files or replace existing file contents.",
16
- inputSchema: z.object({
17
- file_path: z.string().describe("Path to the file to write"),
18
- content: z.string().describe("Text content to write to the file")
19
- }),
20
- execute: async ({ file_path, content }) => {
21
- try {
22
- const absolutePath = expandPath(file_path, cwd);
23
- const existed = await pathExists(absolutePath);
24
- await writeTextContent(absolutePath, content);
25
- const bytes = Buffer.byteLength(content, "utf-8");
26
- const verb = existed ? "Updated" : "Created";
27
- return `${verb} file: ${absolutePath} (${bytes} bytes)`;
28
- } catch (error) {
29
- const message = error instanceof Error ? error.message : String(error);
30
- return `Error [write]: Failed to write file: ${message}`;
31
- }
32
- }
33
- });
34
- }
35
- var write = createWrite();
36
-
37
- export {
38
- createWrite,
39
- write
40
- };
@@ -1,136 +0,0 @@
1
- // src/task/index.ts
2
- import { tool } from "ai";
3
- import { z } from "zod";
4
- import { mkdir, readFile, writeFile } from "fs/promises";
5
- import { dirname, join } from "path";
6
- import { randomBytes } from "crypto";
7
- function generateId() {
8
- return randomBytes(4).toString("hex");
9
- }
10
- async function loadTasks(filePath) {
11
- try {
12
- const data = await readFile(filePath, "utf-8");
13
- return JSON.parse(data);
14
- } catch {
15
- return [];
16
- }
17
- }
18
- async function saveTasks(filePath, tasks) {
19
- await mkdir(dirname(filePath), { recursive: true });
20
- await writeFile(filePath, JSON.stringify(tasks, null, 2), "utf-8");
21
- }
22
- function formatTask(t) {
23
- return [
24
- `ID: ${t.id}`,
25
- `Subject: ${t.subject}`,
26
- `Description: ${t.description}`,
27
- `Status: ${t.status}`,
28
- `Created: ${t.createdAt}`,
29
- `Updated: ${t.updatedAt}`
30
- ].join("\n");
31
- }
32
- function createTask(config = {}) {
33
- const cwd = config.cwd ?? process.cwd();
34
- const tasksFile = config.tasksFile ?? join(cwd, ".agentool", "tasks.json");
35
- return tool({
36
- description: "JSON file-based task tracker. Use this to create, get, update, list, and delete tasks. Each task has an id, subject, description, status, and timestamps.",
37
- inputSchema: z.object({
38
- action: z.enum(["create", "get", "update", "list", "delete"]).describe(
39
- "The operation to perform"
40
- ),
41
- id: z.string().optional().describe(
42
- "Task id (required for get, update, delete)"
43
- ),
44
- subject: z.string().optional().describe(
45
- "Task subject (required for create, optional for update)"
46
- ),
47
- description: z.string().optional().describe(
48
- "Task description (required for create, optional for update)"
49
- ),
50
- status: z.enum(["pending", "in_progress", "completed"]).optional().describe(
51
- "Task status (optional for create/update, defaults to pending)"
52
- )
53
- }),
54
- execute: async ({ action, id, subject, description, status }) => {
55
- try {
56
- switch (action) {
57
- case "create":
58
- return await createEntry(tasksFile, subject, description, status);
59
- case "list":
60
- return await listEntries(tasksFile);
61
- case "get":
62
- return await getEntry(tasksFile, id);
63
- case "update":
64
- return await updateEntry(tasksFile, id, subject, description, status);
65
- case "delete":
66
- return await deleteEntry(tasksFile, id);
67
- default:
68
- return `Error [task]: Unknown action "${String(action)}".`;
69
- }
70
- } catch (error) {
71
- const msg = error instanceof Error ? error.message : String(error);
72
- return `Error [task]: ${msg}`;
73
- }
74
- }
75
- });
76
- }
77
- async function createEntry(filePath, subject, description, status) {
78
- if (!subject) return "Error [task]: Subject is required for create action.";
79
- if (!description) return "Error [task]: Description is required for create action.";
80
- const tasks = await loadTasks(filePath);
81
- const now = (/* @__PURE__ */ new Date()).toISOString();
82
- const entry = {
83
- id: generateId(),
84
- subject,
85
- description,
86
- status: status ?? "pending",
87
- createdAt: now,
88
- updatedAt: now
89
- };
90
- tasks.push(entry);
91
- await saveTasks(filePath, tasks);
92
- return `Created task ${entry.id}.
93
- ${formatTask(entry)}`;
94
- }
95
- async function listEntries(filePath) {
96
- const tasks = await loadTasks(filePath);
97
- if (tasks.length === 0) return "No tasks found.";
98
- return tasks.map(formatTask).join("\n---\n");
99
- }
100
- async function getEntry(filePath, id) {
101
- if (!id) return "Error [task]: ID is required for get action.";
102
- const tasks = await loadTasks(filePath);
103
- const found = tasks.find((t) => t.id === id);
104
- if (!found) return `Error [task]: Task "${id}" not found.`;
105
- return formatTask(found);
106
- }
107
- async function updateEntry(filePath, id, subject, description, status) {
108
- if (!id) return "Error [task]: ID is required for update action.";
109
- const tasks = await loadTasks(filePath);
110
- const idx = tasks.findIndex((t) => t.id === id);
111
- if (idx === -1) return `Error [task]: Task "${id}" not found.`;
112
- const entry = tasks[idx];
113
- if (subject) entry.subject = subject;
114
- if (description) entry.description = description;
115
- if (status) entry.status = status;
116
- entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
117
- tasks[idx] = entry;
118
- await saveTasks(filePath, tasks);
119
- return `Updated task ${id}.
120
- ${formatTask(entry)}`;
121
- }
122
- async function deleteEntry(filePath, id) {
123
- if (!id) return "Error [task]: ID is required for delete action.";
124
- const tasks = await loadTasks(filePath);
125
- const idx = tasks.findIndex((t) => t.id === id);
126
- if (idx === -1) return `Error [task]: Task "${id}" not found.`;
127
- tasks.splice(idx, 1);
128
- await saveTasks(filePath, tasks);
129
- return `Deleted task "${id}".`;
130
- }
131
- var task = createTask();
132
-
133
- export {
134
- createTask,
135
- task
136
- };
@@ -1,30 +0,0 @@
1
- // src/ask-user/index.ts
2
- import { tool } from "ai";
3
- import { z } from "zod";
4
- function createAskUser(config = {}) {
5
- return tool({
6
- description: "Ask the user a question and wait for their response. Use this when you need clarification, confirmation, or additional information from the user before proceeding.",
7
- inputSchema: z.object({
8
- question: z.string().describe("The question to ask the user"),
9
- options: z.array(z.string()).optional().describe("Optional list of suggested response options")
10
- }),
11
- execute: async ({ question, options }) => {
12
- if (!config.onQuestion) {
13
- return "Error [ask-user]: No onQuestion callback configured. Provide an onQuestion function in the tool config to enable user interaction.";
14
- }
15
- try {
16
- const response = await config.onQuestion(question, options);
17
- return response;
18
- } catch (error) {
19
- const msg = error instanceof Error ? error.message : String(error);
20
- return `Error [ask-user]: Failed to get user response: ${msg}`;
21
- }
22
- }
23
- });
24
- }
25
- var askUser = createAskUser();
26
-
27
- export {
28
- createAskUser,
29
- askUser
30
- };
@@ -1,40 +0,0 @@
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 _chunkCAEVLIQBcjs = require('./chunk-CAEVLIQB.cjs');
5
-
6
-
7
- var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
8
-
9
- // src/write/index.ts
10
- var _ai = require('ai');
11
- var _zod = require('zod');
12
- function createWrite(config = {}) {
13
- const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
14
- return _ai.tool.call(void 0, {
15
- description: "Write text content to a file, creating parent directories as needed. If the file exists it is overwritten. Use this to create new files or replace existing file contents.",
16
- inputSchema: _zod.z.object({
17
- file_path: _zod.z.string().describe("Path to the file to write"),
18
- content: _zod.z.string().describe("Text content to write to the file")
19
- }),
20
- execute: async ({ file_path, content }) => {
21
- try {
22
- const absolutePath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
23
- const existed = await _chunkCAEVLIQBcjs.pathExists.call(void 0, absolutePath);
24
- await _chunkCAEVLIQBcjs.writeTextContent.call(void 0, absolutePath, content);
25
- const bytes = Buffer.byteLength(content, "utf-8");
26
- const verb = existed ? "Updated" : "Created";
27
- return `${verb} file: ${absolutePath} (${bytes} bytes)`;
28
- } catch (error) {
29
- const message = error instanceof Error ? error.message : String(error);
30
- return `Error [write]: Failed to write file: ${message}`;
31
- }
32
- }
33
- });
34
- }
35
- var write = createWrite();
36
-
37
-
38
-
39
-
40
- exports.createWrite = createWrite; exports.write = write;
@@ -1,40 +0,0 @@
1
- // src/sleep/index.ts
2
- import { tool, zodSchema } from "ai";
3
- import { z } from "zod";
4
- function createSleep(config = {}) {
5
- const maxDuration = config.maxDuration ?? 3e5;
6
- return tool({
7
- description: "Pause execution for a specified duration. Useful for rate limiting, polling intervals, or waiting for external processes. Maximum duration is 300 seconds (5 minutes).",
8
- inputSchema: zodSchema(
9
- z.object({
10
- durationMs: z.number().describe("Duration to sleep in milliseconds"),
11
- reason: z.string().optional().describe("Optional reason for the sleep")
12
- })
13
- ),
14
- execute: async ({ durationMs, reason }) => {
15
- try {
16
- const clamped = Math.max(0, Math.min(durationMs, maxDuration));
17
- const start = Date.now();
18
- await new Promise((resolve) => setTimeout(resolve, clamped));
19
- const elapsed = Date.now() - start;
20
- const parts = [`Slept for ${elapsed}ms`];
21
- if (reason) parts.push(`Reason: ${reason}`);
22
- if (clamped !== durationMs) {
23
- parts.push(
24
- `(clamped from ${durationMs}ms to ${clamped}ms, max: ${maxDuration}ms)`
25
- );
26
- }
27
- return parts.join(". ");
28
- } catch (error) {
29
- const message = error instanceof Error ? error.message : String(error);
30
- return `Sleep failed: ${message}`;
31
- }
32
- }
33
- });
34
- }
35
- var sleep = createSleep();
36
-
37
- export {
38
- createSleep,
39
- sleep
40
- };
@@ -1,73 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunk5NW4OGRIcjs = require('./chunk-5NW4OGRI.cjs');
6
-
7
-
8
- var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
9
-
10
- // src/edit/index.ts
11
- var _promises = require('fs/promises');
12
- var _ai = require('ai');
13
- var _zod = require('zod');
14
- function createEdit(config = {}) {
15
- return _ai.tool.call(void 0, {
16
- description: "Perform an exact string replacement in a file. Locates old_string in the file and replaces it with new_string. Supports curly-quote fallback matching. When replace_all is false (default), old_string must appear exactly once.",
17
- inputSchema: _zod.z.object({
18
- file_path: _zod.z.string().describe("Path to the file to edit"),
19
- old_string: _zod.z.string().describe("The exact string to find and replace"),
20
- new_string: _zod.z.string().describe("The replacement string"),
21
- replace_all: _zod.z.boolean().optional().default(false).describe("Replace all occurrences (default: false)")
22
- }),
23
- execute: async ({ file_path, old_string, new_string, replace_all }) => {
24
- try {
25
- const resolved = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, config.cwd);
26
- let content;
27
- try {
28
- content = await _promises.readFile.call(void 0, resolved, "utf-8");
29
- } catch (err) {
30
- const msg = err instanceof Error ? err.message : String(err);
31
- return `Error [edit]: Cannot read file "${resolved}": ${msg}`;
32
- }
33
- if (old_string === new_string) {
34
- return "Error [edit]: old_string and new_string are identical \u2014 nothing to change.";
35
- }
36
- const actualOld = _chunk5NW4OGRIcjs.findActualString.call(void 0, content, old_string);
37
- if (actualOld === null) {
38
- const preview = content.slice(0, 200);
39
- return `Error [edit]: old_string not found in "${resolved}". File starts with:
40
- ${preview}`;
41
- }
42
- if (!replace_all) {
43
- let count = 0;
44
- let pos = 0;
45
- while (pos < content.length) {
46
- const idx = content.indexOf(actualOld, pos);
47
- if (idx === -1) break;
48
- count++;
49
- pos = idx + 1;
50
- }
51
- if (count > 1) {
52
- return `Error [edit]: old_string appears ${count} times in "${resolved}". Use replace_all to replace every occurrence, or provide a more specific string.`;
53
- }
54
- }
55
- const styledNew = _chunk5NW4OGRIcjs.preserveQuoteStyle.call(void 0, old_string, actualOld, new_string);
56
- const updated = _chunk5NW4OGRIcjs.applyEditToFile.call(void 0, content, actualOld, styledNew, replace_all);
57
- await _promises.writeFile.call(void 0, resolved, updated, "utf-8");
58
- const snippet = styledNew.length > 0 ? styledNew.slice(0, 200) : "(deletion)";
59
- return `Successfully edited "${resolved}". Replacement snippet:
60
- ${snippet}`;
61
- } catch (error) {
62
- const msg = error instanceof Error ? error.message : String(error);
63
- return `Error [edit]: ${msg}`;
64
- }
65
- }
66
- });
67
- }
68
- var edit = createEdit();
69
-
70
-
71
-
72
-
73
- exports.createEdit = createEdit; exports.edit = edit;
@@ -1,40 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/sleep/index.ts
2
- var _ai = require('ai');
3
- var _zod = require('zod');
4
- function createSleep(config = {}) {
5
- const maxDuration = _nullishCoalesce(config.maxDuration, () => ( 3e5));
6
- return _ai.tool.call(void 0, {
7
- description: "Pause execution for a specified duration. Useful for rate limiting, polling intervals, or waiting for external processes. Maximum duration is 300 seconds (5 minutes).",
8
- inputSchema: _ai.zodSchema.call(void 0,
9
- _zod.z.object({
10
- durationMs: _zod.z.number().describe("Duration to sleep in milliseconds"),
11
- reason: _zod.z.string().optional().describe("Optional reason for the sleep")
12
- })
13
- ),
14
- execute: async ({ durationMs, reason }) => {
15
- try {
16
- const clamped = Math.max(0, Math.min(durationMs, maxDuration));
17
- const start = Date.now();
18
- await new Promise((resolve) => setTimeout(resolve, clamped));
19
- const elapsed = Date.now() - start;
20
- const parts = [`Slept for ${elapsed}ms`];
21
- if (reason) parts.push(`Reason: ${reason}`);
22
- if (clamped !== durationMs) {
23
- parts.push(
24
- `(clamped from ${durationMs}ms to ${clamped}ms, max: ${maxDuration}ms)`
25
- );
26
- }
27
- return parts.join(". ");
28
- } catch (error) {
29
- const message = error instanceof Error ? error.message : String(error);
30
- return `Sleep failed: ${message}`;
31
- }
32
- }
33
- });
34
- }
35
- var sleep = createSleep();
36
-
37
-
38
-
39
-
40
- exports.createSleep = createSleep; exports.sleep = sleep;