@openclaw/venice-provider 2026.7.2-beta.7 → 2026.8.1-beta.2

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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as openclaw_plugin_default, i as VENICE_MODEL_DISCOVERY_OPTIONS } from "./models-B-tcQZD0.js";
2
2
  import { applyVeniceConfig } from "./onboard.js";
3
3
  import { buildStaticVeniceProvider } from "./provider-catalog.js";
4
- import { createVeniceDeepSeekV4Wrapper } from "./stream.js";
4
+ import { createVeniceStreamWrapper } from "./stream.js";
5
5
  import { fetchVeniceUsage } from "./usage.js";
6
6
  import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
7
7
  import { applyModelCompatPatch } from "openclaw/plugin-sdk/provider-model-shared";
@@ -48,7 +48,7 @@ var venice_default = defineSingleProviderPluginEntry({
48
48
  liveModelDiscovery: VENICE_MODEL_DISCOVERY_OPTIONS
49
49
  },
50
50
  normalizeResolvedModel: ({ modelId, model }) => isXaiBackedVeniceModel(modelId) ? applyXaiModelCompat(model) : void 0,
51
- wrapStreamFn: (ctx) => createVeniceDeepSeekV4Wrapper(ctx.streamFn, ctx.thinkingLevel),
51
+ wrapStreamFn: (ctx) => createVeniceStreamWrapper(ctx.streamFn, ctx.thinkingLevel),
52
52
  resolveUsageAuth: async (ctx) => {
53
53
  const apiKey = ctx.resolveApiKeyFromConfigAndStore({ envDirect: [ctx.env.VENICE_API_KEY] });
54
54
  return apiKey ? { token: apiKey } : null;
package/dist/stream.js CHANGED
@@ -3,8 +3,105 @@ import { createPayloadPatchStreamWrapper, normalizeOpenAICompatibleReasoningRepl
3
3
  function isVeniceDeepSeekV4ModelId(modelId) {
4
4
  return modelId === "deepseek-v4-flash" || modelId === "deepseek-v4-pro";
5
5
  }
6
- function createVeniceDeepSeekV4Wrapper(baseStreamFn, thinkingLevel) {
7
- return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload, model }) => {
6
+ function isVeniceGeminiModelId(modelId) {
7
+ return typeof modelId === "string" && modelId.trim().toLowerCase().startsWith("gemini-");
8
+ }
9
+ function isVeniceGemini3ModelId(modelId) {
10
+ return typeof modelId === "string" && /^gemini-3(?:[.-]|$)/.test(modelId.trim().toLowerCase());
11
+ }
12
+ function stringifyHistoricalValue(value) {
13
+ if (typeof value === "string") return value;
14
+ if (value === null || value === void 0) return "";
15
+ try {
16
+ return JSON.stringify(value);
17
+ } catch {
18
+ return "[Unserializable historical value]";
19
+ }
20
+ }
21
+ function describeHistoricalToolCall(toolCall) {
22
+ const fn = toolCall.function && typeof toolCall.function === "object" ? toolCall.function : {};
23
+ const name = typeof fn.name === "string" && fn.name.length > 0 ? fn.name : "unknown_tool";
24
+ const args = stringifyHistoricalValue(fn.arguments) || "{}";
25
+ return {
26
+ ...typeof toolCall.id === "string" ? { id: toolCall.id } : {},
27
+ name,
28
+ text: `[Historical tool call: ${name}(${args})]`
29
+ };
30
+ }
31
+ function applyVeniceGeminiToolHistoryCompatibility(payload, context, model) {
32
+ if (model.provider !== "venice" || !isVeniceGeminiModelId(model.id)) return;
33
+ const historicalToolCallBatches = [];
34
+ let hasHistoricalSignature = false;
35
+ const requiresUnsignedCallFallback = isVeniceGemini3ModelId(model.id);
36
+ for (const message of context.messages ?? []) {
37
+ if (message.role !== "assistant" || message.stopReason === "error" || message.stopReason === "aborted") continue;
38
+ const isExactRoute = message.api === model.api && message.provider === model.provider && message.model === model.id;
39
+ const batch = [];
40
+ for (const block of message.content) {
41
+ if (block.type !== "toolCall" || typeof block.id !== "string") continue;
42
+ const thoughtSignature = isExactRoute && typeof block.thoughtSignature === "string" && block.thoughtSignature.length > 0 ? block.thoughtSignature : void 0;
43
+ hasHistoricalSignature ||= thoughtSignature !== void 0;
44
+ batch.push({
45
+ id: block.id,
46
+ name: block.name,
47
+ ...thoughtSignature ? { thoughtSignature } : {}
48
+ });
49
+ }
50
+ if (batch.length > 0) historicalToolCallBatches.push(batch);
51
+ }
52
+ if (!hasHistoricalSignature && !requiresUnsignedCallFallback || !Array.isArray(payload.messages)) return;
53
+ let historicalBatchIndex = 0;
54
+ let pendingDowngradedToolCalls;
55
+ for (const message of payload.messages) {
56
+ if (!message || typeof message !== "object") {
57
+ pendingDowngradedToolCalls = void 0;
58
+ continue;
59
+ }
60
+ const record = message;
61
+ if (record.role === "tool") {
62
+ const toolCallId = typeof record.tool_call_id === "string" ? record.tool_call_id : void 0;
63
+ if (!toolCallId) continue;
64
+ const pendingCalls = pendingDowngradedToolCalls;
65
+ if (!pendingCalls) continue;
66
+ const toolNames = pendingCalls.get(toolCallId);
67
+ if (!toolNames) continue;
68
+ const toolName = toolNames.shift();
69
+ if (!toolName) continue;
70
+ if (toolNames.length === 0) pendingCalls.delete(toolCallId);
71
+ const result = stringifyHistoricalValue(record.content);
72
+ for (const key of Object.keys(record)) delete record[key];
73
+ record.role = "user";
74
+ record.content = `[Historical tool result for ${toolName}:\n${result}]`;
75
+ continue;
76
+ }
77
+ pendingDowngradedToolCalls = void 0;
78
+ if (record.role !== "assistant" || !Array.isArray(record.tool_calls)) continue;
79
+ const historicalBatch = historicalToolCallBatches[historicalBatchIndex++];
80
+ let shouldDowngradeBatch = false;
81
+ const describedCalls = [];
82
+ for (const [toolCallIndex, toolCall] of record.tool_calls.entries()) {
83
+ if (!toolCall || typeof toolCall !== "object") continue;
84
+ const toolCallRecord = toolCall;
85
+ const historicalCall = historicalBatch?.[toolCallIndex];
86
+ const describedCall = describeHistoricalToolCall(toolCallRecord);
87
+ const signature = historicalCall && historicalCall.id === toolCallRecord.id && historicalCall.name === describedCall.name ? historicalCall.thoughtSignature : void 0;
88
+ if (signature) toolCallRecord.thought_signature = signature;
89
+ else if (requiresUnsignedCallFallback) shouldDowngradeBatch = true;
90
+ describedCalls.push(describedCall);
91
+ }
92
+ if (!shouldDowngradeBatch) continue;
93
+ pendingDowngradedToolCalls = /* @__PURE__ */ new Map();
94
+ for (const call of describedCalls) if (call.id) {
95
+ const names = pendingDowngradedToolCalls.get(call.id) ?? [];
96
+ names.push(call.name);
97
+ pendingDowngradedToolCalls.set(call.id, names);
98
+ }
99
+ record.content = [stringifyHistoricalValue(record.content), ...describedCalls.map((call) => call.text)].filter((part) => part.length > 0).join("\n");
100
+ delete record.tool_calls;
101
+ }
102
+ }
103
+ function createVeniceStreamWrapper(baseStreamFn, thinkingLevel) {
104
+ return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload, context, model }) => {
8
105
  if (model.provider === "venice" && isVeniceDeepSeekV4ModelId(model.id)) {
9
106
  delete payload.thinking;
10
107
  delete payload.reasoning;
@@ -14,7 +111,8 @@ function createVeniceDeepSeekV4Wrapper(baseStreamFn, thinkingLevel) {
14
111
  replaceNullReasoningContent: true
15
112
  });
16
113
  }
114
+ applyVeniceGeminiToolHistoryCompatibility(payload, context, model);
17
115
  });
