bingocode 1.0.2 → 1.0.3

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 (186) hide show
  1. package/desktop/README.md +30 -0
  2. package/desktop/bunfig.toml +1 -0
  3. package/desktop/index.html +17 -0
  4. package/desktop/package.json +55 -0
  5. package/desktop/pnpm-lock.yaml +3832 -0
  6. package/desktop/public/app-icon.jpg +0 -0
  7. package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
  8. package/desktop/public/fonts/inter-latin.woff2 +0 -0
  9. package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  10. package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
  11. package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
  12. package/desktop/public/fonts/manrope-latin.woff2 +0 -0
  13. package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
  14. package/desktop/public/icons/bilibili.svg +1 -0
  15. package/desktop/public/icons/douyin.svg +1 -0
  16. package/desktop/public/icons/github.svg +3 -0
  17. package/desktop/public/icons/xiaohongshu.svg +1 -0
  18. package/desktop/scripts/build-macos-arm64.sh +270 -0
  19. package/desktop/scripts/build-sidecars.ts +183 -0
  20. package/desktop/scripts/build-windows-x64.ps1 +295 -0
  21. package/desktop/scripts/scan-missing-imports.ts +235 -0
  22. package/desktop/sidecars/claude-sidecar.ts +156 -0
  23. package/desktop/src/App.tsx +5 -0
  24. package/desktop/src/__tests__/agentsSettings.test.tsx +349 -0
  25. package/desktop/src/__tests__/pages.test.tsx +290 -0
  26. package/desktop/src/__tests__/skillsSettings.test.tsx +205 -0
  27. package/desktop/src/api/adapters.ts +12 -0
  28. package/desktop/src/api/agents.ts +36 -0
  29. package/desktop/src/api/cliTasks.ts +28 -0
  30. package/desktop/src/api/client.ts +63 -0
  31. package/desktop/src/api/computerUse.ts +76 -0
  32. package/desktop/src/api/filesystem.ts +30 -0
  33. package/desktop/src/api/hahaOAuth.ts +38 -0
  34. package/desktop/src/api/models.ts +28 -0
  35. package/desktop/src/api/providers.ts +63 -0
  36. package/desktop/src/api/search.ts +29 -0
  37. package/desktop/src/api/sessions.ts +56 -0
  38. package/desktop/src/api/settings.ts +20 -0
  39. package/desktop/src/api/skills.ts +19 -0
  40. package/desktop/src/api/tasks.ts +36 -0
  41. package/desktop/src/api/teams.ts +44 -0
  42. package/desktop/src/api/websocket.ts +164 -0
  43. package/desktop/src/components/chat/AskUserQuestion.tsx +268 -0
  44. package/desktop/src/components/chat/AssistantMessage.tsx +29 -0
  45. package/desktop/src/components/chat/AttachmentGallery.tsx +113 -0
  46. package/desktop/src/components/chat/ChatInput.tsx +622 -0
  47. package/desktop/src/components/chat/CodeViewer.tsx +161 -0
  48. package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +174 -0
  49. package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +311 -0
  50. package/desktop/src/components/chat/DiffViewer.tsx +157 -0
  51. package/desktop/src/components/chat/FileSearchMenu.tsx +198 -0
  52. package/desktop/src/components/chat/ImageGalleryModal.tsx +91 -0
  53. package/desktop/src/components/chat/InlineImageGallery.tsx +106 -0
  54. package/desktop/src/components/chat/InlineTaskSummary.tsx +60 -0
  55. package/desktop/src/components/chat/MermaidRenderer.test.tsx +98 -0
  56. package/desktop/src/components/chat/MermaidRenderer.tsx +361 -0
  57. package/desktop/src/components/chat/MessageActionBar.tsx +27 -0
  58. package/desktop/src/components/chat/MessageList.test.tsx +313 -0
  59. package/desktop/src/components/chat/MessageList.tsx +249 -0
  60. package/desktop/src/components/chat/PermissionDialog.tsx +262 -0
  61. package/desktop/src/components/chat/SessionTaskBar.test.tsx +99 -0
  62. package/desktop/src/components/chat/SessionTaskBar.tsx +159 -0
  63. package/desktop/src/components/chat/StreamingIndicator.tsx +41 -0
  64. package/desktop/src/components/chat/TerminalChrome.tsx +35 -0
  65. package/desktop/src/components/chat/ThinkingBlock.tsx +87 -0
  66. package/desktop/src/components/chat/ToolCallBlock.tsx +247 -0
  67. package/desktop/src/components/chat/ToolCallGroup.tsx +617 -0
  68. package/desktop/src/components/chat/ToolResultBlock.tsx +107 -0
  69. package/desktop/src/components/chat/UserMessage.tsx +38 -0
  70. package/desktop/src/components/chat/chatBlocks.test.tsx +136 -0
  71. package/desktop/src/components/chat/clipboard.ts +25 -0
  72. package/desktop/src/components/chat/composerUtils.test.ts +55 -0
  73. package/desktop/src/components/chat/composerUtils.ts +149 -0
  74. package/desktop/src/components/controls/ModelSelector.tsx +156 -0
  75. package/desktop/src/components/controls/PermissionModeSelector.tsx +229 -0
  76. package/desktop/src/components/layout/AppShell.tsx +107 -0
  77. package/desktop/src/components/layout/ContentRouter.tsx +27 -0
  78. package/desktop/src/components/layout/ProjectFilter.tsx +126 -0
  79. package/desktop/src/components/layout/Sidebar.test.tsx +158 -0
  80. package/desktop/src/components/layout/Sidebar.tsx +384 -0
  81. package/desktop/src/components/layout/StatusBar.tsx +31 -0
  82. package/desktop/src/components/layout/TabBar.test.tsx +136 -0
  83. package/desktop/src/components/layout/TabBar.tsx +318 -0
  84. package/desktop/src/components/layout/TitleBar.tsx +96 -0
  85. package/desktop/src/components/layout/WindowControls.test.tsx +69 -0
  86. package/desktop/src/components/layout/WindowControls.tsx +89 -0
  87. package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +100 -0
  88. package/desktop/src/components/markdown/MarkdownRenderer.tsx +229 -0
  89. package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +107 -0
  90. package/desktop/src/components/shared/Button.tsx +63 -0
  91. package/desktop/src/components/shared/CopyButton.tsx +58 -0
  92. package/desktop/src/components/shared/DirectoryPicker.tsx +316 -0
  93. package/desktop/src/components/shared/Dropdown.tsx +91 -0
  94. package/desktop/src/components/shared/Input.tsx +38 -0
  95. package/desktop/src/components/shared/Modal.tsx +65 -0
  96. package/desktop/src/components/shared/ProjectContextChip.tsx +30 -0
  97. package/desktop/src/components/shared/Spinner.tsx +30 -0
  98. package/desktop/src/components/shared/Textarea.tsx +38 -0
  99. package/desktop/src/components/shared/Toast.tsx +47 -0
  100. package/desktop/src/components/shared/UpdateChecker.tsx +90 -0
  101. package/desktop/src/components/skills/SkillDetail.test.tsx +89 -0
  102. package/desktop/src/components/skills/SkillDetail.tsx +403 -0
  103. package/desktop/src/components/skills/SkillList.tsx +254 -0
  104. package/desktop/src/components/tasks/DayOfWeekPicker.tsx +57 -0
  105. package/desktop/src/components/tasks/NewTaskModal.tsx +407 -0
  106. package/desktop/src/components/tasks/PromptEditor.tsx +74 -0
  107. package/desktop/src/components/tasks/TaskEmptyState.tsx +30 -0
  108. package/desktop/src/components/tasks/TaskList.tsx +46 -0
  109. package/desktop/src/components/tasks/TaskRow.tsx +253 -0
  110. package/desktop/src/components/tasks/TaskRunsPanel.tsx +195 -0
  111. package/desktop/src/components/teams/TeamStatusBar.tsx +147 -0
  112. package/desktop/src/config/providerPresets.ts +78 -0
  113. package/desktop/src/config/spinnerVerbs.ts +193 -0
  114. package/desktop/src/hooks/useKeyboardShortcuts.ts +60 -0
  115. package/desktop/src/i18n/index.ts +54 -0
  116. package/desktop/src/i18n/locales/en.ts +670 -0
  117. package/desktop/src/i18n/locales/zh.ts +670 -0
  118. package/desktop/src/lib/__tests__/cronDescribe.test.ts +93 -0
  119. package/desktop/src/lib/cronDescribe.ts +188 -0
  120. package/desktop/src/lib/desktopRuntime.ts +54 -0
  121. package/desktop/src/lib/parseRunOutput.ts +79 -0
  122. package/desktop/src/main.tsx +13 -0
  123. package/desktop/src/mocks/data.ts +202 -0
  124. package/desktop/src/pages/ActiveSession.test.tsx +181 -0
  125. package/desktop/src/pages/ActiveSession.tsx +219 -0
  126. package/desktop/src/pages/AdapterSettings.tsx +375 -0
  127. package/desktop/src/pages/AgentTeams.tsx +200 -0
  128. package/desktop/src/pages/ComputerUseSettings.tsx +420 -0
  129. package/desktop/src/pages/EmptySession.tsx +518 -0
  130. package/desktop/src/pages/NewTaskModal.tsx +346 -0
  131. package/desktop/src/pages/ScheduledTasks.tsx +66 -0
  132. package/desktop/src/pages/ScheduledTasksEmpty.tsx +152 -0
  133. package/desktop/src/pages/ScheduledTasksList.tsx +416 -0
  134. package/desktop/src/pages/SessionControls.tsx +460 -0
  135. package/desktop/src/pages/Settings.tsx +1448 -0
  136. package/desktop/src/pages/ToolInspection.tsx +235 -0
  137. package/desktop/src/stores/adapterStore.ts +106 -0
  138. package/desktop/src/stores/agentStore.ts +34 -0
  139. package/desktop/src/stores/chatStore.test.ts +505 -0
  140. package/desktop/src/stores/chatStore.ts +850 -0
  141. package/desktop/src/stores/cliTaskStore.ts +152 -0
  142. package/desktop/src/stores/hahaOAuthStore.test.ts +77 -0
  143. package/desktop/src/stores/hahaOAuthStore.ts +97 -0
  144. package/desktop/src/stores/providerStore.ts +101 -0
  145. package/desktop/src/stores/sessionStore.test.ts +63 -0
  146. package/desktop/src/stores/sessionStore.ts +102 -0
  147. package/desktop/src/stores/settingsStore.ts +120 -0
  148. package/desktop/src/stores/skillStore.ts +51 -0
  149. package/desktop/src/stores/tabStore.ts +169 -0
  150. package/desktop/src/stores/taskStore.ts +68 -0
  151. package/desktop/src/stores/teamStore.ts +344 -0
  152. package/desktop/src/stores/uiStore.ts +100 -0
  153. package/desktop/src/stores/updateStore.test.ts +71 -0
  154. package/desktop/src/stores/updateStore.ts +221 -0
  155. package/desktop/src/theme/globals.css +465 -0
  156. package/desktop/src/types/adapter.ts +33 -0
  157. package/desktop/src/types/chat.ts +152 -0
  158. package/desktop/src/types/cliTask.ts +24 -0
  159. package/desktop/src/types/provider.ts +62 -0
  160. package/desktop/src/types/session.ts +27 -0
  161. package/desktop/src/types/settings.ts +22 -0
  162. package/desktop/src/types/skill.ts +38 -0
  163. package/desktop/src/types/task.ts +56 -0
  164. package/desktop/src/types/team.ts +38 -0
  165. package/desktop/src-tauri/Cargo.lock +5549 -0
  166. package/desktop/src-tauri/Cargo.toml +20 -0
  167. package/desktop/src-tauri/app-icon.svg +13 -0
  168. package/desktop/src-tauri/build.rs +3 -0
  169. package/desktop/src-tauri/capabilities/default.json +106 -0
  170. package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  171. package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +4 -0
  172. package/desktop/src-tauri/icons/icon.icns +0 -0
  173. package/desktop/src-tauri/icons/icon.ico +0 -0
  174. package/desktop/src-tauri/src/lib.rs +408 -0
  175. package/desktop/src-tauri/src/main.rs +6 -0
  176. package/desktop/src-tauri/tauri.conf.json +78 -0
  177. package/desktop/src-tauri/tauri.macos.conf.json +18 -0
  178. package/desktop/src-tauri/tauri.release-ci.json +5 -0
  179. package/desktop/src-tauri/tauri.windows.conf.json +16 -0
  180. package/desktop/src-tauri/windows-installer-hooks.nsh +17 -0
  181. package/desktop/tsconfig.json +25 -0
  182. package/desktop/vite.config.ts +26 -0
  183. package/desktop/vitest.config.ts +18 -0
  184. package/package.json +1 -1
  185. package/src/commands/desktop/desktop.tsx +9 -0
  186. package/src/commands/desktop/index.ts +26 -0
