monoban 1.11.0 → 1.13.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 +350 -32
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -5954,6 +5954,8 @@ const LOOP_DEFAULTS = {
5954
5954
  merge: true,
5955
5955
  deliverMaxOpen: 1,
5956
5956
  checksMinutes: 60,
5957
+ /** deliver: a run decides the questions only you can settle on its own, at once (no wait for your answer). */
5958
+ askMinutes: 0,
5957
5959
  /** deliver: agentpipe's own tier for its review step. */
5958
5960
  reviewTier: null,
5959
5961
  scavengeMaxOpen: 5
@@ -6365,7 +6367,8 @@ const PROBLEM_CODES = [
6365
6367
  "email_not_sent",
6366
6368
  "loops_off",
6367
6369
  "nothing_to_do",
6368
- "pr_open"
6370
+ "pr_open",
6371
+ "too_late"
6369
6372
  ];
6370
6373
  const CODES = new Set(PROBLEM_CODES);
6371
6374
  const isString = (v) => typeof v === "string";
@@ -6453,7 +6456,8 @@ const RUN_EVENT_KINDS = [
6453
6456
  "question",
6454
6457
  "warning",
6455
6458
  "error",
6456
- "activity"
6459
+ "activity",
6460
+ "answer"
6457
6461
  ];
6458
6462
  /** Where a run works. Only on the runner's machine for now; remote (a fresh clone) comes later. */
6459
6463
  const RUN_MODES = ["local"];
@@ -6469,6 +6473,10 @@ const RUN_LIMITS = {
6469
6473
  eventsPerBatch: 200,
6470
6474
  eventMessage: 2e3,
6471
6475
  reason: 1e3,
6476
+ /** An answer to a run's question (the check on task_run_answers.answer). */
6477
+ answer: 2e3,
6478
+ /** Answers per run (guard_task_run_answer). */
6479
+ answersPerRun: 100,
6472
6480
  workdir: 1024,
6473
6481
  runnerName: 64,
6474
6482
  runnersPerUser: 20
@@ -6485,6 +6493,17 @@ function formatDuration(ms) {
6485
6493
  if (minutes < 60) return `${minutes}m${String(seconds % 60).padStart(2, "0")}`;
6486
6494
  return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, "0")}`;
6487
6495
  }
6496
+ /** A question's id, as agentpipe names it (`plan-2`): never an option (the check on task_run_answers.question_id). */
6497
+ const QUESTION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
6498
+ /**
6499
+ * What came of an answer you sent (an `answer` event, MON-259): it reached the run; it came after the run stopped
6500
+ * waiting for it (agentpipe decided it on its own); or agentpipe refused it.
6501
+ */
6502
+ const ANSWER_OUTCOMES = [
6503
+ "reached",
6504
+ "too_late",
6505
+ "refused"
6506
+ ];
6488
6507
  /** A step's mark in a list: ✓ ok, ● running, ✗ failed, – skipped, ■ cancelled, ? needs you. */
6489
6508
  const STEP_MARKS = {
6490
6509
  running: "●",
@@ -7022,6 +7041,13 @@ const loopCommon = {
7022
7041
  /** Runs in a row that failed or need you before it pauses itself. */
7023
7042
  pauseAfter: wholeBetween(LOOP_LIMITS.pauseAfter)
7024
7043
  };
7044
+ /** ASK_MINUTES, one literal each (`z.literal` of a list keeps only the first in the OpenAPI document). */
7045
+ const ASK_MINUTES_SCHEMA = union([
7046
+ literal(0),
7047
+ literal(5),
7048
+ literal(15),
7049
+ literal(30)
7050
+ ]);
7025
7051
  const deliverFields = {
7026
7052
  ...loopCommon,
7027
7053
  /** The column it takes tasks from. */
@@ -7035,7 +7061,9 @@ const deliverFields = {
7035
7061
  /** How long `checks` waits for CI, in minutes. */
7036
7062
  checksMinutes: wholeBetween(LOOP_LIMITS.checksMinutes),
7037
7063
  /** The agentpipe tier its review step runs on (`--tier`); null: agentpipe's own. */
7038
- reviewTier: string().regex(TIER_NAME, "A tier's name, like light").nullable()
7064
+ reviewTier: string().regex(TIER_NAME, "A tier's name, like light").nullable(),
7065
+ /** How long a run waits for your answer to a question only you can settle, in minutes; 0: it doesn't wait. */
7066
+ askMinutes: ASK_MINUTES_SCHEMA
7039
7067
  };
7040
7068
  const scavengeFields = {
7041
7069
  ...loopCommon,
@@ -7061,7 +7089,8 @@ const DeliverOptionsSchema = strictObject({
7061
7089
  merge: deliverFields.merge.default(LOOP_DEFAULTS.merge),
7062
7090
  maxOpen: deliverFields.maxOpen.default(LOOP_DEFAULTS.deliverMaxOpen),
7063
7091
  checksMinutes: deliverFields.checksMinutes.default(LOOP_DEFAULTS.checksMinutes),
7064
- reviewTier: deliverFields.reviewTier.default(LOOP_DEFAULTS.reviewTier)
7092
+ reviewTier: deliverFields.reviewTier.default(LOOP_DEFAULTS.reviewTier),
7093
+ askMinutes: deliverFields.askMinutes.default(LOOP_DEFAULTS.askMinutes)
7065
7094
  }).refine(budgetFits, {
7066
7095
  message: BUDGET_FITS,
7067
7096
  path: ["budgetUsd"]
@@ -7196,13 +7225,19 @@ const TaskRunSchema = object({
7196
7225
  costUsd: number$1().nullable(),
7197
7226
  /** Someone asked it to stop; it will at its next checkpoint. */
7198
7227
  cancelRequested: boolean(),
7228
+ /**
7229
+ * While it waits for your answer to a question only you can settle (its loop's `askMinutes`, MON-258): until when.
7230
+ * Null when it doesn't wait (its last word is something else, it's not running, or its runner went quiet); it
7231
+ * stops waiting at that time even if this still says it does. `POST …/questions/{questionId}/answer` takes an
7232
+ * answer only while this is in the future.
7233
+ */
7234
+ waitingUntil: Timestamp.nullable(),
7199
7235
  version: Version,
7200
7236
  createdAt: Timestamp,
7201
7237
  startedAt: Timestamp.nullable(),
7202
7238
  finishedAt: Timestamp.nullable(),
7203
7239
  updatedAt: Timestamp
7204
7240
  }).meta({ id: "TaskRun" });
7205
- TaskRunSchema.extend({ steps: array(RunStepSchema) }).meta({ id: "TaskRunDetail" });
7206
7241
  /** A run for a runner to start: with what it needs to check the folder (the project's key and repo). */
7207
7242
  /** A run's project, for the runner to check the folder against (its key, and the repository it's linked to). */
7208
7243
  const RunProjectSchema = object({
@@ -7210,6 +7245,29 @@ const RunProjectSchema = object({
7210
7245
  repo: string().nullable()
7211
7246
  }).meta({ id: "RunProject" });
7212
7247
  const RunToStartSchema = TaskRunSchema.extend({ project: RunProjectSchema }).meta({ id: "RunToStart" });
7248
+ string().regex(QUESTION_ID, "A question's id, like plan-2").meta({ example: "plan-2" });
7249
+ union([strictObject({ text: text().min(1, "Required").max(RUN_LIMITS.answer).regex(/^[^\u0001-\u0008\u000b\u000c\u000e-\u001f\u007f]*$/, "Lines and tabs only, no other control characters") }), strictObject({ skip: literal(true) })]).meta({ id: "RunAnswerCreate" });
7250
+ /** An answer you sent to a run's question: your words, or null for "you decide". What came of it is the run's events. */
7251
+ const RunAnswerSchema = object({
7252
+ id: IdSchema,
7253
+ runId: IdSchema,
7254
+ questionId: string(),
7255
+ text: string().nullable(),
7256
+ createdAt: Timestamp
7257
+ }).meta({ id: "RunAnswer" });
7258
+ /**
7259
+ * An answer you sent, as the run shows it: with what its runner said came of it (its `answer` event): `reached` the
7260
+ * run, `too_late`, or `refused` (with agentpipe's words, in `said`); null until the runner has handed it on.
7261
+ */
7262
+ const RunAnswerOnRunSchema = RunAnswerSchema.extend({
7263
+ outcome: _enum(ANSWER_OUTCOMES).nullable(),
7264
+ /** The runner's words for it (English), or null. */
7265
+ said: string().nullable()
7266
+ }).meta({ id: "RunAnswerOnRun" });
7267
+ TaskRunSchema.extend({
7268
+ steps: array(RunStepSchema),
7269
+ answers: array(RunAnswerOnRunSchema).max(RUN_LIMITS.answersPerRun)
7270
+ }).meta({ id: "TaskRunDetail" });
7213
7271
  /** Run an agent on a task, on one of your runners. */
7214
7272
  /** An absolute path on a runner's machine. */
7215
7273
  const Workdir = string().trim().min(1, "Required").max(RUN_LIMITS.workdir).refine(isAbsolutePath, "An absolute path, like /Users/you/code/project").meta({ pattern: "^/" });
@@ -7293,7 +7351,12 @@ object({
7293
7351
  loopId: IdSchema,
7294
7352
  workdir: string(),
7295
7353
  project: RunProjectSchema
7296
- }).meta({ id: "LoopWaiting" })).optional()
7354
+ }).meta({ id: "LoopWaiting" })).optional(),
7355
+ /**
7356
+ * Answers to its running runs' questions it hasn't said what came of yet (no `answer` event names them), oldest
7357
+ * first: it hands each to agentpipe (`agentpipe answer`) and reports the outcome (MON-259).
7358
+ */
7359
+ answers: array(RunAnswerSchema).optional()
7297
7360
  }).meta({ id: "RunnerWork" });
7298
7361
  /** At least one option, or the patch would change nothing (the refine, for JSON Schema: minProperties). */
7299
7362
  const someOption = (o) => Object.keys(o).length > 0;
@@ -8142,7 +8205,7 @@ function archivedByTime(task, archiveAfterDays, now = Date.now()) {
8142
8205
  }
8143
8206
  // src/version.ts
8144
8207
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
8145
- const VERSION = "1.11.0";
8208
+ const VERSION = "1.13.0";
8146
8209
  /** Sent as X-Monoban-Client, and shown in Settings › CLI sessions. */
8147
8210
  const CLIENT = `cli/${VERSION}`;
8148
8211
  // src/api.ts
@@ -11687,8 +11750,8 @@ const RELEASES = `https://github.com/thiagodmont/homebrew-tap/releases`;
11687
11750
  * agentpipe comes with a new monoban: change these three lines (from the release's checksums.txt) and release.
11688
11751
  */
11689
11752
  const AGENTPIPE = {
11690
- version: "0.10.0",
11691
- wheelSha256: "19f73117601ab8dabc8caabf63f6777c8eecf114e7e11acea2d6b40b653200d4",
11753
+ version: "0.11.0",
11754
+ wheelSha256: "7f6920a517bdd8f45f3943fe975b839b36b5a330a89434f62c8ef074ccaa6d6a",
11692
11755
  requirementsSha256: "41a8d073b0087efb80efafeb6a2b4750340d0f64920159cd4c723ed9167d0a98"
11693
11756
  };
11694
11757
  const agentpipeWheel = (version) => `agentpipe-${version}-py3-none-any.whl`;
@@ -11802,7 +11865,7 @@ async function latestVersion(ctx) {
11802
11865
  async function upgrade(ctx, options, kind = thisInstall()) {
11803
11866
  const latest = await latestVersion(ctx);
11804
11867
  const { how, command } = UPGRADE[kind];
11805
- const outdated = latest !== null && newer(latest, "1.11.0");
11868
+ const outdated = latest !== null && newer(latest, "1.13.0");
11806
11869
  if (options.json) {
11807
11870
  ctx.out(JSON.stringify({
11808
11871
  version: VERSION,
@@ -12387,7 +12450,10 @@ const str = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
12387
12450
  const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
12388
12451
  /** A message the API takes: one line or more, at most 2000 characters. */
12389
12452
  const clip$1 = (text) => text.length > 2e3 ? `${text.slice(0, 1999)}…` : text;
12390
- /** `merge.blocked`'s decisions: each with its id, question id, category and answer; anything else is left out. */
12453
+ /**
12454
+ * `merge.blocked`'s decisions (and `merge.completed`'s `accepted`): each with its id, question id, category and answer;
12455
+ * anything else is left out.
12456
+ */
12391
12457
  function decisionsOf(value) {
12392
12458
  if (!Array.isArray(value)) return [];
12393
12459
  return value.flatMap((x) => {
@@ -12450,6 +12516,20 @@ function agentpipeMapper(report) {
12450
12516
  /** `scout --track`: the tasks its `file` step filed (their refs, else their URLs), and `run.end`'s counts. */
12451
12517
  const filed = [];
12452
12518
  let counts = null;
12519
+ /** A window open for your answers (`run --ask-window`): when it closes, and the questions it still waits on. */
12520
+ let asking = null;
12521
+ /** The run's "now" while the window is open: the time it closes in `data` (each reader says it in their own words). */
12522
+ const waiting = (window, step, at) => report.event({
12523
+ kind: "activity",
12524
+ ...step && { step },
12525
+ message: `Waiting for your answer until ${window.until}`,
12526
+ data: {
12527
+ waitingUntil: window.until,
12528
+ questions: window.open.size,
12529
+ ids: [...window.open].join(",")
12530
+ },
12531
+ ...at && { at }
12532
+ });
12453
12533
  const spent = () => report.update({ costUsd: Math.round((total + shipped) * 1e4) / 1e4 });
12454
12534
  const flush = (cost) => {
12455
12535
  if (!pending) return;
@@ -12687,6 +12767,44 @@ function agentpipeMapper(report) {
12687
12767
  });
12688
12768
  return;
12689
12769
  }
12770
+ case "question.prompted": {
12771
+ const seconds = num(d.timeout_s) ?? 0;
12772
+ const ids = Array.isArray(d.ids) ? d.ids.flatMap((id) => str(id) ? [str(id)] : []) : [];
12773
+ if (seconds <= 0 || !ids.length) return;
12774
+ const from = Date.parse(at ?? "");
12775
+ asking = {
12776
+ until: new Date((Number.isNaN(from) ? Date.now() : from) + seconds * 1e3).toISOString(),
12777
+ open: new Set(ids)
12778
+ };
12779
+ waiting(asking, step, at);
12780
+ return;
12781
+ }
12782
+ case "question.settled": {
12783
+ const id = str(d.id);
12784
+ if (!asking || !id || !asking.open.delete(id)) return;
12785
+ if (asking.open.size) {
12786
+ waiting(asking, step, at);
12787
+ return;
12788
+ }
12789
+ asking = null;
12790
+ report.event({
12791
+ kind: "activity",
12792
+ ...step && { step },
12793
+ message: "Answered: it goes on",
12794
+ ...at && { at }
12795
+ });
12796
+ return;
12797
+ }
12798
+ case "question.timeout":
12799
+ if (!asking) return;
12800
+ asking = null;
12801
+ report.event({
12802
+ kind: "activity",
12803
+ ...step && { step },
12804
+ message: "No answer came: it decides on its own",
12805
+ ...at && { at }
12806
+ });
12807
+ return;
12690
12808
  case "error": {
12691
12809
  const text = str(d.message) ?? str(d.kind) ?? "Something went wrong.";
12692
12810
  report.event({
@@ -12722,6 +12840,19 @@ function agentpipeMapper(report) {
12722
12840
  status: "succeeded",
12723
12841
  reason: sha ? `Merged (${sha.slice(0, 7)}).` : "Merged."
12724
12842
  };
12843
+ for (const decision of decisionsOf(d.accepted)) report.event({
12844
+ kind: "question",
12845
+ ...step && { step },
12846
+ message: clip$1(decision.question ?? decision.answer),
12847
+ data: {
12848
+ decisionId: decision.decisionId,
12849
+ questionId: decision.questionId,
12850
+ category: decision.category,
12851
+ answer: decision.answer.slice(0, 2e3),
12852
+ accepted: "setting"
12853
+ },
12854
+ ...at && { at }
12855
+ });
12725
12856
  return;
12726
12857
  }
12727
12858
  case "merge.blocked": {
@@ -12798,7 +12929,12 @@ function agentpipeMapper(report) {
12798
12929
  /** What `scout --track` filed (refs, in order), and the numbers behind how it ended (`run.end`'s counts). */
12799
12930
  filed: () => [...filed],
12800
12931
  counts: () => counts,
12801
- flush: () => flush()
12932
+ flush: () => flush(),
12933
+ /**
12934
+ * Whether the run waits for an answer to this question now, with a moment to spare: agentpipe 0.10.0's `answer`
12935
+ * doesn't check, and settles it whenever it comes, over what the run decided once its window closed.
12936
+ */
12937
+ waitsFor: (questionId, now = Date.now()) => Boolean(asking?.open.has(questionId) && Date.parse(asking.until) - now > 3e3)
12802
12938
  };
12803
12939
  }
12804
12940
  /** One stdout line as an event, or null for agentpipe's plain lines ("profile: cached", the step table). */
@@ -12897,6 +13033,42 @@ function agentpipeCommand({ command = "agentpipe", args, cwd, env, monobanBin =
12897
13033
  }
12898
13034
  });
12899
13035
  }
13036
+ /**
13037
+ * Runs a short agentpipe command (`answer`) to its end: how it ended, and what it printed, on one line (its reason
13038
+ * first, then a hint; rich prints to stdout, and wraps it at the terminal's width unless told a wide one).
13039
+ */
13040
+ const execOutput = (command, args, env) => new Promise((resolve) => execFile(command, args, {
13041
+ timeout: 3e4,
13042
+ env: {
13043
+ ...env,
13044
+ COLUMNS: "1000"
13045
+ },
13046
+ maxBuffer: 1048576
13047
+ }, (err, stdout, stderr) => {
13048
+ const said = `${stdout}\n${stderr}`.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
13049
+ resolve({
13050
+ code: err ? typeof err.code === "number" ? err.code : null : 0,
13051
+ said: said || null
13052
+ });
13053
+ }));
13054
+ /**
13055
+ * `agentpipe answer` for an answer you sent from the browser (MON-259): your words after `--`, so nothing in them is
13056
+ * an option (`--agent-answer` is words here), or `--skip` for "you decide". An argv, never a shell.
13057
+ */
13058
+ function answerArgs(runId, questionId, text) {
13059
+ return text === null ? [
13060
+ "answer",
13061
+ runId,
13062
+ questionId,
13063
+ "--skip"
13064
+ ] : [
13065
+ "answer",
13066
+ runId,
13067
+ questionId,
13068
+ "--",
13069
+ text
13070
+ ];
13071
+ }
12900
13072
  /** Runs a short agentpipe command (`cancel`) to its end, whatever it says. */
12901
13073
  const exec = (command, args, env) => new Promise((resolve) => execFile(command, args, {
12902
13074
  timeout: 3e4,
@@ -17908,6 +18080,11 @@ var en_US_default = {
17908
18080
  "help": "Back to task",
17909
18081
  "keywords": "run runs orchestrator agent progress steps watch"
17910
18082
  },
18083
+ "answer": {
18084
+ "label": "Answer the question {id}'s run asks",
18085
+ "help": "Answer the question task's run asks",
18086
+ "keywords": "answer question run agent loop decide reply"
18087
+ },
17911
18088
  "undo": { "label": "Undo" }
17912
18089
  },
17913
18090
  move: {
@@ -18126,6 +18303,11 @@ var en_US_default = {
18126
18303
  "delete": {
18127
18304
  "label": "Delete {name}",
18128
18305
  "help": "Delete loop"
18306
+ },
18307
+ "accept": {
18308
+ "label": "Accept {ref}'s {count, plural, one {decision} other {# decisions}} and merge",
18309
+ "help": "Accept the decisions a run's merge waits on",
18310
+ "keywords": "accept ratify decision decisions approve merge provisional"
18129
18311
  }
18130
18312
  },
18131
18313
  archive: {
@@ -18259,6 +18441,10 @@ var en_US_default = {
18259
18441
  "reviewTier": "Review on",
18260
18442
  "reviewTierHint": "The models agentpipe reviews the pull request with: its tier (--tier).",
18261
18443
  "reviewTierDefault": "agentpipe's own tier",
18444
+ "askMinutes": "Wait for your answers",
18445
+ "askMinutesHint": "A question only you can settle waits this long for your answer before the run decides it on its own. While it waits, the run keeps its worktree and its runner.",
18446
+ "askNever": "Don't wait: it decides on its own",
18447
+ "askFor": "{minutes} minutes",
18262
18448
  "focus": "What to look for",
18263
18449
  "focusPlaceholder": "Tests that fail now and then, and why",
18264
18450
  "filesIn": "Files tasks in",
@@ -18271,7 +18457,7 @@ var en_US_default = {
18271
18457
  "budgetUsdPerDay": "Budget per day (US$)",
18272
18458
  "pauseAfter": "Pause after runs in a row",
18273
18459
  "summary": {
18274
- "deliver": "Every {interval}, on {runner}, it takes {tagged, select, yes {the tasks tagged #{tag} in {column}} other {every task in {column}}}, one at a time, up to {perDay} a day, and opens a pull request for each. {merge, select, yes {It merges each one when its checks pass.} other {It leaves each one for you to merge.}} It stops taking tasks while {maxOpen, plural, one {# pull request waits} other {# pull requests wait}} for you, spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.",
18460
+ "deliver": "Every {interval}, on {runner}, it takes {tagged, select, yes {the tasks tagged #{tag} in {column}} other {every task in {column}}}, one at a time, up to {perDay} a day, and opens a pull request for each. {merge, select, yes {It merges each one when its checks pass.} other {It leaves each one for you to merge.}} It stops taking tasks while {maxOpen, plural, one {# pull request waits} other {# pull requests wait}} for you, spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.{askMinutes, plural, =0 {} other { It waits up to # minutes for your answer to a question only you can settle.}}",
18275
18461
  "scavenge": "Every {interval}, on {runner}, it looks for: {focus}. It files what it finds in {column}, tagged #{tag}, and stops filing while {maxOpen, plural, one {# of those tasks is} other {# of those tasks are}} open. It spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.",
18276
18462
  "incomplete": "Fill in the fields above to see what the loop will do."
18277
18463
  },
@@ -18321,7 +18507,17 @@ var en_US_default = {
18321
18507
  "queued": "{name} runs at its runner's next check-in.",
18322
18508
  "deleted": "Deleted {name}.",
18323
18509
  "failed": "That didn't work: try again.",
18324
- "continued": "{ref} continues from {step} at its runner's next check-in."
18510
+ "continued": "{ref} continues from {step} at its runner's next check-in.",
18511
+ "accepted": "{ref} merges at its runner's next check-in, with {count, plural, one {the decision} other {the # decisions}} accepted."
18512
+ },
18513
+ decisions: {
18514
+ "label": "{ref}'s merge waits on {count, plural, one {a decision} other {# decisions}} the agent made on its own",
18515
+ "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.",
18516
+ "answer": "Its answer:",
18517
+ "accept": "{count, plural, one {Accept it and merge} other {Accept all # and merge}}",
18518
+ "paused": "The loop is paused: resume it, then accept them here.",
18519
+ "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.",
18520
+ "accepting": "It accepts {count, plural, one {# decision} other {# decisions}} read at {commit}, then merges."
18325
18521
  }
18326
18522
  },
18327
18523
  notes: {
@@ -18550,7 +18746,8 @@ var en_US_default = {
18550
18746
  pr_open: "This task's pull request may still be open: continue it from a step, or close it first.",
18551
18747
  unreachable: "Couldn't reach monoban. Try again.",
18552
18748
  unreachableShort: "Couldn't reach monoban.",
18553
- cantDeleteAccount: "Couldn't delete your account. Try again."
18749
+ cantDeleteAccount: "Couldn't delete your account. Try again.",
18750
+ too_late: "Too late: the run no longer waits for that answer. It decided on its own; accept or change what it decided."
18554
18751
  },
18555
18752
  projects: {
18556
18753
  empty: {
@@ -18760,6 +18957,7 @@ var en_US_default = {
18760
18957
  "noneYet": "none yet",
18761
18958
  "none": "none",
18762
18959
  "now": "now",
18960
+ "waitingForAnswer": "Waiting for your {count, plural, one {answer} other {answers to # questions}} until {time}",
18763
18961
  "reported": "What it reported",
18764
18962
  "yoursToDecide": "only you can decide this",
18765
18963
  "latest": "latest",
@@ -18768,7 +18966,8 @@ var en_US_default = {
18768
18966
  "board": "board",
18769
18967
  "question": "question",
18770
18968
  "warning": "warning",
18771
- "error": "error"
18969
+ "error": "error",
18970
+ "accepted": "accepted"
18772
18971
  },
18773
18972
  "earlierRuns": "earlier runs",
18774
18973
  "earlierRun": "{date} · {status}",
@@ -18780,7 +18979,35 @@ var en_US_default = {
18780
18979
  "cancelled": "cancelled:",
18781
18980
  "needs_human": "needs human:"
18782
18981
  },
18783
- "attempt": "(attempt {n})"
18982
+ "attempt": "(attempt {n})",
18983
+ "questions": {
18984
+ "label": "Questions waiting for you",
18985
+ "heading": "your answers",
18986
+ "closes": "It waits for you until {time}, then decides on its own.",
18987
+ "unknown": "Question {id} (its text isn't among the latest events)",
18988
+ "field": "Your answer to {id}",
18989
+ "placeholder": "Your answer: it reaches the agent as you write it",
18990
+ "send": "Send",
18991
+ "sending": "Sending…",
18992
+ "skip": "You decide",
18993
+ "skipHint": "“You decide” tells it to decide this one on its own, as if no answer came.",
18994
+ "yours": "You answered: {text}",
18995
+ "yoursSkip": "You left it to the run.",
18996
+ "sent": "Sent: its runner hands it on at its next check-in.",
18997
+ "reached": "It reached the run.",
18998
+ "tooLate": "Too late: the run had stopped waiting, so it decided on its own. If a decision only you can make holds its merge, accept it on the run.",
18999
+ "refused": "agentpipe didn't take it: {said}",
19000
+ "unsent": "The run ended before its runner handed this on.",
19001
+ "tooLateNow": "Too late: the run no longer waits for this answer, so it decides on its own. If a decision only you can make holds its merge, accept it on the run.",
19002
+ "answeredAlready": "It was answered already.",
19003
+ "failed": "Couldn't send it."
19004
+ },
19005
+ "accepted": {
19006
+ "label": "{count, plural, one {# decision} other {# decisions}} the repository's setting accepted",
19007
+ "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>.",
19008
+ "answer": "Its answer:",
19009
+ "authority": "only you could decide this, and nobody read it"
19010
+ }
18784
19011
  },
18785
19012
  runners: {
18786
19013
  "title": "Runners",
@@ -18904,6 +19131,7 @@ var en_US_default = {
18904
19131
  "status": {
18905
19132
  "queued": "waiting for the runner",
18906
19133
  "running": "running",
19134
+ "waiting": "waiting for your answer",
18907
19135
  "cancelling": "cancelling",
18908
19136
  "succeeded": "done",
18909
19137
  "failed": "failed",
@@ -19765,8 +19993,9 @@ function eventAge(iso, words, now = Date.now()) {
19765
19993
  }
19766
19994
  // ../../packages/i18n/src/runs.ts
19767
19995
  /** A run's status in a few words. */
19768
- function describeRunStatus(run, { t }) {
19996
+ function describeRunStatus(run, { t }, now = Date.now()) {
19769
19997
  if (run.status === "running" && run.cancelRequested) return t("run.status.cancelling");
19998
+ if (run.status === "running" && run.waitingUntil && Date.parse(run.waitingUntil) > now) return t("run.status.waiting");
19770
19999
  return t(`run.status.${run.status}`);
19771
20000
  }
19772
20001
  /** "$0.31", "$0.004": what a run or step cost, in US dollars, to a cent once it's a cent or more. */
@@ -21581,7 +21810,8 @@ function options(run) {
21581
21810
  const o = run.plan.options;
21582
21811
  return {
21583
21812
  checksMinutes: o.checksMinutes ?? LOOP_DEFAULTS.checksMinutes,
21584
- reviewTier: o.reviewTier ?? null
21813
+ reviewTier: o.reviewTier ?? null,
21814
+ askMinutes: o.askMinutes ?? LOOP_DEFAULTS.askMinutes
21585
21815
  };
21586
21816
  }
21587
21817
  /** The loop's review tier, if it names one: the preflight checks the folder's agentpipe has it. */
@@ -21589,11 +21819,14 @@ const reviewTierOf = (run) => options(run).reviewTier;
21589
21819
  /** Money as agentpipe takes it: dollars, to the cent. */
21590
21820
  const usd = (n) => (Math.floor(n * 100) / 100).toFixed(2);
21591
21821
  /**
21592
- * `agentpipe run` on the run's task: always `--autonomous` (nobody is there to answer), from an up-to-date base
21593
- * (`--fresh-base`), opening a draft pull request (`checks` marks it ready once it's green), on what is left of the
21594
- * budget. The dry run is the same command with `--dry-run`, so it checks what the run will do.
21822
+ * `agentpipe run` on the run's task: always `--autonomous` (it never stops to ask in a terminal nobody reads), from
21823
+ * an up-to-date base (`--fresh-base`), opening a draft pull request (`checks` marks it ready once it's green), on
21824
+ * what is left of the budget. A loop that waits for your answers (`askMinutes`) holds the questions only you can
21825
+ * settle open that long first (`--ask-window`, AGE-202); otherwise agentpipe decides them at once. The dry run is the
21826
+ * same command with `--dry-run`, so it checks what the run will do.
21595
21827
  */
21596
21828
  function implementArgs(run, budgetUsd) {
21829
+ const { askMinutes } = options(run);
21597
21830
  return [
21598
21831
  "run",
21599
21832
  run.workdir,
@@ -21604,9 +21837,12 @@ function implementArgs(run, budgetUsd) {
21604
21837
  "--fresh-base",
21605
21838
  "--draft",
21606
21839
  "--budget",
21607
- usd(budgetUsd)
21840
+ usd(budgetUsd),
21841
+ ...askMinutes > 0 ? ["--ask-window", String(askMinutes * 60)] : []
21608
21842
  ];
21609
21843
  }
21844
+ /** Whether the run's preview is implement's dry run: a run with its task that doesn't only merge. */
21845
+ const previewed = (run) => Boolean(run.ref) && run.plan.from !== "merge";
21610
21846
  /** `agentpipe review` on the pull request, fixing what it finds, on the loop's tier when it names one. */
21611
21847
  function reviewArgs(run, pr, budgetUsd) {
21612
21848
  const tier = options(run).reviewTier;
@@ -21786,8 +22022,9 @@ const deliver = {
21786
22022
  })
21787
22023
  }
21788
22024
  },
21789
- dryRun: (run) => run.ref && run.plan.from !== "merge" ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
22025
+ dryRun: (run) => previewed(run) ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
21790
22026
  tier: (run) => run.plan.from ? null : reviewTierOf(run),
22027
+ needs: (run) => previewed(run) && options(run).askMinutes > 0 ? ["run.ask_window"] : [],
21791
22028
  finished: ({ pr, last }) => {
21792
22029
  if (!pr) return null;
21793
22030
  if (last?.step === "merge" && last.status === "ok") return last.message ?? "Merged.";
@@ -21985,6 +22222,7 @@ function runRecipe(name, run, report, deps) {
21985
22222
  const feed = agentpipeMapper({
21986
22223
  event: (e) => {
21987
22224
  if (e.kind === "pr_opened" && known(e.data?.url)) return;
22225
+ if (e.kind === "activity") deps.onWaiting?.(Boolean(e.data?.waitingUntil));
21988
22226
  report.event({
21989
22227
  ...e,
21990
22228
  ...e.step !== void 0 && e.step !== null && { step: innerStep(outer, e.step) },
@@ -22047,7 +22285,8 @@ function runRecipe(name, run, report, deps) {
22047
22285
  process: started,
22048
22286
  externalId: null,
22049
22287
  shipping,
22050
- finishes: finishing
22288
+ finishes: finishing,
22289
+ waitsFor: feed.waitsFor
22051
22290
  };
22052
22291
  if (cancelled && !finishing) (shipping() ? started.terminate : started.interrupt)();
22053
22292
  const exit = await started.done;
@@ -22146,6 +22385,27 @@ function runRecipe(name, run, report, deps) {
22146
22385
  status: "failed",
22147
22386
  reason: clip(`The run stopped: ${err.message}`, 1e3)
22148
22387
  })),
22388
+ /**
22389
+ * Hands an answer you sent from the browser to agentpipe, while the command running now waits for it (MON-259),
22390
+ * and says what came of it. Not once it stopped waiting: agentpipe would take it over what it decided.
22391
+ */
22392
+ answer: async (a) => {
22393
+ const now = current;
22394
+ if (!now?.externalId || !now.waitsFor(a.questionId)) return {
22395
+ outcome: "too_late",
22396
+ message: `Too late: the run no longer waited for an answer to ${a.questionId}.`
22397
+ };
22398
+ const env = agentpipeEnv(deps.env, deps.monobanBin);
22399
+ const { code, said } = await (deps.execOutput ?? execOutput)(deps.command, answerArgs(now.externalId, a.questionId, a.text), env);
22400
+ if (code === 0) return {
22401
+ outcome: "reached",
22402
+ message: a.text === null ? `It decides ${a.questionId} on its own, as you asked.` : `Your answer to ${a.questionId} reached the run.`
22403
+ };
22404
+ return {
22405
+ outcome: "refused",
22406
+ message: clip(`agentpipe didn't take your answer to ${a.questionId}: ${said ?? `exit code ${code ?? "none"}`}`, 1e3)
22407
+ };
22408
+ },
22149
22409
  cancel: async () => {
22150
22410
  cancelled = true;
22151
22411
  const now = current;
@@ -22304,9 +22564,27 @@ function runBoard(api) {
22304
22564
  * A loop's run goes on with nobody watching, so the preview must also say agentpipe's sandbox is on: for each model
22305
22565
  * step (its `boundary`) and for the repository's own commands (`commands.sandbox`, `[commands] sandbox`), spike S9,
22306
22566
  * AGE-157. A preview that doesn't say refuses it too. And a tier the recipe names (`--tier`) must be one the folder's
22307
- * agentpipe has (`capabilities <folder> --json`, AGE-127).
22567
+ * agentpipe has (`capabilities <folder> --json`, AGE-127), as must every flag the loop's options need (before the
22568
+ * dry run, which would only say it has no such option).
22308
22569
  */
22309
22570
  async function preflight(run, recipe, deps) {
22571
+ let asked = null;
22572
+ const capabilities = () => {
22573
+ asked ??= (deps.capabilities ?? ((folder) => agentpipeCapabilities(deps.command, deps.env, folder)))(run.workdir);
22574
+ return asked;
22575
+ };
22576
+ const needs = recipe.needs?.(run) ?? [];
22577
+ if (needs.length) {
22578
+ const said = await capabilities();
22579
+ const missing = needs.filter((need) => {
22580
+ const [command = "", flag = ""] = need.split(".");
22581
+ return said?.commands?.[command]?.[flag] !== true;
22582
+ });
22583
+ if (missing.length) return clip(`The agentpipe here has no ${missing.map((need) => {
22584
+ const [command = "", flag = ""] = need.split(".");
22585
+ return `\`${command} --${flag.replaceAll("_", "-")}\``;
22586
+ }).join(" or ")}, which the loop's settings need: update it (\`monoban agentpipe update\`), or change the loop.`, 1e3);
22587
+ }
22310
22588
  const args = recipe.dryRun(run);
22311
22589
  if (args) {
22312
22590
  const refused = await dryRun(run, args, recipe.sandboxed ?? null, deps);
@@ -22314,7 +22592,7 @@ async function preflight(run, recipe, deps) {
22314
22592
  }
22315
22593
  const tier = recipe.tier?.(run) ?? null;
22316
22594
  if (tier) {
22317
- const said = await (deps.capabilities ?? ((folder) => agentpipeCapabilities(deps.command, deps.env, folder)))(run.workdir);
22595
+ const said = await capabilities();
22318
22596
  if (!said?.tiers) return `agentpipe couldn't say which tiers ${run.workdir} has, so the review tier ${tier} can't be checked.`;
22319
22597
  if (!said.tiers.includes(tier)) return clip(`agentpipe has no tier ${tier} in ${run.workdir} (it has ${said.tiers.join(", ") || "none"}).`, 1e3);
22320
22598
  }
@@ -22538,6 +22816,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
22538
22816
  ctx.err(`Cancelling ${active.ref}: asked from the board.`);
22539
22817
  active.cancel();
22540
22818
  }
22819
+ for (const a of work.answers ?? []) if (a.runId === run.id) active.answer(a);
22541
22820
  } else if (first) {
22542
22821
  const status = run.recipe ? "cancelled" : "failed";
22543
22822
  await patch(api, run.id, {
@@ -22581,6 +22860,14 @@ async function runRunner(ctx, settings, deps, options = {}) {
22581
22860
  const outbox = new Outbox(api, run.id, now);
22582
22861
  let cancel = async () => {};
22583
22862
  let cancelled = false;
22863
+ /** Answers handed on (or being), so a check-in before the outcome is reported doesn't hand one on twice. */
22864
+ const answered = /* @__PURE__ */ new Set();
22865
+ /** Hands an answer to the run (a loop's run): none until it started. One at a time, in order. */
22866
+ let relay = null;
22867
+ let relaying = Promise.resolve();
22868
+ let reportOf = null;
22869
+ /** Its step's check-in rate (a window open for your answers makes it faster for a while). */
22870
+ let stepSeconds = 5;
22584
22871
  const self = {
22585
22872
  id: run.id,
22586
22873
  ref: ref ?? "a deleted task",
@@ -22590,6 +22877,27 @@ async function runRunner(ctx, settings, deps, options = {}) {
22590
22877
  await cancel();
22591
22878
  },
22592
22879
  flush: () => outbox.flush(),
22880
+ answer: (a) => {
22881
+ if (answered.has(a.id) || !relay || !reportOf) return;
22882
+ answered.add(a.id);
22883
+ const [hand, report] = [relay, reportOf];
22884
+ relaying = relaying.then(async () => {
22885
+ const said = await hand(a).catch((err) => ({
22886
+ outcome: "refused",
22887
+ message: `Couldn't hand on your answer: ${err.message}`
22888
+ }));
22889
+ report.event({
22890
+ kind: "answer",
22891
+ message: said.message,
22892
+ data: {
22893
+ answerId: a.id,
22894
+ questionId: a.questionId,
22895
+ outcome: said.outcome
22896
+ }
22897
+ });
22898
+ wake.abort();
22899
+ });
22900
+ },
22593
22901
  pollSeconds: 5
22594
22902
  };
22595
22903
  return {
@@ -22652,19 +22960,28 @@ async function runRunner(ctx, settings, deps, options = {}) {
22652
22960
  },
22653
22961
  update: (u) => outbox.update(u)
22654
22962
  };
22655
- const started = loopRun && deps.agentpipe ? runRecipe(run.recipe, loopRun, report, {
22963
+ const recipeRun = loopRun && deps.agentpipe ? runRecipe(run.recipe, loopRun, report, {
22656
22964
  ...deps.agentpipe,
22657
22965
  recheck: () => recheck(run.id),
22658
22966
  mayMerge: () => mayMerge(run.id),
22659
22967
  onStep: (seconds) => {
22660
- self.pollSeconds = seconds ?? settings.pollSeconds;
22968
+ stepSeconds = seconds ?? settings.pollSeconds;
22969
+ self.pollSeconds = stepSeconds;
22970
+ },
22971
+ onWaiting: (waiting) => {
22972
+ self.pollSeconds = waiting ? Math.min(stepSeconds, 5) : stepSeconds;
22661
22973
  }
22662
- }) : adapter.start({
22974
+ }) : null;
22975
+ const started = recipeRun ?? adapter.start({
22663
22976
  ref,
22664
22977
  workdir: run.workdir,
22665
22978
  options: run.options
22666
22979
  }, report);
22667
22980
  cancel = started.cancel;
22981
+ if (recipeRun) {
22982
+ relay = recipeRun.answer;
22983
+ reportOf = report;
22984
+ }
22668
22985
  if (cancelled) started.cancel();
22669
22986
  const ending = await started.done;
22670
22987
  await outbox.flush();
@@ -22758,6 +23075,7 @@ function describe$1(e) {
22758
23075
  }
22759
23076
  case "pr_opened": return `pull request ${e.message}`;
22760
23077
  case "question": return `? ${e.message}`;
23078
+ case "answer": return `↳ ${e.message}`;
22761
23079
  case "error": return `✗ ${e.message}`;
22762
23080
  default: return null;
22763
23081
  }
@@ -23270,7 +23588,7 @@ function describe({ state, running }, board, now) {
23270
23588
  const seenAgo = `checked in ${since(board.lastSeenAt, now)} ago (every ${board.pollSeconds}s)`;
23271
23589
  row("board", `${board.online ? "online" : "offline"} · ${seenAgo}`);
23272
23590
  } else if (!state.runnerId) row("board", "not on the board yet: it's starting");
23273
- if (state.version !== "1.11.0") {
23591
+ if (state.version !== "1.13.0") {
23274
23592
  const again = state.background ? "`monoban runner restart`" : "start it again in its terminal";
23275
23593
  row("update", `it runs monoban ${state.version}, this is ${VERSION}: ${again}`);
23276
23594
  }
@@ -23708,7 +24026,7 @@ async function checks(ctx, deps = {}) {
23708
24026
  const found = [];
23709
24027
  const latest = await (deps.latest ?? latestVersion)(ctx);
23710
24028
  const upgrade = UPGRADE[thisInstall()].command;
23711
- found.push(latest && newer(latest, "1.11.0") ? {
24029
+ found.push(latest && newer(latest, "1.13.0") ? {
23712
24030
  name: "monoban",
23713
24031
  status: "warn",
23714
24032
  detail: `${VERSION}; ${latest} is out`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monoban",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "Your monoban.dev kanban board in the terminal: add, move and start tasks, and hand them to coding agents.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://monoban.dev",