loopengine 0.4.3 → 0.4.5
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-anchor.d.ts +39 -0
- package/dist/core/audit-anchor.js +90 -0
- package/dist/core/audit-store.d.ts +63 -1
- package/dist/core/audit-store.js +120 -1
- package/dist/core/mcp-abilities.js +14 -6
- package/dist/core/run-agent.d.ts +32 -6
- package/dist/core/run-agent.js +53 -8
- package/dist/core/workflow-runs.d.ts +24 -0
- package/dist/core/workflow-runs.js +50 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +8 -3
- package/dist/web/agents-config-page.js +17 -7
- package/dist/web/audit-admin.d.ts +28 -0
- package/dist/web/audit-admin.js +52 -0
- package/dist/web/audit-page.d.ts +15 -0
- package/dist/web/audit-page.js +371 -0
- package/dist/web/change-log.js +1 -0
- package/dist/web/console-shell.js +6 -2
- package/dist/web/dev-ui-styles.js +2 -0
- package/dist/web/global-config-page.js +41 -1
- package/dist/web/workflow-audit-report.d.ts +8 -0
- package/dist/web/workflow-audit-report.js +129 -0
- package/dist/web/workflow-audit.d.ts +120 -0
- package/dist/web/workflow-audit.js +208 -0
- package/dist/web/workflow-evidence.d.ts +14 -3
- package/dist/web/workflow-evidence.js +2 -2
- package/package.json +3 -1
|
@@ -29,6 +29,18 @@ const SESSION_PREFIX = 'run-';
|
|
|
29
29
|
const SCHEDULE_SESSION_PREFIX = 'sched-';
|
|
30
30
|
export class RunError extends Error {
|
|
31
31
|
}
|
|
32
|
+
function matchesSearch(run, f) {
|
|
33
|
+
const people = [...(run.decisions ?? []), ...(run.answers ?? [])].map((d) => d.by);
|
|
34
|
+
return (!f.agent || run.agent === f.agent)
|
|
35
|
+
&& (!f.agents || f.agents.includes(run.agent))
|
|
36
|
+
&& (!f.workflowId || run.workflow_id === f.workflowId)
|
|
37
|
+
&& (!f.status || run.status === f.status)
|
|
38
|
+
&& (!f.by || people.includes(f.by))
|
|
39
|
+
&& (!f.since || run.started_at >= f.since)
|
|
40
|
+
&& (!f.until || run.started_at <= f.until)
|
|
41
|
+
&& (!f.before || run.started_at < f.before)
|
|
42
|
+
&& (!f.q || JSON.stringify(run).toLowerCase().includes(f.q.toLowerCase()));
|
|
43
|
+
}
|
|
32
44
|
const fileMutex = new KeyedMutex();
|
|
33
45
|
/** One JSON file per run under `<dir>/runs/` — one server process. */
|
|
34
46
|
export class FileRunStore {
|
|
@@ -157,6 +169,35 @@ export class SqliteRunStore {
|
|
|
157
169
|
async since(agent, workflowId, since) {
|
|
158
170
|
return this.db.prepare('SELECT data FROM runs WHERE agent = ? AND workflow_id = ? AND started_at >= ? ORDER BY started_at').all(agent, workflowId, since).map((r) => this.read(r));
|
|
159
171
|
}
|
|
172
|
+
async search(f) {
|
|
173
|
+
const where = [];
|
|
174
|
+
const args = [];
|
|
175
|
+
const add = (clause, ...values) => {
|
|
176
|
+
where.push(clause);
|
|
177
|
+
args.push(...values);
|
|
178
|
+
};
|
|
179
|
+
if (f.agent)
|
|
180
|
+
add('agent = ?', f.agent);
|
|
181
|
+
if (f.agents)
|
|
182
|
+
add(`agent IN (${f.agents.map(() => '?').join(', ') || "''"})`, ...f.agents);
|
|
183
|
+
if (f.workflowId)
|
|
184
|
+
add('workflow_id = ?', f.workflowId);
|
|
185
|
+
if (f.status)
|
|
186
|
+
add('status = ?', f.status);
|
|
187
|
+
if (f.since)
|
|
188
|
+
add('started_at >= ?', f.since);
|
|
189
|
+
if (f.until)
|
|
190
|
+
add('started_at <= ?', f.until);
|
|
191
|
+
if (f.before)
|
|
192
|
+
add('started_at < ?', f.before);
|
|
193
|
+
if (f.by)
|
|
194
|
+
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);
|
|
195
|
+
if (f.q)
|
|
196
|
+
add("data LIKE ? ESCAPE '\\'", `%${f.q.replace(/[\\%_]/g, (c) => '\\' + c)}%`);
|
|
197
|
+
const limit = Math.min(Math.max(f.limit ?? 50, 1), 200);
|
|
198
|
+
const sql = `SELECT data FROM runs${where.length ? ` WHERE ${where.join(' AND ')}` : ''} ORDER BY started_at DESC LIMIT ${limit}`;
|
|
199
|
+
return this.db.prepare(sql).all(...args).map((r) => this.read(r));
|
|
200
|
+
}
|
|
160
201
|
async bySession(sessionId) {
|
|
161
202
|
const row = this.db.prepare('SELECT data FROM runs WHERE session_id = ? ORDER BY started_at DESC LIMIT 1').get(sessionId);
|
|
162
203
|
return row ? this.read(row) : undefined;
|
|
@@ -217,6 +258,15 @@ export async function runsSince(agent, workflowId, since) {
|
|
|
217
258
|
return store.since(agent, workflowId, since);
|
|
218
259
|
return (await listRuns(agent, { workflowId })).filter((r) => r.started_at >= since).reverse();
|
|
219
260
|
}
|
|
261
|
+
/** Runs matching the filter, newest first: every one the store keeps
|
|
262
|
+
* (the console's list where it keeps no more). */
|
|
263
|
+
export async function searchRuns(filter) {
|
|
264
|
+
const store = getRunStore();
|
|
265
|
+
if (store.search)
|
|
266
|
+
return store.search(filter);
|
|
267
|
+
const limit = Math.min(Math.max(filter.limit ?? 50, 1), 200);
|
|
268
|
+
return (await store.list()).filter((r) => matchesSearch(r, filter)).slice(0, limit);
|
|
269
|
+
}
|
|
220
270
|
/** One of an agent's runs; undefined for another agent's. */
|
|
221
271
|
export async function getRun(agent, runId) {
|
|
222
272
|
if (!/^[A-Za-z0-9_-]+$/.test(runId))
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export { FileSecretStore, setSecretStore, getSecretStore, type SecretStore } fro
|
|
|
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
10
|
export { changeOf, keptBody, type Change } from '#web/change-log.js';
|
|
11
|
+
export { eventText, eventsCsv, caseRow, type AuditCaseRow } from '#web/audit-admin.js';
|
|
12
|
+
export { auditPageHtml, auditPageFor } from '#web/audit-page.js';
|
|
13
|
+
export { buildWorkflowAudit, lineDiff, type WorkflowAudit, type WorkflowAuditInput, type AuditCounts, type AuditPerson, type AuditDecision, type AuditVersion, type AuditCase } from '#web/workflow-audit.js';
|
|
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';
|
|
11
16
|
export { workflowHealth, healthAlerts, type WorkflowHealth, type HealthNumbers, type HealthVersion, type HealthDay, type HealthAlert, type HealthMeasure } from '#web/workflow-health.js';
|
|
12
17
|
export { setRunObserver, reportRun, usedTool, type RunEvent, type RunEventSource, type RunObserver } from '#core/run-events.js';
|
|
13
18
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS, type NotifierFile, type MessagingApprover } from '#core/notifier-file.js';
|
|
@@ -59,7 +64,7 @@ export { discoverAgents, loadAgentModule, synthesizeCreateModelCall } from './co
|
|
|
59
64
|
export { abilityDependencies, installMissingAbilityDependencies, installMissingPackages } from './core/ability-dependencies.js';
|
|
60
65
|
export type { AgentModule } from './core/discover-agents.js';
|
|
61
66
|
export { agentAsTool } from './core/agent-as-tool.js';
|
|
62
|
-
export { resumeAgent, loadRules, loadDefaultTools, loadSubagentAsTools, systemTools, systemSkillsDir } from './core/run-agent.js';
|
|
67
|
+
export { resumeAgent, recordedCalls, type RecordedCall, type EvalModeOptions, loadRules, loadDefaultTools, loadSubagentAsTools, systemTools, systemSkillsDir } from './core/run-agent.js';
|
|
63
68
|
export { Compactor, TruncatingSummarizer } from './core/compaction.js';
|
|
64
69
|
export type { Summarizer, RecoverResult, RecoverAction } from './core/compaction.js';
|
|
65
70
|
export { LLMSummarizer } from './core/llm-summarizer.js';
|
|
@@ -94,10 +99,10 @@ export { WORKFLOW_EXAMPLES, workflowExample, type WorkflowExample } from './core
|
|
|
94
99
|
export { WORKFLOW_EXAMPLE_MESSAGES, type WorkflowExampleMessage } from './core/system-agents/workflow-example-messages.js';
|
|
95
100
|
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';
|
|
96
101
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError, type CallbackDelivery, type CallbackPending, type RunCallbackEvent } from './core/run-callbacks.js';
|
|
97
|
-
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, readMeta, writeMeta, type EventFilter, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays, type Version, type VersionKind, type AuditEvent, type AuditEventKind } from './core/audit-store.js';
|
|
98
|
-
export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, getRun, isUnderWay, RunError, type WorkflowRun, type WorkflowRunStatus, type RunVersions, type RunDecision, type RunStore, type ExecuteRun, type RunOutcome, type StartRunInput } from './core/workflow-runs.js';
|
|
102
|
+
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, noteAnchor, lastAnchor, 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
|
+
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';
|
|
99
104
|
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';
|
|
100
|
-
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 } from './web/workflow-evidence.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';
|
|
101
106
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
102
107
|
export { playgroundHtml } from './web/playground.js';
|
|
103
108
|
export { readSkill, writeSkill, deleteSkill, SkillInvalidIdError, SkillNotFoundError } from './web/skills-admin.js';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,11 @@ export { FileSecretStore, setSecretStore, getSecretStore } from '#core/secret-st
|
|
|
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
12
|
export { changeOf, keptBody } from '#web/change-log.js';
|
|
13
|
+
export { eventText, eventsCsv, caseRow } from '#web/audit-admin.js';
|
|
14
|
+
export { auditPageHtml, auditPageFor } from '#web/audit-page.js';
|
|
15
|
+
export { buildWorkflowAudit, lineDiff } from '#web/workflow-audit.js';
|
|
16
|
+
export { workflowAuditReportHtml } from '#web/workflow-audit-report.js';
|
|
17
|
+
export { anchorConfig, anchorLatest, fetchAnchors, signAnchorRequest, startAuditAnchoring, AUDIT_ANCHORS_PATH } from '#core/audit-anchor.js';
|
|
13
18
|
export { workflowHealth, healthAlerts } from '#web/workflow-health.js';
|
|
14
19
|
export { setRunObserver, reportRun, usedTool } from '#core/run-events.js';
|
|
15
20
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS } from '#core/notifier-file.js';
|
|
@@ -58,7 +63,7 @@ export { agentAsTool } from './core/agent-as-tool.js';
|
|
|
58
63
|
// create-loopengine can build the same admin surface on top of its own
|
|
59
64
|
// copy of adapters/http.ts (which, like agent-registry.ts, is meant to be
|
|
60
65
|
// owned/edited, not imported — see this file's own header comment).
|
|
61
|
-
export { resumeAgent, loadRules, loadDefaultTools, loadSubagentAsTools, systemTools, systemSkillsDir } from './core/run-agent.js';
|
|
66
|
+
export { resumeAgent, recordedCalls, loadRules, loadDefaultTools, loadSubagentAsTools, systemTools, systemSkillsDir } from './core/run-agent.js';
|
|
62
67
|
export { Compactor, TruncatingSummarizer } from './core/compaction.js';
|
|
63
68
|
export { LLMSummarizer } from './core/llm-summarizer.js';
|
|
64
69
|
export { createCheckpointStore, SqliteCheckpointStore } from './core/durable-approvals.js';
|
|
@@ -87,8 +92,8 @@ export { WORKFLOW_EXAMPLES, workflowExample } from './core/system-agents/workflo
|
|
|
87
92
|
export { WORKFLOW_EXAMPLE_MESSAGES } from './core/system-agents/workflow-example-messages.js';
|
|
88
93
|
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';
|
|
89
94
|
export { checkCallbackUrl, callbackSecret, signCallback, deliverCallback, runCallbackPayload, isPrivateAddress, CallbackUrlError } from './core/run-callbacks.js';
|
|
90
|
-
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, readMeta, writeMeta, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays } from './core/audit-store.js';
|
|
91
|
-
export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
|
|
95
|
+
export { auditDb, openAuditDb, setAuditDb, recordEvent, runEvents, listEvents, eventPeople, eventHash, verifyEventChain, latestEventHash, noteAnchor, lastAnchor, readMeta, writeMeta, noteVersion, listVersions, getVersion, briefContent, briefFromContent, retentionDays } from './core/audit-store.js';
|
|
96
|
+
export { WorkflowRunner, FileRunStore, SqliteRunStore, getRunStore, setRunStore, listRuns, runsSince, searchRuns, getRun, isUnderWay, RunError } from './core/workflow-runs.js';
|
|
92
97
|
export { readWorkflows, readWorkflow, setWorkflowFields, setWorkflowDelivery, clearWorkflowFields, validateParams, workflowRunMessage, workflowPreviewMessage, migrateWorkflowsFile, WorkflowParamsError, readWorkspacePolicies, writeWorkspacePolicies } from './core/workflows.js';
|
|
93
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';
|
|
94
99
|
export { globalConfigPageHtml } from './web/global-config-page.js';
|
|
@@ -208,6 +208,7 @@ export const agentsConfigPageHtml = `<!doctype html>
|
|
|
208
208
|
.wf-crit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
|
|
209
209
|
.wf-crit-kind { font-size: 12px; color: var(--ink-muted); }
|
|
210
210
|
.wf-crit-rate { font-variant-numeric: tabular-nums; }
|
|
211
|
+
.wf-case-standins { margin: 0; font-size: 12.5px; color: var(--ink-muted); }
|
|
211
212
|
.wf-health { display: grid; gap: 12px; margin-bottom: 8px; }
|
|
212
213
|
.wf-health-alert { padding: 10px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: 13px; font-weight: 600; }
|
|
213
214
|
.wf-health-chart { margin: 0; display: grid; gap: 4px; }
|
|
@@ -217,6 +218,8 @@ export const agentsConfigPageHtml = `<!doctype html>
|
|
|
217
218
|
.wf-health-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
|
|
218
219
|
.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; }
|
|
219
220
|
.wf-health-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
|
221
|
+
.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; }
|
|
222
|
+
.wf-audit-link:hover { background: var(--surface); }
|
|
220
223
|
.wf-change-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13px; }
|
|
221
224
|
.wf-change-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
|
|
222
225
|
.wf-change-kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); min-width: 64px; }
|
|
@@ -784,7 +787,7 @@ ${renderMarkdownScript}
|
|
|
784
787
|
'<td>' + runsPill(t.name) + '</td>' +
|
|
785
788
|
'<td>' + (t.safe ? 'yes' : 'no') + '</td></tr>';
|
|
786
789
|
}).join('');
|
|
787
|
-
return '<table><thead><tr><th>Name</th><th>What it does</th><th>Runs</th><th>
|
|
790
|
+
return '<table><thead><tr><th>Name</th><th>What it does</th><th>Runs</th><th>Only reads</th></tr></thead><tbody>' + rows + '</tbody></table>';
|
|
788
791
|
}
|
|
789
792
|
|
|
790
793
|
// Local tools' own table, unlike renderTools above (shared by Agent as
|
|
@@ -807,7 +810,7 @@ ${renderMarkdownScript}
|
|
|
807
810
|
'<td>' + (t.safe ? 'yes' : 'no') + '</td>' +
|
|
808
811
|
'<td>' + actions + '</td></tr>';
|
|
809
812
|
}).join('');
|
|
810
|
-
return '<table><thead><tr><th>Name</th><th>What it does</th><th>Runs</th><th>
|
|
813
|
+
return '<table><thead><tr><th>Name</th><th>What it does</th><th>Runs</th><th>Only reads</th><th></th></tr></thead><tbody>' + rows + '</tbody></table>';
|
|
811
814
|
}
|
|
812
815
|
|
|
813
816
|
// Overview's own tools table, unlike the Tools tab's three separately-
|
|
@@ -840,7 +843,7 @@ ${renderMarkdownScript}
|
|
|
840
843
|
addRows(cfg.gatewayTools, 'Gateway');
|
|
841
844
|
addRows(cfg.agentAsTools, 'Agent as Tool');
|
|
842
845
|
if (!rows.length) return '<p class="muted">No tools.</p>';
|
|
843
|
-
return '<table><thead><tr><th>Name</th><th>Description</th><th>Type</th><th>
|
|
846
|
+
return '<table><thead><tr><th>Name</th><th>Description</th><th>Type</th><th>Only reads</th></tr></thead><tbody>' + rows.join('') + '</tbody></table>';
|
|
844
847
|
}
|
|
845
848
|
|
|
846
849
|
function renderSkills(skills) {
|
|
@@ -1381,9 +1384,16 @@ ${renderMarkdownScript}
|
|
|
1381
1384
|
var why = !last ? ''
|
|
1382
1385
|
: 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>' : '')
|
|
1383
1386
|
: '<p class="hint" style="margin:0">' + escapeHtml(last.reason || last.error || '') + '</p>';
|
|
1387
|
+
// The calls the test didn't make: what it would have done.
|
|
1388
|
+
var standIns = last && last.standIns && last.standIns.length
|
|
1389
|
+
? '<p class="wf-case-standins">Not made in the test: ' + last.standIns.map(function (x) {
|
|
1390
|
+
var shown = JSON.stringify(x.input);
|
|
1391
|
+
return '<code title="' + escapeHtml(shown) + '">' + escapeHtml(x.tool) + '</code>' + (x.replayed ? ' <span class="hint">(reply from its run)</span>' : '');
|
|
1392
|
+
}).join(', ') + '</p>'
|
|
1393
|
+
: '';
|
|
1384
1394
|
return '<li class="wf-case" data-case="' + escapeHtml(c.id) + '"><div class="wf-case-head"><strong>Case ' + (i + 1) + '</strong>' + pill +
|
|
1385
1395
|
'<span class="hint">' + (values || 'no inputs') + '</span><button type="button" class="wf-link wf-case-remove">Remove</button></div>' +
|
|
1386
|
-
why +
|
|
1396
|
+
why + standIns +
|
|
1387
1397
|
'<details><summary>Good result' + (c.reference ? '' : ' (none)') + (last && last.result ? ' and its latest result' : '') + '</summary>' +
|
|
1388
1398
|
'<textarea class="wf-case-ref" aria-label="Good result for case ' + (i + 1) + '" placeholder="Optional: what a good result says, to compare against">' + escapeHtml(c.reference || '') + '</textarea>' +
|
|
1389
1399
|
'<div class="wf-case-actions"><button type="button" class="wf-case-save">Save good result</button></div>' +
|
|
@@ -1395,7 +1405,7 @@ ${renderMarkdownScript}
|
|
|
1395
1405
|
tiles + feedbackHint + critSection +
|
|
1396
1406
|
'<h4 class="wf-sub">Eval cases</h4>' +
|
|
1397
1407
|
'<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>' +
|
|
1398
|
-
'<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: tools that need approval
|
|
1408
|
+
'<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>' +
|
|
1399
1409
|
(cases ? '<ul class="wf-cases">' + cases + '</ul>' : '<p class="hint" style="margin:0">No cases yet. Save a run from History below as a case, then run the cases after each change to the instructions or model.</p>') +
|
|
1400
1410
|
'<h4 class="wf-sub">History</h4>' +
|
|
1401
1411
|
(runsHtml ? '<ul class="schedule-history">' + runsHtml + '</ul>' : '<p class="hint" style="margin:0">No runs yet.</p>');
|
|
@@ -1464,7 +1474,7 @@ ${renderMarkdownScript}
|
|
|
1464
1474
|
'<div class="wf-page-crumb-row"><button type="button" class="le-menu-btn" data-le-menu aria-label="Open navigation">☰</button>' +
|
|
1465
1475
|
'<a class="wf-page-crumb" href="/agents/config?agent=' + encodeURIComponent(name) + '&tab=workflows">' + String.fromCharCode(8592) + ' ' + escapeHtml(agentLabel) + ' ' + String.fromCharCode(183) + ' Workflows</a></div>' +
|
|
1466
1476
|
'<div class="wf-page-title-row"><h1>' + escapeHtml(w.title) + '</h1>' +
|
|
1467
|
-
'<span class="wf-row-actions"><button type="button" class="workflow-edit">Edit</button></span></div>' +
|
|
1477
|
+
'<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>' +
|
|
1468
1478
|
(w.description && w.description !== w.title ? '<p class="wf-page-desc">' + escapeHtml(w.description) + '</p>' : '') +
|
|
1469
1479
|
'<div class="wf-page-meta">' +
|
|
1470
1480
|
'<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>' +
|
|
@@ -5114,7 +5124,7 @@ ${renderMarkdownScript}
|
|
|
5114
5124
|
'<button type="button" id="httpToolAddHeaderBtn" class="hint-btn">Add header</button>' +
|
|
5115
5125
|
'</label>' +
|
|
5116
5126
|
'<label class="http-tool-inline-label"><input type="checkbox" name="sendFieldsAsJsonBody"> Send fields as a JSON body (POST/PUT/PATCH only)</label>' +
|
|
5117
|
-
'<label class="http-tool-inline-label"><input type="checkbox" name="safe">
|
|
5127
|
+
'<label class="http-tool-inline-label"><input type="checkbox" name="safe"> Only reads data <span class="hint">(changes nothing: it runs in test runs, and alongside other calls)</span></label>' +
|
|
5118
5128
|
'<label>Response JSON path <span class="hint">(optional — e.g. data.status; leave blank to return the raw response text)</span>' +
|
|
5119
5129
|
'<input type="text" name="responseJsonPath" placeholder="data.status">' +
|
|
5120
5130
|
'</label>' +
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AuditEvent } from '../core/audit-store.js';
|
|
2
|
+
import type { WorkflowRun } from '../core/workflow-runs.js';
|
|
3
|
+
/** An event in words, as the page and the CSV file show it: what
|
|
4
|
+
* happened, and any detail (a reason, an answer, a note). */
|
|
5
|
+
export declare function eventText(e: AuditEvent): {
|
|
6
|
+
what: string;
|
|
7
|
+
detail: string;
|
|
8
|
+
};
|
|
9
|
+
/** The events as a CSV file, one row each, in the order given. */
|
|
10
|
+
export declare function eventsCsv(events: AuditEvent[]): string;
|
|
11
|
+
/** A case in the Cases list. */
|
|
12
|
+
export interface AuditCaseRow {
|
|
13
|
+
id: string;
|
|
14
|
+
agent: string;
|
|
15
|
+
workflowId: string;
|
|
16
|
+
workflowTitle: string;
|
|
17
|
+
/** Its inputs, in a line. */
|
|
18
|
+
inputs: string;
|
|
19
|
+
status: WorkflowRun['status'];
|
|
20
|
+
startedAt: string;
|
|
21
|
+
finishedAt?: string;
|
|
22
|
+
briefVersion?: number;
|
|
23
|
+
/** Everyone who decided or answered something in it. */
|
|
24
|
+
people: string[];
|
|
25
|
+
/** The start of its result, or its error. */
|
|
26
|
+
outcome: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function caseRow(run: WorkflowRun, workflowTitle: string | undefined): AuditCaseRow;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const short = (text, max) => {
|
|
2
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
3
|
+
return flat.length > max ? flat.slice(0, max - 1) + '…' : flat;
|
|
4
|
+
};
|
|
5
|
+
/** An event in words, as the page and the CSV file show it: what
|
|
6
|
+
* happened, and any detail (a reason, an answer, a note). */
|
|
7
|
+
export function eventText(e) {
|
|
8
|
+
const d = e.data;
|
|
9
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
10
|
+
if (e.kind === 'change')
|
|
11
|
+
return { what: str(d.label) || 'Changed a setting', detail: '' };
|
|
12
|
+
if (e.kind === 'decision') {
|
|
13
|
+
const what = `${d.approved ? (d.edited ? 'Approved as changed' : 'Approved') : 'Denied'} ${str(d.tool)}`;
|
|
14
|
+
return { what, detail: str(d.reason) };
|
|
15
|
+
}
|
|
16
|
+
if (e.kind === 'answer')
|
|
17
|
+
return { what: 'Answered a question', detail: `${short(str(d.question), 200)} → ${short(str(d.answer), 400)}` };
|
|
18
|
+
const verdict = d.verdict === 'good' ? 'Good' : d.verdict === 'bad' ? 'Bad' : '';
|
|
19
|
+
const edit = d.edit === 'none' ? 'used unedited' : d.edit ? `${str(d.edit)} edits` : '';
|
|
20
|
+
return { what: `Feedback${verdict || edit ? `: ${[verdict, edit].filter(Boolean).join(', ')}` : ''}`, detail: str(d.note) };
|
|
21
|
+
}
|
|
22
|
+
const CSV_COLUMNS = ['When (UTC)', 'Kind', 'Person', 'Agent', 'Workflow', 'What', 'Detail', 'Case', 'Event', 'Hash'];
|
|
23
|
+
function csvCell(value) {
|
|
24
|
+
// A leading = + - @ would run as a formula in a spreadsheet.
|
|
25
|
+
const safe = /^[=+\-@]/.test(value) ? `'${value}` : value;
|
|
26
|
+
return /[",\n\r]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe;
|
|
27
|
+
}
|
|
28
|
+
/** The events as a CSV file, one row each, in the order given. */
|
|
29
|
+
export function eventsCsv(events) {
|
|
30
|
+
const rows = events.map((e) => {
|
|
31
|
+
const { what, detail } = eventText(e);
|
|
32
|
+
return [e.at, e.kind, e.by ?? '', e.agent, e.workflow_id ?? '', what, detail, e.run_id ?? '', String(e.id), e.hash ?? ''].map(csvCell).join(',');
|
|
33
|
+
});
|
|
34
|
+
return [CSV_COLUMNS.join(','), ...rows].join('\r\n') + '\r\n';
|
|
35
|
+
}
|
|
36
|
+
export function caseRow(run, workflowTitle) {
|
|
37
|
+
const inputs = Object.entries(run.params ?? {}).map(([k, v]) => `${k}: ${v}`).join(' · ');
|
|
38
|
+
const people = [...new Set([...(run.decisions ?? []), ...(run.answers ?? [])].map((d) => d.by).filter((b) => Boolean(b)))];
|
|
39
|
+
return {
|
|
40
|
+
id: run.run_id,
|
|
41
|
+
agent: run.agent,
|
|
42
|
+
workflowId: run.workflow_id,
|
|
43
|
+
workflowTitle: workflowTitle ?? (run.workflow_id || 'One-off job'),
|
|
44
|
+
inputs: short(inputs, 160),
|
|
45
|
+
status: run.status,
|
|
46
|
+
startedAt: run.started_at,
|
|
47
|
+
...(run.finished_at ? { finishedAt: run.finished_at } : {}),
|
|
48
|
+
...(run.versions?.brief ? { briefVersion: run.versions.brief } : {}),
|
|
49
|
+
people,
|
|
50
|
+
outcome: short(run.status === 'error' ? run.error ?? '' : run.result ?? '', 200),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The page with its filters' choices in it (agents, workflows, people),
|
|
2
|
+
* so they show at once instead of after another request. */
|
|
3
|
+
export declare function auditPageFor(filters: {
|
|
4
|
+
agents: {
|
|
5
|
+
name: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}[];
|
|
8
|
+
workflows: {
|
|
9
|
+
agent: string;
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
}[];
|
|
13
|
+
people: string[];
|
|
14
|
+
}): string;
|
|
15
|
+
export declare const auditPageHtml: string;
|