@dev-anywhere/proxy 0.4.84 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +12 -3
  2. package/dist/{chunk-2JSCH6DW.js → chunk-5OJB4FGI.js} +11 -4
  3. package/dist/chunk-5OJB4FGI.js.map +1 -0
  4. package/dist/{chunk-RYUEUDBR.js → chunk-5WZ6B735.js} +9 -6
  5. package/dist/chunk-5WZ6B735.js.map +1 -0
  6. package/dist/{chunk-LWDOXOWY.js → chunk-CN7UT6KW.js} +3 -80
  7. package/dist/chunk-CN7UT6KW.js.map +1 -0
  8. package/dist/{chunk-B3GHP25U.js → chunk-F53HQ6GP.js} +14 -2
  9. package/dist/chunk-F53HQ6GP.js.map +1 -0
  10. package/dist/chunk-NOUZTHUN.js +86 -0
  11. package/dist/chunk-NOUZTHUN.js.map +1 -0
  12. package/dist/{chunk-6ESPTMAZ.js → chunk-OEXRT54F.js} +6 -6
  13. package/dist/{chunk-ENXGI3FO.js → chunk-RSJKBUBY.js} +387 -332
  14. package/dist/chunk-RSJKBUBY.js.map +1 -0
  15. package/dist/index.js +21 -6
  16. package/dist/index.js.map +1 -1
  17. package/dist/quick-tunnel-MO3U67K3.js +318 -0
  18. package/dist/quick-tunnel-MO3U67K3.js.map +1 -0
  19. package/dist/{relay-token-QD7ULGNS.js → relay-token-X7NWRMKV.js} +4 -3
  20. package/dist/{relay-token-QD7ULGNS.js.map → relay-token-X7NWRMKV.js.map} +1 -1
  21. package/dist/serve.js +428 -212
  22. package/dist/serve.js.map +1 -1
  23. package/dist/session-worker.js +2 -27
  24. package/dist/session-worker.js.map +1 -1
  25. package/dist/{terminal-EUZKQXTH.js → terminal-4EXLE5C7.js} +27 -19
  26. package/dist/terminal-4EXLE5C7.js.map +1 -0
  27. package/dist/terminal-worker.js +55 -12
  28. package/dist/terminal-worker.js.map +1 -1
  29. package/package.json +4 -4
  30. package/dist/chunk-2JSCH6DW.js.map +0 -1
  31. package/dist/chunk-B3GHP25U.js.map +0 -1
  32. package/dist/chunk-ENXGI3FO.js.map +0 -1
  33. package/dist/chunk-LWDOXOWY.js.map +0 -1
  34. package/dist/chunk-RYUEUDBR.js.map +0 -1
  35. package/dist/terminal-EUZKQXTH.js.map +0 -1
  36. /package/dist/{chunk-6ESPTMAZ.js.map → chunk-OEXRT54F.js.map} +0 -0
@@ -383,13 +383,56 @@ var VoiceSummaryReasonSchema = z7.enum([
383
383
  "approval"
384
384
  ]);
385
385
 
386
+ // ../../packages/shared/dist/schemas/voice-stream.js
387
+ import { z as z8 } from "zod";
388
+ var VoiceAsrAudioEncodingSchema = z8.enum(["pcm_s16le", "mulaw"]);
389
+ var VoiceAsrStartMessageSchema = z8.object({
390
+ type: z8.literal("start"),
391
+ sessionId: z8.string().min(1),
392
+ attemptId: z8.string().min(1),
393
+ sampleRate: z8.number().int().positive(),
394
+ encoding: VoiceAsrAudioEncodingSchema
395
+ });
396
+ var VoiceAsrStopMessageSchema = z8.object({
397
+ type: z8.literal("stop"),
398
+ attemptId: z8.string().min(1)
399
+ });
400
+ var VoiceAsrClientMessageSchema = z8.discriminatedUnion("type", [
401
+ VoiceAsrStartMessageSchema,
402
+ VoiceAsrStopMessageSchema
403
+ ]);
404
+ var VoiceAsrServerMessageSchema = z8.discriminatedUnion("type", [
405
+ z8.object({ type: z8.literal("ready"), attemptId: z8.string().min(1) }),
406
+ z8.object({
407
+ type: z8.literal("audio_ack"),
408
+ attemptId: z8.string().min(1),
409
+ encodedBytes: z8.number().int().nonnegative(),
410
+ pcmBytes: z8.number().int().nonnegative(),
411
+ chunks: z8.number().int().nonnegative()
412
+ }),
413
+ z8.object({ type: z8.literal("partial"), attemptId: z8.string().min(1), text: z8.string() }),
414
+ z8.object({ type: z8.literal("final"), attemptId: z8.string().min(1), text: z8.string() }),
415
+ z8.object({
416
+ type: z8.literal("closed"),
417
+ attemptId: z8.string().min(1),
418
+ code: z8.number().int().optional(),
419
+ reason: z8.string().optional()
420
+ }),
421
+ z8.object({
422
+ type: z8.literal("error"),
423
+ attemptId: z8.string().min(1),
424
+ error: z8.string().optional(),
425
+ errorCode: z8.string().optional()
426
+ })
427
+ ]);
428
+
386
429
  // ../../packages/shared/dist/slash-commands.js
387
430
  function isCompactCommandText(text) {
388
431
  return /^\/compact(?:\s|$)/.test(text.trimStart());
389
432
  }
390
433
 
391
434
  // ../../packages/shared/dist/schemas/relay-control.js
392
- import { z as z8 } from "zod";
435
+ import { z as z9 } from "zod";
393
436
 
394
437
  // ../../packages/shared/dist/constants/relay-errors.js
