@openclaw/venice-provider 2026.10.10 → 2026.11.5-beta.1

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.
@@ -1,5 +1,6 @@
1
1
  import { parseVeniceModelPricing } from "../pricing-api.js";
2
2
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { floorPositiveFiniteNumber } from "openclaw/plugin-sdk/number-runtime";
3
4
  import { buildManifestModelProviderConfig, readManifestProviderDefaultModelRef } from "openclaw/plugin-sdk/provider-catalog-shared";
4
5
  // extensions/venice/openclaw.plugin.json
5
6
  var openclaw_plugin_default = {
@@ -388,17 +389,6 @@ const VENICE_MODEL_CATALOG = buildManifestModelProviderConfig({
388
389
  providerId: "venice",
389
390
  catalog: VENICE_MANIFEST_CATALOG
390
391
  }).models;
391
- function normalizePositiveInt(value) {
392
- if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
393
- return Math.floor(value);
394
- }
395
- function resolveApiMaxCompletionTokens(params) {
396
- const raw = normalizePositiveInt(params.apiModel.model_spec?.maxCompletionTokens);
397
- if (!raw) return;
398
- const contextWindow = normalizePositiveInt(params.apiModel.model_spec?.availableContextTokens);
399
- const knownMaxTokens = typeof params.knownMaxTokens === "number" && Number.isFinite(params.knownMaxTokens) ? Math.floor(params.knownMaxTokens) : void 0;
400
- return Math.min(raw, contextWindow ?? knownMaxTokens ?? VENICE_DEFAULT_CONTEXT_WINDOW, knownMaxTokens ?? VENICE_DISCOVERY_HARD_MAX_TOKENS);
401
- }
402
392
  function projectVeniceModels(rows, fallback) {
403
393
  const catalogById = new Map(fallback.models.map((model) => [model.id, model]));
404
394
  const models = [];
@@ -408,17 +398,19 @@ function projectVeniceModels(rows, fallback) {
408
398
  if (typeof apiModel.id !== "string" || !apiModel.id.trim()) continue;
409
399
  const catalogEntry = catalogById.get(apiModel.id);
410
400
  const liveCost = parseVeniceModelPricing(apiModel.model_spec?.pricing);
411
- const apiMaxTokens = resolveApiMaxCompletionTokens({
412
- apiModel,
413
- knownMaxTokens: catalogEntry?.maxTokens
414
- });
401
+ const knownMaxTokens = catalogEntry?.maxTokens;
402
+ const raw = floorPositiveFiniteNumber(apiModel.model_spec?.maxCompletionTokens);
403
+ let apiMaxTokens;
404
+ if (raw) {
405
+ const contextWindow = floorPositiveFiniteNumber(apiModel.model_spec?.availableContextTokens);
406
+ const knownCap = knownMaxTokens === void 0 ? void 0 : Math.floor(knownMaxTokens);
407
+ apiMaxTokens = Math.min(raw, contextWindow ?? knownCap ?? VENICE_DEFAULT_CONTEXT_WINDOW, knownCap ?? VENICE_DISCOVERY_HARD_MAX_TOKENS);
408
+ }
415
409
  const supportsTools = apiModel.model_spec?.capabilities?.supportsFunctionCalling;
416
410
  if (catalogEntry) {
417
411
  const definition = {
418
412
  ...catalogEntry,
419
- input: [...catalogEntry.input],
420
- cost: liveCost ?? { ...catalogEntry.cost },
421
- ...catalogEntry.compat ? { compat: { ...catalogEntry.compat } } : {}
413
+ cost: liveCost ?? catalogEntry.cost
422
414
  };
423
415
  if (apiMaxTokens !== void 0) definition.maxTokens = apiMaxTokens;
424
416
  if (supportsTools === false) definition.compat = {
@@ -437,7 +429,7 @@ function projectVeniceModels(rows, fallback) {
437
429
  reasoning: isReasoning,
438
430
  input: hasVision ? ["text", "image"] : ["text"],
439
431
  cost: liveCost ?? VENICE_DEFAULT_COST,
440
- contextWindow: normalizePositiveInt(apiSpec?.availableContextTokens) ?? VENICE_DEFAULT_CONTEXT_WINDOW,
432
+ contextWindow: floorPositiveFiniteNumber(apiSpec?.availableContextTokens) ?? VENICE_DEFAULT_CONTEXT_WINDOW,
441
433
  maxTokens: apiMaxTokens ?? VENICE_DEFAULT_MAX_TOKENS,
442
434
  compat: {
443
435
  supportsUsageInStreaming: false,
@@ -0,0 +1 @@
1
+ {"version":3,"entries":[{"output":"api.js","source":"extensions/venice/api.ts"},{"output":"index.js","source":"extensions/venice/index.ts"},{"output":"models.js","source":"extensions/venice/models.ts"},{"output":"onboard.js","source":"extensions/venice/onboard.ts"},{"output":"pricing-api.js","source":"extensions/venice/pricing-api.ts"},{"output":"provider-catalog.js","source":"extensions/venice/provider-catalog.ts"},{"output":"stream.js","source":"extensions/venice/stream.ts"}],"chunks":[{"output":".setup/models-ZOIqXP1y.mjs","sha256":"e1b7d1a8e7e70102c51a63e8b057d35d2446dad876c93ff41af8d08912ee6dbd","facadeSource":null,"sources":["extensions/venice/models.ts","extensions/venice/openclaw.plugin.json"]},{"output":"api.js","sha256":"94b8052dadae92cb8f56622540d4f2a2feb5313331cef2ee9b9ce55d80817c25","facadeSource":"extensions/venice/api.ts","sources":[]},{"output":"index.js","sha256":"b3e05c107292767d28e71f7781472d35e886703717ec651411a1e9f207d934d7","facadeSource":"extensions/venice/index.ts","sources":["extensions/venice/index.ts"]},{"output":"models.js","sha256":"28a38b81587718fd3cac87710e3bbce722165cbe200bb834a1908f437bb8fc3a","facadeSource":"extensions/venice/models.ts","sources":[]},{"output":"onboard.js","sha256":"761c4f9eb4f2fac0b4b531f51db847c9792f39743f74632d6f61430abf5348d7","facadeSource":"extensions/venice/onboard.ts","sources":["extensions/venice/onboard.ts"]},{"output":"pricing-api.js","sha256":"ce228915187a0739fbea273f4545f21b1de7e49b3a5b41e13efd540a0e89ac83","facadeSource":"extensions/venice/pricing-api.ts","sources":["extensions/venice/pricing-api.ts"]},{"output":"provider-catalog.js","sha256":"a91a51a5881f76a3e378860fbd8a79e3196458b21d212acce3f20dbaa576ddfe","facadeSource":"extensions/venice/provider-catalog.ts","sources":["extensions/venice/provider-catalog.ts"]},{"output":"stream.js","sha256":"754eb6ef1a1847d413260aac3ba69ea706a8957293eb007a6f5ecfea37067e87","facadeSource":"extensions/venice/stream.ts","sources":["extensions/venice/stream.ts"]}],"unrenderedSources":["extensions/venice/api.ts"]}
package/dist/api.js CHANGED
@@ -1 +1 @@
1
- export { t as VENICE_BASE_URL, n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG } from "./.setup/models-D2_M1haP.mjs";
1
+ export { t as VENICE_BASE_URL, n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG } from "./.setup/models-ZOIqXP1y.mjs";
package/dist/index.js CHANGED
@@ -1,13 +1,16 @@
1
- import { a as openclaw_plugin_default, i as VENICE_MODEL_DISCOVERY_OPTIONS, t as VENICE_BASE_URL } from "./.setup/models-D2_M1haP.mjs";
1
+ import { a as openclaw_plugin_default, i as VENICE_MODEL_DISCOVERY_OPTIONS, t as VENICE_BASE_URL } from "./.setup/models-ZOIqXP1y.mjs";
2
2
  import { applyVeniceConfig } from "./onboard.js";
3
3
  import { buildStaticVeniceProvider } from "./provider-catalog.js";
4
4
  import { createVeniceStreamWrapper } from "./stream.js";
5
- import { fetchVeniceUsage } from "./usage.js";
6
5
  import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
6
+ import { readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
7
7
  import { applyModelCompatPatch } from "openclaw/plugin-sdk/provider-model-shared";
8
+ import { buildUsageErrorSnapshot, buildUsageHttpErrorSnapshot, parseProviderUsageNonNegativeNumber, resolveProviderUsageApiKeyAuth } from "openclaw/plugin-sdk/provider-usage";
8
9
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
9
10
  // extensions/venice/index.ts
10
11
  const PROVIDER_ID = "venice";
12
+ const VENICE_BALANCE_URL = "https://api.venice.ai/api/v1/billing/balance";
13
+ const VENICE_USAGE_RESPONSE_MAX_BYTES = 1048576;
11
14
  const XAI_UNSUPPORTED_SCHEMA_KEYWORDS = [
12
15
  "minLength",
13
16
  "maxLength",
@@ -16,9 +19,6 @@ const XAI_UNSUPPORTED_SCHEMA_KEYWORDS = [
16
19
  "minContains",
17
20
  "maxContains"
18
21
  ];
19
- function isXaiBackedVeniceModel(modelId) {
20
- return normalizeLowercaseStringOrEmpty(modelId).includes("grok");
21
- }
22
22
  var venice_default = defineSingleProviderPluginEntry({
23
23
  id: PROVIDER_ID,
24
24
  name: "Venice Provider",
@@ -42,7 +42,7 @@ var venice_default = defineSingleProviderPluginEntry({
42
42
  liveModelDiscovery: VENICE_MODEL_DISCOVERY_OPTIONS
43
43
  },
44
44
  normalizeResolvedModel: ({ modelId, model }) => {
45
- const normalized = isXaiBackedVeniceModel(modelId) ? applyModelCompatPatch(model, {
45
+ const normalized = normalizeLowercaseStringOrEmpty(modelId).includes("grok") ? applyModelCompatPatch(model, {
46
46
  toolSchemaProfile: "xai",
47
47
  unsupportedToolSchemaKeywords: [...XAI_UNSUPPORTED_SCHEMA_KEYWORDS],
48
48
  toolCallArgumentsEncoding: "html-entities"
@@ -53,15 +53,76 @@ var venice_default = defineSingleProviderPluginEntry({
53
53
  }) : normalized;
54
54
  },
55
55
  wrapStreamFn: (ctx) => createVeniceStreamWrapper(ctx.streamFn),
56
- resolveUsageAuth: async (ctx) => {
57
- const apiKey = (await ctx.resolveApiKeyCandidatesFromConfigAndStore?.({ envDirect: [ctx.env.VENICE_API_KEY] }))?.[0];
58
- return apiKey ? { token: apiKey } : null;
59
- },
60
- fetchUsageSnapshot: async (ctx) => await fetchVeniceUsage({
61
- token: ctx.token,
62
- timeoutMs: ctx.timeoutMs,
63
- fetchFn: ctx.fetchFn
64
- })
56
+ resolveUsageAuth: (ctx) => resolveProviderUsageApiKeyAuth(ctx, [ctx.env.VENICE_API_KEY]),
57
+ fetchUsageSnapshot: async (ctx) => {
58
+ let response;
59
+ try {
60
+ response = await ctx.fetchFn(VENICE_BALANCE_URL, {
61
+ headers: {
62
+ Accept: "application/json",
63
+ Authorization: `Bearer ${ctx.token}`
64
+ },
65
+ signal: AbortSignal.timeout(ctx.timeoutMs)
66
+ });
67
+ } catch {
68
+ return buildUsageErrorSnapshot("venice", "Usage unavailable");
69
+ }
70
+ if (!response.ok) {
71
+ await response.body?.cancel().catch(() => void 0);
72
+ return buildUsageHttpErrorSnapshot({
73
+ provider: "venice",
74
+ status: response.status
75
+ });
76
+ }
77
+ let data;
78
+ try {
79
+ data = await readProviderJsonObjectResponse(response, "Venice usage", {
80
+ maxBytes: VENICE_USAGE_RESPONSE_MAX_BYTES,
81
+ chunkTimeoutMs: ctx.timeoutMs,
82
+ onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Venice usage response stalled for ${chunkTimeoutMs}ms`)
83
+ });
84
+ } catch {
85
+ return buildUsageErrorSnapshot("venice", "Malformed usage response");
86
+ }
87
+ const diem = parseProviderUsageNonNegativeNumber(data.balances?.diem);
88
+ const usd = parseProviderUsageNonNegativeNumber(data.balances?.usd);
89
+ const allocation = parseProviderUsageNonNegativeNumber(data.diemEpochAllocation);
90
+ const windows = [];
91
+ if (diem !== void 0 && allocation !== void 0 && allocation > 0) windows.push({
92
+ label: "DIEM epoch",
93
+ usedPercent: Math.min(100, Math.max(0, (allocation - diem) / allocation * 100))
94
+ });
95
+ const billing = [];
96
+ if (diem !== void 0) billing.push({
97
+ type: "balance",
98
+ label: "DIEM balance",
99
+ amount: diem,
100
+ unit: "DIEM"
101
+ });
102
+ if (usd !== void 0) billing.push({
103
+ type: "balance",
104
+ label: "USD balance",
105
+ amount: usd,
106
+ unit: "USD"
107
+ });
108
+ if (diem !== void 0 && allocation !== void 0 && allocation > 0) billing.push({
109
+ type: "budget",
110
+ label: "DIEM epoch",
111
+ used: Math.max(0, allocation - diem),
112
+ limit: allocation,
113
+ unit: "DIEM",
114
+ period: "epoch"
115
+ });
116
+ const consumptionCurrency = typeof data.consumptionCurrency === "string" ? data.consumptionCurrency.trim().toUpperCase() : "";
117
+ return {
118
+ provider: "venice",
119
+ displayName: "Venice",
120
+ windows,
121
+ ...billing.length > 0 ? { billing } : {},
122
+ ...consumptionCurrency ? { plan: `${consumptionCurrency} billing` } : {},
123
+ ...data.canConsume === false ? { summary: "API consumption unavailable" } : {}
124
+ };
125
+ }
65
126
  }
66
127
  });
67
128
  export { venice_default as default };
package/dist/models.js CHANGED
@@ -1 +1 @@
1
- export { t as VENICE_BASE_URL, n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG, i as VENICE_MODEL_DISCOVERY_OPTIONS } from "./.setup/models-D2_M1haP.mjs";
1
+ export { t as VENICE_BASE_URL, n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG, i as VENICE_MODEL_DISCOVERY_OPTIONS } from "./.setup/models-ZOIqXP1y.mjs";
package/dist/onboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-D2_M1haP.mjs";
1
+ import { n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-ZOIqXP1y.mjs";
2
2
  import { createProviderConnectionPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
3
3
  // extensions/venice/onboard.ts
4
4
  const { applyConfig: applyVeniceConfig } = createProviderConnectionPresetAppliers({
@@ -1,10 +1,10 @@
1
- import { r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-D2_M1haP.mjs";
1
+ import { r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-ZOIqXP1y.mjs";
2
2
  // extensions/venice/provider-catalog.ts
3
3
  function buildStaticVeniceProvider() {
4
4
  return {
5
5
  baseUrl: VENICE_BASE_URL,
6
6
  api: "openai-completions",
7
- models: structuredClone(VENICE_MODEL_CATALOG)
7
+ models: VENICE_MODEL_CATALOG
8
8
  };
9
9
  }
10
10
  export { buildStaticVeniceProvider };
package/dist/stream.js CHANGED
@@ -1,15 +1,6 @@
1
1
  import { asOptionalObjectRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
2
2
  import { createPayloadPatchStreamWrapper, normalizeOpenAICompatibleReasoningReplay } from "openclaw/plugin-sdk/provider-stream-shared";
3
3
  // extensions/venice/stream.ts
4
- function isVeniceDeepSeekV4ModelId(modelId) {
5
- return modelId === "deepseek-v4-flash" || modelId === "deepseek-v4-pro";
6
- }
7
- function isVeniceGeminiModelId(modelId) {
8
- return typeof modelId === "string" && modelId.trim().toLowerCase().startsWith("gemini-");
9
- }
10
- function isVeniceGemini3ModelId(modelId) {
11
- return typeof modelId === "string" && /^gemini-3(?:[.-]|$)/.test(modelId.trim().toLowerCase());
12
- }
13
4
  function stringifyHistoricalValue(value) {
14
5
  if (typeof value === "string") return value;
15
6
  if (value === null || value === void 0) return "";
@@ -19,91 +10,9 @@ function stringifyHistoricalValue(value) {
19
10
  return "[Unserializable historical value]";
20
11
  }
21
12
  }
22
- function describeHistoricalToolCall(toolCall) {
23
- const fn = asOptionalObjectRecord(toolCall.function);
24
- const name = typeof fn?.name === "string" && fn.name.length > 0 ? fn.name : "unknown_tool";
25
- const args = stringifyHistoricalValue(fn?.arguments) || "{}";
26
- return {
27
- ...typeof toolCall.id === "string" ? { id: toolCall.id } : {},
28
- name,
29
- text: `[Historical tool call: ${name}(${args})]`
30
- };
31
- }
32
- function applyVeniceGeminiToolHistoryCompatibility(payload, context, model) {
33
- if (model.provider !== "venice" || !isVeniceGeminiModelId(model.id)) return;
34
- const historicalToolCallBatches = [];
35
- let hasHistoricalSignature = false;
36
- const requiresUnsignedCallFallback = isVeniceGemini3ModelId(model.id);
37
- for (const message of context.messages ?? []) {
38
- if (message.role !== "assistant" || message.stopReason === "error" || message.stopReason === "aborted") continue;
39
- const isExactRoute = message.api === model.api && message.provider === model.provider && message.model === model.id;
40
- const batch = [];
41
- for (const block of message.content) {
42
- if (block.type !== "toolCall" || typeof block.id !== "string") continue;
43
- const thoughtSignature = isExactRoute && typeof block.thoughtSignature === "string" && block.thoughtSignature.length > 0 ? block.thoughtSignature : void 0;
44
- hasHistoricalSignature ||= thoughtSignature !== void 0;
45
- batch.push({
46
- id: block.id,
47
- name: block.name,
48
- ...thoughtSignature ? { thoughtSignature } : {}
49
- });
50
- }
51
- if (batch.length > 0) historicalToolCallBatches.push(batch);
52
- }
53
- if (!hasHistoricalSignature && !requiresUnsignedCallFallback || !Array.isArray(payload.messages)) return;
54
- let historicalBatchIndex = 0;
55
- let pendingDowngradedToolCalls;
56
- for (const message of payload.messages) {
57
- const record = asOptionalObjectRecord(message);
58
- if (!record) {
59
- pendingDowngradedToolCalls = void 0;
60
- continue;
61
- }
62
- if (record.role === "tool") {
63
- const toolCallId = typeof record.tool_call_id === "string" ? record.tool_call_id : void 0;
64
- if (!toolCallId) continue;
65
- const pendingCalls = pendingDowngradedToolCalls;
66
- if (!pendingCalls) continue;
67
- const toolNames = pendingCalls.get(toolCallId);
68
- if (!toolNames) continue;
69
- const toolName = toolNames.shift();
70
- if (!toolName) continue;
71
- if (toolNames.length === 0) pendingCalls.delete(toolCallId);
72
- const result = stringifyHistoricalValue(record.content);
73
- for (const key of Object.keys(record)) delete record[key];
74
- record.role = "user";
75
- record.content = `[Historical tool result for ${toolName}:\n${result}]`;
76
- continue;
77
- }
78
- pendingDowngradedToolCalls = void 0;
79
- if (record.role !== "assistant" || !Array.isArray(record.tool_calls)) continue;
80
- const historicalBatch = historicalToolCallBatches[historicalBatchIndex++];
81
- let shouldDowngradeBatch = false;
82
- const describedCalls = [];
83
- for (const [toolCallIndex, toolCall] of record.tool_calls.entries()) {
84
- const toolCallRecord = asOptionalObjectRecord(toolCall);
85
- if (!toolCallRecord) continue;
86
- const historicalCall = historicalBatch?.[toolCallIndex];
87
- const describedCall = describeHistoricalToolCall(toolCallRecord);
88
- const signature = historicalCall && historicalCall.id === toolCallRecord.id && historicalCall.name === describedCall.name ? historicalCall.thoughtSignature : void 0;
89
- if (signature) toolCallRecord.thought_signature = signature;
90
- else if (requiresUnsignedCallFallback) shouldDowngradeBatch = true;
91
- describedCalls.push(describedCall);
92
- }
93
- if (!shouldDowngradeBatch) continue;
94
- pendingDowngradedToolCalls = /* @__PURE__ */ new Map();
95
- for (const call of describedCalls) if (call.id) {
96
- const names = pendingDowngradedToolCalls.get(call.id) ?? [];
97
- names.push(call.name);
98
- pendingDowngradedToolCalls.set(call.id, names);
99
- }
100
- record.content = [stringifyHistoricalValue(record.content), ...describedCalls.map((call) => call.text)].filter((part) => part.length > 0).join("\n");
101
- delete record.tool_calls;
102
- }
103
- }
104
13
  function createVeniceStreamWrapper(baseStreamFn) {
105
14
  return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload, context, model }) => {
106
- if (model.provider === "venice" && isVeniceDeepSeekV4ModelId(model.id)) {
15
+ if (model.provider === "venice" && (model.id === "deepseek-v4-flash" || model.id === "deepseek-v4-pro")) {
107
16
  delete payload.thinking;
108
17
  delete payload.reasoning;
109
18
  delete payload.reasoning_effort;
@@ -112,7 +21,83 @@ function createVeniceStreamWrapper(baseStreamFn) {
112
21
  replaceNullReasoningContent: true
113
22
  });
114
23
  }
115
- applyVeniceGeminiToolHistoryCompatibility(payload, context, model);
24
+ if (model.provider !== "venice" || !model.id.trim().toLowerCase().startsWith("gemini-")) return;
25
+ const historicalToolCallBatches = [];
26
+ let hasHistoricalSignature = false;
27
+ const requiresUnsignedCallFallback = /^gemini-3(?:[.-]|$)/.test(model.id.trim().toLowerCase());
28
+ for (const message of context.messages) {
29
+ if (message.role !== "assistant" || message.stopReason === "error" || message.stopReason === "aborted") continue;
30
+ const isExactRoute = message.api === model.api && message.provider === model.provider && message.model === model.id;
31
+ const batch = [];
32
+ for (const block of message.content) {
33
+ if (block.type !== "toolCall") continue;
34
+ const thoughtSignature = isExactRoute ? block.thoughtSignature || void 0 : void 0;
35
+ hasHistoricalSignature ||= thoughtSignature !== void 0;
36
+ batch.push({
37
+ id: block.id,
38
+ name: block.name,
39
+ ...thoughtSignature ? { thoughtSignature } : {}
40
+ });
41
+ }
42
+ if (batch.length > 0) historicalToolCallBatches.push(batch);
43
+ }
44
+ if (!hasHistoricalSignature && !requiresUnsignedCallFallback || !Array.isArray(payload.messages)) return;
45
+ let historicalBatchIndex = 0;
46
+ let pendingDowngradedToolCalls;
47
+ for (const message of payload.messages) {
48
+ const record = asOptionalObjectRecord(message);
49
+ if (!record) {
50
+ pendingDowngradedToolCalls = void 0;
51
+ continue;
52
+ }
53
+ if (record.role === "tool") {
54
+ const toolCallId = typeof record.tool_call_id === "string" ? record.tool_call_id : void 0;
55
+ if (!toolCallId) continue;
56
+ const pendingCalls = pendingDowngradedToolCalls;
57
+ if (!pendingCalls) continue;
58
+ const toolNames = pendingCalls.get(toolCallId);
59
+ if (!toolNames) continue;
60
+ const toolName = toolNames.shift();
61
+ if (!toolName) continue;
62
+ if (toolNames.length === 0) pendingCalls.delete(toolCallId);
63
+ const result = stringifyHistoricalValue(record.content);
64
+ for (const key of Object.keys(record)) delete record[key];
65
+ record.role = "user";
66
+ record.content = `[Historical tool result for ${toolName}:\n${result}]`;
67
+ continue;
68
+ }
69
+ pendingDowngradedToolCalls = void 0;
70
+ if (record.role !== "assistant" || !Array.isArray(record.tool_calls)) continue;
71
+ const historicalBatch = historicalToolCallBatches[historicalBatchIndex++];
72
+ let shouldDowngradeBatch = false;
73
+ const describedCalls = [];
74
+ for (const [toolCallIndex, toolCall] of record.tool_calls.entries()) {
75
+ const toolCallRecord = asOptionalObjectRecord(toolCall);
76
+ if (!toolCallRecord) continue;
77
+ const historicalCall = historicalBatch?.[toolCallIndex];
78
+ const fn = asOptionalObjectRecord(toolCallRecord.function);
79
+ const name = typeof fn?.name === "string" && fn.name.length > 0 ? fn.name : "unknown_tool";
80
+ const args = stringifyHistoricalValue(fn?.arguments) || "{}";
81
+ const describedCall = {
82
+ ...typeof toolCallRecord.id === "string" ? { id: toolCallRecord.id } : {},
83
+ name,
84
+ text: `[Historical tool call: ${name}(${args})]`
85
+ };
86
+ const signature = historicalCall && historicalCall.id === toolCallRecord.id && historicalCall.name === describedCall.name ? historicalCall.thoughtSignature : void 0;
87
+ if (signature) toolCallRecord.thought_signature = signature;
88
+ else if (requiresUnsignedCallFallback) shouldDowngradeBatch = true;
89
+ describedCalls.push(describedCall);
90
+ }
91
+ if (!shouldDowngradeBatch) continue;
92
+ pendingDowngradedToolCalls = /* @__PURE__ */ new Map();
93
+ for (const call of describedCalls) if (call.id) {
94
+ const names = pendingDowngradedToolCalls.get(call.id) ?? [];
95
+ names.push(call.name);
96
+ pendingDowngradedToolCalls.set(call.id, names);
97
+ }
98
+ record.content = [stringifyHistoricalValue(record.content), ...describedCalls.map((call) => call.text)].filter((part) => part.length > 0).join("\n");
99
+ delete record.tool_calls;
100
+ }
116
101
  });
117
102
  }
118
103
  export { createVeniceStreamWrapper };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/venice-provider",
3
- "version": "2026.10.10",
3
+ "version": "2026.11.5-beta.1",
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.10.10"
17
+ "pluginApi": ">=2026.11.5-beta.1"
18
18
  },
19
19
  "build": {
20
- "openclawVersion": "2026.10.10",
20
+ "openclawVersion": "2026.11.5-beta.1",
21
21
  "bundledDist": false
22
22
  },
23
23
  "release": {
@@ -40,7 +40,7 @@
40
40
  "assets/activity.svg"
41
41
  ],
42
42
  "peerDependencies": {
43
- "openclaw": ">=2026.10.10"
43
+ "openclaw": ">=2026.11.5-beta.1"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "openclaw": {
@@ -1 +0,0 @@
1
- {"version":3,"entries":[{"output":"api.js","source":"extensions/venice/api.ts"},{"output":"index.js","source":"extensions/venice/index.ts"},{"output":"models.js","source":"extensions/venice/models.ts"},{"output":"onboard.js","source":"extensions/venice/onboard.ts"},{"output":"pricing-api.js","source":"extensions/venice/pricing-api.ts"},{"output":"provider-catalog.js","source":"extensions/venice/provider-catalog.ts"},{"output":"stream.js","source":"extensions/venice/stream.ts"},{"output":"usage.js","source":"extensions/venice/usage.ts"}],"chunks":[{"output":".setup/models-D2_M1haP.mjs","sha256":"f1a18955dd80e5eb9010b993041752ee05d54a79547b0df2d9c970207cc358d6","facadeSource":null,"sources":["extensions/venice/models.ts","extensions/venice/openclaw.plugin.json"]},{"output":"api.js","sha256":"7bb34be5e6d4ec8bb909074a5337318706d066a3f34331594f2cf1ef1a8fe650","facadeSource":"extensions/venice/api.ts","sources":[]},{"output":"index.js","sha256":"731ecdf1154f6fbf2654e4173c8fe96c680d1bee5a3bbfe2f462e4e4eb65d5e3","facadeSource":"extensions/venice/index.ts","sources":["extensions/venice/index.ts"]},{"output":"models.js","sha256":"9384ba29edc85a024bb6f59246b530bbe9b4e413c3c3c8896f8e1931aa23ff42","facadeSource":"extensions/venice/models.ts","sources":[]},{"output":"onboard.js","sha256":"cdb97e84fefa2318642fa76a560ab3adce42c79e6fc8578f7ea42f7aef83f3c3","facadeSource":"extensions/venice/onboard.ts","sources":["extensions/venice/onboard.ts"]},{"output":"pricing-api.js","sha256":"ce228915187a0739fbea273f4545f21b1de7e49b3a5b41e13efd540a0e89ac83","facadeSource":"extensions/venice/pricing-api.ts","sources":["extensions/venice/pricing-api.ts"]},{"output":"provider-catalog.js","sha256":"6fb1881ba867454028111612dc182379f9fd534aaf8861e0bd0379c4e1fb73e5","facadeSource":"extensions/venice/provider-catalog.ts","sources":["extensions/venice/provider-catalog.ts"]},{"output":"stream.js","sha256":"b10e6be3a7ee5b7684c3942b7649ba2ad848dc0d736de0750fa30b04e81fde53","facadeSource":"extensions/venice/stream.ts","sources":["extensions/venice/stream.ts"]},{"output":"usage.js","sha256":"962055e6385e1402fb99408c205c38c9908e088339247617eb382fc28ee51d12","facadeSource":"extensions/venice/usage.ts","sources":["extensions/venice/usage.ts"]}],"unrenderedSources":["extensions/venice/api.ts"]}
package/dist/usage.js DELETED
@@ -1,75 +0,0 @@
1
- import { readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
2
- import { buildUsageErrorSnapshot, buildUsageHttpErrorSnapshot, parseProviderUsageNonNegativeNumber } from "openclaw/plugin-sdk/provider-usage";
3
- // extensions/venice/usage.ts
4
- const VENICE_BALANCE_URL = "https://api.venice.ai/api/v1/billing/balance";
5
- const VENICE_USAGE_RESPONSE_MAX_BYTES = 1048576;
6
- async function fetchVeniceUsage(params) {
7
- let response;
8
- try {
9
- response = await params.fetchFn(VENICE_BALANCE_URL, {
10
- headers: {
11
- Accept: "application/json",
12
- Authorization: `Bearer ${params.token}`
13
- },
14
- signal: AbortSignal.timeout(params.timeoutMs)
15
- });
16
- } catch {
17
- return buildUsageErrorSnapshot("venice", "Usage unavailable");
18
- }
19
- if (!response.ok) {
20
- await response.body?.cancel().catch(() => void 0);
21
- return buildUsageHttpErrorSnapshot({
22
- provider: "venice",
23
- status: response.status
24
- });
25
- }
26
- let data;
27
- try {
28
- data = await readProviderJsonObjectResponse(response, "Venice usage", {
29
- maxBytes: VENICE_USAGE_RESPONSE_MAX_BYTES,
30
- chunkTimeoutMs: params.timeoutMs,
31
- onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Venice usage response stalled for ${chunkTimeoutMs}ms`)
32
- });
33
- } catch {
34
- return buildUsageErrorSnapshot("venice", "Malformed usage response");
35
- }
36
- const diem = parseProviderUsageNonNegativeNumber(data.balances?.diem);
37
- const usd = parseProviderUsageNonNegativeNumber(data.balances?.usd);
38
- const allocation = parseProviderUsageNonNegativeNumber(data.diemEpochAllocation);
39
- const windows = [];
40
- if (diem !== void 0 && allocation !== void 0 && allocation > 0) windows.push({
41
- label: "DIEM epoch",
42
- usedPercent: Math.min(100, Math.max(0, (allocation - diem) / allocation * 100))
43
- });
44
- const billing = [];
45
- if (diem !== void 0) billing.push({
46
- type: "balance",
47
- label: "DIEM balance",
48
- amount: diem,
49
- unit: "DIEM"
50
- });
51
- if (usd !== void 0) billing.push({
52
- type: "balance",
53
- label: "USD balance",
54
- amount: usd,
55
- unit: "USD"
56
- });
57
- if (diem !== void 0 && allocation !== void 0 && allocation > 0) billing.push({
58
- type: "budget",
59
- label: "DIEM epoch",
60
- used: Math.max(0, allocation - diem),
61
- limit: allocation,
62
- unit: "DIEM",
63
- period: "epoch"
64
- });
65
- const consumptionCurrency = typeof data.consumptionCurrency === "string" ? data.consumptionCurrency.trim().toUpperCase() : "";
66
- return {
67
- provider: "venice",
68
- displayName: "Venice",
69
- windows,
70
- ...billing.length > 0 ? { billing } : {},
71
- ...consumptionCurrency ? { plan: `${consumptionCurrency} billing` } : {},
72
- ...data.canConsume === false ? { summary: "API consumption unavailable" } : {}
73
- };
74
- }
75
- export { fetchVeniceUsage };