import { Chronicle } from "@chroniclelabs/sdk";
const client = new Chronicle();
const example = (await client.worlds.examples.list()).items.find((e) =>
(e.blueprint.scenario.tasks ?? []).some((t) => t.key === "triage-duplicate-invoice"));
if (!example) throw new Error("The duplicate-invoice example is not available");
const preview = await client.worlds.compile({ blueprint: example.blueprint });
if (preview.problems.length) throw new Error(preview.problems.join("\n"));
let world = await client.worlds.create({ blueprint: example.blueprint, idempotencyKey: "demo-1" });
world = await client.worlds.wait(world.world.id, { timeout: 180_000 });
if (world.status !== "ready") throw new Error(`World ${world.world.id}: ${world.status}; ${world.launchError}`);
if (world.evaluation?.status !== "ready") {
throw new Error(`Task setup is not ready for world ${world.world.id}; see the Worlds guide`);
}
let run = await client.evaluations.create({
taskSuiteId: world.evaluation.taskSuiteId,
agents: ["billing-agent@1.0.0"],
idempotencyKey: "demo-run-1",
});
run = await client.evaluations.wait(run.id, { timeout: 600_000 });
if (run.status !== "succeeded") throw new Error(`Evaluation ${run.id}: ${run.status}; inspect its trials`);
const results = await client.evaluations.results(run.id);
for (const task of results.taskResults) {
console.log(task.taskId, task.passed ? "passed" : "failed", task.failedScorers);
}