kryptheon 0.1.74 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/kryptheon.js CHANGED
@@ -3221,26 +3221,43 @@ async function everythingFromDashboard(steps, opened, say, control, info) {
3221
3221
  });
3222
3222
  const step = { onStop: (fn) => (stopStep = fn) };
3223
3223
  const done = [];
3224
+ const dash = require(path.join(PACKAGE_DIR, 'kryptheon-dashboard.js'));
3225
+ const progress = typeof control.progress === 'function' ? control.progress : () => {};
3226
+ const estimate = (s) => (Number.isFinite(s.estimateMs) ? s.estimateMs : 60000);
3227
+ let quickSaid = false;
3224
3228
  for (let i = 0; i < steps.length; i++) {
3225
3229
  const s = steps[i];
3226
3230
  if (stopped) {
3227
3231
  done.push({ id: s.id, label: s.label, ok: false, said: 'not run: stopped' });
3228
3232
  continue;
3229
3233
  }
3234
+ // The first deep step: what ran so far is on Findings already, and the page and the guide say so.
3235
+ const quickDone = Boolean(s.deep) && i > 0;
3236
+ const leftMs = steps.slice(i).reduce((n, x) => n + estimate(x), 0);
3237
+ if (quickDone && !quickSaid) {
3238
+ quickSaid = true;
3239
+ say('');
3240
+ say('The first findings are ready - open Findings and start on the serious ones. The deeper checks keep running: about ' + dash.howLong(leftMs) + ' more.');
3241
+ }
3242
+ progress({ step: i + 1, of: steps.length, id: s.id, label: s.label, deep: Boolean(s.deep), quickDone: quickSaid, leftMs: leftMs, stepStartedAt: new Date().toISOString() });
3230
3243
  say('');
3231
3244
  say('Step ' + (i + 1) + ' of ' + steps.length + ': ' + s.label + ' - ' + s.title);
3232
3245
  stopStep = null;
3246
+ const t0 = Date.now();
3233
3247
  let r;
3234
3248
  try {
3235
3249
  if (s.id === 'api') r = await apiFromDashboard(s.origin, say, step, s.readOnly === true);
3236
- else if (PROBE_CHECKS[s.id]) r = await probeFromDashboard(s.id, say, step, info.confirmed);
3250
+ else if (PROBE_CHECKS[s.id]) r = await probeFromDashboard(s.id, say, step, info.confirmed, s.deep ? dash.DEEP_STEP_LIMIT_MS : 0);
3237
3251
  else r = await runFromDashboard(s.id, opened, say);
3238
3252
  } catch (err) {
3239
3253
  r = { ok: false, why: err && err.message ? err.message : String(err) };
3240
3254
  }
3255
+ const took = Date.now() - t0;
3241
3256
  const ok = Boolean(r && r.ok);
3242
- done.push({ id: s.id, label: s.label, ok: ok, said: ok ? r.summary : 'did not finish: ' + ((r && r.why) || 'it gave no answer') });
3243
- say((ok ? 'Done: ' : 'Did not finish: ') + (ok ? r.summary : (r && r.why) || 'it gave no answer'));
3257
+ // measured only when the step ran its whole course: a stopped or cut step would make the next estimate short
3258
+ if (ok && !stopped && !(r && r.timeUp)) dash.rememberStepTime(USER_DIR, process.env, s.id, took);
3259
+ done.push({ id: s.id, label: s.label, ok: ok, tookMs: took, said: (ok ? r.summary : 'did not finish: ' + ((r && r.why) || 'it gave no answer')) + ' (' + dash.howLong(took) + ')' });
3260
+ say((ok ? 'Done in ' + dash.howLong(took) + ': ' : 'Did not finish (' + dash.howLong(took) + '): ') + (ok ? r.summary : (r && r.why) || 'it gave no answer'));
3244
3261
  }
3245
3262
  say('');
3246
3263
  say('What ran:');
@@ -3311,7 +3328,7 @@ function runFromDashboard(id, opened, say) {
3311
3328
  * the tick, for an address that is not this computer) - so it runs here, in
3312
3329
  * this process, where its Stop can reach the browser run.
3313
3330
  */
