@denizokcu/haze 1.4.0 → 1.5.1
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 +48 -1
- package/README.md +28 -12
- package/SECURITY.md +1 -1
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +7 -0
- package/dist/cli/chat/BusyBar.js +8 -0
- package/dist/cli/chat/DynamicFrame.d.ts +37 -0
- package/dist/cli/chat/DynamicFrame.js +48 -0
- package/dist/cli/chat/busyIndicator.d.ts +3 -1
- package/dist/cli/chat/busyIndicator.js +11 -9
- package/dist/cli/chat/chatMetrics.d.ts +1 -1
- package/dist/cli/chat/chatMetrics.js +3 -3
- package/dist/cli/chat/inputSuggestions.js +2 -1
- package/dist/cli/chat/liveRegion.js +1 -1
- package/dist/cli/chat/messages.js +27 -16
- package/dist/cli/chat/resizeGuard.d.ts +20 -0
- package/dist/cli/chat/resizeGuard.js +25 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
- package/dist/cli/chat/sessionLifecycle.js +13 -2
- package/dist/cli/chat/sessionRecorder.d.ts +2 -1
- package/dist/cli/chat/sessionRecorder.js +8 -0
- package/dist/cli/chat/shutdown.d.ts +27 -0
- package/dist/cli/chat/shutdown.js +79 -0
- package/dist/cli/chat/terminalControl.d.ts +45 -0
- package/dist/cli/chat/terminalControl.js +107 -0
- package/dist/cli/chat/tips.js +1 -0
- package/dist/cli/chat/userInput.d.ts +43 -0
- package/dist/cli/chat/userInput.js +63 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +14 -6
- package/dist/cli/chat/wizard/types.d.ts +8 -1
- package/dist/cli/chat/wizardDispatch.js +1 -1
- package/dist/cli/commands/chat.js +258 -172
- package/dist/cli/commands/commandHelp.js +6 -2
- package/dist/cli/commands/commands.d.ts +8 -0
- package/dist/cli/commands/commands.js +11 -0
- package/dist/cli/commands/formatters.d.ts +1 -1
- package/dist/cli/commands/formatters.js +20 -2
- package/dist/cli/commands/logsCommand.js +21 -2
- package/dist/cli/commands/reasoningCommand.d.ts +23 -14
- package/dist/cli/commands/reasoningCommand.js +53 -20
- package/dist/cli/commands/runCommand.js +19 -11
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +11 -6
- package/dist/cli/commands/streaming/attemptSetup.d.ts +1 -0
- package/dist/cli/commands/streaming/attemptSetup.js +11 -5
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +8 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +3 -2
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +4 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +43 -7
- package/dist/cli/commands/streaming/prepareStep.js +7 -3
- package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
- package/dist/cli/commands/streaming/streamLoop.js +3 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
- package/dist/cli/commands/streaming.d.ts +1 -1
- package/dist/cli/commands/streaming.js +23 -17
- package/dist/cli/commands/wizardFlow.d.ts +5 -2
- package/dist/cli/commands/wizardFlow.js +17 -10
- package/dist/cli/index.js +17 -1
- package/dist/config/contextFiles.d.ts +9 -0
- package/dist/config/contextFiles.js +21 -1
- package/dist/config/modelCatalog.d.ts +3 -0
- package/dist/config/modelCatalog.js +29 -0
- package/dist/config/providerPresets.d.ts +1 -1
- package/dist/config/providerPresets.js +42 -3
- package/dist/config/settings.d.ts +11 -4
- package/dist/config/settings.js +9 -0
- package/dist/core/agent/budgets.d.ts +13 -15
- package/dist/core/agent/budgets.js +15 -17
- package/dist/core/agent/completionController.d.ts +6 -2
- package/dist/core/agent/completionController.js +16 -3
- package/dist/core/agent/goalPolicy.d.ts +10 -0
- package/dist/core/agent/goalPolicy.js +44 -6
- package/dist/core/agent/projectPreflight.d.ts +2 -0
- package/dist/core/agent/projectPreflight.js +56 -0
- package/dist/core/agent/reasoningPolicy.d.ts +34 -4
- package/dist/core/agent/reasoningPolicy.js +27 -4
- package/dist/core/agent/workState.d.ts +8 -0
- package/dist/core/agent/workState.js +191 -8
- package/dist/core/providerContracts.d.ts +32 -0
- package/dist/core/providerContracts.js +1 -0
- package/dist/core/session/sessionReport.d.ts +33 -0
- package/dist/core/session/sessionReport.js +121 -0
- package/dist/core/session/sessionSlimming.js +9 -3
- package/dist/core/session/sessionStore.d.ts +12 -0
- package/dist/core/session/sessionStore.js +20 -4
- package/dist/core/subagent/contracts.d.ts +3 -25
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/validation/outputParser.d.ts +6 -1
- package/dist/core/validation/outputParser.js +6 -2
- package/dist/llm/client.d.ts +4 -2
- package/dist/llm/client.js +44 -16
- package/dist/llm/hazeTools.d.ts +8553 -8550
- package/dist/llm/hazeTools.js +6 -503
- package/dist/llm/lspTools.d.ts +120 -120
- package/dist/llm/mcp.js +3 -0
- package/dist/llm/requestContext.d.ts +1 -1
- package/dist/llm/requestContext.js +1 -1
- package/dist/{core/subagent → llm}/subagentRunner.d.ts +9 -9
- package/dist/{core/subagent → llm}/subagentRunner.js +22 -25
- package/dist/llm/systemPrompt.d.ts +11 -1
- package/dist/llm/systemPrompt.js +2 -11
- package/dist/llm/tools/fetchTool.d.ts +30 -30
- package/dist/llm/tools/fileTools.d.ts +7768 -0
- package/dist/llm/tools/fileTools.js +510 -0
- package/dist/llm/tools/processTool.d.ts +30 -30
- package/dist/llm/tools/shellTool.d.ts +30 -30
- package/dist/llm/tools/shellTool.js +8 -4
- package/dist/llm/tools/toolContext.d.ts +3 -32
- package/dist/llm/tools/toolContext.js +33 -52
- package/dist/llm/tools/toolContextState.d.ts +40 -0
- package/dist/llm/tools/toolContextState.js +34 -0
- package/dist/llm/workerContext.d.ts +7 -0
- package/dist/llm/workerContext.js +18 -1
- package/dist/skills/SkillLoader.js +3 -3
- package/dist/skills/SkillRegistry.js +3 -3
- package/dist/skills/builder/SkillBuilder.js +3 -3
- package/dist/skills/confinement.d.ts +7 -0
- package/dist/skills/confinement.js +15 -0
- package/dist/ui/codeHighlight.js +4 -4
- package/dist/ui/components/MarkdownText.js +7 -8
- package/dist/ui/components/NativeIndicators.d.ts +15 -0
- package/dist/ui/components/NativeIndicators.js +32 -0
- package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
- package/dist/ui/components/StreamingMarkdownText.js +38 -0
- package/dist/ui/components/TextInput.d.ts +7 -2
- package/dist/ui/components/TextInput.js +103 -46
- package/dist/ui/components/WizardChoices.d.ts +18 -0
- package/dist/ui/components/WizardChoices.js +32 -0
- package/dist/ui/inputBuffer.js +12 -6
- package/dist/ui/textGeometry.d.ts +14 -0
- package/dist/ui/textGeometry.js +31 -0
- package/package.json +14 -13
- /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
- /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
|
@@ -9,17 +9,17 @@ export declare const processTool: ({
|
|
|
9
9
|
limit: number;
|
|
10
10
|
backgroundId?: string | undefined;
|
|
11
11
|
}>;
|
|
12
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
12
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
13
13
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
14
14
|
action: "output" | "kill" | "list";
|
|
15
15
|
offset: number;
|
|
16
16
|
limit: number;
|
|
17
17
|
backgroundId?: string | undefined;
|
|
18
|
-
}, NoInfer<import("./
|
|
19
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
18
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
19
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
20
20
|
onInputDelta?: ((options: {
|
|
21
21
|
inputTextDelta: string;
|
|
22
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
22
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
23
23
|
onInputAvailable?: ((options: {
|
|
24
24
|
input: {
|
|
25
25
|
action: "output" | "kill" | "list";
|
|
@@ -27,7 +27,7 @@ export declare const processTool: ({
|
|
|
27
27
|
limit: number;
|
|
28
28
|
backgroundId?: string | undefined;
|
|
29
29
|
};
|
|
30
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
30
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
31
31
|
toModelOutput?: ((options: {
|
|
32
32
|
toolCallId: string;
|
|
33
33
|
input: {
|
|
@@ -195,10 +195,10 @@ export declare const processTool: ({
|
|
|
195
195
|
error?: undefined;
|
|
196
196
|
suggestedNextStep?: undefined;
|
|
197
197
|
processes?: undefined;
|
|
198
|
-
}, NoInfer<import("./
|
|
198
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
199
199
|
} & {
|
|
200
200
|
description?: string | ((options: {
|
|
201
|
-
context: NoInfer<import("./
|
|
201
|
+
context: NoInfer<import("./toolContextState.js").HazeToolContext>;
|
|
202
202
|
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
203
203
|
}) => string) | undefined;
|
|
204
204
|
strict?: boolean;
|
|
@@ -272,7 +272,7 @@ export declare const processTool: ({
|
|
|
272
272
|
error?: undefined;
|
|
273
273
|
suggestedNextStep?: undefined;
|
|
274
274
|
processes?: undefined;
|
|
275
|
-
}, NoInfer<import("./
|
|
275
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
276
276
|
}) | ({
|
|
277
277
|
deferLoading?: boolean;
|
|
278
278
|
title?: string;
|
|
@@ -284,17 +284,17 @@ export declare const processTool: ({
|
|
|
284
284
|
limit: number;
|
|
285
285
|
backgroundId?: string | undefined;
|
|
286
286
|
}>;
|
|
287
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
287
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
288
288
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
289
289
|
action: "output" | "kill" | "list";
|
|
290
290
|
offset: number;
|
|
291
291
|
limit: number;
|
|
292
292
|
backgroundId?: string | undefined;
|
|
293
|
-
}, NoInfer<import("./
|
|
294
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
293
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
294
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
295
295
|
onInputDelta?: ((options: {
|
|
296
296
|
inputTextDelta: string;
|
|
297
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
297
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
298
298
|
onInputAvailable?: ((options: {
|
|
299
299
|
input: {
|
|
300
300
|
action: "output" | "kill" | "list";
|
|
@@ -302,7 +302,7 @@ export declare const processTool: ({
|
|
|
302
302
|
limit: number;
|
|
303
303
|
backgroundId?: string | undefined;
|
|
304
304
|
};
|
|
305
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
305
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
306
306
|
toModelOutput?: ((options: {
|
|
307
307
|
toolCallId: string;
|
|
308
308
|
input: {
|
|
@@ -470,10 +470,10 @@ export declare const processTool: ({
|
|
|
470
470
|
error?: undefined;
|
|
471
471
|
suggestedNextStep?: undefined;
|
|
472
472
|
processes?: undefined;
|
|
473
|
-
}, NoInfer<import("./
|
|
473
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
474
474
|
} & {
|
|
475
475
|
description?: string | ((options: {
|
|
476
|
-
context: NoInfer<import("./
|
|
476
|
+
context: NoInfer<import("./toolContextState.js").HazeToolContext>;
|
|
477
477
|
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
478
478
|
}) => string) | undefined;
|
|
479
479
|
strict?: boolean;
|
|
@@ -547,7 +547,7 @@ export declare const processTool: ({
|
|
|
547
547
|
error?: undefined;
|
|
548
548
|
suggestedNextStep?: undefined;
|
|
549
549
|
processes?: undefined;
|
|
550
|
-
}, NoInfer<import("./
|
|
550
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
551
551
|
}) | ({
|
|
552
552
|
deferLoading?: boolean;
|
|
553
553
|
title?: string;
|
|
@@ -559,17 +559,17 @@ export declare const processTool: ({
|
|
|
559
559
|
limit: number;
|
|
560
560
|
backgroundId?: string | undefined;
|
|
561
561
|
}>;
|
|
562
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
562
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
563
563
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
564
564
|
action: "output" | "kill" | "list";
|
|
565
565
|
offset: number;
|
|
566
566
|
limit: number;
|
|
567
567
|
backgroundId?: string | undefined;
|
|
568
|
-
}, NoInfer<import("./
|
|
569
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
568
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
569
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
570
570
|
onInputDelta?: ((options: {
|
|
571
571
|
inputTextDelta: string;
|
|
572
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
572
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
573
573
|
onInputAvailable?: ((options: {
|
|
574
574
|
input: {
|
|
575
575
|
action: "output" | "kill" | "list";
|
|
@@ -577,7 +577,7 @@ export declare const processTool: ({
|
|
|
577
577
|
limit: number;
|
|
578
578
|
backgroundId?: string | undefined;
|
|
579
579
|
};
|
|
580
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
580
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
581
581
|
toModelOutput?: ((options: {
|
|
582
582
|
toolCallId: string;
|
|
583
583
|
input: {
|
|
@@ -745,7 +745,7 @@ export declare const processTool: ({
|
|
|
745
745
|
error?: undefined;
|
|
746
746
|
suggestedNextStep?: undefined;
|
|
747
747
|
processes?: undefined;
|
|
748
|
-
}, NoInfer<import("./
|
|
748
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
749
749
|
} & {
|
|
750
750
|
type: "provider";
|
|
751
751
|
id: `${string}.${string}`;
|
|
@@ -812,7 +812,7 @@ export declare const processTool: ({
|
|
|
812
812
|
error?: undefined;
|
|
813
813
|
suggestedNextStep?: undefined;
|
|
814
814
|
processes?: undefined;
|
|
815
|
-
}, NoInfer<import("./
|
|
815
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
816
816
|
}) | ({
|
|
817
817
|
deferLoading?: boolean;
|
|
818
818
|
title?: string;
|
|
@@ -824,17 +824,17 @@ export declare const processTool: ({
|
|
|
824
824
|
limit: number;
|
|
825
825
|
backgroundId?: string | undefined;
|
|
826
826
|
}>;
|
|
827
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
827
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
828
828
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
829
829
|
action: "output" | "kill" | "list";
|
|
830
830
|
offset: number;
|
|
831
831
|
limit: number;
|
|
832
832
|
backgroundId?: string | undefined;
|
|
833
|
-
}, NoInfer<import("./
|
|
834
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
833
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
834
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
835
835
|
onInputDelta?: ((options: {
|
|
836
836
|
inputTextDelta: string;
|
|
837
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
837
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
838
838
|
onInputAvailable?: ((options: {
|
|
839
839
|
input: {
|
|
840
840
|
action: "output" | "kill" | "list";
|
|
@@ -842,7 +842,7 @@ export declare const processTool: ({
|
|
|
842
842
|
limit: number;
|
|
843
843
|
backgroundId?: string | undefined;
|
|
844
844
|
};
|
|
845
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
845
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
846
846
|
toModelOutput?: ((options: {
|
|
847
847
|
toolCallId: string;
|
|
848
848
|
input: {
|
|
@@ -1010,7 +1010,7 @@ export declare const processTool: ({
|
|
|
1010
1010
|
error?: undefined;
|
|
1011
1011
|
suggestedNextStep?: undefined;
|
|
1012
1012
|
processes?: undefined;
|
|
1013
|
-
}, NoInfer<import("./
|
|
1013
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1014
1014
|
} & {
|
|
1015
1015
|
type: "provider";
|
|
1016
1016
|
id: `${string}.${string}`;
|
|
@@ -1077,5 +1077,5 @@ export declare const processTool: ({
|
|
|
1077
1077
|
error?: undefined;
|
|
1078
1078
|
suggestedNextStep?: undefined;
|
|
1079
1079
|
processes?: undefined;
|
|
1080
|
-
}, NoInfer<import("./
|
|
1080
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1081
1081
|
});
|
|
@@ -9,17 +9,17 @@ export declare const shellTool: ({
|
|
|
9
9
|
background: boolean;
|
|
10
10
|
timeoutSeconds?: number | undefined;
|
|
11
11
|
}>;
|
|
12
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
12
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
13
13
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
14
14
|
command: string;
|
|
15
15
|
purpose: "validation" | "auto";
|
|
16
16
|
background: boolean;
|
|
17
17
|
timeoutSeconds?: number | undefined;
|
|
18
|
-
}, NoInfer<import("./
|
|
19
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
18
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
19
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
20
20
|
onInputDelta?: ((options: {
|
|
21
21
|
inputTextDelta: string;
|
|
22
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
22
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
23
23
|
onInputAvailable?: ((options: {
|
|
24
24
|
input: {
|
|
25
25
|
command: string;
|
|
@@ -27,7 +27,7 @@ export declare const shellTool: ({
|
|
|
27
27
|
background: boolean;
|
|
28
28
|
timeoutSeconds?: number | undefined;
|
|
29
29
|
};
|
|
30
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
30
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
31
31
|
toModelOutput?: ((options: {
|
|
32
32
|
toolCallId: string;
|
|
33
33
|
input: {
|
|
@@ -273,10 +273,10 @@ export declare const shellTool: ({
|
|
|
273
273
|
recoverable?: undefined;
|
|
274
274
|
suggestedNextStep?: undefined;
|
|
275
275
|
background?: undefined;
|
|
276
|
-
}, NoInfer<import("./
|
|
276
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
277
277
|
} & {
|
|
278
278
|
description?: string | ((options: {
|
|
279
|
-
context: NoInfer<import("./
|
|
279
|
+
context: NoInfer<import("./toolContextState.js").HazeToolContext>;
|
|
280
280
|
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
281
281
|
}) => string) | undefined;
|
|
282
282
|
strict?: boolean;
|
|
@@ -376,7 +376,7 @@ export declare const shellTool: ({
|
|
|
376
376
|
recoverable?: undefined;
|
|
377
377
|
suggestedNextStep?: undefined;
|
|
378
378
|
background?: undefined;
|
|
379
|
-
}, NoInfer<import("./
|
|
379
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
380
380
|
}) | ({
|
|
381
381
|
deferLoading?: boolean;
|
|
382
382
|
title?: string;
|
|
@@ -388,17 +388,17 @@ export declare const shellTool: ({
|
|
|
388
388
|
background: boolean;
|
|
389
389
|
timeoutSeconds?: number | undefined;
|
|
390
390
|
}>;
|
|
391
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
391
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
392
392
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
393
393
|
command: string;
|
|
394
394
|
purpose: "validation" | "auto";
|
|
395
395
|
background: boolean;
|
|
396
396
|
timeoutSeconds?: number | undefined;
|
|
397
|
-
}, NoInfer<import("./
|
|
398
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
397
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
398
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
399
399
|
onInputDelta?: ((options: {
|
|
400
400
|
inputTextDelta: string;
|
|
401
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
401
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
402
402
|
onInputAvailable?: ((options: {
|
|
403
403
|
input: {
|
|
404
404
|
command: string;
|
|
@@ -406,7 +406,7 @@ export declare const shellTool: ({
|
|
|
406
406
|
background: boolean;
|
|
407
407
|
timeoutSeconds?: number | undefined;
|
|
408
408
|
};
|
|
409
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
409
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
410
410
|
toModelOutput?: ((options: {
|
|
411
411
|
toolCallId: string;
|
|
412
412
|
input: {
|
|
@@ -652,10 +652,10 @@ export declare const shellTool: ({
|
|
|
652
652
|
recoverable?: undefined;
|
|
653
653
|
suggestedNextStep?: undefined;
|
|
654
654
|
background?: undefined;
|
|
655
|
-
}, NoInfer<import("./
|
|
655
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
656
656
|
} & {
|
|
657
657
|
description?: string | ((options: {
|
|
658
|
-
context: NoInfer<import("./
|
|
658
|
+
context: NoInfer<import("./toolContextState.js").HazeToolContext>;
|
|
659
659
|
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
660
660
|
}) => string) | undefined;
|
|
661
661
|
strict?: boolean;
|
|
@@ -755,7 +755,7 @@ export declare const shellTool: ({
|
|
|
755
755
|
recoverable?: undefined;
|
|
756
756
|
suggestedNextStep?: undefined;
|
|
757
757
|
background?: undefined;
|
|
758
|
-
}, NoInfer<import("./
|
|
758
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
759
759
|
}) | ({
|
|
760
760
|
deferLoading?: boolean;
|
|
761
761
|
title?: string;
|
|
@@ -767,17 +767,17 @@ export declare const shellTool: ({
|
|
|
767
767
|
background: boolean;
|
|
768
768
|
timeoutSeconds?: number | undefined;
|
|
769
769
|
}>;
|
|
770
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
770
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
771
771
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
772
772
|
command: string;
|
|
773
773
|
purpose: "validation" | "auto";
|
|
774
774
|
background: boolean;
|
|
775
775
|
timeoutSeconds?: number | undefined;
|
|
776
|
-
}, NoInfer<import("./
|
|
777
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
776
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
777
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
778
778
|
onInputDelta?: ((options: {
|
|
779
779
|
inputTextDelta: string;
|
|
780
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
780
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
781
781
|
onInputAvailable?: ((options: {
|
|
782
782
|
input: {
|
|
783
783
|
command: string;
|
|
@@ -785,7 +785,7 @@ export declare const shellTool: ({
|
|
|
785
785
|
background: boolean;
|
|
786
786
|
timeoutSeconds?: number | undefined;
|
|
787
787
|
};
|
|
788
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
788
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
789
789
|
toModelOutput?: ((options: {
|
|
790
790
|
toolCallId: string;
|
|
791
791
|
input: {
|
|
@@ -1031,7 +1031,7 @@ export declare const shellTool: ({
|
|
|
1031
1031
|
recoverable?: undefined;
|
|
1032
1032
|
suggestedNextStep?: undefined;
|
|
1033
1033
|
background?: undefined;
|
|
1034
|
-
}, NoInfer<import("./
|
|
1034
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1035
1035
|
} & {
|
|
1036
1036
|
type: "provider";
|
|
1037
1037
|
id: `${string}.${string}`;
|
|
@@ -1124,7 +1124,7 @@ export declare const shellTool: ({
|
|
|
1124
1124
|
recoverable?: undefined;
|
|
1125
1125
|
suggestedNextStep?: undefined;
|
|
1126
1126
|
background?: undefined;
|
|
1127
|
-
}, NoInfer<import("./
|
|
1127
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1128
1128
|
}) | ({
|
|
1129
1129
|
deferLoading?: boolean;
|
|
1130
1130
|
title?: string;
|
|
@@ -1136,17 +1136,17 @@ export declare const shellTool: ({
|
|
|
1136
1136
|
background: boolean;
|
|
1137
1137
|
timeoutSeconds?: number | undefined;
|
|
1138
1138
|
}>;
|
|
1139
|
-
contextSchema?: import("ai").FlexibleSchema<import("./
|
|
1139
|
+
contextSchema?: import("ai").FlexibleSchema<import("./toolContextState.js").HazeToolContext> | undefined;
|
|
1140
1140
|
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
1141
1141
|
command: string;
|
|
1142
1142
|
purpose: "validation" | "auto";
|
|
1143
1143
|
background: boolean;
|
|
1144
1144
|
timeoutSeconds?: number | undefined;
|
|
1145
|
-
}, NoInfer<import("./
|
|
1146
|
-
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
1145
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>> | undefined;
|
|
1146
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
1147
1147
|
onInputDelta?: ((options: {
|
|
1148
1148
|
inputTextDelta: string;
|
|
1149
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
1149
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
1150
1150
|
onInputAvailable?: ((options: {
|
|
1151
1151
|
input: {
|
|
1152
1152
|
command: string;
|
|
@@ -1154,7 +1154,7 @@ export declare const shellTool: ({
|
|
|
1154
1154
|
background: boolean;
|
|
1155
1155
|
timeoutSeconds?: number | undefined;
|
|
1156
1156
|
};
|
|
1157
|
-
} & import("ai").ToolExecutionOptions<NoInfer<import("./
|
|
1157
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("./toolContextState.js").HazeToolContext>>) => void | PromiseLike<void>) | undefined;
|
|
1158
1158
|
toModelOutput?: ((options: {
|
|
1159
1159
|
toolCallId: string;
|
|
1160
1160
|
input: {
|
|
@@ -1400,7 +1400,7 @@ export declare const shellTool: ({
|
|
|
1400
1400
|
recoverable?: undefined;
|
|
1401
1401
|
suggestedNextStep?: undefined;
|
|
1402
1402
|
background?: undefined;
|
|
1403
|
-
}, NoInfer<import("./
|
|
1403
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1404
1404
|
} & {
|
|
1405
1405
|
type: "provider";
|
|
1406
1406
|
id: `${string}.${string}`;
|
|
@@ -1493,5 +1493,5 @@ export declare const shellTool: ({
|
|
|
1493
1493
|
recoverable?: undefined;
|
|
1494
1494
|
suggestedNextStep?: undefined;
|
|
1495
1495
|
background?: undefined;
|
|
1496
|
-
}, NoInfer<import("./
|
|
1496
|
+
}, NoInfer<import("./toolContextState.js").HazeToolContext>>;
|
|
1497
1497
|
});
|
|
@@ -60,7 +60,14 @@ export const shellTool = tool({
|
|
|
60
60
|
const { code, timedOut } = processResult;
|
|
61
61
|
const stdout = processResult.stdout.text;
|
|
62
62
|
const stderr = processResult.stderr.text;
|
|
63
|
-
|
|
63
|
+
// A spawn failure (executable missing / not found, exit 127) is an
|
|
64
|
+
// environment blocker, not a failed check: nothing ran, so there is no
|
|
65
|
+
// pass/fail evidence to record (observed 2026-10-04: a `missing_executable`
|
|
66
|
+
// shell result was recorded as a failed `test` validation and rode a goal
|
|
67
|
+
// checkpoint as an unresolvable red). Diagnose it below and keep the
|
|
68
|
+
// validation summary absent.
|
|
69
|
+
const missing = code !== 0 && !processResult.aborted ? detectMissingExecutable({ command, code, stderr }) : undefined;
|
|
70
|
+
const validationSummary = isValidationCommand && !missing
|
|
64
71
|
? parseValidationOutput({ command, code, stdout, stderr, timedOut, stdoutTruncated: processResult.stdout.omittedBytes > 0, stderrTruncated: processResult.stderr.omittedBytes > 0, classification })
|
|
65
72
|
: undefined;
|
|
66
73
|
// Evidence truthfulness: a passing validation whose command shape can
|
|
@@ -77,9 +84,6 @@ export const shellTool = tool({
|
|
|
77
84
|
: undefined;
|
|
78
85
|
const validationPassed = confirmedValidationSummary?.status === 'passed';
|
|
79
86
|
const output = filterShellOutput({ command, code, stdout, stderr, timedOut, classification, validationSummary: confirmedValidationSummary, storeRawOutput: storeToolOutput, fallbackCompact: compactStoredOutput, compactMaxChars: validationPassed ? SHORT_VALIDATION_CHARS : COMPACT_COMMAND_CHARS });
|
|
80
|
-
// Generic, dependency-agnostic diagnostic for a missing executable. Only the
|
|
81
|
-
// executable name and a generic next step are exposed (never raw stderr).
|
|
82
|
-
const missing = code !== 0 && !processResult.aborted ? detectMissingExecutable({ command, code, stderr }) : undefined;
|
|
83
87
|
return {
|
|
84
88
|
ok: code === 0 && !timedOut && !processResult.aborted && !processResult.error,
|
|
85
89
|
code, command, purpose, cwd, classification, durationMs: Date.now() - startedAt, timedOut,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { ToolFailureReasonCode } from '../toolResultTypes.js';
|
|
3
2
|
import { type ContextFile } from '../../config/contextFiles.js';
|
|
4
|
-
import type
|
|
5
|
-
|
|
3
|
+
import { type HazeToolContext, type ToolExecutionContext } from './toolContextState.js';
|
|
4
|
+
export type { HazeToolContext, PostMutationDiagnostics, ToolExecutionContext } from './toolContextState.js';
|
|
5
|
+
export { hazeContext, isHazeToolContext } from './toolContextState.js';
|
|
6
6
|
/**
|
|
7
7
|
* Turn-scoped tool-call orchestration shared by every built-in tool: in-flight
|
|
8
8
|
* and completed-call deduplication, a mutation epoch that invalidates read
|
|
@@ -13,36 +13,7 @@ import type { WorkspaceMutationOwner, WorkspaceMutationPolicy } from '../../core
|
|
|
13
13
|
* passes to the AI SDK. Tests and older callers may still provide the legacy
|
|
14
14
|
* `experimental_context` shape. Nothing here is persisted.
|
|
15
15
|
*/
|
|
16
|
-
export type ToolExecutionContext = {
|
|
17
|
-
abortSignal?: AbortSignal;
|
|
18
|
-
context?: unknown;
|
|
19
|
-
experimental_context?: unknown;
|
|
20
|
-
};
|
|
21
|
-
export type PostMutationDiagnostics = (paths: readonly string[]) => Promise<unknown | undefined>;
|
|
22
|
-
export type HazeToolContext = {
|
|
23
|
-
inFlightToolCalls?: Map<string, Promise<unknown>>;
|
|
24
|
-
completedToolCalls?: Map<string, number>;
|
|
25
|
-
mutationEpoch?: number;
|
|
26
|
-
failedMutationPaths?: Set<string>;
|
|
27
|
-
failedMutationReasons?: Map<string, ToolFailureReasonCode | undefined>;
|
|
28
|
-
pathsReadAfterFailedMutation?: Set<string>;
|
|
29
|
-
inFlightMutationPaths?: Set<string>;
|
|
30
|
-
loadedContextFilePaths?: Set<string>;
|
|
31
|
-
loadedContextFileSignatures?: Map<string, string>;
|
|
32
|
-
pendingContextFiles?: ContextFile[];
|
|
33
|
-
scopedContextDiscovery?: Promise<void>;
|
|
34
|
-
onContextFileRead?: (path: string) => void;
|
|
35
|
-
mutationPolicy?: WorkspaceMutationPolicy;
|
|
36
|
-
mutationOwner?: WorkspaceMutationOwner;
|
|
37
|
-
/** True in disposable worker contexts; background processes are main-turn-only. */
|
|
38
|
-
isSubagent?: boolean;
|
|
39
|
-
/** Real paths the user mentioned this turn; read tools may escape workspace for them. */
|
|
40
|
-
blessedPaths?: readonly BlessedPath[];
|
|
41
|
-
/** Runs LSP diagnostics after successful file mutations and embeds them in that tool result. */
|
|
42
|
-
postMutationDiagnostics?: PostMutationDiagnostics;
|
|
43
|
-
};
|
|
44
16
|
export declare const hazeToolContextSchema: z.ZodCustom<HazeToolContext, HazeToolContext>;
|
|
45
|
-
export declare function hazeContext(context: ToolExecutionContext): HazeToolContext | undefined;
|
|
46
17
|
export declare function toolsContextFor<T extends Record<string, unknown>>(tools: T, context: HazeToolContext): Partial<Record<keyof T, HazeToolContext>>;
|
|
47
18
|
/**
|
|
48
19
|
* Lazily load scoped CLAUDE.md/AGENTS.md files that apply to `filePath` and
|
|
@@ -4,58 +4,19 @@ import { readScopedContextFilesForPath } from '../../config/contextFiles.js';
|
|
|
4
4
|
import { workspacePathKey, workspaceRoot } from '../../utils/path.js';
|
|
5
5
|
import { isFailedToolOutput, requiresReadFileRecovery, toolInputField } from '../../core/agent/toolResults.js';
|
|
6
6
|
import { HazeToolError } from './failures.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return JSON.stringify(value) ?? 'undefined';
|
|
20
|
-
}
|
|
21
|
-
function toolCallKey(toolName, input) {
|
|
22
|
-
return `${toolName}:${stableJsonStringify(input)}`;
|
|
23
|
-
}
|
|
24
|
-
function isRecord(value) {
|
|
25
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
-
}
|
|
27
|
-
function isMutationPolicy(value) {
|
|
28
|
-
return isRecord(value) && typeof value.acquire === 'function' && typeof value.createOwner === 'function';
|
|
29
|
-
}
|
|
30
|
-
function isHazeToolContext(value) {
|
|
31
|
-
if (!isRecord(value))
|
|
32
|
-
return false;
|
|
33
|
-
const validOptional = (key, predicate) => value[key] === undefined || predicate(value[key]);
|
|
34
|
-
return validOptional('inFlightToolCalls', field => field instanceof Map)
|
|
35
|
-
&& validOptional('completedToolCalls', field => field instanceof Map)
|
|
36
|
-
&& validOptional('mutationEpoch', field => typeof field === 'number' && Number.isSafeInteger(field) && field >= 0)
|
|
37
|
-
&& validOptional('failedMutationPaths', field => field instanceof Set)
|
|
38
|
-
&& validOptional('failedMutationReasons', field => field instanceof Map)
|
|
39
|
-
&& validOptional('pathsReadAfterFailedMutation', field => field instanceof Set)
|
|
40
|
-
&& validOptional('inFlightMutationPaths', field => field instanceof Set)
|
|
41
|
-
&& validOptional('loadedContextFilePaths', field => field instanceof Set)
|
|
42
|
-
&& validOptional('loadedContextFileSignatures', field => field instanceof Map)
|
|
43
|
-
&& validOptional('pendingContextFiles', field => Array.isArray(field))
|
|
44
|
-
&& validOptional('scopedContextDiscovery', field => field instanceof Promise)
|
|
45
|
-
&& validOptional('onContextFileRead', field => typeof field === 'function')
|
|
46
|
-
&& validOptional('mutationPolicy', isMutationPolicy)
|
|
47
|
-
&& validOptional('mutationOwner', field => typeof field === 'symbol')
|
|
48
|
-
&& validOptional('isSubagent', field => typeof field === 'boolean')
|
|
49
|
-
&& validOptional('blessedPaths', field => Array.isArray(field) && field.every(item => isRecord(item) && typeof item.realPath === 'string' && typeof item.isDirectory === 'boolean'))
|
|
50
|
-
&& validOptional('postMutationDiagnostics', field => typeof field === 'function');
|
|
51
|
-
}
|
|
7
|
+
import { hazeContext, isHazeToolContext } from './toolContextState.js';
|
|
8
|
+
export { hazeContext, isHazeToolContext } from './toolContextState.js';
|
|
9
|
+
/**
|
|
10
|
+
* Turn-scoped tool-call orchestration shared by every built-in tool: in-flight
|
|
11
|
+
* and completed-call deduplication, a mutation epoch that invalidates read
|
|
12
|
+
* caches after writes, edit-recovery gating, and lazy discovery of scoped
|
|
13
|
+
* project instructions (CLAUDE.md / AGENTS.md below the cwd).
|
|
14
|
+
*
|
|
15
|
+
* All state lives on per-tool `context` values, which the agent turn owns and
|
|
16
|
+
* passes to the AI SDK. Tests and older callers may still provide the legacy
|
|
17
|
+
* `experimental_context` shape. Nothing here is persisted.
|
|
18
|
+
*/
|
|
52
19
|
export const hazeToolContextSchema = z.custom(isHazeToolContext, 'Invalid haze tool context');
|
|
53
|
-
export function hazeContext(context) {
|
|
54
|
-
const value = typeof context.context === 'object' && context.context != null
|
|
55
|
-
? context.context
|
|
56
|
-
: context.experimental_context;
|
|
57
|
-
return isHazeToolContext(value) ? value : undefined;
|
|
58
|
-
}
|
|
59
20
|
export function toolsContextFor(tools, context) {
|
|
60
21
|
const hazeToolNames = new Set(['listFiles', 'readFile', 'grep', 'replaceInFiles', 'replaceLines', 'writeFile', 'editFile', 'shell', 'process', 'fetch', 'lspRenameSymbol', 'lspSafeDeleteSymbol']);
|
|
61
22
|
return Object.fromEntries(Object.keys(tools).filter(name => hazeToolNames.has(name)).map(name => [name, context]));
|
|
@@ -129,7 +90,7 @@ async function attachPostMutationDiagnostics(toolName, input, result, diagnostic
|
|
|
129
90
|
if (!diagnostics)
|
|
130
91
|
return result;
|
|
131
92
|
const paths = changedPathsForDiagnostics(toolName, input, result);
|
|
132
|
-
if (paths.length === 0 || !
|
|
93
|
+
if (paths.length === 0 || !isRecordValue(result))
|
|
133
94
|
return result;
|
|
134
95
|
try {
|
|
135
96
|
const lspDiagnostics = await diagnostics(paths);
|
|
@@ -140,6 +101,9 @@ async function attachPostMutationDiagnostics(toolName, input, result, diagnostic
|
|
|
140
101
|
return { ...result, lspDiagnostics: { ok: false, error: `Automatic LSP diagnostics failed: ${message.split('\n')[0]}` } };
|
|
141
102
|
}
|
|
142
103
|
}
|
|
104
|
+
function isRecordValue(value) {
|
|
105
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
106
|
+
}
|
|
143
107
|
function isReadOnlyFileTool(toolName) {
|
|
144
108
|
return ['listFiles', 'readFile', 'grep'].includes(toolName);
|
|
145
109
|
}
|
|
@@ -149,6 +113,23 @@ function isReadOnlyFileTool(toolName) {
|
|
|
149
113
|
function isDeduplicableReadOnlyTool(toolName) {
|
|
150
114
|
return isReadOnlyFileTool(toolName) || toolName === 'fetch';
|
|
151
115
|
}
|
|
116
|
+
function stableJsonStringify(value, seen = new WeakSet()) {
|
|
117
|
+
if (Array.isArray(value))
|
|
118
|
+
return `[${value.map(item => stableJsonStringify(item, seen)).join(',')}]`;
|
|
119
|
+
if (value && typeof value === 'object') {
|
|
120
|
+
if (seen.has(value))
|
|
121
|
+
throw new Error('Circular tool input');
|
|
122
|
+
seen.add(value);
|
|
123
|
+
const entries = Object.entries(value)
|
|
124
|
+
.filter(([, entryValue]) => entryValue !== undefined)
|
|
125
|
+
.sort(([a], [b]) => a.localeCompare(b));
|
|
126
|
+
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableJsonStringify(entryValue, seen)}`).join(',')}}`;
|
|
127
|
+
}
|
|
128
|
+
return JSON.stringify(value) ?? 'undefined';
|
|
129
|
+
}
|
|
130
|
+
function toolCallKey(toolName, input) {
|
|
131
|
+
return `${toolName}:${stableJsonStringify(input)}`;
|
|
132
|
+
}
|
|
152
133
|
/**
|
|
153
134
|
* Wrap a tool's execution with turn-scoped deduplication and edit-recovery:
|
|
154
135
|
* - skip concurrent mutations of the same path;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ContextFile } from '../../config/contextFiles.js';
|
|
2
|
+
import type { ToolFailureReasonCode } from '../toolResultTypes.js';
|
|
3
|
+
import type { BlessedPath } from '../../core/attachments/readBlessings.js';
|
|
4
|
+
import type { WorkspaceMutationOwner, WorkspaceMutationPolicy } from '../../core/subagent/workspaceMutationPolicy.js';
|
|
5
|
+
/**
|
|
6
|
+
* The turn-scoped tool execution state schema and guards, split from
|
|
7
|
+
* `toolContext.ts` so the widely-imported context type stops dragging the
|
|
8
|
+
* dedup/mutation runtime with it. `toolContext.ts` re-exports everything below
|
|
9
|
+
* for existing importers; new code imports from here.
|
|
10
|
+
*/
|
|
11
|
+
export type ToolExecutionContext = {
|
|
12
|
+
abortSignal?: AbortSignal;
|
|
13
|
+
context?: unknown;
|
|
14
|
+
experimental_context?: unknown;
|
|
15
|
+
};
|
|
16
|
+
export type PostMutationDiagnostics = (paths: readonly string[]) => Promise<unknown | undefined>;
|
|
17
|
+
export type HazeToolContext = {
|
|
18
|
+
inFlightToolCalls?: Map<string, Promise<unknown>>;
|
|
19
|
+
completedToolCalls?: Map<string, number>;
|
|
20
|
+
mutationEpoch?: number;
|
|
21
|
+
failedMutationPaths?: Set<string>;
|
|
22
|
+
failedMutationReasons?: Map<string, ToolFailureReasonCode | undefined>;
|
|
23
|
+
pathsReadAfterFailedMutation?: Set<string>;
|
|
24
|
+
inFlightMutationPaths?: Set<string>;
|
|
25
|
+
loadedContextFilePaths?: Set<string>;
|
|
26
|
+
loadedContextFileSignatures?: Map<string, string>;
|
|
27
|
+
pendingContextFiles?: ContextFile[];
|
|
28
|
+
scopedContextDiscovery?: Promise<void>;
|
|
29
|
+
onContextFileRead?: (path: string) => void;
|
|
30
|
+
mutationPolicy?: WorkspaceMutationPolicy;
|
|
31
|
+
mutationOwner?: WorkspaceMutationOwner;
|
|
32
|
+
/** True in disposable worker contexts; background processes are main-turn-only. */
|
|
33
|
+
isSubagent?: boolean;
|
|
34
|
+
/** Real paths the user mentioned this turn; read tools may escape workspace for them. */
|
|
35
|
+
blessedPaths?: readonly BlessedPath[];
|
|
36
|
+
/** Runs LSP diagnostics after successful file mutations and embeds them in that tool result. */
|
|
37
|
+
postMutationDiagnostics?: PostMutationDiagnostics;
|
|
38
|
+
};
|
|
39
|
+
export declare function isHazeToolContext(value: unknown): value is HazeToolContext;
|
|
40
|
+
export declare function hazeContext(context: ToolExecutionContext): HazeToolContext | undefined;
|