@chipschat/acp 1.0.22 → 1.0.23

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.
@@ -1,9 +1,9 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/main.js` in @chipschat/acp 1.0.22 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/acp 1.0.23 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
- ## @chipschat/harness 1.0.4 (Apache-2.0)
6
+ ## @chipschat/harness 1.0.5 (Apache-2.0)
7
7
 
8
8
  Apache License
9
9
  Version 2.0, January 2004
@@ -207,7 +207,7 @@ Apache License
207
207
  See the License for the specific language governing permissions and
208
208
  limitations under the License.
209
209
 
210
- ## @chipschat/protocol 1.0.4 (Apache-2.0)
210
+ ## @chipschat/protocol 1.0.5 (Apache-2.0)
211
211
 
212
212
  Apache License
213
213
  Version 2.0, January 2004
package/dist/main.js CHANGED
@@ -20389,6 +20389,25 @@ var DROPPED_ANY = new RegExp(String.raw`^(?:&?>>?[ \t]*\/dev\/null|>&[12])${ENDS
20389
20389
 
20390
20390
  // node_modules/@chipschat/protocol/dist/src/connectors.js
20391
20391
  var words = (most) => external_exports.string().trim().min(1).max(most);
20392
+ var startStep = external_exports.object({
20393
+ says: words(200).describe("What they do, as a sentence: `Install Claude Code.`"),
20394
+ line: words(400).optional().describe("The line for it, run in Terminal: the maker's own installer or sign-in."),
20395
+ open: external_exports.url({ protocol: /^https$/ }).optional().describe("A page of the maker's to open for it: where to make an account."),
20396
+ done: external_exports.object({
20397
+ program: external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/).optional().describe("A command the step puts on the PATH: the step is done once it is there."),
20398
+ signedIn: external_exports.literal(true).optional().describe("The step is done once the card's agent says it is signed in, which Chips for Mac asks its own status command, by the card, from a list of its own.")
20399
+ }).optional().describe("How Chips for Mac sees the step done, so the steps tick themselves off (ADR 0290's addendum). Chips only looks: it never runs a step.")
20400
+ }).describe("A step of the written steps, run by the person, never by Chips.");
20401
+ var connectorStart = external_exports.object({
20402
+ answer: words(60).describe("What a person who has this says: `I pay for Claude`."),
20403
+ suggest: words(200).describe("What Chips suggests to them, in a sentence."),
20404
+ steps: external_exports.array(startStep).min(1).max(6),
20405
+ none: external_exports.object({
20406
+ answer: words(60).describe("`Neither of those`."),
20407
+ suggest: words(200),
20408
+ first: external_exports.array(startStep).min(1).max(3).describe("What they do before this card's steps: make an account with its maker.")
20409
+ }).optional().describe("This card is the one suggested to somebody who has none of the others.")
20410
+ }).describe("The written steps for somebody with no agent yet.");
20392
20411
  var connectorKind = external_exports.enum(["one-line", "sdk", "http", "guide"]).describe("`one-line`: a command to run where the harness runs; `sdk`: code on @chipschat/harness; `http`: a key and curl lines; `guide`: a page to follow.");
20393
20412
  var connector = external_exports.object({
20394
20413
  id: external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,40}$/).describe("The docs' name for it, lower case."),
@@ -20398,6 +20417,7 @@ var connector = external_exports.object({
20398
20417
  program: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,40}$/).optional().describe("The agent's own command, as a person runs it: Chips for Mac looks for it, to say the agent is on this Mac (ADR 0288)."),
20399
20418
  whose: words(200).optional().describe("Who makes the agent and where what a person sends it goes, in whole sentences, said beside its way in (ADR 0288)."),
20400
20419
  terms: external_exports.url({ protocol: /^https?$/ }).optional().describe("Its maker's own terms or licence."),
20420
+ start: connectorStart.optional(),
20401
20421
  kind: connectorKind,
20402
20422
  command: words(400).optional().describe("What to run where the harness runs, with `{link}` where the link goes."),
20403
20423
  sentence: words(600).optional().describe("What to say to the agent so it connects itself, with `{link}` in it."),
@@ -20610,7 +20630,7 @@ function renderProjectAsks(facts, options) {
20610
20630
 
20611
20631
  // node_modules/@chipschat/protocol/dist/src/spend.js
20612
20632
  var SPEND_CEILING_MIN = 0.25;
20613
- var SPEND_CEILING_MAX = 100;
20633
+ var SPEND_CEILING_MAX = 1e3;
20614
20634
  var SPEND_CEILING_STEP = 0.25;
20615
20635
  function isSpendCeiling(usd) {
20616
20636
  if (!Number.isFinite(usd) || usd < SPEND_CEILING_MIN || usd > SPEND_CEILING_MAX)
@@ -20646,12 +20666,19 @@ var roomIdle = external_exports.object({
20646
20666
  participant_id: external_exports.string().min(1).max(120),
20647
20667
  minutes: external_exports.int().nonnegative().describe("How long since its last turn here ended, in whole minutes.")
20648
20668
  });
20669
+ var roomAway = external_exports.object({
20670
+ participant_id: external_exports.string().min(1).max(120),
20671
+ why: external_exports.enum(["offline", "trouble"]).describe("`offline`: no connection of its harness is open. `trouble`: its harness is connected and says something is wrong on its side (ADR 0083)."),
20672
+ reason: external_exports.string().min(1).max(200).optional().describe("For `trouble`: what its harness said is wrong, in its own words."),
20673
+ minutes: external_exports.int().nonnegative().describe("For how long, in whole minutes.")
20674
+ });
20649
20675
  var roomNote = external_exports.object({
20650
20676
  members: external_exports.array(roomMember).max(500).describe("The room's people, then its agents, each by name, anybody removed left out."),
20651
20677
  notes: external_exports.record(external_exports.string().max(120), external_exports.string().max(64e3)).describe("The note for each who takes the turn (`for`), by their id: who is here, with handles, and that only those @-mentioned act. A harness puts it at the top of the turn."),
20652
20678
  rules: external_exports.record(external_exports.string().max(120), external_exports.string().max(4e3)).optional().describe("How the space works, for each who takes the turn, by their id: the words its note ends with (ADR 0250), that everyone here reads what it writes and, beside other agents, what an @ does and when to answer NO_REPLY. They stay the same while the space's agents do, so a harness whose session keeps its earlier turns may say them once, and the note without them after."),
20653
20679
  working: external_exports.array(roomWork).max(500).optional().describe("The room's agents with a turn going as Chips sends this one (ADR 0104), the takers' own included. A turn nothing has been heard from for ten minutes is not counted."),
20654
- idle: external_exports.array(roomIdle).max(500).optional().describe("The room's other agents that have had a turn here: how long since the last one ended (ADR 0104).")
20680
+ idle: external_exports.array(roomIdle).max(500).optional().describe("The room's other agents that have had a turn here: how long since the last one ended (ADR 0104)."),
20681
+ away: external_exports.array(roomAway).max(500).optional().describe("The room's agents that can't answer as Chips sends this turn (ADR 0291): offline, or their harness says something is wrong. Work handed to one of them waits.")
20655
20682
  });
20656
20683
  function noteWithoutRules(room, taker) {
20657
20684
  const note = room?.notes[taker];
@@ -21024,7 +21051,7 @@ var hello = defineEvent({
21024
21051
  server: external_exports.object({
21025
21052
  name: external_exports.string().min(1).max(120).describe("Usually `chipsd`."),
21026
21053
  version: external_exports.string().min(1).max(60).describe("The server's own version."),
21027
- takes: external_exports.array(external_exports.string().min(1).max(40)).max(32).optional().describe("What this server keeps of what a person's client may send beyond the base set, by the names in `SERVER_TAKES`. `held_yes` is `for_minutes` and `until_stopped` on `approval.resolved`. A server older than the field says nothing, and drops those fields, so a client offers neither to it (ADR 0281).")
21054
+ takes: external_exports.array(external_exports.string().min(1).max(40)).max(32).optional().describe("What this server keeps of what a person's client may send beyond the base set, by the names in `SERVER_TAKES`. `held_yes` is `for_minutes` and `until_stopped` on `approval.resolved`. A server older than the field says nothing, and drops those fields, so a client offers neither to it (ADR 0281). `spend_no_cap` is No cap and amounts past $100 on a room's Spend per job (ADR 0292).")
21028
21055
  }).describe("Who the client is talking to."),
21029
21056
  harnesses: external_exports.array(harnessManifest).min(1).max(64).describe("The harness the token belongs to, and only that one. One connection speaks for all of the harness's agents (ADR 0087), which `agents` lists. A harness running inside another is a lane, not a duplicate."),
21030
21057
  harness: harnessManifest.optional().describe("The harness this connection is: `harnesses[0]`, said once. Read this rather than the list."),
@@ -21336,7 +21363,8 @@ var runStatus = defineEvent({
21336
21363
  phase: external_exports.string().min(1).max(120).describe("A short machine-ish label, for example `reading`."),
21337
21364
  verb_phrase: external_exports.string().min(1).max(200).describe(`What to show under the harness's name, for example "Reading PO #4471\u2026".`),
21338
21365
  progress: external_exports.number().min(0).max(1).optional().describe("Fraction complete, when the harness knows."),
21339
- estimate_seconds: external_exports.int().nonnegative().optional().describe("Seconds remaining, when the harness knows.")
21366
+ estimate_seconds: external_exports.int().nonnegative().optional().describe("Seconds remaining, when the harness knows."),
21367
+ pausable: external_exports.boolean().optional().describe("This run holds where it is when a person pauses it (ADR 0293): on `run.pause` the harness stops the run's work within a few seconds without ending it, on `run.resume` it carries on in the same conversation, and on `run.cancel` while paused it ends quietly. Said once, on any status of the run; clients offer Pause only on a run that said it.")
21340
21368
  })
21341
21369
  });
21342
21370
  var runPlan = defineEvent({
@@ -22015,7 +22043,10 @@ var messageHanded = defineEvent({
22015
22043
  payload: external_exports.object({
22016
22044
  message_id: id("message").describe("The message, as `message.new` named it."),
22017
22045
  agent_id: agentId.describe("Who it is handed to."),
22018
- lead: external_exports.literal(true).optional().describe("Handed to the room's lead because it was nobody's turn and the room went still (ADR 0104), rather than held by the referee.")
22046
+ lead: external_exports.literal(true).optional().describe("Handed to the room's lead because it was nobody's turn and the room went still (ADR 0104), or because the agent it was for did not pick it up (`unanswered_by`), rather than held by the referee."),
22047
+ unanswered_by: agentId.optional().describe("The agent the message was for that did not pick it up (ADR 0291): no turn of its on it, no word and no pass, a minute after it was said. The message is handed to the room's lead, or, when the lead said it or is the one that did not pick it up, back to the agent that said it."),
22048
+ why: external_exports.enum(["offline", "trouble", "failed", "silent"]).optional().describe("With `unanswered_by`, why: its harness is `offline`, or says something is wrong (`trouble`); its turn on the message `failed`; or it is connected and nothing has been heard from it (`silent`)."),
22049
+ reason: external_exports.string().min(1).max(200).optional().describe("For `trouble`, what its harness said is wrong; for `failed`, the run's error.")
22019
22050
  })
22020
22051
  });
22021
22052
  var turnPassed = defineEvent({
@@ -22058,9 +22089,17 @@ var spaceSpendCeilingSet = defineEvent({
22058
22089
  summary: "What a room allows a job to spend was set, or set back to the default.",
22059
22090
  requiresRun: false,
22060
22091
  payload: external_exports.object({
22061
- usd: spendCeiling.describe("What the room allows a job now, in US dollars, from 0.25 to 100 in steps of 0.25; `null` for the default (3).")
22092
+ usd: spendCeiling.describe("What the room allows a job now, in US dollars, from 0.25 to 1000 in steps of 0.25; `null` for the default (3).")
22062
22093
  })
22063
22094
  });
22095
+ var spaceSpendCeilingLifted = defineEvent({
22096
+ type: "space.spend_ceiling_lifted",
22097
+ direction: "workspace",
22098
+ sender: "chips",
22099
+ summary: "A room's cap on what a job may spend was taken off: No cap.",
22100
+ requiresRun: false,
22101
+ payload: external_exports.object({})
22102
+ });
22064
22103
  var spaceLockSet = defineEvent({
22065
22104
  type: "space.lock_set",
22066
22105
  direction: "workspace",
@@ -22443,6 +22482,7 @@ var WORKSPACE_EVENTS = [
22443
22482
  messageHanded,
22444
22483
  spaceLeadSet,
22445
22484
  spaceSpendCeilingSet,
22485
+ spaceSpendCeilingLifted,
22446
22486
  spaceLockSet,
22447
22487
  turnPassed,
22448
22488
  contextCompacted,
@@ -25276,6 +25316,7 @@ function file2(path) {
25276
25316
  };
25277
25317
  return {
25278
25318
  kind: "file",
25319
+ path,
25279
25320
  get: (account) => read()[account],
25280
25321
  set(account, secret) {
25281
25322
  write({ ...read(), [account]: secret });
@@ -25286,14 +25327,34 @@ function file2(path) {
25286
25327
  }
25287
25328
  };
25288
25329
  }
25330
+ function orInTheFile(best, plain, say = (line) => void process.stderr.write(`${line}
25331
+ `)) {
25332
+ const where = best.kind === "keychain" ? "The keychain" : "The Secret Service";
25333
+ return {
25334
+ kind: best.kind,
25335
+ get: (account) => best.get(account) ?? plain.get(account),
25336
+ set(account, secret) {
25337
+ try {
25338
+ best.set(account, secret);
25339
+ } catch {
25340
+ plain.set(account, secret);
25341
+ say(`${where} wouldn't take its key, so it's kept in ${plain.path ?? "a file"}, which only you can read.`);
25342
+ }
25343
+ },
25344
+ remove(account) {
25345
+ best.remove(account);
25346
+ plain.remove(account);
25347
+ }
25348
+ };
25349
+ }
25289
25350
  function openKeyStore(env2, platform = process.platform) {
25290
25351
  const plain = file2(join2(configHome(env2), "harness-keys.json"));
25291
25352
  if (env2["CHIPS_NO_KEYCHAIN"] === "true")
25292
25353
  return plain;
25293
25354
  if (platform === "darwin" && answers("/usr/bin/security", ["list-keychains"]))
25294
- return keychain();
25355
+ return orInTheFile(keychain(), plain);
25295
25356
  if (platform === "linux" && answers("sh", ["-c", "command -v secret-tool"]))
25296
- return secretService();
25357
+ return orInTheFile(secretService(), plain);
25297
25358
  return plain;
25298
25359
  }
25299
25360
 
@@ -25534,9 +25595,18 @@ async function join3(options) {
25534
25595
  const answered = joinedOf(answer);
25535
25596
  const joined2 = { ...answered, url: hereInstead(answered.url, env2) ?? answered.url };
25536
25597
  if (store !== false)
25537
- store.set(account, JSON.stringify({ ...joined2, from, hello: "due" }));
25598
+ keepTheKey(store, account, { ...joined2, from, hello: "due" });
25538
25599
  return joined2;
25539
25600
  }
25601
+ function keepTheKey(store, account, record2) {
25602
+ try {
25603
+ store.set(account, JSON.stringify(record2));
25604
+ } catch (error62) {
25605
+ const why = error62 instanceof Error ? error62.message.split("\n")[0] : String(error62);
25606
+ process.stderr.write(`Its key couldn't be kept here (${why}). It works while this runs. Once it stops, it needs a new link from Chips.
25607
+ `);
25608
+ }
25609
+ }
25540
25610
  async function helloOnce(joined2, options) {
25541
25611
  const { spaceId } = joined2;
25542
25612
  if (spaceId === void 0)
@@ -25685,15 +25755,60 @@ function rulesFor(message, options = {}) {
25685
25755
  options.sendsFiles === true ? sendingFiles({ project: project !== void 0 }) : void 0
25686
25756
  ].filter((part) => part !== void 0 && part !== "").join("\n\n");
25687
25757
  }
25688
- function promptFor(message, options = {}) {
25689
- const taker = takerOf(message, options);
25690
- const held = options.rulesHeld === true;
25691
- const notes = message.room?.notes ?? {};
25692
- const note = taker === void 0 ? void 0 : held ? noteWithoutRules(message.room, taker) : notes[taker];
25758
+ function lineOfHeard(heard) {
25759
+ const files = heard.attachments ?? [];
25760
+ const said = files.flatMap((file3) => file3.transcript === void 0 ? [] : [file3.transcript]);
25761
+ return {
25762
+ seq: 1,
25763
+ at: "",
25764
+ kind: "said",
25765
+ from: {
25766
+ id: heard.from.participant_id,
25767
+ kind: heard.from.kind,
25768
+ name: heard.from.display_name,
25769
+ ...heard.from.workspace_role === void 0 ? {} : { workspace_role: heard.from.workspace_role }
25770
+ },
25771
+ text: heard.text,
25772
+ ...said.length === 0 ? {} : { transcript: said.join(" ") },
25773
+ ...files.length === 0 ? {} : { files: files.map((file3) => file3.filename) },
25774
+ ...heard.held === true ? { held: true } : {}
25775
+ };
25776
+ }
25777
+ function sinceOf(options) {
25778
+ const since = (options.since ?? []).slice(-CONTEXT_BUDGET.lines);
25779
+ if (since.length === 0)
25780
+ return void 0;
25781
+ const those = (options.earlier ?? []).length === 0 ? "that message" : "those messages";
25782
+ return [
25783
+ `Said in this space after ${those}, to others:`,
25784
+ ...since.map((each) => renderLine(lineOfHeard(each)))
25785
+ ].join("\n");
25786
+ }
25787
+ function heldWords(answer, released = false) {
25788
+ if (answer?.held !== true)
25789
+ return void 0;
25790
+ if (released) {
25791
+ return "Your last message in this space was held from the agents it named until a person acted. A person has now, so Chips has handed it to them: do not send it again.";
25792
+ }
25793
+ const count = answer.exchange?.count;
25794
+ const since = typeof count === "number" && count > 0 ? ` (they have sent each other ${count} since a person last acted)` : "";
25795
+ return `Your last message in this space was held, so the agents it named do not have it yet: messages between the agents here are held${since} until a person acts. Until then, tell the person what is done and what is blocked, rather than asking the agents again.`;
25796
+ }
25797
+ var BEFORE_HEADING = "Said in this space before you joined:";
25798
+ function beforeOf(message, options) {
25799
+ const said = /* @__PURE__ */ new Set([
25800
+ message.message_id,
25801
+ ...(options.earlier ?? []).map((each) => each.message_id)
25802
+ ]);
25803
+ const lines2 = (options.before?.lines ?? []).filter((line) => line.message_id === void 0 || !said.has(line.message_id));
25804
+ return lines2.length === 0 ? void 0 : [BEFORE_HEADING, ...lines2.map(renderLine)].join("\n");
25805
+ }
25806
+ function waitedWords(count) {
25807
+ return `${count} messages for you waited while you were working or away. They follow, oldest first. Answer them together in one reply, and where a later one changes or settles an earlier one, go by the later.`;
25808
+ }
25809
+ function saidOf(message, options, taker) {
25693
25810
  const who2 = options.sayWho === false ? "" : `${withRole(message.from.display_name, message.from)}: `;
25694
25811
  const files = (message.attachments ?? []).map(renderAttachment);
25695
- const words4 = [`${who2}${message.text}`, ...files].join("\n");
25696
- const sending = options.sendsFiles === true && !held ? sendingFiles({ project: options.project !== void 0 }) : void 0;
25697
25812
  const replying = renderReplyingTo(message.replying_to, {
25698
25813
  sender: {
25699
25814
  id: message.from.participant_id,
@@ -25705,15 +25820,42 @@ function promptFor(message, options = {}) {
25705
25820
  at: message.ts,
25706
25821
  zone: options.zone
25707
25822
  });
25823
+ return [replying, [`${who2}${message.text}`, ...files].join("\n")];
25824
+ }
25825
+ function contextOf(message, options) {
25826
+ const { context } = message;
25827
+ const waited = /* @__PURE__ */ new Set([
25828
+ ...(options.earlier ?? []).map((each) => each.message_id),
25829
+ ...options.answered ?? []
25830
+ ]);
25831
+ if (context === void 0 || waited.size === 0)
25832
+ return context;
25833
+ return {
25834
+ ...context,
25835
+ lines: context.lines.filter((line) => line.message_id === void 0 || !waited.has(line.message_id))
25836
+ };
25837
+ }
25838
+ function promptFor(message, options = {}) {
25839
+ const taker = takerOf(message, options);
25840
+ const held = options.rulesHeld === true;
25841
+ const earlier = options.earlier ?? [];
25842
+ const notes = message.room?.notes ?? {};
25843
+ const note = taker === void 0 ? void 0 : held ? noteWithoutRules(message.room, taker) : notes[taker];
25844
+ const sending = options.sendsFiles === true && !held ? sendingFiles({ project: options.project !== void 0 }) : void 0;
25708
25845
  const project = options.project === void 0 ? void 0 : held ? renderProjectFacts(options.project) : renderProjectNote(options.project, { othersInRoom: othersBeside(message, taker) });
25709
25846
  return [
25847
+ // Held still where this message says so; else a person has acted since, and it was handed over.
25848
+ heldWords(options.heldPost, message.exchange?.stage !== "held"),
25710
25849
  message.exchange?.note,
25711
25850
  note,
25712
25851
  project,
25713
25852
  sending,
25714
- renderContext(message.context),
25715
- replying,
25716
- words4
25853
+ beforeOf(message, options),
25854
+ renderContext(contextOf(message, options)),
25855
+ earlier.length === 0 ? void 0 : waitedWords(earlier.length + 1),
25856
+ ...earlier.flatMap((each) => saidOf(each, options, taker)),
25857
+ ...saidOf(message, options, taker),
25858
+ sinceOf(options)
25717
25859
  ].filter((part) => part !== void 0 && part !== "").join("\n\n");
25718
25860
  }
25719
25861
 
@@ -25912,8 +26054,35 @@ var pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0,
25912
26054
  var LOAD_TRIES = 40;
25913
26055
  var runOf = (options) => options.run ?? ((command) => execFileSync2(command[0], command.slice(1), {
25914
26056
  encoding: "utf8",
25915
- stdio: ["ignore", "pipe", "ignore"]
26057
+ // What it printed on failing is what says why: no session, no bus.
26058
+ stdio: ["ignore", "pipe", "pipe"]
25916
26059
  }));
26060
+ var Refused = class extends Error {
26061
+ command;
26062
+ printed;
26063
+ constructor(command, printed) {
26064
+ super(`${command.join(" ")} failed`);
26065
+ this.command = command;
26066
+ this.printed = printed;
26067
+ }
26068
+ };
26069
+ function printedBy(error62) {
26070
+ if (typeof error62 !== "object" || error62 === null)
26071
+ return String(error62);
26072
+ const { stderr, stdout, message } = error62;
26073
+ const said = [stderr, stdout].map((each) => typeof each === "string" ? each.trim() : "").join("\n").trim();
26074
+ return said !== "" ? said : typeof message === "string" ? message : "";
26075
+ }
26076
+ function refusedWords(command, printed) {
26077
+ const first = printed.split("\n")[0]?.trim() ?? "";
26078
+ if (command[0] === "launchctl" && /Bootstrap failed: (5|125)|Domain does not support|Could not find domain/.test(printed)) {
26079
+ return "Nobody is logged in to this Mac at its screen, so it can't be kept running from here";
26080
+ }
26081
+ if (command[0] === "systemctl" && /Failed to connect to (user scope )?bus|DBUS_SESSION_BUS_ADDRESS|not been booted with systemd/.test(printed)) {
26082
+ return "This shell has no systemd user session, so it can't be kept running from here";
26083
+ }
26084
+ return `It couldn't be kept running: \`${command.join(" ")}\` failed${first === "" ? "" : ` (${first})`}`;
26085
+ }
25917
26086
  var ours = (path) => !existsSync3(path) || readFileSync3(path, "utf8").includes(MARK);
25918
26087
  function runOne(command, run2, retryMs) {
25919
26088
  const tries = command[0] === "launchctl" && command[1] === "bootstrap" ? LOAD_TRIES : 1;
@@ -25925,7 +26094,7 @@ function runOne(command, run2, retryMs) {
25925
26094
  if (mayFail(command))
25926
26095
  return;
25927
26096
  if (tried >= tries)
25928
- throw error62;
26097
+ throw new Refused(command, printedBy(error62));
25929
26098
  pause(retryMs);
25930
26099
  }
25931
26100
  }
@@ -25967,7 +26136,20 @@ function keepRunning(spec, options = {}) {
25967
26136
  mkdirSync2(dirname2(file3.logFile), { recursive: true });
25968
26137
  writeFileSync2(file3.path, file3.contents, { mode: 384 });
25969
26138
  chmodSync2(file3.path, 384);
25970
- runAll(startCommands(file3.kind, spec.label, file3.path, uidOf(options)), options);
26139
+ try {
26140
+ runAll(startCommands(file3.kind, spec.label, file3.path, uidOf(options)), options);
26141
+ } catch (error62) {
26142
+ if (!(error62 instanceof Refused))
26143
+ throw error62;
26144
+ try {
26145
+ runAll(stopCommands(file3.kind, spec.label, uidOf(options)), options);
26146
+ } catch {
26147
+ }
26148
+ rmSync2(file3.path, { force: true });
26149
+ const why = refusedWords(error62.command, error62.printed);
26150
+ sayOf(options)(`${why}. It runs here instead, while this terminal is open.`);
26151
+ return { state: "failed", why };
26152
+ }
25971
26153
  if (file3.kind === "systemd" && !lingers(options)) {
25972
26154
  sayOf(options)("It stops when you log out. To keep it running on a machine nobody logs in to, run this once: sudo loginctl enable-linger $USER");
25973
26155
  }
@@ -26995,21 +27177,6 @@ var ContextFiles = class {
26995
27177
 
26996
27178
  // src/fold.ts
26997
27179
  var GATHER_MS = 150;
26998
- function heldWords(answer, released = false) {
26999
- if (answer?.held !== true) return void 0;
27000
- if (released) {
27001
- return "Your last message in this space was held from the agents it named until a person acted. A person has now, so Chips has handed it to them: do not send it again.";
27002
- }
27003
- const count = answer.exchange?.count;
27004
- const since = typeof count === "number" && count > 0 ? ` (they have sent each other ${count} since a person last acted)` : "";
27005
- return `Your last message in this space was held, so the agents it named do not have it yet: messages between the agents here are held${since} until a person acts. Until then, tell the person what is done and what is blocked, rather than asking the agents again.`;
27006
- }
27007
- var BEFORE_HEADING = "Said in this space before you joined:";
27008
- function beforeOf(message, earlier, before) {
27009
- const said = /* @__PURE__ */ new Set([message.message_id, ...earlier.map((each) => each.message_id)]);
27010
- const lines2 = (before?.lines ?? []).filter((line) => line.message_id === void 0 || !said.has(line.message_id));
27011
- return lines2.length === 0 ? void 0 : [BEFORE_HEADING, ...lines2.map(renderLine)].join("\n");
27012
- }
27013
27180
  function folds(message) {
27014
27181
  return message.handed !== true;
27015
27182
  }
@@ -27021,77 +27188,6 @@ function keepHeard(since, heard) {
27021
27188
  since.push(heard);
27022
27189
  if (since.length > CONTEXT_BUDGET.lines) since.shift();
27023
27190
  }
27024
- function lineOfHeard(heard) {
27025
- const files = heard.attachments ?? [];
27026
- const said = files.flatMap((file3) => file3.transcript === void 0 ? [] : [file3.transcript]);
27027
- return {
27028
- seq: 1,
27029
- at: "",
27030
- kind: "said",
27031
- from: {
27032
- id: heard.from.participant_id,
27033
- kind: heard.from.kind,
27034
- name: heard.from.display_name,
27035
- ...heard.from.workspace_role === void 0 ? {} : { workspace_role: heard.from.workspace_role }
27036
- },
27037
- text: heard.text,
27038
- ...said.length === 0 ? {} : { transcript: said.join(" ") },
27039
- ...files.length === 0 ? {} : { files: files.map((file3) => file3.filename) },
27040
- ...heard.held === true ? { held: true } : {}
27041
- };
27042
- }
27043
- function sinceOf(since, earlier) {
27044
- const newest = since.slice(-CONTEXT_BUDGET.lines);
27045
- if (newest.length === 0) return void 0;
27046
- const those = earlier.length === 0 ? "that message" : "those messages";
27047
- return [`Said in this space after ${those}, to others:`, ...newest.map((each) => renderLine(lineOfHeard(each)))].join("\n");
27048
- }
27049
- function waitedWords(count) {
27050
- return `${count} messages for you waited while you were working or away. They follow, oldest first. Answer them together in one reply, and where a later one changes or settles an earlier one, go by the later.`;
27051
- }
27052
- function saidOf(message, options, taker) {
27053
- const who2 = options.sayWho === false ? "" : `${withRole(message.from.display_name, message.from)}: `;
27054
- const files = (message.attachments ?? []).map(renderAttachment);
27055
- const replying = renderReplyingTo(message.replying_to, {
27056
- sender: {
27057
- id: message.from.participant_id,
27058
- name: message.from.display_name,
27059
- kind: message.from.kind,
27060
- workspace_role: message.from.workspace_role
27061
- },
27062
- taker,
27063
- at: message.ts,
27064
- zone: options.zone
27065
- });
27066
- return [replying, [`${who2}${message.text}`, ...files].join("\n")];
27067
- }
27068
- function contextOf(message, earlier, answered) {
27069
- const { context } = message;
27070
- const waited = /* @__PURE__ */ new Set([...earlier.map((each) => each.message_id), ...answered]);
27071
- if (context === void 0 || waited.size === 0) return context;
27072
- return { ...context, lines: context.lines.filter((line) => line.message_id === void 0 || !waited.has(line.message_id)) };
27073
- }
27074
- function promptForAll(message, options = {}) {
27075
- const { earlier = [], since = [], answered = [], before, heldPost, ...rest } = options;
27076
- const held = heldWords(heldPost, message.exchange?.stage !== "held");
27077
- const joinedBefore = beforeOf(message, earlier, before);
27078
- if (earlier.length === 0 && since.length === 0 && answered.length === 0 && held === void 0 && joinedBefore === void 0) {
27079
- return promptFor(message, rest);
27080
- }
27081
- const taker = rest.taker ?? (message.for?.length === 1 ? message.for[0] : void 0);
27082
- const text = [
27083
- joinedBefore,
27084
- renderContext(contextOf(message, earlier, answered)),
27085
- earlier.length === 0 ? void 0 : waitedWords(earlier.length + 1),
27086
- ...earlier.flatMap((each) => saidOf(each, rest, taker)),
27087
- ...saidOf(message, rest, taker),
27088
- sinceOf(since, earlier)
27089
- ].filter((part) => part !== void 0 && part !== "").join("\n\n");
27090
- const { attachments: _files, replying_to: _reply, context: _lines, exchange, ...bare } = message;
27091
- const chips2 = [held, exchange?.note].filter((part) => part !== void 0 && part !== "").join("\n\n");
27092
- const one = { ...bare, text, ...chips2 === "" ? {} : { exchange: { ...exchange, note: chips2 } } };
27093
- return promptFor(one, { ...rest, sayWho: false });
27094
- }
27095
27191
 
27096
27192
  // src/models.ts
27097
27193
  var SETTINGS_LEVEL = "default";
@@ -28003,7 +28099,7 @@ var Bridge = class {
28003
28099
  };
28004
28100
  const rules = rulesFor(message, asked);
28005
28101
  const joined2 = `${speakerId ?? record2.agentId}|${spaceId}`;
28006
- let words4 = promptForAll(message, {
28102
+ let words4 = promptFor(message, {
28007
28103
  ...asked,
28008
28104
  rulesHeld: this.rules.holds(sessionId, rules),
28009
28105
  earlier,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
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": {
@@ -33,9 +33,9 @@
33
33
  "release": "npm run build && npm test && npm pack"
34
34
  },
35
35
  "devDependencies": {
36
- "@chipschat/conformance": "1.0.4",
37
- "@chipschat/harness": "1.0.4",
38
- "@chipschat/protocol": "1.0.4",
36
+ "@chipschat/conformance": "1.0.5",
37
+ "@chipschat/harness": "1.0.5",
38
+ "@chipschat/protocol": "1.0.5",
39
39
  "@types/node": "22.19.0",
40
40
  "esbuild": "0.27.7",
41
41
  "tsx": "4.21.0",