Skip to content

Commit 93cdbe3

Browse files
committed
Merge origin/main into PR #107473
2 parents ae3d3ec + d2b869e commit 93cdbe3

45 files changed

Lines changed: 1515 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/plugins/plugin-inventory.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Each entry lists the package, distribution route, and description.
5151

5252
## Core npm package
5353

54-
67 plugins
54+
66 plugins
5555

5656
- **[admin-http-rpc](/plugins/reference/admin-http-rpc)** (`@openclaw/admin-http-rpc`) - included in OpenClaw. OpenClaw admin HTTP RPC endpoint.
5757

@@ -159,8 +159,6 @@ Each entry lists the package, distribution route, and description.
159159

160160
- **[sglang](/plugins/reference/sglang)** (`@openclaw/sglang-provider`) - included in OpenClaw. Adds SGLang model provider support to OpenClaw.
161161

162-
- **[synthetic](/plugins/reference/synthetic)** (`@openclaw/synthetic-provider`) - included in OpenClaw. Adds Synthetic model provider support to OpenClaw.
163-
164162
- **[telegram](/plugins/reference/telegram)** (`@openclaw/telegram`) - included in OpenClaw. Adds the Telegram channel surface for sending and receiving OpenClaw messages.
165163

166164
- **[together](/plugins/reference/together)** (`@openclaw/together-provider`) - included in OpenClaw. Adds Together model provider support to OpenClaw.
@@ -189,7 +187,7 @@ Each entry lists the package, distribution route, and description.
189187

190188
## Official external packages
191189

192-
78 plugins
190+
79 plugins
193191

194192
- **[acpx](/plugins/reference/acpx)** (`@openclaw/acpx`) - npm; ClawHub. OpenClaw ACP runtime backend with plugin-owned session and transport management.
195193

@@ -319,6 +317,8 @@ Each entry lists the package, distribution route, and description.
319317

320318
- **[synology-chat](/plugins/reference/synology-chat)** (`@openclaw/synology-chat`) - npm; ClawHub. Synology Chat channel plugin for OpenClaw channels and direct messages.
321319

320+
- **[synthetic](/plugins/reference/synthetic)** (`@openclaw/synthetic-provider`) - npm; ClawHub: `clawhub:@openclaw/synthetic-provider`. Adds Synthetic model provider support to OpenClaw.
321+
322322
- **[tavily](/plugins/reference/tavily)** (`@openclaw/tavily-plugin`) - npm; ClawHub: `clawhub:@openclaw/tavily-plugin`. Adds agent-callable tools. Adds web search provider support.
323323

324324
- **[teams-meetings](/plugins/reference/teams-meetings)** (`@openclaw/teams-meetings`) - npm; ClawHub: `clawhub:@openclaw/teams-meetings`. Join Microsoft Teams meetings as a Chrome browser guest.

‎docs/plugins/reference/synthetic.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Adds Synthetic model provider support to OpenClaw.
1212
## Distribution
1313

1414
- Package: `@openclaw/synthetic-provider`
15-
- Install route: included in OpenClaw
15+
- Install route: npm; ClawHub: `clawhub:@openclaw/synthetic-provider`
1616

1717
## Surface
1818

‎docs/providers/synthetic.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ title: "Synthetic"
77
---
88

