loki-mode 11.145.0 → 11.146.0

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 (76) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/dashboard/__init__.py +1 -1
  4. package/docs/CLI-REFERENCE.md +1 -1
  5. package/docs/INSTALLATION.md +1 -1
  6. package/loki-ts/dist/loki.js +1693 -1689
  7. package/mcp/__init__.py +1 -1
  8. package/package.json +2 -2
  9. package/packages/control-plane/dist/ask-tools-server.js +10 -1
  10. package/packages/control-plane/dist/server.js +521 -26
  11. package/packages/control-plane/src/server/routes/index.ts +2 -1
  12. package/packages/control-plane/src/server/routes/workspace.ts +126 -0
  13. package/packages/control-plane/src/server/runs.ts +8 -0
  14. package/packages/control-plane/ui/dist/assets/index-CWUisTer.css +1 -0
  15. package/packages/control-plane/ui/dist/assets/index-CwNcWbo3.js +151 -0
  16. package/packages/control-plane/ui/dist/index.html +2 -2
  17. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  18. package/web-app/dist/assets/{AdminPage-Dtrte_9h.js → AdminPage-DeR4gl6L.js} +1 -1
  19. package/web-app/dist/assets/{Avatar-BqDxz5Iw.js → Avatar-ByWp4bxk.js} +1 -1
  20. package/web-app/dist/assets/{Badge-BGX45Lnh.js → Badge-D7AlqwvS.js} +1 -1
  21. package/web-app/dist/assets/{Button-DVr538c3.js → Button-B0Mukoh2.js} +1 -1
  22. package/web-app/dist/assets/{CockpitPage-CIODjzWx.js → CockpitPage-BZRQbXD_.js} +1 -1
  23. package/web-app/dist/assets/{ComparePage-DSaexpQe.js → ComparePage-B_rn9nnQ.js} +1 -1
  24. package/web-app/dist/assets/{ErrorBoundary-CnkNmsIK.js → ErrorBoundary-Cp0pyJvY.js} +1 -1
  25. package/web-app/dist/assets/{EvidenceReceiptPanel-BOYje705.js → EvidenceReceiptPanel-DmWRoowG.js} +1 -1
  26. package/web-app/dist/assets/{GitHubIssuesPanel-D-obZbg0.js → GitHubIssuesPanel-B5DI_-br.js} +1 -1
  27. package/web-app/dist/assets/{GitHubPRsPanel-BDP6UPrV.js → GitHubPRsPanel-CW0LYfHT.js} +1 -1
  28. package/web-app/dist/assets/{HomePage-CyuUJmkD.js → HomePage-DPSWa5R5.js} +2 -2
  29. package/web-app/dist/assets/{LoginPage-CwzpHE77.js → LoginPage-CwoGp6Vj.js} +1 -1
  30. package/web-app/dist/assets/{MagicPage-B-2U-xDs.js → MagicPage-gkNRlwuf.js} +1 -1
  31. package/web-app/dist/assets/{MetricsPage-cNfnAqIP.js → MetricsPage-CDnOCldd.js} +1 -1
  32. package/web-app/dist/assets/{NotFoundPage-Bnja4u7t.js → NotFoundPage-Bnvssp3g.js} +1 -1
  33. package/web-app/dist/assets/{ProjectPage-DxKwokda.js → ProjectPage-DgtG5BlM.js} +3 -3
  34. package/web-app/dist/assets/{ProjectsPage-D0HElwG2.js → ProjectsPage-Ckbjkg_L.js} +1 -1
  35. package/web-app/dist/assets/{SettingsPage-cKZTmoDV.js → SettingsPage-D-R2gEUm.js} +1 -1
  36. package/web-app/dist/assets/{ShowcasePage-COCzMSj2.js → ShowcasePage-Em9ddqYI.js} +1 -1
  37. package/web-app/dist/assets/{SystemSettingsPage-DpEdU35g.js → SystemSettingsPage-gN8Y0061.js} +1 -1
  38. package/web-app/dist/assets/{TeamsPage-CRa-oR3c.js → TeamsPage-CUuN5SDA.js} +1 -1
  39. package/web-app/dist/assets/{TemplatesPage-CqVQ2RrJ.js → TemplatesPage-CXOEV__d.js} +1 -1
  40. package/web-app/dist/assets/{TerminalOutput-77EBpy6w.js → TerminalOutput-BWG3HITb.js} +1 -1
  41. package/web-app/dist/assets/{activity-CwYJMGXJ.js → activity-DxQfYkTL.js} +1 -1
  42. package/web-app/dist/assets/{bell-D7tpnhHd.js → bell-BwhFGRVu.js} +1 -1
  43. package/web-app/dist/assets/{bot-BGEMExhD.js → bot-CyvCOo2P.js} +1 -1
  44. package/web-app/dist/assets/{check-DXYfUB9x.js → check-BO8HHeFn.js} +1 -1
  45. package/web-app/dist/assets/{chevron-left-fmjoQGhm.js → chevron-left-DHacGkaA.js} +1 -1
  46. package/web-app/dist/assets/{circle-alert-Bg5XeK2P.js → circle-alert-CtUDR5al.js} +1 -1
  47. package/web-app/dist/assets/{clock-CsKyZSPS.js → clock-eFnNWkzH.js} +1 -1
  48. package/web-app/dist/assets/{cloud-Bd60jog4.js → cloud-CNw2NygE.js} +1 -1
  49. package/web-app/dist/assets/{code-xml-Ctl0DdWZ.js → code-xml-epWPsMsv.js} +1 -1
  50. package/web-app/dist/assets/{database-ziASlG1B.js → database-DF7YXeji.js} +1 -1
  51. package/web-app/dist/assets/{dollar-sign-Bo2f3aLO.js → dollar-sign-3qMKGL_Z.js} +1 -1
  52. package/web-app/dist/assets/{file-code-corner-BZCY8u6u.js → file-code-corner-d4385evP.js} +1 -1
  53. package/web-app/dist/assets/{file-plus-DZX_AwtZ.js → file-plus-BdY4WvqD.js} +1 -1
  54. package/web-app/dist/assets/{globe-BqP4Lntz.js → globe-D-pzos7L.js} +1 -1
  55. package/web-app/dist/assets/{hammer-KMjpooTk.js → hammer-CKSu1dvx.js} +1 -1
  56. package/web-app/dist/assets/{index-B_8pnUwl.js → index-MgAdMJ-_.js} +3 -3
  57. package/web-app/dist/assets/{layers-Bdkz5DFw.js → layers-Df6wyWQv.js} +1 -1
  58. package/web-app/dist/assets/{loader-circle-BV_0L7bg.js → loader-circle-D7ToQmQ_.js} +1 -1
  59. package/web-app/dist/assets/{lock-DhK1z1dB.js → lock-tnSuBc1R.js} +1 -1
  60. package/web-app/dist/assets/{package-De8MCdUa.js → package-Bjca3WQy.js} +1 -1
  61. package/web-app/dist/assets/{plus-BQbDrNgm.js → plus-DuwA_qsO.js} +1 -1
  62. package/web-app/dist/assets/{refresh-cw-BQ2ezlqR.js → refresh-cw-Da58kJj9.js} +1 -1
  63. package/web-app/dist/assets/{rotate-ccw-EuVYh2XK.js → rotate-ccw-Fkw8w7IS.js} +1 -1
  64. package/web-app/dist/assets/{scroll-text-BcrL2UnM.js → scroll-text-C8H6DOOY.js} +1 -1
  65. package/web-app/dist/assets/{server-dpdGPXDc.js → server-BM6Vt7xD.js} +1 -1
  66. package/web-app/dist/assets/{shield-alert-B2AnkpV_.js → shield-alert-DWYdFESN.js} +1 -1
  67. package/web-app/dist/assets/{thumbs-up-Zock-j5_.js → thumbs-up-Dl3OOA_N.js} +1 -1
  68. package/web-app/dist/assets/{trash-2-B9zGFCn0.js → trash-2-BspuXMRV.js} +1 -1
  69. package/web-app/dist/assets/{trending-down-DWQW56VW.js → trending-down-DK9U9VEk.js} +1 -1
  70. package/web-app/dist/assets/{trending-up--6mzkyyP.js → trending-up-C5RaQYmy.js} +1 -1
  71. package/web-app/dist/assets/{upload-CNxdXaU0.js → upload-CMZ51Yr8.js} +1 -1
  72. package/web-app/dist/assets/{usePolling-CVHCrC_t.js → usePolling-DZ1CmD1A.js} +1 -1
  73. package/web-app/dist/assets/{user-CuL3zj1a.js → user-C-xZ3AXa.js} +1 -1
  74. package/web-app/dist/index.html +1 -1
  75. package/packages/control-plane/ui/dist/assets/index-DeSVrWgd.css +0 -1
  76. package/packages/control-plane/ui/dist/assets/index-Dy80VLtj.js +0 -190
@@ -34447,6 +34447,10 @@ ${r.session.summary}` };
34447
34447
  if (!pr)
34448
34448
  break;
34449
34449
  proofRounds.push({ exit: pr.exit, failed: pr.failed, seconds: pr.seconds });
34450
+ {
34451
+ const la0 = labelAsks(ctx.provider, prior.intake, prior.plan, ctx.repoDir);
34452
+ ctx.emit("proof.rerun", "implement", { round: round2 + 1, exit: pr.exit, proved: pr.proved, failed: pr.failed, seconds: pr.seconds, source: la0.source, statuses: ruleStatus(la0.asks, pr).map((s, i) => ({ line: s.line, status: s.status, checks: pr.lines[String(i + 1)]?.proved ?? 0, ...s.reason ? { reason: s.reason } : {} })) });
34453
+ }
34450
34454
  if (pr.exit === 0 && pr.failed === 0) {
34451
34455
  const la = labelAsks(ctx.provider, prior.intake, prior.plan, ctx.repoDir);
34452
34456
  if (!la.asks.length || round2 + 1 >= proofLoopMax())
@@ -34463,6 +34467,7 @@ ${r.session.summary}` };
34463
34467
  return lc.marks && !lc.marks.met.includes(i + 1) ? [{ line: `${i + 1}. ${line2}`, reason: `it has a passing check, but a reviewer found a gap: ${lc.reasons?.[String(i + 1)] ?? "not stated"}` }] : [];
34464
34468
  });
34465
34469
  lineRounds.push({ met: lc.marks?.met.length ?? 0, unmet: unmet.length, usd: lc.usd });
34470
+ ctx.emit("acceptance.round", "implement", { round: round2 + 1, met: la.asks.length - unmet.length, unmet: unmet.length });
34466
34471
  if (!unmet.length)
34467
34472
  break;
34468
34473
  const r2 = await resumeForProofScript(ctx, { ...unchained(), iterationId: ids[ids.length - 1] }, session, unmetBrief(unmet));
