@peer2peer/cli 0.0.0-stage → 0.1.1
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/LICENSE +201 -0
- package/README.md +370 -2
- package/dist/ancestry.d.ts +13 -0
- package/dist/ancestry.js +71 -0
- package/dist/app.d.ts +368 -0
- package/dist/app.js +1181 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +56 -0
- package/dist/circle-ops.d.ts +402 -0
- package/dist/circle-ops.js +1725 -0
- package/dist/cli.d.ts +660 -0
- package/dist/cli.js +1787 -0
- package/dist/codes.d.ts +231 -0
- package/dist/codes.js +998 -0
- package/dist/config.d.ts +159 -0
- package/dist/config.js +294 -0
- package/dist/doctor.d.ts +113 -0
- package/dist/doctor.js +930 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +29 -0
- package/dist/ext-host.d.ts +38 -0
- package/dist/ext-host.js +293 -0
- package/dist/extensions.d.ts +487 -0
- package/dist/extensions.js +406 -0
- package/dist/features.d.ts +91 -0
- package/dist/features.js +164 -0
- package/dist/format.d.ts +57 -0
- package/dist/format.js +248 -0
- package/dist/graph-memory.d.ts +107 -0
- package/dist/graph-memory.js +393 -0
- package/dist/history.d.ts +155 -0
- package/dist/history.js +697 -0
- package/dist/identity.d.ts +239 -0
- package/dist/identity.js +759 -0
- package/dist/inbound.d.ts +32 -0
- package/dist/inbound.js +261 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -0
- package/dist/ix-local.d.ts +76 -0
- package/dist/ix-local.js +203 -0
- package/dist/join-answers.d.ts +49 -0
- package/dist/join-answers.js +149 -0
- package/dist/outbox.d.ts +109 -0
- package/dist/outbox.js +337 -0
- package/dist/pretty.d.ts +100 -0
- package/dist/pretty.js +256 -0
- package/dist/procstart.d.ts +1 -0
- package/dist/procstart.js +66 -0
- package/dist/progress.d.ts +30 -0
- package/dist/progress.js +78 -0
- package/dist/projects.d.ts +491 -0
- package/dist/projects.js +1383 -0
- package/dist/prompt/picker.d.ts +64 -0
- package/dist/prompt/picker.js +152 -0
- package/dist/prompt/tty.d.ts +29 -0
- package/dist/prompt/tty.js +122 -0
- package/dist/readonly.d.ts +20 -0
- package/dist/readonly.js +50 -0
- package/dist/receipts.d.ts +99 -0
- package/dist/receipts.js +182 -0
- package/dist/relay-client.d.ts +277 -0
- package/dist/relay-client.js +873 -0
- package/dist/relay-info.d.ts +24 -0
- package/dist/relay-info.js +53 -0
- package/dist/rotation.d.ts +402 -0
- package/dist/rotation.js +2054 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.js +74 -0
- package/dist/sessions.d.ts +355 -0
- package/dist/sessions.js +1247 -0
- package/dist/shortcode.d.ts +149 -0
- package/dist/shortcode.js +465 -0
- package/dist/social.d.ts +139 -0
- package/dist/social.js +485 -0
- package/dist/state.d.ts +509 -0
- package/dist/state.js +220 -0
- package/dist/stdin.d.ts +17 -0
- package/dist/stdin.js +46 -0
- package/dist/sync.d.ts +77 -0
- package/dist/sync.js +375 -0
- package/dist/transient.d.ts +1 -0
- package/dist/transient.js +28 -0
- package/dist/trust.d.ts +37 -0
- package/dist/trust.js +134 -0
- package/dist/tty-confirm.d.ts +2 -0
- package/dist/tty-confirm.js +53 -0
- package/dist/tui/command.d.ts +20 -0
- package/dist/tui/command.js +70 -0
- package/dist/tui/frame.d.ts +43 -0
- package/dist/tui/frame.js +111 -0
- package/dist/tui/model.d.ts +221 -0
- package/dist/tui/model.js +259 -0
- package/dist/tui/sanitize.d.ts +13 -0
- package/dist/tui/sanitize.js +151 -0
- package/dist/tui/terminal.d.ts +88 -0
- package/dist/tui/terminal.js +354 -0
- package/dist/tui/tui.d.ts +78 -0
- package/dist/tui/tui.js +612 -0
- package/dist/tui/view.d.ts +4 -0
- package/dist/tui/view.js +358 -0
- package/dist/unknown-kinds.d.ts +12 -0
- package/dist/unknown-kinds.js +66 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/want-pow.d.ts +12 -0
- package/dist/want-pow.js +46 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +331 -0
- package/dist/xstate.d.ts +125 -0
- package/dist/xstate.js +422 -0
- package/package.json +60 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// `p2p tui`: interactive only. It refuses to start unless stdin and stdout
|
|
4
|
+
// are both a terminal, and refuses inside an agent's tool call (Codex and
|
|
5
|
+
// Claude Code set CODEX_THREAD_ID / CLAUDECODE there); the Claude mod's
|
|
6
|
+
// command guard refuses it too. Diagnostics the app would print while the
|
|
7
|
+
// TUI owns the screen are kept and printed once the terminal is restored.
|
|
8
|
+
import { CliError, toErrorJson } from "../errors.js";
|
|
9
|
+
import { checkSid } from "../sessions.js";
|
|
10
|
+
import { personHere } from "../projects.js";
|
|
11
|
+
import { TtyTerminal } from "./terminal.js";
|
|
12
|
+
import { Tui, TUI_SESSION } from "./tui.js";
|
|
13
|
+
/** Why `p2p tui` won't start here, or undefined. */
|
|
14
|
+
export function tuiRefusal(env, isTTY, front = false) {
|
|
15
|
+
// An agent's session: its environment, or (scrubbed) a Claude Code or Codex ancestor (projects.ts).
|
|
16
|
+
if (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CLAUDECODE || !personHere({ env, front })) {
|
|
17
|
+
return "p2p tui is for you to run in your own terminal, not from an agent's tool call";
|
|
18
|
+
}
|
|
19
|
+
if (!isTTY)
|
|
20
|
+
return "p2p tui needs an interactive terminal (stdin and stdout); in scripts use `p2p ls`, `p2p held`, `p2p watch`";
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
export async function tuiCommand(d, o) {
|
|
24
|
+
const isTTY = d.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
25
|
+
const refusal = tuiRefusal(d.env, d.terminal ? true : isTTY, d.front === true);
|
|
26
|
+
if (refusal) {
|
|
27
|
+
d.io.err(`p2p tui: ${refusal}`);
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
let session;
|
|
31
|
+
try {
|
|
32
|
+
session = checkSid(o.session ?? TUI_SESSION);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
d.io.err(`p2p tui: ${String(toErrorJson(e).reason)}`);
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
const kept = [];
|
|
39
|
+
const keep = (m) => {
|
|
40
|
+
kept.push(m);
|
|
41
|
+
if (kept.length > 200)
|
|
42
|
+
kept.shift();
|
|
43
|
+
};
|
|
44
|
+
const app = d.makeApp(d.env, { out: () => { }, err: keep });
|
|
45
|
+
try {
|
|
46
|
+
if (!(await app.load(false)))
|
|
47
|
+
throw new CliError("no_identity", "no identity here yet: run `p2p setup` first");
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
const j = toErrorJson(e);
|
|
51
|
+
d.io.err(`p2p tui: ${String(j.error)}: ${String(j.reason)}`);
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
const term = d.terminal ?? new TtyTerminal(process.stdin, process.stdout, d.env);
|
|
55
|
+
const tui = new Tui(app, { term, session, version: d.version, ...(d.signal ? { signal: d.signal } : {}), log: keep });
|
|
56
|
+
try {
|
|
57
|
+
await tui.run();
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
const j = toErrorJson(e);
|
|
61
|
+
d.io.err(`p2p tui: ${String(j.error)}: ${String(j.reason)}`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
// What the app said while the screen was ours, now that it is the terminal's again (last few).
|
|
66
|
+
for (const m of kept.slice(-5))
|
|
67
|
+
d.io.err(m);
|
|
68
|
+
}
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type Color = "green" | "red" | "yellow" | "cyan" | "magenta" | "gray";
|
|
2
|
+
export interface Style {
|
|
3
|
+
fg?: Color;
|
|
4
|
+
bold?: boolean;
|
|
5
|
+
dim?: boolean;
|
|
6
|
+
inverse?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Span {
|
|
9
|
+
text: string;
|
|
10
|
+
style?: Style;
|
|
11
|
+
}
|
|
12
|
+
export declare class Line {
|
|
13
|
+
readonly width: number;
|
|
14
|
+
readonly spans: Span[];
|
|
15
|
+
private used;
|
|
16
|
+
constructor(width: number);
|
|
17
|
+
get remaining(): number;
|
|
18
|
+
/** Appends sanitized text, cut to `max` columns (and to what's left of the line). */
|
|
19
|
+
add(text: unknown, style?: Style, max?: number): this;
|
|
20
|
+
/** Spaces: a fixed gap (raw spaces, not peer text). */
|
|
21
|
+
gap(n?: number): this;
|
|
22
|
+
/** `text` padded (or cut) to exactly `w` columns. */
|
|
23
|
+
col(text: unknown, w: number, style?: Style): this;
|
|
24
|
+
/** Pads the line to its width (with `style`, e.g. inverse for a selected row). */
|
|
25
|
+
fill(style?: Style): this;
|
|
26
|
+
/** The same line with every span shown selected (inverse). */
|
|
27
|
+
selected(): this;
|
|
28
|
+
text(): string;
|
|
29
|
+
}
|
|
30
|
+
export interface Frame {
|
|
31
|
+
cols: number;
|
|
32
|
+
rows: number;
|
|
33
|
+
lines: Line[];
|
|
34
|
+
}
|
|
35
|
+
export declare function makeFrame(cols: number, rows: number): Frame;
|
|
36
|
+
/** Plain text, one line per row, padded: for snapshot tests and NO_COLOR. */
|
|
37
|
+
export declare function frameText(f: Frame): string;
|
|
38
|
+
/**
|
|
39
|
+
* The whole frame as terminal output: cursor home, each row then erase-to-end,
|
|
40
|
+
* styles reset after every styled span. Without colour, only bold and inverse
|
|
41
|
+
* (selection must stay visible) are used.
|
|
42
|
+
*/
|
|
43
|
+
export declare function toAnsi(f: Frame, color: boolean): string;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// A frame: rows of styled spans, exactly `cols` wide. Spans are built only by
|
|
4
|
+
// Line.add, which runs every piece of text through cell() (sanitize.ts), so
|
|
5
|
+
// nothing reaches the terminal unsanitized. toAnsi() adds the only escape
|
|
6
|
+
// sequences the TUI ever writes (SGR colours, erase-line, cursor home); they
|
|
7
|
+
// come from this file, never from data.
|
|
8
|
+
import { cell, displayWidth } from "./sanitize.js";
|
|
9
|
+
export class Line {
|
|
10
|
+
width;
|
|
11
|
+
spans = [];
|
|
12
|
+
used = 0;
|
|
13
|
+
constructor(width) {
|
|
14
|
+
this.width = width;
|
|
15
|
+
}
|
|
16
|
+
get remaining() {
|
|
17
|
+
return Math.max(0, this.width - this.used);
|
|
18
|
+
}
|
|
19
|
+
/** Appends sanitized text, cut to `max` columns (and to what's left of the line). */
|
|
20
|
+
add(text, style, max = Infinity) {
|
|
21
|
+
const room = Math.min(this.remaining, max);
|
|
22
|
+
const t = cell(text, room);
|
|
23
|
+
if (t !== "") {
|
|
24
|
+
this.spans.push(style ? { text: t, style } : { text: t });
|
|
25
|
+
this.used += displayWidth(t);
|
|
26
|
+
}
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/** Spaces: a fixed gap (raw spaces, not peer text). */
|
|
30
|
+
gap(n = 1) {
|
|
31
|
+
const k = Math.min(n, this.remaining);
|
|
32
|
+
if (k > 0) {
|
|
33
|
+
this.spans.push({ text: " ".repeat(k) });
|
|
34
|
+
this.used += k;
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** `text` padded (or cut) to exactly `w` columns. */
|
|
39
|
+
col(text, w, style) {
|
|
40
|
+
const before = this.used;
|
|
41
|
+
this.add(text, style, w);
|
|
42
|
+
return this.gap(w - (this.used - before));
|
|
43
|
+
}
|
|
44
|
+
/** Pads the line to its width (with `style`, e.g. inverse for a selected row). */
|
|
45
|
+
fill(style) {
|
|
46
|
+
const k = this.remaining;
|
|
47
|
+
if (k > 0) {
|
|
48
|
+
this.spans.push(style ? { text: " ".repeat(k), style } : { text: " ".repeat(k) });
|
|
49
|
+
this.used += k;
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/** The same line with every span shown selected (inverse). */
|
|
54
|
+
selected() {
|
|
55
|
+
for (const s of this.spans)
|
|
56
|
+
s.style = { ...s.style, inverse: true };
|
|
57
|
+
return this.fill({ inverse: true });
|
|
58
|
+
}
|
|
59
|
+
text() {
|
|
60
|
+
return this.spans.map((s) => s.text).join("");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function makeFrame(cols, rows) {
|
|
64
|
+
return { cols, rows, lines: [] };
|
|
65
|
+
}
|
|
66
|
+
/** Plain text, one line per row, padded: for snapshot tests and NO_COLOR. */
|
|
67
|
+
export function frameText(f) {
|
|
68
|
+
const out = [];
|
|
69
|
+
for (let i = 0; i < f.rows; i++) {
|
|
70
|
+
const l = f.lines[i];
|
|
71
|
+
const t = l ? l.text() : "";
|
|
72
|
+
out.push(t + " ".repeat(Math.max(0, f.cols - displayWidth(t))));
|
|
73
|
+
}
|
|
74
|
+
return out.join("\n");
|
|
75
|
+
}
|
|
76
|
+
const FG = { red: 31, green: 32, yellow: 33, magenta: 35, cyan: 36, gray: 90 };
|
|
77
|
+
function sgr(s, color) {
|
|
78
|
+
if (!s)
|
|
79
|
+
return "";
|
|
80
|
+
const codes = [];
|
|
81
|
+
if (s.bold)
|
|
82
|
+
codes.push(1);
|
|
83
|
+
if (s.dim && color)
|
|
84
|
+
codes.push(2);
|
|
85
|
+
if (s.inverse)
|
|
86
|
+
codes.push(7);
|
|
87
|
+
if (s.fg && color)
|
|
88
|
+
codes.push(FG[s.fg]);
|
|
89
|
+
return codes.length ? `\u001b[${codes.join(";")}m` : "";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The whole frame as terminal output: cursor home, each row then erase-to-end,
|
|
93
|
+
* styles reset after every styled span. Without colour, only bold and inverse
|
|
94
|
+
* (selection must stay visible) are used.
|
|
95
|
+
*/
|
|
96
|
+
export function toAnsi(f, color) {
|
|
97
|
+
let out = "\u001b[H";
|
|
98
|
+
for (let i = 0; i < f.rows; i++) {
|
|
99
|
+
const l = f.lines[i];
|
|
100
|
+
if (l) {
|
|
101
|
+
for (const s of l.spans) {
|
|
102
|
+
const on = sgr(s.style, color);
|
|
103
|
+
out += on ? `${on}${s.text}\u001b[0m` : s.text;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
out += "\u001b[K";
|
|
107
|
+
if (i < f.rows - 1)
|
|
108
|
+
out += "\r\n";
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
export type Screen = "people" | "held" | "messages" | "send" | "health";
|
|
2
|
+
export declare const SCREENS: readonly Screen[];
|
|
3
|
+
export declare const SCREEN_TITLES: Record<Screen, string>;
|
|
4
|
+
export interface AgentRow {
|
|
5
|
+
id: string;
|
|
6
|
+
parent?: string;
|
|
7
|
+
type: string;
|
|
8
|
+
task: string;
|
|
9
|
+
state: string;
|
|
10
|
+
branch?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionRow {
|
|
13
|
+
own: string;
|
|
14
|
+
sid: string;
|
|
15
|
+
ref: string;
|
|
16
|
+
label: string;
|
|
17
|
+
state: string;
|
|
18
|
+
live: boolean;
|
|
19
|
+
ageSec: number;
|
|
20
|
+
summary?: string;
|
|
21
|
+
repo?: string;
|
|
22
|
+
branch?: string;
|
|
23
|
+
files: string[];
|
|
24
|
+
agents: AgentRow[];
|
|
25
|
+
thisDevice?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PersonRow {
|
|
28
|
+
userId: string;
|
|
29
|
+
address: string;
|
|
30
|
+
/** How they relate: friend, circle-mate (names of shared circles), or you. */
|
|
31
|
+
relation: string;
|
|
32
|
+
self: boolean;
|
|
33
|
+
live: boolean;
|
|
34
|
+
sessions: SessionRow[];
|
|
35
|
+
}
|
|
36
|
+
export interface HeldRow {
|
|
37
|
+
/** "item": a CLI held item (p2p held); "codex": a message a Codex session holds. */
|
|
38
|
+
source: "item" | "codex";
|
|
39
|
+
id: string;
|
|
40
|
+
type: string;
|
|
41
|
+
from: string;
|
|
42
|
+
/** codex: the session that holds it. */
|
|
43
|
+
session?: string;
|
|
44
|
+
summary: string;
|
|
45
|
+
at: number;
|
|
46
|
+
}
|
|
47
|
+
export type Outcome = "shown" | "held" | "declined" | "expired" | "ended";
|
|
48
|
+
export interface MessageRow {
|
|
49
|
+
id: string;
|
|
50
|
+
dir: "in" | "out";
|
|
51
|
+
at: number;
|
|
52
|
+
/** The other side: address, and the session (ref) when known. */
|
|
53
|
+
who: string;
|
|
54
|
+
userId?: string;
|
|
55
|
+
own?: string;
|
|
56
|
+
sid?: string;
|
|
57
|
+
ref?: string;
|
|
58
|
+
text: string;
|
|
59
|
+
/** out: delivery state and receipt outcomes. */
|
|
60
|
+
state?: "sent" | "offline" | "outbox" | "failed" | "expired";
|
|
61
|
+
outcomes?: Outcome[];
|
|
62
|
+
lastSeen?: number;
|
|
63
|
+
receiptId?: string;
|
|
64
|
+
note?: string;
|
|
65
|
+
/** From the message history (history.ts): kept past this run, up to its retention. */
|
|
66
|
+
fromHistory?: true;
|
|
67
|
+
/** The person's own inbox (this TUI's session, or no session) rather than one of their agent sessions'. */
|
|
68
|
+
inbox?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface RelayRow {
|
|
71
|
+
url: string;
|
|
72
|
+
up: boolean;
|
|
73
|
+
reason?: string;
|
|
74
|
+
access?: string;
|
|
75
|
+
attention?: boolean;
|
|
76
|
+
software?: string;
|
|
77
|
+
pow?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface CheckRow {
|
|
80
|
+
status: "ok" | "fail" | "unknown";
|
|
81
|
+
title: string;
|
|
82
|
+
detail: string;
|
|
83
|
+
fix?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface Health {
|
|
86
|
+
relays: RelayRow[];
|
|
87
|
+
doctor?: {
|
|
88
|
+
scope: string;
|
|
89
|
+
who?: string;
|
|
90
|
+
checks: CheckRow[];
|
|
91
|
+
summary: {
|
|
92
|
+
ok: number;
|
|
93
|
+
fail: number;
|
|
94
|
+
unknown: number;
|
|
95
|
+
};
|
|
96
|
+
at: number;
|
|
97
|
+
};
|
|
98
|
+
running?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface Data {
|
|
101
|
+
me?: {
|
|
102
|
+
userId: string;
|
|
103
|
+
address: string;
|
|
104
|
+
};
|
|
105
|
+
session: string;
|
|
106
|
+
people: PersonRow[];
|
|
107
|
+
held: HeldRow[];
|
|
108
|
+
/** Why held messages of the Claude Code mod aren't listed (shown on the Held screen). */
|
|
109
|
+
heldNote: string;
|
|
110
|
+
messages: MessageRow[];
|
|
111
|
+
health: Health;
|
|
112
|
+
loading: boolean;
|
|
113
|
+
}
|
|
114
|
+
export type Modal = {
|
|
115
|
+
kind: "confirm";
|
|
116
|
+
title: string;
|
|
117
|
+
lines: string[];
|
|
118
|
+
effect: Effect;
|
|
119
|
+
} | {
|
|
120
|
+
kind: "prompt";
|
|
121
|
+
title: string;
|
|
122
|
+
lines: string[];
|
|
123
|
+
text: string;
|
|
124
|
+
secret?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** A confirmation that takes a typed word (not y, not a paste): for trust. */
|
|
127
|
+
| {
|
|
128
|
+
kind: "typed";
|
|
129
|
+
title: string;
|
|
130
|
+
lines: string[];
|
|
131
|
+
word: string;
|
|
132
|
+
text: string;
|
|
133
|
+
effect: Effect;
|
|
134
|
+
} | {
|
|
135
|
+
kind: "detail";
|
|
136
|
+
title: string;
|
|
137
|
+
lines: string[];
|
|
138
|
+
} | {
|
|
139
|
+
kind: "help";
|
|
140
|
+
};
|
|
141
|
+
export interface SendTarget {
|
|
142
|
+
label: string;
|
|
143
|
+
/** What sendMessage gets as `to`: a userId, with "[ref]" for one session. */
|
|
144
|
+
to: string;
|
|
145
|
+
}
|
|
146
|
+
export interface Ui {
|
|
147
|
+
screen: Screen;
|
|
148
|
+
sel: Record<Screen, number>;
|
|
149
|
+
modal?: Modal;
|
|
150
|
+
/** Send screen: the chosen target and the text being typed. */
|
|
151
|
+
compose?: {
|
|
152
|
+
target: SendTarget;
|
|
153
|
+
text: string;
|
|
154
|
+
};
|
|
155
|
+
flash?: {
|
|
156
|
+
text: string;
|
|
157
|
+
error?: boolean;
|
|
158
|
+
};
|
|
159
|
+
busy?: string;
|
|
160
|
+
/** Messages screen: only your inbox (this TUI's session, or none), not your agent sessions' too. */
|
|
161
|
+
inboxOnly?: boolean;
|
|
162
|
+
}
|
|
163
|
+
export type Effect = {
|
|
164
|
+
kind: "quit";
|
|
165
|
+
} | {
|
|
166
|
+
kind: "accept-item";
|
|
167
|
+
id: string;
|
|
168
|
+
} | {
|
|
169
|
+
kind: "decline-item";
|
|
170
|
+
id: string;
|
|
171
|
+
} | {
|
|
172
|
+
kind: "codex-release";
|
|
173
|
+
id: string;
|
|
174
|
+
} | {
|
|
175
|
+
kind: "codex-decline";
|
|
176
|
+
id: string;
|
|
177
|
+
} | {
|
|
178
|
+
kind: "trust-and-release";
|
|
179
|
+
id: string;
|
|
180
|
+
from: string;
|
|
181
|
+
} | {
|
|
182
|
+
kind: "send";
|
|
183
|
+
to: string;
|
|
184
|
+
label: string;
|
|
185
|
+
text: string;
|
|
186
|
+
} | {
|
|
187
|
+
kind: "doctor";
|
|
188
|
+
user?: string;
|
|
189
|
+
} | {
|
|
190
|
+
kind: "prompt-answer";
|
|
191
|
+
text: string;
|
|
192
|
+
} | {
|
|
193
|
+
kind: "prompt-cancel";
|
|
194
|
+
};
|
|
195
|
+
export interface Key {
|
|
196
|
+
name: string;
|
|
197
|
+
ch?: string;
|
|
198
|
+
ctrl?: boolean;
|
|
199
|
+
shift?: boolean;
|
|
200
|
+
/** Part of a bracketed paste: typed only into a message or a prompt, never a command key. */
|
|
201
|
+
paste?: boolean;
|
|
202
|
+
}
|
|
203
|
+
export declare function initialUi(): Ui;
|
|
204
|
+
export type PeopleItem = {
|
|
205
|
+
kind: "person";
|
|
206
|
+
person: PersonRow;
|
|
207
|
+
} | {
|
|
208
|
+
kind: "session";
|
|
209
|
+
person: PersonRow;
|
|
210
|
+
session: SessionRow;
|
|
211
|
+
};
|
|
212
|
+
export declare function peopleItems(d: Data): PeopleItem[];
|
|
213
|
+
/** Send targets: live sessions first (not this TUI's own), then each person (their one session, or our session). */
|
|
214
|
+
export declare function sendTargets(d: Data): SendTarget[];
|
|
215
|
+
export declare function messagesSorted(d: Data, ui?: Pick<Ui, "inboxOnly">): MessageRow[];
|
|
216
|
+
export declare function clampSel(ui: Ui, d: Data): Ui;
|
|
217
|
+
/** One key press. Returns the next ui and, at most, one effect. */
|
|
218
|
+
export declare function onKey(ui0: Ui, d: Data, key: Key, page?: number): {
|
|
219
|
+
ui: Ui;
|
|
220
|
+
effect?: Effect;
|
|
221
|
+
};
|