linkshell-cli 0.2.9 → 0.2.11
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/cli/src/runtime/bridge-session.d.ts +2 -4
- package/dist/cli/src/runtime/bridge-session.js +107 -39
- package/dist/cli/src/runtime/bridge-session.js.map +1 -1
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/shared-protocol/src/index.d.ts +167 -12
- package/dist/shared-protocol/src/index.js +27 -0
- package/dist/shared-protocol/src/index.js.map +1 -1
- package/package.json +1 -1
- package/src/runtime/bridge-session.ts +122 -43
|
@@ -10,6 +10,7 @@ export declare const envelopeSchema: z.ZodObject<{
|
|
|
10
10
|
id: z.ZodString;
|
|
11
11
|
type: z.ZodString;
|
|
12
12
|
sessionId: z.ZodString;
|
|
13
|
+
terminalId: z.ZodOptional<z.ZodString>;
|
|
13
14
|
deviceId: z.ZodOptional<z.ZodString>;
|
|
14
15
|
timestamp: z.ZodString;
|
|
15
16
|
traceId: z.ZodOptional<z.ZodString>;
|
|
@@ -17,20 +18,22 @@ export declare const envelopeSchema: z.ZodObject<{
|
|
|
17
18
|
ack: z.ZodOptional<z.ZodNumber>;
|
|
18
19
|
payload: z.ZodUnknown;
|
|
19
20
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
sessionId: string;
|
|
21
21
|
id: string;
|
|
22
22
|
type: string;
|
|
23
|
+
sessionId: string;
|
|
23
24
|
timestamp: string;
|
|
25
|
+
terminalId?: string | undefined;
|
|
24
26
|
deviceId?: string | undefined;
|
|
25
27
|
traceId?: string | undefined;
|
|
26
28
|
seq?: number | undefined;
|
|
27
29
|
ack?: number | undefined;
|
|
28
30
|
payload?: unknown;
|
|
29
31
|
}, {
|
|
30
|
-
sessionId: string;
|
|
31
32
|
id: string;
|
|
32
33
|
type: string;
|
|
34
|
+
sessionId: string;
|
|
33
35
|
timestamp: string;
|
|
36
|
+
terminalId?: string | undefined;
|
|
34
37
|
deviceId?: string | undefined;
|
|
35
38
|
traceId?: string | undefined;
|
|
36
39
|
seq?: number | undefined;
|
|
@@ -81,20 +84,26 @@ export declare const sessionConnectPayloadSchema: z.ZodObject<{
|
|
|
81
84
|
protocolVersion: z.ZodOptional<z.ZodNumber>;
|
|
82
85
|
hostname: z.ZodOptional<z.ZodString>;
|
|
83
86
|
platform: z.ZodOptional<z.ZodString>;
|
|
87
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
88
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
84
89
|
}, "strip", z.ZodTypeAny, {
|
|
85
90
|
role: "host" | "client";
|
|
86
91
|
clientName: string;
|
|
87
|
-
provider?: "
|
|
92
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
88
93
|
protocolVersion?: number | undefined;
|
|
89
94
|
hostname?: string | undefined;
|
|
90
95
|
platform?: string | undefined;
|
|
96
|
+
cwd?: string | undefined;
|
|
97
|
+
projectName?: string | undefined;
|
|
91
98
|
}, {
|
|
92
99
|
role: "host" | "client";
|
|
93
100
|
clientName: string;
|
|
94
|
-
provider?: "
|
|
101
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
95
102
|
protocolVersion?: number | undefined;
|
|
96
103
|
hostname?: string | undefined;
|
|
97
104
|
platform?: string | undefined;
|
|
105
|
+
cwd?: string | undefined;
|
|
106
|
+
projectName?: string | undefined;
|
|
98
107
|
}>;
|
|
99
108
|
export declare const terminalExitPayloadSchema: z.ZodObject<{
|
|
100
109
|
exitCode: z.ZodNullable<z.ZodNumber>;
|
|
@@ -239,8 +248,8 @@ export declare const screenStatusPayloadSchema: z.ZodObject<{
|
|
|
239
248
|
error?: string | undefined;
|
|
240
249
|
}, {
|
|
241
250
|
active: boolean;
|
|
242
|
-
error?: string | undefined;
|
|
243
251
|
mode?: "webrtc" | "fallback" | "off" | undefined;
|
|
252
|
+
error?: string | undefined;
|
|
244
253
|
}>;
|
|
245
254
|
export declare const screenOfferPayloadSchema: z.ZodObject<{
|
|
246
255
|
sdp: z.ZodString;
|
|
@@ -269,6 +278,85 @@ export declare const screenIcePayloadSchema: z.ZodObject<{
|
|
|
269
278
|
sdpMid?: string | null | undefined;
|
|
270
279
|
sdpMLineIndex?: number | null | undefined;
|
|
271
280
|
}>;
|
|
281
|
+
export declare const terminalSpawnPayloadSchema: z.ZodObject<{
|
|
282
|
+
cwd: z.ZodString;
|
|
283
|
+
provider: z.ZodOptional<z.ZodEnum<["claude", "codex", "custom"]>>;
|
|
284
|
+
}, "strip", z.ZodTypeAny, {
|
|
285
|
+
cwd: string;
|
|
286
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
287
|
+
}, {
|
|
288
|
+
cwd: string;
|
|
289
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
290
|
+
}>;
|
|
291
|
+
export declare const terminalInfoSchema: z.ZodObject<{
|
|
292
|
+
terminalId: z.ZodString;
|
|
293
|
+
cwd: z.ZodString;
|
|
294
|
+
projectName: z.ZodString;
|
|
295
|
+
provider: z.ZodString;
|
|
296
|
+
status: z.ZodEnum<["running", "exited"]>;
|
|
297
|
+
}, "strip", z.ZodTypeAny, {
|
|
298
|
+
terminalId: string;
|
|
299
|
+
status: "running" | "exited";
|
|
300
|
+
provider: string;
|
|
301
|
+
cwd: string;
|
|
302
|
+
projectName: string;
|
|
303
|
+
}, {
|
|
304
|
+
terminalId: string;
|
|
305
|
+
status: "running" | "exited";
|
|
306
|
+
provider: string;
|
|
307
|
+
cwd: string;
|
|
308
|
+
projectName: string;
|
|
309
|
+
}>;
|
|
310
|
+
export declare const terminalListPayloadSchema: z.ZodObject<{
|
|
311
|
+
terminals: z.ZodArray<z.ZodObject<{
|
|
312
|
+
terminalId: z.ZodString;
|
|
313
|
+
cwd: z.ZodString;
|
|
314
|
+
projectName: z.ZodString;
|
|
315
|
+
provider: z.ZodString;
|
|
316
|
+
status: z.ZodEnum<["running", "exited"]>;
|
|
317
|
+
}, "strip", z.ZodTypeAny, {
|
|
318
|
+
terminalId: string;
|
|
319
|
+
status: "running" | "exited";
|
|
320
|
+
provider: string;
|
|
321
|
+
cwd: string;
|
|
322
|
+
projectName: string;
|
|
323
|
+
}, {
|
|
324
|
+
terminalId: string;
|
|
325
|
+
status: "running" | "exited";
|
|
326
|
+
provider: string;
|
|
327
|
+
cwd: string;
|
|
328
|
+
projectName: string;
|
|
329
|
+
}>, "many">;
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
terminals: {
|
|
332
|
+
terminalId: string;
|
|
333
|
+
status: "running" | "exited";
|
|
334
|
+
provider: string;
|
|
335
|
+
cwd: string;
|
|
336
|
+
projectName: string;
|
|
337
|
+
}[];
|
|
338
|
+
}, {
|
|
339
|
+
terminals: {
|
|
340
|
+
terminalId: string;
|
|
341
|
+
status: "running" | "exited";
|
|
342
|
+
provider: string;
|
|
343
|
+
cwd: string;
|
|
344
|
+
projectName: string;
|
|
345
|
+
}[];
|
|
346
|
+
}>;
|
|
347
|
+
export declare const terminalSpawnedPayloadSchema: z.ZodObject<{
|
|
348
|
+
terminalId: z.ZodString;
|
|
349
|
+
cwd: z.ZodString;
|
|
350
|
+
projectName: z.ZodString;
|
|
351
|
+
}, "strip", z.ZodTypeAny, {
|
|
352
|
+
terminalId: string;
|
|
353
|
+
cwd: string;
|
|
354
|
+
projectName: string;
|
|
355
|
+
}, {
|
|
356
|
+
terminalId: string;
|
|
357
|
+
cwd: string;
|
|
358
|
+
projectName: string;
|
|
359
|
+
}>;
|
|
272
360
|
export declare const fileUploadPayloadSchema: z.ZodObject<{
|
|
273
361
|
data: z.ZodString;
|
|
274
362
|
filename: z.ZodString;
|
|
@@ -283,11 +371,11 @@ export declare const errorPayloadSchema: z.ZodObject<{
|
|
|
283
371
|
code: z.ZodString;
|
|
284
372
|
message: z.ZodString;
|
|
285
373
|
}, "strip", z.ZodTypeAny, {
|
|
286
|
-
message: string;
|
|
287
374
|
code: string;
|
|
288
|
-
}, {
|
|
289
375
|
message: string;
|
|
376
|
+
}, {
|
|
290
377
|
code: string;
|
|
378
|
+
message: string;
|
|
291
379
|
}>;
|
|
292
380
|
export declare const protocolMessageSchemas: {
|
|
293
381
|
readonly "session.connect": z.ZodObject<{
|
|
@@ -297,20 +385,26 @@ export declare const protocolMessageSchemas: {
|
|
|
297
385
|
protocolVersion: z.ZodOptional<z.ZodNumber>;
|
|
298
386
|
hostname: z.ZodOptional<z.ZodString>;
|
|
299
387
|
platform: z.ZodOptional<z.ZodString>;
|
|
388
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
389
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
300
390
|
}, "strip", z.ZodTypeAny, {
|
|
301
391
|
role: "host" | "client";
|
|
302
392
|
clientName: string;
|
|
303
|
-
provider?: "
|
|
393
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
304
394
|
protocolVersion?: number | undefined;
|
|
305
395
|
hostname?: string | undefined;
|
|
306
396
|
platform?: string | undefined;
|
|
397
|
+
cwd?: string | undefined;
|
|
398
|
+
projectName?: string | undefined;
|
|
307
399
|
}, {
|
|
308
400
|
role: "host" | "client";
|
|
309
401
|
clientName: string;
|
|
310
|
-
provider?: "
|
|
402
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
311
403
|
protocolVersion?: number | undefined;
|
|
312
404
|
hostname?: string | undefined;
|
|
313
405
|
platform?: string | undefined;
|
|
406
|
+
cwd?: string | undefined;
|
|
407
|
+
projectName?: string | undefined;
|
|
314
408
|
}>;
|
|
315
409
|
readonly "session.ack": z.ZodObject<{
|
|
316
410
|
seq: z.ZodNumber;
|
|
@@ -337,11 +431,11 @@ export declare const protocolMessageSchemas: {
|
|
|
337
431
|
code: z.ZodString;
|
|
338
432
|
message: z.ZodString;
|
|
339
433
|
}, "strip", z.ZodTypeAny, {
|
|
340
|
-
message: string;
|
|
341
434
|
code: string;
|
|
342
|
-
}, {
|
|
343
435
|
message: string;
|
|
436
|
+
}, {
|
|
344
437
|
code: string;
|
|
438
|
+
message: string;
|
|
345
439
|
}>;
|
|
346
440
|
readonly "terminal.output": z.ZodObject<{
|
|
347
441
|
stream: z.ZodEnum<["stdout", "stderr"]>;
|
|
@@ -501,8 +595,8 @@ export declare const protocolMessageSchemas: {
|
|
|
501
595
|
error?: string | undefined;
|
|
502
596
|
}, {
|
|
503
597
|
active: boolean;
|
|
504
|
-
error?: string | undefined;
|
|
505
598
|
mode?: "webrtc" | "fallback" | "off" | undefined;
|
|
599
|
+
error?: string | undefined;
|
|
506
600
|
}>;
|
|
507
601
|
readonly "screen.offer": z.ZodObject<{
|
|
508
602
|
sdp: z.ZodString;
|
|
@@ -541,6 +635,66 @@ export declare const protocolMessageSchemas: {
|
|
|
541
635
|
data: string;
|
|
542
636
|
filename: string;
|
|
543
637
|
}>;
|
|
638
|
+
readonly "terminal.spawn": z.ZodObject<{
|
|
639
|
+
cwd: z.ZodString;
|
|
640
|
+
provider: z.ZodOptional<z.ZodEnum<["claude", "codex", "custom"]>>;
|
|
641
|
+
}, "strip", z.ZodTypeAny, {
|
|
642
|
+
cwd: string;
|
|
643
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
644
|
+
}, {
|
|
645
|
+
cwd: string;
|
|
646
|
+
provider?: "custom" | "claude" | "codex" | undefined;
|
|
647
|
+
}>;
|
|
648
|
+
readonly "terminal.spawned": z.ZodObject<{
|
|
649
|
+
terminalId: z.ZodString;
|
|
650
|
+
cwd: z.ZodString;
|
|
651
|
+
projectName: z.ZodString;
|
|
652
|
+
}, "strip", z.ZodTypeAny, {
|
|
653
|
+
terminalId: string;
|
|
654
|
+
cwd: string;
|
|
655
|
+
projectName: string;
|
|
656
|
+
}, {
|
|
657
|
+
terminalId: string;
|
|
658
|
+
cwd: string;
|
|
659
|
+
projectName: string;
|
|
660
|
+
}>;
|
|
661
|
+
readonly "terminal.list": z.ZodObject<{
|
|
662
|
+
terminals: z.ZodArray<z.ZodObject<{
|
|
663
|
+
terminalId: z.ZodString;
|
|
664
|
+
cwd: z.ZodString;
|
|
665
|
+
projectName: z.ZodString;
|
|
666
|
+
provider: z.ZodString;
|
|
667
|
+
status: z.ZodEnum<["running", "exited"]>;
|
|
668
|
+
}, "strip", z.ZodTypeAny, {
|
|
669
|
+
terminalId: string;
|
|
670
|
+
status: "running" | "exited";
|
|
671
|
+
provider: string;
|
|
672
|
+
cwd: string;
|
|
673
|
+
projectName: string;
|
|
674
|
+
}, {
|
|
675
|
+
terminalId: string;
|
|
676
|
+
status: "running" | "exited";
|
|
677
|
+
provider: string;
|
|
678
|
+
cwd: string;
|
|
679
|
+
projectName: string;
|
|
680
|
+
}>, "many">;
|
|
681
|
+
}, "strip", z.ZodTypeAny, {
|
|
682
|
+
terminals: {
|
|
683
|
+
terminalId: string;
|
|
684
|
+
status: "running" | "exited";
|
|
685
|
+
provider: string;
|
|
686
|
+
cwd: string;
|
|
687
|
+
projectName: string;
|
|
688
|
+
}[];
|
|
689
|
+
}, {
|
|
690
|
+
terminals: {
|
|
691
|
+
terminalId: string;
|
|
692
|
+
status: "running" | "exited";
|
|
693
|
+
provider: string;
|
|
694
|
+
cwd: string;
|
|
695
|
+
projectName: string;
|
|
696
|
+
}[];
|
|
697
|
+
}>;
|
|
544
698
|
};
|
|
545
699
|
export type ProtocolMessageType = keyof typeof protocolMessageSchemas;
|
|
546
700
|
export declare function createEnvelope<T>(input: {
|
|
@@ -551,6 +705,7 @@ export declare function createEnvelope<T>(input: {
|
|
|
551
705
|
seq?: number;
|
|
552
706
|
ack?: number;
|
|
553
707
|
deviceId?: string;
|
|
708
|
+
terminalId?: string;
|
|
554
709
|
traceId?: string;
|
|
555
710
|
}): Envelope;
|
|
556
711
|
export declare function parseEnvelope(raw: string): Envelope;
|
|
@@ -26,6 +26,7 @@ export const envelopeSchema = z.object({
|
|
|
26
26
|
id: z.string().min(1),
|
|
27
27
|
type: z.string().min(1),
|
|
28
28
|
sessionId: z.string().min(1),
|
|
29
|
+
terminalId: z.string().min(1).optional(),
|
|
29
30
|
deviceId: z.string().min(1).optional(),
|
|
30
31
|
timestamp: z.string().datetime(),
|
|
31
32
|
traceId: z.string().min(1).optional(),
|
|
@@ -55,6 +56,8 @@ export const sessionConnectPayloadSchema = z.object({
|
|
|
55
56
|
protocolVersion: z.number().int().optional(),
|
|
56
57
|
hostname: z.string().optional(),
|
|
57
58
|
platform: z.string().optional(),
|
|
59
|
+
cwd: z.string().optional(),
|
|
60
|
+
projectName: z.string().optional(),
|
|
58
61
|
});
|
|
59
62
|
export const terminalExitPayloadSchema = z.object({
|
|
60
63
|
exitCode: z.number().int().nullable(),
|
|
@@ -128,6 +131,26 @@ export const screenIcePayloadSchema = z.object({
|
|
|
128
131
|
sdpMid: z.string().nullable().optional(),
|
|
129
132
|
sdpMLineIndex: z.number().nullable().optional(),
|
|
130
133
|
});
|
|
134
|
+
// ── Terminal spawn/list payloads ───────────────────────────────────
|
|
135
|
+
export const terminalSpawnPayloadSchema = z.object({
|
|
136
|
+
cwd: z.string().min(1),
|
|
137
|
+
provider: z.enum(["claude", "codex", "custom"]).optional(),
|
|
138
|
+
});
|
|
139
|
+
export const terminalInfoSchema = z.object({
|
|
140
|
+
terminalId: z.string().min(1),
|
|
141
|
+
cwd: z.string(),
|
|
142
|
+
projectName: z.string(),
|
|
143
|
+
provider: z.string(),
|
|
144
|
+
status: z.enum(["running", "exited"]),
|
|
145
|
+
});
|
|
146
|
+
export const terminalListPayloadSchema = z.object({
|
|
147
|
+
terminals: z.array(terminalInfoSchema),
|
|
148
|
+
});
|
|
149
|
+
export const terminalSpawnedPayloadSchema = z.object({
|
|
150
|
+
terminalId: z.string().min(1),
|
|
151
|
+
cwd: z.string(),
|
|
152
|
+
projectName: z.string(),
|
|
153
|
+
});
|
|
131
154
|
// ── File upload payloads ────────────────────────────────────────────
|
|
132
155
|
export const fileUploadPayloadSchema = z.object({
|
|
133
156
|
data: z.string(), // base64 encoded
|
|
@@ -165,6 +188,9 @@ export const protocolMessageSchemas = {
|
|
|
165
188
|
"screen.answer": screenAnswerPayloadSchema,
|
|
166
189
|
"screen.ice": screenIcePayloadSchema,
|
|
167
190
|
"file.upload": fileUploadPayloadSchema,
|
|
191
|
+
"terminal.spawn": terminalSpawnPayloadSchema,
|
|
192
|
+
"terminal.spawned": terminalSpawnedPayloadSchema,
|
|
193
|
+
"terminal.list": terminalListPayloadSchema,
|
|
168
194
|
};
|
|
169
195
|
// ── UUID helper (works in Node, Web, and Expo) ─────────────────────
|
|
170
196
|
function generateId() {
|
|
@@ -183,6 +209,7 @@ export function createEnvelope(input) {
|
|
|
183
209
|
id: input.id ?? generateId(),
|
|
184
210
|
type: input.type,
|
|
185
211
|
sessionId: input.sessionId,
|
|
212
|
+
terminalId: input.terminalId,
|
|
186
213
|
deviceId: input.deviceId,
|
|
187
214
|
timestamp: new Date().toISOString(),
|
|
188
215
|
traceId: input.traceId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../shared-protocol/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uEAAuE;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,uEAAuE;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC;IACvC,iBAAiB;IACjB,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,MAAM;IACN,YAAY;CACb,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,mBAAmB;IACnB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;CACf,CAAC,CAAC;AAGH,uEAAuE;AAEvE,MAAM,CAAC,MAAM,c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AE,KAAK,CAAC,SAAS;QAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAiB;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAW,EACX,OAAgB;IAEhB,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import WebSocket from "ws";
|
|
|
3
3
|
import { hostname, platform } from "node:os";
|
|
4
4
|
import { writeFileSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
|
-
import { join } from "node:path";
|
|
6
|
+
import { join, basename } from "node:path";
|
|
7
7
|
import {
|
|
8
8
|
createEnvelope,
|
|
9
9
|
parseEnvelope,
|
|
@@ -36,6 +36,18 @@ const HEARTBEAT_INTERVAL = 15_000;
|
|
|
36
36
|
const RECONNECT_BASE_DELAY = 1_000;
|
|
37
37
|
const RECONNECT_MAX_DELAY = 30_000;
|
|
38
38
|
const RECONNECT_MAX_ATTEMPTS = 20;
|
|
39
|
+
const DEFAULT_TERMINAL_ID = "default";
|
|
40
|
+
|
|
41
|
+
interface TerminalInstance {
|
|
42
|
+
id: string;
|
|
43
|
+
pty: pty.IPty;
|
|
44
|
+
cwd: string;
|
|
45
|
+
projectName: string;
|
|
46
|
+
provider: string;
|
|
47
|
+
scrollback: ScrollbackBuffer;
|
|
48
|
+
outputSeq: number;
|
|
49
|
+
status: "running" | "exited";
|
|
50
|
+
}
|
|
39
51
|
|
|
40
52
|
function getPairingGatewayParam(gatewayHttpUrl: string): string | undefined {
|
|
41
53
|
try {
|
|
@@ -96,10 +108,7 @@ function resolvePairingGateway(
|
|
|
96
108
|
export class BridgeSession {
|
|
97
109
|
private readonly options: BridgeSessionOptions;
|
|
98
110
|
private socket: WebSocket | undefined;
|
|
99
|
-
private
|
|
100
|
-
private outputSeq = 0;
|
|
101
|
-
private lastAckedSeq = -1;
|
|
102
|
-
private scrollback = new ScrollbackBuffer(1000);
|
|
111
|
+
private terminals = new Map<string, TerminalInstance>();
|
|
103
112
|
private heartbeatTimer: ReturnType<typeof setInterval> | undefined;
|
|
104
113
|
private reconnectTimer: ReturnType<typeof setTimeout> | undefined;
|
|
105
114
|
private reconnectAttempts = 0;
|
|
@@ -128,7 +137,7 @@ export class BridgeSession {
|
|
|
128
137
|
if (!this.sessionId) {
|
|
129
138
|
await this.createPairing();
|
|
130
139
|
}
|
|
131
|
-
this.spawnTerminal();
|
|
140
|
+
this.spawnTerminal(DEFAULT_TERMINAL_ID, process.cwd());
|
|
132
141
|
this.connectGateway();
|
|
133
142
|
}
|
|
134
143
|
|
|
@@ -219,6 +228,8 @@ export class BridgeSession {
|
|
|
219
228
|
protocolVersion: PROTOCOL_VERSION,
|
|
220
229
|
hostname: this.options.hostname || hostname(),
|
|
221
230
|
platform: platform(),
|
|
231
|
+
cwd: process.cwd(),
|
|
232
|
+
projectName: basename(process.cwd()),
|
|
222
233
|
},
|
|
223
234
|
}),
|
|
224
235
|
);
|
|
@@ -251,26 +262,55 @@ export class BridgeSession {
|
|
|
251
262
|
}
|
|
252
263
|
|
|
253
264
|
private handleMessage(envelope: Envelope): void {
|
|
265
|
+
const tid = envelope.terminalId ?? DEFAULT_TERMINAL_ID;
|
|
254
266
|
switch (envelope.type) {
|
|
255
267
|
case "terminal.input": {
|
|
256
268
|
const p = parseTypedPayload("terminal.input", envelope.payload);
|
|
257
|
-
this.
|
|
269
|
+
const term = this.terminals.get(tid);
|
|
270
|
+
if (term && term.status === "running") term.pty.write(p.data);
|
|
258
271
|
break;
|
|
259
272
|
}
|
|
260
273
|
case "terminal.resize": {
|
|
261
274
|
const p = parseTypedPayload("terminal.resize", envelope.payload);
|
|
262
|
-
this.
|
|
275
|
+
const term = this.terminals.get(tid);
|
|
276
|
+
if (term && term.status === "running") term.pty.resize(p.cols, p.rows);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case "terminal.spawn": {
|
|
280
|
+
const p = parseTypedPayload("terminal.spawn", envelope.payload);
|
|
281
|
+
const newId = `term-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
282
|
+
this.spawnTerminal(newId, p.cwd, p.provider);
|
|
283
|
+
// Notify client
|
|
284
|
+
this.send(createEnvelope({
|
|
285
|
+
type: "terminal.spawned",
|
|
286
|
+
sessionId: this.sessionId,
|
|
287
|
+
terminalId: newId,
|
|
288
|
+
payload: { terminalId: newId, cwd: p.cwd, projectName: basename(p.cwd) },
|
|
289
|
+
}));
|
|
290
|
+
// Send updated list
|
|
291
|
+
this.sendTerminalList();
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
case "terminal.list": {
|
|
295
|
+
this.sendTerminalList();
|
|
263
296
|
break;
|
|
264
297
|
}
|
|
265
298
|
case "session.ack": {
|
|
266
299
|
const p = parseTypedPayload("session.ack", envelope.payload);
|
|
267
|
-
|
|
268
|
-
|
|
300
|
+
const term = this.terminals.get(tid);
|
|
301
|
+
if (term) {
|
|
302
|
+
term.scrollback.trimUpTo(p.seq);
|
|
303
|
+
}
|
|
269
304
|
break;
|
|
270
305
|
}
|
|
271
306
|
case "session.resume": {
|
|
272
307
|
const p = parseTypedPayload("session.resume", envelope.payload);
|
|
273
|
-
|
|
308
|
+
// Replay all terminals
|
|
309
|
+
for (const [termId, term] of this.terminals) {
|
|
310
|
+
this.replayFrom(termId, term, p.lastAckedSeq);
|
|
311
|
+
}
|
|
312
|
+
// Also send terminal list so client knows what's available
|
|
313
|
+
this.sendTerminalList();
|
|
274
314
|
break;
|
|
275
315
|
}
|
|
276
316
|
case "session.heartbeat":
|
|
@@ -300,9 +340,10 @@ export class BridgeSession {
|
|
|
300
340
|
const tempPath = join(tmpdir(), `linkshell-image-${Date.now()}.${ext}`);
|
|
301
341
|
writeFileSync(tempPath, Buffer.from(p.data, "base64"));
|
|
302
342
|
this.log(`image saved to ${tempPath}`);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
343
|
+
const term = this.terminals.get(tid);
|
|
344
|
+
if (term && term.status === "running") {
|
|
345
|
+
term.pty.write(`\x1b[200~${tempPath}\x1b[201~`);
|
|
346
|
+
}
|
|
306
347
|
break;
|
|
307
348
|
}
|
|
308
349
|
default:
|
|
@@ -310,8 +351,23 @@ export class BridgeSession {
|
|
|
310
351
|
}
|
|
311
352
|
}
|
|
312
353
|
|
|
313
|
-
private
|
|
314
|
-
const
|
|
354
|
+
private sendTerminalList(): void {
|
|
355
|
+
const terminals = [...this.terminals.values()].map((t) => ({
|
|
356
|
+
terminalId: t.id,
|
|
357
|
+
cwd: t.cwd,
|
|
358
|
+
projectName: t.projectName,
|
|
359
|
+
provider: t.provider,
|
|
360
|
+
status: t.status,
|
|
361
|
+
}));
|
|
362
|
+
this.send(createEnvelope({
|
|
363
|
+
type: "terminal.list",
|
|
364
|
+
sessionId: this.sessionId,
|
|
365
|
+
payload: { terminals },
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private replayFrom(terminalId: string, term: TerminalInstance, afterSeq: number): void {
|
|
370
|
+
const messages = term.scrollback.replayFrom(afterSeq);
|
|
315
371
|
for (const msg of messages) {
|
|
316
372
|
const payload = msg.payload as {
|
|
317
373
|
stream: string;
|
|
@@ -324,6 +380,7 @@ export class BridgeSession {
|
|
|
324
380
|
createEnvelope({
|
|
325
381
|
type: "terminal.output",
|
|
326
382
|
sessionId: this.sessionId,
|
|
383
|
+
terminalId,
|
|
327
384
|
seq: msg.seq,
|
|
328
385
|
payload: { ...payload, isReplay: true },
|
|
329
386
|
}),
|
|
@@ -331,30 +388,39 @@ export class BridgeSession {
|
|
|
331
388
|
}
|
|
332
389
|
}
|
|
333
390
|
|
|
334
|
-
private spawnTerminal(): void {
|
|
335
|
-
// Filter out undefined env values — node-pty's native posix_spawnp chokes on them
|
|
391
|
+
private spawnTerminal(terminalId: string, cwd: string, providerOverride?: string): void {
|
|
336
392
|
const cleanEnv: Record<string, string> = {};
|
|
337
393
|
for (const [k, v] of Object.entries(this.options.providerConfig.env)) {
|
|
338
394
|
if (v !== undefined) cleanEnv[k] = v;
|
|
339
395
|
}
|
|
340
396
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
397
|
+
const term: TerminalInstance = {
|
|
398
|
+
id: terminalId,
|
|
399
|
+
pty: pty.spawn(
|
|
400
|
+
this.options.providerConfig.command,
|
|
401
|
+
this.options.providerConfig.args,
|
|
402
|
+
{
|
|
403
|
+
name: "xterm-256color",
|
|
404
|
+
cols: this.options.cols,
|
|
405
|
+
rows: this.options.rows,
|
|
406
|
+
cwd,
|
|
407
|
+
env: cleanEnv,
|
|
408
|
+
},
|
|
409
|
+
),
|
|
410
|
+
cwd,
|
|
411
|
+
projectName: basename(cwd),
|
|
412
|
+
provider: providerOverride ?? this.options.providerConfig.provider,
|
|
413
|
+
scrollback: new ScrollbackBuffer(1000),
|
|
414
|
+
outputSeq: 0,
|
|
415
|
+
status: "running",
|
|
416
|
+
};
|
|
352
417
|
|
|
353
|
-
|
|
354
|
-
const seq =
|
|
418
|
+
term.pty.onData((data) => {
|
|
419
|
+
const seq = term.outputSeq++;
|
|
355
420
|
const envelope = createEnvelope({
|
|
356
421
|
type: "terminal.output",
|
|
357
422
|
sessionId: this.sessionId,
|
|
423
|
+
terminalId,
|
|
358
424
|
seq,
|
|
359
425
|
payload: {
|
|
360
426
|
stream: "stdout" as const,
|
|
@@ -364,24 +430,34 @@ export class BridgeSession {
|
|
|
364
430
|
isFinal: false,
|
|
365
431
|
},
|
|
366
432
|
});
|
|
367
|
-
|
|
433
|
+
term.scrollback.push(envelope);
|
|
368
434
|
this.send(envelope);
|
|
369
435
|
});
|
|
370
436
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
437
|
+
term.pty.onExit(({ exitCode, signal }) => {
|
|
438
|
+
term.status = "exited";
|
|
439
|
+
this.send(createEnvelope({
|
|
374
440
|
type: "terminal.exit",
|
|
375
441
|
sessionId: this.sessionId,
|
|
442
|
+
terminalId,
|
|
376
443
|
payload: { exitCode, signal },
|
|
377
|
-
});
|
|
378
|
-
this.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
444
|
+
}));
|
|
445
|
+
this.sendTerminalList();
|
|
446
|
+
|
|
447
|
+
// If all terminals exited, close the session
|
|
448
|
+
const allExited = [...this.terminals.values()].every((t) => t.status === "exited");
|
|
449
|
+
if (allExited) {
|
|
450
|
+
this.exited = true;
|
|
451
|
+
setTimeout(() => {
|
|
452
|
+
this.stopHeartbeat();
|
|
453
|
+
this.socket?.close();
|
|
454
|
+
}, 500);
|
|
455
|
+
process.exitCode = exitCode ?? 0;
|
|
456
|
+
}
|
|
384
457
|
});
|
|
458
|
+
|
|
459
|
+
this.terminals.set(terminalId, term);
|
|
460
|
+
this.log(`spawned terminal ${terminalId} in ${cwd}`);
|
|
385
461
|
}
|
|
386
462
|
|
|
387
463
|
private send(message: Envelope): void {
|
|
@@ -515,7 +591,10 @@ export class BridgeSession {
|
|
|
515
591
|
}
|
|
516
592
|
this.socket?.close();
|
|
517
593
|
this.socket = undefined;
|
|
518
|
-
this.
|
|
594
|
+
for (const term of this.terminals.values()) {
|
|
595
|
+
if (term.status === "running") term.pty.kill();
|
|
596
|
+
}
|
|
597
|
+
this.terminals.clear();
|
|
519
598
|
process.exitCode = exitCode;
|
|
520
599
|
}
|
|
521
600
|
}
|