shadok-ai 0.20.59 → 0.20.61

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 CHANGED
@@ -1151,6 +1151,37 @@ conversation, the same trust the site already has over what they type there.
1151
1151
  Needs the multi-tenant deployment (External groups do), and HTTPS on the sites
1152
1152
  that embed it.
1153
1153
 
1154
+ ### First-run script (optional): prepare a guest's account before its agent starts
1155
+
1156
+ An **External** group can carry a shell script that runs once for each new
1157
+ conversation — a new WhatsApp number, Telegram user or site visitor — before
1158
+ that person's agent is started. Use it for whatever the agent should find in
1159
+ place: a folder layout, a file fetched from another service, an account
1160
+ reserved for this person. The agent's first turn is then only its answer.
1161
+
1162
+ Write it in the External group's settings (*First-run script*). It runs with
1163
+ `sh`, as that conversation's own Unix user, in its own folder, with the secrets
1164
+ of the door's profile, and it is given:
1165
+
1166
+ | Variable | Value |
1167
+ |---|---|
1168
+ | `SHADOK_GUEST_KEY` | the conversation: `wa-<number>`, `tg-<id>`, `web-<visitor>` |
1169
+ | `SHADOK_GUEST_DOOR` | `whatsapp`, `telegram`, `widget`, or `agent` |
1170
+ | `SHADOK_GUEST_DIR` | the conversation's folder (also the working directory) |
1171
+ | `SHADOK_GROUP_ID` | the group |
1172
+
1173
+ - The person's first message waits for it: 60 seconds at most.
1174
+ - **A non-zero exit or a timeout means no agent is started.** The account is
1175
+ erased, the person is asked to write again, and the script runs again at
1176
+ their next message. The panel shows the last run and why it failed; the
1177
+ server log has a `guests: first-run script FAILED` line.
1178
+ - It applies to **new** conversations only. People already talking when you
1179
+ add or change the script are not affected.
1180
+ - An agent you start yourself in the group runs it too (door `agent`) — the
1181
+ way to try a script without a phone.
1182
+ - What the script reserves in another service is not released when the
1183
+ conversation is erased.
1184
+
1154
1185
  ### Running in Docker
1155
1186
 
1156
1187
  > Putting one instance online for someone else, on its own machine, behind a
@@ -2021,8 +2052,8 @@ client, or immediately on an explicit `stop` (which ends it for everyone).
2021
2052
  | `{type:"term-data", data}` | **experimental** — raw pane output (base64) for a client-side terminal emulator |
2022
2053
  | `{type:"gone"}` / `{type:"error", message, code?}` / `{type:"exited", code}` / `{type:"stopped"}` | session lost, errors, termination. `error.code` is `"busy"` for a prompt refused mid-turn and `"logged-out"` for a spawn refused because the instance isn't signed in, `"resume-refused"` for a `resume` whose shortened id matches no agent or several, `"unresponsive"` for a prompt that could not be delivered because the agent's terminal stopped taking input and the automatic restart did not recover it, `"turn-timeout"` for a turn whose screen kept changing for 15 min without any sign of work (a real hang — a turn that is merely long is waited on for as long as it shows work) — so a machine client needn't match on the message text |
2023
2054
 
