@dev-anywhere/proxy 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{autostart-XIZTTKSV.js → autostart-TMACAYHZ.js} +12 -8
- package/dist/{autostart-XIZTTKSV.js.map → autostart-TMACAYHZ.js.map} +1 -1
- package/dist/{chunk-N63J6URN.js → chunk-5COVSNQZ.js} +2 -2
- package/dist/chunk-5OARBB2B.js +36 -0
- package/dist/chunk-5OARBB2B.js.map +1 -0
- package/dist/chunk-724Y2CKO.js +94 -0
- package/dist/chunk-724Y2CKO.js.map +1 -0
- package/dist/{chunk-3KATRUOJ.js → chunk-7FPUPHTZ.js} +817 -1179
- package/dist/chunk-7FPUPHTZ.js.map +1 -0
- package/dist/{chunk-DAFUSBKJ.js → chunk-AZ5MTPUR.js} +2 -91
- package/dist/chunk-AZ5MTPUR.js.map +1 -0
- package/dist/chunk-BUUAXCBP.js +93 -0
- package/dist/chunk-BUUAXCBP.js.map +1 -0
- package/dist/{chunk-XADKKDUV.js → chunk-BZWRTKXC.js} +2 -33
- package/dist/chunk-BZWRTKXC.js.map +1 -0
- package/dist/chunk-C2VZS676.js +377 -0
- package/dist/chunk-C2VZS676.js.map +1 -0
- package/dist/{chunk-R4SLOZKJ.js → chunk-DEMLXEB5.js} +3 -3
- package/dist/{chunk-T7N6ALSP.js → chunk-EEXWF5SA.js} +6 -5
- package/dist/chunk-EEXWF5SA.js.map +1 -0
- package/dist/{chunk-QWHC5PEP.js → chunk-IEBAPWH3.js} +6 -44
- package/dist/chunk-IEBAPWH3.js.map +1 -0
- package/dist/chunk-LAFXAGDU.js +29 -0
- package/dist/chunk-LAFXAGDU.js.map +1 -0
- package/dist/{chunk-L2DA7PGQ.js → chunk-LIGQMX7K.js} +9 -7
- package/dist/{chunk-L2DA7PGQ.js.map → chunk-LIGQMX7K.js.map} +1 -1
- package/dist/chunk-SSTYQQSR.js +86 -0
- package/dist/chunk-SSTYQQSR.js.map +1 -0
- package/dist/{chunk-TMY2OA3C.js → chunk-TIXHLU3Q.js} +6 -22
- package/dist/chunk-TIXHLU3Q.js.map +1 -0
- package/dist/{chunk-WLXTXXNY.js → chunk-TLY6IMDY.js} +39 -1
- package/dist/chunk-TLY6IMDY.js.map +1 -0
- package/dist/chunk-TQP3COOV.js +69 -0
- package/dist/chunk-TQP3COOV.js.map +1 -0
- package/dist/{chunk-4TXAGHXH.js → chunk-UBWS5JVM.js} +10 -8
- package/dist/{chunk-4TXAGHXH.js.map → chunk-UBWS5JVM.js.map} +1 -1
- package/dist/{chunk-POTR6UPA.js → chunk-WEATMI5J.js} +7 -1
- package/dist/chunk-WEATMI5J.js.map +1 -0
- package/dist/chunk-WG3KLJFJ.js +64 -0
- package/dist/chunk-WG3KLJFJ.js.map +1 -0
- package/dist/{chunk-Q6EYYC4Z.js → chunk-ZRABX7EM.js} +2 -2
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/{logger-NB7VSWM5.js → logger-XEIQC6K6.js} +3 -3
- package/dist/preview-worker.js +7871 -0
- package/dist/preview-worker.js.map +1 -0
- package/dist/{relay-token-DJX6KWOT.js → relay-token-Y3IFNUMX.js} +4 -4
- package/dist/serve.js +2650 -10105
- package/dist/serve.js.map +1 -1
- package/dist/session-worker.js +35 -69
- package/dist/session-worker.js.map +1 -1
- package/dist/{terminal-ZAWO3GKY.js → terminal-FNVKGTTL.js} +17 -12
- package/dist/terminal-FNVKGTTL.js.map +1 -0
- package/dist/terminal-worker.js +22 -16
- package/dist/terminal-worker.js.map +1 -1
- package/dist/update-runner.js +4 -3
- package/dist/update-runner.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-3KATRUOJ.js.map +0 -1
- package/dist/chunk-CMADETTC.js +0 -147
- package/dist/chunk-CMADETTC.js.map +0 -1
- package/dist/chunk-DAFUSBKJ.js.map +0 -1
- package/dist/chunk-POTR6UPA.js.map +0 -1
- package/dist/chunk-QWHC5PEP.js.map +0 -1
- package/dist/chunk-T7N6ALSP.js.map +0 -1
- package/dist/chunk-TMY2OA3C.js.map +0 -1
- package/dist/chunk-WLXTXXNY.js.map +0 -1
- package/dist/chunk-XADKKDUV.js.map +0 -1
- package/dist/terminal-ZAWO3GKY.js.map +0 -1
- /package/dist/{chunk-N63J6URN.js.map → chunk-5COVSNQZ.js.map} +0 -0
- /package/dist/{chunk-R4SLOZKJ.js.map → chunk-DEMLXEB5.js.map} +0 -0
- /package/dist/{chunk-Q6EYYC4Z.js.map → chunk-ZRABX7EM.js.map} +0 -0
- /package/dist/{logger-NB7VSWM5.js.map → logger-XEIQC6K6.js.map} +0 -0
- /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/
|
|
315
|
-
|
|
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/
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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
|
|
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 =
|
|
391
|
+
var WebPreviewNameSchema = z8.string().trim().min(1).max(WEB_PREVIEW_NAME_MAX_LENGTH);
|
|
453
392
|
var tunnelProviderValues = ["cloudflare", "cpolar"];
|
|
454
|
-
var TunnelProviderSchema =
|
|
455
|
-
var WebPreviewPathSchema =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
481
|
-
var WebPreviewTunnelStatusSchema =
|
|
482
|
-
|
|
483
|
-
available:
|
|
484
|
-
command:
|
|
485
|
-
version:
|
|
486
|
-
error:
|
|
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
|
-
|
|
490
|
-
available:
|
|
491
|
-
command:
|
|
492
|
-
version:
|
|
493
|
-
error:
|
|
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 =
|
|
436
|
+
var WebPreviewCapabilitySchema = z8.object({
|
|
498
437
|
cloudflared: WebPreviewTunnelStatusSchema,
|
|
499
438
|
cpolar: WebPreviewTunnelStatusSchema
|
|
500
439
|
});
|
|
501
|
-
var WebPreviewSourceInputSchema =
|
|
502
|
-
|
|
503
|
-
kind:
|
|
440
|
+
var WebPreviewSourceInputSchema = z8.discriminatedUnion("kind", [
|
|
441
|
+
z8.object({
|
|
442
|
+
kind: z8.literal("local"),
|
|
504
443
|
url: LoopbackHttpUrlSchema
|
|
505
444
|
}).strict(),
|
|
506
|
-
|
|
507
|
-
kind:
|
|
445
|
+
z8.object({
|
|
446
|
+
kind: z8.literal("static"),
|
|
508
447
|
path: WebPreviewPathSchema,
|
|
509
448
|
entryPath: WebPreviewPathSchema
|
|
510
449
|
}).strict()
|
|
511
450
|
]);
|
|
512
|
-
var PreviewSourceSchema =
|
|
513
|
-
|
|
514
|
-
kind:
|
|
515
|
-
rootPath:
|
|
516
|
-
entryPath:
|
|
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
|
-
|
|
520
|
-
kind:
|
|
521
|
-
url:
|
|
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 =
|
|
534
|
-
var PreviewSummaryBaseSchema =
|
|
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:
|
|
540
|
-
updatedAt:
|
|
478
|
+
createdAt: z8.number().int().nonnegative(),
|
|
479
|
+
updatedAt: z8.number().int().nonnegative()
|
|
541
480
|
});
|
|
542
481
|
var PreviewSummaryInactiveShape = {
|
|
543
|
-
publicUrl:
|
|
544
|
-
error:
|
|
482
|
+
publicUrl: z8.never().optional(),
|
|
483
|
+
error: z8.never().optional()
|
|
545
484
|
};
|
|
546
|
-
var PreviewSummarySchema =
|
|
485
|
+
var PreviewSummarySchema = z8.discriminatedUnion("state", [
|
|
547
486
|
PreviewSummaryBaseSchema.extend({
|
|
548
|
-
state:
|
|
487
|
+
state: z8.literal("starting"),
|
|
549
488
|
...PreviewSummaryInactiveShape
|
|
550
489
|
}),
|
|
551
490
|
PreviewSummaryBaseSchema.extend({
|
|
552
|
-
state:
|
|
491
|
+
state: z8.literal("ready"),
|
|
553
492
|
publicUrl: PublicPreviewUrlSchema,
|
|
554
|
-
error:
|
|
493
|
+
error: z8.never().optional()
|
|
555
494
|
}),
|
|
556
495
|
PreviewSummaryBaseSchema.extend({
|
|
557
|
-
state:
|
|
496
|
+
state: z8.literal("disconnected"),
|
|
558
497
|
...PreviewSummaryInactiveShape
|
|
559
498
|
}),
|
|
560
499
|
PreviewSummaryBaseSchema.extend({
|
|
561
|
-
state:
|
|
562
|
-
publicUrl:
|
|
563
|
-
error:
|
|
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:
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
537
|
+
var DevicePreviewStreamFormatSchema = z9.enum(devicePreviewStreamFormatValues);
|
|
599
538
|
var devicePreviewPlatformValues = ["ios", "android"];
|
|
600
|
-
var DevicePreviewPlatformSchema =
|
|
601
|
-
var DevicePreviewToolSuggestionsSchema =
|
|
602
|
-
var DevicePreviewToolStatusSchema =
|
|
603
|
-
|
|
604
|
-
supported:
|
|
605
|
-
available:
|
|
606
|
-
interactive:
|
|
607
|
-
command:
|
|
608
|
-
version:
|
|
609
|
-
error:
|
|
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
|
-
|
|
613
|
-
supported:
|
|
614
|
-
available:
|
|
615
|
-
interactive:
|
|
616
|
-
command:
|
|
617
|
-
version:
|
|
618
|
-
error:
|
|
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
|
-
|
|
622
|
-
supported:
|
|
623
|
-
available:
|
|
624
|
-
interactive:
|
|
625
|
-
command:
|
|
626
|
-
version:
|
|
627
|
-
error:
|
|
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 =
|
|
570
|
+
var DevicePreviewCapabilitySchema = z9.object({
|
|
632
571
|
ios: DevicePreviewToolStatusSchema,
|
|
633
572
|
android: DevicePreviewToolStatusSchema
|
|
634
573
|
});
|
|
635
|
-
var DevicePreviewTargetBaseSchema =
|
|
574
|
+
var DevicePreviewTargetBaseSchema = z9.object({
|
|
636
575
|
targetId: IdSchema,
|
|
637
576
|
platform: DevicePreviewPlatformSchema,
|
|
638
|
-
name:
|
|
639
|
-
model:
|
|
640
|
-
osVersion:
|
|
641
|
-
interactive:
|
|
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 =
|
|
644
|
-
var DevicePreviewTargetSchema =
|
|
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:
|
|
651
|
-
height:
|
|
589
|
+
width: z9.never().optional(),
|
|
590
|
+
height: z9.never().optional()
|
|
652
591
|
})
|
|
653
592
|
]);
|
|
654
|
-
var DevicePreviewStateSchema =
|
|
655
|
-
var DevicePreviewSummaryBaseSchema =
|
|
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:
|
|
661
|
-
osVersion:
|
|
662
|
-
interactive:
|
|
663
|
-
createdAt:
|
|
664
|
-
updatedAt:
|
|
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 =
|
|
605
|
+
var DevicePreviewSummarySchema = z9.discriminatedUnion("state", [
|
|
667
606
|
DevicePreviewSummaryBaseSchema.extend({
|
|
668
|
-
state:
|
|
669
|
-
error:
|
|
607
|
+
state: z9.literal("ready"),
|
|
608
|
+
error: z9.never().optional()
|
|
670
609
|
}),
|
|
671
610
|
DevicePreviewSummaryBaseSchema.extend({
|
|
672
|
-
state:
|
|
673
|
-
error:
|
|
611
|
+
state: z9.literal("disconnected"),
|
|
612
|
+
error: z9.never().optional()
|
|
674
613
|
})
|
|
675
614
|
]);
|
|
676
|
-
var DevicePreviewJpegStreamProfileSchema =
|
|
677
|
-
format:
|
|
678
|
-
maxFps:
|
|
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 =
|
|
681
|
-
format:
|
|
619
|
+
var DevicePreviewH264StreamProfileSchema = z9.object({
|
|
620
|
+
format: z9.literal("h264_annex_b")
|
|
682
621
|
}).strict();
|
|
683
|
-
var DevicePreviewStreamProfileSchema =
|
|
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 =
|
|
695
|
-
var NormalizedCoordinateSchema =
|
|
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 =
|
|
636
|
+
var DevicePreviewTouchPhaseSchema = z9.enum(devicePreviewTouchPhaseValues);
|
|
698
637
|
var devicePreviewOrientationValues = [
|
|
699
638
|
"portrait",
|
|
700
639
|
"landscape_left",
|
|
@@ -702,321 +641,166 @@ var devicePreviewOrientationValues = [
|
|
|
702
641
|
"portrait_upside_down",
|
|
703
642
|
"auto"
|
|
704
643
|
];
|
|
705
|
-
var DevicePreviewOrientationSchema =
|
|
706
|
-
var DevicePreviewInputSchema =
|
|
707
|
-
|
|
708
|
-
kind:
|
|
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
|
-
|
|
714
|
-
kind:
|
|
715
|
-
text:
|
|
652
|
+
z9.object({
|
|
653
|
+
kind: z9.literal("text"),
|
|
654
|
+
text: z9.string().min(1).max(DEVICE_PREVIEW_TEXT_MAX_LENGTH)
|
|
716
655
|
}).strict(),
|
|
717
|
-
|
|
718
|
-
kind:
|
|
719
|
-
button:
|
|
656
|
+
z9.object({
|
|
657
|
+
kind: z9.literal("button"),
|
|
658
|
+
button: z9.enum(["home", "back"])
|
|
720
659
|
}).strict(),
|
|
721
|
-
|
|
722
|
-
kind:
|
|
660
|
+
z9.object({
|
|
661
|
+
kind: z9.literal("orientation"),
|
|
723
662
|
orientation: DevicePreviewOrientationSchema
|
|
724
663
|
}).strict()
|
|
725
664
|
]);
|
|
726
|
-
var DevicePreviewStreamRegisterSchema =
|
|
727
|
-
type:
|
|
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 =
|
|
732
|
-
|
|
733
|
-
type:
|
|
734
|
-
success:
|
|
735
|
-
error:
|
|
736
|
-
}),
|
|
737
|
-
|
|
738
|
-
type:
|
|
739
|
-
success:
|
|
740
|
-
error:
|
|
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 =
|
|
744
|
-
type:
|
|
682
|
+
var DevicePreviewStreamFlowBaseSchema = z9.object({
|
|
683
|
+
type: z9.literal("device_preview_stream_flow"),
|
|
745
684
|
streamId: IdSchema
|
|
746
685
|
});
|
|
747
|
-
var DevicePreviewStreamFlowSchema =
|
|
686
|
+
var DevicePreviewStreamFlowSchema = z9.discriminatedUnion("paused", [
|
|
748
687
|
DevicePreviewStreamFlowBaseSchema.extend({
|
|
749
|
-
paused:
|
|
750
|
-
resyncRequired:
|
|
688
|
+
paused: z9.literal(true),
|
|
689
|
+
resyncRequired: z9.literal(false)
|
|
751
690
|
}).strict(),
|
|
752
691
|
DevicePreviewStreamFlowBaseSchema.extend({
|
|
753
|
-
paused:
|
|
754
|
-
resyncRequired:
|
|
692
|
+
paused: z9.literal(false),
|
|
693
|
+
resyncRequired: z9.boolean()
|
|
755
694
|
}).strict()
|
|
756
695
|
]);
|
|
757
|
-
var DevicePreviewStreamServerMessageSchema =
|
|
696
|
+
var DevicePreviewStreamServerMessageSchema = z9.union([
|
|
758
697
|
DevicePreviewStreamRegisterResponseSchema,
|
|
759
698
|
DevicePreviewStreamFlowSchema
|
|
760
699
|
]);
|
|
761
700
|
|
|
762
|
-
// ../../packages/shared/dist/schemas/
|
|
763
|
-
import { z as
|
|
764
|
-
var
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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 =
|
|
710
|
+
var ProxyInfoSchema = z11.object({
|
|
927
711
|
proxyId: IdSchema,
|
|
928
|
-
name:
|
|
929
|
-
osName:
|
|
930
|
-
version:
|
|
931
|
-
online:
|
|
932
|
-
sessions:
|
|
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 =
|
|
718
|
+
var RelayClientInfoSchema = z11.object({
|
|
935
719
|
clientId: IdSchema,
|
|
936
720
|
proxyId: IdSchema.optional(),
|
|
937
|
-
connectedAt:
|
|
938
|
-
current:
|
|
939
|
-
userAgent:
|
|
940
|
-
platform:
|
|
941
|
-
maxTouchPoints:
|
|
942
|
-
browserName:
|
|
943
|
-
osName:
|
|
944
|
-
deviceKind:
|
|
945
|
-
remoteAddress:
|
|
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 =
|
|
948
|
-
available:
|
|
949
|
-
command:
|
|
950
|
-
error:
|
|
951
|
-
suggestions:
|
|
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 =
|
|
737
|
+
var AgentCliStatusSchema = z11.object({
|
|
954
738
|
claude: AgentCliAvailabilitySchema,
|
|
955
739
|
codex: AgentCliAvailabilitySchema,
|
|
956
740
|
kimi: AgentCliAvailabilitySchema
|
|
957
741
|
});
|
|
958
|
-
var DirEntrySchema =
|
|
959
|
-
var FileTreeGroupSchema =
|
|
960
|
-
path:
|
|
961
|
-
entries:
|
|
742
|
+
var DirEntrySchema = z11.object({ name: z11.string(), isDir: z11.boolean() });
|
|
743
|
+
var FileTreeGroupSchema = z11.object({
|
|
744
|
+
path: z11.string(),
|
|
745
|
+
entries: z11.array(DirEntrySchema)
|
|
962
746
|
});
|
|
963
|
-
var CommandEntrySchema =
|
|
964
|
-
name:
|
|
965
|
-
description:
|
|
966
|
-
argumentHint:
|
|
967
|
-
source:
|
|
747
|
+
var CommandEntrySchema = z11.object({
|
|
748
|
+
name: z11.string(),
|
|
749
|
+
description: z11.string(),
|
|
750
|
+
argumentHint: z11.string().optional(),
|
|
751
|
+
source: z11.string()
|
|
968
752
|
});
|
|
969
|
-
var HistorySessionSchema =
|
|
970
|
-
id:
|
|
971
|
-
title:
|
|
972
|
-
projectDir:
|
|
973
|
-
updatedAt:
|
|
974
|
-
provider:
|
|
975
|
-
preferredMode:
|
|
753
|
+
var HistorySessionSchema = z11.object({
|
|
754
|
+
id: z11.string(),
|
|
755
|
+
title: z11.string(),
|
|
756
|
+
projectDir: z11.string(),
|
|
757
|
+
updatedAt: z11.number(),
|
|
758
|
+
provider: z11.enum(providerValues),
|
|
759
|
+
preferredMode: z11.enum(sessionModeValues).optional()
|
|
976
760
|
});
|
|
977
761
|
var SessionHistoryPositionShape = {
|
|
978
|
-
timestamp:
|
|
979
|
-
cursor:
|
|
762
|
+
timestamp: z11.number().optional(),
|
|
763
|
+
cursor: z11.string().optional()
|
|
980
764
|
};
|
|
981
|
-
var SessionHistoryMessageSchema =
|
|
982
|
-
|
|
983
|
-
role:
|
|
984
|
-
text:
|
|
765
|
+
var SessionHistoryMessageSchema = z11.discriminatedUnion("role", [
|
|
766
|
+
z11.object({
|
|
767
|
+
role: z11.enum(["user", "assistant", "system"]),
|
|
768
|
+
text: z11.string(),
|
|
985
769
|
...SessionHistoryPositionShape
|
|
986
770
|
}),
|
|
987
|
-
|
|
988
|
-
role:
|
|
989
|
-
text:
|
|
771
|
+
z11.object({
|
|
772
|
+
role: z11.literal("activity"),
|
|
773
|
+
text: z11.string(),
|
|
990
774
|
toolId: IdSchema,
|
|
991
|
-
toolName:
|
|
992
|
-
parameters:
|
|
993
|
-
status:
|
|
775
|
+
toolName: z11.string(),
|
|
776
|
+
parameters: z11.record(z11.string(), z11.unknown()).optional(),
|
|
777
|
+
status: z11.enum(["running", "done", "error"]),
|
|
994
778
|
...SessionHistoryPositionShape
|
|
995
779
|
})
|
|
996
780
|
]);
|
|
997
781
|
var RequestIdShape = { requestId: IdSchema.optional() };
|
|
998
782
|
var RequiredRequestIdShape = { requestId: IdSchema };
|
|
999
|
-
var ControlErrorCodeSchema =
|
|
783
|
+
var ControlErrorCodeSchema = z11.enum(Object.values(ControlErrorCode));
|
|
1000
784
|
var RequestErrorShape = {
|
|
1001
|
-
error:
|
|
785
|
+
error: z11.string().optional(),
|
|
1002
786
|
errorCode: ControlErrorCodeSchema.optional()
|
|
1003
787
|
};
|
|
1004
788
|
var NoRequestErrorShape = {
|
|
1005
|
-
error:
|
|
1006
|
-
errorCode:
|
|
789
|
+
error: z11.never().optional(),
|
|
790
|
+
errorCode: z11.never().optional()
|
|
1007
791
|
};
|
|
1008
792
|
var RequiredRequestErrorShape = {
|
|
1009
|
-
error:
|
|
793
|
+
error: z11.string().min(1),
|
|
1010
794
|
errorCode: ControlErrorCodeSchema
|
|
1011
795
|
};
|
|
1012
|
-
var RemoteFileDispositionSchema =
|
|
1013
|
-
var RemoteFileUploadKindSchema =
|
|
796
|
+
var RemoteFileDispositionSchema = z11.enum(["inline", "download"]);
|
|
797
|
+
var RemoteFileUploadKindSchema = z11.enum(["clipboard_image", "file"]);
|
|
1014
798
|
function control(type, shape, directions) {
|
|
1015
799
|
return {
|
|
1016
800
|
type,
|
|
1017
801
|
directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
|
|
1018
|
-
schema:
|
|
1019
|
-
type:
|
|
802
|
+
schema: z11.object({
|
|
803
|
+
type: z11.literal(type),
|
|
1020
804
|
...shape ?? {}
|
|
1021
805
|
})
|
|
1022
806
|
};
|
|
@@ -1025,8 +809,8 @@ function strictControl(type, shape, directions) {
|
|
|
1025
809
|
return {
|
|
1026
810
|
type,
|
|
1027
811
|
directions: new Set(Array.isArray(directions) ? directions : directions ? [directions] : []),
|
|
1028
|
-
schema:
|
|
1029
|
-
type:
|
|
812
|
+
schema: z11.object({
|
|
813
|
+
type: z11.literal(type),
|
|
1030
814
|
...shape
|
|
1031
815
|
}).strict()
|
|
1032
816
|
};
|
|
@@ -1038,331 +822,331 @@ function controlSchema(type, schema, directions) {
|
|
|
1038
822
|
schema
|
|
1039
823
|
};
|
|
1040
824
|
}
|
|
1041
|
-
var ProxySelectResponseSchema =
|
|
1042
|
-
|
|
1043
|
-
type:
|
|
825
|
+
var ProxySelectResponseSchema = z11.discriminatedUnion("success", [
|
|
826
|
+
z11.object({
|
|
827
|
+
type: z11.literal("proxy_select_response"),
|
|
1044
828
|
...RequestIdShape,
|
|
1045
|
-
success:
|
|
829
|
+
success: z11.literal(true),
|
|
1046
830
|
...NoRequestErrorShape,
|
|
1047
831
|
proxyId: IdSchema,
|
|
1048
832
|
bindingId: IdSchema
|
|
1049
833
|
}),
|
|
1050
|
-
|
|
1051
|
-
type:
|
|
834
|
+
z11.object({
|
|
835
|
+
type: z11.literal("proxy_select_response"),
|
|
1052
836
|
...RequestIdShape,
|
|
1053
|
-
success:
|
|
1054
|
-
proxyId:
|
|
1055
|
-
bindingId:
|
|
837
|
+
success: z11.literal(false),
|
|
838
|
+
proxyId: z11.never().optional(),
|
|
839
|
+
bindingId: z11.never().optional(),
|
|
1056
840
|
...RequestErrorShape
|
|
1057
841
|
})
|
|
1058
842
|
]);
|
|
1059
|
-
var ClientRegisterResponseSchema =
|
|
1060
|
-
|
|
1061
|
-
type:
|
|
1062
|
-
protocolVersion:
|
|
1063
|
-
status:
|
|
843
|
+
var ClientRegisterResponseSchema = z11.discriminatedUnion("status", [
|
|
844
|
+
z11.object({
|
|
845
|
+
type: z11.literal("client_register_response"),
|
|
846
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
847
|
+
status: z11.literal("restored"),
|
|
1064
848
|
proxyId: IdSchema,
|
|
1065
849
|
bindingId: IdSchema
|
|
1066
850
|
}),
|
|
1067
|
-
|
|
1068
|
-
type:
|
|
1069
|
-
protocolVersion:
|
|
1070
|
-
status:
|
|
851
|
+
z11.object({
|
|
852
|
+
type: z11.literal("client_register_response"),
|
|
853
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
854
|
+
status: z11.literal("proxy_offline"),
|
|
1071
855
|
proxyId: IdSchema,
|
|
1072
856
|
bindingId: IdSchema
|
|
1073
857
|
}),
|
|
1074
|
-
|
|
1075
|
-
type:
|
|
1076
|
-
protocolVersion:
|
|
1077
|
-
status:
|
|
858
|
+
z11.object({
|
|
859
|
+
type: z11.literal("client_register_response"),
|
|
860
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
861
|
+
status: z11.literal("new"),
|
|
1078
862
|
// 已知的绑定字段不能作为扩展信息被忽略;new 状态明确表示尚未绑定。
|
|
1079
|
-
proxyId:
|
|
1080
|
-
bindingId:
|
|
863
|
+
proxyId: z11.never().optional(),
|
|
864
|
+
bindingId: z11.never().optional()
|
|
1081
865
|
})
|
|
1082
866
|
]);
|
|
1083
|
-
var PreviewCreateResponseSchema =
|
|
1084
|
-
|
|
1085
|
-
type:
|
|
867
|
+
var PreviewCreateResponseSchema = z11.discriminatedUnion("accepted", [
|
|
868
|
+
z11.object({
|
|
869
|
+
type: z11.literal("preview_create_response"),
|
|
1086
870
|
...RequiredRequestIdShape,
|
|
1087
871
|
scope: PreviewScopeSchema,
|
|
1088
872
|
operationId: IdSchema,
|
|
1089
|
-
accepted:
|
|
873
|
+
accepted: z11.literal(true),
|
|
1090
874
|
...NoRequestErrorShape,
|
|
1091
875
|
previewId: IdSchema
|
|
1092
876
|
}),
|
|
1093
|
-
|
|
1094
|
-
type:
|
|
877
|
+
z11.object({
|
|
878
|
+
type: z11.literal("preview_create_response"),
|
|
1095
879
|
...RequiredRequestIdShape,
|
|
1096
880
|
scope: PreviewScopeSchema,
|
|
1097
881
|
operationId: IdSchema,
|
|
1098
|
-
accepted:
|
|
1099
|
-
previewId:
|
|
882
|
+
accepted: z11.literal(false),
|
|
883
|
+
previewId: z11.never().optional(),
|
|
1100
884
|
...RequiredRequestErrorShape
|
|
1101
885
|
})
|
|
1102
886
|
]);
|
|
1103
|
-
var DevicePreviewCreateResponseSchema =
|
|
1104
|
-
|
|
1105
|
-
type:
|
|
887
|
+
var DevicePreviewCreateResponseSchema = z11.discriminatedUnion("accepted", [
|
|
888
|
+
z11.object({
|
|
889
|
+
type: z11.literal("device_preview_create_response"),
|
|
1106
890
|
...RequiredRequestIdShape,
|
|
1107
891
|
scope: PreviewScopeSchema,
|
|
1108
892
|
operationId: IdSchema,
|
|
1109
|
-
accepted:
|
|
893
|
+
accepted: z11.literal(true),
|
|
1110
894
|
...NoRequestErrorShape,
|
|
1111
895
|
previewId: IdSchema
|
|
1112
896
|
}),
|
|
1113
|
-
|
|
1114
|
-
type:
|
|
897
|
+
z11.object({
|
|
898
|
+
type: z11.literal("device_preview_create_response"),
|
|
1115
899
|
...RequiredRequestIdShape,
|
|
1116
900
|
scope: PreviewScopeSchema,
|
|
1117
901
|
operationId: IdSchema,
|
|
1118
|
-
accepted:
|
|
1119
|
-
previewId:
|
|
902
|
+
accepted: z11.literal(false),
|
|
903
|
+
previewId: z11.never().optional(),
|
|
1120
904
|
...RequiredRequestErrorShape
|
|
1121
905
|
})
|
|
1122
906
|
]);
|
|
1123
|
-
var PreviewCapabilityResponseSchema =
|
|
1124
|
-
|
|
1125
|
-
type:
|
|
907
|
+
var PreviewCapabilityResponseSchema = z11.discriminatedUnion("success", [
|
|
908
|
+
z11.object({
|
|
909
|
+
type: z11.literal("preview_capability_response"),
|
|
1126
910
|
...RequiredRequestIdShape,
|
|
1127
911
|
scope: PreviewScopeSchema,
|
|
1128
|
-
success:
|
|
912
|
+
success: z11.literal(true),
|
|
1129
913
|
...NoRequestErrorShape,
|
|
1130
914
|
capability: WebPreviewCapabilitySchema
|
|
1131
915
|
}),
|
|
1132
|
-
|
|
1133
|
-
type:
|
|
916
|
+
z11.object({
|
|
917
|
+
type: z11.literal("preview_capability_response"),
|
|
1134
918
|
...RequiredRequestIdShape,
|
|
1135
919
|
scope: PreviewScopeSchema,
|
|
1136
|
-
success:
|
|
1137
|
-
capability:
|
|
920
|
+
success: z11.literal(false),
|
|
921
|
+
capability: z11.never().optional(),
|
|
1138
922
|
...RequiredRequestErrorShape
|
|
1139
923
|
})
|
|
1140
924
|
]);
|
|
1141
|
-
var DevicePreviewCapabilityResponseSchema =
|
|
1142
|
-
|
|
1143
|
-
type:
|
|
925
|
+
var DevicePreviewCapabilityResponseSchema = z11.discriminatedUnion("success", [
|
|
926
|
+
z11.object({
|
|
927
|
+
type: z11.literal("device_preview_capability_response"),
|
|
1144
928
|
...RequiredRequestIdShape,
|
|
1145
929
|
scope: PreviewScopeSchema,
|
|
1146
|
-
success:
|
|
930
|
+
success: z11.literal(true),
|
|
1147
931
|
...NoRequestErrorShape,
|
|
1148
932
|
capability: DevicePreviewCapabilitySchema
|
|
1149
933
|
}),
|
|
1150
|
-
|
|
1151
|
-
type:
|
|
934
|
+
z11.object({
|
|
935
|
+
type: z11.literal("device_preview_capability_response"),
|
|
1152
936
|
...RequiredRequestIdShape,
|
|
1153
937
|
scope: PreviewScopeSchema,
|
|
1154
|
-
success:
|
|
1155
|
-
capability:
|
|
938
|
+
success: z11.literal(false),
|
|
939
|
+
capability: z11.never().optional(),
|
|
1156
940
|
...RequiredRequestErrorShape
|
|
1157
941
|
})
|
|
1158
942
|
]);
|
|
1159
|
-
var ProxyInfoRequestSchema =
|
|
1160
|
-
type:
|
|
943
|
+
var ProxyInfoRequestSchema = z11.object({
|
|
944
|
+
type: z11.literal("proxy_info_request"),
|
|
1161
945
|
...RequestIdShape
|
|
1162
946
|
}).strict();
|
|
1163
|
-
var ProxyInfoResponseSchema =
|
|
1164
|
-
type:
|
|
947
|
+
var ProxyInfoResponseSchema = z11.object({
|
|
948
|
+
type: z11.literal("proxy_info"),
|
|
1165
949
|
...RequestIdShape,
|
|
1166
|
-
homePath:
|
|
950
|
+
homePath: z11.string(),
|
|
1167
951
|
agentCli: AgentCliStatusSchema
|
|
1168
952
|
});
|
|
1169
|
-
var PreviewStaticInspectResponseSchema =
|
|
1170
|
-
|
|
1171
|
-
type:
|
|
953
|
+
var PreviewStaticInspectResponseSchema = z11.discriminatedUnion("success", [
|
|
954
|
+
z11.object({
|
|
955
|
+
type: z11.literal("preview_static_inspect_response"),
|
|
1172
956
|
...RequiredRequestIdShape,
|
|
1173
957
|
scope: PreviewScopeSchema,
|
|
1174
|
-
success:
|
|
958
|
+
success: z11.literal(true),
|
|
1175
959
|
...NoRequestErrorShape,
|
|
1176
960
|
entryPath: WebPreviewPathSchema.optional(),
|
|
1177
961
|
htmlEntries: PreviewHtmlEntriesSchema
|
|
1178
962
|
}),
|
|
1179
|
-
|
|
1180
|
-
type:
|
|
963
|
+
z11.object({
|
|
964
|
+
type: z11.literal("preview_static_inspect_response"),
|
|
1181
965
|
...RequiredRequestIdShape,
|
|
1182
966
|
scope: PreviewScopeSchema,
|
|
1183
|
-
success:
|
|
1184
|
-
entryPath:
|
|
1185
|
-
htmlEntries:
|
|
967
|
+
success: z11.literal(false),
|
|
968
|
+
entryPath: z11.never().optional(),
|
|
969
|
+
htmlEntries: z11.never().optional(),
|
|
1186
970
|
...RequiredRequestErrorShape
|
|
1187
971
|
})
|
|
1188
972
|
]);
|
|
1189
|
-
var PreviewRenameResponseSchema =
|
|
1190
|
-
|
|
1191
|
-
type:
|
|
973
|
+
var PreviewRenameResponseSchema = z11.discriminatedUnion("success", [
|
|
974
|
+
z11.object({
|
|
975
|
+
type: z11.literal("preview_rename_response"),
|
|
1192
976
|
...RequiredRequestIdShape,
|
|
1193
977
|
scope: PreviewScopeSchema,
|
|
1194
978
|
operationId: IdSchema,
|
|
1195
979
|
previewId: IdSchema,
|
|
1196
|
-
success:
|
|
980
|
+
success: z11.literal(true),
|
|
1197
981
|
...NoRequestErrorShape
|
|
1198
982
|
}),
|
|
1199
|
-
|
|
1200
|
-
type:
|
|
983
|
+
z11.object({
|
|
984
|
+
type: z11.literal("preview_rename_response"),
|
|
1201
985
|
...RequiredRequestIdShape,
|
|
1202
986
|
scope: PreviewScopeSchema,
|
|
1203
987
|
operationId: IdSchema,
|
|
1204
988
|
previewId: IdSchema,
|
|
1205
|
-
success:
|
|
989
|
+
success: z11.literal(false),
|
|
1206
990
|
...RequiredRequestErrorShape
|
|
1207
991
|
})
|
|
1208
992
|
]);
|
|
1209
|
-
var PreviewReconnectResponseSchema =
|
|
1210
|
-
|
|
1211
|
-
type:
|
|
993
|
+
var PreviewReconnectResponseSchema = z11.discriminatedUnion("success", [
|
|
994
|
+
z11.object({
|
|
995
|
+
type: z11.literal("preview_reconnect_response"),
|
|
1212
996
|
...RequiredRequestIdShape,
|
|
1213
997
|
scope: PreviewScopeSchema,
|
|
1214
998
|
operationId: IdSchema,
|
|
1215
999
|
previewId: IdSchema,
|
|
1216
|
-
success:
|
|
1000
|
+
success: z11.literal(true),
|
|
1217
1001
|
...NoRequestErrorShape
|
|
1218
1002
|
}),
|
|
1219
|
-
|
|
1220
|
-
type:
|
|
1003
|
+
z11.object({
|
|
1004
|
+
type: z11.literal("preview_reconnect_response"),
|
|
1221
1005
|
...RequiredRequestIdShape,
|
|
1222
1006
|
scope: PreviewScopeSchema,
|
|
1223
1007
|
operationId: IdSchema,
|
|
1224
1008
|
previewId: IdSchema,
|
|
1225
|
-
success:
|
|
1009
|
+
success: z11.literal(false),
|
|
1226
1010
|
...RequiredRequestErrorShape
|
|
1227
1011
|
})
|
|
1228
1012
|
]);
|
|
1229
|
-
var PreviewCloseResponseSchema =
|
|
1230
|
-
|
|
1231
|
-
type:
|
|
1013
|
+
var PreviewCloseResponseSchema = z11.discriminatedUnion("success", [
|
|
1014
|
+
z11.object({
|
|
1015
|
+
type: z11.literal("preview_close_response"),
|
|
1232
1016
|
...RequiredRequestIdShape,
|
|
1233
1017
|
scope: PreviewScopeSchema,
|
|
1234
1018
|
operationId: IdSchema,
|
|
1235
1019
|
previewId: IdSchema,
|
|
1236
|
-
success:
|
|
1020
|
+
success: z11.literal(true),
|
|
1237
1021
|
...NoRequestErrorShape
|
|
1238
1022
|
}),
|
|
1239
|
-
|
|
1240
|
-
type:
|
|
1023
|
+
z11.object({
|
|
1024
|
+
type: z11.literal("preview_close_response"),
|
|
1241
1025
|
...RequiredRequestIdShape,
|
|
1242
1026
|
scope: PreviewScopeSchema,
|
|
1243
1027
|
operationId: IdSchema,
|
|
1244
1028
|
previewId: IdSchema,
|
|
1245
|
-
success:
|
|
1029
|
+
success: z11.literal(false),
|
|
1246
1030
|
...RequiredRequestErrorShape
|
|
1247
1031
|
})
|
|
1248
1032
|
]);
|
|
1249
|
-
var DevicePreviewTargetsResponseSchema =
|
|
1250
|
-
|
|
1251
|
-
type:
|
|
1033
|
+
var DevicePreviewTargetsResponseSchema = z11.discriminatedUnion("success", [
|
|
1034
|
+
z11.object({
|
|
1035
|
+
type: z11.literal("device_preview_targets_response"),
|
|
1252
1036
|
...RequiredRequestIdShape,
|
|
1253
1037
|
scope: PreviewScopeSchema,
|
|
1254
|
-
success:
|
|
1038
|
+
success: z11.literal(true),
|
|
1255
1039
|
...NoRequestErrorShape,
|
|
1256
|
-
targets:
|
|
1040
|
+
targets: z11.array(DevicePreviewTargetSchema).max(1024)
|
|
1257
1041
|
}),
|
|
1258
|
-
|
|
1259
|
-
type:
|
|
1042
|
+
z11.object({
|
|
1043
|
+
type: z11.literal("device_preview_targets_response"),
|
|
1260
1044
|
...RequiredRequestIdShape,
|
|
1261
1045
|
scope: PreviewScopeSchema,
|
|
1262
|
-
success:
|
|
1263
|
-
targets:
|
|
1046
|
+
success: z11.literal(false),
|
|
1047
|
+
targets: z11.never().optional(),
|
|
1264
1048
|
...RequiredRequestErrorShape
|
|
1265
1049
|
})
|
|
1266
1050
|
]);
|
|
1267
|
-
var DevicePreviewRenameResponseSchema =
|
|
1268
|
-
|
|
1269
|
-
type:
|
|
1051
|
+
var DevicePreviewRenameResponseSchema = z11.discriminatedUnion("success", [
|
|
1052
|
+
z11.object({
|
|
1053
|
+
type: z11.literal("device_preview_rename_response"),
|
|
1270
1054
|
...RequiredRequestIdShape,
|
|
1271
1055
|
scope: PreviewScopeSchema,
|
|
1272
1056
|
operationId: IdSchema,
|
|
1273
1057
|
previewId: IdSchema,
|
|
1274
|
-
success:
|
|
1058
|
+
success: z11.literal(true),
|
|
1275
1059
|
...NoRequestErrorShape
|
|
1276
1060
|
}),
|
|
1277
|
-
|
|
1278
|
-
type:
|
|
1061
|
+
z11.object({
|
|
1062
|
+
type: z11.literal("device_preview_rename_response"),
|
|
1279
1063
|
...RequiredRequestIdShape,
|
|
1280
1064
|
scope: PreviewScopeSchema,
|
|
1281
1065
|
operationId: IdSchema,
|
|
1282
1066
|
previewId: IdSchema,
|
|
1283
|
-
success:
|
|
1067
|
+
success: z11.literal(false),
|
|
1284
1068
|
...RequiredRequestErrorShape
|
|
1285
1069
|
})
|
|
1286
1070
|
]);
|
|
1287
|
-
var DevicePreviewReconnectResponseSchema =
|
|
1288
|
-
|
|
1289
|
-
type:
|
|
1071
|
+
var DevicePreviewReconnectResponseSchema = z11.discriminatedUnion("success", [
|
|
1072
|
+
z11.object({
|
|
1073
|
+
type: z11.literal("device_preview_reconnect_response"),
|
|
1290
1074
|
...RequiredRequestIdShape,
|
|
1291
1075
|
scope: PreviewScopeSchema,
|
|
1292
1076
|
operationId: IdSchema,
|
|
1293
1077
|
previewId: IdSchema,
|
|
1294
|
-
success:
|
|
1078
|
+
success: z11.literal(true),
|
|
1295
1079
|
...NoRequestErrorShape
|
|
1296
1080
|
}),
|
|
1297
|
-
|
|
1298
|
-
type:
|
|
1081
|
+
z11.object({
|
|
1082
|
+
type: z11.literal("device_preview_reconnect_response"),
|
|
1299
1083
|
...RequiredRequestIdShape,
|
|
1300
1084
|
scope: PreviewScopeSchema,
|
|
1301
1085
|
operationId: IdSchema,
|
|
1302
1086
|
previewId: IdSchema,
|
|
1303
|
-
success:
|
|
1087
|
+
success: z11.literal(false),
|
|
1304
1088
|
...RequiredRequestErrorShape
|
|
1305
1089
|
})
|
|
1306
1090
|
]);
|
|
1307
|
-
var DevicePreviewCloseResponseSchema =
|
|
1308
|
-
|
|
1309
|
-
type:
|
|
1091
|
+
var DevicePreviewCloseResponseSchema = z11.discriminatedUnion("success", [
|
|
1092
|
+
z11.object({
|
|
1093
|
+
type: z11.literal("device_preview_close_response"),
|
|
1310
1094
|
...RequiredRequestIdShape,
|
|
1311
1095
|
scope: PreviewScopeSchema,
|
|
1312
1096
|
operationId: IdSchema,
|
|
1313
1097
|
previewId: IdSchema,
|
|
1314
|
-
success:
|
|
1098
|
+
success: z11.literal(true),
|
|
1315
1099
|
...NoRequestErrorShape
|
|
1316
1100
|
}),
|
|
1317
|
-
|
|
1318
|
-
type:
|
|
1101
|
+
z11.object({
|
|
1102
|
+
type: z11.literal("device_preview_close_response"),
|
|
1319
1103
|
...RequiredRequestIdShape,
|
|
1320
1104
|
scope: PreviewScopeSchema,
|
|
1321
1105
|
operationId: IdSchema,
|
|
1322
1106
|
previewId: IdSchema,
|
|
1323
|
-
success:
|
|
1107
|
+
success: z11.literal(false),
|
|
1324
1108
|
...RequiredRequestErrorShape
|
|
1325
1109
|
})
|
|
1326
1110
|
]);
|
|
1327
|
-
var DevicePreviewStreamUrlResponseSchema =
|
|
1328
|
-
|
|
1329
|
-
type:
|
|
1111
|
+
var DevicePreviewStreamUrlResponseSchema = z11.discriminatedUnion("success", [
|
|
1112
|
+
z11.object({
|
|
1113
|
+
type: z11.literal("device_preview_stream_url_response"),
|
|
1330
1114
|
...RequiredRequestIdShape,
|
|
1331
1115
|
scope: PreviewScopeSchema,
|
|
1332
1116
|
previewId: IdSchema,
|
|
1333
|
-
success:
|
|
1117
|
+
success: z11.literal(true),
|
|
1334
1118
|
...NoRequestErrorShape,
|
|
1335
|
-
url:
|
|
1119
|
+
url: z11.string().min(1).max(4096),
|
|
1336
1120
|
leaseId: IdSchema,
|
|
1337
|
-
expiresAt:
|
|
1338
|
-
controlMode:
|
|
1121
|
+
expiresAt: z11.number().int().nonnegative(),
|
|
1122
|
+
controlMode: z11.enum(["controller", "view_only"])
|
|
1339
1123
|
}),
|
|
1340
|
-
|
|
1341
|
-
type:
|
|
1124
|
+
z11.object({
|
|
1125
|
+
type: z11.literal("device_preview_stream_url_response"),
|
|
1342
1126
|
...RequiredRequestIdShape,
|
|
1343
1127
|
scope: PreviewScopeSchema,
|
|
1344
1128
|
previewId: IdSchema,
|
|
1345
|
-
success:
|
|
1346
|
-
url:
|
|
1347
|
-
leaseId:
|
|
1348
|
-
expiresAt:
|
|
1349
|
-
controlMode:
|
|
1129
|
+
success: z11.literal(false),
|
|
1130
|
+
url: z11.never().optional(),
|
|
1131
|
+
leaseId: z11.never().optional(),
|
|
1132
|
+
expiresAt: z11.never().optional(),
|
|
1133
|
+
controlMode: z11.never().optional(),
|
|
1350
1134
|
...RequiredRequestErrorShape
|
|
1351
1135
|
})
|
|
1352
1136
|
]);
|
|
1353
1137
|
var DevicePreviewStreamStartResponseBaseShape = {
|
|
1354
|
-
type:
|
|
1138
|
+
type: z11.literal("device_preview_stream_start_response"),
|
|
1355
1139
|
streamId: IdSchema,
|
|
1356
1140
|
leaseId: IdSchema,
|
|
1357
1141
|
previewId: IdSchema
|
|
1358
1142
|
};
|
|
1359
|
-
var DevicePreviewStreamStartSuccessSchema =
|
|
1143
|
+
var DevicePreviewStreamStartSuccessSchema = z11.object({
|
|
1360
1144
|
...DevicePreviewStreamStartResponseBaseShape,
|
|
1361
|
-
success:
|
|
1145
|
+
success: z11.literal(true),
|
|
1362
1146
|
...NoRequestErrorShape,
|
|
1363
1147
|
format: DevicePreviewStreamFormatSchema,
|
|
1364
|
-
width:
|
|
1365
|
-
height:
|
|
1148
|
+
width: z11.number().int().positive().max(16384).optional(),
|
|
1149
|
+
height: z11.number().int().positive().max(16384).optional()
|
|
1366
1150
|
}).superRefine((response, context) => {
|
|
1367
1151
|
if (response.width === void 0 === (response.height === void 0))
|
|
1368
1152
|
return;
|
|
@@ -1372,80 +1156,80 @@ var DevicePreviewStreamStartSuccessSchema = z13.object({
|
|
|
1372
1156
|
message: "Device preview stream dimensions must include both width and height"
|
|
1373
1157
|
});
|
|
1374
1158
|
});
|
|
1375
|
-
var DevicePreviewStreamStartResponseSchema =
|
|
1159
|
+
var DevicePreviewStreamStartResponseSchema = z11.discriminatedUnion("success", [
|
|
1376
1160
|
DevicePreviewStreamStartSuccessSchema,
|
|
1377
|
-
|
|
1161
|
+
z11.object({
|
|
1378
1162
|
...DevicePreviewStreamStartResponseBaseShape,
|
|
1379
|
-
success:
|
|
1380
|
-
format:
|
|
1381
|
-
width:
|
|
1382
|
-
height:
|
|
1163
|
+
success: z11.literal(false),
|
|
1164
|
+
format: z11.never().optional(),
|
|
1165
|
+
width: z11.never().optional(),
|
|
1166
|
+
height: z11.never().optional(),
|
|
1383
1167
|
...RequiredRequestErrorShape
|
|
1384
1168
|
})
|
|
1385
1169
|
]);
|
|
1386
|
-
var DevicePreviewStreamCompleteSchema =
|
|
1387
|
-
type:
|
|
1170
|
+
var DevicePreviewStreamCompleteSchema = z11.object({
|
|
1171
|
+
type: z11.literal("device_preview_stream_complete"),
|
|
1388
1172
|
streamId: IdSchema,
|
|
1389
1173
|
leaseId: IdSchema,
|
|
1390
1174
|
previewId: IdSchema,
|
|
1391
|
-
success:
|
|
1392
|
-
error:
|
|
1175
|
+
success: z11.literal(false),
|
|
1176
|
+
error: z11.string().min(1)
|
|
1393
1177
|
});
|
|
1394
1178
|
var DevicePreviewStreamStartBaseShape = {
|
|
1395
|
-
type:
|
|
1179
|
+
type: z11.literal("device_preview_stream_start"),
|
|
1396
1180
|
streamId: IdSchema,
|
|
1397
1181
|
leaseId: IdSchema,
|
|
1398
1182
|
previewId: IdSchema
|
|
1399
1183
|
};
|
|
1400
|
-
var DevicePreviewStreamStartSchema =
|
|
1401
|
-
|
|
1184
|
+
var DevicePreviewStreamStartSchema = z11.discriminatedUnion("format", [
|
|
1185
|
+
z11.object({
|
|
1402
1186
|
...DevicePreviewStreamStartBaseShape,
|
|
1403
1187
|
...DevicePreviewJpegStreamProfileSchema.shape
|
|
1404
1188
|
}).strict(),
|
|
1405
|
-
|
|
1189
|
+
z11.object({
|
|
1406
1190
|
...DevicePreviewStreamStartBaseShape,
|
|
1407
1191
|
...DevicePreviewH264StreamProfileSchema.shape
|
|
1408
1192
|
}).strict()
|
|
1409
1193
|
]);
|
|
1410
|
-
var DevicePreviewInputAckSchema =
|
|
1411
|
-
|
|
1412
|
-
type:
|
|
1194
|
+
var DevicePreviewInputAckSchema = z11.discriminatedUnion("success", [
|
|
1195
|
+
z11.object({
|
|
1196
|
+
type: z11.literal("device_preview_input_ack"),
|
|
1413
1197
|
scope: PreviewScopeSchema,
|
|
1414
1198
|
leaseId: IdSchema,
|
|
1415
|
-
inputSeq:
|
|
1416
|
-
success:
|
|
1199
|
+
inputSeq: z11.number().int().min(0).max(4294967295),
|
|
1200
|
+
success: z11.literal(true),
|
|
1417
1201
|
...NoRequestErrorShape
|
|
1418
1202
|
}),
|
|
1419
|
-
|
|
1420
|
-
type:
|
|
1203
|
+
z11.object({
|
|
1204
|
+
type: z11.literal("device_preview_input_ack"),
|
|
1421
1205
|
scope: PreviewScopeSchema,
|
|
1422
1206
|
leaseId: IdSchema,
|
|
1423
|
-
inputSeq:
|
|
1424
|
-
success:
|
|
1207
|
+
inputSeq: z11.number().int().min(0).max(4294967295),
|
|
1208
|
+
success: z11.literal(false),
|
|
1425
1209
|
...RequiredRequestErrorShape
|
|
1426
1210
|
})
|
|
1427
1211
|
]);
|
|
1428
|
-
var DevicePreviewControlClaimResponseSchema =
|
|
1429
|
-
|
|
1430
|
-
type:
|
|
1212
|
+
var DevicePreviewControlClaimResponseSchema = z11.discriminatedUnion("success", [
|
|
1213
|
+
z11.object({
|
|
1214
|
+
type: z11.literal("device_preview_control_claim_response"),
|
|
1431
1215
|
...RequiredRequestIdShape,
|
|
1432
1216
|
scope: PreviewScopeSchema,
|
|
1433
1217
|
leaseId: IdSchema,
|
|
1434
|
-
success:
|
|
1218
|
+
success: z11.literal(true),
|
|
1435
1219
|
...NoRequestErrorShape,
|
|
1436
|
-
controlMode:
|
|
1220
|
+
controlMode: z11.literal("controller")
|
|
1437
1221
|
}),
|
|
1438
|
-
|
|
1439
|
-
type:
|
|
1222
|
+
z11.object({
|
|
1223
|
+
type: z11.literal("device_preview_control_claim_response"),
|
|
1440
1224
|
...RequiredRequestIdShape,
|
|
1441
1225
|
scope: PreviewScopeSchema,
|
|
1442
1226
|
leaseId: IdSchema,
|
|
1443
|
-
success:
|
|
1444
|
-
controlMode:
|
|
1227
|
+
success: z11.literal(false),
|
|
1228
|
+
controlMode: z11.never().optional(),
|
|
1445
1229
|
...RequiredRequestErrorShape
|
|
1446
1230
|
})
|
|
1447
1231
|
]);
|
|
1448
|
-
var SessionPermissionModeSchema =
|
|
1232
|
+
var SessionPermissionModeSchema = z11.enum([
|
|
1449
1233
|
"default",
|
|
1450
1234
|
"auto",
|
|
1451
1235
|
"acceptEdits",
|
|
@@ -1453,111 +1237,111 @@ var SessionPermissionModeSchema = z13.enum([
|
|
|
1453
1237
|
"bypassPermissions",
|
|
1454
1238
|
"dontAsk"
|
|
1455
1239
|
]);
|
|
1456
|
-
var AgentJsonSessionCreateSchema =
|
|
1457
|
-
type:
|
|
1240
|
+
var AgentJsonSessionCreateSchema = z11.object({
|
|
1241
|
+
type: z11.literal("session_create"),
|
|
1458
1242
|
...RequiredRequestIdShape,
|
|
1459
|
-
kind:
|
|
1460
|
-
cwd:
|
|
1461
|
-
name:
|
|
1462
|
-
provider:
|
|
1463
|
-
mode:
|
|
1464
|
-
resumeSessionId:
|
|
1243
|
+
kind: z11.literal("agent"),
|
|
1244
|
+
cwd: z11.string(),
|
|
1245
|
+
name: z11.string().optional(),
|
|
1246
|
+
provider: z11.enum(providerValues),
|
|
1247
|
+
mode: z11.literal("json"),
|
|
1248
|
+
resumeSessionId: z11.string().optional(),
|
|
1465
1249
|
permissionMode: SessionPermissionModeSchema.optional()
|
|
1466
1250
|
}).strict();
|
|
1467
|
-
var AgentPtySessionCreateSchema =
|
|
1468
|
-
type:
|
|
1251
|
+
var AgentPtySessionCreateSchema = z11.object({
|
|
1252
|
+
type: z11.literal("session_create"),
|
|
1469
1253
|
...RequiredRequestIdShape,
|
|
1470
|
-
kind:
|
|
1471
|
-
cwd:
|
|
1472
|
-
name:
|
|
1473
|
-
provider:
|
|
1474
|
-
mode:
|
|
1475
|
-
resumeSessionId:
|
|
1476
|
-
cols:
|
|
1477
|
-
rows:
|
|
1254
|
+
kind: z11.literal("agent"),
|
|
1255
|
+
cwd: z11.string(),
|
|
1256
|
+
name: z11.string().optional(),
|
|
1257
|
+
provider: z11.enum(providerValues),
|
|
1258
|
+
mode: z11.literal("pty"),
|
|
1259
|
+
resumeSessionId: z11.string().optional(),
|
|
1260
|
+
cols: z11.number().int().positive().max(PTY_INITIAL_MAX_COLS),
|
|
1261
|
+
rows: z11.number().int().positive().max(PTY_INITIAL_MAX_ROWS),
|
|
1478
1262
|
permissionMode: SessionPermissionModeSchema.optional()
|
|
1479
1263
|
}).strict();
|
|
1480
|
-
var TerminalSessionCreateSchema =
|
|
1481
|
-
type:
|
|
1264
|
+
var TerminalSessionCreateSchema = z11.object({
|
|
1265
|
+
type: z11.literal("session_create"),
|
|
1482
1266
|
...RequiredRequestIdShape,
|
|
1483
|
-
kind:
|
|
1484
|
-
name:
|
|
1485
|
-
mode:
|
|
1486
|
-
cols:
|
|
1487
|
-
rows:
|
|
1267
|
+
kind: z11.literal("terminal"),
|
|
1268
|
+
name: z11.string().optional(),
|
|
1269
|
+
mode: z11.literal("pty"),
|
|
1270
|
+
cols: z11.number().int().positive().max(PTY_INITIAL_MAX_COLS),
|
|
1271
|
+
rows: z11.number().int().positive().max(PTY_INITIAL_MAX_ROWS)
|
|
1488
1272
|
}).strict();
|
|
1489
|
-
var SessionCreateSchema =
|
|
1273
|
+
var SessionCreateSchema = z11.discriminatedUnion("mode", [
|
|
1490
1274
|
AgentJsonSessionCreateSchema,
|
|
1491
|
-
|
|
1275
|
+
z11.discriminatedUnion("kind", [AgentPtySessionCreateSchema, TerminalSessionCreateSchema])
|
|
1492
1276
|
]);
|
|
1493
1277
|
var SessionCreateSuccessBaseShape = {
|
|
1494
1278
|
...NoRequestErrorShape,
|
|
1495
|
-
activeWriterPid:
|
|
1496
|
-
type:
|
|
1279
|
+
activeWriterPid: z11.never().optional(),
|
|
1280
|
+
type: z11.literal("session_create_response"),
|
|
1497
1281
|
...RequiredRequestIdShape,
|
|
1498
|
-
success:
|
|
1282
|
+
success: z11.literal(true),
|
|
1499
1283
|
sessionId: IdSchema,
|
|
1500
|
-
cwd:
|
|
1501
|
-
lastActive:
|
|
1502
|
-
name:
|
|
1503
|
-
nameLocked:
|
|
1284
|
+
cwd: z11.string(),
|
|
1285
|
+
lastActive: z11.number(),
|
|
1286
|
+
name: z11.string().optional(),
|
|
1287
|
+
nameLocked: z11.boolean().optional()
|
|
1504
1288
|
};
|
|
1505
|
-
var SessionCreateSuccessResponseSchema =
|
|
1506
|
-
|
|
1289
|
+
var SessionCreateSuccessResponseSchema = z11.discriminatedUnion("mode", [
|
|
1290
|
+
z11.object({
|
|
1507
1291
|
...SessionCreateSuccessBaseShape,
|
|
1508
|
-
kind:
|
|
1509
|
-
mode:
|
|
1510
|
-
ptyOwner:
|
|
1511
|
-
provider:
|
|
1292
|
+
kind: z11.literal("agent"),
|
|
1293
|
+
mode: z11.literal("json"),
|
|
1294
|
+
ptyOwner: z11.never().optional(),
|
|
1295
|
+
provider: z11.enum(providerValues)
|
|
1512
1296
|
}),
|
|
1513
|
-
|
|
1514
|
-
|
|
1297
|
+
z11.discriminatedUnion("kind", [
|
|
1298
|
+
z11.object({
|
|
1515
1299
|
...SessionCreateSuccessBaseShape,
|
|
1516
|
-
kind:
|
|
1517
|
-
mode:
|
|
1518
|
-
provider:
|
|
1519
|
-
ptyOwner:
|
|
1300
|
+
kind: z11.literal("agent"),
|
|
1301
|
+
mode: z11.literal("pty"),
|
|
1302
|
+
provider: z11.enum(providerValues),
|
|
1303
|
+
ptyOwner: z11.enum(ptyOwnerValues)
|
|
1520
1304
|
}),
|
|
1521
|
-
|
|
1305
|
+
z11.object({
|
|
1522
1306
|
...SessionCreateSuccessBaseShape,
|
|
1523
|
-
kind:
|
|
1524
|
-
mode:
|
|
1525
|
-
provider:
|
|
1526
|
-
ptyOwner:
|
|
1307
|
+
kind: z11.literal("terminal"),
|
|
1308
|
+
mode: z11.literal("pty"),
|
|
1309
|
+
provider: z11.literal("claude"),
|
|
1310
|
+
ptyOwner: z11.literal("proxy-hosted")
|
|
1527
1311
|
})
|
|
1528
1312
|
])
|
|
1529
1313
|
]);
|
|
1530
|
-
var SessionCreateResponseSchema =
|
|
1314
|
+
var SessionCreateResponseSchema = z11.discriminatedUnion("success", [
|
|
1531
1315
|
SessionCreateSuccessResponseSchema,
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1316
|
+
z11.object({
|
|
1317
|
+
type: z11.literal("session_create_response"),
|
|
1534
1318
|
...RequiredRequestIdShape,
|
|
1535
|
-
success:
|
|
1536
|
-
sessionId:
|
|
1537
|
-
cwd:
|
|
1538
|
-
lastActive:
|
|
1539
|
-
name:
|
|
1540
|
-
nameLocked:
|
|
1541
|
-
kind:
|
|
1542
|
-
mode:
|
|
1543
|
-
provider:
|
|
1544
|
-
ptyOwner:
|
|
1319
|
+
success: z11.literal(false),
|
|
1320
|
+
sessionId: z11.never().optional(),
|
|
1321
|
+
cwd: z11.never().optional(),
|
|
1322
|
+
lastActive: z11.never().optional(),
|
|
1323
|
+
name: z11.never().optional(),
|
|
1324
|
+
nameLocked: z11.never().optional(),
|
|
1325
|
+
kind: z11.never().optional(),
|
|
1326
|
+
mode: z11.never().optional(),
|
|
1327
|
+
provider: z11.never().optional(),
|
|
1328
|
+
ptyOwner: z11.never().optional(),
|
|
1545
1329
|
...RequiredRequestErrorShape,
|
|
1546
|
-
activeWriterPid:
|
|
1330
|
+
activeWriterPid: z11.number().int().positive().optional()
|
|
1547
1331
|
})
|
|
1548
1332
|
]);
|
|
1549
1333
|
var relayControlDefinitions = [
|
|
1550
1334
|
control("proxy_register", {
|
|
1551
|
-
protocolVersion:
|
|
1335
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
1552
1336
|
proxyId: IdSchema,
|
|
1553
|
-
name:
|
|
1554
|
-
osName:
|
|
1555
|
-
proxyVersion:
|
|
1337
|
+
name: z11.string().optional(),
|
|
1338
|
+
osName: z11.string().min(1).max(64).optional(),
|
|
1339
|
+
proxyVersion: z11.string().min(1).max(64)
|
|
1556
1340
|
}),
|
|
1557
1341
|
control("proxy_register_response", {
|
|
1558
|
-
protocolVersion:
|
|
1559
|
-
status:
|
|
1560
|
-
relayVersion:
|
|
1342
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
1343
|
+
status: z11.enum(["new", "reconnected"]),
|
|
1344
|
+
relayVersion: z11.string().min(1).max(64),
|
|
1561
1345
|
// Relay rotates this nonce for every successful main Proxy registration. The dedicated image
|
|
1562
1346
|
// stream socket must present it before Relay accepts frames, so a superseded Proxy connection
|
|
1563
1347
|
// cannot keep publishing into a newly registered Proxy with the same persistent proxyId.
|
|
@@ -1566,7 +1350,7 @@ var relayControlDefinitions = [
|
|
|
1566
1350
|
control("proxy_list_request", RequestIdShape),
|
|
1567
1351
|
control("proxy_list_response", {
|
|
1568
1352
|
...RequestIdShape,
|
|
1569
|
-
proxies:
|
|
1353
|
+
proxies: z11.array(ProxyInfoSchema)
|
|
1570
1354
|
}),
|
|
1571
1355
|
control("proxy_remove", {
|
|
1572
1356
|
...RequiredRequestIdShape,
|
|
@@ -1575,74 +1359,74 @@ var relayControlDefinitions = [
|
|
|
1575
1359
|
control("proxy_remove_response", {
|
|
1576
1360
|
...RequiredRequestIdShape,
|
|
1577
1361
|
proxyId: IdSchema,
|
|
1578
|
-
success:
|
|
1362
|
+
success: z11.boolean(),
|
|
1579
1363
|
...RequestErrorShape
|
|
1580
1364
|
}),
|
|
1581
1365
|
control("relay_client_list_request", RequestIdShape),
|
|
1582
1366
|
control("relay_client_list_response", {
|
|
1583
1367
|
...RequestIdShape,
|
|
1584
|
-
clients:
|
|
1368
|
+
clients: z11.array(RelayClientInfoSchema)
|
|
1585
1369
|
}),
|
|
1586
1370
|
control("relay_client_kick", { ...RequiredRequestIdShape, clientId: IdSchema }),
|
|
1587
1371
|
control("relay_client_kick_response", {
|
|
1588
1372
|
...RequiredRequestIdShape,
|
|
1589
1373
|
clientId: IdSchema,
|
|
1590
|
-
success:
|
|
1374
|
+
success: z11.boolean(),
|
|
1591
1375
|
...RequestErrorShape
|
|
1592
1376
|
}),
|
|
1593
1377
|
control("relay_client_kicked", {
|
|
1594
|
-
reason:
|
|
1378
|
+
reason: z11.string().optional()
|
|
1595
1379
|
}),
|
|
1596
1380
|
control("remote_file_url_request", {
|
|
1597
1381
|
...RequiredRequestIdShape,
|
|
1598
1382
|
sessionId: IdSchema,
|
|
1599
|
-
path:
|
|
1383
|
+
path: z11.string().min(1),
|
|
1600
1384
|
disposition: RemoteFileDispositionSchema
|
|
1601
1385
|
}),
|
|
1602
1386
|
control("remote_file_url_response", {
|
|
1603
1387
|
...RequiredRequestIdShape,
|
|
1604
1388
|
...RequestErrorShape,
|
|
1605
1389
|
sessionId: IdSchema,
|
|
1606
|
-
path:
|
|
1607
|
-
success:
|
|
1608
|
-
url:
|
|
1609
|
-
expiresAt:
|
|
1390
|
+
path: z11.string().optional(),
|
|
1391
|
+
success: z11.boolean(),
|
|
1392
|
+
url: z11.string().optional(),
|
|
1393
|
+
expiresAt: z11.number().int().nonnegative().optional()
|
|
1610
1394
|
}),
|
|
1611
1395
|
control("remote_file_metadata_request", {
|
|
1612
1396
|
...RequiredRequestIdShape,
|
|
1613
1397
|
sessionId: IdSchema,
|
|
1614
|
-
path:
|
|
1398
|
+
path: z11.string().min(1)
|
|
1615
1399
|
}),
|
|
1616
1400
|
control("remote_file_metadata_response", {
|
|
1617
1401
|
...RequiredRequestIdShape,
|
|
1618
1402
|
...RequestErrorShape,
|
|
1619
1403
|
sessionId: IdSchema,
|
|
1620
|
-
path:
|
|
1621
|
-
success:
|
|
1622
|
-
mimeType:
|
|
1623
|
-
size:
|
|
1624
|
-
fileName:
|
|
1404
|
+
path: z11.string().optional(),
|
|
1405
|
+
success: z11.boolean(),
|
|
1406
|
+
mimeType: z11.string().optional(),
|
|
1407
|
+
size: z11.number().int().nonnegative().optional(),
|
|
1408
|
+
fileName: z11.string().optional()
|
|
1625
1409
|
}),
|
|
1626
1410
|
control("remote_file_stream_request", {
|
|
1627
1411
|
streamId: IdSchema,
|
|
1628
1412
|
sessionId: IdSchema,
|
|
1629
|
-
path:
|
|
1413
|
+
path: z11.string().min(1),
|
|
1630
1414
|
disposition: RemoteFileDispositionSchema
|
|
1631
1415
|
}),
|
|
1632
1416
|
control("remote_file_stream_response", {
|
|
1633
1417
|
...RequestErrorShape,
|
|
1634
1418
|
streamId: IdSchema,
|
|
1635
1419
|
sessionId: IdSchema,
|
|
1636
|
-
success:
|
|
1637
|
-
path:
|
|
1638
|
-
mimeType:
|
|
1639
|
-
size:
|
|
1640
|
-
fileName:
|
|
1420
|
+
success: z11.boolean(),
|
|
1421
|
+
path: z11.string().optional(),
|
|
1422
|
+
mimeType: z11.string().optional(),
|
|
1423
|
+
size: z11.number().int().nonnegative().optional(),
|
|
1424
|
+
fileName: z11.string().optional()
|
|
1641
1425
|
}),
|
|
1642
1426
|
control("remote_file_stream_complete", {
|
|
1643
1427
|
...RequestErrorShape,
|
|
1644
1428
|
streamId: IdSchema,
|
|
1645
|
-
success:
|
|
1429
|
+
success: z11.boolean()
|
|
1646
1430
|
}),
|
|
1647
1431
|
control("remote_file_stream_cancel", {
|
|
1648
1432
|
streamId: IdSchema
|
|
@@ -1651,25 +1435,25 @@ var relayControlDefinitions = [
|
|
|
1651
1435
|
...RequiredRequestIdShape,
|
|
1652
1436
|
sessionId: IdSchema,
|
|
1653
1437
|
kind: RemoteFileUploadKindSchema,
|
|
1654
|
-
fileName:
|
|
1655
|
-
mimeType:
|
|
1656
|
-
size:
|
|
1438
|
+
fileName: z11.string().optional(),
|
|
1439
|
+
mimeType: z11.string().min(1),
|
|
1440
|
+
size: z11.number().int().nonnegative().optional()
|
|
1657
1441
|
}),
|
|
1658
1442
|
control("remote_file_upload_url_response", {
|
|
1659
1443
|
...RequiredRequestIdShape,
|
|
1660
1444
|
...RequestErrorShape,
|
|
1661
1445
|
sessionId: IdSchema,
|
|
1662
|
-
success:
|
|
1663
|
-
uploadUrl:
|
|
1664
|
-
expiresAt:
|
|
1446
|
+
success: z11.boolean(),
|
|
1447
|
+
uploadUrl: z11.string().optional(),
|
|
1448
|
+
expiresAt: z11.number().int().nonnegative().optional()
|
|
1665
1449
|
}),
|
|
1666
1450
|
control("remote_file_upload_stream_request", {
|
|
1667
1451
|
uploadId: IdSchema,
|
|
1668
1452
|
sessionId: IdSchema,
|
|
1669
1453
|
kind: RemoteFileUploadKindSchema,
|
|
1670
|
-
fileName:
|
|
1671
|
-
mimeType:
|
|
1672
|
-
size:
|
|
1454
|
+
fileName: z11.string().optional(),
|
|
1455
|
+
mimeType: z11.string().min(1),
|
|
1456
|
+
size: z11.number().int().nonnegative().optional()
|
|
1673
1457
|
}),
|
|
1674
1458
|
control("remote_file_upload_stream_complete", {
|
|
1675
1459
|
uploadId: IdSchema
|
|
@@ -1681,14 +1465,14 @@ var relayControlDefinitions = [
|
|
|
1681
1465
|
...RequestErrorShape,
|
|
1682
1466
|
uploadId: IdSchema,
|
|
1683
1467
|
sessionId: IdSchema,
|
|
1684
|
-
success:
|
|
1685
|
-
path:
|
|
1468
|
+
success: z11.boolean(),
|
|
1469
|
+
path: z11.string().optional()
|
|
1686
1470
|
}),
|
|
1687
1471
|
control("proxy_select", { ...RequestIdShape, proxyId: IdSchema }),
|
|
1688
1472
|
controlSchema("proxy_select_response", ProxySelectResponseSchema),
|
|
1689
1473
|
control("relay_error", {
|
|
1690
|
-
code:
|
|
1691
|
-
message:
|
|
1474
|
+
code: z11.enum(Object.values(RelayErrorCode)),
|
|
1475
|
+
message: z11.string(),
|
|
1692
1476
|
// 可选 requestId: relay 把 client 发来 raw 的 requestId 字段透传回来,
|
|
1693
1477
|
// client 侧 waitForMessage 据此把对应 pending request 立即拒掉而不必等到 timeout。
|
|
1694
1478
|
requestId: IdSchema.optional()
|
|
@@ -1707,7 +1491,7 @@ var relayControlDefinitions = [
|
|
|
1707
1491
|
control("voice_config_update_response", {
|
|
1708
1492
|
...RequestIdShape,
|
|
1709
1493
|
...RequestErrorShape,
|
|
1710
|
-
success:
|
|
1494
|
+
success: z11.boolean(),
|
|
1711
1495
|
config: VoiceProviderConfigSchema.optional()
|
|
1712
1496
|
}),
|
|
1713
1497
|
control("voice_config_test", {
|
|
@@ -1717,15 +1501,15 @@ var relayControlDefinitions = [
|
|
|
1717
1501
|
control("voice_config_test_response", {
|
|
1718
1502
|
...RequestIdShape,
|
|
1719
1503
|
...RequestErrorShape,
|
|
1720
|
-
success:
|
|
1721
|
-
audioBase64:
|
|
1722
|
-
audioSampleRate:
|
|
1723
|
-
audioEncoding:
|
|
1724
|
-
transcript:
|
|
1504
|
+
success: z11.boolean(),
|
|
1505
|
+
audioBase64: z11.string().optional(),
|
|
1506
|
+
audioSampleRate: z11.number().int().positive().optional(),
|
|
1507
|
+
audioEncoding: z11.literal("pcm_s16le").optional(),
|
|
1508
|
+
transcript: z11.string().optional()
|
|
1725
1509
|
}),
|
|
1726
1510
|
control("voice_capabilities_request", {
|
|
1727
1511
|
...RequestIdShape,
|
|
1728
|
-
region:
|
|
1512
|
+
region: z11.enum(voiceRegionValues).optional()
|
|
1729
1513
|
}),
|
|
1730
1514
|
control("voice_capabilities_response", {
|
|
1731
1515
|
...RequestIdShape,
|
|
@@ -1737,31 +1521,31 @@ var relayControlDefinitions = [
|
|
|
1737
1521
|
control("latency_web_relay_ping", RequiredRequestIdShape),
|
|
1738
1522
|
control("latency_web_relay_pong", {
|
|
1739
1523
|
...RequiredRequestIdShape,
|
|
1740
|
-
relayNow:
|
|
1524
|
+
relayNow: z11.number().optional()
|
|
1741
1525
|
}),
|
|
1742
1526
|
control("latency_relay_proxy_request", RequiredRequestIdShape),
|
|
1743
1527
|
control("latency_relay_proxy_response", {
|
|
1744
1528
|
...RequiredRequestIdShape,
|
|
1745
|
-
success:
|
|
1746
|
-
rttMs:
|
|
1747
|
-
error:
|
|
1529
|
+
success: z11.boolean(),
|
|
1530
|
+
rttMs: z11.number().nonnegative().optional(),
|
|
1531
|
+
error: z11.string().optional()
|
|
1748
1532
|
}),
|
|
1749
1533
|
control("latency_relay_proxy_ping", {
|
|
1750
1534
|
...RequiredRequestIdShape,
|
|
1751
|
-
relayNow:
|
|
1535
|
+
relayNow: z11.number().optional()
|
|
1752
1536
|
}),
|
|
1753
1537
|
control("latency_relay_proxy_pong", {
|
|
1754
1538
|
...RequiredRequestIdShape,
|
|
1755
|
-
proxyNow:
|
|
1539
|
+
proxyNow: z11.number().optional()
|
|
1756
1540
|
}),
|
|
1757
1541
|
control("latency_web_proxy_ping", RequiredRequestIdShape, "client_to_proxy"),
|
|
1758
|
-
control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow:
|
|
1542
|
+
control("latency_web_proxy_pong", { ...RequiredRequestIdShape, proxyNow: z11.number().optional() }, "proxy_to_client"),
|
|
1759
1543
|
// Web preview is independent from Agent/terminal sessions. Relay rewrites requestId and routes
|
|
1760
1544
|
// every response to the exact requesting WebSocket; only the two push messages are broadcast.
|
|
1761
1545
|
strictControl("preview_capability_request", {
|
|
1762
1546
|
...RequiredRequestIdShape,
|
|
1763
1547
|
scope: PreviewScopeSchema,
|
|
1764
|
-
refreshPath:
|
|
1548
|
+
refreshPath: z11.boolean()
|
|
1765
1549
|
}, "client_to_proxy"),
|
|
1766
1550
|
controlSchema("preview_capability_response", PreviewCapabilityResponseSchema, "proxy_to_client"),
|
|
1767
1551
|
strictControl("preview_static_inspect_request", {
|
|
@@ -1784,8 +1568,8 @@ var relayControlDefinitions = [
|
|
|
1784
1568
|
...RequiredRequestIdShape,
|
|
1785
1569
|
scope: PreviewScopeSchema,
|
|
1786
1570
|
epoch: IdSchema,
|
|
1787
|
-
revision:
|
|
1788
|
-
previews:
|
|
1571
|
+
revision: z11.number().int().nonnegative(),
|
|
1572
|
+
previews: z11.array(PreviewSummarySchema)
|
|
1789
1573
|
}, "proxy_to_client"),
|
|
1790
1574
|
strictControl("preview_rename_request", {
|
|
1791
1575
|
...RequiredRequestIdShape,
|
|
@@ -1811,24 +1595,24 @@ var relayControlDefinitions = [
|
|
|
1811
1595
|
controlSchema("preview_close_response", PreviewCloseResponseSchema, "proxy_to_client"),
|
|
1812
1596
|
control("preview_state_event", {
|
|
1813
1597
|
epoch: IdSchema,
|
|
1814
|
-
revision:
|
|
1598
|
+
revision: z11.number().int().nonnegative(),
|
|
1815
1599
|
preview: PreviewSummarySchema
|
|
1816
1600
|
}),
|
|
1817
1601
|
control("preview_removed_event", {
|
|
1818
1602
|
epoch: IdSchema,
|
|
1819
|
-
revision:
|
|
1603
|
+
revision: z11.number().int().nonnegative(),
|
|
1820
1604
|
previewId: IdSchema
|
|
1821
1605
|
}),
|
|
1822
1606
|
control("preview_state_push", {
|
|
1823
1607
|
scope: PreviewScopeSchema,
|
|
1824
1608
|
epoch: IdSchema,
|
|
1825
|
-
revision:
|
|
1609
|
+
revision: z11.number().int().nonnegative(),
|
|
1826
1610
|
preview: PreviewSummarySchema
|
|
1827
1611
|
}, "proxy_to_client"),
|
|
1828
1612
|
control("preview_removed_push", {
|
|
1829
1613
|
scope: PreviewScopeSchema,
|
|
1830
1614
|
epoch: IdSchema,
|
|
1831
|
-
revision:
|
|
1615
|
+
revision: z11.number().int().nonnegative(),
|
|
1832
1616
|
previewId: IdSchema
|
|
1833
1617
|
}, "proxy_to_client"),
|
|
1834
1618
|
// Device previews are a sibling of Web previews under the product-level Preview entry, but
|
|
@@ -1837,13 +1621,13 @@ var relayControlDefinitions = [
|
|
|
1837
1621
|
strictControl("device_preview_capability_request", {
|
|
1838
1622
|
...RequiredRequestIdShape,
|
|
1839
1623
|
scope: PreviewScopeSchema,
|
|
1840
|
-
refreshPath:
|
|
1624
|
+
refreshPath: z11.boolean()
|
|
1841
1625
|
}, "client_to_proxy"),
|
|
1842
1626
|
controlSchema("device_preview_capability_response", DevicePreviewCapabilityResponseSchema, "proxy_to_client"),
|
|
1843
1627
|
strictControl("device_preview_targets_request", {
|
|
1844
1628
|
...RequiredRequestIdShape,
|
|
1845
1629
|
scope: PreviewScopeSchema,
|
|
1846
|
-
refresh:
|
|
1630
|
+
refresh: z11.boolean()
|
|
1847
1631
|
}, "client_to_proxy"),
|
|
1848
1632
|
controlSchema("device_preview_targets_response", DevicePreviewTargetsResponseSchema, "proxy_to_client"),
|
|
1849
1633
|
strictControl("device_preview_create_request", {
|
|
@@ -1859,8 +1643,8 @@ var relayControlDefinitions = [
|
|
|
1859
1643
|
...RequiredRequestIdShape,
|
|
1860
1644
|
scope: PreviewScopeSchema,
|
|
1861
1645
|
epoch: IdSchema,
|
|
1862
|
-
revision:
|
|
1863
|
-
previews:
|
|
1646
|
+
revision: z11.number().int().nonnegative(),
|
|
1647
|
+
previews: z11.array(DevicePreviewSummarySchema).max(1024)
|
|
1864
1648
|
}, "proxy_to_client"),
|
|
1865
1649
|
strictControl("device_preview_rename_request", {
|
|
1866
1650
|
...RequiredRequestIdShape,
|
|
@@ -1886,24 +1670,24 @@ var relayControlDefinitions = [
|
|
|
1886
1670
|
controlSchema("device_preview_close_response", DevicePreviewCloseResponseSchema, "proxy_to_client"),
|
|
1887
1671
|
control("device_preview_state_event", {
|
|
1888
1672
|
epoch: IdSchema,
|
|
1889
|
-
revision:
|
|
1673
|
+
revision: z11.number().int().nonnegative(),
|
|
1890
1674
|
preview: DevicePreviewSummarySchema
|
|
1891
1675
|
}),
|
|
1892
1676
|
control("device_preview_removed_event", {
|
|
1893
1677
|
epoch: IdSchema,
|
|
1894
|
-
revision:
|
|
1678
|
+
revision: z11.number().int().nonnegative(),
|
|
1895
1679
|
previewId: IdSchema
|
|
1896
1680
|
}),
|
|
1897
1681
|
control("device_preview_state_push", {
|
|
1898
1682
|
scope: PreviewScopeSchema,
|
|
1899
1683
|
epoch: IdSchema,
|
|
1900
|
-
revision:
|
|
1684
|
+
revision: z11.number().int().nonnegative(),
|
|
1901
1685
|
preview: DevicePreviewSummarySchema
|
|
1902
1686
|
}, "proxy_to_client"),
|
|
1903
1687
|
control("device_preview_removed_push", {
|
|
1904
1688
|
scope: PreviewScopeSchema,
|
|
1905
1689
|
epoch: IdSchema,
|
|
1906
|
-
revision:
|
|
1690
|
+
revision: z11.number().int().nonnegative(),
|
|
1907
1691
|
previewId: IdSchema
|
|
1908
1692
|
}, "proxy_to_client"),
|
|
1909
1693
|
strictControl("device_preview_stream_url_request", {
|
|
@@ -1923,7 +1707,7 @@ var relayControlDefinitions = [
|
|
|
1923
1707
|
strictControl("device_preview_input", {
|
|
1924
1708
|
scope: PreviewScopeSchema,
|
|
1925
1709
|
leaseId: IdSchema,
|
|
1926
|
-
inputSeq:
|
|
1710
|
+
inputSeq: z11.number().int().min(0).max(4294967295),
|
|
1927
1711
|
input: DevicePreviewInputSchema
|
|
1928
1712
|
}, "client_to_proxy"),
|
|
1929
1713
|
controlSchema("device_preview_input_ack", DevicePreviewInputAckSchema, "proxy_to_client"),
|
|
@@ -1931,7 +1715,7 @@ var relayControlDefinitions = [
|
|
|
1931
1715
|
// browsers cannot abort another viewer's queued input, and Proxy never sends it to browsers.
|
|
1932
1716
|
strictControl("device_preview_input_revoke", {
|
|
1933
1717
|
leaseId: IdSchema,
|
|
1934
|
-
reason:
|
|
1718
|
+
reason: z11.literal("control_taken_over")
|
|
1935
1719
|
}),
|
|
1936
1720
|
strictControl("device_preview_control_claim_request", {
|
|
1937
1721
|
...RequiredRequestIdShape,
|
|
@@ -1942,18 +1726,18 @@ var relayControlDefinitions = [
|
|
|
1942
1726
|
control("device_preview_control_revoked_push", {
|
|
1943
1727
|
scope: PreviewScopeSchema,
|
|
1944
1728
|
leaseId: IdSchema,
|
|
1945
|
-
reason:
|
|
1729
|
+
reason: z11.enum(["taken_over", "stream_closed", "proxy_offline", "lease_expired"])
|
|
1946
1730
|
}),
|
|
1947
1731
|
// 客户端注册协议
|
|
1948
1732
|
control("client_register", {
|
|
1949
|
-
protocolVersion:
|
|
1733
|
+
protocolVersion: z11.literal(RELAY_CONTROL_PROTOCOL_VERSION),
|
|
1950
1734
|
clientId: IdSchema,
|
|
1951
|
-
userAgent:
|
|
1952
|
-
platform:
|
|
1953
|
-
maxTouchPoints:
|
|
1954
|
-
browserName:
|
|
1955
|
-
osName:
|
|
1956
|
-
deviceKind:
|
|
1735
|
+
userAgent: z11.string().optional(),
|
|
1736
|
+
platform: z11.string().optional(),
|
|
1737
|
+
maxTouchPoints: z11.number().int().nonnegative().optional(),
|
|
1738
|
+
browserName: z11.string().min(1),
|
|
1739
|
+
osName: z11.string().min(1),
|
|
1740
|
+
deviceKind: z11.enum(["desktop", "tablet", "phone", "unknown"])
|
|
1957
1741
|
}),
|
|
1958
1742
|
controlSchema("client_register_response", ClientRegisterResponseSchema),
|
|
1959
1743
|
// Proxy 离线通知
|
|
@@ -1975,38 +1759,38 @@ var relayControlDefinitions = [
|
|
|
1975
1759
|
// 目录列表请求与响应
|
|
1976
1760
|
strictControl("dir_list_request", {
|
|
1977
1761
|
...RequestIdShape,
|
|
1978
|
-
path:
|
|
1979
|
-
includeHidden:
|
|
1762
|
+
path: z11.string(),
|
|
1763
|
+
includeHidden: z11.boolean()
|
|
1980
1764
|
}, "client_to_proxy"),
|
|
1981
1765
|
control("dir_list_response", {
|
|
1982
1766
|
...RequestIdShape,
|
|
1983
1767
|
...RequestErrorShape,
|
|
1984
|
-
entries:
|
|
1985
|
-
path:
|
|
1986
|
-
includeHidden:
|
|
1768
|
+
entries: z11.array(DirEntrySchema),
|
|
1769
|
+
path: z11.string(),
|
|
1770
|
+
includeHidden: z11.boolean()
|
|
1987
1771
|
}, "proxy_to_client"),
|
|
1988
1772
|
// 目录创建请求与响应
|
|
1989
|
-
control("dir_create_request", { ...RequestIdShape, path:
|
|
1773
|
+
control("dir_create_request", { ...RequestIdShape, path: z11.string() }, "client_to_proxy"),
|
|
1990
1774
|
control("dir_create_response", {
|
|
1991
1775
|
...RequestIdShape,
|
|
1992
1776
|
...RequestErrorShape,
|
|
1993
|
-
path:
|
|
1994
|
-
success:
|
|
1777
|
+
path: z11.string(),
|
|
1778
|
+
success: z11.boolean()
|
|
1995
1779
|
}, "proxy_to_client"),
|
|
1996
1780
|
// 命令列表推送,proxy 将可用命令列表推给 client
|
|
1997
1781
|
control("command_list_push", {
|
|
1998
1782
|
sessionId: IdSchema,
|
|
1999
|
-
commands:
|
|
1783
|
+
commands: z11.array(CommandEntrySchema)
|
|
2000
1784
|
}, "proxy_to_client"),
|
|
2001
1785
|
// 文件树推送: 按目录分组, 首组 path 即为 session cwd。
|
|
2002
1786
|
// 前端把它写入普通目录树;includeHidden=true 的按需响应使用独立缓存。
|
|
2003
1787
|
control("file_tree_push", {
|
|
2004
|
-
groups:
|
|
1788
|
+
groups: z11.array(FileTreeGroupSchema)
|
|
2005
1789
|
}, "proxy_to_client"),
|
|
2006
1790
|
// 会话列表请求与权限模式变更
|
|
2007
1791
|
strictControl("session_list_request", {}, "client_to_proxy"),
|
|
2008
1792
|
control("permission_mode_change", {
|
|
2009
|
-
mode:
|
|
1793
|
+
mode: z11.enum(["default", "auto_accept", "plan"]),
|
|
2010
1794
|
// sessionId 可选:传入时 proxy 按该会话的 mode 分叉(PTY 发 Tab ANSI),未传走全局日志行为
|
|
2011
1795
|
sessionId: IdSchema.optional()
|
|
2012
1796
|
}, "client_to_proxy"),
|
|
@@ -2015,33 +1799,33 @@ var relayControlDefinitions = [
|
|
|
2015
1799
|
control("session_history_response", {
|
|
2016
1800
|
...RequiredRequestIdShape,
|
|
2017
1801
|
...RequestErrorShape,
|
|
2018
|
-
success:
|
|
2019
|
-
sessions:
|
|
1802
|
+
success: z11.boolean(),
|
|
1803
|
+
sessions: z11.array(HistorySessionSchema)
|
|
2020
1804
|
}, "proxy_to_client"),
|
|
2021
1805
|
// PTY 语义状态,从 Envelope 迁移到 Control 层
|
|
2022
1806
|
control("pty_state", { sessionId: IdSchema, payload: PtyStatePayloadSchema }, "proxy_to_client"),
|
|
2023
1807
|
// Provider 语义状态,来自 Claude/Codex hook 等结构化事件,不从 PTY 字节推断
|
|
2024
1808
|
control("agent_status", { sessionId: IdSchema, payload: AgentStatusPayloadSchema }, "proxy_to_client"),
|
|
2025
1809
|
// 终端标题变化,proxy -> client
|
|
2026
|
-
control("terminal_title", { sessionId: IdSchema, title:
|
|
1810
|
+
control("terminal_title", { sessionId: IdSchema, title: z11.string() }, "proxy_to_client"),
|
|
2027
1811
|
// 终端尺寸变化,proxy -> client
|
|
2028
1812
|
control("terminal_resize", {
|
|
2029
1813
|
sessionId: IdSchema,
|
|
2030
|
-
cols:
|
|
2031
|
-
rows:
|
|
1814
|
+
cols: z11.number().int().positive(),
|
|
1815
|
+
rows: z11.number().int().positive(),
|
|
2032
1816
|
// PTY output and resize events share one ordered render sequence. The client can therefore
|
|
2033
1817
|
// place a resize between the exact byte frames that preceded and followed it.
|
|
2034
|
-
outputSeq:
|
|
1818
|
+
outputSeq: z11.number().int().nonnegative()
|
|
2035
1819
|
}, "proxy_to_client"),
|
|
2036
|
-
control("terminal_resize_request", { sessionId: IdSchema, cols:
|
|
1820
|
+
control("terminal_resize_request", { sessionId: IdSchema, cols: z11.number().int().positive(), rows: z11.number().int().positive() }, "client_to_proxy"),
|
|
2037
1821
|
// 远程终止 JSON 会话,client -> proxy
|
|
2038
1822
|
strictControl("session_terminate", { sessionId: IdSchema }, "client_to_proxy"),
|
|
2039
|
-
control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name:
|
|
1823
|
+
control("session_rename", { ...RequestIdShape, sessionId: IdSchema, name: z11.string() }, "client_to_proxy"),
|
|
2040
1824
|
control("session_rename_response", {
|
|
2041
1825
|
...RequestIdShape,
|
|
2042
1826
|
sessionId: IdSchema,
|
|
2043
|
-
success:
|
|
2044
|
-
name:
|
|
1827
|
+
success: z11.boolean(),
|
|
1828
|
+
name: z11.string().optional(),
|
|
2045
1829
|
...RequestErrorShape
|
|
2046
1830
|
}, "proxy_to_client"),
|
|
2047
1831
|
// 中断当前 turn,client -> proxy;JSON 由 session-worker 打断 Claude 子进程并保留会话。
|
|
@@ -2049,22 +1833,22 @@ var relayControlDefinitions = [
|
|
|
2049
1833
|
// turn 完成信号,proxy -> client,对应 claude stream-json 的 result 事件
|
|
2050
1834
|
control("turn_result", {
|
|
2051
1835
|
sessionId: IdSchema,
|
|
2052
|
-
success:
|
|
2053
|
-
isError:
|
|
1836
|
+
success: z11.boolean(),
|
|
1837
|
+
isError: z11.boolean(),
|
|
2054
1838
|
// stream-json result.result 是本轮最终文本。assistant_message 流丢失或 CLI 未发增量时,
|
|
2055
1839
|
// Web 用它作为 JSON 模式兜底展示,避免 turn 已结束但界面空白。
|
|
2056
|
-
result:
|
|
1840
|
+
result: z11.string().optional()
|
|
2057
1841
|
}, "proxy_to_client"),
|
|
2058
1842
|
// 客户端发送到 PTY 的原始字节(ANSI 序列),不追加换行
|
|
2059
|
-
control("remote_input_raw", { sessionId: IdSchema, data:
|
|
1843
|
+
control("remote_input_raw", { sessionId: IdSchema, data: z11.string(), traceId: IdSchema.optional() }, "client_to_proxy"),
|
|
2060
1844
|
// 客户端询问 proxy 的环境信息 (home 路径等), client -> proxy -> response
|
|
2061
1845
|
// FilePathPicker 用 homePath 作为 select 模式下的默认起点, 新建会话时打开即可浏览
|
|
2062
1846
|
controlSchema("proxy_info_request", ProxyInfoRequestSchema, "client_to_proxy"),
|
|
2063
1847
|
controlSchema("proxy_info", ProxyInfoResponseSchema, "proxy_to_client"),
|
|
2064
|
-
control("agent_cli_config_update", { ...RequestIdShape, provider:
|
|
1848
|
+
control("agent_cli_config_update", { ...RequestIdShape, provider: z11.enum(providerValues), path: z11.string().min(1) }, "client_to_proxy"),
|
|
2065
1849
|
control("agent_cli_config_update_response", {
|
|
2066
1850
|
...RequestIdShape,
|
|
2067
|
-
provider:
|
|
1851
|
+
provider: z11.enum(providerValues),
|
|
2068
1852
|
agentCli: AgentCliStatusSchema.optional(),
|
|
2069
1853
|
...RequestErrorShape
|
|
2070
1854
|
}, "proxy_to_client"),
|
|
@@ -2076,16 +1860,16 @@ var relayControlDefinitions = [
|
|
|
2076
1860
|
// 非零退出。把可识别的运行时错误结构化推给 Web,避免关键错误只留在终端闪屏里。
|
|
2077
1861
|
control("session_runtime_error", {
|
|
2078
1862
|
sessionId: IdSchema,
|
|
2079
|
-
error:
|
|
1863
|
+
error: z11.string(),
|
|
2080
1864
|
errorCode: ControlErrorCodeSchema,
|
|
2081
|
-
activeWriterPid:
|
|
1865
|
+
activeWriterPid: z11.number().int().positive().optional()
|
|
2082
1866
|
}, "proxy_to_client"),
|
|
2083
1867
|
// 客户端请求会话历史消息,client -> proxy
|
|
2084
1868
|
control("session_messages_request", {
|
|
2085
1869
|
...RequestIdShape,
|
|
2086
1870
|
sessionId: IdSchema,
|
|
2087
|
-
limit:
|
|
2088
|
-
before:
|
|
1871
|
+
limit: z11.number().int().min(1).max(200).optional(),
|
|
1872
|
+
before: z11.string().optional()
|
|
2089
1873
|
}, "client_to_proxy"),
|
|
2090
1874
|
// 客户端请求会话资源(命令列表 + 文件树),client -> proxy
|
|
2091
1875
|
control("session_resources_request", { ...RequiredRequestIdShape, sessionId: IdSchema }, "client_to_proxy"),
|
|
@@ -2093,14 +1877,14 @@ var relayControlDefinitions = [
|
|
|
2093
1877
|
...RequiredRequestIdShape,
|
|
2094
1878
|
...RequestErrorShape,
|
|
2095
1879
|
sessionId: IdSchema,
|
|
2096
|
-
commands:
|
|
2097
|
-
groups:
|
|
1880
|
+
commands: z11.array(CommandEntrySchema),
|
|
1881
|
+
groups: z11.array(FileTreeGroupSchema)
|
|
2098
1882
|
}, "proxy_to_client"),
|
|
2099
1883
|
// 客户端请求当前 provider 语义状态;不经 relay 缓存,由 proxy 返回当前值
|
|
2100
1884
|
control("agent_status_request", { ...RequestIdShape, sessionId: IdSchema.optional() }, "client_to_proxy"),
|
|
2101
1885
|
control("agent_status_response", {
|
|
2102
1886
|
...RequestIdShape,
|
|
2103
|
-
statuses:
|
|
1887
|
+
statuses: z11.array(z11.object({ sessionId: IdSchema, payload: AgentStatusPayloadSchema }))
|
|
2104
1888
|
}, "proxy_to_client"),
|
|
2105
1889
|
// 客户端确认已收到审批请求;proxy 只记录送达状态,不把它当成用户决策
|
|
2106
1890
|
control("permission_request_delivered", { sessionId: IdSchema, requestId: IdSchema }, "client_to_proxy"),
|
|
@@ -2110,18 +1894,18 @@ var relayControlDefinitions = [
|
|
|
2110
1894
|
control("permission_decision_result", {
|
|
2111
1895
|
sessionId: IdSchema,
|
|
2112
1896
|
requestId: IdSchema,
|
|
2113
|
-
outcome:
|
|
2114
|
-
delivered:
|
|
2115
|
-
message:
|
|
1897
|
+
outcome: z11.enum(["allow", "deny"]),
|
|
1898
|
+
delivered: z11.boolean(),
|
|
1899
|
+
message: z11.string().optional()
|
|
2116
1900
|
}, "proxy_to_client"),
|
|
2117
1901
|
// proxy 推送当前 pending 的工具审批列表,client 据此恢复审批卡片
|
|
2118
1902
|
control("pending_approvals_push", {
|
|
2119
1903
|
sessionId: IdSchema,
|
|
2120
|
-
approvals:
|
|
1904
|
+
approvals: z11.array(z11.object({
|
|
2121
1905
|
requestId: IdSchema,
|
|
2122
|
-
toolName:
|
|
2123
|
-
input:
|
|
2124
|
-
options:
|
|
1906
|
+
toolName: z11.string(),
|
|
1907
|
+
input: z11.record(z11.string(), z11.unknown()),
|
|
1908
|
+
options: z11.array(ApprovalOptionSchema).optional()
|
|
2125
1909
|
}))
|
|
2126
1910
|
}, "proxy_to_client"),
|
|
2127
1911
|
// Voice Pilot speech summaries are produced by proxy-side Claude Code so it can read project context.
|
|
@@ -2129,7 +1913,7 @@ var relayControlDefinitions = [
|
|
|
2129
1913
|
...RequestIdShape,
|
|
2130
1914
|
sessionId: IdSchema,
|
|
2131
1915
|
messageId: IdSchema,
|
|
2132
|
-
text:
|
|
1916
|
+
text: z11.string().min(1),
|
|
2133
1917
|
reason: VoiceSummaryReasonSchema
|
|
2134
1918
|
}, "client_to_proxy"),
|
|
2135
1919
|
control("voice_summary_response", {
|
|
@@ -2137,27 +1921,27 @@ var relayControlDefinitions = [
|
|
|
2137
1921
|
...RequestErrorShape,
|
|
2138
1922
|
sessionId: IdSchema,
|
|
2139
1923
|
messageId: IdSchema,
|
|
2140
|
-
success:
|
|
2141
|
-
summary:
|
|
1924
|
+
success: z11.boolean(),
|
|
1925
|
+
summary: z11.string().min(1).optional()
|
|
2142
1926
|
}, "proxy_to_client"),
|
|
2143
1927
|
// 恢复会话时推送历史消息,proxy -> client
|
|
2144
1928
|
control("session_history_messages", {
|
|
2145
1929
|
...RequestIdShape,
|
|
2146
1930
|
sessionId: IdSchema,
|
|
2147
|
-
before:
|
|
2148
|
-
messages:
|
|
2149
|
-
hasMore:
|
|
2150
|
-
nextBefore:
|
|
1931
|
+
before: z11.string().optional(),
|
|
1932
|
+
messages: z11.array(SessionHistoryMessageSchema),
|
|
1933
|
+
hasMore: z11.boolean().optional(),
|
|
1934
|
+
nextBefore: z11.string().optional()
|
|
2151
1935
|
}, "proxy_to_client"),
|
|
2152
1936
|
// proxy 重连后同步活跃 session 列表给 relay。session_sync 由 relay 自消费(更新 proxy-session
|
|
2153
1937
|
// 关联)不转发给 client,因此**没有** direction 标注——RelayControlDirection 只描述转发流。
|
|
2154
1938
|
control("session_sync", {
|
|
2155
|
-
sessions:
|
|
2156
|
-
id:
|
|
2157
|
-
cwd:
|
|
2158
|
-
name:
|
|
2159
|
-
nameLocked:
|
|
2160
|
-
state:
|
|
1939
|
+
sessions: z11.array(createSessionIdentitySchema({
|
|
1940
|
+
id: z11.string(),
|
|
1941
|
+
cwd: z11.string(),
|
|
1942
|
+
name: z11.string().optional(),
|
|
1943
|
+
nameLocked: z11.boolean().optional(),
|
|
1944
|
+
state: z11.enum(sessionStateValues)
|
|
2161
1945
|
}))
|
|
2162
1946
|
}),
|
|
2163
1947
|
// PTY 会话订阅,client -> proxy,触发 terminal serialize() 返回当前状态
|
|
@@ -2165,18 +1949,234 @@ var relayControlDefinitions = [
|
|
|
2165
1949
|
// PTY 会话快照,proxy -> client,serialize() 的全量终端状态
|
|
2166
1950
|
control("session_snapshot", {
|
|
2167
1951
|
sessionId: IdSchema,
|
|
2168
|
-
cols:
|
|
2169
|
-
rows:
|
|
2170
|
-
data:
|
|
2171
|
-
outputSeq:
|
|
1952
|
+
cols: z11.number().int().positive(),
|
|
1953
|
+
rows: z11.number().int().positive(),
|
|
1954
|
+
data: z11.string(),
|
|
1955
|
+
outputSeq: z11.number().int().nonnegative(),
|
|
2172
1956
|
requestId: IdSchema
|
|
2173
1957
|
}, "proxy_to_client")
|
|
2174
1958
|
];
|
|
2175
1959
|
var relayControlSchemas = relayControlDefinitions.map((definition) => definition.schema);
|
|
2176
|
-
var RelayControlSchema =
|
|
1960
|
+
var RelayControlSchema = z11.discriminatedUnion("type", relayControlSchemas);
|
|
2177
1961
|
var ProxyToClientRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("proxy_to_client")).map((definition) => definition.type));
|
|
2178
1962
|
var ClientToProxyRelayControlTypes = new Set(relayControlDefinitions.filter((definition) => definition.directions.has("client_to_proxy")).map((definition) => definition.type));
|
|
2179
1963
|
|
|
1964
|
+
// ../../packages/shared/dist/state-machine.js
|
|
1965
|
+
function computeAbsorbingSet(transitions) {
|
|
1966
|
+
const absorbing = /* @__PURE__ */ new Set();
|
|
1967
|
+
const entries = Object.entries(transitions);
|
|
1968
|
+
for (const [s, outs] of entries) {
|
|
1969
|
+
if (outs.length === 0)
|
|
1970
|
+
absorbing.add(s);
|
|
1971
|
+
}
|
|
1972
|
+
let changed = true;
|
|
1973
|
+
while (changed) {
|
|
1974
|
+
changed = false;
|
|
1975
|
+
for (const [s, outs] of entries) {
|
|
1976
|
+
if (absorbing.has(s))
|
|
1977
|
+
continue;
|
|
1978
|
+
if (outs.length > 0 && outs.every((t) => absorbing.has(t))) {
|
|
1979
|
+
absorbing.add(s);
|
|
1980
|
+
changed = true;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
return absorbing;
|
|
1985
|
+
}
|
|
1986
|
+
function createFSM(def) {
|
|
1987
|
+
let state = def.initial;
|
|
1988
|
+
const absorbing = computeAbsorbingSet(def.transitions);
|
|
1989
|
+
const tryTransitionTo = (to) => {
|
|
1990
|
+
const allowed = def.transitions[state];
|
|
1991
|
+
if (!allowed?.includes(to)) {
|
|
1992
|
+
def.onRejected?.(state, to, absorbing.has(state));
|
|
1993
|
+
return false;
|
|
1994
|
+
}
|
|
1995
|
+
const from = state;
|
|
1996
|
+
state = to;
|
|
1997
|
+
def.onTransition?.(from, to);
|
|
1998
|
+
return true;
|
|
1999
|
+
};
|
|
2000
|
+
return {
|
|
2001
|
+
current: () => state,
|
|
2002
|
+
is: (s) => state === s,
|
|
2003
|
+
isIn: (ss) => ss.includes(state),
|
|
2004
|
+
canTransitionTo: (to) => def.transitions[state]?.includes(to) ?? false,
|
|
2005
|
+
transitionTo: (to) => {
|
|
2006
|
+
if (!tryTransitionTo(to)) {
|
|
2007
|
+
throw new Error(`Invalid FSM transition: ${state} -> ${to}`);
|
|
2008
|
+
}
|
|
2009
|
+
},
|
|
2010
|
+
tryTransitionTo,
|
|
2011
|
+
isInAbsorbingState: () => absorbing.has(state)
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
function defineFSM(transitions) {
|
|
2015
|
+
const absorbing = computeAbsorbingSet(transitions);
|
|
2016
|
+
return {
|
|
2017
|
+
canTransition: (from, to) => transitions[from]?.includes(to) ?? false,
|
|
2018
|
+
isAbsorbing: (state) => absorbing.has(state)
|
|
2019
|
+
};
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
// ../../packages/shared/dist/schemas/proxy-upgrade-bootstrap.js
|
|
2023
|
+
import { z as z12 } from "zod";
|
|
2024
|
+
var PROXY_UPGRADE_BOOTSTRAP_VERSION = 1;
|
|
2025
|
+
var StableVersionSchema = z12.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
|
|
2026
|
+
var ProxyUpgradeBootstrapResponseSchema = z12.object({
|
|
2027
|
+
bootstrapVersion: z12.literal(PROXY_UPGRADE_BOOTSTRAP_VERSION),
|
|
2028
|
+
relayVersion: StableVersionSchema,
|
|
2029
|
+
controlProtocolVersion: z12.number().int().positive()
|
|
2030
|
+
});
|
|
2031
|
+
|
|
2032
|
+
// ../../packages/shared/dist/schemas/voice-stream.js
|
|
2033
|
+
import { z as z13 } from "zod";
|
|
2034
|
+
var VoiceAsrAudioEncodingSchema = z13.enum(["pcm_s16le", "mulaw"]);
|
|
2035
|
+
var VoiceAsrStartMessageSchema = z13.object({
|
|
2036
|
+
type: z13.literal("start"),
|
|
2037
|
+
sessionId: z13.string().min(1),
|
|
2038
|
+
attemptId: z13.string().min(1),
|
|
2039
|
+
sampleRate: z13.number().int().positive(),
|
|
2040
|
+
encoding: VoiceAsrAudioEncodingSchema
|
|
2041
|
+
});
|
|
2042
|
+
var VoiceAsrStopMessageSchema = z13.object({
|
|
2043
|
+
type: z13.literal("stop"),
|
|
2044
|
+
attemptId: z13.string().min(1)
|
|
2045
|
+
});
|
|
2046
|
+
var VoiceAsrClientMessageSchema = z13.discriminatedUnion("type", [
|
|
2047
|
+
VoiceAsrStartMessageSchema,
|
|
2048
|
+
VoiceAsrStopMessageSchema
|
|
2049
|
+
]);
|
|
2050
|
+
var VoiceAsrServerMessageSchema = z13.discriminatedUnion("type", [
|
|
2051
|
+
z13.object({ type: z13.literal("ready"), attemptId: z13.string().min(1) }),
|
|
2052
|
+
z13.object({
|
|
2053
|
+
type: z13.literal("audio_ack"),
|
|
2054
|
+
attemptId: z13.string().min(1),
|
|
2055
|
+
encodedBytes: z13.number().int().nonnegative(),
|
|
2056
|
+
pcmBytes: z13.number().int().nonnegative(),
|
|
2057
|
+
chunks: z13.number().int().nonnegative()
|
|
2058
|
+
}),
|
|
2059
|
+
z13.object({ type: z13.literal("partial"), attemptId: z13.string().min(1), text: z13.string() }),
|
|
2060
|
+
z13.object({ type: z13.literal("final"), attemptId: z13.string().min(1), text: z13.string() }),
|
|
2061
|
+
z13.object({
|
|
2062
|
+
type: z13.literal("closed"),
|
|
2063
|
+
attemptId: z13.string().min(1),
|
|
2064
|
+
code: z13.number().int().optional(),
|
|
2065
|
+
reason: z13.string().optional()
|
|
2066
|
+
}),
|
|
2067
|
+
z13.object({
|
|
2068
|
+
type: z13.literal("error"),
|
|
2069
|
+
attemptId: z13.string().min(1),
|
|
2070
|
+
error: z13.string().optional(),
|
|
2071
|
+
errorCode: z13.string().optional()
|
|
2072
|
+
})
|
|
2073
|
+
]);
|
|
2074
|
+
|
|
2075
|
+
// ../../packages/shared/dist/slash-commands.js
|
|
2076
|
+
function isCompactCommandText(text) {
|
|
2077
|
+
return /^\/compact(?:\s|$)/.test(text.trimStart());
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
// ../../packages/shared/dist/tool-activity-summary.js
|
|
2081
|
+
var SECRET_VALUE_PATTERN = /((?:authorization|api[_-]?key|token|password|secret)\s*[:=]\s*)(?:bearer\s+)?[^\s'"]+/giu;
|
|
2082
|
+
var SECRET_FLAG_PATTERN = /(--(?:api-key|token|password|secret)(?:=|\s+))[^\s'"]+/giu;
|
|
2083
|
+
function asString(value) {
|
|
2084
|
+
return typeof value === "string" ? value : "";
|
|
2085
|
+
}
|
|
2086
|
+
function compact(value, max = 140) {
|
|
2087
|
+
const text = value.replace(/\s+/gu, " ").trim();
|
|
2088
|
+
if (text.length <= max)
|
|
2089
|
+
return text;
|
|
2090
|
+
return `${text.slice(0, max - 1)}\u2026`;
|
|
2091
|
+
}
|
|
2092
|
+
function redact(value) {
|
|
2093
|
+
return value.replace(SECRET_VALUE_PATTERN, "$1[redacted]").replace(SECRET_FLAG_PATTERN, "$1[redacted]");
|
|
2094
|
+
}
|
|
2095
|
+
function filePath(input) {
|
|
2096
|
+
return asString(input.file_path) || asString(input.path) || asString(input.notebook_path);
|
|
2097
|
+
}
|
|
2098
|
+
function summarizeToolActivity(toolName, input) {
|
|
2099
|
+
switch (toolName) {
|
|
2100
|
+
case "Bash": {
|
|
2101
|
+
const command = compact(redact(asString(input.command)));
|
|
2102
|
+
return command ? `\u8FD0\u884C\u547D\u4EE4\uFF1A${command}` : "\u8FD0\u884C\u547D\u4EE4";
|
|
2103
|
+
}
|
|
2104
|
+
case "BashBatch": {
|
|
2105
|
+
const commands = Array.isArray(input.commands) ? input.commands.filter((item) => typeof item === "string") : [];
|
|
2106
|
+
return commands.length > 0 ? `\u6279\u91CF\u8FD0\u884C\u547D\u4EE4\uFF1A${commands.length} \u6761` : "\u6279\u91CF\u8FD0\u884C\u547D\u4EE4";
|
|
2107
|
+
}
|
|
2108
|
+
case "ProcessWait":
|
|
2109
|
+
return "\u7B49\u5F85\u547D\u4EE4\u5B8C\u6210";
|
|
2110
|
+
case "ProcessInput": {
|
|
2111
|
+
const value = compact(redact(asString(input.input)), 80);
|
|
2112
|
+
return value ? `\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165\uFF1A${value}` : "\u53D1\u9001\u7EC8\u7AEF\u8F93\u5165";
|
|
2113
|
+
}
|
|
2114
|
+
case "Read": {
|
|
2115
|
+
const path = filePath(input);
|
|
2116
|
+
return path ? `\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}` : "\u8BFB\u53D6\u6587\u4EF6";
|
|
2117
|
+
}
|
|
2118
|
+
case "Write": {
|
|
2119
|
+
const path = filePath(input);
|
|
2120
|
+
return path ? `\u5199\u5165\u6587\u4EF6\uFF1A${path}` : "\u5199\u5165\u6587\u4EF6";
|
|
2121
|
+
}
|
|
2122
|
+
case "Edit":
|
|
2123
|
+
case "MultiEdit": {
|
|
2124
|
+
const path = filePath(input);
|
|
2125
|
+
return path ? `\u7F16\u8F91\u6587\u4EF6\uFF1A${path}` : "\u7F16\u8F91\u6587\u4EF6";
|
|
2126
|
+
}
|
|
2127
|
+
case "LS": {
|
|
2128
|
+
const path = filePath(input);
|
|
2129
|
+
return path ? `\u5217\u51FA\u76EE\u5F55\uFF1A${path}` : "\u5217\u51FA\u76EE\u5F55";
|
|
2130
|
+
}
|
|
2131
|
+
case "Grep": {
|
|
2132
|
+
const pattern = compact(redact(asString(input.pattern)), 80);
|
|
2133
|
+
const path = filePath(input);
|
|
2134
|
+
if (pattern && path)
|
|
2135
|
+
return `\u641C\u7D22\uFF1A${pattern} in ${path}`;
|
|
2136
|
+
return pattern ? `\u641C\u7D22\uFF1A${pattern}` : "\u641C\u7D22\u6587\u672C";
|
|
2137
|
+
}
|
|
2138
|
+
case "Glob": {
|
|
2139
|
+
const pattern = compact(redact(asString(input.pattern)), 80);
|
|
2140
|
+
return pattern ? `\u67E5\u627E\u6587\u4EF6\uFF1A${pattern}` : "\u67E5\u627E\u6587\u4EF6";
|
|
2141
|
+
}
|
|
2142
|
+
case "WebFetch": {
|
|
2143
|
+
const url = compact(redact(asString(input.url)), 100);
|
|
2144
|
+
return url ? `\u8BFB\u53D6\u7F51\u9875\uFF1A${url}` : "\u8BFB\u53D6\u7F51\u9875";
|
|
2145
|
+
}
|
|
2146
|
+
case "WebSearch": {
|
|
2147
|
+
const query = compact(redact(asString(input.query)), 100);
|
|
2148
|
+
return query ? `\u7F51\u9875\u641C\u7D22\uFF1A${query}` : "\u7F51\u9875\u641C\u7D22";
|
|
2149
|
+
}
|
|
2150
|
+
case "ViewImage": {
|
|
2151
|
+
const path = filePath(input);
|
|
2152
|
+
return path ? `\u67E5\u770B\u56FE\u7247\uFF1A${path}` : "\u67E5\u770B\u56FE\u7247";
|
|
2153
|
+
}
|
|
2154
|
+
case "ViewImageBatch": {
|
|
2155
|
+
const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
|
|
2156
|
+
return paths.length > 0 ? `\u6279\u91CF\u67E5\u770B\u56FE\u7247\uFF1A${paths.length} \u5F20` : "\u6279\u91CF\u67E5\u770B\u56FE\u7247";
|
|
2157
|
+
}
|
|
2158
|
+
case "Web":
|
|
2159
|
+
return "\u8BBF\u95EE\u7F51\u9875";
|
|
2160
|
+
case "ToolScript":
|
|
2161
|
+
return "\u6267\u884C\u5DE5\u5177\u7F16\u6392";
|
|
2162
|
+
case "TodoWrite":
|
|
2163
|
+
return "\u66F4\u65B0\u4EFB\u52A1\u5217\u8868";
|
|
2164
|
+
case "Patch": {
|
|
2165
|
+
const path = filePath(input);
|
|
2166
|
+
if (path)
|
|
2167
|
+
return `\u5E94\u7528\u8865\u4E01\uFF1A${path}`;
|
|
2168
|
+
const paths = Array.isArray(input.paths) ? input.paths.filter((item) => typeof item === "string") : [];
|
|
2169
|
+
if (paths.length === 1)
|
|
2170
|
+
return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]}`;
|
|
2171
|
+
if (paths.length > 1)
|
|
2172
|
+
return `\u5E94\u7528\u8865\u4E01\uFF1A${paths[0]} \u7B49 ${paths.length} \u4E2A\u6587\u4EF6`;
|
|
2173
|
+
return "\u5E94\u7528\u8865\u4E01";
|
|
2174
|
+
}
|
|
2175
|
+
default:
|
|
2176
|
+
return `\u4F7F\u7528\u5DE5\u5177\uFF1A${toolName}`;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
2180
|
// ../../packages/shared/dist/constants/session.js
|
|
2181
2181
|
var SessionState = {
|
|
2182
2182
|
IDLE: "idle",
|
|
@@ -2397,9 +2397,6 @@ function encodeDevicePreviewH264ProxyPacket(streamId, packet) {
|
|
|
2397
2397
|
return encoded;
|
|
2398
2398
|
}
|
|
2399
2399
|
|
|
2400
|
-
// src/ipc/ipc-protocol.ts
|
|
2401
|
-
import { z as z14 } from "zod";
|
|
2402
|
-
|
|
2403
2400
|
// src/ipc/line-buffer.ts
|
|
2404
2401
|
import { Transform } from "stream";
|
|
2405
2402
|
import { StringDecoder } from "string_decoder";
|
|
@@ -2428,364 +2425,11 @@ var LineBuffer = class extends Transform {
|
|
|
2428
2425
|
}
|
|
2429
2426
|
};
|
|
2430
2427
|
|
|
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
2428
|
export {
|
|
2787
2429
|
IdSchema,
|
|
2430
|
+
ApprovalOptionSchema,
|
|
2788
2431
|
providerValues,
|
|
2432
|
+
ptySemanticStateValues,
|
|
2789
2433
|
PTY_INITIAL_MIN_COLS,
|
|
2790
2434
|
PTY_INITIAL_MIN_ROWS,
|
|
2791
2435
|
PTY_INITIAL_MAX_COLS,
|
|
@@ -2811,6 +2455,7 @@ export {
|
|
|
2811
2455
|
isProxyProtocolRejectDirection,
|
|
2812
2456
|
RELAY_JSON_MESSAGE_MAX_BYTES,
|
|
2813
2457
|
encodeBinaryFrame,
|
|
2458
|
+
decodeBinaryFrame,
|
|
2814
2459
|
encodeFileStreamFrame,
|
|
2815
2460
|
decodeFileStreamFrame,
|
|
2816
2461
|
DEVICE_PREVIEW_FRAME_MAX_BYTES,
|
|
@@ -2818,13 +2463,6 @@ export {
|
|
|
2818
2463
|
encodeDevicePreviewH264ProxyPacket,
|
|
2819
2464
|
createFSM,
|
|
2820
2465
|
defineFSM,
|
|
2821
|
-
LineBuffer
|
|
2822
|
-
WORKER_IPC_PROTOCOL_VERSION,
|
|
2823
|
-
TERMINAL_IPC_PROTOCOL_VERSION,
|
|
2824
|
-
encodeBinaryIpcFrame,
|
|
2825
|
-
serializeWorkerMsg,
|
|
2826
|
-
createWorkerReader,
|
|
2827
|
-
serializeIpc,
|
|
2828
|
-
createIpcReader
|
|
2466
|
+
LineBuffer
|
|
2829
2467
|
};
|
|
2830
|
-
//# sourceMappingURL=chunk-
|
|
2468
|
+
//# sourceMappingURL=chunk-7FPUPHTZ.js.map
|