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

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/README.md +5 -6
  2. package/dist/{__build_info__-DdTVd2p5.mjs → __build_info__-DFF18K8y.mjs} +72 -3
  3. package/dist/bin.mjs +603 -384
  4. package/dist/{clean-NnboOuz6.mjs → clean-DVaEH9e7.mjs} +5 -2
  5. package/dist/{completion-snnYGjgK.mjs → completion-Dv5kf598.mjs} +6 -6
  6. package/dist/context-CEaKOVmG.mjs +683 -0
  7. package/dist/{decide-B81wCZQg.mjs → decide-3l9q8UtX.mjs} +3 -3
  8. package/dist/{find-BKW-uGey.mjs → find-DEjjOlTG.mjs} +1 -1
  9. package/dist/format-Cb5_m-Qd.mjs +191 -0
  10. package/dist/{in-a-run-BPXX09Bs.mjs → in-a-run-BS9Nc-JW.mjs} +1 -1
  11. package/dist/{limits-JCve2QpI.mjs → limits-BSwEjQST.mjs} +1 -1
  12. package/dist/{list-C7UEgmtd.mjs → list-Qxr6rwsY.mjs} +11 -4
  13. package/dist/{mcp-CKPyNaKD.mjs → mcp-CslnG5wf.mjs} +6 -6
  14. package/dist/output-Bqljtmp_.mjs +40 -0
  15. package/dist/{pause-B_SL_yDz.mjs → pause-D7OVB5Ac.mjs} +4 -4
  16. package/dist/{relay-o-Luee1c.mjs → relay-EceRIebO.mjs} +2 -2
  17. package/dist/{remove-DAZ7ZCzt.mjs → remove-0IQZVWmI.mjs} +14 -7
  18. package/dist/{send-3B64fBNB.mjs → send-C0uwfUYi.mjs} +3 -3
  19. package/dist/{src-DHvWU4tX.mjs → src-Df6KOIDC.mjs} +5682 -3248
  20. package/dist/{src-C38BPzit.mjs → src-cmmXKHn1.mjs} +266 -203
  21. package/dist/{src-BJTegEzY.mjs → src-i5k2Y-kf.mjs} +40 -88
  22. package/dist/src-oaJYIddp.mjs +2255 -0
  23. package/dist/ui/THIRD_PARTY_LICENSES.txt +594 -0
  24. package/dist/ui/assets/app-C8uhHVYp.css +1 -0
  25. package/dist/ui/assets/app-qs8Lofv6.js +75 -0
  26. package/dist/ui/assets/{index-D83F2OKZ.js → index-DV1ZaOk-.js} +3 -3
  27. package/dist/ui/assets/theme-CdXvqTQ6.js +1 -0
  28. package/dist/ui/index.html +2 -2
  29. package/dist/{ui-CY4xxJUu.mjs → ui-CBkHJdqk.mjs} +4 -4
  30. package/dist/{usage-CJnytoe4.mjs → usage-Cd8pEYyK.mjs} +5 -5
  31. package/dist/{watch-BJB82ZJ7.mjs → watch-DW5R2OPO.mjs} +6 -6
  32. package/dist/{workflows-CiM7S3l0.mjs → workflows-BT1gDRIV.mjs} +4 -3
  33. package/dist/{worktrees-86ySXxR6.mjs → worktrees-g1MQMGie.mjs} +78 -19
  34. package/package.json +2 -4
  35. package/dist/context-DO3sBy9v.mjs +0 -274
  36. package/dist/format-CmTlTOjT.mjs +0 -427
  37. package/dist/output-B1V6ZJSx.mjs +0 -950
  38. package/dist/src-Dyz_Gy1q.mjs +0 -1183
  39. package/dist/ui/assets/app-C8nJ6NpT.js +0 -67
  40. package/dist/ui/assets/app-CH7YC3in.css +0 -1
  41. package/dist/ui/assets/theme-3xH5jxKs.js +0 -1
