-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathagent-mode.test.ts
More file actions
59 lines (49 loc) · 2.18 KB
/
Copy pathagent-mode.test.ts
File metadata and controls
59 lines (49 loc) · 2.18 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
51
52
53
54
55
56
57
58
59
import {afterEach, beforeEach, describe, expect, it} from "vitest";
import {AgentMode} from "../../AgentMode";
describe("AgentMode plan mode", () => {
it("resolves the plan mode by id", () => {
expect(AgentMode.find("plan")).toBe(AgentMode.Plan);
});
it("carries planning instructions only for Plan mode", () => {
expect(AgentMode.Plan.planInstructions).toBeTruthy();
expect(AgentMode.Plan.planInstructions?.length ?? 0).toBeGreaterThan(0);
expect(AgentMode.ReadOnly.planInstructions).toBeNull();
expect(AgentMode.Agent.planInstructions).toBeNull();
expect(AgentMode.AgentFullAccess.planInstructions).toBeNull();
});
it("uses a read-only sandbox with no approvals", () => {
expect(AgentMode.Plan.sandboxMode).toBe("read-only");
expect(AgentMode.Plan.sandboxPolicy).toEqual({type: "readOnly", networkAccess: false});
expect(AgentMode.Plan.approvalPolicy).toBe("never");
});
it("includes plan in the available modes exposed to clients", () => {
expect(AgentMode.all().map((mode) => mode.id)).toContain("plan");
const state = AgentMode.Agent.toSessionModeState();
expect(state.availableModes).toEqual(
expect.arrayContaining([
expect.objectContaining({id: "plan", name: "Plan"}),
]),
);
});
describe("getInitialAgentMode", () => {
let previous: string | undefined;
beforeEach(() => {
previous = process.env["INITIAL_AGENT_MODE"];
});
afterEach(() => {
if (previous === undefined) {
delete process.env["INITIAL_AGENT_MODE"];
} else {
process.env["INITIAL_AGENT_MODE"] = previous;
}
});
it("honors INITIAL_AGENT_MODE=plan", () => {
process.env["INITIAL_AGENT_MODE"] = "plan";
expect(AgentMode.getInitialAgentMode()).toBe(AgentMode.Plan);
});
it("falls back to the default mode for unknown values", () => {
process.env["INITIAL_AGENT_MODE"] = "does-not-exist";
expect(AgentMode.getInitialAgentMode()).toBe(AgentMode.DEFAULT_AGENT_MODE);
});
});
});