monoban 1.15.0 → 1.16.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 +1285 -215
  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`
@@ -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,7 @@ const PROBLEM_CODES = [
6628
6867
  "too_many_loops",
6629
6868
  "no_runner",
6630
6869
  "open_tasks_limit",
6870
+ "runner_outdated",
6631
6871
  "used_by_loop",
6632
6872
  "place_gone",
6633
6873
  "too_late"
@@ -7226,6 +7466,23 @@ const loopCommon = {
7226
7466
  /** Runs in a row that failed, since it was last resumed, before it pauses itself. */
7227
7467
  pauseAfter: wholeBetween(LOOP_LIMITS.pauseAfter)
7228
7468
  };
7469
+ /** A list of sites as JSON Schema can say it: the rule itself is `SitesSchema`'s. */
7470
+ const sitesList = () => array(string().meta({
7471
+ maxLength: SITE_RULE.host,
7472
+ pattern: "^[A-Za-z0-9.-]+$"
7473
+ }));
7474
+ /**
7475
+ * A deliver loop's sites (loops.ts `sitesProblem`, `sitesOf`): a refused entry's message is on its index, the limits'
7476
+ * on the list. Stored folded, unique and sorted.
7477
+ */
7478
+ const SitesSchema = sitesList().superRefine((entries, ctx) => {
7479
+ const problem = sitesProblem(entries);
7480
+ if (problem) ctx.addIssue({
7481
+ code: "custom",
7482
+ path: problem.index === null ? [] : [problem.index],
7483
+ message: problem.message
7484
+ });
7485
+ }).overwrite(sitesOf).meta({ maxItems: LOOP_LIMITS.sites });
7229
7486
  /** ASK_MINUTES, one literal each (`z.literal` of a list keeps only the first in the OpenAPI document). */
7230
7487
  const ASK_MINUTES_SCHEMA = union([
7231
7488
  literal(0),
@@ -7248,7 +7505,31 @@ const deliverFields = {
7248
7505
  /** The agentpipe tier its review step runs on (`--tier`); null: agentpipe's own. */
7249
7506
  reviewTier: string().regex(TIER_NAME, "A tier's name, like light").nullable(),
7250
7507
  /** 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
7508
+ askMinutes: ASK_MINUTES_SCHEMA,
7509
+ /**
7510
+ * Its runs' `resolve` and `arbitrate` steps may fetch pages from `sites`, and only those (agentpipe's
7511
+ * `allow_network`, MON-248; loops.ts `SITE_RULE`). On needs a site. Their reads narrow to the repository, so a
7512
+ * question whose answer is only in a dependency installed outside it is escalated to you.
7513
+ */
7514
+ network: boolean(),
7515
+ /**
7516
+ * The sites they may read (agentpipe's `allowed_domains`): exact host names, kept folded to lower case, each once,
7517
+ * sorted. Only with the network on; the runner's machine must also permit each one in its own agentpipe config.
7518
+ */
7519
+ sites: SitesSchema,
7520
+ /**
7521
+ * agentpipe's `arbitrate` answers every question a run raised that nobody answered: from research when it can, on
7522
+ * its best judgement when it can't, saying why (agentpipe's `--advisor`, AGE-204). Off: it answers only what a
7523
+ * source supports, and the run stops for you on the rest. The runner's machine must allow it in its own agentpipe
7524
+ * config.
7525
+ */
7526
+ advisor: boolean(),
7527
+ /**
7528
+ * The decisions its runs made on their own are accepted at merge, without you (agentpipe's `--accept-decisions`,
7529
+ * AGE-204); some still wait for you (one hard to reverse, a judgement whose citation failed). Only with `merge` on.
7530
+ * The runner's machine must allow it in its own agentpipe config.
7531
+ */
7532
+ acceptAtMerge: boolean()
7252
7533
  };
7253
7534
  const scavengeFields = {
7254
7535
  ...loopCommon,
@@ -7275,10 +7556,20 @@ const DeliverOptionsSchema = strictObject({
7275
7556
  maxOpen: deliverFields.maxOpen.default(LOOP_DEFAULTS.deliverMaxOpen),
7276
7557
  checksMinutes: deliverFields.checksMinutes.default(LOOP_DEFAULTS.checksMinutes),
7277
7558
  reviewTier: deliverFields.reviewTier.default(LOOP_DEFAULTS.reviewTier),
7278
- askMinutes: deliverFields.askMinutes.default(LOOP_DEFAULTS.askMinutes)
7559
+ askMinutes: deliverFields.askMinutes.default(LOOP_DEFAULTS.askMinutes),
7560
+ network: deliverFields.network.default(LOOP_DEFAULTS.network),
7561
+ sites: deliverFields.sites.default([]),
7562
+ advisor: deliverFields.advisor.default(LOOP_DEFAULTS.advisor),
7563
+ acceptAtMerge: deliverFields.acceptAtMerge.default(LOOP_DEFAULTS.acceptAtMerge)
7279
7564
  }).refine(budgetFits, {
7280
7565
  message: BUDGET_FITS,
7281
7566
  path: ["budgetUsd"]
7567
+ }).superRefine((options, ctx) => {
7568
+ for (const problem of [networkProblem(options), acceptAtMergeProblem(options)]) if (problem) ctx.addIssue({
7569
+ code: "custom",
7570
+ path: [problem.path],
7571
+ message: problem.message
7572
+ });
7282
7573
  }).meta({ id: "DeliverOptions" });
7283
7574
  const ScavengeOptionsSchema = strictObject({
7284
7575
  ...scavengeFields,
@@ -7331,14 +7622,30 @@ const RunStepSchema = object({
7331
7622
  * its column and tag had, and for a run that continues a pull request, the step it starts at, the pull request and
7332
7623
  * the run that opened it. Only the server writes it.
7333
7624
  */
7625
+ const DecisionIdSchema = string().regex(DECISION_ID, "A decision id is 12 hex characters");
7334
7626
  /**
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.
7627
+ * The provisional decisions a person accepted for a continued run's merge: each agentpipe's decision id and its run
7628
+ * (`agentpipe ratify` takes both), and the pull request's head commit they read them at. A plain id (the body before
7629
+ * MON-302, taken for one more release) is a decision of the run that opened the pull request.
7337
7630
  */
7338
7631
  const DecisionsAcceptSchema = strictObject({
7339
- decisions: array(string().regex(/^[0-9a-f]{12}$/, "A decision id is 12 hex characters")).min(1).max(20),
7632
+ decisions: array(union([DecisionIdSchema, strictObject({
7633
+ id: DecisionIdSchema,
7634
+ run: string().regex(AGENTPIPE_RUN, "agentpipe's run id, as the decision names it")
7635
+ }).meta({ id: "AcceptedDecision" })])).min(1).max(20),
7340
7636
  headSha: string().regex(/^[0-9a-f]{40}$/, "The full commit the decisions were read at")
7341
7637
  }).meta({ id: "DecisionsAccept" });
7638
+ /**
7639
+ * The pull request a start-over closes before it runs the task again from the first step (MON-292), and agentpipe's
7640
+ * run that opened it (`agentpipe close --expect-run`; its branch is `agentpipe/<id>`), null when that run never said
7641
+ * it. Not the run's own pull request: the run opens a new one.
7642
+ */
7643
+ const LoopRunClosesSchema = object({
7644
+ prUrl: string(),
7645
+ /** The monoban run that opened it. */
7646
+ continues: IdSchema,
7647
+ externalId: string().nullable()
7648
+ }).meta({ id: "LoopRunCloses" });
7342
7649
  const LoopRunPlanSchema = object({
7343
7650
  /** The loop's options when the run was made (its recipe's: DeliverOptionsSet or ScavengeOptionsSet). */
7344
7651
  options: union([DeliverOptionsSetSchema, ScavengeOptionsSetSchema]),
@@ -7362,6 +7669,11 @@ const LoopRunPlanSchema = object({
7362
7669
  /** A run continued from merge after a person accepted the earlier run's provisional decisions; else null. */
7363
7670
  accept: DecisionsAcceptSchema.nullable().optional(),
7364
7671
  /**
7672
+ * A start-over (`{task, startOver}`, MON-292): the pull request it closes through agentpipe first, then a fresh run
7673
+ * of the task with its own pull request. Never in `prUrl` and `externalId`, which are the run's own. Else null.
7674
+ */
7675
+ closes: LoopRunClosesSchema.nullable().optional(),
7676
+ /**
7365
7677
  * A person started it on a task they named (`{task}`, `{task, from}`, an accept: MON-273): a one-off, which may
7366
7678
  * start on a paused loop (from a browser) and never counts toward the loop's `perDay` or `pauseAfter`. False for
7367
7679
  * Run now (`{}`) and for a run its runner's check-in started.
@@ -7386,6 +7698,13 @@ const TaskRunSchema = object({
7386
7698
  mayMerge: boolean().nullable(),
7387
7699
  /** Why it may not (`mergeOff`); null when it may, or isn't a deliver loop's. */
7388
7700
  mergeHold: _enum(MERGE_HOLDS).nullable(),
7701
+ /**
7702
+ * 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
7703
+ * 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,
7704
+ * 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
7705
+ * deliver loop's, or whose loop or task is gone.
7706
+ */
7707
+ taskQueued: boolean().nullable(),
7389
7708
  runner: object({
7390
7709
  /** Null once the runner is gone. */
7391
7710
  id: IdSchema.nullable(),
@@ -7565,7 +7884,10 @@ object({
7565
7884
  /** At least one option, or the patch would change nothing (the refine, for JSON Schema: minProperties). */
7566
7885
  const someOption = (o) => Object.keys(o).length > 0;
7567
7886
  const SOME_OPTION = "Send at least one option to change";
7568
- const DeliverOptionsPatchSchema = strictObject(deliverFields).partial().refine(someOption, SOME_OPTION).meta({
7887
+ const DeliverOptionsPatchSchema = strictObject({
7888
+ ...deliverFields,
7889
+ sites: sitesList().meta({ maxItems: LOOP_LIMITS.sites })
7890
+ }).partial().refine(someOption, SOME_OPTION).meta({
7569
7891
  id: "DeliverOptionsPatch",
7570
7892
  minProperties: 1
7571
7893
  });
@@ -7627,11 +7949,15 @@ const LoopBase = object({
7627
7949
  /** Null: on. Else why it's paused. */
7628
7950
  paused: _enum(PAUSE_REASONS).nullable(),
7629
7951
  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. */
7952
+ /**
7953
+ * Its run going now (queued or running): the step it's in (null before the first) and its task, if it has one, and
7954
+ * while it waits for your answer, until when (worked out as the run's `waitingUntil` is, MON-295).
7955
+ */
7631
7956
  going: object({
7632
7957
  runId: IdSchema,
7633
7958
  step: string().nullable(),
7634
- ref: string().nullable()
7959
+ ref: string().nullable(),
7960
+ waitingUntil: Timestamp.nullable()
7635
7961
  }).nullable().meta({ id: "LoopGoing" }),
7636
7962
  /** Its runs started in the last 24 hours, and what they cost. */
7637
7963
  last24h: object({
@@ -7676,6 +8002,12 @@ object({
7676
8002
  }).meta({ id: "NeedsYouRun" }),
7677
8003
  /** Its pull request; null for `failed`. */
7678
8004
  prUrl: string().nullable(),
8005
+ /**
8006
+ * Its task's link to that pull request, as last heard (agentpipe's `ledger sync` refreshes it): `closed` is the
8007
+ * `closed` kind, and a `merged` or `closed` one can't be continued (MON-291). Null when there's no link, no state, or
8008
+ * no pull request.
8009
+ */
8010
+ prState: _enum(LINK_STATES).nullable(),
7679
8011
  /** Where that run stopped, and the step to continue the pull request from that fits it (contract's `whereItStopped`). */
7680
8012
  stopped: object({
7681
8013
  at: _enum(STOPPED_AT).nullable(),
@@ -7687,20 +8019,77 @@ object({
7687
8019
  hold: _enum(MERGE_HOLDS).nullable(),
7688
8020
  /**
7689
8021
  * `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.
8022
+ * with the run that reported it and agentpipe's run that made it (what accepting them names). Null for the other
8023
+ * kinds.
7691
8024
  */
7692
8025
  pending: object({
7693
8026
  headSha: string(),
7694
8027
  decisions: array(object({
7695
8028
  id: string(),
7696
8029
  run: IdSchema,
8030
+ /**
8031
+ * agentpipe's run that made it (agentpipe 0.15.0), which accepting it names (`{ id, run }`, MON-302).
8032
+ * Null when the runner didn't say (an older runner or agentpipe): the run that opened the pull request,
8033
+ * and accepting it sends its id alone.
8034
+ */
8035
+ agentpipeRun: string().nullable(),
7697
8036
  questionId: string(),
7698
8037
  category: string(),
7699
8038
  question: string().nullable(),
7700
- answer: string()
7701
- }).meta({ id: "PendingDecision" })).max(20)
7702
- }).nullable().meta({ id: "PendingDecisions" })
8039
+ answer: string(),
8040
+ /**
8041
+ * How it was reached (agentpipe's `method`, MON-268): `judgement` is best judgement, any other cites a
8042
+ * source. Null when the runner didn't say.
8043
+ */
8044
+ method: string().nullable(),
8045
+ /** A best judgement whose cited source couldn't be confirmed; null when the runner didn't say. */
8046
+ unverified: boolean().nullable(),
8047
+ /** The reason the agent gave for a best judgement; null when none. */
8048
+ rationale: string().nullable(),
8049
+ /**
8050
+ * Why it waits for you on a loop that accepts decisions at merge (agentpipe's `waits_because`:
8051
+ * `unverified`, `hard`, `not_announced`, or a later word); null on a loop that doesn't accept them.
8052
+ */
8053
+ waitsBecause: string().nullable()
8054
+ }).meta({ id: "PendingDecision" })).max(20),
8055
+ /** How many decisions wait in all: more than `decisions` when one accept can't take them all (MON-300). */
8056
+ total: number$1().int().nonnegative(),
8057
+ /**
8058
+ * The decisions later runs on the pull request replaced (AGE-221): shown, never offered, never counted.
8059
+ */
8060
+ replaced: array(object({
8061
+ id: string(),
8062
+ agentpipeRun: string().nullable(),
8063
+ questionId: string(),
8064
+ category: string(),
8065
+ replacedBy: string(),
8066
+ replacedByRun: string().nullable()
8067
+ }).meta({ id: "ReplacedDecision" })).max(20)
8068
+ }).nullable().meta({ id: "PendingDecisions" }),
8069
+ /**
8070
+ * It carries the loop's tag again, in the loop's column, but its pull request may still be open, so the loop
8071
+ * doesn't take it (MON-291): it takes it once the pull request is closed. False for the other rows.
8072
+ */
8073
+ retagged: boolean()
7703
8074
  }).meta({ id: "NeedsYou" });
