fwdloop 0.24.0 → 0.25.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 (49) hide show
  1. package/bin/fwdloop +33 -26
  2. package/package.json +1 -1
  3. package/src/cited-record.js +3 -22
  4. package/src/cited-source.js +5 -6
  5. package/src/diary.js +21 -17
  6. package/src/flowmodel.js +6 -37
  7. package/src/keysfile.js +1 -1
  8. package/src/launcher.js +552 -0
  9. package/src/learnstore.js +6 -4
  10. package/src/line-checks.js +55 -0
  11. package/src/opener.js +33 -0
  12. package/src/panel/author.js +2 -0
  13. package/src/panel/authorflows.js +9 -9
  14. package/src/panel/authorresume.js +4 -3
  15. package/src/panel/data.js +3 -2
  16. package/src/panel/index.html +22 -8
  17. package/src/panel/result.js +7 -12
  18. package/src/panel/server.js +53 -5
  19. package/src/panel/settings.js +4 -18
  20. package/src/panel/spawn.js +0 -9
  21. package/src/prompts.js +33 -0
  22. package/src/runfile.js +60 -0
  23. package/src/runner.js +18 -17
  24. package/src/sheet-record.js +15 -35
  25. package/src/sheetblock.js +3 -3
  26. package/src/sheetrun.js +6 -6
  27. package/src/summary-words.js +13 -5
  28. package/src/tty-colour.js +29 -0
  29. package/types/cited-record.d.ts +0 -2
  30. package/types/diary.d.ts +2 -5
  31. package/types/flowmodel.d.ts +2 -21
  32. package/types/keysfile.d.ts +7 -0
  33. package/types/launcher.d.ts +307 -0
  34. package/types/learnstore.d.ts +1 -1
  35. package/types/line-checks.d.ts +26 -0
  36. package/types/opener.d.ts +12 -0
  37. package/types/panel/author.d.ts +2 -0
  38. package/types/panel/result.d.ts +1 -3
  39. package/types/panel/server.d.ts +24 -3
  40. package/types/panel/settings.d.ts +2 -2
  41. package/types/panel/spawn.d.ts +0 -6
  42. package/types/prompts.d.ts +14 -0
  43. package/types/runfile.d.ts +48 -0
  44. package/types/runner.d.ts +3 -3
  45. package/types/sheet-record.d.ts +0 -2
  46. package/types/sheetblock.d.ts +2 -2
  47. package/types/sheetrun.d.ts +1 -1
  48. package/types/summary-words.d.ts +2 -1
  49. package/types/tty-colour.d.ts +33 -0
package/src/opener.js ADDED
@@ -0,0 +1,33 @@
1
+ // borrowed-from: bareloop src/opener.js@d21ae80 (v0.47.1, 704d598)
2
+ // Adaptation: none. Moved here from fwdloop's Settings route (src/panel/settings.js, borrowed-from bareloop src/panel/settingsroutes.js@07c298f) so Settings
3
+ // and the launcher share it.
4
+ // The ONE "open this in the OS" helper: `xdg-open` (linux) / `open` (macOS), argv array, no shell, detached.
5
+ // Settings' "Open keys folder" and the `fwdloop start` launcher both use it. Another OS or a failed spawn
6
+ // resolves `false` (the caller then shows the path/URL as text); it never throws.
7
+ import { spawn as realSpawn } from 'node:child_process';
8
+
9
+ /**
10
+ * @param {string} target a folder path or a URL
11
+ * @param {{ platform?: string, spawnFn?: ((cmd: string, args: string[], o: object) => any)|null, underTest?: boolean }} [opts]
12
+ * `spawnFn: null` = no opener at all (resolves false); undefined = the real spawn, unless `underTest`, which spawns nothing
13
+ * unless a test injected one
14
+ * @returns {Promise<boolean>} true once the opener process has started
15
+ */
16
+ export function openInOs(target, opts = {}) {
17
+ const platform = opts.platform ?? process.platform;
18
+ const cmd = platform === 'linux' ? 'xdg-open' : (platform === 'darwin' ? 'open' : null);
19
+ const opener = opts.spawnFn === undefined ? (opts.underTest ? null : realSpawn) : opts.spawnFn;
20
+ if (!cmd || !opener) return Promise.resolve(false);
21
+ return new Promise((resolve) => {
22
+ let child;
23
+ try { child = opener(cmd, [target], { detached: true, stdio: 'ignore' }); } catch { resolve(false); return; }
24
+ let settled = false;
25
+ child.once('error', () => { if (!settled) { settled = true; resolve(false); } });
26
+ child.once('spawn', () => {
27
+ if (settled) return;
28
+ settled = true;
29
+ if (typeof child.unref === 'function') child.unref();
30
+ resolve(true);
31
+ });
32
+ });
33
+ }
@@ -407,6 +407,8 @@ export function createAuthor(opts) {
407
407
  if (r.status !== 200 || !r.body.flow) return r;
408
408
  return { ...r, body: { ...r.body, flow: { ...r.body.flow, trigger: triggerDoor.card(r.body.flow.flow) } } };
409
409
  },
410
+ /** M4b am4 item 7: how many drafts are open for `whoami` and the launcher's stop warning: the card `live()` returns (the newest draft not abandoned or signed), 0 or 1. */
411
+ openDrafts() { return this.live().body.draft ? 1 : 0; },
410
412
  run: flowsDoor.run,
411
413
  reuseCheck: (b) => flowsDoor.reuseCheck(b),
412
414
  runPrepare: flowsDoor.runPrepare,
@@ -5,7 +5,7 @@
5
5
  // flows() only flows whose `readFlow` passes (a missing, unsigned or tampered flow is never listed), that `canFlowRun` accepts
6
6
  // (the one function shared with the run's own preflight: an unwired verb is not listed; amendment 22) and that have at least one
7
7
  // passed run (amendment 7 item 7; Run again reaches the rest), each with its signed
8
- // cap, its declared source roles, the source paths the NEWEST run of that flow used (its `inputs.json`
8
+ // cap, its declared source roles, the source paths the NEWEST run of that flow used (its `run.json` inputs
9
9
  // manifest `source` field; blank when none) and what is left this month (a courtesy: the CLI's own monthly
