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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Central orchestrator for the hooks system. Handles configuration loading,
|
|
5
5
|
* validation, and hook execution across all supported events.
|
|
6
6
|
*/
|
|
7
|
-
import { type HookEvent, type
|
|
7
|
+
import { type HookEvent, type WaveConfiguration, type PartialHookConfiguration, type HookExecutionContext, type ExtendedHookExecutionContext, type HookExecutionResult, type ValidationResult } from "../types/hooks.js";
|
|
8
8
|
import { HookMatcher } from "../utils/hookMatcher.js";
|
|
9
9
|
import type { Logger } from "../types/index.js";
|
|
10
10
|
import type { MessageManager } from "./messageManager.js";
|
|
@@ -20,10 +20,10 @@ export declare class HookManager {
|
|
|
20
20
|
*/
|
|
21
21
|
loadConfiguration(userHooks?: PartialHookConfiguration, projectHooks?: PartialHookConfiguration): void;
|
|
22
22
|
/**
|
|
23
|
-
* Load configuration from
|
|
24
|
-
*
|
|
23
|
+
* Load hooks configuration from a pre-loaded WaveConfiguration
|
|
24
|
+
* Configuration loading is now handled by ConfigurationService
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
loadConfigurationFromWaveConfig(waveConfig: WaveConfiguration | null): void;
|
|
27
27
|
/**
|
|
28
28
|
* Execute hooks for a specific event
|
|
29
29
|
*/
|
|
@@ -53,9 +53,9 @@ export declare class HookManager {
|
|
|
53
53
|
*/
|
|
54
54
|
hasHooks(event: HookEvent, toolName?: string): boolean;
|
|
55
55
|
/**
|
|
56
|
-
* Validate
|
|
56
|
+
* Validate Wave configuration structure and content
|
|
57
57
|
*/
|
|
58
|
-
validateConfiguration(config:
|
|
58
|
+
validateConfiguration(config: WaveConfiguration): ValidationResult;
|
|
59
59
|
/**
|
|
60
60
|
* Validate partial hook configuration structure and content
|
|
61
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hookManager.d.ts","sourceRoot":"","sources":["../../src/managers/hookManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAItB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"hookManager.d.ts","sourceRoot":"","sources":["../../src/managers/hookManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAItB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAAuC;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG/B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAA+B,EACxC,MAAM,CAAC,EAAE,MAAM;IAOjB;;;OAGG;IACH,iBAAiB,CACf,SAAS,CAAC,EAAE,wBAAwB,EACpC,YAAY,CAAC,EAAE,wBAAwB,GACtC,IAAI;IAyBP;;;OAGG;IACH,+BAA+B,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI;IAqC3E;;OAEG;IACG,YAAY,CAChB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,GAC3D,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAyHjC;;;OAGG;IACH,kBAAkB,CAChB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,cAAc,CAAC,EAAE,cAAc,EAC/B,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,MAAM,GACtB;QACD,WAAW,EAAE,OAAO,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;IAuCD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAsE3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAWtD;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;IA8DlE;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAyCpC;;OAEG;IACH,gBAAgB,IAAI,wBAAwB,GAAG,SAAS;IAOxD;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAsDhC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA8BhC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACH,OAAO,CAAC,aAAa;IAiCrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA2C3B;;OAEG;IACH,qBAAqB,IAAI;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KAC3C;CA+CF"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { HookConfigurationError, isValidHookEvent, isValidHookEventConfig, } from "../types/hooks.js";
|
|
8
8
|
import { HookMatcher } from "../utils/hookMatcher.js";
|
|
9
|
-
import { executeCommand, isCommandSafe
|
|
9
|
+
import { executeCommand, isCommandSafe } from "../services/hook.js";
|
|
10
10
|
import { MessageSource } from "../types/index.js";
|
|
11
11
|
export class HookManager {
|
|
12
12
|
constructor(workdir, matcher = new HookMatcher(), logger) {
|
|
@@ -36,33 +36,31 @@ export class HookManager {
|
|
|
36
36
|
this.configuration = merged;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Load configuration from
|
|
40
|
-
*
|
|
39
|
+
* Load hooks configuration from a pre-loaded WaveConfiguration
|
|
40
|
+
* Configuration loading is now handled by ConfigurationService
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
loadConfigurationFromWaveConfig(waveConfig) {
|
|
43
43
|
try {
|
|
44
|
-
this.logger?.debug(`[HookManager] Loading configuration...`);
|
|
45
|
-
|
|
46
|
-
this.logger?.debug(`[HookManager] Merged config result:`, mergedConfig);
|
|
47
|
-
this.configuration = mergedConfig || undefined;
|
|
44
|
+
this.logger?.debug(`[HookManager] Loading hooks configuration from pre-loaded config...`);
|
|
45
|
+
this.configuration = waveConfig?.hooks || undefined;
|
|
48
46
|
// Validate the loaded configuration if it exists
|
|
49
|
-
if (
|
|
50
|
-
const validation = this.validatePartialConfiguration(
|
|
47
|
+
if (waveConfig?.hooks) {
|
|
48
|
+
const validation = this.validatePartialConfiguration(waveConfig.hooks);
|
|
51
49
|
if (!validation.valid) {
|
|
52
|
-
throw new HookConfigurationError("
|
|
50
|
+
throw new HookConfigurationError("provided configuration", validation.errors);
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
this.logger?.debug(`[HookManager]
|
|
53
|
+
this.logger?.debug(`[HookManager] Hooks configuration loaded successfully with ${Object.keys(waveConfig?.hooks || {}).length} event types`);
|
|
56
54
|
}
|
|
57
55
|
catch (error) {
|
|
58
56
|
// If loading fails, start with undefined configuration (no hooks)
|
|
59
57
|
this.configuration = undefined;
|
|
60
|
-
// Re-throw configuration errors, but handle
|
|
58
|
+
// Re-throw configuration errors, but handle other errors gracefully
|
|
61
59
|
if (error instanceof HookConfigurationError) {
|
|
62
60
|
throw error;
|
|
63
61
|
}
|
|
64
62
|
else {
|
|
65
|
-
this.logger?.warn(
|
|
63
|
+
this.logger?.warn(`[HookManager] Failed to load configuration, continuing with no hooks: ${error.message}`);
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -108,14 +106,14 @@ export class HookManager {
|
|
|
108
106
|
const hookCommand = config.hooks[commandIndex];
|
|
109
107
|
try {
|
|
110
108
|
this.logger?.debug(`[HookManager] Executing command ${commandIndex + 1}/${config.hooks.length} in configuration ${configIndex + 1}`);
|
|
111
|
-
const result = await executeCommand(hookCommand.command, context);
|
|
109
|
+
const result = await executeCommand(hookCommand.command, context, undefined);
|
|
112
110
|
results.push(result);
|
|
113
111
|
// Report individual command result
|
|
114
112
|
if (result.success) {
|
|
115
113
|
this.logger?.debug(`[HookManager] Command ${commandIndex + 1} completed successfully in ${result.duration}ms`);
|
|
116
114
|
}
|
|
117
115
|
else {
|
|
118
|
-
this.logger?.
|
|
116
|
+
this.logger?.debug(`[HookManager] Command ${commandIndex + 1} failed in ${result.duration}ms (exit code: ${result.exitCode}, timed out: ${result.timedOut})`);
|
|
119
117
|
}
|
|
120
118
|
// Continue with next command even if this one fails
|
|
121
119
|
// This allows for non-critical hooks to fail without stopping the workflow
|
|
@@ -208,6 +206,7 @@ export class HookManager {
|
|
|
208
206
|
result: errorMessage,
|
|
209
207
|
success: false,
|
|
210
208
|
error: "Hook blocked tool execution",
|
|
209
|
+
stage: "end", // Hook blocking results in end stage with error
|
|
211
210
|
});
|
|
212
211
|
}
|
|
213
212
|
return { shouldBlock: true };
|
|
@@ -225,6 +224,17 @@ export class HookManager {
|
|
|
225
224
|
source: MessageSource.HOOK,
|
|
226
225
|
});
|
|
227
226
|
return { shouldBlock: true, errorMessage };
|
|
227
|
+
case "Notification":
|
|
228
|
+
// For notification hooks with exit code 2, only show stderr in error block
|
|
229
|
+
messageManager.addErrorBlock(errorMessage);
|
|
230
|
+
return { shouldBlock: false };
|
|
231
|
+
case "SubagentStop":
|
|
232
|
+
// Similar to Stop, show error and allow blocking
|
|
233
|
+
messageManager.addUserMessage({
|
|
234
|
+
content: errorMessage,
|
|
235
|
+
source: MessageSource.HOOK,
|
|
236
|
+
});
|
|
237
|
+
return { shouldBlock: true, errorMessage };
|
|
228
238
|
default:
|
|
229
239
|
return { shouldBlock: false };
|
|
230
240
|
}
|
|
@@ -248,35 +258,53 @@ export class HookManager {
|
|
|
248
258
|
return eventConfigs.some((config) => this.configApplies(config, event, toolName));
|
|
249
259
|
}
|
|
250
260
|
/**
|
|
251
|
-
* Validate
|
|
261
|
+
* Validate Wave configuration structure and content
|
|
252
262
|
*/
|
|
253
263
|
validateConfiguration(config) {
|
|
254
264
|
const errors = [];
|
|
255
265
|
if (!config || typeof config !== "object") {
|
|
256
266
|
return { valid: false, errors: ["Configuration must be an object"] };
|
|
257
267
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
errors
|
|
262
|
-
}
|
|
268
|
+
// Validate hooks if present
|
|
269
|
+
if (config.hooks) {
|
|
270
|
+
if (typeof config.hooks !== "object") {
|
|
271
|
+
errors.push("hooks property must be an object");
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Validate each hook event
|
|
275
|
+
for (const [eventName, eventConfigs] of Object.entries(config.hooks)) {
|
|
276
|
+
// Validate event name
|
|
277
|
+
if (!isValidHookEvent(eventName)) {
|
|
278
|
+
errors.push(`Invalid hook event: ${eventName}`);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
// Validate event configurations
|
|
282
|
+
if (!Array.isArray(eventConfigs)) {
|
|
283
|
+
errors.push(`Hook event ${eventName} must be an array of configurations`);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
eventConfigs.forEach((eventConfig, index) => {
|
|
287
|
+
const configErrors = this.validateEventConfig(eventName, eventConfig, index);
|
|
288
|
+
errors.push(...configErrors);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
263
292
|
}
|
|
264
|
-
// Validate
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
errors.push(`Invalid hook event: ${eventName}`);
|
|
269
|
-
continue;
|
|
293
|
+
// Validate environment variables if present
|
|
294
|
+
if (config.env) {
|
|
295
|
+
if (typeof config.env !== "object" || Array.isArray(config.env)) {
|
|
296
|
+
errors.push("env property must be an object");
|
|
270
297
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
298
|
+
else {
|
|
299
|
+
for (const [key, value] of Object.entries(config.env)) {
|
|
300
|
+
if (typeof key !== "string" || key.trim() === "") {
|
|
301
|
+
errors.push(`Invalid environment variable key: ${key}`);
|
|
302
|
+
}
|
|
303
|
+
if (typeof value !== "string") {
|
|
304
|
+
errors.push(`Environment variable ${key} must have a string value`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
275
307
|
}
|
|
276
|
-
eventConfigs.forEach((eventConfig, index) => {
|
|
277
|
-
const configErrors = this.validateEventConfig(eventName, eventConfig, index);
|
|
278
|
-
errors.push(...configErrors);
|
|
279
|
-
});
|
|
280
308
|
}
|
|
281
309
|
return {
|
|
282
310
|
valid: errors.length === 0,
|
|
@@ -356,7 +384,10 @@ export class HookManager {
|
|
|
356
384
|
}
|
|
357
385
|
}
|
|
358
386
|
// Validate non-tool events don't have unexpected tool names
|
|
359
|
-
if ((event === "UserPromptSubmit" ||
|
|
387
|
+
if ((event === "UserPromptSubmit" ||
|
|
388
|
+
event === "Stop" ||
|
|
389
|
+
event === "Notification" ||
|
|
390
|
+
event === "SubagentStop") &&
|
|
360
391
|
context.toolName !== undefined) {
|
|
361
392
|
this.logger?.warn(`[HookManager] ${event} event has unexpected toolName in context: ${context.toolName}`);
|
|
362
393
|
}
|
|
@@ -403,7 +434,10 @@ export class HookManager {
|
|
|
403
434
|
*/
|
|
404
435
|
configApplies(config, event, toolName) {
|
|
405
436
|
// For events that don't use matchers, config always applies
|
|
406
|
-
if (event === "UserPromptSubmit" ||
|
|
437
|
+
if (event === "UserPromptSubmit" ||
|
|
438
|
+
event === "Stop" ||
|
|
439
|
+
event === "Notification" ||
|
|
440
|
+
event === "SubagentStop") {
|
|
407
441
|
return true;
|
|
408
442
|
}
|
|
409
443
|
// For tool-based events, check matcher if present
|
|
@@ -437,7 +471,11 @@ export class HookManager {
|
|
|
437
471
|
}
|
|
438
472
|
}
|
|
439
473
|
// Validate that non-tool events don't have matchers
|
|
440
|
-
if ((event === "UserPromptSubmit" ||
|
|
474
|
+
if ((event === "UserPromptSubmit" ||
|
|
475
|
+
event === "Stop" ||
|
|
476
|
+
event === "Notification" ||
|
|
477
|
+
event === "SubagentStop") &&
|
|
478
|
+
config.matcher) {
|
|
441
479
|
errors.push(`${prefix}: Event ${event} should not have a matcher`);
|
|
442
480
|
}
|
|
443
481
|
// Validate commands
|
|
@@ -462,6 +500,8 @@ export class HookManager {
|
|
|
462
500
|
PostToolUse: 0,
|
|
463
501
|
UserPromptSubmit: 0,
|
|
464
502
|
Stop: 0,
|
|
503
|
+
SubagentStop: 0,
|
|
504
|
+
Notification: 0,
|
|
465
505
|
},
|
|
466
506
|
};
|
|
467
507
|
}
|
|
@@ -470,6 +510,8 @@ export class HookManager {
|
|
|
470
510
|
PostToolUse: 0,
|
|
471
511
|
UserPromptSubmit: 0,
|
|
472
512
|
Stop: 0,
|
|
513
|
+
SubagentStop: 0,
|
|
514
|
+
Notification: 0,
|
|
473
515
|
};
|
|
474
516
|
let totalConfigs = 0;
|
|
475
517
|
let totalCommands = 0;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live Configuration Manager
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates live configuration reload functionality including:
|
|
5
|
+
* - Hook configuration watching and reloading
|
|
6
|
+
* - Configuration file watching for settings.json files
|
|
7
|
+
* - Coordination between file watchers and configuration updates
|
|
8
|
+
*/
|
|
9
|
+
import type { Logger } from "../types/index.js";
|
|
10
|
+
import type { HookManager } from "./hookManager.js";
|
|
11
|
+
import type { PermissionManager } from "./permissionManager.js";
|
|
12
|
+
import type { WaveConfiguration } from "../types/hooks.js";
|
|
13
|
+
import { ConfigurationService } from "../services/configurationService.js";
|
|
14
|
+
export interface LiveConfigManagerOptions {
|
|
15
|
+
workdir: string;
|
|
16
|
+
logger?: Logger;
|
|
17
|
+
hookManager?: HookManager;
|
|
18
|
+
permissionManager?: PermissionManager;
|
|
19
|
+
configurationService?: ConfigurationService;
|
|
20
|
+
}
|
|
21
|
+
export declare class LiveConfigManager {
|
|
22
|
+
private readonly workdir;
|
|
23
|
+
private readonly logger?;
|
|
24
|
+
private readonly hookManager?;
|
|
25
|
+
private readonly permissionManager?;
|
|
26
|
+
private isInitialized;
|
|
27
|
+
private readonly configurationService;
|
|
28
|
+
private currentConfiguration;
|
|
29
|
+
private lastValidConfiguration;
|
|
30
|
+
private fileWatcher;
|
|
31
|
+
private userConfigPaths?;
|
|
32
|
+
private projectConfigPaths?;
|
|
33
|
+
private isWatching;
|
|
34
|
+
private reloadInProgress;
|
|
35
|
+
constructor(options: LiveConfigManagerOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Initialize configuration watching
|
|
38
|
+
* Maps to FR-004: System MUST watch settings.json files
|
|
39
|
+
* Supports watching multiple file paths (e.g., settings.local.json and settings.json)
|
|
40
|
+
*/
|
|
41
|
+
private initializeWatching;
|
|
42
|
+
/**
|
|
43
|
+
* Get current configuration
|
|
44
|
+
*/
|
|
45
|
+
getCurrentConfiguration(): WaveConfiguration | null;
|
|
46
|
+
/**
|
|
47
|
+
* Initialize configuration management with file watching
|
|
48
|
+
*/
|
|
49
|
+
initialize(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Shutdown configuration management and cleanup resources
|
|
52
|
+
*/
|
|
53
|
+
shutdown(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Reload configuration from files
|
|
56
|
+
* Maps to FR-008: Continue with previous valid configuration on errors
|
|
57
|
+
*/
|
|
58
|
+
private reloadConfiguration;
|
|
59
|
+
/**
|
|
60
|
+
* Reload configuration from files (public method)
|
|
61
|
+
*/
|
|
62
|
+
reload(): Promise<WaveConfiguration>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if watching is active
|
|
65
|
+
*/
|
|
66
|
+
isWatchingActive(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get watcher status for monitoring
|
|
69
|
+
*/
|
|
70
|
+
getWatcherStatus(): {
|
|
71
|
+
isActive: boolean;
|
|
72
|
+
configurationLoaded: boolean;
|
|
73
|
+
hasValidConfiguration: boolean;
|
|
74
|
+
reloadInProgress: boolean;
|
|
75
|
+
watchedFiles: {
|
|
76
|
+
path: string;
|
|
77
|
+
isActive: boolean;
|
|
78
|
+
method: "native" | "polling" | "failed";
|
|
79
|
+
errorCount: number;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
private setupFileWatcherEvents;
|
|
83
|
+
private handleFileChange;
|
|
84
|
+
/**
|
|
85
|
+
* Validate configuration structure and content
|
|
86
|
+
*/
|
|
87
|
+
private validateConfiguration;
|
|
88
|
+
private detectChanges;
|
|
89
|
+
/**
|
|
90
|
+
* Get configuration file paths for user and project settings
|
|
91
|
+
* Returns paths in priority order (local.json first, then .json)
|
|
92
|
+
*/
|
|
93
|
+
private getConfigurationPaths;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=liveConfigManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveConfigManager.d.ts","sourceRoot":"","sources":["../../src/managers/liveConfigManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAKhE,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAK3E,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAoB;IACvD,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAG5D,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,sBAAsB,CAAkC;IAGhE,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,eAAe,CAAC,CAAW;IACnC,OAAO,CAAC,kBAAkB,CAAC,CAAW;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,gBAAgB,CAAkB;gBAE9B,OAAO,EAAE,wBAAwB;IAW7C;;;;OAIG;YACW,kBAAkB;IA6DhC;;OAEG;IACH,uBAAuB,IAAI,iBAAiB,GAAG,IAAI;IAInD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBjC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB/B;;;OAGG;YACW,mBAAmB;IA8MjC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAK1C;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,gBAAgB;;;;;;;;;;;;IAgBhB,OAAO,CAAC,sBAAsB;YAMhB,gBAAgB;IA8C9B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0E7B,OAAO,CAAC,aAAa;IAuDrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAQ9B"}
|