@dev-anywhere/proxy 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/{autostart-G2MSOPL7.js → autostart-TMACAYHZ.js} +104 -26
  2. package/dist/autostart-TMACAYHZ.js.map +1 -0
  3. package/dist/{chunk-HYDXGNKA.js → chunk-5COVSNQZ.js} +2 -2
  4. package/dist/chunk-5OARBB2B.js +36 -0
  5. package/dist/chunk-5OARBB2B.js.map +1 -0
  6. package/dist/chunk-724Y2CKO.js +94 -0
  7. package/dist/chunk-724Y2CKO.js.map +1 -0
  8. package/dist/{chunk-GIFG7KAJ.js → chunk-7FPUPHTZ.js} +817 -1177
  9. package/dist/chunk-7FPUPHTZ.js.map +1 -0
  10. package/dist/{chunk-DAFUSBKJ.js → chunk-AZ5MTPUR.js} +2 -91
  11. package/dist/chunk-AZ5MTPUR.js.map +1 -0
  12. package/dist/chunk-BUUAXCBP.js +93 -0
  13. package/dist/chunk-BUUAXCBP.js.map +1 -0
  14. package/dist/{chunk-XADKKDUV.js → chunk-BZWRTKXC.js} +2 -33
  15. package/dist/chunk-BZWRTKXC.js.map +1 -0
  16. package/dist/chunk-C2VZS676.js +377 -0
  17. package/dist/chunk-C2VZS676.js.map +1 -0
  18. package/dist/{chunk-GYL5JKWQ.js → chunk-DEMLXEB5.js} +3 -3
  19. package/dist/{chunk-KWODOJBK.js → chunk-EEXWF5SA.js} +6 -5
  20. package/dist/chunk-EEXWF5SA.js.map +1 -0
  21. package/dist/{chunk-EIXVJR3C.js → chunk-IEBAPWH3.js} +6 -44
  22. package/dist/chunk-IEBAPWH3.js.map +1 -0
  23. package/dist/chunk-LAFXAGDU.js +29 -0
  24. package/dist/chunk-LAFXAGDU.js.map +1 -0
  25. package/dist/{chunk-2YUDGRJ6.js → chunk-LIGQMX7K.js} +9 -7
  26. package/dist/{chunk-2YUDGRJ6.js.map → chunk-LIGQMX7K.js.map} +1 -1
  27. package/dist/chunk-SSTYQQSR.js +86 -0
  28. package/dist/chunk-SSTYQQSR.js.map +1 -0
  29. package/dist/{chunk-QZ3OZJBG.js → chunk-TIXHLU3Q.js} +6 -22
  30. package/dist/chunk-TIXHLU3Q.js.map +1 -0
  31. package/dist/{chunk-WLXTXXNY.js → chunk-TLY6IMDY.js} +39 -1
  32. package/dist/chunk-TLY6IMDY.js.map +1 -0
  33. package/dist/chunk-TQP3COOV.js +69 -0
  34. package/dist/chunk-TQP3COOV.js.map +1 -0
  35. package/dist/{chunk-M34C6LTF.js → chunk-UBWS5JVM.js} +19 -9
  36. package/dist/chunk-UBWS5JVM.js.map +1 -0
  37. package/dist/{chunk-YK2XKOP4.js → chunk-WEATMI5J.js} +8 -1
  38. package/dist/chunk-WEATMI5J.js.map +1 -0
  39. package/dist/chunk-WG3KLJFJ.js +64 -0
  40. package/dist/chunk-WG3KLJFJ.js.map +1 -0
  41. package/dist/{chunk-YYNHKGCH.js → chunk-ZRABX7EM.js} +2 -2
  42. package/dist/index.js +19 -15
  43. package/dist/index.js.map +1 -1
  44. package/dist/{logger-B7B64O4P.js → logger-XEIQC6K6.js} +3 -3
  45. package/dist/preview-worker.js +7871 -0
  46. package/dist/preview-worker.js.map +1 -0
  47. package/dist/{relay-token-N3BSBURG.js → relay-token-Y3IFNUMX.js} +4 -4
  48. package/dist/serve.js +2725 -10113
  49. package/dist/serve.js.map +1 -1
  50. package/dist/session-worker.js +35 -69
  51. package/dist/session-worker.js.map +1 -1
  52. package/dist/{terminal-UTFRKKZ4.js → terminal-FNVKGTTL.js} +17 -12
  53. package/dist/terminal-FNVKGTTL.js.map +1 -0
  54. package/dist/terminal-worker.js +29 -22
  55. package/dist/terminal-worker.js.map +1 -1
  56. package/dist/update-runner.js +4 -3
  57. package/dist/update-runner.js.map +1 -1
  58. package/package.json +3 -3
  59. package/dist/autostart-G2MSOPL7.js.map +0 -1
  60. package/dist/chunk-CMADETTC.js +0 -147
  61. package/dist/chunk-CMADETTC.js.map +0 -1
  62. package/dist/chunk-DAFUSBKJ.js.map +0 -1
  63. package/dist/chunk-EIXVJR3C.js.map +0 -1
  64. package/dist/chunk-GIFG7KAJ.js.map +0 -1
  65. package/dist/chunk-KWODOJBK.js.map +0 -1
  66. package/dist/chunk-M34C6LTF.js.map +0 -1
  67. package/dist/chunk-QZ3OZJBG.js.map +0 -1
  68. package/dist/chunk-WLXTXXNY.js.map +0 -1
  69. package/dist/chunk-XADKKDUV.js.map +0 -1
  70. package/dist/chunk-YK2XKOP4.js.map +0 -1
  71. package/dist/terminal-UTFRKKZ4.js.map +0 -1
  72. /package/dist/{chunk-HYDXGNKA.js.map → chunk-5COVSNQZ.js.map} +0 -0
  73. /package/dist/{chunk-GYL5JKWQ.js.map → chunk-DEMLXEB5.js.map} +0 -0
  74. /package/dist/{chunk-YYNHKGCH.js.map → chunk-ZRABX7EM.js.map} +0 -0
  75. /package/dist/{logger-B7B64O4P.js.map → logger-XEIQC6K6.js.map} +0 -0
  76. /package/dist/{relay-token-N3BSBURG.js.map → relay-token-Y3IFNUMX.js.map} +0 -0
@@ -311,63 +311,8 @@ var ControlErrorCode = {
311
311
  UNKNOWN: "UNKNOWN"
312
312
  };
313
313
 
314
- // ../../packages/shared/dist/state-machine.js
315
- function computeAbsorbingSet(transitions) {
316
- const absorbing = /* @__PURE__ */ new Set();
317
- const entries = Object.entries(transitions);
318
- for (const [s, outs] of entries) {
319
- if (outs.length === 0)
320
- absorbing.add(s);
321
- }
322
- let changed = true;
323
- while (changed) {
324
- changed = false;
325
- for (const [s, outs] of entries) {
326
- if (absorbing.has(s))
327
- continue;
328
- if (outs.length > 0 && outs.every((t) => absorbing.has(t))) {
329
- absorbing.add(s);
330
- changed = true;
331
- }
332
- }
333
- }
334
- return absorbing;
335
- }
336
- function createFSM(def) {
337
- let state = def.initial;
338
- const absorbing = computeAbsorbingSet(def.transitions);
339
- const tryTransitionTo = (to) => {
340
- const allowed = def.transitions[state];
341
- if (!allowed?.includes(to)) {
342
- def.onRejected?.(state, to, absorbing.has(state));
343
- return false;
344
- }
345
- const from = state;
346
- state = to;
347
- def.onTransition?.(from, to);
348
- return true;
349
- };
350
- return {
351
- current: () => state,
352
- is: (s) => state === s,
353
- isIn: (ss) => ss.includes(state),
354
- canTransitionTo: (to) => def.transitions[state]?.includes(to) ?? false,
355
- transitionTo: (to) => {
356
- if (!tryTransitionTo(to)) {
357
- throw new Error(`Invalid FSM transition: ${state} -> ${to}`);
358
- }
359
- },
360
- tryTransitionTo,
361
- isInAbsorbingState: () => absorbing.has(state)
362
- };
363
- }
364
- function defineFSM(transitions) {
365
- const absorbing = computeAbsorbingSet(transitions);
366
- return {
367
- canTransition: (from, to) => transitions[from]?.includes(to) ?? false,
368
- isAbsorbing: (state) => absorbing.has(state)
369
- };
370
- }
314
+ // ../../packages/shared/dist/schemas/relay-control.js
315
+ import { z as z11 } from "zod";
371
316
 
372
317
  // ../../packages/shared/dist/schemas/voice.js
373
318
  import { z as z7 } from "zod";
@@ -424,35 +369,29 @@ var VoiceSummaryReasonSchema = z7.enum([
424
369
  "approval"
425
370
  ]);
426
371
 
427
- // ../../packages/shared/dist/schemas/preview-scope.js
428
- import { z as z8 } from "zod";
429
- var PreviewScopeSchema = z8.object({
430
- proxyId: IdSchema,
431
- bindingId: IdSchema
432
- }).strict();
433
-
434
- // ../../packages/shared/dist/schemas/proxy-upgrade-bootstrap.js
435
- import { z as z9 } from "zod";
436
- var PROXY_UPGRADE_BOOTSTRAP_VERSION = 1;
437
- var StableVersionSchema = z9.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
438
- var ProxyUpgradeBootstrapResponseSchema = z9.object({
439
- bootstrapVersion: z9.literal(PROXY_UPGRADE_BOOTSTRAP_VERSION),
440
- relayVersion: StableVersionSchema,
441
- controlProtocolVersion: z9.number().int().positive()
442
- });
372
+ // ../../packages/shared/dist/constants/relay-errors.js
373
+ var RelayErrorCode = {
374
+ NOT_REGISTERED: "NOT_REGISTERED",
375
+ NOT_BOUND: "NOT_BOUND",
376
+ PROXY_OFFLINE: "PROXY_OFFLINE",
377
+ INVALID_MESSAGE: "INVALID_MESSAGE",
378
+ STALE_BINDING: "STALE_BINDING",
379
+ UNSUPPORTED: "UNSUPPORTED",
380
+ INVALID_RANGE: "INVALID_RANGE"
381
+ };
443
382
 
444
383
  // ../../packages/shared/dist/schemas/web-preview.js
445
- import { z as z10 } from "zod";
384
+ import { z as z8 } from "zod";
446
385
  var WEB_PREVIEW_PATH_MAX_LENGTH = 4096;
447
386
  var WEB_PREVIEW_SOURCE_URL_MAX_LENGTH = 4096;
448
387
  var WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH = 65536;
449
388
  var WEB_PREVIEW_NAME_MAX_LENGTH = 256;
450
389
  var WEB_PREVIEW_ERROR_MAX_LENGTH = 4096;
451
390
  var WEB_PREVIEW_HTML_ENTRY_MAX_COUNT = 1e3;
452
- var WebPreviewNameSchema = z10.string().trim().min(1).max(WEB_PREVIEW_NAME_MAX_LENGTH);
391
+ var WebPreviewNameSchema = z8.string().trim().min(1).max(WEB_PREVIEW_NAME_MAX_LENGTH);
453
392
  var tunnelProviderValues = ["cloudflare", "cpolar"];
