@kikkimo/claude-launcher 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/README.md +32 -17
- package/claude-launcher +638 -393
- package/docs/README-zh.md +32 -17
- package/lib/api-manager.js +136 -11
- package/lib/auth/password-input.js +8 -4
- package/lib/auth/password-validator.js +83 -48
- package/lib/i18n/index.js +4 -3
- package/lib/i18n/language-manager.js +4 -3
- package/lib/i18n/locales/de.js +93 -9
- package/lib/i18n/locales/en.js +93 -9
- package/lib/i18n/locales/es.js +93 -9
- package/lib/i18n/locales/fr.js +93 -9
- package/lib/i18n/locales/it.js +93 -9
- package/lib/i18n/locales/ja.js +93 -9
- package/lib/i18n/locales/ko.js +93 -9
- package/lib/i18n/locales/pt.js +93 -9
- package/lib/i18n/locales/ru.js +93 -9
- package/lib/i18n/locales/zh-TW.js +93 -9
- package/lib/i18n/locales/zh.js +93 -9
- package/lib/launcher.js +131 -93
- package/lib/presets/providers.js +39 -18
- package/lib/ui/api-editor.js +210 -0
- package/lib/ui/interactive-table.js +216 -99
- package/lib/ui/menu.js +78 -55
- package/lib/ui/prompts.js +168 -139
- package/lib/ui/screen.js +125 -0
- package/lib/utils/stdin-manager.js +11 -9
- package/lib/utils/version-checker.js +63 -3
- package/package.json +2 -2
package/lib/i18n/locales/zh.js
CHANGED
|
@@ -10,10 +10,11 @@ module.exports = {
|
|
|
10
10
|
title: "主菜单",
|
|
11
11
|
launch_default: "启动 Claude Code",
|
|
12
12
|
launch_skip: "启动 Claude Code(自动跳过权限询问)",
|
|
13
|
+
launch_auto_mode: "启动 Claude Code(启用自动模式)",
|
|
13
14
|
launch_api: "使用第三方API启动 Claude Code",
|
|
14
15
|
launch_api_skip: "使用第三方API启动 Claude Code(自动跳过权限询问)",
|
|
15
16
|
api_management: "第三方API管理",
|
|
16
|
-
|
|
17
|
+
config_management: "配置管理",
|
|
17
18
|
version_check: "版本更新检查",
|
|
18
19
|
exit: "退出"
|
|
19
20
|
},
|
|
@@ -21,11 +22,26 @@ module.exports = {
|
|
|
21
22
|
title: "第三方API管理",
|
|
22
23
|
add_new: "添加新的第三方API",
|
|
23
24
|
remove: "删除API",
|
|
25
|
+
edit: "编辑API",
|
|
24
26
|
switch: "切换激活的API",
|
|
25
27
|
statistics: "查看API统计",
|
|
26
28
|
export: "导出配置",
|
|
27
29
|
import: "导入配置",
|
|
28
30
|
change_password: "修改密码",
|
|
31
|
+
manual_upgrade: "手动升级模型",
|
|
32
|
+
back: "返回主菜单"
|
|
33
|
+
},
|
|
34
|
+
config: {
|
|
35
|
+
title: "配置管理",
|
|
36
|
+
language: "语言设置",
|
|
37
|
+
auto_model_upgrade: "模型自动升级",
|
|
38
|
+
model_upgrade_notification: "模型升级提示",
|
|
39
|
+
telemetry: "Anthropic 遥测数据",
|
|
40
|
+
api_launch_mode: "第三方API启动模式",
|
|
41
|
+
back: "返回主菜单"
|
|
42
|
+
},
|
|
43
|
+
api_select: {
|
|
44
|
+
title: "选择要启动的API:",
|
|
29
45
|
back: "返回主菜单"
|
|
30
46
|
},
|
|
31
47
|
remove_api: {
|
|
@@ -203,6 +219,23 @@ module.exports = {
|
|
|
203
219
|
remove_confirm: "要删除的API:{0}",
|
|
204
220
|
cannot_undo: "此操作无法撤销!",
|
|
205
221
|
removed_info: "已删除:{0}"
|
|
222
|
+
},
|
|
223
|
+
edit: {
|
|
224
|
+
select_api: '选择要编辑的 API',
|
|
225
|
+
current_value: '当前值:{0}',
|
|
226
|
+
new_value: '新值:',
|
|
227
|
+
success: '✅ {0} 更新成功',
|
|
228
|
+
cancelled: '编辑已取消',
|
|
229
|
+
back: '返回',
|
|
230
|
+
field_name: '名称',
|
|
231
|
+
field_provider: '供应商',
|
|
232
|
+
field_base_url: 'Base URL',
|
|
233
|
+
field_model: '模型',
|
|
234
|
+
name_required: '编辑时名称不能为空',
|
|
235
|
+
duplicate: '此更改将创建重复的配置',
|
|
236
|
+
provider_url_mismatch: '供应商和 URL 可能不一致',
|
|
237
|
+
provider_url_mismatch_detail: '供应商:{0} / URL 建议:{1}',
|
|
238
|
+
url_provider_hint: "URL 匹配供应商 '{0}',但当前供应商为 '{1}'。建议更新供应商字段。"
|
|
206
239
|
}
|
|
207
240
|
},
|
|
208
241
|
|
|
@@ -276,6 +309,10 @@ module.exports = {
|
|
|
276
309
|
good: "良好",
|
|
277
310
|
strong: "强",
|
|
278
311
|
very_strong: "极强"
|
|
312
|
+
},
|
|
313
|
+
guard: {
|
|
314
|
+
delete: { header: '🗑️ 删除 API — 需要密码验证身份' },
|
|
315
|
+
edit: { header: '✏️ 编辑 API — 需要密码验证身份' }
|
|
279
316
|
}
|
|
280
317
|
},
|
|
281
318
|
|
|
@@ -323,15 +360,22 @@ module.exports = {
|
|
|
323
360
|
|
|
324
361
|
// 导航和界面
|
|
325
362
|
navigation: {
|
|
326
|
-
use_arrows: "使用 ↑↓
|
|
327
|
-
use_arrows_esc: "使用 ↑↓ 导航,回车键{0},ESC
|
|
363
|
+
use_arrows: "使用 ↑↓ 方向键导航,回车/空格键选择,连击两次 Ctrl+C 退出",
|
|
364
|
+
use_arrows_esc: "使用 ↑↓ 导航,回车键{0},ESC键取消",
|
|
365
|
+
use_arrows_page_esc: "←→ 第{0}/{1}页,↑↓ 导航,回车键{2},ESC键取消",
|
|
328
366
|
use_number_keys: "使用数字键选择:",
|
|
329
367
|
currently_active: "当前激活的API",
|
|
330
368
|
select_action: "选择一个操作:",
|
|
331
369
|
no_options: "无可用选项",
|
|
332
370
|
enter_choice: "输入您的选择({0},或任意其他键返回主菜单):",
|
|
333
371
|
arrow_keys_not_available: "方向键不可用。输入选择编号 (1-{0}):",
|
|
334
|
-
enter_choice_prompt: "[>] 输入您的选择 (1-2,或任意其他键返回主菜单): "
|
|
372
|
+
enter_choice_prompt: "[>] 输入您的选择 (1-2,或任意其他键返回主菜单): ",
|
|
373
|
+
action: {
|
|
374
|
+
edit: '编辑',
|
|
375
|
+
remove: '删除',
|
|
376
|
+
switch: '切换',
|
|
377
|
+
select: '选择'
|
|
378
|
+
}
|
|
335
379
|
},
|
|
336
380
|
|
|
337
381
|
// 启动过程
|
|
@@ -572,19 +616,15 @@ module.exports = {
|
|
|
572
616
|
model_upgrade: {
|
|
573
617
|
notification: "模型升级可用: {0} → {1}",
|
|
574
618
|
notification_api: "API: {0}",
|
|
575
|
-
notification_hint: "
|
|
619
|
+
notification_hint: "自动升级:「配置管理」/ 手动升级:「第三方API管理 > 手动升级模型」",
|
|
576
620
|
auto_upgraded: "模型已自动升级: {0} → {1}",
|
|
577
621
|
|
|
578
|
-
settings_title: "模型升级设置",
|
|
579
622
|
current_config: "当前配置",
|
|
580
623
|
auto_upgrade_label: "自动使用最新模型",
|
|
581
624
|
auto_upgrade_on: "开启",
|
|
582
625
|
auto_upgrade_off: "关闭",
|
|
583
626
|
|
|
584
|
-
menu_toggle_auto_on: "自动升级 [● 开启]",
|
|
585
|
-
menu_toggle_auto_off: "自动升级 [○ 关闭]",
|
|
586
627
|
menu_manual_upgrade: "手动一键升级所有模型",
|
|
587
|
-
menu_back: "返回",
|
|
588
628
|
|
|
589
629
|
manual_title: "模型升级检查",
|
|
590
630
|
manual_checking: "正在检查 {0} 个 API 配置...",
|
|
@@ -599,5 +639,49 @@ module.exports = {
|
|
|
599
639
|
manual_complete: "升级完成!",
|
|
600
640
|
manual_stats_upgraded: "已升级: {0} 个",
|
|
601
641
|
manual_stats_skipped: "已跳过: {0} 个 ({1} 个已是最新, {2} 个无升级信息)"
|
|
642
|
+
},
|
|
643
|
+
hints: {
|
|
644
|
+
auto_mode_info: '启动后按 Shift+Tab 可切换到自动执行模式',
|
|
645
|
+
active_api_info: '当前激活:{0} / {1}',
|
|
646
|
+
no_active_api: '未配置激活的API,请前往"API管理"添加。',
|
|
647
|
+
direct_mode_desc: '直接启动模式,使用激活的API直接启动',
|
|
648
|
+
direct_mode_api_info: 'API: {0} | 提供商: {1}',
|
|
649
|
+
direct_mode_api_detail: '模型: {0} | 最后使用: {1}',
|
|
650
|
+
direct_mode_change: '启动模式可在「配置管理」中切换',
|
|
651
|
+
direct_mode_no_active: '直接启动模式,但当前没有激活的API',
|
|
652
|
+
direct_mode_no_active_detail: '已配置 {0} 个API,请在「第三方API管理」中选择激活',
|
|
653
|
+
select_mode_desc: '选择模式,启动前将从API列表中选择',
|
|
654
|
+
select_mode_change: '启动模式可在「配置管理」中切换',
|
|
655
|
+
select_mode_api_count: '已配置 {0} 个API,当前激活: {1}',
|
|
656
|
+
select_mode_active_none: '无',
|
|
657
|
+
no_api_configured: '未配置第三方API,请先在「第三方API管理」中添加',
|
|
658
|
+
api_management_info: '已配置 {0} 个API,当前激活: {1}',
|
|
659
|
+
config_summary: '语言: {0} | 启动模式: {1} | 遥测: {2}',
|
|
660
|
+
edit_password_required: '🔒 编辑API配置需要密码验证',
|
|
661
|
+
remove_password_required: '🔒 删除API需要密码验证',
|
|
662
|
+
export_password_required: '🔒 导出配置需要密码验证',
|
|
663
|
+
import_password_required: '🔒 导入配置需要密码验证',
|
|
664
|
+
config: {
|
|
665
|
+
language: '切换界面显示语言,当前: {0}',
|
|
666
|
+
auto_upgrade: '自动检测并升级第三方API的模型版本',
|
|
667
|
+
upgrade_notification: '在主菜单顶部显示模型可升级的通知',
|
|
668
|
+
telemetry: '关闭后启动时注入 DISABLE_TELEMETRY=1,建议关闭',
|
|
669
|
+
launch_mode: '直接模式: 使用激活API启动 / 选择模式: 启动前从列表选择'
|
|
670
|
+
},
|
|
671
|
+
api_select: {
|
|
672
|
+
info: 'API: {0}',
|
|
673
|
+
detail: '提供商: {0} | 模型: {1}',
|
|
674
|
+
usage: '使用次数: {0} | 最后使用: {1}'
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
|
|
678
|
+
config: {
|
|
679
|
+
values: {
|
|
680
|
+
on: '开启',
|
|
681
|
+
off: '关闭',
|
|
682
|
+
direct_mode: '直接模式',
|
|
683
|
+
select_mode: '选择模式',
|
|
684
|
+
recommended_off: '关闭 (推荐)'
|
|
685
|
+
}
|
|
602
686
|
}
|
|
603
687
|
};
|
package/lib/launcher.js
CHANGED
|
@@ -7,11 +7,108 @@ const colors = require('./ui/colors');
|
|
|
7
7
|
const i18n = require('./i18n');
|
|
8
8
|
const { getProvider } = require('./presets/providers');
|
|
9
9
|
const stdinManager = require('./utils/stdin-manager');
|
|
10
|
+
const { loadConfigSync } = require('./utils/version-checker');
|
|
11
|
+
|
|
12
|
+
// Module-level flag for console handoff state
|
|
13
|
+
let consoleRelinquished = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Detach stdin and suspend stdinManager so the child process owns the terminal
|
|
17
|
+
*/
|
|
18
|
+
function relinquishConsoleToChild() {
|
|
19
|
+
if (consoleRelinquished) return;
|
|
20
|
+
consoleRelinquished = true;
|
|
21
|
+
try {
|
|
22
|
+
if (process.stdin.isTTY) {
|
|
23
|
+
process.stdin.setRawMode(false);
|
|
24
|
+
}
|
|
25
|
+
} catch (_) {}
|
|
26
|
+
|
|
27
|
+
// Detach only current scope listeners to avoid affecting other modules
|
|
28
|
+
if (stdinManager.activeScope && typeof stdinManager.activeScope.detach === 'function') {
|
|
29
|
+
stdinManager.activeScope.detach();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Suspend stdin manager so no new listeners are attached while Claude is running
|
|
33
|
+
if (typeof stdinManager.suspend === 'function') {
|
|
34
|
+
stdinManager.suspend();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Restore stdinManager after child process exits
|
|
40
|
+
*/
|
|
41
|
+
function restoreConsoleForLauncher() {
|
|
42
|
+
if (!consoleRelinquished) return;
|
|
43
|
+
consoleRelinquished = false;
|
|
44
|
+
if (typeof stdinManager.resume === 'function') {
|
|
45
|
+
stdinManager.resume();
|
|
46
|
+
}
|
|
47
|
+
stdinManager.enableCtrlC();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handle launch failures with optional rollback and user prompt
|
|
52
|
+
*/
|
|
53
|
+
function handleLaunchFailure(message, opts = {}) {
|
|
54
|
+
if (opts.afterHandover) {
|
|
55
|
+
restoreConsoleForLauncher();
|
|
56
|
+
} else {
|
|
57
|
+
stdinManager.enableCtrlC();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Rollback launch statistics if callback provided — pass error message for lastError
|
|
61
|
+
if (typeof opts.rollbackFn === 'function') {
|
|
62
|
+
try { opts.rollbackFn(message); } catch (_) {}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log(colors.red + '[x] ' + message + colors.reset);
|
|
66
|
+
console.log(colors.gray + i18n.tSync('ui.general.press_key_return_menu') + colors.reset);
|
|
67
|
+
|
|
68
|
+
if (process.stdin.isTTY) {
|
|
69
|
+
try {
|
|
70
|
+
process.stdin.setRawMode(true);
|
|
71
|
+
process.stdin.resume();
|
|
72
|
+
} catch (_) {
|
|
73
|
+
// Ignore setup failures
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Set timeout to prevent infinite hanging
|
|
77
|
+
const timeoutId = setTimeout(() => {
|
|
78
|
+
try {
|
|
79
|
+
process.stdin.setRawMode(false);
|
|
80
|
+
} catch (_) {
|
|
81
|
+
// Ignore cleanup failures
|
|
82
|
+
}
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}, 60000); // 60 second timeout
|
|
85
|
+
|
|
86
|
+
process.stdin.once('data', () => {
|
|
87
|
+
clearTimeout(timeoutId);
|
|
88
|
+
try {
|
|
89
|
+
process.stdin.setRawMode(false);
|
|
90
|
+
} catch (_) {
|
|
91
|
+
// Ignore cleanup failures
|
|
92
|
+
}
|
|
93
|
+
// Exit after user acknowledges the error
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
// For non-TTY environments, exit immediately
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
10
101
|
|
|
11
102
|
/**
|
|
12
103
|
* Launch Claude Code with specified environment variables
|
|
13
104
|
*/
|
|
14
|
-
function launchClaude(command, envVars = {}, disableAuthTokens = false) {
|
|
105
|
+
function launchClaude(command, envVars = {}, disableAuthTokens = false, opts = {}) {
|
|
106
|
+
// Inject telemetry control from config
|
|
107
|
+
const launcherConfig = loadConfigSync();
|
|
108
|
+
if (launcherConfig.disableTelemetry) {
|
|
109
|
+
envVars.DISABLE_TELEMETRY = '1';
|
|
110
|
+
}
|
|
111
|
+
|
|
15
112
|
// Disable Ctrl+C monitoring before launching Claude Code
|
|
16
113
|
// This allows Ctrl+C to be handled exclusively by Claude Code process
|
|
17
114
|
stdinManager.disableCtrlC();
|
|
@@ -49,81 +146,6 @@ function launchClaude(command, envVars = {}, disableAuthTokens = false) {
|
|
|
49
146
|
const args = command.split(' ');
|
|
50
147
|
const cmd = args.shift();
|
|
51
148
|
|
|
52
|
-
let consoleRelinquished = false;
|
|
53
|
-
const relinquishConsoleToChild = () => {
|
|
54
|
-
if (consoleRelinquished) return;
|
|
55
|
-
consoleRelinquished = true;
|
|
56
|
-
// Do the minimal changes: switch to cooked mode and detach current scope, but do not pause stdin nor swallow signals
|
|
57
|
-
try {
|
|
58
|
-
if (process.stdin.isTTY) {
|
|
59
|
-
process.stdin.setRawMode(false);
|
|
60
|
-
}
|
|
61
|
-
} catch (_) {}
|
|
62
|
-
|
|
63
|
-
// Detach only current scope listeners to avoid affecting other modules
|
|
64
|
-
if (stdinManager.activeScope && typeof stdinManager.activeScope.detach === 'function') {
|
|
65
|
-
stdinManager.activeScope.detach();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Suspend stdin manager so no new listeners are attached while Claude is running
|
|
69
|
-
if (typeof stdinManager.suspend === 'function') {
|
|
70
|
-
stdinManager.suspend();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const restoreConsoleForLauncher = () => {
|
|
75
|
-
if (!consoleRelinquished) return;
|
|
76
|
-
consoleRelinquished = false;
|
|
77
|
-
if (typeof stdinManager.resume === 'function') {
|
|
78
|
-
stdinManager.resume();
|
|
79
|
-
}
|
|
80
|
-
stdinManager.enableCtrlC();
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const handleLaunchFailure = (message, opts = {}) => {
|
|
84
|
-
if (opts.afterHandover) {
|
|
85
|
-
restoreConsoleForLauncher();
|
|
86
|
-
} else {
|
|
87
|
-
stdinManager.enableCtrlC();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log(colors.red + '[x] ' + message + colors.reset);
|
|
91
|
-
console.log(colors.gray + i18n.tSync('ui.general.press_key_return_menu') + colors.reset);
|
|
92
|
-
|
|
93
|
-
if (process.stdin.isTTY) {
|
|
94
|
-
try {
|
|
95
|
-
process.stdin.setRawMode(true);
|
|
96
|
-
process.stdin.resume();
|
|
97
|
-
} catch (_) {
|
|
98
|
-
// Ignore setup failures
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Set timeout to prevent infinite hanging
|
|
102
|
-
const timeoutId = setTimeout(() => {
|
|
103
|
-
try {
|
|
104
|
-
process.stdin.setRawMode(false);
|
|
105
|
-
} catch (_) {
|
|
106
|
-
// Ignore cleanup failures
|
|
107
|
-
}
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}, 60000); // 60 second timeout
|
|
110
|
-
|
|
111
|
-
process.stdin.once('data', () => {
|
|
112
|
-
clearTimeout(timeoutId);
|
|
113
|
-
try {
|
|
114
|
-
process.stdin.setRawMode(false);
|
|
115
|
-
} catch (_) {
|
|
116
|
-
// Ignore cleanup failures
|
|
117
|
-
}
|
|
118
|
-
// Exit after user acknowledges the error
|
|
119
|
-
process.exit(1);
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
122
|
-
// For non-TTY environments, exit immediately
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
149
|
try {
|
|
128
150
|
// Clean up terminal state before launching Claude
|
|
129
151
|
if (process.stdin.isTTY) {
|
|
@@ -135,15 +157,8 @@ function launchClaude(command, envVars = {}, disableAuthTokens = false) {
|
|
|
135
157
|
}
|
|
136
158
|
}
|
|
137
159
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
// This ensures only the current scope's listeners are detached while
|
|
141
|
-
// preserving any listeners from other modules.
|
|
142
|
-
//
|
|
143
|
-
// Note: Do NOT remove global SIGINT/SIGTERM handlers here.
|
|
144
|
-
// The existing handlers already check stdinManager.isSuspended() and
|
|
145
|
-
// will properly ignore signals during child process execution.
|
|
146
|
-
// Removing all handlers would break other modules and degrade reliability.
|
|
160
|
+
// Relinquish console before spawn so the child inherits a clean terminal
|
|
161
|
+
relinquishConsoleToChild();
|
|
147
162
|
|
|
148
163
|
// Launch Claude in current terminal, inherit stdio
|
|
149
164
|
const child = spawn(cmd, args, {
|
|
@@ -153,19 +168,22 @@ function launchClaude(command, envVars = {}, disableAuthTokens = false) {
|
|
|
153
168
|
shell: true
|
|
154
169
|
});
|
|
155
170
|
|
|
156
|
-
relinquishConsoleToChild();
|
|
157
|
-
|
|
158
171
|
child.on('close', (code) => {
|
|
159
172
|
restoreConsoleForLauncher();
|
|
160
173
|
process.exit(code || 0);
|
|
161
174
|
});
|
|
162
175
|
|
|
163
176
|
child.on('error', (error) => {
|
|
164
|
-
handleLaunchFailure('Error running Claude: ' + error.message, {
|
|
177
|
+
handleLaunchFailure('Error running Claude: ' + error.message, {
|
|
178
|
+
afterHandover: true,
|
|
179
|
+
rollbackFn: opts.rollbackFn
|
|
180
|
+
});
|
|
165
181
|
});
|
|
166
182
|
|
|
167
183
|
} catch (error) {
|
|
168
|
-
handleLaunchFailure('Error launching Claude Code: ' + error.message
|
|
184
|
+
handleLaunchFailure('Error launching Claude Code: ' + error.message, {
|
|
185
|
+
rollbackFn: opts.rollbackFn
|
|
186
|
+
});
|
|
169
187
|
}
|
|
170
188
|
}
|
|
171
189
|
|
|
@@ -183,6 +201,15 @@ function launchClaudeSkipPermissions() {
|
|
|
183
201
|
launchClaude('claude --dangerously-skip-permissions');
|
|
184
202
|
}
|
|
185
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Launch Claude with auto mode enabled
|
|
206
|
+
* Note: --enable-auto-mode makes auto mode available as a permission mode.
|
|
207
|
+
* User must press Shift+Tab in the session to switch to it.
|
|
208
|
+
*/
|
|
209
|
+
function launchClaudeAutoMode() {
|
|
210
|
+
launchClaude('claude --enable-auto-mode');
|
|
211
|
+
}
|
|
212
|
+
|
|
186
213
|
/**
|
|
187
214
|
* Get environment variables based on provider type
|
|
188
215
|
*/
|
|
@@ -222,12 +249,21 @@ function getProviderEnvVars(api) {
|
|
|
222
249
|
/**
|
|
223
250
|
* Launch Claude with third-party API configuration
|
|
224
251
|
*/
|
|
225
|
-
function launchClaudeWithApi(api, skipPermissions = false) {
|
|
252
|
+
function launchClaudeWithApi(api, skipPermissions = false, opts = {}) {
|
|
226
253
|
const command = skipPermissions
|
|
227
254
|
? 'claude --dangerously-skip-permissions'
|
|
228
255
|
: 'claude';
|
|
229
256
|
|
|
230
|
-
|
|
257
|
+
let envVars;
|
|
258
|
+
try {
|
|
259
|
+
envVars = getProviderEnvVars(api);
|
|
260
|
+
} catch (error) {
|
|
261
|
+
handleLaunchFailure('Failed to prepare API environment: ' + error.message, {
|
|
262
|
+
afterHandover: true,
|
|
263
|
+
rollbackFn: opts.rollbackFn
|
|
264
|
+
});
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
231
267
|
|
|
232
268
|
console.log('');
|
|
233
269
|
console.log(colors.bright + colors.orange + '🔗 ' + i18n.tSync('launch.using_third_party_api') + colors.reset);
|
|
@@ -272,7 +308,7 @@ function launchClaudeWithApi(api, skipPermissions = false) {
|
|
|
272
308
|
|
|
273
309
|
console.log('');
|
|
274
310
|
|
|
275
|
-
launchClaude(command, envVars, true);
|
|
311
|
+
launchClaude(command, envVars, true, { rollbackFn: opts.rollbackFn });
|
|
276
312
|
}
|
|
277
313
|
|
|
278
314
|
/**
|
|
@@ -353,7 +389,9 @@ module.exports = {
|
|
|
353
389
|
launchClaude,
|
|
354
390
|
launchClaudeDefault,
|
|
355
391
|
launchClaudeSkipPermissions,
|
|
392
|
+
launchClaudeAutoMode,
|
|
356
393
|
launchClaudeWithApi,
|
|
357
394
|
getProviderEnvVars,
|
|
358
|
-
testApiConnection
|
|
395
|
+
testApiConnection,
|
|
396
|
+
handleLaunchFailure
|
|
359
397
|
};
|
package/lib/presets/providers.js
CHANGED
|
@@ -35,15 +35,20 @@ const providers = {
|
|
|
35
35
|
compatibility: 'native'
|
|
36
36
|
},
|
|
37
37
|
moonshot: {
|
|
38
|
-
name: 'Moonshot AI (Kimi-K2)',
|
|
38
|
+
name: 'Moonshot AI (Kimi-K2.5/K2-Thinking)',
|
|
39
39
|
baseUrl: 'https://api.moonshot.cn/anthropic',
|
|
40
40
|
models: [
|
|
41
|
-
'kimi-k2
|
|
42
|
-
'kimi-k2-0905-preview',
|
|
43
|
-
'kimi-k2-turbo-preview',
|
|
41
|
+
'kimi-k2.5',
|
|
44
42
|
'kimi-k2-thinking',
|
|
45
43
|
'kimi-k2-thinking-turbo'
|
|
46
44
|
],
|
|
45
|
+
versionAliases: {
|
|
46
|
+
'kimi-k2-0711-preview': 'kimi-k2.5',
|
|
47
|
+
'kimi-k2-0905-preview': 'kimi-k2.5',
|
|
48
|
+
'kimi-k2-turbo-preview': 'kimi-k2.5',
|
|
49
|
+
'kimi-k2-thinking': 'kimi-k2.5',
|
|
50
|
+
'kimi-k2-thinking-turbo': 'kimi-k2.5'
|
|
51
|
+
},
|
|
47
52
|
authTokenFormat: 'sk-...',
|
|
48
53
|
description: 'Moonshot AI - Provides Anthropic-compatible API',
|
|
49
54
|
requiresToken: true,
|
|
@@ -74,8 +79,14 @@ const providers = {
|
|
|
74
79
|
name: 'MiniMax CN (国内版)',
|
|
75
80
|
baseUrl: 'https://api.minimaxi.com/anthropic',
|
|
76
81
|
models: [
|
|
82
|
+
'MiniMax-M2.7',
|
|
83
|
+
'MiniMax-M2.5',
|
|
77
84
|
'MiniMax-M2.1'
|
|
78
85
|
],
|
|
86
|
+
versionAliases: {
|
|
87
|
+
'MiniMax-M2.1': 'MiniMax-M2.7',
|
|
88
|
+
'MiniMax-M2.5': 'MiniMax-M2.7'
|
|
89
|
+
},
|
|
79
90
|
authTokenFormat: 'sk-...',
|
|
80
91
|
description: 'MiniMax AI - Anthropic-compatible API for China users',
|
|
81
92
|
requiresToken: true,
|
|
@@ -90,8 +101,14 @@ const providers = {
|
|
|
90
101
|
name: 'MiniMax Global (国际版)',
|
|
91
102
|
baseUrl: 'https://api.minimax.io/anthropic',
|
|
92
103
|
models: [
|
|
104
|
+
'MiniMax-M2.7',
|
|
105
|
+
'MiniMax-M2.5',
|
|
93
106
|
'MiniMax-M2.1'
|
|
94
107
|
],
|
|
108
|
+
versionAliases: {
|
|
109
|
+
'MiniMax-M2.1': 'MiniMax-M2.7',
|
|
110
|
+
'MiniMax-M2.5': 'MiniMax-M2.7'
|
|
111
|
+
},
|
|
95
112
|
authTokenFormat: 'sk-...',
|
|
96
113
|
description: 'MiniMax AI - Anthropic-compatible API for international users',
|
|
97
114
|
requiresToken: true,
|
|
@@ -120,18 +137,20 @@ const providers = {
|
|
|
120
137
|
note: 'Requires extended timeout for complex reasoning tasks'
|
|
121
138
|
},
|
|
122
139
|
zhipu: {
|
|
123
|
-
name: 'ZhiPu AI (GLM-5
|
|
140
|
+
name: 'ZhiPu AI (GLM-5.1/5-Turbo/5/4.7) - 智谱清言',
|
|
124
141
|
baseUrl: 'https://open.bigmodel.cn/api/anthropic',
|
|
125
142
|
models: [
|
|
143
|
+
'glm-5.1',
|
|
144
|
+
'glm-5-turbo',
|
|
126
145
|
'glm-5',
|
|
127
|
-
'glm-4.7'
|
|
128
|
-
'glm-4.6',
|
|
129
|
-
'glm-4.5'
|
|
146
|
+
'glm-4.7'
|
|
130
147
|
],
|
|
131
148
|
versionAliases: {
|
|
132
|
-
'glm-4.5': 'glm-5',
|
|
133
|
-
'glm-4.6': 'glm-5',
|
|
134
|
-
'glm-4.7': 'glm-5'
|
|
149
|
+
'glm-4.5': 'glm-5.1',
|
|
150
|
+
'glm-4.6': 'glm-5.1',
|
|
151
|
+
'glm-4.7': 'glm-5.1',
|
|
152
|
+
'glm-5': 'glm-5.1',
|
|
153
|
+
'glm-5-turbo': 'glm-5.1'
|
|
135
154
|
},
|
|
136
155
|
authTokenFormat: 'sk-...',
|
|
137
156
|
description: 'ZhiPu AI (智谱清言) - Anthropic-compatible API for mainland China',
|
|
@@ -144,18 +163,20 @@ const providers = {
|
|
|
144
163
|
note: 'Requires extended timeout for large responses'
|
|
145
164
|
},
|
|
146
165
|
zai: {
|
|
147
|
-
name: 'Z.ai (GLM-5
|
|
166
|
+
name: 'Z.ai (GLM-5.1/5-Turbo/5/4.7) - ZhiPu Global',
|
|
148
167
|
baseUrl: 'https://api.z.ai/api/anthropic',
|
|
149
168
|
models: [
|
|
169
|
+
'glm-5.1',
|
|
170
|
+
'glm-5-turbo',
|
|
150
171
|
'glm-5',
|
|
151
|
-
'glm-4.7'
|
|
152
|
-
'glm-4.6',
|
|
153
|
-
'glm-4.5'
|
|
172
|
+
'glm-4.7'
|
|
154
173
|
],
|
|
155
174
|
versionAliases: {
|
|
156
|
-
'glm-4.5': 'glm-5',
|
|
157
|
-
'glm-4.6': 'glm-5',
|
|
158
|
-
'glm-4.7': 'glm-5'
|
|
175
|
+
'glm-4.5': 'glm-5.1',
|
|
176
|
+
'glm-4.6': 'glm-5.1',
|
|
177
|
+
'glm-4.7': 'glm-5.1',
|
|
178
|
+
'glm-5': 'glm-5.1',
|
|
179
|
+
'glm-5-turbo': 'glm-5.1'
|
|
159
180
|
},
|
|
160
181
|
authTokenFormat: 'sk-...',
|
|
161
182
|
description: 'Z.ai (ZhiPu AI Global) - Anthropic-compatible API for international users',
|