@revojs/ai 0.2.33 → 0.2.36

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.
@@ -96,6 +96,14 @@ function toBody(options) {
96
96
  } catch {
97
97
  args = {};
98
98
  }
99
+ const signature = part.providerOptions?.google?.thoughtSignature;
100
+ if (typeof signature === "string") return [{
101
+ functionCall: {
102
+ name: part.toolName,
103
+ args
104
+ },
105
+ thoughtSignature: signature
106
+ }];
99
107
  return [{ functionCall: {
100
108
  name: part.toolName,
101
109
  args
@@ -115,6 +123,14 @@ function toBody(options) {
115
123
  });
116
124
  return [];
117
125
  });
126
+ let signed = false;
127
+ for (const part of parts) if (part.functionCall !== void 0 && part.thoughtSignature !== void 0) signed = true;
128
+ if (!signed) {
129
+ for (const part of parts) if (part.functionCall !== void 0) {
130
+ part.thoughtSignature = SKIP_THOUGHT_SIGNATURE;
131
+ break;
132
+ }
133
+ }
118
134
  if (parts.length > 0) contents.push({
119
135
  role: "model",
120
136
  parts
@@ -221,12 +237,14 @@ async function* readParts(response, warnings) {
221
237
  }
222
238
  if (part.functionCall !== void 0) {
223
239
  toolCalls = true;
224
- yield {
240
+ const call = {
225
241
  type: "tool-call",
226
242
  toolCallId: `gemini-tool-${toolCount++}`,
227
243
  toolName: part.functionCall.name ?? "",
228
244
  input: JSON.stringify(part.functionCall.args ?? {})
229
245
  };
246
+ if (part.thoughtSignature !== void 0) call.providerMetadata = { google: { thoughtSignature: part.thoughtSignature } };
247
+ yield call;
230
248
  continue;
231
249
  }
232
250
  if (typeof part.text === "string" && part.text.length > 0) {
@@ -280,12 +298,14 @@ function geminiGenerateProtocol(config) {
280
298
  }
281
299
  if (part.functionCall !== void 0) {
282
300
  toolCalls = true;
283
- content.push({
301
+ const call = {
284
302
  type: "tool-call",
285
303
  toolCallId: `gemini-tool-${toolCount++}`,
286
304
  toolName: part.functionCall.name ?? "",
287
305
  input: JSON.stringify(part.functionCall.args ?? {})
288
- });
306
+ };
307
+ if (part.thoughtSignature !== void 0) call.providerMetadata = { google: { thoughtSignature: part.thoughtSignature } };
308
+ content.push(call);
289
309
  continue;
290
310
  }
291
311
  if (typeof part.text === "string" && part.text.length > 0) content.push({
@@ -321,5 +341,6 @@ function geminiStreamProtocol(config) {
321
341
  };
322
342
  };
323
343
  }
344
+ var SKIP_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
324
345
  //#endregion
325
346
  export { geminiGenerateProtocol, geminiStreamProtocol };
@@ -2,6 +2,7 @@ import { defineProvider, modelsDevProtocol, useModelsDev } from "../index.js";
2
2
  import { messagesGenerateProtocol, messagesStreamProtocol } from "../protocols/anthropic-messages.js";
3
3
  import { chatCompletionsGenerateProtocol, chatCompletionsStreamProtocol } from "../protocols/openai-chat-completions.js";
4
4
  import { responsesGenerateProtocol, responsesStreamProtocol } from "../protocols/openai-responses.js";
5
+ import { geminiGenerateProtocol, geminiStreamProtocol } from "../protocols/google-models.js";
5
6
  import { useVariables } from "revojs";
6
7
  //#region src/providers/opencode-go.ts
7
8
  var opencode_go_default = defineProvider({ setup(scope) {
@@ -47,6 +48,16 @@ var opencode_go_default = defineProvider({ setup(scope) {
47
48
  };
48
49
  return useModelsDev("opencode-go", (model, provider) => {
49
50
  const protocol = modelsDevProtocol(model, provider);
51
+ if (protocol === "google-models") {
52
+ const google = {
53
+ baseURL: model.provider?.api ?? "https://opencode.ai/inference/go/google/v1beta",
54
+ apiKey: variables.opencodeApiKey
55
+ };
56
+ return {
57
+ textGenerate: withSession(geminiGenerateProtocol(google)),
58
+ textStream: withSession(geminiStreamProtocol(google))
59
+ };
60
+ }
50
61
  return protocol === void 0 ? void 0 : protocols[protocol];
51
62
  });
52
63
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revojs/ai",
3
- "version": "0.2.33",
3
+ "version": "0.2.36",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",