@@ -0,0 +1,235 @@
1
+ import { useState } from 'react'
2
+ import { mockToolInspection } from '../mocks/data'
3
+
4
+ export function ToolInspection() {
5
+ const [activeDiffTab, setActiveDiffTab] = useState<'split' | 'unified'>('split')
6
+
7
+ const { toolType, toolName, description, filePath, dryRunStatus, linesChanged, diffLines } =
8
+ mockToolInspection
9
+
10
+ return (
11
+ <div className="flex-1 flex flex-col overflow-hidden bg-[var(--color-surface)]">
12
+ {/* Separator */}
13
+ <div className="h-px w-full bg-[var(--color-surface-container)]" />
14
+
15
+ {/* Content */}
16
+ <main className="flex-1 overflow-y-auto p-8 max-w-6xl mx-auto w-full">
17
+ <div className="flex flex-col gap-6">
18
+ {/* ── Title row + action buttons ─────────────────── */}
19
+ <div className="flex items-start justify-between">
20
+ <div className="space-y-1">
21
+ <div className="flex items-center gap-2">
22
+ <span className="px-2 py-0.5 bg-[var(--color-primary-fixed)] text-[var(--color-on-primary)] text-[10px] font-bold rounded uppercase tracking-widest">
23
+ {toolType}
24
+ </span>
25
+ <h1 className="font-[var(--font-headline)] font-extrabold text-2xl text-[var(--color-on-surface)] tracking-tight">
26
+ {toolName}
27
+ </h1>
28
+ </div>
29
+ <p className="text-[var(--color-on-surface-variant)] font-medium">{description}</p>
30
+ </div>
31
+ <div className="flex gap-2">
32
+ <button className="px-4 py-2 bg-[var(--color-surface-container-high)] rounded-lg text-sm font-semibold hover:bg-[var(--color-surface-variant)] transition-all">
33
+ Revert Change
34
+ </button>
35
+ <button className="px-4 py-2 bg-[var(--color-primary)] text-[var(--color-on-primary)] rounded-lg text-sm font-semibold shadow-sm hover:opacity-90 transition-all">
36
+ Apply to All
37
+ </button>
38
+ </div>
39
+ </div>
40
+
41
+ {/* ── Metadata cards ─────────────────────────────── */}
42
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
43
+ <div className="bg-[var(--color-surface-container-low)] rounded-xl p-4 flex flex-col gap-1">
44
+ <span className="text-[10px] font-bold text-[var(--color-outline)] uppercase tracking-wider">
45
+ Target File
46
+ </span>
47
+ <div className="flex items-center gap-2 text-[var(--color-on-surface)]">
48
+ <span className="material-symbols-outlined text-[18px]">description</span>
49
+ <span className="font-[var(--font-mono)] text-sm">{filePath}</span>
50
+ </div>
51
+ </div>
52
+
53
+ <div className="bg-[var(--color-surface-container-low)] rounded-xl p-4 flex flex-col gap-1">
54
+ <span className="text-[10px] font-bold text-[var(--color-outline)] uppercase tracking-wider">
55
+ Status
56
+ </span>
57
+ <div className="flex items-center gap-2 text-[var(--color-tertiary)]">
58
+ <span
59
+ className="material-symbols-outlined text-[18px]"
60
+ style={{ fontVariationSettings: "'FILL' 1" }}
61
+ >
62
+ check_circle
63
+ </span>
64
+ <span className="font-semibold text-sm">{dryRunStatus}</span>
65
+ </div>
66
+ </div>
67
+
68
+ <div className="bg-[var(--color-surface-container-low)] rounded-xl p-4 flex flex-col gap-1">
69
+ <span className="text-[10px] font-bold text-[var(--color-outline)] uppercase tracking-wider">
70
+ Lines Modified
71
+ </span>
72
+ <div className="flex items-center gap-2 text-[var(--color-on-surface)]">
73
+ <span className="material-symbols-outlined text-[18px]">edit_note</span>
74
+ <span className="font-semibold text-sm">
75
+ +{linesChanged.added} / -{linesChanged.removed} lines
76
+ </span>
77
+ </div>
78
+ </div>
79
+ </div>
80
+
81
+ {/* ── Diff Viewer ────────────────────────────────── */}
82
+ <div className="bg-[var(--color-surface-dim)] rounded-xl overflow-hidden border border-[var(--color-outline-variant)]/20 shadow-sm">
83
+ <div className="px-4 py-2.5 bg-[var(--color-surface-container-high)] flex items-center justify-between border-b border-[var(--color-outline-variant)]/20">
84
+ <div className="flex items-center gap-3">
85
+ <div className="flex gap-1.5">
86
+ <div className="w-2.5 h-2.5 rounded-full bg-[var(--color-error)] opacity-30" />
87
+ <div className="w-2.5 h-2.5 rounded-full bg-[var(--color-primary-fixed-dim)]" />
88
+ <div className="w-2.5 h-2.5 rounded-full bg-[var(--color-tertiary-container)] opacity-30" />
89
+ </div>
90
+ <span className="font-[var(--font-mono)] text-xs text-[var(--color-outline)] px-2 border-l border-[var(--color-outline-variant)]/30">
91
+ {filePath} — Diff View
92
+ </span>
93
+ </div>
94
+ <div className="flex items-center gap-4">
95
+ <span className="text-[11px] text-[var(--color-outline)] font-medium">
96
+ L{diffLines[0]?.lineNo ?? 1} — L{diffLines[diffLines.length - 1]?.lineNo ?? 1}
97
+ </span>
98
+ <div className="flex bg-[var(--color-surface-container-low)] rounded p-0.5">
99
+ <button
100
+ onClick={() => setActiveDiffTab('split')}
101
+ className={`px-2 py-1 text-[10px] font-bold uppercase ${
102
+ activeDiffTab === 'split'
103
+ ? 'bg-[var(--color-surface)] rounded shadow-sm text-[var(--color-on-surface)]'
104
+ : 'text-[var(--color-outline)]'
105
+ }`}
106
+ >
107
+ Split
108
+ </button>
109
+ <button
110
+ onClick={() => setActiveDiffTab('unified')}
111
+ className={`px-2 py-1 text-[10px] font-bold uppercase ${
112
+ activeDiffTab === 'unified'
113
+ ? 'bg-[var(--color-surface)] rounded shadow-sm text-[var(--color-on-surface)]'
114
+ : 'text-[var(--color-outline)]'
115
+ }`}
116
+ >
117
+ Unified
118
+ </button>
119
+ </div>
120
+ </div>
121
+ </div>
122
+
123
+ <div className="font-[var(--font-mono)] text-[13px] leading-relaxed p-4 overflow-x-auto whitespace-pre">
124
+ {diffLines.map((line, idx) => {
125
+ const isAdded = line.type === 'added'
126
+ const isRemoved = line.type === 'removed'
127
+
128
+ let rowBg = ''
129
+ if (isAdded) rowBg = 'bg-[var(--color-diff-added-bg)]'
130
+ else if (isRemoved) rowBg = 'bg-[var(--color-diff-removed-bg)]'
131
+
132
+ let lineNoColor = 'text-[var(--color-outline)] opacity-40'
133
+ if (isAdded) lineNoColor = 'text-[var(--color-tertiary)] opacity-40'
134
+ else if (isRemoved) lineNoColor = 'text-[var(--color-error)] opacity-40'
135
+
136
+ const prefix = isAdded ? '+ ' : isRemoved ? '- ' : ' '
137
+
138
+ return (
139
+ <div key={idx} className={`flex w-full ${rowBg}`}>
140
+ <span
141
+ className={`w-10 flex-shrink-0 text-right pr-4 select-none ${lineNoColor}`}
142
+ >
143
+ {line.lineNo}
144
+ </span>
145
+ <span className="text-[var(--color-on-surface-variant)]">
146
+ {prefix}
147
+ {line.content}
148
+ </span>
149
+ </div>
150
+ )
151
+ })}
152
+ </div>
153
+ </div>
154
+
155
+ {/* ── Implementation Context ─────────────────────── */}
156
+ <div className="p-6 bg-[var(--color-surface-container-lowest)] rounded-2xl border border-[var(--color-outline-variant)]/10">
157
+ <h3 className="font-[var(--font-headline)] font-bold text-sm text-[var(--color-on-surface)] mb-4">
158
+ Implementation Context
159
+ </h3>
160
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
161
+ <div className="space-y-4">
162
+ <div className="flex items-start gap-3">
163
+ <div className="mt-1 w-6 h-6 rounded bg-[var(--color-primary-fixed)] flex items-center justify-center">
164
+ <span className="material-symbols-outlined text-[14px] text-[var(--color-on-primary)]">
165
+ psychology
166
+ </span>
167
+ </div>
168
+ <div>
169
+ <p className="text-xs font-bold uppercase tracking-widest text-[var(--color-outline)] mb-1">
170
+ Reasoning
171
+ </p>
172
+ <p className="text-sm text-[var(--color-on-surface-variant)] leading-relaxed">
173
+ The <code className="font-[var(--font-mono)]">legacyAuthService</code> was
174
+ deprecated in RFC-204. The new SDK provides automatic session refresh and
175
+ better error typing. This migration ensures the login flow is compliant with
176
+ the new security standards.
177
+ </p>
178
+ </div>
179
+ </div>
180
+
181
+ <div className="flex items-start gap-3">
182
+ <div className="mt-1 w-6 h-6 rounded bg-[var(--color-diff-added-bg)] flex items-center justify-center">
183
+ <span className="material-symbols-outlined text-[14px] text-[var(--color-diff-added-text)]">
184
+ science
185
+ </span>
186
+ </div>
187
+ <div>
188
+ <p className="text-xs font-bold uppercase tracking-widest text-[var(--color-outline)] mb-1">
189
+ Impact Analysis
190
+ </p>
191
+ <p className="text-sm text-[var(--color-on-surface-variant)] leading-relaxed">
192
+ No changes needed in calling components. The interface remains compatible but
193
+ internal state management is improved.
194
+ </p>
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ <div className="flex items-center justify-center">
200
+ <div className="w-full h-32 rounded-xl bg-[var(--color-surface-container)] relative overflow-hidden group">
201
+ <div className="absolute inset-0 bg-gradient-to-br from-[var(--color-primary)]/5 to-[var(--color-secondary)]/5" />
202
+ <div className="absolute inset-0 flex items-center justify-center gap-4">
203
+ <div className="flex flex-col items-center gap-1">
204
+ <div className="p-2 bg-[var(--color-surface)] rounded-lg shadow-sm">
205
+ <span className="material-symbols-outlined text-[var(--color-outline)]">
206
+ description
207
+ </span>
208
+ </div>
209
+ <span className="text-[9px] font-bold text-[var(--color-outline)]">
210
+ auth.ts
211
+ </span>
212
+ </div>
213
+ <span className="material-symbols-outlined text-[var(--color-outline)] animate-pulse">
214
+ keyboard_double_arrow_right
215
+ </span>
216
+ <div className="flex flex-col items-center gap-1">
217
+ <div className="p-2 bg-[var(--color-surface)] rounded-lg shadow-sm border border-[var(--color-tertiary)]/20">
218
+ <span className="material-symbols-outlined text-[var(--color-tertiary)]">
219
+ check_circle
220
+ </span>
221
+ </div>
222
+ <span className="text-[9px] font-bold text-[var(--color-tertiary)]">
223
+ Verified
224
+ </span>
225
+ </div>
226
+ </div>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ </div>
232
+ </main>
233
+ </div>
234
+ )
235
+ }
@@ -0,0 +1,106 @@
1
+ import { create } from 'zustand'
2
+ import { adaptersApi } from '../api/adapters'
3
+ import type { AdapterFileConfig } from '../types/adapter'
4
+
5
+ /**
6
+ * Tauri command 触发器:让主进程 kill + respawn adapter sidecar,
7
+ * 让 ~/.claude/adapters.json 里的最新凭据被新进程读到,建立飞书 / Telegram
8
+ * 的 WebSocket 连接。
9
+ *
10
+ * 在非 Tauri 环境(纯浏览器调试 / 单元测试)这会安静失败 —— 那种场景下
11
+ * 本来也没有 sidecar 可重启。
12
+ */
13
+ async function notifyTauriRestartAdapters(): Promise<void> {
14
+ try {
15
+ // 用 dynamic import 避开 SSR / non-tauri 测试环境的硬依赖
16
+ const { invoke } = await import('@tauri-apps/api/core')
17
+ await invoke('restart_adapters_sidecar')
18
+ } catch (err) {
19
+ // 不阻塞保存流程 —— 配置文件已经写入,下次启动 App 也会生效
20
+ if (typeof console !== 'undefined') {
21
+ console.warn('[adapterStore] restart_adapters_sidecar failed:', err)
22
+ }
23
+ }
24
+ }
25
+
26
+ const SAFE_ALPHABET = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789'
27
+ const CODE_LENGTH = 6
28
+ const CODE_TTL_MS = 60 * 60 * 1000 // 60 minutes
29
+
30
+ function generateCode(): string {
31
+ const maxValid = Math.floor(256 / SAFE_ALPHABET.length) * SAFE_ALPHABET.length
32
+ let code = ''
33
+ while (code.length < CODE_LENGTH) {
34
+ const array = new Uint8Array(1)
35
+ crypto.getRandomValues(array)
36
+ if (array[0]! < maxValid) {
37
+ code += SAFE_ALPHABET[array[0]! % SAFE_ALPHABET.length]
38
+ }
39
+ }
40
+ return code
41
+ }
42
+
43
+ type AdapterStore = {
44
+ config: AdapterFileConfig
45
+ isLoading: boolean
46
+ error: string | null
47
+
48
+ fetchConfig: () => Promise<void>
49
+ updateConfig: (patch: Partial<AdapterFileConfig>) => Promise<void>
50
+ generatePairingCode: () => Promise<string>
51
+ removePairedUser: (platform: 'telegram' | 'feishu', userId: string | number) => Promise<void>
52
+ }
53
+
54
+ export const useAdapterStore = create<AdapterStore>((set, get) => ({
55
+ config: {},
56
+ isLoading: false,
57
+ error: null,
58
+
59
+ fetchConfig: async () => {
60
+ set({ isLoading: true, error: null })
61
+ try {
62
+ const config = await adaptersApi.getConfig()
63
+ set({ config, isLoading: false })
64
+ } catch (err) {
65
+ const message = err instanceof Error ? err.message : 'Failed to load config'
66
+ set({ isLoading: false, error: message })
67
+ }
68
+ },
69
+
70
+ updateConfig: async (patch) => {
71
+ const config = await adaptersApi.updateConfig(patch)
72
+ set({ config })
73
+ // 配置文件已写入磁盘,让 Tauri 主进程 kill + respawn adapter sidecar,
74
+ // 触发飞书 / Telegram WebSocket 用新凭据重连。pairing code / paired users
75
+ // 这种轻量更新也会触发重启 —— 这是个有意为之的简化:保证"任何配置变更
76
+ // 都立刻生效",比起精细判断哪些字段值得重启更可靠。
77
+ void notifyTauriRestartAdapters()
78
+ },
79
+
80
+ generatePairingCode: async () => {
81
+ const code = generateCode()
82
+ const now = Date.now()
83
+ await get().updateConfig({
84
+ pairing: {
85
+ code,
86
+ expiresAt: now + CODE_TTL_MS,
87
+ createdAt: now,
88
+ },
89
+ })
90
+ return code
91
+ },
92
+
93
+ removePairedUser: async (platform, userId) => {
94
+ const { config } = get()
95
+ const platformConfig = config[platform]
96
+ if (!platformConfig) return
97
+
98
+ const pairedUsers = (platformConfig.pairedUsers ?? []).filter(
99
+ (u) => String(u.userId) !== String(userId),
100
+ )
101
+
102
+ await get().updateConfig({
103
+ [platform]: { ...platformConfig, pairedUsers },
104
+ })
105
+ },
106
+ }))
@@ -0,0 +1,34 @@
1
+ import { create } from 'zustand'
2
+ import { agentsApi, type AgentDefinition } from '../api/agents'
3
+
4
+ type AgentStore = {
5
+ activeAgents: AgentDefinition[]
6
+ allAgents: AgentDefinition[]
7
+ isLoading: boolean
8
+ error: string | null
9
+ selectedAgent: AgentDefinition | null
10
+
11
+ fetchAgents: (cwd?: string) => Promise<void>
12
+ selectAgent: (agent: AgentDefinition | null) => void
13
+ }
14
+
15
+ export const useAgentStore = create<AgentStore>((set) => ({
16
+ activeAgents: [],
17
+ allAgents: [],
18
+ isLoading: false,
19
+ error: null,
20
+ selectedAgent: null,
21
+
22
+ fetchAgents: async (cwd) => {
23
+ set({ isLoading: true, error: null })
24
+ try {
25
+ const { activeAgents, allAgents } = await agentsApi.list(cwd)
26
+ set({ activeAgents, allAgents, isLoading: false })
27
+ } catch (error) {
28
+ const message = error instanceof Error ? error.message : 'Failed to load agents'
29
+ set({ isLoading: false, error: message })
30
+ }
31
+ },
32
+
33
+ selectAgent: (agent) => set({ selectedAgent: agent }),
34
+ }))