@@ -1,86 +1,16 @@
1
- import { B as linkNodes, Cn as runDirOf, Ct as walkChecks, En as inside, Fn as applyEdits, G as requestContinue, Gn as expandEdge, Hn as EdgeInputSchema, Ht as planPost, In as newWorkflowText, J as tellLiveRun, K as requestPause, Ln as readDocument, Nn as skillsIn, Nt as nodeSays, On as LESSON_CAP_TOKENS, Pn as WorkflowEditSchema, Rn as renderJsonSchema, St as checkWorkflowText, Tn as workflowDirOf, U as unlinkNodes, Ut as runGh, Vt as DISCUSSIONS, Wt as sendPost, _t as runStatus, bn as placeFiles, bt as processAlive, ct as explainWorkflowText, d as runningRunIds, f as runningScript, gt as pausedOf, hn as loadAgents, ht as liveStatus, l as planUpgrade, nt as resumable, o as limitsReport, ot as detachRun, p as detectInstaller, q as requestStop, qn as NodeSchema, r as capsHere, st as followEvents, tn as readCondition, tt as detachResume, u as releaseNotes, v as triggersReport, vt as runTree, wt as walkSummary, xn as placeFor, zn as parseWorkflow } from "./src-DHvWU4tX.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__-DdTVd2p5.mjs";
3
- import { n as pendingDecisions, r as builtinProblem, t as answerDecision } from "./decide-B81wCZQg.mjs";
4
- import { n as newRunId, t as findRun } from "./find-BKW-uGey.mjs";
5
- import { c as openStore, l as storePath, s as nodeOf } from "./output-B1V6ZJSx.mjs";
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";
6
5
  import { n as usageReport } from "./report-DK4LGqwF.mjs";
7
- import { a as planClean, i as keyOf, o as stepActs, r as cleanStep, s as stepPrunes, t as applyClean } from "./clean-NnboOuz6.mjs";
8
- import { a as readWorktrees, c as planLine, i as projectHead, l as removeRefusal, n as lostWork, o as labelOf, r as planRemove, s as mergeStateOf, t as applyRemove, u as stateParts } from "./remove-DAZ7ZCzt.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";
9
8
  import path from "node:path";
10
9
  import { z } from "zod";
11
10
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
12
11
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
13
12
  import { homedir } from "node:os";
14
13
  import { createServer } from "node:http";
15
- // ../core/src/store/activity.ts
16
- const LONGEST_LINE = 120;
17
- /**
18
- * The fields of a tool's input that say what it's working on, best first. Only
19
- * these are shown, so what else a tool was given stays in the logs.
20
- */
21
- const TARGETS = [
22
- "file_path",
23
- "notebook_path",
24
- "path",
25
- "url",
26
- "pattern",
27
- "query",
28
- "command"
29
- ];
30
- const oneLine = (text) => {
31
- const line = text.replaceAll(/\s+/gu, " ").trim();
32
- return line.length > LONGEST_LINE ? `${line.slice(0, 119)}…` : line;
33
- };
34
- const toolLine = ({ name, input }) => {
35
- const target = TARGETS.map((field) => input[field]).find((value) => typeof value === "string" && value.trim() !== "");
36
- if (typeof target !== "string") return name;
37
- return oneLine(target.startsWith(`${name} `) ? target : `${name} ${target}`);
38
- };
39
- /** What a finished node said, or why it failed. */
40
- const finishedNow = (ok, error, summary) => {
41
- if (!ok) return error === void 0 ? void 0 : oneLine(error);
42
- return typeof summary === "string" && summary.trim() !== "" ? oneLine(summary) : void 0;
43
- };
44
- /** Each node's activity, by id; a node that never started has none. */
45
- const runActivity = (stored) => {
46
- const nodes = /* @__PURE__ */ new Map();
47
- const of = (id) => {
48
- const found = nodes.get(id);
49
- if (found !== void 0) return found;
50
- const fresh = {};
51
- nodes.set(id, fresh);
52
- return fresh;
53
- };
54
- for (const { at, event } of stored) if (event.type === "node.started") {
55
- const node = of(event.id);
56
- node.startedAt ??= at;
57
- delete node.finishedAt;
58
- delete node.now;
59
- } else if (event.type === "node.event") {
60
- if (event.event.type === "tool.called") of(event.id).now = toolLine(event.event);
61
- } else if (event.type === "decision.opened") of(event.node).now = oneLine(`Asked: ${event.question}`);
62
- else if (event.type === "decision.answered") of(event.node).now = oneLine(`Answered: ${event.answer}`);
63
- else if (event.type === "decision.withdrawn") delete of(event.node).now;
64
- else if (event.type === "node.finished") {
65
- const node = of(event.id);
66
- node.finishedAt = at;
67
- const now = finishedNow(event.ok, event.error, event.output["summary"]);
68
- if (now === void 0) delete node.now;
69
- else node.now = now;
70
- }
71
- return nodes;
72
- };
73
- /** The ownership tree, with what each node is doing and when it ran. */
74
- const activeTree = (stored) => {
75
- const activity = runActivity(stored);
76
- const dress = (node) => {
77
- Object.assign(node, activity.get(node.id));
78
- for (const child of node.children) dress(child);
79
- };
80
- const roots = runTree(stored.map(({ event }) => event));
81
- for (const root of roots) dress(root);
82
- return roots;
83
- };
84
14
  // ../server/src/contract-builder.ts
