forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecution-policy.test.ts
More file actions
50 lines (46 loc) · 1.77 KB
/
Copy pathexecution-policy.test.ts
File metadata and controls
50 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { describe, expect, it } from "vitest";
import {
executionRoleAllowsTool,
providerBoundaryForAdapter,
resolveAdapterWithinBoundary,
} from "../src/runtime/execution-policy.js";
describe("agent execution policy", () => {
it("derives the declared production credential boundary", () => {
expect(providerBoundaryForAdapter("pi-mono")).toBe("managed_cloud");
expect(providerBoundaryForAdapter("acp")).toBe("local_user:acp");
expect(providerBoundaryForAdapter("hermes")).toBe("local_user:hermes");
expect(providerBoundaryForAdapter("openclaw")).toBe("local_user:openclaw");
});
it("pins local-user surfaces to the exact selected adapter", () => {
expect(resolveAdapterWithinBoundary({
providerBoundary: "local_user:acp",
defaultAdapterId: "acp",
requestedAdapterId: "acp",
})).toBe("acp");
expect(() => resolveAdapterWithinBoundary({
providerBoundary: "local_user:acp",
defaultAdapterId: "acp",
requestedAdapterId: "hermes",
})).toThrow("Local provider mode is pinned to acp");
});
it("fails closed for local and unknown overrides from managed execution", () => {
for (const adapterId of ["acp", "hermes", "openclaw", "unknown-adapter"]) {
expect(() => resolveAdapterWithinBoundary({
providerBoundary: "managed_cloud",
defaultAdapterId: "pi-mono",
requestedAdapterId: adapterId,
})).toThrow();
}
});
it("denies every leaf-restricted control tool for leaf roles", () => {
for (const toolName of [
"send_agent_message",
"spawn_background_agent",
"spawn_agent",
"run_agent_and_wait",
]) {
expect(executionRoleAllowsTool("leaf", toolName)).toBe(false);
expect(executionRoleAllowsTool("coordinator", toolName)).toBe(true);
}
});
});