@dev-anywhere/relay 0.9.0 → 0.9.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.
@@ -481,18 +481,28 @@ var PreviewScopeSchema = z8.object({
481
481
  bindingId: IdSchema
482
482
  }).strict();
483
483
 
484
- // ../../packages/shared/dist/schemas/web-preview.js
484
+ // ../../packages/shared/dist/schemas/proxy-upgrade-bootstrap.js
485
485
  import { z as z9 } from "zod";
486
+ var PROXY_UPGRADE_BOOTSTRAP_VERSION = 1;
487
+ var StableVersionSchema = z9.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
488
+ var ProxyUpgradeBootstrapResponseSchema = z9.object({
489
+ bootstrapVersion: z9.literal(PROXY_UPGRADE_BOOTSTRAP_VERSION),
490
+ relayVersion: StableVersionSchema,
491
+ controlProtocolVersion: z9.number().int().positive()
492
+ });
493
+
494
+ // ../../packages/shared/dist/schemas/web-preview.js
495
+ import { z as z10 } from "zod";
486
496
  var WEB_PREVIEW_PATH_MAX_LENGTH = 4096;
487
497
  var WEB_PREVIEW_SOURCE_URL_MAX_LENGTH = 4096;
488
498
  var WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH = 65536;
489
499
  var WEB_PREVIEW_NAME_MAX_LENGTH = 256;
490
500
  var WEB_PREVIEW_ERROR_MAX_LENGTH = 4096;
491
501
  var WEB_PREVIEW_HTML_ENTRY_MAX_COUNT = 1e3;
492
- var WebPreviewNameSchema = z9.string().trim().min(1).max(WEB_PREVIEW_NAME_MAX_LENGTH);
502
+ var WebPreviewNameSchema = z10.string().trim().min(1).max(WEB_PREVIEW_NAME_MAX_LENGTH);
493
503
  var tunnelProviderValues = ["cloudflare", "cpolar"];
