@dev-anywhere/relay 0.9.3 → 0.9.5

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.
@@ -31,10 +31,10 @@ var AssistantMessagePayloadSchema = z2.object({
31
31
  revision: z2.number().int().positive(),
32
32
  text: z2.string(),
33
33
  status: z2.enum(["streaming", "completed"])
34
- }).strict();
34
+ });
35
35
  var ThinkingPayloadSchema = z2.object({
36
36
  text: z2.string()
37
- }).strict();
37
+ });
38
38
 
39
39
  // ../../packages/shared/dist/schemas/tool.js
40
40
  import { z as z3 } from "zod";
@@ -48,13 +48,13 @@ var ApprovalOptionSchema = z3.object({
48
48
  optionId: IdSchema,
49
49
  name: z3.string().min(1),
50
50
  kind: ApprovalOptionKindSchema
51
- }).strict();
51
+ });
52
52
  var ToolUseRequestPayloadSchema = z3.object({
53
53
  toolName: z3.string(),
54
54
  toolId: IdSchema,
55
55
  parameters: z3.record(z3.string(), z3.unknown()),
56
56
  options: z3.array(ApprovalOptionSchema).optional()
57
- }).strict();
57
+ });
58
58
  var ToolApprovePayloadSchema = z3.object({
59
59
  toolId: IdSchema,
60
60
  whitelistTool: z3.boolean().optional(),
@@ -69,7 +69,7 @@ var ToolResultPayloadSchema = z3.object({
69
69
  toolId: IdSchema,
70
70
  result: z3.unknown(),
71
71
  isError: z3.boolean()
72
- }).strict();
72
+ });
73
73
 
74
74
  // ../../packages/shared/dist/schemas/session.js
75
75
  import { z as z4 } from "zod";
@@ -116,22 +116,23 @@ function createSessionIdentitySchema(commonFields) {
116
116
  ...commonFields,
117
117
  kind: z4.literal("agent"),
118
118
  mode: z4.literal("json"),
119
- provider: z4.enum(providerValues)
120
- }).strict(),
119
+ provider: z4.enum(providerValues),
120
+ ptyOwner: z4.never().optional()
121
+ }),
121
122
  z4.object({
122
123
  ...commonFields,
123
124
  kind: z4.literal("agent"),
124
125
  mode: z4.literal("pty"),
125
126
  provider: z4.enum(providerValues),
126
127
  ptyOwner: z4.enum(ptyOwnerValues)
127
- }).strict(),
128
+ }),
128
129
  z4.object({
129
130
  ...commonFields,
130
131
  kind: z4.literal("terminal"),
131
132
  mode: z4.literal("pty"),
132
133
  provider: z4.literal("claude"),
133
134
  ptyOwner: z4.literal("proxy-hosted")
134
- }).strict()
135
+ })
135
136
  ]);
136
137
  }
137
138
  var SessionInfoSchema = createSessionIdentitySchema({
@@ -146,12 +147,12 @@ var SessionInfoSchema = createSessionIdentitySchema({
146
147
  });
147
148
  var SessionListPayloadSchema = z4.object({
148
149
  sessions: z4.array(SessionInfoSchema)
149
- }).strict();
150
+ });
150
151
  var SessionStatusPayloadSchema = z4.object({
151
152
  sessionId: IdSchema,
152
153
  state: z4.enum(sessionStateValues),
153
154
  lastActive: z4.number()
154
- }).strict();
155
+ });
155
156
  var PtyStatePayloadSchema = z4.object({
156
157
  state: z4.enum(ptySemanticStateValues),
157
158
  seq: z4.number().int().nonnegative(),
@@ -179,7 +180,7 @@ var AgentStatusPayloadSchema = z4.object({
179
180
 
180
181
  // ../../packages/shared/dist/schemas/system.js
181
182
  import { z as z5 } from "zod";
182
- var HeartbeatPayloadSchema = z5.object({}).strict();
183
+ var HeartbeatPayloadSchema = z5.object({});
183
184
  var AuthPayloadSchema = z5.object({
184
185
  pairingCode: z5.string().optional(),
185
186
  token: z5.string().optional()
@@ -189,7 +190,7 @@ var SyncRequestPayloadSchema = z5.object({
189
190
  }).strict();
190
191
  var SyncResponsePayloadSchema = z5.object({
191
192
  messages: z5.array(z5.record(z5.string(), z5.unknown()))
192
- }).strict();
193
+ });
193
194
 
194
195
  // ../../packages/shared/dist/schemas/envelope.js
195
196
  var BaseEnvelopeFields = {
@@ -202,6 +203,10 @@ var SessionedEnvelopeFields = {
202
203
  ...BaseEnvelopeFields,
203
204
  sessionId: IdSchema
204
205
  };
206
+ var GlobalEnvelopeFields = {
207
+ ...BaseEnvelopeFields,
208
+ sessionId: z6.never().optional()
209
+ };
205
210
  var MessageEnvelopeSchema = z6.discriminatedUnion("type", [
206
211
  // chat (3)
207
212
  z6.object({
@@ -213,65 +218,65 @@ var MessageEnvelopeSchema = z6.discriminatedUnion("type", [
213
218
  ...SessionedEnvelopeFields,
214
219
  type: z6.literal("assistant_message"),
215
220
  payload: AssistantMessagePayloadSchema
216
- }).strict(),
221
+ }),
217
222
  z6.object({
218
223
  ...SessionedEnvelopeFields,
219
224
  type: z6.literal("thinking"),
220
225
  payload: ThinkingPayloadSchema
221
- }).strict(),
226
+ }),
222
227
  // tool (4): 工具审批决策属于 relay control,不进入会话消息信封。
223
228
  // tool_use_request: 审批流请求(proxy → client),toolId 是 approval requestId
224
229
  z6.object({
225
230
  ...SessionedEnvelopeFields,
226
231
  type: z6.literal("tool_use_request"),
227
232
  payload: ToolUseRequestPayloadSchema
228
- }).strict(),
233
+ }),
229
234
  // tool_result: 工具执行结果(proxy → client),toolId 对应 assistant_tool_use / tool_use_request 的 toolId
230
235
  z6.object({
231
236
  ...SessionedEnvelopeFields,
232
237
  type: z6.literal("tool_result"),
233
238
  payload: ToolResultPayloadSchema
234
- }).strict(),
239
+ }),
235
240
  // assistant_tool_use: 纯展示型工具调用(proxy → client),区别于 tool_use_request 无审批语义
236
241
  // payload 结构复用 ToolUseRequestPayloadSchema;toolId 是 Claude 分配的 tool_use id
237
242
  z6.object({
238
243
  ...SessionedEnvelopeFields,
239
244
  type: z6.literal("assistant_tool_use"),
240
245
  payload: ToolUseRequestPayloadSchema
241
- }).strict(),
246
+ }),
242
247
  // session (2)
243
248
  // session_list 是全局广播 (列出所有 session), 不绑定具体 sessionId, 不携带该字段。
244
249
  z6.object({
245
- ...BaseEnvelopeFields,
250
+ ...GlobalEnvelopeFields,
246
251
  type: z6.literal("session_list"),
247
252
  payload: SessionListPayloadSchema
248
- }).strict(),
253
+ }),
249
254
  z6.object({
250
255
  ...SessionedEnvelopeFields,
251
256
  type: z6.literal("session_status"),
252
257
  payload: SessionStatusPayloadSchema
253
- }).strict(),
258
+ }),
254
259
  // system (5): 心跳 / 认证 / 同步——全局, 无 sessionId