85
15
  /** A new workflow's name, as its file and its `name:` take it. */
86
16
  const NewWorkflowSchema = z.strictObject({ name: z.string().min(1) });
@@ -167,7 +97,13 @@ const AcceptSchema = z.strictObject({
167
97
  /** Which workflow's lessons, when it was seen in more than one. */
168
98
  workflow: z.string().min(1).optional()
169
99
  });
170
- const ApplySchema = z.strictObject({ driver: z.enum(["sdk", "cli"]).optional() });
100
+ const DriverIdSchema = z.enum({
101
+ "claude-code": "claude-code",
102
+ "open-code": "open-code",
103
+ "command-code": "command-code"
104
+ });
105
+ DriverIdSchema.options;
106
+ const ApplySchema = z.strictObject({ driver: DriverIdSchema.optional() });
171
107
  const PublishPreviewSchema = z.strictObject({
172
108
  /** Also hide the repositories' and workflows' names. */
173
109
  hideNames: z.boolean() });
@@ -327,7 +263,6 @@ const WORKTREES_API = {
327
263
  // ../server/src/contract.ts
328
264
  const Count = z.coerce.number().int().positive();
329
265
  const Seq = z.coerce.number().int().nonnegative();
330
- const Driver = z.enum(["sdk", "cli"]);
331
266
  const RunsQuerySchema = z.strictObject({
332
267
  project: z.string().min(1).optional(),
333
268
  limit: Count.optional()
@@ -349,7 +284,9 @@ const EventsQuerySchema = z.strictObject({
349
284
  });
350
285
  const DecisionsQuerySchema = z.strictObject({
351
286
  run: z.string().min(1).optional(),
352
- project: z.string().min(1).optional()
287
+ project: z.string().min(1).optional(),
288
+ /** Only runs of this workflow, by name; ANDed with `run` or `project`. */
289
+ workflow: z.string().min(1).optional()
353
290
  });
354
291
  /** An answer: the option, and what the person said with it, if anything. */
355
292
  const AnswerSchema = z.strictObject({
@@ -358,7 +295,7 @@ const AnswerSchema = z.strictObject({
358
295
  });
359
296
  const RunFlags = {
360
297
  inputs: z.record(z.string(), z.string()).optional(),
361
- driver: Driver.optional(),
298
+ driver: DriverIdSchema.optional(),
362
299
  inPlace: z.boolean().optional(),
363
300
  allowDirty: z.boolean().optional()
364
301
  };
@@ -367,7 +304,9 @@ const StartRunSchema = z.strictObject({
367
304
  project: z.string().min(1),
368
305
  /** A workflow's name in the project, or a path inside the project. */
369
306
  workflow: z.string().min(1),
370
- ...RunFlags
307
+ ...RunFlags,
308
+ /** Its sessions load the machine's Claude setup (`--machine-claude`). */
309
+ machineClaude: z.boolean().optional()
371
310
  });
372
311
  const ResumeRunSchema = z.strictObject(RunFlags);
373
312
  const MessageSchema = z.strictObject({
@@ -481,7 +420,8 @@ const STREAMS = {
481
420
  run: "/api/runs/:id/stream",
482
421
  /**
483
422
  * `runs`, `decisions`, `version`, each when it changes; `?project=` keeps
484
- * one. `upgrade`: the upgrade's output, then `end` (contract-update.ts).
423
+ * one, `?workflow=` narrows `decisions` to that workflow's. `upgrade`: the
424
+ * upgrade's output, then `end` (contract-update.ts).
485
425
  */
486
426
  overview: "/api/stream",
487
427
  upgrade: "/api/upgrade/stream"
@@ -941,7 +881,8 @@ const flagsOf = (options) => [
941
881
  ...Object.entries(options.inputs ?? {}).flatMap(([name, value]) => ["--input", `${name}=${value}`]),
942
882
  ...options.driver === void 0 ? [] : ["--driver", options.driver],
943
883
  ...options.inPlace === void 0 ? [] : [options.inPlace ? "--in-place" : "--no-in-place"],
944
- ...options.allowDirty === true ? ["--allow-dirty"] : []
884
+ ...options.allowDirty === true ? ["--allow-dirty"] : [],
885
+ ...options.machineClaude === true ? ["--machine-claude"] : []
945
886
  ];
946
887
  const WORKFLOW_SUFFIX = ".ork.yaml";
947
888
  /**
@@ -1607,7 +1548,7 @@ const readRoutes = (context) => ({
1607
1548
  tree: ({ params }) => {
1608
1549
  const found = runOf(context, params.id);
1609
1550
  if (!found.ok) return found.refusal;
1610
- return ok(activeTree(context.store.events(found.run.id)));
1551
+ return ok(nestItems(activeTree(context.store.events(found.run.id))));
1611
1552
  },
1612
1553
  graph: ({ params }) => {
1613
1554
  const found = runOf(context, params.id);
@@ -1617,15 +1558,22 @@ const readRoutes = (context) => ({
1617
1558
  events: ({ params, query }) => {
1618
1559
  const found = runOf(context, params.id);
1619
1560
  if (!found.ok) return found.refusal;
1620
- const events = context.store.events(found.run.id, query.after ?? 0).filter((s) => query.node === void 0 || nodeOf(s.event) === query.node);
1561
+ const events = context.store.events(found.run.id, query.after ?? 0).filter((s) => query.node === void 0 || isNodeEvent(s.event, query.node));
1621
1562
  const newest = query.last === void 0 ? events : events.slice(-query.last);
1622
1563
  return ok(query.limit === void 0 ? newest : newest.slice(0, query.limit));
1623
1564
  },
1624
1565
  decisions: ({ query }) => {
1625
- if (query.run === void 0) return ok(pendingDecisions(context.store, query.project === void 0 ? {} : { project: projectRoot(context, query.project) }));
1566
+ const workflow = query.workflow === void 0 ? {} : { workflow: query.workflow };
1567
+ if (query.run === void 0) return ok(pendingDecisions(context.store, {
1568
+ ...workflow,
1569
+ ...query.project === void 0 ? {} : { project: projectRoot(context, query.project) }
1570
+ }));
1626
1571
  const found = runOf(context, query.run);
1627
1572
  if (!found.ok) return found.refusal;
1628
- return ok(pendingDecisions(context.store, { runId: found.run.id }));
1573
+ return ok(pendingDecisions(context.store, {
1574
+ ...workflow,
1575
+ runId: found.run.id
1576
+ }));
1629
1577
  },
1630
1578
  decision: ({ params }) => {
1631
1579
  const found = context.store.decision(params.id);
@@ -2866,6 +2814,7 @@ const runStream = async (context, req, res, url, id, shutdown) => {
2866
2814
  const overviewStream = (context, res, url, shutdown) => {
2867
2815
  const key = url.searchParams.get("project");
2868
2816
  const root = key === null ? void 0 : projectOf(context, key)?.root ?? key;
2817
+ const workflow = url.searchParams.get("workflow");
2869
2818
  const stream = openEventStream(res);
2870
2819
  const last = {
2871
2820
  runs: "",
@@ -2878,7 +2827,10 @@ const overviewStream = (context, res, url, shutdown) => {
2878
2827
  ...filter,
2879
2828
  limit: OVERVIEW_RUNS
2880
2829
  }).map((run) => viewOf$2(context, run));
2881
- const decisions = pendingDecisions(context.store, filter);
2830
+ const decisions = pendingDecisions(context.store, {
2831
+ ...filter,
2832
+ ...workflow === null ? {} : { workflow }
2833
+ });
2882
2834
  for (const [name, value] of [
2883
2835
  ["runs", runs],
2884
2836
  ["decisions", decisions],