loopengine 0.4.8 → 0.4.9

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.
@@ -209,6 +209,9 @@ export const agentsConfigPageHtml = `<!doctype html>
209
209
  .wf-crit-kind { font-size: 12px; color: var(--ink-muted); }
210
210
  .wf-crit-rate { font-variant-numeric: tabular-nums; }
211
211
  .wf-case-standins { margin: 0; font-size: 12.5px; color: var(--ink-muted); }
212
+ .wf-panel { min-width: 0; }
213
+ .wf-run-lines, .wf-cand-list, .wf-change-list { min-width: 0; }
214
+ .wf-run-line, .wf-run-link { min-width: 0; overflow: hidden; }
212
215
  .wf-run-lines, .wf-cand-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
213
216
  .wf-run-line, .wf-cand-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; }
214
217
  .wf-run-line:first-child, .wf-cand-list li:first-child { border-top: 0; }
@@ -228,8 +231,16 @@ export const agentsConfigPageHtml = `<!doctype html>
228
231
  .wf-health-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
229
232
  .wf-health-table th { text-align: left; font-weight: 600; color: var(--ink-muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
230
233
  .wf-health-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
231
- .wf-audit-link { font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; margin-right: 8px; }
232
- .wf-audit-link:hover { background: var(--surface); }
234
+ .wf-audit-summary ul.wf-audit-lines { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13.5px; line-height: 1.5; }
235
+ .wf-audit-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
236
+ .wf-audit-tools a { font-size: 13px; font-weight: 600; color: var(--accent-ink); text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; }
237
+ .wf-audit-tools a.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
238
+ .wf-health-more summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent-ink); }
239
+ .wf-health-more .wf-health-table { margin-top: 8px; }
240
+ .wf-sub-sub { font-size: 12px; font-weight: 700; color: var(--ink-muted); margin-top: 6px; }
241
+ .wf-eval-last { margin: 0; font-size: 13px; }
242
+ .wf-eval-details { display: inline; }
243
+ .wf-eval-details summary { display: inline; cursor: pointer; color: var(--accent-ink); font-size: 12.5px; }
233
244
  .chg { display: grid; gap: 6px; margin-top: 4px; font-size: 12.5px; flex-basis: 100%; }
234
245
  .chg-field del { color: var(--bad); }
235
246
  .chg-field ins { color: var(--good); text-decoration: none; }
@@ -971,7 +982,9 @@ ${renderMarkdownScript}
971
982
  // header and list. Every link to a workflow lands here.
972
983
  var pageParams = new URLSearchParams(location.search);
973
984
  var workflowPageId = pageParams.get('tab') === 'workflows' && pageParams.get('workflow') || null;
974
- if (workflowPageId && pageParams.get('wtab')) workflowTabs[workflowPageId] = pageParams.get('wtab');
985
+ // Evidence and Changes became Audit and Improve: old links still open.
986
+ var OLD_TABS = { evidence: 'audit', changes: 'audit' };
987
+ if (workflowPageId && pageParams.get('wtab')) workflowTabs[workflowPageId] = OLD_TABS[pageParams.get('wtab')] || pageParams.get('wtab');
975
988
  // A case's page, with a back link to here.
976
989
  function caseHref(runId) {
977
990
  return '/cases/' + encodeURIComponent(runId) + '?back=' + encodeURIComponent(location.pathname + location.search);
@@ -1065,7 +1078,6 @@ ${renderMarkdownScript}
1065
1078
  for (var i = 0; i < tabs.length; i++) tabs[i].setAttribute('aria-selected', String(tabs[i].dataset.tab === key));
1066
1079
  var panels = card.querySelectorAll('.wf-panel');
1067
1080
  for (var j = 0; j < panels.length; j++) panels[j].hidden = panels[j].dataset.panel !== key;
1068
- if (key === 'changes') loadWorkflowChanges(card);
1069
1081
  }
1070
1082
 
1071
1083
  // The Health panel: the last 30 days of runs, as totals, day by day and
@@ -1075,7 +1087,7 @@ ${renderMarkdownScript}
1075
1087
  if (!box) return;
1076
1088
  fetch(base + '/health', { headers: { accept: 'application/json' } })
1077
1089
  .then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
1078
- .then(function (h) { box.innerHTML = '<h4 class="wf-sub">Health, last ' + h.days + ' days</h4>' + workflowHealthHtml(h); })
1090
+ .then(function (h) { box.innerHTML = '<h4 class="wf-sub">At a glance</h4>' + workflowHealthHtml(h); })
1079
1091
  .catch(function (err) { box.innerHTML = '<h4 class="wf-sub">Health</h4><p class="error">Could not load it: ' + escapeHtml(err.message) + '</p>'; });
