@krapht/ork 1.0.0-alpha.20 → 1.0.0-alpha.21

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.
Files changed (52) hide show
  1. package/dist/{__build_info__-D6mXC4cD.mjs → __build_info__-0wqQ-rtf.mjs} +3 -51
  2. package/dist/{attach-C1OnxyMh.mjs → attach-C0-YyNoY.mjs} +6 -6
  3. package/dist/{attach-CEGbRg1D.mjs → attach-CAKNqnUK.mjs} +64 -35
  4. package/dist/bin.mjs +1426 -72
  5. package/dist/{brief-DH66xmj8.mjs → brief-C2hew8cS.mjs} +7 -6
  6. package/dist/{builtin-files-Cf-NZDqM.mjs → builtin-files-YYAnbZGD.mjs} +1 -1
  7. package/dist/{chips-BqcT58qr.mjs → chips-CP_pgKlj.mjs} +7 -2
  8. package/dist/{completion-DS0gCZRm.mjs → completion-K4rAVsrf.mjs} +6 -6
  9. package/dist/{context-CGPh12HV.mjs → context-B-fjPJky.mjs} +4 -4
  10. package/dist/context-DMK0U1w0.mjs +160 -0
  11. package/dist/{detached-Dakw5RZj.mjs → detached-q0AYG0Bs.mjs} +6 -5
  12. package/dist/{find-BTikxc54.mjs → find-Ct5CNl1J.mjs} +1 -1
  13. package/dist/{flags-C8yCq0j5.mjs → flags-C90N4J1i.mjs} +3 -3
  14. package/dist/{follow-ups-CtlhHbwe.mjs → follow-ups-D3HPyNYM.mjs} +14 -9
  15. package/dist/{format-BB4E-T6x.mjs → format-CiPhQqbX.mjs} +24 -13
  16. package/dist/{help-groups-BpRgBSTh.mjs → help-groups-BQvcKQ9H.mjs} +8 -3
  17. package/dist/{in-a-run-CbnKjO7t.mjs → in-a-run-D_wg4iJi.mjs} +2 -2
  18. package/dist/{install-CWcpX5g4.mjs → install-Hji6LIei.mjs} +50 -2
  19. package/dist/{limits-VQqsBoQk.mjs → limits-BD6RZRCS.mjs} +1 -1
  20. package/dist/{mcp-wGfkMCVF.mjs → mcp-CpbDmBLG.mjs} +6 -6
  21. package/dist/{once-BHxSdZz_.mjs → once-J8Qn5fTG.mjs} +4 -4
  22. package/dist/{output-B1kwo0YU.mjs → output-DXZbnFt_.mjs} +61 -42
  23. package/dist/{pause-C_Wxh-KM.mjs → pause-Cl4ZYA35.mjs} +4 -4
  24. package/dist/{print-DNYzq4Rr.mjs → print-DzugGZQB.mjs} +2 -2
  25. package/dist/{project-records-XY3ku95x.mjs → project-records-CtkmlsHN.mjs} +3 -3
  26. package/dist/{relay-BA6tsnpc.mjs → relay-CiP77vga.mjs} +2 -2
  27. package/dist/{run-Bvvg-fiF.mjs → run-CtuNY3mE.mjs} +1 -1
  28. package/dist/{send-nrKtak5F.mjs → send-DRYGks8K.mjs} +3 -4
  29. package/dist/short-flags-DkJLWVqh.mjs +1 -0
  30. package/dist/short-flags-Qf21as0E.mjs +83 -0
  31. package/dist/{src-D4JSymhK.mjs → src-BMFQKHz4.mjs} +32 -14
  32. package/dist/{src-CmEvHdju.mjs → src-BrFfDKux.mjs} +8 -7
  33. package/dist/{src-8cOPOgrT.mjs → src-BuF9Lbow.mjs} +77 -18
  34. package/dist/{src-I_RyKu6_.mjs → src-k0A_QpST.mjs} +5 -3
  35. package/dist/store-rTgRu8xy.mjs +25 -0
  36. package/dist/ui/assets/app-BYxpKJRh.css +1 -0
  37. package/dist/ui/assets/{app-BowhjEAe.js → app-SEFEJLkF.js} +8 -8
  38. package/dist/ui/assets/{index-CrMa2oHB.js → index-Cb6Voq_W.js} +2 -2
  39. package/dist/ui/index.html +1 -1
  40. package/dist/{ui-DY3Dnpho.mjs → ui-C2f37TSb.mjs} +9 -6
  41. package/dist/{usage-1VwSg_Qt.mjs → usage-BuvGcQSk.mjs} +6 -7
  42. package/dist/validate-ObP5lt29.mjs +1 -0
  43. package/dist/{validate-BxayjjkV.mjs → validate-_HjACtk9.mjs} +6 -6
  44. package/dist/{verdict-CMvPCpWC.mjs → verdict-B592j1W3.mjs} +2 -2
  45. package/dist/{watch-CT0EtLPZ.mjs → watch-DV3ixCYj.mjs} +7 -7
  46. package/dist/{workflows-DHHi-APg.mjs → workflows-QLjBhGNS.mjs} +3 -3
  47. package/dist/{worktrees-CZvbHzbN.mjs → worktrees-D3ubG_Qw.mjs} +6 -6
  48. package/dist/yolo-BSH1E_kE.mjs +33 -0
  49. package/package.json +1 -1
  50. package/dist/run-DBUAq-Uu.mjs +0 -1452
  51. package/dist/store-CDpk8Wtz.mjs +0 -16
  52. package/dist/ui/assets/app--FijEXiJ.css +0 -1