99
[Synthetic](https://synthetic.new) exposes Anthropic-compatible endpoints.
10-
OpenClaw bundles it as the `synthetic` provider and uses the Anthropic
11-
Messages API.
10+
OpenClaw provides it through the official `@openclaw/synthetic-provider`
11+
plugin and uses the Anthropic Messages API.
1212

1313
| Property | Value |
1414
| -------- | ------------------------------------- |
@@ -20,6 +20,12 @@ Messages API.
2020
## Getting started
2121

2222
<Steps>
23+
<Step title="Install the plugin">
24+
```bash
25+
openclaw plugins install @openclaw/synthetic-provider
26+
openclaw gateway restart
27+
```
28+
</Step>
2329
<Step title="Get an API key">
2430
Get a `SYNTHETIC_API_KEY` from your Synthetic account, or let onboarding
2531
prompt you for one.

‎extensions/ollama/index.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ describe("ollama plugin", () => {
19011901
expect(rows).toHaveLength(8);
19021902
});
19031903

1904-
it("keeps unknown requested Ollama models unresolved when show has no metadata", async () => {
1904+
it("keeps unknown requested Ollama models unresolved when show inspection fails", async () => {
19051905
const provider = registerProvider();
19061906
const previous = process.env.OLLAMA_API_KEY;
19071907
process.env.OLLAMA_API_KEY = "ollama-local";
@@ -1910,7 +1910,7 @@ describe("ollama plugin", () => {
19101910
api: "ollama",
19111911
models: [],
19121912
});
1913-
queryOllamaModelShowInfoMock.mockResolvedValueOnce({});
1913+
queryOllamaModelShowInfoMock.mockResolvedValueOnce({ showInspectionFailed: true });
19141914

19151915
try {
19161916
await provider.prepareDynamicModel?.({

‎extensions/ollama/provider-discovery.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe("Ollama provider", () => {
323323
const fetchMock = vi.fn(async (input: unknown) => {
324324
const url = String(input);
325325
if (url.endsWith("/api/tags")) {
326-
return tagsResponse(["qwen3:32b"]);
326+
return tagsResponse(["deepseek-r1:14b"]);
327327
}
328328
if (url.endsWith("/api/show")) {
329329
return jsonResponse({}, 500);
@@ -335,8 +335,10 @@ describe("Ollama provider", () => {
335335
const provider = await runOllamaCatalog({
336336
env: { OLLAMA_API_KEY: "test-key", VITEST: "", NODE_ENV: "development" },
337337
});
338-
const model = provider?.models?.find((entry) => entry.id === "qwen3:32b");
338+
const model = provider?.models?.find((entry) => entry.id === "deepseek-r1:14b");
339339
expect(model?.contextWindow).toBe(128000);
340+
expect(model?.compat?.supportsTools).toBe(false);
341+
expect(model?.reasoning).toBe(true);
340342
expectDiscoveryCallCounts(fetchMock, { tags: 1, show: 1 });
341343
});
342344

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* CJK-aware character weighting for Ollama usage fallback estimates.
3+
*
4+
* This stays plugin-private because exposing it through the Plugin SDK would
5+
* create a stable public contract for one provider-specific fallback. Keep
6+
* the weighting aligned with normalization-core's CJK budget heuristic.
7+
*/
8+
9+
const CHARS_PER_TOKEN_ESTIMATE = 4;
10+
11+
const NON_ASCII_RE = /[\u0080-\u{10FFFF}]/u;
12+
const COMMON_CJK_RE = /[\u00B7\u3000-\u319F\u4E00-\u9FA5\uAC00-\uD7AF\uFF01-\uFF60]/gu;
13+
const RARE_BMP_CJK_RE =
14+
/[\u1100-\u11FF\u2E80-\u2FFF\u31A0-\u4DFF\u9FA6-\u9FFF\uA000-\uA4FF\uA700-\uA707\uA960-\uA97F\uD7B0-\uD7FF\uF900-\uFAFF]/gu;
15+
const TWO_TOKEN_CJK_RE =
16+
/[\u{02C7}\u{02C9}-\u{02CB}\u{02D9}\u{02EA}-\u{02EB}\uFE10-\uFE4F\uFF61-\uFFDC\uFFE0-\uFFE6]|\u{0305}|\u{0323}/gu;
17+
const THREE_TOKEN_SUPPLEMENTARY_CJK_RE = /[\u{1D360}-\u{1D371}]/gu;
18+
const SUPPLEMENTARY_CJK_RE =
19+
/[\u{16FE0}-\u{16FFF}\u{1AFF0}-\u{1AFFF}\u{1B000}-\u{1B16F}\u{1F200}-\u{1F2FF}\u{20000}-\u{2FA1F}\u{30000}-\u{3347F}]/gu;
20+
const SPECIAL_CJK_RE =
21+
/[\u{02C7}\u{02C9}-\u{02CB}\u{02D9}\u{02EA}-\u{02EB}\u1100-\u11FF\u2E80-\u2FFF\u31A0-\u4DFF\u9FA6-\u9FFF\uA000-\uA4FF\uA700-\uA707\uA960-\uA97F\uD7B0-\uD7FF\uF900-\uFAFF\uFE10-\uFE4F\uFF61-\uFFDC\uFFE0-\uFFE6\u{16FE0}-\u{16FFF}\u{1AFF0}-\u{1AFFF}\u{1B000}-\u{1B16F}\u{1D360}-\u{1D371}\u{1F200}-\u{1F2FF}\u{20000}-\u{2FA1F}\u{30000}-\u{3347F}]|\u{0305}|\u{0323}/u;
22+
23+
function countMatches(text: string, pattern: RegExp): number {
24+
return (text.match(pattern) ?? []).length;
25+
}
26+
27+
export function estimateStringChars(text: string): number {
28+
if (!NON_ASCII_RE.test(text)) {
29+
return text.length;
30+
}
31+
const commonCjkCount = countMatches(text, COMMON_CJK_RE);
32+
const commonEstimate = text.length + commonCjkCount * (CHARS_PER_TOKEN_ESTIMATE - 1);
33+
if (!SPECIAL_CJK_RE.test(text)) {
34+
return commonEstimate;
35+
}
36+
const rareBmpCjkCount = countMatches(text, RARE_BMP_CJK_RE);
37+
const twoTokenCjkCount = countMatches(text, TWO_TOKEN_CJK_RE);
38+
const threeTokenSupplementaryCjkCount = countMatches(text, THREE_TOKEN_SUPPLEMENTARY_CJK_RE);
39+
const supplementaryCjkCount = countMatches(text, SUPPLEMENTARY_CJK_RE);
40+
return (
41+
commonEstimate +
42+
rareBmpCjkCount * (CHARS_PER_TOKEN_ESTIMATE * 3 - 1) +
43+
twoTokenCjkCount * (CHARS_PER_TOKEN_ESTIMATE * 2 - 1) +
44+
threeTokenSupplementaryCjkCount * (CHARS_PER_TOKEN_ESTIMATE * 3 - 2) +
45+
supplementaryCjkCount * (CHARS_PER_TOKEN_ESTIMATE * 4 - 2)
46+
);
47+
}

‎extensions/ollama/src/provider-models.test.ts‎

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,27 @@ describe("ollama provider models", () => {
471471
expect(model.compat?.supportsUsageInStreaming).toBe(true);
472472
});
473473

474+
it("keeps failed inspection distinct from omitted and empty capabilities", () => {
475+
const uninspected = buildOllamaModelDefinition("deepseek-r1:14b", 65536);
476+
const authoritativeEmpty = buildOllamaModelDefinition("deepseek-r1:14b", 65536, []);
477+
const inspectionFailed = buildOllamaModelDefinition("deepseek-r1:14b", 65536, undefined, {
478+
showInspectionFailed: true,
479+
});
480+
481+
expect(uninspected).toMatchObject({
482+
reasoning: true,
483+
compat: { supportsTools: true },
484+
});
485+
expect(authoritativeEmpty).toMatchObject({
486+
reasoning: false,
487+
compat: { supportsTools: false },
488+
});
489+
expect(inspectionFailed).toMatchObject({
490+
reasoning: true,
491+
compat: { supportsTools: false },
492+
});
493+
});
494+
474495
it.each([
475496
{ parameters: "num_ctx 8192\nnum_ctx 32768", expected: 32768 },
476497
{ parameters: "temperature 0.8\nnum_ctx -1\nnum_ctx 0", expected: undefined },
@@ -506,9 +527,9 @@ describe("ollama provider models", () => {
506527
vi.fn(async () => showResponse.response),
507528
);
508529

509-
await expect(queryOllamaModelShowInfo("http://127.0.0.1:11434", "llama3:8b")).resolves.toEqual(
510-
{},
511-
);
530+
await expect(queryOllamaModelShowInfo("http://127.0.0.1:11434", "llama3:8b")).resolves.toEqual({
531+
showInspectionFailed: true,
532+
});
512533
expect(showResponse.wasCanceled()).toBe(true);
513534
});
514535

@@ -609,7 +630,9 @@ describe("ollama provider models", () => {
609630
});
610631
await waitForSocketClose("/api/tags");
611632

612-
await expect(queryOllamaModelShowInfo(baseUrl, "llama3:8b")).resolves.toEqual({});
633+
await expect(queryOllamaModelShowInfo(baseUrl, "llama3:8b")).resolves.toEqual({
634+
showInspectionFailed: true,
635+
});
613636
await waitForSocketClose("/api/show");
614637

615638
mode = "success";
@@ -639,6 +662,50 @@ describe("ollama provider models", () => {
639662
}
640663
});
641664

665+
it("keeps tools off after a live /api/show failure", async () => {
666+
const server = createServer((request, response) => {
667+
response.setHeader("Content-Type", "application/json");
668+
if (request.url === "/api/tags") {
669+
response.end(
670+
JSON.stringify({
671+
models: [{ name: "deepseek-r1:14b", digest: "sha256:show-failure" }],
672+
}),
673+
);
674+
return;
675+
}
676+
if (request.url === "/api/show") {
677+
response.statusCode = 500;
678+
response.end(JSON.stringify({ error: "show failed" }));
679+
return;
680+
}
681+
response.statusCode = 404;
682+
response.end(JSON.stringify({ error: "not found" }));
683+
});
684+
685+
const listening = once(server, "listening");
686+
try {
687+
server.listen(0, "127.0.0.1");
688+
await listening;
689+
const address = server.address();
690+
if (!address || typeof address === "string") {
691+
throw new Error("Ollama test server did not expose a TCP address");
692+
}
693+
694+
const provider = await buildOllamaProvider(`http://127.0.0.1:${address.port}`);
695+
const model = expectDefined(provider.models?.[0], "show-failed Ollama model");
696+
697+
expect(model.id).toBe("deepseek-r1:14b");
698+
expect(model.compat?.supportsTools).toBe(false);
699+
expect(model.reasoning).toBe(true);
700+
} finally {
701+
if (server.listening) {
702+
await new Promise<void>((resolve, reject) => {
703+
server.close((error) => (error ? reject(error) : resolve()));
704+
});
705+
}
706+
}
707+
});
708+
642709
it("fails soft and stops reading when discovery streams exceed the JSON byte cap", async () => {
643710
// Larger than the shared 16 MiB readProviderJsonResponse cap so the bounded reader cancels
644711
// the stream mid-flight; if the cap were removed the reader would buffer the whole payload.
@@ -687,7 +754,7 @@ describe("ollama provider models", () => {
687754
vi.fn(async () => makeOversizedJsonResponse()),
688755
);
689756
const showInfo = await queryOllamaModelShowInfo("http://127.0.0.1:11434", "evil-model:latest");
690-
expect(showInfo).toEqual({});
757+
expect(showInfo).toEqual({ showInspectionFailed: true });
691758
expect(canceled).toBe(true);
692759
expect(bytesPulled).toBeLessThan(TOTAL_CHUNKS * ONE_MIB);
693760
});

‎extensions/ollama/src/provider-models.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type OllamaTagsResponse = {
3737
export type OllamaModelWithContext = OllamaTagModel & {
3838
contextWindow?: number;
3939
capabilities?: string[];
40+
showInspectionFailed?: boolean;
4041
};
4142

4243
const OLLAMA_SHOW_CONCURRENCY = 8;
@@ -81,8 +82,14 @@ export function resolveOllamaApiBase(configuredBaseUrl?: string): string {
8182
export type OllamaModelShowInfo = {
8283
contextWindow?: number;
8384
capabilities?: string[];
85+
/** Distinguishes a failed request from a successful response that omitted capabilities. */
86+
showInspectionFailed?: boolean;
8487
};
8588

89+
const OLLAMA_FAILED_SHOW_INFO: OllamaModelShowInfo = Object.freeze({
90+
showInspectionFailed: true,
91+
});
92+
8693
type OllamaModelRequestOptions = {
8794
apiKey?: string;
8895
timeoutMs?: number;
@@ -227,7 +234,7 @@ export async function queryOllamaModelShowInfo(
227234
return await readOllamaModelShowInfo(apiBase, modelName, opts);
228235
} catch {
229236
throwIfOllamaRequestAborted(opts?.signal);
230-
return {};
237+
return OLLAMA_FAILED_SHOW_INFO;
231238
}
232239
}
233240

@@ -279,10 +286,7 @@ export async function enrichOllamaModelsWithContext(
279286
const batchResults = await Promise.all(
280287
batch.map(async (model) => {
281288
const showInfo = await queryOllamaModelShowInfoCached(apiBase, model, opts);
282-
return Object.assign({}, model, {
283-
contextWindow: showInfo.contextWindow,
284-
capabilities: showInfo.capabilities,
285-
});
289+
return Object.assign({}, model, showInfo);
286290
}),
287291
);
288292
enriched.push(...batchResults);
@@ -343,6 +347,7 @@ export function buildOllamaModelDefinition(
343347
modelId: string,
344348
contextWindow?: number,
345349
capabilities?: string[],
350+
opts?: { showInspectionFailed?: boolean },
346351
): ModelDefinitionConfig {
347352
const hasVision = capabilities?.includes("vision") ?? false;
348353
const input: ("text" | "image")[] = hasVision ? ["text", "image"] : ["text"];
@@ -352,7 +357,8 @@ export function buildOllamaModelDefinition(
352357
? isReasoningModelHeuristic(modelId)
353358
: capabilities.includes("thinking"));
354359
const compat = {
355-
supportsTools: capabilities?.includes("tools") ?? true,
360+
supportsTools:
361+
opts?.showInspectionFailed === true ? false : (capabilities?.includes("tools") ?? true),
356362
supportsUsageInStreaming: true,
357363
supportsJsonSchemaResponseFormat: !isOllamaCloudModel(modelId),
358364
};
@@ -467,7 +473,9 @@ export async function buildOllamaProvider(
467473
baseUrl: apiBase,
468474
api: "ollama",
469475
models: discovered.map((model) =>
470-
buildOllamaModelDefinition(model.name, model.contextWindow, model.capabilities),
476+
buildOllamaModelDefinition(model.name, model.contextWindow, model.capabilities, {
477+
showInspectionFailed: model.showInspectionFailed,
478+
}),
471479
),
472480
};
473481
}

0 commit comments

Comments
 (0)