255
260
  z6.object({
256
- ...BaseEnvelopeFields,
261
+ ...GlobalEnvelopeFields,
257
262
  type: z6.literal("heartbeat"),
258
263
  payload: HeartbeatPayloadSchema
259
- }).strict(),
264
+ }),
260
265
  z6.object({
261
- ...BaseEnvelopeFields,
266
+ ...GlobalEnvelopeFields,
262
267
  type: z6.literal("auth"),
263
268
  payload: AuthPayloadSchema
264
269
  }).strict(),
265
270
  z6.object({
266
- ...BaseEnvelopeFields,
271
+ ...GlobalEnvelopeFields,
267
272
  type: z6.literal("sync_request"),
268
273
  payload: SyncRequestPayloadSchema
269
274
  }).strict(),
270
275
  z6.object({
271
- ...BaseEnvelopeFields,
276
+ ...GlobalEnvelopeFields,
272
277
  type: z6.literal("sync_response"),
273
278
  payload: SyncResponsePayloadSchema
274
- }).strict()
279
+ })
275
280
  ]);
276
281
 
277
282
  // ../../packages/shared/dist/schemas/voice.js
@@ -287,8 +292,11 @@ var VoiceProviderConfigSchema = z7.object({
287
292
  asrModel: z7.string().min(1),
288
293
  ttsModel: z7.string().min(1),
289
294
  ttsVoice: z7.string().min(1),
290
- turnIdleSeconds: z7.number().int().positive().safe().default(3)
291
- }).strict();
295
+ turnIdleSeconds: z7.number().int().positive().safe().default(3),
296
+ // 密钥及其写入操作不属于可公开的配置描述。
297
+ apiKey: z7.never().optional(),
298
+ clearApiKey: z7.never().optional()
299
+ });
292
300
  var VoiceConfigUpdateSchema = z7.object({
293
301
  provider: z7.enum(voiceProviderValues).optional(),
294
302
  apiKey: z7.string().min(1).optional(),
@@ -307,13 +315,13 @@ var VoiceOptionSchema = z7.object({
307
315
  age: z7.string().min(1).optional(),
308
316
  model: z7.string().min(1).optional(),
309
317
  source: z7.enum(voiceOptionSourceValues)
310
- }).strict();
318
+ });
311
319
  var VoiceCapabilitiesSchema = z7.object({
312
320
  asrModels: z7.array(VoiceOptionSchema),
313
321
  ttsModels: z7.array(VoiceOptionSchema),
314
322
  ttsVoices: z7.array(VoiceOptionSchema),
315
323
  fetchedAt: z7.number().optional()
316
- }).strict();
324
+ });
317
325
  var BUNDLED_BAILIAN_ASR_MODELS = [
318
326
  {
319
327
  value: "qwen3-asr-flash-realtime",
@@ -535,19 +543,19 @@ var WebPreviewTunnelStatusSchema = z10.discriminatedUnion("available", [
535
543
  version: z10.string().min(1).max(256).optional(),
536
544
  error: z10.never().optional(),
537
545
  suggestions: WebPreviewTunnelSuggestionsSchema
538
- }).strict(),
546
+ }),
539
547
  z10.object({
540
548
  available: z10.literal(false),
541
549
  command: z10.never().optional(),
542
550
  version: z10.never().optional(),
543
551
  error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH),
544
552
  suggestions: WebPreviewTunnelSuggestionsSchema
545
- }).strict()
553
+ })
546
554
  ]);
547
555
  var WebPreviewCapabilitySchema = z10.object({
548
556
  cloudflared: WebPreviewTunnelStatusSchema,
549
557
  cpolar: WebPreviewTunnelStatusSchema
550
- }).strict();
558
+ });
551
559
  var WebPreviewSourceInputSchema = z10.discriminatedUnion("kind", [
552
560
  z10.object({
553
561
  kind: z10.literal("local"),
@@ -562,13 +570,16 @@ var WebPreviewSourceInputSchema = z10.discriminatedUnion("kind", [
562
570
  var PreviewSourceSchema = z10.discriminatedUnion("kind", [
563
571
  z10.object({
564
572
  kind: z10.literal("local"),
573
+ rootPath: z10.never().optional(),
574
+ entryPath: z10.never().optional(),
565
575
  url: LoopbackHttpUrlSchema
566
- }).strict(),
576
+ }),
567
577
  z10.object({
568
578
  kind: z10.literal("static"),
579
+ url: z10.never().optional(),
569
580
  rootPath: WebPreviewPathSchema,
570
581
  entryPath: WebPreviewPathSchema
571
- }).strict()
582
+ })
572
583
  ]);
573
584
  var previewStateValues = [
574
585
  "starting",
@@ -594,25 +605,25 @@ var PreviewSummarySchema = z10.discriminatedUnion("state", [
594
605
  PreviewSummaryBaseSchema.extend({
595
606
  state: z10.literal("starting"),
596
607
  ...PreviewSummaryInactiveShape
597
- }).strict(),
608
+ }),
598
609
  PreviewSummaryBaseSchema.extend({
599
610
  state: z10.literal("ready"),
600
611
  publicUrl: PublicPreviewUrlSchema,
601
612
  error: z10.never().optional()
602
- }).strict(),
613
+ }),
603
614
  PreviewSummaryBaseSchema.extend({
604
615
  state: z10.literal("disconnected"),
605
616
  ...PreviewSummaryInactiveShape
606
- }).strict(),
617
+ }),
607
618
  PreviewSummaryBaseSchema.extend({
608
619
  state: z10.literal("failed"),
609
620
  publicUrl: z10.never().optional(),
610
621
  error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH)
611
- }).strict(),
622
+ }),
612
623
  PreviewSummaryBaseSchema.extend({
613
624
  state: z10.literal("stopping"),
614
625
  ...PreviewSummaryInactiveShape
615
- }).strict()
626
+ })
616
627
  ]).superRefine((preview, context) => {
617
628
  if (preview.state !== "ready")
618
629
  return;
@@ -655,7 +666,7 @@ var DevicePreviewToolStatusSchema = z11.union([
655
666
  version: z11.never().optional(),
656
667
  error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
657
668
  suggestions: DevicePreviewToolSuggestionsSchema
658
- }).strict(),
669
+ }),
659
670
  z11.object({
660
671
  supported: z11.literal(true),
661
672
  available: z11.literal(false),
@@ -664,7 +675,7 @@ var DevicePreviewToolStatusSchema = z11.union([
664
675
  version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
665
676
  error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
666
677
  suggestions: DevicePreviewToolSuggestionsSchema
667
- }).strict(),
678
+ }),
668
679
  z11.object({
669
680
  supported: z11.literal(true),
670
681
  available: z11.literal(true),
@@ -673,12 +684,12 @@ var DevicePreviewToolStatusSchema = z11.union([
673
684
  version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
674
685
  error: z11.never().optional(),
675
686
  suggestions: DevicePreviewToolSuggestionsSchema
676
- }).strict()
687
+ })
677
688
  ]);
