@google/gemini-cli 0.32.0-preview.0 → 0.33.0-preview.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/README.md +11 -9
- package/dist/package.json +3 -3
- package/dist/src/config/config.js +6 -1
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +70 -1
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/extension-manager.js +1 -0
- package/dist/src/config/extension-manager.js.map +1 -1
- package/dist/src/config/extension.d.ts +9 -0
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/sandboxConfig.js +3 -1
- package/dist/src/config/sandboxConfig.js.map +1 -1
- package/dist/src/config/settings.d.ts +0 -2
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +9 -13
- package/dist/src/config/settingsSchema.js +5 -13
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/gemini.js +1 -1
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/test-utils/render.js +5 -1
- package/dist/src/test-utils/render.js.map +1 -1
- package/dist/src/ui/AppContainer.js +1 -18
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +3 -1
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.test.js +45 -0
- package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -1
- package/dist/src/ui/commands/hooksCommand.js +12 -8
- package/dist/src/ui/commands/hooksCommand.js.map +1 -1
- package/dist/src/ui/commands/hooksCommand.test.js +15 -23
- package/dist/src/ui/commands/hooksCommand.test.js.map +1 -1
- package/dist/src/ui/commands/planCommand.js +33 -3
- package/dist/src/ui/commands/planCommand.js.map +1 -1
- package/dist/src/ui/commands/planCommand.test.js +29 -1
- package/dist/src/ui/commands/planCommand.test.js.map +1 -1
- package/dist/src/ui/components/AgentConfigDialog.js +17 -33
- package/dist/src/ui/components/AgentConfigDialog.js.map +1 -1
- package/dist/src/ui/components/AppHeader.d.ts +1 -1
- package/dist/src/ui/components/AppHeader.js +15 -8
- package/dist/src/ui/components/AppHeader.js.map +1 -1
- package/dist/src/ui/components/AppHeader.test.js +7 -0
- package/dist/src/ui/components/AppHeader.test.js.map +1 -1
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +1 -1
- package/dist/src/ui/components/ContextUsageDisplay.js +15 -3
- package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextUsageDisplay.test.js +25 -19
- package/dist/src/ui/components/ContextUsageDisplay.test.js.map +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js +1 -6
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.test.js +2 -2
- package/dist/src/ui/components/DetailedMessagesDisplay.test.js.map +1 -1
- package/dist/src/ui/components/DialogManager.js +3 -19
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/ExitPlanModeDialog.js +2 -1
- package/dist/src/ui/components/ExitPlanModeDialog.js.map +1 -1
- package/dist/src/ui/components/ExitPlanModeDialog.test.js +2 -13
- package/dist/src/ui/components/ExitPlanModeDialog.test.js.map +1 -1
- package/dist/src/ui/components/Footer.js +3 -1
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Footer.test.js +41 -6
- package/dist/src/ui/components/Footer.test.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +2 -3
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/HooksDialog.d.ts +36 -0
- package/dist/src/ui/components/HooksDialog.js +81 -0
- package/dist/src/ui/components/HooksDialog.js.map +1 -0
- package/dist/src/ui/components/HooksDialog.test.js +187 -0
- package/dist/src/ui/components/HooksDialog.test.js.map +1 -0
- package/dist/src/ui/components/MainContent.js +2 -1
- package/dist/src/ui/components/MainContent.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.d.ts +1 -5
- package/dist/src/ui/components/SettingsDialog.js +90 -254
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +127 -105
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/StatusDisplay.test.js +5 -4
- package/dist/src/ui/components/StatusDisplay.test.js.map +1 -1
- package/dist/src/ui/components/Tips.d.ts +1 -1
- package/dist/src/ui/components/Tips.js +1 -1
- package/dist/src/ui/components/Tips.js.map +1 -1
- package/dist/src/ui/components/Tips.test.d.ts +1 -1
- package/dist/src/ui/components/Tips.test.js +6 -7
- package/dist/src/ui/components/Tips.test.js.map +1 -1
- package/dist/src/ui/components/UserIdentity.d.ts +1 -1
- package/dist/src/ui/components/UserIdentity.js +10 -12
- package/dist/src/ui/components/UserIdentity.js.map +1 -1
- package/dist/src/ui/components/UserIdentity.test.js +23 -10
- package/dist/src/ui/components/UserIdentity.test.js.map +1 -1
- package/dist/src/ui/components/messages/InfoMessage.d.ts +1 -0
- package/dist/src/ui/components/messages/InfoMessage.js +2 -2
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
- package/dist/src/ui/components/messages/SubagentProgressDisplay.d.ts +11 -0
- package/dist/src/ui/components/messages/SubagentProgressDisplay.js +73 -0
- package/dist/src/ui/components/messages/SubagentProgressDisplay.js.map +1 -0
- package/dist/src/ui/components/messages/SubagentProgressDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/messages/SubagentProgressDisplay.test.js +158 -0
- package/dist/src/ui/components/messages/SubagentProgressDisplay.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolResultDisplay.js +5 -0
- package/dist/src/ui/components/messages/ToolResultDisplay.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSettingsDialog.d.ts +5 -2
- package/dist/src/ui/components/shared/BaseSettingsDialog.js +3 -2
- package/dist/src/ui/components/shared/BaseSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSettingsDialog.test.js +24 -0
- package/dist/src/ui/components/shared/BaseSettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionRegistryView.d.ts +1 -2
- package/dist/src/ui/constants/tips.js +1 -1
- package/dist/src/ui/constants/tips.js.map +1 -1
- package/dist/src/ui/constants.d.ts +4 -0
- package/dist/src/ui/constants.js +4 -0
- package/dist/src/ui/constants.js.map +1 -1
- package/dist/src/ui/contexts/SettingsContext.js +2 -1
- package/dist/src/ui/contexts/SettingsContext.js.map +1 -1
- package/dist/src/ui/contexts/UIStateContext.d.ts +0 -2
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/contexts/VimModeContext.d.ts +1 -3
- package/dist/src/ui/contexts/VimModeContext.js +7 -16
- package/dist/src/ui/contexts/VimModeContext.js.map +1 -1
- package/dist/src/ui/hooks/toolMapping.js +1 -0
- package/dist/src/ui/hooks/toolMapping.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +16 -13
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.js +31 -2
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.d.ts +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.js +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useTerminalTheme.js +6 -3
- package/dist/src/ui/hooks/useTerminalTheme.js.map +1 -1
- package/dist/src/ui/hooks/useTerminalTheme.test.js +19 -0
- package/dist/src/ui/hooks/useTerminalTheme.test.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.js +26 -12
- package/dist/src/ui/hooks/useToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +101 -8
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.d.ts +26 -4
- package/dist/src/ui/themes/theme-manager.js +40 -7
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.test.js +2 -1
- package/dist/src/ui/themes/theme-manager.test.js.map +1 -1
- package/dist/src/ui/types.d.ts +3 -17
- package/dist/src/ui/types.js +0 -1
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.d.ts +6 -2
- package/dist/src/ui/utils/commandUtils.js +12 -5
- package/dist/src/ui/utils/commandUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.test.js +21 -7
- package/dist/src/ui/utils/commandUtils.test.js.map +1 -1
- package/dist/src/utils/agentSettings.d.ts +3 -11
- package/dist/src/utils/agentSettings.js +23 -81
- package/dist/src/utils/agentSettings.js.map +1 -1
- package/dist/src/{ui/components/SessionRetentionWarningDialog.test.d.ts → utils/agentSettings.test.d.ts} +0 -2
- package/dist/src/utils/agentSettings.test.js +111 -0
- package/dist/src/utils/agentSettings.test.js.map +1 -0
- package/dist/src/utils/dialogScopeUtils.d.ts +6 -2
- package/dist/src/utils/dialogScopeUtils.js +3 -3
- package/dist/src/utils/dialogScopeUtils.js.map +1 -1
- package/dist/src/utils/dialogScopeUtils.test.js +5 -5
- package/dist/src/utils/dialogScopeUtils.test.js.map +1 -1
- package/dist/src/utils/featureToggleUtils.d.ts +55 -0
- package/dist/src/utils/featureToggleUtils.js +95 -0
- package/dist/src/utils/featureToggleUtils.js.map +1 -0
- package/dist/src/utils/featureToggleUtils.test.d.ts +6 -0
- package/dist/src/utils/featureToggleUtils.test.js +126 -0
- package/dist/src/utils/featureToggleUtils.test.js.map +1 -0
- package/dist/src/utils/handleAutoUpdate.d.ts +7 -0
- package/dist/src/utils/handleAutoUpdate.js +41 -0
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.test.js +52 -1
- package/dist/src/utils/handleAutoUpdate.test.js.map +1 -1
- package/dist/src/utils/processUtils.js +2 -0
- package/dist/src/utils/processUtils.js.map +1 -1
- package/dist/src/utils/processUtils.test.js +7 -1
- package/dist/src/utils/processUtils.test.js.map +1 -1
- package/dist/src/utils/sessionCleanup.js +8 -0
- package/dist/src/utils/sessionCleanup.js.map +1 -1
- package/dist/src/utils/sessionCleanup.test.js +19 -0
- package/dist/src/utils/sessionCleanup.test.js.map +1 -1
- package/dist/src/utils/settingsUtils.d.ts +18 -91
- package/dist/src/utils/settingsUtils.js +127 -207
- package/dist/src/utils/settingsUtils.js.map +1 -1
- package/dist/src/utils/settingsUtils.test.js +78 -264
- package/dist/src/utils/settingsUtils.test.js.map +1 -1
- package/dist/src/utils/skillSettings.d.ts +4 -14
- package/dist/src/utils/skillSettings.js +32 -81
- package/dist/src/utils/skillSettings.js.map +1 -1
- package/dist/src/utils/skillSettings.test.d.ts +6 -0
- package/dist/src/utils/skillSettings.test.js +142 -0
- package/dist/src/utils/skillSettings.test.js.map +1 -0
- package/dist/src/zed-integration/acpResume.test.js +8 -0
- package/dist/src/zed-integration/acpResume.test.js.map +1 -1
- package/dist/src/zed-integration/commandHandler.d.ts +26 -0
- package/dist/src/zed-integration/commandHandler.js +102 -0
- package/dist/src/zed-integration/commandHandler.js.map +1 -0
- package/dist/src/zed-integration/commandHandler.test.d.ts +6 -0
- package/dist/src/zed-integration/commandHandler.test.js +25 -0
- package/dist/src/zed-integration/commandHandler.test.js.map +1 -0
- package/dist/src/zed-integration/commands/commandRegistry.d.ts +12 -0
- package/dist/src/zed-integration/commands/commandRegistry.js +26 -0
- package/dist/src/zed-integration/commands/commandRegistry.js.map +1 -0
- package/dist/src/zed-integration/commands/extensions.d.ts +57 -0
- package/dist/src/zed-integration/commands/extensions.js +320 -0
- package/dist/src/zed-integration/commands/extensions.js.map +1 -0
- package/dist/src/zed-integration/commands/init.d.ts +12 -0
- package/dist/src/zed-integration/commands/init.js +47 -0
- package/dist/src/zed-integration/commands/init.js.map +1 -0
- package/dist/src/zed-integration/commands/memory.d.ts +34 -0
- package/dist/src/zed-integration/commands/memory.js +83 -0
- package/dist/src/zed-integration/commands/memory.js.map +1 -0
- package/dist/src/zed-integration/commands/restore.d.ts +18 -0
- package/dist/src/zed-integration/commands/restore.js +140 -0
- package/dist/src/zed-integration/commands/restore.js.map +1 -0
- package/dist/src/zed-integration/commands/types.d.ts +31 -0
- package/dist/src/zed-integration/commands/types.js +7 -0
- package/dist/src/zed-integration/commands/types.js.map +1 -0
- package/dist/src/zed-integration/zedIntegration.d.ts +9 -2
- package/dist/src/zed-integration/zedIntegration.js +170 -8
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/src/zed-integration/zedIntegration.test.js +329 -2
- package/dist/src/zed-integration/zedIntegration.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/src/ui/components/SessionRetentionWarningDialog.d.ts +0 -12
- package/dist/src/ui/components/SessionRetentionWarningDialog.js +0 -27
- package/dist/src/ui/components/SessionRetentionWarningDialog.js.map +0 -1
- package/dist/src/ui/components/SessionRetentionWarningDialog.test.js +0 -72
- package/dist/src/ui/components/SessionRetentionWarningDialog.test.js.map +0 -1
- package/dist/src/ui/components/views/HooksList.d.ts +0 -24
- package/dist/src/ui/components/views/HooksList.js +0 -28
- package/dist/src/ui/components/views/HooksList.js.map +0 -1
- package/dist/src/ui/hooks/useSessionRetentionCheck.d.ts +0 -12
- package/dist/src/ui/hooks/useSessionRetentionCheck.js +0 -57
- package/dist/src/ui/hooks/useSessionRetentionCheck.js.map +0 -1
- package/dist/src/ui/hooks/useSessionRetentionCheck.test.js +0 -169
- package/dist/src/ui/hooks/useSessionRetentionCheck.test.js.map +0 -1
- /package/dist/src/ui/{hooks/useSessionRetentionCheck.test.d.ts → components/HooksDialog.test.d.ts} +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { getCheckpointInfoList, getToolCallDataSchema, isNodeError, performRestore, } from '@google/gemini-cli-core';
|
|
7
|
+
import * as fs from 'node:fs/promises';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
export class RestoreCommand {
|
|
10
|
+
name = 'restore';
|
|
11
|
+
description = 'Restore to a previous checkpoint, or list available checkpoints to restore. This will reset the conversation and file history to the state it was in when the checkpoint was created';
|
|
12
|
+
requiresWorkspace = true;
|
|
13
|
+
subCommands = [new ListCheckpointsCommand()];
|
|
14
|
+
async execute(context, args) {
|
|
15
|
+
const { config, git: gitService } = context;
|
|
16
|
+
const argsStr = args.join(' ');
|
|
17
|
+
try {
|
|
18
|
+
if (!argsStr) {
|
|
19
|
+
return await new ListCheckpointsCommand().execute(context);
|
|
20
|
+
}
|
|
21
|
+
if (!config.getCheckpointingEnabled()) {
|
|
22
|
+
return {
|
|
23
|
+
name: this.name,
|
|
24
|
+
data: 'Checkpointing is not enabled. Please enable it in your settings (`general.checkpointing.enabled: true`) to use /restore.',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const selectedFile = argsStr.endsWith('.json')
|
|
28
|
+
? argsStr
|
|
29
|
+
: `${argsStr}.json`;
|
|
30
|
+
const checkpointDir = config.storage.getProjectTempCheckpointsDir();
|
|
31
|
+
const filePath = path.join(checkpointDir, selectedFile);
|
|
32
|
+
let data;
|
|
33
|
+
try {
|
|
34
|
+
data = await fs.readFile(filePath, 'utf-8');
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (isNodeError(error) && error.code === 'ENOENT') {
|
|
38
|
+
return {
|
|
39
|
+
name: this.name,
|
|
40
|
+
data: `File not found: ${selectedFile}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
46
|
+
const toolCallData = JSON.parse(data);
|
|
47
|
+
const ToolCallDataSchema = getToolCallDataSchema();
|
|
48
|
+
const parseResult = ToolCallDataSchema.safeParse(toolCallData);
|
|
49
|
+
if (!parseResult.success) {
|
|
50
|
+
return {
|
|
51
|
+
name: this.name,
|
|
52
|
+
data: 'Checkpoint file is invalid or corrupted.',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const restoreResultGenerator = performRestore(parseResult.data, gitService);
|
|
56
|
+
const restoreResult = [];
|
|
57
|
+
for await (const result of restoreResultGenerator) {
|
|
58
|
+
restoreResult.push(result);
|
|
59
|
+
}
|
|
60
|
+
// Format the result nicely since Zed just dumps data
|
|
61
|
+
const formattedResult = restoreResult
|
|
62
|
+
.map((r) => {
|
|
63
|
+
if (r.type === 'message') {
|
|
64
|
+
return `[${r.messageType.toUpperCase()}] ${r.content}`;
|
|
65
|
+
}
|
|
66
|
+
else if (r.type === 'load_history') {
|
|
67
|
+
return `Loaded history with ${r.clientHistory.length} messages.`;
|
|
68
|
+
}
|
|
69
|
+
return `Restored: ${JSON.stringify(r)}`;
|
|
70
|
+
})
|
|
71
|
+
.join('\n');
|
|
72
|
+
return {
|
|
73
|
+
name: this.name,
|
|
74
|
+
data: formattedResult,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
return {
|
|
79
|
+
name: this.name,
|
|
80
|
+
data: `An unexpected error occurred during restore: ${error}`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class ListCheckpointsCommand {
|
|
86
|
+
name = 'restore list';
|
|
87
|
+
description = 'Lists all available checkpoints.';
|
|
88
|
+
async execute(context) {
|
|
89
|
+
const { config } = context;
|
|
90
|
+
try {
|
|
91
|
+
if (!config.getCheckpointingEnabled()) {
|
|
92
|
+
return {
|
|
93
|
+
name: this.name,
|
|
94
|
+
data: 'Checkpointing is not enabled. Please enable it in your settings (`general.checkpointing.enabled: true`) to use /restore.',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const checkpointDir = config.storage.getProjectTempCheckpointsDir();
|
|
98
|
+
try {
|
|
99
|
+
await fs.mkdir(checkpointDir, { recursive: true });
|
|
100
|
+
}
|
|
101
|
+
catch (_e) {
|
|
102
|
+
// Ignore
|
|
103
|
+
}
|
|
104
|
+
const files = await fs.readdir(checkpointDir);
|
|
105
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
106
|
+
if (jsonFiles.length === 0) {
|
|
107
|
+
return { name: this.name, data: 'No checkpoints found.' };
|
|
108
|
+
}
|
|
109
|
+
const checkpointFiles = new Map();
|
|
110
|
+
for (const file of jsonFiles) {
|
|
111
|
+
const filePath = path.join(checkpointDir, file);
|
|
112
|
+
const data = await fs.readFile(filePath, 'utf-8');
|
|
113
|
+
checkpointFiles.set(file, data);
|
|
114
|
+
}
|
|
115
|
+
const checkpointInfoList = getCheckpointInfoList(checkpointFiles);
|
|
116
|
+
const formatted = checkpointInfoList
|
|
117
|
+
.map((info) => {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
+
const i = info;
|
|
120
|
+
const fileName = String(i['fileName'] || 'Unknown');
|
|
121
|
+
const toolName = String(i['toolName'] || 'Unknown');
|
|
122
|
+
const status = String(i['status'] || 'Unknown');
|
|
123
|
+
const timestamp = new Date(Number(i['timestamp']) || 0).toLocaleString();
|
|
124
|
+
return `- **${fileName}**: ${toolName} (Status: ${status}) [${timestamp}]`;
|
|
125
|
+
})
|
|
126
|
+
.join('\n');
|
|
127
|
+
return {
|
|
128
|
+
name: this.name,
|
|
129
|
+
data: `Available Checkpoints:\n${formatted}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (_error) {
|
|
133
|
+
return {
|
|
134
|
+
name: this.name,
|
|
135
|
+
data: 'An unexpected error occurred while listing checkpoints.',
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../../src/zed-integration/commands/restore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAOlC,MAAM,OAAO,cAAc;IAChB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAClB,sLAAsL,CAAC;IAChL,iBAAiB,GAAG,IAAI,CAAC;IACzB,WAAW,GAAG,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;IAEtD,KAAK,CAAC,OAAO,CACX,OAAuB,EACvB,IAAc;QAEd,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,MAAM,IAAI,sBAAsB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7D,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,CAAC;gBACtC,OAAO;oBACL,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,0HAA0H;iBACjI,CAAC;YACJ,CAAC;YAED,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAC5C,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,GAAG,OAAO,OAAO,CAAC;YAEtB,MAAM,aAAa,GAAG,MAAM,CA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CAAC,cAAc,EAAE,CAAC;gBAEnB,OAAO,OAAO,QAAQ,OAAO,QAAQ,aAAa,MAAM,MAAM,SAAS,GAAG,CAAC;YAC7E,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,2BAA2B,SAAS,EAAE;aAC7C,CAAC;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,yDAAyD;aAChE,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Config, GitService } from '@google/gemini-cli-core';
|
|
7
|
+
import type { LoadedSettings } from '../../config/settings.js';
|
|
8
|
+
export interface CommandContext {
|
|
9
|
+
config: Config;
|
|
10
|
+
settings: LoadedSettings;
|
|
11
|
+
git?: GitService;
|
|
12
|
+
sendMessage: (text: string) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface CommandArgument {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly isRequired?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface Command {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly aliases?: string[];
|
|
22
|
+
readonly description: string;
|
|
23
|
+
readonly arguments?: CommandArgument[];
|
|
24
|
+
readonly subCommands?: Command[];
|
|
25
|
+
readonly requiresWorkspace?: boolean;
|
|
26
|
+
execute(context: CommandContext, args: string[]): Promise<CommandExecutionResponse>;
|
|
27
|
+
}
|
|
28
|
+
export interface CommandExecutionResponse {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly data: unknown;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/zed-integration/commands/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type Config, type GeminiChat, type ConversationRecord } from '@google/gemini-cli-core';
|
|
7
7
|
import * as acp from '@agentclientprotocol/sdk';
|
|
8
8
|
import type { LoadedSettings } from '../config/settings.js';
|
|
9
9
|
import type { CliArgs } from '../config/config.js';
|
|
@@ -26,6 +26,7 @@ export declare class GeminiAgent {
|
|
|
26
26
|
cancel(params: acp.CancelNotification): Promise<void>;
|
|
27
27
|
prompt(params: acp.PromptRequest): Promise<acp.PromptResponse>;
|
|
28
28
|
setSessionMode(params: acp.SetSessionModeRequest): Promise<acp.SetSessionModeResponse>;
|
|
29
|
+
unstable_setSessionModel(params: acp.SetSessionModelRequest): Promise<acp.SetSessionModelResponse>;
|
|
29
30
|
}
|
|
30
31
|
export declare class Session {
|
|
31
32
|
#private;
|
|
@@ -33,12 +34,18 @@ export declare class Session {
|
|
|
33
34
|
private readonly chat;
|
|
34
35
|
private readonly config;
|
|
35
36
|
private readonly connection;
|
|
37
|
+
private readonly settings;
|
|
36
38
|
private pendingPrompt;
|
|
37
|
-
|
|
39
|
+
private commandHandler;
|
|
40
|
+
constructor(id: string, chat: GeminiChat, config: Config, connection: acp.AgentSideConnection, settings: LoadedSettings);
|
|
38
41
|
cancelPendingPrompt(): Promise<void>;
|
|
39
42
|
setMode(modeId: acp.SessionModeId): acp.SetSessionModeResponse;
|
|
43
|
+
private getAvailableCommands;
|
|
44
|
+
sendAvailableCommands(): Promise<void>;
|
|
45
|
+
setModel(modelId: acp.ModelId): acp.SetSessionModelResponse;
|
|
40
46
|
streamHistory(messages: ConversationRecord['messages']): Promise<void>;
|
|
41
47
|
prompt(params: acp.PromptRequest): Promise<acp.PromptResponse>;
|
|
48
|
+
private handleCommand;
|
|
42
49
|
private sendUpdate;
|
|
43
50
|
private runTool;
|
|
44
51
|
debug(msg: string): void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { CoreToolCallStatus, AuthType, logToolCall, convertToFunctionResponse, ToolConfirmationOutcome, clearCachedCredentialFile, isNodeError, getErrorMessage, isWithinRoot, getErrorStatus, MCPServerConfig, DiscoveredMCPTool, StreamEventType, ToolCallEvent, debugLogger, ReadManyFilesTool, REFERENCE_CONTENT_START, resolveModel, createWorkingStdio, startupProfiler, Kind, partListUnionToString, LlmRole, ApprovalMode, getVersion, convertSessionToClientHistory, } from '@google/gemini-cli-core';
|
|
6
|
+
import { CoreToolCallStatus, AuthType, logToolCall, convertToFunctionResponse, ToolConfirmationOutcome, clearCachedCredentialFile, isNodeError, getErrorMessage, isWithinRoot, getErrorStatus, MCPServerConfig, DiscoveredMCPTool, StreamEventType, ToolCallEvent, debugLogger, ReadManyFilesTool, REFERENCE_CONTENT_START, resolveModel, createWorkingStdio, startupProfiler, Kind, partListUnionToString, LlmRole, ApprovalMode, getVersion, convertSessionToClientHistory, DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_FLASH_MODEL, DEFAULT_GEMINI_FLASH_LITE_MODEL, PREVIEW_GEMINI_MODEL, PREVIEW_GEMINI_3_1_MODEL, PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL, PREVIEW_GEMINI_FLASH_MODEL, DEFAULT_GEMINI_MODEL_AUTO, PREVIEW_GEMINI_MODEL_AUTO, getDisplayString, } from '@google/gemini-cli-core';
|
|
7
7
|
import * as acp from '@agentclientprotocol/sdk';
|
|
8
8
|
import { AcpFileSystemService } from './fileSystemService.js';
|
|
9
9
|
import { getAcpErrorMessage } from './acpErrors.js';
|
|
@@ -19,7 +19,9 @@ import { randomUUID } from 'node:crypto';
|
|
|
19
19
|
import { loadCliConfig } from '../config/config.js';
|
|
20
20
|
import { runExitCleanup } from '../utils/cleanup.js';
|
|
21
21
|
import { SessionSelector } from '../utils/sessionUtils.js';
|
|
22
|
+
import { CommandHandler } from './commandHandler.js';
|
|
22
23
|
export async function runZedIntegration(config, settings, argv) {
|
|
24
|
+
// ... (skip unchanged lines) ...
|
|
23
25
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
24
26
|
const stdout = Writable.toWeb(workingStdout);
|
|
25
27
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
@@ -152,15 +154,25 @@ export class GeminiAgent {
|
|
|
152
154
|
startupProfiler.flush(config);
|
|
153
155
|
const geminiClient = config.getGeminiClient();
|
|
154
156
|
const chat = await geminiClient.startChat();
|
|
155
|
-
const session = new Session(sessionId, chat, config, this.connection);
|
|
157
|
+
const session = new Session(sessionId, chat, config, this.connection, this.settings);
|
|
156
158
|
this.sessions.set(sessionId, session);
|
|
157
|
-
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
161
|
+
session.sendAvailableCommands();
|
|
162
|
+
}, 0);
|
|
163
|
+
const { availableModels, currentModelId } = buildAvailableModels(config, loadedSettings);
|
|
164
|
+
const response = {
|
|
158
165
|
sessionId,
|
|
159
166
|
modes: {
|
|
160
167
|
availableModes: buildAvailableModes(config.isPlanEnabled()),
|
|
161
168
|
currentModeId: config.getApprovalMode(),
|
|
162
169
|
},
|
|
170
|
+
models: {
|
|
171
|
+
availableModels,
|
|
172
|
+
currentModelId,
|
|
173
|
+
},
|
|
163
174
|
};
|
|
175
|
+
return response;
|
|
164
176
|
}
|
|
165
177
|
async loadSession({ sessionId, cwd, mcpServers, }) {
|
|
166
178
|
const config = await this.initializeSessionConfig(sessionId, cwd, mcpServers);
|
|
@@ -177,17 +189,27 @@ export class GeminiAgent {
|
|
|
177
189
|
conversation: sessionData,
|
|
178
190
|
filePath: sessionPath,
|
|
179
191
|
});
|
|
180
|
-
const session = new Session(sessionId, geminiClient.getChat(), config, this.connection);
|
|
192
|
+
const session = new Session(sessionId, geminiClient.getChat(), config, this.connection, this.settings);
|
|
181
193
|
this.sessions.set(sessionId, session);
|
|
182
194
|
// Stream history back to client
|
|
183
195
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
184
196
|
session.streamHistory(sessionData.messages);
|
|
185
|
-
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
199
|
+
session.sendAvailableCommands();
|
|
200
|
+
}, 0);
|
|
201
|
+
const { availableModels, currentModelId } = buildAvailableModels(config, this.settings);
|
|
202
|
+
const response = {
|
|
186
203
|
modes: {
|
|
187
204
|
availableModes: buildAvailableModes(config.isPlanEnabled()),
|
|
188
205
|
currentModeId: config.getApprovalMode(),
|
|
189
206
|
},
|
|
207
|
+
models: {
|
|
208
|
+
availableModels,
|
|
209
|
+
currentModelId,
|
|
210
|
+
},
|
|
190
211
|
};
|
|
212
|
+
return response;
|
|
191
213
|
}
|
|
192
214
|
async initializeSessionConfig(sessionId, cwd, mcpServers) {
|
|
193
215
|
const selectedAuthType = this.settings.merged.security.auth.selectedType;
|
|
@@ -265,18 +287,28 @@ export class GeminiAgent {
|
|
|
265
287
|
}
|
|
266
288
|
return session.setMode(params.modeId);
|
|
267
289
|
}
|
|
290
|
+
async unstable_setSessionModel(params) {
|
|
291
|
+
const session = this.sessions.get(params.sessionId);
|
|
292
|
+
if (!session) {
|
|
293
|
+
throw new Error(`Session not found: ${params.sessionId}`);
|
|
294
|
+
}
|
|
295
|
+
return session.setModel(params.modelId);
|
|
296
|
+
}
|
|
268
297
|
}
|
|
269
298
|
export class Session {
|
|
270
299
|
id;
|
|
271
300
|
chat;
|
|
272
301
|
config;
|
|
273
302
|
connection;
|
|
303
|
+
settings;
|
|
274
304
|
pendingPrompt = null;
|
|
275
|
-
|
|
305
|
+
commandHandler = new CommandHandler();
|
|
306
|
+
constructor(id, chat, config, connection, settings) {
|
|
276
307
|
this.id = id;
|
|
277
308
|
this.chat = chat;
|
|
278
309
|
this.config = config;
|
|
279
310
|
this.connection = connection;
|
|
311
|
+
this.settings = settings;
|
|
280
312
|
}
|
|
281
313
|
async cancelPendingPrompt() {
|
|
282
314
|
if (!this.pendingPrompt) {
|
|
@@ -295,6 +327,23 @@ export class Session {
|
|
|
295
327
|
this.config.setApprovalMode(mode.id);
|
|
296
328
|
return {};
|
|
297
329
|
}
|
|
330
|
+
getAvailableCommands() {
|
|
331
|
+
return this.commandHandler.getAvailableCommands();
|
|
332
|
+
}
|
|
333
|
+
async sendAvailableCommands() {
|
|
334
|
+
const availableCommands = this.getAvailableCommands().map((command) => ({
|
|
335
|
+
name: command.name,
|
|
336
|
+
description: command.description,
|
|
337
|
+
}));
|
|
338
|
+
await this.sendUpdate({
|
|
339
|
+
sessionUpdate: 'available_commands_update',
|
|
340
|
+
availableCommands,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
setModel(modelId) {
|
|
344
|
+
this.config.setModel(modelId);
|
|
345
|
+
return {};
|
|
346
|
+
}
|
|
298
347
|
async streamHistory(messages) {
|
|
299
348
|
for (const msg of messages) {
|
|
300
349
|
const contentString = partListUnionToString(msg.content);
|
|
@@ -364,9 +413,40 @@ export class Session {
|
|
|
364
413
|
this.pendingPrompt?.abort();
|
|
365
414
|
const pendingSend = new AbortController();
|
|
366
415
|
this.pendingPrompt = pendingSend;
|
|
416
|
+
await this.config.waitForMcpInit();
|
|
367
417
|
const promptId = Math.random().toString(16).slice(2);
|
|
368
418
|
const chat = this.chat;
|
|
369
419
|
const parts = await this.#resolvePrompt(params.prompt, pendingSend.signal);
|
|
420
|
+
// Command interception
|
|
421
|
+
let commandText = '';
|
|
422
|
+
for (const part of parts) {
|
|
423
|
+
if (typeof part === 'object' && part !== null) {
|
|
424
|
+
if ('text' in part) {
|
|
425
|
+
// It is a text part
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-type-assertion
|
|
427
|
+
const text = part.text;
|
|
428
|
+
if (typeof text === 'string') {
|
|
429
|
+
commandText += text;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
// Non-text part (image, embedded resource)
|
|
434
|
+
// Stop looking for command
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
commandText = commandText.trim();
|
|
440
|
+
if (commandText &&
|
|
441
|
+
(commandText.startsWith('/') || commandText.startsWith('$'))) {
|
|
442
|
+
// If we found a command, pass it to handleCommand
|
|
443
|
+
// Note: handleCommand currently expects `commandText` to be the command string
|
|
444
|
+
// It uses `parts` argument but effectively ignores it in current implementation
|
|
445
|
+
const handled = await this.handleCommand(commandText, parts);
|
|
446
|
+
if (handled) {
|
|
447
|
+
return { stopReason: 'end_turn' };
|
|
448
|
+
}
|
|
449
|
+
}
|
|
370
450
|
let nextMessage = { role: 'user', parts };
|
|
371
451
|
while (nextMessage !== null) {
|
|
372
452
|
if (pendingSend.signal.aborted) {
|
|
@@ -432,6 +512,23 @@ export class Session {
|
|
|
432
512
|
}
|
|
433
513
|
return { stopReason: 'end_turn' };
|
|
434
514
|
}
|
|
515
|
+
async handleCommand(commandText,
|
|
516
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
517
|
+
parts) {
|
|
518
|
+
const gitService = await this.config.getGitService();
|
|
519
|
+
const commandContext = {
|
|
520
|
+
config: this.config,
|
|
521
|
+
settings: this.settings,
|
|
522
|
+
git: gitService,
|
|
523
|
+
sendMessage: async (text) => {
|
|
524
|
+
await this.sendUpdate({
|
|
525
|
+
sessionUpdate: 'agent_message_chunk',
|
|
526
|
+
content: { type: 'text', text },
|
|
527
|
+
});
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
return this.commandHandler.handleCommand(commandText, commandContext);
|
|
531
|
+
}
|
|
435
532
|
async sendUpdate(update) {
|
|
436
533
|
const params = {
|
|
437
534
|
sessionId: this.id,
|
|
@@ -474,7 +571,7 @@ export class Session {
|
|
|
474
571
|
if (confirmationDetails.type === 'edit') {
|
|
475
572
|
content.push({
|
|
476
573
|
type: 'diff',
|
|
477
|
-
path: confirmationDetails.
|
|
574
|
+
path: confirmationDetails.filePath,
|
|
478
575
|
oldText: confirmationDetails.originalContent,
|
|
479
576
|
newText: confirmationDetails.newContent,
|
|
480
577
|
_meta: {
|
|
@@ -915,7 +1012,8 @@ function toToolCallContent(toolResult) {
|
|
|
915
1012
|
if ('fileName' in toolResult.returnDisplay) {
|
|
916
1013
|
return {
|
|
917
1014
|
type: 'diff',
|
|
918
|
-
path: toolResult.returnDisplay.
|
|
1015
|
+
path: toolResult.returnDisplay.filePath ??
|
|
1016
|
+
toolResult.returnDisplay.fileName,
|
|
919
1017
|
oldText: toolResult.returnDisplay.originalContent,
|
|
920
1018
|
newText: toolResult.returnDisplay.newContent,
|
|
921
1019
|
_meta: {
|
|
@@ -1053,4 +1151,68 @@ function buildAvailableModes(isPlanEnabled) {
|
|
|
1053
1151
|
}
|
|
1054
1152
|
return modes;
|
|
1055
1153
|
}
|
|
1154
|
+
function buildAvailableModels(config, settings) {
|
|
1155
|
+
const preferredModel = config.getModel() || DEFAULT_GEMINI_MODEL_AUTO;
|
|
1156
|
+
const shouldShowPreviewModels = config.getHasAccessToPreviewModel();
|
|
1157
|
+
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
1158
|
+
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
1159
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
1160
|
+
const mainOptions = [
|
|
1161
|
+
{
|
|
1162
|
+
value: DEFAULT_GEMINI_MODEL_AUTO,
|
|
1163
|
+
title: getDisplayString(DEFAULT_GEMINI_MODEL_AUTO),
|
|
1164
|
+
description: 'Let Gemini CLI decide the best model for the task: gemini-2.5-pro, gemini-2.5-flash',
|
|
1165
|
+
},
|
|
1166
|
+
];
|
|
1167
|
+
if (shouldShowPreviewModels) {
|
|
1168
|
+
mainOptions.unshift({
|
|
1169
|
+
value: PREVIEW_GEMINI_MODEL_AUTO,
|
|
1170
|
+
title: getDisplayString(PREVIEW_GEMINI_MODEL_AUTO),
|
|
1171
|
+
description: useGemini31
|
|
1172
|
+
? 'Let Gemini CLI decide the best model for the task: gemini-3.1-pro, gemini-3-flash'
|
|
1173
|
+
: 'Let Gemini CLI decide the best model for the task: gemini-3-pro, gemini-3-flash',
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
const manualOptions = [
|
|
1177
|
+
{
|
|
1178
|
+
value: DEFAULT_GEMINI_MODEL,
|
|
1179
|
+
title: getDisplayString(DEFAULT_GEMINI_MODEL),
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
value: DEFAULT_GEMINI_FLASH_MODEL,
|
|
1183
|
+
title: getDisplayString(DEFAULT_GEMINI_FLASH_MODEL),
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
value: DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
|
1187
|
+
title: getDisplayString(DEFAULT_GEMINI_FLASH_LITE_MODEL),
|
|
1188
|
+
},
|
|
1189
|
+
];
|
|
1190
|
+
if (shouldShowPreviewModels) {
|
|
1191
|
+
const previewProModel = useGemini31
|
|
1192
|
+
? PREVIEW_GEMINI_3_1_MODEL
|
|
1193
|
+
: PREVIEW_GEMINI_MODEL;
|
|
1194
|
+
const previewProValue = useCustomToolModel
|
|
1195
|
+
? PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL
|
|
1196
|
+
: previewProModel;
|
|
1197
|
+
manualOptions.unshift({
|
|
1198
|
+
value: previewProValue,
|
|
1199
|
+
title: getDisplayString(previewProModel),
|
|
1200
|
+
}, {
|
|
1201
|
+
value: PREVIEW_GEMINI_FLASH_MODEL,
|
|
1202
|
+
title: getDisplayString(PREVIEW_GEMINI_FLASH_MODEL),
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
const scaleOptions = (options) => options.map((o) => ({
|
|
1206
|
+
modelId: o.value,
|
|
1207
|
+
name: o.title,
|
|
1208
|
+
description: o.description,
|
|
1209
|
+
}));
|
|
1210
|
+
return {
|
|
1211
|
+
availableModels: [
|
|
1212
|
+
...scaleOptions(mainOptions),
|
|
1213
|
+
...scaleOptions(manualOptions),
|
|
1214
|
+
],
|
|
1215
|
+
currentModelId: preferredModel,
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1056
1218
|
//# sourceMappingURL=zedIntegration.js.map
|