@chipschat/acp 1.0.33 → 1.0.35

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.
package/dist/main.js CHANGED
@@ -5244,14 +5244,14 @@ var memo = {
5244
5244
  (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
5245
5245
  inst._zod.deferred.push(() => {
5246
5246
  const base = inst._zod.parse;
5247
- const wrapped = (payload, ctx) => {
5247
+ const wrapped2 = (payload, ctx) => {
5248
5248
  if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value))
5249
5249
  throw new $ZodCyclicError();
5250
5250
  return base(payload, ctx);
5251
5251
  };
5252
- inst._zod.parse = wrapped;
5252
+ inst._zod.parse = wrapped2;
5253
5253
  if (inst._zod.run === base)
5254
- inst._zod.run = wrapped;
5254
+ inst._zod.run = wrapped2;
5255
5255
  });
5256
5256
  },
5257
5257
  attach(inst) {
@@ -5263,12 +5263,12 @@ var memo = {
5263
5263
  (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
5264
5264
  inst._zod.deferred.push(() => {
5265
5265
  const base = inst._zod.parse;
5266
- const wrapped = (payload, ctx) => {
5266
+ const wrapped2 = (payload, ctx) => {
5267
5267
  if (isRecursiveInst === void 0) {
5268
5268
  const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
5269
5269
  if (walked === NONE) {
5270
5270
  inst._zod.parse = base;
5271
- if (inst._zod.run === wrapped)
5271
+ if (inst._zod.run === wrapped2)
5272
5272
  inst._zod.run = base;
5273
5273
  return base(payload, ctx);
5274
5274
  }
@@ -5322,9 +5322,9 @@ var memo = {
5322
5322
  entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
5323
5323
  return result;
5324
5324
  };
5325
- inst._zod.parse = wrapped;
5325
+ inst._zod.parse = wrapped2;
5326
5326
  if (inst._zod.run === base)
5327
- inst._zod.run = wrapped;
5327
+ inst._zod.run = wrapped2;
5328
5328
  });
5329
5329
  }
5330
5330
  };
@@ -12995,7 +12995,7 @@ function withParser(schema, parser) {
12995
12995
  const clone2 = clone(schema);
12996
12996
  const liveRun = schema._zod.run;
12997
12997
  const originalRun = liveRun.__originalRun ?? liveRun;
12998
- const wrapped = (payload, ctx) => {
12998
+ const wrapped2 = (payload, ctx) => {
12999
12999
  if (ctx?.async || ctx?.direction === "backward" || ctx?.skipChecks || ctx?.[FALLBACK_FLAG]) {
13000
13000
  return originalRun(payload, ctx);
13001
13001
  }
@@ -13011,10 +13011,10 @@ function withParser(schema, parser) {
13011
13011
  ctx[FALLBACK_FLAG] = true;
13012
13012
  return originalRun(payload, ctx);
13013
13013
  };
13014
- wrapped.__originalRun = originalRun;
13014
+ wrapped2.__originalRun = originalRun;
13015
13015
  clone2._zod.bag.fallbackRun = originalRun;
13016
13016
  clone2._zod.bag.validator = parser;
13017
- clone2._zod.run = wrapped;
13017
+ clone2._zod.run = wrapped2;
13018
13018
  if (!liveRun.__originalRun)
13019
13019
  installCompiledUserMethods(clone2, schema, parser);
13020
13020
  return clone2;
@@ -19958,11 +19958,21 @@ var policyHold = external_exports.object({
19958
19958
  by: external_exports.string().min(1).max(120).optional().describe("Who turned its asks off. Filled in by Chips from the credential that sent it."),
19959
19959
  at: isoTimestamp.optional().describe("When they were turned off. Filled in by Chips.")
19960
19960
  }).describe("A harness's asks turned off: Chips says yes for it until `until`.");
19961
+ var policyMode = external_exports.object({
19962
+ id: external_exports.string().min(1).max(80).describe("The mode as the harness names it on the wire: `auto`, `bypassPermissions`."),
19963
+ name: external_exports.string().min(1).max(80).optional().describe("Its name as the harness offered it (`own_rules.modes`), for the record: `Auto`. Sent by the person's client."),
19964
+ back_to: external_exports.string().min(1).max(80).optional().describe("The name of the mode its sessions go back to, as the harness offered it: `Default`. Sent by the person's client."),
19965
+ everything: external_exports.boolean().optional().describe("In it the harness never asks, as it said when it offered it: the apps wear yellow while it holds. Sent by the person's client."),
19966
+ until: isoTimestamp.optional().describe("When its sessions go back to the mode they start in. Absent: when a person changes it."),
19967
+ by: external_exports.string().min(1).max(120).optional().describe("Who picked it. Filled in by Chips from the credential that sent it."),
19968
+ at: isoTimestamp.optional().describe("When it was picked. Filled in by Chips.")
19969
+ }).describe("The mode a person picked for a harness's sessions, and until when.");
19961
19970
  var policy = external_exports.object({
19962
19971
  autonomy: autonomyLevel,
19963
19972
  rules: external_exports.array(policyRule).max(200).describe("Evaluated in order; the workspace cap always wins."),
19964
19973
  hold: policyHold.nullable().optional().describe("Its asks turned off (ADR 0299), for every space: kept only with no `space_id`. `null` turns them back on; absent leaves it as it was."),
19965
- chips_rules: external_exports.boolean().optional().describe("Whether Chips's rules answer any of its asks (ADR 0300): off, every ask it sends goes to a person and a don't-ask-again is the harness's own. Kept only with no `space_id`; absent leaves it as it was, and never set it reads as on for a harness with a rule or a hold, or whose workspace has one.")
19974
+ chips_rules: external_exports.boolean().optional().describe("Whether Chips's rules answer any of its asks (ADR 0300): off, every ask it sends goes to a person and a don't-ask-again is the harness's own. Kept only with no `space_id`; absent leaves it as it was, and never set it reads as on for a harness with a rule or a hold, or whose workspace has one."),
19975
+ mode: policyMode.nullable().optional().describe("The mode a person put its sessions in (ADR 0300, 19 November addendum), for every space: kept only with no `space_id`. `null` puts them back in the mode they start in; absent leaves it as it was.")
19966
19976
  }).describe("A harness's autonomy level and the rules that fill in the details.");
19967
19977
  var cost = external_exports.object({
19968
19978
  usd: external_exports.number().nonnegative().describe("An estimate, in US dollars."),
@@ -20394,6 +20404,21 @@ var HARNESS_CAPABILITIES = {
20394
20404
  var ENDS = String.raw`(?=$|[\s;&|])`;
20395
20405
  var DROPPED_AFTER_DESCRIPTOR = new RegExp(String.raw`^(?:>>?[ \t]*\/dev\/null|>&[12])${ENDS}`);
20396
20406
  var DROPPED_ANY = new RegExp(String.raw`^(?:&?>>?[ \t]*\/dev\/null|>&[12])${ENDS}`);
20407
+ function listedIn(list, program, rest) {
20408
+ const listed = list.find(([first, ...more]) => {
20409
+ if (first !== program)
20410
+ return false;
20411
+ let from = 0;
20412
+ for (const word of more) {
20413
+ const at = rest.indexOf(word, from);
20414
+ if (at === -1)
20415
+ return false;
20416
+ from = at + 1;
20417
+ }
20418
+ return true;
20419
+ });
20420
+ return listed?.join(" ");
20421
+ }
20397
20422
 
20398
20423
  // node_modules/@chipschat/protocol/dist/src/connectors.js
20399
20424
  var words = (most) => external_exports.string().trim().min(1).max(most);
@@ -23001,11 +23026,24 @@ var ownEntry = external_exports.object({
23001
23026
  raw: external_exports.string().min(1).max(400).optional().describe("The entry as its settings write it: `Bash(git:*)`.")
23002
23027
  }).describe("One thing a harness's own settings let through, ask about, or refuse.");
23003
23028
  var entries = external_exports.array(ownEntry).max(OWN_RULES_MAX);
23029
+ var OWN_MODES_MAX = 12;
23030
+ var ownMode = external_exports.object({
23031
+ id: external_exports.string().min(1).max(80).describe("The mode as the harness names it on the wire, what `policy.mode.id` carries: `auto`."),
23032
+ name: external_exports.string().min(1).max(80).describe("Its name, as the harness's own picker says it: `Auto`."),
23033
+ words: external_exports.string().min(1).max(200).optional().describe("What it does, in a plain line, for the row under its name."),
23034
+ everything: external_exports.boolean().optional().describe("In it the harness never asks: Claude Code's Bypass permissions, Codex's Full access.")
23035
+ }).describe("One mode a harness offers to run its sessions in (ADR 0300, 19 November addendum).");
23036
+ var ownModes = external_exports.object({
23037
+ base: external_exports.string().min(1).max(80).describe("The mode its sessions start in, and go back to when a picked mode's time is up."),
23038
+ running: external_exports.string().min(1).max(80).optional().describe("The mode its sessions run in now, which can differ from the one picked: Claude Code runs Auto as Accept edits on a model that can't use it."),
23039
+ offers: external_exports.array(ownMode).min(1).max(OWN_MODES_MAX).describe("Each mode it offers, in its order.")
23040
+ }).describe("The modes a harness offers, and the one it starts in.");
23004
23041
  var ownRules = external_exports.object({
23005
23042
  read_from: external_exports.array(external_exports.string().min(1).max(300)).min(1).max(8).describe("Where it read them, in the order they apply: `~/.claude/settings.json`."),
23006
23043
  note: external_exports.string().min(1).max(400).optional().describe("A sentence in the harness's own words about them: who else reads the same file, what its mode means."),
23007
23044
  mode: external_exports.string().min(1).max(80).optional().describe("The mode its sessions run in, as the harness names it: `Default`."),
23008
23045
  everything: external_exports.boolean().optional().describe("It runs everything without asking, so nothing it does reaches Chips as an ask."),
23046
+ modes: ownModes.optional().describe("The modes a person may put its sessions in from Chips (`policy.mode`), and the one they start in. Absent: it can't be switched from Chips."),
23009
23047
  runs: entries.describe("What it runs without asking."),
23010
23048
  asks: entries.optional().describe("What it always asks about, whatever else it lets through."),
23011
23049
  refuses: entries.optional().describe("What it never does."),
@@ -23025,6 +23063,1123 @@ var HTML_POLICY = "default-src 'none'; img-src data: blob:; font-src data:; medi
23025
23063
  var PAGE_SANDBOX = "allow-scripts allow-popups allow-popups-to-escape-sandbox";
23026
23064
  var PAGE_HEADER_POLICY = `${HTML_POLICY}; sandbox ${PAGE_SANDBOX}`;
23027
23065
 
23066
+ // node_modules/@chipschat/protocol/dist/src/shell-scan.js
23067
+ var FILLED = "\0";
23068
+ var DEEPEST = 12;
23069
+ function scanCommands(line) {
23070
+ const found = {
23071
+ commands: [],
23072
+ names: /* @__PURE__ */ new Map(),
23073
+ knowable: knowable(line),
23074
+ leading: true,
23075
+ lost: false
23076
+ };
23077
+ new Scan(line, found, 0, false).run();
23078
+ return found.lost ? void 0 : found.commands;
23079
+ }
23080
+ function knowable(line) {
23081
+ if (/(?:^|[^\w$])IFS\+?=/.test(line))
23082
+ return () => false;
23083
+ const bare = /* @__PURE__ */ new Map();
23084
+ for (const [name] of line.matchAll(/(?<![\w$])(?<!\$\{)[A-Za-z_]\w*/g)) {
23085
+ bare.set(name, (bare.get(name) ?? 0) + 1);
23086
+ }
23087
+ const given = new Set([...line.matchAll(/\$\{([A-Za-z_]\w*):?=/g)].map((match) => match[1]));
23088
+ return (name) => bare.get(name) === 1 && !given.has(name);
23089
+ }
23090
+ var NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
23091
+ var SETS = /^[A-Za-z_][A-Za-z0-9_]*=/;
23092
+ var SETTERS = /* @__PURE__ */ new Set(["export", "local", "readonly", "declare", "typeset"]);
23093
+ var ENDS_TARGET = " \n;|&()<>";
23094
+ var BEFORE_A_WORD = " \n;&|()";
23095
+ var ANSI = {
23096
+ a: "\x07",
23097
+ b: "\b",
23098
+ e: "\x1B",
23099
+ E: "\x1B",
23100
+ f: "\f",
23101
+ n: "\n",
23102
+ r: "\r",
23103
+ t: " ",
23104
+ v: "\v",
23105
+ "\\": "\\",
23106
+ "'": "'",
23107
+ '"': '"',
23108
+ "?": "?"
23109
+ };
23110
+ var Scan = class _Scan {
23111
+ text;
23112
+ found;
23113
+ depth;
23114
+ piped;
23115
+ at = 0;
23116
+ words = [];
23117
+ word;
23118
+ fed = [];
23119
+ unseen = false;
23120
+ waiting = [];
23121
+ constructor(text, found, depth, piped) {
23122
+ this.text = text;
23123
+ this.found = found;
23124
+ this.depth = depth;
23125
+ this.piped = piped;
23126
+ }
23127
+ /** What each character outside quotes does; any other is part of a word. */
23128
+ static STEPS = {
23129
+ " ": _Scan.prototype.endWord,
23130
+ " ": _Scan.prototype.endWord,
23131
+ "\n": _Scan.prototype.newLine,
23132
+ "\\": _Scan.prototype.escaped,
23133
+ "'": _Scan.prototype.single,
23134
+ '"': _Scan.prototype.double,
23135
+ $: _Scan.prototype.dollar,
23136
+ "`": _Scan.prototype.backticks,
23137
+ "#": _Scan.prototype.comment,
23138
+ "&": _Scan.prototype.ampersand,
23139
+ "|": _Scan.prototype.bar,
23140
+ ";": _Scan.prototype.semicolon,
23141
+ "(": _Scan.prototype.opens,
23142
+ ")": _Scan.prototype.endCommand,
23143
+ "<": _Scan.prototype.redirect,
23144
+ ">": _Scan.prototype.redirect,
23145
+ "*": _Scan.prototype.glob,
23146
+ "?": _Scan.prototype.glob,
23147
+ "[": _Scan.prototype.bracket
23148
+ };
23149
+ run() {
23150
+ while (this.at < this.text.length)
23151
+ this.step();
23152
+ this.endCommand();
23153
+ }
23154
+ /** One character, or the whole of what it opens; leaves `at` on the next to read. */
23155
+ step() {
23156
+ const char = this.text[this.at];
23157
+ const does = _Scan.STEPS[char];
23158
+ if (does === void 0)
23159
+ this.add(char);
23160
+ else
23161
+ does.call(this);
23162
+ this.at += 1;
23163
+ }
23164
+ add(text) {
23165
+ this.word = (this.word ?? "") + text;
23166
+ }
23167
+ endWord() {
23168
+ if (this.word !== void 0)
23169
+ this.words.push(this.word);
23170
+ this.word = void 0;
23171
+ }
23172
+ endCommand(pipesOn = false) {
23173
+ this.endWord();
23174
+ if (this.words.length > 0 && !this.keep())
23175
+ this.found.leading = false;
23176
+ if (this.words.length > 0 || this.fed.length > 0) {
23177
+ const piped = this.piped || this.unseen;
23178
+ this.found.commands.push({ words: this.words, fed: this.fed, piped });
23179
+ }
23180
+ this.words = [];
23181
+ this.fed = [];
23182
+ this.piped = pipesOn;
23183
+ this.unseen = false;
23184
+ }
23185
+ /**
23186
+ * A part ended by more than `;` or a new line. What it set may not be set for what follows (a
23187
+ * pipe's part runs in a subshell, `&&` may not run it), so names set from here on are not read.
23188
+ */
23189
+ chain(pipesOn) {
23190
+ this.found.leading = false;
23191
+ this.endCommand(pipesOn);
23192
+ }
23193
+ /**
23194
+ * Whether this part only sets names (`U=…`, `export U=…`). Each is kept, so a later `$U` can be
23195
+ * read, where nothing else in the line touches the name; not inside `$(…)`, which runs apart.
23196
+ */
23197
+ keep() {
23198
+ const [first, ...rest] = this.words;
23199
+ const words4 = SETTERS.has(first ?? "") ? rest : this.words;
23200
+ if (words4.length === 0 || !words4.every((word) => SETS.test(word)))
23201
+ return false;
23202
+ if (this.depth > 0)
23203
+ return true;
23204
+ for (const word of words4) {
23205
+ const equals = word.indexOf("=");
23206
+ const name = word.slice(0, equals);
23207
+ const value = word.slice(equals + 1);
23208
+ if (!value.includes(FILLED) && this.found.knowable(name)) {
23209
+ this.found.names.set(name, { value, sure: this.found.leading });
23210
+ }
23211
+ }
23212
+ return true;
23213
+ }
23214
+ /** A new line ends the command, and the text of the heredocs opened on it comes next. */
23215
+ newLine() {
23216
+ this.endCommand();
23217
+ let at = this.at + 1;
23218
+ for (const open2 of this.waiting)
23219
+ at = this.body(open2, at);
23220
+ this.waiting = [];
23221
+ this.at = at - 1;
23222
+ }
23223
+ /** One heredoc's text, from `from` up to its closing word; where what follows it starts. */
23224
+ body(open2, from) {
23225
+ let at = from;
23226
+ const lines2 = [];
23227
+ while (at < this.text.length) {
23228
+ const end2 = this.text.indexOf("\n", at);
23229
+ const stop = end2 === -1 ? this.text.length : end2;
23230
+ const line = this.text.slice(at, stop);
23231
+ at = stop + 1;
23232
+ if ((open2.tabs ? line.replace(/^\t+/, "") : line) === open2.closes)
23233
+ break;
23234
+ lines2.push(line);
23235
+ }
23236
+ const body = lines2.join("\n");
23237
+ open2.into[open2.at] = body;
23238
+ if (!open2.literal)
23239
+ this.inside(body);
23240
+ return at;
23241
+ }
23242
+ /** A backslash makes the next character itself; before a new line it joins the two lines. */
23243
+ escaped() {
23244
+ const next = this.text[this.at + 1];
23245
+ if (next === void 0)
23246
+ return;
23247
+ if (next !== "\n")
23248
+ this.add(next);
23249
+ this.at += 1;
23250
+ }
23251
+ /** Inside single quotes everything is itself. */
23252
+ single() {
23253
+ const end2 = this.text.indexOf("'", this.at + 1);
23254
+ const stop = end2 === -1 ? this.text.length : end2;
23255
+ this.add(this.text.slice(this.at + 1, stop));
23256
+ this.at = stop;
23257
+ }
23258
+ /** Inside double quotes a shell still fills in `$` and runs backticks. */
23259
+ double() {
23260
+ this.word ??= "";
23261
+ for (this.at += 1; this.at < this.text.length; this.at += 1) {
23262
+ const char = this.text[this.at];
23263
+ if (char === '"')
23264
+ return;
23265
+ if (char === "$")
23266
+ this.dollar(true);
23267
+ else if (char === "`")
23268
+ this.backticks();
23269
+ else if (char === "\\" && '"\\$`\n'.includes(this.text[this.at + 1] ?? ""))
23270
+ this.escaped();
23271
+ else
23272
+ this.add(char);
23273
+ }
23274
+ }
23275
+ /**
23276
+ * `$(…)`, `${…}`, `$NAME`, `$'…'`, `$"…"`: what runs inside is scanned, and the word is filled
23277
+ * in. zsh's `$=NAME`, `$~NAME` and `$^NAME` change how a value is read, so they are filled in.
23278
+ */
23279
+ dollar(quoted2 = false) {
23280
+ const next = this.text[this.at + 1] ?? "";
23281
+ if (next === "(")
23282
+ this.runs(this.at + 1, false);
23283
+ else if (next === "{")
23284
+ this.braced(this.at + 1, quoted2);
23285
+ else if (next === "'" && !quoted2)
23286
+ this.ansi();
23287
+ else if (next === '"' && !quoted2)
23288
+ return;
23289
+ else if (this.zshFlag())
23290
+ this.add(FILLED);
23291
+ else if (/[A-Za-z0-9_@*#?$!-]/.test(next)) {
23292
+ const name = this.nameAt(this.at + 1);
23293
+ this.fill(name, quoted2, this.at + 1 + name.length);
23294
+ this.at += name.length;
23295
+ } else
23296
+ this.add("$");
23297
+ }
23298
+ /** zsh's `$=NAME`, `$~NAME`, `$^NAME` and their braced forms, read past; whether it was one. */
23299
+ zshFlag() {
23300
+ const flag = this.text[this.at + 1] ?? "";
23301
+ const after = this.text[this.at + 2] ?? "";
23302
+ if (flag === "" || !"=~^".includes(flag) || !/[A-Za-z_{]/.test(after))
23303
+ return false;
23304
+ this.at += 1;
23305
+ if (after === "{")
23306
+ this.at = closing(this.text, this.at + 1, "{", "}");
23307
+ else
23308
+ this.at += this.nameAt(this.at + 1).length;
23309
+ return true;
23310
+ }
23311
+ /** The name or one special character a `$` stands before. */
23312
+ nameAt(at) {
23313
+ return /^(?:[A-Za-z_][A-Za-z0-9_]*|.)/s.exec(this.text.slice(at))?.[0] ?? "";
23314
+ }
23315
+ /**
23316
+ * `${NAME}` is the name's value; anything more in the braces is filled in, after what runs
23317
+ * inside it. bash 5.3's `${ …; }` and `${| …; }` run their text as commands.
23318
+ */
23319
+ braced(open2, quoted2) {
23320
+ const close = closing(this.text, open2, "{", "}");
23321
+ const within3 = this.text.slice(open2 + 1, close);
23322
+ if (NAME.test(within3))
23323
+ this.fill(within3, quoted2, close + 1);
23324
+ else {
23325
+ if (/^[\s|]/.test(within3))
23326
+ this.scan(within3.replace(/^\|/, ""), false);
23327
+ else
23328
+ this.inside(within3);
23329
+ this.add(FILLED);
23330
+ }
23331
+ this.at = close;
23332
+ }
23333
+ /** `$'…'`, with its backslash escapes read as a shell reads them. */
23334
+ ansi() {
23335
+ let at = this.at + 2;
23336
+ let text = "";
23337
+ while (at < this.text.length && this.text[at] !== "'") {
23338
+ if (this.text[at] === "\\" && at + 1 < this.text.length) {
23339
+ const [value, length] = ansiEscape(this.text, at + 1);
23340
+ text += value;
23341
+ at += 1 + length;
23342
+ } else {
23343
+ text += this.text[at];
23344
+ at += 1;
23345
+ }
23346
+ }
23347
+ this.add(text);
23348
+ this.at = at;
23349
+ }
23350
+ /**
23351
+ * A name's value where the line set it, else the mark of what the shell fills in. A name set
23352
+ * where the setting might not run may be empty, so it is read only quoted on its own (`"$C"`):
23353
+ * empty, that is an empty word, which runs nothing. Bare, an empty `$X` drops out and the next
23354
+ * word takes its place; beside other text, it changes the word. `after` is where the text after
23355
+ * the name starts.
23356
+ */
23357
+ fill(name, quoted2, after) {
23358
+ const named = this.found.names.get(name);
23359
+ const value = named?.value;
23360
+ const alone2 = quoted2 && this.word === "" && this.text[after] === '"' && ENDS_TARGET.includes(this.text[after + 1] ?? " ");
23361
+ if (value === void 0 || named?.sure !== true && !alone2)
23362
+ this.add(FILLED);
23363
+ else if (quoted2)
23364
+ this.add(value);
23365
+ else {
23366
+ value.split(/[ \t\n]+/).forEach((piece, index) => {
23367
+ if (index > 0)
23368
+ this.endWord();
23369
+ if (piece !== "")
23370
+ this.add(piece.replace(/[*?[]/g, FILLED));
23371
+ });
23372
+ }
23373
+ }
23374
+ backticks() {
23375
+ let end2 = this.at + 1;
23376
+ while (end2 < this.text.length && this.text[end2] !== "`")
23377
+ end2 += this.text[end2] === "\\" ? 2 : 1;
23378
+ this.scan(this.text.slice(this.at + 1, end2).replace(/\\([`\\$])/g, "$1"), false);
23379
+ this.add(FILLED);
23380
+ this.at = Math.min(end2, this.text.length);
23381
+ }
23382
+ /**
23383
+ * `(…)` after a `$`, a `<`, a `>` or zsh's `=` runs what is inside, and leaves something filled
23384
+ * in. Inside `>(…)` the first command is fed what is written to it.
23385
+ */
23386
+ runs(open2, fed) {
23387
+ const close = closing(this.text, open2, "(", ")");
23388
+ this.scan(this.text.slice(open2 + 1, close), fed);
23389
+ this.add(FILLED);
23390
+ this.at = close;
23391
+ }
23392
+ /** The commands in text that runs inside this line. */
23393
+ scan(text, fed) {
23394
+ if (this.depth >= DEEPEST)
23395
+ this.found.lost = true;
23396
+ else
23397
+ new _Scan(text, this.found, this.depth + 1, fed).run();
23398
+ }
23399
+ /** What runs inside text a shell only fills in: its `$(…)` and backticks, nothing else. */
23400
+ inside(text) {
23401
+ for (let at = 0; at < text.length; at += 1) {
23402
+ const char = text[at];
23403
+ if (char === "\\")
23404
+ at += 1;
23405
+ else if (char === "$" && text[at + 1] === "(") {
23406
+ const close = closing(text, at + 1, "(", ")");
23407
+ this.scan(text.slice(at + 2, close), false);
23408
+ at = close;
23409
+ } else if (char === "`") {
23410
+ const end2 = text.indexOf("`", at + 1);
23411
+ const stop = end2 === -1 ? text.length : end2;
23412
+ this.scan(text.slice(at + 1, stop), false);
23413
+ at = stop;
23414
+ }
23415
+ }
23416
+ }
23417
+ /** A comment runs to the line's end; a `#` inside a word is itself. */
23418
+ comment() {
23419
+ if (this.word !== void 0) {
23420
+ this.add("#");
23421
+ return;
23422
+ }
23423
+ const end2 = this.text.indexOf("\n", this.at);
23424
+ this.at = (end2 === -1 ? this.text.length : end2) - 1;
23425
+ }
23426
+ /** `&&` and `&` end a command; `&>` sends its output somewhere. */
23427
+ ampersand() {
23428
+ const next = this.text[this.at + 1];
23429
+ if (next === ">")
23430
+ this.redirect();
23431
+ else {
23432
+ this.chain(false);
23433
+ if (next === "&")
23434
+ this.at += 1;
23435
+ }
23436
+ }
23437
+ /** `|` and `|&` pipe this command into the next; `||` only ends it. */
23438
+ bar() {
23439
+ const next = this.text[this.at + 1];
23440
+ this.chain(next !== "|");
23441
+ if (next === "|" || next === "&")
23442
+ this.at += 1;
23443
+ }
23444
+ semicolon() {
23445
+ this.endCommand();
23446
+ if (this.text[this.at + 1] === ";")
23447
+ this.at += 1;
23448
+ }
23449
+ /**
23450
+ * `(` opens a subshell or a function's `()`; after `name=` a list of values, whose `$(…)` still
23451
+ * runs; after zsh's lone `=` a command whose output stands as a file; and glued to a word, a
23452
+ * zsh glob's group (`/bin/(r)m`), which could be anything.
23453
+ */
23454
+ opens() {
23455
+ const word = this.word;
23456
+ if (word === "=") {
23457
+ this.word = void 0;
23458
+ this.runs(this.at, false);
23459
+ } else if (word?.endsWith("=") === true) {
23460
+ const close = closing(this.text, this.at, "(", ")");
23461
+ this.inside(this.text.slice(this.at + 1, close));
23462
+ this.add(FILLED);
23463
+ this.at = close;
23464
+ } else if (word !== void 0 && this.text[this.at + 1] !== ")") {
23465
+ this.at = closing(this.text, this.at, "(", ")");
23466
+ this.add(FILLED);
23467
+ } else
23468
+ this.chain(false);
23469
+ }
23470
+ glob() {
23471
+ this.add(FILLED);
23472
+ }
23473
+ /**
23474
+ * `[` with a `]` later in the word is a glob. Alone (`[ -d x ]`, `[[`) it is the test command,
23475
+ * and after a name (`a[0]=x`) an array's index.
23476
+ */
23477
+ bracket() {
23478
+ const rest = this.text.slice(this.at + 1);
23479
+ const index = NAME.test(this.word ?? "") && /^[^\]]*\]\+?=/.test(rest);
23480
+ const glob = !index && /^[^\s;&|()<>'"]*\]/.test(rest) && !/^\[?\s/.test(rest);
23481
+ this.add(glob ? FILLED : "[");
23482
+ }
23483
+ /** A redirection: its file is no word of the command, and a heredoc's text waits for its lines. */
23484
+ redirect() {
23485
+ if (this.word !== void 0 && /^(?:\d+|\{[A-Za-z_]\w*\})$/.test(this.word)) {
23486
+ this.word = void 0;
23487
+ } else
23488
+ this.endWord();
23489
+ const rest = this.text.slice(this.at);
23490
+ const heredoc = /^<<(-?)(?!<)[ \t]*/.exec(rest);
23491
+ if (heredoc !== null)
23492
+ this.heredoc(heredoc[0].length, heredoc[1] === "-");
23493
+ else if (/^[<>]\(/.test(rest)) {
23494
+ this.runs(this.at + 1, rest[0] === ">");
23495
+ } else {
23496
+ const sign = /^(?:<<<|&>>?|>>|>&|<&|>\||<>|[<>])[ \t]*/.exec(rest)[0];
23497
+ this.at += sign.length;
23498
+ const target = this.target();
23499
+ if (sign.startsWith("<<<"))
23500
+ this.fed.push(target);
23501
+ else if (sign.trim() === "<" && target.includes(FILLED))
23502
+ this.unseen = true;
23503
+ }
23504
+ }
23505
+ heredoc(sign, tabs) {
23506
+ this.at += sign;
23507
+ const { closes, literal: literal2 } = this.closingWord();
23508
+ this.waiting.push({ closes, tabs, literal: literal2, into: this.fed, at: this.fed.length });
23509
+ this.fed.push("");
23510
+ }
23511
+ /** A heredoc's closing word, as written: quotes off and nothing filled in, as a shell has it. */
23512
+ closingWord() {
23513
+ let closes = "";
23514
+ let literal2 = false;
23515
+ for (; this.at < this.text.length; this.at += 1) {
23516
+ const char = this.text[this.at];
23517
+ if (ENDS_TARGET.includes(char))
23518
+ break;
23519
+ if (char === "'" || char === '"') {
23520
+ const end2 = quoteEnd(this.text, this.at);
23521
+ closes += this.text.slice(this.at + 1, end2);
23522
+ this.at = end2;
23523
+ literal2 = true;
23524
+ } else if (char === "\\") {
23525
+ this.at += 1;
23526
+ closes += this.text[this.at] ?? "";
23527
+ literal2 = true;
23528
+ } else
23529
+ closes += char;
23530
+ }
23531
+ this.at -= 1;
23532
+ return { closes, literal: literal2 };
23533
+ }
23534
+ /** The word a redirection points at, read and left out of the command's words. */
23535
+ target() {
23536
+ if (/^[<>]\($/.test(this.text.slice(this.at, this.at + 2))) {
23537
+ this.runs(this.at + 1, this.text[this.at] === ">");
23538
+ this.word = void 0;
23539
+ return FILLED;
23540
+ }
23541
+ while (this.at < this.text.length && !ENDS_TARGET.includes(this.text[this.at])) {
23542
+ this.step();
23543
+ }
23544
+ const target = this.word ?? "";
23545
+ this.word = void 0;
23546
+ this.at -= 1;
23547
+ return target;
23548
+ }
23549
+ };
23550
+ function ansiEscape(text, at) {
23551
+ const char = text[at];
23552
+ const known = ANSI[char];
23553
+ if (known !== void 0)
23554
+ return [known, 1];
23555
+ const code = /^(?:x([0-9A-Fa-f]{1,2})|u([0-9A-Fa-f]{1,4})|U([0-9A-Fa-f]{1,8})|([0-7]{1,3}))/.exec(text.slice(at));
23556
+ if (code !== null) {
23557
+ const [whole3, hex3, short, long, octal] = code;
23558
+ const value = hex3 ?? short ?? long;
23559
+ const point = value === void 0 ? Number.parseInt(octal ?? "0", 8) : Number.parseInt(value, 16);
23560
+ return [String.fromCodePoint(Math.min(point, 1114111)), whole3.length];
23561
+ }
23562
+ if (char === "c" && at + 1 < text.length) {
23563
+ return [String.fromCharCode(text.charCodeAt(at + 1) & 31), 2];
23564
+ }
23565
+ return [`\\${char}`, 1];
23566
+ }
23567
+ function closing(text, open2, left, right) {
23568
+ let depth = 0;
23569
+ let cases = 0;
23570
+ for (let at = open2; at < text.length; at = whole(text, at) + 1) {
23571
+ const char = text[at];
23572
+ if (char === left)
23573
+ depth += 1;
23574
+ else if (char === right && !(left === "(" && cases > 0 && depth === 1)) {
23575
+ depth -= 1;
23576
+ if (depth === 0)
23577
+ return at;
23578
+ } else
23579
+ cases += caseWord(text, at);
23580
+ }
23581
+ return text.length;
23582
+ }
23583
+ function caseWord(text, at) {
23584
+ if (!startsAWord(text, at))
23585
+ return 0;
23586
+ const word = /^(?:case|esac)(?=[\s;&|()]|$)/.exec(text.slice(at, at + 5))?.[0];
23587
+ return word === "case" ? 1 : word === "esac" ? -1 : 0;
23588
+ }
23589
+ function startsAWord(text, at) {
23590
+ return at === 0 || BEFORE_A_WORD.includes(text[at - 1]);
23591
+ }
23592
+ function whole(text, at) {
23593
+ const char = text[at];
23594
+ if (char === "\\")
23595
+ return at + 1;
23596
+ if (char === "'" || char === '"')
23597
+ return quoteEnd(text, at);
23598
+ if (char === "$" && text[at + 1] === "'")
23599
+ return ansiEnd(text, at + 1);
23600
+ if (char === "#" && startsAWord(text, at)) {
23601
+ const end2 = text.indexOf("\n", at);
23602
+ return end2 === -1 ? text.length : end2 - 1;
23603
+ }
23604
+ return at;
23605
+ }
23606
+ function quoteEnd(text, open2) {
23607
+ const quote = text[open2];
23608
+ for (let at = open2 + 1; at < text.length; at += 1) {
23609
+ if (text[at] === "\\" && quote === '"')
23610
+ at += 1;
23611
+ else if (text[at] === quote)
23612
+ return at;
23613
+ }
23614
+ return text.length;
23615
+ }
23616
+ function ansiEnd(text, open2) {
23617
+ for (let at = open2 + 1; at < text.length; at += 1) {
23618
+ if (text[at] === "\\")
23619
+ at += 1;
23620
+ else if (text[at] === "'")
23621
+ return at;
23622
+ }
23623
+ return text.length;
23624
+ }
23625
+
23626
+ // node_modules/@chipschat/protocol/dist/src/pause.js
23627
+ var NEVER_FOR_A_WHILE = [
23628
+ ["rm"],
23629
+ ["rmdir"],
23630
+ ["find", "-delete"],
23631
+ ["dd"],
23632
+ ["mkfs"],
23633
+ ["sudo"],
23634
+ ["su"],
23635
+ ["doas"],
23636
+ ["ssh"],
23637
+ ["scp"],
23638
+ ["rsync"],
23639
+ ["curl"],
23640
+ ["wget"],
23641
+ ["git", "push"],
23642
+ ["npm", "publish"],
23643
+ ["pnpm", "publish"],
23644
+ ["yarn", "publish"],
23645
+ ["gh", "api"],
23646
+ ["gh", "repo", "delete"],
23647
+ ["gh", "pr", "merge"],
23648
+ ["gh", "release", "delete"],
23649
+ ["kubectl", "delete"],
23650
+ ["git", "reset"],
23651
+ ["git", "clean"],
23652
+ ["shutdown"],
23653
+ ["reboot"]
23654
+ ];
23655
+ var LONGEST_FOLLOWED = 2e5;
23656
+ var DEEPEST_STRING = 6;
23657
+ var CANT_FOLLOW = "a command Chips can't follow";
23658
+ var CANT_TELL = "a program Chips can't tell";
23659
+ var PIPED_SHELL = "a shell run on what is piped to it";
23660
+ var ELSEWHERE = /(?:^|[^\w$])(?:[A-Za-z_]*proxy|CURL_HOME|WGETRC|HOME|XDG_CONFIG_HOME)\+?=/i;
23661
+ function alone(words4) {
23662
+ return { words: words4, fed: [], piped: false };
23663
+ }
23664
+ function lineAsks(line, outer) {
23665
+ if (outer.depth > DEEPEST_STRING || line.length > LONGEST_FOLLOWED)
23666
+ return CANT_FOLLOW;
23667
+ const commands = scanCommands(line);
23668
+ if (commands === void 0)
23669
+ return CANT_FOLLOW;
23670
+ const reading = { depth: outer.depth + 1, elsewhere: outer.elsewhere || ELSEWHERE.test(line) };
23671
+ for (const command of commands) {
23672
+ const asks = commandAsks(command, reading);
23673
+ if (asks !== void 0)
23674
+ return asks;
23675
+ }
23676
+ return void 0;
23677
+ }
23678
+ var BEFORE_A_PROGRAM = new Map([
23679
+ ...["!", "if", "then", "else", "elif", "fi", "do", "done", "while", "until", "esac"].map((word) => [word, 1]),
23680
+ // zsh's: `noglob rm`, `nocorrect rm`, `- rm`, `repeat 3 rm`, `{ … } always { … }`.
23681
+ ...["{", "}", "noglob", "nocorrect", "-", "always"].map((word) => [word, 1]),
23682
+ ["function", 2],
23683
+ ["repeat", 2]
23684
+ ]);
23685
+ var NO_PROGRAM = /* @__PURE__ */ new Set(["for", "case", "select", "[[", "in"]);
23686
+ var SETS_A_NAME = /^[A-Za-z_][A-Za-z0-9_]*(?:\[[^\]]*\])?\+?=/;
23687
+ function fromProgram(words4) {
23688
+ let at = 0;
23689
+ for (; ; ) {
23690
+ const word = words4[at];
23691
+ if (word === void 0)
23692
+ return [];
23693
+ const skips = word === "coproc" ? coprocSkips(words4, at) : BEFORE_A_PROGRAM.get(word);
23694
+ if (skips !== void 0)
23695
+ at += skips;
23696
+ else if (SETS_A_NAME.test(word))
23697
+ at += 1;
23698
+ else
23699
+ return words4.slice(at);
23700
+ }
23701
+ }
23702
+ function coprocSkips(words4, at) {
23703
+ const named = /^[A-Za-z_]\w*$/.test(words4[at + 1] ?? "");
23704
+ return named && (words4[at + 2] === "{" || words4[at + 2] === void 0) ? 2 : 1;
23705
+ }
23706
+ function programName(word) {
23707
+ if (BRACES.test(word))
23708
+ return void 0;
23709
+ const path = word.length > 1 && word.startsWith("=") ? word.slice(1) : word;
23710
+ const name = path.slice(path.lastIndexOf("/") + 1).toLowerCase();
23711
+ if (name === "" || name.includes(FILLED))
23712
+ return void 0;
23713
+ return name.startsWith("mkfs.") ? "mkfs" : name;
23714
+ }
23715
+ var BRACES = /\{[^}]*(?:,|\.\.)[^}]*\}/;
23716
+ function commandAsks(command, reading) {
23717
+ const words4 = fromProgram(command.words);
23718
+ const [first, ...rest] = words4;
23719
+ if (first === void 0 || NO_PROGRAM.has(first))
23720
+ return void 0;
23721
+ const group = rest.findIndex((word, at) => word === "{" || word === "}" || word === "always" && rest[at - 1] === "}");
23722
+ if (group !== -1) {
23723
+ const head = { ...command, words: [first, ...rest.slice(0, group)] };
23724
+ return commandAsks(head, reading) ?? commandAsks(alone(rest.slice(group + 1)), reading);
23725
+ }
23726
+ const program = programName(first);
23727
+ if (program === void 0)
23728
+ return CANT_TELL;
23729
+ const through = READ_THROUGH.get(program)?.({ ...command, words: words4 }, rest, reading);
23730
+ if (through !== void 0)
23731
+ return through;
23732
+ if (program === "curl" || program === "wget") {
23733
+ const before = command.words.slice(0, command.words.length - words4.length);
23734
+ const routed = reading.elsewhere || before.some((word) => ELSEWHERE.test(word));
23735
+ return !routed && staysHere(program, rest) ? void 0 : program;
23736
+ }
23737
+ return listedIn(NEVER_FOR_A_WHILE, program, rest.flatMap(expandBraces));
23738
+ }
23739
+ function expandBraces(word, depth = 0) {
23740
+ const match = /^(.*?)\{([^{}]*,[^{}]*)\}(.*)$/s.exec(word);
23741
+ if (match === null || depth > 3)
23742
+ return [word];
23743
+ const [, head = "", list = "", tail = ""] = match;
23744
+ return list.split(",").flatMap((part) => expandBraces(`${head}${part}${tail}`, depth + 1));
23745
+ }
23746
+ function wrapped(takes, rest, count = 0) {
23747
+ let at = 0;
23748
+ while (at < rest.length) {
23749
+ const word = rest[at];
23750
+ if (takes.includes(word))
23751
+ at += 2;
23752
+ else if (word.startsWith("-") && word !== "-" || SETS_A_NAME.test(word))
23753
+ at += 1;
23754
+ else
23755
+ break;
23756
+ }
23757
+ return { own: rest.slice(0, at), run: rest.slice(at + count) };
23758
+ }
23759
+ function wrapper(takes = [], count = 0) {
23760
+ return (command, rest, reading) => {
23761
+ const { own: own2, run: run2 } = wrapped(takes, rest, count);
23762
+ const set2 = own2.filter((word) => SETS_A_NAME.test(word));
23763
+ return commandAsks({ ...command, words: [...set2, ...run2] }, reading);
23764
+ };
23765
+ }
23766
+ var env = (command, rest, reading) => {
23767
+ const { own: own2 } = wrapped(["-u", "--unset", "-C", "--chdir", "-P"], rest);
23768
+ if (own2.some((word) => /^(?:-[A-Za-z]*S|--split-string)/.test(word)))
23769
+ return CANT_FOLLOW;
23770
+ return wrapper(["-u", "--unset", "-C", "--chdir", "-P"])(command, rest, reading);
23771
+ };
23772
+ var commandBuiltin = (command, rest, reading) => {
23773
+ const { own: own2 } = wrapped([], rest);
23774
+ if (own2.some((word) => /^-[A-Za-z]*[vV]/.test(word)))
23775
+ return void 0;
23776
+ return wrapper()(command, rest, reading);
23777
+ };
23778
+ var XARGS_TAKES = ["-a", "-d", "-E", "-I", "-J", "-L", "-n", "-P", "-R", "-S", "-s"].concat([
23779
+ "--arg-file",
23780
+ "--delimiter",
23781
+ "--max-args",
23782
+ "--max-procs",
23783
+ "--max-chars",
23784
+ "--process-slot-var"
23785
+ ]);
23786
+ var xargs = (command, rest, reading) => {
23787
+ const { own: own2, run: run2 } = wrapped(XARGS_TAKES, rest);
23788
+ if (run2.length === 0)
23789
+ return void 0;
23790
+ const swap = swappedIn(own2);
23791
+ const words4 = swap === void 0 || swap === "" ? [...run2, FILLED] : run2.map((word) => word.split(swap).join(FILLED));
23792
+ return commandAsks({ ...command, words: words4 }, reading);
23793
+ };
23794
+ function swappedIn(own2) {
23795
+ const at = own2.findIndex((word) => /^(?:-[IJi]|--replace)/.test(word));
23796
+ const flag = own2[at];
23797
+ if (flag === void 0)
23798
+ return void 0;
23799
+ const attached = /^(?:-[IJi]|--replace=?)(.*)$/.exec(flag)?.[1] ?? "";
23800
+ if (attached !== "")
23801
+ return attached;
23802
+ return /^(?:-i|--replace)/.test(flag) ? "{}" : own2[at + 1];
23803
+ }
23804
+ var SHELL_TAKES = /* @__PURE__ */ new Set(["--rcfile", "--init-file", "--emulate"]);
23805
+ var shell = (command, rest, reading) => {
23806
+ const { string: string4, operand } = shellHanded(rest);
23807
+ if (string4)
23808
+ return operand === void 0 ? void 0 : lineAsks(operand, reading);
23809
+ return scriptAsks(command, operand, rest.includes("-s"), reading);
23810
+ };
23811
+ function shellHanded(rest) {
23812
+ let string4 = false;
23813
+ for (let at = 0; at < rest.length; at += 1) {
23814
+ const word = rest[at];
23815
+ if (word === "--")
23816
+ return { string: string4, operand: rest[at + 1] };
23817
+ if (SHELL_TAKES.has(word))
23818
+ at += 1;
23819
+ else if (/^[-+][A-Za-z]+$/.test(word)) {
23820
+ string4 ||= word.startsWith("-") && word.includes("c");
23821
+ at += word.replace(/[^oO]/g, "").length;
23822
+ } else if (!word.startsWith("--"))
23823
+ return { string: string4, operand: word };
23824
+ }
23825
+ return { string: string4, operand: void 0 };
23826
+ }
23827
+ function scriptAsks(command, operand, stdin, reading) {
23828
+ if (stdin || operand === void 0 || /^(?:-|\/dev\/stdin|\/dev\/fd\/0)$/.test(operand)) {
23829
+ const fed = command.fed.map((text) => lineAsks(text, reading));
23830
+ const asks = fed.find((each) => each !== void 0);
23831
+ if (asks !== void 0 || command.fed.length > 0)
23832
+ return asks;
23833
+ return command.piped ? PIPED_SHELL : void 0;
23834
+ }
23835
+ return programName(operand) === void 0 || operand.startsWith("/dev/fd/") ? CANT_TELL : void 0;
23836
+ }
23837
+ var sourced = (command, rest, reading) => {
23838
+ const operand = rest.find((word) => !word.startsWith("-"));
23839
+ return operand === void 0 ? void 0 : scriptAsks(command, operand, false, reading);
23840
+ };
23841
+ var evaluated = (_command, rest, reading) => lineAsks(rest.join(" "), reading);
23842
+ var trap = (_command, rest, reading) => {
23843
+ const words4 = rest[0] === "--" ? rest.slice(1) : rest;
23844
+ const action2 = words4[0];
23845
+ if (action2 === void 0 || action2 === "-" || /^-[lp]$/.test(action2))
23846
+ return void 0;
23847
+ return lineAsks(action2, reading);
23848
+ };
23849
+ var watch = (_command, rest, reading) => lineAsks(wrapped(["-n", "--interval"], rest).run.join(" "), reading);
23850
+ var find = (command, rest, reading) => {
23851
+ const words4 = rest.flatMap((word) => expandBraces(word));
23852
+ for (let at = 0; at < words4.length; at += 1) {
23853
+ if (!/^-(?:exec|execdir|ok|okdir)$/.test(words4[at]))
23854
+ continue;
23855
+ const ends = words4.findIndex((word, index) => index > at && (word === ";" || word === "+"));
23856
+ const stop = ends === -1 ? words4.length : ends;
23857
+ const run2 = words4.slice(at + 1, stop).map((word) => word.split("{}").join(FILLED));
23858
+ const asks = commandAsks({ ...command, words: run2 }, reading);
23859
+ if (asks !== void 0)
23860
+ return asks;
23861
+ at = stop;
23862
+ }
23863
+ return void 0;
23864
+ };
23865
+ var alias = (_command, rest, reading) => {
23866
+ for (const word of rest) {
23867
+ const equals = word.indexOf("=");
23868
+ const asks = equals > 0 ? lineAsks(word.slice(equals + 1), reading) : void 0;
23869
+ if (asks !== void 0)
23870
+ return asks;
23871
+ }
23872
+ return void 0;
23873
+ };
23874
+ var hash3 = (command, rest, reading) => {
23875
+ const p = rest.indexOf("-p");
23876
+ const paths = p === -1 ? rest.filter((word) => word.includes("=")).map((word) => word.slice(word.indexOf("=") + 1)) : [rest[p + 1] ?? ""];
23877
+ for (const path of paths) {
23878
+ const asks = commandAsks({ ...command, words: [path] }, reading);
23879
+ if (asks !== void 0)
23880
+ return asks;
23881
+ }
23882
+ return void 0;
23883
+ };
23884
+ var mapfile = (_command, rest, reading) => {
23885
+ const at = rest.indexOf("-C");
23886
+ return at === -1 ? void 0 : lineAsks(rest[at + 1] ?? "", reading);
23887
+ };
23888
+ var flock = (command, rest, reading) => {
23889
+ const { run: run2 } = wrapped(["-w", "--timeout", "-E", "--conflict-exit-code"], rest);
23890
+ const after = run2.slice(1);
23891
+ if (after[0] === "-c" || after[0] === "--command")
23892
+ return lineAsks(after[1] ?? "", reading);
23893
+ return commandAsks({ ...command, words: after }, reading);
23894
+ };
23895
+ var script = (command, rest, reading) => {
23896
+ const c = rest.findIndex((word) => word === "-c" || word === "--command");
23897
+ if (c !== -1)
23898
+ return lineAsks(rest[c + 1] ?? "", reading);
23899
+ const { run: run2 } = wrapped(["-t", "-T", "-I", "-O", "-B", "-E"], rest);
23900
+ return commandAsks({ ...command, words: run2.slice(1) }, reading);
23901
+ };
23902
+ function starts(rest, flags2) {
23903
+ const found = [];
23904
+ let unsure = false;
23905
+ for (let at = 0; at < rest.length; at += 1) {
23906
+ const word = rest[at];
23907
+ if (word === "--")
23908
+ return [...found, at + 1];
23909
+ if (flags2.takes.includes(word))
23910
+ at += 1;
23911
+ else if (word.startsWith("-") && word !== "-")
23912
+ unsure = unknownFlag(word, flags2);
23913
+ else {
23914
+ found.push(at);
23915
+ if (!unsure)
23916
+ return found;
23917
+ unsure = false;
23918
+ }
23919
+ }
23920
+ return found;
23921
+ }
23922
+ function unknownFlag(word, flags2) {
23923
+ return !word.includes("=") && !flags2.plain.includes(word);
23924
+ }
23925
+ function execAsks(command, words4, flags2, reading) {
23926
+ const line = shellLine(words4, flags2);
23927
+ if (line !== void 0)
23928
+ return lineAsks(line, reading);
23929
+ for (const at of starts(words4, flags2)) {
23930
+ const asks = commandAsks({ ...command, words: words4.slice(at) }, reading);
23931
+ if (asks !== void 0)
23932
+ return asks;
23933
+ }
23934
+ return void 0;
23935
+ }
23936
+ function shellLine(words4, flags2) {
23937
+ let at = 0;
23938
+ while (at < words4.length) {
23939
+ const word = words4[at];
23940
+ if (/^(?:-c|--call|--shell-mode)$/.test(word))
23941
+ return words4.slice(at + 1).join(" ");
23942
+ if (word.startsWith("--call="))
23943
+ return [word.slice(7), ...words4.slice(at + 1)].join(" ");
23944
+ if (word === "--" || !word.startsWith("-"))
23945
+ return void 0;
23946
+ at += flags2.takes.includes(word) ? 2 : 1;
23947
+ }
23948
+ return void 0;
23949
+ }
23950
+ function commanded(how) {
23951
+ return (command, rest, reading) => {
23952
+ for (const at of starts(rest, how.global)) {
23953
+ const named = rest.slice(at, at + (how.naming ?? 1));
23954
+ if (named.some((word) => word.includes(FILLED)))
23955
+ return CANT_TELL;
23956
+ const asks = verbAsks(how, command, rest, at, reading);
23957
+ if (asks !== void 0)
23958
+ return asks;
23959
+ }
23960
+ return void 0;
23961
+ };
23962
+ }
23963
+ function verbAsks(how, command, rest, at, reading) {
23964
+ const verb = rest[at] ?? "";
23965
+ const flags2 = how.runs?.get(verb);
23966
+ if (flags2 !== void 0)
23967
+ return execAsks(command, rest.slice(at + 1), flags2, reading);
23968
+ if (how.orRuns === void 0 || how.orRuns.has(verb))
23969
+ return void 0;
23970
+ return commandAsks({ ...command, words: rest.slice(at) }, reading);
23971
+ }
23972
+ var GIT_TAKES = ["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--exec-path"].concat([
23973
+ "--config-env",
23974
+ "--super-prefix"
23975
+ ]);
23976
+ var git = (_command, rest, reading) => {
23977
+ const { own: own2, run: run2 } = wrapped(GIT_TAKES, rest);
23978
+ const config2 = own2.filter((_, at) => own2[at - 1] === "-c" || own2[at - 1] === "--config-env");
23979
+ if (config2.some((word) => /^(?:alias\.|help\.autocorrect)/i.test(word)))
23980
+ return CANT_TELL;
23981
+ const [sub, ...after] = run2;
23982
+ if (sub === void 0)
23983
+ return void 0;
23984
+ if (sub.includes(FILLED))
23985
+ return CANT_TELL;
23986
+ return GIT_RUNS.get(sub)?.(after, reading);
23987
+ };
23988
+ var GIT_RUNS = /* @__PURE__ */ new Map([
23989
+ ["config", (after) => after.some((word) => /^alias\./i.test(word)) ? CANT_TELL : void 0],
23990
+ [
23991
+ "submodule",
23992
+ (after, reading) => {
23993
+ const at = after.indexOf("foreach");
23994
+ if (at === -1)
23995
+ return void 0;
23996
+ return lineAsks(wrapped([], after.slice(at + 1)).run.join(" "), reading);
23997
+ }
23998
+ ],
23999
+ [
24000
+ "rebase",
24001
+ (after, reading) => {
24002
+ const lines2 = after.flatMap((word, at) => word === "-x" || word === "--exec" ? [after[at + 1] ?? ""] : word.startsWith("--exec=") ? [word.slice(7)] : []);
24003
+ return lines2.map((line) => lineAsks(line, reading)).find((asks) => asks !== void 0);
24004
+ }
24005
+ ],
24006
+ [
24007
+ "bisect",
24008
+ (after, reading) => after[0] === "run" ? commandAsks(alone(after.slice(1)), reading) : void 0
24009
+ ]
24010
+ ]);
24011
+ var PNPM_COMMANDS = new Set("add install i update up upgrade remove rm uninstall un link ln unlink import rebuild rb prune fetch patch patch-commit patch-remove audit list ls ll la outdated why licenses run run-script test t tst start exec dlx create publish pack store root bin config c get set setup init deploy env recursive multi m server doctor help self-update cat-file cat-index find-hash approve-builds ignored-builds install-test it dedupe sbom version".split(" "));
24012
+ var NPM_EXEC = {
24013
+ takes: ["--package", "-p", "-w", "--workspace", "--prefix", "-C"],
24014
+ plain: ["-y", "--yes", "--no", "-ws", "--workspaces", "--include-workspace-root", "-q", "-s"]
24015
+ };
24016
+ var UV_PLAIN = ["-q", "--quiet", "-v", "--verbose", "-n", "--no-cache", "--offline"].concat(["--native-tls", "--no-progress", "--no-config", "--preview", "--isolated", "--frozen"], ["--locked", "--managed-python", "--no-managed-python", "--no-python-downloads"]);
24017
+ var UV_TAKES = ["--color", "--cache-dir", "--config-file", "--directory", "--project"].concat(["--python-preference", "--allow-insecure-host", "--index-url", "--extra-index-url"], ["--find-links", "-f", "--index", "--default-index"]);
24018
+ var READ_THROUGH = /* @__PURE__ */ new Map([
24019
+ ["timeout", wrapper(["-k", "--kill-after", "-s", "--signal"], 1)],
24020
+ ["gtimeout", wrapper(["-k", "--kill-after", "-s", "--signal"], 1)],
24021
+ ["env", env],
24022
+ ["nice", wrapper(["-n", "--adjustment"])],
24023
+ ["nohup", wrapper()],
24024
+ ["time", wrapper(["-o", "--output", "-f", "--format"])],
24025
+ ["command", commandBuiltin],
24026
+ ["builtin", wrapper()],
24027
+ ["exec", wrapper(["-a"])],
24028
+ ["caffeinate", wrapper(["-t", "-w"])],
24029
+ ["stdbuf", wrapper(["-i", "-o", "-e"])],
24030
+ ["arch", wrapper(["-arch", "-e", "-d"])],
24031
+ ["setsid", wrapper()],
24032
+ ["unbuffer", wrapper()],
24033
+ ["taskpolicy", wrapper(["-c", "-t", "-l", "-g", "-p"])],
24034
+ ["ionice", wrapper(["-c", "-n", "-p"])],
24035
+ ["xcrun", wrapper(["-sdk", "--sdk", "-toolchain", "--toolchain"])],
24036
+ ["flock", flock],
24037
+ ["script", script],
24038
+ ["xargs", xargs],
24039
+ ["sh", shell],
24040
+ ["bash", shell],
24041
+ ["zsh", shell],
24042
+ ["dash", shell],
24043
+ ["ksh", shell],
24044
+ ["source", sourced],
24045
+ [".", sourced],
24046
+ ["eval", evaluated],
24047
+ ["trap", trap],
24048
+ ["watch", watch],
24049
+ ["find", find],
24050
+ ["alias", alias],
24051
+ ["hash", hash3],
24052
+ ["mapfile", mapfile],
24053
+ ["readarray", mapfile],
24054
+ ["git", git],
24055
+ ["gh", commanded({ global: { takes: ["-R", "--repo", "--hostname"], plain: [] }, naming: 2 })],
24056
+ [
24057
+ "kubectl",
24058
+ commanded({
24059
+ global: {
24060
+ takes: ["-n", "--namespace", "--context", "--cluster", "--kubeconfig", "-s", "--server"],
24061
+ plain: []
24062
+ }
24063
+ })
24064
+ ],
24065
+ [
24066
+ "npm",
24067
+ commanded({
24068
+ global: { takes: ["-C", "--prefix", "-w", "--workspace", "--userconfig"], plain: [] },
24069
+ runs: /* @__PURE__ */ new Map([
24070
+ ["exec", NPM_EXEC],
24071
+ ["x", NPM_EXEC]
24072
+ ])
24073
+ })
24074
+ ],
24075
+ ["npx", (command, rest, reading) => execAsks(command, rest, NPM_EXEC, reading)],
24076
+ [
24077
+ "pnpm",
24078
+ commanded({
24079
+ global: {
24080
+ takes: ["-C", "--dir", "--filter", "-F", "--reporter", "--loglevel", "--filter-prod"],
24081
+ plain: ["-r", "--recursive", "-w", "--workspace-root", "--silent", "-s", "--parallel"]
24082
+ },
24083
+ runs: /* @__PURE__ */ new Map([
24084
+ ["exec", { takes: ["--resume-from", "--filter", "-F", "-C", "--dir"], plain: ["-r"] }]
24085
+ ]),
24086
+ orRuns: PNPM_COMMANDS
24087
+ })
24088
+ ],
24089
+ [
24090
+ "yarn",
24091
+ commanded({
24092
+ global: { takes: ["--cwd"], plain: ["-s", "--silent"] },
24093
+ runs: /* @__PURE__ */ new Map([["exec", { takes: [], plain: [] }]])
24094
+ })
24095
+ ],
24096
+ [
24097
+ "uv",
24098
+ commanded({
24099
+ global: { takes: UV_TAKES, plain: UV_PLAIN },
24100
+ runs: /* @__PURE__ */ new Map([
24101
+ [
24102
+ "run",
24103
+ {
24104
+ takes: UV_TAKES.concat(["--with", "--with-editable", "--with-requirements"]).concat([
24105
+ "--python",
24106
+ "-p",
24107
+ "--env-file",
24108
+ "--group",
24109
+ "--extra",
24110
+ "--package",
24111
+ "--no-group"
24112
+ ]),
24113
+ plain: UV_PLAIN.concat([
24114
+ "--no-project",
24115
+ "--no-sync",
24116
+ "--active",
24117
+ "--all-extras"
24118
+ ]).concat([
24119
+ "--all-groups",
24120
+ "--no-dev",
24121
+ "--dev",
24122
+ "--script",
24123
+ "-s",
24124
+ "--module",
24125
+ "-m",
24126
+ "--exact"
24127
+ ])
24128
+ }
24129
+ ]
24130
+ ])
24131
+ })
24132
+ ]
24133
+ ]);
24134
+ function flagSet(words4) {
24135
+ return new Set(words4.split(" "));
24136
+ }
24137
+ var CURL = {
24138
+ plain: flagSet("-s -S -f -i -I -L -v -k -g -N -G -O -J -# -4 -6 -q -n -Z --silent --show-error --fail --fail-with-body --fail-early --include --head --location --verbose --insecure --globoff --no-buffer --get --remote-name --remote-name-all --remote-header-name --compressed --no-progress-meter --progress-bar --http1.0 --http1.1 --http2 --http2-prior-knowledge --path-as-is --retry-connrefused --retry-all-errors --create-dirs --ipv4 --ipv6 --raw --tcp-nodelay --digest --basic --anyauth --location-trusted --post301 --post302 --post303 --styled-output --no-styled-output --disable --netrc --parallel"),
24139
+ takes: flagSet("-X -H -d -o -w -m -u -A -e -b -c -F -D -T -r -E -Y -y -z --request --header --data --data-raw --data-binary --data-urlencode --json --output --write-out --max-time --connect-timeout --retry --retry-delay --retry-max-time --user --user-agent --referer --cookie --cookie-jar --form --dump-header --upload-file --range --max-redirs --noproxy --limit-rate --max-filesize --trace --trace-ascii --stderr --cacert --cert --key --keepalive-time --oauth2-bearer --speed-limit --speed-time --time-cond --etag-save --etag-compare --url-query --unix-socket --netrc-file --expect100-timeout")
24140
+ };
24141
+ var WGET = {
24142
+ plain: flagSet("-q -S -v -c -N -nv -nc --quiet --spider --server-response --verbose --no-verbose --continue --no-check-certificate --no-clobber"),
24143
+ takes: flagSet("-O -T -t -o -P --output-document --timeout --tries --header --post-data --method --body-data --output-file --directory-prefix")
24144
+ };
24145
+ var ON_THIS_MACHINE = new RegExp(String.raw`^(?:https?:\/\/)?(?:localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\])` + String.raw`(?::[\d${FILLED}]+)?(?:[\/?#].*)?$`, "is");
24146
+ function staysHere(program, rest) {
24147
+ const known = program === "curl" ? CURL : WGET;
24148
+ let addresses = 0;
24149
+ for (let at = 0; at < rest.length; at += 1) {
24150
+ const word = rest[at];
24151
+ if (!word.startsWith("-") || word === "-") {
24152
+ if (!ON_THIS_MACHINE.test(word))
24153
+ return false;
24154
+ addresses += 1;
24155
+ continue;
24156
+ }
24157
+ const taken = flagTakes(known, word);
24158
+ if (taken === void 0)
24159
+ return false;
24160
+ at += taken;
24161
+ }
24162
+ return addresses > 0;
24163
+ }
24164
+ function flagTakes(known, word) {
24165
+ const [name = "", value] = word.startsWith("--") ? word.split(/=(.*)/s) : [word];
24166
+ if (known.plain.has(name))
24167
+ return 0;
24168
+ if (known.takes.has(name))
24169
+ return value === void 0 ? 1 : 0;
24170
+ return word.startsWith("--") ? void 0 : shortFlagsTake(known, word);
24171
+ }
24172
+ function shortFlagsTake(known, word) {
24173
+ for (let at = 1; at < word.length; at += 1) {
24174
+ const flag = `-${word[at]}`;
24175
+ if (known.takes.has(flag))
24176
+ return at === word.length - 1 ? 1 : 0;
24177
+ if (!known.plain.has(flag))
24178
+ return void 0;
24179
+ }
24180
+ return 0;
24181
+ }
24182
+
23028
24183
  // node_modules/@chipschat/protocol/dist/src/push.js
23029
24184
  var PUSH_WORDS = {
23030
24185
  /** An ask of an agent's that waits on a person (ADR 0045). */
@@ -23312,6 +24467,76 @@ async function download(fetcher, token, attachment2) {
23312
24467
  return new Uint8Array(await response.arrayBuffer());
23313
24468
  }
23314
24469
 
24470
+ // node_modules/@chipschat/harness/dist/mode.js
24471
+ var LONGEST_WAIT_MS = 2147483647;
24472
+ function modeHolds(mode, now) {
24473
+ if (mode === void 0)
24474
+ return void 0;
24475
+ return mode.until === void 0 || Date.parse(mode.until) > now ? mode : void 0;
24476
+ }
24477
+ var keyOf = (mode) => mode === void 0 ? "" : `${mode.id}|${mode.until ?? ""}`;
24478
+ var ModeWatch = class {
24479
+ options;
24480
+ picked;
24481
+ /** What was said last, as `keyOf` writes it. */
24482
+ said = "";
24483
+ ends;
24484
+ settling;
24485
+ constructor(options) {
24486
+ this.options = options;
24487
+ }
24488
+ /** The mode that holds now, or nothing. */
24489
+ get current() {
24490
+ return modeHolds(this.picked, this.options.now());
24491
+ }
24492
+ /** A hello's policy: the mode as the server keeps it now, or none. */
24493
+ fromHello(policy2) {
24494
+ this.picked = policy2?.mode ?? void 0;
24495
+ this.settle();
24496
+ }
24497
+ /** An event heard: a `policy.updated` for this harness, for every space, that says a mode. */
24498
+ heard(event, harnessId) {
24499
+ if (event["type"] !== "policy.updated" || event["space_id"] != null)
24500
+ return;
24501
+ if (harnessId === void 0 || event["harness_id"] !== harnessId)
24502
+ return;
24503
+ const policy2 = event["policy"];
24504
+ if (policy2?.mode === void 0)
24505
+ return;
24506
+ this.picked = policy2.mode ?? void 0;
24507
+ this.settle();
24508
+ }
24509
+ stop() {
24510
+ clearTimeout(this.ends);
24511
+ clearTimeout(this.settling);
24512
+ this.ends = void 0;
24513
+ this.settling = void 0;
24514
+ }
24515
+ settle() {
24516
+ clearTimeout(this.settling);
24517
+ this.settling = setTimeout(() => {
24518
+ this.settling = void 0;
24519
+ this.say();
24520
+ }, 0);
24521
+ }
24522
+ /** Say the mode that holds now if it changed, and look again when it ends. */
24523
+ say() {
24524
+ clearTimeout(this.ends);
24525
+ this.ends = void 0;
24526
+ const now = this.options.now();
24527
+ const mode = modeHolds(this.picked, now);
24528
+ const until = mode?.until === void 0 ? void 0 : Date.parse(mode.until);
24529
+ if (until !== void 0) {
24530
+ this.ends = setTimeout(() => this.say(), Math.min(Math.max(until - now, 0), LONGEST_WAIT_MS));
24531
+ }
24532
+ const key = keyOf(mode);
24533
+ if (key === this.said)
24534
+ return;
24535
+ this.said = key;
24536
+ this.options.changed(mode);
24537
+ }
24538
+ };
24539
+
23315
24540
  // node_modules/@chipschat/harness/dist/project.js
23316
24541
  import { execFile } from "node:child_process";
23317
24542
  import { existsSync } from "node:fs";
@@ -23379,10 +24604,10 @@ function heldNote(pushed, name) {
23379
24604
  return `(Not in the space's project: it couldn't be sent: ${stopped(pushed.why)})`;
23380
24605
  }
23381
24606
  }
23382
- async function checkGit(git2 = "git", path = process.env["PATH"] ?? "/usr/bin:/bin") {
24607
+ async function checkGit(git3 = "git", path = process.env["PATH"] ?? "/usr/bin:/bin") {
23383
24608
  const [major, minor] = versionIn(PROJECT_GIT_VERSION) ?? [0, 0];
23384
24609
  return new Promise((resolve6) => {
23385
- execFile(git2, ["--version"], { env: { PATH: path } }, (error62, stdout) => {
24610
+ execFile(git3, ["--version"], { env: { PATH: path } }, (error62, stdout) => {
23386
24611
  if (error62 !== null)
23387
24612
  return resolve6({ ok: false, why: "git was not found on this machine" });
23388
24613
  const mine = versionIn(stdout);
@@ -23816,7 +25041,7 @@ ${sent.err}`;
23816
25041
  ["merge.conflictStyle", "merge"],
23817
25042
  ["core.quotePath", "false"]
23818
25043
  ];
23819
- const env2 = {
25044
+ const env3 = {
23820
25045
  // biome-ignore lint/style/noProcessEnv: git is found where the harness finds its tools.
23821
25046
  PATH: options.path ?? process.env["PATH"] ?? "/usr/bin:/bin",
23822
25047
  GIT_CONFIG_NOSYSTEM: "1",
@@ -23830,11 +25055,11 @@ ${sent.err}`;
23830
25055
  GIT_CONFIG_COUNT: String(pairs.length)
23831
25056
  };
23832
25057
  pairs.forEach(([key, value], at) => {
23833
- env2[`GIT_CONFIG_KEY_${at}`] = key;
23834
- env2[`GIT_CONFIG_VALUE_${at}`] = value;
25058
+ env3[`GIT_CONFIG_KEY_${at}`] = key;
25059
+ env3[`GIT_CONFIG_VALUE_${at}`] = value;
23835
25060
  });
23836
25061
  return new Promise((resolve6) => {
23837
- execFile(options.git ?? "git", [...args], { cwd: this.copy, env: env2, maxBuffer: 64 * 1024 * 1024 }, (error62, stdout, stderr) => resolve6({ ok: error62 === null, out: stdout, err: stderr }));
25062
+ execFile(options.git ?? "git", [...args], { cwd: this.copy, env: env3, maxBuffer: 64 * 1024 * 1024 }, (error62, stdout, stderr) => resolve6({ ok: error62 === null, out: stdout, err: stderr }));
23838
25063
  });
23839
25064
  }
23840
25065
  };
@@ -24294,6 +25519,9 @@ var Settings = class {
24294
25519
  * mode it runs in, and each entry. Chips decides nothing from it; a person reads it on the
24295
25520
  * harness's Permissions page. Send it when connected and whenever the settings are read again;
24296
25521
  * a copy the same as the last is not sent again. An older Chips has no such page and refuses it.
25522
+ * `modes` says which modes a person may pick for its sessions from Chips (ADR 0300, addendum of
25523
+ * 19 November 2026), the one they start in, and the one they run in now; without it, Chips
25524
+ * offers no picker. The pick reaches the harness as `chips.mode`.
24297
25525
  */
24298
25526
  ownRules(copy) {
24299
25527
  return this.send("own-rules", this.harnessId(), copy, {});
@@ -24483,6 +25711,11 @@ var Chips = class _Chips {
24483
25711
  since;
24484
25712
  connectionState = "connecting";
24485
25713
  helloEvent;
25714
+ /** The mode a person picked for this harness's sessions (Chips ADR 0300), said as it changes. */
25715
+ modes = new ModeWatch({
25716
+ now: () => Date.now(),
25717
+ changed: (mode) => this.emitter.emit("mode", mode)
25718
+ });
24486
25719
  /** What this harness last said is wrong on its side, said again whenever it reconnects. */
24487
25720
  trouble;
24488
25721
  /**
@@ -24631,6 +25864,16 @@ var Chips = class _Chips {
24631
25864
  get policy() {
24632
25865
  return this.hello.policy;
24633
25866
  }
25867
+ /**
25868
+ * The mode a person picked in Chips for this harness's sessions (Chips ADR 0300, addendum of 19
25869
+ * November 2026), while it holds: one of the modes the harness offers in its own rules
25870
+ * (`settings.ownRules`, `modes`). Nothing while none is picked, or once its `until` has passed.
25871
+ * Put each session in it where the agent offers it, else in the mode it starts in; the `mode`
25872
+ * event says when it changes, its end included.
25873
+ */
25874
+ get mode() {
25875
+ return this.modes.current;
25876
+ }
24634
25877
  /** The highest `seq` heard, to persist for `since` on the next start. */
24635
25878
  get lastSeq() {
24636
25879
  return this.since;
@@ -24988,6 +26231,7 @@ var Chips = class _Chips {
24988
26231
  close() {
24989
26232
  this.closed = true;
24990
26233
  clearTimeout(this.timer);
26234
+ this.modes.stop();
24991
26235
  clearTimeout(this.saving);
24992
26236
  this.saving = void 0;
24993
26237
  this.saveNow();
@@ -25123,6 +26367,7 @@ var Chips = class _Chips {
25123
26367
  onHello(socket, hello2) {
25124
26368
  this.helloEvent = hello2;
25125
26369
  this.emitter.emit("hello", hello2);
26370
+ this.modes.fromHello(hello2.policy);
25126
26371
  const again2 = this.replay?.again;
25127
26372
  const from = again2 !== void 0 && again2.size > 0 ? Math.min(...again2) - 1 : this.since;
25128
26373
  socket.send(JSON.stringify({
@@ -25253,6 +26498,7 @@ var Chips = class _Chips {
25253
26498
  this.save();
25254
26499
  }
25255
26500
  this.settleWaiters(event);
26501
+ this.modes.heard(event, this.me()?.harness_id);
25256
26502
  this.emitter.emit("event", event);
25257
26503
  this.routeToRuns(event);
25258
26504
  if (event["type"] === "run.cancel" && typeof event["run_id"] === "string") {
@@ -25469,12 +26715,12 @@ function addPasswordCommand(account, secret) {
25469
26715
  return `add-generic-password -U -a ${quoted(account)} -s ${quoted(SERVICE)} -w ${quoted(secret)}
25470
26716
  `;
25471
26717
  }
25472
- function configHome(env2) {
25473
- const own2 = env2["CHIPS_CONFIG_HOME"];
26718
+ function configHome(env3) {
26719
+ const own2 = env3["CHIPS_CONFIG_HOME"];
25474
26720
  if (own2 !== void 0 && own2 !== "")
25475
26721
  return own2;
25476
- const xdg = env2["XDG_CONFIG_HOME"];
25477
- return join2(xdg !== void 0 && xdg !== "" ? xdg : join2(env2["HOME"] ?? homedir(), ".config"), "chips");
26722
+ const xdg = env3["XDG_CONFIG_HOME"];
26723
+ return join2(xdg !== void 0 && xdg !== "" ? xdg : join2(env3["HOME"] ?? homedir(), ".config"), "chips");
25478
26724
  }
25479
26725
  function answers(command, args) {
25480
26726
  try {
@@ -25594,9 +26840,9 @@ function orInTheFile(best, plain, say = (line) => void process.stderr.write(`${l
25594
26840
  }
25595
26841
  };
25596
26842
  }
25597
- function openKeyStore(env2, platform = process.platform) {
25598
- const plain = file2(join2(configHome(env2), "harness-keys.json"));
25599
- if (env2["CHIPS_NO_KEYCHAIN"] === "true")
26843
+ function openKeyStore(env3, platform = process.platform) {
26844
+ const plain = file2(join2(configHome(env3), "harness-keys.json"));
26845
+ if (env3["CHIPS_NO_KEYCHAIN"] === "true")
25600
26846
  return plain;
25601
26847
  if (platform === "darwin" && answers("/usr/bin/security", ["list-keychains"]))
25602
26848
  return orInTheFile(keychain(), plain);
@@ -25608,8 +26854,8 @@ function openKeyStore(env2, platform = process.platform) {
25608
26854
  // node_modules/@chipschat/harness/dist/steps.js
25609
26855
  import { writeSync } from "node:fs";
25610
26856
  var STEP_MARK = "chips-step ";
25611
- function reportStep(step, detail = {}, env2 = process.env, write = (line) => void writeSync(1, line)) {
25612
- if (env2["CHIPS_STEPS"] !== "json")
26857
+ function reportStep(step, detail = {}, env3 = process.env, write = (line) => void writeSync(1, line)) {
26858
+ if (env3["CHIPS_STEPS"] !== "json")
25613
26859
  return;
25614
26860
  try {
25615
26861
  write(`${STEP_MARK}${JSON.stringify({ step, ...detail })}
@@ -25627,16 +26873,16 @@ var JoinError = class extends Error {
25627
26873
  this.refusal = refusal;
25628
26874
  }
25629
26875
  };
25630
- function serverJsonUrl(env2) {
26876
+ function serverJsonUrl(env3) {
25631
26877
  try {
25632
- const said = JSON.parse(readFileSync2(joinPath(configHome(env2), "server.json"), "utf8"));
26878
+ const said = JSON.parse(readFileSync2(joinPath(configHome(env3), "server.json"), "utf8"));
25633
26879
  return typeof said.url === "string" && said.url !== "" ? said.url : void 0;
25634
26880
  } catch {
25635
26881
  return void 0;
25636
26882
  }
25637
26883
  }
25638
- function serverHere(env2) {
25639
- const url2 = serverJsonUrl(env2);
26884
+ function serverHere(env3) {
26885
+ const url2 = serverJsonUrl(env3);
25640
26886
  if (url2 === void 0)
25641
26887
  return void 0;
25642
26888
  let port;
@@ -25656,8 +26902,8 @@ function serverHere(env2) {
25656
26902
  }
25657
26903
  return { url: url2.replace(/\/$/, ""), port, hosts };
25658
26904
  }
25659
- function hereInstead(url2, env2) {
25660
- const here2 = serverHere(env2);
26905
+ function hereInstead(url2, env3) {
26906
+ const here2 = serverHere(env3);
25661
26907
  if (here2 === void 0)
25662
26908
  return void 0;
25663
26909
  try {
@@ -25668,22 +26914,22 @@ function hereInstead(url2, env2) {
25668
26914
  return void 0;
25669
26915
  }
25670
26916
  }
25671
- function accountsHere(url2, name, env2) {
25672
- const here2 = serverHere(env2);
26917
+ function accountsHere(url2, name, env3) {
26918
+ const here2 = serverHere(env3);
25673
26919
  if (here2 === void 0 || here2.url !== url2.replace(/\/$/, ""))
25674
26920
  return [];
25675
26921
  return [...here2.hosts].filter((host) => /^\d+\.\d+\.\d+\.\d+$/.test(host) && host !== "127.0.0.1").map((host) => accountOf(`http://${host}${here2.port === "" ? "" : `:${here2.port}`}`, name));
25676
26922
  }
25677
- function findServer(options, env2) {
26923
+ function findServer(options, env3) {
25678
26924
  if (options.link !== void 0) {
25679
26925
  const parsed = parseJoinLink(options.link);
25680
26926
  if (parsed === void 0) {
25681
26927
  throw new JoinError("invalid", "That is not a join link: it looks like <address>/j/<secret>.");
25682
26928
  }
25683
- const here2 = hereInstead(parsed.url, env2);
26929
+ const here2 = hereInstead(parsed.url, env3);
25684
26930
  return here2 === void 0 ? parsed : { url: here2, secret: parsed.secret };
25685
26931
  }
25686
- const url2 = options.url ?? env2["CHIPS_URL"] ?? serverJsonUrl(env2);
26932
+ const url2 = options.url ?? env3["CHIPS_URL"] ?? serverJsonUrl(env3);
25687
26933
  if (url2 === void 0 || url2 === "") {
25688
26934
  throw new JoinError("nowhere", "Where is Chips? Pass a link or url, set CHIPS_URL, or run chips up on this machine.");
25689
26935
  }
@@ -25712,8 +26958,8 @@ function keptAtAny(store, accounts) {
25712
26958
  }
25713
26959
  return void 0;
25714
26960
  }
25715
- function rehomed(store, account, joined3, env2) {
25716
- const here2 = hereInstead(joined3.url, env2);
26961
+ function rehomed(store, account, joined3, env3) {
26962
+ const here2 = hereInstead(joined3.url, env3);
25717
26963
  if (here2 === void 0 || here2 === joined3.url)
25718
26964
  return joined3;
25719
26965
  if (store !== false) {
@@ -25822,25 +27068,25 @@ function askOrRedeem(server, options) {
25822
27068
  }
25823
27069
  var usedUp = (error62) => error62 instanceof JoinError && USED_UP.has(error62.refusal);
25824
27070
  async function join3(options) {
25825
- const env2 = options.env ?? process.env;
25826
- reportStep("joining", {}, env2);
25827
- const server = findServer(options, env2);
25828
- const store = options.keep ?? openKeyStore(env2);
27071
+ const env3 = options.env ?? process.env;
27072
+ reportStep("joining", {}, env3);
27073
+ const server = findServer(options, env3);
27074
+ const store = options.keep ?? openKeyStore(env3);
25829
27075
  const account = accountOf(server.url, options.name);
25830
- const found = keptAtAny(store, [account, ...accountsHere(server.url, options.name, env2)]);
27076
+ const found = keptAtAny(store, [account, ...accountsHere(server.url, options.name, env3)]);
25831
27077
  const from = server.secret === void 0 ? void 0 : linkHash(server.secret);
25832
27078
  if (found !== void 0 && (from === void 0 || found.kept.from === from))
25833
- return rehomed(store, found.account, found.kept.joined, env2);
27079
+ return rehomed(store, found.account, found.kept.joined, env3);
25834
27080
  let answer;
25835
27081
  try {
25836
27082
  answer = await askOrRedeem(server, options);
25837
27083
  } catch (error62) {
25838
27084
  if (found !== void 0 && usedUp(error62))
25839
- return rehomed(store, found.account, found.kept.joined, env2);
27085
+ return rehomed(store, found.account, found.kept.joined, env3);
25840
27086
  throw error62;
25841
27087
  }
25842
27088
  const answered = joinedOf(answer);
25843
- const joined3 = { ...answered, url: hereInstead(answered.url, env2) ?? answered.url };
27089
+ const joined3 = { ...answered, url: hereInstead(answered.url, env3) ?? answered.url };
25844
27090
  if (store !== false)
25845
27091
  keepTheKey(store, account, { ...joined3, from, hello: "due" });
25846
27092
  return joined3;
@@ -26100,8 +27346,8 @@ function promptFor(message, options = {}) {
26100
27346
  const held = options.rulesHeld === true;
26101
27347
  const earlier = options.earlier ?? [];
26102
27348
  const notes = message.room?.notes ?? {};
26103
- const whole2 = taker === void 0 ? void 0 : held ? noteWithoutRules(message.room, taker) : notes[taker];
26104
- const { note, about } = taker === void 0 ? { note: whole2, about: void 0 } : noteAndAbout(whole2, message.room, taker);
27349
+ const whole3 = taker === void 0 ? void 0 : held ? noteWithoutRules(message.room, taker) : notes[taker];
27350
+ const { note, about } = taker === void 0 ? { note: whole3, about: void 0 } : noteAndAbout(whole3, message.room, taker);
26105
27351
  const sending = options.sendsFiles === true && !held ? sendingFiles({ project: options.project !== void 0 }) : void 0;
26106
27352
  const project = options.project === void 0 ? void 0 : held ? renderProjectFacts(options.project) : renderProjectNote(options.project, { othersInRoom: othersBeside(message, taker) });
26107
27353
  return [
@@ -26202,7 +27448,7 @@ var associatedApp = (app) => app === void 0 ? "" : ` <key>AssociatedBundleIdent
26202
27448
  `;
26203
27449
  function launchdPlist(spec, logFile, app) {
26204
27450
  const args = spec.command.map((word) => ` <string>${xml(word)}</string>`).join("\n");
26205
- const env2 = Object.entries(spec.environment).map(([key, value]) => ` <key>${xml(key)}</key>
27451
+ const env3 = Object.entries(spec.environment).map(([key, value]) => ` <key>${xml(key)}</key>
26206
27452
  <string>${xml(value)}</string>`).join("\n");
26207
27453
  return `<?xml version="1.0" encoding="UTF-8"?>
26208
27454
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -26219,7 +27465,7 @@ ${args}
26219
27465
  <string>${xml(spec.folder)}</string>
26220
27466
  <key>EnvironmentVariables</key>
26221
27467
  <dict>
26222
- ${env2}
27468
+ ${env3}
26223
27469
  </dict>
26224
27470
  <key>RunAtLoad</key>
26225
27471
  <true/>
@@ -26237,7 +27483,7 @@ function systemdUnit(spec, logFile) {
26237
27483
  const literal2 = (value) => value.replace(/%/g, "%%");
26238
27484
  const quote = (value) => `"${literal2(value).replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
26239
27485
  const word = (value) => quote(value.replace(/\$/g, "$$$$"));
26240
- const env2 = Object.entries(spec.environment).map(([key, value]) => `Environment=${quote(`${key}=${value}`)}`).join("\n");
27486
+ const env3 = Object.entries(spec.environment).map(([key, value]) => `Environment=${quote(`${key}=${value}`)}`).join("\n");
26241
27487
  return `# ${MARK}. Its bridge's \`npm run keep -- --stop\` stops it and removes this file.
26242
27488
  [Unit]
26243
27489
  Description=${spec.label}
@@ -26246,7 +27492,7 @@ After=network-online.target
26246
27492
  [Service]
26247
27493
  ExecStart=${spec.command.map(word).join(" ")}
26248
27494
  WorkingDirectory=${literal2(spec.folder)}
26249
- ${env2}
27495
+ ${env3}
26250
27496
  Restart=always
26251
27497
  RestartSec=5
26252
27498
  StandardOutput=append:${literal2(logFile)}
@@ -26282,9 +27528,9 @@ var HANDED_OVER = /* @__PURE__ */ new Set([
26282
27528
  "CHIPS_STOP_COMMAND",
26283
27529
  "CHIPS_STEPS"
26284
27530
  ]);
26285
- function keepEnvironment(url2, env2 = process.env, names = [], node2) {
27531
+ function keepEnvironment(url2, env3 = process.env, names = [], node2) {
26286
27532
  const kept2 = { CHIPS_URL: url2 };
26287
- for (const [name, value] of Object.entries(env2)) {
27533
+ for (const [name, value] of Object.entries(env3)) {
26288
27534
  if (value === void 0 || value === "")
26289
27535
  continue;
26290
27536
  if (name === "PATH" || names.includes(name) || name.startsWith("CHIPS_") && !HANDED_OVER.has(name))
@@ -26300,21 +27546,21 @@ function nodeFirst(folder2, path) {
26300
27546
  return [folder2, ...rest].join(delimiter);
26301
27547
  }
26302
27548
  function runsKept(label2, given = {}) {
26303
- const env2 = given.env ?? process.env;
26304
- if (env2["XPC_SERVICE_NAME"] === label2)
27549
+ const env3 = given.env ?? process.env;
27550
+ if (env3["XPC_SERVICE_NAME"] === label2)
26305
27551
  return true;
26306
- const started2 = env2["SYSTEMD_EXEC_PID"] ?? "";
27552
+ const started2 = env3["SYSTEMD_EXEC_PID"] ?? "";
26307
27553
  if (started2 !== "")
26308
27554
  return started2 === String(given.pid ?? process.pid);
26309
27555
  const terminal = given.terminal ?? process.stdout.isTTY === true;
26310
- return (env2["INVOCATION_ID"] ?? "") !== "" && !terminal;
27556
+ return (env3["INVOCATION_ID"] ?? "") !== "" && !terminal;
26311
27557
  }
26312
- function keptNode(env2 = process.env) {
26313
- const given = env2["CHIPS_NODE"];
26314
- return given !== void 0 && given !== "" ? given : nodeOnPath(env2);
27558
+ function keptNode(env3 = process.env) {
27559
+ const given = env3["CHIPS_NODE"];
27560
+ return given !== void 0 && given !== "" ? given : nodeOnPath(env3);
26315
27561
  }
26316
- function nodeOnPath(env2 = process.env) {
26317
- for (const folder2 of (env2["PATH"] ?? "").split(delimiter)) {
27562
+ function nodeOnPath(env3 = process.env) {
27563
+ for (const folder2 of (env3["PATH"] ?? "").split(delimiter)) {
26318
27564
  if (folder2 === "")
26319
27565
  continue;
26320
27566
  try {
@@ -26494,10 +27740,10 @@ var AcpError = class extends Error {
26494
27740
  function isAuthRequired(error62) {
26495
27741
  return error62 instanceof AcpError && error62.code === -32e3 && /auth/i.test(error62.message);
26496
27742
  }
26497
- function processWire(command, cwd, env2, log2) {
27743
+ function processWire(command, cwd, env3, log2) {
26498
27744
  const [program, ...args] = command;
26499
27745
  if (program === void 0) throw new Error("an agent needs a command");
26500
- const child = spawn(program, args, { cwd, env: env2, stdio: ["pipe", "pipe", "pipe"] });
27746
+ const child = spawn(program, args, { cwd, env: env3, stdio: ["pipe", "pipe", "pipe"] });
26501
27747
  const lines2 = createInterface({ input: child.stdout });
26502
27748
  createInterface({ input: child.stderr }).on("line", log2);
26503
27749
  const closers = [];
@@ -26712,6 +27958,27 @@ import { delimiter as delimiter3, dirname as dirname4, join as join7 } from "nod
26712
27958
 
26713
27959
  // src/kinds.ts
26714
27960
  var SIGN_IN_DOING = "Run this in Terminal, then try again. Your browser opens to sign in.";
27961
+ var CLAUDE_MODES = [
27962
+ { id: "default", name: "Default", words: "Asks before edits and commands its settings don't allow." },
27963
+ { id: "acceptEdits", name: "Accept edits", words: "Edits files without asking. Commands still ask." },
27964
+ { id: "auto", name: "Auto", words: "Claude Code judges each step and asks only when one looks risky." },
27965
+ { id: "bypassPermissions", name: "Bypass permissions", words: "Never asks. Whatever it does just happens.", everything: true }
27966
+ ];
27967
+ var CODEX_MODES = [
27968
+ { id: "read-only", name: "Read-only", words: "Reads on its own. Changes nothing without a yes: it asks first, or says it can't." },
27969
+ {
27970
+ id: "workspace-write",
27971
+ name: "Workspace access",
27972
+ words: "Edits and runs commands in the agent's folder. Asks before the network or anything outside it."
27973
+ },
27974
+ { id: "agent", name: "Auto review", words: "Codex judges each step and asks only when one looks risky." },
27975
+ {
27976
+ id: "agent-full-access",
27977
+ name: "Full access",
27978
+ words: "Never asks. Reaches the network and any file on this computer.",
27979
+ everything: true
27980
+ }
27981
+ ];
26715
27982
  var KNOWN2 = [
26716
27983
  {
26717
27984
  id: "claude-code",
@@ -26724,6 +27991,7 @@ var KNOWN2 = [
26724
27991
  installLine: "curl -fsSL https://claude.ai/install.sh | bash",
26725
27992
  installedIn: ".local/bin",
26726
27993
  mode: "default",
27994
+ modes: CLAUDE_MODES,
26727
27995
  signIn: "run `claude auth login`",
26728
27996
  signInLine: "claude auth login",
26729
27997
  signInDoing: SIGN_IN_DOING
@@ -26739,6 +28007,7 @@ var KNOWN2 = [
26739
28007
  installLine: "curl -fsSL https://chatgpt.com/codex/install.sh | sh",
26740
28008
  installedIn: ".local/bin",
26741
28009
  mode: "workspace-write",
28010
+ modes: CODEX_MODES,
26742
28011
  signIn: "run `codex login`",
26743
28012
  // Over SSH no browser opens, and the address `codex login` prints calls back to that machine.
26744
28013
  signInNoScreen: "`codex login --device-auth`",
@@ -26754,13 +28023,18 @@ var knownBy = (kind2) => {
26754
28023
  const program = kind2.command[0]?.split("/").pop();
26755
28024
  return KNOWN2.find((each) => each.program === program);
26756
28025
  };
28026
+ function modesOf(kind2) {
28027
+ const known = knownBy(kind2);
28028
+ if (known === void 0 || kind2.mode !== known.mode) return [];
28029
+ return known.modes;
28030
+ }
26757
28031
  var knownOf = (kind2) => knownBy(kind2);
26758
28032
  function knownIdOf(kind2) {
26759
28033
  return knownBy(kind2)?.id;
26760
28034
  }
26761
28035
  var CODEX_DOC_BYTES = 65536;
26762
- function codexConfigOf(env2) {
26763
- const raw = env2["CODEX_CONFIG"];
28036
+ function codexConfigOf(env3) {
28037
+ const raw = env3["CODEX_CONFIG"];
26764
28038
  if (raw === void 0 || raw.trim() === "") return void 0;
26765
28039
  try {
26766
28040
  const parsed = JSON.parse(raw);
@@ -26769,16 +28043,16 @@ function codexConfigOf(env2) {
26769
28043
  return void 0;
26770
28044
  }
26771
28045
  }
26772
- function adapterEnv(kind2, env2) {
26773
- if (knownIdOf(kind2) !== "codex") return env2;
26774
- const raw = env2["CODEX_CONFIG"];
26775
- const config2 = codexConfigOf(env2);
26776
- if (raw !== void 0 && raw.trim() !== "" && config2 === void 0) return env2;
26777
- if (config2?.["project_doc_max_bytes"] !== void 0) return env2;
26778
- return { ...env2, CODEX_CONFIG: JSON.stringify({ ...config2, project_doc_max_bytes: CODEX_DOC_BYTES }) };
28046
+ function adapterEnv(kind2, env3) {
28047
+ if (knownIdOf(kind2) !== "codex") return env3;
28048
+ const raw = env3["CODEX_CONFIG"];
28049
+ const config2 = codexConfigOf(env3);
28050
+ if (raw !== void 0 && raw.trim() !== "" && config2 === void 0) return env3;
28051
+ if (config2?.["project_doc_max_bytes"] !== void 0) return env3;
28052
+ return { ...env3, CODEX_CONFIG: JSON.stringify({ ...config2, project_doc_max_bytes: CODEX_DOC_BYTES }) };
26779
28053
  }
26780
- function codexDocBytes(env2) {
26781
- const said = codexConfigOf(env2)?.["project_doc_max_bytes"];
28054
+ function codexDocBytes(env3) {
28055
+ const said = codexConfigOf(env3)?.["project_doc_max_bytes"];
26782
28056
  return typeof said === "number" && Number.isFinite(said) && said > 0 ? said : 32768;
26783
28057
  }
26784
28058
  function installWords(kind2) {
@@ -26874,11 +28148,11 @@ function configPathOf(word, home = homedir4()) {
26874
28148
  }
26875
28149
  function foldersPathOf(path, home = homedir4()) {
26876
28150
  const places = placesOf(home);
26877
- const whole2 = resolve2(fromHome(path, home));
26878
- const under = inside2(places.agents, whole2);
28151
+ const whole3 = resolve2(fromHome(path, home));
28152
+ const under = inside2(places.agents, whole3);
26879
28153
  const old = under === void 0 ? void 0 : join5(places.oldAgents, under);
26880
- if (old !== void 0 && existsSync5(old) && !existsSync5(whole2)) return old;
26881
- return nowAt(whole2, places.oldAgents, places.agents);
28154
+ if (old !== void 0 && existsSync5(old) && !existsSync5(whole3)) return old;
28155
+ return nowAt(whole3, places.oldAgents, places.agents);
26882
28156
  }
26883
28157
 
26884
28158
  // src/setup.ts
@@ -26932,10 +28206,10 @@ var runnable = (path) => {
26932
28206
  }
26933
28207
  };
26934
28208
  var onPath = (program, path) => path.split(delimiter2).some((dir) => dir !== "" && runnable(join6(dir, program)));
26935
- function checkCommand(kind2, env2 = process.env) {
28209
+ function checkCommand(kind2, env3 = process.env) {
26936
28210
  const [program] = kind2.command;
26937
28211
  if (program === void 0) throw new SetupError(`${kind2.name} has no command to run. ${STILL_GOOD}`);
26938
- const path = { ...env2, ...kind2.env }["PATH"] ?? "";
28212
+ const path = { ...env3, ...kind2.env }["PATH"] ?? "";
26939
28213
  const found = program.includes("/") ? runnable(isAbsolute3(program) ? program : resolve3(fromHome(program))) : onPath(program, path);
26940
28214
  if (!found) {
26941
28215
  throw new SetupError(
@@ -27005,17 +28279,17 @@ var inNewTerminal = (name) => `If ${name} still isn't found, run that command in
27005
28279
  var PATIENCE_MS = 20 * 6e4;
27006
28280
  var adapterFolder = (id2, home = homedir5()) => join7(placesOf(home).settings, "adapters", id2);
27007
28281
  var fetchedAt = (id2, program, home) => join7(adapterFolder(id2, home), "node_modules", ".bin", program);
27008
- var pathOf2 = (kind2, env2) => ({ ...env2, ...kind2.env })["PATH"] ?? "";
27009
- function makersFolder(kind2, env2 = process.env, home = homedir5()) {
28282
+ var pathOf2 = (kind2, env3) => ({ ...env3, ...kind2.env })["PATH"] ?? "";
28283
+ function makersFolder(kind2, env3 = process.env, home = homedir5()) {
27010
28284
  const known = knownOf(kind2);
27011
- if (known === void 0 || onPath(known.agent, pathOf2(kind2, env2))) return void 0;
28285
+ if (known === void 0 || onPath(known.agent, pathOf2(kind2, env3))) return void 0;
27012
28286
  const folder2 = join7(home, known.installedIn);
27013
28287
  return runnable(join7(folder2, known.agent)) ? folder2 : void 0;
27014
28288
  }
27015
28289
  var pathWithLast = (path, folder2) => [...(path ?? "").split(delimiter3).filter((each) => each !== ""), folder2].join(delimiter3);
27016
- function withFetchedAdapter(kind2, env2 = process.env, home = homedir5()) {
28290
+ function withFetchedAdapter(kind2, env3 = process.env, home = homedir5()) {
27017
28291
  const known = knownOf(kind2);
27018
- if (known === void 0 || kind2.command[0] !== known.program || onPath(known.program, pathOf2(kind2, env2))) return kind2;
28292
+ if (known === void 0 || kind2.command[0] !== known.program || onPath(known.program, pathOf2(kind2, env3))) return kind2;
27019
28293
  const fetched = fetchedAt(known.id, known.program, home);
27020
28294
  return runnable(fetched) ? { ...kind2, command: [fetched, ...kind2.command.slice(1)] } : kind2;
27021
28295
  }
@@ -27056,11 +28330,11 @@ function npmInstall(job) {
27056
28330
  });
27057
28331
  }
27058
28332
  async function readyAdapter(kind2, options = {}) {
27059
- const env2 = options.env ?? process.env;
28333
+ const env3 = options.env ?? process.env;
27060
28334
  const home = options.home ?? homedir5();
27061
28335
  const known = knownOf(kind2);
27062
28336
  if (known === void 0 || kind2.command[0] !== known.program) return kind2;
27063
- const path = pathOf2(kind2, env2);
28337
+ const path = pathOf2(kind2, env3);
27064
28338
  if (onPath(known.program, path)) return kind2;
27065
28339
  if (!onPath(known.agent, path)) {
27066
28340
  throw new SetupError(
@@ -27068,10 +28342,10 @@ async function readyAdapter(kind2, options = {}) {
27068
28342
  agentMissingStop(known)
27069
28343
  );
27070
28344
  }
27071
- const npm = env2["CHIPS_NPM"];
28345
+ const npm = env3["CHIPS_NPM"];
27072
28346
  if (!known.fetches || npm === void 0 || npm === "") return kind2;
27073
28347
  const folder2 = adapterFolder(known.id, home);
27074
- const { CHIPS_JOIN_LINK: _link, ...rest } = env2;
28348
+ const { CHIPS_JOIN_LINK: _link, ...rest } = env3;
27075
28349
  const node2 = process.execPath;
27076
28350
  options.say?.(`Getting what ${kind2.name} needs from npm, a large download`);
27077
28351
  try {
@@ -27088,7 +28362,7 @@ async function readyAdapter(kind2, options = {}) {
27088
28362
  const why = error62 instanceof Error ? error62.message : String(error62);
27089
28363
  throw new SetupError(`${kind2.name}'s adapter couldn't be downloaded: ${why}. ${STILL_GOOD}`, adapterFailedStop(kind2.name));
27090
28364
  }
27091
- const ready = withFetchedAdapter(kind2, env2, home);
28365
+ const ready = withFetchedAdapter(kind2, env3, home);
27092
28366
  if (ready.command[0] === known.program) {
27093
28367
  rmSync3(folder2, { recursive: true, force: true });
27094
28368
  throw new SetupError(`${known.adapter} installed, but it has no ${known.program}. ${STILL_GOOD}`, adapterFailedStop(kind2.name));
@@ -27164,8 +28438,8 @@ function autoCompactWindowOf(layers, model) {
27164
28438
  const chosen = key !== void 0 && key in byModel ? byModel[key] : top;
27165
28439
  return typeof chosen === "number" && Number.isFinite(chosen) && chosen > 0 ? chosen : void 0;
27166
28440
  }
27167
- function autoCompactWindowFromEnv(env2) {
27168
- const said = /^\s*(\d+(?:\.\d+)?)\s*([km]?)\s*$/i.exec(env2["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] ?? "");
28441
+ function autoCompactWindowFromEnv(env3) {
28442
+ const said = /^\s*(\d+(?:\.\d+)?)\s*([km]?)\s*$/i.exec(env3["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] ?? "");
27169
28443
  if (said === null) return void 0;
27170
28444
  const scale = { "": 1, k: 1e3, m: 1e6 }[(said[2] ?? "").toLowerCase()] ?? 1;
27171
28445
  const tokens2 = Math.round(Number(said[1]) * scale);
@@ -27181,11 +28455,11 @@ import { createHash as createHash2 } from "node:crypto";
27181
28455
  import { readdirSync, readFileSync as readFileSync8, statSync } from "node:fs";
27182
28456
  import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
27183
28457
  import { dirname as dirname5, join as join9, parse as parse3, relative as relative2, sep as sep3 } from "node:path";
27184
- function placesOf2(env2, home) {
28458
+ function placesOf2(env3, home) {
27185
28459
  return {
27186
28460
  home,
27187
- claudeHome: env2["CLAUDE_CONFIG_DIR"] || join9(home, ".claude"),
27188
- codexHome: env2["CODEX_HOME"] || join9(home, ".codex")
28461
+ claudeHome: env3["CLAUDE_CONFIG_DIR"] || join9(home, ".claude"),
28462
+ codexHome: env3["CODEX_HOME"] || join9(home, ".codex")
27189
28463
  };
27190
28464
  }
27191
28465
  function hashOf(text) {
@@ -27487,6 +28761,48 @@ function keepHeard(since, heard) {
27487
28761
  if (since.length > CONTEXT_BUDGET.lines) since.shift();
27488
28762
  }
27489
28763
 
28764
+ // src/modes.ts
28765
+ function pickedMode(chips2) {
28766
+ const mode = chips2?.mode;
28767
+ return typeof mode?.id === "string" && mode.id !== "" ? mode.id : void 0;
28768
+ }
28769
+ function onModeChange(chips2, handler) {
28770
+ const on = chips2.on;
28771
+ if (typeof on !== "function" || !("mode" in chips2)) return false;
28772
+ on.call(chips2, "mode", handler);
28773
+ return true;
28774
+ }
28775
+ function modeOption(options) {
28776
+ return options?.find((option) => option.category === "mode") ?? options?.find((option) => option.id === "mode");
28777
+ }
28778
+ function offeredIn(options) {
28779
+ const option = modeOption(options);
28780
+ return option === void 0 || option.options.length === 0 ? void 0 : option.options.map((each) => each.value);
28781
+ }
28782
+ function currentIn(options) {
28783
+ const value = modeOption(options)?.currentValue;
28784
+ return value === void 0 || value === "" ? void 0 : value;
28785
+ }
28786
+ function withCurrent(options, mode) {
28787
+ const option = modeOption(options);
28788
+ return option === void 0 ? options : options.map((each) => each === option ? { ...each, currentValue: mode } : each);
28789
+ }
28790
+ function modeTarget(base, modes, picked, offered) {
28791
+ if (picked === void 0 || picked === base) return { mode: base };
28792
+ if (!modes.some((mode) => mode.id === picked)) {
28793
+ return { mode: base, why: `the mode picked in Chips, ${picked}, isn't one Chips may put it in` };
28794
+ }
28795
+ if (offered !== void 0 && !offered.includes(picked)) {
28796
+ return { mode: base, why: `it doesn't offer ${picked} here, so it stays in ${base}` };
28797
+ }
28798
+ return { mode: picked };
28799
+ }
28800
+ function modesCopy(modes, base, running, offered) {
28801
+ const offers2 = modes.filter((mode) => mode.id === base || offered === void 0 || offered.includes(mode.id));
28802
+ if (offers2.length === 0 || !offers2.some((mode) => mode.id === base)) return void 0;
28803
+ return { base, ...running === void 0 ? {} : { running }, offers: offers2 };
28804
+ }
28805
+
27490
28806
  // src/own-rules.ts
27491
28807
  import { homedir as homedir6 } from "node:os";
27492
28808
  var MOST = 200;
@@ -27539,7 +28855,7 @@ function ownDefaultMode(layer) {
27539
28855
  const mode = isRecord2(permissions) ? permissions["defaultMode"] : void 0;
27540
28856
  return typeof mode === "string" && mode !== "" ? mode : void 0;
27541
28857
  }
27542
- var CLAUDE_MODES = {
28858
+ var CLAUDE_MODES2 = {
27543
28859
  default: "Default",
27544
28860
  acceptEdits: "Accept edits",
27545
28861
  plan: "Plan",
@@ -27548,7 +28864,7 @@ var CLAUDE_MODES = {
27548
28864
  auto: "Auto"
27549
28865
  };
27550
28866
  function claudeModeName(mode) {
27551
- return CLAUDE_MODES[mode] ?? mode;
28867
+ return CLAUDE_MODES2[mode] ?? mode;
27552
28868
  }
27553
28869
  function tilde(path, home = homedir6()) {
27554
28870
  return path === home ? "~" : path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
@@ -27583,17 +28899,18 @@ function claudeOwnRules(options) {
27583
28899
  ask_line
27584
28900
  };
27585
28901
  }
27586
- var CODEX_MODES = {
27587
- "read-only": "Read only",
27588
- "workspace-write": "Workspace write",
27589
- auto: "Auto",
28902
+ var CODEX_MODES2 = {
28903
+ "read-only": "Read-only",
28904
+ "workspace-write": "Workspace access",
28905
+ agent: "Auto review",
28906
+ "agent-full-access": "Full access",
27590
28907
  "full-access": "Full access",
27591
28908
  "danger-full-access": "Full access"
27592
28909
  };
27593
28910
  function codexOwnRules(mode) {
27594
28911
  const read_from = ["the mode Chips starts each Codex session in"];
27595
- const name = CODEX_MODES[mode] ?? mode;
27596
- if (mode === "full-access" || mode === "danger-full-access") {
28912
+ const name = CODEX_MODES2[mode] ?? mode;
28913
+ if (mode === "agent-full-access" || mode === "full-access" || mode === "danger-full-access") {
27597
28914
  return {
27598
28915
  read_from,
27599
28916
  mode: name,
@@ -27606,7 +28923,15 @@ function codexOwnRules(mode) {
27606
28923
  return {
27607
28924
  read_from,
27608
28925
  mode: name,
27609
- note: "Codex reads on its own and asks before it changes a file or runs anything else.",
28926
+ note: "Codex reads on its own and changes nothing without a yes: it asks first, or says it can't.",
28927
+ runs: []
28928
+ };
28929
+ }
28930
+ if (mode === "agent") {
28931
+ return {
28932
+ read_from,
28933
+ mode: name,
28934
+ note: "Codex edits files and runs commands inside the agent's folder in its own sandbox, judges each step itself, and asks only about one it finds risky.",
27610
28935
  runs: []
27611
28936
  };
27612
28937
  }
@@ -27734,8 +29059,8 @@ function reachable(percent2, window) {
27734
29059
  const tokens2 = Math.round(percent2 / 100 * window) + HEADROOM;
27735
29060
  return tokens2 >= LEAST_WINDOW && tokens2 <= window;
27736
29061
  }
27737
- function claudeOwn(env2, layers, model, window) {
27738
- const fromEnv = autoCompactWindowFromEnv(env2);
29062
+ function claudeOwn(env3, layers, model, window) {
29063
+ const fromEnv = autoCompactWindowFromEnv(env3);
27739
29064
  if (fromEnv !== void 0) return { at: percentOf(fromEnv, window), fixed: true };
27740
29065
  if (!autoCompactOn(layers)) return { at: null, fixed: false };
27741
29066
  return { at: percentOf(autoCompactWindowOf(layers, model) ?? window, window), fixed: false };
@@ -27884,6 +29209,14 @@ var Bridge = class {
27884
29209
  windowTimers = /* @__PURE__ */ new Map();
27885
29210
  /** Each live session's options as the agent last said them: its model and effort among them. */
27886
29211
  sessionOptions = /* @__PURE__ */ new Map();
29212
+ /** The modes its agent last said it offers, from any session (Chips ADR 0300): its `mode` option. */
29213
+ offered;
29214
+ /** The mode its sessions last ran in, of those a person may pick, as the agent said it. */
29215
+ modeNow;
29216
+ /** The mode each session's agent said it went into while the bridge was moving it, by session. */
29217
+ modeSaid = /* @__PURE__ */ new Map();
29218
+ /** What it runs on its own, to send again in a moment: a mode change moves every session at once. */
29219
+ ownRulesTimer;
27887
29220
  /** Hear what Chips asks, learn the agents Chips has, run the agent, and close idle sessions. */
27888
29221
  async start() {
27889
29222
  const { chips: chips2 } = this.options;
@@ -27901,6 +29234,7 @@ var Bridge = class {
27901
29234
  chips2.on("feedback", (feedback2) => after("a second look", () => this.lookAgain(feedback2)));
27902
29235
  chips2.on("event", (event) => after(event.type, () => this.noted(event)));
27903
29236
  chips2.onSpaceAsked((asked) => after("a room from the +", () => this.claim(asked)));
29237
+ onModeChange(chips2, () => after("a mode", () => this.remode()));
27904
29238
  await this.know(await chips2.agents.list(), { forget: true });
27905
29239
  this.knew();
27906
29240
  await this.sendContexts();
@@ -28027,11 +29361,11 @@ var Bridge = class {
28027
29361
  }
28028
29362
  /** The record a Chips agent is, read afresh once when it is new to the bridge. */
28029
29363
  async recordOf(agentId2) {
28030
- const find = () => this.records().find((record2) => record2.agentId === agentId2);
28031
- const found = find();
29364
+ const find2 = () => this.records().find((record2) => record2.agentId === agentId2);
29365
+ const found = find2();
28032
29366
  if (found !== void 0) return found;
28033
29367
  await this.know(await this.options.chips.agents.list().catch(() => []));
28034
- return find();
29368
+ return find2();
28035
29369
  }
28036
29370
  /** Registered: the record takes Chips's id and name, which Chips may have numbered. */
28037
29371
  registered(record2, agent) {
@@ -28698,11 +30032,80 @@ ${files.join("\n")}`;
28698
30032
  const settings = claudeSessionSettings(this.options.state.windows?.[record2.key]);
28699
30033
  return settings === void 0 ? void 0 : { claudeCode: { options: { settings } } };
28700
30034
  }
28701
- /** The session into the mode the config names, or left in its own when the agent won't. */
30035
+ /**
30036
+ * The session into its mode: the one a person picked in Chips while it holds, where this kind
30037
+ * offers it and the agent has it, else the one the config names (Chips ADR 0300). One the agent
30038
+ * refuses goes back to the config's; one it refuses too leaves it in its own.
30039
+ */
28702
30040
  async moded(client, sessionId) {
28703
- const { mode, name } = this.options.kind;
28704
- if (mode === void 0) return;
28705
- await client.setMode(sessionId, mode).catch((error62) => this.log(`${name} stays in its own mode, not ${mode}: ${messageOf(error62)}`));
30041
+ const { mode: base, name } = this.options.kind;
30042
+ if (base === void 0) return;
30043
+ const offered = offeredIn(this.sessionOptions.get(sessionId));
30044
+ if (offered !== void 0 && offered.join() !== this.offered?.join()) {
30045
+ this.offered = offered;
30046
+ this.ownRulesSoon();
30047
+ }
30048
+ const target = modeTarget(base, modesOf(this.options.kind), pickedMode(this.options.chips), offered ?? this.offered);
30049
+ if (target.why !== void 0) this.log(`${name} runs in ${base}: ${target.why}`);
30050
+ if (await this.setModeOf(client, sessionId, target.mode)) return;
30051
+ if (target.mode !== base) await this.setModeOf(client, sessionId, base);
30052
+ }
30053
+ /**
30054
+ * One session into one mode: true once the agent took it. What it says it went into, where it
30055
+ * says, is what it runs in: Claude Code runs Auto as Accept edits on a model that can't use it.
30056
+ */
30057
+ async setModeOf(client, sessionId, mode) {
30058
+ this.modeSaid.delete(sessionId);
30059
+ try {
30060
+ await client.setMode(sessionId, mode);
30061
+ } catch (error62) {
30062
+ this.log(`${this.options.kind.name} stays in its own mode, not ${mode}: ${messageOf(error62)}`);
30063
+ return false;
30064
+ }
30065
+ const now = this.modeSaid.get(sessionId) ?? mode;
30066
+ this.modeSaid.delete(sessionId);
30067
+ const options = this.sessionOptions.get(sessionId);
30068
+ if (options !== void 0) this.sessionOptions.set(sessionId, withCurrent(options, now));
30069
+ this.ran(now);
30070
+ return true;
30071
+ }
30072
+ /** Every live session into its mode now: a person picked one in Chips, put it back, or its time is up. */
30073
+ async remode() {
30074
+ const client = this.process.client;
30075
+ const picked = pickedMode(this.options.chips);
30076
+ this.log(`${this.options.kind.name}'s mode from Chips: ${picked ?? `back to ${this.options.kind.mode ?? "its own"}`}`);
30077
+ if (client !== void 0 && !client.gone) {
30078
+ for (const sessionId of [...this.process.live]) await this.moded(client, sessionId);
30079
+ }
30080
+ this.modeNow = void 0;
30081
+ for (const sessionId of this.process.live) {
30082
+ const now = currentIn(this.sessionOptions.get(sessionId));
30083
+ if (now !== void 0) this.ran(now);
30084
+ }
30085
+ this.ownRulesSoon();
30086
+ }
30087
+ /** The mode its sessions run in, where it is one a person may pick; Plan and the like are passing. */
30088
+ ran(mode) {
30089
+ if (!modesOf(this.options.kind).some((each) => each.id === mode) && mode !== this.options.kind.mode) return;
30090
+ if (this.modeNow === mode) return;
30091
+ this.modeNow = mode;
30092
+ this.ownRulesSoon();
30093
+ }
30094
+ /** What it runs on its own, sent again in a moment. */
30095
+ ownRulesSoon() {
30096
+ clearTimeout(this.ownRulesTimer);
30097
+ this.ownRulesTimer = setTimeout(() => {
30098
+ this.ownRulesTimer = void 0;
30099
+ void this.sendOwnRules();
30100
+ }, QUIET_MS);
30101
+ this.ownRulesTimer.unref();
30102
+ }
30103
+ /** The mode its sessions run in, or go into next where none has said. */
30104
+ runningMode() {
30105
+ const base = this.options.kind.mode;
30106
+ if (base === void 0) return void 0;
30107
+ if (this.modeNow !== void 0) return this.modeNow;
30108
+ return modeTarget(base, modesOf(this.options.kind), pickedMode(this.options.chips), this.offered).mode;
28706
30109
  }
28707
30110
  /** The message's files, saved where the agent works, as lines that say where. */
28708
30111
  async filesFor(record2, message) {
@@ -28952,7 +30355,14 @@ ${files.join("\n")}`;
28952
30355
  if (copy !== void 0) await sendOwnRules(this.options.chips.settings, copy);
28953
30356
  }
28954
30357
  ownRules() {
28955
- if (this.knownKind === "codex") return codexOwnRules(this.options.kind.mode ?? "workspace-write");
30358
+ const copy = this.ownRulesNow();
30359
+ const base = this.options.kind.mode;
30360
+ if (copy === void 0 || base === void 0) return copy;
30361
+ const modes = modesCopy(modesOf(this.options.kind), base, this.runningMode(), this.offered);
30362
+ return modes === void 0 ? copy : { ...copy, modes };
30363
+ }
30364
+ ownRulesNow() {
30365
+ if (this.knownKind === "codex") return codexOwnRules(this.runningMode() ?? "workspace-write");
28956
30366
  if (this.knownKind !== "claude-code") return void 0;
28957
30367
  const userPath = join10(this.places.claudeHome, "settings.json");
28958
30368
  const folders = [...new Set(this.records().map((record2) => record2.folder))].flatMap(
@@ -28965,7 +30375,7 @@ ${files.join("\n")}`;
28965
30375
  userPath,
28966
30376
  user: readLayer(userPath),
28967
30377
  folders,
28968
- mode: this.options.kind.mode ?? "default",
30378
+ mode: this.runningMode() ?? "default",
28969
30379
  home: this.places.home
28970
30380
  });
28971
30381
  }
@@ -29088,7 +30498,23 @@ ${files.join("\n")}`;
29088
30498
  }
29089
30499
  case "config_option_update": {
29090
30500
  const options = configOptionsOf(update);
29091
- if (this.sessionOptions.has(sessionId) && options.length > 0) this.sessionOptions.set(sessionId, options);
30501
+ if (this.sessionOptions.has(sessionId) && options.length > 0) {
30502
+ this.sessionOptions.set(sessionId, options);
30503
+ const now = currentIn(options);
30504
+ if (now !== void 0) {
30505
+ this.modeSaid.set(sessionId, now);
30506
+ this.ran(now);
30507
+ }
30508
+ }
30509
+ return;
30510
+ }
30511
+ case "current_mode_update": {
30512
+ const mode = update["currentModeId"];
30513
+ if (typeof mode !== "string" || mode === "") return;
30514
+ const options = this.sessionOptions.get(sessionId);
30515
+ if (options !== void 0) this.sessionOptions.set(sessionId, withCurrent(options, mode));
30516
+ this.modeSaid.set(sessionId, mode);
30517
+ this.ran(mode);
29092
30518
  return;
29093
30519
  }
29094
30520
  case "available_commands_update": {
@@ -29351,6 +30777,11 @@ ${files.join("\n")}`;
29351
30777
  try {
29352
30778
  const made = await client.newSession(kind2.folder ?? kind2.folders);
29353
30779
  sessionId = made.sessionId;
30780
+ const offered = offeredIn(made.configOptions);
30781
+ if (offered !== void 0 && offered.join() !== this.offered?.join()) {
30782
+ this.offered = offered;
30783
+ this.ownRulesSoon();
30784
+ }
29354
30785
  const { catalog, refused: refused3 } = await lookAt(
29355
30786
  made.configOptions,
29356
30787
  (configId, value) => client.setConfigOption(made.sessionId, configId, value)
@@ -29657,12 +31088,12 @@ function riskOf(kind2) {
29657
31088
  return [];
29658
31089
  }
29659
31090
  function optionFor(decision, options, changesMode) {
29660
- const find = (kind2) => options.find((option) => option.kind === kind2)?.optionId;
29661
- if (!decision.allowed) return find("reject_once") ?? find("reject_always");
31091
+ const find2 = (kind2) => options.find((option) => option.kind === kind2)?.optionId;
31092
+ if (!decision.allowed) return find2("reject_once") ?? find2("reject_always");
29662
31093
  const always = options.filter((option) => option.kind === "allow_always");
29663
31094
  const ownAlways = always.length === 1 && !changesMode ? always[0]?.optionId : void 0;
29664
31095
  if (decision.scope === "always" && decision.keeps === "harness" && ownAlways !== void 0) return ownAlways;
29665
- return find("allow_once") ?? ownAlways;
31096
+ return find2("allow_once") ?? ownAlways;
29666
31097
  }
29667
31098
  function questionOf(id2, field, message) {
29668
31099
  const prompt = String(field["title"] ?? field["description"] ?? message ?? id2).slice(0, 500);
@@ -29696,18 +31127,18 @@ var flags = process.argv.slice(2);
29696
31127
  var words3 = flags.filter((word) => !word.startsWith("--"));
29697
31128
  var handsOver = flags.includes("--keep");
29698
31129
  var stopping = flags.includes("--stop");
29699
- var whole = (word) => configTargetOf(word);
31130
+ var whole2 = (word) => configTargetOf(word);
29700
31131
  function asStarted(root, file3, started2 = process.argv[1]) {
29701
31132
  if (started2 === void 0 || started2 === "") return { root, file: file3 };
29702
31133
  const tail = relative3(root, file3);
29703
- const whole2 = resolve4(started2);
29704
- if (!whole2.endsWith(`${sep4}${tail}`)) return { root, file: file3 };
31134
+ const whole3 = resolve4(started2);
31135
+ if (!whole3.endsWith(`${sep4}${tail}`)) return { root, file: file3 };
29705
31136
  try {
29706
- if (realpathSync(whole2) !== realpathSync(file3)) return { root, file: file3 };
31137
+ if (realpathSync(whole3) !== realpathSync(file3)) return { root, file: file3 };
29707
31138
  } catch {
29708
31139
  return { root, file: file3 };
29709
31140
  }
29710
- return { root: whole2.slice(0, -tail.length - 1), file: whole2 };
31141
+ return { root: whole3.slice(0, -tail.length - 1), file: whole3 };
29711
31142
  }
29712
31143
  var { root: here, file: self } = asStarted(
29713
31144
  fileURLToPath2(new URL("..", import.meta.url)).replace(/\/$/, ""),
@@ -29733,7 +31164,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
29733
31164
  const node2 = keptNode();
29734
31165
  const kept2 = keepRunning({
29735
31166
  label: label2,
29736
- command: [node2, ...run, ...words3.map(whole)],
31167
+ command: [node2, ...run, ...words3.map(whole2)],
29737
31168
  folder: here,
29738
31169
  environment: keepEnvironment(url2, process.env, names, node2)
29739
31170
  });
@@ -29796,10 +31227,10 @@ function removeIfEmpty(path) {
29796
31227
  } catch {
29797
31228
  }
29798
31229
  }
29799
- function claudeStoreOf(folder2, env2, home = homedir8()) {
31230
+ function claudeStoreOf(folder2, env3, home = homedir8()) {
29800
31231
  const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
29801
31232
  if (name.length > 200) return void 0;
29802
- return join11(env2["CLAUDE_CONFIG_DIR"] ? resolve5(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
31233
+ return join11(env3["CLAUDE_CONFIG_DIR"] ? resolve5(fromHome(env3["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
29803
31234
  }
29804
31235
  function pairOf(path, places) {
29805
31236
  const old = inside2(places.oldAgents, path);
@@ -29821,7 +31252,7 @@ var readJson = (path) => {
29821
31252
  return void 0;
29822
31253
  }
29823
31254
  };
29824
- function moveOld(configPath2, log2, home = homedir8(), env2 = process.env) {
31255
+ function moveOld(configPath2, log2, home = homedir8(), env3 = process.env) {
29825
31256
  const places = placesOf(home);
29826
31257
  const keptIn = join11(dirname6(configPath2), basename5(configPath2, ".json"));
29827
31258
  const name = inside2(places.settings, configPath2);
@@ -29871,7 +31302,7 @@ function moveOld(configPath2, log2, home = homedir8(), env2 = process.env) {
29871
31302
  }
29872
31303
  if (changed) writeJson(statePath2, state2);
29873
31304
  }
29874
- const storeEnv = { ...env2, ...kindEnv };
31305
+ const storeEnv = { ...env3, ...kindEnv };
29875
31306
  for (const { old, now } of pairs) {
29876
31307
  if (there(old) || !there(now)) continue;
29877
31308
  const folders = [{ old, now }];
@@ -29893,11 +31324,11 @@ var link = process.env["CHIPS_JOIN_LINK"] || void 0;
29893
31324
  var LABEL = `chat.chips.acp.${basename6(configTargetOf(words3[0]), ".json")}`;
29894
31325
  if (stopping) forgetAdapter(basename6(configTargetOf(words3[0]), ".json"));
29895
31326
  stopIfAsked(LABEL);
29896
- var closing = [];
31327
+ var closing2 = [];
29897
31328
  var started = false;
29898
31329
  for (const signal of ["SIGINT", "SIGTERM"]) {
29899
31330
  process.on(signal, () => {
29900
- for (const close of closing.reverse()) close();
31331
+ for (const close of closing2.reverse()) close();
29901
31332
  if (started) process.exit(0);
29902
31333
  process.removeAllListeners(signal);
29903
31334
  process.kill(process.pid, signal);
@@ -29968,7 +31399,7 @@ var state = {
29968
31399
  ...kept.models === void 0 ? {} : { models: kept.models },
29969
31400
  costs: kept.costs ?? {}
29970
31401
  };
29971
- var env = adapterEnv(kind, { ...process.env, ...kind.env });
31402
+ var env2 = adapterEnv(kind, { ...process.env, ...kind.env });
29972
31403
  var waitingFor;
29973
31404
  var waitingSaid = (why) => {
29974
31405
  if (why !== waitingFor) log(`waiting for Chips: ${why}`);
@@ -29991,23 +31422,23 @@ var chips = await connect({
29991
31422
  // An agent's files, its context window and its model, changed from its page (Chips ADRs 0134, 0146, 0241).
29992
31423
  settings: settingsFor(kind, () => bridge)
29993
31424
  });
29994
- closing.push(() => chips.close());
29995
- var git = await checkGit();
29996
- if (!git.ok) log(`rooms' projects are off: ${git.why}`);
31425
+ closing2.push(() => chips.close());
31426
+ var git2 = await checkGit();
31427
+ if (!git2.ok) log(`rooms' projects are off: ${git2.why}`);
29997
31428
  bridge = new Bridge({
29998
31429
  chips,
29999
31430
  kind,
30000
- projects: git.ok,
31431
+ projects: git2.ok,
30001
31432
  // Claude Code's and Codex's adapters offer their models as session options (Chips ADR 0241).
30002
31433
  models: knownIdOf(kind) !== void 0,
30003
31434
  state,
30004
31435
  saveState: (next) => writeFileSync5(statePath, `${JSON.stringify(next, null, 2)}
30005
31436
  `, { mode: 384 }),
30006
- wire: () => processWire(kind.command, kind.folder ?? kind.folders, env, (line) => log(`${kind.name}: ${line}`)),
30007
- env,
31437
+ wire: () => processWire(kind.command, kind.folder ?? kind.folders, env2, (line) => log(`${kind.name}: ${line}`)),
31438
+ env: env2,
30008
31439
  log
30009
31440
  });
30010
- closing.push(() => bridge?.stop());
31441
+ closing2.push(() => bridge?.stop());
30011
31442
  await bridge.start();
30012
31443
  started = true;
30013
31444
  log(`connected as ${chips.harnessId} (${kind.name}), ${Object.keys(state.agents).length} agent(s)`);