Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled

Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
2026-07-05 09:36:54 +00:00
parent 3216769225
commit bedb527145
21108 changed files with 6010766 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# Venice OpenClaw provider
Official OpenClaw provider plugin for Venice.
## Install
```sh
openclaw plugins install @openclaw/venice-provider
```
## Docs
See `docs/providers/venice.md` in the OpenClaw repository, or the published docs at `https://docs.openclaw.ai/providers/venice`.

9
extensions/venice/api.ts Normal file
View File

@@ -0,0 +1,9 @@
// Venice API module exposes the plugin public contract.
export {
buildVeniceModelDefinition,
discoverVeniceModels,
VENICE_BASE_URL,
VENICE_DEFAULT_MODEL_REF,
VENICE_MODEL_CATALOG,
} from "./models.js";
export { buildVeniceProvider } from "./provider-catalog.js";

View File

@@ -0,0 +1,110 @@
// Venice tests cover index plugin behavior.
import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";
import { describe, expect, it } from "vitest";
import plugin from "./index.js";
describe("venice provider plugin", () => {
it("applies the shared xAI compat patch to Grok-backed Venice models only", async () => {
const provider = await registerSingleProviderPlugin(plugin);
expect(
provider.normalizeResolvedModel?.({
modelId: "venice/grok-4",
model: {
id: "grok-4",
compat: {
supportsUsageInStreaming: true,
},
},
} as never),
).toEqual({
id: "grok-4",
compat: {
supportsUsageInStreaming: true,
toolSchemaProfile: "xai",
unsupportedToolSchemaKeywords: [
"minLength",
"maxLength",
"minItems",
"maxItems",
"minContains",
"maxContains",
],
nativeWebSearchTool: true,
toolCallArgumentsEncoding: "html-entities",
},
});
expect(
provider.normalizeResolvedModel?.({
modelId: "venice/llama-3.3-70b",
model: {
id: "llama-3.3-70b",
compat: {},
},
} as never),
).toBeUndefined();
});
it("fills missing DeepSeek V4 reasoning_content on Venice replay turns", async () => {
const provider = await registerSingleProviderPlugin(plugin);
const capturedPayloads: Record<string, unknown>[] = [];
const baseStreamFn = (_model: unknown, _context: unknown, options: unknown) => {
const payload = {
model: "deepseek-v4-pro",
thinking: { type: "enabled" },
reasoning_effort: "high",
messages: [
{
role: "assistant",
tool_calls: [
{
id: "call_1",
type: "function",
function: { name: "read", arguments: "{}" },
},
],
},
{ role: "assistant", content: "done" },
],
};
(options as { onPayload?: (payload: Record<string, unknown>) => void })?.onPayload?.(payload);
capturedPayloads.push(payload);
return {} as never;
};
const streamFn = provider.wrapStreamFn?.({
streamFn: baseStreamFn as never,
providerId: "venice",
modelId: "deepseek-v4-pro",
thinkingLevel: "high",
} as never);
expect(streamFn).toBeTypeOf("function");
await streamFn?.({ provider: "venice", id: "deepseek-v4-pro" } as never, {} as never, {});
expect(capturedPayloads).toEqual([
{
model: "deepseek-v4-pro",
messages: [
{
role: "assistant",
tool_calls: [
{
id: "call_1",
type: "function",
function: { name: "read", arguments: "{}" },
},
],
reasoning_content: "",
},
{
role: "assistant",
content: "done",
reasoning_content: "",
},
],
},
]);
});
});

View File

