mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor: remove dead core and extension exports (#104963)
* refactor(agents): remove obsolete exec eligibility helper * refactor(diffs): internalize viewer-only state * refactor(qa-lab): internalize implementation helpers
This commit is contained in:
@@ -135,13 +135,12 @@ describe("hydrateViewer", () => {
|
||||
fileDiffHydrateMock.mockImplementationOnce(() => {
|
||||
throw new Error("broken card");
|
||||
});
|
||||
const { controllers, hydrateViewer } = await import("./viewer-client.js");
|
||||
controllers.splice(0);
|
||||
const { hydrateViewer } = await import("./viewer-client.js");
|
||||
|
||||
await hydrateViewer();
|
||||
|
||||
expect(fileDiffHydrateMock).toHaveBeenCalledTimes(2);
|
||||
expect(controllers).toHaveLength(1);
|
||||
expect(fileDiffRerenderMock).toHaveBeenCalledTimes(1);
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"Skipping diff card that failed to hydrate",
|
||||
expect.any(Error),
|
||||
@@ -157,14 +156,13 @@ describe("hydrateViewer", () => {
|
||||
fileDiffSetOptionsMock.mockImplementationOnce(() => {
|
||||
throw new Error("broken options");
|
||||
});
|
||||
const { controllers, hydrateViewer } = await import("./viewer-client.js");
|
||||
controllers.splice(0);
|
||||
const { hydrateViewer } = await import("./viewer-client.js");
|
||||
|
||||
await hydrateViewer();
|
||||
|
||||
expect(fileDiffHydrateMock).toHaveBeenCalledTimes(2);
|
||||
expect(fileDiffSetOptionsMock).toHaveBeenCalledTimes(2);
|
||||
expect(controllers).toHaveLength(1);
|
||||
expect(fileDiffRerenderMock).toHaveBeenCalledTimes(1);
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"Skipping diff card that failed to hydrate",
|
||||
expect.any(Error),
|
||||
@@ -175,30 +173,22 @@ describe("hydrateViewer", () => {
|
||||
|
||||
it("replaces stale controllers when hydrating the current cards again", async () => {
|
||||
renderCard();
|
||||
const { controllers, hydrateViewer } = await import("./viewer-client.js");
|
||||
controllers.splice(0);
|
||||
const { hydrateViewer } = await import("./viewer-client.js");
|
||||
|
||||
await hydrateViewer();
|
||||
expect(controllers).toHaveLength(1);
|
||||
const firstController = controllers[0];
|
||||
|
||||
document.body.innerHTML = "";
|
||||
renderCard();
|
||||
await hydrateViewer();
|
||||
|
||||
expect(controllers).toHaveLength(1);
|
||||
expect(controllers[0]).not.toBe(firstController);
|
||||
expect(fileDiffHydrateMock).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
const currentOptions = fileDiffSetOptionsMock.mock.calls.at(-1)?.[0] as Record<string, unknown>;
|
||||
const renderHeaderMetadata = currentOptions.renderHeaderMetadata as () => HTMLElement;
|
||||
fileDiffRerenderMock.mockClear();
|
||||
|
||||
describe("resolveViewerLanguagePackAvailability", () => {
|
||||
it("resolves defined and undefined build flags", async () => {
|
||||
const { resolveViewerLanguagePackAvailability } = await import("./viewer-client.js");
|
||||
renderHeaderMetadata().querySelector<HTMLButtonElement>("button")?.click();
|
||||
|
||||
expect(resolveViewerLanguagePackAvailability(true)).toBe(true);
|
||||
expect(resolveViewerLanguagePackAvailability(false)).toBe(false);
|
||||
expect(resolveViewerLanguagePackAvailability(undefined)).toBe(false);
|
||||
expect(fileDiffRerenderMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -447,12 +437,10 @@ describe("header metadata", () => {
|
||||
'<nav class="oc-diff-card oc-diff-nav" aria-label="Changed files"><ol></ol></nav>',
|
||||
);
|
||||
renderCard();
|
||||
const { controllers, hydrateViewer } = await import("./viewer-client.js");
|
||||
controllers.splice(0);
|
||||
const { hydrateViewer } = await import("./viewer-client.js");
|
||||
|
||||
await hydrateViewer();
|
||||
|
||||
expect(controllers).toHaveLength(1);
|
||||
expect(fileDiffHydrateMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ function readInjectedLanguagePackFlag(): boolean | undefined {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function resolveViewerLanguagePackAvailability(
|
||||
function resolveViewerLanguagePackAvailability(
|
||||
buildFlag: boolean | undefined = readInjectedLanguagePackFlag(),
|
||||
): boolean {
|
||||
return buildFlag === true;
|
||||
@@ -39,7 +39,7 @@ type DiffController = {
|
||||
diff: FileDiff;
|
||||
};
|
||||
|
||||
export const controllers: DiffController[] = [];
|
||||
const controllers: DiffController[] = [];
|
||||
|
||||
const viewerState: ViewerState = {
|
||||
theme: "dark",
|
||||
@@ -372,7 +372,7 @@ async function main(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export const disableAutoStartKey = Symbol.for("openclaw.diffs.disableAutoStart");
|
||||
const disableAutoStartKey = Symbol.for("openclaw.diffs.disableAutoStart");
|
||||
|
||||
const autoStartDisabled = Boolean(
|
||||
(globalThis as typeof globalThis & Record<symbol, unknown>)[disableAutoStartKey],
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Qa Lab tests cover cron run wait plugin behavior.
|
||||
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { resolveCronRunPollIntervalMs, waitForCronRunCompletion } from "./cron-run-wait.js";
|
||||
import { waitForCronRunCompletion } from "./cron-run-wait.js";
|
||||
|
||||
describe("waitForCronRunCompletion", () => {
|
||||
it("ignores older entries and returns the newly finished run", async () => {
|
||||
@@ -53,10 +52,6 @@ describe("waitForCronRunCompletion", () => {
|
||||
).rejects.toThrow(/timed out waiting for cron run completion/);
|
||||
});
|
||||
|
||||
it("clamps oversized poll intervals before sleeping", () => {
|
||||
expect(resolveCronRunPollIntervalMs(Number.MAX_SAFE_INTEGER)).toBe(MAX_TIMER_TIMEOUT_MS);
|
||||
});
|
||||
|
||||
it("keeps oversized poll intervals within the overall timeout", async () => {
|
||||
const callGateway = vi
|
||||
.fn<
|
||||
|
||||
@@ -15,7 +15,7 @@ type QaCronRunsPage = {
|
||||
entries?: QaCronRunLogEntry[];
|
||||
};
|
||||
|
||||
export function resolveCronRunPollIntervalMs(intervalMs: number | undefined): number {
|
||||
function resolveCronRunPollIntervalMs(intervalMs: number | undefined): number {
|
||||
return resolveTimerTimeoutMs(intervalMs ?? 1_000, 1_000, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
resolveQaEvidenceArtifactFileByIndex,
|
||||
resolveQaEvidenceArtifactFile,
|
||||
resolveQaEvidenceProducerFile,
|
||||
resolveQaEvidenceFile,
|
||||
} from "./evidence-gallery.js";
|
||||
import {
|
||||
QA_EVIDENCE_FILENAME,
|
||||
@@ -616,9 +615,11 @@ describe("evidence gallery", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(resolveQaEvidenceFile({ inputPath: outputDir, repoRoot })).resolves.toBe(
|
||||
await fs.realpath(evidencePath),
|
||||
);
|
||||
await expect(
|
||||
buildQaEvidenceGalleryModel({ evidencePath: outputDir, repoRoot }),
|
||||
).resolves.toMatchObject({
|
||||
counts: { blocked: 0, fail: 0, pass: 1, skipped: 0 },
|
||||
});
|
||||
await expect(
|
||||
resolveQaEvidenceArtifactFile({
|
||||
artifactPath: "artifact.log",
|
||||
@@ -694,7 +695,10 @@ describe("evidence gallery", () => {
|
||||
}),
|
||||
).rejects.toThrow("Evidence artifact not found.");
|
||||
await expect(
|
||||
resolveQaEvidenceFile({ inputPath: "/tmp/not-openclaw-evidence.json", repoRoot }),
|
||||
buildQaEvidenceGalleryModel({
|
||||
evidencePath: "/tmp/not-openclaw-evidence.json",
|
||||
repoRoot,
|
||||
}),
|
||||
).rejects.toThrow("Evidence path not found.");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ async function resolveContainedFileIfExists(
|
||||
return stats?.isFile() ? realFile : null;
|
||||
}
|
||||
|
||||
export async function resolveQaEvidenceFile(params: {
|
||||
async function resolveQaEvidenceFile(params: {
|
||||
inputPath: string;
|
||||
repoRoot: string;
|
||||
}): Promise<string> {
|
||||
|
||||
@@ -5,7 +5,6 @@ import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
createMockJsonlReplayCellRunner,
|
||||
extractJsonlReplayUserTurns,
|
||||
renderJsonlReplayMarkdownReport,
|
||||
runJsonlReplay,
|
||||
type JsonlReplayCellRunner,
|
||||
@@ -56,8 +55,10 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("jsonl replay", () => {
|
||||
it("extracts user-turn boundaries while ignoring system, tool-only, empty, and malformed rows", () => {
|
||||
const turns = extractJsonlReplayUserTurns(
|
||||
it("extracts user-turn boundaries while ignoring system, tool-only, empty, and malformed rows", async () => {
|
||||
const transcriptDir = await makeTempDir();
|
||||
await fs.writeFile(
|
||||
path.join(transcriptDir, "turns.jsonl"),
|
||||
[
|
||||
`{"message":{"role":"system","content":"System setup"}}`,
|
||||
`{"message":{"role":"tool","content":"tool-only prelude"}}`,
|
||||
@@ -67,6 +68,21 @@ describe("jsonl replay", () => {
|
||||
`{"message":{"role":"user","content":[{"type":"text","text":"Plan the release"},{"type":"tool_result","content":"ignored"}]}}`,
|
||||
`{"role":"user","content":[{"type":"input_text","text":"Check the follow-up"}]}`,
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
let turns: readonly Parameters<JsonlReplayCellRunner>[0]["turn"][] = [];
|
||||
const runCell: JsonlReplayCellRunner = async (params) => {
|
||||
turns = params.turns;
|
||||
return createMockJsonlReplayCellRunner()(params);
|
||||
};
|
||||
|
||||
await runJsonlReplay(
|
||||
{
|
||||
directory: transcriptDir,
|
||||
runtimePair: ["openclaw", "codex"],
|
||||
providerMode: "mock-openai",
|
||||
},
|
||||
{ runCell },
|
||||
);
|
||||
|
||||
expect(turns).toEqual([
|
||||
|
||||
@@ -105,7 +105,7 @@ function extractTextContent(content: unknown): string {
|
||||
return parts.join("\n").trim();
|
||||
}
|
||||
|
||||
export function extractJsonlReplayUserTurns(transcriptBytes: string): JsonlReplayTurn[] {
|
||||
function extractJsonlReplayUserTurns(transcriptBytes: string): JsonlReplayTurn[] {
|
||||
const turns: JsonlReplayTurn[] = [];
|
||||
const acceptedLines: string[] = [];
|
||||
for (const [lineIndex, rawLine] of transcriptBytes.split(/\r?\n/u).entries()) {
|
||||
|
||||
@@ -5,13 +5,8 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { setTimeout as sleep } from "node:timers/promises";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { readQaJsonBody } from "./bus-server.js";
|
||||
import { resolveUiAssetVersion } from "./lab-server-ui.js";
|
||||
import {
|
||||
startQaLabServer,
|
||||
writeQaLabServerError,
|
||||
type QaLabServerStartParams,
|
||||
} from "./lab-server.js";
|
||||
import { startQaLabServer, type QaLabServerStartParams } from "./lab-server.js";
|
||||
|
||||
const qaChannelMock = vi.hoisted(() => ({
|
||||
resolveAccount: vi.fn(),
|
||||
@@ -607,38 +602,6 @@ describe("qa-lab server", () => {
|
||||
expect(outsideResponse.status).toBe(404);
|
||||
});
|
||||
|
||||
it("returns controlled errors for oversized JSON body reads", async () => {
|
||||
const req = {
|
||||
headers: { "content-length": String(1024 * 1024 + 1) },
|
||||
destroyed: false,
|
||||
destroy() {
|
||||
this.destroyed = true;
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
statusCode: 0,
|
||||
body: "",
|
||||
writeHead(statusCode: number) {
|
||||
this.statusCode = statusCode;
|
||||
},
|
||||
end(payload: string) {
|
||||
this.body = payload;
|
||||
},
|
||||
};
|
||||
|
||||
let error: unknown;
|
||||
try {
|
||||
await readQaJsonBody(req as never);
|
||||
} catch (caught) {
|
||||
error = caught;
|
||||
}
|
||||
|
||||
writeQaLabServerError(res as never, error);
|
||||
|
||||
expect(res.statusCode).toBe(413);
|
||||
expect(JSON.parse(res.body)).toEqual({ error: "Payload too large" });
|
||||
});
|
||||
|
||||
it("returns controlled errors for malformed JSON body reads", async () => {
|
||||
const lab = await startQaLabServerForTest();
|
||||
cleanups.push(async () => {
|
||||
|
||||
@@ -73,7 +73,7 @@ export type {
|
||||
QaLabServerStartParams,
|
||||
} from "./lab-server.types.js";
|
||||
|
||||
export function writeQaLabServerError(res: Parameters<typeof writeError>[0], error: unknown): void {
|
||||
function writeQaLabServerError(res: Parameters<typeof writeError>[0], error: unknown): void {
|
||||
if (writeQaRequestBodyLimitError(res, error)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
loadQaRunnerModelOptions,
|
||||
parseQaRunnerModelOptionsOutput,
|
||||
selectQaRunnerModelOptions,
|
||||
} from "./model-catalog.runtime.js";
|
||||
import { loadQaRunnerModelOptions } from "./model-catalog.runtime.js";
|
||||
import { createTempDirHarness } from "./temp-dir.test-helper.js";
|
||||
|
||||
const { cleanup, makeTempDir } = createTempDirHarness();
|
||||
@@ -51,46 +47,22 @@ async function waitForDead(pid: number, timeoutMs: number): Promise<void> {
|
||||
}
|
||||
|
||||
describe("qa runner model catalog", () => {
|
||||
it("filters to available rows and prefers gpt-5.6-luna first", () => {
|
||||
expect(
|
||||
selectQaRunnerModelOptions([
|
||||
{
|
||||
key: "anthropic/claude-sonnet-4-6",
|
||||
name: "Claude Sonnet 4.6",
|
||||
input: "text",
|
||||
available: true,
|
||||
missing: false,
|
||||
},
|
||||
{
|
||||
key: "openai/gpt-5.6-luna",
|
||||
name: "gpt-5.6-luna",
|
||||
input: "text,image",
|
||||
available: true,
|
||||
missing: false,
|
||||
},
|
||||
{
|
||||
key: "openrouter/auto",
|
||||
name: "OpenRouter Auto",
|
||||
input: "text",
|
||||
available: false,
|
||||
missing: false,
|
||||
},
|
||||
]).map((entry) => entry.key),
|
||||
).toEqual(["openai/gpt-5.6-luna", "anthropic/claude-sonnet-4-6"]);
|
||||
});
|
||||
|
||||
it("reports malformed catalog JSON with an owned error", () => {
|
||||
expect(() => parseQaRunnerModelOptionsOutput("{not json")).toThrow(
|
||||
"qa model catalog returned malformed JSON",
|
||||
);
|
||||
});
|
||||
|
||||
it("ignores invalid catalog rows without failing the model picker", () => {
|
||||
expect(
|
||||
parseQaRunnerModelOptionsOutput(
|
||||
it("filters catalog output and prefers gpt-5.6-luna first", async () => {
|
||||
const repoRoot = await makeTempDir("openclaw-qa-model-catalog-output-");
|
||||
await fs.mkdir(path.join(repoRoot, "dist"), { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(repoRoot, "dist", "index.js"),
|
||||
`process.stdout.write(${JSON.stringify(
|
||||
JSON.stringify({
|
||||
models: [
|
||||
null,
|
||||
{
|
||||
key: "anthropic/claude-sonnet-4-6",
|
||||
name: "Claude Sonnet 4.6",
|
||||
input: "text",
|
||||
available: true,
|
||||
missing: false,
|
||||
},
|
||||
{
|
||||
key: "openai/gpt-5.6-luna",
|
||||
name: "gpt-5.6-luna",
|
||||
@@ -98,10 +70,37 @@ describe("qa runner model catalog", () => {
|
||||
available: true,
|
||||
missing: false,
|
||||
},
|
||||
{
|
||||
key: "openrouter/auto",
|
||||
name: "OpenRouter Auto",
|
||||
input: "text",
|
||||
available: false,
|
||||
missing: false,
|
||||
},
|
||||
],
|
||||
}),
|
||||
).map((entry) => entry.key),
|
||||
).toEqual(["openai/gpt-5.6-luna"]);
|
||||
)});\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
await expect(loadQaRunnerModelOptions({ repoRoot })).resolves.toEqual([
|
||||
expect.objectContaining({ key: "openai/gpt-5.6-luna" }),
|
||||
expect.objectContaining({ key: "anthropic/claude-sonnet-4-6" }),
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports malformed catalog JSON with an owned error", async () => {
|
||||
const repoRoot = await makeTempDir("openclaw-qa-model-catalog-malformed-");
|
||||
await fs.mkdir(path.join(repoRoot, "dist"), { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(repoRoot, "dist", "index.js"),
|
||||
`process.stdout.write("{not json");\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
await expect(loadQaRunnerModelOptions({ repoRoot })).rejects.toThrow(
|
||||
"qa model catalog returned malformed JSON",
|
||||
);
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")(
|
||||
|
||||
@@ -53,7 +53,7 @@ function splitModelKey(key: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function selectQaRunnerModelOptions(rows: ModelRow[]): QaRunnerModelOption[] {
|
||||
function selectQaRunnerModelOptions(rows: ModelRow[]): QaRunnerModelOption[] {
|
||||
const options = rows
|
||||
.filter((row) => row.available === true && !row.missing)
|
||||
.map((row) => {
|
||||
@@ -93,7 +93,7 @@ function isModelRow(value: unknown): value is ModelRow {
|
||||
);
|
||||
}
|
||||
|
||||
export function parseQaRunnerModelOptionsOutput(stdout: string): QaRunnerModelOption[] {
|
||||
function parseQaRunnerModelOptionsOutput(stdout: string): QaRunnerModelOption[] {
|
||||
let payload: unknown;
|
||||
try {
|
||||
payload = JSON.parse(stdout) as unknown;
|
||||
|
||||
@@ -343,7 +343,6 @@ const qaScenarioPackFileSchema = z.object({
|
||||
export type QaScenarioExecution = z.infer<typeof qaScenarioExecutionSchema>;
|
||||
export type QaScenarioFlow = z.infer<typeof qaFlowSchema>;
|
||||
export type QaRuntimeParityTier = z.infer<typeof qaRuntimeParityTierSchema>;
|
||||
export type QaRuntimeParityUsage = z.infer<typeof qaRuntimeParityUsageSchema>;
|
||||
export type QaSeedScenario = z.infer<typeof qaSeedScenarioSchema>;
|
||||
export type QaSeedScenarioWithSource = QaSeedScenario & {
|
||||
sourcePath: string;
|
||||
|
||||
@@ -125,7 +125,6 @@ vi.mock("../skills/runtime/session-snapshot.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./exec-defaults.js", () => ({
|
||||
canExecRequestNode: () => false,
|
||||
resolveNodeExecEligibility: () => ({ canExec: false }),
|
||||
}));
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { SessionEntry } from "../config/sessions.js";
|
||||
import * as execApprovals from "../infra/exec-approvals.js";
|
||||
import {
|
||||
canExecRequestNode,
|
||||
resolveExecDefaults,
|
||||
resolveNodeExecEligibility,
|
||||
} from "./exec-defaults.js";
|
||||
import { resolveExecDefaults, resolveNodeExecEligibility } from "./exec-defaults.js";
|
||||
|
||||
describe("resolveExecDefaults", () => {
|
||||
beforeEach(() => {
|
||||
@@ -298,21 +294,6 @@ describe("resolveExecDefaults", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("blocks node advertising in helper calls when sandbox is available", () => {
|
||||
expect(
|
||||
canExecRequestNode({
|
||||
cfg: {
|
||||
tools: {
|
||||
exec: {
|
||||
host: "auto",
|
||||
},
|
||||
},
|
||||
},
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks node skill eligibility for deny policy and preserves node bindings", () => {
|
||||
expect(
|
||||
resolveNodeExecEligibility({
|
||||
|
||||
+10
-35
@@ -65,8 +65,8 @@ function applySessionLegacyExecPolicyLayer(
|
||||
return base;
|
||||
}
|
||||
|
||||
// Gather the shared config state once so canExecRequestNode and
|
||||
// resolveExecDefaults stay aligned on agent/global/session precedence.
|
||||
// Gather the shared config state once so exec resolution applies one
|
||||
// agent/global/session precedence order.
|
||||
function resolveExecConfigState(params: {
|
||||
cfg?: OpenClawConfig;
|
||||
sessionEntry?: ExecSessionDefaults;
|
||||
@@ -106,34 +106,6 @@ function resolveExecConfigState(params: {
|
||||
};
|
||||
}
|
||||
|
||||
function resolveExecSandboxAvailability(params: {
|
||||
cfg: OpenClawConfig;
|
||||
sessionKey?: string;
|
||||
sandboxAvailable?: boolean;
|
||||
}) {
|
||||
return (
|
||||
params.sandboxAvailable ??
|
||||
(params.sessionKey
|
||||
? resolveSandboxRuntimeStatus({
|
||||
cfg: params.cfg,
|
||||
sessionKey: params.sessionKey,
|
||||
}).sandboxed
|
||||
: false)
|
||||
);
|
||||
}
|
||||
|
||||
/** Returns whether the current exec policy allows requesting host node execution. */
|
||||
export function canExecRequestNode(params: {
|
||||
cfg?: OpenClawConfig;
|
||||
sessionEntry?: ExecSessionDefaults;
|
||||
execOverrides?: ExecPolicyOverrides;
|
||||
agentId?: string;
|
||||
sessionKey?: string;
|
||||
sandboxAvailable?: boolean;
|
||||
}): boolean {
|
||||
return resolveNodeExecEligibility(params).canExec;
|
||||
}
|
||||
|
||||
/** Resolves whether node exec is usable and any effective node binding. */
|
||||
export function resolveNodeExecEligibility(params: {
|
||||
cfg?: OpenClawConfig;
|
||||
@@ -178,11 +150,14 @@ export function resolveExecDefaults(params: {
|
||||
agentExec,
|
||||
globalExec,
|
||||
} = resolveExecConfigState(params);
|
||||
const sandboxAvailable = resolveExecSandboxAvailability({
|
||||
cfg,
|
||||
sessionKey: params.sessionKey,
|
||||
sandboxAvailable: params.sandboxAvailable,
|
||||
});
|
||||
const sandboxAvailable =
|
||||
params.sandboxAvailable ??
|
||||
(params.sessionKey
|
||||
? resolveSandboxRuntimeStatus({
|
||||
cfg,
|
||||
sessionKey: params.sessionKey,
|
||||
}).sandboxed
|
||||
: false);
|
||||
const resolved = resolveExecTarget({
|
||||
configuredTarget: host,
|
||||
elevatedRequested: params.elevatedRequested === true,
|
||||
|
||||
@@ -39,7 +39,6 @@ vi.mock("../plugin-sdk/browser-control-auth.js", () => browserControlAuthMock);
|
||||
vi.mock("../plugin-sdk/browser-profiles.js", () => browserProfilesMock);
|
||||
|
||||
vi.mock("./exec-defaults.js", () => ({
|
||||
canExecRequestNode: vi.fn(() => false),
|
||||
resolveNodeExecEligibility: resolveNodeExecEligibilityMock,
|
||||
}));
|
||||
|
||||
|
||||
@@ -280,6 +280,5 @@ vi.mock("../skills/runtime/session-snapshot.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("../agents/exec-defaults.js", () => ({
|
||||
canExecRequestNode: vi.fn(() => false),
|
||||
resolveNodeExecEligibility: vi.fn(() => ({ canExec: false })),
|
||||
}));
|
||||
|
||||
@@ -6,7 +6,6 @@ const mocks = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../agents/exec-defaults.js", () => ({
|
||||
canExecRequestNode: () => false,
|
||||
resolveNodeExecEligibility: () => ({ canExec: false }),
|
||||
}));
|
||||
vi.mock("../../config/config.js", () => ({
|
||||
|
||||
@@ -192,7 +192,6 @@ vi.mock("../../web-search/runtime.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../skills/runtime/cron-snapshot.runtime.js", () => ({
|
||||
canExecRequestNode: vi.fn(() => false),
|
||||
resolveNodeExecEligibility: vi.fn(() => ({ canExec: false })),
|
||||
getRemoteSkillEligibility: getRemoteSkillEligibilityMock,
|
||||
resolveEffectiveAgentSkillFilter: resolveAgentSkillsFilterMock,
|
||||
|
||||
Reference in New Issue
Block a user