@yuridulin/pointer 0.0.0-stage → 0.1.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 (71) hide show
  1. package/README.md +54 -2
  2. package/package.json +51 -4
  3. package/server/acp/catalog.ts +111 -0
  4. package/server/acp/connection.ts +233 -0
  5. package/server/acp/fake-agent.ts +408 -0
  6. package/server/acp/protocol.ts +167 -0
  7. package/server/acp/run.ts +139 -0
  8. package/server/acp/session.ts +1249 -0
  9. package/server/attachments.ts +115 -0
  10. package/server/changes.ts +239 -0
  11. package/server/cli.ts +362 -0
  12. package/server/compact.ts +361 -0
  13. package/server/config.ts +176 -0
  14. package/server/db.ts +462 -0
  15. package/server/dev.ts +8 -0
  16. package/server/diff.ts +190 -0
  17. package/server/engines.ts +63 -0
  18. package/server/files.ts +254 -0
  19. package/server/git.ts +319 -0
  20. package/server/history.ts +425 -0
  21. package/server/http/attachments.ts +63 -0
  22. package/server/http/browse.ts +108 -0
  23. package/server/http/chats.ts +627 -0
  24. package/server/http/closing.ts +14 -0
  25. package/server/http/files.ts +115 -0
  26. package/server/http/git.ts +84 -0
  27. package/server/http/preview.ts +21 -0
  28. package/server/http/providers.ts +200 -0
  29. package/server/http/reply.ts +38 -0
  30. package/server/hub.ts +521 -0
  31. package/server/install.ts +169 -0
  32. package/server/jobs.ts +664 -0
  33. package/server/linkPreview.ts +172 -0
  34. package/server/loop.ts +328 -0
  35. package/server/main.ts +353 -0
  36. package/server/probe.ts +34 -0
  37. package/server/process.ts +333 -0
  38. package/server/prompt.ts +196 -0
  39. package/server/providers/fake.ts +100 -0
  40. package/server/providers/opencode.ts +468 -0
  41. package/server/providers/registry.ts +149 -0
  42. package/server/providers/store.ts +210 -0
  43. package/server/segments.ts +248 -0
  44. package/server/sse.ts +93 -0
  45. package/server/tools/bash.ts +222 -0
  46. package/server/tools/edit.ts +254 -0
  47. package/server/tools/glob.ts +63 -0
  48. package/server/tools/grep.ts +122 -0
  49. package/server/tools/ignore.ts +54 -0
  50. package/server/tools/index.ts +129 -0
  51. package/server/tools/jail.ts +85 -0
  52. package/server/tools/jobs.ts +293 -0
  53. package/server/tools/read.ts +248 -0
  54. package/server/tools/write.ts +70 -0
  55. package/server/tray.ps1 +191 -0
  56. package/server/turn.ts +663 -0
  57. package/server/watch.ts +94 -0
  58. package/shared/acpConfig.ts +113 -0
  59. package/shared/links.ts +122 -0
  60. package/shared/types.ts +392 -0
  61. package/web/dist/app.css +1 -0
  62. package/web/dist/assets/codicon-mxdk0fnd.ttf +0 -0
  63. package/web/dist/index.html +28 -0
  64. package/web/dist/main.css +1 -0
  65. package/web/dist/main.js +1366 -0
  66. package/web/dist/tokens.css +1 -0
  67. package/web/dist/workers/css.worker.js +97 -0
  68. package/web/dist/workers/editor.worker.js +30 -0
  69. package/web/dist/workers/html.worker.js +300 -0
  70. package/web/dist/workers/json.worker.js +62 -0
  71. package/web/dist/workers/ts.worker.js +67733 -0