3314
- async function probeFromDashboard(id, say, control, confirmed) {
3331
+ async function probeFromDashboard(id, say, control, confirmed, limitMs) {
3315
3332
  if (!PROBE_CHECKS[id]) return { ok: false, why: '"' + id + '" cannot be run from the dashboard' };
3316
3333
  const runner = probeModule(id);
3317
3334
  const { flows } = probeFlows();
@@ -3324,19 +3341,36 @@ async function probeFromDashboard(id, say, control, confirmed) {
3324
3341
  }
3325
3342
  if (!flows.length) return { ok: false, why: 'there is no recording that can be replayed - record one of your flows' };
3326
3343
  if (!ensureBrowser()) return { ok: false, why: 'the browser could not be downloaded' };
3344
+ // Inside Check my app a deep step has a time limit: then it stops like Stop does - what it found is kept, and
3345
+ // what it did not reach is said as not tried.
3346
+ let timeUp = false;
3347
+ let timer = null;
3327
3348
  const report = await runner.run(USER_DIR, flows, {
3328
3349
  say: say,
3329
- onControl: (c) => control.onStop(() => c.stop()),
3350
+ onControl: (c) => {
3351
+ control.onStop(() => c.stop());
3352
+ if (limitMs > 0 && !timer) {
3353
+ timer = setTimeout(() => {
3354
+ timeUp = true;
3355
+ say('Time limit of ' + Math.round(limitMs / 60000) + ' minutes reached: stopping here and keeping what was found.');
3356
+ c.stop();
3357
+ }, limitMs);
3358
+ if (timer.unref) timer.unref();
3359
+ }
3360
+ },
3330
3361
  confirmed: confirmed || [],
3331
3362
  });
3363
+ if (timer) clearTimeout(timer);
3332
3364
  runner.save(USER_DIR, report);
3333
3365
  for (const line of runner.summaryLines(report)) say(line);
3334
3366
  const problems = report.findings.filter((f) => f.status === 'confirmed').length;
3335
3367
  const tested = report.flows.some((f) => f.state === 'tested');
3336
- if (!tested) return { ok: false, why: 'nothing was tested - see what it printed' };
3368
+ if (!tested) return { ok: false, why: 'nothing was tested - see what it printed', timeUp: timeUp };
3337
3369
  return {
3338
3370
  ok: true,
3339
- summary: (report.stopped ? 'stopped after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs - ' : '') +
3371
+ timeUp: timeUp,
3372
+ summary: (timeUp ? 'time limit reached after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs, the rest not tried - '
3373
+ : report.stopped ? 'stopped after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs - ' : '') +
3340
3374
  (problems ? problems + (problems === 1 ? ' problem found' : ' problems found') + ' - see Findings' : 'no problem found in what was tried') +
3341
3375
  (report.testData.length ? '. ' + report.testData.length + ' test writes were left in your app' : ''),
3342
3376
  };
@@ -3874,6 +3908,14 @@ async function dashboardCommand() {
3874
3908
  console.log(' It is only reachable from this machine. Everything else is a button');
3875
3909
  console.log(' on that page. Press Ctrl+C here to stop it.');
3876
3910
  console.log('');
3911
+ // This window IS Kryptheon; the page is only its screen. Closed, or paused by a click inside it (Windows
3912
+ // QuickEdit), every button on the page stops working - said here, where it happens (2026-11-22).
3913
+ console.log(' ==================================================================');
3914
+ console.log(' KEEP THIS WINDOW OPEN while you use Kryptheon.');
3915
+ console.log(' Minimize it - do not close it, and do not click inside it:');
3916
+ console.log(' a click inside pauses it ("Select" in the title). Esc resumes.');
3917
+ console.log(' ==================================================================');
3918
+ console.log('');
3877
3919
 
3878
3920
  // While the page is open, Kryptheon notices changes by itself: once a change
3879
3921
  // has settled, it looks, runs the fast checks, and the page shows what
@@ -95,12 +95,80 @@
95
95
  body: JSON.stringify(body),
96
96
  }).then(function (res) {
97
97
  return res.json().then(function (data) {
98
+ // Kryptheon was started again since this page was opened: its token is new, so this page is too old to use.
99
+ if (res.status === 403 && data.why === 'missing or wrong token') {
100
+ window.location.reload();
101
+ throw new Error('Kryptheon was started again - this page is reloading.');
102
+ }
98
103
  if (!res.ok || data.ok === false) throw new Error(data.why || 'the dashboard answered ' + res.status);
99
104
  return data;
100
105
  });
106
+ }, function (err) {
107
+ // No answer at all: the black window - Kryptheon itself - is closed or paused. Never "Failed to fetch".
108
+ if (isNoAnswer(err)) { markStopped(); throw new Error(STOPPED_WORDS); }
109
+ throw err;
101
110
  });
102
111
  }
103
112
 