1080
1092
  }
1081
1093
 
@@ -1121,26 +1133,36 @@ ${renderMarkdownScript}
1121
1133
  '</div>';
1122
1134
  var rows = h.versions.map(function (v) {
1123
1135
  var d = v.approved + v.denied;
1124
- return '<tr><td>' + (v.version == null ? '<span class="hint">before versions</span>' : 'v' + v.version) + '</td><td>' + v.runs + '</td><td>' + healthPct(v.failed, v.finished) + '</td><td>' + healthPct(v.approved, d) + '</td><td>' + healthPct(v.changed + v.denied, d) + '</td>' +
1136
+ return '<tr><td>' + (v.version == null ? '<span class="hint">before versions</span>' : 'Version ' + v.version) + '</td><td>' + v.runs + '</td><td>' + healthPct(v.failed, v.finished) + '</td><td>' + healthPct(v.approved, d) + '</td><td>' + healthPct(v.changed + v.denied, d) + '</td>' +
1125
1137
  '<td>' + (v.runs ? (v.questions / v.runs).toFixed(1) : '0') + '</td><td>' + (v.feedback ? healthPct(v.unedited, v.feedback) : String.fromCharCode(8212)) + '</td><td>' + healthTime(v.medianMs) + '</td><td>' + healthCost(v.costPerRunUsd) + '</td></tr>';
1126
1138
  }).join('');
1127
1139
  return alerts + stats + healthChartHtml(h.daily) +
1128
- '<div class="wf-health-table"><table><thead><tr><th>Brief</th><th>Runs</th><th>Failed</th><th>Approved</th><th>Changed or denied</th><th>Questions per run</th><th>Used unedited</th><th>Time</th><th>Cost per run</th></tr></thead><tbody>' + rows + '</tbody></table></div>';
1140
+ '<details class="wf-health-more"><summary>By version of its instructions</summary><div class="wf-health-table"><table><thead><tr><th>Version</th><th>Runs</th><th>Failed</th><th>Approved</th><th>Changed or denied</th><th>Questions per run</th><th>Used unedited</th><th>Time</th><th>Cost per run</th></tr></thead><tbody>' + rows + '</tbody></table></div></details>';
1129
1141
  }
1130
1142
 
