-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathagent-chat-service.test.ts
More file actions
120 lines (111 loc) · 3.1 KB
/
Copy pathagent-chat-service.test.ts
File metadata and controls
120 lines (111 loc) · 3.1 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { describe, expect, it } from "bun:test";
import { getAgentDefinition } from "../services/agent-registry";
import { resolveAgentChatSupport, resolveAgentTerminalSubmitDelayMs } from "../services/agent-chat-service";
import type { ProjectConfig } from "../domain/config";
const TEST_CONFIG: ProjectConfig = {
name: "Project",
workspace: {
mainBranch: "main",
worktreeRoot: "__worktrees",
defaultAgent: "claude",
autoPull: { enabled: false, intervalSeconds: 300 },
},
profiles: {
default: {
runtime: "host",
envPassthrough: [],
panes: [{ id: "agent", kind: "agent", focus: true }],
},
},
agents: {
gemini: {
label: "Gemini CLI",
startCommand: 'gemini --prompt "${PROMPT}"',
},
},
services: [],
startupEnvs: {},
integrations: {
github: { linkedRepos: [], autoRemoveOnMerge: false },
linear: { enabled: true, autoCreateWorktrees: false, createTicketOption: false, postCommentOnPickup: false },
},
lifecycleHooks: {},
autoName: null,
oneshot: { systemPrompt: "" },
};
describe("resolveAgentChatSupport", () => {
it("maps built-in agents to their dashboard chat providers", () => {
expect(resolveAgentChatSupport({
agentId: "claude",
agentLabel: "Claude",
agent: getAgentDefinition(TEST_CONFIG, "claude"),
action: "chat",
})).toEqual({
ok: true,
data: {
provider: "claude",
submitDelayMs: 0,
},
});
expect(resolveAgentChatSupport({
agentId: "codex",
agentLabel: "Codex",
agent: getAgentDefinition(TEST_CONFIG, "codex"),
action: "chat",
})).toEqual({
ok: true,
data: {
provider: "codex",
submitDelayMs: 200,
},
});
});
it("rejects terminal-only custom agents", () => {
expect(resolveAgentChatSupport({
agentId: "gemini",
agentLabel: "Gemini CLI",
agent: getAgentDefinition(TEST_CONFIG, "gemini"),
action: "chat",
})).toEqual({
ok: false,
error: "Gemini CLI does not support in-app chat",
status: 409,
});
});
it("rejects missing and unknown agents", () => {
expect(resolveAgentChatSupport({
agentId: null,
agentLabel: null,
agent: null,
action: "chat",
})).toEqual({
ok: false,
error: "This worktree has no agent configured",
status: 409,
});
expect(resolveAgentChatSupport({
agentId: "missing",
agentLabel: null,
agent: null,
action: "interrupt",
})).toEqual({
ok: false,
error: "Unknown agent: missing",
status: 404,
});
});
it("uses the same terminal submit delay for built-in Codex prompts", () => {
expect(resolveAgentTerminalSubmitDelayMs({
agentId: "codex",
agent: getAgentDefinition(TEST_CONFIG, "codex"),
})).toBe(200);
expect(resolveAgentTerminalSubmitDelayMs({
agentId: "claude",
agent: getAgentDefinition(TEST_CONFIG, "claude"),
})).toBe(0);
expect(resolveAgentTerminalSubmitDelayMs({
agentId: "gemini",
agent: getAgentDefinition(TEST_CONFIG, "gemini"),
})).toBe(0);
});
});