agentool 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +738 -52
  2. package/dist/ask-user/index.cjs +8 -0
  3. package/dist/ask-user/index.d.cts +68 -0
  4. package/dist/ask-user/index.d.ts +68 -0
  5. package/dist/ask-user/index.js +8 -0
  6. package/dist/bash/index.cjs +8 -0
  7. package/dist/bash/index.d.cts +63 -0
  8. package/dist/bash/index.d.ts +63 -0
  9. package/dist/bash/index.js +8 -0
  10. package/dist/chunk-3EPGFWZV.cjs +30 -0
  11. package/dist/chunk-3VO6NETR.cjs +79 -0
  12. package/dist/chunk-44AFQ2B7.js +30 -0
  13. package/dist/chunk-4HIATLKI.js +112 -0
  14. package/dist/chunk-4HXAKPQH.cjs +36 -0
  15. package/dist/chunk-4YI2H55A.js +142 -0
  16. package/dist/chunk-56CL4JCW.cjs +53 -0
  17. package/dist/chunk-5NW4OGRI.cjs +99 -0
  18. package/dist/chunk-5O55DKOB.cjs +112 -0
  19. package/dist/chunk-5TDZF4IM.cjs +197 -0
  20. package/dist/chunk-6DJSWTWQ.cjs +40 -0
  21. package/dist/chunk-6PQLFDGT.js +117 -0
  22. package/dist/chunk-ACGW44YT.js +47 -0
  23. package/dist/chunk-CAEVLIQB.cjs +117 -0
  24. package/dist/chunk-CGTPF6IS.js +90 -0
  25. package/dist/chunk-E6NBEYZD.js +51 -0
  26. package/dist/chunk-EA3YV7ZG.js +79 -0
  27. package/dist/chunk-ECYT46FP.js +40 -0
  28. package/dist/chunk-FV2R5FFQ.cjs +102 -0
  29. package/dist/chunk-FW3UJ622.cjs +59 -0
  30. package/dist/chunk-G3ITTPGX.js +99 -0
  31. package/dist/chunk-HDKXSKMO.js +30 -0
  32. package/dist/chunk-HNP7JDQC.cjs +159 -0
  33. package/dist/chunk-HNUL2CID.cjs +34 -0
  34. package/dist/chunk-HZAQRHBT.js +99 -0
  35. package/dist/chunk-I3ONDY7P.js +46 -0
  36. package/dist/chunk-I6KFFQPV.cjs +58 -0
  37. package/dist/chunk-IEX4NOVN.cjs +48 -0
  38. package/dist/chunk-IRRNYFI5.js +48 -0
  39. package/dist/chunk-K77GC2QI.js +59 -0
  40. package/dist/chunk-L5JH4I77.cjs +51 -0
  41. package/dist/chunk-LK6SQH2G.cjs +30 -0
  42. package/dist/chunk-LPV5CN2K.js +58 -0
  43. package/dist/chunk-LTE5NG4D.js +53 -0
  44. package/dist/chunk-MF7CJVIZ.js +40 -0
  45. package/dist/chunk-MIYA7TNR.cjs +123 -0
  46. package/dist/chunk-MJCAXASI.js +123 -0
  47. package/dist/chunk-OM2UFTGS.cjs +47 -0
  48. package/dist/chunk-ONBH74ZV.cjs +90 -0
  49. package/dist/chunk-OXLQ7QVL.cjs +40 -0
  50. package/dist/chunk-P6Z5XFDS.js +73 -0
  51. package/dist/chunk-QZ5GS6HW.cjs +46 -0
  52. package/dist/chunk-S7IVHOA6.js +75 -0
  53. package/dist/chunk-SUSAPI5W.cjs +142 -0
  54. package/dist/chunk-TMW3XKKJ.js +34 -0
  55. package/dist/chunk-UDIG7332.js +159 -0
  56. package/dist/chunk-VLNDEVKS.js +102 -0
  57. package/dist/chunk-VXZ4RKJI.js +36 -0
  58. package/dist/chunk-XAQGZ374.js +197 -0
  59. package/dist/chunk-YPPPGGLA.cjs +99 -0
  60. package/dist/chunk-ZBLQV6UO.cjs +73 -0
  61. package/dist/chunk-ZFQZWXOI.cjs +75 -0
  62. package/dist/context-compaction/index.cjs +8 -0
  63. package/dist/context-compaction/index.d.cts +77 -0
  64. package/dist/context-compaction/index.d.ts +77 -0
  65. package/dist/context-compaction/index.js +8 -0
  66. package/dist/diff/index.cjs +9 -0
  67. package/dist/diff/index.d.cts +72 -0
  68. package/dist/diff/index.d.ts +72 -0
  69. package/dist/diff/index.js +9 -0
  70. package/dist/edit/index.cjs +10 -0
  71. package/dist/edit/index.d.cts +53 -0
  72. package/dist/edit/index.d.ts +53 -0
  73. package/dist/edit/index.js +10 -0
  74. package/dist/glob/index.cjs +10 -0
  75. package/dist/glob/index.d.cts +47 -0
  76. package/dist/glob/index.d.ts +47 -0
  77. package/dist/glob/index.js +10 -0
  78. package/dist/grep/index.cjs +10 -0
  79. package/dist/grep/index.d.cts +50 -0
  80. package/dist/grep/index.d.ts +50 -0
  81. package/dist/grep/index.js +10 -0
  82. package/dist/http-request/index.cjs +8 -0
  83. package/dist/http-request/index.d.cts +60 -0
  84. package/dist/http-request/index.d.ts +60 -0
  85. package/dist/http-request/index.js +8 -0
  86. package/dist/index.cjs +133 -0
  87. package/dist/index.d.cts +23 -0
  88. package/dist/index.d.ts +23 -0
  89. package/dist/index.js +133 -0
  90. package/dist/lsp/index.cjs +10 -0
  91. package/dist/lsp/index.d.cts +35 -0
  92. package/dist/lsp/index.d.ts +35 -0
  93. package/dist/lsp/index.js +10 -0
  94. package/dist/memory/index.cjs +9 -0
  95. package/dist/memory/index.d.cts +63 -0
  96. package/dist/memory/index.d.ts +63 -0
  97. package/dist/memory/index.js +9 -0
  98. package/dist/multi-edit/index.cjs +11 -0
  99. package/dist/multi-edit/index.d.cts +72 -0
  100. package/dist/multi-edit/index.d.ts +72 -0
  101. package/dist/multi-edit/index.js +11 -0
  102. package/dist/read/index.cjs +10 -0
  103. package/dist/read/index.d.cts +67 -0
  104. package/dist/read/index.d.ts +67 -0
  105. package/dist/read/index.js +10 -0
  106. package/dist/sleep/index.cjs +8 -0
  107. package/dist/sleep/index.d.cts +60 -0
  108. package/dist/sleep/index.d.ts +60 -0
  109. package/dist/sleep/index.js +8 -0
  110. package/dist/task-create/index.cjs +9 -0
  111. package/dist/task-create/index.d.cts +19 -0
  112. package/dist/task-create/index.d.ts +19 -0
  113. package/dist/task-create/index.js +9 -0
  114. package/dist/task-get/index.cjs +9 -0
  115. package/dist/task-get/index.d.cts +15 -0
  116. package/dist/task-get/index.d.ts +15 -0
  117. package/dist/task-get/index.js +9 -0
  118. package/dist/task-list/index.cjs +9 -0
  119. package/dist/task-list/index.d.cts +11 -0
  120. package/dist/task-list/index.d.ts +11 -0
  121. package/dist/task-list/index.js +9 -0
  122. package/dist/task-update/index.cjs +9 -0
  123. package/dist/task-update/index.d.cts +31 -0
  124. package/dist/task-update/index.d.ts +31 -0
  125. package/dist/task-update/index.js +9 -0
  126. package/dist/tool-search/index.cjs +8 -0
  127. package/dist/tool-search/index.d.cts +18 -0
  128. package/dist/tool-search/index.d.ts +18 -0
  129. package/dist/tool-search/index.js +8 -0
  130. package/dist/types-3QPDuCXN.d.cts +45 -0
  131. package/dist/types-3QPDuCXN.d.ts +45 -0
  132. package/dist/web-fetch/index.cjs +8 -0
  133. package/dist/web-fetch/index.d.cts +54 -0
  134. package/dist/web-fetch/index.d.ts +54 -0
  135. package/dist/web-fetch/index.js +8 -0
  136. package/dist/web-search/index.cjs +8 -0
  137. package/dist/web-search/index.d.cts +21 -0
  138. package/dist/web-search/index.d.ts +21 -0
  139. package/dist/web-search/index.js +8 -0
  140. package/dist/write/index.cjs +10 -0
  141. package/dist/write/index.d.cts +47 -0
  142. package/dist/write/index.d.ts +47 -0
  143. package/dist/write/index.js +10 -0
  144. package/package.json +170 -20
  145. package/dist/core/index.d.ts +0 -20
  146. package/dist/core/index.js +0 -1
  147. package/dist/core/index.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunk3EPGFWZVcjs = require('../chunk-3EPGFWZV.cjs');
