wave-agent-sdk 0.0.7 → 0.0.10
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.
- package/dist/agent.d.ts +105 -24
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +438 -53
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/managers/aiManager.d.ts +18 -7
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +254 -142
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +11 -9
- package/dist/managers/hookManager.d.ts +6 -6
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +81 -39
- package/dist/managers/liveConfigManager.d.ts +95 -0
- package/dist/managers/liveConfigManager.d.ts.map +1 -0
- package/dist/managers/liveConfigManager.js +442 -0
- package/dist/managers/lspManager.d.ts +43 -0
- package/dist/managers/lspManager.d.ts.map +1 -0
- package/dist/managers/lspManager.js +326 -0
- package/dist/managers/messageManager.d.ts +41 -24
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +184 -73
- package/dist/managers/permissionManager.d.ts +66 -0
- package/dist/managers/permissionManager.d.ts.map +1 -0
- package/dist/managers/permissionManager.js +208 -0
- package/dist/managers/skillManager.d.ts +1 -0
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +2 -1
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +4 -2
- package/dist/managers/subagentManager.d.ts +42 -6
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +213 -62
- package/dist/managers/toolManager.d.ts +38 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +66 -2
- package/dist/services/aiService.d.ts +15 -5
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +446 -77
- package/dist/services/configurationService.d.ts +116 -0
- package/dist/services/configurationService.d.ts.map +1 -0
- package/dist/services/configurationService.js +585 -0
- package/dist/services/fileWatcher.d.ts +69 -0
- package/dist/services/fileWatcher.d.ts.map +1 -0
- package/dist/services/fileWatcher.js +212 -0
- package/dist/services/hook.d.ts +5 -40
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +47 -109
- package/dist/services/jsonlHandler.d.ts +71 -0
- package/dist/services/jsonlHandler.d.ts.map +1 -0
- package/dist/services/jsonlHandler.js +236 -0
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +33 -11
- package/dist/services/session.d.ts +116 -52
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +415 -143
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +77 -17
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +27 -1
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +33 -8
- package/dist/tools/lspTool.d.ts +6 -0
- package/dist/tools/lspTool.d.ts.map +1 -0
- package/dist/tools/lspTool.js +589 -0
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +30 -10
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +113 -3
- package/dist/tools/skillTool.js +2 -2
- package/dist/tools/todoWriteTool.d.ts.map +1 -1
- package/dist/tools/todoWriteTool.js +23 -0
- package/dist/tools/types.d.ts +11 -8
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +30 -15
- package/dist/types/commands.d.ts +4 -1
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/config.d.ts +4 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +69 -0
- package/dist/types/configuration.d.ts.map +1 -0
- package/dist/types/configuration.js +8 -0
- package/dist/types/core.d.ts +45 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/environment.d.ts +83 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/environment.js +21 -0
- package/dist/types/fileSearch.d.ts +5 -0
- package/dist/types/fileSearch.d.ts.map +1 -0
- package/dist/types/fileSearch.js +1 -0
- package/dist/types/hooks.d.ts +18 -3
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +8 -8
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +7 -0
- package/dist/types/lsp.d.ts +90 -0
- package/dist/types/lsp.d.ts.map +1 -0
- package/dist/types/lsp.js +4 -0
- package/dist/types/messaging.d.ts +19 -12
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +35 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +12 -0
- package/dist/types/session.d.ts +15 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +7 -0
- package/dist/types/skills.d.ts +1 -0
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/types/tools.d.ts +35 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +4 -0
- package/dist/utils/abortUtils.d.ts +34 -0
- package/dist/utils/abortUtils.d.ts.map +1 -0
- package/dist/utils/abortUtils.js +92 -0
- package/dist/utils/bashHistory.d.ts +4 -0
- package/dist/utils/bashHistory.d.ts.map +1 -1
- package/dist/utils/bashHistory.js +48 -30
- package/dist/utils/builtinSubagents.d.ts +7 -0
- package/dist/utils/builtinSubagents.d.ts.map +1 -0
- package/dist/utils/builtinSubagents.js +65 -0
- package/dist/utils/cacheControlUtils.d.ts +96 -0
- package/dist/utils/cacheControlUtils.d.ts.map +1 -0
- package/dist/utils/cacheControlUtils.js +324 -0
- package/dist/utils/commandPathResolver.d.ts +52 -0
- package/dist/utils/commandPathResolver.d.ts.map +1 -0
- package/dist/utils/commandPathResolver.js +145 -0
- package/dist/utils/configPaths.d.ts +85 -0
- package/dist/utils/configPaths.d.ts.map +1 -0
- package/dist/utils/configPaths.js +121 -0
- package/dist/utils/constants.d.ts +1 -13
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -14
- package/dist/utils/convertMessagesForAPI.d.ts +2 -1
- package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
- package/dist/utils/convertMessagesForAPI.js +39 -18
- package/dist/utils/customCommands.d.ts.map +1 -1
- package/dist/utils/customCommands.js +66 -21
- package/dist/utils/fileSearch.d.ts +14 -0
- package/dist/utils/fileSearch.d.ts.map +1 -0
- package/dist/utils/fileSearch.js +88 -0
- package/dist/utils/fileUtils.d.ts +27 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +145 -0
- package/dist/utils/globalLogger.d.ts +88 -0
- package/dist/utils/globalLogger.d.ts.map +1 -0
- package/dist/utils/globalLogger.js +120 -0
- package/dist/utils/largeOutputHandler.d.ts +15 -0
- package/dist/utils/largeOutputHandler.d.ts.map +1 -0
- package/dist/utils/largeOutputHandler.js +40 -0
- package/dist/utils/markdownParser.d.ts.map +1 -1
- package/dist/utils/markdownParser.js +1 -17
- package/dist/utils/mcpUtils.d.ts.map +1 -1
- package/dist/utils/mcpUtils.js +25 -3
- package/dist/utils/messageOperations.d.ts +20 -18
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +30 -38
- package/dist/utils/pathEncoder.d.ts +108 -0
- package/dist/utils/pathEncoder.d.ts.map +1 -0
- package/dist/utils/pathEncoder.js +279 -0
- package/dist/utils/subagentParser.d.ts +2 -2
- package/dist/utils/subagentParser.d.ts.map +1 -1
- package/dist/utils/subagentParser.js +12 -8
- package/dist/utils/tokenCalculation.d.ts +26 -0
- package/dist/utils/tokenCalculation.d.ts.map +1 -0
- package/dist/utils/tokenCalculation.js +36 -0
- package/dist/utils/tokenEstimator.d.ts +39 -0
- package/dist/utils/tokenEstimator.d.ts.map +1 -0
- package/dist/utils/tokenEstimator.js +55 -0
- package/package.json +6 -6
- package/src/agent.ts +586 -78
- package/src/index.ts +4 -0
- package/src/managers/aiManager.ts +341 -192
- package/src/managers/backgroundBashManager.ts +11 -9
- package/src/managers/hookManager.ts +102 -54
- package/src/managers/liveConfigManager.ts +634 -0
- package/src/managers/lspManager.ts +434 -0
- package/src/managers/messageManager.ts +258 -121
- package/src/managers/permissionManager.ts +276 -0
- package/src/managers/skillManager.ts +3 -1
- package/src/managers/slashCommandManager.ts +5 -3
- package/src/managers/subagentManager.ts +295 -76
- package/src/managers/toolManager.ts +95 -3
- package/src/services/aiService.ts +656 -84
- package/src/services/configurationService.ts +762 -0
- package/src/services/fileWatcher.ts +300 -0
- package/src/services/hook.ts +54 -144
- package/src/services/jsonlHandler.ts +303 -0
- package/src/services/memory.ts +34 -11
- package/src/services/session.ts +522 -173
- package/src/tools/bashTool.ts +94 -20
- package/src/tools/deleteFileTool.ts +38 -1
- package/src/tools/editTool.ts +44 -9
- package/src/tools/lspTool.ts +760 -0
- package/src/tools/multiEditTool.ts +41 -11
- package/src/tools/readTool.ts +127 -3
- package/src/tools/skillTool.ts +2 -2
- package/src/tools/todoWriteTool.ts +33 -1
- package/src/tools/types.ts +15 -9
- package/src/tools/writeTool.ts +43 -16
- package/src/types/commands.ts +6 -1
- package/src/types/config.ts +5 -0
- package/src/types/configuration.ts +73 -0
- package/src/types/core.ts +55 -0
- package/src/types/environment.ts +104 -0
- package/src/types/fileSearch.ts +4 -0
- package/src/types/hooks.ts +32 -16
- package/src/types/index.ts +7 -0
- package/src/types/lsp.ts +96 -0
- package/src/types/messaging.ts +21 -14
- package/src/types/permissions.ts +48 -0
- package/src/types/session.ts +20 -0
- package/src/types/skills.ts +1 -0
- package/src/types/tools.ts +38 -0
- package/src/utils/abortUtils.ts +118 -0
- package/src/utils/bashHistory.ts +55 -31
- package/src/utils/builtinSubagents.ts +71 -0
- package/src/utils/cacheControlUtils.ts +475 -0
- package/src/utils/commandPathResolver.ts +189 -0
- package/src/utils/configPaths.ts +163 -0
- package/src/utils/constants.ts +2 -17
- package/src/utils/convertMessagesForAPI.ts +44 -18
- package/src/utils/customCommands.ts +90 -22
- package/src/utils/fileSearch.ts +107 -0
- package/src/utils/fileUtils.ts +160 -0
- package/src/utils/globalLogger.ts +128 -0
- package/src/utils/largeOutputHandler.ts +55 -0
- package/src/utils/markdownParser.ts +1 -19
- package/src/utils/mcpUtils.ts +34 -3
- package/src/utils/messageOperations.ts +47 -53
- package/src/utils/pathEncoder.ts +394 -0
- package/src/utils/subagentParser.ts +13 -9
- package/src/utils/tokenCalculation.ts +43 -0
- package/src/utils/tokenEstimator.ts +68 -0
- package/dist/utils/configResolver.d.ts +0 -38
- package/dist/utils/configResolver.d.ts.map +0 -1
- package/dist/utils/configResolver.js +0 -106
- package/src/utils/configResolver.ts +0 -142
package/dist/tools/readTool.js
CHANGED
|
@@ -1,6 +1,112 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
1
|
+
import { readFile, stat } from "fs/promises";
|
|
2
|
+
import { extname } from "path";
|
|
3
|
+
import { logger } from "../utils/globalLogger.js";
|
|
2
4
|
import { resolvePath, getDisplayPath } from "../utils/path.js";
|
|
3
5
|
import { isBinaryDocument, getBinaryDocumentError, } from "../utils/fileFormat.js";
|
|
6
|
+
import { convertImageToBase64 } from "../utils/messageOperations.js";
|
|
7
|
+
/**
|
|
8
|
+
* Supported image file extensions
|
|
9
|
+
*/
|
|
10
|
+
const SUPPORTED_IMAGE_EXTENSIONS = [
|
|
11
|
+
"png",
|
|
12
|
+
"jpeg",
|
|
13
|
+
"jpg",
|
|
14
|
+
"gif",
|
|
15
|
+
"webp",
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Check if a file path represents an image file
|
|
19
|
+
* @param filePath - Path to the file
|
|
20
|
+
* @returns true if the file is a supported image format
|
|
21
|
+
*/
|
|
22
|
+
function isImageFile(filePath) {
|
|
23
|
+
const ext = extname(filePath).toLowerCase().substring(1);
|
|
24
|
+
return SUPPORTED_IMAGE_EXTENSIONS.includes(ext);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate image file size
|
|
28
|
+
* @param filePath - Path to the image file
|
|
29
|
+
* @param maxSizeBytes - Maximum allowed file size in bytes (default: 20MB)
|
|
30
|
+
* @returns Promise<boolean> - true if file size is within limit
|
|
31
|
+
*/
|
|
32
|
+
async function validateImageFileSize(filePath, maxSizeBytes = 20 * 1024 * 1024) {
|
|
33
|
+
try {
|
|
34
|
+
const stats = await stat(filePath);
|
|
35
|
+
return stats.size <= maxSizeBytes;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get MIME type for image file based on extension
|
|
43
|
+
* @param filePath - Path to the image file
|
|
44
|
+
* @returns MIME type string
|
|
45
|
+
*/
|
|
46
|
+
function getImageMimeType(filePath) {
|
|
47
|
+
const ext = extname(filePath).toLowerCase().substring(1);
|
|
48
|
+
switch (ext) {
|
|
49
|
+
case "png":
|
|
50
|
+
return "image/png";
|
|
51
|
+
case "jpg":
|
|
52
|
+
case "jpeg":
|
|
53
|
+
return "image/jpeg";
|
|
54
|
+
case "gif":
|
|
55
|
+
return "image/gif";
|
|
56
|
+
case "webp":
|
|
57
|
+
return "image/webp";
|
|
58
|
+
default:
|
|
59
|
+
return "image/png"; // Default fallback
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Process an image file and return ToolResult with image data
|
|
64
|
+
* @param filePath - Path to the image file
|
|
65
|
+
* @param context - Tool execution context
|
|
66
|
+
* @returns Promise<ToolResult> with image data
|
|
67
|
+
*/
|
|
68
|
+
async function processImageFile(filePath, context) {
|
|
69
|
+
try {
|
|
70
|
+
// Resolve path
|
|
71
|
+
const actualFilePath = filePath.startsWith("/")
|
|
72
|
+
? filePath
|
|
73
|
+
: resolvePath(filePath, context.workdir);
|
|
74
|
+
// Validate file size
|
|
75
|
+
const isValidSize = await validateImageFileSize(actualFilePath);
|
|
76
|
+
if (!isValidSize) {
|
|
77
|
+
const stats = await stat(actualFilePath);
|
|
78
|
+
const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
content: "",
|
|
82
|
+
error: `Image file exceeds 20MB limit (actual: ${sizeMB}MB)`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Convert image to base64
|
|
86
|
+
const imageDataUrl = convertImageToBase64(actualFilePath);
|
|
87
|
+
const mimeType = getImageMimeType(actualFilePath);
|
|
88
|
+
// Extract base64 data from data URL (remove data:image/type;base64, prefix)
|
|
89
|
+
const base64Data = imageDataUrl.split(",")[1] || "";
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
content: `Image file processed: ${getDisplayPath(filePath, context.workdir)}\nFormat: ${mimeType}\nSize: Available for AI processing`,
|
|
93
|
+
shortResult: `Image processed (${mimeType})`,
|
|
94
|
+
images: [
|
|
95
|
+
{
|
|
96
|
+
data: base64Data,
|
|
97
|
+
mediaType: mimeType,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
content: "",
|
|
106
|
+
error: `Failed to process image: ${error instanceof Error ? error.message : String(error)}`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
4
110
|
/**
|
|
5
111
|
* Read Tool Plugin - Read file content
|
|
6
112
|
*/
|
|
@@ -10,7 +116,7 @@ export const readTool = {
|
|
|
10
116
|
type: "function",
|
|
11
117
|
function: {
|
|
12
118
|
name: "Read",
|
|
13
|
-
description: "Reads a file from the local filesystem. You can access any file directly by using this tool.\nAssume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\n\nUsage:\n- The file_path parameter must be an absolute path, not a relative path\n- By default, it reads up to 2000 lines starting from the beginning of the file\n- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\n- Any lines longer than 2000 characters will be truncated\n- Results are returned using cat -n format, with line numbers starting at 1\n- This tool allows
|
|
119
|
+
description: "Reads a file from the local filesystem. You can access any file directly by using this tool.\nAssume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\n\nUsage:\n- The file_path parameter must be an absolute path, not a relative path\n- By default, it reads up to 2000 lines starting from the beginning of the file\n- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\n- Any lines longer than 2000 characters will be truncated\n- Results are returned using cat -n format, with line numbers starting at 1\n- This tool allows Agent to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Agent is a multimodal LLM.\n- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.\n- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.\n- You will regularly be asked to read screenshots. If the user provides a path to a screenshot ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths like /var/folders/123/abc/T/TemporaryItems/NSIRD_screencaptureui_ZfB1tD/Screenshot.png\n- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.\n- Binary document formats (PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX) are not supported and will return an error.",
|
|
14
120
|
parameters: {
|
|
15
121
|
type: "object",
|
|
16
122
|
properties: {
|
|
@@ -50,6 +156,10 @@ export const readTool = {
|
|
|
50
156
|
error: getBinaryDocumentError(filePath),
|
|
51
157
|
};
|
|
52
158
|
}
|
|
159
|
+
// Check if this is an image file
|
|
160
|
+
if (isImageFile(filePath)) {
|
|
161
|
+
return processImageFile(filePath, context);
|
|
162
|
+
}
|
|
53
163
|
try {
|
|
54
164
|
// Note: New Read tool requires absolute paths, so we don't use resolvePath
|
|
55
165
|
// But for compatibility, if it's not an absolute path, we still try to resolve
|
|
@@ -59,7 +169,7 @@ export const readTool = {
|
|
|
59
169
|
const fileContent = await readFile(actualFilePath, "utf-8");
|
|
60
170
|
// Check if file is empty
|
|
61
171
|
if (fileContent.length === 0) {
|
|
62
|
-
|
|
172
|
+
logger.warn(`File ${filePath} exists but has empty contents`);
|
|
63
173
|
return {
|
|
64
174
|
success: true,
|
|
65
175
|
content: "⚠️ System reminder: This file exists but has empty contents.",
|
package/dist/tools/skillTool.js
CHANGED
|
@@ -14,11 +14,11 @@ export function createSkillTool(skillManager) {
|
|
|
14
14
|
return `Invoke a Wave skill by name. Skills are user-defined automation templates that can be personal or project-specific.\n\nAvailable skills:\n${skillList}`;
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
|
-
name: "
|
|
17
|
+
name: "Skill",
|
|
18
18
|
config: {
|
|
19
19
|
type: "function",
|
|
20
20
|
function: {
|
|
21
|
-
name: "
|
|
21
|
+
name: "Skill",
|
|
22
22
|
description: getToolDescription(),
|
|
23
23
|
parameters: {
|
|
24
24
|
type: "object",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todoWriteTool.d.ts","sourceRoot":"","sources":["../../src/tools/todoWriteTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"todoWriteTool.d.ts","sourceRoot":"","sources":["../../src/tools/todoWriteTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAQtE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,UAoP3B,CAAC"}
|
|
@@ -92,6 +92,29 @@ When in doubt, use this tool. Being proactive with task management demonstrates
|
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
|
+
formatCompactParams: (params, context) => {
|
|
96
|
+
void context; // Context not needed for this tool
|
|
97
|
+
try {
|
|
98
|
+
const { todos } = params;
|
|
99
|
+
// Handle invalid or missing tasks array
|
|
100
|
+
if (!todos || !Array.isArray(todos)) {
|
|
101
|
+
return "invalid todos";
|
|
102
|
+
}
|
|
103
|
+
// Handle empty task list
|
|
104
|
+
if (todos.length === 0) {
|
|
105
|
+
return "0 tasks";
|
|
106
|
+
}
|
|
107
|
+
// Count completed tasks
|
|
108
|
+
const completedCount = todos.filter((todo) => todo && todo.status === "completed").length;
|
|
109
|
+
const totalCount = todos.length;
|
|
110
|
+
// Format with proper singular/plural
|
|
111
|
+
const taskWord = totalCount === 1 ? "task" : "tasks";
|
|
112
|
+
return `${completedCount}/${totalCount} ${taskWord}`;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return "invalid todos";
|
|
116
|
+
}
|
|
117
|
+
},
|
|
95
118
|
execute: async (args) => {
|
|
96
119
|
try {
|
|
97
120
|
// Validate arguments
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Tool plugin interface definitions
|
|
3
3
|
*/
|
|
4
4
|
import { ChatCompletionFunctionTool } from "openai/resources.js";
|
|
5
|
+
import type { PermissionMode, PermissionCallback } from "../types/permissions.js";
|
|
5
6
|
export interface ToolPlugin {
|
|
6
7
|
name: string;
|
|
7
8
|
config: ChatCompletionFunctionTool;
|
|
@@ -13,14 +14,6 @@ export interface ToolResult {
|
|
|
13
14
|
content: string;
|
|
14
15
|
error?: string;
|
|
15
16
|
shortResult?: string;
|
|
16
|
-
originalContent?: string;
|
|
17
|
-
newContent?: string;
|
|
18
|
-
diffResult?: Array<{
|
|
19
|
-
count?: number;
|
|
20
|
-
value: string;
|
|
21
|
-
added?: boolean;
|
|
22
|
-
removed?: boolean;
|
|
23
|
-
}>;
|
|
24
17
|
filePath?: string;
|
|
25
18
|
images?: Array<{
|
|
26
19
|
data: string;
|
|
@@ -31,5 +24,15 @@ export interface ToolContext {
|
|
|
31
24
|
abortSignal?: AbortSignal;
|
|
32
25
|
backgroundBashManager?: import("../managers/backgroundBashManager.js").BackgroundBashManager;
|
|
33
26
|
workdir: string;
|
|
27
|
+
/** Permission mode for this tool execution */
|
|
28
|
+
permissionMode?: PermissionMode;
|
|
29
|
+
/** Custom permission callback */
|
|
30
|
+
canUseToolCallback?: PermissionCallback;
|
|
31
|
+
/** Permission manager instance for permission checks */
|
|
32
|
+
permissionManager?: import("../managers/permissionManager.js").PermissionManager;
|
|
33
|
+
/** MCP manager instance for calling MCP tools */
|
|
34
|
+
mcpManager?: import("../managers/mcpManager.js").McpManager;
|
|
35
|
+
/** LSP manager instance for code intelligence */
|
|
36
|
+
lspManager?: import("../types/lsp.js").ILspManager;
|
|
34
37
|
}
|
|
35
38
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC;IACzB,mBAAmB,CAAC,EAAE,CACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,WAAW,KACjB,MAAM,CAAC;CACb;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,sCAAsC,EAAE,qBAAqB,CAAC;IAC7F,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,wDAAwD;IACxD,iBAAiB,CAAC,EAAE,OAAO,kCAAkC,EAAE,iBAAiB,CAAC;IACjF,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,2BAA2B,EAAE,UAAU,CAAC;IAC5D,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,iBAAiB,EAAE,WAAW,CAAC;CACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGtE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UAoLvB,CAAC"}
|
package/dist/tools/writeTool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
2
2
|
import { dirname } from "path";
|
|
3
|
+
import { logger } from "../utils/globalLogger.js";
|
|
3
4
|
import { resolvePath, getDisplayPath } from "../utils/path.js";
|
|
4
|
-
import { diffLines } from "diff";
|
|
5
5
|
/**
|
|
6
6
|
* File Write Tool Plugin
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ export const writeTool = {
|
|
|
11
11
|
type: "function",
|
|
12
12
|
function: {
|
|
13
13
|
name: "Write",
|
|
14
|
-
description: "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.",
|
|
14
|
+
description: "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.\n- IMPORTANT: Always provide file_path parameter before content parameter when calling this tool.",
|
|
15
15
|
parameters: {
|
|
16
16
|
type: "object",
|
|
17
17
|
properties: {
|
|
@@ -67,9 +67,6 @@ export const writeTool = {
|
|
|
67
67
|
content: `File ${filePath} already has the same content, no changes needed`,
|
|
68
68
|
shortResult: "No changes needed",
|
|
69
69
|
filePath: resolvedPath,
|
|
70
|
-
originalContent,
|
|
71
|
-
newContent: content,
|
|
72
|
-
diffResult: [],
|
|
73
70
|
};
|
|
74
71
|
}
|
|
75
72
|
// Ensure directory exists
|
|
@@ -81,9 +78,32 @@ export const writeTool = {
|
|
|
81
78
|
// Ignore directory already exists error
|
|
82
79
|
if (mkdirError instanceof Error &&
|
|
83
80
|
!mkdirError.message.includes("EEXIST")) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
logger.warn(`Failed to create directory ${fileDir}: ${mkdirError.message}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Permission check after validation but before real operation
|
|
85
|
+
if (context.permissionManager &&
|
|
86
|
+
context.permissionMode &&
|
|
87
|
+
context.permissionMode !== "bypassPermissions") {
|
|
88
|
+
if (context.permissionManager.isRestrictedTool("Write")) {
|
|
89
|
+
try {
|
|
90
|
+
const permissionContext = context.permissionManager.createContext("Write", context.permissionMode, context.canUseToolCallback, { file_path: filePath, content });
|
|
91
|
+
const permissionResult = await context.permissionManager.checkPermission(permissionContext);
|
|
92
|
+
if (permissionResult.behavior === "deny") {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
content: "",
|
|
96
|
+
error: `Write operation denied by user, reason: ${permissionResult.message || "No reason provided"}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
content: "",
|
|
104
|
+
error: "Permission check failed",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
}
|
|
89
109
|
// Write file
|
|
@@ -97,26 +117,21 @@ export const writeTool = {
|
|
|
97
117
|
error: `Failed to write file: ${writeError instanceof Error ? writeError.message : String(writeError)}`,
|
|
98
118
|
};
|
|
99
119
|
}
|
|
100
|
-
// Generate diff information
|
|
101
|
-
const diffResult = diffLines(originalContent, content);
|
|
102
120
|
const shortResult = isExistingFile ? "File overwritten" : "File created";
|
|
103
121
|
const lines = content.split("\n").length;
|
|
104
122
|
const chars = content.length;
|
|
105
123
|
const detailedContent = `${shortResult} (${lines} lines, ${chars} characters)`;
|
|
106
|
-
|
|
124
|
+
logger.debug(`Write tool: ${shortResult}`);
|
|
107
125
|
return {
|
|
108
126
|
success: true,
|
|
109
127
|
content: detailedContent,
|
|
110
128
|
shortResult,
|
|
111
129
|
filePath: resolvedPath,
|
|
112
|
-
originalContent,
|
|
113
|
-
newContent: content,
|
|
114
|
-
diffResult,
|
|
115
130
|
};
|
|
116
131
|
}
|
|
117
132
|
catch (error) {
|
|
118
133
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
119
|
-
|
|
134
|
+
logger.error(`Write tool error: ${errorMessage}`);
|
|
120
135
|
return {
|
|
121
136
|
success: false,
|
|
122
137
|
content: "",
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export interface SlashCommand {
|
|
|
9
9
|
handler: (args?: string) => Promise<void> | void;
|
|
10
10
|
}
|
|
11
11
|
export interface CustomSlashCommandConfig {
|
|
12
|
-
allowedTools?: string[];
|
|
13
12
|
model?: string;
|
|
14
13
|
description?: string;
|
|
15
14
|
}
|
|
@@ -20,5 +19,9 @@ export interface CustomSlashCommand {
|
|
|
20
19
|
filePath: string;
|
|
21
20
|
content: string;
|
|
22
21
|
config?: CustomSlashCommandConfig;
|
|
22
|
+
namespace?: string;
|
|
23
|
+
isNested: boolean;
|
|
24
|
+
depth: number;
|
|
25
|
+
segments: string[];
|
|
23
26
|
}
|
|
24
27
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/types/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,wBAAwB;IACvC,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/types/commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAGlC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
* Agent and service configuration types
|
|
3
3
|
* Dependencies: None
|
|
4
4
|
*/
|
|
5
|
+
import OpenAI from "openai";
|
|
5
6
|
export interface GatewayConfig {
|
|
6
7
|
apiKey: string;
|
|
7
8
|
baseURL: string;
|
|
9
|
+
defaultHeaders?: Record<string, string>;
|
|
10
|
+
fetchOptions?: OpenAI["fetchOptions"];
|
|
11
|
+
fetch?: OpenAI["fetch"];
|
|
8
12
|
}
|
|
9
13
|
export interface ModelConfig {
|
|
10
14
|
agentModel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Management Types
|
|
3
|
+
*
|
|
4
|
+
* Types for centralized configuration loading and validation services.
|
|
5
|
+
* These support the refactored configuration architecture that separates
|
|
6
|
+
* configuration management from hook execution.
|
|
7
|
+
*/
|
|
8
|
+
import type { WaveConfiguration } from "./hooks.js";
|
|
9
|
+
/**
|
|
10
|
+
* Result of configuration loading operations with detailed status information
|
|
11
|
+
*/
|
|
12
|
+
export interface ConfigurationLoadResult {
|
|
13
|
+
/** The loaded configuration, or null if loading failed */
|
|
14
|
+
configuration: WaveConfiguration | null;
|
|
15
|
+
/** Whether the loading operation was successful */
|
|
16
|
+
success: boolean;
|
|
17
|
+
/** Error message if loading failed */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** Path of the successfully loaded file */
|
|
20
|
+
sourcePath?: string;
|
|
21
|
+
/** Non-critical warnings during loading */
|
|
22
|
+
warnings: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of configuration validation operations
|
|
26
|
+
*/
|
|
27
|
+
export interface ValidationResult {
|
|
28
|
+
/** Whether the configuration is valid */
|
|
29
|
+
isValid: boolean;
|
|
30
|
+
/** Critical errors that prevent configuration use */
|
|
31
|
+
errors: string[];
|
|
32
|
+
/** Non-critical warnings about the configuration */
|
|
33
|
+
warnings: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration file paths organized by category
|
|
37
|
+
*/
|
|
38
|
+
export interface ConfigurationPaths {
|
|
39
|
+
/** User-specific configuration file paths in priority order */
|
|
40
|
+
userPaths: string[];
|
|
41
|
+
/** Project-specific configuration file paths in priority order */
|
|
42
|
+
projectPaths: string[];
|
|
43
|
+
/** All configuration paths combined */
|
|
44
|
+
allPaths: string[];
|
|
45
|
+
/** Only the paths that actually exist on the filesystem */
|
|
46
|
+
existingPaths: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for configuring the ConfigurationService
|
|
50
|
+
*/
|
|
51
|
+
export interface ConfigurationServiceOptions {
|
|
52
|
+
/** Working directory for resolving project configurations */
|
|
53
|
+
workdir: string;
|
|
54
|
+
/** Optional logger for configuration operations */
|
|
55
|
+
logger?: Logger;
|
|
56
|
+
/** Whether to enable validation during loading (default: true) */
|
|
57
|
+
enableValidation?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Minimal logger interface for configuration services
|
|
61
|
+
*/
|
|
62
|
+
interface Logger {
|
|
63
|
+
error: (...args: unknown[]) => void;
|
|
64
|
+
warn: (...args: unknown[]) => void;
|
|
65
|
+
info: (...args: unknown[]) => void;
|
|
66
|
+
debug: (...args: unknown[]) => void;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/types/configuration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,0DAA0D;IAC1D,aAAa,EAAE,iBAA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@
|
|
|
2
2
|
* Core foundational types used across multiple domains
|
|
3
3
|
* Dependencies: None (foundation layer)
|
|
4
4
|
*/
|
|
5
|
+
import type { CompletionUsage } from "openai/resources";
|
|
5
6
|
/**
|
|
6
7
|
* Logger interface definition
|
|
7
8
|
* Compatible with OpenAI package Logger interface
|
|
@@ -22,6 +23,50 @@ export interface Usage {
|
|
|
22
23
|
total_tokens: number;
|
|
23
24
|
model?: string;
|
|
24
25
|
operation_type?: "agent" | "compress";
|
|
26
|
+
cache_read_input_tokens?: number;
|
|
27
|
+
cache_creation_input_tokens?: number;
|
|
28
|
+
cache_creation?: {
|
|
29
|
+
ephemeral_5m_input_tokens: number;
|
|
30
|
+
ephemeral_1h_input_tokens: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Enhanced usage metrics including Claude cache information
|
|
35
|
+
* Backward compatible with standard OpenAI CompletionUsage
|
|
36
|
+
*/
|
|
37
|
+
export interface ClaudeUsage extends CompletionUsage {
|
|
38
|
+
prompt_tokens: number;
|
|
39
|
+
completion_tokens: number;
|
|
40
|
+
total_tokens: number;
|
|
41
|
+
/**
|
|
42
|
+
* Number of tokens read from existing cache
|
|
43
|
+
* Indicates cost savings from cache hits
|
|
44
|
+
*/
|
|
45
|
+
cache_read_input_tokens?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Number of tokens used to create new cache entries
|
|
48
|
+
* Investment in future cache hits
|
|
49
|
+
*/
|
|
50
|
+
cache_creation_input_tokens?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Detailed breakdown of cache creation by duration
|
|
53
|
+
*/
|
|
54
|
+
cache_creation?: {
|
|
55
|
+
/** Tokens cached for 5 minute duration */
|
|
56
|
+
ephemeral_5m_input_tokens: number;
|
|
57
|
+
/** Tokens cached for 1 hour duration */
|
|
58
|
+
ephemeral_1h_input_tokens: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents a diff change for tool parameter-based diff display
|
|
63
|
+
* Contains the old content and new content for comparison
|
|
64
|
+
*/
|
|
65
|
+
export interface Change {
|
|
66
|
+
/** The original content (empty string for additions) */
|
|
67
|
+
oldContent: string;
|
|
68
|
+
/** The new content (empty string for deletions) */
|
|
69
|
+
newContent: string;
|
|
25
70
|
}
|
|
26
71
|
export declare class ConfigurationError extends Error {
|
|
27
72
|
readonly field: string;
|
package/dist/types/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAA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MAAM,EACb,QAAQ,CAAC,EAAE,OAAO,YAAA;CAKrC;AAGD,eAAO,MAAM,aAAa;;;;;;CAQhB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable System Types
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive TypeScript types for environment variable validation,
|
|
5
|
+
* merging, and conflict resolution in the Wave Agent SDK.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Result of environment variable validation
|
|
9
|
+
*/
|
|
10
|
+
export interface EnvironmentValidationResult {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
errors: string[];
|
|
13
|
+
warnings: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Context containing merged environment variables and conflict information
|
|
17
|
+
*/
|
|
18
|
+
export interface MergedEnvironmentContext {
|
|
19
|
+
userVars: Record<string, string>;
|
|
20
|
+
projectVars: Record<string, string>;
|
|
21
|
+
mergedVars: Record<string, string>;
|
|
22
|
+
conflicts: Array<{
|
|
23
|
+
key: string;
|
|
24
|
+
userValue: string;
|
|
25
|
+
projectValue: string;
|
|
26
|
+
resolvedValue: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if a value is a valid environment variables object
|
|
31
|
+
*/
|
|
32
|
+
export declare function isValidEnvironmentVars(env: unknown): env is Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Configuration options for environment merging
|
|
35
|
+
*/
|
|
36
|
+
export interface EnvironmentMergeOptions {
|
|
37
|
+
/** Whether to include warnings for conflicting variables */
|
|
38
|
+
includeConflictWarnings?: boolean;
|
|
39
|
+
/** Whether to validate variable names for common patterns */
|
|
40
|
+
validateVariableNames?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of environment variable processing operations
|
|
44
|
+
*/
|
|
45
|
+
export interface EnvironmentProcessResult {
|
|
46
|
+
/** The processed environment variables */
|
|
47
|
+
processedVars: Record<string, string>;
|
|
48
|
+
/** Any conflicts that occurred during processing */
|
|
49
|
+
conflicts: EnvironmentConflict[];
|
|
50
|
+
/** Non-critical warnings during processing */
|
|
51
|
+
warnings: string[];
|
|
52
|
+
/** Whether the variables were successfully applied to process.env */
|
|
53
|
+
applied: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Enhanced environment merge context with conflict details
|
|
57
|
+
*/
|
|
58
|
+
export interface EnvironmentMergeContext {
|
|
59
|
+
/** User-provided environment variables */
|
|
60
|
+
userVars: Record<string, string>;
|
|
61
|
+
/** Project-provided environment variables */
|
|
62
|
+
projectVars: Record<string, string>;
|
|
63
|
+
/** Final merged environment variables */
|
|
64
|
+
mergedVars: Record<string, string>;
|
|
65
|
+
/** Detailed conflict information */
|
|
66
|
+
conflicts: EnvironmentConflict[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Detailed information about an environment variable conflict
|
|
70
|
+
*/
|
|
71
|
+
export interface EnvironmentConflict {
|
|
72
|
+
/** The environment variable key */
|
|
73
|
+
key: string;
|
|
74
|
+
/** Value from user configuration */
|
|
75
|
+
userValue: string;
|
|
76
|
+
/** Value from project configuration */
|
|
77
|
+
projectValue: string;
|
|
78
|
+
/** Final resolved value (which source won) */
|
|
79
|
+
resolvedValue: string;
|
|
80
|
+
/** Which source provided the final value */
|
|
81
|
+
source: "user" | "project";
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/types/environment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,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GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable System Types
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive TypeScript types for environment variable validation,
|
|
5
|
+
* merging, and conflict resolution in the Wave Agent SDK.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a valid environment variables object
|
|
9
|
+
*/
|
|
10
|
+
export function isValidEnvironmentVars(env) {
|
|
11
|
+
if (typeof env !== "object" || env === null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// Check if all keys and values are strings
|
|
15
|
+
for (const [key, value] of Object.entries(env)) {
|
|
16
|
+
if (typeof key !== "string" || typeof value !== "string") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|