@krapht/ork 1.0.0-alpha.10 → 1.0.0-alpha.12

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 (41) hide show
  1. package/dist/{__build_info__-DFF18K8y.mjs → __build_info__-BJbE3Zvp.mjs} +4 -72
  2. package/dist/attach-BmV5ckb9.mjs +89 -0
  3. package/dist/bin.mjs +467 -864
  4. package/dist/{decide-3l9q8UtX.mjs → builtin-files-w0YULJ4c.mjs} +2 -50
  5. package/dist/chips-CyeB_rhR.mjs +43 -0
  6. package/dist/{clean-DVaEH9e7.mjs → clean-D8GI_2K-.mjs} +1 -1
  7. package/dist/{completion-Dv5kf598.mjs → completion-CzElB8nS.mjs} +24 -16
  8. package/dist/{context-CEaKOVmG.mjs → context-BAwgVSX5.mjs} +43 -31
  9. package/dist/decide-DlbyctOE.mjs +50 -0
  10. package/dist/{find-DEjjOlTG.mjs → find-p05wlbmu.mjs} +1 -1
  11. package/dist/format-Dni98cbh.mjs +206 -0
  12. package/dist/{help-groups-BwYoAWsh.mjs → help-groups-DYP_zMRP.mjs} +4 -0
  13. package/dist/{in-a-run-BS9Nc-JW.mjs → in-a-run-BI-hLIl_.mjs} +4 -2
  14. package/dist/{limits-BSwEjQST.mjs → limits-CElmhowV.mjs} +1 -1
  15. package/dist/{list-Qxr6rwsY.mjs → list-zW2xKuGr.mjs} +1 -1
  16. package/dist/{mcp-CslnG5wf.mjs → mcp-CM3b65AZ.mjs} +6 -6
  17. package/dist/output-CnRzrbUM.mjs +423 -0
  18. package/dist/{pause-D7OVB5Ac.mjs → pause-BuS83WAI.mjs} +4 -4
  19. package/dist/{relay-EceRIebO.mjs → relay-DAsJA8wF.mjs} +2 -2
  20. package/dist/{remove-0IQZVWmI.mjs → remove-Dh7D_hVn.mjs} +3 -3
  21. package/dist/{report-DK4LGqwF.mjs → report-CEN8VoUb.mjs} +31 -20
  22. package/dist/{send-C0uwfUYi.mjs → send-MFEQZH31.mjs} +3 -3
  23. package/dist/{src-cmmXKHn1.mjs → src-BfxkJOYm.mjs} +234 -150
  24. package/dist/{src-Df6KOIDC.mjs → src-CdDTQLdQ.mjs} +2081 -1035
  25. package/dist/{src-oaJYIddp.mjs → src-D1QedD5y.mjs} +523 -81
  26. package/dist/{src-i5k2Y-kf.mjs → src-S9yK2OHU.mjs} +79 -11
  27. package/dist/store-B2OaE4ID.mjs +1356 -0
  28. package/dist/ui/assets/{app-qs8Lofv6.js → app-CAoZtku5.js} +16 -16
  29. package/dist/ui/assets/app-QoHVi-mb.css +1 -0
  30. package/dist/ui/assets/{index-DV1ZaOk-.js → index-BL7Ad0OA.js} +2 -2
  31. package/dist/ui/index.html +1 -1
  32. package/dist/{ui-CBkHJdqk.mjs → ui-C4Ys26oO.mjs} +4 -4
  33. package/dist/{usage-Cd8pEYyK.mjs → usage-C2zx-X6q.mjs} +43 -32
  34. package/dist/verdict-CIy8tAyX.mjs +84 -0
  35. package/dist/{watch-DW5R2OPO.mjs → watch-DzCeqM05.mjs} +28 -16
  36. package/dist/{workflows-BT1gDRIV.mjs → workflows-Rr5w90A0.mjs} +3 -3
  37. package/dist/{worktrees-g1MQMGie.mjs → worktrees-f6SAbum5.mjs} +11 -10
  38. package/package.json +1 -1
  39. package/dist/format-Cb5_m-Qd.mjs +0 -191
  40. package/dist/output-Bqljtmp_.mjs +0 -40
  41. package/dist/ui/assets/app-C8uhHVYp.css +0 -1
