perf: optimize plugin schema validation

This commit is contained in:
Peter Steinberger
2026-05-02 16:15:37 +01:00
parent 0cf51b77fb
commit a3564ae546
13 changed files with 335 additions and 12 deletions

View File

@@ -399,6 +399,20 @@ const accountSchema = z.object({
const configSchema = buildChannelConfigSchema(accountSchema);
```
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:
```typescript
import { Type } from "typebox";
import { buildJsonChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
const configSchema = buildJsonChannelConfigSchema(
Type.Object({
token: Type.Optional(Type.String()),
allowFrom: Type.Optional(Type.Array(Type.String())),
}),
);
```
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.
## Setup wizards