@chipschat/acp 1.0.31 → 1.0.33

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/README.md CHANGED
@@ -168,7 +168,7 @@ minutes and loaded again with its memory. Fourteen runs, none failed, $0.35, all
168
168
  | Context gauge, cost | `usage_update` (`used`/`size`; `cost` in USD, the turn's share) |
169
169
  | The reply | `agent_message_chunk`s gathered into one message; `NO_REPLY` alone is the turn passed |
170
170
  | Files in the reply | each `MEDIA:<path>` line of the reply sent as an upload with its words, only from the agent's folder (`sendAnswer`); the post says why one could not go |
171
- | Approval card | `session/request_permission`, asked in the agent's own words where the call has a `description` (Claude Code's commands: "Syntax-check game.js? `node --check game.js`"), else "Allow it to" and the call's title; allowed always picks `allow_always`, except for a command, which picks `allow_once` since Chips remembers it by how each part starts (Chips ADR 0239); no picks `reject_once`; Stop answers `cancelled`; the card hears how the call went |
171
+ | Approval card | `session/request_permission`, asked in the agent's own words where the call has a `description` (Claude Code's commands: "Syntax-check game.js? `node --check game.js`"), else "Allow it to" and the call's title; a yes picks `allow_once`, an Always too while Chips keeps the rule (Chips ADR 0239), so switching the rule off in Chips brings the asks back; with the harness's Chips's rules off (`keeps: "harness"`, Chips ADR 0300) an Always picks `allow_always` where the ask offers exactly one and the call is not a `switch_mode`, so Claude Code's plan ask, whose always options are "use auto mode" and "bypass permissions", is answered with its once; no picks `reject_once`; Stop answers `cancelled`; an ask that expires with nobody's answer is answered `cancelled` too, its prompt is stopped (`session/cancel`), and the turn ends on one line in the space: "Nobody answered, so I stopped. Ask me to carry on."; the card hears how the call went |
172
172
  | Question card | `elicitation/create` form of up to four choice or yes/no fields; anything else is declined; Stop answers `cancel` |
173
173
  | Stop | `session/cancel` |
