@ancha-labs/cli 0.1.6 → 0.2.1

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.
@@ -1639,7 +1639,7 @@ function starterCount(tool, key, state) {
1639
1639
  }
1640
1640
 
1641
1641
  // frontend/src/generated/coding-agent-skill.ts
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## 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. If it doesn't, `ancha traces diff <trace file> latest` shows the calls production made and the trial didn't; the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\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";
1643
1643
 
1644
1644
  // frontend/src/workspace-pages.ts
1645
1645
  var startSentence = "Test our agent with Ancha. Start with: npx -y @ancha-labs/cli init, then read https://app.ancha.io/llms.txt";
@@ -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
@@ -57330,6 +57330,7 @@ var EXECUTION_SUPPORT = {
57330
57330
  "world": sceneOnly,
57331
57331
  "start_time": sceneOnly,
57332
57332
  "time_scale": sceneOnly,
57333
+ "skip_idle": sceneOnly,
57333
57334
  "seed": sceneOnly,
57334
57335
  "world_rules": sceneOnly,
57335
57336
  "people": sceneOnly,
@@ -57769,13 +57770,14 @@ var DatadogSeedSchema = external_exports.strictObject({
57769
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(),
57770
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()
57771
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)");
57772
57774
  var PagerDutySeedSchema = external_exports.strictObject({
57773
- 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"),
57774
57776
  actor: ref6.optional(),
57775
57777
  default_service: ref6.describe("Defaults to the sole declared service; required with multiple services").optional(),
57776
- 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(),
57777
- 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) })),
57778
- 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),
57779
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()
57780
57782
  });
