loopengine 0.4.5 → 0.4.6
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/core/audit-store.d.ts +5 -24
- package/dist/core/audit-store.js +12 -33
- package/dist/core/workflow-runs.d.ts +3 -0
- package/dist/core/workflow-runs.js +10 -1
- package/dist/core/workspace-roles.js +2 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3 -4
- package/dist/web/agents-config-page.js +54 -13
- package/dist/web/audit-admin.d.ts +3 -1
- package/dist/web/audit-admin.js +2 -1
- package/dist/web/audit-page.js +18 -14
- package/dist/web/console-shell.js +3 -1
- package/dist/web/inbox-admin.d.ts +17 -0
- package/dist/web/inbox-admin.js +32 -7
- package/dist/web/inbox-page.js +140 -23
- package/dist/web/workflow-audit-report.js +1 -1
- package/dist/web/workflow-audit.d.ts +2 -6
- package/dist/web/workflow-audit.js +1 -1
- package/dist/web/workflow-evidence.d.ts +21 -0
- package/dist/web/workflow-evidence.js +84 -1
- package/package.json +1 -3
- package/dist/core/audit-anchor.d.ts +0 -39
- package/dist/core/audit-anchor.js +0 -90
|
@@ -49,37 +49,18 @@ export interface ChainCheck {
|
|
|
49
49
|
broken?: {
|
|
50
50
|
id: number;
|
|
51
51
|
at?: string;
|
|
52
|
-
problem: 'changed' | 'missing-before'
|
|
52
|
+
problem: 'changed' | 'missing-before';
|
|
53
53
|
};
|
|
54
|
-
/** Anchors checked against the chain. */
|
|
55
|
-
anchors: number;
|
|
56
54
|
}
|
|
57
|
-
/** Checks every event's hash, in order
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
eventId: number;
|
|
62
|
-
hash: string;
|
|
63
|
-
}[], database?: DatabaseSync | undefined): ChainCheck;
|
|
64
|
-
/** The latest event's id and hash, to anchor. */
|
|
55
|
+
/** Checks every event's hash, in order. */
|
|
56
|
+
export declare function verifyEventChain(database?: DatabaseSync | undefined): ChainCheck;
|
|
57
|
+
/** The latest event's id and hash: written down anywhere outside the
|
|
58
|
+
* workspace, it lets a later check show the log wasn't rewritten. */
|
|
65
59
|
export declare function latestEventHash(database?: DatabaseSync | undefined): {
|
|
66
60
|
id: number;
|
|
67
61
|
at: string;
|
|
68
62
|
hash: string;
|
|
69
63
|
} | undefined;
|
|
70
|
-
/** Notes an anchor sent away (or kept only here, `sentAt` absent). */
|
|
71
|
-
export declare function noteAnchor(anchor: {
|
|
72
|
-
eventId: number;
|
|
73
|
-
hash: string;
|
|
74
|
-
at: string;
|
|
75
|
-
sentAt?: string;
|
|
76
|
-
}, database?: DatabaseSync | undefined): void;
|
|
77
|
-
export declare function lastAnchor(database?: DatabaseSync | undefined): {
|
|
78
|
-
eventId: number;
|
|
79
|
-
hash: string;
|
|
80
|
-
at: string;
|
|
81
|
-
sentAt?: string;
|
|
82
|
-
} | undefined;
|
|
83
64
|
export declare function schedulerDir(): string;
|
|
84
65
|
/** The process-wide database; undefined where node:sqlite isn't there,
|
|
85
66
|
* or LOOPENGINE_RUN_STORE=files asks for the JSON files. */
|
package/dist/core/audit-store.js
CHANGED
|
@@ -161,9 +161,10 @@ export function openAuditDb(dir) {
|
|
|
161
161
|
//
|
|
162
162
|
// Each event carries a hash of its own content and of the event before's
|
|
163
163
|
// hash, so changing or removing any event breaks every link after it
|
|
164
|
-
// (verifyEventChain finds where).
|
|
165
|
-
//
|
|
166
|
-
//
|
|
164
|
+
// (verifyEventChain finds where). It shows tampering, not prevents it;
|
|
165
|
+
// and someone who rewrites every hash after an edit isn't caught unless
|
|
166
|
+
// the latest hash was kept somewhere else (latestEventHash, and each
|
|
167
|
+
// export carries the hashes).
|
|
167
168
|
const GENESIS = '';
|
|
168
169
|
/** An event's hash: SHA-256 of the hash before it and its content. */
|
|
169
170
|
export function eventHash(prev, e) {
|
|
@@ -177,7 +178,6 @@ function chainEvents(db) {
|
|
|
177
178
|
if (!columns.includes('hash')) {
|
|
178
179
|
db.exec('ALTER TABLE events ADD COLUMN prev TEXT; ALTER TABLE events ADD COLUMN hash TEXT;');
|
|
179
180
|
}
|
|
180
|
-
db.exec("CREATE TABLE IF NOT EXISTS audit_anchors (event_id INTEGER PRIMARY KEY, hash TEXT NOT NULL, at TEXT NOT NULL, sent_at TEXT)");
|
|
181
181
|
const first = db.prepare('SELECT MIN(id) AS id FROM events WHERE hash IS NULL').get();
|
|
182
182
|
if (first.id == null)
|
|
183
183
|
return;
|
|
@@ -200,59 +200,38 @@ function chainEvents(db) {
|
|
|
200
200
|
}
|
|
201
201
|
writeMeta('events_chained', `${new Date().toISOString()} ${rows.length}`, db);
|
|
202
202
|
}
|
|
203
|
-
/** Checks every event's hash, in order
|
|
204
|
-
|
|
205
|
-
* back from where they were sent) still matches its event. */
|
|
206
|
-
export function verifyEventChain(anchors, database = auditDb()) {
|
|
203
|
+
/** Checks every event's hash, in order. */
|
|
204
|
+
export function verifyEventChain(database = auditDb()) {
|
|
207
205
|
if (!database)
|
|
208
|
-
return { ok: true, events: 0
|
|
206
|
+
return { ok: true, events: 0 };
|
|
209
207
|
let prev = GENESIS;
|
|
210
208
|
let count = 0;
|
|
211
209
|
let last;
|
|
212
210
|
let after = 0;
|
|
213
|
-
const byId = new Map();
|
|
214
|
-
const kept = anchors ?? database.prepare('SELECT event_id AS eventId, hash FROM audit_anchors').all();
|
|
215
|
-
const wanted = new Set(kept.map((a) => a.eventId));
|
|
216
211
|
for (;;) {
|
|
217
212
|
const rows = database.prepare('SELECT * FROM events WHERE id > ? ORDER BY id LIMIT 5000').all(after);
|
|
218
213
|
if (!rows.length)
|
|
219
214
|
break;
|
|
220
215
|
for (const row of rows) {
|
|
221
216
|
if ((row.prev ?? GENESIS) !== prev)
|
|
222
|
-
return { ok: false, events: count, broken: { id: row.id, at: row.at, problem: 'missing-before' },
|
|
217
|
+
return { ok: false, events: count, broken: { id: row.id, at: row.at, problem: 'missing-before' }, ...(last ? { last } : {}) };
|
|
223
218
|
const hash = eventHash(prev, row);
|
|
224
219
|
if (hash !== row.hash)
|
|
225
|
-
return { ok: false, events: count, broken: { id: row.id, at: row.at, problem: 'changed' },
|
|
226
|
-
if (wanted.has(row.id))
|
|
227
|
-
byId.set(row.id, hash);
|
|
220
|
+
return { ok: false, events: count, broken: { id: row.id, at: row.at, problem: 'changed' }, ...(last ? { last } : {}) };
|
|
228
221
|
prev = hash;
|
|
229
222
|
count++;
|
|
230
223
|
last = { id: row.id, at: row.at, hash };
|
|
231
224
|
}
|
|
232
225
|
after = rows.at(-1).id;
|
|
233
226
|
}
|
|
234
|
-
|
|
235
|
-
const hash = byId.get(anchor.eventId);
|
|
236
|
-
if (hash === undefined)
|
|
237
|
-
return { ok: false, events: count, broken: { id: anchor.eventId, problem: 'missing-after-anchor' }, anchors: kept.length, ...(last ? { last } : {}) };
|
|
238
|
-
if (hash !== anchor.hash)
|
|
239
|
-
return { ok: false, events: count, broken: { id: anchor.eventId, problem: 'anchor-differs' }, anchors: kept.length, ...(last ? { last } : {}) };
|
|
240
|
-
}
|
|
241
|
-
return { ok: true, events: count, anchors: kept.length, ...(last ? { last } : {}) };
|
|
227
|
+
return { ok: true, events: count, ...(last ? { last } : {}) };
|
|
242
228
|
}
|
|
243
|
-
/** The latest event's id and hash
|
|
229
|
+
/** The latest event's id and hash: written down anywhere outside the
|
|
230
|
+
* workspace, it lets a later check show the log wasn't rewritten. */
|
|
244
231
|
export function latestEventHash(database = auditDb()) {
|
|
245
232
|
const row = database?.prepare('SELECT id, at, hash FROM events WHERE hash IS NOT NULL ORDER BY id DESC LIMIT 1').get();
|
|
246
233
|
return row ? { id: Number(row.id), at: row.at, hash: row.hash } : undefined;
|
|
247
234
|
}
|
|
248
|
-
/** Notes an anchor sent away (or kept only here, `sentAt` absent). */
|
|
249
|
-
export function noteAnchor(anchor, database = auditDb()) {
|
|
250
|
-
database?.prepare('INSERT OR REPLACE INTO audit_anchors (event_id, hash, at, sent_at) VALUES (?, ?, ?, ?)').run(anchor.eventId, anchor.hash, anchor.at, anchor.sentAt ?? null);
|
|
251
|
-
}
|
|
252
|
-
export function lastAnchor(database = auditDb()) {
|
|
253
|
-
const row = database?.prepare('SELECT event_id, hash, at, sent_at FROM audit_anchors ORDER BY event_id DESC LIMIT 1').get();
|
|
254
|
-
return row ? { eventId: Number(row.event_id), hash: row.hash, at: row.at, ...(row.sent_at ? { sentAt: row.sent_at } : {}) } : undefined;
|
|
255
|
-
}
|
|
256
235
|
let db;
|
|
257
236
|
export function schedulerDir() {
|
|
258
237
|
return process.env.LOOPENGINE_SCHEDULER_DIR || path.join(process.cwd(), '.scheduler');
|
|
@@ -149,6 +149,9 @@ export interface RunSearch {
|
|
|
149
149
|
until?: string;
|
|
150
150
|
/** Started before this ISO time (the next page). */
|
|
151
151
|
before?: string;
|
|
152
|
+
/** Runs worth a look: a person denied or changed what it did, its
|
|
153
|
+
* result was marked bad (or heavily edited), or it asked a question. */
|
|
154
|
+
flag?: 'overruled' | 'bad' | 'asked';
|
|
152
155
|
limit?: number;
|
|
153
156
|
}
|
|
154
157
|
/** One JSON file per run under `<dir>/runs/` — one server process. */
|
|
@@ -39,7 +39,10 @@ function matchesSearch(run, f) {
|
|
|
39
39
|
&& (!f.since || run.started_at >= f.since)
|
|
40
40
|
&& (!f.until || run.started_at <= f.until)
|
|
41
41
|
&& (!f.before || run.started_at < f.before)
|
|
42
|
-
&& (!f.q || JSON.stringify(run).toLowerCase().includes(f.q.toLowerCase()))
|
|
42
|
+
&& (!f.q || JSON.stringify(run).toLowerCase().includes(f.q.toLowerCase()))
|
|
43
|
+
&& (f.flag !== 'overruled' || (run.decisions ?? []).some((d) => !d.approved || d.edited))
|
|
44
|
+
&& (f.flag !== 'bad' || run.feedback?.verdict === 'bad' || run.feedback?.edit === 'heavy')
|
|
45
|
+
&& (f.flag !== 'asked' || (run.answers ?? []).length > 0);
|
|
43
46
|
}
|
|
44
47
|
const fileMutex = new KeyedMutex();
|
|
45
48
|
/** One JSON file per run under `<dir>/runs/` — one server process. */
|
|
@@ -192,6 +195,12 @@ export class SqliteRunStore {
|
|
|
192
195
|
add('started_at < ?', f.before);
|
|
193
196
|
if (f.by)
|
|
194
197
|
add("(EXISTS (SELECT 1 FROM json_each(runs.data, '$.decisions') WHERE json_extract(value, '$.by') = ?) OR EXISTS (SELECT 1 FROM json_each(runs.data, '$.answers') WHERE json_extract(value, '$.by') = ?))", f.by, f.by);
|
|
198
|
+
if (f.flag === 'overruled')
|
|
199
|
+
add("EXISTS (SELECT 1 FROM json_each(runs.data, '$.decisions') WHERE json_extract(value, '$.approved') = 0 OR json_extract(value, '$.edited') = 1)");
|
|
200
|
+
if (f.flag === 'bad')
|
|
201
|
+
add("(json_extract(data, '$.feedback.verdict') = 'bad' OR json_extract(data, '$.feedback.edit') = 'heavy')");
|
|
202
|
+
if (f.flag === 'asked')
|
|
203
|
+
add("json_array_length(data, '$.answers') > 0");
|
|
195
204
|
if (f.q)
|
|
196
205
|
add("data LIKE ? ESCAPE '\\'", `%${f.q.replace(/[\\%_]/g, (c) => '\\' + c)}%`);
|
|
197
206
|
const limit = Math.min(Math.max(f.limit ?? 50, 1), 200);
|
|
@@ -43,6 +43,8 @@ export function roleLabel(role) {
|
|
|
43
43
|
export function inboxOnlyAllows(method, pathname) {
|
|
44
44
|
if (pathname === '/inbox' || pathname.startsWith('/inbox/'))
|
|
45
45
|
return true;
|
|
46
|
+
if (method === 'GET' && /^\/cases\/[^/]+$/.test(pathname))
|
|
47
|
+
return true;
|
|
46
48
|
if (method === 'POST' && /^\/pending-(approvals\/[^/]+\/resolve|questions\/[^/]+\/answer)$/.test(pathname))
|
|
47
49
|
return true;
|
|
48
50
|
if (method === 'GET' && (pathname === '/config/settings' || pathname === '/healthz'))
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export { eventText, eventsCsv, caseRow, type AuditCaseRow } from '#web/audit-adm
|
|
|
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';
|
|
14
14
|
export { workflowAuditReportHtml } from '#web/workflow-audit-report.js';
|
|
15
|
-
export { anchorConfig, anchorLatest, fetchAnchors, signAnchorRequest, startAuditAnchoring, AUDIT_ANCHORS_PATH, type AnchorConfig, type AnchorResult } from '#core/audit-anchor.js';
|
|
16
15
|
export { workflowHealth, healthAlerts, type WorkflowHealth, type HealthNumbers, type HealthVersion, type HealthDay, type HealthAlert, type HealthMeasure } from '#web/workflow-health.js';
|
|
17
16
|
export { setRunObserver, reportRun, usedTool, type RunEvent, type RunEventSource, type RunObserver } from '#core/run-events.js';
|
|
18
17
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS, type NotifierFile, type MessagingApprover } from '#core/notifier-file.js';
|
|
@@ -99,10 +98,10 @@ export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core
|
|
|
99
98
|
export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
|
|
100
99
|
export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError, type WorkflowTrigger, type PublicTrigger, type TriggerSettings, type TriggerVerify, type TriggerFilter, type TriggerSender, type SignatureAlgorithm, type TriggerDelivery, type TriggerOutcome, type TriggerStore } from './core/workflow-triggers.js';
|
|
101
100
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError, type CallbackDelivery, type CallbackPending, type RunCallbackEvent } from './core/run-callbacks.js';
|
|
102
|
-
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash,
|
|
101
|
+
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, type ChainCheck, readMeta, writeMeta, type EventFilter, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays, type Version, type VersionKind, type AuditEvent, type AuditEventKind } from './core/audit-store.js';
|
|
103
102
|
export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, searchRuns, type RunSearch, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunVersions, type RunDecision, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
|
|
104
103
|
export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies, type Workflow, type WorkflowFields, type WorkflowParameter, type WorkflowModel, type WorkflowDelivery, type RunMessageExtras } from './core/workflows.js';
|
|
105
|
-
export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION, type WorkflowScores, type EvalCase, type EvalCaseResult, type EvalCheck, type EvalCriterion, type CriterionKind, type EvalRound, type WorkflowEvals, type EvalRunDeps, type StandIn } from './web/workflow-evidence.js';
|
|
104
|
+
export { EvidenceError, evalCandidates, suggestedCriteria, type EvalCandidate, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION, type WorkflowScores, type EvalCase, type EvalCaseResult, type EvalCheck, type EvalCriterion, type CriterionKind, type EvalRound, type WorkflowEvals, type EvalRunDeps, type StandIn } from './web/workflow-evidence.js';
|
|
106
105
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
107
106
|
export { playgroundHtml } from './web/playground.js';
|
|
108
107
|
export { readSkill, writeSkill, deleteSkill, SkillInvalidIdError, SkillNotFoundError } from './web/skills-admin.js';
|
|
@@ -148,4 +147,4 @@ export { compressResponses, serveConsoleAsset } from './web/response-compression
|
|
|
148
147
|
export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
|
|
149
148
|
export { homeOverview, workflowsOverview, startsOf, type HomeOverview, type WorkflowsOverview, type WorkflowOverviewRow } from './web/workflows-overview.js';
|
|
150
149
|
export { homePageHtml } from './web/home-page.js';
|
|
151
|
-
export { listInbox, getInboxCase, timelineOf, type InboxDeps, type InboxItem, type InboxCase, type InboxPending, type InboxStep } from './web/inbox-admin.js';
|
|
150
|
+
export { listInbox, getInboxCase, timelineOf, RECENT_DAYS, type InboxView, type InboxDeps, type InboxItem, type InboxCase, type InboxPending, type InboxStep } from './web/inbox-admin.js';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ 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';
|
|
16
16
|
export { workflowAuditReportHtml } from '#web/workflow-audit-report.js';
|
|
17
|
-
export { anchorConfig, anchorLatest, fetchAnchors, signAnchorRequest, startAuditAnchoring, AUDIT_ANCHORS_PATH } from '#core/audit-anchor.js';
|
|
18
17
|
export { workflowHealth, healthAlerts } from '#web/workflow-health.js';
|
|
19
18
|
export { setRunObserver, reportRun, usedTool } from '#core/run-events.js';
|
|
20
19
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS } from '#core/notifier-file.js';
|
|
@@ -92,10 +91,10 @@ export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflo
|
|
|
92
91
|
export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
|
|
93
92
|
export { createTrigger, updateTrigger, rotateTrigger, listTriggers, findTriggerByToken, publicTrigger, checkTriggerSettings, verifySenderSignature, parsePayload, valueAt, deliveryId, passesFilter, paramsFromPayload, checkRunDelivery, fillChatNotice, resultToChat, recordDelivery as recordTriggerDelivery, FileTriggerStore, getTriggerStore, setTriggerStore, TriggerError } from './core/workflow-triggers.js';
|
|
94
93
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError } from './core/run-callbacks.js';
|
|
95
|
-
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash,
|
|
94
|
+
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, readMeta, writeMeta, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays } from './core/audit-store.js';
|
|
96
95
|
export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, searchRuns, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
|
|
97
96
|
export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
|
|
98
|
-
export { EvidenceError, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION } from './web/workflow-evidence.js';
|
|
97
|
+
export { EvidenceError, evalCandidates, suggestedCriteria, workflowScores, runFeedbackFrom, readEvals, addEvalCase, updateEvalCase, removeEvalCase, setEvalCriteria, effectiveCriteria, codeCheck, judgeCriteria, checkCase, roundSummary, draftCriteria, startEvalRound, EVAL_CRITERIA_PROMPT, DRAFT_CRITERIA_PROMPT, REFERENCE_CRITERION } from './web/workflow-evidence.js';
|
|
99
98
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
100
99
|
export { playgroundHtml } from './web/playground.js';
|
|
101
100
|
export { readSkill, writeSkill, deleteSkill, SkillInvalidIdError, SkillNotFoundError } from './web/skills-admin.js';
|
|
@@ -139,4 +138,4 @@ export { compressResponses, serveConsoleAsset } from './web/response-compression
|
|
|
139
138
|
export { workflowsOverviewPageHtml } from './web/workflows-overview-page.js';
|
|
140
139
|
export { homeOverview, workflowsOverview, startsOf } from './web/workflows-overview.js';
|
|
141
140
|
export { homePageHtml } from './web/home-page.js';
|
|
142
|
-
export { listInbox, getInboxCase, timelineOf } from './web/inbox-admin.js';
|
|
141
|
+
export { listInbox, getInboxCase, timelineOf, RECENT_DAYS } from './web/inbox-admin.js';
|
|
@@ -209,6 +209,16 @@ 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-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
|
+
.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
|
+
.wf-run-line:first-child, .wf-cand-list li:first-child { border-top: 0; }
|
|
215
|
+
.wf-run-link { display: flex; gap: 10px; flex: 1 1 320px; min-width: 0; color: var(--ink); text-decoration: none; }
|
|
216
|
+
.wf-run-link:hover .wf-run-text { text-decoration: underline; }
|
|
217
|
+
.wf-run-when { color: var(--ink-muted); white-space: nowrap; }
|
|
218
|
+
.wf-run-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
219
|
+
.wf-run-line .wf-run-evidence { flex-basis: 100%; padding-left: 2px; }
|
|
220
|
+
.wf-cand-text { display: grid; gap: 2px; flex: 1 1 320px; min-width: 0; }
|
|
221
|
+
.wf-cand-text strong { font-weight: 600; overflow-wrap: anywhere; }
|
|
212
222
|
.wf-health { display: grid; gap: 12px; margin-bottom: 8px; }
|
|
213
223
|
.wf-health-alert { padding: 10px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: 13px; font-weight: 600; }
|
|
214
224
|
.wf-health-chart { margin: 0; display: grid; gap: 4px; }
|
|
@@ -954,6 +964,11 @@ ${renderMarkdownScript}
|
|
|
954
964
|
var pageParams = new URLSearchParams(location.search);
|
|
955
965
|
var workflowPageId = pageParams.get('tab') === 'workflows' && pageParams.get('workflow') || null;
|
|
956
966
|
if (workflowPageId && pageParams.get('wtab')) workflowTabs[workflowPageId] = pageParams.get('wtab');
|
|
967
|
+
// A case's page, with a back link to here.
|
|
968
|
+
function caseHref(runId) {
|
|
969
|
+
return '/cases/' + encodeURIComponent(runId) + '?back=' + encodeURIComponent(location.pathname + location.search);
|
|
970
|
+
}
|
|
971
|
+
|
|
957
972
|
function workflowPageHref(agent, id, tab) {
|
|
958
973
|
return '/agents/config?agent=' + encodeURIComponent(agent) + '&tab=workflows&workflow=' + encodeURIComponent(id) + (tab ? '&wtab=' + encodeURIComponent(tab) : '');
|
|
959
974
|
}
|
|
@@ -1134,7 +1149,7 @@ ${renderMarkdownScript}
|
|
|
1134
1149
|
var kind = e.kind === 'change' ? 'Setting' : e.kind === 'decision' ? 'Decision' : e.kind === 'answer' ? 'Answer' : 'Feedback';
|
|
1135
1150
|
return '<li><span class="wf-change-kind ' + escapeHtml(e.kind) + '">' + kind + '</span><span class="wf-change-text">' + changeText(e) + '</span>' +
|
|
1136
1151
|
'<span class="hint">' + (e.by ? escapeHtml(e.by) + DOT : '') + escapeHtml(when) +
|
|
1137
|
-
(e.run_id ? DOT + '<a href="
|
|
1152
|
+
(e.run_id ? DOT + '<a href="' + caseHref(e.run_id) + '">case</a>' : '') + '</span></li>';
|
|
1138
1153
|
}).join('') + '</ol>';
|
|
1139
1154
|
}
|
|
1140
1155
|
|
|
@@ -1406,9 +1421,34 @@ ${renderMarkdownScript}
|
|
|
1406
1421
|
'<h4 class="wf-sub">Eval cases</h4>' +
|
|
1407
1422
|
'<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>' +
|
|
1408
1423
|
'<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>' +
|
|
1409
|
-
(cases ? '<ul class="wf-cases">' + cases + '</ul>' : '<p class="hint" style="margin:0">No cases yet. Save
|
|
1410
|
-
'<h4 class="wf-sub">
|
|
1411
|
-
|
|
1424
|
+
(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>') +
|
|
1425
|
+
(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>' : '') +
|
|
1426
|
+
'<h4 class="wf-sub">Recent runs</h4>' +
|
|
1427
|
+
(runsHtml ? '<ul class="wf-run-lines">' + runsHtml + '</ul>' : '<p class="hint" style="margin:0">No runs yet.</p>') +
|
|
1428
|
+
(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>' : '');
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// Worth testing: runs from the last 30 days that would make good eval
|
|
1432
|
+
// cases, each with why (a person denied or changed what it did, a bad
|
|
1433
|
+
// result, a question it asked, a failure, or a typical good run).
|
|
1434
|
+
var WHY = { denied: ['bad', 'Denied'], changed: ['ask', 'Changed'], bad: ['bad', 'Bad result'], asked: ['ask', 'Asked'], failed: ['bad', 'Failed'], typical: ['good', 'Typical'] };
|
|
1435
|
+
function loadCandidates(card, base) {
|
|
1436
|
+
var box = card.querySelector('.wf-candidates');
|
|
1437
|
+
if (!box) return;
|
|
1438
|
+
fetch(base + '/evals/candidates', { headers: { accept: 'application/json' } })
|
|
1439
|
+
.then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
|
|
1440
|
+
.then(function (data) {
|
|
1441
|
+
var list = data.candidates || [];
|
|
1442
|
+
if (!list.length) { box.innerHTML = '<p class="hint" style="margin:0">Nothing new to suggest from the last 30 days.</p>'; return; }
|
|
1443
|
+
box.innerHTML = '<p class="hint" style="margin:0 0 6px">From the last 30 days, best first. Open one to read it in full before saving.</p><ul class="wf-cand-list">' + list.map(function (c) {
|
|
1444
|
+
var why = WHY[c.why] || ['', c.why];
|
|
1445
|
+
return '<li><span class="le-pill ' + why[0] + '">' + why[1] + '</span>' +
|
|
1446
|
+
'<span class="wf-cand-text"><strong>' + escapeHtml(c.detail) + '</strong><span class="hint">' + escapeHtml(new Date(c.at).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })) + (c.inputs ? DOT + escapeHtml(c.inputs) : '') + '</span></span>' +
|
|
1447
|
+
'<a class="wf-link" href="' + caseHref(c.runId) + '">Open</a>' +
|
|
1448
|
+
'<button type="button" class="wf-link wf-save-case" data-run="' + escapeHtml(c.runId) + '">Save as eval case</button></li>';
|
|
1449
|
+
}).join('') + '</ul>';
|
|
1450
|
+
})
|
|
1451
|
+
.catch(function (err) { box.innerHTML = '<p class="error">Could not look through its runs: ' + escapeHtml(err.message) + '</p>'; });
|
|
1412
1452
|
}
|
|
1413
1453
|
|
|
1414
1454
|
// A run's evidence line: its feedback, and saving it as an eval case.
|
|
@@ -1445,20 +1485,20 @@ ${renderMarkdownScript}
|
|
|
1445
1485
|
return '<label class="workflow-param">' + escapeHtml(p) + (spec.required ? '' : ' <span class="hint">(optional)</span>') +
|
|
1446
1486
|
'<textarea rows="1" name="' + escapeHtml(p) + '"' + (spec.required ? ' required' : '') + ' placeholder="' + escapeHtml(spec.description || '') + '"></textarea></label>';
|
|
1447
1487
|
}).join('');
|
|
1488
|
+
// Recent runs, one line each, opening the case (where everything
|
|
1489
|
+
// about it is).
|
|
1448
1490
|
var runs = (w.recentRuns || []).map(function (r) {
|
|
1449
1491
|
var pill = r.status === 'done' ? '<span class="le-pill good">Done</span>'
|
|
1450
1492
|
: r.status === 'error' ? '<span class="le-pill bad">Failed</span>'
|
|
1451
|
-
: r.status === 'awaiting_approval' ? '<span class="le-pill ask">Waiting
|
|
1493
|
+
: r.status === 'awaiting_approval' ? '<span class="le-pill ask">Waiting</span>'
|
|
1452
1494
|
: '<span class="le-pill accent">Running</span>';
|
|
1453
|
-
var values = r.params ? Object.keys(r.params).map(function (k) { return
|
|
1454
|
-
var source = r.source === 'console' ? 'Manual run' : r.source === 'api' ? 'App / API' : r.source === 'schedule' ? 'Scheduled' + (r.task_name ? ' · ' + r.task_name : '') : r.source === 'chain' ? 'After another workflow, in a goal' + String.fromCharCode(8217) + 's job' : 'Webhook';
|
|
1495
|
+
var values = r.params ? Object.keys(r.params).map(function (k) { return k + ': ' + r.params[k]; }).join(DOT) : '';
|
|
1455
1496
|
var outcome = r.status === 'error' ? (r.error || '') : (r.result || '');
|
|
1456
|
-
var
|
|
1457
|
-
return '<li class="
|
|
1458
|
-
'<span class="
|
|
1459
|
-
'<span class="
|
|
1460
|
-
(
|
|
1461
|
-
(outcome ? '<div><div class="workflow-run-entry-label">' + (r.status === 'error' ? 'Error' : 'Final response') + '</div><div class="schedule-result workflow-markdown">' + formattedOutcome + '</div><details class="schedule-result-details"><summary>View full ' + (r.status === 'error' ? 'error' : 'response') + '</summary><div class="schedule-result-full workflow-markdown workflow-markdown-full">' + formattedOutcome + '</div></details></div>' : '') +
|
|
1497
|
+
var line = (values ? values + DOT : '') + outcome;
|
|
1498
|
+
return '<li class="wf-run-line">' + pill +
|
|
1499
|
+
'<a class="wf-run-link" href="' + caseHref(r.run_id) + '"><span class="wf-run-when">' + escapeHtml(new Date(r.started_at).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })) + '</span>' +
|
|
1500
|
+
'<span class="wf-run-text">' + escapeHtml(line.length > 160 ? line.slice(0, 160) + String.fromCharCode(8230) : line) + '</span></a>' +
|
|
1501
|
+
(r.versions && r.versions.brief ? '<span class="hint">brief v' + r.versions.brief + '</span>' : '') +
|
|
1462
1502
|
runEvidenceHtml(w, r) + '</li>';
|
|
1463
1503
|
}).join('');
|
|
1464
1504
|
var last = workflowLastRun(w);
|
|
@@ -2144,6 +2184,7 @@ ${renderMarkdownScript}
|
|
|
2144
2184
|
for (var t = 0; t < tabs.length; t++) tabs[t].addEventListener('click', function (ev) { showWorkflowTab(card, ev.currentTarget.dataset.tab); });
|
|
2145
2185
|
loadBriefVersions(card, base);
|
|
2146
2186
|
loadWorkflowHealth(card, base);
|
|
2187
|
+
loadCandidates(card, base);
|
|
2147
2188
|
if (workflowTabs[id] === 'changes') loadWorkflowChanges(card);
|
|
2148
2189
|
card.querySelector('.workflow-edit').addEventListener('click', function () { openWorkflowEditor(name, card); });
|
|
2149
2190
|
// Opens the workflow's page on its Triggers tab.
|
|
@@ -24,5 +24,7 @@ export interface AuditCaseRow {
|
|
|
24
24
|
people: string[];
|
|
25
25
|
/** The start of its result, or its error. */
|
|
26
26
|
outcome: string;
|
|
27
|
+
/** Saved as one of its workflow's eval cases. */
|
|
28
|
+
evalCase?: boolean;
|
|
27
29
|
}
|
|
28
|
-
export declare function caseRow(run: WorkflowRun, workflowTitle: string | undefined): AuditCaseRow;
|
|
30
|
+
export declare function caseRow(run: WorkflowRun, workflowTitle: string | undefined, evalCase?: boolean): AuditCaseRow;
|
package/dist/web/audit-admin.js
CHANGED
|
@@ -33,7 +33,7 @@ export function eventsCsv(events) {
|
|
|
33
33
|
});
|
|
34
34
|
return [CSV_COLUMNS.join(','), ...rows].join('\r\n') + '\r\n';
|
|
35
35
|
}
|
|
36
|
-
export function caseRow(run, workflowTitle) {
|
|
36
|
+
export function caseRow(run, workflowTitle, evalCase = false) {
|
|
37
37
|
const inputs = Object.entries(run.params ?? {}).map(([k, v]) => `${k}: ${v}`).join(' · ');
|
|
38
38
|
const people = [...new Set([...(run.decisions ?? []), ...(run.answers ?? [])].map((d) => d.by).filter((b) => Boolean(b)))];
|
|
39
39
|
return {
|
|
@@ -48,5 +48,6 @@ export function caseRow(run, workflowTitle) {
|
|
|
48
48
|
...(run.versions?.brief ? { briefVersion: run.versions.brief } : {}),
|
|
49
49
|
people,
|
|
50
50
|
outcome: short(run.status === 'error' ? run.error ?? '' : run.result ?? '', 200),
|
|
51
|
+
...(evalCase ? { evalCase: true } : {}),
|
|
51
52
|
};
|
|
52
53
|
}
|
package/dist/web/audit-page.js
CHANGED
|
@@ -59,6 +59,7 @@ export const auditPageHtml = `<!doctype html>
|
|
|
59
59
|
.au-state.bad { background: var(--bad-soft); color: var(--bad); }
|
|
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
|
+
.au-evalcase { color: var(--accent-ink); font-weight: 600; }
|
|
62
63
|
.au-empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); font-size: 13.5px; }
|
|
63
64
|
.au-more { justify-self: center; }
|
|
64
65
|
.error { font-size: 13px; color: var(--bad); margin: 0; }
|
|
@@ -91,6 +92,9 @@ ${consoleSidebarHtml}
|
|
|
91
92
|
<select id="auKind" aria-label="Kind">
|
|
92
93
|
<option value="">Everything</option><option value="change">Settings changed</option><option value="decision">Approvals</option><option value="answer">Answers</option><option value="feedback">Feedback</option>
|
|
93
94
|
</select>
|
|
95
|
+
<select id="auFlag" aria-label="Worth a look" hidden>
|
|
96
|
+
<option value="">Any case</option><option value="overruled">Denied or changed</option><option value="bad">Marked bad</option><option value="asked">Asked a question</option>
|
|
97
|
+
</select>
|
|
94
98
|
<select id="auStatus" aria-label="Status" hidden>
|
|
95
99
|
<option value="">Any outcome</option><option value="done">Done</option><option value="error">Failed</option><option value="awaiting_approval">Waiting for a decision</option><option value="running">Running</option>
|
|
96
100
|
</select>
|
|
@@ -117,7 +121,7 @@ ${consoleShellScript}
|
|
|
117
121
|
var state = {
|
|
118
122
|
tab: params.get('tab') === 'cases' ? 'cases' : 'activity',
|
|
119
123
|
agent: params.get('agent') || '', workflow: params.get('workflow') || '', by: params.get('by') || '',
|
|
120
|
-
kind: params.get('kind') || '', status: params.get('status') || '',
|
|
124
|
+
kind: params.get('kind') || '', status: params.get('status') || '', flag: params.get('flag') || '',
|
|
121
125
|
period: params.has('period') ? params.get('period') : '30', q: params.get('q') || '',
|
|
122
126
|
};
|
|
123
127
|
// The filters' choices come with the page (auditPageFor), so they show
|
|
@@ -129,7 +133,7 @@ ${consoleShellScript}
|
|
|
129
133
|
var more = document.getElementById('auMore');
|
|
130
134
|
var el = {
|
|
131
135
|
agent: document.getElementById('auAgent'), workflow: document.getElementById('auWorkflow'), by: document.getElementById('auBy'),
|
|
132
|
-
kind: document.getElementById('auKind'), status: document.getElementById('auStatus'), period: document.getElementById('auPeriod'),
|
|
136
|
+
kind: document.getElementById('auKind'), status: document.getElementById('auStatus'), flag: document.getElementById('auFlag'), period: document.getElementById('auPeriod'),
|
|
133
137
|
q: document.getElementById('auQ'), exportLink: document.getElementById('auExport'),
|
|
134
138
|
};
|
|
135
139
|
|
|
@@ -166,6 +170,7 @@ ${consoleShellScript}
|
|
|
166
170
|
if (state.by) q.set('by', state.by);
|
|
167
171
|
if (state.tab === 'activity' && state.kind) q.set('kind', state.kind);
|
|
168
172
|
if (state.tab === 'cases' && state.status) q.set('status', state.status);
|
|
173
|
+
if (state.tab === 'cases' && state.flag) q.set('flag', state.flag);
|
|
169
174
|
if (state.period) q.set('since', new Date(Date.now() - Number(state.period) * 86400000).toISOString());
|
|
170
175
|
if (state.q) q.set('q', state.q);
|
|
171
176
|
Object.keys(extra || {}).forEach(function (k) { q.set(k, extra[k]); });
|
|
@@ -178,6 +183,7 @@ ${consoleShellScript}
|
|
|
178
183
|
['agent', 'workflow', 'by', 'q'].forEach(function (k) { if (state[k]) q.set(k, state[k]); });
|
|
179
184
|
if (state.tab === 'activity' && state.kind) q.set('kind', state.kind);
|
|
180
185
|
if (state.tab === 'cases' && state.status) q.set('status', state.status);
|
|
186
|
+
if (state.tab === 'cases' && state.flag) q.set('flag', state.flag);
|
|
181
187
|
if (state.period !== '30') q.set('period', state.period);
|
|
182
188
|
history.replaceState(null, '', '/audit' + (q.toString() ? '?' + q.toString() : ''));
|
|
183
189
|
}
|
|
@@ -186,7 +192,7 @@ ${consoleShellScript}
|
|
|
186
192
|
// the agent, or the workspace setting.
|
|
187
193
|
function eventLink(e) {
|
|
188
194
|
var d = e.data || {};
|
|
189
|
-
if (e.run_id) return { href: '/
|
|
195
|
+
if (e.run_id) return { href: '/cases/' + encodeURIComponent(e.run_id) + '?back=' + encodeURIComponent(location.pathname + location.search), text: 'Case' };
|
|
190
196
|
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' };
|
|
191
197
|
if (e.agent) return { href: '/agents/config?agent=' + encodeURIComponent(e.agent), text: 'Agent' };
|
|
192
198
|
var path = String(d.path || '');
|
|
@@ -223,8 +229,8 @@ ${consoleShellScript}
|
|
|
223
229
|
return '<div class="au-row au-case"><span class="au-state ' + pill[0] + '">' + pill[1] + '</span>' +
|
|
224
230
|
'<span class="au-what"><strong>' + esc(c.workflowTitle) + (c.inputs ? DOT + esc(c.inputs) : '') + '</strong>' +
|
|
225
231
|
(c.outcome ? '<span class="au-detail">' + esc(c.outcome) + '</span>' : '') +
|
|
226
|
-
'<span class="au-where">' + esc(when(c.startedAt)) + DOT + esc(agentLabel(c.agent)) + (c.briefVersion ? DOT + 'brief v' + c.briefVersion : '') + (c.people.length ? DOT + 'decided by ' + esc(c.people.join(', ')) : '') + '</span></span>' +
|
|
227
|
-
'<a class="au-open" href="/
|
|
232
|
+
'<span class="au-where">' + esc(when(c.startedAt)) + DOT + esc(agentLabel(c.agent)) + (c.briefVersion ? DOT + 'brief v' + c.briefVersion : '') + (c.people.length ? DOT + 'decided by ' + esc(c.people.join(', ')) : '') + (c.evalCase ? DOT + '<span class="au-evalcase">eval case</span>' : '') + '</span></span>' +
|
|
233
|
+
'<a class="au-open" href="/cases/' + encodeURIComponent(c.id) + '?back=' + encodeURIComponent(location.pathname + location.search) + '">Open ' + String.fromCharCode(8594) + '</a></div>';
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
function load(append) {
|
|
@@ -261,6 +267,7 @@ ${consoleShellScript}
|
|
|
261
267
|
for (var i = 0; i < tabs.length; i++) tabs[i].setAttribute('aria-selected', String(tabs[i].getAttribute('data-tab') === state.tab));
|
|
262
268
|
el.kind.hidden = state.tab !== 'activity';
|
|
263
269
|
el.status.hidden = state.tab !== 'cases';
|
|
270
|
+
el.flag.hidden = state.tab !== 'cases';
|
|
264
271
|
el.exportLink.hidden = state.tab !== 'activity';
|
|
265
272
|
verifyBtn.hidden = state.tab !== 'activity';
|
|
266
273
|
el.exportLink.href = '/audit/events.csv?' + query();
|
|
@@ -301,7 +308,7 @@ ${consoleShellScript}
|
|
|
301
308
|
changed();
|
|
302
309
|
});
|
|
303
310
|
el.agent.addEventListener('change', function () { state.agent = el.agent.value; fillWorkflows(); changed(); });
|
|
304
|
-
['workflow', 'by', 'kind', 'status', 'period'].forEach(function (k) {
|
|
311
|
+
['workflow', 'by', 'kind', 'status', 'flag', 'period'].forEach(function (k) {
|
|
305
312
|
el[k].addEventListener('change', function () { state[k] = el[k].value; changed(); });
|
|
306
313
|
});
|
|
307
314
|
var typing;
|
|
@@ -311,14 +318,12 @@ ${consoleShellScript}
|
|
|
311
318
|
});
|
|
312
319
|
more.addEventListener('click', function () { load(true); });
|
|
313
320
|
|
|
314
|
-
// Checks every event's hash, in order
|
|
321
|
+
// Checks every event's hash, in order.
|
|
315
322
|
var verifyBtn = document.getElementById('auVerify');
|
|
316
323
|
var check = document.getElementById('auCheck');
|
|
317
324
|
var PROBLEMS = {
|
|
318
325
|
'changed': 'it was changed after it was recorded',
|
|
319
326
|
'missing-before': 'an event before it was removed, or the order changed',
|
|
320
|
-
'missing-after-anchor': 'events up to an anchored point are missing',
|
|
321
|
-
'anchor-differs': 'it no longer matches the hash anchored for it',
|
|
322
327
|
};
|
|
323
328
|
verifyBtn.addEventListener('click', function () {
|
|
324
329
|
verifyBtn.disabled = true;
|
|
@@ -328,15 +333,13 @@ ${consoleShellScript}
|
|
|
328
333
|
fetch('/audit/verify', { headers: { accept: 'application/json' } })
|
|
329
334
|
.then(function (r) { return r.ok ? r.json() : r.json().then(function (b) { throw new Error(b.error || 'HTTP ' + r.status); }); })
|
|
330
335
|
.then(function (v) {
|
|
331
|
-
var anchors = v.anchors ? v.anchors + ' anchor' + (v.anchors === 1 ? '' : 's') + ' kept at ' + v.anchoredAt + ' match' + (v.anchors === 1 ? 'es' : '') : 'no anchors yet (one is sent each day)';
|
|
332
|
-
var note = v.anchorsNote ? '<span class="hint">Anchors checked are this workspace' + String.fromCharCode(8217) + 's own: ' + esc(v.anchorsNote) + '.</span>' : '';
|
|
333
336
|
if (v.ok) {
|
|
334
|
-
check.innerHTML = 'Intact: all ' + v.events.toLocaleString() + ' events check out
|
|
335
|
-
(v.last ? '<span class="hint">Latest event #' + v.last.id + ', ' + esc(when(v.last.at)) + DOT + 'hash ' + esc(v.last.hash
|
|
337
|
+
check.innerHTML = 'Intact: all ' + v.events.toLocaleString() + ' events check out.' +
|
|
338
|
+
(v.last ? '<span class="hint">Latest event #' + v.last.id + ', ' + esc(when(v.last.at)) + DOT + 'hash ' + esc(v.last.hash) + '</span>' : '');
|
|
336
339
|
} else {
|
|
337
340
|
check.className = 'au-check bad';
|
|
338
341
|
check.innerHTML = 'Broken at event #' + v.broken.id + (v.broken.at ? ' (' + esc(when(v.broken.at)) + ')' : '') + ': ' + esc(PROBLEMS[v.broken.problem] || v.broken.problem) + '.' +
|
|
339
|
-
'<span class="hint">' + v.events.toLocaleString() + ' events before it check out.</span>'
|
|
342
|
+
'<span class="hint">' + v.events.toLocaleString() + ' events before it check out.</span>';
|
|
340
343
|
}
|
|
341
344
|
})
|
|
342
345
|
.catch(function (err) { check.className = 'au-check bad'; check.textContent = 'Could not check: ' + err.message; })
|
|
@@ -346,6 +349,7 @@ ${consoleShellScript}
|
|
|
346
349
|
el.q.value = state.q;
|
|
347
350
|
el.kind.value = state.kind;
|
|
348
351
|
el.status.value = state.status;
|
|
352
|
+
el.flag.value = state.flag;
|
|
349
353
|
el.period.value = state.period;
|
|
350
354
|
function fillFilters(f) {
|
|
351
355
|
filters = f;
|
|
@@ -390,7 +390,9 @@ export const consoleShellScript = `<script>
|
|
|
390
390
|
: page === 'workflows' || page === 'workflows-overview' ? 'workflows'
|
|
391
391
|
: page === 'config' ? 'settings'
|
|
392
392
|
: page === 'inbox' ? 'inbox'
|
|
393
|
-
: page === 'audit' ? 'audit'
|
|
393
|
+
: page === 'audit' ? 'audit'
|
|
394
|
+
// A case, in the section it was opened from.
|
|
395
|
+
: page === 'case' ? ((params.get('back') || '').indexOf('/audit') === 0 ? 'audit' : (params.get('back') || '').indexOf('/agents') === 0 ? 'workflows' : 'inbox') : '';
|
|
394
396
|
var railItems = document.querySelectorAll('[data-le-section]');
|
|
395
397
|
for (var ri = 0; ri < railItems.length; ri++) {
|
|
396
398
|
if (railItems[ri].getAttribute('data-le-section') === section0) railItems[ri].classList.add('is-current');
|
|
@@ -37,15 +37,32 @@ export interface InboxItem {
|
|
|
37
37
|
finishedAt?: string;
|
|
38
38
|
/** The latest person who decided something in it. */
|
|
39
39
|
lastBy?: string;
|
|
40
|
+
/** When it began waiting on a person (its oldest open request). */
|
|
41
|
+
waitingSince?: string;
|
|
42
|
+
/** When anything last happened in it: finished, or decided. */
|
|
43
|
+
lastActivity: string;
|
|
44
|
+
/** What happened, in a few words: "Done automatically", "Approved by
|
|
45
|
+
* ana@…", "Failed". */
|
|
46
|
+
outcome: string;
|
|
40
47
|
}
|
|
48
|
+
/** The Inbox's views: what's waiting on a person (however long), and
|
|
49
|
+
* everything from the last RECENT_DAYS days. */
|
|
50
|
+
export type InboxView = 'needs' | 'recent';
|
|
51
|
+
export declare const RECENT_DAYS = 7;
|
|
52
|
+
/** `view`: "needs" (waiting on a person, oldest first, however long),
|
|
53
|
+
* "recent" (the last RECENT_DAYS days, latest first), or "auto" (needs
|
|
54
|
+
* when anything waits, else recent). `open` is the older name for needs. */
|
|
41
55
|
export declare function listInbox(deps: InboxDeps, filter?: {
|
|
56
|
+
view?: InboxView | 'auto';
|
|
42
57
|
open?: boolean;
|
|
43
58
|
q?: string;
|
|
44
59
|
workflow?: string;
|
|
45
60
|
limit?: number;
|
|
61
|
+
now?: number;
|
|
46
62
|
}): Promise<{
|
|
47
63
|
items: InboxItem[];
|
|
48
64
|
open: number;
|
|
65
|
+
view: InboxView;
|
|
49
66
|
workflows: {
|
|
50
67
|
id: string;
|
|
51
68
|
title: string;
|