8075
+ object({
8076
+ project: object({
8077
+ key: string(),
8078
+ name: string()
8079
+ }).meta({ id: "NeedsYouProject" }),
8080
+ loop: object({
8081
+ id: IdSchema,
8082
+ name: string()
8083
+ }).meta({ id: "NeedsYouLoopRef" }),
8084
+ /** 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. */
8085
+ own: boolean(),
8086
+ /** Its tasks' rows, newest first. */
8087
+ tasks: array(object({
8088
+ ref: string(),
8089
+ kind: _enum(TASK_NEEDS_YOU_KINDS)
8090
+ }).meta({ id: "NeedsYouTask" })),
8091
+ count: number$1().int().positive()
8092
+ }).meta({ id: "NeedsYouLoop" });
7704
8093
  const LoopCreateBase = {
7705
8094
  name: loopName,
7706
8095
  runnerId: IdSchema,
@@ -7737,18 +8126,35 @@ strictObject({
7737
8126
  * With `from: "merge"`, from the browser only: the provisional decisions the last run reported, accepted. The run
7738
8127
  * ratifies them (`agentpipe ratify`) before it merges.
7739
8128
  */
7740
- accept: DecisionsAcceptSchema.optional()
8129
+ accept: DecisionsAcceptSchema.optional(),
8130
+ /**
8131
+ * With `task`, from a browser only (MON-292): start it over. Its pull request from this loop, which may still be
8132
+ * open, is closed through agentpipe first (a comment says why, and its branch is deleted), then a new run does the
8133
+ * task from the first step. Never with `from`.
8134
+ */
8135
+ startOver: boolean().optional()
7741
8136
  }).refine((body) => body.from === void 0 || body.task !== void 0, {
7742
8137
  message: "Name the task whose pull request to continue",
7743
8138
  path: ["from"]
7744
8139
  }).refine((body) => body.accept === void 0 || body.from === "merge", {
7745
8140
  message: "Decisions are accepted for a merge: continue from merge",
7746
8141
  path: ["accept"]
8142
+ }).refine((body) => body.startOver === void 0 || body.task !== void 0, {
8143
+ message: "Name the task to start over",
8144
+ path: ["startOver"]
8145
+ }).refine((body) => !body.startOver || body.from === void 0, {
8146
+ message: "A start-over runs the task from the start: leave out from",
8147
+ path: ["startOver"]
7747
8148
  }).meta({
7748
8149
  id: "LoopRunCreate",
7749
8150
  dependentRequired: {
7750
8151
  from: ["task"],
7751
- accept: ["from"]
8152
+ accept: ["from"],
8153
+ startOver: ["task"]
8154
+ },
8155
+ not: {
8156
+ required: ["startOver", "from"],
8157
+ properties: { startOver: { const: true } }
7752
8158
  }
7753
8159
  });
7754
8160
  PageQuerySchema.extend({
@@ -8484,7 +8890,7 @@ function archivedByTime(task, archiveAfterDays, now = Date.now()) {
8484
8890
  }
8485
8891
  // src/version.ts
8486
8892
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
8487
- const VERSION = "1.15.0";
8893
+ const VERSION = "1.16.0";
8488
8894
  /** Sent as X-Monoban-Client, and shown in Settings › CLI sessions. */
8489
8895
  const CLIENT = `cli/${VERSION}`;
8490
8896
  // src/api.ts
@@ -12031,8 +12437,8 @@ const RELEASES = `https://github.com/thiagodmont/homebrew-tap/releases`;
12031
12437
  * agentpipe comes with a new monoban: change these three lines (from the release's checksums.txt) and release.
12032
12438
  */
12033
12439
  const AGENTPIPE = {
12034
- version: "0.13.0",
12035
- wheelSha256: "4f4be6459f8beeb13270c746497438177e6040656aaf008c80767d0d74fde19b",
12440
+ version: "0.15.0",
12441
+ wheelSha256: "bb184e5ca93798d34e78a264587468ba33420f9f774e3cfc669d05c49bdbc8ea",
12036
12442
  requirementsSha256: "41a8d073b0087efb80efafeb6a2b4750340d0f64920159cd4c723ed9167d0a98"
12037
12443
  };
12038
12444
  /**
@@ -12154,7 +12560,7 @@ async function latestVersion(ctx) {
12154
12560
  async function upgrade(ctx, options, kind = thisInstall()) {
12155
12561
  const latest = await latestVersion(ctx);
12156
12562
  const { how, command } = UPGRADE[kind];
12157
- const outdated = latest !== null && newer(latest, "1.15.0");
12563
+ const outdated = latest !== null && newer(latest, "1.16.0");
12158
12564
  if (options.json) {
12159
12565
  ctx.out(JSON.stringify({
12160
12566
  version: VERSION,
@@ -16912,11 +17318,14 @@ var en_US_default = {
16912
17318
  "board": "board",
16913
17319
  "notes": "notes.md",
16914
17320
  "loops": "loops",
17321
+ "loopsNeedsYou": "loops · {count, plural, one {# needs you} other {# need you}}",
16915
17322
  "archive": "archive"
16916
17323
  },
16917
17324
  status: {
16918
17325
  "notes": "notes.md",
16919
17326
  "loops": "loops · {count}",
17327
+ "needsYou": "{count, plural, one {# thing needs you in its loops} other {# things need you in its loops}}",
17328
+ "needsYouTitle": "Open the loops tab",
16920
17329
  "archiveTask": "{ref} · archive",
16921
17330
  "archive": "archive · {count}",
16922
17331
  "task": "{ref} · {column}",
@@ -16924,7 +17333,9 @@ var en_US_default = {
16924
17333
  "noColumns": "no columns"
16925
17334
  },
16926
17335
  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 {}}",
17336
+ "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 {}}",
17337
+ "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}}",
17338
+ "needsTitle": "Go to it in its loop",
16928
17339
  "provisional": "not synced: the number may change when it's saved",
16929
17340
  "wontDo": "won't do",
16930
17341
  "archived": "archived",
@@ -17234,6 +17645,11 @@ var en_US_default = {
17234
17645
  "help": "Answer the question task's run asks",
17235
17646
  "keywords": "answer question run agent loop decide reply"
17236
17647
  },
17648
+ "needsYou": {
17649
+ "label": "Go to what {ref} needs in its loop",
17650
+ "help": "Go to what the task needs in its loop",
17651
+ "keywords": "loop needs you decision review pull request closed failed run row"
17652
+ },
17237
17653
  "undo": { "label": "Undo" }
17238
17654
  },
17239
17655
  move: {
@@ -17471,6 +17887,16 @@ var en_US_default = {
17471
17887
  "label": "See {ref}'s run",
17472
17888
  "help": "See the run that failed",
17473
17889
  "keywords": "run failed why see show"
17890
+ },
17891
+ "runAgain": {
17892
+ "label": "Run {ref} again from the start",
17893
+ "help": "Run a loop's task again from the start",
17894
+ "keywords": "retry rerun again restart start over"
17895
+ },
17896
+ "startOver": {
17897
+ "label": "Start {ref} over",
17898
+ "help": "Close a loop task's pull request and run the task again from the start",
17899
+ "keywords": "start over restart redo discard close pull request again"
17474
17900
  }
17475
17901
  },
17476
17902
  archive: {
@@ -17532,6 +17958,7 @@ var en_US_default = {
17532
17958
  loading: "loading loops…",
17533
17959
  loadFailed: "Couldn't load the loops.",
17534
17960
  tryAgain: "Try again",
17961
+ announce: "{name}: {state}",
17535
17962
  heading: {
17536
17963
  "name": "loop",
17537
17964
  "type": "type",
@@ -17668,6 +18095,14 @@ var en_US_default = {
17668
18095
  "cancel": "Cancel",
17669
18096
  "couldnt": "Couldn't delete the loop."
17670
18097
  },
18098
+ startOver: {
18099
+ "title": "Start {ref} over?",
18100
+ "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}.",
18101
+ "confirm": "Close it and start over",
18102
+ "starting": "Starting over…",
18103
+ "cancel": "Cancel",
18104
+ "couldnt": "Couldn't start it over."
18105
+ },
17671
18106
  controls: {
17672
18107
  "new": "New loop",
17673
18108
  "runNow": "Run now",
@@ -17686,13 +18121,19 @@ var en_US_default = {
17686
18121
  "deleted": "Deleted {name}.",
17687
18122
  "failed": "That didn't work: try again.",
17688
18123
  "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."
18124
+ "accepted": "{ref} merges at its runner's next check-in, with {count, plural, one {the decision} other {the # decisions}} accepted.",
18125
+ "runAgain": "A run starts {ref} again from the first step at its runner's next check-in.",
18126
+ "startOver": "A run closes {number, select, none {its pull request} other {#{number}}} and starts {ref} over at its runner's next check-in."
17690
18127
  },
17691
18128
  decisions: {
17692
18129
  "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.",
17693
18130
  "answer": "Its answer:",
17694
18131
  "accept": "{count, plural, one {Accept it and merge} other {Accept all # and merge}}",
18132
+ "acceptSome": "Accept {shown} of {total} and merge",
18133
+ "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
18134
  "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.",
18135
+ "tick": "Accept this one",
18136
+ "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
18137
  "accepting": "It accepts {count, plural, one {# decision} other {# decisions}} read at {commit}, then merges."
17697
18138
  },
17698
18139
  continueStep: {
@@ -17728,10 +18169,14 @@ var en_US_default = {
17728
18169
  "decision": "{ref}'s merge waits on {count, plural, one {a decision} other {# decisions}} only you can accept.",
17729
18170
  "review": "{ref}'s pull request waits for you: {reason}",
17730
18171
  "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.",
18172
+ "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.",
18173
+ "retagged": "It has the loop's tag again: the loop takes it once {number, select, none {its pull request} other {#{number}}} is closed.",
17733
18174
  "openPr": "Open the pull request",
17734
18175
  "seeRun": "See the run",
18176
+ "runAgain": "Run again from the start",
18177
+ "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.",
18178
+ "runAgainTag": "It takes #{tag} off the task, as when the loop takes it.",
18179
+ "startOver": "Start over",
17735
18180
  "said": "What the run said: {reason}",
17736
18181
  "otherSteps": "Or continue it from another step:",
17737
18182
  "row": "{state} · {count, plural, one {# needs you} other {# need you}}: {first}",
@@ -17741,6 +18186,7 @@ var en_US_default = {
17741
18186
  "runnerOutdated": "its runner can't run it",
17742
18187
  "decision": "a decision on {ref}",
17743
18188
  "review": "{ref}'s pull request",
18189
+ "closed": "{ref}'s closed pull request",
17744
18190
  "failed": "{ref} failed"
17745
18191
  }
17746
18192
  }
@@ -17981,6 +18427,7 @@ var en_US_default = {
17981
18427
  too_many_loops: "This project has as many loops as it may have.",
17982
18428
  no_runner: "This loop has no runner: choose one for it first.",
17983
18429
  open_tasks_limit: "This loop has as many open tasks as it may: it files more once you close some.",
18430
+ runner_outdated: "This loop's runner can't start a task over: update monoban on its machine, then restart the runner.",
17984
18431
  used_by_loop: "A loop uses it: change or delete the loop first.",
17985
18432
  place_gone: "This loop's column or tag was deleted: edit the loop to choose another.",
17986
18433
  unreachable: "Couldn't reach monoban. Try again.",
@@ -18117,6 +18564,7 @@ var en_US_default = {
18117
18564
  howRunsWork: "How runs work ↗",
18118
18565
  loading: "loading…",
18119
18566
  tryAgain: "Try again",
18567
+ stale: "This may be out of date: monoban didn't answer.",
18120
18568
  agentDefault: "{agent}'s default",
18121
18569
  dialog: {
18122
18570
  "title": "Run {label} with an agent",
@@ -18243,10 +18691,21 @@ var en_US_default = {
18243
18691
  "failed": "Couldn't send it."
18244
18692
  },
18245
18693
  "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>.",
18694
+ "label": "{count, plural, =0 {No decisions merged without your confirmation} one {# decision merged without your confirmation} other {# decisions merged without your confirmation}}",
18695
+ "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>.",
18696
+ "bySetting": "accepted by the repository's setting",
18697
+ "byLoop": "accepted by this loop",
18698
+ "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.",
18699
+ "loop": "This loop accepts decisions at merge: its runs said so on the pull request before it merged.",
18248
18700
  "answer": "Its answer:",
18249
- "authority": "only you could decide this, and nobody read it"
18701
+ "authority": "only you could decide this, and nobody read it",
18702
+ "disagree": "Disagree with one? Revert the pull request, then reopen the task with your answer."
18703
+ },
18704
+ "decision": {
18705
+ "how": "{how, select, source {from a source} judgement {best judgement} unverified {best judgement, its source wasn't verified} other {}}",
18706
+ "why": "Why: {reason}",
18707
+ "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}}",
18708
+ "replaced": "Replaced by a later run's decision, {id}"
18250
18709
  },
18251
18710
  "setAside": {
18252
18711
  "label": "{count, plural, one {# review comment was set aside} other {# review comments were set aside}}",
@@ -18255,6 +18714,21 @@ var en_US_default = {
18255
18714
  "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
18715
  }
18257
18716
  },
18717
+ failure: {
18718
+ "inStep": "It failed in {step}.",
18719
+ "bare": "It failed.",
18720
+ "task": {
18721
+ "reason": "{ref}'s run failed: {reason}",
18722
+ "inStep": "{ref}'s run failed in {step}.",
18723
+ "bare": "{ref}'s run failed."
18724
+ },
18725
+ "fate": {
18726
+ "queued": "{ref} is in the loop's queue: it takes it again at a later run.",
18727
+ "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.",
18728
+ "once": "The loop won't take {ref} again on its own: it tries each task once. Run it again from the start."
18729
+ },
18730
+ "said": "What {agent} said"
18731
+ },
18258
18732
  runners: {
18259
18733
  "title": "Runners",
18260
18734
  "about": "Machines that run coding agents on your tasks (Run with an agent, <key>R</key> on a task). A runner is <cmd>monoban runner</cmd> running there, in the background; runs wait until it is.",
@@ -18296,6 +18770,12 @@ var en_US_default = {
18296
18770
  "agent_signed_out": "The agent on this runner isn't signed in: sign in there.",
18297
18771
  "cannot_push": "GitHub won't let this runner push to the repository: check its gh sign-in there (gh auth status).",
18298
18772
  "commands_unverified": "None of the repository's test, lint or type-check commands ran cleanly, so agentpipe can't check a change: fix one.",
18773
+ "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.",
18774
+ "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.",
18775
+ "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.",
18776
+ "sites_invalid": "agentpipe on this runner refused the loop's sites as monoban sent them: update monoban and agentpipe there.",
18777
+ "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.",
18778
+ "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.",
18299
18779
  "budget_spent": "The run spent its budget before it finished: raise the loop's budget for the next one.",
18300
18780
  "decisions_unratified": "Its merge waits for you to accept decisions the agent made on its own.",
18301
18781
  "checks_pending": "Its checks were still running, so it wasn't merged: continue it from checks once they pass.",
@@ -18437,7 +18917,7 @@ var en_US_default = {
18437
18917
  },
18438
18918
  "waitingForYou": {
18439
18919
  "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}}"
18920
+ "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
18921
  },
18442
18922
  "dailyLimit": "{count, plural, one {# run} other {# runs}} in 24 hours: its daily limit, until {time}",
18443
18923
  "budget": "{spent} of {limit} spent in 24 hours: its daily budget",
@@ -18886,6 +19366,8 @@ var en_US_default = {
18886
19366
  planAllToday: "plan all for today",
18887
19367
  nothingPlanned: "Nothing planned.",
18888
19368
  group: "{late, select, yes {{project}, late} other {{project}, {day}}}",
19369
+ needsYou: "{project}: {count, plural, one {# thing needs you in its loops} other {# things need you in its loops}}",
19370
+ needsYouLabel: "What needs you in your loops",
18889
19371
  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
19372
  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
19373
  showADay: "Show a day",
@@ -19352,6 +19834,14 @@ function describeLoopState({ state, nextAt, why }, words, now = Date.now()) {
19352
19834
  case "next": return t("loop.state.next", { time: clock(nextAt ? Date.parse(nextAt) : now, now, locale) });
19353
19835
  }
19354
19836
  }
19837
+ /**
19838
+ * 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
19839
+ * words, `run.status.waiting`) while its run waits for your answer (contract's `loopWaits`, MON-295), else its state's
19840
+ * (`describeLoopState`).
19841
+ */
19842
+ function describeLoop(loop, words, now = Date.now()) {
19843
+ return loopWaits(loop, now) ? words.t("run.status.waiting") : describeLoopState(loop.state, words, now);
19844
+ }
19355
19845
  /** The causes that keep a runner from running a loop at all (`runnerOutdated`), each with its own words. */
19356
19846
  const OUTDATED = [
19357
19847
  "monoban_outdated",
@@ -19541,9 +20031,12 @@ async function loopsOf(api, key) {
19541
20031
  }
19542
20032
  /** Where a project's loops are made, changed and resumed (a single loop has no page of its own). */
19543
20033
  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. */
20034
+ /**
20035
+ * What it's doing, in a few words: its state ("waiting for your answer" while its run waits for you, MON-295), and
20036
+ * while a run goes, the step and task.
20037
+ */
19545
20038
  function loopDoing(loop, now = Date.now()) {
19546
- const state = describeLoopState(loop.state, ENGLISH, now);
20039
+ const state = describeLoop(loop, ENGLISH, now);
19547
20040
  const going = loop.going && [loop.going.step, loop.going.ref].filter(Boolean).join(" on ");
19548
20041
  return going ? `${state}: ${going}` : state;
19549
20042
  }
@@ -19885,6 +20378,45 @@ function atLeast(a, b) {
19885
20378
  }
19886
20379
  return true;
19887
20380
  }
20381
+ // src/runner/redact.ts
20382
+ /**
20383
+ * What the runner sends the board from an agent's output, secrets out: a command line, an error, a step's message.
20384
+ * Every message a run reports goes through `clip()` (docs/PLAN-AGENT-LOOPS.md §1.6: agentpipe's too).
20385
+ */
20386
+ /** Secrets a command line or an error might carry, kept out of what the board shows. */
20387
+ const SECRETS = [
20388
+ [/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g, "…"],
20389
+ [/\bsk-[A-Za-z0-9_-]{16,}/g, "…"],
20390
+ [/\bmbn_[A-Za-z0-9_]{8,}/g, "…"],
20391
+ [/\bxox[abprs]-[A-Za-z0-9-]{10,}/g, "…"],
20392
+ [/\bAKIA[0-9A-Z]{16}\b/g, "…"],
20393
+ [/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1…"],
20394
+ [/((?:token|secret|passw(?:or)?d|api[_-]?key|auth)[A-Za-z_]*["']?\s*[=:]\s*["']?)(?!Bearer\b|Basic\b)[^\s"']+/gi, "$1…"]
20395
+ ];
20396
+ function redact(text) {
20397
+ return SECRETS.reduce((t, [pattern, by]) => t.replace(pattern, by), text);
20398
+ }
20399
+ /** A message the API takes (and the board shows), secrets out. */
20400
+ function clip$1(text, max = 2e3) {
20401
+ const clean = redact(text).trim();
20402
+ return clean.length > max ? `${clean.slice(0, max - 1)}…` : clean;
20403
+ }
20404
+ /** Words as a sentence: ended with a period unless they end a sentence already. */
20405
+ function sentence(text) {
20406
+ const said = text.trim();
20407
+ return /[.!?…]$/.test(said) ? said : `${said}.`;
20408
+ }
20409
+ /**
20410
+ * A reason that names a command a person must run on the runner's machine (docs/PLAN-AGENT-LOOPS.md §1.6): the
20411
+ * sentence first, complete without the command, then the command as the last sentence, on the same line (a run's
20412
+ * reason is one string, and `monoban runs` prints it in a table). A step the loop's page has a button for (accepting
20413
+ * decisions, continuing from a step) names no command: the reason points at the page. Several commands are run in
20414
+ * their order: "`monoban agentpipe update`, then `monoban runner restart`".
20415
+ */
20416
+ function onRunnersMachine(text, command, ...then) {
20417
+ const commands = [command, ...then].map((c) => `\`${c}\``).join(", then ");
20418
+ return `${sentence(text).replace(/\s+/g, " ")} On the runner's machine: ${commands}.`;
20419
+ }
19888
20420
  // src/runner/agents/agentpipe.ts
19889
20421
  /** agentpipe's step statuses that monoban has too; the others (budget_exceeded, max_turns…) are failures. */
19890
20422
  const SAME = [
@@ -19901,7 +20433,7 @@ const RUN_ENDINGS = {
19901
20433
  nothing_to_do: "succeeded"
19902
20434
  };
19903
20435
  /** How agentpipe's own endings read, before its reason. */
19904
- const SAYS = {
20436
+ const SAYS$1 = {
19905
20437
  refused: "It couldn't start",
19906
20438
  nothing_to_do: "There was nothing to do"
19907
20439
  };
@@ -19931,15 +20463,90 @@ const CI_SAYS = {
19931
20463
  * code, and its reason (agentpipe's words) says it. Never read from the words.
19932
20464
  */
19933
20465
  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;
20466
+ /**
20467
+ * The owner's switches (agentpipe 0.15.0, AGE-204): a loop's advisor (`--advisor`) and accepting decisions at merge
20468
+ * (`--accept-decisions`) each work only where the runner's machine allows it, in agentpipe's own config, which only
20469
+ * its owner edits (no command sets it, and monoban never does: no runner.json key either, the owner's decision of
20470
+ * 2026-11-18). agentpipe refuses the flag without it, by these checks: the dry run in its preview, a command on its
20471
+ * `run.end`, `merge` on its `merge.blocked`. Each becomes the run's ending in monoban's words, with its code (MON-268),
20472
+ * naming the key and the file, never a command.
20473
+ */
20474
+ const SWITCHES_OFF = {
20475
+ advisor_not_allowed: {
20476
+ code: "advisor_switch_off",
20477
+ 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."
20478
+ },
20479
+ accept_decisions_not_allowed: {
20480
+ code: "accept_switch_off",
20481
+ 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."
20482
+ }
20483
+ };
20484
+ /** The owner's switch a refusal's `check` says is off, or null. */
20485
+ const switchOff = (check) => typeof check === "string" ? SWITCHES_OFF[check] ?? null : null;
20486
+ /** The run's reason code for a refused merge's `check` (an owner's switch off included), or null. */
20487
+ const mergeCheckCode = (check) => MERGE_CHECKS.find((code) => code === check) ?? switchOff(check)?.code ?? null;
19936
20488
  const str = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
19937
20489
  const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
19938
20490
  /** 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;
20491
+ const clip = (text) => text.length > 2e3 ? `${text.slice(0, 1999)}…` : text;
19940
20492
  /**
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.
20493
+ * Text cut to at most `chars` UTF-16 units and `bytes` UTF-8 bytes, its start kept (never inside a character): a
20494
+ * decision's event must fit the 8 KB its data may hold (task_run_events.data), whatever language it's in.
20495
+ */
20496
+ function upTo(text, chars, bytes) {
20497
+ let out = "";
20498
+ let size = 0;
20499
+ for (const ch of text) {
20500
+ const n = Buffer.byteLength(ch);
20501
+ if (out.length + ch.length > chars || size + n > bytes) break;
20502
+ out += ch;
20503
+ size += n;
20504
+ }
20505
+ return out;
20506
+ }
20507
+ /**
20508
+ * What a decision's event may hold of each of agentpipe's words, by characters and by bytes: together, at their
20509
+ * largest, with every other field, under the 8 KB of an event's data (a test fills one).
20510
+ */
20511
+ const DECISION_LIMITS = {
20512
+ answer: {
20513
+ chars: 2e3,
20514
+ bytes: 4e3
20515
+ },
20516
+ /** agentpipe clips it to 1,000 characters (merge.blocked v6). */
20517
+ rationale: {
20518
+ chars: 1e3,
20519
+ bytes: 2e3
20520
+ },
20521
+ questionId: {
20522
+ chars: 200,
20523
+ bytes: 200
20524
+ },
20525
+ category: {
20526
+ chars: 100,
20527
+ bytes: 100
20528
+ },
20529
+ /** `method` and `waits_because`: agentpipe's words, a few letters. */
20530
+ word: {
20531
+ chars: 40,
20532
+ bytes: 40
20533
+ }
20534
+ };
20535
+ const limited = (text, limit) => upTo(text, limit.chars, limit.bytes);
20536
+ /** What agentpipe's `accepted_by` says (`setting`, `caller`) as monoban writes it: the loop's option is the caller. */
20537
+ const ACCEPTED_BY = {
20538
+ setting: "setting",
20539
+ caller: "loop"
20540
+ };
20541
+ /**
20542
+ * `merge.blocked`'s decisions (and `merge.completed`'s `accepted`): each with its id, question id, category and answer,
20543
+ * and the agentpipe run that made it (agentpipe 0.15.0's `run_id`, merge.blocked v7 and merge.completed v6: a merge
20544
+ * waits on every run's decisions on the pull request, AGE-219, and `ratify` takes the decision's own run, MON-302;
20545
+ * null before it, or one monoban wouldn't pass to `ratify`); anything else is left out. And how it was reached
20546
+ * (0.15.0, MON-268): its `method` (`adjudicated`, `judgement`…), whether a judgement's source couldn't be confirmed
20547
+ * (`unverified`), the reason the agent gave (`rationale`), why it still waits with --accept-decisions (`waits_because`:
20548
+ * `unverified`, `hard`, `not_announced`) and who accepted it (`accepted_by`); each null when agentpipe didn't say. The
20549
+ * agent's words (the answer, the reason) with secrets out, each within DECISION_LIMITS.
19943
20550
  */
19944
20551
  function decisionsOf(value) {
19945
20552
  if (!Array.isArray(value)) return [];
@@ -19952,13 +20559,74 @@ function decisionsOf(value) {
19952
20559
  str(o.category),
19953
20560
  str(o.answer)
19954
20561
  ];
19955
- if (!decisionId || !/^[0-9a-f]{12}$/.test(decisionId) || !questionId || !category || !answer) return [];
20562
+ if (!decisionId || !DECISION_ID.test(decisionId) || !questionId || !category || !answer) return [];
20563
+ const run = str(o.run_id);
20564
+ const agentpipeRun = run && AGENTPIPE_RUN.test(run) ? run : null;
20565
+ const [method, rationale, waitsBecause, acceptedBy] = [
20566
+ str(o.method),
20567
+ str(o.rationale),
20568
+ str(o.waits_because),
20569
+ str(o.accepted_by)
20570
+ ];
19956
20571
  return [{
19957
20572
  decisionId,
19958
- questionId,
19959
- category,
19960
- answer,
19961
- question: str(o.question)
20573
+ agentpipeRun,
20574
+ questionId: limited(questionId, DECISION_LIMITS.questionId),
20575
+ category: limited(category, DECISION_LIMITS.category),
20576
+ answer: limited(redact(answer), DECISION_LIMITS.answer),
20577
+ question: str(o.question),
20578
+ method: method ? limited(method, DECISION_LIMITS.word) : null,
20579
+ unverified: typeof o.unverified === "boolean" ? o.unverified : null,
20580
+ rationale: rationale ? limited(redact(rationale), DECISION_LIMITS.rationale) : null,
20581
+ waitsBecause: waitsBecause ? limited(waitsBecause, DECISION_LIMITS.word) : null,
20582
+ accepted: (acceptedBy && ACCEPTED_BY[acceptedBy]) ?? "setting"
20583
+ }];
20584
+ });
20585
+ }
20586
+ /**
20587
+ * A decision's event data (a `question`'s): who made it and how, and what it says, flat (event data holds no lists).
20588
+ * Only what agentpipe said: a field it left out is left out.
20589
+ */
20590
+ function decisionData(d) {
20591
+ return {
20592
+ decisionId: d.decisionId,
20593
+ ...d.agentpipeRun && { agentpipeRun: d.agentpipeRun },
20594
+ questionId: d.questionId,
20595
+ category: d.category,
20596
+ answer: d.answer,
20597
+ ...d.method && { method: d.method },
20598
+ ...d.unverified !== null && { unverified: d.unverified },
20599
+ ...d.rationale && { rationale: d.rationale }
20600
+ };
20601
+ }
20602
+ /**
20603
+ * `merge.blocked`'s and `merge.completed`'s `replaced` (agentpipe 0.15.0, AGE-221): a decision a later run's decision
20604
+ * on the pull request replaced, which no merge waits on any more, and the one that replaced it.
20605
+ */
20606
+ function replacedOf(value) {
20607
+ if (!Array.isArray(value)) return [];
20608
+ return value.flatMap((x) => {
20609
+ if (!x || typeof x !== "object") return [];
20610
+ const o = x;
20611
+ const [decisionId, questionId, category, replacedBy] = [
20612
+ str(o.decision_id),
20613
+ str(o.question_id),
20614
+ str(o.category),
20615
+ str(o.replaced_by)
20616
+ ];
20617
+ if (!decisionId || !DECISION_ID.test(decisionId) || !replacedBy || !DECISION_ID.test(replacedBy)) return [];
20618
+ if (!questionId || !category) return [];
20619
+ const runOf = (v) => {
20620
+ const run = str(v);
20621
+ return run && AGENTPIPE_RUN.test(run) ? run : null;
20622
+ };
20623
+ return [{
20624
+ decisionId,
20625
+ agentpipeRun: runOf(o.run_id),
20626
+ questionId: limited(questionId, DECISION_LIMITS.questionId),
20627
+ category: limited(category, DECISION_LIMITS.category),
20628
+ replacedBy,
20629
+ replacedByRun: runOf(o.replaced_by_run)
19962
20630
  }];
19963
20631
  });
19964
20632
  }
@@ -20025,6 +20693,8 @@ function agentpipeMapper(report) {
20025
20693
  let blocked = null;
20026
20694
  /** The review comments `address` set aside (`feedback.intake`'s `refused`), for the recipe to report. */
20027
20695
  const setAside = [];
20696
+ /** `close.completed`: the pull request it closed to start over. */
20697
+ let closed = null;
20028
20698
  /** A window open for your answers (`run --ask-window`): when it closes, and the questions it still waits on. */
20029
20699
  let asking = null;
20030
20700
  /** 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 +20710,31 @@ function agentpipeMapper(report) {
20040
20710
  ...at && { at }
20041
20711
  });
20042
20712
  const spent = () => report.update({ costUsd: Math.round((total + shipped) * 1e4) / 1e4 });
20713
+ /** Each decision of a run once (two runs' decisions with one id are two, MON-302). */
20714
+ const unique = (decisions) => {
20715
+ const seen = /* @__PURE__ */ new Set();
20716
+ return decisions.filter((x) => {
20717
+ const key = `${x.agentpipeRun ?? ""}/${x.decisionId}`;
20718
+ return !seen.has(key) && Boolean(seen.add(key));
20719
+ });
20720
+ };
20721
+ /** Each replaced decision, a question that names the decision that replaced it (MON-300 shows it, never offers it). */
20722
+ const reportReplaced = (value, step, at) => {
20723
+ for (const r of replacedOf(value)) report.event({
20724
+ kind: "question",
20725
+ ...step && { step },
20726
+ message: `Decision ${r.decisionId} was replaced by a later run's decision, ${r.replacedBy}.`,
20727
+ data: {
20728
+ decisionId: r.decisionId,
20729
+ ...r.agentpipeRun && { agentpipeRun: r.agentpipeRun },
20730
+ questionId: r.questionId,
20731
+ category: r.category,
20732
+ replacedBy: r.replacedBy,
20733
+ ...r.replacedByRun && { replacedByRun: r.replacedByRun }
20734
+ },
20735
+ ...at && { at }
20736
+ });
20737
+ };
20043
20738
  const flush = (cost) => {
20044
20739
  if (!pending) return;
20045
20740
  const { step, attempt, status, message, at } = pending;
@@ -20052,7 +20747,7 @@ function agentpipeMapper(report) {
20052
20747
  step,
20053
20748
  attempt,
20054
20749
  status,
20055
- ...message && { message: clip$1(message) },
20750
+ ...message && { message: clip(message) },
20056
20751
  ...Object.keys(data).length && { data },
20057
20752
  ...at && { at }
20058
20753
  });
@@ -20138,7 +20833,7 @@ function agentpipeMapper(report) {
20138
20833
  if (ci?.said !== now) report.event({
20139
20834
  kind: "activity",
20140
20835
  ...step && { step },
20141
- message: clip$1(now),
20836
+ message: clip(now),
20142
20837
  ...at && { at }
20143
20838
  });
20144
20839
  ci = {
@@ -20216,7 +20911,7 @@ function agentpipeMapper(report) {
20216
20911
  const change = str(d.change);
20217
20912
  if (change) report.event({
20218
20913
  kind: "board",
20219
- message: clip$1(change),
20914
+ message: clip(change),
20220
20915
  ...at && { at }
20221
20916
  });
20222
20917
  return;
@@ -20229,8 +20924,8 @@ function agentpipeMapper(report) {
20229
20924
  report.event({
20230
20925
  kind: "board",
20231
20926
  ...step && { step },
20232
- message: clip$1(`filed ${what}`),
20233
- data: { url: clip$1(url) },
20927
+ message: clip(`filed ${what}`),
20928
+ data: { url: clip(url) },
20234
20929
  ...at && { at }
20235
20930
  });
20236
20931
  return;
@@ -20260,7 +20955,7 @@ function agentpipeMapper(report) {
20260
20955
  for (const q of asked) report.event({
20261
20956
  kind: "question",
20262
20957
  ...step && { step },
20263
- message: clip$1(q.text),
20958
+ message: clip(q.text),
20264
20959
  data: {
20265
20960
  questionId: q.id,
20266
20961
  category: q.category
@@ -20273,7 +20968,7 @@ function agentpipeMapper(report) {
20273
20968
  report.event({
20274
20969
  kind: "question",
20275
20970
  ...step && { step },
20276
- message: clip$1(text),
20971
+ message: clip(text),
20277
20972
  ...at && { at }
20278
20973
  });
20279
20974
  return;
@@ -20321,7 +21016,7 @@ function agentpipeMapper(report) {
20321
21016
  report.event({
20322
21017
  kind: "warning",
20323
21018
  ...step && { step },
20324
- message: clip$1(text),
21019
+ message: clip(text),
20325
21020
  ...at && { at }
20326
21021
  });
20327
21022
  return;
@@ -20334,46 +21029,56 @@ function agentpipeMapper(report) {
20334
21029
  if (d.counts && typeof d.counts === "object") counts = Object.fromEntries(Object.entries(d.counts).flatMap(([k, v]) => num(v) === null ? [] : [[k, v]]));
20335
21030
  const reason = str(d.reason);
20336
21031
  runReason = reason;
20337
- const says = SAYS[status];
21032
+ const off = status === "refused" ? switchOff(d.check) : null;
21033
+ if (off) {
21034
+ ending = {
21035
+ status: "needs_human",
21036
+ reason: off.reason,
21037
+ code: off.code
21038
+ };
21039
+ return;
21040
+ }
21041
+ const says = SAYS$1[status];
20338
21042
  ending = {
20339
21043
  status: RUN_ENDINGS[status] ?? "failed",
20340
- reason: clip$1(says ? `${says}${reason ? `: ${reason}` : "."}` : reason ?? (RUN_ENDINGS[status] ? "" : `It ended ${status.replace(/_/g, " ")}.`)) || null
21044
+ reason: clip(says ? `${says}${reason ? `: ${reason}` : "."}` : reason ?? (RUN_ENDINGS[status] ? "" : `It ended ${status.replace(/_/g, " ")}.`)) || null
20341
21045
  };
20342
21046
  if (ending.status === "failed" && ending.reason) report.event({
20343
21047
  kind: "error",
20344
- message: clip$1(ending.reason)
21048
+ message: clip(ending.reason)
20345
21049
  });
20346
21050
  return;
20347
21051
  }
20348
21052
  case "merge.completed": {
20349
21053
  said = "merged";
20350
21054
  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({
21055
+ const accepted = unique(decisionsOf(d.accepted));
21056
+ for (const decision of accepted) report.event({
20356
21057
  kind: "question",
20357
21058
  ...step && { step },
20358
- message: clip$1(decision.question ?? decision.answer),
21059
+ message: clip(decision.question ?? decision.answer),
20359
21060
  data: {
20360
- decisionId: decision.decisionId,
20361
- questionId: decision.questionId,
20362
- category: decision.category,
20363
- answer: decision.answer.slice(0, 2e3),
20364
- accepted: "setting"
21061
+ ...decisionData(decision),
21062
+ accepted: decision.accepted
20365
21063
  },
20366
21064
  ...at && { at }
20367
21065
  });
21066
+ reportReplaced(d.replaced, step, at);
21067
+ const merged = sha ? `Merged (${sha.slice(0, 7)})` : "Merged";
21068
+ const n = accepted.length;
21069
+ ending = {
21070
+ status: "succeeded",
21071
+ reason: n ? `${merged}, with ${n} ${n === 1 ? "decision" : "decisions"} nobody confirmed.` : `${merged}.`
21072
+ };
20368
21073
  return;
20369
21074
  }
20370
21075
  case "merge.blocked": {
20371
21076
  said = "blocked";
20372
- const reason = str(d.reason);
21077
+ const reason = switchOff(d.check)?.reason ?? str(d.reason);
20373
21078
  const code = mergeCheckCode(d.check);
20374
21079
  ending = {
20375
21080
  status: "needs_human",
20376
- reason: clip$1(reason ?? "agentpipe didn't merge it."),
21081
+ reason: clip(reason ?? "agentpipe didn't merge it."),
20377
21082
  ...code && { code }
20378
21083
  };
20379
21084
  if (code !== "checks_pending") report.event({
@@ -20392,18 +21097,35 @@ function agentpipeMapper(report) {
20392
21097
  if (headSha) for (const decision of decisions) report.event({
20393
21098
  kind: "question",
20394
21099
  ...step && { step },
20395
- message: clip$1(decision.question ?? decision.answer),
21100
+ message: clip(decision.question ?? decision.answer),
20396
21101
  data: {
20397
- decisionId: decision.decisionId,
20398
- questionId: decision.questionId,
20399
- category: decision.category,
20400
- answer: decision.answer.slice(0, 2e3),
21102
+ ...decisionData(decision),
21103
+ ...decision.waitsBecause && { waitsBecause: decision.waitsBecause },
20401
21104
  headSha
20402
21105
  },
20403
21106
  ...at && { at }
20404
21107
  });
21108
+ reportReplaced(d.replaced, step, at);
20405
21109
  return;
20406
21110
  }
21111
+ case "close.completed":
21112
+ said = "closed";
21113
+ closed = {
21114
+ pr: num(d.pr) ?? 0,
21115
+ branchDeleted: d.branch_deleted === true
21116
+ };
21117
+ ending = {
21118
+ status: "succeeded",
21119
+ reason: null
21120
+ };
21121
+ return;
21122
+ case "close.refused":
21123
+ said = "refused";
21124
+ ending = {
21125
+ status: "failed",
21126
+ reason: clip(str(d.reason) ?? "agentpipe didn't close the pull request.")
21127
+ };
21128
+ return;
20407
21129
  case "ship.end": {
20408
21130
  flush();
20409
21131
  const state = str(d.state) ?? "failed";
@@ -20424,15 +21146,15 @@ function agentpipeMapper(report) {
20424
21146
  };
20425
21147
  else if (state === "refused") ending = {
20426
21148
  status: "failed",
20427
- reason: clip$1(`${SAYS.refused}${reason ? `: ${reason}` : "."}`)
21149
+ reason: clip(`${SAYS$1.refused}${reason ? `: ${reason}` : "."}`)
20428
21150
  };
20429
21151
  else ending = {
20430
21152
  status: SHIP_ENDINGS[state] ?? "failed",
20431
- reason: reason ? clip$1(reason) : SHIP_ENDINGS[state] ? null : `It ended ${state.replace(/_/g, " ")}.`
21153
+ reason: reason ? clip(reason) : SHIP_ENDINGS[state] ? null : `It ended ${state.replace(/_/g, " ")}.`
20432
21154
  };
20433
21155
  if (ending.status === "failed" && ending.reason) report.event({
20434
21156
  kind: "error",
20435
- message: clip$1(ending.reason)
21157
+ message: clip(ending.reason)
20436
21158
  });
20437
21159
  return;
20438
21160
  }
@@ -20455,6 +21177,8 @@ function agentpipeMapper(report) {
20455
21177
  blocked: () => blocked,
20456
21178
  /** The review comments `address` set aside (`feedback.intake`'s `refused`), in order. */
20457
21179
  setAside: () => [...setAside],
21180
+ /** The pull request `close` closed to start over (`close.completed`), or null. */
21181
+ closed: () => closed,
20458
21182
  flush: () => flush(),
20459
21183
  /**
20460
21184
  * 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 +21195,9 @@ const LATE = [
20471
21195
  "decided by the agent after nobody answered in time"
20472
21196
  ];
20473
21197
  /**
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.
21198
+ * Whether agentpipe refused an answer for coming too late, from its words (0.12.0, the same at 0.15.0). `answer --json`
21199
+ * (0.14.0, AGE-207) names the refusal's `check` (`answer_too_late`, `decided_already`): reading it instead means calling
21200
+ * `answer` with `--json`. One a person already answered isn't late: it says whose it was.
20476
21201
  */
20477
21202
  function refusedAsLate(said) {
20478
21203
  return said !== null && LATE.some((words) => said.includes(words));
@@ -20542,15 +21267,24 @@ const KEEP_PREFIXES = [
20542
21267
  "MONOBAN_"
20543
21268
  ];
20544
21269
  /**
21270
+ * The variable a caller's settings travel in (agentpipe 0.14.0, AGE-194): JSON, read by the commands that apply them.
21271
+ * The runner owns it: a value in its own environment never reaches agentpipe (agentpipeEnv), and only a loop's run
21272
+ * sets it, from its options (`runEnv`, recipes/index.ts). The preflight checks agentpipe names the same one.
21273
+ */
21274
+ const CALLER_SETTINGS = "AGENTPIPE_CALLER_SETTINGS";
21275
+ /**
20545
21276
  * agentpipe's environment: only what it needs, so the runner's other secrets (a database password, cloud keys, an
20546
21277
  * 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.
21278
+ * one that started it. A caller's settings only as given here (`callerSettings`, a loop's run's, from `runEnv`):
21279
+ * never one inherited, which would reach every command, manual runs and `cancel` included.
20548
21280
  */
20549
- function agentpipeEnv(env, monobanBin) {
21281
+ function agentpipeEnv(env, monobanBin, callerSettings = null) {
20550
21282
  const kept = {};
20551
21283
  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
21284
  delete kept.MONOBAN_BIN;
21285
+ delete kept[CALLER_SETTINGS];
20553
21286
  if (monobanBin) kept.MONOBAN_BIN = monobanBin;
21287
+ if (callerSettings !== null) kept[CALLER_SETTINGS] = callerSettings;
20554
21288
  return kept;
20555
21289
  }
20556
21290
  /**
@@ -20559,12 +21293,12 @@ function agentpipeEnv(env, monobanBin) {
20559
21293
  * `map` (its plain lines skipped), its stderr's last line kept to say why it stopped. `stop()` and `interrupt()`
20560
21294
  * end it from outside; `agentpipe cancel <run id>` is the polite way, once there is one.
20561
21295
  */
20562
- function agentpipeCommand({ command = "agentpipe", args, cwd, env, monobanBin = null, map, spawn = defaultSpawn, graceMs }) {
21296
+ function agentpipeCommand({ command = "agentpipe", args, cwd, env, monobanBin = null, callerSettings = null, map, spawn = defaultSpawn, graceMs }) {
20563
21297
  return startProcess({
20564
21298
  command,
20565
21299
  args,
20566
21300
  cwd,
20567
- env: agentpipeEnv(env, monobanBin),
21301
+ env: agentpipeEnv(env, monobanBin, callerSettings),
20568
21302
  spawn,
20569
21303
  ...graceMs !== void 0 && { graceMs },
20570
21304
  onLine: (line) => {
@@ -20674,6 +21408,31 @@ function agentpipe({ command = "agentpipe", args = [], spawn = defaultSpawn, exe
20674
21408
  }
20675
21409
  };
20676
21410
  }
21411
+ /**
21412
+ * A loop option's flag, as `capabilities` names it (agentpipe 0.15.0), and the commands of a deliver run it goes on
21413
+ * (`address` is `address --apply`): the advisor on the three that build `arbitrate`; accepting at merge on those (a run
21414
+ * announces it on the pull request) and on `merge` (which accepts). The recipe's `ship` never merges (`--no-merge`),
21415
+ * so it never takes it. The preflight checks the folder's agentpipe has each on the commands the run calls.
21416
+ */
21417
+ const FLAGS = {
21418
+ advisor: {
21419
+ flag: "--advisor",
21420
+ commands: [
21421
+ "run",
21422
+ "review --fix",
21423
+ "address"
21424
+ ]
21425
+ },
21426
+ accept_decisions: {
21427
+ flag: "--accept-decisions",
21428
+ commands: [
21429
+ "run",
21430
+ "review --fix",
21431
+ "address",
21432
+ "merge"
21433
+ ]
21434
+ }
21435
+ };
20677
21436
  /** What each loop's recipe needs of agentpipe: its commands and their flags (docs/PLAN-AGENT-LOOPS.md §1.6). */
20678
21437
  const RECIPE_NEEDS = {
20679
21438
  deliver: [
@@ -21742,45 +22501,6 @@ function buildPrompt({ task, comments, branch }) {
21742
22501
  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
22502
  return lines.join("\n");
21744
22503
  }
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
22504
  const ok = (value, data) => ({
21785
22505
  status: "ok",
21786
22506
  ...value !== void 0 && { value },
@@ -21829,7 +22549,7 @@ function steps(report, isCancelled = () => false) {
21829
22549
  step: name,
21830
22550
  attempt,
21831
22551
  status,
21832
- ...message && { message: clip(message) },
22552
+ ...message && { message: clip$1(message) },
21833
22553
  data: {
21834
22554
  durationMs: Date.now() - started,
21835
22555
  ...data
@@ -22022,7 +22742,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22022
22742
  const { step } = steps(report, () => cancelled);
22023
22743
  const warn = (message) => report.event({
22024
22744
  kind: "warning",
22025
- message: clip(message)
22745
+ message: clip$1(message)
22026
22746
  });
22027
22747
  /** Says on the task how it went; a failure to is a warning, not the run's ending. */
22028
22748
  let ref = run.ref;
@@ -22045,7 +22765,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22045
22765
  });
22046
22766
  if (moved) report.event({
22047
22767
  kind: "board",
22048
- message: clip(moved)
22768
+ message: clip$1(moved)
22049
22769
  });
22050
22770
  return ok({
22051
22771
  branch,
@@ -22059,7 +22779,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22059
22779
  })
22060
22780
  });
22061
22781
  } catch (err) {
22062
- return failed(clip(`Couldn't get the folder ready: ${err.message}`, 1e3));
22782
+ return failed(clip$1(`Couldn't get the folder ready: ${err.message}`, 1e3));
22063
22783
  }
22064
22784
  }, { always: true });
22065
22785
  if (!prepared.ran || !prepared.value) return {
@@ -22076,7 +22796,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22076
22796
  if (limited) report.event({
22077
22797
  kind: "warning",
22078
22798
  step: "code",
22079
- message: clip(limited.warning)
22799
+ message: clip$1(limited.warning)
22080
22800
  });
22081
22801
  const asked = limited ? {
22082
22802
  ...run,
@@ -22090,14 +22810,14 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22090
22810
  const activity = throttled((message) => report.event({
22091
22811
  kind: "activity",
22092
22812
  step: "code",
22093
- message: clip(message, 200)
22813
+ message: clip$1(message, 200)
22094
22814
  }), activityMs);
22095
22815
  const out = {
22096
22816
  activity: (m) => m.trim() && activity.push(m),
22097
22817
  warning: (m) => report.event({
22098
22818
  kind: "warning",
22099
22819
  step: "code",
22100
- message: clip(m)
22820
+ message: clip$1(m)
22101
22821
  }),
22102
22822
  externalId: (id) => report.update({ externalId: id.slice(0, 128) })
22103
22823
  };
@@ -22163,7 +22883,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22163
22883
  let { failure } = coded.value;
22164
22884
  if (spawnError) return {
22165
22885
  status: "failed",
22166
- reason: clip(spawnError, 1e3)
22886
+ reason: clip$1(spawnError, 1e3)
22167
22887
  };
22168
22888
  const unfinished = cancelled || failure !== null;
22169
22889
  const committed = await step("commit", async () => {
@@ -22198,35 +22918,35 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22198
22918
  reason: commits ? `Cancelled; its work so far is on ${branch}.` : null
22199
22919
  };
22200
22920
  if (failure) {
22201
- await tell(`${label} couldn't finish: ${clip(failure, 1e3)}${kept}`);
22921
+ await tell(`${label} couldn't finish: ${clip$1(failure, 1e3)}${kept}`);
22202
22922
  return {
22203
22923
  status: "failed",
22204
- reason: clip(failure, 1e3)
22924
+ reason: clip$1(failure, 1e3)
22205
22925
  };
22206
22926
  }
22207
22927
  if (outcome?.status === "blocked") {
22208
22928
  const question = outcome.question || outcome.summary || "It got stuck without saying why.";
22209
22929
  report.event({
22210
22930
  kind: "question",
22211
- message: clip(question)
22931
+ message: clip$1(question)
22212
22932
  });
22213
- await tell(`${label} needs an answer: ${clip(question, 1500)}${kept}`);
22933
+ await tell(`${label} needs an answer: ${clip$1(question, 1500)}${kept}`);
22214
22934
  return {
22215
22935
  status: "needs_human",
22216
- reason: clip(question, 1e3)
22936
+ reason: clip$1(question, 1e3)
22217
22937
  };
22218
22938
  }
22219
22939
  const summary = outcome?.summary || (typeof result.answer === "string" ? result.answer : "");
22220
22940
  if (!commits) {
22221
22941
  const reason = `${label} changed nothing${summary ? `: ${summary}` : "."}`;
22222
- await tell(`${label} made no changes.${summary ? `\n\n${clip(summary, 1500)}` : ""}`);
22942
+ await tell(`${label} made no changes.${summary ? `\n\n${clip$1(summary, 1500)}` : ""}`);
22223
22943
  return {
22224
22944
  status: "needs_human",
22225
- reason: clip(reason, 1e3)
22945
+ reason: clip$1(reason, 1e3)
22226
22946
  };
22227
22947
  }
22228
22948
  let url = null;
22229
- const prTitle = clip(outcome?.prTitle || `${ref}: ${title}`, 200);
22949
+ const prTitle = clip$1(outcome?.prTitle || `${ref}: ${title}`, 200);
22230
22950
  if (run.options.pr === "none") await step("pr", async () => skipped(`none asked for: the work is on ${branch}`));
22231
22951
  else {
22232
22952
  const up = async (fn) => {
@@ -22234,7 +22954,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22234
22954
  await fn();
22235
22955
  return ok();
22236
22956
  } catch (err) {
22237
- return failed(clip(err.message, 1e3));
22957
+ return failed(clip$1(err.message, 1e3));
22238
22958
  }
22239
22959
  };
22240
22960
  const pushed = await step("push", () => up(() => ws.push(branch)));
@@ -22243,7 +22963,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22243
22963
  base,
22244
22964
  branch,
22245
22965
  title: prTitle,
22246
- body: `${clip(summary || prTitle, 6e3)}\n\n---\n${ref} · by ${label}, through \`monoban runner\``,
22966
+ body: `${clip$1(summary || prTitle, 6e3)}\n\n---\n${ref} · by ${label}, through \`monoban runner\``,
22247
22967
  draft: run.options.pr === "draft"
22248
22968
  });
22249
22969
  report.update({ prUrl: url });
@@ -22266,7 +22986,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22266
22986
  await step("report", async () => {
22267
22987
  try {
22268
22988
  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)}` : ""}`);
22989
+ await board.comment(ref, `${label} finished${url ? `: ${url}` : `, on the branch \`${branch}\``}.${summary ? `\n\n${clip$1(summary, 6e3)}` : ""}`);
22270
22990
  report.event({
22271
22991
  kind: "board",
22272
22992
  message: url ? "attached the pull request, and commented" : "commented"
@@ -22284,7 +23004,7 @@ function codingAgent({ spec, command, args: extra = [], board, env = process.env
22284
23004
  return {
22285
23005
  done: flow().catch((err) => ({
22286
23006
  status: "failed",
22287
- reason: clip(`The run stopped: ${err.message}`, 1e3)
23007
+ reason: clip$1(`The run stopped: ${err.message}`, 1e3)
22288
23008
  })),
22289
23009
  cancel: async () => {
22290
23010
  cancelled = true;
@@ -22491,6 +23211,129 @@ const codexSpec = ({ allowFullAccess = false } = {}) => ({
22491
23211
  reader: codexReader
22492
23212
  });
22493
23213
  codexSpec();
23214
+ // src/runner/recipes/settings.ts
23215
+ /**
23216
+ * A loop's settings for agentpipe (AGE-193, docs/PLAN-AGENT-LOOPS.md §1.14): a deliver loop's `network` and `sites`
23217
+ * become agentpipe's `allow_network` and `allowed_domains` for its `resolve` and `arbitrate` steps, handed to the
23218
+ * commands that apply them as JSON in one environment variable (CALLER_SETTINGS), never a file or an argument.
23219
+ */
23220
+ /** The steps a caller's settings set, and their fields, as agentpipe's `capabilities` lists them (AGE-196). */
23221
+ const CALLER_STEPS = ["resolve", "arbitrate"];
23222
+ const CALLER_FIELDS = ["allow_network", "allowed_domains"];
23223
+ /**
23224
+ * A run's settings from its loop's options: with the network on, both steps reach it, fetching from the loop's sites
23225
+ * alone. None with it off: agentpipe then runs on the machine's own config. The options aren't checked here (the API
23226
+ * did): a network on with odd sites is sent as it is, for agentpipe to refuse, never dropped.
23227
+ */
23228
+ function callerSettingsOf(options) {
23229
+ if (options.network !== true) return null;
23230
+ const sites = Array.isArray(options.sites) ? options.sites.map(String) : [];
23231
+ const step = () => ({
23232
+ allow_network: true,
23233
+ allowed_domains: [...sites]
23234
+ });
23235
+ return { steps: {
23236
+ resolve: step(),
23237
+ arbitrate: step()
23238
+ } };
23239
+ }
23240
+ /** Which of the commands that apply a caller's settings this is, or null: one that never gets them. */
23241
+ function callerCommandOf(args) {
23242
+ if (args[0] === "run") return "run";
23243
+ if (args[0] === "review" && args.includes("--fix")) return "review --fix";
23244
+ if (args[0] === "address" && args.includes("--apply")) return "address";
23245
+ return null;
23246
+ }
23247
+ /**
23248
+ * The environment of one agentpipe command of a loop's run, as `agentpipeCommand` takes it: the runner's (agentpipe
23249
+ * keeps only part of it, agentpipeEnv), the loop's project as the folder's (`MONOBAN_PROJECT`: the runner checked the
23250
+ * folder is that project's, but its link or $MONOBAN_PROJECT could name another), and the run's settings, only on a
23251
+ * command that applies them. Every command of a run gets its environment here, its dry run included: this is the one
23252
+ * place that sets CALLER_SETTINGS.
23253
+ */
23254
+ function runEnv(run, settings, deps, args) {
23255
+ const command = callerCommandOf(args);
23256
+ const applies = settings !== null && command !== null && settings.commands.includes(command);
23257
+ return {
23258
+ env: {
23259
+ ...deps.env,
23260
+ MONOBAN_PROJECT: run.project
23261
+ },
23262
+ callerSettings: applies ? JSON.stringify(settings.settings) : null
23263
+ };
23264
+ }
23265
+ /** The same sites, whatever their order or case. */
23266
+ function sameSites(a, b) {
23267
+ const [x, y] = [new Set(a.map((s) => s.toLowerCase())), new Set(b.map((s) => s.toLowerCase()))];
23268
+ return x.size === y.size && [...x].every((s) => y.has(s));
23269
+ }
23270
+ const sitesSaid = (sites) => sites.length ? sites.join(", ") : "none";
23271
+ /**
23272
+ * What a command's `run.start` says agentpipe applied (`caller`, agentpipe 0.14.0, AGE-195: one entry per step the
23273
+ * caller set; none when nothing was sent) against what the run sent: one difference per step, in words, with its
23274
+ * values as event data takes them (no lists: the sites joined). Nothing stops the run (AGE-193 D22): the dry run's
23275
+ * comparison is the check that refuses.
23276
+ */
23277
+ function callerDifferences(caller, sent) {
23278
+ const applied = /* @__PURE__ */ new Map();
23279
+ for (const entry of Array.isArray(caller) ? caller : []) {
23280
+ if (!entry || typeof entry !== "object") continue;
23281
+ const { step, allow_network, allowed_domains } = entry;
23282
+ if (typeof step !== "string") continue;
23283
+ const sites = Array.isArray(allowed_domains) ? allowed_domains.filter((s) => typeof s === "string") : [];
23284
+ applied.set(step, {
23285
+ network: allow_network === true,
23286
+ sites
23287
+ });
23288
+ }
23289
+ return CALLER_STEPS.flatMap((step) => {
23290
+ const want = sent?.steps[step] ?? null;
23291
+ const got = applied.get(step) ?? null;
23292
+ const asked = want ? {
23293
+ network: want.allow_network,
23294
+ sites: want.allowed_domains
23295
+ } : null;
23296
+ if (!asked && !got) return [];
23297
+ if (asked && got && asked.network === got.network && sameSites(asked.sites, got.sites)) return [];
23298
+ const said = (s) => s ? `the network ${s.network ? "on" : "off"}, sites ${sitesSaid(s.sites)}` : "nothing set";
23299
+ return [{
23300
+ step,
23301
+ message: `agentpipe set ${step} otherwise than the run sent: ${said(got)}, where the run sent ${said(asked)}.`,
23302
+ data: {
23303
+ callerSettings: true,
23304
+ agentpipeStep: step,
23305
+ network: got ? got.network : null,
23306
+ sites: got ? got.sites.join(",") : null,
23307
+ sentNetwork: asked ? asked.network : null,
23308
+ sentSites: asked ? asked.sites.join(",") : null
23309
+ }
23310
+ }];
23311
+ });
23312
+ }
23313
+ /** The tools a step that reads sites may hold (AGE-194): it needs `WebFetch`, and nothing beyond these. */
23314
+ const READING_TOOLS = [
23315
+ "Read",
23316
+ "Glob",
23317
+ "Grep",
23318
+ "WebFetch"
23319
+ ];
23320
+ /**
23321
+ * What a dry run's step boundary says against the run's settings for it (AGE-194): the network on, the run's sites
23322
+ * (as sets), its tools within Read, Glob, Grep and WebFetch with WebFetch among them, and its reads held to the
23323
+ * worktree (`read_scope`). Each difference in words; none: it is held as sent.
23324
+ */
23325
+ function boundaryDifferences(boundary, sent) {
23326
+ const out = [];
23327
+ if (boundary.network !== true) out.push("its network is off");
23328
+ const sites = Array.isArray(boundary.allowed_domains) ? boundary.allowed_domains.map(String) : [];
23329
+ if (!sameSites(sites, sent.allowed_domains)) out.push(`it would read ${sitesSaid(sites)}, not ${sitesSaid(sent.allowed_domains)}`);
23330
+ const tools = Array.isArray(boundary.tools) ? boundary.tools.map(String) : [];
23331
+ const beyond = tools.filter((t) => !READING_TOOLS.includes(t));
23332
+ if (beyond.length) out.push(`it holds ${beyond.join(", ")}`);
23333
+ if (!tools.includes("WebFetch")) out.push("it has no WebFetch");
23334
+ if (boundary.read_scope !== "worktree") out.push(`its reads aren't held to the worktree (${typeof boundary.read_scope === "string" ? boundary.read_scope : "unsaid"})`);
23335
+ return out;
23336
+ }
22494
23337
  // src/runner/recipes/deliver.ts
22495
23338
  /**
22496
23339
  * `deliver` (docs/PLAN-AGENT-LOOPS.md §1.6): takes a task and delivers it as a pull request: `implement` opens it
@@ -22504,9 +23347,25 @@ function options(run) {
22504
23347
  return {
22505
23348
  checksMinutes: o.checksMinutes ?? LOOP_DEFAULTS.checksMinutes,
22506
23349
  reviewTier: o.reviewTier ?? null,
22507
- askMinutes: o.askMinutes ?? LOOP_DEFAULTS.askMinutes
23350
+ askMinutes: o.askMinutes ?? LOOP_DEFAULTS.askMinutes,
23351
+ advisor: o.advisor === true,
23352
+ acceptAtMerge: o.acceptAtMerge === true
22508
23353
  };
22509
23354
  }
23355
+ /** The loop's options that are agentpipe flags (§1.15, MON-268), each by the capability that names it. */
23356
+ function flagged(run) {
23357
+ const o = options(run);
23358
+ return [...o.advisor ? ["advisor"] : [], ...o.acceptAtMerge ? ["accept_decisions"] : []];
23359
+ }
23360
+ /**
23361
+ * The loop's flags for one agentpipe command (§1.15, MON-268), on the commands `capabilities` lists for each
23362
+ * (agentpipe 0.15.0, FLAGS): `--advisor` on `run`, `review --fix` and `address --apply` when the loop's advisor is on;
23363
+ * `--accept-decisions` on those and on `merge` when it accepts at merge. None with both off. Whether the machine allows
23364
+ * them is agentpipe's to say: its dry run refuses either flag the owner's switch doesn't allow.
23365
+ */
23366
+ function flagsFor(run, command) {
23367
+ return flagged(run).filter((capability) => FLAGS[capability].commands.includes(command)).map((capability) => FLAGS[capability].flag);
23368
+ }
22510
23369
  /** The loop's review tier, if it names one: the preflight checks the folder's agentpipe has it. */
22511
23370
  const reviewTierOf = (run) => options(run).reviewTier;
22512
23371
  /** Money as agentpipe takes it: dollars, to the cent. */
@@ -22515,8 +23374,9 @@ const usd = (n) => (Math.floor(n * 100) / 100).toFixed(2);
22515
23374
  * `agentpipe run` on the run's task: always `--autonomous` (it never stops to ask in a terminal nobody reads), from
22516
23375
  * an up-to-date base (`--fresh-base`), opening a draft pull request (`checks` marks it ready once it's green), on
22517
23376
  * 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.
23377
+ * settle open that long first (`--ask-window`, AGE-202); otherwise agentpipe decides them at once. The loop's
23378
+ * advisor and accepting at merge are its flags (`flagsFor`). The dry run is the same command with `--dry-run`, so it
23379
+ * checks what the run will do, the owner's switches for those flags included.
22520
23380
  */
22521
23381
  function implementArgs(run, budgetUsd) {
22522
23382
  const { askMinutes } = options(run);
@@ -22531,12 +23391,84 @@ function implementArgs(run, budgetUsd) {
22531
23391
  "--draft",
22532
23392
  "--budget",
22533
23393
  usd(budgetUsd),
22534
- ...askMinutes > 0 ? ["--ask-window", String(askMinutes * 60)] : []
23394
+ ...askMinutes > 0 ? ["--ask-window", String(askMinutes * 60)] : [],
23395
+ ...flagsFor(run, "run")
23396
+ ];
23397
+ }
23398
+ /**
23399
+ * `agentpipe close` (AGE-223, agentpipe 0.15.0): closes the pull request a start-over discards (MON-292), as the run
23400
+ * that opened it (`--expect-run`, which it refuses unless that run on this machine opened it; without the id, the run
23401
+ * its branch names). It comments why on the pull request itself (it takes no reason of ours), deletes the run's
23402
+ * branch, and records the work as started over, not rejected.
23403
+ */
23404
+ function closeArgs(run, pr, externalId) {
23405
+ return [
23406
+ "close",
23407
+ String(pr.number),
23408
+ run.workdir,
23409
+ ...externalId ? ["--expect-run", externalId] : [],
23410
+ "--json"
22535
23411
  ];
22536
23412
  }
23413
+ /**
23414
+ * What the run says first once agentpipe closed the pull request it starts over: its number, and what became of its
23415
+ * branch (agentpipe's is `agentpipe/<run id>`; `close.completed` says only whether it's gone).
23416
+ */
23417
+ function closedSays(pr, externalId, branchDeleted) {
23418
+ const branch = externalId ? ` agentpipe/${externalId}` : "";
23419
+ return branchDeleted ? `Closed #${pr.number} to start over; its branch${branch} was deleted.` : `Closed #${pr.number} to start over; its branch${branch} was kept.`;
23420
+ }
23421
+ /**
23422
+ * A start-over (MON-292), before anything else in implement: agentpipe closes the pull request it discards, and the
23423
+ * task's link to it says closed. Anything but `close.completed` ends the run there, before `agentpipe run`: a second
23424
+ * pull request must not be possible. Neither its run id nor its pull request becomes the run's (the mapper reports
23425
+ * none for `close`); the run's are what `agentpipe run` opens next. Null once it's closed.
23426
+ */
23427
+ async function closeFirst(ctx, closes) {
23428
+ const value = {
23429
+ externalId: null,
23430
+ prUrl: null
23431
+ };
23432
+ const old = prOf(closes.prUrl);
23433
+ if (!old) return failed(`There's no pull request to close: ${clip$1(closes.prUrl, 200)} isn't one.`, value);
23434
+ const closed = await ctx.agentpipe(closeArgs(ctx.run, old, closes.externalId));
23435
+ if (closed.ending?.status === "cancelled") return {
23436
+ status: "cancelled",
23437
+ message: "Cancelled.",
23438
+ value
23439
+ };
23440
+ if (!closed.closed) {
23441
+ const { exit } = closed;
23442
+ const said = closed.ending?.reason ?? exit.spawnError ?? exit.lastError;
23443
+ return failed(said ? sentence(said) : `agentpipe didn't close #${old.number} and didn't say why.`, value);
23444
+ }
23445
+ await ctx.prClosed(old);
23446
+ ctx.note(closedSays(old, closes.externalId, closed.closed.branchDeleted));
23447
+ return null;
23448
+ }
23449
+ /** What a start-over needs of agentpipe (`capabilities`): `close` with `--json` and `--expect-run`. */
23450
+ const CLOSE_NEEDS = ["close.json", "close.expect_run"];
22537
23451
  /** Whether the run's preview is implement's dry run: a run with its task that doesn't only merge. */
22538
23452
  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. */
23453
+ /**
23454
+ * The loop's network and sites for agentpipe's `resolve` and `arbitrate` (§1.14), on the commands that build those
23455
+ * steps: `run` (implement, and the dry run before it), `review --fix` and `address`. A run continued from `checks` or
23456
+ * `feedback` runs only `address`, previewed with implement's dry run, which builds the two steps from the same config
23457
+ * (AGE-193 D21). None for a run that only merges (no dry run, no model), or with the network off.
23458
+ */
23459
+ function settingsOf(run) {
23460
+ const settings = callerSettingsOf(run.plan.options);
23461
+ if (!settings || !previewed(run)) return null;
23462
+ return {
23463
+ settings,
23464
+ commands: run.plan.from ? ["run", "address"] : [
23465
+ "run",
23466
+ "review --fix",
23467
+ "address"
23468
+ ]
23469
+ };
23470
+ }
23471
+ /** `agentpipe review` on the pull request, fixing what it finds, on the loop's tier when it names one, with its flags. */
22540
23472
  function reviewArgs(run, pr, budgetUsd) {
22541
23473
  const tier = options(run).reviewTier;
22542
23474
  return [
@@ -22547,7 +23479,8 @@ function reviewArgs(run, pr, budgetUsd) {
22547
23479
  "--json",
22548
23480
  "--budget",
22549
23481
  usd(budgetUsd),
22550
- ...tier ? ["--tier", tier] : []
23482
+ ...tier ? ["--tier", tier] : [],
23483
+ ...flagsFor(run, "review --fix")
22551
23484
  ];
22552
23485
  }
22553
23486
  /**
@@ -22570,7 +23503,10 @@ function checksArgs(run, pr, budgetUsd, { force = false, deadline = options(run)
22570
23503
  ...force ? ["--force"] : []
22571
23504
  ];
22572
23505
  }
22573
- /** `agentpipe address --apply --ship --no-merge`: answers the review comments, then sees CI green again. */
23506
+ /**
23507
+ * `agentpipe address --apply --ship --no-merge`: answers the review comments, then sees CI green again, with the
23508
+ * loop's flags (its ship loop never merges, so `--accept-decisions` there only announces this run's decisions).
23509
+ */
22574
23510
  function feedbackArgs(run, pr, budgetUsd) {
22575
23511
  return [
22576
23512
  "address",
@@ -22581,13 +23517,16 @@ function feedbackArgs(run, pr, budgetUsd) {
22581
23517
  "--no-merge",
22582
23518
  "--json",
22583
23519
  "--budget",
22584
- usd(budgetUsd)
23520
+ usd(budgetUsd),
23521
+ ...flagsFor(run, "address")
22585
23522
  ];
22586
23523
  }
22587
23524
  /**
22588
23525
  * `agentpipe merge --expect-run`: merges the pull request only if it is the one this machine's run opened (its
22589
23526
  * 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`).
23527
+ * one (§1.7). A refusal says what a person does next (`unblocking`). A loop that accepts at merge passes
23528
+ * `--accept-decisions` (§1.15): agentpipe accepts each decision of a run on the pull request that announced it, and
23529
+ * still holds the ones a person must read (`waitsBecause`), which go to the loop's page as any other.
22591
23530
  */
22592
23531
  function mergeArgs(run, pr, runId) {
22593
23532
  return [
@@ -22596,12 +23535,14 @@ function mergeArgs(run, pr, runId) {
22596
23535
  run.workdir,
22597
23536
  "--expect-run",
22598
23537
  runId,
22599
- "--json"
23538
+ "--json",
23539
+ ...flagsFor(run, "merge")
22600
23540
  ];
22601
23541
  }
22602
23542
  /**
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.
23543
+ * `agentpipe ratify`: accepts one provisional decision of a run on the pull request (its own: ids repeat across runs,
23544
+ * AGE-219), at a commit. With `--json` (agentpipe 0.13.0, AGE-218) it ends on one `run.end`: `ok` (`ratified`), or
23545
+ * `refused` with one sentence.
22605
23546
  */
22606
23547
  function ratifyArgs(decision, runId, headSha) {
22607
23548
  return [
@@ -22616,19 +23557,20 @@ function ratifyArgs(decision, runId, headSha) {
22616
23557
  ];
22617
23558
  }
22618
23559
  /**
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.
23560
+ * Continued after a person accepted the last run's decisions in the browser: each ratified against its own run
23561
+ * (MON-302; a plain id, from a server before it, is the run that opened the pull request's) at the commit they read,
23562
+ * so a merge of anything newer still refuses (agentpipe binds a ratification to its commit). How it stopped, or null
23563
+ * when agentpipe took them all.
22622
23564
  */
22623
23565
  async function ratify(ctx, runId, accept) {
22624
- for (const decision of accept.decisions) {
22625
- const ratified = await ctx.agentpipe(ratifyArgs(decision, runId, accept.headSha));
23566
+ for (const decision of accept.decisions.map((d) => acceptedOf(d, runId))) {
23567
+ const ratified = await ctx.agentpipe(ratifyArgs(decision.id, decision.run, accept.headSha));
22626
23568
  if (ratified.ending?.status === "cancelled") return endOf(ratified, "agentpipe ratify");
22627
23569
  const { exit } = ratified;
22628
23570
  const said = exit.spawnError ?? (ratified.ending ? ratified.reason : exit.lastError);
22629
23571
  if (exit.code !== 0) return {
22630
23572
  status: "needs_human",
22631
- message: notRatified(decision, said)
23573
+ message: notRatified(decision.id, said)
22632
23574
  };
22633
23575
  }
22634
23576
  return null;
@@ -22733,7 +23675,7 @@ function unblocking(reason, blocked) {
22733
23675
  const checks = blocked?.check === "checks_pending" || blocked?.check === "checks_failed";
22734
23676
  if (!checks && said.includes("`")) return said;
22735
23677
  const next = checks ? NEXT.checks : NEXT.settled;
22736
- return `${clip(sentence(said), RUN_REASON - next.length - 1)} ${next}`;
23678
+ return `${clip$1(sentence(said), RUN_REASON - next.length - 1)} ${next}`;
22737
23679
  }
22738
23680
  /** A step's ending from how its command ended: agentpipe's word, else why it stopped without one. */
22739
23681
  function endOf(result, what) {
@@ -22768,6 +23710,9 @@ const deliver = {
22768
23710
  pollSeconds: 15,
22769
23711
  run: async (ctx) => {
22770
23712
  if (!ctx.run.ref) return failed("A deliver run needs its task.");
23713
+ const closes = ctx.run.plan.closes;
23714
+ const stopped = closes ? await closeFirst(ctx, closes) : null;
23715
+ if (stopped) return stopped;
22771
23716
  return endOf(await ctx.agentpipe(implementArgs(ctx.run, ctx.budgetUsd)), "agentpipe run");
22772
23717
  }
22773
23718
  },
@@ -22816,6 +23761,7 @@ const deliver = {
22816
23761
  const merged = await ctx.agentpipe(mergeArgs(ctx.run, pr, ctx.runId));
22817
23762
  if (merged.blocked?.check === "checks_pending") return checksPending(ctx, pr, merged);
22818
23763
  const end = endOf(merged, "agentpipe merge");
23764
+ if (end.code === "accept_switch_off") return end;
22819
23765
  return end.status === "needs_human" ? {
22820
23766
  ...end,
22821
23767
  message: unblocking(end.message, merged.blocked)
@@ -22825,7 +23771,13 @@ const deliver = {
22825
23771
  },
22826
23772
  dryRun: (run) => previewed(run) ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
22827
23773
  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"] : []],
23774
+ settings: settingsOf,
23775
+ needs: (run) => [
23776
+ ...previewed(run) && options(run).askMinutes > 0 ? ["run.ask_window"] : [],
23777
+ ...run.plan.accept ? ["ratify.json"] : [],
23778
+ ...flagged(run),
23779
+ ...run.plan.closes ? CLOSE_NEEDS : []
23780
+ ],
22829
23781
  finished: ({ pr, last }) => {
22830
23782
  if (!pr) return null;
22831
23783
  if (last?.step === "merge" && last.status === "ok") return last.message ?? "Merged.";
@@ -23003,10 +23955,8 @@ function runRecipe(name, run, report, deps) {
23003
23955
  const innerAttempts = /* @__PURE__ */ new Map();
23004
23956
  /** The review comments set aside over the whole run, each once (by its link, else its author and words). */
23005
23957
  const setAside = /* @__PURE__ */ new Map();
23006
- const projectEnv = {
23007
- ...deps.env,
23008
- MONOBAN_PROJECT: run.project
23009
- };
23958
+ /** What the run hands agentpipe (`runEnv` puts it on the commands that apply it). */
23959
+ const settings = recipe?.settings?.(run) ?? null;
23010
23960
  const command = (outer) => async (args) => {
23011
23961
  if (cancelled) return {
23012
23962
  ending: {
@@ -23026,7 +23976,8 @@ function runRecipe(name, run, report, deps) {
23026
23976
  filed: [],
23027
23977
  counts: null,
23028
23978
  blocked: null,
23029
- setAside: []
23979
+ setAside: [],
23980
+ closed: null
23030
23981
  };
23031
23982
  let externalId = null;
23032
23983
  let prUrl = null;
@@ -23045,7 +23996,7 @@ function runRecipe(name, run, report, deps) {
23045
23996
  ...e,
23046
23997
  ...step && { step },
23047
23998
  ...attempt !== null && { attempt },
23048
- ...e.message && { message: clip(e.message) }
23999
+ ...e.message && { message: clip$1(e.message) }
23049
24000
  });
23050
24001
  },
23051
24002
  update: (u) => {
@@ -23087,13 +24038,22 @@ function runRecipe(name, run, report, deps) {
23087
24038
  if (noted || !leased || !pid || event.kind === "ship.end") return;
23088
24039
  noted = safely(() => leases.started(leased.url, pid));
23089
24040
  };
24041
+ const given = runEnv(run, settings, deps, args);
24042
+ const applying = callerCommandOf(args) !== null;
24043
+ const sent = settings && given.callerSettings !== null ? settings.settings : null;
23090
24044
  const started = agentpipeCommand({
23091
24045
  command: deps.command,
23092
24046
  args,
23093
24047
  cwd: run.workdir,
23094
- env: projectEnv,
24048
+ ...given,
23095
24049
  monobanBin: deps.monobanBin,
23096
24050
  map: (event) => {
24051
+ if (applying && event.kind === "run.start") for (const { message, data } of callerDifferences(event.data?.caller, sent)) report.event({
24052
+ kind: "warning",
24053
+ step: outer,
24054
+ message: clip$1(message),
24055
+ data
24056
+ });
23097
24057
  feed.take(event);
23098
24058
  if (current) current.externalId = externalId;
23099
24059
  watch(event);
@@ -23132,7 +24092,8 @@ function runRecipe(name, run, report, deps) {
23132
24092
  filed: feed.filed(),
23133
24093
  counts: feed.counts(),
23134
24094
  blocked: feed.blocked(),
23135
- setAside: feed.setAside()
24095
+ setAside: feed.setAside(),
24096
+ closed: feed.closed()
23136
24097
  };
23137
24098
  };
23138
24099
  /**
@@ -23145,13 +24106,13 @@ function runRecipe(name, run, report, deps) {
23145
24106
  for (const { step, author, reason, url, said } of setAside.values()) report.event({
23146
24107
  kind: "warning",
23147
24108
  step,
23148
- message: clip(`Set aside a review comment by ${author} (${reason})`),
24109
+ message: clip$1(`Set aside a review comment by ${author} (${reason})`),
23149
24110
  data: {
23150
24111
  setAside: true,
23151
24112
  author: author.slice(0, 200),
23152
24113
  reason: reason.slice(0, 200),
23153
24114
  url: url && url.length <= 2e3 ? url : null,
23154
- opening: said ? clip(said, 500) : null
24115
+ opening: said ? clip$1(said, 500) : null
23155
24116
  }
23156
24117
  });
23157
24118
  };
@@ -23219,10 +24180,27 @@ function runRecipe(name, run, report, deps) {
23219
24180
  report.event({
23220
24181
  kind: "warning",
23221
24182
  step: stepName,
23222
- message: clip(message)
24183
+ message: clip$1(message)
23223
24184
  });
23224
24185
  }
23225
- }
24186
+ },
24187
+ prClosed: async (p) => {
24188
+ try {
24189
+ await deps.prClosed?.(p.url);
24190
+ } catch (err) {
24191
+ const message = `Couldn't set the task's link to #${p.number} closed: ${err.message}`;
24192
+ report.event({
24193
+ kind: "warning",
24194
+ step: stepName,
24195
+ message: clip$1(message)
24196
+ });
24197
+ }
24198
+ },
24199
+ note: (message) => report.event({
24200
+ kind: "board",
24201
+ step: stepName,
24202
+ message: clip$1(message)
24203
+ })
23226
24204
  };
23227
24205
  finishing = Boolean(s.finishes);
23228
24206
  const out = await step(stepName, () => s.run(ctx));
@@ -23245,7 +24223,7 @@ function runRecipe(name, run, report, deps) {
23245
24223
  if (out.status === "ok" || out.status === "skipped") continue;
23246
24224
  return {
23247
24225
  status: out.status === "needs_human" || out.status === "cancelled" ? out.status : "failed",
23248
- reason: out.message ? clip(out.message, 1e3) : null,
24226
+ reason: out.message ? clip$1(out.message, 1e3) : null,
23249
24227
  ...out.code && { code: out.code }
23250
24228
  };
23251
24229
  }
@@ -23258,7 +24236,7 @@ function runRecipe(name, run, report, deps) {
23258
24236
  };
23259
24237
  })().catch((err) => ({
23260
24238
  status: "failed",
23261
- reason: clip(`The run stopped: ${err.message}`, 1e3)
24239
+ reason: clip$1(`The run stopped: ${err.message}`, 1e3)
23262
24240
  })).then((ending) => {
23263
24241
  reportSetAside();
23264
24242
  return ending;
@@ -23281,11 +24259,11 @@ function runRecipe(name, run, report, deps) {
23281
24259
  };
23282
24260
  if (refusedAsLate(said)) return {
23283
24261
  outcome: "too_late",
23284
- message: clip(`Too late: ${said}`, 1e3)
24262
+ message: clip$1(`Too late: ${said}`, 1e3)
23285
24263
  };
23286
24264
  return {
23287
24265
  outcome: "refused",
23288
- message: clip(`agentpipe didn't take your answer to ${a.questionId}: ${said ?? `exit code ${code ?? "none"}`}`, 1e3)
24266
+ message: clip$1(`agentpipe didn't take your answer to ${a.questionId}: ${said ?? `exit code ${code ?? "none"}`}`, 1e3)
23289
24267
  };
23290
24268
  },
23291
24269
  cancel: async () => {
@@ -23333,9 +24311,10 @@ const DEFINITIONS = {
23333
24311
  */
23334
24312
  async function detectAgents(settings, env, version = versionOf) {
23335
24313
  const names = settings.agents ?? Object.keys(AGENTS$1);
24314
+ const { [CALLER_SETTINGS]: _inherited, ...asked } = env;
23336
24315
  const checked = await Promise.all(names.map(async (name) => ({
23337
24316
  name,
23338
- version: await version(settings.commands[name], env)
24317
+ version: await version(settings.commands[name], asked)
23339
24318
  })));
23340
24319
  const found = [];
23341
24320
  const missing = [];
@@ -23460,13 +24439,21 @@ function runBoard(api) {
23460
24439
  // src/runner/recipes/preflight.ts
23461
24440
  /**
23462
24441
  * 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.
24442
+ * words for it; any other refusal is `agentpipe_refused`. agentpipe says a `check` for each refusal (0.12.0 on); 0.14.0
24443
+ * adds a caller's settings' (`caller_*`, AGE-194), whose words name the step or the site, the file and the line to
24444
+ * change. 0.15.0 adds the owner's switches' (`advisor_not_allowed`, `accept_decisions_not_allowed`), which are monoban's
24445
+ * own sentence, naming the key and the file (SWITCHES_OFF, MON-268).
23465
24446
  */
23466
24447
  const PREVIEW_CHECKS = {
23467
24448
  signed_out: "agent_signed_out",
23468
24449
  unpushable: "cannot_push",
23469
- ungated: "commands_unverified"
24450
+ ungated: "commands_unverified",
24451
+ caller_settings_invalid: "sites_invalid",
24452
+ caller_step_not_eligible: "sites_step_ineligible",
24453
+ caller_nothing_fetched: "sites_nothing_fetched",
24454
+ caller_site_not_permitted: "site_not_permitted",
24455
+ advisor_not_allowed: "advisor_switch_off",
24456
+ accept_decisions_not_allowed: "accept_switch_off"
23470
24457
  };
23471
24458
  const refusal = (reason, code = null) => ({
23472
24459
  reason,
@@ -23484,6 +24471,12 @@ const refusal = (reason, code = null) => ({
23484
24471
  * 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
24472
  * agentpipe has (`capabilities <folder> --json`, AGE-127), as must every flag the loop's options need (before the
23486
24473
  * dry run, which would only say it has no such option).
24474
+ *
24475
+ * A run with settings for agentpipe (a deliver loop's network and sites, §1.14) needs an agentpipe that takes them in
24476
+ * the variable the runner writes, on every command of the run that gets them (`capabilities`' `caller_settings`,
24477
+ * AGE-196: an older one would refuse the variable as an unknown setting, in other words). Its dry run gets them too,
24478
+ * and must show `resolve` and `arbitrate` held to them (AGE-194); a refusal by them (its `caller_*` checks) is
24479
+ * agentpipe's sentence, which names the site or the step, the file and the line to change.
23487
24480
  */
23488
24481
  async function preflight(run, recipe, deps) {
23489
24482
  let asked = null;
@@ -23494,38 +24487,85 @@ async function preflight(run, recipe, deps) {
23494
24487
  const needs = recipe.needs?.(run) ?? [];
23495
24488
  if (needs.length) {
23496
24489
  const said = await capabilities();
23497
- const missing = needs.filter((need) => {
24490
+ const flags = needs.flatMap((need) => {
24491
+ if (need in FLAGS) return missingFlag(said, need);
23498
24492
  const [command = "", flag = ""] = need.split(".");
23499
- return said?.commands?.[command]?.[flag] !== true;
24493
+ return said?.commands?.[command]?.[flag] === true ? [] : [`\`${command} --${flag.replaceAll("_", "-")}\``];
23500
24494
  });
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");
24495
+ if (flags.length) {
24496
+ 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.`;
24497
+ return refusal(clip$1(onRunnersMachine(said, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
23507
24498
  }
23508
24499
  }
24500
+ const settings = recipe.settings?.(run) ?? null;
24501
+ if (settings) {
24502
+ const refused = takesSettings(await capabilities(), settings, deps.runner ?? "this runner");
24503
+ if (refused) return refused;
24504
+ }
23509
24505
  const args = recipe.dryRun(run);
23510
24506
  if (args) {
23511
- const refused = await dryRun(run, args, recipe.sandboxed ?? null, deps);
24507
+ const refused = await dryRun(run, args, recipe.sandboxed ?? null, settings, deps);
23512
24508
  if (refused) return refused;
23513
24509
  }
23514
24510
  const tier = recipe.tier?.(run) ?? null;
23515
24511
  if (tier) {
23516
24512
  const said = await capabilities();
23517
24513
  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");
24514
+ 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
24515
  }
23520
24516
  return null;
23521
24517
  }
23522
- async function dryRun(run, args, only, deps) {
24518
+ /**
24519
+ * The commands a loop option's flag must be on (FLAGS: the advisor on `run`, `review --fix` and `address`; accepting
24520
+ * at merge on those and `merge`) that the folder's agentpipe doesn't list for it (`capabilities`' `advisor` and
24521
+ * `accept_decisions`, agentpipe 0.15.0), each as the command line it lacks; none when it has them all. Its own name
24522
+ * for the flag must be ours: a different one is none at all.
24523
+ */
24524
+ function missingFlag(said, need) {
24525
+ const { flag, commands } = FLAGS[need];
24526
+ const has = said?.[need];
24527
+ const listed = has && has.flag === flag && Array.isArray(has.commands) ? has.commands : [];
24528
+ return commands.filter((c) => !listed.includes(c)).map((c) => `\`${c} ${flag}\``);
24529
+ }
24530
+ /** Whether a list agentpipe said holds every one of `wanted`. */
24531
+ const holds = (said, wanted) => Array.isArray(said) && wanted.every((w) => said.includes(w));
24532
+ /**
24533
+ * Whether the folder's agentpipe takes the run's settings (`capabilities`' `caller_settings`, AGE-196): in the
24534
+ * variable the runner writes (a different name refuses the run: what agentpipe prints never chooses which variable
24535
+ * the runner writes), with both steps and both fields, on every command of the run that gets them. Null when it does.
24536
+ */
24537
+ function takesSettings(said, settings, runner) {
24538
+ const caller = said?.caller_settings;
24539
+ const variable = caller?.variable;
24540
+ if (caller && typeof variable === "string" && variable !== "AGENTPIPE_CALLER_SETTINGS") {
24541
+ 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`;
24542
+ return refusal(clip$1(onRunnersMachine(sentence, "monoban agentpipe update"), 1e3), "agentpipe_outdated");
24543
+ }
24544
+ if (variable === "AGENTPIPE_CALLER_SETTINGS" && holds(caller?.steps, CALLER_STEPS) && holds(caller?.fields, CALLER_FIELDS) && holds(caller?.commands, settings.commands)) return null;
24545
+ 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");
24546
+ }
24547
+ /**
24548
+ * The dry run's `resolve` and `arbitrate` against the run's settings (AGE-194): each shown, with the network on, the
24549
+ * run's sites, only the reading tools and WebFetch, and its reads held to the worktree. Null when they are.
24550
+ */
24551
+ function heldToSettings(steps, sent, runner) {
24552
+ const off = CALLER_STEPS.flatMap((name) => {
24553
+ const boundary = steps.find((s) => s.name === name)?.boundary;
24554
+ if (!boundary) return [`${name} isn't shown`];
24555
+ const differences = boundaryDifferences(boundary, sent.steps[name]);
24556
+ return differences.length ? [`${name}: ${differences.join(", ")}`] : [];
24557
+ });
24558
+ if (!off.length) return null;
24559
+ 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");
24560
+ }
24561
+ async function dryRun(run, args, only, settings, deps) {
23523
24562
  let preview = null;
24563
+ const given = runEnv(run, settings, deps, args);
23524
24564
  const exit = await agentpipeCommand({
23525
24565
  command: deps.command,
23526
24566
  args,
23527
24567
  cwd: run.workdir,
23528
- env: deps.env,
24568
+ ...given,
23529
24569
  monobanBin: deps.monobanBin,
23530
24570
  map: (event) => {
23531
24571
  if (event.kind === "run.preview") preview = event.data ?? {};
@@ -23537,19 +24577,24 @@ async function dryRun(run, args, only, deps) {
23537
24577
  if (exit.code !== 0) {
23538
24578
  const refusals = (said?.refusals ?? []).filter((r) => typeof r.message === "string" && r.message);
23539
24579
  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");
24580
+ const code = refusals.map((r) => typeof r.check === "string" ? PREVIEW_CHECKS[r.check] : void 0).find(Boolean) ?? "agentpipe_refused";
24581
+ const theirs = refusals.filter((r) => !switchOff(r.check)).map((r) => r.message);
24582
+ const switches = refusals.flatMap((r) => switchOff(r.check)?.reason ?? []);
24583
+ const words = theirs.length ? `agentpipe won't start it: ${theirs.join("; ")}` : null;
24584
+ if (!switches.length) return refusal(clip$1(words ?? "", 1e3), code);
24585
+ return refusal(clip$1([...words ? [sentence(words)] : [], ...switches].join(" "), 1e3), code);
23542
24586
  }
23543
24587
  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");
24588
+ return refusal(clip$1(`agentpipe's dry run refused it (exit code ${exit.code ?? "none"})${last}`, 1e3), "agentpipe_refused");
23545
24589
  }
23546
24590
  if (!said) return refusal("agentpipe's dry run didn't say what the run would do, so its sandbox can't be checked.");
23547
24591
  const steps = said.steps ?? [];
23548
24592
  const unseen = (only ?? []).filter((name) => !steps.some((s) => s.name === name && s.boundary));
23549
24593
  if (unseen.length) return refusal(`agentpipe's dry run didn't show ${unseen.join(", ")}, so its sandbox can't be checked.`);
23550
24594
  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");
24595
+ 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
24596
  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");
24597
+ if (settings && given.callerSettings !== null) return heldToSettings(steps, settings.settings, deps.runner ?? "this runner");
23553
24598
  return null;
23554
24599
  }
23555
24600
  // src/runner/spend.ts
@@ -23598,6 +24643,19 @@ function spendInMemory(now = Date.now) {
23598
24643
  }
23599
24644
  };
23600
24645
  }
24646
+ // src/runner/poll.ts
24647
+ /**
24648
+ * What this runner says it can do beyond its recipes (contract's `RUNNER_FEATURES`, the names the API knows), when it
24649
+ * registers and at each check-in. A name is said only once this runner does it: a loop that needs one is handed only
24650
+ * to a runner that says it. `sites`: it hands a loop's network and sites to agentpipe (MON-250); `advisor`: a loop's
24651
+ * advisor and accepting at merge, as agentpipe's flags (MON-268); `start-over`: it closes a task's pull request through
24652
+ * agentpipe before it runs the task again (MON-292).
24653
+ */
24654
+ const SAYS = [
24655
+ "sites",
24656
+ "advisor",
24657
+ "start-over"
24658
+ ];
23601
24659
  const sleepFor = (ms, signal) => new Promise((resolve) => {
23602
24660
  if (signal.aborted) return resolve();
23603
24661
  const timer = setTimeout(resolve, ms);
@@ -23639,7 +24697,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
23639
24697
  return await unwrap(api.POST("/v1/runners", { body: {
23640
24698
  ...body,
23641
24699
  recipes,
23642
- features: [...RUNNER_FEATURES]
24700
+ features: [...SAYS]
23643
24701
  } }));
23644
24702
  } catch (err) {
23645
24703
  if (!(err instanceof ApiProblem && err.status === 400)) throw err;
@@ -23677,7 +24735,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
23677
24735
  return await heartbeat(api, runner.id, {
23678
24736
  recipes,
23679
24737
  free,
23680
- features: [...RUNNER_FEATURES],
24738
+ features: [...SAYS],
23681
24739
  loops
23682
24740
  });
23683
24741
  } catch (err) {
@@ -23894,7 +24952,10 @@ async function runRunner(ctx, settings, deps, options = {}) {
23894
24952
  const problem = await deps.workdirProblem(run.workdir, run.project);
23895
24953
  if (problem) return refuse("failed", problem, "folder_refused");
23896
24954
  if (loopRun && recipe && deps.agentpipe) {
23897
- const refused = await preflight(loopRun, recipe, deps.agentpipe);
24955
+ const refused = await preflight(loopRun, recipe, {
24956
+ ...deps.agentpipe,
24957
+ runner: runner.name
24958
+ });
23898
24959
  if (refused) return refuse("failed", refused.reason, refused.code);
23899
24960
  }
23900
24961
  const what = ref ?? `a ${run.recipe} run`;
@@ -23926,7 +24987,8 @@ async function runRunner(ctx, settings, deps, options = {}) {
23926
24987
  ...deps.agentpipe,
23927
24988
  recheck: () => recheck(run.id),
23928
24989
  mayMerge: () => mayMerge(run.id),
23929
- prReady: (url) => prReady(ref, url),
24990
+ prReady: (url) => prLink(ref, url, "open"),
24991
+ prClosed: (url) => prLink(ref, url, "closed"),
23930
24992
  onStep: (seconds) => {
23931
24993
  stepSeconds = seconds ?? settings.pollSeconds;
23932
24994
  self.pollSeconds = stepSeconds;
@@ -23996,9 +25058,11 @@ async function runRunner(ctx, settings, deps, options = {}) {
23996
25058
  /**
23997
25059
  * agentpipe said the run's pull request is ready (`ready_to_merge`, from `checks` or `feedback`): the task's link to
23998
25060
  * 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.
25061
+ * closed. Or it closed one to start the task over (`close.completed`, MON-292), which it doesn't attach again: the
25062
+ * link says `closed`, so the task's next start isn't refused as `pr_open`. The URL and the state only: the link
25063
+ * keeps the title agentpipe gave it. Throws when the board refused.
24000
25064
  */
24001
- async function prReady(ref, url) {
25065
+ async function prLink(ref, url, state) {
24002
25066
  if (!ref) return;
24003
25067
  const { key, number } = taskRefOf(ref);
24004
25068
  await unwrap(api.POST("/v1/projects/{key}/tasks/{number}/links", {
@@ -24008,7 +25072,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
24008
25072
  } },
24009
25073
  body: {
24010
25074
  url,
24011
- state: "open"
25075
+ state
24012
25076
  }
24013
25077
  }));
24014
25078
  }
@@ -24601,7 +25665,7 @@ function describe(ctx, { state, running }, board, stuck, now) {
24601
25665
  const seenAgo = `checked in ${since(board.lastSeenAt, now)} ago (every ${board.pollSeconds}s)`;
24602
25666
  row("board", `${board.online ? "online" : "offline"} · ${seenAgo}`);
24603
25667
  } else if (!state.runnerId) row("board", "not on the board yet: it's starting");
24604
- if (state.version !== "1.15.0") {
25668
+ if (state.version !== "1.16.0") {
24605
25669
  const again = state.background ? "`monoban runner restart`" : "start it again in its terminal";
24606
25670
  row("update", `it runs monoban ${state.version}, this is ${VERSION}: ${again}`);
24607
25671
  }
@@ -25060,7 +26124,7 @@ async function checks(ctx, deps = {}) {
25060
26124
  const found = [];
25061
26125
  const latest = await (deps.latest ?? latestVersion)(ctx);
25062
26126
  const upgrade = UPGRADE[thisInstall()].command;
25063
- found.push(latest && newer(latest, "1.15.0") ? {
26127
+ found.push(latest && newer(latest, "1.16.0") ? {
25064
26128
  name: "monoban",
25065
26129
  status: "warn",
25066
26130
  detail: `${VERSION}; ${latest} is out`,
@@ -25972,7 +27036,13 @@ machine allows a run to turn it off. Settings can also go in runner.json in the
25972
27036
  {"pollSeconds": 60, "allow": ["/Users/me/code"], "confirm": false, "agents": ["claude"],
25973
27037
  "adapters": {"claude": {"command": "claude", "args": []}, "codex": {"allowFullAccess": false}},
25974
27038
  "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));
27039
+ too when agentpipe can run them: --no-loops, or "enabled": false, says no; "merge": false never merges here.
27040
+ A loop with its network on lets its runs' resolve and arbitrate steps (which answer questions and settle
27041
+ disagreements) read pages from the loop's sites, nothing else: they gain WebFetch alone and read only the
27042
+ repository. The runner hands the sites to agentpipe in AGENTPIPE_CALLER_SETTINGS, on the commands that build
27043
+ those steps; it sets that variable itself, and one in its own environment never reaches agentpipe. This machine
27044
+ permits only the sites listed in permitted_sites under [callers] in ~/.agentpipe/config.toml (empty as agentpipe
27045
+ ships), and a run with any other site doesn't start.`).action(async (options) => runner(await ctx(), options));
25976
27046
  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
27047
  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
27048
  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));