@@ -0,0 +1,71 @@
// Venice plugin entrypoint registers its OpenClaw integration.
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
import {
applyModelCompatPatch,
type ModelCompatConfig,
} from "openclaw/plugin-sdk/provider-model-shared";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
import { applyVeniceConfig, VENICE_DEFAULT_MODEL_REF } from "./onboard.js";
import { buildVeniceProvider } from "./provider-catalog.js";
import { createVeniceDeepSeekV4Wrapper } from "./stream.js";
const PROVIDER_ID = "venice";
const XAI_UNSUPPORTED_SCHEMA_KEYWORDS = [
"minLength",
"maxLength",
"minItems",
"maxItems",
"minContains",
"maxContains",
] as const;
function applyXaiModelCompat<T extends { compat?: unknown }>(model: T): T {
return applyModelCompatPatch(model as T & { compat?: ModelCompatConfig }, {
toolSchemaProfile: "xai",
unsupportedToolSchemaKeywords: [...XAI_UNSUPPORTED_SCHEMA_KEYWORDS],
nativeWebSearchTool: true,
toolCallArgumentsEncoding: "html-entities",
}) as T;
}
function isXaiBackedVeniceModel(modelId: string): boolean {
return normalizeLowercaseStringOrEmpty(modelId).includes("grok");
}
export default defineSingleProviderPluginEntry({
id: PROVIDER_ID,
name: "Venice Provider",
description: "Bundled Venice provider plugin",
provider: {
label: "Venice",
docsPath: "/providers/venice",
auth: [
{
methodId: "api-key",
label: "Venice AI API key",
hint: "Privacy-focused (uncensored models)",
optionKey: "veniceApiKey",
flagName: "--venice-api-key",
envVar: "VENICE_API_KEY",
promptMessage: "Enter Venice AI API key",
defaultModel: VENICE_DEFAULT_MODEL_REF,
applyConfig: (cfg) => applyVeniceConfig(cfg),
noteMessage: [
"Venice AI provides privacy-focused inference with uncensored models.",
"Get your API key at: https://venice.ai/settings/api",
"Supports 'private' (fully private) and 'anonymized' (proxy) modes.",
].join("\n"),
noteTitle: "Venice AI",
wizard: {
groupLabel: "Venice AI",
},
},
],
catalog: {
buildProvider: buildVeniceProvider,
},
normalizeResolvedModel: ({ modelId, model }) =>
isXaiBackedVeniceModel(modelId) ? applyXaiModelCompat(model) : undefined,
wrapStreamFn: (ctx) => createVeniceDeepSeekV4Wrapper(ctx.streamFn, ctx.thinkingLevel),
},
});

View File

