wave-agent-sdk 0.9.6 → 0.10.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.
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +59 -6
- package/dist/managers/messageManager.d.ts +5 -1
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +11 -1
- package/dist/managers/pluginManager.js +1 -1
- package/dist/managers/skillManager.d.ts +17 -3
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +64 -26
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +28 -10
- 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/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +4 -0
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +15 -2
- package/dist/tools/agentTool.d.ts.map +1 -1
- package/dist/tools/agentTool.js +7 -3
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +6 -2
- 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/types/marketplace.d.ts +1 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/processes.d.ts +4 -0
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/types/skills.d.ts +1 -0
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/utils/fileSearch.d.ts.map +1 -1
- package/dist/utils/fileSearch.js +1 -6
- package/dist/utils/markdownParser.js +1 -1
- package/dist/utils/messageOperations.d.ts +6 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +26 -2
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +24 -7
- package/package.json +1 -1
- package/scripts/install_ripgrep.js +7 -5
- package/scripts/postinstall.js +10 -7
- package/src/index.ts +0 -1
- package/src/managers/backgroundTaskManager.ts +62 -6
- package/src/managers/messageManager.ts +16 -1
- package/src/managers/pluginManager.ts +1 -1
- package/src/managers/skillManager.ts +76 -35
- package/src/managers/slashCommandManager.ts +33 -10
- package/src/managers/subagentManager.ts +31 -0
- package/src/services/MarketplaceService.ts +6 -0
- package/src/services/hook.ts +16 -2
- package/src/tools/agentTool.ts +9 -3
- package/src/tools/bashTool.ts +6 -2
- package/src/tools/globTool.ts +9 -61
- package/src/tools/grepTool.ts +0 -7
- package/src/types/marketplace.ts +1 -0
- package/src/types/processes.ts +4 -0
- package/src/types/skills.ts +1 -0
- package/src/utils/fileSearch.ts +1 -6
- package/src/utils/markdownParser.ts +1 -1
- package/src/utils/messageOperations.ts +32 -1
- 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/globTool.ts
CHANGED
|
@@ -1,70 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { rgPath } from "../utils/ripgrep.js";
|
|
1
|
+
import { glob } from "glob";
|
|
3
2
|
import { stat } from "fs/promises";
|
|
4
3
|
import type { ToolPlugin, ToolResult, ToolContext } from "./types.js";
|
|
5
4
|
import { resolvePath, getDisplayPath } from "../utils/path.js";
|
|
6
|
-
import { getAllIgnorePatterns } from "../utils/fileFilter.js";
|
|
7
5
|
import { GLOB_TOOL_NAME } from "../constants/tools.js";
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Maximum number of files returned by glob tool
|
|
11
9
|
*/
|
|
12
|
-
const MAX_GLOB_RESULTS =
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Execute ripgrep to find files matching a pattern
|
|
16
|
-
*/
|
|
17
|
-
async function runRipgrep(pattern: string, workdir: string): Promise<string[]> {
|
|
18
|
-
if (!rgPath) {
|
|
19
|
-
throw new Error("ripgrep is not available");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ignorePatterns = getAllIgnorePatterns();
|
|
23
|
-
const rgArgs = ["--files", "--color=never", "--hidden", "--glob", pattern];
|
|
24
|
-
|
|
25
|
-
for (const ignorePattern of ignorePatterns) {
|
|
26
|
-
rgArgs.push("--glob", `!${ignorePattern}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return new Promise<string[]>((resolve, reject) => {
|
|
30
|
-
const child = spawn(rgPath, rgArgs, {
|
|
31
|
-
cwd: workdir,
|
|
32
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
let stdout = "";
|
|
36
|
-
let stderr = "";
|
|
37
|
-
|
|
38
|
-
child.stdout?.on("data", (data) => {
|
|
39
|
-
stdout += data.toString();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
child.stderr?.on("data", (data) => {
|
|
43
|
-
stderr += data.toString();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
child.on("close", (code) => {
|
|
47
|
-
if (code !== 0 && code !== 1) {
|
|
48
|
-
reject(
|
|
49
|
-
new Error(
|
|
50
|
-
`ripgrep failed with code ${code}: ${stderr || "Unknown error"}`,
|
|
51
|
-
),
|
|
52
|
-
);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const files = stdout
|
|
56
|
-
.trim()
|
|
57
|
-
.split("\n")
|
|
58
|
-
.filter((f) => f.length > 0)
|
|
59
|
-
.map((f) => f.replace(/\\/g, "/")); // Normalize to forward slashes
|
|
60
|
-
resolve(files);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
child.on("error", (err) => {
|
|
64
|
-
reject(err);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
10
|
+
const MAX_GLOB_RESULTS = 100;
|
|
68
11
|
|
|
69
12
|
/**
|
|
70
13
|
* Glob Tool Plugin - Fast file pattern matching
|
|
@@ -122,8 +65,13 @@ export const globTool: ToolPlugin = {
|
|
|
122
65
|
? resolvePath(searchPath, context.workdir)
|
|
123
66
|
: context.workdir;
|
|
124
67
|
|
|
125
|
-
// Execute glob search using
|
|
126
|
-
const matches = await
|
|
68
|
+
// Execute glob search using glob package
|
|
69
|
+
const matches = await glob(pattern, {
|
|
70
|
+
cwd: workdir,
|
|
71
|
+
nodir: true,
|
|
72
|
+
dot: true,
|
|
73
|
+
ignore: ["**/.git/**"],
|
|
74
|
+
});
|
|
127
75
|
|
|
128
76
|
if (matches.length === 0) {
|
|
129
77
|
return {
|
package/src/tools/grepTool.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ToolPlugin, ToolResult, ToolContext } from "./types.js";
|
|
2
2
|
import { spawn } from "child_process";
|
|
3
|
-
import { getAllIgnorePatterns } from "../utils/fileFilter.js";
|
|
4
3
|
import { rgPath } from "../utils/ripgrep.js";
|
|
5
4
|
import { getDisplayPath } from "../utils/path.js";
|
|
6
5
|
import {
|
|
@@ -188,12 +187,6 @@ export const grepTool: ToolPlugin = {
|
|
|
188
187
|
rgArgs.push("--glob", globPattern);
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
// Get common ignore rules
|
|
192
|
-
const ignorePatterns = getAllIgnorePatterns();
|
|
193
|
-
for (const exclude of ignorePatterns) {
|
|
194
|
-
rgArgs.push("--glob", `!${exclude}`);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
190
|
// Add search pattern - use -e parameter to avoid patterns starting with - being mistaken as command line options
|
|
198
191
|
rgArgs.push("-e", pattern);
|
|
199
192
|
|
package/src/types/marketplace.ts
CHANGED
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/types/skills.ts
CHANGED
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, {
|
|
@@ -81,7 +76,7 @@ export const searchFiles = async (
|
|
|
81
76
|
workingDirectory?: string;
|
|
82
77
|
},
|
|
83
78
|
): Promise<FileItem[]> => {
|
|
84
|
-
const { maxResults =
|
|
79
|
+
const { maxResults = 100, workingDirectory = process.cwd() } = options || {};
|
|
85
80
|
|
|
86
81
|
try {
|
|
87
82
|
const files = await getAllFiles(workingDirectory);
|
|
@@ -173,7 +173,7 @@ export function replaceBashCommandsWithOutput(
|
|
|
173
173
|
processedContent = processedContent.replace(bashCommandRegex, (match) => {
|
|
174
174
|
if (commandIndex < results.length) {
|
|
175
175
|
const result = results[commandIndex++];
|
|
176
|
-
return
|
|
176
|
+
return result.output;
|
|
177
177
|
}
|
|
178
178
|
return match;
|
|
179
179
|
});
|
|
@@ -17,6 +17,7 @@ export interface UserMessageParams {
|
|
|
17
17
|
// Parameter interfaces for message operations
|
|
18
18
|
export interface AddUserMessageParams extends UserMessageParams {
|
|
19
19
|
messages: Message[];
|
|
20
|
+
id?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface UpdateToolBlockParams {
|
|
@@ -123,6 +124,7 @@ export const addUserMessageToMessages = ({
|
|
|
123
124
|
images,
|
|
124
125
|
customCommandContent,
|
|
125
126
|
source,
|
|
127
|
+
id,
|
|
126
128
|
}: AddUserMessageParams): Message[] => {
|
|
127
129
|
const blocks: Message["blocks"] = [];
|
|
128
130
|
|
|
@@ -145,13 +147,42 @@ export const addUserMessageToMessages = ({
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
const userMessage: Message = {
|
|
148
|
-
id: generateMessageId(),
|
|
150
|
+
id: id || generateMessageId(),
|
|
149
151
|
role: "user",
|
|
150
152
|
blocks,
|
|
151
153
|
};
|
|
152
154
|
return [...messages, userMessage];
|
|
153
155
|
};
|
|
154
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Update a user message's content or customCommandContent by its ID.
|
|
159
|
+
*/
|
|
160
|
+
export const updateUserMessageInMessages = (
|
|
161
|
+
messages: Message[],
|
|
162
|
+
id: string,
|
|
163
|
+
params: Partial<UserMessageParams>,
|
|
164
|
+
): Message[] => {
|
|
165
|
+
return messages.map((msg) => {
|
|
166
|
+
if (msg.id === id && msg.role === "user") {
|
|
167
|
+
const newBlocks = msg.blocks.map((block) => {
|
|
168
|
+
if (block.type === "text") {
|
|
169
|
+
return {
|
|
170
|
+
...block,
|
|
171
|
+
...(params.content !== undefined && { content: params.content }),
|
|
172
|
+
...(params.customCommandContent !== undefined && {
|
|
173
|
+
customCommandContent: params.customCommandContent,
|
|
174
|
+
}),
|
|
175
|
+
...(params.source !== undefined && { source: params.source }),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return block;
|
|
179
|
+
});
|
|
180
|
+
return { ...msg, blocks: newBlocks };
|
|
181
|
+
}
|
|
182
|
+
return msg;
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
|
|
155
186
|
// Add assistant message (support one-time addition of answer and tool calls)
|
|
156
187
|
export const addAssistantMessageToMessages = (
|
|
157
188
|
messages: Message[],
|
|
@@ -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
|
-
};
|