wave-agent-sdk 0.9.7 → 0.10.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.
- package/dist/core/session.d.ts +1 -1
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +1 -0
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +59 -6
- package/dist/managers/messageManager.d.ts +1 -6
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +0 -6
- package/dist/managers/permissionManager.d.ts +1 -1
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +17 -9
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +13 -1
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +0 -1
- package/dist/managers/subagentManager.d.ts +2 -0
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +22 -0
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +1 -0
- package/dist/services/session.d.ts +7 -0
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +33 -0
- package/dist/tools/agentTool.d.ts.map +1 -1
- package/dist/tools/agentTool.js +7 -3
- package/dist/tools/askUserQuestion.d.ts.map +1 -1
- package/dist/tools/askUserQuestion.js +8 -1
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +7 -3
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +1 -1
- package/dist/tools/exitPlanMode.d.ts.map +1 -1
- package/dist/tools/exitPlanMode.js +1 -1
- package/dist/tools/globTool.d.ts.map +1 -1
- package/dist/tools/globTool.js +9 -48
- package/dist/tools/grepTool.d.ts.map +1 -1
- package/dist/tools/grepTool.js +0 -6
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +1 -1
- package/dist/types/permissions.d.ts +2 -0
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/processes.d.ts +4 -0
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/utils/bashParser.d.ts.map +1 -1
- package/dist/utils/bashParser.js +50 -0
- package/dist/utils/fileSearch.d.ts.map +1 -1
- package/dist/utils/fileSearch.js +0 -5
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +24 -7
- package/package.json +1 -1
- package/src/core/session.ts +1 -0
- package/src/index.ts +0 -1
- package/src/managers/aiManager.ts +1 -0
- package/src/managers/backgroundTaskManager.ts +62 -6
- package/src/managers/messageManager.ts +1 -9
- package/src/managers/permissionManager.ts +21 -8
- package/src/managers/skillManager.ts +11 -1
- package/src/managers/slashCommandManager.ts +0 -1
- package/src/managers/subagentManager.ts +31 -0
- package/src/managers/toolManager.ts +1 -0
- package/src/services/session.ts +41 -0
- package/src/tools/agentTool.ts +9 -3
- package/src/tools/askUserQuestion.ts +10 -0
- package/src/tools/bashTool.ts +7 -2
- package/src/tools/editTool.ts +1 -0
- package/src/tools/exitPlanMode.ts +1 -0
- package/src/tools/globTool.ts +9 -61
- package/src/tools/grepTool.ts +0 -7
- package/src/tools/types.ts +2 -0
- package/src/tools/writeTool.ts +1 -0
- package/src/types/permissions.ts +2 -0
- package/src/types/processes.ts +4 -0
- package/src/utils/bashParser.ts +54 -0
- package/src/utils/fileSearch.ts +0 -5
- package/src/utils/openaiClient.ts +23 -7
- package/dist/utils/fileFilter.d.ts +0 -15
- package/dist/utils/fileFilter.d.ts.map +0 -1
- package/dist/utils/fileFilter.js +0 -35
- package/src/utils/fileFilter.ts +0 -39
package/src/tools/writeTool.ts
CHANGED
package/src/types/permissions.ts
CHANGED
|
@@ -56,6 +56,8 @@ export interface ToolPermissionContext {
|
|
|
56
56
|
suggestedPrefix?: string;
|
|
57
57
|
/** Whether to hide the persistent permission option (e.g., "Don't ask again") in the UI */
|
|
58
58
|
hidePersistentOption?: boolean;
|
|
59
|
+
/** The ID of the tool call that triggered this permission request */
|
|
60
|
+
toolCallId?: string;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/** List of tools that require permission checks in default mode */
|
package/src/types/processes.ts
CHANGED
|
@@ -34,6 +34,10 @@ export interface BackgroundTaskBase {
|
|
|
34
34
|
* Used for cleanup when the task is stopped.
|
|
35
35
|
*/
|
|
36
36
|
subagentId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional path to the real-time output log file.
|
|
39
|
+
*/
|
|
40
|
+
outputPath?: string;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export interface BackgroundShell extends BackgroundTaskBase {
|
package/src/utils/bashParser.ts
CHANGED
|
@@ -327,6 +327,60 @@ export function hasWriteRedirections(command: string): boolean {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
if (char === ">") {
|
|
330
|
+
// Check if this is a redirection to /dev/null
|
|
331
|
+
let j = i + 1;
|
|
332
|
+
// Handle >> or >|
|
|
333
|
+
if (j < command.length && (command[j] === ">" || command[j] === "|")) {
|
|
334
|
+
j++;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Skip whitespace after operator
|
|
338
|
+
while (j < command.length && /\s/.test(command[j])) {
|
|
339
|
+
j++;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Extract the target word, handling quotes and escapes
|
|
343
|
+
let target = "";
|
|
344
|
+
let targetEscaped = false;
|
|
345
|
+
let targetInSingleQuote = false;
|
|
346
|
+
let targetInDoubleQuote = false;
|
|
347
|
+
let k = j;
|
|
348
|
+
while (k < command.length) {
|
|
349
|
+
const c = command[k];
|
|
350
|
+
if (targetEscaped) {
|
|
351
|
+
targetEscaped = false;
|
|
352
|
+
target += c;
|
|
353
|
+
k++;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (c === "\\") {
|
|
357
|
+
targetEscaped = true;
|
|
358
|
+
k++;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (c === "'" && !targetInDoubleQuote) {
|
|
362
|
+
targetInSingleQuote = !targetInSingleQuote;
|
|
363
|
+
k++;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (c === '"' && !targetInSingleQuote) {
|
|
367
|
+
targetInDoubleQuote = !targetInDoubleQuote;
|
|
368
|
+
k++;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (!targetInSingleQuote && !targetInDoubleQuote && /\s/.test(c)) {
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
target += c;
|
|
375
|
+
k++;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// If the target is exactly /dev/null, we ignore this redirection
|
|
379
|
+
if (target === "/dev/null") {
|
|
380
|
+
i = k - 1; // Move the main loop index to the end of the target
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
|
|
330
384
|
return true;
|
|
331
385
|
}
|
|
332
386
|
}
|
package/src/utils/fileSearch.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { rgPath } from "./ripgrep.js";
|
|
3
3
|
import fuzzysort from "fuzzysort";
|
|
4
|
-
import { getAllIgnorePatterns } from "./fileFilter.js";
|
|
5
4
|
import type { FileItem } from "../types/fileSearch.js";
|
|
6
5
|
import { logger } from "./globalLogger.js";
|
|
7
6
|
|
|
@@ -13,11 +12,7 @@ async function getAllFiles(workingDirectory: string): Promise<string[]> {
|
|
|
13
12
|
throw new Error("ripgrep is not available");
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
const ignorePatterns = getAllIgnorePatterns();
|
|
17
15
|
const rgArgs = ["--files", "--color=never", "--hidden"];
|
|
18
|
-
for (const pattern of ignorePatterns) {
|
|
19
|
-
rgArgs.push("--glob", `!${pattern}`);
|
|
20
|
-
}
|
|
21
16
|
|
|
22
17
|
return new Promise((resolve, reject) => {
|
|
23
18
|
const child = spawn(rgPath, rgArgs, {
|
|
@@ -97,13 +97,29 @@ export class OpenAIClient {
|
|
|
97
97
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
let response: Response;
|
|
101
|
+
try {
|
|
102
|
+
response = await fetchFn(url, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers,
|
|
105
|
+
body: JSON.stringify(params),
|
|
106
|
+
signal: options?.signal,
|
|
107
|
+
...(fetchOptions as RequestInit),
|
|
108
|
+
});
|
|
109
|
+
} catch (e) {
|
|
110
|
+
if (e instanceof Error && e.name === "AbortError") {
|
|
111
|
+
throw e;
|
|
112
|
+
}
|
|
113
|
+
if (attempt < maxRetries) {
|
|
114
|
+
logger.warn("OpenAI API network error, retrying...", {
|
|
115
|
+
attempt: attempt + 1,
|
|
116
|
+
error: e,
|
|
117
|
+
});
|
|
118
|
+
lastError = e as Error;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
throw e;
|
|
122
|
+
}
|
|
107
123
|
|
|
108
124
|
if (response.ok) {
|
|
109
125
|
if (params.stream) {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common ignore directory and file patterns
|
|
3
|
-
* Can be reused by multiple tools (glob, ripgrep, etc.)
|
|
4
|
-
*/
|
|
5
|
-
export declare const COMMON_IGNORE_PATTERNS: {
|
|
6
|
-
dependencies: string[];
|
|
7
|
-
cache: string[];
|
|
8
|
-
editor: string[];
|
|
9
|
-
os: string[];
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Get flat array of all common ignore patterns
|
|
13
|
-
*/
|
|
14
|
-
export declare const getAllIgnorePatterns: () => string[];
|
|
15
|
-
//# sourceMappingURL=fileFilter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileFilter.d.ts","sourceRoot":"","sources":["../../src/utils/fileFilter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;CAsBlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAAO,MAAM,EAO7C,CAAC"}
|
package/dist/utils/fileFilter.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common ignore directory and file patterns
|
|
3
|
-
* Can be reused by multiple tools (glob, ripgrep, etc.)
|
|
4
|
-
*/
|
|
5
|
-
export const COMMON_IGNORE_PATTERNS = {
|
|
6
|
-
// Dependencies and build directories
|
|
7
|
-
dependencies: [
|
|
8
|
-
"node_modules/**",
|
|
9
|
-
".git/**",
|
|
10
|
-
"dist/**",
|
|
11
|
-
"build/**",
|
|
12
|
-
".next/**",
|
|
13
|
-
"coverage/**",
|
|
14
|
-
".nyc_output/**",
|
|
15
|
-
"tmp/**",
|
|
16
|
-
"temp/**",
|
|
17
|
-
],
|
|
18
|
-
// Cache and temporary files
|
|
19
|
-
cache: ["*.log", "*.cache", ".DS_Store", "Thumbs.db", "*~", "*.swp", "*.swo"],
|
|
20
|
-
// Editor and IDE files
|
|
21
|
-
editor: [".vscode/**", ".idea/**", "*.sublime-*"],
|
|
22
|
-
// Operating system related
|
|
23
|
-
os: [".DS_Store", "Thumbs.db", "desktop.ini"],
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Get flat array of all common ignore patterns
|
|
27
|
-
*/
|
|
28
|
-
export const getAllIgnorePatterns = () => {
|
|
29
|
-
return [
|
|
30
|
-
...COMMON_IGNORE_PATTERNS.dependencies,
|
|
31
|
-
...COMMON_IGNORE_PATTERNS.cache,
|
|
32
|
-
...COMMON_IGNORE_PATTERNS.editor,
|
|
33
|
-
...COMMON_IGNORE_PATTERNS.os,
|
|
34
|
-
];
|
|
35
|
-
};
|
package/src/utils/fileFilter.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common ignore directory and file patterns
|
|
3
|
-
* Can be reused by multiple tools (glob, ripgrep, etc.)
|
|
4
|
-
*/
|
|
5
|
-
export const COMMON_IGNORE_PATTERNS = {
|
|
6
|
-
// Dependencies and build directories
|
|
7
|
-
dependencies: [
|
|
8
|
-
"node_modules/**",
|
|
9
|
-
".git/**",
|
|
10
|
-
"dist/**",
|
|
11
|
-
"build/**",
|
|
12
|
-
".next/**",
|
|
13
|
-
"coverage/**",
|
|
14
|
-
".nyc_output/**",
|
|
15
|
-
"tmp/**",
|
|
16
|
-
"temp/**",
|
|
17
|
-
],
|
|
18
|
-
|
|
19
|
-
// Cache and temporary files
|
|
20
|
-
cache: ["*.log", "*.cache", ".DS_Store", "Thumbs.db", "*~", "*.swp", "*.swo"],
|
|
21
|
-
|
|
22
|
-
// Editor and IDE files
|
|
23
|
-
editor: [".vscode/**", ".idea/**", "*.sublime-*"],
|
|
24
|
-
|
|
25
|
-
// Operating system related
|
|
26
|
-
os: [".DS_Store", "Thumbs.db", "desktop.ini"],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Get flat array of all common ignore patterns
|
|
31
|
-
*/
|
|
32
|
-
export const getAllIgnorePatterns = (): string[] => {
|
|
33
|
-
return [
|
|
34
|
-
...COMMON_IGNORE_PATTERNS.dependencies,
|
|
35
|
-
...COMMON_IGNORE_PATTERNS.cache,
|
|
36
|
-
...COMMON_IGNORE_PATTERNS.editor,
|
|
37
|
-
...COMMON_IGNORE_PATTERNS.os,
|
|
38
|
-
];
|
|
39
|
-
};
|