my-durable 0.0.76 → 0.0.78
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/apps/dpi-backend/src/archived.ts +54 -9
- package/apps/dpi-backend/src/git.ts +178 -78
- package/apps/dpi-backend/src/pairing.ts +3 -1
- package/apps/dpi-backend/src/salvage.ts +70 -4
- package/apps/dpi-backend/src/store.ts +273 -15
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-h81haD43.css → index-BF6mtGF4.css} +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DAF9D074.js +82 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/git-rules.ts +38 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/git-store.ts +64 -19
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/hub.ts +26 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/GitPanel.vue +46 -2
- package/apps/dpi-playground/apps/dpi-playground-hub/src/audit.ts +11 -3
- package/apps/dpi-playground/apps/dpi-playground-hub/src/monitor.ts +25 -2
- package/apps/dpi-playground/apps/dpi-playground-hub/src/mux.ts +44 -4
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-transport.ts +52 -6
- package/apps/dpi-sdk/src/api.ts +5 -1
- package/apps/dpi-sdk/src/models.ts +180 -19
- package/apps/dpi-sdk/src/node/config.ts +13 -2
- package/apps/dpi-sdk/src/node/ops.ts +33 -6
- package/apps/dpi-sdk/src/node/registry-migration.ts +76 -3
- package/apps/dpi-sdk/src/node/registry.ts +5 -2
- package/apps/dpi-sdk/src/transcript.ts +1 -0
- package/apps/dpi-tui/src/app.ts +7 -6
- package/apps/dpi-tui/src/pairing.ts +15 -11
- package/apps/dpi-tui/src/pickers.ts +11 -8
- package/apps/dpi-tui/src/sanitize.ts +5 -0
- package/apps/dpi-tui/src/views.ts +16 -16
- package/apps/dpi-tui/src/welcome.ts +9 -4
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-BmxTF5DB.js +0 -82
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@earendil-works/pi-tui";
|
|
14
14
|
import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
|
|
15
15
|
import { agentTree, type TreeNode } from "../../dpi-sdk/src/models.ts";
|
|
16
|
-
import { sanitizeTerminal } from "./sanitize.ts";
|
|
16
|
+
import { oneLine, sanitizeTerminal } from "./sanitize.ts";
|
|
17
17
|
import type { App } from "./app.ts";
|
|
18
18
|
import { c, selectTheme } from "./theme.ts";
|
|
19
19
|
|
|
@@ -261,11 +261,14 @@ export async function pickSession(app: App) {
|
|
|
261
261
|
const tree = await app.client.tree();
|
|
262
262
|
const items: SelectItem[] = [
|
|
263
263
|
{ value: "+new", label: "+ New session", description: `choose a directory on ${sanitizeTerminal(app.device.id)}` },
|
|
264
|
-
...tree.sessions.map((s) =>
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
...tree.sessions.map((s) => {
|
|
265
|
+
const agents = Array.isArray(s.agents) ? s.agents : [];
|
|
266
|
+
return {
|
|
267
|
+
value: s.id,
|
|
268
|
+
label: oneLine(String(s.name ?? "")),
|
|
269
|
+
description: `${oneLine(String(s.cwd ?? "").split("/").slice(-2).join("/"))} │ ${agents.length} agent${agents.length === 1 ? "" : "s"}${s.busy ? " │ working" : ""}`,
|
|
270
|
+
};
|
|
271
|
+
}),
|
|
269
272
|
];
|
|
270
273
|
app.overlay(
|
|
271
274
|
new Picker(`Sessions on ${sanitizeTerminal(app.device.id)}`, items, (item) => {
|
|
@@ -368,7 +371,7 @@ function chooseModel(app: App, current?: string) {
|
|
|
368
371
|
const models = app.info.models;
|
|
369
372
|
const picker = new Picker(
|
|
370
373
|
`Model (${sanitizeTerminal(app.device.name)})`,
|
|
371
|
-
models.map((m) => ({ value: `${m.provider}/${m.id}`, label:
|
|
374
|
+
models.map((m) => ({ value: `${m.provider}/${m.id}`, label: oneLine(String(m.name ?? "")), description: `${oneLine(String(m.tier ?? ""))} │ ${oneLine(String(m.provider ?? ""))}` })),
|
|
372
375
|
(item) => {
|
|
373
376
|
app.closeOverlay();
|
|
374
377
|
done(models.find((m) => `${m.provider}/${m.id}` === item.value));
|
|
@@ -438,7 +441,7 @@ export function pickAgent(app: App) {
|
|
|
438
441
|
rows.push({
|
|
439
442
|
value: String(a.id),
|
|
440
443
|
label: `${" ".repeat(depth)}${icon} ${sanitizeTerminal(a.name)}${a.busy ? " ●" : ""}`,
|
|
441
|
-
description: [a.kind === "fork" ? `fork @ #${a.forkedAt}` : a.kind, a.background ? `${a.background} bg` : ""]
|
|
444
|
+
description: [a.kind === "fork" ? `fork @ #${oneLine(String(a.forkedAt ?? ""))}` : oneLine(String(a.kind ?? "")), a.background ? `${oneLine(String(a.background))} bg` : ""]
|
|
442
445
|
.filter(Boolean)
|
|
443
446
|
.join(" │ "),
|
|
444
447
|
});
|
|
@@ -12,6 +12,11 @@ const C0 = /[\u0000-\u0008\u000B-\u001F\u007F\u0080-\u009F]/g;
|
|
|
12
12
|
|
|
13
13
|
/** Neutralize terminal control sequences in an untrusted string before render/stdout. */
|
|
14
14
|
export function sanitizeTerminal(s: string): string {
|
|
15
|
+
// run-7 D4-A: wire fields are typed strings only by CONVENTION — a hostile
|
|
16
|
+
// device's name/modelId/branch/error-message arrived as any JSON value and
|
|
17
|
+
// the bare s.replace() below killed the whole TUI render (no try/catch in
|
|
18
|
+
// pi-tui's render loop, no process.on handler installed).
|
|
19
|
+
if (typeof s !== "string") return String(s ?? "");
|
|
15
20
|
return s.replace(ESC_SEQ, "").replace(C0, "");
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -7,7 +7,7 @@ import type { SessionSummary } from "../../dpi-sdk/src/api.ts";
|
|
|
7
7
|
import type { GitStatus } from "../../dpi-sdk/src/client.ts";
|
|
8
8
|
import type { DeviceRow } from "../../dpi-sdk/src/node/registry.ts";
|
|
9
9
|
import { c, STATE_COLOR, STATE_GLYPH, type RowState } from "./theme.ts";
|
|
10
|
-
import { sanitizeTerminal } from "./sanitize.ts";
|
|
10
|
+
import { oneLine, sanitizeTerminal } from "./sanitize.ts";
|
|
11
11
|
|
|
12
12
|
export type View = "herd" | "network" | "agent" | "log";
|
|
13
13
|
|
|
@@ -68,7 +68,7 @@ export const sessionState = (s: SessionSummary): RowState =>
|
|
|
68
68
|
* web's GitPanel has carried a merge banner all along. Mirrors the FE text.
|
|
69
69
|
*/
|
|
70
70
|
export function gitStateSuffix(g: Pick<GitStatus, "merge" | "conflicts" | "detached">): string {
|
|
71
|
-
if (g.merge) return ` · merging (${g.conflicts
|
|
71
|
+
if (g.merge) return ` · merging (${Number(g.conflicts) || 0} conflicts)`;
|
|
72
72
|
if (g.detached) return " (detached)";
|
|
73
73
|
return "";
|
|
74
74
|
}
|
|
@@ -102,19 +102,19 @@ export function herdRows(sessions: SessionSummary[], filter = "", branchOf?: (cw
|
|
|
102
102
|
const out: HerdRow[] = [];
|
|
103
103
|
const groups = new Map<string, SessionSummary[]>();
|
|
104
104
|
for (const s of kept) {
|
|
105
|
-
const key = basename(s.cwd);
|
|
105
|
+
const key = basename(String(s.cwd ?? ""));
|
|
106
106
|
const list = groups.get(key) ?? [];
|
|
107
107
|
list.push(s);
|
|
108
108
|
groups.set(key, list);
|
|
109
109
|
}
|
|
110
110
|
for (const [dir, list] of groups) {
|
|
111
|
-
out.push({ kind: "group", label:
|
|
111
|
+
out.push({ kind: "group", label: oneLine(String(dir ?? "")) });
|
|
112
112
|
for (const s of list)
|
|
113
113
|
out.push({
|
|
114
114
|
kind: "session",
|
|
115
|
-
label:
|
|
115
|
+
label: oneLine(String(s.name ?? "")),
|
|
116
116
|
sessionId: s.id,
|
|
117
|
-
branch: branchOf ?
|
|
117
|
+
branch: branchOf ? oneLine(String(branchOf(String(s.cwd ?? "")) ?? "")) || undefined : undefined,
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
return out;
|
|
@@ -147,7 +147,7 @@ export function renderHerd(
|
|
|
147
147
|
const cursorRow = rows[opts.cursor ?? 0];
|
|
148
148
|
for (const row of rows) {
|
|
149
149
|
if (row.kind === "group") {
|
|
150
|
-
const group = sessions.filter((s) =>
|
|
150
|
+
const group = sessions.filter((s) => oneLine(String(basename(String(s.cwd ?? "")) ?? "")) === row.label);
|
|
151
151
|
const busy = group.filter((s) => s.busy).length;
|
|
152
152
|
const header = `${c.muted("~/")}${c.text(row.label)}${c.muted("/")} ${c.muted(`· ${group.length} agent${group.length === 1 ? "" : "s"} · ${busy} busy`)}`;
|
|
153
153
|
// The cursor is drawn on headers too: a keypress must always be visible,
|
|
@@ -167,7 +167,7 @@ export function renderHerd(
|
|
|
167
167
|
const branch = row.branch ? ` ${c.muted(`⎇ ${fit(row.branch, 10)}`)}` : "";
|
|
168
168
|
let line =
|
|
169
169
|
`${marker}${fit(selected ? c.bold(row.label) : row.label, cols.name - visibleWidth(branch))}${branch} ${fit(state, cols.state)}` +
|
|
170
|
-
(showModel ? ` ${fit(c.muted(
|
|
170
|
+
(showModel ? ` ${fit(c.muted(oneLine(String((basename(String(s.model ?? "")) || s.model) ?? ""))), cols.model)}` : "") +
|
|
171
171
|
` ${fit(c.muted(agents), cols.agents)}`;
|
|
172
172
|
if (showAge) line += ` ${fit(c.muted(ageOf(s.createdAt)), cols.age)}`;
|
|
173
173
|
lines.push(atCursor && !selected ? c.inverse(fit(line, w)) : fit(line, w));
|
|
@@ -208,12 +208,12 @@ export function networkRows(devices: DeviceRow[], currentDeviceId: string, filte
|
|
|
208
208
|
continue;
|
|
209
209
|
out.push({
|
|
210
210
|
kind: "device",
|
|
211
|
-
label:
|
|
211
|
+
label: oneLine(String(d.name || d.id)),
|
|
212
212
|
deviceId: d.id,
|
|
213
213
|
current: d.id === currentDeviceId,
|
|
214
214
|
});
|
|
215
|
-
for (const s of d.lastTree?.sessions
|
|
216
|
-
out.push({ kind: "session", label:
|
|
215
|
+
for (const s of (Array.isArray(d.lastTree?.sessions) ? d.lastTree!.sessions : []))
|
|
216
|
+
out.push({ kind: "session", label: oneLine(String(s.name ?? "")), deviceId: d.id, sessionId: s.id });
|
|
217
217
|
}
|
|
218
218
|
return out;
|
|
219
219
|
}
|
|
@@ -239,7 +239,7 @@ export function renderNetwork(
|
|
|
239
239
|
const seen = d.lastSeenAt ? ageOf(d.lastSeenAt) : "never";
|
|
240
240
|
label =
|
|
241
241
|
`${dot} ${c.bold(row.label)}${row.current ? c.accent(" ▌") : ""} ${c.muted(`[${d.kind}]`)} ` +
|
|
242
|
-
`${c.muted(d.transport === "tunnel" ? "tunnel" : "lan")} ${c.muted(d.lastStatus === "online" ? seen : `${
|
|
242
|
+
`${c.muted(d.transport === "tunnel" ? "tunnel" : "lan")} ${c.muted(d.lastStatus === "online" ? seen : `${oneLine(d.lastStatus)} · ${seen}`)}`;
|
|
243
243
|
} else {
|
|
244
244
|
const selected = row.sessionId === opts.currentSessionId;
|
|
245
245
|
const marker = selected ? c.accent("▌") : " ";
|
|
@@ -283,7 +283,7 @@ export function renderStatusbar(
|
|
|
283
283
|
: ["j/k move", "↵ open", "1-4 views", "⇥ tabs", "esc agent"];
|
|
284
284
|
// Catalog miss degrades to "?" (R5 finding 5): "—" read as "no usage yet",
|
|
285
285
|
// when it actually means the window is unknown — a different problem.
|
|
286
|
-
const right = `${c.muted("ctx")} ${opts.ctxLeft === undefined ? c.muted("?") : c.text(`${opts.ctxLeft}%`)}${opts.background ? c.muted(` · ${opts.background} bg`) : ""} ${c.muted("dev")} ${c.text(fit(
|
|
286
|
+
const right = `${c.muted("ctx")} ${opts.ctxLeft === undefined ? c.muted("?") : c.text(`${opts.ctxLeft}%`)}${opts.background ? c.muted(` · ${opts.background} bg`) : ""} ${c.muted("dev")} ${c.text(fit(oneLine(String(opts.device ?? "")), 18))}`;
|
|
287
287
|
const left = `${chip} ${keys.map((k) => c.muted(k)).join(c.muted(" • "))}`;
|
|
288
288
|
const gap = Math.max(1, w - visibleWidth(left) - visibleWidth(right));
|
|
289
289
|
return c.inverse(padTo(fit(`${left}${rep(" ", gap)}${right}`, w), w));
|
|
@@ -355,10 +355,10 @@ export function renderHerdPanel(
|
|
|
355
355
|
const onDefault = defaultModel !== undefined && s.model === defaultModel;
|
|
356
356
|
const lines = [
|
|
357
357
|
c.muted(" OVERVIEW"),
|
|
358
|
-
` ${c.bold(
|
|
359
|
-
` ${c.muted(
|
|
358
|
+
` ${c.bold(oneLine(String(s.name ?? "")))}`,
|
|
359
|
+
` ${c.muted(oneLine(String(basename(String(s.cwd ?? "")) ?? "")))} ${c.muted("·")} ${c.text(oneLine(String((basename(String(s.model ?? "")) || s.model) ?? "")))}${onDefault ? c.muted(" (default)") : ""}`,
|
|
360
360
|
git?.repo
|
|
361
|
-
? ` ${c.muted("⎇")} ${c.text(
|
|
361
|
+
? ` ${c.muted("⎇")} ${c.text(oneLine(String(git.branch ?? git.head ?? "?")))}${c.muted("±")}${c.text(String((Number(git.staged) || 0) + (Number(git.unstaged) || 0) + (Number(git.untracked) || 0)))}${Number(git.ahead) > 0 ? c.text(` ↑${Number(git.ahead)}`) : ""}${Number(git.behind) > 0 ? c.text(` ↓${Number(git.behind)}`) : ""}${git.worktreeOf ? c.muted(" · worktree") : ""}`
|
|
362
362
|
: "",
|
|
363
363
|
"",
|
|
364
364
|
` ${c.muted("state")} ${STATE_COLOR[sessionState(s)](sessionState(s))}`,
|
|
@@ -21,7 +21,7 @@ import type { App, DeviceRef } from "./app.ts";
|
|
|
21
21
|
import { Picker } from "./pickers.ts";
|
|
22
22
|
import { parsePairArgs, runPairing, type PairArgs } from "./pairing.ts";
|
|
23
23
|
import { c } from "./theme.ts";
|
|
24
|
-
import { sanitizeTerminal } from "./sanitize.ts";
|
|
24
|
+
import { oneLine, sanitizeTerminal } from "./sanitize.ts";
|
|
25
25
|
|
|
26
26
|
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
27
27
|
|
|
@@ -277,8 +277,11 @@ export class WelcomePicker extends Picker {
|
|
|
277
277
|
/** Open the welcome screen overlay. `notice` names an unreachable auto-connect. */
|
|
278
278
|
export function showWelcome(app: App, opts: { notice?: string } = {}) {
|
|
279
279
|
const devices = app.registry?.list() ?? [];
|
|
280
|
+
// run-8 U6: oneLine, not just sanitizeTerminal — a hostile device JSON
|
|
281
|
+
// error.message carries LFs, and truncateToWidth passes an embedded LF
|
|
282
|
+
// through inside ONE logical row (probe: forged row + cursor drift).
|
|
280
283
|
const subtitle = opts.notice
|
|
281
|
-
? c.err(
|
|
284
|
+
? c.err(oneLine(opts.notice))
|
|
282
285
|
: c.muted("This is the app — connect a device to get started:");
|
|
283
286
|
let picked = false; // an action was chosen: closing the overlay is a step, not a quit
|
|
284
287
|
app.overlay(
|
|
@@ -426,7 +429,7 @@ async function welcomeLocal(app: App) {
|
|
|
426
429
|
const id = suggestDeviceId(probe.info.hostname, probe.info.name);
|
|
427
430
|
stepPicker(
|
|
428
431
|
app,
|
|
429
|
-
`Local backend: ${
|
|
432
|
+
`Local backend: ${oneLine(probe.info.name || probe.info.hostname || url)}`,
|
|
430
433
|
[{ value: "open", label: `Save as "${id}" and open`, description: `${url} │ token from DPI_TOKEN / backend.env` }],
|
|
431
434
|
// local.token was read BEFORE a first boot may have written backend.env —
|
|
432
435
|
// re-resolve, the file exists now.
|
|
@@ -454,7 +457,9 @@ function welcomeSwitch(app: App) {
|
|
|
454
457
|
async function saveAndOpen(app: App, id: string, url: string, token: string, name?: string) {
|
|
455
458
|
if (!app.registry) return app.flash("No registry — start with --url/--token.", true);
|
|
456
459
|
try {
|
|
457
|
-
|
|
460
|
+
// run-8 U6: the device-supplied name is persisted for EVERY later render —
|
|
461
|
+
// collapse and bound it at the write boundary, not per render site.
|
|
462
|
+
app.registry.upsert({ id, name: oneLine(name || id).slice(0, 128) || id, url, kind: "url", source: "ui", token });
|
|
458
463
|
} catch (e) {
|
|
459
464
|
app.flash((e as Error).message, true);
|
|
460
465
|
return showWelcome(app);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.78",
|
|
4
4
|
"description": "Durable Pi — the durable agent network: hub web UI, device backend daemon, TUI admin and the shared SDK, packaged as one runnable monorepo install",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|