174
174
  | Pause (Chips ADR 0293) | each run says `pausable: true` as it starts; Pause is `session/cancel` with the run kept and nothing posted, and Resume the next prompt of the same session: "You were paused partway through this. Carry on from where you stopped. Nothing you wrote before the pause reached the room, so write your whole reply.", then anything steered meanwhile. A Pause before a prompt holds it; one while an approval or question card waits stops nothing, and the answer reaches the agent on Resume |
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/main.js` in @chipschat/acp 1.0.31 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/acp 1.0.33 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
6
  ## @chipschat/harness 1.0.10 (Apache-2.0)
package/dist/main.js CHANGED
@@ -5078,7 +5078,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
5078
5078
  var NONE = 0;
5079
5079
  var ASSUMED = 1;
5080
5080
  var PROVEN = 2;
5081
- function isRecursive(inst, stack, resolve5) {
5081
+ function isRecursive(inst, stack, resolve6) {
5082
5082
  const cached2 = recursive.get(inst);
5083
5083
  if (cached2 !== void 0)
5084
5084
  return cached2 ? PROVEN : NONE;
@@ -5088,7 +5088,7 @@ function isRecursive(inst, stack, resolve5) {
5088
5088
  let result = NONE;
5089
5089
  const check2 = (child) => {
5090
5090
  if (result !== PROVEN && child?._zod) {
5091
- const answer = isRecursive(child, stack, resolve5);
5091
+ const answer = isRecursive(child, stack, resolve6);
5092
5092
  if (answer > result)
5093
5093
  result = answer;
5094
5094
  }
@@ -5099,7 +5099,7 @@ function isRecursive(inst, stack, resolve5) {
5099
5099
  const desc = Object.getOwnPropertyDescriptor(sh, key);
5100
5100
  if (spread && !desc.enumerable)
5101
5101
  continue;
5102
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve5) : NONE;
5102
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve6) : NONE;
5103
5103
  if (child > answer)
5104
5104
  answer = child;
5105
5105
  }
@@ -5163,7 +5163,7 @@ function isRecursive(inst, stack, resolve5) {
5163
5163
  break;
5164
5164
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
5165
5165
  case "lazy": {
5166
- const inner = def._cachedInner ?? (resolve5 ? inst._zod.innerType : void 0);
5166
+ const inner = def._cachedInner ?? (resolve6 ? inst._zod.innerType : void 0);
5167
5167
  merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
5168
5168
  break;
5169
5169
  }
@@ -23220,8 +23220,8 @@ function createOutbox() {
23220
23220
  const waiting = /* @__PURE__ */ new Map();
23221
23221
  return {
23222
23222
  add(key, event) {
23223
- return new Promise((resolve5, reject) => {
23224
- waiting.set(key, { event, resolve: resolve5, reject });
23223
+ return new Promise((resolve6, reject) => {
23224
+ waiting.set(key, { event, resolve: resolve6, reject });
23225
23225
  });
23226
23226
  },
23227
23227
  unanswered: () => [...waiting.values()].map((entry) => entry.event),
@@ -23297,7 +23297,7 @@ async function inPieces(call, path, bytes) {
23297
23297
  async function afterLoss(error62, failures) {
23298
23298
  if (error62 instanceof RefusedError || failures >= PIECE_TRIES)
23299
23299
  throw error62;
23300
- await new Promise((resolve5) => setTimeout(resolve5, 250 * failures));
23300
+ await new Promise((resolve6) => setTimeout(resolve6, 250 * failures));
23301
23301
  }
23302
23302
  function sendPiece(call, path, bytes, offset) {
23303
23303
  const piece = bytes.subarray(offset, Math.min(offset + PIECE_BYTES, bytes.byteLength));
@@ -23381,13 +23381,13 @@ function heldNote(pushed, name) {
23381
23381
  }
23382
23382
  async function checkGit(git2 = "git", path = process.env["PATH"] ?? "/usr/bin:/bin") {
23383
23383
  const [major, minor] = versionIn(PROJECT_GIT_VERSION) ?? [0, 0];
23384
- return new Promise((resolve5) => {
23384
+ return new Promise((resolve6) => {
23385
23385
  execFile(git2, ["--version"], { env: { PATH: path } }, (error62, stdout) => {
23386
23386
  if (error62 !== null)
23387
- return resolve5({ ok: false, why: "git was not found on this machine" });
23387
+ return resolve6({ ok: false, why: "git was not found on this machine" });
23388
23388
  const mine = versionIn(stdout);
23389
23389
  const enough = mine !== void 0 && (mine[0] > major || mine[0] === major && mine[1] >= minor);
23390
- resolve5(enough ? { ok: true, version: mine.join(".") } : { ok: false, why: `${stdout.trim()} is older than ${PROJECT_GIT_VERSION}` });
23390
+ resolve6(enough ? { ok: true, version: mine.join(".") } : { ok: false, why: `${stdout.trim()} is older than ${PROJECT_GIT_VERSION}` });
23391
23391
  });
23392
23392
  });
23393
23393
  }
@@ -23833,8 +23833,8 @@ ${sent.err}`;
23833
23833
  env2[`GIT_CONFIG_KEY_${at}`] = key;
23834
23834
  env2[`GIT_CONFIG_VALUE_${at}`] = value;
23835
23835
  });
23836
- return new Promise((resolve5) => {
23837
- execFile(options.git ?? "git", [...args], { cwd: this.copy, env: env2, maxBuffer: 64 * 1024 * 1024 }, (error62, stdout, stderr) => resolve5({ ok: error62 === null, out: stdout, err: stderr }));
23836
+ 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 }));
23838
23838
  });
23839
23839
  }
23840
23840
  };
