bingocode 1.0.3 → 1.0.4

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 (184) hide show
  1. package/package.json +1 -1
  2. package/desktop/README.md +0 -30
  3. package/desktop/bunfig.toml +0 -1
  4. package/desktop/index.html +0 -17
  5. package/desktop/package.json +0 -55
  6. package/desktop/pnpm-lock.yaml +0 -3832
  7. package/desktop/public/app-icon.jpg +0 -0
  8. package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
  9. package/desktop/public/fonts/inter-latin.woff2 +0 -0
  10. package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  11. package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
  12. package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
  13. package/desktop/public/fonts/manrope-latin.woff2 +0 -0
  14. package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
  15. package/desktop/public/icons/bilibili.svg +0 -1
  16. package/desktop/public/icons/douyin.svg +0 -1
  17. package/desktop/public/icons/github.svg +0 -3
  18. package/desktop/public/icons/xiaohongshu.svg +0 -1
  19. package/desktop/scripts/build-macos-arm64.sh +0 -270
  20. package/desktop/scripts/build-sidecars.ts +0 -183
  21. package/desktop/scripts/build-windows-x64.ps1 +0 -295
  22. package/desktop/scripts/scan-missing-imports.ts +0 -235
  23. package/desktop/sidecars/claude-sidecar.ts +0 -156
  24. package/desktop/src/App.tsx +0 -5
  25. package/desktop/src/__tests__/agentsSettings.test.tsx +0 -349
  26. package/desktop/src/__tests__/pages.test.tsx +0 -290
  27. package/desktop/src/__tests__/skillsSettings.test.tsx +0 -205
  28. package/desktop/src/api/adapters.ts +0 -12
  29. package/desktop/src/api/agents.ts +0 -36
  30. package/desktop/src/api/cliTasks.ts +0 -28
  31. package/desktop/src/api/client.ts +0 -63
  32. package/desktop/src/api/computerUse.ts +0 -76
  33. package/desktop/src/api/filesystem.ts +0 -30
  34. package/desktop/src/api/hahaOAuth.ts +0 -38
  35. package/desktop/src/api/models.ts +0 -28
  36. package/desktop/src/api/providers.ts +0 -63
  37. package/desktop/src/api/search.ts +0 -29
  38. package/desktop/src/api/sessions.ts +0 -56
  39. package/desktop/src/api/settings.ts +0 -20
  40. package/desktop/src/api/skills.ts +0 -19
  41. package/desktop/src/api/tasks.ts +0 -36
  42. package/desktop/src/api/teams.ts +0 -44
  43. package/desktop/src/api/websocket.ts +0 -164
  44. package/desktop/src/components/chat/AskUserQuestion.tsx +0 -268
  45. package/desktop/src/components/chat/AssistantMessage.tsx +0 -29
  46. package/desktop/src/components/chat/AttachmentGallery.tsx +0 -113
  47. package/desktop/src/components/chat/ChatInput.tsx +0 -622
  48. package/desktop/src/components/chat/CodeViewer.tsx +0 -161
  49. package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +0 -174
  50. package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +0 -311
  51. package/desktop/src/components/chat/DiffViewer.tsx +0 -157
  52. package/desktop/src/components/chat/FileSearchMenu.tsx +0 -198
  53. package/desktop/src/components/chat/ImageGalleryModal.tsx +0 -91
  54. package/desktop/src/components/chat/InlineImageGallery.tsx +0 -106
  55. package/desktop/src/components/chat/InlineTaskSummary.tsx +0 -60
  56. package/desktop/src/components/chat/MermaidRenderer.test.tsx +0 -98
  57. package/desktop/src/components/chat/MermaidRenderer.tsx +0 -361
  58. package/desktop/src/components/chat/MessageActionBar.tsx +0 -27
  59. package/desktop/src/components/chat/MessageList.test.tsx +0 -313
  60. package/desktop/src/components/chat/MessageList.tsx +0 -249
  61. package/desktop/src/components/chat/PermissionDialog.tsx +0 -262
  62. package/desktop/src/components/chat/SessionTaskBar.test.tsx +0 -99
  63. package/desktop/src/components/chat/SessionTaskBar.tsx +0 -159
  64. package/desktop/src/components/chat/StreamingIndicator.tsx +0 -41
  65. package/desktop/src/components/chat/TerminalChrome.tsx +0 -35
  66. package/desktop/src/components/chat/ThinkingBlock.tsx +0 -87
  67. package/desktop/src/components/chat/ToolCallBlock.tsx +0 -247
  68. package/desktop/src/components/chat/ToolCallGroup.tsx +0 -617
  69. package/desktop/src/components/chat/ToolResultBlock.tsx +0 -107
  70. package/desktop/src/components/chat/UserMessage.tsx +0 -38
  71. package/desktop/src/components/chat/chatBlocks.test.tsx +0 -136
  72. package/desktop/src/components/chat/clipboard.ts +0 -25
  73. package/desktop/src/components/chat/composerUtils.test.ts +0 -55
  74. package/desktop/src/components/chat/composerUtils.ts +0 -149
  75. package/desktop/src/components/controls/ModelSelector.tsx +0 -156
  76. package/desktop/src/components/controls/PermissionModeSelector.tsx +0 -229
  77. package/desktop/src/components/layout/AppShell.tsx +0 -107
  78. package/desktop/src/components/layout/ContentRouter.tsx +0 -27
  79. package/desktop/src/components/layout/ProjectFilter.tsx +0 -126
  80. package/desktop/src/components/layout/Sidebar.test.tsx +0 -158
  81. package/desktop/src/components/layout/Sidebar.tsx +0 -384
  82. package/desktop/src/components/layout/StatusBar.tsx +0 -31
  83. package/desktop/src/components/layout/TabBar.test.tsx +0 -136
  84. package/desktop/src/components/layout/TabBar.tsx +0 -318
  85. package/desktop/src/components/layout/TitleBar.tsx +0 -96
  86. package/desktop/src/components/layout/WindowControls.test.tsx +0 -69
  87. package/desktop/src/components/layout/WindowControls.tsx +0 -89
  88. package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +0 -100
  89. package/desktop/src/components/markdown/MarkdownRenderer.tsx +0 -229
  90. package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +0 -107
  91. package/desktop/src/components/shared/Button.tsx +0 -63
  92. package/desktop/src/components/shared/CopyButton.tsx +0 -58
  93. package/desktop/src/components/shared/DirectoryPicker.tsx +0 -316
  94. package/desktop/src/components/shared/Dropdown.tsx +0 -91
  95. package/desktop/src/components/shared/Input.tsx +0 -38
  96. package/desktop/src/components/shared/Modal.tsx +0 -65
  97. package/desktop/src/components/shared/ProjectContextChip.tsx +0 -30
  98. package/desktop/src/components/shared/Spinner.tsx +0 -30
  99. package/desktop/src/components/shared/Textarea.tsx +0 -38
  100. package/desktop/src/components/shared/Toast.tsx +0 -47
  101. package/desktop/src/components/shared/UpdateChecker.tsx +0 -90
  102. package/desktop/src/components/skills/SkillDetail.test.tsx +0 -89
  103. package/desktop/src/components/skills/SkillDetail.tsx +0 -403
  104. package/desktop/src/components/skills/SkillList.tsx +0 -254
  105. package/desktop/src/components/tasks/DayOfWeekPicker.tsx +0 -57
  106. package/desktop/src/components/tasks/NewTaskModal.tsx +0 -407
  107. package/desktop/src/components/tasks/PromptEditor.tsx +0 -74
  108. package/desktop/src/components/tasks/TaskEmptyState.tsx +0 -30
  109. package/desktop/src/components/tasks/TaskList.tsx +0 -46
  110. package/desktop/src/components/tasks/TaskRow.tsx +0 -253
  111. package/desktop/src/components/tasks/TaskRunsPanel.tsx +0 -195
  112. package/desktop/src/components/teams/TeamStatusBar.tsx +0 -147
  113. package/desktop/src/config/providerPresets.ts +0 -78
  114. package/desktop/src/config/spinnerVerbs.ts +0 -193
  115. package/desktop/src/hooks/useKeyboardShortcuts.ts +0 -60
  116. package/desktop/src/i18n/index.ts +0 -54
  117. package/desktop/src/i18n/locales/en.ts +0 -670
  118. package/desktop/src/i18n/locales/zh.ts +0 -670
  119. package/desktop/src/lib/__tests__/cronDescribe.test.ts +0 -93
  120. package/desktop/src/lib/cronDescribe.ts +0 -188
  121. package/desktop/src/lib/desktopRuntime.ts +0 -54
  122. package/desktop/src/lib/parseRunOutput.ts +0 -79
  123. package/desktop/src/main.tsx +0 -13
  124. package/desktop/src/mocks/data.ts +0 -202
  125. package/desktop/src/pages/ActiveSession.test.tsx +0 -181
  126. package/desktop/src/pages/ActiveSession.tsx +0 -219
  127. package/desktop/src/pages/AdapterSettings.tsx +0 -375
  128. package/desktop/src/pages/AgentTeams.tsx +0 -200
  129. package/desktop/src/pages/ComputerUseSettings.tsx +0 -420
  130. package/desktop/src/pages/EmptySession.tsx +0 -518
  131. package/desktop/src/pages/NewTaskModal.tsx +0 -346
  132. package/desktop/src/pages/ScheduledTasks.tsx +0 -66
  133. package/desktop/src/pages/ScheduledTasksEmpty.tsx +0 -152
  134. package/desktop/src/pages/ScheduledTasksList.tsx +0 -416
  135. package/desktop/src/pages/SessionControls.tsx +0 -460
  136. package/desktop/src/pages/Settings.tsx +0 -1448
  137. package/desktop/src/pages/ToolInspection.tsx +0 -235
  138. package/desktop/src/stores/adapterStore.ts +0 -106
  139. package/desktop/src/stores/agentStore.ts +0 -34
  140. package/desktop/src/stores/chatStore.test.ts +0 -505
  141. package/desktop/src/stores/chatStore.ts +0 -850
  142. package/desktop/src/stores/cliTaskStore.ts +0 -152
  143. package/desktop/src/stores/hahaOAuthStore.test.ts +0 -77
  144. package/desktop/src/stores/hahaOAuthStore.ts +0 -97
  145. package/desktop/src/stores/providerStore.ts +0 -101
  146. package/desktop/src/stores/sessionStore.test.ts +0 -63
  147. package/desktop/src/stores/sessionStore.ts +0 -102
  148. package/desktop/src/stores/settingsStore.ts +0 -120
  149. package/desktop/src/stores/skillStore.ts +0 -51
  150. package/desktop/src/stores/tabStore.ts +0 -169
  151. package/desktop/src/stores/taskStore.ts +0 -68
  152. package/desktop/src/stores/teamStore.ts +0 -344
  153. package/desktop/src/stores/uiStore.ts +0 -100
  154. package/desktop/src/stores/updateStore.test.ts +0 -71
  155. package/desktop/src/stores/updateStore.ts +0 -221
  156. package/desktop/src/theme/globals.css +0 -465
  157. package/desktop/src/types/adapter.ts +0 -33
  158. package/desktop/src/types/chat.ts +0 -152
  159. package/desktop/src/types/cliTask.ts +0 -24
  160. package/desktop/src/types/provider.ts +0 -62
  161. package/desktop/src/types/session.ts +0 -27
  162. package/desktop/src/types/settings.ts +0 -22
  163. package/desktop/src/types/skill.ts +0 -38
  164. package/desktop/src/types/task.ts +0 -56
  165. package/desktop/src/types/team.ts +0 -38
  166. package/desktop/src-tauri/Cargo.lock +0 -5549
  167. package/desktop/src-tauri/Cargo.toml +0 -20
  168. package/desktop/src-tauri/app-icon.svg +0 -13
  169. package/desktop/src-tauri/build.rs +0 -3
  170. package/desktop/src-tauri/capabilities/default.json +0 -106
  171. package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +0 -5
  172. package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +0 -4
  173. package/desktop/src-tauri/icons/icon.icns +0 -0
  174. package/desktop/src-tauri/icons/icon.ico +0 -0
  175. package/desktop/src-tauri/src/lib.rs +0 -408
  176. package/desktop/src-tauri/src/main.rs +0 -6
  177. package/desktop/src-tauri/tauri.conf.json +0 -78
  178. package/desktop/src-tauri/tauri.macos.conf.json +0 -18
  179. package/desktop/src-tauri/tauri.release-ci.json +0 -5
  180. package/desktop/src-tauri/tauri.windows.conf.json +0 -16
  181. package/desktop/src-tauri/windows-installer-hooks.nsh +0 -17
  182. package/desktop/tsconfig.json +0 -25
  183. package/desktop/vite.config.ts +0 -26
  184. package/desktop/vitest.config.ts +0 -18
@@ -1,235 +0,0 @@
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
- }
@@ -1,106 +0,0 @@
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
- }))
@@ -1,34 +0,0 @@
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
- }))