@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.42
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/CHANGELOG.md +130 -0
- package/NOTICE +2 -0
- package/README.md +149 -21
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- package/dist/calendar/address.d.ts +49 -0
- package/dist/calendar/address.js +153 -0
- package/dist/calendar/fetch.d.ts +24 -0
- package/dist/calendar/fetch.js +146 -0
- package/dist/calendar/ics-faux.d.ts +39 -0
- package/dist/calendar/ics-faux.js +236 -0
- package/dist/calendar/labels.d.ts +3 -0
- package/dist/calendar/labels.js +61 -0
- package/dist/calendar/names.d.ts +52 -0
- package/dist/calendar/names.js +54 -0
- package/dist/calendar/parse.d.ts +108 -0
- package/dist/calendar/parse.js +625 -0
- package/dist/calendar/routes.d.ts +17 -0
- package/dist/calendar/routes.js +81 -0
- package/dist/calendar/tools.d.ts +23 -0
- package/dist/calendar/tools.js +124 -0
- package/dist/cli.js +22 -6
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- package/dist/computer-record.d.ts +55 -0
- package/dist/computer-record.js +315 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +15 -2
- package/dist/computers.d.ts +11 -1
- package/dist/computers.js +23 -26
- package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +72 -0
- package/dist/eval-mailbox.d.ts +4 -1
- package/dist/eval-mailbox.js +11 -3
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +42 -0
- package/dist/feed/parse.js +291 -0
- package/dist/feed/pointer.d.ts +2 -0
- package/dist/feed/pointer.js +17 -0
- package/dist/file-types.js +1 -0
- package/dist/host-command.d.ts +3 -0
- package/dist/host-command.js +18 -0
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/learn/check.d.ts +17 -1
- package/dist/learn/check.js +240 -5
- package/dist/learn/compile.d.ts +48 -27
- package/dist/learn/compile.js +134 -101
- package/dist/learn/promote.d.ts +61 -5
- package/dist/learn/promote.js +12 -2
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/learning-setting.d.ts +23 -0
- package/dist/learning-setting.js +51 -0
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +3 -0
- package/dist/learning.d.ts +3 -2
- package/dist/learning.js +5 -3
- package/dist/mcp-oauth.d.ts +23 -1
- package/dist/mcp-oauth.js +46 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +151 -21
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-reads-over-store.d.ts +5 -1
- package/dist/run-reads-over-store.js +8 -4
- package/dist/run-recordings.d.ts +20 -0
- package/dist/run-recordings.js +133 -0
- package/dist/run-secrets.js +12 -4
- package/dist/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +94 -16
- package/dist/runner/adapter-run-spec.d.ts +19 -0
- package/dist/runner/adapter-run-spec.js +57 -36
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +41 -32
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +22 -40
- package/dist/runner/learning-end.d.ts +17 -7
- package/dist/runner/learning-end.js +79 -53
- package/dist/runner/main.d.ts +12 -1
- package/dist/runner/main.js +31 -4
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +6 -2
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +4 -2
- package/dist/runner/model-route.js +8 -8
- package/dist/runner/promotion.d.ts +44 -4
- package/dist/runner/promotion.js +323 -21
- package/dist/runner/reflect-hook.d.ts +5 -0
- package/dist/runner/reflect-hook.js +22 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +6 -11
- package/dist/runner/workflow-first.js +16 -20
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +21 -7
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +5 -3
- package/dist/server.d.ts +31 -5
- package/dist/server.js +240 -61
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +11 -3
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +64 -10
- package/dist/store/store.d.ts +38 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +6 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +8 -2
- package/dist/template-eval.d.ts +11 -0
- package/dist/template-eval.js +177 -52
- package/dist/templates.d.ts +13 -1
- package/dist/templates.js +89 -18
- package/dist/timeline/computer.js +2 -1
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-adapter.d.ts +9 -4
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +420 -0
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +23 -5
- package/dist/validate.js +7 -2
- package/dist/webhooks.js +9 -5
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +35 -4
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +34 -22
- package/package.json +11 -9
- package/templates/README.md +38 -4
- package/dist/console/assets/index-Jbxjcmdp.js +0 -705
package/dist/template-eval.js
CHANGED
|
@@ -23,7 +23,9 @@ import { inputMessage } from "./run-manifest.js";
|
|
|
23
23
|
import { shownUrl } from "./mcp-probe.js";
|
|
24
24
|
import { isMonidName, MCP_SERVER_NAME, MCP_TOOL_NAME, mcpNameOf, mcpToolName, monidNameOf, parseToolName } from "./tool-names.js";
|
|
25
25
|
import { evalClock, LAYOUTS, mailboxAfter, mailboxFixtureOf, mailboxText, mailboxVerdict, seed, seededFaux, snapshot } from "./eval-mailbox.js";
|
|
26
|
+
import { caseFeeds, feedFixtureOf } from "./eval-feed.js";
|
|
26
27
|
import { EMAIL_TOOLS } from "./email/names.js";
|
|
28
|
+
import { CALENDAR_EVENTS } from "./calendar/names.js";
|
|
27
29
|
import { settingsKeyOf, shellToolOf } from "./tool-gate.js";
|
|
28
30
|
import { webShownOf } from "./timeline/index.js";
|
|
29
31
|
import { ASK_TOOL, BOUND_TOOLS } from "./tools.js";
|
|
@@ -32,7 +34,7 @@ import { WEB_FETCH_TOOL } from "./web-fetch.js";
|
|
|
32
34
|
import { WEB_SEARCH_TOOL } from "./web-search.js";
|
|
33
35
|
import { dayIn, serverZone } from "./environment.js";
|
|
34
36
|
import { instantOf } from "./trigger-adapter.js";
|
|
35
|
-
import { applyBodyOf, compiled, filledPins, onServerName, onServers, packageView, readPackage } from "./templates.js";
|
|
37
|
+
import { applyBodyOf, compiled, filledPins, filledSource, onServerName, onServers, packageView, readPackage } from "./templates.js";
|
|
36
38
|
import { inputIssues, inputSchemaOf, isObject, MODEL_REF } from "./validate.js";
|
|
37
39
|
/** What a grader run is told, whatever the rubric: blind, strict, and its verdict as one JSON block. */
|
|
38
40
|
export const GRADER_INSTRUCTIONS = `You grade one run of an AI agent against one rubric. You see the rubric, the task the agent was given, its answer, and the tool calls it made; nothing else, and nothing else matters.
|
|
@@ -63,7 +65,7 @@ export const EVAL_HARNESSES = "agentrun-eval-harnesses";
|
|
|
63
65
|
export const ON_DATA_WITH_SERVER = "--on-data is the data folder of the eval's own server, and --server names another server: give one of them";
|
|
64
66
|
const FRONT = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
65
67
|
const PROMPT_FIELDS = ["description", "runs", "max_cost_usd", "input"];
|
|
66
|
-
const CASE_FIELDS = ["parameters", "grants", "mcp", "web", "monid", "learning", "now", "email"];
|
|
68
|
+
const CASE_FIELDS = ["parameters", "grants", "mcp", "web", "monid", "learning", "now", "email", "calendar", "feed"];
|
|
67
69
|
const GRADER_FIELDS = {
|
|
68
70
|
llm: ["type", "target"],
|
|
69
71
|
regex: ["type", "pattern", "flags", "expect", "target"],
|
|
@@ -79,7 +81,7 @@ const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule each fake MCP server li
|
|
|
79
81
|
/** A host name on this machine: a case with fake MCP servers needs a server here, which reaches them on loopback. */
|
|
80
82
|
const LOOPBACK_HOST = /^(?:127\.\d+\.\d+\.\d+|localhost|\[::1\])$/; // key-gate: loopback-rule a server on this machine reaches the fakes
|
|
81
83
|
/** A case's fields that the eval's own runner alone binds (EvalFakes), each with what it does: a named server refuses them. */
|
|
82
|
-
const OWN_SERVER_FAKES = [["web", "web fakes the web tools"], ["now", "now sets its runs' clock"], ["monid", "monid fakes the package's monid endpoints"], ["email", "email fakes the server's email account"]];
|
|
84
|
+
const OWN_SERVER_FAKES = [["web", "web fakes the web tools"], ["now", "now sets its runs' clock"], ["monid", "monid fakes the package's monid endpoints"], ["email", "email fakes the server's email account"], ["calendar", "calendar fakes the server's calendar"], ["feed", "feed fakes the package's feeds"]];
|
|
83
85
|
/** A case's run input: its prompt's body as content (none when empty), then its typed fields. */
|
|
84
86
|
export const runInput = (content, fields) => ({ ...(content ? { content } : {}), ...fields });
|
|
85
87
|
/** Cases that do not check: every problem, each naming its file. */
|
|
@@ -273,7 +275,8 @@ function graderOfType(p, file, text, bad) {
|
|
|
273
275
|
* fixture, each learned note as the learning API checks one, and each grader's fields. Nothing runs. PackageError or
|
|
274
276
|
* CaseError with every problem found. */
|
|
275
277
|
export function readCases(dir, names) {
|
|
276
|
-
|
|
278
|
+
// The cases are read below, each fixture checked there in the case's own words (a CaseError), not by the package read.
|
|
279
|
+
const pkg = readPackage(dir, { evalFixtures: false });
|
|
277
280
|
const problems = [];
|
|
278
281
|
const missing = (names ?? []).filter((name) => !pkg.evals.includes(name));
|
|
279
282
|
if (missing.length)
|
|
@@ -304,7 +307,7 @@ export function readCases(dir, names) {
|
|
|
304
307
|
for (const field of unknown(c, CASE_FIELDS))
|
|
305
308
|
bad(`${at}/case.yaml: no field ${field}: its fields are ${CASE_FIELDS.join(", ")}`);
|
|
306
309
|
// An email case's run is on its trigger's input, and its prompt gives none (`email` below holds it to that).
|
|
307
|
-
if (c.email === undefined)
|
|
310
|
+
if (c.email === undefined && c.feed === undefined)
|
|
308
311
|
for (const issue of inputIssues(runInput(body, fields), inputSchemaOf(pkg.inputSchema)))
|
|
309
312
|
bad(`${at}/prompt.md: ${issue.message}`);
|
|
310
313
|
if (c.parameters !== undefined && !isObject(c.parameters))
|
|
@@ -419,6 +422,55 @@ export function readCases(dir, names) {
|
|
|
419
422
|
if (body || fields || f.max_cost_usd !== undefined)
|
|
420
423
|
bad(`${at}/prompt.md: an email case's run is started by the package's trigger, on the trigger's input and cap: its prompt.md holds description and runs alone`);
|
|
421
424
|
}
|
|
425
|
+
// The case's calendar: an iCalendar file in the case, served by a fake calendar server as the server's calendar.
|
|
426
|
+
let calendar;
|
|
427
|
+
if (c.calendar !== undefined) {
|
|
428
|
+
const path = inside(root, c.calendar, "file");
|
|
429
|
+
if (!path || !path.endsWith(".ics"))
|
|
430
|
+
bad(`${at}/case.yaml: calendar is an iCalendar file (.ics) in the case (not ${JSON.stringify(c.calendar)})`);
|
|
431
|
+
else {
|
|
432
|
+
const text = readFileSync(join(root, path), "utf8");
|
|
433
|
+
if (!/^\uFEFF?\s*BEGIN:VCALENDAR\b/i.test(text))
|
|
434
|
+
bad(`${at}/${path}: is not an iCalendar file (one that starts BEGIN:VCALENDAR)`);
|
|
435
|
+
else
|
|
436
|
+
calendar = { file: path, text };
|
|
437
|
+
}
|
|
438
|
+
if (!(pkg.tools ?? []).includes(CALENDAR_EVENTS))
|
|
439
|
+
bad(`${at}/case.yaml: calendar fakes the server's calendar, and the package's tools don't name ${CALENDAR_EVENTS}`);
|
|
440
|
+
}
|
|
441
|
+
// The case's fake feed: its fixture, and the package's feed trigger its runs start from (eval-feed.ts).
|
|
442
|
+
let feed;
|
|
443
|
+
if (c.feed !== undefined) {
|
|
444
|
+
const path = inside(root, c.feed, "file");
|
|
445
|
+
let parsed;
|
|
446
|
+
if (c.email !== undefined)
|
|
447
|
+
bad(`${at}/case.yaml: a case's run is started by one trigger: email or feed, not both`);
|
|
448
|
+
if (!path)
|
|
449
|
+
bad(`${at}/case.yaml: feed is a feed fixture file in the case (not ${JSON.stringify(c.feed)})`);
|
|
450
|
+
else {
|
|
451
|
+
try {
|
|
452
|
+
parsed = JSON.parse(readFileSync(join(root, path), "utf8"));
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
bad(`${at}/${path}: is not JSON (${error.message})`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const fixture = parsed === undefined ? undefined : feedFixtureOf(parsed, `${at}/${path}`, bad);
|
|
459
|
+
const kindOf = (t) => (isObject(t.source) ? t.source.kind : undefined);
|
|
460
|
+
const named = fixture?.trigger === undefined ? undefined : pkg.triggers.find((t) => t.name === fixture.trigger);
|
|
461
|
+
const starts = named ? [named] : pkg.triggers.filter((t) => kindOf(t) === "feed");
|
|
462
|
+
if (!fixture)
|
|
463
|
+
undefined;
|
|
464
|
+
else if (fixture.trigger !== undefined && !named)
|
|
465
|
+
bad(`${at}/${path}: trigger ${fixture.trigger} is not one of the package's triggers (${pkg.triggers.map((t) => String(t.name)).join(", ") || "none"})`);
|
|
466
|
+
else if (starts.length !== 1 || kindOf(starts[0]) !== "feed")
|
|
467
|
+
bad(`${at}/${path}: a feed case starts its run through the package's feed trigger, and ${named ? `${fixture.trigger} is a ${String(kindOf(named))} trigger` : starts.length ? `the package has ${starts.length}: name one with trigger` : "the package has none"}`);
|
|
468
|
+
else
|
|
469
|
+
feed = { ...fixture, trigger: String(starts[0].name) };
|
|
470
|
+
// Its run is the trigger's, on the trigger's input and cap: the prompt gives neither.
|
|
471
|
+
if (body || fields || f.max_cost_usd !== undefined)
|
|
472
|
+
bad(`${at}/prompt.md: a feed case's run is started by the package's trigger, on the trigger's input and cap: its prompt.md holds description and runs alone`);
|
|
473
|
+
}
|
|
422
474
|
const learning = [];
|
|
423
475
|
if (c.learning !== undefined) {
|
|
424
476
|
const folder = inside(root, c.learning, "dir");
|
|
@@ -464,7 +516,7 @@ export function readCases(dir, names) {
|
|
|
464
516
|
cases.push({
|
|
465
517
|
name, description: typeof f.description === "string" ? f.description : "", runs: typeof f.runs === "number" ? f.runs : 1,
|
|
466
518
|
...(typeof f.max_cost_usd === "number" ? { maxCostUsd: f.max_cost_usd } : {}), input: body, ...(fields ? { fields } : {}),
|
|
467
|
-
parameters, grants, mcp, ...(web ? { web } : {}), ...(monid ? { monid } : {}), learning, graders, ...(typeof c.now === "string" ? { now: c.now } : {}), ...(email ? { email } : {}),
|
|
519
|
+
parameters, grants, mcp, ...(web ? { web } : {}), ...(monid ? { monid } : {}), learning, graders, ...(typeof c.now === "string" ? { now: c.now } : {}), ...(email ? { email } : {}), ...(calendar ? { calendar } : {}), ...(feed ? { feed } : {}),
|
|
468
520
|
});
|
|
469
521
|
}
|
|
470
522
|
if (problems.length)
|
|
@@ -958,7 +1010,11 @@ export async function evalTemplate(options) {
|
|
|
958
1010
|
throw new CaseError(options.dir, refused);
|
|
959
1011
|
// Each run's fakes, by the agent the eval made for it (runOnce), which the runner beside the server reads at the claim.
|
|
960
1012
|
const fakes = new Map();
|
|
961
|
-
const clock = !options.server && cases.some((one) => one.email) ? evalClock() : undefined;
|
|
1013
|
+
const clock = !options.server && cases.some((one) => one.email || one.feed) ? evalClock() : undefined;
|
|
1014
|
+
// Where the eval's own server reads each feed: the running feed case's fakes (feedRun). A feed no case routes (a feed
|
|
1015
|
+
// trigger of the package's that the eval deletes once the apply made it, read at its creation) is served nowhere: its
|
|
1016
|
+
// read is unreachable at once, never sent, so no eval reads a real feed.
|
|
1017
|
+
const feedRoutes = {};
|
|
962
1018
|
const started = new Date().toISOString();
|
|
963
1019
|
const scratch = options.server ? undefined : mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "agentrun-eval-"));
|
|
964
1020
|
// The in-process server's data: the owner's folder (options.data), which stays, or one in the scratch, gone with it.
|
|
@@ -991,7 +1047,7 @@ export async function evalTemplate(options) {
|
|
|
991
1047
|
// A token of its own on a scratch folder. On the owner's folder none is given: a given token makes the server remove
|
|
992
1048
|
// the folder's .token (server.ts), the owner's saved API token, so the eval's server reads the one the folder keeps,
|
|
993
1049
|
// and a .token it had to make there (the folder had none) goes when it closes, the folder as it was.
|
|
994
|
-
const serve = await startServe({ mcpLoopback: true, mcpStandIns: true, data: data, port: 0, ...(options.data === undefined ? { token: randomBytes(24).toString("base64url") } : {}), templates: join(scratch, "templates"), drainTimeout: "5s", harnessInstall, ...(options.serve ?? {}), ...(clock ? { triggerClock: clock } : {}) }).catch((error) => {
|
|
1050
|
+
const serve = await startServe({ mcpLoopback: true, mcpStandIns: true, data: data, port: 0, ...(options.data === undefined ? { token: randomBytes(24).toString("base64url") } : {}), templates: join(scratch, "templates"), drainTimeout: "5s", harnessInstall, feedsAt: (url) => feedRoutes.route?.(url) ?? null, ...(options.serve ?? {}), ...(clock ? { triggerClock: clock } : {}) }).catch((error) => {
|
|
995
1051
|
removeTree(scratch);
|
|
996
1052
|
throw error;
|
|
997
1053
|
});
|
|
@@ -1008,7 +1064,7 @@ export async function evalTemplate(options) {
|
|
|
1008
1064
|
const { withoutFaux } = await import("./model.js");
|
|
1009
1065
|
const serveOptions = options.serve ?? {};
|
|
1010
1066
|
// Its run lines go to stderr: stdout is the eval's report.
|
|
1011
|
-
const beside = await runnerBeside(data, { mcpLoopback: serve.localInstall, evalFakes: (agentId) => fakes.get(agentId), harnessInstall, onLine: (line) => console.error(line), ...(serveOptions.faux ? { env: { ...withoutFaux(process.env), ...fauxEnvOf({ data: data, ...serveOptions }) } } : {}) }).catch(async (error) => {
|
|
1067
|
+
const beside = await runnerBeside(data, { mcpLoopback: serve.localInstall, mcpOwn: serve.own, evalFakes: (agentId) => fakes.get(agentId), harnessInstall, onLine: (line) => console.error(line), ...(serveOptions.faux ? { env: { ...withoutFaux(process.env), ...fauxEnvOf({ data: data, ...serveOptions }) } } : {}) }).catch(async (error) => {
|
|
1012
1068
|
await closeServe();
|
|
1013
1069
|
removeTree(scratch);
|
|
1014
1070
|
throw error;
|
|
@@ -1021,7 +1077,9 @@ export async function evalTemplate(options) {
|
|
|
1021
1077
|
// An email case saves its fake mailbox as the server's email account, a secret write, which the API token never
|
|
1022
1078
|
// makes: the eval owns its own scratch server, so it opens that server's console from its launch link, as the owner
|
|
1023
1079
|
// who started it would, and makes those writes from that session.
|
|
1024
|
-
|
|
1080
|
+
// A calendar case saves its fake calendar as the server's calendar, a secret write too.
|
|
1081
|
+
const calendarCase = cases.some((one) => one.calendar);
|
|
1082
|
+
if ((clock || calendarCase) && serve.launchCode) {
|
|
1025
1083
|
const origin = new URL(serve.baseUrl).origin;
|
|
1026
1084
|
const opened = await fetch(`${origin}/?launch=${encodeURIComponent(serve.launchCode)}`, { redirect: "manual" }).catch(() => undefined);
|
|
1027
1085
|
const cookie = opened?.headers.getSetCookie().map((line) => line.split(";")[0]).join("; ");
|
|
@@ -1042,12 +1100,25 @@ export async function evalTemplate(options) {
|
|
|
1042
1100
|
: `the server on ${options.data} did not say whether it keeps an email account (GET /settings/email ${kept?.status ?? "failed"}), which an email case's fake mailbox would replace: nothing ran`);
|
|
1043
1101
|
}
|
|
1044
1102
|
}
|
|
1103
|
+
// On the owner's folder, a calendar case's fake calendar would replace the calendar its server keeps: refused before
|
|
1104
|
+
// anything runs, the calendar as it was.
|
|
1105
|
+
if (calendarCase && options.data !== undefined) {
|
|
1106
|
+
const kept = await api("GET", "/settings/calendar", undefined, owner).catch(() => undefined);
|
|
1107
|
+
const configured = kept?.status === 200 && isObject(kept.body) && kept.body.configured === true;
|
|
1108
|
+
if (configured || kept?.status !== 200) {
|
|
1109
|
+
await close();
|
|
1110
|
+
removeTree(scratch);
|
|
1111
|
+
throw new Error(configured
|
|
1112
|
+
? `the server on ${options.data} keeps a calendar${isObject(kept.body) && typeof kept.body.name === "string" ? ` (${kept.body.name})` : ""}, and a calendar case saves its fake calendar as the server's calendar in its place: remove it (DELETE /v2/settings/calendar), run the eval, and save it again; or run the eval without --on-data`
|
|
1113
|
+
: `the server on ${options.data} did not say whether it keeps a calendar (GET /settings/calendar ${kept?.status ?? "failed"}), which a calendar case's fake calendar would replace: nothing ran`);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1045
1116
|
}
|
|
1046
1117
|
const results = [];
|
|
1047
1118
|
let grader;
|
|
1048
1119
|
const made = { agents: [], runs: new Set(), triggers: new Set() };
|
|
1049
1120
|
const ctx = {
|
|
1050
|
-
api, pkg, options, made, log, fakes, ...(clock ? { clock } : {}), ...(owner ? { owner } : {}),
|
|
1121
|
+
api, pkg, options, made, log, fakes, feedRoutes, ...(clock ? { clock } : {}), ...(owner ? { owner } : {}),
|
|
1051
1122
|
graderAgent: async () => {
|
|
1052
1123
|
if (grader)
|
|
1053
1124
|
return grader;
|
|
@@ -1102,6 +1173,7 @@ async function runCase(ctx, one) {
|
|
|
1102
1173
|
const saved = [];
|
|
1103
1174
|
const runs = [];
|
|
1104
1175
|
const total = options.runs ?? one.runs;
|
|
1176
|
+
let calendarFaux;
|
|
1105
1177
|
// A server an owner keeps (--server, or the owner's folder with --on-data): its MCP servers are the owner's.
|
|
1106
1178
|
const owners = Boolean(options.server) || options.data !== undefined;
|
|
1107
1179
|
try {
|
|
@@ -1126,6 +1198,13 @@ async function runCase(ctx, one) {
|
|
|
1126
1198
|
if (owners && !(await ownsFake(api, name, fake.url)))
|
|
1127
1199
|
throw new ApiFailure(`another eval saved its own MCP server named ${name} on this server meanwhile: run one eval of this package at a time on a server`);
|
|
1128
1200
|
}
|
|
1201
|
+
// A calendar case's fake calendar, on loopback, saved as the server's calendar for all its runs (a read-only fake: no
|
|
1202
|
+
// run changes it).
|
|
1203
|
+
if (one.calendar) {
|
|
1204
|
+
const { startIcsFaux } = await import("./calendar/ics-faux.js");
|
|
1205
|
+
calendarFaux = await startIcsFaux({ text: one.calendar.text });
|
|
1206
|
+
expectOk("saving the case's fake calendar as the server's calendar", await api("PUT", "/settings/calendar", { url: calendarFaux.address }, ctx.owner));
|
|
1207
|
+
}
|
|
1129
1208
|
// An email case's runs repeat on each of its mailbox's layouts, each run on a fake account of its own.
|
|
1130
1209
|
const layouts = one.email ? one.email.layouts : [undefined];
|
|
1131
1210
|
for (const layout of layouts) {
|
|
@@ -1133,7 +1212,7 @@ async function runCase(ctx, one) {
|
|
|
1133
1212
|
options.signal?.throwIfAborted();
|
|
1134
1213
|
for (const fake of fakes)
|
|
1135
1214
|
fake.calls.length = 0;
|
|
1136
|
-
const result = layout ? await mailRun(ctx, one, n, fakes, layout) : await runOnce(ctx, one, n, fakes);
|
|
1215
|
+
const result = layout ? await mailRun(ctx, one, n, fakes, layout) : one.feed ? await feedRun(ctx, one, n, fakes) : await runOnce(ctx, one, n, fakes);
|
|
1137
1216
|
log(`case ${one.name} run ${n}${layout ? ` (${layout})` : ""}: ${result.status}, ${result.pass ? "pass" : "FAIL"}${result.cost_usd === null ? "" : ` (${usd(result.cost_usd)})`}`);
|
|
1138
1217
|
runs.push(result);
|
|
1139
1218
|
}
|
|
@@ -1161,6 +1240,13 @@ async function runCase(ctx, one) {
|
|
|
1161
1240
|
if (removed.status !== 204 && removed.status !== 404)
|
|
1162
1241
|
ctx.log(`case ${one.name}: the server's email account (the case's fake mailbox) was not removed: DELETE /settings/email ${removed.status} ${JSON.stringify(removed.body).slice(0, 200)}`);
|
|
1163
1242
|
}
|
|
1243
|
+
// The eval's own server's calendar was the case's fake calendar, gone with it; a removal that fails is said.
|
|
1244
|
+
if (one.calendar) {
|
|
1245
|
+
const removed = await api("DELETE", "/settings/calendar", undefined, ctx.owner).catch((error) => ({ status: 0, body: error.message }));
|
|
1246
|
+
if (removed.status !== 204 && removed.status !== 404)
|
|
1247
|
+
ctx.log(`case ${one.name}: the server's calendar (the case's fake calendar) was not removed: DELETE /settings/calendar ${removed.status} ${JSON.stringify(removed.body).slice(0, 200)}`);
|
|
1248
|
+
await calendarFaux?.close();
|
|
1249
|
+
}
|
|
1164
1250
|
}
|
|
1165
1251
|
}
|
|
1166
1252
|
/** What the stopped server on `data` would do on its own once started, said ("1 enabled trigger, 2 runs not ended"), or
|
|
@@ -1206,26 +1292,48 @@ async function mailRun(ctx, one, n, fakes, layout) {
|
|
|
1206
1292
|
await faux.close();
|
|
1207
1293
|
}
|
|
1208
1294
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
async function
|
|
1295
|
+
/** One run of a feed case: its fake feeds started from the case's fixture, the trigger's URLs (filled from the case's
|
|
1296
|
+
* parameters, as the apply fills them) routed to them before the apply makes the trigger, the run started as the
|
|
1297
|
+
* package's trigger starts it (runOnce), then the fakes closed: runs never share one. */
|
|
1298
|
+
async function feedRun(ctx, one, n, fakes) {
|
|
1299
|
+
const fixture = one.feed;
|
|
1300
|
+
const source = filledSource(ctx.pkg, fixture.trigger, one.parameters);
|
|
1301
|
+
const urls = Array.isArray(source?.urls) ? source.urls.filter((url) => typeof url === "string") : [];
|
|
1302
|
+
if (!urls.length)
|
|
1303
|
+
throw new ApiFailure(`the package's trigger ${fixture.trigger} names no feed URL with the case's parameters`);
|
|
1304
|
+
const feeds = await caseFeeds(fixture, urls, typeof source?.items === "string" ? source.items : undefined, typeof source?.id === "string" ? source.id : undefined);
|
|
1305
|
+
ctx.feedRoutes.route = feeds.route;
|
|
1306
|
+
try {
|
|
1307
|
+
return await runOnce(ctx, one, n, fakes, undefined, feeds);
|
|
1308
|
+
}
|
|
1309
|
+
finally {
|
|
1310
|
+
ctx.feedRoutes.route = undefined;
|
|
1311
|
+
await feeds.close();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
/** The run of an email or feed case's trigger: its first poll waited on at the apply, on what the fake held then (the
|
|
1315
|
+
* history), then the case's new message or item delivered (`deliver`, given the trigger as it reads), and the trigger's
|
|
1316
|
+
* own next time come on the eval's clock, so its poll (or its schedule) fires through the engine's path; the run is its
|
|
1317
|
+
* firing's. `hint`: what to add when it starts none. */
|
|
1318
|
+
async function triggerRun(ctx, name, agentId, triggerId, deliver, hint) {
|
|
1213
1319
|
const { api, options } = ctx;
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1320
|
+
const read = () => api("GET", `/triggers/${encodeURIComponent(triggerId)}`).then((answered) => expectOk(`reading the package's trigger ${name}`, answered));
|
|
1321
|
+
const firings = async () => expectOk(`reading the firings of ${name}`, await api("GET", `/triggers/${encodeURIComponent(triggerId)}/firings`)).firings ?? [];
|
|
1322
|
+
const deadline = Date.now() + (options.queueTimeoutMs ?? QUEUE_TIMEOUT_MS);
|
|
1323
|
+
// Its first poll takes its start (the apply kicks it, and answers once it has or at FIRST_POLL_WAIT_MS, if slower): the
|
|
1324
|
+
// case's mail or item goes in only once that poll has read, or it would be part of the start and fire nothing, and the
|
|
1325
|
+
// clock moves only once that poll has set the next time, or the poll's next time would be a tick past the clock's.
|
|
1326
|
+
let trigger = await read();
|
|
1327
|
+
while (trigger.last_check === null && trigger.enabled === true && Date.now() < deadline) {
|
|
1328
|
+
options.signal?.throwIfAborted();
|
|
1329
|
+
await sleep(100);
|
|
1330
|
+
trigger = await read();
|
|
1331
|
+
}
|
|
1217
1332
|
const known = new Set((await firings()).map((f) => String(f.key)));
|
|
1218
|
-
|
|
1219
|
-
// The new message arrives where the trigger watches: its source's mailbox (INBOX by default).
|
|
1220
|
-
const watched = isObject(trigger.source) && typeof trigger.source.mailbox === "string" ? trigger.source.mailbox : "INBOX";
|
|
1221
|
-
if (fixture.message)
|
|
1222
|
-
seed(mail.faux, mail.layout, watched, fixture.message);
|
|
1223
|
-
// What the account holds before the run: what it adds or moves is read against this.
|
|
1224
|
-
const before = snapshot(mail.faux);
|
|
1333
|
+
deliver(trigger);
|
|
1225
1334
|
if (typeof trigger.next_at !== "string")
|
|
1226
|
-
throw new ApiFailure(`the package's trigger ${
|
|
1335
|
+
throw new ApiFailure(`the package's trigger ${name} has no next time to fire at${isObject(trigger.disabled) ? ` (it is off: ${String(trigger.disabled.detail ?? trigger.disabled.reason)})` : ""}`);
|
|
1227
1336
|
ctx.clock.to(Date.parse(trigger.next_at));
|
|
1228
|
-
const deadline = Date.now() + (options.queueTimeoutMs ?? QUEUE_TIMEOUT_MS);
|
|
1229
1337
|
for (;;) {
|
|
1230
1338
|
options.signal?.throwIfAborted();
|
|
1231
1339
|
const fresh = (await firings()).filter((f) => !known.has(String(f.key)));
|
|
@@ -1233,25 +1341,25 @@ async function triggerRun(ctx, one, agentId, triggerId, mail) {
|
|
|
1233
1341
|
if (started) {
|
|
1234
1342
|
ctx.made.runs.add(String(started.run_id));
|
|
1235
1343
|
// Off at once, before the run is waited on or graded: a repeating schedule (or a second message) would start
|
|
1236
|
-
// another paid run on the same fake
|
|
1237
|
-
expectOk(`turning off the package's trigger ${
|
|
1238
|
-
return
|
|
1344
|
+
// another paid run on the same fake, which no report counts and which changes what the graders read.
|
|
1345
|
+
expectOk(`turning off the package's trigger ${name} after its run started`, await api("PATCH", `/triggers/${encodeURIComponent(triggerId)}`, { enabled: false }));
|
|
1346
|
+
return String(started.run_id);
|
|
1239
1347
|
}
|
|
1240
1348
|
const failed = fresh.find((f) => f.status === "failed");
|
|
1241
1349
|
if (failed)
|
|
1242
|
-
throw new ApiFailure(`the package's trigger ${
|
|
1350
|
+
throw new ApiFailure(`the package's trigger ${name} fired and its run was refused: ${String(failed.error ?? "no reason given")}`);
|
|
1243
1351
|
if (Date.now() > deadline) {
|
|
1244
1352
|
const last = (await read()).last_check;
|
|
1245
1353
|
const check = isObject(last) ? last : undefined;
|
|
1246
1354
|
const said = fresh.flatMap((f) => (typeof f.reason === "string" ? [f.reason] : []));
|
|
1247
|
-
throw new ApiFailure(`the package's trigger ${
|
|
1355
|
+
throw new ApiFailure(`the package's trigger ${name} started no run of ${agentId} within ${Math.round((options.queueTimeoutMs ?? QUEUE_TIMEOUT_MS) / 1000)} s of its time${check ? `; its last check: ${String(check.message)}` : ""}${said.length ? `; its firings: ${said.join(" ")}` : ""}${hint}`);
|
|
1248
1356
|
}
|
|
1249
1357
|
await sleep(200);
|
|
1250
1358
|
}
|
|
1251
1359
|
}
|
|
1252
1360
|
/** One run of a case: a fresh agent (so one run's learning never reaches the next), its notes, the run, its grades. An
|
|
1253
1361
|
* email case's run (`mail`) is its trigger's (triggerRun). */
|
|
1254
|
-
async function runOnce(ctx, one, n, fakes, mail) {
|
|
1362
|
+
async function runOnce(ctx, one, n, fakes, mail, feeds) {
|
|
1255
1363
|
const { api, pkg, options, made } = ctx;
|
|
1256
1364
|
const stopped = () => options.signal?.throwIfAborted();
|
|
1257
1365
|
await serverPins(ctx, one);
|
|
@@ -1262,7 +1370,9 @@ async function runOnce(ctx, one, n, fakes, mail) {
|
|
|
1262
1370
|
// every run. Left where the run before took it, a schedule's next time is a later day each run, with no mail of the case.
|
|
1263
1371
|
// A millisecond before it: a schedule's next time is strictly after the clock, so a case whose `now` is the schedule's
|
|
1264
1372
|
// own time (an evening digest's 18:00) fires for that time, not the next day's.
|
|
1265
|
-
|
|
1373
|
+
// An email or feed case's run is its one trigger's (readCases chose it): `via`, that trigger's name.
|
|
1374
|
+
const via = mail ? one.email.trigger : feeds ? one.feed.trigger : undefined;
|
|
1375
|
+
if (via !== undefined && one.now !== undefined)
|
|
1266
1376
|
ctx.clock?.set(instantOf(one.now) - 1);
|
|
1267
1377
|
// Approvals never, for the eval's own agent only: a run that stopped at its first ask would measure nothing. The
|
|
1268
1378
|
// package's default (ask, say, for a template whose tools cost money) is the owner's at install, and stays as it is;
|
|
@@ -1272,17 +1382,17 @@ async function runOnce(ctx, one, n, fakes, mail) {
|
|
|
1272
1382
|
made.agents.push(agentId);
|
|
1273
1383
|
// An eval's agent runs only the eval's runs: the package's triggers (a weekly schedule, say) would start paid runs of
|
|
1274
1384
|
// their own, into the fakes' logs, and outlive the eval. Each one the apply made is deleted at once.
|
|
1275
|
-
// An email case's run is its one trigger's
|
|
1385
|
+
// An email or feed case's run is its one trigger's: that one stays, until the run is read.
|
|
1276
1386
|
let kept;
|
|
1277
1387
|
for (const id of Array.isArray(applied.trigger_ids) ? applied.trigger_ids.map(String) : []) {
|
|
1278
|
-
if (
|
|
1388
|
+
if (via !== undefined && !kept && expectOk(`reading the package's trigger ${id}`, await api("GET", `/triggers/${encodeURIComponent(id)}`)).name === via)
|
|
1279
1389
|
kept = id;
|
|
1280
1390
|
else
|
|
1281
1391
|
made.triggers.add(id);
|
|
1282
1392
|
}
|
|
1283
1393
|
await deleteTriggers(api, made, true);
|
|
1284
|
-
if (
|
|
1285
|
-
throw new ApiFailure(`the apply made no trigger named ${
|
|
1394
|
+
if (via !== undefined && !kept)
|
|
1395
|
+
throw new ApiFailure(`the apply made no trigger named ${via}`);
|
|
1286
1396
|
if (kept)
|
|
1287
1397
|
made.triggers.add(kept);
|
|
1288
1398
|
const agent = expectOk(`reading the agent ${agentId}`, await api("GET", `/agents/${encodeURIComponent(agentId)}`));
|
|
@@ -1297,21 +1407,35 @@ async function runOnce(ctx, one, n, fakes, mail) {
|
|
|
1297
1407
|
// The case's fakes, for this run's agent alone, before its run can be claimed.
|
|
1298
1408
|
ctx.fakes.set(agentId, { ...(one.web !== undefined ? { web: one.web } : {}), ...(one.now !== undefined ? { now: new Date(instantOf(one.now)) } : {}), ...(one.monid !== undefined ? { monid: one.monid } : {}), ...(mail ? { email: { imap: mail.faux.imap, smtp: mail.faux.smtp, kind: mail.layout } } : {}) });
|
|
1299
1409
|
let runId;
|
|
1300
|
-
let
|
|
1301
|
-
if (
|
|
1410
|
+
let fired;
|
|
1411
|
+
if (via !== undefined && kept) {
|
|
1302
1412
|
// A trigger the package ships off is turned on for the eval's run: its start is taken then, on the history.
|
|
1303
|
-
if (expectOk(`reading the package's trigger ${
|
|
1304
|
-
expectOk(`turning on the package's trigger ${
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1413
|
+
if (expectOk(`reading the package's trigger ${via}`, await api("GET", `/triggers/${encodeURIComponent(kept)}`)).enabled !== true)
|
|
1414
|
+
expectOk(`turning on the package's trigger ${via}`, await api("PATCH", `/triggers/${encodeURIComponent(kept)}`, { enabled: true }));
|
|
1415
|
+
if (mail) {
|
|
1416
|
+
const fixture = one.email;
|
|
1417
|
+
let before;
|
|
1418
|
+
runId = await triggerRun(ctx, via, agentId, kept, (trigger) => {
|
|
1419
|
+
// The new message arrives where the trigger watches: its source's mailbox (INBOX by default).
|
|
1420
|
+
const watched = isObject(trigger.source) && typeof trigger.source.mailbox === "string" ? trigger.source.mailbox : "INBOX";
|
|
1421
|
+
if (fixture.message)
|
|
1422
|
+
seed(mail.faux, mail.layout, watched, fixture.message);
|
|
1423
|
+
// What the account holds before the run: what it adds or moves is read against this.
|
|
1424
|
+
before = snapshot(mail.faux);
|
|
1425
|
+
}, fixture.message ? " (its accept rules may leave the case's message)" : "");
|
|
1426
|
+
fired = { mailbox: () => mailboxAfter(mail.faux, mail.layout, before) };
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
runId = await triggerRun(ctx, via, agentId, kept, () => feeds.deliver(), " (its accept rules may leave the case's item)");
|
|
1430
|
+
fired = {};
|
|
1431
|
+
}
|
|
1308
1432
|
}
|
|
1309
1433
|
else
|
|
1310
1434
|
runId = await startRun(ctx, agentId, { input: runInput(one.input, one.fields), ...(one.maxCostUsd !== undefined ? { max_cost_usd: one.maxCostUsd } : {}) }, "starting the run");
|
|
1311
1435
|
// A run started is paid for: whatever fails after this (a read, a grade) still gives it a result, with its cost where
|
|
1312
1436
|
// the server says it, so the case's total never drops it.
|
|
1313
1437
|
try {
|
|
1314
|
-
return await ranOnce(ctx, one, n, fakes, agent, agentId, runId, used,
|
|
1438
|
+
return await ranOnce(ctx, one, n, fakes, agent, agentId, runId, used, fired);
|
|
1315
1439
|
}
|
|
1316
1440
|
catch (error) {
|
|
1317
1441
|
if (!(error instanceof ApiFailure))
|
|
@@ -1326,8 +1450,9 @@ async function runOnce(ctx, one, n, fakes, mail) {
|
|
|
1326
1450
|
}
|
|
1327
1451
|
}
|
|
1328
1452
|
/** The started run `runId` of `agentId` waited on, read and graded; its calls on the saved servers `used` gave its needs
|
|
1329
|
-
* ({toolkit: server}) named on the package's toolkits;
|
|
1330
|
-
|
|
1453
|
+
* ({toolkit: server}) named on the package's toolkits; a run its trigger started (`fired`) graded on the input it was
|
|
1454
|
+
* given, an email run's fake mailbox read once it has ended. */
|
|
1455
|
+
async function ranOnce(ctx, one, n, fakes, agent, agentId, runId, used, fired) {
|
|
1331
1456
|
const { api, options } = ctx;
|
|
1332
1457
|
const stopped = () => options.signal?.throwIfAborted();
|
|
1333
1458
|
const ended = await waitRun(api, runId, Date.now() + (options.runTimeoutMs ?? RUN_TIMEOUT_MS), options.signal, options.queueTimeoutMs);
|
|
@@ -1336,7 +1461,7 @@ async function ranOnce(ctx, one, n, fakes, agent, agentId, runId, used, after) {
|
|
|
1336
1461
|
await settle(ctx, runId, ended.status);
|
|
1337
1462
|
// Its metrics once it has ended (a cancelled run's end writes them too), before the eval's server can go.
|
|
1338
1463
|
const metrics = await metricsOf(api, agentId, options.signal);
|
|
1339
|
-
const mailbox =
|
|
1464
|
+
const mailbox = fired?.mailbox ? await fired.mailbox() : undefined;
|
|
1340
1465
|
stopped();
|
|
1341
1466
|
const result = isObject(view.result) ? view.result : {};
|
|
1342
1467
|
const harness = isObject(agent.definition) && typeof agent.definition.harness === "string" ? agent.definition.harness : "pi";
|
|
@@ -1354,8 +1479,8 @@ async function ranOnce(ctx, one, n, fakes, agent, agentId, runId, used, after) {
|
|
|
1354
1479
|
};
|
|
1355
1480
|
stopped();
|
|
1356
1481
|
const base = { run: n, agent_id: agentId, run_id: runId, status: ended.status, cost_usd: costOf(view), answer: record.answer, calls: record.calls, mcp_calls: record.mcpCalls, created_at: typeof view.created_at === "string" ? view.created_at : null, ended_at: typeof view.ended_at === "string" ? view.ended_at : null, metrics, ...(mailbox ? { mailbox_after: mailbox.after } : {}) };
|
|
1357
|
-
// The grader's task: the input the run was given, an email run's its trigger's (the payload in its tag).
|
|
1358
|
-
const task =
|
|
1482
|
+
// The grader's task: the input the run was given, an email or feed run's its trigger's (the payload in its tag).
|
|
1483
|
+
const task = fired ? inputMessage(view.input ?? {}) : inputMessage(runInput(one.input, one.fields));
|
|
1359
1484
|
// Waiting on its person's answer (an ask_person question, a tool call's approval) is where such a run stops, and is
|
|
1360
1485
|
// graded; paused at its cap, or stopped, it did not get there.
|
|
1361
1486
|
const pending = isObject(view.pending) && typeof view.pending.kind === "string" ? view.pending.kind : undefined;
|
package/dist/templates.d.ts
CHANGED
|
@@ -175,11 +175,21 @@ export declare const TRIGGER_NOT_SET_UP_YET: Readonly<Record<string, readonly st
|
|
|
175
175
|
export declare const notSetUpYet: (kind: unknown, code: string) => boolean;
|
|
176
176
|
/** What an apply says of a composio trigger it skipped (notSetUpYet): which trigger, and the refusal's own words. */
|
|
177
177
|
export declare function composioTriggerSkipped(packageName: string, trigger: Json, why: string): string;
|
|
178
|
+
/** Whether a feed trigger, its parameters filled, reads no feed: its urls one whole array parameter the apply was given
|
|
179
|
+
* empty. An apply skips it, never itself, as it skips a github trigger with GitHub not connected (a warning under
|
|
180
|
+
* triggers.<i>): the agent stands. */
|
|
181
|
+
export declare const feedLeftEmpty: (trigger: Json) => boolean;
|
|
182
|
+
/** What an apply says of a feed trigger it skipped (feedLeftEmpty): which, and the parameter to set. `declared` is the
|
|
183
|
+
* package's own urls ("${parameters.status_feeds}"). */
|
|
184
|
+
export declare function feedTriggerEmpty(packageName: string, trigger: Json, declared: unknown): string;
|
|
178
185
|
/** Where the owner makes a composio trigger an apply skipped, once what refused it is fixed. */
|
|
179
186
|
export declare const COMPOSIO_TRIGGER_FIX = "Once that's fixed, make it from Triggers \u2192 New app trigger for this agent, with the same event and config.";
|
|
180
187
|
/** What an apply says of a github trigger it skipped because GitHub is not connected here: what to do, and what the
|
|
181
188
|
* trigger would then run on, in the package's own words ("Code review runs on each pull request to acme/widgets."). */
|
|
182
189
|
export declare const githubTriggerUnconnected: (packageName: string, source: Json) => string;
|
|
190
|
+
/** The source of the package's trigger `name`, filled from the apply's `parameters` as an apply fills it (each parameter
|
|
191
|
+
* left out given its default): a template eval reads the feed URLs its case's trigger will read before it applies. */
|
|
192
|
+
export declare function filledSource(p: Package, name: string, parameters: Json): Json | undefined;
|
|
183
193
|
/** One entry of a package's folder, as readdirSync's withFileTypes gives it. */
|
|
184
194
|
export type PackageEntry = {
|
|
185
195
|
name: string;
|
|
@@ -207,7 +217,9 @@ export declare function folderFiles(dir: string): PackageFiles;
|
|
|
207
217
|
export declare function memoryFiles(name: string, where: string, files: ReadonlyMap<string, Buffer>): PackageFiles;
|
|
208
218
|
/** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
|
|
209
219
|
* with every problem found. */
|
|
210
|
-
export declare function readPackage(from: string | PackageFiles
|
|
220
|
+
export declare function readPackage(from: string | PackageFiles, { evalFixtures }?: {
|
|
221
|
+
evalFixtures?: boolean;
|
|
222
|
+
}): Package;
|
|
211
223
|
/** What is wrong with the trigger bodies an apply makes (compiled's `triggers`), as POST /v2/triggers checks a body, all
|
|
212
224
|
* but the agent each names (the one the apply makes), as of `now`, each field under `triggers.<i>`. A trigger's input is
|
|
213
225
|
* its runs' input, and a package's agent is agentic, so each input is checked against the package's input schema in
|