678
689
  var DevicePreviewCapabilitySchema = z11.object({
679
690
  ios: DevicePreviewToolStatusSchema,
680
691
  android: DevicePreviewToolStatusSchema
681
- }).strict();
692
+ });
682
693
  var DevicePreviewTargetBaseSchema = z11.object({
683
694
  targetId: IdSchema,
684
695
  platform: DevicePreviewPlatformSchema,
@@ -692,11 +703,11 @@ var DevicePreviewTargetSchema = z11.union([
692
703
  DevicePreviewTargetBaseSchema.extend({
693
704
  width: DevicePreviewScreenEdgeSchema,
694
705
  height: DevicePreviewScreenEdgeSchema
695
- }).strict(),
706
+ }),
696
707
  DevicePreviewTargetBaseSchema.extend({
697
708
  width: z11.never().optional(),
698
709
  height: z11.never().optional()
699
- }).strict()
710
+ })
700
711
  ]);
701
712
  var DevicePreviewStateSchema = z11.enum(["ready", "disconnected"]);
702
713
  var DevicePreviewSummaryBaseSchema = z11.object({
@@ -714,11 +725,11 @@ var DevicePreviewSummarySchema = z11.discriminatedUnion("state", [
714
725
  DevicePreviewSummaryBaseSchema.extend({
715
726
  state: z11.literal("ready"),
716
727
  error: z11.never().optional()
717
- }).strict(),
728
+ }),
718
729
  DevicePreviewSummaryBaseSchema.extend({
719
730
  state: z11.literal("disconnected"),
720
731
  error: z11.never().optional()
721
- }).strict()
732
+ })
722
733
  ]);
723
734
  var DevicePreviewJpegStreamProfileSchema = z11.object({
724
735
  format: z11.literal("jpeg"),
@@ -774,17 +785,18 @@ var DevicePreviewStreamRegisterSchema = z11.object({
774
785
  type: z11.literal("device_preview_stream_register"),
775
786
  proxyId: IdSchema,
776
787
  connectionId: IdSchema
777
- }).strict();
788
+ });
778
789
  var DevicePreviewStreamRegisterResponseSchema = z11.discriminatedUnion("success", [
779
790
  z11.object({
780
791
  type: z11.literal("device_preview_stream_register_response"),
781
- success: z11.literal(true)
782
- }).strict(),
792
+ success: z11.literal(true),
793
+ error: z11.never().optional()
794
+ }),
783
795
  z11.object({
784
796
  type: z11.literal("device_preview_stream_register_response"),
785
797
  success: z11.literal(false),
786
798
  error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH)
787
- }).strict()
799
+ })
788
800
  ]);
789
801
  var DevicePreviewStreamFlowBaseSchema = z11.object({
790
802
  type: z11.literal("device_preview_stream_flow"),
@@ -894,6 +906,7 @@ var RELAY_CONTROL_PROTOCOL_VERSION = 1;
894
906
  var ProxyInfoSchema = z13.object({
895
907
  proxyId: IdSchema,
896
908
  name: z13.string().optional(),
909
+ osName: z13.string().min(1).max(64).optional(),
897
910
  version: z13.string().min(1).max(64),
898
911
  online: z13.boolean(),
899
912
  sessions: z13.array(z13.string())
@@ -968,6 +981,10 @@ var RequestErrorShape = {
968
981
  error: z13.string().optional(),
969
982
  errorCode: ControlErrorCodeSchema.optional()
970
983
  };
984
+ var NoRequestErrorShape = {
985
+ error: z13.never().optional(),
986
+ errorCode: z13.never().optional()
987
+ };
971
988
  var RequiredRequestErrorShape = {
972
989
  error: z13.string().min(1),
973
990
  errorCode: ControlErrorCodeSchema
@@ -1006,15 +1023,18 @@ var ProxySelectResponseSchema = z13.discriminatedUnion("success", [
1006
1023
  type: z13.literal("proxy_select_response"),
1007
1024
  ...RequestIdShape,
1008
1025
  success: z13.literal(true),
1026
+ ...NoRequestErrorShape,
1009
1027
  proxyId: IdSchema,
1010
1028
  bindingId: IdSchema
1011
- }).strict(),
1029
+ }),
1012
1030
  z13.object({
1013
1031
  type: z13.literal("proxy_select_response"),
1014
1032
  ...RequestIdShape,
1015
1033
  success: z13.literal(false),
1034
+ proxyId: z13.never().optional(),
1035
+ bindingId: z13.never().optional(),
1016
1036
  ...RequestErrorShape
1017
- }).strict()
1037
+ })
1018
1038
  ]);
1019
1039
  var ClientRegisterResponseSchema = z13.discriminatedUnion("status", [
1020
1040
  z13.object({
@@ -1023,19 +1043,22 @@ var ClientRegisterResponseSchema = z13.discriminatedUnion("status", [
1023
1043
  status: z13.literal("restored"),
1024
1044
  proxyId: IdSchema,
1025
1045
  bindingId: IdSchema
1026
- }).strict(),
1046
+ }),
1027
1047
  z13.object({
1028
1048
  type: z13.literal("client_register_response"),
1029
1049
  protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1030
1050
  status: z13.literal("proxy_offline"),
1031
1051
  proxyId: IdSchema,
1032
1052
  bindingId: IdSchema
1033
- }).strict(),
1053
+ }),
1034
1054
  z13.object({
1035
1055
  type: z13.literal("client_register_response"),
1036
1056
  protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1037
- status: z13.literal("new")
1038
- }).strict()
1057
+ status: z13.literal("new"),
1058
+ // 已知的绑定字段不能作为扩展信息被忽略;new 状态明确表示尚未绑定。
1059
+ proxyId: z13.never().optional(),
1060
+ bindingId: z13.never().optional()
1061
+ })
1039
1062
  ]);
1040
1063
  var PreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1041
1064
  z13.object({
@@ -1044,16 +1067,18 @@ var PreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1044
1067
  scope: PreviewScopeSchema,
1045
1068
  operationId: IdSchema,
1046
1069
  accepted: z13.literal(true),
1070
+ ...NoRequestErrorShape,
1047
1071
  previewId: IdSchema
1048
- }).strict(),
1072
+ }),
1049
1073
  z13.object({
1050
1074
  type: z13.literal("preview_create_response"),
1051
1075
  ...RequiredRequestIdShape,
1052
1076
  scope: PreviewScopeSchema,
1053
1077
  operationId: IdSchema,
1054
1078
  accepted: z13.literal(false),
1079
+ previewId: z13.never().optional(),
1055
1080
  ...RequiredRequestErrorShape
1056
- }).strict()
1081
+ })
1057
1082
  ]);
1058
1083
  var DevicePreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1059
1084
  z13.object({
@@ -1062,16 +1087,18 @@ var DevicePreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1062
1087
  scope: PreviewScopeSchema,
1063
1088
  operationId: IdSchema,
1064
1089
  accepted: z13.literal(true),
1090
+ ...NoRequestErrorShape,
1065
1091
  previewId: IdSchema
1066
- }).strict(),
1092
+ }),
1067
1093
  z13.object({
1068
1094
  type: z13.literal("device_preview_create_response"),
1069
1095
  ...RequiredRequestIdShape,
1070
1096
  scope: PreviewScopeSchema,
1071
1097
  operationId: IdSchema,
1072
1098
  accepted: z13.literal(false),
1099
+ previewId: z13.never().optional(),
1073
1100
  ...RequiredRequestErrorShape
1074
- }).strict()
1101
+ })
1075
1102
  ]);
