@denizokcu/haze 0.11.0 → 1.1.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 +33 -0
- package/README.md +28 -14
- package/SECURITY.md +5 -3
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/TaskBar.js +1 -1
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/fileMentionSuggestions.js +1 -1
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +10 -41
- package/dist/cli/chat/messages.d.ts +0 -2
- package/dist/cli/chat/messages.js +5 -5
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +257 -130
- package/dist/cli/commands/chat.js +61 -77
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/commandHelp.js +2 -0
- package/dist/cli/commands/commands.js +2 -0
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +12 -25
- package/dist/cli/commands/providerWizard.js +2 -3
- package/dist/cli/commands/runCommand.js +1 -1
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/settingsSummary.js +2 -0
- 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 +2 -1
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- 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 +1 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
- package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
- 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 +14 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
- 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 +14 -25
- package/dist/cli/commands/streaming.js +43 -754
- package/dist/cli/commands/themesCommand.d.ts +17 -0
- package/dist/cli/commands/themesCommand.js +24 -0
- package/dist/cli/commands/wizardFlow.d.ts +341 -0
- package/dist/cli/commands/wizardFlow.js +397 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.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 +0 -15
- package/dist/config/modelDiscovery.js +1 -1
- package/dist/config/settings.d.ts +9 -0
- package/dist/config/settings.js +4 -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 +63 -1
- package/dist/core/agent/budgets.js +84 -1
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/completionController.d.ts +7 -13
- package/dist/core/agent/completionController.js +17 -8
- package/dist/core/agent/contextBudget.d.ts +0 -4
- package/dist/core/agent/contextBudget.js +3 -3
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +5 -1
- package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
- package/dist/core/agent/goalPolicy.js +106 -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 +2 -2
- package/dist/core/agent/toolCapabilities.js +5 -5
- package/dist/core/agent/toolOutputStore.js +1 -1
- package/dist/core/agent/toolResults.js +1 -1
- package/dist/core/agent/workState.d.ts +6 -3
- package/dist/core/agent/workState.js +62 -7
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +0 -6
- package/dist/core/deadline.js +1 -1
- 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 +1 -1
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +10 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/secretPaths.d.ts +18 -0
- package/dist/core/safety/secretPaths.js +115 -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 +1 -0
- package/dist/core/session/sessionStore.js +39 -20
- 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 +2 -14
- package/dist/core/subagent/contracts.js +3 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentRunner.js +3 -4
- 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.js +5 -1
- package/dist/llm/hazeTools.d.ts +139 -124
- package/dist/llm/hazeTools.js +20 -11
- 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 +3824 -570
- package/dist/llm/lspTools.js +65 -1
- package/dist/llm/openaiCodex.d.ts +0 -2
- package/dist/llm/openaiCodex.js +0 -4
- package/dist/llm/openaiCodexOAuth.d.ts +0 -3
- package/dist/llm/openaiCodexOAuth.js +6 -3
- package/dist/llm/requestContext.d.ts +5 -1
- package/dist/llm/requestContext.js +25 -2
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +16 -7
- package/dist/llm/toolResultTypes.d.ts +1 -15
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +0 -9
- package/dist/llm/tools/editMatch.js +1 -1
- package/dist/llm/tools/failures.d.ts +6 -0
- package/dist/llm/tools/failures.js +8 -2
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +4 -2
- package/dist/llm/tools/fileToolShared.js +9 -5
- package/dist/llm/tools/gitIgnore.d.ts +25 -32
- package/dist/llm/tools/gitIgnore.js +216 -98
- 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 +0 -2
- package/dist/llm/tools/readRecovery.js +4 -2
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
- package/dist/llm/tools/{bashTool.js → shellTool.js} +18 -14
- package/dist/llm/tools/toolContext.js +5 -5
- package/dist/llm/tools/workspaceFile.d.ts +4 -4
- package/dist/llm/tools/workspaceFile.js +29 -17
- package/dist/llm/webFetch.d.ts +1 -1
- 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/components/Header.js +1 -1
- package/dist/ui/components/MarkdownText.js +10 -10
- package/dist/ui/components/TextInput.d.ts +1 -1
- package/dist/ui/components/TextInput.js +2 -2
- package/dist/ui/terminalColors.d.ts +29 -0
- package/dist/ui/terminalColors.js +47 -0
- package/dist/ui/theme.d.ts +105 -10
- package/dist/ui/theme.js +126 -15
- package/dist/ui/themes/af-magic.d.ts +7 -0
- package/dist/ui/themes/af-magic.js +25 -0
- package/dist/ui/themes/agnoster.d.ts +10 -0
- package/dist/ui/themes/agnoster.js +40 -0
- package/dist/ui/themes/bira.d.ts +10 -0
- package/dist/ui/themes/bira.js +28 -0
- package/dist/ui/themes/bureau.d.ts +10 -0
- package/dist/ui/themes/bureau.js +28 -0
- package/dist/ui/themes/clean.d.ts +9 -0
- package/dist/ui/themes/clean.js +27 -0
- package/dist/ui/themes/cloud.d.ts +6 -0
- package/dist/ui/themes/cloud.js +24 -0
- package/dist/ui/themes/dst.d.ts +10 -0
- package/dist/ui/themes/dst.js +28 -0
- package/dist/ui/themes/fishy.d.ts +7 -0
- package/dist/ui/themes/fishy.js +25 -0
- package/dist/ui/themes/index.d.ts +8 -0
- package/dist/ui/themes/index.js +36 -0
- package/dist/ui/themes/light.d.ts +3 -0
- package/dist/ui/themes/light.js +21 -0
- package/dist/ui/themes/purple.d.ts +7 -0
- package/dist/ui/themes/purple.js +26 -0
- package/dist/ui/themes/robbyrussell.d.ts +8 -0
- package/dist/ui/themes/robbyrussell.js +26 -0
- package/dist/ui/themes/solarized-dark.d.ts +16 -0
- package/dist/ui/themes/solarized-dark.js +44 -0
- package/dist/ui/themes/solarized-light.d.ts +12 -0
- package/dist/ui/themes/solarized-light.js +40 -0
- package/dist/ui/themes/steeef.d.ts +11 -0
- package/dist/ui/themes/steeef.js +29 -0
- package/dist/utils/buildInfo.d.ts +6 -13
- package/dist/utils/buildInfo.js +6 -15
- package/dist/utils/fs.d.ts +7 -5
- package/dist/utils/fs.js +5 -2
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +1 -1
- package/package.json +6 -4
- 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 -27
- package/dist/cli/commands/streaming/turnOutcome.js +0 -29
- package/dist/cli/commands/wizardActions.d.ts +0 -47
- package/dist/cli/commands/wizardActions.js +0 -47
- 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 -58
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -190
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
- package/dist/core/agent/toolExecutionBudget.js +0 -49
- package/dist/core/agent/turnBudget.d.ts +0 -35
- package/dist/core/agent/turnBudget.js +0 -27
- 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.js +0 -43
- 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 -20
- package/dist/core/limits/byteBudgets.js +0 -20
- package/dist/core/limits/textBudgets.d.ts +0 -25
- package/dist/core/limits/textBudgets.js +0 -25
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -149
- package/dist/llm/lsp.js +0 -368
- 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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
import type { LoadedSkill } from '../../skills/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pure result functions for the skills wizard flow: selection, actions,
|
|
5
|
+
* creation-from-description, and confirm-remove. Steps live in
|
|
6
|
+
* `wizardFlow.ts`; submit orchestration in `chat/wizardDispatch.ts`.
|
|
7
|
+
*/
|
|
8
|
+
export type SkillWizardResult = {
|
|
9
|
+
message?: string;
|
|
10
|
+
mode?: 'chat' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsConfirmRemove';
|
|
11
|
+
selectedName?: string;
|
|
12
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
13
|
+
clearDraft?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function selectSkillResult(skills: LoadedSkill[], name: string): SkillWizardResult;
|
|
16
|
+
export declare function skillInfoMessage(settings: HazeSettings, skill: LoadedSkill): string;
|
|
17
|
+
export declare function selectSkillActionResult(settings: HazeSettings, skills: LoadedSkill[], selectedName: string | undefined, action: string): SkillWizardResult & {
|
|
18
|
+
skill?: LoadedSkill;
|
|
19
|
+
validate?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type SkillCreationResult = {
|
|
22
|
+
busy?: boolean;
|
|
23
|
+
busyLabel?: string;
|
|
24
|
+
message?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
draftName?: string;
|
|
27
|
+
mode?: 'chat';
|
|
28
|
+
clearDraft?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function captureSkillDescription(value: string, draftName: string | undefined): SkillCreationResult;
|
|
31
|
+
export declare function skillCreationMessage(name: string, file: string): string;
|
|
32
|
+
export declare function skillCreationFailure(error: unknown): string;
|
|
33
|
+
export type SkillConfirmRemoveResult = {
|
|
34
|
+
message?: string;
|
|
35
|
+
mode?: 'chat';
|
|
36
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
37
|
+
removedDir?: string;
|
|
38
|
+
selectedName?: string;
|
|
39
|
+
skill?: LoadedSkill;
|
|
40
|
+
};
|
|
41
|
+
export declare function skillConfirmRemoveResult(settings: HazeSettings, skills: LoadedSkill[], selectedName: string | undefined, value: string): SkillConfirmRemoveResult;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { isSkillEnabled, setSkillEnabled } from '../../config/skillSettings.js';
|
|
2
|
-
import { COMMON_ACTIONS, SKILL_ACTIONS, SKILL_CHOICES } from './
|
|
3
|
-
export function skillPickerValue(skill) {
|
|
4
|
-
return `${skill.name} · ${skill.source}`;
|
|
5
|
-
}
|
|
6
|
-
export function findSelectedSkill(skills, selection) {
|
|
7
|
-
if (!selection)
|
|
8
|
-
return undefined;
|
|
9
|
-
return skills.find(skill => skillPickerValue(skill) === selection)
|
|
10
|
-
?? skills.find(skill => skill.name === selection);
|
|
11
|
-
}
|
|
1
|
+
import { isSkillEnabled, removeSkillSetting, setSkillEnabled } from '../../config/skillSettings.js';
|
|
2
|
+
import { COMMON_ACTIONS, SKILL_ACTIONS, SKILL_CHOICES, findSelectedSkill, isYesConfirmation, skillPickerValue } from './wizardFlow.js';
|
|
12
3
|
export function selectSkillResult(skills, name) {
|
|
13
4
|
if (name === SKILL_CHOICES.addSkill)
|
|
14
5
|
return { mode: 'skillsAddName', clearDraft: true, message: 'Name the skill (kebab-case, e.g. security-review). ESC cancels.' };
|
|
@@ -46,3 +37,34 @@ export function selectSkillActionResult(settings, skills, selectedName, action)
|
|
|
46
37
|
return { mode: 'skillsConfirmRemove', message: `Remove ${skill.source} skill ${skill.name}? This deletes ${skill.dir}. Type "yes" to confirm. Esc to cancel.`, skill };
|
|
47
38
|
return { message: `Unknown skill action: ${action}`, skill };
|
|
48
39
|
}
|
|
40
|
+
export function captureSkillDescription(value, draftName) {
|
|
41
|
+
const description = value.trim();
|
|
42
|
+
if (!description)
|
|
43
|
+
return { message: 'Description is required. Try again, or press ESC to cancel.' };
|
|
44
|
+
if (!draftName)
|
|
45
|
+
return { mode: 'chat', clearDraft: true, message: 'Skill wizard lost the name. Start over with /skills.' };
|
|
46
|
+
return { description, draftName, busy: true, busyLabel: 'Creating skill' };
|
|
47
|
+
}
|
|
48
|
+
export function skillCreationMessage(name, file) {
|
|
49
|
+
return `Created skill ${name} at ${file}. Invoke it with /${name}. Edit SKILL.md to refine its workflow.`;
|
|
50
|
+
}
|
|
51
|
+
export function skillCreationFailure(error) {
|
|
52
|
+
return `Skill creation failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
53
|
+
}
|
|
54
|
+
export function skillConfirmRemoveResult(settings, skills, selectedName, value) {
|
|
55
|
+
if (!selectedName)
|
|
56
|
+
return { mode: 'chat' };
|
|
57
|
+
if (!isYesConfirmation(value))
|
|
58
|
+
return { mode: 'chat', selectedName: undefined, message: 'Cancelled. Skill not removed.' };
|
|
59
|
+
const skill = findSelectedSkill(skills, selectedName);
|
|
60
|
+
if (!skill)
|
|
61
|
+
return { mode: 'chat', selectedName: undefined, message: `Skill ${selectedName} not found.` };
|
|
62
|
+
return {
|
|
63
|
+
mode: 'chat',
|
|
64
|
+
selectedName: undefined,
|
|
65
|
+
skill,
|
|
66
|
+
removedDir: skill.dir,
|
|
67
|
+
settingsPatch: { skills: removeSkillSetting(settings, skill.name, skill.source) },
|
|
68
|
+
message: skill.source === 'global' ? `Removed skill ${skill.name}.` : `Removed project skill ${skill.name}.`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* mutable holder set by whichever internal site aborts first. A user abort
|
|
9
9
|
* never sets it and therefore stays `'user'` (the default).
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
type TurnAbortCauseKind = 'user' | 'turn-deadline' | 'model-stream-idle';
|
|
12
12
|
export interface TurnAbortCause {
|
|
13
13
|
kind: TurnAbortCauseKind;
|
|
14
14
|
/** Window of the timer that fired (idle window or turn deadline), for messages and diagnostics. */
|
|
@@ -22,3 +22,4 @@ export declare function createUserAbortCause(): TurnAbortCause;
|
|
|
22
22
|
* idle timeout keeps whichever cause actually fired first.
|
|
23
23
|
*/
|
|
24
24
|
export declare function abortForTurn(cause: TurnAbortCause, next: TurnAbortCause, controller: AbortController, reason: string): void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ContextFile } from '../../../config/contextFiles.js';
|
|
2
|
+
import type { PromptSession } from '../../../llm/systemPrompt.js';
|
|
3
|
+
import type { TurnExecutionScope } from '../../../llm/requestContext.js';
|
|
4
|
+
import type { ToolExecutionBudgetState, TurnBudget } from '../../../core/agent/budgets.js';
|
|
5
|
+
import type { TurnExecutionState } from '../../../core/agent/completionController.js';
|
|
6
|
+
import type { SessionGoal } from '../../../core/agent/goalPolicy.js';
|
|
7
|
+
import { type AgentAttemptResult } from './attemptOutcome.js';
|
|
8
|
+
import type { AttemptCleanupRegistry } from './attemptLifecycle.js';
|
|
9
|
+
import type { TurnAbortCause } from './abortCause.js';
|
|
10
|
+
import type { StreamCallbacks, TurnExecutionOptions } from '../streaming.js';
|
|
11
|
+
export interface AgentAttemptInput {
|
|
12
|
+
value: string;
|
|
13
|
+
contextFiles: ContextFile[];
|
|
14
|
+
callbacks: StreamCallbacks;
|
|
15
|
+
retryAttempt: number;
|
|
16
|
+
retryingExistingRequest: boolean;
|
|
17
|
+
contextOverflowRecovered: boolean;
|
|
18
|
+
session: PromptSession | undefined;
|
|
19
|
+
modelOverride: string | undefined;
|
|
20
|
+
abortController: AbortController;
|
|
21
|
+
turnOptions: TurnExecutionOptions;
|
|
22
|
+
turnScope: {
|
|
23
|
+
executionScope?: TurnExecutionScope;
|
|
24
|
+
};
|
|
25
|
+
turnState: TurnExecutionState;
|
|
26
|
+
turnBudget: TurnBudget;
|
|
27
|
+
globalBudget: ToolExecutionBudgetState;
|
|
28
|
+
/** Slice execution budget shared by every attempt in the current slice (main phase or one recovery slice); reset when a new slice is admitted. */
|
|
29
|
+
sliceBudget: ToolExecutionBudgetState;
|
|
30
|
+
goal: SessionGoal;
|
|
31
|
+
abortCause: TurnAbortCause;
|
|
32
|
+
/** Exactly-once teardown registry; shared with the turn's forced-settlement path. */
|
|
33
|
+
cleanup: AttemptCleanupRegistry;
|
|
34
|
+
remainingTurnDeadlineMs: () => number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run one agent attempt end to end: setup (`attemptSetup`), the stream loop
|
|
38
|
+
* (`streamLoop`), then terminal classification and recovery decisions
|
|
39
|
+
* (`attemptOutcome`). Failures are classified from the abort cause and error
|
|
40
|
+
* in one catch; MCP clients, the LSP pool, the stall guard, and the tool
|
|
41
|
+
* display are always torn down.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runAgentAttempt(input: AgentAttemptInput): Promise<AgentAttemptResult>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { closeMcpClients } from '../../../llm/mcp.js';
|
|
2
|
+
import { modelThinkingLabel } from '../../../utils/modelName.js';
|
|
3
|
+
import { normalizeAssistantText } from './assistantText.js';
|
|
4
|
+
import { createToolGroupRenderer } from './toolGroupRenderer.js';
|
|
5
|
+
import { prepareAttempt } from './attemptSetup.js';
|
|
6
|
+
import { createAttemptLoopState, runAttemptStream } from './streamLoop.js';
|
|
7
|
+
import { createStreamStallGuard } from './stallRecovery.js';
|
|
8
|
+
import { finalizeAttemptOutcome, handleAttemptFailure } from './attemptOutcome.js';
|
|
9
|
+
import { ATTEMPT_TEARDOWN_BOUND_MS } from './attemptLifecycle.js';
|
|
10
|
+
/**
|
|
11
|
+
* Run one agent attempt end to end: setup (`attemptSetup`), the stream loop
|
|
12
|
+
* (`streamLoop`), then terminal classification and recovery decisions
|
|
13
|
+
* (`attemptOutcome`). Failures are classified from the abort cause and error
|
|
14
|
+
* in one catch; MCP clients, the LSP pool, the stall guard, and the tool
|
|
15
|
+
* display are always torn down.
|
|
16
|
+
*/
|
|
17
|
+
export async function runAgentAttempt(input) {
|
|
18
|
+
const { value, contextFiles, callbacks, retryAttempt, retryingExistingRequest, contextOverflowRecovered, session, modelOverride, abortController, turnOptions, turnScope, turnState, turnBudget, globalBudget, sliceBudget, goal, abortCause, cleanup, remainingTurnDeadlineMs } = input;
|
|
19
|
+
callbacks.setBusyLabel?.(modelThinkingLabel(undefined));
|
|
20
|
+
let loadedMcp;
|
|
21
|
+
let lspPool;
|
|
22
|
+
let mcpClosed = false;
|
|
23
|
+
let lspClosed = false;
|
|
24
|
+
const toolDisplay = createToolGroupRenderer({ addMessage: callbacks.addMessage, updateMessage: callbacks.updateMessage, debugLog: callbacks.debugLog, onEvent: callbacks.onEvent, log: callbacks.log });
|
|
25
|
+
// Teardown is registered, not inline: whichever runs first — this attempt's
|
|
26
|
+
// own finally or the turn-level forced settlement after an abort-ignoring
|
|
27
|
+
// stream — performs it exactly once (bounded), the other becomes a no-op.
|
|
28
|
+
cleanup.register(async () => {
|
|
29
|
+
const closes = [];
|
|
30
|
+
if (loadedMcp?.clients.length && !mcpClosed) {
|
|
31
|
+
mcpClosed = true;
|
|
32
|
+
closes.push(closeMcpClients(loadedMcp.clients));
|
|
33
|
+
}
|
|
34
|
+
if (lspPool && !lspClosed) {
|
|
35
|
+
lspClosed = true;
|
|
36
|
+
closes.push(lspPool.close());
|
|
37
|
+
}
|
|
38
|
+
stallGuard?.clear();
|
|
39
|
+
toolDisplay.stopToolTimer();
|
|
40
|
+
await Promise.allSettled(closes);
|
|
41
|
+
});
|
|
42
|
+
const salvage = { requestMessages: [], accumulated: [] };
|
|
43
|
+
let stallGuard;
|
|
44
|
+
let setup;
|
|
45
|
+
try {
|
|
46
|
+
setup = await prepareAttempt({ value, contextFiles, callbacks, retryingExistingRequest, contextOverflowRecovered, session, modelOverride, abortController, turnOptions, turnScope, turnBudget, globalBudget, sliceBudget, goal, onContextFileRead: path => toolDisplay.addContextFileRead(path) });
|
|
47
|
+
if (!setup)
|
|
48
|
+
return { status: 'failed' };
|
|
49
|
+
const attemptSetupResult = setup;
|
|
50
|
+
loadedMcp = setup.loadedMcp;
|
|
51
|
+
lspPool = setup.lspPool;
|
|
52
|
+
salvage.requestMessages = setup.requestMessages;
|
|
53
|
+
const loopState = createAttemptLoopState(normalizeAssistantText(callbacks.getLastAssistantText()), setup.contextFiles, callbacks);
|
|
54
|
+
stallGuard = createStreamStallGuard({
|
|
55
|
+
controller: abortController,
|
|
56
|
+
abortCause,
|
|
57
|
+
retryAttempt,
|
|
58
|
+
maxRetries: attemptSetupResult.modelRetries,
|
|
59
|
+
classifyEmission: () => loopState.currentAssistantText.trim().length > 0 || loopState.assistantStarted ? 'text' : loopState.inFlightTools.size > 0 ? 'tool' : 'none',
|
|
60
|
+
isToolInFlight: () => loopState.inFlightTools.size > 0,
|
|
61
|
+
provider: () => attemptSetupResult.runtime.config.providerName,
|
|
62
|
+
model: () => attemptSetupResult.runtime.config.modelName,
|
|
63
|
+
workPhase: () => goal.phase,
|
|
64
|
+
stepsUsed: () => turnState.stepsUsed,
|
|
65
|
+
onEvent: callbacks.onEvent,
|
|
66
|
+
log: callbacks.log,
|
|
67
|
+
debugLog: callbacks.debugLog,
|
|
68
|
+
});
|
|
69
|
+
const stream = await runAttemptStream({ setup, callbacks, abortController, retryAttempt, recoverySlice: turnOptions.recoverySlice, turnState, turnBudget, globalBudget, goal, stallGuard, loopState, toolDisplay, salvage });
|
|
70
|
+
return finalizeAttemptOutcome({ value, callbacks, abortController, turnOptions, turnState, turnBudget, goal, remainingTurnDeadlineMs, stream });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return handleAttemptFailure({ value, callbacks, abortController, turnState, retryAttempt, contextOverflowRecovered, abortCause, stallGuard, salvage, error, maxRetries: setup?.modelRetries });
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await cleanup.closeOnce(ATTEMPT_TEARDOWN_BOUND_MS);
|
|
77
|
+
toolDisplay.finalizeToolGroup();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { StreamCallbacks } from '../streaming.js';
|
|
2
|
+
import type { AgentAttemptResult } from './attemptOutcome.js';
|
|
3
|
+
/** Upper bound for one forced teardown pass; the underlying closes continue even if it expires. */
|
|
4
|
+
export declare const ATTEMPT_TEARDOWN_BOUND_MS = 5000;
|
|
5
|
+
/**
|
|
6
|
+
* Exactly-once cleanup registry for one agent attempt. The attempt registers
|
|
7
|
+
* its resource cleanups (MCP clients, LSP pool, stall guard, tool display) as
|
|
8
|
+
* it acquires them; whichever of the attempt's own `finally` or the turn's
|
|
9
|
+
* forced settlement runs first performs the teardown, and the other becomes a
|
|
10
|
+
* no-op. `closeOnce` is bounded and reports truthfully whether every cleanup
|
|
11
|
+
* completed within `timeoutMs` (closes keep settling in the background).
|
|
12
|
+
*/
|
|
13
|
+
export interface AttemptCleanupRegistry {
|
|
14
|
+
/** Register a cleanup to run once at teardown. Ignored after teardown started. */
|
|
15
|
+
register: (cleanup: () => void | Promise<void>) => void;
|
|
16
|
+
/** Run all registered cleanups exactly once; resolves false when the bound expired. */
|
|
17
|
+
closeOnce: (timeoutMs: number) => Promise<boolean>;
|
|
18
|
+
/** True once teardown has started. */
|
|
19
|
+
readonly closed: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function createAttemptCleanupRegistry(): AttemptCleanupRegistry;
|
|
22
|
+
/**
|
|
23
|
+
* Per-turn callback guard for the attempt machinery. After `quarantine()` —
|
|
24
|
+
* run at forced settlement — every state-mutating callback (messages,
|
|
25
|
+
* conversation, busy/goal/work state, events, token usage, logs) becomes a
|
|
26
|
+
* permanent no-op, so a still-running abort-ignoring stream cannot mutate the
|
|
27
|
+
* finished turn's UI, conversation, or session state if it ever wakes up.
|
|
28
|
+
* Diagnostics (`debugLog`) and read-only accessors stay live.
|
|
29
|
+
*/
|
|
30
|
+
export interface QuarantinableCallbacks {
|
|
31
|
+
callbacks: StreamCallbacks;
|
|
32
|
+
/** Permanently no-op all state-mutating callbacks. */
|
|
33
|
+
quarantine: () => void;
|
|
34
|
+
}
|
|
35
|
+
export declare function createQuarantinableCallbacks(callbacks: StreamCallbacks): QuarantinableCallbacks;
|
|
36
|
+
export interface ForcedSettlementDeps {
|
|
37
|
+
abortController: AbortController;
|
|
38
|
+
cleanup: AttemptCleanupRegistry;
|
|
39
|
+
quarantine: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Build the synthetic attempt result after forced teardown. Runs with the
|
|
42
|
+
* turn's live (unguarded) callbacks before the abandoned attempt's result
|
|
43
|
+
* (if it ever settles) is discarded.
|
|
44
|
+
*/
|
|
45
|
+
onForced: (tornDownCleanly: boolean) => AgentAttemptResult;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Await one agent attempt, but never let an abort-ignoring attempt defer the
|
|
49
|
+
* turn forever: once the shared controller aborts (user cancel or absolute
|
|
50
|
+
* deadline), the attempt gets a grace window to settle normally; if the grace
|
|
51
|
+
* expires, owned resources are torn down (bounded, exactly once), the attempt's
|
|
52
|
+
* callbacks are quarantined, and the turn resolves with `onForced`'s result.
|
|
53
|
+
* The abandoned attempt keeps running detached; its eventual settlement is
|
|
54
|
+
* discarded and its teardown is a no-op.
|
|
55
|
+
*/
|
|
56
|
+
export declare function awaitAttemptWithForcedSettlement(attempt: Promise<AgentAttemptResult>, deps: ForcedSettlementDeps): Promise<AgentAttemptResult>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grace window for an aborted attempt to settle on its own (streams normally
|
|
3
|
+
* reject immediately on abort) before the turn forces settlement.
|
|
4
|
+
*/
|
|
5
|
+
const ATTEMPT_SETTLEMENT_GRACE_MS = 5000;
|
|
6
|
+
/** Upper bound for one forced teardown pass; the underlying closes continue even if it expires. */
|
|
7
|
+
export const ATTEMPT_TEARDOWN_BOUND_MS = 5000;
|
|
8
|
+
export function createAttemptCleanupRegistry() {
|
|
9
|
+
const cleanups = [];
|
|
10
|
+
let closePromise;
|
|
11
|
+
return {
|
|
12
|
+
register: cleanup => {
|
|
13
|
+
if (!closePromise)
|
|
14
|
+
cleanups.push(cleanup);
|
|
15
|
+
},
|
|
16
|
+
get closed() {
|
|
17
|
+
return closePromise != null;
|
|
18
|
+
},
|
|
19
|
+
closeOnce(timeoutMs) {
|
|
20
|
+
if (!closePromise) {
|
|
21
|
+
const settled = Promise.allSettled(cleanups.map(cleanup => cleanup()));
|
|
22
|
+
// The teardown continues even when the bound expires; its eventual
|
|
23
|
+
// settlement must never surface as an unhandled rejection.
|
|
24
|
+
void settled.then(() => undefined, () => undefined);
|
|
25
|
+
closePromise = Promise.race([
|
|
26
|
+
settled.then(() => true),
|
|
27
|
+
new Promise(resolve => setTimeout(() => resolve(false), timeoutMs)),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
return closePromise;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function createQuarantinableCallbacks(callbacks) {
|
|
35
|
+
const state = { quarantined: false };
|
|
36
|
+
const whileLive = (fn) => (...args) => {
|
|
37
|
+
if (!state.quarantined)
|
|
38
|
+
fn(...args);
|
|
39
|
+
};
|
|
40
|
+
// `compactConversation`'s boolean return is consumed by overflow recovery;
|
|
41
|
+
// a quarantined call must answer "not compacted" instead of undefined.
|
|
42
|
+
const whileLiveBoolean = (fn) => (...args) => (state.quarantined ? false : fn(...args));
|
|
43
|
+
const guarded = {
|
|
44
|
+
...callbacks,
|
|
45
|
+
addMessage: whileLive(callbacks.addMessage),
|
|
46
|
+
updateMessage: whileLive(callbacks.updateMessage),
|
|
47
|
+
setConversation: whileLive(callbacks.setConversation),
|
|
48
|
+
setBusy: whileLive(callbacks.setBusy),
|
|
49
|
+
setLastAssistantText: whileLive(callbacks.setLastAssistantText),
|
|
50
|
+
...(callbacks.setBusyLabel ? { setBusyLabel: whileLive(callbacks.setBusyLabel) } : {}),
|
|
51
|
+
...(callbacks.setAbortController ? { setAbortController: whileLive(callbacks.setAbortController) } : {}),
|
|
52
|
+
...(callbacks.setGoalStatus ? { setGoalStatus: whileLive(callbacks.setGoalStatus) } : {}),
|
|
53
|
+
...(callbacks.onEvent ? { onEvent: whileLive(callbacks.onEvent) } : {}),
|
|
54
|
+
...(callbacks.compactConversation ? { compactConversation: whileLiveBoolean(callbacks.compactConversation) } : {}),
|
|
55
|
+
...(callbacks.recordTokenUsage ? { recordTokenUsage: whileLive(callbacks.recordTokenUsage) } : {}),
|
|
56
|
+
...(callbacks.setWorkState ? { setWorkState: whileLive(callbacks.setWorkState) } : {}),
|
|
57
|
+
...(callbacks.onTasksChanged ? { onTasksChanged: whileLive(callbacks.onTasksChanged) } : {}),
|
|
58
|
+
get log() {
|
|
59
|
+
return state.quarantined ? undefined : callbacks.log;
|
|
60
|
+
},
|
|
61
|
+
get contextFileSignatures() {
|
|
62
|
+
return callbacks.contextFileSignatures;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
return { callbacks: guarded, quarantine: () => {
|
|
66
|
+
state.quarantined = true;
|
|
67
|
+
} };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Await one agent attempt, but never let an abort-ignoring attempt defer the
|
|
71
|
+
* turn forever: once the shared controller aborts (user cancel or absolute
|
|
72
|
+
* deadline), the attempt gets a grace window to settle normally; if the grace
|
|
73
|
+
* expires, owned resources are torn down (bounded, exactly once), the attempt's
|
|
74
|
+
* callbacks are quarantined, and the turn resolves with `onForced`'s result.
|
|
75
|
+
* The abandoned attempt keeps running detached; its eventual settlement is
|
|
76
|
+
* discarded and its teardown is a no-op.
|
|
77
|
+
*/
|
|
78
|
+
export async function awaitAttemptWithForcedSettlement(attempt, deps) {
|
|
79
|
+
const { abortController, cleanup, quarantine, onForced } = deps;
|
|
80
|
+
return new Promise(resolve => {
|
|
81
|
+
let finished = false;
|
|
82
|
+
let graceTimer;
|
|
83
|
+
const finish = (result) => {
|
|
84
|
+
if (finished)
|
|
85
|
+
return;
|
|
86
|
+
finished = true;
|
|
87
|
+
if (graceTimer)
|
|
88
|
+
clearTimeout(graceTimer);
|
|
89
|
+
resolve(result);
|
|
90
|
+
};
|
|
91
|
+
// runAgentAttempt classifies its own errors, but never let a surprise
|
|
92
|
+
// rejection surface as unhandled after the turn moved on.
|
|
93
|
+
attempt.then(result => finish(result), () => finish({ status: 'failed' }));
|
|
94
|
+
const armGrace = () => {
|
|
95
|
+
if (finished || graceTimer)
|
|
96
|
+
return;
|
|
97
|
+
graceTimer = setTimeout(async () => {
|
|
98
|
+
if (finished)
|
|
99
|
+
return;
|
|
100
|
+
const tornDown = await cleanup.closeOnce(ATTEMPT_TEARDOWN_BOUND_MS);
|
|
101
|
+
quarantine();
|
|
102
|
+
finish(onForced(tornDown));
|
|
103
|
+
}, ATTEMPT_SETTLEMENT_GRACE_MS);
|
|
104
|
+
};
|
|
105
|
+
if (abortController.signal.aborted)
|
|
106
|
+
armGrace();
|
|
107
|
+
else
|
|
108
|
+
abortController.signal.addEventListener('abort', armGrace, { once: true });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type TurnExecutionState } from '../../../core/agent/completionController.js';
|
|
2
|
+
import { type SessionGoal } from '../../../core/agent/goalPolicy.js';
|
|
3
|
+
import { type TurnBudget } from '../../../core/agent/budgets.js';
|
|
4
|
+
import { type AttemptSalvage, type StreamStallGuard } from './stallRecovery.js';
|
|
5
|
+
import type { TurnAbortCause } from './abortCause.js';
|
|
6
|
+
import type { AttemptStreamOutcome } from './streamLoop.js';
|
|
7
|
+
import type { RequestIntent } from '../../../core/agent/goalPolicy.js';
|
|
8
|
+
import type { StreamCallbacks, TurnExecutionOptions, TurnResult, TurnStatus } from '../streaming.js';
|
|
9
|
+
import type { ValidationOutcome, WorkTaskProgress } from '../../../core/agent/workState.js';
|
|
10
|
+
/**
|
|
11
|
+
* CLI adapter for the authoritative turn-status decision. The pure policy
|
|
12
|
+
* lives in `core/agent/completionController.ts`; this keeps the single call site
|
|
13
|
+
* in the agent turn (see streaming/AGENTS.md) and preserves the documented
|
|
14
|
+
* field-based signature exercised by `tests/cli/commands/streaming/attemptOutcome.test.ts`.
|
|
15
|
+
*
|
|
16
|
+
* The optional work-evidence fields (intent, mutation/validation counts, task
|
|
17
|
+
* progress) project the turn-wide `TurnExecutionState`; when omitted, the
|
|
18
|
+
* defaults cannot reject a turn (unknown intent, no mutations, no task list).
|
|
19
|
+
*/
|
|
20
|
+
export declare function terminalTurnStatus(input: {
|
|
21
|
+
aborted: boolean;
|
|
22
|
+
error?: unknown;
|
|
23
|
+
assistantText: string;
|
|
24
|
+
sawToolCall: boolean;
|
|
25
|
+
lastToolOk?: boolean;
|
|
26
|
+
finishReason?: string;
|
|
27
|
+
budgetReached?: boolean;
|
|
28
|
+
unresolvedToolInputError?: boolean;
|
|
29
|
+
intent?: RequestIntent;
|
|
30
|
+
mutationCount?: number;
|
|
31
|
+
validationOutcome?: ValidationOutcome;
|
|
32
|
+
taskProgress?: WorkTaskProgress;
|
|
33
|
+
}): TurnStatus;
|
|
34
|
+
/** Bounded recovery slice an attempt proposes for the next agent call. */
|
|
35
|
+
type AttemptRecovery = {
|
|
36
|
+
kind: 'length' | 'rescue' | 'goal';
|
|
37
|
+
control: string;
|
|
38
|
+
slice: {
|
|
39
|
+
maxSteps: number;
|
|
40
|
+
maxToolCalls: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** Internal per-attempt result: the turn outcome plus retry/recovery directives for `runAgentTurn`. */
|
|
44
|
+
export type AgentAttemptResult = TurnResult & {
|
|
45
|
+
retry?: {
|
|
46
|
+
attempt: number;
|
|
47
|
+
contextOverflowRecovered: boolean;
|
|
48
|
+
delayMs: number; /** The retry aborts the previous controller (idle stall); hand the loop a fresh one. */
|
|
49
|
+
freshController?: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** When set, run one bounded recovery slice next (length-continuation, rescue, or goal continuation). */
|
|
52
|
+
recovery?: AttemptRecovery;
|
|
53
|
+
};
|
|
54
|
+
/** Keep terminal evidence truthful on normal, timeout, and forced-settlement paths. */
|
|
55
|
+
export declare function projectGoalEvidence(turnState: TurnExecutionState, goal: SessionGoal): void;
|
|
56
|
+
export interface AttemptOutcomeDeps {
|
|
57
|
+
value: string;
|
|
58
|
+
callbacks: StreamCallbacks;
|
|
59
|
+
abortController: AbortController;
|
|
60
|
+
turnOptions: TurnExecutionOptions;
|
|
61
|
+
turnState: TurnExecutionState;
|
|
62
|
+
turnBudget: TurnBudget;
|
|
63
|
+
goal: SessionGoal;
|
|
64
|
+
remainingTurnDeadlineMs: () => number;
|
|
65
|
+
stream: AttemptStreamOutcome;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Classify the finished attempt: project work evidence onto the turn state,
|
|
69
|
+
* decide the authoritative turn status and goal status, then propose bounded
|
|
70
|
+
* recovery (length-continuation, goal continuation, rescue) or an
|
|
71
|
+
* `incomplete-goal` checkpoint when no same-turn recovery can run. Never
|
|
72
|
+
* reports incomplete work as `complete`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function finalizeAttemptOutcome(deps: AttemptOutcomeDeps): AgentAttemptResult;
|
|
75
|
+
export interface AttemptFailureDeps {
|
|
76
|
+
value: string;
|
|
77
|
+
callbacks: StreamCallbacks;
|
|
78
|
+
abortController: AbortController;
|
|
79
|
+
turnState: TurnExecutionState;
|
|
80
|
+
retryAttempt: number;
|
|
81
|
+
contextOverflowRecovered: boolean;
|
|
82
|
+
abortCause: TurnAbortCause;
|
|
83
|
+
stallGuard: StreamStallGuard | undefined;
|
|
84
|
+
salvage: AttemptSalvage;
|
|
85
|
+
error: unknown;
|
|
86
|
+
/** Retry-pool size for this turn (`modelRetries` setting); defaults to DEFAULT_MODEL_RETRIES. */
|
|
87
|
+
maxRetries?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Classify a failed attempt from the recorded abort cause and the error:
|
|
91
|
+
* idle-stall retry/pause (shared bounded retry pool), absolute turn deadline,
|
|
92
|
+
* user abort, context-overflow compaction retry, transient model retry, or a
|
|
93
|
+
* hard model-call failure. Completed-step progress is always preserved.
|
|
94
|
+
*/
|
|
95
|
+
export declare function handleAttemptFailure(deps: AttemptFailureDeps): AgentAttemptResult;
|
|
96
|
+
export {};
|