@google/gemini-cli-core 0.19.0-preview.0 → 0.20.0-nightly.20251127.5bed97064
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/dist/google-gemini-cli-core-0.20.0-nightly.20251126.d2a6cff4d.tgz +0 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +1 -1
- package/dist/src/availability/modelAvailabilityService.js +2 -2
- package/dist/src/availability/modelAvailabilityService.js.map +1 -1
- package/dist/src/availability/modelAvailabilityService.test.js +3 -3
- package/dist/src/availability/modelAvailabilityService.test.js.map +1 -1
- package/dist/src/availability/policyHelpers.d.ts +21 -0
- package/dist/src/availability/policyHelpers.js +41 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/policyHelpers.test.d.ts +6 -0
- package/dist/src/availability/policyHelpers.test.js +51 -0
- package/dist/src/availability/policyHelpers.test.js.map +1 -0
- package/dist/src/config/config.d.ts +8 -1
- package/dist/src/config/config.js +17 -1
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +14 -0
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/core/client.js +4 -37
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +45 -0
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +55 -0
- package/dist/src/core/coreToolHookTriggers.js +244 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolScheduler.js +11 -2
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +66 -1
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +90 -18
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +14 -3
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +64 -0
- package/dist/src/core/geminiChatHookTriggers.js +136 -0
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -0
- package/dist/src/core/prompts.js +38 -19
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/fallback/handler.js +105 -28
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +145 -0
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +8 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.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/mcp/auth-provider.d.ts +16 -0
- package/dist/src/mcp/auth-provider.js +7 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +10 -2
- package/dist/src/mcp/google-auth-provider.js +28 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +45 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +2 -2
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/services/chatCompressionService.js +2 -2
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +7 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +1 -0
- package/dist/src/tools/mcp-client-manager.js +13 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +35 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +1 -0
- package/dist/src/tools/mcp-client.js +4 -1
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +48 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/shell.js +43 -3
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +23 -4
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/utils/exitCodes.d.ts +12 -0
- package/dist/src/utils/exitCodes.js +13 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.js +5 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +28 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +19 -0
- package/dist/src/utils/tokenCalculation.js +70 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tokenCalculation.test.d.ts +6 -0
- package/dist/src/utils/tokenCalculation.test.js +78 -0
- package/dist/src/utils/tokenCalculation.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { GenerateContentResponse, GenerateContentParameters, GenerateContentConfig, ContentListUnion, ToolConfig, ToolListUnion } from '@google/genai';
|
|
7
|
+
import type { MessageBus } from '../confirmation-bus/message-bus.js';
|
|
8
|
+
/**
|
|
9
|
+
* Result from firing the BeforeModel hook.
|
|
10
|
+
*/
|
|
11
|
+
export interface BeforeModelHookResult {
|
|
12
|
+
/** Whether the model call was blocked */
|
|
13
|
+
blocked: boolean;
|
|
14
|
+
/** Reason for blocking (if blocked) */
|
|
15
|
+
reason?: string;
|
|
16
|
+
/** Synthetic response to return instead of calling the model (if blocked) */
|
|
17
|
+
syntheticResponse?: GenerateContentResponse;
|
|
18
|
+
/** Modified config (if not blocked) */
|
|
19
|
+
modifiedConfig?: GenerateContentConfig;
|
|
20
|
+
/** Modified contents (if not blocked) */
|
|
21
|
+
modifiedContents?: ContentListUnion;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result from firing the BeforeToolSelection hook.
|
|
25
|
+
*/
|
|
26
|
+
export interface BeforeToolSelectionHookResult {
|
|
27
|
+
/** Modified tool config */
|
|
28
|
+
toolConfig?: ToolConfig;
|
|
29
|
+
/** Modified tools */
|
|
30
|
+
tools?: ToolListUnion;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result from firing the AfterModel hook.
|
|
34
|
+
* Contains either a modified response or indicates to use the original chunk.
|
|
35
|
+
*/
|
|
36
|
+
export interface AfterModelHookResult {
|
|
37
|
+
/** The response to yield (either modified or original) */
|
|
38
|
+
response: GenerateContentResponse;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fires the BeforeModel hook and returns the result.
|
|
42
|
+
*
|
|
43
|
+
* @param messageBus The message bus to use for hook communication
|
|
44
|
+
* @param llmRequest The LLM request parameters
|
|
45
|
+
* @returns The hook result with blocking info or modifications
|
|
46
|
+
*/
|
|
47
|
+
export declare function fireBeforeModelHook(messageBus: MessageBus, llmRequest: GenerateContentParameters): Promise<BeforeModelHookResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Fires the BeforeToolSelection hook and returns the result.
|
|
50
|
+
*
|
|
51
|
+
* @param messageBus The message bus to use for hook communication
|
|
52
|
+
* @param llmRequest The LLM request parameters
|
|
53
|
+
* @returns The hook result with tool configuration modifications
|
|
54
|
+
*/
|
|
55
|
+
export declare function fireBeforeToolSelectionHook(messageBus: MessageBus, llmRequest: GenerateContentParameters): Promise<BeforeToolSelectionHookResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Fires the AfterModel hook and returns the result.
|
|
58
|
+
*
|
|
59
|
+
* @param messageBus The message bus to use for hook communication
|
|
60
|
+
* @param originalRequest The original LLM request parameters
|
|
61
|
+
* @param chunk The current response chunk from the model
|
|
62
|
+
* @returns The hook result containing the response to yield
|
|
63
|
+
*/
|
|
64
|
+
export declare function fireAfterModelHook(messageBus: MessageBus, originalRequest: GenerateContentParameters, chunk: GenerateContentResponse): Promise<AfterModelHookResult>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { MessageBusType, } from '../confirmation-bus/types.js';
|
|
7
|
+
import { createHookOutput, } from '../hooks/types.js';
|
|
8
|
+
import { debugLogger } from '../utils/debugLogger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Fires the BeforeModel hook and returns the result.
|
|
11
|
+
*
|
|
12
|
+
* @param messageBus The message bus to use for hook communication
|
|
13
|
+
* @param llmRequest The LLM request parameters
|
|
14
|
+
* @returns The hook result with blocking info or modifications
|
|
15
|
+
*/
|
|
16
|
+
export async function fireBeforeModelHook(messageBus, llmRequest) {
|
|
17
|
+
try {
|
|
18
|
+
const response = await messageBus.request({
|
|
19
|
+
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
20
|
+
eventName: 'BeforeModel',
|
|
21
|
+
input: {
|
|
22
|
+
llm_request: llmRequest,
|
|
23
|
+
},
|
|
24
|
+
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
25
|
+
// Reconstruct result from response
|
|
26
|
+
const beforeResultFinalOutput = response.output
|
|
27
|
+
? createHookOutput('BeforeModel', response.output)
|
|
28
|
+
: undefined;
|
|
29
|
+
const hookOutput = beforeResultFinalOutput;
|
|
30
|
+
// Check if hook blocked the model call or requested to stop execution
|
|
31
|
+
const blockingError = hookOutput?.getBlockingError();
|
|
32
|
+
if (blockingError?.blocked || hookOutput?.shouldStopExecution()) {
|
|
33
|
+
const beforeModelOutput = hookOutput;
|
|
34
|
+
const syntheticResponse = beforeModelOutput.getSyntheticResponse();
|
|
35
|
+
const reason = hookOutput?.getEffectiveReason() || 'Model call blocked by hook';
|
|
36
|
+
return {
|
|
37
|
+
blocked: true,
|
|
38
|
+
reason,
|
|
39
|
+
syntheticResponse,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Apply modifications from hook
|
|
43
|
+
if (hookOutput) {
|
|
44
|
+
const beforeModelOutput = hookOutput;
|
|
45
|
+
const modifiedRequest = beforeModelOutput.applyLLMRequestModifications(llmRequest);
|
|
46
|
+
return {
|
|
47
|
+
blocked: false,
|
|
48
|
+
modifiedConfig: modifiedRequest.config,
|
|
49
|
+
modifiedContents: modifiedRequest.contents,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { blocked: false };
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
debugLogger.warn(`BeforeModel hook failed:`, error);
|
|
56
|
+
return { blocked: false };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fires the BeforeToolSelection hook and returns the result.
|
|
61
|
+
*
|
|
62
|
+
* @param messageBus The message bus to use for hook communication
|
|
63
|
+
* @param llmRequest The LLM request parameters
|
|
64
|
+
* @returns The hook result with tool configuration modifications
|
|
65
|
+
*/
|
|
66
|
+
export async function fireBeforeToolSelectionHook(messageBus, llmRequest) {
|
|
67
|
+
try {
|
|
68
|
+
const response = await messageBus.request({
|
|
69
|
+
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
70
|
+
eventName: 'BeforeToolSelection',
|
|
71
|
+
input: {
|
|
72
|
+
llm_request: llmRequest,
|
|
73
|
+
},
|
|
74
|
+
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
75
|
+
// Reconstruct result from response
|
|
76
|
+
const toolSelectionResultFinalOutput = response.output
|
|
77
|
+
? createHookOutput('BeforeToolSelection', response.output)
|
|
78
|
+
: undefined;
|
|
79
|
+
// Apply tool configuration modifications
|
|
80
|
+
if (toolSelectionResultFinalOutput) {
|
|
81
|
+
const beforeToolSelectionOutput = toolSelectionResultFinalOutput;
|
|
82
|
+
const modifiedConfig = beforeToolSelectionOutput.applyToolConfigModifications({
|
|
83
|
+
toolConfig: llmRequest.config?.toolConfig,
|
|
84
|
+
tools: llmRequest.config?.tools,
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
toolConfig: modifiedConfig.toolConfig,
|
|
88
|
+
tools: modifiedConfig.tools,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
debugLogger.warn(`BeforeToolSelection hook failed:`, error);
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fires the AfterModel hook and returns the result.
|
|
100
|
+
*
|
|
101
|
+
* @param messageBus The message bus to use for hook communication
|
|
102
|
+
* @param originalRequest The original LLM request parameters
|
|
103
|
+
* @param chunk The current response chunk from the model
|
|
104
|
+
* @returns The hook result containing the response to yield
|
|
105
|
+
*/
|
|
106
|
+
export async function fireAfterModelHook(messageBus, originalRequest, chunk) {
|
|
107
|
+
try {
|
|
108
|
+
const response = await messageBus.request({
|
|
109
|
+
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
110
|
+
eventName: 'AfterModel',
|
|
111
|
+
input: {
|
|
112
|
+
llm_request: originalRequest,
|
|
113
|
+
llm_response: chunk,
|
|
114
|
+
},
|
|
115
|
+
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
116
|
+
// Reconstruct result from response
|
|
117
|
+
const afterResultFinalOutput = response.output
|
|
118
|
+
? createHookOutput('AfterModel', response.output)
|
|
119
|
+
: undefined;
|
|
120
|
+
// Apply modifications from hook (handles both normal modifications and stop execution)
|
|
121
|
+
if (afterResultFinalOutput) {
|
|
122
|
+
const afterModelOutput = afterResultFinalOutput;
|
|
123
|
+
const modifiedResponse = afterModelOutput.getModifiedResponse();
|
|
124
|
+
if (modifiedResponse) {
|
|
125
|
+
return { response: modifiedResponse };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { response: chunk };
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
debugLogger.warn(`AfterModel hook failed:`, error);
|
|
132
|
+
// On error, return original chunk to avoid interrupting the stream.
|
|
133
|
+
return { response: chunk };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=geminiChatHookTriggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geminiChatHookTriggers.js","sourceRoot":"","sources":["../../../src/core/geminiChatHookTriggers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,GAIjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAqCtD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAsB,EACtB,UAAqC;IAErC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAIvC;YACE,IAAI,EAAE,cAAc,CAAC,sBAAsB;YAC3C,SAAS,EAAE,aAAa;YACxB,KAAK,EAAE;gBACL,WAAW,EAAE,UAAgD;aAC9D;SACF,EACD,cAAc,CAAC,uBAAuB,CACvC,CAAC;QAEF,mCAAmC;QACnC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,MAAM;YAC7C,CAAC,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC;YAClD,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,UAAU,GAAG,uBAAuB,CAAC;QAE3C,sEAAsE;QACtE,MAAM,aAAa,GAAG,UAAU,EAAE,gBAAgB,EAAE,CAAC;QACrD,IAAI,aAAa,EAAE,OAAO,IAAI,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;YAChE,MAAM,iBAAiB,GAAG,UAAmC,CAAC;YAC9D,MAAM,iBAAiB,GAAG,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gB,EAAE,CAAC;YACxC,CAAC;QACH,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,IAAI,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QACnD,oEAAoE;QACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
package/dist/src/core/prompts.js
CHANGED
|
@@ -75,7 +75,11 @@ export function getCoreSystemPrompt(config, userMemory) {
|
|
|
75
75
|
}
|
|
76
76
|
// TODO(joshualitt): Replace with system instructions on model configs.
|
|
77
77
|
const desiredModel = getEffectiveModel(config.isInFallbackMode(), config.getModel(), config.getPreviewFeatures());
|
|
78
|
-
const
|
|
78
|
+
const isGemini3 = desiredModel === PREVIEW_GEMINI_MODEL;
|
|
79
|
+
const mandatesVariant = isGemini3
|
|
80
|
+
? `
|
|
81
|
+
- **Do not call tools in silence:** You must provide to the user very short and concise natural explanation (one sentence) before calling tools.`
|
|
82
|
+
: ``;
|
|
79
83
|
const enableCodebaseInvestigator = config
|
|
80
84
|
.getToolRegistry()
|
|
81
85
|
.getAllToolNames()
|
|
@@ -84,13 +88,14 @@ export function getCoreSystemPrompt(config, userMemory) {
|
|
|
84
88
|
.getToolRegistry()
|
|
85
89
|
.getAllToolNames()
|
|
86
90
|
.includes(WriteTodosTool.Name);
|
|
91
|
+
const interactiveMode = config.isInteractiveShellEnabled();
|
|
87
92
|
let basePrompt;
|
|
88
93
|
if (systemMdEnabled) {
|
|
89
94
|
basePrompt = fs.readFileSync(systemMdPath, 'utf8');
|
|
90
95
|
}
|
|
91
96
|
else {
|
|
92
97
|
const promptConfig = {
|
|
93
|
-
preamble: `You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.`,
|
|
98
|
+
preamble: `You are ${interactiveMode ? 'an interactive ' : 'a non-interactive '}CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.`,
|
|
94
99
|
coreMandates: `
|
|
95
100
|
# Core Mandates
|
|
96
101
|
|
|
@@ -100,9 +105,12 @@ export function getCoreSystemPrompt(config, userMemory) {
|
|
|
100
105
|
- **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
|
|
101
106
|
- **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. *NEVER* talk to the user or describe your changes through comments.
|
|
102
107
|
- **Proactiveness:** Fulfill the user's request thoroughly. When adding features or fixing bugs, this includes adding tests to ensure quality. Consider all created files, especially tests, to be permanent artifacts unless the user says otherwise.
|
|
103
|
-
-
|
|
108
|
+
- ${interactiveMode ? `**Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.` : `**Handle Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request.`}
|
|
104
109
|
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
105
|
-
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes
|
|
110
|
+
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.${mandatesVariant}${!interactiveMode
|
|
111
|
+
? `
|
|
112
|
+
- **Continue the work** You are not to interact with the user. Do your best to complete the task at hand, using your best judgement and avoid asking user for any additional information.`
|
|
113
|
+
: ''}`,
|
|
106
114
|
primaryWorkflows_prefix: `
|
|
107
115
|
# Primary Workflows
|
|
108
116
|
|
|
@@ -135,14 +143,14 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
135
143
|
primaryWorkflows_suffix: `3. **Implement:** Use the available tools (e.g., '${EDIT_TOOL_NAME}', '${WRITE_FILE_TOOL_NAME}' '${SHELL_TOOL_NAME}' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core
|
|
136
144
|
Mandates').
|
|
137
145
|
4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
|
|
138
|
-
5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards
|
|
146
|
+
5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards.${interactiveMode ? " If unsure about these commands, you can ask the user if they'd like you to run them and if so how to." : ''}
|
|
139
147
|
6. **Finalize:** After all verification passes, consider the task complete. Do not remove or revert any changes or created files (like tests). Await the user's next instruction.
|
|
140
148
|
|
|
141
149
|
## New Applications
|
|
142
150
|
|
|
143
151
|
**Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are '${WRITE_FILE_TOOL_NAME}', '${EDIT_TOOL_NAME}' and '${SHELL_TOOL_NAME}'.
|
|
144
152
|
|
|
145
|
-
1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints
|
|
153
|
+
1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints.${interactiveMode ? ' If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.' : ''}
|
|
146
154
|
2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
|
|
147
155
|
- When key technologies aren't specified, prefer the following:
|
|
148
156
|
- **Websites (Frontend):** React (JavaScript/TypeScript) or Angular with Bootstrap CSS, incorporating Material Design principles for UI/UX.
|
|
@@ -152,10 +160,18 @@ Mandates').
|
|
|
152
160
|
- **Mobile App:** Compose Multiplatform (Kotlin Multiplatform) or Flutter (Dart) using Material Design libraries and principles, when sharing code between Android and iOS. Jetpack Compose (Kotlin JVM) with Material Design principles or SwiftUI (Swift) for native apps targeted at either Android or iOS, respectively.
|
|
153
161
|
- **3d Games:** HTML/CSS/JavaScript with Three.js.
|
|
154
162
|
- **2d Games:** HTML/CSS/JavaScript.
|
|
155
|
-
|
|
163
|
+
${(function () {
|
|
164
|
+
if (interactiveMode) {
|
|
165
|
+
return `3. **User Approval:** Obtain user approval for the proposed plan.
|
|
156
166
|
4. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using '${SHELL_TOOL_NAME}' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
|
|
157
167
|
5. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.
|
|
158
|
-
6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype
|
|
168
|
+
6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.`;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return `3. **Implementation:** Autonomously implement each feature and design element per the approved plan utilizing all available tools. When starting ensure you scaffold the application using '${SHELL_TOOL_NAME}' for commands like 'npm init', 'npx create-react-app'. Aim for full scope completion. Proactively create or source necessary placeholder assets (e.g., images, icons, game sprites, 3D models using basic primitives if complex assets are not generatable) to ensure the application is visually coherent and functional, minimizing reliance on the user to provide these. If the model can generate simple assets (e.g., a uniformly colored square sprite, a simple 3D cube), it should do so. Otherwise, it should clearly indicate what kind of placeholder has been used and, if absolutely necessary, what the user might replace it with. Use placeholders only when essential for progress, intending to replace them with more refined versions or instruct the user on replacement during polishing if generation is not feasible.
|
|
172
|
+
4. **Verify:** Review work against the original request, the approved plan. Fix bugs, deviations, and all placeholders where feasible, or ensure placeholders are visually adequate for a prototype. Ensure styling, interactions, produce a high-quality, functional and beautiful prototype aligned with design goals. Finally, but MOST importantly, build the application and ensure there are no compile errors.`;
|
|
173
|
+
}
|
|
174
|
+
})()}`,
|
|
159
175
|
operationalGuidelines: `
|
|
160
176
|
# Operational Guidelines
|
|
161
177
|
${(function () {
|
|
@@ -179,13 +195,13 @@ IT IS CRITICAL TO FOLLOW THESE GUIDELINES TO AVOID EXCESSIVE TOKEN CONSUMPTION.
|
|
|
179
195
|
## Tone and Style (CLI Interaction)
|
|
180
196
|
- **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
|
|
181
197
|
- **Minimal Output:** Aim for fewer than 3 lines of text output (excluding tool use/code generation) per response whenever practical. Focus strictly on the user's query.
|
|
182
|
-
- **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous
|
|
183
|
-
|
|
184
|
-
if (useChattySystemPrompt) {
|
|
198
|
+
- **Clarity over Brevity (When Needed):** While conciseness is key, prioritize clarity for essential explanations or when seeking necessary clarification if a request is ambiguous.${(function () {
|
|
199
|
+
if (isGemini3) {
|
|
185
200
|
return '';
|
|
186
201
|
}
|
|
187
202
|
else {
|
|
188
|
-
return
|
|
203
|
+
return `
|
|
204
|
+
- **No Chitchat:** Avoid conversational filler, preambles ("Okay, I will now..."), or postambles ("I have finished the changes..."). Get straight to the action or answer.`;
|
|
189
205
|
}
|
|
190
206
|
})()}
|
|
191
207
|
- **Formatting:** Use GitHub-flavored Markdown. Responses will be rendered in monospace.
|
|
@@ -199,16 +215,17 @@ ${(function () {
|
|
|
199
215
|
## Tool Usage
|
|
200
216
|
- **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
|
|
201
217
|
- **Command Execution:** Use the '${SHELL_TOOL_NAME}' tool for running shell commands, remembering the safety rule to explain modifying commands first.
|
|
202
|
-
- **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user.
|
|
203
218
|
${(function () {
|
|
204
|
-
if (
|
|
205
|
-
return `- **
|
|
219
|
+
if (interactiveMode) {
|
|
220
|
+
return `- **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user.
|
|
221
|
+
- **Interactive Commands:** Prefer non-interactive commands when it makes sense; however, some commands are only interactive and expect user input during their execution (e.g. ssh, vim). If you choose to execute an interactive command consider letting the user know they can press \`ctrl + f\` to focus into the shell to provide input.`;
|
|
206
222
|
}
|
|
207
223
|
else {
|
|
208
|
-
return `- **
|
|
224
|
+
return `- **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`.
|
|
225
|
+
- **Interactive Commands:** Only execute non-interactive commands.`;
|
|
209
226
|
}
|
|
210
227
|
})()}
|
|
211
|
-
- **Remembering Facts:** Use the '${MEMORY_TOOL_NAME}' tool to remember specific, *user-related* facts or preferences when the user explicitly asks, or when they state a clear, concise piece of information that would help personalize or streamline *your future interactions with them* (e.g., preferred coding style, common project paths they use, personal tool aliases). This tool is for user-specific information that should persist across sessions. Do *not* use it for general project context or information
|
|
228
|
+
- **Remembering Facts:** Use the '${MEMORY_TOOL_NAME}' tool to remember specific, *user-related* facts or preferences when the user explicitly asks, or when they state a clear, concise piece of information that would help personalize or streamline *your future interactions with them* (e.g., preferred coding style, common project paths they use, personal tool aliases). This tool is for user-specific information that should persist across sessions. Do *not* use it for general project context or information.${interactiveMode ? ` If unsure whether to save something, you can ask the user, "Should I remember that for you?"` : ''}
|
|
212
229
|
- **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
|
|
213
230
|
|
|
214
231
|
## Interaction Details
|
|
@@ -251,8 +268,10 @@ ${(function () {
|
|
|
251
268
|
- \`git log -n 3\` to review recent commit messages and match their style (verbosity, formatting, signature line, etc.)
|
|
252
269
|
- Combine shell commands whenever possible to save time/steps, e.g. \`git status && git diff HEAD && git log -n 3\`.
|
|
253
270
|
- Always propose a draft commit message. Never just ask the user to give you the full commit message.
|
|
254
|
-
- Prefer commit messages that are clear, concise, and focused more on "why" and less on "what"
|
|
255
|
-
|
|
271
|
+
- Prefer commit messages that are clear, concise, and focused more on "why" and less on "what".${interactiveMode
|
|
272
|
+
? `
|
|
273
|
+
- Keep the user informed and ask for clarification or confirmation where needed.`
|
|
274
|
+
: ''}
|
|
256
275
|
- After each commit, confirm that it was successful by running \`git status\`.
|
|
257
276
|
- If a commit fails, never attempt to work around the issues without being asked to do so.
|
|
258
277
|
- Never push changes to a remote repository without being asked explicitly by the user.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/core/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAKhD,wFAAwF;IACxF,MAAM,aAAa,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC7D,CAAC;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAChD,sDAAsD;IACtD,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACtD,yDAAyD;QACzD,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,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AAY,GAChB,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACxC,CAAC,CAAC,cAAc,UAAU,CAAC,IAAI,EAAE,EAAE;QACnC,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,GAAG,UAAU,GAAG,YAAY,EAAE,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDR,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -11,10 +11,19 @@ import { openBrowserSecurely } from '../utils/secure-browser-launcher.js';
|
|
|
11
11
|
import { debugLogger } from '../utils/debugLogger.js';
|
|
12
12
|
import { getErrorMessage } from '../utils/errors.js';
|
|
13
13
|
import { ModelNotFoundError } from '../utils/httpErrors.js';
|
|
14
|
-
import { TerminalQuotaError } from '../utils/googleQuotaErrors.js';
|
|
14
|
+
import { RetryableQuotaError, TerminalQuotaError, } from '../utils/googleQuotaErrors.js';
|
|
15
|
+
import { buildFallbackPolicyContext, resolvePolicyChain, resolvePolicyAction, } from '../availability/policyHelpers.js';
|
|
15
16
|
const UPGRADE_URL_PAGE = 'https://goo.gle/set-up-gemini-code-assist';
|
|
16
17
|
export async function handleFallback(config, failedModel, authType, error) {
|
|
17
|
-
|
|
18
|
+
if (config.isModelAvailabilityServiceEnabled()) {
|
|
19
|
+
return handlePolicyDrivenFallback(config, failedModel, authType, error);
|
|
20
|
+
}
|
|
21
|
+
return legacyHandleFallback(config, failedModel, authType, error);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Old fallback logic relying on hard coded strings
|
|
25
|
+
*/
|
|
26
|
+
async function legacyHandleFallback(config, failedModel, authType, error) {
|
|
18
27
|
if (authType !== AuthType.LOGIN_WITH_GOOGLE)
|
|
19
28
|
return null;
|
|
20
29
|
// Guardrail: If it's a ModelNotFoundError but NOT the preview model, do not handle it.
|
|
@@ -46,34 +55,63 @@ export async function handleFallback(config, failedModel, authType, error) {
|
|
|
46
55
|
// Pass the specific failed model to the UI handler.
|
|
47
56
|
const intent = await fallbackModelHandler(failedModel, fallbackModel, error);
|
|
48
57
|
// Process Intent and Update State
|
|
49
|
-
|
|
50
|
-
case 'retry_always':
|
|
51
|
-
// If the error is non-retryable, e.g. TerminalQuota Error, trigger a regular fallback to flash.
|
|
52
|
-
// For all other errors, activate previewModel fallback.
|
|
53
|
-
if (shouldActivatePreviewFallback) {
|
|
54
|
-
activatePreviewModelFallbackMode(config);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
activateFallbackMode(config, authType);
|
|
58
|
-
}
|
|
59
|
-
return true; // Signal retryWithBackoff to continue.
|
|
60
|
-
case 'retry_once':
|
|
61
|
-
// Just retry this time, do NOT set sticky fallback mode.
|
|
62
|
-
return true;
|
|
63
|
-
case 'stop':
|
|
64
|
-
activateFallbackMode(config, authType);
|
|
65
|
-
return false;
|
|
66
|
-
case 'retry_later':
|
|
67
|
-
return false;
|
|
68
|
-
case 'upgrade':
|
|
69
|
-
await handleUpgrade();
|
|
70
|
-
return false;
|
|
71
|
-
default:
|
|
72
|
-
throw new Error(`Unexpected fallback intent received from fallbackModelHandler: "${intent}"`);
|
|
73
|
-
}
|
|
58
|
+
return await processIntent(config, intent, failedModel, fallbackModel, authType, error);
|
|
74
59
|
}
|
|
75
60
|
catch (handlerError) {
|
|
76
|
-
|
|
61
|
+
console.error('Fallback UI handler failed:', handlerError);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* New fallback logic using the ModelAvailabilityService
|
|
67
|
+
*/
|
|
68
|
+
async function handlePolicyDrivenFallback(config, failedModel, authType, error) {
|
|
69
|
+
if (authType !== AuthType.LOGIN_WITH_GOOGLE) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const chain = resolvePolicyChain(config);
|
|
73
|
+
const { failedPolicy, candidates } = buildFallbackPolicyContext(chain, failedModel);
|
|
74
|
+
if (!candidates.length) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const availability = config.getModelAvailabilityService();
|
|
78
|
+
const selection = availability.selectFirstAvailable(candidates.map((policy) => policy.model));
|
|
79
|
+
let lastResortPolicy = candidates.find((policy) => policy.isLastResort);
|
|
80
|
+
if (!lastResortPolicy) {
|
|
81
|
+
debugLogger.warn('No isLastResort policy found in candidates, using last candidate as fallback.');
|
|
82
|
+
lastResortPolicy = candidates[candidates.length - 1];
|
|
83
|
+
}
|
|
84
|
+
const fallbackModel = selection.selectedModel ?? lastResortPolicy.model;
|
|
85
|
+
const selectedPolicy = candidates.find((policy) => policy.model === fallbackModel) ??
|
|
86
|
+
lastResortPolicy;
|
|
87
|
+
if (!fallbackModel || fallbackModel === failedModel) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const failureKind = classifyFailureKind(error);
|
|
91
|
+
const action = resolvePolicyAction(failureKind, selectedPolicy);
|
|
92
|
+
if (action === 'silent') {
|
|
93
|
+
return processIntent(config, 'retry_always', failedModel, fallbackModel, authType, error);
|
|
94
|
+
}
|
|
95
|
+
// This will be used in the future when FallbackRecommendation is passed through UI
|
|
96
|
+
const recommendation = {
|
|
97
|
+
...selection,
|
|
98
|
+
selectedModel: fallbackModel,
|
|
99
|
+
action,
|
|
100
|
+
failureKind,
|
|
101
|
+
failedPolicy,
|
|
102
|
+
selectedPolicy,
|
|
103
|
+
};
|
|
104
|
+
void recommendation;
|
|
105
|
+
const handler = config.getFallbackModelHandler();
|
|
106
|
+
if (typeof handler !== 'function') {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const intent = await handler(failedModel, fallbackModel, error);
|
|
111
|
+
return await processIntent(config, intent, failedModel, fallbackModel, authType);
|
|
112
|
+
}
|
|
113
|
+
catch (handlerError) {
|
|
114
|
+
debugLogger.error('Fallback handler failed:', handlerError);
|
|
77
115
|
return null;
|
|
78
116
|
}
|
|
79
117
|
}
|
|
@@ -85,6 +123,33 @@ async function handleUpgrade() {
|
|
|
85
123
|
debugLogger.warn('Failed to open browser automatically:', getErrorMessage(error));
|
|
86
124
|
}
|
|
87
125
|
}
|
|
126
|
+
async function processIntent(config, intent, failedModel, fallbackModel, authType, error) {
|
|
127
|
+
switch (intent) {
|
|
128
|
+
case 'retry_always':
|
|
129
|
+
// If the error is non-retryable, e.g. TerminalQuota Error, trigger a regular fallback to flash.
|
|
130
|
+
// For all other errors, activate previewModel fallback.
|
|
131
|
+
if (failedModel === PREVIEW_GEMINI_MODEL &&
|
|
132
|
+
!(error instanceof TerminalQuotaError)) {
|
|
133
|
+
activatePreviewModelFallbackMode(config);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
activateFallbackMode(config, authType);
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
case 'retry_once':
|
|
140
|
+
return true;
|
|
141
|
+
case 'stop':
|
|
142
|
+
activateFallbackMode(config, authType);
|
|
143
|
+
return false;
|
|
144
|
+
case 'retry_later':
|
|
145
|
+
return false;
|
|
146
|
+
case 'upgrade':
|
|
147
|
+
await handleUpgrade();
|
|
148
|
+
return false;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`Unexpected fallback intent received from fallbackModelHandler: "${intent}"`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
88
153
|
function activateFallbackMode(config, authType) {
|
|
89
154
|
if (!config.isInFallbackMode()) {
|
|
90
155
|
config.setFallbackMode(true);
|
|
@@ -100,4 +165,16 @@ function activatePreviewModelFallbackMode(config) {
|
|
|
100
165
|
// We might want a specific event for Preview Model fallback, but for now we just set the mode.
|
|
101
166
|
}
|
|
102
167
|
}
|
|
168
|
+
function classifyFailureKind(error) {
|
|
169
|
+
if (error instanceof TerminalQuotaError) {
|
|
170
|
+
return 'terminal';
|
|
171
|
+
}
|
|
172
|
+
if (error instanceof RetryableQuotaError) {
|
|
173
|
+
return 'transient';
|
|
174
|
+
}
|
|
175
|
+
if (error instanceof ModelNotFoundError) {
|
|
176
|
+
return 'not_found';
|
|
177
|
+
}
|
|
178
|
+
return 'unknown';
|
|
179
|
+
}
|
|
103
180
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/fallback/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/fallback/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACt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