1076
1103
  var PreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1077
1104
  z13.object({
@@ -1079,15 +1106,17 @@ var PreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1079
1106
  ...RequiredRequestIdShape,
1080
1107
  scope: PreviewScopeSchema,
1081
1108
  success: z13.literal(true),
1109
+ ...NoRequestErrorShape,
1082
1110
  capability: WebPreviewCapabilitySchema
1083
- }).strict(),
1111
+ }),
1084
1112
  z13.object({
1085
1113
  type: z13.literal("preview_capability_response"),
1086
1114
  ...RequiredRequestIdShape,
1087
1115
  scope: PreviewScopeSchema,
1088
1116
  success: z13.literal(false),
1117
+ capability: z13.never().optional(),
1089
1118
  ...RequiredRequestErrorShape
1090
- }).strict()
1119
+ })
1091
1120
  ]);
1092
1121
  var DevicePreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1093
1122
  z13.object({
@@ -1095,15 +1124,17 @@ var DevicePreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1095
1124
  ...RequiredRequestIdShape,
1096
1125
  scope: PreviewScopeSchema,
1097
1126
  success: z13.literal(true),
1127
+ ...NoRequestErrorShape,
1098
1128
  capability: DevicePreviewCapabilitySchema
1099
- }).strict(),
1129
+ }),
1100
1130
  z13.object({
1101
1131
  type: z13.literal("device_preview_capability_response"),
1102
1132
  ...RequiredRequestIdShape,
1103
1133
  scope: PreviewScopeSchema,
1104
1134
  success: z13.literal(false),
1135
+ capability: z13.never().optional(),
1105
1136
  ...RequiredRequestErrorShape
1106
- }).strict()
1137
+ })
1107
1138
  ]);
1108
1139
  var ProxyInfoRequestSchema = z13.object({
1109
1140
  type: z13.literal("proxy_info_request"),
@@ -1114,23 +1145,26 @@ var ProxyInfoResponseSchema = z13.object({
1114
1145
  ...RequestIdShape,
1115
1146
  homePath: z13.string(),
1116
1147
  agentCli: AgentCliStatusSchema
1117
- }).strict();
1148
+ });
1118
1149
  var PreviewStaticInspectResponseSchema = z13.discriminatedUnion("success", [
1119
1150
  z13.object({
1120
1151
  type: z13.literal("preview_static_inspect_response"),
1121
1152
  ...RequiredRequestIdShape,
1122
1153
  scope: PreviewScopeSchema,
1123
1154
  success: z13.literal(true),
1155
+ ...NoRequestErrorShape,
1124
1156
  entryPath: WebPreviewPathSchema.optional(),
1125
1157
  htmlEntries: PreviewHtmlEntriesSchema
1126
- }).strict(),
1158
+ }),
1127
1159
  z13.object({
1128
1160
  type: z13.literal("preview_static_inspect_response"),
1129
1161
  ...RequiredRequestIdShape,
1130
1162
  scope: PreviewScopeSchema,
1131
1163
  success: z13.literal(false),
1164
+ entryPath: z13.never().optional(),
1165
+ htmlEntries: z13.never().optional(),
1132
1166
  ...RequiredRequestErrorShape
1133
- }).strict()
1167
+ })
1134
1168
  ]);
1135
1169
  var PreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1136
1170
  z13.object({
@@ -1139,8 +1173,9 @@ var PreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1139
1173
  scope: PreviewScopeSchema,
1140
1174
  operationId: IdSchema,
1141
1175
  previewId: IdSchema,
1142
- success: z13.literal(true)
1143
- }).strict(),
1176
+ success: z13.literal(true),
1177
+ ...NoRequestErrorShape
1178
+ }),
1144
1179
  z13.object({
1145
1180
  type: z13.literal("preview_rename_response"),
1146
1181
  ...RequiredRequestIdShape,
@@ -1149,7 +1184,7 @@ var PreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1149
1184
  previewId: IdSchema,
1150
1185
  success: z13.literal(false),
1151
1186
  ...RequiredRequestErrorShape
1152
- }).strict()
1187
+ })
1153
1188
  ]);
1154
1189
  var PreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1155
1190
  z13.object({
@@ -1158,8 +1193,9 @@ var PreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1158
1193
  scope: PreviewScopeSchema,
1159
1194
  operationId: IdSchema,
1160
1195
  previewId: IdSchema,
1161
- success: z13.literal(true)
1162
- }).strict(),
1196
+ success: z13.literal(true),
1197
+ ...NoRequestErrorShape
1198
+ }),
1163
1199
  z13.object({
1164
1200
  type: z13.literal("preview_reconnect_response"),
1165
1201
  ...RequiredRequestIdShape,
@@ -1168,7 +1204,7 @@ var PreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1168
1204
  previewId: IdSchema,
1169
1205
  success: z13.literal(false),
1170
1206
  ...RequiredRequestErrorShape
1171
- }).strict()
1207
+ })
1172
1208
  ]);
1173
1209
  var PreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1174
1210
  z13.object({
@@ -1177,8 +1213,9 @@ var PreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1177
1213
  scope: PreviewScopeSchema,
1178
1214
  operationId: IdSchema,
1179
1215
  previewId: IdSchema,
1180
- success: z13.literal(true)
1181
- }).strict(),
1216
+ success: z13.literal(true),
1217
+ ...NoRequestErrorShape
1218
+ }),
1182
1219
  z13.object({
1183
1220
  type: z13.literal("preview_close_response"),
1184
1221
  ...RequiredRequestIdShape,
@@ -1187,7 +1224,7 @@ var PreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1187
1224
  previewId: IdSchema,
1188
1225
  success: z13.literal(false),
1189
1226
  ...RequiredRequestErrorShape
1190
- }).strict()
1227
+ })
1191
1228
  ]);
1192
1229
  var DevicePreviewTargetsResponseSchema = z13.discriminatedUnion("success", [
1193
1230
  z13.object({
@@ -1195,15 +1232,17 @@ var DevicePreviewTargetsResponseSchema = z13.discriminatedUnion("success", [
1195
1232
  ...RequiredRequestIdShape,
1196
1233
  scope: PreviewScopeSchema,
1197
1234
  success: z13.literal(true),
1235
+ ...NoRequestErrorShape,
1198
1236
  targets: z13.array(DevicePreviewTargetSchema).max(1024)
1199
- }).strict(),
1237
+ }),
1200
1238
  z13.object({
1201
1239
  type: z13.literal("device_preview_targets_response"),
1202
1240
  ...RequiredRequestIdShape,
1203
1241
  scope: PreviewScopeSchema,
1204
1242
  success: z13.literal(false),
1243
+ targets: z13.never().optional(),
1205
1244
  ...RequiredRequestErrorShape
1206
- }).strict()
1245
+ })
1207
1246
  ]);
1208
1247
  var DevicePreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1209