10
10
  // check is what refuses).
11
11
  // run(body) { flow, inputs: [{role, path}], runId } -> the SAME $0 input checks as the card (`checkInputRows`), the role set
@@ -19,7 +19,7 @@ import { canFlowRun, willNotRunSay } from '../canrun.js';
19
19
  import { loadCatalogue } from '../catalogue.js';
20
20
  import { ConfigError, readConfig } from '../config.js';
21
21
  import {
22
- changeSentence, checkFlowName, listFlowNames, listRunIds, nextRunId, planForReuse, readFileInside, readFlow, resolveRunDir, suggestFlowName,
22
+ changeSentence, checkFlowName, listFlowNames, listRunIds, nextRunId, planForReuse, readFlow, resolveRunDir, suggestFlowName,
23
23
  } from '../flow.js';
24
24
  import { jobKeyOfCard, jobKeyOfSigned } from '../jobkey.js';
25
25
  import { spendSummary } from '../monthly.js';
@@ -36,6 +36,7 @@ import { SCHEDULE_BUSY_SAY } from '../summary-words.js';
36
36
  import { providerKeys } from './spawn.js';
37
37
  import { pageAddressesOf, pageAddressRefusal } from '../pagefetch.js';
38
38
  import { readModelRecord, writeModelRecord } from '../flowmodel.js';
39
+ import { readRunInputs, RUN_FILE } from '../runfile.js';
39
40
 
40
41
  /** M6 amendment 1: the sentence the page shows and the sign route refuses with, for a job with a run running or waiting at its ask. @param {string} runId */
41
42
  export const editBlockedSay = (runId) => `finish or stop ${runId} first`;
@@ -90,28 +91,27 @@ export function createFlowsDoor(opts) {
90
91
  };
91
92
  }
92
93
 
