@gjermundgaraba/clankermux 0.3.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.
@@ -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" | "cancelled" | "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: number;
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;
@@ -114,15 +189,31 @@ export interface LabelParams {
114
189
  session: string;
115
190
  label: string;
116
191
  }
117
- /** `resize`: a side left out keeps the session's. */
192
+ /** `resize`: a side left out keeps the session's; so does a policy. */
118
193
  export interface ResizeParams {
119
194
  session: string;
120
195
  cols?: number;
121
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;
122
204
  }
205
+ export type ReadFormat = "text" | "vt" | "html";
206
+ export type ReadScope = "screen" | "history" | "alternate" | "last_command";
123
207
  export interface ReadParams {
124
208
  session: string;
125
209
  scrollback?: number;
210
+ format?: ReadFormat;
211
+ scope?: ReadScope;
212
+ }
213
+ export interface TailParams {
214
+ session: string;
215
+ after: number;
216
+ max_bytes?: number;
126
217
  }
127
218
  /** `send`: exactly one of `text`, `keys` and `data`. */
128
219
  export interface SendParams {
@@ -193,6 +284,13 @@ export interface Sent {
193
284
  export interface Cancelled {
194
285
  cancelled: boolean;
195
286
  }
287
+ export interface AckParams {
288
+ session: string;
289
+ record_ids?: string[];
290
+ }
291
+ export interface Acked {
292
+ record_ids: string[];
293
+ }
196
294
  export interface CreateParams {
197
295
  label?: string;
198
296
  argv?: string[];
@@ -202,7 +300,12 @@ export interface CreateParams {
202
300
  rows?: number;
203
301
  on_exit?: OnExit;
204
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. */
205
306
  export type Event = {
307
+ seq: number;
308
+ } & ({
206
309
  event: "session_created";
207
310
  session: Session;
208
311
  } | {
@@ -218,11 +321,46 @@ export type Event = {
218
321
  event: "program_status_changed";
219
322
  id: string;
220
323
  record: StatusRecord;
324
+ reason: StatusReason;
221
325
  } | {
222
326
  event: "program_status_removed";
223
327
  id: string;
224
328
  record_ids: string[];
225
- };
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
+ });
226
364
  export type Scheme = "light" | "dark";
227
365
  export interface Profile {
228
366
  fg?: string;
@@ -279,5 +417,149 @@ export interface Gap {
279
417
  to: number;
280
418
  }
281
419
  export interface Closed {
282
- 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
+ };
283
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.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
- "@types/ws": "^8.18.0"
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",