pi-durable-subagents 1.0.43 → 1.0.45

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.
@@ -3,7 +3,7 @@
3
3
  import { initiatorSummary, restartLine } from "./restart.js";
4
4
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
5
5
  import { join } from "node:path";
6
- import { compileFanout } from "../compat/fanout.js";
6
+ import { FANOUT_BODIES } from "../compat/fanout.js";
7
7
  import { crc32, forgetJournalSnapshot, forgetJournalSnapshotsIf, journalAppends, readJournalRecord, readJournalSnapshot, readJournalUncached } from "../kernel/journal.js";
8
8
  import { readCache, writeCache } from "../kernel/cache.js";
9
9
  import { digestDir, journalPath, pinnedDir, workflowDir } from "../paths.js";
@@ -31,6 +31,44 @@ export function modelStatusText(c, now = Date.now()) {
31
31
  (c.routedModel ? ` (routed ${c.routedModel})` : "") +
32
32
  (m ? ` (used ${m.used}, selected ${m.selected})` : "") + (c.modelUnavailable ? ` (model-unavailable: ${c.modelUnavailable})` : "");
33
33
  }
34
+ /** A command call's command as one line: an argv array joined with spaces (an argument that needs it single-quoted as
35
+ * for sh), a string as it is. */
36
+ export function commandText(command) {
37
+ if (Array.isArray(command))
38
+ return command.map(a => { const s = String(a); return /^[A-Za-z0-9_./:=@%+,-]+$/.test(s) ? s : `'${s.replaceAll("'", "'\\''")}'`; }).join(" ");
39
+ return String(command ?? "");
40
+ }
41
+ /** R8: The pinned refusal of a send to a command call (the engine gives the same reason). */
42
+ export const commandSendRefusal = (kind) => `command call: ${kind} is not supported (stop it, or start a new call)`;
43
+ /** R8, F5: Whether a send address names a command call, matched whole as the engine's findCall does, among the
44
+ * current revision's calls: `<wid>/<key>`, `<wid>@<rev>/<key>@<gen>`, or a bare wid of a workflow with one key. A key
45
+ * may contain `@` and digits: nothing is stripped. Read-only; false for anything it cannot resolve. */
46
+ export function isCommandTarget(home, to) {
47
+ if (typeof to !== "string" || !to)
48
+ return false;
49
+ const wid = to.split(/[@/]/, 1)[0]; // a wid has neither '@' nor '/'
50
+ if (!wid || !existsSync(journalPath(home, wid)))
51
+ return false;
52
+ let entries;
53
+ try {
54
+ entries = readJournalSnapshot(journalPath(home, wid));
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ const rev = Math.max(1, ...entries.filter(e => e.type === "wf-created" || e.type === "revised").map(e => Number(e.revision) || 1));
60
+ const start = entries.findLastIndex(e => e.type === "revised");
61
+ const calls = (start < 0 ? entries : entries.slice(start)).filter(e => e.type === "call" || e.type === "generation");
62
+ const keys = new Set(calls.map(e => String(e.key)));
63
+ const named = calls.findLast(e => to === `${wid}/${e.key}` || to === `${wid}@${rev}/${e.key}@${e.gen}` || (to === wid && keys.size === 1));
64
+ if (!named)
65
+ return false;
66
+ return calls.findLast(e => e.key === named.key).spec?.command !== undefined;
67
+ }
68
+ /** A command clipped to one display line of at most `n` characters ("command: <clipped>" in status and the UI). */
69
+ export function commandLine(command, n = 80) {
70
+ return clip(command.replace(/\s+/g, " ").trim(), n);
71
+ }
34
72
  /** A workflow has live work: it runs, or follow-ups opened on it after it finished have not ended yet. */
35
73
  export function isLive(wf) {
36
74
  return wf.status === "running" || (wf.followUps ?? 0) > 0;
@@ -46,8 +84,8 @@ export function progressOf(wf) {
46
84
  const done = [...latest.values()].filter(c => c.phase === "sealed").length;
47
85
  return { done, total: wf.planned ?? latest.size, plus: wf.planned === undefined && wf.status === "running" };
48
86
  }
49
- // v12 §4: the exact bodies compileFanout emits after the `const steps = [...];` line, so only true fanouts count as planned.
50
- const fanoutBodies = [compileFanout({ tasks: [] }).source, compileFanout({ chain: [] }).source].map(s => s.slice(s.indexOf("\n") + 1));
87
+ // v12 §4: the exact bodies compileFanout emits (or emitted) after the `const steps = [...];` line, so only true fanouts count as planned.
88
+ const fanoutBodies = FANOUT_BODIES;
51
89
  /** v12 §4: The planned total of a pinned script: its steps count when it is a compiled tasks/chain fanout; scripts have none. */
52
90
  export function plannedFromScript(source) {
53
91
  const cut = source.indexOf("\n"), head = source.slice(0, Math.max(0, cut)), rest = source.slice(cut + 1);
@@ -101,6 +139,7 @@ function snapshotReducer(wid, entries) {
101
139
  let terminal = current.findLast(e => e.type === JT.done || (e.type === "resumed" && !e.call));
102
140
  const calls = new Map();
103
141
  const byExec = new Map();
142
+ const byCommand = new Map(); // command attempt id -> its call
104
143
  const hibernating = new Map(); // callId → exec that decided to hibernate and is not fenced yet
105
144
  const fenced = new Set();
106
145
  const resolved = new Set();
@@ -133,7 +172,9 @@ function snapshotReducer(wid, entries) {
133
172
  const result = e.type === "refused" ? refusedResult(key, e.reason) :
134
173
  e.type === "reused" ? entries.find(s => s.type === JT.sealed && s.call === e.from)?.result : undefined;
135
174
  const wanted = e.spec?.model;
175
+ const command = e.spec?.command;
136
176
  calls.set(callId, { key, gen, callId, pos: Number(e.pos), agent: String(e.spec?.agent ?? ""),
177
+ ...(command !== undefined ? { command: commandText(command) } : {}),
137
178
  // Until a slot is acquired (`selected`), show the model the call asked for, not nothing.
138
179
  ...(typeof wanted === "string" && wanted ? { model: wanted } : {}),
139
180
  phase: result ? "sealed" : "queued", ...(result ? { result, endedAt: e.ts } : {}),
@@ -168,6 +209,26 @@ function snapshotReducer(wid, entries) {
168
209
  hibernating.delete(call.callId);
169
210
  }
170
211
  }
212
+ else if (e.type === "command-intent") {
213
+ // A command call runs from its intent until its seal; it never has an `exec`, so nothing treats it as an execution.
214
+ const call = calls.get(String(e.call));
215
+ if (call && call.phase !== "sealed") {
216
+ call.commandRun = { attempt: Number(e.n) || 1, id: String(e.id) };
217
+ call.phase = "running";
218
+ call.startedAt = e.ts;
219
+ call.lastActivity = e.ts;
220
+ delete call.writerWait;
221
+ byCommand.set(String(e.id), call);
222
+ }
223
+ }
224
+ else if (e.type === "command-started") {
225
+ const call = byCommand.get(String(e.id)), dir = e.dir;
226
+ if (call && call.commandRun?.id === e.id) {
227
+ call.commandRun = { ...call.commandRun, ...(Number.isSafeInteger(e.pid) ? { pid: Number(e.pid) } : {}), ...(typeof dir === "string" ? { log: join(dir, "output.log") } : {}) };
228
+ call.startedAt = e.ts;
229
+ call.lastActivity = e.ts;
230
+ }
231
+ }
171
232
  else if (e.type === "slot-wait") {
172
233
  const call = byExec.get(String(e.exec));
173
234
  if (call && call.exec === e.exec) {
@@ -892,7 +953,8 @@ export function queueWait(c, state, now = Date.now(), starting = orchestratorSta
892
953
  return undefined;
893
954
  if (starting)
894
955
  return { reason: "starting", detail: "orchestrator starting", since: starting.since };
895
- const settings = state.config?.settings ?? {}, pools = settings.pools ?? {}, wanted = c.poolWait?.model ?? c.model ?? settings.defaultModel;
956
+ // A command call takes no provider slot: only the orchestrator's start and a writer lock hold it back.
957
+ const settings = state.config?.settings ?? {}, pools = settings.pools ?? {}, wanted = c.command !== undefined ? undefined : c.poolWait?.model ?? c.model ?? settings.defaultModel;
896
958
  let providers = [];
897
959
  if (wanted && Object.hasOwn(pools, wanted)) {
898
960
  try {
@@ -1076,6 +1138,20 @@ export function formatUsage(u) {
1076
1138
  const n = (v) => v >= 1e6 ? `${(v / 1e6).toFixed(2)}M` : v >= 1e3 ? `${(v / 1e3).toFixed(1)}K` : String(v);
1077
1139
  return `${n(u.input)} in / ${n(u.output)} out${u.costUsd > 0 ? `, $${u.costUsd.toFixed(u.costUsd < 0.01 ? 4 : 2)}` : ""}`;
1078
1140
  }
1141
+ /** The CommandStatus of a command call (empty for an agent call): pid only while it is live. */
1142
+ export function commandStatus(c, now = Date.now()) {
1143
+ if (c.command === undefined)
1144
+ return {};
1145
+ const run = c.commandRun, data = c.result?.data, live = c.phase !== "sealed" && run !== undefined;
1146
+ return { command: commandLine(c.command),
1147
+ ...(live && run.pid !== undefined ? { pid: run.pid } : {}), ...(live && (run.attempt ?? 1) > 1 ? { attempt: run.attempt } : {}),
1148
+ ...(live && c.startedAt !== undefined ? { for: age(now - c.startedAt) } : {}),
1149
+ ...(typeof data?.exitCode === "number" ? { exitCode: data.exitCode } : {}), ...(typeof data?.signal === "string" ? { signal: data.signal } : {}) };
1150
+ }
1151
+ /** "pid 123" / "exit 3" / "SIGKILL" of a command call's status line (empty for an agent call or before the start). */
1152
+ export function commandFacts(c) {
1153
+ return [c.pid !== undefined ? `pid ${c.pid}` : "", c.attempt ? `attempt ${c.attempt}` : "", c.for ?? "", c.exitCode !== undefined ? `exit ${c.exitCode}` : "", c.signal ?? ""].filter(Boolean).join(", ");
1154
+ }
1079
1155
  /** P25, T10: Compact one workflow snapshot: per-call one-line facts, usage, open attention; no outputs or entries. */
1080
1156
  export function compactWorkflow(wf, leases) {
1081
1157
  const progress = progressOf(wf); // v12 §4
@@ -1087,7 +1163,7 @@ export function compactWorkflow(wf, leases) {
1087
1163
  ...(wf.planned !== undefined ? { planned: wf.planned } : {}), done: progress.done,
1088
1164
  calls: wf.calls.map(c => {
1089
1165
  const r = c.result, last = r?.output?.split("\n").map(l => l.trim()).filter(Boolean).at(-1);
1090
- return { key: c.key, gen: c.gen, callId: c.callId, phase: c.phase, ...modelStatus(c), ...(r ? { status: r.status, ok: r.ok } : {}),
1166
+ return { key: c.key, gen: c.gen, callId: c.callId, phase: c.phase, ...modelStatus(c), ...commandStatus(c), ...(r ? { status: r.status, ok: r.ok } : {}),
1091
1167
  ...(c.sharedWorktree ? { sharedWorktree: c.sharedWorktree } : {}),
1092
1168
  ...(c.model ? { model: c.model } : {}), ...(c.tools ? { tools: c.tools } : {}), ...(c.pending ? { pending: c.pending } : {}), ...(c.switching ? { switching: c.switching } : {}), ...(c.switchFailed ? { switchFailed: c.switchFailed } : {}), ...(nonzero(c.usage) ? { usage: c.usage } : {}),
1093
1169
  ...(last ? { lastLine: clip(last, 200) } : {}), ...(r?.error ? { error: clip(r.error, 300) } : {}), ...(c.hibernated ? { hibernated: true } : {}),
@@ -1274,12 +1350,13 @@ export function statusBrief(home, options = {}) {
1274
1350
  const brief = (w) => {
1275
1351
  const p = progressOf(w), open = w.attention.filter(a => a.kind !== "finished");
1276
1352
  const calls = latestCalls(w).filter(c => c.phase !== "sealed" || (c.result && !c.result.ok) || c.notesPending).map((c) => {
1277
- const live = c.phase !== "sealed", quiet = c.lastActivity !== undefined ? now - c.lastActivity : undefined;
1278
- return { key: c.key, agent: c.agent, phase: c.phase, ...modelStatus(c), ...(c.model ? { model: c.model } : {}),
1353
+ // A command call shows its command, pid and age instead of a model, quiet time and tokens.
1354
+ const live = c.phase !== "sealed", quiet = c.lastActivity !== undefined ? now - c.lastActivity : undefined, agent = c.command === undefined;
1355
+ return { key: c.key, agent: c.agent, phase: c.phase, ...modelStatus(c), ...(c.model ? { model: c.model } : {}), ...commandStatus(c, now),
1279
1356
  ...(c.sharedWorktree ? { sharedWorktree: c.sharedWorktree } : {}),
1280
1357
  ...(live && c.startedAt !== undefined ? { for: age(now - c.startedAt) } : {}),
1281
- ...(live && c.phase !== "asking" && quiet !== undefined && quiet >= 60_000 ? { quiet: age(quiet) } : {}),
1282
- ...(live && c.startedAt !== undefined ? { tokens: tokens(c.usage) } : {}),
1358
+ ...(agent && live && c.phase !== "asking" && quiet !== undefined && quiet >= 60_000 ? { quiet: age(quiet) } : {}),
1359
+ ...(agent && live && c.startedAt !== undefined ? { tokens: tokens(c.usage) } : {}),
1283
1360
  ...(c.result ? { status: c.result.status, ...(c.result.error ? { error: clip(c.result.error, 200) } : {}) } : {}),
1284
1361
  ...(c.hibernated ? { hibernated: true } : {}), ...(c.answered ? { answered: c.answered } : {}), ...(c.answerForwarded ? { answerForwarded: c.answerForwarded } : {}), ...(live && c.writerWait ? { writerWait: c.writerWait } : {}),
1285
1362
  ...(live && byCall.get(c.callId) ? { lease: byCall.get(c.callId) } : {}),
@@ -0,0 +1,98 @@
1
+ // Command calls (CallSpec.command): the launcher. A command runs detached in its own session under a tiny /bin/sh
2
+ // wrapper that runs it, then records its exit status atomically in the attempt directory (`exit.tmp`, renamed to `exit`)
3
+ // and exits with the same status. Its output (stdout and stderr, interleaved) is appended to `output.log` in the same
4
+ // directory through a descriptor the orchestrator opens, passes and closes: no pipe leads back into the orchestrator and
5
+ // no node process stays resident for the life of the command, so it outlives the orchestrator that started it.
6
+ import { spawn } from "node:child_process";
7
+ import { closeSync, openSync } from "node:fs";
8
+ import { mkdir, readFile, stat, open } from "node:fs/promises";
9
+ import { constants } from "node:os";
10
+ import { join } from "node:path";
11
+ import { captureStart } from "./proctable.js";
12
+ import { findOnPath } from "./launch.js";
13
+ export const COMMAND_LOG = "output.log";
14
+ export const COMMAND_EXIT = "exit";
15
+ /** The output a result carries: the last bytes of `output.log`. */
16
+ export const OUTPUT_TAIL_BYTES = 16 * 1024;
17
+ /** The wrapper: `$1` is the attempt directory, `$2` the absolute `mv`, the rest the command's argv. Its own steps use
18
+ * only shell builtins and that absolute `mv` with every expansion quoted, so they work under any environment the
19
+ * command gets (PATH unset or bogus, IFS, LC_*). The argv runs through `exec` in a subshell: it is always a program
20
+ * (looked up on the command's PATH; a shell builtin name such as `exit` is no builtin there, 127 when no program has
21
+ * it), and its end, however it comes, never skips recording the status. A program named by a path that does not exist
22
+ * is 127 before `exec`: some shells (bash 3.2, the macOS /bin/sh) report 126 for it instead. */
23
+ const WRAPPER = 'd="$1"; m="$2"; shift 2; ( case "$1" in (*/*) [ -e "$1" ] || { printf "%s: %s: not found\\n" "$0" "$1" >&2; exit 127; } ;; esac; exec "$@" ); s="$?"; printf "%s\\n" "$s" > "$d/exit.tmp" && "$m" -f "$d/exit.tmp" "$d/exit"; exit "$s"';
24
+ /** `mv` for the wrapper: from this process's PATH, else /bin or /usr/bin; resolved once. */
25
+ let mvPath;
26
+ export function resolveMv(PATH = process.env.PATH) {
27
+ mvPath ??= findOnPath("mv", PATH) ?? findOnPath("mv", "/bin:/usr/bin") ?? "/bin/mv";
28
+ return mvPath;
29
+ }
30
+ /** The argv the wrapper runs: an argv as given (a program, never shell syntax), a string through `/bin/sh -c`. */
31
+ export const commandArgv = (command) => typeof command === "string" ? ["/bin/sh", "-c", command] : [...command];
32
+ export async function spawnCommand(spec) {
33
+ await mkdir(spec.dir, { recursive: true });
34
+ const fd = openSync(join(spec.dir, COMMAND_LOG), "a");
35
+ try {
36
+ const mv = resolveMv(), argv = commandArgv(spec.command);
37
+ if (spec.proceed && !spec.proceed())
38
+ return undefined;
39
+ const child = spawn("/bin/sh", ["-c", WRAPPER, "dsa-command", spec.dir, mv, ...argv], { cwd: spec.cwd, env: spec.env, detached: true, stdio: ["ignore", fd, fd] });
40
+ const exited = new Promise(resolve => { child.once("exit", () => resolve()); child.once("error", () => resolve()); });
41
+ await new Promise((resolve, reject) => { child.once("spawn", resolve); child.once("error", reject); });
42
+ child.unref();
43
+ const pid = child.pid;
44
+ const start = child.exitCode !== null || child.signalCode !== null ? "" : await captureStart(pid).catch(() => "");
45
+ return { pid, start, exited };
46
+ }
47
+ finally {
48
+ closeSync(fd);
49
+ }
50
+ }
51
+ /** The status the wrapper recorded, or undefined while there is none (the command runs, or ended without one). */
52
+ export async function readExitRecord(dir) {
53
+ const path = join(dir, COMMAND_EXIT);
54
+ let text, at;
55
+ try {
56
+ [text, at] = await Promise.all([readFile(path, "utf8"), stat(path).then(s => s.mtimeMs)]);
57
+ }
58
+ catch (error) {
59
+ if (error.code === "ENOENT")
60
+ return undefined;
61
+ throw error;
62
+ }
63
+ const status = Number(text.trim());
64
+ return Number.isInteger(status) && status >= 0 ? { status, at } : undefined;
65
+ }
66
+ const signalNames = new Map(Object.entries(constants.signals).map(([name, n]) => [n, name]));
67
+ /** How an exit status reads. The wrapper sees the status of a shell: a command killed by signal N exits 128+N. A command
68
+ * that itself exits with a status above 128 (`exit 130`) therefore reads as killed by that signal: the two cannot be
69
+ * told apart from the status alone (the shell convention). */
70
+ export function exitMeaning(status) {
71
+ const name = status > 128 ? signalNames.get(status - 128) : undefined;
72
+ return name ? { exitCode: null, signal: name } : { exitCode: status, signal: null };
73
+ }
74
+ /** The last `bytes` of a file, starting on a UTF-8 character boundary ("" when it is missing). */
75
+ export async function readTail(path, bytes = OUTPUT_TAIL_BYTES) {
76
+ const file = await open(path, "r").catch(error => { if (error.code === "ENOENT")
77
+ return undefined; throw error; });
78
+ if (!file)
79
+ return "";
80
+ try {
81
+ const { size } = await file.stat(), from = Math.max(0, size - bytes), buffer = Buffer.alloc(size - from);
82
+ for (let read = 0; read < buffer.length;) {
83
+ const { bytesRead } = await file.read(buffer, read, buffer.length - read, from + read);
84
+ if (!bytesRead)
85
+ break;
86
+ read += bytesRead;
87
+ }
88
+ // Skip continuation bytes (10xxxxxx) a cut in the middle of a character left at the start.
89
+ let skip = 0;
90
+ if (from > 0)
91
+ while (skip < buffer.length && skip < 4 && (buffer[skip] & 0xc0) === 0x80)
92
+ skip++;
93
+ return buffer.subarray(skip).toString("utf8");
94
+ }
95
+ finally {
96
+ await file.close();
97
+ }
98
+ }
@@ -100,15 +100,25 @@ export async function scopeRunner(env, options = {}) {
100
100
  function started(child) {
101
101
  return new Promise((resolve, reject) => { child.once("spawn", resolve); child.once("error", reject); });
102
102
  }
103
+ /** The variables the executor sets for one call's processes (a subagent, a command call, a gate). An orchestrator
104
+ * started from inside a call (its CLI, a command that runs `start`) never carries them: with the call's DSA_EXEC it
105
+ * would be one of that call's processes, and the call's fence (its end, a stop) would kill it. */
106
+ export const PER_CALL_ENV = ["DSA_SESSION", "DSA_EXEC", "DSA_CALL", "DSA_INBOX", "DSA_JOURNAL", "DSA_SCHEMA", "DSA_BUDGET", "DSA_MODEL", "DSA_RESULT", "DSA_OUTPUT", "DSA_PROBE"];
107
+ /** `env` without PER_CALL_ENV. */
108
+ export function orchestratorEnv(env) {
109
+ const rest = { ...env };
110
+ for (const name of PER_CALL_ENV)
111
+ delete rest[name];
112
+ return rest;
113
+ }
103
114
  /** Start the orchestrator at `entry`, detached, with `env` minus the starting session's DSA_SESSION (it serves every
104
- * session) plus DSA_HOME and the resolved DSA_PI_BIN. In its own systemd scope when one is available (the scope execs
115
+ * session) and every other per-call variable (PER_CALL_ENV) plus DSA_HOME and the resolved DSA_PI_BIN. In its own systemd scope when one is available (the scope execs
105
116
  * the command: same environment, and the pid is the orchestrator's), else a plain detached process. */
106
117
  export async function launchOrchestrator(entry, env, options) {
107
118
  const pi = resolvePi(env);
108
119
  if (!pi.path && options.requirePi)
109
120
  throw new PiNotFound(pi.problem);
110
- const { DSA_SESSION: _session, ...rest } = env;
111
- const childEnv = { ...rest, DSA_HOME: options.home, ...(pi.path ? { DSA_PI_BIN: pi.path } : {}) };
121
+ const childEnv = { ...orchestratorEnv(env), DSA_HOME: options.home, ...(pi.path ? { DSA_PI_BIN: pi.path } : {}) };
112
122
  const node = options.node ?? process.execPath, run = options.spawn ?? spawn;
113
123
  const runner = await scopeRunner(env, options);
114
124
  if (runner) {
package/dist/types.js CHANGED
@@ -56,6 +56,8 @@ export const JT = {
56
56
  rejected: "rejected",
57
57
  withdrawn: "withdrawn",
58
58
  };
59
+ /** A command call (CallSpec.command): no agent, task or model at runtime even though the type declares them. */
60
+ export const isCommandCall = (spec) => spec?.command !== undefined;
59
61
  // ---------------------------------------------------------------------------
60
62
  // Environment variables passed to children (child session agent reads them)
61
63
  // ---------------------------------------------------------------------------
package/dist/ui/screen.js CHANGED
@@ -1,12 +1,39 @@
1
1
  import { AssistantMessageComponent, UserMessageComponent, ToolExecutionComponent, getMarkdownTheme, getSelectListTheme } from "@earendil-works/pi-coding-agent";
2
- import { Input, SelectList, fuzzyFilter, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
+ import { Input, SelectList, fuzzyFilter, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
3
3
  import { CT } from "../types.js";
4
4
  import { UiActions, UiData } from "./data.js";
5
- import { callName, workflowName, doneOrder, isOpen, plainReason, toggleOpen, duration, keepSelection, summaryText, listRows, modelLabel, pendingText, resultPhrase, statusPhrase, rowText, toolCount } from "./view.js";
5
+ import { callName, workflowName, doneOrder, isOpen, plainReason, toggleOpen, duration, keepSelection, summaryText, listRows, modelColumn, modelLabel, pendingText, resultPhrase, statusPhrase, rowText, toolCount } from "./view.js";
6
6
  import { fitWidth, frame, inner } from "./frame.js";
7
7
  import { thinkingElapsed } from "./thinking.js";
8
8
  import { thoughtSummary } from "./session.js";
9
9
  const levels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
10
+ /** A command call runs a process: it takes no message and no model; only stop controls it. */
11
+ const isCommand = (c) => c?.command !== undefined;
12
+ const COMMAND_NOTE = "a command call takes no messages or model; x or /stop stops it";
13
+ /** The watch view's second head line of a command call: "running · pid 123 · 2m05s · <log>" / "failed · exit 3 · 41s". */
14
+ export function commandHead(c, w, now) {
15
+ const r = c.result, data = r?.data, log = c.commandRun?.log;
16
+ const ended = r ? [r.status, typeof data?.exitCode === "number" ? `exit ${data.exitCode}` : typeof data?.signal === "string" ? data.signal : "",
17
+ typeof data?.durationMs === "number" ? duration(data.durationMs) : ""] : [statusPhrase(c, w, undefined, now)];
18
+ return [...ended, log ?? ""].filter(Boolean).join(" · ");
19
+ }
20
+ /** The watch view's body of a command call: the whole command, then its result's output (the last 16 KiB of its log)
21
+ * once it ended, else where its output goes. */
22
+ export function commandTranscript(c, w, now) {
23
+ const lines = [`$ ${c.command ?? ""}`, ""];
24
+ if (c.result) {
25
+ if (c.result.error)
26
+ lines.push(c.result.error, "");
27
+ lines.push(...(c.result.output ? c.result.output.replace(/\n+$/, "").split("\n") : ["(no output)"]));
28
+ }
29
+ else if (c.phase === "queued")
30
+ lines.push(statusPhrase(c, w, undefined, now));
31
+ else
32
+ lines.push(`${statusPhrase(c, w, undefined, now)}${c.commandRun?.log ? `; output goes to ${c.commandRun.log}` : ""}`);
33
+ return lines;
34
+ }
35
+ /** One output line wrapped to the panel; control characters (also escape sequences a command printed) are dropped. */
36
+ const wrapLine = (line, width) => wrapTextWithAnsi(line.replace(/\t/g, " ").replace(/[\x00-\x08\x0b-\x1f\x7f]/g, ""), Math.max(1, width));
10
37
  /** UI §2–3: A single pi component owns list/watch navigation while the main agent keeps running. */
11
38
  const SPIN = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
12
39
  export class SubagentScreen {
@@ -174,6 +201,13 @@ export class SubagentScreen {
174
201
  const c = target ?? this.current().c;
175
202
  if (!c)
176
203
  return;
204
+ if (isCommand(c)) {
205
+ if (target)
206
+ this.listNotice = { text: COMMAND_NOTE, until: Date.now() + 5000 };
207
+ else
208
+ this.notice = COMMAND_NOTE;
209
+ return;
210
+ }
177
211
  this.menuTitle = `Model for ${c.key}`;
178
212
  const models = this.ctx.modelRegistry.getAvailable();
179
213
  this.menuItems = models.map(m => ({ value: `${m.provider}/${m.id}`, label: this.name(`${m.provider}/${m.id}`) }));
@@ -204,7 +238,7 @@ export class SubagentScreen {
204
238
  }
205
239
  thinkingMenu() {
206
240
  const { c } = this.current();
207
- if (!c)
241
+ if (!c || isCommand(c))
208
242
  return;
209
243
  const model = this.data.facts.get(c.callId)?.model ?? c.model;
210
244
  if (!model)
@@ -224,6 +258,10 @@ export class SubagentScreen {
224
258
  const { c } = this.current();
225
259
  if (!c)
226
260
  return;
261
+ if (isCommand(c)) {
262
+ this.notice = COMMAND_NOTE;
263
+ return;
264
+ }
227
265
  const facts = this.data.facts.get(c.callId), model = facts?.model ?? c.model;
228
266
  if (!model) {
229
267
  this.notice = "Model not yet recorded";
@@ -254,7 +292,11 @@ export class SubagentScreen {
254
292
  return;
255
293
  }
256
294
  if (message.startsWith("/")) {
257
- this.notice = "Commands: /model, /stop";
295
+ this.notice = isCommand(c) ? "Commands: /stop" : "Commands: /model, /stop";
296
+ return;
297
+ }
298
+ if (isCommand(c)) {
299
+ this.notice = COMMAND_NOTE;
258
300
  return;
259
301
  }
260
302
  const q = w.attention.find(a => a.kind === "question" && a.call === c.callId);
@@ -316,7 +358,9 @@ export class SubagentScreen {
316
358
  else if (!this.busy) {
317
359
  const row = this.selectedRow(), c = row?.kind === "call" ? row.call : undefined, w = row?.workflow;
318
360
  const asking = c && w?.attention.some(a => a.kind === "question" && a.call === c.callId);
319
- if (key === "s" && c && c.phase !== "sealed")
361
+ if (isCommand(c) && "sfam".includes(key))
362
+ this.listNotice = { text: COMMAND_NOTE, until: Date.now() + 5000 };
363
+ else if (key === "s" && c && c.phase !== "sealed")
320
364
  this.beginListInput("steer", row);
321
365
  else if (key === "f" && c?.phase === "sealed")
322
366
  this.beginListInput("follow-up", row);
@@ -379,7 +423,7 @@ export class SubagentScreen {
379
423
  // Panel coordinates: row 0 is the top border, column 2 is the first content column.
380
424
  if (event.y === 2) {
381
425
  const { c, w } = this.current();
382
- if (!c || !w)
426
+ if (!c || !w || isCommand(c))
383
427
  return;
384
428
  const facts = this.data.facts.get(c.callId), model = `${callName(w, c)} · ${this.name(facts?.model ?? c.model)} ▾ · `;
385
429
  const x = event.x - 2;
@@ -403,6 +447,8 @@ export class SubagentScreen {
403
447
  return this.input.handleMouse({ ...event, x: event.x - 2, y: 0 });
404
448
  }
405
449
  transcript(c, w, width) {
450
+ if (isCommand(c))
451
+ return { lines: commandTranscript(c, w, Date.now()).flatMap(line => line ? wrapLine(line, width) : [""]), thoughts: [] };
406
452
  const entries = this.data.sessions.get(c.callId) ?? [], lines = [], thoughts = [];
407
453
  const tools = new Map();
408
454
  // A `{ thought }` part is an expanded thinking block: like pi, a click anywhere on it collapses it again.
@@ -532,7 +578,7 @@ export class SubagentScreen {
532
578
  const rowWidth = Math.max(1, size.width - 2);
533
579
  this.rows = this.doneTab && w ? doneOrder(w.calls).map(c => {
534
580
  const f = this.data.facts.get(c.callId);
535
- return { id: c.callId, kind: "call", workflow: w, call: c, failed: !c.result?.ok, text: rowText(" ", callName(w, c), this.name(f?.model ?? c.model), resultPhrase(c), [toolCount(f?.tools)], rowWidth) };
581
+ return { id: c.callId, kind: "call", workflow: w, call: c, failed: !c.result?.ok, text: rowText(" ", callName(w, c), modelColumn(c, f, this.name), resultPhrase(c), [toolCount(f?.tools)], rowWidth) };
536
582
  }) : listRows(this.data.workflows, this.state, this.data.facts, this.name, rowWidth);
537
583
  height = this.height(Math.max(1, this.rows.length) + footerRows);
538
584
  size = inner(width, height); // inner width does not depend on height
@@ -549,10 +595,11 @@ export class SubagentScreen {
549
595
  const row = this.selectedRow(), c = row?.kind === "call" ? row.call : undefined;
550
596
  const asking = c && row?.workflow?.attention.some(a => a.kind === "question" && a.call === c.callId);
551
597
  const narrow = size.width < 72;
598
+ const agent = c && !isCommand(c);
552
599
  const keys = [narrow ? "↑↓" : "↑ ↓ select", row && row.kind !== "preview" ? `Enter ${narrow ? "" : row.kind === "workflow" ? (isOpen(row.workflow, this.state) ? "collapse" : "expand") : row.kind === "call" ? "watch" : "open"}`.trim() : "",
553
- c && c.phase !== "sealed" ? (narrow ? "s" : "s steer") : "", c?.phase === "sealed" ? (narrow ? "f" : "f follow-up") : "",
600
+ agent && c.phase !== "sealed" ? (narrow ? "s" : "s steer") : "", agent && c.phase === "sealed" ? (narrow ? "f" : "f follow-up") : "",
554
601
  c && c.phase !== "sealed" || row?.kind === "workflow" && row.workflow?.status === "running" ? (narrow ? "x" : "x stop") : "",
555
- c ? (narrow ? "m" : "m model") : "", asking ? (narrow ? "a" : "a answer") : "", row?.workflow?.paused ? (narrow ? "r" : "r resume") : "", "Esc back"].filter(Boolean).join(" · ");
602
+ agent ? (narrow ? "m" : "m model") : "", asking ? (narrow ? "a" : "a answer") : "", row?.workflow?.paused ? (narrow ? "r" : "r resume") : "", "Esc back"].filter(Boolean).join(" · ");
556
603
  const notice = this.listNotice && this.listNotice.until > Date.now() ? this.listNotice.text : "";
557
604
  const footer = this.listInput ? this.listInput.editor.render(size.width) : this.stopTarget ? [`Stop ${this.stopTarget.name}? y confirm · any other key cancels`] : notice ? [notice] : [];
558
605
  const body = this.rows.length ? lines.slice(0, Math.max(0, size.height - footer.length)) : ["No subagents"];
@@ -567,14 +614,16 @@ export class SubagentScreen {
567
614
  const tabs = size.width < 60 ? `${callName(w, c)} ${w.calls.indexOf(c) + 1}/${w.calls.length}` : `${[...active.map(c => callName(w, c)), ...(done ? [`${done} done`] : [])].join(" · ")} ← → switch`;
568
615
  const tools = toolCount(facts?.tools), pending = pendingText(c.pending), rule = this.theme.fg("borderMuted", "─".repeat(size.width));
569
616
  const switching = c.switching ? ` → ${this.name(c.switching)} (requested)` : "";
570
- const head = [tabs, `${callName(w, c)} · ${this.name(facts?.model ?? c.model)} ▾${switching} · ${facts?.thinking ?? "off"} ▾${tools ? ` · ${tools}` : ""}${pending ? ` · ${pending}` : ""}`,
571
- this.theme.fg("dim", this.spend(c, facts)), ...(c.phase === "queued" && c.answered ? [statusPhrase(c, w, facts, Date.now())] : []), rule];
617
+ // A command call shows its command, process and log instead of a model, thinking level and spend.
618
+ const head = isCommand(c) ? [tabs, `${callName(w, c)} · ${modelColumn(c, facts, this.name)}`, this.theme.fg("dim", commandHead(c, w, Date.now())), rule]
619
+ : [tabs, `${callName(w, c)} · ${this.name(facts?.model ?? c.model)} ▾${switching} · ${facts?.thinking ?? "off"} ▾${tools ? ` · ${tools}` : ""}${pending ? ` · ${pending}` : ""}`,
620
+ this.theme.fg("dim", this.spend(c, facts)), ...(c.phase === "queued" && c.answered ? [statusPhrase(c, w, facts, Date.now())] : []), rule];
572
621
  const asking = w.attention.some(a => a.kind === "question" && a.call === c.callId);
573
- const placeholder = `${c.phase === "sealed" ? "Continue" : asking ? "Reply to" : "Steer"} ${c.key}…${this.uses < 3 ? " / for commands" : ""}`;
622
+ const placeholder = isCommand(c) ? `${c.phase === "sealed" ? "Finished" : "Running"} command · /stop stops it` : `${c.phase === "sealed" ? "Continue" : asking ? "Reply to" : "Steer"} ${c.key}…${this.uses < 3 ? " / for commands" : ""}`;
574
623
  const empty = new Input({ prompt: "", placeholder, placeholderStyle: text => this.theme.fg("dim", text) });
575
624
  empty.focused = this.focused;
576
625
  const editor = this.input.getValue() ? this.input.render(size.width) : empty.render(size.width);
577
- const hint = this.input.getValue().startsWith("/") ? "/model · /stop" : this.notice;
626
+ const hint = this.input.getValue().startsWith("/") ? (isCommand(c) ? "/stop" : "/model · /stop") : this.notice;
578
627
  const transcript = this.transcript(c, w, size.width), available = Math.max(1, size.height - head.length - editor.length - 2);
579
628
  const bottom = Math.max(0, transcript.lines.length - available);
580
629
  // Scrolling back down to the end resumes following, as in pi's own transcript.
package/dist/ui/tool.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { Text } from "@earendil-works/pi-tui";
2
2
  import { plainReason, queuedPhrase } from "./view.js";
3
+ import { commandLine, commandText } from "../orchestrator/snapshot.js";
4
+ /** A step's agent, or "command" for a command step. */
5
+ const who = (s) => s.command !== undefined ? "command" : String(s.agent ?? "?");
3
6
  const short = (id) => typeof id === "string" ? (id.length > 12 ? `${id.slice(0, 10)}…` : id) : "";
4
7
  const clip = (s, n) => s.length > n ? `${s.slice(0, n - 1)}…` : s;
5
8
  /** UI §5: One line per tool call: what was asked, never the raw arguments (scripts and task prompts stay out of the transcript). */
@@ -8,15 +11,16 @@ export function callLine(args) {
8
11
  const agents = (list) => {
9
12
  const counts = new Map();
10
13
  for (const s of list)
11
- counts.set(String(s.agent ?? "?"), (counts.get(String(s.agent ?? "?")) ?? 0) + 1);
14
+ counts.set(who(s), (counts.get(who(s)) ?? 0) + 1);
12
15
  return [...counts].map(([a, n]) => n > 1 ? `${a}×${n}` : a).join(", ");
13
16
  };
14
17
  switch (args.action) {
15
18
  case "run": {
16
19
  const what = Array.isArray(args.tasks) ? `${steps.length} in parallel (${agents(steps)})`
17
- : Array.isArray(args.chain) ? `chain of ${steps.length} (${steps.map(s => String(s.agent ?? "?")).join(" → ")})`
20
+ : Array.isArray(args.chain) ? `chain of ${steps.length} (${steps.map(who).join(" → ")})`
18
21
  : typeof args.source === "string" ? `workflow script (${args.source.split("\n").length} lines)`
19
- : typeof args.workflow === "string" ? `workflow ${args.workflow}` : `${String(args.agent ?? "?")}: ${clip(String(args.task ?? "").split("\n")[0], 70)}`;
22
+ : typeof args.workflow === "string" ? `workflow ${args.workflow}`
23
+ : args.command !== undefined ? `command: ${clip(commandLine(commandText(args.command)), 70)}` : `${String(args.agent ?? "?")}: ${clip(String(args.task ?? "").split("\n")[0], 70)}`;
20
24
  return `run ${typeof args.name === "string" ? `${args.name} · ` : ""}${what}`;
21
25
  }
22
26
  case "send": return `send ${String(args.kind ?? "")} → ${String(args.to ?? "")}${typeof args.message === "string" ? `: ${clip(args.message.split("\n")[0], 70)}` : typeof args.model === "string" ? `: ${args.model}` : ""}`;
@@ -32,7 +36,7 @@ export function resultLines(details) {
32
36
  const d = (details ?? {});
33
37
  if (typeof d.wid === "string" && typeof d.key === "string" && typeof d.phase === "string") {
34
38
  const r = d.result;
35
- return [`${d.key} · ${r?.status ?? (d.phase === "queued" ? queuedPhrase(d, Date.now()) : d.phase)}${typeof d.model === "string" ? ` · ${d.model}` : ""}`];
39
+ return [`${d.key} · ${r?.status ?? (d.phase === "queued" ? queuedPhrase(d, Date.now()) : d.phase)}${typeof d.model === "string" ? ` · ${d.model}` : ""}${typeof d.command === "string" ? ` · command: ${commandLine(d.command, 60)}` : ""}`];
36
40
  }
37
41
  if (typeof d.wid === "string" && !Array.isArray(d.calls))
38
42
  return [`started workflow ${d.wid}`, ...(typeof d.paused === "string" ? [`⚠ ${d.paused}`] : [])];
package/dist/ui/view.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
- import { answerForwardedNote, isLive, queuedText, labelsText, liveCalls, ownedBy, progressOf } from "../orchestrator/snapshot.js";
2
+ import { answerForwardedNote, commandLine, isLive, queuedText, labelsText, liveCalls, ownedBy, progressOf } from "../orchestrator/snapshot.js";
3
3
  import { oneLine } from "./frame.js";
4
4
  /** UI §2: Render compact wall-clock durations; never present these as charged active time. */
5
5
  export function duration(ms) {
@@ -22,6 +22,10 @@ export function modelLabel(model, find, aliases = {}) {
22
22
  const named = (word) => Boolean(word) && new RegExp(`(^|[^a-z0-9])${word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^a-z0-9]|$)`, "i").test(name);
23
23
  return suffix.toLowerCase() === family || named(provider) || named(suffix) ? name : `${name} (${suffix})`;
24
24
  }
25
+ /** UI §2: The model column of a call: a command call shows its command instead ("command: npm test"). */
26
+ export function modelColumn(c, f, name) {
27
+ return c.command !== undefined ? `command: ${commandLine(c.command, 40)}` : name(f?.model ?? c.model);
28
+ }
25
29
  /** UI §2–3: Count committed tool calls compactly; zero is not shown. */
26
30
  export const toolCount = (n) => n ? `${n} tool${n === 1 ? "" : "s"}` : "";
27
31
  /** UI §3, P7: Messages sent to a call whose delivery the child has not confirmed yet; zero is not shown. */
@@ -130,6 +134,11 @@ export function statusPhrase(call, workflow, facts, now) {
130
134
  return `no activity for ${duration(now - Math.max(call.lastActivity ?? call.startedAt ?? now, facts?.lastActivity ?? 0))}`;
131
135
  if (call.phase === "queued")
132
136
  return workflow.paused ? "paused · r resumes" : queuedPhrase(call, now);
137
+ // A command call has no session: its process and how long it runs (from the start of its attempt).
138
+ if (call.command !== undefined) {
139
+ const run = call.commandRun, age = duration(Math.max(0, now - (call.startedAt ?? now)));
140
+ return run?.pid !== undefined ? `running · pid ${run.pid}${(run.attempt ?? 1) > 1 ? ` · attempt ${run.attempt}` : ""} · ${age}` : `starting · ${age}`;
141
+ }
133
142
  // Liveness (UI §2): the age of the newest evidence ticks, and resets whenever the agent does anything.
134
143
  const since = duration(Math.max(0, now - Math.max(call.lastActivity ?? 0, facts?.lastActivity ?? 0, call.startedAt ?? 0)));
135
144
  if (facts?.activity)
@@ -175,7 +184,8 @@ export function callName(w, c) {
175
184
  return `${c.key}${gen}`;
176
185
  const peers = keys.filter(k => GENERATED.test(k) && w.calls.find(x => x.key === k)?.agent === c.agent)
177
186
  .sort((a, b) => Number(GENERATED.exec(a)[1]) - Number(GENERATED.exec(b)[1]));
178
- return `${c.agent}${peers.length > 1 ? ` ${peers.indexOf(c.key) + 1}` : ""}${gen}`;
187
+ // A command call has no agent: it goes by "command" (numbered like an agent's when there are several).
188
+ return `${c.agent || (c.command !== undefined ? "command" : "")}${peers.length > 1 ? ` ${peers.indexOf(c.key) + 1}` : ""}${gen}`;
179
189
  }
180
190
  const WORDS = { ok: "done", stopped: "stopped", failed: "failed", "gate-failed": "failed", timeout: "timeout", budget: "budget", unknown: "unknown", skipped: "skipped", parked: "parked" };
181
191
  /** v12 §4: The result word of a sealed status — a stopped call is never called failed; timeout/budget/unknown are named as such. */
@@ -240,14 +250,15 @@ export function dockLines(workflows, facts, name, width, now = Date.now(), rows
240
250
  const line = ended && now - (ended.endedAt ?? 0) < 10 * 60_000 ? mainLine(workflows, now) : undefined;
241
251
  return line ? [truncateToWidth(line, Math.max(1, width))] : [];
242
252
  }
243
- const cols = { key: Math.min(20, Math.max(...active.map(a => visibleWidth(callName(a.w, a.c))))), model: Math.min(20, Math.max(...active.map(a => visibleWidth(name(facts.get(a.c.callId)?.model ?? a.c.model))))) };
253
+ const cols = { key: Math.min(20, Math.max(...active.map(a => visibleWidth(callName(a.w, a.c))))), model: Math.min(20, Math.max(...active.map(a => visibleWidth(modelColumn(a.c, facts.get(a.c.callId), name))))) };
244
254
  const shown = active.slice(0, rows);
245
255
  const lines = shown.map(({ w, c, asking }) => {
246
256
  // A running tool is activity; otherwise a minute without new evidence (no message, no tool) stops the spinner.
247
- const f = facts.get(c.callId), fresh = Boolean(f?.activity) || now - Math.max(c.lastActivity ?? 0, f?.lastActivity ?? 0, c.startedAt ?? 0) < 60_000;
257
+ // A running command call is busy as long as its process runs.
258
+ const f = facts.get(c.callId), fresh = Boolean(f?.activity) || c.command !== undefined && c.phase === "running" || now - Math.max(c.lastActivity ?? 0, f?.lastActivity ?? 0, c.startedAt ?? 0) < 60_000;
248
259
  const mark = asking ? "?" : c.phase === "queued" ? "·" : fresh ? SPIN[Math.floor(now / 500) % SPIN.length] : "…";
249
260
  const phrase = answerForwardedNote(c, now) || (asking ? `asks: ${w.attention.find(a => a.kind === "question" && a.call === c.callId).text}` : statusPhrase(c, w, f, now));
250
- return rowText(`${mark} `, callName(w, c), name(f?.model ?? c.model), phrase, [], width, cols);
261
+ return rowText(`${mark} `, callName(w, c), modelColumn(c, f, name), phrase, [], width, cols);
251
262
  });
252
263
  const more = active.length - shown.length;
253
264
  lines.push(truncateToWidth(`${more ? `+${more} more · ` : ""}${summaryText(workflows, now)} · ↓ subagents`, Math.max(1, width)));
@@ -290,11 +301,11 @@ export function listRows(workflows, state, facts, name, width, now = Date.now())
290
301
  // Aligned columns across the whole list (UI §2): key and model start at the same column on every row.
291
302
  const shownCalls = visible.flatMap(w => w.calls.map(c => ({ w, c })));
292
303
  const cols = { key: Math.min(24, Math.max(0, ...shownCalls.map(({ w, c }) => visibleWidth(callName(w, c))))),
293
- model: Math.min(26, Math.max(0, ...shownCalls.map(({ c }) => visibleWidth(name(facts.get(c.callId)?.model ?? c.model))))) };
304
+ model: Math.min(26, Math.max(0, ...shownCalls.map(({ c }) => visibleWidth(modelColumn(c, facts.get(c.callId), name))))) };
294
305
  const callRow = (w, c, indent, preview, dim = false) => {
295
306
  const f = facts.get(c.callId), age = c.phase === "sealed" ? `${duration(now - (c.endedAt ?? now))} ago` : c.startedAt ? duration(now - c.startedAt) : "";
296
307
  // A requested switch shows at once (it applies when the current step ends; until then it would look as if it had failed).
297
- const shown = c.switching ? `${name(f?.model ?? c.model)} → ${name(c.switching)}` : name(f?.model ?? c.model);
308
+ const shown = c.switching ? `${name(f?.model ?? c.model)} → ${name(c.switching)}` : modelColumn(c, f, name);
298
309
  const text = rowText(indent, callName(w, c), shown, statusPhrase(c, w, f, now), [pendingMarker(c.pending), toolCount(f?.tools), age], width, cols);
299
310
  rows.push({ id: c.callId, kind: "call", workflow: w, call: c, failed: Boolean(failed(c)), dim, text });
300
311
  // Overview (UI §2): every active agent shows what it last said, thought or saw, without opening it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-durable-subagents",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Subagents for pi that never lose work and never do it twice. Crash-safe workflows, automatic recovery, and a live view just like the main agent.",
5
5
  "type": "module",
6
6
  "license": "MIT",