@lay111/dsh-plugin-google 1.0.6 → 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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +83 -30
  3. package/src/models.js +37 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lay111/dsh-plugin-google",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Native DeepSeek Harness Plugin for Google Antigravity Pro & Gemini/Claude Models",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/api.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import { USER_AGENT } from './auth.js';
2
2
  import { findModel } from './models.js';
3
3
 
4
- const ANTIGRAVITY_ENDPOINT = 'https://cloudaicompanion.googleapis.com/v1:streamGenerateChat';
4
+ const ANTIGRAVITY_ENDPOINTS = [
5
+ 'https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse',
6
+ 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse',
7
+ ];
5
8
 
6
9
  export function formatMessagesToAntigravity(messages, modelSpec, projectId) {
7
10
  const contents = [];
@@ -9,9 +12,13 @@ export function formatMessagesToAntigravity(messages, modelSpec, projectId) {
9
12
 
10
13
  for (const message of messages) {
11
14
  if (message.role === 'system') {
12
- systemInstruction = {
13
- parts: [{ text: typeof message.content === 'string' ? message.content : '' }],
14
- };
15
+ const text = typeof message.content === 'string' ? message.content : JSON.stringify(message.content);
16
+ if (text.length > 0) {
17
+ systemInstruction = {
18
+ role: 'user',
19
+ parts: [{ text }],
20
+ };
21
+ }
15
22
  continue;
16
23
  }
17
24
 
@@ -57,27 +64,38 @@ export function formatMessagesToAntigravity(messages, modelSpec, projectId) {
57
64
  }
58
65
  }
59
66
 
67
+ if (contents.length === 0) {
68
+ contents.push({ role: 'user', parts: [{ text: 'Hello' }] });
69
+ }
70
+
71
+ const isClaude = modelSpec.id.includes('claude') || modelSpec.wireId.includes('claude');
60
72
  const payload = {
61
73
  project: projectId || 'aicode-consumers',
62
74
  model: modelSpec.wireId,
75
+ requestId: `agent/dsh/${Date.now()}/traj_${Date.now()}/1`,
63
76
  request: {
64
77
  contents,
78
+ generationConfig: {
79
+ maxOutputTokens: modelSpec.maxTokens || 8192,
80
+ ...(modelSpec.supportsThinking
81
+ ? {
82
+ thinkingConfig: {
83
+ includeThoughts: true,
84
+ thinkingBudget: modelSpec.thinkingBudget || 10000,
85
+ },
86
+ }
87
+ : {}),
88
+ },
89
+ ...(systemInstruction ? { systemInstruction } : {}),
90
+ labels: {
91
+ trajectory_id: `traj_${Date.now()}`,
92
+ used_claude: String(isClaude),
93
+ },
65
94
  },
95
+ userAgent: 'antigravity',
96
+ requestType: 'agent',
66
97
  };
67
98
 
68
- if (modelSpec.supportsThinking) {
69
- payload.request.generationConfig = {
70
- thinkingConfig: {
71
- includeThoughts: true,
72
- thinkingBudget: modelSpec.thinkingBudget || 10000,
73
- },
74
- };
75
- }
76
-
77
- if (systemInstruction) {
78
- payload.request.systemInstruction = systemInstruction;
79
- }
80
-
81
99
  return payload;
82
100
  }
83
101
 
@@ -97,20 +115,55 @@ export async function* streamAntigravity(options, accessToken, projectId) {
97
115
  ];
98
116
  }
99
117
 
100
- const response = await fetch(ANTIGRAVITY_ENDPOINT, {
101
- method: 'POST',
102
- headers: {
103
- Authorization: `Bearer ${accessToken}`,
104
- 'Content-Type': 'application/json',
105
- 'User-Agent': USER_AGENT,
106
- },
107
- body: JSON.stringify(payload),
108
- signal: options.signal,
109
- });
118
+ let response = null;
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
+ }
141
+
142
+ const status = res.status;
143
+ const errText = await res.text();
144
+ lastError = `(HTTP ${status}) ${errText}`;
110
145
 
111
- if (!response.ok) {
112
- const errorText = await response.text();
113
- throw new Error(`Google API Error (${response.status}): ${errorText}`);
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
+ }
156
+ }
157
+ }
158
+
159
+ if (response) break;
160
+ }
161
+
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
+ }
166
+ throw new Error(`Google Antigravity Upstream Error: ${lastError}`);
114
167
  }
115
168
 
116
169
  const reader = response.body.getReader();
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-standard',
14
- name: 'Gemini 3.7 Flash (Standard)',
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: false,
19
- description: 'Standard low-latency mode without extended thinking',
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: true,
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: 'claude-sonnet-4.6',
53
- name: 'Claude Sonnet 4.6 (Thinking)',
54
- wireId: 'claude-sonnet-4-6-thinking',
55
- contextWindow: 200000,
56
- maxTokens: 64000,
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
- description: 'Anthropic Claude Opus for highest-tier architecture and logic modeling',
77
+ thinkingBudget: 8000,
78
+ description: 'Google Pro Agent model for long-horizon agentic execution',
68
79
  },
69
80
  {
70
81
  id: 'gpt-oss-120b',