loopengine 0.4.14 → 0.5.0
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 +71 -8
- package/dist/core/audit-store.js +206 -12
- package/dist/core/input-schema.d.ts +47 -0
- package/dist/core/input-schema.js +180 -0
- package/dist/core/output-schema.d.ts +30 -0
- package/dist/core/output-schema.js +105 -0
- package/dist/core/run-agent.js +35 -2
- package/dist/core/scheduler.d.ts +6 -0
- package/dist/core/scheduler.js +22 -16
- package/dist/core/trace.d.ts +34 -0
- package/dist/core/trace.js +149 -0
- package/dist/core/workflow-runs.d.ts +30 -5
- package/dist/core/workflow-runs.js +62 -12
- package/dist/core/workflow-triggers.d.ts +8 -1
- package/dist/core/workflow-triggers.js +13 -0
- package/dist/core/workflows.d.ts +17 -1
- package/dist/core/workflows.js +72 -9
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/web/agents-config-page.js +372 -67
- package/dist/web/audit-admin.d.ts +2 -2
- package/dist/web/audit-admin.js +5 -3
- package/dist/web/audit-page.js +7 -5
- package/dist/web/change-log.js +4 -2
- package/dist/web/console-shell.js +1 -1
- package/dist/web/decide-page.js +1 -1
- package/dist/web/goals-admin.d.ts +8 -5
- package/dist/web/goals-admin.js +25 -5
- package/dist/web/goals-page.js +8 -2
- package/dist/web/inbox-page.js +143 -1
- package/dist/web/run-trace.d.ts +114 -0
- package/dist/web/run-trace.js +79 -0
- package/dist/web/workflow-admin.d.ts +12 -3
- package/dist/web/workflow-admin.js +42 -7
- package/dist/web/workflow-audit-report.js +5 -5
- package/dist/web/workflow-audit.d.ts +3 -3
- package/dist/web/workflow-audit.js +12 -11
- package/dist/web/workflow-drafts.d.ts +75 -0
- package/dist/web/workflow-drafts.js +112 -0
- package/dist/web/workflow-evidence.d.ts +17 -4
- package/dist/web/workflow-evidence.js +22 -6
- package/dist/web/workflow-health.d.ts +2 -2
- package/dist/web/workflow-health.js +7 -1
- package/package.json +9 -1
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
25
25
|
import { dirname, join } from 'node:path';
|
|
26
26
|
import { randomUUID } from 'node:crypto';
|
|
27
|
+
import { checkOutput } from '#core/output-schema.js';
|
|
27
28
|
import { editAmount } from './goals-admin.js';
|
|
28
29
|
export class EvidenceError extends Error {
|
|
29
30
|
}
|
|
@@ -80,6 +81,9 @@ export function runFeedbackFrom(run, body) {
|
|
|
80
81
|
at: new Date().toISOString(),
|
|
81
82
|
};
|
|
82
83
|
}
|
|
84
|
+
/** The check every round adds for a workflow with an output schema: its
|
|
85
|
+
* result matches the schema (core/output-schema.ts), checked in code. */
|
|
86
|
+
export const OUTPUT_SCHEMA_CRITERION = { id: 'output-schema', text: 'Matches the output schema', kind: 'output_schema' };
|
|
83
87
|
const MAX_CASES = 30;
|
|
84
88
|
const MAX_ROUNDS = 10;
|
|
85
89
|
const MAX_CRITERIA = 8;
|
|
@@ -140,6 +144,14 @@ export function removeEvalCase(agentDir, workflowId, caseId) {
|
|
|
140
144
|
/** Replaces the workflow's criteria. Each needs its words; a code check
|
|
141
145
|
* needs its value. */
|
|
142
146
|
export function setEvalCriteria(agentDir, workflowId, input) {
|
|
147
|
+
const criteria = checkEvalCriteria(input);
|
|
148
|
+
const evals = readEvals(agentDir, workflowId);
|
|
149
|
+
writeEvals(agentDir, workflowId, { ...evals, criteria });
|
|
150
|
+
return criteria;
|
|
151
|
+
}
|
|
152
|
+
/** Criteria as given, checked (each its words, a value where its kind
|
|
153
|
+
* needs one, at most MAX_CRITERIA), without saving them. */
|
|
154
|
+
export function checkEvalCriteria(input) {
|
|
143
155
|
if (!Array.isArray(input))
|
|
144
156
|
throw new EvidenceError('criteria must be a list.');
|
|
145
157
|
if (input.length > MAX_CRITERIA)
|
|
@@ -160,8 +172,6 @@ export function setEvalCriteria(agentDir, workflowId, input) {
|
|
|
160
172
|
used.add(id);
|
|
161
173
|
return { id, text, kind, ...(value && kind !== 'judge' && kind !== 'reference' ? { value } : {}) };
|
|
162
174
|
});
|
|
163
|
-
const evals = readEvals(agentDir, workflowId);
|
|
164
|
-
writeEvals(agentDir, workflowId, { ...evals, criteria });
|
|
165
175
|
return criteria;
|
|
166
176
|
}
|
|
167
177
|
/** The criteria a round checks: the workflow's, or with none set,
|
|
@@ -184,6 +194,12 @@ export function codeCheck(criterion, run) {
|
|
|
184
194
|
const called = run.tools.some((t) => t.toLowerCase() === value);
|
|
185
195
|
return { criterionId: criterion.id, pass: !called, ...(called ? { reason: `It called ${criterion.value}.` } : {}) };
|
|
186
196
|
}
|
|
197
|
+
case 'output_schema': {
|
|
198
|
+
if (!run.outputSchema)
|
|
199
|
+
return { criterionId: criterion.id, pass: true };
|
|
200
|
+
const check = checkOutput(run.outputSchema, run.result);
|
|
201
|
+
return { criterionId: criterion.id, pass: check.ok, ...(check.ok ? {} : { reason: check.errors.join('; ').slice(0, 500) }) };
|
|
202
|
+
}
|
|
187
203
|
default: return undefined;
|
|
188
204
|
}
|
|
189
205
|
}
|
|
@@ -228,7 +244,7 @@ export async function checkCase(judge, input) {
|
|
|
228
244
|
const error = input.run.error;
|
|
229
245
|
return applies.map((c) => ({ criterionId: c.id, pass: false, reason: `The run failed: ${error.slice(0, 200)}` }));
|
|
230
246
|
}
|
|
231
|
-
const run = input.run;
|
|
247
|
+
const run = { ...input.run, ...(input.outputSchema ? { outputSchema: input.outputSchema } : {}) };
|
|
232
248
|
const coded = new Map(applies.flatMap((c) => { const r = codeCheck(c, run); return r ? [[c.id, r]] : []; }));
|
|
233
249
|
const forJudge = applies.filter((c) => !coded.has(c.id));
|
|
234
250
|
let judged = new Map();
|
|
@@ -302,7 +318,7 @@ export function startEvalRound(deps) {
|
|
|
302
318
|
const cases = evals.cases;
|
|
303
319
|
const startedAt = new Date().toISOString();
|
|
304
320
|
writeEvals(deps.agentDir, deps.workflowId, { ...evals, running: { startedAt, done: 0, total: cases.length } });
|
|
305
|
-
const criteria = effectiveCriteria(evals);
|
|
321
|
+
const criteria = [...effectiveCriteria(evals), ...(deps.outputSchema ? [OUTPUT_SCHEMA_CRITERION] : [])];
|
|
306
322
|
return (async () => {
|
|
307
323
|
const results = [];
|
|
308
324
|
for (const c of cases) {
|
|
@@ -313,7 +329,7 @@ export function startEvalRound(deps) {
|
|
|
313
329
|
catch (err) {
|
|
314
330
|
run = { error: err instanceof Error ? err.message : String(err) };
|
|
315
331
|
}
|
|
316
|
-
const checks = await checkCase(deps.judge, { instructions: deps.instructions, criteria, reference: c.reference ?? '', run });
|
|
332
|
+
const checks = await checkCase(deps.judge, { instructions: deps.instructions, criteria, reference: c.reference ?? '', ...(deps.outputSchema ? { outputSchema: deps.outputSchema } : {}), run });
|
|
317
333
|
results.push({
|
|
318
334
|
caseId: c.id,
|
|
319
335
|
...('error' in run ? { error: run.error } : { result: run.result.slice(0, 20000), tools: [...new Set(run.tools)], ...(run.standIns?.length ? { standIns: run.standIns.slice(0, 50) } : {}) }),
|
|
@@ -324,7 +340,7 @@ export function startEvalRound(deps) {
|
|
|
324
340
|
}
|
|
325
341
|
const round = {
|
|
326
342
|
at: startedAt,
|
|
327
|
-
...(deps.
|
|
343
|
+
...(deps.workflowVersion ? { workflowVersion: deps.workflowVersion } : {}),
|
|
328
344
|
model: deps.model,
|
|
329
345
|
judge: deps.judgeLabel,
|
|
330
346
|
cases: results,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WorkflowRun } from '../core/workflow-runs.js';
|
|
2
2
|
export interface HealthNumbers {
|
|
3
3
|
runs: number;
|
|
4
4
|
/** Finished, done or failed. */
|
|
@@ -22,7 +22,7 @@ export interface HealthNumbers {
|
|
|
22
22
|
pricedRuns: number;
|
|
23
23
|
}
|
|
24
24
|
export interface HealthVersion extends HealthNumbers {
|
|
25
|
-
/** The
|
|
25
|
+
/** The workflow version, or null for runs from before versions. */
|
|
26
26
|
version: number | null;
|
|
27
27
|
/** Its first and last run in the period. */
|
|
28
28
|
from: string;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// A workflow's health (the workflow page's Health panel): how its runs
|
|
2
|
+
// went over the last 30 days, per workflow version and day by day, and an
|
|
3
|
+
// alert when a measure suddenly gets worse. Built from the runs
|
|
4
|
+
// (core/workflow-runs.ts: status, decisions, answers, feedback, the brief
|
|
5
|
+
// version each ran under) and their model calls' cost (core/usage.ts).
|
|
6
|
+
import { workflowVersionOf } from '../core/workflow-runs.js';
|
|
1
7
|
const DAY = 24 * 60 * 60 * 1000;
|
|
2
8
|
function numbers(runs, costs) {
|
|
3
9
|
const finished = runs.filter((r) => r.status === 'done' || r.status === 'error');
|
|
@@ -59,7 +65,7 @@ export function workflowHealth(runs, costs, options = {}) {
|
|
|
59
65
|
const inPeriod = runs.filter((r) => r.started_at >= since).sort((a, b) => a.started_at.localeCompare(b.started_at));
|
|
60
66
|
const byVersion = new Map();
|
|
61
67
|
for (const r of inPeriod) {
|
|
62
|
-
const v = r
|
|
68
|
+
const v = workflowVersionOf(r) ?? null;
|
|
63
69
|
byVersion.set(v, [...(byVersion.get(v) ?? []), r]);
|
|
64
70
|
}
|
|
65
71
|
const versions = [...byVersion.entries()]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loopengine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"dist/core/trusted-proxy.d.ts",
|
|
48
48
|
"dist/core/audit-store.js",
|
|
49
49
|
"dist/core/audit-store.d.ts",
|
|
50
|
+
"dist/core/trace.js",
|
|
51
|
+
"dist/core/trace.d.ts",
|
|
52
|
+
"dist/core/output-schema.js",
|
|
53
|
+
"dist/core/output-schema.d.ts",
|
|
54
|
+
"dist/core/input-schema.js",
|
|
55
|
+
"dist/core/input-schema.d.ts",
|
|
50
56
|
"dist/core/workspace-roles.js",
|
|
51
57
|
"dist/core/workspace-roles.d.ts",
|
|
52
58
|
"dist/core/unattended.js",
|
|
@@ -166,6 +172,8 @@
|
|
|
166
172
|
"@anthropic-ai/sdk": "^0.116.0",
|
|
167
173
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
168
174
|
"actauth": "^0.0.12",
|
|
175
|
+
"ajv": "^8.20.0",
|
|
176
|
+
"ajv-formats": "^3.0.1",
|
|
169
177
|
"ioredis": "^6.0.0",
|
|
170
178
|
"openai": "^7.4.0",
|
|
171
179
|
"semver": "^7.8.5",
|