@vibeapi/api-helper 0.0.186 → 0.0.188
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 +278 -3
- package/dist/client-config.snapshot.json +278 -3
- package/dist/lib/auto-update.js +1 -1
- package/dist/lib/components.js +1 -1
- package/dist/lib/npm-cache.d.ts +13 -0
- package/dist/lib/npm-cache.js +1 -0
- package/dist/lib/persistent-env.d.ts +6 -0
- package/dist/lib/persistent-env.js +1 -1
- package/dist/lib/tool-upgrade.js +1 -1
- package/dist/lib/tools/antigravity.js +1 -1
- package/dist/models.json +2 -0
- package/models.json +2 -0
- package/package.json +1 -1
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"groups": [
|
|
16
16
|
"Claude 官方特供版"
|
|
17
17
|
],
|
|
18
|
-
"hint": "支持 Fable,完美缓存,只能在 Claude Code、IDE 官方插件和桌面端中使用",
|
|
18
|
+
"hint": "其他模型照常能用;Claude 支持 Fable,完美缓存,只能在 Claude Code、IDE 官方插件和桌面端中使用",
|
|
19
19
|
"id": "claude-special",
|
|
20
|
-
"label": "
|
|
20
|
+
"label": "Claude 用官方版"
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
23
|
},
|
|
@@ -810,6 +810,44 @@
|
|
|
810
810
|
"name": "Kimi K3",
|
|
811
811
|
"recommended": false
|
|
812
812
|
},
|
|
813
|
+
{
|
|
814
|
+
"capabilities": {
|
|
815
|
+
"contextWindowTokens": 1000000,
|
|
816
|
+
"functionCall": true,
|
|
817
|
+
"imageOutput": false,
|
|
818
|
+
"inputModalities": [
|
|
819
|
+
"text",
|
|
820
|
+
"image",
|
|
821
|
+
"video"
|
|
822
|
+
],
|
|
823
|
+
"maxOutput": 131072,
|
|
824
|
+
"outputModalities": [
|
|
825
|
+
"text"
|
|
826
|
+
],
|
|
827
|
+
"reasoning": true,
|
|
828
|
+
"reasoningEfforts": [
|
|
829
|
+
"none",
|
|
830
|
+
"low",
|
|
831
|
+
"high",
|
|
832
|
+
"xhigh"
|
|
833
|
+
],
|
|
834
|
+
"structuredOutput": true,
|
|
835
|
+
"video": true,
|
|
836
|
+
"vision": true
|
|
837
|
+
},
|
|
838
|
+
"context_window": 1000000,
|
|
839
|
+
"description": "100 万上下文 | 深度推理 | 视觉理解",
|
|
840
|
+
"endpoint_types": [
|
|
841
|
+
"openai"
|
|
842
|
+
],
|
|
843
|
+
"group": "",
|
|
844
|
+
"group_name": "",
|
|
845
|
+
"hidden": false,
|
|
846
|
+
"id": "qwen4-max",
|
|
847
|
+
"max_output_tokens": 131072,
|
|
848
|
+
"name": "Qwen 4 Max",
|
|
849
|
+
"recommended": false
|
|
850
|
+
},
|
|
813
851
|
{
|
|
814
852
|
"capabilities": {
|
|
815
853
|
"contextWindowTokens": 1000000,
|
|
@@ -1035,6 +1073,121 @@
|
|
|
1035
1073
|
"name": "GPT-6 Astra",
|
|
1036
1074
|
"recommended": true
|
|
1037
1075
|
},
|
|
1076
|
+
{
|
|
1077
|
+
"capabilities": {
|
|
1078
|
+
"contextWindowTokens": 1050000,
|
|
1079
|
+
"functionCall": true,
|
|
1080
|
+
"imageOutput": false,
|
|
1081
|
+
"inputModalities": [
|
|
1082
|
+
"text",
|
|
1083
|
+
"image"
|
|
1084
|
+
],
|
|
1085
|
+
"knowledgeCutoff": "2026-05-18",
|
|
1086
|
+
"maxOutput": 128000,
|
|
1087
|
+
"outputModalities": [
|
|
1088
|
+
"text"
|
|
1089
|
+
],
|
|
1090
|
+
"reasoning": true,
|
|
1091
|
+
"reasoningEfforts": [
|
|
1092
|
+
"low",
|
|
1093
|
+
"medium",
|
|
1094
|
+
"high",
|
|
1095
|
+
"xhigh",
|
|
1096
|
+
"max"
|
|
1097
|
+
],
|
|
1098
|
+
"search": true,
|
|
1099
|
+
"settings": {
|
|
1100
|
+
"disabledParams": [
|
|
1101
|
+
"temperature",
|
|
1102
|
+
"top_p",
|
|
1103
|
+
"frequency_penalty",
|
|
1104
|
+
"presence_penalty"
|
|
1105
|
+
],
|
|
1106
|
+
"extendParams": [
|
|
1107
|
+
"reasoningEffort"
|
|
1108
|
+
],
|
|
1109
|
+
"searchImpl": "internal"
|
|
1110
|
+
},
|
|
1111
|
+
"streaming": true,
|
|
1112
|
+
"structuredOutput": true,
|
|
1113
|
+
"video": false,
|
|
1114
|
+
"vision": true
|
|
1115
|
+
},
|
|
1116
|
+
"clients": {
|
|
1117
|
+
"codex": true
|
|
1118
|
+
},
|
|
1119
|
+
"context_window": 1050000,
|
|
1120
|
+
"description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 高难度编程与专业工作",
|
|
1121
|
+
"endpoint_types": [
|
|
1122
|
+
"openai",
|
|
1123
|
+
"openai-response"
|
|
1124
|
+
],
|
|
1125
|
+
"group": "",
|
|
1126
|
+
"group_name": "",
|
|
1127
|
+
"hidden": false,
|
|
1128
|
+
"id": "gpt-6.2-astra",
|
|
1129
|
+
"max_output_tokens": 128000,
|
|
1130
|
+
"name": "GPT-6.2 Astra",
|
|
1131
|
+
"recommended": false
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
"capabilities": {
|
|
1135
|
+
"contextWindowTokens": 1050000,
|
|
1136
|
+
"defaultReasoningEffort": "medium",
|
|
1137
|
+
"functionCall": true,
|
|
1138
|
+
"imageOutput": false,
|
|
1139
|
+
"inputModalities": [
|
|
1140
|
+
"text",
|
|
1141
|
+
"image"
|
|
1142
|
+
],
|
|
1143
|
+
"knowledgeCutoff": "2026-06-01",
|
|
1144
|
+
"maxOutput": 128000,
|
|
1145
|
+
"outputModalities": [
|
|
1146
|
+
"text"
|
|
1147
|
+
],
|
|
1148
|
+
"reasoning": true,
|
|
1149
|
+
"reasoningEfforts": [
|
|
1150
|
+
"low",
|
|
1151
|
+
"medium",
|
|
1152
|
+
"high",
|
|
1153
|
+
"xhigh",
|
|
1154
|
+
"max"
|
|
1155
|
+
],
|
|
1156
|
+
"search": true,
|
|
1157
|
+
"settings": {
|
|
1158
|
+
"disabledParams": [
|
|
1159
|
+
"temperature",
|
|
1160
|
+
"top_p",
|
|
1161
|
+
"frequency_penalty",
|
|
1162
|
+
"presence_penalty"
|
|
1163
|
+
],
|
|
1164
|
+
"extendParams": [
|
|
1165
|
+
"reasoningEffort"
|
|
1166
|
+
],
|
|
1167
|
+
"searchImpl": "internal"
|
|
1168
|
+
},
|
|
1169
|
+
"streaming": true,
|
|
1170
|
+
"structuredOutput": true,
|
|
1171
|
+
"video": false,
|
|
1172
|
+
"vision": true
|
|
1173
|
+
},
|
|
1174
|
+
"clients": {
|
|
1175
|
+
"codex": true
|
|
1176
|
+
},
|
|
1177
|
+
"context_window": 1050000,
|
|
1178
|
+
"description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 复杂编程与专业工作",
|
|
1179
|
+
"endpoint_types": [
|
|
1180
|
+
"openai",
|
|
1181
|
+
"openai-response"
|
|
1182
|
+
],
|
|
1183
|
+
"group": "",
|
|
1184
|
+
"group_name": "",
|
|
1185
|
+
"hidden": false,
|
|
1186
|
+
"id": "gpt-6.2-sol",
|
|
1187
|
+
"max_output_tokens": 128000,
|
|
1188
|
+
"name": "GPT-6.2 Sol",
|
|
1189
|
+
"recommended": false
|
|
1190
|
+
},
|
|
1038
1191
|
{
|
|
1039
1192
|
"capabilities": {
|
|
1040
1193
|
"contextWindowTokens": 1050000,
|
|
@@ -1641,6 +1794,44 @@
|
|
|
1641
1794
|
"name": "Kimi K3",
|
|
1642
1795
|
"recommended": false
|
|
1643
1796
|
},
|
|
1797
|
+
{
|
|
1798
|
+
"capabilities": {
|
|
1799
|
+
"contextWindowTokens": 1000000,
|
|
1800
|
+
"functionCall": true,
|
|
1801
|
+
"imageOutput": false,
|
|
1802
|
+
"inputModalities": [
|
|
1803
|
+
"text",
|
|
1804
|
+
"image",
|
|
1805
|
+
"video"
|
|
1806
|
+
],
|
|
1807
|
+
"maxOutput": 131072,
|
|
1808
|
+
"outputModalities": [
|
|
1809
|
+
"text"
|
|
1810
|
+
],
|
|
1811
|
+
"reasoning": true,
|
|
1812
|
+
"reasoningEfforts": [
|
|
1813
|
+
"none",
|
|
1814
|
+
"low",
|
|
1815
|
+
"high",
|
|
1816
|
+
"xhigh"
|
|
1817
|
+
],
|
|
1818
|
+
"structuredOutput": true,
|
|
1819
|
+
"video": true,
|
|
1820
|
+
"vision": true
|
|
1821
|
+
},
|
|
1822
|
+
"context_window": 1000000,
|
|
1823
|
+
"description": "100 万上下文 | 深度推理 | 视觉理解",
|
|
1824
|
+
"endpoint_types": [
|
|
1825
|
+
"openai"
|
|
1826
|
+
],
|
|
1827
|
+
"group": "",
|
|
1828
|
+
"group_name": "",
|
|
1829
|
+
"hidden": false,
|
|
1830
|
+
"id": "qwen4-max",
|
|
1831
|
+
"max_output_tokens": 131072,
|
|
1832
|
+
"name": "Qwen 4 Max",
|
|
1833
|
+
"recommended": false
|
|
1834
|
+
},
|
|
1644
1835
|
{
|
|
1645
1836
|
"capabilities": {
|
|
1646
1837
|
"contextWindowTokens": 1000000,
|
|
@@ -1927,6 +2118,88 @@
|
|
|
1927
2118
|
"name": "Gemini 4 Carbon",
|
|
1928
2119
|
"recommended": false
|
|
1929
2120
|
},
|
|
2121
|
+
{
|
|
2122
|
+
"capabilities": {
|
|
2123
|
+
"contextWindowTokens": 1048576,
|
|
2124
|
+
"functionCall": true,
|
|
2125
|
+
"imageOutput": false,
|
|
2126
|
+
"inputModalities": [
|
|
2127
|
+
"text",
|
|
2128
|
+
"image",
|
|
2129
|
+
"video",
|
|
2130
|
+
"audio"
|
|
2131
|
+
],
|
|
2132
|
+
"knowledgeCutoff": "2026-03-31",
|
|
2133
|
+
"maxOutput": 65536,
|
|
2134
|
+
"outputModalities": [
|
|
2135
|
+
"text"
|
|
2136
|
+
],
|
|
2137
|
+
"reasoning": true,
|
|
2138
|
+
"reasoningEfforts": [
|
|
2139
|
+
"low",
|
|
2140
|
+
"medium",
|
|
2141
|
+
"high",
|
|
2142
|
+
"xhigh"
|
|
2143
|
+
],
|
|
2144
|
+
"structuredOutput": true,
|
|
2145
|
+
"video": true,
|
|
2146
|
+
"vision": true
|
|
2147
|
+
},
|
|
2148
|
+
"context_window": 1048576,
|
|
2149
|
+
"description": "100 万上下文 | 复杂编码 | Agent 任务",
|
|
2150
|
+
"endpoint_types": [
|
|
2151
|
+
"gemini",
|
|
2152
|
+
"openai"
|
|
2153
|
+
],
|
|
2154
|
+
"group": "",
|
|
2155
|
+
"group_name": "",
|
|
2156
|
+
"hidden": false,
|
|
2157
|
+
"id": "gemini-4-neon",
|
|
2158
|
+
"max_output_tokens": 65536,
|
|
2159
|
+
"name": "Gemini 4 Neon",
|
|
2160
|
+
"recommended": false
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
"capabilities": {
|
|
2164
|
+
"contextWindowTokens": 1048576,
|
|
2165
|
+
"functionCall": true,
|
|
2166
|
+
"imageOutput": false,
|
|
2167
|
+
"inputModalities": [
|
|
2168
|
+
"text",
|
|
2169
|
+
"image",
|
|
2170
|
+
"video",
|
|
2171
|
+
"audio"
|
|
2172
|
+
],
|
|
2173
|
+
"knowledgeCutoff": "2026-03-31",
|
|
2174
|
+
"maxOutput": 65536,
|
|
2175
|
+
"outputModalities": [
|
|
2176
|
+
"text"
|
|
2177
|
+
],
|
|
2178
|
+
"reasoning": true,
|
|
2179
|
+
"reasoningEfforts": [
|
|
2180
|
+
"low",
|
|
2181
|
+
"medium",
|
|
2182
|
+
"high",
|
|
2183
|
+
"xhigh"
|
|
2184
|
+
],
|
|
2185
|
+
"structuredOutput": true,
|
|
2186
|
+
"video": true,
|
|
2187
|
+
"vision": true
|
|
2188
|
+
},
|
|
2189
|
+
"context_window": 1048576,
|
|
2190
|
+
"description": "100 万上下文 | 快速推理 | 编码与 Agent",
|
|
2191
|
+
"endpoint_types": [
|
|
2192
|
+
"gemini",
|
|
2193
|
+
"openai"
|
|
2194
|
+
],
|
|
2195
|
+
"group": "",
|
|
2196
|
+
"group_name": "",
|
|
2197
|
+
"hidden": false,
|
|
2198
|
+
"id": "gemini-4-hydrogen",
|
|
2199
|
+
"max_output_tokens": 65536,
|
|
2200
|
+
"name": "Gemini 4 Hydrogen",
|
|
2201
|
+
"recommended": false
|
|
2202
|
+
},
|
|
1930
2203
|
{
|
|
1931
2204
|
"capabilities": {
|
|
1932
2205
|
"contextWindowTokens": 1048576,
|
|
@@ -2168,7 +2441,7 @@
|
|
|
2168
2441
|
"tool": "gemini"
|
|
2169
2442
|
}
|
|
2170
2443
|
],
|
|
2171
|
-
"revision": "2026-11-
|
|
2444
|
+
"revision": "2026-11-21T07:47:09Z-11",
|
|
2172
2445
|
"schema": 1,
|
|
2173
2446
|
"tools": {
|
|
2174
2447
|
"claude": {
|
|
@@ -2189,6 +2462,8 @@
|
|
|
2189
2462
|
"agy_models": [
|
|
2190
2463
|
"gemini-4-argon",
|
|
2191
2464
|
"gemini-4-carbon-medium",
|
|
2465
|
+
"gemini-4-hydrogen",
|
|
2466
|
+
"gemini-4-neon",
|
|
2192
2467
|
"gemini-3.8-flash",
|
|
2193
2468
|
"gemini-3.7-flash",
|
|
2194
2469
|
"gemini-3.6-flash",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"groups": [
|
|
16
16
|
"Claude 官方特供版"
|
|
17
17
|
],
|
|
18
|
-
"hint": "支持 Fable,完美缓存,只能在 Claude Code、IDE 官方插件和桌面端中使用",
|
|
18
|
+
"hint": "其他模型照常能用;Claude 支持 Fable,完美缓存,只能在 Claude Code、IDE 官方插件和桌面端中使用",
|
|
19
19
|
"id": "claude-special",
|
|
20
|
-
"label": "
|
|
20
|
+
"label": "Claude 用官方版"
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
23
|
},
|
|
@@ -810,6 +810,44 @@
|
|
|
810
810
|
"name": "Kimi K3",
|
|
811
811
|
"recommended": false
|
|
812
812
|
},
|
|
813
|
+
{
|
|
814
|
+
"capabilities": {
|
|
815
|
+
"contextWindowTokens": 1000000,
|
|
816
|
+
"functionCall": true,
|
|
817
|
+
"imageOutput": false,
|
|
818
|
+
"inputModalities": [
|
|
819
|
+
"text",
|
|
820
|
+
"image",
|
|
821
|
+
"video"
|
|
822
|
+
],
|
|
823
|
+
"maxOutput": 131072,
|
|
824
|
+
"outputModalities": [
|
|
825
|
+
"text"
|
|
826
|
+
],
|
|
827
|
+
"reasoning": true,
|
|
828
|
+
"reasoningEfforts": [
|
|
829
|
+
"none",
|
|
830
|
+
"low",
|
|
831
|
+
"high",
|
|
832
|
+
"xhigh"
|
|
833
|
+
],
|
|
834
|
+
"structuredOutput": true,
|
|
835
|
+
"video": true,
|
|
836
|
+
"vision": true
|
|
837
|
+
},
|
|
838
|
+
"context_window": 1000000,
|
|
839
|
+
"description": "100 万上下文 | 深度推理 | 视觉理解",
|
|
840
|
+
"endpoint_types": [
|
|
841
|
+
"openai"
|
|
842
|
+
],
|
|
843
|
+
"group": "",
|
|
844
|
+
"group_name": "",
|
|
845
|
+
"hidden": false,
|
|
846
|
+
"id": "qwen4-max",
|
|
847
|
+
"max_output_tokens": 131072,
|
|
848
|
+
"name": "Qwen 4 Max",
|
|
849
|
+
"recommended": false
|
|
850
|
+
},
|
|
813
851
|
{
|
|
814
852
|
"capabilities": {
|
|
815
853
|
"contextWindowTokens": 1000000,
|
|
@@ -1035,6 +1073,121 @@
|
|
|
1035
1073
|
"name": "GPT-6 Astra",
|
|
1036
1074
|
"recommended": true
|
|
1037
1075
|
},
|
|
1076
|
+
{
|
|
1077
|
+
"capabilities": {
|
|
1078
|
+
"contextWindowTokens": 1050000,
|
|
1079
|
+
"functionCall": true,
|
|
1080
|
+
"imageOutput": false,
|
|
1081
|
+
"inputModalities": [
|
|
1082
|
+
"text",
|
|
1083
|
+
"image"
|
|
1084
|
+
],
|
|
1085
|
+
"knowledgeCutoff": "2026-05-18",
|
|
1086
|
+
"maxOutput": 128000,
|
|
1087
|
+
"outputModalities": [
|
|
1088
|
+
"text"
|
|
1089
|
+
],
|
|
1090
|
+
"reasoning": true,
|
|
1091
|
+
"reasoningEfforts": [
|
|
1092
|
+
"low",
|
|
1093
|
+
"medium",
|
|
1094
|
+
"high",
|
|
1095
|
+
"xhigh",
|
|
1096
|
+
"max"
|
|
1097
|
+
],
|
|
1098
|
+
"search": true,
|
|
1099
|
+
"settings": {
|
|
1100
|
+
"disabledParams": [
|
|
1101
|
+
"temperature",
|
|
1102
|
+
"top_p",
|
|
1103
|
+
"frequency_penalty",
|
|
1104
|
+
"presence_penalty"
|
|
1105
|
+
],
|
|
1106
|
+
"extendParams": [
|
|
1107
|
+
"reasoningEffort"
|
|
1108
|
+
],
|
|
1109
|
+
"searchImpl": "internal"
|
|
1110
|
+
},
|
|
1111
|
+
"streaming": true,
|
|
1112
|
+
"structuredOutput": true,
|
|
1113
|
+
"video": false,
|
|
1114
|
+
"vision": true
|
|
1115
|
+
},
|
|
1116
|
+
"clients": {
|
|
1117
|
+
"codex": true
|
|
1118
|
+
},
|
|
1119
|
+
"context_window": 1050000,
|
|
1120
|
+
"description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 高难度编程与专业工作",
|
|
1121
|
+
"endpoint_types": [
|
|
1122
|
+
"openai",
|
|
1123
|
+
"openai-response"
|
|
1124
|
+
],
|
|
1125
|
+
"group": "",
|
|
1126
|
+
"group_name": "",
|
|
1127
|
+
"hidden": false,
|
|
1128
|
+
"id": "gpt-6.2-astra",
|
|
1129
|
+
"max_output_tokens": 128000,
|
|
1130
|
+
"name": "GPT-6.2 Astra",
|
|
1131
|
+
"recommended": false
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
"capabilities": {
|
|
1135
|
+
"contextWindowTokens": 1050000,
|
|
1136
|
+
"defaultReasoningEffort": "medium",
|
|
1137
|
+
"functionCall": true,
|
|
1138
|
+
"imageOutput": false,
|
|
1139
|
+
"inputModalities": [
|
|
1140
|
+
"text",
|
|
1141
|
+
"image"
|
|
1142
|
+
],
|
|
1143
|
+
"knowledgeCutoff": "2026-06-01",
|
|
1144
|
+
"maxOutput": 128000,
|
|
1145
|
+
"outputModalities": [
|
|
1146
|
+
"text"
|
|
1147
|
+
],
|
|
1148
|
+
"reasoning": true,
|
|
1149
|
+
"reasoningEfforts": [
|
|
1150
|
+
"low",
|
|
1151
|
+
"medium",
|
|
1152
|
+
"high",
|
|
1153
|
+
"xhigh",
|
|
1154
|
+
"max"
|
|
1155
|
+
],
|
|
1156
|
+
"search": true,
|
|
1157
|
+
"settings": {
|
|
1158
|
+
"disabledParams": [
|
|
1159
|
+
"temperature",
|
|
1160
|
+
"top_p",
|
|
1161
|
+
"frequency_penalty",
|
|
1162
|
+
"presence_penalty"
|
|
1163
|
+
],
|
|
1164
|
+
"extendParams": [
|
|
1165
|
+
"reasoningEffort"
|
|
1166
|
+
],
|
|
1167
|
+
"searchImpl": "internal"
|
|
1168
|
+
},
|
|
1169
|
+
"streaming": true,
|
|
1170
|
+
"structuredOutput": true,
|
|
1171
|
+
"video": false,
|
|
1172
|
+
"vision": true
|
|
1173
|
+
},
|
|
1174
|
+
"clients": {
|
|
1175
|
+
"codex": true
|
|
1176
|
+
},
|
|
1177
|
+
"context_window": 1050000,
|
|
1178
|
+
"description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 复杂编程与专业工作",
|
|
1179
|
+
"endpoint_types": [
|
|
1180
|
+
"openai",
|
|
1181
|
+
"openai-response"
|
|
1182
|
+
],
|
|
1183
|
+
"group": "",
|
|
1184
|
+
"group_name": "",
|
|
1185
|
+
"hidden": false,
|
|
1186
|
+
"id": "gpt-6.2-sol",
|
|
1187
|
+
"max_output_tokens": 128000,
|
|
1188
|
+
"name": "GPT-6.2 Sol",
|
|
1189
|
+
"recommended": false
|
|
1190
|
+
},
|
|
1038
1191
|
{
|
|
1039
1192
|
"capabilities": {
|
|
1040
1193
|
"contextWindowTokens": 1050000,
|
|
@@ -1641,6 +1794,44 @@
|
|
|
1641
1794
|
"name": "Kimi K3",
|
|
1642
1795
|
"recommended": false
|
|
1643
1796
|
},
|
|
1797
|
+
{
|
|
1798
|
+
"capabilities": {
|
|
1799
|
+
"contextWindowTokens": 1000000,
|
|
1800
|
+
"functionCall": true,
|
|
1801
|
+
"imageOutput": false,
|
|
1802
|
+
"inputModalities": [
|
|
1803
|
+
"text",
|
|
1804
|
+
"image",
|
|
1805
|
+
"video"
|
|
1806
|
+
],
|
|
1807
|
+
"maxOutput": 131072,
|
|
1808
|
+
"outputModalities": [
|
|
1809
|
+
"text"
|
|
1810
|
+
],
|
|
1811
|
+
"reasoning": true,
|
|
1812
|
+
"reasoningEfforts": [
|
|
1813
|
+
"none",
|
|
1814
|
+
"low",
|
|
1815
|
+
"high",
|
|
1816
|
+
"xhigh"
|
|
1817
|
+
],
|
|
1818
|
+
"structuredOutput": true,
|
|
1819
|
+
"video": true,
|
|
1820
|
+
"vision": true
|
|
1821
|
+
},
|
|
1822
|
+
"context_window": 1000000,
|
|
1823
|
+
"description": "100 万上下文 | 深度推理 | 视觉理解",
|
|
1824
|
+
"endpoint_types": [
|
|
1825
|
+
"openai"
|
|
1826
|
+
],
|
|
1827
|
+
"group": "",
|
|
1828
|
+
"group_name": "",
|
|
1829
|
+
"hidden": false,
|
|
1830
|
+
"id": "qwen4-max",
|
|
1831
|
+
"max_output_tokens": 131072,
|
|
1832
|
+
"name": "Qwen 4 Max",
|
|
1833
|
+
"recommended": false
|
|
1834
|
+
},
|
|
1644
1835
|
{
|
|
1645
1836
|
"capabilities": {
|
|
1646
1837
|
"contextWindowTokens": 1000000,
|
|
@@ -1927,6 +2118,88 @@
|
|
|
1927
2118
|
"name": "Gemini 4 Carbon",
|
|
1928
2119
|
"recommended": false
|
|
1929
2120
|
},
|
|
2121
|
+
{
|
|
2122
|
+
"capabilities": {
|
|
2123
|
+
"contextWindowTokens": 1048576,
|
|
2124
|
+
"functionCall": true,
|
|
2125
|
+
"imageOutput": false,
|
|
2126
|
+
"inputModalities": [
|
|
2127
|
+
"text",
|
|
2128
|
+
"image",
|
|
2129
|
+
"video",
|
|
2130
|
+
"audio"
|
|
2131
|
+
],
|
|
2132
|
+
"knowledgeCutoff": "2026-03-31",
|
|
2133
|
+
"maxOutput": 65536,
|
|
2134
|
+
"outputModalities": [
|
|
2135
|
+
"text"
|
|
2136
|
+
],
|
|
2137
|
+
"reasoning": true,
|
|
2138
|
+
"reasoningEfforts": [
|
|
2139
|
+
"low",
|
|
2140
|
+
"medium",
|
|
2141
|
+
"high",
|
|
2142
|
+
"xhigh"
|
|
2143
|
+
],
|
|
2144
|
+
"structuredOutput": true,
|
|
2145
|
+
"video": true,
|
|
2146
|
+
"vision": true
|
|
2147
|
+
},
|
|
2148
|
+
"context_window": 1048576,
|
|
2149
|
+
"description": "100 万上下文 | 复杂编码 | Agent 任务",
|
|
2150
|
+
"endpoint_types": [
|
|
2151
|
+
"gemini",
|
|
2152
|
+
"openai"
|
|
2153
|
+
],
|
|
2154
|
+
"group": "",
|
|
2155
|
+
"group_name": "",
|
|
2156
|
+
"hidden": false,
|
|
2157
|
+
"id": "gemini-4-neon",
|
|
2158
|
+
"max_output_tokens": 65536,
|
|
2159
|
+
"name": "Gemini 4 Neon",
|
|
2160
|
+
"recommended": false
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
"capabilities": {
|
|
2164
|
+
"contextWindowTokens": 1048576,
|
|
2165
|
+
"functionCall": true,
|
|
2166
|
+
"imageOutput": false,
|
|
2167
|
+
"inputModalities": [
|
|
2168
|
+
"text",
|
|
2169
|
+
"image",
|
|
2170
|
+
"video",
|
|
2171
|
+
"audio"
|
|
2172
|
+
],
|
|
2173
|
+
"knowledgeCutoff": "2026-03-31",
|
|
2174
|
+
"maxOutput": 65536,
|
|
2175
|
+
"outputModalities": [
|
|
2176
|
+
"text"
|
|
2177
|
+
],
|
|
2178
|
+
"reasoning": true,
|
|
2179
|
+
"reasoningEfforts": [
|
|
2180
|
+
"low",
|
|
2181
|
+
"medium",
|
|
2182
|
+
"high",
|
|
2183
|
+
"xhigh"
|
|
2184
|
+
],
|
|
2185
|
+
"structuredOutput": true,
|
|
2186
|
+
"video": true,
|
|
2187
|
+
"vision": true
|
|
2188
|
+
},
|
|
2189
|
+
"context_window": 1048576,
|
|
2190
|
+
"description": "100 万上下文 | 快速推理 | 编码与 Agent",
|
|
2191
|
+
"endpoint_types": [
|
|
2192
|
+
"gemini",
|
|
2193
|
+
"openai"
|
|
2194
|
+
],
|
|
2195
|
+
"group": "",
|
|
2196
|
+
"group_name": "",
|
|
2197
|
+
"hidden": false,
|
|
2198
|
+
"id": "gemini-4-hydrogen",
|
|
2199
|
+
"max_output_tokens": 65536,
|
|
2200
|
+
"name": "Gemini 4 Hydrogen",
|
|
2201
|
+
"recommended": false
|
|
2202
|
+
},
|
|
1930
2203
|
{
|
|
1931
2204
|
"capabilities": {
|
|
1932
2205
|
"contextWindowTokens": 1048576,
|
|
@@ -2168,7 +2441,7 @@
|
|
|
2168
2441
|
"tool": "gemini"
|
|
2169
2442
|
}
|
|
2170
2443
|
],
|
|
2171
|
-
"revision": "2026-11-
|
|
2444
|
+
"revision": "2026-11-21T07:47:09Z-11",
|
|
2172
2445
|
"schema": 1,
|
|
2173
2446
|
"tools": {
|
|
2174
2447
|
"claude": {
|
|
@@ -2189,6 +2462,8 @@
|
|
|
2189
2462
|
"agy_models": [
|
|
2190
2463
|
"gemini-4-argon",
|
|
2191
2464
|
"gemini-4-carbon-medium",
|
|
2465
|
+
"gemini-4-hydrogen",
|
|
2466
|
+
"gemini-4-neon",
|
|
2192
2467
|
"gemini-3.8-flash",
|
|
2193
2468
|
"gemini-3.7-flash",
|
|
2194
2469
|
"gemini-3.6-flash",
|
package/dist/lib/auto-update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as e,copyFileSync as t,existsSync as r,lstatSync as n,mkdirSync as o,readdirSync as s,readFileSync as a,readlinkSync as i,renameSync as l,rmSync as c,symlinkSync as u,writeFileSync as p}from"fs";import{homedir as d}from"os";import{basename as m,dirname as f,join as h,sep as g}from"path";import{spawnSync as _}from"child_process";import y from"chalk";import{checkForUpdate as v,readLocalPackage as x,UPDATE_SOURCES as w}from"../commands/update.js";import{i18n as k}from"./i18n.js";import{isColorEnabled as S}from"./runtime-options.js";import{logger as b}from"../utils/logger.js";import{isHelpRequest as $}from"./cli-help.js";import{brand as I,brandEnvName as
|
|
1
|
+
import{chmodSync as e,copyFileSync as t,existsSync as r,lstatSync as n,mkdirSync as o,readdirSync as s,readFileSync as a,readlinkSync as i,renameSync as l,rmSync as c,symlinkSync as u,writeFileSync as p}from"fs";import{homedir as d}from"os";import{basename as m,dirname as f,join as h,sep as g}from"path";import{spawnSync as _}from"child_process";import y from"chalk";import{checkForUpdate as v,readLocalPackage as x,UPDATE_SOURCES as w}from"../commands/update.js";import{i18n as k}from"./i18n.js";import{isColorEnabled as S}from"./runtime-options.js";import{logger as b}from"../utils/logger.js";import{isHelpRequest as $}from"./cli-help.js";import{brand as I,brandEnvName as j}from"./brand.js";import{flushTelemetry as E,track as P}from"./telemetry.js";import{processAlive as N}from"../utils/process-alive.js";import{endedByInterrupt as A}from"./signals.js";import{npmCacheArgs as T}from"./npm-cache.js";export const INSTALL_RETRY_INTERVAL_MS=36e5;export const INSTALL_TIMEOUT_MS=45e3;function R(e,t){return S()?e(t):t}export function resolveUpdateCachePath(e=process.env){const t=e[j("CONFIG_DIR")]?.trim();if(t)return h(t,"update-state.json");const r=e[j("TEST_HOME")]?.trim();return h(r||d(),I().configDirName,"update-state.json")}export function isGlobalPackageInstall(e){return e.split(g).includes("node_modules")}export function isNpxExecution(e=process.env){return"exec"===e.npm_command||"npx"===e.npm_lifecycle_event}export function isPnpmGlobalInstall(e){return e.includes(`${g}.pnpm${g}`)||e.includes(`${g}pnpm${g}global${g}`)}export function resolveNpmGlobalPrefix(e){const t=`${g}node_modules${g}`,r=e.indexOf(t);if(r<0)return null;const n=e.slice(0,r);return n.endsWith(`${g}lib`)?f(n):n}export function shouldSkipStartupUpdate(e,t=process.env){return"1"===t[j("SKIP_AUTO_UPDATE")]||"1"===t[j("DISABLE_AUTO_UPDATE")]||(!(!["--json","--non-interactive","--dry-run","--help","-h","--version","-v"].some(t=>e.includes(t))&&!$(e))||e.includes("update")||e.includes("completion"))}function U(t,r,n,s,a){try{o(f(t),{recursive:!0,mode:448});const i=`${t}.tmp-${process.pid}`,c={package_name:r,checked_at:n,latest:s.latest,source:s.source,registry:s.registry,errors:s.errors,...void 0===a?{}:{install_attempted_at:a,install_attempted_version:s.latest||void 0}};p(i,JSON.stringify(c),{encoding:"utf-8",mode:384}),l(i,t),e(t,384)}catch(e){b.warn("Failed to persist update check cache:",e)}}export function windowsShellCommand(e,t){return[e,...t.map(e=>`"${e}"`)].join(" ")}export const defaultInstallRunner=(e,t)=>{const r={stdio:"inherit",timeout:45e3,killSignal:"SIGTERM"};return"win32"===process.platform?_(windowsShellCommand(e,t),{...r,shell:!0}):_(e,t,r)};const D=(e,t)=>_(process.execPath,[process.argv[1],...e],{stdio:"inherit",env:t}),O="-update-";function C(e,t){const r=`.${t}${O}`;return s(e).filter(e=>e.startsWith(r)).map(t=>{const n=/^(old-)?(\d+)$/.exec(t.slice(r.length));return{path:h(e,t),old:Boolean(n?.[1]),pid:n?Number(n[2]):null}})}export function recoverInterruptedSwap(e){try{if(r(e)||!r(f(e)))return!1;const t=C(f(e),m(e)).filter(e=>e.old&&null!==e.pid&&!N(e.pid)).filter(e=>r(h(e.path,"package.json"))).sort((e,t)=>n(t.path).mtimeMs-n(e.path).mtimeMs);return 0!==t.length&&(M(t[0].path,e),!0)}catch(e){return b.warn("Failed to restore the package an interrupted update moved aside:",e),!1}}function M(e,t){for(let r=0;;r++)try{return void l(e,t)}catch(e){const t=e.code;if(r>=9||"EPERM"!==t&&"EACCES"!==t&&"EBUSY"!==t)throw e;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,200)}}export function swapStagedPackage(e,s,l,p,d){const g=p.split("/"),_=[h(e,"node_modules",...g),h(e,"lib","node_modules",...g)].find(e=>r(h(e,"package.json")));if(!_)return!1;const y=JSON.parse(a(h(_,"package.json"),"utf-8"));if(y.version!==d)return!1;recoverInterruptedSwap(l);const v=h(f(l),`.${m(l)}${O}old-${process.pid}`),x=r(l);x&&M(l,v);try{M(_,l)}catch(e){throw x&&M(v,l),e}c(v,{recursive:!0,force:!0,maxRetries:3});const w="string"==typeof y.bin?[g[g.length-1]]:Object.keys(y.bin||{});for(const[r,a]of[[h(e,"bin"),h(s,"bin")],[e,s]])for(const e of w.flatMap(e=>["",".cmd",".ps1"].map(t=>e+t))){const s=h(r,e),l=h(a,e),c=n(s,{throwIfNoEntry:!1});if(!n(l,{throwIfNoEntry:!1})&&c&&!c.isDirectory())try{o(a,{recursive:!0}),c.isSymbolicLink()?u(i(s),l):t(s,l)}catch(e){b.warn("Failed to restore command shim:",e)}}return!0}export async function runStartupUpdate(e,t={}){const n=t.env||process.env,o=t.localPackage||x(),s=t.globalInstall??isGlobalPackageInstall(o.root),i=t.npx??isNpxExecution(n);if(!s||i||shouldSkipStartupUpdate(e,n))return{status:"skipped",handled:!1,source:null};const l=t.now??Date.now(),u=t.cachePath||resolveUpdateCachePath(n),p=function(e,t){try{if(!r(e))return null;const n=JSON.parse(a(e,"utf-8"));return n.package_name===t.name&&Number.isFinite(n.checked_at)?n:null}catch{return null}}(u,o);let d=function(e,t,r){if(!e||e.latest)return null;const n=r-e.checked_at;if(n<0||n>=6e5)return null;const o=Array.isArray(e.errors)?e.errors:[];return{current:t.version,latest:null,up_to_date:null,source:e.source,registry:e.registry,errors:o,error:o.map(e=>`${e.source}: ${e.error}`).join("; ")||"unknown"}}(p,o,l),_=null;if(d||(d=await v({localPackage:o,fetchFn:t.fetchFn}),d.latest&&p?.install_attempted_version===d.latest&&Number.isFinite(p.install_attempted_at)&&(_=p.install_attempted_at),U(u,o.name,l,d,_??void 0)),!d.latest)return{status:"unavailable",handled:!1,source:null};if(d.up_to_date)return{status:"current",handled:!1,source:d.source};if(null!==_&&l>=_&&l-_<36e5)return{status:"update_failed",handled:!1,source:d.source};const S=t.output||console.log,b=t.errorOutput||console.error,$=t.installRunner||defaultInstallRunner,I=isPnpmGlobalInstall(o.root),M=I?"win32"===process.platform?"pnpm.cmd":"pnpm":"win32"===process.platform?"npm.cmd":"npm",F=I?null:resolveNpmGlobalPrefix(o.root),G=o.root,L=F&&G.endsWith(g+o.name.split("/").join(g))?h(f(G),`.${m(G)}${O}${process.pid}`):null;L&&(recoverInterruptedSwap(G),function(e,t){try{for(const r of C(e,t))null!==r.pid&&r.pid!==process.pid&&N(r.pid)||c(r.path,{recursive:!0,force:!0})}catch{}}(f(G),m(G))),U(u,o.name,l,d,l),S(R(y.cyan,k.t("update.auto_installing",{version:d.latest})));const B={from:o.version,to:d.latest,staged:Boolean(L)};P("self-update","start",{detail:B}),await E();const J=[...d.registry?[d.registry]:[],...w.map(e=>e.registry).filter(e=>e!==d.registry)],W=Date.now();let K=null,Y="unknown",H=0;for(const e of J){if(Date.now()-W>=45e3)break;H++;const t=$(M,I?["add","--global",`${o.name}@${d.latest}`,"--registry",e]:["install","--global",...L?["--prefix",L]:F?["--prefix",F]:[],`${o.name}@${d.latest}`,"--registry",e,"--no-audit","--no-fund","--fetch-timeout=15000","--fetch-retries=1","--fetch-retry-mintimeout=1000","--fetch-retry-maxtimeout=3000",...T(f(u))]);if(0===t.status){if(!L){K=e;break}try{if(!swapStagedPackage(L,F,G,o.name,d.latest)){Y="staged install incomplete";continue}K=e;break}catch(e){Y=e instanceof Error?e.message:String(e);break}finally{c(L,{recursive:!0,force:!0,maxRetries:3})}}else if(Y=t.error?.message||`exit ${t.status??"unknown"}`,L&&c(L,{recursive:!0,force:!0,maxRetries:3}),A(t)){Y="interrupted";break}}const V=Date.now()-W;if(P("self-update",K?"ok":V>=45e3?"timeout":"fail",{duration_ms:V,...K?{}:{error:Y},detail:{...B,attempts:H,registry:K}}),await E(),!K)return b(R(y.yellow,k.t("update.auto_failed",{error:Y}))),{status:"update_failed",handled:!1,source:d.source};S(R(y.green,k.t("update.auto_installed",{version:d.latest})));const q=(t.reexecRunner||D)(e,{...n,[j("SKIP_AUTO_UPDATE")]:"1"});return q.error?(b(R(y.yellow,k.t("update.reexec_failed",{error:q.error.message}))),{status:"update_failed",handled:!1,source:d.source}):(process.exitCode=q.status??1,P("command","skip",{duration_ms:Date.now()-W,detail:{reason:"self-update-rerun",exit_code:process.exitCode}}),{status:"reexecuted",handled:!0,source:d.source})}
|
package/dist/lib/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync as t}from"child_process";import{existsSync as e,mkdirSync as o,readFileSync as n,readdirSync as r,realpathSync as a,rmSync as s,statSync as i,writeFileSync as l}from"fs";import{delimiter as c,dirname as u,isAbsolute as p,join as d,sep as m}from"path";import{fileURLToPath as f}from"url";import g from"chalk";import{brand as h,CLI_NAME as w}from"./brand.js";import{configManager as v}from"./config.js";import{i18n as y}from"./i18n.js";import{appLatest as b,appStatus as _,appStatusWith as $,cachedAppStatus as P,getApp as x}from"./app-update.js";import{compareVersions as A}from"./model-registry.js";import{isJsonMode as k}from"./runtime-options.js";import{maskSecrets as D,track as S}from"./telemetry.js";import{failureContext as j,lastCommandExit as L,lastCommandOutput as E,runWatched as C}from"./tool-upgrade.js";import{runInstallScript as R,traceSummary as T}from"./install-script.js";import{atomicWriteFile as M}from"./tools/backup.js";import{getAdapter as N}from"./tools/registry.js";import{findInstallsIncludingNative as O,forgetInstalls as U,NPM_MIRROR as I,npmMirrorVersion as B}from"./tools/tool-installs.js";import{toolHome as F}from"./tools/types.js";import{logger as J}from"../utils/logger.js";let V=null;export function parseManifest(t){const e=JSON.parse(t);if(1!==e.schema||!Array.isArray(e.components))throw new Error("components.json: schema must be 1 with a components list");const o=new Set;for(const t of e.components){if(!t.id||!t.name||!["runtime","cli","app"].includes(t.category))throw new Error(`components.json: bad entry ${JSON.stringify(t.id)}`);for(const e of[t.id,...t.aliases??[]]){if(o.has(e))throw new Error(`components.json: duplicate name ${e}`);o.add(e)}if("runtime"===t.category&&(!t.detect||"script"!==t.install.type))throw new Error(`components.json: runtime ${t.id} needs detect + a script`);if("cli"===t.category&&!t.adapter)throw new Error(`components.json: cli ${t.id} needs an adapter`);if("app"===t.category&&!t.app)throw new Error(`components.json: app ${t.id} needs an app id`)}for(const t of e.components)for(const e of t.requires)if(!o.has(e))throw new Error(`components.json: ${t.id} requires unknown ${e}`);return e}function H(){return V||(V=parseManifest(n(function(){const t=u(f(import.meta.url)),o=[d(t,"..","..","components.json"),d(t,"..","components.json"),d(t,"components.json")],n=o.find(t=>e(t));if(!n)throw new Error(`components.json not found, searched: ${o.join(", ")}`);return n}(),"utf-8"))),V}export function setComponentManifestForTests(t){V=null===t?null:parseManifest(t)}export function listComponents(){return H().components}export function resolveComponent(t){const e=t.trim().toLowerCase();return listComponents().find(t=>t.id===e||(t.aliases??[]).includes(e))}let W=null;export function componentPlatform(){return W??process.platform}export function expandUrl(t){const e=h().installMirror??{};let o=!1;const n=t.replace(/\{(scripts|agy|devtools)\}/g,(t,n)=>{const r="devtools"===n?H().devtools:e[n];return r||(o=!0),r??""});return o?null:n}export function componentSource(t,e=componentPlatform()){return(t.sources[e]??t.sources.all??"").replace(/\{(scripts|agy|devtools)\}/g,(t,e)=>("devtools"===e?H().devtools:h().installMirror?.[e])??t)}export function installBlocker(t=process.env,e=componentPlatform()){return"win32"===e?/\\system32\\config\\systemprofile/i.test(t.USERPROFILE??"")||t.USERNAME?.endsWith("$")?"system":null:0===(G??process.getuid?.())&&t.SUDO_USER&&"root"!==t.SUDO_USER?"sudo":null}let G=null,q=!0,K=e=>{const o=/\.(cmd|bat)$/i.test(e)?t(`"${e}" --version`,{encoding:"utf-8",timeout:1e4,windowsHide:!0,shell:!0,stdio:["ignore","pipe","pipe"]}):t(e,["--version"],{encoding:"utf-8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return`${o.stdout??""}${o.stderr??""}`},X=()=>0===t("xcode-select",["-p"],{stdio:"ignore",timeout:1e4}).status;function Z(t){try{return a(t)}catch{return t}}function z(t,e){return"win32"===e?[`${t}.exe`,`${t}.cmd`]:[t]}export function knownRuntimePaths(t,e=componentPlatform(),o=process.env){const n=F();if("node"===t){if("win32"===e){const t=o.FNM_DIR||d(o.APPDATA||d(n,"AppData","Roaming"),"fnm");return[d(t,"aliases","default","node.exe"),d(o.LOCALAPPDATA||d(n,"AppData","Local"),"Programs","nodejs","node.exe")]}return[d(Y(e,o),"aliases","default","bin","node"),"/opt/homebrew/bin/node","/usr/local/bin/node","/usr/bin/node"]}if("uv"===t)return"win32"===e?[d(n,".local","bin","uv.exe"),d(n,".cargo","bin","uv.exe")]:[d(o.UV_INSTALL_DIR||d(n,".local","bin"),"uv"),d(n,".cargo","bin","uv"),"/opt/homebrew/bin/uv","/usr/local/bin/uv"];if("git"===t){if("win32"===e){const t=o.LOCALAPPDATA||d(n,"AppData","Local");return[d(t,"Programs","Git","cmd","git.exe"),d(o.ProgramFiles||"C:\\Program Files","Git","cmd","git.exe")]}return["/opt/homebrew/bin/git","/usr/local/bin/git","/usr/bin/git"]}return[]}function Y(t,o){if(o.FNM_DIR)return o.FNM_DIR;const n=F();if("win32"===t)return d(o.APPDATA||d(n,"AppData","Roaming"),"fnm");const r=d(n,".local","share","fnm"),a=d(n,"Library","Application Support","fnm");return"darwin"===t&&!e(r)&&e(a)?a:r}let Q=()=>{const e=e=>{const o=`${t("reg",["query",e,"/v","Path"],{encoding:"utf-8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","ignore"]}).stdout??""}`.split(/\r?\n/).find(t=>/\sREG_(EXPAND_)?SZ\s/.test(t));return o?o.replace(/^.*?REG_(EXPAND_)?SZ\s+/,""):""};return[e("HKCU\\Environment"),e("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment")].flatMap(t=>{return(e=t,e.replace(/%([^%]+)%/g,(t,e)=>process.env[e]??t)).split(";");var e}).map(t=>t.trim().replace(/^"|"$/g,"")).filter(Boolean)},tt=null;export function probeRuntime(t,e=componentPlatform()){const o=t.detect,n=new RegExp(o.pattern),r=new Set,a=[],s=o=>{if(!function(t){try{return i(t).isFile()}catch{return!1}}(o))return;if("darwin"===e&&"git"===t.id&&"/usr/bin/git"===o&&!X())return;const s=Z(o),l="win32"===e?s.toLowerCase():s;if(r.has(l))return;r.add(l);const c=n.exec(K(o));c&&a.push({path:o,version:c[1]??null})},l=(process.env.PATH??"").split("win32"===e?";":c);"win32"===e&&l.push(...tt??=st(()=>Q())??[]);for(const t of l)if(t&&p(t))for(const n of z(o.command,e))s(d(t,n));for(const o of knownRuntimePaths(t.id,e))(q||o.startsWith(F()))&&s(o);return a}export function scriptTarget(t,e=componentPlatform(),o=process.env){const n=F();return"node"===t?"win32"===e?d(Y(e,o),"aliases","default","node.exe"):d(Y(e,o),"aliases","default","bin","node"):"uv"===t?d(o.UV_INSTALL_DIR||d(n,".local","bin"),"win32"===e?"uv.exe":"uv"):"git"===t&&"win32"===e?d(o.LOCALAPPDATA||d(n,"AppData","Local"),"Programs","Git","cmd","git.exe"):null}export function runtimeManager(t,e,o=componentPlatform(),n=process.env){const r=Z(e),a=t=>"win32"===o?t.replace(/\//g,"\\").toLowerCase():t,s=a(r),i=a(e),l="win32"===o?"\\":"\\"===m?"/":m,c=t=>s.includes(a(t))||i.includes(a(t)),p=t=>s.startsWith(a(t)+l)||i.startsWith(a(t)+l),f=F(),g=/[\\/](Cellar|Caskroom|homebrew)[\\/]/i.test(r)||/^\/opt\/homebrew\//.test(e)||/^\/usr\/local\/(Cellar|opt)\//.test(r);if("node"===t)return c(`${l}fnm${l}`)||p(Y(o,n))?{by:"fnm",auto:!0}:g?{by:"brew",auto:!1,hint:"brew upgrade node"}:c(`${l}.nvm${l}`)?{by:"nvm",auto:!1,hint:"nvm install --lts --reinstall-packages-from=current"}:c(`${l}nvm${l}`)&&"win32"===o?{by:"nvm",auto:!1,hint:"nvm install lts"}:c(`${l}.volta${l}`)||c(`${l}volta${l}`)?{by:"volta",auto:!1,hint:"volta install node@lts"}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update nodejs-lts"}:c(`${l}.asdf${l}`)?{by:"asdf",auto:!1,hint:"asdf install nodejs latest"}:c(`${l}mise${l}`)?{by:"mise",auto:!1,hint:"mise use -g node@lts"}:{by:"system",auto:!1};if("uv"===t)return[n.UV_INSTALL_DIR,d(f,".local","bin"),d(f,".cargo","bin")].filter(Boolean).some(t=>a(u(e))===a(t)||a(u(r))===a(t))?{by:"standalone",auto:!0}:g?{by:"brew",auto:!1,hint:"brew upgrade uv"}:c("pipx")?{by:"pipx",auto:!1,hint:"pipx upgrade uv"}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update uv"}:c("winget")?{by:"winget",auto:!1,hint:"winget upgrade astral-sh.uv"}:c("site-packages")||c(`${l}python`)?{by:"pip",auto:!1,hint:"pip install -U uv"}:{by:"other",auto:!1};if("git"===t){if("win32"===o){const t=n.LOCALAPPDATA||d(f,"AppData","Local");return p(d(t,"Programs","Git"))?{by:"git-for-windows-user",auto:!0}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update git"}:{by:"git-for-windows",auto:!1,hint:"git update-git-for-windows"}}return g?{by:"brew",auto:!1,hint:"brew upgrade git"}:"darwin"===o?{by:"xcode",auto:!1,hint:"softwareupdate --list"}:{by:"system",auto:!1}}return{by:"other",auto:!1}}function et(){return d(v.getConfigDir(),"component-releases.json")}function ot(){try{const t=JSON.parse(n(et(),"utf-8"));return t&&"object"==typeof t?t:{}}catch{return{}}}function nt(t,e){try{o(v.getConfigDir(),{recursive:!0}),l(et(),JSON.stringify({...ot(),[t]:e},null,2))}catch(t){J.logError("components.writeCache",t)}}let rt=async(t,e=15e3)=>{const o=await fetch(t,{signal:AbortSignal.timeout(e)});if(!o.ok)throw new Error(`HTTP ${o.status} ${t}`);return o.text()};const at=/(\d+\.\d+\.\d+)/;export function latestNodeLts(t){const e=JSON.parse(t).find(t=>"string"==typeof t.lts&&t.lts&&"string"==typeof t.version);if(!e)throw new Error("no LTS release in the Node index");return e.version.replace(/^v/,"")}export function devtoolsVersion(t,e){const o=t.split(/\r?\n/).find(t=>t.startsWith(`${e}=`)),n=o?at.exec(o.slice(e.length+1)):null;if(!n)throw new Error(`${e} is not in versions.txt`);return n[1]}export async function latestVersion(t,e={}){const o=componentPlatform(),n=`${t.id}:${o}`,r=ot()[n],a=r&&Date.now()-r.checked_at<(r.version?36e5:6e5);if(r&&a&&!e.refresh)return{version:r.version??null,...r.error?{error:r.error}:{}};try{const e=await async function(t,e){const o=t.latest;switch(o.type){case"node-lts":return latestNodeLts(await rt(o.url));case"devtools":return o.platforms&&!o.platforms.includes(e)?null:devtoolsVersion(await rt(`${H().devtools}/versions.txt`),o.key);case"npm":{if(o.staleTag){const e=N(t.adapter??"")?.installSpec,o=e?await B(e):"latest";if("latest"!==o)return o}const e=JSON.parse(await rt(`${I}/${o.package}/latest`));if(!e.version)throw new Error(`no version for ${o.package}`);return e.version}case"version-file":{const t=expandUrl(o.url);if(!t)return null;const e=at.exec(await rt(t));if(!e)throw new Error(`no version in ${t}`);return e[1]}default:return null}}(t,o);return e&&nt(n,{version:e,checked_at:Date.now()}),{version:e}}catch(e){const o=e instanceof Error?e.message:String(e);return J.logError(`components.latest(${t.id})`,e),nt(n,{error:o,checked_at:Date.now()}),{version:r?.version??null,error:o}}}export async function prefetchLatest(t,e={}){const o=componentPlatform(),n=await Promise.all(t.map(async t=>t.platforms.includes(o)?"app"===t.category?[t.id,x(t.app)?await b(t.app,e):{version:null}]:[t.id,await latestVersion(t,e)]:[t.id,{version:null}]));return new Map(n)}export async function componentStatus(t,e={}){const o=componentPlatform(),n={id:t.id,name:t.name,category:t.category,supported:t.platforms.includes(o),source:componentSource(t,o)},r={...n,installed:!1,current:null,latest:null,outdated:!1,path:null,managed_by:null,auto_upgrade:!1,blocker:n.supported?installBlocker():"unsupported_platform"};if(!n.supported)return r;if("app"===t.category){const o=x(t.app);if(!o)return{...r,blocker:"unsupported_platform"};const n=e.latest?$(t.app,e.latest):e.offline?P(t.app):await _(t.app,{refresh:e.refresh});return{...r,installed:n.installed,current:n.current,latest:n.latest,outdated:n.outdated,path:n.installed?st(()=>o.appInstaller.installedPath()):null,managed_by:n.installed?"app":null,auto_upgrade:n.installed&&!n.blocker,blocker:n.blocker??installBlocker(),...n.error?{error:n.error}:{}}}let a=null,s=null,i=null;if("cli"===t.category){const e=N(t.adapter)?.installSpec,o=e?O(e)[0]:void 0;o&&(a=o.version,s=o.path,i={by:o.kind,auto:!0})}else{const e=probeRuntime(t,o)[0];e&&(a=e.version,s=e.path,i=runtimeManager(t.id,e.path,o))}const{version:l,error:c}=e.latest?e.latest:e.offline?{version:ot()[`${t.id}:${o}`]?.version??null,error:void 0}:await latestVersion(t,{refresh:e.refresh}),u=l?ot()[`${t.id}:${o}:ceiling`]:void 0,p=Boolean(u?.version&&u.error===l&&a&&A(a,u.version)>=0);return{...r,installed:Boolean(s),current:a,latest:l,outdated:Boolean(a&&l&&A(a,l)<0&&!p),...p?{capped_at:u.version}:{},path:s,managed_by:i?.by??null,auto_upgrade:i?.auto??!1,...i?.hint?{hint:i.hint}:{},...c?{error:c}:{}}}function st(t){try{return t()}catch{return null}}const it={idleMs:18e4,timeoutMs:36e5};let lt,ct=async(t,e)=>(lt=await R({name:(/([a-z0-9-]+)\.(?:ps1|sh)$/i.exec(t)?.[1]??"runtime").toLowerCase(),url:t,platform:componentPlatform(),limits:{...it,env:e},output:E,run:(t,e,o)=>C(t,e,o)}),"ok"===lt.outcome),ut=async(t,e)=>"ok"===await C(t,e,it);function pt(t){k()?process.stderr.write(t+"\n"):console.log(t)}export function globalPackages(t,e=componentPlatform()){const o=u(Z(t)),a="win32"===e?d(o,"node_modules"):d(u(o),"lib","node_modules"),s=[],i=(t,e)=>{try{const o=JSON.parse(n(d(t,"package.json"),"utf-8"));o.version&&s.push({name:e,version:o.version})}catch{}};let l=[];try{l=r(a)}catch{return s}for(const t of l)if(!t.startsWith(".")&&"npm"!==t&&"corepack"!==t)if(t.startsWith("@"))try{for(const e of r(d(a,t)))e.startsWith(".")||i(d(a,t,e),`${t}/${e}`)}catch{}else i(d(a,t),t);return s}function dt(t,e,o={}){const n=["installed","upgraded","reinstalled","up_to_date","already_installed"].includes(e);return{tool:t.id,category:t.category,current:t.current,latest:t.latest,result:e,version_after:null,ok:n,...o}}function mt(t){return`${w} upgrade ${t}`}export async function runRuntime(t,e,n={}){const r=Date.now(),a=componentPlatform(),s=await componentStatus(t,{refresh:!0}),i=t.name;if(!s.supported)return pt(g.yellow(" ! "+y.t("components.unsupported_platform",{tool:i}))),dt(s,"unavailable",{reason:"unsupported_platform"});if(s.blocker)return pt(g.yellow(" ! "+function(t,e){return y.t(`components.blocked_${t}`,{tool:e})}(s.blocker,i))),dt(s,"unavailable",{reason:s.blocker});const l=function(t){if("script"!==t.install.type)return null;const e=h().installMirror?.scripts;return e?`${e}/${t.install.script}.${"win32"===componentPlatform()?"ps1":"sh"}`:null}(t);if(s.installed&&!n.force){const o=g.gray(`(${s.path})`);if(s.latest&&!s.outdated)return pt(g.green(" √ "+y.t("components.up_to_date",{tool:i,current:s.current??"?"}))+o),"upgrade"===e&&pt(g.gray(" "+y.t("components.force_hint",{command:`${mt(t.id)} --force`}))),dt(s,"install"===e?"already_installed":"up_to_date");if("install"===e)return pt(g.green(" √ "+y.t("components.already_installed",{tool:i,current:s.current??"?"}))+o),s.outdated&&pt(g.yellow(" ! "+upgradeAdvice(s))),dt(s,"already_installed",s.outdated?{hint:upgradeAdvice(s)}:{});if(!s.latest)return pt(g.yellow(" ! "+y.t("components.no_latest",{tool:i,current:s.current??"?",how:gt(s)}))),dt(s,"manual",{reason:s.error??"no_latest",hint:s.hint});if(!s.auto_upgrade)return pt(g.yellow(" ! "+upgradeAdvice(s))),dt(s,"manual",{hint:s.hint})}if(!l)return pt(g.yellow(" ! "+y.t("components.no_mirror",{tool:i}))),dt(s,"unavailable",{reason:"no_mirror"});s.installed&&!s.auto_upgrade&&pt(g.yellow(" ! "+y.t("components.force_beside",{tool:i,path:s.path??"?",by:s.managed_by??"?"})));const p={};s.installed&&"script"===t.install.type&&Object.assign(p,t.install.forceEnv??{}),"uv"===t.id&&s.installed&&s.auto_upgrade&&s.path&&(p.UV_INSTALL_DIR=u(s.path));const d=t.upgrade?.migrateGlobalPackages&&s.installed&&"fnm"===s.managed_by&&s.path,m=d?globalPackages(s.path,a):[],f=d?Z(s.path):null;pt(g.gray(" "+y.t(s.installed?"components.upgrading":"components.installing",{tool:i,latest:s.latest??"",source:s.source}))),S(`component:${t.id}`,"start",{detail:{mode:e,force:Boolean(n.force),current:s.current}}),d&&m.length&&f&&function(t){try{o(v.getConfigDir(),{recursive:!0}),M(wt(),JSON.stringify({...t,noted_at:Date.now()},null,2),384)}catch(t){J.logError("components: note migration",t)}}({packages:m,old_node:f}),lt=void 0;const w=await ct(l,p);U(),tt=null;const b=probeRuntime(t,a),_=scriptTarget(t.id,a,{...process.env,...p}),$=(_?b.find(t=>{return e=t.path,o=_,"win32"===a?Z(e).toLowerCase()===Z(o).toLowerCase():Z(e)===Z(o);var e,o}):void 0)??b.find(e=>runtimeManager(t.id,e.path,a).auto)??b[0];if(!w||!$){vt();const e=lt;return S(`component:${t.id}`,"fail",{duration_ms:Date.now()-r,error:D(E())||void 0,detail:{reason:w?"not_found_after":"script_failed",...e?{how:e.how,...e.fileProblem?{file_problem:e.fileProblem}:{},...T(e.trace)}:{},...L(),...j()}}),pt(g.red(" × "+y.t("components.script_failed",{tool:i,command:(s.installed?mt:ft)(t.id)}))),dt(s,"failed",{reason:w?"not_found_after":"script_failed"})}let P;d&&m.length&&f&&Z($.path)!==f&&(P=await ht(m,$.path,a)?"done":"failed"),"failed"!==P&&vt();const x=b[0];x&&x.path!==$.path&&x.version&&$.version&&A(x.version,$.version)<0&&pt(g.yellow(" ! "+y.t("components.path_shadowed",{tool:i,active:x.path,version:$.version,path:$.path}))),s.latest&&$.version&&A($.version,s.latest)<0&&(nt(`${t.id}:${a}:ceiling`,{version:$.version,error:s.latest,checked_at:Date.now()}),pt(g.yellow(" ! "+y.t("components.capped",{tool:i,latest:s.latest,version:$.version})))),S(`component:${t.id}`,"ok",{duration_ms:Date.now()-r,detail:{version:$.version,...P?{migration:P}:{}}});const k=s.installed?n.force&&!s.outdated?"reinstalled":"upgraded":"installed";var C;return pt(g.green(" √ "+("installed"===k?y.t("components.installed",{tool:i,version:$.version??"?"}):"reinstalled"===k?y.t("components.reinstalled",{tool:i,version:$.version??"?"}):y.t("components.upgraded",{tool:i,from:s.current??"?",to:$.version??"?"})))+g.gray(`(${$.path})`)),C=u($.path),(process.env.PATH??"").split("win32"===componentPlatform()?";":c).some(t=>"win32"===componentPlatform()?t.toLowerCase()===C.toLowerCase():t===C)||pt(g.gray(" "+y.t("components.new_terminal"))),dt(s,k,{version_after:$.version})}function ft(t){return`${w} install ${t}`}function gt(t){return t.hint?t.hint:y.t(`components.how_${t.managed_by??"other"}`,{tool:t.name})}export function upgradeAdvice(t){return t.auto_upgrade?y.t("components.outdated_auto",{tool:t.name,current:t.current??"?",latest:t.latest??"?",command:mt(t.id)}):y.t("components.outdated_manual",{tool:t.name,current:t.current??"?",latest:t.latest??"?",by:t.managed_by??"?",how:gt(t),command:`${mt(t.id)} --force`})}async function ht(t,e,o){const n=new Set(globalPackages(e,o).map(t=>t.name)),r=t.filter(t=>!n.has(t.name));if(!r.length)return!0;pt(g.gray(" "+y.t("components.migrating_globals",{packages:r.map(t=>t.name).join("、")})));const a=function(t,e){const o=u(Z(t));return d(o,"win32"===e?"npm.cmd":"npm")}(e,o),s=["install","-g",...r.map(t=>`${t.name}@${t.version}`),`--registry=${I}`,"--no-fund","--no-audit","--loglevel=error"];return!!await ut(a,s)||(pt(g.yellow(" ! "+y.t("components.migrate_failed",{command:[a,...s].join(" ")}))),!1)}const wt=()=>d(v.getConfigDir(),"node-migration.json");function vt(){try{s(wt(),{force:!0})}catch(t){J.logError("components: clear migration",t)}}export async function resumePendingMigration(){let t;try{if(!e(wt()))return"none";t=JSON.parse(n(wt(),"utf-8"))}catch{return vt(),"none"}const o=componentPlatform(),r=listComponents().find(t=>"node"===t.id),a=r?probeRuntime(r,o).find(t=>"fnm"===runtimeManager("node",t.path,o).by):void 0;if(!Array.isArray(t.packages)||"number"!=typeof t.noted_at||Date.now()-t.noted_at>2592e6||!a||Z(a.path)===t.old_node)return vt(),"none";S("component:node","start",{detail:{mode:"resume-migration"}});const s=await ht(t.packages,a.path,o);return s&&vt(),S("component:node",s?"ok":"fail",{detail:{mode:"resume-migration",migration:s?"done":"failed"}}),s?"done":"failed"}export function setComponentDepsForTests(t){void 0!==t.platform&&(W=t.platform),void 0!==t.uid&&(G=t.uid),void 0!==t.systemPaths&&(q=t.systemPaths),t.registryPath&&(Q=t.registryPath,tt=null),t.versionRunner&&(K=t.versionRunner),t.macDeveloperTools&&(X=t.macDeveloperTools),t.fetchText&&(rt=t.fetchText),t.scriptRunner&&(ct=t.scriptRunner),t.commandRunner&&(ut=t.commandRunner)}
|
|
1
|
+
import{spawnSync as t}from"child_process";import{existsSync as e,mkdirSync as o,readFileSync as n,readdirSync as r,realpathSync as a,rmSync as s,statSync as i,writeFileSync as l}from"fs";import{delimiter as c,dirname as u,isAbsolute as p,join as d,sep as m}from"path";import{fileURLToPath as f}from"url";import g from"chalk";import{brand as h,CLI_NAME as w}from"./brand.js";import{configManager as v}from"./config.js";import{npmCacheArgs as y}from"./npm-cache.js";import{i18n as b}from"./i18n.js";import{appLatest as _,appStatus as $,appStatusWith as P,cachedAppStatus as x,getApp as A}from"./app-update.js";import{compareVersions as k}from"./model-registry.js";import{isJsonMode as D}from"./runtime-options.js";import{maskSecrets as S,track as j}from"./telemetry.js";import{failureContext as L,lastCommandExit as E,lastCommandOutput as C,runWatched as R}from"./tool-upgrade.js";import{runInstallScript as T,traceSummary as M}from"./install-script.js";import{atomicWriteFile as N}from"./tools/backup.js";import{getAdapter as O}from"./tools/registry.js";import{findInstallsIncludingNative as U,forgetInstalls as I,NPM_MIRROR as B,npmMirrorVersion as F}from"./tools/tool-installs.js";import{toolHome as J}from"./tools/types.js";import{logger as V}from"../utils/logger.js";let H=null;export function parseManifest(t){const e=JSON.parse(t);if(1!==e.schema||!Array.isArray(e.components))throw new Error("components.json: schema must be 1 with a components list");const o=new Set;for(const t of e.components){if(!t.id||!t.name||!["runtime","cli","app"].includes(t.category))throw new Error(`components.json: bad entry ${JSON.stringify(t.id)}`);for(const e of[t.id,...t.aliases??[]]){if(o.has(e))throw new Error(`components.json: duplicate name ${e}`);o.add(e)}if("runtime"===t.category&&(!t.detect||"script"!==t.install.type))throw new Error(`components.json: runtime ${t.id} needs detect + a script`);if("cli"===t.category&&!t.adapter)throw new Error(`components.json: cli ${t.id} needs an adapter`);if("app"===t.category&&!t.app)throw new Error(`components.json: app ${t.id} needs an app id`)}for(const t of e.components)for(const e of t.requires)if(!o.has(e))throw new Error(`components.json: ${t.id} requires unknown ${e}`);return e}function W(){return H||(H=parseManifest(n(function(){const t=u(f(import.meta.url)),o=[d(t,"..","..","components.json"),d(t,"..","components.json"),d(t,"components.json")],n=o.find(t=>e(t));if(!n)throw new Error(`components.json not found, searched: ${o.join(", ")}`);return n}(),"utf-8"))),H}export function setComponentManifestForTests(t){H=null===t?null:parseManifest(t)}export function listComponents(){return W().components}export function resolveComponent(t){const e=t.trim().toLowerCase();return listComponents().find(t=>t.id===e||(t.aliases??[]).includes(e))}let G=null;export function componentPlatform(){return G??process.platform}export function expandUrl(t){const e=h().installMirror??{};let o=!1;const n=t.replace(/\{(scripts|agy|devtools)\}/g,(t,n)=>{const r="devtools"===n?W().devtools:e[n];return r||(o=!0),r??""});return o?null:n}export function componentSource(t,e=componentPlatform()){return(t.sources[e]??t.sources.all??"").replace(/\{(scripts|agy|devtools)\}/g,(t,e)=>("devtools"===e?W().devtools:h().installMirror?.[e])??t)}export function installBlocker(t=process.env,e=componentPlatform()){return"win32"===e?/\\system32\\config\\systemprofile/i.test(t.USERPROFILE??"")||t.USERNAME?.endsWith("$")?"system":null:0===(q??process.getuid?.())&&t.SUDO_USER&&"root"!==t.SUDO_USER?"sudo":null}let q=null,K=!0,X=e=>{const o=/\.(cmd|bat)$/i.test(e)?t(`"${e}" --version`,{encoding:"utf-8",timeout:1e4,windowsHide:!0,shell:!0,stdio:["ignore","pipe","pipe"]}):t(e,["--version"],{encoding:"utf-8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","pipe"]});return`${o.stdout??""}${o.stderr??""}`},Z=()=>0===t("xcode-select",["-p"],{stdio:"ignore",timeout:1e4}).status;function z(t){try{return a(t)}catch{return t}}function Y(t,e){return"win32"===e?[`${t}.exe`,`${t}.cmd`]:[t]}export function knownRuntimePaths(t,e=componentPlatform(),o=process.env){const n=J();if("node"===t){if("win32"===e){const t=o.FNM_DIR||d(o.APPDATA||d(n,"AppData","Roaming"),"fnm");return[d(t,"aliases","default","node.exe"),d(o.LOCALAPPDATA||d(n,"AppData","Local"),"Programs","nodejs","node.exe")]}return[d(Q(e,o),"aliases","default","bin","node"),"/opt/homebrew/bin/node","/usr/local/bin/node","/usr/bin/node"]}if("uv"===t)return"win32"===e?[d(n,".local","bin","uv.exe"),d(n,".cargo","bin","uv.exe")]:[d(o.UV_INSTALL_DIR||d(n,".local","bin"),"uv"),d(n,".cargo","bin","uv"),"/opt/homebrew/bin/uv","/usr/local/bin/uv"];if("git"===t){if("win32"===e){const t=o.LOCALAPPDATA||d(n,"AppData","Local");return[d(t,"Programs","Git","cmd","git.exe"),d(o.ProgramFiles||"C:\\Program Files","Git","cmd","git.exe")]}return["/opt/homebrew/bin/git","/usr/local/bin/git","/usr/bin/git"]}return[]}function Q(t,o){if(o.FNM_DIR)return o.FNM_DIR;const n=J();if("win32"===t)return d(o.APPDATA||d(n,"AppData","Roaming"),"fnm");const r=d(n,".local","share","fnm"),a=d(n,"Library","Application Support","fnm");return"darwin"===t&&!e(r)&&e(a)?a:r}let tt=()=>{const e=e=>{const o=`${t("reg",["query",e,"/v","Path"],{encoding:"utf-8",timeout:1e4,windowsHide:!0,stdio:["ignore","pipe","ignore"]}).stdout??""}`.split(/\r?\n/).find(t=>/\sREG_(EXPAND_)?SZ\s/.test(t));return o?o.replace(/^.*?REG_(EXPAND_)?SZ\s+/,""):""};return[e("HKCU\\Environment"),e("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment")].flatMap(t=>{return(e=t,e.replace(/%([^%]+)%/g,(t,e)=>process.env[e]??t)).split(";");var e}).map(t=>t.trim().replace(/^"|"$/g,"")).filter(Boolean)},et=null;export function probeRuntime(t,e=componentPlatform()){const o=t.detect,n=new RegExp(o.pattern),r=new Set,a=[],s=o=>{if(!function(t){try{return i(t).isFile()}catch{return!1}}(o))return;if("darwin"===e&&"git"===t.id&&"/usr/bin/git"===o&&!Z())return;const s=z(o),l="win32"===e?s.toLowerCase():s;if(r.has(l))return;r.add(l);const c=n.exec(X(o));c&&a.push({path:o,version:c[1]??null})},l=(process.env.PATH??"").split("win32"===e?";":c);"win32"===e&&l.push(...et??=it(()=>tt())??[]);for(const t of l)if(t&&p(t))for(const n of Y(o.command,e))s(d(t,n));for(const o of knownRuntimePaths(t.id,e))(K||o.startsWith(J()))&&s(o);return a}export function scriptTarget(t,e=componentPlatform(),o=process.env){const n=J();return"node"===t?"win32"===e?d(Q(e,o),"aliases","default","node.exe"):d(Q(e,o),"aliases","default","bin","node"):"uv"===t?d(o.UV_INSTALL_DIR||d(n,".local","bin"),"win32"===e?"uv.exe":"uv"):"git"===t&&"win32"===e?d(o.LOCALAPPDATA||d(n,"AppData","Local"),"Programs","Git","cmd","git.exe"):null}export function runtimeManager(t,e,o=componentPlatform(),n=process.env){const r=z(e),a=t=>"win32"===o?t.replace(/\//g,"\\").toLowerCase():t,s=a(r),i=a(e),l="win32"===o?"\\":"\\"===m?"/":m,c=t=>s.includes(a(t))||i.includes(a(t)),p=t=>s.startsWith(a(t)+l)||i.startsWith(a(t)+l),f=J(),g=/[\\/](Cellar|Caskroom|homebrew)[\\/]/i.test(r)||/^\/opt\/homebrew\//.test(e)||/^\/usr\/local\/(Cellar|opt)\//.test(r);if("node"===t)return c(`${l}fnm${l}`)||p(Q(o,n))?{by:"fnm",auto:!0}:g?{by:"brew",auto:!1,hint:"brew upgrade node"}:c(`${l}.nvm${l}`)?{by:"nvm",auto:!1,hint:"nvm install --lts --reinstall-packages-from=current"}:c(`${l}nvm${l}`)&&"win32"===o?{by:"nvm",auto:!1,hint:"nvm install lts"}:c(`${l}.volta${l}`)||c(`${l}volta${l}`)?{by:"volta",auto:!1,hint:"volta install node@lts"}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update nodejs-lts"}:c(`${l}.asdf${l}`)?{by:"asdf",auto:!1,hint:"asdf install nodejs latest"}:c(`${l}mise${l}`)?{by:"mise",auto:!1,hint:"mise use -g node@lts"}:{by:"system",auto:!1};if("uv"===t)return[n.UV_INSTALL_DIR,d(f,".local","bin"),d(f,".cargo","bin")].filter(Boolean).some(t=>a(u(e))===a(t)||a(u(r))===a(t))?{by:"standalone",auto:!0}:g?{by:"brew",auto:!1,hint:"brew upgrade uv"}:c("pipx")?{by:"pipx",auto:!1,hint:"pipx upgrade uv"}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update uv"}:c("winget")?{by:"winget",auto:!1,hint:"winget upgrade astral-sh.uv"}:c("site-packages")||c(`${l}python`)?{by:"pip",auto:!1,hint:"pip install -U uv"}:{by:"other",auto:!1};if("git"===t){if("win32"===o){const t=n.LOCALAPPDATA||d(f,"AppData","Local");return p(d(t,"Programs","Git"))?{by:"git-for-windows-user",auto:!0}:c(`${l}scoop${l}`)?{by:"scoop",auto:!1,hint:"scoop update git"}:{by:"git-for-windows",auto:!1,hint:"git update-git-for-windows"}}return g?{by:"brew",auto:!1,hint:"brew upgrade git"}:"darwin"===o?{by:"xcode",auto:!1,hint:"softwareupdate --list"}:{by:"system",auto:!1}}return{by:"other",auto:!1}}function ot(){return d(v.getConfigDir(),"component-releases.json")}function nt(){try{const t=JSON.parse(n(ot(),"utf-8"));return t&&"object"==typeof t?t:{}}catch{return{}}}function rt(t,e){try{o(v.getConfigDir(),{recursive:!0}),l(ot(),JSON.stringify({...nt(),[t]:e},null,2))}catch(t){V.logError("components.writeCache",t)}}let at=async(t,e=15e3)=>{const o=await fetch(t,{signal:AbortSignal.timeout(e)});if(!o.ok)throw new Error(`HTTP ${o.status} ${t}`);return o.text()};const st=/(\d+\.\d+\.\d+)/;export function latestNodeLts(t){const e=JSON.parse(t).find(t=>"string"==typeof t.lts&&t.lts&&"string"==typeof t.version);if(!e)throw new Error("no LTS release in the Node index");return e.version.replace(/^v/,"")}export function devtoolsVersion(t,e){const o=t.split(/\r?\n/).find(t=>t.startsWith(`${e}=`)),n=o?st.exec(o.slice(e.length+1)):null;if(!n)throw new Error(`${e} is not in versions.txt`);return n[1]}export async function latestVersion(t,e={}){const o=componentPlatform(),n=`${t.id}:${o}`,r=nt()[n],a=r&&Date.now()-r.checked_at<(r.version?36e5:6e5);if(r&&a&&!e.refresh)return{version:r.version??null,...r.error?{error:r.error}:{}};try{const e=await async function(t,e){const o=t.latest;switch(o.type){case"node-lts":return latestNodeLts(await at(o.url));case"devtools":return o.platforms&&!o.platforms.includes(e)?null:devtoolsVersion(await at(`${W().devtools}/versions.txt`),o.key);case"npm":{if(o.staleTag){const e=O(t.adapter??"")?.installSpec,o=e?await F(e):"latest";if("latest"!==o)return o}const e=JSON.parse(await at(`${B}/${o.package}/latest`));if(!e.version)throw new Error(`no version for ${o.package}`);return e.version}case"version-file":{const t=expandUrl(o.url);if(!t)return null;const e=st.exec(await at(t));if(!e)throw new Error(`no version in ${t}`);return e[1]}default:return null}}(t,o);return e&&rt(n,{version:e,checked_at:Date.now()}),{version:e}}catch(e){const o=e instanceof Error?e.message:String(e);return V.logError(`components.latest(${t.id})`,e),rt(n,{error:o,checked_at:Date.now()}),{version:r?.version??null,error:o}}}export async function prefetchLatest(t,e={}){const o=componentPlatform(),n=await Promise.all(t.map(async t=>t.platforms.includes(o)?"app"===t.category?[t.id,A(t.app)?await _(t.app,e):{version:null}]:[t.id,await latestVersion(t,e)]:[t.id,{version:null}]));return new Map(n)}export async function componentStatus(t,e={}){const o=componentPlatform(),n={id:t.id,name:t.name,category:t.category,supported:t.platforms.includes(o),source:componentSource(t,o)},r={...n,installed:!1,current:null,latest:null,outdated:!1,path:null,managed_by:null,auto_upgrade:!1,blocker:n.supported?installBlocker():"unsupported_platform"};if(!n.supported)return r;if("app"===t.category){const o=A(t.app);if(!o)return{...r,blocker:"unsupported_platform"};const n=e.latest?P(t.app,e.latest):e.offline?x(t.app):await $(t.app,{refresh:e.refresh});return{...r,installed:n.installed,current:n.current,latest:n.latest,outdated:n.outdated,path:n.installed?it(()=>o.appInstaller.installedPath()):null,managed_by:n.installed?"app":null,auto_upgrade:n.installed&&!n.blocker,blocker:n.blocker??installBlocker(),...n.error?{error:n.error}:{}}}let a=null,s=null,i=null;if("cli"===t.category){const e=O(t.adapter)?.installSpec,o=e?U(e)[0]:void 0;o&&(a=o.version,s=o.path,i={by:o.kind,auto:!0})}else{const e=probeRuntime(t,o)[0];e&&(a=e.version,s=e.path,i=runtimeManager(t.id,e.path,o))}const{version:l,error:c}=e.latest?e.latest:e.offline?{version:nt()[`${t.id}:${o}`]?.version??null,error:void 0}:await latestVersion(t,{refresh:e.refresh}),u=l?nt()[`${t.id}:${o}:ceiling`]:void 0,p=Boolean(u?.version&&u.error===l&&a&&k(a,u.version)>=0);return{...r,installed:Boolean(s),current:a,latest:l,outdated:Boolean(a&&l&&k(a,l)<0&&!p),...p?{capped_at:u.version}:{},path:s,managed_by:i?.by??null,auto_upgrade:i?.auto??!1,...i?.hint?{hint:i.hint}:{},...c?{error:c}:{}}}function it(t){try{return t()}catch{return null}}const lt={idleMs:18e4,timeoutMs:36e5};let ct,ut=async(t,e)=>(ct=await T({name:(/([a-z0-9-]+)\.(?:ps1|sh)$/i.exec(t)?.[1]??"runtime").toLowerCase(),url:t,platform:componentPlatform(),limits:{...lt,env:e},output:C,run:(t,e,o)=>R(t,e,o)}),"ok"===ct.outcome),pt=async(t,e)=>"ok"===await R(t,e,lt);function dt(t){D()?process.stderr.write(t+"\n"):console.log(t)}export function globalPackages(t,e=componentPlatform()){const o=u(z(t)),a="win32"===e?d(o,"node_modules"):d(u(o),"lib","node_modules"),s=[],i=(t,e)=>{try{const o=JSON.parse(n(d(t,"package.json"),"utf-8"));o.version&&s.push({name:e,version:o.version})}catch{}};let l=[];try{l=r(a)}catch{return s}for(const t of l)if(!t.startsWith(".")&&"npm"!==t&&"corepack"!==t)if(t.startsWith("@"))try{for(const e of r(d(a,t)))e.startsWith(".")||i(d(a,t,e),`${t}/${e}`)}catch{}else i(d(a,t),t);return s}function mt(t,e,o={}){const n=["installed","upgraded","reinstalled","up_to_date","already_installed"].includes(e);return{tool:t.id,category:t.category,current:t.current,latest:t.latest,result:e,version_after:null,ok:n,...o}}function ft(t){return`${w} upgrade ${t}`}export async function runRuntime(t,e,n={}){const r=Date.now(),a=componentPlatform(),s=await componentStatus(t,{refresh:!0}),i=t.name;if(!s.supported)return dt(g.yellow(" ! "+b.t("components.unsupported_platform",{tool:i}))),mt(s,"unavailable",{reason:"unsupported_platform"});if(s.blocker)return dt(g.yellow(" ! "+function(t,e){return b.t(`components.blocked_${t}`,{tool:e})}(s.blocker,i))),mt(s,"unavailable",{reason:s.blocker});const l=function(t){if("script"!==t.install.type)return null;const e=h().installMirror?.scripts;return e?`${e}/${t.install.script}.${"win32"===componentPlatform()?"ps1":"sh"}`:null}(t);if(s.installed&&!n.force){const o=g.gray(`(${s.path})`);if(s.latest&&!s.outdated)return dt(g.green(" √ "+b.t("components.up_to_date",{tool:i,current:s.current??"?"}))+o),"upgrade"===e&&dt(g.gray(" "+b.t("components.force_hint",{command:`${ft(t.id)} --force`}))),mt(s,"install"===e?"already_installed":"up_to_date");if("install"===e)return dt(g.green(" √ "+b.t("components.already_installed",{tool:i,current:s.current??"?"}))+o),s.outdated&&dt(g.yellow(" ! "+upgradeAdvice(s))),mt(s,"already_installed",s.outdated?{hint:upgradeAdvice(s)}:{});if(!s.latest)return dt(g.yellow(" ! "+b.t("components.no_latest",{tool:i,current:s.current??"?",how:ht(s)}))),mt(s,"manual",{reason:s.error??"no_latest",hint:s.hint});if(!s.auto_upgrade)return dt(g.yellow(" ! "+upgradeAdvice(s))),mt(s,"manual",{hint:s.hint})}if(!l)return dt(g.yellow(" ! "+b.t("components.no_mirror",{tool:i}))),mt(s,"unavailable",{reason:"no_mirror"});s.installed&&!s.auto_upgrade&&dt(g.yellow(" ! "+b.t("components.force_beside",{tool:i,path:s.path??"?",by:s.managed_by??"?"})));const p={};s.installed&&"script"===t.install.type&&Object.assign(p,t.install.forceEnv??{}),"uv"===t.id&&s.installed&&s.auto_upgrade&&s.path&&(p.UV_INSTALL_DIR=u(s.path));const d=t.upgrade?.migrateGlobalPackages&&s.installed&&"fnm"===s.managed_by&&s.path,m=d?globalPackages(s.path,a):[],f=d?z(s.path):null;dt(g.gray(" "+b.t(s.installed?"components.upgrading":"components.installing",{tool:i,latest:s.latest??"",source:s.source}))),j(`component:${t.id}`,"start",{detail:{mode:e,force:Boolean(n.force),current:s.current}}),d&&m.length&&f&&function(t){try{o(v.getConfigDir(),{recursive:!0}),N(vt(),JSON.stringify({...t,noted_at:Date.now()},null,2),384)}catch(t){V.logError("components: note migration",t)}}({packages:m,old_node:f}),ct=void 0;const w=await ut(l,p);I(),et=null;const y=probeRuntime(t,a),_=scriptTarget(t.id,a,{...process.env,...p}),$=(_?y.find(t=>{return e=t.path,o=_,"win32"===a?z(e).toLowerCase()===z(o).toLowerCase():z(e)===z(o);var e,o}):void 0)??y.find(e=>runtimeManager(t.id,e.path,a).auto)??y[0];if(!w||!$){yt();const e=ct;return j(`component:${t.id}`,"fail",{duration_ms:Date.now()-r,error:S(C())||void 0,detail:{reason:w?"not_found_after":"script_failed",...e?{how:e.how,...e.fileProblem?{file_problem:e.fileProblem}:{},...M(e.trace)}:{},...E(),...L()}}),dt(g.red(" × "+b.t("components.script_failed",{tool:i,command:(s.installed?ft:gt)(t.id)}))),mt(s,"failed",{reason:w?"not_found_after":"script_failed"})}let P;d&&m.length&&f&&z($.path)!==f&&(P=await wt(m,$.path,a)?"done":"failed"),"failed"!==P&&yt();const x=y[0];x&&x.path!==$.path&&x.version&&$.version&&k(x.version,$.version)<0&&dt(g.yellow(" ! "+b.t("components.path_shadowed",{tool:i,active:x.path,version:$.version,path:$.path}))),s.latest&&$.version&&k($.version,s.latest)<0&&(rt(`${t.id}:${a}:ceiling`,{version:$.version,error:s.latest,checked_at:Date.now()}),dt(g.yellow(" ! "+b.t("components.capped",{tool:i,latest:s.latest,version:$.version})))),j(`component:${t.id}`,"ok",{duration_ms:Date.now()-r,detail:{version:$.version,...P?{migration:P}:{}}});const A=s.installed?n.force&&!s.outdated?"reinstalled":"upgraded":"installed";var D;return dt(g.green(" √ "+("installed"===A?b.t("components.installed",{tool:i,version:$.version??"?"}):"reinstalled"===A?b.t("components.reinstalled",{tool:i,version:$.version??"?"}):b.t("components.upgraded",{tool:i,from:s.current??"?",to:$.version??"?"})))+g.gray(`(${$.path})`)),D=u($.path),(process.env.PATH??"").split("win32"===componentPlatform()?";":c).some(t=>"win32"===componentPlatform()?t.toLowerCase()===D.toLowerCase():t===D)||dt(g.gray(" "+b.t("components.new_terminal"))),mt(s,A,{version_after:$.version})}function gt(t){return`${w} install ${t}`}function ht(t){return t.hint?t.hint:b.t(`components.how_${t.managed_by??"other"}`,{tool:t.name})}export function upgradeAdvice(t){return t.auto_upgrade?b.t("components.outdated_auto",{tool:t.name,current:t.current??"?",latest:t.latest??"?",command:ft(t.id)}):b.t("components.outdated_manual",{tool:t.name,current:t.current??"?",latest:t.latest??"?",by:t.managed_by??"?",how:ht(t),command:`${ft(t.id)} --force`})}async function wt(t,e,o){const n=new Set(globalPackages(e,o).map(t=>t.name)),r=t.filter(t=>!n.has(t.name));if(!r.length)return!0;dt(g.gray(" "+b.t("components.migrating_globals",{packages:r.map(t=>t.name).join("、")})));const a=function(t,e){const o=u(z(t));return d(o,"win32"===e?"npm.cmd":"npm")}(e,o),s=["install","-g",...r.map(t=>`${t.name}@${t.version}`),`--registry=${B}`,"--no-fund","--no-audit","--loglevel=error",...y(v.getConfigDir())];return!!await pt(a,s)||(dt(g.yellow(" ! "+b.t("components.migrate_failed",{command:[a,...s].join(" ")}))),!1)}const vt=()=>d(v.getConfigDir(),"node-migration.json");function yt(){try{s(vt(),{force:!0})}catch(t){V.logError("components: clear migration",t)}}export async function resumePendingMigration(){let t;try{if(!e(vt()))return"none";t=JSON.parse(n(vt(),"utf-8"))}catch{return yt(),"none"}const o=componentPlatform(),r=listComponents().find(t=>"node"===t.id),a=r?probeRuntime(r,o).find(t=>"fnm"===runtimeManager("node",t.path,o).by):void 0;if(!Array.isArray(t.packages)||"number"!=typeof t.noted_at||Date.now()-t.noted_at>2592e6||!a||z(a.path)===t.old_node)return yt(),"none";j("component:node","start",{detail:{mode:"resume-migration"}});const s=await wt(t.packages,a.path,o);return s&&yt(),j("component:node",s?"ok":"fail",{detail:{mode:"resume-migration",migration:s?"done":"failed"}}),s?"done":"failed"}export function setComponentDepsForTests(t){void 0!==t.platform&&(G=t.platform),void 0!==t.uid&&(q=t.uid),void 0!==t.systemPaths&&(K=t.systemPaths),t.registryPath&&(tt=t.registryPath,et=null),t.versionRunner&&(X=t.versionRunner),t.macDeveloperTools&&(Z=t.macDeveloperTools),t.fetchText&&(at=t.fetchText),t.scriptRunner&&(ut=t.scriptRunner),t.commandRunner&&(pt=t.commandRunner)}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* npm's cache this account can't write: "npm config set cache D:\nodejs\node_cache" from a tutorial with that folder
|
|
3
|
+
* made by an administrator (11-18 Windows customer: every `npm install` failed with EPERM under `_cacache\tmp`), or a
|
|
4
|
+
* `~/.npm` left by `sudo npm`. The setting lives in the user's `.npmrc`, so every Node hits it. We don't touch the
|
|
5
|
+
* `.npmrc`; our own npm runs get `--cache=<our dir>/npm-cache` instead. The one-click installers do the same.
|
|
6
|
+
*/
|
|
7
|
+
/** The cache npm will use: `npm_config_cache`, else `cache=` in the user's npmrc, else npm's default. */
|
|
8
|
+
export declare function npmCacheDir(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
|
|
9
|
+
/** Whether a new file can be made where npm makes its temporary files (the closest folder that exists). */
|
|
10
|
+
export declare function canWriteNpmCache(dir: string): boolean;
|
|
11
|
+
/** Extra npm arguments: `--cache=<ownDir>/npm-cache` when npm's own cache can't be written, else none. */
|
|
12
|
+
export declare function npmCacheArgs(ownDir: string, env?: NodeJS.ProcessEnv): string[];
|
|
13
|
+
export declare function resetNpmCacheArgsForTests(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{closeSync as t,existsSync as r,openSync as e,readFileSync as c,unlinkSync as n}from"fs";import{dirname as o,join as s}from"path";import{toolHome as i}from"./tools/types.js";export function npmCacheDir(t=process.env,r=process.platform){const e=p(t,"npm_config_cache");if(e)return e;const n=i(),o=function(t,r){let e;try{e=c(t,"utf8")}catch{return""}let n="";for(const t of e.split(/\r?\n/)){const e=t.trim();if(!e||e.startsWith(";")||e.startsWith("#"))continue;const c=/^cache\s*=\s*(.*)$/.exec(e);c&&(n=c[1].trim().replace(/^(["'])(.*)\1$/,"$2").replace(/\$\{([^}]+)\}/g,(t,e)=>r[e]??""),(n.startsWith("~/")||n.startsWith("~\\"))&&(n=s(i(),n.slice(2))))}return n}(p(t,"npm_config_userconfig")||s(n,".npmrc"),t);return o||("win32"===r?s(t.LOCALAPPDATA||s(n,"AppData","Local"),"npm-cache"):s(n,".npm"))}function p(t,r){const e=Object.keys(t).find(t=>t.toLowerCase()===r);return e?(t[e]??"").trim():""}export function canWriteNpmCache(c){let i=s(c,"_cacache","tmp");for(;!r(i);){const t=o(i);if(t===i)return!0;i=t}const p=s(i,`.write-test-${process.pid}-${Date.now()}`);try{return t(e(p,"wx")),n(p),!0}catch(t){const r=t.code;return!("EPERM"===r||"EACCES"===r||"EBUSY"===r)}}let a=null;export function npmCacheArgs(t,r=process.env){const e=npmCacheDir(r),c=`${e}\n${t}`;if(a?.key===c)return a.args;const n=canWriteNpmCache(e)?[]:[`--cache=${s(t,"npm-cache")}`];return a={key:c,args:n},n}export function resetNpmCacheArgsForTests(){a=null}
|
|
@@ -14,4 +14,10 @@ export declare function writePersistentEnv(id: string, envFile: string, vars: Re
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function removePersistentEnv(id: string, envFile: string, names: readonly string[]): void;
|
|
16
16
|
/** 读回 env 文件里的变量;文件不存在或没有内容时为空对象。 */
|
|
17
|
+
/**
|
|
18
|
+
* env 文件里的值是不是都已生效:Unix 由 rc 行加载文件,文件即生效;Windows 工具读的是用户环境变量,
|
|
19
|
+
* 要逐个核对注册表里的值与文件一致。只比文件判断「已是最新」会让一次没写进注册表的旧值一直留着
|
|
20
|
+
* (11-21 客户 Windows 机器:文件已有 gemini-4-neon,用户环境变量还是旧菜单,refresh 一直报已是最新)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function persistentEnvApplied(envFile: string): boolean;
|
|
17
23
|
export declare function readPersistentEnvFile(envFile: string): Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as t,existsSync as n,readFileSync as
|
|
1
|
+
import{chmodSync as t,existsSync as n,readFileSync as e,realpathSync as o,unlinkSync as r}from"fs";import{join as s}from"path";import{logger as i}from"../utils/logger.js";import{getShellRcFilePath as c}from"./env-cleanup.js";import{broadcastEnvChange as f,deleteWindowsEnv as p,readWindowsEnv as u,setUserEnv as l}from"./windows-env.js";import{atomicWriteFile as m,backupBeforeWrite as a}from"./tools/backup.js";import{toolHome as $}from"./tools/types.js";import{CLI_NAME as d}from"./brand.js";const h=t=>`# ${d}:${t}`;function v(){const t=$(),e=new Set,o=c();o&&e.add(o);for(const o of[".zshrc",".bashrc"]){const r=s(t,o);n(r)&&e.add(r)}return[...e]}function j(t,n,e){const o=`"${function(t){const n=$();return t.startsWith(n+"/")?`$HOME/${t.slice(n.length+1)}`:t}(n)}"`;return t.endsWith(".fish")?`test -f ${o}; and source ${o} ${h(e)}`:`[ -f ${o} ] && . ${o} ${h(e)}`}function E(t,e){const r=n(t)?o(t):t;a(r),m(r,e)}function w(t,n){return t.split("\n").filter(t=>!t.trimEnd().endsWith(h(n))).join("\n")}function b(t,n){if(/['\r\n]/.test(n))throw new Error(`${t} contains a quote or newline and cannot be written to a shell env file`)}export function writePersistentEnv(o,r,s){for(const[t,n]of Object.entries(s))b(t,n);const i=Object.entries(s).map(([t,n])=>`export ${t}='${n}'`).join("\n");a(r),m(r,`# Written by ${d}. Loaded from your shell profile.\n${i}\n`,384),t(r,384);for(const[t,n]of Object.entries(s))process.env[t]=n;if("win32"===process.platform){for(const[t,n]of Object.entries(s))l(t,n);return f(),{rcFiles:[]}}const c=[];for(const t of v()){const s=n(t)?e(t,"utf-8"):"",i=j(t,r,o);if(s.split("\n").some(t=>t.trimEnd()===i)){c.push(t);continue}const f=w(s,o).replace(/\n*$/,"");E(t,`${f?f+"\n\n":""}${i}\n`),c.push(t)}return{rcFiles:c}}export function removePersistentEnv(t,o,s){const c=readPersistentEnvFile(o);let l=!1;if("win32"===process.platform){let t=!1;for(const n of s)if(void 0!==c[n]&&u("user",n)===c[n])try{p("user",n),t=!0}catch(t){l=!0,i.logError("persistentEnv.remove",t)}t&&f()}else for(const o of v()){if(!n(o))continue;const r=e(o,"utf-8"),s=w(r,t);s!==r&&E(o,s)}!l&&n(o)&&(a(o),r(o))}export function persistentEnvApplied(t){return"win32"!==process.platform||Object.entries(readPersistentEnvFile(t)).every(([t,n])=>u("user",t)===n)}export function readPersistentEnvFile(t){const o={};if(!n(t))return o;for(const n of e(t,"utf-8").split("\n")){const t=n.match(/^export ([A-Z_][A-Z0-9_]*)='([^']*)'$/);t&&(o[t[1]]=t[2])}return o}
|
package/dist/lib/tool-upgrade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as t,spawnSync as
|
|
1
|
+
import{spawn as t,spawnSync as o}from"child_process";import{rmSync as e}from"fs";import{dirname as r,join as n}from"path";import a from"chalk";import i from"inquirer";import{i18n as s}from"./i18n.js";import{logger as l}from"../utils/logger.js";import{compareVersions as p,getToolMinVersion as c}from"./model-registry.js";import{getAdapter as m}from"./tools/registry.js";import{findInstalls as u,findInstallsIncludingNative as d,forgetInstalls as g,installLabel as f,npmMirrorInstallCommand as w,npmMirrorVersion as h,npmUninstallCommand as _}from"./tools/tool-installs.js";import{toolHome as v}from"./tools/types.js";import{isJsonMode as y,isNonInteractive as k,shouldAutoConfirm as b}from"./runtime-options.js";import{flushTelemetry as x,maskHome as j,maskSecrets as C,track as T}from"./telemetry.js";import{windowsSecurityProducts as D}from"./windows-security.js";import{isWindowsPowerShell as $,powerShellEnv as E}from"./powershell-env.js";import{diagnoseMissing as M,runInstallScript as P,traceSummary as S}from"./install-script.js";import{endedByInterrupt as I}from"./signals.js";import{npmCacheArgs as O}from"./npm-cache.js";import{configManager as U}from"./config.js";let A="ok",W={};export function lastCommandExit(){return W}let q="";const z=t=>{q=(q+t.toString("utf-8")).slice(-3e3)};export function outputTail(t){return t.replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").split(/\r?\n/).map(t=>t.split("\r").pop().trimEnd()).filter(Boolean).join("\n").slice(-1500)}export function lastCommandOutput(){return outputTail(q)}export function lastCommandInterrupted(){return I({status:W.exit_code,signal:W.signal})}let B=async(t,e,r={})=>(console.log(a.gray("$ ")+[t,...e].join(" ")),q="",W={},r.idleMs?A=await runWatched(t,e,r):(await x(1e3),A=function(t,e,r){const n=F(t)?o(N(t,e),{stdio:R(),shell:!0,timeout:r}):o(t,e,{stdio:R(),timeout:r,env:H(t)});return n.error&&l.logError(`upgrade: ${t}`,n.error),W={exit_code:n.status,signal:n.signal,...n.error?{spawn_error:String(n.error.message)}:{}},"ETIMEDOUT"===n.error?.code?"timeout":0===n.status?"ok":"fail"}(t,e,r.timeoutMs)),"ok"===A);const F=t=>"win32"===process.platform&&!/\.exe$/i.test(t),H=t=>$(t)?E():process.env,N=(t,o)=>[t,...o].map(t=>/\s/.test(t)?`"${t}"`:t).join(" "),R=()=>["inherit",y()?2:"inherit","inherit"];export function runWatched(o,e,r){return new Promise(n=>{const a=r.env?{...H(o),...r.env}:H(o),i=F(o)?t(N(o,e),{stdio:["inherit","pipe","pipe"],shell:!0,env:a}):t(o,e,{stdio:["inherit","pipe","pipe"],env:a});let s;const p=t=>{s=t,i.kill()};let c;const m=()=>{clearTimeout(c),r.idleMs&&(c=setTimeout(()=>p("stalled"),r.idleMs))},u=r.timeoutMs?setTimeout(()=>p("timeout"),r.timeoutMs):void 0;m(),i.stdout?.on("data",t=>{(y()?process.stderr:process.stdout).write(t),z(t),m()}),i.stderr?.on("data",t=>{process.stderr.write(t),z(t),m()});const d=t=>{clearTimeout(c),clearTimeout(u),n(t)};i.on("error",t=>{l.logError(`upgrade: ${o}`,t),W={...W,spawn_error:String(t.message)},d(s??"fail")}),i.on("close",(t,o)=>{W={...W,exit_code:t,signal:o},s&&(y()?process.stderr:process.stdout).write("\n"),d(s??(0===t?"ok":"fail"))})})}export function setUpgradeRunnerForTests(t){B=async(o,e,r)=>{const n=await t(o,e,r);return A="string"==typeof n?n:n?"ok":"fail","ok"===A}}const V={ok:"install.script_failed_npm",fail:"install.script_failed_npm",stalled:"install.script_stalled_npm",timeout:"install.script_timeout_npm"};let Y;export function lastInstallMissing(){return Y}export async function mirrorInstall(t,o){if(Y=void 0,!t.mirrorScript)return Z(t);console.log(a.gray(s.t("install.downloading")));const e=`install-script:${t.command}`,n=Date.now();T(e,"start");const i=await P({name:t.command,url:"win32"===process.platform?t.mirrorScript.ps1:t.mirrorScript.sh,limits:{idleMs:18e4,timeoutMs:36e5},output:lastCommandOutput,run:async(t,o,e)=>(await B(t,o,e),A)});let l,p=i.outcome;if("ok"===p&&o&&(g(),!o.installed())){const t=M(i.trace,o.expectedPaths);"not_on_path"===t.reason&&t.path&&o.addToPath?.(r(t.path))&&o.installed()?l=r(t.path):(Y=t,p="fail")}const c="ok"===p;if(T(e,"stalled"===p?"timeout":p,{duration_ms:Date.now()-n,detail:{..."stalled"===p||"timeout"===p?{reason:p}:{},...Y?{reason:Y.reason,...Y.path?{path:j(Y.path)}:{}}:{},...l?{path_added:j(l)}:{},how:i.how,...i.fileProblem?{file_problem:i.fileProblem}:{},...S(i.trace),...lastCommandExit(),...c?{output:C(lastCommandOutput())}:{},...c?{}:failureContext()},...c?{}:{error:lastCommandOutput()||(Y?"(no output)":void 0)}}),Y&&console.log(a.yellow(" ! "+function(t,o){const e=D().join("、");switch(o.reason){case"removed_after_install":return s.t(e?"install.missing_removed_by":"install.missing_removed",{tool:t,path:o.path??"",security:e});case"not_on_path":return s.t("install.missing_not_on_path",{tool:t,path:o.path??""});case"not_downloaded":return s.t("install.missing_not_downloaded",{tool:t});default:return s.t("install.missing_unknown",{tool:t})}}(t.command,Y))),c||!t.npmPackage||lastCommandInterrupted())return c;console.log(a.yellow(" ! "+s.t(V[i.outcome],{minutes:String(3)}))),T(e,"fallback");const m=await Z(t);return m&&o&&(g(),o.installed()&&(Y=void 0)),m&&!Y}export function failureContext(){const t=D();return t.length?{security:t}:{}}async function Z(t){const o=w(t,await h(t)),[e,...r]=o.split(" "),n=[...r,...O(U.getConfigDir())],i=`install-npm:${t.command}`,l=Date.now();T(i,"start");const p=await B(e,n);return T(i,p?"ok":"fail",{duration_ms:Date.now()-l,detail:{...lastCommandExit(),...p?{}:failureContext()}}),p||"win32"===process.platform||console.log(a.yellow(" ! "+s.t("upgrade.npm_permission",{command:o}))),p}async function G(t,o){switch(o.kind){case"npm":t.npmPackage&&await B("npm",["uninstall","-g",t.npmPackage]);break;case"brew":t.brew&&await B("brew",["uninstall",t.brew]);break;case"native":try{e(o.path,{force:!0});for(const o of t.native?.dataDirs??[])e(n(v(),...o),{recursive:!0,force:!0})}catch(t){l.logError("upgrade: remove native copy",t)}break;default:return!1}return g(),!u(t).some(t=>t.path===o.path)}function J(t,o){switch(o.kind){case"npm":return _(t);case"brew":return`brew uninstall ${t.brew}`;case"native":return s.t("upgrade.delete_paths",{paths:[o.path,...(t.native?.dataDirs??[]).map(t=>n(v(),...t))].join("、")});default:return s.t("upgrade.delete_paths",{paths:o.path})}}export async function upgradeTool(t){const o=Date.now();T(`upgrade:${t}`,"start");try{const e=await async function(t){const o=m(t),e=o?.installSpec;if(!o||!e)throw new Error(s.t("upgrade.unsupported",{tool:t}));const r=o.displayName;g();const n=u(e);if(console.log(a.bold(`\n${r}`)),0===n.length)console.log(s.t("upgrade.not_installed_installing",{tool:r})),await mirrorInstall(e);else{const t=n[0];console.log(a.gray(" "+s.t("upgrade.current",{copy:f(t)})));const o=await async function(t,o){switch(o.kind){case"native":return B(o.path,t.native?.updateArgs??["update"],{timeoutMs:t.native?.updateTimeoutMs});case"npm":return Z(t);case"brew":return!!t.brew&&B("brew",["upgrade",t.brew]);default:return!1}}(e,t);!o&&lastCommandInterrupted()||(o||"other"!==t.kind?o||"npm"===t.kind||"native"===t.kind&&await async function(t){const o=t.native?.mirrorUpdate;if(!o)return!1;console.log(a.yellow(" ! "+s.t("upgrade.native_mirror_trying")));const e=`native-mirror:${t.command}`,r=Date.now();T(e,"start");try{const{version:t,manifestVerified:n}=await o();return T(e,"ok",{duration_ms:Date.now()-r,detail:{version:t,manifest_verified:n}}),console.log(a.green(" √ "+s.t(n?"upgrade.native_mirror_done_verified":"upgrade.native_mirror_done",{version:t}))),!0}catch(t){return l.logError("upgrade: native mirror",t),T(e,"fail",{duration_ms:Date.now()-r,error:t,detail:failureContext()}),console.log(a.yellow(" ! "+s.t("upgrade.native_mirror_failed",{reason:t instanceof Error?t.message:String(t)}))),!1}}(e)||(console.log(a.yellow(" ! "+s.t("upgrade.fallback_mirror"))),await mirrorInstall(e)):console.log(a.yellow(" ! "+s.t("upgrade.unknown_install",{path:t.path}))))}g(),await async function(t,o){const e=u(t);if(e.length<2)return;const r=function(t){return t.reduce((t,o)=>o.version&&(!t.version||p(o.version,t.version)>0)?o:t)}(e),n=e.filter(t=>t!==r);console.log(a.yellow(" ! "+s.t("upgrade.duplicates",{tool:o,keep:f(r),others:n.map(f).join("、")})));let l=b();l||k()||!process.stdin.isTTY||(l=(await i.prompt([{type:"confirm",name:"remove",message:s.t("upgrade.confirm_remove"),default:!0}])).remove);for(const o of n)l&&await G(t,o)?console.log(a.green(" √ "+s.t("upgrade.removed",{copy:f(o)}))):console.log(a.yellow(" ! "+s.t("upgrade.remove_by_hand",{how:J(t,o)})))}(e,r),g();const w=d(e)[0];if(!w)return console.log(a.red(" × "+s.t("upgrade.still_missing",{tool:r}))),!1;w.onPath||console.log(a.gray(" "+s.t("components.new_terminal")));const h=c(t);if(h&&w.version&&p(w.version,h)<0){console.log(a.yellow(" ! "+s.t("upgrade.still_old",{copy:f(w),min:h})));for(const t of o.upgradeHints?.(h)??[])console.log(a.yellow(" ! "+t));return!1}return console.log(a.green(" √ "+s.t("upgrade.done",{copy:f(w)}))),!0}(t);return T(`upgrade:${t}`,e?"ok":"fail",{duration_ms:Date.now()-o}),e}catch(e){throw T(`upgrade:${t}`,"fail",{duration_ms:Date.now()-o,error:e}),e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as t,existsSync as r,readFileSync as e}from"fs";import{join as n}from"path";import{i18n as o}from"../i18n.js";import{prettyModelName as i}from"../gateway-models.js";import{getAgyRules as a}from"../model-registry.js";import{logger as l}from"../../utils/logger.js";import{
|
|
1
|
+
import{chmodSync as t,existsSync as r,readFileSync as e}from"fs";import{join as n}from"path";import{i18n as o}from"../i18n.js";import{prettyModelName as i}from"../gateway-models.js";import{getAgyRules as a}from"../model-registry.js";import{logger as l}from"../../utils/logger.js";import{persistentEnvApplied as s,readPersistentEnvFile as c,removePersistentEnv as u,writePersistentEnv as p}from"../persistent-env.js";import{backupBeforeWrite as m,atomicWriteFile as d}from"./backup.js";import{findInstalls as g,mirrorInstallCommand as y}from"./tool-installs.js";import{toolHome as f}from"./types.js";import{brand as h,PROVIDER_KEY as v}from"../brand.js";const A="agy",_="AGY_LLM_GATEWAY_URL",E="AGY_LLM_GATEWAY_API_KEY",j="AGY_LLM_GATEWAY_MODELS",w=["GEMINI_API_KEY","GOOGLE_GEMINI_BASE_URL"],K="gemini",b=()=>n(f(),".gemini","antigravity-cli"),I=()=>n(b(),"settings.json"),P=()=>n(b(),`${v}.env`),M=()=>n(f(),".antigravity","settings.json"),G=h().installMirror?.agy,L={command:"agy",native:{binDir:"win32"===process.platform?["AppData","Local","agy","bin"]:[".local","bin"],updateArgs:["update"],dataDirs:[]},...G?{mirrorScript:{sh:`${G}/install.sh`,ps1:`${G}/install.ps1`}}:{}};function $(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function C(t,n){if(!r(t))return{};const o=e(t,"utf-8");if(!o.trim())return{};try{const t=JSON.parse(o);if(!$(t))throw new Error(`${n} root must be an object`);return t}catch(t){throw new Error(`Existing ${n} cannot be parsed; back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}}const N=()=>C(I(),"~/.gemini/antigravity-cli/settings.json"),S=()=>C(M(),"~/.antigravity/settings.json");function Y(r,e,n){m(r),d(r,JSON.stringify(e,null,2)+"\n",n),void 0!==n&&t(r,n)}function x(t){return(t||"").replace(/\/+$/,"").replace(/\/v1(beta)?$/,"")}const k=/-(minimal|low|medium|high|xhigh|max)$/;function O(t){const r=a().gatewayModels,e=t?r.filter(r=>t.models.includes(r)||t.models.includes(r.replace(k,""))):[];return e.length>0?e:r}function U(t){const r=t.replace(/-preview$/,""),e=k.exec(r)?.[1];return e?`${i(r.replace(k,""))} (${e[0].toUpperCase()}${e.slice(1)})`:i(r)}function D(t){const r=t.gateway;return $(r)&&!0===r.enabled&&"string"==typeof r.apiKey&&r.apiKey.trim()&&"string"==typeof r.url?{url:r.url,apiKey:r.apiKey}:null}function R(t){const r=t.models;return $(r)&&Array.isArray(r.list)?r.list.map(t=>$(t)&&"string"==typeof t.modelId?t.modelId:"").filter(Boolean):[]}function T(){try{if(N().modelProvider!==K)return null}catch{return null}const t=c(P()),r=t.GEMINI_API_KEY;return r&&r.trim()?{apiKey:r,url:t.GOOGLE_GEMINI_BASE_URL??""}:null}function B(t){const r=c(P());return r[_]===t.url&&r[E]===t.apiKey}function W(t,r,e){const n=N(),o=S();o.gateway={...$(o.gateway)?o.gateway:{},enabled:!0,url:r,apiKey:t,wireProtocol:"genai"},o.models={...$(o.models)?o.models:{},defaultModelId:e[0],list:e.map(t=>({modelId:t,displayName:U(t),supportsThinking:!0}))},Y(M(),o,384),w.some(t=>void 0!==c(P())[t])&&u(A,P(),w);const i=p(A,P(),{[_]:r,[E]:t,[j]:e.join(",")}).rcFiles;for(const t of w)delete process.env[t];return n.modelProvider===K&&(delete n.modelProvider,Y(I(),n)),i}let J=null,F=null;export const antigravityAdapter={name:"agy",displayName:"Antigravity CLI",command:"agy",installCommand:y(L),installSpec:L,configPath:M(),wantsModelCatalog:!0,loadPrivateConfig(t){N(),S();const r=O(t.catalog);J=W(t.apiKey,x(t.baseUrl),r),F=r},unloadPrivateConfig(){try{const t=S();D(t)&&(delete t.gateway,delete t.models,Y(M(),t,384))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}try{const t=N();t.modelProvider===K&&(delete t.modelProvider,Y(I(),t))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}u(A,P(),[_,E,j,...w])},detectCurrentConfig(){try{const t=D(S());if(t)return{apiKey:t.apiKey}}catch{return{apiKey:null}}return{apiKey:T()?.apiKey??null}},listedModels(){try{const t=S(),r=D(t);if(r)return B(r)?R(t):[]}catch{return null}return T()?[]:null},refreshModelMenu(t){const r=S(),e=D(r)??T();if(!e)return;const n=O(t.catalog),o=e.url||x(t.baseUrl),i=D(r);null!==i&&B(i)&&R(r).join(",")===n.join(",")&&c(P())[j]===n.join(",")&&s(P())&&null===T()||W(e.apiKey,o,n)},getConfig(){try{return S()}catch(t){return l.logError("antigravityAdapter.getConfig",t),null}},applyNotes(){const t=[];if(F&&F.length>0){const r=F.map(U);t.push({kind:"summary",text:o.t("tools.agy.menu_written",{count:String(r.length),list:r.join(o.t("tools.grok.list_separator")),default:r[0]})})}return null===J||0===g(L).length||t.push({kind:"action",text:o.t("tools.agy.open_new_terminal")}),t},backupPaths:()=>[M(),I(),P()],forceResetPaths:()=>[P()]};
|
package/dist/models.json
CHANGED
package/models.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.188",
|
|
4
4
|
"description": "CLI tool for managing AI coding assistants (Claude Code, Codex, OpenClaw, Hermes, AtomCode, Grok Build) with one unified config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|