bingocode 1.0.1 → 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.
- package/bin/bingo-win.cjs +34 -3
- package/desktop/README.md +30 -0
- package/desktop/bunfig.toml +1 -0
- package/desktop/index.html +17 -0
- package/desktop/package.json +55 -0
- package/desktop/pnpm-lock.yaml +3832 -0
- package/desktop/public/app-icon.jpg +0 -0
- package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/inter-latin.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin.woff2 +0 -0
- package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
- package/desktop/public/icons/bilibili.svg +1 -0
- package/desktop/public/icons/douyin.svg +1 -0
- package/desktop/public/icons/github.svg +3 -0
- package/desktop/public/icons/xiaohongshu.svg +1 -0
- package/desktop/scripts/build-macos-arm64.sh +270 -0
- package/desktop/scripts/build-sidecars.ts +183 -0
- package/desktop/scripts/build-windows-x64.ps1 +295 -0
- package/desktop/scripts/scan-missing-imports.ts +235 -0
- package/desktop/sidecars/claude-sidecar.ts +156 -0
- package/desktop/src/App.tsx +5 -0
- package/desktop/src/__tests__/agentsSettings.test.tsx +349 -0
- package/desktop/src/__tests__/pages.test.tsx +290 -0
- package/desktop/src/__tests__/skillsSettings.test.tsx +205 -0
- package/desktop/src/api/adapters.ts +12 -0
- package/desktop/src/api/agents.ts +36 -0
- package/desktop/src/api/cliTasks.ts +28 -0
- package/desktop/src/api/client.ts +63 -0
- package/desktop/src/api/computerUse.ts +76 -0
- package/desktop/src/api/filesystem.ts +30 -0
- package/desktop/src/api/hahaOAuth.ts +38 -0
- package/desktop/src/api/models.ts +28 -0
- package/desktop/src/api/providers.ts +63 -0
- package/desktop/src/api/search.ts +29 -0
- package/desktop/src/api/sessions.ts +56 -0
- package/desktop/src/api/settings.ts +20 -0
- package/desktop/src/api/skills.ts +19 -0
- package/desktop/src/api/tasks.ts +36 -0
- package/desktop/src/api/teams.ts +44 -0
- package/desktop/src/api/websocket.ts +164 -0
- package/desktop/src/components/chat/AskUserQuestion.tsx +268 -0
- package/desktop/src/components/chat/AssistantMessage.tsx +29 -0
- package/desktop/src/components/chat/AttachmentGallery.tsx +113 -0
- package/desktop/src/components/chat/ChatInput.tsx +622 -0
- package/desktop/src/components/chat/CodeViewer.tsx +161 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +174 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +311 -0
- package/desktop/src/components/chat/DiffViewer.tsx +157 -0
- package/desktop/src/components/chat/FileSearchMenu.tsx +198 -0
- package/desktop/src/components/chat/ImageGalleryModal.tsx +91 -0
- package/desktop/src/components/chat/InlineImageGallery.tsx +106 -0
- package/desktop/src/components/chat/InlineTaskSummary.tsx +60 -0
- package/desktop/src/components/chat/MermaidRenderer.test.tsx +98 -0
- package/desktop/src/components/chat/MermaidRenderer.tsx +361 -0
- package/desktop/src/components/chat/MessageActionBar.tsx +27 -0
- package/desktop/src/components/chat/MessageList.test.tsx +313 -0
- package/desktop/src/components/chat/MessageList.tsx +249 -0
- package/desktop/src/components/chat/PermissionDialog.tsx +262 -0
- package/desktop/src/components/chat/SessionTaskBar.test.tsx +99 -0
- package/desktop/src/components/chat/SessionTaskBar.tsx +159 -0
- package/desktop/src/components/chat/StreamingIndicator.tsx +41 -0
- package/desktop/src/components/chat/TerminalChrome.tsx +35 -0
- package/desktop/src/components/chat/ThinkingBlock.tsx +87 -0
- package/desktop/src/components/chat/ToolCallBlock.tsx +247 -0
- package/desktop/src/components/chat/ToolCallGroup.tsx +617 -0
- package/desktop/src/components/chat/ToolResultBlock.tsx +107 -0
- package/desktop/src/components/chat/UserMessage.tsx +38 -0
- package/desktop/src/components/chat/chatBlocks.test.tsx +136 -0
- package/desktop/src/components/chat/clipboard.ts +25 -0
- package/desktop/src/components/chat/composerUtils.test.ts +55 -0
- package/desktop/src/components/chat/composerUtils.ts +149 -0
- package/desktop/src/components/controls/ModelSelector.tsx +156 -0
- package/desktop/src/components/controls/PermissionModeSelector.tsx +229 -0
- package/desktop/src/components/layout/AppShell.tsx +107 -0
- package/desktop/src/components/layout/ContentRouter.tsx +27 -0
- package/desktop/src/components/layout/ProjectFilter.tsx +126 -0
- package/desktop/src/components/layout/Sidebar.test.tsx +158 -0
- package/desktop/src/components/layout/Sidebar.tsx +384 -0
- package/desktop/src/components/layout/StatusBar.tsx +31 -0
- package/desktop/src/components/layout/TabBar.test.tsx +136 -0
- package/desktop/src/components/layout/TabBar.tsx +318 -0
- package/desktop/src/components/layout/TitleBar.tsx +96 -0
- package/desktop/src/components/layout/WindowControls.test.tsx +69 -0
- package/desktop/src/components/layout/WindowControls.tsx +89 -0
- package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +100 -0
- package/desktop/src/components/markdown/MarkdownRenderer.tsx +229 -0
- package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +107 -0
- package/desktop/src/components/shared/Button.tsx +63 -0
- package/desktop/src/components/shared/CopyButton.tsx +58 -0
- package/desktop/src/components/shared/DirectoryPicker.tsx +316 -0
- package/desktop/src/components/shared/Dropdown.tsx +91 -0
- package/desktop/src/components/shared/Input.tsx +38 -0
- package/desktop/src/components/shared/Modal.tsx +65 -0
- package/desktop/src/components/shared/ProjectContextChip.tsx +30 -0
- package/desktop/src/components/shared/Spinner.tsx +30 -0
- package/desktop/src/components/shared/Textarea.tsx +38 -0
- package/desktop/src/components/shared/Toast.tsx +47 -0
- package/desktop/src/components/shared/UpdateChecker.tsx +90 -0
- package/desktop/src/components/skills/SkillDetail.test.tsx +89 -0
- package/desktop/src/components/skills/SkillDetail.tsx +403 -0
- package/desktop/src/components/skills/SkillList.tsx +254 -0
- package/desktop/src/components/tasks/DayOfWeekPicker.tsx +57 -0
- package/desktop/src/components/tasks/NewTaskModal.tsx +407 -0
- package/desktop/src/components/tasks/PromptEditor.tsx +74 -0
- package/desktop/src/components/tasks/TaskEmptyState.tsx +30 -0
- package/desktop/src/components/tasks/TaskList.tsx +46 -0
- package/desktop/src/components/tasks/TaskRow.tsx +253 -0
- package/desktop/src/components/tasks/TaskRunsPanel.tsx +195 -0
- package/desktop/src/components/teams/TeamStatusBar.tsx +147 -0
- package/desktop/src/config/providerPresets.ts +78 -0
- package/desktop/src/config/spinnerVerbs.ts +193 -0
- package/desktop/src/hooks/useKeyboardShortcuts.ts +60 -0
- package/desktop/src/i18n/index.ts +54 -0
- package/desktop/src/i18n/locales/en.ts +670 -0
- package/desktop/src/i18n/locales/zh.ts +670 -0
- package/desktop/src/lib/__tests__/cronDescribe.test.ts +93 -0
- package/desktop/src/lib/cronDescribe.ts +188 -0
- package/desktop/src/lib/desktopRuntime.ts +54 -0
- package/desktop/src/lib/parseRunOutput.ts +79 -0
- package/desktop/src/main.tsx +13 -0
- package/desktop/src/mocks/data.ts +202 -0
- package/desktop/src/pages/ActiveSession.test.tsx +181 -0
- package/desktop/src/pages/ActiveSession.tsx +219 -0
- package/desktop/src/pages/AdapterSettings.tsx +375 -0
- package/desktop/src/pages/AgentTeams.tsx +200 -0
- package/desktop/src/pages/ComputerUseSettings.tsx +420 -0
- package/desktop/src/pages/EmptySession.tsx +518 -0
- package/desktop/src/pages/NewTaskModal.tsx +346 -0
- package/desktop/src/pages/ScheduledTasks.tsx +66 -0
- package/desktop/src/pages/ScheduledTasksEmpty.tsx +152 -0
- package/desktop/src/pages/ScheduledTasksList.tsx +416 -0
- package/desktop/src/pages/SessionControls.tsx +460 -0
- package/desktop/src/pages/Settings.tsx +1448 -0
- package/desktop/src/pages/ToolInspection.tsx +235 -0
- package/desktop/src/stores/adapterStore.ts +106 -0
- package/desktop/src/stores/agentStore.ts +34 -0
- package/desktop/src/stores/chatStore.test.ts +505 -0
- package/desktop/src/stores/chatStore.ts +850 -0
- package/desktop/src/stores/cliTaskStore.ts +152 -0
- package/desktop/src/stores/hahaOAuthStore.test.ts +77 -0
- package/desktop/src/stores/hahaOAuthStore.ts +97 -0
- package/desktop/src/stores/providerStore.ts +101 -0
- package/desktop/src/stores/sessionStore.test.ts +63 -0
- package/desktop/src/stores/sessionStore.ts +102 -0
- package/desktop/src/stores/settingsStore.ts +120 -0
- package/desktop/src/stores/skillStore.ts +51 -0
- package/desktop/src/stores/tabStore.ts +169 -0
- package/desktop/src/stores/taskStore.ts +68 -0
- package/desktop/src/stores/teamStore.ts +344 -0
- package/desktop/src/stores/uiStore.ts +100 -0
- package/desktop/src/stores/updateStore.test.ts +71 -0
- package/desktop/src/stores/updateStore.ts +221 -0
- package/desktop/src/theme/globals.css +465 -0
- package/desktop/src/types/adapter.ts +33 -0
- package/desktop/src/types/chat.ts +152 -0
- package/desktop/src/types/cliTask.ts +24 -0
- package/desktop/src/types/provider.ts +62 -0
- package/desktop/src/types/session.ts +27 -0
- package/desktop/src/types/settings.ts +22 -0
- package/desktop/src/types/skill.ts +38 -0
- package/desktop/src/types/task.ts +56 -0
- package/desktop/src/types/team.ts +38 -0
- package/desktop/src-tauri/Cargo.lock +5549 -0
- package/desktop/src-tauri/Cargo.toml +20 -0
- package/desktop/src-tauri/app-icon.svg +13 -0
- package/desktop/src-tauri/build.rs +3 -0
- package/desktop/src-tauri/capabilities/default.json +106 -0
- package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +4 -0
- package/desktop/src-tauri/icons/icon.icns +0 -0
- package/desktop/src-tauri/icons/icon.ico +0 -0
- package/desktop/src-tauri/src/lib.rs +408 -0
- package/desktop/src-tauri/src/main.rs +6 -0
- package/desktop/src-tauri/tauri.conf.json +78 -0
- package/desktop/src-tauri/tauri.macos.conf.json +18 -0
- package/desktop/src-tauri/tauri.release-ci.json +5 -0
- package/desktop/src-tauri/tauri.windows.conf.json +16 -0
- package/desktop/src-tauri/windows-installer-hooks.nsh +17 -0
- package/desktop/tsconfig.json +25 -0
- package/desktop/vite.config.ts +26 -0
- package/desktop/vitest.config.ts +18 -0
- package/package.json +1 -1
- package/src/commands/desktop/desktop.tsx +9 -0
- package/src/commands/desktop/index.ts +26 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
3
|
+
import '@testing-library/jest-dom'
|
|
4
|
+
|
|
5
|
+
import { Settings } from '../pages/Settings'
|
|
6
|
+
import { useSkillStore } from '../stores/skillStore'
|
|
7
|
+
import { useSettingsStore } from '../stores/settingsStore'
|
|
8
|
+
import { useSessionStore } from '../stores/sessionStore'
|
|
9
|
+
import { useTabStore, SETTINGS_TAB_ID } from '../stores/tabStore'
|
|
10
|
+
|
|
11
|
+
vi.mock('../api/agents', () => ({
|
|
12
|
+
agentsApi: {
|
|
13
|
+
list: vi.fn().mockResolvedValue({ activeAgents: [], allAgents: [] }),
|
|
14
|
+
},
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
vi.mock('../stores/providerStore', () => ({
|
|
18
|
+
useProviderStore: () => ({
|
|
19
|
+
providers: [],
|
|
20
|
+
activeId: null,
|
|
21
|
+
isLoading: false,
|
|
22
|
+
fetchProviders: vi.fn(),
|
|
23
|
+
deleteProvider: vi.fn(),
|
|
24
|
+
activateProvider: vi.fn(),
|
|
25
|
+
activateOfficial: vi.fn(),
|
|
26
|
+
testProvider: vi.fn(),
|
|
27
|
+
createProvider: vi.fn(),
|
|
28
|
+
updateProvider: vi.fn(),
|
|
29
|
+
testConfig: vi.fn(),
|
|
30
|
+
}),
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
vi.mock('../pages/AdapterSettings', () => ({
|
|
34
|
+
AdapterSettings: () => <div>Adapter Settings Mock</div>,
|
|
35
|
+
}))
|
|
36
|
+
|
|
37
|
+
vi.mock('../stores/agentStore', () => ({
|
|
38
|
+
useAgentStore: () => ({
|
|
39
|
+
activeAgents: [],
|
|
40
|
+
allAgents: [],
|
|
41
|
+
isLoading: false,
|
|
42
|
+
error: null,
|
|
43
|
+
selectedAgent: null,
|
|
44
|
+
fetchAgents: vi.fn(),
|
|
45
|
+
selectAgent: vi.fn(),
|
|
46
|
+
}),
|
|
47
|
+
}))
|
|
48
|
+
|
|
49
|
+
vi.mock('../components/chat/CodeViewer', () => ({
|
|
50
|
+
CodeViewer: ({ code }: { code: string }) => <pre data-testid="code-viewer">{code}</pre>,
|
|
51
|
+
}))
|
|
52
|
+
|
|
53
|
+
const MOCK_FETCH_SKILLS = vi.fn()
|
|
54
|
+
const MOCK_FETCH_SKILL_DETAIL = vi.fn()
|
|
55
|
+
const MOCK_CLEAR_SELECTION = vi.fn()
|
|
56
|
+
|
|
57
|
+
function switchToSkillsTab() {
|
|
58
|
+
fireEvent.click(screen.getByText('Skills'))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe('Settings > Skills tab', () => {
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
vi.clearAllMocks()
|
|
64
|
+
useSettingsStore.setState({ locale: 'en' })
|
|
65
|
+
useSessionStore.setState({
|
|
66
|
+
sessions: [
|
|
67
|
+
{
|
|
68
|
+
id: 'session-1',
|
|
69
|
+
title: 'Active session',
|
|
70
|
+
createdAt: '2026-04-20T00:00:00.000Z',
|
|
71
|
+
modifiedAt: '2026-04-20T00:00:00.000Z',
|
|
72
|
+
messageCount: 1,
|
|
73
|
+
projectPath: '/workspace/project',
|
|
74
|
+
workDir: '/workspace/project',
|
|
75
|
+
workDirExists: true,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
activeSessionId: 'session-1',
|
|
79
|
+
isLoading: false,
|
|
80
|
+
error: null,
|
|
81
|
+
selectedProjects: [],
|
|
82
|
+
availableProjects: ['/workspace/project'],
|
|
83
|
+
})
|
|
84
|
+
useTabStore.setState({ tabs: [], activeTabId: null })
|
|
85
|
+
useSkillStore.setState({
|
|
86
|
+
skills: [],
|
|
87
|
+
selectedSkill: null,
|
|
88
|
+
isLoading: false,
|
|
89
|
+
isDetailLoading: false,
|
|
90
|
+
error: null,
|
|
91
|
+
fetchSkills: MOCK_FETCH_SKILLS,
|
|
92
|
+
fetchSkillDetail: MOCK_FETCH_SKILL_DETAIL,
|
|
93
|
+
clearSelection: MOCK_CLEAR_SELECTION,
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('renders browser summary and grouped skill cards', () => {
|
|
98
|
+
useSkillStore.setState({
|
|
99
|
+
skills: [
|
|
100
|
+
{
|
|
101
|
+
name: 'alpha',
|
|
102
|
+
displayName: 'Alpha Skill',
|
|
103
|
+
description: 'First skill description',
|
|
104
|
+
source: 'user',
|
|
105
|
+
userInvocable: true,
|
|
106
|
+
version: '1.0.0',
|
|
107
|
+
contentLength: 400,
|
|
108
|
+
hasDirectory: true,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'beta',
|
|
112
|
+
description: 'Second skill description',
|
|
113
|
+
source: 'project',
|
|
114
|
+
userInvocable: false,
|
|
115
|
+
contentLength: 200,
|
|
116
|
+
hasDirectory: true,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
render(<Settings />)
|
|
122
|
+
switchToSkillsTab()
|
|
123
|
+
|
|
124
|
+
expect(screen.getByText('Browse installed skills')).toBeInTheDocument()
|
|
125
|
+
expect(screen.getByText('Skill Browser')).toBeInTheDocument()
|
|
126
|
+
expect(screen.getByText('Total skills')).toBeInTheDocument()
|
|
127
|
+
expect(screen.getByText('Alpha Skill')).toBeInTheDocument()
|
|
128
|
+
expect(screen.getByText('Second skill description')).toBeInTheDocument()
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('uses the active session workDir even when settings tab is focused', () => {
|
|
132
|
+
const fetchSkills = vi.fn()
|
|
133
|
+
useSkillStore.setState({
|
|
134
|
+
skills: [],
|
|
135
|
+
selectedSkill: null,
|
|
136
|
+
isLoading: false,
|
|
137
|
+
isDetailLoading: false,
|
|
138
|
+
error: null,
|
|
139
|
+
fetchSkills,
|
|
140
|
+
fetchSkillDetail: MOCK_FETCH_SKILL_DETAIL,
|
|
141
|
+
clearSelection: MOCK_CLEAR_SELECTION,
|
|
142
|
+
})
|
|
143
|
+
useTabStore.setState({
|
|
144
|
+
activeTabId: SETTINGS_TAB_ID,
|
|
145
|
+
tabs: [{ sessionId: SETTINGS_TAB_ID, title: 'Settings', type: 'settings', status: 'idle' }],
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
render(<Settings />)
|
|
149
|
+
switchToSkillsTab()
|
|
150
|
+
|
|
151
|
+
expect(fetchSkills).toHaveBeenCalledWith('/workspace/project')
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('opens skill detail with metadata cards and parsed markdown body', () => {
|
|
155
|
+
useSkillStore.setState({
|
|
156
|
+
selectedSkill: {
|
|
157
|
+
meta: {
|
|
158
|
+
name: 'alpha',
|
|
159
|
+
displayName: 'Alpha Skill',
|
|
160
|
+
description: 'First skill description',
|
|
161
|
+
source: 'user',
|
|
162
|
+
userInvocable: true,
|
|
163
|
+
version: '1.0.0',
|
|
164
|
+
contentLength: 400,
|
|
165
|
+
hasDirectory: true,
|
|
166
|
+
},
|
|
167
|
+
tree: [
|
|
168
|
+
{ name: 'SKILL.md', path: 'SKILL.md', type: 'file' },
|
|
169
|
+
{ name: 'run.ts', path: 'run.ts', type: 'file' },
|
|
170
|
+
],
|
|
171
|
+
files: [
|
|
172
|
+
{
|
|
173
|
+
path: 'SKILL.md',
|
|
174
|
+
content: '# Hello\n\nBody content',
|
|
175
|
+
body: '# Hello\n\nBody content',
|
|
176
|
+
language: 'markdown',
|
|
177
|
+
isEntry: true,
|
|
178
|
+
frontmatter: {
|
|
179
|
+
description: 'Frontmatter description',
|
|
180
|
+
'allowed-tools': ['Read', 'Edit'],
|
|
181
|
+
model: 'sonnet',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
path: 'run.ts',
|
|
186
|
+
content: 'console.log("hello")',
|
|
187
|
+
language: 'typescript',
|
|
188
|
+
isEntry: false,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
skillRoot: '/tmp/alpha',
|
|
192
|
+
},
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
render(<Settings />)
|
|
196
|
+
switchToSkillsTab()
|
|
197
|
+
|
|
198
|
+
expect(screen.getByText('Skill metadata')).toBeInTheDocument()
|
|
199
|
+
expect(screen.getByText('/slash')).toBeInTheDocument()
|
|
200
|
+
expect(screen.getByText('Frontmatter description')).toBeInTheDocument()
|
|
201
|
+
expect(screen.getByText('Read, Edit')).toBeInTheDocument()
|
|
202
|
+
expect(screen.getByText('Hello')).toBeInTheDocument()
|
|
203
|
+
expect(screen.queryByText(/^---$/)).not.toBeInTheDocument()
|
|
204
|
+
})
|
|
205
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
import type { AdapterFileConfig } from '../types/adapter'
|
|
3
|
+
|
|
4
|
+
export const adaptersApi = {
|
|
5
|
+
getConfig() {
|
|
6
|
+
return api.get<AdapterFileConfig>('/api/adapters')
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
updateConfig(patch: Partial<AdapterFileConfig>) {
|
|
10
|
+
return api.put<AdapterFileConfig>('/api/adapters', patch)
|
|
11
|
+
},
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
|
|
3
|
+
export type AgentSource =
|
|
4
|
+
| 'built-in'
|
|
5
|
+
| 'plugin'
|
|
6
|
+
| 'userSettings'
|
|
7
|
+
| 'projectSettings'
|
|
8
|
+
| 'localSettings'
|
|
9
|
+
| 'flagSettings'
|
|
10
|
+
| 'policySettings'
|
|
11
|
+
|
|
12
|
+
export type AgentDefinition = {
|
|
13
|
+
agentType: string
|
|
14
|
+
description?: string
|
|
15
|
+
model?: string
|
|
16
|
+
modelDisplay?: string
|
|
17
|
+
tools?: string[]
|
|
18
|
+
systemPrompt?: string
|
|
19
|
+
color?: string
|
|
20
|
+
source: AgentSource
|
|
21
|
+
baseDir?: string
|
|
22
|
+
overriddenBy?: AgentSource
|
|
23
|
+
isActive: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type AgentListResponse = {
|
|
27
|
+
activeAgents: AgentDefinition[]
|
|
28
|
+
allAgents: AgentDefinition[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const agentsApi = {
|
|
32
|
+
list: (cwd?: string) => {
|
|
33
|
+
const query = cwd ? `?cwd=${encodeURIComponent(cwd)}` : ''
|
|
34
|
+
return api.get<AgentListResponse>(`/api/agents${query}`)
|
|
35
|
+
},
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
import type { CLITask, TaskListSummary } from '../types/cliTask'
|
|
3
|
+
|
|
4
|
+
type TaskListsResponse = { lists: TaskListSummary[] }
|
|
5
|
+
type TasksResponse = { tasks: CLITask[] }
|
|
6
|
+
type TaskResponse = { task: CLITask }
|
|
7
|
+
|
|
8
|
+
export const cliTasksApi = {
|
|
9
|
+
/** List all task lists with summaries */
|
|
10
|
+
listTaskLists() {
|
|
11
|
+
return api.get<TaskListsResponse>('/api/tasks/lists')
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/** Get all tasks for a specific task list */
|
|
15
|
+
getTasksForList(taskListId: string) {
|
|
16
|
+
return api.get<TasksResponse>(`/api/tasks/lists/${encodeURIComponent(taskListId)}`)
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
/** Get a single task */
|
|
20
|
+
getTask(taskListId: string, taskId: string) {
|
|
21
|
+
return api.get<TaskResponse>(`/api/tasks/lists/${encodeURIComponent(taskListId)}/${taskId}`)
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** List all tasks across all task lists */
|
|
25
|
+
listAll() {
|
|
26
|
+
return api.get<TasksResponse>('/api/tasks')
|
|
27
|
+
},
|
|
28
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const DEFAULT_BASE_URL = 'http://127.0.0.1:3456'
|
|
2
|
+
|
|
3
|
+
let baseUrl = DEFAULT_BASE_URL
|
|
4
|
+
|
|
5
|
+
export function setBaseUrl(url: string) {
|
|
6
|
+
baseUrl = url.replace(/\/$/, '')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getBaseUrl() {
|
|
10
|
+
return baseUrl
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getDefaultBaseUrl() {
|
|
14
|
+
return DEFAULT_BASE_URL
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class ApiError extends Error {
|
|
18
|
+
constructor(
|
|
19
|
+
public status: number,
|
|
20
|
+
public body: unknown,
|
|
21
|
+
) {
|
|
22
|
+
super(`API error ${status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`)
|
|
23
|
+
this.name = 'ApiError'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function request<T>(method: string, path: string, body?: unknown, options?: { timeout?: number }): Promise<T> {
|
|
28
|
+
const url = `${baseUrl}${path}`
|
|
29
|
+
const headers: Record<string, string> = {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const controller = new AbortController()
|
|
34
|
+
const timeout = setTimeout(() => controller.abort(), options?.timeout ?? 30_000)
|
|
35
|
+
try {
|
|
36
|
+
const res = await fetch(url, {
|
|
37
|
+
method,
|
|
38
|
+
headers,
|
|
39
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
40
|
+
signal: controller.signal,
|
|
41
|
+
})
|
|
42
|
+
clearTimeout(timeout)
|
|
43
|
+
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
const errorBody = await res.json().catch(() => res.text())
|
|
46
|
+
throw new ApiError(res.status, errorBody)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (res.status === 204) return undefined as T
|
|
50
|
+
return res.json() as Promise<T>
|
|
51
|
+
} catch (err) {
|
|
52
|
+
clearTimeout(timeout)
|
|
53
|
+
throw err
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const api = {
|
|
58
|
+
get: <T>(path: string, options?: { timeout?: number }) => request<T>('GET', path, undefined, options),
|
|
59
|
+
post: <T>(path: string, body?: unknown, options?: { timeout?: number }) => request<T>('POST', path, body, options),
|
|
60
|
+
put: <T>(path: string, body?: unknown) => request<T>('PUT', path, body),
|
|
61
|
+
patch: <T>(path: string, body?: unknown) => request<T>('PATCH', path, body),
|
|
62
|
+
delete: <T>(path: string) => request<T>('DELETE', path),
|
|
63
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
|
|
3
|
+
export type ComputerUseStatus = {
|
|
4
|
+
platform: string
|
|
5
|
+
supported: boolean
|
|
6
|
+
python: {
|
|
7
|
+
installed: boolean
|
|
8
|
+
version: string | null
|
|
9
|
+
path: string | null
|
|
10
|
+
}
|
|
11
|
+
venv: {
|
|
12
|
+
created: boolean
|
|
13
|
+
path: string
|
|
14
|
+
}
|
|
15
|
+
dependencies: {
|
|
16
|
+
installed: boolean
|
|
17
|
+
requirementsFound: boolean
|
|
18
|
+
}
|
|
19
|
+
permissions: {
|
|
20
|
+
accessibility: boolean | null
|
|
21
|
+
screenRecording: boolean | null
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SetupStep = {
|
|
26
|
+
name: string
|
|
27
|
+
ok: boolean
|
|
28
|
+
message: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SetupResult = {
|
|
32
|
+
success: boolean
|
|
33
|
+
steps: SetupStep[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InstalledApp = {
|
|
37
|
+
bundleId: string
|
|
38
|
+
displayName: string
|
|
39
|
+
path: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type AuthorizedApp = {
|
|
43
|
+
bundleId: string
|
|
44
|
+
displayName: string
|
|
45
|
+
authorizedAt: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ComputerUseConfig = {
|
|
49
|
+
authorizedApps: AuthorizedApp[]
|
|
50
|
+
grantFlags: {
|
|
51
|
+
clipboardRead: boolean
|
|
52
|
+
clipboardWrite: boolean
|
|
53
|
+
systemKeyCombos: boolean
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const computerUseApi = {
|
|
58
|
+
getStatus() {
|
|
59
|
+
return api.get<ComputerUseStatus>('/api/computer-use/status')
|
|
60
|
+
},
|
|
61
|
+
runSetup() {
|
|
62
|
+
return api.post<SetupResult>('/api/computer-use/setup', undefined, { timeout: 300_000 })
|
|
63
|
+
},
|
|
64
|
+
getInstalledApps() {
|
|
65
|
+
return api.get<{ apps: InstalledApp[] }>('/api/computer-use/apps')
|
|
66
|
+
},
|
|
67
|
+
getAuthorizedApps() {
|
|
68
|
+
return api.get<ComputerUseConfig>('/api/computer-use/authorized-apps')
|
|
69
|
+
},
|
|
70
|
+
setAuthorizedApps(config: Partial<ComputerUseConfig>) {
|
|
71
|
+
return api.put<{ ok: true }>('/api/computer-use/authorized-apps', config)
|
|
72
|
+
},
|
|
73
|
+
openSettings(pane: 'Privacy_ScreenCapture' | 'Privacy_Accessibility') {
|
|
74
|
+
return api.post<{ ok: true }>('/api/computer-use/open-settings', { pane })
|
|
75
|
+
},
|
|
76
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
|
|
3
|
+
type DirEntry = {
|
|
4
|
+
name: string
|
|
5
|
+
path: string
|
|
6
|
+
isDirectory: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type BrowseResult = {
|
|
10
|
+
currentPath: string
|
|
11
|
+
parentPath: string
|
|
12
|
+
entries: DirEntry[]
|
|
13
|
+
query?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const filesystemApi = {
|
|
17
|
+
browse(path?: string, options?: { includeFiles?: boolean }) {
|
|
18
|
+
const q = new URLSearchParams()
|
|
19
|
+
if (path) q.set('path', path)
|
|
20
|
+
if (options?.includeFiles) q.set('includeFiles', 'true')
|
|
21
|
+
const qs = q.toString()
|
|
22
|
+
return api.get<BrowseResult>(`/api/filesystem/browse${qs ? `?${qs}` : ''}`)
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
search(query: string, cwd?: string) {
|
|
26
|
+
const q = new URLSearchParams({ search: query, maxResults: '200' })
|
|
27
|
+
if (cwd) q.set('path', cwd)
|
|
28
|
+
return api.get<BrowseResult>(`/api/filesystem/browse?${q}`)
|
|
29
|
+
},
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// desktop/src/api/hahaOAuth.ts
|
|
2
|
+
|
|
3
|
+
import { api, getBaseUrl } from './client'
|
|
4
|
+
|
|
5
|
+
export type HahaOAuthStatus =
|
|
6
|
+
| { loggedIn: false }
|
|
7
|
+
| {
|
|
8
|
+
loggedIn: true
|
|
9
|
+
expiresAt: number | null
|
|
10
|
+
scopes: string[]
|
|
11
|
+
subscriptionType: 'pro' | 'max' | 'team' | 'enterprise' | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function currentServerPort(): number {
|
|
15
|
+
const port = new URL(getBaseUrl()).port
|
|
16
|
+
const parsed = Number.parseInt(port, 10)
|
|
17
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
18
|
+
throw new Error(`Cannot determine server port from baseUrl: ${getBaseUrl()}`)
|
|
19
|
+
}
|
|
20
|
+
return parsed
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const hahaOAuthApi = {
|
|
24
|
+
start() {
|
|
25
|
+
return api.post<{ authorizeUrl: string; state: string }>(
|
|
26
|
+
'/api/haha-oauth/start',
|
|
27
|
+
{ serverPort: currentServerPort() },
|
|
28
|
+
)
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
status() {
|
|
32
|
+
return api.get<HahaOAuthStatus>('/api/haha-oauth')
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
logout() {
|
|
36
|
+
return api.delete<{ ok: true }>('/api/haha-oauth')
|
|
37
|
+
},
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
import type { ModelInfo, EffortLevel } from '../types/settings'
|
|
3
|
+
|
|
4
|
+
type ModelsResponse = { models: ModelInfo[]; provider: { id: string; name: string } | null }
|
|
5
|
+
type CurrentModelResponse = { model: ModelInfo }
|
|
6
|
+
type EffortResponse = { level: EffortLevel; available: EffortLevel[] }
|
|
7
|
+
|
|
8
|
+
export const modelsApi = {
|
|
9
|
+
list() {
|
|
10
|
+
return api.get<ModelsResponse>('/api/models')
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
getCurrent() {
|
|
14
|
+
return api.get<CurrentModelResponse>('/api/models/current')
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
setCurrent(modelId: string) {
|
|
18
|
+
return api.put<{ ok: true; model: string }>('/api/models/current', { modelId })
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
getEffort() {
|
|
22
|
+
return api.get<EffortResponse>('/api/effort')
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
setEffort(level: EffortLevel) {
|
|
26
|
+
return api.put<{ ok: true; level: EffortLevel }>('/api/effort', { level })
|
|
27
|
+
},
|
|
28
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// desktop/src/api/providers.ts
|
|
2
|
+
|
|
3
|
+
import { api } from './client'
|
|
4
|
+
import type {
|
|
5
|
+
SavedProvider,
|
|
6
|
+
CreateProviderInput,
|
|
7
|
+
UpdateProviderInput,
|
|
8
|
+
TestProviderConfigInput,
|
|
9
|
+
ProviderTestResult,
|
|
10
|
+
} from '../types/provider'
|
|
11
|
+
import type { ProviderPreset } from '../config/providerPresets'
|
|
12
|
+
|
|
13
|
+
type ProvidersResponse = { providers: SavedProvider[]; activeId: string | null }
|
|
14
|
+
type ProviderResponse = { provider: SavedProvider }
|
|
15
|
+
type PresetsResponse = { presets: ProviderPreset[] }
|
|
16
|
+
type TestResultResponse = { result: ProviderTestResult }
|
|
17
|
+
type AuthStatusResponse = {
|
|
18
|
+
hasAuth: boolean
|
|
19
|
+
source: 'cc-haha-provider' | 'original-settings' | 'env' | 'none'
|
|
20
|
+
activeProvider?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const providersApi = {
|
|
24
|
+
list() {
|
|
25
|
+
return api.get<ProvidersResponse>('/api/providers')
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
presets() {
|
|
29
|
+
return api.get<PresetsResponse>('/api/providers/presets')
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
authStatus() {
|
|
33
|
+
return api.get<AuthStatusResponse>('/api/providers/auth-status')
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
create(input: CreateProviderInput) {
|
|
37
|
+
return api.post<ProviderResponse>('/api/providers', input)
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
update(id: string, input: UpdateProviderInput) {
|
|
41
|
+
return api.put<ProviderResponse>(`/api/providers/${id}`, input)
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
delete(id: string) {
|
|
45
|
+
return api.delete<{ ok: true }>(`/api/providers/${id}`)
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
activate(id: string) {
|
|
49
|
+
return api.post<{ ok: true }>(`/api/providers/${id}/activate`)
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
activateOfficial() {
|
|
53
|
+
return api.post<{ ok: true }>('/api/providers/official')
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
test(id: string, overrides?: { baseUrl?: string; modelId?: string; apiFormat?: string }) {
|
|
57
|
+
return api.post<TestResultResponse>(`/api/providers/${id}/test`, overrides)
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
testConfig(input: TestProviderConfigInput) {
|
|
61
|
+
return api.post<TestResultResponse>('/api/providers/test', input)
|
|
62
|
+
},
|
|
63
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
|
|
3
|
+
type SearchResult = {
|
|
4
|
+
file: string
|
|
5
|
+
line: number
|
|
6
|
+
text: string
|
|
7
|
+
context?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type SearchResponse = { results: SearchResult[]; total: number }
|
|
11
|
+
|
|
12
|
+
type SessionSearchResult = {
|
|
13
|
+
sessionId: string
|
|
14
|
+
title: string
|
|
15
|
+
matchCount: number
|
|
16
|
+
matches: Array<{ line: number; text: string }>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type SessionSearchResponse = { results: SessionSearchResult[] }
|
|
20
|
+
|
|
21
|
+
export const searchApi = {
|
|
22
|
+
search(params: { query: string; cwd?: string; maxResults?: number; glob?: string }) {
|
|
23
|
+
return api.post<SearchResponse>('/api/search', params)
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
searchSessions(query: string) {
|
|
27
|
+
return api.post<SessionSearchResponse>('/api/search/sessions', { query })
|
|
28
|
+
},
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
import type { SessionListItem, MessageEntry } from '../types/session'
|
|
3
|
+
|
|
4
|
+
type SessionsResponse = { sessions: SessionListItem[]; total: number }
|
|
5
|
+
type MessagesResponse = { messages: MessageEntry[] }
|
|
6
|
+
type CreateSessionResponse = { sessionId: string }
|
|
7
|
+
|
|
8
|
+
export type RecentProject = {
|
|
9
|
+
projectPath: string
|
|
10
|
+
realPath: string
|
|
11
|
+
projectName: string
|
|
12
|
+
isGit: boolean
|
|
13
|
+
repoName: string | null
|
|
14
|
+
branch: string | null
|
|
15
|
+
modifiedAt: string
|
|
16
|
+
sessionCount: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const sessionsApi = {
|
|
20
|
+
list(params?: { project?: string; limit?: number; offset?: number }) {
|
|
21
|
+
const query = new URLSearchParams()
|
|
22
|
+
if (params?.project) query.set('project', params.project)
|
|
23
|
+
if (params?.limit) query.set('limit', String(params.limit))
|
|
24
|
+
if (params?.offset) query.set('offset', String(params.offset))
|
|
25
|
+
const qs = query.toString()
|
|
26
|
+
return api.get<SessionsResponse>(`/api/sessions${qs ? `?${qs}` : ''}`)
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
getMessages(sessionId: string) {
|
|
30
|
+
return api.get<MessagesResponse>(`/api/sessions/${sessionId}/messages`)
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
create(workDir?: string) {
|
|
34
|
+
return api.post<CreateSessionResponse>('/api/sessions', workDir ? { workDir } : {})
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
delete(sessionId: string) {
|
|
38
|
+
return api.delete<{ ok: true }>(`/api/sessions/${sessionId}`)
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
rename(sessionId: string, title: string) {
|
|
42
|
+
return api.patch<{ ok: true }>(`/api/sessions/${sessionId}`, { title })
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
getRecentProjects() {
|
|
46
|
+
return api.get<{ projects: RecentProject[] }>('/api/sessions/recent-projects')
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
getGitInfo(sessionId: string) {
|
|
50
|
+
return api.get<{ branch: string | null; repoName: string | null; workDir: string; changedFiles: number }>(`/api/sessions/${sessionId}/git-info`)
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
getSlashCommands(sessionId: string) {
|
|
54
|
+
return api.get<{ commands: Array<{ name: string; description: string }> }>(`/api/sessions/${sessionId}/slash-commands`)
|
|
55
|
+
},
|
|
56
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { api } from './client'
|
|
2
|
+
import type { PermissionMode, UserSettings } from '../types/settings'
|
|
3
|
+
|
|
4
|
+
export const settingsApi = {
|
|
5
|
+
getUser() {
|
|
6
|
+
return api.get<UserSettings>('/api/settings/user')
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
updateUser(settings: Partial<UserSettings>) {
|
|
10
|
+
return api.put<{ ok: true }>('/api/settings/user', settings)
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
getPermissionMode() {
|
|
14
|
+
return api.get<{ mode: PermissionMode }>('/api/permissions/mode')
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
setPermissionMode(mode: PermissionMode) {
|
|
18
|
+
return api.put<{ ok: true; mode: PermissionMode }>('/api/permissions/mode', { mode })
|
|
19
|
+
},
|
|
20
|
+
}
|