@denizokcu/haze 0.8.0 → 0.9.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/CHANGELOG.md +11 -1
- package/README.md +15 -13
- package/dist/cli/chat/sessionRecorder.d.ts +3 -0
- package/dist/cli/chat/sessionRecorder.js +23 -8
- package/dist/cli/commands/chat.js +90 -104
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +1 -1
- package/dist/cli/commands/formatters.js +3 -3
- package/dist/cli/commands/logsCommand.js +7 -21
- package/dist/cli/commands/mcpWizard.js +24 -2
- package/dist/cli/commands/providerWizard.js +18 -5
- package/dist/cli/commands/runCommand.js +7 -15
- package/dist/cli/commands/settingsSummary.js +3 -1
- package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
- package/dist/cli/commands/streaming/turnOutcome.js +13 -0
- package/dist/cli/commands/streaming.js +66 -29
- package/dist/cli/commands/wizardPrompts.js +1 -1
- package/dist/cli/commands/wizardSuggestions.js +2 -1
- package/dist/cli/commands/wizardTransition.d.ts +33 -0
- package/dist/cli/commands/wizardTransition.js +44 -0
- package/dist/config/contextFiles.js +6 -3
- package/dist/config/endpointSecurity.d.ts +2 -0
- package/dist/config/endpointSecurity.js +28 -0
- package/dist/config/inputHistory.js +4 -2
- package/dist/config/privateStorage.d.ts +6 -0
- package/dist/config/privateStorage.js +61 -0
- package/dist/config/settings.js +4 -4
- package/dist/config/updateCheck.js +4 -2
- package/dist/core/agent/toolOutputStore.d.ts +3 -0
- package/dist/core/agent/toolOutputStore.js +32 -11
- package/dist/core/goal/completionPolicy.d.ts +0 -28
- package/dist/core/goal/completionPolicy.js +0 -88
- package/dist/core/io/boundedRead.d.ts +15 -0
- package/dist/core/io/boundedRead.js +97 -0
- package/dist/core/limits/byteBudgets.d.ts +13 -0
- package/dist/core/limits/byteBudgets.js +13 -0
- package/dist/core/log/llmLog.d.ts +10 -0
- package/dist/core/log/llmLog.js +59 -13
- package/dist/core/persistence/orderedFileWriter.d.ts +11 -0
- package/dist/core/persistence/orderedFileWriter.js +29 -0
- package/dist/core/process/runBoundedProcess.d.ts +27 -0
- package/dist/core/process/runBoundedProcess.js +80 -0
- package/dist/core/session/sessionStore.js +48 -25
- package/dist/core/subagent/subagentRunner.js +1 -1
- package/dist/llm/client.js +4 -1
- package/dist/llm/hazeTools.d.ts +410 -16
- package/dist/llm/hazeTools.js +36 -32
- package/dist/llm/lsp.d.ts +21 -3
- package/dist/llm/lsp.js +55 -13
- package/dist/llm/lspTools.d.ts +96 -48
- package/dist/llm/mcp.d.ts +1 -1
- package/dist/llm/mcp.js +65 -16
- package/dist/llm/requestContext.d.ts +1 -0
- package/dist/llm/requestContext.js +6 -3
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +368 -16
- package/dist/llm/tools/bashTool.js +19 -57
- package/dist/llm/tools/grepRunner.d.ts +15 -0
- package/dist/llm/tools/grepRunner.js +85 -0
- package/dist/skills/SkillLoader.js +17 -5
- package/dist/skills/SkillRegistry.js +19 -6
- package/dist/skills/types.d.ts +5 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +9 -4
- package/package.json +1 -1
|
@@ -29,13 +29,16 @@ export async function assembleRequestContext(input) {
|
|
|
29
29
|
if (hasInstalledLsp)
|
|
30
30
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'lsp', tools: lspTools } });
|
|
31
31
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'subagent', tools: { subagent: createSubagentTool({ model: input.model, contextFiles: input.contextFiles, session: input.session }) } } });
|
|
32
|
-
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'skill', tools: buildSkillTools({ skills: enabledSkills }) } });
|
|
32
|
+
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'skill', tools: buildSkillTools({ skills: enabledSkills, errors: skillRegistry.errors ?? [] }) } });
|
|
33
33
|
const mcpServers = configuredMcpServers(settings).filter(server => server.enabled !== false);
|
|
34
|
-
const loadedMcp = mcpServers.length > 0
|
|
34
|
+
const loadedMcp = mcpServers.length > 0
|
|
35
|
+
? await loadMcpTools(mcpServers, new Set(Object.keys(availableTools)), ...(input.abortSignal ? [input.abortSignal] : []))
|
|
36
|
+
: undefined;
|
|
35
37
|
if (loadedMcp && Object.keys(loadedMcp.tools).length > 0) {
|
|
36
38
|
addCapabilityTools({ availableTools, toolCategories, loaded: { category: 'mcp', tools: loadedMcp.tools }, skipCollisions: true });
|
|
37
39
|
}
|
|
38
40
|
const mcpAvailable = Boolean(loadedMcp && Object.keys(loadedMcp.tools).length > 0);
|
|
39
|
-
const
|
|
41
|
+
const skillErrors = (skillRegistry.errors ?? []).map(error => `${error.directory}: ${error.message}`);
|
|
42
|
+
const systemPrompt = `${buildSystemPrompt(input.contextFiles, input.session, { lspAvailable: hasInstalledLsp, mcpAvailable })}${skillErrors.length ? `\n\n<skill-load-errors>\nInvalid skills were isolated:\n${skillErrors.map(error => `- ${error}`).join('\n')}\n</skill-load-errors>` : ''}`;
|
|
40
43
|
return { systemPrompt, availableTools, toolCategories, loadedMcp };
|
|
41
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'existing_file_requires_overwrite' | 'invalid_line_range' | 'io_error' | 'blocked_url' | 'scoped_instructions_discovered';
|
|
1
|
+
export type ToolFailureReasonCode = 'old_text_missing' | 'old_text_not_unique' | 'overlapping_edits' | 'ignored_path' | 'existing_file_requires_overwrite' | 'invalid_line_range' | 'io_error' | 'file_too_large' | 'blocked_url' | 'scoped_instructions_discovered';
|
|
2
2
|
export type ToolDiffLine = {
|
|
3
3
|
type: 'add' | 'remove' | 'context';
|
|
4
4
|
oldLine?: number;
|
|
@@ -31,15 +31,81 @@ export declare const bashTool: ({
|
|
|
31
31
|
allowMutation: boolean;
|
|
32
32
|
timeoutSeconds?: number | undefined;
|
|
33
33
|
};
|
|
34
|
-
output:
|
|
34
|
+
output: NoInfer<{
|
|
35
|
+
ok: true;
|
|
36
|
+
duplicateSkipped: true;
|
|
37
|
+
toolName: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
} | {
|
|
40
|
+
error?: string | undefined;
|
|
41
|
+
ok: boolean;
|
|
42
|
+
code: number | null;
|
|
43
|
+
command: string;
|
|
44
|
+
cwd: string;
|
|
45
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
46
|
+
durationMs: number;
|
|
47
|
+
timedOut: boolean;
|
|
48
|
+
aborted: boolean;
|
|
49
|
+
signal: NodeJS.Signals | null;
|
|
50
|
+
forcedTermination: boolean;
|
|
51
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
52
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
53
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
54
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
55
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
56
|
+
}>;
|
|
35
57
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
36
58
|
} & {
|
|
37
|
-
outputSchema?: import("ai").FlexibleSchema<
|
|
59
|
+
outputSchema?: import("ai").FlexibleSchema<{
|
|
60
|
+
ok: true;
|
|
61
|
+
duplicateSkipped: true;
|
|
62
|
+
toolName: string;
|
|
63
|
+
reason: string;
|
|
64
|
+
} | {
|
|
65
|
+
error?: string | undefined;
|
|
66
|
+
ok: boolean;
|
|
67
|
+
code: number | null;
|
|
68
|
+
command: string;
|
|
69
|
+
cwd: string;
|
|
70
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
71
|
+
durationMs: number;
|
|
72
|
+
timedOut: boolean;
|
|
73
|
+
aborted: boolean;
|
|
74
|
+
signal: NodeJS.Signals | null;
|
|
75
|
+
forcedTermination: boolean;
|
|
76
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
77
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
78
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
79
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
80
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
81
|
+
}> | undefined;
|
|
38
82
|
execute: import("ai").ToolExecuteFunction<{
|
|
39
83
|
command: string;
|
|
40
84
|
allowMutation: boolean;
|
|
41
85
|
timeoutSeconds?: number | undefined;
|
|
42
|
-
},
|
|
86
|
+
}, {
|
|
87
|
+
ok: true;
|
|
88
|
+
duplicateSkipped: true;
|
|
89
|
+
toolName: string;
|
|
90
|
+
reason: string;
|
|
91
|
+
} | {
|
|
92
|
+
error?: string | undefined;
|
|
93
|
+
ok: boolean;
|
|
94
|
+
code: number | null;
|
|
95
|
+
command: string;
|
|
96
|
+
cwd: string;
|
|
97
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
98
|
+
durationMs: number;
|
|
99
|
+
timedOut: boolean;
|
|
100
|
+
aborted: boolean;
|
|
101
|
+
signal: NodeJS.Signals | null;
|
|
102
|
+
forcedTermination: boolean;
|
|
103
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
104
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
105
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
106
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
107
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
108
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
43
109
|
} & {
|
|
44
110
|
description?: string | ((options: {
|
|
45
111
|
context: NoInfer<import("./toolContext.js").HazeToolContext>;
|
|
@@ -64,7 +130,29 @@ export declare const bashTool: ({
|
|
|
64
130
|
command: string;
|
|
65
131
|
allowMutation: boolean;
|
|
66
132
|
timeoutSeconds?: number | undefined;
|
|
67
|
-
},
|
|
133
|
+
}, {
|
|
134
|
+
ok: true;
|
|
135
|
+
duplicateSkipped: true;
|
|
136
|
+
toolName: string;
|
|
137
|
+
reason: string;
|
|
138
|
+
} | {
|
|
139
|
+
error?: string | undefined;
|
|
140
|
+
ok: boolean;
|
|
141
|
+
code: number | null;
|
|
142
|
+
command: string;
|
|
143
|
+
cwd: string;
|
|
144
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
145
|
+
durationMs: number;
|
|
146
|
+
timedOut: boolean;
|
|
147
|
+
aborted: boolean;
|
|
148
|
+
signal: NodeJS.Signals | null;
|
|
149
|
+
forcedTermination: boolean;
|
|
150
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
151
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
152
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
153
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
154
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
155
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
68
156
|
}) | ({
|
|
69
157
|
title?: string;
|
|
70
158
|
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
@@ -98,15 +186,81 @@ export declare const bashTool: ({
|
|
|
98
186
|
allowMutation: boolean;
|
|
99
187
|
timeoutSeconds?: number | undefined;
|
|
100
188
|
};
|
|
101
|
-
output:
|
|
189
|
+
output: NoInfer<{
|
|
190
|
+
ok: true;
|
|
191
|
+
duplicateSkipped: true;
|
|
192
|
+
toolName: string;
|
|
193
|
+
reason: string;
|
|
194
|
+
} | {
|
|
195
|
+
error?: string | undefined;
|
|
196
|
+
ok: boolean;
|
|
197
|
+
code: number | null;
|
|
198
|
+
command: string;
|
|
199
|
+
cwd: string;
|
|
200
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
201
|
+
durationMs: number;
|
|
202
|
+
timedOut: boolean;
|
|
203
|
+
aborted: boolean;
|
|
204
|
+
signal: NodeJS.Signals | null;
|
|
205
|
+
forcedTermination: boolean;
|
|
206
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
207
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
208
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
209
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
210
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
211
|
+
}>;
|
|
102
212
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
103
213
|
} & {
|
|
104
|
-
outputSchema?: import("ai").FlexibleSchema<
|
|
214
|
+
outputSchema?: import("ai").FlexibleSchema<{
|
|
215
|
+
ok: true;
|
|
216
|
+
duplicateSkipped: true;
|
|
217
|
+
toolName: string;
|
|
218
|
+
reason: string;
|
|
219
|
+
} | {
|
|
220
|
+
error?: string | undefined;
|
|
221
|
+
ok: boolean;
|
|
222
|
+
code: number | null;
|
|
223
|
+
command: string;
|
|
224
|
+
cwd: string;
|
|
225
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
226
|
+
durationMs: number;
|
|
227
|
+
timedOut: boolean;
|
|
228
|
+
aborted: boolean;
|
|
229
|
+
signal: NodeJS.Signals | null;
|
|
230
|
+
forcedTermination: boolean;
|
|
231
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
232
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
233
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
234
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
235
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
236
|
+
}> | undefined;
|
|
105
237
|
execute: import("ai").ToolExecuteFunction<{
|
|
106
238
|
command: string;
|
|
107
239
|
allowMutation: boolean;
|
|
108
240
|
timeoutSeconds?: number | undefined;
|
|
109
|
-
},
|
|
241
|
+
}, {
|
|
242
|
+
ok: true;
|
|
243
|
+
duplicateSkipped: true;
|
|
244
|
+
toolName: string;
|
|
245
|
+
reason: string;
|
|
246
|
+
} | {
|
|
247
|
+
error?: string | undefined;
|
|
248
|
+
ok: boolean;
|
|
249
|
+
code: number | null;
|
|
250
|
+
command: string;
|
|
251
|
+
cwd: string;
|
|
252
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
253
|
+
durationMs: number;
|
|
254
|
+
timedOut: boolean;
|
|
255
|
+
aborted: boolean;
|
|
256
|
+
signal: NodeJS.Signals | null;
|
|
257
|
+
forcedTermination: boolean;
|
|
258
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
259
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
260
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
261
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
262
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
263
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
110
264
|
} & {
|
|
111
265
|
description?: string | ((options: {
|
|
112
266
|
context: NoInfer<import("./toolContext.js").HazeToolContext>;
|
|
@@ -131,7 +285,29 @@ export declare const bashTool: ({
|
|
|
131
285
|
command: string;
|
|
132
286
|
allowMutation: boolean;
|
|
133
287
|
timeoutSeconds?: number | undefined;
|
|
134
|
-
},
|
|
288
|
+
}, {
|
|
289
|
+
ok: true;
|
|
290
|
+
duplicateSkipped: true;
|
|
291
|
+
toolName: string;
|
|
292
|
+
reason: string;
|
|
293
|
+
} | {
|
|
294
|
+
error?: string | undefined;
|
|
295
|
+
ok: boolean;
|
|
296
|
+
code: number | null;
|
|
297
|
+
command: string;
|
|
298
|
+
cwd: string;
|
|
299
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
300
|
+
durationMs: number;
|
|
301
|
+
timedOut: boolean;
|
|
302
|
+
aborted: boolean;
|
|
303
|
+
signal: NodeJS.Signals | null;
|
|
304
|
+
forcedTermination: boolean;
|
|
305
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
306
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
307
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
308
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
309
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
310
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
135
311
|
}) | ({
|
|
136
312
|
title?: string;
|
|
137
313
|
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
@@ -165,15 +341,81 @@ export declare const bashTool: ({
|
|
|
165
341
|
allowMutation: boolean;
|
|
166
342
|
timeoutSeconds?: number | undefined;
|
|
167
343
|
};
|
|
168
|
-
output:
|
|
344
|
+
output: NoInfer<{
|
|
345
|
+
ok: true;
|
|
346
|
+
duplicateSkipped: true;
|
|
347
|
+
toolName: string;
|
|
348
|
+
reason: string;
|
|
349
|
+
} | {
|
|
350
|
+
error?: string | undefined;
|
|
351
|
+
ok: boolean;
|
|
352
|
+
code: number | null;
|
|
353
|
+
command: string;
|
|
354
|
+
cwd: string;
|
|
355
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
356
|
+
durationMs: number;
|
|
357
|
+
timedOut: boolean;
|
|
358
|
+
aborted: boolean;
|
|
359
|
+
signal: NodeJS.Signals | null;
|
|
360
|
+
forcedTermination: boolean;
|
|
361
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
362
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
363
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
364
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
365
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
366
|
+
}>;
|
|
169
367
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
170
368
|
} & {
|
|
171
|
-
outputSchema?: import("ai").FlexibleSchema<
|
|
369
|
+
outputSchema?: import("ai").FlexibleSchema<{
|
|
370
|
+
ok: true;
|
|
371
|
+
duplicateSkipped: true;
|
|
372
|
+
toolName: string;
|
|
373
|
+
reason: string;
|
|
374
|
+
} | {
|
|
375
|
+
error?: string | undefined;
|
|
376
|
+
ok: boolean;
|
|
377
|
+
code: number | null;
|
|
378
|
+
command: string;
|
|
379
|
+
cwd: string;
|
|
380
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
381
|
+
durationMs: number;
|
|
382
|
+
timedOut: boolean;
|
|
383
|
+
aborted: boolean;
|
|
384
|
+
signal: NodeJS.Signals | null;
|
|
385
|
+
forcedTermination: boolean;
|
|
386
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
387
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
388
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
389
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
390
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
391
|
+
}> | undefined;
|
|
172
392
|
execute: import("ai").ToolExecuteFunction<{
|
|
173
393
|
command: string;
|
|
174
394
|
allowMutation: boolean;
|
|
175
395
|
timeoutSeconds?: number | undefined;
|
|
176
|
-
},
|
|
396
|
+
}, {
|
|
397
|
+
ok: true;
|
|
398
|
+
duplicateSkipped: true;
|
|
399
|
+
toolName: string;
|
|
400
|
+
reason: string;
|
|
401
|
+
} | {
|
|
402
|
+
error?: string | undefined;
|
|
403
|
+
ok: boolean;
|
|
404
|
+
code: number | null;
|
|
405
|
+
command: string;
|
|
406
|
+
cwd: string;
|
|
407
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
408
|
+
durationMs: number;
|
|
409
|
+
timedOut: boolean;
|
|
410
|
+
aborted: boolean;
|
|
411
|
+
signal: NodeJS.Signals | null;
|
|
412
|
+
forcedTermination: boolean;
|
|
413
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
414
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
415
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
416
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
417
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
418
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
177
419
|
} & {
|
|
178
420
|
type: "provider";
|
|
179
421
|
id: `${string}.${string}`;
|
|
@@ -189,7 +431,29 @@ export declare const bashTool: ({
|
|
|
189
431
|
command: string;
|
|
190
432
|
allowMutation: boolean;
|
|
191
433
|
timeoutSeconds?: number | undefined;
|
|
192
|
-
},
|
|
434
|
+
}, {
|
|
435
|
+
ok: true;
|
|
436
|
+
duplicateSkipped: true;
|
|
437
|
+
toolName: string;
|
|
438
|
+
reason: string;
|
|
439
|
+
} | {
|
|
440
|
+
error?: string | undefined;
|
|
441
|
+
ok: boolean;
|
|
442
|
+
code: number | null;
|
|
443
|
+
command: string;
|
|
444
|
+
cwd: string;
|
|
445
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
446
|
+
durationMs: number;
|
|
447
|
+
timedOut: boolean;
|
|
448
|
+
aborted: boolean;
|
|
449
|
+
signal: NodeJS.Signals | null;
|
|
450
|
+
forcedTermination: boolean;
|
|
451
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
452
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
453
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
454
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
455
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
456
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
193
457
|
}) | ({
|
|
194
458
|
title?: string;
|
|
195
459
|
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
@@ -223,15 +487,81 @@ export declare const bashTool: ({
|
|
|
223
487
|
allowMutation: boolean;
|
|
224
488
|
timeoutSeconds?: number | undefined;
|
|
225
489
|
};
|
|
226
|
-
output:
|
|
490
|
+
output: NoInfer<{
|
|
491
|
+
ok: true;
|
|
492
|
+
duplicateSkipped: true;
|
|
493
|
+
toolName: string;
|
|
494
|
+
reason: string;
|
|
495
|
+
} | {
|
|
496
|
+
error?: string | undefined;
|
|
497
|
+
ok: boolean;
|
|
498
|
+
code: number | null;
|
|
499
|
+
command: string;
|
|
500
|
+
cwd: string;
|
|
501
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
502
|
+
durationMs: number;
|
|
503
|
+
timedOut: boolean;
|
|
504
|
+
aborted: boolean;
|
|
505
|
+
signal: NodeJS.Signals | null;
|
|
506
|
+
forcedTermination: boolean;
|
|
507
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
508
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
509
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
510
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
511
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
512
|
+
}>;
|
|
227
513
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
228
514
|
} & {
|
|
229
|
-
outputSchema?: import("ai").FlexibleSchema<
|
|
515
|
+
outputSchema?: import("ai").FlexibleSchema<{
|
|
516
|
+
ok: true;
|
|
517
|
+
duplicateSkipped: true;
|
|
518
|
+
toolName: string;
|
|
519
|
+
reason: string;
|
|
520
|
+
} | {
|
|
521
|
+
error?: string | undefined;
|
|
522
|
+
ok: boolean;
|
|
523
|
+
code: number | null;
|
|
524
|
+
command: string;
|
|
525
|
+
cwd: string;
|
|
526
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
527
|
+
durationMs: number;
|
|
528
|
+
timedOut: boolean;
|
|
529
|
+
aborted: boolean;
|
|
530
|
+
signal: NodeJS.Signals | null;
|
|
531
|
+
forcedTermination: boolean;
|
|
532
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
533
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
534
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
535
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
536
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
537
|
+
}> | undefined;
|
|
230
538
|
execute: import("ai").ToolExecuteFunction<{
|
|
231
539
|
command: string;
|
|
232
540
|
allowMutation: boolean;
|
|
233
541
|
timeoutSeconds?: number | undefined;
|
|
234
|
-
},
|
|
542
|
+
}, {
|
|
543
|
+
ok: true;
|
|
544
|
+
duplicateSkipped: true;
|
|
545
|
+
toolName: string;
|
|
546
|
+
reason: string;
|
|
547
|
+
} | {
|
|
548
|
+
error?: string | undefined;
|
|
549
|
+
ok: boolean;
|
|
550
|
+
code: number | null;
|
|
551
|
+
command: string;
|
|
552
|
+
cwd: string;
|
|
553
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
554
|
+
durationMs: number;
|
|
555
|
+
timedOut: boolean;
|
|
556
|
+
aborted: boolean;
|
|
557
|
+
signal: NodeJS.Signals | null;
|
|
558
|
+
forcedTermination: boolean;
|
|
559
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
560
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
561
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
562
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
563
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
564
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
235
565
|
} & {
|
|
236
566
|
type: "provider";
|
|
237
567
|
id: `${string}.${string}`;
|
|
@@ -247,5 +577,27 @@ export declare const bashTool: ({
|
|
|
247
577
|
command: string;
|
|
248
578
|
allowMutation: boolean;
|
|
249
579
|
timeoutSeconds?: number | undefined;
|
|
250
|
-
},
|
|
580
|
+
}, {
|
|
581
|
+
ok: true;
|
|
582
|
+
duplicateSkipped: true;
|
|
583
|
+
toolName: string;
|
|
584
|
+
reason: string;
|
|
585
|
+
} | {
|
|
586
|
+
error?: string | undefined;
|
|
587
|
+
ok: boolean;
|
|
588
|
+
code: number | null;
|
|
589
|
+
command: string;
|
|
590
|
+
cwd: string;
|
|
591
|
+
classification: import("../../core/safety/bashClassifier.js").BashClassification;
|
|
592
|
+
durationMs: number;
|
|
593
|
+
timedOut: boolean;
|
|
594
|
+
aborted: boolean;
|
|
595
|
+
signal: NodeJS.Signals | null;
|
|
596
|
+
forcedTermination: boolean;
|
|
597
|
+
stdout: import("../../core/bashOutput/types.js").StreamReduction;
|
|
598
|
+
stderr: import("../../core/bashOutput/types.js").StreamReduction;
|
|
599
|
+
validationSummary: import("../toolResultTypes.js").ValidationSummary | undefined;
|
|
600
|
+
stdoutBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
601
|
+
stderrBytes: import("../../core/process/runBoundedProcess.js").BoundedStream;
|
|
602
|
+
}, NoInfer<import("./toolContext.js").HazeToolContext>>;
|
|
251
603
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import { tool } from 'ai';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
import { classifyBashCommand, isValidationClassification } from '../../core/safety/bashClassifier.js';
|
|
@@ -8,6 +7,8 @@ import { storeToolOutput } from '../../core/agent/toolOutputStore.js';
|
|
|
8
7
|
import { workspaceRoot } from '../../utils/path.js';
|
|
9
8
|
import { compactStoredOutput, COMPACT_COMMAND_CHARS } from './outputCap.js';
|
|
10
9
|
import { hazeToolContextSchema, runDedupedTool } from './toolContext.js';
|
|
10
|
+
import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
|
|
11
|
+
import { BASH_STREAM_BYTES } from '../../core/limits/byteBudgets.js';
|
|
11
12
|
const SHORT_VALIDATION_CHARS = 2_000;
|
|
12
13
|
export const bashTool = tool({
|
|
13
14
|
description: 'Run workspace tests, builds, validation, or inspection. Risk classification is informational; use file tools for edits.',
|
|
@@ -22,61 +23,22 @@ export const bashTool = tool({
|
|
|
22
23
|
const classification = classifyBashCommand(command);
|
|
23
24
|
const timeoutMs = (timeoutSeconds ?? 60) * 1000;
|
|
24
25
|
const startedAt = Date.now();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
settled = true;
|
|
43
|
-
clearTimeout(timer);
|
|
44
|
-
context.abortSignal?.removeEventListener('abort', abort);
|
|
45
|
-
const validationSummary = isValidationClassification(classification)
|
|
46
|
-
? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: stdout.length > COMPACT_COMMAND_CHARS, stderrTruncated: stderr.length > COMPACT_COMMAND_CHARS, classification })
|
|
47
|
-
: undefined;
|
|
48
|
-
const validationPassed = validationSummary?.status === 'passed';
|
|
49
|
-
const output = filterBashOutput({
|
|
50
|
-
command,
|
|
51
|
-
code,
|
|
52
|
-
stdout,
|
|
53
|
-
stderr,
|
|
54
|
-
timedOut,
|
|
55
|
-
classification,
|
|
56
|
-
validationSummary,
|
|
57
|
-
storeRawOutput: storeToolOutput,
|
|
58
|
-
fallbackCompact: compactStoredOutput,
|
|
59
|
-
compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS,
|
|
60
|
-
});
|
|
61
|
-
resolve({
|
|
62
|
-
ok: code === 0 && !timedOut,
|
|
63
|
-
code,
|
|
64
|
-
command,
|
|
65
|
-
cwd,
|
|
66
|
-
classification,
|
|
67
|
-
durationMs: Date.now() - startedAt,
|
|
68
|
-
timedOut,
|
|
69
|
-
stdout: output.stdout,
|
|
70
|
-
stderr: output.stderr,
|
|
71
|
-
validationSummary,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
child.on('error', error => {
|
|
75
|
-
settled = true;
|
|
76
|
-
clearTimeout(timer);
|
|
77
|
-
context.abortSignal?.removeEventListener('abort', abort);
|
|
78
|
-
resolve({ ok: false, command, cwd, classification, durationMs: Date.now() - startedAt, error: error.message });
|
|
79
|
-
});
|
|
80
|
-
});
|
|
26
|
+
const processResult = await runBoundedProcess({ command: 'bash', args: ['-lc', command], cwd, timeoutMs, signal: context.abortSignal, maxStdoutBytes: BASH_STREAM_BYTES, maxStderrBytes: BASH_STREAM_BYTES });
|
|
27
|
+
const { code, timedOut } = processResult;
|
|
28
|
+
const stdout = processResult.stdout.text;
|
|
29
|
+
const stderr = processResult.stderr.text;
|
|
30
|
+
const validationSummary = isValidationClassification(classification)
|
|
31
|
+
? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: processResult.stdout.omittedBytes > 0, stderrTruncated: processResult.stderr.omittedBytes > 0, classification })
|
|
32
|
+
: undefined;
|
|
33
|
+
const validationPassed = validationSummary?.status === 'passed';
|
|
34
|
+
const output = filterBashOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
|
|
35
|
+
return {
|
|
36
|
+
ok: code === 0 && !timedOut && !processResult.aborted && !processResult.error,
|
|
37
|
+
code, command, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
|
|
38
|
+
aborted: processResult.aborted, signal: processResult.signal, forcedTermination: processResult.forced,
|
|
39
|
+
stdout: output.stdout, stderr: output.stderr, validationSummary,
|
|
40
|
+
stdoutBytes: processResult.stdout, stderrBytes: processResult.stderr,
|
|
41
|
+
...(processResult.error ? { error: processResult.error } : {}),
|
|
42
|
+
};
|
|
81
43
|
}),
|
|
82
44
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function runRipgrepBounded(input: {
|
|
2
|
+
executable: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
cwd: string;
|
|
5
|
+
maxMatches: number;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
stdout: string;
|
|
10
|
+
stderr: string;
|
|
11
|
+
code: number | null;
|
|
12
|
+
capped: boolean;
|
|
13
|
+
timedOut: boolean;
|
|
14
|
+
aborted: boolean;
|
|
15
|
+
}>;
|