@agentconnect.md/daemon 1.0.0-rc.119 → 1.0.0-rc.120

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/dist/index.js CHANGED
@@ -24261,6 +24261,14 @@ var LocalStore = class {
24261
24261
  openSessionAgents(channel, thread) {
24262
24262
  return this.db.prepare("SELECT agentId FROM sessions WHERE channel = ? AND thread = ? AND state != 'closed'").all(channel, thread).map((r) => r.agentId);
24263
24263
  }
24264
+ /** Agents with a TTL-`closed` session in this thread (§7.3). Backs thread-affinity
24265
+ * revival: when no OPEN session owns a thread, a follow-up reply can still be routed
24266
+ * to the sole agent that previously owned it, and SessionManager.handle recreates/
24267
+ * resumes the ACP session. Kept separate from `openSessionAgents` so the live
24268
+ * multi-agent disambiguation (2+ open owners → mention-gated) is never perturbed. */
24269
+ closedSessionAgents(channel, thread) {
24270
+ return this.db.prepare("SELECT agentId FROM sessions WHERE channel = ? AND thread = ? AND state = 'closed'").all(channel, thread).map((r) => r.agentId);
24271
+ }
24264
24272
  /** Count non-closed sessions in (channel, thread) touched at/after `sinceTs`
24265
24273
  * (epoch ms). Used to bound unrouted-transcript growth to recently-active
24266
24274
  * threads, since there is no session-`closed` lifecycle yet. */
@@ -24379,7 +24387,9 @@ var SessionManager = class {
24379
24387
  }
24380
24388
  threadOwner(channel, thread) {
24381
24389
  const owners = this.deps.store.openSessionAgents(channel, thread);
24382
- return owners.length === 1 ? owners[0] : null;
24390
+ if (owners.length > 0) return owners.length === 1 ? owners[0] : null;
24391
+ const dormant = this.deps.store.closedSessionAgents(channel, thread);
24392
+ return dormant.length === 1 ? dormant[0] : null;
24383
24393
  }
24384
24394
  async handle(agentId, msg) {
24385
24395
  const agent = this.deps.agentById(agentId);