@linxiraos/pi-wire 1.4.6 → 1.4.9

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/CHANGELOG.md CHANGED
@@ -1,8 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.4.9] - 2026-11-03
4
+
5
+ - Synced with upstream OMP v18.16.0; no package-specific user-visible changes.
6
+
7
+ ## [1.4.7] - 2026-10-30
8
+
9
+ - Regenerated RPC/SDK wire from the OMP v18.14.0 schema; no user-facing API changes.
10
+
3
11
  ## [1.4.6] - 2026-10-28
4
12
 
5
- - Released as part of Zeta 1.4.6; no package-specific user-visible changes.
13
+ ### Added
14
+
15
+ - Added the TSP `json` kind for displaying raw JSON values as interactive, expandable trees in the terminal.
16
+ - Added `TspEditorProps.typeahead` support so programs that cannot yet read input can preserve typed text, display it at the caret, and submit it when input becomes available.
6
17
 
7
18
  ## [1.4.5] - 2026-10-28
8
19
 
@@ -430,6 +430,19 @@ export declare const COLLAB_PROTO = 3;
430
430
  export declare const INTENT_FIELD = "i";
431
431
  /** Plaintext envelope prefix: `[4B uint32 BE peerId][sealed payload]`. */
432
432
  export declare const ENVELOPE_HEADER_LENGTH = 4;
433
+ /**
434
+ * Prefix `sealed` with its envelope header. Host→relay: peerId 0 broadcasts to
435
+ * all guests, peerId N targets guest N. Guest→relay: always 0; the relay
436
+ * rewrites it to the sender's id.
437
+ */
438
+ export declare function packEnvelope(peerId: number, sealed: Uint8Array): Uint8Array<ArrayBuffer>;
439
+ /** Split an envelope into its peerId and sealed payload; `null` when shorter than the header. */
440
+ export declare function unpackEnvelope(data: Uint8Array): {
441
+ peerId: number;
442
+ payload: Uint8Array;
443
+ } | null;
444
+ /** Rewrite the peerId in place without copying the payload. */
445
+ export declare function rewriteEnvelopePeer(data: Uint8Array, peerId: number): void;
433
446
  export declare const ROOM_ID_BYTES = 16;
434
447
  /** AES-256-GCM room key; the seal key for every collab frame. */
435
448
  export declare const ROOM_KEY_BYTES = 32;
@@ -441,8 +454,6 @@ export declare const ROOM_KEY_BYTES = 32;
441
454
  export declare const WRITE_TOKEN_BYTES = 16;
442
455
  /** Default public relay; bare `<roomId>.<key>` links resolve against it. */
443
456
  export declare const DEFAULT_RELAY_URL = "wss://my.omp.sh";
