fix: define openclaw plugin entry
This commit is contained in:
parent
df3aab97be
commit
80bbce0955
7
dist/index.d.ts
vendored
7
dist/index.d.ts
vendored
@ -1,9 +1,8 @@
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
||||
declare const plugin: {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
register: typeof register;
|
||||
};
|
||||
configSchema: import("openclaw/plugin-sdk/core").OpenClawPluginConfigSchema;
|
||||
register: NonNullable<import("openclaw/plugin-sdk/core").OpenClawPluginDefinition["register"]>;
|
||||
} & Pick<import("openclaw/plugin-sdk/core").OpenClawPluginDefinition, "kind" | "reload" | "nodeHostCommands" | "securityAuditCollectors">;
|
||||
export default plugin;
|
||||
declare function register(api: OpenClawPluginApi): void;
|
||||
|
||||
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -1,3 +1,4 @@
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { getPluginRuntimeGatewayRequestScope } from "openclaw/plugin-sdk/plugin-runtime";
|
||||
import { collectAndSnapshotXWorkmateArtifacts, exportXWorkmateArtifacts, prepareXWorkmateArtifacts, readXWorkmateArtifact, formatArtifactManifestMarkdown, } from "./src/exportArtifacts.js";
|
||||
import { getXWorkmateTaskSnapshot, recordXWorkmateSessionMapping, registerXWorkmateSessionExtension, } from "./src/taskState.js";
|
||||
@ -32,12 +33,12 @@ function resolveRunScope(ctx) {
|
||||
function stringParam(value) {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
const plugin = {
|
||||
const plugin = definePluginEntry({
|
||||
id: "openclaw-multi-session-plugins",
|
||||
name: "openclaw-multi-session-plugins",
|
||||
description: "OpenClaw logical isolation support for multi-session plugin runtimes and scoped XWorkmate artifacts.",
|
||||
register,
|
||||
};
|
||||
});
|
||||
export default plugin;
|
||||
function register(api) {
|
||||
registerXWorkmateSessionExtension(api);
|
||||
|
||||
4
dist/src/exportArtifacts.d.ts
vendored
4
dist/src/exportArtifacts.d.ts
vendored
@ -24,6 +24,10 @@ type XWorkmateArtifactExport = {
|
||||
expectedArtifactDirStatus: XWorkmateExpectedArtifactDirStatus[];
|
||||
constraintSatisfied: boolean;
|
||||
missingRequiredExtensions: string[];
|
||||
missingRequiredFileCounts: Record<string, {
|
||||
expected: number;
|
||||
actual: number;
|
||||
}>;
|
||||
};
|
||||
type XWorkmateArtifactPrepare = {
|
||||
runId: string;
|
||||
|
||||
37
dist/src/exportArtifacts.js
vendored
37
dist/src/exportArtifacts.js
vendored
@ -131,6 +131,7 @@ export async function exportXWorkmateArtifacts(input) {
|
||||
const sinceUnixMs = nonNegativeNumber(params.sinceUnixMs, 0);
|
||||
const includeContent = optionalBoolean(params.includeContent, true);
|
||||
const requiredArtifactExtensions = normalizeRequiredExtensions(params.requiredArtifactExtensions);
|
||||
const expectedFileCountByExtension = normalizeExpectedFileCountByExtension(params.expectedFileCountByExtension);
|
||||
const workspaceDir = resolveWorkspaceDir({
|
||||
config: input.config,
|
||||
pluginConfig,
|
||||
@ -248,6 +249,7 @@ export async function exportXWorkmateArtifacts(input) {
|
||||
artifacts.push(artifact);
|
||||
}
|
||||
const missingRequiredExtensions = missingRequiredArtifactExtensions(artifacts, requiredArtifactExtensions);
|
||||
const missingRequiredFileCounts = missingRequiredArtifactFileCounts(artifacts, expectedFileCountByExtension);
|
||||
const result = {
|
||||
runId,
|
||||
sessionKey,
|
||||
@ -259,8 +261,9 @@ export async function exportXWorkmateArtifacts(input) {
|
||||
warnings,
|
||||
expectedArtifactDirs: expectedDirs,
|
||||
expectedArtifactDirStatus: await expectedArtifactDirStatuses(workspaceRoot, expectedDirs),
|
||||
constraintSatisfied: missingRequiredExtensions.length === 0,
|
||||
constraintSatisfied: missingRequiredExtensions.length === 0 && Object.keys(missingRequiredFileCounts).length === 0,
|
||||
missingRequiredExtensions,
|
||||
missingRequiredFileCounts,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
@ -367,6 +370,7 @@ export async function readXWorkmateArtifact(input) {
|
||||
expectedArtifactDirStatus: [],
|
||||
constraintSatisfied: true,
|
||||
missingRequiredExtensions: [],
|
||||
missingRequiredFileCounts: {},
|
||||
};
|
||||
return result;
|
||||
}
|
||||
@ -404,6 +408,37 @@ function missingRequiredArtifactExtensions(artifacts, requiredExtensions) {
|
||||
}
|
||||
return requiredExtensions.filter((extension) => !artifacts.some((artifact) => artifact.relativePath.toLowerCase().endsWith(`.${extension}`)));
|
||||
}
|
||||
function normalizeExpectedFileCountByExtension(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
||||
return {};
|
||||
}
|
||||
const result = {};
|
||||
for (const [rawExtension, rawCount] of Object.entries(value)) {
|
||||
const extension = rawExtension
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/^\.+/u, "");
|
||||
if (!extension || extension.includes("/") || extension.includes("\\") || extension.includes("\0")) {
|
||||
continue;
|
||||
}
|
||||
const count = typeof rawCount === "number" ? rawCount : Number.parseInt(optionalString(rawCount), 10);
|
||||
if (!Number.isFinite(count) || count <= 0) {
|
||||
continue;
|
||||
}
|
||||
result[extension] = Math.floor(count);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function missingRequiredArtifactFileCounts(artifacts, expectedFileCountByExtension) {
|
||||
const missing = {};
|
||||
for (const [extension, expected] of Object.entries(expectedFileCountByExtension)) {
|
||||
const actual = artifacts.filter((artifact) => artifact.relativePath.toLowerCase().endsWith(`.${extension}`)).length;
|
||||
if (actual < expected) {
|
||||
missing[extension] = { expected, actual };
|
||||
}
|
||||
}
|
||||
return missing;
|
||||
}
|
||||
async function expectedArtifactDirStatuses(workspaceRoot, expectedArtifactDirs) {
|
||||
const statuses = [];
|
||||
for (const relativePath of expectedArtifactDirs) {
|
||||
|
||||
5
index.ts
5
index.ts
@ -3,6 +3,7 @@ import type {
|
||||
GatewayRequestHandlerOptions,
|
||||
OpenClawPluginApi,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { getPluginRuntimeGatewayRequestScope } from "openclaw/plugin-sdk/plugin-runtime";
|
||||
import {
|
||||
collectAndSnapshotXWorkmateArtifacts,
|
||||
@ -83,12 +84,12 @@ function stringParam(value: unknown): string {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
const plugin = {
|
||||
const plugin = definePluginEntry({
|
||||
id: "openclaw-multi-session-plugins",
|
||||
name: "openclaw-multi-session-plugins",
|
||||
description: "OpenClaw logical isolation support for multi-session plugin runtimes and scoped XWorkmate artifacts.",
|
||||
register,
|
||||
};
|
||||
});
|
||||
|
||||
export default plugin;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user