@jcjeon/integration-cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/.gitignore +23 -0
  2. package/.npmignore +21 -0
  3. package/.prettierignore +6 -0
  4. package/.prettierrc +26 -0
  5. package/AGENTS.md +10 -0
  6. package/CLAUDE.md +10 -0
  7. package/README.md +384 -0
  8. package/apps/server/README.md +294 -0
  9. package/apps/server/eslint.config.mjs +20 -0
  10. package/apps/server/nest-cli.json +8 -0
  11. package/apps/server/package.json +89 -0
  12. package/apps/server/scripts/postinstall.js +53 -0
  13. package/apps/server/src/__mocks__/glob.js +6 -0
  14. package/apps/server/src/__mocks__/uuid.js +5 -0
  15. package/apps/server/src/app.controller.spec.ts +24 -0
  16. package/apps/server/src/app.controller.ts +13 -0
  17. package/apps/server/src/app.module.ts +18 -0
  18. package/apps/server/src/app.service.ts +8 -0
  19. package/apps/server/src/common/ji-paths.ts +41 -0
  20. package/apps/server/src/database/database.module.ts +27 -0
  21. package/apps/server/src/database/entities/agent-changelog.entity.ts +39 -0
  22. package/apps/server/src/database/entities/agent-session.entity.ts +29 -0
  23. package/apps/server/src/database/entities/conversation.entity.ts +41 -0
  24. package/apps/server/src/database/entities/session.entity.ts +16 -0
  25. package/apps/server/src/database/entities/task-agent-run.entity.ts +40 -0
  26. package/apps/server/src/database/entities/task-agent.entity.ts +42 -0
  27. package/apps/server/src/database/entities/task-requirement.entity.ts +27 -0
  28. package/apps/server/src/database/entities/task-run.entity.ts +41 -0
  29. package/apps/server/src/database/entities/task.entity.ts +44 -0
  30. package/apps/server/src/main.ts +65 -0
  31. package/apps/server/src/modules/agents/agent-model-settings.spec.ts +80 -0
  32. package/apps/server/src/modules/agents/agents.module.ts +11 -0
  33. package/apps/server/src/modules/agents/claude/claude-auth.manager.ts +83 -0
  34. package/apps/server/src/modules/agents/claude/claude-pty.manager.ts +380 -0
  35. package/apps/server/src/modules/agents/claude/claude.controller.ts +85 -0
  36. package/apps/server/src/modules/agents/claude/claude.gateway.ts +158 -0
  37. package/apps/server/src/modules/agents/claude/claude.module.ts +18 -0
  38. package/apps/server/src/modules/agents/claude/claude.service.ts +67 -0
  39. package/apps/server/src/modules/agents/claude/dto/create-session.dto.ts +24 -0
  40. package/apps/server/src/modules/agents/claude/dto/resize-session.dto.ts +13 -0
  41. package/apps/server/src/modules/agents/claude/dto/send-input.dto.ts +9 -0
  42. package/apps/server/src/modules/agents/claude/interfaces/claude-session.interface.ts +26 -0
  43. package/apps/server/src/modules/agents/claude/interfaces/pty-event.interface.ts +10 -0
  44. package/apps/server/src/modules/agents/claude/interfaces/stream-event.interface.ts +61 -0
  45. package/apps/server/src/modules/agents/codex/codex-auth.manager.ts +107 -0
  46. package/apps/server/src/modules/agents/codex/codex-session.manager.ts +357 -0
  47. package/apps/server/src/modules/agents/codex/codex.controller.ts +64 -0
  48. package/apps/server/src/modules/agents/codex/codex.gateway.ts +97 -0
  49. package/apps/server/src/modules/agents/codex/codex.module.ts +17 -0
  50. package/apps/server/src/modules/agents/codex/dto/configure-auth.dto.ts +7 -0
  51. package/apps/server/src/modules/agents/gemini/dto/configure-auth.dto.ts +15 -0
  52. package/apps/server/src/modules/agents/gemini/dto/create-session.dto.ts +9 -0
  53. package/apps/server/src/modules/agents/gemini/dto/send-input.dto.ts +9 -0
  54. package/apps/server/src/modules/agents/gemini/gemini-auth.manager.ts +157 -0
  55. package/apps/server/src/modules/agents/gemini/gemini-session.manager.ts +287 -0
  56. package/apps/server/src/modules/agents/gemini/gemini.controller.ts +93 -0
  57. package/apps/server/src/modules/agents/gemini/gemini.gateway.ts +149 -0
  58. package/apps/server/src/modules/agents/gemini/gemini.module.ts +17 -0
  59. package/apps/server/src/modules/agents/gemini/interfaces/gemini-session.interface.ts +18 -0
  60. package/apps/server/src/modules/agents/gemini/interfaces/stream-event.interface.ts +14 -0
  61. package/apps/server/src/modules/agents/session-termination.spec.ts +103 -0
  62. package/apps/server/src/modules/changelog/changelog.controller.ts +20 -0
  63. package/apps/server/src/modules/changelog/changelog.module.ts +14 -0
  64. package/apps/server/src/modules/changelog/changelog.service.spec.ts +531 -0
  65. package/apps/server/src/modules/changelog/changelog.service.ts +690 -0
  66. package/apps/server/src/modules/conversations/conversation.controller.spec.ts +106 -0
  67. package/apps/server/src/modules/conversations/conversation.controller.ts +60 -0
  68. package/apps/server/src/modules/conversations/conversation.module.ts +14 -0
  69. package/apps/server/src/modules/conversations/conversation.service.spec.ts +176 -0
  70. package/apps/server/src/modules/conversations/conversation.service.ts +54 -0
  71. package/apps/server/src/modules/conversations/dto/create-conversation.dto.ts +37 -0
  72. package/apps/server/src/modules/conversations/enums/conversation.enum.ts +13 -0
  73. package/apps/server/src/modules/fs/fs.controller.ts +29 -0
  74. package/apps/server/src/modules/fs/fs.module.ts +8 -0
  75. package/apps/server/src/modules/harness/dto/save-harness.dto.ts +9 -0
  76. package/apps/server/src/modules/harness/harness.controller.spec.ts +95 -0
  77. package/apps/server/src/modules/harness/harness.controller.ts +35 -0
  78. package/apps/server/src/modules/harness/harness.module.ts +11 -0
  79. package/apps/server/src/modules/harness/harness.service.spec.ts +217 -0
  80. package/apps/server/src/modules/harness/harness.service.ts +112 -0
  81. package/apps/server/src/modules/sessions/session.controller.spec.ts +68 -0
  82. package/apps/server/src/modules/sessions/session.controller.ts +43 -0
  83. package/apps/server/src/modules/sessions/session.module.ts +14 -0
  84. package/apps/server/src/modules/sessions/session.service.spec.ts +106 -0
  85. package/apps/server/src/modules/sessions/session.service.ts +35 -0
  86. package/apps/server/src/modules/tasks/dto/create-task.dto.ts +54 -0
  87. package/apps/server/src/modules/tasks/dto/execute-task.dto.ts +22 -0
  88. package/apps/server/src/modules/tasks/dto/merge-file.dto.ts +7 -0
  89. package/apps/server/src/modules/tasks/dto/rerun-task.dto.ts +14 -0
  90. package/apps/server/src/modules/tasks/dto/update-task.dto.ts +55 -0
  91. package/apps/server/src/modules/tasks/task-execution.service.ts +978 -0
  92. package/apps/server/src/modules/tasks/task.gateway.ts +140 -0
  93. package/apps/server/src/modules/tasks/tasks.controller.spec.ts +210 -0
  94. package/apps/server/src/modules/tasks/tasks.controller.ts +139 -0
  95. package/apps/server/src/modules/tasks/tasks.module.ts +30 -0
  96. package/apps/server/src/modules/tasks/tasks.service.spec.ts +552 -0
  97. package/apps/server/src/modules/tasks/tasks.service.ts +333 -0
  98. package/apps/server/test/app.e2e-spec.ts +28 -0
  99. package/apps/server/test/jest-e2e.json +9 -0
  100. package/apps/server/tsconfig.build.json +4 -0
  101. package/apps/server/tsconfig.json +13 -0
  102. package/apps/web/AGENTS.md +7 -0
  103. package/apps/web/CLAUDE.md +1 -0
  104. package/apps/web/README.md +36 -0
  105. package/apps/web/eslint.config.mjs +21 -0
  106. package/apps/web/next-env.d.ts +6 -0
  107. package/apps/web/next.config.ts +7 -0
  108. package/apps/web/package.json +49 -0
  109. package/apps/web/postcss.config.mjs +7 -0
  110. package/apps/web/public/file.svg +1 -0
  111. package/apps/web/public/globe.svg +1 -0
  112. package/apps/web/public/next.svg +1 -0
  113. package/apps/web/public/vercel.svg +1 -0
  114. package/apps/web/public/window.svg +1 -0
  115. package/apps/web/src/app/claude/page.tsx +5 -0
  116. package/apps/web/src/app/codex/page.tsx +126 -0
  117. package/apps/web/src/app/favicon.ico +0 -0
  118. package/apps/web/src/app/gemini/page.tsx +130 -0
  119. package/apps/web/src/app/globals.css +149 -0
  120. package/apps/web/src/app/layout.tsx +40 -0
  121. package/apps/web/src/app/login/page.tsx +67 -0
  122. package/apps/web/src/app/page.tsx +497 -0
  123. package/apps/web/src/app/task/[id]/page.tsx +11 -0
  124. package/apps/web/src/app/test/page.tsx +298 -0
  125. package/apps/web/src/components/ui/Modal.tsx +78 -0
  126. package/apps/web/src/components/ui/WorkingDirPicker.tsx +195 -0
  127. package/apps/web/src/components/ui/__tests__/Modal.test.tsx +68 -0
  128. package/apps/web/src/features/auth/api/__tests__/auth.api.test.ts +83 -0
  129. package/apps/web/src/features/auth/api/auth.api.ts +81 -0
  130. package/apps/web/src/features/auth/hooks/__tests__/useClaudeAuth.test.ts +166 -0
  131. package/apps/web/src/features/auth/hooks/__tests__/useCodexAuth.test.ts +127 -0
  132. package/apps/web/src/features/auth/hooks/__tests__/useGeminiAuth.test.ts +120 -0
  133. package/apps/web/src/features/auth/hooks/useClaudeAuth.ts +88 -0
  134. package/apps/web/src/features/auth/hooks/useCodexAuth.ts +149 -0
  135. package/apps/web/src/features/auth/hooks/useGeminiAuth.ts +125 -0
  136. package/apps/web/src/features/auth/ui/CodexLoginPanel.tsx +302 -0
  137. package/apps/web/src/features/auth/ui/GeminiLoginPanel.tsx +316 -0
  138. package/apps/web/src/features/auth/ui/LoginForm.tsx +190 -0
  139. package/apps/web/src/features/auth/ui/LoginPanel.tsx +114 -0
  140. package/apps/web/src/features/auth/ui/__tests__/LoginPanel.test.tsx +105 -0
  141. package/apps/web/src/features/chat/api/__tests__/sessions.api.test.ts +187 -0
  142. package/apps/web/src/features/chat/api/sessions.api.ts +161 -0
  143. package/apps/web/src/features/chat/container/ClaudePageContainer.tsx +152 -0
  144. package/apps/web/src/features/chat/hooks/__tests__/useCodexSessions.test.ts +131 -0
  145. package/apps/web/src/features/chat/hooks/__tests__/useGeminiSessions.test.ts +130 -0
  146. package/apps/web/src/features/chat/hooks/useAgentModelSettings.ts +54 -0
  147. package/apps/web/src/features/chat/hooks/useClaudeSessions.ts +323 -0
  148. package/apps/web/src/features/chat/hooks/useCodexSessions.ts +275 -0
  149. package/apps/web/src/features/chat/hooks/useGeminiSessions.ts +255 -0
  150. package/apps/web/src/features/chat/hooks/useSessionCommand.ts +66 -0
  151. package/apps/web/src/features/chat/hooks/useSessionRename.ts +61 -0
  152. package/apps/web/src/features/chat/hooks/useSessionWorkingDirectories.ts +34 -0
  153. package/apps/web/src/features/chat/hooks/useUnifiedSessions.ts +156 -0
  154. package/apps/web/src/features/chat/lib/agentModelOptions.ts +72 -0
  155. package/apps/web/src/features/chat/ui/AgentModelPicker.tsx +134 -0
  156. package/apps/web/src/features/chat/ui/AgentSelectModal.tsx +236 -0
  157. package/apps/web/src/features/chat/ui/ChatInput.tsx +162 -0
  158. package/apps/web/src/features/chat/ui/ChatMessage.tsx +204 -0
  159. package/apps/web/src/features/chat/ui/ChatWorkspace.tsx +207 -0
  160. package/apps/web/src/features/chat/ui/CheckingSkeleton.tsx +44 -0
  161. package/apps/web/src/features/chat/ui/ClaudeLoginView.tsx +44 -0
  162. package/apps/web/src/features/chat/ui/PermissionCard.tsx +37 -0
  163. package/apps/web/src/features/chat/ui/SessionSidebar.tsx +280 -0
  164. package/apps/web/src/features/chat/ui/__tests__/AgentSelectModal.test.tsx +58 -0
  165. package/apps/web/src/features/chat/ui/__tests__/ChatInput.test.tsx +134 -0
  166. package/apps/web/src/features/chat/ui/__tests__/ChatMessage.test.tsx +106 -0
  167. package/apps/web/src/features/chat/ui/__tests__/ChatWorkspace.test.tsx +66 -0
  168. package/apps/web/src/features/diff/ui/DiffFileRow.tsx +73 -0
  169. package/apps/web/src/features/diff/ui/DiffHunk.tsx +61 -0
  170. package/apps/web/src/features/diff/ui/FileChangeBadge.tsx +23 -0
  171. package/apps/web/src/features/diff/ui/__tests__/DiffFileRow.test.tsx +40 -0
  172. package/apps/web/src/features/diff/ui/__tests__/DiffHunk.test.tsx +24 -0
  173. package/apps/web/src/features/diff/ui/__tests__/FileChangeBadge.test.tsx +16 -0
  174. package/apps/web/src/features/fs/api/fs.api.ts +14 -0
  175. package/apps/web/src/features/fs/hooks/useDirBrowser.ts +50 -0
  176. package/apps/web/src/features/harness/api/__tests__/harness.api.test.ts +73 -0
  177. package/apps/web/src/features/harness/api/harness.api.ts +46 -0
  178. package/apps/web/src/features/harness/hooks/__tests__/useHarness.test.ts +65 -0
  179. package/apps/web/src/features/harness/hooks/useHarness.ts +66 -0
  180. package/apps/web/src/features/harness/ui/HarnessModal.tsx +171 -0
  181. package/apps/web/src/features/harness/ui/__tests__/HarnessModal.test.tsx +46 -0
  182. package/apps/web/src/features/status/ui/AgentStatusModal.tsx +267 -0
  183. package/apps/web/src/features/status/ui/__tests__/AgentStatusModal.test.tsx +71 -0
  184. package/apps/web/src/features/tasks/api/__tests__/changelog.api.test.ts +89 -0
  185. package/apps/web/src/features/tasks/api/__tests__/tasks.api.test.ts +282 -0
  186. package/apps/web/src/features/tasks/api/changelog.api.ts +52 -0
  187. package/apps/web/src/features/tasks/api/tasks.api.ts +175 -0
  188. package/apps/web/src/features/tasks/container/TaskDetailPageContainer.tsx +69 -0
  189. package/apps/web/src/features/tasks/hooks/__tests__/useChangelogCodeCopy.test.ts +48 -0
  190. package/apps/web/src/features/tasks/hooks/__tests__/useTaskChangelog.test.ts +48 -0
  191. package/apps/web/src/features/tasks/hooks/__tests__/useTaskCreate.test.ts +217 -0
  192. package/apps/web/src/features/tasks/hooks/__tests__/useTaskEdit.test.ts +152 -0
  193. package/apps/web/src/features/tasks/hooks/__tests__/useTaskExecution.test.ts +143 -0
  194. package/apps/web/src/features/tasks/hooks/__tests__/useTaskList.test.ts +168 -0
  195. package/apps/web/src/features/tasks/hooks/__tests__/useTaskNotification.test.ts +125 -0
  196. package/apps/web/src/features/tasks/hooks/__tests__/useTaskRuns.test.ts +51 -0
  197. package/apps/web/src/features/tasks/hooks/useChangelogCodeCopy.ts +52 -0
  198. package/apps/web/src/features/tasks/hooks/useCopyToClipboard.ts +47 -0
  199. package/apps/web/src/features/tasks/hooks/useTaskChangelog.ts +32 -0
  200. package/apps/web/src/features/tasks/hooks/useTaskCreate.ts +137 -0
  201. package/apps/web/src/features/tasks/hooks/useTaskDetail.ts +217 -0
  202. package/apps/web/src/features/tasks/hooks/useTaskEdit.ts +130 -0
  203. package/apps/web/src/features/tasks/hooks/useTaskExecution.ts +137 -0
  204. package/apps/web/src/features/tasks/hooks/useTaskList.ts +159 -0
  205. package/apps/web/src/features/tasks/hooks/useTaskNotification.ts +80 -0
  206. package/apps/web/src/features/tasks/hooks/useTaskRuns.ts +32 -0
  207. package/apps/web/src/features/tasks/ui/AgentOutputPanel.tsx +203 -0
  208. package/apps/web/src/features/tasks/ui/AgentRoleSelect.tsx +97 -0
  209. package/apps/web/src/features/tasks/ui/ChangelogPanel.tsx +321 -0
  210. package/apps/web/src/features/tasks/ui/RunHistoryPanel.tsx +193 -0
  211. package/apps/web/src/features/tasks/ui/TaskCreateModal.tsx +205 -0
  212. package/apps/web/src/features/tasks/ui/TaskDetailView.tsx +413 -0
  213. package/apps/web/src/features/tasks/ui/TaskEditModal.tsx +165 -0
  214. package/apps/web/src/features/tasks/ui/TaskListModal.tsx +591 -0
  215. package/apps/web/src/features/tasks/ui/__tests__/AgentRoleSelect.test.tsx +91 -0
  216. package/apps/web/src/features/tasks/ui/__tests__/ChangelogPanel.test.tsx +94 -0
  217. package/apps/web/src/features/tasks/ui/__tests__/RunHistoryPanel.test.tsx +71 -0
  218. package/apps/web/src/features/tasks/ui/__tests__/TaskCreateModal.test.tsx +153 -0
  219. package/apps/web/src/features/tasks/ui/__tests__/TaskEditModal.test.tsx +75 -0
  220. package/apps/web/src/features/tasks/ui/__tests__/TaskListModal.test.tsx +243 -0
  221. package/apps/web/src/hooks/useWorkingDir.ts +28 -0
  222. package/apps/web/src/lib/__tests__/ansi.test.ts +88 -0
  223. package/apps/web/src/lib/ansi.ts +105 -0
  224. package/apps/web/src/lib/constants.ts +4 -0
  225. package/apps/web/src/lib/quota.ts +22 -0
  226. package/apps/web/src/lib/theme.tsx +78 -0
  227. package/apps/web/src/lib/toast.tsx +175 -0
  228. package/apps/web/src/store/agentStatusStore.ts +38 -0
  229. package/apps/web/tsconfig.json +18 -0
  230. package/apps/web/vitest.config.ts +25 -0
  231. package/apps/web/vitest.setup.ts +10 -0
  232. package/package.json +85 -0
  233. package/packages/cli/dist/commands/check.d.ts +1 -0
  234. package/packages/cli/dist/commands/check.js +89 -0
  235. package/packages/cli/dist/commands/init.d.ts +5 -0
  236. package/packages/cli/dist/commands/init.js +183 -0
  237. package/packages/cli/dist/commands/start.d.ts +4 -0
  238. package/packages/cli/dist/commands/start.js +188 -0
  239. package/packages/cli/dist/index.d.ts +2 -0
  240. package/packages/cli/dist/index.js +71 -0
  241. package/packages/cli/dist/utils/agent-tools.d.ts +28 -0
  242. package/packages/cli/dist/utils/agent-tools.js +193 -0
  243. package/packages/cli/dist/utils/project-init.d.ts +12 -0
  244. package/packages/cli/dist/utils/project-init.js +258 -0
  245. package/packages/cli/dist/utils/proxy.d.ts +8 -0
  246. package/packages/cli/dist/utils/proxy.js +138 -0
  247. package/packages/cli/package.json +30 -0
  248. package/packages/cli/src/commands/check.ts +77 -0
  249. package/packages/cli/src/commands/init.ts +209 -0
  250. package/packages/cli/src/commands/start.ts +183 -0
  251. package/packages/cli/src/index.ts +91 -0
  252. package/packages/cli/src/utils/agent-tools.ts +201 -0
  253. package/packages/cli/src/utils/project-init.ts +252 -0
  254. package/packages/cli/src/utils/proxy.ts +123 -0
  255. package/packages/cli/tsconfig.json +14 -0
  256. package/packages/eslint-config/base.mjs +31 -0
  257. package/packages/eslint-config/nest.mjs +55 -0
  258. package/packages/eslint-config/next.mjs +23 -0
  259. package/packages/eslint-config/package.json +20 -0
  260. package/packages/typescript-config/base.json +16 -0
  261. package/packages/typescript-config/nestjs.json +17 -0
  262. package/packages/typescript-config/nextjs.json +15 -0
  263. package/packages/typescript-config/package.json +11 -0
  264. package/turbo.json +28 -0
