@chipschat/acp 1.0.28 → 1.0.30

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
@@ -124,6 +124,10 @@ its asks). Then nothing reaches Chips as a card. Put them where they ask:
124
124
  does without asking, and read-only commands never ask.
125
125
  - Codex in `workspace-write` changes its folder freely and asks before the network or anything
126
126
  outside it. `read-only` asks before any change.
127
+ - The bridge tells Chips what those settings let through (Chips ADR 0299), for the harness's
128
+ Permissions page: Claude Code's `permissions` lists from your settings and each agent's folder,
129
+ and the mode; for Codex, its mode. It reads them and never writes them. Needs Chips SDK 1.0.10;
130
+ on an older one nothing is sent.
127
131
 
128
132
  ## Live
129
133
 
@@ -1,9 +1,9 @@
1
1
  # Third-party notices
2
2
 
3
- `dist/main.js` in @chipschat/acp 1.0.28 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/acp 1.0.30 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
- ## @chipschat/harness 1.0.8 (Apache-2.0)
6
+ ## @chipschat/harness 1.0.10 (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.8 (Apache-2.0)
210
+ ## @chipschat/protocol 1.0.10 (Apache-2.0)
211
211
 
212
212
  Apache License
213
213
  Version 2.0, January 2004
package/dist/main.js CHANGED
@@ -687,9 +687,9 @@ function assertNever(_x) {
687
687
  }
688
688
  function assert(_) {
689
689
  }
690
- function getEnumValues(entries) {
691
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
692
- const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
690
+ function getEnumValues(entries2) {
691
+ const numericValues = Object.values(entries2).filter((v) => typeof v === "number");
692
+ const values = Object.entries(entries2).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
693
693
  return values;
694
694
  }
695
695
  function joinValues(array2, separator = "|") {
@@ -2524,16 +2524,16 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
2524
2524
  hide(inst, Symbol.iterator, function* () {
2525
2525
  yield inst;
2526
2526
  });
2527
- let entries;
2527
+ let entries2;
2528
2528
  inst._zod.check = (payload) => {
2529
2529
  if (payload.value == null) {
2530
2530
  payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
2531
2531
  return void 0;
2532
2532
  }
2533
- entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
2533
+ entries2 ?? (entries2 = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
2534
2534
  const input2 = payload.value;
2535
2535
  let proms;
2536
- for (const [key, schema] of entries) {
2536
+ for (const [key, schema] of entries2) {
2537
2537
  const result = schema._zod.run({ value: input2[key], issues: [] }, {});
2538
2538
  if (result instanceof Promise) {
2539
2539
  proms ?? (proms = []);
@@ -15351,18 +15351,18 @@ function _set(Class2, valueType, params) {
15351
15351
  }
15352
15352
  // @__NO_SIDE_EFFECTS__
15353
15353
  function _enum(Class2, values, params) {
15354
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
15354
+ const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
15355
15355
  return new Class2({
15356
15356
  type: "enum",
15357
- entries,
15357
+ entries: entries2,
15358
15358
  ...normalizeParams(params)
15359
15359
  });
15360
15360
  }
15361
15361
  // @__NO_SIDE_EFFECTS__
15362
- function _nativeEnum(Class2, entries, params) {
15362
+ function _nativeEnum(Class2, entries2, params) {
15363
15363
  return new Class2({
15364
15364
  type: "enum",
15365
- entries,
15365
+ entries: entries2,
15366
15366
  ...normalizeParams(params)
15367
15367
  });
15368
15368
  }
@@ -18345,17 +18345,17 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
18345
18345
  };
18346
18346
  });
18347
18347
  function _enum2(values, params) {
18348
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
18348
+ const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
18349
18349
  return new ZodEnum({
18350
18350
  type: "enum",
18351
- entries,
18351
+ entries: entries2,
18352
18352
  ...util_exports.normalizeParams(params)
18353
18353
  });
18354
18354
  }
18355
- function nativeEnum(entries, params) {
18355
+ function nativeEnum(entries2, params) {
18356
18356
  return new ZodEnum({
18357
18357
  type: "enum",
18358
- entries,
18358
+ entries: entries2,
18359
18359
  ...util_exports.normalizeParams(params)
18360
18360
  });
18361
18361
  }
@@ -19952,9 +19952,17 @@ var policyRule = external_exports.object({
19952
19952
  made_by: external_exports.string().min(1).max(120).optional().describe("Who made it by answering an ask with Always (ADR 0195). Filled in by Chips."),
19953
19953
  made_at: isoTimestamp.optional().describe("When a person's answer made it (ADR 0195): Always, or This session. Filled in by Chips. A rule a person's answer made never allows an action that matters.")
19954
19954
  }).describe("A rule the policy engine evaluates.");
19955
+ var policyHold = external_exports.object({
19956
+ until: isoTimestamp.optional().describe("When its asks come back. Absent: when a person turns them back on."),
19957
+ matters: external_exports.boolean().optional().describe("Whether the yes covers asks that matter too: money, a message outside the workspace, anything that can't be undone. Absent or false, those still wait for a person."),
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
+ at: isoTimestamp.optional().describe("When they were turned off. Filled in by Chips.")
19960
+ }).describe("A harness's asks turned off: Chips says yes for it until `until`.");
19955
19961
  var policy = external_exports.object({
19956
19962
  autonomy: autonomyLevel,
19957
- rules: external_exports.array(policyRule).max(200).describe("Evaluated in order; the workspace cap always wins.")
19963
+ rules: external_exports.array(policyRule).max(200).describe("Evaluated in order; the workspace cap always wins."),
19964
+ 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.")
19958
19966
  }).describe("A harness's autonomy level and the rules that fill in the details.");
19959
19967
  var cost = external_exports.object({
19960
19968
  usd: external_exports.number().nonnegative().describe("An estimate, in US dollars."),
@@ -20676,6 +20684,7 @@ var roomNote = external_exports.object({
20676
20684
  members: external_exports.array(roomMember).max(500).describe("The room's people, then its agents, each by name, anybody removed left out."),
20677
20685
  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."),
20678
20686
  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."),
20687
+ about_message: external_exports.record(external_exports.string().max(120), external_exports.string().max(4e3)).optional().describe("What Chips says of this message to each who takes the turn, by their id: the words their note opens with when it has any. They say that the message is theirs though nothing @-mentions them, that it went to several agents or to all, that it comes to the lead as nobody's turn, that the agent it was for has not picked it up, or that it arrives late. A harness may say them beside the message and the note without them (`noteAndAbout`), as the SDK's `promptFor` does: on a session's first turn the note is far above the message. Absent when no taker's note says anything of the message."),
20679
20688
  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."),
20680
20689
  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
20690
  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.")
@@ -20687,6 +20696,13 @@ function noteWithoutRules(room, taker) {
20687
20696
  return note;
20688
20697
  return note.slice(0, note.length - rules.length).trimEnd();
20689
20698
  }
20699
+ function noteAndAbout(note, room, taker) {
20700
+ const about = room?.about_message?.[taker];
20701
+ if (note === void 0 || about === void 0 || about === "" || !note.startsWith(about)) {
20702
+ return { note, about: void 0 };
20703
+ }
20704
+ return { note: note.slice(about.length).trimStart(), about };
20705
+ }
20690
20706
  var MONTHS = [
20691
20707
  "January",
20692
20708
  "February",
@@ -21151,6 +21167,7 @@ var approvalResolved = defineEvent({
21151
21167
  approval_id: id("approval"),
21152
21168
  decision: external_exports.enum(["approved", "edited", "denied", "expired"]).describe("`expired` means nobody answered and the fallback applied."),
21153
21169
  scope: external_exports.enum(["once", "session", "always"]).default("once").describe("How far the answer reaches. `always` becomes a policy rule."),
21170
+ keeps: external_exports.literal("harness").optional().describe("With `always`: the harness keeps it as its own always, since its Chips's rules are off (ADR 0300), and Chips writes no rule. Filled in by Chips."),
21154
21171
  everywhere: external_exports.boolean().optional().describe("With `always`: the rule is the harness's in every space, not only this one (ADR 0239). An owner or an admin only."),
21155
21172
  for_minutes: external_exports.number().int().min(5).max(240).optional().describe("With `once` and a yes: for this many minutes, everything the asking agent asks in this space goes ahead without a card (ADR 0239, addendum of 6 November 2026; ADR 0281), commands Chips can't read too. An ask that matters still waits for a person. Chips keeps the rule, so the harness is answered once."),
21156
21173
  until_stopped: external_exports.literal(true).optional().describe("With `once` and a yes, instead of `for_minutes`: everything the asking agent asks in this space goes ahead without a card until a person stops it (`approval.held_stopped`, ADR 0281). An ask that matters still waits for a person. Chips keeps the rule, so the harness is answered once."),
@@ -22452,6 +22469,19 @@ var exchangeLimitsSet = defineEvent({
22452
22469
  circles: external_exports.boolean().describe("Whether agents going in circles (the same two or three taking turns and saying again what they said) are told to stop then, whatever the count.")
22453
22470
  })
22454
22471
  });
22472
+ var policyWorkspaceUpdated = defineEvent({
22473
+ type: "policy.workspace_updated",
22474
+ direction: "workspace",
22475
+ sender: "person",
22476
+ summary: "An owner or an admin set the rules for every harness, or turned every harness's asks off for a while (ADR 0299).",
22477
+ requiresRun: false,
22478
+ payload: external_exports.object({
22479
+ rules: external_exports.array(policyRule).max(200).describe("Read before any harness's own, in order. Each rule a person adds is kept with who made it and when."),
22480
+ hold: policyHold.nullable().optional().describe("Every harness's asks turned off. `null` turns them back on; absent leaves it as it was."),
22481
+ workspace_max_autonomy: autonomyLevel.describe("The workspace cap as it stands, which this doesn't change. Filled in by Chips."),
22482
+ changed_by: external_exports.string().min(1).max(120).describe("Who changed them. Filled in by Chips from the credential that sent it.")
22483
+ })
22484
+ });
22455
22485
  var workspaceRenamed = defineEvent({
22456
22486
  type: "workspace.renamed",
22457
22487
  direction: "workspace",
@@ -22521,7 +22551,8 @@ var WORKSPACE_EVENTS = [
22521
22551
  attachmentLimitsSet,
22522
22552
  exchangeLimitsSet,
22523
22553
  workspaceRenamed,
22524
- relaySet
22554
+ relaySet,
22555
+ policyWorkspaceUpdated
22525
22556
  ];
22526
22557
 
22527
22558
  // node_modules/@chipschat/protocol/dist/src/events/catalogue.js
@@ -22959,6 +22990,36 @@ var notificationSettings = external_exports.object({
22959
22990
  spaces: external_exports.record(external_exports.string().min(1).max(120), spaceNotifications).optional()
22960
22991
  });
22961
22992
 
22993
+ // node_modules/@chipschat/protocol/dist/src/own-rules.js
22994
+ var OWN_RULES_MAX = 200;
22995
+ var OWN_KINDS = ["read", "write", "web", "command", "tool"];
22996
+ var ownKind = external_exports.enum(OWN_KINDS);
22997
+ var ownEntry = external_exports.object({
22998
+ kind: ownKind.describe("What it lets through: reading files, writing them, the web, commands, or another tool."),
22999
+ name: external_exports.string().min(1).max(120).describe("The tool or program as the harness names it: `Read`, `WebFetch`, `git`."),
23000
+ words: external_exports.array(external_exports.string().min(1).max(120)).max(8).optional().describe('For a command: the words every command it lets through starts with, `["git"]`. Absent on a command entry: any command.'),
23001
+ raw: external_exports.string().min(1).max(400).optional().describe("The entry as its settings write it: `Bash(git:*)`.")
23002
+ }).describe("One thing a harness's own settings let through, ask about, or refuse.");
23003
+ var entries = external_exports.array(ownEntry).max(OWN_RULES_MAX);
23004
+ var ownRules = external_exports.object({
23005
+ 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
+ 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
+ mode: external_exports.string().min(1).max(80).optional().describe("The mode its sessions run in, as the harness names it: `Default`."),
23008
+ everything: external_exports.boolean().optional().describe("It runs everything without asking, so nothing it does reaches Chips as an ask."),
23009
+ runs: entries.describe("What it runs without asking."),
23010
+ asks: entries.optional().describe("What it always asks about, whatever else it lets through."),
23011
+ refuses: entries.optional().describe("What it never does."),
23012
+ ask_line: external_exports.object({
23013
+ entry: external_exports.string().min(1).max(200).describe("One entry that asks, with `{words}` where a command's start goes."),
23014
+ line: external_exports.string().min(1).max(300).describe("The line those entries go in, with `{entries}` where they go, comma-separated."),
23015
+ where: external_exports.string().min(1).max(300).describe("Where the line goes, in words.")
23016
+ }).optional().describe("How to make a command ask in its own settings, for the page's Copy.")
23017
+ }).describe("What a harness's own settings let through, in its own terms (ADR 0299).");
23018
+ var ownRulesRead = external_exports.object({
23019
+ own_rules: ownRules.nullable().describe("The latest copy; `null` before the harness sent one."),
23020
+ heard_at: isoTimestamp.nullable().describe("When Chips heard it.")
23021
+ }).describe("What a harness last said it runs on its own.");
23022
+
22962
23023
  // node_modules/@chipschat/protocol/dist/src/pages.js
22963
23024
  var HTML_POLICY = "default-src 'none'; img-src data: blob:; font-src data:; media-src data: blob:; style-src 'unsafe-inline'; script-src 'unsafe-inline'";
22964
23025
  var PAGE_SANDBOX = "allow-scripts allow-popups allow-popups-to-escape-sandbox";
@@ -24024,6 +24085,7 @@ var Run = class {
24024
24085
  decision: event.decision,
24025
24086
  allowed: event.decision === "approved" || event.decision === "edited",
24026
24087
  scope: event.scope ?? "once",
24088
+ ...event.keeps === "harness" ? { keeps: "harness" } : {},
24027
24089
  input: event.decision === "edited" ? event.updated_input : input2.action.input,
24028
24090
  reason: event.reason,
24029
24091
  by: event.resolved_by,
@@ -24176,7 +24238,8 @@ var PATHS = {
24176
24238
  model: (id2) => `/v1/agents/${encodeURIComponent(id2)}/model`,
24177
24239
  heartbeat: (id2) => `/v1/agents/${encodeURIComponent(id2)}/heartbeat`,
24178
24240
  "context-window": (id2) => `/v1/agents/${encodeURIComponent(id2)}/context-window`,
24179
- jobs: (id2) => `/v1/harnesses/${encodeURIComponent(id2)}/jobs`
24241
+ jobs: (id2) => `/v1/harnesses/${encodeURIComponent(id2)}/jobs`,
24242
+ "own-rules": (id2) => `/v1/harnesses/${encodeURIComponent(id2)}/own-rules`
24180
24243
  };
24181
24244
  var FRAMES = {
24182
24245
  "context.edit": contextEditFrame,
@@ -24226,6 +24289,15 @@ var Settings = class {
24226
24289
  jobs(copy) {
24227
24290
  return this.send("jobs", this.harnessId(), copy, {});
24228
24291
  }
24292
+ /**
24293
+ * What the harness's own settings let through without asking (ADR 0299): where it read them, the
24294
+ * mode it runs in, and each entry. Chips decides nothing from it; a person reads it on the
24295
+ * harness's Permissions page. Send it when connected and whenever the settings are read again;
24296
+ * a copy the same as the last is not sent again. An older Chips has no such page and refuses it.
24297
+ */
24298
+ ownRules(copy) {
24299
+ return this.send("own-rules", this.harnessId(), copy, {});
24300
+ }
24229
24301
  /**
24230
24302
  * Runs of its jobs the harness finished (`jobs`), two hundred to a post. A run sent again says
24231
24303
  * what it says over the one before, and what it leaves out stays, so send it once more when its
@@ -25640,10 +25712,10 @@ function keptAtAny(store, accounts) {
25640
25712
  }
25641
25713
  return void 0;
25642
25714
  }
25643
- function rehomed(store, account, joined2, env2) {
25644
- const here2 = hereInstead(joined2.url, env2);
25645
- if (here2 === void 0 || here2 === joined2.url)
25646
- return joined2;
25715
+ function rehomed(store, account, joined3, env2) {
25716
+ const here2 = hereInstead(joined3.url, env2);
25717
+ if (here2 === void 0 || here2 === joined3.url)
25718
+ return joined3;
25647
25719
  if (store !== false) {
25648
25720
  try {
25649
25721
  const record2 = JSON.parse(store.get(account) ?? "{}");
@@ -25651,7 +25723,7 @@ function rehomed(store, account, joined2, env2) {
25651
25723
  } catch {
25652
25724
  }
25653
25725
  }
25654
- return { ...joined2, url: here2 };
25726
+ return { ...joined3, url: here2 };
25655
25727
  }
25656
25728
  function keptAt(store, account) {
25657
25729
  if (store === false)
@@ -25768,10 +25840,10 @@ async function join3(options) {
25768
25840
  throw error62;
25769
25841
  }
25770
25842
  const answered = joinedOf(answer);
25771
- const joined2 = { ...answered, url: hereInstead(answered.url, env2) ?? answered.url };
25843
+ const joined3 = { ...answered, url: hereInstead(answered.url, env2) ?? answered.url };
25772
25844
  if (store !== false)
25773
- keepTheKey(store, account, { ...joined2, from, hello: "due" });
25774
- return joined2;
25845
+ keepTheKey(store, account, { ...joined3, from, hello: "due" });
25846
+ return joined3;
25775
25847
  }
25776
25848
  function keepTheKey(store, account, record2) {
25777
25849
  try {
@@ -25782,12 +25854,12 @@ function keepTheKey(store, account, record2) {
25782
25854
  `);
25783
25855
  }
25784
25856
  }
25785
- async function helloOnce(joined2, options) {
25786
- const { spaceId } = joined2;
25857
+ async function helloOnce(joined3, options) {
25858
+ const { spaceId } = joined3;
25787
25859
  if (spaceId === void 0)
25788
25860
  return false;
25789
25861
  const store = options.keep ?? openKeyStore(options.env ?? process.env);
25790
- const account = accountOf(joined2.url, options.name);
25862
+ const account = accountOf(joined3.url, options.name);
25791
25863
  let record2;
25792
25864
  try {
25793
25865
  const kept2 = store === false ? void 0 : store.get(account);
@@ -25795,7 +25867,7 @@ async function helloOnce(joined2, options) {
25795
25867
  } catch {
25796
25868
  record2 = void 0;
25797
25869
  }
25798
- const due = store === false || record2?.["hello"] === "due" && record2["token"] === joined2.token;
25870
+ const due = store === false || record2?.["hello"] === "due" && record2["token"] === joined3.token;
25799
25871
  if (!due)
25800
25872
  return false;
25801
25873
  await options.say(spaceId);
@@ -25981,8 +26053,21 @@ function beforeOf(message, options, taker) {
25981
26053
  function waitedWords(count) {
25982
26054
  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.`;
25983
26055
  }
26056
+ function forWords(message, taker) {
26057
+ if (taker === void 0 || !othersBeside(message, taker))
26058
+ return "";
26059
+ const members2 = message.room?.members ?? [];
26060
+ const to = (message.addressed_to ?? []).flatMap((id2) => {
26061
+ const member = members2.find((each) => each.participant_id === id2);
26062
+ return member === void 0 ? [] : [{ id: id2, name: member.name }];
26063
+ });
26064
+ if (to.length === 0)
26065
+ return "";
26066
+ const others = to.filter((each) => each.id !== taker).map((each) => each.name);
26067
+ return `, to ${namesInWords(others.length === to.length ? others : ["you", ...others])}`;
26068
+ }
25984
26069
  function saidOf(message, options, taker) {
25985
- const who2 = options.sayWho === false ? "" : `${withRole(message.from.display_name, message.from)}: `;
26070
+ const who2 = options.sayWho === false ? "" : `${withRole(message.from.display_name, message.from)}${forWords(message, taker)}: `;
25986
26071
  const files = (message.attachments ?? []).map(renderAttachment);
25987
26072
  const replying = renderReplyingTo(message.replying_to, {
25988
26073
  sender: {
@@ -26015,7 +26100,8 @@ function promptFor(message, options = {}) {
26015
26100
  const held = options.rulesHeld === true;
26016
26101
  const earlier = options.earlier ?? [];
26017
26102
  const notes = message.room?.notes ?? {};
26018
- const note = taker === void 0 ? void 0 : held ? noteWithoutRules(message.room, taker) : notes[taker];
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);
26019
26105
  const sending = options.sendsFiles === true && !held ? sendingFiles({ project: options.project !== void 0 }) : void 0;
26020
26106
  const project = options.project === void 0 ? void 0 : held ? renderProjectFacts(options.project) : renderProjectNote(options.project, { othersInRoom: othersBeside(message, taker) });
26021
26107
  return [
@@ -26030,6 +26116,7 @@ function promptFor(message, options = {}) {
26030
26116
  renderContext(contextOf(message, options), { taker }),
26031
26117
  earlier.length === 0 ? void 0 : waitedWords(earlier.length + 1),
26032
26118
  ...earlier.flatMap((each) => saidOf(each, options, taker)),
26119
+ about,
26033
26120
  ...saidOf(message, options, taker),
26034
26121
  sinceOf(options)
26035
26122
  ].filter((part) => part !== void 0 && part !== "").join("\n\n");
@@ -26998,7 +27085,7 @@ function forgetAdapter(id2, home = homedir5()) {
26998
27085
  import { randomBytes } from "node:crypto";
26999
27086
  import { existsSync as existsSync8 } from "node:fs";
27000
27087
  import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
27001
- import { homedir as homedir6 } from "node:os";
27088
+ import { homedir as homedir7 } from "node:os";
27002
27089
  import { join as join10 } from "node:path";
27003
27090
 
27004
27091
  // src/claude-settings.ts
@@ -27382,6 +27469,147 @@ function keepHeard(since, heard) {
27382
27469
  if (since.length > CONTEXT_BUDGET.lines) since.shift();
27383
27470
  }
27384
27471
 
27472
+ // src/own-rules.ts
27473
+ import { homedir as homedir6 } from "node:os";
27474
+ var MOST = 200;
27475
+ var MOST_PLACES = 8;
27476
+ var LONGEST_NAME = 120;
27477
+ var LONGEST_RAW = 400;
27478
+ var READS = /* @__PURE__ */ new Set(["Read", "Glob", "Grep", "LS", "NotebookRead"]);
27479
+ var WRITES = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
27480
+ var WEB = /* @__PURE__ */ new Set(["WebFetch", "WebSearch"]);
27481
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
27482
+ var clip = (text, most) => text.length > most ? text.slice(0, most) : text;
27483
+ function bashWords(inner) {
27484
+ if (inner === void 0) return void 0;
27485
+ const pattern = inner.trim().replace(/:\*$/, "").replace(/\s+\*$/, "");
27486
+ if (pattern === "" || pattern === "*") return void 0;
27487
+ const words4 = pattern.split(/\s+/).map((word) => clip(word, LONGEST_NAME));
27488
+ return words4.slice(0, 8);
27489
+ }
27490
+ function claudeEntry(rule) {
27491
+ const said = /^\s*([^()\s]+)\s*(?:\((.*)\))?\s*$/s.exec(rule);
27492
+ const name = said?.[1];
27493
+ if (name === void 0) return void 0;
27494
+ const raw = clip(rule.trim(), LONGEST_RAW);
27495
+ const tool = clip(name, LONGEST_NAME);
27496
+ if (name === "Bash") {
27497
+ const words4 = bashWords(said?.[2]);
27498
+ return { kind: "command", name: tool, ...words4 === void 0 ? {} : { words: words4 }, raw };
27499
+ }
27500
+ const kind2 = READS.has(name) ? "read" : WRITES.has(name) ? "write" : WEB.has(name) ? "web" : "tool";
27501
+ return { kind: kind2, name: tool, raw };
27502
+ }
27503
+ function joined(layers, list) {
27504
+ const seen = /* @__PURE__ */ new Set();
27505
+ const entries2 = [];
27506
+ for (const layer of layers) {
27507
+ const permissions = layer["permissions"];
27508
+ const rules = isRecord2(permissions) ? permissions[list] : void 0;
27509
+ if (!Array.isArray(rules)) continue;
27510
+ for (const rule of rules) {
27511
+ if (typeof rule !== "string" || seen.has(rule.trim())) continue;
27512
+ seen.add(rule.trim());
27513
+ const entry = claudeEntry(rule);
27514
+ if (entry !== void 0) entries2.push(entry);
27515
+ }
27516
+ }
27517
+ return entries2.slice(0, MOST);
27518
+ }
27519
+ function ownDefaultMode(layer) {
27520
+ const permissions = layer?.["permissions"];
27521
+ const mode = isRecord2(permissions) ? permissions["defaultMode"] : void 0;
27522
+ return typeof mode === "string" && mode !== "" ? mode : void 0;
27523
+ }
27524
+ var CLAUDE_MODES = {
27525
+ default: "Default",
27526
+ acceptEdits: "Accept edits",
27527
+ plan: "Plan",
27528
+ bypassPermissions: "Bypass permissions",
27529
+ dontAsk: "Don't ask",
27530
+ auto: "Auto"
27531
+ };
27532
+ function claudeModeName(mode) {
27533
+ return CLAUDE_MODES[mode] ?? mode;
27534
+ }
27535
+ function tilde(path, home = homedir6()) {
27536
+ return path === home ? "~" : path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
27537
+ }
27538
+ function claudeOwnRules(options) {
27539
+ const home = options.home ?? homedir6();
27540
+ const layers = [...options.user === void 0 ? [] : [options.user], ...options.folders.map((each) => each.layer)];
27541
+ const userPlace = tilde(options.userPath, home);
27542
+ const read_from = [userPlace, ...options.folders.map((each) => tilde(each.path, home))].slice(0, MOST_PLACES);
27543
+ const own2 = ownDefaultMode(options.user);
27544
+ const notes = [
27545
+ "Your own Claude Code reads the same file, so a change there changes both.",
27546
+ own2 !== void 0 && own2 !== options.mode ? `Your own Claude Code runs in ${claudeModeName(own2)} mode; Chips puts each session in ${claudeModeName(options.mode)}.` : void 0
27547
+ ].filter((note) => note !== void 0);
27548
+ const ask_line = {
27549
+ entry: '"Bash({words}:*)"',
27550
+ line: '"ask": [{entries}]',
27551
+ where: `\`permissions\` in \`${userPlace}\``
27552
+ };
27553
+ if (options.mode === "bypassPermissions") {
27554
+ return { read_from, note: notes.join(" "), mode: claudeModeName(options.mode), everything: true, runs: [] };
27555
+ }
27556
+ const allowed = joined(layers, "allow");
27557
+ const edits = options.mode === "acceptEdits" ? ["Edit", "Write", "MultiEdit"].filter((name) => !allowed.some((entry) => entry.name === name)).map((name) => ({ kind: "write", name, raw: "acceptEdits" })) : [];
27558
+ return {
27559
+ read_from,
27560
+ note: notes.join(" "),
27561
+ mode: claudeModeName(options.mode),
27562
+ runs: [...allowed, ...edits].slice(0, MOST),
27563
+ asks: joined(layers, "ask"),
27564
+ refuses: joined(layers, "deny"),
27565
+ ask_line
27566
+ };
27567
+ }
27568
+ var CODEX_MODES = {
27569
+ "read-only": "Read only",
27570
+ "workspace-write": "Workspace write",
27571
+ auto: "Auto",
27572
+ "full-access": "Full access",
27573
+ "danger-full-access": "Full access"
27574
+ };
27575
+ function codexOwnRules(mode) {
27576
+ const read_from = ["the mode Chips starts each Codex session in"];
27577
+ const name = CODEX_MODES[mode] ?? mode;
27578
+ if (mode === "full-access" || mode === "danger-full-access") {
27579
+ return {
27580
+ read_from,
27581
+ mode: name,
27582
+ everything: true,
27583
+ note: "Codex runs with full access, so it never asks.",
27584
+ runs: []
27585
+ };
27586
+ }
27587
+ if (mode === "read-only") {
27588
+ return {
27589
+ read_from,
27590
+ mode: name,
27591
+ note: "Codex reads on its own and asks before it changes a file or runs anything else.",
27592
+ runs: []
27593
+ };
27594
+ }
27595
+ return {
27596
+ read_from,
27597
+ mode: name,
27598
+ note: "Codex edits files and runs commands inside the agent's folder in its own sandbox, and asks before the network or anything outside that folder.",
27599
+ runs: []
27600
+ };
27601
+ }
27602
+ async function sendOwnRules(settings, copy) {
27603
+ const send = settings?.ownRules;
27604
+ if (typeof send !== "function") return false;
27605
+ try {
27606
+ await send.call(settings, copy);
27607
+ return true;
27608
+ } catch {
27609
+ return false;
27610
+ }
27611
+ }
27612
+
27385
27613
  // src/models.ts
27386
27614
  var SETTINGS_LEVEL = "default";
27387
27615
  var LEVEL_WORDS = { xhigh: "Extra high" };
@@ -27592,7 +27820,7 @@ var Bridge = class {
27592
27820
  this.knew = resolve5;
27593
27821
  });
27594
27822
  this.env = options.env ?? adapterEnv(options.kind, { ...process.env, ...options.kind.env });
27595
- this.places = placesOf2(this.env, options.home ?? homedir6());
27823
+ this.places = placesOf2(this.env, options.home ?? homedir7());
27596
27824
  this.knownKind = knownIdOf(options.kind);
27597
27825
  this.files = this.knownKind === void 0 ? void 0 : new ContextFiles(this.knownKind, options.kind, this.places, codexDocBytes(this.env));
27598
27826
  }
@@ -27657,6 +27885,7 @@ var Bridge = class {
27657
27885
  await this.know(await chips2.agents.list(), { forget: true });
27658
27886
  this.knew();
27659
27887
  await this.sendContexts();
27888
+ await this.sendOwnRules();
27660
27889
  for (const record2 of this.records()) await this.sendWindow(record2);
27661
27890
  await this.sendModels();
27662
27891
  await this.run();
@@ -28294,14 +28523,14 @@ var Bridge = class {
28294
28523
  project
28295
28524
  };
28296
28525
  const rules = rulesFor(message, asked);
28297
- const joined2 = `${speakerId ?? record2.agentId}|${spaceId}`;
28526
+ const joined3 = `${speakerId ?? record2.agentId}|${spaceId}`;
28298
28527
  let words4 = promptFor(message, {
28299
28528
  ...asked,
28300
28529
  rulesHeld: this.rules.holds(sessionId, rules),
28301
28530
  earlier,
28302
28531
  since,
28303
28532
  answered: room.answered,
28304
- before: this.caughtUp.get(joined2),
28533
+ before: this.caughtUp.get(joined3),
28305
28534
  heldPost: room.heldPost
28306
28535
  });
28307
28536
  const files = [];
@@ -28329,7 +28558,7 @@ ${files.join("\n")}`;
28329
28558
  turn.prompting = false;
28330
28559
  if (prompt === words4) {
28331
28560
  keepAnswered(room.answered, [...earlier, message]);
28332
- this.caughtUp.delete(joined2);
28561
+ this.caughtUp.delete(joined3);
28333
28562
  room.heldPost = void 0;
28334
28563
  }
28335
28564
  if (turn.cancelled) return;
@@ -28656,8 +28885,8 @@ ${files.join("\n")}`;
28656
28885
  }).catch(() => void 0);
28657
28886
  }
28658
28887
  async planned(turn, update) {
28659
- const entries = Array.isArray(update["entries"]) ? update["entries"] : [];
28660
- const steps = entries.filter((entry) => entry["status"] !== "completed").slice(0, 20).map((entry, index) => ({ stepId: `plan-${index + 1}`, title: String(entry["content"] ?? "").slice(0, 300) })).filter((step) => step.title !== "");
28888
+ const entries2 = Array.isArray(update["entries"]) ? update["entries"] : [];
28889
+ const steps = entries2.filter((entry) => entry["status"] !== "completed").slice(0, 20).map((entry, index) => ({ stepId: `plan-${index + 1}`, title: String(entry["content"] ?? "").slice(0, 300) })).filter((step) => step.title !== "");
28661
28890
  if (steps.length > 0) await turn.run.plan(steps).catch(() => void 0);
28662
28891
  }
28663
28892
  // ------------------------------------------------------------------ what the agents read (Chips ADRs 0134, 0238)
@@ -28668,8 +28897,36 @@ ${files.join("\n")}`;
28668
28897
  /** The agents came or went: the copies sent again where they changed (Chips takes the same copy once). */
28669
28898
  agentsChanged() {
28670
28899
  if (this.files !== void 0) void this.sendContexts();
28900
+ void this.sendOwnRules();
28671
28901
  void this.sendModels();
28672
28902
  }
28903
+ /**
28904
+ * What its own settings let through without asking (Chips ADR 0299), read again with the agents'
28905
+ * folders: Claude Code's lists, Codex's mode. Chips takes the same copy once; an older Chips, or
28906
+ * an SDK before 1.0.10, takes none, and nothing else changes.
28907
+ */
28908
+ async sendOwnRules() {
28909
+ const copy = this.ownRules();
28910
+ if (copy !== void 0) await sendOwnRules(this.options.chips.settings, copy);
28911
+ }
28912
+ ownRules() {
28913
+ if (this.knownKind === "codex") return codexOwnRules(this.options.kind.mode ?? "workspace-write");
28914
+ if (this.knownKind !== "claude-code") return void 0;
28915
+ const userPath = join10(this.places.claudeHome, "settings.json");
28916
+ const folders = [...new Set(this.records().map((record2) => record2.folder))].flatMap(
28917
+ (folder2) => [join10(folder2, ".claude", "settings.json"), join10(folder2, ".claude", "settings.local.json")].flatMap((path) => {
28918
+ const layer = readLayer(path);
28919
+ return layer === void 0 ? [] : [{ path, layer }];
28920
+ })
28921
+ );
28922
+ return claudeOwnRules({
28923
+ userPath,
28924
+ user: readLayer(userPath),
28925
+ folders,
28926
+ mode: this.options.kind.mode ?? "default",
28927
+ home: this.places.home
28928
+ });
28929
+ }
28673
28930
  /** The harness's own set and each agent's files, as they are on disk now. */
28674
28931
  async sendContexts() {
28675
28932
  const files = this.files;
@@ -29327,17 +29584,17 @@ function questionFor(title2, input2) {
29327
29584
  const fields = typeof input2 === "object" && input2 !== null ? input2 : {};
29328
29585
  const said = oneLine(fields["description"])?.replace(/[\s.?!:;,]+$/, "");
29329
29586
  if (said === void 0 || said === "") return `Allow it to ${lowerFirst(title2)}?`.slice(0, QUESTION_MAX);
29330
- const asked = `${clip(said, QUESTION_MAX - 1)}?`;
29587
+ const asked = `${clip2(said, QUESTION_MAX - 1)}?`;
29331
29588
  const command = oneLine(Array.isArray(fields["command"]) ? fields["command"].join(" ") : fields["command"]);
29332
29589
  const room = QUESTION_MAX - asked.length - 3;
29333
29590
  if (command === void 0 || command.includes("`") || room < 12) return asked;
29334
- return `${asked} \`${clip(command, room)}\``;
29591
+ return `${asked} \`${clip2(command, room)}\``;
29335
29592
  }
29336
29593
  function oneLine(value) {
29337
29594
  const line = typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "";
29338
29595
  return line === "" ? void 0 : line;
29339
29596
  }
29340
- function clip(text, max) {
29597
+ function clip2(text, max) {
29341
29598
  return text.length <= max ? text : `${text.slice(0, max - 1)}\u2026`;
29342
29599
  }
29343
29600
  function riskOf(kind2) {
@@ -29348,7 +29605,10 @@ function riskOf(kind2) {
29348
29605
  function optionFor(decision, options, command) {
29349
29606
  const find = (kind2) => options.find((option) => option.kind === kind2)?.optionId;
29350
29607
  if (!decision.allowed) return find("reject_once") ?? find("reject_always");
29351
- if (decision.scope === "always" && !command) return find("allow_always") ?? find("allow_once");
29608
+ const harnessKeeps = decision.keeps === "harness";
29609
+ if (decision.scope === "always" && (!command || harnessKeeps)) {
29610
+ return find("allow_always") ?? find("allow_once");
29611
+ }
29352
29612
  return find("allow_once") ?? find("allow_always");
29353
29613
  }
29354
29614
  function carriesCommand(input2) {
@@ -29435,7 +29695,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
29435
29695
 
29436
29696
  // src/move.ts
29437
29697
  import { lstatSync, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync9, renameSync as renameSync2, rmdirSync, writeFileSync as writeFileSync4 } from "node:fs";
29438
- import { homedir as homedir7 } from "node:os";
29698
+ import { homedir as homedir8 } from "node:os";
29439
29699
  import { basename as basename5, dirname as dirname6, join as join11, resolve as resolve4 } from "node:path";
29440
29700
  var there = (path) => {
29441
29701
  try {
@@ -29447,7 +29707,7 @@ var there = (path) => {
29447
29707
  };
29448
29708
  var isFolder = (path) => lstatSync(path).isDirectory();
29449
29709
  var shown = (path, home) => path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
29450
- function merge2(from, to, log2, home = homedir7(), quiet = false) {
29710
+ function merge2(from, to, log2, home = homedir8(), quiet = false) {
29451
29711
  if (!there(from)) return;
29452
29712
  try {
29453
29713
  if (!there(to)) {
@@ -29473,7 +29733,7 @@ function removeIfEmpty(path) {
29473
29733
  } catch {
29474
29734
  }
29475
29735
  }
29476
- function claudeStoreOf(folder2, env2, home = homedir7()) {
29736
+ function claudeStoreOf(folder2, env2, home = homedir8()) {
29477
29737
  const name = folder2.replace(/[^a-zA-Z0-9]/g, "-");
29478
29738
  if (name.length > 200) return void 0;
29479
29739
  return join11(env2["CLAUDE_CONFIG_DIR"] ? resolve4(fromHome(env2["CLAUDE_CONFIG_DIR"], home)) : join11(home, ".claude"), "projects", name);
@@ -29498,7 +29758,7 @@ var readJson = (path) => {
29498
29758
  return void 0;
29499
29759
  }
29500
29760
  };
29501
- function moveOld(configPath2, log2, home = homedir7(), env2 = process.env) {
29761
+ function moveOld(configPath2, log2, home = homedir8(), env2 = process.env) {
29502
29762
  const places = placesOf(home);
29503
29763
  const keptIn = join11(dirname6(configPath2), basename5(configPath2, ".json"));
29504
29764
  const name = inside2(places.settings, configPath2);
@@ -29615,7 +29875,7 @@ var refused2 = (error62) => {
29615
29875
  `);
29616
29876
  process.exit(1);
29617
29877
  };
29618
- var joined = await join3({
29878
+ var joined2 = await join3({
29619
29879
  link,
29620
29880
  url: process.env["CHIPS_URL"],
29621
29881
  name: kind.name,
@@ -29633,7 +29893,7 @@ var joined = await join3({
29633
29893
  ],
29634
29894
  onCode: (code) => log(`Allow this harness in Chips: ${code}`)
29635
29895
  }).catch(refused2);
29636
- keepIfAsked(LABEL, joined.url, ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CODEX_HOME", "CLAUDE_CONFIG_DIR"], log);
29896
+ keepIfAsked(LABEL, joined2.url, ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "CODEX_HOME", "CLAUDE_CONFIG_DIR"], log);
29637
29897
  var kept = existsSync10(statePath) ? JSON.parse(readFileSync10(statePath, "utf8")) : {};
29638
29898
  var state = {
29639
29899
  sessions: kept.sessions ?? {},
@@ -29650,8 +29910,8 @@ var waitingSaid = (why) => {
29650
29910
  };
29651
29911
  var bridge;
29652
29912
  var chips = await connect({
29653
- url: joined.url,
29654
- token: joined.token,
29913
+ url: joined2.url,
29914
+ token: joined2.token,
29655
29915
  client: { name: "chips-acp", version: VERSION },
29656
29916
  store: fileStore(join12(folder, "chips-state.json")),
29657
29917
  // The copy this machine keeps running starts at login, perhaps before its server is up: it waits
@@ -29685,7 +29945,7 @@ closing.push(() => bridge?.stop());
29685
29945
  await bridge.start();
29686
29946
  started = true;
29687
29947
  log(`connected as ${chips.harnessId} (${kind.name}), ${Object.keys(state.agents).length} agent(s)`);
29688
- await helloOnce(joined, {
29948
+ await helloOnce(joined2, {
29689
29949
  name: kind.name,
29690
29950
  say: (spaceId) => (
29691
29951
  // In the shape every bridge's hello has: "Hi, I'm …", then what to do (the onboarding audit, item 39).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
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.8",
37
- "@chipschat/harness": "1.0.8",
38
- "@chipschat/protocol": "1.0.8",
36
+ "@chipschat/conformance": "1.0.10",
37
+ "@chipschat/harness": "1.0.10",
38
+ "@chipschat/protocol": "1.0.10",
39
39
  "@types/node": "22.19.0",
40
40
  "esbuild": "0.27.7",
41
41
  "tsx": "4.21.0",