113
+ /* ----------------------------- Kryptheon stopped ----------------------------- */
114
+
115
+ // The page is only a screen; Kryptheon is the black window that opened it. Closed, or paused by a click inside it
116
+ // (Windows QuickEdit), it answers nothing - and every button said "Failed to fetch" (2026-11-22). A heartbeat
117
+ // notices within seconds, a box says what happened and how to start it again, and when Kryptheon is back the
118
+ // page reloads itself: a new start has a new token, so the old page could not press anything.
119
+ var STOPPED_WORDS = 'Kryptheon stopped on this computer - the box on the page says how to start it again.';
120
+ var misses = 0;
121
+ var stopped = false;
122
+ function isNoAnswer(err) { return !!err && (err.name === 'TypeError' || /Failed to fetch|NetworkError|Load failed/i.test(String(err.message))); }
123
+ function startCommand() {
124
+ var root = state && state.project && state.project.root;
125
+ var mac = /Mac/i.test(navigator.platform || '') || /Mac OS X/.test(navigator.userAgent || '');
126
+ if (mac) return (root ? 'cd "' + root + '" && ' : '') + 'npx -y kryptheon@latest dashboard';
127
+ return 'cmd /k ' + (root ? 'cd /d "' + root + '" && ' : '') + 'npx -y kryptheon@latest dashboard';
128
+ }
129
+ function markStopped() {
130
+ if (stopped) return;
131
+ stopped = true;
132
+ var box = byId('stoppedBox');
133
+ if (!box) return;
134
+ var mac = /Mac/i.test(navigator.platform || '') || /Mac OS X/.test(navigator.userAgent || '');
135
+ clear(box);
136
+ var card = el('div', 'stopped-card');
137
+ card.appendChild(el('h2', null, 'Kryptheon stopped on this computer'));
138
+ card.appendChild(el('p', null, 'This page is only the screen. Kryptheon itself is the black window that opened it' +
139
+ (mac ? ' (the Terminal window)' : '') + ' - and it is closed, or paused.'));
140
+ var ways = el('ul');
141
+ ways.appendChild(el('li', null, mac ? 'If the Terminal window is still open: click it. If it shows an error, start it again below.'
142
+ : 'If you see the black window in the taskbar: click it and press Esc. A click inside it pauses it - "Select" in its title means paused.'));
143
+ ways.appendChild(el('li', null, mac ? 'If it is closed: open Terminal, paste this and press Enter:'
144
+ : 'If it is closed: press Win+R, paste this and press Enter:'));
145
+ card.appendChild(ways);
146
+ var line = el('div', 'stopped-cmd');
147
+ var cmd = startCommand();
148
+ line.appendChild(el('code', null, cmd));
149
+ line.appendChild(button('sun sm', 'copy', 'Copy', function () { copy(cmd, 'Copied - paste it ' + (mac ? 'into Terminal' : 'into Win+R') + ' and press Enter'); }));
150
+ card.appendChild(line);
151
+ var wait = el('p', 'stopped-wait');
152
+ wait.appendChild(el('span', 'spin'));
153
+ wait.appendChild(document.createTextNode(' Waiting for Kryptheon - this page comes back by itself as soon as it starts.'));
154
+ card.appendChild(wait);
155
+ card.appendChild(el('p', 'fallback', 'Keep the black window open while you use Kryptheon: minimize it, never close it, never click inside it.'));
156
+ box.appendChild(card);
157
+ box.hidden = false;
158
+ byId('subline').textContent = 'Kryptheon stopped on this computer';
159
+ }
160
+ setInterval(function () {
161
+ fetch('/api/job', { cache: 'no-store' }).then(function (res) {
162
+ if (!res.ok) return;
163
+ misses = 0;
164
+ if (stopped) window.location.reload();
165
+ }, function (err) {
166
+ if (!isNoAnswer(err)) return;
167
+ misses += 1;
168
+ if (misses >= 2) markStopped();
169
+ });
170
+ }, 3000);
171
+
104
172
  function setBusy(on) {
105
173
  busy = on;
106
174
  Array.prototype.forEach.call(document.querySelectorAll('[data-action]'), function (b) { b.disabled = on; });
@@ -124,7 +192,7 @@
124
192
  }
125
193
  // The guide (kryptheon-tour.js) follows the page: what the server last said, and whether something runs.
126
194
  function tell() {
127
- try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy } })); } catch (e) { /* no guide then */ }
195
+ try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy, quickDone: !!(busy && job && job.progress && job.progress.quickDone) } })); } catch (e) { /* no guide then */ }
128
196
  }
129
197
  // The clipboard, and when a browser refuses it, the older way: the text
130
198
  // put in a box off the screen, selected and copied.
@@ -267,6 +335,24 @@
267
335
  head.appendChild(close);
268
336
  }
269
337
  box.appendChild(head);
338
+ // Check my app: where it is, how long is left (measured on this computer once it has run), and - once the quick
339
+ // part is done - that its findings can be read while the deeper checks keep going.
340
+ var p = job.running && job.progress;
341
+ if (p) {
342
+ var left = Math.max(0, (p.leftMs || 0) - (Date.now() - new Date(p.stepStartedAt).getTime()));
343
+ box.appendChild(el('div', 'job-progress', 'Step ' + p.step + ' of ' + p.of + ': ' + p.label + ' · about ' + minutesWords(left) + ' left'));
344
+ if (p.quickDone) {
345
+ var ready = el('div', 'job-ready');
346
+ ready.appendChild(el('span', null, 'The first findings are ready. Read them and start on the serious ones - the deeper checks keep running.'));
347
+ if (currentView() !== 'findings') {
348
+ var see = el('button', 'go', 'See findings →');
349
+ see.type = 'button';
350
+ see.addEventListener('click', function () { go('findings'); });
351
+ ready.appendChild(see);
352
+ }
353
+ box.appendChild(ready);
354
+ }
355
+ }
270
356
  var open = linesOpen === null ? job.running || !ok : linesOpen;
271
357
  var lines = null;
272
358
  if (open) {
@@ -303,13 +389,23 @@
303
389
  root.style.setProperty('--job-room', (box.offsetHeight + 12) + 'px');
304
390
  }
305
391
 
392
+ /** "under a minute", "1 minute", "12 minutes". */
393
+ function minutesWords(ms) {
394
+ var m = Math.round(ms / 60000);
395
+ return m < 1 ? 'under a minute' : m === 1 ? '1 minute' : m + ' minutes';
396
+ }
397
+
306
398
  function getJob() {
307
399
  return fetch('/api/job', { cache: 'no-store' }).then(function (res) { return res.json(); }).then(function (d) { return d.job; });
308
400
  }
309
401
 
310
402
  /** Starts a job and follows it to its end. Resolves with the finished job. */