1131
- // The Changes tab: every change to this workflow's settings, and every
1132
- // decision, answer and feedback in its runs, newest first, with who.
1133
- function loadWorkflowChanges(card) {
1134
- var box = card.querySelector('.wf-changes');
1135
- if (!box || box.getAttribute('data-loaded') === '1') return;
1136
- box.setAttribute('data-loaded', '1');
1137
- var agent = pageParams.get('agent');
1138
- fetch('/audit?agent=' + encodeURIComponent(agent) + '&workflow=' + encodeURIComponent(card.dataset.workflow) + '&limit=200', { headers: { accept: 'application/json' } })
1143
+ // The Audit tab's summary: the workflow's last 30 days in sentences, the
1144
+ // same as the Audit page's.
1145
+ function loadAuditSummary(card, base) {
1146
+ var box = card.querySelector('.wf-audit-summary');
1147
+ if (!box) return;
1148
+ fetch(base + '/audit', { headers: { accept: 'application/json' } })
1139
1149
  .then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
1140
- .then(function (data) { box.innerHTML = workflowChangesHtml(data.events || []); })
1141
- .catch(function (err) { box.setAttribute('data-loaded', '0'); box.innerHTML = '<p class="error">Could not load the changes: ' + escapeHtml(err.message) + '</p>'; });
1150
+ .then(function (a) { box.innerHTML = '<h4 class="wf-sub">In the last 30 days</h4><ul class="wf-audit-lines">' + a.summary.map(function (line) { return '<li>' + escapeHtml(line) + '</li>'; }).join('') + '</ul>'; })
1151
+ .catch(function (err) { box.innerHTML = '<p class="error">Could not load its summary: ' + escapeHtml(err.message) + '</p>'; });
1142
1152
  }
1143
1153
 
1154
+ // The Audit tab's latest few settings changes, with what changed.
1155
+ function loadLatestChanges(card, name) {
1156
+ var box = card.querySelector('.wf-changes-latest');
1157
+ if (!box) return;
1158
+ fetch('/audit?agent=' + encodeURIComponent(name) + '&workflow=' + encodeURIComponent(card.dataset.workflow) + '&kind=change&limit=3', { headers: { accept: 'application/json' } })
1159
+ .then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
1160
+ .then(function (data) { box.innerHTML = (data.events || []).length ? workflowChangesHtml(data.events) : '<p class="hint" style="margin:0">No settings changed yet.</p>'; })
1161
+ .catch(function (err) { box.innerHTML = '<p class="error">Could not load its changes: ' + escapeHtml(err.message) + '</p>'; });
1162
+ }
1163
+
1164
+ // A list of changes (and decisions): every change to this workflow's settings, and every
1165
+ // decision, answer and feedback in its runs, newest first, with who.
1144
1166
  function changeText(e) {
1145
1167
  var d = e.data || {};
1146
1168
  if (e.kind === 'change') return escapeHtml(d.label || 'Changed a setting');
@@ -1349,10 +1371,6 @@ ${renderMarkdownScript}
1349
1371
  (w.originalRequest ? '<details class="wf-original"><summary>Original message</summary><div class="workflow-steps-text">' + escapeHtml(w.originalRequest) + '</div></details>' : '');
1350
1372
  }
1351
1373
 
1352
- function scoreTileHtml(label, value, detail) {
1353
- return '<div class="wf-score"><span class="wf-score-k">' + label + '</span><strong class="wf-score-v">' + value + '</strong>' + (detail ? '<span class="hint">' + detail + '</span>' : '') + '</div>';
1354
- }
1355
-
1356
1374
  // A criterion's kind, in words, for its row and its editor.
1357
1375
  var CRIT_KINDS = [
1358
1376
  ['judge', 'Judge decides'],
@@ -1363,6 +1381,7 @@ ${renderMarkdownScript}
1363
1381
  ['reference', 'Matches the good result'],
1364
1382
  ];
1365
1383
  function critKindText(c) {
1384
+ if (c.kind === 'reference') return 'Checked against each eval case' + RSQ + 's saved good result';
1366
1385
  var label = (CRIT_KINDS.filter(function (k) { return k[0] === c.kind; })[0] || CRIT_KINDS[0])[1];
1367
1386
  return c.value ? label + ' ' + String.fromCharCode(8220) + c.value + String.fromCharCode(8221) : label;
1368
1387
  }
@@ -1376,23 +1395,26 @@ ${renderMarkdownScript}
1376
1395
  }
1377
1396
  var REFERENCE_CRIT = { id: 'reference', text: 'Matches the good result: the same facts and decisions', kind: 'reference' };
1378
1397
 
