@chipschat/acp 1.0.32 → 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.32 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
@@ -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
  }
@@ -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
29536
  const stopped2 = new Promise((resolve6) => {
29508
- off = turn.run.on("cancel", () => resolve6(void 0));
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.32",
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": {