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