@@ -1,55 +1,7 @@
1
- import { E as parseVersion, T as isNewer, w as compareVersions } from "./src-8cOPOgrT.mjs";
1
+ import { E as parseVersion, T as isNewer, w as compareVersions } from "./src-BuF9Lbow.mjs";
2
2
  import path from "node:path";
3
3
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
- // ../core/src/remote/session.ts
6
- const chattable = (type) => type === "agent.leader" || type === "agent.worker";
7
- /** Reads `node`'s session from a run's events, and every node's last output. */
8
- const nodeSession = (events, node) => {
9
- const session = {
10
- known: false,
11
- chattable: false,
12
- running: false
13
- };
14
- const outputs = {};
15
- for (const { event } of events) {
16
- if (event.type === "run.started") {
17
- const declared = event.nodes.find((n) => n.id === node);
18
- if (declared !== void 0) {
19
- session.known = true;
20
- session.chattable = chattable(declared.type);
21
- }
22
- }
23
- if (event.type === "node.finished") outputs[event.id] = event.output;
24
- if (!("id" in event) || event.id !== node) continue;
25
- if (event.type === "node.started") {
26
- session.known = true;
27
- session.chattable = chattable(event.nodeType);
28
- session.running = true;
29
- }
30
- if (event.type === "node.finished") session.running = false;
31
- if (event.type === "worktree" && event.action === "created") session.checkout = {
32
- path: event.path,
33
- ...event.branch === void 0 ? {} : { branch: event.branch },
34
- own: true,
35
- owner: node
36
- };
37
- if (event.type !== "node.event") continue;
38
- const inner = event.event;
39
- if (inner.fork === true) continue;
40
- if (inner.type === "session.started") {
41
- session.sessionId = inner.sessionId;
42
- if (inner.cwd !== void 0) session.cwd = inner.cwd;
43
- if (inner.driver !== void 0) session.driver = inner.driver;
44
- if (inner.model !== "") session.model = inner.model;
45
- }
46
- if (inner.type === "session.finished" && inner.outcome.sessionId !== "") session.sessionId = inner.outcome.sessionId;
47
- }
48
- return {
49
- session,
50
- outputs
51
- };
52
- };
53
5
  /** The dist-tags every install follows, toward and after 1.0.0. */
