@lay111/dsh-plugin-google 1.0.6 → 1.0.7

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +63 -30
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.7",
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,37 @@ 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');
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
+ ...(modelSpec.supportsThinking
79
+ ? {
80
+ generationConfig: {
81
+ thinkingConfig: {
82
+ includeThoughts: true,
83
+ thinkingBudget: modelSpec.thinkingBudget || 10000,
84
+ },
85
+ },
86
+ }
87
+ : {}),
88
+ ...(systemInstruction ? { systemInstruction } : {}),
89
+ labels: {
90
+ trajectory_id: `traj_${Date.now()}`,
91
+ used_claude: String(isClaude),
92
+ },
65
93
  },
94
+ userAgent: 'antigravity',
95
+ requestType: 'agent',
66
96
  };
67
97
 
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
98
  return payload;
82
99
  }
83
100
 
@@ -97,20 +114,36 @@ export async function* streamAntigravity(options, accessToken, projectId) {
97
114
  ];
98
115
  }
99
116
 
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
- });
117
+ let response = null;
118
+ let lastError = null;
119
+
120
+ for (const endpoint of ANTIGRAVITY_ENDPOINTS) {
121
+ try {
122
+ const res = await fetch(endpoint, {
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
+ });
133
+
134
+ if (res.ok) {
135
+ response = res;
136
+ break;
137
+ } else {
138
+ lastError = await res.text();
139
+ }
140
+ } catch (err) {
141
+ lastError = err.message;
142
+ }
143
+ }
110
144
 
111
- if (!response.ok) {
112
- const errorText = await response.text();
113
- throw new Error(`Google API Error (${response.status}): ${errorText}`);
145
+ if (!response) {
146
+ throw new Error(`Google Antigravity Upstream Error: ${lastError}`);
114
147
  }
115
148
 
116
149
  const reader = response.body.getReader();