惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
IT之家
IT之家
博客园_首页
博客园 - 【当耐特】
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
GbyAI
GbyAI
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
H
Help Net Security
T
Tailwind CSS Blog
B
Blog RSS Feed
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
博客园 - 叶小钗
雷峰网
雷峰网
量子位

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf: optimize plugin schema validation · openclaw/opencl...
steipete · 2026-05-02 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,2 +1,2 @@

1-

b0424fd44d888d28f7f4ab0f653e5ae37f6ae61aad298b759ea0531edccb4405 plugin-sdk-api-baseline.json

2-

82a080f2ec0455f1496391dc35534545b07181655ef5d3845e8c86eda7979501 plugin-sdk-api-baseline.jsonl

1+

dfdecb3918124ec7926ffe17220e498ffeef2fc7a7edfea528cc5a7f284cb8ef plugin-sdk-api-baseline.json

2+

079c31016f34256af290f80f3e16d6f8154eb13513d36547ba41d3241d60e0e4 plugin-sdk-api-baseline.jsonl

Original file line numberDiff line numberDiff line change

@@ -399,6 +399,20 @@ const accountSchema = z.object({

399399

const configSchema = buildChannelConfigSchema(accountSchema);

400400

```

401401
402+

If you already author the contract as JSON Schema or TypeBox, use the direct helper so OpenClaw can skip Zod-to-JSON-Schema conversion on metadata paths:

403+
404+

```typescript

405+

import { Type } from "typebox";

406+

import { buildJsonChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";

407+
408+

const configSchema = buildJsonChannelConfigSchema(

409+

Type.Object({

410+

token: Type.Optional(Type.String()),

411+

allowFrom: Type.Optional(Type.Array(Type.String())),

412+

}),

413+

);

414+

```

415+
402416

For third-party plugins, the cold-path contract is still the plugin manifest: mirror the generated JSON Schema into `openclaw.plugin.json#channelConfigs` so config schema, setup, and UI surfaces can inspect `channels.<id>` without loading runtime code.

403417
404418

## Setup wizards

Original file line numberDiff line numberDiff line change

@@ -22,7 +22,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)

2222

| Subpath | Key exports |

2323

| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

2424

| `plugin-sdk/plugin-entry` | `definePluginEntry` |

25-

| `plugin-sdk/core` | `defineChannelPluginEntry`, `createChatChannelPlugin`, `createChannelPluginBase`, `defineSetupPluginEntry`, `buildChannelConfigSchema` |

25+

| `plugin-sdk/core` | `defineChannelPluginEntry`, `createChatChannelPlugin`, `createChannelPluginBase`, `defineSetupPluginEntry`, `buildChannelConfigSchema`, `buildJsonChannelConfigSchema` |

2626

| `plugin-sdk/config-schema` | `OpenClawSchema` |

2727

| `plugin-sdk/provider-entry` | `defineSingleProviderPluginEntry` |

2828

| `plugin-sdk/testing` | Broad compatibility barrel for legacy plugin tests; prefer focused test subpaths for new extension tests |

@@ -58,7 +58,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)

5858

| `plugin-sdk/channel-pairing` | `createChannelPairingController` |

5959

| `plugin-sdk/channel-reply-pipeline` | `createChannelReplyPipeline`, `resolveChannelSourceReplyDeliveryMode` |

6060

| `plugin-sdk/channel-config-helpers` | `createHybridChannelConfigAdapter`, `resolveChannelDmAccess`, `resolveChannelDmAllowFrom`, `resolveChannelDmPolicy`, `normalizeChannelDmPolicy`, `normalizeLegacyDmAliases` |

61-

| `plugin-sdk/channel-config-schema` | Shared channel config schema primitives and generic builder |

61+

| `plugin-sdk/channel-config-schema` | Shared channel config schema primitives plus Zod and direct JSON/TypeBox builders |

6262

| `plugin-sdk/bundled-channel-config-schema` | Bundled OpenClaw channel config schemas for maintained bundled plugins only |

6363

| `plugin-sdk/channel-config-schema-legacy` | Deprecated compatibility alias for bundled-channel config schemas |

6464

| `plugin-sdk/telegram-command-config` | Telegram custom-command normalization/validation helpers with bundled-contract fallback |

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,10 @@

11

import { describe, expect, it, vi } from "vitest";

22

import { z } from "zod";

3-

import { buildChannelConfigSchema, emptyChannelConfigSchema } from "./config-schema.js";

3+

import {

4+

buildChannelConfigSchema,

5+

buildJsonChannelConfigSchema,

6+

emptyChannelConfigSchema,

7+

} from "./config-schema.js";

48
59

describe("buildChannelConfigSchema", () => {

610

it("builds json schema when toJSONSchema is available", () => {

@@ -47,6 +51,37 @@ describe("buildChannelConfigSchema", () => {

4751

});

4852

});

4953
54+

describe("buildJsonChannelConfigSchema", () => {

55+

it("validates direct JSON schemas without zod conversion", () => {

56+

const result = buildJsonChannelConfigSchema(

57+

{

58+

type: "object",

59+

additionalProperties: false,

60+

properties: {

61+

enabled: { type: "boolean", default: true },

62+

},

63+

},

64+

{ cacheKey: "config-schema.test.json-channel" },

65+

);

66+
67+

expect(result.schema).toEqual({

68+

type: "object",

69+

additionalProperties: false,

70+

properties: {

71+

enabled: { type: "boolean", default: true },

72+

},

73+

});

74+

expect(result.runtime?.safeParse({})).toEqual({

75+

success: true,

76+

data: { enabled: true },

77+

});

78+

expect(result.runtime?.safeParse({ enabled: "yes" })).toEqual({

79+

success: false,

80+

issues: [{ path: ["enabled"], message: "must be boolean" }],

81+

});

82+

});

83+

});

84+
5085

describe("emptyChannelConfigSchema", () => {

5186

it("accepts undefined and empty objects only", () => {

5287

const result = emptyChannelConfigSchema();

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import { z, type ZodRawShape, type ZodTypeAny } from "zod";

22

import { DmPolicySchema } from "../../config/zod-schema.core.js";

3+

import { validateJsonSchemaValue } from "../../plugins/schema-validator.js";

34

import type { JsonSchemaObject } from "../../shared/json-schema.types.js";

45

import type {

56

ChannelConfigRuntimeIssue,

@@ -41,6 +42,12 @@ type BuildChannelConfigSchemaOptions = {

4142

uiHints?: Record<string, ChannelConfigUiHint>;

4243

};

4344
45+

type BuildJsonChannelConfigSchemaOptions = {

46+

cacheKey?: string;

47+

uiHints?: Record<string, ChannelConfigUiHint>;

48+

runtime?: ChannelConfigSchema["runtime"];

49+

};

50+
4451

function cloneRuntimeIssue(issue: unknown): ChannelConfigRuntimeIssue {

4552

const record = issue && typeof issue === "object" ? (issue as Record<string, unknown>) : {};

4653

const path = Array.isArray(record.path)

@@ -72,6 +79,53 @@ function safeParseRuntimeSchema(

7279

};

7380

}

7481
82+

function toIssuePath(path: string): Array<string | number> {

83+

if (!path || path === "<root>") {

84+

return [];

85+

}

86+

return path.split(".").map((segment) => {

87+

const index = Number(segment);

88+

return Number.isInteger(index) && String(index) === segment ? index : segment;

89+

});

90+

}

91+
92+

function safeParseJsonSchema(

93+

schema: JsonSchemaObject,

94+

cacheKey: string,

95+

value: unknown,

96+

): ChannelConfigRuntimeParseResult {

97+

const result = validateJsonSchemaValue({

98+

schema,

99+

cacheKey,

100+

value,

101+

applyDefaults: true,

102+

});

103+

if (result.ok) {

104+

return { success: true, data: result.value };

105+

}

106+

return {

107+

success: false,

108+

issues: result.errors.map((issue) => ({

109+

path: toIssuePath(issue.path),

110+

message: issue.message,

111+

})),

112+

};

113+

}

114+
115+

export function buildJsonChannelConfigSchema(

116+

schema: JsonSchemaObject,

117+

options?: BuildJsonChannelConfigSchemaOptions,

118+

): ChannelConfigSchema {

119+

return {

120+

schema,

121+

...(options?.uiHints ? { uiHints: options.uiHints } : {}),

122+

runtime: options?.runtime ?? {

123+

safeParse: (value) =>

124+

safeParseJsonSchema(schema, options?.cacheKey ?? "channel-config-schema:json", value),

125+

},

126+

};

127+

}

128+
75129

export function buildChannelConfigSchema(

76130

schema: ZodTypeAny,

77131

options?: BuildChannelConfigSchemaOptions,

Original file line numberDiff line numberDiff line change

@@ -3,6 +3,7 @@ export {

33

AllowFromListSchema,

44

buildChannelConfigSchema,

55

buildCatchallMultiAccountChannelSchema,

6+

buildJsonChannelConfigSchema,

67

buildNestedDmConfigSchema,

78

} from "../channels/plugins/config-schema.js";

89

export {

Original file line numberDiff line numberDiff line change

@@ -181,7 +181,11 @@ export type { PluginRuntime, RuntimeLogger } from "../plugins/runtime/types.js";

181181

export type { WizardPrompter } from "../wizard/prompts.js";

182182
183183

export { definePluginEntry } from "./plugin-entry.js";

184-

export { buildPluginConfigSchema, emptyPluginConfigSchema } from "../plugins/config-schema.js";

184+

export {

185+

buildJsonPluginConfigSchema,

186+

buildPluginConfigSchema,

187+

emptyPluginConfigSchema,

188+

} from "../plugins/config-schema.js";

185189

export { KeyedAsyncQueue, enqueueKeyedTask } from "./keyed-async-queue.js";

186190

export { createDedupeCache, resolveGlobalDedupeCache } from "../infra/dedupe.js";

187191

export { generateSecureToken, generateSecureUuid } from "../infra/secure-random.js";

@@ -192,6 +196,7 @@ export {

192196

export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";

193197

export {

194198

buildChannelConfigSchema,

199+

buildJsonChannelConfigSchema,

195200

emptyChannelConfigSchema,

196201

} from "../channels/plugins/config-schema.js";

197202

export {

Original file line numberDiff line numberDiff line change

@@ -223,7 +223,11 @@ export type {

223223

export type { ProviderRuntimeModel } from "../plugins/provider-runtime-model.types.js";

224224

export type { OpenClawConfig };

225225
226-

export { buildPluginConfigSchema, emptyPluginConfigSchema } from "../plugins/config-schema.js";

226+

export {

227+

buildJsonPluginConfigSchema,

228+

buildPluginConfigSchema,

229+

emptyPluginConfigSchema,

230+

} from "../plugins/config-schema.js";

227231
228232

/** Options for a plugin entry that registers providers, tools, commands, or services. */

229233

type DefinePluginEntryOptions = {

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,9 @@

11

import fs from "node:fs";

22

import path from "node:path";

3-

import { buildChannelConfigSchema } from "../channels/plugins/config-schema.js";

3+

import {

4+

buildChannelConfigSchema,

5+

buildJsonChannelConfigSchema,

6+

} from "../channels/plugins/config-schema.js";

47

import type { ChannelConfigRuntimeSchema } from "../channels/plugins/types.config.js";

58

import type { JsonSchemaObject } from "../shared/json-schema.types.js";

69

import {

@@ -46,6 +49,24 @@ function isBuiltChannelConfigSchema(value: unknown): value is ChannelConfigSurfa

4649

return Boolean(candidate.schema && typeof candidate.schema === "object");

4750

}

4851
52+

function isJsonSchemaConfigSurface(value: unknown): value is JsonSchemaObject {

53+

if (!value || typeof value !== "object") {

54+

return false;

55+

}

56+

const candidate = value as Record<string, unknown>;

57+

if (typeof candidate.safeParse === "function" || typeof candidate.toJSONSchema === "function") {

58+

return false;

59+

}

60+

return (

61+

typeof candidate.type === "string" ||

62+

Array.isArray(candidate.anyOf) ||

63+

Array.isArray(candidate.oneOf) ||

64+

Array.isArray(candidate.allOf) ||

65+

Array.isArray(candidate.enum) ||

66+

Object.prototype.hasOwnProperty.call(candidate, "const")

67+

);

68+

}

69+
4970

function resolveConfigSchemaExport(imported: Record<string, unknown>): ChannelConfigSurface | null {

5071

for (const [name, value] of Object.entries(imported)) {

5172

if (name.endsWith("ChannelConfigSchema") && isBuiltChannelConfigSchema(value)) {

@@ -60,6 +81,9 @@ function resolveConfigSchemaExport(imported: Record<string, unknown>): ChannelCo

6081

if (isBuiltChannelConfigSchema(value)) {

6182

return value;

6283

}

84+

if (isJsonSchemaConfigSurface(value)) {

85+

return buildJsonChannelConfigSchema(value);

86+

}

6387

if (value && typeof value === "object") {

6488

return buildChannelConfigSchema(value as never);

6589

}

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,10 @@

11

import { describe, expect, it, vi } from "vitest";

22

import { z } from "zod";

3-

import { buildPluginConfigSchema, emptyPluginConfigSchema } from "./config-schema.js";

3+

import {

4+

buildJsonPluginConfigSchema,

5+

buildPluginConfigSchema,

6+

emptyPluginConfigSchema,

7+

} from "./config-schema.js";

48
59

function expectSafeParseCases(

610

safeParse: ((value: unknown) => unknown) | undefined,

@@ -83,6 +87,37 @@ describe("buildPluginConfigSchema", () => {

8387

});

8488

});

8589
90+

describe("buildJsonPluginConfigSchema", () => {

91+

it("validates direct JSON schemas without zod conversion", () => {

92+

const result = buildJsonPluginConfigSchema(

93+

{

94+

type: "object",

95+

additionalProperties: false,

96+

properties: {

97+

enabled: { type: "boolean", default: true },

98+

},

99+

},

100+

{ cacheKey: "config-schema.test.json-plugin" },

101+

);

102+
103+

expect(result.jsonSchema).toEqual({

104+

type: "object",

105+

additionalProperties: false,

106+

properties: {

107+

enabled: { type: "boolean", default: true },

108+

},

109+

});

110+

expect(result.safeParse?.({})).toEqual({

111+

success: true,

112+

data: { enabled: true },

113+

});

114+

expect(result.safeParse?.({ enabled: "yes" })).toEqual({

115+

success: false,

116+

error: { issues: [{ path: ["enabled"], message: "must be boolean" }] },

117+

});

118+

});

119+

});

120+
86121

describe("emptyPluginConfigSchema", () => {

87122

it("accepts undefined and empty objects only", () => {

88123

const schema = emptyPluginConfigSchema();