1248
  z13.object({
@@ -1212,8 +1251,9 @@ var DevicePreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1212
1251
  scope: PreviewScopeSchema,
1213
1252
  operationId: IdSchema,
1214
1253
  previewId: IdSchema,
1215
- success: z13.literal(true)
1216
- }).strict(),
1254
+ success: z13.literal(true),
1255
+ ...NoRequestErrorShape
1256
+ }),
1217
1257
  z13.object({
1218
1258
  type: z13.literal("device_preview_rename_response"),
1219
1259
  ...RequiredRequestIdShape,
@@ -1222,7 +1262,7 @@ var DevicePreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1222
1262
  previewId: IdSchema,
1223
1263
  success: z13.literal(false),
1224
1264
  ...RequiredRequestErrorShape
1225
- }).strict()
1265
+ })
1226
1266
  ]);
1227
1267
  var DevicePreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1228
1268
  z13.object({
@@ -1231,8 +1271,9 @@ var DevicePreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1231
1271
  scope: PreviewScopeSchema,
1232
1272
  operationId: IdSchema,
1233
1273
  previewId: IdSchema,
1234
- success: z13.literal(true)
1235
- }).strict(),
1274
+ success: z13.literal(true),
1275
+ ...NoRequestErrorShape
1276
+ }),
1236
1277
  z13.object({
1237
1278
  type: z13.literal("device_preview_reconnect_response"),
1238
1279
  ...RequiredRequestIdShape,
@@ -1241,7 +1282,7 @@ var DevicePreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1241
1282
  previewId: IdSchema,
1242
1283
  success: z13.literal(false),
1243
1284
  ...RequiredRequestErrorShape
1244
- }).strict()
1285
+ })
1245
1286
  ]);
1246
1287
  var DevicePreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1247
1288
  z13.object({
@@ -1250,8 +1291,9 @@ var DevicePreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1250
1291
  scope: PreviewScopeSchema,
1251
1292
  operationId: IdSchema,
1252
1293
  previewId: IdSchema,
1253
- success: z13.literal(true)
1254
- }).strict(),
1294
+ success: z13.literal(true),
1295
+ ...NoRequestErrorShape
1296
+ }),
1255
1297
  z13.object({
1256
1298
  type: z13.literal("device_preview_close_response"),
1257
1299
  ...RequiredRequestIdShape,
@@ -1260,7 +1302,7 @@ var DevicePreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1260
1302
  previewId: IdSchema,
1261
1303
  success: z13.literal(false),
1262
1304
  ...RequiredRequestErrorShape
1263
- }).strict()
1305
+ })
1264
1306
  ]);
1265
1307
  var DevicePreviewStreamUrlResponseSchema = z13.discriminatedUnion("success", [
1266
1308
  z13.object({
@@ -1269,19 +1311,24 @@ var DevicePreviewStreamUrlResponseSchema = z13.discriminatedUnion("success", [
1269
1311
  scope: PreviewScopeSchema,
1270
1312
  previewId: IdSchema,
1271
1313
  success: z13.literal(true),
1314
+ ...NoRequestErrorShape,
1272
1315
  url: z13.string().min(1).max(4096),
1273
1316
  leaseId: IdSchema,
1274
1317
  expiresAt: z13.number().int().nonnegative(),
1275
1318
  controlMode: z13.enum(["controller", "view_only"])
1276
- }).strict(),
1319
+ }),
1277
1320
  z13.object({
1278
1321
  type: z13.literal("device_preview_stream_url_response"),
1279
1322
  ...RequiredRequestIdShape,
1280
1323
  scope: PreviewScopeSchema,
1281
1324
  previewId: IdSchema,
1282
1325
  success: z13.literal(false),
1326
+ url: z13.never().optional(),
1327
+ leaseId: z13.never().optional(),
1328
+ expiresAt: z13.never().optional(),
1329
+ controlMode: z13.never().optional(),
1283
1330
  ...RequiredRequestErrorShape
1284
- }).strict()
1331
+ })
1285
1332
  ]);
1286
1333
  var DevicePreviewStreamStartResponseBaseShape = {
1287
1334
  type: z13.literal("device_preview_stream_start_response"),
@@ -1292,10 +1339,11 @@ var DevicePreviewStreamStartResponseBaseShape = {
1292
1339
  var DevicePreviewStreamStartSuccessSchema = z13.object({
1293
1340
  ...DevicePreviewStreamStartResponseBaseShape,
1294
1341
  success: z13.literal(true),
1342
+ ...NoRequestErrorShape,
1295
1343
  format: DevicePreviewStreamFormatSchema,
1296
1344
  width: z13.number().int().positive().max(16384).optional(),
1297
1345
  height: z13.number().int().positive().max(16384).optional()
1298
- }).strict().superRefine((response, context) => {
1346
+ }).superRefine((response, context) => {
1299
1347
  if (response.width === void 0 === (response.height === void 0))
1300
1348
  return;
1301
1349
  context.addIssue({
@@ -1309,8 +1357,11 @@ var DevicePreviewStreamStartResponseSchema = z13.discriminatedUnion("success", [
1309
1357
  z13.object({
1310
1358
  ...DevicePreviewStreamStartResponseBaseShape,
1311
1359
  success: z13.literal(false),
1360
+ format: z13.never().optional(),
1361
+ width: z13.never().optional(),
1362
+ height: z13.never().optional(),
1312
1363
  ...RequiredRequestErrorShape
1313
- }).strict()
1364
+ })
1314
1365
  ]);
1315
1366
  var DevicePreviewStreamCompleteSchema = z13.object({
1316
1367
  type: z13.literal("device_preview_stream_complete"),
@@ -1319,7 +1370,7 @@ var DevicePreviewStreamCompleteSchema = z13.object({
1319
1370
  previewId: IdSchema,
1320
1371
  success: z13.literal(false),
1321
1372
  error: z13.string().min(1)
1322
- }).strict();
1373
+ });
1323
1374
  var DevicePreviewStreamStartBaseShape = {
1324
1375
  type: z13.literal("device_preview_stream_start"),
1325
1376
  streamId: IdSchema,
@@ -1342,8 +1393,9 @@ var DevicePreviewInputAckSchema = z13.discriminatedUnion("success", [
1342
1393
  scope: PreviewScopeSchema,
1343
1394
  leaseId: IdSchema,
1344
1395
  inputSeq: z13.number().int().min(0).max(4294967295),
1345
- success: z13.literal(true)
1346
- }).strict(),
1396
+ success: z13.literal(true),
1397
+ ...NoRequestErrorShape
1398
+ }),
1347
1399
  z13.object({
1348
1400
  type: z13.literal("device_preview_input_ack"),
1349
1401
  scope: PreviewScopeSchema,
@@ -1351,7 +1403,7 @@ var DevicePreviewInputAckSchema = z13.discriminatedUnion("success", [
1351
1403
  inputSeq: z13.number().int().min(0).max(4294967295),
1352
1404
  success: z13.literal(false),
1353
1405
  ...RequiredRequestErrorShape
1354
- }).strict()
1406
+ })
1355
1407
  ]);
1356
1408
  var DevicePreviewControlClaimResponseSchema = z13.discriminatedUnion("success", [
1357
1409
  z13.object({
@@ -1360,16 +1412,18 @@ var DevicePreviewControlClaimResponseSchema = z13.discriminatedUnion("success",
1360
1412
  scope: PreviewScopeSchema,
1361
1413
  leaseId: IdSchema,
1362
1414
  success: z13.literal(true),
1415
+ ...NoRequestErrorShape,
1363
1416
  controlMode: z13.literal("controller")
1364
- }).strict(),
1417
+ }),
1365
1418
  z13.object({
1366
1419
  type: z13.literal("device_preview_control_claim_response"),
1367
1420
  ...RequiredRequestIdShape,
1368
1421
  scope: PreviewScopeSchema,
1369
1422
  leaseId: IdSchema,
1370
1423
  success: z13.literal(false),
1424
+ controlMode: z13.never().optional(),
1371
1425
  ...RequiredRequestErrorShape
1372
- }).strict()
1426
+ })
1373
1427
  ]);