@@ -1,4 +1,4 @@
1
- import { $t as targetOf, An as inside, Ct as runTree, Fn as plainPathInside, Ht as FEEDBACK_KINDS, In as writePlainFile, Mn as LESSON_CAP_TOKENS, Nn as estimateTokens, Pn as guardedBase, Tn as placeFor, Ut as FEEDBACK_SEVERITIES, Yt as publishPost, Zt as fingerprint, g as parseVersion, h as isNewer, m as compareVersions, un as maskSecrets, wn as placeFiles } from "./src-Df6KOIDC.mjs";
1
+ import { Bn as placeFiles, En as maskSecrets, Jn as LESSON_CAP_TOKENS, Kn as inside, Qn as writePlainFile, Vn as placeFor, Xn as guardedBase, Yn as estimateTokens, Zn as plainPathInside, an as FEEDBACK_SEVERITIES, d as parseVersion, dn as publishPost, hn as targetOf, in as FEEDBACK_KINDS, l as compareVersions, pn as fingerprint, u as isNewer } from "./src-CdDTQLdQ.mjs";
2
2
  import path from "node:path";
3
3
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
4
4
  import { homedir } from "node:os";
@@ -402,6 +402,7 @@ const nodeSession = (events, node) => {
402
402
  session.sessionId = inner.sessionId;
403
403
  if (inner.cwd !== void 0) session.cwd = inner.cwd;
404
404
  if (inner.driver !== void 0) session.driver = inner.driver;
405
+ if (inner.model !== "") session.model = inner.model;
405
406
  }
406
407
  if (inner.type === "session.finished" && inner.outcome.sessionId !== "") session.sessionId = inner.outcome.sessionId;
407
408
  }
@@ -410,75 +411,6 @@ const nodeSession = (events, node) => {
410
411
  outputs
411
412
  };
412
413
  };
413
- // ../core/src/store/activity.ts
414
- const LONGEST_LINE = 120;
415
- /**
416
- * The fields of a tool's input that say what it's working on, best first. Only
417
- * these are shown, so what else a tool was given stays in the logs.
418
- */
419
- const TARGETS = [
420
- "file_path",
421
- "notebook_path",
422
- "path",
423
- "url",
424
- "pattern",
425
- "query",
426
- "command"
427
- ];
428
- const oneLine = (text) => {
429
- const line = text.replaceAll(/\s+/gu, " ").trim();
430
- return line.length > LONGEST_LINE ? `${line.slice(0, 119)}…` : line;
431
- };
432
- const toolLine = ({ name, input }) => {
433
- const target = TARGETS.map((field) => input[field]).find((value) => typeof value === "string" && value.trim() !== "");
434
- if (typeof target !== "string") return name;
435
- return oneLine(target.startsWith(`${name} `) ? target : `${name} ${target}`);
436
- };
437
- /** What a finished node said, or why it failed. */
438
- const finishedNow = (ok, error, summary) => {
439
- if (!ok) return error === void 0 ? void 0 : oneLine(error);
440
- return typeof summary === "string" && summary.trim() !== "" ? oneLine(summary) : void 0;
441
- };
442
- /** Each node's activity, by id; a node that never started has none. */
443
- const runActivity = (stored) => {
444
- const nodes = /* @__PURE__ */ new Map();
445
- const of = (id) => {
446
- const found = nodes.get(id);
447
- if (found !== void 0) return found;
448
- const fresh = {};
449
- nodes.set(id, fresh);
450
- return fresh;
451
- };
452
- for (const { at, event } of stored) if (event.type === "node.started") {
453
- const node = of(event.id);
454
- node.startedAt ??= at;
455
- delete node.finishedAt;
456
- delete node.now;
457
- } else if (event.type === "node.event") {
458
- if (event.event.type === "tool.called") of(event.id).now = toolLine(event.event);
459
- } else if (event.type === "decision.opened") of(event.node).now = oneLine(`Asked: ${event.question}`);
460
- else if (event.type === "decision.answered") of(event.node).now = oneLine(`Answered: ${event.answer}`);
461
- else if (event.type === "decision.withdrawn") delete of(event.node).now;
462
- else if (event.type === "node.finished") {
463
- const node = of(event.id);
464
- node.finishedAt = at;
465
- const now = finishedNow(event.ok, event.error, event.output["summary"]);
466
- if (now === void 0) delete node.now;
467
- else node.now = now;
468
- }
469
- return nodes;
470
- };
471
- /** The ownership tree, with what each node is doing and when it ran. */
472
- const activeTree = (stored) => {
473
- const activity = runActivity(stored);
474
- const dress = (node) => {
475
- Object.assign(node, activity.get(node.id));
476
- for (const child of node.children) dress(child);
477
- };
478
- const roots = runTree(stored.map(({ event }) => event));
479
- for (const root of roots) dress(root);
480
- return roots;
481
- };
482
414
  /** The dist-tags every install follows, toward and after 1.0.0. */
