import fs from "node:fs"; import { createRequire } from "node:module"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { formatPluginConfigIssue } from "openclaw/plugin-sdk/extension-shared"; import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime"; import { AcpxPluginConfigSchema, DEFAULT_ACPX_TIMEOUT_SECONDS } from "./config-schema.js"; import type {
AcpxPluginConfig,
AcpxPermissionMode,
AcpxNonInteractivePermissionPolicy,
McpServerConfig,
AcpxMcpServer,
ResolvedAcpxPluginConfig,
} from "./config-schema.js";
export {
ACPX_NON_INTERACTIVE_POLICIES,
ACPX_PERMISSION_MODES,
type AcpxMcpServer,
type AcpxNonInteractivePermissionPolicy,
type AcpxPermissionMode,
type AcpxPluginConfig,
type McpServerConfig,
type ResolvedAcpxPluginConfig,
createAcpxPluginConfigSchema,
} from "./config-schema.js";
function resolveNearestAcpxPluginRoot(moduleUrl: string): string {
let cursor = path.dirname(fileURLToPath(moduleUrl)); for (let i = 0; i < 3; i += 1) { // Bundled entries live at the plugin root while source files still live under src/. if (isAcpxPluginRoot(cursor)) { return cursor;
} const parent = path.dirname(cursor); if (parent === cursor) { break;
}
cursor = parent;
} return path.resolve(path.dirname(fileURLToPath(moduleUrl)), "..");
}
function resolveAcpxPluginRootFromOpenClawLayout(moduleUrl: string): string | null {
let cursor = path.dirname(fileURLToPath(moduleUrl)); for (let i = 0; i < 5; i += 1) { const candidates = [
path.join(cursor, "extensions", "acpx"),
path.join(cursor, "dist", "extensions", "acpx"),
path.join(cursor, "dist-runtime", "extensions", "acpx"),
]; for (const candidate of candidates) { if (isAcpxPluginRoot(candidate)) { return candidate;
}
} const parent = path.dirname(cursor); if (parent === cursor) { break;
}
cursor = parent;
} returnnull;
}
export function resolveAcpxPluginRoot(moduleUrl: string = import.meta.url): string { const resolvedRoot = resolveNearestAcpxPluginRoot(moduleUrl); // In a live repo checkout, dist/ can be rebuilt out from under the running gateway. // Prefer the stable source plugin root when a built extension is running beside it. return (
resolveWorkspaceAcpxPluginRoot(resolvedRoot) ??
resolveRepoAcpxPluginRoot(resolvedRoot) ?? // Shared dist/dist-runtime chunks can load this module outside the plugin tree. // Scan common OpenClaw layouts before falling back to the nearest path guess.
resolveAcpxPluginRootFromOpenClawLayout(moduleUrl) ??
resolvedRoot
);
}
// Lowercase probeAgent so lookups match the registry keys built above, which // also go through normalizeLowercaseStringOrEmpty. Without this, a user who // writes `probeAgent: "OpenCode"` would silently miss the stored "opencode" // key. const probeAgent = normalizeLowercaseStringOrEmpty(normalized.probeAgent) || undefined;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.