@openclaw/venice-provider 2026.10.10-beta.5 → 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.
- package/dist/.setup/{models-D73jPrCr.mjs → models-ZOIqXP1y.mjs} +13 -23
- package/dist/.source-module-urls/88442fd9d00c944bdd8e06deff0e58ad3961475f64178d6bd2080dae7f922b01.json +1 -0
- package/dist/api.js +1 -1
- package/dist/index.js +77 -17
- package/dist/models.js +1 -1
- package/dist/onboard.js +2 -3
- package/dist/pricing-api.js +1 -2
- package/dist/provider-catalog.js +3 -4
- package/dist/stream.js +79 -95
- package/package.json +4 -4
- package/dist/.source-module-urls/370c3afd778019a5d1f3d8dbc23d6b701833af80f2e2167c64091d0bbaa95402.json +0 -1
- package/dist/usage.js +0 -76
|
@@ -1,7 +1,8 @@
|
|
|
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 = {
|
|
6
7
|
id: "venice",
|
|
7
8
|
categories: ["models"],
|
|
@@ -369,8 +370,7 @@ var openclaw_plugin_default = {
|
|
|
369
370
|
"discovery": { "venice": "refreshable" }
|
|
370
371
|
}
|
|
371
372
|
};
|
|
372
|
-
|
|
373
|
-
//#region extensions/venice/models.ts
|
|
373
|
+
// extensions/venice/models.ts
|
|
374
374
|
const VENICE_MANIFEST_CATALOG = openclaw_plugin_default.modelCatalog.providers.venice;
|
|
375
375
|
const VENICE_BASE_URL = VENICE_MANIFEST_CATALOG.baseUrl;
|
|
376
376
|
const VENICE_DEFAULT_MODEL_REF = readManifestProviderDefaultModelRef(openclaw_plugin_default, "venice");
|
|
@@ -389,17 +389,6 @@ const VENICE_MODEL_CATALOG = buildManifestModelProviderConfig({
|
|
|
389
389
|
providerId: "venice",
|
|
390
390
|
catalog: VENICE_MANIFEST_CATALOG
|
|
391
391
|
}).models;
|
|
392
|
-
function normalizePositiveInt(value) {
|
|
393
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return;
|
|
394
|
-
return Math.floor(value);
|
|
395
|
-
}
|
|
396
|
-
function resolveApiMaxCompletionTokens(params) {
|
|
397
|
-
const raw = normalizePositiveInt(params.apiModel.model_spec?.maxCompletionTokens);
|
|
398
|
-
if (!raw) return;
|
|
399
|
-
const contextWindow = normalizePositiveInt(params.apiModel.model_spec?.availableContextTokens);
|
|
400
|
-
const knownMaxTokens = typeof params.knownMaxTokens === "number" && Number.isFinite(params.knownMaxTokens) ? Math.floor(params.knownMaxTokens) : void 0;
|
|
401
|
-
return Math.min(raw, contextWindow ?? knownMaxTokens ?? VENICE_DEFAULT_CONTEXT_WINDOW, knownMaxTokens ?? VENICE_DISCOVERY_HARD_MAX_TOKENS);
|
|
402
|
-
}
|
|
403
392
|
function projectVeniceModels(rows, fallback) {
|
|
404
393
|
const catalogById = new Map(fallback.models.map((model) => [model.id, model]));
|
|
405
394
|
const models = [];
|
|
@@ -409,17 +398,19 @@ function projectVeniceModels(rows, fallback) {
|
|
|
409
398
|
if (typeof apiModel.id !== "string" || !apiModel.id.trim()) continue;
|
|
410
399
|
const catalogEntry = catalogById.get(apiModel.id);
|
|
411
400
|
const liveCost = parseVeniceModelPricing(apiModel.model_spec?.pricing);
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
+
}
|
|
416
409
|
const supportsTools = apiModel.model_spec?.capabilities?.supportsFunctionCalling;
|
|
417
410
|
if (catalogEntry) {
|
|
418
411
|
const definition = {
|
|
419
412
|
...catalogEntry,
|
|
420
|
-
|
|
421
|
-
cost: liveCost ?? { ...catalogEntry.cost },
|
|
422
|
-
...catalogEntry.compat ? { compat: { ...catalogEntry.compat } } : {}
|
|
413
|
+
cost: liveCost ?? catalogEntry.cost
|
|
423
414
|
};
|
|
424
415
|
if (apiMaxTokens !== void 0) definition.maxTokens = apiMaxTokens;
|
|
425
416
|
if (supportsTools === false) definition.compat = {
|
|
@@ -438,7 +429,7 @@ function projectVeniceModels(rows, fallback) {
|
|
|
438
429
|
reasoning: isReasoning,
|
|
439
430
|
input: hasVision ? ["text", "image"] : ["text"],
|
|
440
431
|
cost: liveCost ?? VENICE_DEFAULT_COST,
|
|
441
|
-
contextWindow:
|
|
432
|
+
contextWindow: floorPositiveFiniteNumber(apiSpec?.availableContextTokens) ?? VENICE_DEFAULT_CONTEXT_WINDOW,
|
|
442
433
|
maxTokens: apiMaxTokens ?? VENICE_DEFAULT_MAX_TOKENS,
|
|
443
434
|
compat: {
|
|
444
435
|
supportsUsageInStreaming: false,
|
|
@@ -455,5 +446,4 @@ const VENICE_MODEL_DISCOVERY_OPTIONS = {
|
|
|
455
446
|
authentication: "none",
|
|
456
447
|
projectRows: projectVeniceModels
|
|
457
448
|
};
|
|
458
|
-
//#endregion
|
|
459
449
|
export { openclaw_plugin_default as a, VENICE_MODEL_DISCOVERY_OPTIONS as i, VENICE_DEFAULT_MODEL_REF as n, VENICE_MODEL_CATALOG as r, VENICE_BASE_URL as t };
|
|
@@ -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-
|
|
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-
|
|
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 =
|
|
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,16 +53,76 @@ var venice_default = defineSingleProviderPluginEntry({
|
|
|
53
53
|
}) : normalized;
|
|
54
54
|
},
|
|
55
55
|
wrapStreamFn: (ctx) => createVeniceStreamWrapper(ctx.streamFn),
|
|
56
|
-
resolveUsageAuth:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
//#endregion
|
|
68
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-
|
|
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,6 +1,6 @@
|
|
|
1
|
-
import { n as VENICE_DEFAULT_MODEL_REF, r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-
|
|
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({
|
|
5
5
|
primaryModelRef: VENICE_DEFAULT_MODEL_REF,
|
|
6
6
|
resolveParams: () => ({
|
|
@@ -14,5 +14,4 @@ const { applyConfig: applyVeniceConfig } = createProviderConnectionPresetApplier
|
|
|
14
14
|
}]
|
|
15
15
|
})
|
|
16
16
|
});
|
|
17
|
-
//#endregion
|
|
18
17
|
export { applyVeniceConfig };
|
package/dist/pricing-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asFiniteNumberInRange, asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { normalizeModelPricingCatalog } from "openclaw/plugin-sdk/model-catalog-pricing";
|
|
3
|
-
|
|
3
|
+
// extensions/venice/pricing-api.ts
|
|
4
4
|
function readVeniceRates(value) {
|
|
5
5
|
const row = asOptionalRecord(value);
|
|
6
6
|
const [input, output, cacheRead, cacheWrite] = [
|
|
@@ -50,5 +50,4 @@ function parseVeniceModelPricing(value) {
|
|
|
50
50
|
function parseVenicePricingCatalog(payload) {
|
|
51
51
|
return normalizeModelPricingCatalog(asOptionalRecord(payload)?.data, parseVeniceModelPricing, { readPricing: (model) => model.type === "text" ? asOptionalRecord(model.model_spec)?.pricing : void 0 });
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { parseVeniceModelPricing, parseVenicePricingCatalog };
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-
|
|
2
|
-
|
|
1
|
+
import { r as VENICE_MODEL_CATALOG, t as VENICE_BASE_URL } from "./.setup/models-ZOIqXP1y.mjs";
|
|
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:
|
|
7
|
+
models: VENICE_MODEL_CATALOG
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
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
|
-
|
|
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
|
-
}
|
|
3
|
+
// extensions/venice/stream.ts
|
|
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" &&
|
|
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,8 +21,83 @@ function createVeniceStreamWrapper(baseStreamFn) {
|
|
|
112
21
|
replaceNullReasoningContent: true
|
|
113
22
|
});
|
|
114
23
|
}
|
|
115
|
-
|
|
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
|
-
//#endregion
|
|
119
103
|
export { createVeniceStreamWrapper };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/venice-provider",
|
|
3
|
-
"version": "2026.
|
|
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.
|
|
17
|
+
"pluginApi": ">=2026.11.5-beta.1"
|
|
18
18
|
},
|
|
19
19
|
"build": {
|
|
20
|
-
"openclawVersion": "2026.
|
|
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.
|
|
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-D73jPrCr.mjs","sha256":"756b00853c77002b12b97051114d97fb5576e76146c79b489a987c42130f3748","facadeSource":null,"sources":["extensions/venice/models.ts","extensions/venice/openclaw.plugin.json"]},{"output":"api.js","sha256":"6d3d96fb74da771c848bb2722baaa6cca5e9844d3cf660ea13477f463f5b96f9","facadeSource":"extensions/venice/api.ts","sources":[]},{"output":"index.js","sha256":"62026e0efc9780af28a9912db065254fc3bf70bb5ae8571694b9475e5a09aa7f","facadeSource":"extensions/venice/index.ts","sources":["extensions/venice/index.ts"]},{"output":"models.js","sha256":"16534440f58cd6baf2d02d91ddfeb23f476d73fe077a3540ad925a792dcaaed0","facadeSource":"extensions/venice/models.ts","sources":[]},{"output":"onboard.js","sha256":"ed10d9c8151f81131e73bddcb9ca996633f24c76962ff8bf30ed634364e0e0ff","facadeSource":"extensions/venice/onboard.ts","sources":["extensions/venice/onboard.ts"]},{"output":"pricing-api.js","sha256":"19d663f3b05ced3c05908f78f4034fc13cad3403543ee695199137eda2a58748","facadeSource":"extensions/venice/pricing-api.ts","sources":["extensions/venice/pricing-api.ts"]},{"output":"provider-catalog.js","sha256":"b0f25583fbd5a244a6cfa4f5b406d39e63422b803633247b20b8538147d546f9","facadeSource":"extensions/venice/provider-catalog.ts","sources":["extensions/venice/provider-catalog.ts"]},{"output":"stream.js","sha256":"31bb88ff33ad413a01a691576c6616f3e9bf45d927cab2cb1159b33f9b203f62","facadeSource":"extensions/venice/stream.ts","sources":["extensions/venice/stream.ts"]},{"output":"usage.js","sha256":"33dd3d519baaf914fa8b67bb6a3b55738a901e9e854237ee8399497e88f666e0","facadeSource":"extensions/venice/usage.ts","sources":["extensions/venice/usage.ts"]}],"unrenderedSources":["extensions/venice/api.ts"]}
|
package/dist/usage.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { readProviderJsonObjectResponse } from "openclaw/plugin-sdk/provider-http";
|
|
2
|
-
import { buildUsageErrorSnapshot, buildUsageHttpErrorSnapshot, parseProviderUsageNonNegativeNumber } from "openclaw/plugin-sdk/provider-usage";
|
|
3
|
-
//#region 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
|
-
//#endregion
|
|
76
|
-
export { fetchVeniceUsage };
|