monoban 1.15.0 → 1.17.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.
Files changed (2) hide show
  1. package/dist/index.mjs +1374 -262
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -860,12 +860,12 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
860
860
  issues: []
861
861
  }, ctx);
862
862
  if (result instanceof Promise) throw new $ZodAsyncError();
863
- return result.issues.length ? failure$1(_Err, result.issues, ctx) : {
863
+ return result.issues.length ? failure$2(_Err, result.issues, ctx) : {
864
864
  success: true,
865
865
  data: result.value
866
866
  };
867
867
  };
868
- function failure$1(Err, issues, ctx) {
868
+ function failure$2(Err, issues, ctx) {
869
869
  let error;
870
870
  return {
871
871
  success: false,
@@ -894,7 +894,7 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
894
894
  issues: []
895
895
  }, ctx);
896
896
  if (result instanceof Promise) result = await result;
897
- return result.issues.length ? failure$1(_Err, result.issues, ctx) : {
897
+ return result.issues.length ? failure$2(_Err, result.issues, ctx) : {
898
898
  success: true,
899
899
  data: result.value
900
900
  };
@@ -5892,6 +5892,14 @@ function linkLabel(link) {
5892
5892
  return link.url;
5893
5893
  }
5894
5894
  }
5895
+ /**
5896
+ * A GitHub pull request's URL as one key, `owner/name/pull/N`, read from the URL lowercased (however it was written:
5897
+ * without a scheme, `www.`, `/files`, a query or a #fragment), as parseLink reads its repository and number. Written
5898
+ * once for both sides: `prKey` here, and the API's SQL (`substring(lower(url) from PR_KEY_PATTERN)`, MON-291), whose
5899
+ * queue and counts can't run JavaScript. The pattern is the same in both regex dialects.
5900
+ */
5901
+ const PR_KEY_PATTERN = String.raw`^(?:https?://)?(?:www\.)?github\.com/([a-z0-9][a-z0-9-]{0,38}/[a-z0-9._-]{1,100}/pull/[1-9][0-9]{0,8})(?:[/?#]|$)`;
5902
+ new RegExp(PR_KEY_PATTERN);
5895
5903
  // ../../packages/contract/src/runs.ts
5896
5904
  /**
5897
5905
  * Runs: a coding agent working on a task on the user's machine (docs/PLAN-ORCHESTRATOR.md). `monoban runner`
@@ -5916,7 +5924,7 @@ const RUN_ENDINGS$1 = [
5916
5924
  ];
5917
5925
  /**
5918
5926
  * Why a run ended the way it did, as a code (MON-303): the reason's English words stay its detail, and the web says
5919
- * the code's sentence in the reader's language (`runs.reason.<code>`) with them under it. Only an ending a person acts
5927
+ * the code's sentence in the reader's language (`shared.run.reason.<code>`, `describeRunReason`) with them under it. Only an ending a person acts
5920
5928
  * on has one; any other has none, and reads as its words. Add new ones; never change the meaning of existing ones. One
5921
5929
  * meaning, one code, named as the API's problems are (MON-288).
5922
5930
  */
@@ -5932,6 +5940,12 @@ const RUN_REASON_CODES = [
5932
5940
  "agent_signed_out",
5933
5941
  "cannot_push",
5934
5942
  "commands_unverified",
5943
+ "site_not_permitted",
5944
+ "sites_step_ineligible",
5945
+ "sites_nothing_fetched",
5946
+ "sites_invalid",
5947
+ "advisor_switch_off",
5948
+ "accept_switch_off",
5935
5949
  "budget_spent",
5936
5950
  "decisions_unratified",
5937
5951
  "checks_pending",
@@ -6090,7 +6104,11 @@ const LOOP_LIMITS = {
6090
6104
  /** scavenge: its open tasks before it stops filing. */
6091
6105
  scavengeMaxOpen: range(1, 20),
6092
6106
  /** scavenge: what to look for, on one line. */
6093
- focus: 500
6107
+ focus: 500,
6108
+ /** deliver: the sites its runs may read (`sites`; AGE-193 D12, agentpipe's own limits): at most this many… */
6109
+ sites: 20,
6110
+ /** …and this many characters in all: the sum of the entries' lengths, as sent. */
6111
+ sitesCharacters: 1e3
6094
6112
  };
6095
6113
  /** What a loop's options are when left out. Merge is on unless the loop says otherwise (plan §1.10.3). */
6096
6114
  const LOOP_DEFAULTS = {
@@ -6105,11 +6123,211 @@ const LOOP_DEFAULTS = {
6105
6123
  askMinutes: 0,
6106
6124
  /** deliver: agentpipe's own tier for its review step. */
6107
6125
  reviewTier: null,
6126
+ /** deliver: its runs set no network and no sites: the machine's own agentpipe config decides (`sites`, below). */
6127
+ network: false,
6128
+ /**
6129
+ * deliver: agentpipe's `arbitrate` answers only the questions a source supports (at most 5), and a run stops for
6130
+ * you on the rest. On: it answers every one nobody answered, on its best judgement when nothing supports an answer,
6131
+ * saying why (agentpipe's `--advisor`, AGE-204).
6132
+ */
6133
+ advisor: false,
6134
+ /**
6135
+ * deliver: the merge waits until you accept each decision a run made on its own. On: they are accepted at merge
6136
+ * (agentpipe's `--accept-decisions`, AGE-204). Only on a loop that merges (`acceptAtMergeProblem`).
6137
+ */
6138
+ acceptAtMerge: false,
6108
6139
  scavengeMaxOpen: 5
6109
6140
  };
6110
6141
  /** A tier's name, as agentpipe takes it (`--tier NAME`). */
6111
6142
  const TIER_NAME = /^[a-z][a-z0-9_-]{0,31}$/;
6112
6143
  /**
6144
+ * deliver: the sites a loop's runs may read (MON-248, AGE-193). With its `network` on, agentpipe's `resolve` and
6145
+ * `arbitrate` steps may fetch pages from these sites and no others, so an answer that cites a page can be checked
6146
+ * (agentpipe ADR-22); the runner's machine still permits only the sites in its own agentpipe config
6147
+ * (`permitted_sites` under `[callers]`). This is agentpipe's rule for a caller's site (AGE-215,
6148
+ * `agentpipe/config/callers.py`), written once here for the API's schema, the loop dialog and the demo; agentpipe's
6149
+ * fixture is `packages/contract/samples/domains.json`, its release's `samples/domains.json` as the pin brings it, and
6150
+ * `sites.test.ts` holds this rule to it. A site is an exact
6151
+ * host name (never `*.`, AGE-193 D18): ASCII letters, digits and hyphens in dot-separated labels (an international
6152
+ * name as punycode, `xn--`), folded to lower case, at most 253 characters, with at least two labels; no scheme, path,
6153
+ * port, IP address, trailing dot, `localhost` or single label.
6154
+ */
6155
+ const SITE_RULE = {
6156
+ host: 253,
6157
+ label: 63
6158
+ };
6159
+ /** Each reason in English, as agentpipe says it (the API's `detail`). */
6160
+ const SITE_REASON_WORDS = {
6161
+ empty: "it is empty",
6162
+ whitespace: "it holds whitespace",
6163
+ not_ascii: "it is not ASCII; write an international name as punycode (xn--)",
6164
+ scheme_or_path: "it holds a scheme or a path; name the host alone",
6165
+ ip_address: "it is an IP address; name a host",
6166
+ port: "it holds a port; name the host alone",
6167
+ wildcard_alone: "a wildcard must be followed by a host",
6168
+ wildcard_position: "a wildcard may only open the entry, as *.",
6169
+ wildcard_too_wide: "a wildcard needs a host of two labels or more after *.",
6170
+ wildcard: "a loop names an exact host, never a wildcard",
6171
+ trailing_dot: "it ends with a dot",
6172
+ too_long: `it is longer than ${SITE_RULE.host} characters`,
6173
+ empty_label: "it has an empty label",
6174
+ label_too_long: `a label is longer than ${SITE_RULE.label} characters`,
6175
+ bad_character: "it holds a character other than letters, digits, hyphens and dots",
6176
+ hyphen_at_edge: "a label starts or ends with a hyphen",
6177
+ localhost: "it names this machine",
6178
+ single_label: "it is a single label; name a full host"
6179
+ };
6180
+ /** What Python's `str.isspace()` calls whitespace, which agentpipe refuses first after emptiness. */
6181
+ const SPACE = /[\t\n\v\f\r \x1c-\x1f\x85\xa0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]/;
6182
+ const ASCII = /^[\x00-\x7f]*$/;
6183
+ const LABEL = /^[a-z0-9-]+$/;
6184
+ /** A last label a URL parser reads as part of an IPv4 address (`127.1`, `0x7f.0.0.1`). */
6185
+ const NUMERIC_LABEL = /^(?:[0-9]+|0x[0-9a-f]*)$/;
6186
+ /** Python's `IPv4Address`: four decimal octets, no leading zeros. */
6187
+ function isIPv4(text) {
6188
+ const octets = text.split(".");
6189
+ return octets.length === 4 && octets.every((o) => /^(?:0|[1-9][0-9]{0,2})$/.test(o) && Number(o) <= 255);
6190
+ }
6191
+ /** Python's `IPv6Address`: eight hextets, one `::` for one or more of them, maybe an IPv4 tail and a `%zone`. */
6192
+ function isIPv6(text) {
6193
+ const zone = text.indexOf("%");
6194
+ if (zone !== -1 && (zone === text.length - 1 || text.includes("%", zone + 1))) return false;
6195
+ const parts = (zone === -1 ? text : text.slice(0, zone)).split(":");
6196
+ if (parts.length < 3) return false;
6197
+ const tail = parts.at(-1);
6198
+ if (tail.includes(".")) {
6199
+ if (!isIPv4(tail)) return false;
6200
+ parts.splice(-1, 1, "0", "0");
6201
+ }
6202
+ if (parts.length > 9) return false;
6203
+ const skips = parts.flatMap((part, i) => part === "" && i > 0 && i < parts.length - 1 ? [i] : []);
6204
+ if (skips.length > 1) return false;
6205
+ let hextets = parts;
6206
+ if (skips.length === 1) {
6207
+ const skip = skips[0];
6208
+ const head = parts.slice(0, skip);
6209
+ const rest = parts.slice(skip + 1);
6210
+ if (head[0] === "" && head.length !== 1) return false;
6211
+ if (rest.at(-1) === "" && rest.length !== 1) return false;
6212
+ hextets = [...head, ...rest].filter((part) => part !== "");
6213
+ if (hextets.length > 7) return false;
6214
+ } else if (parts.length !== 8) return false;
6215
+ return hextets.every((h) => /^[0-9a-fA-F]{1,4}$/.test(h));
6216
+ }
6217
+ /** Python's `ipaddress.ip_address()` takes it, bare or in brackets. */
6218
+ function isIp(entry) {
6219
+ const bare = entry.startsWith("[") && entry.endsWith("]") ? entry.slice(1, -1) : entry;
6220
+ return isIPv4(bare) || isIPv6(bare);
6221
+ }
6222
+ var Refused = class {
6223
+ reason;
6224
+ constructor(reason) {
6225
+ this.reason = reason;
6226
+ }
6227
+ };
6228
+ function checkLabel(label) {
6229
+ if (!label) throw new Refused("empty_label");
6230
+ if (label.length > SITE_RULE.label) throw new Refused("label_too_long");
6231
+ if (!LABEL.test(label)) throw new Refused("bad_character");
6232
+ if (label.startsWith("-") || label.endsWith("-")) throw new Refused("hyphen_at_edge");
6233
+ }
6234
+ /** `name`, already folded, if the rule takes it as a host. */
6235
+ function host(name) {
6236
+ if (name.endsWith(".")) throw new Refused("trailing_dot");
6237
+ if (name.length > SITE_RULE.host) throw new Refused("too_long");
6238
+ const labels = name.split(".");
6239
+ for (const label of labels) checkLabel(label);
6240
+ const last = labels.at(-1);
6241
+ if (NUMERIC_LABEL.test(last)) throw new Refused("ip_address");
6242
+ if (last === "localhost") throw new Refused("localhost");
6243
+ if (labels.length < 2) throw new Refused("single_label");
6244
+ return name;
6245
+ }
6246
+ /** agentpipe's `caller_site`: its `machine_site` (a host, or `*.` and a host), and then no wildcard. */
6247
+ function callerSite(entry) {
6248
+ if (!entry) throw new Refused("empty");
6249
+ if (SPACE.test(entry)) throw new Refused("whitespace");
6250
+ if (!ASCII.test(entry)) throw new Refused("not_ascii");
6251
+ if (entry.includes("/") || entry.includes("\\")) throw new Refused("scheme_or_path");
6252
+ if (isIp(entry)) throw new Refused("ip_address");
6253
+ if (entry.includes(":")) throw new Refused("port");
6254
+ const folded = entry.toLowerCase();
6255
+ if (!folded.includes("*")) return host(folded);
6256
+ if (folded === "*" || folded === "*.") throw new Refused("wildcard_alone");
6257
+ if (!folded.startsWith("*.") || folded.slice(2).includes("*")) throw new Refused("wildcard_position");
6258
+ try {
6259
+ host(folded.slice(2));
6260
+ } catch (refused) {
6261
+ throw refused instanceof Refused && refused.reason === "single_label" ? new Refused("wildcard_too_wide") : refused;
6262
+ }
6263
+ throw new Refused("wildcard");
6264
+ }
6265
+ /** One entry as a loop may name it: the site, folded to lower case, or why the rule refuses it. */
6266
+ function siteOf(entry) {
6267
+ try {
6268
+ return { site: callerSite(entry) };
6269
+ } catch (refused) {
6270
+ return { reason: refused.reason };
6271
+ }
6272
+ }
6273
+ /** Why a loop's sites are refused (`SitesProblem`), or null. The limits count the entries as sent. */
6274
+ function sitesProblem(entries) {
6275
+ if (entries.length > LOOP_LIMITS.sites) return {
6276
+ index: null,
6277
+ reason: "too_many",
6278
+ message: `At most ${LOOP_LIMITS.sites} sites`
6279
+ };
6280
+ if (entries.reduce((sum, entry) => sum + entry.length, 0) > LOOP_LIMITS.sitesCharacters) return {
6281
+ index: null,
6282
+ reason: "too_long_in_all",
6283
+ message: `At most ${LOOP_LIMITS.sitesCharacters.toLocaleString("en-US")} characters of sites in all`
6284
+ };
6285
+ for (const [index, entry] of entries.entries()) {
6286
+ const read = siteOf(entry);
6287
+ if ("reason" in read) {
6288
+ const message = `Site ${index + 1} isn't one a loop can read: ${SITE_REASON_WORDS[read.reason]}`;
6289
+ return {
6290
+ index,
6291
+ reason: read.reason,
6292
+ message
6293
+ };
6294
+ }
6295
+ }
6296
+ return null;
6297
+ }
6298
+ /**
6299
+ * Accepting decisions at merge needs a loop that merges: one that never merges has nothing to accept. It doesn't
6300
+ * need the advisor (the two are independent, AGE-204 decision 5). Why not, on `acceptAtMerge`, or null.
6301
+ */
6302
+ function acceptAtMergeProblem({ merge, acceptAtMerge }) {
6303
+ return acceptAtMerge && !merge ? {
6304
+ path: "acceptAtMerge",
6305
+ message: "Turn merge on to accept decisions at merge, or turn this off"
6306
+ } : null;
6307
+ }
6308
+ /**
6309
+ * A loop's sites as stored: folded to lower case, each once, sorted, so the order and case they were typed in never
6310
+ * change the loop (its version hashes its options). A repeat is no error.
6311
+ */
6312
+ function sitesOf(entries) {
6313
+ return [...new Set(entries.map((entry) => entry.toLowerCase()))].sort();
6314
+ }
6315
+ /**
6316
+ * The network and the sites go together: on names at least one site, and sites need it on. Why not, on which
6317
+ * option, or null.
6318
+ */
6319
+ function networkProblem({ network, sites }) {
6320
+ if (network && sites.length === 0) return {
6321
+ path: "sites",
6322
+ message: "Name the sites its runs may read, or turn the network off"
6323
+ };
6324
+ if (!network && sites.length > 0) return {
6325
+ path: "network",
6326
+ message: "Turn the network on for these sites, or name none"
6327
+ };
6328
+ return null;
6329
+ }
6330
+ /**
6113
6331
  * The steps a deliver run can continue a pull request from (`POST /v1/loops/{id}/runs {task, from}`): the ones
6114
6332
  * after it was opened and reviewed. `merge` only when the loop merges.
6115
6333
  */
@@ -6128,25 +6346,54 @@ const MERGE_HOLDS = ["mergeOff"];
6128
6346
  * never ended), or `beforeMerge` when it did every step and merge was skipped (its loop didn't merge).
6129
6347
  */
6130
6348
  const STOPPED_AT = [...RECIPES$1.deliver.steps, "beforeMerge"];
6349
+ /** A decision id, as agentpipe makes them. */
6350
+ const DECISION_ID = /^[0-9a-f]{12}$/;
6351
+ /**
6352
+ * agentpipe's run id as monoban takes it (`r-20261113-200354-T5BA`), loosely: one word that starts with a letter or a
6353
+ * digit, since `agentpipe ratify` takes it as an argument (never an option, a prefix to look up, or `@last`).
6354
+ */
6355
+ const AGENTPIPE_RUN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
6356
+ /**
6357
+ * An accepted decision with its run (`DecisionsAccept`'s): a plain id, as a body before MON-302 sends it, is a decision
6358
+ * of the run that opened the pull request (`opener`, agentpipe's).
6359
+ */
6360
+ function acceptedOf(accepted, opener) {
6361
+ return typeof accepted === "string" ? {
6362
+ id: accepted,
6363
+ run: opener
6364
+ } : accepted;
6365
+ }
6131
6366
  /**
6132
6367
  * What a loop's Needs you list holds (MON-279): `loop`, the loop itself when it's stopped for something you fix
6133
6368
  * (`loopNeedsYou`), never in the route's list (the web draws it from the loop's state, and the loop's `needsYou`
6134
6369
  * counts it); then a row per task: its merge waits on decisions only you can accept (`decision`), its pull request
6135
- * waits for you (`review`), or its run failed and the loop won't take it again on its own (`failed`).
6370
+ * waits for you (`review`), its pull request was closed without merging (`closed`, MON-291: run it again, move it or
6371
+ * archive it), or its run failed and the loop won't take it again on its own (`failed`).
6136
6372
  */
6137
6373
  const NEEDS_YOU_KINDS = [
6138
6374
  "loop",
6139
6375
  "decision",
6140
6376
  "review",
6377
+ "closed",
6141
6378
  "failed"
6142
6379
  ];
6143
6380
  /** The kinds of a task's row. */
6144
6381
  const TASK_NEEDS_YOU_KINDS = [
6145
6382
  "decision",
6146
6383
  "review",
6384
+ "closed",
6147
6385
  "failed"
6148
6386
  ];
6149
6387
  /**
6388
+ * Whether a running loop's run waits for your answer now (MON-295): its `going.waitingUntil` is ahead, the time the
6389
+ * run's own `waitingUntil` says (a question only you can settle, MON-260). A loop in any other state says that state
6390
+ * (paused stays paused).
6391
+ */
6392
+ function loopWaits({ state, going }, now = Date.now()) {
6393
+ if (state.state !== "running" || !going?.waitingUntil) return false;
6394
+ return Date.parse(going.waitingUntil) > now;
6395
+ }
6396
+ /**
6150
6397
  * A loop's runs from the API (newest first) as its history lists them. Why a run stops before merge is the server's
6151
6398
  * (`mergeHold`: the loop doesn't merge). It's shown for a run going on, which will stop there, and for one that
6152
6399
  * ended with a pull request, which did. A run that ended without one (cancelled, or failed before it got that far, as
@@ -6192,14 +6439,6 @@ const PAUSE_REASONS = [
6192
6439
  "unstartable"
6193
6440
  ];
6194
6441
  /**
6195
- * What a runner can do beyond running its recipes, as it says when it registers and at each check-in (MON-223): by
6196
- * what its process says now, as its recipes are. A loop whose options need one (`loopNeeds`) is `runnerOutdated` on a
6197
- * runner that doesn't say it. A name is added here by the task that teaches the runner it, never before (a runner
6198
- * that said one it hasn't would be handed what it can't do): `sites` (MON-248), `advisor` (MON-266), `gates`
6199
- * (MON-224). None yet.
6200
- */
6201
- const RUNNER_FEATURES = [];
6202
- /**
6203
6442
  * Why a runner can't start a loop's run, as its process says at each check-in (MON-223). A code that means what one
6204
6443
  * of `RUN_REASON_CODES` means is that one. The first three mean it runs no loops at all (it offers no recipes):
6205
6444
  * - `loops_off_here`: loops are off on that machine (`--no-loops`, or `loops.enabled: false` in its runner.json);
@@ -6628,6 +6867,8 @@ const PROBLEM_CODES = [
6628
6867
  "too_many_loops",
6629
6868
  "no_runner",
6630
6869
  "open_tasks_limit",
6870
+ "runner_outdated",
6871
+ "daily_limit",
6631
6872
  "used_by_loop",
6632
6873
  "place_gone",
6633
6874
  "too_late"
@@ -7226,6 +7467,23 @@ const loopCommon = {
7226
7467
  /** Runs in a row that failed, since it was last resumed, before it pauses itself. */
7227
7468
  pauseAfter: wholeBetween(LOOP_LIMITS.pauseAfter)
7228
7469
  };
7470
+ /** A list of sites as JSON Schema can say it: the rule itself is `SitesSchema`'s. */
7471
+ const sitesList = () => array(string().meta({
7472
+ maxLength: SITE_RULE.host,
7473
+ pattern: "^[A-Za-z0-9.-]+$"
7474
+ }));
7475
+ /**
7476
+ * A deliver loop's sites (loops.ts `sitesProblem`, `sitesOf`): a refused entry's message is on its index, the limits'
7477
+ * on the list. Stored folded, unique and sorted.
7478
+ */
7479
+ const SitesSchema = sitesList().superRefine((entries, ctx) => {
7480
+ const problem = sitesProblem(entries);
7481
+ if (problem) ctx.addIssue({
7482
+ code: "custom",
7483
+ path: problem.index === null ? [] : [problem.index],
7484
+ message: problem.message
7485
+ });
7486
+ }).overwrite(sitesOf).meta({ maxItems: LOOP_LIMITS.sites });
7229
7487
  /** ASK_MINUTES, one literal each (`z.literal` of a list keeps only the first in the OpenAPI document). */
7230
7488
  const ASK_MINUTES_SCHEMA = union([
7231
7489
  literal(0),
@@ -7248,7 +7506,31 @@ const deliverFields = {
7248
7506
  /** The agentpipe tier its review step runs on (`--tier`); null: agentpipe's own. */
7249
7507
  reviewTier: string().regex(TIER_NAME, "A tier's name, like light").nullable(),
7250
7508
  /** How long a run waits for your answer to a question only you can settle, in minutes; 0: it doesn't wait. */
7251
- askMinutes: ASK_MINUTES_SCHEMA
7509
+ askMinutes: ASK_MINUTES_SCHEMA,
7510
+ /**
7511
+ * Its runs' `resolve` and `arbitrate` steps may fetch pages from `sites`, and only those (agentpipe's
7512
+ * `allow_network`, MON-248; loops.ts `SITE_RULE`). On needs a site. Their reads narrow to the repository, so a
7513
+ * question whose answer is only in a dependency installed outside it is escalated to you.
7514
+ */
7515
+ network: boolean(),
7516
+ /**
7517
+ * The sites they may read (agentpipe's `allowed_domains`): exact host names, kept folded to lower case, each once,
7518
+ * sorted. Only with the network on; the runner's machine must also permit each one in its own agentpipe config.
7519
+ */
7520
+ sites: SitesSchema,
7521
+ /**
7522
+ * agentpipe's `arbitrate` answers every question a run raised that nobody answered: from research when it can, on
7523
+ * its best judgement when it can't, saying why (agentpipe's `--advisor`, AGE-204). Off: it answers only what a
7524
+ * source supports, and the run stops for you on the rest. The runner's machine must allow it in its own agentpipe
7525
+ * config.
7526
+ */
7527
+ advisor: boolean(),
7528
+ /**
7529
+ * The decisions its runs made on their own are accepted at merge, without you (agentpipe's `--accept-decisions`,
7530
+ * AGE-204); some still wait for you (one hard to reverse, a judgement whose citation failed). Only with `merge` on.
7531
+ * The runner's machine must allow it in its own agentpipe config.
7532
+ */
7533
+ acceptAtMerge: boolean()
7252
7534
  };
7253
7535
  const scavengeFields = {
7254
7536
  ...loopCommon,
@@ -7275,10 +7557,20 @@ const DeliverOptionsSchema = strictObject({
7275
7557
  maxOpen: deliverFields.maxOpen.default(LOOP_DEFAULTS.deliverMaxOpen),
7276
7558
  checksMinutes: deliverFields.checksMinutes.default(LOOP_DEFAULTS.checksMinutes),
7277
7559
  reviewTier: deliverFields.reviewTier.default(LOOP_DEFAULTS.reviewTier),
7278
- askMinutes: deliverFields.askMinutes.default(LOOP_DEFAULTS.askMinutes)
7560
+ askMinutes: deliverFields.askMinutes.default(LOOP_DEFAULTS.askMinutes),
7561
+ network: deliverFields.network.default(LOOP_DEFAULTS.network),
7562
+ sites: deliverFields.sites.default([]),
7563
+ advisor: deliverFields.advisor.default(LOOP_DEFAULTS.advisor),
7564
+ acceptAtMerge: deliverFields.acceptAtMerge.default(LOOP_DEFAULTS.acceptAtMerge)
7279
7565
  }).refine(budgetFits, {
7280
7566
  message: BUDGET_FITS,
7281
7567
  path: ["budgetUsd"]
7568
+ }).superRefine((options, ctx) => {
7569
+ for (const problem of [networkProblem(options), acceptAtMergeProblem(options)]) if (problem) ctx.addIssue({
7570
+ code: "custom",
7571
+ path: [problem.path],
7572
+ message: problem.message
7573
+ });
7282
7574
  }).meta({ id: "DeliverOptions" });
7283
7575
  const ScavengeOptionsSchema = strictObject({
7284
7576
  ...scavengeFields,
@@ -7331,14 +7623,30 @@ const RunStepSchema = object({
7331
7623
  * its column and tag had, and for a run that continues a pull request, the step it starts at, the pull request and
7332
7624
  * the run that opened it. Only the server writes it.
7333
7625
  */
7626
+ const DecisionIdSchema = string().regex(DECISION_ID, "A decision id is 12 hex characters");
7334
7627
  /**
7335
- * The provisional decisions a person accepted for a continued run's merge: agentpipe's decision ids (`agentpipe
7336
- * ratify` takes them) and the pull request's head commit they read them at.
7628
+ * The provisional decisions a person accepted for a continued run's merge: each agentpipe's decision id and its run
7629
+ * (`agentpipe ratify` takes both), and the pull request's head commit they read them at. A plain id (the body before
7630
+ * MON-302, taken for one more release) is a decision of the run that opened the pull request.
7337
7631
  */
7338
7632
  const DecisionsAcceptSchema = strictObject({
7339
- decisions: array(string().regex(/^[0-9a-f]{12}$/, "A decision id is 12 hex characters")).min(1).max(20),
7633
+ decisions: array(union([DecisionIdSchema, strictObject({
7634
+ id: DecisionIdSchema,
7635
+ run: string().regex(AGENTPIPE_RUN, "agentpipe's run id, as the decision names it")
7636
+ }).meta({ id: "AcceptedDecision" })])).min(1).max(20),
7340
7637
  headSha: string().regex(/^[0-9a-f]{40}$/, "The full commit the decisions were read at")
7341
7638
  }).meta({ id: "DecisionsAccept" });
7639
+ /**
7640
+ * The pull request a start-over closes before it runs the task again from the first step (MON-292), and agentpipe's
7641
+ * run that opened it (`agentpipe close --expect-run`; its branch is `agentpipe/<id>`), null when that run never said
7642
+ * it. Not the run's own pull request: the run opens a new one.
7643
+ */
7644
+ const LoopRunClosesSchema = object({
7645
+ prUrl: string(),
7646
+ /** The monoban run that opened it. */
7647
+ continues: IdSchema,
7648
+ externalId: string().nullable()
7649
+ }).meta({ id: "LoopRunCloses" });
7342
7650
  const LoopRunPlanSchema = object({
7343
7651
  /** The loop's options when the run was made (its recipe's: DeliverOptionsSet or ScavengeOptionsSet). */
7344
7652
  options: union([DeliverOptionsSetSchema, ScavengeOptionsSetSchema]),
@@ -7362,9 +7670,15 @@ const LoopRunPlanSchema = object({
7362
7670
  /** A run continued from merge after a person accepted the earlier run's provisional decisions; else null. */
7363
7671
  accept: DecisionsAcceptSchema.nullable().optional(),
7364
7672
  /**
7365
- * A person started it on a task they named (`{task}`, `{task, from}`, an accept: MON-273): a one-off, which may
7366
- * start on a paused loop (from a browser) and never counts toward the loop's `perDay` or `pauseAfter`. False for
7367
- * Run now (`{}`) and for a run its runner's check-in started.
7673
+ * A start-over (`{task, startOver}`, MON-292): the pull request it closes through agentpipe first, then a fresh run
7674
+ * of the task with its own pull request. Never in `prUrl` and `externalId`, which are the run's own. Else null.
7675
+ */
7676
+ closes: LoopRunClosesSchema.nullable().optional(),
7677
+ /**
7678
+ * A person started it from a signed-in browser on a task they named (`{task}`, `{task, from}`, an accept, a start
7679
+ * over: MON-273): a one-off, which may start on a paused loop and never counts toward the loop's `perDay` or
7680
+ * `pauseAfter`. False for Run now (`{}`), for a run its runner's check-in started, and for a named start from a CLI
7681
+ * or a personal token, which counts like the loop's own runs (MON-315).
7368
7682
  */
7369
7683
  byPerson: boolean()
7370
7684
  }).meta({ id: "LoopRunPlan" });
@@ -7386,6 +7700,13 @@ const TaskRunSchema = object({
7386
7700
  mayMerge: boolean().nullable(),
7387
7701
  /** Why it may not (`mergeOff`); null when it may, or isn't a deliver loop's. */
7388
7702
  mergeHold: _enum(MERGE_HOLDS).nullable(),
7703
+ /**
7704
+ * A deliver loop's run: whether its task is in the loop's queue now (MON-280), as the loop's claim reads it with
7705
+ * the options the loop has now: the loop takes it again at a later run. False: it won't on its own (with a tag,
7706
+ * the tag came off when a run took it; without one, the loop tries each task once). Null for a run that isn't a
7707
+ * deliver loop's, or whose loop or task is gone.
7708
+ */
7709
+ taskQueued: boolean().nullable(),
7389
7710
  runner: object({
7390
7711
  /** Null once the runner is gone. */
7391
7712
  id: IdSchema.nullable(),
@@ -7565,7 +7886,10 @@ object({
7565
7886
  /** At least one option, or the patch would change nothing (the refine, for JSON Schema: minProperties). */
7566
7887
  const someOption = (o) => Object.keys(o).length > 0;
7567
7888
  const SOME_OPTION = "Send at least one option to change";
7568
- const DeliverOptionsPatchSchema = strictObject(deliverFields).partial().refine(someOption, SOME_OPTION).meta({
7889
+ const DeliverOptionsPatchSchema = strictObject({
7890
+ ...deliverFields,
7891
+ sites: sitesList().meta({ maxItems: LOOP_LIMITS.sites })
7892
+ }).partial().refine(someOption, SOME_OPTION).meta({
7569
7893
  id: "DeliverOptionsPatch",
7570
7894
  minProperties: 1
7571
7895
  });
@@ -7619,7 +7943,13 @@ const LoopBase = object({
7619
7943
  name: string(),
7620
7944
  online: boolean(),
7621
7945
  /** Its machine merges loops' pull requests: false when its runner says it never does (`loops.merge: false`). */
7622
- merges: boolean()
7946
+ merges: boolean(),
7947
+ /**
7948
+ * What its runner can do beyond its recipes (loops.ts `RUNNER_FEATURES`), as its process said last, online or
7949
+ * not: the loop page tells you when it lacks one the loop's options need (`missingFeatures`, MON-249). None once
7950
+ * the runner is gone.
7951
+ */
7952
+ features: array(string())
7623
7953
  }).meta({ id: "LoopRunner" }),
7624
7954
  workdir: string(),
7625
7955
  /** Between the starts of its runs. */
@@ -7627,11 +7957,15 @@ const LoopBase = object({
7627
7957
  /** Null: on. Else why it's paused. */
7628
7958
  paused: _enum(PAUSE_REASONS).nullable(),
7629
7959
  state: LoopStateSchema,
7630
- /** Its run going now (queued or running): the step it's in (null before the first) and its task, if it has one. */
7960
+ /**
7961
+ * Its run going now (queued or running): the step it's in (null before the first) and its task, if it has one, and
7962
+ * while it waits for your answer, until when (worked out as the run's `waitingUntil` is, MON-295).
7963
+ */
7631
7964
  going: object({
7632
7965
  runId: IdSchema,
7633
7966
  step: string().nullable(),
7634
- ref: string().nullable()
7967
+ ref: string().nullable(),
7968
+ waitingUntil: Timestamp.nullable()
7635
7969
  }).nullable().meta({ id: "LoopGoing" }),
7636
7970
  /** Its runs started in the last 24 hours, and what they cost. */
7637
7971
  last24h: object({
@@ -7676,6 +8010,12 @@ object({
7676
8010
  }).meta({ id: "NeedsYouRun" }),
7677
8011
  /** Its pull request; null for `failed`. */
7678
8012
  prUrl: string().nullable(),
8013
+ /**
8014
+ * Its task's link to that pull request, as last heard (agentpipe's `ledger sync` refreshes it): `closed` is the
8015
+ * `closed` kind, and a `merged` or `closed` one can't be continued (MON-291). Null when there's no link, no state, or
8016
+ * no pull request.
8017
+ */
8018
+ prState: _enum(LINK_STATES).nullable(),
7679
8019
  /** Where that run stopped, and the step to continue the pull request from that fits it (contract's `whereItStopped`). */
7680
8020
  stopped: object({
7681
8021
  at: _enum(STOPPED_AT).nullable(),
@@ -7687,20 +8027,77 @@ object({
7687
8027
  hold: _enum(MERGE_HOLDS).nullable(),
7688
8028
  /**
7689
8029
  * `decision`: the decisions the pull request's latest blocked merge reported, at the last commit it named, each
7690
- * with the run that reported it (what accepting them names). Null for the other kinds.
8030
+ * with the run that reported it and agentpipe's run that made it (what accepting them names). Null for the other
8031
+ * kinds.
7691
8032
  */
7692
8033
  pending: object({
7693
8034
  headSha: string(),
7694
8035
  decisions: array(object({
7695
8036
  id: string(),
7696
8037
  run: IdSchema,
8038
+ /**
8039
+ * agentpipe's run that made it (agentpipe 0.15.0), which accepting it names (`{ id, run }`, MON-302).
8040
+ * Null when the runner didn't say (an older runner or agentpipe): the run that opened the pull request,
8041
+ * and accepting it sends its id alone.
8042
+ */
8043
+ agentpipeRun: string().nullable(),
7697
8044
  questionId: string(),
7698
8045
  category: string(),
7699
8046
  question: string().nullable(),
7700
- answer: string()
7701
- }).meta({ id: "PendingDecision" })).max(20)
7702
- }).nullable().meta({ id: "PendingDecisions" })
8047
+ answer: string(),
8048
+ /**
8049
+ * How it was reached (agentpipe's `method`, MON-268): `judgement` is best judgement, any other cites a
8050
+ * source. Null when the runner didn't say.
8051
+ */
8052
+ method: string().nullable(),
8053
+ /** A best judgement whose cited source couldn't be confirmed; null when the runner didn't say. */
8054
+ unverified: boolean().nullable(),
8055
+ /** The reason the agent gave for a best judgement; null when none. */
8056
+ rationale: string().nullable(),
8057
+ /**
8058
+ * Why it waits for you on a loop that accepts decisions at merge (agentpipe's `waits_because`:
8059
+ * `unverified`, `hard`, `not_announced`, or a later word); null on a loop that doesn't accept them.
8060
+ */
8061
+ waitsBecause: string().nullable()
8062
+ }).meta({ id: "PendingDecision" })).max(20),
8063
+ /** How many decisions wait in all: more than `decisions` when one accept can't take them all (MON-300). */
8064
+ total: number$1().int().nonnegative(),
8065
+ /**
8066
+ * The decisions later runs on the pull request replaced (AGE-221): shown, never offered, never counted.
8067
+ */
8068
+ replaced: array(object({
8069
+ id: string(),
8070
+ agentpipeRun: string().nullable(),
8071
+ questionId: string(),
8072
+ category: string(),
8073
+ replacedBy: string(),
8074
+ replacedByRun: string().nullable()
8075
+ }).meta({ id: "ReplacedDecision" })).max(20)
8076
+ }).nullable().meta({ id: "PendingDecisions" }),
8077
+ /**
8078
+ * It carries the loop's tag again, in the loop's column, but its pull request may still be open, so the loop
8079
+ * doesn't take it (MON-291): it takes it once the pull request is closed. False for the other rows.
8080
+ */
8081
+ retagged: boolean()
7703
8082
  }).meta({ id: "NeedsYou" });
8083
+ object({
8084
+ project: object({
8085
+ key: string(),
8086
+ name: string()
8087
+ }).meta({ id: "NeedsYouProject" }),
8088
+ loop: object({
8089
+ id: IdSchema,
8090
+ name: string()
8091
+ }).meta({ id: "NeedsYouLoopRef" }),
8092
+ /** The loop itself is stopped for something you fix: paused by its failures or a run that couldn't start, no runner, a runner too old. */
8093
+ own: boolean(),
8094
+ /** Its tasks' rows, newest first. */
8095
+ tasks: array(object({
8096
+ ref: string(),
8097
+ kind: _enum(TASK_NEEDS_YOU_KINDS)
8098
+ }).meta({ id: "NeedsYouTask" })),
8099
+ count: number$1().int().positive()
8100
+ }).meta({ id: "NeedsYouLoop" });
7704
8101
  const LoopCreateBase = {
7705
8102
  name: loopName,
7706
8103
  runnerId: IdSchema,
@@ -7737,18 +8134,35 @@ strictObject({
7737
8134
  * With `from: "merge"`, from the browser only: the provisional decisions the last run reported, accepted. The run
7738
8135
  * ratifies them (`agentpipe ratify`) before it merges.
7739
8136
  */
7740
- accept: DecisionsAcceptSchema.optional()
8137
+ accept: DecisionsAcceptSchema.optional(),
8138
+ /**
8139
+ * With `task`, from a browser only (MON-292): start it over. Its pull request from this loop, which may still be
8140
+ * open, is closed through agentpipe first (a comment says why, and its branch is deleted), then a new run does the
8141
+ * task from the first step. Never with `from`.
8142
+ */
8143
+ startOver: boolean().optional()
7741
8144
  }).refine((body) => body.from === void 0 || body.task !== void 0, {
7742
8145
  message: "Name the task whose pull request to continue",
7743
8146
  path: ["from"]
7744
8147
  }).refine((body) => body.accept === void 0 || body.from === "merge", {
7745
8148
  message: "Decisions are accepted for a merge: continue from merge",
7746
8149
  path: ["accept"]
8150
+ }).refine((body) => body.startOver === void 0 || body.task !== void 0, {
8151
+ message: "Name the task to start over",
8152
+ path: ["startOver"]
8153
+ }).refine((body) => !body.startOver || body.from === void 0, {
8154
+ message: "A start-over runs the task from the start: leave out from",
8155
+ path: ["startOver"]
7747
8156
  }).meta({
7748
8157
  id: "LoopRunCreate",
7749
8158
  dependentRequired: {
7750
8159
  from: ["task"],
7751
- accept: ["from"]
8160
+ accept: ["from"],
8161
+ startOver: ["task"]
8162
+ },
8163
+ not: {
8164
+ required: ["startOver", "from"],
8165
+ properties: { startOver: { const: true } }
7752
8166
  }
7753
8167
  });
7754
8168
  PageQuerySchema.extend({
@@ -8484,7 +8898,7 @@ function archivedByTime(task, archiveAfterDays, now = Date.now()) {
8484
8898
  }
8485
8899
  // src/version.ts
8486
8900
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
8487
- const VERSION = "1.15.0";
8901
+ const VERSION = "1.17.0";
8488
8902
  /** Sent as X-Monoban-Client, and shown in Settings › CLI sessions. */
8489
8903
  const CLIENT = `cli/${VERSION}`;
8490
8904
  // src/api.ts
@@ -8623,7 +9037,7 @@ var KeychainStore = class {
8623
9037
  this.entry.setPassword(JSON.stringify(credentials));
8624
9038
  } catch (err) {
8625
9039
  if (!this.warned) {
8626
- this.warn(`Couldn't use the system keychain (${reason$2(err)}), so the sign-in is saved in ${this.file.path}.`);
9040
+ this.warn(`Couldn't use the system keychain (${reason$1(err)}), so the sign-in is saved in ${this.file.path}.`);
8627
9041
  this.warned = true;
8628
9042
  }
8629
9043
  await this.file.save(credentials);
@@ -8638,7 +9052,7 @@ var KeychainStore = class {
8638
9052
  await this.file.clear();
8639
9053
  }
8640
9054
  };
8641
- const reason$2 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0];
9055
+ const reason$1 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0];
8642
9056
  /**
8643
9057
  * The store for one API (`account` is its origin, so a local API's sign-in never mixes with
8644
9058
  * api.monoban.dev's). The keychain module is optional: without it (or with MONOBAN_NO_KEYCHAIN=1)
@@ -12031,8 +12445,8 @@ const RELEASES = `https://github.com/thiagodmont/homebrew-tap/releases`;
12031
12445
  * agentpipe comes with a new monoban: change these three lines (from the release's checksums.txt) and release.
12032
12446
  */
12033
12447
  const AGENTPIPE = {
12034
- version: "0.13.0",
12035
- wheelSha256: "4f4be6459f8beeb13270c746497438177e6040656aaf008c80767d0d74fde19b",
12448
+ version: "0.16.0",
12449
+ wheelSha256: "ceb968faac32beb5bdd6b439300aebad46d269193fb18796e9a9de5996f44e43",
12036
12450
  requirementsSha256: "41a8d073b0087efb80efafeb6a2b4750340d0f64920159cd4c723ed9167d0a98"
12037
12451
  };
12038
12452
  /**
@@ -12154,7 +12568,7 @@ async function latestVersion(ctx) {
12154
12568
  async function upgrade(ctx, options, kind = thisInstall()) {
12155
12569
  const latest = await latestVersion(ctx);
12156
12570
  const { how, command } = UPGRADE[kind];
12157
- const outdated = latest !== null && newer(latest, "1.15.0");
12571
+ const outdated = latest !== null && newer(latest, "1.17.0");
12158
12572
  if (options.json) {
12159
12573
  ctx.out(JSON.stringify({
12160
12574
  version: VERSION,
@@ -16912,11 +17326,14 @@ var en_US_default = {
16912
17326
  "board": "board",
16913
17327
  "notes": "notes.md",
16914
17328
  "loops": "loops",
17329
+ "loopsNeedsYou": "loops · {count, plural, one {# needs you} other {# need you}}",
16915
17330
  "archive": "archive"
16916
17331
  },
16917
17332
  status: {
16918
17333
  "notes": "notes.md",
16919
17334
  "loops": "loops · {count}",
17335
+ "needsYou": "{count, plural, one {# thing needs you in its loops} other {# things need you in its loops}}",
17336
+ "needsYouTitle": "Open the loops tab",
16920
17337
  "archiveTask": "{ref} · archive",
16921
17338
  "archive": "archive · {count}",
16922
17339
  "task": "{ref} · {column}",
@@ -16924,7 +17341,9 @@ var en_US_default = {
16924
17341
  "noColumns": "no columns"
16925
17342
  },
16926
17343
  card: {
16927
- "label": "{ref}: {title}{link, select, none {} other { ({link})}}{day, select, none {} other {, {day}}}{state, select, wontDo {, won't do} archived {, archived} other {}}{provisional, select, yes {, not synced} other {}}{marked, select, yes {, marked} other {}}",
17344
+ "label": "{ref}: {title}{link, select, none {} other { ({link})}}{needs, select, none {} other {, {needs}}}{day, select, none {} other {, {day}}}{state, select, wontDo {, won't do} archived {, archived} other {}}{provisional, select, yes {, not synced} other {}}{marked, select, yes {, marked} other {}}",
17345
+ "needs": "needs you: {kind, select, decision {a decision to accept} review {its pull request} closed {its closed pull request} failed {its run failed} other {its loop}}",
17346
+ "needsTitle": "Go to it in its loop",
16928
17347
  "provisional": "not synced: the number may change when it's saved",
16929
17348
  "wontDo": "won't do",
16930
17349
  "archived": "archived",
@@ -17234,6 +17653,11 @@ var en_US_default = {
17234
17653
  "help": "Answer the question task's run asks",
17235
17654
  "keywords": "answer question run agent loop decide reply"
17236
17655
  },
17656
+ "needsYou": {
17657
+ "label": "Go to what {ref} needs in its loop",
17658
+ "help": "Go to what the task needs in its loop",
17659
+ "keywords": "loop needs you decision review pull request closed failed run row"
17660
+ },
17237
17661
  "undo": { "label": "Undo" }
17238
17662
  },
17239
17663
  move: {
@@ -17471,6 +17895,16 @@ var en_US_default = {
17471
17895
  "label": "See {ref}'s run",
17472
17896
  "help": "See the run that failed",
17473
17897
  "keywords": "run failed why see show"
17898
+ },
17899
+ "runAgain": {
17900
+ "label": "Run {ref} again from the start",
17901
+ "help": "Run a loop's task again from the start",
17902
+ "keywords": "retry rerun again restart start over"
17903
+ },
17904
+ "startOver": {
17905
+ "label": "Start {ref} over",
17906
+ "help": "Close a loop task's pull request and run the task again from the start",
17907
+ "keywords": "start over restart redo discard close pull request again"
17474
17908
  }
17475
17909
  },
17476
17910
  archive: {
@@ -17532,6 +17966,7 @@ var en_US_default = {
17532
17966
  loading: "loading loops…",
17533
17967
  loadFailed: "Couldn't load the loops.",
17534
17968
  tryAgain: "Try again",
17969
+ announce: "{name}: {state}",
17535
17970
  heading: {
17536
17971
  "name": "loop",
17537
17972
  "type": "type",
@@ -17562,7 +17997,10 @@ var en_US_default = {
17562
17997
  "continueHint": "A run starts from the step you choose at the runner's next check-in.",
17563
17998
  "oneOff": "The loop stays paused: only this run starts.",
17564
17999
  "neverMerges": "{runner} never merges: its runner.json says `loops.merge` is false, so a run there stops before the merge. Turn it on there. On the runner's machine: `monoban runner restart`.",
17565
- "stopped": "{at, select, implement {It stopped while writing the change.} review {It stopped while reviewing the change.} checks {It stopped while getting CI green.} feedback {It stopped while answering the review comments.} merge {Its merge didn't go through.} beforeMerge {It did every step before merge.} other {}}"
18000
+ "stopped": "{at, select, implement {It stopped while writing the change.} review {It stopped while reviewing the change.} checks {It stopped while getting CI green.} feedback {It stopped while answering the review comments.} merge {Its merge didn't go through.} beforeMerge {It did every step before merge.} other {}}",
18001
+ "sites": "May read pages on {list}",
18002
+ "advisor": "The advisor decides every question nobody answered",
18003
+ "acceptAtMerge": "Decisions it made on its own merge without you reading them"
17566
18004
  },
17567
18005
  runs: {
17568
18006
  "heading": "Runs",
@@ -17581,6 +18019,7 @@ var en_US_default = {
17581
18019
  "newTitle": "New loop in {project}",
17582
18020
  "editTitle": "Edit {name}",
17583
18021
  "description": "A loop runs an agent on your runner, through agentpipe, again and again. It starts at its runner's next check-in.",
18022
+ "appliesLater": "{going, select, yes {Applies to its later runs. Cancel the run that's going on to stop it.} other {Applies to its later runs.}}",
17584
18023
  "name": "Name",
17585
18024
  "namePlaceholder": "Ship the To do column",
17586
18025
  "type": "Type",
@@ -17599,15 +18038,20 @@ var en_US_default = {
17599
18038
  "anyTag": "any tag: every task in the column",
17600
18039
  "merge": "Merge each pull request when its checks pass",
17601
18040
  "mergeHint": "Off: each pull request waits for you to merge.",
18041
+ "acceptAtMerge": "Merge without confirming decisions",
18042
+ "acceptAtMergeHint": "Off: the merge waits until you accept each decision a run made on its own. On: they merge unread, listed on the run and the pull request. One that's hard to undo, or whose source wasn't verified, still waits for you.",
18043
+ "acceptAtMergeOff": "Needs merging on.",
17602
18044
  "deliverMaxOpen": "Pull requests that may wait for you",
17603
18045
  "checksMinutes": "Wait for checks (minutes)",
17604
18046
  "reviewTier": "Review on",
17605
18047
  "reviewTierHint": "The models agentpipe reviews the pull request with: its tier (--tier).",
17606
18048
  "reviewTierDefault": "agentpipe's own tier",
17607
18049
  "askMinutes": "Wait for your answers",
17608
- "askMinutesHint": "A question only you can settle waits this long for your answer before the run decides it on its own. While it waits, the run keeps its worktree and its runner.",
17609
- "askNever": "Don't wait: it decides on its own",
18050
+ "askMinutesHint": "A question only you can settle waits this long for your answer first.",
18051
+ "askNever": "Don't wait",
17610
18052
  "askFor": "{minutes} minutes",
18053
+ "advisor": "Let the advisor decide what nobody answered",
18054
+ "advisorHint": "Off, a question no source can answer stops the run for you; on, agentpipe's strongest model decides every open question, on its best judgement when it finds no source, and writes why.",
17611
18055
  "focus": "What to look for",
17612
18056
  "focusPlaceholder": "Tests that fail now and then, and why",
17613
18057
  "filesIn": "Files tasks in",
@@ -17633,9 +18077,15 @@ var en_US_default = {
17633
18077
  "scavenge": "It looks for: {focus}. It files what it finds in {column}, tagged #{tag}, and stops filing while {maxOpen, plural, one {# of those tasks is} other {# of those tasks are}} open."
17634
18078
  },
17635
18079
  "delivering": "{merge, select, yes {It merges each pull request when its checks pass} other {It leaves each pull request for you to merge}}, and stops taking tasks while {maxOpen, plural, one {# pull request waits} other {# pull requests wait}} for you.",
17636
- "decisions": "{merge, select, yes {{askMinutes, plural, =0 {It decides a question only you can settle on its own, and holds the merge until you accept that decision on the loop's page.} other {It waits up to # minutes for your answer to a question only you can settle, then decides it on its own and holds the merge until you accept that decision on the loop's page.}}} other {{askMinutes, plural, =0 {It decides a question only you can settle on its own.} other {It waits up to # minutes for your answer to a question only you can settle, then decides it on its own.}}}}",
18080
+ "decisions": {
18081
+ "wait": "{askMinutes, plural, =0 {It doesn't wait for your answer to a question only you can settle.} other {It waits up to # minutes for your answer to a question only you can settle.}}",
18082
+ "advisor": "{advisor, select, yes {The advisor decides every question nobody answered.} other {A question nobody answered that no source settles stops the run for you.}}",
18083
+ "merge": "{accept, select, yes {Decisions it made on its own merge without you reading them.} other {Its merge waits until you accept each decision it made on its own, on the loop's page.}}"
18084
+ },
17637
18085
  "limits": "It makes up to {perDay, plural, one {# run} other {# runs}} a day, spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails} other {# runs in a row that fail}}.",
17638
- "incomplete": "Fill in the fields above to see what the loop will do."
18086
+ "incomplete": "Fill in the fields above to see what the loop will do.",
18087
+ "sites": "{sites, plural, =0 {} other {To check an answer that cites a web page, it may read pages on {list}.}}",
18088
+ "more": "{count, plural, one {# more} other {# more}}"
17639
18089
  },
17640
18090
  "create": "Create loop",
17641
18091
  "creating": "Creating…",
@@ -17656,9 +18106,16 @@ var en_US_default = {
17656
18106
  "tag": "Pick the tag it puts on what it files.",
17657
18107
  "columnGone": "Its column was deleted: pick another.",
17658
18108
  "tagGone": "Its tag was deleted: pick another.",
17659
- "nul": "Can't contain NUL characters."
18109
+ "nul": "Can't contain NUL characters.",
18110
+ "siteName": "{entry} isn't a site's name. Write only the name, like docs.python.org.",
18111
+ "sitesNone": "List at least one site.",
18112
+ "sitesMany": "At most {max} sites.",
18113
+ "sitesLong": "At most {max, number} characters in all."
17660
18114
  },
17661
- "pauseAfterHint": "That fail, counted since you last resumed it."
18115
+ "pauseAfterHint": "That fail, counted since you last resumed it.",
18116
+ "network": "Let it check answers against web pages",
18117
+ "sites": "Sites it may read",
18118
+ "sitesHint": "One per line, like docs.python.org. {named, select, yes {{runner}} other {The runner's machine}} must permit each one too, or the run won't start. <how>How to permit a site</how>"
17662
18119
  },
17663
18120
  "delete": {
17664
18121
  "title": "Delete {name}?",
@@ -17668,6 +18125,14 @@ var en_US_default = {
17668
18125
  "cancel": "Cancel",
17669
18126
  "couldnt": "Couldn't delete the loop."
17670
18127
  },
18128
+ startOver: {
18129
+ "title": "Start {ref} over?",
18130
+ "about": "This closes pull request{number, select, none {} other { #{number}}} with a comment saying why and deletes its branch, so the work on it is discarded. A new run then does {ref} from the start, for up to {budget}.",
18131
+ "confirm": "Close it and start over",
18132
+ "starting": "Starting over…",
18133
+ "cancel": "Cancel",
18134
+ "couldnt": "Couldn't start it over."
18135
+ },
17671
18136
  controls: {
17672
18137
  "new": "New loop",
17673
18138
  "runNow": "Run now",
@@ -17686,13 +18151,19 @@ var en_US_default = {
17686
18151
  "deleted": "Deleted {name}.",
17687
18152
  "failed": "That didn't work: try again.",
17688
18153
  "continued": "{step, select, checks {A run fixes {ref}'s CI at its runner's next check-in.} feedback {A run answers {ref}'s review comments at its runner's next check-in.} merge {A run merges {ref}'s pull request at its runner's next check-in.} other {A run continues {ref}'s pull request at its runner's next check-in.}}",
17689
- "accepted": "{ref} merges at its runner's next check-in, with {count, plural, one {the decision} other {the # decisions}} accepted."
18154
+ "accepted": "{ref} merges at its runner's next check-in, with {count, plural, one {the decision} other {the # decisions}} accepted.",
18155
+ "runAgain": "A run starts {ref} again from the first step at its runner's next check-in.",
18156
+ "startOver": "A run closes {number, select, none {its pull request} other {#{number}}} and starts {ref} over at its runner's next check-in."
17690
18157
  },
17691
18158
  decisions: {
17692
- "why": "The agent decided without asking anyone. Read them against the <pr>pull request</pr> at {commit}: accepting them lets it merge that commit, not one pushed after.",
18159
+ "why": "Nobody answered these questions, so the agent decided them. Read them against the <pr>pull request</pr> at {commit}: accepting them lets it merge that commit, not one pushed after.",
17693
18160
  "answer": "Its answer:",
17694
18161
  "accept": "{count, plural, one {Accept it and merge} other {Accept all # and merge}}",
18162
+ "acceptSome": "Accept {shown} of {total} and merge",
18163
+ "some": "One acceptance takes at most {shown}: this one accepts {shown} of {total}, and the merge then waits on the other {rest, plural, =0 {none} one {one} other {#}}, which you accept the same way.",
17695
18164
  "hint": "A run continues from merge at the runner's next check-in: it accepts them with agentpipe ratify, then merges. If the branch moved since, it waits for you again.",
18165
+ "tick": "Accept this one",
18166
+ "ticks": "{count, plural, =0 {Nothing to tick.} one {Tick the decision that's hard to undo or unverified, under Details, to accept it.} other {Tick each of the # decisions that are hard to undo or unverified, under Details, to accept them.}}",
17696
18167
  "accepting": "It accepts {count, plural, one {# decision} other {# decisions}} read at {commit}, then merges."
17697
18168
  },
17698
18169
  continueStep: {
@@ -17728,10 +18199,14 @@ var en_US_default = {
17728
18199
  "decision": "{ref}'s merge waits on {count, plural, one {a decision} other {# decisions}} only you can accept.",
17729
18200
  "review": "{ref}'s pull request waits for you: {reason}",
17730
18201
  "reviewBare": "{ref}'s pull request waits for you.",
17731
- "failed": "{ref}'s run failed: {reason} The loop won't take it again on its own.",
17732
- "failedBare": "{ref}'s run failed. The loop won't take it again on its own.",
18202
+ "closed": "{ref}'s <pr>pull request{number, select, none {} other { #{number}}}</pr> was closed without merging. Run {ref} again from the start, move it, or archive it.",
18203
+ "retagged": "It has the loop's tag again: the loop takes it once {number, select, none {its pull request} other {#{number}}} is closed.",
17733
18204
  "openPr": "Open the pull request",
17734
18205
  "seeRun": "See the run",
18206
+ "runAgain": "Run again from the start",
18207
+ "runAgainDoes": "Runs {ref} again from the first step, as a new run. It may spend up to {budget}, which counts toward the loop's budget for the day.",
18208
+ "runAgainTag": "It takes #{tag} off the task, as when the loop takes it.",
18209
+ "startOver": "Start over",
17735
18210
  "said": "What the run said: {reason}",
17736
18211
  "otherSteps": "Or continue it from another step:",
17737
18212
  "row": "{state} · {count, plural, one {# needs you} other {# need you}}: {first}",
@@ -17741,9 +18216,11 @@ var en_US_default = {
17741
18216
  "runnerOutdated": "its runner can't run it",
17742
18217
  "decision": "a decision on {ref}",
17743
18218
  "review": "{ref}'s pull request",
18219
+ "closed": "{ref}'s closed pull request",
17744
18220
  "failed": "{ref} failed"
17745
18221
  }
17746
- }
18222
+ },
18223
+ olderRunner: "{runner} runs an older monoban, which ignores these: update it there to 1.16.0 or newer (<code>monoban upgrade</code>), then <code>monoban runner restart</code>."
17747
18224
  },
17748
18225
  notes: {
17749
18226
  find: {
@@ -17932,7 +18409,8 @@ var en_US_default = {
17932
18409
  "changingLanguage": "Changing the language",
17933
18410
  "loadingLoops": "Loading the loops",
17934
18411
  "savingLoop": "Saving the loop",
17935
- "deletingLoop": "Deleting the loop"
18412
+ "deletingLoop": "Deleting the loop",
18413
+ "changingLoopEmails": "Changing which emails you get"
17936
18414
  },
17937
18415
  keptNotRemoved: "Could not remove what's kept. Try again.",
17938
18416
  saveState: {
@@ -17981,12 +18459,14 @@ var en_US_default = {
17981
18459
  too_many_loops: "This project has as many loops as it may have.",
17982
18460
  no_runner: "This loop has no runner: choose one for it first.",
17983
18461
  open_tasks_limit: "This loop has as many open tasks as it may: it files more once you close some.",
18462
+ runner_outdated: "This loop's runner can't start a task over: update monoban on its machine, then restart the runner.",
18463
+ daily_limit: "This loop has started as many runs as it may in 24 hours: start this one from the browser, or wait.",
17984
18464
  used_by_loop: "A loop uses it: change or delete the loop first.",
17985
18465
  place_gone: "This loop's column or tag was deleted: edit the loop to choose another.",
17986
18466
  unreachable: "Couldn't reach monoban. Try again.",
17987
18467
  unreachableShort: "Couldn't reach monoban.",
17988
18468
  cantDeleteAccount: "Couldn't delete your account. Try again.",
17989
- too_late: "Too late: the run no longer waits for that answer. It decided on its own; accept or change what it decided."
18469
+ too_late: "Too late: the run no longer waits for that answer. It went on without it: accept or change what it decided."
17990
18470
  },
17991
18471
  projects: {
17992
18472
  empty: {
@@ -18117,6 +18597,7 @@ var en_US_default = {
18117
18597
  howRunsWork: "How runs work ↗",
18118
18598
  loading: "loading…",
18119
18599
  tryAgain: "Try again",
18600
+ stale: "This may be out of date: monoban didn't answer.",
18120
18601
  agentDefault: "{agent}'s default",
18121
18602
  dialog: {
18122
18603
  "title": "Run {label} with an agent",
@@ -18223,37 +18704,64 @@ var en_US_default = {
18223
18704
  "label": "Questions waiting for you",
18224
18705
  "answered": "Your answers",
18225
18706
  "heading": "your answers",
18226
- "closes": "It waits for you until {time}, then decides on its own.",
18707
+ "closes": "It waits for you until {time}, then goes on without your answer.",
18227
18708
  "unknown": "Question {id} (its text isn't among the latest events)",
18228
18709
  "field": "Your answer to {id}",
18229
18710
  "placeholder": "Your answer: it reaches the agent as you write it",
18230
18711
  "send": "Send",
18231
18712
  "sending": "Sending…",
18232
18713
  "skip": "You decide",
18233
- "skipHint": "“You decide” tells it to decide this one on its own, as if no answer came.",
18714
+ "skipHint": "“You decide” tells it to go on without your answer to this one, as if none came.",
18234
18715
  "yours": "You answered: {text}",
18235
18716
  "yoursSkip": "You left it to the run.",
18236
18717
  "sent": "Sent: its runner hands it on at its next check-in.",
18237
18718
  "reached": "It reached the run.",
18238
- "tooLate": "Too late: the run had stopped waiting, so it decided on its own. If a decision only you can make holds its merge, accept it on the run.",
18719
+ "tooLate": "Too late: the run had stopped waiting, so it went on without your answer. If a decision only you can make holds its merge, accept it on the run.",
18239
18720
  "refused": "agentpipe didn't take it: {said}",
18240
18721
  "unsent": "The run ended before its runner handed this on.",
18241
- "tooLateNow": "Too late: the run no longer waits for this answer, so it decides on its own. If a decision only you can make holds its merge, accept it on the run.",
18722
+ "tooLateNow": "Too late: the run no longer waits for this answer, so it goes on without it. If a decision only you can make holds its merge, accept it on the run.",
18242
18723
  "answeredAlready": "It was answered already.",
18243
18724
  "failed": "Couldn't send it."
18244
18725
  },
18245
18726
  "accepted": {
18246
- "label": "{count, plural, one {# decision} other {# decisions}} the repository's setting accepted",
18247
- "why": "The agent decided on its own, and the merge went ahead without anyone reading what it decided: agentpipe's setting for this repository (<code>ship.accept_provisional</code>, on the runner's machine, not in monoban or in the repository) accepts decisions of these kinds. Read them against the <pr>pull request</pr>.",
18727
+ "label": "{count, plural, =0 {No decisions merged without your confirmation} one {# decision merged without your confirmation} other {# decisions merged without your confirmation}}",
18728
+ "why": "The agent decided on its own, and the merge went ahead without anyone reading what it decided. Read them against the <pr>pull request</pr>.",
18729
+ "bySetting": "accepted by the repository's setting",
18730
+ "byLoop": "accepted by this loop",
18731
+ "setting": "The repository's setting is agentpipe's <code>ship.accept_provisional</code>, on the runner's machine (not in monoban or in the repository): it accepts decisions of the kinds it lists.",
18732
+ "loop": "This loop accepts decisions at merge: its runs said so on the pull request before it merged.",
18248
18733
  "answer": "Its answer:",
18249
- "authority": "only you could decide this, and nobody read it"
18734
+ "authority": "only you could decide this, and nobody read it",
18735
+ "disagree": "Disagree with one? Revert the pull request, then reopen the task with your answer."
18736
+ },
18737
+ "decision": {
18738
+ "how": "{how, select, source {from a source} judgement {best judgement} unverified {best judgement, its source wasn't verified} other {}}",
18739
+ "why": "Why: {reason}",
18740
+ "waits": "{why, select, unverified {Its source wasn't verified} hard {Hard to undo} not_announced {Made before this loop accepted decisions} other {It waits for you}}",
18741
+ "replaced": "Replaced by a later run's decision, {id}"
18250
18742
  },
18251
18743
  "setAside": {
18252
18744
  "label": "{count, plural, one {# review comment was set aside} other {# review comments were set aside}}",
18253
18745
  "by": "<who>{author}</who> {reason, select, unauthorized {isn't a collaborator on the repository} no_write_access {can't push to the repository} other {({code})}}",
18254
18746
  "open": "open it on GitHub",
18255
18747
  "fix": "agentpipe answers only people who can push to the repository. To have it answer a review bot, add the bot's login to <code>address.trusted_bots</code> in <code>~/.agentpipe/config.toml</code> on the runner's machine, then continue from feedback."
18256
- }
18748
+ },
18749
+ "webPages": "web pages"
18750
+ },
18751
+ failure: {
18752
+ "inStep": "It failed in {step}.",
18753
+ "bare": "It failed.",
18754
+ "task": {
18755
+ "reason": "{ref}'s run failed: {reason}",
18756
+ "inStep": "{ref}'s run failed in {step}.",
18757
+ "bare": "{ref}'s run failed."
18758
+ },
18759
+ "fate": {
18760
+ "queued": "{ref} is in the loop's queue: it takes it again at a later run.",
18761
+ "tagOff": "The loop won't take {ref} again on its own: #{tag} came off when this run took it. Run it again from the start, or put the tag back.",
18762
+ "once": "The loop won't take {ref} again on its own: it tries each task once. Run it again from the start."
18763
+ },
18764
+ "said": "What {agent} said"
18257
18765
  },
18258
18766
  runners: {
18259
18767
  "title": "Runners",
@@ -18283,29 +18791,6 @@ var en_US_default = {
18283
18791
  "many": "runners {online}/{total} running",
18284
18792
  "label": "Runner: {text}. How to start it",
18285
18793
  "notRunning": "Not running: start it with monoban runner"
18286
- },
18287
- reason: {
18288
- "loop_unsupported": "This runner can't run this kind of loop: update monoban there, or give the loop another runner.",
18289
- "agent_missing": "This runner doesn't have the agent the run asked for: install it there, or run it on another runner.",
18290
- "folder_refused": "The run can't work in that folder: give it a checkout of the project's repository, in a folder the runner allows.",
18291
- "day_spent": "This machine has spent its day's budget for loops: the task waits for a later run (or raise loops.maxUsdPerDay in its runner.json).",
18292
- "agentpipe_outdated": "The agentpipe on this runner is too old for what this run needs: update it there (monoban agentpipe update).",
18293
- "sandbox_off": "agentpipe's sandbox is off on this runner, and a loop runs only with it on: turn it on in agentpipe's config there.",
18294
- "tier_missing": "The agentpipe on this runner doesn't have the review tier the loop names: add it there, or change the loop.",
18295
- "agentpipe_refused": "agentpipe on this runner refused to start the run: fix what it says.",
18296
- "agent_signed_out": "The agent on this runner isn't signed in: sign in there.",
18297
- "cannot_push": "GitHub won't let this runner push to the repository: check its gh sign-in there (gh auth status).",
18298
- "commands_unverified": "None of the repository's test, lint or type-check commands ran cleanly, so agentpipe can't check a change: fix one.",
18299
- "budget_spent": "The run spent its budget before it finished: raise the loop's budget for the next one.",
18300
- "decisions_unratified": "Its merge waits for you to accept decisions the agent made on its own.",
18301
- "checks_pending": "Its checks were still running, so it wasn't merged: continue it from checks once they pass.",
18302
- "checks_failed": "A check failed, so it wasn't merged.",
18303
- "no_checks": "The pull request has no checks, so it wasn't merged on its own: add a CI check, then continue it from merge.",
18304
- "review_objection": "agentpipe's review asked for changes, so it wasn't merged: read the review before you continue it.",
18305
- "review_required": "GitHub waits for a required review (or another rule) before it merges.",
18306
- "not_this_run": "The pull request isn't one this run opened, so it wasn't merged.",
18307
- "merge_rejected": "GitHub refused the merge: continue it from merge to try again.",
18308
- "not_merged": "agentpipe didn't merge it: continue it from merge once that's settled."
18309
18794
  }
18310
18795
  },
18311
18796
  schedule: {
@@ -18379,6 +18864,14 @@ var en_US_default = {
18379
18864
  "use": "Use this",
18380
18865
  "note": "What you type (tasks, columns, notes) is never translated. The CLI speaks English for now.",
18381
18866
  "failed": "Couldn't change the language. Try again."
18867
+ },
18868
+ loopEmails: {
18869
+ "title": "Emails about loops",
18870
+ "about": "monoban emails {email} about your loops, so you don't have to watch them.",
18871
+ "stopped": "When a loop pauses itself or a run needs you",
18872
+ "finished": "When a run finishes",
18873
+ "finishedHint": "One email for each run that ends well: what it delivered or filed, how long it took and what it cost.",
18874
+ "failed": "Couldn't save that. Try again."
18382
18875
  }
18383
18876
  },
18384
18877
  shared: {
@@ -18411,7 +18904,36 @@ var en_US_default = {
18411
18904
  },
18412
18905
  "tokens": "{n} tokens",
18413
18906
  "thousandTokens": "{n}k tokens",
18414
- "millionTokens": "{n}M tokens"
18907
+ "millionTokens": "{n}M tokens",
18908
+ "reason": {
18909
+ "loop_unsupported": "This runner can't run this kind of loop: update monoban there, or give the loop another runner.",
18910
+ "agent_missing": "This runner doesn't have the agent the run asked for: install it there, or run it on another runner.",
18911
+ "folder_refused": "The run can't work in that folder: give it a checkout of the project's repository, in a folder the runner allows.",
18912
+ "day_spent": "This machine has spent its day's budget for loops: the task waits for a later run (or raise loops.maxUsdPerDay in its runner.json).",
18913
+ "agentpipe_outdated": "The agentpipe on this runner is too old for what this run needs: update it there (monoban agentpipe update).",
18914
+ "sandbox_off": "agentpipe's sandbox is off on this runner, and a loop runs only with it on: turn it on in agentpipe's config there.",
18915
+ "tier_missing": "The agentpipe on this runner doesn't have the review tier the loop names: add it there, or change the loop.",
18916
+ "agentpipe_refused": "agentpipe on this runner refused to start the run: fix what it says.",
18917
+ "agent_signed_out": "The agent on this runner isn't signed in: sign in there.",
18918
+ "cannot_push": "GitHub won't let this runner push to the repository: check its gh sign-in there (gh auth status).",
18919
+ "commands_unverified": "None of the repository's test, lint or type-check commands ran cleanly, so agentpipe can't check a change: fix one.",
18920
+ "site_not_permitted": "This runner's machine doesn't permit a site the loop lists: add it to permitted_sites under [callers] in ~/.agentpipe/config.toml there, or take it off the loop.",
18921
+ "sites_step_ineligible": "agentpipe's resolve or arbitrate step on this runner isn't set up to read the loop's sites: change that step in agentpipe's config there, as the reason says.",
18922
+ "sites_nothing_fetched": "agentpipe on this runner would fetch no page from the loop's sites (its research is off, or allows no fetch): change that in agentpipe's config there, as the reason says.",
18923
+ "sites_invalid": "agentpipe on this runner refused the loop's sites as monoban sent them: update monoban and agentpipe there.",
18924
+ "advisor_switch_off": "This runner's machine doesn't let the advisor decide: set allow_best_judgement = true under [resolve] in ~/.agentpipe/config.toml there, or turn the advisor off on the loop.",
18925
+ "accept_switch_off": "This runner's machine doesn't let a merge accept decisions without you: set allow_accept_decisions = true under [ship] in ~/.agentpipe/config.toml there, or stop accepting decisions at merge on the loop.",
18926
+ "budget_spent": "The run spent its budget before it finished: raise the loop's budget for the next one.",
18927
+ "decisions_unratified": "Its merge waits for you to accept decisions the agent made on its own.",
18928
+ "checks_pending": "Its checks were still running, so it wasn't merged: continue it from checks once they pass.",
18929
+ "checks_failed": "A check failed, so it wasn't merged.",
18930
+ "no_checks": "The pull request has no checks, so it wasn't merged on its own: add a CI check, then continue it from merge.",
18931
+ "review_objection": "agentpipe's review asked for changes, so it wasn't merged: read the review before you continue it.",
18932
+ "review_required": "GitHub waits for a required review (or another rule) before it merges.",
18933
+ "not_this_run": "The pull request isn't one this run opened, so it wasn't merged.",
18934
+ "merge_rejected": "GitHub refused the merge: continue it from merge to try again.",
18935
+ "not_merged": "agentpipe didn't merge it: continue it from merge once that's settled."
18936
+ }
18415
18937
  },
18416
18938
  loop: {
18417
18939
  "state": {
@@ -18437,7 +18959,7 @@ var en_US_default = {
18437
18959
  },
18438
18960
  "waitingForYou": {
18439
18961
  "pullRequests": "{count, plural, one {a pull request waits for you} other {# pull requests wait for you}}",
18440
- "tasks": "{count, plural, one {a task it filed waits for you} other {# tasks it filed wait for you}}"
18962
+ "tasks": "{count, plural, one {a task it filed is open: finish or archive it, or raise its limit} other {# tasks it filed are open: finish or archive some, or raise its limit}}"
18441
18963
  },
18442
18964
  "dailyLimit": "{count, plural, one {# run} other {# runs}} in 24 hours: its daily limit, until {time}",
18443
18965
  "budget": "{spent} of {limit} spent in 24 hours: its daily budget",
@@ -18886,6 +19408,8 @@ var en_US_default = {
18886
19408
  planAllToday: "plan all for today",
18887
19409
  nothingPlanned: "Nothing planned.",
18888
19410
  group: "{late, select, yes {{project}, late} other {{project}, {day}}}",
19411
+ needsYou: "{project}: {count, plural, one {# thing needs you in its loops} other {# things need you in its loops}}",
19412
+ needsYouLabel: "What needs you in your loops",
18889
19413
  empty: "{when, select, today {Nothing planned for today.} tomorrow {Nothing planned for tomorrow.} yesterday {Nothing planned for yesterday.} week {Nothing planned for these 7 days.} other {Nothing planned for {day}.}}",
18890
19414
  emptyHint: "On a board, press <kbd>d</kbd> on a task to plan it for a day. In a terminal: <code>monoban schedule MON-12 today</code>",
18891
19415
  showADay: "Show a day",
@@ -19352,6 +19876,14 @@ function describeLoopState({ state, nextAt, why }, words, now = Date.now()) {
19352
19876
  case "next": return t("loop.state.next", { time: clock(nextAt ? Date.parse(nextAt) : now, now, locale) });
19353
19877
  }
19354
19878
  }
19879
+ /**
19880
+ * A loop's state in a few words, as its row, its page and `monoban loops` say it: "waiting for your answer" (a run's
19881
+ * words, `run.status.waiting`) while its run waits for your answer (contract's `loopWaits`, MON-295), else its state's
19882
+ * (`describeLoopState`).
19883
+ */
19884
+ function describeLoop(loop, words, now = Date.now()) {
19885
+ return loopWaits(loop, now) ? words.t("run.status.waiting") : describeLoopState(loop.state, words, now);
19886
+ }
19355
19887
  /** The causes that keep a runner from running a loop at all (`runnerOutdated`), each with its own words. */
19356
19888
  const OUTDATED = [
19357
19889
  "monoban_outdated",
@@ -19541,9 +20073,12 @@ async function loopsOf(api, key) {
19541
20073
  }
19542
20074
  /** Where a project's loops are made, changed and resumed (a single loop has no page of its own). */
19543
20075
  const loopsTab = (ctx, key) => `${ctx.webUrl}/p/${key}?view=loops`;
19544
- /** What it's doing, in a few words: its state, and while a run goes, the step and task. */
20076
+ /**
20077
+ * What it's doing, in a few words: its state ("waiting for your answer" while its run waits for you, MON-295), and
20078
+ * while a run goes, the step and task.
20079
+ */
19545
20080
  function loopDoing(loop, now = Date.now()) {
19546
- const state = describeLoopState(loop.state, ENGLISH, now);
20081
+ const state = describeLoop(loop, ENGLISH, now);
19547
20082
  const going = loop.going && [loop.going.step, loop.going.ref].filter(Boolean).join(" on ");
19548
20083
  return going ? `${state}: ${going}` : state;
19549
20084
  }
@@ -19885,6 +20420,45 @@ function atLeast(a, b) {
19885
20420
  }
19886
20421
  return true;
19887
20422
  }
20423
+ // src/runner/redact.ts
20424
+ /**
20425
+ * What the runner sends the board from an agent's output, secrets out: a command line, an error, a step's message.
20426
+ * Every message a run reports goes through `clip()` (docs/PLAN-AGENT-LOOPS.md §1.6: agentpipe's too).
20427
+ */
20428
+ /** Secrets a command line or an error might carry, kept out of what the board shows. */
20429
+ const SECRETS = [
20430
+ [/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "…"],
20431
+ [/\bsk-[A-Za-z0-9_-]{16,}/g, "…"],
20432
+ [/\bmbn_[A-Za-z0-9_]{8,}/g, "…"],
20433
+ [/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "…"],
20434
+ [/\bAKIA[0-9A-Z]{16}\b/g, "…"],
20435
+ [/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1…"],
20436
+ [/((?:token|secret|passw(?:or)?d|api[_-]?key|auth)[A-Za-z_]*["']?\s*[=:]\s*["']?)(?!Bearer\b|Basic\b)[^\s"']+/gi, "$1…"]
20437
+ ];
20438
+ function redact(text) {
20439
+ return SECRETS.reduce((t, [pattern, by]) => t.replace(pattern, by), text);
20440
+ }
20441
+ /** A message the API takes (and the board shows), secrets out. */
20442
+ function clip$1(text, max = 2e3) {
20443
+ const clean = redact(text).trim();
20444
+ return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;
20445
+ }
20446
+ /** Words as a sentence: ended with a period unless they end a sentence already. */
20447
+ function sentence(text) {
20448
+ const said = text.trim();
20449
+ return /[.!?…]$/.test(said) ? said : `${said}.`;
20450
+ }
20451
+ /**
20452
+ * A reason that names a command a person must run on the runner's machine (docs/PLAN-AGENT-LOOPS.md §1.6): the
20453
+ * sentence first, complete without the command, then the command as the last sentence, on the same line (a run's
20454
+ * reason is one string, and `monoban runs` prints it in a table). A step the loop's page has a button for (accepting
20455
+ * decisions, continuing from a step) names no command: the reason points at the page. Several commands are run in
20456
+ * their order: "`monoban agentpipe update`, then `monoban runner restart`".
20457
+ */
20458
+ function onRunnersMachine(text, command, ...then) {
20459
+ const commands = [command, ...then].map((c) => `\`${c}\``).join(", then ");
20460
+ return `${sentence(text).replace(/\s+/g, " ")} On the runner's machine: ${commands}.`;
20461
+ }
19888
20462
  // src/runner/agents/agentpipe.ts
19889
20463
  /** agentpipe's step statuses that monoban has too; the others (budget_exceeded, max_turns…) are failures. */
19890
20464
  const SAME = [
@@ -19901,7 +20475,7 @@ const RUN_ENDINGS = {
19901
20475
  nothing_to_do: "succeeded"
19902
20476
  };
19903
20477
  /** How agentpipe's own endings read, before its reason. */
19904
- const SAYS = {
20478
+ const SAYS$1 = {
19905
20479
  refused: "It couldn't start",
19906
20480
  nothing_to_do: "There was nothing to do"
19907
20481
  };
@@ -19931,15 +20505,90 @@ const CI_SAYS = {
19931
20505
  * code, and its reason (agentpipe's words) says it. Never read from the words.
19932
20506
  */
19933
20507
  const MERGE_CHECKS = HELD_MERGE_CODES;
19934
- /** The run's reason code for a refused merge's `check`, or null. */
19935
- const mergeCheckCode = (check) => MERGE_CHECKS.find((code) => code === check) ?? null;
20508
+ /**
20509
+ * The owner's switches (agentpipe 0.15.0, AGE-204): a loop's advisor (`--advisor`) and accepting decisions at merge
20510
+ * (`--accept-decisions`) each work only where the runner's machine allows it, in agentpipe's own config, which only
20511
+ * its owner edits (no command sets it, and monoban never does: no runner.json key either, the owner's decision of
20512
+ * 2026-11-18). agentpipe refuses the flag without it, by these checks: the dry run in its preview, a command on its
20513
+ * `run.end`, `merge` on its `merge.blocked`. Each becomes the run's ending in monoban's words, with its code (MON-268),
20514
+ * naming the key and the file, never a command.
20515
+ */
20516
+ const SWITCHES_OFF = {
20517
+ advisor_not_allowed: {
20518
+ code: "advisor_switch_off",
20519
+ reason: "This machine doesn't let the advisor decide (resolve.allow_best_judgement in agentpipe's config, ~/.agentpipe/config.toml): turn it on there, or untick it on the loop."
20520
+ },
20521
+ accept_decisions_not_allowed: {
20522
+ code: "accept_switch_off",
20523
+ reason: "This machine doesn't let a merge accept decisions (ship.allow_accept_decisions in agentpipe's config, ~/.agentpipe/config.toml): turn it on there, or untick it on the loop."
20524
+ }
20525
+ };
20526
+ /** The owner's switch a refusal's `check` says is off, or null. */
20527
+ const switchOff = (check) => typeof check === "string" ? SWITCHES_OFF[check] ?? null : null;
20528
+ /** The run's reason code for a refused merge's `check` (an owner's switch off included), or null. */
20529
+ const mergeCheckCode = (check) => MERGE_CHECKS.find((code) => code === check) ?? switchOff(check)?.code ?? null;
19936
20530
  const str = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
19937
20531
  const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
19938
20532
  /** A message the API takes: one line or more, at most 2000 characters. */
19939
- const clip$1 = (text) => text.length > 2e3 ? `${text.slice(0, 1999)}…` : text;
20533
+ const clip = (text) => text.length > 2e3 ? `${text.slice(0, 1999)}…` : text;
20534
+ /**
20535
+ * Text cut to at most `chars` UTF-16 units and `bytes` UTF-8 bytes, its start kept (never inside a character): a
20536
+ * decision's event must fit the 8 KB its data may hold (task_run_events.data), whatever language it's in.
20537
+ */
20538
+ function upTo(text, chars, bytes) {
20539
+ let out = "";
20540
+ let size = 0;
20541
+ for (const ch of text) {
20542
+ const n = Buffer.byteLength(ch);
20543
+ if (out.length + ch.length > chars || size + n > bytes) break;
20544
+ out += ch;
20545
+ size += n;
20546
+ }
20547
+ return out;
20548
+ }
20549
+ /**
20550
+ * What a decision's event may hold of each of agentpipe's words, by characters and by bytes: together, at their
20551
+ * largest, with every other field, under the 8 KB of an event's data (a test fills one).
20552
+ */
20553
+ const DECISION_LIMITS = {
20554
+ answer: {
20555
+ chars: 2e3,
20556
+ bytes: 4e3
20557
+ },
20558
+ /** agentpipe clips it to 1,000 characters (merge.blocked v6). */
20559
+ rationale: {
20560
+ chars: 1e3,
20561
+ bytes: 2e3
20562
+ },
20563
+ questionId: {
20564
+ chars: 200,
20565
+ bytes: 200
20566
+ },
20567
+ category: {
20568
+ chars: 100,
20569
+ bytes: 100
20570
+ },
20571
+ /** `method` and `waits_because`: agentpipe's words, a few letters. */
20572
+ word: {
20573
+ chars: 40,
20574
+ bytes: 40
20575
+ }
20576
+ };
20577
+ const limited = (text, limit) => upTo(text, limit.chars, limit.bytes);
20578
+ /** What agentpipe's `accepted_by` says (`setting`, `caller`) as monoban writes it: the loop's option is the caller. */
20579
+ const ACCEPTED_BY = {
20580
+ setting: "setting",
20581
+ caller: "loop"
20582
+ };
19940
20583
  /**
19941
- * `merge.blocked`'s decisions (and `merge.completed`'s `accepted`): each with its id, question id, category and answer;
19942
- * anything else is left out.
20584
+ * `merge.blocked`'s decisions (and `merge.completed`'s `accepted`): each with its id, question id, category and answer,
20585
+ * and the agentpipe run that made it (agentpipe 0.15.0's `run_id`, merge.blocked v7 and merge.completed v6: a merge
20586
+ * waits on every run's decisions on the pull request, AGE-219, and `ratify` takes the decision's own run, MON-302;
20587
+ * null before it, or one monoban wouldn't pass to `ratify`); anything else is left out. And how it was reached
20588
+ * (0.15.0, MON-268): its `method` (`adjudicated`, `judgement`…), whether a judgement's source couldn't be confirmed
20589
+ * (`unverified`), the reason the agent gave (`rationale`), why it still waits with --accept-decisions (`waits_because`:
20590
+ * `unverified`, `hard`, `not_announced`) and who accepted it (`accepted_by`); each null when agentpipe didn't say. The
20591
+ * agent's words (the answer, the reason) with secrets out, each within DECISION_LIMITS.
19943
20592
  */
19944
20593
  function decisionsOf(value) {
19945
20594
  if (!Array.isArray(value)) return [];
@@ -19952,13 +20601,74 @@ function decisionsOf(value) {
19952
20601
  str(o.category),
19953
20602
  str(o.answer)
19954
20603
  ];
19955
- if (!decisionId || !/^[0-9a-f]{12}$/.test(decisionId) || !questionId || !category || !answer) return [];
20604
+ if (!decisionId || !DECISION_ID.test(decisionId) || !questionId || !category || !answer) return [];
20605
+ const run = str(o.run_id);
20606
+ const agentpipeRun = run && AGENTPIPE_RUN.test(run) ? run : null;
20607
+ const [method, rationale, waitsBecause, acceptedBy] = [
20608
+ str(o.method),
20609
+ str(o.rationale),
20610
+ str(o.waits_because),
20611
+ str(o.accepted_by)
20612
+ ];
19956
20613
  return [{
19957
20614
  decisionId,
19958
- questionId,
19959
- category,
19960
- answer,
19961
- question: str(o.question)
20615
+ agentpipeRun,
20616
+ questionId: limited(questionId, DECISION_LIMITS.questionId),
20617
+ category: limited(category, DECISION_LIMITS.category),
20618
+ answer: limited(redact(answer), DECISION_LIMITS.answer),
20619
+ question: str(o.question),
20620
+ method: method ? limited(method, DECISION_LIMITS.word) : null,
20621
+ unverified: typeof o.unverified === "boolean" ? o.unverified : null,
20622
+ rationale: rationale ? limited(redact(rationale), DECISION_LIMITS.rationale) : null,
20623
+ waitsBecause: waitsBecause ? limited(waitsBecause, DECISION_LIMITS.word) : null,
20624
+ accepted: (acceptedBy && ACCEPTED_BY[acceptedBy]) ?? "setting"
20625
+ }];
20626
+ });
20627
+ }
20628
+ /**
20629
+ * A decision's event data (a `question`'s): who made it and how, and what it says, flat (event data holds no lists).
20630
+ * Only what agentpipe said: a field it left out is left out.
20631
+ */
20632
+ function decisionData(d) {
20633
+ return {
20634
+ decisionId: d.decisionId,
20635
+ ...d.agentpipeRun && { agentpipeRun: d.agentpipeRun },
20636
+ questionId: d.questionId,
20637
+ category: d.category,
20638
+ answer: d.answer,
20639
+ ...d.method && { method: d.method },
20640
+ ...d.unverified !== null && { unverified: d.unverified },
20641
+ ...d.rationale && { rationale: d.rationale }
20642
+ };
20643
+ }
20644
+ /**
20645
+ * `merge.blocked`'s and `merge.completed`'s `replaced` (agentpipe 0.15.0, AGE-221): a decision a later run's decision
20646
+ * on the pull request replaced, which no merge waits on any more, and the one that replaced it.
20647
+ */
20648
+ function replacedOf(value) {
20649
+ if (!Array.isArray(value)) return [];
20650
+ return value.flatMap((x) => {
20651
+ if (!x || typeof x !== "object") return [];
20652
+ const o = x;
20653
+ const [decisionId, questionId, category, replacedBy] = [
20654
+ str(o.decision_id),
20655
+ str(o.question_id),
20656
+ str(o.category),
20657
+ str(o.replaced_by)
20658
+ ];
20659
+ if (!decisionId || !DECISION_ID.test(decisionId) || !replacedBy || !DECISION_ID.test(replacedBy)) return [];
20660
+ if (!questionId || !category) return [];
20661
+ const runOf = (v) => {
20662
+ const run = str(v);
20663
+ return run && AGENTPIPE_RUN.test(run) ? run : null;
20664
+ };
20665
+ return [{
20666
+ decisionId,
20667
+ agentpipeRun: runOf(o.run_id),
20668
+ questionId: limited(questionId, DECISION_LIMITS.questionId),
20669
+ category: limited(category, DECISION_LIMITS.category),
20670
+ replacedBy,
20671
+ replacedByRun: runOf(o.replaced_by_run)
19962
20672
  }];
19963
20673
  });
19964
20674
  }
@@ -20025,6 +20735,8 @@ function agentpipeMapper(report) {
20025
20735
  let blocked = null;
20026
20736
  /** The review comments `address` set aside (`feedback.intake`'s `refused`), for the recipe to report. */
20027
20737
  const setAside = [];
20738
+ /** `close.completed`: the pull request it closed to start over. */
20739
+ let closed = null;
20028
20740
  /** A window open for your answers (`run --ask-window`): when it closes, and the questions it still waits on. */
20029
20741
  let asking = null;
20030
20742
  /** The run's "now" while the window is open: the time it closes in `data` (each reader says it in their own words). */
@@ -20040,6 +20752,31 @@ function agentpipeMapper(report) {
20040
20752
  ...at && { at }
20041
20753
  });
20042
20754
  const spent = () => report.update({ costUsd: Math.round((total + shipped) * 1e4) / 1e4 });
20755
+ /** Each decision of a run once (two runs' decisions with one id are two, MON-302). */
20756
+ const unique = (decisions) => {
20757
+ const seen = /* @__PURE__ */ new Set();
20758
+ return decisions.filter((x) => {
20759
+ const key = `${x.agentpipeRun ?? ""}/${x.decisionId}`;
20760
+ return !seen.has(key) && Boolean(seen.add(key));
20761
+ });
20762
+ };
20763
+ /** Each replaced decision, a question that names the decision that replaced it (MON-300 shows it, never offers it). */
20764
+ const reportReplaced = (value, step, at) => {
20765
+ for (const r of replacedOf(value)) report.event({
20766
+ kind: "question",
20767
+ ...step && { step },
20768
+ message: `Decision ${r.decisionId} was replaced by a later run's decision, ${r.replacedBy}.`,
20769
+ data: {
20770
+ decisionId: r.decisionId,
20771
+ ...r.agentpipeRun && { agentpipeRun: r.agentpipeRun },
20772
+ questionId: r.questionId,
20773
+ category: r.category,
20774
+ replacedBy: r.replacedBy,
20775
+ ...r.replacedByRun && { replacedByRun: r.replacedByRun }
20776
+ },
20777
+ ...at && { at }
20778
+ });
20779
+ };
20043
20780
  const flush = (cost) => {
20044
20781
  if (!pending) return;
20045
20782
  const { step, attempt, status, message, at } = pending;
@@ -20052,7 +20789,7 @@ function agentpipeMapper(report) {
20052
20789
  step,
20053
20790
  attempt,
20054
20791
  status,
20055
- ...message && { message: clip$1(message) },
20792
+ ...message && { message: clip(message) },
20056
20793
  ...Object.keys(data).length && { data },
20057
20794
  ...at && { at }
20058
20795
  });
@@ -20138,7 +20875,7 @@ function agentpipeMapper(report) {
20138
20875
  if (ci?.said !== now) report.event({
20139
20876
  kind: "activity",
20140
20877
  ...step && { step },
20141
- message: clip$1(now),
20878
+ message: clip(now),
20142
20879
  ...at && { at }
20143
20880
  });
20144
20881
  ci = {
@@ -20216,7 +20953,7 @@ function agentpipeMapper(report) {
20216
20953
  const change = str(d.change);
20217
20954
  if (change) report.event({
20218
20955
  kind: "board",
20219
- message: clip$1(change),
20956
+ message: clip(change),
20220
20957
  ...at && { at }
20221
20958
  });
20222
20959
  return;
@@ -20229,8 +20966,8 @@ function agentpipeMapper(report) {
20229
20966
  report.event({
20230
20967
  kind: "board",
20231
20968
  ...step && { step },
20232
- message: clip$1(`filed ${what}`),
20233
- data: { url: clip$1(url) },
20969
+ message: clip(`filed ${what}`),
20970
+ data: { url: clip(url) },
20234
20971
  ...at && { at }
20235
20972
  });
20236
20973
  return;
@@ -20260,7 +20997,7 @@ function agentpipeMapper(report) {
20260
20997
  for (const q of asked) report.event({
20261
20998
  kind: "question",
20262
20999
  ...step && { step },
20263
- message: clip$1(q.text),
21000
+ message: clip(q.text),
20264
21001
  data: {
20265
21002
  questionId: q.id,
20266
21003
  category: q.category
@@ -20273,7 +21010,7 @@ function agentpipeMapper(report) {
20273
21010
  report.event({
20274
21011
  kind: "question",
20275
21012
  ...step && { step },
20276
- message: clip$1(text),
21013
+ message: clip(text),
20277
21014
  ...at && { at }
20278
21015
  });
20279
21016
  return;
@@ -20321,7 +21058,7 @@ function agentpipeMapper(report) {
20321
21058
  report.event({
20322
21059
  kind: "warning",
20323
21060
  ...step && { step },
20324
- message: clip$1(text),
21061
+ message: clip(text),
20325
21062
  ...at && { at }
20326
21063
  });
20327
21064
  return;
@@ -20334,46 +21071,56 @@ function agentpipeMapper(report) {
20334
21071
  if (d.counts && typeof d.counts === "object") counts = Object.fromEntries(Object.entries(d.counts).flatMap(([k, v]) => num(v) === null ? [] : [[k, v]]));
20335
21072
  const reason = str(d.reason);
20336
21073
  runReason = reason;
20337
- const says = SAYS[status];
21074
+ const off = status === "refused" ? switchOff(d.check) : null;
21075
+ if (off) {
21076
+ ending = {
21077
+ status: "needs_human",
21078
+ reason: off.reason,
21079
+ code: off.code
21080
+ };
21081
+ return;
21082
+ }
21083
+ const says = SAYS$1[status];
20338
21084
  ending = {
20339
21085
  status: RUN_ENDINGS[status] ?? "failed",
20340
- reason: clip$1(says ? `${says}${reason ? `: ${reason}` : "."}` : reason ?? (RUN_ENDINGS[status] ? "" : `It ended ${status.replace(/_/g, " ")}.`)) || null
21086
+ reason: clip(says ? `${says}${reason ? `: ${reason}` : "."}` : reason ?? (RUN_ENDINGS[status] ? "" : `It ended ${status.replace(/_/g, " ")}.`)) || null
20341
21087
  };
20342
21088
  if (ending.status === "failed" && ending.reason) report.event({
20343
21089
  kind: "error",
20344
- message: clip$1(ending.reason)
21090
+ message: clip(ending.reason)
20345
21091
  });
20346
21092
  return;
20347
21093
  }
20348
21094
  case "merge.completed": {
20349
21095
  said = "merged";
20350
21096
  const sha = str(d.sha);
20351
- ending = {
20352
- status: "succeeded",
20353
- reason: sha ? `Merged (${sha.slice(0, 7)}).` : "Merged."
20354
- };
20355
- for (const decision of decisionsOf(d.accepted)) report.event({
21097
+ const accepted = unique(decisionsOf(d.accepted));
21098
+ for (const decision of accepted) report.event({
20356
21099
  kind: "question",
20357
21100
  ...step && { step },
20358
- message: clip$1(decision.question ?? decision.answer),
21101
+ message: clip(decision.question ?? decision.answer),
20359
21102
  data: {
20360
- decisionId: decision.decisionId,
20361
- questionId: decision.questionId,
20362
- category: decision.category,
20363
- answer: decision.answer.slice(0, 2e3),
20364
- accepted: "setting"
21103
+ ...decisionData(decision),
21104
+ accepted: decision.accepted
20365
21105
  },
20366
21106
  ...at && { at }
20367
21107
  });
21108
+ reportReplaced(d.replaced, step, at);
21109
+ const merged = sha ? `Merged (${sha.slice(0, 7)})` : "Merged";
21110
+ const n = accepted.length;
21111
+ ending = {
21112
+ status: "succeeded",
21113
+ reason: n ? `${merged}, with ${n} ${n === 1 ? "decision" : "decisions"} nobody confirmed.` : `${merged}.`
21114
+ };
20368
21115
  return;
20369
21116
  }
20370
21117
  case "merge.blocked": {
20371
21118
  said = "blocked";
20372
- const reason = str(d.reason);
21119
+ const reason = switchOff(d.check)?.reason ?? str(d.reason);
20373
21120
  const code = mergeCheckCode(d.check);
20374
21121
  ending = {
20375
21122
  status: "needs_human",
20376
- reason: clip$1(reason ?? "agentpipe didn't merge it."),
21123
+ reason: clip(reason ?? "agentpipe didn't merge it."),
20377
21124
  ...code && { code }
20378
21125
  };
20379
21126
  if (code !== "checks_pending") report.event({
@@ -20392,18 +21139,35 @@ function agentpipeMapper(report) {
20392
21139
  if (headSha) for (const decision of decisions) report.event({
20393
21140
  kind: "question",
20394
21141
  ...step && { step },
20395
- message: clip$1(decision.question ?? decision.answer),
21142
+ message: clip(decision.question ?? decision.answer),
20396
21143
  data: {
20397
- decisionId: decision.decisionId,
20398
- questionId: decision.questionId,
20399
- category: decision.category,
20400
- answer: decision.answer.slice(0, 2e3),
21144
+ ...decisionData(decision),
21145
+ ...decision.waitsBecause && { waitsBecause: decision.waitsBecause },
20401
21146
  headSha
20402
21147
  },
20403
21148
  ...at && { at }
20404
21149
  });
21150
+ reportReplaced(d.replaced, step, at);
20405
21151
  return;
20406
21152
  }
21153
+ case "close.completed":
21154
+ said = "closed";
21155
+ closed = {
21156
+ pr: num(d.pr) ?? 0,
21157
+ branchDeleted: d.branch_deleted === true
21158
+ };
21159
+ ending = {
21160
+ status: "succeeded",
21161
+ reason: null
21162
+ };
21163
+ return;
21164
+ case "close.refused":
21165
+ said = "refused";
21166
+ ending = {
21167
+ status: "failed",
21168
+ reason: clip(str(d.reason) ?? "agentpipe didn't close the pull request.")
21169
+ };
21170
+ return;
20407
21171
  case "ship.end": {
20408
21172
  flush();
20409
21173
  const state = str(d.state) ?? "failed";
@@ -20424,15 +21188,15 @@ function agentpipeMapper(report) {
20424
21188
  };
20425
21189
  else if (state === "refused") ending = {
20426
21190
  status: "failed",
20427
- reason: clip$1(`${SAYS.refused}${reason ? `: ${reason}` : "."}`)
21191
+ reason: clip(`${SAYS$1.refused}${reason ? `: ${reason}` : "."}`)
20428
21192
  };
20429
21193
  else ending = {
20430
21194
  status: SHIP_ENDINGS[state] ?? "failed",
20431
- reason: reason ? clip$1(reason) : SHIP_ENDINGS[state] ? null : `It ended ${state.replace(/_/g, " ")}.`
21195
+ reason: reason ? clip(reason) : SHIP_ENDINGS[state] ? null : `It ended ${state.replace(/_/g, " ")}.`
20432
21196
  };
20433
21197
  if (ending.status === "failed" && ending.reason) report.event({
20434
21198
  kind: "error",
20435
- message: clip$1(ending.reason)
21199
+ message: clip(ending.reason)
20436
21200
  });
20437
21201
  return;
20438
21202
  }
@@ -20455,6 +21219,8 @@ function agentpipeMapper(report) {
20455
21219
  blocked: () => blocked,
20456
21220
  /** The review comments `address` set aside (`feedback.intake`'s `refused`), in order. */
20457
21221
  setAside: () => [...setAside],
21222
+ /** The pull request `close` closed to start over (`close.completed`), or null. */
21223
+ closed: () => closed,
20458
21224
  flush: () => flush(),
20459
21225
  /**
20460
21226
  * Whether the run still waits for an answer to this question: it's open and its window hasn't closed. Only so an
@@ -20471,8 +21237,9 @@ const LATE = [
20471
21237
  "decided by the agent after nobody answered in time"
20472
21238
  ];
20473
21239
  /**
20474
- * Whether agentpipe refused an answer for coming too late, from its words (0.12.0). AGE-207 gives the refusal a
20475
- * stable reason: read that instead once it's pinned. One a person already answered isn't late: it says whose it was.
21240
+ * Whether agentpipe refused an answer for coming too late, from its words (0.12.0, the same at 0.15.0). `answer --json`
21241
+ * (0.14.0, AGE-207) names the refusal's `check` (`answer_too_late`, `decided_already`): reading it instead means calling
21242
+ * `answer` with `--json`. One a person already answered isn't late: it says whose it was.
20476
21243
  */
20477
21244
  function refusedAsLate(said) {
20478
21245
  return said !== null && LATE.some((words) => said.includes(words));
@@ -20542,15 +21309,24 @@ const KEEP_PREFIXES = [
20542
21309
  "MONOBAN_"
20543
21310
  ];
20544
21311
  /**
21312
+ * The variable a caller's settings travel in (agentpipe 0.14.0, AGE-194): JSON, read by the commands that apply them.
21313
+ * The runner owns it: a value in its own environment never reaches agentpipe (agentpipeEnv), and only a loop's run
21314
+ * sets it, from its options (`runEnv`, recipes/index.ts). The preflight checks agentpipe names the same one.
21315
+ */
21316
+ const CALLER_SETTINGS = "AGENTPIPE_CALLER_SETTINGS";
21317
+ /**
20545
21318
  * agentpipe's environment: only what it needs, so the runner's other secrets (a database password, cloud keys, an
20546
21319
  * npm token) never reach it, nor the commands it runs. MONOBAN_BIN names this monoban, so agentpipe calls back the
20547
- * one that started it.
21320
+ * one that started it. A caller's settings only as given here (`callerSettings`, a loop's run's, from `runEnv`):
21321
+ * never one inherited, which would reach every command, manual runs and `cancel` included.
20548
21322
  */
20549
- function agentpipeEnv(env, monobanBin) {
21323
+ function agentpipeEnv(env, monobanBin, callerSettings = null) {
20550
21324
  const kept = {};
20551
21325
  for (const [name, value] of Object.entries(env)) if (value !== void 0 && (KEEP.has(name) || KEEP_PREFIXES.some((p) => name.startsWith(p)))) kept[name] = value;
20552
21326
  delete kept.MONOBAN_BIN;
21327
+ delete kept[CALLER_SETTINGS];
20553
21328
  if (monobanBin) kept.MONOBAN_BIN = monobanBin;
21329
+ if (callerSettings !== null) kept[CALLER_SETTINGS] = callerSettings;
20554
21330
  return kept;
20555
21331
  }
20556
21332
  /**
@@ -20559,12 +21335,12 @@ function agentpipeEnv(env, monobanBin) {
20559
21335
  * `map` (its plain lines skipped), its stderr's last line kept to say why it stopped. `stop()` and `interrupt()`
20560
21336
  * end it from outside; `agentpipe cancel <run id>` is the polite way, once there is one.
20561
21337
  */
20562
- function agentpipeCommand({ command = "agentpipe", args, cwd, env, monobanBin = null, map, spawn = defaultSpawn, graceMs }) {
21338
+ function agentpipeCommand({ command = "agentpipe", args, cwd, env, monobanBin = null, callerSettings = null, map, spawn = defaultSpawn, graceMs }) {
20563
21339
  return startProcess({
20564
21340
  command,
20565
21341
  args,
20566
21342
  cwd,
20567
- env: agentpipeEnv(env, monobanBin),
21343
+ env: agentpipeEnv(env, monobanBin, callerSettings),
20568
21344
  spawn,
20569
21345
  ...graceMs !== void 0 && { graceMs },
20570
21346
  onLine: (line) => {
@@ -20674,6 +21450,31 @@ function agentpipe({ command = "agentpipe", args = [], spawn = defaultSpawn, exe
20674
21450
  }
20675
21451
  };
20676
21452
  }
21453
+ /**
21454
+ * A loop option's flag, as `capabilities` names it (agentpipe 0.15.0), and the commands of a deliver run it goes on
21455
+ * (`address` is `address --apply`): the advisor on the three that build `arbitrate`; accepting at merge on those (a run
21456
+ * announces it on the pull request) and on `merge` (which accepts). The recipe's `ship` never merges (`--no-merge`),
21457
+ * so it never takes it. The preflight checks the folder's agentpipe has each on the commands the run calls.
21458
+ */
21459
+ const FLAGS = {
21460
+ advisor: {
21461
+ flag: "--advisor",
21462
+ commands: [
21463
+ "run",
21464
+ "review --fix",
21465
+ "address"
21466
+ ]
21467
+ },
21468
+ accept_decisions: {
21469
+ flag: "--accept-decisions",
21470
+ commands: [
21471
+ "run",
21472
+ "review --fix",
21473
+ "address",
21474
+ "merge"
21475
+ ]
21476
+ }
21477
+ };
20677
21478
  /** What each loop's recipe needs of agentpipe: its commands and their flags (docs/PLAN-AGENT-LOOPS.md §1.6). */
20678
21479
  const RECIPE_NEEDS = {
20679
21480
  deliver: [
@@ -21742,45 +22543,6 @@ function buildPrompt({ task, comments, branch }) {
21742
22543
  lines.push("", "## How to work", "", `- You're in a git checkout of the project, on the branch ${branch}, made for this task. Stay on it.`, "- Do what the task asks, and only that. Follow the repository's own instructions (CLAUDE.md, AGENTS.md, CONTRIBUTING, the README) and run its checks (tests, lint, typecheck) before you finish.", "- Commit your work on this branch with clear messages (if git won't let you, leave the changes: they're committed for you). Don't push, don't open a pull request and don't change the monoban board: that's done for you when you finish.", "- Nobody is watching to answer questions. When something is unclear, make a reasonable choice and say so in your summary. Stop as blocked only when you can't go on without an answer.", "", "End with a JSON object, and nothing after it: {\"status\": \"done\" or \"blocked\", \"summary\": what you changed and how you checked it, \"prTitle\": a pull request title, \"question\": what you need to know when blocked, else \"\"}.");
21743
22544
  return lines.join("\n");
21744
22545
  }
21745
- // src/runner/redact.ts
21746
- /**
21747
- * What the runner sends the board from an agent's output, secrets out: a command line, an error, a step's message.
21748
- * Every message a run reports goes through `clip()` (docs/PLAN-AGENT-LOOPS.md §1.6: agentpipe's too).
21749
- */
21750
- /** Secrets a command line or an error might carry, kept out of what the board shows. */
21751
- const SECRETS = [
21752
- [/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "…"],
21753
- [/\bsk-[A-Za-z0-9_-]{16,}/g, "…"],
21754
- [/\bmbn_[A-Za-z0-9_]{8,}/g, "…"],
21755
- [/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "…"],
21756
- [/\bAKIA[0-9A-Z]{16}\b/g, "…"],
21757
- [/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1…"],
21758
- [/((?:token|secret|passw(?:or)?d|api[_-]?key|auth)[A-Za-z_]*["']?\s*[=:]\s*["']?)(?!Bearer\b|Basic\b)[^\s"']+/gi, "$1…"]
21759
- ];
21760
- function redact(text) {
21761
- return SECRETS.reduce((t, [pattern, by]) => t.replace(pattern, by), text);
21762
- }
21763
- /** A message the API takes (and the board shows), secrets out. */
21764
- function clip(text, max = 2e3) {
21765
- const clean = redact(text).trim();
21766
- return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;
21767
- }
21768
- /** Words as a sentence: ended with a period unless they end a sentence already. */
21769
- function sentence(text) {
21770
- const said = text.trim();
21771
- return /[.!?…]$/.test(said) ? said : `${said}.`;
21772
- }
21773
- /**
21774
- * A reason that names a command a person must run on the runner's machine (docs/PLAN-AGENT-LOOPS.md §1.6): the
21775
- * sentence first, complete without the command, then the command as the last sentence, on the same line (a run's
21776
- * reason is one string, and `monoban runs` prints it in a table). A step the loop's page has a button for (accepting
21777
- * decisions, continuing from a step) names no command: the reason points at the page. Several commands are run in
21778
- * their order: "`monoban agentpipe update`, then `monoban runner restart`".
21779
- */
21780
- function onRunnersMachine(text, command, ...then) {
21781
- const commands = [command, ...then].map((c) => `\`${c}\``).join(", then ");
21782
- return `${sentence(text).replace(/\s+/g, " ")} On the runner's machine: ${commands}.`;
21783
- }
21784
22546
  const ok = (value, data) => ({
21785
22547
  status: "ok",
21786
22548
  ...value !== void 0 && { value },
@@ -21829,7 +22591,7 @@ function steps(report, isCancelled = () => false) {
21829
22591
  step: name,
21830
22592
  attempt,
21831
22593
  status,
21832
- ...message && { message: clip(message) },
22594
+ ...message && { message: clip$1(message) },
21833
22595
  data: {
21834
22596
  durationMs: Date.now() - started,
21835
22597
  ...data
@@ -22022,7 +22784,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22022
22784
  const { step } = steps(report, () => cancelled);
22023
22785
  const warn = (message) => report.event({
22024
22786
  kind: "warning",
22025
- message: clip(message)
22787
+ message: clip$1(message)
22026
22788
  });
22027
22789
  /** Says on the task how it went; a failure to is a warning, not the run's ending. */
22028
22790
  let ref = run.ref;
@@ -22045,7 +22807,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22045
22807
  });
22046
22808
  if (moved) report.event({
22047
22809
  kind: "board",
22048
- message: clip(moved)
22810
+ message: clip$1(moved)
22049
22811
  });
22050
22812
  return ok({
22051
22813
  branch,
@@ -22059,7 +22821,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22059
22821
  })
22060
22822
  });
22061
22823
  } catch (err) {
22062
- return failed(clip(`Couldn't get the folder ready: ${err.message}`, 1e3));
22824
+ return failed(clip$1(`Couldn't get the folder ready: ${err.message}`, 1e3));
22063
22825
  }
22064
22826
  }, { always: true });
22065
22827
  if (!prepared.ran || !prepared.value) return {
@@ -22076,7 +22838,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22076
22838
  if (limited) report.event({
22077
22839
  kind: "warning",
22078
22840
  step: "code",
22079
- message: clip(limited.warning)
22841
+ message: clip$1(limited.warning)
22080
22842
  });
22081
22843
  const asked = limited ? {
22082
22844
  ...run,
@@ -22090,14 +22852,14 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22090
22852
  const activity = throttled((message) => report.event({
22091
22853
  kind: "activity",
22092
22854
  step: "code",
22093
- message: clip(message, 200)
22855
+ message: clip$1(message, 200)
22094
22856
  }), activityMs);
22095
22857
  const out = {
22096
22858
  activity: (m) => m.trim() && activity.push(m),
22097
22859
  warning: (m) => report.event({
22098
22860
  kind: "warning",
22099
22861
  step: "code",
22100
- message: clip(m)
22862
+ message: clip$1(m)
22101
22863
  }),
22102
22864
  externalId: (id) => report.update({ externalId: id.slice(0, 128) })
22103
22865
  };
@@ -22163,7 +22925,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22163
22925
  let { failure } = coded.value;
22164
22926
  if (spawnError) return {
22165
22927
  status: "failed",
22166
- reason: clip(spawnError, 1e3)
22928
+ reason: clip$1(spawnError, 1e3)
22167
22929
  };
22168
22930
  const unfinished = cancelled || failure !== null;
22169
22931
  const committed = await step("commit", async () => {
@@ -22198,35 +22960,35 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22198
22960
  reason: commits ? `Cancelled; its work so far is on ${branch}.` : null
22199
22961
  };
22200
22962
  if (failure) {
22201
- await tell(`${label} couldn't finish: ${clip(failure, 1e3)}${kept}`);
22963
+ await tell(`${label} couldn't finish: ${clip$1(failure, 1e3)}${kept}`);
22202
22964
  return {
22203
22965
  status: "failed",
22204
- reason: clip(failure, 1e3)
22966
+ reason: clip$1(failure, 1e3)
22205
22967
  };
22206
22968
  }
22207
22969
  if (outcome?.status === "blocked") {
22208
22970
  const question = outcome.question || outcome.summary || "It got stuck without saying why.";
22209
22971
  report.event({
22210
22972
  kind: "question",
22211
- message: clip(question)
22973
+ message: clip$1(question)
22212
22974
  });
22213
- await tell(`${label} needs an answer: ${clip(question, 1500)}${kept}`);
22975
+ await tell(`${label} needs an answer: ${clip$1(question, 1500)}${kept}`);
22214
22976
  return {
22215
22977
  status: "needs_human",
22216
- reason: clip(question, 1e3)
22978
+ reason: clip$1(question, 1e3)
22217
22979
  };
22218
22980
  }
22219
22981
  const summary = outcome?.summary || (typeof result.answer === "string" ? result.answer : "");
22220
22982
  if (!commits) {
22221
22983
  const reason = `${label} changed nothing${summary ? `: ${summary}` : "."}`;
22222
- await tell(`${label} made no changes.${summary ? `\n\n${clip(summary, 1500)}` : ""}`);
22984
+ await tell(`${label} made no changes.${summary ? `\n\n${clip$1(summary, 1500)}` : ""}`);
22223
22985
  return {
22224
22986
  status: "needs_human",
22225
- reason: clip(reason, 1e3)
22987
+ reason: clip$1(reason, 1e3)
22226
22988
  };
22227
22989
  }
22228
22990
  let url = null;
22229
- const prTitle = clip(outcome?.prTitle || `${ref}: ${title}`, 200);
22991
+ const prTitle = clip$1(outcome?.prTitle || `${ref}: ${title}`, 200);
22230
22992
  if (run.options.pr === "none") await step("pr", async () => skipped(`none asked for: the work is on ${branch}`));
22231
22993
  else {
22232
22994
  const up = async (fn) => {
@@ -22234,7 +22996,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22234
22996
  await fn();
22235
22997
  return ok();
22236
22998
  } catch (err) {
22237
- return failed(clip(err.message, 1e3));
22999
+ return failed(clip$1(err.message, 1e3));
22238
23000
  }
22239
23001
  };
22240
23002
  const pushed = await step("push", () => up(() => ws.push(branch)));
@@ -22243,7 +23005,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22243
23005
  base,
22244
23006
  branch,
22245
23007
  title: prTitle,
22246
- body: `${clip(summary || prTitle, 6e3)}\n\n---\n${ref} · by ${label}, through \`monoban runner\``,
23008
+ body: `${clip$1(summary || prTitle, 6e3)}\n\n---\n${ref} · by ${label}, through \`monoban runner\``,
22247
23009
  draft: run.options.pr === "draft"
22248
23010
  });
22249
23011
  report.update({ prUrl: url });
@@ -22266,7 +23028,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22266
23028
  await step("report", async () => {
22267
23029
  try {
22268
23030
  if (url) await board.attach(ref, url, prTitle, run.options.pr === "draft");
22269
- await board.comment(ref, `${label} finished${url ? `: ${url}` : `, on the branch \`${branch}\``}.${summary ? `\n\n${clip(summary, 6e3)}` : ""}`);
23031
+ await board.comment(ref, `${label} finished${url ? `: ${url}` : `, on the branch \`${branch}\``}.${summary ? `\n\n${clip$1(summary, 6e3)}` : ""}`);
22270
23032
  report.event({
22271
23033
  kind: "board",
22272
23034
  message: url ? "attached the pull request, and commented" : "commented"
@@ -22284,7 +23046,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22284
23046
  return {
22285
23047
  done: flow().catch((err) => ({
22286
23048
  status: "failed",
22287
- reason: clip(`The run stopped: ${err.message}`, 1e3)
23049
+ reason: clip$1(`The run stopped: ${err.message}`, 1e3)
22288
23050
  })),
22289
23051
  cancel: async () => {
22290
23052
  cancelled = true;
@@ -22491,6 +23253,129 @@ const codexSpec = ({ allowFullAccess = false } = {}) => ({
22491
23253
  reader: codexReader
22492
23254
  });
22493
23255
  codexSpec();
23256
+ // src/runner/recipes/settings.ts
23257
+ /**
23258
+ * A loop's settings for agentpipe (AGE-193, docs/PLAN-AGENT-LOOPS.md §1.14): a deliver loop's `network` and `sites`
23259
+ * become agentpipe's `allow_network` and `allowed_domains` for its `resolve` and `arbitrate` steps, handed to the
23260
+ * commands that apply them as JSON in one environment variable (CALLER_SETTINGS), never a file or an argument.
23261
+ */
23262
+ /** The steps a caller's settings set, and their fields, as agentpipe's `capabilities` lists them (AGE-196). */
23263
+ const CALLER_STEPS = ["resolve", "arbitrate"];
23264
+ const CALLER_FIELDS = ["allow_network", "allowed_domains"];
23265
+ /**
23266
+ * A run's settings from its loop's options: with the network on, both steps reach it, fetching from the loop's sites
23267
+ * alone. None with it off: agentpipe then runs on the machine's own config. The options aren't checked here (the API
23268
+ * did): a network on with odd sites is sent as it is, for agentpipe to refuse, never dropped.
23269
+ */
23270
+ function callerSettingsOf(options) {
23271
+ if (options.network !== true) return null;
23272
+ const sites = Array.isArray(options.sites) ? options.sites.map(String) : [];
23273
+ const step = () => ({
23274
+ allow_network: true,
23275
+ allowed_domains: [...sites]
23276
+ });
23277
+ return { steps: {
23278
+ resolve: step(),
23279
+ arbitrate: step()
23280
+ } };
23281
+ }
23282
+ /** Which of the commands that apply a caller's settings this is, or null: one that never gets them. */
23283
+ function callerCommandOf(args) {
23284
+ if (args[0] === "run") return "run";
23285
+ if (args[0] === "review" && args.includes("--fix")) return "review --fix";
23286
+ if (args[0] === "address" && args.includes("--apply")) return "address";
23287
+ return null;
23288
+ }
23289
+ /**
23290
+ * The environment of one agentpipe command of a loop's run, as `agentpipeCommand` takes it: the runner's (agentpipe
23291
+ * keeps only part of it, agentpipeEnv), the loop's project as the folder's (`MONOBAN_PROJECT`: the runner checked the
23292
+ * folder is that project's, but its link or $MONOBAN_PROJECT could name another), and the run's settings, only on a
23293
+ * command that applies them. Every command of a run gets its environment here, its dry run included: this is the one
23294
+ * place that sets CALLER_SETTINGS.
23295
+ */
23296
+ function runEnv(run, settings, deps, args) {
23297
+ const command = callerCommandOf(args);
23298
+ const applies = settings !== null && command !== null && settings.commands.includes(command);
23299
+ return {
23300
+ env: {
23301
+ ...deps.env,
23302
+ MONOBAN_PROJECT: run.project
23303
+ },
23304
+ callerSettings: applies ? JSON.stringify(settings.settings) : null
23305
+ };
23306
+ }
23307
+ /** The same sites, whatever their order or case. */
23308
+ function sameSites(a, b) {
23309
+ const [x, y] = [new Set(a.map((s) => s.toLowerCase())), new Set(b.map((s) => s.toLowerCase()))];
23310
+ return x.size === y.size && [...x].every((s) => y.has(s));
23311
+ }
23312
+ const sitesSaid = (sites) => sites.length ? sites.join(", ") : "none";
23313
+ /**
23314
+ * What a command's `run.start` says agentpipe applied (`caller`, agentpipe 0.14.0, AGE-195: one entry per step the
23315
+ * caller set; none when nothing was sent) against what the run sent: one difference per step, in words, with its
23316
+ * values as event data takes them (no lists: the sites joined). Nothing stops the run (AGE-193 D22): the dry run's
23317
+ * comparison is the check that refuses.
23318
+ */
23319
+ function callerDifferences(caller, sent) {
23320
+ const applied = /* @__PURE__ */ new Map();
23321
+ for (const entry of Array.isArray(caller) ? caller : []) {
23322
+ if (!entry || typeof entry !== "object") continue;
23323
+ const { step, allow_network, allowed_domains } = entry;
23324
+ if (typeof step !== "string") continue;
23325
+ const sites = Array.isArray(allowed_domains) ? allowed_domains.filter((s) => typeof s === "string") : [];
23326
+ applied.set(step, {
23327
+ network: allow_network === true,
23328
+ sites
23329
+ });
23330
+ }
23331
+ return CALLER_STEPS.flatMap((step) => {
23332
+ const want = sent?.steps[step] ?? null;
23333
+ const got = applied.get(step) ?? null;
23334
+ const asked = want ? {
23335
+ network: want.allow_network,
23336
+ sites: want.allowed_domains
23337
+ } : null;
23338
+ if (!asked && !got) return [];
23339
+ if (asked && got && asked.network === got.network && sameSites(asked.sites, got.sites)) return [];
23340
+ const said = (s) => s ? `the network ${s.network ? "on" : "off"}, sites ${sitesSaid(s.sites)}` : "nothing set";
23341
+ return [{
23342
+ step,
23343
+ message: `agentpipe set ${step} otherwise than the run sent: ${said(got)}, where the run sent ${said(asked)}.`,
23344
+ data: {
23345
+ callerSettings: true,
23346
+ agentpipeStep: step,
23347
+ network: got ? got.network : null,
23348
+ sites: got ? got.sites.join(",") : null,
23349
+ sentNetwork: asked ? asked.network : null,
23350
+ sentSites: asked ? asked.sites.join(",") : null
23351
+ }
23352
+ }];
23353
+ });
23354
+ }
23355
+ /** The tools a step that reads sites may hold (AGE-194): it needs `WebFetch`, and nothing beyond these. */
23356
+ const READING_TOOLS = [
23357
+ "Read",
23358
+ "Glob",
23359
+ "Grep",
23360
+ "WebFetch"
23361
+ ];
23362
+ /**
23363
+ * What a dry run's step boundary says against the run's settings for it (AGE-194): the network on, the run's sites
23364
+ * (as sets), its tools within Read, Glob, Grep and WebFetch with WebFetch among them, and its reads held to the
23365
+ * worktree (`read_scope`). Each difference in words; none: it is held as sent.
23366
+ */
23367
+ function boundaryDifferences(boundary, sent) {
23368
+ const out = [];
23369
+ if (boundary.network !== true) out.push("its network is off");
23370
+ const sites = Array.isArray(boundary.allowed_domains) ? boundary.allowed_domains.map(String) : [];
23371
+ if (!sameSites(sites, sent.allowed_domains)) out.push(`it would read ${sitesSaid(sites)}, not ${sitesSaid(sent.allowed_domains)}`);
23372
+ const tools = Array.isArray(boundary.tools) ? boundary.tools.map(String) : [];
23373
+ const beyond = tools.filter((t) => !READING_TOOLS.includes(t));
23374
+ if (beyond.length) out.push(`it holds ${beyond.join(", ")}`);
23375
+ if (!tools.includes("WebFetch")) out.push("it has no WebFetch");
23376
+ if (boundary.read_scope !== "worktree") out.push(`its reads aren't held to the worktree (${typeof boundary.read_scope === "string" ? boundary.read_scope : "unsaid"})`);
23377
+ return out;
23378
+ }
22494
23379
  // src/runner/recipes/deliver.ts
22495
23380
  /**
22496
23381
  * `deliver` (docs/PLAN-AGENT-LOOPS.md §1.6): takes a task and delivers it as a pull request: `implement` opens it
@@ -22504,9 +23389,25 @@ function options(run) {
22504
23389
  return {
22505
23390
  checksMinutes: o.checksMinutes ?? LOOP_DEFAULTS.checksMinutes,
22506
23391
  reviewTier: o.reviewTier ?? null,
22507
- askMinutes: o.askMinutes ?? LOOP_DEFAULTS.askMinutes
23392
+ askMinutes: o.askMinutes ?? LOOP_DEFAULTS.askMinutes,
23393
+ advisor: o.advisor === true,
23394
+ acceptAtMerge: o.acceptAtMerge === true
22508
23395
  };
22509
23396
  }
23397
+ /** The loop's options that are agentpipe flags (§1.15, MON-268), each by the capability that names it. */
23398
+ function flagged(run) {
23399
+ const o = options(run);
23400
+ return [...o.advisor ? ["advisor"] : [], ...o.acceptAtMerge ? ["accept_decisions"] : []];
23401
+ }
23402
+ /**
23403
+ * The loop's flags for one agentpipe command (§1.15, MON-268), on the commands `capabilities` lists for each
23404
+ * (agentpipe 0.15.0, FLAGS): `--advisor` on `run`, `review --fix` and `address --apply` when the loop's advisor is on;
23405
+ * `--accept-decisions` on those and on `merge` when it accepts at merge. None with both off. Whether the machine allows
23406
+ * them is agentpipe's to say: its dry run refuses either flag the owner's switch doesn't allow.
23407
+ */
23408
+ function flagsFor(run, command) {
23409
+ return flagged(run).filter((capability) => FLAGS[capability].commands.includes(command)).map((capability) => FLAGS[capability].flag);
23410
+ }
22510
23411
  /** The loop's review tier, if it names one: the preflight checks the folder's agentpipe has it. */
22511
23412
  const reviewTierOf = (run) => options(run).reviewTier;
22512
23413
  /** Money as agentpipe takes it: dollars, to the cent. */
@@ -22515,8 +23416,9 @@ const usd = (n) => (Math.floor(n * 100) / 100).toFixed(2);
22515
23416
  * `agentpipe run` on the run's task: always `--autonomous` (it never stops to ask in a terminal nobody reads), from
22516
23417
  * an up-to-date base (`--fresh-base`), opening a draft pull request (`checks` marks it ready once it's green), on
22517
23418
  * what is left of the budget. A loop that waits for your answers (`askMinutes`) holds the questions only you can
22518
- * settle open that long first (`--ask-window`, AGE-202); otherwise agentpipe decides them at once. The dry run is the
22519
- * same command with `--dry-run`, so it checks what the run will do.
23419
+ * settle open that long first (`--ask-window`, AGE-202); otherwise agentpipe decides them at once. The loop's
23420
+ * advisor and accepting at merge are its flags (`flagsFor`). The dry run is the same command with `--dry-run`, so it
23421
+ * checks what the run will do, the owner's switches for those flags included.
22520
23422
  */
22521
23423
  function implementArgs(run, budgetUsd) {
22522
23424
  const { askMinutes } = options(run);
@@ -22531,12 +23433,84 @@ function implementArgs(run, budgetUsd) {
22531
23433
  "--draft",
22532
23434
  "--budget",
22533
23435
  usd(budgetUsd),
22534
- ...askMinutes > 0 ? ["--ask-window", String(askMinutes * 60)] : []
23436
+ ...askMinutes > 0 ? ["--ask-window", String(askMinutes * 60)] : [],
23437
+ ...flagsFor(run, "run")
22535
23438
  ];
22536
23439
  }
23440
+ /**
23441
+ * `agentpipe close` (AGE-223, agentpipe 0.15.0): closes the pull request a start-over discards (MON-292), as the run
23442
+ * that opened it (`--expect-run`, which it refuses unless that run on this machine opened it; without the id, the run
23443
+ * its branch names). It comments why on the pull request itself (it takes no reason of ours), deletes the run's
23444
+ * branch, and records the work as started over, not rejected.
23445
+ */
23446
+ function closeArgs(run, pr, externalId) {
23447
+ return [
23448
+ "close",
23449
+ String(pr.number),
23450
+ run.workdir,
23451
+ ...externalId ? ["--expect-run", externalId] : [],
23452
+ "--json"
23453
+ ];
23454
+ }
23455
+ /**
23456
+ * What the run says first once agentpipe closed the pull request it starts over: its number, and what became of its
23457
+ * branch (agentpipe's is `agentpipe/<run id>`; `close.completed` says only whether it's gone).
23458
+ */
23459
+ function closedSays(pr, externalId, branchDeleted) {
23460
+ const branch = externalId ? ` agentpipe/${externalId}` : "";
23461
+ return branchDeleted ? `Closed #${pr.number} to start over; its branch${branch} was deleted.` : `Closed #${pr.number} to start over; its branch${branch} was kept.`;
23462
+ }
23463
+ /**
23464
+ * A start-over (MON-292), before anything else in implement: agentpipe closes the pull request it discards, and the
23465
+ * task's link to it says closed. Anything but `close.completed` ends the run there, before `agentpipe run`: a second
23466
+ * pull request must not be possible. Neither its run id nor its pull request becomes the run's (the mapper reports
23467
+ * none for `close`); the run's are what `agentpipe run` opens next. Null once it's closed.
23468
+ */
23469
+ async function closeFirst(ctx, closes) {
23470
+ const value = {
23471
+ externalId: null,
23472
+ prUrl: null
23473
+ };
23474
+ const old = prOf(closes.prUrl);
23475
+ if (!old) return failed(`There's no pull request to close: ${clip$1(closes.prUrl, 200)} isn't one.`, value);
23476
+ const closed = await ctx.agentpipe(closeArgs(ctx.run, old, closes.externalId));
23477
+ if (closed.ending?.status === "cancelled") return {
23478
+ status: "cancelled",
23479
+ message: "Cancelled.",
23480
+ value
23481
+ };
23482
+ if (!closed.closed) {
23483
+ const { exit } = closed;
23484
+ const said = closed.ending?.reason ?? exit.spawnError ?? exit.lastError;
23485
+ return failed(said ? sentence(said) : `agentpipe didn't close #${old.number} and didn't say why.`, value);
23486
+ }
23487
+ await ctx.prClosed(old);
23488
+ ctx.note(closedSays(old, closes.externalId, closed.closed.branchDeleted));
23489
+ return null;
23490
+ }
23491
+ /** What a start-over needs of agentpipe (`capabilities`): `close` with `--json` and `--expect-run`. */
23492
+ const CLOSE_NEEDS = ["close.json", "close.expect_run"];
22537
23493
  /** Whether the run's preview is implement's dry run: a run with its task that doesn't only merge. */
22538
23494
  const previewed = (run) => Boolean(run.ref) && run.plan.from !== "merge";
22539
- /** `agentpipe review` on the pull request, fixing what it finds, on the loop's tier when it names one. */
23495
+ /**
23496
+ * The loop's network and sites for agentpipe's `resolve` and `arbitrate` (§1.14), on the commands that build those
23497
+ * steps: `run` (implement, and the dry run before it), `review --fix` and `address`. A run continued from `checks` or
23498
+ * `feedback` runs only `address`, previewed with implement's dry run, which builds the two steps from the same config
23499
+ * (AGE-193 D21). None for a run that only merges (no dry run, no model), or with the network off.
23500
+ */
23501
+ function settingsOf(run) {
23502
+ const settings = callerSettingsOf(run.plan.options);
23503
+ if (!settings || !previewed(run)) return null;
23504
+ return {
23505
+ settings,
23506
+ commands: run.plan.from ? ["run", "address"] : [
23507
+ "run",
23508
+ "review --fix",
23509
+ "address"
23510
+ ]
23511
+ };
23512
+ }
23513
+ /** `agentpipe review` on the pull request, fixing what it finds, on the loop's tier when it names one, with its flags. */
22540
23514
  function reviewArgs(run, pr, budgetUsd) {
22541
23515
  const tier = options(run).reviewTier;
22542
23516
  return [
@@ -22547,7 +23521,8 @@ function reviewArgs(run, pr, budgetUsd) {
22547
23521
  "--json",
22548
23522
  "--budget",
22549
23523
  usd(budgetUsd),
22550
- ...tier ? ["--tier", tier] : []
23524
+ ...tier ? ["--tier", tier] : [],
23525
+ ...flagsFor(run, "review --fix")
22551
23526
  ];
22552
23527
  }
22553
23528
  /**
@@ -22570,7 +23545,10 @@ function checksArgs(run, pr, budgetUsd, { force = false, deadline = options(run)
22570
23545
  ...force ? ["--force"] : []
22571
23546
  ];
22572
23547
  }
22573
- /** `agentpipe address --apply --ship --no-merge`: answers the review comments, then sees CI green again. */
23548
+ /**
23549
+ * `agentpipe address --apply --ship --no-merge`: answers the review comments, then sees CI green again, with the
23550
+ * loop's flags (its ship loop never merges, so `--accept-decisions` there only announces this run's decisions).
23551
+ */
22574
23552
  function feedbackArgs(run, pr, budgetUsd) {
22575
23553
  return [
22576
23554
  "address",
@@ -22581,13 +23559,16 @@ function feedbackArgs(run, pr, budgetUsd) {
22581
23559
  "--no-merge",
22582
23560
  "--json",
22583
23561
  "--budget",
22584
- usd(budgetUsd)
23562
+ usd(budgetUsd),
23563
+ ...flagsFor(run, "address")
22585
23564
  ];
22586
23565
  }
22587
23566
  /**
22588
23567
  * `agentpipe merge --expect-run`: merges the pull request only if it is the one this machine's run opened (its
22589
23568
  * store has the run, the branch is the run's, the author is the `gh` user), refusing a required review or a blocked
22590
- * one (§1.7). A refusal says what a person does next (`unblocking`).
23569
+ * one (§1.7). A refusal says what a person does next (`unblocking`). A loop that accepts at merge passes
23570
+ * `--accept-decisions` (§1.15): agentpipe accepts each decision of a run on the pull request that announced it, and
23571
+ * still holds the ones a person must read (`waitsBecause`), which go to the loop's page as any other.
22591
23572
  */
22592
23573
  function mergeArgs(run, pr, runId) {
22593
23574
  return [
@@ -22596,12 +23577,14 @@ function mergeArgs(run, pr, runId) {
22596
23577
  run.workdir,
22597
23578
  "--expect-run",
22598
23579
  runId,
22599
- "--json"
23580
+ "--json",
23581
+ ...flagsFor(run, "merge")
22600
23582
  ];
22601
23583
  }
22602
23584
  /**
22603
- * `agentpipe ratify`: accepts one provisional decision of the run that opened the pull request, at a commit. With
22604
- * `--json` (agentpipe 0.13.0, AGE-218) it ends on one `run.end`: `ok` (`ratified`), or `refused` with one sentence.
23585
+ * `agentpipe ratify`: accepts one provisional decision of a run on the pull request (its own: ids repeat across runs,
23586
+ * AGE-219), at a commit. With `--json` (agentpipe 0.13.0, AGE-218) it ends on one `run.end`: `ok` (`ratified`), or
23587
+ * `refused` with one sentence.
22605
23588
  */
22606
23589
  function ratifyArgs(decision, runId, headSha) {
22607
23590
  return [
@@ -22616,19 +23599,20 @@ function ratifyArgs(decision, runId, headSha) {
22616
23599
  ];
22617
23600
  }
22618
23601
  /**
22619
- * Continued after a person accepted the last run's decisions in the browser: each ratified at the commit they read,
22620
- * so a merge of anything newer still refuses (agentpipe binds a ratification to its commit). How it stopped, or
22621
- * null when agentpipe took them all.
23602
+ * Continued after a person accepted the last run's decisions in the browser: each ratified against its own run
23603
+ * (MON-302; a plain id, from a server before it, is the run that opened the pull request's) at the commit they read,
23604
+ * so a merge of anything newer still refuses (agentpipe binds a ratification to its commit). How it stopped, or null
23605
+ * when agentpipe took them all.
22622
23606
  */
22623
23607
  async function ratify(ctx, runId, accept) {
22624
- for (const decision of accept.decisions) {
22625
- const ratified = await ctx.agentpipe(ratifyArgs(decision, runId, accept.headSha));
23608
+ for (const decision of accept.decisions.map((d) => acceptedOf(d, runId))) {
23609
+ const ratified = await ctx.agentpipe(ratifyArgs(decision.id, decision.run, accept.headSha));
22626
23610
  if (ratified.ending?.status === "cancelled") return endOf(ratified, "agentpipe ratify");
22627
23611
  const { exit } = ratified;
22628
23612
  const said = exit.spawnError ?? (ratified.ending ? ratified.reason : exit.lastError);
22629
23613
  if (exit.code !== 0) return {
22630
23614
  status: "needs_human",
22631
- message: notRatified(decision, said)
23615
+ message: notRatified(decision.id, said)
22632
23616
  };
22633
23617
  }
22634
23618
  return null;
@@ -22733,7 +23717,7 @@ function unblocking(reason, blocked) {
22733
23717
  const checks = blocked?.check === "checks_pending" || blocked?.check === "checks_failed";
22734
23718
  if (!checks && said.includes("`")) return said;
22735
23719
  const next = checks ? NEXT.checks : NEXT.settled;
22736
- return `${clip(sentence(said), RUN_REASON - next.length - 1)} ${next}`;
23720
+ return `${clip$1(sentence(said), RUN_REASON - next.length - 1)} ${next}`;
22737
23721
  }
22738
23722
  /** A step's ending from how its command ended: agentpipe's word, else why it stopped without one. */
22739
23723
  function endOf(result, what) {
@@ -22768,6 +23752,9 @@ const deliver = {
22768
23752
  pollSeconds: 15,
22769
23753
  run: async (ctx) => {
22770
23754
  if (!ctx.run.ref) return failed("A deliver run needs its task.");
23755
+ const closes = ctx.run.plan.closes;
23756
+ const stopped = closes ? await closeFirst(ctx, closes) : null;
23757
+ if (stopped) return stopped;
22771
23758
  return endOf(await ctx.agentpipe(implementArgs(ctx.run, ctx.budgetUsd)), "agentpipe run");
22772
23759
  }
22773
23760
  },
@@ -22816,6 +23803,7 @@ const deliver = {
22816
23803
  const merged = await ctx.agentpipe(mergeArgs(ctx.run, pr, ctx.runId));
22817
23804
  if (merged.blocked?.check === "checks_pending") return checksPending(ctx, pr, merged);
22818
23805
  const end = endOf(merged, "agentpipe merge");
23806
+ if (end.code === "accept_switch_off") return end;
22819
23807
  return end.status === "needs_human" ? {
22820
23808
  ...end,
22821
23809
  message: unblocking(end.message, merged.blocked)
@@ -22825,7 +23813,13 @@ const deliver = {
22825
23813
  },
22826
23814
  dryRun: (run) => previewed(run) ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
22827
23815
  tier: (run) => run.plan.from ? null : reviewTierOf(run),
22828
- needs: (run) => [...previewed(run) && options(run).askMinutes > 0 ? ["run.ask_window"] : [], ...run.plan.accept ? ["ratify.json"] : []],
23816
+ settings: settingsOf,
23817
+ needs: (run) => [
23818
+ ...previewed(run) && options(run).askMinutes > 0 ? ["run.ask_window"] : [],
23819
+ ...run.plan.accept ? ["ratify.json"] : [],
23820
+ ...flagged(run),
23821
+ ...run.plan.closes ? CLOSE_NEEDS : []
23822
+ ],
22829
23823
  finished: ({ pr, last }) => {
22830
23824
  if (!pr) return null;
22831
23825
  if (last?.step === "merge" && last.status === "ok") return last.message ?? "Merged.";
@@ -23003,10 +23997,8 @@ function runRecipe(name, run, report, deps) {
23003
23997
  const innerAttempts = /* @__PURE__ */ new Map();
23004
23998
  /** The review comments set aside over the whole run, each once (by its link, else its author and words). */
23005
23999
  const setAside = /* @__PURE__ */ new Map();
23006
- const projectEnv = {
23007
- ...deps.env,
23008
- MONOBAN_PROJECT: run.project
23009
- };
24000
+ /** What the run hands agentpipe (`runEnv` puts it on the commands that apply it). */
24001
+ const settings = recipe?.settings?.(run) ?? null;
23010
24002
  const command = (outer) => async (args) => {
23011
24003
  if (cancelled) return {
23012
24004
  ending: {
@@ -23026,7 +24018,8 @@ function runRecipe(name, run, report, deps) {
23026
24018
  filed: [],
23027
24019
  counts: null,
23028
24020
  blocked: null,
23029
- setAside: []
24021
+ setAside: [],
24022
+ closed: null
23030
24023
  };
23031
24024
  let externalId = null;
23032
24025
  let prUrl = null;
@@ -23045,7 +24038,7 @@ function runRecipe(name, run, report, deps) {
23045
24038
  ...e,
23046
24039
  ...step && { step },
23047
24040
  ...attempt !== null && { attempt },
23048
- ...e.message && { message: clip(e.message) }
24041
+ ...e.message && { message: clip$1(e.message) }
23049
24042
  });
23050
24043
  },
23051
24044
  update: (u) => {
@@ -23087,13 +24080,22 @@ function runRecipe(name, run, report, deps) {
23087
24080
  if (noted || !leased || !pid || event.kind === "ship.end") return;
23088
24081
  noted = safely(() => leases.started(leased.url, pid));
23089
24082
  };
24083
+ const given = runEnv(run, settings, deps, args);
24084
+ const applying = callerCommandOf(args) !== null;
24085
+ const sent = settings && given.callerSettings !== null ? settings.settings : null;
23090
24086
  const started = agentpipeCommand({
23091
24087
  command: deps.command,
23092
24088
  args,
23093
24089
  cwd: run.workdir,
23094
- env: projectEnv,
24090
+ ...given,
23095
24091
  monobanBin: deps.monobanBin,
23096
24092
  map: (event) => {
24093
+ if (applying && event.kind === "run.start") for (const { message, data } of callerDifferences(event.data?.caller, sent)) report.event({
24094
+ kind: "warning",
24095
+ step: outer,
24096
+ message: clip$1(message),
24097
+ data
24098
+ });
23097
24099
  feed.take(event);
23098
24100
  if (current) current.externalId = externalId;
23099
24101
  watch(event);
@@ -23132,7 +24134,8 @@ function runRecipe(name, run, report, deps) {
23132
24134
  filed: feed.filed(),
23133
24135
  counts: feed.counts(),
23134
24136
  blocked: feed.blocked(),
23135
- setAside: feed.setAside()
24137
+ setAside: feed.setAside(),
24138
+ closed: feed.closed()
23136
24139
  };
23137
24140
  };
23138
24141
  /**
@@ -23145,13 +24148,13 @@ function runRecipe(name, run, report, deps) {
23145
24148
  for (const { step, author, reason, url, said } of setAside.values()) report.event({
23146
24149
  kind: "warning",
23147
24150
  step,
23148
- message: clip(`Set aside a review comment by ${author} (${reason})`),
24151
+ message: clip$1(`Set aside a review comment by ${author} (${reason})`),
23149
24152
  data: {
23150
24153
  setAside: true,
23151
24154
  author: author.slice(0, 200),
23152
24155
  reason: reason.slice(0, 200),
23153
24156
  url: url && url.length <= 2e3 ? url : null,
23154
- opening: said ? clip(said, 500) : null
24157
+ opening: said ? clip$1(said, 500) : null
23155
24158
  }
23156
24159
  });
23157
24160
  };
@@ -23219,10 +24222,27 @@ function runRecipe(name, run, report, deps) {
23219
24222
  report.event({
23220
24223
  kind: "warning",
23221
24224
  step: stepName,
23222
- message: clip(message)
24225
+ message: clip$1(message)
23223
24226
  });
23224
24227
  }
23225
- }
24228
+ },
24229
+ prClosed: async (p) => {
24230
+ try {
24231
+ await deps.prClosed?.(p.url);
24232
+ } catch (err) {
24233
+ const message = `Couldn't set the task's link to #${p.number} closed: ${err.message}`;
24234
+ report.event({
24235
+ kind: "warning",
24236
+ step: stepName,
24237
+ message: clip$1(message)
24238
+ });
24239
+ }
24240
+ },
24241
+ note: (message) => report.event({
24242
+ kind: "board",
24243
+ step: stepName,
24244
+ message: clip$1(message)
24245
+ })
23226
24246
  };
23227
24247
  finishing = Boolean(s.finishes);
23228
24248
  const out = await step(stepName, () => s.run(ctx));
@@ -23245,7 +24265,7 @@ function runRecipe(name, run, report, deps) {
23245
24265
  if (out.status === "ok" || out.status === "skipped") continue;
23246
24266
  return {
23247
24267
  status: out.status === "needs_human" || out.status === "cancelled" ? out.status : "failed",
23248
- reason: out.message ? clip(out.message, 1e3) : null,
24268
+ reason: out.message ? clip$1(out.message, 1e3) : null,
23249
24269
  ...out.code && { code: out.code }
23250
24270
  };
23251
24271
  }
@@ -23258,7 +24278,7 @@ function runRecipe(name, run, report, deps) {
23258
24278
  };
23259
24279
  })().catch((err) => ({
23260
24280
  status: "failed",
23261
- reason: clip(`The run stopped: ${err.message}`, 1e3)
24281
+ reason: clip$1(`The run stopped: ${err.message}`, 1e3)
23262
24282
  })).then((ending) => {
23263
24283
  reportSetAside();
23264
24284
  return ending;
@@ -23281,11 +24301,11 @@ function runRecipe(name, run, report, deps) {
23281
24301
  };
23282
24302
  if (refusedAsLate(said)) return {
23283
24303
  outcome: "too_late",
23284
- message: clip(`Too late: ${said}`, 1e3)
24304
+ message: clip$1(`Too late: ${said}`, 1e3)
23285
24305
  };
23286
24306
  return {
23287
24307
  outcome: "refused",
23288
- message: clip(`agentpipe didn't take your answer to ${a.questionId}: ${said ?? `exit code ${code ?? "none"}`}`, 1e3)
24308
+ message: clip$1(`agentpipe didn't take your answer to ${a.questionId}: ${said ?? `exit code ${code ?? "none"}`}`, 1e3)
23289
24309
  };
23290
24310
  },
23291
24311
  cancel: async () => {
@@ -23333,9 +24353,10 @@ const DEFINITIONS = {
23333
24353
  */
23334
24354
  async function detectAgents(settings, env, version = versionOf) {
23335
24355
  const names = settings.agents ?? Object.keys(AGENTS$1);
24356
+ const { [CALLER_SETTINGS]: _inherited, ...asked } = env;
23336
24357
  const checked = await Promise.all(names.map(async (name) => ({
23337
24358
  name,
23338
- version: await version(settings.commands[name], env)
24359
+ version: await version(settings.commands[name], asked)
23339
24360
  })));
23340
24361
  const found = [];
23341
24362
  const missing = [];
@@ -23460,13 +24481,21 @@ function runBoard(api) {
23460
24481
  // src/runner/recipes/preflight.ts
23461
24482
  /**
23462
24483
  * A dry-run refusal's `check` (agentpipe's name for the precondition), as the run's reason code, where monoban has
23463
- * words for it; any other refusal is `agentpipe_refused`. agentpipe 0.12.0 (the pin) says a `check` for each refusal.
23464
- * MON-250 and MON-268 add theirs here as they land.
24484
+ * words for it; any other refusal is `agentpipe_refused`. agentpipe says a `check` for each refusal (0.12.0 on); 0.14.0
24485
+ * adds a caller's settings' (`caller_*`, AGE-194), whose words name the step or the site, the file and the line to
24486
+ * change. 0.15.0 adds the owner's switches' (`advisor_not_allowed`, `accept_decisions_not_allowed`), which are monoban's
24487
+ * own sentence, naming the key and the file (SWITCHES_OFF, MON-268).
23465
24488
  */
23466
24489
  const PREVIEW_CHECKS = {
23467
24490
  signed_out: "agent_signed_out",
23468
24491
  unpushable: "cannot_push",
23469
- ungated: "commands_unverified"
24492
+ ungated: "commands_unverified",
24493
+ caller_settings_invalid: "sites_invalid",
24494
+ caller_step_not_eligible: "sites_step_ineligible",
24495
+ caller_nothing_fetched: "sites_nothing_fetched",
24496
+ caller_site_not_permitted: "site_not_permitted",
24497
+ advisor_not_allowed: "advisor_switch_off",
24498
+ accept_decisions_not_allowed: "accept_switch_off"
23470
24499
  };
23471
24500
  const refusal = (reason, code = null) => ({
23472
24501
  reason,
@@ -23484,6 +24513,12 @@ const refusal = (reason, code = null) => ({
23484
24513
  * AGE-157. A preview that doesn't say refuses it too. And a tier the recipe names (`--tier`) must be one the folder's
23485
24514
  * agentpipe has (`capabilities <folder> --json`, AGE-127), as must every flag the loop's options need (before the
23486
24515
  * dry run, which would only say it has no such option).
24516
+ *
24517
+ * A run with settings for agentpipe (a deliver loop's network and sites, §1.14) needs an agentpipe that takes them in
24518
+ * the variable the runner writes, on every command of the run that gets them (`capabilities`' `caller_settings`,
24519
+ * AGE-196: an older one would refuse the variable as an unknown setting, in other words). Its dry run gets them too,
24520
+ * and must show `resolve` and `arbitrate` held to them (AGE-194); a refusal by them (its `caller_*` checks) is
24521
+ * agentpipe's sentence, which names the site or the step, the file and the line to change.
23487
24522
  */
23488
24523
  async function preflight(run, recipe, deps) {
23489
24524
  let asked = null;
@@ -23494,38 +24529,85 @@ async function preflight(run, recipe, deps) {
23494
24529
  const needs = recipe.needs?.(run) ?? [];
23495
24530
  if (needs.length) {
23496
24531
  const said = await capabilities();
23497
- const missing = needs.filter((need) => {
24532
+ const flags = needs.flatMap((need) => {
24533
+ if (need in FLAGS) return missingFlag(said, need);
23498
24534
  const [command = "", flag = ""] = need.split(".");
23499
- return said?.commands?.[command]?.[flag] !== true;
24535
+ return said?.commands?.[command]?.[flag] === true ? [] : [`\`${command} --${flag.replaceAll("_", "-")}\``];
23500
24536
  });
23501
- if (missing.length) {
23502
- const flags = missing.map((need) => {
23503
- const [command = "", flag = ""] = need.split(".");
23504
- return `\`${command} --${flag.replaceAll("_", "-")}\``;
23505
- });
23506
- return refusal(clip(onRunnersMachine(`The agentpipe here has no ${flags.join(" or ")}, which this run needs: update agentpipe.`, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
24537
+ if (flags.length) {
24538
+ const said = flags.some((flag) => flag.startsWith("`close ")) ? "The agentpipe here can't close a pull request to start over: update agentpipe." : `The agentpipe here has no ${flags.join(" or ")}, which this run needs: update agentpipe.`;
24539
+ return refusal(clip$1(onRunnersMachine(said, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
23507
24540
  }
23508
24541
  }
24542
+ const settings = recipe.settings?.(run) ?? null;
24543
+ if (settings) {
24544
+ const refused = takesSettings(await capabilities(), settings, deps.runner ?? "this runner");
24545
+ if (refused) return refused;
24546
+ }
23509
24547
  const args = recipe.dryRun(run);
23510
24548
  if (args) {
23511
- const refused = await dryRun(run, args, recipe.sandboxed ?? null, deps);
24549
+ const refused = await dryRun(run, args, recipe.sandboxed ?? null, settings, deps);
23512
24550
  if (refused) return refused;
23513
24551
  }
23514
24552
  const tier = recipe.tier?.(run) ?? null;
23515
24553
  if (tier) {
23516
24554
  const said = await capabilities();
23517
24555
  if (!said?.tiers) return refusal(`agentpipe couldn't say which tiers ${run.workdir} has, so the review tier ${tier} can't be checked.`);
23518
- if (!said.tiers.includes(tier)) return refusal(clip(`agentpipe has no tier ${tier} in ${run.workdir} (it has ${said.tiers.join(", ") || "none"}).`, 1e3), "tier_missing");
24556
+ if (!said.tiers.includes(tier)) return refusal(clip$1(`agentpipe has no tier ${tier} in ${run.workdir} (it has ${said.tiers.join(", ") || "none"}).`, 1e3), "tier_missing");
23519
24557
  }
23520
24558
  return null;
23521
24559
  }
23522
- async function dryRun(run, args, only, deps) {
24560
+ /**
24561
+ * The commands a loop option's flag must be on (FLAGS: the advisor on `run`, `review --fix` and `address`; accepting
24562
+ * at merge on those and `merge`) that the folder's agentpipe doesn't list for it (`capabilities`' `advisor` and
24563
+ * `accept_decisions`, agentpipe 0.15.0), each as the command line it lacks; none when it has them all. Its own name
24564
+ * for the flag must be ours: a different one is none at all.
24565
+ */
24566
+ function missingFlag(said, need) {
24567
+ const { flag, commands } = FLAGS[need];
24568
+ const has = said?.[need];
24569
+ const listed = has && has.flag === flag && Array.isArray(has.commands) ? has.commands : [];
24570
+ return commands.filter((c) => !listed.includes(c)).map((c) => `\`${c} ${flag}\``);
24571
+ }
24572
+ /** Whether a list agentpipe said holds every one of `wanted`. */
24573
+ const holds = (said, wanted) => Array.isArray(said) && wanted.every((w) => said.includes(w));
24574
+ /**
24575
+ * Whether the folder's agentpipe takes the run's settings (`capabilities`' `caller_settings`, AGE-196): in the
24576
+ * variable the runner writes (a different name refuses the run: what agentpipe prints never chooses which variable
24577
+ * the runner writes), with both steps and both fields, on every command of the run that gets them. Null when it does.
24578
+ */
24579
+ function takesSettings(said, settings, runner) {
24580
+ const caller = said?.caller_settings;
24581
+ const variable = caller?.variable;
24582
+ if (caller && typeof variable === "string" && variable !== "AGENTPIPE_CALLER_SETTINGS") {
24583
+ const sentence = `The agentpipe on ${runner} takes a caller's settings in ${variable}, not ${CALLER_SETTINGS}, so this loop's sites can't reach it: install the agentpipe this monoban comes with`;
24584
+ return refusal(clip$1(onRunnersMachine(sentence, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
24585
+ }
24586
+ if (variable === "AGENTPIPE_CALLER_SETTINGS" && holds(caller?.steps, CALLER_STEPS) && holds(caller?.fields, CALLER_FIELDS) && holds(caller?.commands, settings.commands)) return null;
24587
+ return refusal(clip$1(onRunnersMachine(`The agentpipe on ${runner} is too old for this loop's sites: update it`, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
24588
+ }
24589
+ /**
24590
+ * The dry run's `resolve` and `arbitrate` against the run's settings (AGE-194): each shown, with the network on, the
24591
+ * run's sites, only the reading tools and WebFetch, and its reads held to the worktree. Null when they are.
24592
+ */
24593
+ function heldToSettings(steps, sent, runner) {
24594
+ const off = CALLER_STEPS.flatMap((name) => {
24595
+ const boundary = steps.find((s) => s.name === name)?.boundary;
24596
+ if (!boundary) return [`${name} isn't shown`];
24597
+ const differences = boundaryDifferences(boundary, sent.steps[name]);
24598
+ return differences.length ? [`${name}: ${differences.join(", ")}`] : [];
24599
+ });
24600
+ if (!off.length) return null;
24601
+ return refusal(clip$1(onRunnersMachine(`agentpipe's dry run doesn't hold its steps to this loop's sites (${off.join("; ")}), so the run didn't start: update the agentpipe on ${runner}`, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
24602
+ }
24603
+ async function dryRun(run, args, only, settings, deps) {
23523
24604
  let preview = null;
24605
+ const given = runEnv(run, settings, deps, args);
23524
24606
  const exit = await agentpipeCommand({
23525
24607
  command: deps.command,
23526
24608
  args,
23527
24609
  cwd: run.workdir,
23528
- env: deps.env,
24610
+ ...given,
23529
24611
  monobanBin: deps.monobanBin,
23530
24612
  map: (event) => {
23531
24613
  if (event.kind === "run.preview") preview = event.data ?? {};
@@ -23537,19 +24619,24 @@ async function dryRun(run, args, only, deps) {
23537
24619
  if (exit.code !== 0) {
23538
24620
  const refusals = (said?.refusals ?? []).filter((r) => typeof r.message === "string" && r.message);
23539
24621
  if (refusals.length) {
23540
- const known = refusals.map((r) => typeof r.check === "string" ? PREVIEW_CHECKS[r.check] : void 0);
23541
- return refusal(clip(`agentpipe won't start it: ${refusals.map((r) => r.message).join("; ")}`, 1e3), known.find(Boolean) ?? "agentpipe_refused");
24622
+ const code = refusals.map((r) => typeof r.check === "string" ? PREVIEW_CHECKS[r.check] : void 0).find(Boolean) ?? "agentpipe_refused";
24623
+ const theirs = refusals.filter((r) => !switchOff(r.check)).map((r) => r.message);
24624
+ const switches = refusals.flatMap((r) => switchOff(r.check)?.reason ?? []);
24625
+ const words = theirs.length ? `agentpipe won't start it: ${theirs.join("; ")}` : null;
24626
+ if (!switches.length) return refusal(clip$1(words ?? "", 1e3), code);
24627
+ return refusal(clip$1([...words ? [sentence(words)] : [], ...switches].join(" "), 1e3), code);
23542
24628
  }
23543
24629
  const last = exit.lastError ? `: ${exit.lastError}` : ".";
23544
- return refusal(clip(`agentpipe's dry run refused it (exit code ${exit.code ?? "none"})${last}`, 1e3), "agentpipe_refused");
24630
+ return refusal(clip$1(`agentpipe's dry run refused it (exit code ${exit.code ?? "none"})${last}`, 1e3), "agentpipe_refused");
23545
24631
  }
23546
24632
  if (!said) return refusal("agentpipe's dry run didn't say what the run would do, so its sandbox can't be checked.");
23547
24633
  const steps = said.steps ?? [];
23548
24634
  const unseen = (only ?? []).filter((name) => !steps.some((s) => s.name === name && s.boundary));
23549
24635
  if (unseen.length) return refusal(`agentpipe's dry run didn't show ${unseen.join(", ")}, so its sandbox can't be checked.`);
23550
24636
  const off = steps.filter((s) => s.boundary && s.boundary.sandbox !== true).filter((s) => !only || typeof s.name === "string" && only.includes(s.name)).map((s) => typeof s.name === "string" ? s.name : "a step");
23551
- if (off.length) return refusal(clip(onRunnersMachine(`agentpipe's sandbox is off for ${off.join(", ")}: a loop runs only with it on. Turn each step's sandbox on in ~/.agentpipe/config.toml, or in the repository's own file, which this prints`, "agentpipe config where"), 1e3), "sandbox_off");
24637
+ if (off.length) return refusal(clip$1(onRunnersMachine(`agentpipe's sandbox is off for ${off.join(", ")}: a loop runs only with it on. Turn each step's sandbox on in ~/.agentpipe/config.toml, or in the repository's own file, which this prints`, "agentpipe config where"), 1e3), "sandbox_off");
23552
24638
  if (said.commands?.sandbox !== true) return refusal(onRunnersMachine("agentpipe's sandbox is off for the repository's own commands: a loop runs only with it on. Set [commands] sandbox = true in ~/.agentpipe/config.toml, or in the repository's own file, which this prints", "agentpipe config where"), "sandbox_off");
24639
+ if (settings && given.callerSettings !== null) return heldToSettings(steps, settings.settings, deps.runner ?? "this runner");
23553
24640
  return null;
23554
24641
  }
23555
24642
  // src/runner/spend.ts
@@ -23598,6 +24685,19 @@ function spendInMemory(now = Date.now) {
23598
24685
  }
23599
24686
  };
23600
24687
  }
24688
+ // src/runner/poll.ts
24689
+ /**
24690
+ * What this runner says it can do beyond its recipes (contract's `RUNNER_FEATURES`, the names the API knows), when it
24691
+ * registers and at each check-in. A name is said only once this runner does it: a loop that needs one is handed only
24692
+ * to a runner that says it. `sites`: it hands a loop's network and sites to agentpipe (MON-250); `advisor`: a loop's
24693
+ * advisor and accepting at merge, as agentpipe's flags (MON-268); `start-over`: it closes a task's pull request through
24694
+ * agentpipe before it runs the task again (MON-292).
24695
+ */
24696
+ const SAYS = [
24697
+ "sites",
24698
+ "advisor",
24699
+ "start-over"
24700
+ ];
23601
24701
  const sleepFor = (ms, signal) => new Promise((resolve) => {
23602
24702
  if (signal.aborted) return resolve();
23603
24703
  const timer = setTimeout(resolve, ms);
@@ -23639,7 +24739,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
23639
24739
  return await unwrap(api.POST("/v1/runners", { body: {
23640
24740
  ...body,
23641
24741
  recipes,
23642
- features: [...RUNNER_FEATURES]
24742
+ features: [...SAYS]
23643
24743
  } }));
23644
24744
  } catch (err) {
23645
24745
  if (!(err instanceof ApiProblem && err.status === 400)) throw err;
@@ -23677,7 +24777,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
23677
24777
  return await heartbeat(api, runner.id, {
23678
24778
  recipes,
23679
24779
  free,
23680
- features: [...RUNNER_FEATURES],
24780
+ features: [...SAYS],
23681
24781
  loops
23682
24782
  });
23683
24783
  } catch (err) {
@@ -23894,7 +24994,10 @@ async function runRunner(ctx, settings, deps, options = {}) {
23894
24994
  const problem = await deps.workdirProblem(run.workdir, run.project);
23895
24995
  if (problem) return refuse("failed", problem, "folder_refused");
23896
24996
  if (loopRun && recipe && deps.agentpipe) {
23897
- const refused = await preflight(loopRun, recipe, deps.agentpipe);
24997
+ const refused = await preflight(loopRun, recipe, {
24998
+ ...deps.agentpipe,
24999
+ runner: runner.name
25000
+ });
23898
25001
  if (refused) return refuse("failed", refused.reason, refused.code);
23899
25002
  }
23900
25003
  const what = ref ?? `a ${run.recipe} run`;
@@ -23926,7 +25029,8 @@ async function runRunner(ctx, settings, deps, options = {}) {
23926
25029
  ...deps.agentpipe,
23927
25030
  recheck: () => recheck(run.id),
23928
25031
  mayMerge: () => mayMerge(run.id),
23929
- prReady: (url) => prReady(ref, url),
25032
+ prReady: (url) => prLink(ref, url, "open"),
25033
+ prClosed: (url) => prLink(ref, url, "closed"),
23930
25034
  onStep: (seconds) => {
23931
25035
  stepSeconds = seconds ?? settings.pollSeconds;
23932
25036
  self.pollSeconds = stepSeconds;
@@ -23996,9 +25100,11 @@ async function runRunner(ctx, settings, deps, options = {}) {
23996
25100
  /**
23997
25101
  * agentpipe said the run's pull request is ready (`ready_to_merge`, from `checks` or `feedback`): the task's link to
23998
25102
  * it says `open` (MON-284). It attached the link as a draft when it opened it, and again only once it's merged or
23999
- * closed. The URL and the state only: the link keeps the title agentpipe gave it. Throws when the board refused.
25103
+ * closed. Or it closed one to start the task over (`close.completed`, MON-292), which it doesn't attach again: the
25104
+ * link says `closed`, so the task's next start isn't refused as `pr_open`. The URL and the state only: the link
25105
+ * keeps the title agentpipe gave it. Throws when the board refused.
24000
25106
  */
24001
- async function prReady(ref, url) {
25107
+ async function prLink(ref, url, state) {
24002
25108
  if (!ref) return;
24003
25109
  const { key, number } = taskRefOf(ref);
24004
25110
  await unwrap(api.POST("/v1/projects/{key}/tasks/{number}/links", {
@@ -24008,7 +25114,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
24008
25114
  } },
24009
25115
  body: {
24010
25116
  url,
24011
- state: "open"
25117
+ state
24012
25118
  }
24013
25119
  }));
24014
25120
  }
@@ -24601,7 +25707,7 @@ function describe(ctx, { state, running }, board, stuck, now) {
24601
25707
  const seenAgo = `checked in ${since(board.lastSeenAt, now)} ago (every ${board.pollSeconds}s)`;
24602
25708
  row("board", `${board.online ? "online" : "offline"} · ${seenAgo}`);
24603
25709
  } else if (!state.runnerId) row("board", "not on the board yet: it's starting");
24604
- if (state.version !== "1.15.0") {
25710
+ if (state.version !== "1.17.0") {
24605
25711
  const again = state.background ? "`monoban runner restart`" : "start it again in its terminal";
24606
25712
  row("update", `it runs monoban ${state.version}, this is ${VERSION}: ${again}`);
24607
25713
  }
@@ -25060,7 +26166,7 @@ async function checks(ctx, deps = {}) {
25060
26166
  const found = [];
25061
26167
  const latest = await (deps.latest ?? latestVersion)(ctx);
25062
26168
  const upgrade = UPGRADE[thisInstall()].command;
25063
- found.push(latest && newer(latest, "1.15.0") ? {
26169
+ found.push(latest && newer(latest, "1.17.0") ? {
25064
26170
  name: "monoban",
25065
26171
  status: "warn",
25066
26172
  detail: `${VERSION}; ${latest} is out`,
@@ -25972,7 +27078,13 @@ machine allows a run to turn it off. Settings can also go in runner.json in the
25972
27078
  {"pollSeconds": 60, "allow": ["/Users/me/code"], "confirm": false, "agents": ["claude"],
25973
27079
  "adapters": {"claude": {"command": "claude", "args": []}, "codex": {"allowFullAccess": false}},
25974
27080
  "loops": {"enabled": true, "merge": true, "maxUsdPerDay": 100}}. Agent loops (made in the browser) run here
25975
- too when agentpipe can run them: --no-loops, or "enabled": false, says no; "merge": false never merges here.`).action(async (options) => runner(await ctx(), options));
27081
+ too when agentpipe can run them: --no-loops, or "enabled": false, says no; "merge": false never merges here.
27082
+ A loop with its network on lets its runs' resolve and arbitrate steps (which answer questions and settle
27083
+ disagreements) read pages from the loop's sites, nothing else: they gain WebFetch alone and read only the
27084
+ repository. The runner hands the sites to agentpipe in AGENTPIPE_CALLER_SETTINGS, on the commands that build
27085
+ those steps; it sets that variable itself, and one in its own environment never reaches agentpipe. This machine
27086
+ permits only the sites listed in permitted_sites under [callers] in ~/.agentpipe/config.toml (empty as agentpipe
27087
+ ships), and a run with any other site doesn't start.`).action(async (options) => runner(await ctx(), options));
25976
27088
  runnerCommand.command("status").description("This machine's runners: running or not, the run going on, what the board sees, why one stopped").option("--name <name>", "only this runner").addOption(json()).action(async (options) => runnerStatus(await ctx(), options));
25977
27089
  runnerCommand.command("stop").description("Stop this machine's runners (a run going on is cancelled; asks first)").option("--name <name>", "only this runner").option("--wait", "let the run going on finish first, then stop").option("-y, --yes", "don't ask before cancelling a run").action(async (options) => runnerStop(await ctx(), options));
25978
27090
  runnerCommand.command("restart").description("Stop the runner and start it again in the background, with the same flags (after an upgrade)").option("--name <name>", "which runner, when there are several").option("-y, --yes", "don't ask before cancelling a run").action(async (options) => runnerRestart(await ctx(), options));