@gjermundgaraba/clankermux 0.2.0 → 0.4.0
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/README.md +91 -30
- package/dist/client/attachment.d.ts +1 -0
- package/dist/client/attachment.js +1 -1
- package/dist/client/client.d.ts +123 -0
- package/dist/client/client.js +268 -0
- package/dist/client/connection.d.ts +17 -2
- package/dist/client/connection.js +21 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +1 -1
- package/dist/client/mount.d.ts +45 -42
- package/dist/client/mount.js +77 -56
- package/dist/client/worker.d.ts +115 -46
- package/dist/client/worker.js +457 -218
- package/dist/proto/messages.d.ts +358 -11
- package/package.json +4 -3
package/dist/proto/messages.d.ts
CHANGED
|
@@ -20,9 +20,12 @@ export interface Limits {
|
|
|
20
20
|
text: number;
|
|
21
21
|
markers: number;
|
|
22
22
|
records: number;
|
|
23
|
+
commands: number;
|
|
23
24
|
page: number;
|
|
24
25
|
hello_timeout: number;
|
|
25
26
|
remove_grace: number;
|
|
27
|
+
events: number;
|
|
28
|
+
attachments: number;
|
|
26
29
|
}
|
|
27
30
|
export interface Welcome {
|
|
28
31
|
version: number;
|
|
@@ -41,7 +44,7 @@ export interface Reply {
|
|
|
41
44
|
id: number;
|
|
42
45
|
result: unknown;
|
|
43
46
|
}
|
|
44
|
-
export type ErrorCode = "protocol_error" | "version_mismatch" | "invalid_request" | "limit_exceeded" | "no_such_session" | "not_running" | "running" | "signal_failed" | "engine_mismatch" | "channel_in_use" | "read_only" | "input_overflow" | "too_slow" | "internal";
|
|
47
|
+
export type ErrorCode = "protocol_error" | "version_mismatch" | "invalid_request" | "limit_exceeded" | "no_such_session" | "not_running" | "running" | "signal_failed" | "engine_mismatch" | "channel_in_use" | "read_only" | "input_overflow" | "too_slow" | "cancelled" | "scope_unavailable" | "internal" | "no_such_attachment";
|
|
45
48
|
export interface ErrorMessage {
|
|
46
49
|
id?: number;
|
|
47
50
|
code: ErrorCode;
|
|
@@ -64,6 +67,28 @@ export interface StatusRecord {
|
|
|
64
67
|
msg?: string;
|
|
65
68
|
progress?: number;
|
|
66
69
|
updated_at: string;
|
|
70
|
+
/** On `done` and `error` records only: false until `ack`. */
|
|
71
|
+
seen?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** `Session.attention`: the most urgent record that wants the user. */
|
|
74
|
+
export interface Attention {
|
|
75
|
+
state: string;
|
|
76
|
+
kind?: string;
|
|
77
|
+
app?: string;
|
|
78
|
+
msg?: string;
|
|
79
|
+
/** The record's id. */
|
|
80
|
+
record: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* One command from its OSC 133 marks, as stream offsets: `start` at the
|
|
84
|
+
* prompt (`A`), `output` where its output begins (`C`), `end` where it
|
|
85
|
+
* ended (`D`) with the `exit` the shell reported.
|
|
86
|
+
*/
|
|
87
|
+
export interface Command {
|
|
88
|
+
start: number;
|
|
89
|
+
output?: number;
|
|
90
|
+
end?: number;
|
|
91
|
+
exit?: number;
|
|
67
92
|
}
|
|
68
93
|
export interface Session {
|
|
69
94
|
id: string;
|
|
@@ -82,13 +107,55 @@ export interface Session {
|
|
|
82
107
|
exit?: Exit;
|
|
83
108
|
offset: number;
|
|
84
109
|
marker: number;
|
|
85
|
-
attachments
|
|
110
|
+
/** Open attachments, in the order they opened. */
|
|
111
|
+
attachments: AttachmentInfo[];
|
|
112
|
+
command?: Command;
|
|
86
113
|
program_status?: StatusRecord[];
|
|
114
|
+
attention?: Attention;
|
|
115
|
+
size: SizeInfo;
|
|
116
|
+
}
|
|
117
|
+
/** One open attachment of a session. */
|
|
118
|
+
export interface AttachmentInfo {
|
|
119
|
+
/** Unique on the server and never reused: `detach` takes it. */
|
|
120
|
+
channel: number;
|
|
121
|
+
/** The connection's `HELLO.client`. */
|
|
122
|
+
client: Peer;
|
|
123
|
+
read_only: boolean;
|
|
124
|
+
/** The size of its latest viewport report, if it made one. */
|
|
125
|
+
viewport?: {
|
|
126
|
+
cols: number;
|
|
127
|
+
rows: number;
|
|
128
|
+
};
|
|
129
|
+
since: string;
|
|
130
|
+
last_input?: string;
|
|
131
|
+
}
|
|
132
|
+
/** `latest`: the most recent report wins; `smallest`: the smallest
|
|
133
|
+
* columns and rows among the attachments' reports; `fixed`: only `resize`
|
|
134
|
+
* changes the size. */
|
|
135
|
+
export type SizePolicy = "latest" | "smallest" | "fixed";
|
|
136
|
+
export interface SizeInfo {
|
|
137
|
+
policy: SizePolicy;
|
|
138
|
+
/** Under `latest`, the attachment whose report is current. */
|
|
139
|
+
owner?: number;
|
|
87
140
|
}
|
|
88
141
|
export interface Page {
|
|
89
142
|
sessions: Session[];
|
|
90
143
|
next?: string;
|
|
91
144
|
}
|
|
145
|
+
/** `subscribe`: `after` and `incarnation` together replay the events after
|
|
146
|
+
* `after`. */
|
|
147
|
+
export interface SubscribeParams {
|
|
148
|
+
after?: number;
|
|
149
|
+
incarnation?: string;
|
|
150
|
+
}
|
|
151
|
+
/** The `subscribe` reply: the first page without `after`, `gap` with it. */
|
|
152
|
+
export interface Subscribed {
|
|
153
|
+
sessions?: Session[];
|
|
154
|
+
next?: string;
|
|
155
|
+
oldest: number;
|
|
156
|
+
latest: number;
|
|
157
|
+
gap?: boolean;
|
|
158
|
+
}
|
|
92
159
|
export interface Read {
|
|
93
160
|
text: string;
|
|
94
161
|
cols: number;
|
|
@@ -99,6 +166,14 @@ export interface Read {
|
|
|
99
166
|
};
|
|
100
167
|
offset: number;
|
|
101
168
|
status: Status;
|
|
169
|
+
truncated?: boolean;
|
|
170
|
+
}
|
|
171
|
+
export interface Tail {
|
|
172
|
+
text: string;
|
|
173
|
+
start_offset: number;
|
|
174
|
+
next_offset: number;
|
|
175
|
+
complete: boolean;
|
|
176
|
+
truncated?: boolean;
|
|
102
177
|
}
|
|
103
178
|
export interface ListParams {
|
|
104
179
|
after?: string;
|
|
@@ -110,23 +185,111 @@ export interface SignalParams {
|
|
|
110
185
|
session: string;
|
|
111
186
|
signal: string;
|
|
112
187
|
}
|
|
113
|
-
export interface
|
|
188
|
+
export interface LabelParams {
|
|
114
189
|
session: string;
|
|
115
190
|
label: string;
|
|
116
191
|
}
|
|
117
|
-
|
|
192
|
+
/** `resize`: a side left out keeps the session's; so does a policy. */
|
|
193
|
+
export interface ResizeParams {
|
|
118
194
|
session: string;
|
|
119
|
-
cols
|
|
120
|
-
rows
|
|
195
|
+
cols?: number;
|
|
196
|
+
rows?: number;
|
|
197
|
+
policy?: SizePolicy;
|
|
198
|
+
}
|
|
199
|
+
/** `detach`: `reason` reaches the attachment as `CLOSED.message`. */
|
|
200
|
+
export interface DetachParams {
|
|
201
|
+
session: string;
|
|
202
|
+
channel: number;
|
|
203
|
+
reason?: string;
|
|
121
204
|
}
|
|
205
|
+
export type ReadFormat = "text" | "vt" | "html";
|
|
206
|
+
export type ReadScope = "screen" | "history" | "alternate" | "last_command";
|
|
122
207
|
export interface ReadParams {
|
|
123
208
|
session: string;
|
|
124
209
|
scrollback?: number;
|
|
210
|
+
format?: ReadFormat;
|
|
211
|
+
scope?: ReadScope;
|
|
212
|
+
}
|
|
213
|
+
export interface TailParams {
|
|
214
|
+
session: string;
|
|
215
|
+
after: number;
|
|
216
|
+
max_bytes?: number;
|
|
125
217
|
}
|
|
126
|
-
|
|
218
|
+
/** `send`: exactly one of `text`, `keys` and `data`. */
|
|
219
|
+
export interface SendParams {
|
|
127
220
|
session: string;
|
|
128
|
-
/**
|
|
129
|
-
|
|
221
|
+
/** UTF-8, written as typed. */
|
|
222
|
+
text?: string;
|
|
223
|
+
/** Key names, encoded by the session's terminal. */
|
|
224
|
+
keys?: string[];
|
|
225
|
+
/** Base64 bytes. */
|
|
226
|
+
data?: string;
|
|
227
|
+
/** `text` or `data` as a paste, bracketed when mode 2004 is set. */
|
|
228
|
+
paste?: boolean;
|
|
229
|
+
/** A wait armed before the bytes are written. */
|
|
230
|
+
wait?: SendWait;
|
|
231
|
+
}
|
|
232
|
+
export interface SendWait {
|
|
233
|
+
until: Until;
|
|
234
|
+
timeout_ms?: number;
|
|
235
|
+
}
|
|
236
|
+
/** What a wait waits for: one or more facts, the first to hold wins. */
|
|
237
|
+
export interface Until {
|
|
238
|
+
exited?: true;
|
|
239
|
+
/** Exactly one of `text` and `regex`. */
|
|
240
|
+
output?: {
|
|
241
|
+
text?: string;
|
|
242
|
+
regex?: string;
|
|
243
|
+
};
|
|
244
|
+
status?: {
|
|
245
|
+
states: string[];
|
|
246
|
+
record?: string;
|
|
247
|
+
};
|
|
248
|
+
prompt?: true;
|
|
249
|
+
quiet_ms?: number;
|
|
250
|
+
}
|
|
251
|
+
/** A stream cursor: the next byte's offset and the latest marker reflected. */
|
|
252
|
+
export interface StreamCursor {
|
|
253
|
+
offset: number;
|
|
254
|
+
marker: number;
|
|
255
|
+
}
|
|
256
|
+
export interface WaitParams {
|
|
257
|
+
session: string;
|
|
258
|
+
until: Until;
|
|
259
|
+
after?: StreamCursor;
|
|
260
|
+
timeout_ms?: number;
|
|
261
|
+
}
|
|
262
|
+
export interface CancelParams {
|
|
263
|
+
id: number;
|
|
264
|
+
}
|
|
265
|
+
export type WaitReason = "exited" | "matched" | "status" | "prompt" | "quiet" | "timeout";
|
|
266
|
+
/** The `wait` result. */
|
|
267
|
+
export interface Waited {
|
|
268
|
+
reason: WaitReason;
|
|
269
|
+
at: StreamCursor;
|
|
270
|
+
exit?: Exit;
|
|
271
|
+
match?: {
|
|
272
|
+
text: string;
|
|
273
|
+
offset: number;
|
|
274
|
+
};
|
|
275
|
+
record?: StatusRecord;
|
|
276
|
+
}
|
|
277
|
+
/** The `send` result. */
|
|
278
|
+
export interface Sent {
|
|
279
|
+
/** The cursor once the PTY took the bytes. */
|
|
280
|
+
at: StreamCursor;
|
|
281
|
+
wait?: Waited;
|
|
282
|
+
}
|
|
283
|
+
/** The `cancel` result. */
|
|
284
|
+
export interface Cancelled {
|
|
285
|
+
cancelled: boolean;
|
|
286
|
+
}
|
|
287
|
+
export interface AckParams {
|
|
288
|
+
session: string;
|
|
289
|
+
record_ids?: string[];
|
|
290
|
+
}
|
|
291
|
+
export interface Acked {
|
|
292
|
+
record_ids: string[];
|
|
130
293
|
}
|
|
131
294
|
export interface CreateParams {
|
|
132
295
|
label?: string;
|
|
@@ -137,7 +300,12 @@ export interface CreateParams {
|
|
|
137
300
|
rows?: number;
|
|
138
301
|
on_exit?: OnExit;
|
|
139
302
|
}
|
|
303
|
+
export type StatusReason = "report" | "clear" | "prompt" | "exit" | "restore" | "evicted" | "ack";
|
|
304
|
+
export type ProgressState = "remove" | "set" | "error" | "indeterminate" | "pause";
|
|
305
|
+
/** `EVENT`: `seq` counts from 1 per server incarnation. */
|
|
140
306
|
export type Event = {
|
|
307
|
+
seq: number;
|
|
308
|
+
} & ({
|
|
141
309
|
event: "session_created";
|
|
142
310
|
session: Session;
|
|
143
311
|
} | {
|
|
@@ -153,11 +321,46 @@ export type Event = {
|
|
|
153
321
|
event: "program_status_changed";
|
|
154
322
|
id: string;
|
|
155
323
|
record: StatusRecord;
|
|
324
|
+
reason: StatusReason;
|
|
156
325
|
} | {
|
|
157
326
|
event: "program_status_removed";
|
|
158
327
|
id: string;
|
|
159
328
|
record_ids: string[];
|
|
160
|
-
|
|
329
|
+
reason: StatusReason;
|
|
330
|
+
} | {
|
|
331
|
+
event: "bell";
|
|
332
|
+
id: string;
|
|
333
|
+
} | {
|
|
334
|
+
event: "notification";
|
|
335
|
+
id: string;
|
|
336
|
+
title: string;
|
|
337
|
+
body: string;
|
|
338
|
+
} | {
|
|
339
|
+
event: "progress";
|
|
340
|
+
id: string;
|
|
341
|
+
state: ProgressState;
|
|
342
|
+
progress?: number;
|
|
343
|
+
} | {
|
|
344
|
+
event: "command_started";
|
|
345
|
+
id: string;
|
|
346
|
+
offset: number;
|
|
347
|
+
} | {
|
|
348
|
+
event: "command_ended";
|
|
349
|
+
id: string;
|
|
350
|
+
offset: number;
|
|
351
|
+
exit?: number;
|
|
352
|
+
} | {
|
|
353
|
+
event: "attachment_opened";
|
|
354
|
+
id: string;
|
|
355
|
+
channel: number;
|
|
356
|
+
client: Peer;
|
|
357
|
+
read_only: boolean;
|
|
358
|
+
} | {
|
|
359
|
+
event: "attachment_closed";
|
|
360
|
+
id: string;
|
|
361
|
+
channel: number;
|
|
362
|
+
reason: string;
|
|
363
|
+
});
|
|
161
364
|
export type Scheme = "light" | "dark";
|
|
162
365
|
export interface Profile {
|
|
163
366
|
fg?: string;
|
|
@@ -214,5 +417,149 @@ export interface Gap {
|
|
|
214
417
|
to: number;
|
|
215
418
|
}
|
|
216
419
|
export interface Closed {
|
|
217
|
-
reason: "closed" | "removed" | "stopping";
|
|
420
|
+
reason: "closed" | "removed" | "stopping" | "detached";
|
|
421
|
+
/** The reason a `detach` gave. */
|
|
422
|
+
message?: string;
|
|
423
|
+
}
|
|
424
|
+
/** The result of a method that answers with success alone. */
|
|
425
|
+
export type Empty = Record<string, never>;
|
|
426
|
+
/** `describe`: one method, or the whole catalog. */
|
|
427
|
+
export interface DescribeParams {
|
|
428
|
+
method?: string;
|
|
429
|
+
}
|
|
430
|
+
/** A JSON Schema (2020-12); `$ref`s point into the catalog's `$defs`. */
|
|
431
|
+
export type JsonSchema = {
|
|
432
|
+
[key: string]: unknown;
|
|
433
|
+
} | boolean;
|
|
434
|
+
/** `read` answers from the server's state; `mutation` changes it;
|
|
435
|
+
* `stream` starts frames that follow the reply. */
|
|
436
|
+
export type Class = "read" | "mutation" | "stream";
|
|
437
|
+
/** One method of `REQUEST`. */
|
|
438
|
+
export interface MethodInfo {
|
|
439
|
+
name: string;
|
|
440
|
+
class: Class;
|
|
441
|
+
summary: string;
|
|
442
|
+
/** Objects refuse undefined fields. */
|
|
443
|
+
params: JsonSchema;
|
|
444
|
+
/** Objects may gain fields. */
|
|
445
|
+
result: JsonSchema;
|
|
446
|
+
/** The codes its `ERROR` can carry. */
|
|
447
|
+
errors: ErrorCode[];
|
|
448
|
+
examples: {
|
|
449
|
+
params: unknown;
|
|
450
|
+
result: unknown;
|
|
451
|
+
}[];
|
|
452
|
+
}
|
|
453
|
+
/** One kind of `EVENT`. */
|
|
454
|
+
export interface EventInfo {
|
|
455
|
+
name: string;
|
|
456
|
+
summary: string;
|
|
457
|
+
/** The event without `seq`. */
|
|
458
|
+
schema: JsonSchema;
|
|
459
|
+
/** `EVENT` payloads, with `seq`. */
|
|
460
|
+
examples: unknown[];
|
|
461
|
+
}
|
|
462
|
+
export interface FrameInfo {
|
|
463
|
+
name: string;
|
|
464
|
+
type: number;
|
|
465
|
+
direction: "client" | "server";
|
|
466
|
+
/** `0`, `n`, or `0 or n`. */
|
|
467
|
+
channel: string;
|
|
468
|
+
payload: "json" | "raw" | "empty";
|
|
469
|
+
summary: string;
|
|
470
|
+
schema?: JsonSchema;
|
|
471
|
+
}
|
|
472
|
+
export interface ErrorInfo {
|
|
473
|
+
code: ErrorCode;
|
|
474
|
+
summary: string;
|
|
475
|
+
}
|
|
476
|
+
/** The `describe {}` result. */
|
|
477
|
+
export interface Catalog {
|
|
478
|
+
protocol: number;
|
|
479
|
+
/** The server's release. */
|
|
480
|
+
version: string;
|
|
481
|
+
methods: MethodInfo[];
|
|
482
|
+
events: EventInfo[];
|
|
483
|
+
frames: FrameInfo[];
|
|
484
|
+
errors: ErrorInfo[];
|
|
485
|
+
$defs: Record<string, JsonSchema>;
|
|
486
|
+
}
|
|
487
|
+
/** The `describe {method}` result: the method and the schemas it refers to. */
|
|
488
|
+
export interface Description {
|
|
489
|
+
protocol: number;
|
|
490
|
+
version: string;
|
|
491
|
+
method: MethodInfo;
|
|
492
|
+
$defs: Record<string, JsonSchema>;
|
|
493
|
+
}
|
|
494
|
+
/** Each method's params and result, as the catalog lists them. */
|
|
495
|
+
export interface Methods {
|
|
496
|
+
create: {
|
|
497
|
+
params: CreateParams;
|
|
498
|
+
result: Session;
|
|
499
|
+
};
|
|
500
|
+
list: {
|
|
501
|
+
params: ListParams;
|
|
502
|
+
result: Page;
|
|
503
|
+
};
|
|
504
|
+
inspect: {
|
|
505
|
+
params: SessionParams;
|
|
506
|
+
result: Session;
|
|
507
|
+
};
|
|
508
|
+
end: {
|
|
509
|
+
params: SessionParams;
|
|
510
|
+
result: Empty;
|
|
511
|
+
};
|
|
512
|
+
signal: {
|
|
513
|
+
params: SignalParams;
|
|
514
|
+
result: Empty;
|
|
515
|
+
};
|
|
516
|
+
remove: {
|
|
517
|
+
params: SessionParams;
|
|
518
|
+
result: Empty;
|
|
519
|
+
};
|
|
520
|
+
label: {
|
|
521
|
+
params: LabelParams;
|
|
522
|
+
result: Session;
|
|
523
|
+
};
|
|
524
|
+
resize: {
|
|
525
|
+
params: ResizeParams;
|
|
526
|
+
result: Empty;
|
|
527
|
+
};
|
|
528
|
+
read: {
|
|
529
|
+
params: ReadParams;
|
|
530
|
+
result: Read;
|
|
531
|
+
};
|
|
532
|
+
tail: {
|
|
533
|
+
params: TailParams;
|
|
534
|
+
result: Tail;
|
|
535
|
+
};
|
|
536
|
+
send: {
|
|
537
|
+
params: SendParams;
|
|
538
|
+
result: Sent;
|
|
539
|
+
};
|
|
540
|
+
wait: {
|
|
541
|
+
params: WaitParams;
|
|
542
|
+
result: Waited;
|
|
543
|
+
};
|
|
544
|
+
cancel: {
|
|
545
|
+
params: CancelParams;
|
|
546
|
+
result: Cancelled;
|
|
547
|
+
};
|
|
548
|
+
detach: {
|
|
549
|
+
params: DetachParams;
|
|
550
|
+
result: Empty;
|
|
551
|
+
};
|
|
552
|
+
subscribe: {
|
|
553
|
+
params: SubscribeParams;
|
|
554
|
+
result: Subscribed;
|
|
555
|
+
};
|
|
556
|
+
ack: {
|
|
557
|
+
params: AckParams;
|
|
558
|
+
result: Acked;
|
|
559
|
+
};
|
|
560
|
+
describe: {
|
|
561
|
+
params: DescribeParams;
|
|
562
|
+
result: Description | Catalog;
|
|
563
|
+
};
|
|
218
564
|
}
|
|
565
|
+
export type Method = keyof Methods;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjermundgaraba/clankermux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"ws": "^8.18.0",
|
|
44
|
-
"
|
|
43
|
+
"@types/ws": "^8.18.0",
|
|
44
|
+
"ajv": "^8.20.0",
|
|
45
|
+
"ws": "^8.18.0"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.worker.json",
|