agent-embassy 4.2.0 → 4.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/CHANGELOG.md +19 -0
- package/README.md +28 -17
- package/SECURITY.md +25 -11
- package/dist/src/gateway/broker-control.js +9 -2
- package/dist/src/gateway/broker-control.js.map +1 -1
- package/dist/src/gateway/broker.d.ts +14 -0
- package/dist/src/gateway/broker.js +6 -2
- package/dist/src/gateway/broker.js.map +1 -1
- package/dist/src/gateway/codex-discovery.d.ts +42 -0
- package/dist/src/gateway/codex-discovery.js +604 -0
- package/dist/src/gateway/codex-discovery.js.map +1 -0
- package/dist/src/gateway/codex-stateless-transport.d.ts +1 -1
- package/dist/src/gateway/codex-stateless-transport.js +126 -18
- package/dist/src/gateway/codex-stateless-transport.js.map +1 -1
- package/dist/src/gateway/core-cli.js +10 -6
- package/dist/src/gateway/core-cli.js.map +1 -1
- package/dist/src/gateway/core-version.d.ts +1 -1
- package/dist/src/gateway/core-version.js +1 -1
- package/dist/src/gateway/endpoint-directory.d.ts +12 -0
- package/dist/src/gateway/endpoint-directory.js +94 -4
- package/dist/src/gateway/endpoint-directory.js.map +1 -1
- package/dist/src/gateway/ledger-codec.js +11 -6
- package/dist/src/gateway/ledger-codec.js.map +1 -1
- package/dist/src/gateway/ledger.d.ts +2 -1
- package/dist/src/gateway/ledger.js +5 -2
- package/dist/src/gateway/ledger.js.map +1 -1
- package/dist/src/gateway/local-control.d.ts +1 -1
- package/dist/src/gateway/local-control.js +1 -1
- package/dist/src/gateway/owned-state.d.ts +1 -0
- package/dist/src/gateway/owned-state.js +1 -1
- package/dist/src/gateway/owned-state.js.map +1 -1
- package/dist/src/gateway/runtime.d.ts +4 -2
- package/dist/src/gateway/runtime.js +18 -5
- package/dist/src/gateway/runtime.js.map +1 -1
- package/dist/src/gateway/tui-model.d.ts +67 -0
- package/dist/src/gateway/tui-model.js +136 -0
- package/dist/src/gateway/tui-model.js.map +1 -0
- package/dist/src/gateway/tui-view.d.ts +11 -0
- package/dist/src/gateway/tui-view.js +206 -0
- package/dist/src/gateway/tui-view.js.map +1 -0
- package/dist/src/gateway/tui.d.ts +7 -40
- package/dist/src/gateway/tui.js +43 -231
- package/dist/src/gateway/tui.js.map +1 -1
- package/docs/CONFIGURATION.md +59 -17
- package/docs/DELIVERY.md +18 -6
- package/docs/GATEWAY-ARCHITECTURE.md +43 -21
- package/package.json +8 -3
- package/skills/embassy-peer/SKILL.md +6 -6
|
@@ -7,6 +7,7 @@ import { MessagingBroker } from "./broker.js";
|
|
|
7
7
|
import { ClaudePeerAdapter } from "./claude-peer.js";
|
|
8
8
|
import { attestClaudePeerRuntime } from "./claude-runtime.js";
|
|
9
9
|
import { createStatelessCodexOperationTransport } from "./codex-stateless-transport.js";
|
|
10
|
+
import { createCodexDiscoveryObserver } from "./codex-discovery.js";
|
|
10
11
|
import { loadGatewayConfig, defaultGatewayStateDir } from "./config.js";
|
|
11
12
|
import { Coordinator } from "./coordinator.js";
|
|
12
13
|
import { EndpointDirectory } from "./endpoint-directory.js";
|
|
@@ -20,8 +21,8 @@ import { OwnedStateFile } from "./owned-state.js";
|
|
|
20
21
|
const leaseLost = () => new BridgeError("GATEWAY_INSTANCE_LEASE_LOST", "Embassy lost its host-wide gateway lease and shut down.", true);
|
|
21
22
|
const cancelled = () => new BridgeError("GATEWAY_START_CANCELLED", "Gateway startup was cancelled before it became ready.", true);
|
|
22
23
|
const codexEnvironment = (env) => Object.fromEntries(["HOME", "USER", "LOGNAME"].flatMap((key) => env[key] === undefined ? [] : [[key, env[key]]]));
|
|
23
|
-
/** Assemble the schema-
|
|
24
|
-
*
|
|
24
|
+
/** Assemble the schema-7 broker. The bounded Codex metadata observer starts only
|
|
25
|
+
* after control and state ownership are established; provider writes stay per-operation. */
|
|
25
26
|
export async function runCoreRuntime(options, dependencies = {}) {
|
|
26
27
|
const env = options.env ?? process.env;
|
|
27
28
|
const d = {
|
|
@@ -33,6 +34,7 @@ export async function runCoreRuntime(options, dependencies = {}) {
|
|
|
33
34
|
attestClaudeRuntime: dependencies.attestClaudeRuntime ?? attestClaudePeerRuntime,
|
|
34
35
|
createClaudePeer: dependencies.createClaudePeer ?? ((runtime, config) => new ClaudePeerAdapter({ ...runtime })),
|
|
35
36
|
createCodexOperation: dependencies.createCodexOperation ?? ((source) => createStatelessCodexOperationTransport({ local: { environment: codexEnvironment(source) } })),
|
|
37
|
+
createCodexDiscovery: dependencies.createCodexDiscovery ?? createCodexDiscoveryObserver,
|
|
36
38
|
createFederation: dependencies.createFederation ?? ((host, nodes) => new Federation({ host, nodes })),
|
|
37
39
|
serveControl: dependencies.serveControl ?? serveLocalControl,
|
|
38
40
|
add: dependencies.addSignalListener ?? ((signal, listener) => process.on(signal, listener)),
|
|
@@ -57,6 +59,7 @@ export async function runCoreRuntime(options, dependencies = {}) {
|
|
|
57
59
|
let control, broker;
|
|
58
60
|
let claude, loopback;
|
|
59
61
|
let federation;
|
|
62
|
+
let discovery;
|
|
60
63
|
let primary;
|
|
61
64
|
try {
|
|
62
65
|
if (controller.signal.aborted)
|
|
@@ -117,11 +120,20 @@ export async function runCoreRuntime(options, dependencies = {}) {
|
|
|
117
120
|
const codex = new CodexDestination({ host: config.hostId, operation: d.createCodexOperation(env) });
|
|
118
121
|
loopback = new LoopbackDestination(codex);
|
|
119
122
|
federation = d.createFederation(config.hostId, config.peerNodes);
|
|
120
|
-
const directory = new EndpointDirectory({ host: config.hostId, limits: ledgerLimits, store, claude: peer, remote: federation
|
|
123
|
+
const directory = new EndpointDirectory({ host: config.hostId, limits: ledgerLimits, store, claude: peer, remote: federation,
|
|
124
|
+
automaticCodex: true });
|
|
125
|
+
let codexObservation = { complete: false, truncated: false };
|
|
126
|
+
discovery = d.createCodexDiscovery({ hostId: config.hostId, local: { environment: codexEnvironment(env) },
|
|
127
|
+
maxEndpoints: ledgerLimits.endpoints, onSnapshot: async (snapshot) => {
|
|
128
|
+
assertWrite();
|
|
129
|
+
const result = await directory.reconcileCodex(snapshot.threads, snapshot.removedIds, snapshot.observation.truncated, snapshot.observation.complete);
|
|
130
|
+
codexObservation = { ...snapshot.observation, truncated: snapshot.observation.truncated || result.truncated };
|
|
131
|
+
} });
|
|
121
132
|
const coordinator = new Coordinator({ host: config.hostId, limits: ledgerLimits, store, claude,
|
|
122
133
|
codex: loopback, ssh: federation, resolve: (identity) => directory.exact(identity), assertWritable: assertWrite });
|
|
123
134
|
broker = new MessagingBroker({ host: config.hostId, limits: ledgerLimits, store, directory, coordinator,
|
|
124
|
-
nodes: config.peerNodes, steeringEnabled: config.steeringEnabled, federation
|
|
135
|
+
nodes: config.peerNodes, steeringEnabled: config.steeringEnabled, federation,
|
|
136
|
+
...(discovery ? { codexDiscovery: { refresh: () => discovery.refresh(), observation: () => codexObservation } } : {}) });
|
|
125
137
|
control = await d.serveControl({ stateDir: config.stateDir, socketPath: config.controlSocketPath,
|
|
126
138
|
handle: (input) => {
|
|
127
139
|
if (!ready || controller.signal.aborted)
|
|
@@ -136,6 +148,7 @@ export async function runCoreRuntime(options, dependencies = {}) {
|
|
|
136
148
|
await broker.start();
|
|
137
149
|
assertStarting();
|
|
138
150
|
ready = true;
|
|
151
|
+
discovery?.start();
|
|
139
152
|
const announced = Promise.resolve(options.onReady({ status: "ready", hostId: config.hostId,
|
|
140
153
|
codexMode: "native_messaging" })).then(() => ({ kind: "ready" }), (error) => ({ kind: "error", error }));
|
|
141
154
|
const publication = await Promise.race([announced, stopped.then(() => ({ kind: "stopped" })),
|
|
@@ -156,7 +169,7 @@ export async function runCoreRuntime(options, dependencies = {}) {
|
|
|
156
169
|
d.remove("SIGINT", stop);
|
|
157
170
|
d.remove("SIGTERM", stop);
|
|
158
171
|
const failures = [];
|
|
159
|
-
for (const resource of [control, broker, ...(broker === undefined ? [loopback, claude, federation] : []), store]) {
|
|
172
|
+
for (const resource of [control, discovery, broker, ...(broker === undefined ? [loopback, claude, federation] : []), store]) {
|
|
160
173
|
if (resource !== undefined)
|
|
161
174
|
await resource.close().catch((error) => failures.push(error));
|
|
162
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/gateway/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAkC,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,sCAAsC,EAAyC,MAAM,gCAAgC,CAAC;AAC/H,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAsB,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAA4D,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAA6B,MAAM,uBAAuB,CAAC;AAC5H,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAA6B,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBlD,MAAM,SAAS,GAAG,GAAG,EAAE,C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AAC;IACpD,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,QAAQ,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAC5H,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,sFAAsF;IACtF,gFAAgF;IAChF,mFAAmF;IACnF,kEAAkE;IAClE,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QACrE,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,cAAc,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,EACrG,qEAAqE,CAAC,CAAC;IACzE,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,OAAO,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type Obj = Record<string, unknown>;
|
|
2
|
+
export type Section = "endpoints" | "deliveries" | "retirements" | "result";
|
|
3
|
+
export type Mode = "browse" | "token" | "confirm";
|
|
4
|
+
export type EndpointRow = Readonly<{
|
|
5
|
+
id: string;
|
|
6
|
+
alias: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
host: string;
|
|
9
|
+
local: boolean;
|
|
10
|
+
queueDepth?: number;
|
|
11
|
+
lastOperation?: Obj;
|
|
12
|
+
observedAt?: string;
|
|
13
|
+
safeErrorCode?: string;
|
|
14
|
+
codex?: Obj;
|
|
15
|
+
placeholder?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export type DeliverySummary = Readonly<{
|
|
18
|
+
summary: true;
|
|
19
|
+
rows: readonly Obj[];
|
|
20
|
+
}>;
|
|
21
|
+
export type TuiModel = {
|
|
22
|
+
snapshot?: Obj;
|
|
23
|
+
snapshotAt?: number;
|
|
24
|
+
staleSince?: number;
|
|
25
|
+
error?: string;
|
|
26
|
+
errorDetail?: string;
|
|
27
|
+
action?: string;
|
|
28
|
+
actionRunning?: boolean;
|
|
29
|
+
host?: string;
|
|
30
|
+
restarted?: boolean;
|
|
31
|
+
section: Section;
|
|
32
|
+
previousSection?: Exclude<Section, "result">;
|
|
33
|
+
selected: Record<Exclude<Section, "result">, number> & Partial<Record<"result", number>>;
|
|
34
|
+
selectedEndpoint?: string;
|
|
35
|
+
mode: Mode;
|
|
36
|
+
token: string;
|
|
37
|
+
retiring?: EndpointRow;
|
|
38
|
+
result?: Readonly<{
|
|
39
|
+
label: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}>;
|
|
42
|
+
hosts?: readonly Readonly<{
|
|
43
|
+
host: string;
|
|
44
|
+
state: string;
|
|
45
|
+
selected: boolean;
|
|
46
|
+
}>[];
|
|
47
|
+
};
|
|
48
|
+
export declare const object: (value: unknown) => value is Obj;
|
|
49
|
+
export declare const list: (value: unknown) => Obj[];
|
|
50
|
+
export declare const text: (value: unknown, fallback?: string) => string;
|
|
51
|
+
export declare const clean: (value: unknown) => string;
|
|
52
|
+
export declare const errorText: (error: unknown) => string;
|
|
53
|
+
export declare const age: (milliseconds: unknown) => string;
|
|
54
|
+
export declare const json: (value: unknown) => string;
|
|
55
|
+
export declare const endpointKey: (row: Pick<EndpointRow, "host" | "id">) => string;
|
|
56
|
+
export declare const unsuccessful: Set<string>;
|
|
57
|
+
export declare const deliveryToken: RegExp;
|
|
58
|
+
export declare function tokenFeedback(token: string): string;
|
|
59
|
+
export declare const groups: readonly ["Working", "Waiting", "Faulted", "Ready", "Dormant", "Not reporting", "Cached"];
|
|
60
|
+
export declare function endpointGroup(row: EndpointRow): number;
|
|
61
|
+
export declare function endpointRows(snapshot?: Obj): EndpointRow[];
|
|
62
|
+
export declare function sectionRows(model: TuiModel, width?: number): (Obj | EndpointRow | DeliverySummary | string)[];
|
|
63
|
+
export declare function operation(row: EndpointRow): string;
|
|
64
|
+
export declare function collisionAliases(snapshot?: Obj): Set<string>;
|
|
65
|
+
export declare function summaryLine(row: DeliverySummary): string;
|
|
66
|
+
export declare const isLoopback: (value: unknown) => boolean;
|
|
67
|
+
export declare function modalFits(model: Readonly<TuiModel>, width: number, height: number): boolean;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import wrapAnsi from "wrap-ansi";
|
|
2
|
+
export const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
3
|
+
export const list = (value) => Array.isArray(value) ? value.filter(object) : [];
|
|
4
|
+
export const text = (value, fallback = "not reported") => typeof value === "string" && value.length > 0 ? value : fallback;
|
|
5
|
+
const ansi = /(?:\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[P^_X][\s\S]*?\u001b\\|\u001b\[[0-?]*[ -/]*[@-~]|\u001b[@-_])/g;
|
|
6
|
+
export const clean = (value) => text(value, "").replace(ansi, "")
|
|
7
|
+
.replace(/[\p{Cc}\p{Cf}]/gu, (character) => character === "\u200d" ? character
|
|
8
|
+
: character === "\n" || character === "\r" || character === "\t" ? " " : "?");
|
|
9
|
+
export const errorText = (error) => {
|
|
10
|
+
if (object(error) && typeof error.code === "string")
|
|
11
|
+
return clean(error.code);
|
|
12
|
+
if (error instanceof Error && typeof error.code === "string")
|
|
13
|
+
return clean(error.code);
|
|
14
|
+
return "CONTROL_UNAVAILABLE";
|
|
15
|
+
};
|
|
16
|
+
export const age = (milliseconds) => {
|
|
17
|
+
const ms = typeof milliseconds === "number" && Number.isFinite(milliseconds) ? Math.max(0, milliseconds) : 0;
|
|
18
|
+
if (ms < 1_000)
|
|
19
|
+
return `${Math.round(ms)}ms`;
|
|
20
|
+
if (ms < 60_000)
|
|
21
|
+
return `${Math.floor(ms / 1_000)}s`;
|
|
22
|
+
if (ms < 3_600_000)
|
|
23
|
+
return `${Math.floor(ms / 60_000)}m`;
|
|
24
|
+
return `${Math.floor(ms / 3_600_000)}h`;
|
|
25
|
+
};
|
|
26
|
+
export const json = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
return clean(JSON.stringify(value));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return "unprintable result";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const endpointKey = (row) => `${row.host}\0${row.id}`;
|
|
35
|
+
const loopback = (value) => typeof value === "string" && /^loopback-[ab]-[0-9a-f]{8}@/.test(value);
|
|
36
|
+
export const unsuccessful = new Set(["failed", "cancelled", "expired", "ambiguous", "unconfirmed"]);
|
|
37
|
+
export const deliveryToken = /^dlv_[A-Za-z0-9_-]{24}$/;
|
|
38
|
+
export function tokenFeedback(token) {
|
|
39
|
+
if (deliveryToken.test(token))
|
|
40
|
+
return "format valid";
|
|
41
|
+
if ("dlv_".startsWith(token) || /^dlv_[A-Za-z0-9_-]{0,23}$/.test(token))
|
|
42
|
+
return "format incomplete";
|
|
43
|
+
return "format invalid";
|
|
44
|
+
}
|
|
45
|
+
export const groups = ["Working", "Waiting", "Faulted", "Ready", "Dormant", "Not reporting", "Cached"];
|
|
46
|
+
export function endpointGroup(row) {
|
|
47
|
+
if (!row.local)
|
|
48
|
+
return 6;
|
|
49
|
+
return { busy: 0, waiting: 1, systemError: 2, idle: 3, dormant: 4 }[String(row.codex?.state)] ?? 5;
|
|
50
|
+
}
|
|
51
|
+
export function endpointRows(snapshot) {
|
|
52
|
+
const local = list(snapshot?.routes).map((row) => ({ id: text(row.id), alias: text(row.alias), provider: text(row.provider),
|
|
53
|
+
host: text(row.host), local: true, ...(typeof row.queueDepth === "number" ? { queueDepth: row.queueDepth } : {}),
|
|
54
|
+
...(object(row.lastOperation) ? { lastOperation: row.lastOperation } : {}), ...(object(row.codex) ? { codex: row.codex } : {}) }));
|
|
55
|
+
const federation = object(snapshot?.federation) ? snapshot.federation : undefined;
|
|
56
|
+
const remote = list(federation?.nodes).flatMap((node) => {
|
|
57
|
+
const common = { host: text(node.host), local: false,
|
|
58
|
+
...(typeof node.observedAt === "string" ? { observedAt: node.observedAt } : {}),
|
|
59
|
+
...(typeof node.safeErrorCode === "string" ? { safeErrorCode: node.safeErrorCode } : {}) };
|
|
60
|
+
const routes = list(node.routes);
|
|
61
|
+
return routes.length ? routes.map((row) => ({ ...common, id: text(row.id), alias: text(row.alias),
|
|
62
|
+
provider: text(row.provider), host: text(row.host, common.host) }))
|
|
63
|
+
: [{ ...common, id: "", alias: "No cached endpoints", provider: "-", placeholder: true }];
|
|
64
|
+
});
|
|
65
|
+
return [...local, ...remote].sort((a, b) => endpointGroup(a) - endpointGroup(b));
|
|
66
|
+
}
|
|
67
|
+
function deliveryRows(snapshot) {
|
|
68
|
+
const sorted = list(snapshot?.messages).sort((a, b) => (typeof a.ageMs === "number" ? a.ageMs : Number.MAX_SAFE_INTEGER) -
|
|
69
|
+
(typeof b.ageMs === "number" ? b.ageMs : Number.MAX_SAFE_INTEGER));
|
|
70
|
+
const result = [];
|
|
71
|
+
for (const row of sorted) {
|
|
72
|
+
const anonymous = typeof row.source !== "string" && typeof row.target !== "string", last = result.at(-1);
|
|
73
|
+
if (object(last) && last.summary === true && anonymous && Array.isArray(last.rows))
|
|
74
|
+
result[result.length - 1] = { summary: true, rows: [...last.rows.filter(object), row] };
|
|
75
|
+
else if (anonymous)
|
|
76
|
+
result.push({ summary: true, rows: [row] });
|
|
77
|
+
else
|
|
78
|
+
result.push(row);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
export function sectionRows(model, width = 80) {
|
|
83
|
+
if (model.section === "endpoints")
|
|
84
|
+
return endpointRows(model.snapshot);
|
|
85
|
+
if (model.section === "deliveries")
|
|
86
|
+
return deliveryRows(model.snapshot);
|
|
87
|
+
if (model.section === "result") {
|
|
88
|
+
if (!model.result)
|
|
89
|
+
return [];
|
|
90
|
+
let value = model.result.value;
|
|
91
|
+
try {
|
|
92
|
+
value = JSON.stringify(JSON.parse(value), null, 2);
|
|
93
|
+
}
|
|
94
|
+
catch { /* A refusal includes plain operator guidance. */ }
|
|
95
|
+
return [`${model.result.label}:`, ...value.split("\n").flatMap((line) => wrapAnsi(clean(line), Math.max(1, width - 2), { hard: true, trim: false }).split("\n"))];
|
|
96
|
+
}
|
|
97
|
+
return list(model.snapshot?.retirements);
|
|
98
|
+
}
|
|
99
|
+
export function operation(row) {
|
|
100
|
+
if (!row.lastOperation)
|
|
101
|
+
return "not yet observed";
|
|
102
|
+
const outcome = text(row.lastOperation.outcome);
|
|
103
|
+
return outcome === "delivered" ? "delivered" : `${outcome} !${text(row.lastOperation.code)}`;
|
|
104
|
+
}
|
|
105
|
+
export function collisionAliases(snapshot) {
|
|
106
|
+
const counts = new Map();
|
|
107
|
+
for (const row of endpointRows(snapshot))
|
|
108
|
+
if (!row.placeholder)
|
|
109
|
+
counts.set(row.alias, (counts.get(row.alias) ?? 0) + 1);
|
|
110
|
+
return new Set([...counts].filter(([, count]) => count > 1).map(([alias]) => alias));
|
|
111
|
+
}
|
|
112
|
+
export function summaryLine(row) {
|
|
113
|
+
const counts = new Map();
|
|
114
|
+
for (const item of row.rows) {
|
|
115
|
+
const state = text(item.state), label = `${state}${unsuccessful.has(state) && item.safeErrorCode ? ` !${text(item.safeErrorCode)}` : ""}`;
|
|
116
|
+
counts.set(label, (counts.get(label) ?? 0) + 1);
|
|
117
|
+
}
|
|
118
|
+
return `${row.rows.length} unattributed deliveries · ${[...counts].map(([label, count]) => `${label} ${count}`).join(" · ")}`;
|
|
119
|
+
}
|
|
120
|
+
export const isLoopback = loopback;
|
|
121
|
+
export function modalFits(model, width, height) {
|
|
122
|
+
if (width < 48)
|
|
123
|
+
return false;
|
|
124
|
+
const inner = Math.min(78, width - 4) - 6;
|
|
125
|
+
const count = (value) => wrapAnsi(clean(value), inner, { hard: true, trim: false }).split("\n").length;
|
|
126
|
+
if (model.mode === "token")
|
|
127
|
+
return height >= 11;
|
|
128
|
+
if (model.mode !== "confirm" || !model.retiring)
|
|
129
|
+
return true;
|
|
130
|
+
const row = model.retiring;
|
|
131
|
+
const rows = 11 + count(`Host: ${row.host}`) + count(`Alias: ${row.alias}`) + count(row.id) +
|
|
132
|
+
count(`${row.provider} · queue ${row.queueDepth ?? 0} · last ${operation(row)}`) +
|
|
133
|
+
count("queued/reserved work is cancelled, armed work becomes ambiguous, accepted work becomes unconfirmed — cannot be undone.");
|
|
134
|
+
return rows <= height;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=tui-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui-model.js","sourceRoot":"","sources":["../../../src/gateway/tui-model.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAwCjC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAgB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAc,EAAS,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAc,EA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AAM,CAAC;IAC/G,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,MAAM,IAAI,EAAE,CAAC;IAChD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7D,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC3B,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACzF,KAAK,CAAC,GAAG,GAAG,CAAC,QAAQ,YAAY,GAAG,CAAC,UAAU,IAAI,CAAC,WAAW,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAChF,KAAK,CAAC,wHAAwH,CAAC,CAAC;IAClI,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type TuiModel } from "./tui-model.js";
|
|
3
|
+
export type TuiViewProps = Readonly<{
|
|
4
|
+
model: Readonly<TuiModel>;
|
|
5
|
+
columns: number;
|
|
6
|
+
rows: number;
|
|
7
|
+
now: number;
|
|
8
|
+
color: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export { modalFits } from "./tui-model.js";
|
|
11
|
+
export declare function TuiView({ model, columns, rows, now, color }: TuiViewProps): React.JSX.Element;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Box, Text } from "ink";
|
|
4
|
+
import stringWidth from "string-width";
|
|
5
|
+
import { age, clean, collisionAliases, endpointGroup, endpointKey, groups, isLoopback, list, modalFits, object, operation, sectionRows, summaryLine, text, tokenFeedback, unsuccessful, } from "./tui-model.js";
|
|
6
|
+
function tone(value) {
|
|
7
|
+
if (["healthy", "idle", "ready", "delivered", "ok"].includes(value))
|
|
8
|
+
return "good";
|
|
9
|
+
if (["busy", "working", "queued", "reserved", "armed", "accepted"].includes(value))
|
|
10
|
+
return "busy";
|
|
11
|
+
if (value === "waiting")
|
|
12
|
+
return "waiting";
|
|
13
|
+
if (["dormant", "cached", "unknown"].includes(value))
|
|
14
|
+
return "dormant";
|
|
15
|
+
if (value === "stale")
|
|
16
|
+
return "busy";
|
|
17
|
+
if (unsuccessful.has(value) || ["unreachable", "not reachable", "degraded", "systemError"].includes(value))
|
|
18
|
+
return "bad";
|
|
19
|
+
return "plain";
|
|
20
|
+
}
|
|
21
|
+
function ToneText({ children, value, color, bold = false, inverse = false, dim = false, wrap = "truncate-end" }) {
|
|
22
|
+
const semantic = tone(value ?? "");
|
|
23
|
+
const foreground = !color ? undefined : semantic === "good" ? "green" : semantic === "busy" ? "yellow"
|
|
24
|
+
: semantic === "waiting" ? "magenta" : semantic === "bad" ? "red" : undefined;
|
|
25
|
+
return _jsx(Text, { ...(foreground ? { color: foreground } : {}), bold: color && bold, inverse: color && inverse, dimColor: color && (dim || semantic === "dormant" || value === "stale"), ...(wrap ? { wrap } : {}), children: children });
|
|
26
|
+
}
|
|
27
|
+
const graphemes = new Intl.Segmenter("en", { granularity: "grapheme" });
|
|
28
|
+
function padded(value, width, right = false) {
|
|
29
|
+
const safe = clean(value);
|
|
30
|
+
let output = safe;
|
|
31
|
+
if (stringWidth(safe) > width) {
|
|
32
|
+
output = "";
|
|
33
|
+
for (const { segment } of graphemes.segment(safe)) {
|
|
34
|
+
if (stringWidth(output + segment) > width - 1)
|
|
35
|
+
break;
|
|
36
|
+
output += segment;
|
|
37
|
+
}
|
|
38
|
+
output += width > 0 ? "…" : "";
|
|
39
|
+
}
|
|
40
|
+
const space = " ".repeat(Math.max(0, width - stringWidth(output)));
|
|
41
|
+
return right ? space + output : output + space;
|
|
42
|
+
}
|
|
43
|
+
function DataLine({ cells, selected, color, width }) {
|
|
44
|
+
return _jsx(Box, { height: 1, flexShrink: 0, width: width, children: _jsxs(Text, { inverse: selected && color, children: [selected ? "> " : " ", cells.map((cell, index) => _jsx(ToneText, { color: color, ...(!selected && cell.tone ? { value: cell.tone } : {}), bold: cell.bold ?? false, dim: !selected && (cell.dim ?? false), children: index < cells.length - 1 ? `${padded(cell.value, Math.max(0, cell.width - 1), cell.right)} ` : padded(cell.value, cell.width, cell.right) }, index))] }) });
|
|
45
|
+
}
|
|
46
|
+
function endpointWidths(width) {
|
|
47
|
+
const alias = Math.min(48, Math.max(10, width - 63));
|
|
48
|
+
return { alias, outcome: Math.max(1, width - alias - 27) };
|
|
49
|
+
}
|
|
50
|
+
function Rule({ width, color }) {
|
|
51
|
+
return _jsx(ToneText, { color: color, dim: true, children: "─".repeat(Math.max(1, width)) });
|
|
52
|
+
}
|
|
53
|
+
function HostTabs({ model, color, width }) {
|
|
54
|
+
if (!model.hosts || model.hosts.length < 2)
|
|
55
|
+
return null;
|
|
56
|
+
const count = Math.max(1, Math.floor(width / 24)), active = Math.max(0, model.hosts.findIndex((host) => host.selected));
|
|
57
|
+
const start = Math.max(0, Math.min(active - 1, model.hosts.length - count));
|
|
58
|
+
return _jsx(Box, { flexShrink: 0, height: 1, overflow: "hidden", children: model.hosts.slice(start, start + count).map((host) => _jsxs(Box, { width: Math.floor(width / Math.min(count, model.hosts.length)), paddingRight: 1, flexShrink: 0, children: [_jsx(ToneText, { color: color, value: host.state, children: "\u25CF " }), _jsx(ToneText, { color: color, value: host.state, bold: host.selected, wrap: "truncate-end", children: host.selected ? `[${clean(host.host)} · ${clean(host.state)}]` : `${clean(host.host)} · ${clean(host.state)}` })] }, host.host)) });
|
|
59
|
+
}
|
|
60
|
+
function Header({ model, width, now, color }) {
|
|
61
|
+
const snapshot = model.snapshot;
|
|
62
|
+
const health = model.error ? "UNREACHABLE" : snapshot ? text(snapshot.health, "unknown") : "not reachable";
|
|
63
|
+
const elapsed = model.snapshotAt === undefined ? "never" : now - model.snapshotAt < 1_000 ? "just now" : `${age(now - model.snapshotAt)} ago`;
|
|
64
|
+
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(HostTabs, { model: model, color: color, width: width }), _jsxs(Box, { height: 1, children: [_jsx(Box, { width: Math.max(12, width - 43), children: _jsxs(ToneText, { color: color, bold: true, wrap: "truncate-end", children: ["Embassy ", clean(model.host ?? "local")] }) }), _jsx(Box, { width: 25, children: _jsxs(ToneText, { color: color, value: health.toLowerCase(), children: ["broker ", clean(health)] }) }), _jsx(Box, { width: 18, children: _jsxs(ToneText, { color: color, dim: true, wrap: "truncate-end", children: ["ledger rev ", String(snapshot?.revision ?? "-")] }) })] }), _jsx(Box, { height: 1, flexShrink: 0, children: _jsxs(ToneText, { color: color, dim: true, wrap: "truncate-end", children: ["Updated ", elapsed, object(snapshot?.codex) ? ` · Codex discovery ${snapshot.codex.complete ? "up to 20 most recent" : "partial"}${snapshot.codex.truncated ? " · truncated" : ""} · ${observationAge(snapshot.codex.observedAt, now)}${snapshot.codex.safeErrorCode ? ` !${clean(text(snapshot.codex.safeErrorCode))}` : ""}` : ""] }) }), model.error ? _jsxs(_Fragment, { children: [_jsxs(ToneText, { color: color, value: "stale", children: ["STALE ", age(now - (model.staleSince ?? now)), " !", clean(model.error)] }), _jsxs(ToneText, { color: color, dim: true, children: [snapshot ? `Last-known: ${clean(text(snapshot.health))}. ` : "", "Run embassy service status on ", clean(model.host ?? "local"), "."] }), model.errorDetail ? _jsx(ToneText, { color: color, value: "failed", children: clean(model.errorDetail) }) : null] }) : snapshot?.safeErrorCode ? _jsxs(ToneText, { color: color, value: "failed", children: ["!", clean(text(snapshot.safeErrorCode))] }) : null, model.restarted ? _jsx(ToneText, { color: color, value: "busy", children: "Ledger revision decreased; broker restarted/reset." }) : null, _jsx(ToneText, { color: color, dim: true, children: padded("── not a provider readiness proof ", width).replace(/ +$/, (spaces) => " " + "─".repeat(Math.max(0, spaces.length - 1))) })] });
|
|
65
|
+
}
|
|
66
|
+
function observationAge(value, now) {
|
|
67
|
+
const parsed = typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
68
|
+
return Number.isFinite(parsed) ? `${age(now - parsed)} ago` : "not yet refreshed";
|
|
69
|
+
}
|
|
70
|
+
function SectionTabs({ model, color }) {
|
|
71
|
+
const failed = list(model.snapshot?.messages).filter((row) => row.state === "failed").length;
|
|
72
|
+
const tabs = ["endpoints", "deliveries", "retirements", "result"];
|
|
73
|
+
return _jsx(Box, { flexShrink: 0, children: tabs.map((section, index) => {
|
|
74
|
+
const selected = model.section === section;
|
|
75
|
+
const label = `${index + 1} ${section}`;
|
|
76
|
+
return _jsxs(Box, { marginRight: 2, children: [_jsx(ToneText, { color: color, bold: selected, dim: !selected, children: selected ? `[${label}` : label }), section === "deliveries" && failed ? _jsxs(ToneText, { color: color, value: "failed", children: [" (", failed, " failed)"] }) : null, selected ? _jsx(ToneText, { color: color, bold: true, children: "]" }) : null] }, section);
|
|
77
|
+
}) });
|
|
78
|
+
}
|
|
79
|
+
function EndpointLine({ row, selected, collisions, color, now, width }) {
|
|
80
|
+
const state = row.local ? text(row.codex?.state, "unknown") : row.safeErrorCode ? "stale" : "cached";
|
|
81
|
+
const alias = clean(row.alias), collision = collisions.has(row.alias);
|
|
82
|
+
const sizes = endpointWidths(width), outcome = text(row.lastOperation?.outcome, "");
|
|
83
|
+
return _jsxs(Box, { flexDirection: "column", children: [_jsx(DataLine, { selected: selected, color: color, width: width, cells: [
|
|
84
|
+
{ value: state, width: 12, tone: state }, { value: alias, width: sizes.alias, bold: true },
|
|
85
|
+
{ value: row.provider, width: 7, dim: true }, { value: row.local ? String(row.queueDepth ?? 0) : "—", width: 6, right: true, dim: true },
|
|
86
|
+
{ value: row.local ? operation(row) : "not reported", width: sizes.outcome,
|
|
87
|
+
tone: outcome === "failed" || outcome === "delivered" ? outcome : "", dim: !["failed", "delivered"].includes(outcome) },
|
|
88
|
+
] }), collision ? _jsx(Box, { paddingLeft: 14, height: 1, children: _jsxs(ToneText, { color: color, dim: true, wrap: "truncate-end", children: ["ambiguous name \u00B7 endpoint \u2026", clean(row.id.slice(-8))] }) }) : null, !row.local ? _jsx(Box, { paddingLeft: 14, height: 1, children: _jsxs(ToneText, { color: color, value: row.safeErrorCode ? "stale" : "dormant", dim: true, wrap: "truncate-end", children: ["SSH ", clean(row.host), " \u00B7 catalog ", observationAge(row.observedAt, now), row.safeErrorCode ? ` !${clean(row.safeErrorCode)}` : "", " \u00B7 queue/last not reported"] }) }) : null] });
|
|
89
|
+
}
|
|
90
|
+
function DeliveryLine({ row, selected, color, width }) {
|
|
91
|
+
if (row.summary === true)
|
|
92
|
+
return _jsx(DataLine, { selected: selected, color: color, width: width, cells: [{ value: summaryLine(row), width: width - 2,
|
|
93
|
+
tone: row.rows.some((item) => unsuccessful.has(String(item.state))) ? "failed" : "" }] });
|
|
94
|
+
const item = row;
|
|
95
|
+
const state = text(item.state), fault = unsuccessful.has(state) && item.safeErrorCode ? ` !${clean(text(item.safeErrorCode))}` : "";
|
|
96
|
+
const source = clean(text(item.source, "unavailable sender")), target = clean(text(item.target, "unavailable recipient"));
|
|
97
|
+
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(DataLine, { selected: selected, color: color, width: width, cells: [
|
|
98
|
+
{ value: `${age(item.ageMs)} ago`, width: 10, right: true, dim: true }, { value: state, width: 13, tone: state },
|
|
99
|
+
{ value: `${source} -> ${target}${isLoopback(source) || isLoopback(target) ? " (loopback check)" : ""}`, width: width - 25, bold: true },
|
|
100
|
+
] }), fault ? _jsx(Box, { paddingLeft: 25, height: 1, children: _jsx(ToneText, { color: color, value: "failed", wrap: "truncate-end", children: fault.trim() }) }) : null] });
|
|
101
|
+
}
|
|
102
|
+
function content(model, color, now, width) {
|
|
103
|
+
const rows = sectionRows(model, width), selected = selectedIndex(model, rows), collisions = collisionAliases(model.snapshot);
|
|
104
|
+
const entries = [];
|
|
105
|
+
if (model.section === "endpoints") {
|
|
106
|
+
let prior = -1;
|
|
107
|
+
for (const [index, item] of rows.entries()) {
|
|
108
|
+
const group = endpointGroup(item);
|
|
109
|
+
if (group !== prior) {
|
|
110
|
+
const count = rows.filter((row) => endpointGroup(row) === group).length;
|
|
111
|
+
entries.push({ key: `group-${group}`, height: 1, node: _jsxs(ToneText, { color: color, bold: true, children: [groups[group], " (", count, ")"] }) });
|
|
112
|
+
prior = group;
|
|
113
|
+
}
|
|
114
|
+
entries.push({ key: `${endpointKey(item)}\0${index}`, index, height: 1 + Number(collisions.has(item.alias)) + Number(!item.local),
|
|
115
|
+
node: _jsx(EndpointLine, { row: item, selected: index === selected, collisions: collisions, color: color, now: now, width: width }) });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (model.section === "deliveries") {
|
|
119
|
+
rows.forEach((row, index) => entries.push({ key: `delivery-${index}`, index,
|
|
120
|
+
height: object(row) && !row.summary && unsuccessful.has(String(row.state)) && row.safeErrorCode ? 2 : 1,
|
|
121
|
+
node: _jsx(DeliveryLine, { row: row, selected: index === selected, color: color, width: width }) }));
|
|
122
|
+
}
|
|
123
|
+
else if (model.section === "retirements") {
|
|
124
|
+
rows.forEach((row, index) => {
|
|
125
|
+
const item = row, alias = text(item.alias), at = Date.parse(String(item.at));
|
|
126
|
+
entries.push({ key: `retirement-${index}`, index, height: 1,
|
|
127
|
+
node: _jsx(DataLine, { selected: index === selected, color: color, width: width, cells: [
|
|
128
|
+
{ value: Number.isFinite(at) ? `${age(now - at)} ago` : text(item.at), width: 11, right: true, dim: true },
|
|
129
|
+
{ value: alias + (isLoopback(alias) ? " (loopback check)" : ""), width: width - 13, bold: !isLoopback(alias), dim: isLoopback(alias) },
|
|
130
|
+
] }) });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else if (model.result) {
|
|
134
|
+
rows.forEach((row, index) => {
|
|
135
|
+
const state = /"(?:state|status|health|outcome)":\s*"([a-zA-Z]+)"/.exec(String(row))?.[1];
|
|
136
|
+
entries.push({ key: `result-${index}`, index, height: 1,
|
|
137
|
+
node: _jsx(DataLine, { selected: index === selected, color: color, width: width, cells: [
|
|
138
|
+
{ value: clean(row), width: width - 2, ...(state ? { tone: state } : {}), bold: index === 0 },
|
|
139
|
+
] }) });
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return entries;
|
|
143
|
+
}
|
|
144
|
+
function selectedIndex(model, rows = sectionRows(model)) {
|
|
145
|
+
if (model.section === "endpoints" && model.selectedEndpoint)
|
|
146
|
+
return rows.findIndex((row) => endpointKey(row) === model.selectedEndpoint);
|
|
147
|
+
return Math.max(0, Math.min(model.selected[model.section] ?? 0, Math.max(0, rows.length - 1)));
|
|
148
|
+
}
|
|
149
|
+
function viewport(all, focus, height) {
|
|
150
|
+
let start = 0, end = 0;
|
|
151
|
+
while (start < all.length) {
|
|
152
|
+
let remaining = height - Number(all.slice(0, start).some((entry) => entry.index !== undefined));
|
|
153
|
+
end = start;
|
|
154
|
+
while (end < all.length && all[end].height <= remaining) {
|
|
155
|
+
remaining -= all[end].height;
|
|
156
|
+
end++;
|
|
157
|
+
}
|
|
158
|
+
if (end < all.length && remaining === 0)
|
|
159
|
+
end--;
|
|
160
|
+
while (end > start && all[end - 1].index === undefined)
|
|
161
|
+
end--;
|
|
162
|
+
if (focus < 0 || focus < end || start >= focus)
|
|
163
|
+
break;
|
|
164
|
+
start++;
|
|
165
|
+
}
|
|
166
|
+
const above = all.slice(0, start).filter((entry) => entry.index !== undefined).length;
|
|
167
|
+
const below = all.slice(end).filter((entry) => entry.index !== undefined).length;
|
|
168
|
+
return { entries: all.slice(start, end), above, below };
|
|
169
|
+
}
|
|
170
|
+
function DialogContent({ model, columns, color }) {
|
|
171
|
+
const retirement = model.mode === "confirm" ? model.retiring : undefined;
|
|
172
|
+
return _jsxs(Box, { width: Math.min(78, columns - 4), borderStyle: "round", borderColor: color ? "gray" : undefined, paddingX: 2, paddingY: 1, flexDirection: "column", children: [_jsx(ToneText, { color: color, bold: true, children: retirement ? "Retire endpoint" : "Look up delivery" }), _jsx(Box, { height: 1 }), retirement ? _jsxs(_Fragment, { children: [_jsxs(ToneText, { color: color, bold: true, wrap: "wrap", children: ["Host: ", clean(retirement.host)] }), _jsxs(ToneText, { color: color, bold: true, wrap: "wrap", children: ["Alias: ", clean(retirement.alias)] }), _jsx(ToneText, { color: color, dim: true, children: "Endpoint ID" }), _jsx(ToneText, { color: color, bold: true, wrap: "wrap", children: clean(retirement.id) }), _jsx(Box, { height: 1 }), _jsxs(ToneText, { color: color, bold: true, wrap: "wrap", children: [clean(retirement.provider), " \u00B7 queue ", retirement.queueDepth ?? 0, " \u00B7 last ", clean(operation(retirement))] }), _jsx(Box, { height: 1 }), _jsx(ToneText, { color: color, value: "failed", wrap: "wrap", children: "queued/reserved work is cancelled, armed work becomes ambiguous, accepted work becomes unconfirmed \u2014 cannot be undone." }), _jsx(Box, { height: 1 }), _jsxs(Box, { children: [_jsx(ToneText, { color: color, value: "failed", bold: true, children: "y confirm" }), _jsx(ToneText, { color: color, children: " \u00B7 " }), _jsx(ToneText, { color: color, bold: true, children: "[N] cancel" })] })] }) : _jsxs(_Fragment, { children: [_jsx(ToneText, { color: color, dim: true, children: "Delivery token" }), _jsx(ToneText, { color: color, bold: true, children: clean(model.token || "dlv_…") }), _jsx(ToneText, { color: color, dim: true, children: tokenFeedback(model.token) }), _jsx(Box, { height: 1 }), _jsx(ToneText, { color: color, bold: true, children: "Enter look up \u00B7 Esc cancel" })] })] });
|
|
173
|
+
}
|
|
174
|
+
export { modalFits } from "./tui-model.js";
|
|
175
|
+
function Dialog({ model, columns, rows, color }) {
|
|
176
|
+
if (!modalFits(model, columns, rows))
|
|
177
|
+
return _jsx(TooSmall, { mode: model.mode, color: color });
|
|
178
|
+
return _jsx(Box, { width: columns, height: rows, alignItems: "center", justifyContent: "center", children: _jsx(DialogContent, { model: model, columns: columns, color: color }) });
|
|
179
|
+
}
|
|
180
|
+
function TooSmall({ mode, color }) {
|
|
181
|
+
return _jsxs(Box, { flexDirection: "column", width: "100%", children: [_jsx(Box, { height: 1, flexShrink: 0, children: _jsx(ToneText, { color: color, bold: true, wrap: "truncate-end", children: "Embassy \u00B7 terminal too small" }) }), _jsx(Box, { height: 1, flexShrink: 0, children: _jsx(ToneText, { color: color, dim: true, wrap: "truncate-end", children: mode === "confirm" ? "Resize to show the exact endpoint ID and consequences." : "Resize: needs 48×10." }) }), _jsx(Box, { height: 1, flexShrink: 0, children: _jsx(ToneText, { color: color, wrap: "truncate-end", children: mode === "confirm" ? "N cancel" : mode === "token" ? "Esc cancel" : "q quit" }) })] });
|
|
182
|
+
}
|
|
183
|
+
export function TuiView({ model, columns, rows, now, color }) {
|
|
184
|
+
const width = Math.max(1, columns), height = Math.max(1, rows);
|
|
185
|
+
if (height < 10 || width < 48)
|
|
186
|
+
return _jsx(Box, { width: width, height: height, overflow: "hidden", children: _jsx(TooSmall, { mode: model.mode, color: color }) });
|
|
187
|
+
if (model.mode !== "browse")
|
|
188
|
+
return _jsx(Dialog, { model: model, columns: width, rows: height, color: color });
|
|
189
|
+
const all = content(model, color, now, width), source = sectionRows(model, width), selected = selectedIndex(model, source);
|
|
190
|
+
const headerRows = 3 + (model.hosts && model.hosts.length > 1 ? 1 : 0) + (model.error ? 2 + (model.errorDetail ? 1 : 0) : model.snapshot?.safeErrorCode ? 1 : 0)
|
|
191
|
+
+ (model.restarted ? 1 : 0);
|
|
192
|
+
const actionRows = model.action ? 1 : 0, available = Math.max(1, height - headerRows - actionRows - 3 - Number(model.section === "endpoints"));
|
|
193
|
+
const focus = all.findIndex((entry) => entry.index === selected);
|
|
194
|
+
const visible = viewport(all, focus, available), sizes = endpointWidths(width);
|
|
195
|
+
const counter = `${model.section}${model.section === "result" ? " line" : ""} ${source.length ? `${selected < 0 ? "-" : selected + 1}/${source.length}` : "0/0"}`;
|
|
196
|
+
const empty = model.error ? `Broker unreachable (!${model.error}).` : !model.snapshot ? "Broker not reachable."
|
|
197
|
+
: model.section === "endpoints" ? "No endpoints registered." : model.section === "deliveries" ? "No deliveries yet."
|
|
198
|
+
: model.section === "retirements" ? "No retirements." : "No result yet. Run an action to see its result here.";
|
|
199
|
+
return _jsxs(Box, { width: width, height: height, flexDirection: "column", children: [_jsx(Header, { model: model, width: width, now: now, color: color }), _jsx(SectionTabs, { model: model, color: color }), model.section === "endpoints" ? _jsx(DataLine, { selected: false, color: color, width: width, cells: [
|
|
200
|
+
{ value: "State", width: 12, dim: true }, { value: "Endpoint", width: sizes.alias, dim: true },
|
|
201
|
+
{ value: "Type", width: 7, dim: true }, { value: "Queue", width: 6, right: true, dim: true },
|
|
202
|
+
{ value: "Outcome", width: sizes.outcome, dim: true },
|
|
203
|
+
] }) : null, _jsxs(Box, { flexDirection: "column", height: available, flexShrink: 0, overflow: "hidden", children: [visible.above > 0 ? _jsxs(ToneText, { color: color, dim: true, children: ["\u2191 ", visible.above, " more"] }) : null, visible.entries.length ? visible.entries.map((entry) => _jsx(React.Fragment, { children: entry.node }, entry.key))
|
|
204
|
+
: _jsx(ToneText, { color: color, dim: true, children: empty }), _jsx(Box, { flexGrow: 1 }), visible.below > 0 ? _jsxs(ToneText, { color: color, dim: true, children: ["\u2193 ", visible.below, " more"] }) : null] }), model.action ? _jsxs(ToneText, { color: color, ...(model.actionRunning ? { value: "busy" } : {}), wrap: "truncate-end", children: [clean(model.action), model.actionRunning ? " — polling paused" : ""] }) : null, _jsx(Rule, { width: width, color: color }), _jsx(Box, { height: 1, flexShrink: 0, children: _jsxs(ToneText, { color: color, dim: true, wrap: "truncate-end", children: [counter, " \u00B7 [/]:host Tab:view \u2191\u2193 r:refresh c:check d:token x:retire q:quit"] }) })] });
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=tui-view.js.map
|