zooid 0.7.2 → 0.7.4

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.
@@ -23352,7 +23352,11 @@ function acpUpdateToAgentEvent(notif) {
23352
23352
  return {
23353
23353
  type: "agent_message_chunk",
23354
23354
  sessionId,
23355
- content: update.content
23355
+ content: update.content,
23356
+ // `messageId` is not part of the ACP `agent_message_chunk` schema, but
23357
+ // opencode includes it. Forward it so transports can split on message
23358
+ // boundaries; harmlessly undefined for agents that omit it.
23359
+ messageId: update.messageId
23356
23360
  };
23357
23361
  case "tool_call":
23358
23362
  return {
@@ -24890,7 +24894,8 @@ var MatrixClient = class {
24890
24894
  if (r.ok) return;
24891
24895
  if (r.status === 403) {
24892
24896
  const body = await r.text();
24893
- if (/already (in the room|invited|a member|joined)/i.test(body)) return;
24897
+ const idempotent = /already (in the room|invited|a member|joined)/i.test(body) || /user that is joined/i.test(body);
24898
+ if (idempotent) return;
24894
24899
  throw new Error(`invite(${opts.targetUserId}) failed: 403 ${body}`);
24895
24900
  }
24896
24901
  throw new Error(`invite(${opts.targetUserId}) failed: ${r.status}`);
@@ -25575,7 +25580,7 @@ function toMatrixHtml(markdown) {
25575
25580
  var STARTUP_GRACE_MS = 5e3;
25576
25581
  var SEEN_EVENT_CAP = 5e3;
25577
25582
  var DRAIN_QUIET_MS = 300;
25578
- var DRAIN_MAX_MS = 3e3;
25583
+ var DRAIN_MAX_MS = 3e4;
25579
25584
  var delay = (ms) => new Promise((r) => setTimeout(r, ms));
25580
25585
  function inboundThreadRoot2(evt) {
25581
25586
  const r = evt.content?.["m.relates_to"];
@@ -25588,6 +25593,7 @@ function createMatrixTransport(opts) {
25588
25593
  const pool = new BotPool(client, bindings);
25589
25594
  const sessions = /* @__PURE__ */ new Map();
25590
25595
  const buffers = /* @__PURE__ */ new Map();
25596
+ const bufferMessageIds = /* @__PURE__ */ new Map();
25591
25597
  const sendQueue = /* @__PURE__ */ new Map();
25592
25598
  const threadStates = /* @__PURE__ */ new Map();
25593
25599
  const cutoffTs = Date.now() - STARTUP_GRACE_MS;
@@ -25602,8 +25608,13 @@ function createMatrixTransport(opts) {
25602
25608
  const block = event.content;
25603
25609
  if (block.type === "text" && typeof block.text === "string") {
25604
25610
  const current = buffers.get(event.sessionId) ?? "";
25605
- const prefix = block.text === "" && current.length > 0 ? "\n\n" : "";
25611
+ const prevMessageId = bufferMessageIds.get(event.sessionId);
25612
+ const messageChanged = event.messageId !== void 0 && prevMessageId !== void 0 && event.messageId !== prevMessageId;
25613
+ const needsBreak = current.length > 0 && (block.text === "" || messageChanged);
25614
+ const prefix = needsBreak ? "\n\n" : "";
25606
25615
  buffers.set(event.sessionId, current + prefix + block.text);
25616
+ if (event.messageId !== void 0)
25617
+ bufferMessageIds.set(event.sessionId, event.messageId);
25607
25618
  } else {
25608
25619
  console.warn(`[matrix:${name}] dropped chunk block type=${block.type}`, block);
25609
25620
  }
@@ -25846,6 +25857,7 @@ function createMatrixTransport(opts) {
25846
25857
  const sessionId = await agents.ensureSession(agent.name, sessionKey, evt.room_id);
25847
25858
  sessions.set(sessionId, { agent, roomId: evt.room_id, threadRoot });
25848
25859
  buffers.set(sessionId, "");
25860
+ bufferMessageIds.delete(sessionId);
25849
25861
  const roomId = evt.room_id;
25850
25862
  const TYPING_TTL_MS = 3e4;
25851
25863
  const TYPING_REFRESH_MS = 25e3;
@@ -25871,7 +25883,7 @@ function createMatrixTransport(opts) {
25871
25883
  while (drainQuietMs > 0 && Date.now() - drainStart < drainMaxMs) {
25872
25884
  await delay(drainQuietMs);
25873
25885
  const next = buffers.get(sessionId) ?? "";
25874
- if (next === drained) break;
25886
+ if (next === drained && next.length > 0) break;
25875
25887
  drained = next;
25876
25888
  }
25877
25889
  const text = buffers.get(sessionId) ?? "";
@@ -25906,6 +25918,7 @@ function createMatrixTransport(opts) {
25906
25918
  await safeTyping(false);
25907
25919
  await safePresence("online");
25908
25920
  buffers.delete(sessionId);
25921
+ bufferMessageIds.delete(sessionId);
25909
25922
  }
25910
25923
  }
25911
25924
  return {
@@ -31584,4 +31597,4 @@ export {
31584
31597
  startDaemonSocketServer,
31585
31598
  buildAcpRegistry
31586
31599
  };
31587
- //# sourceMappingURL=chunk-O6E4CDTV.js.map
31600
+ //# sourceMappingURL=chunk-OKGNOROJ.js.map