@lay111/dsh-plugin-google 1.0.7 → 1.0.8
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/package.json +1 -1
- package/src/api.js +47 -27
- package/src/models.js +37 -26
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -68,23 +68,24 @@ export function formatMessagesToAntigravity(messages, modelSpec, projectId) {
|
|
|
68
68
|
contents.push({ role: 'user', parts: [{ text: 'Hello' }] });
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
const isClaude = modelSpec.id.includes('claude');
|
|
71
|
+
const isClaude = modelSpec.id.includes('claude') || modelSpec.wireId.includes('claude');
|
|
72
72
|
const payload = {
|
|
73
73
|
project: projectId || 'aicode-consumers',
|
|
74
74
|
model: modelSpec.wireId,
|
|
75
75
|
requestId: `agent/dsh/${Date.now()}/traj_${Date.now()}/1`,
|
|
76
76
|
request: {
|
|
77
77
|
contents,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
generationConfig: {
|
|
79
|
+
maxOutputTokens: modelSpec.maxTokens || 8192,
|
|
80
|
+
...(modelSpec.supportsThinking
|
|
81
|
+
? {
|
|
81
82
|
thinkingConfig: {
|
|
82
83
|
includeThoughts: true,
|
|
83
84
|
thinkingBudget: modelSpec.thinkingBudget || 10000,
|
|
84
85
|
},
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
},
|
|
88
89
|
...(systemInstruction ? { systemInstruction } : {}),
|
|
89
90
|
labels: {
|
|
90
91
|
trajectory_id: `traj_${Date.now()}`,
|
|
@@ -116,33 +117,52 @@ export async function* streamAntigravity(options, accessToken, projectId) {
|
|
|
116
117
|
|
|
117
118
|
let response = null;
|
|
118
119
|
let lastError = null;
|
|
120
|
+
const maxRetries = 3;
|
|
121
|
+
|
|
122
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
123
|
+
for (const endpoint of ANTIGRAVITY_ENDPOINTS) {
|
|
124
|
+
try {
|
|
125
|
+
const res = await fetch(endpoint, {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {
|
|
128
|
+
Authorization: `Bearer ${accessToken}`,
|
|
129
|
+
'Content-Type': 'application/json',
|
|
130
|
+
Accept: 'text/event-stream',
|
|
131
|
+
'User-Agent': USER_AGENT,
|
|
132
|
+
},
|
|
133
|
+
body: JSON.stringify(payload),
|
|
134
|
+
signal: options.signal,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (res.ok) {
|
|
138
|
+
response = res;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
119
141
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
method: 'POST',
|
|
124
|
-
headers: {
|
|
125
|
-
Authorization: `Bearer ${accessToken}`,
|
|
126
|
-
'Content-Type': 'application/json',
|
|
127
|
-
Accept: 'text/event-stream',
|
|
128
|
-
'User-Agent': USER_AGENT,
|
|
129
|
-
},
|
|
130
|
-
body: JSON.stringify(payload),
|
|
131
|
-
signal: options.signal,
|
|
132
|
-
});
|
|
142
|
+
const status = res.status;
|
|
143
|
+
const errText = await res.text();
|
|
144
|
+
lastError = `(HTTP ${status}) ${errText}`;
|
|
133
145
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
// If rate-limited (429) or temporary server overload (503), wait and retry
|
|
147
|
+
if ((status === 429 || status === 503) && attempt < maxRetries - 1) {
|
|
148
|
+
await new Promise((r) => setTimeout(r, (attempt + 1) * 1500));
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
lastError = err.message;
|
|
153
|
+
if (attempt < maxRetries - 1) {
|
|
154
|
+
await new Promise((r) => setTimeout(r, (attempt + 1) * 1000));
|
|
155
|
+
}
|
|
139
156
|
}
|
|
140
|
-
} catch (err) {
|
|
141
|
-
lastError = err.message;
|
|
142
157
|
}
|
|
158
|
+
|
|
159
|
+
if (response) break;
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
if (!response) {
|
|
163
|
+
if (lastError?.includes('429') || lastError?.includes('exhausted')) {
|
|
164
|
+
throw new Error(`Google Quota Exceeded (429): 当前模型并发或配额超限。建议在 TUI 中输入 /model 切换至 claude-sonnet-4.6、gemini-3.7-flash-medium 或 gemini-3.6-flash,或稍等 20 秒后重试。`);
|
|
165
|
+
}
|
|
146
166
|
throw new Error(`Google Antigravity Upstream Error: ${lastError}`);
|
|
147
167
|
}
|
|
148
168
|
|
package/src/models.js
CHANGED
|
@@ -10,32 +10,51 @@ export const ANTIGRAVITY_MODELS = [
|
|
|
10
10
|
description: 'Google flagship coding model with 10k thinking budget (Fast & Deep)',
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
|
-
id: 'gemini-3.7-flash-
|
|
14
|
-
name: 'Gemini 3.7 Flash
|
|
15
|
-
wireId: 'gemini-3.7-flash',
|
|
13
|
+
id: 'gemini-3.7-flash-medium',
|
|
14
|
+
name: 'Gemini 3.7 Flash Medium',
|
|
15
|
+
wireId: 'gemini-3.7-flash-medium',
|
|
16
16
|
contextWindow: 1048576,
|
|
17
17
|
maxTokens: 65536,
|
|
18
|
-
supportsThinking:
|
|
19
|
-
|
|
18
|
+
supportsThinking: true,
|
|
19
|
+
thinkingBudget: 5000,
|
|
20
|
+
description: 'Balanced latency and thinking depth',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'gemini-3.7-flash-low',
|
|
24
|
+
name: 'Gemini 3.7 Flash Low (Fast)',
|
|
25
|
+
wireId: 'gemini-3.7-flash-low',
|
|
26
|
+
contextWindow: 1048576,
|
|
27
|
+
maxTokens: 65536,
|
|
28
|
+
supportsThinking: true,
|
|
29
|
+
thinkingBudget: 1000,
|
|
30
|
+
description: 'Fast lightweight thinking mode for rapid iterations',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'claude-sonnet-4.6',
|
|
34
|
+
name: 'Claude Sonnet 4.6 (Thinking)',
|
|
35
|
+
wireId: 'claude-sonnet-4-6',
|
|
36
|
+
contextWindow: 200000,
|
|
37
|
+
maxTokens: 64000,
|
|
38
|
+
supportsThinking: true,
|
|
39
|
+
description: 'Anthropic Claude Sonnet 4.6 with reasoning chain via Google Pro',
|
|
20
40
|
},
|
|
21
41
|
{
|
|
22
42
|
id: 'gemini-3.6-flash',
|
|
23
|
-
name: 'Gemini 3.6 Flash',
|
|
24
|
-
wireId: 'gemini-3.6-flash',
|
|
43
|
+
name: 'Gemini 3.6 Flash High',
|
|
44
|
+
wireId: 'gemini-3.6-flash-high',
|
|
25
45
|
contextWindow: 1048576,
|
|
26
46
|
maxTokens: 65536,
|
|
27
47
|
supportsThinking: true,
|
|
28
48
|
thinkingBudget: 4000,
|
|
29
|
-
description: 'Fast lightweight Flash model',
|
|
49
|
+
description: 'Fast lightweight Flash model with reasoning',
|
|
30
50
|
},
|
|
31
51
|
{
|
|
32
52
|
id: 'gemini-3.5-flash',
|
|
33
53
|
name: 'Gemini 3.5 Flash',
|
|
34
|
-
wireId: 'gemini-3.5-flash',
|
|
54
|
+
wireId: 'gemini-3.5-flash-low',
|
|
35
55
|
contextWindow: 1048576,
|
|
36
56
|
maxTokens: 65536,
|
|
37
|
-
supportsThinking:
|
|
38
|
-
thinkingBudget: 4000,
|
|
57
|
+
supportsThinking: false,
|
|
39
58
|
description: 'Classic Flash model',
|
|
40
59
|
},
|
|
41
60
|
{
|
|
@@ -49,22 +68,14 @@ export const ANTIGRAVITY_MODELS = [
|
|
|
49
68
|
description: 'Pro-tier deep reasoning agent model',
|
|
50
69
|
},
|
|
51
70
|
{
|
|
52
|
-
id: '
|
|
53
|
-
name: '
|
|
54
|
-
wireId: '
|
|
55
|
-
contextWindow:
|
|
56
|
-
maxTokens:
|
|
57
|
-
supportsThinking: true,
|
|
58
|
-
description: 'Anthropic Claude Sonnet with reasoning chain via Antigravity',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: 'claude-opus-4.6',
|
|
62
|
-
name: 'Claude Opus 4.6 (Thinking)',
|
|
63
|
-
wireId: 'claude-opus-4-6-thinking',
|
|
64
|
-
contextWindow: 200000,
|
|
65
|
-
maxTokens: 64000,
|
|
71
|
+
id: 'gemini-pro-agent',
|
|
72
|
+
name: 'Gemini Pro Agent (Ultra)',
|
|
73
|
+
wireId: 'gemini-pro-agent',
|
|
74
|
+
contextWindow: 1048576,
|
|
75
|
+
maxTokens: 65536,
|
|
66
76
|
supportsThinking: true,
|
|
67
|
-
|
|
77
|
+
thinkingBudget: 8000,
|
|
78
|
+
description: 'Google Pro Agent model for long-horizon agentic execution',
|
|
68
79
|
},
|
|
69
80
|
{
|
|
70
81
|
id: 'gpt-oss-120b',
|