my-durable 0.0.72 → 0.0.73
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/README.md +2 -2
- package/apps/dpi-backend/API.md +1 -0
- package/apps/dpi-backend/src/backup.ts +18 -0
- package/apps/dpi-backend/src/routes.ts +10 -1
- package/apps/dpi-backend/src/store.ts +125 -1
- package/apps/dpi-backend/src/telegram.ts +99 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-BE-fN78Y.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-C9TcDwN6.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/components/NetworkSidebar.vue +43 -4
- package/apps/dpi-playground/apps/dpi-playground-hub/src/audit.ts +25 -11
- package/apps/dpi-playground/apps/dpi-playground-hub/src/monitor.ts +6 -2
- package/apps/dpi-playground/apps/dpi-playground-hub/src/mux.ts +6 -2
- package/apps/dpi-playground/apps/dpi-playground-hub/src/transport.ts +12 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-transport.ts +1 -1
- package/apps/dpi-sdk/src/api.ts +13 -1
- package/apps/dpi-sdk/src/client.ts +12 -5
- package/apps/dpi-sdk/src/node/config.ts +13 -2
- package/apps/dpi-sdk/src/node/drivers.ts +4 -0
- package/apps/dpi-tui/src/commands.ts +41 -1
- package/apps/dpi-tui/src/pairing.ts +2 -2
- package/apps/dpi-tui/src/views.ts +1 -1
- package/docs/host-project-checklist.md +1 -1
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CpNu1wqa.js +0 -81
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DSU1QhGO.css +0 -1
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<meta name="referrer" content="no-referrer" />
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="/icons/durable-pi.svg" />
|
|
9
9
|
<title>Durable Pi | Network</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-C9TcDwN6.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BE-fN78Y.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="app"></div>
|
|
@@ -46,7 +46,16 @@ const list = ref<HTMLElement>();
|
|
|
46
46
|
* own matches (names/cwds/models) so results do not depend on how fresh the
|
|
47
47
|
* hub's tree is. Transcripts are not scanned — that needs an FTS index. */
|
|
48
48
|
const query = ref("");
|
|
49
|
-
const deviceHits = ref<
|
|
49
|
+
const deviceHits = ref<
|
|
50
|
+
{
|
|
51
|
+
deviceId: string;
|
|
52
|
+
name: string;
|
|
53
|
+
cwd: string;
|
|
54
|
+
id: string;
|
|
55
|
+
where: string[];
|
|
56
|
+
hits: { agent: string; entry: number; kind: string; text: string }[];
|
|
57
|
+
}[]
|
|
58
|
+
>([]);
|
|
50
59
|
const searching = ref(false);
|
|
51
60
|
const needle = computed(() => query.value.trim().toLowerCase());
|
|
52
61
|
const filtering = computed(() => needle.value.length >= 2);
|
|
@@ -99,29 +108,42 @@ const extraHits = computed(() =>
|
|
|
99
108
|
);
|
|
100
109
|
|
|
101
110
|
let searchTimer: ReturnType<typeof setTimeout> | undefined;
|
|
111
|
+
let searchGeneration = 0;
|
|
102
112
|
watch(query, (value) => {
|
|
103
113
|
clearTimeout(searchTimer);
|
|
104
114
|
const q = value.trim();
|
|
105
115
|
if (q.length < 2) {
|
|
116
|
+
++searchGeneration; // an in-flight scan for the cleared query must not resurrect stale hits
|
|
106
117
|
deviceHits.value = [];
|
|
107
118
|
searching.value = false;
|
|
108
119
|
return;
|
|
109
120
|
}
|
|
110
121
|
searchTimer = setTimeout(async () => {
|
|
111
122
|
searching.value = true;
|
|
123
|
+
// R18 cold-review minor 4: scope=all scans take seconds per device — a
|
|
124
|
+
// generation token keeps a slower OLD query from overwriting a newer one.
|
|
125
|
+
const generation = ++searchGeneration;
|
|
112
126
|
const found: typeof deviceHits.value = [];
|
|
113
127
|
for (const device of network.devices.value.filter((d) => d.status === "online")) {
|
|
114
128
|
const result = await deviceClient(device.id)
|
|
115
|
-
.searchSessions(q)
|
|
129
|
+
.searchSessions(q, "all")
|
|
116
130
|
.catch(() => undefined);
|
|
131
|
+
if (generation !== searchGeneration) return; // a newer query superseded this scan
|
|
117
132
|
for (const match of result?.matches ?? [])
|
|
118
|
-
found.push({
|
|
133
|
+
found.push({
|
|
134
|
+
deviceId: device.id,
|
|
135
|
+
id: match.id,
|
|
136
|
+
name: match.name,
|
|
137
|
+
cwd: match.cwd,
|
|
138
|
+
where: match.where,
|
|
139
|
+
hits: match.hits ?? [],
|
|
140
|
+
});
|
|
119
141
|
}
|
|
120
142
|
deviceHits.value = found;
|
|
121
143
|
searching.value = false;
|
|
122
144
|
}, 250);
|
|
123
145
|
});
|
|
124
|
-
const clearSearch = () => ((query.value = ""), (deviceHits.value = []));
|
|
146
|
+
const clearSearch = () => ((query.value = ""), ++searchGeneration, (deviceHits.value = []));
|
|
125
147
|
|
|
126
148
|
/** Bulk session manage (orca ManageSessionsSection): select many, then
|
|
127
149
|
* archive/abort each with a per-row result. Client-side loop over the
|
|
@@ -387,6 +409,13 @@ function keydown(e: KeyboardEvent) {
|
|
|
387
409
|
<span class="hit-name">{{ hit.name }}</span>
|
|
388
410
|
<code class="hit-cwd">{{ hit.cwd }}</code>
|
|
389
411
|
<em v-if="hit.where.length" class="hit-where">{{ hit.where.join(" · ") }}</em>
|
|
412
|
+
<em
|
|
413
|
+
v-if="hit.hits.length"
|
|
414
|
+
class="hit-line"
|
|
415
|
+
:title="hit.hits.map((h) => `${h.agent} #${h.entry}: ${h.text}`).join('\n')"
|
|
416
|
+
>
|
|
417
|
+
{{ hit.hits[0].agent }} #{{ hit.hits[0].entry }} · {{ hit.hits[0].text.slice(0, 90) }}
|
|
418
|
+
</em>
|
|
390
419
|
</button>
|
|
391
420
|
</template>
|
|
392
421
|
<p v-if="filtering && !localRows.length && !extraHits.length" class="hint tree-empty">
|
|
@@ -446,6 +475,16 @@ function keydown(e: KeyboardEvent) {
|
|
|
446
475
|
.search-input::-webkit-search-cancel-button { display: none; }
|
|
447
476
|
.tree-search .clear { padding: 2px; }
|
|
448
477
|
.searching { opacity: 0.6; font-size: 13px; }
|
|
478
|
+
.hit-line {
|
|
479
|
+
display: block;
|
|
480
|
+
font-style: normal;
|
|
481
|
+
font-size: 12px;
|
|
482
|
+
opacity: 0.75;
|
|
483
|
+
white-space: nowrap;
|
|
484
|
+
overflow: hidden;
|
|
485
|
+
text-overflow: ellipsis;
|
|
486
|
+
max-width: 100%;
|
|
487
|
+
}
|
|
449
488
|
.hit-head { margin: 6px 2px 2px; }
|
|
450
489
|
.hit {
|
|
451
490
|
display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
|
|
@@ -109,20 +109,34 @@ export function scrubSecrets(value: string): string {
|
|
|
109
109
|
// capability token in audit path samples — the token IS the secret. The
|
|
110
110
|
// prefix spelling is ATTACKER-CONTROLLED (/share/, /api/shares/, /Share/,
|
|
111
111
|
// /%73hare/...), so anchor on a *share-shaped* path segment (case-blind,
|
|
112
|
-
// percent-encoding tolerated) followed by the
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
// percent-encoding tolerated) followed by the token run — not on any one
|
|
113
|
+
// literal prefix. Bare token-shaped values elsewhere (audit enums like
|
|
114
|
+
// "foreign_subscription") stay readable.
|
|
115
|
+
// R18 (run-4 h6): three deliberate spellings still escaped — a non-token
|
|
116
|
+
// separator byte wedged between segment and token ('/api/shares/.<tok>'),
|
|
117
|
+
// a padded run longer than 32 chars, and percent-encoded spellings the
|
|
118
|
+
// literal pass cannot see. Tolerate 0-2 separator bytes, drop the upper
|
|
119
|
+
// bound, and re-run both rules on a percent-decoded copy.
|
|
120
|
+
// Cold-review minor 1: a decoded `/api/shares/<word>%2F<token>` leaves the
|
|
121
|
+
// token behind a short extra path segment — tolerate one such segment AND
|
|
122
|
+
// keep the direct 0–2 non-token separator (run-4 h6) before the run.
|
|
123
|
+
const shareShaped =
|
|
124
|
+
/(\/[a-z0-9%]*shares?\/)(?:[^\s"']{0,8}\/)?[^\w\n]{0,2}[A-Za-z0-9_-]{20,}(?![A-Za-z0-9_-])/gi;
|
|
119
125
|
// Encoded spellings (/%73hare/) hide the literal "share" — any
|
|
120
126
|
// percent-bearing path segment followed by a token-shaped run is treated
|
|
121
127
|
// the same.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
const percentBearing = /(\/[^\s"']*%[^\s"']*\/)[A-Za-z0-9_-]{20,}(?![A-Za-z0-9_-])/gi;
|
|
129
|
+
const scrubTokens = (s: string): string => s.replace(shareShaped, "$1<redacted>").replace(percentBearing, "$1<redacted>");
|
|
130
|
+
out = scrubTokens(out);
|
|
131
|
+
// The decoded pass sees through %XX spellings of the separator, the first
|
|
132
|
+
// token characters, or the segment itself; the sample is bounded (≤200
|
|
133
|
+
// chars) so a pathological decode cannot explode it.
|
|
134
|
+
try {
|
|
135
|
+
const decoded = decodeURIComponent(out);
|
|
136
|
+
if (decoded !== out) out = scrubTokens(decoded);
|
|
137
|
+
} catch {
|
|
138
|
+
// malformed percent escapes stay as the literal pass left them
|
|
139
|
+
}
|
|
126
140
|
// Credential material without its prefix (slices, echo): 43-char base64url runs.
|
|
127
141
|
out = out.replace(/(?<![A-Za-z0-9_-])[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g, "<redacted>");
|
|
128
142
|
// Pairing codes as standalone values ("code":"AB2C7DEF" / "ABCD2345EF67") but not ordinary words.
|
|
@@ -25,8 +25,12 @@ export interface LiveState {
|
|
|
25
25
|
const sleep = (ms: number, signal: AbortSignal) =>
|
|
26
26
|
new Promise<void>((resolve) => {
|
|
27
27
|
if (signal.aborted) return resolve();
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// R18 (run-4 h5): remove the abort listener on the timer path too — a
|
|
29
|
+
// completed sleep used to leave one listener on the long-lived signal,
|
|
30
|
+
// and a flapping device retained closures without bound.
|
|
31
|
+
const onAbort = () => (clearTimeout(timer), resolve());
|
|
32
|
+
const timer = setTimeout(() => (signal.removeEventListener("abort", onAbort), resolve()), ms);
|
|
33
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
export interface TunnelTransportSource {
|
|
@@ -85,8 +85,12 @@ export function parseSubKey(key: string) {
|
|
|
85
85
|
const sleep = (ms: number, signal: AbortSignal) =>
|
|
86
86
|
new Promise<void>((resolve) => {
|
|
87
87
|
if (signal.aborted) return resolve();
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
// R18 (run-4 h5): remove the abort listener on the timer path too — a
|
|
89
|
+
// completed sleep used to leave one listener on the long-lived signal,
|
|
90
|
+
// and a flapping device retained closures without bound.
|
|
91
|
+
const onAbort = () => (clearTimeout(timer), resolve());
|
|
92
|
+
const timer = setTimeout(() => (signal.removeEventListener("abort", onAbort), resolve()), ms);
|
|
93
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
90
94
|
});
|
|
91
95
|
|
|
92
96
|
export class StreamMux {
|
|
@@ -108,11 +108,23 @@ export class LanTransport implements DeviceTransport {
|
|
|
108
108
|
},
|
|
109
109
|
body: hasBody && input.body !== undefined ? JSON.stringify(input.body) : undefined,
|
|
110
110
|
signal: effective,
|
|
111
|
+
// R18 (run-4 h5): the device-side connector refuses redirects (one
|
|
112
|
+
// exact origin); a compromised LAN peer must not aim the hub's fetches
|
|
113
|
+
// elsewhere. 3xx → clean 502, same as the connector.
|
|
114
|
+
redirect: "manual",
|
|
111
115
|
});
|
|
112
116
|
} catch (cause) {
|
|
113
117
|
if (signal?.aborted) throw cause;
|
|
114
118
|
throw new DpiError("offline", `Cannot reach ${this.client.baseUrl}`, 0, { cause });
|
|
115
119
|
}
|
|
120
|
+
if (response.status >= 300 && response.status < 400) {
|
|
121
|
+
await response.body?.cancel().catch(() => undefined);
|
|
122
|
+
throw new DpiError(
|
|
123
|
+
"offline",
|
|
124
|
+
`Device API answered with a redirect (${response.status}); redirects are not followed`,
|
|
125
|
+
502,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
116
128
|
// R17 (run-3 h8): size parity with the tunnel leg — the device connector
|
|
117
129
|
// caps its own fetches (16 MiB textual / binary cap) and reassembly
|
|
118
130
|
// budgets bound the tunnel; this leg used to buffer arrayBuffer() with NO
|
|
@@ -558,7 +558,7 @@ export class TunnelDispatcher {
|
|
|
558
558
|
// connection swap. The prefix marks hub-derived keys in device logs; 73 chars fits the
|
|
559
559
|
// device's 128-char header cap and the wire schema's 256.
|
|
560
560
|
const idempotencyKey =
|
|
561
|
-
input.idempotencyKey
|
|
561
|
+
input.idempotencyKey ||
|
|
562
562
|
(input.method === "GET" || input.method === "HEAD"
|
|
563
563
|
? undefined
|
|
564
564
|
: "dpi-auto-" +
|
package/apps/dpi-sdk/src/api.ts
CHANGED
|
@@ -473,6 +473,14 @@ export interface DeviceVitals {
|
|
|
473
473
|
counts?: { sessions: number; archived: number };
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
+
/** One transcript hit inside a session search match (scope=all): which agent, which entry, what it says. */
|
|
477
|
+
export interface TranscriptSearchHit {
|
|
478
|
+
agent: string;
|
|
479
|
+
entry: number;
|
|
480
|
+
kind: string;
|
|
481
|
+
text: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
476
484
|
/** One session-search hit: the summary fields plus which of them matched. */
|
|
477
485
|
export interface SessionSearchMatch {
|
|
478
486
|
id: string;
|
|
@@ -482,12 +490,16 @@ export interface SessionSearchMatch {
|
|
|
482
490
|
createdAt: number;
|
|
483
491
|
dbPath: string;
|
|
484
492
|
compaction?: CompactionSettings;
|
|
485
|
-
where: Array<"name" | "cwd" | "model">;
|
|
493
|
+
where: Array<"name" | "cwd" | "model" | "transcript">;
|
|
494
|
+
/** Present when scope=all found transcript text (up to a few per session, newest first). */
|
|
495
|
+
hits?: TranscriptSearchHit[];
|
|
486
496
|
}
|
|
487
497
|
|
|
488
498
|
export interface SessionSearchResult {
|
|
489
499
|
query: string;
|
|
490
500
|
matches: SessionSearchMatch[];
|
|
501
|
+
/** Present on scope=all: what the transcript scan covered before its budget ran out. */
|
|
502
|
+
scanned?: { sessions: number; entries: number; truncated: boolean };
|
|
491
503
|
}
|
|
492
504
|
|
|
493
505
|
export interface DeviceTree {
|
|
@@ -342,9 +342,12 @@ export class DpiClient {
|
|
|
342
342
|
deviceUsage() {
|
|
343
343
|
return this.request<DeviceUsageReport>("GET", "/v1/device/usage");
|
|
344
344
|
}
|
|
345
|
-
/** Session search over names/cwds/models
|
|
346
|
-
searchSessions(query: string) {
|
|
347
|
-
return this.request<SessionSearchResult>(
|
|
345
|
+
/** Session search over names/cwds/models; scope="all" adds the bounded transcript scan (R18). */
|
|
346
|
+
searchSessions(query: string, scope?: "meta" | "all") {
|
|
347
|
+
return this.request<SessionSearchResult>(
|
|
348
|
+
"GET",
|
|
349
|
+
`/v1/sessions/search?q=${enc(query)}${scope === "all" ? "&scope=all" : ""}`,
|
|
350
|
+
);
|
|
348
351
|
}
|
|
349
352
|
dirs(path = "") {
|
|
350
353
|
return this.request<DirListing>("GET", `/v1/fs/dirs?path=${enc(path)}`);
|
|
@@ -614,8 +617,12 @@ export type ConnectionState = "connecting" | "live" | "offline" | "unauthorized"
|
|
|
614
617
|
const sleep = (ms: number, signal: AbortSignal) =>
|
|
615
618
|
new Promise<void>((resolve) => {
|
|
616
619
|
if (signal.aborted) return resolve();
|
|
617
|
-
|
|
618
|
-
|
|
620
|
+
// R18 (run-4 h5): remove the abort listener on the timer path too — a
|
|
621
|
+
// completed sleep used to leave one listener on the long-lived signal,
|
|
622
|
+
// and a flapping device retained closures without bound.
|
|
623
|
+
const onAbort = () => (clearTimeout(timer), resolve());
|
|
624
|
+
const timer = setTimeout(() => (signal.removeEventListener("abort", onAbort), resolve()), ms);
|
|
625
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
619
626
|
});
|
|
620
627
|
|
|
621
628
|
/**
|
|
@@ -118,7 +118,16 @@ export function parseNetworkConfig(text: string, file = NETWORK_FILE): NetworkCo
|
|
|
118
118
|
node: Number(d.node ?? 24),
|
|
119
119
|
codeDir: pathish(typeof d.code_dir === "string" ? d.code_dir : "~/dpi", "code_dir"),
|
|
120
120
|
homeDir: pathish(typeof d.home_dir === "string" ? d.home_dir : "~/.dpi", "home_dir"),
|
|
121
|
-
|
|
121
|
+
// R18 (run-4 h7): ':' is the DPI_START_DIRS list separator on the device
|
|
122
|
+
// (config.ts splits on it) — an entry containing ':' would smuggle an
|
|
123
|
+
// EXTRA containment root past the operator's declared list.
|
|
124
|
+
startDirs:
|
|
125
|
+
d.start_dirs === undefined
|
|
126
|
+
? [DEFAULT_START_DIR]
|
|
127
|
+
: strList(d.start_dirs, `${where}.start_dirs`).map((r: string) => {
|
|
128
|
+
if (r.includes(":")) throw Error(`${where}.start_dirs must not contain ':' (the DPI_START_DIRS separator)`);
|
|
129
|
+
return pathish(r, "start_dirs");
|
|
130
|
+
}),
|
|
122
131
|
host: d.host === undefined ? (kind === "local" ? "127.0.0.1" : "0.0.0.0") : pathish(str(d.host, `${where}.host`), "host"),
|
|
123
132
|
envKeys: d.env_keys === undefined ? [] : strList(d.env_keys, `${where}.env_keys`),
|
|
124
133
|
env: {},
|
|
@@ -134,7 +143,9 @@ export function parseNetworkConfig(text: string, file = NETWORK_FILE): NetworkCo
|
|
|
134
143
|
// R17 (run-3 h12): the ssh scalar is a leading argv element — a leading
|
|
135
144
|
// dash would be parsed as an ssh OPTION (e.g. -oProxyCommand=…). Accept
|
|
136
145
|
// only a user@host[:port] shape.
|
|
137
|
-
|
|
146
|
+
// R18 (run-4 h7): the user part may not START with a dash either —
|
|
147
|
+
// `-Jjump@evil` is an attached-value ssh option (ProxyJump), not a user.
|
|
148
|
+
if (!/^[A-Za-z0-9._%][A-Za-z0-9._%-]*@[A-Za-z0-9.-]+(:\d+)?$/.test(target))
|
|
138
149
|
throw Error(`${where}.ssh must be user@host[:port] (no options, no metacharacters)`);
|
|
139
150
|
device.ssh = target;
|
|
140
151
|
}
|
|
@@ -115,6 +115,10 @@ async function writeEnv(device: NetDevice, ctx: DriverContext, rotate = false) {
|
|
|
115
115
|
ctx.log(`warning: device ${device.id} env ${k} has no value or contains a newline — skipped`);
|
|
116
116
|
// R17 (run-3 h12): config.ts rejects CR/LF in these at parse; the sink
|
|
117
117
|
// guards too so a future field can never reintroduce the line-injection.
|
|
118
|
+
// R18 (run-4 h7): ':' in a start_dirs entry splits into an EXTRA containment
|
|
119
|
+
// root on the device — refuse at the sink as well.
|
|
120
|
+
if (device.startDirs.some((r) => r.includes(":")))
|
|
121
|
+
throw Error(`device ${device.id}: start_dirs must not contain ':' (the DPI_START_DIRS separator)`);
|
|
118
122
|
for (const [k, v] of [["DPI_HOST", device.host], ["DPI_START_DIRS", device.startDirs.join(":")]] as const)
|
|
119
123
|
if (/[\n\r]/.test(v))
|
|
120
124
|
throw Error(`device ${device.id}: ${k} value contains a newline — refusing to write backend.env`);
|
|
@@ -27,6 +27,7 @@ export const COMMANDS: SlashCommand[] = [
|
|
|
27
27
|
{ name: "reset", description: "start a fresh context", argumentHint: "[handoff note]" },
|
|
28
28
|
{ name: "name", description: "rename this agent", argumentHint: "<name>" },
|
|
29
29
|
{ name: "tasks", description: "live tasks in this session" },
|
|
30
|
+
{ name: "find", description: "search every session's transcript on this device", argumentHint: "<text>" },
|
|
30
31
|
{ name: "pair", description: "pair THIS device with a hub", argumentHint: "<CODE|PAIR_URL> [--hub ORIGIN] [--force]" },
|
|
31
32
|
{
|
|
32
33
|
name: "git",
|
|
@@ -206,7 +207,10 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
|
|
|
206
207
|
let value = arg;
|
|
207
208
|
if (!value) {
|
|
208
209
|
const current = app.sessionSummary()?.agents.find((a) => a.id === app.agentId)?.name ?? "";
|
|
209
|
-
|
|
210
|
+
// Agent names ride the wire from device/hub (model-choosable for forks
|
|
211
|
+
// and subagents) and pi-tui's Input renders its value verbatim — seed
|
|
212
|
+
// it sanitized (run-4 h4).
|
|
213
|
+
const typed = await app.prompt("Agent name", current && current !== "main" ? sanitizeTerminal(current) : "");
|
|
210
214
|
value = (typed ?? "").trim();
|
|
211
215
|
if (!value) return app.flash("rename cancelled"), true;
|
|
212
216
|
}
|
|
@@ -223,6 +227,42 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
|
|
|
223
227
|
case "pair":
|
|
224
228
|
await runPairing(app, parsePairArgs(arg));
|
|
225
229
|
break;
|
|
230
|
+
case "find": {
|
|
231
|
+
// R18: transcript search across every session on the device. Transcript
|
|
232
|
+
// text is untrusted — every interpolation below goes through
|
|
233
|
+
// sanitizeTerminal before it reaches chrome (run-3 h5 discipline).
|
|
234
|
+
if (!arg) return app.flash("usage: /find <text> — searches every session's transcript", true), true;
|
|
235
|
+
await app.run(async () => {
|
|
236
|
+
const result = await app.client.searchSessions(arg, "all");
|
|
237
|
+
const shown = result.matches.slice(0, 12);
|
|
238
|
+
app.overlay(
|
|
239
|
+
new Panel(() => {
|
|
240
|
+
const lines = [
|
|
241
|
+
c.bold(c.accent(`"${sanitizeTerminal(arg)}" — ${result.matches.length} session${result.matches.length === 1 ? "" : "s"}`)),
|
|
242
|
+
"",
|
|
243
|
+
];
|
|
244
|
+
if (!result.matches.length) lines.push(c.muted("No matches (names, folders, models or transcripts)."));
|
|
245
|
+
for (const m of shown) {
|
|
246
|
+
lines.push(
|
|
247
|
+
`${c.secondary(sanitizeTerminal(m.name))} ${c.muted(sanitizeTerminal(m.cwd))}${m.where.includes("transcript") ? " " + c.warn("◍ transcript") : ""}`,
|
|
248
|
+
);
|
|
249
|
+
for (const hit of (m.hits ?? []).slice(0, 3))
|
|
250
|
+
lines.push(
|
|
251
|
+
c.muted(
|
|
252
|
+
` ${sanitizeTerminal(m.name)}:${sanitizeTerminal(hit.agent)} #${hit.entry} — ${sanitizeTerminal(hit.text.slice(0, 140))}`,
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
if (result.matches.length > shown.length) lines.push(c.muted(`… ${result.matches.length - shown.length} more`));
|
|
257
|
+
if (result.scanned?.truncated)
|
|
258
|
+
lines.push(c.muted(`scan budget reached (${result.scanned.entries} entries) — refine the query`));
|
|
259
|
+
lines.push("", c.muted("esc close"));
|
|
260
|
+
return lines;
|
|
261
|
+
}, () => app.closeOverlay()),
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
226
266
|
case "tasks":
|
|
227
267
|
app.overlay(
|
|
228
268
|
new Panel(() => {
|
|
@@ -175,9 +175,9 @@ export function pairingViewLines(
|
|
|
175
175
|
} else if (status.state === "revoked") {
|
|
176
176
|
lines.push(c.warn("Revoked on the hub. /pair CODE to pair again."));
|
|
177
177
|
} else {
|
|
178
|
-
lines.push(c.muted(note));
|
|
178
|
+
lines.push(c.muted(sanitizeTerminal(note)));
|
|
179
179
|
}
|
|
180
|
-
if (note && status.state !== "pairing") lines.push(c.muted(note));
|
|
180
|
+
if (note && status.state !== "pairing") lines.push(c.muted(sanitizeTerminal(note)));
|
|
181
181
|
return lines.flatMap((line) => wrapTextWithAnsi(line, Math.max(1, width)));
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -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 : `${d.lastStatus} · ${seen}`)}`;
|
|
242
|
+
`${c.muted(d.transport === "tunnel" ? "tunnel" : "lan")} ${c.muted(d.lastStatus === "online" ? seen : `${sanitizeTerminal(d.lastStatus)} · ${seen}`)}`;
|
|
243
243
|
} else {
|
|
244
244
|
const selected = row.sessionId === opts.currentSessionId;
|
|
245
245
|
const marker = selected ? c.accent("▌") : " ";
|
|
@@ -133,7 +133,7 @@ All four are DECIDED (0.0.46, user-approved):
|
|
|
133
133
|
|---|---|---|---|---|
|
|
134
134
|
| MUST | Device vitals endpoint + card | herdr `shared/types.ts:19` (`Device.uptime`, `since`); piggery `top` (`docs/reference.md:22`) | ✅ (`0.0.38`) | GET `/device/vitals` (`vitals.ts`: uptime, loadavg, memory, statfs free, counts) + Inspector **Host** tab (`HostPanel.vue`). On demand only — verified 0 requests until the tab opens |
|
|
135
135
|
| MUST | `dpi doctor` | piggery `check`/`doctor` (`docs/reference.md:33-34`) | ✅ (`0.0.38`) | `dpi doctor [--json] [--quiet]` (`doctor.ts`): node ≥ 22.19, healthz, start-dir writability, default-model probe, hub reachability; exit 1 only on FAIL, probe/hub are WARN |
|
|
136
|
-
| SHOULD | Session search (device-side first) | paseo `packages/server/src/server/agent-history-search.ts` | ✅ (`0.0.38`) | GET `/sessions/search?q=` matches names/cwd/models (
|
|
136
|
+
| SHOULD | Session search (device-side first) | paseo `packages/server/src/server/agent-history-search.ts` | ✅ (`0.0.38` metadata; `0.0.73` transcripts) | GET `/sessions/search?q=` matches names/cwd/models; `&scope=all` adds a bounded read-only transcript walk (100 sessions / 4k entries per agent / 50k entries total, newest first — one broken session is skipped). FTS stays the upgrade path for large fleets: the transcript DBs are engine-owned (vendored pi-durable), so no FTS tables of our own without an engine change. FE: instant local filter + debounced device call merged as "more on device" (now with transcript hit previews); TUI: `/find` |
|
|
137
137
|
| SHOULD | Session export bundle | paseo `packages/server/src/server/exports.ts` | ✅ (`0.0.38`) | GET `/sessions/:s/export` → base64 zip (`zip.ts`, zero-dep writer): manifest + session record + per-agent transcript.json/.md + config.json. Import still later |
|
|
138
138
|
|
|
139
139
|
## Wave 2 — medium
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
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": {
|