@denizokcu/haze 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -17
- package/README.md +121 -64
- package/dist/cli/chat/chatMetrics.d.ts +17 -1
- package/dist/cli/chat/chatMetrics.js +22 -5
- package/dist/cli/chat/contextReport.d.ts +11 -0
- package/dist/cli/chat/contextReport.js +44 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
- package/dist/cli/chat/fileMentionSuggestions.js +91 -0
- package/dist/cli/chat/inputSuggestions.d.ts +5 -0
- package/dist/cli/chat/inputSuggestions.js +17 -3
- package/dist/cli/chat/sessionLifecycle.d.ts +58 -0
- package/dist/cli/chat/sessionLifecycle.js +155 -0
- package/dist/cli/chat/sessionRecorder.d.ts +3 -0
- package/dist/cli/chat/sessionRecorder.js +21 -8
- package/dist/cli/chat/startupInfo.d.ts +1 -0
- package/dist/cli/chat/startupInfo.js +11 -0
- package/dist/cli/chat/tips.d.ts +21 -0
- package/dist/cli/chat/tips.js +43 -0
- package/dist/cli/chat/wizardDispatch.d.ts +64 -0
- package/dist/cli/chat/wizardDispatch.js +645 -0
- package/dist/cli/commands/chat.d.ts +1 -0
- package/dist/cli/commands/chat.js +246 -779
- package/dist/cli/commands/chatModes.d.ts +1 -1
- package/dist/cli/commands/chatModes.js +7 -2
- package/dist/cli/commands/commandHelp.js +5 -3
- package/dist/cli/commands/commands.d.ts +4 -3
- package/dist/cli/commands/commands.js +12 -13
- package/dist/cli/commands/fleetCommand.d.ts +14 -0
- package/dist/cli/commands/fleetCommand.js +46 -0
- package/dist/cli/commands/formatters.d.ts +5 -0
- package/dist/cli/commands/formatters.js +36 -9
- package/dist/cli/commands/logsCommand.js +8 -28
- package/dist/cli/commands/mcpWizard.js +24 -2
- package/dist/cli/commands/modelCommand.js +1 -1
- package/dist/cli/commands/providerWizard.d.ts +1 -0
- package/dist/cli/commands/providerWizard.js +31 -5
- package/dist/cli/commands/runCommand.d.ts +1 -0
- package/dist/cli/commands/runCommand.js +32 -20
- package/dist/cli/commands/sessionPicker.d.ts +9 -0
- package/dist/cli/commands/sessionPicker.js +29 -0
- package/dist/cli/commands/settingsSummary.js +8 -4
- package/dist/cli/commands/skillConfirmRemove.js +4 -3
- package/dist/cli/commands/skillWizard.d.ts +2 -0
- package/dist/cli/commands/skillWizard.js +16 -6
- package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
- package/dist/cli/commands/streaming/idleTimer.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +4 -2
- package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
- package/dist/cli/commands/streaming/turnOutcome.js +13 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -4
- package/dist/cli/commands/streaming.d.ts +13 -1
- package/dist/cli/commands/streaming.js +104 -44
- package/dist/cli/commands/wizardActions.d.ts +6 -0
- package/dist/cli/commands/wizardActions.js +6 -0
- package/dist/cli/commands/wizardPrompts.js +1 -1
- package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
- package/dist/cli/commands/wizardSuggestions.js +62 -13
- package/dist/cli/commands/wizardTransition.d.ts +37 -0
- package/dist/cli/commands/wizardTransition.js +43 -0
- package/dist/cli/index.js +17 -3
- package/dist/cli/terminalTitle.d.ts +6 -0
- package/dist/cli/terminalTitle.js +36 -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.d.ts +3 -3
- package/dist/config/inputHistory.js +13 -17
- package/dist/config/modelDiscovery.d.ts +20 -0
- package/dist/config/modelDiscovery.js +51 -0
- package/dist/config/privateStorage.d.ts +6 -0
- package/dist/config/privateStorage.js +61 -0
- package/dist/config/providerPresets.d.ts +16 -4
- package/dist/config/providerPresets.js +263 -34
- package/dist/config/providers.d.ts +2 -0
- package/dist/config/providers.js +7 -0
- package/dist/config/settings.d.ts +22 -0
- package/dist/config/settings.js +33 -5
- package/dist/config/skillSettings.d.ts +6 -13
- package/dist/config/skillSettings.js +20 -19
- package/dist/config/updateCheck.js +4 -2
- package/dist/core/agent/budgets.d.ts +26 -0
- package/dist/core/agent/budgets.js +34 -0
- package/dist/core/agent/compaction.js +17 -3
- package/dist/core/agent/contextBudget.d.ts +8 -0
- package/dist/core/agent/contextBudget.js +29 -0
- package/dist/core/agent/errors.js +6 -2
- package/dist/core/agent/events.d.ts +12 -0
- package/dist/core/agent/toolOutputStore.d.ts +8 -0
- package/dist/core/agent/toolOutputStore.js +49 -11
- package/dist/core/agent/workState.d.ts +1 -1
- package/dist/core/agent/workState.js +0 -4
- package/dist/core/attachments/imageAttachments.d.ts +90 -0
- package/dist/core/attachments/imageAttachments.js +245 -0
- package/dist/core/attachments/readBlessings.d.ts +37 -0
- package/dist/core/attachments/readBlessings.js +79 -0
- package/dist/core/goal/completionPolicy.d.ts +0 -28
- package/dist/core/goal/completionPolicy.js +0 -88
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -13
- package/dist/core/io/boundedRead.d.ts +15 -0
- package/dist/core/io/boundedRead.js +144 -0
- package/dist/core/limits/byteBudgets.d.ts +18 -0
- package/dist/core/limits/byteBudgets.js +18 -0
- package/dist/core/limits/textBudgets.d.ts +23 -0
- package/dist/core/limits/textBudgets.js +23 -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/backgroundRegistry.d.ts +35 -0
- package/dist/core/process/backgroundRegistry.js +194 -0
- package/dist/core/process/runBoundedProcess.d.ts +30 -0
- package/dist/core/process/runBoundedProcess.js +116 -0
- package/dist/core/safety/urlGuard.d.ts +2 -1
- package/dist/core/safety/urlGuard.js +3 -2
- package/dist/core/session/sessionSlimming.js +47 -4
- package/dist/core/session/sessionStore.d.ts +37 -0
- package/dist/core/session/sessionStore.js +136 -27
- package/dist/core/subagent/contracts.d.ts +116 -0
- package/dist/core/subagent/contracts.js +54 -0
- package/dist/core/subagent/executionProfiles.d.ts +28 -0
- package/dist/core/subagent/executionProfiles.js +45 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +74 -0
- package/dist/core/subagent/subagentCoordinator.js +134 -0
- package/dist/core/subagent/subagentRunner.d.ts +211 -145
- package/dist/core/subagent/subagentRunner.js +228 -98
- package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
- package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
- package/dist/core/tasks/taskStorage.js +12 -1
- package/dist/llm/client.d.ts +20 -29
- package/dist/llm/client.js +33 -29
- package/dist/llm/hazeTools.d.ts +2396 -67
- package/dist/llm/hazeTools.js +50 -37
- package/dist/llm/lsp.d.ts +23 -3
- package/dist/llm/lsp.js +73 -16
- 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 +23 -1
- package/dist/llm/requestContext.js +50 -7
- package/dist/llm/systemPrompt.d.ts +4 -1
- package/dist/llm/systemPrompt.js +14 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +1210 -16
- package/dist/llm/tools/bashTool.js +43 -60
- package/dist/llm/tools/fetchTool.d.ts +26 -26
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +2 -1
- package/dist/llm/tools/fileToolShared.js +5 -5
- package/dist/llm/tools/grepRunner.d.ts +20 -0
- package/dist/llm/tools/grepRunner.js +66 -0
- package/dist/llm/tools/outputCap.d.ts +2 -6
- package/dist/llm/tools/outputCap.js +2 -6
- package/dist/llm/tools/processTool.d.ts +1077 -0
- package/dist/llm/tools/processTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +8 -0
- package/dist/llm/tools/toolContext.js +22 -11
- package/dist/llm/tools/workspaceFile.d.ts +9 -1
- package/dist/llm/tools/workspaceFile.js +33 -4
- package/dist/llm/webFetch.js +24 -11
- package/dist/llm/workerContext.d.ts +18 -0
- package/dist/llm/workerContext.js +55 -0
- package/dist/skills/SkillLoader.d.ts +2 -2
- package/dist/skills/SkillLoader.js +17 -5
- package/dist/skills/SkillRegistry.d.ts +3 -2
- package/dist/skills/SkillRegistry.js +53 -10
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +23 -5
- package/dist/skills/skillTools.js +11 -4
- package/dist/skills/types.d.ts +11 -1
- package/dist/ui/components/TextInput.d.ts +5 -2
- package/dist/ui/components/TextInput.js +76 -8
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/fs.d.ts +0 -1
- package/dist/utils/fs.js +0 -4
- package/dist/utils/openPath.d.ts +2 -0
- package/dist/utils/openPath.js +9 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +9 -4
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -7,8 +6,15 @@ import { filterBashOutput } from '../../core/bashOutput/registry.js';
|
|
|
7
6
|
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
|
-
import { hazeToolContextSchema, runDedupedTool } from './toolContext.js';
|
|
11
|
-
|
|
9
|
+
import { hazeContext, hazeToolContextSchema, runDedupedTool } from './toolContext.js';
|
|
10
|
+
import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
|
|
11
|
+
import { BASH_STREAM_BYTES } from '../../core/limits/byteBudgets.js';
|
|
12
|
+
import { SHORT_VALIDATION_CHARS } from '../../core/limits/textBudgets.js';
|
|
13
|
+
import { startBackgroundProcess } from '../../core/process/backgroundRegistry.js';
|
|
14
|
+
/** Byte-stat metadata only — the raw stream text must never reach the model context (see code-review CR-001). */
|
|
15
|
+
function streamByteStats(stream) {
|
|
16
|
+
return { totalBytes: stream.totalBytes, retainedBytes: stream.retainedBytes, omittedBytes: stream.omittedBytes };
|
|
17
|
+
}
|
|
12
18
|
export const bashTool = tool({
|
|
13
19
|
description: 'Run workspace tests, builds, validation, or inspection. Risk classification is informational; use file tools for edits.',
|
|
14
20
|
contextSchema: hazeToolContextSchema,
|
|
@@ -16,67 +22,44 @@ export const bashTool = tool({
|
|
|
16
22
|
command: z.string().min(1).describe('Command to execute with bash -lc'),
|
|
17
23
|
timeoutSeconds: z.number().int().positive().max(600).optional().describe('Timeout in seconds; defaults to 60'),
|
|
18
24
|
allowMutation: z.boolean().default(false).describe('Deprecated compatibility flag. Commands run without confirmation; retained for compatibility.'),
|
|
25
|
+
background: z.boolean().default(false).describe('Start a registered long-running process and return immediately. Use process to list, inspect output, or kill it.'),
|
|
19
26
|
}),
|
|
20
|
-
execute: async ({ command, timeoutSeconds }, context) => runDedupedTool('bash', { command, timeoutSeconds }, context, async () => {
|
|
27
|
+
execute: async ({ command, timeoutSeconds, background }, context) => runDedupedTool('bash', { command, timeoutSeconds, background }, context, async () => {
|
|
21
28
|
const cwd = workspaceRoot();
|
|
22
29
|
const classification = classifyBashCommand(command);
|
|
30
|
+
if (background) {
|
|
31
|
+
if (hazeContext(context)?.isSubagent) {
|
|
32
|
+
return { ok: false, command, reasonCode: 'background_not_allowed', recoverable: false, error: 'Background processes are available only to the main haze turn, not fleet workers.', suggestedNextStep: 'Run the server from the main conversation.' };
|
|
33
|
+
}
|
|
34
|
+
if (context.abortSignal?.aborted) {
|
|
35
|
+
return { ok: false, command, reasonCode: 'aborted', recoverable: true, error: 'Background process was not started because the turn is already aborted.', suggestedNextStep: 'Retry when the turn is active.' };
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const started = startBackgroundProcess({ command, cwd });
|
|
39
|
+
return { ok: true, background: true, ...started, classification, hint: `Use readToolOutput with handle ${started.outputHandle} for logs, or process action=kill backgroundId=${started.backgroundId} when done.` };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { ok: false, background: true, command, reasonCode: 'background_limit', recoverable: true, error: error instanceof Error ? error.message : String(error), suggestedNextStep: 'List background processes and kill one before retrying.' };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
const timeoutMs = (timeoutSeconds ?? 60) * 1000;
|
|
24
46
|
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
|
-
});
|
|
47
|
+
const processResult = await runBoundedProcess({ command: 'bash', args: ['-lc', command], cwd, timeoutMs, signal: context.abortSignal, maxStdoutBytes: BASH_STREAM_BYTES, maxStderrBytes: BASH_STREAM_BYTES });
|
|
48
|
+
const { code, timedOut } = processResult;
|
|
49
|
+
const stdout = processResult.stdout.text;
|
|
50
|
+
const stderr = processResult.stderr.text;
|
|
51
|
+
const validationSummary = isValidationClassification(classification)
|
|
52
|
+
? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: processResult.stdout.omittedBytes > 0, stderrTruncated: processResult.stderr.omittedBytes > 0, classification })
|
|
53
|
+
: undefined;
|
|
54
|
+
const validationPassed = validationSummary?.status === 'passed';
|
|
55
|
+
const output = filterBashOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
|
|
56
|
+
return {
|
|
57
|
+
ok: code === 0 && !timedOut && !processResult.aborted && !processResult.error,
|
|
58
|
+
code, command, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
|
|
59
|
+
aborted: processResult.aborted, signal: processResult.signal, forcedTermination: processResult.forced,
|
|
60
|
+
stdout: output.stdout, stderr: output.stderr, validationSummary,
|
|
61
|
+
stdoutBytes: streamByteStats(processResult.stdout), stderrBytes: streamByteStats(processResult.stderr),
|
|
62
|
+
...(processResult.error ? { error: processResult.error } : {}),
|
|
63
|
+
};
|
|
81
64
|
}),
|
|
82
65
|
});
|
|
@@ -4,12 +4,12 @@ export declare const fetchTool: ({
|
|
|
4
4
|
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
5
5
|
inputSchema: import("ai").FlexibleSchema<{
|
|
6
6
|
url: string;
|
|
7
|
-
format: "
|
|
7
|
+
format: "text" | "auto";
|
|
8
8
|
}>;
|
|
9
9
|
contextSchema?: import("ai").FlexibleSchema<import("./toolContext.js").HazeToolContext> | undefined;
|
|
10
10
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
11
11
|
url: string;
|
|
12
|
-
format: "
|
|
12
|
+
format: "text" | "auto";
|
|
13
13
|
}, NoInfer<import("./toolContext.js").HazeToolContext>> | undefined;
|
|
14
14
|
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
15
15
|
onInputDelta?: ((options: {
|
|
@@ -18,14 +18,14 @@ export declare const fetchTool: ({
|
|
|
18
18
|
onInputAvailable?: ((options: {
|
|
19
19
|
input: {
|
|
20
20
|
url: string;
|
|
21
|
-
format: "
|
|
21
|
+
format: "text" | "auto";
|
|
22
22
|
};
|
|
23
23
|
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
24
24
|
toModelOutput?: ((options: {
|
|
25
25
|
toolCallId: string;
|
|
26
26
|
input: {
|
|
27
27
|
url: string;
|
|
28
|
-
format: "
|
|
28
|
+
format: "text" | "auto";
|
|
29
29
|
};
|
|
30
30
|
output: NoInfer<{
|
|
31
31
|
ok: boolean;
|
|
@@ -155,7 +155,7 @@ export declare const fetchTool: ({
|
|
|
155
155
|
}> | undefined;
|
|
156
156
|
execute: import("ai").ToolExecuteFunction<{
|
|
157
157
|
url: string;
|
|
158
|
-
format: "
|
|
158
|
+
format: "text" | "auto";
|
|
159
159
|
}, {
|
|
160
160
|
ok: boolean;
|
|
161
161
|
toolName: string;
|
|
@@ -227,7 +227,7 @@ export declare const fetchTool: ({
|
|
|
227
227
|
inputExamples?: {
|
|
228
228
|
input: NoInfer<{
|
|
229
229
|
url: string;
|
|
230
|
-
format: "
|
|
230
|
+
format: "text" | "auto";
|
|
231
231
|
}>;
|
|
232
232
|
}[] | undefined;
|
|
233
233
|
id?: never;
|
|
@@ -239,7 +239,7 @@ export declare const fetchTool: ({
|
|
|
239
239
|
} & {
|
|
240
240
|
execute: import("ai").ToolExecuteFunction<{
|
|
241
241
|
url: string;
|
|
242
|
-
format: "
|
|
242
|
+
format: "text" | "auto";
|
|
243
243
|
}, {
|
|
244
244
|
ok: boolean;
|
|
245
245
|
toolName: string;
|
|
@@ -308,12 +308,12 @@ export declare const fetchTool: ({
|
|
|
308
308
|
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
309
309
|
inputSchema: import("ai").FlexibleSchema<{
|
|
310
310
|
url: string;
|
|
311
|
-
format: "
|
|
311
|
+
format: "text" | "auto";
|
|
312
312
|
}>;
|
|
313
313
|
contextSchema?: import("ai").FlexibleSchema<import("./toolContext.js").HazeToolContext> | undefined;
|
|
314
314
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
315
315
|
url: string;
|
|
316
|
-
format: "
|
|
316
|
+
format: "text" | "auto";
|
|
317
317
|
}, NoInfer<import("./toolContext.js").HazeToolContext>> | undefined;
|
|
318
318
|
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
319
319
|
onInputDelta?: ((options: {
|
|
@@ -322,14 +322,14 @@ export declare const fetchTool: ({
|
|
|
322
322
|
onInputAvailable?: ((options: {
|
|
323
323
|
input: {
|
|
324
324
|
url: string;
|
|
325
|
-
format: "
|
|
325
|
+
format: "text" | "auto";
|
|
326
326
|
};
|
|
327
327
|
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
328
328
|
toModelOutput?: ((options: {
|
|
329
329
|
toolCallId: string;
|
|
330
330
|
input: {
|
|
331
331
|
url: string;
|
|
332
|
-
format: "
|
|
332
|
+
format: "text" | "auto";
|
|
333
333
|
};
|
|
334
334
|
output: NoInfer<{
|
|
335
335
|
ok: boolean;
|
|
@@ -459,7 +459,7 @@ export declare const fetchTool: ({
|
|
|
459
459
|
}> | undefined;
|
|
460
460
|
execute: import("ai").ToolExecuteFunction<{
|
|
461
461
|
url: string;
|
|
462
|
-
format: "
|
|
462
|
+
format: "text" | "auto";
|
|
463
463
|
}, {
|
|
464
464
|
ok: boolean;
|
|
465
465
|
toolName: string;
|
|
@@ -531,7 +531,7 @@ export declare const fetchTool: ({
|
|
|
531
531
|
inputExamples?: {
|
|
532
532
|
input: NoInfer<{
|
|
533
533
|
url: string;
|
|
534
|
-
format: "
|
|
534
|
+
format: "text" | "auto";
|
|
535
535
|
}>;
|
|
536
536
|
}[] | undefined;
|
|
537
537
|
id?: never;
|
|
@@ -543,7 +543,7 @@ export declare const fetchTool: ({
|
|
|
543
543
|
} & {
|
|
544
544
|
execute: import("ai").ToolExecuteFunction<{
|
|
545
545
|
url: string;
|
|
546
|
-
format: "
|
|
546
|
+
format: "text" | "auto";
|
|
547
547
|
}, {
|
|
548
548
|
ok: boolean;
|
|
549
549
|
toolName: string;
|
|
@@ -612,12 +612,12 @@ export declare const fetchTool: ({
|
|
|
612
612
|
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
613
613
|
inputSchema: import("ai").FlexibleSchema<{
|
|
614
614
|
url: string;
|
|
615
|
-
format: "
|
|
615
|
+
format: "text" | "auto";
|
|
616
616
|
}>;
|
|
617
617
|
contextSchema?: import("ai").FlexibleSchema<import("./toolContext.js").HazeToolContext> | undefined;
|
|
618
618
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
619
619
|
url: string;
|
|
620
|
-
format: "
|
|
620
|
+
format: "text" | "auto";
|
|
621
621
|
}, NoInfer<import("./toolContext.js").HazeToolContext>> | undefined;
|
|
622
622
|
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
623
623
|
onInputDelta?: ((options: {
|
|
@@ -626,14 +626,14 @@ export declare const fetchTool: ({
|
|
|
626
626
|
onInputAvailable?: ((options: {
|
|
627
627
|
input: {
|
|
628
628
|
url: string;
|
|
629
|
-
format: "
|
|
629
|
+
format: "text" | "auto";
|
|
630
630
|
};
|
|
631
631
|
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
632
632
|
toModelOutput?: ((options: {
|
|
633
633
|
toolCallId: string;
|
|
634
634
|
input: {
|
|
635
635
|
url: string;
|
|
636
|
-
format: "
|
|
636
|
+
format: "text" | "auto";
|
|
637
637
|
};
|
|
638
638
|
output: NoInfer<{
|
|
639
639
|
ok: boolean;
|
|
@@ -763,7 +763,7 @@ export declare const fetchTool: ({
|
|
|
763
763
|
}> | undefined;
|
|
764
764
|
execute: import("ai").ToolExecuteFunction<{
|
|
765
765
|
url: string;
|
|
766
|
-
format: "
|
|
766
|
+
format: "text" | "auto";
|
|
767
767
|
}, {
|
|
768
768
|
ok: boolean;
|
|
769
769
|
toolName: string;
|
|
@@ -839,7 +839,7 @@ export declare const fetchTool: ({
|
|
|
839
839
|
} & {
|
|
840
840
|
execute: import("ai").ToolExecuteFunction<{
|
|
841
841
|
url: string;
|
|
842
|
-
format: "
|
|
842
|
+
format: "text" | "auto";
|
|
843
843
|
}, {
|
|
844
844
|
ok: boolean;
|
|
845
845
|
toolName: string;
|
|
@@ -908,12 +908,12 @@ export declare const fetchTool: ({
|
|
|
908
908
|
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
909
909
|
inputSchema: import("ai").FlexibleSchema<{
|
|
910
910
|
url: string;
|
|
911
|
-
format: "
|
|
911
|
+
format: "text" | "auto";
|
|
912
912
|
}>;
|
|
913
913
|
contextSchema?: import("ai").FlexibleSchema<import("./toolContext.js").HazeToolContext> | undefined;
|
|
914
914
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
915
915
|
url: string;
|
|
916
|
-
format: "
|
|
916
|
+
format: "text" | "auto";
|
|
917
917
|
}, NoInfer<import("./toolContext.js").HazeToolContext>> | undefined;
|
|
918
918
|
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
919
919
|
onInputDelta?: ((options: {
|
|
@@ -922,14 +922,14 @@ export declare const fetchTool: ({
|
|
|
922
922
|
onInputAvailable?: ((options: {
|
|
923
923
|
input: {
|
|
924
924
|
url: string;
|
|
925
|
-
format: "
|
|
925
|
+
format: "text" | "auto";
|
|
926
926
|
};
|
|
927
927
|
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContext.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
928
928
|
toModelOutput?: ((options: {
|
|
929
929
|
toolCallId: string;
|
|
930
930
|
input: {
|
|
931
931
|
url: string;
|
|
932
|
-
format: "
|
|
932
|
+
format: "text" | "auto";
|
|
933
933
|
};
|
|
934
934
|
output: NoInfer<{
|
|
935
935
|
ok: boolean;
|
|
@@ -1059,7 +1059,7 @@ export declare const fetchTool: ({
|
|
|
1059
1059
|
}> | undefined;
|
|
1060
1060
|
execute: import("ai").ToolExecuteFunction<{
|
|
1061
1061
|
url: string;
|
|
1062
|
-
format: "
|
|
1062
|
+
format: "text" | "auto";
|
|
1063
1063
|
}, {
|
|
1064
1064
|
ok: boolean;
|
|
1065
1065
|
toolName: string;
|
|
@@ -1135,7 +1135,7 @@ export declare const fetchTool: ({
|
|
|
1135
1135
|
} & {
|
|
1136
1136
|
execute: import("ai").ToolExecuteFunction<{
|
|
1137
1137
|
url: string;
|
|
1138
|
-
format: "
|
|
1138
|
+
format: "text" | "auto";
|
|
1139
1139
|
}, {
|
|
1140
1140
|
ok: boolean;
|
|
1141
1141
|
toolName: string;
|
|
@@ -4,8 +4,8 @@ import { reductionMetrics } from '../../core/toolOutput/reduction.js';
|
|
|
4
4
|
import { fetchUrlContent, BlockedUrlError } from '../webFetch.js';
|
|
5
5
|
import { structuredToolFailure } from './failures.js';
|
|
6
6
|
import { compactStoredOutput } from './outputCap.js';
|
|
7
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits/textBudgets.js';
|
|
7
8
|
import { hazeToolContextSchema, runDedupedTool } from './toolContext.js';
|
|
8
|
-
const MAX_OUTPUT_CHARS = 50_000;
|
|
9
9
|
export const fetchTool = tool({
|
|
10
10
|
description: 'Fetch a public http(s) URL and return readable content. Use for current docs, API references, error lookups, or CI logs. Private/loopback/metadata hosts are blocked.',
|
|
11
11
|
contextSchema: hazeToolContextSchema,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits/textBudgets.js';
|
|
2
|
+
export { MAX_OUTPUT_CHARS };
|
|
2
3
|
export declare const DEFAULT_READ_LINES = 300;
|
|
3
4
|
/** Inline diff lines beyond this count are omitted (just the count is returned). */
|
|
4
5
|
export declare const INLINE_DIFF_LINE_LIMIT = 20;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { execFile as execFileCallback } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
3
|
import { workspaceRelativePath, workspaceRoot } from '../../utils/path.js';
|
|
4
|
+
import { MAX_OUTPUT_CHARS } from '../../core/limits/textBudgets.js';
|
|
4
5
|
import { HazeToolError } from './failures.js';
|
|
5
6
|
const execFile = promisify(execFileCallback);
|
|
6
|
-
export
|
|
7
|
+
export { MAX_OUTPUT_CHARS };
|
|
7
8
|
export const DEFAULT_READ_LINES = 300;
|
|
8
9
|
/** Inline diff lines beyond this count are omitted (just the count is returned). */
|
|
9
10
|
export const INLINE_DIFF_LINE_LIMIT = 20;
|
|
@@ -15,10 +16,9 @@ export async function isGitIgnored(absolutePath) {
|
|
|
15
16
|
await execFile('git', ['-C', workspaceRoot(), 'check-ignore', '-q', '--', relative]);
|
|
16
17
|
return true;
|
|
17
18
|
}
|
|
18
|
-
catch
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return false;
|
|
19
|
+
catch {
|
|
20
|
+
// Fail open: exit 1 means "not ignored", exit 128 means "not a repo", and
|
|
21
|
+
// any other git failure should not block workspace reads (CR-016).
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line-oriented bounded ripgrep runner built on the shared bounded-process
|
|
3
|
+
* primitive, so spawn/timeout/abort/process-group teardown behavior is
|
|
4
|
+
* identical to bash (CR-004). Match counting and early-stop stay here.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runRipgrepBounded(input: {
|
|
7
|
+
executable: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
cwd: string;
|
|
10
|
+
maxMatches: number;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
code: number | null;
|
|
17
|
+
capped: boolean;
|
|
18
|
+
timedOut: boolean;
|
|
19
|
+
aborted: boolean;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
2
|
+
import { runBoundedProcess } from '../../core/process/runBoundedProcess.js';
|
|
3
|
+
import { GREP_STREAM_BYTES, PROCESS_STDERR_BYTES, TEXT_LINE_BYTES } from '../../core/limits/byteBudgets.js';
|
|
4
|
+
/**
|
|
5
|
+
* Line-oriented bounded ripgrep runner built on the shared bounded-process
|
|
6
|
+
* primitive, so spawn/timeout/abort/process-group teardown behavior is
|
|
7
|
+
* identical to bash (CR-004). Match counting and early-stop stay here.
|
|
8
|
+
*/
|
|
9
|
+
export async function runRipgrepBounded(input) {
|
|
10
|
+
const decoder = new StringDecoder('utf8');
|
|
11
|
+
let pending = '';
|
|
12
|
+
const lines = [];
|
|
13
|
+
let retainedBytes = 0;
|
|
14
|
+
let matches = 0;
|
|
15
|
+
let capped = false;
|
|
16
|
+
let protocolError;
|
|
17
|
+
const result = await runBoundedProcess({
|
|
18
|
+
command: input.executable,
|
|
19
|
+
args: input.args,
|
|
20
|
+
cwd: input.cwd,
|
|
21
|
+
timeoutMs: input.timeoutMs ?? 30_000,
|
|
22
|
+
signal: input.signal,
|
|
23
|
+
// Raw stdout head is unused: line retention happens in the interceptor.
|
|
24
|
+
maxStdoutBytes: 0,
|
|
25
|
+
maxStderrBytes: PROCESS_STDERR_BYTES,
|
|
26
|
+
onStdoutChunk: chunk => {
|
|
27
|
+
pending += decoder.write(chunk);
|
|
28
|
+
if (Buffer.byteLength(pending, 'utf8') > TEXT_LINE_BYTES) {
|
|
29
|
+
protocolError = `ripgrep JSON line exceeds ${TEXT_LINE_BYTES} bytes`;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const parts = pending.split('\n');
|
|
33
|
+
pending = parts.pop() ?? '';
|
|
34
|
+
for (const line of parts) {
|
|
35
|
+
if (capped)
|
|
36
|
+
continue;
|
|
37
|
+
const lineBytes = Buffer.byteLength(line, 'utf8') + 1;
|
|
38
|
+
if (retainedBytes + lineBytes > GREP_STREAM_BYTES) {
|
|
39
|
+
capped = true;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
lines.push(line);
|
|
43
|
+
retainedBytes += lineBytes;
|
|
44
|
+
try {
|
|
45
|
+
if (JSON.parse(line).type === 'match')
|
|
46
|
+
matches++;
|
|
47
|
+
}
|
|
48
|
+
catch { /* parser reports malformed data later */ }
|
|
49
|
+
// Global match cap is enforced here (source of truth). The `--max-count`
|
|
50
|
+
// flag passed to ripgrep is a per-file safeguard only (CR-021).
|
|
51
|
+
if (matches > input.maxMatches) {
|
|
52
|
+
capped = true;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (result.error)
|
|
60
|
+
throw new Error(result.error);
|
|
61
|
+
const tail = pending + decoder.end();
|
|
62
|
+
if (tail && !capped)
|
|
63
|
+
lines.push(tail);
|
|
64
|
+
const stderr = result.stderr.text + (protocolError ? `${result.stderr.text ? '\n' : ''}${protocolError}` : '');
|
|
65
|
+
return { stdout: lines.join('\n'), stderr, code: result.code, capped, timedOut: result.timedOut, aborted: result.aborted };
|
|
66
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/** Default ceiling for rendered grep output. */
|
|
4
|
-
export declare const GREP_MAX_OUTPUT_CHARS = 30000;
|
|
5
|
-
/** Default ceiling for a single grep match line. */
|
|
6
|
-
export declare const GREP_MAX_LINE_CHARS = 500;
|
|
1
|
+
import { COMPACT_COMMAND_CHARS, GREP_MAX_LINE_CHARS, GREP_MAX_OUTPUT_CHARS } from '../../core/limits/textBudgets.js';
|
|
2
|
+
export { COMPACT_COMMAND_CHARS, GREP_MAX_OUTPUT_CHARS, GREP_MAX_LINE_CHARS };
|
|
7
3
|
/**
|
|
8
4
|
* Cap a string to `maxChars` characters, keeping a head + tail and storing the
|
|
9
5
|
* full text behind a `readToolOutput` handle so nothing is lost.
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { storeToolOutput } from '../../core/agent/toolOutputStore.js';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
/** Default ceiling for rendered grep output. */
|
|
5
|
-
export const GREP_MAX_OUTPUT_CHARS = 30_000;
|
|
6
|
-
/** Default ceiling for a single grep match line. */
|
|
7
|
-
export const GREP_MAX_LINE_CHARS = 500;
|
|
2
|
+
import { COMPACT_COMMAND_CHARS, GREP_MAX_LINE_CHARS, GREP_MAX_OUTPUT_CHARS } from '../../core/limits/textBudgets.js';
|
|
3
|
+
export { COMPACT_COMMAND_CHARS, GREP_MAX_OUTPUT_CHARS, GREP_MAX_LINE_CHARS };
|
|
8
4
|
/**
|
|
9
5
|
* Cap a string to `maxChars` characters, keeping a head + tail and storing the
|
|
10
6
|
* full text behind a `readToolOutput` handle so nothing is lost.
|