@@ -0,0 +1,294 @@
// Venice tests cover models plugin behavior.
import { clearLiveCatalogCacheForTests } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
buildVeniceModelDefinition,
discoverVeniceModels,
VENICE_MODEL_CATALOG,
} from "./models.js";
const ORIGINAL_NODE_ENV = process.env.NODE_ENV;
const ORIGINAL_VITEST = process.env.VITEST;
function restoreDiscoveryEnv(): void {
if (ORIGINAL_NODE_ENV === undefined) {
delete process.env.NODE_ENV;
} else {
process.env.NODE_ENV = ORIGINAL_NODE_ENV;
}
if (ORIGINAL_VITEST === undefined) {
delete process.env.VITEST;
} else {
process.env.VITEST = ORIGINAL_VITEST;
}
}
async function runWithDiscoveryEnabled<T>(operation: () => Promise<T>): Promise<T> {
process.env.NODE_ENV = "development";
delete process.env.VITEST;
try {
return await operation();
} finally {
restoreDiscoveryEnv();
}
}
function makeModelsResponse(id: string): Response {
return new Response(
JSON.stringify({
data: [
{
id,
model_spec: {
name: id,
privacy: "private",
availableContextTokens: 131072,
maxCompletionTokens: 4096,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: true,
},
},
},
],
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
},
);
}
type ModelSpecOverride = {
id: string;
availableContextTokens?: number;
maxCompletionTokens?: number;
capabilities?: {
supportsReasoning?: boolean;
supportsVision?: boolean;
supportsFunctionCalling?: boolean;
};
includeModelSpec?: boolean;
};
function makeModelRow(params: ModelSpecOverride) {
if (params.includeModelSpec === false) {
return { id: params.id };
}
return {
id: params.id,
model_spec: {
name: params.id,
privacy: "private",
...(params.availableContextTokens === undefined
? {}
: { availableContextTokens: params.availableContextTokens }),
...(params.maxCompletionTokens === undefined
? {}
: { maxCompletionTokens: params.maxCompletionTokens }),
...(params.capabilities === undefined ? {} : { capabilities: params.capabilities }),
},
};
}
function stubVeniceModelsFetch(rows: ModelSpecOverride[]) {
const fetchMock = vi.fn(
async () =>
new Response(
JSON.stringify({
data: rows.map((row) => makeModelRow(row)),
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
},
),
);
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
return fetchMock;
}
describe("venice-models", () => {
afterEach(() => {
clearLiveCatalogCacheForTests();
vi.unstubAllGlobals();
restoreDiscoveryEnv();
});
it("buildVeniceModelDefinition returns config with required fields", () => {
const entry = VENICE_MODEL_CATALOG[0];
const def = buildVeniceModelDefinition(entry);
expect(def.id).toBe(entry.id);
expect(def.name).toBe(entry.name);
expect(def.reasoning).toBe(entry.reasoning);
expect(def.input).toEqual(entry.input);
expect(def.cost).toEqual({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
expect(def.contextWindow).toBe(entry.contextWindow);
expect(def.maxTokens).toBe(entry.maxTokens);
});
it("retries transient fetch failures before succeeding", async () => {
let attempts = 0;
const fetchMock = vi.fn(async () => {
attempts += 1;
if (attempts < 3) {
throw Object.assign(new TypeError("fetch failed"), {
cause: { code: "ECONNRESET", message: "socket hang up" },
});
}
return makeModelsResponse("llama-3.3-70b");
});
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels({ retryDelayMs: 0 }));
expect(attempts).toBe(3);
expect(models.map((m) => m.id)).toContain("llama-3.3-70b");
});
it("uses API maxCompletionTokens for catalog models when present", async () => {
stubVeniceModelsFetch([
{
id: "llama-3.3-70b",
availableContextTokens: 131072,
maxCompletionTokens: 2048,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: true,
},
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels({ retryDelayMs: 0 }));
const llama = models.find((m) => m.id === "llama-3.3-70b");
expect(llama?.maxTokens).toBe(2048);
});
it("retains catalog maxTokens when the API omits maxCompletionTokens", async () => {
stubVeniceModelsFetch([
{
id: "qwen3-235b-a22b-instruct-2507",
availableContextTokens: 131072,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: true,
},
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels({ retryDelayMs: 0 }));
const qwen = models.find((m) => m.id === "qwen3-235b-a22b-instruct-2507");
expect(qwen?.maxTokens).toBe(16384);
});
it("disables tools for catalog models that do not support function calling", () => {
const model = buildVeniceModelDefinition(
VENICE_MODEL_CATALOG.find((entry) => entry.id === "deepseek-v3.2")!,
);
expect(model.compat?.supportsTools).toBe(false);
});
it("uses a conservative bounded maxTokens value for new models", async () => {
stubVeniceModelsFetch([
{
id: "new-model-2026",
availableContextTokens: 50_000,
maxCompletionTokens: 200_000,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: false,
},
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels({ retryDelayMs: 0 }));
const newModel = models.find((m) => m.id === "new-model-2026");
expect(newModel?.maxTokens).toBe(50000);
expect(newModel?.maxTokens).toBeLessThanOrEqual(newModel?.contextWindow ?? Infinity);
expect(newModel?.compat?.supportsTools).toBe(false);
});
it("caps new-model maxTokens to the fallback context window when API context is missing", async () => {
stubVeniceModelsFetch([
{
id: "new-model-without-context",
maxCompletionTokens: 200_000,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: true,
},
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels());
const newModel = models.find((m) => m.id === "new-model-without-context");
expect(newModel?.contextWindow).toBe(128000);
expect(newModel?.maxTokens).toBe(128000);
});
it("ignores missing capabilities on partial metadata instead of aborting discovery", async () => {
stubVeniceModelsFetch([
{
id: "llama-3.3-70b",
availableContextTokens: 131072,
maxCompletionTokens: 2048,
},
{
id: "new-model-partial",
maxCompletionTokens: 2048,
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels());
const knownModel = models.find((m) => m.id === "llama-3.3-70b");
const partialModel = models.find((m) => m.id === "new-model-partial");
expect(models).not.toHaveLength(VENICE_MODEL_CATALOG.length);
expect(knownModel?.maxTokens).toBe(2048);
expect(partialModel?.contextWindow).toBe(128000);
expect(partialModel?.maxTokens).toBe(2048);
expect(partialModel?.compat?.supportsTools).toBeUndefined();
});
it("keeps known models discoverable when a row omits model_spec", async () => {
stubVeniceModelsFetch([
{ id: "llama-3.3-70b", includeModelSpec: false },
{
id: "new-model-valid",
availableContextTokens: 32_000,
maxCompletionTokens: 2_048,
capabilities: {
supportsReasoning: false,
supportsVision: false,
supportsFunctionCalling: true,
},
},
]);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels());
const knownModel = models.find((m) => m.id === "llama-3.3-70b");
const newModel = models.find((m) => m.id === "new-model-valid");
expect(models).not.toHaveLength(VENICE_MODEL_CATALOG.length);
expect(knownModel?.maxTokens).toBe(4096);
expect(newModel?.contextWindow).toBe(32000);
expect(newModel?.maxTokens).toBe(2048);
});
it("falls back to static catalog after retry budget is exhausted", async () => {
const fetchMock = vi.fn(async () => {
throw Object.assign(new TypeError("fetch failed"), {
cause: { code: "ENOTFOUND", message: "getaddrinfo ENOTFOUND api.venice.ai" },
});
});
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
const models = await runWithDiscoveryEnabled(() => discoverVeniceModels({ retryDelayMs: 0 }));
expect(fetchMock).toHaveBeenCalledTimes(3);
expect(models).toHaveLength(VENICE_MODEL_CATALOG.length);
expect(models.map((m) => m.id)).toEqual(VENICE_MODEL_CATALOG.map((m) => m.id));
});
});

269
extensions/venice/models.ts Normal file
View File

@@ -0,0 +1,269 @@
// Venice plugin module implements models behavior.
import {
getCachedLiveProviderModelRows,
LiveModelCatalogHttpError,
} from "openclaw/plugin-sdk/provider-catalog-live-runtime";
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
import { createSubsystemLogger, retryAsync } from "openclaw/plugin-sdk/runtime-env";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
import manifest from "./openclaw.plugin.json" with { type: "json" };
const log = createSubsystemLogger("venice-models");
const VENICE_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
providerId: "venice",
catalog: manifest.modelCatalog.providers.venice,
});
export const VENICE_BASE_URL = VENICE_MANIFEST_PROVIDER.baseUrl;
const VENICE_DEFAULT_MODEL_ID = "kimi-k2-5";
export const VENICE_DEFAULT_MODEL_REF = `venice/${VENICE_DEFAULT_MODEL_ID}`;
const VENICE_ALLOWED_HOSTNAMES = ["api.venice.ai"];
const VENICE_DEFAULT_COST = {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
};
const VENICE_DEFAULT_CONTEXT_WINDOW = 128_000;
const VENICE_DEFAULT_MAX_TOKENS = 4096;
const VENICE_DISCOVERY_HARD_MAX_TOKENS = 131_072;
const VENICE_DISCOVERY_TIMEOUT_MS = 10_000;
const VENICE_DISCOVERY_CACHE_TTL_MS = 60_000;
const VENICE_DISCOVERY_RETRYABLE_HTTP_STATUS = new Set([408, 425, 429, 500, 502, 503, 504]);
const VENICE_DISCOVERY_RETRYABLE_NETWORK_CODES = new Set([
"ECONNABORTED",
"ECONNREFUSED",
"ECONNRESET",
"EAI_AGAIN",
"ENETDOWN",
"ENETUNREACH",
"ENOTFOUND",
"ETIMEDOUT",
"UND_ERR_BODY_TIMEOUT",
"UND_ERR_CONNECT_TIMEOUT",
"UND_ERR_CONNECT_ERROR",
"UND_ERR_HEADERS_TIMEOUT",
"UND_ERR_SOCKET",
]);
export const VENICE_MODEL_CATALOG: ModelDefinitionConfig[] = VENICE_MANIFEST_PROVIDER.models;
type VeniceCatalogEntry = ModelDefinitionConfig;
export function buildVeniceModelDefinition(entry: VeniceCatalogEntry): ModelDefinitionConfig {
return {
id: entry.id,
name: entry.name,
reasoning: entry.reasoning,
input: [...entry.input],
cost: VENICE_DEFAULT_COST,
contextWindow: entry.contextWindow,
maxTokens: entry.maxTokens,
compat: {
supportsUsageInStreaming: false,
...entry.compat,
},
};
}
interface VeniceModelSpec {
name: string;
privacy: "private" | "anonymized";
availableContextTokens?: number;
maxCompletionTokens?: number;
capabilities?: {
supportsReasoning?: boolean;
supportsVision?: boolean;
supportsFunctionCalling?: boolean;
};
}
interface VeniceModel {
id: string;
model_spec?: VeniceModelSpec;
}
function staticVeniceModelDefinitions(): ModelDefinitionConfig[] {
return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
}
function hasRetryableNetworkCode(err: unknown): boolean {
const queue: unknown[] = [err];
const seen = new Set<unknown>();
while (queue.length > 0) {
const current = queue.shift();
if (!current || typeof current !== "object" || seen.has(current)) {
continue;
}
seen.add(current);
const candidate = current as {
cause?: unknown;
errors?: unknown;
code?: unknown;
errno?: unknown;
};
const code =
typeof candidate.code === "string"
? candidate.code
: typeof candidate.errno === "string"
? candidate.errno
: undefined;
if (code && VENICE_DISCOVERY_RETRYABLE_NETWORK_CODES.has(code)) {
return true;
}
if (candidate.cause) {
queue.push(candidate.cause);
}
if (Array.isArray(candidate.errors)) {
queue.push(...candidate.errors);
}
}
return false;
}
function isRetryableVeniceDiscoveryError(err: unknown): boolean {
if (err instanceof LiveModelCatalogHttpError) {
return VENICE_DISCOVERY_RETRYABLE_HTTP_STATUS.has(err.status);
}
if (err instanceof Error && err.name === "AbortError") {
return true;
}
if (err instanceof TypeError && normalizeLowercaseStringOrEmpty(err.message) === "fetch failed") {
return true;
}
return hasRetryableNetworkCode(err);
}
function normalizePositiveInt(value: unknown): number | undefined {
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
return undefined;
}
return Math.floor(value);
}
function resolveApiMaxCompletionTokens(params: {
apiModel: VeniceModel;
knownMaxTokens?: number;
}): number | undefined {
const raw = normalizePositiveInt(params.apiModel.model_spec?.maxCompletionTokens);
if (!raw) {
return undefined;
}
const contextWindow = normalizePositiveInt(params.apiModel.model_spec?.availableContextTokens);
const knownMaxTokens =
typeof params.knownMaxTokens === "number" && Number.isFinite(params.knownMaxTokens)
? Math.floor(params.knownMaxTokens)
: undefined;
const hardCap = knownMaxTokens ?? VENICE_DISCOVERY_HARD_MAX_TOKENS;
const fallbackContextWindow = knownMaxTokens ?? VENICE_DEFAULT_CONTEXT_WINDOW;
return Math.min(raw, contextWindow ?? fallbackContextWindow, hardCap);
}
function resolveApiSupportsTools(apiModel: VeniceModel): boolean | undefined {
const supportsFunctionCalling = apiModel.model_spec?.capabilities?.supportsFunctionCalling;
return typeof supportsFunctionCalling === "boolean" ? supportsFunctionCalling : undefined;
}
type VeniceModelDiscoveryOptions = {
retryDelayMs?: number;
};
export async function discoverVeniceModels(
options: VeniceModelDiscoveryOptions = {},
): Promise<ModelDefinitionConfig[]> {
if (process.env.NODE_ENV === "test" || process.env.VITEST) {
return staticVeniceModelDefinitions();
}
try {
const data = await retryAsync(
async () =>
await getCachedLiveProviderModelRows({
providerId: "venice",
endpoint: `${VENICE_BASE_URL}/models`,
timeoutMs: VENICE_DISCOVERY_TIMEOUT_MS,
ttlMs: VENICE_DISCOVERY_CACHE_TTL_MS,
policy: { allowedHostnames: VENICE_ALLOWED_HOSTNAMES },
auditContext: "venice-model-discovery",
}),
{
attempts: 3,
minDelayMs: options.retryDelayMs ?? 300,
maxDelayMs: options.retryDelayMs ?? 2000,
jitter: options.retryDelayMs === undefined ? 0.2 : 0,
label: "venice-model-discovery",
shouldRetry: isRetryableVeniceDiscoveryError,
},
);
if (data.length === 0) {
log.warn("No models found from API, using static catalog");
return staticVeniceModelDefinitions();
}
const catalogById = new Map<string, VeniceCatalogEntry>(
VENICE_MODEL_CATALOG.map((m) => [m.id, m]),
);
const models: ModelDefinitionConfig[] = [];
for (const apiModel of data as VeniceModel[]) {
const catalogEntry = catalogById.get(apiModel.id);
const apiMaxTokens = resolveApiMaxCompletionTokens({
apiModel,
knownMaxTokens: catalogEntry?.maxTokens,
});
const apiSupportsTools = resolveApiSupportsTools(apiModel);
if (catalogEntry) {
const definition = buildVeniceModelDefinition(catalogEntry);
if (apiMaxTokens !== undefined) {
definition.maxTokens = apiMaxTokens;
}
if (apiSupportsTools === false) {
definition.compat = {
...definition.compat,
supportsTools: false,
};
}
models.push(definition);
} else {
const apiSpec = apiModel.model_spec;
const lowerModelId = normalizeLowercaseStringOrEmpty(apiModel.id);
const isReasoning =
apiSpec?.capabilities?.supportsReasoning ||
lowerModelId.includes("thinking") ||
lowerModelId.includes("reason") ||
lowerModelId.includes("r1");
const hasVision = apiSpec?.capabilities?.supportsVision === true;
models.push({
id: apiModel.id,
name: apiSpec?.name || apiModel.id,
reasoning: isReasoning,
input: hasVision ? ["text", "image"] : ["text"],
cost: VENICE_DEFAULT_COST,
contextWindow:
normalizePositiveInt(apiSpec?.availableContextTokens) ?? VENICE_DEFAULT_CONTEXT_WINDOW,
maxTokens: apiMaxTokens ?? VENICE_DEFAULT_MAX_TOKENS,
compat: {
supportsUsageInStreaming: false,
...(apiSupportsTools === false ? { supportsTools: false } : {}),
},
});
}
}
return models.length > 0 ? models : staticVeniceModelDefinitions();
} catch (error) {
if (error instanceof LiveModelCatalogHttpError) {
log.warn(`Failed to discover models: HTTP ${error.status}, using static catalog`);
return staticVeniceModelDefinitions();
}
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
return staticVeniceModelDefinitions();
}
}

12
extensions/venice/npm-shrinkwrap.json generated Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "@openclaw/venice-provider",
"version": "2026.6.11",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@openclaw/venice-provider",
"version": "2026.6.11"
}
}
}

View File

@@ -0,0 +1,28 @@
// Venice setup module handles plugin onboarding behavior.
import {
createModelCatalogPresetAppliers,
type OpenClawConfig,
} from "openclaw/plugin-sdk/provider-onboard";
import {
buildVeniceModelDefinition,
VENICE_BASE_URL,
VENICE_DEFAULT_MODEL_REF,
VENICE_MODEL_CATALOG,
} from "./api.js";
export { VENICE_DEFAULT_MODEL_REF };
const venicePresetAppliers = createModelCatalogPresetAppliers({
primaryModelRef: VENICE_DEFAULT_MODEL_REF,
resolveParams: (_cfg: OpenClawConfig) => ({
providerId: "venice",
api: "openai-completions",
baseUrl: VENICE_BASE_URL,
catalogModels: VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition),
aliases: [{ modelRef: VENICE_DEFAULT_MODEL_REF, alias: "Kimi K2.5" }],
}),
});
export function applyVeniceConfig(cfg: OpenClawConfig): OpenClawConfig {
return venicePresetAppliers.applyConfig(cfg);
}