93
- /** The source paths one run froze: role -> path, from that run's `inputs.json`. Blank = none. @param {string} runDir @param {string[]} roles @param {Record<string, string>} [pages] M10 am3: page role -> signed address */
94
+ /** The source paths one run froze: role -> path, from that run's `run.json` inputs. Blank = none. @param {string} runDir @param {string[]} roles @param {Record<string, string>} [pages] M10 am3: page role -> signed address */
94
95
  function sourcesOf(runDir, roles, pages = {}) {
95
96
  /** @type {Record<string, string>} */
96
97
  const out = Object.fromEntries(roles.map((r) => [r, pages[r] ?? ''])); // M10 am3: a page input shows its signed address, whatever a run froze
97
98
  if (runDir === '') return out;
98
- const f = readFileInside(runDir, 'inputs.json');
99
- let rows = [];
100
- try { rows = f.ok ? JSON.parse(f.text) : []; } catch { rows = []; }
101
- for (const row of Array.isArray(rows) ? rows : []) {
99
+ const f = readRunInputs(runDir);
100
+ for (const row of f.ok ? f.entries : []) {
102
101
  if (row && typeof row.id === 'string' && roles.includes(row.id) && !Object.hasOwn(pages, row.id) && typeof row.source === 'string') out[row.id] = row.source;
103
102
  }
104
103
  return out;
105
104
  }
106
105
 
107
- /** The source paths the newest run of this flow used: role -> path, from that run's `inputs.json`. Blank = none. @param {string} flowDir @param {string[]} roles @param {Record<string, string>} [pages] */
106
+ /** The source paths the newest run of this flow used: role -> path, from that run's `run.json` inputs. Blank = none. @param {string} flowDir @param {string[]} roles @param {Record<string, string>} [pages] */
108
107
  function lastSources(flowDir, roles, pages = {}) {
109
108
  let newest = null;
110
109
  for (const id of listRunIds(flowDir)) {
111
110
  const r = resolveRunDir(flowDir, id);
112
111
  if (!r.ok) continue;
113
112
  let t;
114
- try { t = lstatSync(join(r.runDir, 'inputs.json')).mtimeMs; } catch { continue; }
113
+ if (!readRunInputs(r.runDir).ok) continue; // a run that froze no inputs (a refusal at start) is not "the newest run that ran"
114
+ try { t = lstatSync(join(r.runDir, RUN_FILE)).mtimeMs; } catch { continue; }
115
115
  if (newest === null || t > newest.t || (t === newest.t && id > newest.id)) newest = { t, id, runDir: r.runDir };
116
116
  }
117
117
  if (newest === null) return { runId: null, sources: sourcesOf('', roles, pages) };
@@ -16,7 +16,7 @@ import { userInfo } from 'node:os';
16
16
 
17
17
  import { scrub } from '../authoring.js';
18
18
  import { loadCatalogue } from '../catalogue.js';
19
- import { changeSentence, checkFlowName, readFileInside, readPlan, readRunPlan, resolveRunDir } from '../flow.js';
19
+ import { changeSentence, checkFlowName, readPlan, readRunPlan, resolveRunDir } from '../flow.js';
20
20
  import { readResumeLock } from '../liveness.js';
21
21
  import { auditSpend } from '../runner.js';
22
22
  import {
@@ -28,6 +28,7 @@ import { checkValues } from './authorvalues.js';
28
28
  import { getRunControls } from './data.js';
29
29
  import { providerKeys } from './spawn.js';
30
30
  import { readModelRecord } from '../flowmodel.js';
31
+ import { readRunInputs } from '../runfile.js';
31
32
 
32
33
  const KEYS = ['flow', 'runId', 'capUsd', 'hash'];
33
34
 
@@ -102,9 +103,9 @@ export function createResumeDoor(opts) {
102
103
  form(flow, runId) {
103
104
  const s = inspect({ flow: flow ?? '', runId: runId ?? '' }, true);
104
105
  if (!s.ok) return s.reply;
105
- const inputsRead = readFileInside(s.runDir, 'inputs.json');
106
+ const inputsRead = readRunInputs(s.runDir);
106
107
  let inputs = [];
107
- try { inputs = inputsRead.ok ? JSON.parse(inputsRead.text).map((m) => ({ role: String(m.id), path: String(m.source) })) : []; } catch { inputs = []; }
108
+ try { inputs = inputsRead.ok ? inputsRead.entries.map((m) => ({ role: String(m.id), path: String(m.source) })) : []; } catch { inputs = []; }
108
109
  const floor = capFloorOf(s.hasRound, home, readModelRecord(dirname(dirname(s.runDir))));
109
110
  const floorUsd = floor.usd;
110
111
  return {
package/src/panel/data.js CHANGED
@@ -48,7 +48,8 @@ import {
48
48
  import { MAX_STRUCTURE_RETRIES } from '../drafter.js';
49
49
  import { isResultRun, checkTypeOf, buildResult, downloadOf, readCitedChecks } from './result.js';
50
50
  import { thinkingRuleWords, thinkingTryWords } from '../thinking.js';
51
- import { readRunThinking, readLearningsRecord } from '../flowmodel.js';
51
+ import { readLearningsRecord } from '../flowmodel.js';
52
+ import { readRunThinking } from '../runfile.js';
52
53
  import {
53
54
  isTryRow, loadDiaries, deriveFold, cardLine, summaryLines,
54
55
  } from '../audit-fold.js';
@@ -2135,7 +2136,7 @@ export function getRunJob({
2135
2136
  trigger: f && f.trigger ? f.trigger : null, from: f?.from ?? null, model: f?.model ?? null, destination: f?.destination ?? null, inputs: f?.inputs ?? null, home,
2136
2137
  });
2137
2138
  })(),
2138
- // M4d am28: the run's rule from its own thinking.json; a run with none (before am25) reads `—` (thinkingRuleWords(null)); the row always shows
2139
+ // M4d am28: the run's rule from its own run.json; a run with none (before am25) reads `—` (thinkingRuleWords(null)); the row always shows
2139
2140
  thinkingRule: thinkingRuleWords(readRunThinking(run.runDir)),
2140
2141
  jobFrom: copy.present ? 'run' : 'current',
2141
2142
  jobFromWhy: copy.present ? null : NO_JOB_COPY_WORDS,
@@ -321,6 +321,10 @@
321
321
  .ended-row:last-child{margin-bottom:0;}
322
322
  .ended-label{color:var(--text-faint);font-size:11px;letter-spacing:0.08em;min-width:84px;}
323
323
  .ended-text{flex:1 1 220px;min-width:0;overflow-wrap:anywhere;}
324
+ /* M9 am24: a NEXT with several instructions is one per line, label muted, instructions in a second column (shape: bareloop 8cad363, with labels in the muted colour) */
325
+ .next-rows{display:grid;grid-template-columns:max-content minmax(0,1fr);column-gap:10px;row-gap:2px;}
326
+ .next-label{color:var(--text-faint);}
327
+ .next-text{min-width:0;overflow-wrap:anywhere;}
324
328
  .audit-sched-start{padding:6px 10px;margin-bottom:8px;border:1px solid var(--border-strong);background:var(--panel2);font-size:12px;overflow-wrap:anywhere;}
325
329
  .when-sub{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px;}
326
330
  .when-sub > *{flex:1 1 120px;min-width:0;}
@@ -437,10 +441,12 @@
437
441
  .audit-group.audit-fold h4.audit-status-header::before{content:"\25B6 ";color:var(--text-faint);}
438
442
  .audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC ";}
439
443
  .audit-group.audit-fold h4.audit-status-header::after{content:none;}
440
- /* M8 item 6: bareloop's learnings box, copied (borrowed-from: bareloop src/panel/index.html@v0.46.0 :421-424): a framed row, the header a full-width button with the chip and words inline, no arrow */
444
+ /* M8 item 6: bareloop's learnings box, copied (borrowed-from: bareloop src/panel/index.html@v0.47.1 417e80c, the learnings arrow only): a framed row, the header a full-width button with the arrow, chip and words inline; the arrow is the same ▶ / ▼ the other Audit folds draw (h4.audit-status-header::before), faint, a smaller gap on a phone */
441
445
  .audit-part{border:1px solid var(--border);margin-bottom:6px;background:var(--panel2);}
442
446
  .audit-part-toggle{width:100%;text-align:left;display:block;white-space:normal;min-height:44px;padding:8px 10px;}
443
447
  .audit-part-toggle::before,.audit-part-toggle::after{content:"";}
448
+ .audit-part-toggle.audit-learn-fold::before{content:"\25B6 ";color:var(--text-faint);}
449
+ .audit-part-toggle.audit-learn-fold[aria-expanded="true"]::before{content:"\25BC ";}
444
450
  .audit-part-body{padding:8px 10px 10px;border-top:1px dotted var(--border-strong);}
445
451
  @media (max-width: 640px){
446
452
  /* (l) a phone: the name is the only thing that shrinks — drop the dots and the word "try", tighten the gaps */
@@ -449,6 +455,8 @@
449
455
  .audit-group.audit-fold h4.audit-status-header > .badge{padding-left:0;padding-right:0;font-size:10px;}
450
456
  .audit-group.audit-fold h4.audit-status-header::before{content:"\25B6";}
451
457
  .audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC";}
458
+ .audit-part-toggle.audit-learn-fold::before{content:"\25B6 ";}
459
+ .audit-part-toggle.audit-learn-fold[aria-expanded="true"]::before{content:"\25BC ";}
452
460
  .audit-fold-sep{display:none;}
453
461
  .audit-fold-try{margin-left:.4em;} /* the cost and the try count never touch: "$0.0010" + "1" must not read $0.00101 */
454
462
  /* the tail wraps inside the header (never spills or is cut): it may break at its spaces and shrink */
@@ -1039,6 +1047,9 @@
1039
1047
  <div class="rw-picked" id="rw-picked" data-testid="rw-picked" hidden><span id="rw-picked-txt" data-testid="rw-picked-txt"></span><a id="rw-change" data-testid="rw-change" role="button" tabindex="0">change</a></div>
1040
1048
  <div class="hint" id="jf-run-empty" data-testid="jf-run-empty"></div>
1041
1049
  <div class="jf-err" id="jf-err-flow" data-testid="jf-err-flow"></div>
1050
+ <div class="hint" id="jf-run-model" data-testid="jf-run-model"></div>
1051
+ <select id="jf-run-pick" data-testid="jf-run-pick" aria-label="Model to run this job with" hidden disabled><option value="">Reading your models…</option></select>
1052
+ <div class="jf-err" id="jf-err-run-model" data-testid="jf-err-run-model"></div>
1042
1053
  </div>
1043
1054
  <div class="field" data-testid="jf-run-job-field">
1044
1055
  <label for="jf-run-jobbox">The job</label>
@@ -1049,9 +1060,6 @@
1049
1060
  <div class="ro-lines" id="jf-run-job" data-testid="jf-run-job"></div>
1050
1061
  <div class="jf-err" id="jf-err-run-job" data-testid="jf-err-run-job"></div>
1051
1062
  <div class="hint" id="jf-run-job-hint" data-testid="jf-run-job-hint">Change anything here. A changed job line, guardrail, ask or step drafts a new workflow; a changed destination, cap, wait or model signs a new run; new files just run.</div>
1052
- <div class="hint" id="jf-run-model" data-testid="jf-run-model"></div>
1053
- <select id="jf-run-pick" data-testid="jf-run-pick" aria-label="Model to run this job with" hidden disabled><option value="">Reading your models…</option></select>
1054
- <div class="jf-err" id="jf-err-run-model" data-testid="jf-err-run-model"></div>
1055
1063
  </div>
1056
1064
  <div class="field" id="jf-run-newname-field" data-testid="jf-run-newname-field" hidden>
1057
1065
  <label for="jf-run-newname">Name of the new workflow</label>
@@ -2629,6 +2637,12 @@
2629
2637
  var c = red ? ' is-red' : '';
2630
2638
  return '<div class="ended-row"><span class="ended-label' + c + '">' + label + '</span><span class="ended-text' + c + '"' + (testid ? ' data-testid="' + testid + '"' : '') + '>' + escapeXml(value) + '</span></div>';
2631
2639
  }
2640
+ // M9 am24: `next` is one string; `rows` ([label, instruction] pairs, from summary-words.js) is there only when it holds several instructions
2641
+ function nextRow(ended){
2642
+ if(!Array.isArray(ended.rows) || ended.rows.length < 2) return summaryRow("NEXT", ended.next, "ended-next");
2643
+ var grid = ended.rows.map(function(r){ return '<span class="next-row" style="display:contents"><span class="next-label">' + escapeXml(r[0]) + '</span><span class="next-text">' + escapeXml(r[1]) + '</span></span>'; }).join("");
2644
+ return '<div class="ended-row"><span class="ended-label">NEXT</span><span class="ended-text next-rows" data-testid="ended-next">' + grid + '</span></div>';
2645
+ }
2632
2646
  function renderSummary(detail){
2633
2647
  var sm = detail.summary || {};
2634
2648
  var box = document.getElementById("ended-block");
@@ -2639,7 +2653,7 @@
2639
2653
  if(sc && sc.red === true) tone = "red";
2640
2654
  box.hidden = false;
2641
2655
  box.className = "ended-block" + (tone ? " " + tone : "");
2642
- box.innerHTML = (sm.ended ? summaryRow("ENDED", sm.ended.reason, "ended-reason") + summaryRow("NEXT", sm.ended.next, "ended-next") : "") +
2656
+ box.innerHTML = (sm.ended ? summaryRow("ENDED", sm.ended.reason, "ended-reason") + nextRow(sm.ended) : "") +
2643
2657
  (sc ? summaryRow("SCHEDULE", sc.line1, "sched-line1", sc.red === true) + (sc.line2 ? summaryRow("", sc.line2, "sched-line2", sc.red === true) : "") : "");
2644
2658
  } else { box.hidden = true; box.innerHTML = ""; }
2645
2659
  note.hidden = !sm.catchUp;
@@ -3317,7 +3331,7 @@
3317
3331
  var auditExpanded = {}; // step -> true/false once a human toggled it; reset when the run changes
3318
3332
  var auditExpandedRun = null;
3319
3333
  // M8 item 6: cross-run learnings, READ-ONLY: what the drafter was handed from earlier runs. ONE fold at the top of the Audit tab, in both views, hidden when the run was handed nothing.
3320
- // borrowed-from: bareloop src/panel/index.html@v0.46.0 :2843-2931 (learnRow, learnHintLabel, renderAuditLearnings), drawn in fwdloop's own fold (the schedule section's header and body shape)
3334
+ // borrowed-from: bareloop src/panel/index.html@v0.47.1 (417e80c, the learnings fold arrow; the rest as @v0.46.0 :2843-2931: learnRow, learnHintLabel, renderAuditLearnings), drawn in fwdloop's own fold (the schedule section's header and body shape)
3321
3335
  // instead of bareloop's .audit-part button. The fields come from the server (learn.js parseHintBlock, the one reader of the block) - this page never splits the prose. No edit, no button but the fold.
3322
3336
  function learnRow(tbody, testid, label, lines){
3323
3337
  var tr = document.createElement("tr");
@@ -3354,7 +3368,7 @@
3354
3368
  wrap.setAttribute("data-testid", "audit-group-learnings");
3355
3369
  var head = document.createElement("button");
3356
3370
  head.type = "button";
3357
- head.className = "btn audit-part-toggle";
3371
+ head.className = "btn audit-part-toggle audit-learn-fold";
3358
3372
  head.setAttribute("aria-expanded", "false");
3359
3373
  head.setAttribute("data-testid", "audit-learnings-head");
3360
3374
  var label = "What the planner was told from earlier runs \u00B7 " + count + (count === 1 ? " hint" : " hints");
@@ -5486,7 +5500,7 @@
5486
5500
  runDestEl.readOnly = !(f && f.hasSend);
5487
5501
  runDestEl.classList.toggle("locked", !(f && f.hasSend));
5488
5502
  byId("jf-run-dest-hint").textContent = !f ? "" : (f.hasSend ? "Where the accepted result is placed, at the last step. A different folder is signed for this run only." : "This flow has no send step, so there is no destination to set.");
5489
- runCapEl.value = v ? String(v.capUsd) : "";
5503
+ runCapEl.value = f ? String(f.values.capUsd) : ""; // M6 am11: the job's SIGNED cap, never what an earlier run was capped at after drafting (v)
5490
5504
  runWaitsEl.innerHTML = "";
5491
5505
  Object.keys((v && v.askWaits) || {}).forEach(function(line){
5492
5506
  var row = document.createElement("div");
@@ -18,7 +18,7 @@ import { NOT_CHECKED_LABEL } from '../checked.js';
18
18
  import { checkSendDestination } from '../runner.js';
19
19
  import { isAgree, readingOfQuestion } from '../pageask.js';
20
20
  import { lineRules } from '../pagebits.js';
21
- import { CITED_CHECKS_FILE } from '../cited-record.js';
21
+ import { readLineSection, LINE_CHECKS_FILE } from '../line-checks.js';
22
22
  import { readChecks } from '../diary.js';
23
23
  import { sheetLineBlocks, csvRolesOf } from '../sheetblock.js';
24
24
  import { readSheetChecks } from '../sheet-record.js';
@@ -33,8 +33,6 @@ export const RESULT_YOU_CONFIRMED = '(you confirmed)';
33
33
  /** the Your-call card's words (bareloop server.js@2959217 DOOR_WORDS.waiting.head and RESULT_DOOR_ASK); the page types none of them */
34
34
  export const RESULT_DOOR_HEAD = 'waiting for you';
35
35
  export const RESULT_DOOR_ASK = 'the checks passed; is this what you wanted?';
36
- /** the M10 cited-check record, in the run's own folder: `writeCitedLine` (src/cited-record.js) is its one writer, `readCitedChecks` its one reader. */
37
- export { CITED_CHECKS_FILE };
38
36
 
39
37
  /** end-row outcomes that are not a failure of the job */
40
38
  const NOT_FAILED = new Set(['complete', 'stopped', 'cap-halt', 'rerun', 'ask-expired']);
@@ -78,7 +76,7 @@ function readProof(p) {
78
76
  }
79
77
 
80
78
  /**
81
- * The ONE reader of the M10 cited-check record (`<run>/cited-checks.json`). Expected shape (typed, nothing parsed out of prose):
79
+ * The ONE reader of the M10 cited-check record (the `cited` section of `<run>/line-checks.json`, src/line-checks.js; `writeCitedLine`, src/cited-record.js, writes it). Expected shape (typed, nothing parsed out of prose):
82
80
  * { lines: [ { n: int, source: string (the role of a signed source), passed: boolean,
83
81
  * facts: [ { name: string, kind: 'phrase'|'value', sentence: string, confirmed?: true } ],
84
82
  * rows: [ { n: int, quote: string, cells: string[] (one per fact), proof?: { text: string, marks: [[start, end], ...] } } ] | null,
@@ -88,15 +86,12 @@ function readProof(p) {
88
86
  * @returns {{present: false}|{present: true, ok: false, red: string}|{present: true, ok: true, lines: any[]}}
89
87
  */
90
88
  export function readCitedChecks(runDir) {
91
- const r = readFileInside(runDir, CITED_CHECKS_FILE);
89
+ const r = readLineSection(runDir, 'cited');
92
90
  if (!r.ok) return r.missing ? { present: false } : { present: true, ok: false, red: r.red };
93
91
  /** @param {string} why @returns {{present: true, ok: false, red: string}} */
94
- const red = (why) => ({ present: true, ok: false, red: `${CITED_CHECKS_FILE}: ${why}` });
95
- let rec;
96
- try { rec = JSON.parse(r.text); } catch { return red('not valid JSON'); }
97
- if (!rec || !Array.isArray(rec.lines)) return red('"lines" is not a list');
92
+ const red = (why) => ({ present: true, ok: false, red: `${LINE_CHECKS_FILE} (cited): ${why}` });
98
93
  const lines = [];
99
- for (const l of rec.lines) {
94
+ for (const l of r.lines) {
100
95
  if (!l || !isInt(l.n) || !isStr(l.source)) return red('a line needs an integer "n" and a "source"');
101
96
  if (typeof l.passed !== 'boolean') return red(`line ${l.n}: "passed" is not true or false`);
102
97
  if (!Array.isArray(l.facts)) return red(`line ${l.n}: "facts" is not a list`);
@@ -199,7 +194,7 @@ export function deliveredOf({
199
194
  }
200
195
 
201
196
  /**
202
- * M10 am9 item 2: the checks one job line's step(s) ran, from the run's own check record (`checks.jsonl`, written by code at every try), each step's NEWEST
197
+ * M10 am9 item 2: the checks one job line's step(s) ran, from the run's own check record (`diary.jsonl` rows of kind checks, written by code at every try), each step's NEWEST
203
198
  * try, in the Audit try line's words (`text`, `result`). Never the AI's words. A line no step ran (an ask, a send) has none.
204
199
  * @param {any[]} stepsOfLine the declaration's steps for the line @param {any[]} diary `readChecks(runDir)`
205
200
  * @returns {{ok: boolean, text: string, result: string|null}[]}
@@ -237,7 +232,7 @@ export function buildResult({
237
232
  // am9: a page job's card is bareloop's (no checks list); every other job lists what each step checked
238
233
  const diary = urls.size === 0 ? readChecks(runDir) : [];
239
234
  // M10b am2: the block of every job line that reads a sheet (guardrails, Checked with ✓ / ✗ and what was found, Not checked), from the signed job and the run's
240
- // sheet-checks.json; it is there with no rows found and when the result is written to a doc
235
+ // the sheet section of line-checks.json; it is there with no rows found and when the result is written to a doc
241
236
  const sheetBlocks = sheetLineBlocks({ declaration, lines: flowRead.lines, csvRoles: csvRolesOf(arbiter), record: readSheetChecks(runDir) });
242
237
  const lines = flowRead.lines.filter((l) => !taken.has(l.n)).map((l) => {
243
238
  const c = record.find((x) => x.n === l.n) ?? null;
@@ -376,7 +376,7 @@ function authorPost(res, url, body, author) {
376
376
  * real listening socket where that is simpler.
377
377
  * @param {import('node:http').IncomingMessage} req
378
378
  * @param {import('node:http').ServerResponse} res
379
- * @param {{ root: string, port: number, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number }} opts
379
+ * @param {{ root: string, port: number, version?: string|null, startedAt?: string, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number }} opts
380
380
  */
381
381
  export function handleRequest(req, res, opts) {
382
382
  const method = req.method ?? 'GET';
@@ -510,7 +510,7 @@ export function handleRequest(req, res, opts) {
510
510
  return;
511
511
  }
512
512
  html = html.replace(/__FWDLOOP_PANEL_PORT__/g, String(opts.port));
513
- const version = readOwnVersion(opts.packagePath); // M4d am17: the header's number, read from fwdloop's own package.json at serve time
513
+ const version = opts.version !== undefined ? opts.version : readOwnVersion(opts.packagePath); // M4d am17: the header's number from fwdloop's own package.json; M4b am5 item 5: the one read at panel start (opts.version), not at serve time
514
514
  html = version === null ? html.replace(/v__FWDLOOP_VERSION__/g, 'version unknown').replace(/__FWDLOOP_VERSION__/g, '') : html.replace(/__FWDLOOP_VERSION__/g, version);
515
515
  html = html.replace(/__FWDLOOP_PLAN_CHECK_RULES__/g, () => JSON.stringify(pageRules())); // M4d am15: the one copy of the plain words
516
516
  if (method === 'HEAD') {
@@ -523,6 +523,13 @@ export function handleRequest(req, res, opts) {
523
523
  return;
524
524
  }
525
525
 
526
+ // M4b am4 item 7 (borrowed-from: bareloop src/panel/server.js@cb2e8a7): who is answering here, the launcher's probe (`fwdloop start|stop|status`). Read-only, no token;
527
+ // the Host guard above already holds. `drafts` = the open drafting card (opts.author.openDrafts), `schedules` = jobs with a live schedule.
528
+ if (pathname === '/api/whoami') {
529
+ send(200, whoamiPayload(opts));
530
+ return;
531
+ }
532
+
526
533
  const loaded = loadCatalogue();
527
534
  if (!loaded.ok) {
528
535
  sendText(res, 500, `catalogue failed to load: ${cleanPaths(loaded.reds.join('; '), opts.root)}`);
@@ -629,13 +636,50 @@ export function handleRequest(req, res, opts) {
629
636
  sendText(res, 404, 'not found');
630
637
  }
631
638
 
639
+ /**
640
+ * `GET /api/whoami` body (borrowed-from: bareloop src/panel/server.js@cb2e8a7 whoamiPayload, commit 98cbb1c version read at start).
641
+ * Adapted: app 'fwdloop'; `drafts` = `author.openDrafts()` (the open drafting card), `schedules` = the live schedules `author.trigger.scan()` finds.
642
+ * @param {{ port: number, version?: string|null, startedAt?: string, packagePath?: string, author?: ReturnType<typeof createAuthor> }} opts
643
+ */
644
+ function whoamiPayload(opts) {
645
+ const drafts = opts.author ? opts.author.openDrafts() : 0;
646
+ let schedules = 0;
647
+ try { schedules = opts.author ? opts.author.trigger.scan().length : 0; } catch { schedules = 0; }
648
+ const version = opts.version !== undefined ? opts.version : readOwnVersion(opts.packagePath);
649
+ return { app: 'fwdloop', version: version ?? 'unknown', pid: process.pid, port: opts.port, drafts, schedules, startedAt: opts.startedAt };
650
+ }
651
+
652
+ /**
653
+ * The runs list as the panel builds it, for a caller with no panel running (the launcher header): the SAME `listRuns` over the same catalogue,
654
+ * so Needs you (M11's `needsYouOf` tag on each row) has ONE owner. Read-only, $0; the resume-attempt and starting-run lookups are the panel's
655
+ * in-memory ones and a stopped panel has none.
656
+ * borrowed-from: bareloop src/panel/server.js@c772d4e (runsListForCount); adapted: fwdloop's listRuns rows, no schedules-gave-up part (fwdloop has no such concept).
657
+ * @param {{ root: string, now?: () => number }} opts
658
+ * @returns {any[]} the rows of /api/runs
659
+ */
660
+ export function runsListForCount(opts) {
661
+ const loaded = loadCatalogue();
662
+ if (!loaded.ok) throw new Error(`catalogue failed to load: ${loaded.reds.join('; ')}`);
663
+ return listRuns({ root: opts.root, catalogue: loaded.primitives, ...(opts.now ? { now: opts.now } : {}) });
664
+ }
665
+
666
+ /**
667
+ * The ONE spelling of the panel's own address (the launcher prints and opens it too).
668
+ * borrowed-from: bareloop src/panel/server.js@9104b2b (panelUrl); adaptation: none.
669
+ * @param {number} boundPort
670
+ * @returns {string}
671
+ */
672
+ export function panelUrl(boundPort) {
673
+ return `http://127.0.0.1:${boundPort}`;
674
+ }
675
+
632
676
  /**
633
677
  * Start the panel server. Binds `127.0.0.1` ONLY. A taken port is a LOUD,
634
678
  * non-zero-exit failure — this never falls back to another port (see file
635
679
  * header). Resolves once actually listening; rejects on a bind error
636
680
  * (including `EADDRINUSE`) with a `.port` field on the error for the
637
681
  * caller's message.
638
- * @param {{ port?: number, root: string, packagePath?: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: Function, platform?: string }, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number }, author?: { env?: Record<string,string|undefined>, loadEnv?: () => any, bin?: string, now?: () => number }, scheduler?: { intervalMs?: number } }} opts
682
+ * @param {{ port?: number, root: string, packagePath?: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number }, author?: { env?: Record<string,string|undefined>, loadEnv?: () => any, bin?: string, now?: () => number }, scheduler?: { intervalMs?: number } }} opts
639
683
  * `resume` and `author` are for tests only (a fake env/bin, a short retry window); the CLI passes none.
640
684
  * @returns {Promise<{ server: import('node:http').Server, port: number, tick: () => void, close: () => Promise<void> }>}
641
685
  */
@@ -645,6 +689,10 @@ export function createPanelServer(opts) {
645
689
  }
646
690
  const requestedPort = opts.port ?? DEFAULT_PORT;
647
691
  const { root } = opts;
692
+ // M4b am5 item 5: the version THIS process runs, read once at start. package.json on disk can move on while the panel keeps running old code.
693
+ const version = readOwnVersion(opts.packagePath);
694
+ // M4b am6 item 1: when this panel started, set once here; whoami hands it out so the launcher can say how long ago.
695
+ const startedAt = new Date().toISOString();
648
696
  // One resumer per server: the one owner of every run's resume-attempt record.
649
697
  // M4d: the keys file is re-read before EVERY resume spawn (editing it needs no restart); an env injected by a test is the shell side.
650
698
  const resumer = createResumer({ root, loadEnv: () => keysForDoor({ env: opts.resume?.env }), ...opts.resume });
@@ -672,7 +720,7 @@ export function createPanelServer(opts) {
672
720
  const server = createServer((req, res) => {
673
721
  try {
674
722
  handleRequest(req, res, {
675
- root, port: boundPort, resumer, settings, author, packagePath: opts.packagePath, now: opts.author?.now,
723
+ root, port: boundPort, resumer, settings, author, version, startedAt, packagePath: opts.packagePath, now: opts.author?.now,
676
724
  });
677
725
  } catch (e) {
678
726
  sendText(res, 500, 'internal error');
@@ -726,7 +774,7 @@ export async function panelMain(argv, ctx) {
726
774
  const keys = keysForDoor();
727
775
  if (!keys.ok) ctx.err(String(keys.refusal));
728
776
  ctx.out(`fwdloop panel — (root: ${root}) (Ctrl-C to stop)`);
729
- ctx.out(`http://127.0.0.1:${boundPort}/`);
777
+ ctx.out(`${panelUrl(boundPort)}/`);
730
778
  // never resolves on its own — the process stays up until killed, same
731
779
  // shape any other long-running dev server takes.
732
780
  await new Promise(() => {});
@@ -21,7 +21,7 @@ import {
21
21
  import { SHAPES } from '../providershapes.js';
22
22
  import { keysForDoor, isKeyName } from '../keysfile.js';
23
23
  import { spendSummary } from '../monthly.js';
24
- import { spawnOpener as realSpawn } from './spawn.js';
24
+ import { openInOs } from '../opener.js';
25
25
  import { dirname } from 'node:path';
26
26
  import { homedir } from 'node:os';
27
27
 
@@ -32,7 +32,7 @@ const BROKEN_CONFIG = 'Your settings file (config.json) cannot be read. Fix or r
32
32
  const isNumberAbove0 = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0;
33
33
 
34
34
  /**
35
- * @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: Function, platform?: string }} cfg
35
+ * @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }} cfg
36
36
  * `home` the config home (undefined = the real `~/.config/fwdloop`); `skip` true under a test process
37
37
  * with no `FWDLOOP_CONFIG_HOME` (Settings then touches nothing); `env` the shell side (tests only);
38
38
  * `fetch` and `now` are test seams.
@@ -181,22 +181,8 @@ export function createSettings(cfg) {
181
181
  const shown = keys().path;
182
182
  const dir = dirname(shown.startsWith('~') ? homedir() + shown.slice(1) : shown);
183
183
  const cannot = () => reply(200, { ok: true, opened: false, path: dir });
184
- const platform = cfg.platform ?? process.platform;
185
- const cmd = platform === 'linux' ? 'xdg-open' : (platform === 'darwin' ? 'open' : null);
186
- const opener = cfg.openFolderSpawn ?? (process.env.NODE_ENV === 'test' ? null : realSpawn);
187
- if (!cmd || !opener) return Promise.resolve(cannot());
188
- return new Promise((resolve) => {
189
- let child;
190
- try { child = opener(cmd, [dir], { detached: true, stdio: 'ignore' }); } catch { resolve(cannot()); return; }
191
- let settled = false;
192
- child.once('error', () => { if (!settled) { settled = true; resolve(cannot()); } });
193
- child.once('spawn', () => {
194
- if (settled) return;
195
- settled = true;
196
- if (typeof child.unref === 'function') child.unref();
197
- resolve(reply(200, { ok: true, opened: true, path: dir }));
198
- });
199
- });
184
+ return openInOs(dir, { platform: cfg.platform, spawnFn: cfg.openFolderSpawn, underTest: process.env.NODE_ENV === 'test' })
185
+ .then((opened) => (opened ? reply(200, { ok: true, opened: true, path: dir }) : cannot()));
200
186
  }
201
187
 
202
188
  async function test(body) {
@@ -17,15 +17,6 @@ import { keyValues } from '../keysfile.js';
17
17
  /** A pid whose liveness cannot be told (no /proc) counts as running only while its pid.json is this fresh (M4c's 10-minute rule). */
18
18
  const UNKNOWN_FRESH_MS = 10 * 60 * 1000;
19
19
 
20
- /**
21
- * The ONE spawn for the Settings "Open keys folder" button (borrowed-from: bareloop src/panel/settingsroutes.js@07c298f): the OS file manager
22
- * (`xdg-open` / `open`) on a folder the server chose, argv array, no shell, detached. Settings calls it only through its injected seam.
23
- * @param {string} cmd @param {string[]} args @param {import('node:child_process').SpawnOptions} o
24
- */
25
- export function spawnOpener(cmd, args, o) {
26
- return spawn(cmd, args, o);
27
- }
28
-
29
20
  /**
30
21
  * @param {{ bin: string, argv: string[], env: Record<string, string|undefined>, logPath: string }} a
31
22
  * @returns {import('node:child_process').ChildProcess} the child (already `unref()`ed; the log fd is closed here)
package/src/prompts.js ADDED
@@ -0,0 +1,33 @@
1
+ // borrowed-from: bareloop src/prompts.js@1bad2c8 (openAsker only; askRequired and the menu changes are not copied)
2
+ // The CLI's one line-asker. Every prompt in the launcher reads through this, so a closed stdin behaves the same everywhere.
3
+
4
+ import { createInterface } from 'node:readline';
5
+
6
+ /**
7
+ * One readline over `stdin`, with a LINE QUEUE: lines that arrive before the next question (piped input, a paste, or input that
8
+ * ends while the header is still waiting on the port probe) wait for it instead of being dropped, and a closed stdin answers ''
9
+ * (the safe default) and never hangs.
10
+ * @param {{ stdin?: any, stdout?: any }} [io]
11
+ * @returns {{ ask: (q: string) => Promise<string>, close: () => void }}
12
+ */
13
+ export function openAsker(io = {}) {
14
+ const stdout = io.stdout ?? process.stdout;
15
+ const stdin = io.stdin ?? process.stdin;
16
+ const tty = Boolean(stdin.isTTY);
17
+ // a real terminal needs readline's output to echo the typed line; piped input echoes nothing
18
+ const rl = createInterface({ input: stdin, ...(tty ? { output: stdout, terminal: true } : { terminal: false }) });
19
+ /** @type {string[]} */
20
+ const queue = [];
21
+ /** @type {((s: string) => void)[]} */
22
+ const waiting = [];
23
+ let closed = false;
24
+ rl.on('line', (line) => { const w = waiting.shift(); if (w) w(line); else queue.push(line); });
25
+ rl.once('close', () => { closed = true; while (waiting.length) /** @type {(s: string) => void} */ (waiting.shift())(''); });
26
+ const ask = (/** @type {string} */ q) => {
27
+ stdout.write(q);
28
+ if (queue.length) return Promise.resolve(/** @type {string} */ (queue.shift()));
29
+ if (closed) return Promise.resolve('');
30
+ return new Promise((resolve) => { waiting.push(resolve); });
31
+ };
32
+ return { ask, close: () => rl.close() };
33
+ }
package/src/runfile.js ADDED
@@ -0,0 +1,60 @@
1
+ // M8b item 1: `run.json`, the run's start record - one file in the run's folder with three sections: `model` (the model the run started on, M4d am33),
2
+ // `thinking` (the job's "Thinking on" box as it was at the start, M4d am25) and `inputs` (the manifest `freezeInputs` made, M3/M10). Written once, by
3
+ // `writeRunStart` and nothing else; every reader of those three goes through this file's readers (`readRunModel` is in src/flowmodel.js, which owns the provider's
4
+ // key-name check). Kept free of the provider on purpose: the learnings note code reads `inputs` and must reach no provider module.
5
+ import { writeFileSync } from 'node:fs';
6
+ import { join } from 'node:path';
7
+ import { readFileInside } from './flow.js';
8
+
9
+ /** the file's name in the run's folder */
10
+ export const RUN_FILE = 'run.json';
11
+
12
+ /**
13
+ * The record as parsed, or why not. `missing` = no file; `unreadable` = the gateway refused it (a symlink, outside the folder); `invalid` = not a JSON object.
14
+ * @param {string|null} runDir @returns {{ok: true, rec: Record<string, any>}|{ok: false, code: 'missing'|'unreadable'|'invalid', red: string}}
15
+ */
16
+ export function readRunRecord(runDir) {
17
+ if (typeof runDir !== 'string') return { ok: false, code: 'missing', red: `no ${RUN_FILE}` };
18
+ const r = readFileInside(runDir, RUN_FILE);
19
+ if (!r.ok) return r.missing ? { ok: false, code: 'missing', red: `no ${RUN_FILE}` } : { ok: false, code: 'unreadable', red: `${RUN_FILE}: ${r.red}` };
20
+ try {
21
+ const j = JSON.parse(r.text);
22
+ return j !== null && typeof j === 'object' && !Array.isArray(j) ? { ok: true, rec: j } : { ok: false, code: 'invalid', red: `${RUN_FILE} is not a JSON object` };
23
+ } catch (err) { return { ok: false, code: 'invalid', red: `${RUN_FILE} is not valid JSON — ${/** @type {any} */ (err).message}` }; }
24
+ }
25
+
26
+ /**
27
+ * M4d am26: the run's OWN record of the box (`thinking` in `<run>/run.json`) and nothing else: `true`/`false`, or `null` when the run has none (a run from before am25).
28
+ * An unreadable record is box off, as `readJobThinking` has always read it. @param {string|null} runDir @returns {boolean|null}
29
+ */
30
+ export function readRunThinking(runDir) {
31
+ const got = readRunRecord(runDir);
32
+ if (!got.ok) return got.code === 'invalid' ? false : null;
33
+ return Object.hasOwn(got.rec, 'thinking') ? got.rec.thinking === true : null;
34
+ }
35
+
36
+ /**
37
+ * M8b: the ONE reader of what a run froze at its start (`inputs` in `<run>/run.json`: the manifest `freezeInputs` made). `missing` = the run froze none (no record, or no
38
+ * `inputs` section: a refusal at freeze leaves none); `unreadable` = the gateway refused the file; `invalid` = the section is not a list.
39
+ * @param {string|null} runDir
40
+ * @returns {{ok: true, entries: any[]}|{ok: false, code: 'missing'|'unreadable'|'invalid', red: string}}
41
+ */
42
+ export function readRunInputs(runDir) {
43
+ const got = readRunRecord(runDir);
44
+ if (!got.ok) return got;
45
+ if (!Object.hasOwn(got.rec, 'inputs')) return { ok: false, code: 'missing', red: `${RUN_FILE} has no inputs` };
46
+ return Array.isArray(got.rec.inputs) ? { ok: true, entries: got.rec.inputs } : { ok: false, code: 'invalid', red: `${RUN_FILE}: inputs is not a list` };
47
+ }
48
+
49
+ /**
50
+ * M8b item 1: the ONE writer of `run.json`, called once when a fresh run has frozen its inputs (`runFlow`); never over an existing record. `model` is the pick
51
+ * the run started on (M4d am33; null = the section is left out), `thinking` the job's "Thinking on" box as it was at the start (M4d am25: written for every fresh
52
+ * run, ticked or not), `inputs` the manifest `freezeInputs` returned. A section given as null is left out;
53
+ * a fresh run always has `thinking` and `inputs`.
54
+ * @param {string} runDir @param {{ model: { slot: string, model: string }|null, thinking: boolean|null, inputs: any[]|null }} start
55
+ */
56
+ export function writeRunStart(runDir, { model, thinking, inputs }) {
57
+ writeFileSync(join(runDir, RUN_FILE), `${JSON.stringify({
58
+ ...(model ? { model: { slot: model.slot, model: model.model } } : {}), ...(thinking === null ? {} : { thinking }), ...(inputs === null ? {} : { inputs }),
59
+ }, null, 2)}\n`, { mode: 0o600, flag: 'wx' });
60
+ }