@snowyroad/arp 0.3.4 → 0.3.5

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.
Files changed (2) hide show
  1. package/dist/cli.js +15 -18
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -857,15 +857,15 @@ function isAddressed(content, agentName) {
857
857
  return false;
858
858
  }
859
859
  function classifyCatchUp(messages, agentName, nowMs, opts) {
860
- const mentions = messages.filter((m) => {
861
- if (m.seq <= opts.deliveredMaxSeq) return false;
860
+ const inWindow = messages.filter((m) => {
862
861
  const t = Date.parse(rawUntrusted(m.createdAt));
863
- const withinTtl = Number.isFinite(t) ? t >= nowMs - opts.ttlMs : true;
864
- if (!withinTtl) return false;
865
- return !sameText(m.senderName, agentName) && isAddressed(m.content, agentName);
862
+ return Number.isFinite(t) ? t >= nowMs - opts.ttlMs : true;
866
863
  });
864
+ const mentions = inWindow.filter(
865
+ (m) => !sameText(m.senderName, agentName) && isAddressed(m.content, agentName)
866
+ );
867
867
  const capped = mentions.slice(-opts.maxMentions);
868
- return { context: messages, mentions: capped };
868
+ return { context: inWindow, mentions: capped };
869
869
  }
870
870
 
871
871
  // src/relayClient.ts
@@ -883,7 +883,6 @@ var MAX_BACKFILL_CHARS_PER_CATCHUP = 2e6;
883
883
  var MAX_BACKFILL_CHARS_PER_CONNECTION = 8e6;
884
884
  var MAX_CONCURRENT_CATCHUPS = 3;
885
885
  var GAP_RESUME_MIN_INTERVAL_MS = 5e3;
886
- var REBUILD_LOOKBACK_SEQS = 100;
887
886
  function clampContent(s) {
888
887
  if (s.length <= MAX_MESSAGE_CONTENT_CHARS) return s;
889
888
  return `${s.slice(0, MAX_MESSAGE_CONTENT_CHARS)}
@@ -1123,10 +1122,10 @@ var RelayClient = class {
1123
1122
  }
1124
1123
  /** Run a catch-up with bounded concurrency (BRIDGE-12): at most
1125
1124
  * MAX_CONCURRENT_CATCHUPS paginated backfill loops in flight; extras queue FIFO. */
1126
- scheduleCatchUp(channelId, afterSeq, deliveredMaxSeq) {
1125
+ scheduleCatchUp(channelId, afterSeq) {
1127
1126
  const run = () => {
1128
1127
  this.activeCatchUps++;
1129
- void this.catchUp(channelId, afterSeq, deliveredMaxSeq).finally(() => {
1128
+ void this.catchUp(channelId, afterSeq).finally(() => {
1130
1129
  this.activeCatchUps--;
1131
1130
  const next = this.catchUpWaiters.shift();
1132
1131
  if (next) next();
@@ -1141,15 +1140,14 @@ var RelayClient = class {
1141
1140
  }
1142
1141
  /** Offline-rejoin catch-up: classify the missed window and hand it to onCatchUp once.
1143
1142
  * Does NOT route through emitInbound/onInbound to avoid per-message passive submits. */
1144
- async catchUp(channelId, afterSeq, deliveredMaxSeq) {
1143
+ async catchUp(channelId, afterSeq) {
1145
1144
  const missed = await this.fetchAfterSeq(channelId, afterSeq);
1146
1145
  if (missed.length === 0) return;
1147
1146
  for (const m of missed) if (m.id) this.markSeen(channelId, m.id);
1148
1147
  this.bumpCursor(channelId, missed[missed.length - 1].seq);
1149
1148
  const result = classifyCatchUp(missed, this.cfg.agentName, Date.now(), {
1150
1149
  ttlMs: this.cfg.catchUpTtlMs,
1151
- maxMentions: this.cfg.catchUpMaxMentions,
1152
- deliveredMaxSeq
1150
+ maxMentions: this.cfg.catchUpMaxMentions
1153
1151
  });
1154
1152
  this.catchUpCbs.forEach((cb) => cb(channelId, result));
1155
1153
  }
@@ -1293,11 +1291,10 @@ var RelayClient = class {
1293
1291
  for (const [ch, seqRaw] of Object.entries(resume)) {
1294
1292
  const seq = Number(seqRaw);
1295
1293
  if (Number.isFinite(seq) && seq > this.cursorOf(ch)) this.cursors.set(ch, seq);
1296
- const deliveredMax = this.cursorOf(ch);
1297
- if (!this.caughtUp.has(ch) && deliveredMax > 0) {
1294
+ const floor = this.cursorOf(ch);
1295
+ if (!this.caughtUp.has(ch) && floor > 0) {
1298
1296
  this.caughtUp.add(ch);
1299
- const rebuildFloor = Math.max(0, deliveredMax - REBUILD_LOOKBACK_SEQS);
1300
- this.scheduleCatchUp(ch, rebuildFloor, deliveredMax);
1297
+ this.scheduleCatchUp(ch, floor);
1301
1298
  }
1302
1299
  }
1303
1300
  }
@@ -1801,8 +1798,8 @@ ${fence("channel message", msg.content)}
1801
1798
  this.beacon?.begin();
1802
1799
  try {
1803
1800
  await this.session.converseLocal(capPrompt(
1804
- this.promptHead() + `You just (re)connected to ARP channel ${this.channelId}. Here is recent channel history for context \u2014 you may have already seen some of it. Absorb it so you can follow back-references in later messages; do NOT reply to it:
1805
- ` + fence("recent channel history", transcript)
1801
+ this.promptHead() + `You just reconnected to ARP channel ${this.channelId} after being away. Here is what you missed (context only, do NOT reply to it):
1802
+ ` + fence("missed channel messages", transcript)
1806
1803
  ));
1807
1804
  } finally {
1808
1805
  this.beacon?.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowyroad/arp",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Connect your own coding agent (Claude Code, Codex, Gemini, Grok) to an Agent Relay Protocol channel and collaborate with other agents and humans.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "SnowyRoad",