311
403
  function runJob(path, body) {
312
- if (busy) { toast('Something is already running - wait for it to finish.'); return Promise.reject(new Error('busy')); }
404
+ if (busy) {
405
+ var pr = job && job.running && job.progress;
406
+ toast(pr && pr.quickDone ? 'Check my app is still running its deeper checks - try this again when they end.' : 'Something is already running - wait for it to finish.');
407
+ return Promise.reject(new Error('busy'));
408
+ }
313
409
  setBusy(true);
314
410
  return post(path, body).then(function (started) {
315
411
  job = started.job;
@@ -331,7 +427,13 @@
331
427
  getJob().then(function (now) {
332
428
  // Drawn again only when something in it changed, so a button in it
333
429
  // stays the same button between presses.
334
- if (now && JSON.stringify(now) !== JSON.stringify(job)) { job = now; renderJob(); }
430
+ if (now && JSON.stringify(now) !== JSON.stringify(job)) {
431
+ var wasQuick = !!(job && job.progress && job.progress.quickDone);
432
+ job = now;
433
+ renderJob();
434
+ // the quick part just finished: its findings are on the server now - load them, and tell the guide
435
+ if (!wasQuick && job.progress && job.progress.quickDone) { load(); tell(); }
436
+ }
335
437
  if (now && now.running) setTimeout(tick, 700);
336
438
  else resolve(now);
337
439
  }, function () { setTimeout(tick, 1500); });
@@ -850,6 +952,10 @@
850
952
  return box;
851
953
  }
852
954
 
955
+ // What the findings list shows in the open: the rest are in "More to check", which stays as the person left it.
956
+ var SERIOUS = { CRITICAL: true, 'HIGH CRITICAL': true, HIGH: true };
957
+ function isSerious(f) { return !!SERIOUS[f.severity]; }
958
+ var moreOpen = false;
853
959
  function renderFindings() {
854
960
  var body = byId('findingList');
855
961
  clear(body);
@@ -858,7 +964,8 @@
858
964
  if (statusFilter === 'verify' && f.status === 'confirmed') return false;
859
965
  return true;
860
966
  });
861
- byId('findingBadge').textContent = shown.length + (shown.length !== state.findings.length ? ' of ' + state.findings.length : '');
967
+ var serious = shown.filter(isSerious).length;
968
+ byId('findingBadge').textContent = (serious ? serious + ' serious · ' : '') + shown.length + (shown.length !== state.findings.length ? ' of ' + state.findings.length : '');
862
969
  // A finding the last re-check closed is no longer in the list, so its
863
970
  // answer is said here instead - with what the fix newly broke, if anything.
864
971
  var open = state.findings.some(function (f) { return lastRecheck && f.id === lastRecheck.id; });
@@ -907,6 +1014,16 @@
907
1014
  return;
908
1015
  }
909
1016
  var newlyBroken = (lastRecheck ? lastRecheck.newProblems : []).map(function (p) { return p.id; });
1017
+ // Serious first, in the open; the rest in a box that opens, counted - never left out. Only when there is
1018
+ // something serious: a list of nothing but smaller things is shown as it is.
1019
+ var seriousCount = shown.filter(isSerious).length;
1020
+ var more = null;
1021
+ if (seriousCount && seriousCount < shown.length) {
1022
+ more = el('details', 'f-more');
1023
+ more.open = moreOpen;
1024
+ more.addEventListener('toggle', function () { moreOpen = more.open; });
1025
+ more.appendChild(el('summary', null, 'More to check (' + (shown.length - seriousCount) + ') - medium and low: worth fixing, after the serious ones above'));
1026
+ }
910
1027
  shown.forEach(function (f) {
911
1028
  var card = el('div', 'finding ' + (f.status === 'confirmed' ? 'bad' : 'warn'));
912
1029
  var head = el('button', 'finding-head');
@@ -961,8 +1078,9 @@
961
1078
  card.appendChild(quick);
962
1079
  }
963
1080
  if (openRow === f.id) card.appendChild(detailBox(f));
964
- body.appendChild(card);
1081
+ (more && !isSerious(f) ? more : body).appendChild(card);
965
1082
  });
1083
+ if (more) body.appendChild(more);
966
1084
  }
967
1085
 
968
1086
  /* -------------------------------- other views -------------------------------- */
@@ -1256,7 +1374,7 @@
1256
1374
  if (!entries.length) { toast('Type the password first.'); return; }
1257
1375
  post('/api/setup/accounts', { entries: entries }).then(function () {
1258
1376
  pwTyped = {};
1259
- toast('Saved. Running your recordings now - 2-3 minutes.');
1377
+ toast('Saved. Running your recordings now.');
1260
1378
  load().then(function () { runChecks(['regression']); });
1261
1379
  }, function (err) { toast(err.message); });
1262
1380
  });
@@ -2052,7 +2170,10 @@
2052
2170
  load.last = text;
2053
2171
  render(next);
2054
2172
  })
2055
- .catch(function (err) { byId('subline').textContent = 'Could not load: ' + err.message; });
2173
+ .catch(function (err) {
2174
+ if (isNoAnswer(err)) { misses += 1; if (misses >= 2) markStopped(); return; }
2175
+ byId('subline').textContent = 'Could not load: ' + err.message;
2176
+ });
2056
2177
  }
2057
2178
 
2058
2179
  renderAI();
@@ -216,6 +216,11 @@
216
216
 
