mcp-agent-foundry 1.3.0 → 2.0.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/README.md +350 -52
- package/dist/background/index.d.ts +33 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +33 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/task-runner.d.ts +177 -0
- package/dist/background/task-runner.d.ts.map +1 -0
- package/dist/background/task-runner.js +551 -0
- package/dist/background/task-runner.js.map +1 -0
- package/dist/background/types.d.ts +135 -0
- package/dist/background/types.d.ts.map +1 -0
- package/dist/background/types.js +8 -0
- package/dist/background/types.js.map +1 -0
- package/dist/failover/health-tracker.d.ts +81 -1
- package/dist/failover/health-tracker.d.ts.map +1 -1
- package/dist/failover/health-tracker.js +229 -1
- package/dist/failover/health-tracker.js.map +1 -1
- package/dist/hooks/hook-executor.d.ts +77 -0
- package/dist/hooks/hook-executor.d.ts.map +1 -0
- package/dist/hooks/hook-executor.js +308 -0
- package/dist/hooks/hook-executor.js.map +1 -0
- package/dist/hooks/hook-manager.d.ts +140 -0
- package/dist/hooks/hook-manager.d.ts.map +1 -0
- package/dist/hooks/hook-manager.js +520 -0
- package/dist/hooks/hook-manager.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +221 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +31 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/auto-mode.d.ts +221 -0
- package/dist/mcp/auto-mode.d.ts.map +1 -0
- package/dist/mcp/auto-mode.js +436 -0
- package/dist/mcp/auto-mode.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +22 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools/tasks/delete-task.d.ts +25 -0
- package/dist/mcp/tools/tasks/delete-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/delete-task.js +148 -0
- package/dist/mcp/tools/tasks/delete-task.js.map +1 -0
- package/dist/mcp/tools/tasks/index.d.ts +2 -0
- package/dist/mcp/tools/tasks/index.d.ts.map +1 -1
- package/dist/mcp/tools/tasks/index.js +6 -0
- package/dist/mcp/tools/tasks/index.js.map +1 -1
- package/dist/observability/debug-logger.d.ts +209 -0
- package/dist/observability/debug-logger.d.ts.map +1 -0
- package/dist/observability/debug-logger.js +430 -0
- package/dist/observability/debug-logger.js.map +1 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +12 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/logger.d.ts +180 -0
- package/dist/observability/logger.d.ts.map +1 -1
- package/dist/observability/logger.js +158 -0
- package/dist/observability/logger.js.map +1 -1
- package/dist/router/context-manager.d.ts +214 -1
- package/dist/router/context-manager.d.ts.map +1 -1
- package/dist/router/context-manager.js +759 -2
- package/dist/router/context-manager.js.map +1 -1
- package/dist/router/context-types.d.ts +182 -0
- package/dist/router/context-types.d.ts.map +1 -0
- package/dist/router/context-types.js +8 -0
- package/dist/router/context-types.js.map +1 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +165 -0
- package/dist/server.js.map +1 -1
- package/dist/skills/hot-reloader.d.ts +104 -0
- package/dist/skills/hot-reloader.d.ts.map +1 -0
- package/dist/skills/hot-reloader.js +314 -0
- package/dist/skills/hot-reloader.js.map +1 -0
- package/dist/skills/index.d.ts +14 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +16 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skill-executor.d.ts +96 -0
- package/dist/skills/skill-executor.d.ts.map +1 -0
- package/dist/skills/skill-executor.js +289 -0
- package/dist/skills/skill-executor.js.map +1 -0
- package/dist/skills/skill-loader.d.ts +147 -0
- package/dist/skills/skill-loader.d.ts.map +1 -0
- package/dist/skills/skill-loader.js +579 -0
- package/dist/skills/skill-loader.js.map +1 -0
- package/dist/skills/types.d.ts +198 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +21 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tasks/coordinator.d.ts +22 -1
- package/dist/tasks/coordinator.d.ts.map +1 -1
- package/dist/tasks/coordinator.js +83 -0
- package/dist/tasks/coordinator.js.map +1 -1
- package/dist/tasks/state-coordinator.d.ts +19 -0
- package/dist/tasks/state-coordinator.d.ts.map +1 -1
- package/dist/tasks/state-coordinator.js +40 -0
- package/dist/tasks/state-coordinator.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes hook commands and parses their output.
|
|
5
|
+
* Handles variable substitution, timeouts, and process management.
|
|
6
|
+
*/
|
|
7
|
+
import type { Logger } from '../observability/logger.js';
|
|
8
|
+
import type { HookDefinition, HookInput, HookVariables, HookExecutionResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Executes hook commands in child processes.
|
|
11
|
+
* Handles variable substitution, timeouts, and output parsing.
|
|
12
|
+
*/
|
|
13
|
+
export declare class HookExecutor {
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly defaultTimeout;
|
|
16
|
+
constructor(logger: Logger, defaultTimeout?: number);
|
|
17
|
+
/**
|
|
18
|
+
* Execute a hook command and parse its output.
|
|
19
|
+
*
|
|
20
|
+
* @param hook - Hook definition to execute
|
|
21
|
+
* @param input - Input data to pass to the hook
|
|
22
|
+
* @returns Hook execution result
|
|
23
|
+
*/
|
|
24
|
+
execute(hook: HookDefinition, input: HookInput): Promise<HookExecutionResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Substitute variables in a command string.
|
|
27
|
+
* Variables use the ${VAR_NAME} syntax.
|
|
28
|
+
*
|
|
29
|
+
* @param command - Command string with variable placeholders
|
|
30
|
+
* @param variables - Variable values to substitute
|
|
31
|
+
* @returns Command with variables substituted
|
|
32
|
+
*/
|
|
33
|
+
substituteVariables(command: string, variables: Partial<HookVariables>): string;
|
|
34
|
+
/**
|
|
35
|
+
* Build environment variables for hook process.
|
|
36
|
+
* Merges current environment with hook-specific env and variables.
|
|
37
|
+
*
|
|
38
|
+
* @param hook - Hook definition
|
|
39
|
+
* @param input - Hook input data
|
|
40
|
+
* @param variables - Computed variable values
|
|
41
|
+
* @returns Environment variables for the process
|
|
42
|
+
*/
|
|
43
|
+
buildEnv(hook: HookDefinition, input: HookInput, variables: Partial<HookVariables>): Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Build variable values from hook input.
|
|
46
|
+
*
|
|
47
|
+
* @param input - Hook input data
|
|
48
|
+
* @returns Variable values for substitution
|
|
49
|
+
*/
|
|
50
|
+
private buildVariables;
|
|
51
|
+
/**
|
|
52
|
+
* Run a shell command with timeout and input handling.
|
|
53
|
+
*
|
|
54
|
+
* @param command - Shell command to execute
|
|
55
|
+
* @param options - Execution options
|
|
56
|
+
* @returns Hook output parsed from stdout
|
|
57
|
+
*/
|
|
58
|
+
private runCommand;
|
|
59
|
+
/**
|
|
60
|
+
* Parse hook output from stdout.
|
|
61
|
+
* Attempts to parse as JSON, falls back to raw output.
|
|
62
|
+
*
|
|
63
|
+
* @param stdout - Raw stdout from the hook
|
|
64
|
+
* @param stderr - Raw stderr from the hook
|
|
65
|
+
* @param exitCode - Process exit code
|
|
66
|
+
* @returns Parsed hook output
|
|
67
|
+
*/
|
|
68
|
+
private parseOutput;
|
|
69
|
+
/**
|
|
70
|
+
* Escape a string for safe use in shell commands.
|
|
71
|
+
*
|
|
72
|
+
* @param value - String to escape
|
|
73
|
+
* @returns Shell-safe string
|
|
74
|
+
*/
|
|
75
|
+
private escapeForShell;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=hook-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-executor.d.ts","sourceRoot":"","sources":["../../src/hooks/hook-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EAET,aAAa,EACb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAoBpB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,MAAM,EAAE,MAAM,EAAE,cAAc,GAAE,MAAa;IAKzD;;;;;;OAMG;IACG,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAsEnF;;;;;;;OAOG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM;IAY/E;;;;;;;;OAQG;IACH,QAAQ,CACN,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA8BzB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;;;OAMG;YACW,UAAU;IAyFxB;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IAiCnB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CASvB"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes hook commands and parses their output.
|
|
5
|
+
* Handles variable substitution, timeouts, and process management.
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Maximum output buffer size in bytes (1MB).
|
|
13
|
+
*/
|
|
14
|
+
const MAX_OUTPUT_SIZE = 1024 * 1024;
|
|
15
|
+
/**
|
|
16
|
+
* Regex pattern for variable substitution: ${VAR_NAME}
|
|
17
|
+
*/
|
|
18
|
+
const VARIABLE_PATTERN = /\$\{([A-Z_][A-Z0-9_]*)\}/g;
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Hook Executor Class
|
|
21
|
+
// ============================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Executes hook commands in child processes.
|
|
24
|
+
* Handles variable substitution, timeouts, and output parsing.
|
|
25
|
+
*/
|
|
26
|
+
export class HookExecutor {
|
|
27
|
+
logger;
|
|
28
|
+
defaultTimeout;
|
|
29
|
+
constructor(logger, defaultTimeout = 5000) {
|
|
30
|
+
this.logger = logger.child({ component: 'HookExecutor' });
|
|
31
|
+
this.defaultTimeout = defaultTimeout;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Execute a hook command and parse its output.
|
|
35
|
+
*
|
|
36
|
+
* @param hook - Hook definition to execute
|
|
37
|
+
* @param input - Input data to pass to the hook
|
|
38
|
+
* @returns Hook execution result
|
|
39
|
+
*/
|
|
40
|
+
async execute(hook, input) {
|
|
41
|
+
const startTime = Date.now();
|
|
42
|
+
// Check if hook is enabled
|
|
43
|
+
if (hook.enabled === false) {
|
|
44
|
+
this.logger.debug('Hook disabled, skipping', { hookName: hook.name });
|
|
45
|
+
return {
|
|
46
|
+
hook,
|
|
47
|
+
success: true,
|
|
48
|
+
output: {},
|
|
49
|
+
durationMs: 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const timeout = hook.timeout_ms ?? this.defaultTimeout;
|
|
53
|
+
const variables = this.buildVariables(input);
|
|
54
|
+
const command = this.substituteVariables(hook.command, variables);
|
|
55
|
+
const env = this.buildEnv(hook, input, variables);
|
|
56
|
+
const cwd = hook.cwd ?? process.cwd();
|
|
57
|
+
this.logger.debug('Executing hook', {
|
|
58
|
+
hookName: hook.name,
|
|
59
|
+
event: input.event,
|
|
60
|
+
command: command.substring(0, 100), // Truncate for logging
|
|
61
|
+
timeout,
|
|
62
|
+
cwd,
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
const output = await this.runCommand(command, {
|
|
66
|
+
cwd,
|
|
67
|
+
env,
|
|
68
|
+
timeout,
|
|
69
|
+
input: JSON.stringify(input),
|
|
70
|
+
});
|
|
71
|
+
const durationMs = Date.now() - startTime;
|
|
72
|
+
this.logger.debug('Hook completed', {
|
|
73
|
+
hookName: hook.name,
|
|
74
|
+
durationMs,
|
|
75
|
+
exitCode: output.exitCode,
|
|
76
|
+
hasOutput: !!output.stdout,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
hook,
|
|
80
|
+
success: output.exitCode === 0,
|
|
81
|
+
output,
|
|
82
|
+
durationMs,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
const durationMs = Date.now() - startTime;
|
|
87
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
88
|
+
this.logger.warn('Hook execution failed', {
|
|
89
|
+
hookName: hook.name,
|
|
90
|
+
durationMs,
|
|
91
|
+
error: errorMessage,
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
hook,
|
|
95
|
+
success: false,
|
|
96
|
+
error: error instanceof Error ? error : new Error(errorMessage),
|
|
97
|
+
durationMs,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Substitute variables in a command string.
|
|
103
|
+
* Variables use the ${VAR_NAME} syntax.
|
|
104
|
+
*
|
|
105
|
+
* @param command - Command string with variable placeholders
|
|
106
|
+
* @param variables - Variable values to substitute
|
|
107
|
+
* @returns Command with variables substituted
|
|
108
|
+
*/
|
|
109
|
+
substituteVariables(command, variables) {
|
|
110
|
+
return command.replace(VARIABLE_PATTERN, (match, varName) => {
|
|
111
|
+
const value = variables[varName];
|
|
112
|
+
if (value !== undefined) {
|
|
113
|
+
// Escape special characters for shell safety
|
|
114
|
+
return this.escapeForShell(value);
|
|
115
|
+
}
|
|
116
|
+
// Leave unmatched variables as-is
|
|
117
|
+
return match;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Build environment variables for hook process.
|
|
122
|
+
* Merges current environment with hook-specific env and variables.
|
|
123
|
+
*
|
|
124
|
+
* @param hook - Hook definition
|
|
125
|
+
* @param input - Hook input data
|
|
126
|
+
* @param variables - Computed variable values
|
|
127
|
+
* @returns Environment variables for the process
|
|
128
|
+
*/
|
|
129
|
+
buildEnv(hook, input, variables) {
|
|
130
|
+
// Start with current environment
|
|
131
|
+
const env = { ...process.env };
|
|
132
|
+
// Add hook variables as environment variables
|
|
133
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
134
|
+
if (value !== undefined) {
|
|
135
|
+
env[`HOOK_${key}`] = value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Add convenience variables
|
|
139
|
+
env['HOOK_EVENT'] = input.event;
|
|
140
|
+
env['HOOK_NAME'] = hook.name;
|
|
141
|
+
if (input.timestamp) {
|
|
142
|
+
env['HOOK_TIMESTAMP'] = input.timestamp.toISOString();
|
|
143
|
+
}
|
|
144
|
+
// Add hook-specific environment variables (highest priority)
|
|
145
|
+
if (hook.env) {
|
|
146
|
+
for (const [key, value] of Object.entries(hook.env)) {
|
|
147
|
+
// Substitute variables in env values too
|
|
148
|
+
env[key] = this.substituteVariables(value, variables);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return env;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Build variable values from hook input.
|
|
155
|
+
*
|
|
156
|
+
* @param input - Hook input data
|
|
157
|
+
* @returns Variable values for substitution
|
|
158
|
+
*/
|
|
159
|
+
buildVariables(input) {
|
|
160
|
+
return {
|
|
161
|
+
CLAUDE_SESSION_ID: input.sessionId ?? '',
|
|
162
|
+
TASK_ID: input.taskId ?? '',
|
|
163
|
+
WORKTREE_PATH: input.worktreePath ?? '',
|
|
164
|
+
TOOL_NAME: input.toolName ?? '',
|
|
165
|
+
PROVIDER: input.provider ?? '',
|
|
166
|
+
MODEL: input.model ?? '',
|
|
167
|
+
ROLE: input.role ?? '',
|
|
168
|
+
ERROR_CODE: input.errorCode?.toString() ?? '',
|
|
169
|
+
ERROR_MESSAGE: input.errorMessage ?? '',
|
|
170
|
+
FROM_PROVIDER: input.fromProvider ?? '',
|
|
171
|
+
TO_PROVIDER: input.toProvider ?? '',
|
|
172
|
+
ATTEMPT_NUMBER: input.attemptNumber?.toString() ?? '',
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Run a shell command with timeout and input handling.
|
|
177
|
+
*
|
|
178
|
+
* @param command - Shell command to execute
|
|
179
|
+
* @param options - Execution options
|
|
180
|
+
* @returns Hook output parsed from stdout
|
|
181
|
+
*/
|
|
182
|
+
async runCommand(command, options) {
|
|
183
|
+
return new Promise((resolve, reject) => {
|
|
184
|
+
let child;
|
|
185
|
+
let killed = false;
|
|
186
|
+
let stdout = '';
|
|
187
|
+
let stderr = '';
|
|
188
|
+
// Spawn shell process
|
|
189
|
+
try {
|
|
190
|
+
child = spawn('/bin/sh', ['-c', command], {
|
|
191
|
+
cwd: options.cwd,
|
|
192
|
+
env: options.env,
|
|
193
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
reject(new Error(`Failed to spawn process: ${error instanceof Error ? error.message : String(error)}`));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Setup timeout
|
|
201
|
+
const timer = setTimeout(() => {
|
|
202
|
+
killed = true;
|
|
203
|
+
child.kill('SIGTERM');
|
|
204
|
+
// Give it a moment to clean up, then force kill
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
if (!child.killed) {
|
|
207
|
+
child.kill('SIGKILL');
|
|
208
|
+
}
|
|
209
|
+
}, 1000);
|
|
210
|
+
reject(new Error(`Hook timed out after ${options.timeout}ms`));
|
|
211
|
+
}, options.timeout);
|
|
212
|
+
// Collect stdout
|
|
213
|
+
if (child.stdout) {
|
|
214
|
+
child.stdout.on('data', (data) => {
|
|
215
|
+
if (stdout.length < MAX_OUTPUT_SIZE) {
|
|
216
|
+
stdout += data.toString();
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// Collect stderr
|
|
221
|
+
if (child.stderr) {
|
|
222
|
+
child.stderr.on('data', (data) => {
|
|
223
|
+
if (stderr.length < MAX_OUTPUT_SIZE) {
|
|
224
|
+
stderr += data.toString();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
// Write input to stdin
|
|
229
|
+
if (options.input && child.stdin) {
|
|
230
|
+
child.stdin.write(options.input);
|
|
231
|
+
child.stdin.end();
|
|
232
|
+
}
|
|
233
|
+
// Handle process exit
|
|
234
|
+
child.on('close', (code) => {
|
|
235
|
+
clearTimeout(timer);
|
|
236
|
+
if (killed) {
|
|
237
|
+
// Already rejected due to timeout
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const exitCode = code ?? 1;
|
|
241
|
+
const output = this.parseOutput(stdout, stderr, exitCode);
|
|
242
|
+
resolve(output);
|
|
243
|
+
});
|
|
244
|
+
// Handle spawn errors
|
|
245
|
+
child.on('error', (error) => {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
if (!killed) {
|
|
248
|
+
reject(error);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Parse hook output from stdout.
|
|
255
|
+
* Attempts to parse as JSON, falls back to raw output.
|
|
256
|
+
*
|
|
257
|
+
* @param stdout - Raw stdout from the hook
|
|
258
|
+
* @param stderr - Raw stderr from the hook
|
|
259
|
+
* @param exitCode - Process exit code
|
|
260
|
+
* @returns Parsed hook output
|
|
261
|
+
*/
|
|
262
|
+
parseOutput(stdout, stderr, exitCode) {
|
|
263
|
+
const trimmedStdout = stdout.trim();
|
|
264
|
+
const trimmedStderr = stderr.trim();
|
|
265
|
+
// Try to parse stdout as JSON
|
|
266
|
+
if (trimmedStdout) {
|
|
267
|
+
try {
|
|
268
|
+
const parsed = JSON.parse(trimmedStdout);
|
|
269
|
+
return {
|
|
270
|
+
...parsed,
|
|
271
|
+
exitCode,
|
|
272
|
+
stdout: trimmedStdout,
|
|
273
|
+
stderr: trimmedStderr || undefined,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// Not JSON, treat as message
|
|
278
|
+
return {
|
|
279
|
+
message: trimmedStdout,
|
|
280
|
+
exitCode,
|
|
281
|
+
stdout: trimmedStdout,
|
|
282
|
+
stderr: trimmedStderr || undefined,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// No stdout, return basic output
|
|
287
|
+
return {
|
|
288
|
+
exitCode,
|
|
289
|
+
stdout: trimmedStdout || undefined,
|
|
290
|
+
stderr: trimmedStderr || undefined,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Escape a string for safe use in shell commands.
|
|
295
|
+
*
|
|
296
|
+
* @param value - String to escape
|
|
297
|
+
* @returns Shell-safe string
|
|
298
|
+
*/
|
|
299
|
+
escapeForShell(value) {
|
|
300
|
+
// For simple alphanumeric strings, no escaping needed
|
|
301
|
+
if (/^[a-zA-Z0-9_\-./]+$/.test(value)) {
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
// Escape single quotes and wrap in single quotes
|
|
305
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=hook-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-executor.js","sourceRoot":"","sources":["../../src/hooks/hook-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AAUzD,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAErD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,OAAO,YAAY;IACN,MAAM,CAAS;IACf,cAAc,CAAS;IAExC,YAAY,MAAc,EAAE,iBAAyB,IAAI;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,IAAoB,EAAE,KAAgB;QAClD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,2BAA2B;QAC3B,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACtE,OAAO;gBACL,IAAI;gBACJ,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,EAAE;gBACV,UAAU,EAAE,CAAC;aACd,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,cAAc,CAAC;QACvD,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,KA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CAAC;QACf,CAAC;QAED,iDAAiD;QACjD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Manager
|
|
3
|
+
*
|
|
4
|
+
* Central manager for hook registration, filtering, and execution.
|
|
5
|
+
* Handles hook lifecycle, session tracking, and event triggering.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import type { Logger } from '../observability/logger.js';
|
|
9
|
+
import type { HooksConfig, HookDefinition, HookEvent, HookInput, HookTriggerResult, HookManagerEvents } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Manages hook registration, filtering, and execution.
|
|
12
|
+
* Provides an event-based API for hook lifecycle notifications.
|
|
13
|
+
*/
|
|
14
|
+
export declare class HookManager extends EventEmitter {
|
|
15
|
+
private readonly logger;
|
|
16
|
+
private readonly executor;
|
|
17
|
+
private config;
|
|
18
|
+
private hooks;
|
|
19
|
+
private runTracker;
|
|
20
|
+
private sessionId;
|
|
21
|
+
private hooksFilePath?;
|
|
22
|
+
private fileWatcher?;
|
|
23
|
+
constructor(config: Partial<HooksConfig> | undefined, logger: Logger);
|
|
24
|
+
/**
|
|
25
|
+
* Check if hooks system is enabled.
|
|
26
|
+
*/
|
|
27
|
+
get isEnabled(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current session ID.
|
|
30
|
+
*/
|
|
31
|
+
getSessionId(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Register hooks from configuration.
|
|
34
|
+
* Validates and indexes hooks by event type.
|
|
35
|
+
*
|
|
36
|
+
* @param hooks - Hook definitions to register
|
|
37
|
+
*/
|
|
38
|
+
registerHooks(hooks: HookDefinition[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Unregister a hook by name.
|
|
41
|
+
*
|
|
42
|
+
* @param name - Name of the hook to unregister
|
|
43
|
+
*/
|
|
44
|
+
unregisterHook(name: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get all hooks registered for an event.
|
|
47
|
+
*
|
|
48
|
+
* @param event - Hook event type
|
|
49
|
+
* @returns Array of hook definitions
|
|
50
|
+
*/
|
|
51
|
+
getHooksForEvent(event: HookEvent): HookDefinition[];
|
|
52
|
+
/**
|
|
53
|
+
* Trigger all hooks for an event.
|
|
54
|
+
* Executes matching hooks in registration order.
|
|
55
|
+
*
|
|
56
|
+
* @param event - Event to trigger
|
|
57
|
+
* @param input - Input data (without event and timestamp)
|
|
58
|
+
* @returns Combined result from all hooks
|
|
59
|
+
*/
|
|
60
|
+
trigger(event: HookEvent, input: Omit<HookInput, 'event' | 'timestamp'>): Promise<HookTriggerResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Check if a hook should run based on filters and run tracking.
|
|
63
|
+
*
|
|
64
|
+
* @param hook - Hook definition to check
|
|
65
|
+
* @param input - Hook input data
|
|
66
|
+
* @returns True if hook should run
|
|
67
|
+
*/
|
|
68
|
+
shouldRun(hook: HookDefinition, input: HookInput): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Mark a hook as having run (for once: true hooks).
|
|
71
|
+
*
|
|
72
|
+
* @param hookName - Name of the hook
|
|
73
|
+
*/
|
|
74
|
+
markRun(hookName: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a hook has already run this session.
|
|
77
|
+
*
|
|
78
|
+
* @param hookName - Name of the hook
|
|
79
|
+
* @returns True if hook has run
|
|
80
|
+
*/
|
|
81
|
+
hasRun(hookName: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Reset run tracking (for new session).
|
|
84
|
+
*/
|
|
85
|
+
resetSession(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Load hooks from an external file.
|
|
88
|
+
*
|
|
89
|
+
* @param path - Path to hooks configuration file (JSON or YAML)
|
|
90
|
+
*/
|
|
91
|
+
loadFromFile(path: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Start watching hooks file for changes.
|
|
94
|
+
* Automatically reloads hooks when file changes.
|
|
95
|
+
*/
|
|
96
|
+
watchFile(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Stop watching hooks file.
|
|
99
|
+
*/
|
|
100
|
+
stopWatching(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Hot-reload hooks from file.
|
|
103
|
+
*/
|
|
104
|
+
reload(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Update configuration.
|
|
107
|
+
*
|
|
108
|
+
* @param config - New configuration (partial)
|
|
109
|
+
*/
|
|
110
|
+
updateConfig(config: Partial<HooksConfig>): void;
|
|
111
|
+
/**
|
|
112
|
+
* Get current configuration.
|
|
113
|
+
*/
|
|
114
|
+
getConfig(): HooksConfig;
|
|
115
|
+
/**
|
|
116
|
+
* Shutdown hook manager and cleanup resources.
|
|
117
|
+
*/
|
|
118
|
+
shutdown(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Generate a unique session ID.
|
|
121
|
+
*/
|
|
122
|
+
private generateSessionId;
|
|
123
|
+
/**
|
|
124
|
+
* Parse hooks file content (JSON).
|
|
125
|
+
*/
|
|
126
|
+
private parseHooksFile;
|
|
127
|
+
/**
|
|
128
|
+
* Match a string against a pattern (supports * wildcard).
|
|
129
|
+
*/
|
|
130
|
+
private matchesPattern;
|
|
131
|
+
/**
|
|
132
|
+
* Merge two hook outputs, with later values taking precedence.
|
|
133
|
+
*/
|
|
134
|
+
private mergeOutputs;
|
|
135
|
+
}
|
|
136
|
+
export interface HookManager {
|
|
137
|
+
on<K extends keyof HookManagerEvents>(event: K, listener: (payload: HookManagerEvents[K]) => void): this;
|
|
138
|
+
emit<K extends keyof HookManagerEvents>(event: K, payload: HookManagerEvents[K]): boolean;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=hook-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-manager.d.ts","sourceRoot":"","sources":["../../src/hooks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