View File

@@ -0,0 +1,471 @@
{
"id": "venice",
"activation": {
"onStartup": false
},
"enabledByDefault": true,
"providers": ["venice"],
"providerAuthChoices": [
{
"provider": "venice",
"method": "api-key",
"choiceId": "venice-api-key",
"choiceLabel": "Venice AI API key",
"groupId": "venice",
"groupLabel": "Venice AI",
"groupHint": "Privacy-focused (uncensored models)",
"optionKey": "veniceApiKey",
"cliFlag": "--venice-api-key",
"cliOption": "--venice-api-key <key>",
"cliDescription": "Venice API key"
}
],
"configSchema": {
"type": "object",
"additionalProperties": false,
"properties": {}
},
"setup": {
"providers": [
{
"id": "venice",
"authMethods": ["api-key"],
"envVars": ["VENICE_API_KEY"]
}
]
},
"modelCatalog": {
"providers": {
"venice": {
"baseUrl": "https://api.venice.ai/api/v1",
"api": "openai-completions",
"models": [
{
"id": "llama-3.3-70b",
"name": "Llama 3.3 70B",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 4096,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "llama-3.2-3b",
"name": "Llama 3.2 3B",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 4096,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "hermes-3-llama-3.1-405b",
"name": "Hermes 3 Llama 3.1 405B",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false,
"supportsTools": false
}
},
{
"id": "qwen3-235b-a22b-thinking-2507",
"name": "Qwen3 235B Thinking",
"reasoning": true,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-235b-a22b-instruct-2507",
"name": "Qwen3 235B Instruct",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-coder-480b-a35b-instruct",
"name": "Qwen3 Coder 480B",
"reasoning": false,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-coder-480b-a35b-instruct-turbo",
"name": "Qwen3 Coder 480B Turbo",
"reasoning": false,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-5-35b-a3b",
"name": "Qwen3.5 35B A3B",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-next-80b",
"name": "Qwen3 Next 80B",
"reasoning": false,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-vl-235b-a22b",
"name": "Qwen3 VL 235B (Vision)",
"reasoning": false,
"input": ["text", "image"],
"contextWindow": 256000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "qwen3-4b",
"name": "Venice Small (Qwen3 4B)",
"reasoning": true,
"input": ["text"],
"contextWindow": 32000,
"maxTokens": 4096,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "deepseek-v3.2",
"name": "DeepSeek V3.2",
"reasoning": true,
"input": ["text"],
"contextWindow": 160000,
"maxTokens": 32768,
"compat": {
"supportsUsageInStreaming": false,
"supportsTools": false
}
},
{
"id": "venice-uncensored",
"name": "Venice Uncensored (Dolphin-Mistral)",
"reasoning": false,
"input": ["text"],
"contextWindow": 32000,
"maxTokens": 4096,
"compat": {
"supportsUsageInStreaming": false,
"supportsTools": false
}
},
{
"id": "mistral-31-24b",
"name": "Venice Medium (Mistral)",
"reasoning": false,
"input": ["text", "image"],
"contextWindow": 128000,
"maxTokens": 4096,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "google-gemma-3-27b-it",
"name": "Google Gemma 3 27B Instruct",
"reasoning": false,
"input": ["text", "image"],
"contextWindow": 198000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-oss-120b",
"name": "OpenAI GPT OSS 120B",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "nvidia-nemotron-3-nano-30b-a3b",
"name": "NVIDIA Nemotron 3 Nano 30B",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "olafangensan-glm-4.7-flash-heretic",
"name": "GLM 4.7 Flash Heretic",
"reasoning": true,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 24000,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "zai-org-glm-4.6",
"name": "GLM 4.6",
"reasoning": false,
"input": ["text"],
"contextWindow": 198000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "zai-org-glm-4.7",
"name": "GLM 4.7",
"reasoning": true,
"input": ["text"],
"contextWindow": 198000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "zai-org-glm-4.7-flash",
"name": "GLM 4.7 Flash",
"reasoning": true,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "zai-org-glm-5",
"name": "GLM 5",
"reasoning": true,
"input": ["text"],
"contextWindow": 198000,
"maxTokens": 32000,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "kimi-k2-5",
"name": "Kimi K2.5",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "kimi-k2-thinking",
"name": "Kimi K2 Thinking",
"reasoning": true,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "minimax-m21",
"name": "MiniMax M2.1",
"reasoning": true,
"input": ["text"],
"contextWindow": 198000,
"maxTokens": 32768,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "minimax-m25",
"name": "MiniMax M2.5",
"reasoning": true,
"input": ["text"],
"contextWindow": 198000,
"maxTokens": 32768,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "claude-opus-4-6",
"name": "Claude Opus 4.6 (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 128000,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "claude-sonnet-4-6",
"name": "Claude Sonnet 4.6 (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 64000,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-52",
"name": "GPT-5.2 (via Venice)",
"reasoning": true,
"input": ["text"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-52-codex",
"name": "GPT-5.2 Codex (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-53-codex",
"name": "GPT-5.3 Codex (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 400000,
"maxTokens": 128000,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-54",
"name": "GPT-5.4 (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 131072,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-4o-2024-11-20",
"name": "GPT-4o (via Venice)",
"reasoning": false,
"input": ["text", "image"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "openai-gpt-4o-mini-2024-07-18",
"name": "GPT-4o Mini (via Venice)",
"reasoning": false,
"input": ["text", "image"],
"contextWindow": 128000,
"maxTokens": 16384,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "gemini-3-pro-preview",
"name": "Gemini 3 Pro (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 198000,
"maxTokens": 32768,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "gemini-3-1-pro-preview",
"name": "Gemini 3.1 Pro (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 32768,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "gemini-3-flash-preview",
"name": "Gemini 3 Flash (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 256000,
"maxTokens": 65536,
"compat": {
"supportsUsageInStreaming": false
}
},
{
"id": "grok-41-fast",
"name": "Grok 4.1 Fast (via Venice)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 30000,
"compat": {
"supportsUsageInStreaming": false
}
}
]
}
},
"discovery": {
"venice": "refreshable"
}
}
}

View File

@@ -0,0 +1,35 @@
{
"name": "@openclaw/venice-provider",
"version": "2026.6.11",
"description": "OpenClaw Venice provider plugin",
"type": "module",
"devDependencies": {
"@openclaw/plugin-sdk": "workspace:*"
},
"openclaw": {
"extensions": [
"./index.ts"
],
"install": {
"clawhubSpec": "clawhub:@openclaw/venice-provider",
"npmSpec": "@openclaw/venice-provider",
"defaultChoice": "npm",
"minHostVersion": ">=2026.6.9"
},
"compat": {
"pluginApi": ">=2026.6.11"
},
"build": {
"openclawVersion": "2026.6.11",
"bundledDist": false
},
"release": {
"publishToClawHub": true,
"publishToNpm": true
}
},
"repository": {
"type": "git",
"url": "https://github.com/openclaw/openclaw"
}
}

View File

@@ -0,0 +1,12 @@
// Venice provider module implements model/runtime integration.
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import { discoverVeniceModels, VENICE_BASE_URL } from "./models.js";
export async function buildVeniceProvider(): Promise<ModelProviderConfig> {
const models = await discoverVeniceModels();
return {
baseUrl: VENICE_BASE_URL,
api: "openai-completions",
models,
};
}

View File

@@ -0,0 +1,4 @@
// Venice tests cover provider runtime.contract plugin behavior.
import { describeVeniceProviderRuntimeContract } from "openclaw/plugin-sdk/provider-test-contracts";
describeVeniceProviderRuntimeContract(() => import("./index.js"));

View File

@@ -0,0 +1,38 @@
// Venice plugin module implements stream behavior.
import type { ProviderWrapStreamFnContext } from "openclaw/plugin-sdk/plugin-entry";
import { createPayloadPatchStreamWrapper } from "openclaw/plugin-sdk/provider-stream-shared";
function isVeniceDeepSeekV4ModelId(modelId: unknown): boolean {
return modelId === "deepseek-v4-flash" || modelId === "deepseek-v4-pro";
}
function ensureVeniceDeepSeekV4Replay(payload: Record<string, unknown>): void {
delete payload.thinking;
delete payload.reasoning;
delete payload.reasoning_effort;
if (!Array.isArray(payload.messages)) {
return;
}
for (const message of payload.messages) {
if (!message || typeof message !== "object") {
continue;
}
const record = message as Record<string, unknown>;
if (record.role === "assistant") {
record.reasoning_content ??= "";
}
}
}
export function createVeniceDeepSeekV4Wrapper(
baseStreamFn: ProviderWrapStreamFnContext["streamFn"],
thinkingLevel: ProviderWrapStreamFnContext["thinkingLevel"],
): ProviderWrapStreamFnContext["streamFn"] {
void thinkingLevel;
return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload, model }) => {
if (model.provider === "venice" && isVeniceDeepSeekV4ModelId(model.id)) {
ensureVeniceDeepSeekV4Replay(payload);
}
});
}

View File

@@ -0,0 +1,16 @@
{
"extends": "../tsconfig.package-boundary.base.json",
"compilerOptions": {
"rootDir": "."
},
"include": ["./*.ts", "./src/**/*.ts"],
"exclude": [
"./**/*.test.ts",
"./dist/**",
"./node_modules/**",
"./src/test-support/**",
"./src/**/*test-helpers.ts",
"./src/**/*test-harness.ts",
"./src/**/*test-support.ts"
]
}