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