57781
57783
  var FaultRuleSchema = external_exports.strictObject({
@@ -57875,13 +57877,15 @@ var ListenSchema = external_exports.union([
57875
57877
  var AccountsSchema = external_exports.strictObject({
57876
57878
  slack: refUse.optional().describe("Their Slack user, from seed.slack.users"),
57877
57879
  github: refUse.optional().describe("Their GitHub identity, from seed.github.users"),
57878
- 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")
57879
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");
57880
- 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"];
57881
57885
  var WorkSchema = external_exports.strictObject({
57882
57886
  after: worldDuration("Simulated time from the start of the attempt, or from when `when` first holds", 0).default("0s"),
57883
57887
  when: WorldPredicateSchema.optional().describe("The work waits until this holds"),
57884
- do: external_exports.enum(PERSON_ACTIONS),
57888
+ do: external_exports.enum(WORK_ACTIONS),
57885
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"),
57886
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")
57887
57891
  });
@@ -57915,6 +57919,7 @@ var PersonStepSchema = external_exports.discriminatedUnion("action", [
57915
57919
  external_exports.object({ action: external_exports.literal("comment"), where: stepWhere, text: stepText }),
57916
57920
  external_exports.object({ action: external_exports.literal("open_issue"), where: stepWhere, title: external_exports.string().trim().min(1).max(256), text: stepText }),
57917
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 }),
57918
57923
  external_exports.object({ action: external_exports.literal("wait") })
57919
57924
  ]);
57920
57925
 
@@ -58974,6 +58979,27 @@ var message = external_exports.strictObject({
58974
58979
  in_reply_to: ref7.optional(),
58975
58980
  attachments: external_exports.array(attachment).max(20).default([])
58976
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");
58977
59003
  var draft = message.omit({ from: true, labels: true }).extend({ at: when.default("0s") });
58978
59004
  var label3 = external_exports.strictObject({
58979
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"),
@@ -65208,8 +65234,11 @@ function duration6(description2) {
65208
65234
  }
65209
65235
  }).describe(description2);
65210
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();
65211
65238
  var SlackUserSeed = external_exports.strictObject({
65212
65239
  ref: refName3,
65240
+ id: slackIdPin("UW", "U048N5Q2JL4"),
65241
+ bot_id: slackIdPin("B", "B04A1BC2DEF"),
65213
65242
  name: external_exports.string(),
65214
65243
  real_name: external_exports.string().optional(),
65215
65244
  email: external_exports.string().optional(),
@@ -65217,6 +65246,7 @@ var SlackUserSeed = external_exports.strictObject({
65217
65246
  });
65218
65247
  var SlackChannelSeed = external_exports.strictObject({
65219
65248
  ref: refName3,
65249
+ id: slackIdPin("CG", "C048N5Q2JL4"),
65220
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)"),
65221
65251
  is_private: external_exports.boolean().optional(),
65222
65252
  topic: external_exports.string().optional(),
@@ -65231,10 +65261,11 @@ var SlackPost = external_exports.strictObject({
65231
65261
  thread_of: refUse3.optional()
65232
65262
  });
65233
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"),
65234
65265
  at: duration6("Offset from start_time; must be <= 0 (seed messages are history)").default("0s")
65235
65266
  });
65236
65267
  var SlackSeedSchema = external_exports.strictObject({
65237
- 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(),
65238
65269
  bot: refUse3.optional(),
65239
65270
  users: external_exports.array(SlackUserSeed),
65240
65271
  channels: external_exports.array(SlackChannelSeed),
@@ -65337,7 +65368,8 @@ var StateCheckSchema = external_exports.union([
65337
65368
  external_exports.strictObject({ "github.pull": external_exports.strictObject({ pull: refUse3, merged: external_exports.boolean() }) }),
65338
65369
  external_exports.strictObject({ "github.issue": GitHubIssueCheckSchema }),
65339
65370
  GitHubPermissionCheckSchema,
65340
- OktaUserCheckSchema
65371
+ OktaUserCheckSchema,
65372
+ external_exports.strictObject({ "gmail.thread": GmailThreadCheckSchema })
65341
65373
  ]);
65342
65374
  var SLACK_REACTION_NAME = /^[a-z0-9_+-]+(?:::skin-tone-[2-6])?$/;
65343
65375
  var actorAt = duration6("Offset from start_time; must be >= 0");
@@ -65347,7 +65379,8 @@ var actorActions = [
65347
65379
  { "github.comment": external_exports.strictObject({ issue: refUse3, user: refUse3.optional(), body: external_exports.string() }) },
65348
65380
  { "pagerduty.acknowledge": PagerDutyActorArgsSchema },
65349
65381
  { "pagerduty.resolve": PagerDutyActorArgsSchema },
65350
- { "sentry.capture": SentryCaptureArgsSchema }
65382
+ { "sentry.capture": SentryCaptureArgsSchema },
65383
+ { "gmail.send": GmailSendArgsSchema }
65351
65384
  ];
65352
65385
  var timed = (action) => external_exports.strictObject({ at: actorAt, ...action });
65353
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 });
@@ -65358,13 +65391,22 @@ var ActorSchema = external_exports.union([
65358
65391
  timed(actorActions[3]),
65359
65392
  timed(actorActions[4]),
65360
65393
  timed(actorActions[5]),
65394
+ timed(actorActions[6]),
65361
65395
  conditional(actorActions[0]),
65362
65396
  conditional(actorActions[1]),
65363
65397
  conditional(actorActions[2]),
65364
65398
  conditional(actorActions[3]),
65365
65399
  conditional(actorActions[4]),
65366
- conditional(actorActions[5])
65400
+ conditional(actorActions[5]),
65401
+ conditional(actorActions[6])
65367
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
+ });
65368
65410
  var TraceCheckSchema = external_exports.strictObject({
65369
65411
  called: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
65370
65412
  not_called: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
@@ -65393,10 +65435,12 @@ var SceneSchema = external_exports.strictObject({
65393
65435
  error: "expected an ISO 8601 timestamp with a timezone, e.g. 2026-03-04T14:00:00Z"
65394
65436
  }),
65395
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(),
65396
65440
  timeout: duration6("Per-trial time budget, e.g. 5m").default("5m"),
65397
65441
  task: external_exports.string().optional(),
65398
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() }),
65399
- 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(),
65400
65444
  people: PeopleSchema.optional(),
65401
65445
  until: UntilSchema.optional(),
65402
65446
  checks: external_exports.array(CheckSchema),