454
- var TunnelProviderSchema = z10.enum(tunnelProviderValues);
455
- var WebPreviewPathSchema = z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH);
393
+ var TunnelProviderSchema = z8.enum(tunnelProviderValues);
394
+ var WebPreviewPathSchema = z8.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH);
456
395
  function parseUrlSafely(value) {
457
396
  try {
458
397
  return new URL(value);
@@ -460,7 +399,7 @@ function parseUrlSafely(value) {
460
399
  return null;
461
400
  }
462
401
  }
463
- var LoopbackHttpUrlSchema = z10.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_LENGTH).url().refine((value) => {
402
+ var LoopbackHttpUrlSchema = z8.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_LENGTH).url().refine((value) => {
464
403
  const url = parseUrlSafely(value);
465
404
  if (!url)
466
405
  return false;
@@ -468,7 +407,7 @@ var LoopbackHttpUrlSchema = z10.string().min(1).max(WEB_PREVIEW_SOURCE_URL_MAX_L
468
407
  return false;
469
408
  return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
470
409
  }, "Local preview URL must use http:// with a loopback host and no credentials");
471
- var PublicPreviewUrlSchema = z10.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH).url().refine((value) => {
410
+ var PublicPreviewUrlSchema = z8.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_LENGTH).url().refine((value) => {
472
411
  const url = parseUrlSafely(value);
473
412
  if (!url)
474
413
  return false;
@@ -477,48 +416,48 @@ var PublicPreviewUrlSchema = z10.string().min(1).max(WEB_PREVIEW_PUBLIC_URL_MAX_
477
416
  var DNS_LABEL_PATTERN = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
478
417
  var CLOUDFLARE_PUBLIC_HOST_PATTERN = new RegExp(`^${DNS_LABEL_PATTERN}\\.trycloudflare\\.com$`, "i");
479
418
  var CPOLAR_PUBLIC_HOST_PATTERN = new RegExp(`^(?:${DNS_LABEL_PATTERN}\\.)+cpolar\\.(?:top|cn|io)$`, "i");
480
- var WebPreviewTunnelSuggestionsSchema = z10.array(z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
481
- var WebPreviewTunnelStatusSchema = z10.discriminatedUnion("available", [
482
- z10.object({
483
- available: z10.literal(true),
484
- command: z10.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH),
485
- version: z10.string().min(1).max(256).optional(),
486
- error: z10.never().optional(),
419
+ var WebPreviewTunnelSuggestionsSchema = z8.array(z8.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
420
+ var WebPreviewTunnelStatusSchema = z8.discriminatedUnion("available", [
421
+ z8.object({
422
+ available: z8.literal(true),
423
+ command: z8.string().min(1).max(WEB_PREVIEW_PATH_MAX_LENGTH),
424
+ version: z8.string().min(1).max(256).optional(),
425
+ error: z8.never().optional(),
487
426
  suggestions: WebPreviewTunnelSuggestionsSchema
488
427
  }),
489
- z10.object({
490
- available: z10.literal(false),
491
- command: z10.never().optional(),
492
- version: z10.never().optional(),
493
- error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH),
428
+ z8.object({
429
+ available: z8.literal(false),
430
+ command: z8.never().optional(),
431
+ version: z8.never().optional(),
432
+ error: z8.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH),
494
433
  suggestions: WebPreviewTunnelSuggestionsSchema
495
434
  })
496
435
  ]);
497
- var WebPreviewCapabilitySchema = z10.object({
436
+ var WebPreviewCapabilitySchema = z8.object({
498
437
  cloudflared: WebPreviewTunnelStatusSchema,
499
438
  cpolar: WebPreviewTunnelStatusSchema
500
439
  });
501
- var WebPreviewSourceInputSchema = z10.discriminatedUnion("kind", [
502
- z10.object({
503
- kind: z10.literal("local"),
440
+ var WebPreviewSourceInputSchema = z8.discriminatedUnion("kind", [
441
+ z8.object({
442
+ kind: z8.literal("local"),
504
443
  url: LoopbackHttpUrlSchema
505
444
  }).strict(),
506
- z10.object({
507
- kind: z10.literal("static"),
445
+ z8.object({
446
+ kind: z8.literal("static"),
508
447
  path: WebPreviewPathSchema,
509
448
  entryPath: WebPreviewPathSchema
510
449
  }).strict()
511
450
  ]);
512
- var PreviewSourceSchema = z10.discriminatedUnion("kind", [
513
- z10.object({
514
- kind: z10.literal("local"),
515
- rootPath: z10.never().optional(),
516
- entryPath: z10.never().optional(),
451
+ var PreviewSourceSchema = z8.discriminatedUnion("kind", [
452
+ z8.object({
453
+ kind: z8.literal("local"),
454
+ rootPath: z8.never().optional(),
455
+ entryPath: z8.never().optional(),
517
456
  url: LoopbackHttpUrlSchema
518
457
  }),
519
- z10.object({
520
- kind: z10.literal("static"),
521
- url: z10.never().optional(),
458
+ z8.object({
459
+ kind: z8.literal("static"),
460
+ url: z8.never().optional(),
522
461
  rootPath: WebPreviewPathSchema,
523
462
  entryPath: WebPreviewPathSchema
524
463
  })
@@ -530,40 +469,40 @@ var previewStateValues = [
530
469
  "failed",
531
470
  "stopping"
532
471
  ];
533
- var PreviewStateSchema = z10.enum(previewStateValues);
534
- var PreviewSummaryBaseSchema = z10.object({
472
+ var PreviewStateSchema = z8.enum(previewStateValues);
473
+ var PreviewSummaryBaseSchema = z8.object({
535
474
  previewId: IdSchema,
536
475
  name: WebPreviewNameSchema,
537
476
  source: PreviewSourceSchema,
538
477
  tunnelProvider: TunnelProviderSchema,
539
- createdAt: z10.number().int().nonnegative(),
540
- updatedAt: z10.number().int().nonnegative()
478
+ createdAt: z8.number().int().nonnegative(),
479
+ updatedAt: z8.number().int().nonnegative()
541
480
  });
542
481
  var PreviewSummaryInactiveShape = {
543
- publicUrl: z10.never().optional(),
544
- error: z10.never().optional()
482
+ publicUrl: z8.never().optional(),
483
+ error: z8.never().optional()
545
484
  };
546
- var PreviewSummarySchema = z10.discriminatedUnion("state", [
485
+ var PreviewSummarySchema = z8.discriminatedUnion("state", [
547
486
  PreviewSummaryBaseSchema.extend({
548
- state: z10.literal("starting"),
487
+ state: z8.literal("starting"),
549
488
  ...PreviewSummaryInactiveShape
550
489
  }),
551
490
  PreviewSummaryBaseSchema.extend({
552
- state: z10.literal("ready"),
491
+ state: z8.literal("ready"),
553
492
  publicUrl: PublicPreviewUrlSchema,
554
- error: z10.never().optional()
493
+ error: z8.never().optional()
555
494
  }),
556
495
  PreviewSummaryBaseSchema.extend({
557
- state: z10.literal("disconnected"),
496
+ state: z8.literal("disconnected"),
558
497
  ...PreviewSummaryInactiveShape
559
498
  }),
560
499
  PreviewSummaryBaseSchema.extend({
561
- state: z10.literal("failed"),
562
- publicUrl: z10.never().optional(),
563
- error: z10.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH)
500
+ state: z8.literal("failed"),
501
+ publicUrl: z8.never().optional(),
502
+ error: z8.string().min(1).max(WEB_PREVIEW_ERROR_MAX_LENGTH)
564
503
  }),
565
504
  PreviewSummaryBaseSchema.extend({
566
- state: z10.literal("stopping"),
505
+ state: z8.literal("stopping"),
567
506
  ...PreviewSummaryInactiveShape
568
507
  })
569
508
  ]).superRefine((preview, context) => {
@@ -583,104 +522,104 @@ var PreviewSummarySchema = z10.discriminatedUnion("state", [
583
522
  });
584
523
  }
585
524
  });
586
- var PreviewHtmlEntriesSchema = z10.array(WebPreviewPathSchema).max(WEB_PREVIEW_HTML_ENTRY_MAX_COUNT);
525
+ var PreviewHtmlEntriesSchema = z8.array(WebPreviewPathSchema).max(WEB_PREVIEW_HTML_ENTRY_MAX_COUNT);
587
526
 
588
527
  // ../../packages/shared/dist/schemas/device-preview.js
589
- import { z as z11 } from "zod";
528
+ import { z as z9 } from "zod";
590
529
  var DEVICE_PREVIEW_PATH_MAX_LENGTH = 4096;
591
530
  var DEVICE_PREVIEW_TEXT_MAX_LENGTH = 4096;
592
531
  var DEVICE_PREVIEW_ERROR_MAX_LENGTH = 4096;
593
532
  var DEVICE_PREVIEW_NAME_MAX_LENGTH = 256;
594
533
  var DEVICE_PREVIEW_VERSION_MAX_LENGTH = 256;
595
534
  var DEVICE_PREVIEW_SCREEN_EDGE_MAX = 16384;
596
- var DevicePreviewNameSchema = z11.string().trim().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH);
535
+ var DevicePreviewNameSchema = z9.string().trim().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH);
597
536
  var devicePreviewStreamFormatValues = ["jpeg", "h264_annex_b"];
598
- var DevicePreviewStreamFormatSchema = z11.enum(devicePreviewStreamFormatValues);
537
+ var DevicePreviewStreamFormatSchema = z9.enum(devicePreviewStreamFormatValues);
599
538
  var devicePreviewPlatformValues = ["ios", "android"];
600
- var DevicePreviewPlatformSchema = z11.enum(devicePreviewPlatformValues);
601
- var DevicePreviewToolSuggestionsSchema = z11.array(z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
602
- var DevicePreviewToolStatusSchema = z11.union([
603
- z11.object({
604
- supported: z11.literal(false),
605
- available: z11.literal(false),
606
- interactive: z11.literal(false),
607
- command: z11.never().optional(),
608
- version: z11.never().optional(),
609
- error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
539
+ var DevicePreviewPlatformSchema = z9.enum(devicePreviewPlatformValues);
540
+ var DevicePreviewToolSuggestionsSchema = z9.array(z9.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH)).max(32).optional();
541
+ var DevicePreviewToolStatusSchema = z9.union([
542
+ z9.object({
543
+ supported: z9.literal(false),
544
+ available: z9.literal(false),
545
+ interactive: z9.literal(false),
546
+ command: z9.never().optional(),
547
+ version: z9.never().optional(),
548
+ error: z9.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
610
549
  suggestions: DevicePreviewToolSuggestionsSchema
611
550
  }),
612
- z11.object({
613
- supported: z11.literal(true),
614
- available: z11.literal(false),
615
- interactive: z11.literal(false),
616
- command: z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH).optional(),
617
- version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
618
- error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
551
+ z9.object({
552
+ supported: z9.literal(true),
553
+ available: z9.literal(false),
554
+ interactive: z9.literal(false),
555
+ command: z9.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH).optional(),
556
+ version: z9.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
557
+ error: z9.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH),
619
558
  suggestions: DevicePreviewToolSuggestionsSchema
620
559
  }),
621
- z11.object({
622
- supported: z11.literal(true),
623
- available: z11.literal(true),
624
- interactive: z11.literal(true),
625
- command: z11.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH),
626
- version: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
627
- error: z11.never().optional(),
560
+ z9.object({
561
+ supported: z9.literal(true),
562
+ available: z9.literal(true),
563
+ interactive: z9.literal(true),
564
+ command: z9.string().min(1).max(DEVICE_PREVIEW_PATH_MAX_LENGTH),
565
+ version: z9.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH).optional(),
566
+ error: z9.never().optional(),
628
567
  suggestions: DevicePreviewToolSuggestionsSchema
629
568
  })
630
569
  ]);
631
- var DevicePreviewCapabilitySchema = z11.object({
570
+ var DevicePreviewCapabilitySchema = z9.object({
632
571
  ios: DevicePreviewToolStatusSchema,
633
572
  android: DevicePreviewToolStatusSchema
634
573
  });
635
- var DevicePreviewTargetBaseSchema = z11.object({
574
+ var DevicePreviewTargetBaseSchema = z9.object({
636
575
  targetId: IdSchema,
637
576
  platform: DevicePreviewPlatformSchema,
638
- name: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
639
- model: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
640
- osVersion: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
641
- interactive: z11.boolean()
577
+ name: z9.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
578
+ model: z9.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
579
+ osVersion: z9.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
580
+ interactive: z9.boolean()
642
581
  });
643
- var DevicePreviewScreenEdgeSchema = z11.number().int().positive().max(DEVICE_PREVIEW_SCREEN_EDGE_MAX);
644
- var DevicePreviewTargetSchema = z11.union([
582
+ var DevicePreviewScreenEdgeSchema = z9.number().int().positive().max(DEVICE_PREVIEW_SCREEN_EDGE_MAX);
583
+ var DevicePreviewTargetSchema = z9.union([
645
584
  DevicePreviewTargetBaseSchema.extend({
646
585
  width: DevicePreviewScreenEdgeSchema,
647
586
  height: DevicePreviewScreenEdgeSchema
648
587
  }),
649
588
  DevicePreviewTargetBaseSchema.extend({
650
- width: z11.never().optional(),
651
- height: z11.never().optional()
589
+ width: z9.never().optional(),
590
+ height: z9.never().optional()
652
591
  })
653
592
  ]);
654
- var DevicePreviewStateSchema = z11.enum(["ready", "disconnected"]);
655
- var DevicePreviewSummaryBaseSchema = z11.object({
593
+ var DevicePreviewStateSchema = z9.enum(["ready", "disconnected"]);
594
+ var DevicePreviewSummaryBaseSchema = z9.object({
656
595
  previewId: IdSchema,
657
596
  name: DevicePreviewNameSchema,
658
597
  platform: DevicePreviewPlatformSchema,
659
598
  targetId: IdSchema,
660
- model: z11.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
661
- osVersion: z11.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
662
- interactive: z11.boolean(),
663
- createdAt: z11.number().int().nonnegative(),
664
- updatedAt: z11.number().int().nonnegative()
599
+ model: z9.string().min(1).max(DEVICE_PREVIEW_NAME_MAX_LENGTH),
600
+ osVersion: z9.string().min(1).max(DEVICE_PREVIEW_VERSION_MAX_LENGTH),
601
+ interactive: z9.boolean(),
602
+ createdAt: z9.number().int().nonnegative(),
603
+ updatedAt: z9.number().int().nonnegative()
665
604
  });
666
- var DevicePreviewSummarySchema = z11.discriminatedUnion("state", [
605
+ var DevicePreviewSummarySchema = z9.discriminatedUnion("state", [
667
606
  DevicePreviewSummaryBaseSchema.extend({
668
- state: z11.literal("ready"),
669
- error: z11.never().optional()
607
+ state: z9.literal("ready"),
608
+ error: z9.never().optional()
670
609
  }),
671
610
  DevicePreviewSummaryBaseSchema.extend({
672
- state: z11.literal("disconnected"),
673
- error: z11.never().optional()
611
+ state: z9.literal("disconnected"),
612
+ error: z9.never().optional()
674
613
  })
675
614
  ]);
676
- var DevicePreviewJpegStreamProfileSchema = z11.object({
677
- format: z11.literal("jpeg"),
678
- maxFps: z11.number().int().min(1).max(30).optional()
615
+ var DevicePreviewJpegStreamProfileSchema = z9.object({
616
+ format: z9.literal("jpeg"),
617
+ maxFps: z9.number().int().min(1).max(30).optional()
679
618
  }).strict();
680
- var DevicePreviewH264StreamProfileSchema = z11.object({
681
- format: z11.literal("h264_annex_b")
619
+ var DevicePreviewH264StreamProfileSchema = z9.object({
620
+ format: z9.literal("h264_annex_b")
682
621
  }).strict();
683
- var DevicePreviewStreamProfileSchema = z11.discriminatedUnion("format", [
622
+ var DevicePreviewStreamProfileSchema = z9.discriminatedUnion("format", [
684
623
  DevicePreviewJpegStreamProfileSchema,
685
624
  DevicePreviewH264StreamProfileSchema
686
625
  ]);
@@ -691,10 +630,10 @@ var devicePreviewStreamStopReasonValues = [
691
630
  "relay_shutdown",
692
631
  "stream_error"
693
632
  ];
694
- var DevicePreviewStreamStopReasonSchema = z11.enum(devicePreviewStreamStopReasonValues);
695
- var NormalizedCoordinateSchema = z11.number().finite().min(0).max(1);
633
+ var DevicePreviewStreamStopReasonSchema = z9.enum(devicePreviewStreamStopReasonValues);
634
+ var NormalizedCoordinateSchema = z9.number().finite().min(0).max(1);
696
635
  var devicePreviewTouchPhaseValues = ["down", "move", "up"];
697
- var DevicePreviewTouchPhaseSchema = z11.enum(devicePreviewTouchPhaseValues);
636
+ var DevicePreviewTouchPhaseSchema = z9.enum(devicePreviewTouchPhaseValues);
698
637
  var devicePreviewOrientationValues = [
699
638
  "portrait",
700
639
  "landscape_left",
@@ -702,320 +641,166 @@ var devicePreviewOrientationValues = [
702
641
  "portrait_upside_down",
703
642
  "auto"
704
643
  ];
705
- var DevicePreviewOrientationSchema = z11.enum(devicePreviewOrientationValues);
706
- var DevicePreviewInputSchema = z11.discriminatedUnion("kind", [
707
- z11.object({
708
- kind: z11.literal("touch"),
644
+ var DevicePreviewOrientationSchema = z9.enum(devicePreviewOrientationValues);
645
+ var DevicePreviewInputSchema = z9.discriminatedUnion("kind", [
646
+ z9.object({
647
+ kind: z9.literal("touch"),
709
648
  phase: DevicePreviewTouchPhaseSchema,
710
649
  x: NormalizedCoordinateSchema,
711
650
  y: NormalizedCoordinateSchema
712
651
  }).strict(),
713
- z11.object({
714
- kind: z11.literal("text"),
715
- text: z11.string().min(1).max(DEVICE_PREVIEW_TEXT_MAX_LENGTH)
652
+ z9.object({
653
+ kind: z9.literal("text"),
654
+ text: z9.string().min(1).max(DEVICE_PREVIEW_TEXT_MAX_LENGTH)
716
655
  }).strict(),
717
- z11.object({
718
- kind: z11.literal("button"),
719
- button: z11.enum(["home", "back"])
656
+ z9.object({
657
+ kind: z9.literal("button"),
658
+ button: z9.enum(["home", "back"])
720
659
  }).strict(),
721
- z11.object({
722
- kind: z11.literal("orientation"),
660
+ z9.object({
661
+ kind: z9.literal("orientation"),
723
662
  orientation: DevicePreviewOrientationSchema
724
663
  }).strict()
725
664
  ]);
726
- var DevicePreviewStreamRegisterSchema = z11.object({
727
- type: z11.literal("device_preview_stream_register"),
665
+ var DevicePreviewStreamRegisterSchema = z9.object({
666
+ type: z9.literal("device_preview_stream_register"),
728
667
  proxyId: IdSchema,
729
668
  connectionId: IdSchema
730
669
  });
731
- var DevicePreviewStreamRegisterResponseSchema = z11.discriminatedUnion("success", [
732
- z11.object({
733
- type: z11.literal("device_preview_stream_register_response"),
734
- success: z11.literal(true),
735
- error: z11.never().optional()
736
- }),
737
- z11.object({
738
- type: z11.literal("device_preview_stream_register_response"),
739
- success: z11.literal(false),
740
- error: z11.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH)
670
+ var DevicePreviewStreamRegisterResponseSchema = z9.discriminatedUnion("success", [
671
+ z9.object({
672
+ type: z9.literal("device_preview_stream_register_response"),
673
+ success: z9.literal(true),
674
+ error: z9.never().optional()
675
+ }),
676
+ z9.object({
677
+ type: z9.literal("device_preview_stream_register_response"),
678
+ success: z9.literal(false),
679
+ error: z9.string().min(1).max(DEVICE_PREVIEW_ERROR_MAX_LENGTH)
741
680
  })
742
681
  ]);
743
- var DevicePreviewStreamFlowBaseSchema = z11.object({
744
- type: z11.literal("device_preview_stream_flow"),
682
+ var DevicePreviewStreamFlowBaseSchema = z9.object({
683
+ type: z9.literal("device_preview_stream_flow"),
745
684
  streamId: IdSchema
746
685
  });
747
- var DevicePreviewStreamFlowSchema = z11.discriminatedUnion("paused", [
686
+ var DevicePreviewStreamFlowSchema = z9.discriminatedUnion("paused", [
748
687
  DevicePreviewStreamFlowBaseSchema.extend({
749
- paused: z11.literal(true),
750
- resyncRequired: z11.literal(false)
688
+ paused: z9.literal(true),
689
+ resyncRequired: z9.literal(false)
751
690
  }).strict(),
752
691
  DevicePreviewStreamFlowBaseSchema.extend({
753
- paused: z11.literal(false),
754
- resyncRequired: z11.boolean()
692
+ paused: z9.literal(false),
693
+ resyncRequired: z9.boolean()
755
694
  }).strict()
756
695
  ]);
757
- var DevicePreviewStreamServerMessageSchema = z11.union([
696
+ var DevicePreviewStreamServerMessageSchema = z9.union([
758
697
  DevicePreviewStreamRegisterResponseSchema,
759
698
  DevicePreviewStreamFlowSchema
760
699
  ]);
761
700
 
762
- // ../../packages/shared/dist/schemas/voice-stream.js
763
- import { z as z12 } from "zod";
764
- var VoiceAsrAudioEncodingSchema = z12.enum(["pcm_s16le", "mulaw"]);
765
- var VoiceAsrStartMessageSchema = z12.object({
766
- type: z12.literal("start"),
767
- sessionId: z12.string().min(1),
768
- attemptId: z12.string().min(1),
769
- sampleRate: z12.number().int().positive(),
770
- encoding: VoiceAsrAudioEncodingSchema
771
- });
772
- var VoiceAsrStopMessageSchema = z12.object({
773
- type: z12.literal("stop"),
774
- attemptId: z12.string().min(1)
775
- });
776
- var VoiceAsrClientMessageSchema = z12.discriminatedUnion("type", [
777
- VoiceAsrStartMessageSchema,
778
- VoiceAsrStopMessageSchema
779
- ]);
780
- var VoiceAsrServerMessageSchema = z12.discriminatedUnion("type", [
781
- z12.object({ type: z12.literal("ready"), attemptId: z12.string().min(1) }),
782
- z12.object({
783
- type: z12.literal("audio_ack"),
784
- attemptId: z12.string().min(1),
785
- encodedBytes: z12.number().int().nonnegative(),
786
- pcmBytes: z12.number().int().nonnegative(),
787
- chunks: z12.number().int().nonnegative()
788
- }),
789
- z12.object({ type: z12.literal("partial"), attemptId: z12.string().min(1), text: z12.string() }),
790
- z12.object({ type: z12.literal("final"), attemptId: z12.string().min(1), text: z12.string() }),
791
- z12.object({
792
- type: z12.literal("closed"),
793
- attemptId: z12.string().min(1),
794
- code: z12.number().int().optional(),
795
- reason: z12.string().optional()
796
- }),
797
- z12.object({
798
- type: z12.literal("error"),
799
- attemptId: z12.string().min(1),
800
- error: z12.string().optional(),
801
- errorCode: z12.string().optional()
802
- })
803
- ]);
804
-
805
- // ../../packages/shared/dist/slash-commands.js
806
- function isCompactCommandText(text) {
807
- return /^\/compact(?:\s|$)/.test(text.trimStart());
808
- }
809
-
810
- // ../../packages/shared/dist/tool-activity-summary.js
811
- var SECRET_VALUE_PATTERN = /((?:authorization|api[_-]?key|token|password|secret)\s*[:=]\s*)(?:bearer\s+)?[^\s'"]+/giu;
812
- var SECRET_FLAG_PATTERN = /(--(?:api-key|token|password|secret)(?:=|\s+))[^\s'"]+/giu;
813
- function asString(value) {
814
- return typeof value === "string" ? value : "";
815
- }
816
- function compact(value, max = 140) {
817
- const text = value.replace(/\s+/gu, " ").trim();
818
- if (text.length <= max)
819
- return text;
820
- return `${text.slice(0, max - 1)}\u2026`;
821
- }
822
- function redact(value) {
823
- return value.replace(SECRET_VALUE_PATTERN, "$1[redacted]").replace(SECRET_FLAG_PATTERN, "$1[redacted]");
824
- }
825
- function filePath(input) {
826
- return asString(input.file_path) || asString(input.path) || asString(input.notebook_path);
827
- }
828
- function summarizeToolActivity(toolName, input) {
829
- switch (toolName) {
830
- case "Bash": {
831
- const command = compact(redact(asString(input.command)));
832
- return command ? `\u8FD0\u884C\u547D\u4EE4\uFF1A${command}` : "\u8FD0\u884C\u547D\u4EE4";
833
- }
834
- case "BashBatch": {
835
- const commands = Array.isArray(input.commands) ? input.commands.filter((item) => typeof item === "string") : [];
836
- return commands.length > 0 ? `\u6279\u91CF\u8FD0\u884C\u547D\u4EE4\uFF1A${commands.length} \u6761` : "\u6279\u91CF\u8FD0\u884C\u547D\u4EE4";
837
- }
838
- case "ProcessWait":
839
- return "\u7B49\u5F85\u547D\u4EE4\u5B8C\u6210";
840
- case "ProcessInput": {
841
- const value = compact(redact(asString(input.input)), 80);
842
- return value ? `\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165\uFF1A${value}` : "\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165";
843
- }
844
- case "Read": {
845
- const path = filePath(input);
846
- return path ? `\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}` : "\u8BFB\u53D6\u6587\u4EF6";
847
- }
848
- case "Write": {
849
- const path = filePath(input);
850
- return path ? `\u5199\u5165\u6587\u4EF6\uFF1A${path}` : "\u5199\u5165\u6587\u4EF6";
851
- }
852
- case "Edit":
853
- case "MultiEdit": {
854
- const path = filePath(input);
855
- return path ? `\u7F16\u8F91\u6587\u4EF6\uFF1A${path}` : "\u7F16\u8F91\u6587\u4EF6";
856
- }
857
- case "LS": {
858
- const path = filePath(input);
859
- return path ? `\u5217\u51FA\u76EE\u5F55\uFF1A${path}` : "\u5217\u51FA\u76EE\u5F55";
860
- }
861
- case "Grep": {
862
- const pattern = compact(redact(asString(input.pattern)), 80);
863
- const path = filePath(input);
864
- if (pattern && path)
865
- return `\u641C\u7D22\uFF1A${pattern} in ${path}`;
866
- return pattern ? `\u641C\u7D22\uFF1A${pattern}` : "\u641C\u7D22\u6587\u672C";
867
- }
868
- case "Glob": {
869
- const pattern = compact(redact(asString(input.pattern)), 80);
870
- return pattern ? `\u67E5\u627E\u6587\u4EF6\uFF1A${pattern}` : "\u67E5\u627E\u6587\u4EF6";
871
- }
872
- case "WebFetch": {
873
- const url = compact(redact(asString(input.url)), 100);
874
- return url ? `\u8BFB\u53D6\u7F51\u9875\uFF1A${url}` : "\u8BFB\u53D6\u7F51\u9875";
875
- }
876
- case "WebSearch": {
877
- const query = compact(redact(asString(input.query)), 100);
878
- return query ? `\u7F51\u9875\u641C\u7D22\uFF1A${query}` : "\u7F51\u9875\u641C\u7D22";
879
- }
880
- case "ViewImage": {
881
- const path = filePath(input);
882
- return path ? `\u67E5\u770B\u56FE\u7247\uFF1A${path}` : "\u67E5\u770B\u56FE\u7247";
883
- }
884
- case "ViewImageBatch": {
885
- const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
886
- return paths.length > 0 ? `\u6279\u91CF\u67E5\u770B\u56FE\u7247\uFF1A${paths.length} \u5F20` : "\u6279\u91CF\u67E5\u770B\u56FE\u7247";
887
- }
888
- case "Web":
889
- return "\u8BBF\u95EE\u7F51\u9875";
890
- case "ToolScript":
891
- return "\u6267\u884C\u5DE5\u5177\u7F16\u6392";
892
- case "TodoWrite":
893
- return "\u66F4\u65B0\u4EFB\u52A1\u5217\u8868";
894
- case "Patch": {
895
- const path = filePath(input);
896
- if (path)
897
- return `\u5E94\u7528\u8865\u4E01\uFF1A${path}`;
898
- const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
899
- if (paths.length === 1)
900
- return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]}`;
901
- if (paths.length > 1)
902
- return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]} \u7B49 ${paths.length} \u4E2A\u6587\u4EF6`;
903
- return "\u5E94\u7528\u8865\u4E01";
904
- }
905
- default:
906
- return `\u4F7F\u7528\u5DE5\u5177\uFF1A${toolName}`;
907
- }
908
- }
909
-
910
- // ../../packages/shared/dist/schemas/relay-control.js
911
- import { z as z13 } from "zod";
912
-
913
- // ../../packages/shared/dist/constants/relay-errors.js
914
- var RelayErrorCode = {
915
- NOT_REGISTERED: "NOT_REGISTERED",
916
- NOT_BOUND: "NOT_BOUND",
917
- PROXY_OFFLINE: "PROXY_OFFLINE",
918
- INVALID_MESSAGE: "INVALID_MESSAGE",
919
- STALE_BINDING: "STALE_BINDING",
920
- UNSUPPORTED: "UNSUPPORTED",
921
- INVALID_RANGE: "INVALID_RANGE"
922
- };
701
+ // ../../packages/shared/dist/schemas/preview-scope.js
702
+ import { z as z10 } from "zod";
703
+ var PreviewScopeSchema = z10.object({
704
+ proxyId: IdSchema,
705
+ bindingId: IdSchema
706
+ }).strict();
923
707
 
924
708
  // ../../packages/shared/dist/schemas/relay-control.js
925
709
  var RELAY_CONTROL_PROTOCOL_VERSION = 1;
926
- var ProxyInfoSchema = z13.object({
710
+ var ProxyInfoSchema = z11.object({
927
711
  proxyId: IdSchema,
928
- name: z13.string().optional(),
929
- version: z13.string().min(1).max(64),
930
- online: z13.boolean(),
931
- sessions: z13.array(z13.string())
712
+ name: z11.string().optional(),
713
+ osName: z11.string().min(1).max(64).optional(),
714
+ version: z11.string().min(1).max(64),
715
+ online: z11.boolean(),
716
+ sessions: z11.array(z11.string())
932
717
  });
933
- var RelayClientInfoSchema = z13.object({
718
+ var RelayClientInfoSchema = z11.object({
934
719
  clientId: IdSchema,
935
720
  proxyId: IdSchema.optional(),
936
- connectedAt: z13.number().int().nonnegative(),
937
- current: z13.boolean().optional(),
938
- userAgent: z13.string().optional(),
939
- platform: z13.string().optional(),
940
- maxTouchPoints: z13.number().int().nonnegative().optional(),
941
- browserName: z13.string().min(1),
942
- osName: z13.string().min(1),
943
- deviceKind: z13.enum(["desktop", "tablet", "phone", "unknown"]),
944
- remoteAddress: z13.string().optional()
721
+ connectedAt: z11.number().int().nonnegative(),
722
+ current: z11.boolean().optional(),
723
+ userAgent: z11.string().optional(),
724
+ platform: z11.string().optional(),
725
+ maxTouchPoints: z11.number().int().nonnegative().optional(),
726
+ browserName: z11.string().min(1),
727
+ osName: z11.string().min(1),
728
+ deviceKind: z11.enum(["desktop", "tablet", "phone", "unknown"]),
729
+ remoteAddress: z11.string().optional()
945
730
  });
946
- var AgentCliAvailabilitySchema = z13.object({
947
- available: z13.boolean(),
948
- command: z13.string().optional(),
949
- error: z13.string().optional(),
950
- suggestions: z13.array(z13.string()).optional()
731
+ var AgentCliAvailabilitySchema = z11.object({
732
+ available: z11.boolean(),
733
+ command: z11.string().optional(),
734
+ error: z11.string().optional(),
735
+ suggestions: z11.array(z11.string()).optional()
951
736
  });
952
- var AgentCliStatusSchema = z13.object({
737
+ var AgentCliStatusSchema = z11.object({
953
738
  claude: AgentCliAvailabilitySchema,
954
739
  codex: AgentCliAvailabilitySchema,
955
740
  kimi: AgentCliAvailabilitySchema
956
741
  });
957
- var DirEntrySchema = z13.object({ name: z13.string(), isDir: z13.boolean() });
958
- var FileTreeGroupSchema = z13.object({
959
- path: z13.string(),
960
- entries: z13.array(DirEntrySchema)
742
+ var DirEntrySchema = z11.object({ name: z11.string(), isDir: z11.boolean() });
743
+ var FileTreeGroupSchema = z11.object({
744
+ path: z11.string(),
745
+ entries: z11.array(DirEntrySchema)
961
746
  });
962
- var CommandEntrySchema = z13.object({
963
- name: z13.string(),
964
- description: z13.string(),
965
- argumentHint: z13.string().optional(),
966
- source: z13.string()
747
+ var CommandEntrySchema = z11.object({
748
+ name: z11.string(),
749
+ description: z11.string(),
750
+ argumentHint: z11.string().optional(),
751
+ source: z11.string()
967
752
  });
968
- var HistorySessionSchema = z13.object({
969
- id: z13.string(),
970
- title: z13.string(),
971
- projectDir: z13.string(),
972
- updatedAt: z13.number(),
973
- provider: z13.enum(providerValues),
974
- preferredMode: z13.enum(sessionModeValues).optional()
753
+ var HistorySessionSchema = z11.object({
754
+ id: z11.string(),
755
+ title: z11.string(),
756
+ projectDir: z11.string(),
757
+ updatedAt: z11.number(),
758
+ provider: z11.enum(providerValues),
759
+ preferredMode: z11.enum(sessionModeValues).optional()
975
760
  });
976
761
  var SessionHistoryPositionShape = {
977
- timestamp: z13.number().optional(),
978
- cursor: z13.string().optional()
762
+ timestamp: z11.number().optional(),
763
+ cursor: z11.string().optional()
979
764
  };
980
- var SessionHistoryMessageSchema = z13.discriminatedUnion("role", [
981
- z13.object({
982
- role: z13.enum(["user", "assistant", "system"]),
983
- text: z13.string(),
765
+ var SessionHistoryMessageSchema = z11.discriminatedUnion("role", [
766
+ z11.object({
767
+ role: z11.enum(["user", "assistant", "system"]),
768
+ text: z11.string(),
984
769
  ...SessionHistoryPositionShape
985
770
  }),
986
- z13.object({
987
- role: z13.literal("activity"),
988
- text: z13.string(),
771
+ z11.object({
772
+ role: z11.literal("activity"),
773
+ text: z11.string(),
989
774
  toolId: IdSchema,
990
- toolName: z13.string(),
991
- parameters: z13.record(z13.string(), z13.unknown()).optional(),
992
- status: z13.enum(["running", "done", "error"]),
775
+ toolName: z11.string(),
776
+ parameters: z11.record(z11.string(), z11.unknown()).optional(),
777
+ status: z11.enum(["running", "done", "error"]),
993
778
  ...SessionHistoryPositionShape
994
779
  })
995
780
  ]);
996
781
  var RequestIdShape = { requestId: IdSchema.optional() };
997
782
  var RequiredRequestIdShape = { requestId: IdSchema };
998
- var ControlErrorCodeSchema = z13.enum(Object.values(ControlErrorCode));
783
+ var ControlErrorCodeSchema = z11.enum(Object.values(ControlErrorCode));
999
784
  var RequestErrorShape = {
1000
- error: z13.string().optional(),
785
+ error: z11.string().optional(),
1001
786
  errorCode: ControlErrorCodeSchema.optional()
1002
787
  };
1003
788
  var NoRequestErrorShape = {
1004
- error: z13.never().optional(),
1005
- errorCode: z13.never().optional()
789
+ error: z11.never().optional(),
790
+ errorCode: z11.never().optional()
1006
791
  };
1007
792
  var RequiredRequestErrorShape = {
1008
- error: z13.string().min(1),
793
+ error: z11.string().min(1),
1009
794
  errorCode: ControlErrorCodeSchema
1010
795
  };
1011
- var RemoteFileDispositionSchema = z13.enum(["inline", "download"]);
1012
- var RemoteFileUploadKindSchema = z13.enum(["clipboard_image", "file"]);
796
+ var RemoteFileDispositionSchema = z11.enum(["inline", "download"]);
797
+ var RemoteFileUploadKindSchema = z11.enum(["clipboard_image", "file"]);
1013
798
  function control(type, shape, directions) {
1014
799
  return {
1015
800
  type,
1016
801
  directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
1017
- schema: z13.object({
1018
- type: z13.literal(type),
802
+ schema: z11.object({
803
+ type: z11.literal(type),
1019
804
  ...shape ?? {}
1020
805
  })
1021
806
  };
@@ -1024,8 +809,8 @@ function strictControl(type, shape, directions) {
1024
809
  return {
1025
810
  type,
1026
811
  directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
1027
- schema: z13.object({
1028
- type: z13.literal(type),
812
+ schema: z11.object({
813
+ type: z11.literal(type),
1029
814
  ...shape
1030
815
  }).strict()
1031
816
  };
@@ -1037,331 +822,331 @@ function controlSchema(type, schema, directions) {
1037
822
  schema
1038
823
  };
1039
824
  }
1040
- var ProxySelectResponseSchema = z13.discriminatedUnion("success", [
1041
- z13.object({
1042
- type: z13.literal("proxy_select_response"),
825
+ var ProxySelectResponseSchema = z11.discriminatedUnion("success", [
826
+ z11.object({
827
+ type: z11.literal("proxy_select_response"),
1043
828
  ...RequestIdShape,
1044
- success: z13.literal(true),
829
+ success: z11.literal(true),
1045
830
  ...NoRequestErrorShape,
1046
831
  proxyId: IdSchema,
1047
832
  bindingId: IdSchema
1048
833
  }),
1049
- z13.object({
1050
- type: z13.literal("proxy_select_response"),
834
+ z11.object({
835
+ type: z11.literal("proxy_select_response"),
1051
836
  ...RequestIdShape,
1052
- success: z13.literal(false),
1053
- proxyId: z13.never().optional(),
1054
- bindingId: z13.never().optional(),
837
+ success: z11.literal(false),
838
+ proxyId: z11.never().optional(),
839
+ bindingId: z11.never().optional(),
1055
840
  ...RequestErrorShape
1056
841
  })
1057
842
  ]);
1058
- var ClientRegisterResponseSchema = z13.discriminatedUnion("status", [
1059
- z13.object({
1060
- type: z13.literal("client_register_response"),
1061
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1062
- status: z13.literal("restored"),
843
+ var ClientRegisterResponseSchema = z11.discriminatedUnion("status", [
844
+ z11.object({
845
+ type: z11.literal("client_register_response"),
846
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
847
+ status: z11.literal("restored"),
1063
848
  proxyId: IdSchema,
1064
849
  bindingId: IdSchema
1065
850
  }),
1066
- z13.object({
1067
- type: z13.literal("client_register_response"),
1068
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1069
- status: z13.literal("proxy_offline"),
851
+ z11.object({
852
+ type: z11.literal("client_register_response"),
853
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
854
+ status: z11.literal("proxy_offline"),
1070
855
  proxyId: IdSchema,
1071
856
  bindingId: IdSchema
1072
857
  }),
1073
- z13.object({
1074
- type: z13.literal("client_register_response"),
1075
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1076
- status: z13.literal("new"),
858
+ z11.object({
859
+ type: z11.literal("client_register_response"),
860
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
861
+ status: z11.literal("new"),
1077
862
  // 已知的绑定字段不能作为扩展信息被忽略;new 状态明确表示尚未绑定。
1078
- proxyId: z13.never().optional(),
1079
- bindingId: z13.never().optional()
863
+ proxyId: z11.never().optional(),
864
+ bindingId: z11.never().optional()
1080
865
  })
1081
866
  ]);
1082
- var PreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1083
- z13.object({
1084
- type: z13.literal("preview_create_response"),
867
+ var PreviewCreateResponseSchema = z11.discriminatedUnion("accepted", [
868
+ z11.object({
869
+ type: z11.literal("preview_create_response"),
1085
870
  ...RequiredRequestIdShape,
1086
871
  scope: PreviewScopeSchema,
1087
872
  operationId: IdSchema,
1088
- accepted: z13.literal(true),
873
+ accepted: z11.literal(true),
1089
874
  ...NoRequestErrorShape,
1090
875
  previewId: IdSchema
1091
876
  }),
1092
- z13.object({
1093
- type: z13.literal("preview_create_response"),
877
+ z11.object({
878
+ type: z11.literal("preview_create_response"),
1094
879
  ...RequiredRequestIdShape,
1095
880
  scope: PreviewScopeSchema,
1096
881
  operationId: IdSchema,
1097
- accepted: z13.literal(false),
1098
- previewId: z13.never().optional(),
882
+ accepted: z11.literal(false),
883
+ previewId: z11.never().optional(),
1099
884
  ...RequiredRequestErrorShape
1100
885
  })
1101
886
  ]);
1102
- var DevicePreviewCreateResponseSchema = z13.discriminatedUnion("accepted", [
1103
- z13.object({
1104
- type: z13.literal("device_preview_create_response"),
887
+ var DevicePreviewCreateResponseSchema = z11.discriminatedUnion("accepted", [
888
+ z11.object({
889
+ type: z11.literal("device_preview_create_response"),
1105
890
  ...RequiredRequestIdShape,
1106
891
  scope: PreviewScopeSchema,
1107
892
  operationId: IdSchema,
1108
- accepted: z13.literal(true),
893
+ accepted: z11.literal(true),
1109
894
  ...NoRequestErrorShape,
1110
895
  previewId: IdSchema
1111
896
  }),
1112
- z13.object({
1113
- type: z13.literal("device_preview_create_response"),
897
+ z11.object({
898
+ type: z11.literal("device_preview_create_response"),
1114
899
  ...RequiredRequestIdShape,
1115
900
  scope: PreviewScopeSchema,
1116
901
  operationId: IdSchema,
1117
- accepted: z13.literal(false),
1118
- previewId: z13.never().optional(),
902
+ accepted: z11.literal(false),
903
+ previewId: z11.never().optional(),
1119
904
  ...RequiredRequestErrorShape
1120
905
  })
1121
906
  ]);
1122
- var PreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1123
- z13.object({
1124
- type: z13.literal("preview_capability_response"),
907
+ var PreviewCapabilityResponseSchema = z11.discriminatedUnion("success", [
908
+ z11.object({
909
+ type: z11.literal("preview_capability_response"),
1125
910
  ...RequiredRequestIdShape,
1126
911
  scope: PreviewScopeSchema,
1127
- success: z13.literal(true),
912
+ success: z11.literal(true),
1128
913
  ...NoRequestErrorShape,
1129
914
  capability: WebPreviewCapabilitySchema
1130
915
  }),
1131
- z13.object({
1132
- type: z13.literal("preview_capability_response"),
916
+ z11.object({
917
+ type: z11.literal("preview_capability_response"),
1133
918
  ...RequiredRequestIdShape,
1134
919
  scope: PreviewScopeSchema,
1135
- success: z13.literal(false),
1136
- capability: z13.never().optional(),
920
+ success: z11.literal(false),
921
+ capability: z11.never().optional(),
1137
922
  ...RequiredRequestErrorShape
1138
923
  })
1139
924
  ]);
1140
- var DevicePreviewCapabilityResponseSchema = z13.discriminatedUnion("success", [
1141
- z13.object({
1142
- type: z13.literal("device_preview_capability_response"),
925
+ var DevicePreviewCapabilityResponseSchema = z11.discriminatedUnion("success", [
926
+ z11.object({
927
+ type: z11.literal("device_preview_capability_response"),
1143
928
  ...RequiredRequestIdShape,
1144
929
  scope: PreviewScopeSchema,
1145
- success: z13.literal(true),
930
+ success: z11.literal(true),
1146
931
  ...NoRequestErrorShape,
1147
932
  capability: DevicePreviewCapabilitySchema
1148
933
  }),
1149
- z13.object({
1150
- type: z13.literal("device_preview_capability_response"),
934
+ z11.object({
935
+ type: z11.literal("device_preview_capability_response"),
1151
936
  ...RequiredRequestIdShape,
1152
937
  scope: PreviewScopeSchema,
1153
- success: z13.literal(false),
1154
- capability: z13.never().optional(),
938
+ success: z11.literal(false),
939
+ capability: z11.never().optional(),
1155
940
  ...RequiredRequestErrorShape
1156
941
  })
1157
942
  ]);
1158
- var ProxyInfoRequestSchema = z13.object({
1159
- type: z13.literal("proxy_info_request"),
943
+ var ProxyInfoRequestSchema = z11.object({
944
+ type: z11.literal("proxy_info_request"),
1160
945
  ...RequestIdShape
1161
946
  }).strict();
1162
- var ProxyInfoResponseSchema = z13.object({
1163
- type: z13.literal("proxy_info"),
947
+ var ProxyInfoResponseSchema = z11.object({
948
+ type: z11.literal("proxy_info"),
1164
949
  ...RequestIdShape,
1165
- homePath: z13.string(),
950
+ homePath: z11.string(),
1166
951
  agentCli: AgentCliStatusSchema
1167
952
  });
1168
- var PreviewStaticInspectResponseSchema = z13.discriminatedUnion("success", [
1169
- z13.object({
1170
- type: z13.literal("preview_static_inspect_response"),
953
+ var PreviewStaticInspectResponseSchema = z11.discriminatedUnion("success", [
954
+ z11.object({
955
+ type: z11.literal("preview_static_inspect_response"),
1171
956
  ...RequiredRequestIdShape,
1172
957
  scope: PreviewScopeSchema,
1173
- success: z13.literal(true),
958
+ success: z11.literal(true),
1174
959
  ...NoRequestErrorShape,
1175
960
  entryPath: WebPreviewPathSchema.optional(),
1176
961
  htmlEntries: PreviewHtmlEntriesSchema
1177
962
  }),
1178
- z13.object({
1179
- type: z13.literal("preview_static_inspect_response"),
963
+ z11.object({
964
+ type: z11.literal("preview_static_inspect_response"),
1180
965
  ...RequiredRequestIdShape,
1181
966
  scope: PreviewScopeSchema,
1182
- success: z13.literal(false),
1183
- entryPath: z13.never().optional(),
1184
- htmlEntries: z13.never().optional(),
967
+ success: z11.literal(false),
968
+ entryPath: z11.never().optional(),
969
+ htmlEntries: z11.never().optional(),
1185
970
  ...RequiredRequestErrorShape
1186
971
  })
1187
972
  ]);
1188
- var PreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1189
- z13.object({
1190
- type: z13.literal("preview_rename_response"),
973
+ var PreviewRenameResponseSchema = z11.discriminatedUnion("success", [
974
+ z11.object({
975
+ type: z11.literal("preview_rename_response"),
1191
976
  ...RequiredRequestIdShape,
1192
977
  scope: PreviewScopeSchema,
1193
978
  operationId: IdSchema,
1194
979
  previewId: IdSchema,
1195
- success: z13.literal(true),
980
+ success: z11.literal(true),
1196
981
  ...NoRequestErrorShape
1197
982
  }),
1198
- z13.object({
1199
- type: z13.literal("preview_rename_response"),
983
+ z11.object({
984
+ type: z11.literal("preview_rename_response"),
1200
985
  ...RequiredRequestIdShape,
1201
986
  scope: PreviewScopeSchema,
1202
987
  operationId: IdSchema,
1203
988
  previewId: IdSchema,
1204
- success: z13.literal(false),
989
+ success: z11.literal(false),
1205
990
  ...RequiredRequestErrorShape
1206
991
  })
1207
992
  ]);
1208
- var PreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1209
- z13.object({
1210
- type: z13.literal("preview_reconnect_response"),
993
+ var PreviewReconnectResponseSchema = z11.discriminatedUnion("success", [
994
+ z11.object({
995
+ type: z11.literal("preview_reconnect_response"),
1211
996
  ...RequiredRequestIdShape,
1212
997
  scope: PreviewScopeSchema,
1213
998
  operationId: IdSchema,
1214
999
  previewId: IdSchema,
1215
- success: z13.literal(true),
1000
+ success: z11.literal(true),
1216
1001
  ...NoRequestErrorShape
1217
1002
  }),
1218
- z13.object({
1219
- type: z13.literal("preview_reconnect_response"),
1003
+ z11.object({
1004
+ type: z11.literal("preview_reconnect_response"),
1220
1005
  ...RequiredRequestIdShape,
1221
1006
  scope: PreviewScopeSchema,
1222
1007
  operationId: IdSchema,
1223
1008
  previewId: IdSchema,
1224
- success: z13.literal(false),
1009
+ success: z11.literal(false),
1225
1010
  ...RequiredRequestErrorShape
1226
1011
  })
1227
1012
  ]);
1228
- var PreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1229
- z13.object({
1230
- type: z13.literal("preview_close_response"),
1013
+ var PreviewCloseResponseSchema = z11.discriminatedUnion("success", [
1014
+ z11.object({
1015
+ type: z11.literal("preview_close_response"),
1231
1016
  ...RequiredRequestIdShape,
1232
1017
  scope: PreviewScopeSchema,
1233
1018
  operationId: IdSchema,
1234
1019
  previewId: IdSchema,
1235
- success: z13.literal(true),
1020
+ success: z11.literal(true),
1236
1021
  ...NoRequestErrorShape
1237
1022
  }),
1238
- z13.object({
1239
- type: z13.literal("preview_close_response"),
1023
+ z11.object({
1024
+ type: z11.literal("preview_close_response"),
1240
1025
  ...RequiredRequestIdShape,
1241
1026
  scope: PreviewScopeSchema,
1242
1027
  operationId: IdSchema,
1243
1028
  previewId: IdSchema,
1244
- success: z13.literal(false),
1029
+ success: z11.literal(false),
1245
1030
  ...RequiredRequestErrorShape
1246
1031
  })
1247
1032
  ]);
1248
- var DevicePreviewTargetsResponseSchema = z13.discriminatedUnion("success", [
1249
- z13.object({
1250
- type: z13.literal("device_preview_targets_response"),
1033
+ var DevicePreviewTargetsResponseSchema = z11.discriminatedUnion("success", [
1034
+ z11.object({
1035
+ type: z11.literal("device_preview_targets_response"),
1251
1036
  ...RequiredRequestIdShape,
1252
1037
  scope: PreviewScopeSchema,
1253
- success: z13.literal(true),
1038
+ success: z11.literal(true),
1254
1039
  ...NoRequestErrorShape,
1255
- targets: z13.array(DevicePreviewTargetSchema).max(1024)
1040
+ targets: z11.array(DevicePreviewTargetSchema).max(1024)
1256
1041
  }),
1257
- z13.object({
1258
- type: z13.literal("device_preview_targets_response"),
1042
+ z11.object({
1043
+ type: z11.literal("device_preview_targets_response"),
1259
1044
  ...RequiredRequestIdShape,
1260
1045
  scope: PreviewScopeSchema,
1261
- success: z13.literal(false),
1262
- targets: z13.never().optional(),
1046
+ success: z11.literal(false),
1047
+ targets: z11.never().optional(),
1263
1048
  ...RequiredRequestErrorShape
1264
1049
  })
1265
1050
  ]);
1266
- var DevicePreviewRenameResponseSchema = z13.discriminatedUnion("success", [
1267
- z13.object({
1268
- type: z13.literal("device_preview_rename_response"),
1051
+ var DevicePreviewRenameResponseSchema = z11.discriminatedUnion("success", [
1052
+ z11.object({
1053
+ type: z11.literal("device_preview_rename_response"),
1269
1054
  ...RequiredRequestIdShape,
1270
1055
  scope: PreviewScopeSchema,
1271
1056
  operationId: IdSchema,
1272
1057
  previewId: IdSchema,
1273
- success: z13.literal(true),
1058
+ success: z11.literal(true),
1274
1059
  ...NoRequestErrorShape
1275
1060
  }),
1276
- z13.object({
1277
- type: z13.literal("device_preview_rename_response"),
1061
+ z11.object({
1062
+ type: z11.literal("device_preview_rename_response"),
1278
1063
  ...RequiredRequestIdShape,
1279
1064
  scope: PreviewScopeSchema,
1280
1065
  operationId: IdSchema,
1281
1066
  previewId: IdSchema,
1282
- success: z13.literal(false),
1067
+ success: z11.literal(false),
1283
1068
  ...RequiredRequestErrorShape
1284
1069
  })
1285
1070
  ]);
1286
- var DevicePreviewReconnectResponseSchema = z13.discriminatedUnion("success", [
1287
- z13.object({
1288
- type: z13.literal("device_preview_reconnect_response"),
1071
+ var DevicePreviewReconnectResponseSchema = z11.discriminatedUnion("success", [
1072
+ z11.object({
1073
+ type: z11.literal("device_preview_reconnect_response"),
1289
1074
  ...RequiredRequestIdShape,
1290
1075
  scope: PreviewScopeSchema,
1291
1076
  operationId: IdSchema,
1292
1077
  previewId: IdSchema,
1293
- success: z13.literal(true),
1078
+ success: z11.literal(true),
1294
1079
  ...NoRequestErrorShape
1295
1080
  }),
1296
- z13.object({
1297
- type: z13.literal("device_preview_reconnect_response"),
1081
+ z11.object({
1082
+ type: z11.literal("device_preview_reconnect_response"),
1298
1083
  ...RequiredRequestIdShape,
1299
1084
  scope: PreviewScopeSchema,
1300
1085
  operationId: IdSchema,
1301
1086
  previewId: IdSchema,
1302
- success: z13.literal(false),
1087
+ success: z11.literal(false),
1303
1088
  ...RequiredRequestErrorShape
1304
1089
  })
1305
1090
  ]);
1306
- var DevicePreviewCloseResponseSchema = z13.discriminatedUnion("success", [
1307
- z13.object({
1308
- type: z13.literal("device_preview_close_response"),
1091
+ var DevicePreviewCloseResponseSchema = z11.discriminatedUnion("success", [
1092
+ z11.object({
1093
+ type: z11.literal("device_preview_close_response"),
1309
1094
  ...RequiredRequestIdShape,
1310
1095
  scope: PreviewScopeSchema,
1311
1096
  operationId: IdSchema,
1312
1097
  previewId: IdSchema,
1313
- success: z13.literal(true),
1098
+ success: z11.literal(true),
1314
1099
  ...NoRequestErrorShape
1315
1100
  }),
1316
- z13.object({
1317
- type: z13.literal("device_preview_close_response"),
1101
+ z11.object({
1102
+ type: z11.literal("device_preview_close_response"),
1318
1103
  ...RequiredRequestIdShape,
1319
1104
  scope: PreviewScopeSchema,
1320
1105
  operationId: IdSchema,
1321
1106
  previewId: IdSchema,
1322
- success: z13.literal(false),
1107
+ success: z11.literal(false),
1323
1108
  ...RequiredRequestErrorShape
1324
1109
  })
1325
1110
  ]);
1326
- var DevicePreviewStreamUrlResponseSchema = z13.discriminatedUnion("success", [
1327
- z13.object({
1328
- type: z13.literal("device_preview_stream_url_response"),
1111
+ var DevicePreviewStreamUrlResponseSchema = z11.discriminatedUnion("success", [
1112
+ z11.object({
1113
+ type: z11.literal("device_preview_stream_url_response"),
1329
1114
  ...RequiredRequestIdShape,
1330
1115
  scope: PreviewScopeSchema,
1331
1116
  previewId: IdSchema,
1332
- success: z13.literal(true),
1117
+ success: z11.literal(true),
1333
1118
  ...NoRequestErrorShape,
1334
- url: z13.string().min(1).max(4096),
1119
+ url: z11.string().min(1).max(4096),
1335
1120
  leaseId: IdSchema,
1336
- expiresAt: z13.number().int().nonnegative(),
1337
- controlMode: z13.enum(["controller", "view_only"])
1121
+ expiresAt: z11.number().int().nonnegative(),
1122
+ controlMode: z11.enum(["controller", "view_only"])
1338
1123
  }),
1339
- z13.object({
1340
- type: z13.literal("device_preview_stream_url_response"),
1124
+ z11.object({
1125
+ type: z11.literal("device_preview_stream_url_response"),
1341
1126
  ...RequiredRequestIdShape,
1342
1127
  scope: PreviewScopeSchema,
1343
1128
  previewId: IdSchema,
1344
- success: z13.literal(false),
1345
- url: z13.never().optional(),
1346
- leaseId: z13.never().optional(),
1347
- expiresAt: z13.never().optional(),
1348
- controlMode: z13.never().optional(),
1129
+ success: z11.literal(false),
1130
+ url: z11.never().optional(),
1131
+ leaseId: z11.never().optional(),
1132
+ expiresAt: z11.never().optional(),
1133
+ controlMode: z11.never().optional(),
1349
1134
  ...RequiredRequestErrorShape
1350
1135
  })
1351
1136
  ]);
1352
1137
  var DevicePreviewStreamStartResponseBaseShape = {
1353
- type: z13.literal("device_preview_stream_start_response"),
1138
+ type: z11.literal("device_preview_stream_start_response"),
1354
1139
  streamId: IdSchema,
1355
1140
  leaseId: IdSchema,
1356
1141
  previewId: IdSchema
1357
1142
  };
1358
- var DevicePreviewStreamStartSuccessSchema = z13.object({
1143
+ var DevicePreviewStreamStartSuccessSchema = z11.object({
1359
1144
  ...DevicePreviewStreamStartResponseBaseShape,
1360
- success: z13.literal(true),
1145
+ success: z11.literal(true),
1361
1146
  ...NoRequestErrorShape,
1362
1147
  format: DevicePreviewStreamFormatSchema,
1363
- width: z13.number().int().positive().max(16384).optional(),
1364
- height: z13.number().int().positive().max(16384).optional()
1148
+ width: z11.number().int().positive().max(16384).optional(),
1149
+ height: z11.number().int().positive().max(16384).optional()
1365
1150
  }).superRefine((response, context) => {
1366
1151
  if (response.width === void 0 === (response.height === void 0))
1367
1152
  return;
@@ -1371,80 +1156,80 @@ var DevicePreviewStreamStartSuccessSchema = z13.object({
1371
1156
  message: "Device preview stream dimensions must include both width and height"
1372
1157
  });
1373
1158
  });
1374
- var DevicePreviewStreamStartResponseSchema = z13.discriminatedUnion("success", [
1159
+ var DevicePreviewStreamStartResponseSchema = z11.discriminatedUnion("success", [
1375
1160
  DevicePreviewStreamStartSuccessSchema,
1376
- z13.object({
1161
+ z11.object({
1377
1162
  ...DevicePreviewStreamStartResponseBaseShape,
1378
- success: z13.literal(false),
1379
- format: z13.never().optional(),
1380
- width: z13.never().optional(),
1381
- height: z13.never().optional(),
1163
+ success: z11.literal(false),
1164
+ format: z11.never().optional(),
1165
+ width: z11.never().optional(),
1166
+ height: z11.never().optional(),
1382
1167
  ...RequiredRequestErrorShape
1383
1168
  })
1384
1169
  ]);
1385
- var DevicePreviewStreamCompleteSchema = z13.object({
1386
- type: z13.literal("device_preview_stream_complete"),
1170
+ var DevicePreviewStreamCompleteSchema = z11.object({
1171
+ type: z11.literal("device_preview_stream_complete"),
1387
1172
  streamId: IdSchema,
1388
1173
  leaseId: IdSchema,
1389
1174
  previewId: IdSchema,
1390
- success: z13.literal(false),
1391
- error: z13.string().min(1)
1175
+ success: z11.literal(false),
1176
+ error: z11.string().min(1)
1392
1177
  });
1393
1178
  var DevicePreviewStreamStartBaseShape = {
1394
- type: z13.literal("device_preview_stream_start"),
1179
+ type: z11.literal("device_preview_stream_start"),
1395
1180
  streamId: IdSchema,
1396
1181
  leaseId: IdSchema,
1397
1182
  previewId: IdSchema
1398
1183
  };
1399
- var DevicePreviewStreamStartSchema = z13.discriminatedUnion("format", [
1400
- z13.object({
1184
+ var DevicePreviewStreamStartSchema = z11.discriminatedUnion("format", [
1185
+ z11.object({
1401
1186
  ...DevicePreviewStreamStartBaseShape,
1402
1187
  ...DevicePreviewJpegStreamProfileSchema.shape
1403
1188
  }).strict(),
1404
- z13.object({
1189
+ z11.object({
1405
1190
  ...DevicePreviewStreamStartBaseShape,
1406
1191
  ...DevicePreviewH264StreamProfileSchema.shape
1407
1192
  }).strict()
1408
1193
  ]);
1409
- var DevicePreviewInputAckSchema = z13.discriminatedUnion("success", [
1410
- z13.object({
1411
- type: z13.literal("device_preview_input_ack"),
1194
+ var DevicePreviewInputAckSchema = z11.discriminatedUnion("success", [
1195
+ z11.object({
1196
+ type: z11.literal("device_preview_input_ack"),
1412
1197
  scope: PreviewScopeSchema,
1413
1198
  leaseId: IdSchema,
1414
- inputSeq: z13.number().int().min(0).max(4294967295),
1415
- success: z13.literal(true),
1199
+ inputSeq: z11.number().int().min(0).max(4294967295),
1200
+ success: z11.literal(true),
1416
1201
  ...NoRequestErrorShape
1417
1202
  }),
1418
- z13.object({
1419
- type: z13.literal("device_preview_input_ack"),
1203
+ z11.object({
1204
+ type: z11.literal("device_preview_input_ack"),
1420
1205
  scope: PreviewScopeSchema,
1421
1206
  leaseId: IdSchema,
1422
- inputSeq: z13.number().int().min(0).max(4294967295),
1423
- success: z13.literal(false),
1207
+ inputSeq: z11.number().int().min(0).max(4294967295),
1208
+ success: z11.literal(false),
1424
1209
  ...RequiredRequestErrorShape
1425
1210
  })
1426
1211
  ]);
1427
- var DevicePreviewControlClaimResponseSchema = z13.discriminatedUnion("success", [
1428
- z13.object({
1429
- type: z13.literal("device_preview_control_claim_response"),
1212
+ var DevicePreviewControlClaimResponseSchema = z11.discriminatedUnion("success", [
1213
+ z11.object({
1214
+ type: z11.literal("device_preview_control_claim_response"),
1430
1215
  ...RequiredRequestIdShape,
1431
1216
  scope: PreviewScopeSchema,
1432
1217
  leaseId: IdSchema,
1433
- success: z13.literal(true),
1218
+ success: z11.literal(true),
1434
1219
  ...NoRequestErrorShape,
1435
- controlMode: z13.literal("controller")
1220
+ controlMode: z11.literal("controller")
1436
1221
  }),
1437
- z13.object({
1438
- type: z13.literal("device_preview_control_claim_response"),
1222
+ z11.object({
1223
+ type: z11.literal("device_preview_control_claim_response"),
1439
1224
  ...RequiredRequestIdShape,
1440
1225
  scope: PreviewScopeSchema,
1441
1226
  leaseId: IdSchema,
1442
- success: z13.literal(false),
1443
- controlMode: z13.never().optional(),
1227
+ success: z11.literal(false),
1228
+ controlMode: z11.never().optional(),
1444
1229
  ...RequiredRequestErrorShape
1445
1230
  })
1446
1231
  ]);
1447
- var SessionPermissionModeSchema = z13.enum([
1232
+ var SessionPermissionModeSchema = z11.enum([
1448
1233
  "default",
1449
1234
  "auto",
1450
1235
  "acceptEdits",
@@ -1452,110 +1237,111 @@ var SessionPermissionModeSchema = z13.enum([
1452
1237
  "bypassPermissions",
1453
1238
  "dontAsk"
1454
1239
  ]);
1455
- var AgentJsonSessionCreateSchema = z13.object({
1456
- type: z13.literal("session_create"),
1240
+ var AgentJsonSessionCreateSchema = z11.object({
1241
+ type: z11.literal("session_create"),
1457
1242
  ...RequiredRequestIdShape,
1458
- kind: z13.literal("agent"),
1459
- cwd: z13.string(),
1460
- name: z13.string().optional(),
1461
- provider: z13.enum(providerValues),
1462
- mode: z13.literal("json"),
1463
- resumeSessionId: z13.string().optional(),
1243
+ kind: z11.literal("agent"),
1244
+ cwd: z11.string(),
1245
+ name: z11.string().optional(),
1246
+ provider: z11.enum(providerValues),
1247
+ mode: z11.literal("json"),
1248
+ resumeSessionId: z11.string().optional(),
1464
1249
  permissionMode: SessionPermissionModeSchema.optional()
1465
1250
  }).strict();
1466
- var AgentPtySessionCreateSchema = z13.object({
1467
- type: z13.literal("session_create"),
1251
+ var AgentPtySessionCreateSchema = z11.object({
1252
+ type: z11.literal("session_create"),
1468
1253
  ...RequiredRequestIdShape,
1469
- kind: z13.literal("agent"),
1470
- cwd: z13.string(),
1471
- name: z13.string().optional(),
1472
- provider: z13.enum(providerValues),
1473
- mode: z13.literal("pty"),
1474
- resumeSessionId: z13.string().optional(),
1475
- cols: z13.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1476
- rows: z13.number().int().positive().max(PTY_INITIAL_MAX_ROWS),
1254
+ kind: z11.literal("agent"),
1255
+ cwd: z11.string(),
1256
+ name: z11.string().optional(),
1257
+ provider: z11.enum(providerValues),
1258
+ mode: z11.literal("pty"),
1259
+ resumeSessionId: z11.string().optional(),
1260
+ cols: z11.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1261
+ rows: z11.number().int().positive().max(PTY_INITIAL_MAX_ROWS),
1477
1262
  permissionMode: SessionPermissionModeSchema.optional()
1478
1263
  }).strict();
1479
- var TerminalSessionCreateSchema = z13.object({
1480
- type: z13.literal("session_create"),
1264
+ var TerminalSessionCreateSchema = z11.object({
1265
+ type: z11.literal("session_create"),
1481
1266
  ...RequiredRequestIdShape,
1482
- kind: z13.literal("terminal"),
1483
- name: z13.string().optional(),
1484
- mode: z13.literal("pty"),
1485
- cols: z13.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1486
- rows: z13.number().int().positive().max(PTY_INITIAL_MAX_ROWS)
1267
+ kind: z11.literal("terminal"),
1268
+ name: z11.string().optional(),
1269
+ mode: z11.literal("pty"),
1270
+ cols: z11.number().int().positive().max(PTY_INITIAL_MAX_COLS),
1271
+ rows: z11.number().int().positive().max(PTY_INITIAL_MAX_ROWS)
1487
1272
  }).strict();
1488
- var SessionCreateSchema = z13.discriminatedUnion("mode", [
1273
+ var SessionCreateSchema = z11.discriminatedUnion("mode", [
1489
1274
  AgentJsonSessionCreateSchema,
1490
- z13.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
1275
+ z11.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
1491
1276
  ]);
1492
1277
  var SessionCreateSuccessBaseShape = {
1493
1278
  ...NoRequestErrorShape,
1494
- activeWriterPid: z13.never().optional(),
1495
- type: z13.literal("session_create_response"),
1279
+ activeWriterPid: z11.never().optional(),
1280
+ type: z11.literal("session_create_response"),
1496
1281
  ...RequiredRequestIdShape,
1497
- success: z13.literal(true),
1282
+ success: z11.literal(true),
1498
1283
  sessionId: IdSchema,
1499
- cwd: z13.string(),
1500
- lastActive: z13.number(),
1501
- name: z13.string().optional(),
1502
- nameLocked: z13.boolean().optional()
1284
+ cwd: z11.string(),
1285
+ lastActive: z11.number(),
1286
+ name: z11.string().optional(),
1287
+ nameLocked: z11.boolean().optional()
1503
1288
  };
1504
- var SessionCreateSuccessResponseSchema = z13.discriminatedUnion("mode", [
1505
- z13.object({
1289
+ var SessionCreateSuccessResponseSchema = z11.discriminatedUnion("mode", [
1290
+ z11.object({
1506
1291
  ...SessionCreateSuccessBaseShape,
1507
- kind: z13.literal("agent"),
1508
- mode: z13.literal("json"),
1509
- ptyOwner: z13.never().optional(),
1510
- provider: z13.enum(providerValues)
1292
+ kind: z11.literal("agent"),
1293
+ mode: z11.literal("json"),
1294
+ ptyOwner: z11.never().optional(),
1295
+ provider: z11.enum(providerValues)
1511
1296
  }),
1512
- z13.discriminatedUnion("kind", [
1513
- z13.object({
1297
+ z11.discriminatedUnion("kind", [
1298
+ z11.object({
1514
1299
  ...SessionCreateSuccessBaseShape,
1515
- kind: z13.literal("agent"),
1516
- mode: z13.literal("pty"),
1517
- provider: z13.enum(providerValues),
1518
- ptyOwner: z13.enum(ptyOwnerValues)
1300
+ kind: z11.literal("agent"),
1301
+ mode: z11.literal("pty"),
1302
+ provider: z11.enum(providerValues),
1303
+ ptyOwner: z11.enum(ptyOwnerValues)
1519
1304
  }),
1520
- z13.object({
1305
+ z11.object({
1521
1306
  ...SessionCreateSuccessBaseShape,
1522
- kind: z13.literal("terminal"),
1523
- mode: z13.literal("pty"),
1524
- provider: z13.literal("claude"),
1525
- ptyOwner: z13.literal("proxy-hosted")
1307
+ kind: z11.literal("terminal"),
1308
+ mode: z11.literal("pty"),
1309
+ provider: z11.literal("claude"),
1310
+ ptyOwner: z11.literal("proxy-hosted")
1526
1311
  })
1527
1312
  ])
1528
1313
  ]);
1529
- var SessionCreateResponseSchema = z13.discriminatedUnion("success", [
1314
+ var SessionCreateResponseSchema = z11.discriminatedUnion("success", [
1530
1315
  SessionCreateSuccessResponseSchema,
1531
- z13.object({
1532
- type: z13.literal("session_create_response"),
1316
+ z11.object({
1317
+ type: z11.literal("session_create_response"),
1533
1318
  ...RequiredRequestIdShape,
1534
- success: z13.literal(false),
1535
- sessionId: z13.never().optional(),
1536
- cwd: z13.never().optional(),
1537
- lastActive: z13.never().optional(),
1538
- name: z13.never().optional(),
1539
- nameLocked: z13.never().optional(),
1540
- kind: z13.never().optional(),
1541
- mode: z13.never().optional(),
1542
- provider: z13.never().optional(),
1543
- ptyOwner: z13.never().optional(),
1319
+ success: z11.literal(false),
1320
+ sessionId: z11.never().optional(),
1321
+ cwd: z11.never().optional(),
1322
+ lastActive: z11.never().optional(),
1323
+ name: z11.never().optional(),
1324
+ nameLocked: z11.never().optional(),
1325
+ kind: z11.never().optional(),
1326
+ mode: z11.never().optional(),
1327
+ provider: z11.never().optional(),
1328
+ ptyOwner: z11.never().optional(),
1544
1329
  ...RequiredRequestErrorShape,
1545
- activeWriterPid: z13.number().int().positive().optional()
1330
+ activeWriterPid: z11.number().int().positive().optional()
1546
1331
  })
1547
1332
  ]);
1548
1333
  var relayControlDefinitions = [
1549
1334
  control("proxy_register", {
1550
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1335
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1551
1336
  proxyId: IdSchema,
1552
- name: z13.string().optional(),
1553
- proxyVersion: z13.string().min(1).max(64)
1337
+ name: z11.string().optional(),
1338
+ osName: z11.string().min(1).max(64).optional(),
1339
+ proxyVersion: z11.string().min(1).max(64)
1554
1340
  }),
1555
1341
  control("proxy_register_response", {
1556
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1557
- status: z13.enum(["new", "reconnected"]),
1558
- relayVersion: z13.string().min(1).max(64),
1342
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1343
+ status: z11.enum(["new", "reconnected"]),
1344
+ relayVersion: z11.string().min(1).max(64),
1559
1345
  // Relay rotates this nonce for every successful main Proxy registration. The dedicated image
1560
1346
  // stream socket must present it before Relay accepts frames, so a superseded Proxy connection
1561
1347
  // cannot keep publishing into a newly registered Proxy with the same persistent proxyId.
@@ -1564,7 +1350,7 @@ var relayControlDefinitions = [
1564
1350
  control("proxy_list_request", RequestIdShape),
1565
1351
  control("proxy_list_response", {
1566
1352
  ...RequestIdShape,
1567
- proxies: z13.array(ProxyInfoSchema)
1353
+ proxies: z11.array(ProxyInfoSchema)
1568
1354
  }),
1569
1355
  control("proxy_remove", {
1570
1356
  ...RequiredRequestIdShape,
@@ -1573,74 +1359,74 @@ var relayControlDefinitions = [
1573
1359
  control("proxy_remove_response", {
1574
1360
  ...RequiredRequestIdShape,
1575
1361
  proxyId: IdSchema,
1576
- success: z13.boolean(),
1362
+ success: z11.boolean(),
1577
1363
  ...RequestErrorShape
1578
1364
  }),
1579
1365
  control("relay_client_list_request", RequestIdShape),
1580
1366
  control("relay_client_list_response", {
1581
1367
  ...RequestIdShape,
1582
- clients: z13.array(RelayClientInfoSchema)
1368
+ clients: z11.array(RelayClientInfoSchema)
1583
1369
  }),
1584
1370
  control("relay_client_kick", { ...RequiredRequestIdShape, clientId: IdSchema }),
1585
1371
  control("relay_client_kick_response", {
1586
1372
  ...RequiredRequestIdShape,
1587
1373
  clientId: IdSchema,
1588
- success: z13.boolean(),
1374
+ success: z11.boolean(),
1589
1375
  ...RequestErrorShape
1590
1376
  }),
1591
1377
  control("relay_client_kicked", {
1592
- reason: z13.string().optional()
1378
+ reason: z11.string().optional()
1593
1379
  }),
1594
1380
  control("remote_file_url_request", {
1595
1381
  ...RequiredRequestIdShape,
1596
1382
  sessionId: IdSchema,
1597
- path: z13.string().min(1),
1383
+ path: z11.string().min(1),
1598
1384
  disposition: RemoteFileDispositionSchema
1599
1385
  }),
1600
1386
  control("remote_file_url_response", {
1601
1387
  ...RequiredRequestIdShape,
1602
1388
  ...RequestErrorShape,
1603
1389
  sessionId: IdSchema,
1604
- path: z13.string().optional(),
1605
- success: z13.boolean(),
1606
- url: z13.string().optional(),
1607
- expiresAt: z13.number().int().nonnegative().optional()
1390
+ path: z11.string().optional(),
1391
+ success: z11.boolean(),
1392
+ url: z11.string().optional(),
1393
+ expiresAt: z11.number().int().nonnegative().optional()
1608
1394
  }),
1609
1395
  control("remote_file_metadata_request", {
1610
1396
  ...RequiredRequestIdShape,
1611
1397
  sessionId: IdSchema,
1612
- path: z13.string().min(1)
1398
+ path: z11.string().min(1)
1613
1399
  }),
1614
1400
  control("remote_file_metadata_response", {
1615
1401
  ...RequiredRequestIdShape,
1616
1402
  ...RequestErrorShape,
1617
1403
  sessionId: IdSchema,
1618
- path: z13.string().optional(),
1619
- success: z13.boolean(),
1620
- mimeType: z13.string().optional(),
1621
- size: z13.number().int().nonnegative().optional(),
1622
- fileName: z13.string().optional()
1404
+ path: z11.string().optional(),
1405
+ success: z11.boolean(),
1406
+ mimeType: z11.string().optional(),
1407
+ size: z11.number().int().nonnegative().optional(),
1408
+ fileName: z11.string().optional()
1623
1409
  }),
1624
1410
  control("remote_file_stream_request", {
1625
1411
  streamId: IdSchema,
1626
1412
  sessionId: IdSchema,
1627
- path: z13.string().min(1),
1413
+ path: z11.string().min(1),
1628
1414
  disposition: RemoteFileDispositionSchema
1629
1415
  }),
1630
1416
  control("remote_file_stream_response", {
1631
1417
  ...RequestErrorShape,
1632
1418
  streamId: IdSchema,
1633
1419
  sessionId: IdSchema,
1634
- success: z13.boolean(),
1635
- path: z13.string().optional(),
1636
- mimeType: z13.string().optional(),
1637
- size: z13.number().int().nonnegative().optional(),
1638
- fileName: z13.string().optional()
1420
+ success: z11.boolean(),
1421
+ path: z11.string().optional(),
1422
+ mimeType: z11.string().optional(),
1423
+ size: z11.number().int().nonnegative().optional(),
1424
+ fileName: z11.string().optional()
1639
1425
  }),
1640
1426
  control("remote_file_stream_complete", {
1641
1427
  ...RequestErrorShape,
1642
1428
  streamId: IdSchema,
1643
- success: z13.boolean()
1429
+ success: z11.boolean()
1644
1430
  }),
1645
1431
  control("remote_file_stream_cancel", {
1646
1432
  streamId: IdSchema
@@ -1649,25 +1435,25 @@ var relayControlDefinitions = [
1649
1435
  ...RequiredRequestIdShape,
1650
1436
  sessionId: IdSchema,
1651
1437
  kind: RemoteFileUploadKindSchema,
1652
- fileName: z13.string().optional(),
1653
- mimeType: z13.string().min(1),
1654
- size: z13.number().int().nonnegative().optional()
1438
+ fileName: z11.string().optional(),
1439
+ mimeType: z11.string().min(1),
1440
+ size: z11.number().int().nonnegative().optional()
1655
1441
  }),
1656
1442
  control("remote_file_upload_url_response", {
1657
1443
  ...RequiredRequestIdShape,
1658
1444
  ...RequestErrorShape,
1659
1445
  sessionId: IdSchema,
1660
- success: z13.boolean(),
1661
- uploadUrl: z13.string().optional(),
1662
- expiresAt: z13.number().int().nonnegative().optional()
1446
+ success: z11.boolean(),
1447
+ uploadUrl: z11.string().optional(),
1448
+ expiresAt: z11.number().int().nonnegative().optional()
1663
1449
  }),
1664
1450
  control("remote_file_upload_stream_request", {
1665
1451
  uploadId: IdSchema,
1666
1452
  sessionId: IdSchema,
1667
1453
  kind: RemoteFileUploadKindSchema,
1668
- fileName: z13.string().optional(),
1669
- mimeType: z13.string().min(1),
1670
- size: z13.number().int().nonnegative().optional()
1454
+ fileName: z11.string().optional(),
1455
+ mimeType: z11.string().min(1),
1456
+ size: z11.number().int().nonnegative().optional()
1671
1457
  }),
1672
1458
  control("remote_file_upload_stream_complete", {
1673
1459
  uploadId: IdSchema
@@ -1679,14 +1465,14 @@ var relayControlDefinitions = [
1679
1465
  ...RequestErrorShape,
1680
1466
  uploadId: IdSchema,
1681
1467
  sessionId: IdSchema,
1682
- success: z13.boolean(),
1683
- path: z13.string().optional()
1468
+ success: z11.boolean(),
1469
+ path: z11.string().optional()
1684
1470
  }),
1685
1471
  control("proxy_select", { ...RequestIdShape, proxyId: IdSchema }),
1686
1472
  controlSchema("proxy_select_response", ProxySelectResponseSchema),
1687
1473
  control("relay_error", {
1688
- code: z13.enum(Object.values(RelayErrorCode)),
1689
- message: z13.string(),
1474
+ code: z11.enum(Object.values(RelayErrorCode)),
1475
+ message: z11.string(),
1690
1476
  // 可选 requestId: relay 把 client 发来 raw 的 requestId 字段透传回来,
1691
1477
  // client 侧 waitForMessage 据此把对应 pending request 立即拒掉而不必等到 timeout。
1692
1478
  requestId: IdSchema.optional()
@@ -1705,7 +1491,7 @@ var relayControlDefinitions = [
1705
1491
  control("voice_config_update_response", {
1706
1492
  ...RequestIdShape,
1707
1493
  ...RequestErrorShape,
1708
- success: z13.boolean(),
1494
+ success: z11.boolean(),
1709
1495
  config: VoiceProviderConfigSchema.optional()
1710
1496
  }),
1711
1497
  control("voice_config_test", {
@@ -1715,15 +1501,15 @@ var relayControlDefinitions = [
1715
1501
  control("voice_config_test_response", {
1716
1502
  ...RequestIdShape,
1717
1503
  ...RequestErrorShape,
1718
- success: z13.boolean(),
1719
- audioBase64: z13.string().optional(),
1720
- audioSampleRate: z13.number().int().positive().optional(),
1721
- audioEncoding: z13.literal("pcm_s16le").optional(),
1722
- transcript: z13.string().optional()
1504
+ success: z11.boolean(),
1505
+ audioBase64: z11.string().optional(),
1506
+ audioSampleRate: z11.number().int().positive().optional(),
1507
+ audioEncoding: z11.literal("pcm_s16le").optional(),
1508
+ transcript: z11.string().optional()
1723
1509
  }),
1724
1510
  control("voice_capabilities_request", {
1725
1511
  ...RequestIdShape,
1726
- region: z13.enum(voiceRegionValues).optional()
1512
+ region: z11.enum(voiceRegionValues).optional()
1727
1513
  }),
1728
1514
  control("voice_capabilities_response", {
1729
1515
  ...RequestIdShape,
@@ -1735,31 +1521,31 @@ var relayControlDefinitions = [
1735
1521
  control("latency_web_relay_ping", RequiredRequestIdShape),
1736
1522
  control("latency_web_relay_pong", {
1737
1523
  ...RequiredRequestIdShape,
1738
- relayNow: z13.number().optional()
1524
+ relayNow: z11.number().optional()
1739
1525
  }),
1740
1526
  control("latency_relay_proxy_request", RequiredRequestIdShape),
1741
1527
  control("latency_relay_proxy_response", {
1742
1528
  ...RequiredRequestIdShape,
1743
- success: z13.boolean(),
1744
- rttMs: z13.number().nonnegative().optional(),
1745
- error: z13.string().optional()
1529
+ success: z11.boolean(),
1530
+ rttMs: z11.number().nonnegative().optional(),
1531
+ error: z11.string().optional()
1746
1532
  }),
1747
1533
  control("latency_relay_proxy_ping", {
1748
1534
  ...RequiredRequestIdShape,
1749
- relayNow: z13.number().optional()
1535
+ relayNow: z11.number().optional()
1750
1536
  }),
1751
1537
  control("latency_relay_proxy_pong", {
1752
1538
  ...RequiredRequestIdShape,
1753
- proxyNow: z13.number().optional()
1539
+ proxyNow: z11.number().optional()
1754
1540
  }),
1755
1541
  control("latency_web_proxy_ping", RequiredRequestIdShape, "client_to_proxy"),
1756
- control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z13.number().optional() }, "proxy_to_client"),
1542
+ control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z11.number().optional() }, "proxy_to_client"),
1757
1543
  // Web preview is independent from Agent/terminal sessions. Relay rewrites requestId and routes
1758
1544
  // every response to the exact requesting WebSocket; only the two push messages are broadcast.
1759
1545
  strictControl("preview_capability_request", {
1760
1546
  ...RequiredRequestIdShape,
1761
1547
  scope: PreviewScopeSchema,
1762
- refreshPath: z13.boolean()
1548
+ refreshPath: z11.boolean()
1763
1549
  }, "client_to_proxy"),
1764
1550
  controlSchema("preview_capability_response", PreviewCapabilityResponseSchema, "proxy_to_client"),
1765
1551
  strictControl("preview_static_inspect_request", {
@@ -1782,8 +1568,8 @@ var relayControlDefinitions = [
1782
1568
  ...RequiredRequestIdShape,
1783
1569
  scope: PreviewScopeSchema,
1784
1570
  epoch: IdSchema,
1785
- revision: z13.number().int().nonnegative(),
1786
- previews: z13.array(PreviewSummarySchema)
1571
+ revision: z11.number().int().nonnegative(),
1572
+ previews: z11.array(PreviewSummarySchema)
1787
1573
  }, "proxy_to_client"),
1788
1574
  strictControl("preview_rename_request", {
1789
1575
  ...RequiredRequestIdShape,
@@ -1809,24 +1595,24 @@ var relayControlDefinitions = [
1809
1595
  controlSchema("preview_close_response", PreviewCloseResponseSchema, "proxy_to_client"),
1810
1596
  control("preview_state_event", {
1811
1597
  epoch: IdSchema,
1812
- revision: z13.number().int().nonnegative(),
1598
+ revision: z11.number().int().nonnegative(),
1813
1599
  preview: PreviewSummarySchema
1814
1600
  }),
1815
1601
  control("preview_removed_event", {
1816
1602
  epoch: IdSchema,
1817
- revision: z13.number().int().nonnegative(),
1603
+ revision: z11.number().int().nonnegative(),
1818
1604
  previewId: IdSchema
1819
1605
  }),
1820
1606
  control("preview_state_push", {
1821
1607
  scope: PreviewScopeSchema,
1822
1608
  epoch: IdSchema,
1823
- revision: z13.number().int().nonnegative(),
1609
+ revision: z11.number().int().nonnegative(),
1824
1610
  preview: PreviewSummarySchema
1825
1611
  }, "proxy_to_client"),
1826
1612
  control("preview_removed_push", {
1827
1613
  scope: PreviewScopeSchema,
1828
1614
  epoch: IdSchema,
1829
- revision: z13.number().int().nonnegative(),
1615
+ revision: z11.number().int().nonnegative(),
1830
1616
  previewId: IdSchema
1831
1617
  }, "proxy_to_client"),
1832
1618
  // Device previews are a sibling of Web previews under the product-level Preview entry, but
@@ -1835,13 +1621,13 @@ var relayControlDefinitions = [
1835
1621
  strictControl("device_preview_capability_request", {
1836
1622
  ...RequiredRequestIdShape,
1837
1623
  scope: PreviewScopeSchema,
1838
- refreshPath: z13.boolean()
1624
+ refreshPath: z11.boolean()
1839
1625
  }, "client_to_proxy"),
1840
1626
  controlSchema("device_preview_capability_response", DevicePreviewCapabilityResponseSchema, "proxy_to_client"),
1841
1627
  strictControl("device_preview_targets_request", {
1842
1628
  ...RequiredRequestIdShape,
1843
1629
  scope: PreviewScopeSchema,
1844
- refresh: z13.boolean()
1630
+ refresh: z11.boolean()
1845
1631
  }, "client_to_proxy"),
1846
1632
  controlSchema("device_preview_targets_response", DevicePreviewTargetsResponseSchema, "proxy_to_client"),
1847
1633
  strictControl("device_preview_create_request", {
@@ -1857,8 +1643,8 @@ var relayControlDefinitions = [
1857
1643
  ...RequiredRequestIdShape,
1858
1644
  scope: PreviewScopeSchema,
1859
1645
  epoch: IdSchema,
1860
- revision: z13.number().int().nonnegative(),
1861
- previews: z13.array(DevicePreviewSummarySchema).max(1024)
1646
+ revision: z11.number().int().nonnegative(),
1647
+ previews: z11.array(DevicePreviewSummarySchema).max(1024)
1862
1648
  }, "proxy_to_client"),
1863
1649
  strictControl("device_preview_rename_request", {
1864
1650
  ...RequiredRequestIdShape,
@@ -1884,24 +1670,24 @@ var relayControlDefinitions = [
1884
1670
  controlSchema("device_preview_close_response", DevicePreviewCloseResponseSchema, "proxy_to_client"),
1885
1671
  control("device_preview_state_event", {
1886
1672
  epoch: IdSchema,
1887
- revision: z13.number().int().nonnegative(),
1673
+ revision: z11.number().int().nonnegative(),
1888
1674
  preview: DevicePreviewSummarySchema
1889
1675
  }),
1890
1676
  control("device_preview_removed_event", {
1891
1677
  epoch: IdSchema,
1892
- revision: z13.number().int().nonnegative(),
1678
+ revision: z11.number().int().nonnegative(),
1893
1679
  previewId: IdSchema
1894
1680
  }),
1895
1681
  control("device_preview_state_push", {
1896
1682
  scope: PreviewScopeSchema,
1897
1683
  epoch: IdSchema,
1898
- revision: z13.number().int().nonnegative(),
1684
+ revision: z11.number().int().nonnegative(),
1899
1685
  preview: DevicePreviewSummarySchema
1900
1686
  }, "proxy_to_client"),
1901
1687
  control("device_preview_removed_push", {
1902
1688
  scope: PreviewScopeSchema,
1903
1689
  epoch: IdSchema,
1904
- revision: z13.number().int().nonnegative(),
1690
+ revision: z11.number().int().nonnegative(),
1905
1691
  previewId: IdSchema
1906
1692
  }, "proxy_to_client"),
1907
1693
  strictControl("device_preview_stream_url_request", {
@@ -1921,7 +1707,7 @@ var relayControlDefinitions = [
1921
1707
  strictControl("device_preview_input", {
1922
1708
  scope: PreviewScopeSchema,
1923
1709
  leaseId: IdSchema,
1924
- inputSeq: z13.number().int().min(0).max(4294967295),
1710
+ inputSeq: z11.number().int().min(0).max(4294967295),
1925
1711
  input: DevicePreviewInputSchema
1926
1712
  }, "client_to_proxy"),
1927
1713
  controlSchema("device_preview_input_ack", DevicePreviewInputAckSchema, "proxy_to_client"),
@@ -1929,7 +1715,7 @@ var relayControlDefinitions = [
1929
1715
  // browsers cannot abort another viewer's queued input, and Proxy never sends it to browsers.
1930
1716
  strictControl("device_preview_input_revoke", {
1931
1717
  leaseId: IdSchema,
1932
- reason: z13.literal("control_taken_over")
1718
+ reason: z11.literal("control_taken_over")
1933
1719
  }),
1934
1720
  strictControl("device_preview_control_claim_request", {
1935
1721
  ...RequiredRequestIdShape,
@@ -1940,18 +1726,18 @@ var relayControlDefinitions = [
1940
1726
  control("device_preview_control_revoked_push", {
1941
1727
  scope: PreviewScopeSchema,
1942
1728
  leaseId: IdSchema,
1943
- reason: z13.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
1729
+ reason: z11.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
1944
1730
  }),
1945
1731
  // 客户端注册协议
1946
1732
  control("client_register", {
1947
- protocolVersion: z13.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1733
+ protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
1948
1734
  clientId: IdSchema,
1949
- userAgent: z13.string().optional(),
1950
- platform: z13.string().optional(),
1951
- maxTouchPoints: z13.number().int().nonnegative().optional(),
1952
- browserName: z13.string().min(1),
1953
- osName: z13.string().min(1),
1954
- deviceKind: z13.enum(["desktop", "tablet", "phone", "unknown"])
1735
+ userAgent: z11.string().optional(),
1736
+ platform: z11.string().optional(),
1737
+ maxTouchPoints: z11.number().int().nonnegative().optional(),
1738
+ browserName: z11.string().min(1),
1739
+ osName: z11.string().min(1),
1740
+ deviceKind: z11.enum(["desktop", "tablet", "phone", "unknown"])
1955
1741
  }),
1956
1742
  controlSchema("client_register_response", ClientRegisterResponseSchema),
1957
1743
  // Proxy 离线通知
@@ -1973,38 +1759,38 @@ var relayControlDefinitions = [
1973
1759
  // 目录列表请求与响应
1974
1760
  strictControl("dir_list_request", {
1975
1761
  ...RequestIdShape,
1976
- path: z13.string(),
1977
- includeHidden: z13.boolean()
1762
+ path: z11.string(),
1763
+ includeHidden: z11.boolean()
1978
1764
  }, "client_to_proxy"),
1979
1765
  control("dir_list_response", {
1980
1766
  ...RequestIdShape,
1981
1767
  ...RequestErrorShape,
1982
- entries: z13.array(DirEntrySchema),
1983
- path: z13.string(),
1984
- includeHidden: z13.boolean()
1768
+ entries: z11.array(DirEntrySchema),
1769
+ path: z11.string(),
1770
+ includeHidden: z11.boolean()
1985
1771
  }, "proxy_to_client"),
1986
1772
  // 目录创建请求与响应
1987
- control("dir_create_request", { ...RequestIdShape, path: z13.string() }, "client_to_proxy"),
1773
+ control("dir_create_request", { ...RequestIdShape, path: z11.string() }, "client_to_proxy"),
1988
1774
  control("dir_create_response", {
1989
1775
  ...RequestIdShape,
1990
1776
  ...RequestErrorShape,
1991
- path: z13.string(),
1992
- success: z13.boolean()
1777
+ path: z11.string(),
1778
+ success: z11.boolean()
1993
1779
  }, "proxy_to_client"),
1994
1780
  // 命令列表推送,proxy 将可用命令列表推给 client
1995
1781
  control("command_list_push", {
1996
1782
  sessionId: IdSchema,
1997
- commands: z13.array(CommandEntrySchema)
1783
+ commands: z11.array(CommandEntrySchema)
1998
1784
  }, "proxy_to_client"),
1999
1785
  // 文件树推送: 按目录分组, 首组 path 即为 session cwd。
2000
1786
  // 前端把它写入普通目录树;includeHidden=true 的按需响应使用独立缓存。
2001
1787
  control("file_tree_push", {
2002
- groups: z13.array(FileTreeGroupSchema)
1788
+ groups: z11.array(FileTreeGroupSchema)
2003
1789
  }, "proxy_to_client"),
2004
1790
  // 会话列表请求与权限模式变更
2005
1791
  strictControl("session_list_request", {}, "client_to_proxy"),
2006
1792
  control("permission_mode_change", {
2007
- mode: z13.enum(["default", "auto_accept", "plan"]),
1793
+ mode: z11.enum(["default", "auto_accept", "plan"]),
2008
1794
  // sessionId 可选:传入时 proxy 按该会话的 mode 分叉(PTY 发 Tab ANSI),未传走全局日志行为
2009
1795
  sessionId: IdSchema.optional()
2010
1796
  }, "client_to_proxy"),
@@ -2013,33 +1799,33 @@ var relayControlDefinitions = [
2013
1799
  control("session_history_response", {
2014
1800
  ...RequiredRequestIdShape,
2015
1801
  ...RequestErrorShape,
2016
- success: z13.boolean(),
2017
- sessions: z13.array(HistorySessionSchema)
1802
+ success: z11.boolean(),
1803
+ sessions: z11.array(HistorySessionSchema)
2018
1804
  }, "proxy_to_client"),
2019
1805
  // PTY 语义状态,从 Envelope 迁移到 Control 层
2020
1806
  control("pty_state", { sessionId: IdSchema, payload: PtyStatePayloadSchema }, "proxy_to_client"),
2021
1807
  // Provider 语义状态,来自 Claude/Codex hook 等结构化事件,不从 PTY 字节推断
2022
1808
  control("agent_status", { sessionId: IdSchema, payload: AgentStatusPayloadSchema }, "proxy_to_client"),
2023
1809
  // 终端标题变化,proxy -> client
2024
- control("terminal_title", { sessionId: IdSchema, title: z13.string() }, "proxy_to_client"),
1810
+ control("terminal_title", { sessionId: IdSchema, title: z11.string() }, "proxy_to_client"),
2025
1811
  // 终端尺寸变化,proxy -> client
2026
1812
  control("terminal_resize", {
2027
1813
  sessionId: IdSchema,
2028
- cols: z13.number().int().positive(),
2029
- rows: z13.number().int().positive(),
1814
+ cols: z11.number().int().positive(),
1815
+ rows: z11.number().int().positive(),
2030
1816
  // PTY output and resize events share one ordered render sequence. The client can therefore
2031
1817
  // place a resize between the exact byte frames that preceded and followed it.
2032
- outputSeq: z13.number().int().nonnegative()
1818
+ outputSeq: z11.number().int().nonnegative()
2033
1819
  }, "proxy_to_client"),
2034
- control("terminal_resize_request", { sessionId: IdSchema, cols: z13.number().int().positive(), rows: z13.number().int().positive() }, "client_to_proxy"),
1820
+ control("terminal_resize_request", { sessionId: IdSchema, cols: z11.number().int().positive(), rows: z11.number().int().positive() }, "client_to_proxy"),
2035
1821
  // 远程终止 JSON 会话,client -> proxy
2036
1822
  strictControl("session_terminate", { sessionId: IdSchema }, "client_to_proxy"),
2037
- control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z13.string() }, "client_to_proxy"),
1823
+ control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z11.string() }, "client_to_proxy"),
2038
1824
  control("session_rename_response", {
2039
1825
  ...RequestIdShape,
2040
1826
  sessionId: IdSchema,
2041
- success: z13.boolean(),
2042
- name: z13.string().optional(),
1827
+ success: z11.boolean(),
1828
+ name: z11.string().optional(),
2043
1829
  ...RequestErrorShape
2044
1830
  }, "proxy_to_client"),
2045
1831
  // 中断当前 turn,client -> proxy;JSON 由 session-worker 打断 Claude 子进程并保留会话。
@@ -2047,22 +1833,22 @@ var relayControlDefinitions = [
2047
1833
  // turn 完成信号,proxy -> client,对应 claude stream-json 的 result 事件
2048
1834
  control("turn_result", {
2049
1835
  sessionId: IdSchema,
2050
- success: z13.boolean(),
2051
- isError: z13.boolean(),
1836
+ success: z11.boolean(),
1837
+ isError: z11.boolean(),
2052
1838
  // stream-json result.result 是本轮最终文本。assistant_message 流丢失或 CLI 未发增量时,
2053
1839
  // Web 用它作为 JSON 模式兜底展示,避免 turn 已结束但界面空白。
2054
- result: z13.string().optional()
1840
+ result: z11.string().optional()
2055
1841
  }, "proxy_to_client"),
2056
1842
  // 客户端发送到 PTY 的原始字节(ANSI 序列),不追加换行
2057
- control("remote_input_raw", { sessionId: IdSchema, data: z13.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
1843
+ control("remote_input_raw", { sessionId: IdSchema, data: z11.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
2058
1844
  // 客户端询问 proxy 的环境信息 (home 路径等), client -> proxy -> response
2059
1845
  // FilePathPicker 用 homePath 作为 select 模式下的默认起点, 新建会话时打开即可浏览
2060
1846
  controlSchema("proxy_info_request", ProxyInfoRequestSchema, "client_to_proxy"),
2061
1847
  controlSchema("proxy_info", ProxyInfoResponseSchema, "proxy_to_client"),
2062
- control("agent_cli_config_update", { ...RequestIdShape, provider: z13.enum(providerValues), path: z13.string().min(1) }, "client_to_proxy"),
1848
+ control("agent_cli_config_update", { ...RequestIdShape, provider: z11.enum(providerValues), path: z11.string().min(1) }, "client_to_proxy"),
2063
1849
  control("agent_cli_config_update_response", {
2064
1850
  ...RequestIdShape,
2065
- provider: z13.enum(providerValues),
1851
+ provider: z11.enum(providerValues),
2066
1852
  agentCli: AgentCliStatusSchema.optional(),
2067
1853
  ...RequestErrorShape
2068
1854
  }, "proxy_to_client"),
@@ -2074,16 +1860,16 @@ var relayControlDefinitions = [
2074
1860
  // 非零退出。把可识别的运行时错误结构化推给 Web,避免关键错误只留在终端闪屏里。
2075
1861
  control("session_runtime_error", {
2076
1862
  sessionId: IdSchema,
2077
- error: z13.string(),
1863
+ error: z11.string(),
2078
1864
  errorCode: ControlErrorCodeSchema,
2079
- activeWriterPid: z13.number().int().positive().optional()
1865
+ activeWriterPid: z11.number().int().positive().optional()
2080
1866
  }, "proxy_to_client"),
2081
1867
  // 客户端请求会话历史消息,client -> proxy
2082
1868
  control("session_messages_request", {
2083
1869
  ...RequestIdShape,
2084
1870
  sessionId: IdSchema,
2085
- limit: z13.number().int().min(1).max(200).optional(),
2086
- before: z13.string().optional()
1871
+ limit: z11.number().int().min(1).max(200).optional(),
1872
+ before: z11.string().optional()
2087
1873
  }, "client_to_proxy"),
2088
1874
  // 客户端请求会话资源(命令列表 + 文件树),client -> proxy
2089
1875
  control("session_resources_request", { ...RequiredRequestIdShape, sessionId: IdSchema }, "client_to_proxy"),
@@ -2091,14 +1877,14 @@ var relayControlDefinitions = [
2091
1877
  ...RequiredRequestIdShape,
2092
1878
  ...RequestErrorShape,
2093
1879
  sessionId: IdSchema,
2094
- commands: z13.array(CommandEntrySchema),
2095
- groups: z13.array(FileTreeGroupSchema)
1880
+ commands: z11.array(CommandEntrySchema),
1881
+ groups: z11.array(FileTreeGroupSchema)
2096
1882
  }, "proxy_to_client"),
2097
1883
  // 客户端请求当前 provider 语义状态;不经 relay 缓存,由 proxy 返回当前值
2098
1884
  control("agent_status_request", { ...RequestIdShape, sessionId: IdSchema.optional() }, "client_to_proxy"),
2099
1885
  control("agent_status_response", {
2100
1886
  ...RequestIdShape,
2101
- statuses: z13.array(z13.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
1887
+ statuses: z11.array(z11.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
2102
1888
  }, "proxy_to_client"),
2103
1889
  // 客户端确认已收到审批请求;proxy 只记录送达状态,不把它当成用户决策
2104
1890
  control("permission_request_delivered", { sessionId: IdSchema, requestId: IdSchema }, "client_to_proxy"),
@@ -2108,18 +1894,18 @@ var relayControlDefinitions = [
2108
1894
  control("permission_decision_result", {
2109
1895
  sessionId: IdSchema,
2110
1896
  requestId: IdSchema,
2111
- outcome: z13.enum(["allow", "deny"]),
2112
- delivered: z13.boolean(),
2113
- message: z13.string().optional()
1897
+ outcome: z11.enum(["allow", "deny"]),
1898
+ delivered: z11.boolean(),
1899
+ message: z11.string().optional()
2114
1900
  }, "proxy_to_client"),
2115
1901
  // proxy 推送当前 pending 的工具审批列表,client 据此恢复审批卡片
2116
1902
  control("pending_approvals_push", {
2117
1903
  sessionId: IdSchema,
2118
- approvals: z13.array(z13.object({
1904
+ approvals: z11.array(z11.object({
2119
1905
  requestId: IdSchema,
2120
- toolName: z13.string(),
2121
- input: z13.record(z13.string(), z13.unknown()),
2122
- options: z13.array(ApprovalOptionSchema).optional()
1906
+ toolName: z11.string(),
1907
+ input: z11.record(z11.string(), z11.unknown()),
1908
+ options: z11.array(ApprovalOptionSchema).optional()
2123
1909
  }))
2124
1910
  }, "proxy_to_client"),
2125
1911
  // Voice Pilot speech summaries are produced by proxy-side Claude Code so it can read project context.
@@ -2127,7 +1913,7 @@ var relayControlDefinitions = [
2127
1913
  ...RequestIdShape,
2128
1914
  sessionId: IdSchema,
2129
1915
  messageId: IdSchema,
2130
- text: z13.string().min(1),
1916
+ text: z11.string().min(1),
2131
1917
  reason: VoiceSummaryReasonSchema
2132
1918
  }, "client_to_proxy"),
2133
1919
  control("voice_summary_response", {
@@ -2135,27 +1921,27 @@ var relayControlDefinitions = [
2135
1921
  ...RequestErrorShape,
2136
1922
  sessionId: IdSchema,
2137
1923
  messageId: IdSchema,
2138
- success: z13.boolean(),
2139
- summary: z13.string().min(1).optional()
1924
+ success: z11.boolean(),
1925
+ summary: z11.string().min(1).optional()
2140
1926
  }, "proxy_to_client"),
2141
1927
  // 恢复会话时推送历史消息,proxy -> client
2142
1928
  control("session_history_messages", {
2143
1929
  ...RequestIdShape,
2144
1930
  sessionId: IdSchema,
2145
- before: z13.string().optional(),
2146
- messages: z13.array(SessionHistoryMessageSchema),
2147
- hasMore: z13.boolean().optional(),
2148
- nextBefore: z13.string().optional()
1931
+ before: z11.string().optional(),
1932
+ messages: z11.array(SessionHistoryMessageSchema),
1933
+ hasMore: z11.boolean().optional(),
1934
+ nextBefore: z11.string().optional()
2149
1935
  }, "proxy_to_client"),
2150
1936
  // proxy 重连后同步活跃 session 列表给 relay。session_sync 由 relay 自消费(更新 proxy-session
2151
1937
  // 关联)不转发给 client,因此**没有** direction 标注——RelayControlDirection 只描述转发流。
2152
1938
  control("session_sync", {
2153
- sessions: z13.array(createSessionIdentitySchema({
2154
- id: z13.string(),
2155
- cwd: z13.string(),
2156
- name: z13.string().optional(),
2157
- nameLocked: z13.boolean().optional(),
2158
- state: z13.enum(sessionStateValues)
1939
+ sessions: z11.array(createSessionIdentitySchema({
1940
+ id: z11.string(),
1941
+ cwd: z11.string(),
1942
+ name: z11.string().optional(),
1943
+ nameLocked: z11.boolean().optional(),
1944
+ state: z11.enum(sessionStateValues)
2159
1945
  }))
2160
1946
  }),
2161
1947
  // PTY 会话订阅,client -> proxy,触发 terminal serialize() 返回当前状态
@@ -2163,18 +1949,234 @@ var relayControlDefinitions = [
2163
1949
  // PTY 会话快照,proxy -> client,serialize() 的全量终端状态
2164
1950
  control("session_snapshot", {
2165
1951
  sessionId: IdSchema,
2166
- cols: z13.number().int().positive(),
2167
- rows: z13.number().int().positive(),
2168
- data: z13.string(),
2169
- outputSeq: z13.number().int().nonnegative(),
1952
+ cols: z11.number().int().positive(),
1953
+ rows: z11.number().int().positive(),
1954
+ data: z11.string(),
1955
+ outputSeq: z11.number().int().nonnegative(),
2170
1956
  requestId: IdSchema
2171
1957
  }, "proxy_to_client")
2172
1958
  ];
2173
1959
  var relayControlSchemas = relayControlDefinitions.map((definition) => definition.schema);
2174
- var RelayControlSchema = z13.discriminatedUnion("type", relayControlSchemas);
1960
+ var RelayControlSchema = z11.discriminatedUnion("type", relayControlSchemas);
2175
1961
  var ProxyToClientRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("proxy_to_client")).map((definition) => definition.type));
2176
1962
  var ClientToProxyRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("client_to_proxy")).map((definition) => definition.type));
2177
1963
 
1964
+ // ../../packages/shared/dist/state-machine.js
1965
+ function computeAbsorbingSet(transitions) {
1966
+ const absorbing = /* @__PURE__ */ new Set();
1967
+ const entries = Object.entries(transitions);
1968
+ for (const [s, outs] of entries) {
1969
+ if (outs.length === 0)
1970
+ absorbing.add(s);
1971
+ }
1972
+ let changed = true;
1973
+ while (changed) {
1974
+ changed = false;
1975
+ for (const [s, outs] of entries) {
1976
+ if (absorbing.has(s))
1977
+ continue;
1978
+ if (outs.length > 0 && outs.every((t) => absorbing.has(t))) {
1979
+ absorbing.add(s);
1980
+ changed = true;
1981
+ }
1982
+ }
1983
+ }
1984
+ return absorbing;
1985
+ }
1986
+ function createFSM(def) {
1987
+ let state = def.initial;
1988
+ const absorbing = computeAbsorbingSet(def.transitions);
1989
+ const tryTransitionTo = (to) => {
1990
+ const allowed = def.transitions[state];
1991
+ if (!allowed?.includes(to)) {
1992
+ def.onRejected?.(state, to, absorbing.has(state));
1993
+ return false;
1994
+ }
1995
+ const from = state;
1996
+ state = to;
1997
+ def.onTransition?.(from, to);
1998
+ return true;
1999
+ };
2000
+ return {
2001
+ current: () => state,
2002
+ is: (s) => state === s,
2003
+ isIn: (ss) => ss.includes(state),
2004
+ canTransitionTo: (to) => def.transitions[state]?.includes(to) ?? false,
2005
+ transitionTo: (to) => {
2006
+ if (!tryTransitionTo(to)) {
2007
+ throw new Error(`Invalid FSM transition: ${state} -> ${to}`);
2008
+ }
2009
+ },
2010
+ tryTransitionTo,
2011
+ isInAbsorbingState: () => absorbing.has(state)
2012
+ };
2013
+ }
2014
+ function defineFSM(transitions) {
2015
+ const absorbing = computeAbsorbingSet(transitions);
2016
+ return {
2017
+ canTransition: (from, to) => transitions[from]?.includes(to) ?? false,
2018
+ isAbsorbing: (state) => absorbing.has(state)
2019
+ };
2020
+ }
2021
+
2022
+ // ../../packages/shared/dist/schemas/proxy-upgrade-bootstrap.js
2023
+ import { z as z12 } from "zod";
2024
+ var PROXY_UPGRADE_BOOTSTRAP_VERSION = 1;
2025
+ var StableVersionSchema = z12.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
2026
+ var ProxyUpgradeBootstrapResponseSchema = z12.object({
2027
+ bootstrapVersion: z12.literal(PROXY_UPGRADE_BOOTSTRAP_VERSION),
2028
+ relayVersion: StableVersionSchema,
2029
+ controlProtocolVersion: z12.number().int().positive()
2030
+ });
2031
+
2032
+ // ../../packages/shared/dist/schemas/voice-stream.js
2033
+ import { z as z13 } from "zod";
2034
+ var VoiceAsrAudioEncodingSchema = z13.enum(["pcm_s16le", "mulaw"]);
2035
+ var VoiceAsrStartMessageSchema = z13.object({
2036
+ type: z13.literal("start"),
2037
+ sessionId: z13.string().min(1),
2038
+ attemptId: z13.string().min(1),
2039
+ sampleRate: z13.number().int().positive(),
2040
+ encoding: VoiceAsrAudioEncodingSchema
2041
+ });
2042
+ var VoiceAsrStopMessageSchema = z13.object({
2043
+ type: z13.literal("stop"),
2044
+ attemptId: z13.string().min(1)
2045
+ });
2046
+ var VoiceAsrClientMessageSchema = z13.discriminatedUnion("type", [
2047
+ VoiceAsrStartMessageSchema,
2048
+ VoiceAsrStopMessageSchema
2049
+ ]);
2050
+ var VoiceAsrServerMessageSchema = z13.discriminatedUnion("type", [
2051
+ z13.object({ type: z13.literal("ready"), attemptId: z13.string().min(1) }),
2052
+ z13.object({
2053
+ type: z13.literal("audio_ack"),
2054
+ attemptId: z13.string().min(1),
2055
+ encodedBytes: z13.number().int().nonnegative(),
2056
+ pcmBytes: z13.number().int().nonnegative(),
2057
+ chunks: z13.number().int().nonnegative()
2058
+ }),
2059
+ z13.object({ type: z13.literal("partial"), attemptId: z13.string().min(1), text: z13.string() }),
2060
+ z13.object({ type: z13.literal("final"), attemptId: z13.string().min(1), text: z13.string() }),
2061
+ z13.object({
2062
+ type: z13.literal("closed"),
2063
+ attemptId: z13.string().min(1),
2064
+ code: z13.number().int().optional(),
2065
+ reason: z13.string().optional()
2066
+ }),
2067
+ z13.object({
2068
+ type: z13.literal("error"),
2069
+ attemptId: z13.string().min(1),
2070
+ error: z13.string().optional(),
2071
+ errorCode: z13.string().optional()
2072
+ })
2073
+ ]);
2074
+
2075
+ // ../../packages/shared/dist/slash-commands.js
2076
+ function isCompactCommandText(text) {
2077
+ return /^\/compact(?:\s|$)/.test(text.trimStart());
2078
+ }
2079
+
2080
+ // ../../packages/shared/dist/tool-activity-summary.js
2081
+ var SECRET_VALUE_PATTERN = /((?:authorization|api[_-]?key|token|password|secret)\s*[:=]\s*)(?:bearer\s+)?[^\s'"]+/giu;
2082
+ var SECRET_FLAG_PATTERN = /(--(?:api-key|token|password|secret)(?:=|\s+))[^\s'"]+/giu;
2083
+ function asString(value) {
2084
+ return typeof value === "string" ? value : "";
2085
+ }
2086
+ function compact(value, max = 140) {
2087
+ const text = value.replace(/\s+/gu, " ").trim();
2088
+ if (text.length <= max)
2089
+ return text;
2090
+ return `${text.slice(0, max - 1)}\u2026`;
2091
+ }
2092
+ function redact(value) {
2093
+ return value.replace(SECRET_VALUE_PATTERN, "$1[redacted]").replace(SECRET_FLAG_PATTERN, "$1[redacted]");
2094
+ }
2095
+ function filePath(input) {
2096
+ return asString(input.file_path) || asString(input.path) || asString(input.notebook_path);
2097
+ }
2098
+ function summarizeToolActivity(toolName, input) {
2099
+ switch (toolName) {
2100
+ case "Bash": {
2101
+ const command = compact(redact(asString(input.command)));
2102
+ return command ? `\u8FD0\u884C\u547D\u4EE4\uFF1A${command}` : "\u8FD0\u884C\u547D\u4EE4";
2103
+ }
2104
+ case "BashBatch": {
2105
+ const commands = Array.isArray(input.commands) ? input.commands.filter((item) => typeof item === "string") : [];
2106
+ return commands.length > 0 ? `\u6279\u91CF\u8FD0\u884C\u547D\u4EE4\uFF1A${commands.length} \u6761` : "\u6279\u91CF\u8FD0\u884C\u547D\u4EE4";
2107
+ }
2108
+ case "ProcessWait":
2109
+ return "\u7B49\u5F85\u547D\u4EE4\u5B8C\u6210";
2110
+ case "ProcessInput": {
2111
+ const value = compact(redact(asString(input.input)), 80);
2112
+ return value ? `\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165\uFF1A${value}` : "\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165";
2113
+ }
2114
+ case "Read": {
2115
+ const path = filePath(input);
2116
+ return path ? `\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}` : "\u8BFB\u53D6\u6587\u4EF6";
2117
+ }
2118
+ case "Write": {
2119
+ const path = filePath(input);
2120
+ return path ? `\u5199\u5165\u6587\u4EF6\uFF1A${path}` : "\u5199\u5165\u6587\u4EF6";
2121
+ }
2122
+ case "Edit":
2123
+ case "MultiEdit": {
2124
+ const path = filePath(input);
2125
+ return path ? `\u7F16\u8F91\u6587\u4EF6\uFF1A${path}` : "\u7F16\u8F91\u6587\u4EF6";
2126
+ }
2127
+ case "LS": {
2128
+ const path = filePath(input);
2129
+ return path ? `\u5217\u51FA\u76EE\u5F55\uFF1A${path}` : "\u5217\u51FA\u76EE\u5F55";
2130
+ }
2131
+ case "Grep": {
2132
+ const pattern = compact(redact(asString(input.pattern)), 80);
2133
+ const path = filePath(input);
2134
+ if (pattern && path)
2135
+ return `\u641C\u7D22\uFF1A${pattern} in ${path}`;
2136
+ return pattern ? `\u641C\u7D22\uFF1A${pattern}` : "\u641C\u7D22\u6587\u672C";
2137
+ }
2138
+ case "Glob": {
2139
+ const pattern = compact(redact(asString(input.pattern)), 80);
2140
+ return pattern ? `\u67E5\u627E\u6587\u4EF6\uFF1A${pattern}` : "\u67E5\u627E\u6587\u4EF6";
2141
+ }
2142
+ case "WebFetch": {
2143
+ const url = compact(redact(asString(input.url)), 100);
2144
+ return url ? `\u8BFB\u53D6\u7F51\u9875\uFF1A${url}` : "\u8BFB\u53D6\u7F51\u9875";
2145
+ }
2146
+ case "WebSearch": {
2147
+ const query = compact(redact(asString(input.query)), 100);
2148
+ return query ? `\u7F51\u9875\u641C\u7D22\uFF1A${query}` : "\u7F51\u9875\u641C\u7D22";
2149
+ }
2150
+ case "ViewImage": {
2151
+ const path = filePath(input);
2152
+ return path ? `\u67E5\u770B\u56FE\u7247\uFF1A${path}` : "\u67E5\u770B\u56FE\u7247";
2153
+ }
2154
+ case "ViewImageBatch": {
2155
+ const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
2156
+ return paths.length > 0 ? `\u6279\u91CF\u67E5\u770B\u56FE\u7247\uFF1A${paths.length} \u5F20` : "\u6279\u91CF\u67E5\u770B\u56FE\u7247";
2157
+ }
2158
+ case "Web":
2159
+ return "\u8BBF\u95EE\u7F51\u9875";
2160
+ case "ToolScript":
2161
+ return "\u6267\u884C\u5DE5\u5177\u7F16\u6392";
2162
+ case "TodoWrite":
2163
+ return "\u66F4\u65B0\u4EFB\u52A1\u5217\u8868";
2164
+ case "Patch": {
2165
+ const path = filePath(input);
2166
+ if (path)
2167
+ return `\u5E94\u7528\u8865\u4E01\uFF1A${path}`;
2168
+ const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
2169
+ if (paths.length === 1)
2170
+ return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]}`;
2171
+ if (paths.length > 1)
2172
+ return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]} \u7B49 ${paths.length} \u4E2A\u6587\u4EF6`;
2173
+ return "\u5E94\u7528\u8865\u4E01";
2174
+ }
2175
+ default:
2176
+ return `\u4F7F\u7528\u5DE5\u5177\uFF1A${toolName}`;
2177
+ }
2178
+ }
2179
+
2178
2180
  // ../../packages/shared/dist/constants/session.js
2179
2181
  var SessionState = {
2180
2182
  IDLE: "idle",
@@ -2395,9 +2397,6 @@ function encodeDevicePreviewH264ProxyPacket(streamId, packet) {
2395
2397
  return encoded;
2396
2398
  }
2397
2399
 
2398
- // src/ipc/ipc-protocol.ts
2399
- import { z as z14 } from "zod";
2400
-
2401
2400
  // src/ipc/line-buffer.ts
2402
2401
  import { Transform } from "stream";
2403
2402
  import { StringDecoder } from "string_decoder";
@@ -2426,364 +2425,11 @@ var LineBuffer = class extends Transform {
2426
2425
  }
2427
2426
  };
2428
2427
 
2429
- // src/ipc/ipc-protocol.ts
2430
- var IPC_BINARY_MARKER = 0;
2431
- var WORKER_IPC_PROTOCOL_VERSION = 1;
2432
- var TERMINAL_IPC_PROTOCOL_VERSION = 2;
2433
- function encodeBinaryIpcFrame(sessionId, data, outputSeq) {
2434
- const inner = encodeBinaryFrame(sessionId, outputSeq, data);
2435
- const frame = Buffer.alloc(1 + 4 + inner.length);
2436
- frame[0] = IPC_BINARY_MARKER;
2437
- frame.writeUInt32LE(inner.length, 1);
2438
- frame.set(inner, 5);
2439
- return frame;
2440
- }
2441
- var ProviderHookContextSchema = z14.object({
2442
- provider: z14.enum(["claude", "codex"]),
2443
- sessionId: z14.string(),
2444
- hookUrl: z14.string(),
2445
- marker: z14.string(),
2446
- token: z14.string()
2447
- }).strict();
2448
- var terminalSessionCreateFields = {
2449
- type: z14.literal("session_create_request"),
2450
- name: z14.string().optional(),
2451
- mode: z14.literal("pty"),
2452
- cwd: z14.string().min(1),
2453
- pid: z14.number().int().positive().max(Number.MAX_SAFE_INTEGER),
2454
- protocolVersion: z14.literal(TERMINAL_IPC_PROTOCOL_VERSION),
2455
- sessionId: z14.string().min(1).optional()
2456
- };
2457
- var TerminalSessionCreateRequestSchema = z14.discriminatedUnion("kind", [
2458
- z14.object({
2459
- ...terminalSessionCreateFields,
2460
- kind: z14.literal("agent"),
2461
- provider: z14.enum(providerValues)
2462
- }).strict(),
2463
- z14.object({
2464
- ...terminalSessionCreateFields,
2465
- kind: z14.literal("terminal"),
2466
- provider: z14.literal("claude")
2467
- }).strict()
2468
- ]);
2469
- var TerminalSessionCreateResponseSchema = z14.discriminatedUnion("success", [
2470
- // Responses may add descriptive fields within the same protocol generation. Validate known
2471
- // fields and discard extensions, while rejecting fields that contradict the success branch.
2472
- z14.object({
2473
- type: z14.literal("session_create_response"),
2474
- success: z14.literal(true),
2475
- sessionId: z14.string().min(1),
2476
- protocolVersion: z14.literal(TERMINAL_IPC_PROTOCOL_VERSION),
2477
- hook: ProviderHookContextSchema.optional(),
2478
- error: z14.never().optional()
2479
- }),
2480
- z14.object({
2481
- type: z14.literal("session_create_response"),
2482
- success: z14.literal(false),
2483
- protocolVersion: z14.literal(TERMINAL_IPC_PROTOCOL_VERSION),
2484
- error: z14.string().min(1),
2485
- sessionId: z14.never().optional(),
2486
- hook: z14.never().optional()
2487
- })
2488
- ]);
2489
- var IpcMessageSchema = z14.discriminatedUnion("type", [
2490
- // 客户端请求创建新会话,sessionId 可选用于重连时复用
2491
- TerminalSessionCreateRequestSchema,
2492
- // 服务端响应创建会话
2493
- TerminalSessionCreateResponseSchema,
2494
- // 客户端向服务端注册 PTY 会话
2495
- z14.object({
2496
- type: z14.literal("pty_register"),
2497
- sessionId: z14.string(),
2498
- pid: z14.number()
2499
- }),
2500
- // 客户端取消注册 PTY 会话
2501
- z14.object({
2502
- type: z14.literal("pty_deregister"),
2503
- sessionId: z14.string(),
2504
- exitCode: z14.number().int().optional(),
2505
- errorTail: z14.string().max(2048).optional(),
2506
- runtimeError: z14.discriminatedUnion("errorCode", [
2507
- z14.object({
2508
- errorCode: z14.literal(ControlErrorCode.SESSION_ALREADY_ACTIVE),
2509
- nativeSessionId: z14.string()
2510
- }),
2511
- z14.object({
2512
- errorCode: z14.literal(ControlErrorCode.PROCESS_START_FAILED),
2513
- error: z14.string().max(2048)
2514
- })
2515
- ]).optional()
2516
- }),
2517
- // serve → worker: hook approval state participates in PTY semantic inference.
2518
- z14.object({
2519
- type: z14.literal("pty_approval_context"),
2520
- sessionId: z14.string(),
2521
- waiting: z14.boolean()
2522
- }),
2523
- // 输入,从服务端转发到客户端的 PTY stdin(手机远程输入注入)
2524
- z14.object({
2525
- type: z14.literal("pty_input"),
2526
- sessionId: z14.string(),
2527
- data: z14.string(),
2528
- traceId: z14.string().optional()
2529
- }),
2530
- // serve → terminal:Web 端移除本地终端会话时,只断开远程视图,不杀本地 CLI。
2531
- z14.object({
2532
- type: z14.literal("pty_detach"),
2533
- sessionId: z14.string()
2534
- }),
2535
- // serve → terminal worker:终止 Web 创建的纯终端进程。
2536
- z14.object({
2537
- type: z14.literal("pty_terminate"),
2538
- sessionId: z14.string()
2539
- }),
2540
- // 错误响应
2541
- z14.object({
2542
- type: z14.literal("error"),
2543
- message: z14.string(),
2544
- code: z14.string().optional()
2545
- }),
2546
- // terminal → serve:终端标题变化,由 xterm onTitleChange 触发
2547
- z14.object({
2548
- type: z14.literal("pty_title_change"),
2549
- sessionId: z14.string(),
2550
- title: z14.string()
2551
- }),
2552
- // terminal → serve:shell 通过 OSC 7 报告的当前工作目录
2553
- z14.object({
2554
- type: z14.literal("pty_cwd_change"),
2555
- sessionId: z14.string(),
2556
- cwd: z14.string().min(1)
2557
- }),
2558
- // terminal → serve:local runtime 观察到的 PTY 语义事件。
2559
- z14.object({
2560
- type: z14.literal("pty_semantic_event"),
2561
- sessionId: z14.string(),
2562
- state: z14.enum(ptySemanticStateValues),
2563
- seq: z14.number().int().nonnegative(),
2564
- title: z14.string().optional(),
2565
- tool: z14.string().optional()
2566
- }),
2567
- // terminal → serve:终端尺寸变化
2568
- z14.object({
2569
- type: z14.literal("pty_resize"),
2570
- sessionId: z14.string(),
2571
- cols: z14.number(),
2572
- rows: z14.number(),
2573
- // Shares the monotonic render-event sequence used by binary PTY frames and snapshots.
2574
- outputSeq: z14.number().int().nonnegative()
2575
- }),
2576
- // serve → terminal worker:Web owns pure terminal geometry, so resize requests flow down.
2577
- z14.object({
2578
- type: z14.literal("pty_resize_request"),
2579
- sessionId: z14.string(),
2580
- cols: z14.number(),
2581
- rows: z14.number()
2582
- }),
2583
- // serve → terminal:请求 HeadlessTerminal serialize() 快照
2584
- z14.object({
2585
- type: z14.literal("pty_subscribe"),
2586
- sessionId: z14.string(),
2587
- requestId: z14.string()
2588
- }),
2589
- // terminal → serve:serialize() 结果
2590
- z14.object({
2591
- type: z14.literal("pty_snapshot"),
2592
- sessionId: z14.string(),
2593
- cols: z14.number(),
2594
- rows: z14.number(),
2595
- data: z14.string(),
2596
- outputSeq: z14.number().int().nonnegative(),
2597
- requestId: z14.string()
2598
- }),
2599
- // serve → terminal:relay 连接状态变更,供终端给用户显示 remote viewing 是否通畅
2600
- z14.object({
2601
- type: z14.literal("bridge_status"),
2602
- connected: z14.boolean()
2603
- })
2604
- ]);
2605
- var WorkerMessageSchema = z14.discriminatedUnion("type", [
2606
- // worker → serve: every socket connection begins with this protocol and process identity.
2607
- // Readiness is reported separately because provider bootstrap can fail after IPC negotiation.
2608
- // Hello extensions are informational; the required version and identity remain authoritative.
2609
- z14.object({
2610
- type: z14.literal("worker_protocol_hello"),
2611
- protocolVersion: z14.literal(WORKER_IPC_PROTOCOL_VERSION),
2612
- sessionId: z14.string().min(1),
2613
- provider: z14.enum(providerValues),
2614
- pid: z14.number().int().positive().max(Number.MAX_SAFE_INTEGER)
2615
- }),
2616
- // serve → worker: the worker also rejects a daemon from another IPC generation.
2617
- z14.object({
2618
- type: z14.literal("serve_protocol_hello"),
2619
- protocolVersion: z14.literal(WORKER_IPC_PROTOCOL_VERSION),
2620
- sessionId: z14.string().min(1),
2621
- pid: z14.number().int().positive().max(Number.MAX_SAFE_INTEGER)
2622
- }),
2623
- // serve → worker: 发送用户输入给 claude
2624
- z14.object({
2625
- type: z14.literal("worker_input"),
2626
- content: z14.string()
2627
- }),
2628
- // serve → worker: 停止 claude 进程(终止整个 JSON 会话)
2629
- z14.object({
2630
- type: z14.literal("worker_stop")
2631
- }),
2632
- // serve → worker: 只中断当前 provider turn,worker 进程保持可复用。
2633
- z14.object({
2634
- type: z14.literal("worker_interrupt")
2635
- }),
2636
- // serve → worker: 工具审批响应
2637
- z14.object({
2638
- type: z14.literal("worker_approval_response"),
2639
- requestId: z14.string(),
2640
- behavior: z14.enum(["allow", "deny"]),
2641
- message: z14.string().optional(),
2642
- remember: z14.boolean().optional(),
2643
- optionId: z14.string().optional()
2644
- }),
2645
- // worker → serve: provider 输出事件(带序列号)
2646
- z14.object({
2647
- type: z14.literal("worker_event"),
2648
- seq: z14.number(),
2649
- event: z14.record(z14.string(), z14.unknown())
2650
- }),
2651
- // worker → serve: provider 进程退出
2652
- z14.object({
2653
- type: z14.literal("worker_exit"),
2654
- code: z14.number(),
2655
- errorTail: z14.string().max(2048).optional()
2656
- }),
2657
- // worker → serve: 当前 turn 已中断,JSON 会话仍可继续接收后续输入。
2658
- z14.object({
2659
- type: z14.literal("worker_interrupted")
2660
- }),
2661
- // worker → serve: provider 真正开始执行一个排队中的 turn(区别于仅接收输入)。
2662
- z14.object({
2663
- type: z14.literal("worker_turn_started")
2664
- }),
2665
- // worker → serve: 工具审批请求
2666
- z14.object({
2667
- type: z14.literal("worker_approval_request"),
2668
- requestId: z14.string(),
2669
- toolName: z14.string(),
2670
- input: z14.record(z14.string(), z14.unknown()),
2671
- options: z14.array(ApprovalOptionSchema).optional()
2672
- }),
2673
- // worker → serve: worker 就绪。Claude 在进程启动后发送;Codex/Kimi 分别在
2674
- // app-server/ACP initialize + native session start|resume 完成后发送。
2675
- z14.object({
2676
- type: z14.literal("worker_ready"),
2677
- pid: z14.number(),
2678
- nativeSession: z14.object({
2679
- provider: z14.enum(providerValues),
2680
- sessionId: z14.string()
2681
- }).optional()
2682
- }),
2683
- // Provider 在 worker_ready 之前失败时保留一小段脱敏后的诊断;可识别错误同时携带
2684
- // 结构化 code,serve 不再只能把它降级成笼统的 WORKER_START_FAILED。
2685
- z14.object({
2686
- type: z14.literal("worker_startup_error"),
2687
- provider: z14.enum(providerValues),
2688
- message: z14.string().max(2048),
2689
- errorCode: z14.literal(ControlErrorCode.SESSION_ALREADY_ACTIVE).optional(),
2690
- nativeSessionId: z14.string().optional()
2691
- }),
2692
- // worker → serve: provider 原生会话 ID。
2693
- z14.object({
2694
- type: z14.literal("worker_native_session_id"),
2695
- provider: z14.enum(providerValues),
2696
- sessionId: z14.string()
2697
- }),
2698
- // serve → worker: 将指定工具加入会话白名单,后续同名工具自动审批
2699
- z14.object({
2700
- type: z14.literal("worker_whitelist_add"),
2701
- toolName: z14.string()
2702
- })
2703
- ]);
2704
- function serializeWorkerMsg(msg) {
2705
- return JSON.stringify(msg) + "\n";
2706
- }
2707
- function createWorkerReader(stream, onMessage, onProtocolError) {
2708
- const lineBuffer = new LineBuffer();
2709
- lineBuffer.on("data", (line) => {
2710
- const str = typeof line === "string" ? line : line.toString();
2711
- if (str.length === 0) return;
2712
- let raw;
2713
- try {
2714
- raw = JSON.parse(str);
2715
- } catch (err) {
2716
- onProtocolError(new Error("Worker message parse error", { cause: err }), str);
2717
- return;
2718
- }
2719
- const result = WorkerMessageSchema.safeParse(raw);
2720
- if (!result.success) {
2721
- onProtocolError(new Error(`Worker message validation failed: ${result.error.message}`), str);
2722
- return;
2723
- }
2724
- onMessage(result.data);
2725
- });
2726
- stream.pipe(lineBuffer);
2727
- }
2728
- function serializeIpc(msg) {
2729
- return JSON.stringify(msg) + "\n";
2730
- }
2731
- function createIpcReader(stream, onMessage, onBinaryFrame, onProtocolError) {
2732
- let buf = Buffer.alloc(0);
2733
- let disposed = false;
2734
- function drain() {
2735
- while (buf.length > 0) {
2736
- if (buf[0] === IPC_BINARY_MARKER) {
2737
- if (buf.length < 5) return;
2738
- const payloadLen = buf.readUInt32LE(1);
2739
- const totalFrameLen = 1 + 4 + payloadLen;
2740
- if (buf.length < totalFrameLen) return;
2741
- const decoded = decodeBinaryFrame(buf.subarray(5, totalFrameLen));
2742
- if (decoded && onBinaryFrame) {
2743
- onBinaryFrame(decoded.sessionId, Buffer.from(decoded.data), decoded.outputSeq);
2744
- }
2745
- buf = buf.subarray(totalFrameLen);
2746
- } else {
2747
- const newlineIdx = buf.indexOf(10);
2748
- if (newlineIdx === -1) return;
2749
- const line = buf.subarray(0, newlineIdx).toString("utf-8");
2750
- buf = buf.subarray(newlineIdx + 1);
2751
- if (line.length === 0) continue;
2752
- let raw;
2753
- try {
2754
- raw = JSON.parse(line);
2755
- } catch (err) {
2756
- onProtocolError(new Error("IPC message parse error", { cause: err }), line);
2757
- continue;
2758
- }
2759
- const result = IpcMessageSchema.safeParse(raw);
2760
- if (!result.success) {
2761
- onProtocolError(
2762
- new Error(`IPC message validation failed: ${result.error.message}`),
2763
- line
2764
- );
2765
- continue;
2766
- }
2767
- onMessage(result.data);
2768
- }
2769
- }
2770
- }
2771
- function onData(chunk) {
2772
- if (disposed) return;
2773
- const incoming = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
2774
- buf = Buffer.concat([buf, incoming]);
2775
- drain();
2776
- }
2777
- stream.on("data", onData);
2778
- return () => {
2779
- disposed = true;
2780
- stream.off("data", onData);
2781
- };
2782
- }
2783
-
2784
2428
  export {
2785
2429
  IdSchema,
2430
+ ApprovalOptionSchema,
2786
2431
  providerValues,
2432
+ ptySemanticStateValues,
2787
2433
  PTY_INITIAL_MIN_COLS,
2788
2434
  PTY_INITIAL_MIN_ROWS,
2789
2435
  PTY_INITIAL_MAX_COLS,
@@ -2809,6 +2455,7 @@ export {
2809
2455
  isProxyProtocolRejectDirection,
2810
2456
  RELAY_JSON_MESSAGE_MAX_BYTES,
2811
2457
  encodeBinaryFrame,
2458
+ decodeBinaryFrame,
2812
2459
  encodeFileStreamFrame,
2813
2460
  decodeFileStreamFrame,
2814
2461
  DEVICE_PREVIEW_FRAME_MAX_BYTES,
@@ -2816,13 +2463,6 @@ export {
2816
2463
  encodeDevicePreviewH264ProxyPacket,
2817
2464
  createFSM,
2818
2465
  defineFSM,
2819
- LineBuffer,
2820
- WORKER_IPC_PROTOCOL_VERSION,
2821
- TERMINAL_IPC_PROTOCOL_VERSION,
2822
- encodeBinaryIpcFrame,
2823
- serializeWorkerMsg,
2824
- createWorkerReader,
2825
- serializeIpc,
2826
- createIpcReader
2466
+ LineBuffer
2827
2467
  };
2828
- //# sourceMappingURL=chunk-GIFG7KAJ.js.map
2468
+ //# sourceMappingURL=chunk-7FPUPHTZ.js.map