@denizokcu/haze 0.10.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -1
- package/README.md +77 -27
- package/SECURITY.md +22 -0
- package/bin/haze.js +102 -1
- package/dist/buildInfo.json +7 -0
- package/dist/cli/chat/TaskBar.d.ts +2 -1
- package/dist/cli/chat/TaskBar.js +7 -4
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/contextReport.js +2 -0
- package/dist/cli/chat/fileMentionSuggestions.js +3 -2
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +9 -41
- package/dist/cli/chat/liveRegion.d.ts +25 -0
- package/dist/cli/chat/liveRegion.js +48 -0
- package/dist/cli/chat/messages.d.ts +33 -4
- package/dist/cli/chat/messages.js +218 -35
- package/dist/cli/chat/sessionLifecycle.d.ts +11 -1
- package/dist/cli/chat/sessionLifecycle.js +64 -14
- package/dist/cli/chat/sessionRecorder.js +75 -7
- package/dist/cli/chat/startupInfo.d.ts +0 -1
- package/dist/cli/chat/startupInfo.js +11 -15
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +349 -133
- package/dist/cli/commands/chat.d.ts +5 -0
- package/dist/cli/commands/chat.js +216 -172
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/commands.d.ts +2 -0
- package/dist/cli/commands/commands.js +10 -5
- package/dist/cli/commands/doctor.d.ts +19 -0
- package/dist/cli/commands/doctor.js +76 -0
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +8 -25
- package/dist/cli/commands/ndjsonSink.d.ts +23 -0
- package/dist/cli/commands/ndjsonSink.js +38 -0
- package/dist/cli/commands/providerWizard.d.ts +9 -2
- package/dist/cli/commands/providerWizard.js +39 -7
- package/dist/cli/commands/runCommand.d.ts +3 -0
- package/dist/cli/commands/runCommand.js +117 -11
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +25 -0
- package/dist/cli/commands/streaming/abortCause.js +16 -0
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/assistantText.js +9 -2
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
- package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +130 -0
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +16 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +80 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -1
- package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -4
- package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
- package/dist/cli/commands/streaming/toolResultState.js +29 -7
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +65 -9
- package/dist/cli/commands/streaming.js +133 -430
- package/dist/cli/commands/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +68 -22
- package/dist/cli/terminalTitle.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +36 -0
- package/dist/config/modelDiscovery.js +164 -1
- package/dist/config/privateStorage.js +28 -2
- package/dist/config/providerAuth.d.ts +14 -0
- package/dist/config/providerAuth.js +49 -0
- package/dist/config/providerPresets.d.ts +39 -7
- package/dist/config/providerPresets.js +371 -100
- package/dist/config/providers.js +2 -0
- package/dist/config/settings.d.ts +43 -0
- package/dist/config/settings.js +12 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +73 -1
- package/dist/core/agent/budgets.js +94 -1
- package/dist/core/agent/compaction.d.ts +38 -0
- package/dist/core/agent/compaction.js +92 -17
- package/dist/core/agent/completionController.d.ts +224 -0
- package/dist/core/agent/completionController.js +296 -0
- package/dist/core/agent/contextBudget.d.ts +36 -2
- package/dist/core/agent/contextBudget.js +62 -9
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +78 -0
- package/dist/core/agent/goalPolicy.d.ts +47 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/reasoningPolicy.d.ts +31 -0
- package/dist/core/agent/reasoningPolicy.js +27 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +27 -0
- package/dist/core/agent/toolCapabilities.js +58 -0
- package/dist/core/agent/toolOutputStore.d.ts +8 -0
- package/dist/core/agent/toolOutputStore.js +11 -11
- package/dist/core/agent/toolResults.d.ts +12 -0
- package/dist/core/agent/toolResults.js +38 -0
- package/dist/core/agent/turnPolicy.d.ts +11 -0
- package/dist/core/agent/turnPolicy.js +19 -0
- package/dist/core/agent/workState.d.ts +81 -3
- package/dist/core/agent/workState.js +176 -10
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +27 -0
- package/dist/core/deadline.js +74 -0
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +8 -1
- package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
- package/dist/core/persistence/orderedFileWriter.js +16 -2
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +15 -10
- package/dist/core/process/runBoundedProcess.d.ts +8 -2
- package/dist/core/process/runBoundedProcess.js +15 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/missingExecutable.d.ts +42 -0
- package/dist/core/safety/missingExecutable.js +77 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +38 -0
- package/dist/core/session/sessionStore.js +242 -59
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +6 -14
- package/dist/core/subagent/contracts.js +4 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
- package/dist/core/subagent/subagentCoordinator.js +32 -2
- package/dist/core/subagent/subagentRunner.js +19 -40
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.d.ts +17 -1
- package/dist/llm/client.js +86 -14
- package/dist/llm/hazeTools.d.ts +693 -204
- package/dist/llm/hazeTools.js +110 -28
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +5653 -33
- package/dist/llm/lspTools.js +152 -80
- package/dist/llm/openaiCodex.d.ts +1 -0
- package/dist/llm/openaiCodex.js +43 -0
- package/dist/llm/openaiCodexOAuth.d.ts +51 -0
- package/dist/llm/openaiCodexOAuth.js +217 -0
- package/dist/llm/requestContext.d.ts +7 -0
- package/dist/llm/requestContext.js +30 -4
- package/dist/llm/systemPrompt.d.ts +12 -0
- package/dist/llm/systemPrompt.js +24 -11
- package/dist/llm/toolResultTypes.d.ts +7 -14
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +14 -9
- package/dist/llm/tools/editMatch.js +73 -1
- package/dist/llm/tools/failures.d.ts +2 -0
- package/dist/llm/tools/failures.js +1 -0
- package/dist/llm/tools/fetchTool.d.ts +16 -0
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +8 -5
- package/dist/llm/tools/fileToolShared.js +22 -23
- package/dist/llm/tools/gitIgnore.d.ts +42 -0
- package/dist/llm/tools/gitIgnore.js +247 -0
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +8 -0
- package/dist/llm/tools/readRecovery.js +135 -0
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +171 -123
- package/dist/llm/tools/{bashTool.js → shellTool.js} +20 -14
- package/dist/llm/tools/toolContext.d.ts +1 -1
- package/dist/llm/tools/toolContext.js +66 -37
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- package/dist/llm/webFetch.d.ts +18 -1
- package/dist/llm/webFetch.js +64 -97
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -1
- package/dist/ui/codeHighlight.d.ts +4 -0
- package/dist/ui/codeHighlight.js +31 -0
- package/dist/ui/components/Header.d.ts +1 -1
- package/dist/ui/components/MarkdownText.d.ts +16 -2
- package/dist/ui/components/MarkdownText.js +244 -34
- package/dist/ui/components/TextInput.d.ts +8 -1
- package/dist/ui/components/TextInput.js +6 -2
- package/dist/ui/theme.d.ts +4 -3
- package/dist/ui/theme.js +5 -4
- package/dist/utils/buildInfo.d.ts +97 -0
- package/dist/utils/buildInfo.js +244 -0
- package/dist/utils/fs.d.ts +11 -0
- package/dist/utils/fs.js +91 -26
- package/dist/utils/openPath.d.ts +2 -2
- package/dist/utils/openPath.js +19 -6
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +6 -2
- package/dist/utils/utf8.d.ts +22 -0
- package/dist/utils/utf8.js +54 -0
- package/dist/utils/version.d.ts +9 -3
- package/dist/utils/version.js +28 -2
- package/package.json +28 -21
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -10
- package/dist/cli/commands/streaming/turnOutcome.js +0 -13
- package/dist/cli/commands/wizardActions.d.ts +0 -46
- package/dist/cli/commands/wizardActions.js +0 -46
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -52
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -188
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.d.ts +0 -2
- package/dist/core/goal/completionPolicy.js +0 -7
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -18
- package/dist/core/limits/byteBudgets.js +0 -18
- package/dist/core/limits/textBudgets.d.ts +0 -23
- package/dist/core/limits/textBudgets.js +0 -23
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -129
- package/dist/llm/lsp.js +0 -307
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
|
@@ -11,7 +11,31 @@ export type NativeToolCall = {
|
|
|
11
11
|
toolName: string;
|
|
12
12
|
input: unknown;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
14
|
+
export type ToolDisplayDiffLine = {
|
|
15
|
+
type: 'add' | 'remove' | 'context';
|
|
16
|
+
oldLine?: number;
|
|
17
|
+
newLine?: number;
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'gap';
|
|
21
|
+
omittedLines: number;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'meta';
|
|
24
|
+
text: string;
|
|
25
|
+
};
|
|
26
|
+
export type ToolDisplayDiff = {
|
|
27
|
+
id: string;
|
|
28
|
+
path: string;
|
|
29
|
+
addedLines: number;
|
|
30
|
+
removedLines: number;
|
|
31
|
+
lines: ToolDisplayDiffLine[];
|
|
32
|
+
truncated?: boolean;
|
|
33
|
+
omittedLines?: number;
|
|
34
|
+
handle?: string;
|
|
35
|
+
complete?: boolean;
|
|
36
|
+
previousContentOmittedBytes?: number;
|
|
37
|
+
};
|
|
38
|
+
type ToolDisplayItem = {
|
|
15
39
|
id: string;
|
|
16
40
|
summary: string;
|
|
17
41
|
status: 'running' | 'success' | 'error';
|
|
@@ -20,6 +44,7 @@ export type ToolDisplayItem = {
|
|
|
20
44
|
finishedAt?: number;
|
|
21
45
|
durationMs?: number;
|
|
22
46
|
showResult?: boolean;
|
|
47
|
+
diff?: ToolDisplayDiff;
|
|
23
48
|
};
|
|
24
49
|
export interface ToolGroupRendererDeps {
|
|
25
50
|
addMessage: (msg: {
|
|
@@ -28,11 +53,13 @@ export interface ToolGroupRendererDeps {
|
|
|
28
53
|
text: string;
|
|
29
54
|
streaming: boolean;
|
|
30
55
|
toolCount: number;
|
|
56
|
+
toolDiffs?: ToolDisplayDiff[];
|
|
31
57
|
}) => void;
|
|
32
58
|
updateMessage: (id: string, update: {
|
|
33
59
|
text?: string;
|
|
34
60
|
streaming?: boolean;
|
|
35
61
|
toolCount?: number;
|
|
62
|
+
toolDiffs?: ToolDisplayDiff[];
|
|
36
63
|
}) => void;
|
|
37
64
|
debugLog: (line: string) => void;
|
|
38
65
|
onEvent?: AgentEventSink;
|
|
@@ -54,4 +81,7 @@ export interface ToolGroupRenderer {
|
|
|
54
81
|
/** Add a scoped context-file read to the active tool group display. */
|
|
55
82
|
addContextFileRead: (path: string) => void;
|
|
56
83
|
}
|
|
84
|
+
/** Extract the bounded structured diff returned by dedicated file mutation tools for rich terminal rendering. */
|
|
85
|
+
export declare function toolDiffFromResult(toolCall: NativeToolCall, output: unknown): ToolDisplayDiff | undefined;
|
|
57
86
|
export declare function createToolGroupRenderer(deps: ToolGroupRendererDeps): ToolGroupRenderer;
|
|
87
|
+
export {};
|
|
@@ -6,6 +6,51 @@ function logEntry(log, entry) {
|
|
|
6
6
|
void logAppend(log, entry).catch(() => undefined);
|
|
7
7
|
}
|
|
8
8
|
const createToolGroup = () => ({ id: `tools-${Date.now()}-${Math.random().toString(36).slice(2)}`, items: [], started: false, finalized: false });
|
|
9
|
+
function record(value) {
|
|
10
|
+
return typeof value === 'object' && value != null ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Extract the bounded structured diff returned by dedicated file mutation tools for rich terminal rendering. */
|
|
13
|
+
export function toolDiffFromResult(toolCall, output) {
|
|
14
|
+
if (toolCall.toolName !== 'editFile' && toolCall.toolName !== 'replaceLines' && toolCall.toolName !== 'writeFile')
|
|
15
|
+
return undefined;
|
|
16
|
+
const result = record(output);
|
|
17
|
+
if (!result || result.ok !== true || !Array.isArray(result.diff))
|
|
18
|
+
return undefined;
|
|
19
|
+
const lines = result.diff.flatMap((candidate) => {
|
|
20
|
+
const line = record(candidate);
|
|
21
|
+
if (!line)
|
|
22
|
+
return [];
|
|
23
|
+
if (line.type === 'gap' && typeof line.omittedLines === 'number' && line.omittedLines > 0) {
|
|
24
|
+
return [{ type: 'gap', omittedLines: line.omittedLines }];
|
|
25
|
+
}
|
|
26
|
+
if (line.type === 'meta' && typeof line.text === 'string')
|
|
27
|
+
return [{ type: 'meta', text: line.text }];
|
|
28
|
+
if ((line.type !== 'add' && line.type !== 'remove' && line.type !== 'context') || typeof line.text !== 'string')
|
|
29
|
+
return [];
|
|
30
|
+
return [{
|
|
31
|
+
type: line.type,
|
|
32
|
+
...(typeof line.oldLine === 'number' ? { oldLine: line.oldLine } : {}),
|
|
33
|
+
...(typeof line.newLine === 'number' ? { newLine: line.newLine } : {}),
|
|
34
|
+
text: line.text,
|
|
35
|
+
}];
|
|
36
|
+
});
|
|
37
|
+
if (lines.length === 0)
|
|
38
|
+
return undefined;
|
|
39
|
+
const input = record(toolCall.input);
|
|
40
|
+
const path = typeof result.path === 'string' ? result.path : typeof input?.path === 'string' ? input.path : 'edited file';
|
|
41
|
+
return {
|
|
42
|
+
id: toolCall.toolCallId,
|
|
43
|
+
path,
|
|
44
|
+
addedLines: typeof result.addedLines === 'number' ? result.addedLines : lines.filter(line => line.type === 'add').length,
|
|
45
|
+
removedLines: typeof result.removedLines === 'number' ? result.removedLines : lines.filter(line => line.type === 'remove').length,
|
|
46
|
+
lines,
|
|
47
|
+
truncated: result.diffTruncated === true,
|
|
48
|
+
omittedLines: typeof result.diffOmittedLines === 'number' ? result.diffOmittedLines : 0,
|
|
49
|
+
...(typeof result.diffHandle === 'string' ? { handle: result.diffHandle } : {}),
|
|
50
|
+
complete: result.diffComplete !== false,
|
|
51
|
+
...(typeof result.previousContentOmittedBytes === 'number' ? { previousContentOmittedBytes: result.previousContentOmittedBytes } : {}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
9
54
|
export function createToolGroupRenderer(deps) {
|
|
10
55
|
let toolGroup = createToolGroup();
|
|
11
56
|
let toolTimer;
|
|
@@ -31,16 +76,17 @@ export function createToolGroupRenderer(deps) {
|
|
|
31
76
|
};
|
|
32
77
|
const updateToolGroup = (streaming = true, group = toolGroup) => {
|
|
33
78
|
const text = renderToolGroup(group);
|
|
34
|
-
|
|
35
|
-
//
|
|
79
|
+
const toolDiffs = group.items.flatMap(item => item.diff ? [item.diff] : []);
|
|
80
|
+
// toolCount and diffs are carried structurally so metrics and rich code
|
|
81
|
+
// rendering never depend on parsing the compact caption/row format.
|
|
36
82
|
if (!group.started) {
|
|
37
83
|
group.started = true;
|
|
38
84
|
group.finalized = !streaming;
|
|
39
|
-
deps.addMessage({ id: group.id, role: 'tool', text, streaming, toolCount: group.items.length });
|
|
85
|
+
deps.addMessage({ id: group.id, role: 'tool', text, streaming, toolCount: group.items.length, toolDiffs });
|
|
40
86
|
}
|
|
41
87
|
else {
|
|
42
88
|
group.finalized = !streaming;
|
|
43
|
-
deps.updateMessage(group.id, { text, streaming, toolCount: group.items.length });
|
|
89
|
+
deps.updateMessage(group.id, { text, streaming, toolCount: group.items.length, toolDiffs });
|
|
44
90
|
}
|
|
45
91
|
};
|
|
46
92
|
const finalizeToolGroup = (group = toolGroup) => {
|
|
@@ -10,4 +10,9 @@ export declare function applyToolResultState(state: ToolResultState, event: {
|
|
|
10
10
|
output: unknown;
|
|
11
11
|
ok: boolean;
|
|
12
12
|
}): ToolResultState;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Update recovery state from the SDK's internally ordered step content. This
|
|
15
|
+
* runs in onStepEnd, before prepareStep can start the next model request, so a
|
|
16
|
+
* fast provider cannot outrun state updates queued on the public stream.
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyStepToolResultState(state: ToolResultState, content: readonly unknown[]): ToolResultState;
|
|
@@ -1,25 +1,47 @@
|
|
|
1
|
-
import { isDuplicateSkippedOutput, toolInputField } from '../../../core/agent/toolResults.js';
|
|
1
|
+
import { isDuplicateSkippedOutput, requiresReadFileRecovery, toolInputField, toolOutputOk } from '../../../core/agent/toolResults.js';
|
|
2
|
+
import { workspacePathKey } from '../../../utils/path.js';
|
|
2
3
|
const MUTATING_TOOLS = new Set(['editFile', 'replaceLines', 'writeFile']);
|
|
4
|
+
function samePath(first, second) {
|
|
5
|
+
return first != null && second != null && workspacePathKey(first) === workspacePathKey(second);
|
|
6
|
+
}
|
|
3
7
|
export function initialToolResultState() {
|
|
4
8
|
return { mutatingToolSucceeded: false, editRecoveryReadSatisfied: false };
|
|
5
9
|
}
|
|
6
10
|
export function applyToolResultState(state, event) {
|
|
7
11
|
const path = toolInputField(event.input, 'path');
|
|
8
|
-
if (!event.ok && MUTATING_TOOLS.has(event.toolName)) {
|
|
12
|
+
if (!event.ok && MUTATING_TOOLS.has(event.toolName) && path && requiresReadFileRecovery(event.output)) {
|
|
9
13
|
return { ...state, editRecoveryPath: path, editRecoveryReadSatisfied: false };
|
|
10
14
|
}
|
|
11
|
-
if (event.ok && event.toolName === 'readFile' && path
|
|
15
|
+
if (event.ok && event.toolName === 'readFile' && samePath(path, state.editRecoveryPath) && !isDuplicateSkippedOutput(event.output)) {
|
|
12
16
|
return { ...state, editRecoveryReadSatisfied: true };
|
|
13
17
|
}
|
|
14
18
|
if (event.ok && !isDuplicateSkippedOutput(event.output) && MUTATING_TOOLS.has(event.toolName)) {
|
|
19
|
+
const clearsRecovery = !path || samePath(path, state.editRecoveryPath);
|
|
15
20
|
return {
|
|
16
21
|
mutatingToolSucceeded: true,
|
|
17
|
-
editRecoveryPath:
|
|
18
|
-
editRecoveryReadSatisfied:
|
|
22
|
+
editRecoveryPath: clearsRecovery ? undefined : state.editRecoveryPath,
|
|
23
|
+
editRecoveryReadSatisfied: clearsRecovery ? false : state.editRecoveryReadSatisfied,
|
|
19
24
|
};
|
|
20
25
|
}
|
|
21
26
|
return state;
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Update recovery state from the SDK's internally ordered step content. This
|
|
30
|
+
* runs in onStepEnd, before prepareStep can start the next model request, so a
|
|
31
|
+
* fast provider cannot outrun state updates queued on the public stream.
|
|
32
|
+
*/
|
|
33
|
+
export function applyStepToolResultState(state, content) {
|
|
34
|
+
let next = state;
|
|
35
|
+
for (const part of content) {
|
|
36
|
+
if (typeof part !== 'object' || part == null || !('type' in part))
|
|
37
|
+
continue;
|
|
38
|
+
const value = part;
|
|
39
|
+
if (value.type === 'tool-result' && typeof value.toolName === 'string') {
|
|
40
|
+
next = applyToolResultState(next, { toolName: value.toolName, input: value.input, output: value.output, ok: toolOutputOk(value.output, true) });
|
|
41
|
+
}
|
|
42
|
+
else if (value.type === 'tool-error' && typeof value.toolName === 'string') {
|
|
43
|
+
next = applyToolResultState(next, { toolName: value.toolName, input: value.input, output: value.error, ok: false });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return next;
|
|
25
47
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
2
|
import type { ContextFile } from '../../../config/contextFiles.js';
|
|
3
|
+
import type { LlmLog } from '../../../core/log/llmLog.js';
|
|
4
|
+
import { type LlmLogEntry } from '../../../core/log/llmLog.js';
|
|
3
5
|
export interface TokenUsage {
|
|
4
6
|
inputTokens: number | undefined;
|
|
5
7
|
outputTokens: number | undefined;
|
|
@@ -15,6 +17,8 @@ export interface TokenUsage {
|
|
|
15
17
|
effectiveNonCachedInput: number | undefined;
|
|
16
18
|
}
|
|
17
19
|
export declare function retryDelayMs(attempt: number): number;
|
|
20
|
+
/** Append one entry to the per-turn LLM log when file logging is enabled; never blocks the turn. */
|
|
21
|
+
export declare function logEntry(log: LlmLog | undefined, entry: LlmLogEntry): void;
|
|
18
22
|
export declare function abortableDelay(milliseconds: number, signal: AbortSignal): Promise<void>;
|
|
19
23
|
export declare function estimateInputBreakdown(input: {
|
|
20
24
|
system: string;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { appendLogEntry as logAppend } from '../../../core/log/llmLog.js';
|
|
1
2
|
import { cacheHitRatio, contextBreakdown, effectiveNonCachedInput, estimateValueTokens } from '../../../core/agent/contextBudget.js';
|
|
2
3
|
export function retryDelayMs(attempt) {
|
|
3
4
|
return Math.min(4000, 1000 * 2 ** attempt);
|
|
4
5
|
}
|
|
6
|
+
/** Append one entry to the per-turn LLM log when file logging is enabled; never blocks the turn. */
|
|
7
|
+
export function logEntry(log, entry) {
|
|
8
|
+
if (log)
|
|
9
|
+
void logAppend(log, entry).catch(() => undefined);
|
|
10
|
+
}
|
|
5
11
|
export async function abortableDelay(milliseconds, signal) {
|
|
6
12
|
if (signal.aborted)
|
|
7
13
|
return;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { type ModelMessage } from 'ai';
|
|
2
1
|
import type { LlmLog } from '../../core/log/llmLog.js';
|
|
3
|
-
import {
|
|
4
|
-
import { type PromptSession } from '../../llm/systemPrompt.js';
|
|
5
|
-
import type { ContextFile } from '../../config/contextFiles.js';
|
|
2
|
+
import type { ModelMessage } from 'ai';
|
|
6
3
|
import { type AgentEventSink } from '../../core/agent/events.js';
|
|
7
|
-
import {
|
|
4
|
+
import type { ImageAttachment } from '../../core/attachments/imageAttachments.js';
|
|
8
5
|
import { type BlessedPath } from '../../core/attachments/readBlessings.js';
|
|
9
|
-
|
|
10
|
-
import type { WorkState } from '../../core/agent/workState.js';
|
|
6
|
+
import type { TurnCompletionEvidence } from '../../core/agent/completionController.js';
|
|
7
|
+
import type { ValidationOutcome, WorkTaskProgress, WorkState } from '../../core/agent/workState.js';
|
|
8
|
+
import type { SubagentOverrides, TurnExecutionScope } from '../../llm/requestContext.js';
|
|
9
|
+
import type { PromptSession } from '../../llm/systemPrompt.js';
|
|
10
|
+
import type { ContextFile } from '../../config/contextFiles.js';
|
|
11
|
+
import type { IncompleteGoalResume } from './streaming/goalCheckpoint.js';
|
|
11
12
|
import { type TokenUsage } from './streaming/turnRuntime.js';
|
|
12
|
-
|
|
13
|
+
import type { ToolDisplayDiff } from './streaming/toolGroupRenderer.js';
|
|
13
14
|
export type Message = {
|
|
14
15
|
id?: string;
|
|
15
16
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
@@ -21,11 +22,51 @@ export type Message = {
|
|
|
21
22
|
tokensPerSecond?: number;
|
|
22
23
|
displayOrder?: number;
|
|
23
24
|
toolCount?: number;
|
|
25
|
+
toolDiffs?: ToolDisplayDiff[];
|
|
24
26
|
};
|
|
25
27
|
export type TurnStatus = 'complete' | 'aborted' | 'failed';
|
|
26
|
-
/** Authoritative outcome of a turn, so callers (esp. headless/CI) need not sniff message
|
|
28
|
+
/** Authoritative outcome of a turn, so callers (esp. headless/CI) need not sniff message texts. */
|
|
27
29
|
export interface TurnResult {
|
|
28
30
|
status: TurnStatus;
|
|
31
|
+
/** Distinguishes a real user cancel from an internal absolute deadline. */
|
|
32
|
+
abortReason?: 'user' | 'turn-deadline';
|
|
33
|
+
/** Bounded, safe completion evidence (no raw commands/output). Additive. */
|
|
34
|
+
evidence?: TurnCompletionEvidence;
|
|
35
|
+
/**
|
|
36
|
+
* The turn paused with recoverable work unfinished; this carries what a
|
|
37
|
+
* one-key/automatic resume needs instead of forcing the user to restate the
|
|
38
|
+
* task. Safe metadata only (reasons, counts, enums) — never commands,
|
|
39
|
+
* content, or credentials.
|
|
40
|
+
*
|
|
41
|
+
* - `model-stream-idle`: the model stream stalled past the idle window and
|
|
42
|
+
* bounded retries could not continue. The conversation keeps completed
|
|
43
|
+
* steps; resume continues the same logical turn's retry pool.
|
|
44
|
+
* - `incomplete-goal`: the attempt ended `recoverable-incomplete` (declared
|
|
45
|
+
* tasks or post-edit validation outstanding) with no same-turn recovery
|
|
46
|
+
* available — including step/tool budget boundaries that finish as
|
|
47
|
+
* `tool-calls`. A goal supervisor (or the interactive R key) continues the
|
|
48
|
+
* logical goal in a fresh physical turn against the preserved
|
|
49
|
+
* conversation; completed mutations are never replayed.
|
|
50
|
+
*/
|
|
51
|
+
resume?: {
|
|
52
|
+
kind: 'model-stream-idle';
|
|
53
|
+
request: string;
|
|
54
|
+
retryAttempt: number;
|
|
55
|
+
} | IncompleteGoalResume;
|
|
56
|
+
}
|
|
57
|
+
/** Supervisor-provided logical-goal context: tags checkpoints and seeds cumulative evidence. */
|
|
58
|
+
interface TurnGoalContext {
|
|
59
|
+
goalId: string;
|
|
60
|
+
/** 1-based physical-turn counter for the logical goal. */
|
|
61
|
+
cycle: number;
|
|
62
|
+
/** Cumulative evidence carried from earlier physical turns. */
|
|
63
|
+
carried: {
|
|
64
|
+
mutationCount: number;
|
|
65
|
+
validationOutcome: ValidationOutcome;
|
|
66
|
+
taskProgress?: WorkTaskProgress;
|
|
67
|
+
};
|
|
68
|
+
/** Consecutive no-progress physical turns at goal level (diagnostics). */
|
|
69
|
+
noProgressCount: number;
|
|
29
70
|
}
|
|
30
71
|
export interface TurnExecutionOptions {
|
|
31
72
|
ephemeralControl?: string;
|
|
@@ -34,6 +75,20 @@ export interface TurnExecutionOptions {
|
|
|
34
75
|
attachments?: readonly ImageAttachment[];
|
|
35
76
|
/** User-mentioned paths whose reads may escape workspace confinement this turn. */
|
|
36
77
|
blessedPaths?: readonly BlessedPath[];
|
|
78
|
+
/** When set, this attempt is a bounded recovery slice (length-continuation, rescue, or goal continuation). */
|
|
79
|
+
recoverySlice?: {
|
|
80
|
+
kind: 'length' | 'rescue' | 'goal';
|
|
81
|
+
maxSteps: number;
|
|
82
|
+
maxToolCalls: number;
|
|
83
|
+
};
|
|
84
|
+
/** Absolute turn deadline in milliseconds (headless `--timeout`); defaults to DEFAULT_TURN_DEADLINE_MS. */
|
|
85
|
+
turnDeadlineMs?: number;
|
|
86
|
+
/** Logical-goal context from the goal supervisor; hydrates cumulative evidence so a fresh physical turn cannot complete while carried work remains. */
|
|
87
|
+
goalContext?: TurnGoalContext;
|
|
88
|
+
/** Shared turn scope (coordinator admission + workspace mutation lease) reused across a logical goal's physical turns. */
|
|
89
|
+
sharedTurnScope?: {
|
|
90
|
+
executionScope?: TurnExecutionScope;
|
|
91
|
+
};
|
|
37
92
|
}
|
|
38
93
|
export interface StreamCallbacks {
|
|
39
94
|
addMessage: (msg: Message) => void;
|
|
@@ -56,3 +111,4 @@ export interface StreamCallbacks {
|
|
|
56
111
|
contextFileSignatures?: Map<string, string>;
|
|
57
112
|
}
|
|
58
113
|
export declare function runAgentTurn(value: string, displayValue: string | undefined, contextFiles: ContextFile[], callbacks: StreamCallbacks, retryAttempt?: number, retryingExistingRequest?: boolean, contextOverflowRecovered?: boolean, session?: PromptSession, modelOverride?: string, turnOptions?: TurnExecutionOptions): Promise<TurnResult>;
|
|
114
|
+
export {};
|