@ccpocket-base-auth/bridge 1.26.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.
- package/README.md +67 -0
- package/dist/archive-store.d.ts +28 -0
- package/dist/archive-store.js +68 -0
- package/dist/archive-store.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex-process.d.ts +171 -0
- package/dist/codex-process.js +1928 -0
- package/dist/codex-process.js.map +1 -0
- package/dist/debug-trace-store.d.ts +15 -0
- package/dist/debug-trace-store.js +78 -0
- package/dist/debug-trace-store.js.map +1 -0
- package/dist/doctor.d.ts +58 -0
- package/dist/doctor.js +663 -0
- package/dist/doctor.js.map +1 -0
- package/dist/firebase-auth.d.ts +35 -0
- package/dist/firebase-auth.js +132 -0
- package/dist/firebase-auth.js.map +1 -0
- package/dist/gallery-store.d.ts +67 -0
- package/dist/gallery-store.js +333 -0
- package/dist/gallery-store.js.map +1 -0
- package/dist/image-store.d.ts +23 -0
- package/dist/image-store.js +142 -0
- package/dist/image-store.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +191 -0
- package/dist/index.js.map +1 -0
- package/dist/mdns.d.ts +7 -0
- package/dist/mdns.js +49 -0
- package/dist/mdns.js.map +1 -0
- package/dist/parser.d.ts +465 -0
- package/dist/parser.js +251 -0
- package/dist/parser.js.map +1 -0
- package/dist/project-history.d.ts +10 -0
- package/dist/project-history.js +73 -0
- package/dist/project-history.js.map +1 -0
- package/dist/prompt-history-backup.d.ts +15 -0
- package/dist/prompt-history-backup.js +46 -0
- package/dist/prompt-history-backup.js.map +1 -0
- package/dist/proxy.d.ts +15 -0
- package/dist/proxy.js +95 -0
- package/dist/proxy.js.map +1 -0
- package/dist/push-i18n.d.ts +7 -0
- package/dist/push-i18n.js +75 -0
- package/dist/push-i18n.js.map +1 -0
- package/dist/push-relay.d.ts +29 -0
- package/dist/push-relay.js +70 -0
- package/dist/push-relay.js.map +1 -0
- package/dist/recording-store.d.ts +51 -0
- package/dist/recording-store.js +158 -0
- package/dist/recording-store.js.map +1 -0
- package/dist/screenshot.d.ts +28 -0
- package/dist/screenshot.js +98 -0
- package/dist/screenshot.js.map +1 -0
- package/dist/sdk-process.d.ts +180 -0
- package/dist/sdk-process.js +937 -0
- package/dist/sdk-process.js.map +1 -0
- package/dist/session.d.ts +142 -0
- package/dist/session.js +615 -0
- package/dist/session.js.map +1 -0
- package/dist/sessions-index.d.ts +128 -0
- package/dist/sessions-index.js +1767 -0
- package/dist/sessions-index.js.map +1 -0
- package/dist/setup-launchd.d.ts +8 -0
- package/dist/setup-launchd.js +109 -0
- package/dist/setup-launchd.js.map +1 -0
- package/dist/setup-systemd.d.ts +8 -0
- package/dist/setup-systemd.js +118 -0
- package/dist/setup-systemd.js.map +1 -0
- package/dist/startup-info.d.ts +8 -0
- package/dist/startup-info.js +92 -0
- package/dist/startup-info.js.map +1 -0
- package/dist/usage.d.ts +69 -0
- package/dist/usage.js +545 -0
- package/dist/usage.js.map +1 -0
- package/dist/version.d.ts +13 -0
- package/dist/version.js +43 -0
- package/dist/version.js.map +1 -0
- package/dist/websocket.d.ts +127 -0
- package/dist/websocket.js +2482 -0
- package/dist/websocket.js.map +1 -0
- package/dist/worktree-store.d.ts +25 -0
- package/dist/worktree-store.js +59 -0
- package/dist/worktree-store.js.map +1 -0
- package/dist/worktree.d.ts +47 -0
- package/dist/worktree.js +313 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +68 -0
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import type { GalleryImageInfo } from "./gallery-store.js";
|
|
2
|
+
import type { ImageRef } from "./image-store.js";
|
|
3
|
+
import type { WindowInfo } from "./screenshot.js";
|
|
4
|
+
import type { WorktreeInfo } from "./worktree.js";
|
|
5
|
+
export type { ImageRef } from "./image-store.js";
|
|
6
|
+
export interface AssistantTextContent {
|
|
7
|
+
type: "text";
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AssistantToolUseContent {
|
|
11
|
+
type: "tool_use";
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
input: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface AssistantThinkingContent {
|
|
17
|
+
type: "thinking";
|
|
18
|
+
thinking: string;
|
|
19
|
+
}
|
|
20
|
+
export type AssistantContent = AssistantTextContent | AssistantToolUseContent | AssistantThinkingContent;
|
|
21
|
+
/** Shape of the assistant message object within ServerMessage. */
|
|
22
|
+
export interface AssistantMessage {
|
|
23
|
+
id: string;
|
|
24
|
+
role: "assistant";
|
|
25
|
+
content: AssistantContent[];
|
|
26
|
+
model: string;
|
|
27
|
+
}
|
|
28
|
+
export type PermissionMode = "default" | "acceptEdits" | "bypassPermissions" | "plan";
|
|
29
|
+
export type Provider = "claude" | "codex";
|
|
30
|
+
export type ClientMessage = {
|
|
31
|
+
type: "start";
|
|
32
|
+
projectPath: string;
|
|
33
|
+
provider?: Provider;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
continue?: boolean;
|
|
36
|
+
permissionMode?: PermissionMode;
|
|
37
|
+
sandboxMode?: string;
|
|
38
|
+
model?: string;
|
|
39
|
+
effort?: "low" | "medium" | "high" | "max";
|
|
40
|
+
maxTurns?: number;
|
|
41
|
+
maxBudgetUsd?: number;
|
|
42
|
+
fallbackModel?: string;
|
|
43
|
+
forkSession?: boolean;
|
|
44
|
+
persistSession?: boolean;
|
|
45
|
+
modelReasoningEffort?: string;
|
|
46
|
+
networkAccessEnabled?: boolean;
|
|
47
|
+
webSearchMode?: string;
|
|
48
|
+
useWorktree?: boolean;
|
|
49
|
+
worktreeBranch?: string;
|
|
50
|
+
existingWorktreePath?: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: "input";
|
|
53
|
+
text: string;
|
|
54
|
+
sessionId?: string;
|
|
55
|
+
images?: Array<{
|
|
56
|
+
base64: string;
|
|
57
|
+
mimeType: string;
|
|
58
|
+
}>;
|
|
59
|
+
imageId?: string;
|
|
60
|
+
imageBase64?: string;
|
|
61
|
+
mimeType?: string;
|
|
62
|
+
skill?: {
|
|
63
|
+
name: string;
|
|
64
|
+
path: string;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
type: "push_register";
|
|
68
|
+
token: string;
|
|
69
|
+
platform: "ios" | "android" | "web";
|
|
70
|
+
locale?: string;
|
|
71
|
+
privacyMode?: boolean;
|
|
72
|
+
} | {
|
|
73
|
+
type: "push_unregister";
|
|
74
|
+
token: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: "set_permission_mode";
|
|
77
|
+
mode: PermissionMode;
|
|
78
|
+
sessionId?: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: "set_sandbox_mode";
|
|
81
|
+
sandboxMode: string;
|
|
82
|
+
sessionId?: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: "approve";
|
|
85
|
+
id: string;
|
|
86
|
+
updatedInput?: Record<string, unknown>;
|
|
87
|
+
clearContext?: boolean;
|
|
88
|
+
sessionId?: string;
|
|
89
|
+
} | {
|
|
90
|
+
type: "approve_always";
|
|
91
|
+
id: string;
|
|
92
|
+
sessionId?: string;
|
|
93
|
+
} | {
|
|
94
|
+
type: "reject";
|
|
95
|
+
id: string;
|
|
96
|
+
message?: string;
|
|
97
|
+
sessionId?: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: "answer";
|
|
100
|
+
toolUseId: string;
|
|
101
|
+
result: string;
|
|
102
|
+
sessionId?: string;
|
|
103
|
+
} | {
|
|
104
|
+
type: "list_sessions";
|
|
105
|
+
} | {
|
|
106
|
+
type: "stop_session";
|
|
107
|
+
sessionId: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: "rename_session";
|
|
110
|
+
sessionId: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
provider?: string;
|
|
113
|
+
providerSessionId?: string;
|
|
114
|
+
projectPath?: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: "get_history";
|
|
117
|
+
sessionId: string;
|
|
118
|
+
} | {
|
|
119
|
+
type: "list_recent_sessions";
|
|
120
|
+
limit?: number;
|
|
121
|
+
offset?: number;
|
|
122
|
+
projectPath?: string;
|
|
123
|
+
provider?: "claude" | "codex";
|
|
124
|
+
namedOnly?: boolean;
|
|
125
|
+
searchQuery?: string;
|
|
126
|
+
} | {
|
|
127
|
+
type: "resume_session";
|
|
128
|
+
sessionId: string;
|
|
129
|
+
projectPath: string;
|
|
130
|
+
permissionMode?: PermissionMode;
|
|
131
|
+
provider?: Provider;
|
|
132
|
+
sandboxMode?: string;
|
|
133
|
+
model?: string;
|
|
134
|
+
effort?: "low" | "medium" | "high" | "max";
|
|
135
|
+
maxTurns?: number;
|
|
136
|
+
maxBudgetUsd?: number;
|
|
137
|
+
fallbackModel?: string;
|
|
138
|
+
forkSession?: boolean;
|
|
139
|
+
persistSession?: boolean;
|
|
140
|
+
modelReasoningEffort?: string;
|
|
141
|
+
networkAccessEnabled?: boolean;
|
|
142
|
+
webSearchMode?: string;
|
|
143
|
+
} | {
|
|
144
|
+
type: "list_gallery";
|
|
145
|
+
project?: string;
|
|
146
|
+
sessionId?: string;
|
|
147
|
+
} | {
|
|
148
|
+
type: "list_files";
|
|
149
|
+
projectPath: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: "get_diff";
|
|
152
|
+
projectPath: string;
|
|
153
|
+
} | {
|
|
154
|
+
type: "get_diff_image";
|
|
155
|
+
projectPath: string;
|
|
156
|
+
filePath: string;
|
|
157
|
+
version: "old" | "new" | "both";
|
|
158
|
+
} | {
|
|
159
|
+
type: "interrupt";
|
|
160
|
+
sessionId?: string;
|
|
161
|
+
} | {
|
|
162
|
+
type: "list_project_history";
|
|
163
|
+
} | {
|
|
164
|
+
type: "remove_project_history";
|
|
165
|
+
projectPath: string;
|
|
166
|
+
} | {
|
|
167
|
+
type: "list_worktrees";
|
|
168
|
+
projectPath: string;
|
|
169
|
+
} | {
|
|
170
|
+
type: "remove_worktree";
|
|
171
|
+
projectPath: string;
|
|
172
|
+
worktreePath: string;
|
|
173
|
+
} | {
|
|
174
|
+
type: "rewind";
|
|
175
|
+
sessionId: string;
|
|
176
|
+
targetUuid: string;
|
|
177
|
+
mode: "conversation" | "code" | "both";
|
|
178
|
+
} | {
|
|
179
|
+
type: "rewind_dry_run";
|
|
180
|
+
sessionId: string;
|
|
181
|
+
targetUuid: string;
|
|
182
|
+
} | {
|
|
183
|
+
type: "list_windows";
|
|
184
|
+
} | {
|
|
185
|
+
type: "take_screenshot";
|
|
186
|
+
mode: "fullscreen" | "window";
|
|
187
|
+
windowId?: number;
|
|
188
|
+
projectPath: string;
|
|
189
|
+
sessionId?: string;
|
|
190
|
+
} | {
|
|
191
|
+
type: "get_debug_bundle";
|
|
192
|
+
sessionId: string;
|
|
193
|
+
traceLimit?: number;
|
|
194
|
+
includeDiff?: boolean;
|
|
195
|
+
} | {
|
|
196
|
+
type: "get_usage";
|
|
197
|
+
} | {
|
|
198
|
+
type: "list_recordings";
|
|
199
|
+
} | {
|
|
200
|
+
type: "get_recording";
|
|
201
|
+
sessionId: string;
|
|
202
|
+
} | {
|
|
203
|
+
type: "get_message_images";
|
|
204
|
+
claudeSessionId: string;
|
|
205
|
+
messageUuid: string;
|
|
206
|
+
} | {
|
|
207
|
+
type: "backup_prompt_history";
|
|
208
|
+
data: string;
|
|
209
|
+
appVersion: string;
|
|
210
|
+
dbVersion: number;
|
|
211
|
+
} | {
|
|
212
|
+
type: "restore_prompt_history";
|
|
213
|
+
} | {
|
|
214
|
+
type: "get_prompt_history_backup_info";
|
|
215
|
+
} | {
|
|
216
|
+
type: "archive_session";
|
|
217
|
+
sessionId: string;
|
|
218
|
+
provider: Provider;
|
|
219
|
+
projectPath: string;
|
|
220
|
+
} | {
|
|
221
|
+
type: "refresh_branch";
|
|
222
|
+
sessionId: string;
|
|
223
|
+
};
|
|
224
|
+
/** Image change detected in a git diff (binary image file). */
|
|
225
|
+
export interface ImageChange {
|
|
226
|
+
filePath: string;
|
|
227
|
+
isNew: boolean;
|
|
228
|
+
isDeleted: boolean;
|
|
229
|
+
isSvg: boolean;
|
|
230
|
+
oldSize?: number;
|
|
231
|
+
newSize?: number;
|
|
232
|
+
/** Base64-encoded old image (included only for on-demand loads). */
|
|
233
|
+
oldBase64?: string;
|
|
234
|
+
/** Base64-encoded new image (included only for on-demand loads). */
|
|
235
|
+
newBase64?: string;
|
|
236
|
+
mimeType: string;
|
|
237
|
+
/** Whether the image can be loaded on demand (auto-display or loadable range). */
|
|
238
|
+
loadable: boolean;
|
|
239
|
+
/** Whether the image qualifies for auto-display (≤ auto threshold). */
|
|
240
|
+
autoDisplay?: boolean;
|
|
241
|
+
}
|
|
242
|
+
export interface DebugTraceEvent {
|
|
243
|
+
ts: string;
|
|
244
|
+
sessionId: string;
|
|
245
|
+
direction: "incoming" | "outgoing" | "internal";
|
|
246
|
+
channel: "ws" | "session" | "bridge";
|
|
247
|
+
type: string;
|
|
248
|
+
detail?: string;
|
|
249
|
+
}
|
|
250
|
+
export type ServerMessage = {
|
|
251
|
+
type: "system";
|
|
252
|
+
subtype: string;
|
|
253
|
+
sessionId?: string;
|
|
254
|
+
claudeSessionId?: string;
|
|
255
|
+
model?: string;
|
|
256
|
+
provider?: Provider;
|
|
257
|
+
projectPath?: string;
|
|
258
|
+
slashCommands?: string[];
|
|
259
|
+
skills?: string[];
|
|
260
|
+
skillMetadata?: Array<{
|
|
261
|
+
name: string;
|
|
262
|
+
path: string;
|
|
263
|
+
description: string;
|
|
264
|
+
shortDescription?: string;
|
|
265
|
+
enabled: boolean;
|
|
266
|
+
scope: string;
|
|
267
|
+
displayName?: string;
|
|
268
|
+
defaultPrompt?: string;
|
|
269
|
+
brandColor?: string;
|
|
270
|
+
}>;
|
|
271
|
+
worktreePath?: string;
|
|
272
|
+
worktreeBranch?: string;
|
|
273
|
+
permissionMode?: PermissionMode;
|
|
274
|
+
sandboxMode?: string;
|
|
275
|
+
clearContext?: boolean;
|
|
276
|
+
sourceSessionId?: string;
|
|
277
|
+
tipCode?: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "assistant";
|
|
280
|
+
message: AssistantMessage;
|
|
281
|
+
messageUuid?: string;
|
|
282
|
+
} | {
|
|
283
|
+
type: "tool_result";
|
|
284
|
+
toolUseId: string;
|
|
285
|
+
content: string;
|
|
286
|
+
toolName?: string;
|
|
287
|
+
images?: ImageRef[];
|
|
288
|
+
userMessageUuid?: string;
|
|
289
|
+
rawContentBlocks?: unknown[];
|
|
290
|
+
} | {
|
|
291
|
+
type: "result";
|
|
292
|
+
subtype: string;
|
|
293
|
+
result?: string;
|
|
294
|
+
error?: string;
|
|
295
|
+
cost?: number;
|
|
296
|
+
duration?: number;
|
|
297
|
+
sessionId?: string;
|
|
298
|
+
stopReason?: string;
|
|
299
|
+
inputTokens?: number;
|
|
300
|
+
cachedInputTokens?: number;
|
|
301
|
+
outputTokens?: number;
|
|
302
|
+
toolCalls?: number;
|
|
303
|
+
fileEdits?: number;
|
|
304
|
+
} | {
|
|
305
|
+
type: "error";
|
|
306
|
+
message: string;
|
|
307
|
+
errorCode?: string;
|
|
308
|
+
} | {
|
|
309
|
+
type: "status";
|
|
310
|
+
status: ProcessStatus;
|
|
311
|
+
} | {
|
|
312
|
+
type: "history";
|
|
313
|
+
messages: ServerMessage[];
|
|
314
|
+
} | {
|
|
315
|
+
type: "permission_request";
|
|
316
|
+
toolUseId: string;
|
|
317
|
+
toolName: string;
|
|
318
|
+
input: Record<string, unknown>;
|
|
319
|
+
} | {
|
|
320
|
+
type: "permission_resolved";
|
|
321
|
+
toolUseId: string;
|
|
322
|
+
} | {
|
|
323
|
+
type: "stream_delta";
|
|
324
|
+
text: string;
|
|
325
|
+
} | {
|
|
326
|
+
type: "thinking_delta";
|
|
327
|
+
text: string;
|
|
328
|
+
} | {
|
|
329
|
+
type: "file_list";
|
|
330
|
+
files: string[];
|
|
331
|
+
} | {
|
|
332
|
+
type: "project_history";
|
|
333
|
+
projects: string[];
|
|
334
|
+
} | {
|
|
335
|
+
type: "diff_result";
|
|
336
|
+
diff: string;
|
|
337
|
+
error?: string;
|
|
338
|
+
errorCode?: string;
|
|
339
|
+
imageChanges?: ImageChange[];
|
|
340
|
+
} | {
|
|
341
|
+
type: "diff_image_result";
|
|
342
|
+
filePath: string;
|
|
343
|
+
version: "old" | "new" | "both";
|
|
344
|
+
base64?: string;
|
|
345
|
+
mimeType?: string;
|
|
346
|
+
error?: string;
|
|
347
|
+
oldBase64?: string;
|
|
348
|
+
newBase64?: string;
|
|
349
|
+
} | {
|
|
350
|
+
type: "worktree_list";
|
|
351
|
+
worktrees: WorktreeInfo[];
|
|
352
|
+
mainBranch?: string;
|
|
353
|
+
} | {
|
|
354
|
+
type: "worktree_removed";
|
|
355
|
+
worktreePath: string;
|
|
356
|
+
} | {
|
|
357
|
+
type: "tool_use_summary";
|
|
358
|
+
summary: string;
|
|
359
|
+
precedingToolUseIds: string[];
|
|
360
|
+
} | {
|
|
361
|
+
type: "rewind_preview";
|
|
362
|
+
canRewind: boolean;
|
|
363
|
+
filesChanged?: string[];
|
|
364
|
+
insertions?: number;
|
|
365
|
+
deletions?: number;
|
|
366
|
+
error?: string;
|
|
367
|
+
} | {
|
|
368
|
+
type: "rewind_result";
|
|
369
|
+
success: boolean;
|
|
370
|
+
mode: "conversation" | "code" | "both";
|
|
371
|
+
error?: string;
|
|
372
|
+
} | {
|
|
373
|
+
type: "user_input";
|
|
374
|
+
text: string;
|
|
375
|
+
userMessageUuid?: string;
|
|
376
|
+
isSynthetic?: boolean;
|
|
377
|
+
isMeta?: boolean;
|
|
378
|
+
imageCount?: number;
|
|
379
|
+
} | {
|
|
380
|
+
type: "window_list";
|
|
381
|
+
windows: WindowInfo[];
|
|
382
|
+
} | {
|
|
383
|
+
type: "screenshot_result";
|
|
384
|
+
success: boolean;
|
|
385
|
+
image?: GalleryImageInfo;
|
|
386
|
+
error?: string;
|
|
387
|
+
} | {
|
|
388
|
+
type: "debug_bundle";
|
|
389
|
+
sessionId: string;
|
|
390
|
+
generatedAt: string;
|
|
391
|
+
session: {
|
|
392
|
+
id: string;
|
|
393
|
+
provider: Provider;
|
|
394
|
+
status: ProcessStatus;
|
|
395
|
+
projectPath: string;
|
|
396
|
+
worktreePath?: string;
|
|
397
|
+
worktreeBranch?: string;
|
|
398
|
+
claudeSessionId?: string;
|
|
399
|
+
createdAt: string;
|
|
400
|
+
lastActivityAt: string;
|
|
401
|
+
};
|
|
402
|
+
pastMessageCount: number;
|
|
403
|
+
historySummary: string[];
|
|
404
|
+
debugTrace: DebugTraceEvent[];
|
|
405
|
+
traceFilePath: string;
|
|
406
|
+
reproRecipe: {
|
|
407
|
+
wsUrlHint: string;
|
|
408
|
+
startBridgeCommand: string;
|
|
409
|
+
resumeSessionMessage: Record<string, unknown>;
|
|
410
|
+
getHistoryMessage: Record<string, unknown>;
|
|
411
|
+
getDebugBundleMessage: Record<string, unknown>;
|
|
412
|
+
notes: string[];
|
|
413
|
+
};
|
|
414
|
+
agentPrompt: string;
|
|
415
|
+
diff: string;
|
|
416
|
+
diffError?: string;
|
|
417
|
+
savedBundlePath?: string;
|
|
418
|
+
} | {
|
|
419
|
+
type: "usage_result";
|
|
420
|
+
providers: UsageInfoPayload[];
|
|
421
|
+
} | {
|
|
422
|
+
type: "message_images_result";
|
|
423
|
+
messageUuid: string;
|
|
424
|
+
images: ImageRef[];
|
|
425
|
+
} | {
|
|
426
|
+
type: "prompt_history_backup_result";
|
|
427
|
+
success: boolean;
|
|
428
|
+
backedUpAt?: string;
|
|
429
|
+
error?: string;
|
|
430
|
+
} | {
|
|
431
|
+
type: "prompt_history_restore_result";
|
|
432
|
+
success: boolean;
|
|
433
|
+
data?: string;
|
|
434
|
+
appVersion?: string;
|
|
435
|
+
dbVersion?: number;
|
|
436
|
+
backedUpAt?: string;
|
|
437
|
+
error?: string;
|
|
438
|
+
} | {
|
|
439
|
+
type: "prompt_history_backup_info";
|
|
440
|
+
exists: boolean;
|
|
441
|
+
appVersion?: string;
|
|
442
|
+
dbVersion?: number;
|
|
443
|
+
backedUpAt?: string;
|
|
444
|
+
sizeBytes?: number;
|
|
445
|
+
} | {
|
|
446
|
+
type: "rename_result";
|
|
447
|
+
sessionId: string;
|
|
448
|
+
name: string | null;
|
|
449
|
+
success: boolean;
|
|
450
|
+
error?: string;
|
|
451
|
+
};
|
|
452
|
+
export interface UsageWindowPayload {
|
|
453
|
+
utilization: number;
|
|
454
|
+
resetsAt: string;
|
|
455
|
+
}
|
|
456
|
+
export interface UsageInfoPayload {
|
|
457
|
+
provider: "claude" | "codex";
|
|
458
|
+
fiveHour: UsageWindowPayload | null;
|
|
459
|
+
sevenDay: UsageWindowPayload | null;
|
|
460
|
+
error?: string;
|
|
461
|
+
}
|
|
462
|
+
export type ProcessStatus = "starting" | "idle" | "running" | "waiting_approval" | "compacting";
|
|
463
|
+
/** Normalize tool_result content: may be string or array of content blocks. */
|
|
464
|
+
export declare function normalizeToolResultContent(content: string | unknown[]): string;
|
|
465
|
+
export declare function parseClientMessage(data: string): ClientMessage | null;
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// ---- Helpers ----
|
|
2
|
+
/** Normalize tool_result content: may be string or array of content blocks. */
|
|
3
|
+
export function normalizeToolResultContent(content) {
|
|
4
|
+
if (Array.isArray(content)) {
|
|
5
|
+
return content
|
|
6
|
+
.filter((c) => c.type === "text")
|
|
7
|
+
.map((c) => c.text)
|
|
8
|
+
.join("\n");
|
|
9
|
+
}
|
|
10
|
+
return typeof content === "string" ? content : String(content ?? "");
|
|
11
|
+
}
|
|
12
|
+
// ---- Parser ----
|
|
13
|
+
export function parseClientMessage(data) {
|
|
14
|
+
try {
|
|
15
|
+
const msg = JSON.parse(data);
|
|
16
|
+
if (!msg.type || typeof msg.type !== "string")
|
|
17
|
+
return null;
|
|
18
|
+
switch (msg.type) {
|
|
19
|
+
case "start":
|
|
20
|
+
if (typeof msg.projectPath !== "string")
|
|
21
|
+
return null;
|
|
22
|
+
if (msg.model !== undefined && typeof msg.model !== "string")
|
|
23
|
+
return null;
|
|
24
|
+
if (msg.effort !== undefined && !["low", "medium", "high", "max"].includes(String(msg.effort)))
|
|
25
|
+
return null;
|
|
26
|
+
if (msg.maxTurns !== undefined
|
|
27
|
+
&& (!Number.isInteger(msg.maxTurns) || Number(msg.maxTurns) < 1))
|
|
28
|
+
return null;
|
|
29
|
+
if (msg.maxBudgetUsd !== undefined
|
|
30
|
+
&& (typeof msg.maxBudgetUsd !== "number" || !Number.isFinite(msg.maxBudgetUsd) || msg.maxBudgetUsd < 0))
|
|
31
|
+
return null;
|
|
32
|
+
if (msg.fallbackModel !== undefined && typeof msg.fallbackModel !== "string")
|
|
33
|
+
return null;
|
|
34
|
+
if (msg.forkSession !== undefined && typeof msg.forkSession !== "boolean")
|
|
35
|
+
return null;
|
|
36
|
+
if (msg.persistSession !== undefined && typeof msg.persistSession !== "boolean")
|
|
37
|
+
return null;
|
|
38
|
+
if (msg.networkAccessEnabled !== undefined && typeof msg.networkAccessEnabled !== "boolean")
|
|
39
|
+
return null;
|
|
40
|
+
if (msg.modelReasoningEffort !== undefined
|
|
41
|
+
&& !["minimal", "low", "medium", "high", "xhigh"].includes(String(msg.modelReasoningEffort)))
|
|
42
|
+
return null;
|
|
43
|
+
if (msg.webSearchMode !== undefined
|
|
44
|
+
&& !["disabled", "cached", "live"].includes(String(msg.webSearchMode)))
|
|
45
|
+
return null;
|
|
46
|
+
break;
|
|
47
|
+
case "input":
|
|
48
|
+
if (typeof msg.text !== "string")
|
|
49
|
+
return null;
|
|
50
|
+
// Validate images array if provided
|
|
51
|
+
if (msg.images !== undefined) {
|
|
52
|
+
if (!Array.isArray(msg.images))
|
|
53
|
+
return null;
|
|
54
|
+
for (const img of msg.images) {
|
|
55
|
+
if (typeof img?.base64 !== "string" || typeof img?.mimeType !== "string")
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Legacy: imageBase64 requires mimeType
|
|
60
|
+
if (msg.imageBase64 && typeof msg.mimeType !== "string")
|
|
61
|
+
return null;
|
|
62
|
+
break;
|
|
63
|
+
case "push_register":
|
|
64
|
+
if (typeof msg.token !== "string")
|
|
65
|
+
return null;
|
|
66
|
+
if (msg.platform !== "ios" && msg.platform !== "android" && msg.platform !== "web")
|
|
67
|
+
return null;
|
|
68
|
+
break;
|
|
69
|
+
case "push_unregister":
|
|
70
|
+
if (typeof msg.token !== "string")
|
|
71
|
+
return null;
|
|
72
|
+
break;
|
|
73
|
+
case "set_permission_mode":
|
|
74
|
+
if (typeof msg.mode !== "string"
|
|
75
|
+
|| !["default", "acceptEdits", "bypassPermissions", "plan"].includes(msg.mode))
|
|
76
|
+
return null;
|
|
77
|
+
break;
|
|
78
|
+
case "set_sandbox_mode":
|
|
79
|
+
if (typeof msg.sandboxMode !== "string")
|
|
80
|
+
return null;
|
|
81
|
+
break;
|
|
82
|
+
case "approve":
|
|
83
|
+
if (typeof msg.id !== "string")
|
|
84
|
+
return null;
|
|
85
|
+
break;
|
|
86
|
+
case "approve_always":
|
|
87
|
+
if (typeof msg.id !== "string")
|
|
88
|
+
return null;
|
|
89
|
+
break;
|
|
90
|
+
case "reject":
|
|
91
|
+
if (typeof msg.id !== "string")
|
|
92
|
+
return null;
|
|
93
|
+
break;
|
|
94
|
+
case "answer":
|
|
95
|
+
if (typeof msg.toolUseId !== "string" || typeof msg.result !== "string")
|
|
96
|
+
return null;
|
|
97
|
+
break;
|
|
98
|
+
case "list_sessions":
|
|
99
|
+
break;
|
|
100
|
+
case "stop_session":
|
|
101
|
+
if (typeof msg.sessionId !== "string")
|
|
102
|
+
return null;
|
|
103
|
+
break;
|
|
104
|
+
case "rename_session":
|
|
105
|
+
if (typeof msg.sessionId !== "string")
|
|
106
|
+
return null;
|
|
107
|
+
break;
|
|
108
|
+
case "get_history":
|
|
109
|
+
if (typeof msg.sessionId !== "string")
|
|
110
|
+
return null;
|
|
111
|
+
break;
|
|
112
|
+
case "list_recent_sessions":
|
|
113
|
+
break;
|
|
114
|
+
case "resume_session":
|
|
115
|
+
if (typeof msg.sessionId !== "string" || typeof msg.projectPath !== "string")
|
|
116
|
+
return null;
|
|
117
|
+
if (msg.provider && msg.provider !== "claude" && msg.provider !== "codex")
|
|
118
|
+
return null;
|
|
119
|
+
if (msg.model !== undefined && typeof msg.model !== "string")
|
|
120
|
+
return null;
|
|
121
|
+
if (msg.effort !== undefined && !["low", "medium", "high", "max"].includes(String(msg.effort)))
|
|
122
|
+
return null;
|
|
123
|
+
if (msg.maxTurns !== undefined
|
|
124
|
+
&& (!Number.isInteger(msg.maxTurns) || Number(msg.maxTurns) < 1))
|
|
125
|
+
return null;
|
|
126
|
+
if (msg.maxBudgetUsd !== undefined
|
|
127
|
+
&& (typeof msg.maxBudgetUsd !== "number" || !Number.isFinite(msg.maxBudgetUsd) || msg.maxBudgetUsd < 0))
|
|
128
|
+
return null;
|
|
129
|
+
if (msg.fallbackModel !== undefined && typeof msg.fallbackModel !== "string")
|
|
130
|
+
return null;
|
|
131
|
+
if (msg.forkSession !== undefined && typeof msg.forkSession !== "boolean")
|
|
132
|
+
return null;
|
|
133
|
+
if (msg.persistSession !== undefined && typeof msg.persistSession !== "boolean")
|
|
134
|
+
return null;
|
|
135
|
+
if (msg.networkAccessEnabled !== undefined && typeof msg.networkAccessEnabled !== "boolean")
|
|
136
|
+
return null;
|
|
137
|
+
if (msg.modelReasoningEffort !== undefined
|
|
138
|
+
&& !["minimal", "low", "medium", "high", "xhigh"].includes(String(msg.modelReasoningEffort)))
|
|
139
|
+
return null;
|
|
140
|
+
if (msg.webSearchMode !== undefined
|
|
141
|
+
&& !["disabled", "cached", "live"].includes(String(msg.webSearchMode)))
|
|
142
|
+
return null;
|
|
143
|
+
break;
|
|
144
|
+
case "list_gallery":
|
|
145
|
+
break;
|
|
146
|
+
case "list_files":
|
|
147
|
+
if (typeof msg.projectPath !== "string")
|
|
148
|
+
return null;
|
|
149
|
+
break;
|
|
150
|
+
case "get_diff":
|
|
151
|
+
if (typeof msg.projectPath !== "string")
|
|
152
|
+
return null;
|
|
153
|
+
break;
|
|
154
|
+
case "get_diff_image":
|
|
155
|
+
if (typeof msg.projectPath !== "string")
|
|
156
|
+
return null;
|
|
157
|
+
if (typeof msg.filePath !== "string")
|
|
158
|
+
return null;
|
|
159
|
+
if (msg.version !== "old" && msg.version !== "new" && msg.version !== "both")
|
|
160
|
+
return null;
|
|
161
|
+
break;
|
|
162
|
+
case "interrupt":
|
|
163
|
+
break;
|
|
164
|
+
case "list_project_history":
|
|
165
|
+
break;
|
|
166
|
+
case "remove_project_history":
|
|
167
|
+
if (typeof msg.projectPath !== "string")
|
|
168
|
+
return null;
|
|
169
|
+
break;
|
|
170
|
+
case "list_worktrees":
|
|
171
|
+
if (typeof msg.projectPath !== "string")
|
|
172
|
+
return null;
|
|
173
|
+
break;
|
|
174
|
+
case "remove_worktree":
|
|
175
|
+
if (typeof msg.projectPath !== "string" || typeof msg.worktreePath !== "string")
|
|
176
|
+
return null;
|
|
177
|
+
break;
|
|
178
|
+
case "rewind":
|
|
179
|
+
if (typeof msg.sessionId !== "string" || typeof msg.targetUuid !== "string")
|
|
180
|
+
return null;
|
|
181
|
+
if (msg.mode !== "conversation" && msg.mode !== "code" && msg.mode !== "both")
|
|
182
|
+
return null;
|
|
183
|
+
break;
|
|
184
|
+
case "rewind_dry_run":
|
|
185
|
+
if (typeof msg.sessionId !== "string" || typeof msg.targetUuid !== "string")
|
|
186
|
+
return null;
|
|
187
|
+
break;
|
|
188
|
+
case "list_windows":
|
|
189
|
+
break;
|
|
190
|
+
case "take_screenshot":
|
|
191
|
+
if (msg.mode !== "fullscreen" && msg.mode !== "window")
|
|
192
|
+
return null;
|
|
193
|
+
if (msg.mode === "window" && typeof msg.windowId !== "number")
|
|
194
|
+
return null;
|
|
195
|
+
if (typeof msg.projectPath !== "string")
|
|
196
|
+
return null;
|
|
197
|
+
break;
|
|
198
|
+
case "get_debug_bundle":
|
|
199
|
+
if (typeof msg.sessionId !== "string")
|
|
200
|
+
return null;
|
|
201
|
+
if (msg.traceLimit !== undefined && typeof msg.traceLimit !== "number")
|
|
202
|
+
return null;
|
|
203
|
+
if (msg.includeDiff !== undefined && typeof msg.includeDiff !== "boolean")
|
|
204
|
+
return null;
|
|
205
|
+
break;
|
|
206
|
+
case "get_usage":
|
|
207
|
+
break;
|
|
208
|
+
case "list_recordings":
|
|
209
|
+
break;
|
|
210
|
+
case "get_recording":
|
|
211
|
+
if (typeof msg.sessionId !== "string")
|
|
212
|
+
return null;
|
|
213
|
+
break;
|
|
214
|
+
case "get_message_images":
|
|
215
|
+
if (typeof msg.claudeSessionId !== "string" || typeof msg.messageUuid !== "string")
|
|
216
|
+
return null;
|
|
217
|
+
break;
|
|
218
|
+
case "backup_prompt_history":
|
|
219
|
+
if (typeof msg.data !== "string")
|
|
220
|
+
return null;
|
|
221
|
+
if (typeof msg.appVersion !== "string")
|
|
222
|
+
return null;
|
|
223
|
+
if (typeof msg.dbVersion !== "number" || !Number.isInteger(msg.dbVersion))
|
|
224
|
+
return null;
|
|
225
|
+
break;
|
|
226
|
+
case "restore_prompt_history":
|
|
227
|
+
break;
|
|
228
|
+
case "get_prompt_history_backup_info":
|
|
229
|
+
break;
|
|
230
|
+
case "refresh_branch":
|
|
231
|
+
if (typeof msg.sessionId !== "string")
|
|
232
|
+
return null;
|
|
233
|
+
break;
|
|
234
|
+
case "archive_session":
|
|
235
|
+
if (typeof msg.sessionId !== "string")
|
|
236
|
+
return null;
|
|
237
|
+
if (msg.provider !== "claude" && msg.provider !== "codex")
|
|
238
|
+
return null;
|
|
239
|
+
if (typeof msg.projectPath !== "string")
|
|
240
|
+
return null;
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return msg;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=parser.js.map
|