444
- /** Default share viewer/upload base; `/share` links resolve against `<base>/<id>#<key>`. */
445
- export declare const DEFAULT_SHARE_URL = "https://my.omp.sh/s";
446
457
  export interface ParsedCollabLink {
447
458
  /** wss://host[:port]/r/<roomId> — no query, no fragment. */
448
459
  wsUrl: string;
@@ -11,11 +11,9 @@
11
11
  * `q` query, `o` open, `f` frame, `b` blob, `t` palette, `x` close. Terminal →
12
12
  * program: `r` reply, `e` event (on the pty's input side).
13
13
  *
14
- * The normative spec is the Tern SDK's Surface Protocol and Elements reference
15
- * (`docs/sdk/src/protocol` and `docs/sdk/src/elements` in the Stencil
16
- * repository, https://docs.stencil.so/tern/protocol/); these types mirror it.
17
- * Unknown fields and verbs are ignored in both directions, so every addition
18
- * here is optional.
14
+ * The normative spec is the Tern Surface Protocol; this file mirrors its
15
+ * vocabulary. Unknown fields and verbs are ignored in both directions, so
16
+ * every addition here is optional.
19
17
  */
20
18
  /** Protocol version this build speaks. */
21
19
  export declare const TSP_VERSION = 1;
@@ -26,9 +24,9 @@ export declare const TSP_DEFAULT_APC_LIMIT = 65536;
26
24
  /** Unacknowledged frames a sender may have in flight unless the hello reply says otherwise. */
27
25
  export declare const TSP_DEFAULT_CREDITS = 2;
28
26
  /** One-letter message verb. */
29
- export type TspVerb = "q" | "o" | "f" | "b" | "t" | "x" | "r" | "e";
27
+ export type TspVerb = "q" | "o" | "f" | "b" | "x" | "r" | "e";
30
28
  /** Every component kind in the v1 vocabulary. */
31
- export declare const TSP_KINDS: readonly ["col", "row", "card", "section", "rule", "spacer", "text", "md", "code", "diff", "ansi", "math", "image", "media", "kv", "table", "tree", "badge", "kbd", "icon", "spinner", "shimmer", "elapsed", "progress", "rate", "list", "item", "tabs", "editor", "input", "status", "seg", "overlay", "toast", "rows", "picker", "prefs", "tool", "checklist", "agent", "chart", "meter", "effort"];
29
+ export declare const TSP_KINDS: readonly ["col", "row", "card", "section", "rule", "spacer", "text", "md", "code", "diff", "ansi", "math", "image", "media", "kv", "table", "tree", "json", "badge", "kbd", "icon", "spinner", "shimmer", "elapsed", "progress", "rate", "list", "item", "tabs", "editor", "input", "button", "status", "seg", "overlay", "toast", "rows", "picker", "prefs", "tool", "checklist", "agent", "chart", "meter", "effort"];
32
30
  export type TspKind = (typeof TSP_KINDS)[number];
33
31
  /** Semantic colour of a node's chrome. */
34
32
  export type TspTone = "neutral" | "accent" | "info" | "success" | "warning" | "error" | "pending" | "muted" | "user";
@@ -104,8 +102,10 @@ export interface TspCommonProps {
104
102
  * right after another tooltip or card), anchored below it (above without
105
103
  * room) and clamped to the window. It stays open while the pointer is over
106
104
  * the node or the card, closes on leave (short grace), press, key or scroll,
107
- * and replaces the node's `title` tooltip while open. Terminals that don't
108
- * know it ignore it and keep showing `title`.
105
+ * and replaces the node's `title` tooltip while open. A lone `md` card is a
106
+ * wide read-only preview the pointer passes through (open only over the
107
+ * node). On an `agent` it opens over the row, not the children. Terminals
108
+ * that don't know it ignore it and keep showing `title`.
109
109
  */
110
110
  hovercard?: TspPropNode;
111
111
  }
@@ -174,7 +174,15 @@ export interface TspCodeProps {
174
174
  lang?: string;
175
175
  /** The file the text comes from: the terminal picks the grammar from it (and heads a block outside a tool card with it). */
176
176
  path?: string;
177
+ /** The first line's number; later lines count up from it. */
177
178
  start?: number;
179
+ /**
180
+ * Each line's number (one per line of `text`, strictly ascending), for non-contiguous lines: replaces counting from
181
+ * `start`, and a `…` gap row is drawn before every line whose number is not the previous one's + 1. Marks' `line` and
182
+ * folds' `from`/`to` are in this numbering. Ignored (numbers count from `start`) when its length differs from the
183
+ * text's line count or it is not strictly ascending.
184
+ */
185
+ nums?: readonly number[];
178
186
  numbers?: boolean;
179
187
  marks?: readonly {
180
188
  line: number;
@@ -277,6 +285,20 @@ export interface TspTreeNode {
277
285
  export interface TspTreeProps {
278
286
  nodes: readonly TspTreeNode[];
279
287
  }
288
+ /**
289
+ * A raw JSON value the terminal draws as an interactive tree: small containers
290
+ * whole on one row, larger ones folded to a preview that expands on click.
291
+ * Folding is local to the terminal and sends no events.
292
+ */
293
+ export interface TspJsonProps {
294
+ /** Any JSON value; absent reads as null. */
295
+ value: unknown;
296
+ /**
297
+ * Levels of containers expanded below the top-level entries (default 0:
298
+ * the root's entries listed, every container among them folded).
299
+ */
300
+ open?: number;
301
+ }
280
302
  export interface TspBadgeProps {
281
303
  text: string;
282
304
  }
@@ -339,6 +361,29 @@ export interface TspTabsProps {
339
361
  label: TspText;
340
362
  }[];
341
363
  active?: string;
364
+ /** `underline` (default): an accent underline under the active tab; `segmented`: a well with a raised thumb. */
365
+ variant?: "underline" | "segmented";
366
+ }
367
+ /**
368
+ * A push button. A click sends an `action` event with `actions.click` (else
369
+ * `click`); a disabled or busy button sends nothing. It never takes focus.
370
+ */
371
+ export interface TspButtonProps {
372
+ /** Label; empty with an `icon` draws an icon-only button (give it a `title` or `aria`). */
373
+ text?: string;
374
+ /** Leading icon name. */
375
+ icon?: string;
376
+ /** Keycaps drawn after the label (the key names of `kbd`); display only. */
377
+ keys?: readonly string[];
378
+ variant?: "default" | "primary" | "quiet" | "danger";
379
+ /** `md` 28px (bars, heads, forms), `sm` 22px (inline, rows). */
380
+ size?: "sm" | "md";
381
+ /** A pressed toggle. */
382
+ on?: boolean;
383
+ /** Dimmed and inert; a string is the reason, shown as the tooltip. */
384
+ disabled?: boolean | string;
385
+ /** A spinner in the icon's place; inert. */
386
+ busy?: boolean;
342
387
  }
343
388
  export interface TspEditorDecoration {
344
389
  from: number;
@@ -367,6 +412,9 @@ export interface TspEditorProps {
367
412
  * Independent of text editability or keyboard focus; absent or false is not ready. */
368
413
  sendable?: boolean;
369
414
  maxLines?: number;
415
+ /** The program cannot read input yet: while the field has the focus, the terminal keeps
416
+ * what is typed into it, draws it at the caret, and sends it once this clears. */
417
+ typeahead?: boolean;
370
418
  }
371
419
  export type TspInputProps = Omit<TspEditorProps, "maxLines">;
372
420
  export interface TspStatusProps {
@@ -899,6 +947,7 @@ export interface TspPropsByKind {
899
947
  kv: TspKvProps;
900
948
  table: TspTableProps;
901
949
  tree: TspTreeProps;
950
+ json: TspJsonProps;
902
951
  badge: TspBadgeProps;
903
952
  kbd: TspKbdProps;
904
953
  icon: TspIconProps;
@@ -912,6 +961,7 @@ export interface TspPropsByKind {
912
961
  tabs: TspTabsProps;
913
962
  editor: TspEditorProps;
914
963
  input: TspInputProps;
964
+ button: TspButtonProps;
915
965
  status: TspStatusProps;
916
966
  seg: TspSegProps;
917
967
  overlay: TspOverlayProps;
@@ -990,23 +1040,6 @@ export interface TspClose {
990
1040
  /** Keep `main` in scrollback (true) or remove the surface (false). */
991
1041
  keep: boolean;
992
1042
  }
993
- /**
994
- * Verb `t`: the program's resolved theme for a surface, sent after `o` and
995
- * before its first `f`, and again whenever the theme or variant changes.
996
- * Each variant maps token names to `#rrggbb`; tokens left at the terminal
997
- * default are omitted. A program with one variant sends only that one.
998
- */
999
- export interface TspPalette {
1000
- /** Surface id. */
1001
- sf: string;
1002
- dark?: Readonly<Record<string, string>>;
1003
- light?: Readonly<Record<string, string>>;
1004
- /** Theme names behind each variant. */
1005
- name?: {
1006
- dark?: string;
1007
- light?: string;
1008
- };
1009
- }
1010
1043
  /** Verb `q`. */
1011
1044
  export type TspQuery = {
1012
1045
  q: "hello";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@linxiraos/pi-wire",
4
- "version": "1.4.6",
4
+ "version": "1.4.9",
5
5
  "description": "Shared wire protocol types for omp packages",
6
6
  "homepage": "https://linxira-os.github.io/zeta/",
7
7
  "author": "Can Boluk",
@@ -30,10 +30,10 @@
30
30
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/bun": "1.4.3"
33
+ "@types/bun": "1.4.4"
34
34
  },
35
35
  "engines": {
36
- "bun": ">=1.3.14"
36
+ "bun": ">=1.4.4"
37
37
  },
38
38
  "files": [
39
39
  "src",
package/src/index.ts CHANGED
@@ -410,6 +410,30 @@ export const INTENT_FIELD = "i";
410
410
  /** Plaintext envelope prefix: `[4B uint32 BE peerId][sealed payload]`. */
411
411
  export const ENVELOPE_HEADER_LENGTH = 4;
412
412
 
413
+ /**
414
+ * Prefix `sealed` with its envelope header. Host→relay: peerId 0 broadcasts to
415
+ * all guests, peerId N targets guest N. Guest→relay: always 0; the relay
416
+ * rewrites it to the sender's id.
417
+ */
418
+ export function packEnvelope(peerId: number, sealed: Uint8Array): Uint8Array<ArrayBuffer> {
419
+ const out = new Uint8Array(ENVELOPE_HEADER_LENGTH + sealed.byteLength);
420
+ new DataView(out.buffer).setUint32(0, peerId, false);
421
+ out.set(sealed, ENVELOPE_HEADER_LENGTH);
422
+ return out;
423
+ }
424
+
425
+ /** Split an envelope into its peerId and sealed payload; `null` when shorter than the header. */
426
+ export function unpackEnvelope(data: Uint8Array): { peerId: number; payload: Uint8Array } | null {
427
+ if (data.byteLength < ENVELOPE_HEADER_LENGTH) return null;
428
+ const peerId = new DataView(data.buffer, data.byteOffset, ENVELOPE_HEADER_LENGTH).getUint32(0, false);
429
+ return { peerId, payload: data.subarray(ENVELOPE_HEADER_LENGTH) };
430
+ }
431
+
432
+ /** Rewrite the peerId in place without copying the payload. */
433
+ export function rewriteEnvelopePeer(data: Uint8Array, peerId: number): void {
434
+ new DataView(data.buffer, data.byteOffset, ENVELOPE_HEADER_LENGTH).setUint32(0, peerId, false);
435
+ }
436
+
413
437
  export const ROOM_ID_BYTES = 16;
414
438
 
415
439
  /** AES-256-GCM room key; the seal key for every collab frame. */
@@ -425,9 +449,6 @@ export const WRITE_TOKEN_BYTES = 16;
425
449
  /** Default public relay; bare `<roomId>.<key>` links resolve against it. */
426
450
  export const DEFAULT_RELAY_URL = "wss://my.omp.sh";
427
451
 
428
- /** Default share viewer/upload base; `/share` links resolve against `<base>/<id>#<key>`. */
429
- export const DEFAULT_SHARE_URL = "https://my.omp.sh/s";
430
-
431
452
  export interface ParsedCollabLink {
432
453
  /** wss://host[:port]/r/<roomId> — no query, no fragment. */
433
454
  wsUrl: string;
package/src/tsp.ts CHANGED
@@ -11,11 +11,9 @@
11
11
  * `q` query, `o` open, `f` frame, `b` blob, `t` palette, `x` close. Terminal →
12
12
  * program: `r` reply, `e` event (on the pty's input side).
13
13
  *
14
- * The normative spec is the Tern SDK's Surface Protocol and Elements reference
15
- * (`docs/sdk/src/protocol` and `docs/sdk/src/elements` in the Stencil
16
- * repository, https://docs.stencil.so/tern/protocol/); these types mirror it.
17
- * Unknown fields and verbs are ignored in both directions, so every addition
18
- * here is optional.
14
+ * The normative spec is the Tern Surface Protocol; this file mirrors its
15
+ * vocabulary. Unknown fields and verbs are ignored in both directions, so
16
+ * every addition here is optional.
19
17
  */
20
18
 
21
19
  /** Protocol version this build speaks. */
@@ -28,7 +26,7 @@ export const TSP_DEFAULT_APC_LIMIT = 65_536;
28
26
  export const TSP_DEFAULT_CREDITS = 2;
29
27
 
30
28
  /** One-letter message verb. */
31
- export type TspVerb = "q" | "o" | "f" | "b" | "t" | "x" | "r" | "e";
29
+ export type TspVerb = "q" | "o" | "f" | "b" | "x" | "r" | "e";
32
30
 
33
31
  // ═══════════════════════════════════════════════════════════════════════════
34
32
  // Vocabulary
@@ -53,6 +51,7 @@ export const TSP_KINDS = [
53
51
  "kv",
54
52
  "table",
55
53
  "tree",
54
+ "json",
56
55
  "badge",
57
56
  "kbd",
58
57
  "icon",
@@ -66,6 +65,7 @@ export const TSP_KINDS = [
66
65
  "tabs",
67
66
  "editor",
68
67
  "input",
68
+ "button",
69
69
  "status",
70
70
  "seg",
71
71
  "overlay",
@@ -154,8 +154,10 @@ export interface TspCommonProps {
154
154
  * right after another tooltip or card), anchored below it (above without
155
155
  * room) and clamped to the window. It stays open while the pointer is over
156
156
  * the node or the card, closes on leave (short grace), press, key or scroll,
157
- * and replaces the node's `title` tooltip while open. Terminals that don't
158
- * know it ignore it and keep showing `title`.
157
+ * and replaces the node's `title` tooltip while open. A lone `md` card is a
158
+ * wide read-only preview the pointer passes through (open only over the
159
+ * node). On an `agent` it opens over the row, not the children. Terminals
160
+ * that don't know it ignore it and keep showing `title`.
159
161
  */
160
162
  hovercard?: TspPropNode;
161
163
  }
@@ -225,7 +227,15 @@ export interface TspCodeProps {
225
227
  lang?: string;
226
228
  /** The file the text comes from: the terminal picks the grammar from it (and heads a block outside a tool card with it). */
227
229
  path?: string;
230
+ /** The first line's number; later lines count up from it. */
228
231
  start?: number;
232
+ /**
233
+ * Each line's number (one per line of `text`, strictly ascending), for non-contiguous lines: replaces counting from
234
+ * `start`, and a `…` gap row is drawn before every line whose number is not the previous one's + 1. Marks' `line` and
235
+ * folds' `from`/`to` are in this numbering. Ignored (numbers count from `start`) when its length differs from the
236
+ * text's line count or it is not strictly ascending.
237
+ */
238
+ nums?: readonly number[];
229
239
  numbers?: boolean;
230
240
  marks?: readonly { line: number; tone: TspTone }[];
231
241
  wrap?: boolean;
@@ -313,6 +323,20 @@ export interface TspTreeNode {
313
323
  export interface TspTreeProps {
314
324
  nodes: readonly TspTreeNode[];
315
325
  }
326
+ /**
327
+ * A raw JSON value the terminal draws as an interactive tree: small containers
328
+ * whole on one row, larger ones folded to a preview that expands on click.
329
+ * Folding is local to the terminal and sends no events.
330
+ */
331
+ export interface TspJsonProps {
332
+ /** Any JSON value; absent reads as null. */
333
+ value: unknown;
334
+ /**
335
+ * Levels of containers expanded below the top-level entries (default 0:
336
+ * the root's entries listed, every container among them folded).
337
+ */
338
+ open?: number;
339
+ }
316
340
  export interface TspBadgeProps {
317
341
  text: string;
318
342
  }
@@ -366,6 +390,29 @@ export interface TspItemProps {
366
390
  export interface TspTabsProps {
367
391
  items: readonly { id: string; label: TspText }[];
368
392
  active?: string;
393
+ /** `underline` (default): an accent underline under the active tab; `segmented`: a well with a raised thumb. */
394
+ variant?: "underline" | "segmented";
395
+ }
396
+ /**
397
+ * A push button. A click sends an `action` event with `actions.click` (else
398
+ * `click`); a disabled or busy button sends nothing. It never takes focus.
399
+ */
400
+ export interface TspButtonProps {
401
+ /** Label; empty with an `icon` draws an icon-only button (give it a `title` or `aria`). */
402
+ text?: string;
403
+ /** Leading icon name. */
404
+ icon?: string;
405
+ /** Keycaps drawn after the label (the key names of `kbd`); display only. */
406
+ keys?: readonly string[];
407
+ variant?: "default" | "primary" | "quiet" | "danger";
408
+ /** `md` 28px (bars, heads, forms), `sm` 22px (inline, rows). */
409
+ size?: "sm" | "md";
410
+ /** A pressed toggle. */
411
+ on?: boolean;
412
+ /** Dimmed and inert; a string is the reason, shown as the tooltip. */
413
+ disabled?: boolean | string;
414
+ /** A spinner in the icon's place; inert. */
415
+ busy?: boolean;
369
416
  }
370
417
  export interface TspEditorDecoration {
371
418
  from: number;
@@ -394,6 +441,9 @@ export interface TspEditorProps {
394
441
  * Independent of text editability or keyboard focus; absent or false is not ready. */
395
442
  sendable?: boolean;
396
443
  maxLines?: number;
444
+ /** The program cannot read input yet: while the field has the focus, the terminal keeps
445
+ * what is typed into it, draws it at the caret, and sends it once this clears. */
446
+ typeahead?: boolean;
397
447
  }
398
448
  export type TspInputProps = Omit<TspEditorProps, "maxLines">;
399
449
  export interface TspStatusProps {
@@ -863,6 +913,7 @@ export interface TspPropsByKind {
863
913
  kv: TspKvProps;
864
914
  table: TspTableProps;
865
915
  tree: TspTreeProps;
916
+ json: TspJsonProps;
866
917
  badge: TspBadgeProps;
867
918
  kbd: TspKbdProps;
868
919
  icon: TspIconProps;
@@ -876,6 +927,7 @@ export interface TspPropsByKind {
876
927
  tabs: TspTabsProps;
877
928
  editor: TspEditorProps;
878
929
  input: TspInputProps;
930
+ button: TspButtonProps;
879
931
  status: TspStatusProps;
880
932
  seg: TspSegProps;
881
933
  overlay: TspOverlayProps;
@@ -969,21 +1021,6 @@ export interface TspClose {
969
1021
  keep: boolean;
970
1022
  }
971
1023
 
972
- /**
973
- * Verb `t`: the program's resolved theme for a surface, sent after `o` and
974
- * before its first `f`, and again whenever the theme or variant changes.
975
- * Each variant maps token names to `#rrggbb`; tokens left at the terminal
976
- * default are omitted. A program with one variant sends only that one.
977
- */
978
- export interface TspPalette {
979
- /** Surface id. */
980
- sf: string;
981
- dark?: Readonly<Record<string, string>>;
982
- light?: Readonly<Record<string, string>>;
983
- /** Theme names behind each variant. */
984
- name?: { dark?: string; light?: string };
985
- }
986
-
987
1024
  /** Verb `q`. */
988
1025
  export type TspQuery =
989
1026
  | { q: "hello"; v: readonly number[]; app: string; ver?: string; features?: readonly string[] }