@dev-anywhere/proxy 0.3.13 → 0.4.2
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/dist/{chunk-JYPJ7PQ3.js → chunk-IFQSVDHB.js} +371 -260
- package/dist/chunk-IFQSVDHB.js.map +1 -0
- package/dist/{chunk-ENA4NCWK.js → chunk-UDLPU2NC.js} +14 -2
- package/dist/chunk-UDLPU2NC.js.map +1 -0
- package/dist/{chunk-LWTSGIOQ.js → chunk-W6275ZRJ.js} +13 -1
- package/dist/chunk-W6275ZRJ.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/serve.js +286 -25
- package/dist/serve.js.map +1 -1
- package/dist/session-worker.js +6 -4
- package/dist/session-worker.js.map +1 -1
- package/dist/{terminal-TKIXG3KL.js → terminal-HB75QUZK.js} +7 -4
- package/dist/terminal-HB75QUZK.js.map +1 -0
- package/package.json +3 -3
- package/dist/chunk-ENA4NCWK.js.map +0 -1
- package/dist/chunk-JYPJ7PQ3.js.map +0 -1
- package/dist/chunk-LWTSGIOQ.js.map +0 -1
- package/dist/terminal-TKIXG3KL.js.map +0 -1
|
@@ -325,8 +325,60 @@ function defineFSM(transitions) {
|
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
// ../../packages/shared/dist/schemas/
|
|
328
|
+
// ../../packages/shared/dist/schemas/voice.js
|
|
329
329
|
import { z as z7 } from "zod";
|
|
330
|
+
var voiceProviderValues = ["aliyun-bailian"];
|
|
331
|
+
var voiceRegionValues = ["cn", "intl"];
|
|
332
|
+
var voiceOptionSourceValues = ["official", "custom"];
|
|
333
|
+
var voiceOptionGenderValues = ["male", "female", "unknown"];
|
|
334
|
+
var VoiceProviderConfigSchema = z7.object({
|
|
335
|
+
provider: z7.enum(voiceProviderValues),
|
|
336
|
+
configured: z7.boolean(),
|
|
337
|
+
region: z7.enum(voiceRegionValues),
|
|
338
|
+
asrModel: z7.string().min(1),
|
|
339
|
+
ttsModel: z7.string().min(1),
|
|
340
|
+
ttsVoice: z7.string().min(1),
|
|
341
|
+
turnIdleSeconds: z7.number().int().positive().safe().default(3)
|
|
342
|
+
}).strict();
|
|
343
|
+
var VoiceConfigUpdateSchema = z7.object({
|
|
344
|
+
provider: z7.enum(voiceProviderValues).optional(),
|
|
345
|
+
apiKey: z7.string().min(1).optional(),
|
|
346
|
+
clearApiKey: z7.boolean().optional(),
|
|
347
|
+
region: z7.enum(voiceRegionValues).optional(),
|
|
348
|
+
asrModel: z7.string().min(1).optional(),
|
|
349
|
+
ttsModel: z7.string().min(1).optional(),
|
|
350
|
+
ttsVoice: z7.string().min(1).optional(),
|
|
351
|
+
turnIdleSeconds: z7.number().int().positive().safe().optional()
|
|
352
|
+
}).strict();
|
|
353
|
+
var VoiceOptionSchema = z7.object({
|
|
354
|
+
value: z7.string().min(1),
|
|
355
|
+
label: z7.string().min(1),
|
|
356
|
+
description: z7.string().min(1).optional(),
|
|
357
|
+
gender: z7.enum(voiceOptionGenderValues).optional(),
|
|
358
|
+
age: z7.string().min(1).optional(),
|
|
359
|
+
model: z7.string().min(1).optional(),
|
|
360
|
+
source: z7.enum(voiceOptionSourceValues)
|
|
361
|
+
}).strict();
|
|
362
|
+
var VoiceCapabilitiesSchema = z7.object({
|
|
363
|
+
asrModels: z7.array(VoiceOptionSchema),
|
|
364
|
+
ttsModels: z7.array(VoiceOptionSchema),
|
|
365
|
+
ttsVoices: z7.array(VoiceOptionSchema),
|
|
366
|
+
fetchedAt: z7.number().optional()
|
|
367
|
+
}).strict();
|
|
368
|
+
var VoiceSummaryReasonSchema = z7.enum([
|
|
369
|
+
"code",
|
|
370
|
+
"table",
|
|
371
|
+
"diff",
|
|
372
|
+
"log",
|
|
373
|
+
"stack_trace",
|
|
374
|
+
"long_list",
|
|
375
|
+
"long_text",
|
|
376
|
+
"mixed",
|
|
377
|
+
"approval"
|
|
378
|
+
]);
|
|
379
|
+
|
|
380
|
+
// ../../packages/shared/dist/schemas/relay-control.js
|
|
381
|
+
import { z as z8 } from "zod";
|
|
330
382
|
|
|
331
383
|
// ../../packages/shared/dist/constants/relay-errors.js
|
|
332
384
|
var RelayErrorCode = {
|
|
@@ -353,59 +405,59 @@ var ControlErrorCode = {
|
|
|
353
405
|
};
|
|
354
406
|
|
|
355
407
|
// ../../packages/shared/dist/schemas/relay-control.js
|
|
356
|
-
var ProxyInfoSchema =
|
|
408
|
+
var ProxyInfoSchema = z8.object({
|
|
357
409
|
proxyId: IdSchema,
|
|
358
|
-
name:
|
|
359
|
-
online:
|
|
360
|
-
sessions:
|
|
410
|
+
name: z8.string().optional(),
|
|
411
|
+
online: z8.boolean(),
|
|
412
|
+
sessions: z8.array(z8.string()).optional()
|
|
361
413
|
});
|
|
362
|
-
var AgentCliAvailabilitySchema =
|
|
363
|
-
available:
|
|
364
|
-
command:
|
|
365
|
-
error:
|
|
366
|
-
suggestions:
|
|
414
|
+
var AgentCliAvailabilitySchema = z8.object({
|
|
415
|
+
available: z8.boolean(),
|
|
416
|
+
command: z8.string().optional(),
|
|
417
|
+
error: z8.string().optional(),
|
|
418
|
+
suggestions: z8.array(z8.string()).optional()
|
|
367
419
|
});
|
|
368
|
-
var AgentCliStatusSchema =
|
|
420
|
+
var AgentCliStatusSchema = z8.object({
|
|
369
421
|
claude: AgentCliAvailabilitySchema,
|
|
370
422
|
codex: AgentCliAvailabilitySchema
|
|
371
423
|
});
|
|
372
|
-
var DirEntrySchema =
|
|
373
|
-
var FileTreeGroupSchema =
|
|
374
|
-
path:
|
|
375
|
-
entries:
|
|
424
|
+
var DirEntrySchema = z8.object({ name: z8.string(), isDir: z8.boolean() });
|
|
425
|
+
var FileTreeGroupSchema = z8.object({
|
|
426
|
+
path: z8.string(),
|
|
427
|
+
entries: z8.array(DirEntrySchema)
|
|
376
428
|
});
|
|
377
|
-
var CommandEntrySchema =
|
|
378
|
-
name:
|
|
379
|
-
description:
|
|
380
|
-
argumentHint:
|
|
381
|
-
source:
|
|
429
|
+
var CommandEntrySchema = z8.object({
|
|
430
|
+
name: z8.string(),
|
|
431
|
+
description: z8.string(),
|
|
432
|
+
argumentHint: z8.string().optional(),
|
|
433
|
+
source: z8.string()
|
|
382
434
|
});
|
|
383
|
-
var HistorySessionSchema =
|
|
384
|
-
id:
|
|
385
|
-
title:
|
|
386
|
-
projectDir:
|
|
387
|
-
updatedAt:
|
|
388
|
-
provider:
|
|
435
|
+
var HistorySessionSchema = z8.object({
|
|
436
|
+
id: z8.string(),
|
|
437
|
+
title: z8.string(),
|
|
438
|
+
projectDir: z8.string(),
|
|
439
|
+
updatedAt: z8.number(),
|
|
440
|
+
provider: z8.enum(providerValues).optional()
|
|
389
441
|
});
|
|
390
|
-
var SessionHistoryMessageSchema =
|
|
391
|
-
role:
|
|
392
|
-
text:
|
|
393
|
-
timestamp:
|
|
394
|
-
cursor:
|
|
442
|
+
var SessionHistoryMessageSchema = z8.object({
|
|
443
|
+
role: z8.enum(["user", "assistant"]),
|
|
444
|
+
text: z8.string(),
|
|
445
|
+
timestamp: z8.number().optional(),
|
|
446
|
+
cursor: z8.string().optional()
|
|
395
447
|
});
|
|
396
448
|
var RequestIdShape = { requestId: IdSchema.optional() };
|
|
397
|
-
var ControlErrorCodeSchema =
|
|
449
|
+
var ControlErrorCodeSchema = z8.enum(Object.values(ControlErrorCode));
|
|
398
450
|
var RequestErrorShape = {
|
|
399
|
-
error:
|
|
451
|
+
error: z8.string().optional(),
|
|
400
452
|
errorCode: ControlErrorCodeSchema.optional()
|
|
401
453
|
};
|
|
402
|
-
var ClipboardImageMimeTypeSchema =
|
|
454
|
+
var ClipboardImageMimeTypeSchema = z8.enum(["image/png", "image/jpeg", "image/webp", "image/gif"]);
|
|
403
455
|
function control(type, shape, directions) {
|
|
404
456
|
return {
|
|
405
457
|
type,
|
|
406
458
|
directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
|
|
407
|
-
schema:
|
|
408
|
-
type:
|
|
459
|
+
schema: z8.object({
|
|
460
|
+
type: z8.literal(type),
|
|
409
461
|
...shape ?? {}
|
|
410
462
|
})
|
|
411
463
|
};
|
|
@@ -413,36 +465,75 @@ function control(type, shape, directions) {
|
|
|
413
465
|
var relayControlDefinitions = [
|
|
414
466
|
control("proxy_register", {
|
|
415
467
|
proxyId: IdSchema,
|
|
416
|
-
name:
|
|
468
|
+
name: z8.string().optional()
|
|
417
469
|
}),
|
|
418
470
|
control("proxy_register_response", {
|
|
419
|
-
status:
|
|
471
|
+
status: z8.enum(["new", "reconnected"])
|
|
420
472
|
}),
|
|
421
473
|
control("proxy_list_request", RequestIdShape),
|
|
422
474
|
control("proxy_list_response", {
|
|
423
475
|
...RequestIdShape,
|
|
424
|
-
proxies:
|
|
476
|
+
proxies: z8.array(ProxyInfoSchema)
|
|
425
477
|
}),
|
|
426
478
|
control("proxy_select", { ...RequestIdShape, proxyId: IdSchema }),
|
|
427
479
|
control("proxy_select_response", {
|
|
428
480
|
...RequestIdShape,
|
|
429
|
-
success:
|
|
481
|
+
success: z8.boolean(),
|
|
430
482
|
proxyId: IdSchema.optional(),
|
|
431
483
|
...RequestErrorShape
|
|
432
484
|
}),
|
|
433
485
|
control("relay_error", {
|
|
434
|
-
code:
|
|
435
|
-
message:
|
|
486
|
+
code: z8.enum(Object.values(RelayErrorCode)),
|
|
487
|
+
message: z8.string(),
|
|
436
488
|
// 可选 requestId: relay 把 client 发来 raw 的 requestId 字段透传回来,
|
|
437
489
|
// client 侧 waitForMessage 据此把对应 pending request 立即拒掉而不必等到 timeout。
|
|
438
490
|
requestId: IdSchema.optional()
|
|
439
491
|
}),
|
|
492
|
+
// Voice Pilot config is relay-local: client reads/updates the relay's stored provider settings.
|
|
493
|
+
control("voice_config_request", RequestIdShape),
|
|
494
|
+
control("voice_config_response", {
|
|
495
|
+
...RequestIdShape,
|
|
496
|
+
...RequestErrorShape,
|
|
497
|
+
config: VoiceProviderConfigSchema.optional()
|
|
498
|
+
}),
|
|
499
|
+
control("voice_config_update", {
|
|
500
|
+
...RequestIdShape,
|
|
501
|
+
config: VoiceConfigUpdateSchema
|
|
502
|
+
}),
|
|
503
|
+
control("voice_config_update_response", {
|
|
504
|
+
...RequestIdShape,
|
|
505
|
+
...RequestErrorShape,
|
|
506
|
+
success: z8.boolean(),
|
|
507
|
+
config: VoiceProviderConfigSchema.optional()
|
|
508
|
+
}),
|
|
509
|
+
control("voice_config_test", {
|
|
510
|
+
...RequestIdShape,
|
|
511
|
+
config: VoiceConfigUpdateSchema.optional()
|
|
512
|
+
}),
|
|
513
|
+
control("voice_config_test_response", {
|
|
514
|
+
...RequestIdShape,
|
|
515
|
+
...RequestErrorShape,
|
|
516
|
+
success: z8.boolean(),
|
|
517
|
+
audioBase64: z8.string().optional(),
|
|
518
|
+
audioSampleRate: z8.number().int().positive().optional(),
|
|
519
|
+
audioEncoding: z8.literal("pcm_s16le").optional(),
|
|
520
|
+
transcript: z8.string().optional()
|
|
521
|
+
}),
|
|
522
|
+
control("voice_capabilities_request", {
|
|
523
|
+
...RequestIdShape,
|
|
524
|
+
region: z8.enum(voiceRegionValues).optional()
|
|
525
|
+
}),
|
|
526
|
+
control("voice_capabilities_response", {
|
|
527
|
+
...RequestIdShape,
|
|
528
|
+
...RequestErrorShape,
|
|
529
|
+
capabilities: VoiceCapabilitiesSchema.optional()
|
|
530
|
+
}),
|
|
440
531
|
// 客户端注册协议
|
|
441
532
|
control("client_register", {
|
|
442
533
|
clientId: IdSchema
|
|
443
534
|
}),
|
|
444
535
|
control("client_register_response", {
|
|
445
|
-
status:
|
|
536
|
+
status: z8.enum(["restored", "proxy_offline", "new"]),
|
|
446
537
|
proxyId: IdSchema.optional()
|
|
447
538
|
}),
|
|
448
539
|
// Proxy 离线通知
|
|
@@ -461,51 +552,51 @@ var relayControlDefinitions = [
|
|
|
461
552
|
control("dir_list_request", {
|
|
462
553
|
proxyId: IdSchema.optional(),
|
|
463
554
|
...RequestIdShape,
|
|
464
|
-
path:
|
|
555
|
+
path: z8.string()
|
|
465
556
|
}, "client_to_proxy"),
|
|
466
|
-
control("dir_list_response", { ...RequestIdShape, ...RequestErrorShape, entries:
|
|
557
|
+
control("dir_list_response", { ...RequestIdShape, ...RequestErrorShape, entries: z8.array(DirEntrySchema), path: z8.string() }, "proxy_to_client"),
|
|
467
558
|
// 目录创建请求与响应
|
|
468
|
-
control("dir_create_request", { ...RequestIdShape, path:
|
|
559
|
+
control("dir_create_request", { ...RequestIdShape, path: z8.string() }, "client_to_proxy"),
|
|
469
560
|
control("dir_create_response", {
|
|
470
561
|
...RequestIdShape,
|
|
471
562
|
...RequestErrorShape,
|
|
472
|
-
path:
|
|
473
|
-
success:
|
|
563
|
+
path: z8.string(),
|
|
564
|
+
success: z8.boolean()
|
|
474
565
|
}, "proxy_to_client"),
|
|
475
566
|
// 命令列表推送,proxy 将可用命令列表推给 client
|
|
476
|
-
control("command_list_push", { commands:
|
|
567
|
+
control("command_list_push", { commands: z8.array(CommandEntrySchema) }, "proxy_to_client"),
|
|
477
568
|
// 文件树推送: 按目录分组, 首组 path 即为 session cwd
|
|
478
569
|
// 前端直接把每组写入 tree[path], 与 dir_list_response 共享 cache slot
|
|
479
570
|
control("file_tree_push", {
|
|
480
|
-
groups:
|
|
571
|
+
groups: z8.array(FileTreeGroupSchema)
|
|
481
572
|
}, "proxy_to_client"),
|
|
482
573
|
// 会话列表请求与权限模式变更
|
|
483
574
|
control("session_list", void 0, ["client_to_proxy", "proxy_to_client"]),
|
|
484
575
|
control("permission_mode_change", {
|
|
485
|
-
mode:
|
|
576
|
+
mode: z8.enum(["default", "auto_accept", "plan"]),
|
|
486
577
|
// sessionId 可选:传入时 proxy 按该会话的 mode 分叉(PTY 发 Tab ANSI),未传走全局日志行为
|
|
487
578
|
sessionId: IdSchema.optional()
|
|
488
579
|
}, "client_to_proxy"),
|
|
489
580
|
// 会话历史浏览
|
|
490
581
|
control("session_history_request", RequestIdShape, "client_to_proxy"),
|
|
491
|
-
control("session_history_response", { ...RequestIdShape, sessions:
|
|
582
|
+
control("session_history_response", { ...RequestIdShape, sessions: z8.array(HistorySessionSchema) }, "proxy_to_client"),
|
|
492
583
|
// PTY 语义状态,从 Envelope 迁移到 Control 层
|
|
493
584
|
control("pty_state", { sessionId: IdSchema, payload: PtyStatePayloadSchema }, "proxy_to_client"),
|
|
494
585
|
// Provider 语义状态,来自 Claude/Codex hook 等结构化事件,不从 PTY 字节推断
|
|
495
586
|
control("agent_status", { sessionId: IdSchema, payload: AgentStatusPayloadSchema }, "proxy_to_client"),
|
|
496
587
|
// 终端标题变化,proxy -> client
|
|
497
|
-
control("terminal_title", { sessionId: IdSchema, title:
|
|
588
|
+
control("terminal_title", { sessionId: IdSchema, title: z8.string() }, "proxy_to_client"),
|
|
498
589
|
// 终端尺寸变化,proxy -> client
|
|
499
|
-
control("terminal_resize", { sessionId: IdSchema, cols:
|
|
500
|
-
control("terminal_resize_request", { sessionId: IdSchema, cols:
|
|
590
|
+
control("terminal_resize", { sessionId: IdSchema, cols: z8.number().int().positive(), rows: z8.number().int().positive() }, "proxy_to_client"),
|
|
591
|
+
control("terminal_resize_request", { sessionId: IdSchema, cols: z8.number().int().positive(), rows: z8.number().int().positive() }, "client_to_proxy"),
|
|
501
592
|
// 远程终止 JSON 会话,client -> proxy
|
|
502
593
|
control("session_terminate", { sessionId: IdSchema }, "client_to_proxy"),
|
|
503
|
-
control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name:
|
|
594
|
+
control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z8.string() }, "client_to_proxy"),
|
|
504
595
|
control("session_rename_response", {
|
|
505
596
|
...RequestIdShape,
|
|
506
597
|
sessionId: IdSchema,
|
|
507
|
-
success:
|
|
508
|
-
name:
|
|
598
|
+
success: z8.boolean(),
|
|
599
|
+
name: z8.string().optional(),
|
|
509
600
|
...RequestErrorShape
|
|
510
601
|
}, "proxy_to_client"),
|
|
511
602
|
// 中断当前 turn,client -> proxy,SIGINT 到 worker 进程让 claude CLI abort 当前流
|
|
@@ -513,114 +604,117 @@ var relayControlDefinitions = [
|
|
|
513
604
|
// turn 完成信号,proxy -> client,对应 claude stream-json 的 result 事件
|
|
514
605
|
control("turn_result", {
|
|
515
606
|
sessionId: IdSchema,
|
|
516
|
-
success:
|
|
517
|
-
isError:
|
|
607
|
+
success: z8.boolean(),
|
|
608
|
+
isError: z8.boolean(),
|
|
518
609
|
// stream-json result.result 是本轮最终文本。assistant_message 流丢失或 CLI 未发增量时,
|
|
519
610
|
// Web 用它作为 JSON 模式兜底展示,避免 turn 已结束但界面空白。
|
|
520
|
-
result:
|
|
611
|
+
result: z8.string().optional()
|
|
521
612
|
}, "proxy_to_client"),
|
|
522
613
|
// 客户端发送到 PTY 的原始字节(ANSI 序列),不追加换行
|
|
523
|
-
control("remote_input_raw", { sessionId: IdSchema, data:
|
|
614
|
+
control("remote_input_raw", { sessionId: IdSchema, data: z8.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
|
|
524
615
|
control("clipboard_image_upload", {
|
|
525
616
|
...RequestIdShape,
|
|
526
617
|
sessionId: IdSchema,
|
|
527
618
|
mimeType: ClipboardImageMimeTypeSchema,
|
|
528
|
-
dataBase64:
|
|
529
|
-
fileName:
|
|
619
|
+
dataBase64: z8.string().min(1),
|
|
620
|
+
fileName: z8.string().optional()
|
|
530
621
|
}, "client_to_proxy"),
|
|
531
622
|
control("clipboard_image_upload_response", {
|
|
532
623
|
...RequestIdShape,
|
|
533
624
|
...RequestErrorShape,
|
|
534
625
|
sessionId: IdSchema,
|
|
535
|
-
success:
|
|
626
|
+
success: z8.boolean(),
|
|
536
627
|
// success=false 时 proxy 没有有效 path 可填;保持 optional 以避免占位空字符串通过校验。
|
|
537
|
-
path:
|
|
628
|
+
path: z8.string().optional()
|
|
538
629
|
}, "proxy_to_client"),
|
|
539
630
|
control("image_preview_request", {
|
|
540
631
|
...RequestIdShape,
|
|
541
632
|
sessionId: IdSchema,
|
|
542
|
-
path:
|
|
633
|
+
path: z8.string().min(1)
|
|
543
634
|
}, "client_to_proxy"),
|
|
544
635
|
control("image_preview_response", {
|
|
545
636
|
...RequestIdShape,
|
|
546
637
|
...RequestErrorShape,
|
|
547
638
|
sessionId: IdSchema,
|
|
548
|
-
success:
|
|
639
|
+
success: z8.boolean(),
|
|
549
640
|
// 同 clipboard_image_upload_response:失败时 proxy 不一定有路径。
|
|
550
|
-
path:
|
|
641
|
+
path: z8.string().optional(),
|
|
551
642
|
mimeType: ClipboardImageMimeTypeSchema.optional(),
|
|
552
|
-
dataBase64:
|
|
553
|
-
size:
|
|
643
|
+
dataBase64: z8.string().optional(),
|
|
644
|
+
size: z8.number().int().nonnegative().optional()
|
|
554
645
|
}, "proxy_to_client"),
|
|
555
646
|
// 任意文件下载: 与 image_preview 形状对称, 只是 mimeType 不限定为图片;
|
|
556
647
|
// 单租户场景下 path 任意 (不受 previewRoots 限制), 由 proxy 端 size cap 兜底。
|
|
557
648
|
control("file_download_request", {
|
|
558
649
|
...RequestIdShape,
|
|
559
650
|
sessionId: IdSchema,
|
|
560
|
-
path:
|
|
651
|
+
path: z8.string().min(1)
|
|
561
652
|
}, "client_to_proxy"),
|
|
562
653
|
control("file_download_response", {
|
|
563
654
|
...RequestIdShape,
|
|
564
655
|
...RequestErrorShape,
|
|
565
656
|
sessionId: IdSchema,
|
|
566
|
-
success:
|
|
567
|
-
path:
|
|
568
|
-
mimeType:
|
|
569
|
-
dataBase64:
|
|
570
|
-
size:
|
|
657
|
+
success: z8.boolean(),
|
|
658
|
+
path: z8.string().optional(),
|
|
659
|
+
mimeType: z8.string().optional(),
|
|
660
|
+
dataBase64: z8.string().optional(),
|
|
661
|
+
size: z8.number().int().nonnegative().optional()
|
|
571
662
|
}, "proxy_to_client"),
|
|
572
663
|
// 任意文件上传: 复用 clipboard_image_upload 的形状, mimeType 放开 + fileName 必填,
|
|
573
664
|
// 由 proxy 端写入 session cwd 的 .dev-anywhere/uploads/ 子目录, 返回相对路径供 web 拼成 @path。
|
|
574
665
|
control("file_upload_request", {
|
|
575
666
|
...RequestIdShape,
|
|
576
667
|
sessionId: IdSchema,
|
|
577
|
-
mimeType:
|
|
578
|
-
dataBase64:
|
|
579
|
-
fileName:
|
|
668
|
+
mimeType: z8.string().min(1),
|
|
669
|
+
dataBase64: z8.string().min(1),
|
|
670
|
+
fileName: z8.string().min(1)
|
|
580
671
|
}, "client_to_proxy"),
|
|
581
672
|
control("file_upload_response", {
|
|
582
673
|
...RequestIdShape,
|
|
583
674
|
...RequestErrorShape,
|
|
584
675
|
sessionId: IdSchema,
|
|
585
|
-
success:
|
|
586
|
-
path:
|
|
676
|
+
success: z8.boolean(),
|
|
677
|
+
path: z8.string().optional()
|
|
587
678
|
}, "proxy_to_client"),
|
|
588
679
|
// 客户端询问 proxy 的环境信息 (home 路径等), client -> proxy -> response
|
|
589
680
|
// FilePathPicker 用 homePath 作为 select 模式下的默认起点, 新建会话时打开即可浏览
|
|
590
681
|
control("proxy_info_request", RequestIdShape, "client_to_proxy"),
|
|
591
|
-
control("proxy_info", { ...RequestIdShape, homePath:
|
|
592
|
-
control("agent_cli_config_update", { ...RequestIdShape, provider:
|
|
682
|
+
control("proxy_info", { ...RequestIdShape, homePath: z8.string(), agentCli: AgentCliStatusSchema }, "proxy_to_client"),
|
|
683
|
+
control("agent_cli_config_update", { ...RequestIdShape, provider: z8.enum(providerValues), path: z8.string().min(1) }, "client_to_proxy"),
|
|
593
684
|
control("agent_cli_config_update_response", {
|
|
594
685
|
...RequestIdShape,
|
|
595
|
-
provider:
|
|
686
|
+
provider: z8.enum(providerValues),
|
|
596
687
|
agentCli: AgentCliStatusSchema.optional(),
|
|
597
688
|
...RequestErrorShape
|
|
598
689
|
}, "proxy_to_client"),
|
|
599
690
|
// 远程创建 JSON 会话,client -> proxy -> response
|
|
600
691
|
control("session_create", {
|
|
601
692
|
...RequestIdShape,
|
|
602
|
-
cwd:
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
693
|
+
cwd: z8.string(),
|
|
694
|
+
name: z8.string().optional(),
|
|
695
|
+
provider: z8.enum(providerValues),
|
|
696
|
+
mode: z8.enum(sessionModeValues).optional(),
|
|
697
|
+
resumeSessionId: z8.string().optional(),
|
|
606
698
|
// 透传给 claude CLI 的 --permission-mode, undefined 时 proxy 兜底为 "default"
|
|
607
|
-
permissionMode:
|
|
699
|
+
permissionMode: z8.enum(["default", "auto", "acceptEdits", "plan", "bypassPermissions", "dontAsk"]).optional()
|
|
608
700
|
}, "client_to_proxy"),
|
|
609
701
|
control("session_create_response", {
|
|
610
702
|
...RequestIdShape,
|
|
611
703
|
// 失败路径只送 errorCode/error, sessionId 此时无语义。成功路径才有 id。
|
|
612
704
|
sessionId: IdSchema.optional(),
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
705
|
+
name: z8.string().optional(),
|
|
706
|
+
nameLocked: z8.boolean().optional(),
|
|
707
|
+
mode: z8.enum(sessionModeValues).optional(),
|
|
708
|
+
provider: z8.enum(providerValues).optional(),
|
|
709
|
+
ptyOwner: z8.enum(ptyOwnerValues).optional(),
|
|
616
710
|
...RequestErrorShape
|
|
617
711
|
}, "proxy_to_client"),
|
|
618
712
|
// 客户端请求会话历史消息,client -> proxy
|
|
619
713
|
control("session_messages_request", {
|
|
620
714
|
...RequestIdShape,
|
|
621
715
|
sessionId: IdSchema,
|
|
622
|
-
limit:
|
|
623
|
-
before:
|
|
716
|
+
limit: z8.number().int().min(1).max(200).optional(),
|
|
717
|
+
before: z8.string().optional()
|
|
624
718
|
}, "client_to_proxy"),
|
|
625
719
|
// 客户端请求会话资源(命令列表 + 文件树),client -> proxy
|
|
626
720
|
control("session_resources_request", { ...RequestIdShape, sessionId: IdSchema }, "client_to_proxy"),
|
|
@@ -628,14 +722,14 @@ var relayControlDefinitions = [
|
|
|
628
722
|
...RequestIdShape,
|
|
629
723
|
...RequestErrorShape,
|
|
630
724
|
sessionId: IdSchema,
|
|
631
|
-
commands:
|
|
632
|
-
groups:
|
|
725
|
+
commands: z8.array(CommandEntrySchema),
|
|
726
|
+
groups: z8.array(FileTreeGroupSchema)
|
|
633
727
|
}, "proxy_to_client"),
|
|
634
728
|
// 客户端请求当前 provider 语义状态;不经 relay 缓存,由 proxy 返回当前值
|
|
635
729
|
control("agent_status_request", { ...RequestIdShape, sessionId: IdSchema.optional() }, "client_to_proxy"),
|
|
636
730
|
control("agent_status_response", {
|
|
637
731
|
...RequestIdShape,
|
|
638
|
-
statuses:
|
|
732
|
+
statuses: z8.array(z8.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
|
|
639
733
|
}, "proxy_to_client"),
|
|
640
734
|
// 客户端确认已收到审批请求;proxy 只记录送达状态,不把它当成用户决策
|
|
641
735
|
control("permission_request_delivered", { sessionId: IdSchema, requestId: IdSchema }, "client_to_proxy"),
|
|
@@ -645,40 +739,56 @@ var relayControlDefinitions = [
|
|
|
645
739
|
control("permission_decision_result", {
|
|
646
740
|
sessionId: IdSchema,
|
|
647
741
|
requestId: IdSchema,
|
|
648
|
-
outcome:
|
|
649
|
-
delivered:
|
|
650
|
-
message:
|
|
742
|
+
outcome: z8.enum(["allow", "deny"]),
|
|
743
|
+
delivered: z8.boolean(),
|
|
744
|
+
message: z8.string().optional()
|
|
651
745
|
}, "proxy_to_client"),
|
|
652
746
|
// proxy 推送当前 pending 的工具审批列表,client 据此恢复审批卡片
|
|
653
747
|
control("pending_approvals_push", {
|
|
654
748
|
sessionId: IdSchema,
|
|
655
|
-
approvals:
|
|
749
|
+
approvals: z8.array(z8.object({
|
|
656
750
|
requestId: IdSchema,
|
|
657
|
-
toolName:
|
|
658
|
-
input:
|
|
751
|
+
toolName: z8.string(),
|
|
752
|
+
input: z8.record(z8.string(), z8.unknown())
|
|
659
753
|
}))
|
|
660
754
|
}, "proxy_to_client"),
|
|
755
|
+
// Voice Pilot speech summaries are produced by proxy-side Claude Code so it can read project context.
|
|
756
|
+
control("voice_summary_request", {
|
|
757
|
+
...RequestIdShape,
|
|
758
|
+
sessionId: IdSchema,
|
|
759
|
+
messageId: IdSchema,
|
|
760
|
+
text: z8.string().min(1),
|
|
761
|
+
reason: VoiceSummaryReasonSchema
|
|
762
|
+
}, "client_to_proxy"),
|
|
763
|
+
control("voice_summary_response", {
|
|
764
|
+
...RequestIdShape,
|
|
765
|
+
...RequestErrorShape,
|
|
766
|
+
sessionId: IdSchema,
|
|
767
|
+
messageId: IdSchema,
|
|
768
|
+
success: z8.boolean(),
|
|
769
|
+
summary: z8.string().min(1).optional()
|
|
770
|
+
}, "proxy_to_client"),
|
|
661
771
|
// 恢复会话时推送历史消息,proxy -> client
|
|
662
772
|
control("session_history_messages", {
|
|
663
773
|
...RequestIdShape,
|
|
664
774
|
sessionId: IdSchema,
|
|
665
|
-
before:
|
|
666
|
-
messages:
|
|
667
|
-
hasMore:
|
|
668
|
-
nextBefore:
|
|
775
|
+
before: z8.string().optional(),
|
|
776
|
+
messages: z8.array(SessionHistoryMessageSchema),
|
|
777
|
+
hasMore: z8.boolean().optional(),
|
|
778
|
+
nextBefore: z8.string().optional()
|
|
669
779
|
}, "proxy_to_client"),
|
|
670
780
|
// proxy 重连后同步活跃 session 列表给 relay。session_sync 由 relay 自消费(更新 proxy-session
|
|
671
781
|
// 关联)不转发给 client,因此**没有** direction 标注——RelayControlDirection 只描述转发流。
|
|
672
782
|
control("session_sync", {
|
|
673
|
-
sessions:
|
|
674
|
-
id:
|
|
675
|
-
mode:
|
|
676
|
-
provider:
|
|
677
|
-
ptyOwner:
|
|
678
|
-
cwd:
|
|
679
|
-
name:
|
|
680
|
-
nameLocked:
|
|
681
|
-
state:
|
|
783
|
+
sessions: z8.array(z8.object({
|
|
784
|
+
id: z8.string(),
|
|
785
|
+
mode: z8.enum(sessionModeValues),
|
|
786
|
+
provider: z8.enum(providerValues),
|
|
787
|
+
ptyOwner: z8.enum(ptyOwnerValues).optional(),
|
|
788
|
+
cwd: z8.string().optional(),
|
|
789
|
+
name: z8.string().optional(),
|
|
790
|
+
nameLocked: z8.boolean().optional(),
|
|
791
|
+
state: z8.enum(sessionStateValues)
|
|
682
792
|
}))
|
|
683
793
|
}),
|
|
684
794
|
// PTY 会话订阅,client -> proxy,触发 terminal serialize() 返回当前状态
|
|
@@ -686,15 +796,15 @@ var relayControlDefinitions = [
|
|
|
686
796
|
// PTY 会话快照,proxy -> client,serialize() 的全量终端状态
|
|
687
797
|
control("session_snapshot", {
|
|
688
798
|
sessionId: IdSchema,
|
|
689
|
-
cols:
|
|
690
|
-
rows:
|
|
691
|
-
data:
|
|
692
|
-
outputSeq:
|
|
799
|
+
cols: z8.number().int().positive(),
|
|
800
|
+
rows: z8.number().int().positive(),
|
|
801
|
+
data: z8.string(),
|
|
802
|
+
outputSeq: z8.number().int().nonnegative(),
|
|
693
803
|
requestId: IdSchema.optional()
|
|
694
804
|
}, "proxy_to_client")
|
|
695
805
|
];
|
|
696
806
|
var relayControlSchemas = relayControlDefinitions.map((definition) => definition.schema);
|
|
697
|
-
var RelayControlSchema =
|
|
807
|
+
var RelayControlSchema = z8.discriminatedUnion("type", relayControlSchemas);
|
|
698
808
|
var ProxyToClientRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("proxy_to_client")).map((definition) => definition.type));
|
|
699
809
|
var ClientToProxyRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("client_to_proxy")).map((definition) => definition.type));
|
|
700
810
|
|
|
@@ -743,7 +853,7 @@ function decodeBinaryFrame(view) {
|
|
|
743
853
|
}
|
|
744
854
|
|
|
745
855
|
// src/ipc/ipc-protocol.ts
|
|
746
|
-
import { z as
|
|
856
|
+
import { z as z9 } from "zod";
|
|
747
857
|
|
|
748
858
|
// src/ipc/line-buffer.ts
|
|
749
859
|
import { Transform } from "stream";
|
|
@@ -784,203 +894,204 @@ function encodeBinaryIpcFrame(sessionId, data, outputSeq) {
|
|
|
784
894
|
return frame;
|
|
785
895
|
}
|
|
786
896
|
var sessionStateValues2 = Object.values(SessionState);
|
|
787
|
-
var ProviderHookContextSchema =
|
|
788
|
-
provider:
|
|
789
|
-
sessionId:
|
|
790
|
-
hookUrl:
|
|
791
|
-
marker:
|
|
792
|
-
token:
|
|
897
|
+
var ProviderHookContextSchema = z9.object({
|
|
898
|
+
provider: z9.enum(["claude", "codex"]),
|
|
899
|
+
sessionId: z9.string(),
|
|
900
|
+
hookUrl: z9.string(),
|
|
901
|
+
marker: z9.string(),
|
|
902
|
+
token: z9.string()
|
|
793
903
|
});
|
|
794
|
-
var IpcMessageSchema =
|
|
904
|
+
var IpcMessageSchema = z9.discriminatedUnion("type", [
|
|
795
905
|
// 客户端请求创建新会话,sessionId 可选用于重连时复用
|
|
796
|
-
|
|
797
|
-
type:
|
|
798
|
-
name:
|
|
799
|
-
mode:
|
|
800
|
-
provider:
|
|
801
|
-
cwd:
|
|
802
|
-
pid:
|
|
803
|
-
sessionId:
|
|
906
|
+
z9.object({
|
|
907
|
+
type: z9.literal("session_create_request"),
|
|
908
|
+
name: z9.string().optional(),
|
|
909
|
+
mode: z9.enum(["pty", "json"]),
|
|
910
|
+
provider: z9.enum(["claude", "codex"]),
|
|
911
|
+
cwd: z9.string(),
|
|
912
|
+
pid: z9.number(),
|
|
913
|
+
sessionId: z9.string().optional()
|
|
804
914
|
}),
|
|
805
915
|
// 服务端响应创建会话
|
|
806
|
-
|
|
807
|
-
type:
|
|
808
|
-
sessionId:
|
|
809
|
-
error:
|
|
916
|
+
z9.object({
|
|
917
|
+
type: z9.literal("session_create_response"),
|
|
918
|
+
sessionId: z9.string(),
|
|
919
|
+
error: z9.string().optional(),
|
|
810
920
|
hook: ProviderHookContextSchema.optional()
|
|
811
921
|
}),
|
|
812
922
|
// 客户端请求终止会话
|
|
813
|
-
|
|
814
|
-
type:
|
|
815
|
-
sessionId:
|
|
923
|
+
z9.object({
|
|
924
|
+
type: z9.literal("session_terminate_request"),
|
|
925
|
+
sessionId: z9.string()
|
|
816
926
|
}),
|
|
817
927
|
// 服务端响应终止会话
|
|
818
|
-
|
|
819
|
-
type:
|
|
820
|
-
sessionId:
|
|
821
|
-
success:
|
|
928
|
+
z9.object({
|
|
929
|
+
type: z9.literal("session_terminate_response"),
|
|
930
|
+
sessionId: z9.string(),
|
|
931
|
+
success: z9.boolean()
|
|
822
932
|
}),
|
|
823
933
|
// 客户端向服务端注册 PTY 会话
|
|
824
|
-
|
|
825
|
-
type:
|
|
826
|
-
sessionId:
|
|
827
|
-
pid:
|
|
934
|
+
z9.object({
|
|
935
|
+
type: z9.literal("pty_register"),
|
|
936
|
+
sessionId: z9.string(),
|
|
937
|
+
pid: z9.number()
|
|
828
938
|
}),
|
|
829
939
|
// 客户端取消注册 PTY 会话
|
|
830
|
-
|
|
831
|
-
type:
|
|
832
|
-
sessionId:
|
|
940
|
+
z9.object({
|
|
941
|
+
type: z9.literal("pty_deregister"),
|
|
942
|
+
sessionId: z9.string()
|
|
833
943
|
}),
|
|
834
944
|
// 输入,从服务端转发到客户端的 PTY stdin(手机远程输入注入)
|
|
835
|
-
|
|
836
|
-
type:
|
|
837
|
-
sessionId:
|
|
838
|
-
data:
|
|
945
|
+
z9.object({
|
|
946
|
+
type: z9.literal("pty_input"),
|
|
947
|
+
sessionId: z9.string(),
|
|
948
|
+
data: z9.string(),
|
|
949
|
+
traceId: z9.string().optional()
|
|
839
950
|
}),
|
|
840
951
|
// serve → terminal:Web 端移除本地终端会话时,只断开远程视图,不杀本地 CLI。
|
|
841
|
-
|
|
842
|
-
type:
|
|
843
|
-
sessionId:
|
|
952
|
+
z9.object({
|
|
953
|
+
type: z9.literal("pty_detach"),
|
|
954
|
+
sessionId: z9.string()
|
|
844
955
|
}),
|
|
845
956
|
// 服务端广播会话状态变更
|
|
846
|
-
|
|
847
|
-
type:
|
|
848
|
-
sessionId:
|
|
849
|
-
state:
|
|
957
|
+
z9.object({
|
|
958
|
+
type: z9.literal("session_status_update"),
|
|
959
|
+
sessionId: z9.string(),
|
|
960
|
+
state: z9.enum(sessionStateValues2)
|
|
850
961
|
}),
|
|
851
962
|
// 错误响应
|
|
852
|
-
|
|
853
|
-
type:
|
|
854
|
-
message:
|
|
855
|
-
code:
|
|
963
|
+
z9.object({
|
|
964
|
+
type: z9.literal("error"),
|
|
965
|
+
message: z9.string(),
|
|
966
|
+
code: z9.string().optional()
|
|
856
967
|
}),
|
|
857
968
|
// 客户端请求服务状态(含 relay 连接信息和 worker 状态)
|
|
858
|
-
|
|
859
|
-
type:
|
|
969
|
+
z9.object({
|
|
970
|
+
type: z9.literal("service_status_request")
|
|
860
971
|
}),
|
|
861
972
|
// 服务端响应增强版服务状态
|
|
862
|
-
|
|
863
|
-
type:
|
|
864
|
-
config:
|
|
865
|
-
profile:
|
|
866
|
-
relayName:
|
|
867
|
-
relayNameSource:
|
|
868
|
-
relayUrl:
|
|
869
|
-
relayUrlSource:
|
|
870
|
-
relayTokenSource:
|
|
871
|
-
hookPort:
|
|
872
|
-
hookPortSource:
|
|
973
|
+
z9.object({
|
|
974
|
+
type: z9.literal("service_status_response"),
|
|
975
|
+
config: z9.object({
|
|
976
|
+
profile: z9.string().optional(),
|
|
977
|
+
relayName: z9.string(),
|
|
978
|
+
relayNameSource: z9.enum(["cli", "profile"]),
|
|
979
|
+
relayUrl: z9.string().optional(),
|
|
980
|
+
relayUrlSource: z9.enum(["env", "file", "none"]),
|
|
981
|
+
relayTokenSource: z9.enum(["env", "file", "none"]),
|
|
982
|
+
hookPort: z9.number(),
|
|
983
|
+
hookPortSource: z9.enum(["env", "file", "default"])
|
|
873
984
|
}),
|
|
874
|
-
relay:
|
|
875
|
-
connected:
|
|
876
|
-
proxyId:
|
|
877
|
-
reconnectAttempt:
|
|
878
|
-
queueDepth:
|
|
985
|
+
relay: z9.object({
|
|
986
|
+
connected: z9.boolean(),
|
|
987
|
+
proxyId: z9.string(),
|
|
988
|
+
reconnectAttempt: z9.number(),
|
|
989
|
+
queueDepth: z9.number()
|
|
879
990
|
}).nullable(),
|
|
880
|
-
sessions:
|
|
881
|
-
|
|
882
|
-
id:
|
|
883
|
-
mode:
|
|
884
|
-
state:
|
|
885
|
-
createdAt:
|
|
886
|
-
name:
|
|
887
|
-
hasWorker:
|
|
991
|
+
sessions: z9.array(
|
|
992
|
+
z9.object({
|
|
993
|
+
id: z9.string(),
|
|
994
|
+
mode: z9.enum(["pty", "json"]),
|
|
995
|
+
state: z9.enum(sessionStateValues2),
|
|
996
|
+
createdAt: z9.string(),
|
|
997
|
+
name: z9.string().optional(),
|
|
998
|
+
hasWorker: z9.boolean()
|
|
888
999
|
})
|
|
889
1000
|
)
|
|
890
1001
|
}),
|
|
891
1002
|
// terminal → serve:终端标题变化,由 xterm onTitleChange 触发
|
|
892
|
-
|
|
893
|
-
type:
|
|
894
|
-
sessionId:
|
|
895
|
-
title:
|
|
1003
|
+
z9.object({
|
|
1004
|
+
type: z9.literal("pty_title_change"),
|
|
1005
|
+
sessionId: z9.string(),
|
|
1006
|
+
title: z9.string()
|
|
896
1007
|
}),
|
|
897
1008
|
// terminal → serve:local runtime 观察到的 PTY 语义事件。
|
|
898
|
-
|
|
899
|
-
type:
|
|
900
|
-
sessionId:
|
|
901
|
-
state:
|
|
902
|
-
title:
|
|
903
|
-
tool:
|
|
1009
|
+
z9.object({
|
|
1010
|
+
type: z9.literal("pty_semantic_event"),
|
|
1011
|
+
sessionId: z9.string(),
|
|
1012
|
+
state: z9.enum(ptySemanticStateValues),
|
|
1013
|
+
title: z9.string().optional(),
|
|
1014
|
+
tool: z9.string().optional()
|
|
904
1015
|
}),
|
|
905
1016
|
// terminal → serve:终端尺寸变化
|
|
906
|
-
|
|
907
|
-
type:
|
|
908
|
-
sessionId:
|
|
909
|
-
cols:
|
|
910
|
-
rows:
|
|
1017
|
+
z9.object({
|
|
1018
|
+
type: z9.literal("pty_resize"),
|
|
1019
|
+
sessionId: z9.string(),
|
|
1020
|
+
cols: z9.number(),
|
|
1021
|
+
rows: z9.number()
|
|
911
1022
|
}),
|
|
912
1023
|
// serve → terminal:请求 HeadlessTerminal serialize() 快照
|
|
913
|
-
|
|
914
|
-
type:
|
|
915
|
-
sessionId:
|
|
916
|
-
requestId:
|
|
1024
|
+
z9.object({
|
|
1025
|
+
type: z9.literal("pty_subscribe"),
|
|
1026
|
+
sessionId: z9.string(),
|
|
1027
|
+
requestId: z9.string().optional()
|
|
917
1028
|
}),
|
|
918
1029
|
// terminal → serve:serialize() 结果
|
|
919
|
-
|
|
920
|
-
type:
|
|
921
|
-
sessionId:
|
|
922
|
-
cols:
|
|
923
|
-
rows:
|
|
924
|
-
data:
|
|
925
|
-
outputSeq:
|
|
926
|
-
requestId:
|
|
1030
|
+
z9.object({
|
|
1031
|
+
type: z9.literal("pty_snapshot"),
|
|
1032
|
+
sessionId: z9.string(),
|
|
1033
|
+
cols: z9.number(),
|
|
1034
|
+
rows: z9.number(),
|
|
1035
|
+
data: z9.string(),
|
|
1036
|
+
outputSeq: z9.number().int().nonnegative(),
|
|
1037
|
+
requestId: z9.string().optional()
|
|
927
1038
|
}),
|
|
928
1039
|
// serve → terminal:relay 连接状态变更,供终端给用户显示 remote viewing 是否通畅
|
|
929
|
-
|
|
930
|
-
type:
|
|
931
|
-
connected:
|
|
1040
|
+
z9.object({
|
|
1041
|
+
type: z9.literal("bridge_status"),
|
|
1042
|
+
connected: z9.boolean()
|
|
932
1043
|
})
|
|
933
1044
|
]);
|
|
934
|
-
var WorkerMessageSchema =
|
|
1045
|
+
var WorkerMessageSchema = z9.discriminatedUnion("type", [
|
|
935
1046
|
// serve → worker: 发送用户输入给 claude
|
|
936
|
-
|
|
937
|
-
type:
|
|
938
|
-
content:
|
|
1047
|
+
z9.object({
|
|
1048
|
+
type: z9.literal("worker_input"),
|
|
1049
|
+
content: z9.string()
|
|
939
1050
|
}),
|
|
940
1051
|
// serve → worker: 停止 claude 进程
|
|
941
|
-
|
|
942
|
-
type:
|
|
1052
|
+
z9.object({
|
|
1053
|
+
type: z9.literal("worker_stop")
|
|
943
1054
|
}),
|
|
944
1055
|
// serve → worker: 工具审批响应
|
|
945
|
-
|
|
946
|
-
type:
|
|
947
|
-
requestId:
|
|
948
|
-
behavior:
|
|
949
|
-
message:
|
|
1056
|
+
z9.object({
|
|
1057
|
+
type: z9.literal("worker_approval_response"),
|
|
1058
|
+
requestId: z9.string(),
|
|
1059
|
+
behavior: z9.enum(["allow", "deny"]),
|
|
1060
|
+
message: z9.string().optional()
|
|
950
1061
|
}),
|
|
951
1062
|
// worker → serve: claude 输出事件(带序列号)
|
|
952
|
-
|
|
953
|
-
type:
|
|
954
|
-
seq:
|
|
955
|
-
event:
|
|
1063
|
+
z9.object({
|
|
1064
|
+
type: z9.literal("worker_event"),
|
|
1065
|
+
seq: z9.number(),
|
|
1066
|
+
event: z9.record(z9.string(), z9.unknown())
|
|
956
1067
|
}),
|
|
957
1068
|
// worker → serve: claude 进程退出
|
|
958
|
-
|
|
959
|
-
type:
|
|
960
|
-
code:
|
|
1069
|
+
z9.object({
|
|
1070
|
+
type: z9.literal("worker_exit"),
|
|
1071
|
+
code: z9.number()
|
|
961
1072
|
}),
|
|
962
1073
|
// worker → serve: 工具审批请求
|
|
963
|
-
|
|
964
|
-
type:
|
|
965
|
-
requestId:
|
|
966
|
-
toolName:
|
|
967
|
-
input:
|
|
1074
|
+
z9.object({
|
|
1075
|
+
type: z9.literal("worker_approval_request"),
|
|
1076
|
+
requestId: z9.string(),
|
|
1077
|
+
toolName: z9.string(),
|
|
1078
|
+
input: z9.record(z9.string(), z9.unknown())
|
|
968
1079
|
}),
|
|
969
1080
|
// worker → serve: worker 就绪,claude 已启动
|
|
970
|
-
|
|
971
|
-
type:
|
|
972
|
-
pid:
|
|
1081
|
+
z9.object({
|
|
1082
|
+
type: z9.literal("worker_ready"),
|
|
1083
|
+
pid: z9.number()
|
|
973
1084
|
}),
|
|
974
1085
|
// worker → serve: 从 stream-json 的 system.init 事件捕获 Claude CLI 侧的 session ID
|
|
975
1086
|
// proxy 拿它来读 ~/.claude/projects/.../<id>.jsonl 历史或后续 --resume
|
|
976
|
-
|
|
977
|
-
type:
|
|
978
|
-
sessionId:
|
|
1087
|
+
z9.object({
|
|
1088
|
+
type: z9.literal("worker_claude_session_id"),
|
|
1089
|
+
sessionId: z9.string()
|
|
979
1090
|
}),
|
|
980
1091
|
// serve → worker: 将指定工具加入会话白名单,后续同名工具自动审批
|
|
981
|
-
|
|
982
|
-
type:
|
|
983
|
-
toolName:
|
|
1092
|
+
z9.object({
|
|
1093
|
+
type: z9.literal("worker_whitelist_add"),
|
|
1094
|
+
toolName: z9.string()
|
|
984
1095
|
})
|
|
985
1096
|
]);
|
|
986
1097
|
function serializeWorkerMsg(msg) {
|
|
@@ -1080,4 +1191,4 @@ export {
|
|
|
1080
1191
|
serializeIpc,
|
|
1081
1192
|
createIpcReader
|
|
1082
1193
|
};
|
|
1083
|
-
//# sourceMappingURL=chunk-
|
|
1194
|
+
//# sourceMappingURL=chunk-IFQSVDHB.js.map
|