2024
- HTTP endpoints (same auth): `/usage`, `/live`, `/sessions`, `/recover`,
2025
- `/diff`, `/channels` (its GET adds a **derived** `crons` field, and `closes` — how many schedules and webhooks closing that agent would delete — never stored),
2055
+ HTTP endpoints (same auth): `/usage`, `/live` (each row names its `group`), `/sessions`, `/recover`,
2056
+ `/diff`, `/agents/:id/transcript` (GET — the raw `.jsonl`, or `?format=turns`) and `/agents/:id/files` (GET `?path=` a tar of that path, `&list=1` a listing; PUT a tar to seed it, dates kept) — for the agent's CREATOR only among machine callers (the peer that created it, or its parent agent; a person keeps the usual group rule), run as the agent's own Unix user (`pilotctl transcript` / `pilotctl files`), `/channels` (its GET adds a **derived** `crons` field, and `closes` — how many schedules and webhooks closing that agent would delete — never stored),
2026
2057
  `/channels/glance` (GET — each visible row's last-message time and context %,
2027
2058
  read from the transcript's tail so the list fills before the agents resume),
2028
2059
  `/channel` (DELETE), `/groups`, `/groups/ssh` (GET — the SSH **public** key to
@@ -28,6 +28,8 @@ and automatically starts the shadok-ai server when it is not running (port
28
28
  | `freetext <id> <n> "text"` | the "Type something" option: a free answer |
29
29
  | `list [--cwd DIR]` | driven agents (local state + alive/dead) and resumable sessions. With `--peer X`: the agents running ON X (from X itself, tagged `peer`), plus X's resumable sessions only for a `--cwd` you name — a path on X |
30
30
  | `diff <id>` | the agent's changes (git status + diff against the worktree's base) |
31
+ | `transcript <id> [--turns] [--out FILE]` | the FULL transcript of an agent **you created** (your child, or one your instance spawned over `--peer`): every `.jsonl` line, tool calls and results included — or `--turns`, the chat as the cockpit shows it. Anyone else's agent is refused, even one you can see |
32
+ | `files ls <id> [path]` · `files get <id> [path] [--out DIR]` · `files put <id> <local> [--to path]` | the working folder of an agent **you created**: list it, copy it here, or SEED it before its first prompt (`<local>` is a file or a folder, its contents land in the agent's folder or in `--to`). Dates are kept both ways, so `touch -d "10 days ago"` on a seed makes a ten-day-old case. Paths are relative to the agent's folder (`..` refused); everything runs as the agent's own Unix user |
31
33
  | `stop <id> [--force]` | ends the session (for ALL its clients), whether it is running or dormant — sent by id, nothing is resumed — and answers `stopped:true` only once the server confirms. Works over `--peer` with no local state (a restricted peer may close only what it spawned). A local agent this pilotctl never drove needs `--force` |
32
34
  | `reap [--idle 30m] [--dry-run]` | closes every finished agent you spawned: not busy, nobody watching, idle for `--idle` (default 30m). Over a restricted `--peer` that is every agent the peer lists for you (its own, dormant ones included); anywhere else only the ids in your local state. Use it to clear a backlog |
33
35
  | `set-parent <id> <parent-id\|none>` | re-link an agent to a parent, or **detach** it with `none` (it then reports to nobody). The link is what makes the parent hear when the agent finishes, blocks or dies — set automatically at spawn, flipped here when a side task is done and you want it off a lead's back |
@@ -149,10 +149,11 @@ export function parseArgs(argv) {
149
149
  const pos = [];
150
150
  for (let i = 0; i < rest.length; i++) {
151
151
  const a = rest[i];
152
- if (a === "--worktree" || a === "--continue" || a === "--readonly" || a === "--force" || a === "--dry-run") flags[a.slice(2)] = true;
152
+ if (a === "--worktree" || a === "--continue" || a === "--readonly" || a === "--force" || a === "--dry-run" || a === "--turns") flags[a.slice(2)] = true;
153
153
  else if (
154
154
  a === "--cwd" || a === "--resume" || a === "--timeout" || a === "--profile" || a === "--parent" ||
155
- a === "--name" || a === "--peer" || a === "--peer-url" || a === "--peer-token" || a === "--idle" || a === "--group"
155
+ a === "--name" || a === "--peer" || a === "--peer-url" || a === "--peer-token" || a === "--idle" || a === "--group" ||
156
+ a === "--out" || a === "--to"
156
157
  ) flags[a.slice(2)] = rest[++i];
157
158
  // Repeatable: a Skill Factory skill the new agent is born with, `name` or `name@N`.
158
159
  else if (a === "--skill") (flags.skill ||= []).push(rest[++i]);
@@ -509,6 +510,97 @@ async function cmdList(flags) {
509
510
  return { agents, resumable };
510
511
  }
511
512
 
513
+ /**
514
+ * The URL of one of an agent's creator routes (`/agents/<id>/…`). Pure, so the
515
+ * encoding is tested without a server.
516
+ */
517
+ export function agentRouteUrl(base, id, route, query = {}) {
518
+ if (!id) throw new Error(`usage: pilotctl ${route === "transcript" ? "transcript <id>" : "files <ls|get|put> <id>"}`);
519
+ const q = new URLSearchParams(Object.entries(query).filter(([, v]) => v !== undefined && v !== null && v !== ""));
520
+ const qs = q.toString();
521
+ return `${base}/agents/${encodeURIComponent(id)}/${route}${qs ? `?${qs}` : ""}`;
522
+ }
523
+
524
+ async function failOf(r) {
525
+ let msg = `HTTP ${r.status}`;
526
+ try {
527
+ const j = await r.json();
528
+ if (j?.error) msg = `${j.error} (HTTP ${r.status})`;
529
+ } catch {}
530
+ return new Error(msg);
531
+ }
532
+
533
+ /**
534
+ * The full transcript of an agent YOU created (the server checks): every line
535
+ * of its `.jsonl` — tool calls and results included — or, with `--turns`, the
536
+ * chat as the cockpit replays it. `--out FILE` writes it there instead of
537
+ * printing it.
538
+ */
539
+ async function cmdTranscript(id, flags) {
540
+ await ensureServer();
541
+ const r = await fetch(agentRouteUrl(httpBase(), id, "transcript", { format: flags.turns ? "turns" : undefined }), {
542
+ headers: authHeaders(),
543
+ });
544
+ if (!r.ok) throw await failOf(r);
545
+ const text = await r.text();
546
+ if (flags.out) {
547
+ fs.writeFileSync(flags.out, text);
548
+ return { sessionId: id, out: path.resolve(flags.out), bytes: Buffer.byteLength(text) };
549
+ }
550
+ if (flags.turns) return { sessionId: id, turns: JSON.parse(text) };
551
+ const entries = text.split("\n").filter(Boolean).map((l) => {
552
+ try {
553
+ return JSON.parse(l);
554
+ } catch {
555
+ return { unparsed: l };
556
+ }
557
+ });
558
+ return { sessionId: id, entries };
559
+ }
560
+
561
+ /**
562
+ * The working folder of an agent YOU created:
563
+ * files ls <id> [path] what is there (type, size, mtime)
564
+ * files get <id> [path] [--out DIR] copy it here (a tar, extracted into DIR)
565
+ * files put <id> <local> [--to path] seed it: <local> (a file or a folder)
566
+ * lands inside the agent's folder, dates kept
567
+ * Paths on the agent's side are relative to its folder. Dates survive both ways,
568
+ * so a seed made with `touch -d "10 days ago"` really is ten days old there.
569
+ */
570
+ async function cmdFiles(sub, id, arg, flags) {
571
+ await ensureServer();
572
+ if (sub === "ls") {
573
+ const r = await fetch(agentRouteUrl(httpBase(), id, "files", { path: arg, list: "1" }), { headers: authHeaders() });
574
+ if (!r.ok) throw await failOf(r);
575
+ return r.json();
576
+ }
577
+ if (sub === "get") {
578
+ const r = await fetch(agentRouteUrl(httpBase(), id, "files", { path: arg }), { headers: authHeaders() });
579
+ if (!r.ok) throw await failOf(r);
580
+ const out = path.resolve(flags.out || ".");
581
+ fs.mkdirSync(out, { recursive: true });
582
+ const tarball = Buffer.from(await r.arrayBuffer());
583
+ execFileSync("tar", ["-x", "-f", "-", "--no-same-owner", "-C", out], { input: tarball, stdio: ["pipe", "ignore", "pipe"] });
584
+ return { sessionId: id, out, bytes: tarball.length };
585
+ }
586
+ if (sub === "put") {
587
+ if (!arg) throw new Error("usage: pilotctl files put <id> <local file or folder> [--to path]");
588
+ const local = path.resolve(arg);
589
+ const st = fs.statSync(local);
590
+ // A folder's CONTENTS land in the target; a file lands as itself.
591
+ const tarArgs = st.isDirectory() ? ["-c", "-f", "-", "-C", local, "."] : ["-c", "-f", "-", "-C", path.dirname(local), "--", path.basename(local)];
592
+ const tarball = execFileSync("tar", tarArgs, { maxBuffer: 200 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
593
+ const r = await fetch(agentRouteUrl(httpBase(), id, "files", { path: flags.to }), {
594
+ method: "PUT",
595
+ headers: { ...authHeaders(), "content-type": "application/x-tar" },
596
+ body: tarball,
597
+ });
598
+ if (!r.ok) throw await failOf(r);
599
+ return r.json();
600
+ }
601
+ throw new Error("usage: pilotctl files <ls|get|put> <id> …");
602
+ }
603
+
512
604
  async function cmdDiff(id) {
513
605
  await ensureServer();
514
606
  const r = await fetch(`${httpBase()}/diff?session=${encodeURIComponent(id)}`, { headers: authHeaders() });
@@ -773,7 +865,9 @@ async function cmdScreen(id, flags) {
773
865
  }
774
866
 
775
867
  const HELP =
776
- "usage: pilotctl <spawn|prompt|dialog|choose|toggle|confirm|freetext|list|diff|stop|reap|set-parent|screen|profile-prompt|talk|talk-handle|peer> …\n" +
868
+ "usage: pilotctl <spawn|prompt|dialog|choose|toggle|confirm|freetext|list|diff|transcript|files|stop|reap|set-parent|screen|profile-prompt|talk|talk-handle|peer> …\n" +
869
+ " pilotctl transcript <id> [--turns] [--out FILE] # an agent you created: its full transcript\n" +
870
+ " pilotctl files <ls|get|put> <id> [path|local] [--out DIR] [--to path] # …and its folder\n" +
777
871
  " pilotctl set-parent <id> <parent-id|none> # re-link or detach an agent from its parent\n" +
778
872
  " add --peer <alias> to any command to run it against another instance's agents\n" +
779
873
  " pilotctl peer <add <alias> <url> <ticket> [--token]|list|rm <alias>>";
@@ -879,6 +973,10 @@ export async function run(argv) {
879
973
  return cmdList(flags);
880
974
  case "diff":
881
975
  return cmdDiff(pos[0]);
976
+ case "transcript":
977
+ return cmdTranscript(pos[0], flags);
978
+ case "files":
979
+ return cmdFiles(pos[0], pos[1], pos[2], flags);
882
980
  case "stop":
883
981
  return cmdStop(pos[0], flags);
884
982
  case "reap":
@@ -0,0 +1,113 @@
1
+ /**
2
+ * What the CREATOR of an agent may read and seed in it: its full transcript,
3
+ * and the files of its working folder (read, and seeded with a starting set).
4
+ *
5
+ * The need is a test bench. A peer instance spawns an agent into an external
6
+ * group to play a patient, drives it, and then has to judge what happened:
7
+ * the transcript says what the agent did (tool calls included, which the chat
8
+ * stream leaves out), and the folder says what it left behind. A scenario such
9
+ * as "a case opened ten days ago" also needs the folder SEEDED before the first
10
+ * prompt, with the dates of a real ten-day-old case.
11
+ *
12
+ * Pure and dependency-light, so the access rule and the command lines are
13
+ * tested without a server, root or a real Unix account.
14
+ */
15
+ /** Who is asking, as the server resolved it — never as the request claims. */
16
+ export interface FilesCaller {
17
+ /** A peer token's name (another instance), whatever its scope. */
18
+ peer?: string | null;
19
+ /** The session id behind an agent's session key. */
20
+ agent?: string | null;
21
+ /** A person signed in to this cockpit (cookie, or the bootstrap admin). */
22
+ person?: boolean;
23
+ }
24
+ /**
25
+ * May this caller read and seed THIS agent?
26
+ *
27
+ * The creator, and only the creator, among machine callers:
28
+ *
29
+ * - a PEER: the agent carries its name (`createdByPeer`, written at spawn from
30
+ * the token, never from the frame). Ownership alone, whatever the scope —
31
+ * exactly what lets a restricted peer resume, stop or diff its own agents,
32
+ * and nothing of anyone else's. A member peer does NOT get every agent it
33
+ * could see: a test bench reading real patients' conversations is the thing
34
+ * this rule exists to prevent;
35
+ * - an AGENT: it is the agent's parent (`parent`, validated at spawn) AND the
36
+ * group boundary lets it act on it — a parent link is a label a person can
37
+ * re-point, never a key into another group;
38
+ * - a PERSON keeps the cockpit's own rule (`mayAct`): they can already open the
39
+ * agent's chat and history there, so nothing is widened.
40
+ *
41
+ * A guest's boxed agent never qualifies: it can spawn nothing, so it is nobody's
42
+ * parent, and it carries no peer token.
43
+ */
44
+ export declare function filesAccessVerdict(target: {
45
+ sessionId: string;
46
+ parent?: string | null;
47
+ createdByPeer?: string;
48
+ } | null | undefined, caller: FilesCaller, mayAct: boolean): {
49
+ ok: true;
50
+ } | {
51
+ ok: false;
52
+ status: 403 | 404;
53
+ error: string;
54
+ };
55
+ /**
56
+ * A path INSIDE the agent's folder, as the caller wrote it: relative, no `..`
57
+ * segment, no NUL. `""` and `"."` are the folder itself. Returned normalised
58
+ * (`a//b/./c` → `a/b/c`), or null when refused.
59
+ *
60
+ * Refused rather than resolved, because a resolved path is a decision about
61
+ * someone else's filesystem: the folder is the agent's, and the creator gets
62
+ * that folder. Every command below ALSO runs as the agent's own Unix user, so a
63
+ * symlink inside the folder can reach only what the agent itself could — the
64
+ * check is the courtesy, the user is the wall.
65
+ */
66
+ export declare function folderRelPath(raw: unknown): string | null;
67
+ /** How many entries a listing returns at most. The folder of a test agent is
68
+ * small; a larger one is cut and says so. */
69
+ export declare const LIST_LIMIT = 2000;
70
+ /**
71
+ * List `rel` inside `root`, recursively, as the agent's user: one
72
+ * NUL-terminated record per entry — type, size, mtime (epoch seconds), path
73
+ * relative to `rel`. `find` never follows a symlink here (`-P`), it lists it.
74
+ */
75
+ export declare function listArgv(user: string | null, root: string, rel: string): {
76
+ cmd: string;
77
+ argv: string[];
78
+ };
79
+ export interface FolderEntry {
80
+ path: string;
81
+ type: "file" | "dir" | "link" | "other";
82
+ size: number;
83
+ mtime: number;
84
+ }
85
+ /** Parse `listArgv`'s output; malformed records are skipped. */
86
+ export declare function parseListOutput(out: string, limit?: number): {
87
+ entries: FolderEntry[];
88
+ truncated: boolean;
89
+ };
90
+ /**
91
+ * A tar of `rel` (a file or a directory) taken from `root`, on stdout, as the
92
+ * agent's user. Symlinks are archived as links, never followed (tar's default),
93
+ * so an archive holds what the folder holds and nothing it points at.
94
+ */
95
+ export declare function tarCreateArgv(user: string | null, root: string, rel: string): {
96
+ cmd: string;
97
+ argv: string[];
98
+ };
99
+ /**
100
+ * Extract a tar from stdin into `root/rel`, as the agent's user, creating
101
+ * `rel` first. The archive's dates are KEPT — that is what makes a seeded
102
+ * "ten-day-old case" ten days old — and its owners and mode bits never are
103
+ * (the umask applies: a setuid bit in the archive does not survive, which
104
+ * matters wherever this runs as root). GNU tar already
105
+ * refuses members with a `..` and strips a leading `/`; the Unix user is what
106
+ * guarantees the rest (an archive can only write where the agent could).
107
+ */
108
+ export declare function tarExtractArgv(user: string | null, root: string, rel: string): {
109
+ cmd: string;
110
+ argv: string[];
111
+ };
112
+ /** The largest archive a seed may upload. A test fixture, not a backup. */
113
+ export declare const SEED_MAX_BYTES: number;
@@ -0,0 +1,130 @@
1
+ import { dropArgv } from "./osusers.js";
2
+ /**
3
+ * May this caller read and seed THIS agent?
4
+ *
5
+ * The creator, and only the creator, among machine callers:
6
+ *
7
+ * - a PEER: the agent carries its name (`createdByPeer`, written at spawn from
8
+ * the token, never from the frame). Ownership alone, whatever the scope —
9
+ * exactly what lets a restricted peer resume, stop or diff its own agents,
10
+ * and nothing of anyone else's. A member peer does NOT get every agent it
11
+ * could see: a test bench reading real patients' conversations is the thing
12
+ * this rule exists to prevent;
13
+ * - an AGENT: it is the agent's parent (`parent`, validated at spawn) AND the
14
+ * group boundary lets it act on it — a parent link is a label a person can
15
+ * re-point, never a key into another group;
16
+ * - a PERSON keeps the cockpit's own rule (`mayAct`): they can already open the
17
+ * agent's chat and history there, so nothing is widened.
18
+ *
19
+ * A guest's boxed agent never qualifies: it can spawn nothing, so it is nobody's
20
+ * parent, and it carries no peer token.
21
+ */
22
+ export function filesAccessVerdict(target, caller, mayAct) {
23
+ if (!target)
24
+ return { ok: false, status: 404, error: "no such agent" };
25
+ if (caller.peer) {
26
+ return target.createdByPeer === caller.peer
27
+ ? { ok: true }
28
+ : { ok: false, status: 403, error: "only the instance that created this agent may read its transcript and files" };
29
+ }
30
+ if (caller.agent) {
31
+ if (target.parent !== caller.agent)
32
+ return { ok: false, status: 403, error: "only the agent that created this one may read its transcript and files" };
33
+ return mayAct ? { ok: true } : { ok: false, status: 403, error: "not your agent" };
34
+ }
35
+ if (caller.person && mayAct)
36
+ return { ok: true };
37
+ return { ok: false, status: 403, error: "not your agent" };
38
+ }
39
+ /**
40
+ * A path INSIDE the agent's folder, as the caller wrote it: relative, no `..`
41
+ * segment, no NUL. `""` and `"."` are the folder itself. Returned normalised
42
+ * (`a//b/./c` → `a/b/c`), or null when refused.
43
+ *
44
+ * Refused rather than resolved, because a resolved path is a decision about
45
+ * someone else's filesystem: the folder is the agent's, and the creator gets
46
+ * that folder. Every command below ALSO runs as the agent's own Unix user, so a
47
+ * symlink inside the folder can reach only what the agent itself could — the
48
+ * check is the courtesy, the user is the wall.
49
+ */
50
+ export function folderRelPath(raw) {
51
+ if (raw === undefined || raw === null)
52
+ return ".";
53
+ if (typeof raw !== "string" || raw.includes("\0") || raw.length > 1024)
54
+ return null;
55
+ if (raw.startsWith("/") || raw.startsWith("-"))
56
+ return null;
57
+ const parts = raw.split("/").filter((p) => p !== "" && p !== ".");
58
+ if (parts.some((p) => p === ".." || p.startsWith("-")))
59
+ return null;
60
+ return parts.length ? parts.join("/") : ".";
61
+ }
62
+ /** Run as `user` when there is one; as the server otherwise (mono-tenant,
63
+ * where every agent already runs as the server's own user). */
64
+ function asUser(user, cmd, argv) {
65
+ return user ? dropArgv(user, cmd, argv) : { cmd, argv };
66
+ }
67
+ /** How many entries a listing returns at most. The folder of a test agent is
68
+ * small; a larger one is cut and says so. */
69
+ export const LIST_LIMIT = 2000;
70
+ /**
71
+ * List `rel` inside `root`, recursively, as the agent's user: one
72
+ * NUL-terminated record per entry — type, size, mtime (epoch seconds), path
73
+ * relative to `rel`. `find` never follows a symlink here (`-P`), it lists it.
74
+ */
75
+ export function listArgv(user, root, rel) {
76
+ return asUser(user, "find", ["-P", "--", `${root}/${rel}`, "-mindepth", "1", "-printf", "%y\\t%s\\t%T@\\t%P\\0"]);
77
+ }
78
+ /** Parse `listArgv`'s output; malformed records are skipped. */
79
+ export function parseListOutput(out, limit = LIST_LIMIT) {
80
+ const entries = [];
81
+ let truncated = false;
82
+ for (const rec of String(out ?? "").split("\0")) {
83
+ if (!rec)
84
+ continue;
85
+ const [y, size, mtime, ...rest] = rec.split("\t");
86
+ const p = rest.join("\t");
87
+ if (!p || !y)
88
+ continue;
89
+ if (entries.length >= limit) {
90
+ truncated = true;
91
+ break;
92
+ }
93
+ entries.push({
94
+ path: p,
95
+ type: y === "f" ? "file" : y === "d" ? "dir" : y === "l" ? "link" : "other",
96
+ size: Number(size) || 0,
97
+ mtime: Math.round(Number(mtime) || 0),
98
+ });
99
+ }
100
+ entries.sort((a, b) => a.path.localeCompare(b.path));
101
+ return { entries, truncated };
102
+ }
103
+ /**
104
+ * A tar of `rel` (a file or a directory) taken from `root`, on stdout, as the
105
+ * agent's user. Symlinks are archived as links, never followed (tar's default),
106
+ * so an archive holds what the folder holds and nothing it points at.
107
+ */
108
+ export function tarCreateArgv(user, root, rel) {
109
+ return asUser(user, "tar", ["-c", "-f", "-", "-C", root, "--", rel]);
110
+ }
111
+ /**
112
+ * Extract a tar from stdin into `root/rel`, as the agent's user, creating
113
+ * `rel` first. The archive's dates are KEPT — that is what makes a seeded
114
+ * "ten-day-old case" ten days old — and its owners and mode bits never are
115
+ * (the umask applies: a setuid bit in the archive does not survive, which
116
+ * matters wherever this runs as root). GNU tar already
117
+ * refuses members with a `..` and strips a leading `/`; the Unix user is what
118
+ * guarantees the rest (an archive can only write where the agent could).
119
+ */
120
+ export function tarExtractArgv(user, root, rel) {
121
+ return asUser(user, "sh", [
122
+ "-c",
123
+ 'mkdir -p -- "$1" && exec tar -x -f - --no-same-owner --no-same-permissions --no-overwrite-dir -C "$1"',
124
+ "sh",
125
+ `${root}/${rel}`,
126
+ ]);
127
+ }
128
+ /** The largest archive a seed may upload. A test fixture, not a backup. */
129
+ export const SEED_MAX_BYTES = 100 * 1024 * 1024;
130
+ //# sourceMappingURL=agent-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-files.js","sourceRoot":"","sources":["../src/agent-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA2BxC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAgG,EAChG,MAAmB,EACnB,MAAe;IAEf,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;IACvE,IAAI,MAAM,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,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAmB,EAAE,IAAY,EAAE,GAAW;IAC3E,OAAO,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE;QACxB,IAAI;QACJ,uGAAuG;QACvG,IAAI;QACJ,GAAG,IAAI,IAAI,GAAG,EAAE;KACjB,CAAC,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC"}
@@ -37,6 +37,17 @@ export interface ExternalUserRow {
37
37
  * operator asked to erase.
38
38
  */
39
39
  retiring?: number;
40
+ /**
41
+ * `"pending"` while the group's first-run script has not SUCCEEDED for this
42
+ * conversation (`src/guest-init.ts`) — absent otherwise, which is also what
43
+ * every row written before the field existed reads as.
44
+ *
45
+ * Written with the row, at the mint, and dropped on success. It is on disk
46
+ * rather than in memory because the gap it covers is a server that stopped
47
+ * mid-script: without it the next message would find an account, conclude
48
+ * the conversation is an old one, and start an agent in a half-prepared home.
49
+ */
50
+ init?: "pending";
40
51
  }
41
52
  /**
42
53
  * What provisioning this conversation's user amounts to, against the registry.
@@ -69,6 +80,10 @@ export declare function withExternalUser(rows: readonly ExternalUserRow[], row:
69
80
  export declare function externalUsersOfGroup(rows: readonly ExternalUserRow[], groupId: string): ExternalUserRow[];
70
81
  /** The account minted for this conversation, or null. */
71
82
  export declare function externalUserRow(rows: readonly ExternalUserRow[], groupId: string, conversation: string): ExternalUserRow | null;
83
+ /** Mark a conversation's first-run script as owed (new array). */
84
+ export declare function withInitPending(rows: readonly ExternalUserRow[], user: string): ExternalUserRow[];
85
+ /** The first-run script succeeded — or there is none left to run (new array). */
86
+ export declare function withInitDone(rows: readonly ExternalUserRow[], user: string): ExternalUserRow[];
72
87
  /** Drop rows (new array) — a torn-down conversation, or a deleted group's lot. */
73
88
  export declare function withoutExternalUsers(rows: readonly ExternalUserRow[], users: readonly string[]): ExternalUserRow[];
74
89
  /**
@@ -51,6 +51,19 @@ export function externalUserRow(rows, groupId, conversation) {
51
51
  const unit = conversationUnit(groupId, conversation);
52
52
  return rows.find((r) => r.unit === unit) ?? null;
53
53
  }
54
+ /** Mark a conversation's first-run script as owed (new array). */
55
+ export function withInitPending(rows, user) {
56
+ return rows.map((r) => (r.user === user ? { ...r, init: "pending" } : r));
57
+ }
58
+ /** The first-run script succeeded — or there is none left to run (new array). */
59
+ export function withInitDone(rows, user) {
60
+ return rows.map((r) => {
61
+ if (r.user !== user || r.init === undefined)
62
+ return r;
63
+ const { init: _init, ...rest } = r;
64
+ return rest;
65
+ });
66
+ }
54
67
  /** Drop rows (new array) — a torn-down conversation, or a deleted group's lot. */
55
68
  export function withoutExternalUsers(rows, users) {
56
69
  const gone = new Set(users);
@@ -240,6 +253,10 @@ export function normalizeExternalUsers(raw) {
240
253
  // read as live because its timestamp was mangled.
241
254
  if (row.retiring != null)
242
255
  kept.retiring = typeof row.retiring === "number" && Number.isFinite(row.retiring) ? row.retiring : 0;
256
+ // Same direction for the first-run script: any trace of the mark means it
257
+ // is still owed, never that it ran.
258
+ if (row.init != null)
259
+ kept.init = "pending";
243
260
  out.push(kept);
244
261
  }
245
262
  return out;
@@ -1 +1 @@
1
- {"version":3,"file":"external-users.js","sourceRoot":"","sources":["../src/external-users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AA2CpF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAgC,EAChC,IAAoC,EACpC,GAAW;IAKX,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC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QACpC,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,4EAA4E;AAC5E,+EAA+E;AAC/E,mEAAmE;AAEnE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,qBAAqB,CAAC,CAAC;AAE1E,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC;QACH,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;QACzE,2EAA2E;QAC3E,uEAAuE;QACvE,0EAA0E;QAC1E,0EAA0E;QAC1E,oDAAoD;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAgC;IAChE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,2CAA2C;AACxE,CAAC"}
package/dist/extract.d.ts CHANGED
@@ -125,6 +125,14 @@ export declare function transcriptFilePath(cwd: string, sessionId: string, home?
125
125
  * be replayed when resuming the session.
126
126
  */
127
127
  export declare function loadHistory(cwd: string, sessionId: string, home?: string): HistoryTurn[];
128
+ /**
129
+ * The turns of a transcript's TEXT — `loadHistory` without the file read, for a
130
+ * caller that must read the file with someone else's rights (the creator's
131
+ * `GET /agents/:id/transcript?format=turns` reads it as the agent's user:
132
+ * the file sits in the agent's writable HOME, so a root read would follow a
133
+ * symlink the agent planted to a neighbour's transcript).
134
+ */
135
+ export declare function historyFromRaw(raw: string): HistoryTurn[];
128
136
  export interface SessionInfo {
129
137
  id: string;
130
138
  /** Last activity, in ms since epoch (file mtime). */
package/dist/extract.js CHANGED
@@ -376,6 +376,16 @@ export function loadHistory(cwd, sessionId, home = os.homedir()) {
376
376
  catch {
377
377
  return [];
378
378
  }
379
+ return historyFromRaw(raw);
380
+ }
381
+ /**
382
+ * The turns of a transcript's TEXT — `loadHistory` without the file read, for a
383
+ * caller that must read the file with someone else's rights (the creator's
384
+ * `GET /agents/:id/transcript?format=turns` reads it as the agent's user:
385
+ * the file sits in the agent's writable HOME, so a root read would follow a
386
+ * symlink the agent planted to a neighbour's transcript).
387
+ */
388
+ export function historyFromRaw(raw) {
379
389
  const turns = [];
380
390
  // A hidden user prompt (cron / parent notification) was dropped and now
381
391
  // separates the next assistant turn from the previous one — so that turn must