217
217
  /* --- findings: one row each, a rule down the side ------------------------ */
218
218
  .finding { border-bottom: 1px solid var(--line); }
219
+ /* The medium and low findings, after the serious ones: counted in the summary, opened with one press. */
220
+ .f-more { border-bottom: 1px solid var(--line); }
221
+ .f-more > summary { cursor: pointer; padding: 16px 20px; font-weight: 600; font-size: 14px; color: var(--on-light); background: rgba(18, 22, 29, 0.03); }
222
+ .f-more > summary:hover { color: var(--orange-deep); }
223
+ .f-more[open] > summary { border-bottom: 1px solid var(--line); }
219
224
  .finding.bad { box-shadow: inset 3px 0 0 var(--orange); }
220
225
  .finding.warn { box-shadow: inset 3px 0 0 rgba(18, 22, 29, 0.35); }
221
226
  .finding-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 8px 18px 20px; text-align: left; transition: background 0.3s var(--ease); }
@@ -299,6 +304,10 @@
299
304
  .job-close { margin-left: auto; padding: 4px 10px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; border: 1px solid var(--line-dark); }
300
305
  .job-lines { min-height: 0; max-height: 220px; margin: 12px 0 0; overflow: auto; font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; opacity: 0.85; }
301
306
  .job-result { margin-top: 12px; font-weight: 700; }
307
+ /* Check my app: which step and how long is left; then, while the deeper checks run, that findings can be read. */
308
+ .job-progress { margin-top: 10px; font: 12px var(--mono); letter-spacing: 0.04em; color: var(--on-dark); }
309
+ .job-ready { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--ink); background: #ffd9bf; }
310
+ .job-ready button.go { padding: 6px 12px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-dark); background: var(--ink); border: 0; }
302
311
  .job-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
303
312
  .job-acts button { padding: 6px 12px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-dark); border: 1px solid var(--line-dark); }
304
313
  .job-acts button.go { color: var(--ink); background: var(--on-dark); border-color: var(--on-dark); }
@@ -417,9 +426,20 @@
417
426
  @media (prefers-reduced-motion: reduce) {
418
427
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
419
428
  }
429
+ /* Kryptheon itself has stopped: over everything, the guide included - no button on the page can work meanwhile. */
430
+ .stopped { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 14, 20, 0.72); }
431
+ .stopped[hidden] { display: none; }
432
+ .stopped-card { width: min(560px, 100%); padding: 26px 26px 20px; color: var(--ink); background: var(--white); border-top: 4px solid var(--orange); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45); }
433
+ .stopped-card h2 { margin: 0 0 10px; font-weight: 800; font-stretch: 74%; font-size: 1.6rem; text-transform: uppercase; }
434
+ .stopped-card p, .stopped-card li { font-size: 14px; line-height: 1.55; }
435
+ .stopped-card ul { margin: 10px 0; padding-left: 20px; display: grid; gap: 6px; }
436
+ .stopped-cmd { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 14px; padding: 10px 12px; background: rgba(18, 22, 29, 0.06); }
437
+ .stopped-cmd code { flex: 1 1 260px; min-width: 0; font: 12.5px/1.5 var(--mono); overflow-wrap: anywhere; }
438
+ .stopped-wait { display: flex; align-items: center; gap: 8px; color: var(--orange-deep); font-weight: 600; }
420
439
  </style>
421
440
  </head>
422
441
  <body>
442
+ <div class="stopped" id="stoppedBox" hidden role="alertdialog" aria-live="assertive"></div>
423
443
  <div class="shell">
424
444
  <aside class="side">
425
445
  <div class="brand">
@@ -135,6 +135,57 @@ function clearedBy(root, id, env) {
135
135
  return null;
136
136
  }
137
137
 
