@vybestack/llxprt-code-core 0.4.4 → 0.4.5-nightly.251027.c0567b33
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/README.md +9 -0
- package/dist/prompt-config/defaults/default-prompts.json +42 -0
- package/dist/src/auth/precedence.d.ts +2 -0
- package/dist/src/auth/precedence.js +94 -62
- package/dist/src/auth/precedence.js.map +1 -1
- package/dist/src/config/config.d.ts +2 -6
- package/dist/src/config/config.js +60 -17
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/index.d.ts +1 -1
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/core/client.d.ts +10 -6
- package/dist/src/core/client.js +128 -68
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +8 -3
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +6 -5
- package/dist/src/core/geminiChat.js +90 -56
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/prompts.js +8 -3
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompt-config/TemplateEngine.js +46 -9
- package/dist/src/prompt-config/TemplateEngine.js.map +1 -1
- package/dist/src/prompt-config/defaults/core-defaults.js +15 -1
- package/dist/src/prompt-config/defaults/core-defaults.js.map +1 -1
- package/dist/src/prompt-config/defaults/core.md +15 -1
- package/dist/src/prompt-config/defaults/manifest-loader.d.ts +9 -0
- package/dist/src/prompt-config/defaults/manifest-loader.js +98 -0
- package/dist/src/prompt-config/defaults/manifest-loader.js.map +1 -0
- package/dist/src/prompt-config/defaults/prompt-warnings.d.ts +8 -0
- package/dist/src/prompt-config/defaults/prompt-warnings.js +29 -0
- package/dist/src/prompt-config/defaults/prompt-warnings.js.map +1 -0
- package/dist/src/prompt-config/defaults/provider-defaults.js +15 -1
- package/dist/src/prompt-config/defaults/provider-defaults.js.map +1 -1
- package/dist/src/prompt-config/defaults/providers/anthropic/core.md +16 -0
- package/dist/src/prompt-config/defaults/providers/gemini/core.md +7 -2
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md +6 -2
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md +6 -2
- package/dist/src/prompt-config/defaults/providers/openai/core.md +16 -0
- package/dist/src/prompt-config/defaults/providers/openai/tools/todo-pause.md +1 -1
- package/dist/src/prompt-config/defaults/tool-defaults.js +14 -1
- package/dist/src/prompt-config/defaults/tool-defaults.js.map +1 -1
- package/dist/src/prompt-config/defaults/tools/memory.md +1 -1
- package/dist/src/prompt-config/defaults/tools/save-memory.md +1 -0
- package/dist/src/prompt-config/defaults/tools/todo-pause.md +28 -0
- package/dist/src/prompt-config/types.d.ts +3 -0
- package/dist/src/providers/BaseProvider.d.ts +2 -2
- package/dist/src/providers/BaseProvider.js +1 -1
- package/dist/src/providers/BaseProvider.js.map +1 -1
- package/dist/src/providers/IProvider.d.ts +2 -2
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +3 -1
- package/dist/src/providers/anthropic/AnthropicProvider.js +34 -6
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +3 -1
- package/dist/src/providers/gemini/GeminiProvider.js +142 -66
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.d.ts +3 -6
- package/dist/src/providers/openai/OpenAIProvider.js +238 -63
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/parseResponsesStream.js +14 -3
- package/dist/src/providers/openai/parseResponsesStream.js.map +1 -1
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.d.ts +4 -2
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js +38 -11
- package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js.map +1 -1
- package/dist/src/services/complexity-analyzer.d.ts +10 -1
- package/dist/src/services/complexity-analyzer.js +57 -10
- package/dist/src/services/complexity-analyzer.js.map +1 -1
- package/dist/src/services/history/HistoryService.d.ts +8 -0
- package/dist/src/services/history/HistoryService.js +37 -4
- package/dist/src/services/history/HistoryService.js.map +1 -1
- package/dist/src/services/todo-reminder-service.d.ts +5 -0
- package/dist/src/services/todo-reminder-service.js +26 -3
- package/dist/src/services/todo-reminder-service.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -1
- package/dist/src/telemetry/constants.js +0 -1
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -2
- package/dist/src/telemetry/index.js +2 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +1 -2
- package/dist/src/telemetry/loggers.js +1 -17
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +1 -7
- package/dist/src/telemetry/types.js +0 -10
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/todo/todoFormatter.d.ts +24 -0
- package/dist/src/todo/todoFormatter.js +173 -0
- package/dist/src/todo/todoFormatter.js.map +1 -0
- package/dist/src/tools/mcp-tool.js +30 -2
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/todo-read.d.ts +0 -2
- package/dist/src/tools/todo-read.js +8 -91
- package/dist/src/tools/todo-read.js.map +1 -1
- package/dist/src/tools/todo-write.d.ts +0 -1
- package/dist/src/tools/todo-write.js +4 -30
- package/dist/src/tools/todo-write.js.map +1 -1
- package/dist/src/types/modelParams.d.ts +2 -0
- package/dist/src/utils/errorParsing.js +70 -5
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/retry.d.ts +4 -2
- package/dist/src/utils/retry.js +129 -86
- package/dist/src/utils/retry.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ import { BaseTool, Kind } from './tools.js';
|
|
|
7
7
|
import { TodoStore } from './todo-store.js';
|
|
8
8
|
import { Type } from '@google/genai';
|
|
9
9
|
import { TodoReminderService } from '../services/todo-reminder-service.js';
|
|
10
|
+
import { formatTodoListForDisplay } from '../todo/todoFormatter.js';
|
|
11
|
+
import { ToolCallTrackerService } from '../services/tool-call-tracker-service.js';
|
|
10
12
|
export class TodoRead extends BaseTool {
|
|
11
13
|
static Name = 'todo_read';
|
|
12
14
|
reminderService = new TodoReminderService();
|
|
@@ -26,22 +28,17 @@ export class TodoRead extends BaseTool {
|
|
|
26
28
|
const agentId = this.context?.agentId;
|
|
27
29
|
const store = new TodoStore(sessionId, agentId);
|
|
28
30
|
const todos = await store.readTodos();
|
|
31
|
+
const output = formatTodoListForDisplay(todos, {
|
|
32
|
+
getLiveToolCalls: (todoId) => ToolCallTrackerService.getAllToolCalls(sessionId, todoId),
|
|
33
|
+
});
|
|
29
34
|
if (todos.length === 0) {
|
|
30
|
-
|
|
31
|
-
const isComplexTask = false; // Placeholder - will be determined by context
|
|
35
|
+
const isComplexTask = false;
|
|
32
36
|
const reminder = this.reminderService.getReminderForEmptyTodos(isComplexTask);
|
|
33
|
-
const emptyOutput = '## Todo List\n\n' +
|
|
34
|
-
'No todos found.\n\n' +
|
|
35
|
-
'Use TodoWrite to create a task list when working on multi-step projects.';
|
|
36
37
|
return {
|
|
37
|
-
llmContent:
|
|
38
|
-
returnDisplay:
|
|
38
|
+
llmContent: output + (reminder || ''),
|
|
39
|
+
returnDisplay: output,
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
// Group and sort todos
|
|
42
|
-
const groupedTodos = this.groupTodosByStatus(todos);
|
|
43
|
-
// Format output
|
|
44
|
-
const output = this.formatTodos(groupedTodos, todos);
|
|
45
42
|
// Calculate metadata
|
|
46
43
|
const statistics = this.calculateStatistics(todos);
|
|
47
44
|
const suggestedAction = this.determineSuggestedAction(todos);
|
|
@@ -55,86 +52,6 @@ export class TodoRead extends BaseTool {
|
|
|
55
52
|
},
|
|
56
53
|
};
|
|
57
54
|
}
|
|
58
|
-
groupTodosByStatus(todos) {
|
|
59
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
60
|
-
const sortByPriority = (a, b) => priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
61
|
-
return {
|
|
62
|
-
inProgress: todos
|
|
63
|
-
.filter((t) => t.status === 'in_progress')
|
|
64
|
-
.sort(sortByPriority),
|
|
65
|
-
pending: todos.filter((t) => t.status === 'pending').sort(sortByPriority),
|
|
66
|
-
completed: todos
|
|
67
|
-
.filter((t) => t.status === 'completed')
|
|
68
|
-
.sort(sortByPriority),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
formatTodos(groupedTodos, allTodos) {
|
|
72
|
-
const priorityIndicators = {
|
|
73
|
-
high: '[HIGH]',
|
|
74
|
-
medium: '[MEDIUM]',
|
|
75
|
-
low: '[LOW]',
|
|
76
|
-
};
|
|
77
|
-
const statusIcons = {
|
|
78
|
-
in_progress: '[IN_PROGRESS]',
|
|
79
|
-
pending: '[ ]',
|
|
80
|
-
completed: '[*]',
|
|
81
|
-
};
|
|
82
|
-
let output = '## Todo List\n\n';
|
|
83
|
-
// In Progress section
|
|
84
|
-
if (groupedTodos.inProgress.length > 0) {
|
|
85
|
-
output += '### In Progress\n\n';
|
|
86
|
-
for (const todo of groupedTodos.inProgress) {
|
|
87
|
-
const icon = statusIcons[todo.status];
|
|
88
|
-
const priorityIcon = priorityIndicators[todo.priority];
|
|
89
|
-
output += `${icon} **${todo.content}** ${priorityIcon} ${todo.priority}\n`;
|
|
90
|
-
}
|
|
91
|
-
output += '\n';
|
|
92
|
-
}
|
|
93
|
-
// Pending section
|
|
94
|
-
if (groupedTodos.pending.length > 0) {
|
|
95
|
-
output += '### Pending\n\n';
|
|
96
|
-
for (const todo of groupedTodos.pending) {
|
|
97
|
-
const icon = statusIcons[todo.status];
|
|
98
|
-
const priorityIcon = priorityIndicators[todo.priority];
|
|
99
|
-
output += `${icon} **${todo.content}** ${priorityIcon} ${todo.priority}\n`;
|
|
100
|
-
}
|
|
101
|
-
output += '\n';
|
|
102
|
-
}
|
|
103
|
-
// Completed section
|
|
104
|
-
if (groupedTodos.completed.length > 0) {
|
|
105
|
-
output += '### Completed\n\n';
|
|
106
|
-
for (const todo of groupedTodos.completed) {
|
|
107
|
-
const icon = statusIcons[todo.status];
|
|
108
|
-
const priorityIcon = priorityIndicators[todo.priority];
|
|
109
|
-
output += `${icon} **${todo.content}** ${priorityIcon} ${todo.priority}\n`;
|
|
110
|
-
}
|
|
111
|
-
output += '\n';
|
|
112
|
-
}
|
|
113
|
-
// Summary
|
|
114
|
-
const stats = this.calculateStatistics(allTodos);
|
|
115
|
-
output += '### Summary\n\n';
|
|
116
|
-
output += `- Total: ${stats.total} tasks\n`;
|
|
117
|
-
output += `- In Progress: ${stats.inProgress}\n`;
|
|
118
|
-
output += `- Pending: ${stats.pending}\n`;
|
|
119
|
-
output += `- Completed: ${stats.completed}\n\n`;
|
|
120
|
-
output += `Priority distribution:\n`;
|
|
121
|
-
output += `- High priority: ${stats.highPriority}\n`;
|
|
122
|
-
output += `- Medium priority: ${stats.mediumPriority}\n`;
|
|
123
|
-
output += `- Low priority: ${stats.lowPriority}\n\n`;
|
|
124
|
-
// Suggested Next Action
|
|
125
|
-
const suggestedAction = this.determineSuggestedAction(allTodos);
|
|
126
|
-
output += '### Suggested Next Action\n\n';
|
|
127
|
-
if (suggestedAction.type === 'all-complete') {
|
|
128
|
-
output += 'All tasks are completed\n';
|
|
129
|
-
}
|
|
130
|
-
else if (suggestedAction.type === 'continue') {
|
|
131
|
-
output += `Continue working on: **${suggestedAction.taskContent}**\n`;
|
|
132
|
-
}
|
|
133
|
-
else if (suggestedAction.type === 'start') {
|
|
134
|
-
output += `Consider starting: **${suggestedAction.taskContent}**\n`;
|
|
135
|
-
}
|
|
136
|
-
return output;
|
|
137
|
-
}
|
|
138
55
|
calculateStatistics(todos) {
|
|
139
56
|
return {
|
|
140
57
|
total: todos.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-read.js","sourceRoot":"","sources":["../../../src/tools/todo-read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"todo-read.js","sourceRoot":"","sources":["../../../src/tools/todo-read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,MAAM,OAAO,QAAS,SAAQ,QAAoC;IAChE,MAAM,CAAU,IAAI,GAAG,WAAW,CAAC;IAC3B,eAAe,GAAG,IAAI,mBAAmB,EAAE,CAAC;IAEpD;QACE,KAAK,CACH,QAAQ,CAAC,IAAI,EACb,UAAU,EACV,yGAAyG,EACzG,IAAI,CAAC,KAAK,EACV;YACE,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,UAAU,EAAE,EAAE;SACf,EACD,IAAI,EAAE,mBAAmB;QACzB,KAAK,CACN,CAAC;IACJ,CAAC;IAEQ,cAAc,CAAC,OAAuB;QAC7C,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,OAAO,CACX,OAAuB,EACvB,OAAoB,EACpB,aAAwC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CAAC;YACN,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,WAAW,EAAE,IAAI,CAAC,OAAO;aAC1B,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QACjE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,2CAA2C;YAC3C,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACtC,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;gBACrD,OAAO,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACN,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,WAAW,EAAE,IAAI,CAAC,OAAO;aAC1B,CAAC;QACJ,CAAC;QAED,0BAA0B;QAC1B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAClC,CAAC"}
|
|
@@ -14,7 +14,6 @@ export declare class TodoWrite extends BaseTool<TodoWriteParams, ToolResult> {
|
|
|
14
14
|
constructor();
|
|
15
15
|
getDescription(params: TodoWriteParams): string;
|
|
16
16
|
execute(params: TodoWriteParams, _signal: AbortSignal, _updateOutput?: (output: string) => void): Promise<ToolResult>;
|
|
17
|
-
private generateSimplifiedOutput;
|
|
18
17
|
private calculateStatistics;
|
|
19
18
|
private determineNextAction;
|
|
20
19
|
}
|
|
@@ -10,6 +10,7 @@ import { TodoStore } from './todo-store.js';
|
|
|
10
10
|
import { TodoReminderService } from '../services/todo-reminder-service.js';
|
|
11
11
|
import { todoEvents } from './todo-events.js';
|
|
12
12
|
import { TodoContextTracker } from '../services/todo-context-tracker.js';
|
|
13
|
+
import { formatTodoListForDisplay } from '../todo/todoFormatter.js';
|
|
13
14
|
export class TodoWrite extends BaseTool {
|
|
14
15
|
static Name = 'todo_write';
|
|
15
16
|
reminderService = new TodoReminderService();
|
|
@@ -132,21 +133,12 @@ export class TodoWrite extends BaseTool {
|
|
|
132
133
|
};
|
|
133
134
|
todoEvents.emitTodoUpdated(event);
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
-
let output;
|
|
137
|
-
if (isInteractive) {
|
|
138
|
-
// In interactive mode, suppress markdown and return minimal result
|
|
139
|
-
output = 'TODO list updated';
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
// In non-interactive mode, provide simplified markdown
|
|
143
|
-
output = this.generateSimplifiedOutput(params.todos);
|
|
144
|
-
}
|
|
136
|
+
const formattedOutput = formatTodoListForDisplay(params.todos);
|
|
145
137
|
const statistics = this.calculateStatistics(params.todos);
|
|
146
138
|
const nextAction = this.determineNextAction(params.todos);
|
|
147
139
|
return {
|
|
148
|
-
llmContent:
|
|
149
|
-
returnDisplay:
|
|
140
|
+
llmContent: formattedOutput + (reminder || ''),
|
|
141
|
+
returnDisplay: formattedOutput,
|
|
150
142
|
metadata: {
|
|
151
143
|
stateChanged: this.reminderService.shouldGenerateReminder(stateChange),
|
|
152
144
|
todosAdded: stateChange.added.length,
|
|
@@ -157,24 +149,6 @@ export class TodoWrite extends BaseTool {
|
|
|
157
149
|
},
|
|
158
150
|
};
|
|
159
151
|
}
|
|
160
|
-
generateSimplifiedOutput(todos) {
|
|
161
|
-
let output = `## Todo List (${todos.length} tasks)\n`;
|
|
162
|
-
for (const todo of todos) {
|
|
163
|
-
// Determine status marker
|
|
164
|
-
let marker = '';
|
|
165
|
-
if (todo.status === 'completed') {
|
|
166
|
-
marker = '- [x]';
|
|
167
|
-
}
|
|
168
|
-
else if (todo.status === 'pending') {
|
|
169
|
-
marker = '- [ ]';
|
|
170
|
-
}
|
|
171
|
-
else if (todo.status === 'in_progress') {
|
|
172
|
-
marker = '- [→] ← current';
|
|
173
|
-
}
|
|
174
|
-
output += `${marker} ${todo.content}\n`;
|
|
175
|
-
}
|
|
176
|
-
return output;
|
|
177
|
-
}
|
|
178
152
|
calculateStatistics(todos) {
|
|
179
153
|
return {
|
|
180
154
|
total: todos.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo-write.js","sourceRoot":"","sources":["../../../src/tools/todo-write.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAQ,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"todo-write.js","sourceRoot":"","sources":["../../../src/tools/todo-write.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAc,IAAI,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAQ,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kB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,OAAO;aAC1B,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QACjE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,2CAA2C;YAC3C,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACtC,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;gBACrD,OAAO,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACN,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,WAAW,EAAE,IAAI,CAAC,OAAO;aAC1B,CAAC;QACJ,CAAC;QAED,0BAA0B;QAC1B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAClC,CAAC"}
|
|
@@ -72,6 +72,8 @@ export interface EphemeralSettings {
|
|
|
72
72
|
retries?: number;
|
|
73
73
|
/** Initial delay in milliseconds between retry attempts */
|
|
74
74
|
retrywait?: number;
|
|
75
|
+
/** Force OAuth authentication and ignore API keys/env vars */
|
|
76
|
+
authOnly?: boolean;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Complete profile configuration
|
|
@@ -7,6 +7,7 @@ import { isProQuotaExceededError, isGenericQuotaExceededError, isApiError, isStr
|
|
|
7
7
|
import { DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL, } from '../config/models.js';
|
|
8
8
|
import { UserTierId } from '../code_assist/types.js';
|
|
9
9
|
import { AuthType } from '../core/contentGenerator.js';
|
|
10
|
+
import { getErrorStatus, STREAM_INTERRUPTED_ERROR_CODE } from './retry.js';
|
|
10
11
|
// Free Tier message functions
|
|
11
12
|
const getRateLimitErrorMessageGoogleFree = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `\nPossible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
12
13
|
const getRateLimitErrorMessageGoogleProQuotaFree = (currentModel = DEFAULT_GEMINI_MODEL, fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `\nYou have reached your daily ${currentModel} quota limit. You will be switched to the ${fallbackModel} model for the rest of this session. To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
@@ -18,6 +19,48 @@ const getRateLimitErrorMessageGoogleGenericQuotaPaid = (currentModel = DEFAULT_G
|
|
|
18
19
|
const RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI = '\nPlease wait and try again later. To increase your limits, request a quota increase through AI Studio, or switch to another /auth method';
|
|
19
20
|
const RATE_LIMIT_ERROR_MESSAGE_VERTEX = '\nPlease wait and try again later. To increase your limits, request a quota increase through Vertex, or switch to another /auth method';
|
|
20
21
|
const getRateLimitErrorMessageDefault = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `\nPossible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
22
|
+
function buildStatusSuffix(status, statusLabel) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (typeof status === 'number' && Number.isFinite(status)) {
|
|
25
|
+
parts.push(String(status));
|
|
26
|
+
}
|
|
27
|
+
if (typeof statusLabel === 'string') {
|
|
28
|
+
const trimmed = statusLabel.trim();
|
|
29
|
+
if (trimmed.length > 0 && !parts.includes(trimmed)) {
|
|
30
|
+
parts.push(trimmed);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (parts.length === 0) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
return ` (Status: ${parts.join(', ')})`;
|
|
37
|
+
}
|
|
38
|
+
function formatErrorMessageWithStatus(message, status, statusLabel) {
|
|
39
|
+
if (message.includes('(Status:')) {
|
|
40
|
+
return message;
|
|
41
|
+
}
|
|
42
|
+
const suffix = buildStatusSuffix(status, statusLabel);
|
|
43
|
+
if (!suffix) {
|
|
44
|
+
return message;
|
|
45
|
+
}
|
|
46
|
+
return `${message}${suffix}`;
|
|
47
|
+
}
|
|
48
|
+
function getErrorCodeFromUnknown(error) {
|
|
49
|
+
if (typeof error === 'object' && error !== null) {
|
|
50
|
+
if ('code' in error &&
|
|
51
|
+
typeof error.code === 'string') {
|
|
52
|
+
return error.code;
|
|
53
|
+
}
|
|
54
|
+
if ('error' in error &&
|
|
55
|
+
typeof error.error === 'object' &&
|
|
56
|
+
error.error !== null &&
|
|
57
|
+
'code' in error.error &&
|
|
58
|
+
typeof error.error.code === 'string') {
|
|
59
|
+
return error.error.code;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
21
64
|
function getRateLimitMessage(authType, error, userTier, currentModel, fallbackModel) {
|
|
22
65
|
switch (authType) {
|
|
23
66
|
case AuthType.LOGIN_WITH_GOOGLE: {
|
|
@@ -48,19 +91,32 @@ function getRateLimitMessage(authType, error, userTier, currentModel, fallbackMo
|
|
|
48
91
|
}
|
|
49
92
|
}
|
|
50
93
|
export function parseAndFormatApiError(error, authType, userTier, currentModel, fallbackModel) {
|
|
94
|
+
const errorCode = getErrorCodeFromUnknown(error);
|
|
95
|
+
if (errorCode === STREAM_INTERRUPTED_ERROR_CODE) {
|
|
96
|
+
const baseMessage = typeof error === 'object' &&
|
|
97
|
+
error !== null &&
|
|
98
|
+
'message' in error &&
|
|
99
|
+
typeof error.message === 'string'
|
|
100
|
+
? error.message
|
|
101
|
+
: 'Streaming parse error: model response contained malformed data.';
|
|
102
|
+
const formattedMessage = formatErrorMessageWithStatus(baseMessage, undefined, 'STREAM_INTERRUPTED');
|
|
103
|
+
return `[API Error: ${formattedMessage}]\nStreaming data from the provider became invalid before the response completed. Please retry.`;
|
|
104
|
+
}
|
|
51
105
|
// For provider auth type, don't add Gemini-specific rate limit messages
|
|
52
106
|
if (authType === AuthType.USE_PROVIDER) {
|
|
53
107
|
if (isStructuredError(error)) {
|
|
54
|
-
|
|
55
|
-
|
|
108
|
+
const status = getErrorStatus(error);
|
|
109
|
+
let text = `[API Error: ${formatErrorMessageWithStatus(error.message, status)}]`;
|
|
110
|
+
if (status === 429) {
|
|
56
111
|
text += '\nRate limit exceeded. Please wait and try again later.';
|
|
57
112
|
}
|
|
58
113
|
return text;
|
|
59
114
|
}
|
|
60
115
|
}
|
|
61
116
|
if (isStructuredError(error)) {
|
|
62
|
-
|
|
63
|
-
|
|
117
|
+
const status = getErrorStatus(error);
|
|
118
|
+
let text = `[API Error: ${formatErrorMessageWithStatus(error.message, status)}]`;
|
|
119
|
+
if (status === 429) {
|
|
64
120
|
text += getRateLimitMessage(authType, error, userTier, currentModel, fallbackModel);
|
|
65
121
|
}
|
|
66
122
|
return text;
|
|
@@ -86,7 +142,12 @@ export function parseAndFormatApiError(error, authType, userTier, currentModel,
|
|
|
86
142
|
catch (_e) {
|
|
87
143
|
// It's not a nested JSON error, so we just use the message as is.
|
|
88
144
|
}
|
|
89
|
-
|
|
145
|
+
const statusSuffix = buildStatusSuffix(typeof parsedError.error.code === 'number'
|
|
146
|
+
? parsedError.error.code
|
|
147
|
+
: undefined, typeof parsedError.error.status === 'string'
|
|
148
|
+
? parsedError.error.status
|
|
149
|
+
: undefined);
|
|
150
|
+
let text = `[API Error: ${finalMessage}${statusSuffix}]`;
|
|
90
151
|
if (parsedError.error.code === 429) {
|
|
91
152
|
// For provider auth type, use generic rate limit message
|
|
92
153
|
if (authType === AuthType.USE_PROVIDER) {
|
|
@@ -104,6 +165,10 @@ export function parseAndFormatApiError(error, authType, userTier, currentModel,
|
|
|
104
165
|
}
|
|
105
166
|
return `[API Error: ${error}]`;
|
|
106
167
|
}
|
|
168
|
+
const fallbackStatusSuffix = buildStatusSuffix(getErrorStatus(error));
|
|
169
|
+
if (fallbackStatusSuffix) {
|
|
170
|
+
return `[API Error: An unknown error occurred.${fallbackStatusSuffix}]`;
|
|
171
|
+
}
|
|
107
172
|
return '[API Error: An unknown error occurred.]';
|
|
108
173
|
}
|
|
109
174
|
//# sourceMappingURL=errorParsing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorParsing.js","sourceRoot":"","sources":["../../../src/utils/errorParsing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"errorParsing.js","sourceRoot":"","sources":["../../../src/utils/errorParsing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3E,8BAA8B;AAC9B,MAAM,kCAAkC,GAAG,CACzC,gBAAwB,0BAA0B,EAClD,EAAE,CACF,2FAA2F,aAAa,s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,aAAa,CACd,CAAC;oBACJ,CAAC;gBACH,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,kEAAkE;QACpE,CAAC;QACD,OAAO,eAAe,KAAK,GAAG,CAAC;IACjC,CAAC;IAED,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,IAAI,oBAAoB,EAAE,CAAC;QACzB,OAAO,yCAAyC,oBAAoB,GAAG,CAAC;IAC1E,CAAC;IAED,OAAO,yCAAyC,CAAC;AACnD,CAAC"}
|
|
@@ -12,10 +12,12 @@ export interface RetryOptions {
|
|
|
12
12
|
initialDelayMs: number;
|
|
13
13
|
maxDelayMs: number;
|
|
14
14
|
shouldRetry: (error: Error) => boolean;
|
|
15
|
-
onPersistent429?: (authType?: string, error?: unknown) => Promise<string | boolean | null>;
|
|
16
|
-
authType?: string;
|
|
17
15
|
trackThrottleWaitTime?: (waitTimeMs: number) => void;
|
|
18
16
|
}
|
|
17
|
+
export declare const STREAM_INTERRUPTED_ERROR_CODE = "LLXPRT_STREAM_INTERRUPTED";
|
|
18
|
+
export declare function createStreamInterruptionError(message: string, details?: Record<string, unknown>, cause?: unknown): Error;
|
|
19
|
+
export declare function getErrorCode(error: unknown): string | undefined;
|
|
20
|
+
export declare function isNetworkTransientError(error: unknown): boolean;
|
|
19
21
|
/**
|
|
20
22
|
* Retries a function with exponential backoff and jitter.
|
|
21
23
|
* @param fn The asynchronous function to retry.
|