483
415
  const CHANNEL_TAGS = [
484
416
  "latest",
@@ -680,5 +612,5 @@ const registryShown = (registry) => {
680
612
  * fails when it is stale.
681
613
  */
682
614
  const ORK_NAME = "@krapht/ork";
683
- const ORK_VERSION = "1.0.0-alpha.10";
684
- export { placeOf as C, lessonPlaceOf as S, openFixRun as T, nodeSession as _, registryShown as a, recordNote as b, checkDue as c, pendingNotice as d, readUpdateCache as f, activeTree as g, writeUpdateCache as h, registryOf as i, fetchLatest as l, updateCachePath as m, ORK_VERSION as n, updateSwitchOff as o, refreshUpdateCache as p, isSwitchedOn as r, runInstall as s, ORK_NAME as t, newerVersion as u, previewPost as v, feedbackActions as w, acceptItem as x, checkNote as y };
615
+ const ORK_VERSION = "1.0.0-alpha.12";
616
+ export { feedbackActions as C, placeOf as S, previewPost as _, registryShown as a, acceptItem as b, checkDue as c, pendingNotice as d, readUpdateCache as f, nodeSession as g, writeUpdateCache as h, registryOf as i, fetchLatest as l, updateCachePath as m, ORK_VERSION as n, updateSwitchOff as o, refreshUpdateCache as p, isSwitchedOn as r, runInstall as s, ORK_NAME as t, newerVersion as u, checkNote as v, openFixRun as w, lessonPlaceOf as x, recordNote as y };
@@ -0,0 +1,89 @@
1
+ import "./src-CdDTQLdQ.mjs";
2
+ import { l as createTerminalHuman, n as attachRun, t as withStore } from "./store-B2OaE4ID.mjs";
3
+ import { t as findRun } from "./find-p05wlbmu.mjs";
4
+ import { a as style, o as write, s as writeErr } from "./output-CnRzrbUM.mjs";
5
+ import { n as attachRefusal } from "./in-a-run-BI-hLIl_.mjs";
6
+ import { defineCommand } from "citty";
7
+ // src/commands/attach.ts
8
+ /**
9
+ * @file `ork attach`: follow a run and the runs it called on this terminal, and
10
+ * answer their open decisions here (specs/cli.md). Ctrl-C detaches: the run
11
+ * keeps going and its decisions stay open (specs/run-control.md).
12
+ */
13
+ /**
14
+ * Follows `runId` and what it called until it ends or the person detaches, and
15
+ * returns the exit code: 0 when the run succeeded or they detached, else 1.
16
+ */
17
+ const attachSession = async (store, runId, session) => {
18
+ const detach = new AbortController();
19
+ session.signal?.addEventListener("abort", () => {
20
+ detach.abort();
21
+ });
22
+ const interactive = session.terminal?.interactive === true;
23
+ const human = session.terminal === void 0 || !interactive ? void 0 : createTerminalHuman({
24
+ ...session.terminal,
25
+ interrupt: () => {
26
+ detach.abort();
27
+ }
28
+ });
29
+ try {
30
+ const attached = await attachRun(store, runId, session.out, {
31
+ signal: detach.signal,
32
+ hintNoTerminal: human === void 0,
33
+ ...human === void 0 ? {} : { human },
34
+ ...session.home === void 0 ? {} : { home: session.home },
35
+ ...session.intervalMs === void 0 ? {} : { intervalMs: session.intervalMs }
36
+ });
37
+ if (detach.signal.aborted) {
38
+ session.out(style("dim", `detached; run ${runId} keeps going · ork attach ${runId} · ork stop ${runId}`));
39
+ return 0;
40
+ }
41
+ return attached.exitCode;
42
+ } finally {
43
+ human?.close();
44
+ }
45
+ };
46
+ const attach = defineCommand({
47
+ meta: {
48
+ name: "attach",
49
+ description: "Follow a run and the runs it called, and answer their questions here; Ctrl-C detaches"
50
+ },
51
+ args: { run: {
52
+ type: "positional",
53
+ description: "A run id or a prefix of one",
54
+ required: true
55
+ } },
56
+ run: ({ args }) => withStore(async (store) => {
57
+ const refusal = process.stdin.isTTY ? attachRefusal() : null;
58
+ if (refusal !== null) {
59
+ writeErr(refusal);
60
+ process.exitCode = 1;
61
+ return;
62
+ }
63
+ const found = findRun(store, args.run, process.cwd());
64
+ if (!found.ok) {
65
+ writeErr(found.error);
66
+ process.exitCode = 1;
67
+ return;
68
+ }
69
+ const abort = new AbortController();
70
+ const onSigint = () => {
71
+ abort.abort();
72
+ };
73
+ process.once("SIGINT", onSigint);
74
+ try {
75
+ process.exitCode = await attachSession(store, found.run.id, {
76
+ out: write,
77
+ signal: abort.signal,
78
+ terminal: {
79
+ input: process.stdin,
80
+ output: process.stdout,
81
+ interactive: process.stdin.isTTY
82
+ }
83
+ });
84
+ } finally {
85
+ process.off("SIGINT", onSigint);
86
+ }
87
+ })
88
+ });
89
+ export { attach };