@ancha-labs/cli 0.4.22 → 0.4.23
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 +1202 -476
- package/lib/assets/docs/apps.md +36 -0
- package/lib/assets/docs/cloud.md +30 -0
- package/lib/assets/docs/run.md +14 -0
- package/lib/assets/docs/tools.md +40 -1
- package/lib/assets/harbor/companion.mjs +155 -19
- package/lib/assets/ui/app.js +70 -11
- package/lib/mcp-entry.mjs +21 -3
- package/lib/worker.mjs +398 -79
- package/lib/world-server.mjs +95 -17
- package/package.json +1 -1
package/lib/assets/ui/app.js
CHANGED
|
@@ -581,6 +581,53 @@ function duration(ms) {
|
|
|
581
581
|
return `${Math.floor(s / 3600)} h ${String(Math.floor(s / 60) % 60).padStart(2, "0")} m`;
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
+
// cloud/shared/run-metadata.mjs
|
|
585
|
+
function runNumberOf(value) {
|
|
586
|
+
return Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
587
|
+
}
|
|
588
|
+
function runLabel(run, fallback = run.id ?? run.runId ?? run.run_id ?? "") {
|
|
589
|
+
const number = runNumberOf(run.runNumber ?? run.summary?.runNumber);
|
|
590
|
+
return number === void 0 ? fallback : `#${number}`;
|
|
591
|
+
}
|
|
592
|
+
function github2(value) {
|
|
593
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join(",") !== "repository,runId,serverUrl") throw new Error("Invalid GitHub Actions context.");
|
|
594
|
+
const { repository, runId, serverUrl } = value;
|
|
595
|
+
if (typeof repository !== "string" || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository) || repository.length > 201 || repository.split("/").some((p) => p === "." || p === "..") || typeof runId !== "string" || !/^[1-9]\d{0,19}$/.test(runId)) throw new Error("Invalid GitHub Actions context.");
|
|
596
|
+
let url2;
|
|
597
|
+
try {
|
|
598
|
+
url2 = new URL(serverUrl);
|
|
599
|
+
} catch {
|
|
600
|
+
throw new Error("Invalid GitHub Actions server.");
|
|
601
|
+
}
|
|
602
|
+
if (typeof serverUrl !== "string" || serverUrl.length > 2048 || url2.protocol !== "https:" || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/") throw new Error("Invalid GitHub Actions server.");
|
|
603
|
+
return { repository, runId, serverUrl: url2.origin };
|
|
604
|
+
}
|
|
605
|
+
function validateRunMetadata(value) {
|
|
606
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some((k) => !["runNumber", "startedBy"].includes(k))) throw new Error("Invalid run metadata.");
|
|
607
|
+
if (value.runNumber !== void 0 && runNumberOf(value.runNumber) === void 0) throw new Error("Invalid run number.");
|
|
608
|
+
if (value.startedBy !== void 0) {
|
|
609
|
+
const by = value.startedBy;
|
|
610
|
+
if (!by || typeof by !== "object" || Array.isArray(by) || Object.keys(by).some((k) => !["source", "email", "repository", "url"].includes(k)) || !["console", "cli", "github-actions"].includes(by.source)) throw new Error("Invalid run starter.");
|
|
611
|
+
if (by.email !== void 0 && (typeof by.email !== "string" || by.email.length > 320 || /[\x00-\x1f\x7f]/.test(by.email))) throw new Error("Invalid run starter email.");
|
|
612
|
+
if (by.source === "github-actions") {
|
|
613
|
+
let u;
|
|
614
|
+
try {
|
|
615
|
+
u = new URL(by.url);
|
|
616
|
+
} catch {
|
|
617
|
+
throw new Error("Invalid workflow URL.");
|
|
618
|
+
}
|
|
619
|
+
const match = /^\/(.+)\/actions\/runs\/(\d+)$/.exec(u.pathname);
|
|
620
|
+
if (!match || match[1] !== by.repository || u.search || u.hash || u.username || u.password) throw new Error("Invalid workflow URL.");
|
|
621
|
+
github2({ repository: by.repository, runId: match[2], serverUrl: u.origin });
|
|
622
|
+
} else if (by.repository !== void 0 || by.url !== void 0) throw new Error("Invalid run starter context.");
|
|
623
|
+
}
|
|
624
|
+
return value;
|
|
625
|
+
}
|
|
626
|
+
function starterLabel(by) {
|
|
627
|
+
if (!by) return "";
|
|
628
|
+
return [by.email, by.source === "github-actions" ? "GitHub Actions" : by.source === "cli" ? "CLI" : "", by.repository].filter(Boolean).join(" \xB7 ");
|
|
629
|
+
}
|
|
630
|
+
|
|
584
631
|
// cloud/shared/outcome-counts.mjs
|
|
585
632
|
var count = (value) => Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
586
633
|
function attemptOutcome(attempt, graded) {
|
|
@@ -604,6 +651,16 @@ function countAttempts(attempts, requested, graded) {
|
|
|
604
651
|
}
|
|
605
652
|
|
|
606
653
|
// frontend/src/runs-page.ts
|
|
654
|
+
function starterHtml(run) {
|
|
655
|
+
const by = run.startedBy ?? run.origin?.startedBy;
|
|
656
|
+
try {
|
|
657
|
+
validateRunMetadata({ startedBy: by });
|
|
658
|
+
} catch {
|
|
659
|
+
return "";
|
|
660
|
+
}
|
|
661
|
+
const label2 = h(starterLabel(by));
|
|
662
|
+
return by?.url ? `<a href="${h(by.url)}" target="_blank" rel="noopener noreferrer">${label2}</a>` : label2;
|
|
663
|
+
}
|
|
607
664
|
var SOURCES = { console: "Console", cli: "CLI", ci: "CI", cloud: "Cloud" };
|
|
608
665
|
var TARGETS = { local: "Local", docker: "Docker", hosted: "Hosted", cloud: "Cloud" };
|
|
609
666
|
var RANGES = { "24h": ["24 h", 864e5], "7d": ["7 d", 7 * 864e5], "30d": ["30 d", 30 * 864e5] };
|
|
@@ -710,7 +767,7 @@ function row(item, now, compared, references) {
|
|
|
710
767
|
const attemptLinks = whereKey(run.origin) === "cloud" && !terminal(run.status) ? [] : (run.attempts ?? []).map((a) => a.id && a.taskId ? `/playgrounds/${encodeURIComponent(String(run.id))}?task=${encodeURIComponent(String(a.taskId))}&attempt=${encodeURIComponent(String(a.id))}` : void 0);
|
|
711
768
|
const pending = item.status === "queued" ? queueLabel(run.queue) || "Queued" : item.status === "running" ? "Graded as attempts finish" : "";
|
|
712
769
|
const note = [pending, c.graded && !c.requested ? "Rerun to record requested attempts" : "", c.invalid ? `${c.invalid} invalid` : "", c.skipped ? `${c.skipped} skipped` : "", c.ungraded ? `${c.ungraded} ungraded` : "", !c.graded && !pending && !c.invalid && !c.skipped ? "No checks evaluated" : ""].filter(Boolean).join(" \xB7 ");
|
|
713
|
-
return `<tr><td class="wrap"><a class="rt-row" href="/playgrounds/${encodeURIComponent(String(run.id))}" data-nav><span class="rt-result"><span class="c-${item.status}">${resultBadge(item.status)}</span></span><span class="k-name">${h(item.title)}</span>${run.origin?.branch ? `<span class="k-meta">${h(run.origin.branch)}</span>` : ""}<span class="k-id"
|
|
770
|
+
return `<tr><td class="wrap"><a class="rt-row" href="/playgrounds/${encodeURIComponent(String(run.id))}" data-nav><span class="rt-result"><span class="c-${item.status}">${resultBadge(item.status)}</span></span><span class="k-name">${h(item.title)}</span>${run.origin?.branch ? `<span class="k-meta">${h(run.origin.branch)}</span>` : ""}<span class="k-id">${h(runLabel(run, `#${shortId(String(run.id))}`))}</span></a></td><td class="wrap"><span class="k-name">${h(item.agent || "\u2014")}</span>${item.command ? `<div class="k-id" title="${h(item.command)}">${h(item.command)}</div>` : ""}</td><td>${attemptSquares(attemptStates(run), attemptLinks)}<div class="k-meta">${h(`${c.finished} / ${c.total} done`)}</div></td><td class="num">${c.graded && c.requested ? `${c.passed}/${c.requested}` : "\u2014"}${note ? `<div class="k-meta">${h(note)}</div>` : ""}</td>` + (compared ? `<td>${baselineLink}</td>` : "") + `<td class="wrap k-meta">${h(originLabel(run.origin) || "Console")}${starterHtml(run) ? `<div>${starterHtml(run)}</div>` : ""}</td><td class="wrap num k-meta">${when(run.createdAt, now)}<div>${h(item.status === "queued" ? "Queued" : duration(item.ms))}</div></td></tr>`;
|
|
714
771
|
}
|
|
715
772
|
function runsTable(runs, options = {}) {
|
|
716
773
|
const now = options.now ?? Date.now(), compared = runs.some((run) => baselineNote(run));
|
|
@@ -731,7 +788,7 @@ function runsPage(runs, filters, options = {}) {
|
|
|
731
788
|
const inRange = range ? all.filter((item) => now - timeOf(item.run.createdAt) <= RANGES[range][1]) : all;
|
|
732
789
|
const values = (pick, chosen) => [...new Set([...all.map(pick), chosen].filter((v) => Boolean(v)))];
|
|
733
790
|
const query = String(filters.q ?? "").trim().toLowerCase();
|
|
734
|
-
const matches = (item) => !query || [item.title, item.run.origin?.branch, item.run.id, item.agent, item.command, item.run.test?.name, ...(item.run.tasks ?? []).flatMap((t) => [t.id, t.title, t.prompt])].some((v) => String(v ?? "").toLowerCase().includes(query));
|
|
791
|
+
const matches = (item) => !query || [item.title, item.run.origin?.branch, item.run.id, runLabel(item.run), item.agent, item.command, item.run.test?.name, ...(item.run.tasks ?? []).flatMap((t) => [t.id, t.title, t.prompt])].some((v) => String(v ?? "").toLowerCase().includes(query));
|
|
735
792
|
const shown = inRange.filter((item) => matches(item) && (!filters.agent || item.agent === filters.agent || item.run.agentId === filters.agent || item.run.entries?.some((entry) => entry.agentId === filters.agent)) && (!filters.result || item.status === filters.result) && (!filters.where || item.where === filters.where) && (!filters.commit || item.run.origin?.commit === filters.commit) && (!filters.source || item.run.origin?.source === filters.source) && (!filters.target || item.run.origin?.target === filters.target));
|
|
736
793
|
const select = (name, label2, choices, all2) => `<select class="k-filter" name="${name}" aria-label="${h(label2)}" data-run-filter><option value="">${h(all2)}</option>${choices.map(([value, text2]) => `<option value="${h(value)}" ${filters[name] === value ? "selected" : ""}>${h(text2)}</option>`).join("")}</select>`;
|
|
737
794
|
const commits = values((item) => item.run.origin?.commit, filters.commit);
|
|
@@ -1293,7 +1350,7 @@ function agentCrumb(batch) {
|
|
|
1293
1350
|
}
|
|
1294
1351
|
function runDetails(batch, tasks, attempts) {
|
|
1295
1352
|
const baseline = batch.comparison?.baselineRunId, total = timeOf(batch.finishedAt) - timeOf(batch.startedAt ?? batch.createdAt);
|
|
1296
|
-
return `<section class="k-card" aria-label="Details"><h2>Details</h2>` + (agentName(batch) ? detailRow("Agent", batch.agentId ? navLink(agentName(batch), "/agents/" + encodeURIComponent(String(batch.agentId))) : h(agentName(batch))) : "") + (batch.origin?.commit ? detailRow("Commit", `<span class="k-mono">${h(String(batch.origin.commit).slice(0, 7))}${batch.origin.dirty ? " + changes" : ""}</span>`) : "") + (baseline ? detailRow("Compared with", navLink(shortId(String(baseline)), "/playgrounds/" + encodeURIComponent(String(baseline)))) : "") + detailRow("From", h(originLabel(batch.origin) || "Console")) + (batch.createdAt ? detailRow("Started", `<time datetime="${h(batch.createdAt)}" title="${h(utc(batch.createdAt))}">${h(utcClock(batch.createdAt))}<span class="k-meta"> \xB7 ${h(utcDay(batch.createdAt))}</span></time>`) : "") + (Number.isFinite(total) && total >= 0 ? detailRow("Duration", h(duration(total))) : "") + detailRow("Tests \xD7 attempts", h(`${count2(tasks.length, "test")} \xB7 ${count2(runCounts({ ...batch, tasks, attempts }).total, "attempt")}`)) + (Number(batch.concurrency) > 0 ? detailRow("At once", h(`${batch.concurrency} attempts`)) : "") + (batch.exitCode !== void 0 ? detailRow("Exit", h(batch.exitCode)) : "") + "</section>";
|
|
1353
|
+
return `<section class="k-card" aria-label="Details"><h2>Details</h2>` + (agentName(batch) ? detailRow("Agent", batch.agentId ? navLink(agentName(batch), "/agents/" + encodeURIComponent(String(batch.agentId))) : h(agentName(batch))) : "") + (batch.origin?.commit ? detailRow("Commit", `<span class="k-mono">${h(String(batch.origin.commit).slice(0, 7))}${batch.origin.dirty ? " + changes" : ""}</span>`) : "") + (baseline ? detailRow("Compared with", navLink(shortId(String(baseline)), "/playgrounds/" + encodeURIComponent(String(baseline)))) : "") + (batch.rerunOf ? detailRow("Rerun of", `<a href="/runs/${h(encodeURIComponent(batch.rerunOf.runId))}">${h(shortId(batch.rerunOf.runId))}</a>${batch.rerunOf.mode === "failed" ? " \xB7 failed tests" : ""}`) : "") + detailRow("From", h(originLabel(batch.origin) || "Console")) + (starterHtml(batch) ? detailRow("Started by", starterHtml(batch)) : "") + (batch.createdAt ? detailRow("Started", `<time datetime="${h(batch.createdAt)}" title="${h(utc(batch.createdAt))}">${h(utcClock(batch.createdAt))}<span class="k-meta"> \xB7 ${h(utcDay(batch.createdAt))}</span></time>`) : "") + (Number.isFinite(total) && total >= 0 ? detailRow("Duration", h(duration(total))) : "") + detailRow("Tests \xD7 attempts", h(`${count2(tasks.length, "test")} \xB7 ${count2(runCounts({ ...batch, tasks, attempts }).total, "attempt")}`)) + (Number(batch.concurrency) > 0 ? detailRow("At once", h(`${batch.concurrency} attempts`)) : "") + (batch.exitCode !== void 0 ? detailRow("Exit", h(batch.exitCode)) : "") + "</section>";
|
|
1297
1354
|
}
|
|
1298
1355
|
function testSquares(batch, task, attempts) {
|
|
1299
1356
|
const states = attemptStates({ tasks: [task], attempts });
|
|
@@ -1310,12 +1367,14 @@ function runProgress(batch) {
|
|
|
1310
1367
|
return `<section class="k-card k-progress" aria-label="Progress"><div class="k-progress-line"><strong class="k-big mid">${c.finished} of ${c.total} attempts done</strong></div><div class="k-meter s059-meter" role="img" aria-label="${h(label2)}">${states.map((state) => `<span class="${resultClass(state)}"></span>`).join("")}</div><span class="k-meta">${h(label2)}. Results are graded as each attempt finishes.</span></section>`;
|
|
1311
1368
|
}
|
|
1312
1369
|
function renderRunOverview(batch, actionsHtml = "", options = {}) {
|
|
1370
|
+
if (options.task && batch.rerun && /^run_cloud_/.test(String(batch.id))) actionsHtml += `<form method="post" action="/tests/rerun"><input type="hidden" name="runId" value="${h(batch.id)}"><input type="hidden" name="name" value="${h(options.task)}"><input type="hidden" name="idempotencyKey" value="${h(batch.rerun.key)}-test"><button type="submit" class="k-btn primary">Run x5</button></form>`;
|
|
1371
|
+
if (!options.task && batch.rerun && /^run_cloud_/.test(String(batch.id))) actionsHtml += [["again", "Run again"], ...batch.rerun.failed ? [["failed", "Rerun failed"]] : []].map(([mode, label2]) => `<form method="post" action="/runs/${h(encodeURIComponent(batch.id))}/rerun"><input type="hidden" name="mode" value="${mode}"><input type="hidden" name="idempotencyKey" value="${h(batch.rerun.key)}-${mode}"><button type="submit" class="k-btn">${label2}</button></form>`).join("");
|
|
1313
1372
|
const groups = entrySections(batch), tasks = groups.flatMap((group) => group.tasks), allAttempts = records(batch.attempts), c = runCounts(batch);
|
|
1314
1373
|
const rows3 = groups.flatMap(({ entry, tasks: tasks2, attempts }) => tasks2.map((task) => ({ entry, task, attempts: attempts.filter((a) => a.taskId === task.id) }))).filter((row2) => !options.task || row2.task.id === options.task);
|
|
1315
1374
|
const hasProduction = rows3.some((row2) => reproductionOf(batch, row2.task)), baseline = baselineNote(batch);
|
|
1316
1375
|
const failed = rows3.filter((row2) => row2.attempts.some((a) => a.outcome === "failed")).length;
|
|
1317
1376
|
const noResult = rows3.filter((row2) => row2.attempts.some((a) => ["completed", "error", "stopped"].includes(a.status) && !["passed", "failed"].includes(a.outcome))).length;
|
|
1318
|
-
return `<div class="k-page s059-run"><div class="s059-run-content k-stack"><nav class="k-crumbs" aria-label="Breadcrumb">${agentCrumb(batch)}${navLink("Runs", "/playgrounds")}<span>/</span><span aria-current="page"
|
|
1377
|
+
return `<div class="k-page s059-run"><div class="s059-run-content k-stack"><nav class="k-crumbs" aria-label="Breadcrumb">${agentCrumb(batch)}${navLink("Runs", "/playgrounds")}<span>/</span><span aria-current="page">${h(runLabel(batch, `#${shortId(String(batch.id))}`))}</span></nav><header class="k-head"><div class="k-title"><h1>${h(batch.groupName || runTitle(batch))} <span class="k-num">${h(runLabel(batch, `#${shortId(String(batch.id))}`))}</span></h1>${batch.origin?.branch ? `<span class="k-meta">${h(batch.origin.branch)}</span>` : ""}${resultBadge(runStatus(batch))}</div><div class="k-actions">${kitActions(actionsHtml)}</div></header>${queueLine(batch)}${errorMessage(batch.error)}<div class="k-cols"><div class="k-main">${options.task && rows3[0] ? `<section class="k-card k-task"><span class="k-label">Task</span><div>${h(rows3[0].task.prompt ?? "")}</div></section>${comparisonForm(batch, rows3[0].task, rows3[0].attempts)}` : ""}${["running", "starting", "queued"].includes(batch.status) ? runProgress(batch) : ""}<section class="k-card" aria-label="Tests"><div class="k-card-head"><h2>${c.passed} of ${c.total} passed</h2><nav class="k-seg" aria-label="Filter tests"><button type="button" id="run-filter-all" data-test-filter="all" aria-pressed="true">All (${rows3.length})</button><button type="button" id="run-filter-failed" data-test-filter="failed" aria-pressed="false">Failed (${failed})</button><button type="button" id="run-filter-none" data-test-filter="none" aria-pressed="false">No result (${noResult})</button></nav></div><div class="k-scroll"><table class="k-table mid"><thead><tr><th class="icon-cell"><span class="sr-only">Result</span></th><th>Test</th><th>Attempts</th><th class="num">Passed</th>${hasProduction ? "<th>vs production</th>" : ""}</tr></thead><tbody>${rows3.map(({ entry, task, attempts }) => {
|
|
1319
1378
|
const outcome = taskOutcome(attempts, hasChecks([task]), Number(task.attempts) || attempts.length), reproduction = reproductionOf(batch, task);
|
|
1320
1379
|
return `<tr data-test-row data-failed="${attempts.some((a) => a.outcome === "failed")}" data-none="${attempts.some((a) => ["completed", "error", "stopped"].includes(a.status) && !["passed", "failed"].includes(a.outcome))}"><td class="icon-cell">${resultIcon(taskKind(attempts))}</td><td class="wrap"><button class="k-name" type="button" id="run-test-${h(task.id)}" data-peek-task="${h(task.id)}" aria-haspopup="dialog">${h(taskDisplayName(task, tasks.indexOf(task)))}</button>${groups.length > 1 ? `<div class="k-meta">${h(entry?.agentName ?? entry?.name ?? "")}</div>` : ""}<div class="k-meta">${h(shortPrompt(task.prompt))}</div><template data-test-peek="${h(task.id)}">${testPeek(batch, task, attempts, tasks.indexOf(task))}</template></td><td>${testSquares(batch, task, attempts)}</td><td class="num">${attempts.some((a) => ["passed", "failed"].includes(a.outcome)) ? `${attempts.filter((a) => a.outcome === "passed").length}/${Number(task.attempts) || attempts.length}` : "\u2014"}<div class="k-meta">${h(outcome.note)}</div></td>${hasProduction ? `<td>${productionTag(reproduction ? [reproduction] : []) || "\u2014"}</td>` : ""}</tr>`;
|
|
1321
1380
|
}).join("")}</tbody></table></div>${!rows3.length ? '<p class="k-empty">No tasks recorded.</p>' : ""}<p class="k-empty" data-test-empty hidden>No tests match this filter.</p></section></div><aside class="k-side">${runDetails(batch, tasks, allAttempts)}${baseline ? `<p class="k-meta${baseline.tone === "fail" ? " k-fail-text" : ""}">${h(baseline.text)}</p>` : ""}</aside></div></div><div data-peek-host></div></div>`;
|
|
@@ -1640,8 +1699,8 @@ function renderAttemptWorkspace(batch, attempt, evidence, options = {}) {
|
|
|
1640
1699
|
const content = view2 === "tools" ? toolsNav + (tool ? capturedToolView(observation2, tool, { ...query, baseHref: attemptBase }) : '<p class="quiet-empty">No captured tool data.</p>') : view2 === "conversation" ? response + conversationView(observation2, { focus: query.focus }) : view2 === "logs" ? logs.trim() ? `<pre class="rd-log">${h(logs)}</pre>` : stateCard("No log", "The agent wrote nothing to its output in this attempt.") : response + callsSection(observation2, failing, Number(query.call) || void 0) + productionSection(batch, task, fullEvidence);
|
|
1641
1700
|
const tab2 = (label2, name, href2) => navLink(label2, href2, view2 === name ? "on" : "").replace("<a ", `<a ${view2 === name ? 'aria-current="page" ' : ""}`);
|
|
1642
1701
|
const ms = attemptMs(attempt), calls = Number(fullEvidence.toolCalls ?? attempt.toolCalls) || 0, id = String(batch.id), trace = reproductionOf(batch, task)?.trace;
|
|
1643
|
-
const details2 = `<section class="k-card" aria-label="Details"><h2>Details</h2>${detailRow("Agent", h(entry?.agentName ?? (agentName(batch) || "\u2014")))}${detailRow("Attempt", h(attempt.number))}${detailRow("Duration", h(ms === void 0 ? "\u2014" : duration(ms)))}${detailRow("Tool calls", String(calls))}${detailRow("From", h(originLabel(batch.origin) || "Console"))}${batch.createdAt ? detailRow("Started", `<time datetime="${h(batch.createdAt)}" title="${h(utc(batch.createdAt))}">${h(utcClock(batch.createdAt))} \xB7 ${h(utcDay(batch.createdAt))}</time>`) : ""}${trace ? detailRow("Production trace", `<code title="${h(trace)}">${h(String(trace).slice(0, 8))}</code>`) : ""}${detailRow("Run", navLink(shortId(id), basePath(batch)))}${detailRow("Test", h(task.id))}</section>`;
|
|
1644
|
-
return `<div class="k-page s059-attempt"><nav class="k-crumbs" aria-label="Breadcrumb">${agentCrumb({ ...batch, ...entry?.agentName ? { agentName: entry.agentName, agentId: entry.agentId } : {} })}${navLink(
|
|
1702
|
+
const details2 = `<section class="k-card" aria-label="Details"><h2>Details</h2>${detailRow("Agent", h(entry?.agentName ?? (agentName(batch) || "\u2014")))}${detailRow("Attempt", h(attempt.number))}${detailRow("Duration", h(ms === void 0 ? "\u2014" : duration(ms)))}${detailRow("Tool calls", String(calls))}${detailRow("From", h(originLabel(batch.origin) || "Console"))}${batch.createdAt ? detailRow("Started", `<time datetime="${h(batch.createdAt)}" title="${h(utc(batch.createdAt))}">${h(utcClock(batch.createdAt))} \xB7 ${h(utcDay(batch.createdAt))}</time>`) : ""}${trace ? detailRow("Production trace", `<code title="${h(trace)}">${h(String(trace).slice(0, 8))}</code>`) : ""}${detailRow("Run", navLink(runLabel(batch, shortId(id)), basePath(batch)))}${detailRow("Test", h(task.id))}</section>`;
|
|
1703
|
+
return `<div class="k-page s059-attempt"><nav class="k-crumbs" aria-label="Breadcrumb">${agentCrumb({ ...batch, ...entry?.agentName ? { agentName: entry.agentName, agentId: entry.agentId } : {} })}${navLink(runLabel(batch, shortId(id)), basePath(batch))}<span>/</span>${navLink(taskDisplayName(task, index), taskHref(batch, task))}<span>/</span><span aria-current="page">Attempt ${h(attempt.number)}</span>${copyButton(id, "Copy run id")}</nav><header class="k-head"><div class="k-title"><h1>${h(taskDisplayName(task, index))}</h1>${resultBadge(attemptKind(attempt))}${["starting", "running", "queued"].includes(attempt.status) ? executionBadge(attempt) : ""}</div><div class="k-actions">${cliRun(batch) ? copyCommand(`ancha explain ${id}`) : ""}${kitActions(options.actionsHtml ?? "")}</div></header><nav class="k-attempts" aria-label="Attempts">${attempts.map((a) => navLink(String(a.number), taskHref(batch, task, { attempt: a.id, ...view2 === "evidence" ? {} : { view: view2 } }), `k-att ${resultClass(attemptKind(a))}`).replace("<a ", `<a aria-label="Attempt ${h(a.number)}: ${h(resultLabel(attemptKind(a)))}" ${a.id === attempt.id ? 'aria-current="page" ' : ""}`)).join("")}</nav>${queueLine(batch)}${errorMessage(batch.error)}<div class="k-cols"><div class="k-main"><section class="k-card k-task s060-task"><span class="k-label">Task</span><div class="s060-task-text">${h(String(task.prompt ?? "").trim())}</div>${copyButton(codingAgentText(batch, task, fullEvidence, checks2), "Copy for coding agent")}</section>${invalidNote(attempt)}${stepsSection(observation2, checks2, callHref, jump)}${comparisonForm(batch, task, attempts, attempt)}<nav class="k-seg" aria-label="Attempt evidence">${people2 ? tab2("Conversation", "conversation", taskHref(batch, task, { attempt: attempt.id, view: "conversation" })) : ""}${tab2("Evidence", "evidence", people2 ? taskHref(batch, task, { attempt: attempt.id, view: "evidence" }) : attemptBase)}${tab2("World data", "tools", taskHref(batch, task, { attempt: attempt.id, view: "tools" }))}${tab2("Logs", "logs", taskHref(batch, task, { attempt: attempt.id, view: "logs" }))}</nav><div id="attempt-evidence" class="aw-evidence-body">${errorMessage(fullEvidence.error)}${content}</div></div><aside class="k-side">${attemptChecks(checks2, records(observation2.trace).filter((t) => t.path !== "console.manual_action").sort((a, b) => (Number(a.seq) || 0) - (Number(b.seq) || 0)), callHref, jump)}${details2}</aside></div></div>`;
|
|
1645
1704
|
}
|
|
1646
1705
|
function renderManagedComparison(data) {
|
|
1647
1706
|
const sides = records(data.attempts ?? [data.left, data.right]);
|
|
@@ -1781,7 +1840,7 @@ function mountWorldWorkspace(node, options) {
|
|
|
1781
1840
|
if (disposed) return;
|
|
1782
1841
|
const currentRuns = selected ? setupRuns(runs, selected) : [], run = currentRuns[0], attempts = run?.attempts ?? [], tasks = selected?.tasks ?? [], choices = worldSetups(tests, world.id, agentId);
|
|
1783
1842
|
const usedBy = worldSetups(tests, world.id), datasets = world.configuration?.preset?.datasets ?? [];
|
|
1784
|
-
node.innerHTML = `<div class="k-page world-v2"><nav class="k-crumbs" aria-label="Breadcrumb"><a data-nav href="/worlds">Worlds</a><span>/</span><span aria-current="page">${h(world.name)}</span></nav><header class="k-head"><div><div class="k-title"><h1>${h(world.name)}</h1><span class="k-badge">Revision ${h(world.revision)}</span></div><div class="worlds-id"><code title="${h(world.id)}">${h(shortId(world.id))}</code>${copyButton(world.id, "Copy world id")}</div></div><div class="k-actions"><span class="world-agent-select"><select class="k-filter" aria-label="Agent" 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></span><a data-nav class="k-btn" href="${base}?data=1">View data</a><button class="k-btn" type="button" data-ww="configure">Configure</button>${selected ? options.runActions?.(selected.id) ?? button("Run tasks", "run-saved-test", selected.id, "k-btn primary") : ""}</div></header><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("")}${error || errors.length ? '<button class="k-btn" type="button" data-ww="retry">Retry loading tasks and runs</button>' : ""}${!loaded ? skeletonRows(4) : ""}<div class="k-cols"><div class="k-main">${choices.length > 1 ? `<span class="world-setup-select"><select class="k-filter" aria-label="Configuration" 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></span>` : ""}${loaded && configure ? configuration2() : loaded ? `${run ? latestRun(run, attempts, tasks) : ""}<section class="k-card"><div class="k-card-head"><h2>Tasks${tasks.length ? ` \xB7 ${tasks.length}` : ""}</h2><div class="k-actions">${worldHistory(runs, world.id, agentId || void 0).length || selected ? `<button class="k-btn small" type="button" data-ww="history" aria-expanded="${showHistory}">History</button>` : ""}<button class="k-btn small" type="button" data-ww="configure">${tasks.length ? "Edit tasks" : "Add tasks"}</button></div></div>${tasks.length ? taskTable(tasks, attempts, run) : stateCard("Add tasks to this world", agents.length ? "Configure tasks for your agent to run." : "Connect an agent to run tasks.", agents.length ? '<button class="k-btn" type="button" data-ww="configure">Add tasks</button>' : '<a class="k-btn" data-nav href="/agents">Connect an agent</a>')}</section>${selected && !currentRuns.length && setupHistory(runs, selected).some((item) => item.earlier) ? '<p class="k-meta">This configuration has changed. Earlier attempts are in History.</p>' : ""}${showHistory ? history2() : ""}` : ""}${peopleSection(world, true)}</div><aside class="k-side"><section class="k-card"><div class="k-card-head"><h2>Tools \xB7 ${datasets.length}</h2><a data-nav href="${base}?edit=1">Edit world</a></div><div class="k-scroll" role="region" aria-label="World tools" tabindex="0"><table class="k-table"><thead><tr><th scope="col">Tool</th><th scope="col">Records</th></tr></thead><tbody>${datasets.map((dataset) => `<tr><td><a data-nav class="k-name world-tool-label" href="/tools/${enc(dataset.tool)}">${toolLogo(dataset.tool)}${h(toolName(dataset.tool))}</a></td><td><a data-nav class="k-name" href="${base}?data=1&tool=${enc(dataset.tool)}">View data</a></td></tr>`).join("")}</tbody></table></div>${!datasets.length ? '<p class="k-empty">No tools</p>' : ""}</section>${loaded ? `<section class="k-card"><div class="k-card-head"><h2>Used by ${usedBy.length} ${usedBy.length === 1 ? "test" : "tests"}</h2></div>${usedBy.length ? usedBy.map((test) => `<a data-nav class="k-kv k-name" href="${h(href2(test, test.agentId))}">${h(test.name)}</a>`).join("") : '<p class="k-empty">No tests</p>'}</section>` : ""}</aside></div></div>`;
|
|
1843
|
+
node.innerHTML = `<div class="k-page world-v2"><nav class="k-crumbs" aria-label="Breadcrumb"><a data-nav href="/worlds">Worlds</a><span>/</span><span aria-current="page">${h(world.name)}</span></nav><header class="k-head"><div><div class="k-title"><h1>${h(world.name)}</h1><span class="k-badge">Revision ${h(world.revision)}</span></div><div class="worlds-id"><code title="${h(world.id)}">${h(shortId(world.id))}</code>${copyButton(world.id, "Copy world id")}</div></div><div class="k-actions"><span class="world-agent-select"><select class="k-filter" aria-label="Agent" 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></span><a data-nav class="k-btn" href="${base}?data=1">View data</a><a data-nav class="k-btn" href="${h(base + "?new=1&configure=1" + (agentId ? "&agent=" + enc(agentId) : ""))}">New test in this world</a><button class="k-btn" type="button" data-ww="configure">Configure</button>${selected ? options.runActions?.(selected.id) ?? button("Run tasks", "run-saved-test", selected.id, "k-btn primary") : ""}</div></header><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("")}${error || errors.length ? '<button class="k-btn" type="button" data-ww="retry">Retry loading tasks and runs</button>' : ""}${!loaded ? skeletonRows(4) : ""}<div class="k-cols"><div class="k-main">${choices.length > 1 ? `<span class="world-setup-select"><select class="k-filter" aria-label="Configuration" 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></span>` : ""}${loaded && configure ? configuration2() : loaded ? `${run ? latestRun(run, attempts, tasks) : ""}<section class="k-card"><div class="k-card-head"><h2>Tasks${tasks.length ? ` \xB7 ${tasks.length}` : ""}</h2><div class="k-actions">${worldHistory(runs, world.id, agentId || void 0).length || selected ? `<button class="k-btn small" type="button" data-ww="history" aria-expanded="${showHistory}">History</button>` : ""}<button class="k-btn small" type="button" data-ww="configure">${tasks.length ? "Edit tasks" : "Add tasks"}</button></div></div>${tasks.length ? taskTable(tasks, attempts, run) : stateCard("Add tasks to this world", agents.length ? "Configure tasks for your agent to run." : "Connect an agent to run tasks.", agents.length ? '<button class="k-btn" type="button" data-ww="configure">Add tasks</button>' : '<a class="k-btn" data-nav href="/agents">Connect an agent</a>')}</section>${selected && !currentRuns.length && setupHistory(runs, selected).some((item) => item.earlier) ? '<p class="k-meta">This configuration has changed. Earlier attempts are in History.</p>' : ""}${showHistory ? history2() : ""}` : ""}${peopleSection(world, true)}<section class="k-cmd-card"><strong>New test from your coding assistant</strong>${copyCommand(`ancha playground test create --name "<test name>" --agent ${agentId || "<agent id>"} --world ${world.id} --tasks tasks.json`)}</section></div><aside class="k-side"><section class="k-card"><div class="k-card-head"><h2>Tools \xB7 ${datasets.length}</h2><a data-nav href="${base}?edit=1">Edit world</a></div><div class="k-scroll" role="region" aria-label="World tools" tabindex="0"><table class="k-table"><thead><tr><th scope="col">Tool</th><th scope="col">Records</th></tr></thead><tbody>${datasets.map((dataset) => `<tr><td><a data-nav class="k-name world-tool-label" href="/tools/${enc(dataset.tool)}">${toolLogo(dataset.tool)}${h(toolName(dataset.tool))}</a></td><td><a data-nav class="k-name" href="${base}?data=1&tool=${enc(dataset.tool)}">View data</a></td></tr>`).join("")}</tbody></table></div>${!datasets.length ? '<p class="k-empty">No tools</p>' : ""}</section>${loaded ? `<section class="k-card"><div class="k-card-head"><h2>Used by ${usedBy.length} ${usedBy.length === 1 ? "test" : "tests"}</h2></div>${usedBy.length ? usedBy.map((test) => `<a data-nav class="k-kv k-name" href="${h(href2(test, test.agentId))}">${h(test.name)}</a>`).join("") : '<p class="k-empty">No tests</p>'}</section>` : ""}</aside></div></div>`;
|
|
1785
1844
|
}
|
|
1786
1845
|
function latestRun(run, attempts, tasks) {
|
|
1787
1846
|
const requested = run.summary?.counts?.requested ?? attempts.length, summary = executionSummary(attempts, requested), outcome = taskOutcome(attempts, hasChecks(run.tasks ?? tasks), requested);
|
|
@@ -2014,7 +2073,7 @@ function historyBars(runs, history2) {
|
|
|
2014
2073
|
const bars = runs.map((run) => {
|
|
2015
2074
|
const counts = runCounts(run), states = attemptStates(run);
|
|
2016
2075
|
const passed = counts.passed, failed = states.filter((state) => state === "failed").length;
|
|
2017
|
-
return { id: run.id, createdAt: run.createdAt, href: "/playgrounds/" + encodeURIComponent(run.id), passed, failed, none: Math.max(0, counts.total - passed - failed), total: counts.total };
|
|
2076
|
+
return { id: run.id, runNumber: run.runNumber, createdAt: run.createdAt, href: "/playgrounds/" + encodeURIComponent(run.id), passed, failed, none: Math.max(0, counts.total - passed - failed), total: counts.total };
|
|
2018
2077
|
});
|
|
2019
2078
|
for (const run of history2) {
|
|
2020
2079
|
if (!run.summary || bars.some((bar) => bar.id === run.runId)) continue;
|
|
@@ -2024,7 +2083,7 @@ function historyBars(runs, history2) {
|
|
|
2024
2083
|
const ungraded = summary?.verdict === "ungraded" || run.view?.state === "ungraded";
|
|
2025
2084
|
const passed = ungraded ? 0 : c?.passed ?? scenes.reduce((n, s) => n + Number(s.passed ?? 0), 0);
|
|
2026
2085
|
const failed = ungraded ? 0 : c?.failed ?? 0;
|
|
2027
|
-
bars.push({ id: run.runId, createdAt: summary.startedAt ?? run.status?.startedAt, href: "/playgrounds/" + encodeURIComponent(run.runId), passed, failed, none: Math.max(0, total - passed - failed), total });
|
|
2086
|
+
bars.push({ id: run.runId, runNumber: summary.runNumber, createdAt: summary.startedAt ?? run.status?.startedAt, href: "/playgrounds/" + encodeURIComponent(run.runId), passed, failed, none: Math.max(0, total - passed - failed), total });
|
|
2028
2087
|
}
|
|
2029
2088
|
return bars.sort(newestFirst).slice(0, 10).reverse();
|
|
2030
2089
|
}
|
|
@@ -2037,10 +2096,10 @@ function agentRecentRuns(runs, agent, emptyAction, options = {}) {
|
|
|
2037
2096
|
const recent = historyBars(runs, options.history ?? []), max = Math.max(1, ...recent.map((run) => run.total));
|
|
2038
2097
|
const legend = `<div class="ag-legend">${[["pass", "Passed"], ["fail", "Failed"], ["none", "No result"]].map(([kind, label2]) => `<span><span class="k-icon ${kind}" role="img" aria-label="${label2}"></span>${label2}</span>`).join("")}</div>`;
|
|
2039
2098
|
return `<section class="k-card" aria-label="Results over time"><div class="k-card-head"><h2>${recent.length ? `Last ${recent.length} ${recent.length === 1 ? "run" : "runs"}` : "Runs"}</h2>${legend}</div>${recent.length ? `<div class="k-scroll"><div class="ag-chart"><div class="ag-axis k-meta"><span>${max}</span><span>0</span></div><div class="ag-bars">${recent.map((run) => {
|
|
2040
|
-
const label2 = `Run ${shortId(String(run.id))}: ${run.passed} passed, ${run.failed} failed, ${run.none} no result`;
|
|
2099
|
+
const label2 = `Run ${runLabel(run, shortId(String(run.id)))}: ${run.passed} passed, ${run.failed} failed, ${run.none} no result`;
|
|
2041
2100
|
const pass = Math.round(10 * run.passed / max), fail = Math.round(10 * (run.passed + run.failed) / max) - pass;
|
|
2042
2101
|
const none = Math.round(10 * run.total / max) - pass - fail;
|
|
2043
|
-
return `<a class="ag-run" href="${h(run.href)}" data-nav aria-label="${h(label2)}" title="${h(label2)}"><span class="ag-run-stack" aria-hidden="true"><span class="ag-segment pass ag-h-${pass}"></span><span class="ag-segment fail ag-h-${fail}"></span><span class="ag-segment none ag-h-${none}"></span></span><span class="ag-run-id">${h(String(run.id).slice(-7))}</span></a>`;
|
|
2102
|
+
return `<a class="ag-run" href="${h(run.href)}" data-nav aria-label="${h(label2)}" title="${h(label2)}"><span class="ag-run-stack" aria-hidden="true"><span class="ag-segment pass ag-h-${pass}"></span><span class="ag-segment fail ag-h-${fail}"></span><span class="ag-segment none ag-h-${none}"></span></span><span class="ag-run-id">${h(runLabel(run, String(run.id).slice(-7)))}</span></a>`;
|
|
2044
2103
|
}).join("")}</div></div></div><p class="k-note"><a class="k-more" data-nav href="${h(all)}">All runs</a></p>` : stateCard("No runs yet", "Run a saved task to see its results here.", emptyAction)}</section>`;
|
|
2045
2104
|
}
|
|
2046
2105
|
function testLastRun(run, testId) {
|
package/lib/mcp-entry.mjs
CHANGED
|
@@ -57354,10 +57354,10 @@ var EXECUTION_SUPPORT = {
|
|
|
57354
57354
|
"agent.input.per_event": sceneOnly,
|
|
57355
57355
|
"agent.input.events": localOnly,
|
|
57356
57356
|
"agent.input.http": all,
|
|
57357
|
-
"agent.endpoint": localOnly,
|
|
57357
|
+
"agent.endpoint": { ...localOnly, "cloud-vm": true },
|
|
57358
57358
|
"agent.slack_transport.feed": sceneOnly,
|
|
57359
|
-
"agent.slack_transport.http": localOnly,
|
|
57360
|
-
"agent.slack_transport.socket": localOnly,
|
|
57359
|
+
"agent.slack_transport.http": { ...localOnly, "cloud-vm": true },
|
|
57360
|
+
"agent.slack_transport.socket": { ...localOnly, "cloud-vm": true },
|
|
57361
57361
|
"agent.env": sceneOnly,
|
|
57362
57362
|
"agent.pass_env": sceneOnly,
|
|
57363
57363
|
"agent.execution": sceneOnly,
|
|
@@ -67302,6 +67302,7 @@ var fields2 = {
|
|
|
67302
67302
|
};
|
|
67303
67303
|
var TestFileSchema = external_exports.strictObject({
|
|
67304
67304
|
...fields2,
|
|
67305
|
+
function_tools: SceneSchema.shape.tools,
|
|
67305
67306
|
world: external_exports.union([WorldId, external_exports.record(external_exports.string(), external_exports.unknown())], { error: WORLD_ERROR }),
|
|
67306
67307
|
until: external_exports.unknown().optional(),
|
|
67307
67308
|
checks: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional(),
|
|
@@ -67309,6 +67310,7 @@ var TestFileSchema = external_exports.strictObject({
|
|
|
67309
67310
|
});
|
|
67310
67311
|
var TestFileDocument = external_exports.strictObject({
|
|
67311
67312
|
...fields2,
|
|
67313
|
+
function_tools: SceneSchema.shape.tools,
|
|
67312
67314
|
world: external_exports.union([WorldId, WorldBodySchema]).describe("A world file's id (ancha/worlds/<id>.yaml), or the world inline"),
|
|
67313
67315
|
until: SceneSchema.shape.until,
|
|
67314
67316
|
checks: SceneSchema.shape.checks.optional(),
|
|
@@ -67798,6 +67800,22 @@ var NAMED_TARGETS = {
|
|
|
67798
67800
|
var TRANSACTIONS = new Set(NETSUITE_TRANSACTION_TYPES);
|
|
67799
67801
|
var ITEMS = new Set(NETSUITE_ITEM_TYPES);
|
|
67800
67802
|
|
|
67803
|
+
// packages/core/src/function-tool-observation.ts
|
|
67804
|
+
var functionToolObservationSchema = external_exports.strictObject({
|
|
67805
|
+
registered: external_exports.array(external_exports.string()),
|
|
67806
|
+
complete: external_exports.boolean(),
|
|
67807
|
+
protocol_version: external_exports.number().int().nonnegative().optional(),
|
|
67808
|
+
required: external_exports.array(external_exports.string()),
|
|
67809
|
+
missing: external_exports.array(external_exports.string()),
|
|
67810
|
+
tools: external_exports.array(external_exports.strictObject({
|
|
67811
|
+
name: external_exports.string(),
|
|
67812
|
+
registered: external_exports.boolean(),
|
|
67813
|
+
called: external_exports.number().int().nonnegative(),
|
|
67814
|
+
completed: external_exports.number().int().nonnegative(),
|
|
67815
|
+
pending: external_exports.number().int().nonnegative()
|
|
67816
|
+
}))
|
|
67817
|
+
});
|
|
67818
|
+
|
|
67801
67819
|
// backend/src/mcp/configuration.ts
|
|
67802
67820
|
function validateMcpConnection(connection) {
|
|
67803
67821
|
let url3;
|