@lay111/dsh-plugin-google 1.0.4 → 1.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lay111/dsh-plugin-google",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
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/adapter.js CHANGED
@@ -24,24 +24,35 @@ export class AntigravityLlmAdapter {
24
24
  }));
25
25
  }
26
26
 
27
- async resolveModelInfo(provider, modelId, signal) {
27
+ async resolveModel(provider, modelId, signal) {
28
28
  const model = findModel(modelId);
29
29
  return {
30
30
  provider: 'antigravity',
31
31
  id: model.id,
32
32
  name: model.name,
33
- contextWindow: model.contextWindow,
34
- maxTokens: model.maxTokens,
35
- reasoningEfforts: model.supportsThinking
36
- ? [
37
- { id: 'high', name: 'High Thinking' },
38
- { id: 'low', name: 'Low Thinking' },
39
- ]
33
+ inputModalities: ['text'],
34
+ context: { contextWindow: model.contextWindow },
35
+ defaultMaxTokens: model.maxTokens,
36
+ reasoning: model.supportsThinking
37
+ ? {
38
+ efforts: [
39
+ { id: 'high', name: 'High' },
40
+ { id: 'off', name: 'Off' },
41
+ ],
42
+ defaultEffort: 'high',
43
+ }
40
44
  : undefined,
41
45
  };
42
46
  }
43
47
 
44
- async *generate(options, runtime) {
48
+ async prepareCall(provider, modelId, signal) {
49
+ return {
50
+ model: await this.resolveModel(provider, modelId, signal),
51
+ stream: (options) => this.stream(options),
52
+ };
53
+ }
54
+
55
+ async *stream(options) {
45
56
  const { accessToken, projectId } = await getValidAccessToken();
46
57
  yield* streamAntigravity(options, accessToken, projectId);
47
58
  }
package/src/api.js CHANGED
@@ -24,8 +24,8 @@ export function formatMessagesToAntigravity(messages, modelSpec, projectId) {
24
24
  for (const block of message.content) {
25
25
  if (block.type === 'text') {
26
26
  parts.push({ text: block.text });
27
- } else if (block.type === 'thought') {
28
- parts.push({ thought: true, text: block.text });
27
+ } else if (block.type === 'thought' || block.type === 'reasoning') {
28
+ parts.push({ thought: true, text: block.text || block.thought || '' });
29
29
  } else if (block.type === 'tool-call') {
30
30
  parts.push({
31
31
  functionCall: {
@@ -128,47 +128,53 @@ export async function* streamAntigravity(options, accessToken, projectId) {
128
128
  buffer = lines.pop() || '';
129
129
 
130
130
  for (const line of lines) {
131
- const trimmed = line.trim();
131
+ let trimmed = line.trim();
132
132
  if (!trimmed) continue;
133
+ if (trimmed.startsWith('data:')) {
134
+ trimmed = trimmed.slice(5).trim();
135
+ }
136
+ if (trimmed === '[DONE]') break;
133
137
 
134
138
  try {
135
- const item = JSON.parse(trimmed);
136
- const candidate = item.response?.candidates?.[0];
137
- if (!candidate) continue;
139
+ const items = Array.isArray(JSON.parse(trimmed)) ? JSON.parse(trimmed) : [JSON.parse(trimmed)];
140
+ for (const item of items) {
141
+ const candidate = item.response?.candidates?.[0] || item.candidates?.[0];
142
+ if (!candidate) continue;
143
+
144
+ for (const part of candidate.content?.parts || []) {
145
+ if (part.thought) {
146
+ yield {
147
+ type: 'reasoning-delta',
148
+ index: blockIndex,
149
+ text: part.text || '',
150
+ };
151
+ } else if (part.text) {
152
+ yield {
153
+ type: 'text-delta',
154
+ index: blockIndex,
155
+ text: part.text || '',
156
+ };
157
+ } else if (part.functionCall) {
158
+ const callId = `call_${Math.random().toString(36).slice(2, 10)}`;
159
+ yield {
160
+ type: 'tool-call-delta',
161
+ index: blockIndex++,
162
+ id: callId,
163
+ name: part.functionCall.name,
164
+ argumentsDelta: JSON.stringify(part.functionCall.args || {}),
165
+ };
166
+ }
167
+ }
138
168
 
139
- for (const part of candidate.content?.parts || []) {
140
- if (part.thought) {
141
- yield {
142
- type: 'reasoning-delta',
143
- index: blockIndex,
144
- text: part.text || '',
145
- };
146
- } else if (part.text) {
169
+ if (candidate.finishReason) {
147
170
  yield {
148
- type: 'text-delta',
149
- index: blockIndex,
150
- text: part.text || '',
151
- };
152
- } else if (part.functionCall) {
153
- const callId = `call_${Math.random().toString(36).slice(2, 10)}`;
154
- yield {
155
- type: 'tool-call-delta',
156
- index: blockIndex++,
157
- id: callId,
158
- name: part.functionCall.name,
159
- argumentsDelta: JSON.stringify(part.functionCall.args || {}),
171
+ type: 'finish',
172
+ reason: 'stop',
160
173
  };
161
174
  }
162
175
  }
163
-
164
- if (candidate.finishReason) {
165
- yield {
166
- type: 'finish',
167
- reason: candidate.finishReason.toLowerCase() === 'stop' ? 'stop' : 'stop',
168
- };
169
- }
170
176
  } catch {
171
- // ignore partial json
177
+ // ignore partial chunks
172
178
  }
173
179
  }
174
180
  }