@ancha-labs/cli 0.1.5 → 0.2.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/lib/ancha.mjs +12513 -7691
- package/lib/assets/SKILL.md +14 -0
- package/lib/assets/docs/apps.md +88 -0
- package/lib/assets/docs/cloud.md +4 -4
- package/lib/assets/docs/integrations.md +2 -0
- package/lib/assets/docs/run.md +7 -1
- package/lib/assets/docs/setup.md +3 -1
- package/lib/assets/harbor/companion.mjs +2596 -1944
- package/lib/assets/ui/app.js +29 -19
- package/lib/assets/ui/style.css +2 -0
- package/lib/clock-preload.mjs +36 -0
- package/lib/mcp-entry.mjs +130 -24
- package/lib/worker.mjs +3002 -2231
- package/lib/world-server.mjs +2582 -1930
- package/package.json +1 -1
package/lib/assets/ui/app.js
CHANGED
|
@@ -911,9 +911,18 @@ function originLabel(origin) {
|
|
|
911
911
|
return [SOURCES[origin.source] ?? String(origin.source), String(origin.target ?? "").toLowerCase(), commit].filter(Boolean).join(" \xB7 ");
|
|
912
912
|
}
|
|
913
913
|
function result(run) {
|
|
914
|
-
const counts = batchCounts(run),
|
|
914
|
+
const counts = batchCounts(run), summary = run.summary;
|
|
915
915
|
if (!terminal(run.status)) return run.status === "queued" && run.queue ? queueLabel(run.queue) : `${counts.finished} / ${counts.total} finished`;
|
|
916
|
-
|
|
916
|
+
const tasks = run.tasks ?? [], attempts = run.attempts ?? [];
|
|
917
|
+
const verified = summary?.verdictVersion === 2 ? summary.counts : void 0;
|
|
918
|
+
const requested = verified?.requested ?? (tasks.length && tasks.every((task) => Number.isSafeInteger(task.attempts) && task.attempts > 0) ? tasks.reduce((sum2, task) => sum2 + task.attempts, 0) : void 0);
|
|
919
|
+
const passed = verified?.passed ?? attempts.filter((attempt) => attempt.outcome === "passed").length;
|
|
920
|
+
const invalid = verified?.invalid ?? attempts.filter((attempt) => attempt.outcome === "invalid").length;
|
|
921
|
+
const skipped = verified?.skipped ?? attempts.filter((attempt) => attempt.outcome === "skipped").length;
|
|
922
|
+
const graded = typeof summary?.pass_rate === "number" || attempts.some((attempt) => ["passed", "failed"].includes(attempt.outcome));
|
|
923
|
+
const detail = `${invalid ? ` \xB7 ${invalid} invalid` : ""}${skipped ? ` \xB7 ${skipped} skipped` : ""}`;
|
|
924
|
+
if (graded) return `${requested ? `${Math.round(passed / requested * 100)}% passed` : "Unverified rate \xB7 rerun"}${detail}`;
|
|
925
|
+
return `${requested ?? counts.total} ${(requested ?? counts.total) === 1 ? "attempt" : "attempts"}${detail}`;
|
|
917
926
|
}
|
|
918
927
|
function row(run) {
|
|
919
928
|
const date = new Date(run.createdAt), when = Number.isFinite(date.getTime()) ? date.toLocaleString(void 0, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }) : "";
|
|
@@ -943,13 +952,14 @@ function attemptOutcome(attempt) {
|
|
|
943
952
|
if (attempt.outcome === "passed") return { key: "passed", label: "Passed", tone: "pass", mark: "\u2713" };
|
|
944
953
|
if (attempt.outcome === "failed") return { key: "failed", label: "Failed", tone: "fail", mark: "\u2717" };
|
|
945
954
|
if (attempt.outcome === "invalid") return { key: "invalid", label: "Invalid \xB7 harness", tone: "invalid", mark: "?" };
|
|
955
|
+
if (attempt.outcome === "skipped") return { key: "skipped", label: "Skipped", tone: "neutral", mark: "\u25C7" };
|
|
946
956
|
return { key: "ungraded", label: "Ungraded", tone: "neutral", mark: "\u2013" };
|
|
947
957
|
}
|
|
948
958
|
var invalidReasons = { capture_timeout: "Collecting the final tool state timed out", capture_failed: "Collecting the final tool state failed" };
|
|
949
959
|
function invalidNote(attempt) {
|
|
950
960
|
if (attempt.outcome !== "invalid") return "";
|
|
951
961
|
const reason = invalidReasons[String(attempt.invalidReason)] ?? "The harness could not finish this attempt";
|
|
952
|
-
return `<p class="aw-invalid-note">${h(reason)}, so this attempt is
|
|
962
|
+
return `<p class="aw-invalid-note">${h(reason)}, so this attempt is invalid and cannot count as passed. It remains in the requested-attempt denominator.</p>`;
|
|
953
963
|
}
|
|
954
964
|
var startingSeen = /* @__PURE__ */ new Map();
|
|
955
965
|
function startingSince(attempt) {
|
|
@@ -968,12 +978,12 @@ function queueLine(batch) {
|
|
|
968
978
|
const blocking = batch.queue.blockingRun;
|
|
969
979
|
return `<p class="aw-queue" role="status">${h(queueLabel(batch.queue))}.${blocking ? ` ${navLink(String(blocking.name ?? "Another run"), "/playgrounds/" + encodeURIComponent(String(blocking.id)))} is using this workspace's runner.` : ""}</p>`;
|
|
970
980
|
}
|
|
971
|
-
function executionSummary(attempts) {
|
|
981
|
+
function executionSummary(attempts, requested = attempts.length) {
|
|
972
982
|
const finished = attempts.filter((a) => ["completed", "error", "stopped"].includes(a.status));
|
|
973
983
|
const durations = finished.map(attemptMs).filter((ms) => ms !== void 0).sort((x, y) => x - y);
|
|
974
984
|
const passed = attempts.filter((a) => a.outcome === "passed").length, failed = attempts.filter((a) => a.outcome === "failed").length, invalid = attempts.filter((a) => a.outcome === "invalid").length;
|
|
975
985
|
return {
|
|
976
|
-
total:
|
|
986
|
+
total: requested,
|
|
977
987
|
completed: attempts.filter((a) => a.status === "completed").length,
|
|
978
988
|
active: attempts.filter((a) => ["starting", "running"].includes(a.status)).length,
|
|
979
989
|
starting: attempts.filter((a) => a.status === "starting").length,
|
|
@@ -994,14 +1004,14 @@ var percent = (part, whole) => whole ? `${Math.round(part / whole * 100)}%` : "\
|
|
|
994
1004
|
var duration = (ms) => ms === void 0 ? "\u2014" : ms < 1e4 ? `${(ms / 1e3).toFixed(1)}s` : ms < 12e4 ? `${Math.round(ms / 1e3)}s` : `${Math.round(ms / 6e4)}m`;
|
|
995
1005
|
var medianTime = (attempts) => duration(executionSummary(attempts).medianMs);
|
|
996
1006
|
var hasChecks = (tasks) => Array.isArray(tasks) && tasks.some((task) => Array.isArray(task?.checks) && task.checks.length > 0);
|
|
997
|
-
function summaryWidgets(attempts, checked = false) {
|
|
998
|
-
const s = executionSummary(attempts);
|
|
1007
|
+
function summaryWidgets(attempts, checked = false, requested = attempts.length) {
|
|
1008
|
+
const s = executionSummary(attempts, requested);
|
|
999
1009
|
const cell2 = (label2, value, note, tone2 = "") => `<div class="rs-stat${tone2 ? " " + tone2 : ""}"><span>${h(label2)}</span><strong>${h(value)}</strong><small>${h(note)}</small></div>`;
|
|
1000
1010
|
const progress = s.active || s.queued ? [s.active - s.starting && `${s.active - s.starting} running`, s.starting && `${s.starting} starting`, s.queued && `${s.queued} queued`].filter(Boolean).join(" \xB7 ") : s.error ? `${s.error} ended with an error` : s.total ? "All finished" : "No attempts yet";
|
|
1001
|
-
const invalid = s.invalid ? `${s.invalid} invalid (harness),
|
|
1002
|
-
const rate = s.graded ? [`${s.passed} of ${s.
|
|
1003
|
-
const tone = !s.graded ? "" : s.passed === s.
|
|
1004
|
-
return `<section class="run-summary" aria-label="Summary"><div class="rs-stats">${cell2("Success rate", percent(s.passed, s.
|
|
1011
|
+
const invalid = s.invalid ? `${s.invalid} invalid (harness), not passed` : "";
|
|
1012
|
+
const rate = s.graded ? [`${s.passed} of ${s.total} requested passed`, invalid].filter(Boolean).join(" \xB7 ") : !s.total ? "No attempts yet" : !checked ? "Add checks to a task to grade it" : s.active || s.queued ? "Graded as attempts finish" : invalid || "No attempt could be graded";
|
|
1013
|
+
const tone = !s.graded ? "" : s.passed === s.total ? "pass" : s.passed ? "mixed" : "fail";
|
|
1014
|
+
return `<section class="run-summary" aria-label="Summary"><div class="rs-stats">${cell2("Success rate", s.graded ? percent(s.passed, s.total) : "\u2014", rate, tone)}${s.invalid ? cell2("Invalid", String(s.invalid), "Harness failures; not passed", "invalid") : ""}${cell2("Finished", `${s.finished}/${s.total}`, progress)}${cell2("Tool calls", String(s.toolCalls), s.finished ? `${(s.toolCalls / s.finished).toFixed(1)} per attempt` : "\u2014")}${cell2("Median time", duration(s.medianMs), "per attempt")}</div>${progressBar(attempts)}</section>`;
|
|
1005
1015
|
}
|
|
1006
1016
|
function attemptState(attempt) {
|
|
1007
1017
|
const outcome = attemptOutcome(attempt);
|
|
@@ -1013,9 +1023,9 @@ function progressBar(attempts) {
|
|
|
1013
1023
|
const s = executionSummary(attempts), label2 = `${s.finished} of ${s.total} attempts finished${s.graded ? `, ${s.passed} passed, ${s.failed} failed` : ""}${s.invalid ? `, ${s.invalid} invalid` : ""}`;
|
|
1014
1024
|
return `<div class="run-progress" role="img" aria-label="${h(label2)}" title="${h(label2)}">${attempts.map((a) => `<span class="seg ${attemptState(a)}"></span>`).join("")}</div>`;
|
|
1015
1025
|
}
|
|
1016
|
-
function taskOutcome(attempts, checked = false) {
|
|
1017
|
-
const s = executionSummary(attempts);
|
|
1018
|
-
if (s.graded) return { value: percent(s.passed, s.
|
|
1026
|
+
function taskOutcome(attempts, checked = false, requested = attempts.length) {
|
|
1027
|
+
const s = executionSummary(attempts, requested);
|
|
1028
|
+
if (s.graded) return { value: percent(s.passed, s.total), note: `${s.passed} of ${s.total} requested passed${s.invalid ? ` \xB7 ${s.invalid} invalid` : ""}`, tone: s.passed === s.total ? "pass" : s.passed ? "mixed" : "fail" };
|
|
1019
1029
|
if (!s.total) return { value: "\u2014", note: "No attempts", tone: "neutral" };
|
|
1020
1030
|
if (s.invalid && !s.active && !s.queued) return { value: "\u2014", note: `${s.invalid} invalid (harness)`, tone: "neutral" };
|
|
1021
1031
|
return { value: `${s.finished}/${s.total}`, note: s.active ? "running" : s.queued ? "queued" : checked ? "finished \xB7 not graded" : "finished \xB7 no checks", tone: "neutral" };
|
|
@@ -1057,7 +1067,7 @@ function checksView(attempt, jump = () => void 0) {
|
|
|
1057
1067
|
}).join("")}</ul></section>`;
|
|
1058
1068
|
}
|
|
1059
1069
|
function widgets(attempts, tasks) {
|
|
1060
|
-
return summaryWidgets(attempts, hasChecks(tasks));
|
|
1070
|
+
return summaryWidgets(attempts, hasChecks(tasks), tasks.reduce((sum2, task) => sum2 + (Number(task.attempts) || attempts.filter((attempt) => attempt.taskId === task.id).length), 0));
|
|
1061
1071
|
}
|
|
1062
1072
|
function errorMessage(value) {
|
|
1063
1073
|
if (!value) return "";
|
|
@@ -1110,7 +1120,7 @@ function renderRunOverview(batch, actionsHtml = "", options = {}) {
|
|
|
1110
1120
|
const shown = selected ? tasks.filter((t) => t.id === selected.id) : tasks;
|
|
1111
1121
|
if (!shown.length) return "";
|
|
1112
1122
|
return `<section class="aw-task-section">${groups.length > 1 ? `<header class="aw-entry-header"><h2>${h(entry?.agentName ?? entry?.name ?? "Agent")}</h2><span>${h(entry?.world?.name ?? entry?.test?.world?.name ?? "")}</span></header>` : ""}<div class="aw-section-heading"><h2>${selected ? "Attempts" : "Tasks"}</h2>${!selected ? `<span>${tasks.length}</span>` : ""}</div>${selected ? `<section class="aw-task-description"><p>${h(selected.prompt)}</p></section>` : ""}<div class="aw-task-table"><div class="aw-table-head" aria-hidden="true"><span>Task</span><span>Result</span><span>Attempts</span><span>Median</span><span></span></div>${shown.map((task) => {
|
|
1113
|
-
const taskAttempts = attempts.filter((a) => a.taskId === task.id), index = tasks.indexOf(task), first = taskAttempts[0], outcome = taskOutcome(taskAttempts, hasChecks([task]));
|
|
1123
|
+
const taskAttempts = attempts.filter((a) => a.taskId === task.id), index = tasks.indexOf(task), first = taskAttempts[0], outcome = taskOutcome(taskAttempts, hasChecks([task]), Number(task.attempts) || taskAttempts.length);
|
|
1114
1124
|
const href2 = taskHref(batch, task, first ? { attempt: first.id } : {});
|
|
1115
1125
|
return `<article class="aw-task-row"><div class="aw-task-name">${navLink(taskDisplayName(task, index), href2)}${!selected ? `<p class="aw-prompt-excerpt">${h(task.prompt)}</p>` : ""}</div><div class="aw-task-outcome ${outcome.tone}"><strong>${h(outcome.value)}</strong><span>${h(outcome.note)}</span></div>${taskAttempts.length ? markers(batch, task, taskAttempts) : '<p class="quiet-empty">No attempts recorded.</p>'}<span class="aw-task-time">${h(medianTime(taskAttempts))}</span><a data-nav class="aw-row-open" href="${h(href2)}" aria-label="Open ${h(taskDisplayName(task, index))}"></a>${selected ? comparisonForm(batch, task, taskAttempts) : ""}</article>`;
|
|
1116
1126
|
}).join("")}</div></section>`;
|
|
@@ -1368,10 +1378,10 @@ function mountWorldWorkspace(node, options) {
|
|
|
1368
1378
|
function render() {
|
|
1369
1379
|
if (disposed) return;
|
|
1370
1380
|
const currentRuns = selected ? setupRuns(runs, selected) : [], run = currentRuns[0], attempts = run?.attempts ?? [], tasks = selected?.tasks ?? [], choices = worldSetups(tests, world.id, agentId);
|
|
1371
|
-
node.innerHTML = `<div class="ww-workspace"><header class="ww-header"><h1>${h(world.name)}</h1><div class="ww-world-actions"><label class="ww-agent-select">Agent<select data-ww-select="agent"><option value="" disabled>Choose agent</option>${agents.map((a) => `<option value="${h(a.id)}" ${a.id === agentId ? "selected" : ""}>${h(agentLabel(a, agents))}</option>`).join("")}</select></label><button type="button" data-ww="configure">Configure</button>${selected ? options.runActions?.(selected.id) ?? button("Run tasks", "run-saved-test", selected.id, "primary") : ""}</div></header>${peopleSection(world)}<p class="ww-error" role="alert" ${error ? "" : "hidden"}>${h(error)}</p>${errors.map((e) => `<p class="ww-error" role="alert">${h(e.message)}</p>`).join("")}${!loaded ? '<p role="status">Loading tasks\u2026</p>' : ""}${choices.length > 1 ? `<label class="ww-setup-select">Configuration<select data-ww-select="test">${!selected ? '<option value="" selected disabled>New configuration</option>' : ""}${choices.map((t) => `<option value="${h(t.id)}" ${t.id === selected?.id ? "selected" : ""}>${h(t.name)}</option>`).join("")}</select></label>` : ""}${loaded && configure ? configuration2() : loaded ? `${summaryWidgets(attempts, hasChecks(run?.tasks ?? tasks))}<div class="ww-section-heading"><h2>Tasks${tasks.length ? ` <span class="ww-task-count">${tasks.length}</span>` : ""}</h2><div class="actions">${worldHistory(runs, world.id, agentId || void 0).length || selected ? `<button type="button" data-ww="history" aria-expanded="${showHistory}">History</button>` : ""}<button type="button" data-ww="configure">${tasks.length ? "Edit tasks" : "Add tasks"}</button></div></div>${tasks.length ? `<section class="ww-task-table"><div class="ww-table-head"><span>Task</span><span>Result</span><span>Attempts</span><span>Median</span><span></span></div>${tasks.map((task, index) => {
|
|
1381
|
+
node.innerHTML = `<div class="ww-workspace"><header class="ww-header"><h1>${h(world.name)}</h1><div class="ww-world-actions"><label class="ww-agent-select">Agent<select data-ww-select="agent"><option value="" disabled>Choose agent</option>${agents.map((a) => `<option value="${h(a.id)}" ${a.id === agentId ? "selected" : ""}>${h(agentLabel(a, agents))}</option>`).join("")}</select></label><button type="button" data-ww="configure">Configure</button>${selected ? options.runActions?.(selected.id) ?? button("Run tasks", "run-saved-test", selected.id, "primary") : ""}</div></header>${peopleSection(world)}<p class="ww-error" role="alert" ${error ? "" : "hidden"}>${h(error)}</p>${errors.map((e) => `<p class="ww-error" role="alert">${h(e.message)}</p>`).join("")}${!loaded ? '<p role="status">Loading tasks\u2026</p>' : ""}${choices.length > 1 ? `<label class="ww-setup-select">Configuration<select data-ww-select="test">${!selected ? '<option value="" selected disabled>New configuration</option>' : ""}${choices.map((t) => `<option value="${h(t.id)}" ${t.id === selected?.id ? "selected" : ""}>${h(t.name)}</option>`).join("")}</select></label>` : ""}${loaded && configure ? configuration2() : loaded ? `${summaryWidgets(attempts, hasChecks(run?.tasks ?? tasks), run?.summary?.counts?.requested ?? attempts.length)}<div class="ww-section-heading"><h2>Tasks${tasks.length ? ` <span class="ww-task-count">${tasks.length}</span>` : ""}</h2><div class="actions">${worldHistory(runs, world.id, agentId || void 0).length || selected ? `<button type="button" data-ww="history" aria-expanded="${showHistory}">History</button>` : ""}<button type="button" data-ww="configure">${tasks.length ? "Edit tasks" : "Add tasks"}</button></div></div>${tasks.length ? `<section class="ww-task-table"><div class="ww-table-head"><span>Task</span><span>Result</span><span>Attempts</span><span>Median</span><span></span></div>${tasks.map((task, index) => {
|
|
1372
1382
|
const list4 = attempts.filter((a) => a.taskId === task.id), taskURL = run ? `/playgrounds/${enc(run.id)}?task=${enc(task.id)}${list4[0] ? "&attempt=" + enc(list4[0].id) : ""}` : "";
|
|
1373
1383
|
return `<article class="ww-task-row"><div class="ww-task-identity">${taskURL ? `<a data-nav class="ww-task-name" href="${taskURL}"><span class="ww-ordinal">${index + 1}</span><strong>${h(label(task, index))}</strong></a>` : `<strong class="ww-task-name"><span class="ww-ordinal">${index + 1}</span>${h(label(task, index))}</strong>`}<p class="ww-task-prompt" title="${h(task.prompt)}">${h(task.prompt)}</p></div>${(() => {
|
|
1374
|
-
const o = taskOutcome(list4, hasChecks([task]));
|
|
1384
|
+
const o = taskOutcome(list4, hasChecks([task]), Number(task.attempts) || list4.length);
|
|
1375
1385
|
return `<div class="ww-rate ${o.tone}"><strong>${h(o.value)}</strong><span>${h(o.note)}</span></div>`;
|
|
1376
1386
|
})()}<div class="ww-attempt-marks" role="group" aria-label="Attempts for ${h(label(task, index))}">${list4.map((a) => {
|
|
1377
1387
|
const o = attemptOutcome(a);
|
|
@@ -1629,7 +1639,7 @@ function starterCount(tool, key, state) {
|
|
|
1629
1639
|
}
|
|
1630
1640
|
|
|
1631
1641
|
// frontend/src/generated/coding-agent-skill.ts
|
|
1632
|
-
var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, and prove a fix with graded runs. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; everything else prints one JSON object. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, scene files and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## The loop\n\n1. `ancha init --agent \"<the command that starts the agent>\"`, once, in the agent's project, if it has no `ancha.yaml` yet. It writes `ancha.yaml`, `scenes/starter/`, the coding-agent skill, and `.ancha/` in `.gitignore`. It installs and runs nothing.\n2. `ancha doctor --json` checks the config and scenes and runs the agent once. A tool the agent didn't call is a warning, not a failure.\n3. `ancha run --json` runs every scene in fresh worlds. Exit 1 means a check failed.\n4. `ancha explain latest --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n5. `ancha baseline save before` keeps the failing run as the reference.\n6. Fix the agent's code.\n7. `ancha run --compare before --json` proves the fix: exit 0 means every check passes and nothing regressed.\n\nThe starter scene only proves that the agent reaches each tool. For the agent's real job, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a scene can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not `ancha.yaml`, the scenes or their checks. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the scenes, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach trial gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\n`ancha run` starts the agent on this computer. It has this computer's network, and an environment limited to Ancha's variables, the tools' variables and the names allowed in `agent.pass_env` in `ancha.yaml` (or `--pass-env NAME`). The agent's own model key is one of those names: `agent.pass_env: [OPENROUTER_API_KEY]` passes it from this shell, and `agent.env` sets fixed values, such as the path of a key file. Without it, an agent that calls a model stops at its first call. For a sealed run, set `agent.execution: { mode: container, image: node:24-slim }` in `ancha.yaml`; it needs Docker.\n\n## Hosted workspace\n\nIf the user has an Ancha workspace, `ancha login` asks them to approve this computer once in the browser; ask them to do it. After that, `ancha run` still runs its worlds on this computer; `ancha run --upload --json` sends the finished run to their workspace, where the console shows it (`upload.url` in the JSON). `ancha whoami --json` shows the workspace and where runs put their worlds. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login: `ancha run --local --upload --json`. `ancha secrets set NAME` copies a provider key from this shell into the workspace for agents that run there.\n\nRunning the agent itself in the cloud is a console flow at https://app.ancha.io: Bring your agent, Connect, tasks with checks, Run. Send the user there for it.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain latest --json`.\n- Exit 2: usage, config, scene or authentication error. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`. Read the `hint`.\n- Exit 3: infrastructure, or a trial the harness couldn't complete. That's not the agent's fault; run again, and `ancha doctor --json` if it repeats.\n- Exit 4, only with `--strict`: the agent called an endpoint a replica doesn't implement. `ancha explain` lists these coverage gaps even without `--strict`; check `ancha twins coverage <tool>` before changing the agent.\n\nEvery error has a stable `code` and a `hint` that names the next command. More: `ancha docs`, `ancha docs <topic>` for setup, run, explain, compare, scenes, integrations, cloud and playgrounds, and https://ancha.mintlify.app/coding-agents.\n\nTell the user what you ran, the pass rate and the evidence. Never claim a fix until `ancha run --compare` exits 0.\n";
|
|
1642
|
+
var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, and prove a fix with graded runs. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; everything else prints one JSON object. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, scene files and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## The loop\n\n1. `ancha init --agent \"<the command that starts the agent>\"`, once, in the agent's project, if it has no `ancha.yaml` yet. It writes `ancha.yaml`, `scenes/starter/`, the coding-agent skill, and `.ancha/` in `.gitignore`. It installs and runs nothing.\n2. `ancha doctor --json` checks the config and scenes and runs the agent once. A tool the agent didn't call is a warning, not a failure.\n3. `ancha run --json` runs every scene in fresh worlds. Exit 1 means a check failed.\n4. `ancha explain latest --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n5. `ancha baseline save before` keeps the failing run as the reference.\n6. Fix the agent's code.\n7. `ancha run --compare before --json` proves the fix: exit 0 means every check passes and nothing regressed.\n\nThe starter scene only proves that the agent reaches each tool. For the agent's real job, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a scene can make on it. More: `ancha docs scenes`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per trial with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every trial: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## From a production failure\n\nA production run that went wrong becomes a test here. With a trace file (an export from the user's tracing):\n\n1. `ancha import --offline <trace file> --json` makes the test on this computer and uploads nothing. It writes `scenes/from-traces/<name>/scene.yaml` and lists the questions one trace cannot settle, each with the default the test uses.\n2. Ask the user for the answers; don't guess them. Pass them with `--answer <question>=<value>` and import again with `--force` (`ancha docs apps`).\n3. `ancha run` on the `scene.yaml` against the version that failed in production should fail the same way. That is where the loop above starts.\n\nIf the user's workspace takes traces (their agents send them to it), `ancha traces --failed --json` lists the ones where production failed a check, `ancha traces show <id> --json` previews the test, and `ancha pull <id> --json` saves it, with `--answer` for its questions. Checks you add to a pulled `scene.yaml` stay when you pull a newer version; any other edit stops the pull. A workspace that doesn't take traces says so; use the file.\n\n## The rule\n\nFix the agent, not `ancha.yaml`, the scenes or their checks. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the scenes, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach trial gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\n`ancha run` starts the agent on this computer. It has this computer's network, and an environment limited to Ancha's variables, the tools' variables and the names allowed in `agent.pass_env` in `ancha.yaml` (or `--pass-env NAME`). The agent's own model key is one of those names: `agent.pass_env: [OPENROUTER_API_KEY]` passes it from this shell, and `agent.env` sets fixed values, such as the path of a key file. Without it, an agent that calls a model stops at its first call. For a sealed run, set `agent.execution: { mode: container, image: node:24-slim }` in `ancha.yaml`; it needs Docker.\n\n## Hosted workspace\n\nIf the user has an Ancha workspace, `ancha login` asks them to approve this computer once in the browser; ask them to do it. After that, `ancha run` still runs its worlds on this computer; `ancha run --upload --json` sends the finished run to their workspace, where the console shows it (`upload.url` in the JSON). `ancha whoami --json` shows the workspace and where runs put their worlds. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login: `ancha run --local --upload --json`. `ancha secrets set NAME` copies a provider key from this shell into the workspace for agents that run there.\n\nRunning the agent itself in the cloud is a console flow at https://app.ancha.io: Bring your agent, Connect, tasks with checks, Run. Send the user there for it.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain latest --json`.\n- Exit 2: usage, config, scene or authentication error. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`. Read the `hint`.\n- Exit 3: infrastructure, or a trial the harness couldn't complete. That's not the agent's fault; run again, and `ancha doctor --json` if it repeats.\n- Exit 4, only with `--strict`: the agent called an endpoint a replica doesn't implement. `ancha explain` lists these coverage gaps even without `--strict`; check `ancha twins coverage <tool>` before changing the agent.\n\nEvery error has a stable `code` and a `hint` that names the next command. More: `ancha docs`, `ancha docs <topic>` for setup, run, explain, compare, scenes, integrations, cloud and playgrounds, and https://ancha.mintlify.app/coding-agents.\n\nTell the user what you ran, the pass rate and the evidence. Never claim a fix until `ancha run --compare` exits 0.\n";
|
|
1633
1643
|
|
|
1634
1644
|
// frontend/src/workspace-pages.ts
|
|
1635
1645
|
var startSentence = "Test our agent with Ancha. Start with: npx -y @ancha-labs/cli init, then read https://app.ancha.io/llms.txt";
|
package/lib/assets/ui/style.css
CHANGED
|
@@ -285,6 +285,8 @@ main{margin:10px 10px 10px 240px;padding:24px 28px 36px;min-height:calc(100vh -
|
|
|
285
285
|
.rs-stat>strong{font-size:22px;font-weight:600;line-height:1.2;letter-spacing:-.01em;color:var(--ink);font-variant-numeric:tabular-nums}
|
|
286
286
|
.rs-stat>small{font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
287
287
|
.rs-stat.pass>strong{color:var(--pass)}.rs-stat.fail>strong{color:var(--fail)}.rs-stat.mixed>strong{color:#9a6b1f}
|
|
288
|
+
.rs-stat.invalid>strong{color:var(--fail)}
|
|
289
|
+
@media(min-width:701px){.rs-stats:has(.rs-stat.invalid){grid-template-columns:repeat(5,minmax(0,1fr))}}
|
|
288
290
|
.run-summary .run-progress{height:auto;gap:3px;margin:0;padding:0 20px 16px;border-radius:0;background:none;overflow:visible}
|
|
289
291
|
.run-summary .run-progress .seg{height:4px;border-radius:2px}
|
|
290
292
|
.aw-section-heading{justify-content:flex-start;gap:8px;margin:0 0 10px}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Ancha's app clock (agent.clock: node), loaded with --import into the Node processes Ancha starts for an app.
|
|
2
|
+
// Date and Date.now() follow the world's simulated clock, which Ancha mirrors into ANCHA_CLOCK_FILE whenever its
|
|
3
|
+
// course changes (the trial starting, a jump while everyone waits). Between changes the app's time runs at the
|
|
4
|
+
// world's rate from the last mirrored instant; while the world is paused it runs at real speed, so an app never sees
|
|
5
|
+
// time stand still. Timers, performance.now() and process.hrtime() stay real.
|
|
6
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
7
|
+
|
|
8
|
+
const file = process.env.ANCHA_CLOCK_FILE;
|
|
9
|
+
if (file) {
|
|
10
|
+
const RealDate = Date;
|
|
11
|
+
const realNow = RealDate.now.bind(RealDate);
|
|
12
|
+
let seen = '', course = { worldMs: realNow(), realMs: realNow(), scale: 1, paused: false };
|
|
13
|
+
const now = () => {
|
|
14
|
+
try {
|
|
15
|
+
// Ancha renames each version into place, so a new inode or mtime means a new course and a read is never partial.
|
|
16
|
+
const stat = statSync(file, { throwIfNoEntry: false });
|
|
17
|
+
const key = stat ? `${stat.ino}:${stat.mtimeMs}` : '';
|
|
18
|
+
if (stat && key !== seen) { course = JSON.parse(readFileSync(file, 'utf8')); seen = key; }
|
|
19
|
+
} catch { /* keep the last course */ }
|
|
20
|
+
const elapsed = realNow() - course.realMs;
|
|
21
|
+
return Math.floor(course.worldMs + (course.paused ? elapsed : elapsed * course.scale));
|
|
22
|
+
};
|
|
23
|
+
function AnchaDate(...args) {
|
|
24
|
+
if (!new.target) return new RealDate(now()).toString();
|
|
25
|
+
// Subclasses of Date keep their prototype.
|
|
26
|
+
return Reflect.construct(RealDate, args.length === 0 ? [now()] : args, new.target);
|
|
27
|
+
}
|
|
28
|
+
Object.setPrototypeOf(AnchaDate, RealDate);
|
|
29
|
+
// Date's statics (UTC, parse, length, name) as own properties: code that wraps Date copies only own ones.
|
|
30
|
+
for (const key of Object.getOwnPropertyNames(RealDate)) {
|
|
31
|
+
if (key !== 'prototype' && key !== 'now') Object.defineProperty(AnchaDate, key, Object.getOwnPropertyDescriptor(RealDate, key));
|
|
32
|
+
}
|
|
33
|
+
AnchaDate.prototype = RealDate.prototype;
|
|
34
|
+
AnchaDate.now = now;
|
|
35
|
+
globalThis.Date = AnchaDate;
|
|
36
|
+
}
|
package/lib/mcp-entry.mjs
CHANGED
|
@@ -18,9 +18,9 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
18
18
|
throw mod = 0, e;
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
var __export = (target,
|
|
22
|
-
for (var name3 in
|
|
23
|
-
__defProp(target, name3, { get:
|
|
21
|
+
var __export = (target, all2) => {
|
|
22
|
+
for (var name3 in all2)
|
|
23
|
+
__defProp(target, name3, { get: all2[name3], enumerable: true });
|
|
24
24
|
};
|
|
25
25
|
var __copyProps = (to, from, except, desc) => {
|
|
26
26
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -7377,11 +7377,11 @@ var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
|
7377
7377
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
7378
7378
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
7379
7379
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
7380
|
-
var __exportAll = (
|
|
7380
|
+
var __exportAll = (all2, symbols) => {
|
|
7381
7381
|
let target = {};
|
|
7382
|
-
for (var name3 in
|
|
7382
|
+
for (var name3 in all2) {
|
|
7383
7383
|
__defProp2(target, name3, {
|
|
7384
|
-
get:
|
|
7384
|
+
get: all2[name3],
|
|
7385
7385
|
enumerable: true
|
|
7386
7386
|
});
|
|
7387
7387
|
}
|
|
@@ -44348,11 +44348,11 @@ var __getOwnPropNames3 = Object.getOwnPropertyNames;
|
|
|
44348
44348
|
var __getProtoOf3 = Object.getPrototypeOf;
|
|
44349
44349
|
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
44350
44350
|
var __commonJSMin2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
44351
|
-
var __exportAll2 = (
|
|
44351
|
+
var __exportAll2 = (all2, symbols) => {
|
|
44352
44352
|
let target = {};
|
|
44353
|
-
for (var name3 in
|
|
44353
|
+
for (var name3 in all2) {
|
|
44354
44354
|
__defProp3(target, name3, {
|
|
44355
|
-
get:
|
|
44355
|
+
get: all2[name3],
|
|
44356
44356
|
enumerable: true
|
|
44357
44357
|
});
|
|
44358
44358
|
}
|
|
@@ -57313,6 +57313,69 @@ var AnchaError = class extends Error {
|
|
|
57313
57313
|
}
|
|
57314
57314
|
};
|
|
57315
57315
|
|
|
57316
|
+
// packages/core/src/execution-support.ts
|
|
57317
|
+
var all = { local: true, container: true, managed: true };
|
|
57318
|
+
var sceneOnly = { local: true, container: true, managed: false };
|
|
57319
|
+
var EXECUTION_SUPPORT = {
|
|
57320
|
+
"input.scene": { ...sceneOnly, reason: "scene worlds cannot be imported without changing their semantics" },
|
|
57321
|
+
"input.test": { ...sceneOnly, reason: "local test worlds cannot be equated with saved managed worlds" },
|
|
57322
|
+
"input.managed-task": { local: false, container: false, managed: true, reason: "explicit saved-world tasks use runs start or the console" },
|
|
57323
|
+
"managed.world-reference": { local: false, container: false, managed: true, reason: "an explicit reference to an existing managed world, not an imported local world" },
|
|
57324
|
+
"id": all,
|
|
57325
|
+
"title": all,
|
|
57326
|
+
"task": sceneOnly,
|
|
57327
|
+
"start.task": all,
|
|
57328
|
+
"attempts": all,
|
|
57329
|
+
"twins": sceneOnly,
|
|
57330
|
+
"world": sceneOnly,
|
|
57331
|
+
"start_time": sceneOnly,
|
|
57332
|
+
"time_scale": sceneOnly,
|
|
57333
|
+
"skip_idle": sceneOnly,
|
|
57334
|
+
"seed": sceneOnly,
|
|
57335
|
+
"world_rules": sceneOnly,
|
|
57336
|
+
"people": sceneOnly,
|
|
57337
|
+
"until": sceneOnly,
|
|
57338
|
+
"deadline": sceneOnly,
|
|
57339
|
+
"start.message": sceneOnly,
|
|
57340
|
+
"pass": sceneOnly,
|
|
57341
|
+
"scene.timeout": sceneOnly,
|
|
57342
|
+
"test.timeout": all,
|
|
57343
|
+
"checks.state": all,
|
|
57344
|
+
"checks.trace": all,
|
|
57345
|
+
"checks.process": all,
|
|
57346
|
+
"checks.judge": sceneOnly,
|
|
57347
|
+
"agent.input.command": all,
|
|
57348
|
+
"agent.input.per_event": sceneOnly,
|
|
57349
|
+
"agent.input.events": { local: true, container: false, managed: false },
|
|
57350
|
+
"agent.input.http": all,
|
|
57351
|
+
"agent.endpoint": { local: true, container: false, managed: false },
|
|
57352
|
+
"agent.slack_transport.feed": sceneOnly,
|
|
57353
|
+
"agent.slack_transport.http": { local: true, container: false, managed: false },
|
|
57354
|
+
"agent.slack_transport.socket": { local: true, container: false, managed: false },
|
|
57355
|
+
"agent.env": sceneOnly,
|
|
57356
|
+
"agent.pass_env": sceneOnly,
|
|
57357
|
+
"agent.execution": sceneOnly,
|
|
57358
|
+
"judge": sceneOnly,
|
|
57359
|
+
"min_pass_rate": sceneOnly,
|
|
57360
|
+
"--agent": all,
|
|
57361
|
+
"--trials": all,
|
|
57362
|
+
"--parallel": all,
|
|
57363
|
+
"--idempotency-key": all,
|
|
57364
|
+
"--on": all,
|
|
57365
|
+
"--json": all,
|
|
57366
|
+
"--agent-url": { local: true, container: false, managed: false },
|
|
57367
|
+
"--compare": sceneOnly,
|
|
57368
|
+
"--min-pass-rate": sceneOnly,
|
|
57369
|
+
"--strict": sceneOnly,
|
|
57370
|
+
"--seed": sceneOnly,
|
|
57371
|
+
"--out": sceneOnly,
|
|
57372
|
+
"--detach": sceneOnly,
|
|
57373
|
+
"--pass-env": sceneOnly,
|
|
57374
|
+
"--inherit-env": sceneOnly,
|
|
57375
|
+
"--upload": sceneOnly,
|
|
57376
|
+
"--upload-required": sceneOnly
|
|
57377
|
+
};
|
|
57378
|
+
|
|
57316
57379
|
// packages/core/src/duration.ts
|
|
57317
57380
|
var DURATION_RE = /^(-?)(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
|
|
57318
57381
|
var MS_PER = { d: 864e5, h: 36e5, m: 6e4, s: 1e3, ms: 1 };
|
|
@@ -57707,13 +57770,14 @@ var DatadogSeedSchema = external_exports.strictObject({
|
|
|
57707
57770
|
metrics: external_exports.array(external_exports.strictObject({ name: external_exports.string(), tags, points: external_exports.array(external_exports.strictObject({ at: duration3("Historical offset <=0; unique timestamp per series"), value: external_exports.number() })) })).optional(),
|
|
57708
57771
|
logs: external_exports.array(external_exports.strictObject({ ref: refName.optional(), at: duration3("Historical offset <=0"), service: external_exports.string(), status: external_exports.string(), message: external_exports.string(), tags: tags.optional() })).optional()
|
|
57709
57772
|
});
|
|
57773
|
+
var pagerDutyId = external_exports.string().regex(/^P[A-Z0-9]{6}$/, "a PagerDuty id, e.g. PTQNWPX").optional().describe("Pins the native id (TRACE_PLAN \xA710.1)");
|
|
57710
57774
|
var PagerDutySeedSchema = external_exports.strictObject({
|
|
57711
|
-
users: external_exports.array(external_exports.strictObject({ ref: refName, name: external_exports.string(), email: external_exports.string().email() })).min(1, "PagerDuty requires at least one seeded actor user"),
|
|
57775
|
+
users: external_exports.array(external_exports.strictObject({ ref: refName, id: pagerDutyId, name: external_exports.string(), email: external_exports.string().email() })).min(1, "PagerDuty requires at least one seeded actor user"),
|
|
57712
57776
|
actor: ref6.optional(),
|
|
57713
57777
|
default_service: ref6.describe("Defaults to the sole declared service; required with multiple services").optional(),
|
|
57714
|
-
schedules: external_exports.array(external_exports.strictObject({ ref: refName, name: external_exports.string(), entries: external_exports.array(external_exports.strictObject({ user: ref6, start: external_exports.iso.datetime({ offset: true }), end: external_exports.iso.datetime({ offset: true }) })) })).optional(),
|
|
57715
|
-
escalation_policies: external_exports.array(external_exports.strictObject({ ref: refName, name: external_exports.string().optional(), levels: external_exports.array(external_exports.strictObject({ after: duration3("Positive whole simulated minutes on nonfinal levels; omitted on final level").optional(), targets: external_exports.array(ref6).min(1) })).min(1) })),
|
|
57716
|
-
services: external_exports.array(external_exports.strictObject({ ref: refName, name: external_exports.string(), escalation_policy: ref6, slack_channel: ref6.optional() })).min(1),
|
|
57778
|
+
schedules: external_exports.array(external_exports.strictObject({ ref: refName, id: pagerDutyId, name: external_exports.string(), entries: external_exports.array(external_exports.strictObject({ user: ref6, start: external_exports.iso.datetime({ offset: true }), end: external_exports.iso.datetime({ offset: true }) })) })).optional(),
|
|
57779
|
+
escalation_policies: external_exports.array(external_exports.strictObject({ ref: refName, id: pagerDutyId, name: external_exports.string().optional(), levels: external_exports.array(external_exports.strictObject({ after: duration3("Positive whole simulated minutes on nonfinal levels; omitted on final level").optional(), targets: external_exports.array(ref6).min(1) })).min(1) })),
|
|
57780
|
+
services: external_exports.array(external_exports.strictObject({ ref: refName, id: pagerDutyId, name: external_exports.string(), escalation_policy: ref6, slack_channel: ref6.optional() })).min(1),
|
|
57717
57781
|
incidents: external_exports.array(external_exports.strictObject({ ref: refName, service: ref6, title: external_exports.string(), status: status2, at: duration3("Historical offset <=0. Initial acknowledged/resolved state does not fabricate acknowledgement latency."), assignees: external_exports.array(ref6).optional(), dedup_key: external_exports.string().optional() })).optional()
|
|
57718
57782
|
});
|
|
57719
57783
|
var FaultRuleSchema = external_exports.strictObject({
|
|
@@ -57813,13 +57877,15 @@ var ListenSchema = external_exports.union([
|
|
|
57813
57877
|
var AccountsSchema = external_exports.strictObject({
|
|
57814
57878
|
slack: refUse.optional().describe("Their Slack user, from seed.slack.users"),
|
|
57815
57879
|
github: refUse.optional().describe("Their GitHub identity, from seed.github.users"),
|
|
57816
|
-
pagerduty: refUse.optional().describe("Their PagerDuty user, from seed.pagerduty.users")
|
|
57880
|
+
pagerduty: refUse.optional().describe("Their PagerDuty user, from seed.pagerduty.users"),
|
|
57881
|
+
gmail: external_exports.email().optional().describe("Their mailbox, an address in seed.gmail.mailboxes: mail delivered there reaches them and they reply from it")
|
|
57817
57882
|
}).refine((accounts) => Object.values(accounts).some((account2) => account2 !== void 0), "a person needs at least one account").describe("Who this person is in each tool");
|
|
57818
|
-
var PERSON_ACTIONS = ["slack.post", "github.comment", "github.open_issue", "github.approve", "github.pr_merge"];
|
|
57883
|
+
var PERSON_ACTIONS = ["slack.post", "github.comment", "github.open_issue", "github.approve", "github.pr_merge", "gmail.reply"];
|
|
57884
|
+
var WORK_ACTIONS = ["slack.post", "github.comment", "github.open_issue", "github.approve", "github.pr_merge"];
|
|
57819
57885
|
var WorkSchema = external_exports.strictObject({
|
|
57820
57886
|
after: worldDuration("Simulated time from the start of the attempt, or from when `when` first holds", 0).default("0s"),
|
|
57821
57887
|
when: WorldPredicateSchema.optional().describe("The work waits until this holds"),
|
|
57822
|
-
do: external_exports.enum(
|
|
57888
|
+
do: external_exports.enum(WORK_ACTIONS),
|
|
57823
57889
|
ref: refUse.describe("What the work acts on: a channel for slack.post, an issue or pull request for github.comment, a repository for github.open_issue, a pull request for github.approve and github.pr_merge"),
|
|
57824
57890
|
about: external_exports.string().min(1).optional().describe("What the text says; the model writes the words. Required for every action except github.pr_merge")
|
|
57825
57891
|
});
|
|
@@ -57853,6 +57919,7 @@ var PersonStepSchema = external_exports.discriminatedUnion("action", [
|
|
|
57853
57919
|
external_exports.object({ action: external_exports.literal("comment"), where: stepWhere, text: stepText }),
|
|
57854
57920
|
external_exports.object({ action: external_exports.literal("open_issue"), where: stepWhere, title: external_exports.string().trim().min(1).max(256), text: stepText }),
|
|
57855
57921
|
external_exports.object({ action: external_exports.literal("approve"), where: stepWhere, text: stepText.optional() }),
|
|
57922
|
+
external_exports.object({ action: external_exports.literal("reply"), where: stepWhere, text: stepText }),
|
|
57856
57923
|
external_exports.object({ action: external_exports.literal("wait") })
|
|
57857
57924
|
]);
|
|
57858
57925
|
|
|
@@ -58912,6 +58979,27 @@ var message = external_exports.strictObject({
|
|
|
58912
58979
|
in_reply_to: ref7.optional(),
|
|
58913
58980
|
attachments: external_exports.array(attachment).max(20).default([])
|
|
58914
58981
|
});
|
|
58982
|
+
var GmailSendArgsSchema = external_exports.strictObject({
|
|
58983
|
+
/** Names this message so a later gmail.send can answer it with in_reply_to. */
|
|
58984
|
+
ref: ref7.optional(),
|
|
58985
|
+
from: address,
|
|
58986
|
+
to: external_exports.union([address, external_exports.array(address).min(1)]),
|
|
58987
|
+
cc: external_exports.union([address, external_exports.array(address)]).optional(),
|
|
58988
|
+
/** Defaults to "Re: " plus the parent's subject for a reply. */
|
|
58989
|
+
subject: external_exports.string().max(998).optional(),
|
|
58990
|
+
body: external_exports.string().max(1e5),
|
|
58991
|
+
/** The ref of a seeded message or an earlier gmail.send: sets In-Reply-To and References and joins its thread. */
|
|
58992
|
+
in_reply_to: ref7.optional()
|
|
58993
|
+
});
|
|
58994
|
+
var GmailThreadCheckSchema = external_exports.strictObject({
|
|
58995
|
+
of: ref7.describe("The ref of a seeded message or a gmail.send: the thread it is in"),
|
|
58996
|
+
mailbox: address.optional().describe("Whose copy of the thread; defaults to the agent's mailbox"),
|
|
58997
|
+
label: external_exports.string().min(1).max(225).optional().describe("A label name, or a system label id such as INBOX, on any message in the thread"),
|
|
58998
|
+
present: external_exports.boolean().optional().describe("With label: false asserts no message in the thread has it. Defaults to true"),
|
|
58999
|
+
drafts_gte: external_exports.number().int().min(0).optional().describe("At least this many drafts in the thread"),
|
|
59000
|
+
drafts_lte: external_exports.number().int().min(0).optional().describe("At most this many drafts in the thread"),
|
|
59001
|
+
messages_gte: external_exports.number().int().min(1).optional().describe("At least this many messages in the thread, drafts included")
|
|
59002
|
+
}).refine((check3) => check3.label !== void 0 || check3.drafts_gte !== void 0 || check3.drafts_lte !== void 0 || check3.messages_gte !== void 0, "give label, drafts_gte, drafts_lte or messages_gte").refine((check3) => check3.present === void 0 || check3.label !== void 0, "present applies to label");
|
|
58915
59003
|
var draft = message.omit({ from: true, labels: true }).extend({ at: when.default("0s") });
|
|
58916
59004
|
var label3 = external_exports.strictObject({
|
|
58917
59005
|
name: external_exports.string().min(1).max(225).refine((value2) => value2.trim() === value2 && value2.length > 0, "label names have no leading or trailing spaces"),
|
|
@@ -60272,15 +60360,15 @@ var NotionSeedSchema = external_exports.strictObject({
|
|
|
60272
60360
|
databases: external_exports.array(database).max(200).default([])
|
|
60273
60361
|
}).superRefine((seed2, ctx) => {
|
|
60274
60362
|
const issue2 = (path2, message4) => ctx.addIssue({ code: "custom", path: path2, message: message4 });
|
|
60275
|
-
const users = /* @__PURE__ */ new Set(), pages = /* @__PURE__ */ new Set(),
|
|
60363
|
+
const users = /* @__PURE__ */ new Set(), pages = /* @__PURE__ */ new Set(), all2 = /* @__PURE__ */ new Set();
|
|
60276
60364
|
seed2.users.forEach((u, i) => {
|
|
60277
60365
|
if (users.has(u.ref)) issue2(["users", i, "ref"], "duplicate user ref");
|
|
60278
60366
|
users.add(u.ref);
|
|
60279
60367
|
});
|
|
60280
60368
|
const declare = (r, path2) => {
|
|
60281
60369
|
if (r === void 0) return;
|
|
60282
|
-
if (
|
|
60283
|
-
|
|
60370
|
+
if (all2.has(r) || users.has(r)) issue2(path2, `duplicate ref ${r}`);
|
|
60371
|
+
all2.add(r);
|
|
60284
60372
|
};
|
|
60285
60373
|
seed2.pages.forEach((p2, i) => {
|
|
60286
60374
|
declare(p2.ref, ["pages", i, "ref"]);
|
|
@@ -65146,8 +65234,11 @@ function duration6(description2) {
|
|
|
65146
65234
|
}
|
|
65147
65235
|
}).describe(description2);
|
|
65148
65236
|
}
|
|
65237
|
+
var slackIdPin = (prefix2, example) => external_exports.string().regex(new RegExp(`^[${prefix2}][A-Z0-9]{2,20}$`), `a Slack id starting with ${prefix2.split("").join(" or ")}, e.g. ${example}`).optional();
|
|
65149
65238
|
var SlackUserSeed = external_exports.strictObject({
|
|
65150
65239
|
ref: refName3,
|
|
65240
|
+
id: slackIdPin("UW", "U048N5Q2JL4"),
|
|
65241
|
+
bot_id: slackIdPin("B", "B04A1BC2DEF"),
|
|
65151
65242
|
name: external_exports.string(),
|
|
65152
65243
|
real_name: external_exports.string().optional(),
|
|
65153
65244
|
email: external_exports.string().optional(),
|
|
@@ -65155,6 +65246,7 @@ var SlackUserSeed = external_exports.strictObject({
|
|
|
65155
65246
|
});
|
|
65156
65247
|
var SlackChannelSeed = external_exports.strictObject({
|
|
65157
65248
|
ref: refName3,
|
|
65249
|
+
id: slackIdPin("CG", "C048N5Q2JL4"),
|
|
65158
65250
|
name: external_exports.string().regex(/^[a-z0-9_-]{1,80}$/, "must match ^[a-z0-9_-]{1,80}$ (lowercase letters, digits, - and _, 1-80 chars)"),
|
|
65159
65251
|
is_private: external_exports.boolean().optional(),
|
|
65160
65252
|
topic: external_exports.string().optional(),
|
|
@@ -65169,10 +65261,11 @@ var SlackPost = external_exports.strictObject({
|
|
|
65169
65261
|
thread_of: refUse3.optional()
|
|
65170
65262
|
});
|
|
65171
65263
|
var SlackMessageSeed = SlackPost.extend({
|
|
65264
|
+
ts: external_exports.string().regex(/^\d{10}\.\d{6}$/, "a Slack message ts, e.g. 1792591080.000000").optional().describe("Pins the message id; it must be at or before start_time, later than the seed messages before it, and agree with at"),
|
|
65172
65265
|
at: duration6("Offset from start_time; must be <= 0 (seed messages are history)").default("0s")
|
|
65173
65266
|
});
|
|
65174
65267
|
var SlackSeedSchema = external_exports.strictObject({
|
|
65175
|
-
team: external_exports.strictObject({ name: external_exports.string().default("Acme") }).optional(),
|
|
65268
|
+
team: external_exports.strictObject({ name: external_exports.string().default("Acme"), id: slackIdPin("T", "T048N5Q2JL4") }).optional(),
|
|
65176
65269
|
bot: refUse3.optional(),
|
|
65177
65270
|
users: external_exports.array(SlackUserSeed),
|
|
65178
65271
|
channels: external_exports.array(SlackChannelSeed),
|
|
@@ -65275,7 +65368,8 @@ var StateCheckSchema = external_exports.union([
|
|
|
65275
65368
|
external_exports.strictObject({ "github.pull": external_exports.strictObject({ pull: refUse3, merged: external_exports.boolean() }) }),
|
|
65276
65369
|
external_exports.strictObject({ "github.issue": GitHubIssueCheckSchema }),
|
|
65277
65370
|
GitHubPermissionCheckSchema,
|
|
65278
|
-
OktaUserCheckSchema
|
|
65371
|
+
OktaUserCheckSchema,
|
|
65372
|
+
external_exports.strictObject({ "gmail.thread": GmailThreadCheckSchema })
|
|
65279
65373
|
]);
|
|
65280
65374
|
var SLACK_REACTION_NAME = /^[a-z0-9_+-]+(?:::skin-tone-[2-6])?$/;
|
|
65281
65375
|
var actorAt = duration6("Offset from start_time; must be >= 0");
|
|
@@ -65285,7 +65379,8 @@ var actorActions = [
|
|
|
65285
65379
|
{ "github.comment": external_exports.strictObject({ issue: refUse3, user: refUse3.optional(), body: external_exports.string() }) },
|
|
65286
65380
|
{ "pagerduty.acknowledge": PagerDutyActorArgsSchema },
|
|
65287
65381
|
{ "pagerduty.resolve": PagerDutyActorArgsSchema },
|
|
65288
|
-
{ "sentry.capture": SentryCaptureArgsSchema }
|
|
65382
|
+
{ "sentry.capture": SentryCaptureArgsSchema },
|
|
65383
|
+
{ "gmail.send": GmailSendArgsSchema }
|
|
65289
65384
|
];
|
|
65290
65385
|
var timed = (action) => external_exports.strictObject({ at: actorAt, ...action });
|
|
65291
65386
|
var conditional = (action) => external_exports.strictObject({ when: WorldPredicateSchema, after: duration6("Nonnegative delay after predicate first qualifies").optional(), once: external_exports.literal(true).optional(), ...action });
|
|
@@ -65296,13 +65391,22 @@ var ActorSchema = external_exports.union([
|
|
|
65296
65391
|
timed(actorActions[3]),
|
|
65297
65392
|
timed(actorActions[4]),
|
|
65298
65393
|
timed(actorActions[5]),
|
|
65394
|
+
timed(actorActions[6]),
|
|
65299
65395
|
conditional(actorActions[0]),
|
|
65300
65396
|
conditional(actorActions[1]),
|
|
65301
65397
|
conditional(actorActions[2]),
|
|
65302
65398
|
conditional(actorActions[3]),
|
|
65303
65399
|
conditional(actorActions[4]),
|
|
65304
|
-
conditional(actorActions[5])
|
|
65400
|
+
conditional(actorActions[5]),
|
|
65401
|
+
conditional(actorActions[6])
|
|
65305
65402
|
]);
|
|
65403
|
+
var AppCallSchema = external_exports.strictObject({
|
|
65404
|
+
at: actorAt,
|
|
65405
|
+
method: external_exports.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).default("GET"),
|
|
65406
|
+
path: external_exports.string().regex(/^\/(?!\/)/, "a path on the app, starting with a single /"),
|
|
65407
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
65408
|
+
body: external_exports.union([external_exports.string(), external_exports.record(external_exports.string(), external_exports.unknown()), external_exports.array(external_exports.unknown())]).optional()
|
|
65409
|
+
});
|
|
65306
65410
|
var TraceCheckSchema = external_exports.strictObject({
|
|
65307
65411
|
called: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
|
|
65308
65412
|
not_called: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
|
|
@@ -65331,10 +65435,12 @@ var SceneSchema = external_exports.strictObject({
|
|
|
65331
65435
|
error: "expected an ISO 8601 timestamp with a timezone, e.g. 2026-03-04T14:00:00Z"
|
|
65332
65436
|
}),
|
|
65333
65437
|
time_scale: external_exports.number().positive().default(1),
|
|
65438
|
+
/** Jump the clock to the next timed event while nobody is busy, as worlds with people always do. */
|
|
65439
|
+
skip_idle: external_exports.boolean().optional(),
|
|
65334
65440
|
timeout: duration6("Per-trial time budget, e.g. 5m").default("5m"),
|
|
65335
65441
|
task: external_exports.string().optional(),
|
|
65336
65442
|
seed: external_exports.strictObject({ slack: SlackSeedSchema.optional(), github: GitHubSeedSchema.optional(), datadog: DatadogSeedSchema.optional(), pagerduty: PagerDutySeedSchema.optional(), "linkedin-ads": LinkedInAdsSeedSchema.optional(), salesforce: SalesforceSeedSchema.optional(), gong: GongSeedSchema.optional(), hubspot: HubSpotSeedSchema.optional(), ga4: GA4SeedSchema.optional(), "google-ads": GoogleAdsSeedSchema.optional(), "chatgpt-ads": ChatGPTAdsSeedSchema.optional(), "open-meteo": OpenMeteoSeedSchema.optional(), "google-drive": GoogleDriveSeedSchema.optional(), gmail: GmailSeedSchema.optional(), "amazon-s3": AmazonS3SeedSchema.optional(), linear: LinearSeedSchema.optional(), "okta": OktaSeedSchema.optional(), stripe: StripeSeedSchema.optional(), "clerk": ClerkSeedSchema.optional(), "better-stack": BetterStackSeedSchema.optional(), notion: NotionSeedSchema.optional(), attio: AttioSeedSchema.optional(), "dropbox": DropboxSeedSchema.optional(), resend: ResendSeedSchema.optional(), "microsoft-word": MicrosoftWordSeedSchema.optional(), shopify: ShopifySeedSchema.optional(), "lob": LobSeedSchema.optional(), paypal: PayPalSeedSchema.optional(), jira: JiraSeedSchema.optional(), "kalshi": KalshiSeedSchema.optional(), intercom: IntercomSeedSchema.optional(), "zendesk": ZendeskSeedSchema.optional(), "google-calendar": GoogleCalendarSeedSchema.optional(), "twilio": TwilioSeedSchema.optional(), "asana": AsanaSeedSchema.optional(), "discord": DiscordSeedSchema.optional(), sentry: SentrySeedSchema.optional(), "airtable": AirtableSeedSchema.optional() }),
|
|
65337
|
-
world_rules: external_exports.strictObject({ actors: external_exports.array(ActorSchema).optional(), pipelines: external_exports.array(PipelineRuleSchema).optional(), faults: external_exports.array(FaultRuleSchema).optional(), metrics: external_exports.array(MetricRuleSchema).optional(), logs: external_exports.array(LogRuleSchema).optional(), monitors: external_exports.array(MonitorRuleSchema).optional(), integrations: external_exports.array(IntegrationSchema).optional() }).optional(),
|
|
65443
|
+
world_rules: external_exports.strictObject({ actors: external_exports.array(ActorSchema).optional(), app_calls: external_exports.array(AppCallSchema).optional(), pipelines: external_exports.array(PipelineRuleSchema).optional(), faults: external_exports.array(FaultRuleSchema).optional(), metrics: external_exports.array(MetricRuleSchema).optional(), logs: external_exports.array(LogRuleSchema).optional(), monitors: external_exports.array(MonitorRuleSchema).optional(), integrations: external_exports.array(IntegrationSchema).optional() }).optional(),
|
|
65338
65444
|
people: PeopleSchema.optional(),
|
|
65339
65445
|
until: UntilSchema.optional(),
|
|
65340
65446
|
checks: external_exports.array(CheckSchema),
|