@@ -40690,7 +40695,7 @@ var init_seal = __esm(() => {
40690
40695
  `);
40691
40696
  }
40692
40697
  const signed = sig.jwt !== null;
40693
- const data = { ...wallPub ? { wall_published: { files: wp.files.map((f) => f.rel), cmds: [...new Set(wp.files.map((f) => f.cmd))] } } : {}, ...wallKept.length ? { wall_kept: { files: wallKept.map((f) => f.rel), sha256: wallKept.map((f) => createHash28("sha256").update(f.bytes).digest("hex")), cmds: [...new Set(wallKept.map((f) => f.cmd))], sealed_dir: sealedWallDir(ctx.runDir) } } : {}, receipt_path: path, receipt_sha256: hash, signed, kid: sig.kid, verdict, not_proven: receipt.not_proven, ...receipt.context ? { context: receipt.context } : {}, ...mp ? { mutation_line: mp.line } : {}, ...routeBlock ? { route_line: routePrLine(routeBlock) } : {} };
40698
+ const data = { ...wallPub ? { wall_published: { files: wp.files.map((f) => f.rel), cmds: [...new Set(wp.files.map((f) => f.cmd))] } } : {}, ...wallKept.length ? { wall_kept: { files: wallKept.map((f) => f.rel), sha256: wallKept.map((f) => createHash28("sha256").update(f.bytes).digest("hex")), cmds: [...new Set(wallKept.map((f) => f.cmd))], sealed_dir: sealedWallDir(ctx.runDir) } } : {}, receipt_path: path, receipt_sha256: hash, signed, kid: sig.kid, verdict, not_proven: receipt.not_proven, ...issueSt ? { issue_acceptance: issueSt.map((s, i) => ({ line: s.line, status: s.status, checks: proofRun?.lines[String(i + 1)]?.proved ?? 0, ..."reason" in s && s.reason ? { reason: s.reason } : {} })), issue_acceptance_source: listed.length ? "issue" : "plan" } : {}, ...receipt.context ? { context: receipt.context } : {}, ...mp ? { mutation_line: mp.line } : {}, ...routeBlock ? { route_line: routePrLine(routeBlock) } : {} };
40694
40699
  try {
40695
40700
  recordRunVerdict(ctx.repoDir, ctx.runId, verdict);
40696
40701
  } catch {}
@@ -41737,6 +41742,288 @@ var init_liveline = __esm(() => {
41737
41742
  LIVE_LABELS = { intake: "reading the task", plan: "planning", wall: "writing acceptance checks", implement: "implementing", verify: "verifying", fix: "fixing failures", commit: "committing", seal: "sealing the receipt", pr: "opening the PR", deep: "deep review" };
41738
41743
  });
41739
41744
 
41745
+ // ../../loki-ts/src/e10ext/console.ts
41746
+ class LiveConsole {
41747
+ o;
41748
+ t0;
41749
+ drawn = 0;
41750
+ closed = false;
41751
+ details = false;
41752
+ rawOn = false;
41753
+ title = "Loki";
41754
+ model = "";
41755
+ url = null;
41756
+ spent = null;
41757
+ stage = new Map;
41758
+ lines = [];
41759
+ lineSource = "the issue's own lines";
41760
+ seen = [];
41761
+ recent = [];
41762
+ diff = "";
41763
+ proof = "";
41764
+ tests = { pass: 0, fail: 0 };
41765
+ outcome = "";
41766
+ out;
41767
+ unhook = [];
41768
+ midLine = false;
41769
+ constructor(o) {
41770
+ this.o = o;
41771
+ this.t0 = (o.now ?? Date.now)();
41772
+ this.out = o.write ?? ((x) => {
41773
+ process.stdout.write(x);
41774
+ });
41775
+ if (!o.write && o.hookStd !== false)
41776
+ this.hook();
41777
+ this.keys();
41778
+ }
41779
+ hook() {
41780
+ const raw2 = process.stdout.write.bind(process.stdout);
41781
+ this.out = (x) => {
41782
+ raw2(x);
41783
+ };
41784
+ for (const st of [process.stdout, process.stderr]) {
41785
+ const orig = st.write.bind(st);
41786
+ this.unhook.push(() => {
41787
+ st.write = orig;
41788
+ });
41789
+ st.write = (chunk, ...rest) => {
41790
+ if (this.closed)
41791
+ return orig(chunk, ...rest);
41792
+ if (this.drawn > 0) {
41793
+ raw2(`\x1B[${this.drawn}A\r\x1B[J`);
41794
+ this.drawn = 0;
41795
+ }
41796
+ const r = orig(chunk, ...rest), text4 = typeof chunk === "string" ? chunk : chunk instanceof Uint8Array ? Buffer.from(chunk).toString("utf8") : "";
41797
+ if (text4)
41798
+ this.midLine = !text4.endsWith(`
41799
+ `);
41800
+ if (!this.redrawQueued) {
41801
+ this.redrawQueued = true;
41802
+ setImmediate(() => {
41803
+ this.redrawQueued = false;
41804
+ if (!this.closed)
41805
+ this.render();
41806
+ });
41807
+ }
41808
+ return r;
41809
+ };
41810
+ }
41811
+ }
41812
+ redrawQueued = false;
41813
+ now() {
41814
+ return (this.o.now ?? Date.now)();
41815
+ }
41816
+ get color() {
41817
+ return !(this.o.env ?? process.env)["NO_COLOR"];
41818
+ }
41819
+ c(code, s) {
41820
+ return this.color ? `\x1B[${code}m${s}\x1B[0m` : s;
41821
+ }
41822
+ safe(s, w) {
41823
+ const t = redactSecrets(String(s).replace(/[\t\r\n]+/g, " ").replace(UNSAFE_TERMINAL_CHARS_RE, " "));
41824
+ return t.length > w ? `${t.slice(0, Math.max(0, w - 3))}...` : t;
41825
+ }
41826
+ note(s) {
41827
+ this.recent.push(s);
41828
+ if (this.recent.length > 40)
41829
+ this.recent.shift();
41830
+ }
41831
+ setUrl(u) {
41832
+ if (u) {
41833
+ this.url = u;
41834
+ this.render();
41835
+ }
41836
+ }
41837
+ keys() {
41838
+ const stdin = this.o.stdin === undefined ? process.stdin : this.o.stdin;
41839
+ if (!stdin || !stdin.isTTY || typeof stdin.setRawMode !== "function")
41840
+ return;
41841
+ try {
41842
+ stdin.setRawMode(true);
41843
+ stdin.resume();
41844
+ this.rawOn = true;
41845
+ const restore = () => {
41846
+ if (this.rawOn) {
41847
+ try {
41848
+ stdin.setRawMode(false);
41849
+ stdin.pause();
41850
+ } catch {}
41851
+ this.rawOn = false;
41852
+ }
41853
+ };
41854
+ process.once("exit", restore);
41855
+ this.restore = restore;
41856
+ stdin.on("data", (b) => {
41857
+ const k = b.toString("utf8");
41858
+ if (k === "d" || k === "D") {
41859
+ this.details = !this.details;
41860
+ this.render();
41861
+ } else if (k === "\x03" || k === "q" || k === "Q") {
41862
+ restore();
41863
+ (this.o.onCancel ?? (() => {
41864
+ process.kill(process.pid, "SIGINT");
41865
+ }))();
41866
+ }
41867
+ });
41868
+ } catch {
41869
+ this.rawOn = false;
41870
+ }
41871
+ }
41872
+ restore = () => {};
41873
+ onEvent(e) {
41874
+ if (this.closed)
41875
+ return;
41876
+ const d = e.data ?? {};
41877
+ if (e.type === "run.started" || e.type === "run.resumed") {
41878
+ const ref = d["issue_ref"] ?? d["task_title"];
41879
+ if (typeof ref === "string" && ref)
41880
+ this.title = ref;
41881
+ if (typeof d["model"] === "string")
41882
+ this.model = String(d["model"]);
41883
+ }
41884
+ const cp = d["control_plane_url"];
41885
+ if (typeof cp === "string" && cp)
41886
+ this.url = cp;
41887
+ this.seen.push(e);
41888
+ if (e.type === "cost") {
41889
+ try {
41890
+ this.spent = (this.o.spend ?? ((ev) => spendSoFar(ev, this.o.repoDir ? `${this.o.repoDir}/.loki` : undefined)))(this.seen).replace(/^\((.*)\)$/, "$1");
41891
+ } catch {}
41892
+ }
41893
+ if (e.stage && e.type === "stage.started") {
41894
+ this.stage.set(e.stage, { state: "running", at: this.now() });
41895
+ this.note(`${e.stage} started`);
41896
+ } else if (e.stage && /^stage\.(completed|failed|skipped)$/.test(e.type)) {
41897
+ const st = e.type === "stage.completed" ? "done" : e.type === "stage.failed" ? "failed" : "skipped", prev = this.stage.get(e.stage);
41898
+ this.stage.set(e.stage, { state: st, at: prev?.at ?? this.now(), s: typeof d["duration_s"] === "number" ? d["duration_s"] : prev ? (this.now() - prev.at) / 1000 : undefined });
41899
+ this.note(`${e.stage} ${st}${typeof d["reason"] === "string" ? `: ${d["reason"]}` : ""}`);
41900
+ if (e.stage === "intake" && Array.isArray(d["issue_acceptance"]) && d["issue_acceptance"].length)
41901
+ this.lines = d["issue_acceptance"].map((t) => ({ text: String(t), state: "waiting", checks: 0 }));
41902
+ if (e.stage === "seal" && Array.isArray(d["issue_acceptance"]))
41903
+ this.setLines(d["issue_acceptance"], d["issue_acceptance_source"]);
41904
+ if (e.stage === "seal" && typeof d["verdict"] === "string")
41905
+ this.outcome = String(d["verdict"]);
41906
+ }
41907
+ if (e.type === "heartbeat" && d["diff"] && typeof d["diff"] === "object") {
41908
+ const x = d["diff"];
41909
+ this.diff = `${Number(x["files"] ?? 0)} files changed, +${Number(x["insertions"] ?? 0)} -${Number(x["deletions"] ?? 0)}`;
41910
+ }
41911
+ if (e.type === "test.result") {
41912
+ if (d["result"] === "pass")
41913
+ this.tests.pass++;
41914
+ else if (d["result"] === "fail")
41915
+ this.tests.fail++;
41916
+ }
41917
+ if (e.type === "proof.rerun") {
41918
+ this.proof = `Loki ran the proof itself, round ${Number(d["round"] ?? 1)}: ${d["exit"] === 0 ? "passed" : "did not pass"}, ${Number(d["proved"] ?? 0)} passing and ${Number(d["failed"] ?? 0)} failing checks in ${Number(d["seconds"] ?? 0)}s`;
41919
+ this.note(this.proof);
41920
+ if (Array.isArray(d["statuses"]))
41921
+ this.setLines(d["statuses"], d["source"]);
41922
+ }
41923
+ if (e.type === "acceptance.round")
41924
+ this.note(`acceptance check, round ${Number(d["round"] ?? 1)}: ${Number(d["met"] ?? 0)} met, ${Number(d["unmet"] ?? 0)} handed back to the session`);
41925
+ this.render();
41926
+ }
41927
+ setLines(rows, source) {
41928
+ if (!rows.length)
41929
+ return;
41930
+ this.lines = rows.map((r, i) => ({ text: String(r["line"] ?? this.lines[i]?.text ?? `line ${i + 1}`), state: r["status"] === "met" ? "met" : r["status"] === "unmet" ? "unmet" : "waiting", checks: Number(r["checks"] ?? 0), ...typeof r["reason"] === "string" ? { why: r["reason"] } : {} }));
41931
+ if (source === "plan")
41932
+ this.lineSource = "written by Loki from the issue";
41933
+ }
41934
+ frame(final = false) {
41935
+ const w = Math.max(50, terminalWidth({ columns: this.o.columns }) - 1), out2 = [];
41936
+ const right = [this.model, formatDuration((this.now() - this.t0) / 1000), this.spent ?? ""].filter(Boolean).join(" ");
41937
+ const left = this.safe(`LOKI ${this.title}`, Math.max(10, w - right.length - 2));
41938
+ out2.push(`${this.c("1", left)}${" ".repeat(Math.max(1, w - left.length - right.length))}${this.c("2", right)}`);
41939
+ out2.push(this.c("2", "-".repeat(w)));
41940
+ const tag = (s) => s === "done" ? this.c("32", "done") : s === "running" ? this.c("33", "now ") : s === "failed" ? this.c("31", "FAIL") : s === "skipped" ? this.c("2", "skip") : this.c("2", " ");
41941
+ const cells = STAGES.filter(([k]) => k !== "fix" || this.stage.has("fix")).map(([k, label3]) => {
41942
+ const st = this.stage.get(k);
41943
+ const s = st?.state ?? "waiting";
41944
+ const t = s === "running" && st ? ` ${formatDuration((this.now() - st.at) / 1000)}` : s === "done" && st?.s !== undefined ? ` ${formatDuration(st.s)}` : "";
41945
+ return { plain: `[${s === "done" ? "done" : s === "running" ? "now " : s === "failed" ? "FAIL" : s === "skipped" ? "skip" : " "}] ${label3}${t}`, shown: `[${tag(s)}] ${label3}${this.c("2", t)}` };
41946
+ });
41947
+ let row = "", rowPlain = "";
41948
+ for (const c of cells) {
41949
+ if (rowPlain.length + c.plain.length + 3 > w && rowPlain) {
41950
+ out2.push(row);
41951
+ row = "";
41952
+ rowPlain = "";
41953
+ }
41954
+ row += (rowPlain ? " " : "") + c.shown;
41955
+ rowPlain += (rowPlain ? " " : "") + c.plain;
41956
+ }
41957
+ if (rowPlain)
41958
+ out2.push(row);
41959
+ out2.push("");
41960
+ if (this.lines.length) {
41961
+ const met = this.lines.filter((l) => l.state === "met").length;
41962
+ out2.push(`${this.c("1", "Acceptance")} ${this.c("2", `(${this.lineSource})`)} ${met} of ${this.lines.length} met`);
41963
+ this.lines.forEach((l, i) => {
41964
+ const mark = l.state === "met" ? this.c("32", "[ ok ]") : l.state === "unmet" ? this.c("31", "[ no ]") : this.c("2", "[ .. ]");
41965
+ const tail2 = l.state === "met" && l.checks ? ` ${l.checks} check${l.checks === 1 ? "" : "s"}` : "";
41966
+ out2.push(` ${mark} ${String(i + 1).padStart(2)} ${this.safe(l.text, w - 16 - tail2.length)}${this.c("2", tail2)}`);
41967
+ if (l.state === "unmet" && l.why && (final || this.details))
41968
+ out2.push(this.c("2", ` ${this.safe(l.why, w - 14)}`));
41969
+ });
41970
+ out2.push("");
41971
+ }
41972
+ const cur = [...this.stage.entries()].reverse().find(([, v]) => v.state === "running")?.[0];
41973
+ if (!final && cur)
41974
+ out2.push(`${this.c("1", "Now:")} ${this.safe(`${NOW[cur] ?? cur}${cur === "implement" && this.diff ? ` (${this.diff})` : ""}${cur === "verify" && this.tests.pass + this.tests.fail ? ` (${this.tests.pass} passed, ${this.tests.fail} failed so far)` : ""}`, w - 6)}`);
41975
+ if (this.proof)
41976
+ out2.push(this.safe(this.proof, w));
41977
+ if (this.details && !final) {
41978
+ out2.push(this.c("2", "Recent:"));
41979
+ for (const r of this.recent.slice(-8))
41980
+ out2.push(this.c("2", ` ${this.safe(r, w - 2)}`));
41981
+ }
41982
+ if (!final)
41983
+ out2.push(this.c("2", this.safe(`d details q or Ctrl-C stop (loki start resumes it)${this.url ? ` ${this.url}` : ""}`, w)));
41984
+ return out2;
41985
+ }
41986
+ tick() {
41987
+ if (!this.closed)
41988
+ this.render();
41989
+ }
41990
+ render(final = false) {
41991
+ const f = this.frame(final), up = this.drawn > 0 ? `\x1B[${this.drawn}A` : "";
41992
+ let s = `\x1B[?25l${this.drawn === 0 && this.midLine ? `
41993
+ ` : ""}${up}`;
41994
+ this.midLine = false;
41995
+ for (const l of f)
41996
+ s += `\r\x1B[2K${l}
41997
+ `;
41998
+ for (let i = f.length;i < this.drawn; i++)
41999
+ s += `\r\x1B[2K
42000
+ `;
42001
+ if (this.drawn > f.length)
42002
+ s += `\x1B[${this.drawn - f.length}A`;
42003
+ this.out(s);
42004
+ this.drawn = f.length;
42005
+ }
42006
+ clear() {
42007
+ if (this.closed)
42008
+ return;
42009
+ this.render(true);
42010
+ this.closed = true;
42011
+ this.out("\x1B[?25h");
42012
+ for (const u of this.unhook)
42013
+ u();
42014
+ this.unhook = [];
42015
+ this.restore();
42016
+ }
42017
+ }
42018
+ var STAGES, NOW, consoleOn = (env = process.env, tty = !!process.stdout.isTTY) => tty && !/^(0|off|false|no)$/i.test((env["LOKI_CONSOLE"] ?? "").trim()) && env["TERM"] !== "dumb";
42019
+ var init_console = __esm(() => {
42020
+ init_output();
42021
+ init_term_width();
42022
+ init_redact();
42023
+ STAGES = [["intake", "read"], ["plan", "plan"], ["implement", "build"], ["verify", "verify"], ["fix", "fix"], ["commit", "commit"], ["seal", "label"], ["pr", "pull request"]];
42024
+ NOW = { intake: "reading the task", plan: "planning the change", implement: "the session is building and running the product", verify: "running the repository's tests", fix: "fixing what the tests found", commit: "committing", seal: "checking every line and writing the receipt", pr: "opening the pull request" };
42025
+ });
42026
+
41740
42027
  // ../../loki-ts/src/cli/registry.ts
41741
42028
  var exports_registry = {};
41742
42029
  __export(exports_registry, {
@@ -48895,9 +49182,11 @@ usage: loki "<goal>" (or: loki start <prd.md | owner/repo#N>)
48895
49182
  }
48896
49183
  }, 100);
48897
49184
  let liveStop = () => {};
48898
- const liveLine = !verbose && !json2 ? new LiveLine({ tty: !!process.stdout.isTTY, write: (x) => {
49185
+ const liveLine = verbose || json2 ? null : consoleOn() ? new LiveConsole({ write: (x) => {
48899
49186
  process.stdout.write(x);
48900
- }, columns: terminalWidth(), graceS: 3, repoDir }) : null;
49187
+ }, repoDir }) : new LiveLine({ tty: !!process.stdout.isTTY, write: (x) => {
49188
+ process.stdout.write(x);
49189
+ }, columns: terminalWidth(), graceS: 3, repoDir });
48901
49190
  if (liveLine) {
48902
49191
  if (process.env.LOKI_CONTROL_PLANE_URL)
48903
49192
  liveLine.setUrl(process.env.LOKI_CONTROL_PLANE_URL);
@@ -49099,6 +49388,7 @@ var init_supervisor = __esm(() => {
49099
49388
  init_tracker_intake();
49100
49389
  init_output();
49101
49390
  init_liveline();
49391
+ init_console();
49102
49392
  init_worker_proc();
49103
49393
  init_intent_card();
49104
49394
  init_preflight();
@@ -97968,7 +98258,8 @@ function implementWriteFence(cwd) {
97968
98258
  const stage11 = process.env["LOKI_E10_STAGE"], deny = [...cwd && stage11 ? stateDenyRules(cwd, harnessOutputs(cwd, process.env)) : [], ...cwd && fenceEnabled(stage11) ? fencedDenyRules(cwd, process.env) : []];
97969
98259
  if (stage11 !== "implement" && deny.length === 0)
97970
98260
  return;
97971
- return { permissions: { ...stage11 === "implement" ? { blockWritesOutsideWorkingDirectories: true } : {}, ...deny.length > 0 ? { deny } : {} } };
98261
+ const scratch = process.env["LOKI_SCRATCH"];
98262
+ return { permissions: { ...stage11 === "implement" ? { blockWritesOutsideWorkingDirectories: true, ...scratch ? { additionalDirectories: [scratch] } : {} } : {}, ...deny.length > 0 ? { deny } : {} } };
97972
98263
  }
97973
98264
  async function writeCaptured(path, stdout, stderr) {
97974
98265
  ensureParentDir(path);
@@ -98024,6 +98315,7 @@ function claudeProvider() {
98024
98315
  ...modelArgv,
98025
98316
  ...autoFlags,
98026
98317
  ...sessionArgv,
98318
+ ...process.env["LOKI_SCRATCH"] && claudeFlagSupported("--add-dir") ? ["--add-dir", process.env["LOKI_SCRATCH"]] : [],
98027
98319
  ...hostGuard2 || sessionSettings || fence3 ? ["--settings", cliSettingsJson(hostGuard2, sessionSettings, fence3)] : [],
98028
98320
  "-p",
98029
98321
  call.prompt
@@ -128059,8 +128351,8 @@ var init_verify_cmd = __esm(() => {
128059
128351
  });
128060
128352
 
128061
128353
  // src/server/app.ts
128062
- import { existsSync as existsSync123, readFileSync as readFileSync158, statSync as statSync53 } from "fs";
128063
- import { join as join172, resolve as resolve46, sep as sep30 } from "path";
128354
+ import { existsSync as existsSync124, readFileSync as readFileSync159, statSync as statSync54 } from "fs";
128355
+ import { join as join173, resolve as resolve47, sep as sep31 } from "path";
128064
128356
 
128065
128357
  // node_modules/hono/dist/request/constants.js
128066
128358
  var GET_MATCH_RESULT = Symbol();
@@ -134545,6 +134837,12 @@ function runDetail(db, sourceId, runId) {
134545
134837
  const done = f.run.completed?.data;
134546
134838
  const sealed = evs.find((e) => e.type === "receipt.sealed")?.data;
134547
134839
  const stop = stopReason(evs, r.verdict);
134840
+ const sealAcc = evs.findLast((e) => e.type === "stage.completed" && e.stage === "seal")?.data;
134841
+ const proofEv = evs.findLast((e) => e.type === "proof.rerun")?.data;
134842
+ const intakeAcc = evs.find((e) => e.type === "stage.completed" && e.stage === "intake")?.data;
134843
+ const accRows = Array.isArray(sealAcc?.issue_acceptance) ? sealAcc.issue_acceptance : Array.isArray(proofEv?.statuses) ? proofEv.statuses : Array.isArray(intakeAcc?.issue_acceptance) ? intakeAcc.issue_acceptance.map((l) => ({ line: String(l), status: "waiting" })) : [];
134844
+ const acceptance = accRows.map((x) => ({ line: String(x.line ?? ""), status: x.status === "met" ? "met" : x.status === "unmet" ? "unmet" : "waiting", checks: typeof x.checks === "number" ? x.checks : 0, reason: typeof x.reason === "string" ? x.reason : null }));
134845
+ const proof = proofEv ? { round: Number(proofEv.round ?? 1), exit: typeof proofEv.exit === "number" ? proofEv.exit : null, proved: Number(proofEv.proved ?? 0), failed: Number(proofEv.failed ?? 0), seconds: Number(proofEv.seconds ?? 0) } : null;
134548
134846
  return {
134549
134847
  ...withLive(db, r),
134550
134848
  blocked_question: blockedQuestion(evs, r.verdict),
@@ -134553,7 +134851,10 @@ function runDetail(db, sourceId, runId) {
134553
134851
  stages,
134554
134852
  stages_completed: f.completed,
134555
134853
  receipt: sealed ? { sha256: str(sealed.receipt_sha256), signed: sealed.signed === true, verdict: str(sealed.verdict), path: str(sealed.path) } : null,
134556
- not_proven: Array.isArray(done?.not_proven) ? done.not_proven : []
134854
+ not_proven: Array.isArray(done?.not_proven) ? done.not_proven : [],
134855
+ acceptance,
134856
+ acceptance_source: (sealAcc?.issue_acceptance_source ?? proofEv?.source) === "plan" ? "plan" : "issue",
134857
+ proof
134557
134858
  };
134558
134859
  }
134559
134860
 
@@ -138597,8 +138898,202 @@ function mount21(ctx) {
138597
138898
  });
138598
138899
  }
138599
138900
 
138901
+ // src/server/routes/workspace.ts
138902
+ import { existsSync as existsSync122, mkdirSync as mkdirSync92, readFileSync as readFileSync157, readdirSync as readdirSync58, renameSync as renameSync30, statSync as statSync53, writeFileSync as writeFileSync92 } from "fs";
138903
+ import { homedir as homedir17, userInfo } from "os";
138904
+ import { dirname as dirname74, join as join171, resolve as resolve46, sep as sep30 } from "path";
138905
+ var ID7 = /^[a-z0-9][a-z0-9-]{0,39}$/;
138906
+ var MAX_BYTES3 = 200000;
138907
+ var workspaceFile = (env2 = process.env) => env2["LOKI_WORKSPACE_FILE"] || join171(homedir17(), ".loki", "control", "workspace.json");
138908
+ var accountName = () => {
138909
+ try {
138910
+ return userInfo().username || "me";
138911
+ } catch {
138912
+ return "me";
138913
+ }
138914
+ };
138915
+ var text4 = (v10, max) => typeof v10 === "string" && v10.trim() !== "" && v10.length <= max ? v10.trim() : null;
138916
+ function parseWorkspace(raw2) {
138917
+ const o = raw2;
138918
+ const name = text4(o?.account?.name, 80);
138919
+ if (!name)
138920
+ return { ok: false, error: "account.name must be 1 to 80 characters" };
138921
+ if (!Array.isArray(o?.orgs) || o.orgs.length === 0 || o.orgs.length > 50)
138922
+ return { ok: false, error: "orgs must hold 1 to 50 entries" };
138923
+ const orgs = [], orgIds = new Set;
138924
+ for (const x10 of o.orgs) {
138925
+ const id2 = text4(x10?.id, 40), nm2 = text4(x10?.name, 80);
138926
+ if (!id2 || !ID7.test(id2) || orgIds.has(id2) || !nm2)
138927
+ return { ok: false, error: "each org needs a unique lowercase id and a name" };
138928
+ orgIds.add(id2);
138929
+ if (!Array.isArray(x10.projects) || x10.projects.length > 200)
138930
+ return { ok: false, error: `org ${id2}: projects must be a list of at most 200` };
138931
+ const projects = [], pIds = new Set;
138932
+ for (const p of x10.projects) {
138933
+ const pid = text4(p?.id, 40), pn2 = text4(p?.name, 80);
138934
+ if (!pid || !ID7.test(pid) || pIds.has(pid) || !pn2)
138935
+ return { ok: false, error: `org ${id2}: each project needs a unique lowercase id and a name` };
138936
+ pIds.add(pid);
138937
+ const repos = Array.isArray(p.repos) ? [...new Set(p.repos.filter((r) => typeof r === "string" && r.length > 0 && r.length <= 200))].slice(0, 500) : [];
138938
+ projects.push({ id: pid, name: pn2, repos });
138939
+ }
138940
+ orgs.push({ id: id2, name: nm2, projects });
138941
+ }
138942
+ return { ok: true, ws: { account: { name }, orgs } };
138943
+ }
138944
+ function loadWorkspace(known, file = workspaceFile()) {
138945
+ try {
138946
+ if (existsSync122(file)) {
138947
+ const p = parseWorkspace(JSON.parse(readFileSync157(file, "utf8")));
138948
+ if (p.ok)
138949
+ return p.ws;
138950
+ }
138951
+ } catch {}
138952
+ return { account: { name: accountName() }, orgs: [{ id: "personal", name: "Personal", projects: [{ id: "default", name: "My project", repos: [...known] }] }] };
138953
+ }
138954
+ function saveWorkspace(ws2, file = workspaceFile()) {
138955
+ mkdirSync92(dirname74(file), { recursive: true, mode: 448 });
138956
+ const tmp = `${file}.${process.pid}.tmp`;
138957
+ writeFileSync92(tmp, JSON.stringify(ws2, null, 2) + `
138958
+ `, { mode: 384 });
138959
+ renameSync30(tmp, file);
138960
+ }
138961
+ function reposWithRuns(db2) {
138962
+ const names = db2.selectDistinct({ r: runs.originRepo }).from(runs).all().map((x10) => x10.r ? x10.r.split("/").pop() ?? "" : "").filter(Boolean);
138963
+ return [...new Set(names)].sort();
138964
+ }
138965
+ var knownRepos = (db2) => [...new Set([...repoNames(db2), ...reposWithRuns(db2)])].sort();
138966
+ var unassigned = (ws2, withRuns) => {
138967
+ const held = new Set(ws2.orgs.flatMap((o) => o.projects.flatMap((p) => p.repos)));
138968
+ return withRuns.filter((r) => !held.has(r));
138969
+ };
138970
+ function repoDirsOf(db2, name) {
138971
+ const rows = db2.select({ name: localRepos.name, realpath: localRepos.realpath }).from(localRepos).all().filter((r) => r.name === name);
138972
+ return [...new Set(rows.map((r) => r.realpath))].filter((d) => {
138973
+ try {
138974
+ return statSync53(d).isDirectory();
138975
+ } catch {
138976
+ return false;
138977
+ }
138978
+ });
138979
+ }
138980
+ var repoDirOf = (db2, name) => repoDirsOf(db2, name)[0] ?? null;
138981
+ var INSTRUCTION_FILES = ["CLAUDE.md", "CLAUDE.local.md", ".claude/CLAUDE.md", "AGENTS.md"];
138982
+ var NOTE_DIRS = [".loki/memory", ".loki/learnings", ".claude/rules"];
138983
+ var readCapped3 = (p) => {
138984
+ try {
138985
+ const st2 = statSync53(p);
138986
+ if (!st2.isFile())
138987
+ return null;
138988
+ const b = readFileSync157(p);
138989
+ return { text: b.subarray(0, MAX_BYTES3).toString("utf8"), bytes: st2.size, truncated: st2.size > MAX_BYTES3 };
138990
+ } catch {
138991
+ return null;
138992
+ }
138993
+ };
138994
+ function repoKnowledge(dir) {
138995
+ const instructions = INSTRUCTION_FILES.flatMap((f) => {
138996
+ const r = readCapped3(join171(dir, f));
138997
+ return r ? [{ path: f, ...r }] : [];
138998
+ });
138999
+ const notes = [];
139000
+ for (const d of NOTE_DIRS) {
139001
+ let names = [];
139002
+ try {
139003
+ names = readdirSync58(join171(dir, d)).filter((n10) => /\.(md|json|jsonl|txt)$/i.test(n10)).sort().slice(0, 40);
139004
+ } catch {
139005
+ continue;
139006
+ }
139007
+ for (const n10 of names) {
139008
+ const r = readCapped3(join171(dir, d, n10));
139009
+ if (r)
139010
+ notes.push({ path: `${d}/${n10}`, bytes: r.bytes, preview: r.text.slice(0, 600) });
139011
+ }
139012
+ }
139013
+ return { instructions, notes };
139014
+ }
139015
+ function writeInstructions(dir, content) {
139016
+ const root = resolve46(dir), target = join171(root, "CLAUDE.md");
139017
+ if (!target.startsWith(root + sep30))
139018
+ throw new Error("path outside the repository");
139019
+ const tmp = `${target}.${process.pid}.tmp`;
139020
+ writeFileSync92(tmp, content);
139021
+ renameSync30(tmp, target);
139022
+ }
139023
+ function mount22(ctx) {
139024
+ const { app, act, db: db2, local } = ctx, deny = { error: "loopback only without a token" };
139025
+ const body = async (c) => {
139026
+ if (!local(c))
139027
+ return { ok: false, res: c.json({ error: "loopback JSON requests only" }, 403) };
139028
+ if (!originOk(c.req.header("origin")))
139029
+ return { ok: false, res: c.json({ error: "origin not allowed" }, 403) };
139030
+ const t = await c.req.text();
139031
+ if (t.length > MAX_BYTES3 + 2000)
139032
+ return { ok: false, res: c.json({ error: "body too large" }, 413) };
139033
+ try {
139034
+ return { ok: true, json: JSON.parse(t) };
139035
+ } catch {
139036
+ return { ok: false, res: c.json({ error: "invalid JSON" }, 400) };
139037
+ }
139038
+ };
139039
+ app.get("/v1/workspace", (c) => {
139040
+ if (!probeAllowed(ctx, c))
139041
+ return c.json(deny, 403);
139042
+ const active = reposWithRuns(db2), ws2 = loadWorkspace(active);
139043
+ return c.json({ ...ws2, repos: knownRepos(db2), unassigned: unassigned(ws2, active) });
139044
+ });
139045
+ act.put("/v1/workspace", async (c) => {
139046
+ const b = await body(c);
139047
+ if (!b.ok)
139048
+ return b.res;
139049
+ const p = parseWorkspace(b.json);
139050
+ if (!p.ok) {
139051
+ audit3(db2, { kind: "workspace.save", result: "refused", detail: p.error });
139052
+ return c.json({ error: p.error }, 400);
139053
+ }
139054
+ try {
139055
+ saveWorkspace(p.ws);
139056
+ } catch (e10) {
139057
+ return c.json({ error: `could not save: ${e10.message}` }, 500);
139058
+ }
139059
+ audit3(db2, { kind: "workspace.save", result: "saved", detail: `${p.ws.orgs.length} org(s), ${p.ws.orgs.reduce((a, o) => a + o.projects.length, 0)} project(s)` });
139060
+ return c.json({ ...p.ws, repos: knownRepos(db2), unassigned: unassigned(p.ws, reposWithRuns(db2)) });
139061
+ });
139062
+ app.get("/v1/repo/knowledge", (c) => {
139063
+ if (!probeAllowed(ctx, c))
139064
+ return c.json(deny, 403);
139065
+ const name = c.req.query("repo") ?? "", dir = name ? repoDirOf(db2, name) : null;
139066
+ if (!dir)
139067
+ return c.json({ error: "not a repository Loki has seen on this machine" }, 404);
139068
+ return c.json({ repo: name, ...repoKnowledge(dir) });
139069
+ });
139070
+ act.put("/v1/repo/instructions", async (c) => {
139071
+ const b = await body(c);
139072
+ if (!b.ok)
139073
+ return b.res;
139074
+ const name = text4(b.json?.repo, 200), content = b.json?.content;
139075
+ if (!name || typeof content !== "string" || content.length > MAX_BYTES3)
139076
+ return c.json({ error: `repo and content (at most ${MAX_BYTES3} characters) are required` }, 400);
139077
+ const dirs = repoDirsOf(db2, name), dir = dirs[0];
139078
+ if (!dir)
139079
+ return c.json({ error: "not a repository Loki has seen on this machine" }, 404);
139080
+ if (dirs.length > 1) {
139081
+ audit3(db2, { kind: "repo.instructions", target: name, result: "refused", detail: `${dirs.length} checkouts share this name` });
139082
+ return c.json({ error: `${dirs.length} checkouts on this machine are named ${name}; edit CLAUDE.md in the one you mean` }, 409);
139083
+ }
139084
+ try {
139085
+ writeInstructions(dir, content);
139086
+ } catch (e10) {
139087
+ audit3(db2, { kind: "repo.instructions", target: name, result: "error", detail: e10.message });
139088
+ return c.json({ error: `could not write CLAUDE.md: ${e10.message}` }, 500);
139089
+ }
139090
+ audit3(db2, { kind: "repo.instructions", target: name, result: "saved", detail: `${content.length} characters` });
139091
+ return c.json({ repo: name, ...repoKnowledge(dir) });
139092
+ });
139093
+ }
139094
+
138600
139095
  // src/server/routes/index.ts
138601
- var routeModules = [mount2, mount4, mount3, mount8, mount10, mount, mount11, mount6, mount12, mount13, mount15, mount7, mount14, mount16, mount9, mount20, mount21, mount17, mount19, mount5, mount18];
139096
+ var routeModules = [mount2, mount4, mount3, mount8, mount10, mount, mount11, mount6, mount12, mount13, mount15, mount7, mount14, mount16, mount9, mount20, mount21, mount17, mount19, mount5, mount18, mount22];
138602
139097
  function registerRoutes(ctx) {
138603
139098
  mountRepos(ctx.act, ctx.db, ctx.peerIsLoopback, ctx.repoDir, ctx.ghImpl);
138604
139099
  for (const m of routeModules)
@@ -138625,8 +139120,8 @@ function ttlCache(ttlMs = PROBE_CACHE_MS, now2 = Date.now) {
138625
139120
  }
138626
139121
 
138627
139122
  // src/server/legacy/shim.ts
138628
- import { existsSync as existsSync122, readFileSync as readFileSync157 } from "fs";
138629
- import { join as join171 } from "path";
139123
+ import { existsSync as existsSync123, readFileSync as readFileSync158 } from "fs";
139124
+ import { join as join172 } from "path";
138630
139125
 
138631
139126
  // src/server/legacy/routes.ts
138632
139127
  var LEGACY_ROUTES = [
@@ -139004,10 +139499,10 @@ var logged = new Set;
139004
139499
  var toHono = (p) => p.replace(/\{([A-Za-z_]+):path\}/g, ":$1{.+}").replace(/\{([A-Za-z_]+)\}/g, ":$1");
139005
139500
  var NOT_SUPPORTED = "not yet supported by the Control Plane";
139006
139501
  var repoVersion = () => {
139007
- for (const f of [join171(import.meta.dir, "../../../../../VERSION")]) {
139502
+ for (const f of [join172(import.meta.dir, "../../../../../VERSION")]) {
139008
139503
  try {
139009
- if (existsSync122(f))
139010
- return readFileSync157(f, "utf8").trim();
139504
+ if (existsSync123(f))
139505
+ return readFileSync158(f, "utf8").trim();
139011
139506
  } catch {}
139012
139507
  }
139013
139508
  return "unknown";
@@ -139189,7 +139684,7 @@ function legacyShim(opts) {
139189
139684
 
139190
139685
  // src/server/app.ts
139191
139686
  var MAX_BODY2 = 1e6;
139192
- var defaultUiDir = () => [join172(import.meta.dir, "../../ui/dist"), join172(import.meta.dir, "../ui/dist")].find((d) => existsSync123(join172(d, "index.html")));
139687
+ var defaultUiDir = () => [join173(import.meta.dir, "../../ui/dist"), join173(import.meta.dir, "../ui/dist")].find((d) => existsSync124(join173(d, "index.html")));
139193
139688
  function createApp(opts) {
139194
139689
  const uiDir = opts.uiDir ?? defaultUiDir();
139195
139690
  const { db: db2, sqlite } = openDb(opts.dbPath);
@@ -139218,10 +139713,10 @@ function createApp(opts) {
139218
139713
  await next();
139219
139714
  });
139220
139715
  const readInstalled = () => {
139221
- for (const f of [process.env.LOKI_VERSION_FILE, join172(import.meta.dir, "../../../../VERSION")]) {
139716
+ for (const f of [process.env.LOKI_VERSION_FILE, join173(import.meta.dir, "../../../../VERSION")]) {
139222
139717
  try {
139223
139718
  if (f)
139224
- return readFileSync158(f, "utf8").trim() || "unknown";
139719
+ return readFileSync159(f, "utf8").trim() || "unknown";
139225
139720
  } catch {}
139226
139721
  }
139227
139722
  return "unknown";
@@ -139237,12 +139732,12 @@ function createApp(opts) {
139237
139732
  return ready ? c.json({ ready: true }) : c.json({ ready: false }, 503);
139238
139733
  });
139239
139734
  app.post("/v1/ingest", async (c) => {
139240
- const text4 = await c.req.text();
139241
- if (text4.length > MAX_BODY2)
139735
+ const text5 = await c.req.text();
139736
+ if (text5.length > MAX_BODY2)
139242
139737
  return c.json({ error: "body over 1 MB" }, 413);
139243
139738
  let body;
139244
139739
  try {
139245
- body = JSON.parse(text4);
139740
+ body = JSON.parse(text5);
139246
139741
  } catch {
139247
139742
  return c.json({ error: "invalid JSON" }, 400);
139248
139743
  }
@@ -139262,12 +139757,12 @@ function createApp(opts) {
139262
139757
  const source = c.req.param("source"), run2 = c.req.param("run");
139263
139758
  if (!(c.req.header("content-type") ?? "").toLowerCase().startsWith("application/json"))
139264
139759
  return c.json({ error: "content-type must be application/json" }, 400);
139265
- const text4 = await c.req.text();
139266
- if (text4.length > 20000)
139760
+ const text5 = await c.req.text();
139761
+ if (text5.length > 20000)
139267
139762
  return c.json({ error: "body too large" }, 413);
139268
139763
  let body;
139269
139764
  try {
139270
- body = JSON.parse(text4);
139765
+ body = JSON.parse(text5);
139271
139766
  } catch {
139272
139767
  return c.json({ error: "invalid JSON" }, 400);
139273
139768
  }
@@ -139330,13 +139825,13 @@ function createApp(opts) {
139330
139825
  }
139331
139826
  if (!uiDir || p.startsWith("/v1/"))
139332
139827
  return c.json({ error: "not found" }, 404);
139333
- const root = resolve46(uiDir);
139334
- const f = resolve46(root, `.${p}`);
139335
- if (f.startsWith(root + sep30) && existsSync123(f) && statSync53(f).isFile())
139828
+ const root = resolve47(uiDir);
139829
+ const f = resolve47(root, `.${p}`);
139830
+ if (f.startsWith(root + sep31) && existsSync124(f) && statSync54(f).isFile())
139336
139831
  return new Response(Bun.file(f));
139337
139832
  if (/\.[a-z0-9]+$/i.test(p))
139338
139833
  return c.json({ error: "not found" }, 404);
139339
- return new Response(Bun.file(join172(root, "index.html")));
139834
+ return new Response(Bun.file(join173(root, "index.html")));
139340
139835
  });
139341
139836
  return { app, db: db2, close: () => {
139342
139837
  clearInterval(reconciler);