1374
1428
  var SessionPermissionModeSchema = z13.enum([
1375
1429
  "default",
@@ -1417,6 +1471,8 @@ var SessionCreateSchema = z13.discriminatedUnion("mode", [
1417
1471
  z13.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
1418
1472
  ]);
1419
1473
  var SessionCreateSuccessBaseShape = {
1474
+ ...NoRequestErrorShape,
1475
+ activeWriterPid: z13.never().optional(),
1420
1476
  type: z13.literal("session_create_response"),
1421
1477
  ...RequiredRequestIdShape,
1422
1478
  success: z13.literal(true),
@@ -1431,8 +1487,9 @@ var SessionCreateSuccessResponseSchema = z13.discriminatedUnion("mode", [
1431
1487
  ...SessionCreateSuccessBaseShape,
1432
1488
  kind: z13.literal("agent"),
1433
1489
  mode: z13.literal("json"),
1490
+ ptyOwner: z13.never().optional(),
1434
1491
  provider: z13.enum(providerValues)
1435
- }).strict(),
1492
+ }),
1436
1493
  z13.discriminatedUnion("kind", [
1437
1494
  z13.object({
1438
1495
  ...SessionCreateSuccessBaseShape,
@@ -1440,14 +1497,14 @@ var SessionCreateSuccessResponseSchema = z13.discriminatedUnion("mode", [
1440
1497
  mode: z13.literal("pty"),
1441
1498
  provider: z13.enum(providerValues),
1442
1499
  ptyOwner: z13.enum(ptyOwnerValues)
1443
- }).strict(),
1500
+ }),
1444
1501
  z13.object({
1445
1502
  ...SessionCreateSuccessBaseShape,
1446
1503
  kind: z13.literal("terminal"),
1447
1504
  mode: z13.literal("pty"),
1448
1505
  provider: z13.literal("claude"),
1449
1506
  ptyOwner: z13.literal("proxy-hosted")
1450
- }).strict()
1507
+ })
1451
1508
  ])
1452
1509
  ]);
1453
1510
  var SessionCreateResponseSchema = z13.discriminatedUnion("success", [
@@ -1456,18 +1513,28 @@ var SessionCreateResponseSchema = z13.discriminatedUnion("success", [
1456
1513
  type: z13.literal("session_create_response"),
1457
1514
  ...RequiredRequestIdShape,
1458
1515
  success: z13.literal(false),
1516
+ sessionId: z13.never().optional(),
1517
+ cwd: z13.never().optional(),
1518
+ lastActive: z13.never().optional(),
1519
+ name: z13.never().optional(),
1520
+ nameLocked: z13.never().optional(),
1521
+ kind: z13.never().optional(),
1522
+ mode: z13.never().optional(),
1523
+ provider: z13.never().optional(),
1524
+ ptyOwner: z13.never().optional(),
1459
1525
  ...RequiredRequestErrorShape,
1460
1526
  activeWriterPid: z13.number().int().positive().optional()
1461
- }).strict()
1527
+ })
1462
1528
  ]);