5
+
6
+
7
+
8
+ exports.askUser = _chunk3EPGFWZVcjs.askUser; exports.createAskUser = _chunk3EPGFWZVcjs.createAskUser;
@@ -0,0 +1,68 @@
1
+ import * as ai from 'ai';
2
+ import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
3
+
4
+ /**
5
+ * Configuration for the ask-user tool.
6
+ * Extends {@link BaseToolConfig} with an optional callback for receiving user input.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import type { AskUserConfig } from 'agentool/ask-user';
11
+ * const config: AskUserConfig = {
12
+ * onQuestion: async (question) => prompt(question) ?? '',
13
+ * };
14
+ * ```
15
+ */
16
+ interface AskUserConfig extends BaseToolConfig {
17
+ /**
18
+ * Callback invoked when the tool needs user input.
19
+ * Must be provided for the tool to work.
20
+ *
21
+ * @param question - The question to present to the user
22
+ * @param options - Optional list of suggested response options
23
+ * @returns The user's response string
24
+ */
25
+ onQuestion?: (question: string, options?: string[]) => Promise<string>;
26
+ }
27
+ /**
28
+ * Creates an ask-user tool instance with the given configuration.
29
+ * The tool pauses agent execution and prompts the user for input via the
30
+ * configured {@link AskUserConfig.onQuestion} callback.
31
+ *
32
+ * Execute never throws. Errors are returned as descriptive strings.
33
+ *
34
+ * @param config - Tool configuration with optional onQuestion callback
35
+ * @returns An AI SDK tool that asks the user a question and returns their response
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { createAskUser } from 'agentool/ask-user';
40
+ * const askUser = createAskUser({
41
+ * onQuestion: async (q, opts) => {
42
+ * console.log(q, opts);
43
+ * return 'user reply';
44
+ * },
45
+ * });
46
+ * ```
47
+ */
48
+ declare function createAskUser(config?: AskUserConfig): ai.Tool<{
49
+ question: string;
50
+ options?: string[] | undefined;
51
+ }, string>;
52
+ /**
53
+ * Default ask-user tool instance with no callback configured.
54
+ * Calling execute on this instance returns an error string prompting the
55
+ * consumer to provide an {@link AskUserConfig.onQuestion} callback.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { askUser } from 'agentool/ask-user';
60
+ * // Typically you'd use createAskUser() with a callback instead.
61
+ * ```
62
+ */
63
+ declare const askUser: ai.Tool<{
64
+ question: string;
65
+ options?: string[] | undefined;
66
+ }, string>;
67
+
68
+ export { type AskUserConfig, askUser, createAskUser };
@@ -0,0 +1,68 @@
1
+ import * as ai from 'ai';
2
+ import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
3
+
4
+ /**
5
+ * Configuration for the ask-user tool.
6
+ * Extends {@link BaseToolConfig} with an optional callback for receiving user input.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import type { AskUserConfig } from 'agentool/ask-user';
11
+ * const config: AskUserConfig = {
12
+ * onQuestion: async (question) => prompt(question) ?? '',
13
+ * };
14
+ * ```
15
+ */
16
+ interface AskUserConfig extends BaseToolConfig {
17
+ /**
18
+ * Callback invoked when the tool needs user input.
19
+ * Must be provided for the tool to work.
20
+ *
21
+ * @param question - The question to present to the user
22
+ * @param options - Optional list of suggested response options
23
+ * @returns The user's response string
24
+ */
25
+ onQuestion?: (question: string, options?: string[]) => Promise<string>;
26
+ }
27
+ /**
28
+ * Creates an ask-user tool instance with the given configuration.
29
+ * The tool pauses agent execution and prompts the user for input via the
30
+ * configured {@link AskUserConfig.onQuestion} callback.
31
+ *
32
+ * Execute never throws. Errors are returned as descriptive strings.
33
+ *
34
+ * @param config - Tool configuration with optional onQuestion callback
35
+ * @returns An AI SDK tool that asks the user a question and returns their response
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { createAskUser } from 'agentool/ask-user';
40
+ * const askUser = createAskUser({
41
+ * onQuestion: async (q, opts) => {
42
+ * console.log(q, opts);
43
+ * return 'user reply';
44
+ * },
45
+ * });
46
+ * ```
47
+ */
48
+ declare function createAskUser(config?: AskUserConfig): ai.Tool<{
49
+ question: string;
50
+ options?: string[] | undefined;
51
+ }, string>;
52
+ /**
53
+ * Default ask-user tool instance with no callback configured.
54
+ * Calling execute on this instance returns an error string prompting the
55
+ * consumer to provide an {@link AskUserConfig.onQuestion} callback.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { askUser } from 'agentool/ask-user';
60
+ * // Typically you'd use createAskUser() with a callback instead.
61
+ * ```
62
+ */
63
+ declare const askUser: ai.Tool<{
64
+ question: string;
65
+ options?: string[] | undefined;
66
+ }, string>;
67
+
68
+ export { type AskUserConfig, askUser, createAskUser };
@@ -0,0 +1,8 @@
1
+ import {
2
+ askUser,
3
+ createAskUser
4
+ } from "../chunk-HDKXSKMO.js";
5
+ export {
6
+ askUser,
7
+ createAskUser
8
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkSUSAPI5Wcjs = require('../chunk-SUSAPI5W.cjs');
5
+
6
+
7
+
8
+ exports.bash = _chunkSUSAPI5Wcjs.bash; exports.createBash = _chunkSUSAPI5Wcjs.createBash;
@@ -0,0 +1,63 @@
1
+ import * as ai from 'ai';
2
+ import { T as TimeoutConfig } from '../types-3QPDuCXN.cjs';
3
+
4
+ /**
5
+ * Configuration for the bash tool.
6
+ * Extends {@link TimeoutConfig} with an optional shell binary path.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import type { BashConfig } from 'agentool/bash';
11
+ * const config: BashConfig = { cwd: '/my/project', timeout: 30000, shell: '/bin/zsh' };
12
+ * ```
13
+ */
14
+ interface BashConfig extends TimeoutConfig {
15
+ /** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
16
+ shell?: string;
17
+ }
18
+ /**
19
+ * Creates a bash tool that executes shell commands via {@link executeShell}.
20
+ *
21
+ * The tool spawns the configured shell with `-c` and the given command string.
22
+ * Timeout escalation follows SIGTERM then SIGKILL after a 5-second grace period.
23
+ * Execute never throws; errors are returned as descriptive strings.
24
+ *
25
+ * @param config - Optional configuration for cwd, timeout, and shell binary.
26
+ * @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { createBash } from 'agentool/bash';
31
+ *
32
+ * const bashTool = createBash({ cwd: '/my/project', timeout: 60000 });
33
+ * const result = await bashTool.execute(
34
+ * { command: 'ls -la' },
35
+ * { toolCallId: 'id', messages: [] },
36
+ * );
37
+ * ```
38
+ */
39
+ declare function createBash(config?: BashConfig): ai.Tool<{
40
+ command: string;
41
+ timeout?: number | undefined;
42
+ description?: string | undefined;
43
+ }, string>;
44
+ /**
45
+ * Default bash tool instance using the current working directory,
46
+ * a 120-second timeout, and the system default shell.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { bash } from 'agentool/bash';
51
+ * const result = await bash.execute(
52
+ * { command: 'echo hello' },
53
+ * { toolCallId: 'id', messages: [] },
54
+ * );
55
+ * ```
56
+ */
57
+ declare const bash: ai.Tool<{
58
+ command: string;
59
+ timeout?: number | undefined;
60
+ description?: string | undefined;
61
+ }, string>;
62
+
63
+ export { type BashConfig, bash, createBash };
@@ -0,0 +1,63 @@
1
+ import * as ai from 'ai';
2
+ import { T as TimeoutConfig } from '../types-3QPDuCXN.js';
3
+
4
+ /**
5
+ * Configuration for the bash tool.
6
+ * Extends {@link TimeoutConfig} with an optional shell binary path.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import type { BashConfig } from 'agentool/bash';
11
+ * const config: BashConfig = { cwd: '/my/project', timeout: 30000, shell: '/bin/zsh' };
12
+ * ```
13
+ */
14
+ interface BashConfig extends TimeoutConfig {
15
+ /** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
16
+ shell?: string;
17
+ }
18
+ /**
19
+ * Creates a bash tool that executes shell commands via {@link executeShell}.
20
+ *
21
+ * The tool spawns the configured shell with `-c` and the given command string.
22
+ * Timeout escalation follows SIGTERM then SIGKILL after a 5-second grace period.
23
+ * Execute never throws; errors are returned as descriptive strings.
24
+ *
25
+ * @param config - Optional configuration for cwd, timeout, and shell binary.
26
+ * @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { createBash } from 'agentool/bash';
31
+ *
32
+ * const bashTool = createBash({ cwd: '/my/project', timeout: 60000 });
33
+ * const result = await bashTool.execute(
34
+ * { command: 'ls -la' },
35
+ * { toolCallId: 'id', messages: [] },
36
+ * );
37
+ * ```
38
+ */
39
+ declare function createBash(config?: BashConfig): ai.Tool<{
40
+ command: string;
41
+ timeout?: number | undefined;
42
+ description?: string | undefined;
43
+ }, string>;
44
+ /**
45
+ * Default bash tool instance using the current working directory,
46
+ * a 120-second timeout, and the system default shell.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { bash } from 'agentool/bash';
51
+ * const result = await bash.execute(
52
+ * { command: 'echo hello' },
53
+ * { toolCallId: 'id', messages: [] },
54
+ * );
55
+ * ```
56
+ */
57
+ declare const bash: ai.Tool<{
58
+ command: string;
59
+ timeout?: number | undefined;
60
+ description?: string | undefined;
61
+ }, string>;
62
+
63
+ export { type BashConfig, bash, createBash };
@@ -0,0 +1,8 @@
1
+ import {
2
+ bash,
3
+ createBash
4
+ } from "../chunk-4YI2H55A.js";
5
+ export {
6
+ bash,
7
+ createBash
8
+ };
@@ -0,0 +1,30 @@
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;
@@ -0,0 +1,79 @@
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
+ var _chunk5NW4OGRIcjs = require('./chunk-5NW4OGRI.cjs');
6
+
7
+
8
+ var _chunkCAEVLIQBcjs = require('./chunk-CAEVLIQB.cjs');
9
+
10
+
11
+ var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
12
+
13
+ // src/multi-edit/index.ts
14
+ var _promises = require('fs/promises');
15
+ var _ai = require('ai');
16
+ var _zod = require('zod');
17
+ function countOccurrences(text, search) {
18
+ if (search.length === 0) return 0;
19
+ let count = 0;
20
+ let pos = 0;
21
+ while ((pos = text.indexOf(search, pos)) !== -1) {
22
+ count++;
23
+ pos += search.length;
24
+ }
25
+ return count;
26
+ }
27
+ function createMultiEdit(config = {}) {
28
+ const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
29
+ return _ai.tool.call(void 0, {
30
+ description: "Atomically apply multiple text edits to a single file. All edits succeed together or none are applied (rollback on failure). Each edit replaces one occurrence of old_string with new_string. Edits are applied sequentially in the order provided.",
31
+ inputSchema: _zod.z.object({
32
+ file_path: _zod.z.string().describe("Path to the file to edit (absolute or relative to cwd)"),
33
+ edits: _zod.z.array(
34
+ _zod.z.object({
35
+ old_string: _zod.z.string().describe("The exact string to find and replace"),
36
+ new_string: _zod.z.string().describe("The replacement string")
37
+ })
38
+ ).describe("Ordered list of edits to apply atomically")
39
+ }),
40
+ execute: async ({ file_path, edits }) => {
41
+ try {
42
+ if (edits.length === 0) {
43
+ return "No edits provided. File unchanged.";
44
+ }
45
+ const resolvedPath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
46
+ const originalContent = await _promises.readFile.call(void 0, resolvedPath, "utf-8");
47
+ let content = originalContent;
48
+ for (let i = 0; i < edits.length; i++) {
49
+ const edit = edits[i];
50
+ const actualOldString = _chunk5NW4OGRIcjs.findActualString.call(void 0, content, edit.old_string);
51
+ if (actualOldString === null) {
52
+ return `Error [multi-edit]: Edit ${i + 1}/${edits.length} failed \u2014 old_string not found in file. No edits were applied. File: ${resolvedPath}`;
53
+ }
54
+ const occurrences = countOccurrences(content, actualOldString);
55
+ if (occurrences > 1) {
56
+ return `Error [multi-edit]: Edit ${i + 1}/${edits.length} failed \u2014 old_string matches ${occurrences} locations (must be unique). No edits were applied. File: ${resolvedPath}`;
57
+ }
58
+ const styledNewString = _chunk5NW4OGRIcjs.preserveQuoteStyle.call(void 0,
59
+ edit.old_string,
60
+ actualOldString,
61
+ edit.new_string
62
+ );
63
+ content = _chunk5NW4OGRIcjs.applyEditToFile.call(void 0, content, actualOldString, styledNewString);
64
+ }
65
+ await _chunkCAEVLIQBcjs.writeTextContent.call(void 0, resolvedPath, content);
66
+ return `Successfully applied ${edits.length} edit${edits.length === 1 ? "" : "s"} to ${resolvedPath}`;
67
+ } catch (error) {
68
+ const msg = error instanceof Error ? error.message : String(error);
69
+ return `Error [multi-edit]: ${msg}`;
70
+ }
71
+ }
72
+ });
73
+ }
74
+ var multiEdit = createMultiEdit();
75
+
76
+
77
+
78
+
79
+ exports.createMultiEdit = createMultiEdit; exports.multiEdit = multiEdit;
@@ -0,0 +1,30 @@
1
+ // src/web-search/index.ts
2
+ import { tool } from "ai";
3
+ import { z } from "zod";
4
+ function createWebSearch(config = {}) {
5
+ return tool({
6
+ description: "Search the web for information using a search query. Results can be filtered by allowed or blocked domains.",
7
+ inputSchema: z.object({
8
+ query: z.string().min(2).describe("The search query to use"),
9
+ allowed_domains: z.array(z.string()).optional().describe("Only include search results from these domains"),
10
+ blocked_domains: z.array(z.string()).optional().describe("Never include search results from these domains")
11
+ }),
12
+ execute: async ({ query, allowed_domains, blocked_domains }) => {
13
+ try {
14
+ if (!config.onSearch) {
15
+ return "Error [web-search]: No search callback configured. Provide onSearch via createWebSearch({ onSearch: async (query, opts) => ... })";
16
+ }
17
+ return await config.onSearch(query, { allowed_domains, blocked_domains });
18
+ } catch (error) {
19
+ const msg = error instanceof Error ? error.message : String(error);
20
+ return `Error [web-search]: ${msg}`;
21
+ }
22
+ }
23
+ });
24
+ }
25
+ var webSearch = createWebSearch();
26
+
27
+ export {
28
+ createWebSearch,
29
+ webSearch
30
+ };
@@ -0,0 +1,112 @@
1
+ // src/web-fetch/index.ts
2
+ import { tool } from "ai";
3
+ import { z } from "zod";
4
+
5
+ // src/shared/fetch.ts
6
+ var MAX_MARKDOWN_LENGTH = 1e5;
7
+ var DEFAULT_TIMEOUT_MS = 3e4;
8
+ var DEFAULT_MAX_CONTENT_LENGTH = 10 * 1024 * 1024;
9
+ var turndownPromise;
10
+ function getTurndownService() {
11
+ return turndownPromise ??= import("turndown").then((m) => {
12
+ const Turndown = m.default;
13
+ return new Turndown();
14
+ });
15
+ }
16
+ function composeSignal(timeoutMs, userSignal) {
17
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
18
+ if (!userSignal) {
19
+ return timeoutSignal;
20
+ }
21
+ return AbortSignal.any([timeoutSignal, userSignal]);
22
+ }
23
+ async function fetchUrl(url, options) {
24
+ const timeoutMs = options?.timeout ?? DEFAULT_TIMEOUT_MS;
25
+ const maxBytes = options?.maxContentLength ?? DEFAULT_MAX_CONTENT_LENGTH;
26
+ const signal = composeSignal(timeoutMs, options?.signal);
27
+ const headers = {
28
+ Accept: "text/markdown, text/html, */*"
29
+ };
30
+ if (options?.userAgent) {
31
+ headers["User-Agent"] = options.userAgent;
32
+ }
33
+ const response = await fetch(url, { signal, headers });
34
+ const chunks = [];
35
+ let totalBytes = 0;
36
+ if (response.body) {
37
+ const reader = response.body.getReader();
38
+ for (; ; ) {
39
+ const { done, value } = await reader.read();
40
+ if (done) break;
41
+ totalBytes += value.byteLength;
42
+ if (totalBytes > maxBytes) {
43
+ await reader.cancel();
44
+ throw new Error(
45
+ `Response body exceeds maxContentLength (${maxBytes} bytes)`
46
+ );
47
+ }
48
+ chunks.push(value);
49
+ }
50
+ }
51
+ const rawBuffer = Buffer.concat(chunks);
52
+ const byteLength = rawBuffer.length;
53
+ const contentType = response.headers.get("content-type") ?? "";
54
+ const textContent = rawBuffer.toString("utf-8");
55
+ let content;
56
+ if (contentType.includes("text/html")) {
57
+ const td = await getTurndownService();
58
+ content = td.turndown(textContent);
59
+ } else {
60
+ content = textContent;
61
+ }
62
+ let truncated = false;
63
+ if (content.length > MAX_MARKDOWN_LENGTH) {
64
+ content = content.slice(0, MAX_MARKDOWN_LENGTH);
65
+ truncated = true;
66
+ }
67
+ return {
68
+ content,
69
+ contentType,
70
+ statusCode: response.status,
71
+ byteLength,
72
+ truncated
73
+ };
74
+ }
75
+
76
+ // src/web-fetch/index.ts
77
+ function createWebFetch(config = {}) {
78
+ return tool({
79
+ description: "Fetch a URL and return its content. HTML pages are automatically converted to markdown for easier reading. JSON and other text content is returned as-is. Content is truncated at 100,000 characters to manage context size.",
80
+ inputSchema: z.object({
81
+ url: z.string().url().describe("The URL to fetch")
82
+ }),
83
+ execute: async ({ url }) => {
84
+ try {
85
+ const result = await fetchUrl(url, {
86
+ timeout: config.timeout ?? 3e4,
87
+ maxContentLength: config.maxContentLength,
88
+ userAgent: config.userAgent
89
+ });
90
+ const parts = [];
91
+ parts.push(`URL: ${url}`);
92
+ parts.push(`Status: ${result.statusCode}`);
93
+ parts.push(`Content-Type: ${result.contentType}`);
94
+ if (result.truncated) {
95
+ parts.push("(Content truncated to 100,000 characters)");
96
+ }
97
+ parts.push("");
98
+ parts.push(result.content);
99
+ return parts.join("\n");
100
+ } catch (error) {
101
+ const msg = error instanceof Error ? error.message : String(error);
102
+ return `Error [web-fetch]: Failed to fetch ${url}: ${msg}`;
103
+ }
104
+ }
105
+ });
106
+ }
107
+ var webFetch = createWebFetch();
108
+
109
+ export {
110
+ createWebFetch,
111
+ webFetch
112
+ };
@@ -0,0 +1,36 @@
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 _chunkL5JH4I77cjs = require('./chunk-L5JH4I77.cjs');
5
+
6
+ // src/task-get/index.ts
7
+ var _ai = require('ai');
8
+ var _zod = require('zod');
9
+ var _path = require('path');
10
+ function createTaskGet(config = {}) {
11
+ const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
12
+ const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
13
+ return _ai.tool.call(void 0, {
14
+ description: "Retrieve a task by its ID to see full details.",
15
+ inputSchema: _zod.z.object({
16
+ taskId: _zod.z.string().describe("The ID of the task to retrieve")
17
+ }),
18
+ execute: async ({ taskId }) => {
19
+ try {
20
+ const tasks = await _chunkL5JH4I77cjs.loadTasks.call(void 0, tasksFile);
21
+ const found = tasks.find((t) => t.id === taskId);
22
+ if (!found) return `Error [task-get]: Task "${taskId}" not found.`;
23
+ return _chunkL5JH4I77cjs.formatTask.call(void 0, found);
24
+ } catch (error) {
25
+ const msg = error instanceof Error ? error.message : String(error);
26
+ return `Error [task-get]: ${msg}`;
27
+ }
28
+ }
29
+ });
30
+ }
31
+ var taskGet = createTaskGet();
32
+
33
+
34
+
35
+
36
+ exports.createTaskGet = createTaskGet; exports.taskGet = taskGet;