494
- var TunnelProviderSchema = z9.enum(tunnelProviderValues);
495
- var WebPreviewPathSchema = z9.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH);
504
+ var TunnelProviderSchema = z10.enum(tunnelProviderValues);
505
+ var WebPreviewPathSchema = z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH);
496
506
  function parseUrlSafely(value) {
497
507
  try {
498
508
  return new URL(value);
@@ -500,7 +510,7 @@ function parseUrlSafely(value) {
500
510
  return null;
501
511
  }
502
512
  }
503
- var LoopbackHttpUrlSchema = z9.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_LENGTH).url().refine((value) => {
513
+ var LoopbackHttpUrlSchema = z10.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_LENGTH).url().refine((value) => {
504
514
  const url = parseUrlSafely(value);
505
515
  if (!url)
506
516
  return false;
@@ -508,7 +518,7 @@ var LoopbackHttpUrlSchema = z9.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_LE
508
518
  return false;
509
519
  return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
510
520
  }, "Local preview URL must use http:// with a loopback host and no credentials");
511
- var PublicPreviewUrlSchema = z9.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH).url().refine((value) => {
521
+ var PublicPreviewUrlSchema = z10.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH).url().refine((value) => {
512
522
  const url = parseUrlSafely(value);
513
523
  if (!url)
514
524
  return false;
@@ -517,45 +527,45 @@ var PublicPreviewUrlSchema = z9.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_L
517
527
  var DNS_LABEL_PATTERN = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
518
528
  var CLOUDFLARE_PUBLIC_HOST_PATTERN = new RegExp(`^${DNS_LABEL_PATTERN}\\.trycloudflare\\.com$`, "i");
519
529
  var CPOLAR_PUBLIC_HOST_PATTERN = new RegExp(`^(?:${DNS_LABEL_PATTERN}\\.)+cpolar\\.(?:top|cn|io)$`, "i");
520
- var WebPreviewTunnelSuggestionsSchema = z9.array(z9.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
521
- var WebPreviewTunnelStatusSchema = z9.discriminatedUnion("available", [
522
- z9.object({
523
- available: z9.literal(true),
524
- command: z9.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH),
525
- version: z9.string().min(1).max(256).optional(),
526
- error: z9.never().optional(),
530
+ var WebPreviewTunnelSuggestionsSchema = z10.array(z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
531
+ var WebPreviewTunnelStatusSchema = z10.discriminatedUnion("available", [
532
+ z10.object({
533
+ available: z10.literal(true),
534
+ command: z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH),
535
+ version: z10.string().min(1).max(256).optional(),
536
+ error: z10.never().optional(),
527
537
  suggestions: WebPreviewTunnelSuggestionsSchema
528
538
  }).strict(),
529
- z9.object({
530
- available: z9.literal(false),
531
- command: z9.never().optional(),
532
- version: z9.never().optional(),
533
- error: z9.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH),
539
+ z10.object({
540
+ available: z10.literal(false),
541
+ command: z10.never().optional(),
542
+ version: z10.never().optional(),
543
+ error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH),
534
544
  suggestions: WebPreviewTunnelSuggestionsSchema
535
545
  }).strict()
536
546
  ]);
537
- var WebPreviewCapabilitySchema = z9.object({
547
+ var WebPreviewCapabilitySchema = z10.object({
538
548
  cloudflared: WebPreviewTunnelStatusSchema,
539
549
  cpolar: WebPreviewTunnelStatusSchema
540
550
  }).strict();
541
- var WebPreviewSourceInputSchema = z9.discriminatedUnion("kind", [
542
- z9.object({
543
- kind: z9.literal("local"),
551
+ var WebPreviewSourceInputSchema = z10.discriminatedUnion("kind", [
552
+ z10.object({
553
+ kind: z10.literal("local"),
544
554
  url: LoopbackHttpUrlSchema
545
555
  }).strict(),
546
- z9.object({
547
- kind: z9.literal("static"),
556
+ z10.object({
557
+ kind: z10.literal("static"),
548
558
  path: WebPreviewPathSchema,
549
559
  entryPath: WebPreviewPathSchema
550
560
  }).strict()
551
561
  ]);
552
- var PreviewSourceSchema = z9.discriminatedUnion("kind", [
553
- z9.object({
554
- kind: z9.literal("local"),
562
+ var PreviewSourceSchema = z10.discriminatedUnion("kind", [
563
+ z10.object({
564
+ kind: z10.literal("local"),
555
565
  url: LoopbackHttpUrlSchema
556
566
  }).strict(),
557
- z9.object({
558
- kind: z9.literal("static"),
567
+ z10.object({
568
+ kind: z10.literal("static"),
559
569
  rootPath: WebPreviewPathSchema,
560
570
  entryPath: WebPreviewPathSchema
561
571
  }).strict()
@@ -567,40 +577,40 @@ var previewStateValues = [
567
577
  "failed",
568
578
  "stopping"
569
579
  ];
570
- var PreviewStateSchema = z9.enum(previewStateValues);
571
- var PreviewSummaryBaseSchema = z9.object({
580
+ var PreviewStateSchema = z10.enum(previewStateValues);
581
+ var PreviewSummaryBaseSchema = z10.object({
572
582
  previewId: IdSchema,
573
583
  name: WebPreviewNameSchema,
574
584
  source: PreviewSourceSchema,
575
585
  tunnelProvider: TunnelProviderSchema,
576
- createdAt: z9.number().int().nonnegative(),
577
- updatedAt: z9.number().int().nonnegative()
586
+ createdAt: z10.number().int().nonnegative(),
587
+ updatedAt: z10.number().int().nonnegative()
578
588
  });
579
589
  var PreviewSummaryInactiveShape = {
580
- publicUrl: z9.never().optional(),
581
- error: z9.never().optional()
590
+ publicUrl: z10.never().optional(),
591
+ error: z10.never().optional()
582
592
  };
583
- var PreviewSummarySchema = z9.discriminatedUnion("state", [
593
+ var PreviewSummarySchema = z10.discriminatedUnion("state", [
584
594
  PreviewSummaryBaseSchema.extend({
585
- state: z9.literal("starting"),
595
+ state: z10.literal("starting"),
586
596
  ...PreviewSummaryInactiveShape
587
597
  }).strict(),
588
598
  PreviewSummaryBaseSchema.extend({
589
- state: z9.literal("ready"),
599
+ state: z10.literal("ready"),
590
600
  publicUrl: PublicPreviewUrlSchema,
591
- error: z9.never().optional()
601
+ error: z10.never().optional()
592
602
  }).strict(),
593
603
  PreviewSummaryBaseSchema.extend({
594
- state: z9.literal("disconnected"),
604
+ state: z10.literal("disconnected"),
595
605
  ...PreviewSummaryInactiveShape
596
606
  }).strict(),
597
607
  PreviewSummaryBaseSchema.extend({
598
- state: z9.literal("failed"),
599
- publicUrl: z9.never().optional(),
600
- error: z9.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH)
608
+ state: z10.literal("failed"),
609
+ publicUrl: z10.never().optional(),
610
+ error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH)
601
611
  }).strict(),
602
612
  PreviewSummaryBaseSchema.extend({
603
- state: z9.literal("stopping"),
613
+ state: z10.literal("stopping"),
604
614
  ...PreviewSummaryInactiveShape
605
615
  }).strict()
606
616
  ]).superRefine((preview, context) => {
@@ -620,104 +630,104 @@ var PreviewSummarySchema = z9.discriminatedUnion("state", [
620
630
  });
621
631
  }
622
632
  });
623
- var PreviewHtmlEntriesSchema = z9.array(WebPreviewPathSchema).max(WEB_PREVIEW_HTML_ENTRY_MAX_COUNT);
633
+ var PreviewHtmlEntriesSchema = z10.array(WebPreviewPathSchema).max(WEB_PREVIEW_HTML_ENTRY_MAX_COUNT);
624
634
 
625
635
  // ../../packages/shared/dist/schemas/device-preview.js
626
- import { z as z10 } from "zod";
636
+ import { z as z11 } from "zod";
627
637
  var DEVICE_PREVIEW_PATH_MAX_LENGTH = 4096;
628
638
  var DEVICE_PREVIEW_TEXT_MAX_LENGTH = 4096;
629
639
  var DEVICE_PREVIEW_ERROR_MAX_LENGTH = 4096;
630
640
  var DEVICE_PREVIEW_NAME_MAX_LENGTH = 256;
631
641
  var DEVICE_PREVIEW_VERSION_MAX_LENGTH = 256;
632
642
  var DEVICE_PREVIEW_SCREEN_EDGE_MAX = 16384;
633
- var DevicePreviewNameSchema = z10.string().trim().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH);
643
+ var DevicePreviewNameSchema = z11.string().trim().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH);
634
644
  var devicePreviewStreamFormatValues = ["jpeg", "h264_annex_b"];
635
- var DevicePreviewStreamFormatSchema = z10.enum(devicePreviewStreamFormatValues);
645
+ var DevicePreviewStreamFormatSchema = z11.enum(devicePreviewStreamFormatValues);
636
646
  var devicePreviewPlatformValues = ["ios", "android"];
637
- var DevicePreviewPlatformSchema = z10.enum(devicePreviewPlatformValues);
638
- var DevicePreviewToolSuggestionsSchema = z10.array(z10.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
639
- var DevicePreviewToolStatusSchema = z10.union([
640
- z10.object({
641
- supported: z10.literal(false),
642
- available: z10.literal(false),
643
- interactive: z10.literal(false),
644
- command: z10.never().optional(),
645
- version: z10.never().optional(),
646
- error: z10.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
647
+ var DevicePreviewPlatformSchema = z11.enum(devicePreviewPlatformValues);
648
+ var DevicePreviewToolSuggestionsSchema = z11.array(z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
649
+ var DevicePreviewToolStatusSchema = z11.union([
650
+ z11.object({
651
+ supported: z11.literal(false),
652
+ available: z11.literal(false),
653
+ interactive: z11.literal(false),
654
+ command: z11.never().optional(),
655
+ version: z11.never().optional(),
656
+ error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
647
657
  suggestions: DevicePreviewToolSuggestionsSchema
648
658
  }).strict(),
649
- z10.object({
650
- supported: z10.literal(true),
651
- available: z10.literal(false),
652
- interactive: z10.literal(false),
653
- command: z10.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH).optional(),
654
- version: z10.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
655
- error: z10.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
659
+ z11.object({
660
+ supported: z11.literal(true),
661
+ available: z11.literal(false),
662
+ interactive: z11.literal(false),
663
+ command: z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH).optional(),
664
+ version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
665
+ error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
656
666
  suggestions: DevicePreviewToolSuggestionsSchema
657
667
  }).strict(),
658
- z10.object({
659
- supported: z10.literal(true),
660
- available: z10.literal(true),
661
- interactive: z10.literal(true),
662
- command: z10.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH),
663
- version: z10.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
664
- error: z10.never().optional(),
668
+ z11.object({
669
+ supported: z11.literal(true),
670
+ available: z11.literal(true),
671
+ interactive: z11.literal(true),
672
+ command: z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH),
673
+ version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
674
+ error: z11.never().optional(),
665
675
  suggestions: DevicePreviewToolSuggestionsSchema
666
676
  }).strict()
667
677
  ]);
668
- var DevicePreviewCapabilitySchema = z10.object({
678
+ var DevicePreviewCapabilitySchema = z11.object({
669
679
  ios: DevicePreviewToolStatusSchema,
670
680
  android: DevicePreviewToolStatusSchema
671
681
  }).strict();
672
- var DevicePreviewTargetBaseSchema = z10.object({
682
+ var DevicePreviewTargetBaseSchema = z11.object({
673
683
  targetId: IdSchema,
674
684
  platform: DevicePreviewPlatformSchema,
675
- name: z10.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
676
- model: z10.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
677
- osVersion: z10.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
678
- interactive: z10.boolean()
685
+ name: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
686
+ model: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
687
+ osVersion: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
688
+ interactive: z11.boolean()
679
689
  });
680
- var DevicePreviewScreenEdgeSchema = z10.number().int().positive().max(DEVICE_PREVIEW_SCREEN_EDGE_MAX);
681
- var DevicePreviewTargetSchema = z10.union([
690
+ var DevicePreviewScreenEdgeSchema = z11.number().int().positive().max(DEVICE_PREVIEW_SCREEN_EDGE_MAX);
691
+ var DevicePreviewTargetSchema = z11.union([
682
692
  DevicePreviewTargetBaseSchema.extend({
683
693
  width: DevicePreviewScreenEdgeSchema,
684
694
  height: DevicePreviewScreenEdgeSchema
685
695
  }).strict(),
686
696
  DevicePreviewTargetBaseSchema.extend({
687
- width: z10.never().optional(),
688
- height: z10.never().optional()
697
+ width: z11.never().optional(),
698
+ height: z11.never().optional()
689
699
  }).strict()
690
700
  ]);
691
- var DevicePreviewStateSchema = z10.enum(["ready", "disconnected"]);
692
- var DevicePreviewSummaryBaseSchema = z10.object({
701
+ var DevicePreviewStateSchema = z11.enum(["ready", "disconnected"]);
702
+ var DevicePreviewSummaryBaseSchema = z11.object({
693
703
  previewId: IdSchema,
694
704
  name: DevicePreviewNameSchema,
695
705
  platform: DevicePreviewPlatformSchema,
696
706
  targetId: IdSchema,
697
- model: z10.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
698
- osVersion: z10.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
699
- interactive: z10.boolean(),
700
- createdAt: z10.number().int().nonnegative(),
701
- updatedAt: z10.number().int().nonnegative()
707
+ model: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
708
+ osVersion: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
709
+ interactive: z11.boolean(),
710
+ createdAt: z11.number().int().nonnegative(),
711
+ updatedAt: z11.number().int().nonnegative()
702
712
  });
703
- var DevicePreviewSummarySchema = z10.discriminatedUnion("state", [
713
+ var DevicePreviewSummarySchema = z11.discriminatedUnion("state", [
704
714
  DevicePreviewSummaryBaseSchema.extend({
705
- state: z10.literal("ready"),
706
- error: z10.never().optional()
715
+ state: z11.literal("ready"),
716
+ error: z11.never().optional()
707
717
  }).strict(),
708
718
  DevicePreviewSummaryBaseSchema.extend({
709
- state: z10.literal("disconnected"),
710
- error: z10.never().optional()
719
+ state: z11.literal("disconnected"),
720
+ error: z11.never().optional()
711
721
  }).strict()
712
722
  ]);
713
- var DevicePreviewJpegStreamProfileSchema = z10.object({
714
- format: z10.literal("jpeg"),
715
- maxFps: z10.number().int().min(1).max(30).optional()
723
+ var DevicePreviewJpegStreamProfileSchema = z11.object({
724
+ format: z11.literal("jpeg"),
725
+ maxFps: z11.number().int().min(1).max(30).optional()
716
726
  }).strict();
717
- var DevicePreviewH264StreamProfileSchema = z10.object({
718
- format: z10.literal("h264_annex_b")
727
+ var DevicePreviewH264StreamProfileSchema = z11.object({
728
+ format: z11.literal("h264_annex_b")
719
729
  }).strict();
720
- var DevicePreviewStreamProfileSchema = z10.discriminatedUnion("format", [
730
+ var DevicePreviewStreamProfileSchema = z11.discriminatedUnion("format", [
721
731
  DevicePreviewJpegStreamProfileSchema,
722
732
  DevicePreviewH264StreamProfileSchema
723
733
  ]);
@@ -728,10 +738,10 @@ var devicePreviewStreamStopReasonValues = [
728
738
  "relay_shutdown",
729
739
  "stream_error"
730
740
  ];
731
- var DevicePreviewStreamStopReasonSchema = z10.enum(devicePreviewStreamStopReasonValues);
732
- var NormalizedCoordinateSchema = z10.number().finite().min(0).max(1);
741
+ var DevicePreviewStreamStopReasonSchema = z11.enum(devicePreviewStreamStopReasonValues);
742
+ var NormalizedCoordinateSchema = z11.number().finite().min(0).max(1);
733
743
  var devicePreviewTouchPhaseValues = ["down", "move", "up"];
734
- var DevicePreviewTouchPhaseSchema = z10.enum(devicePreviewTouchPhaseValues);
744
+ var DevicePreviewTouchPhaseSchema = z11.enum(devicePreviewTouchPhaseValues);
735
745
  var devicePreviewOrientationValues = [
736
746
  "portrait",
737
747
  "landscape_left",
@@ -739,102 +749,102 @@ var devicePreviewOrientationValues = [
739
749
  "portrait_upside_down",
740
750
  "auto"
741
751
  ];
742
- var DevicePreviewOrientationSchema = z10.enum(devicePreviewOrientationValues);
743
- var DevicePreviewInputSchema = z10.discriminatedUnion("kind", [
744
- z10.object({
745
- kind: z10.literal("touch"),
752
+ var DevicePreviewOrientationSchema = z11.enum(devicePreviewOrientationValues);
753
+ var DevicePreviewInputSchema = z11.discriminatedUnion("kind", [
754
+ z11.object({
755
+ kind: z11.literal("touch"),
746
756
  phase: DevicePreviewTouchPhaseSchema,
747
757
  x: NormalizedCoordinateSchema,
748
758
  y: NormalizedCoordinateSchema
749
759
  }).strict(),
750
- z10.object({
751
- kind: z10.literal("text"),
752
- text: z10.string().min(1).max(DEVICE_PREVIEW_TEXT_MAX_LENGTH)
760
+ z11.object({
761
+ kind: z11.literal("text"),
762
+ text: z11.string().min(1).max(DEVICE_PREVIEW_TEXT_MAX_LENGTH)
753
763
  }).strict(),
754
- z10.object({
755
- kind: z10.literal("button"),
756
- button: z10.enum(["home", "back"])
764
+ z11.object({
765
+ kind: z11.literal("button"),
766
+ button: z11.enum(["home", "back"])
757
767
  }).strict(),
758
- z10.object({
759
- kind: z10.literal("orientation"),
768
+ z11.object({
769
+ kind: z11.literal("orientation"),
760
770
  orientation: DevicePreviewOrientationSchema
761
771
  }).strict()
762
772
  ]);
763
- var DevicePreviewStreamRegisterSchema = z10.object({
764
- type: z10.literal("device_preview_stream_register"),
773
+ var DevicePreviewStreamRegisterSchema = z11.object({
774
+ type: z11.literal("device_preview_stream_register"),
765
775
  proxyId: IdSchema,
766
776
  connectionId: IdSchema
767
777
  }).strict();
768
- var DevicePreviewStreamRegisterResponseSchema = z10.discriminatedUnion("success", [
769
- z10.object({
770
- type: z10.literal("device_preview_stream_register_response"),
771
- success: z10.literal(true)
778
+ var DevicePreviewStreamRegisterResponseSchema = z11.discriminatedUnion("success", [
779
+ z11.object({
780
+ type: z11.literal("device_preview_stream_register_response"),
781
+ success: z11.literal(true)
772
782
  }).strict(),
773
- z10.object({
774
- type: z10.literal("device_preview_stream_register_response"),
775
- success: z10.literal(false),
776
- error: z10.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH)
783
+ z11.object({
784
+ type: z11.literal("device_preview_stream_register_response"),
785
+ success: z11.literal(false),
786
+ error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH)
777
787
  }).strict()
778
788
  ]);
779
- var DevicePreviewStreamFlowBaseSchema = z10.object({
780
- type: z10.literal("device_preview_stream_flow"),
789
+ var DevicePreviewStreamFlowBaseSchema = z11.object({
790
+ type: z11.literal("device_preview_stream_flow"),
781
791
  streamId: IdSchema
782
792
  });
783
- var DevicePreviewStreamFlowSchema = z10.discriminatedUnion("paused", [
793
+ var DevicePreviewStreamFlowSchema = z11.discriminatedUnion("paused", [
784
794
  DevicePreviewStreamFlowBaseSchema.extend({
785
- paused: z10.literal(true),
786
- resyncRequired: z10.literal(false)
795
+ paused: z11.literal(true),
796
+ resyncRequired: z11.literal(false)
787
797
  }).strict(),
788
798
  DevicePreviewStreamFlowBaseSchema.extend({
789
- paused: z10.literal(false),
790
- resyncRequired: z10.boolean()
799
+ paused: z11.literal(false),
800
+ resyncRequired: z11.boolean()
791
801
  }).strict()
792
802
  ]);
793
- var DevicePreviewStreamServerMessageSchema = z10.union([
803
+ var DevicePreviewStreamServerMessageSchema = z11.union([
794
804
  DevicePreviewStreamRegisterResponseSchema,
795
805
  DevicePreviewStreamFlowSchema
796
806
  ]);
797
807
 
798
808
  // ../../packages/shared/dist/schemas/voice-stream.js
799
- import { z as z11 } from "zod";
800
- var VoiceAsrAudioEncodingSchema = z11.enum(["pcm_s16le", "mulaw"]);
801
- var VoiceAsrStartMessageSchema = z11.object({
802
- type: z11.literal("start"),
803
- sessionId: z11.string().min(1),
804
- attemptId: z11.string().min(1),
805
- sampleRate: z11.number().int().positive(),
809
+ import { z as z12 } from "zod";
810
+ var VoiceAsrAudioEncodingSchema = z12.enum(["pcm_s16le", "mulaw"]);
811
+ var VoiceAsrStartMessageSchema = z12.object({
812
+ type: z12.literal("start"),
813
+ sessionId: z12.string().min(1),
814
+ attemptId: z12.string().min(1),
815
+ sampleRate: z12.number().int().positive(),
806
816
  encoding: VoiceAsrAudioEncodingSchema
807
817
  });
808
- var VoiceAsrStopMessageSchema = z11.object({
809
- type: z11.literal("stop"),
810
- attemptId: z11.string().min(1)
818
+ var VoiceAsrStopMessageSchema = z12.object({
819
+ type: z12.literal("stop"),
820
+ attemptId: z12.string().min(1)
811
821
  });
812
- var VoiceAsrClientMessageSchema = z11.discriminatedUnion("type", [
822
+ var VoiceAsrClientMessageSchema = z12.discriminatedUnion("type", [
813
823
  VoiceAsrStartMessageSchema,
814
824
  VoiceAsrStopMessageSchema
815
825
  ]);
816
- var VoiceAsrServerMessageSchema = z11.discriminatedUnion("type", [
817
- z11.object({ type: z11.literal("ready"), attemptId: z11.string().min(1) }),
818
- z11.object({
819
- type: z11.literal("audio_ack"),
820
- attemptId: z11.string().min(1),
821
- encodedBytes: z11.number().int().nonnegative(),
822
- pcmBytes: z11.number().int().nonnegative(),
823
- chunks: z11.number().int().nonnegative()
826
+ var VoiceAsrServerMessageSchema = z12.discriminatedUnion("type", [
827
+ z12.object({ type: z12.literal("ready"), attemptId: z12.string().min(1) }),
828
+ z12.object({
829
+ type: z12.literal("audio_ack"),
830
+ attemptId: z12.string().min(1),
831
+ encodedBytes: z12.number().int().nonnegative(),
832
+ pcmBytes: z12.number().int().nonnegative(),
833
+ chunks: z12.number().int().nonnegative()
824
834
  }),
825
- z11.object({ type: z11.literal("partial"), attemptId: z11.string().min(1), text: z11.string() }),
826
- z11.object({ type: z11.literal("final"), attemptId: z11.string().min(1), text: z11.string() }),
827
- z11.object({
828
- type: z11.literal("closed"),
829
- attemptId: z11.string().min(1),
830
- code: z11.number().int().optional(),
831
- reason: z11.string().optional()
835
+ z12.object({ type: z12.literal("partial"), attemptId: z12.string().min(1), text: z12.string() }),
836
+ z12.object({ type: z12.literal("final"), attemptId: z12.string().min(1), text: z12.string() }),
837
+ z12.object({
838
+ type: z12.literal("closed"),
839
+ attemptId: z12.string().min(1),
840
+ code: z12.number().int().optional(),
841
+ reason: z12.string().optional()
832
842
  }),
833
- z11.object({
834
- type: z11.literal("error"),
835
- attemptId: z11.string().min(1),
836
- error: z11.string().optional(),
837
- errorCode: z11.string().optional()
843
+ z12.object({
844
+ type: z12.literal("error"),
845
+ attemptId: z12.string().min(1),
846
+ error: z12.string().optional(),
847
+ errorCode: z12.string().optional()
838
848
  })
839
849
  ]);
840
850
 
@@ -844,7 +854,7 @@ function serializeControl(msg) {
844
854
  }
845
855
 
846
856
  // ../../packages/shared/dist/schemas/relay-control.js
847
- import { z as z12 } from "zod";
857
+ import { z as z13 } from "zod";
848
858
 
849
859
  // ../../packages/shared/dist/constants/relay-errors.js
850
860
  var RelayErrorCode = {
@@ -881,95 +891,95 @@ var ControlErrorCode = {
881
891
 
882
892
  // ../../packages/shared/dist/schemas/relay-control.js
883
893
  var RELAY_CONTROL_PROTOCOL_VERSION = 1;
884
- var ProxyInfoSchema = z12.object({
894
+ var ProxyInfoSchema = z13.object({
885
895
  proxyId: IdSchema,
886
- name: z12.string().optional(),
887
- version: z12.string().min(1).max(64),
888
- online: z12.boolean(),
889
- sessions: z12.array(z12.string())
896
+ name: z13.string().optional(),
897
+ version: z13.string().min(1).max(64),
898
+ online: z13.boolean(),
899
+ sessions: z13.array(z13.string())
890
900
  });
891
- var RelayClientInfoSchema = z12.object({
901
+ var RelayClientInfoSchema = z13.object({
892
902
  clientId: IdSchema,
893
903
  proxyId: IdSchema.optional(),
894
- connectedAt: z12.number().int().nonnegative(),
895
- current: z12.boolean().optional(),
896
- userAgent: z12.string().optional(),
897
- platform: z12.string().optional(),
898
- maxTouchPoints: z12.number().int().nonnegative().optional(),
899
- browserName: z12.string().min(1),
900
- osName: z12.string().min(1),
901
- deviceKind: z12.enum(["desktop", "tablet", "phone", "unknown"]),
902
- remoteAddress: z12.string().optional()
904
+ connectedAt: z13.number().int().nonnegative(),
905
+ current: z13.boolean().optional(),
906
+ userAgent: z13.string().optional(),
907
+ platform: z13.string().optional(),
908
+ maxTouchPoints: z13.number().int().nonnegative().optional(),
909
+ browserName: z13.string().min(1),
910
+ osName: z13.string().min(1),
911
+ deviceKind: z13.enum(["desktop", "tablet", "phone", "unknown"]),
912
+ remoteAddress: z13.string().optional()
903
913
  });
904
- var AgentCliAvailabilitySchema = z12.object({
905
- available: z12.boolean(),
906
- command: z12.string().optional(),
907
- error: z12.string().optional(),
908
- suggestions: z12.array(z12.string()).optional()
914
+ var AgentCliAvailabilitySchema = z13.object({
915
+ available: z13.boolean(),
916
+ command: z13.string().optional(),
917
+ error: z13.string().optional(),
918
+ suggestions: z13.array(z13.string()).optional()
909
919
  });
910
- var AgentCliStatusSchema = z12.object({
920
+ var AgentCliStatusSchema = z13.object({
911
921
  claude: AgentCliAvailabilitySchema,
912
922
  codex: AgentCliAvailabilitySchema,
913
923
  kimi: AgentCliAvailabilitySchema
914
924
  });
915
- var DirEntrySchema = z12.object({ name: z12.string(), isDir: z12.boolean() });
916
- var FileTreeGroupSchema = z12.object({
917
- path: z12.string(),
918
- entries: z12.array(DirEntrySchema)
925
+ var DirEntrySchema = z13.object({ name: z13.string(), isDir: z13.boolean() });
926
+ var FileTreeGroupSchema = z13.object({
927
+ path: z13.string(),
928
+ entries: z13.array(DirEntrySchema)
919
929
  });
920
- var CommandEntrySchema = z12.object({
921
- name: z12.string(),
922
- description: z12.string(),
923
- argumentHint: z12.string().optional(),
924
- source: z12.string()
930
+ var CommandEntrySchema = z13.object({
931
+ name: z13.string(),
932
+ description: z13.string(),
933
+ argumentHint: z13.string().optional(),
934
+ source: z13.string()
925
935
  });
926
- var HistorySessionSchema = z12.object({
927
- id: z12.string(),
928
- title: z12.string(),
929
- projectDir: z12.string(),
930
- updatedAt: z12.number(),
931
- provider: z12.enum(providerValues),
932
- preferredMode: z12.enum(sessionModeValues).optional()
936
+ var HistorySessionSchema = z13.object({
937
+ id: z13.string(),
938
+ title: z13.string(),
939
+ projectDir: z13.string(),
940
+ updatedAt: z13.number(),
941
+ provider: z13.enum(providerValues),
942
+ preferredMode: z13.enum(sessionModeValues).optional()
933
943
  });
934
944
  var SessionHistoryPositionShape = {
935
- timestamp: z12.number().optional(),
936
- cursor: z12.string().optional()
945
+ timestamp: z13.number().optional(),
946
+ cursor: z13.string().optional()
937
947
  };
938
- var SessionHistoryMessageSchema = z12.discriminatedUnion("role", [
939
- z12.object({
940
- role: z12.enum(["user", "assistant", "system"]),
941
- text: z12.string(),
948
+ var SessionHistoryMessageSchema = z13.discriminatedUnion("role", [
949
+ z13.object({
950
+ role: z13.enum(["user", "assistant", "system"]),
951
+ text: z13.string(),
942
952
  ...SessionHistoryPositionShape
943
953
  }),
944
- z12.object({
945
- role: z12.literal("activity"),
946
- text: z12.string(),
954
+ z13.object({
955
+ role: z13.literal("activity"),
956
+ text: z13.string(),
947
957
  toolId: IdSchema,
948
- toolName: z12.string(),
949
- parameters: z12.record(z12.string(), z12.unknown()).optional(),
950
- status: z12.enum(["running", "done", "error"]),
958
+ toolName: z13.string(),
959
+ parameters: z13.record(z13.string(), z13.unknown()).optional(),
960
+ status: z13.enum(["running", "done", "error"]),
951
961
  ...SessionHistoryPositionShape
952
962
  })
953
963
  ]);
954
964
  var RequestIdShape = { requestId: IdSchema.optional() };
955
965
  var RequiredRequestIdShape = { requestId: IdSchema };
956
- var ControlErrorCodeSchema = z12.enum(Object.values(ControlErrorCode));
966
+ var ControlErrorCodeSchema = z13.enum(Object.values(ControlErrorCode));
957
967
  var RequestErrorShape = {
958
- error: z12.string().optional(),
968
+ error: z13.string().optional(),
959
969
  errorCode: ControlErrorCodeSchema.optional()
960
970
  };
961
971
  var RequiredRequestErrorShape = {
962
- error: z12.string().min(1),
972
+ error: z13.string().min(1),
963
973
  errorCode: ControlErrorCodeSchema
964
974
  };
965
- var RemoteFileDispositionSchema = z12.enum(["inline", "download"]);
966
- var RemoteFileUploadKindSchema = z12.enum(["clipboard_image", "file"]);
975
+ var RemoteFileDispositionSchema = z13.enum(["inline", "download"]);
976
+ var RemoteFileUploadKindSchema = z13.enum(["clipboard_image", "file"]);
967
977
  function control(type, shape, directions) {
968
978
  return {
969
979
  type,
970
980
  directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
971
- schema: z12.object({
972
- type: z12.literal(type),
981
+ schema: z13.object({
982
+ type: z13.literal(type),
973
983
  ...shape ?? {}
974
984
  })
975
985
  };
@@ -978,8 +988,8 @@ function strictControl(type, shape, directions) {
978
988
  return {
979
989
  type,
980
990
  directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
981
- schema: z12.object({
982
- type: z12.literal(type),
991
+ schema: z13.object({
992
+ type: z13.literal(type),
983
993
  ...shape
984
994
  }).strict()
985
995
  };
@@ -991,300 +1001,300 @@ function controlSchema(type, schema, directions) {
991
1001
  schema
992
1002
  };
993
1003
  }
994
- var ProxySelectResponseSchema = z12.discriminatedUnion("success", [
995
- z12.object({
996
- type: z12.literal("proxy_select_response"),
1004
+ var ProxySelectResponseSchema = z13.discriminatedUnion("success", [
1005
+ z13.object({
1006
+ type: z13.literal("proxy_select_response"),
997
1007
  ...RequestIdShape,
998
- success: z12.literal(true),
1008
+ success: z13.literal(true),
999
1009
  proxyId: IdSchema,
1000
1010
  bindingId: IdSchema
1001
1011
  }).strict(),
1002
- z12.object({
1003
- type: z12.literal("proxy_select_response"),
1012
+ z13.object({
1013
+ type: z13.literal("proxy_select_response"),
1004
1014
  ...RequestIdShape,
1005
- success: z12.literal(false),
1015
+ success: z13.literal(false),
1006
1016
  ...RequestErrorShape
1007
1017
  }).strict()
1008
1018
  ]);
1009
- var ClientRegisterResponseSchema = z12.discriminatedUnion("status", [
1010
- z12.object({
1011
- type: z12.literal("client_register_response"),
1012
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1013
- status: z12.literal("restored"),
1019
+ var ClientRegisterResponseSchema = z13.discriminatedUnion("status", [
1020
+ z13.object({
1021
+ type: z13.literal("client_register_response"),
1022
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1023
+ status: z13.literal("restored"),
1014
1024
  proxyId: IdSchema,
1015
1025
  bindingId: IdSchema
1016
1026
  }).strict(),
1017
- z12.object({
1018
- type: z12.literal("client_register_response"),
1019
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1020
- status: z12.literal("proxy_offline"),
1027
+ z13.object({
1028
+ type: z13.literal("client_register_response"),
1029
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1030
+ status: z13.literal("proxy_offline"),
1021
1031
  proxyId: IdSchema,
1022
1032
  bindingId: IdSchema
1023
1033
  }).strict(),
1024
- z12.object({
1025
- type: z12.literal("client_register_response"),
1026
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1027
- status: z12.literal("new")
1034
+ z13.object({
1035
+ type: z13.literal("client_register_response"),
1036
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1037
+ status: z13.literal("new")
1028
1038
  }).strict()
1029
1039
  ]);
1030
- var PreviewCreateResponseSchema = z12.discriminatedUnion("accepted", [
1031
- z12.object({
1032
- type: z12.literal("preview_create_response"),
1040
+ var PreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1041
+ z13.object({
1042
+ type: z13.literal("preview_create_response"),
1033
1043
  ...RequiredRequestIdShape,
1034
1044
  scope: PreviewScopeSchema,
1035
1045
  operationId: IdSchema,
1036
- accepted: z12.literal(true),
1046
+ accepted: z13.literal(true),
1037
1047
  previewId: IdSchema
1038
1048
  }).strict(),
1039
- z12.object({
1040
- type: z12.literal("preview_create_response"),
1049
+ z13.object({
1050
+ type: z13.literal("preview_create_response"),
1041
1051
  ...RequiredRequestIdShape,
1042
1052
  scope: PreviewScopeSchema,
1043
1053
  operationId: IdSchema,
1044
- accepted: z12.literal(false),
1054
+ accepted: z13.literal(false),
1045
1055
  ...RequiredRequestErrorShape
1046
1056
  }).strict()
1047
1057
  ]);
1048
- var DevicePreviewCreateResponseSchema = z12.discriminatedUnion("accepted", [
1049
- z12.object({
1050
- type: z12.literal("device_preview_create_response"),
1058
+ var DevicePreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1059
+ z13.object({
1060
+ type: z13.literal("device_preview_create_response"),
1051
1061
  ...RequiredRequestIdShape,
1052
1062
  scope: PreviewScopeSchema,
1053
1063
  operationId: IdSchema,
1054
- accepted: z12.literal(true),
1064
+ accepted: z13.literal(true),
1055
1065
  previewId: IdSchema
1056
1066
  }).strict(),
1057
- z12.object({
1058
- type: z12.literal("device_preview_create_response"),
1067
+ z13.object({
1068
+ type: z13.literal("device_preview_create_response"),
1059
1069
  ...RequiredRequestIdShape,
1060
1070
  scope: PreviewScopeSchema,
1061
1071
  operationId: IdSchema,
1062
- accepted: z12.literal(false),
1072
+ accepted: z13.literal(false),
1063
1073
  ...RequiredRequestErrorShape
1064
1074
  }).strict()
1065
1075
  ]);
1066
- var PreviewCapabilityResponseSchema = z12.discriminatedUnion("success", [
1067
- z12.object({
1068
- type: z12.literal("preview_capability_response"),
1076
+ var PreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1077
+ z13.object({
1078
+ type: z13.literal("preview_capability_response"),
1069
1079
  ...RequiredRequestIdShape,
1070
1080
  scope: PreviewScopeSchema,
1071
- success: z12.literal(true),
1081
+ success: z13.literal(true),
1072
1082
  capability: WebPreviewCapabilitySchema
1073
1083
  }).strict(),
1074
- z12.object({
1075
- type: z12.literal("preview_capability_response"),
1084
+ z13.object({
1085
+ type: z13.literal("preview_capability_response"),
1076
1086
  ...RequiredRequestIdShape,
1077
1087
  scope: PreviewScopeSchema,
1078
- success: z12.literal(false),
1088
+ success: z13.literal(false),
1079
1089
  ...RequiredRequestErrorShape
1080
1090
  }).strict()
1081
1091
  ]);
1082
- var DevicePreviewCapabilityResponseSchema = z12.discriminatedUnion("success", [
1083
- z12.object({
1084
- type: z12.literal("device_preview_capability_response"),
1092
+ var DevicePreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1093
+ z13.object({
1094
+ type: z13.literal("device_preview_capability_response"),
1085
1095
  ...RequiredRequestIdShape,
1086
1096
  scope: PreviewScopeSchema,
1087
- success: z12.literal(true),
1097
+ success: z13.literal(true),
1088
1098
  capability: DevicePreviewCapabilitySchema
1089
1099
  }).strict(),
1090
- z12.object({
1091
- type: z12.literal("device_preview_capability_response"),
1100
+ z13.object({
1101
+ type: z13.literal("device_preview_capability_response"),
1092
1102
  ...RequiredRequestIdShape,
1093
1103
  scope: PreviewScopeSchema,
1094
- success: z12.literal(false),
1104
+ success: z13.literal(false),
1095
1105
  ...RequiredRequestErrorShape
1096
1106
  }).strict()
1097
1107
  ]);
1098
- var ProxyInfoRequestSchema = z12.object({
1099
- type: z12.literal("proxy_info_request"),
1108
+ var ProxyInfoRequestSchema = z13.object({
1109
+ type: z13.literal("proxy_info_request"),
1100
1110
  ...RequestIdShape
1101
1111
  }).strict();
1102
- var ProxyInfoResponseSchema = z12.object({
1103
- type: z12.literal("proxy_info"),
1112
+ var ProxyInfoResponseSchema = z13.object({
1113
+ type: z13.literal("proxy_info"),
1104
1114
  ...RequestIdShape,
1105
- homePath: z12.string(),
1115
+ homePath: z13.string(),
1106
1116
  agentCli: AgentCliStatusSchema
1107
1117
  }).strict();
1108
- var PreviewStaticInspectResponseSchema = z12.discriminatedUnion("success", [
1109
- z12.object({
1110
- type: z12.literal("preview_static_inspect_response"),
1118
+ var PreviewStaticInspectResponseSchema = z13.discriminatedUnion("success", [
1119
+ z13.object({
1120
+ type: z13.literal("preview_static_inspect_response"),
1111
1121
  ...RequiredRequestIdShape,
1112
1122
  scope: PreviewScopeSchema,
1113
- success: z12.literal(true),
1123
+ success: z13.literal(true),
1114
1124
  entryPath: WebPreviewPathSchema.optional(),
1115
1125
  htmlEntries: PreviewHtmlEntriesSchema
1116
1126
  }).strict(),
1117
- z12.object({
1118
- type: z12.literal("preview_static_inspect_response"),
1127
+ z13.object({
1128
+ type: z13.literal("preview_static_inspect_response"),
1119
1129
  ...RequiredRequestIdShape,
1120
1130
  scope: PreviewScopeSchema,
1121
- success: z12.literal(false),
1131
+ success: z13.literal(false),
1122
1132
  ...RequiredRequestErrorShape
1123
1133
  }).strict()
1124
1134
  ]);
1125
- var PreviewRenameResponseSchema = z12.discriminatedUnion("success", [
1126
- z12.object({
1127
- type: z12.literal("preview_rename_response"),
1135
+ var PreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1136
+ z13.object({
1137
+ type: z13.literal("preview_rename_response"),
1128
1138
  ...RequiredRequestIdShape,
1129
1139
  scope: PreviewScopeSchema,
1130
1140
  operationId: IdSchema,
1131
1141
  previewId: IdSchema,
1132
- success: z12.literal(true)
1142
+ success: z13.literal(true)
1133
1143
  }).strict(),
1134
- z12.object({
1135
- type: z12.literal("preview_rename_response"),
1144
+ z13.object({
1145
+ type: z13.literal("preview_rename_response"),
1136
1146
  ...RequiredRequestIdShape,
1137
1147
  scope: PreviewScopeSchema,
1138
1148
  operationId: IdSchema,
1139
1149
  previewId: IdSchema,
1140
- success: z12.literal(false),
1150
+ success: z13.literal(false),
1141
1151
  ...RequiredRequestErrorShape
1142
1152
  }).strict()
1143
1153
  ]);
1144
- var PreviewReconnectResponseSchema = z12.discriminatedUnion("success", [
1145
- z12.object({
1146
- type: z12.literal("preview_reconnect_response"),
1154
+ var PreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1155
+ z13.object({
1156
+ type: z13.literal("preview_reconnect_response"),
1147
1157
  ...RequiredRequestIdShape,
1148
1158
  scope: PreviewScopeSchema,
1149
1159
  operationId: IdSchema,
1150
1160
  previewId: IdSchema,
1151
- success: z12.literal(true)
1161
+ success: z13.literal(true)
1152
1162
  }).strict(),
1153
- z12.object({
1154
- type: z12.literal("preview_reconnect_response"),
1163
+ z13.object({
1164
+ type: z13.literal("preview_reconnect_response"),
1155
1165
  ...RequiredRequestIdShape,
1156
1166
  scope: PreviewScopeSchema,
1157
1167
  operationId: IdSchema,
1158
1168
  previewId: IdSchema,
1159
- success: z12.literal(false),
1169
+ success: z13.literal(false),
1160
1170
  ...RequiredRequestErrorShape
1161
1171
  }).strict()
1162
1172
  ]);
1163
- var PreviewCloseResponseSchema = z12.discriminatedUnion("success", [
1164
- z12.object({
1165
- type: z12.literal("preview_close_response"),
1173
+ var PreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1174
+ z13.object({
1175
+ type: z13.literal("preview_close_response"),
1166
1176
  ...RequiredRequestIdShape,
1167
1177
  scope: PreviewScopeSchema,
1168
1178
  operationId: IdSchema,
1169
1179
  previewId: IdSchema,
1170
- success: z12.literal(true)
1180
+ success: z13.literal(true)
1171
1181
  }).strict(),
1172
- z12.object({
1173
- type: z12.literal("preview_close_response"),
1182
+ z13.object({
1183
+ type: z13.literal("preview_close_response"),
1174
1184
  ...RequiredRequestIdShape,
1175
1185
  scope: PreviewScopeSchema,
1176
1186
  operationId: IdSchema,
1177
1187
  previewId: IdSchema,
1178
- success: z12.literal(false),
1188
+ success: z13.literal(false),
1179
1189
  ...RequiredRequestErrorShape
1180
1190
  }).strict()
1181
1191
  ]);
1182
- var DevicePreviewTargetsResponseSchema = z12.discriminatedUnion("success", [
1183
- z12.object({
1184
- type: z12.literal("device_preview_targets_response"),
1192
+ var DevicePreviewTargetsResponseSchema = z13.discriminatedUnion("success", [
1193
+ z13.object({
1194
+ type: z13.literal("device_preview_targets_response"),
1185
1195
  ...RequiredRequestIdShape,
1186
1196
  scope: PreviewScopeSchema,
1187
- success: z12.literal(true),
1188
- targets: z12.array(DevicePreviewTargetSchema).max(1024)
1197
+ success: z13.literal(true),
1198
+ targets: z13.array(DevicePreviewTargetSchema).max(1024)
1189
1199
  }).strict(),
1190
- z12.object({
1191
- type: z12.literal("device_preview_targets_response"),
1200
+ z13.object({
1201
+ type: z13.literal("device_preview_targets_response"),
1192
1202
  ...RequiredRequestIdShape,
1193
1203
  scope: PreviewScopeSchema,
1194
- success: z12.literal(false),
1204
+ success: z13.literal(false),
1195
1205
  ...RequiredRequestErrorShape
1196
1206
  }).strict()
1197
1207
  ]);
1198
- var DevicePreviewRenameResponseSchema = z12.discriminatedUnion("success", [
1199
- z12.object({
1200
- type: z12.literal("device_preview_rename_response"),
1208
+ var DevicePreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1209
+ z13.object({
1210
+ type: z13.literal("device_preview_rename_response"),
1201
1211
  ...RequiredRequestIdShape,
1202
1212
  scope: PreviewScopeSchema,
1203
1213
  operationId: IdSchema,
1204
1214
  previewId: IdSchema,
1205
- success: z12.literal(true)
1215
+ success: z13.literal(true)
1206
1216
  }).strict(),
1207
- z12.object({
1208
- type: z12.literal("device_preview_rename_response"),
1217
+ z13.object({
1218
+ type: z13.literal("device_preview_rename_response"),
1209
1219
  ...RequiredRequestIdShape,
1210
1220
  scope: PreviewScopeSchema,
1211
1221
  operationId: IdSchema,
1212
1222
  previewId: IdSchema,
1213
- success: z12.literal(false),
1223
+ success: z13.literal(false),
1214
1224
  ...RequiredRequestErrorShape
1215
1225
  }).strict()
1216
1226
  ]);
1217
- var DevicePreviewReconnectResponseSchema = z12.discriminatedUnion("success", [
1218
- z12.object({
1219
- type: z12.literal("device_preview_reconnect_response"),
1227
+ var DevicePreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1228
+ z13.object({
1229
+ type: z13.literal("device_preview_reconnect_response"),
1220
1230
  ...RequiredRequestIdShape,
1221
1231
  scope: PreviewScopeSchema,
1222
1232
  operationId: IdSchema,
1223
1233
  previewId: IdSchema,
1224
- success: z12.literal(true)
1234
+ success: z13.literal(true)
1225
1235
  }).strict(),
1226
- z12.object({
1227
- type: z12.literal("device_preview_reconnect_response"),
1236
+ z13.object({
1237
+ type: z13.literal("device_preview_reconnect_response"),
1228
1238
  ...RequiredRequestIdShape,
1229
1239
  scope: PreviewScopeSchema,
1230
1240
  operationId: IdSchema,
1231
1241
  previewId: IdSchema,
1232
- success: z12.literal(false),
1242
+ success: z13.literal(false),
1233
1243
  ...RequiredRequestErrorShape
1234
1244
  }).strict()
1235
1245
  ]);
1236
- var DevicePreviewCloseResponseSchema = z12.discriminatedUnion("success", [
1237
- z12.object({
1238
- type: z12.literal("device_preview_close_response"),
1246
+ var DevicePreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1247
+ z13.object({
1248
+ type: z13.literal("device_preview_close_response"),
1239
1249
  ...RequiredRequestIdShape,
1240
1250
  scope: PreviewScopeSchema,
1241
1251
  operationId: IdSchema,
1242
1252
  previewId: IdSchema,
1243
- success: z12.literal(true)
1253
+ success: z13.literal(true)
1244
1254
  }).strict(),
1245
- z12.object({
1246
- type: z12.literal("device_preview_close_response"),
1255
+ z13.object({
1256
+ type: z13.literal("device_preview_close_response"),
1247
1257
  ...RequiredRequestIdShape,
1248
1258
  scope: PreviewScopeSchema,
1249
1259
  operationId: IdSchema,
1250
1260
  previewId: IdSchema,
1251
- success: z12.literal(false),
1261
+ success: z13.literal(false),
1252
1262
  ...RequiredRequestErrorShape
1253
1263
  }).strict()
1254
1264
  ]);
1255
- var DevicePreviewStreamUrlResponseSchema = z12.discriminatedUnion("success", [
1256
- z12.object({
1257
- type: z12.literal("device_preview_stream_url_response"),
1265
+ var DevicePreviewStreamUrlResponseSchema = z13.discriminatedUnion("success", [
1266
+ z13.object({
1267
+ type: z13.literal("device_preview_stream_url_response"),
1258
1268
  ...RequiredRequestIdShape,
1259
1269
  scope: PreviewScopeSchema,
1260
1270
  previewId: IdSchema,
1261
- success: z12.literal(true),
1262
- url: z12.string().min(1).max(4096),
1271
+ success: z13.literal(true),
1272
+ url: z13.string().min(1).max(4096),
1263
1273
  leaseId: IdSchema,
1264
- expiresAt: z12.number().int().nonnegative(),
1265
- controlMode: z12.enum(["controller", "view_only"])
1274
+ expiresAt: z13.number().int().nonnegative(),
1275
+ controlMode: z13.enum(["controller", "view_only"])
1266
1276
  }).strict(),
1267
- z12.object({
1268
- type: z12.literal("device_preview_stream_url_response"),
1277
+ z13.object({
1278
+ type: z13.literal("device_preview_stream_url_response"),
1269
1279
  ...RequiredRequestIdShape,
1270
1280
  scope: PreviewScopeSchema,
1271
1281
  previewId: IdSchema,
1272
- success: z12.literal(false),
1282
+ success: z13.literal(false),
1273
1283
  ...RequiredRequestErrorShape
1274
1284
  }).strict()
1275
1285
  ]);
1276
1286
  var DevicePreviewStreamStartResponseBaseShape = {
1277
- type: z12.literal("device_preview_stream_start_response"),
1287
+ type: z13.literal("device_preview_stream_start_response"),
1278
1288
  streamId: IdSchema,
1279
1289
  leaseId: IdSchema,
1280
1290
  previewId: IdSchema
1281
1291
  };
1282
- var DevicePreviewStreamStartSuccessSchema = z12.object({
1292
+ var DevicePreviewStreamStartSuccessSchema = z13.object({
1283
1293
  ...DevicePreviewStreamStartResponseBaseShape,
1284
- success: z12.literal(true),
1294
+ success: z13.literal(true),
1285
1295
  format: DevicePreviewStreamFormatSchema,
1286
- width: z12.number().int().positive().max(16384).optional(),
1287
- height: z12.number().int().positive().max(16384).optional()
1296
+ width: z13.number().int().positive().max(16384).optional(),
1297
+ height: z13.number().int().positive().max(16384).optional()
1288
1298
  }).strict().superRefine((response, context) => {
1289
1299
  if (response.width === void 0 === (response.height === void 0))
1290
1300
  return;
@@ -1294,74 +1304,74 @@ var DevicePreviewStreamStartSuccessSchema = z12.object({
1294
1304
  message: "Device preview stream dimensions must include both width and height"
1295
1305
  });
1296
1306
  });
1297
- var DevicePreviewStreamStartResponseSchema = z12.discriminatedUnion("success", [
1307
+ var DevicePreviewStreamStartResponseSchema = z13.discriminatedUnion("success", [
1298
1308
  DevicePreviewStreamStartSuccessSchema,
1299
- z12.object({
1309
+ z13.object({
1300
1310
  ...DevicePreviewStreamStartResponseBaseShape,
1301
- success: z12.literal(false),
1311
+ success: z13.literal(false),
1302
1312
  ...RequiredRequestErrorShape
1303
1313
  }).strict()
1304
1314
  ]);
1305
- var DevicePreviewStreamCompleteSchema = z12.object({
1306
- type: z12.literal("device_preview_stream_complete"),
1315
+ var DevicePreviewStreamCompleteSchema = z13.object({
1316
+ type: z13.literal("device_preview_stream_complete"),
1307
1317
  streamId: IdSchema,
1308
1318
  leaseId: IdSchema,
1309
1319
  previewId: IdSchema,
1310
- success: z12.literal(false),
1311
- error: z12.string().min(1)
1320
+ success: z13.literal(false),
1321
+ error: z13.string().min(1)
1312
1322
  }).strict();
1313
1323
  var DevicePreviewStreamStartBaseShape = {
1314
- type: z12.literal("device_preview_stream_start"),
1324
+ type: z13.literal("device_preview_stream_start"),
1315
1325
  streamId: IdSchema,
1316
1326
  leaseId: IdSchema,
1317
1327
  previewId: IdSchema
1318
1328
  };
1319
- var DevicePreviewStreamStartSchema = z12.discriminatedUnion("format", [
1320
- z12.object({
1329
+ var DevicePreviewStreamStartSchema = z13.discriminatedUnion("format", [
1330
+ z13.object({
1321
1331
  ...DevicePreviewStreamStartBaseShape,
1322
1332
  ...DevicePreviewJpegStreamProfileSchema.shape
1323
1333
  }).strict(),
1324
- z12.object({
1334
+ z13.object({
1325
1335
  ...DevicePreviewStreamStartBaseShape,
1326
1336
  ...DevicePreviewH264StreamProfileSchema.shape
1327
1337
  }).strict()
1328
1338
  ]);
1329
- var DevicePreviewInputAckSchema = z12.discriminatedUnion("success", [
1330
- z12.object({
1331
- type: z12.literal("device_preview_input_ack"),
1339
+ var DevicePreviewInputAckSchema = z13.discriminatedUnion("success", [
1340
+ z13.object({
1341
+ type: z13.literal("device_preview_input_ack"),
1332
1342
  scope: PreviewScopeSchema,
1333
1343
  leaseId: IdSchema,
1334
- inputSeq: z12.number().int().min(0).max(4294967295),
1335
- success: z12.literal(true)
1344
+ inputSeq: z13.number().int().min(0).max(4294967295),
1345
+ success: z13.literal(true)
1336
1346
  }).strict(),
1337
- z12.object({
1338
- type: z12.literal("device_preview_input_ack"),
1347
+ z13.object({
1348
+ type: z13.literal("device_preview_input_ack"),
1339
1349
  scope: PreviewScopeSchema,
1340
1350
  leaseId: IdSchema,
1341
- inputSeq: z12.number().int().min(0).max(4294967295),
1342
- success: z12.literal(false),
1351
+ inputSeq: z13.number().int().min(0).max(4294967295),
1352
+ success: z13.literal(false),
1343
1353
  ...RequiredRequestErrorShape
1344
1354
  }).strict()
1345
1355
  ]);
1346
- var DevicePreviewControlClaimResponseSchema = z12.discriminatedUnion("success", [
1347
- z12.object({
1348
- type: z12.literal("device_preview_control_claim_response"),
1356
+ var DevicePreviewControlClaimResponseSchema = z13.discriminatedUnion("success", [
1357
+ z13.object({
1358
+ type: z13.literal("device_preview_control_claim_response"),
1349
1359
  ...RequiredRequestIdShape,
1350
1360
  scope: PreviewScopeSchema,
1351
1361
  leaseId: IdSchema,
1352
- success: z12.literal(true),
1353
- controlMode: z12.literal("controller")
1362
+ success: z13.literal(true),
1363
+ controlMode: z13.literal("controller")
1354
1364
  }).strict(),
1355
- z12.object({
1356
- type: z12.literal("device_preview_control_claim_response"),
1365
+ z13.object({
1366
+ type: z13.literal("device_preview_control_claim_response"),
1357
1367
  ...RequiredRequestIdShape,
1358
1368
  scope: PreviewScopeSchema,
1359
1369
  leaseId: IdSchema,
1360
- success: z12.literal(false),
1370
+ success: z13.literal(false),
1361
1371
  ...RequiredRequestErrorShape
1362
1372
  }).strict()
1363
1373
  ]);
1364
- var SessionPermissionModeSchema = z12.enum([
1374
+ var SessionPermissionModeSchema = z13.enum([
1365
1375
  "default",
1366
1376
  "auto",
1367
1377
  "acceptEdits",
@@ -1369,98 +1379,98 @@ var SessionPermissionModeSchema = z12.enum([
1369
1379
  "bypassPermissions",
1370
1380
  "dontAsk"
1371
1381
  ]);
1372
- var AgentJsonSessionCreateSchema = z12.object({
1373
- type: z12.literal("session_create"),
1382
+ var AgentJsonSessionCreateSchema = z13.object({
1383
+ type: z13.literal("session_create"),
1374
1384
  ...RequiredRequestIdShape,
1375
- kind: z12.literal("agent"),
1376
- cwd: z12.string(),
1377
- name: z12.string().optional(),
1378
- provider: z12.enum(providerValues),
1379
- mode: z12.literal("json"),
1380
- resumeSessionId: z12.string().optional(),
1385
+ kind: z13.literal("agent"),
1386
+ cwd: z13.string(),
1387
+ name: z13.string().optional(),
1388
+ provider: z13.enum(providerValues),
1389
+ mode: z13.literal("json"),
1390
+ resumeSessionId: z13.string().optional(),
1381
1391
  permissionMode: SessionPermissionModeSchema.optional()
1382
1392
  }).strict();
1383
- var AgentPtySessionCreateSchema = z12.object({
1384
- type: z12.literal("session_create"),
1393
+ var AgentPtySessionCreateSchema = z13.object({
1394
+ type: z13.literal("session_create"),
1385
1395
  ...RequiredRequestIdShape,
1386
- kind: z12.literal("agent"),
1387
- cwd: z12.string(),
1388
- name: z12.string().optional(),
1389
- provider: z12.enum(providerValues),
1390
- mode: z12.literal("pty"),
1391
- resumeSessionId: z12.string().optional(),
1392
- cols: z12.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1393
- rows: z12.number().int().positive().max(PTY_INITIAL_MAX_ROWS),
1396
+ kind: z13.literal("agent"),
1397
+ cwd: z13.string(),
1398
+ name: z13.string().optional(),
1399
+ provider: z13.enum(providerValues),
1400
+ mode: z13.literal("pty"),
1401
+ resumeSessionId: z13.string().optional(),
1402
+ cols: z13.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1403
+ rows: z13.number().int().positive().max(PTY_INITIAL_MAX_ROWS),
1394
1404
  permissionMode: SessionPermissionModeSchema.optional()
1395
1405
  }).strict();
1396
- var TerminalSessionCreateSchema = z12.object({
1397
- type: z12.literal("session_create"),
1406
+ var TerminalSessionCreateSchema = z13.object({
1407
+ type: z13.literal("session_create"),
1398
1408
  ...RequiredRequestIdShape,
1399
- kind: z12.literal("terminal"),
1400
- name: z12.string().optional(),
1401
- mode: z12.literal("pty"),
1402
- cols: z12.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1403
- rows: z12.number().int().positive().max(PTY_INITIAL_MAX_ROWS)
1409
+ kind: z13.literal("terminal"),
1410
+ name: z13.string().optional(),
1411
+ mode: z13.literal("pty"),
1412
+ cols: z13.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1413
+ rows: z13.number().int().positive().max(PTY_INITIAL_MAX_ROWS)
1404
1414
  }).strict();
1405
- var SessionCreateSchema = z12.discriminatedUnion("mode", [
1415
+ var SessionCreateSchema = z13.discriminatedUnion("mode", [
1406
1416
  AgentJsonSessionCreateSchema,
1407
- z12.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
1417
+ z13.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
1408
1418
  ]);
1409
1419
  var SessionCreateSuccessBaseShape = {
1410
- type: z12.literal("session_create_response"),
1420
+ type: z13.literal("session_create_response"),
1411
1421
  ...RequiredRequestIdShape,
1412
- success: z12.literal(true),
1422
+ success: z13.literal(true),
1413
1423
  sessionId: IdSchema,
1414
- cwd: z12.string(),
1415
- lastActive: z12.number(),
1416
- name: z12.string().optional(),
1417
- nameLocked: z12.boolean().optional()
1424
+ cwd: z13.string(),
1425
+ lastActive: z13.number(),
1426
+ name: z13.string().optional(),
1427
+ nameLocked: z13.boolean().optional()
1418
1428
  };
1419
- var SessionCreateSuccessResponseSchema = z12.discriminatedUnion("mode", [
1420
- z12.object({
1429
+ var SessionCreateSuccessResponseSchema = z13.discriminatedUnion("mode", [
1430
+ z13.object({
1421
1431
  ...SessionCreateSuccessBaseShape,
1422
- kind: z12.literal("agent"),
1423
- mode: z12.literal("json"),
1424
- provider: z12.enum(providerValues)
1432
+ kind: z13.literal("agent"),
1433
+ mode: z13.literal("json"),
1434
+ provider: z13.enum(providerValues)
1425
1435
  }).strict(),
1426
- z12.discriminatedUnion("kind", [
1427
- z12.object({
1436
+ z13.discriminatedUnion("kind", [
1437
+ z13.object({
1428
1438
  ...SessionCreateSuccessBaseShape,
1429
- kind: z12.literal("agent"),
1430
- mode: z12.literal("pty"),
1431
- provider: z12.enum(providerValues),
1432
- ptyOwner: z12.enum(ptyOwnerValues)
1439
+ kind: z13.literal("agent"),
1440
+ mode: z13.literal("pty"),
1441
+ provider: z13.enum(providerValues),
1442
+ ptyOwner: z13.enum(ptyOwnerValues)
1433
1443
  }).strict(),
1434
- z12.object({
1444
+ z13.object({
1435
1445
  ...SessionCreateSuccessBaseShape,
1436
- kind: z12.literal("terminal"),
1437
- mode: z12.literal("pty"),
1438
- provider: z12.literal("claude"),
1439
- ptyOwner: z12.literal("local-terminal")
1446
+ kind: z13.literal("terminal"),
1447
+ mode: z13.literal("pty"),
1448
+ provider: z13.literal("claude"),
1449
+ ptyOwner: z13.literal("local-terminal")
1440
1450
  }).strict()
1441
1451
  ])
1442
1452
  ]);
1443
- var SessionCreateResponseSchema = z12.discriminatedUnion("success", [
1453
+ var SessionCreateResponseSchema = z13.discriminatedUnion("success", [
1444
1454
  SessionCreateSuccessResponseSchema,
1445
- z12.object({
1446
- type: z12.literal("session_create_response"),
1455
+ z13.object({
1456
+ type: z13.literal("session_create_response"),
1447
1457
  ...RequiredRequestIdShape,
1448
- success: z12.literal(false),
1458
+ success: z13.literal(false),
1449
1459
  ...RequiredRequestErrorShape,
1450
- activeWriterPid: z12.number().int().positive().optional()
1460
+ activeWriterPid: z13.number().int().positive().optional()
1451
1461
  }).strict()
1452
1462
  ]);
1453
1463
  var relayControlDefinitions = [
1454
1464
  strictControl("proxy_register", {
1455
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1465
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1456
1466
  proxyId: IdSchema,
1457
- name: z12.string().optional(),
1458
- proxyVersion: z12.string().min(1).max(64)
1467
+ name: z13.string().optional(),
1468
+ proxyVersion: z13.string().min(1).max(64)
1459
1469
  }),
1460
1470
  strictControl("proxy_register_response", {
1461
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1462
- status: z12.enum(["new", "reconnected"]),
1463
- relayVersion: z12.string().min(1).max(64),
1471
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1472
+ status: z13.enum(["new", "reconnected"]),
1473
+ relayVersion: z13.string().min(1).max(64),
1464
1474
  // Relay rotates this nonce for every successful main Proxy registration. The dedicated image
1465
1475
  // stream socket must present it before Relay accepts frames, so a superseded Proxy connection
1466
1476
  // cannot keep publishing into a newly registered Proxy with the same persistent proxyId.
@@ -1469,7 +1479,7 @@ var relayControlDefinitions = [
1469
1479
  control("proxy_list_request", RequestIdShape),
1470
1480
  control("proxy_list_response", {
1471
1481
  ...RequestIdShape,
1472
- proxies: z12.array(ProxyInfoSchema)
1482
+ proxies: z13.array(ProxyInfoSchema)
1473
1483
  }),
1474
1484
  control("proxy_remove", {
1475
1485
  ...RequiredRequestIdShape,
@@ -1478,74 +1488,74 @@ var relayControlDefinitions = [
1478
1488
  control("proxy_remove_response", {
1479
1489
  ...RequiredRequestIdShape,
1480
1490
  proxyId: IdSchema,
1481
- success: z12.boolean(),
1491
+ success: z13.boolean(),
1482
1492
  ...RequestErrorShape
1483
1493
  }),
1484
1494
  control("relay_client_list_request", RequestIdShape),
1485
1495
  control("relay_client_list_response", {
1486
1496
  ...RequestIdShape,
1487
- clients: z12.array(RelayClientInfoSchema)
1497
+ clients: z13.array(RelayClientInfoSchema)
1488
1498
  }),
1489
1499
  control("relay_client_kick", { ...RequiredRequestIdShape, clientId: IdSchema }),
1490
1500
  control("relay_client_kick_response", {
1491
1501
  ...RequiredRequestIdShape,
1492
1502
  clientId: IdSchema,
1493
- success: z12.boolean(),
1503
+ success: z13.boolean(),
1494
1504
  ...RequestErrorShape
1495
1505
  }),
1496
1506
  control("relay_client_kicked", {
1497
- reason: z12.string().optional()
1507
+ reason: z13.string().optional()
1498
1508
  }),
1499
1509
  control("remote_file_url_request", {
1500
1510
  ...RequiredRequestIdShape,
1501
1511
  sessionId: IdSchema,
1502
- path: z12.string().min(1),
1512
+ path: z13.string().min(1),
1503
1513
  disposition: RemoteFileDispositionSchema
1504
1514
  }),
1505
1515
  control("remote_file_url_response", {
1506
1516
  ...RequiredRequestIdShape,
1507
1517
  ...RequestErrorShape,
1508
1518
  sessionId: IdSchema,
1509
- path: z12.string().optional(),
1510
- success: z12.boolean(),
1511
- url: z12.string().optional(),
1512
- expiresAt: z12.number().int().nonnegative().optional()
1519
+ path: z13.string().optional(),
1520
+ success: z13.boolean(),
1521
+ url: z13.string().optional(),
1522
+ expiresAt: z13.number().int().nonnegative().optional()
1513
1523
  }),
1514
1524
  control("remote_file_metadata_request", {
1515
1525
  ...RequiredRequestIdShape,
1516
1526
  sessionId: IdSchema,
1517
- path: z12.string().min(1)
1527
+ path: z13.string().min(1)
1518
1528
  }),
1519
1529
  control("remote_file_metadata_response", {
1520
1530
  ...RequiredRequestIdShape,
1521
1531
  ...RequestErrorShape,
1522
1532
  sessionId: IdSchema,
1523
- path: z12.string().optional(),
1524
- success: z12.boolean(),
1525
- mimeType: z12.string().optional(),
1526
- size: z12.number().int().nonnegative().optional(),
1527
- fileName: z12.string().optional()
1533
+ path: z13.string().optional(),
1534
+ success: z13.boolean(),
1535
+ mimeType: z13.string().optional(),
1536
+ size: z13.number().int().nonnegative().optional(),
1537
+ fileName: z13.string().optional()
1528
1538
  }),
1529
1539
  control("remote_file_stream_request", {
1530
1540
  streamId: IdSchema,
1531
1541
  sessionId: IdSchema,
1532
- path: z12.string().min(1),
1542
+ path: z13.string().min(1),
1533
1543
  disposition: RemoteFileDispositionSchema
1534
1544
  }),
1535
1545
  control("remote_file_stream_response", {
1536
1546
  ...RequestErrorShape,
1537
1547
  streamId: IdSchema,
1538
1548
  sessionId: IdSchema,
1539
- success: z12.boolean(),
1540
- path: z12.string().optional(),
1541
- mimeType: z12.string().optional(),
1542
- size: z12.number().int().nonnegative().optional(),
1543
- fileName: z12.string().optional()
1549
+ success: z13.boolean(),
1550
+ path: z13.string().optional(),
1551
+ mimeType: z13.string().optional(),
1552
+ size: z13.number().int().nonnegative().optional(),
1553
+ fileName: z13.string().optional()
1544
1554
  }),
1545
1555
  control("remote_file_stream_complete", {
1546
1556
  ...RequestErrorShape,
1547
1557
  streamId: IdSchema,
1548
- success: z12.boolean()
1558
+ success: z13.boolean()
1549
1559
  }),
1550
1560
  control("remote_file_stream_cancel", {
1551
1561
  streamId: IdSchema
@@ -1554,25 +1564,25 @@ var relayControlDefinitions = [
1554
1564
  ...RequiredRequestIdShape,
1555
1565
  sessionId: IdSchema,
1556
1566
  kind: RemoteFileUploadKindSchema,
1557
- fileName: z12.string().optional(),
1558
- mimeType: z12.string().min(1),
1559
- size: z12.number().int().nonnegative().optional()
1567
+ fileName: z13.string().optional(),
1568
+ mimeType: z13.string().min(1),
1569
+ size: z13.number().int().nonnegative().optional()
1560
1570
  }),
1561
1571
  control("remote_file_upload_url_response", {
1562
1572
  ...RequiredRequestIdShape,
1563
1573
  ...RequestErrorShape,
1564
1574
  sessionId: IdSchema,
1565
- success: z12.boolean(),
1566
- uploadUrl: z12.string().optional(),
1567
- expiresAt: z12.number().int().nonnegative().optional()
1575
+ success: z13.boolean(),
1576
+ uploadUrl: z13.string().optional(),
1577
+ expiresAt: z13.number().int().nonnegative().optional()
1568
1578
  }),
1569
1579
  control("remote_file_upload_stream_request", {
1570
1580
  uploadId: IdSchema,
1571
1581
  sessionId: IdSchema,
1572
1582
  kind: RemoteFileUploadKindSchema,
1573
- fileName: z12.string().optional(),
1574
- mimeType: z12.string().min(1),
1575
- size: z12.number().int().nonnegative().optional()
1583
+ fileName: z13.string().optional(),
1584
+ mimeType: z13.string().min(1),
1585
+ size: z13.number().int().nonnegative().optional()
1576
1586
  }),
1577
1587
  control("remote_file_upload_stream_complete", {
1578
1588
  uploadId: IdSchema
@@ -1584,14 +1594,14 @@ var relayControlDefinitions = [
1584
1594
  ...RequestErrorShape,
1585
1595
  uploadId: IdSchema,
1586
1596
  sessionId: IdSchema,
1587
- success: z12.boolean(),
1588
- path: z12.string().optional()
1597
+ success: z13.boolean(),
1598
+ path: z13.string().optional()
1589
1599
  }),
1590
1600
  control("proxy_select", { ...RequestIdShape, proxyId: IdSchema }),
1591
1601
  controlSchema("proxy_select_response", ProxySelectResponseSchema),
1592
1602
  control("relay_error", {
1593
- code: z12.enum(Object.values(RelayErrorCode)),
1594
- message: z12.string(),
1603
+ code: z13.enum(Object.values(RelayErrorCode)),
1604
+ message: z13.string(),
1595
1605
  // 可选 requestId: relay 把 client 发来 raw 的 requestId 字段透传回来,
1596
1606
  // client 侧 waitForMessage 据此把对应 pending request 立即拒掉而不必等到 timeout。
1597
1607
  requestId: IdSchema.optional()
@@ -1610,7 +1620,7 @@ var relayControlDefinitions = [
1610
1620
  control("voice_config_update_response", {
1611
1621
  ...RequestIdShape,
1612
1622
  ...RequestErrorShape,
1613
- success: z12.boolean(),
1623
+ success: z13.boolean(),
1614
1624
  config: VoiceProviderConfigSchema.optional()
1615
1625
  }),
1616
1626
  control("voice_config_test", {
@@ -1620,15 +1630,15 @@ var relayControlDefinitions = [
1620
1630
  control("voice_config_test_response", {
1621
1631
  ...RequestIdShape,
1622
1632
  ...RequestErrorShape,
1623
- success: z12.boolean(),
1624
- audioBase64: z12.string().optional(),
1625
- audioSampleRate: z12.number().int().positive().optional(),
1626
- audioEncoding: z12.literal("pcm_s16le").optional(),
1627
- transcript: z12.string().optional()
1633
+ success: z13.boolean(),
1634
+ audioBase64: z13.string().optional(),
1635
+ audioSampleRate: z13.number().int().positive().optional(),
1636
+ audioEncoding: z13.literal("pcm_s16le").optional(),
1637
+ transcript: z13.string().optional()
1628
1638
  }),
1629
1639
  control("voice_capabilities_request", {
1630
1640
  ...RequestIdShape,
1631
- region: z12.enum(voiceRegionValues).optional()
1641
+ region: z13.enum(voiceRegionValues).optional()
1632
1642
  }),
1633
1643
  control("voice_capabilities_response", {
1634
1644
  ...RequestIdShape,
@@ -1640,31 +1650,31 @@ var relayControlDefinitions = [
1640
1650
  control("latency_web_relay_ping", RequiredRequestIdShape),
1641
1651
  control("latency_web_relay_pong", {
1642
1652
  ...RequiredRequestIdShape,
1643
- relayNow: z12.number().optional()
1653
+ relayNow: z13.number().optional()
1644
1654
  }),
1645
1655
  control("latency_relay_proxy_request", RequiredRequestIdShape),
1646
1656
  control("latency_relay_proxy_response", {
1647
1657
  ...RequiredRequestIdShape,
1648
- success: z12.boolean(),
1649
- rttMs: z12.number().nonnegative().optional(),
1650
- error: z12.string().optional()
1658
+ success: z13.boolean(),
1659
+ rttMs: z13.number().nonnegative().optional(),
1660
+ error: z13.string().optional()
1651
1661
  }),
1652
1662
  control("latency_relay_proxy_ping", {
1653
1663
  ...RequiredRequestIdShape,
1654
- relayNow: z12.number().optional()
1664
+ relayNow: z13.number().optional()
1655
1665
  }),
1656
1666
  control("latency_relay_proxy_pong", {
1657
1667
  ...RequiredRequestIdShape,
1658
- proxyNow: z12.number().optional()
1668
+ proxyNow: z13.number().optional()
1659
1669
  }),
1660
1670
  control("latency_web_proxy_ping", RequiredRequestIdShape, "client_to_proxy"),
1661
- control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z12.number().optional() }, "proxy_to_client"),
1671
+ control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z13.number().optional() }, "proxy_to_client"),
1662
1672
  // Web preview is independent from Agent/terminal sessions. Relay rewrites requestId and routes
1663
1673
  // every response to the exact requesting WebSocket; only the two push messages are broadcast.
1664
1674
  strictControl("preview_capability_request", {
1665
1675
  ...RequiredRequestIdShape,
1666
1676
  scope: PreviewScopeSchema,
1667
- refreshPath: z12.boolean()
1677
+ refreshPath: z13.boolean()
1668
1678
  }, "client_to_proxy"),
1669
1679
  controlSchema("preview_capability_response", PreviewCapabilityResponseSchema, "proxy_to_client"),
1670
1680
  strictControl("preview_static_inspect_request", {
@@ -1687,8 +1697,8 @@ var relayControlDefinitions = [
1687
1697
  ...RequiredRequestIdShape,
1688
1698
  scope: PreviewScopeSchema,
1689
1699
  epoch: IdSchema,
1690
- revision: z12.number().int().nonnegative(),
1691
- previews: z12.array(PreviewSummarySchema)
1700
+ revision: z13.number().int().nonnegative(),
1701
+ previews: z13.array(PreviewSummarySchema)
1692
1702
  }, "proxy_to_client"),
1693
1703
  strictControl("preview_rename_request", {
1694
1704
  ...RequiredRequestIdShape,
@@ -1714,24 +1724,24 @@ var relayControlDefinitions = [
1714
1724
  controlSchema("preview_close_response", PreviewCloseResponseSchema, "proxy_to_client"),
1715
1725
  strictControl("preview_state_event", {
1716
1726
  epoch: IdSchema,
1717
- revision: z12.number().int().nonnegative(),
1727
+ revision: z13.number().int().nonnegative(),
1718
1728
  preview: PreviewSummarySchema
1719
1729
  }),
1720
1730
  strictControl("preview_removed_event", {
1721
1731
  epoch: IdSchema,
1722
- revision: z12.number().int().nonnegative(),
1732
+ revision: z13.number().int().nonnegative(),
1723
1733
  previewId: IdSchema
1724
1734
  }),
1725
1735
  strictControl("preview_state_push", {
1726
1736
  scope: PreviewScopeSchema,
1727
1737
  epoch: IdSchema,
1728
- revision: z12.number().int().nonnegative(),
1738
+ revision: z13.number().int().nonnegative(),
1729
1739
  preview: PreviewSummarySchema
1730
1740
  }, "proxy_to_client"),
1731
1741
  strictControl("preview_removed_push", {
1732
1742
  scope: PreviewScopeSchema,
1733
1743
  epoch: IdSchema,
1734
- revision: z12.number().int().nonnegative(),
1744
+ revision: z13.number().int().nonnegative(),
1735
1745
  previewId: IdSchema
1736
1746
  }, "proxy_to_client"),
1737
1747
  // Device previews are a sibling of Web previews under the product-level Preview entry, but
@@ -1740,13 +1750,13 @@ var relayControlDefinitions = [
1740
1750
  strictControl("device_preview_capability_request", {
1741
1751
  ...RequiredRequestIdShape,
1742
1752
  scope: PreviewScopeSchema,
1743
- refreshPath: z12.boolean()
1753
+ refreshPath: z13.boolean()
1744
1754
  }, "client_to_proxy"),
1745
1755
  controlSchema("device_preview_capability_response", DevicePreviewCapabilityResponseSchema, "proxy_to_client"),
1746
1756
  strictControl("device_preview_targets_request", {
1747
1757
  ...RequiredRequestIdShape,
1748
1758
  scope: PreviewScopeSchema,
1749
- refresh: z12.boolean()
1759
+ refresh: z13.boolean()
1750
1760
  }, "client_to_proxy"),
1751
1761
  controlSchema("device_preview_targets_response", DevicePreviewTargetsResponseSchema, "proxy_to_client"),
1752
1762
  strictControl("device_preview_create_request", {
@@ -1762,8 +1772,8 @@ var relayControlDefinitions = [
1762
1772
  ...RequiredRequestIdShape,
1763
1773
  scope: PreviewScopeSchema,
1764
1774
  epoch: IdSchema,
1765
- revision: z12.number().int().nonnegative(),
1766
- previews: z12.array(DevicePreviewSummarySchema).max(1024)
1775
+ revision: z13.number().int().nonnegative(),
1776
+ previews: z13.array(DevicePreviewSummarySchema).max(1024)
1767
1777
  }, "proxy_to_client"),
1768
1778
  strictControl("device_preview_rename_request", {
1769
1779
  ...RequiredRequestIdShape,
@@ -1789,24 +1799,24 @@ var relayControlDefinitions = [
1789
1799
  controlSchema("device_preview_close_response", DevicePreviewCloseResponseSchema, "proxy_to_client"),
1790
1800
  strictControl("device_preview_state_event", {
1791
1801
  epoch: IdSchema,
1792
- revision: z12.number().int().nonnegative(),
1802
+ revision: z13.number().int().nonnegative(),
1793
1803
  preview: DevicePreviewSummarySchema
1794
1804
  }),
1795
1805
  strictControl("device_preview_removed_event", {
1796
1806
  epoch: IdSchema,
1797
- revision: z12.number().int().nonnegative(),
1807
+ revision: z13.number().int().nonnegative(),
1798
1808
  previewId: IdSchema
1799
1809
  }),
1800
1810
  strictControl("device_preview_state_push", {
1801
1811
  scope: PreviewScopeSchema,
1802
1812
  epoch: IdSchema,
1803
- revision: z12.number().int().nonnegative(),
1813
+ revision: z13.number().int().nonnegative(),
1804
1814
  preview: DevicePreviewSummarySchema
1805
1815
  }, "proxy_to_client"),
1806
1816
  strictControl("device_preview_removed_push", {
1807
1817
  scope: PreviewScopeSchema,
1808
1818
  epoch: IdSchema,
1809
- revision: z12.number().int().nonnegative(),
1819
+ revision: z13.number().int().nonnegative(),
1810
1820
  previewId: IdSchema
1811
1821
  }, "proxy_to_client"),
1812
1822
  strictControl("device_preview_stream_url_request", {
@@ -1826,7 +1836,7 @@ var relayControlDefinitions = [
1826
1836
  strictControl("device_preview_input", {
1827
1837
  scope: PreviewScopeSchema,
1828
1838
  leaseId: IdSchema,
1829
- inputSeq: z12.number().int().min(0).max(4294967295),
1839
+ inputSeq: z13.number().int().min(0).max(4294967295),
1830
1840
  input: DevicePreviewInputSchema
1831
1841
  }, "client_to_proxy"),
1832
1842
  controlSchema("device_preview_input_ack", DevicePreviewInputAckSchema, "proxy_to_client"),
@@ -1834,7 +1844,7 @@ var relayControlDefinitions = [
1834
1844
  // browsers cannot abort another viewer's queued input, and Proxy never sends it to browsers.
1835
1845
  strictControl("device_preview_input_revoke", {
1836
1846
  leaseId: IdSchema,
1837
- reason: z12.literal("control_taken_over")
1847
+ reason: z13.literal("control_taken_over")
1838
1848
  }),
1839
1849
  strictControl("device_preview_control_claim_request", {
1840
1850
  ...RequiredRequestIdShape,
@@ -1845,18 +1855,18 @@ var relayControlDefinitions = [
1845
1855
  strictControl("device_preview_control_revoked_push", {
1846
1856
  scope: PreviewScopeSchema,
1847
1857
  leaseId: IdSchema,
1848
- reason: z12.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
1858
+ reason: z13.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
1849
1859
  }),
1850
1860
  // 客户端注册协议
1851
1861
  strictControl("client_register", {
1852
- protocolVersion: z12.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1862
+ protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1853
1863
  clientId: IdSchema,
1854
- userAgent: z12.string().optional(),
1855
- platform: z12.string().optional(),
1856
- maxTouchPoints: z12.number().int().nonnegative().optional(),
1857
- browserName: z12.string().min(1),
1858
- osName: z12.string().min(1),
1859
- deviceKind: z12.enum(["desktop", "tablet", "phone", "unknown"])
1864
+ userAgent: z13.string().optional(),
1865
+ platform: z13.string().optional(),
1866
+ maxTouchPoints: z13.number().int().nonnegative().optional(),
1867
+ browserName: z13.string().min(1),
1868
+ osName: z13.string().min(1),
1869
+ deviceKind: z13.enum(["desktop", "tablet", "phone", "unknown"])
1860
1870
  }),
1861
1871
  controlSchema("client_register_response", ClientRegisterResponseSchema),
1862
1872
  // Proxy 离线通知
@@ -1878,38 +1888,38 @@ var relayControlDefinitions = [
1878
1888
  // 目录列表请求与响应
1879
1889
  strictControl("dir_list_request", {
1880
1890
  ...RequestIdShape,
1881
- path: z12.string(),
1882
- includeHidden: z12.boolean()
1891
+ path: z13.string(),
1892
+ includeHidden: z13.boolean()
1883
1893
  }, "client_to_proxy"),
1884
1894
  control("dir_list_response", {
1885
1895
  ...RequestIdShape,
1886
1896
  ...RequestErrorShape,
1887
- entries: z12.array(DirEntrySchema),
1888
- path: z12.string(),
1889
- includeHidden: z12.boolean()
1897
+ entries: z13.array(DirEntrySchema),
1898
+ path: z13.string(),
1899
+ includeHidden: z13.boolean()
1890
1900
  }, "proxy_to_client"),
1891
1901
  // 目录创建请求与响应
1892
- control("dir_create_request", { ...RequestIdShape, path: z12.string() }, "client_to_proxy"),
1902
+ control("dir_create_request", { ...RequestIdShape, path: z13.string() }, "client_to_proxy"),
1893
1903
  control("dir_create_response", {
1894
1904
  ...RequestIdShape,
1895
1905
  ...RequestErrorShape,
1896
- path: z12.string(),
1897
- success: z12.boolean()
1906
+ path: z13.string(),
1907
+ success: z13.boolean()
1898
1908
  }, "proxy_to_client"),
1899
1909
  // 命令列表推送,proxy 将可用命令列表推给 client
1900
1910
  control("command_list_push", {
1901
1911
  sessionId: IdSchema,
1902
- commands: z12.array(CommandEntrySchema)
1912
+ commands: z13.array(CommandEntrySchema)
1903
1913
  }, "proxy_to_client"),
1904
1914
  // 文件树推送: 按目录分组, 首组 path 即为 session cwd。
1905
1915
  // 前端把它写入普通目录树;includeHidden=true 的按需响应使用独立缓存。
1906
1916
  control("file_tree_push", {
1907
- groups: z12.array(FileTreeGroupSchema)
1917
+ groups: z13.array(FileTreeGroupSchema)
1908
1918
  }, "proxy_to_client"),
1909
1919
  // 会话列表请求与权限模式变更
1910
1920
  strictControl("session_list_request", {}, "client_to_proxy"),
1911
1921
  control("permission_mode_change", {
1912
- mode: z12.enum(["default", "auto_accept", "plan"]),
1922
+ mode: z13.enum(["default", "auto_accept", "plan"]),
1913
1923
  // sessionId 可选:传入时 proxy 按该会话的 mode 分叉(PTY 发 Tab ANSI),未传走全局日志行为
1914
1924
  sessionId: IdSchema.optional()
1915
1925
  }, "client_to_proxy"),
@@ -1918,33 +1928,33 @@ var relayControlDefinitions = [
1918
1928
  control("session_history_response", {
1919
1929
  ...RequiredRequestIdShape,
1920
1930
  ...RequestErrorShape,
1921
- success: z12.boolean(),
1922
- sessions: z12.array(HistorySessionSchema)
1931
+ success: z13.boolean(),
1932
+ sessions: z13.array(HistorySessionSchema)
1923
1933
  }, "proxy_to_client"),
1924
1934
  // PTY 语义状态,从 Envelope 迁移到 Control 层
1925
1935
  control("pty_state", { sessionId: IdSchema, payload: PtyStatePayloadSchema }, "proxy_to_client"),
1926
1936
  // Provider 语义状态,来自 Claude/Codex hook 等结构化事件,不从 PTY 字节推断
1927
1937
  control("agent_status", { sessionId: IdSchema, payload: AgentStatusPayloadSchema }, "proxy_to_client"),
1928
1938
  // 终端标题变化,proxy -> client
1929
- control("terminal_title", { sessionId: IdSchema, title: z12.string() }, "proxy_to_client"),
1939
+ control("terminal_title", { sessionId: IdSchema, title: z13.string() }, "proxy_to_client"),
1930
1940
  // 终端尺寸变化,proxy -> client
1931
1941
  control("terminal_resize", {
1932
1942
  sessionId: IdSchema,
1933
- cols: z12.number().int().positive(),
1934
- rows: z12.number().int().positive(),
1943
+ cols: z13.number().int().positive(),
1944
+ rows: z13.number().int().positive(),
1935
1945
  // PTY output and resize events share one ordered render sequence. The client can therefore
1936
1946
  // place a resize between the exact byte frames that preceded and followed it.
1937
- outputSeq: z12.number().int().nonnegative()
1947
+ outputSeq: z13.number().int().nonnegative()
1938
1948
  }, "proxy_to_client"),
1939
- control("terminal_resize_request", { sessionId: IdSchema, cols: z12.number().int().positive(), rows: z12.number().int().positive() }, "client_to_proxy"),
1949
+ control("terminal_resize_request", { sessionId: IdSchema, cols: z13.number().int().positive(), rows: z13.number().int().positive() }, "client_to_proxy"),
1940
1950
  // 远程终止 JSON 会话,client -> proxy
1941
1951
  strictControl("session_terminate", { sessionId: IdSchema }, "client_to_proxy"),
1942
- control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z12.string() }, "client_to_proxy"),
1952
+ control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z13.string() }, "client_to_proxy"),
1943
1953
  control("session_rename_response", {
1944
1954
  ...RequestIdShape,
1945
1955
  sessionId: IdSchema,
1946
- success: z12.boolean(),
1947
- name: z12.string().optional(),
1956
+ success: z13.boolean(),
1957
+ name: z13.string().optional(),
1948
1958
  ...RequestErrorShape
1949
1959
  }, "proxy_to_client"),
1950
1960
  // 中断当前 turn,client -> proxy;JSON 由 session-worker 打断 Claude 子进程并保留会话。
@@ -1952,22 +1962,22 @@ var relayControlDefinitions = [
1952
1962
  // turn 完成信号,proxy -> client,对应 claude stream-json 的 result 事件
1953
1963
  control("turn_result", {
1954
1964
  sessionId: IdSchema,
1955
- success: z12.boolean(),
1956
- isError: z12.boolean(),
1965
+ success: z13.boolean(),
1966
+ isError: z13.boolean(),
1957
1967
  // stream-json result.result 是本轮最终文本。assistant_message 流丢失或 CLI 未发增量时,
1958
1968
  // Web 用它作为 JSON 模式兜底展示,避免 turn 已结束但界面空白。
1959
- result: z12.string().optional()
1969
+ result: z13.string().optional()
1960
1970
  }, "proxy_to_client"),
1961
1971
  // 客户端发送到 PTY 的原始字节(ANSI 序列),不追加换行
1962
- control("remote_input_raw", { sessionId: IdSchema, data: z12.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
1972
+ control("remote_input_raw", { sessionId: IdSchema, data: z13.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
1963
1973
  // 客户端询问 proxy 的环境信息 (home 路径等), client -> proxy -> response
1964
1974
  // FilePathPicker 用 homePath 作为 select 模式下的默认起点, 新建会话时打开即可浏览
1965
1975
  controlSchema("proxy_info_request", ProxyInfoRequestSchema, "client_to_proxy"),
1966
1976
  controlSchema("proxy_info", ProxyInfoResponseSchema, "proxy_to_client"),
1967
- control("agent_cli_config_update", { ...RequestIdShape, provider: z12.enum(providerValues), path: z12.string().min(1) }, "client_to_proxy"),
1977
+ control("agent_cli_config_update", { ...RequestIdShape, provider: z13.enum(providerValues), path: z13.string().min(1) }, "client_to_proxy"),
1968
1978
  control("agent_cli_config_update_response", {
1969
1979
  ...RequestIdShape,
1970
- provider: z12.enum(providerValues),
1980
+ provider: z13.enum(providerValues),
1971
1981
  agentCli: AgentCliStatusSchema.optional(),
1972
1982
  ...RequestErrorShape
1973
1983
  }, "proxy_to_client"),
@@ -1979,16 +1989,16 @@ var relayControlDefinitions = [
1979
1989
  // 非零退出。把可识别的运行时错误结构化推给 Web,避免关键错误只留在终端闪屏里。
1980
1990
  control("session_runtime_error", {
1981
1991
  sessionId: IdSchema,
1982
- error: z12.string(),
1992
+ error: z13.string(),
1983
1993
  errorCode: ControlErrorCodeSchema,
1984
- activeWriterPid: z12.number().int().positive().optional()
1994
+ activeWriterPid: z13.number().int().positive().optional()
1985
1995
  }, "proxy_to_client"),
1986
1996
  // 客户端请求会话历史消息,client -> proxy
1987
1997
  control("session_messages_request", {
1988
1998
  ...RequestIdShape,
1989
1999
  sessionId: IdSchema,
1990
- limit: z12.number().int().min(1).max(200).optional(),
1991
- before: z12.string().optional()
2000
+ limit: z13.number().int().min(1).max(200).optional(),
2001
+ before: z13.string().optional()
1992
2002
  }, "client_to_proxy"),
1993
2003
  // 客户端请求会话资源(命令列表 + 文件树),client -> proxy
1994
2004
  control("session_resources_request", { ...RequiredRequestIdShape, sessionId: IdSchema }, "client_to_proxy"),
@@ -1996,14 +2006,14 @@ var relayControlDefinitions = [
1996
2006
  ...RequiredRequestIdShape,
1997
2007
  ...RequestErrorShape,
1998
2008
  sessionId: IdSchema,
1999
- commands: z12.array(CommandEntrySchema),
2000
- groups: z12.array(FileTreeGroupSchema)
2009
+ commands: z13.array(CommandEntrySchema),
2010
+ groups: z13.array(FileTreeGroupSchema)
2001
2011
  }, "proxy_to_client"),
2002
2012
  // 客户端请求当前 provider 语义状态;不经 relay 缓存,由 proxy 返回当前值
2003
2013
  control("agent_status_request", { ...RequestIdShape, sessionId: IdSchema.optional() }, "client_to_proxy"),
2004
2014
  control("agent_status_response", {
2005
2015
  ...RequestIdShape,
2006
- statuses: z12.array(z12.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
2016
+ statuses: z13.array(z13.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
2007
2017
  }, "proxy_to_client"),
2008
2018
  // 客户端确认已收到审批请求;proxy 只记录送达状态,不把它当成用户决策
2009
2019
  control("permission_request_delivered", { sessionId: IdSchema, requestId: IdSchema }, "client_to_proxy"),
@@ -2013,18 +2023,18 @@ var relayControlDefinitions = [
2013
2023
  control("permission_decision_result", {
2014
2024
  sessionId: IdSchema,
2015
2025
  requestId: IdSchema,
2016
- outcome: z12.enum(["allow", "deny"]),
2017
- delivered: z12.boolean(),
2018
- message: z12.string().optional()
2026
+ outcome: z13.enum(["allow", "deny"]),
2027
+ delivered: z13.boolean(),
2028
+ message: z13.string().optional()
2019
2029
  }, "proxy_to_client"),
2020
2030
  // proxy 推送当前 pending 的工具审批列表,client 据此恢复审批卡片
2021
2031
  control("pending_approvals_push", {
2022
2032
  sessionId: IdSchema,
2023
- approvals: z12.array(z12.object({
2033
+ approvals: z13.array(z13.object({
2024
2034
  requestId: IdSchema,
2025
- toolName: z12.string(),
2026
- input: z12.record(z12.string(), z12.unknown()),
2027
- options: z12.array(ApprovalOptionSchema).optional()
2035
+ toolName: z13.string(),
2036
+ input: z13.record(z13.string(), z13.unknown()),
2037
+ options: z13.array(ApprovalOptionSchema).optional()
2028
2038
  }))
2029
2039
  }, "proxy_to_client"),
2030
2040
  // Voice Pilot speech summaries are produced by proxy-side Claude Code so it can read project context.
@@ -2032,7 +2042,7 @@ var relayControlDefinitions = [
2032
2042
  ...RequestIdShape,
2033
2043
  sessionId: IdSchema,
2034
2044
  messageId: IdSchema,
2035
- text: z12.string().min(1),
2045
+ text: z13.string().min(1),
2036
2046
  reason: VoiceSummaryReasonSchema
2037
2047
  }, "client_to_proxy"),
2038
2048
  control("voice_summary_response", {
@@ -2040,27 +2050,27 @@ var relayControlDefinitions = [
2040
2050
  ...RequestErrorShape,
2041
2051
  sessionId: IdSchema,
2042
2052
  messageId: IdSchema,
2043
- success: z12.boolean(),
2044
- summary: z12.string().min(1).optional()
2053
+ success: z13.boolean(),
2054
+ summary: z13.string().min(1).optional()
2045
2055
  }, "proxy_to_client"),
2046
2056
  // 恢复会话时推送历史消息,proxy -> client
2047
2057
  control("session_history_messages", {
2048
2058
  ...RequestIdShape,
2049
2059
  sessionId: IdSchema,
2050
- before: z12.string().optional(),
2051
- messages: z12.array(SessionHistoryMessageSchema),
2052
- hasMore: z12.boolean().optional(),
2053
- nextBefore: z12.string().optional()
2060
+ before: z13.string().optional(),
2061
+ messages: z13.array(SessionHistoryMessageSchema),
2062
+ hasMore: z13.boolean().optional(),
2063
+ nextBefore: z13.string().optional()
2054
2064
  }, "proxy_to_client"),
2055
2065
  // proxy 重连后同步活跃 session 列表给 relay。session_sync 由 relay 自消费(更新 proxy-session
2056
2066
  // 关联)不转发给 client,因此**没有** direction 标注——RelayControlDirection 只描述转发流。
2057
2067
  control("session_sync", {
2058
- sessions: z12.array(createSessionIdentitySchema({
2059
- id: z12.string(),
2060
- cwd: z12.string(),
2061
- name: z12.string().optional(),
2062
- nameLocked: z12.boolean().optional(),
2063
- state: z12.enum(sessionStateValues)
2068
+ sessions: z13.array(createSessionIdentitySchema({
2069
+ id: z13.string(),
2070
+ cwd: z13.string(),
2071
+ name: z13.string().optional(),
2072
+ nameLocked: z13.boolean().optional(),
2073
+ state: z13.enum(sessionStateValues)
2064
2074
  }))
2065
2075
  }),
2066
2076
  // PTY 会话订阅,client -> proxy,触发 terminal serialize() 返回当前状态
@@ -2068,15 +2078,15 @@ var relayControlDefinitions = [
2068
2078
  // PTY 会话快照,proxy -> client,serialize() 的全量终端状态
2069
2079
  control("session_snapshot", {
2070
2080
  sessionId: IdSchema,
2071
- cols: z12.number().int().positive(),
2072
- rows: z12.number().int().positive(),
2073
- data: z12.string(),
2074
- outputSeq: z12.number().int().nonnegative(),
2081
+ cols: z13.number().int().positive(),
2082
+ rows: z13.number().int().positive(),
2083
+ data: z13.string(),
2084
+ outputSeq: z13.number().int().nonnegative(),
2075
2085
  requestId: IdSchema
2076
2086
  }, "proxy_to_client")
2077
2087
  ];
2078
2088
  var relayControlSchemas = relayControlDefinitions.map((definition) => definition.schema);
2079
- var RelayControlSchema = z12.discriminatedUnion("type", relayControlSchemas);
2089
+ var RelayControlSchema = z13.discriminatedUnion("type", relayControlSchemas);
2080
2090
  var ProxyToClientRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("proxy_to_client")).map((definition) => definition.type));
2081
2091
  function isProxyToClientRelayControlType(type) {
2082
2092
  return ProxyToClientRelayControlTypes.has(type);
@@ -2099,6 +2109,29 @@ var RelayCloseCode = {
2099
2109
  DEVICE_STREAM_BINDING_REJECTED: 4404,
2100
2110
  PROXY_PROTOCOL_REJECTED: 4405
2101
2111
  };
2112
+ var RelayProtocolRejectReason = {
2113
+ PAGE_OUTDATED: "page_outdated",
2114
+ SERVICE_OUTDATED: "service_outdated",
2115
+ PROTOCOL_MISMATCH: "protocol_mismatch"
2116
+ };
2117
+ var ProxyProtocolAdmissionDirection = {
2118
+ COMPATIBLE: "compatible",
2119
+ PROXY_OUTDATED: "proxy_outdated",
2120
+ RELAY_OUTDATED: "relay_outdated",
2121
+ PROTOCOL_MISMATCH: "protocol_mismatch"
2122
+ };
2123
+ function isPositiveSafeProtocolVersion(value) {
2124
+ return Number.isSafeInteger(value) && value > 0;
2125
+ }
2126
+ function compareProxyRelayProtocolVersions(proxyProtocolVersion, relayProtocolVersion) {
2127
+ if (!isPositiveSafeProtocolVersion(proxyProtocolVersion) || !isPositiveSafeProtocolVersion(relayProtocolVersion)) {
2128
+ return ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH;
2129
+ }
2130
+ if (proxyProtocolVersion === relayProtocolVersion) {
2131
+ return ProxyProtocolAdmissionDirection.COMPATIBLE;
2132
+ }
2133
+ return proxyProtocolVersion < relayProtocolVersion ? ProxyProtocolAdmissionDirection.PROXY_OUTDATED : ProxyProtocolAdmissionDirection.RELAY_OUTDATED;
2134
+ }
2102
2135
 
2103
2136
  // ../../packages/shared/dist/constants/wire-limits.js
2104
2137
  var RELAY_JSON_MESSAGE_MAX_BYTES = 8 * 1024 * 1024;
@@ -2618,8 +2651,8 @@ var RelayRegistry = class {
2618
2651
  }
2619
2652
  getAllClientWs() {
2620
2653
  const clients = [];
2621
- for (const ws of this.connectedClients.keys()) {
2622
- if (ws.readyState === WebSocket.OPEN) {
2654
+ for (const [ws, metadata] of this.connectedClients) {
2655
+ if (metadata.clientId && ws.readyState === WebSocket.OPEN) {
2623
2656
  clients.push(ws);
2624
2657
  }
2625
2658
  }
@@ -2708,9 +2741,11 @@ function healthRouter(registry, options = {}) {
2708
2741
  const proxyTokenRequired = options.proxyTokenRequired ?? false;
2709
2742
  const clientTokenRequired = options.clientTokenRequired ?? false;
2710
2743
  router.get("/health", (_req, res) => {
2744
+ res.setHeader("Cache-Control", "no-store");
2711
2745
  res.json({
2712
2746
  status: "ok",
2713
2747
  version: RELAY_VERSION,
2748
+ controlProtocolVersion: RELAY_CONTROL_PROTOCOL_VERSION,
2714
2749
  uptime: process.uptime(),
2715
2750
  auth: {
2716
2751
  proxyTokenRequired,
@@ -2754,6 +2789,15 @@ function healthRouter(registry, options = {}) {
2754
2789
  res.status(401).json({ error: "invalid_proxy_token" });
2755
2790
  return false;
2756
2791
  }
2792
+ router.get("/api/proxy-upgrade-bootstrap", (req, res) => {
2793
+ if (!requireProxyTokenIfConfigured(req, res)) return;
2794
+ res.setHeader("Cache-Control", "no-store");
2795
+ res.json({
2796
+ bootstrapVersion: PROXY_UPGRADE_BOOTSTRAP_VERSION,
2797
+ relayVersion: RELAY_VERSION,
2798
+ controlProtocolVersion: RELAY_CONTROL_PROTOCOL_VERSION
2799
+ });
2800
+ });
2757
2801
  router.get("/status", (_req, res) => {
2758
2802
  res.json({
2759
2803
  version: RELAY_VERSION,
@@ -3141,6 +3185,56 @@ var WebPreviewRouteRegistry = class extends PreviewRouteRegistry {
3141
3185
  }
3142
3186
  };
3143
3187
 
3188
+ // src/proxy-upgrade-bootstrap.ts
3189
+ import { z as z14 } from "zod";
3190
+ var UPGRADE_BOOTSTRAP_SOURCE_VERSION = "0.8.1";
3191
+ var STABLE_VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
3192
+ var ProxyUpgradeBootstrapRequestSchema = z14.object({
3193
+ type: z14.literal("proxy_register"),
3194
+ proxyId: IdSchema,
3195
+ name: z14.string().optional(),
3196
+ proxyVersion: z14.literal(UPGRADE_BOOTSTRAP_SOURCE_VERSION)
3197
+ }).strict();
3198
+ function parseStableVersion(value) {
3199
+ const match = STABLE_VERSION_RE.exec(value);
3200
+ if (!match) return null;
3201
+ const parts = [Number(match[1]), Number(match[2]), Number(match[3])];
3202
+ return parts.every(Number.isSafeInteger) ? parts : null;
3203
+ }
3204
+ function isLowerStableVersion(source, target) {
3205
+ const left = parseStableVersion(source);
3206
+ const right = parseStableVersion(target);
3207
+ if (!left || !right) return false;
3208
+ for (let index = 0; index < left.length; index += 1) {
3209
+ if (left[index] !== right[index]) return left[index] < right[index];
3210
+ }
3211
+ return false;
3212
+ }
3213
+ function parseProxyUpgradeBootstrapRequest(raw, relayVersion) {
3214
+ let parsed;
3215
+ try {
3216
+ parsed = JSON.parse(raw);
3217
+ } catch {
3218
+ return null;
3219
+ }
3220
+ const request = ProxyUpgradeBootstrapRequestSchema.safeParse(parsed);
3221
+ if (!request.success) return null;
3222
+ if (!isLowerStableVersion(request.data.proxyVersion, relayVersion)) return null;
3223
+ return request.data;
3224
+ }
3225
+ function sendProxyUpgradeBootstrapResponse(ws, relayVersion) {
3226
+ ws.send(
3227
+ JSON.stringify({
3228
+ type: "proxy_register_response",
3229
+ status: "new",
3230
+ relayVersion
3231
+ }),
3232
+ (error) => {
3233
+ if (error) ws.terminate();
3234
+ }
3235
+ );
3236
+ }
3237
+
3144
3238
  // src/handlers/proxy.ts
3145
3239
  var PREVIEW_EVENT_TYPES = /* @__PURE__ */ new Set([
3146
3240
  "preview_state_event",
@@ -3154,6 +3248,8 @@ var PREVIEW_PUSH_TYPES = /* @__PURE__ */ new Set([
3154
3248
  "device_preview_state_push",
3155
3249
  "device_preview_removed_push"
3156
3250
  ]);
3251
+ var DEFAULT_PROXY_ADMISSION_TIMEOUT_MS = 1e4;
3252
+ var RETRYABLE_PROXY_ADMISSION_TIMEOUT_CLOSE_CODE = 1013;
3157
3253
  function isPreviewEventMessage(message) {
3158
3254
  return PREVIEW_EVENT_TYPES.has(message.type);
3159
3255
  }
@@ -3234,23 +3330,60 @@ function rejectNotRegistered(ws) {
3234
3330
  })
3235
3331
  );
3236
3332
  }
3237
- function closeRejectedProxyProtocol(ws) {
3238
- ws.close(RelayCloseCode.PROXY_PROTOCOL_REJECTED, "proxy protocol rejected");
3333
+ function closeRejectedProxyProtocol(ws, direction = ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH) {
3334
+ if (ws.admissionPhase === "rejected") return;
3335
+ ws.admissionPhase = "rejected";
3336
+ ws.close(RelayCloseCode.PROXY_PROTOCOL_REJECTED, direction);
3337
+ }
3338
+ function classifyInitialProxyProtocol(raw) {
3339
+ let value;
3340
+ try {
3341
+ value = JSON.parse(raw);
3342
+ } catch {
3343
+ return ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH;
3344
+ }
3345
+ if (!value || typeof value !== "object" || value.type !== "proxy_register") {
3346
+ return ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH;
3347
+ }
3348
+ const direction = compareProxyRelayProtocolVersions(
3349
+ value.protocolVersion,
3350
+ RELAY_CONTROL_PROTOCOL_VERSION
3351
+ );
3352
+ return direction === ProxyProtocolAdmissionDirection.COMPATIBLE ? null : direction;
3239
3353
  }
3240
3354
  function isCurrentProxySocket(ws, registry) {
3241
3355
  return ws.proxyId !== void 0 && registry.getProxy(ws.proxyId) === ws;
3242
3356
  }
3243
- function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionHistoryRoutes, webPreviewRoutes, devicePreviewBridge, chaos, remoteFileBridge) {
3357
+ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionHistoryRoutes, webPreviewRoutes, devicePreviewBridge, chaos, remoteFileBridge, proxyAdmissionTimeoutMs = DEFAULT_PROXY_ADMISSION_TIMEOUT_MS) {
3244
3358
  const proxyWs = ws;
3245
3359
  proxyWs.isAlive = true;
3360
+ proxyWs.admissionPhase = "awaiting";
3246
3361
  let registrationCompleted = false;
3362
+ let initialFrameReceived = false;
3363
+ const effectiveAdmissionTimeoutMs = Number.isSafeInteger(proxyAdmissionTimeoutMs) && proxyAdmissionTimeoutMs > 0 ? proxyAdmissionTimeoutMs : DEFAULT_PROXY_ADMISSION_TIMEOUT_MS;
3364
+ let admissionTimeout = setTimeout(() => {
3365
+ admissionTimeout = null;
3366
+ if (proxyWs.admissionPhase !== "awaiting" || proxyWs.readyState !== WebSocket4.OPEN) return;
3367
+ proxyWs.admissionPhase = "rejected";
3368
+ logger.warn({ timeoutMs: effectiveAdmissionTimeoutMs }, "Proxy registration timed out");
3369
+ proxyWs.close(RETRYABLE_PROXY_ADMISSION_TIMEOUT_CLOSE_CODE, "proxy registration timeout");
3370
+ }, effectiveAdmissionTimeoutMs);
3371
+ admissionTimeout.unref?.();
3372
+ const clearAdmissionTimeout = () => {
3373
+ if (!admissionTimeout) return;
3374
+ clearTimeout(admissionTimeout);
3375
+ admissionTimeout = null;
3376
+ };
3247
3377
  proxyWs.on("pong", () => {
3248
3378
  proxyWs.isAlive = true;
3249
3379
  });
3250
3380
  proxyWs.on("message", (data, isBinary) => {
3381
+ if (proxyWs.admissionPhase === "quarantined" || proxyWs.admissionPhase === "rejected") return;
3382
+ const isInitialFrame = !initialFrameReceived;
3383
+ initialFrameReceived = true;
3251
3384
  if (isBinary) {
3252
3385
  if (!proxyWs.proxyId) {
3253
- closeRejectedProxyProtocol(proxyWs);
3386
+ closeRejectedProxyProtocol(proxyWs, ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH);
3254
3387
  return;
3255
3388
  }
3256
3389
  if (!isCurrentProxySocket(proxyWs, registry)) {
@@ -3292,10 +3425,35 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3292
3425
  { size: data.length, proxyId: proxyWs.proxyId },
3293
3426
  "JSON message rejected: exceeds max size"
3294
3427
  );
3295
- if (!proxyWs.proxyId) closeRejectedProxyProtocol(proxyWs);
3428
+ if (!proxyWs.proxyId) {
3429
+ closeRejectedProxyProtocol(proxyWs, ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH);
3430
+ }
3296
3431
  return;
3297
3432
  }
3298
3433
  const raw = data.toString();
3434
+ const upgradeBootstrap = isInitialFrame ? parseProxyUpgradeBootstrapRequest(raw, RELAY_VERSION) : null;
3435
+ if (upgradeBootstrap) {
3436
+ proxyWs.admissionPhase = "quarantined";
3437
+ clearAdmissionTimeout();
3438
+ logger.info(
3439
+ {
3440
+ proxyId: upgradeBootstrap.proxyId,
3441
+ proxyVersion: upgradeBootstrap.proxyVersion,
3442
+ relayVersion: RELAY_VERSION
3443
+ },
3444
+ "Proxy upgrade bootstrap sent"
3445
+ );
3446
+ sendProxyUpgradeBootstrapResponse(proxyWs, RELAY_VERSION);
3447
+ return;
3448
+ }
3449
+ if (isInitialFrame) {
3450
+ const rejection = classifyInitialProxyProtocol(raw);
3451
+ if (rejection) {
3452
+ logger.warn({ direction: rejection }, "Proxy control protocol rejected before admission");
3453
+ closeRejectedProxyProtocol(proxyWs, rejection);
3454
+ return;
3455
+ }
3456
+ }
3299
3457
  const result = parseMessage(raw);
3300
3458
  if (result.kind === "control" && result.message.type === "proxy_register") {
3301
3459
  if (registrationCompleted) {
@@ -3303,10 +3461,12 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3303
3461
  { proxyId: proxyWs.proxyId, requestedProxyId: result.message.proxyId },
3304
3462
  "Repeated Proxy registration on the same socket rejected"
3305
3463
  );
3306
- closeRejectedProxyProtocol(proxyWs);
3464
+ closeRejectedProxyProtocol(proxyWs, ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH);
3307
3465
  return;
3308
3466
  }
3309
3467
  const { proxyId, name, proxyVersion } = result.message;
3468
+ proxyWs.admissionPhase = "ready";
3469
+ clearAdmissionTimeout();
3310
3470
  const status = registry.registerProxy(proxyId, proxyWs, proxyVersion, name);
3311
3471
  proxyWs.proxyId = proxyId;
3312
3472
  registrationCompleted = true;
@@ -3333,8 +3493,7 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3333
3493
  return;
3334
3494
  }
3335
3495
  if (!proxyWs.proxyId) {
3336
- rejectNotRegistered(proxyWs);
3337
- closeRejectedProxyProtocol(proxyWs);
3496
+ closeRejectedProxyProtocol(proxyWs, ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH);
3338
3497
  return;
3339
3498
  }
3340
3499
  if (!isCurrentProxySocket(proxyWs, registry)) {
@@ -3634,6 +3793,7 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3634
3793
  }
3635
3794
  });
3636
3795
  proxyWs.on("close", (code, reason) => {
3796
+ clearAdmissionTimeout();
3637
3797
  if (!proxyWs.proxyId) return;
3638
3798
  const closeMeta = { code, reason: reason.toString() || void 0 };
3639
3799
  const current = registry.getProxy(proxyWs.proxyId);
@@ -4398,15 +4558,45 @@ var DevicePreviewRouteRegistry = class extends PreviewRouteRegistry {
4398
4558
  }
4399
4559
  };
4400
4560
 
4401
- // src/handlers/client.ts
4402
- function isMalformedClientRegister(raw) {
4561
+ // src/client-registration-admission.ts
4562
+ function inspectClientRegistrationAdmission(raw) {
4563
+ let value;
4403
4564
  try {
4404
- const parsed = JSON.parse(raw);
4405
- return parsed !== null && typeof parsed === "object" && parsed.type === "client_register";
4565
+ value = JSON.parse(raw);
4406
4566
  } catch {
4407
- return false;
4567
+ return { kind: "not_client_registration" };
4408
4568
  }
4569
+ if (value === null || typeof value !== "object") {
4570
+ return { kind: "not_client_registration" };
4571
+ }
4572
+ const candidate = value;
4573
+ if (candidate.type !== "client_register") {
4574
+ return { kind: "not_client_registration" };
4575
+ }
4576
+ const clientId = typeof candidate.clientId === "string" ? candidate.clientId : void 0;
4577
+ if (!("protocolVersion" in candidate)) {
4578
+ return {
4579
+ kind: "unversioned_client_registration",
4580
+ ...clientId !== void 0 ? { clientId } : {}
4581
+ };
4582
+ }
4583
+ return {
4584
+ kind: "versioned_client_registration",
4585
+ ...clientId !== void 0 ? { clientId } : {},
4586
+ protocolVersion: candidate.protocolVersion
4587
+ };
4588
+ }
4589
+ function classifyClientRegistrationProtocol(clientVersion, relayVersion = RELAY_CONTROL_PROTOCOL_VERSION) {
4590
+ if (typeof clientVersion !== "number" || !Number.isSafeInteger(clientVersion) || clientVersion <= 0) {
4591
+ return RelayProtocolRejectReason.PROTOCOL_MISMATCH;
4592
+ }
4593
+ if (clientVersion === relayVersion) return null;
4594
+ return clientVersion < relayVersion ? RelayProtocolRejectReason.PAGE_OUTDATED : RelayProtocolRejectReason.SERVICE_OUTDATED;
4409
4595
  }
4596
+
4597
+ // src/handlers/client.ts
4598
+ var DEFAULT_CLIENT_ADMISSION_TIMEOUT_MS = 1e4;
4599
+ var RETRYABLE_CLIENT_ADMISSION_TIMEOUT_CLOSE_CODE = 1013;
4410
4600
  function handleClientRegister(registration, clientWs, registry, logger, webPreviewRoutes, devicePreviewBridge) {
4411
4601
  const { clientId } = registration;
4412
4602
  if (clientWs.clientId && clientWs.clientId !== clientId) {
@@ -4761,8 +4951,36 @@ function validatePreviewScope(ws, registry, requestId, scope) {
4761
4951
  rejectStaleBinding(ws, requestId);
4762
4952
  return false;
4763
4953
  }
4764
- function closeRejectedClientProtocol(ws) {
4765
- ws.close(RelayCloseCode.CLIENT_PROTOCOL_REJECTED, "client protocol rejected");
4954
+ function closeRejectedClientProtocol(ws, reason = RelayProtocolRejectReason.PROTOCOL_MISMATCH) {
4955
+ if (!beginClientRejection(ws)) return;
4956
+ ws.close(RelayCloseCode.CLIENT_PROTOCOL_REJECTED, reason);
4957
+ }
4958
+ function beginClientRejection(ws) {
4959
+ if (ws.admissionPhase === "rejected") return false;
4960
+ ws.admissionPhase = "rejected";
4961
+ return ws.readyState !== WebSocket7.CLOSING && ws.readyState !== WebSocket7.CLOSED;
4962
+ }
4963
+ function closeUnversionedClientProtocol(ws) {
4964
+ if (!beginClientRejection(ws)) return;
4965
+ ws.send(
4966
+ JSON.stringify({
4967
+ type: "relay_client_kicked",
4968
+ reason: "\u9875\u9762\u7248\u672C\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u5237\u65B0"
4969
+ })
4970
+ );
4971
+ ws.close(RelayCloseCode.CLIENT_KICKED, "client refresh required");
4972
+ }
4973
+ function rejectVersionedClientProtocol(ws, clientProtocolVersion, reason, clientId, logger) {
4974
+ logger.warn(
4975
+ {
4976
+ ...clientId !== void 0 ? { clientId } : {},
4977
+ clientProtocolVersion,
4978
+ relayProtocolVersion: RELAY_CONTROL_PROTOCOL_VERSION,
4979
+ reason
4980
+ },
4981
+ "Client control protocol rejected at admission"
4982
+ );
4983
+ closeRejectedClientProtocol(ws, reason);
4766
4984
  }
4767
4985
  function rejectProxySelect(ws, requestId, proxyId) {
4768
4986
  ws.send(
@@ -4815,14 +5033,33 @@ function sendRemoteFileUploadUrlFailure(ws, requestId, sessionId, error, errorCo
4815
5033
  })
4816
5034
  );
4817
5035
  }
4818
- function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, sessionHistoryRoutes, webPreviewRoutes, devicePreviewBridge, chaos, voiceConfigStore, voiceProviders, remoteFileBridge, connectionInfo = {}) {
5036
+ function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, sessionHistoryRoutes, webPreviewRoutes, devicePreviewBridge, chaos, voiceConfigStore, voiceProviders, remoteFileBridge, connectionInfo = {}, clientAdmissionTimeoutMs = DEFAULT_CLIENT_ADMISSION_TIMEOUT_MS) {
4819
5037
  const clientWs = ws;
4820
5038
  clientWs.isAlive = true;
5039
+ clientWs.admissionPhase = "awaiting";
4821
5040
  registry.addClientWs(clientWs, connectionInfo);
5041
+ const effectiveAdmissionTimeoutMs = Number.isSafeInteger(clientAdmissionTimeoutMs) && clientAdmissionTimeoutMs > 0 ? clientAdmissionTimeoutMs : DEFAULT_CLIENT_ADMISSION_TIMEOUT_MS;
5042
+ let admissionTimeout = setTimeout(() => {
5043
+ admissionTimeout = null;
5044
+ if (clientWs.admissionPhase !== "awaiting" || clientWs.readyState !== WebSocket7.OPEN) return;
5045
+ if (!beginClientRejection(clientWs)) return;
5046
+ logger.warn(
5047
+ { timeoutMs: effectiveAdmissionTimeoutMs, remoteAddress: connectionInfo.remoteAddress },
5048
+ "Client registration timed out"
5049
+ );
5050
+ clientWs.close(RETRYABLE_CLIENT_ADMISSION_TIMEOUT_CLOSE_CODE, "client registration timeout");
5051
+ }, effectiveAdmissionTimeoutMs);
5052
+ admissionTimeout.unref?.();
5053
+ const clearAdmissionTimeout = () => {
5054
+ if (!admissionTimeout) return;
5055
+ clearTimeout(admissionTimeout);
5056
+ admissionTimeout = null;
5057
+ };
4822
5058
  clientWs.on("pong", () => {
4823
5059
  clientWs.isAlive = true;
4824
5060
  });
4825
5061
  clientWs.on("message", (data, isBinary) => {
5062
+ if (clientWs.admissionPhase === "rejected") return;
4826
5063
  if (isBinary) {
4827
5064
  if (!clientWs.clientId) closeRejectedClientProtocol(clientWs);
4828
5065
  return;
@@ -4836,6 +5073,32 @@ function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, session
4836
5073
  return;
4837
5074
  }
4838
5075
  const raw = data.toString();
5076
+ const registrationAdmission = inspectClientRegistrationAdmission(raw);
5077
+ if (registrationAdmission.kind === "unversioned_client_registration") {
5078
+ logger.warn(
5079
+ {
5080
+ ...registrationAdmission.clientId !== void 0 ? { clientId: registrationAdmission.clientId } : {}
5081
+ },
5082
+ "Unversioned client registration rejected"
5083
+ );
5084
+ closeUnversionedClientProtocol(clientWs);
5085
+ return;
5086
+ }
5087
+ if (registrationAdmission.kind === "versioned_client_registration") {
5088
+ const registrationProtocolIssue = classifyClientRegistrationProtocol(
5089
+ registrationAdmission.protocolVersion
5090
+ );
5091
+ if (registrationProtocolIssue) {
5092
+ rejectVersionedClientProtocol(
5093
+ clientWs,
5094
+ registrationAdmission.protocolVersion,
5095
+ registrationProtocolIssue,
5096
+ registrationAdmission.clientId,
5097
+ logger
5098
+ );
5099
+ return;
5100
+ }
5101
+ }
4839
5102
  const result = parseMessage(raw);
4840
5103
  if (result.kind === "control") {
4841
5104
  const msg = result.message;
@@ -4852,6 +5115,8 @@ function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, session
4852
5115
  webPreviewRoutes,
4853
5116
  devicePreviewBridge
4854
5117
  );
5118
+ clientWs.admissionPhase = "ready";
5119
+ clearAdmissionTimeout();
4855
5120
  return;
4856
5121
  }
4857
5122
  if (!clientWs.clientId) {
@@ -5369,7 +5634,13 @@ function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, session
5369
5634
  routeClientMessage(raw, clientWs.boundProxyId, clientWs, registry, logger, chaos);
5370
5635
  return;
5371
5636
  }
5372
- logger.error({ error: result.error, raw: raw.slice(0, 200) }, "Invalid message from client");
5637
+ const isRegistrationAttempt = registrationAdmission.kind !== "not_client_registration";
5638
+ const logContext = {
5639
+ error: result.error,
5640
+ raw: raw.slice(0, 200),
5641
+ ...registrationAdmission.kind !== "not_client_registration" && registrationAdmission.clientId !== void 0 ? { clientId: registrationAdmission.clientId } : {}
5642
+ };
5643
+ logger.error(logContext, "Invalid message from client");
5373
5644
  clientWs.send(
5374
5645
  JSON.stringify({
5375
5646
  type: "relay_error",
@@ -5377,11 +5648,13 @@ function handleClientConnection(ws, registry, logger, ptySnapshotRoutes, session
5377
5648
  message: `${result.error} | raw: ${raw.slice(0, 200)}`
5378
5649
  })
5379
5650
  );
5380
- if (isMalformedClientRegister(raw) || !clientWs.clientId) {
5651
+ if (isRegistrationAttempt || !clientWs.clientId) {
5381
5652
  closeRejectedClientProtocol(clientWs);
5382
5653
  }
5383
5654
  });
5384
5655
  clientWs.on("close", (code, reason) => {
5656
+ clearAdmissionTimeout();
5657
+ clientWs.admissionPhase = "rejected";
5385
5658
  ptySnapshotRoutes.abandonSocket(clientWs);
5386
5659
  sessionHistoryRoutes.abandonSocket(clientWs);
5387
5660
  webPreviewRoutes.abandonSocket(clientWs);
@@ -8480,7 +8753,8 @@ function createRelayServer(options) {
8480
8753
  webPreviewRoutes,
8481
8754
  devicePreviewBridge,
8482
8755
  relayChaos,
8483
- remoteFileBridge
8756
+ remoteFileBridge,
8757
+ options.proxyAdmissionTimeoutMs
8484
8758
  );
8485
8759
  });
8486
8760
  devicePreviewStreamWss.on("connection", (ws) => {
@@ -8502,7 +8776,8 @@ function createRelayServer(options) {
8502
8776
  {
8503
8777
  userAgent: firstHeaderValue(request.headers["user-agent"]),
8504
8778
  remoteAddress: requestRemoteAddress(request)
8505
- }
8779
+ },
8780
+ options.clientAdmissionTimeoutMs
8506
8781
  );
8507
8782
  });
8508
8783
  voiceAsrWss.on("connection", (ws) => {
@@ -8609,4 +8884,4 @@ export {
8609
8884
  parseRelayChaosFromEnv,
8610
8885
  createRelayServer
8611
8886
  };
8612
- //# sourceMappingURL=chunk-27ZHYXYL.js.map
8887
+ //# sourceMappingURL=chunk-RGMU7VLD.js.map