1463
1529
  var relayControlDefinitions = [
1464
- strictControl("proxy_register", {
1530
+ control("proxy_register", {
1465
1531
  protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1466
1532
  proxyId: IdSchema,
1467
1533
  name: z13.string().optional(),
1534
+ osName: z13.string().min(1).max(64).optional(),
1468
1535
  proxyVersion: z13.string().min(1).max(64)
1469
1536
  }),
1470
- strictControl("proxy_register_response", {
1537
+ control("proxy_register_response", {
1471
1538
  protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1472
1539
  status: z13.enum(["new", "reconnected"]),
1473
1540
  relayVersion: z13.string().min(1).max(64),
@@ -1693,7 +1760,7 @@ var relayControlDefinitions = [
1693
1760
  }, "client_to_proxy"),
1694
1761
  controlSchema("preview_create_response", PreviewCreateResponseSchema, "proxy_to_client"),
1695
1762
  strictControl("preview_list_request", { ...RequiredRequestIdShape, scope: PreviewScopeSchema }, "client_to_proxy"),
1696
- strictControl("preview_list_response", {
1763
+ control("preview_list_response", {
1697
1764
  ...RequiredRequestIdShape,
1698
1765
  scope: PreviewScopeSchema,
1699
1766
  epoch: IdSchema,
@@ -1722,23 +1789,23 @@ var relayControlDefinitions = [
1722
1789
  previewId: IdSchema
1723
1790
  }, "client_to_proxy"),
1724
1791
  controlSchema("preview_close_response", PreviewCloseResponseSchema, "proxy_to_client"),
1725
- strictControl("preview_state_event", {
1792
+ control("preview_state_event", {
1726
1793
  epoch: IdSchema,
1727
1794
  revision: z13.number().int().nonnegative(),
1728
1795
  preview: PreviewSummarySchema
1729
1796
  }),
1730
- strictControl("preview_removed_event", {
1797
+ control("preview_removed_event", {
1731
1798
  epoch: IdSchema,
1732
1799
  revision: z13.number().int().nonnegative(),
1733
1800
  previewId: IdSchema
1734
1801
  }),
1735
- strictControl("preview_state_push", {
1802
+ control("preview_state_push", {
1736
1803
  scope: PreviewScopeSchema,
1737
1804
  epoch: IdSchema,
1738
1805
  revision: z13.number().int().nonnegative(),
1739
1806
  preview: PreviewSummarySchema
1740
1807
  }, "proxy_to_client"),
1741
- strictControl("preview_removed_push", {
1808
+ control("preview_removed_push", {
1742
1809
  scope: PreviewScopeSchema,
1743
1810
  epoch: IdSchema,
1744
1811
  revision: z13.number().int().nonnegative(),
@@ -1768,7 +1835,7 @@ var relayControlDefinitions = [
1768
1835
  }, "client_to_proxy"),
1769
1836
  controlSchema("device_preview_create_response", DevicePreviewCreateResponseSchema, "proxy_to_client"),
1770
1837
  strictControl("device_preview_list_request", { ...RequiredRequestIdShape, scope: PreviewScopeSchema }, "client_to_proxy"),
1771
- strictControl("device_preview_list_response", {
1838
+ control("device_preview_list_response", {
1772
1839
  ...RequiredRequestIdShape,
1773
1840
  scope: PreviewScopeSchema,
1774
1841
  epoch: IdSchema,
@@ -1797,23 +1864,23 @@ var relayControlDefinitions = [
1797
1864
  previewId: IdSchema
1798
1865
  }, "client_to_proxy"),
1799
1866
  controlSchema("device_preview_close_response", DevicePreviewCloseResponseSchema, "proxy_to_client"),
1800
- strictControl("device_preview_state_event", {
1867
+ control("device_preview_state_event", {
1801
1868
  epoch: IdSchema,
1802
1869
  revision: z13.number().int().nonnegative(),
1803
1870
  preview: DevicePreviewSummarySchema
1804
1871
  }),
1805
- strictControl("device_preview_removed_event", {
1872
+ control("device_preview_removed_event", {
1806
1873
  epoch: IdSchema,
1807
1874
  revision: z13.number().int().nonnegative(),
1808
1875
  previewId: IdSchema
1809
1876
  }),
1810
- strictControl("device_preview_state_push", {
1877
+ control("device_preview_state_push", {
1811
1878
  scope: PreviewScopeSchema,
1812
1879
  epoch: IdSchema,
1813
1880
  revision: z13.number().int().nonnegative(),
1814
1881
  preview: DevicePreviewSummarySchema
1815
1882
  }, "proxy_to_client"),
1816
- strictControl("device_preview_removed_push", {
1883
+ control("device_preview_removed_push", {
1817
1884
  scope: PreviewScopeSchema,
1818
1885
  epoch: IdSchema,
1819
1886
  revision: z13.number().int().nonnegative(),
@@ -1852,13 +1919,13 @@ var relayControlDefinitions = [
1852
1919
  leaseId: IdSchema
1853
1920
  }),
1854
1921
  controlSchema("device_preview_control_claim_response", DevicePreviewControlClaimResponseSchema),
1855
- strictControl("device_preview_control_revoked_push", {
1922
+ control("device_preview_control_revoked_push", {
1856
1923
  scope: PreviewScopeSchema,
1857
1924
  leaseId: IdSchema,
1858
1925
  reason: z13.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
1859
1926
  }),
1860
1927
  // 客户端注册协议
1861
- strictControl("client_register", {
1928
+ control("client_register", {
1862
1929
  protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1863
1930
  clientId: IdSchema,
1864
1931
  userAgent: z13.string().optional(),
@@ -2398,7 +2465,7 @@ var RelayRegistry = class {
2398
2465
  proxyStates = /* @__PURE__ */ new Map();
2399
2466
  clientBindings = /* @__PURE__ */ new Map();
2400
2467
  connectedClients = /* @__PURE__ */ new Map();
2401
- registerProxy(proxyId, ws, version, name) {
2468
+ registerProxy(proxyId, ws, version, name, osName) {
2402
2469
  const existing = this.proxyStates.get(proxyId);
2403
2470
  if (existing) {
2404
2471
  if (existing.ws && existing.ws.readyState === WebSocket.OPEN) {
@@ -2408,6 +2475,7 @@ var RelayRegistry = class {
2408
2475
  existing.connectionState = "online";
2409
2476
  existing.disconnectedAt = null;
2410
2477
  if (name !== void 0) existing.name = name;
2478
+ existing.osName = osName;
2411
2479
  existing.version = version;
2412
2480
  return "reconnected";
2413
2481
  }
@@ -2417,6 +2485,7 @@ var RelayRegistry = class {
2417
2485
  sessions: /* @__PURE__ */ new Set(),
2418
2486
  disconnectedAt: null,
2419
2487
  name,
2488
+ osName,
2420
2489
  version
2421
2490
  });
2422
2491
  return "new";
@@ -2500,6 +2569,7 @@ var RelayRegistry = class {
2500
2569
  return Array.from(this.proxyStates.entries()).map(([proxyId, state]) => ({
2501
2570
  proxyId,
2502
2571
  ...state.name !== void 0 ? { name: state.name } : {},
2572
+ ...state.osName !== void 0 ? { osName: state.osName } : {},
2503
2573
  version: state.version,
2504
2574
  online: state.connectionState === "online"
2505
2575
  }));
@@ -2872,7 +2942,7 @@ function routeProxyMessage(raw, proxyId, registry, logger, chaos) {
2872
2942
  return;
2873
2943
  }
2874
2944
  const { message } = result;
2875
- if ("sessionId" in message) {
2945
+ if (typeof message.sessionId === "string") {
2876
2946
  registry.addSessionToProxy(proxyId, message.sessionId);
2877
2947
  }
2878
2948
  const clients = registry.getClientsForProxy(proxyId);
@@ -3185,6 +3255,14 @@ var WebPreviewRouteRegistry = class extends PreviewRouteRegistry {
3185
3255
  }
3186
3256
  };
3187
3257
 
3258
+ // src/forwarded-control.ts
3259
+ function rewriteForwardedControl(validatedRaw, relayFields) {
3260
+ const message = JSON.parse(validatedRaw);
3261
+ delete message.requestId;
3262
+ delete message.scope;
3263
+ return JSON.stringify({ ...message, ...relayFields });
3264
+ }
3265
+
3188
3266
  // src/proxy-upgrade-bootstrap.ts
3189
3267
  import { z as z14 } from "zod";
3190
3268
  var UPGRADE_BOOTSTRAP_SOURCE_VERSION = "0.8.1";
@@ -3256,19 +3334,19 @@ function isPreviewEventMessage(message) {
3256
3334
  function isPreviewPushType(type) {
3257
3335
  return PREVIEW_PUSH_TYPES.has(type);
3258
3336
  }
3259
- function previewPushFromEvent(event, scope) {
3337
+ function previewPushType(event) {
3260
3338
  switch (event.type) {
3261
3339
  case "preview_state_event":
3262
- return { ...event, type: "preview_state_push", scope };
3340
+ return "preview_state_push";
3263
3341
  case "preview_removed_event":
3264
- return { ...event, type: "preview_removed_push", scope };
3342
+ return "preview_removed_push";
3265
3343
  case "device_preview_state_event":
3266
- return { ...event, type: "device_preview_state_push", scope };
3344
+ return "device_preview_state_push";
3267
3345
  case "device_preview_removed_event":
3268
- return { ...event, type: "device_preview_removed_push", scope };
3346
+ return "device_preview_removed_push";
3269
3347
  }
3270
3348
  }
3271
- function broadcastPreviewEvent(proxyId, sourceProxyWs, event, registry, chaos) {
3349
+ function broadcastPreviewEvent(proxyId, sourceProxyWs, event, raw, registry, chaos) {
3272
3350
  let delivered = 0;
3273
3351
  for (const rawClientWs of registry.getClientsForProxy(proxyId)) {
3274
3352
  const clientWs = rawClientWs;
@@ -3276,12 +3354,12 @@ function broadcastPreviewEvent(proxyId, sourceProxyWs, event, registry, chaos) {
3276
3354
  const scope = { proxyId, bindingId: clientWs.bindingId };
3277
3355
  const isCurrentRoute = () => registry.getProxy(proxyId) === sourceProxyWs && registry.isCurrentClientBinding(clientWs.clientId, clientWs, scope);
3278
3356
  if (!isCurrentRoute()) continue;
3279
- const pushMessage = previewPushFromEvent(event, scope);
3280
- const push = serializeControl(pushMessage);
3357
+ const type = previewPushType(event);
3358
+ const push = rewriteForwardedControl(raw, { type, scope });
3281
3359
  if (chaos) {
3282
3360
  chaos.send(clientWs, push, {
3283
3361
  direction: "proxy_to_client",
3284
- type: pushMessage.type,
3362
+ type,
3285
3363
  guard: isCurrentRoute
3286
3364
  });
3287
3365
  } else if (isCurrentRoute() && clientWs.readyState === WebSocket4.OPEN) {
@@ -3464,10 +3542,10 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3464
3542
  closeRejectedProxyProtocol(proxyWs, ProxyProtocolAdmissionDirection.PROTOCOL_MISMATCH);
3465
3543
  return;
3466
3544
  }
3467
- const { proxyId, name, proxyVersion } = result.message;
3545
+ const { proxyId, name, osName, proxyVersion } = result.message;
3468
3546
  proxyWs.admissionPhase = "ready";
3469
3547
  clearAdmissionTimeout();
3470
- const status = registry.registerProxy(proxyId, proxyWs, proxyVersion, name);
3548
+ const status = registry.registerProxy(proxyId, proxyWs, proxyVersion, name, osName);
3471
3549
  proxyWs.proxyId = proxyId;
3472
3550
  registrationCompleted = true;
3473
3551
  const connectionId = devicePreviewBridge.registerProxyConnection(proxyId, proxyWs);
@@ -3580,6 +3658,7 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3580
3658
  proxyWs.proxyId,
3581
3659
  proxyWs,
3582
3660
  result.message,
3661
+ raw,
3583
3662
  registry,
3584
3663
  chaos
3585
3664
  );
@@ -3594,7 +3673,7 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3594
3673
  rejectNotRegistered(proxyWs);
3595
3674
  return;
3596
3675
  }
3597
- devicePreviewBridge.handleProxyControl(proxyWs.proxyId, proxyWs, result.message);
3676
+ devicePreviewBridge.handleProxyControl(proxyWs.proxyId, proxyWs, result.message, raw);
3598
3677
  return;
3599
3678
  }
3600
3679
  if (proxyWs.proxyId && result.message.type === "remote_file_stream_response") {
@@ -3656,8 +3735,8 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3656
3735
  let delivered = 0;
3657
3736
  for (const target of route.targets) {
3658
3737
  if (target.clientWs.readyState !== WebSocket4.OPEN) continue;
3659
- const response = serializeControl({
3660
- ...result.message,
3738
+ const response = rewriteForwardedControl(raw, {
3739
+ type: result.message.type,
3661
3740
  requestId: target.requestId
3662
3741
  });
3663
3742
  if (chaos) {
@@ -3716,12 +3795,11 @@ function handleProxyConnection(ws, registry, logger, ptySnapshotRoutes, sessionH
3716
3795
  );
3717
3796
  return;
3718
3797
  }
3719
- const response = {
3720
- ...result.message,
3798
+ const responseRaw = rewriteForwardedControl(raw, {
3799
+ type: result.message.type,
3721
3800
  requestId: route.clientRequestId,
3722
3801
  scope: route.scope
3723
- };
3724
- const responseRaw = serializeControl(response);
3802
+ });
3725
3803
  if (chaos) {
3726
3804
  chaos.send(route.clientWs, responseRaw, {
3727
3805
  direction: "proxy_to_client",
@@ -7491,10 +7569,10 @@ var DevicePreviewBridge = class {
7491
7569
  return false;
7492
7570
  }
7493
7571
  }
7494
- handleProxyControl(proxyId, proxyWs, message) {
7572
+ handleProxyControl(proxyId, proxyWs, message, raw) {
7495
7573
  if (!this.isCurrentProxyConnection(proxyId, proxyWs)) return this.isDeviceMessage(message);
7496
7574
  if (isDevicePreviewResponseMessage(message)) {
7497
- this.resolveManagementResponse(proxyId, proxyWs, message);
7575
+ this.resolveManagementResponse(proxyId, proxyWs, message, raw);
7498
7576
  return true;
7499
7577
  }
7500
7578
  switch (message.type) {
@@ -7505,7 +7583,7 @@ var DevicePreviewBridge = class {
7505
7583
  this.handleStreamComplete(proxyId, message);
7506
7584
  return true;
7507
7585
  case "device_preview_input_ack":
7508
- this.handleInputAck(proxyId, message);
7586
+ this.handleInputAck(proxyId, message, raw);
7509
7587
  return true;
7510
7588
  default:
7511
7589
  return this.isDeviceMessage(message);
@@ -7809,7 +7887,7 @@ var DevicePreviewBridge = class {
7809
7887
  return false;
7810
7888
  }
7811
7889
  }
7812
- resolveManagementResponse(proxyId, proxyWs, message) {
7890
+ resolveManagementResponse(proxyId, proxyWs, message, raw) {
7813
7891
  if (message.type === "device_preview_close_response" && message.success) {
7814
7892
  this.stopPreviewStreams(proxyId, message.previewId, "preview_closed");
7815
7893
  }
@@ -7823,12 +7901,12 @@ var DevicePreviewBridge = class {
7823
7901
  }
7824
7902
  const isCurrentRoute = () => this.isCurrentProxyConnection(proxyId, proxyWs) && this.options.registry.isCurrentClientBinding(route.clientId, route.clientWs, route.scope);
7825
7903
  if (route.clientWs.readyState !== WebSocket12.OPEN || !isCurrentRoute()) return;
7826
- const response = {
7827
- ...message,
7904
+ const response = rewriteForwardedControl(raw, {
7905
+ type: message.type,
7828
7906
  requestId: route.clientRequestId,
7829
7907
  scope: route.scope
7830
- };
7831
- this.sendClient(route.clientWs, serializeControl(response), message.type, isCurrentRoute);
7908
+ });
7909
+ this.sendClient(route.clientWs, response, message.type, isCurrentRoute);
7832
7910
  }
7833
7911
  issueStreamUrl(clientWs, message) {
7834
7912
  const requestBindingStillCurrent = () => this.options.registry.isCurrentClientBinding(clientWs.clientId, clientWs, message.scope);
@@ -8136,16 +8214,16 @@ var DevicePreviewBridge = class {
8136
8214
  );
8137
8215
  this.failStream(stream.streamId, 502, message.error);
8138
8216
  }
8139
- handleInputAck(proxyId, message) {
8217
+ handleInputAck(proxyId, message, raw) {
8140
8218
  const lease = this.leases.get(message.leaseId);
8141
8219
  if (!lease || lease.proxyId !== proxyId || !lease.outstandingInputSeqs.delete(message.inputSeq) || lease.clientWs.readyState !== WebSocket12.OPEN) {
8142
8220
  return;
8143
8221
  }
8144
- const response = {
8145
- ...message,
8222
+ const response = rewriteForwardedControl(raw, {
8223
+ type: message.type,
8146
8224
  scope: { proxyId: lease.proxyId, bindingId: lease.bindingId }
8147
- };
8148
- this.sendClient(lease.clientWs, serializeControl(response), message.type, () => {
8225
+ });
8226
+ this.sendClient(lease.clientWs, response, message.type, () => {
8149
8227
  return this.leases.get(lease.leaseId) === lease && lease.controller && this.clientLeaseStillValid(lease);
8150
8228
  });
8151
8229
  }
@@ -8884,4 +8962,4 @@ export {
8884
8962
  parseRelayChaosFromEnv,
8885
8963
  createRelayServer
8886
8964
  };
8887
- //# sourceMappingURL=chunk-PMXR723R.js.map
8965
+ //# sourceMappingURL=chunk-F4RB66MR.js.map