@dev-anywhere/proxy 0.9.5 → 0.9.7

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