@xhscopy-ai/cli 0.0.134 → 0.0.136
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/client-config.snapshot.json +26 -17
- package/dist/brand.json +13 -13
- package/dist/client-config.snapshot.json +26 -17
- package/dist/commands/refresh.js +1 -1
- package/dist/lib/post-apply.js +1 -1
- package/dist/lib/tools/claude-desktop.js +1 -1
- package/dist/locales/en_US.json +1 -1
- package/dist/locales/zh_CN.json +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"description": "100 万上下文 | 12.8 万输出 | 自适应思考常开 | 长时 Agent 与多步研究",
|
|
22
|
-
"group": "
|
|
22
|
+
"group": "grp_rld6af0zorqd",
|
|
23
23
|
"group_name": "",
|
|
24
24
|
"hidden": false,
|
|
25
25
|
"id": "claude-fable-5-1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"description": "轻量档 | 低延迟 | 高频短任务",
|
|
31
|
-
"group": "
|
|
31
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
32
32
|
"group_name": "",
|
|
33
33
|
"hidden": false,
|
|
34
34
|
"id": "claude-haiku-4-5-20251001",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"description": "100 万上下文 | 12.8 万输出 | 低延迟 | 高频轻量任务",
|
|
40
|
-
"group": "
|
|
40
|
+
"group": "grp_rld6af0zorqd",
|
|
41
41
|
"group_name": "",
|
|
42
42
|
"hidden": false,
|
|
43
43
|
"id": "claude-haiku-5-5",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
|
|
49
|
-
"group": "
|
|
49
|
+
"group": "grp_rld6af0zorqd",
|
|
50
50
|
"group_name": "",
|
|
51
51
|
"hidden": false,
|
|
52
52
|
"id": "claude-opus-4-6",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
|
|
67
|
-
"group": "
|
|
67
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
68
68
|
"group_name": "",
|
|
69
69
|
"hidden": false,
|
|
70
70
|
"id": "claude-opus-4-8",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"description": "100 万上下文 | 12.8 万输出 | 自适应思考五档 | Agent 编程",
|
|
76
|
-
"group": "
|
|
76
|
+
"group": "grp_6lyxfgbs440g",
|
|
77
77
|
"group_name": "",
|
|
78
78
|
"hidden": false,
|
|
79
79
|
"id": "claude-opus-5",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"description": "100 万上下文 | 长时 Agent 编程 | 知识工作",
|
|
85
|
-
"group": "
|
|
85
|
+
"group": "grp_irydsgijuckh",
|
|
86
86
|
"group_name": "",
|
|
87
87
|
"hidden": false,
|
|
88
88
|
"id": "claude-opus-5-5",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"description": "100 万上下文 | Agent 编程 | 长上下文不加价",
|
|
94
|
-
"group": "
|
|
94
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
95
95
|
"group_name": "",
|
|
96
96
|
"hidden": false,
|
|
97
97
|
"id": "claude-sonnet-4-6",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"description": "100 万上下文 | Agent 编程 | 工具调用 | 知识工作",
|
|
103
|
-
"group": "
|
|
103
|
+
"group": "grp_rld6af0zorqd",
|
|
104
104
|
"group_name": "",
|
|
105
105
|
"hidden": false,
|
|
106
106
|
"id": "claude-sonnet-5",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"description": "100 万上下文 | 12.8 万输出 | Agent 编程 | 知识工作",
|
|
112
|
-
"group": "
|
|
112
|
+
"group": "grp_rld6af0zorqd",
|
|
113
113
|
"group_name": "",
|
|
114
114
|
"hidden": false,
|
|
115
115
|
"id": "claude-sonnet-5-5",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"codex": [
|
|
121
121
|
{
|
|
122
122
|
"description": "100 万上下文 | 12.8 万输出 | 复杂专业负载",
|
|
123
|
-
"group": "
|
|
123
|
+
"group": "grp_irydsgijuckh",
|
|
124
124
|
"group_name": "",
|
|
125
125
|
"hidden": false,
|
|
126
126
|
"id": "gpt-5.5",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
"description": "105 万上下文 | 12.8 万输出 | 大批量低成本档",
|
|
132
|
-
"group": "
|
|
132
|
+
"group": "grp_bsbtt432saoq",
|
|
133
133
|
"group_name": "",
|
|
134
134
|
"hidden": false,
|
|
135
135
|
"id": "gpt-5.6-luna",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
"description": "105 万上下文 | 12.8 万输出 | 均衡生产档",
|
|
150
|
-
"group": "
|
|
150
|
+
"group": "grp_irydsgijuckh",
|
|
151
151
|
"group_name": "",
|
|
152
152
|
"hidden": false,
|
|
153
153
|
"id": "gpt-5.6-terra",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"description": "105 万上下文 | 12.8 万输出 | 思考强度至 max | 计算机操作 / 编码 / 科学基准接近饱和",
|
|
159
|
-
"group": "
|
|
159
|
+
"group": "grp_mb5v069lpnze",
|
|
160
160
|
"group_name": "",
|
|
161
161
|
"hidden": false,
|
|
162
162
|
"id": "gpt-6-astra",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
"description": "转发至 gpt-6-sol | 实际由 gpt-6-sol 响应 | 105 万上下文 | 12.8 万输出",
|
|
168
|
-
"group": "
|
|
168
|
+
"group": "grp_irydsgijuckh",
|
|
169
169
|
"group_name": "",
|
|
170
170
|
"hidden": false,
|
|
171
171
|
"id": "gpt-6-luna",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
"description": "105 万上下文 | 12.8 万输出 | 复杂编程与 Agent 工作流",
|
|
177
|
-
"group": "
|
|
177
|
+
"group": "grp_squ2qzjnehps",
|
|
178
178
|
"group_name": "",
|
|
179
179
|
"hidden": false,
|
|
180
180
|
"id": "gpt-6-sol",
|
|
@@ -189,6 +189,15 @@
|
|
|
189
189
|
"id": "gpt-6.1-sol",
|
|
190
190
|
"name": "gpt-6.1-sol",
|
|
191
191
|
"recommended": false
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"description": "105 万上下文 | 12.8 万输出 | 计算机操作与日常 Agent 任务 | 均衡档",
|
|
195
|
+
"group": "grp_mb5v069lpnze",
|
|
196
|
+
"group_name": "",
|
|
197
|
+
"hidden": false,
|
|
198
|
+
"id": "gpt-6.1-terra",
|
|
199
|
+
"name": "gpt-6.1-terra",
|
|
200
|
+
"recommended": false
|
|
192
201
|
}
|
|
193
202
|
],
|
|
194
203
|
"gemini": [
|
|
@@ -248,7 +257,7 @@
|
|
|
248
257
|
},
|
|
249
258
|
{
|
|
250
259
|
"description": "约 208 token/秒 | 高吞吐 | 多语言 | 编码",
|
|
251
|
-
"group": "
|
|
260
|
+
"group": "grp_z5khwusxuh2j",
|
|
252
261
|
"group_name": "",
|
|
253
262
|
"hidden": false,
|
|
254
263
|
"id": "gemini-3.6-flash",
|
package/dist/brand.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "xhscopy-ai",
|
|
3
|
-
"displayName": "Xhscopy AI",
|
|
4
|
-
"productName": "Xhscopy AI CLI",
|
|
5
|
-
"shortName": "xhscopy-ai",
|
|
6
|
-
"providerKey": "xhscopy-ai",
|
|
7
2
|
"apiKeyEnv": "XHSCOPY_AI_API_KEY",
|
|
8
3
|
"desktopEntryName": "Xhscopy AI",
|
|
9
|
-
"
|
|
4
|
+
"displayName": "Xhscopy AI",
|
|
10
5
|
"gatewayAddresses": [
|
|
11
6
|
{
|
|
12
|
-
"
|
|
13
|
-
"
|
|
7
|
+
"label": "主站",
|
|
8
|
+
"url": "https://ai.xhscopy.top"
|
|
14
9
|
}
|
|
15
10
|
],
|
|
11
|
+
"id": "xhscopy-ai",
|
|
12
|
+
"installMirror": {
|
|
13
|
+
"agy": "https://cnb.cool/lib/agy/-/releases/latest/download",
|
|
14
|
+
"scripts": "https://cnb.cool/lib/install/-/git/raw/main"
|
|
15
|
+
},
|
|
16
16
|
"links": {
|
|
17
17
|
"tokenPage": "https://ai.xhscopy.top/console/token"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
20
|
-
"scripts": "https://cnb.cool/lib/install/-/git/raw/main",
|
|
21
|
-
"agy": "https://cnb.cool/lib/agy/-/releases/latest/download"
|
|
22
|
-
},
|
|
19
|
+
"packageName": "@xhscopy-ai/cli",
|
|
23
20
|
"pluginMarketplaces": [
|
|
24
21
|
{
|
|
25
|
-
"name": "cn-plugins",
|
|
26
22
|
"add": "https://cnb.cool/lib/claude-plugins-official.git",
|
|
23
|
+
"name": "cn-plugins",
|
|
27
24
|
"probe": "https://cnb.cool/lib/claude-plugins-official.git"
|
|
28
25
|
}
|
|
29
26
|
],
|
|
27
|
+
"productName": "Xhscopy AI CLI",
|
|
28
|
+
"providerKey": "xhscopy-ai",
|
|
29
|
+
"shortName": "xhscopy-ai",
|
|
30
30
|
"updateRegistries": [
|
|
31
31
|
{
|
|
32
32
|
"id": "npm",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"description": "100 万上下文 | 12.8 万输出 | 自适应思考常开 | 长时 Agent 与多步研究",
|
|
22
|
-
"group": "
|
|
22
|
+
"group": "grp_rld6af0zorqd",
|
|
23
23
|
"group_name": "",
|
|
24
24
|
"hidden": false,
|
|
25
25
|
"id": "claude-fable-5-1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"description": "轻量档 | 低延迟 | 高频短任务",
|
|
31
|
-
"group": "
|
|
31
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
32
32
|
"group_name": "",
|
|
33
33
|
"hidden": false,
|
|
34
34
|
"id": "claude-haiku-4-5-20251001",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"description": "100 万上下文 | 12.8 万输出 | 低延迟 | 高频轻量任务",
|
|
40
|
-
"group": "
|
|
40
|
+
"group": "grp_rld6af0zorqd",
|
|
41
41
|
"group_name": "",
|
|
42
42
|
"hidden": false,
|
|
43
43
|
"id": "claude-haiku-5-5",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
|
|
49
|
-
"group": "
|
|
49
|
+
"group": "grp_rld6af0zorqd",
|
|
50
50
|
"group_name": "",
|
|
51
51
|
"hidden": false,
|
|
52
52
|
"id": "claude-opus-4-6",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
|
|
67
|
-
"group": "
|
|
67
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
68
68
|
"group_name": "",
|
|
69
69
|
"hidden": false,
|
|
70
70
|
"id": "claude-opus-4-8",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"description": "100 万上下文 | 12.8 万输出 | 自适应思考五档 | Agent 编程",
|
|
76
|
-
"group": "
|
|
76
|
+
"group": "grp_6lyxfgbs440g",
|
|
77
77
|
"group_name": "",
|
|
78
78
|
"hidden": false,
|
|
79
79
|
"id": "claude-opus-5",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"description": "100 万上下文 | 长时 Agent 编程 | 知识工作",
|
|
85
|
-
"group": "
|
|
85
|
+
"group": "grp_irydsgijuckh",
|
|
86
86
|
"group_name": "",
|
|
87
87
|
"hidden": false,
|
|
88
88
|
"id": "claude-opus-5-5",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"description": "100 万上下文 | Agent 编程 | 长上下文不加价",
|
|
94
|
-
"group": "
|
|
94
|
+
"group": "grp_6eg2dq9ywgrg",
|
|
95
95
|
"group_name": "",
|
|
96
96
|
"hidden": false,
|
|
97
97
|
"id": "claude-sonnet-4-6",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"description": "100 万上下文 | Agent 编程 | 工具调用 | 知识工作",
|
|
103
|
-
"group": "
|
|
103
|
+
"group": "grp_rld6af0zorqd",
|
|
104
104
|
"group_name": "",
|
|
105
105
|
"hidden": false,
|
|
106
106
|
"id": "claude-sonnet-5",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"description": "100 万上下文 | 12.8 万输出 | Agent 编程 | 知识工作",
|
|
112
|
-
"group": "
|
|
112
|
+
"group": "grp_rld6af0zorqd",
|
|
113
113
|
"group_name": "",
|
|
114
114
|
"hidden": false,
|
|
115
115
|
"id": "claude-sonnet-5-5",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"codex": [
|
|
121
121
|
{
|
|
122
122
|
"description": "100 万上下文 | 12.8 万输出 | 复杂专业负载",
|
|
123
|
-
"group": "
|
|
123
|
+
"group": "grp_irydsgijuckh",
|
|
124
124
|
"group_name": "",
|
|
125
125
|
"hidden": false,
|
|
126
126
|
"id": "gpt-5.5",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
"description": "105 万上下文 | 12.8 万输出 | 大批量低成本档",
|
|
132
|
-
"group": "
|
|
132
|
+
"group": "grp_bsbtt432saoq",
|
|
133
133
|
"group_name": "",
|
|
134
134
|
"hidden": false,
|
|
135
135
|
"id": "gpt-5.6-luna",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
"description": "105 万上下文 | 12.8 万输出 | 均衡生产档",
|
|
150
|
-
"group": "
|
|
150
|
+
"group": "grp_irydsgijuckh",
|
|
151
151
|
"group_name": "",
|
|
152
152
|
"hidden": false,
|
|
153
153
|
"id": "gpt-5.6-terra",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"description": "105 万上下文 | 12.8 万输出 | 思考强度至 max | 计算机操作 / 编码 / 科学基准接近饱和",
|
|
159
|
-
"group": "
|
|
159
|
+
"group": "grp_mb5v069lpnze",
|
|
160
160
|
"group_name": "",
|
|
161
161
|
"hidden": false,
|
|
162
162
|
"id": "gpt-6-astra",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
"description": "转发至 gpt-6-sol | 实际由 gpt-6-sol 响应 | 105 万上下文 | 12.8 万输出",
|
|
168
|
-
"group": "
|
|
168
|
+
"group": "grp_irydsgijuckh",
|
|
169
169
|
"group_name": "",
|
|
170
170
|
"hidden": false,
|
|
171
171
|
"id": "gpt-6-luna",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
"description": "105 万上下文 | 12.8 万输出 | 复杂编程与 Agent 工作流",
|
|
177
|
-
"group": "
|
|
177
|
+
"group": "grp_squ2qzjnehps",
|
|
178
178
|
"group_name": "",
|
|
179
179
|
"hidden": false,
|
|
180
180
|
"id": "gpt-6-sol",
|
|
@@ -189,6 +189,15 @@
|
|
|
189
189
|
"id": "gpt-6.1-sol",
|
|
190
190
|
"name": "gpt-6.1-sol",
|
|
191
191
|
"recommended": false
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"description": "105 万上下文 | 12.8 万输出 | 计算机操作与日常 Agent 任务 | 均衡档",
|
|
195
|
+
"group": "grp_mb5v069lpnze",
|
|
196
|
+
"group_name": "",
|
|
197
|
+
"hidden": false,
|
|
198
|
+
"id": "gpt-6.1-terra",
|
|
199
|
+
"name": "gpt-6.1-terra",
|
|
200
|
+
"recommended": false
|
|
192
201
|
}
|
|
193
202
|
],
|
|
194
203
|
"gemini": [
|
|
@@ -248,7 +257,7 @@
|
|
|
248
257
|
},
|
|
249
258
|
{
|
|
250
259
|
"description": "约 208 token/秒 | 高吞吐 | 多语言 | 编码",
|
|
251
|
-
"group": "
|
|
260
|
+
"group": "grp_z5khwusxuh2j",
|
|
252
261
|
"group_name": "",
|
|
253
262
|
"hidden": false,
|
|
254
263
|
"id": "gemini-3.6-flash",
|
package/dist/commands/refresh.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"chalk";import{refreshClientConfig as e}from"../lib/client-config-sync.js";import{i18n as r}from"../lib/i18n.js";import{lastModelRefreshOutcome as s,runModelRefresh as t}from"../lib/model-refresh.js";import{runPendingElevations as i}from"../lib/post-apply.js";import{listAdapters as l}from"../lib/tools/registry.js";export async function refreshCommand(){const n=await e({force:!0}),c=n.source?r.t(`refresh.source.${n.source}`):r.t("refresh.source.none");console.log(o.gray(r.t("refresh.config",{source:c,revision:n.revision||"-"}))+(n.problem?o.yellow(` ${r.t("refresh.problem",{problem:n.problem})}`):""));const f=await t(["refresh"],{force:!0,output:o=>console.log(o)});if(await i(l().map(o=>o.name)),f.length>0)return;const{checked:m,failed:p}=s();0===m&&0===p?console.log(o.gray(r.t("refresh.nothing_checked"))):0===p&&console.log(o.green(r.t("refresh.up_to_date")))}
|
package/dist/lib/post-apply.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"chalk";import t from"inquirer";import{i18n as
|
|
1
|
+
import o from"chalk";import t from"inquirer";import{i18n as n}from"./i18n.js";import{hasExplicitYes as e,isNonInteractive as i,shouldAutoConfirm as r}from"./runtime-options.js";import{toolManager as s}from"./tool-manager.js";import{getAdapter as l}from"./tools/registry.js";import{upgradeTool as a}from"./tool-upgrade.js";import{logger as p}from"../utils/logger.js";async function c(o){const{ok:n}=await t.prompt([{type:"confirm",name:"ok",message:o,default:!0}]);return n}export async function runPendingElevations(t){const e=!i()&&process.stdin.isTTY;for(const i of t){const t=l(i)?.pendingElevation?.();if(!t)continue;if(!(r()||e&&await c(t.prompt)))continue;const s=l(i)?.displayName??i;console.log(o.gray(" "+n.t("setup.elevation_running"))),console.log(t.run()?o.green(" √ "+n.t("setup.elevation_done",{tool:s})):o.yellow(" ! "+n.t("setup.elevation_failed",{tool:s})))}}export async function postApplyPrompts(t){for(const n of t){const t=await(l(n)?.prepareRuntime?.())??[];for(const n of t)console.log("action"===n.kind?o.yellow(" ! "+n.text):o.green(" √ "+n.text))}await runPendingElevations(t);const r=!i()&&process.stdin.isTTY;for(const n of t){let t;try{t=await(l(n)?.followUp?.())}catch(o){p.logError(`postApplyPrompts.followUp(${n})`,o);continue}if(!t)continue;const i=e();if("run"in t&&(i||r))if(i||await c(t.prompt))for(const n of await t.run())console.log("action"===n.kind?o.yellow(" ! "+n.text):o.green(" √ "+n.text));else t.decline();else console.log(o.yellow(" ! "+t.hint))}if(!r)return;const f=t.filter(o=>l(o)?.installSpec&&s.outdatedVersion(o));if(f.length>0){const o=f.map(o=>l(o)?.displayName??o).join("、");if(await c(n.t("setup.offer_upgrade",{tools:o})))for(const o of f)await a(o)}for(const e of t){const t=l(e);if(!t?.runningApp?.isRunning())continue;if(!await c(n.t("setup.offer_restart",{tool:t.displayName})))continue;const i=t.runningApp.restart();console.log(i?o.green(" √ "+n.t("setup.restarted",{tool:t.displayName})):o.yellow(" ! "+n.t("setup.restart_failed",{tool:t.displayName})))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as e,existsSync as t,mkdirSync as o,readdirSync as n,readFileSync as r,rmSync as s}from"fs";import{dirname as i}from"path";import{join as a}from"path";import{randomUUID as l}from"crypto";import{execFileSync as c}from"child_process";import{userInfo as d}from"os";import p from"chalk";import{logger as u}from"../../utils/logger.js";import{track as f}from"../telemetry.js";import{ensureDesktopCli as m}from"./claude-desktop-cli.js";import{i18n as g}from"../i18n.js";import{BRAND_NAME as y,brand as h,brandEnv as k,CLI_NAME as _}from"../brand.js";import{backupBeforeWrite as D,atomicWriteFile as b}from"./backup.js";import{toolHome as A}from"./types.js";import{canRestartDesktop as C,isDesktopRunning as w,restartDesktop as E,WINDOWS_PACKAGE_FAMILIES as M}from"./desktop-process.js";import{setUserRegistryElevated as v}from"./elevated-reg.js";import{UserActionNeeded as O}from"./types.js";import{baseModelId as x,isClaudeModel as S}from"../model-catalog.js";import{getDefaultModels as P}from"../model-registry.js";import{claudeFormat as j,nestedClaudeProjectFiles as L}from"../sessions/formats.js";const I=y;export const CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING="hide_official_login";export const CLAUDE_DESKTOP_FORCE_REGISTRY_SETTING="force_registry";const T=/^[a-f0-9-]{36}$/;function $(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}export function claudeDesktopUserDataDir(){const e=process.env.CLAUDE_USER_DATA_DIR?.trim();if(e)return e;const o=A(),n=Boolean(k("TEST_HOME")?.trim());switch(process.platform){case"darwin":return a(o,"Library","Application Support","Claude-3p");case"win32":{const e=!n&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:a(o,"AppData","Local");return M.map(t=>a(e,"Packages",t,"LocalCache","Local","Claude-3p")).find(e=>t(e))??a(e,"Claude-3p")}default:{const e=!n&&process.env.XDG_CONFIG_HOME?process.env.XDG_CONFIG_HOME:a(o,".config");return a(e,"Claude-3p")}}}const R=()=>a(claudeDesktopUserDataDir(),"configLibrary"),G=()=>a(R(),"_meta.json"),N=e=>a(R(),`${e}.json`),U=()=>a(claudeDesktopUserDataDir(),"claude_desktop_config.json");function K(e){if(!t(e))return null;const o=r(e,"utf-8");if(!o.trim())return null;try{const e=JSON.parse(o);return $(e)?e:null}catch(t){throw new Error(`Existing ${e} cannot be parsed; back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}}function F(n,r){const s=i(n);t(s)||o(s,{recursive:!0,mode:448}),D(n),b(n,JSON.stringify(r,null,2)+"\n");try{e(n,384)}catch(e){u.logError("claude-desktop.writeJson.chmod",e)}}function H(){const e=K(G());if(!e)return null;const t=Array.isArray(e.entries)?e.entries.filter(e=>$(e)&&"string"==typeof e.id&&"string"==typeof e.name):[];return{...e,appliedId:"string"==typeof e.appliedId?e.appliedId:"",entries:t}}function B(e){return e?.entries.find(e=>e.name===I&&T.test(e.id))}const V={opus:0,fable:1,sonnet:2,haiku:3};function W(e){let t=/^claude-(opus|sonnet|haiku|fable)-(\d+(?:-\d+)*)/i.exec(e);return t?{family:t[1].toLowerCase(),version:t[2].split("-").map(Number)}:(t=/^claude-(\d+(?:-\d+)*)-(opus|sonnet|haiku)/i.exec(e),t?{family:t[2].toLowerCase(),version:t[1].split("-").map(Number)}:null)}export function humanizeModelId(e){const t=W(e);return t?`${t.family[0].toUpperCase()+t.family.slice(1)} ${t.version.filter(e=>e<1e7).slice(0,2).join(".")}`:e}function J(e){return W(e)?.family}export function buildInferenceModels(e,t){const{primary:o,bySlot:n}=function(e){const t=["opus","sonnet","haiku","reasoning"].map(t=>x(e[t]||"")).filter(Boolean);return{primary:t[0]??"",bySlot:t}}(e),r=new Set,s=t?.labels??{};let i;if(t&&t.models.some(S)){i=[...new Set(t.models.filter(S).map(x))];for(const e of t.oneMillion)r.add(e)}else{i=[];for(const t of["opus","sonnet","haiku","reasoning"]){const o=(e[t]||"").trim(),n=x(o);n&&(i.includes(n)||i.push(n),/\[1m\]/i.test(o)&&r.add(n))}}const a=e=>V[J(e)??""]??9;i.sort((e,t)=>{if(e===o)return-1;if(t===o)return 1;const n=a(e)-a(t);if(0!==n)return n;const r=W(e),s=W(t);return r&&s?function(e,t){const o=Math.max(e.length,t.length);for(let n=0;n<o;n++){const o=(t[n]??0)-(e[n]??0);if(0!==o)return o}return 0}(r.version,s.version):e.localeCompare(t)});const l=new Set,c=new Map,d=new Set(Object.values(P()).map(e=>x(e||"")));for(const e of n){const t=J(e);t&&i.includes(e)&&!d.has(e)&&!c.has(t)&&c.set(t,e)}return i.map(e=>{const t=J(e),o={name:e,labelOverride:s[e]||humanizeModelId(e)};if(r.has(e)&&(o.supports1m=!0,o.prefer1m=!0),t){o.anthropicFamilyTier=t;const n=c.get(t);n&&n!==e||l.has(t)||(o.isFamilyDefault=!0,l.add(t))}return o})}let z=null,Z=null,q=null,X=null,Y=null;function Q(e){return{inferenceProvider:"gateway",inferenceCredentialKind:"static",inferenceGatewayBaseUrl:(e.baseUrl||"").trim().replace(/\/+$/,""),inferenceGatewayApiKey:e.apiKey,inferenceModels:buildInferenceModels(e.models,e.catalog),disableDeploymentModeChooser:!1!==e.settings?.hide_official_login,chatTabEnabled:!0,chatAdvancedFileAnalysisEnabled:!0,autoModeEnabled:!0,coworkEgressAllowedHosts:["*"],disableEssentialTelemetry:!0,disableNonessentialTelemetry:!0,disableNonessentialServices:!1}}const ee={defaultModelEffort:"medium",modelPrefer1mContext:!0,skipWebFetchPreflight:!0,toolSearchEnabled:!0,builtinBrowserEnabled:!0,isDesktopExtensionEnabled:!0,sshHostAllowlist:["*"],claudeAiImport:{enabled:!0,automatic3pImport:!0,exportEnabled:!0},coworkVmIpv6Enabled:!0,mcpToolTimeoutSec:3600,updateViaUpdatesHost:!0,banner:{enabled:!1}};function te(e){return Object.fromEntries(Object.entries(ee).filter(([t])=>!e(t)))}const oe="SOFTWARE\\Policies\\Claude",ne=`HKCU\\${oe}`,re="HKLM\\SOFTWARE\\Policies\\Claude",se=`${_}-claude-policy.reg`,ie=e=>c("reg",e,{stdio:["ignore","pipe","pipe"]}).toString();let ae=ie;export function setRegRunnerForTests(e){ae=e??ie}function le(){return"win32"===process.platform}function ce(e){let t;try{t=ae(["query",e])}catch{return null}const o=new Map;for(const e of t.split(/\r?\n/)){const t=/^\s{2,}(\S+)\s+(REG_[A-Z_]+)\s*(.*)$/.exec(e);t&&o.set(t[1],t[3])}return o}function de(){if(null===ce(ne))return;const e=a(claudeDesktopUserDataDir(),se);try{t(i(e))||o(i(e),{recursive:!0,mode:448}),D(e),ae(["export",ne,e,"/y"])}catch(e){u.logError("claude-desktop.snapshotPolicy",e)}}function pe(e){de();for(const[t,o]of Object.entries(e)){const[e,n]="boolean"==typeof o?["REG_DWORD",o?"1":"0"]:"number"==typeof o?["REG_DWORD",String(o)]:"string"==typeof o?["REG_SZ",o]:["REG_SZ",JSON.stringify(o)];ae(["add",ne,"/v",t,"/t",e,"/d",n,"/f"])}}function ue(e){const t=ce(ne);if(!t)return;de();let o=t.size;for(const n of e)t.has(n)&&(ae(["delete",ne,"/v",n,"/f"]),o-=1);o<=0&&ae(["delete",ne,"/f"])}const fe=[...Object.keys(Q({apiKey:"",baseUrl:"",models:{haiku:"",sonnet:"",opus:"",reasoning:""}})),...Object.keys(ee)];export function detectManagedConfig(){try{if("darwin"===process.platform){let e="";try{e=d().username}catch{}return[e?`/Library/Managed Preferences/${e}/com.anthropic.claudefordesktop.plist`:"","/Library/Managed Preferences/com.anthropic.claudefordesktop.plist"].filter(Boolean).find(e=>t(e))??null}if("win32"===process.platform)return ce(re)?re:null;const e="/etc/claude-desktop/managed-settings.json";return t(e)?e:null}catch(e){return u.logError("claude-desktop.detectManagedConfig",e),null}}function me(){const e=A();let o;switch(process.platform){case"darwin":o=["/Applications/Claude.app",a(e,"Applications","Claude.app")];break;case"win32":{const t=process.env.LOCALAPPDATA||a(e,"AppData","Local");o=[a(t,"AnthropicClaude"),a(t,"Programs","Claude"),...M.map(e=>a(t,"Packages",e))];break}default:o=["/usr/lib/claude-desktop","/opt/Claude","/usr/bin/claude-desktop",a(e,".local","bin","claude-desktop")]}return o.push(claudeDesktopUserDataDir(),a(claudeDesktopUserDataDir(),"..","Claude")),o.some(e=>t(e))}const ge=/\d+\.\d+\.\d+/;function ye(e){const t=e=>e.split(".").map(Number);return e.sort((e,o)=>{const[n,r]=[t(e),t(o)];for(let e=0;e<3;e++)if(n[e]!==r[e])return r[e]-n[e];return 0})[0]??null}function he(){if("darwin"===process.platform){for(const e of["/Applications/Claude.app",a(A(),"Applications","Claude.app")]){const o=a(e,"Contents","Info.plist");if(!t(o))continue;const n=/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/.exec(r(o,"utf-8")),s=n?ge.exec(n[1])?.[0]:void 0;if(s)return s}return null}if("win32"===process.platform){const e=a(process.env.LOCALAPPDATA||a(A(),"AppData","Local"),"AnthropicClaude");if(t(e)){const t=n(e).map(e=>/^app-(\d+\.\d+\.\d+)$/.exec(e)?.[1]).filter(e=>!!e);if(t.length>0)return ye(t)}const o=M.map(e=>`'${e}'`).join(",");return ye(c("powershell.exe",["-NoProfile","-Command",`Get-AppxPackage | Where-Object { @(${o}) -contains $_.PackageFamilyName } | ForEach-Object { $_.Version.ToString() }`],{encoding:"utf-8",timeout:15e3,windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).flatMap(e=>ge.exec(e)?.[0]??[]))}if("linux"===process.platform)try{const e=c("dpkg-query",["-W","-f=${Version}","claude-desktop"],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});return ge.exec(e)?.[0]??null}catch{return null}return null}const ke="darwin"===process.platform?"open -a Claude":"win32"===process.platform?"Claude":"claude-desktop",_e="darwin"!==process.platform&&"win32"!==process.platform||!h().installMirror?.claudeDesktop?"https://claude.ai/download":h().installMirror.claudeDesktop,De="darwin"===process.platform?`open ${_e}`:"win32"===process.platform?`start ${_e}`:`xdg-open ${_e}`;export const claudeDesktopAdapter={name:"claude-desktop",displayName:"Claude Desktop",command:ke,installCommand:De,configPath:G(),sessions:{format:j,files:()=>L(a(claudeDesktopUserDataDir(),"local-agent-mode-sessions"))},isInstalled:me,installedVersion:he,prepareRuntime:async function(){if(!["win32","darwin","linux"].includes(process.platform)||!me())return[];const e=Date.now();try{const t=await m({userDataDir:claudeDesktopUserDataDir(),onDownload:e=>console.log(p.gray(" "+g.t("tools.claude_desktop.code_cli_downloading",{version:e}))),desktopVersion:"darwin"===process.platform?he():null,mirrorRepo:h().installMirror?.claudeDesktop?.replace(/\/-\/releases\/latest\/?$/,"")??null});return f("desktop-code-cli","skipped"===t.status?"skip":"ok",{duration_ms:Date.now()-e,detail:{...t}}),"installed"!==t.status?[]:[{kind:"summary",text:g.t("tools.claude_desktop.code_cli_installed",{version:t.version})}]}catch(t){return u.logError("claude-desktop.prepareCodeTabCli",t),f("desktop-code-cli","fail",{duration_ms:Date.now()-e,error:t}),[{kind:"action",text:g.t("tools.claude_desktop.code_cli_failed",{reason:t instanceof Error?t.message:String(t)})}]}},runningApp:C()?{isRunning:w,restart:E}:void 0,wantsModelCatalog:!0,loadPrivateConfig(e){const o=H()??{appliedId:"",entries:[]};let n=B(o);n||(n={id:l(),name:I},o.entries.push(n));const r=Q(e);Z=!0===r.disableDeploymentModeChooser,z={models:r.inferenceModels,source:e.catalog?e.catalog.oneMillionSource:"slots",groups:e.catalog?.matchedGroups??[]};const s=K(N(n.id))??{};F(N(n.id),{...te(e=>e in s),...s,...r}),o.appliedId=n.id,F(G(),o);const i=K(U())??{};if("3p"!==i.deploymentMode&&F(U(),{...i,deploymentMode:"3p"}),X=null,Y=null,q=null,le()){const o=ce(ne),n=fe.filter(e=>o?.has(e)),s={...te(e=>o?.has(e)??!1),...r},i=!0===e.settings?.force_registry,l=!i&&function(){const e=!Boolean(k("TEST_HOME")?.trim())&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:a(A(),"AppData","Local");return!!t(a(e,"AnthropicClaude"))||M.some(o=>t(a(e,"Packages",o,"LocalCache","Local","Claude-3p")))}();try{l?ue(fe):pe(s),q=l?"removed":"written"}catch(e){u.logError("claude-desktop.policy",e),X=e instanceof Error?e.message.trim():String(e),(n.length>0||i)&&(Y=l?{action:"remove",values:Object.fromEntries(n.map(e=>[e,null])),deleteKey:n.length===o.size}:{action:"write",values:s,deleteKey:!1})}}},pendingElevation(){const e=Y;return e?{prompt:g.t(`tools.claude_desktop.elevate_${e.action}`),run:()=>{if(!v(oe,e.values,e.deleteKey))return!1;const t=ce(ne),o="remove"===e.action?Object.keys(e.values).every(e=>!t?.has(e)):Object.keys(e.values).every(e=>t?.has(e));return o&&(Y=null,X=null),o}}:null},unloadPrivateConfig(){if(le())try{ue(fe)}catch(e){u.logError("claude-desktop.removePolicy",e)}const e=H(),t=B(e);if(!e||!t)return;D(N(t.id)),s(N(t.id),{force:!0});const o=e.entries.filter(e=>e.id!==t.id);0===o.length?(D(G()),s(G(),{force:!0})):F(G(),{...e,entries:o,appliedId:e.appliedId===t.id?o[0].id:e.appliedId})},listedModels(){const e=H(),t=B(e);if(!t||e?.appliedId!==t.id)return null;const o=K(N(t.id))?.inferenceModels;return Array.isArray(o)?o.map(e=>String(e.name)):null},refreshModelMenu(e){const t=H(),o=B(t);if(!o||t?.appliedId!==o.id)return;const n=K(N(o.id));if(!n)return;const r=buildInferenceModels(e.models,e.catalog);if(JSON.stringify(n.inferenceModels)!==JSON.stringify(r)){if(le()&&ce(ne)?.has("inferenceModels"))try{pe({inferenceModels:r})}catch(e){throw u.logError("claude-desktop.refreshModelMenu registry",e),new O(g.t("tools.claude_desktop.refresh_needs_admin"))}F(N(o.id),{...n,inferenceModels:r})}},detectCurrentConfig(){try{if(le()){const e=ce(ne)?.get("inferenceGatewayApiKey");if(e)return{apiKey:e}}const e=B(H());if(!e)return{apiKey:null};const t=K(N(e.id)),o=t?.inferenceGatewayApiKey;return{apiKey:"string"==typeof o&&o?o:null}}catch(e){return u.logError("claude-desktop.detectCurrentConfig",e),{apiKey:null}}},getConfig(){try{const e=H(),t=B(e);return{meta:e,applied:t?K(N(t.id)):null,desktop:K(U()),...le()?{policy:Object.fromEntries(ce(ne)??[])}:{}}}catch(e){return u.logError("claude-desktop.getConfig",e),null}},clearPinnedModels(){let e=!1;le()&&ce(ne)?.has("inferenceModels")&&(de(),ae(["delete",ne,"/v","inferenceModels","/f"]),e=!0);const t=B(H()),o=t?K(N(t.id)):null;if(t&&o&&void 0!==o.inferenceModels){const{inferenceModels:n,...r}=o;F(N(t.id),r),e=!0}return e?["inferenceModels"]:[]},applyNotes(){const e=[];if(z&&z.models.length>0){const{models:t,source:o,groups:n}=z;e.push({kind:"summary",text:g.t("tools.claude_desktop.models_summary",{count:String(t.length),default:t[0].labelOverride??t[0].name})}),e.push({kind:"detail",text:g.t(`tools.claude_desktop.models_written_${o}`,{count:String(t.length),list:t.map(e=>`${e.labelOverride}${e.supports1m?" (1M)":""}`).join(", "),groups:n.join(" / ")})})}null!==Z&&e.push({kind:"detail",text:g.t(Z?"tools.claude_desktop.official_login_hidden":"tools.claude_desktop.official_login_shown")}),C()&&!w()||e.push({kind:"action",text:g.t("tools.claude_desktop.restart_hint")}),Y?(e.push({kind:"action",text:g.t(`tools.claude_desktop.policy_stale_${Y.action}`)}),e.push({kind:"detail",text:X??""})):X?(e.push({kind:"detail",text:g.t("tools.claude_desktop.registry_denied")}),e.push({kind:"detail",text:X})):le()&&q&&e.push({kind:"detail",text:g.t(`tools.claude_desktop.registry_${q}`,{key:ne})});const t=detectManagedConfig();return t&&e.push({kind:"action",text:g.t("tools.claude_desktop.managed_conflict",{path:t})}),e},forceResetPaths(){const e=[G(),U()];try{const t=B(H());t&&e.push(N(t.id))}catch{}return e},backupPaths(){const e=[G(),U()];le()&&e.push(a(claudeDesktopUserDataDir(),se));try{const t=B(H());t&&e.push(N(t.id))}catch{}return e}};
|
|
1
|
+
import{chmodSync as e,existsSync as t,mkdirSync as o,readdirSync as n,readFileSync as r,rmSync as s}from"fs";import{dirname as i}from"path";import{join as l}from"path";import{randomUUID as a}from"crypto";import{execFileSync as c}from"child_process";import{userInfo as d}from"os";import p from"chalk";import{logger as u}from"../../utils/logger.js";import{track as f}from"../telemetry.js";import{ensureDesktopCli as m}from"./claude-desktop-cli.js";import{i18n as g}from"../i18n.js";import{BRAND_NAME as y,brand as h,brandEnv as k,CLI_NAME as _}from"../brand.js";import{backupBeforeWrite as b,atomicWriteFile as D}from"./backup.js";import{toolHome as A}from"./types.js";import{canRestartDesktop as C,isDesktopRunning as w,restartDesktop as E,WINDOWS_PACKAGE_FAMILIES as v}from"./desktop-process.js";import{setUserRegistryElevated as M}from"./elevated-reg.js";import{UserActionNeeded as O}from"./types.js";import{baseModelId as x,isClaudeModel as S}from"../model-catalog.js";import{getDefaultModels as P}from"../model-registry.js";import{claudeFormat as j,nestedClaudeProjectFiles as L}from"../sessions/formats.js";const I=y;export const CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING="hide_official_login";export const CLAUDE_DESKTOP_FORCE_REGISTRY_SETTING="force_registry";const T=/^[a-f0-9-]{36}$/;function $(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}export function claudeDesktopUserDataDir(){const e=process.env.CLAUDE_USER_DATA_DIR?.trim();if(e)return e;const o=A(),n=Boolean(k("TEST_HOME")?.trim());switch(process.platform){case"darwin":return l(o,"Library","Application Support","Claude-3p");case"win32":{const e=!n&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:l(o,"AppData","Local");return v.map(t=>l(e,"Packages",t,"LocalCache","Local","Claude-3p")).find(e=>t(e))??l(e,"Claude-3p")}default:{const e=!n&&process.env.XDG_CONFIG_HOME?process.env.XDG_CONFIG_HOME:l(o,".config");return l(e,"Claude-3p")}}}const R=()=>l(claudeDesktopUserDataDir(),"configLibrary"),G=()=>l(R(),"_meta.json"),K=e=>l(R(),`${e}.json`),N=()=>l(claudeDesktopUserDataDir(),"claude_desktop_config.json");function U(e){if(!t(e))return null;const o=r(e,"utf-8");if(!o.trim())return null;try{const e=JSON.parse(o);return $(e)?e:null}catch(t){throw new Error(`Existing ${e} cannot be parsed; back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}}function F(n,r){const s=i(n);t(s)||o(s,{recursive:!0,mode:448}),b(n),D(n,JSON.stringify(r,null,2)+"\n");try{e(n,384)}catch(e){u.logError("claude-desktop.writeJson.chmod",e)}}function H(){const e=U(G());if(!e)return null;const t=Array.isArray(e.entries)?e.entries.filter(e=>$(e)&&"string"==typeof e.id&&"string"==typeof e.name):[];return{...e,appliedId:"string"==typeof e.appliedId?e.appliedId:"",entries:t}}function B(e){return e?.entries.find(e=>e.name===I&&T.test(e.id))}const V={opus:0,fable:1,sonnet:2,haiku:3};function W(e){let t=/^claude-(opus|sonnet|haiku|fable)-(\d+(?:-\d+)*)/i.exec(e);return t?{family:t[1].toLowerCase(),version:t[2].split("-").map(Number)}:(t=/^claude-(\d+(?:-\d+)*)-(opus|sonnet|haiku)/i.exec(e),t?{family:t[2].toLowerCase(),version:t[1].split("-").map(Number)}:null)}export function humanizeModelId(e){const t=W(e);return t?`${t.family[0].toUpperCase()+t.family.slice(1)} ${t.version.filter(e=>e<1e7).slice(0,2).join(".")}`:e}function J(e){return W(e)?.family}export function buildInferenceModels(e,t){const{primary:o,bySlot:n}=function(e){const t=["opus","sonnet","haiku","reasoning"].map(t=>x(e[t]||"")).filter(Boolean);return{primary:t[0]??"",bySlot:t}}(e),r=new Set,s=t?.labels??{};let i;if(t&&t.models.some(S)){i=[...new Set(t.models.filter(S).map(x))];for(const e of t.oneMillion)r.add(e)}else{i=[];for(const t of["opus","sonnet","haiku","reasoning"]){const o=(e[t]||"").trim(),n=x(o);n&&(i.includes(n)||i.push(n),/\[1m\]/i.test(o)&&r.add(n))}}const l=e=>V[J(e)??""]??9;i.sort((e,t)=>{if(e===o)return-1;if(t===o)return 1;const n=l(e)-l(t);if(0!==n)return n;const r=W(e),s=W(t);return r&&s?function(e,t){const o=Math.max(e.length,t.length);for(let n=0;n<o;n++){const o=(t[n]??0)-(e[n]??0);if(0!==o)return o}return 0}(r.version,s.version):e.localeCompare(t)});const a=new Set,c=new Map,d=new Set(Object.values(P()).map(e=>x(e||"")));for(const e of n){const t=J(e);t&&i.includes(e)&&!d.has(e)&&!c.has(t)&&c.set(t,e)}return i.map(e=>{const t=J(e),o={name:e,labelOverride:s[e]||humanizeModelId(e)};if(r.has(e)&&(o.supports1m=!0,o.prefer1m=!0),t){o.anthropicFamilyTier=t;const n=c.get(t);n&&n!==e||a.has(t)||(o.isFamilyDefault=!0,a.add(t))}return o})}let z=null,Z=null,q=null,X=null,Y=null;function Q(e){return{inferenceProvider:"gateway",inferenceCredentialKind:"static",inferenceGatewayBaseUrl:(e.baseUrl||"").trim().replace(/\/+$/,""),inferenceGatewayApiKey:e.apiKey,inferenceModels:buildInferenceModels(e.models,e.catalog),disableDeploymentModeChooser:!1!==e.settings?.hide_official_login,chatTabEnabled:!0,chatAdvancedFileAnalysisEnabled:!0,autoModeEnabled:!0,coworkEgressAllowedHosts:["*"],disableEssentialTelemetry:!0,disableNonessentialTelemetry:!0,disableNonessentialServices:!1}}const ee={defaultModelEffort:"medium",modelPrefer1mContext:!0,skipWebFetchPreflight:!0,toolSearchEnabled:!0,builtinBrowserEnabled:!0,isDesktopExtensionEnabled:!0,sshHostAllowlist:["*"],claudeAiImport:{enabled:!0,automatic3pImport:!0,exportEnabled:!0},coworkVmIpv6Enabled:!0,mcpToolTimeoutSec:3600,updateViaUpdatesHost:!0,banner:{enabled:!1}};function te(e){return Object.fromEntries(Object.entries(ee).filter(([t])=>!e(t)))}const oe="SOFTWARE\\Policies\\Claude",ne=`HKCU\\${oe}`,re="HKLM\\SOFTWARE\\Policies\\Claude",se=`${_}-claude-policy.reg`,ie=e=>c("reg",e,{stdio:["ignore","pipe","pipe"]}).toString();let le=ie;export function setRegRunnerForTests(e){le=e??ie}function ae(){return"win32"===process.platform}function ce(e){let t;try{t=le(["query",e])}catch{return null}const o=new Map;for(const e of t.split(/\r?\n/)){const t=/^\s{2,}(\S+)\s+(REG_[A-Z_]+)\s*(.*)$/.exec(e);t&&o.set(t[1],t[3])}return o}function de(){if(null===ce(ne))return;const e=l(claudeDesktopUserDataDir(),se);try{t(i(e))||o(i(e),{recursive:!0,mode:448}),b(e),le(["export",ne,e,"/y"])}catch(e){u.logError("claude-desktop.snapshotPolicy",e)}}function pe(e){de();for(const[t,o]of Object.entries(e)){const[e,n]="boolean"==typeof o?["REG_DWORD",o?"1":"0"]:"number"==typeof o?["REG_DWORD",String(o)]:"string"==typeof o?["REG_SZ",o]:["REG_SZ",JSON.stringify(o)];le(["add",ne,"/v",t,"/t",e,"/d",n,"/f"])}}function ue(e){const t=ce(ne);if(!t)return;de();let o=t.size;for(const n of e)t.has(n)&&(le(["delete",ne,"/v",n,"/f"]),o-=1);o<=0&&le(["delete",ne,"/f"])}function fe(){const e=!Boolean(k("TEST_HOME")?.trim())&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:l(A(),"AppData","Local");return!!t(l(e,"AnthropicClaude"))||v.some(o=>t(l(e,"Packages",o,"LocalCache","Local","Claude-3p")))}const me=[...Object.keys(Q({apiKey:"",baseUrl:"",models:{haiku:"",sonnet:"",opus:"",reasoning:""}})),...Object.keys(ee)];export function detectManagedConfig(){try{if("darwin"===process.platform){let e="";try{e=d().username}catch{}return[e?`/Library/Managed Preferences/${e}/com.anthropic.claudefordesktop.plist`:"","/Library/Managed Preferences/com.anthropic.claudefordesktop.plist"].filter(Boolean).find(e=>t(e))??null}if("win32"===process.platform)return ce(re)?re:null;const e="/etc/claude-desktop/managed-settings.json";return t(e)?e:null}catch(e){return u.logError("claude-desktop.detectManagedConfig",e),null}}function ge(){const e=A();let o;switch(process.platform){case"darwin":o=["/Applications/Claude.app",l(e,"Applications","Claude.app")];break;case"win32":{const t=process.env.LOCALAPPDATA||l(e,"AppData","Local");o=[l(t,"AnthropicClaude"),l(t,"Programs","Claude"),...v.map(e=>l(t,"Packages",e))];break}default:o=["/usr/lib/claude-desktop","/opt/Claude","/usr/bin/claude-desktop",l(e,".local","bin","claude-desktop")]}return o.push(claudeDesktopUserDataDir(),l(claudeDesktopUserDataDir(),"..","Claude")),o.some(e=>t(e))}const ye=/\d+\.\d+\.\d+/;function he(e){const t=e=>e.split(".").map(Number);return e.sort((e,o)=>{const[n,r]=[t(e),t(o)];for(let e=0;e<3;e++)if(n[e]!==r[e])return r[e]-n[e];return 0})[0]??null}function ke(){if("darwin"===process.platform){for(const e of["/Applications/Claude.app",l(A(),"Applications","Claude.app")]){const o=l(e,"Contents","Info.plist");if(!t(o))continue;const n=/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/.exec(r(o,"utf-8")),s=n?ye.exec(n[1])?.[0]:void 0;if(s)return s}return null}if("win32"===process.platform){const e=l(process.env.LOCALAPPDATA||l(A(),"AppData","Local"),"AnthropicClaude");if(t(e)){const t=n(e).map(e=>/^app-(\d+\.\d+\.\d+)$/.exec(e)?.[1]).filter(e=>!!e);if(t.length>0)return he(t)}const o=v.map(e=>`'${e}'`).join(",");return he(c("powershell.exe",["-NoProfile","-Command",`Get-AppxPackage | Where-Object { @(${o}) -contains $_.PackageFamilyName } | ForEach-Object { $_.Version.ToString() }`],{encoding:"utf-8",timeout:15e3,windowsHide:!0,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).flatMap(e=>ye.exec(e)?.[0]??[]))}if("linux"===process.platform)try{const e=c("dpkg-query",["-W","-f=${Version}","claude-desktop"],{encoding:"utf-8",timeout:5e3,stdio:["ignore","pipe","ignore"]});return ye.exec(e)?.[0]??null}catch{return null}return null}const _e="darwin"===process.platform?"open -a Claude":"win32"===process.platform?"Claude":"claude-desktop",be="darwin"!==process.platform&&"win32"!==process.platform||!h().installMirror?.claudeDesktop?"https://claude.ai/download":h().installMirror.claudeDesktop,De="darwin"===process.platform?`open ${be}`:"win32"===process.platform?`start ${be}`:`xdg-open ${be}`;export const claudeDesktopAdapter={name:"claude-desktop",displayName:"Claude Desktop",command:_e,installCommand:De,configPath:G(),sessions:{format:j,files:()=>L(l(claudeDesktopUserDataDir(),"local-agent-mode-sessions"))},isInstalled:ge,installedVersion:ke,prepareRuntime:async function(){if(!["win32","darwin","linux"].includes(process.platform)||!ge())return[];const e=Date.now();try{const t=await m({userDataDir:claudeDesktopUserDataDir(),onDownload:e=>console.log(p.gray(" "+g.t("tools.claude_desktop.code_cli_downloading",{version:e}))),desktopVersion:"darwin"===process.platform?ke():null,mirrorRepo:h().installMirror?.claudeDesktop?.replace(/\/-\/releases\/latest\/?$/,"")??null});return f("desktop-code-cli","skipped"===t.status?"skip":"ok",{duration_ms:Date.now()-e,detail:{...t}}),"installed"!==t.status?[]:[{kind:"summary",text:g.t("tools.claude_desktop.code_cli_installed",{version:t.version})}]}catch(t){return u.logError("claude-desktop.prepareCodeTabCli",t),f("desktop-code-cli","fail",{duration_ms:Date.now()-e,error:t}),[{kind:"action",text:g.t("tools.claude_desktop.code_cli_failed",{reason:t instanceof Error?t.message:String(t)})}]}},runningApp:C()?{isRunning:w,restart:E}:void 0,wantsModelCatalog:!0,loadPrivateConfig(e){const t=H()??{appliedId:"",entries:[]};let o=B(t);o||(o={id:a(),name:I},t.entries.push(o));const n=Q(e);Z=!0===n.disableDeploymentModeChooser,z={models:n.inferenceModels,source:e.catalog?e.catalog.oneMillionSource:"slots",groups:e.catalog?.matchedGroups??[]};const r=U(K(o.id))??{};F(K(o.id),{...te(e=>e in r),...r,...n}),t.appliedId=o.id,F(G(),t);const s=U(N())??{};if("3p"!==s.deploymentMode&&F(N(),{...s,deploymentMode:"3p"}),X=null,Y=null,q=null,ae()){const t=ce(ne),o=me.filter(e=>t?.has(e)),r={...te(e=>t?.has(e)??!1),...n},s=!0===e.settings?.force_registry,i=!s&&fe();try{i?ue(me):pe(r),q=i?"removed":"written"}catch(e){u.logError("claude-desktop.policy",e),X=e instanceof Error?e.message.trim():String(e),(o.length>0||s)&&(Y=i?{action:"remove",values:Object.fromEntries(o.map(e=>[e,null])),deleteKey:o.length===t.size}:{action:"write",values:r,deleteKey:!1})}}},pendingElevation(){const e=Y;return e?{prompt:g.t(`tools.claude_desktop.elevate_${e.action}`),run:()=>{if(!M(oe,e.values,e.deleteKey))return!1;const t=ce(ne),o="remove"===e.action?Object.keys(e.values).every(e=>!t?.has(e)):Object.keys(e.values).every(e=>t?.has(e));return o&&(Y=null,X=null),o}}:null},unloadPrivateConfig(){if(ae())try{ue(me)}catch(e){u.logError("claude-desktop.removePolicy",e)}const e=H(),t=B(e);if(!e||!t)return;b(K(t.id)),s(K(t.id),{force:!0});const o=e.entries.filter(e=>e.id!==t.id);0===o.length?(b(G()),s(G(),{force:!0})):F(G(),{...e,entries:o,appliedId:e.appliedId===t.id?o[0].id:e.appliedId})},listedModels(){const e=H(),t=B(e);if(!t||e?.appliedId!==t.id)return null;const o=U(K(t.id))?.inferenceModels;return Array.isArray(o)?o.map(e=>String(e.name)):null},refreshModelMenu(e){const t=H(),o=B(t);if(!o||t?.appliedId!==o.id)return;const n=U(K(o.id));if(!n)return;const r=buildInferenceModels(e.models,e.catalog),s=JSON.stringify(n.inferenceModels)!==JSON.stringify(r);Y=null;const i=ae()?ce(ne):null;if(!i?.has("inferenceModels"))return void(s&&F(K(o.id),{...n,inferenceModels:r}));const l=me.filter(e=>i.has(e)),a=!0!==e.settings?.force_registry&&fe();if(a||s){s&&F(K(o.id),{...n,inferenceModels:r});try{a?ue(me):pe({inferenceModels:r})}catch(e){throw u.logError("claude-desktop.refreshModelMenu registry",e),Y=a?{action:"remove",values:Object.fromEntries(l.map(e=>[e,null])),deleteKey:l.length===i.size}:{action:"write",values:{inferenceModels:r},deleteKey:!1},new O(g.t("tools.claude_desktop.refresh_needs_admin"))}}},detectCurrentConfig(){try{if(ae()){const e=ce(ne)?.get("inferenceGatewayApiKey");if(e)return{apiKey:e}}const e=B(H());if(!e)return{apiKey:null};const t=U(K(e.id)),o=t?.inferenceGatewayApiKey;return{apiKey:"string"==typeof o&&o?o:null}}catch(e){return u.logError("claude-desktop.detectCurrentConfig",e),{apiKey:null}}},getConfig(){try{const e=H(),t=B(e);return{meta:e,applied:t?U(K(t.id)):null,desktop:U(N()),...ae()?{policy:Object.fromEntries(ce(ne)??[])}:{}}}catch(e){return u.logError("claude-desktop.getConfig",e),null}},clearPinnedModels(){let e=!1;ae()&&ce(ne)?.has("inferenceModels")&&(de(),le(["delete",ne,"/v","inferenceModels","/f"]),e=!0);const t=B(H()),o=t?U(K(t.id)):null;if(t&&o&&void 0!==o.inferenceModels){const{inferenceModels:n,...r}=o;F(K(t.id),r),e=!0}return e?["inferenceModels"]:[]},applyNotes(){const e=[];if(z&&z.models.length>0){const{models:t,source:o,groups:n}=z;e.push({kind:"summary",text:g.t("tools.claude_desktop.models_summary",{count:String(t.length),default:t[0].labelOverride??t[0].name})}),e.push({kind:"detail",text:g.t(`tools.claude_desktop.models_written_${o}`,{count:String(t.length),list:t.map(e=>`${e.labelOverride}${e.supports1m?" (1M)":""}`).join(", "),groups:n.join(" / ")})})}null!==Z&&e.push({kind:"detail",text:g.t(Z?"tools.claude_desktop.official_login_hidden":"tools.claude_desktop.official_login_shown")}),C()&&!w()||e.push({kind:"action",text:g.t("tools.claude_desktop.restart_hint")}),Y?(e.push({kind:"action",text:g.t(`tools.claude_desktop.policy_stale_${Y.action}`)}),e.push({kind:"detail",text:X??""})):X?(e.push({kind:"detail",text:g.t("tools.claude_desktop.registry_denied")}),e.push({kind:"detail",text:X})):ae()&&q&&e.push({kind:"detail",text:g.t(`tools.claude_desktop.registry_${q}`,{key:ne})});const t=detectManagedConfig();return t&&e.push({kind:"action",text:g.t("tools.claude_desktop.managed_conflict",{path:t})}),e},forceResetPaths(){const e=[G(),N()];try{const t=B(H());t&&e.push(K(t.id))}catch{}return e},backupPaths(){const e=[G(),N()];ae()&&e.push(l(claudeDesktopUserDataDir(),se));try{const t=B(H());t&&e.push(K(t.id))}catch{}return e}};
|
package/dist/locales/en_US.json
CHANGED
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
"policy_stale_write": "Claude Desktop still uses old registry settings (most likely from the .reg file downloaded from the gateway page); writing the new config there needs one administrator confirmation",
|
|
403
403
|
"elevate_remove": "Remove the old registry settings? Windows asks for administrator confirmation once; later updates won't need it",
|
|
404
404
|
"elevate_write": "Write the new config to the registry? Windows asks for administrator confirmation once",
|
|
405
|
-
"refresh_needs_admin": "Claude Desktop's model list
|
|
405
|
+
"refresh_needs_admin": "Claude Desktop's model menu was not updated: an old model list is still in the registry, and changing it needs administrator confirmation. Run {{cli}} refresh and click Yes in the Windows prompt",
|
|
406
406
|
"registry_removed": "Removed the old values under {{key}}; Claude Desktop now reads the local config"
|
|
407
407
|
},
|
|
408
408
|
"claude_code": {
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
"policy_stale_write": "Claude Desktop 还在使用注册表里的旧配置(多半是以前从网关页面下载 .reg 写入的);把新配置写进注册表需要管理员确认一次",
|
|
403
403
|
"elevate_remove": "删除注册表里的旧配置?系统会弹出一次管理员确认,之后更新 Claude Desktop 不再需要管理员。",
|
|
404
404
|
"elevate_write": "把新配置写进注册表?系统会弹出一次管理员确认。",
|
|
405
|
-
"refresh_needs_admin": "Claude Desktop
|
|
405
|
+
"refresh_needs_admin": "Claude Desktop 的模型菜单没有更新:注册表里还留着旧的模型列表,改它需要管理员确认。运行 {{cli}} refresh,在弹出的系统窗口里点击「是」",
|
|
406
406
|
"registry_removed": "已删除注册表 {{key}} 里的旧配置,Claude Desktop 改为读取本地配置"
|
|
407
407
|
},
|
|
408
408
|
"claude_code": {
|