1379
- function workflowEvidenceHtml(w, runsHtml) {
1380
- var s = w.scores || { runs: 0, done: 0, failed: 0, approvals: { approved: 0, refused: 0 }, feedback: { count: 0, good: 0, bad: 0, edits: { none: 0, light: 0, heavy: 0 } } };
1398
+ // The Audit tab: what happened and whether it can be trusted. The same
1399
+ // summary as the Audit page's, its health over 30 days, its latest runs
1400
+ // and changes, and the way to the report and the full log.
1401
+ function workflowAuditHtml(w, runsHtml, name) {
1402
+ var auditHref = '/audit?agent=' + encodeURIComponent(name) + '&workflow=' + encodeURIComponent(w.id);
1403
+ return (workflowPageId ? '<section class="wf-audit-summary"><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></section>' : '') +
1404
+ (workflowPageId ? '<section class="wf-health"><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></section>' : '') +
1405
+ '<h4 class="wf-sub">Latest runs</h4>' +
1406
+ (runsHtml ? '<ul class="wf-run-lines">' + runsHtml + '</ul>' : '<p class="hint" style="margin:0">No runs yet.</p>') +
1407
+ (workflowPageId ? '<h4 class="wf-sub">Latest changes</h4><div class="wf-changes-latest"><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></div>' : '') +
1408
+ (workflowPageId ? '<div class="wf-audit-tools"><a class="primary" href="/agents/' + encodeURIComponent(name) + '/workflows/' + encodeURIComponent(w.id) + '/audit/report">Open the report</a><a href="' + auditHref + '">See everything in Audit ' + String.fromCharCode(8594) + '</a></div>' : '');
1409
+ }
1410
+
1411
+ // The Improve tab: the checklist, the eval cases (suggested from real
1412
+ // runs, and saved), and Evaluate.
1413
+ function workflowImproveHtml(w) {
1381
1414
  var evals = w.evals || { cases: [], criteria: [], rounds: [] };
1382
1415
  var criteria = evals.criteria && evals.criteria.length ? evals.criteria : [REFERENCE_CRIT];
1383
1416
  var round = evals.rounds[0];
1384
1417
  var checked = round && round.passRates;
1385
- var decided = s.approvals.approved + s.approvals.refused;
1386
- var f = s.feedback;
1387
- var evalsValue = !round ? String.fromCharCode(8212) : checked ? round.allPassed + ' / ' + round.cases.length : typeof round.average === 'number' ? round.average.toFixed(1) + ' / 5' : String.fromCharCode(8212);
1388
- var evalsDetail = !round ? (evals.cases.length ? 'not run yet' : 'no cases yet') : (checked ? 'passed every check' + DOT : '') + new Date(round.at).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
1389
- var tiles = '<div class="wf-scores">' +
1390
- scoreTileHtml('Runs', String(s.runs), s.runs ? s.done + ' done' + DOT + s.failed + ' failed' : 'none yet') +
1391
- scoreTileHtml('Approvals', decided ? Math.round(100 * s.approvals.approved / decided) + '%' : String.fromCharCode(8212), decided ? s.approvals.approved + ' approved' + DOT + s.approvals.refused + ' refused' : 'none asked yet') +
1392
- scoreTileHtml('Feedback', f.count ? String(f.count) : String.fromCharCode(8212), f.count ? (f.good + f.bad ? f.good + ' good' + DOT + f.bad + ' bad' + DOT : '') + f.edits.none + ' unedited' + DOT + f.edits.light + ' light' + DOT + f.edits.heavy + ' heavy edits' : 'none reported yet') +
1393
- scoreTileHtml('Evals', evalsValue, evalsDetail) +
1394
- '</div>';
1395
- var feedbackHint = f.count ? '' : '<p class="hint" style="margin:0">An app reports what happened to a result with <code>POST /agents/' + escapeHtml(currentName || '') + '/runs/&lt;runId&gt;/feedback</code> and <code>{"final": "the text it sent"}</code> or <code>{"verdict": "good"}</code>.</p>';
1396
1418
  // Each criterion, with how often the latest round passed it.
1397
1419
  var rateOf = {};
1398
1420
  (checked ? round.passRates : []).forEach(function (r) { rateOf[r.criterionId] = r; });
@@ -1401,16 +1423,16 @@ ${renderMarkdownScript}
1401
1423
  var pill = !r || !r.total ? '' : '<span class="le-pill ' + (r.passed === r.total ? 'good' : r.passed * 2 >= r.total ? 'ask' : 'bad') + ' wf-crit-rate">' + r.passed + ' / ' + r.total + '</span>';
1402
1424
  return '<li class="wf-crit"><span><strong>' + escapeHtml(c.text) + '</strong><br><span class="wf-crit-kind">' + escapeHtml(critKindText(c)) + '</span></span>' + pill + '</li>';
1403
1425
  }).join('');
1404
- var critSection = '<h4 class="wf-sub">Criteria</h4>' +
1426
+ var critSection = '<h4 class="wf-sub">Checklist</h4>' +
1405
1427
  '<p class="hint" style="margin:0">' + (evals.criteria && evals.criteria.length
1406
- ? 'Every result is checked on each of these, yes or no. Exact text and tool checks are checked directly; the rest by a judge model from another provider.'
1407
- : 'No criteria yet, so each result is only compared with its case' + RSQ + 's good result. Add the checks that matter, or draft them from the brief.') + '</p>' +
1428
+ ? 'What every good result must get right. Each eval case is checked against every item, yes or no.'
1429
+ : 'What every good result must get right. Nothing on it yet, so each eval case is only compared with its good result. Add the items that matter, or have them suggested from its instructions.') + '</p>' +
1408
1430
  '<ul class="wf-crits">' + critList + '</ul>' +
1409
- '<div class="wf-crit-bar"><button type="button" class="wf-crit-edit">' + (evals.criteria && evals.criteria.length ? 'Edit criteria' : 'Add criteria') + '</button></div>' +
1431
+ '<div class="wf-crit-bar"><button type="button" class="wf-crit-edit">' + (evals.criteria && evals.criteria.length ? 'Edit the checklist' : 'Add to the checklist') + '</button></div>' +
1410
1432
  '<div class="wf-crit-form" hidden>' +
1411
1433
  '<div class="wf-crit-rows">' + (evals.criteria && evals.criteria.length ? evals.criteria : []).map(critRowHtml).join('') + '</div>' +