18
116
  }
19
117
  //#endregion
20
- export { createVeniceDeepSeekV4Wrapper };
118
+ export { createVeniceStreamWrapper };
package/dist/usage.js CHANGED
@@ -1,12 +1,8 @@
1
1
  import { readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
2
- import { buildUsageHttpErrorSnapshot } from "openclaw/plugin-sdk/provider-usage";
2
+ import { buildUsageHttpErrorSnapshot, parseProviderUsageNonNegativeNumber } from "openclaw/plugin-sdk/provider-usage";
3
3
  //#region extensions/venice/usage.ts
4
4
  const VENICE_BALANCE_URL = "https://api.venice.ai/api/v1/billing/balance";
5
5
  const VENICE_USAGE_RESPONSE_MAX_BYTES = 1024 * 1024;
6
- function nonNegativeNumber(value) {
7
- const parsed = typeof value === "number" ? value : typeof value === "string" && value.trim() ? Number(value) : NaN;
8
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
9
- }
10
6
  async function readPayload(response, timeoutMs) {
11
7
  return await readProviderJsonObjectResponse(response, "Venice usage", {
12
8
  maxBytes: VENICE_USAGE_RESPONSE_MAX_BYTES,
@@ -50,9 +46,9 @@ async function fetchVeniceUsage(params) {
50
46
  error: "Malformed usage response"
51
47
  };
52
48
  }
53
- const diem = nonNegativeNumber(data.balances?.diem);
54
- const usd = nonNegativeNumber(data.balances?.usd);
55
- const allocation = nonNegativeNumber(data.diemEpochAllocation);
49
+ const diem = parseProviderUsageNonNegativeNumber(data.balances?.diem);
50
+ const usd = parseProviderUsageNonNegativeNumber(data.balances?.usd);
51
+ const allocation = parseProviderUsageNonNegativeNumber(data.diemEpochAllocation);
56
52
  const windows = [];
57
53
  if (diem !== void 0 && allocation !== void 0 && allocation > 0) windows.push({
58
54
  label: "DIEM epoch",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/venice-provider",
3
- "version": "2026.7.2-beta.7",
3
+ "version": "2026.8.1-beta.2",
4
4
  "description": "OpenClaw Venice provider plugin",
5
5
  "type": "module",
6
6
  "openclaw": {
@@ -14,10 +14,10 @@
14
14
  "minHostVersion": ">=2026.6.9"
15
15
  },
16
16
  "compat": {
17
- "pluginApi": ">=2026.7.2-beta.7"
17
+ "pluginApi": ">=2026.8.1-beta.2"
18
18
  },
19
19
  "build": {
20
- "openclawVersion": "2026.7.2-beta.7",
20
+ "openclawVersion": "2026.8.1-beta.2",
21
21
  "bundledDist": false
22
22
  },
23
23
  "release": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "openclaw": ">=2026.7.2-beta.7"
41
+ "openclaw": ">=2026.8.1-beta.2"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {