loopengine 0.4.6 → 0.4.8
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/web/agents-config-page.js +30 -1
- package/dist/web/audit-admin.js +6 -2
- package/dist/web/audit-page.js +30 -1
- package/dist/web/change-log.d.ts +13 -0
- package/dist/web/change-log.js +67 -0
- package/dist/web/workflow-audit-report.js +3 -1
- package/dist/web/workflow-audit.d.ts +8 -0
- package/dist/web/workflow-audit.js +6 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { createAgentEnv, agentDirFor, envScopeOf, type EnvScope } from '#core/ag
|
|
|
7
7
|
export { FileSecretStore, setSecretStore, getSecretStore, type SecretStore } from '#core/secret-store.js';
|
|
8
8
|
export { signProxyIdentity, verifyProxyIdentity, TRUSTED_PROXY_IDENTITY_HEADER, type ProxyIdentity } from '#core/trusted-proxy.js';
|
|
9
9
|
export { setUsageSink, recordUsage, sessionUsage, usageBySession, type UsageEvent, type UsageSink, type UsageRow } from '#core/usage.js';
|
|
10
|
-
export { changeOf, keptBody, type Change } from '#web/change-log.js';
|
|
10
|
+
export { changeOf, keptBody, describeChanges, changesSummary, type Change, type FieldChange } from '#web/change-log.js';
|
|
11
11
|
export { eventText, eventsCsv, caseRow, type AuditCaseRow } from '#web/audit-admin.js';
|
|
12
12
|
export { auditPageHtml, auditPageFor } from '#web/audit-page.js';
|
|
13
13
|
export { buildWorkflowAudit, lineDiff, type WorkflowAudit, type WorkflowAuditInput, type AuditCounts, type AuditPerson, type AuditDecision, type AuditVersion, type AuditCase } from '#web/workflow-audit.js';
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { createAgentEnv, agentDirFor, envScopeOf } from '#core/agent-env.js';
|
|
|
9
9
|
export { FileSecretStore, setSecretStore, getSecretStore } from '#core/secret-store.js';
|
|
10
10
|
export { signProxyIdentity, verifyProxyIdentity, TRUSTED_PROXY_IDENTITY_HEADER } from '#core/trusted-proxy.js';
|
|
11
11
|
export { setUsageSink, recordUsage, sessionUsage, usageBySession } from '#core/usage.js';
|
|
12
|
-
export { changeOf, keptBody } from '#web/change-log.js';
|
|
12
|
+
export { changeOf, keptBody, describeChanges, changesSummary } from '#web/change-log.js';
|
|
13
13
|
export { eventText, eventsCsv, caseRow } from '#web/audit-admin.js';
|
|
14
14
|
export { auditPageHtml, auditPageFor } from '#web/audit-page.js';
|
|
15
15
|
export { buildWorkflowAudit, lineDiff } from '#web/workflow-audit.js';
|
|
@@ -230,6 +230,14 @@ export const agentsConfigPageHtml = `<!doctype html>
|
|
|
230
230
|
.wf-health-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
|
231
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
232
|
.wf-audit-link:hover { background: var(--surface); }
|
|
233
|
+
.chg { display: grid; gap: 6px; margin-top: 4px; font-size: 12.5px; flex-basis: 100%; }
|
|
234
|
+
.chg-field del { color: var(--bad); }
|
|
235
|
+
.chg-field ins { color: var(--good); text-decoration: none; }
|
|
236
|
+
.chg-lines { display: grid; gap: 1px; margin-top: 3px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
237
|
+
.chg-del { background: var(--bad-soft); color: var(--bad); padding: 1px 6px; }
|
|
238
|
+
.chg-ins { background: var(--good-soft); color: var(--good); padding: 1px 6px; }
|
|
239
|
+
.chg-note { color: var(--ink-muted); font-family: inherit; font-weight: 400; }
|
|
240
|
+
.chg details summary { cursor: pointer; color: var(--accent-ink); font-family: var(--font-sans, inherit); font-size: 12px; margin-top: 2px; }
|
|
233
241
|
.wf-change-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13px; }
|
|
234
242
|
.wf-change-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
|
|
235
243
|
.wf-change-kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); min-width: 64px; }
|
|
@@ -1142,12 +1150,33 @@ ${renderMarkdownScript}
|
|
|
1142
1150
|
return escapeHtml(e.kind);
|
|
1143
1151
|
}
|
|
1144
1152
|
|
|
1153
|
+
// A change's details: each setting from and to, and for long texts the
|
|
1154
|
+
// lines added (+) and removed (−), a few shown and the rest folded.
|
|
1155
|
+
function changeDetailsHtml(d) {
|
|
1156
|
+
var list = d.changes || [];
|
|
1157
|
+
if (!list.length && !d.brief) return '';
|
|
1158
|
+
var MINUS = String.fromCharCode(8722);
|
|
1159
|
+
var lineHtml = function (sign, cls, l) { return '<div class="' + cls + '">' + sign + ' ' + escapeHtml(l) + '</div>'; };
|
|
1160
|
+
var rows = list.map(function (c) {
|
|
1161
|
+
if (c.added || c.removed) {
|
|
1162
|
+
var lines = (c.removed || []).map(function (l) { return lineHtml(MINUS, 'chg-del', l); }).concat((c.added || []).map(function (l) { return lineHtml('+', 'chg-ins', l); }));
|
|
1163
|
+
var head = '<strong>' + escapeHtml(c.field) + '</strong>' + (c.field === 'instructions' && d.brief ? ' <span class="chg-note">brief v' + d.brief.from + ' ' + String.fromCharCode(8594) + ' v' + d.brief.to + '</span>' : '');
|
|
1164
|
+
var shown = lines.slice(0, 6).join('');
|
|
1165
|
+
var more = lines.length > 6 ? '<details><summary>' + (lines.length - 6) + ' more line' + (lines.length - 6 === 1 ? '' : 's') + '</summary>' + lines.slice(6).join('') + '</details>' : '';
|
|
1166
|
+
return '<div class="chg-field">' + head + '<div class="chg-lines">' + (shown || '<div class="chg-note">Only spacing changed.</div>') + more + '</div></div>';
|
|
1167
|
+
}
|
|
1168
|
+
return '<div class="chg-field"><strong>' + escapeHtml(c.field) + '</strong>: <del>' + escapeHtml(c.from) + '</del> ' + String.fromCharCode(8594) + ' <ins>' + escapeHtml(c.to) + '</ins></div>';
|
|
1169
|
+
}).join('');
|
|
1170
|
+
if (!rows && d.brief) rows = '<div class="chg-field">brief v' + d.brief.from + ' ' + String.fromCharCode(8594) + ' v' + d.brief.to + '</div>';
|
|
1171
|
+
return '<div class="chg">' + rows + '</div>';
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1145
1174
|
function workflowChangesHtml(events) {
|
|
1146
1175
|
if (!events.length) return '<p class="hint" style="margin:0">Nothing yet. Edits to this workflow' + RSQ + 's settings, and every approval, answer and feedback in its runs, will be listed here with who and when.</p>';
|
|
1147
1176
|
return '<ol class="wf-change-list">' + events.map(function (e) {
|
|
1148
1177
|
var when = new Date(e.at).toLocaleString(undefined, { month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
|
1149
1178
|
var kind = e.kind === 'change' ? 'Setting' : e.kind === 'decision' ? 'Decision' : e.kind === 'answer' ? 'Answer' : 'Feedback';
|
|
1150
|
-
return '<li><span class="wf-change-kind ' + escapeHtml(e.kind) + '">' + kind + '</span><span class="wf-change-text">' + changeText(e) + '</span>' +
|
|
1179
|
+
return '<li><span class="wf-change-kind ' + escapeHtml(e.kind) + '">' + kind + '</span><span class="wf-change-text">' + changeText(e) + (e.kind === 'change' ? changeDetailsHtml(e.data || {}) : '') + '</span>' +
|
|
1151
1180
|
'<span class="hint">' + (e.by ? escapeHtml(e.by) + DOT : '') + escapeHtml(when) +
|
|
1152
1181
|
(e.run_id ? DOT + '<a href="' + caseHref(e.run_id) + '">case</a>' : '') + '</span></li>';
|
|
1153
1182
|
}).join('') + '</ol>';
|
package/dist/web/audit-admin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changesSummary } from './change-log.js';
|
|
1
2
|
const short = (text, max) => {
|
|
2
3
|
const flat = text.replace(/\s+/g, ' ').trim();
|
|
3
4
|
return flat.length > max ? flat.slice(0, max - 1) + '…' : flat;
|
|
@@ -7,8 +8,11 @@ const short = (text, max) => {
|
|
|
7
8
|
export function eventText(e) {
|
|
8
9
|
const d = e.data;
|
|
9
10
|
const str = (v) => (typeof v === 'string' ? v : '');
|
|
10
|
-
if (e.kind === 'change')
|
|
11
|
-
|
|
11
|
+
if (e.kind === 'change') {
|
|
12
|
+
const brief = d.brief;
|
|
13
|
+
const summary = Array.isArray(d.changes) ? changesSummary(d.changes) : '';
|
|
14
|
+
return { what: str(d.label) || 'Changed a setting', detail: [brief?.from && brief.to ? `brief v${brief.from} → v${brief.to}` : '', summary].filter(Boolean).join('; ') };
|
|
15
|
+
}
|
|
12
16
|
if (e.kind === 'decision') {
|
|
13
17
|
const what = `${d.approved ? (d.edited ? 'Approved as changed' : 'Approved') : 'Denied'} ${str(d.tool)}`;
|
|
14
18
|
return { what, detail: str(d.reason) };
|
package/dist/web/audit-page.js
CHANGED
|
@@ -60,6 +60,14 @@ export const auditPageHtml = `<!doctype html>
|
|
|
60
60
|
.au-state.warn { background: var(--warn-soft); color: var(--warn); }
|
|
61
61
|
.au-state.run { background: var(--accent-soft); color: var(--accent-ink); }
|
|
62
62
|
.au-evalcase { color: var(--accent-ink); font-weight: 600; }
|
|
63
|
+
.chg { display: grid; gap: 6px; margin-top: 4px; font-size: 12.5px; flex-basis: 100%; }
|
|
64
|
+
.chg-field del { color: var(--bad); }
|
|
65
|
+
.chg-field ins { color: var(--good); text-decoration: none; }
|
|
66
|
+
.chg-lines { display: grid; gap: 1px; margin-top: 3px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
67
|
+
.chg-del { background: var(--bad-soft); color: var(--bad); padding: 1px 6px; }
|
|
68
|
+
.chg-ins { background: var(--good-soft); color: var(--good); padding: 1px 6px; }
|
|
69
|
+
.chg-note { color: var(--ink-muted); font-family: inherit; font-weight: 400; }
|
|
70
|
+
.chg details summary { cursor: pointer; color: var(--accent-ink); font-family: var(--font-sans, inherit); font-size: 12px; margin-top: 2px; }
|
|
63
71
|
.au-empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); font-size: 13.5px; }
|
|
64
72
|
.au-more { justify-self: center; }
|
|
65
73
|
.error { font-size: 13px; color: var(--bad); margin: 0; }
|
|
@@ -211,6 +219,27 @@ ${consoleShellScript}
|
|
|
211
219
|
return { what: 'Feedback' + (v ? ': ' + v : ''), detail: d.note || '' };
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
// A change's details: each setting from and to, and for long texts the
|
|
223
|
+
// lines added (+) and removed (−), a few shown and the rest folded.
|
|
224
|
+
function changeDetailsHtml(d) {
|
|
225
|
+
var list = d.changes || [];
|
|
226
|
+
if (!list.length && !d.brief) return '';
|
|
227
|
+
var MINUS = String.fromCharCode(8722);
|
|
228
|
+
var lineHtml = function (sign, cls, l) { return '<div class="' + cls + '">' + sign + ' ' + esc(l) + '</div>'; };
|
|
229
|
+
var rows = list.map(function (c) {
|
|
230
|
+
if (c.added || c.removed) {
|
|
231
|
+
var lines = (c.removed || []).map(function (l) { return lineHtml(MINUS, 'chg-del', l); }).concat((c.added || []).map(function (l) { return lineHtml('+', 'chg-ins', l); }));
|
|
232
|
+
var head = '<strong>' + esc(c.field) + '</strong>' + (c.field === 'instructions' && d.brief ? ' <span class="chg-note">brief v' + d.brief.from + ' ' + String.fromCharCode(8594) + ' v' + d.brief.to + '</span>' : '');
|
|
233
|
+
var shown = lines.slice(0, 6).join('');
|
|
234
|
+
var more = lines.length > 6 ? '<details><summary>' + (lines.length - 6) + ' more line' + (lines.length - 6 === 1 ? '' : 's') + '</summary>' + lines.slice(6).join('') + '</details>' : '';
|
|
235
|
+
return '<div class="chg-field">' + head + '<div class="chg-lines">' + (shown || '<div class="chg-note">Only spacing changed.</div>') + more + '</div></div>';
|
|
236
|
+
}
|
|
237
|
+
return '<div class="chg-field"><strong>' + esc(c.field) + '</strong>: <del>' + esc(c.from) + '</del> ' + String.fromCharCode(8594) + ' <ins>' + esc(c.to) + '</ins></div>';
|
|
238
|
+
}).join('');
|
|
239
|
+
if (!rows && d.brief) rows = '<div class="chg-field">brief v' + d.brief.from + ' ' + String.fromCharCode(8594) + ' v' + d.brief.to + '</div>';
|
|
240
|
+
return '<div class="chg">' + rows + '</div>';
|
|
241
|
+
}
|
|
242
|
+
|
|
214
243
|
function eventRow(e) {
|
|
215
244
|
var words = eventWords(e);
|
|
216
245
|
var link = eventLink(e);
|
|
@@ -219,7 +248,7 @@ ${consoleShellScript}
|
|
|
219
248
|
var where = agentLabel(e.agent) + (e.workflow_id ? DOT + workflowTitle(e.agent, e.workflow_id) : '');
|
|
220
249
|
return '<div class="au-row"><span class="au-when">' + esc(when(e.at)) + '</span>' +
|
|
221
250
|
'<span class="au-kind ' + esc(e.kind) + denied + '">' + kind + '</span>' +
|
|
222
|
-
'<span class="au-what"><strong>' + esc(words.what) + '</strong>' + (words.detail ? '<span class="au-detail">' + esc(words.detail) + '</span>' : '') +
|
|
251
|
+
'<span class="au-what"><strong>' + esc(words.what) + '</strong>' + (words.detail ? '<span class="au-detail">' + esc(words.detail) + '</span>' : '') + (e.kind === 'change' ? changeDetailsHtml(e.data || {}) : '') +
|
|
223
252
|
'<span class="au-where">' + (e.by ? esc(e.by) + DOT : '') + esc(where) + '</span></span>' +
|
|
224
253
|
'<a class="au-open" href="' + esc(link.href) + '">' + esc(link.text) + ' ' + String.fromCharCode(8594) + '</a></div>';
|
|
225
254
|
}
|
package/dist/web/change-log.d.ts
CHANGED
|
@@ -10,3 +10,16 @@ export declare function changeOf(method: string, path: string): Change | undefin
|
|
|
10
10
|
/** A body as kept in the log: secret-looking fields blanked, long text
|
|
11
11
|
* cut. Secrets' bodies are dropped whole. */
|
|
12
12
|
export declare function keptBody(path: string, body: unknown): unknown;
|
|
13
|
+
/** One setting a change touched: short values from and to, or for a
|
|
14
|
+
* long text (instructions, policies) the lines added and removed. */
|
|
15
|
+
export interface FieldChange {
|
|
16
|
+
field: string;
|
|
17
|
+
from?: string;
|
|
18
|
+
to?: string;
|
|
19
|
+
added?: string[];
|
|
20
|
+
removed?: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function describeChanges(before: Record<string, unknown>, after: Record<string, unknown>): FieldChange[];
|
|
23
|
+
/** The changes in a line: "instructions: 2 lines added, 1 removed; title:
|
|
24
|
+
* Refunds → Refund check". */
|
|
25
|
+
export declare function changesSummary(changes: FieldChange[]): string;
|
package/dist/web/change-log.js
CHANGED
|
@@ -85,3 +85,70 @@ function redact(value, depth) {
|
|
|
85
85
|
}
|
|
86
86
|
return value;
|
|
87
87
|
}
|
|
88
|
+
const showValue = (v) => {
|
|
89
|
+
if (v === undefined || v === null || v === '')
|
|
90
|
+
return '(none)';
|
|
91
|
+
const text = typeof v === 'string' ? v : JSON.stringify(v);
|
|
92
|
+
return text.length > 200 ? text.slice(0, 199) + '…' : text;
|
|
93
|
+
};
|
|
94
|
+
// Lines in `after` and not `before`, and the reverse, in order (the same
|
|
95
|
+
// longest-common-subsequence diff the workflow audit uses).
|
|
96
|
+
function lineChanges(before, after) {
|
|
97
|
+
const a = before.split('\n');
|
|
98
|
+
const b = after.split('\n');
|
|
99
|
+
if (a.length * b.length > 4_000_000) {
|
|
100
|
+
const inA = new Set(a);
|
|
101
|
+
const inB = new Set(b);
|
|
102
|
+
return { added: b.filter((l) => !inA.has(l) && l.trim()), removed: a.filter((l) => !inB.has(l) && l.trim()) };
|
|
103
|
+
}
|
|
104
|
+
const t = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
|
|
105
|
+
for (let i = a.length - 1; i >= 0; i--)
|
|
106
|
+
for (let j = b.length - 1; j >= 0; j--)
|
|
107
|
+
t[i][j] = a[i] === b[j] ? t[i + 1][j + 1] + 1 : Math.max(t[i + 1][j], t[i][j + 1]);
|
|
108
|
+
const added = [];
|
|
109
|
+
const removed = [];
|
|
110
|
+
let i = 0;
|
|
111
|
+
let j = 0;
|
|
112
|
+
while (i < a.length && j < b.length) {
|
|
113
|
+
if (a[i] === b[j]) {
|
|
114
|
+
i++;
|
|
115
|
+
j++;
|
|
116
|
+
}
|
|
117
|
+
else if (t[i + 1][j] >= t[i][j + 1])
|
|
118
|
+
removed.push(a[i++]);
|
|
119
|
+
else
|
|
120
|
+
added.push(b[j++]);
|
|
121
|
+
}
|
|
122
|
+
removed.push(...a.slice(i));
|
|
123
|
+
added.push(...b.slice(j));
|
|
124
|
+
return { added: added.filter((l) => l.trim()).map((l) => l.slice(0, 300)), removed: removed.filter((l) => l.trim()).map((l) => l.slice(0, 300)) };
|
|
125
|
+
}
|
|
126
|
+
/** What differs between two snapshots of the same settings, field by
|
|
127
|
+
* field. A text of several lines, or a long one, is told as lines added
|
|
128
|
+
* and removed; anything else as its value before and after. */
|
|
129
|
+
// Always told as lines, however short: what an agent reads.
|
|
130
|
+
const TEXT_FIELDS = new Set(['instructions', 'shared policies', 'checklist']);
|
|
131
|
+
export function describeChanges(before, after) {
|
|
132
|
+
const out = [];
|
|
133
|
+
for (const field of [...new Set([...Object.keys(before), ...Object.keys(after)])]) {
|
|
134
|
+
const b = before[field];
|
|
135
|
+
const a = after[field];
|
|
136
|
+
if (JSON.stringify(b) === JSON.stringify(a))
|
|
137
|
+
continue;
|
|
138
|
+
const long = (v) => typeof v === 'string' && (TEXT_FIELDS.has(field) || v.includes('\n') || v.length > 200);
|
|
139
|
+
if (long(b) || long(a)) {
|
|
140
|
+
const { added, removed } = lineChanges(typeof b === 'string' ? b : '', typeof a === 'string' ? a : '');
|
|
141
|
+
out.push({ field, added: added.slice(0, 40), removed: removed.slice(0, 40) });
|
|
142
|
+
}
|
|
143
|
+
else
|
|
144
|
+
out.push({ field, from: showValue(b), to: showValue(a) });
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
/** The changes in a line: "instructions: 2 lines added, 1 removed; title:
|
|
149
|
+
* Refunds → Refund check". */
|
|
150
|
+
export function changesSummary(changes) {
|
|
151
|
+
return changes.map((c) => (c.added || c.removed
|
|
152
|
+
? `${c.field}: ${c.added?.length ?? 0} line${c.added?.length === 1 ? '' : 's'} added, ${c.removed?.length ?? 0} removed`
|
|
153
|
+
: `${c.field}: ${c.from} → ${c.to}`)).join('; ');
|
|
154
|
+
}
|
|
@@ -31,7 +31,9 @@ export function workflowAuditReportHtml(audit, options) {
|
|
|
31
31
|
<td><a href="${esc(options.caseHref(d.runId))}">case</a></td></tr>`).join('');
|
|
32
32
|
const people = audit.people.map((p) => `<tr><td>${esc(p.by)}</td><td>${p.approved}</td><td>${p.changed}</td><td>${p.denied}</td><td>${p.answered}</td></tr>`).join('');
|
|
33
33
|
const cases = audit.cases.slice(0, 500).map((k) => `<tr><td>${esc(when(k.at))}</td><td>${STATUS[k.status] ?? esc(k.status)}</td><td>${esc(k.inputs)}</td><td>${k.briefVersion ? `v${k.briefVersion}` : ''}</td><td>${esc(k.decidedBy.join(', '))}</td><td class="ar-outcome">${esc(k.outcome)}</td><td><a href="${esc(options.caseHref(k.runId))}">open</a></td></tr>`).join('');
|
|
34
|
-
const changes = audit.changes.map((ch) => `<li>${esc(when(ch.at))} · ${esc(ch.label)}${ch.by ? ` · ${esc(ch.by)}` : ''}
|
|
34
|
+
const changes = audit.changes.map((ch) => `<li>${esc(when(ch.at))} · ${esc(ch.label)}${ch.by ? ` · ${esc(ch.by)}` : ''}${(ch.fields ?? []).map((f) => (f.added || f.removed
|
|
35
|
+
? `<div class="ar-diff"><div class="hint">${esc(f.field)}</div>${(f.removed ?? []).map((l) => `<div class="del">− ${esc(l)}</div>`).join('')}${(f.added ?? []).map((l) => `<div class="ins">+ ${esc(l)}</div>`).join('')}</div>`
|
|
36
|
+
: `<div class="hint">${esc(f.field)}: <del>${esc(f.from)}</del> → <ins>${esc(f.to)}</ins></div>`)).join('')}</li>`).join('');
|
|
35
37
|
return `<!doctype html>
|
|
36
38
|
<html lang="en">
|
|
37
39
|
<head>
|
|
@@ -82,6 +82,14 @@ export interface WorkflowAudit {
|
|
|
82
82
|
at: string;
|
|
83
83
|
by?: string;
|
|
84
84
|
label: string;
|
|
85
|
+
detail?: string;
|
|
86
|
+
fields?: {
|
|
87
|
+
field: string;
|
|
88
|
+
from?: string;
|
|
89
|
+
to?: string;
|
|
90
|
+
added?: string[];
|
|
91
|
+
removed?: string[];
|
|
92
|
+
}[];
|
|
85
93
|
}[];
|
|
86
94
|
cost?: {
|
|
87
95
|
totalUsd: number;
|
|
@@ -126,7 +126,12 @@ export function buildWorkflowAudit(input) {
|
|
|
126
126
|
decidedBy: [...new Set([...(r.decisions ?? []), ...(r.answers ?? [])].map((d) => d.by).filter((b) => Boolean(b)))],
|
|
127
127
|
outcome: short(r.status === 'error' ? r.error ?? '' : r.result ?? '', 200),
|
|
128
128
|
}));
|
|
129
|
-
const changes = input.changes.map((e) =>
|
|
129
|
+
const changes = input.changes.map((e) => {
|
|
130
|
+
const fields = Array.isArray(e.data.changes) ? e.data.changes : [];
|
|
131
|
+
const brief = e.data.brief;
|
|
132
|
+
const detail = [brief?.from && brief.to ? `brief v${brief.from} → v${brief.to}` : '', fields.map((f) => (f.added || f.removed ? `${f.field}: ${f.added?.length ?? 0} line${f.added?.length === 1 ? '' : 's'} added, ${f.removed?.length ?? 0} removed` : `${f.field}: ${f.from} → ${f.to}`)).join('; ')].filter(Boolean).join('; ');
|
|
133
|
+
return { at: e.at, ...(e.by ? { by: e.by } : {}), label: typeof e.data.label === 'string' ? e.data.label : 'Changed a setting', ...(detail ? { detail } : {}), ...(fields.length ? { fields } : {}) };
|
|
134
|
+
});
|
|
130
135
|
// ---- The summary, in sentences. ----
|
|
131
136
|
const summary = [];
|
|
132
137
|
const v = input.verification;
|