138
+ /**
139
+ * The API check's bad-value findings ("took price -1 and saved it", "crashed (500) when name was 3000 characters
140
+ * long") of one route, as one finding: one per field buried the cross-organization and payment holes under fifty
141
+ * lines on a real run (2026-11-21, 119 findings). Every field keeps its line and its proof in the detail, and the
142
+ * one fix prompt names each. A route with one such finding keeps it as it was; nothing of another kind is ever
143
+ * folded in. The headline holds no count, so the finding keeps its id while fields are fixed one by one.
144
+ */
145
+ const BAD_VALUE_KINDS = new Set(['invalid-kept', 'invalid-crash']);
146
+ const SEVERITY_RANK = { 'HIGH CRITICAL': 0, CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3 };
147
+ function groupBadValues(list) {
148
+ const byRoute = new Map();
149
+ for (const f of list) {
150
+ if (!BAD_VALUE_KINDS.has(f.kind)) continue;
151
+ if (!byRoute.has(f.where)) byRoute.set(f.where, []);
152
+ byRoute.get(f.where).push(f);
153
+ }
154
+ const out = [];
155
+ const placed = new Set();
156
+ for (const f of list) {
157
+ const same = BAD_VALUE_KINDS.has(f.kind) ? byRoute.get(f.where) : null;
158
+ if (!same || same.length < 2) { out.push(f); continue; }
159
+ if (placed.has(f.where)) continue;
160
+ placed.add(f.where);
161
+ const severity = same.map((x) => x.severity).sort((a, b) => (SEVERITY_RANK[a] ?? 9) - (SEVERITY_RANK[b] ?? 9))[0];
162
+ const confirmed = same.some((x) => x.status === 'confirmed');
163
+ const fields = Array.from(new Set(same.map((x) => x.field || '?')));
164
+ out.push({
165
+ check: 'api',
166
+ kind: 'invalid-group',
167
+ severity: severity,
168
+ status: confirmed ? 'confirmed' : 'verification required',
169
+ evidence: confirmed ? 'runtime confirmed' : 'seen once',
170
+ confidence: confirmed ? 'high' : 'medium',
171
+ where: f.where,
172
+ headline: f.where + ' takes bad values it should turn away - nothing in the code checks them',
173
+ detail: [same.length + ' tries in ' + fields.length + ' fields (' + fields.join(', ') + '):']
174
+ .concat(same.map((x) => '- ' + x.headline + '\n ' + String(x.detail || '').split('\n').join('\n '))).join('\n'),
175
+ fixPrompt: [
176
+ 'Kryptheon sent bad values to my running app, and ' + f.where + ' did not turn them away:', '',
177
+ same.map((x) => '- ' + x.headline).join('\n'), '',
178
+ 'First check each is real (the app may mean to accept some). For each field that should not take it - ' + fields.join(', ') +
179
+ ' - reject the value where the handler reads it: blank, negative, the wrong type or too long, on the server, with a 400 and a message, before anything is stored. Change nothing else.',
180
+ '', 'Afterwards I will run: npx kryptheon api',
181
+ ].join('\n'),
182
+ when: f.when,
183
+ parts: same.length,
184
+ });
185
+ }
186
+ return out;
187
+ }
188
+
138
189
  /** A time as the dashboard shows it: 13 Oct, 17:20. */
