mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-10 17:21:30 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
const SANDBOX_EXPLAIN_TEST_TIMEOUT_MS = process.platform === "win32" ? 45_000 : 30_000;
|
|
|
|
let mockCfg: unknown = {};
|
|
|
|
vi.mock("../config/config.js", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("../config/config.js")>();
|
|
return {
|
|
...actual,
|
|
loadConfig: vi.fn().mockImplementation(() => mockCfg),
|
|
};
|
|
});
|
|
|
|
const { sandboxExplainCommand } = await import("./sandbox-explain.js");
|
|
|
|
describe("sandbox explain command", () => {
|
|
it("prints JSON shape + fix-it keys", { timeout: SANDBOX_EXPLAIN_TEST_TIMEOUT_MS }, async () => {
|
|
mockCfg = {
|
|
agents: {
|
|
defaults: {
|
|
sandbox: { mode: "all", scope: "agent", workspaceAccess: "none" },
|
|
},
|
|
},
|
|
tools: {
|
|
sandbox: { tools: { deny: ["browser"] } },
|
|
elevated: { enabled: true, allowFrom: { whatsapp: ["*"] } },
|
|
},
|
|
session: { store: "/tmp/openclaw-test-sessions-{agentId}.json" },
|
|
};
|
|
|
|
const logs: string[] = [];
|
|
await sandboxExplainCommand({ json: true, session: "agent:main:main" }, {
|
|
log: (msg: string) => logs.push(msg),
|
|
error: (msg: string) => logs.push(msg),
|
|
exit: (_code: number) => {},
|
|
} as unknown as Parameters<typeof sandboxExplainCommand>[1]);
|
|
|
|
const out = logs.join("");
|
|
const parsed = JSON.parse(out);
|
|
expect(parsed).toHaveProperty("docsUrl", "https://docs.openclaw.ai/sandbox");
|
|
expect(parsed).toHaveProperty("sandbox.mode", "all");
|
|
expect(parsed).toHaveProperty("sandbox.tools.sources.allow.source");
|
|
expect(Array.isArray(parsed.fixIt)).toBe(true);
|
|
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
|
|
expect(parsed.fixIt).toContain("tools.sandbox.tools.alsoAllow");
|
|
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
|
|
});
|
|
|
|
it("shows effective sandbox alsoAllow grants and default-deny removals", async () => {
|
|
mockCfg = {
|
|
agents: {
|
|
defaults: {
|
|
sandbox: { mode: "all", scope: "agent", workspaceAccess: "none" },
|
|
},
|
|
list: [
|
|
{
|
|
id: "tavern",
|
|
tools: {
|
|
sandbox: {
|
|
tools: {
|
|
alsoAllow: ["message", "tts"],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
tools: {
|
|
sandbox: {
|
|
tools: {
|
|
allow: ["browser"],
|
|
},
|
|
},
|
|
},
|
|
session: { store: "/tmp/openclaw-test-sessions-{agentId}.json" },
|
|
};
|
|
|
|
const logs: string[] = [];
|
|
await sandboxExplainCommand({ json: true, agent: "tavern" }, {
|
|
log: (msg: string) => logs.push(msg),
|
|
error: (msg: string) => logs.push(msg),
|
|
exit: (_code: number) => {},
|
|
} as unknown as Parameters<typeof sandboxExplainCommand>[1]);
|
|
|
|
const parsed = JSON.parse(logs.join(""));
|
|
expect(parsed.sandbox.tools.allow).toEqual(
|
|
expect.arrayContaining(["browser", "message", "tts"]),
|
|
);
|
|
expect(parsed.sandbox.tools.deny).not.toContain("browser");
|
|
expect(parsed.sandbox.tools.sources.allow).toEqual({
|
|
source: "agent",
|
|
key: "agents.list[].tools.sandbox.tools.alsoAllow",
|
|
});
|
|
});
|
|
});
|