1412
- '<div class="wf-crit-bar"><button type="button" class="plain wf-crit-add">+ Add a check</button><button type="button" class="plain wf-crit-draft">Draft from the brief</button>' +
1413
- '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save criteria</button></div>' +
1434
+ '<div class="wf-crit-bar"><button type="button" class="plain wf-crit-add">+ Add an item</button><button type="button" class="plain wf-crit-draft">Suggest from its instructions</button>' +
1435
+ '<span style="flex:1"></span><button type="button" class="plain wf-crit-cancel">Cancel</button><button type="button" class="wf-crit-save">Save the checklist</button></div>' +
1414
1436
  '<span class="hint wf-crit-status"></span>' +
1415
1437
  '</div>';
1416
1438
  var latest = {};
@@ -1423,7 +1445,7 @@ ${renderMarkdownScript}
1423
1445
  var values = Object.keys(c.params || {}).map(function (k) { var v = String(c.params[k]); return escapeHtml(k) + ': ' + escapeHtml(v.length > 60 ? v.slice(0, 60) + String.fromCharCode(8230) : v); }).join(DOT);
1424
1446
  var fails = last && last.checks ? last.checks.filter(function (x) { return !x.pass; }) : [];
1425
1447
  var pill = !last ? ''
1426
- : last.checks ? (fails.length ? '<span class="le-pill bad">' + fails.length + ' of ' + last.checks.length + ' checks failed</span>' : '<span class="le-pill good">All ' + last.checks.length + ' checks passed</span>')
1448
+ : last.checks ? (fails.length ? '<span class="le-pill bad">' + fails.length + ' of ' + last.checks.length + ' items missed</span>' : '<span class="le-pill good">Passed all ' + last.checks.length + '</span>')
1427
1449
  : typeof last.score === 'number' ? '<span class="le-pill ' + (last.score >= 4 ? 'good' : last.score === 3 ? 'ask' : 'bad') + '">' + last.score + ' / 5</span>' : '<span class="le-pill bad">Not scored</span>';
1428
1450
  var why = !last ? ''
1429
1451
  : last.checks ? (fails.length ? '<ul class="wf-case-fails">' + fails.map(function (x) { return '<li><strong>' + escapeHtml(critName[x.criterionId] || x.criterionId) + '</strong>' + (x.reason ? ': ' + escapeHtml(x.reason) : '') + '</li>'; }).join('') + '</ul>' : '')
@@ -1444,17 +1466,18 @@ ${renderMarkdownScript}
1444
1466
  (last && last.result ? '<div class="workflow-run-entry-label">Latest result' + (last.tools && last.tools.length ? ' <span class="hint">(called ' + escapeHtml(last.tools.join(', ')) + ')</span>' : '') + '</div><div class="workflow-steps-text">' + escapeHtml(last.result) + '</div>' : '') +
1445
1467
  '</details></li>';
1446
1468
  }).join('');
