@gjermundgaraba/clankermux 0.2.0 → 0.3.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.
@@ -74,7 +74,7 @@ class Client {
74
74
  /** The session attached or being attached. */
75
75
  session;
76
76
  sessions = new Map();
77
- /** Input in order: a paste goes as `write` requests, and keys typed
77
+ /** Input in order: a paste goes as `send` requests, and keys typed
78
78
  * meanwhile wait behind it. `attach` starts a fresh chain; input queued
79
79
  * for an attachment that is gone is dropped, but a paste under way
80
80
  * finishes (cut short, it would leave the program inside a bracketed
@@ -532,7 +532,7 @@ class Client {
532
532
  this.post({ type: "done", id, error });
533
533
  }
534
534
  /** Input for the session, dropped unless attached on a live connection.
535
- * Keys go as INPUT; a paste goes as `write` requests, each answered
535
+ * Keys go as INPUT; a paste goes as `send` requests, each answered
536
536
  * once the PTY took it, since INPUT frames are not acknowledged and a
537
537
  * paste would overflow the input queue. This tab's input is sent in
538
538
  * order, so none of it lands inside a paste. */
@@ -560,7 +560,7 @@ class Client {
560
560
  return;
561
561
  }
562
562
  for (let at = 0; at < bytes.length; at += chunk) {
563
- await conn.call("write", { session, data: base64(bytes.subarray(at, at + chunk)) });
563
+ await conn.call("send", { session, data: base64(bytes.subarray(at, at + chunk)) });
564
564
  }
565
565
  }
566
566
  catch (err) {
@@ -41,7 +41,7 @@ export interface Reply {
41
41
  id: number;
42
42
  result: unknown;
43
43
  }
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";
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";
45
45
  export interface ErrorMessage {
46
46
  id?: number;
47
47
  code: ErrorCode;
@@ -110,23 +110,88 @@ export interface SignalParams {
110
110
  session: string;
111
111
  signal: string;
112
112
  }
113
- export interface SetLabelParams {
113
+ export interface LabelParams {
114
114
  session: string;
115
115
  label: string;
116
116
  }
117
- export interface SetSizeParams {
117
+ /** `resize`: a side left out keeps the session's. */
118
+ export interface ResizeParams {
118
119
  session: string;
119
- cols: number;
120
- rows: number;
120
+ cols?: number;
121
+ rows?: number;
121
122
  }
122
123
  export interface ReadParams {
123
124
  session: string;
124
125
  scrollback?: number;
125
126
  }
126
- export interface WriteParams {
127
+ /** `send`: exactly one of `text`, `keys` and `data`. */
128
+ export interface SendParams {
129
+ session: string;
130
+ /** UTF-8, written as typed. */
131
+ text?: string;
132
+ /** Key names, encoded by the session's terminal. */
133
+ keys?: string[];
134
+ /** Base64 bytes. */
135
+ data?: string;
136
+ /** `text` or `data` as a paste, bracketed when mode 2004 is set. */
137
+ paste?: boolean;
138
+ /** A wait armed before the bytes are written. */
139
+ wait?: SendWait;
140
+ }
141
+ export interface SendWait {
142
+ until: Until;
143
+ timeout_ms?: number;
144
+ }
145
+ /** What a wait waits for: one or more facts, the first to hold wins. */
146
+ export interface Until {
147
+ exited?: true;
148
+ /** Exactly one of `text` and `regex`. */
149
+ output?: {
150
+ text?: string;
151
+ regex?: string;
152
+ };
153
+ status?: {
154
+ states: string[];
155
+ record?: string;
156
+ };
157
+ prompt?: true;
158
+ quiet_ms?: number;
159
+ }
160
+ /** A stream cursor: the next byte's offset and the latest marker reflected. */
161
+ export interface StreamCursor {
162
+ offset: number;
163
+ marker: number;
164
+ }
165
+ export interface WaitParams {
127
166
  session: string;
128
- /** Base64. */
129
- data: string;
167
+ until: Until;
168
+ after?: StreamCursor;
169
+ timeout_ms?: number;
170
+ }
171
+ export interface CancelParams {
172
+ id: number;
173
+ }
174
+ export type WaitReason = "exited" | "matched" | "status" | "prompt" | "quiet" | "timeout";
175
+ /** The `wait` result. */
176
+ export interface Waited {
177
+ reason: WaitReason;
178
+ at: StreamCursor;
179
+ exit?: Exit;
180
+ match?: {
181
+ text: string;
182
+ offset: number;
183
+ };
184
+ record?: StatusRecord;
185
+ }
186
+ /** The `send` result. */
187
+ export interface Sent {
188
+ /** The cursor once the PTY took the bytes. */
189
+ at: StreamCursor;
190
+ wait?: Waited;
191
+ }
192
+ /** The `cancel` result. */
193
+ export interface Cancelled {
194
+ cancelled: boolean;
130
195
  }
131
196
  export interface CreateParams {
132
197
  label?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/clankermux",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",