mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-04 10:10:01 +00:00
* feat: add selectable Code Mode executors Default enabled Code Mode to trusted Node execution and move QuickJS into a bundled executor plugin. Preserve typed discovery, JavaScript-only execution, tool authorization, continuation ownership, and explicit legacy QuickJS selections. Add a web settings selector and document both security boundaries. * refactor: finish Code Mode executor source cutover Remove the retired core worker copies and regenerate config documentation for the requested QuickJS plugin. The 21 added plugin paths are standard plugin management fields; core and channel counts stay unchanged. * refactor: narrow the Code Mode plugin contract Keep only the executor and guest protocol exports consumed by the QuickJS plugin, budget that generic contract, and load the public plugin artifact through the existing runtime test boundary. * refactor: align Code Mode workers with current runtime boundaries Use the worker-side task server, keep asynchronous cleanup ownership explicit, and model the real Promise contracts in lifecycle fixtures. Regenerate the requested plugin config surface and budget the exact 35 public executor exports. * refactor: keep executor implementation types private * chore: regenerate code mode config baseline * fix: satisfy Code Mode executor integration contracts * test: cover QuickJS plugin metadata and exact settings titles * test: retain QuickJS integration in the agent runtime suite * test: keep Code Mode validation within lint and type-shard contracts
68 lines
2.9 KiB
TypeScript
68 lines
2.9 KiB
TypeScript
import { isRecord } from "@openclaw/normalization-core/record-coerce";
|
|
import type { CodeModeExecutor } from "../agents/code-mode-executor-types.js";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { normalizePluginsConfig } from "./config-state.js";
|
|
import {
|
|
hasManifestContractValue,
|
|
isManifestPluginAvailableForControlPlane,
|
|
loadManifestMetadataSnapshot,
|
|
} from "./manifest-contract-eligibility.js";
|
|
import { passesManifestOwnerBasePolicy } from "./manifest-owner-policy.js";
|
|
import { loadValidatedPublicSurfaceModule } from "./public-surface-loader.js";
|
|
import { resolvePluginRootPublicSurfacePath } from "./public-surface-runtime.js";
|
|
|
|
/** Explicit executor selection activates only its admitted manifest owner. */
|
|
export function resolvePluginCodeModeExecutor(
|
|
executorId: CodeModeExecutor["id"],
|
|
config?: OpenClawConfig,
|
|
): CodeModeExecutor {
|
|
const snapshot = loadManifestMetadataSnapshot({ config });
|
|
const normalizedConfig = normalizePluginsConfig(config?.plugins);
|
|
const owners = snapshot.plugins.filter(
|
|
(plugin) =>
|
|
hasManifestContractValue({ plugin, contract: "codeModeExecutors", value: executorId }) &&
|
|
isManifestPluginAvailableForControlPlane({
|
|
snapshot,
|
|
plugin,
|
|
config,
|
|
normalizedConfig,
|
|
// A selected bundled executor replaces a core runtime and keeps its availability.
|
|
allowRestrictiveAllowlistBypass: plugin.origin === "bundled",
|
|
}) &&
|
|
(plugin.origin === "bundled" || passesManifestOwnerBasePolicy({ plugin, normalizedConfig })),
|
|
);
|
|
const [owner, ...otherOwners] = owners;
|
|
if (!owner || otherOwners.length > 0) {
|
|
throw new Error(
|
|
!owner
|
|
? `Code Mode executor "${executorId}" is unavailable or disabled. Enable its plugin or select another executor.`
|
|
: `Code Mode executor "${executorId}" has multiple plugin owners: ${owners.map((candidate) => candidate.id).join(", ")}. Enable only one owner.`,
|
|
);
|
|
}
|
|
const modulePath = resolvePluginRootPublicSurfacePath({
|
|
pluginRoot: owner.rootDir,
|
|
pluginId: owner.id,
|
|
entrySource: owner.source,
|
|
artifactBasename: "code-mode-executor-api.js",
|
|
});
|
|
if (!modulePath) {
|
|
throw new Error(
|
|
`Code Mode executor "${executorId}" plugin "${owner.id}" is missing its runtime artifact.`,
|
|
);
|
|
}
|
|
const module = loadValidatedPublicSurfaceModule({
|
|
modulePath,
|
|
boundaryRoot: owner.rootDir,
|
|
surfaceLabel: "Code Mode executor",
|
|
origin: owner.origin,
|
|
pluginId: owner.id,
|
|
});
|
|
const executor: unknown = "codeModeExecutor" in module ? module.codeModeExecutor : undefined;
|
|
if (!isRecord(executor) || executor.id !== executorId || typeof executor.execute !== "function") {
|
|
throw new Error(
|
|
`Code Mode executor "${executorId}" plugin "${owner.id}" has an invalid runtime artifact.`,
|
|
);
|
|
}
|
|
// SAFETY: Admitted native artifacts implement the SDK contract; the selected id and callable entry are checked above.
|
|
return executor as CodeModeExecutor;
|
|
}
|