1447
- // On the workflow's page: its health, filled by loadWorkflowHealth.
1448
- return (workflowPageId ? '<section class="wf-health"><h4 class="wf-sub">Health, last 30 days</h4><p class="hint" style="margin:0">Loading' + String.fromCharCode(8230) + '</p></section>' : '') +
1449
- tiles + feedbackHint + critSection +
1450
- '<h4 class="wf-sub">Eval cases</h4>' +
1451
- '<div class="wf-evals-bar"><button type="button" class="wf-evals-run"' + (!evals.cases.length || running ? ' disabled' : '') + '>' + (running ? 'Running ' + running.done + ' of ' + running.total + String.fromCharCode(8230) : 'Run evals') + '</button>' +
1452
- '<span class="hint">' + (round ? 'Last run ' + escapeHtml(new Date(round.at).toLocaleString()) + (round.briefVersion ? DOT + 'brief v' + round.briefVersion : '') + DOT + 'model ' + escapeHtml(round.model) + DOT + 'judged by ' + escapeHtml(round.judge) : 'A test run: only tools that just read data run. Anything that would send, write or change something, or need approval, isn' + RSQ + 't done, and nobody is asked anything.') + '</span></div>' +
1453
- (cases ? '<ul class="wf-cases">' + cases + '</ul>' : '<p class="hint" style="margin:0">No cases yet. Save runs worth testing (below) as cases, then run them after each change to the brief or model.</p>') +
1454
- (workflowPageId ? '<h4 class="wf-sub">Worth testing</h4><div class="wf-candidates"><p class="hint" style="margin:0">Looking through its runs' + String.fromCharCode(8230) + '</p></div>' : '') +
1455
- '<h4 class="wf-sub">Recent runs</h4>' +
1456
- (runsHtml ? '<ul class="wf-run-lines">' + runsHtml + '</ul>' : '<p class="hint" style="margin:0">No runs yet.</p>') +
1457
- (workflowPageId ? '<p class="hint" style="margin:0"><a href="/audit?tab=cases&agent=' + encodeURIComponent(pageParams.get('agent') || '') + '&workflow=' + encodeURIComponent(w.id) + '">See all its runs in Audit ' + String.fromCharCode(8594) + '</a></p>' : '');
1469
+ var lastLine = !round ? ''
1470
+ : '<p class="wf-eval-last"><strong>Last evaluation: ' + escapeHtml(new Date(round.at).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + (round.briefVersion ? ', version ' + round.briefVersion + ' of its instructions' : '') + '</strong>' +
1471
+ (checked ? String.fromCharCode(8212) + ' ' + round.allPassed + ' of ' + round.cases.length + ' cases passed every checklist item.' : '') +
1472
+ ' <details class="wf-eval-details"><summary>Details</summary>Ran with ' + escapeHtml(round.model) + DOT + 'judged by ' + escapeHtml(round.judge) + DOT + escapeHtml(new Date(round.at).toLocaleString()) + '</details></p>';
1473
+ return critSection +
1474
+ '<h4 class="wf-sub">Eval cases' + (evals.cases.length ? ' (' + evals.cases.length + ')' : '') + '</h4>' +
1475
+ '<p class="hint" style="margin:0">Real runs saved to check every change against.</p>' +
1476
+ (workflowPageId ? '<div class="wf-sub-sub">Suggested from real runs</div><div class="wf-candidates"><p class="hint" style="margin:0">Looking through its runs' + String.fromCharCode(8230) + '</p></div>' : '') +
1477
+ (cases ? '<div class="wf-sub-sub">Saved</div><ul class="wf-cases">' + cases + '</ul>' : '<p class="hint" style="margin:0">None saved yet: add suggested ones above, or save any run from its case page.</p>') +
1478
+ '<div class="wf-evals-bar"><button type="button" class="wf-evals-run"' + (!evals.cases.length || running ? ' disabled' : '') + '>' + (running ? 'Evaluating ' + running.done + ' of ' + running.total + String.fromCharCode(8230) : 'Evaluate') + '</button>' +
1479
+ '<span class="hint">Runs every eval case again with the current instructions and checks each result against the checklist. Nothing is sent, refunded or submitted.</span></div>' +
1480
+ lastLine;
1458
1481
  }
1459
1482
 
1460
1483
  // Worth testing: runs from the last 30 days that would make good eval
@@ -1489,7 +1512,7 @@ ${renderMarkdownScript}
1489
1512
  }
1490
1513
  if ((r.decisions || []).length) parts.push('<span class="hint">' + r.decisions.map(function (d) { return escapeHtml(d.tool) + (d.approved ? ' approved' : ' refused'); }).join(DOT) + '</span>');
1491
1514
  var saved = ((w.evals && w.evals.cases) || []).some(function (c) { return c.fromRun === r.run_id; });
1492
- if (r.status === 'done' && r.result) parts.push(saved ? '<span class="hint">Saved as an eval case</span>' : '<button type="button" class="wf-link wf-save-case" data-run="' + escapeHtml(r.run_id) + '">Save as eval case</button>');
1515
+ if (saved) parts.push('<span class="hint">An eval case</span>');
1493
1516
  return parts.length ? '<div class="wf-run-evidence">' + parts.join('') + '</div>' : '';
1494
1517
  }
1495
1518
 
@@ -1543,7 +1566,7 @@ ${renderMarkdownScript}
1543
1566
  '<div class="wf-page-crumb-row"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">&#9776;</button>' +
1544
1567
  '<a class="wf-page-crumb" href="/agents/config?agent=' + encodeURIComponent(name) + '&tab=workflows">' + String.fromCharCode(8592) + ' ' + escapeHtml(agentLabel) + ' ' + String.fromCharCode(183) + ' Workflows</a></div>' +
1545
1568
  '<div class="wf-page-title-row"><h1>' + escapeHtml(w.title) + '</h1>' +
1546
- '<span class="wf-row-actions"><a class="wf-audit-link" href="/audit?agent=' + encodeURIComponent(name) + '&workflow=' + encodeURIComponent(w.id) + '">Audit</a><button type="button" class="workflow-edit">Edit</button></span></div>' +
1569
+ '<span class="wf-row-actions"><button type="button" class="workflow-edit">Edit</button></span></div>' +
1547
1570
  (w.description && w.description !== w.title ? '<p class="wf-page-desc">' + escapeHtml(w.description) + '</p>' : '') +