139
190
  function localTime(iso) {
140
191
  const d = new Date(iso);
@@ -345,7 +396,7 @@ function localOrigin(address) {
345
396
  * computer the recordings open. A step marked live opens an address that is
346
397
  * not this computer: it runs only with the person's tick.
347
398
  */
348
- function everythingPlan(checks, app, addresses) {
399
+ function everythingPlan(checks, app, addresses, times) {
349
400
  const by = Object.fromEntries(checks.map((c) => [c.id, c]));
350
401
  const steps = [];
351
402
  const skipped = [];
@@ -388,8 +439,59 @@ function everythingPlan(checks, app, addresses) {
388
439
  lines.push(steps.filter((s) => s.addsData).map((s) => s.label).join(', ') + ' add test data to your app' + (origin && steps.some((s) => s.id === 'api') ? ' (the API step signs in as the accounts whose passwords are in your .env)' : '') + '. Nothing is ever deleted - the test data stays.');
389
440
  lines.push('Where: ' + (where.length ? where.join(', ') : 'your app on this computer') + '. Run it on your own test copy, never on the live app real people use.');
390
441
  }
391
- lines.push('It takes a few minutes. Stop ends it part way; what finished is kept.');
392
- return { steps: steps, skipped: skipped, addsData: addsData, live: live, origin: origin, lines: lines };
442
+ // How long, said as it is: measured on this computer once a run has finished, a guess before that. "A few
443
+ // minutes" was said for years; a real run on a 70-route app took 25 (2026-11-21), and a person who waits
444
+ // twice as long as told closes the window.
445
+ const measured = times || {};
446
+ for (const s of steps) {
447
+ s.deep = DEEP_STEPS.has(s.id);
448
+ s.estimateMs = measured[s.id] || STEP_GUESS_MS[s.id] || 60000;
449
+ }
450
+ const estimateMs = steps.reduce((n, s) => n + s.estimateMs, 0);
451
+ const quick = steps.filter((s) => !s.deep);
452
+ const quickMs = quick.reduce((n, s) => n + s.estimateMs, 0);
453
+ const guessed = steps.some((s) => !measured[s.id]);
454
+ lines.push('About ' + howLong(estimateMs) + (guessed ? ' (a guess - after one run it is measured on this computer)' : '') + '. ' +
455
+ (quick.length && quick.length < steps.length
456
+ ? 'The first findings (' + quick.map((s) => s.label).join(', ') + ') are ready to read after about ' + howLong(quickMs) + '; the deeper checks keep running after them. '
457
+ : '') +
458
+ 'Stop ends it part way; what finished is kept.');
459
+ return { steps: steps, skipped: skipped, addsData: addsData, live: live, origin: origin, lines: lines, estimateMs: estimateMs, quickMs: quickMs };
460
+ }
461
+
462
+ // The steps that replay recordings many times: they run after the others, and each has a time limit.
463
+ const DEEP_STEPS = new Set(['edge', 'reliability', 'roles']);
464
+ // Before anything is measured on this computer. From a real run on a 70-route app (2026-11-21).
465
+ // That run, 22 minutes in all: the first four 7.5, edge 6.5, reliability 4.5, roles 4.
466
+ const STEP_GUESS_MS = { frontend: 20000, backend: 20000, regression: 90000, api: 6 * 60000, edge: 6.5 * 60000, reliability: 4.5 * 60000, roles: 4 * 60000 };
467
+ // A deep step stops here, keeps what it found, and says what was not tried.
468
+ const DEEP_STEP_LIMIT_MS = 8 * 60000;
469
+ const STEP_TIMES_FILE = 'step-times.json';
470
+
471
+ /** "45 s", "4 min", "1 h 10 min". */
472
+ function howLong(ms) {
473
+ const s = Math.max(1, Math.round(ms / 1000));
474
+ if (s < 60) return s + ' s';
475
+ const m = Math.round(s / 60);
476
+ if (m < 60) return m + ' min';
477
+ return Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '');
478
+ }
479
+
480
+ /** How long each step took the last time it finished on this computer: { id: ms }. */
481
+ function readStepTimes(paths) {
482
+ const raw = readJson(path.join(paths.dir, STEP_TIMES_FILE)) || {};
483
+ const out = {};
484
+ for (const k of Object.keys(raw)) if (EVERYTHING_ORDER.includes(k) && Number.isFinite(raw[k]) && raw[k] > 0) out[k] = raw[k];
485
+ return out;
486
+ }
487
+
488
+ /** Kept for the next estimate - only for a step that ran to its end (not stopped, not cut by its limit). */
489
+ function rememberStepTime(root, env, id, ms) {
490
+ if (!EVERYTHING_ORDER.includes(id) || !(ms > 0)) return;
491
+ const paths = store.pathsFor(root, env);
492
+ const times = readStepTimes(paths);
493
+ times[id] = Math.round(ms);
494
+ try { fs.writeFileSync(path.join(paths.dir, STEP_TIMES_FILE), JSON.stringify(times) + '\n', 'utf8'); } catch (err) { /* the guess is used again */ }
393
495
  }
394
496
 
395
497
  // Loaded when it is first needed, so a page that never shows payments never
@@ -793,10 +895,13 @@ function buildState(root, env) {
793
895
  // a re-check that said FIXED after this run: that finding is closed until a later run finds it again
794
896
  const apiFixed = new Set(readHistory(paths.fixes, 500).filter((a) => a && a.check === 'api' && a.verdict === 'fixed' && a.at > (apiLast.checkedAt || ''))
795
897
  .map((a) => a.where + '|' + a.headline));
898
+ const apiFindings = [];
796
899
  for (const f of apiLast.findings || []) {
797
900
  if (apiFixed.has(f.where + '|' + f.headline)) continue;
798
- findings.push({
901
+ apiFindings.push({
799
902
  check: 'api',
903
+ kind: f.kind,
904
+ field: f.field,
800
905
  severity: f.severity,
801
906
  status: f.status,
802
907
  evidence: f.status === 'confirmed' ? 'runtime confirmed' : 'seen once',
@@ -808,6 +913,7 @@ function buildState(root, env) {
808
913
  when: apiLast.checkedAt,
809
914
  });
810
915
  }
916
+ for (const f of groupBadValues(apiFindings)) findings.push(f);
811
917
  }
812
918
 
813
919
  // Input and edge cases, and reliability: the last press of each one's
@@ -1089,7 +1195,7 @@ function buildState(root, env) {
1089
1195
  },
1090
1196
  next: nextAction(findings, steps),
1091
1197
  // What "Check my app" runs with one press, and what it leaves out.
1092
- everything: everythingPlan(checks, { address: readAppAddress(paths), webOnly: webOnly }, recordings ? probeAsk(root, '', env).addresses : []),
1198
+ everything: everythingPlan(checks, { address: readAppAddress(paths), webOnly: webOnly }, recordings ? probeAsk(root, '', env).addresses : [], readStepTimes(paths)),
1093
1199
  baselines: Object.keys(baselines).length,
1094
1200
  changes: recentChanges(root),
1095
1201
  // Part 3 is where a version gets verified. Until then this says so,
@@ -1291,6 +1397,8 @@ function createJobs() {
1291
1397
  id: job.id, kind: job.kind, title: job.title, command: job.command,
1292
1398
  startedAt: job.startedAt, endedAt: job.endedAt, running: job.running,
1293
1399
  lines: job.lines.slice(), result: job.result,
1400
+ // Check my app: which step, how long is left, and whether the first findings are ready to read.
1401
+ progress: job.progress || null,
1294
1402
  // A run that can be ended part way says so, and the page shows Stop.
1295
1403
  stoppable: Boolean(job.running && job.stopper), stopping: Boolean(job.stopping),
1296
1404
  };
@@ -1326,7 +1434,7 @@ function createJobs() {
1326
1434
  secrets = null;
1327
1435
  };
1328
1436
  Promise.resolve()
1329
- .then(() => work(say, { onStop: (fn) => (job.stopper = fn) }))
1437
+ .then(() => work(say, { onStop: (fn) => (job.stopper = fn), progress: (p) => { if (job.running) job.progress = p; } }))
1330
1438
  .then(finish, (err) => finish({ ok: false, why: err && err.message ? err.message : String(err) }));
1331
1439
  return view(job);
1332
1440
  },
@@ -1698,6 +1806,10 @@ module.exports = {
1698
1806
  tenantRoutesLines: tenantRoutesLines,
1699
1807
  CHECKS: CHECKS,
1700
1808
  everythingPlan: everythingPlan,
1809
+ howLong: howLong,
1810
+ readStepTimes: readStepTimes,
1811
+ rememberStepTime: rememberStepTime,
1812
+ DEEP_STEP_LIMIT_MS: DEEP_STEP_LIMIT_MS,
1701
1813
  localOrigin: localOrigin,
1702
1814
  buildState: buildState,
1703
1815
  clearedBy: clearedBy,
package/kryptheon-tour.js CHANGED
@@ -14,6 +14,7 @@
14
14
  var KEY = 'kryptheon.guide.v1';
15
15
  var state = null;
16
16
  var busy = false;
17
+ var quickDone = false; // Check my app is still running, and its first findings are ready to read
17
18
  var on = false;
18
19
  var at = null;
19
20
  var seen = {};
@@ -135,6 +136,13 @@
135
136
  function recordings() { var s = recordStep(); return s ? (s.count || (s.state === 'done' ? 1 : 0)) : 0; }
136
137
  function hasAddress() { return !!(state && state.app && state.app.address); }
137
138
  function findings() { return (state && state.findings) || []; }
139
+ // "4 minutes": when Check my app's first findings come, from the plan's estimate (measured once it has run)
140
+ function firstFindingsIn() {
141
+ var ms = state && state.everything && state.everything.quickMs;
142
+ if (!ms) return '';
143
+ var m = Math.max(1, Math.round(ms / 60000));
144
+ return m === 1 ? '1 minute' : m + ' minutes';
145
+ }
138
146
  function needsPassword() { return !!(state && state.passwordsNeeded && state.passwordsNeeded.length); }
139
147
  function needsConnect() {
140
148
  var f = findings()[0];
@@ -243,7 +251,7 @@
243
251
  show: function (c) {
244
252
  if (busy) {
245
253
  title(c, 'Running ', 'your recordings', '');
246
- c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
254
+ c.appendChild(el('p', 'kt-red', 'Please wait - your recordings are replaying. Keep this page and the black window open.'));
247
255
  waiting(c, 'Running');
248
256
  return;
249
257
  }
@@ -268,7 +276,8 @@
268
276
  return;
269
277
  }
270
278
  title(c, n === 1 ? 'Your ' : 'Your ', n + (n === 1 ? ' finding' : ' findings'), '');
271
- c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The most serious is at the top. Open one to read what went wrong.'));
279
+ c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The serious ones are at the top; the rest are in More to check below them. Open one to read what went wrong.'));
280
+ if (busy) c.appendChild(el('p', null, 'The deeper checks are still running - more findings may appear here while you read.'));
272
281
  row(c, [go('Next', function () { move('fix'); })]);
273
282
  },
274
283
  },
@@ -355,8 +364,8 @@
355
364
  show: function (c) {
356
365
  if (busy) {
357
366
  title(c, 'Checking ', 'your app', '');
358
- c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
359
- c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here.'));
367
+ c.appendChild(el('p', 'kt-red', 'Please wait' + (firstFindingsIn() ? ' - the first findings come in about ' + firstFindingsIn() : '') + '. Keep this page and the black window open.'));
368
+ c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here - and how long is left. The guide moves on as soon as the first findings are ready; the deeper checks keep running after.'));
360
369
  waiting(c, 'Running');
361
370
  return;
362
371
  }
@@ -370,7 +379,9 @@
370
379
  c.appendChild(el('p', null, text));
371
380
  waiting(c, 'Waiting for you to press it');
372
381
  },
373
- done: function () { return seen.ran && !busy; },
382
+ // done when the run ends - or, for Check my app, once its first findings are ready: nobody should sit through
383
+ // the deeper checks before they can read anything
384
+ done: function () { return seen.ran && (!busy || quickDone); },
374
385
  next: next,
375
386
  };
376
387
  }
@@ -637,7 +648,7 @@
637
648
  function signature() {
638
649
  return [at, busy, Date.now() - stepSince > STUCK_MS, seen.connectWhy || '', visible(byId('everyBox')), hasAddress(), recordings(), findings().length, seen.pressed, needsConnect(), connected(),
639
650
  !!((q('#accountBox input') || {}).value),
640
- state && state.autostart && state.autostart.on, state && state.daily && state.daily.on, needsPassword()].join('|');
651
+ state && state.autostart && state.autostart.on, state && state.daily && state.daily.on, needsPassword(), quickDone].join('|');
641
652
  }
642
653
 
643
654
  function move(id, back) {
@@ -696,6 +707,7 @@
696
707
  window.addEventListener('kryptheon:state', function (e) {
697
708
  state = (e.detail && e.detail.state) || state;
698
709
  busy = !!(e.detail && e.detail.busy);
710
+ quickDone = !!(e.detail && e.detail.quickDone);
699
711
  if (!state) return;
700
712
  if (!guideBtn && byId('runAll')) {
701
713
  guideBtn = el('button', 'btn kt-guide-btn', 'Guide me');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kryptheon",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "description": "Record what you do in your app and get plain-language reports when it breaks.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",
@@ -75,7 +75,7 @@
75
75
  "pg": "^8.23.0"
76
76
  },
77
77
  "scripts": {
78
- "check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-tour.check.js && node kryptheon-upgrade.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-pwbox.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
78
+ "check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-tour.check.js && node kryptheon-upgrade.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-pwbox.check.js && node kryptheon-quiet.check.js && node kryptheon-speed.check.js && node kryptheon-stopped.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
79
79
  "check:store": "node kryptheon-store.check.js",
80
80
  "check:code": "node kryptheon-code.check.js",
81
81
  "check:constdata": "node kryptheon-constdata.check.js",