@krapht/ork 1.0.0-alpha.19 → 1.0.0-alpha.20
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/dist/{__build_info__-dPf4cEGL.mjs → __build_info__-D6mXC4cD.mjs} +2 -2
- package/dist/argument-error-CihH46Le.mjs +27 -0
- package/dist/{attach-BQl8nQz2.mjs → attach-C1OnxyMh.mjs} +7 -5
- package/dist/{attach-DhZQ87Nz.mjs → attach-CEGbRg1D.mjs} +126 -69
- package/dist/bin.mjs +556 -119
- package/dist/{brief-BQbeoPMc.mjs → brief-DH66xmj8.mjs} +11 -6
- package/dist/{builtin-files-CWL3JEo-.mjs → builtin-files-Cf-NZDqM.mjs} +1 -1
- package/dist/{command-tree-B6uvMJq1.mjs → command-tree-CEkzWNy6.mjs} +1 -1
- package/dist/{completion-DKPuD_Rw.mjs → completion-DS0gCZRm.mjs} +19 -12
- package/dist/{context-Bw6R_EYq.mjs → context-CGPh12HV.mjs} +3 -3
- package/dist/{detached-BQlbmqR0.mjs → detached-Dakw5RZj.mjs} +3 -3
- package/dist/extra-arguments-BxQMXARO.mjs +13 -0
- package/dist/{find-B30-rd-u.mjs → find-BTikxc54.mjs} +1 -1
- package/dist/{flags-ByYBx-Xb.mjs → flags-C8yCq0j5.mjs} +7 -32
- package/dist/{follow-ups-Cxca1Jgg.mjs → follow-ups-CtlhHbwe.mjs} +87 -26
- package/dist/{format-C-nEZv-P.mjs → format-BB4E-T6x.mjs} +1 -1
- package/dist/{in-a-run-CZFzoT3R.mjs → in-a-run-CbnKjO7t.mjs} +2 -2
- package/dist/{install-CsqK1avz.mjs → install-CWcpX5g4.mjs} +1 -1
- package/dist/{limits-CXh052II.mjs → limits-VQqsBoQk.mjs} +1 -1
- package/dist/{mcp-B4wME9C4.mjs → mcp-wGfkMCVF.mjs} +6 -6
- package/dist/{once-BKn3pOtg.mjs → once-BHxSdZz_.mjs} +43 -7
- package/dist/{pause-B1grR1cl.mjs → pause-C_Wxh-KM.mjs} +6 -3
- package/dist/{print-Bd8MWVJk.mjs → print-DNYzq4Rr.mjs} +1 -1
- package/dist/{project-records-BOEVs69i.mjs → project-records-XY3ku95x.mjs} +4 -1
- package/dist/{relay-CeNiq3GT.mjs → relay-BA6tsnpc.mjs} +1 -1
- package/dist/{run-D6yU2rLf.mjs → run-Bvvg-fiF.mjs} +61 -19
- package/dist/{run-C0C54UiU.mjs → run-DBUAq-Uu.mjs} +29 -20
- package/dist/{send-DqgF58hb.mjs → send-nrKtak5F.mjs} +2 -2
- package/dist/{src-Ciy7i3se.mjs → src-8cOPOgrT.mjs} +155 -32
- package/dist/{src-n-u4TGev.mjs → src-CmEvHdju.mjs} +28 -28
- package/dist/{src-D2qpd-G7.mjs → src-D4JSymhK.mjs} +11 -2
- package/dist/{src-DP02RP9O.mjs → src-I_RyKu6_.mjs} +2 -2
- package/dist/{store-2KXzMCEN.mjs → store-CDpk8Wtz.mjs} +1 -1
- package/dist/ui/assets/app--FijEXiJ.css +1 -0
- package/dist/ui/assets/{app-ICEKpy_C.js → app-BowhjEAe.js} +12 -12
- package/dist/ui/assets/{index-BGaix5wh.js → index-CrMa2oHB.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/dist/{ui-CAvygxTb.mjs → ui-DY3Dnpho.mjs} +4 -4
- package/dist/{usage-BFBco5OS.mjs → usage-1VwSg_Qt.mjs} +4 -4
- package/dist/{validate-UrmC5AG1.mjs → validate-BxayjjkV.mjs} +3 -3
- package/dist/{watch-DTxkgB8R.mjs → watch-CT0EtLPZ.mjs} +5 -5
- package/dist/{workflows-8GV-SeRm.mjs → workflows-DHHi-APg.mjs} +2 -2
- package/dist/{worktrees-CUdUvZlO.mjs → worktrees-CZvbHzbN.mjs} +4 -4
- package/package.json +1 -1
- package/dist/ui/assets/app-C5vO1M-l.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as parseVersion, T as isNewer, w as compareVersions } from "./src-
|
|
1
|
+
import { E as parseVersion, T as isNewer, w as compareVersions } from "./src-8cOPOgrT.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";
|
|
@@ -224,5 +224,5 @@ const registryShown = (registry) => {
|
|
|
224
224
|
* fails when it is stale.
|
|
225
225
|
*/
|
|
226
226
|
const ORK_NAME = "@krapht/ork";
|
|
227
|
-
const ORK_VERSION = "1.0.0-alpha.
|
|
227
|
+
const ORK_VERSION = "1.0.0-alpha.20";
|
|
228
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 };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseArgs } from "citty";
|
|
2
|
+
// src/argument-error.ts
|
|
3
|
+
/**
|
|
4
|
+
* @file The error citty's `runMain` takes for an argument error: the plugins
|
|
5
|
+
* that refuse a flag (`list/known-flags.ts`) or an extra word
|
|
6
|
+
* (`extra-arguments.ts`) throw one, so the message is one line and the exit
|
|
7
|
+
* code is 1, as for a wrong enum value.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* An error citty's `runMain` takes for an argument error (its `CLIError`, which
|
|
11
|
+
* it does not export): a failed parse gives one, and it takes `message`.
|
|
12
|
+
*/
|
|
13
|
+
const argumentError = (message) => {
|
|
14
|
+
try {
|
|
15
|
+
parseArgs([], { x: {
|
|
16
|
+
type: "string",
|
|
17
|
+
required: true
|
|
18
|
+
} });
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
error.message = message;
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return new Error(message);
|
|
26
|
+
};
|
|
27
|
+
export { argumentError as t };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import "./src-
|
|
2
|
-
import { t as findRun } from "./find-
|
|
1
|
+
import "./src-8cOPOgrT.mjs";
|
|
2
|
+
import { t as findRun } from "./find-BTikxc54.mjs";
|
|
3
3
|
import { c as write, l as writeErr, s as style } from "./output-B1kwo0YU.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { n as attachRefusal } from "./in-a-run-
|
|
6
|
-
import { t as
|
|
4
|
+
import { m as createTerminalHuman, t as attachRun } from "./attach-CEGbRg1D.mjs";
|
|
5
|
+
import { n as attachRefusal } from "./in-a-run-CbnKjO7t.mjs";
|
|
6
|
+
import { t as refuseExtraArguments } from "./extra-arguments-BxQMXARO.mjs";
|
|
7
|
+
import { t as withStore } from "./store-CDpk8Wtz.mjs";
|
|
7
8
|
import { defineCommand } from "citty";
|
|
8
9
|
// src/commands/attach.ts
|
|
9
10
|
/**
|
|
@@ -49,6 +50,7 @@ const attach = defineCommand({
|
|
|
49
50
|
name: "attach",
|
|
50
51
|
description: "Follow a run and the runs it called, and answer their questions here; Ctrl-C detaches"
|
|
51
52
|
},
|
|
53
|
+
plugins: [refuseExtraArguments],
|
|
52
54
|
args: { run: {
|
|
53
55
|
type: "positional",
|
|
54
56
|
description: "A run id or a prefix of one",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
2
2
|
import { t as applyFilters } from "./apply-Mb0fNpCX.mjs";
|
|
3
3
|
import { t as outputsText } from "./outputs-text-CNTJ7Qq_.mjs";
|
|
4
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";
|
|
@@ -16,7 +16,11 @@ const cardLines = (t, q, place, verbose, document) => {
|
|
|
16
16
|
const context = q.context === void 0 ? void 0 : clean(q.context);
|
|
17
17
|
if (!t.rich) return {
|
|
18
18
|
lines: [
|
|
19
|
-
...place === void 0 ? [] : [
|
|
19
|
+
...place === void 0 ? [] : [`${[
|
|
20
|
+
`run ${place.run}`,
|
|
21
|
+
place.workflow,
|
|
22
|
+
place.path
|
|
23
|
+
].filter((part) => part !== void 0).join(" · ")} · decision ${place.decision}`],
|
|
20
24
|
...document === void 0 ? [] : [document],
|
|
21
25
|
`? ${plain(q.nodeId)} asks: ${clean(q.question)}`,
|
|
22
26
|
...context === void 0 ? [] : [` ${context.replaceAll("\n", "\n ")}`]
|
|
@@ -28,6 +32,7 @@ const cardLines = (t, q, place, verbose, document) => {
|
|
|
28
32
|
const body = cutShort ? shown.slice(0, CONTEXT_LINES) : shown;
|
|
29
33
|
const where = place === void 0 ? "" : ` ${paint(t, "muted", [
|
|
30
34
|
`run ${place.run}`,
|
|
35
|
+
place.workflow,
|
|
31
36
|
place.path,
|
|
32
37
|
place.index === void 0 || place.total === void 0 ? void 0 : `${String(place.index)} of ${String(place.total)}`
|
|
33
38
|
].filter((part) => part !== void 0).join(" · "))}`;
|
|
@@ -415,11 +420,15 @@ const previewInput = (toolName, input) => {
|
|
|
415
420
|
const line = (key === void 0 ? JSON.stringify(input) : `${key}: ${String(input[key])}`).replaceAll(/\s+/gu, " ").trim();
|
|
416
421
|
return line.length > PREVIEW ? `${toolName} ${line.slice(0, 159)}…` : `${toolName} ${line}`;
|
|
417
422
|
};
|
|
418
|
-
/** Never answers
|
|
423
|
+
/** Never answers until `signal` withdraws it, at once if it already has. */
|
|
419
424
|
const parked = (signal) => new Promise((_, reject) => {
|
|
425
|
+
if (signal?.aborted === true) {
|
|
426
|
+
reject(withdrawn(signal));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
420
429
|
signal?.addEventListener("abort", () => {
|
|
421
430
|
reject(withdrawn(signal));
|
|
422
|
-
});
|
|
431
|
+
}, { once: true });
|
|
423
432
|
});
|
|
424
433
|
/**
|
|
425
434
|
* Answers permission prompts and `ask_user` questions on the terminal, one at a
|
|
@@ -981,6 +990,8 @@ const logListTable = { fields: [{
|
|
|
981
990
|
type: "until",
|
|
982
991
|
get: (stored) => stored.at
|
|
983
992
|
}] };
|
|
993
|
+
/** Whether an event is one `--since`, `--until` and `--node` let through. */
|
|
994
|
+
const matcher = (options) => (stored) => applyFilters(logListTable, [stored], options.filter ?? {}).length > 0 && (options.node === void 0 || isNodeEvent(stored.event, options.node));
|
|
984
995
|
/**
|
|
985
996
|
* Prints a run's events; with `follow`, then each new one as it is stored:
|
|
986
997
|
* pushed over the run's socket, or polled from the store when there is none.
|
|
@@ -989,7 +1000,7 @@ const logListTable = { fields: [{
|
|
|
989
1000
|
*/
|
|
990
1001
|
const followRun = async (store, run, out, options) => {
|
|
991
1002
|
const print = createLogPrinter(options);
|
|
992
|
-
const matches = (
|
|
1003
|
+
const matches = matcher(options);
|
|
993
1004
|
const replayed = options.limit === void 0 ? [] : store.events(run.id, options.after ?? 0).filter((stored) => matches(stored)).slice(0, -options.limit);
|
|
994
1005
|
const dropped = new Set(replayed.map((stored) => stored.seq));
|
|
995
1006
|
if (await followEvents(store, run.id, (stored) => {
|
|
@@ -1004,6 +1015,38 @@ const followRun = async (store, run, out, options) => {
|
|
|
1004
1015
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
1005
1016
|
}) === "crashed") out(style("red", `run ${run.id} stopped without finishing (its process is gone)`));
|
|
1006
1017
|
};
|
|
1018
|
+
// src/runs/gutter.ts
|
|
1019
|
+
/**
|
|
1020
|
+
* @file The gutter before a called run's log lines (its call path, then `›`)
|
|
1021
|
+
* and a log printer laid out in the columns the gutter leaves. Shared by `ork
|
|
1022
|
+
* attach` and the commands that print several runs.
|
|
1023
|
+
*/
|
|
1024
|
+
/** A call path for reading: `plan › build`. */
|
|
1025
|
+
const callPathOf = (path) => path.join(" › ");
|
|
1026
|
+
/** The gutter before a called run's lines: its call path, then ` › `. */
|
|
1027
|
+
const gutterOf = (path) => path.length === 0 ? "" : `${callPathOf(path)} › `;
|
|
1028
|
+
/**
|
|
1029
|
+
* A run's printer, laid out in the columns its gutter leaves, so a line fits
|
|
1030
|
+
* the terminal with the gutter before it and a wrapped line goes on under its
|
|
1031
|
+
* own text, not at the terminal's first column.
|
|
1032
|
+
*/
|
|
1033
|
+
const printerFor = (term, path, options = {}) => createLogPrinter({
|
|
1034
|
+
...options,
|
|
1035
|
+
json: false,
|
|
1036
|
+
view: {
|
|
1037
|
+
term: {
|
|
1038
|
+
...term,
|
|
1039
|
+
width: Math.max(20, term.width - widthOf(gutterOf(path)))
|
|
1040
|
+
},
|
|
1041
|
+
roots: /* @__PURE__ */ new Map()
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
/** Prints `lines` through `out`, each (not blank) behind `path`'s muted gutter. */
|
|
1045
|
+
const printUnder = (out, term, path, lines) => {
|
|
1046
|
+
const gutter = gutterOf(path);
|
|
1047
|
+
const prefix = gutter === "" ? "" : paint(term, "muted", gutter);
|
|
1048
|
+
for (const line of lines) out(line === "" ? line : `${prefix}${line}`);
|
|
1049
|
+
};
|
|
1007
1050
|
// src/runs/ask-stored.ts
|
|
1008
1051
|
/**
|
|
1009
1052
|
* @file Asks one stored decision on a terminal and stores the answer: the
|
|
@@ -1044,68 +1087,39 @@ const askStored = async (store, human, decision, { place, by, signal, home }) =>
|
|
|
1044
1087
|
message: answered.error
|
|
1045
1088
|
};
|
|
1046
1089
|
};
|
|
1047
|
-
// src/runs/
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
const
|
|
1056
|
-
/** The gutter before a called run's lines: its call path, then ` › `. */
|
|
1057
|
-
const gutterOf = (path) => path.length === 0 ? "" : `${where(path)} › `;
|
|
1058
|
-
/**
|
|
1059
|
-
* Prints the events of `root` and of the runs it called until the root ends or
|
|
1060
|
-
* `signal` aborts, and asks each open decision with `options.human`.
|
|
1061
|
-
*/
|
|
1062
|
-
const attachRun = async (store, root, out, options = {}) => {
|
|
1063
|
-
const { human, basePath = [] } = options;
|
|
1064
|
-
const { term } = options.view ?? createView();
|
|
1090
|
+
// src/runs/prompts.ts
|
|
1091
|
+
const closedLine = (id, closed) => {
|
|
1092
|
+
if (closed.type === "decision.withdrawn") return `${id} withdrawn`;
|
|
1093
|
+
const by = closed.by === "owner" ? closed.owner ?? ANSWERED_BY.owner : ANSWERED_BY[closed.by];
|
|
1094
|
+
return `${id} answered elsewhere: ${closed.answer} (${by})`;
|
|
1095
|
+
};
|
|
1096
|
+
/** Creates the prompts a command owns over `store`, asked on `human`. */
|
|
1097
|
+
const createPrompts = (store, human, options) => {
|
|
1098
|
+
const { term, out } = options;
|
|
1065
1099
|
const say = styler(term);
|
|
1066
|
-
const printers = /* @__PURE__ */ new Map();
|
|
1067
1100
|
const prompts = /* @__PURE__ */ new Map();
|
|
1068
1101
|
/** Decisions answered here: their `decision.answered` line is the card's. */
|
|
1069
1102
|
const mine = /* @__PURE__ */ new Set();
|
|
1070
1103
|
const asks = [];
|
|
1071
|
-
const
|
|
1072
|
-
hinted: false,
|
|
1073
|
-
succeeded: false
|
|
1074
|
-
};
|
|
1104
|
+
const state = {};
|
|
1075
1105
|
const show = (path, lines) => {
|
|
1076
|
-
|
|
1077
|
-
const prefix = gutter === "" ? "" : paint(term, "muted", gutter);
|
|
1078
|
-
for (const line of lines) out(line === "" ? line : `${prefix}${line}`);
|
|
1106
|
+
printUnder(out, term, path, lines);
|
|
1079
1107
|
};
|
|
1080
|
-
|
|
1081
|
-
* A run's printer, laid out in the columns its gutter leaves, so a line fits
|
|
1082
|
-
* the terminal with the gutter before it and a wrapped line goes on under its
|
|
1083
|
-
* own text, not at the terminal's first column.
|
|
1084
|
-
*/
|
|
1085
|
-
const printerFor = (path) => createLogPrinter({
|
|
1086
|
-
json: false,
|
|
1087
|
-
view: {
|
|
1088
|
-
term: {
|
|
1089
|
-
...term,
|
|
1090
|
-
width: Math.max(20, term.width - widthOf(gutterOf(path)))
|
|
1091
|
-
},
|
|
1092
|
-
roots: /* @__PURE__ */ new Map()
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
const ask = (run, path, id) => {
|
|
1108
|
+
const ask = ({ run, path = [], workflow }, id) => {
|
|
1096
1109
|
const decision = store.decision(id);
|
|
1097
|
-
if (
|
|
1110
|
+
if (decision === void 0) return;
|
|
1098
1111
|
const prompt = { controller: new AbortController() };
|
|
1099
1112
|
prompts.set(id, prompt);
|
|
1100
1113
|
const settle = async () => {
|
|
1101
1114
|
try {
|
|
1102
1115
|
const asked = await askStored(store, human, decision, {
|
|
1103
|
-
by: "terminal",
|
|
1116
|
+
by: options.by ?? "terminal",
|
|
1104
1117
|
signal: prompt.controller.signal,
|
|
1105
1118
|
place: {
|
|
1106
1119
|
run,
|
|
1107
1120
|
decision: id,
|
|
1108
|
-
...
|
|
1121
|
+
...workflow === void 0 ? {} : { workflow },
|
|
1122
|
+
...path.length === 0 ? {} : { path: callPathOf(path) }
|
|
1109
1123
|
},
|
|
1110
1124
|
...options.home === void 0 ? {} : { home: options.home }
|
|
1111
1125
|
});
|
|
@@ -1115,33 +1129,77 @@ const attachRun = async (store, root, out, options = {}) => {
|
|
|
1115
1129
|
mine.add(id);
|
|
1116
1130
|
if (!term.rich) show(path, [`${say("green", "✓")} ${id}: ${asked.choice}`]);
|
|
1117
1131
|
} else if (asked.kind === "refused") show(path, [paint(term, "warn", `! ${asked.message}`)]);
|
|
1118
|
-
else if (asked.kind === "withdrawn" && closed !== void 0)
|
|
1119
|
-
const by = closed.type === "decision.answered" ? closed.by === "owner" ? closed.owner ?? ANSWERED_BY.owner : ANSWERED_BY[closed.by] : "";
|
|
1120
|
-
show(path, [say("dim", closed.type === "decision.answered" ? `${id} answered elsewhere: ${closed.answer} (${by})` : `${id} withdrawn`)]);
|
|
1121
|
-
}
|
|
1132
|
+
else if (asked.kind === "withdrawn" && closed !== void 0) show(path, [say("dim", closedLine(id, closed))]);
|
|
1122
1133
|
} catch (error) {
|
|
1123
1134
|
prompts.delete(id);
|
|
1124
|
-
|
|
1135
|
+
state.failure ??= { error };
|
|
1125
1136
|
}
|
|
1126
1137
|
};
|
|
1127
1138
|
asks.push(settle());
|
|
1128
1139
|
};
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1140
|
+
return {
|
|
1141
|
+
ask,
|
|
1142
|
+
has: (id) => prompts.has(id) || mine.has(id),
|
|
1143
|
+
seen: (event) => {
|
|
1144
|
+
if (event.type !== "decision.answered" && event.type !== "decision.withdrawn") return false;
|
|
1134
1145
|
const prompt = prompts.get(event.decision);
|
|
1135
1146
|
if (prompt !== void 0) {
|
|
1136
1147
|
prompt.closed = event;
|
|
1137
1148
|
prompt.controller.abort();
|
|
1138
|
-
return;
|
|
1149
|
+
return true;
|
|
1139
1150
|
}
|
|
1140
|
-
|
|
1151
|
+
return event.type === "decision.answered" && mine.has(event.decision);
|
|
1152
|
+
},
|
|
1153
|
+
open: () => prompts.size,
|
|
1154
|
+
abort: () => {
|
|
1155
|
+
for (const prompt of prompts.values()) prompt.controller.abort();
|
|
1156
|
+
},
|
|
1157
|
+
settled: async () => {
|
|
1158
|
+
await Promise.all(asks);
|
|
1159
|
+
if (state.failure !== void 0) throw state.failure.error;
|
|
1141
1160
|
}
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
// src/runs/attach.ts
|
|
1164
|
+
/**
|
|
1165
|
+
* @file Following a run and every run it called on a terminal, and answering
|
|
1166
|
+
* their open decisions there (`ork attach`, and a foreground `ork run` that
|
|
1167
|
+
* calls workflows; specs/cli.md, specs/scheduler/calls.md). Each run has its
|
|
1168
|
+
* own log printer behind its call path; a decision opened in any of them is
|
|
1169
|
+
* asked through one `TerminalHuman`, withdrawn when it closes elsewhere.
|
|
1170
|
+
*/
|
|
1171
|
+
/**
|
|
1172
|
+
* Prints the events of `root` and of the runs it called until the root ends or
|
|
1173
|
+
* `signal` aborts, and asks each open decision with `options.human`.
|
|
1174
|
+
*/
|
|
1175
|
+
const attachRun = async (store, root, out, options = {}) => {
|
|
1176
|
+
const { human, basePath = [] } = options;
|
|
1177
|
+
const { term } = options.view ?? createView();
|
|
1178
|
+
const say = styler(term);
|
|
1179
|
+
const printers = /* @__PURE__ */ new Map();
|
|
1180
|
+
const seen = {
|
|
1181
|
+
hinted: false,
|
|
1182
|
+
succeeded: false
|
|
1183
|
+
};
|
|
1184
|
+
const show = (path, lines) => {
|
|
1185
|
+
printUnder(out, term, path, lines);
|
|
1186
|
+
};
|
|
1187
|
+
const prompts = human === void 0 ? void 0 : createPrompts(store, human, {
|
|
1188
|
+
out,
|
|
1189
|
+
term,
|
|
1190
|
+
...options.home === void 0 ? {} : { home: options.home }
|
|
1191
|
+
});
|
|
1192
|
+
const { end, stillRunning } = await followRunTree(store, root, ({ run, path: below, stored }) => {
|
|
1193
|
+
const path = [...basePath, ...below];
|
|
1194
|
+
const { event } = stored;
|
|
1195
|
+
if (event.type === "run.finished" && below.length === 0) seen.succeeded = event.result.status === "succeeded";
|
|
1196
|
+
if (prompts?.seen(event) === true) return;
|
|
1142
1197
|
if (event.type === "decision.opened" && event.owner === void 0 && pendingDecisions(store, { runId: run }).some((d) => d.id === event.decision)) {
|
|
1143
|
-
if (
|
|
1144
|
-
ask(
|
|
1198
|
+
if (prompts !== void 0) {
|
|
1199
|
+
prompts.ask({
|
|
1200
|
+
run,
|
|
1201
|
+
path
|
|
1202
|
+
}, event.decision);
|
|
1145
1203
|
return;
|
|
1146
1204
|
}
|
|
1147
1205
|
if (options.hintNoTerminal === true && !seen.hinted) {
|
|
@@ -1151,7 +1209,7 @@ const attachRun = async (store, root, out, options = {}) => {
|
|
|
1151
1209
|
}
|
|
1152
1210
|
let print = printers.get(run);
|
|
1153
1211
|
if (print === void 0) {
|
|
1154
|
-
print = printerFor(path);
|
|
1212
|
+
print = printerFor(term, path);
|
|
1155
1213
|
printers.set(run, print);
|
|
1156
1214
|
}
|
|
1157
1215
|
show(path, print(stored));
|
|
@@ -1160,9 +1218,8 @@ const attachRun = async (store, root, out, options = {}) => {
|
|
|
1160
1218
|
...options.intervalMs === void 0 ? {} : { intervalMs: options.intervalMs },
|
|
1161
1219
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
1162
1220
|
});
|
|
1163
|
-
|
|
1164
|
-
await
|
|
1165
|
-
if (seen.failure !== void 0) throw seen.failure.error;
|
|
1221
|
+
prompts?.abort();
|
|
1222
|
+
await prompts?.settled();
|
|
1166
1223
|
if (end === "crashed") show(basePath, [say("red", `run ${root} stopped without finishing (its process is gone)`)]);
|
|
1167
1224
|
for (const id of stillRunning) out(say("dim", `↳ run ${id} still running · ork attach ${id}`));
|
|
1168
1225
|
return {
|
|
@@ -1170,4 +1227,4 @@ const attachRun = async (store, root, out, options = {}) => {
|
|
|
1170
1227
|
exitCode: end === "aborted" || seen.succeeded ? 0 : 1
|
|
1171
1228
|
};
|
|
1172
1229
|
};
|
|
1173
|
-
export {
|
|
1230
|
+
export { printerFor as a, logListTable as c, formatEvent as d, formatRunEvent as f, readText as h, printUnder as i, matcher as l, createTerminalHuman as m, createPrompts as n, createLogPrinter as o, callsShown as p, askStored as r, followRun as s, attachRun as t, unknownNode as u };
|