1548
1571
  '<div class="wf-page-meta">' +
1549
1572
  '<span class="wf-page-meta-item"><span class="wf-page-meta-k">Agent</span><a href="/agents/config?agent=' + encodeURIComponent(name) + '">' + escapeHtml(agentLabel) + '</a></span>' +
@@ -1553,13 +1576,13 @@ ${renderMarkdownScript}
1553
1576
  '</div>' +
1554
1577
  '</header>' +
1555
1578
  '<div class="wf-row-body wf-page-body">' +
1556
- '<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('evidence', 'Evidence' + (runs ? ' <span class="wf-tab-count">' + w.recentRuns.length + '</span>' : '')) + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messages') + tabBtn('contract', 'Contract') + tabBtn('changes', 'Changes') + '</div>' +
1579
+ '<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('audit', 'Audit') + tabBtn('improve', 'Improve') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messages') + tabBtn('contract', 'Contract') + '</div>' +
1557
1580
  panel('brief', workflowBriefHtml(w)) +
1558
- panel('evidence', workflowEvidenceHtml(w, runs)) +
1581
+ panel('audit', workflowAuditHtml(w, runs, name)) +
1582
+ panel('improve', workflowImproveHtml(w)) +
1559
1583
  panel('triggers', workflowTriggersHtml(w, name, params)) +
1560
1584
  panel('messages', workflowMessagesHtml(w, name)) +
1561
1585
  panel('contract', workflowContractHtml(w, name, params)) +
1562
- panel('changes', '<div class="wf-changes"><span class="hint">Loading' + String.fromCharCode(8230) + '</span></div>') +
1563
1586
  '<div class="hint workflow-result"></div>' +
1564
1587
  '<div class="wf-row-foot"><span class="hint">ID <code>' + escapeHtml(w.id) + '</code>, used by the API, schedules and webhooks</span><button type="button" class="wf-remove workflow-forget" title="Its schedules and webhooks go; its instructions stay as a skill for Chat">Remove</button></div>' +
1565
1588
  '</div>' +
@@ -1578,12 +1601,13 @@ ${renderMarkdownScript}
1578
1601
  '<div class="wf-row-body"' + (open ? '' : ' hidden') + '>' +
1579
1602
  // What it does, in full, once it's open (the row shows just its name).
1580
1603
  (w.description && w.description !== w.title ? '<p class="wf-desc">' + escapeHtml(w.description) + '</p>' : '') +
1581
- '<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('contract', 'Contract') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messages') + tabBtn('evidence', 'Evidence' + (runs ? ' <span class="wf-tab-count">' + w.recentRuns.length + '</span>' : '')) + '</div>' +
1604
+ '<div class="wf-tabs" role="tablist">' + tabBtn('brief', 'Brief') + tabBtn('audit', 'Audit') + tabBtn('improve', 'Improve') + tabBtn('contract', 'Contract') + tabBtn('triggers', 'Triggers') + tabBtn('messages', 'Messages') + '</div>' +
1582
1605
  panel('contract', workflowContractHtml(w, name, params)) +
1583
1606
  panel('triggers', workflowTriggersHtml(w, name, params)) +
1584
1607
  panel('messages', workflowMessagesHtml(w, name)) +
1585
1608
  panel('brief', workflowBriefHtml(w)) +
1586
- panel('evidence', workflowEvidenceHtml(w, runs)) +
1609
+ panel('audit', workflowAuditHtml(w, runs, name)) +
1610
+ panel('improve', workflowImproveHtml(w)) +
1587
1611
  '<div class="hint workflow-result"></div>' +
1588
1612
  '<div class="wf-row-foot"><span class="hint">Skill <code>' + escapeHtml(w.id) + '</code></span><button type="button" class="wf-remove workflow-forget" title="Its schedules and webhooks go; its instructions stay as a skill for Chat">Remove</button></div>' +
1589
1613
  '</div>' +
@@ -2214,7 +2238,8 @@ ${renderMarkdownScript}
2214
2238
  loadBriefVersions(card, base);
2215
2239
  loadWorkflowHealth(card, base);
2216
2240
  loadCandidates(card, base);
2217
- if (workflowTabs[id] === 'changes') loadWorkflowChanges(card);
2241
+ loadAuditSummary(card, base);
2242
+ loadLatestChanges(card, name);
2218
2243
  card.querySelector('.workflow-edit').addEventListener('click', function () { openWorkflowEditor(name, card); });
