@denizokcu/haze 0.6.0 → 0.8.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 +42 -7
- package/README.md +81 -34
- package/dist/cli/chat/TaskBar.d.ts +9 -0
- package/dist/cli/chat/TaskBar.js +40 -0
- package/dist/cli/chat/chatMetrics.d.ts +11 -0
- package/dist/cli/chat/chatMetrics.js +50 -0
- package/dist/cli/chat/inputSuggestions.d.ts +16 -0
- package/dist/cli/chat/inputSuggestions.js +55 -0
- package/dist/cli/chat/messages.d.ts +9 -0
- package/dist/cli/chat/messages.js +76 -0
- package/dist/cli/chat/sessionRecorder.d.ts +12 -0
- package/dist/cli/chat/sessionRecorder.js +21 -0
- package/dist/cli/chat/startupInfo.d.ts +4 -0
- package/dist/cli/chat/startupInfo.js +53 -0
- package/dist/cli/chat/turnState.d.ts +5 -0
- package/dist/cli/chat/turnState.js +20 -0
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +331 -906
- package/dist/cli/commands/chatModes.d.ts +8 -0
- package/dist/cli/commands/chatModes.js +44 -0
- package/dist/cli/commands/commandHelp.d.ts +6 -0
- package/dist/cli/commands/commandHelp.js +25 -0
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +41 -267
- package/dist/cli/commands/formatters.d.ts +6 -0
- package/dist/cli/commands/formatters.js +50 -4
- package/dist/cli/commands/initCommand.d.ts +2 -0
- package/dist/cli/commands/initCommand.js +19 -0
- package/dist/cli/commands/logsCommand.d.ts +2 -0
- package/dist/cli/commands/logsCommand.js +63 -0
- package/dist/cli/commands/lspWizard.d.ts +14 -0
- package/dist/cli/commands/lspWizard.js +44 -0
- package/dist/cli/commands/mcpWizard.d.ts +15 -0
- package/dist/cli/commands/mcpWizard.js +69 -0
- package/dist/cli/commands/modelCommand.d.ts +2 -0
- package/dist/cli/commands/modelCommand.js +36 -0
- package/dist/cli/commands/providerWizard.d.ts +30 -0
- package/dist/cli/commands/providerWizard.js +114 -0
- package/dist/cli/commands/runCommand.d.ts +16 -0
- package/dist/cli/commands/runCommand.js +170 -0
- package/dist/cli/commands/settingsSummary.d.ts +3 -0
- package/dist/cli/commands/settingsSummary.js +40 -0
- package/dist/cli/commands/skillConfirmRemove.d.ts +11 -0
- package/dist/cli/commands/skillConfirmRemove.js +19 -0
- package/dist/cli/commands/skillCreation.d.ts +12 -0
- package/dist/cli/commands/skillCreation.js +14 -0
- package/dist/cli/commands/skillWizard.d.ts +15 -0
- package/dist/cli/commands/skillWizard.js +38 -0
- package/dist/cli/commands/streaming/assistantText.d.ts +17 -0
- package/dist/cli/commands/streaming/assistantText.js +115 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +55 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +102 -0
- package/dist/cli/commands/streaming/toolResultState.d.ts +13 -0
- package/dist/cli/commands/streaming/toolResultState.js +25 -0
- package/dist/cli/commands/streaming/turnRuntime.d.ts +78 -0
- package/dist/cli/commands/streaming/turnRuntime.js +86 -0
- package/dist/cli/commands/streaming.d.ts +9 -25
- package/dist/cli/commands/streaming.js +109 -363
- package/dist/cli/commands/wizardActions.d.ts +40 -0
- package/dist/cli/commands/wizardActions.js +40 -0
- package/dist/cli/commands/wizardInput.d.ts +4 -0
- package/dist/cli/commands/wizardInput.js +19 -0
- package/dist/cli/commands/wizardPrompts.d.ts +22 -0
- package/dist/cli/commands/wizardPrompts.js +52 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +23 -0
- package/dist/cli/commands/wizardSuggestions.js +139 -0
- package/dist/cli/index.js +62 -4
- package/dist/config/contextFiles.d.ts +8 -1
- package/dist/config/contextFiles.js +25 -12
- package/dist/config/lspSettings.js +3 -6
- package/dist/config/mcpSettings.js +5 -5
- package/dist/config/providers.js +8 -12
- package/dist/config/settings.d.ts +1 -0
- package/dist/config/settings.js +54 -2
- package/dist/config/skillSettings.js +4 -3
- package/dist/core/agent/budgets.d.ts +6 -0
- package/dist/core/agent/budgets.js +6 -0
- package/dist/core/agent/compaction.js +3 -3
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +1 -7
- package/dist/core/agent/requestAssembly.js +40 -5
- package/dist/core/agent/toolOutputStore.js +5 -4
- package/dist/core/agent/toolResults.d.ts +31 -0
- package/dist/core/agent/toolResults.js +42 -0
- package/dist/core/agent/turnPolicy.d.ts +8 -0
- package/dist/core/agent/turnPolicy.js +23 -0
- package/dist/core/agent/workState.d.ts +18 -5
- package/dist/core/agent/workState.js +39 -20
- package/dist/core/bashOutput/reducers/content.d.ts +1 -0
- package/dist/core/bashOutput/reducers/content.js +1 -1
- package/dist/core/bashOutput/reducers/gh.d.ts +1 -0
- package/dist/core/bashOutput/reducers/gh.js +77 -0
- package/dist/core/bashOutput/registry.js +18 -8
- package/dist/core/goal/completionPolicy.js +1 -1
- package/dist/core/goal/sessionGoal.d.ts +6 -30
- package/dist/core/goal/sessionGoal.js +3 -68
- package/dist/core/safety/bashClassifier.js +30 -0
- package/dist/core/safety/urlGuard.d.ts +1 -0
- package/dist/core/safety/urlGuard.js +6 -1
- package/dist/core/session/sessionSlimming.d.ts +5 -0
- package/dist/core/session/sessionSlimming.js +78 -0
- package/dist/core/session/sessionStore.d.ts +23 -3
- package/dist/core/session/sessionStore.js +30 -10
- package/dist/core/subagent/subagentRunner.d.ts +258 -5
- package/dist/core/subagent/subagentRunner.js +14 -18
- package/dist/core/toolOutput/reduction.d.ts +2 -0
- package/dist/core/toolOutput/reduction.js +12 -0
- package/dist/core/validation/outputParser.js +5 -3
- package/dist/llm/capabilities.d.ts +12 -0
- package/dist/llm/capabilities.js +10 -0
- package/dist/llm/client.d.ts +3 -2
- package/dist/llm/client.js +26 -4
- package/dist/llm/hazeTools.d.ts +7710 -366
- package/dist/llm/hazeTools.js +46 -567
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp.d.ts +46 -1
- package/dist/llm/lsp.js +19 -10
- package/dist/llm/lspTools.d.ts +2310 -119
- package/dist/llm/mcp.js +9 -0
- package/dist/llm/requestContext.js +7 -22
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +3 -3
- package/dist/llm/tools/bashTool.d.ts +251 -0
- package/dist/llm/tools/bashTool.js +82 -0
- package/dist/llm/tools/editMatch.d.ts +55 -0
- package/dist/llm/tools/editMatch.js +99 -0
- package/dist/llm/tools/failures.d.ts +36 -0
- package/dist/llm/tools/failures.js +38 -0
- package/dist/llm/tools/fetchTool.d.ts +1201 -0
- package/dist/llm/tools/fetchTool.js +46 -0
- package/dist/llm/tools/fileToolShared.d.ts +10 -0
- package/dist/llm/tools/fileToolShared.js +43 -0
- package/dist/llm/tools/grepParse.d.ts +13 -0
- package/dist/llm/tools/grepParse.js +67 -0
- package/dist/llm/tools/outputCap.d.ts +53 -0
- package/dist/llm/tools/outputCap.js +67 -0
- package/dist/llm/tools/storedOutputTool.d.ts +351 -0
- package/dist/llm/tools/storedOutputTool.js +17 -0
- package/dist/llm/tools/taskTool.d.ts +629 -0
- package/dist/llm/tools/taskTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +74 -0
- package/dist/llm/tools/toolContext.js +196 -0
- package/dist/llm/tools/workspaceFile.d.ts +33 -0
- package/dist/llm/tools/workspaceFile.js +27 -0
- package/dist/llm/webFetch.d.ts +13 -1
- package/dist/llm/webFetch.js +122 -28
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +8 -8
- package/dist/ui/components/TextInput.d.ts +7 -0
- package/dist/ui/components/TextInput.js +10 -98
- package/dist/ui/inputBuffer.d.ts +28 -0
- package/dist/ui/inputBuffer.js +99 -0
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/collections.js +9 -0
- package/dist/utils/modelName.d.ts +2 -0
- package/dist/utils/modelName.js +15 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +40 -0
- package/examples/skills/files/SKILL.md +1 -1
- package/package.json +14 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { streamText } from 'ai';
|
|
2
2
|
import { type PromptSession } from '../../llm/systemPrompt.js';
|
|
3
|
+
import { toolOnlyStepCount } from '../agent/turnPolicy.js';
|
|
3
4
|
import type { ContextFile } from '../../config/contextFiles.js';
|
|
4
5
|
export interface SubagentResult {
|
|
5
6
|
status: 'ok' | 'error' | 'timeout' | 'cancelled';
|
|
@@ -17,6 +18,11 @@ export interface SubagentResult {
|
|
|
17
18
|
durationMs: number;
|
|
18
19
|
error?: string;
|
|
19
20
|
}
|
|
21
|
+
declare function toolSummary(output: unknown): string;
|
|
22
|
+
export declare const internals: {
|
|
23
|
+
toolSummary: typeof toolSummary;
|
|
24
|
+
toolOnlyStepCount: typeof toolOnlyStepCount;
|
|
25
|
+
};
|
|
20
26
|
export declare function runSubagent(task: string, options: {
|
|
21
27
|
model: Parameters<typeof streamText>[0]['model'];
|
|
22
28
|
contextFiles: ContextFile[];
|
|
@@ -29,8 +35,255 @@ export declare function createSubagentTool(options: {
|
|
|
29
35
|
model: Parameters<typeof streamText>[0]['model'];
|
|
30
36
|
contextFiles: ContextFile[];
|
|
31
37
|
session?: PromptSession;
|
|
32
|
-
}):
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
}): ({
|
|
39
|
+
title?: string;
|
|
40
|
+
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
41
|
+
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
42
|
+
inputSchema: import("ai").FlexibleSchema<{
|
|
43
|
+
task: string;
|
|
44
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
45
|
+
maxSteps?: number | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
|
|
48
|
+
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
49
|
+
task: string;
|
|
50
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
51
|
+
maxSteps?: number | undefined;
|
|
52
|
+
}, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
|
|
53
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
54
|
+
onInputDelta?: ((options: {
|
|
55
|
+
inputTextDelta: string;
|
|
56
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
57
|
+
onInputAvailable?: ((options: {
|
|
58
|
+
input: {
|
|
59
|
+
task: string;
|
|
60
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
61
|
+
maxSteps?: number | undefined;
|
|
62
|
+
};
|
|
63
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
64
|
+
toModelOutput?: ((options: {
|
|
65
|
+
toolCallId: string;
|
|
66
|
+
input: {
|
|
67
|
+
task: string;
|
|
68
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
69
|
+
maxSteps?: number | undefined;
|
|
70
|
+
};
|
|
71
|
+
output: NoInfer<SubagentResult>;
|
|
72
|
+
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
73
|
+
} & {
|
|
74
|
+
outputSchema?: import("ai").FlexibleSchema<SubagentResult> | undefined;
|
|
75
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
76
|
+
task: string;
|
|
77
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
78
|
+
maxSteps?: number | undefined;
|
|
79
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
80
|
+
} & {
|
|
81
|
+
description?: string | ((options: {
|
|
82
|
+
context: NoInfer<import("@ai-sdk/provider-utils").Context>;
|
|
83
|
+
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
84
|
+
}) => string) | undefined;
|
|
85
|
+
strict?: boolean;
|
|
86
|
+
inputExamples?: {
|
|
87
|
+
input: NoInfer<{
|
|
88
|
+
task: string;
|
|
89
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
90
|
+
maxSteps?: number | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
id?: never;
|
|
94
|
+
isProviderExecuted?: never;
|
|
95
|
+
args?: never;
|
|
96
|
+
supportsDeferredResults?: never;
|
|
97
|
+
} & {
|
|
98
|
+
type?: undefined | "function";
|
|
99
|
+
} & {
|
|
100
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
101
|
+
task: string;
|
|
102
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
103
|
+
maxSteps?: number | undefined;
|
|
104
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
105
|
+
}) | ({
|
|
106
|
+
title?: string;
|
|
107
|
+
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
108
|
+
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
109
|
+
inputSchema: import("ai").FlexibleSchema<{
|
|
110
|
+
task: string;
|
|
111
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
112
|
+
maxSteps?: number | undefined;
|
|
113
|
+
}>;
|
|
114
|
+
contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
|
|
115
|
+
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
116
|
+
task: string;
|
|
117
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
118
|
+
maxSteps?: number | undefined;
|
|
119
|
+
}, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
|
|
120
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
121
|
+
onInputDelta?: ((options: {
|
|
122
|
+
inputTextDelta: string;
|
|
123
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
124
|
+
onInputAvailable?: ((options: {
|
|
125
|
+
input: {
|
|
126
|
+
task: string;
|
|
127
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
128
|
+
maxSteps?: number | undefined;
|
|
129
|
+
};
|
|
130
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
131
|
+
toModelOutput?: ((options: {
|
|
132
|
+
toolCallId: string;
|
|
133
|
+
input: {
|
|
134
|
+
task: string;
|
|
135
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
136
|
+
maxSteps?: number | undefined;
|
|
137
|
+
};
|
|
138
|
+
output: NoInfer<SubagentResult>;
|
|
139
|
+
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
140
|
+
} & {
|
|
141
|
+
outputSchema?: import("ai").FlexibleSchema<SubagentResult> | undefined;
|
|
142
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
143
|
+
task: string;
|
|
144
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
145
|
+
maxSteps?: number | undefined;
|
|
146
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
147
|
+
} & {
|
|
148
|
+
description?: string | ((options: {
|
|
149
|
+
context: NoInfer<import("@ai-sdk/provider-utils").Context>;
|
|
150
|
+
experimental_sandbox?: import("ai").Experimental_SandboxSession;
|
|
151
|
+
}) => string) | undefined;
|
|
152
|
+
strict?: boolean;
|
|
153
|
+
inputExamples?: {
|
|
154
|
+
input: NoInfer<{
|
|
155
|
+
task: string;
|
|
156
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
157
|
+
maxSteps?: number | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
}[] | undefined;
|
|
160
|
+
id?: never;
|
|
161
|
+
isProviderExecuted?: never;
|
|
162
|
+
args?: never;
|
|
163
|
+
supportsDeferredResults?: never;
|
|
164
|
+
} & {
|
|
165
|
+
type: "dynamic";
|
|
166
|
+
} & {
|
|
167
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
168
|
+
task: string;
|
|
169
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
170
|
+
maxSteps?: number | undefined;
|
|
171
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
172
|
+
}) | ({
|
|
173
|
+
title?: string;
|
|
174
|
+
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
175
|
+
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
176
|
+
inputSchema: import("ai").FlexibleSchema<{
|
|
177
|
+
task: string;
|
|
178
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
179
|
+
maxSteps?: number | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
|
|
182
|
+
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
183
|
+
task: string;
|
|
184
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
185
|
+
maxSteps?: number | undefined;
|
|
186
|
+
}, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
|
|
187
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
188
|
+
onInputDelta?: ((options: {
|
|
189
|
+
inputTextDelta: string;
|
|
190
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
191
|
+
onInputAvailable?: ((options: {
|
|
192
|
+
input: {
|
|
193
|
+
task: string;
|
|
194
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
195
|
+
maxSteps?: number | undefined;
|
|
196
|
+
};
|
|
197
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
198
|
+
toModelOutput?: ((options: {
|
|
199
|
+
toolCallId: string;
|
|
200
|
+
input: {
|
|
201
|
+
task: string;
|
|
202
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
203
|
+
maxSteps?: number | undefined;
|
|
204
|
+
};
|
|
205
|
+
output: NoInfer<SubagentResult>;
|
|
206
|
+
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
207
|
+
} & {
|
|
208
|
+
outputSchema?: import("ai").FlexibleSchema<SubagentResult> | undefined;
|
|
209
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
210
|
+
task: string;
|
|
211
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
212
|
+
maxSteps?: number | undefined;
|
|
213
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
214
|
+
} & {
|
|
215
|
+
type: "provider";
|
|
216
|
+
id: `${string}.${string}`;
|
|
217
|
+
args: Record<string, unknown>;
|
|
218
|
+
description?: never;
|
|
219
|
+
strict?: never;
|
|
220
|
+
inputExamples?: never;
|
|
221
|
+
} & {
|
|
222
|
+
isProviderExecuted: false;
|
|
223
|
+
supportsDeferredResults?: never;
|
|
224
|
+
} & {
|
|
225
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
226
|
+
task: string;
|
|
227
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
228
|
+
maxSteps?: number | undefined;
|
|
229
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
230
|
+
}) | ({
|
|
231
|
+
title?: string;
|
|
232
|
+
providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
|
|
233
|
+
metadata?: import("@ai-sdk/provider").JSONObject;
|
|
234
|
+
inputSchema: import("ai").FlexibleSchema<{
|
|
235
|
+
task: string;
|
|
236
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
237
|
+
maxSteps?: number | undefined;
|
|
238
|
+
}>;
|
|
239
|
+
contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
|
|
240
|
+
needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
|
|
241
|
+
task: string;
|
|
242
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
243
|
+
maxSteps?: number | undefined;
|
|
244
|
+
}, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
|
|
245
|
+
onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
246
|
+
onInputDelta?: ((options: {
|
|
247
|
+
inputTextDelta: string;
|
|
248
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
249
|
+
onInputAvailable?: ((options: {
|
|
250
|
+
input: {
|
|
251
|
+
task: string;
|
|
252
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
253
|
+
maxSteps?: number | undefined;
|
|
254
|
+
};
|
|
255
|
+
} & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
|
|
256
|
+
toModelOutput?: ((options: {
|
|
257
|
+
toolCallId: string;
|
|
258
|
+
input: {
|
|
259
|
+
task: string;
|
|
260
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
261
|
+
maxSteps?: number | undefined;
|
|
262
|
+
};
|
|
263
|
+
output: NoInfer<SubagentResult>;
|
|
264
|
+
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
265
|
+
} & {
|
|
266
|
+
outputSchema?: import("ai").FlexibleSchema<SubagentResult> | undefined;
|
|
267
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
268
|
+
task: string;
|
|
269
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
270
|
+
maxSteps?: number | undefined;
|
|
271
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
272
|
+
} & {
|
|
273
|
+
type: "provider";
|
|
274
|
+
id: `${string}.${string}`;
|
|
275
|
+
args: Record<string, unknown>;
|
|
276
|
+
description?: never;
|
|
277
|
+
strict?: never;
|
|
278
|
+
inputExamples?: never;
|
|
279
|
+
} & {
|
|
280
|
+
isProviderExecuted: true;
|
|
281
|
+
supportsDeferredResults?: boolean;
|
|
282
|
+
} & {
|
|
283
|
+
execute: import("ai").ToolExecuteFunction<{
|
|
284
|
+
task: string;
|
|
285
|
+
tools?: ("listFiles" | "readFile" | "grep" | "replaceLines" | "writeFile" | "editFile" | "bash" | "fetch" | "readToolOutput")[] | undefined;
|
|
286
|
+
maxSteps?: number | undefined;
|
|
287
|
+
}, SubagentResult, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
288
|
+
});
|
|
289
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { streamText,
|
|
1
|
+
import { streamText, isStepCount, tool } from 'ai';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { buildSubagentPrompt } from '../../llm/systemPrompt.js';
|
|
4
4
|
import { hazeTools } from '../../llm/hazeTools.js';
|
|
5
|
+
import { toolsContextFor } from '../../llm/tools/toolContext.js';
|
|
6
|
+
import { toolOnlyStepCount } from '../agent/turnPolicy.js';
|
|
5
7
|
const ALL_TOOLS = ['listFiles', 'readFile', 'grep', 'bash', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'fetch'];
|
|
6
8
|
const STEP_LIMIT = 25;
|
|
7
9
|
const MAX_SUMMARY = 4000;
|
|
@@ -20,15 +22,7 @@ function toolSummary(output) {
|
|
|
20
22
|
return `failed: ${o.error.slice(0, 120)}`;
|
|
21
23
|
return 'completed';
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
let count = 0;
|
|
25
|
-
for (const step of [...steps].reverse()) {
|
|
26
|
-
if (step.toolCalls.length === 0 || step.text.trim().length > 0)
|
|
27
|
-
break;
|
|
28
|
-
count += 1;
|
|
29
|
-
}
|
|
30
|
-
return count;
|
|
31
|
-
}
|
|
25
|
+
export const internals = { toolSummary, toolOnlyStepCount };
|
|
32
26
|
export async function runSubagent(task, options) {
|
|
33
27
|
const start = performance.now();
|
|
34
28
|
const toolNames = (options.allowedTools ?? ALL_TOOLS).filter(t => ALL_TOOLS.includes(t));
|
|
@@ -40,6 +34,7 @@ export async function runSubagent(task, options) {
|
|
|
40
34
|
scopedTools[name] = hazeTools[key];
|
|
41
35
|
}
|
|
42
36
|
const toolCallLog = [];
|
|
37
|
+
const toolExecutionContext = { inFlightToolCalls: new Map() };
|
|
43
38
|
let tokensIn = 0;
|
|
44
39
|
let tokensOut = 0;
|
|
45
40
|
let lastStep = 0;
|
|
@@ -48,12 +43,13 @@ export async function runSubagent(task, options) {
|
|
|
48
43
|
const result = streamText({
|
|
49
44
|
model: options.model,
|
|
50
45
|
maxOutputTokens: 4096,
|
|
51
|
-
|
|
46
|
+
instructions: buildSubagentPrompt(options.contextFiles, options.session),
|
|
52
47
|
messages: [{ role: 'user', content: task }],
|
|
53
48
|
tools: scopedTools,
|
|
54
|
-
stopWhen:
|
|
49
|
+
stopWhen: isStepCount(maxSteps),
|
|
55
50
|
abortSignal: options.abortSignal,
|
|
56
|
-
|
|
51
|
+
runtimeContext: toolExecutionContext,
|
|
52
|
+
toolsContext: toolsContextFor(scopedTools, toolExecutionContext),
|
|
57
53
|
prepareStep({ steps }) {
|
|
58
54
|
const calls = steps.flatMap(step => step.toolCalls);
|
|
59
55
|
const consecutiveToolOnly = toolOnlyStepCount(steps);
|
|
@@ -67,23 +63,23 @@ export async function runSubagent(task, options) {
|
|
|
67
63
|
}
|
|
68
64
|
return undefined;
|
|
69
65
|
},
|
|
70
|
-
|
|
66
|
+
onStepEnd({ stepNumber }) {
|
|
71
67
|
lastStep = stepNumber;
|
|
72
68
|
},
|
|
73
|
-
|
|
69
|
+
onEnd(event) {
|
|
74
70
|
if (event.usage) {
|
|
75
71
|
tokensIn = event.usage.inputTokens ?? 0;
|
|
76
72
|
tokensOut = event.usage.outputTokens ?? 0;
|
|
77
73
|
}
|
|
78
74
|
},
|
|
79
|
-
|
|
75
|
+
onToolExecutionEnd(event) {
|
|
80
76
|
if (!event.toolCall)
|
|
81
77
|
return;
|
|
82
78
|
totalToolCalls += 1;
|
|
83
79
|
toolCallLog.push({
|
|
84
80
|
name: event.toolCall.toolName,
|
|
85
|
-
summary: toolSummary(event.output),
|
|
86
|
-
durationMs: event.
|
|
81
|
+
summary: event.toolOutput.type === 'tool-result' ? toolSummary(event.toolOutput.output) : `failed: ${String(event.toolOutput.error).slice(0, 120)}`,
|
|
82
|
+
durationMs: event.toolExecutionMs,
|
|
87
83
|
});
|
|
88
84
|
},
|
|
89
85
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type ReductionPressure = 'conservative' | 'normal' | 'aggressive';
|
|
2
|
+
export declare const PROCESSING_OUTPUT_CHAR_LIMIT = 200000;
|
|
2
3
|
export type ReductionContentKind = 'validation' | 'log' | 'search' | 'diff' | 'json' | 'table' | 'web' | 'source-outline' | 'generic';
|
|
3
4
|
export type ReductionParseTier = 'full' | 'degraded' | 'passthrough';
|
|
4
5
|
export interface ReductionMetrics {
|
|
@@ -20,6 +21,7 @@ export interface ToolOutputReductionMetadata extends ReductionMetrics {
|
|
|
20
21
|
warning?: string;
|
|
21
22
|
}
|
|
22
23
|
export declare function estimateReductionTokens(text: string): number;
|
|
24
|
+
export declare function capOutputForProcessing(text: string, maxChars?: number): string;
|
|
23
25
|
export declare function reductionMetrics(raw: string, returned: string): ReductionMetrics;
|
|
24
26
|
export declare function retrievalHint(handle: string): string;
|
|
25
27
|
export declare function isInflating(raw: string, returned: string): boolean;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
export const PROCESSING_OUTPUT_CHAR_LIMIT = 200_000;
|
|
2
|
+
const PROCESSING_TRUNCATION_MARKER = '\n[... output truncated for processing ...]\n';
|
|
1
3
|
export function estimateReductionTokens(text) {
|
|
2
4
|
return Math.ceil(text.length / 4);
|
|
3
5
|
}
|
|
6
|
+
export function capOutputForProcessing(text, maxChars = PROCESSING_OUTPUT_CHAR_LIMIT) {
|
|
7
|
+
if (text.length <= maxChars)
|
|
8
|
+
return text;
|
|
9
|
+
if (maxChars <= PROCESSING_TRUNCATION_MARKER.length)
|
|
10
|
+
return text.slice(0, maxChars);
|
|
11
|
+
const keepChars = maxChars - PROCESSING_TRUNCATION_MARKER.length;
|
|
12
|
+
const headChars = Math.floor(keepChars / 2);
|
|
13
|
+
const tailChars = keepChars - headChars;
|
|
14
|
+
return `${text.slice(0, headChars)}${PROCESSING_TRUNCATION_MARKER}${text.slice(-tailChars)}`;
|
|
15
|
+
}
|
|
4
16
|
export function reductionMetrics(raw, returned) {
|
|
5
17
|
const rawTokensEstimate = estimateReductionTokens(raw);
|
|
6
18
|
const returnedTokensEstimate = estimateReductionTokens(returned);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { capOutputForProcessing } from '../toolOutput/reduction.js';
|
|
1
2
|
function uniq(values) {
|
|
2
3
|
return [...new Set(values.filter(Boolean))];
|
|
3
4
|
}
|
|
@@ -14,13 +15,14 @@ function inferKind(command, classification) {
|
|
|
14
15
|
return 'generic';
|
|
15
16
|
}
|
|
16
17
|
export function parseValidationOutput(input) {
|
|
17
|
-
const text = `${input.stdout}\n${input.stderr}`;
|
|
18
|
+
const text = `${capOutputForProcessing(input.stdout)}\n${capOutputForProcessing(input.stderr)}`;
|
|
18
19
|
const lines = text.split(/\r?\n/);
|
|
19
20
|
const diagnostics = [];
|
|
20
21
|
const failedTests = [];
|
|
21
22
|
const failedFiles = [];
|
|
22
23
|
const kind = inferKind(input.command, input.classification);
|
|
23
|
-
for (
|
|
24
|
+
for (let index = 0; index < lines.length; index++) {
|
|
25
|
+
const line = lines[index];
|
|
24
26
|
const ts = line.match(/^(.+?\.(?:ts|tsx|js|jsx|mts|cts))\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(.+)$/);
|
|
25
27
|
if (ts) {
|
|
26
28
|
const [, file, lineNo, column, severity, message] = ts;
|
|
@@ -31,7 +33,7 @@ export function parseValidationOutput(input) {
|
|
|
31
33
|
const eslint = line.match(/^(.+?\.(?:ts|tsx|js|jsx|mts|cts))\s*$/);
|
|
32
34
|
if (eslint) {
|
|
33
35
|
const currentFile = eslint[1] ?? '';
|
|
34
|
-
const next = lines[
|
|
36
|
+
const next = lines[index + 1];
|
|
35
37
|
if (next && /^\s*\d+:\d+\s+/.test(next))
|
|
36
38
|
failedFiles.push(currentFile);
|
|
37
39
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolSet } from 'ai';
|
|
2
|
+
import type { ToolCategory } from './requestContext.js';
|
|
3
|
+
export interface LoadedCapability {
|
|
4
|
+
category: ToolCategory;
|
|
5
|
+
tools: ToolSet;
|
|
6
|
+
}
|
|
7
|
+
export declare function addCapabilityTools(input: {
|
|
8
|
+
availableTools: ToolSet;
|
|
9
|
+
toolCategories: Map<string, ToolCategory>;
|
|
10
|
+
loaded: LoadedCapability;
|
|
11
|
+
skipCollisions?: boolean;
|
|
12
|
+
}): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function addCapabilityTools(input) {
|
|
2
|
+
const existing = new Set(Object.keys(input.availableTools));
|
|
3
|
+
for (const [name, value] of Object.entries(input.loaded.tools)) {
|
|
4
|
+
if (input.skipCollisions && existing.has(name))
|
|
5
|
+
continue;
|
|
6
|
+
input.toolCategories.set(name, input.loaded.category);
|
|
7
|
+
input.availableTools[name] = value;
|
|
8
|
+
existing.add(name);
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/llm/client.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export interface ModelRuntimeConfig {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function modelWithConfig(session?: {
|
|
17
17
|
cwd?: string;
|
|
18
|
+
modelSelector?: string;
|
|
18
19
|
}): Promise<{
|
|
19
|
-
model: import("@ai-sdk/provider").
|
|
20
|
+
model: import("@ai-sdk/provider").LanguageModelV4;
|
|
20
21
|
config: {
|
|
21
22
|
providerName: string;
|
|
22
23
|
baseURL: string;
|
|
@@ -25,7 +26,7 @@ export declare function modelWithConfig(session?: {
|
|
|
25
26
|
capabilities: ProviderCapabilities;
|
|
26
27
|
};
|
|
27
28
|
} | undefined>;
|
|
28
|
-
export declare function model(): Promise<import("@ai-sdk/provider").
|
|
29
|
+
export declare function model(): Promise<import("@ai-sdk/provider").LanguageModelV4 | undefined>;
|
|
29
30
|
export declare function cacheKeyFor(name: string, cwd?: string): string;
|
|
30
31
|
export declare function providerRequestSettings(config: ModelRuntimeConfig): {
|
|
31
32
|
headers?: {
|
package/dist/llm/client.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
3
|
import { readSettings } from '../config/settings.js';
|
|
4
|
-
import { activeModel } from '../config/providers.js';
|
|
4
|
+
import { activeModel, resolveModelSelector } from '../config/providers.js';
|
|
5
|
+
const HAZE_SITE_URL = 'https://denizokcu.github.io/haze/';
|
|
6
|
+
const HAZE_TITLE = 'Haze';
|
|
7
|
+
function isOpenRouter(providerName, baseURL) {
|
|
8
|
+
return providerName === 'openrouter' || /openrouter\.ai/i.test(baseURL);
|
|
9
|
+
}
|
|
10
|
+
function openRouterHeaders(providerName, baseURL) {
|
|
11
|
+
if (!isOpenRouter(providerName, baseURL))
|
|
12
|
+
return undefined;
|
|
13
|
+
return {
|
|
14
|
+
'HTTP-Referer': HAZE_SITE_URL,
|
|
15
|
+
'X-Title': HAZE_TITLE,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
5
18
|
function capabilities(providerName, baseURL) {
|
|
6
19
|
const directOpenAI = providerName === 'openai' || /api\.openai\.com/i.test(baseURL);
|
|
7
|
-
const openRouter = providerName
|
|
20
|
+
const openRouter = isOpenRouter(providerName, baseURL);
|
|
8
21
|
return {
|
|
9
22
|
reportsCacheUsage: directOpenAI || openRouter,
|
|
10
23
|
supportsPromptCacheKey: directOpenAI,
|
|
@@ -16,7 +29,16 @@ function capabilities(providerName, baseURL) {
|
|
|
16
29
|
}
|
|
17
30
|
export async function modelWithConfig(session) {
|
|
18
31
|
const settings = await readSettings();
|
|
19
|
-
const
|
|
32
|
+
const override = session?.modelSelector?.trim();
|
|
33
|
+
let selection;
|
|
34
|
+
if (override) {
|
|
35
|
+
const resolved = resolveModelSelector(settings, override);
|
|
36
|
+
if (resolved.status === 'found')
|
|
37
|
+
selection = { provider: resolved.provider, model: resolved.model };
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
selection = activeModel(settings);
|
|
41
|
+
}
|
|
20
42
|
if (!selection)
|
|
21
43
|
return undefined;
|
|
22
44
|
const baseURL = selection.provider.url;
|
|
@@ -25,7 +47,7 @@ export async function modelWithConfig(session) {
|
|
|
25
47
|
const cacheSeed = session?.cwd ?? process.cwd();
|
|
26
48
|
const cacheKey = crypto.createHash('sha256').update(`${cacheSeed}\0${name}`).digest('hex').slice(0, 32);
|
|
27
49
|
return {
|
|
28
|
-
model: createOpenAI({ apiKey, baseURL }).chat(name),
|
|
50
|
+
model: createOpenAI({ apiKey, baseURL, headers: openRouterHeaders(selection.provider.name, baseURL) }).chat(name),
|
|
29
51
|
config: {
|
|
30
52
|
providerName: selection.provider.name,
|
|
31
53
|
baseURL,
|