@@ -23859,8 +23859,8 @@ var Lane = class {
23859
23859
  constructor(id2, wire) {
23860
23860
  this.id = id2;
23861
23861
  this.wire = wire;
23862
- this.result = new Promise((resolve5) => {
23863
- this.settle = resolve5;
23862
+ this.result = new Promise((resolve6) => {
23863
+ this.settle = resolve6;
23864
23864
  });
23865
23865
  this.stop = wire.hear(id2, (event) => this.onUpdated(event));
23866
23866
  }
@@ -24004,7 +24004,7 @@ var Run = class {
24004
24004
  /** Resolve once the run is not paused. A stopped run resolves too: check `over` after. */
24005
24005
  async whenRunning() {
24006
24006
  while (this.held && !this.ended) {
24007
- await new Promise((resolve5) => setTimeout(resolve5, 50));
24007
+ await new Promise((resolve6) => setTimeout(resolve6, 50));
24008
24008
  }
24009
24009
  }
24010
24010
  status(input2) {
@@ -24981,8 +24981,8 @@ var Chips = class _Chips {
24981
24981
  /** Resolve with the first event that matches, now or later. */
24982
24982
  waitFor(match) {
24983
24983
  this.listens();
24984
- return new Promise((resolve5) => {
24985
- this.waiters.add({ match, resolve: resolve5 });
24984
+ return new Promise((resolve6) => {
24985
+ this.waiters.add({ match, resolve: resolve6 });
24986
24986
  });
24987
24987
  }
24988
24988
  close() {
@@ -25009,14 +25009,14 @@ var Chips = class _Chips {
25009
25009
  return `${base}/v1/ws?ticket=${encodeURIComponent(String(ticket))}`;
25010
25010
  }
25011
25011
  open(first) {
25012
- return new Promise((resolve5, reject) => {
25012
+ return new Promise((resolve6, reject) => {
25013
25013
  this.setState("connecting");
25014
25014
  const failed = (what, error62) => {
25015
25015
  const why = `${what}: ${describe3(error62)}`;
25016
25016
  if (!first)
25017
25017
  this.scheduleReconnect();
25018
25018
  else if (this.waitsFor(error62))
25019
- this.tryAgain(why, resolve5, reject);
25019
+ this.tryAgain(why, resolve6, reject);
25020
25020
  else
25021
25021
  reject(new ConnectError(why));
25022
25022
  };
@@ -25030,19 +25030,19 @@ var Chips = class _Chips {
25030
25030
  }
25031
25031
  this.socket = socket;
25032
25032
  this.listen(socket, {
25033
- settled: (hello2) => this.settled(socket, hello2, first, resolve5, reject)
25033
+ settled: (hello2) => this.settled(socket, hello2, first, resolve6, reject)
25034
25034
  });
25035
25035
  }, (error62) => failed("could not get a socket ticket", error62));
25036
25036
  });
25037
25037
  }
25038
25038
  /** The handshake's outcome: the hello, a refusal, or the socket gone before either. */
25039
- settled(socket, hello2, first, resolve5, reject) {
25039
+ settled(socket, hello2, first, resolve6, reject) {
25040
25040
  if (hello2 === void 0) {
25041
25041
  const why = "the server closed the socket before saying hello";
25042
25042
  if (!first)
25043
25043
  this.scheduleReconnect();
25044
25044
  else if (this.options.waitForServer === true)
25045
- this.tryAgain(why, resolve5, reject);
25045
+ this.tryAgain(why, resolve6, reject);
25046
25046
  else
25047
25047
  reject(new ConnectError(why));
25048
25048
  return;
@@ -25053,7 +25053,7 @@ var Chips = class _Chips {
25053
25053
  return;
25054
25054
  }
25055
25055
  this.onHello(socket, hello2);
25056
- void this.subscribed(socket).then(resolve5);
25056
+ void this.subscribed(socket).then(resolve6);
25057
25057
  }
25058
25058
  /** The socket's four events. `settled` fires once: with the hello, a refusal, or nothing. */
25059
25059
  listen(socket, on) {
@@ -25150,15 +25150,15 @@ var Chips = class _Chips {
25150
25150
  subscribed(socket) {
25151
25151
  this.pings += 1;
25152
25152
  const ts = Date.now() + this.pings;
25153
- return new Promise((resolve5) => {
25153
+ return new Promise((resolve6) => {
25154
25154
  const timer = setTimeout(() => {
25155
25155
  this.pongs.delete(ts);
25156
- resolve5();
25156
+ resolve6();
25157
25157
  }, 2e3);
25158
25158
  this.pongs.set(ts, () => {
25159
25159
  clearTimeout(timer);
25160
25160
  this.pongs.delete(ts);
25161
- resolve5();
25161
+ resolve6();
25162
25162
  });
25163
25163
  socket.send(JSON.stringify({ frame: "ping", ts }));
25164
25164
  });
@@ -25388,7 +25388,7 @@ var Chips = class _Chips {
25388
25388
  return /^(5\d\d|429)$/.test(error62.code) || UNREACHABLE.has(error62.code);
25389
25389
  }
25390
25390
  /** The first connect again after a wait, as a reconnect waits; `connect` resolves once it is in. */
25391
- tryAgain(why, resolve5, reject) {
25391
+ tryAgain(why, resolve6, reject) {
25392
25392
  if (this.closed) {
25393
25393
  reject(new ConnectError("the connection was closed while waiting for the server"));
25394
25394
  return;
@@ -25398,7 +25398,7 @@ var Chips = class _Chips {
25398
25398
  clearTimeout(this.timer);
25399
25399
  this.timer = setTimeout(() => {
25400
25400
  this.timer = void 0;
25401
- this.open(true).then(resolve5, reject);
25401
+ this.open(true).then(resolve6, reject);
25402
25402
  }, Math.min(500 * this.retry, 5e3));
25403
25403
  }
25404
25404
  scheduleReconnect() {
@@ -25750,8 +25750,8 @@ async function refused(response) {
25750
25750
  const body = await response.json().catch(() => ({}));
25751
25751
  return new JoinError(body.error?.refusal ?? body.error?.code ?? `http_${response.status}`, body.error?.message ?? `Chips answered ${response.status}.`);
25752
25752
  }
25753
- var wait = (ms, signal) => new Promise((resolve5, reject) => {
25754
- const timer = setTimeout(resolve5, ms);
25753
+ var wait = (ms, signal) => new Promise((resolve6, reject) => {
25754
+ const timer = setTimeout(resolve6, ms);
25755
25755
  signal?.addEventListener("abort", () => {
25756
25756
  clearTimeout(timer);
25757
25757
  reject(new JoinError("stopped", "Stopped before a person decided."));
@@ -26616,8 +26616,8 @@ var AcpClient = class {
26616
26616
  call(method, params) {
26617
26617
  if (this.closed) return Promise.reject(new AcpError("the agent is not running", -32e3));
26618
26618
  const id2 = this.next++;
26619
- return new Promise((resolve5, reject) => {
26620
- this.pending.set(id2, { resolve: resolve5, reject });
26619
+ return new Promise((resolve6, reject) => {
26620
+ this.pending.set(id2, { resolve: resolve6, reject });
26621
26621
  this.wire.write(JSON.stringify({ jsonrpc: "2.0", id: id2, method, params }));
26622
26622
  });
26623
26623
  }
@@ -26957,8 +26957,8 @@ async function checkSignIn(kind2, wire, cwd, options = {}) {
26957
26957
  let status;
26958
26958
  let heard = () => {
26959
26959
  };
26960
- const said = new Promise((resolve5) => {
26961
- heard = resolve5;
26960
+ const said = new Promise((resolve6) => {
26961
+ heard = resolve6;
26962
26962
  });
26963
26963
  const client = new AcpClient(wire, {
26964
26964
  update: () => void 0,
@@ -27020,7 +27020,7 @@ function withFetchedAdapter(kind2, env2 = process.env, home = homedir5()) {
27020
27020
  return runnable(fetched) ? { ...kind2, command: [fetched, ...kind2.command.slice(1)] } : kind2;
27021
27021
  }
27022
27022
  function npmInstall(job) {
27023
- return new Promise((resolve5, reject) => {
27023
+ return new Promise((resolve6, reject) => {
27024
27024
  const registry2 = job.env["CHIPS_NPM_REGISTRY"];
27025
27025
  const child = spawn2(
27026
27026
  job.node,
@@ -27050,7 +27050,7 @@ function npmInstall(job) {
27050
27050
  });
27051
27051
  child.on("exit", (code) => {
27052
27052
  clearTimeout(late);
27053
- if (code === 0) resolve5();
27053
+ if (code === 0) resolve6();
27054
27054
  else reject(new Error(said.trim() || `npm stopped with ${code ?? "a signal"}`));
27055
27055
  });
27056
27056
  });
@@ -27816,6 +27816,7 @@ var IDLE_MS = 30 * 6e4;
27816
27816
  var ANSWERED = 500;
27817
27817
  var QUOTED = 1500;
27818
27818
  var CARRY_ON = "You were paused partway through this. Carry on from where you stopped. Nothing you wrote before the pause reached the room, so write your whole reply.";
27819
+ var UNANSWERED = "Nobody answered, so I stopped. Ask me to carry on.";
27819
27820
  function shares(asked) {
27820
27821
  return asked.again === void 0 && folds(asked.message);
27821
27822
  }
@@ -27834,8 +27835,8 @@ var Bridge = class {
27834
27835
  constructor(options) {
27835
27836
  this.options = options;
27836
27837
  this.log = options.log ?? (() => void 0);
27837
- this.known = new Promise((resolve5) => {
27838
- this.knew = resolve5;
27838
+ this.known = new Promise((resolve6) => {
27839
+ this.knew = resolve6;
27839
27840
  });
27840
27841
  this.env = options.env ?? adapterEnv(options.kind, { ...process.env, ...options.kind.env });
27841
27842
  this.places = placesOf2(this.env, options.home ?? homedir7());
@@ -28287,7 +28288,7 @@ var Bridge = class {
28287
28288
  const client = this.process.client;
28288
28289
  if (client !== void 0 && !client.gone && this.process.info !== void 0) return client;
28289
28290
  if (Date.now() > by) return void 0;
28290
- await new Promise((resolve5) => setTimeout(resolve5, 100));
28291
+ await new Promise((resolve6) => setTimeout(resolve6, 100));
28291
28292
  }
28292
28293
  return void 0;
28293
28294
  }
@@ -28491,6 +28492,8 @@ var Bridge = class {
28491
28492
  stopping: false,
28492
28493
  pausing: false,
28493
28494
  asking: 0,
28495
+ unanswered: false,
28496
+ letGo: /* @__PURE__ */ new Set(),
28494
28497
  saidAt: 0,
28495
28498
  gaugeAt: 0,
28496
28499
  steps: /* @__PURE__ */ new Map(),
@@ -28500,11 +28503,7 @@ var Bridge = class {
28500
28503
  };
28501
28504
  room.turn = turn;
28502
28505
  this.sayPausable(run2, speakerId);
28503
- const interrupt = () => {
28504
- if (!turn.prompting || turn.stopping) return;
28505
- turn.stopping = true;
28506
- this.process.client?.cancel(turn.sessionId);
28507
- };
28506
+ const interrupt = () => this.interrupt(turn);
28508
28507
  run2.on("cancel", () => {
28509
28508
  turn.cancelled = true;
28510
28509
  interrupt();
@@ -28583,6 +28582,10 @@ ${files.join("\n")}`;
28583
28582
  const paused = turn.pausing;
28584
28583
  turn.pausing = false;
28585
28584
  if (!await this.unpaused(turn)) return;
28585
+ if (turn.unanswered) {
28586
+ await this.finish(room, turn, "end_turn", UNANSWERED);
28587
+ return;
28588
+ }
28586
28589
  if (stop === "cancelled" && (paused || turn.next.length > 0)) {
28587
28590
  turn.reply = "";
28588
28591
  prompt = paused ? [CARRY_ON, ...turn.next.splice(0)].join("\n\n") : turn.next.shift();
@@ -28593,6 +28596,24 @@ ${files.join("\n")}`;
28593
28596
  }
28594
28597
  await this.finish(room, turn, stop);
28595
28598
  }
28599
+ /** The prompt going, if one is, told to stop (`session/cancel`): once, however many ask. */
28600
+ interrupt(turn) {
28601
+ if (!turn.prompting || turn.stopping) return;
28602
+ turn.stopping = true;
28603
+ this.process.client?.cancel(turn.sessionId);
28604
+ }
28605
+ /**
28606
+ * An ask expired with nobody's answer, so the turn ends: its prompt is stopped, and every ask of
28607
+ * its that still waits is let go with no answer, as ACP has for a stopped prompt. The agent is
28608
+ * not told no. A no reads as "try another way", and its next try asks again, an hour later, all
28609
+ * night. The turn ends on `UNANSWERED` once the prompt is back.
28610
+ */
28611
+ giveUp(turn) {
28612
+ if (turn.unanswered) return;
28613
+ turn.unanswered = true;
28614
+ for (const letGo of [...turn.letGo]) letGo();
28615
+ this.interrupt(turn);
28616
+ }
28596
28617
  /**
28597
28618
  * Once the run isn't paused (Chips ADR 0293): true to go on, false when it was stopped, before or
28598
28619
  * while it waited, which ends the turn with nothing more said, as a Stop does.
@@ -28717,8 +28738,11 @@ ${files.join("\n")}`;
28717
28738
  this.log(`${room.record.name}'s turn says no cost: ${why} ($${total.toFixed(2)} in all now)`);
28718
28739
  await run2.usage({ model: turn.agentName }).catch(() => void 0);
28719
28740
  }
28720
- /** The turn is over: its words in the room, what it cost, and the run ended as it went. */
28721
- async finish(room, turn, stop) {
28741
+ /**
28742
+ * The turn is over: its words in the room, what it cost, and the run ended as it went. With
28743
+ * `instead`, those words are said in place of the agent's own.
28744
+ */
28745
+ async finish(room, turn, stop, instead) {
28722
28746
  const { run: run2 } = turn;
28723
28747
  if (run2.over) return;
28724
28748
  await this.settleSteps(turn, "done");
@@ -28730,7 +28754,7 @@ ${files.join("\n")}`;
28730
28754
  await run2.fail({ error: `${room.record.name} refused.` });
28731
28755
  return;
28732
28756
  }
28733
- const answer = turn.reply.trim() || (turn.said.at(-1) ?? "");
28757
+ const answer = instead ?? (turn.reply.trim() || (turn.said.at(-1) ?? ""));
28734
28758
  const { change, note } = await this.sendProject(room, turn, answer);
28735
28759
  const { chips: chips2 } = this.options;
28736
28760
  const words4 = [answer, note ?? ""].filter((part) => part !== "").join("\n\n");
@@ -29452,7 +29476,7 @@ ${files.join("\n")}`;
29452
29476
  const turn = this.turnOf(String(params["sessionId"]));
29453
29477
  const options = Array.isArray(params["options"]) ? params["options"] : [];
29454
29478
  if (turn === void 0) return { outcome: { outcome: "cancelled" } };
29455
- if (turn.pausing) return { outcome: { outcome: "cancelled" } };
29479
+ if (turn.pausing || turn.unanswered) return { outcome: { outcome: "cancelled" } };
29456
29480
  const call = params["toolCall"] ?? {};
29457
29481
  const kind2 = toolOf(call) ?? "other";
29458
29482
  const title2 = typeof call["title"] === "string" ? call["title"] : `use ${kind2}`;
@@ -29467,7 +29491,11 @@ ${files.join("\n")}`;
29467
29491
  });
29468
29492
  const decision = await this.answerOf(turn, asked);
29469
29493
  if (decision === void 0) return { outcome: { outcome: "cancelled" } };
29470
- const chosen = optionFor(decision, options, carriesCommand(input2));
29494
+ if (decision.decision === "expired") {
29495
+ this.giveUp(turn);
29496
+ return { outcome: { outcome: "cancelled" } };
29497
+ }
29498
+ const chosen = optionFor(decision, options, call["kind"] === "switch_mode");
29471
29499
  if (decision.allowed && chosen !== void 0 && call["toolCallId"] !== void 0) {
29472
29500
  turn.allowed.set(String(call["toolCallId"]), decision.approvalId);
29473
29501
  }
@@ -29500,18 +29528,26 @@ ${files.join("\n")}`;
29500
29528
  /**
29501
29529
  * A person's answer to what the agent asked, once the agent may have it: one given while the run
29502
29530
  * is paused waits for Resume (Chips ADR 0293), and a Stop, before the answer or while it waits,
29503
- * leaves none. While an ask waits, a Pause stops nothing.
29531
+ * leaves none. Nor does a turn that ended on another ask nobody answered (`giveUp`). While an ask
29532
+ * waits, a Pause stops nothing.
29504
29533
  */
29505
29534
  async answerOf(turn, asked) {
29506
29535
  let off = () => void 0;
29507
- const stopped2 = new Promise((resolve5) => {
29508
- off = turn.run.on("cancel", () => resolve5(void 0));
29536
+ const stopped2 = new Promise((resolve6) => {
29537
+ const letGo = () => resolve6(void 0);
29538
+ const unheard = turn.run.on("cancel", letGo);
29539
+ turn.letGo.add(letGo);
29540
+ off = () => {
29541
+ unheard();
29542
+ turn.letGo.delete(letGo);
29543
+ };
29509
29544
  });
29510
29545
  turn.asking += 1;
29511
29546
  try {
29512
29547
  const answer = await Promise.race([asked, stopped2]);
29513
29548
  if (answer === void 0) return void 0;
29514
- return await this.unpaused(turn) ? answer : void 0;
29549
+ if (!await this.unpaused(turn)) return void 0;
29550
+ return turn.unanswered ? void 0 : answer;
29515
29551
  } finally {
29516
29552
  off();
29517
29553
  turn.asking -= 1;
@@ -29620,19 +29656,13 @@ function riskOf(kind2) {
29620
29656
  if (kind2 === "fetch") return ["external"];
29621
29657
  return [];
29622
29658
  }
29623
- function optionFor(decision, options, command) {
29659
+ function optionFor(decision, options, changesMode) {
29624
29660
  const find = (kind2) => options.find((option) => option.kind === kind2)?.optionId;
29625
29661
  if (!decision.allowed) return find("reject_once") ?? find("reject_always");
29626
- const harnessKeeps = decision.keeps === "harness";
29627
- if (decision.scope === "always" && (!command || harnessKeeps)) {
29628
- return find("allow_always") ?? find("allow_once");
29629
- }
29630
- return find("allow_once") ?? find("allow_always");
29631
- }
29632
- function carriesCommand(input2) {
29633
- if (typeof input2 !== "object" || input2 === null) return false;
29634
- const command = input2["command"];
29635
- return typeof command === "string" || Array.isArray(command);
29662
+ const always = options.filter((option) => option.kind === "allow_always");
29663
+ const ownAlways = always.length === 1 && !changesMode ? always[0]?.optionId : void 0;
29664
+ if (decision.scope === "always" && decision.keeps === "harness" && ownAlways !== void 0) return ownAlways;
29665
+ return find("allow_once") ?? ownAlways;
29636
29666
  }
29637
29667
  function questionOf(id2, field, message) {
29638
29668
  const prompt = String(field["title"] ?? field["description"] ?? message ?? id2).slice(0, 500);
@@ -29659,15 +29689,30 @@ function forkName(original) {
29659
29689
  }
29660
29690
 
29661
29691
  // src/keep.ts
29662
- import { basename as basename4 } from "node:path";
29692
+ import { realpathSync } from "node:fs";
29693
+ import { basename as basename4, relative as relative3, resolve as resolve4, sep as sep4 } from "node:path";
29663
29694
  import { fileURLToPath as fileURLToPath2 } from "node:url";
29664
29695
  var flags = process.argv.slice(2);
29665
29696
  var words3 = flags.filter((word) => !word.startsWith("--"));
29666
29697
  var handsOver = flags.includes("--keep");
29667
29698
  var stopping = flags.includes("--stop");
29668
29699
  var whole = (word) => configTargetOf(word);
29669
- var here = fileURLToPath2(new URL("..", import.meta.url)).replace(/\/$/, "");
29670
- var self = fileURLToPath2(import.meta.url);
29700
+ function asStarted(root, file3, started2 = process.argv[1]) {
29701
+ if (started2 === void 0 || started2 === "") return { root, file: file3 };
29702
+ const tail = relative3(root, file3);
29703
+ const whole2 = resolve4(started2);
29704
+ if (!whole2.endsWith(`${sep4}${tail}`)) return { root, file: file3 };
29705
+ try {
29706
+ if (realpathSync(whole2) !== realpathSync(file3)) return { root, file: file3 };
29707
+ } catch {
29708
+ return { root, file: file3 };
29709
+ }
29710
+ return { root: whole2.slice(0, -tail.length - 1), file: whole2 };
29711
+ }
29712
+ var { root: here, file: self } = asStarted(
29713
+ fileURLToPath2(new URL("..", import.meta.url)).replace(/\/$/, ""),
29714
+ fileURLToPath2(import.meta.url)
29715
+ );
29671
29716
  var run = self.endsWith(".js") ? [self] : ["--import", "tsx", "src/main.ts"];
29672
29717
  var again = process.env["npm_lifecycle_event"] === "keep" ? "npm run keep --" : basename4(process.argv[1] ?? "chips");
29673
29718
  var stopLine = process.env["CHIPS_STOP_COMMAND"] || [again, ...words3, "--stop"].join(" ");
@@ -29714,7 +29759,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
29714
29759
  // src/move.ts
29715
29760
  import { lstatSync, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync as renameSync2, rmdirSync, writeFileSync as writeFileSync4 } from "node:fs";
29716
29761
  import { homedir as homedir8 } from "node:os";
29717
- import { basename as basename5, dirname as dirname6, join as join11, resolve as resolve4 } from "node:path";
29762
+ import { basename as basename5, dirname as dirname6, join as join11, resolve as resolve5 } from "node:path";
29718
29763
  var there = (path) => {
29719
29764
  try {
29720
29765
  lstatSync(path);
@@ -29754,7 +29799,7 @@ function removeIfEmpty(path) {
29754
29799
  function claudeStoreOf(folder2, env2, home = homedir8()) {
29755
29800
  const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
29756
29801
  if (name.length > 200) return void 0;
29757
- return join11(env2["CLAUDE_CONFIG_DIR"] ? resolve4(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
29802
+ return join11(env2["CLAUDE_CONFIG_DIR"] ? resolve5(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
29758
29803
  }
29759
29804
  function pairOf(path, places) {
29760
29805
  const old = inside2(places.oldAgents, path);
@@ -29803,7 +29848,7 @@ function moveOld(configPath2, log2, home = homedir8(), env2 = process.env) {
29803
29848
  for (const key of ["folders", "folder"]) {
29804
29849
  const said = config2[key];
29805
29850
  if (typeof said !== "string") continue;
29806
- const path = resolve4(fromHome(said, home));
29851
+ const path = resolve5(fromHome(said, home));
29807
29852
  const moved = nowAt(path, places.oldAgents, places.agents);
29808
29853
  if (moved === path) continue;
29809
29854
  config2[key] = `~/${moved.slice(home.length + 1)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "An agent that speaks the Agent Client Protocol, as a Chips harness of its kind: agents made from Chips, each in a folder of its own, each room a session.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {