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

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 (35) hide show
  1. package/dist/{__build_info__-DFF18K8y.mjs → __build_info__-CIchF6nr.mjs} +3 -72
  2. package/dist/bin.mjs +1066 -387
  3. package/dist/chips-BA7SrrH5.mjs +43 -0
  4. package/dist/{clean-DVaEH9e7.mjs → clean-Di-KT7Mf.mjs} +1 -1
  5. package/dist/{completion-Dv5kf598.mjs → completion-C5D0sEs5.mjs} +22 -15
  6. package/dist/{context-CEaKOVmG.mjs → context-BaNshWr9.mjs} +43 -31
  7. package/dist/{decide-3l9q8UtX.mjs → decide-B6PnKeqo.mjs} +1 -1
  8. package/dist/{find-DEjjOlTG.mjs → find-BicBbGMg.mjs} +1 -1
  9. package/dist/{format-Cb5_m-Qd.mjs → format-lWhN-jYR.mjs} +130 -35
  10. package/dist/{in-a-run-BS9Nc-JW.mjs → in-a-run-CgkVouyG.mjs} +1 -1
  11. package/dist/{limits-BSwEjQST.mjs → limits-jZQp9ZJC.mjs} +1 -1
  12. package/dist/{list-Qxr6rwsY.mjs → list-CEaJ07jd.mjs} +1 -1
  13. package/dist/{mcp-CslnG5wf.mjs → mcp-DYgVA9f5.mjs} +6 -6
  14. package/dist/output-CM95njYt.mjs +421 -0
  15. package/dist/{pause-D7OVB5Ac.mjs → pause-D6PuSlNl.mjs} +4 -4
  16. package/dist/{relay-EceRIebO.mjs → relay-DNx7be9k.mjs} +2 -2
  17. package/dist/{remove-0IQZVWmI.mjs → remove-CpMb4NDl.mjs} +3 -3
  18. package/dist/{report-DK4LGqwF.mjs → report-CEN8VoUb.mjs} +31 -20
  19. package/dist/{send-C0uwfUYi.mjs → send-CLs_fyg7.mjs} +3 -3
  20. package/dist/{src-cmmXKHn1.mjs → src-9iGkjnsy.mjs} +234 -150
  21. package/dist/{src-i5k2Y-kf.mjs → src-B6KvTm7B.mjs} +78 -11
  22. package/dist/{src-oaJYIddp.mjs → src-BnZgZGrf.mjs} +523 -81
  23. package/dist/{src-Df6KOIDC.mjs → src-D6_xjm-x.mjs} +1722 -825
  24. package/dist/ui/assets/{app-qs8Lofv6.js → app-CxURph7a.js} +16 -16
  25. package/dist/ui/assets/app-QoHVi-mb.css +1 -0
  26. package/dist/ui/assets/{index-DV1ZaOk-.js → index-By_8KKG6.js} +2 -2
  27. package/dist/ui/index.html +1 -1
  28. package/dist/{ui-CBkHJdqk.mjs → ui-CIci4UBW.mjs} +4 -4
  29. package/dist/{usage-Cd8pEYyK.mjs → usage-GceBGMjU.mjs} +43 -32
  30. package/dist/{watch-DW5R2OPO.mjs → watch-BmoybMQg.mjs} +28 -16
  31. package/dist/{workflows-BT1gDRIV.mjs → workflows-DZvW3i1e.mjs} +3 -3
  32. package/dist/{worktrees-g1MQMGie.mjs → worktrees-Be51E2rB.mjs} +11 -10
  33. package/package.json +1 -1
  34. package/dist/output-Bqljtmp_.mjs +0 -40
  35. package/dist/ui/assets/app-C8uhHVYp.css +0 -1
@@ -1,10 +1,10 @@
1
- import { $n as NodeSchema, An as inside, Bn as newWorkflowText, D as openStore, Dn as runDirOf, E as isNodeEvent, Gn as parseWorkflow, Gt as DISCUSSIONS, Jn as EdgeInputSchema, Jt as sendPost, Kt as planPost, Ln as skillsIn, Mn as LESSON_CAP_TOKENS, O as storePath, Ot as nestItems, Pt as nodeSays, Q as tellLiveRun, Rn as WorkflowEditSchema, St as runStatus, Tn as placeFor, Tt as processAlive, Vn as readDocument, W as linkNodes, Wn as renderJsonSchema, X as requestPause, Y as requestContinue, Z as requestStop, Zn as expandEdge, at as followEvents, bn as loadAgents, bt as liveStatus, d as runningRunIds, et as detachResume, f as runningScript, ht as walkSummary, it as detachRun, kn as workflowDirOf, l as planUpgrade, mt as walkChecks, o as limitsReport, ot as explainWorkflowText, p as detectInstaller, pt as checkWorkflowText, q as unlinkNodes, qt as runGh, r as capsHere, rn as readCondition, tt as resumable, u as releaseNotes, v as triggersReport, wn as placeFiles, xt as pausedOf, zn as applyEdits } from "./src-Df6KOIDC.mjs";
2
- import { C as placeOf$1, S as lessonPlaceOf, T as openFixRun, _ as nodeSession, a as registryShown, b as recordNote, c as checkDue, f as readUpdateCache, g as activeTree, h as writeUpdateCache, i as registryOf, l as fetchLatest, m as updateCachePath, o as updateSwitchOff, p as refreshUpdateCache, s as runInstall, u as newerVersion, v as previewPost, w as feedbackActions, x as acceptItem } from "./__build_info__-DFF18K8y.mjs";
3
- import { n as pendingDecisions, r as builtinProblem, t as answerDecision } from "./decide-3l9q8UtX.mjs";
4
- import { n as newRunId, t as findRun } from "./find-DEjjOlTG.mjs";
5
- import { n as usageReport } from "./report-DK4LGqwF.mjs";
6
- import { a as planClean, i as keyOf, o as stepActs, r as cleanStep, s as stepPrunes, t as applyClean } from "./clean-DVaEH9e7.mjs";
7
- import { a as readWorktrees, c as mergeStateOf, d as stateParts, i as projectHead, l as planLine, n as lostWork, r as planRemove, s as labelOf, t as applyRemove, u as removeRefusal } from "./remove-0IQZVWmI.mjs";
1
+ import { $n as skillsIn, $t as endOf, At as nestItems, B as linkNodes, Bn as placeFiles, C as openStore, Ct as runStatus, Dt as processAlive, G as requestContinue, Gn as workflowDirOf, In as loadAgents, J as tellLiveRun, Jn as LESSON_CAP_TOKENS, K as requestPause, Kn as inside, S as isNodeEvent, St as pausedOf, U as unlinkNodes, Un as runDirOf, Ut as nodeSays, Vn as placeFor, X as detachResume, Z as resumable, a as releaseNotes, c as detectInstaller, cn as planPost, er as WorkflowEditSchema, et as detachRun, gt as walkSummary, hr as NodeSchema, ht as walkChecks, i as planUpgrade, it as limitsReport, ln as runGh, mt as checkWorkflowText, nn as END_KINDS, nr as newWorkflowText, o as runningRunIds, or as renderJsonSchema, p as triggersReport, pr as expandEdge, q as requestStop, r as capsHere, rr as readDocument, s as runningScript, sn as DISCUSSIONS, sr as parseWorkflow, st as explainWorkflowText, tr as applyEdits, tt as followEvents, un as sendPost, ur as EdgeInputSchema, w as storePath, x as activeTree, xt as liveStatus, yn as readCondition } from "./src-D6_xjm-x.mjs";
2
+ import { C as feedbackActions, S as placeOf$1, _ as previewPost, a as registryShown, b as acceptItem, c as checkDue, f as readUpdateCache, g as nodeSession, h as writeUpdateCache, i as registryOf, l as fetchLatest, m as updateCachePath, o as updateSwitchOff, p as refreshUpdateCache, s as runInstall, u as newerVersion, w as openFixRun, x as lessonPlaceOf, y as recordNote } from "./__build_info__-CIchF6nr.mjs";
3
+ import { n as pendingDecisions, r as builtinProblem, t as answerDecision } from "./decide-B6PnKeqo.mjs";
4
+ import { n as newRunId, t as findRun } from "./find-BicBbGMg.mjs";
5
+ import { n as usageReport } from "./report-CEN8VoUb.mjs";
6
+ import { a as planClean, i as keyOf, o as stepActs, r as cleanStep, s as stepPrunes, t as applyClean } from "./clean-Di-KT7Mf.mjs";
7
+ import { a as readWorktrees, c as mergeStateOf, d as stateParts, i as projectHead, l as planLine, n as lostWork, r as planRemove, s as labelOf, t as applyRemove, u as removeRefusal } from "./remove-CpMb4NDl.mjs";
8
8
  import path from "node:path";
9
9
  import { z } from "zod";
