wave-agent-sdk 1.0.4 → 1.0.6
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 +23 -1
- package/dist/agent.js +34 -4
- package/dist/managers/aiManager.d.ts +36 -0
- package/dist/managers/aiManager.js +240 -8
- package/dist/managers/messageManager.d.ts +1 -3
- package/dist/managers/messageManager.js +19 -9
- package/dist/managers/slashCommandManager.js +28 -0
- package/dist/managers/subagentManager.d.ts +0 -2
- package/dist/services/session.js +2 -9
- package/dist/telemetry/instrumentation.d.ts +1 -1
- package/dist/telemetry/instrumentation.js +57 -28
- package/dist/tools/bashTool.js +16 -6
- package/dist/tools/grepTool.js +11 -3
- package/dist/types/index.d.ts +3 -0
- package/dist/types/messaging.d.ts +2 -0
- package/dist/utils/containerSetup.js +0 -3
- package/dist/utils/messageOperations.d.ts +10 -1
- package/dist/utils/messageOperations.js +19 -1
- package/dist/utils/notificationXml.js +5 -0
- package/dist/utils/ripgrep.d.ts +4 -4
- package/dist/utils/ripgrep.js +4 -27
- package/package.json +20 -8
- package/bin/rg +0 -79
- package/dist/managers/forkedAgentManager.d.ts +0 -50
- package/dist/managers/forkedAgentManager.js +0 -130
- package/scripts/install_ripgrep.js +0 -111
- package/scripts/postinstall.js +0 -38
- package/src/agent.ts +0 -1271
- package/src/constants/subagents.ts +0 -4
- package/src/constants/toolLimits.ts +0 -15
- package/src/constants/tools.ts +0 -24
- package/src/core/plugin.ts +0 -237
- package/src/core/session.ts +0 -9
- package/src/index.ts +0 -38
- package/src/managers/MemoryRuleManager.ts +0 -198
- package/src/managers/aiManager.ts +0 -2429
- package/src/managers/backgroundTaskManager.ts +0 -480
- package/src/managers/bangManager.ts +0 -119
- package/src/managers/cronManager.ts +0 -401
- package/src/managers/foregroundTaskManager.ts +0 -30
- package/src/managers/forkedAgentManager.ts +0 -216
- package/src/managers/hookManager.ts +0 -1089
- package/src/managers/liveConfigManager.ts +0 -445
- package/src/managers/lspManager.ts +0 -470
- package/src/managers/mcpManager.ts +0 -1010
- package/src/managers/messageManager.ts +0 -1180
- package/src/managers/messageQueue.ts +0 -157
- package/src/managers/permissionManager.ts +0 -1140
- package/src/managers/planManager.ts +0 -112
- package/src/managers/pluginManager.ts +0 -330
- package/src/managers/pluginScopeManager.ts +0 -124
- package/src/managers/reversionManager.ts +0 -178
- package/src/managers/skillManager.ts +0 -578
- package/src/managers/slashCommandManager.ts +0 -564
- package/src/managers/subagentManager.ts +0 -915
- package/src/managers/toolManager.ts +0 -489
- package/src/managers/workflowManager.ts +0 -493
- package/src/prompts/autoMemory.ts +0 -33
- package/src/prompts/autoMemoryExtraction.ts +0 -146
- package/src/prompts/index.ts +0 -506
- package/src/prompts/planModeReminders.ts +0 -126
- package/src/services/GitService.ts +0 -131
- package/src/services/MarketplaceService.ts +0 -1052
- package/src/services/MemoryRuleService.ts +0 -71
- package/src/services/aiService.ts +0 -919
- package/src/services/authService.ts +0 -565
- package/src/services/autoMemoryService.ts +0 -280
- package/src/services/configurationService.ts +0 -1520
- package/src/services/fileWatcher.ts +0 -319
- package/src/services/hook.ts +0 -348
- package/src/services/initializationService.ts +0 -357
- package/src/services/interactionService.ts +0 -229
- package/src/services/jsonlHandler.ts +0 -295
- package/src/services/memory.ts +0 -234
- package/src/services/pluginLoader.ts +0 -252
- package/src/services/remoteSettingsService.ts +0 -366
- package/src/services/reversionService.ts +0 -122
- package/src/services/session.ts +0 -922
- package/src/services/taskManager.ts +0 -321
- package/src/telemetry/events.ts +0 -65
- package/src/telemetry/instrumentation.ts +0 -499
- package/src/telemetry/sessionTracing.ts +0 -348
- package/src/tools/agentTool.ts +0 -322
- package/src/tools/askUserQuestion.ts +0 -160
- package/src/tools/bashTool.ts +0 -621
- package/src/tools/buildTool.ts +0 -61
- package/src/tools/cronCreateTool.ts +0 -161
- package/src/tools/cronDeleteTool.ts +0 -51
- package/src/tools/cronListTool.ts +0 -47
- package/src/tools/editTool.ts +0 -313
- package/src/tools/enterPlanMode.ts +0 -124
- package/src/tools/enterWorktreeTool.ts +0 -190
- package/src/tools/exitPlanMode.ts +0 -139
- package/src/tools/exitWorktreeTool.ts +0 -236
- package/src/tools/globTool.ts +0 -167
- package/src/tools/grepTool.ts +0 -399
- package/src/tools/lspTool.ts +0 -883
- package/src/tools/readTool.ts +0 -426
- package/src/tools/skillTool.ts +0 -248
- package/src/tools/taskManagementTools.ts +0 -574
- package/src/tools/taskStopTool.ts +0 -78
- package/src/tools/types.ts +0 -137
- package/src/tools/webFetchTool.ts +0 -373
- package/src/tools/workflowTool.ts +0 -205
- package/src/tools/writeTool.ts +0 -267
- package/src/types/agent.ts +0 -128
- package/src/types/auth.ts +0 -19
- package/src/types/commands.ts +0 -30
- package/src/types/config.ts +0 -43
- package/src/types/configuration.ts +0 -168
- package/src/types/core.ts +0 -105
- package/src/types/cron.ts +0 -13
- package/src/types/environment.ts +0 -106
- package/src/types/fileSearch.ts +0 -4
- package/src/types/history.ts +0 -7
- package/src/types/hooks.ts +0 -256
- package/src/types/index.ts +0 -41
- package/src/types/lsp.ts +0 -98
- package/src/types/marketplace.ts +0 -71
- package/src/types/mcp.ts +0 -43
- package/src/types/memoryRule.ts +0 -31
- package/src/types/messaging.ts +0 -114
- package/src/types/permissions.ts +0 -80
- package/src/types/plugins.ts +0 -39
- package/src/types/processes.ts +0 -99
- package/src/types/reversion.ts +0 -29
- package/src/types/session.ts +0 -12
- package/src/types/skills.ts +0 -108
- package/src/types/tasks.ts +0 -13
- package/src/types/telemetry.ts +0 -98
- package/src/types/tools.ts +0 -44
- package/src/types/workflow.ts +0 -6
- package/src/utils/abortUtils.ts +0 -118
- package/src/utils/atomicWrite.ts +0 -61
- package/src/utils/bashParser.ts +0 -899
- package/src/utils/cacheControlUtils.ts +0 -426
- package/src/utils/commandArgumentParser.ts +0 -161
- package/src/utils/commandPathResolver.ts +0 -88
- package/src/utils/configPaths.ts +0 -220
- package/src/utils/configValidator.ts +0 -100
- package/src/utils/constants.ts +0 -39
- package/src/utils/container.ts +0 -92
- package/src/utils/containerSetup.ts +0 -371
- package/src/utils/convertMessagesForAPI.ts +0 -326
- package/src/utils/cronTasks.ts +0 -128
- package/src/utils/cronTasksLock.ts +0 -182
- package/src/utils/cronToHuman.ts +0 -99
- package/src/utils/customCommands.ts +0 -95
- package/src/utils/editUtils.ts +0 -20
- package/src/utils/fileFormat.ts +0 -40
- package/src/utils/fileSearch.ts +0 -151
- package/src/utils/fileUtils.ts +0 -223
- package/src/utils/gitUtils.ts +0 -315
- package/src/utils/globalLogger.ts +0 -128
- package/src/utils/groupMessagesByApiRound.ts +0 -121
- package/src/utils/hookMatcher.ts +0 -176
- package/src/utils/markdownParser.ts +0 -317
- package/src/utils/mcpUtils.ts +0 -138
- package/src/utils/messageOperations.ts +0 -641
- package/src/utils/modelCapabilities.ts +0 -30
- package/src/utils/nameGenerator.ts +0 -99
- package/src/utils/notificationXml.ts +0 -57
- package/src/utils/openaiClient.ts +0 -251
- package/src/utils/parseCronExpression.ts +0 -78
- package/src/utils/path.ts +0 -72
- package/src/utils/pathEncoder.ts +0 -400
- package/src/utils/pathSafety.ts +0 -40
- package/src/utils/promptHistory.ts +0 -168
- package/src/utils/ripgrep.ts +0 -35
- package/src/utils/shellResolver.ts +0 -190
- package/src/utils/skillParser.ts +0 -246
- package/src/utils/stringUtils.ts +0 -156
- package/src/utils/subagentParser.ts +0 -279
- package/src/utils/taskReminder.ts +0 -96
- package/src/utils/tokenCalculation.ts +0 -43
- package/src/utils/tokenEstimate.ts +0 -34
- package/src/utils/toolResultStorage.ts +0 -117
- package/src/utils/worktreeSession.ts +0 -26
- package/src/utils/worktreeUtils.ts +0 -786
- package/src/workflow/budgetTracker.ts +0 -34
- package/src/workflow/concurrencyLimiter.ts +0 -47
- package/src/workflow/journal.ts +0 -95
- package/src/workflow/progressReporter.ts +0 -141
- package/src/workflow/runState.ts +0 -65
- package/src/workflow/scriptRuntime.ts +0 -274
- package/src/workflow/structuredOutput.ts +0 -123
- package/src/workflow/types.ts +0 -101
- package/src/workflow/workflowApis.ts +0 -410
- package/vendor/ripgrep/linux-aarch64/rg +0 -0
- package/vendor/ripgrep/linux-x86_64/rg +0 -0
- package/vendor/ripgrep/macos-aarch64/rg +0 -0
- package/vendor/ripgrep/macos-x86_64/rg +0 -0
- package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
- package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
package/src/utils/configPaths.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Path Utilities
|
|
3
|
-
*
|
|
4
|
-
* Centralized utilities for resolving Wave configuration file paths.
|
|
5
|
-
* Supports both regular settings.json and local settings.local.json with proper priority.
|
|
6
|
-
*
|
|
7
|
-
* Priority system:
|
|
8
|
-
* - User configs: ~/.wave/settings.json
|
|
9
|
-
* - Local configs: {workdir}/.wave/settings.local.json > {workdir}/.wave/settings.json
|
|
10
|
-
* - Project configs override user configs (existing behavior)
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { join, dirname } from "path";
|
|
14
|
-
import { homedir } from "os";
|
|
15
|
-
import { existsSync } from "fs";
|
|
16
|
-
import { fileURLToPath } from "url";
|
|
17
|
-
import { findUpSync } from "find-up";
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Resolve the package root directory by finding the nearest package.json.
|
|
24
|
-
* Works correctly even when bundled (e.g. esbuild into a VS Code extension),
|
|
25
|
-
* as long as vendor/ and builtin/ remain alongside package.json on disk.
|
|
26
|
-
*/
|
|
27
|
-
let _packageRoot: string | undefined;
|
|
28
|
-
export function getPackageRoot(): string {
|
|
29
|
-
if (_packageRoot) return _packageRoot;
|
|
30
|
-
const pkgPath = findUpSync("package.json", { cwd: __dirname });
|
|
31
|
-
if (pkgPath) {
|
|
32
|
-
_packageRoot = dirname(pkgPath);
|
|
33
|
-
return _packageRoot;
|
|
34
|
-
}
|
|
35
|
-
// Fallback: relative to this file (works during development)
|
|
36
|
-
_packageRoot = join(__dirname, "..", "..");
|
|
37
|
-
return _packageRoot;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get the builtin skills directory path
|
|
42
|
-
*/
|
|
43
|
-
export function getBuiltinSkillsDir(): string {
|
|
44
|
-
return join(getPackageRoot(), "builtin", "skills");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the builtin subagents directory path
|
|
49
|
-
*/
|
|
50
|
-
export function getBuiltinSubagentsDir(): string {
|
|
51
|
-
return join(getPackageRoot(), "builtin", "subagents");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get the builtin plugins directory path
|
|
56
|
-
*/
|
|
57
|
-
export function getBuiltinPluginsDir(): string {
|
|
58
|
-
return join(getPackageRoot(), "builtin", "plugins");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get the user-specific configuration file path (legacy function)
|
|
63
|
-
* @deprecated Use getUserConfigPaths() for better priority support
|
|
64
|
-
*/
|
|
65
|
-
export function getUserConfigPath(): string {
|
|
66
|
-
return join(homedir(), ".wave", "settings.json");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Get the project-specific configuration file path (legacy function)
|
|
71
|
-
* @deprecated Use getProjectConfigPaths() for better priority support
|
|
72
|
-
*/
|
|
73
|
-
export function getProjectConfigPath(workdir: string): string {
|
|
74
|
-
return join(workdir, ".wave", "settings.json");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get the user-specific configuration file paths in priority order
|
|
79
|
-
* Returns array with .json only
|
|
80
|
-
*/
|
|
81
|
-
export function getUserConfigPaths(): string[] {
|
|
82
|
-
const baseDir = join(homedir(), ".wave");
|
|
83
|
-
return [join(baseDir, "settings.json")];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get the plugins directory path
|
|
88
|
-
*/
|
|
89
|
-
export function getPluginsDir(): string {
|
|
90
|
-
return join(homedir(), ".wave", "plugins");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get the local configuration file paths in priority order
|
|
95
|
-
* Returns array with .local.json first, then .json
|
|
96
|
-
*/
|
|
97
|
-
export function getProjectConfigPaths(workdir: string): string[] {
|
|
98
|
-
const baseDir = join(workdir, ".wave");
|
|
99
|
-
return [join(baseDir, "settings.local.json"), join(baseDir, "settings.json")];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Get all configuration file paths (user and project) in priority order
|
|
104
|
-
* Useful for comprehensive configuration detection
|
|
105
|
-
*/
|
|
106
|
-
export function getAllConfigPaths(workdir: string): {
|
|
107
|
-
userPaths: string[];
|
|
108
|
-
projectPaths: string[];
|
|
109
|
-
builtinPaths: string[];
|
|
110
|
-
allPaths: string[];
|
|
111
|
-
} {
|
|
112
|
-
const userPaths = getUserConfigPaths();
|
|
113
|
-
const projectPaths = getProjectConfigPaths(workdir);
|
|
114
|
-
const builtinPaths = [join(getBuiltinSkillsDir(), "settings", "SKILL.md")];
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
userPaths,
|
|
118
|
-
projectPaths,
|
|
119
|
-
builtinPaths,
|
|
120
|
-
allPaths: [...userPaths, ...projectPaths, ...builtinPaths],
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Get existing configuration file paths
|
|
126
|
-
* Returns only the paths that actually exist on the filesystem
|
|
127
|
-
*/
|
|
128
|
-
export function getExistingConfigPaths(workdir: string): {
|
|
129
|
-
userPaths: string[];
|
|
130
|
-
projectPaths: string[];
|
|
131
|
-
builtinPaths: string[];
|
|
132
|
-
existingPaths: string[];
|
|
133
|
-
} {
|
|
134
|
-
const allPaths = getAllConfigPaths(workdir);
|
|
135
|
-
|
|
136
|
-
const existingUserPaths = allPaths.userPaths.filter(existsSync);
|
|
137
|
-
const existingProjectPaths = allPaths.projectPaths.filter(existsSync);
|
|
138
|
-
const existingBuiltinPaths = allPaths.builtinPaths.filter(existsSync);
|
|
139
|
-
const allExistingPaths = allPaths.allPaths.filter(existsSync);
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
userPaths: existingUserPaths,
|
|
143
|
-
projectPaths: existingProjectPaths,
|
|
144
|
-
builtinPaths: existingBuiltinPaths,
|
|
145
|
-
existingPaths: allExistingPaths,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Get the first existing configuration file path with the specified priority
|
|
151
|
-
* @param paths Array of paths in priority order
|
|
152
|
-
* @returns The first path that exists, or undefined if none exist
|
|
153
|
-
*/
|
|
154
|
-
export function getFirstExistingPath(paths: string[]): string | undefined {
|
|
155
|
-
return paths.find((path) => existsSync(path));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Get effective configuration paths (the ones that would actually be used)
|
|
160
|
-
* Returns the highest priority existing path for each category
|
|
161
|
-
*/
|
|
162
|
-
export function getEffectiveConfigPaths(workdir: string): {
|
|
163
|
-
userPath?: string;
|
|
164
|
-
projectPath?: string;
|
|
165
|
-
effectivePath?: string; // The path that takes final precedence
|
|
166
|
-
} {
|
|
167
|
-
const userPaths = getUserConfigPaths();
|
|
168
|
-
const projectPaths = getProjectConfigPaths(workdir);
|
|
169
|
-
|
|
170
|
-
const userPath = getFirstExistingPath(userPaths);
|
|
171
|
-
const projectPath = getFirstExistingPath(projectPaths);
|
|
172
|
-
|
|
173
|
-
// Project path takes precedence over user path if both exist
|
|
174
|
-
const effectivePath = projectPath || userPath;
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
userPath,
|
|
178
|
-
projectPath,
|
|
179
|
-
effectivePath,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Check if any configuration files exist
|
|
185
|
-
*/
|
|
186
|
-
export function hasAnyConfig(workdir: string): boolean {
|
|
187
|
-
const { existingPaths } = getExistingConfigPaths(workdir);
|
|
188
|
-
return existingPaths.length > 0;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Get configuration information for debugging and monitoring
|
|
193
|
-
*/
|
|
194
|
-
export function getConfigurationInfo(workdir: string): {
|
|
195
|
-
hasUser: boolean;
|
|
196
|
-
hasProject: boolean;
|
|
197
|
-
paths: string[];
|
|
198
|
-
userPaths: string[];
|
|
199
|
-
projectPaths: string[];
|
|
200
|
-
existingPaths: string[];
|
|
201
|
-
effectivePaths: {
|
|
202
|
-
userPath?: string;
|
|
203
|
-
projectPath?: string;
|
|
204
|
-
effectivePath?: string;
|
|
205
|
-
};
|
|
206
|
-
} {
|
|
207
|
-
const allPaths = getAllConfigPaths(workdir);
|
|
208
|
-
const existingPaths = getExistingConfigPaths(workdir);
|
|
209
|
-
const effectivePaths = getEffectiveConfigPaths(workdir);
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
hasUser: existingPaths.userPaths.length > 0,
|
|
213
|
-
hasProject: existingPaths.projectPaths.length > 0,
|
|
214
|
-
paths: allPaths.allPaths,
|
|
215
|
-
userPaths: allPaths.userPaths,
|
|
216
|
-
projectPaths: allPaths.projectPaths,
|
|
217
|
-
existingPaths: existingPaths.existingPaths,
|
|
218
|
-
effectivePaths,
|
|
219
|
-
};
|
|
220
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration validator utilities for Agent Constructor Configuration
|
|
3
|
-
* Validates configuration values for correctness and security
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
GatewayConfig,
|
|
8
|
-
ConfigurationError,
|
|
9
|
-
CONFIG_ERRORS,
|
|
10
|
-
} from "../types/index.js";
|
|
11
|
-
|
|
12
|
-
export class ConfigValidator {
|
|
13
|
-
/**
|
|
14
|
-
* Validates gateway configuration
|
|
15
|
-
* @param config - Configuration to validate
|
|
16
|
-
* @throws ConfigurationError with descriptive message if invalid
|
|
17
|
-
*/
|
|
18
|
-
static validateGatewayConfig(config: GatewayConfig): void {
|
|
19
|
-
// Validate API key if provided
|
|
20
|
-
if (config.apiKey !== undefined) {
|
|
21
|
-
if (typeof config.apiKey !== "string") {
|
|
22
|
-
throw new ConfigurationError(
|
|
23
|
-
"API key must be a string if provided.",
|
|
24
|
-
"apiKey",
|
|
25
|
-
config.apiKey,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Validate base URL if provided
|
|
31
|
-
if (config.baseURL) {
|
|
32
|
-
if (typeof config.baseURL !== "string") {
|
|
33
|
-
throw new ConfigurationError(
|
|
34
|
-
"Base URL must be a string if provided.",
|
|
35
|
-
"baseURL",
|
|
36
|
-
config.baseURL,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (config.baseURL.trim() === "") {
|
|
41
|
-
throw new ConfigurationError(
|
|
42
|
-
CONFIG_ERRORS.EMPTY_BASE_URL,
|
|
43
|
-
"baseURL",
|
|
44
|
-
config.baseURL,
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Basic URL format validation
|
|
49
|
-
try {
|
|
50
|
-
new URL(config.baseURL);
|
|
51
|
-
} catch {
|
|
52
|
-
throw new ConfigurationError(
|
|
53
|
-
`Base URL must be a valid URL format. Received: ${config.baseURL}`,
|
|
54
|
-
"baseURL",
|
|
55
|
-
config.baseURL,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Validates token limit value
|
|
63
|
-
* @param maxInputTokens - Token limit to validate
|
|
64
|
-
* @throws ConfigurationError if invalid
|
|
65
|
-
*/
|
|
66
|
-
static validateMaxInputTokens(maxInputTokens: number): void {
|
|
67
|
-
if (typeof maxInputTokens !== "number") {
|
|
68
|
-
throw new ConfigurationError(
|
|
69
|
-
CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
|
|
70
|
-
"maxInputTokens",
|
|
71
|
-
maxInputTokens,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!Number.isInteger(maxInputTokens)) {
|
|
76
|
-
throw new ConfigurationError(
|
|
77
|
-
CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
|
|
78
|
-
"maxInputTokens",
|
|
79
|
-
maxInputTokens,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (maxInputTokens <= 0) {
|
|
84
|
-
throw new ConfigurationError(
|
|
85
|
-
CONFIG_ERRORS.INVALID_WAVE_MAX_INPUT_TOKENS,
|
|
86
|
-
"maxInputTokens",
|
|
87
|
-
maxInputTokens,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Static configuration validator instance
|
|
95
|
-
* Implements ConfigurationValidator interface from types.ts
|
|
96
|
-
*/
|
|
97
|
-
export const configValidator = {
|
|
98
|
-
validateGatewayConfig: ConfigValidator.validateGatewayConfig,
|
|
99
|
-
validateMaxInputTokens: ConfigValidator.validateMaxInputTokens,
|
|
100
|
-
};
|
package/src/utils/constants.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application constants definition
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import path from "path";
|
|
6
|
-
import os from "os";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Application data storage directory
|
|
10
|
-
* Used to store debug logs, command history and other data
|
|
11
|
-
*/
|
|
12
|
-
export const DATA_DIRECTORY = path.join(os.homedir(), ".wave");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Prompt history file path
|
|
16
|
-
*/
|
|
17
|
-
export const PROMPT_HISTORY_FILE = path.join(DATA_DIRECTORY, "history.jsonl");
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Error log directory path
|
|
21
|
-
*/
|
|
22
|
-
export const ERROR_LOG_DIRECTORY = path.join(DATA_DIRECTORY, "error-logs");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* User-level memory file path
|
|
26
|
-
*/
|
|
27
|
-
export const USER_MEMORY_FILE = path.join(DATA_DIRECTORY, "AGENTS.md");
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* AI related constants
|
|
31
|
-
*/
|
|
32
|
-
export const DEFAULT_WAVE_MAX_INPUT_TOKENS = 200000; // Default token limit
|
|
33
|
-
export const DEFAULT_WAVE_MAX_OUTPUT_TOKENS = 32000; // Default output token limit (aligned with Claude Code)
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Default server URL for SSO authentication.
|
|
37
|
-
* Overridden by WAVE_SERVER_URL env var or programmatic AgentOptions.serverUrl.
|
|
38
|
-
*/
|
|
39
|
-
export const DEFAULT_SERVER_URL = "https://codechat.codewave.163.com";
|
package/src/utils/container.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple Dependency Injection container to manage late-binding dependencies
|
|
3
|
-
* and resolve circular references.
|
|
4
|
-
*/
|
|
5
|
-
export class Container {
|
|
6
|
-
private services = new Map<string, unknown>();
|
|
7
|
-
private factories = new Map<string, () => unknown>();
|
|
8
|
-
private parent?: Container;
|
|
9
|
-
|
|
10
|
-
constructor(parent?: Container) {
|
|
11
|
-
this.parent = parent;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Create a child container that inherits from this container
|
|
16
|
-
*/
|
|
17
|
-
createChild(): Container {
|
|
18
|
-
return new Container(this);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Register a singleton instance
|
|
23
|
-
*/
|
|
24
|
-
register<T>(token: string, instance: T): void {
|
|
25
|
-
this.services.set(token, instance);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Register a factory function for lazy resolution
|
|
30
|
-
*/
|
|
31
|
-
provide<T>(token: string, factory: () => T): void {
|
|
32
|
-
this.factories.set(token, factory);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Resolve a service by token
|
|
37
|
-
*/
|
|
38
|
-
get<T>(token: string): T | undefined {
|
|
39
|
-
if (this.services.has(token)) {
|
|
40
|
-
return this.services.get(token) as T;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const factory = this.factories.get(token);
|
|
44
|
-
if (factory) {
|
|
45
|
-
const instance = factory() as T;
|
|
46
|
-
this.services.set(token, instance);
|
|
47
|
-
return instance;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (this.parent) {
|
|
51
|
-
return this.parent.get<T>(token);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check if a service exists
|
|
59
|
-
*/
|
|
60
|
-
has(token: string): boolean {
|
|
61
|
-
return (
|
|
62
|
-
this.services.has(token) ||
|
|
63
|
-
this.factories.has(token) ||
|
|
64
|
-
(this.parent ? this.parent.has(token) : false)
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Example usage for ToolManager:
|
|
70
|
-
/*
|
|
71
|
-
const container = new Container();
|
|
72
|
-
|
|
73
|
-
// 1. Provide managers lazily
|
|
74
|
-
container.provide('SubagentManager', () => new SubagentManager(...));
|
|
75
|
-
container.provide('SkillManager', () => new SkillManager(...));
|
|
76
|
-
|
|
77
|
-
// 2. ToolManager can now resolve them only when needed (e.g., in execute)
|
|
78
|
-
class ToolManager {
|
|
79
|
-
constructor(private container: Container) {}
|
|
80
|
-
|
|
81
|
-
async execute(name: string, args: any, context: any) {
|
|
82
|
-
const enhancedContext = {
|
|
83
|
-
...context,
|
|
84
|
-
subagentManager: this.container.has('SubagentManager')
|
|
85
|
-
? this.container.get('SubagentManager')
|
|
86
|
-
: undefined,
|
|
87
|
-
// ...
|
|
88
|
-
};
|
|
89
|
-
// ...
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
*/
|