@@ -0,0 +1,156 @@
1
+ "use client";
2
+
3
+ import { useCallback, useMemo, useState } from "react";
4
+
5
+ import type { AgentId } from "../ui/AgentSelectModal";
6
+ import type { AgentModelSettings, AgentModelSettingsByAgent } from "../lib/agentModelOptions";
7
+ import { useClaudeSessions } from "./useClaudeSessions";
8
+ import type { ChatMessage, SessionState } from "./useClaudeSessions";
9
+ import { useCodexSessions } from "./useCodexSessions";
10
+ import { useGeminiSessions } from "./useGeminiSessions";
11
+
12
+ export type ConnectionStatus = "disconnected" | "connecting" | "connected";
13
+ export type UnifiedSessionState = SessionState;
14
+
15
+ export function getOverallConnectionStatus(statuses: ConnectionStatus[]): ConnectionStatus {
16
+ if (statuses.includes("connected")) return "connected";
17
+ if (statuses.includes("connecting")) return "connecting";
18
+ return "disconnected";
19
+ }
20
+
21
+ export function useUnifiedSessions() {
22
+ const claude = useClaudeSessions();
23
+ const gemini = useGeminiSessions();
24
+ const codex = useCodexSessions();
25
+ const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null);
26
+
27
+ const sessions = useMemo(
28
+ () =>
29
+ [...claude.sessions, ...gemini.sessions, ...codex.sessions].sort(
30
+ (a, b) => new Date(b.info.createdAt).getTime() - new Date(a.info.createdAt).getTime(),
31
+ ),
32
+ [claude.sessions, gemini.sessions, codex.sessions],
33
+ );
34
+
35
+ const connectionStatusByAgent = useMemo<Record<AgentId, ConnectionStatus>>(
36
+ () => ({
37
+ claude: claude.connectionStatus,
38
+ gemini: gemini.connectionStatus,
39
+ codex: codex.connectionStatus,
40
+ opencode: "disconnected",
41
+ }),
42
+ [claude.connectionStatus, gemini.connectionStatus, codex.connectionStatus],
43
+ );
44
+
45
+ const overallConnectionStatus = useMemo(
46
+ () => getOverallConnectionStatus([claude.connectionStatus, gemini.connectionStatus, codex.connectionStatus]),
47
+ [claude.connectionStatus, gemini.connectionStatus, codex.connectionStatus],
48
+ );
49
+
50
+ const selectedSession = useMemo(
51
+ () => sessions.find((s) => s.info.id === selectedSessionId) ?? null,
52
+ [sessions, selectedSessionId],
53
+ );
54
+
55
+ const selectedConnectionStatus = selectedSession
56
+ ? connectionStatusByAgent[selectedSession.agentId]
57
+ : overallConnectionStatus;
58
+
59
+ const error = claude.error ?? gemini.error ?? codex.error;
60
+
61
+ const findSession = useCallback(
62
+ (sessionId: string) => sessions.find((s) => s.info.id === sessionId) ?? null,
63
+ [sessions],
64
+ );
65
+
66
+ const selectSession = useCallback(
67
+ (sessionId: string) => {
68
+ setSelectedSessionId(sessionId);
69
+ claude.selectSession(sessionId);
70
+ gemini.selectSession(sessionId);
71
+ codex.selectSession(sessionId);
72
+ },
73
+ [claude, gemini, codex],
74
+ );
75
+
76
+ const createSession = useCallback(
77
+ async (
78
+ agentId: AgentId,
79
+ workingDirectory?: string,
80
+ modelSettings?: AgentModelSettings,
81
+ ): Promise<string | null> => {
82
+ if (connectionStatusByAgent[agentId] !== "connected") return null;
83
+
84
+ let sessionId: string | null = null;
85
+ if (agentId === "gemini") {
86
+ sessionId = await gemini.createSession(workingDirectory);
87
+ } else if (agentId === "codex") {
88
+ sessionId = await codex.createSession(workingDirectory, modelSettings);
89
+ } else if (agentId === "claude") {
90
+ sessionId = await claude.createSession(agentId, workingDirectory, modelSettings);
91
+ }
92
+
93
+ if (sessionId) setSelectedSessionId(sessionId);
94
+ return sessionId;
95
+ },
96
+ [connectionStatusByAgent, claude, gemini, codex],
97
+ );
98
+
99
+ const sendMessage = useCallback(
100
+ (sessionId: string, text: string, modelSettingsByAgent?: AgentModelSettingsByAgent) => {
101
+ const session = findSession(sessionId);
102
+ if (!session) return;
103
+ const modelSettings = modelSettingsByAgent?.[session.agentId];
104
+ if (session.agentId === "gemini") gemini.sendMessage(sessionId, text);
105
+ else if (session.agentId === "codex") codex.sendMessage(sessionId, text, modelSettings);
106
+ else claude.sendMessage(sessionId, text, modelSettings);
107
+ },
108
+ [findSession, claude, gemini, codex],
109
+ );
110
+
111
+ const terminateSession = useCallback(
112
+ async (sessionId: string) => {
113
+ const session = findSession(sessionId);
114
+ if (!session) return;
115
+ if (session.agentId === "gemini") await gemini.terminateSession(sessionId);
116
+ else if (session.agentId === "codex") await codex.terminateSession(sessionId);
117
+ else await claude.terminateSession(sessionId);
118
+ setSelectedSessionId((prev) => (prev === sessionId ? null : prev));
119
+ },
120
+ [findSession, claude, gemini, codex],
121
+ );
122
+
123
+ const renameSession = useCallback(
124
+ (sessionId: string, newTitle: string) => {
125
+ const session = findSession(sessionId);
126
+ if (!session) return;
127
+ if (session.agentId === "gemini") gemini.renameSession(sessionId, newTitle);
128
+ else if (session.agentId === "codex") codex.renameSession(sessionId, newTitle);
129
+ else claude.renameSession(sessionId, newTitle);
130
+ },
131
+ [findSession, claude, gemini, codex],
132
+ );
133
+
134
+ const injectClaudeMessage = useCallback(
135
+ (sessionId: string, message: Omit<ChatMessage, "id" | "createdAt">) => {
136
+ claude.injectMessage(sessionId, message);
137
+ },
138
+ [claude],
139
+ );
140
+
141
+ return {
142
+ sessions,
143
+ selectedSession,
144
+ selectedSessionId,
145
+ selectedConnectionStatus,
146
+ connectionStatusByAgent,
147
+ overallConnectionStatus,
148
+ error,
149
+ createSession,
150
+ selectSession,
151
+ sendMessage,
152
+ terminateSession,
153
+ renameSession,
154
+ injectClaudeMessage,
155
+ };
156
+ }
@@ -0,0 +1,72 @@
1
+ import type { AgentId } from "../ui/AgentSelectModal";
2
+
3
+ export type ReasoningLevel = "default" | "low" | "medium" | "high" | "xhigh" | "max";
4
+
5
+ export interface AgentModelSettings {
6
+ model?: string;
7
+ reasoning?: ReasoningLevel;
8
+ }
9
+
10
+ export type AgentModelSettingsByAgent = Partial<Record<AgentId, AgentModelSettings>>;
11
+
12
+ export interface ModelOption {
13
+ value: string;
14
+ label: string;
15
+ description: string;
16
+ }
17
+
18
+ export interface ReasoningOption {
19
+ value: ReasoningLevel;
20
+ label: string;
21
+ }
22
+
23
+ export const AGENT_MODEL_OPTIONS: Partial<Record<AgentId, ModelOption[]>> = {
24
+ claude: [
25
+ { value: "default", label: "기본값", description: "Claude CLI 설정을 그대로 사용" },
26
+ { value: "sonnet", label: "Sonnet", description: "균형 잡힌 기본 작업용" },
27
+ { value: "opus", label: "Opus", description: "복잡한 추론과 대규모 변경용" },
28
+ ],
29
+ codex: [
30
+ { value: "default", label: "기본값", description: "Codex CLI 설정을 그대로 사용" },
31
+ { value: "gpt-5.5", label: "GPT-5.5", description: "최신 고성능 모델" },
32
+ { value: "gpt-5.4", label: "GPT-5.4", description: "범용 작업에 안정적" },
33
+ { value: "gpt-5.4-mini", label: "GPT-5.4 Mini", description: "가벼운 수정과 빠른 응답" },
34
+ { value: "gpt-5.3-codex", label: "GPT-5.3 Codex", description: "코딩 작업 특화" },
35
+ { value: "gpt-5.2", label: "GPT-5.2", description: "이전 호환 모델" },
36
+ ],
37
+ };
38
+
39
+ export const AGENT_REASONING_OPTIONS: Partial<Record<AgentId, ReasoningOption[]>> = {
40
+ claude: [
41
+ { value: "default", label: "기본" },
42
+ { value: "low", label: "Low" },
43
+ { value: "medium", label: "Medium" },
44
+ { value: "high", label: "High" },
45
+ { value: "xhigh", label: "XHigh" },
46
+ { value: "max", label: "Max" },
47
+ ],
48
+ codex: [
49
+ { value: "default", label: "기본" },
50
+ { value: "low", label: "Low" },
51
+ { value: "medium", label: "Medium" },
52
+ { value: "high", label: "High" },
53
+ { value: "xhigh", label: "XHigh" },
54
+ ],
55
+ };
56
+
57
+ export function normalizeAgentModelSettings(settings?: AgentModelSettings): AgentModelSettings {
58
+ return {
59
+ model: settings?.model && settings.model !== "default" ? settings.model : undefined,
60
+ reasoning: settings?.reasoning && settings.reasoning !== "default" ? settings.reasoning : undefined,
61
+ };
62
+ }
63
+
64
+ export function getAgentModelSummary(agentId: AgentId, settings?: AgentModelSettings): string {
65
+ const model = settings?.model ?? "default";
66
+ const reasoning = settings?.reasoning ?? "default";
67
+ const modelLabel =
68
+ AGENT_MODEL_OPTIONS[agentId]?.find((option) => option.value === model)?.label ?? "기본값";
69
+ const reasoningLabel =
70
+ AGENT_REASONING_OPTIONS[agentId]?.find((option) => option.value === reasoning)?.label ?? "기본";
71
+ return `${modelLabel} · ${reasoningLabel}`;
72
+ }
@@ -0,0 +1,134 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef, useState } from "react";
4
+
5
+ import type { AgentId } from "./AgentSelectModal";
6
+ import {
7
+ AGENT_MODEL_OPTIONS,
8
+ AGENT_REASONING_OPTIONS,
9
+ getAgentModelSummary,
10
+ type AgentModelSettings,
11
+ type ReasoningLevel,
12
+ } from "../lib/agentModelOptions";
13
+
14
+ interface AgentModelPickerProps {
15
+ agentId: AgentId;
16
+ value?: AgentModelSettings;
17
+ onChange: (agentId: AgentId, settings: AgentModelSettings) => void;
18
+ }
19
+
20
+ function ChipIcon({ className }: { className?: string }) {
21
+ return (
22
+ <svg viewBox="0 0 16 16" fill="currentColor" className={className}>
23
+ <path d="M5.25 1A1.75 1.75 0 003.5 2.75v.75h-.75A1.75 1.75 0 001 5.25v5.5c0 .966.784 1.75 1.75 1.75h.75v.75c0 .966.784 1.75 1.75 1.75h5.5a1.75 1.75 0 001.75-1.75v-.75h.75A1.75 1.75 0 0015 10.75v-5.5a1.75 1.75 0 00-1.75-1.75h-.75v-.75A1.75 1.75 0 0010.75 1h-5.5zm0 1.5h5.5a.25.25 0 01.25.25v10.5a.25.25 0 01-.25.25h-5.5a.25.25 0 01-.25-.25V2.75a.25.25 0 01.25-.25zm-2.5 2.5h.75v6h-.75a.25.25 0 01-.25-.25v-5.5A.25.25 0 012.75 5zm9.75 0h.75a.25.25 0 01.25.25v5.5a.25.25 0 01-.25.25h-.75V5z" />
24
+ </svg>
25
+ );
26
+ }
27
+
28
+ function isSupportedAgent(agentId: AgentId) {
29
+ return agentId === "claude" || agentId === "codex";
30
+ }
31
+
32
+ export function AgentModelPicker({ agentId, value, onChange }: AgentModelPickerProps) {
33
+ const [open, setOpen] = useState(false);
34
+ const containerRef = useRef<HTMLDivElement>(null);
35
+ const modelOptions = AGENT_MODEL_OPTIONS[agentId] ?? [];
36
+ const reasoningOptions = AGENT_REASONING_OPTIONS[agentId] ?? [];
37
+ const selectedModel = value?.model ?? "default";
38
+ const selectedReasoning = value?.reasoning ?? "default";
39
+ const disabled = !isSupportedAgent(agentId);
40
+
41
+ useEffect(() => {
42
+ if (!open) return;
43
+ const handler = (e: MouseEvent) => {
44
+ if (containerRef.current && !containerRef.current.contains(e.target as Node)) {
45
+ setOpen(false);
46
+ }
47
+ };
48
+ document.addEventListener("mousedown", handler);
49
+ return () => document.removeEventListener("mousedown", handler);
50
+ }, [open]);
51
+
52
+ const changeModel = (model: string) => {
53
+ onChange(agentId, { ...(value ?? {}), model });
54
+ };
55
+
56
+ const changeReasoning = (reasoning: ReasoningLevel) => {
57
+ onChange(agentId, { ...(value ?? {}), reasoning });
58
+ };
59
+
60
+ return (
61
+ <div ref={containerRef} className="relative flex min-w-0 items-center justify-end">
62
+ <button
63
+ type="button"
64
+ disabled={disabled}
65
+ onClick={() => setOpen((prev) => !prev)}
66
+ title="모델 및 추론 설정"
67
+ className="flex min-w-0 max-w-[260px] items-center gap-1.5 rounded-md px-2 py-1 text-xs text-gray-900/45 transition-colors hover:bg-gray-900/[0.05] hover:text-gray-900/75 disabled:cursor-not-allowed disabled:opacity-40 dark:text-white/45 dark:hover:bg-white/[0.06] dark:hover:text-white/75"
68
+ >
69
+ <ChipIcon className="h-3.5 w-3.5 shrink-0" />
70
+ <span className="truncate">{disabled ? "모델 기본값" : getAgentModelSummary(agentId, value)}</span>
71
+ </button>
72
+
73
+ {open && !disabled && (
74
+ <div className="absolute bottom-full right-0 z-50 mb-1 w-80 rounded-xl border border-gray-900/[0.1] bg-white shadow-lg dark:border-white/[0.1] dark:bg-gray-900">
75
+ <div className="border-b border-gray-900/[0.07] px-3 py-2 dark:border-white/[0.07]">
76
+ <p className="text-[11px] font-medium uppercase tracking-wider text-gray-900/30 dark:text-white/30">
77
+ model
78
+ </p>
79
+ <p className="mt-0.5 truncate text-xs text-gray-900/55 dark:text-white/55">
80
+ {getAgentModelSummary(agentId, value)}
81
+ </p>
82
+ </div>
83
+
84
+ <div className="max-h-56 overflow-y-auto py-1">
85
+ {modelOptions.map((option) => (
86
+ <button
87
+ key={option.value}
88
+ type="button"
89
+ onClick={() => changeModel(option.value)}
90
+ className={`flex w-full items-center justify-between gap-3 px-3 py-2 text-left transition-colors hover:bg-gray-900/[0.04] dark:hover:bg-white/[0.05] ${
91
+ selectedModel === option.value ? "text-orange-600 dark:text-orange-400" : "text-gray-900/75 dark:text-white/75"
92
+ }`}
93
+ >
94
+ <span className="min-w-0">
95
+ <span className="block text-sm font-medium">{option.label}</span>
96
+ <span className="block truncate text-[11px] text-gray-900/35 dark:text-white/35">
97
+ {option.description}
98
+ </span>
99
+ </span>
100
+ {selectedModel === option.value && (
101
+ <svg viewBox="0 0 16 16" fill="currentColor" className="h-3.5 w-3.5 shrink-0">
102
+ <path d="M13.78 4.22a.75.75 0 010 1.06l-6.25 6.25a.75.75 0 01-1.06 0L3.22 8.28a.75.75 0 111.06-1.06L7 9.94l5.72-5.72a.75.75 0 011.06 0z" />
103
+ </svg>
104
+ )}
105
+ </button>
106
+ ))}
107
+ </div>
108
+
109
+ <div className="border-t border-gray-900/[0.07] px-3 py-2 dark:border-white/[0.07]">
110
+ <p className="mb-2 text-[11px] font-medium uppercase tracking-wider text-gray-900/30 dark:text-white/30">
111
+ reasoning
112
+ </p>
113
+ <div className="grid grid-cols-3 gap-1">
114
+ {reasoningOptions.map((option) => (
115
+ <button
116
+ key={option.value}
117
+ type="button"
118
+ onClick={() => changeReasoning(option.value)}
119
+ className={`rounded-md px-2 py-1.5 text-xs font-medium transition-colors ${
120
+ selectedReasoning === option.value
121
+ ? "bg-orange-500 text-white"
122
+ : "bg-gray-900/[0.04] text-gray-900/45 hover:bg-gray-900/[0.07] hover:text-gray-900/75 dark:bg-white/[0.05] dark:text-white/45 dark:hover:bg-white/[0.08] dark:hover:text-white/75"
123
+ }`}
124
+ >
125
+ {option.label}
126
+ </button>
127
+ ))}
128
+ </div>
129
+ </div>
130
+ </div>
131
+ )}
132
+ </div>
133
+ );
134
+ }
@@ -0,0 +1,236 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
4
+
5
+ import { Modal } from "@/components/ui/Modal";
6
+ import { useAgentStatusStore } from "@/store/agentStatusStore";
7
+
8
+ export type AgentId = "claude" | "gemini" | "codex" | "opencode";
9
+ type ConnectionStatus = "disconnected" | "connecting" | "connected";
10
+
11
+ interface AgentDef {
12
+ id: AgentId;
13
+ name: string;
14
+ vendor: string;
15
+ description: string;
16
+ available: boolean;
17
+ iconBg: string;
18
+ hoverBorder: string;
19
+ hoverBg: string;
20
+ icon: React.ReactNode;
21
+ }
22
+
23
+ // ─── Icons ────────────────────────────────────────────────────────────────────
24
+
25
+ export const ClaudeIcon = () => (
26
+ <svg viewBox="0 0 24 24" fill="currentColor" className="h-6 w-6 text-[#D97757]">
27
+ <path d="M13.827 3.816L20.05 20.2h-3.672l-1.234-3.365H8.856L7.622 20.2H3.95L10.173 3.816h3.654zm-1.827 4.91l-1.989 5.453h3.978l-1.989-5.453z" />
28
+ </svg>
29
+ );
30
+
31
+ export const GeminiIcon = () => (
32
+ <svg viewBox="0 0 24 24" className="h-6 w-6" aria-hidden="true">
33
+ <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4" />
34
+ <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853" />
35
+ <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05" />
36
+ <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335" />
37
+ </svg>
38
+ );
39
+
40
+ export const CodexIcon = () => (
41
+ // OpenAI logo — simplified
42
+ <svg viewBox="0 0 24 24" fill="currentColor" className="h-6 w-6 text-gray-900 dark:text-white">
43
+ <path d="M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9 6.065 6.065 0 0 0-10.75 2.918 5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.985 5.985 0 0 0 .511 4.91 6.046 6.046 0 0 0 6.515 2.9 5.985 5.985 0 0 0 4.514 2.012 6.046 6.046 0 0 0 5.772-4.206 5.985 5.985 0 0 0 3.998-2.9 6.046 6.046 0 0 0-.747-7.071zM13.26 21.4a4.476 4.476 0 0 1-2.876-1.041l.141-.08 4.779-2.758a.775.775 0 0 0 .393-.681v-6.737l2.02 1.169a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.495 4.493zM3.6 17.275a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.775.775 0 0 0 .781 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-2.675zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973v5.701a.77.77 0 0 0 .388.677l5.815 3.354-2.02 1.169a.076.076 0 0 1-.071 0l-4.83-2.787A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.843-3.354 2.02-1.169a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.402-.695zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.775.775 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5Z" />
44
+ </svg>
45
+ );
46
+
47
+ export const OpenCodeIcon = () => (
48
+ // OpenCode — terminal bracket style
49
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" className="h-6 w-6 text-emerald-500">
50
+ <polyline points="16 18 22 12 16 6" />
51
+ <polyline points="8 6 2 12 8 18" />
52
+ <line x1="12" y1="4" x2="12" y2="20" strokeWidth="1.4" strokeDasharray="2 2" />
53
+ </svg>
54
+ );
55
+
56
+ // ─── Agent Definitions ────────────────────────────────────────────────────────
57
+
58
+ const AGENTS: AgentDef[] = [
59
+ {
60
+ id: "claude",
61
+ name: "Claude Code",
62
+ vendor: "Anthropic",
63
+ description: "코드 작성, 디버깅, 리팩터링을 위한 AI 어시스턴트",
64
+ available: true,
65
+ iconBg: "bg-orange-500/[0.10]",
66
+ hoverBorder: "hover:border-orange-500/30",
67
+ hoverBg: "hover:bg-orange-500/[0.04]",
68
+ icon: <ClaudeIcon />,
69
+ },
70
+ {
71
+ id: "gemini",
72
+ name: "Gemini CLI",
73
+ vendor: "Google",
74
+ description: "Google Gemini 기반 코딩 어시스턴트",
75
+ available: true,
76
+ iconBg: "bg-blue-500/[0.08]",
77
+ hoverBorder: "hover:border-blue-500/20",
78
+ hoverBg: "hover:bg-blue-500/[0.03]",
79
+ icon: <GeminiIcon />,
80
+ },
81
+ {
82
+ id: "codex",
83
+ name: "Codex CLI",
84
+ vendor: "OpenAI",
85
+ description: "OpenAI Codex 기반 터미널 에이전트",
86
+ available: true,
87
+ iconBg: "bg-gray-900/[0.05] dark:bg-white/[0.06]",
88
+ hoverBorder: "hover:border-gray-900/20 dark:hover:border-white/20",
89
+ hoverBg: "hover:bg-gray-900/[0.03] dark:hover:bg-white/[0.03]",
90
+ icon: <CodexIcon />,
91
+ },
92
+ {
93
+ id: "opencode",
94
+ name: "OpenCode",
95
+ vendor: "OpenCode",
96
+ description: "오픈소스 AI 코딩 에이전트",
97
+ available: false,
98
+ iconBg: "bg-emerald-500/[0.08]",
99
+ hoverBorder: "hover:border-emerald-500/20",
100
+ hoverBg: "hover:bg-emerald-500/[0.03]",
101
+ icon: <OpenCodeIcon />,
102
+ },
103
+ ];
104
+
105
+ // ─── Agent Card ───────────────────────────────────────────────────────────────
106
+
107
+ interface AgentCardProps {
108
+ agent: AgentDef;
109
+ connectionStatus: ConnectionStatus;
110
+ onSelect: (id: AgentId) => void;
111
+ }
112
+
113
+ function AgentCard({ agent, connectionStatus, onSelect }: AgentCardProps) {
114
+ const canSelect = agent.available && connectionStatus === "connected";
115
+
116
+ return (
117
+ <button
118
+ onClick={() => canSelect && onSelect(agent.id)}
119
+ disabled={!canSelect}
120
+ className={[
121
+ "group relative flex w-full items-center gap-4 rounded-xl border p-4 text-left transition-all duration-200",
122
+ "border-gray-900/[0.07] bg-gray-900/[0.02] dark:border-white/[0.07] dark:bg-white/[0.02]",
123
+ canSelect
124
+ ? `cursor-pointer ${agent.hoverBorder} ${agent.hoverBg}`
125
+ : "cursor-not-allowed opacity-45",
126
+ ].join(" ")}
127
+ >
128
+ {/* Icon */}
129
+ <span
130
+ className={[
131
+ "flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border border-gray-900/[0.06] dark:border-white/[0.06]",
132
+ agent.iconBg,
133
+ ].join(" ")}
134
+ >
135
+ {agent.icon}
136
+ </span>
137
+
138
+ {/* Text */}
139
+ <div className="min-w-0 flex-1">
140
+ <div className="flex items-center gap-2">
141
+ <span className="text-sm font-semibold text-gray-900/85 dark:text-white/85">
142
+ {agent.name}
143
+ </span>
144
+ <span className="text-[10px] font-medium text-gray-900/25 dark:text-white/25">
145
+ {agent.vendor}
146
+ </span>
147
+ </div>
148
+ <p className="mt-0.5 text-xs text-gray-900/40 dark:text-white/40">{agent.description}</p>
149
+ </div>
150
+
151
+ {/* Status badge */}
152
+ <div className="shrink-0">
153
+ {!agent.available ? (
154
+ <span className="rounded-full border border-gray-900/[0.06] bg-gray-900/[0.03] px-2.5 py-1 text-[11px] font-medium text-gray-900/30 dark:border-white/[0.06] dark:bg-white/[0.03] dark:text-white/30">
155
+ 준비 중
156
+ </span>
157
+ ) : connectionStatus === "connected" ? (
158
+ <span className="flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/[0.08] px-2.5 py-1 text-[11px] font-medium text-emerald-600 dark:text-emerald-400">
159
+ <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-emerald-500" />
160
+ 사용 가능
161
+ </span>
162
+ ) : connectionStatus === "connecting" ? (
163
+ <span className="flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/[0.08] px-2.5 py-1 text-[11px] font-medium text-amber-600 dark:text-amber-400">
164
+ <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-amber-500" />
165
+ 연결 중
166
+ </span>
167
+ ) : (
168
+ <span className="rounded-full border border-gray-900/[0.06] bg-gray-900/[0.03] px-2.5 py-1 text-[11px] font-medium text-gray-900/30 dark:border-white/[0.06] dark:bg-white/[0.03] dark:text-white/30">
169
+ 연결 끊김
170
+ </span>
171
+ )}
172
+ </div>
173
+
174
+ {/* Arrow */}
175
+ {canSelect && (
176
+ <svg
177
+ viewBox="0 0 16 16"
178
+ fill="currentColor"
179
+ className="h-3.5 w-3.5 shrink-0 text-gray-900/20 transition-transform duration-200 group-hover:translate-x-0.5 group-hover:text-gray-900/50 dark:text-white/20 dark:group-hover:text-white/50"
180
+ >
181
+ <path fillRule="evenodd" d="M6.22 4.22a.75.75 0 011.06 0l3.25 3.25a.75.75 0 010 1.06l-3.25 3.25a.75.75 0 01-1.06-1.06L8.94 8 6.22 5.28a.75.75 0 010-1.06z" clipRule="evenodd" />
182
+ </svg>
183
+ )}
184
+ </button>
185
+ );
186
+ }
187
+
188
+ // ─── Modal ────────────────────────────────────────────────────────────────────
189
+
190
+ interface AgentSelectModalProps {
191
+ open: boolean;
192
+ onClose: () => void;
193
+ onSelect: (agentId: AgentId) => void;
194
+ connectionStatusByAgent?: Record<AgentId, ConnectionStatus>;
195
+ }
196
+
197
+ export function AgentSelectModal({ open, onClose, onSelect, connectionStatusByAgent }: AgentSelectModalProps) {
198
+ const { statusByAgent, refresh } = useAgentStatusStore();
199
+
200
+ useEffect(() => {
201
+ if (open) refresh();
202
+ }, [open, refresh]);
203
+
204
+ const effectiveStatus = connectionStatusByAgent ?? statusByAgent;
205
+
206
+ return (
207
+ <Modal open={open} onClose={onClose} title="에이전트 선택" maxWidth="max-w-md" zIndex="z-[60]">
208
+ <div className="flex flex-col gap-2.5">
209
+ {AGENTS.map((agent) => (
210
+ <AgentCard
211
+ key={agent.id}
212
+ agent={agent}
213
+ connectionStatus={effectiveStatus[agent.id] ?? "disconnected"}
214
+ onSelect={(id) => { onSelect(id); onClose(); }}
215
+ />
216
+ ))}
217
+ </div>
218
+ </Modal>
219
+ );
220
+ }
221
+
222
+ // ─── Agent meta (for external use) ───────────────────────────────────────────
223
+
224
+ export const AGENT_META: Record<AgentId, { label: string; dotColor: string }> = {
225
+ claude: { label: "Claude Code", dotColor: "bg-orange-400" },
226
+ gemini: { label: "Gemini CLI", dotColor: "bg-blue-400" },
227
+ codex: { label: "Codex CLI", dotColor: "bg-gray-400" },
228
+ opencode: { label: "OpenCode", dotColor: "bg-emerald-400" },
229
+ };
230
+
231
+ export const AGENT_AVATAR: Record<AgentId, { bg: string; icon: React.ReactNode }> = {
232
+ claude: { bg: "bg-[#D97757]", icon: <svg viewBox="0 0 24 24" fill="currentColor" className="h-5 w-5 text-white"><path d="M13.827 3.816L20.05 20.2h-3.672l-1.234-3.365H8.856L7.622 20.2H3.95L10.173 3.816h3.654zm-1.827 4.91l-1.989 5.453h3.978l-1.989-5.453z" /></svg> },
233
+ gemini: { bg: "bg-white dark:bg-gray-800", icon: <svg viewBox="0 0 24 24" className="h-5 w-5" aria-hidden="true"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4" /><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853" /><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05" /><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335" /></svg> },
234
+ codex: { bg: "bg-gray-900 dark:bg-white", icon: <svg viewBox="0 0 24 24" fill="currentColor" className="h-5 w-5 text-white dark:text-gray-900"><path d="M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9 6.065 6.065 0 0 0-10.75 2.918 5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.985 5.985 0 0 0 .511 4.91 6.046 6.046 0 0 0 6.515 2.9 5.985 5.985 0 0 0 4.514 2.012 6.046 6.046 0 0 0 5.772-4.206 5.985 5.985 0 0 0 3.998-2.9 6.046 6.046 0 0 0-.747-7.071zM13.26 21.4a4.476 4.476 0 0 1-2.876-1.041l.141-.08 4.779-2.758a.775.775 0 0 0 .393-.681v-6.737l2.02 1.169a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.495 4.493zM3.6 17.275a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.775.775 0 0 0 .781 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-2.675zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973v5.701a.77.77 0 0 0 .388.677l5.815 3.354-2.02 1.169a.076.076 0 0 1-.071 0l-4.83-2.787A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855-5.843-3.354 2.02-1.169a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.402-.695zm2.01-3.023-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.775.775 0 0 0-.393.681zm1.097-2.365 2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5Z" /></svg> },
235
+ opencode: { bg: "bg-emerald-600", icon: <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" className="h-5 w-5 text-white"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /><line x1="12" y1="4" x2="12" y2="20" strokeWidth="1.4" strokeDasharray="2 2" /></svg> },
236
+ };