2219
2244
  // Opens the workflow's page on its Triggers tab.
2220
2245
  var triggersBtn = card.querySelector('.workflow-triggers-open');
@@ -2308,7 +2333,7 @@ ${renderMarkdownScript}
2308
2333
  }
2309
2334
  if (cbtn.classList.contains('wf-crit-add')) { rows.insertAdjacentHTML('beforeend', critRowHtml({ kind: 'judge' })); return; }
2310
2335
  if (cbtn.classList.contains('wf-crit-remove')) { cbtn.closest('.wf-crit-row').remove(); return; }
2311
- if (cbtn.classList.contains('wf-crit-cancel')) { workflowTabs[id] = 'evidence'; loadWorkflowsSection(name); return; }
2336
+ if (cbtn.classList.contains('wf-crit-cancel')) { workflowTabs[id] = 'improve'; loadWorkflowsSection(name); return; }
2312
2337
  cbtn.disabled = true;
2313
2338
  if (cbtn.classList.contains('wf-crit-draft')) {
2314
2339
  critStatus.textContent = 'Drafting from the brief' + String.fromCharCode(8230);
@@ -2326,7 +2351,7 @@ ${renderMarkdownScript}
2326
2351
  fetchJsonRetryOnce(base + '/evals/criteria', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ criteria: list }) }).then(function (r) {
2327
2352
  cbtn.disabled = false;
2328
2353
  if (!r.ok) { critStatus.textContent = r.body.error || 'That didn' + String.fromCharCode(8217) + 't save.'; return; }
2329
- workflowTabs[id] = 'evidence';
2354
+ workflowTabs[id] = 'improve';
2330
2355
  loadWorkflowsSection(name);
2331
2356
  });
2332
2357
  });
@@ -2346,7 +2371,7 @@ ${renderMarkdownScript}
2346
2371
  if (request[1].body) opts.body = JSON.stringify(request[1].body);
2347
2372
  fetchJsonRetryOnce(request[0], opts).then(function (r) {
2348
2373
  if (!r.ok) { btn.disabled = false; result.textContent = r.body.error || 'That didn' + String.fromCharCode(8217) + 't work.'; return; }
2349
- workflowTabs[id] = 'evidence';
2374
+ workflowTabs[id] = 'improve';
2350
2375
  loadWorkflowsSection(name);
2351
2376
  });
2352
2377
  });
@@ -201,7 +201,7 @@ ${consoleShellScript}
201
201
  function eventLink(e) {
202
202
  var d = e.data || {};
203
203
  if (e.run_id) return { href: '/cases/' + encodeURIComponent(e.run_id) + '?back=' + encodeURIComponent(location.pathname + location.search), text: 'Case' };
204
- if (e.workflow_id) return { href: workflowHref(e.agent, e.workflow_id, /brief version/i.test(d.label || '') || /Edited the workflow/.test(d.label || '') ? 'brief' : 'changes'), text: 'Workflow' };
204
+ if (e.workflow_id) return { href: workflowHref(e.agent, e.workflow_id, /brief version/i.test(d.label || '') || /Edited the workflow/.test(d.label || '') ? 'brief' : 'audit'), text: 'Workflow' };
205
205
  if (e.agent) return { href: '/agents/config?agent=' + encodeURIComponent(e.agent), text: 'Agent' };
206
206
  var path = String(d.path || '');
207
207
  if (path.indexOf('/config/models') === 0) return { href: '/config?section=models', text: 'Models' };
@@ -417,7 +417,7 @@ ${renderMarkdownScript}
417
417
  .then(function (r) { return r.json().then(function (b) { if (!r.ok) throw new Error(b.error || 'Could not save'); return b; }); })
418
418
  .then(function (b) {
419
419
  btn.textContent = 'Saved as an eval case';
420
- result.innerHTML = 'Saved. <a class="ib-link" href="/agents/config?agent=' + encodeURIComponent(c.agent) + '&tab=workflows&workflow=' + encodeURIComponent(c.workflowId) + '&wtab=evidence">See its eval cases</a>';
420
+ result.innerHTML = 'Saved. <a class="ib-link" href="/agents/config?agent=' + encodeURIComponent(c.agent) + '&tab=workflows&workflow=' + encodeURIComponent(c.workflowId) + '&wtab=improve">See its eval cases</a>';
421
421
  showSuggestions(c, b.suggestions || [], b.criteria || []);
422
422
  })
423
423
  .catch(function (err) { btn.disabled = false; result.textContent = err.message; });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",