54
6
  const CHANNEL_TAGS = [
55
7
  "latest",
@@ -224,5 +176,5 @@ const registryShown = (registry) => {
224
176
  * fails when it is stale.
225
177
  */
226
178
  const ORK_NAME = "@krapht/ork";
227
- const ORK_VERSION = "1.0.0-alpha.20";
228
- export { registryShown as a, fetchLatest as c, readUpdateCache as d, refreshUpdateCache as f, nodeSession as h, registryOf as i, newerVersion as l, writeUpdateCache as m, ORK_VERSION as n, updateSwitchOff as o, updateCachePath as p, isSwitchedOn as r, checkDue as s, ORK_NAME as t, pendingNotice as u };
179
+ const ORK_VERSION = "1.0.0-alpha.21";
180
+ export { registryShown as a, fetchLatest as c, readUpdateCache as d, refreshUpdateCache as f, registryOf as i, newerVersion as l, writeUpdateCache as m, ORK_VERSION as n, updateSwitchOff as o, updateCachePath as p, isSwitchedOn as r, checkDue as s, ORK_NAME as t, pendingNotice as u };
@@ -1,10 +1,10 @@
1
- import "./src-8cOPOgrT.mjs";
2
- import { t as findRun } from "./find-BTikxc54.mjs";
3
- import { c as write, l as writeErr, s as style } from "./output-B1kwo0YU.mjs";
4
- import { m as createTerminalHuman, t as attachRun } from "./attach-CEGbRg1D.mjs";
5
- import { n as attachRefusal } from "./in-a-run-CbnKjO7t.mjs";
1
+ import "./src-BuF9Lbow.mjs";
2
+ import { t as findRun } from "./find-Ct5CNl1J.mjs";
3
+ import { c as write, l as writeErr, s as style } from "./output-DXZbnFt_.mjs";
4
+ import { m as createTerminalHuman, t as attachRun } from "./attach-CAKNqnUK.mjs";
5
+ import { n as attachRefusal } from "./in-a-run-D_wg4iJi.mjs";
6
6
  import { t as refuseExtraArguments } from "./extra-arguments-BxQMXARO.mjs";
7
- import { t as withStore } from "./store-CDpk8Wtz.mjs";
7
+ import { t as withStore } from "./store-rTgRu8xy.mjs";
8
8
  import { defineCommand } from "citty";
9
9
  // src/commands/attach.ts
10
10
  /**
@@ -1,9 +1,9 @@
1
- import { Er as TOOL_INPUT_KEYS, L as isNodeEvent, Nt as lockWaitLine, Or as maskReplacer, at as followRunTree, ft as DETACHED_ENV, ir as END_KINDS, kr as maskSecrets, mt as followEvents, nr as outcomeEnd, ot as answerDecision, st as pendingDecisions, tr as endOf, zt as slotWaitLine } from "./src-8cOPOgrT.mjs";
1
+ import { Ar as maskReplacer, L as isNodeEvent, Nt as lockWaitLine, Or as TOOL_INPUT_KEYS, Pn as liveStatus, at as followRunTree, ft as DETACHED_ENV, ir as outcomeEnd, jr as maskSecrets, mt as followEvents, or as END_KINDS, ot as answerDecision, rr as endOf, st as pendingDecisions, zt as slotWaitLine } from "./src-BuF9Lbow.mjs";
2
2
  import { t as applyFilters } from "./apply-Mb0fNpCX.mjs";
3
3
  import { t as outputsText } from "./outputs-text-CNTJ7Qq_.mjs";
4
- import { C as termOf, D as wrap, E as widthOf, O as readKeys, _ as interrupt, a as plain, b as canKey, g as createRegion, h as paint, m as bold, n as cost, p as apply, r as costOf, s as style, u as confirmOrStop, v as readLine, w as cut, x as plainEnv, y as withdrawn } from "./output-B1kwo0YU.mjs";
5
- import { n as chip, r as nodeChip, t as CHIP_LABELS } from "./chips-BqcT58qr.mjs";
6
- import { a as createView, i as formatBusEvent, n as nodeVerdict, o as styler, r as firstLine, t as hasConflict } from "./verdict-CMvPCpWC.mjs";
4
+ import { C as readKeys, D as apply, O as bold, S as wrap, a as plain, d as createRegion, f as interrupt, g as plainEnv, h as canKey, k as paint, m as withdrawn, n as cost, p as readLine, r as costOf, s as style, u as confirmOrStop, v as termOf, w as barred, x as widthOf, y as cut } from "./output-DXZbnFt_.mjs";
5
+ import { i as nodeChip, n as askChip, r as chip, t as CHIP_LABELS } from "./chips-CP_pgKlj.mjs";
6
+ import { a as createView, i as formatBusEvent, n as nodeVerdict, o as styler, r as firstLine, t as hasConflict } from "./verdict-B592j1W3.mjs";
7
7
  import { z } from "zod";
8
8
  import { createInterface } from "node:readline/promises";
9
9
  // src/human-card.ts
@@ -39,7 +39,7 @@ const cardLines = (t, q, place, verbose, document) => {
39
39
  return {
40
40
  lines: [
41
41
  "",
42
- ` ${chip(t, CHIP_LABELS.ask, "accent")} ${nodeChip(t, plain(q.nodeId))}${where}`,
42
+ ` ${askChip(t)} ${nodeChip(t, plain(q.nodeId))}${where}`,
43
43
  ...wrap(clean(q.question), t.width - 1).map((l) => ` ${bold(t, l)}`),
44
44
  ...body.map((l) => paint(t, "muted", ` ${l}`)),
45
45
  ...cutShort ? [paint(t, "muted", ` … ${String(shown.length - CONTEXT_LINES)} more lines (d)`)] : []
@@ -53,7 +53,7 @@ const permitLine = (t, nodeId, preview) => {
53
53
  const what = plain(preview);
54
54
  if (!t.rich) return `? ${node} wants to run ${what}`;
55
55
  const room = Math.max(20, t.width - node.length - 24);
56
- return ` ${chip(t, CHIP_LABELS.ask, "accent")} ${nodeChip(t, node)} wants to run ${cut(what, room)}`;
56
+ return `${apply(t, "greenBright", "▌")}${askChip(t)} ${nodeChip(t, node)} wants to run ${cut(what, room)}`;
57
57
  };
58
58
  /**
59
59
  * The line a card collapses to once answered: `✓ 509da722-1 · add-invalid-node`
@@ -66,6 +66,41 @@ const doneLine = (t, place, nodeId, answer) => {
66
66
  const said = answer.note === void 0 ? "" : ` · said: ${plain(answer.note)}`;
67
67
  return ` ${paint(t, "ok", "✓")} ${cut(`${who} · ${answer.id}${said}`, t.width - 3)}`;
68
68
  };
69
+ // src/term/option-name.ts
70
+ /**
71
+ * @file The select prompt's options: how one is named (its label, then its id
72
+ * dimmed in parentheses, `Allow (allow)`, or its id alone), the numbered
73
+ * lines of the plain prompt (`1) label (id) - description`), and which option
74
+ * a typed answer names.
75
+ */
76
+ const asIs = (text) => text;
77
+ /**
78
+ * An option's name in at most `width` columns: its label, then its id (what
79
+ * `ork decide --choose` and a plain prompt take) dimmed in parentheses; the id
80
+ * alone when it has no label.
81
+ */
82
+ const nameOf = (t, option, width, look = asIs) => {
83
+ if (width < 1) return "";
84
+ if (option.label === void 0) return look(cut(option.id, width));
85
+ const head = cut(option.label, width);
86
+ const room = width - widthOf(head);
87
+ return room <= 1 ? look(head) : `${look(head)}${paint(t, "muted", cut(` (${option.id})`, room))}`;
88
+ };
89
+ /** The numbered option lines of a plain prompt: ` 1) label (id) - description`. */
90
+ const plainOptions = (options, recommended) => options.map((option, i) => {
91
+ const description = option.description === void 0 ? "" : ` - ${option.description}`;
92
+ const mark = option.id === recommended ? " (recommended)" : "";
93
+ const name = option.label === void 0 ? option.id : `${option.label} (${option.id})`;
94
+ return ` ${String(i + 1)}) ${name}${description}${mark}`;
95
+ });
96
+ /** The option an answer names: its number, or its id; empty is `recommended`. */
97
+ const pickOption = (answer, options, recommended) => {
98
+ const value = answer.trim();
99
+ if (value === "") return recommended;
100
+ const index = Number(value);
101
+ if (Number.isInteger(index) && index >= 1 && index <= options.length) return options[index - 1]?.id;
102
+ return options.find((o) => o.id === value)?.id;
103
+ };
69
104
  // src/term/text.ts
70
105
  /**
71
106
  * @file The text prompt: one line of text, edited in place on a terminal
@@ -191,32 +226,18 @@ const readText = async (io, options) => {
191
226
  * in place), `d` shows or hides the details (a document), `q` or Esc leaves
192
227
  * the question for later, Ctrl-C stops. It redraws only its own lines,
193
228
  * follows a resize, and collapses to one line once answered. Plain mode
194
- * prints the options as `1) id label - description` and asks `Choose [n]: `,
195
- * as `ork decide` always did; there a note is asked for after the choice when
196
- * the prompt takes one.
229
+ * prints the options as `1) label (id) - description` and asks `Choose [n]:
230
+ * `, as `ork decide` always did; there a note is asked for after the choice
231
+ * when the prompt takes one, and `q` or an ended input leaves the question
232
+ * for later where it may wait.
197
233
  */
198
234
  const NOTE_PROMPT = "Note for the run (optional, Enter to skip)";
199
- /** The option an answer names: its number, or its id; empty is `recommended`. */
200
- const pickOption = (answer, options, recommended) => {
201
- const value = answer.trim();
202
- if (value === "") return recommended;
203
- const index = Number(value);
204
- if (Number.isInteger(index) && index >= 1 && index <= options.length) return options[index - 1]?.id;
205
- return options.find((o) => o.id === value)?.id;
206
- };
207
- const label = (option) => option.label === void 0 ? option.id : `${option.id} ${option.label}`;
208
235
  const defaultDone = (options) => (result, term) => {
209
236
  if (result.kind === "later") return ` ${paint(term, "muted", "·")} left for later`;
210
237
  const option = options.find((o) => o.id === result.id);
211
- return cut(` ${paint(term, "ok", "✓")} ${option === void 0 ? result.id : label(option)}`, term.width);
238
+ const name = option === void 0 ? cut(result.id, term.width - 3) : nameOf(term, option, term.width - 3);
239
+ return ` ${paint(term, "ok", "✓")} ${name}`;
212
240
  };
213
- /** The numbered option lines of a plain prompt: ` 1) id label - description`. */
214
- const plainOptions = (options, recommended) => options.map((option, i) => {
215
- const description = option.description === void 0 ? "" : ` - ${option.description}`;
216
- const mark = option.id === recommended ? " (recommended)" : "";
217
- const name = option.label === void 0 ? "" : ` ${option.label}`;
218
- return ` ${String(i + 1)}) ${option.id}${name}${description}${mark}`;
219
- });
220
241
  /** The plain prompt: numbered options, then `Choose [n]: ` until one fits. */
221
242
  const selectPlain = (io, o) => {
222
243
  const term = termOf(io.output, io.env);
@@ -230,8 +251,12 @@ const selectPlain = (io, o) => {
230
251
  const hint = at === -1 ? "" : ` [${String(at + 1)}]`;
231
252
  const ask = async () => {
232
253
  const answer = await readLine(io, ` Choose${hint}: `, o.signal);
233
- if (answer === void 0) throw new Error("input ended");
254
+ if (answer === void 0) {
255
+ if (o.later === true) return { kind: "later" };
256
+ throw new Error("input ended");
257
+ }
234
258
  const id = pickOption(answer, o.options, o.recommended);
259
+ if (id === void 0 && o.later === true && answer.trim() === "q") return { kind: "later" };
235
260
  if (id === void 0) {
236
261
  if (o.details !== void 0 && answer.trim() === "d") say(o.details);
237
262
  else say(" Type an option's number or id.");
@@ -273,8 +298,10 @@ const select = (io, o) => {
273
298
  const selected = i === cursor;
274
299
  const number = i < 9 ? `${String(i + 1)}.` : " ";
275
300
  const mark = option.id === o.recommended ? " (recommended)" : "";
276
- const head = cut(`${number} ${label(option)}`, t.width - 4 - mark.length);
277
- const text = selected ? apply(t, ["bold", "cyan"], head) : head;
301
+ const look = selected ? (text) => apply(t, ["bold", "cyan"], text) : asIs;
302
+ const room = t.width - 4 - mark.length;
303
+ const prefix = cut(`${number} `, room);
304
+ const text = `${look(prefix)}${nameOf(t, option, room - widthOf(prefix), look)}`;
278
305
  const lines = [` ${selected ? paint(t, "accent", "❯") : " "} ${text}${mark === "" ? "" : paint(t, "ok", mark)}`];
279
306
  for (const line of wrap(option.description ?? "", t.width - 7)) if (line !== "") lines.push(paint(t, "muted", ` ${line}`));
280
307
  return lines;
@@ -308,12 +335,12 @@ const select = (io, o) => {
308
335
  keyLine(t)
309
336
  ];
310
337
  if (editing === void 0) {
311
- region.draw(lines);
338
+ region.draw(barred(t, lines));
312
339
  return;
313
340
  }
314
341
  const lead = ` ${paint(t, "accent", "✎")} Note › `;
315
342
  const { line, column } = showLine(lead, editing, t.width, 10);
316
- region.draw([...lines, line], column);
343
+ region.draw(barred(t, [...lines, line]), column);
317
344
  };
318
345
  const finish = (result) => {
319
346
  stop();
@@ -832,7 +859,8 @@ const ANSWERED_BY = {
832
859
  terminal: "terminal",
833
860
  decide: "ork decide",
834
861
  ui: "ork ui",
835
- owner: "its owner"
862
+ owner: "its owner",
863
+ yolo: "yolo: not asked"
836
864
  };
837
865
  /** The transcript lines for one event; tool names come from `tools`. */
838
866
  const formatEvent = (nodeId, event, tools, verbose = false, view = createView(), room = view.term.width - 1) => {
@@ -864,8 +892,9 @@ const formatRunEvent = (event, width, tools, terminal = false, verbose = false,
864
892
  const under = (id, lines) => lines.map((line, i) => `${i === 0 ? tag(id) : blank(id)} ${line}`);
865
893
  if (event.type === "run.started") {
866
894
  const starts = `starts at ${event.entries.join(", ")}`;
895
+ const yolo = event.settings?.yolo === true ? " · yolo" : "";
867
896
  return [
868
- term.rich ? `${chip(term, CHIP_LABELS.run, "accent")} run ${style("bold", event.runId)} of ${event.workflow} ${style("dim", starts)}` : style("dim", `▸ run ${event.runId} of ${event.workflow} (${starts})`),
897
+ term.rich ? `${chip(term, CHIP_LABELS.run, "accent")} run ${style("bold", event.runId)} of ${event.workflow} ${style("dim", starts)}${style("yellow", yolo)}` : `${style("dim", `▸ run ${event.runId} of ${event.workflow} (${starts})`)}${yolo}`,
869
898
  ...event.settings?.trigger === void 0 ? [] : [style("dim", ` started by trigger ${event.settings.trigger}; untrusted inputs: ${(event.settings.untrusted ?? []).join(", ") || "none"}`)],
870
899
  ...term.rich ? [""] : []
871
900
  ];
@@ -1013,7 +1042,7 @@ const followRun = async (store, run, out, options) => {
1013
1042
  ...options.intervalMs === void 0 ? {} : { intervalMs: options.intervalMs },
1014
1043
  ...options.home === void 0 ? {} : { home: options.home },
1015
1044
  ...options.signal === void 0 ? {} : { signal: options.signal }
1016
- }) === "crashed") out(style("red", `run ${run.id} stopped without finishing (its process is gone)`));
1045
+ }) === "crashed" || !options.follow && liveStatus(run) === "crashed") out(style("red", `run ${run.id} crashed: its process is gone`));
1017
1046
  };
1018
1047
  // src/runs/gutter.ts
1019
1048
  /**
@@ -1220,7 +1249,7 @@ const attachRun = async (store, root, out, options = {}) => {
1220
1249
  });
1221
1250
  prompts?.abort();
1222
1251
  await prompts?.settled();
1223
- if (end === "crashed") show(basePath, [say("red", `run ${root} stopped without finishing (its process is gone)`)]);
1252
+ if (end === "crashed") show(basePath, [say("red", `run ${root} crashed: its process is gone`)]);
1224
1253
  for (const id of stillRunning) out(say("dim", `↳ run ${id} still running · ork attach ${id}`));
1225
1254
  return {
1226
1255
  stillRunning,