mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 00:43:18 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
9
openclaw/packages/plugin-package-contract/package.json
Normal file
9
openclaw/packages/plugin-package-contract/package.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@openclaw/plugin-package-contract",
|
||||
"version": "0.0.0-private",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
}
|
||||
85
openclaw/packages/plugin-package-contract/src/index.test.ts
Normal file
85
openclaw/packages/plugin-package-contract/src/index.test.ts
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
EXTERNAL_CODE_PLUGIN_REQUIRED_FIELD_PATHS,
|
||||
listMissingExternalCodePluginFieldPaths,
|
||||
normalizeExternalPluginCompatibility,
|
||||
validateExternalCodePluginPackageJson,
|
||||
} from "./index.js";
|
||||
|
||||
describe("@openclaw/plugin-package-contract", () => {
|
||||
it("normalizes the OpenClaw compatibility block for external plugins", () => {
|
||||
expect(
|
||||
normalizeExternalPluginCompatibility({
|
||||
version: "1.2.3",
|
||||
openclaw: {
|
||||
compat: {
|
||||
pluginApi: ">=2026.3.24-beta.2",
|
||||
minGatewayVersion: "2026.3.24-beta.2",
|
||||
},
|
||||
build: {
|
||||
openclawVersion: "2026.3.24-beta.2",
|
||||
pluginSdkVersion: "0.9.0",
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
pluginApiRange: ">=2026.3.24-beta.2",
|
||||
builtWithOpenClawVersion: "2026.3.24-beta.2",
|
||||
pluginSdkVersion: "0.9.0",
|
||||
minGatewayVersion: "2026.3.24-beta.2",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to install.minHostVersion and package version when compatible", () => {
|
||||
expect(
|
||||
normalizeExternalPluginCompatibility({
|
||||
version: "1.2.3",
|
||||
openclaw: {
|
||||
compat: {
|
||||
pluginApi: ">=1.0.0",
|
||||
},
|
||||
install: {
|
||||
minHostVersion: "2026.3.24-beta.2",
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
pluginApiRange: ">=1.0.0",
|
||||
builtWithOpenClawVersion: "1.2.3",
|
||||
minGatewayVersion: "2026.3.24-beta.2",
|
||||
});
|
||||
});
|
||||
|
||||
it("lists the required external code-plugin fields", () => {
|
||||
expect(EXTERNAL_CODE_PLUGIN_REQUIRED_FIELD_PATHS).toEqual([
|
||||
"openclaw.compat.pluginApi",
|
||||
"openclaw.build.openclawVersion",
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports missing required fields with stable field paths", () => {
|
||||
const packageJson = {
|
||||
openclaw: {
|
||||
compat: {},
|
||||
build: {},
|
||||
},
|
||||
};
|
||||
|
||||
expect(listMissingExternalCodePluginFieldPaths(packageJson)).toEqual([
|
||||
"openclaw.compat.pluginApi",
|
||||
"openclaw.build.openclawVersion",
|
||||
]);
|
||||
expect(validateExternalCodePluginPackageJson(packageJson).issues).toEqual([
|
||||
{
|
||||
fieldPath: "openclaw.compat.pluginApi",
|
||||
message:
|
||||
"openclaw.compat.pluginApi is required for external code plugins published to ClawHub.",
|
||||
},
|
||||
{
|
||||
fieldPath: "openclaw.build.openclawVersion",
|
||||
message:
|
||||
"openclaw.build.openclawVersion is required for external code plugins published to ClawHub.",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
91
openclaw/packages/plugin-package-contract/src/index.ts
Normal file
91
openclaw/packages/plugin-package-contract/src/index.ts
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
import { normalizeOptionalString } from "../../../src/shared/string-coerce.js";
|
||||
import { isRecord } from "../../../src/utils.js";
|
||||
|
||||
export type JsonObject = Record<string, unknown>;
|
||||
|
||||
export type ExternalPluginCompatibility = {
|
||||
pluginApiRange?: string;
|
||||
builtWithOpenClawVersion?: string;
|
||||
pluginSdkVersion?: string;
|
||||
minGatewayVersion?: string;
|
||||
};
|
||||
|
||||
export type ExternalPluginValidationIssue = {
|
||||
fieldPath: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type ExternalCodePluginValidationResult = {
|
||||
compatibility?: ExternalPluginCompatibility;
|
||||
issues: ExternalPluginValidationIssue[];
|
||||
};
|
||||
|
||||
export const EXTERNAL_CODE_PLUGIN_REQUIRED_FIELD_PATHS = [
|
||||
"openclaw.compat.pluginApi",
|
||||
"openclaw.build.openclawVersion",
|
||||
] as const;
|
||||
|
||||
function readOpenClawBlock(packageJson: unknown) {
|
||||
const root = isRecord(packageJson) ? packageJson : undefined;
|
||||
const openclaw = isRecord(root?.openclaw) ? root.openclaw : undefined;
|
||||
const compat = isRecord(openclaw?.compat) ? openclaw.compat : undefined;
|
||||
const build = isRecord(openclaw?.build) ? openclaw.build : undefined;
|
||||
const install = isRecord(openclaw?.install) ? openclaw.install : undefined;
|
||||
return { root, openclaw, compat, build, install };
|
||||
}
|
||||
|
||||
export function normalizeExternalPluginCompatibility(
|
||||
packageJson: unknown,
|
||||
): ExternalPluginCompatibility | undefined {
|
||||
const { root, compat, build, install } = readOpenClawBlock(packageJson);
|
||||
const version = normalizeOptionalString(root?.version);
|
||||
const minHostVersion = normalizeOptionalString(install?.minHostVersion);
|
||||
const compatibility: ExternalPluginCompatibility = {};
|
||||
|
||||
const pluginApi = normalizeOptionalString(compat?.pluginApi);
|
||||
if (pluginApi) {
|
||||
compatibility.pluginApiRange = pluginApi;
|
||||
}
|
||||
|
||||
const minGatewayVersion = normalizeOptionalString(compat?.minGatewayVersion) ?? minHostVersion;
|
||||
if (minGatewayVersion) {
|
||||
compatibility.minGatewayVersion = minGatewayVersion;
|
||||
}
|
||||
|
||||
const builtWithOpenClawVersion = normalizeOptionalString(build?.openclawVersion) ?? version;
|
||||
if (builtWithOpenClawVersion) {
|
||||
compatibility.builtWithOpenClawVersion = builtWithOpenClawVersion;
|
||||
}
|
||||
|
||||
const pluginSdkVersion = normalizeOptionalString(build?.pluginSdkVersion);
|
||||
if (pluginSdkVersion) {
|
||||
compatibility.pluginSdkVersion = pluginSdkVersion;
|
||||
}
|
||||
|
||||
return Object.keys(compatibility).length > 0 ? compatibility : undefined;
|
||||
}
|
||||
|
||||
export function listMissingExternalCodePluginFieldPaths(packageJson: unknown): string[] {
|
||||
const { compat, build } = readOpenClawBlock(packageJson);
|
||||
const missing: string[] = [];
|
||||
if (!normalizeOptionalString(compat?.pluginApi)) {
|
||||
missing.push("openclaw.compat.pluginApi");
|
||||
}
|
||||
if (!normalizeOptionalString(build?.openclawVersion)) {
|
||||
missing.push("openclaw.build.openclawVersion");
|
||||
}
|
||||
return missing;
|
||||
}
|
||||
|
||||
export function validateExternalCodePluginPackageJson(
|
||||
packageJson: unknown,
|
||||
): ExternalCodePluginValidationResult {
|
||||
const issues = listMissingExternalCodePluginFieldPaths(packageJson).map((fieldPath) => ({
|
||||
fieldPath,
|
||||
message: `${fieldPath} is required for external code plugins published to ClawHub.`,
|
||||
}));
|
||||
return {
|
||||
compatibility: normalizeExternalPluginCompatibility(packageJson),
|
||||
issues,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue