@chipschat/acp 1.0.17 → 1.0.18

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.17 carries these packages, bundled in. Each one's
3
+ `dist/main.js` in @chipschat/acp 1.0.18 carries these packages, bundled in. Each one's
4
4
  licence follows.
5
5
 
6
- ## @chipschat/harness 1.0.3 (Apache-2.0)
6
+ ## @chipschat/harness 1.0.4 (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.3 (Apache-2.0)
210
+ ## @chipschat/protocol 1.0.4 (Apache-2.0)
211
211
 
212
212
  Apache License
213
213
  Version 2.0, January 2004
package/dist/main.js CHANGED
@@ -24283,6 +24283,8 @@ function refusalOf(kind2, error62) {
24283
24283
  }
24284
24284
 
24285
24285
  // node_modules/@chipschat/harness/dist/connect.js
24286
+ var HELD_MOST = 2e4;
24287
+ var OF_THE_CONNECTION = /* @__PURE__ */ new Set(["hello", "state", "receipt"]);
24286
24288
  function agentOf(body) {
24287
24289
  return {
24288
24290
  agentId: String(body["agent_id"]),
@@ -24312,12 +24314,25 @@ var Chips = class _Chips {
24312
24314
  /** Makes each ping's `ts` its own, so two in one millisecond are still told apart. */
24313
24315
  pings = 0;
24314
24316
  /**
24315
- * Events held back, and why: one hold until the harness could attach a handler after connect,
24316
- * and one for each catch-up on asked rooms still reading, so that a room's first words heard
24317
- * live and read from its history are handed over once. Delivered in order when none is left.
24317
+ * Events held back, and why: one hold until the harness is listening, and one for each
24318
+ * catch-up on asked rooms still reading, so that a room's first words heard live and read from
24319
+ * its history are handed over once. Delivered in order when none is left.
24320
+ *
24321
+ * The first hold used to last one tick after `connect` resolved. Three bridges looked for git
24322
+ * and listed their agents before they attached a handler, so what `since` replayed was handed
24323
+ * to nobody, and the place in the log moved past it: a message sent while a bridge was down was
24324
+ * never answered (9 November 2026). An event nothing here could take is not heard. So the hold
24325
+ * lasts until something takes events: a handler, a waiter, a run, or a handler for rooms asked
24326
+ * (ADR 0289).
24318
24327
  */
24319
24328
  held = [];
24320
24329
  holds = 1;
24330
+ /** The handshake is done: `connect` has resolved. */
24331
+ started = false;
24332
+ /** Something here takes events (`listens`). */
24333
+ listening = false;
24334
+ /** The first hold is on its way out. */
24335
+ letting = false;
24321
24336
  askHandlers = new Emitter();
24322
24337
  asks = new Asks(() => this.me()?.harness_id, {
24323
24338
  listening: () => this.askHandlers.count("asked") > 0,
@@ -24359,7 +24374,8 @@ var Chips = class _Chips {
24359
24374
  const chips2 = new _Chips(options);
24360
24375
  await chips2.open(true);
24361
24376
  chips2.endOrphans();
24362
- setTimeout(() => chips2.release(), 0);
24377
+ chips2.started = true;
24378
+ chips2.letGo();
24363
24379
  return chips2;
24364
24380
  }
24365
24381
  get state() {
@@ -24457,8 +24473,17 @@ var Chips = class _Chips {
24457
24473
  get lastSeq() {
24458
24474
  return this.since;
24459
24475
  }
24476
+ /**
24477
+ * Hear events by name, or all of them as `event`. What `since` replayed, and what was said
24478
+ * since the connection opened, is handed over a tick after the first handler is attached:
24479
+ * attach every handler together, and all of them hear it. `hello`, `state` and `receipt` are
24480
+ * the connection's own, and attaching one of those alone starts nothing.
24481
+ */
24460
24482
  on(name, handler) {
24461
- return this.emitter.on(name, handler);
24483
+ const off = this.emitter.on(name, handler);
24484
+ if (!OF_THE_CONNECTION.has(name))
24485
+ this.listens();
24486
+ return off;
24462
24487
  }
24463
24488
  /** Say something in a space. */
24464
24489
  post(input2) {
@@ -24488,6 +24513,7 @@ var Chips = class _Chips {
24488
24513
  */
24489
24514
  onSpaceAsked(handler) {
24490
24515
  const off = this.askHandlers.on("asked", handler);
24516
+ this.listens();
24491
24517
  if (this.ready)
24492
24518
  void this.catchUp();
24493
24519
  return off;
@@ -24602,6 +24628,7 @@ var Chips = class _Chips {
24602
24628
  lanes: this.lanes
24603
24629
  }, laneId);
24604
24630
  this.activeRuns.set(runId, run2);
24631
+ this.listens();
24605
24632
  return run2;
24606
24633
  }
24607
24634
  /**
@@ -24702,6 +24729,7 @@ var Chips = class _Chips {
24702
24729
  }
24703
24730
  /** Resolve with the first event that matches, now or later. */
24704
24731
  waitFor(match) {
24732
+ this.listens();
24705
24733
  return new Promise((resolve5) => {
24706
24734
  this.waiters.add({ match, resolve: resolve5 });
24707
24735
  });
@@ -24925,6 +24953,21 @@ var Chips = class _Chips {
24925
24953
  return;
24926
24954
  }
24927
24955
  }
24956
+ /** Something here takes events from now on, so the first hold can go. */
24957
+ listens() {
24958
+ this.listening = true;
24959
+ this.letGo();
24960
+ }
24961
+ /**
24962
+ * Let the first hold go, once the handshake is done and the harness is listening: on the next
24963
+ * tick, so handlers attached together all hear what was held.
24964
+ */
24965
+ letGo() {
24966
+ if (!this.started || !this.listening || this.letting)
24967
+ return;
24968
+ this.letting = true;
24969
+ setTimeout(() => this.release(), 0);
24970
+ }
24928
24971
  /** Let one hold go; with none left, deliver what was held, in order. */
24929
24972
  release() {
24930
24973
  this.holds -= 1;
@@ -24938,6 +24981,8 @@ var Chips = class _Chips {
24938
24981
  onEvent(event) {
24939
24982
  if (this.holds > 0) {
24940
24983
  this.held.push(event);
24984
+ if (!this.listening && this.held.length > HELD_MOST)
24985
+ this.held.shift();
24941
24986
  return;
24942
24987
  }
24943
24988
  const seq = event["seq"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chipschat/acp",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
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.3",
37
- "@chipschat/harness": "1.0.3",
38
- "@chipschat/protocol": "1.0.3",
36
+ "@chipschat/conformance": "1.0.4",
37
+ "@chipschat/harness": "1.0.4",
38
+ "@chipschat/protocol": "1.0.4",
39
39
  "@types/node": "22.19.0",
40
40
  "esbuild": "0.27.7",
41
41
  "tsx": "4.21.0",