395
438
  var RelayErrorCode = {
@@ -416,75 +459,75 @@ var ControlErrorCode = {
416
459
  };
417
460
 
418
461
  // ../../packages/shared/dist/schemas/relay-control.js
419
- var ProxyInfoSchema = z8.object({
462
+ var ProxyInfoSchema = z9.object({
420
463
  proxyId: IdSchema,
421
- name: z8.string().optional(),
422
- online: z8.boolean(),
423
- sessions: z8.array(z8.string()).optional()
464
+ name: z9.string().optional(),
465
+ online: z9.boolean(),
466
+ sessions: z9.array(z9.string()).optional()
424
467
  });
425
- var RelayClientInfoSchema = z8.object({
468
+ var RelayClientInfoSchema = z9.object({
426
469
  clientId: IdSchema,
427
470
  proxyId: IdSchema.optional(),
428
- connectedAt: z8.number().int().nonnegative(),
429
- current: z8.boolean().optional(),
430
- userAgent: z8.string().optional(),
431
- platform: z8.string().optional(),
432
- maxTouchPoints: z8.number().int().nonnegative().optional(),
433
- browserName: z8.string().min(1),
434
- osName: z8.string().min(1),
435
- deviceKind: z8.enum(["desktop", "tablet", "phone", "unknown"]),
436
- remoteAddress: z8.string().optional()
471
+ connectedAt: z9.number().int().nonnegative(),
472
+ current: z9.boolean().optional(),
473
+ userAgent: z9.string().optional(),
474
+ platform: z9.string().optional(),
475
+ maxTouchPoints: z9.number().int().nonnegative().optional(),
476
+ browserName: z9.string().min(1),
477
+ osName: z9.string().min(1),
478
+ deviceKind: z9.enum(["desktop", "tablet", "phone", "unknown"]),
479
+ remoteAddress: z9.string().optional()
437
480
  });
438
- var AgentCliAvailabilitySchema = z8.object({
439
- available: z8.boolean(),
440
- command: z8.string().optional(),
441
- error: z8.string().optional(),
442
- suggestions: z8.array(z8.string()).optional()
481
+ var AgentCliAvailabilitySchema = z9.object({
482
+ available: z9.boolean(),
483
+ command: z9.string().optional(),
484
+ error: z9.string().optional(),
485
+ suggestions: z9.array(z9.string()).optional()
443
486
  });
444
- var AgentCliStatusSchema = z8.object({
487
+ var AgentCliStatusSchema = z9.object({
445
488
  claude: AgentCliAvailabilitySchema,
446
489
  codex: AgentCliAvailabilitySchema
447
490
  });
448
- var DirEntrySchema = z8.object({ name: z8.string(), isDir: z8.boolean() });
449
- var FileTreeGroupSchema = z8.object({
450
- path: z8.string(),
451
- entries: z8.array(DirEntrySchema)
491
+ var DirEntrySchema = z9.object({ name: z9.string(), isDir: z9.boolean() });
492
+ var FileTreeGroupSchema = z9.object({
493
+ path: z9.string(),
494
+ entries: z9.array(DirEntrySchema)
452
495
  });
453
- var CommandEntrySchema = z8.object({
454
- name: z8.string(),
455
- description: z8.string(),
456
- argumentHint: z8.string().optional(),
457
- source: z8.string()
496
+ var CommandEntrySchema = z9.object({
497
+ name: z9.string(),
498
+ description: z9.string(),
499
+ argumentHint: z9.string().optional(),
500
+ source: z9.string()
458
501
  });
459
- var HistorySessionSchema = z8.object({
460
- id: z8.string(),
461
- title: z8.string(),
462
- projectDir: z8.string(),
463
- updatedAt: z8.number(),
464
- provider: z8.enum(providerValues).optional(),
465
- preferredMode: z8.enum(sessionModeValues).optional()
502
+ var HistorySessionSchema = z9.object({
503
+ id: z9.string(),
504
+ title: z9.string(),
505
+ projectDir: z9.string(),
506
+ updatedAt: z9.number(),
507
+ provider: z9.enum(providerValues).optional(),
508
+ preferredMode: z9.enum(sessionModeValues).optional()
466
509
  });
467
- var SessionHistoryMessageSchema = z8.object({
468
- role: z8.enum(["user", "assistant", "system"]),
469
- text: z8.string(),
470
- timestamp: z8.number().optional(),
471
- cursor: z8.string().optional()
510
+ var SessionHistoryMessageSchema = z9.object({
511
+ role: z9.enum(["user", "assistant", "system"]),
512
+ text: z9.string(),
513
+ timestamp: z9.number().optional(),
514
+ cursor: z9.string().optional()
472
515
  });
473
516
  var RequestIdShape = { requestId: IdSchema.optional() };
474
517
  var RequiredRequestIdShape = { requestId: IdSchema };
475
- var ControlErrorCodeSchema = z8.enum(Object.values(ControlErrorCode));
518
+ var ControlErrorCodeSchema = z9.enum(Object.values(ControlErrorCode));
476
519
  var RequestErrorShape = {
477
- error: z8.string().optional(),
520
+ error: z9.string().optional(),
478
521
  errorCode: ControlErrorCodeSchema.optional()
479
522
  };
480
- var RemoteFileDispositionSchema = z8.enum(["inline", "download"]);
481
- var RemoteFileUploadKindSchema = z8.enum(["clipboard_image", "file"]);
523
+ var RemoteFileDispositionSchema = z9.enum(["inline", "download"]);
524
+ var RemoteFileUploadKindSchema = z9.enum(["clipboard_image", "file"]);
482
525
  function control(type, shape, directions) {
483
526
  return {
484
527
  type,
485
528
  directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
486
- schema: z8.object({
487
- type: z8.literal(type),
529
+ schema: z9.object({
530
+ type: z9.literal(type),
488
531
  ...shape ?? {}
489
532
  })
490
533
  };
@@ -492,81 +535,81 @@ function control(type, shape, directions) {
492
535
  var relayControlDefinitions = [
493
536
  control("proxy_register", {
494
537
  proxyId: IdSchema,
495
- name: z8.string().optional()
538
+ name: z9.string().optional()
496
539
  }),
497
540
  control("proxy_register_response", {
498
- status: z8.enum(["new", "reconnected"])
541
+ status: z9.enum(["new", "reconnected"])
499
542
  }),
500
543
  control("proxy_list_request", RequestIdShape),
501
544
  control("proxy_list_response", {
502
545
  ...RequestIdShape,
503
- proxies: z8.array(ProxyInfoSchema)
546
+ proxies: z9.array(ProxyInfoSchema)
504
547
  }),
505
548
  control("relay_client_list_request", RequestIdShape),
506
549
  control("relay_client_list_response", {
507
550
  ...RequestIdShape,
508
- clients: z8.array(RelayClientInfoSchema)
551
+ clients: z9.array(RelayClientInfoSchema)
509
552
  }),
510
553
  control("relay_client_kick", { ...RequiredRequestIdShape, clientId: IdSchema }),
511
554
  control("relay_client_kick_response", {
512
555
  ...RequiredRequestIdShape,
513
556
  clientId: IdSchema,
514
- success: z8.boolean(),
557
+ success: z9.boolean(),
515
558
  ...RequestErrorShape
516
559
  }),
517
560
  control("relay_client_kicked", {
518
- reason: z8.string().optional()
561
+ reason: z9.string().optional()
519
562
  }),
520
563
  control("remote_file_url_request", {
521
564
  ...RequiredRequestIdShape,
522
565
  sessionId: IdSchema,
523
- path: z8.string().min(1),
566
+ path: z9.string().min(1),
524
567
  disposition: RemoteFileDispositionSchema
525
568
  }),
526
569
  control("remote_file_url_response", {
527
570
  ...RequiredRequestIdShape,
528
571
  ...RequestErrorShape,
529
572
  sessionId: IdSchema,
530
- path: z8.string().optional(),
531
- success: z8.boolean(),
532
- url: z8.string().optional(),
533
- expiresAt: z8.number().int().nonnegative().optional()
573
+ path: z9.string().optional(),
574
+ success: z9.boolean(),
575
+ url: z9.string().optional(),
576
+ expiresAt: z9.number().int().nonnegative().optional()
534
577
  }),
535
578
  control("remote_file_metadata_request", {
536
579
  ...RequiredRequestIdShape,
537
580
  sessionId: IdSchema,
538
- path: z8.string().min(1)
581
+ path: z9.string().min(1)
539
582
  }),
540
583
  control("remote_file_metadata_response", {
541
584
  ...RequiredRequestIdShape,
542
585
  ...RequestErrorShape,
543
586
  sessionId: IdSchema,
544
- path: z8.string().optional(),
545
- success: z8.boolean(),
546
- mimeType: z8.string().optional(),
547
- size: z8.number().int().nonnegative().optional(),
548
- fileName: z8.string().optional()
587
+ path: z9.string().optional(),
588
+ success: z9.boolean(),
589
+ mimeType: z9.string().optional(),
590
+ size: z9.number().int().nonnegative().optional(),
591
+ fileName: z9.string().optional()
549
592
  }),
550
593
  control("remote_file_stream_request", {
551
594
  streamId: IdSchema,
552
595
  sessionId: IdSchema,
553
- path: z8.string().min(1),
596
+ path: z9.string().min(1),
554
597
  disposition: RemoteFileDispositionSchema
555
598
  }),
556
599
  control("remote_file_stream_response", {
557
600
  ...RequestErrorShape,
558
601
  streamId: IdSchema,
559
602
  sessionId: IdSchema,
560
- success: z8.boolean(),
561
- path: z8.string().optional(),
562
- mimeType: z8.string().optional(),
563
- size: z8.number().int().nonnegative().optional(),
564
- fileName: z8.string().optional()
603
+ success: z9.boolean(),
604
+ path: z9.string().optional(),
605
+ mimeType: z9.string().optional(),
606
+ size: z9.number().int().nonnegative().optional(),
607
+ fileName: z9.string().optional()
565
608
  }),
566
609
  control("remote_file_stream_complete", {
567
610
  ...RequestErrorShape,
568
611
  streamId: IdSchema,
569
- success: z8.boolean()
612
+ success: z9.boolean()
570
613
  }),
571
614
  control("remote_file_stream_cancel", {
572
615
  streamId: IdSchema
@@ -575,25 +618,25 @@ var relayControlDefinitions = [
575
618
  ...RequiredRequestIdShape,
576
619
  sessionId: IdSchema,
577
620
  kind: RemoteFileUploadKindSchema,
578
- fileName: z8.string().optional(),
579
- mimeType: z8.string().min(1),
580
- size: z8.number().int().nonnegative().optional()
621
+ fileName: z9.string().optional(),
622
+ mimeType: z9.string().min(1),
623
+ size: z9.number().int().nonnegative().optional()
581
624
  }),
582
625
  control("remote_file_upload_url_response", {
583
626
  ...RequiredRequestIdShape,
584
627
  ...RequestErrorShape,
585
628
  sessionId: IdSchema,
586
- success: z8.boolean(),
587
- uploadUrl: z8.string().optional(),
588
- expiresAt: z8.number().int().nonnegative().optional()
629
+ success: z9.boolean(),
630
+ uploadUrl: z9.string().optional(),
631
+ expiresAt: z9.number().int().nonnegative().optional()
589
632
  }),
590
633
  control("remote_file_upload_stream_request", {
591
634
  uploadId: IdSchema,
592
635
  sessionId: IdSchema,
593
636
  kind: RemoteFileUploadKindSchema,
594
- fileName: z8.string().optional(),
595
- mimeType: z8.string().min(1),
596
- size: z8.number().int().nonnegative().optional()
637
+ fileName: z9.string().optional(),
638
+ mimeType: z9.string().min(1),
639
+ size: z9.number().int().nonnegative().optional()
597
640
  }),
598
641
  control("remote_file_upload_stream_complete", {
599
642
  uploadId: IdSchema
@@ -605,19 +648,19 @@ var relayControlDefinitions = [
605
648
  ...RequestErrorShape,
606
649
  uploadId: IdSchema,
607
650
  sessionId: IdSchema,
608
- success: z8.boolean(),
609
- path: z8.string().optional()
651
+ success: z9.boolean(),
652
+ path: z9.string().optional()
610
653
  }),
611
654
  control("proxy_select", { ...RequestIdShape, proxyId: IdSchema }),
612
655
  control("proxy_select_response", {
613
656
  ...RequestIdShape,
614
- success: z8.boolean(),
657
+ success: z9.boolean(),
615
658
  proxyId: IdSchema.optional(),
616
659
  ...RequestErrorShape
617
660
  }),
618
661
  control("relay_error", {
619
- code: z8.enum(Object.values(RelayErrorCode)),
620
- message: z8.string(),
662
+ code: z9.enum(Object.values(RelayErrorCode)),
663
+ message: z9.string(),
621
664
  // 可选 requestId: relay 把 client 发来 raw 的 requestId 字段透传回来,
622
665
  // client 侧 waitForMessage 据此把对应 pending request 立即拒掉而不必等到 timeout。
623
666
  requestId: IdSchema.optional()
@@ -636,7 +679,7 @@ var relayControlDefinitions = [
636
679
  control("voice_config_update_response", {
637
680
  ...RequestIdShape,
638
681
  ...RequestErrorShape,
639
- success: z8.boolean(),
682
+ success: z9.boolean(),
640
683
  config: VoiceProviderConfigSchema.optional()
641
684
  }),
642
685
  control("voice_config_test", {
@@ -646,15 +689,15 @@ var relayControlDefinitions = [
646
689
  control("voice_config_test_response", {
647
690
  ...RequestIdShape,
648
691
  ...RequestErrorShape,
649
- success: z8.boolean(),
650
- audioBase64: z8.string().optional(),
651
- audioSampleRate: z8.number().int().positive().optional(),
652
- audioEncoding: z8.literal("pcm_s16le").optional(),
653
- transcript: z8.string().optional()
692
+ success: z9.boolean(),
693
+ audioBase64: z9.string().optional(),
694
+ audioSampleRate: z9.number().int().positive().optional(),
695
+ audioEncoding: z9.literal("pcm_s16le").optional(),
696
+ transcript: z9.string().optional()
654
697
  }),
655
698
  control("voice_capabilities_request", {
656
699
  ...RequestIdShape,
657
- region: z8.enum(voiceRegionValues).optional()
700
+ region: z9.enum(voiceRegionValues).optional()
658
701
  }),
659
702
  control("voice_capabilities_response", {
660
703
  ...RequestIdShape,
@@ -666,37 +709,37 @@ var relayControlDefinitions = [
666
709
  control("latency_web_relay_ping", RequiredRequestIdShape),
667
710
  control("latency_web_relay_pong", {
668
711
  ...RequiredRequestIdShape,
669
- relayNow: z8.number().optional()
712
+ relayNow: z9.number().optional()
670
713
  }),
671
714
  control("latency_relay_proxy_request", RequiredRequestIdShape),
672
715
  control("latency_relay_proxy_response", {
673
716
  ...RequiredRequestIdShape,
674
- success: z8.boolean(),
675
- rttMs: z8.number().nonnegative().optional(),
676
- error: z8.string().optional()
717
+ success: z9.boolean(),
718
+ rttMs: z9.number().nonnegative().optional(),
719
+ error: z9.string().optional()
677
720
  }),
678
721
  control("latency_relay_proxy_ping", {
679
722
  ...RequiredRequestIdShape,
680
- relayNow: z8.number().optional()
723
+ relayNow: z9.number().optional()
681
724
  }),
682
725
  control("latency_relay_proxy_pong", {
683
726
  ...RequiredRequestIdShape,
684
- proxyNow: z8.number().optional()
727
+ proxyNow: z9.number().optional()
685
728
  }),
686
729
  control("latency_web_proxy_ping", RequiredRequestIdShape, "client_to_proxy"),
687
- control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z8.number().optional() }, "proxy_to_client"),
730
+ control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z9.number().optional() }, "proxy_to_client"),
688
731
  // 客户端注册协议
689
732
  control("client_register", {
690
733
  clientId: IdSchema,
691
- userAgent: z8.string().optional(),
692
- platform: z8.string().optional(),
693
- maxTouchPoints: z8.number().int().nonnegative().optional(),
694
- browserName: z8.string().min(1),
695
- osName: z8.string().min(1),
696
- deviceKind: z8.enum(["desktop", "tablet", "phone", "unknown"])
734
+ userAgent: z9.string().optional(),
735
+ platform: z9.string().optional(),
736
+ maxTouchPoints: z9.number().int().nonnegative().optional(),
737
+ browserName: z9.string().min(1),
738
+ osName: z9.string().min(1),
739
+ deviceKind: z9.enum(["desktop", "tablet", "phone", "unknown"])
697
740
  }),
698
741
  control("client_register_response", {
699
- status: z8.enum(["restored", "proxy_offline", "new"]),
742
+ status: z9.enum(["restored", "proxy_offline", "new"]),
700
743
  proxyId: IdSchema.optional()
701
744
  }),
702
745
  // Proxy 离线通知
@@ -715,51 +758,51 @@ var relayControlDefinitions = [
715
758
  control("dir_list_request", {
716
759
  proxyId: IdSchema.optional(),
717
760
  ...RequestIdShape,
718
- path: z8.string()
761
+ path: z9.string()
719
762
  }, "client_to_proxy"),
720
- control("dir_list_response", { ...RequestIdShape, ...RequestErrorShape, entries: z8.array(DirEntrySchema), path: z8.string() }, "proxy_to_client"),
763
+ control("dir_list_response", { ...RequestIdShape, ...RequestErrorShape, entries: z9.array(DirEntrySchema), path: z9.string() }, "proxy_to_client"),
721
764
  // 目录创建请求与响应
722
- control("dir_create_request", { ...RequestIdShape, path: z8.string() }, "client_to_proxy"),
765
+ control("dir_create_request", { ...RequestIdShape, path: z9.string() }, "client_to_proxy"),
723
766
  control("dir_create_response", {
724
767
  ...RequestIdShape,
725
768
  ...RequestErrorShape,
726
- path: z8.string(),
727
- success: z8.boolean()
769
+ path: z9.string(),
770
+ success: z9.boolean()
728
771
  }, "proxy_to_client"),
729
772
  // 命令列表推送,proxy 将可用命令列表推给 client
730
- control("command_list_push", { commands: z8.array(CommandEntrySchema) }, "proxy_to_client"),
773
+ control("command_list_push", { commands: z9.array(CommandEntrySchema) }, "proxy_to_client"),
731
774
  // 文件树推送: 按目录分组, 首组 path 即为 session cwd
732
775
  // 前端直接把每组写入 tree[path], 与 dir_list_response 共享 cache slot
733
776
  control("file_tree_push", {
734
- groups: z8.array(FileTreeGroupSchema)
777
+ groups: z9.array(FileTreeGroupSchema)
735
778
  }, "proxy_to_client"),
736
779
  // 会话列表请求与权限模式变更
737
780
  control("session_list", void 0, ["client_to_proxy", "proxy_to_client"]),
738
781
  control("permission_mode_change", {
739
- mode: z8.enum(["default", "auto_accept", "plan"]),
782
+ mode: z9.enum(["default", "auto_accept", "plan"]),
740
783
  // sessionId 可选:传入时 proxy 按该会话的 mode 分叉(PTY 发 Tab ANSI),未传走全局日志行为
741
784
  sessionId: IdSchema.optional()
742
785
  }, "client_to_proxy"),
743
786
  // 会话历史浏览
744
787
  control("session_history_request", RequestIdShape, "client_to_proxy"),
745
- control("session_history_response", { ...RequestIdShape, sessions: z8.array(HistorySessionSchema) }, "proxy_to_client"),
788
+ control("session_history_response", { ...RequestIdShape, sessions: z9.array(HistorySessionSchema) }, "proxy_to_client"),
746
789
  // PTY 语义状态,从 Envelope 迁移到 Control 层
747
790
  control("pty_state", { sessionId: IdSchema, payload: PtyStatePayloadSchema }, "proxy_to_client"),
748
791
  // Provider 语义状态,来自 Claude/Codex hook 等结构化事件,不从 PTY 字节推断
749
792
  control("agent_status", { sessionId: IdSchema, payload: AgentStatusPayloadSchema }, "proxy_to_client"),
750
793
  // 终端标题变化,proxy -> client
751
- control("terminal_title", { sessionId: IdSchema, title: z8.string() }, "proxy_to_client"),
794
+ control("terminal_title", { sessionId: IdSchema, title: z9.string() }, "proxy_to_client"),
752
795
  // 终端尺寸变化,proxy -> client
753
- control("terminal_resize", { sessionId: IdSchema, cols: z8.number().int().positive(), rows: z8.number().int().positive() }, "proxy_to_client"),
754
- control("terminal_resize_request", { sessionId: IdSchema, cols: z8.number().int().positive(), rows: z8.number().int().positive() }, "client_to_proxy"),
796
+ control("terminal_resize", { sessionId: IdSchema, cols: z9.number().int().positive(), rows: z9.number().int().positive() }, "proxy_to_client"),
797
+ control("terminal_resize_request", { sessionId: IdSchema, cols: z9.number().int().positive(), rows: z9.number().int().positive() }, "client_to_proxy"),
755
798
  // 远程终止 JSON 会话,client -> proxy
756
799
  control("session_terminate", { sessionId: IdSchema }, "client_to_proxy"),
757
- control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z8.string() }, "client_to_proxy"),
800
+ control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z9.string() }, "client_to_proxy"),
758
801
  control("session_rename_response", {
759
802
  ...RequestIdShape,
760
803
  sessionId: IdSchema,
761
- success: z8.boolean(),
762
- name: z8.string().optional(),
804
+ success: z9.boolean(),
805
+ name: z9.string().optional(),
763
806
  ...RequestErrorShape
764
807
  }, "proxy_to_client"),
765
808
  // 中断当前 turn,client -> proxy;JSON 由 session-worker 打断 Claude 子进程并保留会话。
@@ -767,55 +810,55 @@ var relayControlDefinitions = [
767
810
  // turn 完成信号,proxy -> client,对应 claude stream-json 的 result 事件
768
811
  control("turn_result", {
769
812
  sessionId: IdSchema,
770
- success: z8.boolean(),
771
- isError: z8.boolean(),
813
+ success: z9.boolean(),
814
+ isError: z9.boolean(),
772
815
  // stream-json result.result 是本轮最终文本。assistant_message 流丢失或 CLI 未发增量时,
773
816
  // Web 用它作为 JSON 模式兜底展示,避免 turn 已结束但界面空白。
774
- result: z8.string().optional()
817
+ result: z9.string().optional()
775
818
  }, "proxy_to_client"),
776
819
  // 客户端发送到 PTY 的原始字节(ANSI 序列),不追加换行
777
- control("remote_input_raw", { sessionId: IdSchema, data: z8.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
820
+ control("remote_input_raw", { sessionId: IdSchema, data: z9.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
778
821
  // 客户端询问 proxy 的环境信息 (home 路径等), client -> proxy -> response
779
822
  // FilePathPicker 用 homePath 作为 select 模式下的默认起点, 新建会话时打开即可浏览
780
823
  control("proxy_info_request", RequestIdShape, "client_to_proxy"),
781
- control("proxy_info", { ...RequestIdShape, homePath: z8.string(), agentCli: AgentCliStatusSchema }, "proxy_to_client"),
782
- control("agent_cli_config_update", { ...RequestIdShape, provider: z8.enum(providerValues), path: z8.string().min(1) }, "client_to_proxy"),
824
+ control("proxy_info", { ...RequestIdShape, homePath: z9.string(), agentCli: AgentCliStatusSchema }, "proxy_to_client"),
825
+ control("agent_cli_config_update", { ...RequestIdShape, provider: z9.enum(providerValues), path: z9.string().min(1) }, "client_to_proxy"),
783
826
  control("agent_cli_config_update_response", {
784
827
  ...RequestIdShape,
785
- provider: z8.enum(providerValues),
828
+ provider: z9.enum(providerValues),
786
829
  agentCli: AgentCliStatusSchema.optional(),
787
830
  ...RequestErrorShape
788
831
  }, "proxy_to_client"),
789
832
  // 远程创建 JSON 会话,client -> proxy -> response
790
833
  control("session_create", {
791
834
  ...RequestIdShape,
792
- kind: z8.enum(sessionKindValues).optional(),
793
- cwd: z8.string().optional(),
794
- name: z8.string().optional(),
795
- provider: z8.enum(providerValues).optional(),
796
- mode: z8.enum(sessionModeValues).optional(),
797
- resumeSessionId: z8.string().optional(),
835
+ kind: z9.enum(sessionKindValues).optional(),
836
+ cwd: z9.string().optional(),
837
+ name: z9.string().optional(),
838
+ provider: z9.enum(providerValues).optional(),
839
+ mode: z9.enum(sessionModeValues).optional(),
840
+ resumeSessionId: z9.string().optional(),
798
841
  // 透传给 claude CLI 的 --permission-mode, undefined 时 proxy 兜底为 "default"
799
- permissionMode: z8.enum(["default", "auto", "acceptEdits", "plan", "bypassPermissions", "dontAsk"]).optional()
842
+ permissionMode: z9.enum(["default", "auto", "acceptEdits", "plan", "bypassPermissions", "dontAsk"]).optional()
800
843
  }, "client_to_proxy"),
801
844
  control("session_create_response", {
802
845
  ...RequestIdShape,
803
846
  // 失败路径只送 errorCode/error, sessionId 此时无语义。成功路径才有 id。
804
847
  sessionId: IdSchema.optional(),
805
- name: z8.string().optional(),
806
- nameLocked: z8.boolean().optional(),
807
- kind: z8.enum(sessionKindValues).optional(),
808
- mode: z8.enum(sessionModeValues).optional(),
809
- provider: z8.enum(providerValues).optional(),
810
- ptyOwner: z8.enum(ptyOwnerValues).optional(),
848
+ name: z9.string().optional(),
849
+ nameLocked: z9.boolean().optional(),
850
+ kind: z9.enum(sessionKindValues).optional(),
851
+ mode: z9.enum(sessionModeValues).optional(),
852
+ provider: z9.enum(providerValues).optional(),
853
+ ptyOwner: z9.enum(ptyOwnerValues).optional(),
811
854
  ...RequestErrorShape
812
855
  }, "proxy_to_client"),
813
856
  // 客户端请求会话历史消息,client -> proxy
814
857
  control("session_messages_request", {
815
858
  ...RequestIdShape,
816
859
  sessionId: IdSchema,
817
- limit: z8.number().int().min(1).max(200).optional(),
818
- before: z8.string().optional()
860
+ limit: z9.number().int().min(1).max(200).optional(),
861
+ before: z9.string().optional()
819
862
  }, "client_to_proxy"),
820
863
  // 客户端请求会话资源(命令列表 + 文件树),client -> proxy
821
864
  control("session_resources_request", { ...RequestIdShape, sessionId: IdSchema }, "client_to_proxy"),
@@ -823,14 +866,14 @@ var relayControlDefinitions = [
823
866
  ...RequestIdShape,
824
867
  ...RequestErrorShape,
825
868
  sessionId: IdSchema,
826
- commands: z8.array(CommandEntrySchema),
827
- groups: z8.array(FileTreeGroupSchema)
869
+ commands: z9.array(CommandEntrySchema),
870
+ groups: z9.array(FileTreeGroupSchema)
828
871
  }, "proxy_to_client"),
829
872
  // 客户端请求当前 provider 语义状态;不经 relay 缓存,由 proxy 返回当前值
830
873
  control("agent_status_request", { ...RequestIdShape, sessionId: IdSchema.optional() }, "client_to_proxy"),
831
874
  control("agent_status_response", {
832
875
  ...RequestIdShape,
833
- statuses: z8.array(z8.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
876
+ statuses: z9.array(z9.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
834
877
  }, "proxy_to_client"),
835
878
  // 客户端确认已收到审批请求;proxy 只记录送达状态,不把它当成用户决策
836
879
  control("permission_request_delivered", { sessionId: IdSchema, requestId: IdSchema }, "client_to_proxy"),
@@ -840,17 +883,17 @@ var relayControlDefinitions = [
840
883
  control("permission_decision_result", {
841
884
  sessionId: IdSchema,
842
885
  requestId: IdSchema,
843
- outcome: z8.enum(["allow", "deny"]),
844
- delivered: z8.boolean(),
845
- message: z8.string().optional()
886
+ outcome: z9.enum(["allow", "deny"]),
887
+ delivered: z9.boolean(),
888
+ message: z9.string().optional()
846
889
  }, "proxy_to_client"),
847
890
  // proxy 推送当前 pending 的工具审批列表,client 据此恢复审批卡片
848
891
  control("pending_approvals_push", {
849
892
  sessionId: IdSchema,
850
- approvals: z8.array(z8.object({
893
+ approvals: z9.array(z9.object({
851
894
  requestId: IdSchema,
852
- toolName: z8.string(),
853
- input: z8.record(z8.string(), z8.unknown())
895
+ toolName: z9.string(),
896
+ input: z9.record(z9.string(), z9.unknown())
854
897
  }))
855
898
  }, "proxy_to_client"),
856
899
  // Voice Pilot speech summaries are produced by proxy-side Claude Code so it can read project context.
@@ -858,7 +901,7 @@ var relayControlDefinitions = [
858
901
  ...RequestIdShape,
859
902
  sessionId: IdSchema,
860
903
  messageId: IdSchema,
861
- text: z8.string().min(1),
904
+ text: z9.string().min(1),
862
905
  reason: VoiceSummaryReasonSchema
863
906
  }, "client_to_proxy"),
864
907
  control("voice_summary_response", {
@@ -866,31 +909,31 @@ var relayControlDefinitions = [
866
909
  ...RequestErrorShape,
867
910
  sessionId: IdSchema,
868
911
  messageId: IdSchema,
869
- success: z8.boolean(),
870
- summary: z8.string().min(1).optional()
912
+ success: z9.boolean(),
913
+ summary: z9.string().min(1).optional()
871
914
  }, "proxy_to_client"),
872
915
  // 恢复会话时推送历史消息,proxy -> client
873
916
  control("session_history_messages", {
874
917
  ...RequestIdShape,
875
918
  sessionId: IdSchema,
876
- before: z8.string().optional(),
877
- messages: z8.array(SessionHistoryMessageSchema),
878
- hasMore: z8.boolean().optional(),
879
- nextBefore: z8.string().optional()
919
+ before: z9.string().optional(),
920
+ messages: z9.array(SessionHistoryMessageSchema),
921
+ hasMore: z9.boolean().optional(),
922
+ nextBefore: z9.string().optional()
880
923
  }, "proxy_to_client"),
881
924
  // proxy 重连后同步活跃 session 列表给 relay。session_sync 由 relay 自消费(更新 proxy-session
882
925
  // 关联)不转发给 client,因此**没有** direction 标注——RelayControlDirection 只描述转发流。
883
926
  control("session_sync", {
884
- sessions: z8.array(z8.object({
885
- id: z8.string(),
886
- kind: z8.enum(sessionKindValues).optional(),
887
- mode: z8.enum(sessionModeValues),
888
- provider: z8.enum(providerValues),
889
- ptyOwner: z8.enum(ptyOwnerValues).optional(),
890
- cwd: z8.string().optional(),
891
- name: z8.string().optional(),
892
- nameLocked: z8.boolean().optional(),
893
- state: z8.enum(sessionStateValues)
927
+ sessions: z9.array(z9.object({
928
+ id: z9.string(),
929
+ kind: z9.enum(sessionKindValues).optional(),
930
+ mode: z9.enum(sessionModeValues),
931
+ provider: z9.enum(providerValues),
932
+ ptyOwner: z9.enum(ptyOwnerValues).optional(),
933
+ cwd: z9.string().optional(),
934
+ name: z9.string().optional(),
935
+ nameLocked: z9.boolean().optional(),
936
+ state: z9.enum(sessionStateValues)
894
937
  }))
895
938
  }),
896
939
  // PTY 会话订阅,client -> proxy,触发 terminal serialize() 返回当前状态
@@ -898,15 +941,15 @@ var relayControlDefinitions = [
898
941
  // PTY 会话快照,proxy -> client,serialize() 的全量终端状态
899
942
  control("session_snapshot", {
900
943
  sessionId: IdSchema,
901
- cols: z8.number().int().positive(),
902
- rows: z8.number().int().positive(),
903
- data: z8.string(),
904
- outputSeq: z8.number().int().nonnegative(),
944
+ cols: z9.number().int().positive(),
945
+ rows: z9.number().int().positive(),
946
+ data: z9.string(),
947
+ outputSeq: z9.number().int().nonnegative(),
905
948
  requestId: IdSchema.optional()
906
949
  }, "proxy_to_client")
907
950
  ];
908
951
  var relayControlSchemas = relayControlDefinitions.map((definition) => definition.schema);
909
- var RelayControlSchema = z8.discriminatedUnion("type", relayControlSchemas);
952
+ var RelayControlSchema = z9.discriminatedUnion("type", relayControlSchemas);
910
953
  var ProxyToClientRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("proxy_to_client")).map((definition) => definition.type));
911
954
  var ClientToProxyRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("client_to_proxy")).map((definition) => definition.type));
912
955
 
@@ -920,6 +963,11 @@ var SessionState = {
920
963
  TERMINATED: "terminated"
921
964
  };
922
965
 
966
+ // ../../packages/shared/dist/constants/session-create.js
967
+ var SESSION_CREATE_SERVER_DEADLINE_MS = 3e4;
968
+ var SESSION_CREATE_RESPONSE_GRACE_MS = 5e3;
969
+ var SESSION_CREATE_CLIENT_TIMEOUT_MS = SESSION_CREATE_SERVER_DEADLINE_MS + SESSION_CREATE_RESPONSE_GRACE_MS;
970
+
923
971
  // ../../packages/shared/dist/constants/wire-limits.js
924
972
  var RELAY_JSON_MESSAGE_MAX_BYTES = 8 * 1024 * 1024;
925
973
  var RELAY_BINARY_FRAME_MAX_BYTES = 10 * 1024 * 1024;
@@ -996,7 +1044,7 @@ function decodeFileStreamFrame(view) {
996
1044
  }
997
1045
 
998
1046
  // src/ipc/ipc-protocol.ts
999
- import { z as z9 } from "zod";
1047
+ import { z as z10 } from "zod";
1000
1048
 
1001
1049
  // src/ipc/line-buffer.ts
1002
1050
  import { Transform } from "stream";
@@ -1037,234 +1085,240 @@ function encodeBinaryIpcFrame(sessionId, data, outputSeq) {
1037
1085
  return frame;
1038
1086
  }
1039
1087
  var sessionStateValues2 = Object.values(SessionState);
1040
- var ProviderHookContextSchema = z9.object({
1041
- provider: z9.enum(["claude", "codex"]),
1042
- sessionId: z9.string(),
1043
- hookUrl: z9.string(),
1044
- marker: z9.string(),
1045
- token: z9.string()
1088
+ var ProviderHookContextSchema = z10.object({
1089
+ provider: z10.enum(["claude", "codex"]),
1090
+ sessionId: z10.string(),
1091
+ hookUrl: z10.string(),
1092
+ marker: z10.string(),
1093
+ token: z10.string()
1046
1094
  });
1047
- var IpcMessageSchema = z9.discriminatedUnion("type", [
1095
+ var IpcMessageSchema = z10.discriminatedUnion("type", [
1048
1096
  // 客户端请求创建新会话,sessionId 可选用于重连时复用
1049
- z9.object({
1050
- type: z9.literal("session_create_request"),
1051
- name: z9.string().optional(),
1052
- mode: z9.enum(["pty", "json"]),
1053
- provider: z9.enum(["claude", "codex"]),
1054
- cwd: z9.string(),
1055
- pid: z9.number(),
1056
- sessionId: z9.string().optional(),
1057
- kind: z9.enum(["agent", "terminal"]).optional()
1097
+ z10.object({
1098
+ type: z10.literal("session_create_request"),
1099
+ name: z10.string().optional(),
1100
+ mode: z10.enum(["pty", "json"]),
1101
+ provider: z10.enum(["claude", "codex"]),
1102
+ cwd: z10.string(),
1103
+ pid: z10.number(),
1104
+ sessionId: z10.string().optional(),
1105
+ kind: z10.enum(["agent", "terminal"]).optional()
1058
1106
  }),
1059
1107
  // 服务端响应创建会话
1060
- z9.object({
1061
- type: z9.literal("session_create_response"),
1062
- sessionId: z9.string(),
1063
- error: z9.string().optional(),
1108
+ z10.object({
1109
+ type: z10.literal("session_create_response"),
1110
+ sessionId: z10.string(),
1111
+ error: z10.string().optional(),
1064
1112
  hook: ProviderHookContextSchema.optional()
1065
1113
  }),
1066
1114
  // 客户端请求终止会话
1067
- z9.object({
1068
- type: z9.literal("session_terminate_request"),
1069
- sessionId: z9.string()
1115
+ z10.object({
1116
+ type: z10.literal("session_terminate_request"),
1117
+ sessionId: z10.string()
1070
1118
  }),
1071
1119
  // 服务端响应终止会话
1072
- z9.object({
1073
- type: z9.literal("session_terminate_response"),
1074
- sessionId: z9.string(),
1075
- success: z9.boolean()
1120
+ z10.object({
1121
+ type: z10.literal("session_terminate_response"),
1122
+ sessionId: z10.string(),
1123
+ success: z10.boolean()
1076
1124
  }),
1077
1125
  // 客户端向服务端注册 PTY 会话
1078
- z9.object({
1079
- type: z9.literal("pty_register"),
1080
- sessionId: z9.string(),
1081
- pid: z9.number()
1126
+ z10.object({
1127
+ type: z10.literal("pty_register"),
1128
+ sessionId: z10.string(),
1129
+ pid: z10.number()
1082
1130
  }),
1083
1131
  // 客户端取消注册 PTY 会话
1084
- z9.object({
1085
- type: z9.literal("pty_deregister"),
1086
- sessionId: z9.string()
1132
+ z10.object({
1133
+ type: z10.literal("pty_deregister"),
1134
+ sessionId: z10.string()
1087
1135
  }),
1088
1136
  // 输入,从服务端转发到客户端的 PTY stdin(手机远程输入注入)
1089
- z9.object({
1090
- type: z9.literal("pty_input"),
1091
- sessionId: z9.string(),
1092
- data: z9.string(),
1093
- traceId: z9.string().optional()
1137
+ z10.object({
1138
+ type: z10.literal("pty_input"),
1139
+ sessionId: z10.string(),
1140
+ data: z10.string(),
1141
+ traceId: z10.string().optional()
1094
1142
  }),
1095
1143
  // serve → terminal:Web 端移除本地终端会话时,只断开远程视图,不杀本地 CLI。
1096
- z9.object({
1097
- type: z9.literal("pty_detach"),
1098
- sessionId: z9.string()
1144
+ z10.object({
1145
+ type: z10.literal("pty_detach"),
1146
+ sessionId: z10.string()
1099
1147
  }),
1100
1148
  // serve → terminal worker:终止 Web 创建的纯终端进程。
1101
- z9.object({
1102
- type: z9.literal("pty_terminate"),
1103
- sessionId: z9.string()
1149
+ z10.object({
1150
+ type: z10.literal("pty_terminate"),
1151
+ sessionId: z10.string()
1104
1152
  }),
1105
1153
  // 服务端广播会话状态变更
1106
- z9.object({
1107
- type: z9.literal("session_status_update"),
1108
- sessionId: z9.string(),
1109
- state: z9.enum(sessionStateValues2)
1154
+ z10.object({
1155
+ type: z10.literal("session_status_update"),
1156
+ sessionId: z10.string(),
1157
+ state: z10.enum(sessionStateValues2)
1110
1158
  }),
1111
1159
  // 错误响应
1112
- z9.object({
1113
- type: z9.literal("error"),
1114
- message: z9.string(),
1115
- code: z9.string().optional()
1160
+ z10.object({
1161
+ type: z10.literal("error"),
1162
+ message: z10.string(),
1163
+ code: z10.string().optional()
1116
1164
  }),
1117
1165
  // 客户端请求服务状态(含 relay 连接信息和 worker 状态)
1118
- z9.object({
1119
- type: z9.literal("service_status_request")
1166
+ z10.object({
1167
+ type: z10.literal("service_status_request")
1120
1168
  }),
1121
1169
  // 服务端响应增强版服务状态
1122
- z9.object({
1123
- type: z9.literal("service_status_response"),
1124
- config: z9.object({
1125
- profile: z9.string().optional(),
1126
- relayName: z9.string(),
1127
- relayNameSource: z9.enum(["cli", "profile"]),
1128
- relayUrl: z9.string().optional(),
1129
- relayUrlSource: z9.enum(["env", "file", "none"]),
1130
- relayTokenSource: z9.enum(["env", "file", "none"]),
1131
- hookPort: z9.number(),
1132
- hookPortSource: z9.enum(["env", "file", "default"])
1170
+ z10.object({
1171
+ type: z10.literal("service_status_response"),
1172
+ config: z10.object({
1173
+ profile: z10.string().optional(),
1174
+ relayName: z10.string(),
1175
+ relayNameSource: z10.enum(["cli", "profile", "env"]),
1176
+ relayUrl: z10.string().optional(),
1177
+ relayUrlSource: z10.enum(["env", "file", "none"]),
1178
+ relayTokenSource: z10.enum(["env", "file", "none"]),
1179
+ hookPort: z10.number(),
1180
+ hookPortSource: z10.enum(["env", "file", "default"])
1133
1181
  }),
1134
- relay: z9.object({
1135
- connected: z9.boolean(),
1136
- proxyId: z9.string(),
1137
- reconnectAttempt: z9.number(),
1138
- queueDepth: z9.number()
1182
+ relay: z10.object({
1183
+ connected: z10.boolean(),
1184
+ proxyId: z10.string(),
1185
+ reconnectAttempt: z10.number(),
1186
+ queueDepth: z10.number()
1139
1187
  }).nullable(),
1140
- sessions: z9.array(
1141
- z9.object({
1142
- id: z9.string(),
1143
- mode: z9.enum(["pty", "json"]),
1144
- state: z9.enum(sessionStateValues2),
1145
- createdAt: z9.string(),
1146
- name: z9.string().optional(),
1147
- hasWorker: z9.boolean()
1188
+ sessions: z10.array(
1189
+ z10.object({
1190
+ id: z10.string(),
1191
+ mode: z10.enum(["pty", "json"]),
1192
+ state: z10.enum(sessionStateValues2),
1193
+ createdAt: z10.string(),
1194
+ name: z10.string().optional(),
1195
+ hasWorker: z10.boolean()
1148
1196
  })
1149
1197
  )
1150
1198
  }),
1151
1199
  // terminal → serve:终端标题变化,由 xterm onTitleChange 触发
1152
- z9.object({
1153
- type: z9.literal("pty_title_change"),
1154
- sessionId: z9.string(),
1155
- title: z9.string()
1200
+ z10.object({
1201
+ type: z10.literal("pty_title_change"),
1202
+ sessionId: z10.string(),
1203
+ title: z10.string()
1204
+ }),
1205
+ // terminal → serve:shell 通过 OSC 7 报告的当前工作目录
1206
+ z10.object({
1207
+ type: z10.literal("pty_cwd_change"),
1208
+ sessionId: z10.string(),
1209
+ cwd: z10.string().min(1)
1156
1210
  }),
1157
1211
  // terminal → serve:local runtime 观察到的 PTY 语义事件。
1158
- z9.object({
1159
- type: z9.literal("pty_semantic_event"),
1160
- sessionId: z9.string(),
1161
- state: z9.enum(ptySemanticStateValues),
1162
- seq: z9.number().int().nonnegative(),
1163
- title: z9.string().optional(),
1164
- tool: z9.string().optional()
1212
+ z10.object({
1213
+ type: z10.literal("pty_semantic_event"),
1214
+ sessionId: z10.string(),
1215
+ state: z10.enum(ptySemanticStateValues),
1216
+ seq: z10.number().int().nonnegative(),
1217
+ title: z10.string().optional(),
1218
+ tool: z10.string().optional()
1165
1219
  }),
1166
1220
  // terminal → serve:终端尺寸变化
1167
- z9.object({
1168
- type: z9.literal("pty_resize"),
1169
- sessionId: z9.string(),
1170
- cols: z9.number(),
1171
- rows: z9.number()
1221
+ z10.object({
1222
+ type: z10.literal("pty_resize"),
1223
+ sessionId: z10.string(),
1224
+ cols: z10.number(),
1225
+ rows: z10.number()
1172
1226
  }),
1173
1227
  // serve → terminal worker:Web owns pure terminal geometry, so resize requests flow down.
1174
- z9.object({
1175
- type: z9.literal("pty_resize_request"),
1176
- sessionId: z9.string(),
1177
- cols: z9.number(),
1178
- rows: z9.number()
1228
+ z10.object({
1229
+ type: z10.literal("pty_resize_request"),
1230
+ sessionId: z10.string(),
1231
+ cols: z10.number(),
1232
+ rows: z10.number()
1179
1233
  }),
1180
1234
  // serve → terminal:请求 HeadlessTerminal serialize() 快照
1181
- z9.object({
1182
- type: z9.literal("pty_subscribe"),
1183
- sessionId: z9.string(),
1184
- requestId: z9.string().optional()
1235
+ z10.object({
1236
+ type: z10.literal("pty_subscribe"),
1237
+ sessionId: z10.string(),
1238
+ requestId: z10.string().optional()
1185
1239
  }),
1186
1240
  // terminal → serve:serialize() 结果
1187
- z9.object({
1188
- type: z9.literal("pty_snapshot"),
1189
- sessionId: z9.string(),
1190
- cols: z9.number(),
1191
- rows: z9.number(),
1192
- data: z9.string(),
1193
- outputSeq: z9.number().int().nonnegative(),
1194
- requestId: z9.string().optional()
1241
+ z10.object({
1242
+ type: z10.literal("pty_snapshot"),
1243
+ sessionId: z10.string(),
1244
+ cols: z10.number(),
1245
+ rows: z10.number(),
1246
+ data: z10.string(),
1247
+ outputSeq: z10.number().int().nonnegative(),
1248
+ requestId: z10.string().optional()
1195
1249
  }),
1196
1250
  // serve → terminal:relay 连接状态变更,供终端给用户显示 remote viewing 是否通畅
1197
- z9.object({
1198
- type: z9.literal("bridge_status"),
1199
- connected: z9.boolean()
1251
+ z10.object({
1252
+ type: z10.literal("bridge_status"),
1253
+ connected: z10.boolean()
1200
1254
  })
1201
1255
  ]);
1202
- var WorkerMessageSchema = z9.discriminatedUnion("type", [
1256
+ var WorkerMessageSchema = z10.discriminatedUnion("type", [
1203
1257
  // serve → worker: 发送用户输入给 claude
1204
- z9.object({
1205
- type: z9.literal("worker_input"),
1206
- content: z9.string()
1258
+ z10.object({
1259
+ type: z10.literal("worker_input"),
1260
+ content: z10.string()
1207
1261
  }),
1208
1262
  // serve → worker: 停止 claude 进程(终止整个 JSON 会话)
1209
- z9.object({
1210
- type: z9.literal("worker_stop")
1263
+ z10.object({
1264
+ type: z10.literal("worker_stop")
1211
1265
  }),
1212
1266
  // serve → worker: 只中断当前 Claude turn,worker 进程必须保活并重建 Claude 子进程。
1213
- z9.object({
1214
- type: z9.literal("worker_interrupt")
1267
+ z10.object({
1268
+ type: z10.literal("worker_interrupt")
1215
1269
  }),
1216
1270
  // serve → worker: 工具审批响应
1217
- z9.object({
1218
- type: z9.literal("worker_approval_response"),
1219
- requestId: z9.string(),
1220
- behavior: z9.enum(["allow", "deny"]),
1221
- message: z9.string().optional()
1271
+ z10.object({
1272
+ type: z10.literal("worker_approval_response"),
1273
+ requestId: z10.string(),
1274
+ behavior: z10.enum(["allow", "deny"]),
1275
+ message: z10.string().optional()
1222
1276
  }),
1223
1277
  // worker → serve: claude 输出事件(带序列号)
1224
- z9.object({
1225
- type: z9.literal("worker_event"),
1226
- seq: z9.number(),
1227
- event: z9.record(z9.string(), z9.unknown())
1278
+ z10.object({
1279
+ type: z10.literal("worker_event"),
1280
+ seq: z10.number(),
1281
+ event: z10.record(z10.string(), z10.unknown())
1228
1282
  }),
1229
1283
  // worker → serve: claude 进程退出
1230
- z9.object({
1231
- type: z9.literal("worker_exit"),
1232
- code: z9.number()
1284
+ z10.object({
1285
+ type: z10.literal("worker_exit"),
1286
+ code: z10.number()
1233
1287
  }),
1234
1288
  // worker → serve: 当前 turn 已中断,JSON 会话仍可继续接收后续输入。
1235
- z9.object({
1236
- type: z9.literal("worker_interrupted")
1289
+ z10.object({
1290
+ type: z10.literal("worker_interrupted")
1237
1291
  }),
1238
1292
  // worker → serve: 工具审批请求
1239
- z9.object({
1240
- type: z9.literal("worker_approval_request"),
1241
- requestId: z9.string(),
1242
- toolName: z9.string(),
1243
- input: z9.record(z9.string(), z9.unknown())
1293
+ z10.object({
1294
+ type: z10.literal("worker_approval_request"),
1295
+ requestId: z10.string(),
1296
+ toolName: z10.string(),
1297
+ input: z10.record(z10.string(), z10.unknown())
1244
1298
  }),
1245
1299
  // worker → serve: worker 就绪。Claude 在进程启动后发送;Codex 在 app-server
1246
1300
  // initialize + thread/start|resume 完成后发送,避免 session_create 早于 provider ready。
1247
- z9.object({
1248
- type: z9.literal("worker_ready"),
1249
- pid: z9.number()
1301
+ z10.object({
1302
+ type: z10.literal("worker_ready"),
1303
+ pid: z10.number()
1250
1304
  }),
1251
1305
  // worker → serve: 从 stream-json 的 system.init 事件捕获 Claude CLI 侧的 session ID
1252
1306
  // proxy 拿它来读 ~/.claude/projects/.../<id>.jsonl 历史或后续 --resume
1253
- z9.object({
1254
- type: z9.literal("worker_claude_session_id"),
1255
- sessionId: z9.string()
1307
+ z10.object({
1308
+ type: z10.literal("worker_claude_session_id"),
1309
+ sessionId: z10.string()
1256
1310
  }),
1257
1311
  // worker → serve: provider 原生会话 ID。Codex app-server 用 thread id 作为
1258
1312
  // historySessionId,Claude 仍保留 worker_claude_session_id 的兼容路径。
1259
- z9.object({
1260
- type: z9.literal("worker_native_session_id"),
1261
- provider: z9.enum(["claude", "codex"]),
1262
- sessionId: z9.string()
1313
+ z10.object({
1314
+ type: z10.literal("worker_native_session_id"),
1315
+ provider: z10.enum(["claude", "codex"]),
1316
+ sessionId: z10.string()
1263
1317
  }),
1264
1318
  // serve → worker: 将指定工具加入会话白名单,后续同名工具自动审批
1265
- z9.object({
1266
- type: z9.literal("worker_whitelist_add"),
1267
- toolName: z9.string()
1319
+ z10.object({
1320
+ type: z10.literal("worker_whitelist_add"),
1321
+ toolName: z10.string()
1268
1322
  })
1269
1323
  ]);
1270
1324
  function serializeWorkerMsg(msg) {
@@ -1355,6 +1409,7 @@ export {
1355
1409
  ControlErrorCode,
1356
1410
  RelayControlSchema,
1357
1411
  SessionState,
1412
+ SESSION_CREATE_SERVER_DEADLINE_MS,
1358
1413
  RELAY_JSON_MESSAGE_MAX_BYTES,
1359
1414
  encodeBinaryFrame,
1360
1415
  encodeFileStreamFrame,
@@ -1368,4 +1423,4 @@ export {
1368
1423
  serializeIpc,
1369
1424
  createIpcReader
1370
1425
  };
1371
- //# sourceMappingURL=chunk-ENXGI3FO.js.map
1426
+ //# sourceMappingURL=chunk-RSJKBUBY.js.map