@@ -0,0 +1,94 @@
1
+ import { watch, type FSWatcher } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import { isIgnoredDir } from './tools/ignore'
4
+
5
+ const DEFAULT_DELAY_MS = 80
6
+
7
+ export type WorkspaceWatch = {
8
+ add(id: string, root: string): void
9
+ remove(id: string): void
10
+ sync(rows: ReadonlyArray<{ id: string; root_path: string }>): void
11
+ close(): void
12
+ }
13
+
14
+ type Entry = { root: string; close: () => void }
15
+
16
+ /**
17
+ * Watches workspace folders so edits made outside the daemon (another editor, a terminal)
18
+ * reach the panels. App-driven writes announce themselves; this covers the rest, and a burst
19
+ * of changes collapses into one callback per workspace.
20
+ */
21
+ export function createWorkspaceWatch(
22
+ onChange: (workspaceId: string) => void,
23
+ options?: { delayMs?: number },
24
+ ): WorkspaceWatch {
25
+ const delay = options?.delayMs ?? DEFAULT_DELAY_MS
26
+ const entries = new Map<string, Entry>()
27
+
28
+ function add(id: string, root: string): void {
29
+ const base = resolve(root)
30
+ const current = entries.get(id)
31
+ if (current !== undefined) {
32
+ if (current.root === base) return
33
+ current.close()
34
+ entries.delete(id)
35
+ }
36
+ const state: { closed: boolean; timer: ReturnType<typeof setTimeout> | undefined } = {
37
+ closed: false,
38
+ timer: undefined,
39
+ }
40
+ let watcher: FSWatcher
41
+ try {
42
+ watcher = watch(base, { recursive: true }, (_event, filename) => {
43
+ if (state.closed) return
44
+ // Ignored folders never reach the tree or git status, so their churn refreshes nothing.
45
+ if (filename !== null && String(filename).split(/[\\/]/).some(isIgnoredDir)) return
46
+ clearTimeout(state.timer)
47
+ state.timer = setTimeout(() => {
48
+ state.timer = undefined
49
+ if (!state.closed) onChange(id)
50
+ }, delay)
51
+ })
52
+ } catch {
53
+ // The folder may be gone or unreadable; a missing watch must not take the daemon down.
54
+ return
55
+ }
56
+ watcher.on('error', () => {})
57
+ entries.set(id, {
58
+ root: base,
59
+ close: () => {
60
+ state.closed = true
61
+ clearTimeout(state.timer)
62
+ watcher.close()
63
+ },
64
+ })
65
+ }
66
+
67
+ function remove(id: string): void {
68
+ const entry = entries.get(id)
69
+ if (entry === undefined) return
70
+ entry.close()
71
+ entries.delete(id)
72
+ }
73
+
74
+ function sync(rows: ReadonlyArray<{ id: string; root_path: string }>): void {
75
+ const seen = new Set<string>()
76
+ for (const row of rows) {
77
+ seen.add(row.id)
78
+ add(row.id, row.root_path)
79
+ }
80
+ for (const id of [...entries.keys()]) {
81
+ if (!seen.has(id)) remove(id)
82
+ }
83
+ }
84
+
85
+ return {
86
+ add,
87
+ remove,
88
+ sync,
89
+ close() {
90
+ for (const entry of entries.values()) entry.close()
91
+ entries.clear()
92
+ },
93
+ }
94
+ }
@@ -0,0 +1,113 @@
1
+ export type AcpConfigChoice = { value: string; name: string }
2
+
3
+ export type AcpConfigGroup = { name: string; options: AcpConfigChoice[] }
4
+
5
+ export type AcpConfigOption = {
6
+ configId: string
7
+ name: string
8
+ category?: string
9
+ type: 'select' | 'boolean'
10
+ currentValue: string | boolean
11
+ options?: Array<AcpConfigChoice | AcpConfigGroup>
12
+ }
13
+
14
+ export function parseAcpConfigOptions(value: unknown): AcpConfigOption[] {
15
+ const list = configList(value)
16
+ if (!list) return []
17
+ const options: AcpConfigOption[] = []
18
+ for (const item of list) {
19
+ const parsed = parseOption(item)
20
+ if (parsed) options.push(parsed)
21
+ }
22
+ return options
23
+ }
24
+
25
+ export function configValueAllowed(option: AcpConfigOption, value: string | boolean): boolean {
26
+ if (option.type === 'boolean') return typeof value === 'boolean'
27
+ if (typeof value !== 'string') return false
28
+ return choiceValues(option).includes(value)
29
+ }
30
+
31
+ export function choiceValues(option: AcpConfigOption): string[] {
32
+ const values: string[] = []
33
+ for (const item of option.options ?? []) {
34
+ if ('value' in item) values.push(item.value)
35
+ else for (const choice of item.options) values.push(choice.value)
36
+ }
37
+ return values
38
+ }
39
+
40
+ function configList(value: unknown): unknown[] | null {
41
+ if (Array.isArray(value)) return value
42
+ if (!isRecord(value)) return null
43
+ if (Array.isArray(value.configOptions)) return value.configOptions
44
+ if (Array.isArray(value.options)) return value.options
45
+ return null
46
+ }
47
+
48
+ function parseOption(value: unknown): AcpConfigOption | null {
49
+ if (!isRecord(value)) return null
50
+ const configId = text(value.configId) ?? text(value.id)
51
+ const name = text(value.name)
52
+ if (!configId || !name) return null
53
+ const category = text(value.category)
54
+ if (value.type === 'boolean') {
55
+ if (typeof value.currentValue !== 'boolean') return null
56
+ return { configId, name, ...(category ? { category } : {}), type: 'boolean', currentValue: value.currentValue }
57
+ }
58
+ if (value.type !== 'select' || typeof value.currentValue !== 'string' || value.currentValue === '') return null
59
+ const options = parseEntries(value.options)
60
+ if (!options) return null
61
+ return {
62
+ configId,
63
+ name,
64
+ ...(category ? { category } : {}),
65
+ type: 'select',
66
+ currentValue: value.currentValue,
67
+ options,
68
+ }
69
+ }
70
+
71
+ function parseEntries(value: unknown): Array<AcpConfigChoice | AcpConfigGroup> | null {
72
+ if (!Array.isArray(value)) return null
73
+ const entries: Array<AcpConfigChoice | AcpConfigGroup> = []
74
+ for (const item of value) {
75
+ const choice = parseChoice(item)
76
+ if (choice) {
77
+ entries.push(choice)
78
+ continue
79
+ }
80
+ const group = parseGroup(item)
81
+ if (group) entries.push(group)
82
+ }
83
+ return entries.length > 0 ? entries : null
84
+ }
85
+
86
+ function parseGroup(value: unknown): AcpConfigGroup | null {
87
+ if (!isRecord(value) || 'value' in value) return null
88
+ const name = text(value.name)
89
+ if (!name || !Array.isArray(value.options)) return null
90
+ const options: AcpConfigChoice[] = []
91
+ for (const item of value.options) {
92
+ const choice = parseChoice(item)
93
+ if (choice) options.push(choice)
94
+ }
95
+ if (options.length === 0) return null
96
+ return { name, options }
97
+ }
98
+
99
+ function parseChoice(value: unknown): AcpConfigChoice | null {
100
+ if (!isRecord(value)) return null
101
+ const id = text(value.value)
102
+ const name = text(value.name)
103
+ if (!id || !name) return null
104
+ return { value: id, name }
105
+ }
106
+
107
+ function text(value: unknown): string | null {
108
+ return typeof value === 'string' && value.trim() !== '' ? value : null
109
+ }
110
+
111
+ function isRecord(value: unknown): value is Record<string, unknown> {
112
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
113
+ }
@@ -0,0 +1,122 @@
1
+ /** The drag payload used by pointer's own file tree and Git view. */
2
+ export const POINTER_PATH_MIME = 'application/x-pointer-path'
3
+
4
+ export const IMAGE_EXTENSIONS: Record<string, true> = {
5
+ png: true,
6
+ jpg: true,
7
+ jpeg: true,
8
+ gif: true,
9
+ webp: true,
10
+ bmp: true,
11
+ ico: true,
12
+ svg: true,
13
+ avif: true,
14
+ }
15
+
16
+ /** A link preview as the daemon returns it; `title` falls back to the hostname. */
17
+ export type LinkPreview = {
18
+ url: string
19
+ title: string
20
+ description: string
21
+ image: string | null
22
+ icon: string | null
23
+ site: string
24
+ }
25
+
26
+ const IMAGE_MIME: Record<string, string> = {
27
+ png: 'image/png',
28
+ jpg: 'image/jpeg',
29
+ jpeg: 'image/jpeg',
30
+ gif: 'image/gif',
31
+ webp: 'image/webp',
32
+ bmp: 'image/bmp',
33
+ ico: 'image/x-icon',
34
+ svg: 'image/svg+xml',
35
+ avif: 'image/avif',
36
+ }
37
+
38
+ function pathPart(value: string): string {
39
+ const cut = value.search(/[?#]/)
40
+ return cut < 0 ? value : value.slice(0, cut)
41
+ }
42
+
43
+ function extensionOf(value: string): string {
44
+ const clean = pathPart(value).replaceAll('\\', '/')
45
+ const slash = clean.lastIndexOf('/')
46
+ const name = slash < 0 ? clean : clean.slice(slash + 1)
47
+ const dot = name.lastIndexOf('.')
48
+ return dot > 0 ? name.slice(dot + 1).toLowerCase() : ''
49
+ }
50
+
51
+ export function imageMime(path: string): string | null {
52
+ return IMAGE_MIME[extensionOf(path)] ?? null
53
+ }
54
+
55
+ export function isImageFile(path: string): boolean {
56
+ return IMAGE_EXTENSIONS[extensionOf(path)] === true
57
+ }
58
+
59
+ export function isImageUrl(url: string): boolean {
60
+ let parsed: URL
61
+ try {
62
+ parsed = new URL(url)
63
+ } catch {
64
+ return false
65
+ }
66
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false
67
+ return isImageFile(parsed.pathname)
68
+ }
69
+
70
+ export function isAbsoluteFilePath(path: string): boolean {
71
+ const value = path.trim()
72
+ return (
73
+ /^[a-zA-Z]:[\\/]/.test(value) ||
74
+ value.startsWith('\\\\') ||
75
+ value.startsWith('//') ||
76
+ value.startsWith('/') ||
77
+ /^file:/i.test(value)
78
+ )
79
+ }
80
+
81
+ function encodeFilePart(path: string): string {
82
+ return path.replace(/[%#?<>]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`)
83
+ }
84
+
85
+ /** `D:\A B\x.png` -> `file:///D:/A B/x.png`; spaces stay readable in the transcript. */
86
+ export function pathToFileUrl(path: string): string {
87
+ const value = path.trim()
88
+ if (/^file:/i.test(value)) return value
89
+ const normalized = value.replaceAll('\\', '/')
90
+ if (normalized.startsWith('//')) return `file://${encodeFilePart(normalized)}`
91
+ return `file:///${encodeFilePart(normalized.replace(/^\/+/, ''))}`
92
+ }
93
+
94
+ /** The inverse of `pathToFileUrl`, tolerant of `file://server/share` as well. */
95
+ export function fileUrlToPath(url: string): string {
96
+ let value = url.trim()
97
+ if (!/^file:/i.test(value)) return value
98
+ value = value.replace(/^file:\/\//i, '')
99
+ if (value.startsWith('/')) {
100
+ if (/^\/[a-zA-Z]:/.test(value)) value = value.slice(1)
101
+ } else {
102
+ value = `//${value}`
103
+ }
104
+ try {
105
+ return decodeURIComponent(value)
106
+ } catch {
107
+ return value
108
+ }
109
+ }
110
+
111
+ /** Relative path when `path` is inside `rootPath`; the drive letter is case-insensitive. */
112
+ export function pathToWorkspaceRelative(path: string, rootPath: string): string {
113
+ const target = path.trim().replaceAll('\\', '/')
114
+ const root = rootPath.trim().replaceAll('\\', '/').replace(/\/+$/, '')
115
+ if (root === '') return target
116
+ const folded = /^[a-zA-Z]:\//.test(root) || root.startsWith('//')
117
+ const left = folded ? target.toLowerCase() : target
118
+ const right = folded ? root.toLowerCase() : root
119
+ if (left === right) return ''
120
+ if (!left.startsWith(`${right}/`)) return target
121
+ return target.slice(root.length + 1)
122
+ }
@@ -0,0 +1,392 @@
1
+ export type StopReason = 'end' | 'tool_use' | 'max_tokens' | 'aborted' | 'error'
2
+
3
+ export type Usage = {
4
+ input: number
5
+ output: number
6
+ cacheRead?: number
7
+ }
8
+
9
+ export type TextBlock = { type: 'text'; text: string }
10
+
11
+ export type ThinkingBlock = { type: 'thinking'; text: string; opaque?: unknown }
12
+
13
+ /**
14
+ * A call the model emitted but that must not run: arguments were cut off by the output
15
+ * limit or could not be parsed. `error` is the text the model gets instead of a result,
16
+ * so a broken call is reported rather than silently dropped.
17
+ */
18
+ export type ToolCallBlock = { type: 'tool_call'; id: string; name: string; args: unknown; error?: string }
19
+
20
+ export type Block = TextBlock | ThinkingBlock | ToolCallBlock
21
+
22
+ export type UserMessage = { role: 'user'; content: { text: string; compacted?: boolean } }
23
+
24
+ export type AssistantMessage = {
25
+ role: 'assistant'
26
+ content: {
27
+ blocks: Block[]
28
+ stopReason: StopReason
29
+ usage?: Usage
30
+ model?: string
31
+ servedCheckpoint?: string
32
+ }
33
+ }
34
+
35
+ export type ToolMessage = {
36
+ role: 'tool'
37
+ content: { toolCallId: string; text: string; isError: boolean }
38
+ }
39
+
40
+ export type ModelMessage = UserMessage | AssistantMessage | ToolMessage
41
+
42
+ export type ToolDef = {
43
+ name: string
44
+ description: string
45
+ parameters: Record<string, unknown>
46
+ }
47
+
48
+ export type StreamEvent =
49
+ | { type: 'text_delta'; text: string }
50
+ | { type: 'thinking_delta'; text: string }
51
+ | { type: 'tool_call_started'; id: string; name: string }
52
+ | {
53
+ type: 'done'
54
+ blocks: Block[]
55
+ stopReason: StopReason
56
+ usage: Usage
57
+ error?: string
58
+ servedCheckpoint?: string
59
+ }
60
+
61
+ /** Levels the OpenCode Go chat endpoint accepts as `reasoning_effort` for the default model. */
62
+ export type ReasoningLevel = 'low' | 'high' | 'max'
63
+
64
+ export type StreamLLMInput = {
65
+ model: string
66
+ system?: string
67
+ messages: ModelMessage[]
68
+ tools?: ToolDef[]
69
+ signal?: AbortSignal
70
+ sessionId?: string
71
+ reasoning?: ReasoningLevel
72
+ }
73
+
74
+ export type MessageRole = 'user' | 'assistant' | 'tool' | 'notice'
75
+
76
+ export type RunStatus = 'idle' | 'running' | 'error'
77
+
78
+ export type JobStatus = 'running' | 'finished' | 'killed'
79
+
80
+ /** A background bash task. The output itself lives in the ring and on disk, not in this record. */
81
+ export type JobInfo = {
82
+ id: string
83
+ chatId: string
84
+ command: string
85
+ status: JobStatus
86
+ exitCode: number | null
87
+ outputSize: number
88
+ startedAt: number
89
+ finishedAt: number | null
90
+ /** Full log on disk once the output crossed the ring threshold. */
91
+ logPath: string | null
92
+ }
93
+
94
+ export type JobOutput = JobInfo & {
95
+ requestedOffset: number
96
+ /** Actual start of `text`; larger than requested when the ring already dropped that part. */
97
+ offset: number
98
+ /** Position to pass to the next read. */
99
+ nextOffset: number
100
+ text: string
101
+ /** The requested offset is gone from the ring; `logPath` holds the start. */
102
+ clipped: boolean
103
+ /** `text` is the tail of the available range. */
104
+ truncated: boolean
105
+ }
106
+
107
+ export type ToolOutputState = { callId: string; output: string }
108
+
109
+ export type StartedToolCall = { callId: string; name: string }
110
+
111
+ export type Inflight = {
112
+ text: string
113
+ thinking: string
114
+ tool?: ToolOutputState
115
+ startedCalls?: StartedToolCall[]
116
+ runningCallId?: string
117
+ }
118
+
119
+ export type SnapshotMessage = {
120
+ id: string
121
+ seq: number
122
+ role: MessageRole
123
+ content: unknown
124
+ details?: unknown
125
+ createdAt: number
126
+ }
127
+
128
+ export type EngineInfo = { id: string; label: string; kind: 'native' | 'acp'; available: boolean }
129
+
130
+ export type ProviderKind = 'opencode-go' | 'openai' | 'acp'
131
+
132
+ /** A configured connection. `hasKey` is the only trace of the secret: the key itself stays in the database. */
133
+ export type ProviderInfo = {
134
+ id: string
135
+ kind: ProviderKind
136
+ label: string
137
+ baseUrl: string | null
138
+ hasKey: boolean
139
+ command: string | null
140
+ args: string[] | null
141
+ cwd: string | null
142
+ /** ACP: the command was found. HTTP providers leave this null. */
143
+ available: boolean | null
144
+ models: string[]
145
+ fallbackBaseUrl: string | null
146
+ fallbackCommand: string | null
147
+ /** Off hides the slot from the model menu and the engine switch. */
148
+ enabled: boolean
149
+ }
150
+
151
+ export type ProviderCatalog = {
152
+ providers: ProviderInfo[]
153
+ defaultModel: string | null
154
+ }
155
+
156
+ export type AcpQuestionOption = { id: string; label: string }
157
+
158
+ export type AcpQuestionItem = {
159
+ id: string
160
+ prompt: string
161
+ options: AcpQuestionOption[]
162
+ allowMultiple?: boolean
163
+ }
164
+
165
+ export type AcpQuestion =
166
+ | {
167
+ kind: 'questions'
168
+ id: string
169
+ title: string
170
+ questions: AcpQuestionItem[]
171
+ }
172
+ | {
173
+ kind: 'plan'
174
+ id: string
175
+ title: string
176
+ overview?: string
177
+ plan: string
178
+ todos?: Array<{
179
+ id: string
180
+ content: string
181
+ status: 'pending' | 'in_progress' | 'completed' | 'cancelled'
182
+ }>
183
+ isProject?: boolean
184
+ }
185
+
186
+ export type AcpAnswer =
187
+ | { answers: Array<{ questionId: string; selectedOptionIds: string[] }> }
188
+ | { skipped: true }
189
+ | { accepted: boolean; reason?: string }
190
+
191
+ export type ChatSnapshot = {
192
+ type: 'chat.snapshot'
193
+ chatId: string
194
+ runId: string | null
195
+ rev: number
196
+ messages: SnapshotMessage[]
197
+ inflight: Inflight | null
198
+ status: RunStatus
199
+ queue: string[]
200
+ question: AcpQuestion | null
201
+ jobs: JobInfo[]
202
+ }
203
+
204
+ export type AssistantDelta = {
205
+ type: 'assistant.delta'
206
+ chatId: string
207
+ runId: string
208
+ rev: number
209
+ text?: string
210
+ thinking?: string
211
+ }
212
+
213
+ export type ToolStarted = {
214
+ type: 'tool.started'
215
+ chatId: string
216
+ runId: string
217
+ rev: number
218
+ callId: string
219
+ name: string
220
+ }
221
+
222
+ export type ToolRunning = {
223
+ type: 'tool.running'
224
+ chatId: string
225
+ runId: string
226
+ rev: number
227
+ callId: string
228
+ args: unknown
229
+ }
230
+
231
+ export type ToolOutput = {
232
+ type: 'tool.output'
233
+ chatId: string
234
+ runId: string
235
+ rev: number
236
+ callId: string
237
+ chunk: string
238
+ }
239
+
240
+ export type MessageAppended = {
241
+ type: 'message.appended'
242
+ chatId: string
243
+ runId: string | null
244
+ rev: number
245
+ message: SnapshotMessage
246
+ }
247
+
248
+ export type RunStatusEvent = {
249
+ type: 'run.status'
250
+ chatId: string
251
+ runId: string | null
252
+ rev: number
253
+ status: RunStatus
254
+ }
255
+
256
+ export type RunRetry = {
257
+ type: 'run.retry'
258
+ chatId: string
259
+ runId: string
260
+ rev: number
261
+ attempt: number
262
+ }
263
+
264
+ export type QueueUpdated = {
265
+ type: 'queue.updated'
266
+ chatId: string
267
+ runId: string | null
268
+ rev: number
269
+ queue: string[]
270
+ }
271
+
272
+ export type RunQuestionEvent = {
273
+ type: 'run.question'
274
+ chatId: string
275
+ runId: string
276
+ rev: number
277
+ question: AcpQuestion | null
278
+ }
279
+
280
+ export type JobStarted = {
281
+ type: 'job.started'
282
+ chatId: string
283
+ job: JobInfo
284
+ }
285
+
286
+ export type JobOutputEvent = {
287
+ type: 'job.output'
288
+ chatId: string
289
+ jobId: string
290
+ /** Absolute character offset of this chunk in the job output. */
291
+ offset: number
292
+ chunk: string
293
+ }
294
+
295
+ export type JobFinished = {
296
+ type: 'job.finished'
297
+ chatId: string
298
+ job: JobInfo
299
+ }
300
+
301
+ export type ChatUpserted = {
302
+ type: 'chat.upserted'
303
+ chatId: string
304
+ title: string
305
+ status: RunStatus
306
+ workspaceId: string
307
+ model?: string
308
+ engine?: string
309
+ updatedAt?: number
310
+ /** Есть, когда событие несёт состояние архива; отсутствие значит «не менялось». */
311
+ archivedAt?: number | null
312
+ /** Есть, когда событие несёт уровень. `null` сбрасывает выбор чата к умолчанию провайдера. */
313
+ reasoning?: ReasoningLevel | null
314
+ }
315
+
316
+ export type WorkspaceUpserted = {
317
+ type: 'workspace.upserted'
318
+ id: string
319
+ name: string
320
+ rootPath: string
321
+ createdAt: number
322
+ lastOpenedAt: number
323
+ }
324
+
325
+ export type ChatDeleted = {
326
+ type: 'chat.deleted'
327
+ chatId: string
328
+ }
329
+
330
+ export type WorkspaceDeleted = {
331
+ type: 'workspace.deleted'
332
+ id: string
333
+ }
334
+
335
+ export type WorkspaceFocus = {
336
+ type: 'workspace.focus'
337
+ id: string
338
+ }
339
+
340
+ export type FileNode = {
341
+ name: string
342
+ path: string
343
+ type: 'file' | 'dir'
344
+ children?: FileNode[]
345
+ }
346
+
347
+ export type FileText = { content: string; hash: string }
348
+
349
+ export type BrowseEntry = { name: string; path: string }
350
+
351
+ export type BrowseResult = { path: string; parent: string | null; dirs: BrowseEntry[] }
352
+
353
+ export type GitChange = {
354
+ path: string
355
+ index: string
356
+ worktree: string
357
+ kind: 'changed' | 'renamed' | 'unmerged' | 'untracked'
358
+ origPath?: string
359
+ }
360
+
361
+ export type GitStatus = { repo: boolean; branch: string | null; changes: GitChange[] }
362
+
363
+ export type GitBranch = { name: string; current: boolean }
364
+
365
+ export type FileChanged = {
366
+ type: 'file.changed'
367
+ workspaceId: string
368
+ /** `null` means the changed files are unknown (a finished bash, an ACP turn). */
369
+ path: string | null
370
+ hash: string | null
371
+ }
372
+
373
+ export type ServerEvent =
374
+ | FileChanged
375
+ | ChatSnapshot
376
+ | AssistantDelta
377
+ | ToolStarted
378
+ | ToolRunning
379
+ | ToolOutput
380
+ | MessageAppended
381
+ | RunStatusEvent
382
+ | RunRetry
383
+ | QueueUpdated
384
+ | RunQuestionEvent
385
+ | JobStarted
386
+ | JobOutputEvent
387
+ | JobFinished
388
+ | ChatUpserted
389
+ | WorkspaceUpserted
390
+ | WorkspaceDeleted
391
+ | WorkspaceFocus
392
+ | ChatDeleted