10
10
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -779,7 +779,7 @@ const runOf = (context, id) => {
779
779
  const projectOf = (context, key) => context.store.projects().find((p) => p.id === key || p.root === key);
780
780
  /** A run as the API shows it: with its live status and what is paused. */
781
781
  const viewOf$2 = (context, run) => {
782
- const events = run.status === "running" ? context.store.events(run.id).map((stored) => stored.event) : [];
782
+ const events = run.status === "running" ? context.store.controlEvents(run.id).map((stored) => stored.event) : [];
783
783
  return {
784
784
  ...run,
785
785
  live: runStatus(run, events),
@@ -1450,6 +1450,72 @@ const builderRoutes = (context) => {
1450
1450
  builderSave: ({ params, body }) => inProject(params.id, (project) => saveDraft(context, project, params.name, body.force === true))
1451
1451
  };
1452
1452
  };
1453
+ // ../server/src/end-view.ts
1454
+ /**
1455
+ * @file Resolves how nodes ended for the API: each `node.finished` event (read
1456
+ * through core's `endOf`, so a run stored before ends existed gets a kind
1457
+ * too) and each tree node get an `EndView` (contract-ends.ts).
1458
+ */
1459
+ /** Core's hints send the reader to Details; with no detail there is none. */
1460
+ const HINT_TO_DETAILS = /\bIts (?:last )?(?:output|detail) is under Details(?:; |\.\s*)/u;
1461
+ const hintFor = (hint, hasDetail) => {
1462
+ if (hasDetail) return hint;
1463
+ const rest = hint.replace(HINT_TO_DETAILS, "");
1464
+ return rest === "" ? rest : rest[0]?.toUpperCase() + rest.slice(1);
1465
+ };
1466
+ const endViewOf = (end) => {
1467
+ const info = END_KINDS[end.kind];
1468
+ return {
1469
+ kind: end.kind,
1470
+ message: end.message,
1471
+ ...end.detail === void 0 ? {} : { detail: end.detail },
1472
+ label: info.label,
1473
+ actor: info.actor,
1474
+ transient: info.transient,
1475
+ hint: hintFor(info.hint, end.detail !== void 0),
1476
+ docsAnchor: info.docsAnchor
1477
+ };
1478
+ };
1479
+ /** The event as served: a `node.finished` gets its `end`, old ones too. */
1480
+ const servedEvent = (stored) => {
1481
+ const { event } = stored;
1482
+ return event.type === "node.finished" ? {
1483
+ ...stored,
1484
+ event: {
1485
+ ...event,
1486
+ end: endViewOf(endOf(event))
1487
+ }
1488
+ } : {
1489
+ ...stored,
1490
+ event
1491
+ };
1492
+ };
1493
+ /**
1494
+ * The tree with each node's latest end, from the events it was folded from. A
1495
+ * node that started again has none until it finishes; a failed node's `now` is
1496
+ * the end's message, not the raw error.
1497
+ */
1498
+ const treeWithEnds = (roots, stored) => {
1499
+ const ends = /* @__PURE__ */ new Map();
1500
+ for (const { event } of stored) if (event.type === "node.started") ends.delete(event.id);
1501
+ else if (event.type === "node.finished") ends.set(event.id, endViewOf(endOf(event)));
1502
+ const dress = (node) => {
1503
+ const end = ends.get(node.id);
1504
+ const children = node.children.map(dress);
1505
+ if (end === void 0) return {
1506
+ ...node,
1507
+ children
1508
+ };
1509
+ const failed = node.state === "failed" && end.actor !== null;
1510
+ return {
1511
+ ...node,
1512
+ ...failed ? { now: end.message } : {},
1513
+ end,
1514
+ children
1515
+ };
1516
+ };
1517
+ return roots.map((node) => dress(node));
1518
+ };
1453
1519
  // ../server/src/workflows.ts
1454
1520
  /**
1455
1521
  * @file A project's workflows, for the UI's Run workflow dialog: each
@@ -1548,7 +1614,8 @@ const readRoutes = (context) => ({
1548
1614
  tree: ({ params }) => {
1549
1615
  const found = runOf(context, params.id);
1550
1616
  if (!found.ok) return found.refusal;
1551
- return ok(nestItems(activeTree(context.store.events(found.run.id))));
1617
+ const stored = context.store.events(found.run.id);
1618
+ return ok(treeWithEnds(nestItems(activeTree(stored)), stored));
1552
1619
  },
1553
1620
  graph: ({ params }) => {
1554
1621
  const found = runOf(context, params.id);
@@ -1560,7 +1627,7 @@ const readRoutes = (context) => ({
1560
1627
  if (!found.ok) return found.refusal;
1561
1628
  const events = context.store.events(found.run.id, query.after ?? 0).filter((s) => query.node === void 0 || isNodeEvent(s.event, query.node));
1562
1629
  const newest = query.last === void 0 ? events : events.slice(-query.last);
1563
- return ok(query.limit === void 0 ? newest : newest.slice(0, query.limit));
1630
+ return ok((query.limit === void 0 ? newest : newest.slice(0, query.limit)).map((stored) => servedEvent(stored)));
1564
1631
  },
1565
1632
  decisions: ({ query }) => {
1566
1633
  const workflow = query.workflow === void 0 ? {} : { workflow: query.workflow };
@@ -2801,7 +2868,7 @@ const runStream = async (context, req, res, url, id, shutdown) => {
2801
2868
  }
2802
2869
  const stream = openEventStream(res);
2803
2870
  const end = await followEvents(context.store, found.run.id, (stored) => {
2804
- stream.send("run-event", stored, stored.seq);
2871
+ stream.send("run-event", servedEvent(stored), stored.seq);
2805
2872
  }, {
2806
2873
  follow: true,
2807
2874
  after,