squadrant 0.20.1 → 0.20.2

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.
@@ -9628,6 +9628,7 @@ import os12 from "os";
9628
9628
  import path20 from "path";
9629
9629
 
9630
9630
  // packages/agents/dist/opencode/http-channel.js
9631
+ init_dist2();
9631
9632
  var OpencodeHttpChannel = class {
9632
9633
  name = "opencode-http";
9633
9634
  agent = "opencode";
@@ -9636,12 +9637,16 @@ var OpencodeHttpChannel = class {
9636
9637
  fetchImpl;
9637
9638
  portFor;
9638
9639
  sessionFor;
9640
+ directoryFor;
9641
+ createdAfterFor;
9639
9642
  timeoutMs;
9640
9643
  log;
9641
9644
  constructor(deps) {
9642
9645
  this.fetchImpl = deps.fetchImpl ?? fetch;
9643
9646
  this.portFor = deps.portFor;
9644
9647
  this.sessionFor = deps.sessionFor;
9648
+ this.directoryFor = deps.directoryFor;
9649
+ this.createdAfterFor = deps.createdAfterFor;
9645
9650
  this.timeoutMs = deps.timeoutMs ?? 5e3;
9646
9651
  this.log = deps.log;
9647
9652
  }
@@ -9694,11 +9699,24 @@ var OpencodeHttpChannel = class {
9694
9699
  * are tried. This is a capability probe, NOT a version comparison — the honest
9695
9700
  * check is "does this route answer", and neither path is a promised-stable
9696
9701
  * contract. Re-run the smoke suite when opencode is upgraded.
9702
+ *
9703
+ * #787: when the crew's directory is known, resolve by EXACT directory
9704
+ * (realpath-normalized) and never fall back to the project-wide newest.
9705
+ * GET /session is project-scoped (shared by every worktree of the repo), so
9706
+ * "newest" can be a sibling crew's — prompt_async at that id would run the
9707
+ * message in the wrong session.
9708
+ *
9709
+ * #789: opencode creates a session lazily (nothing exists until the first turn),
9710
+ * so a reused worktree dir can hold a prior crew's session. When the crew's
9711
+ * createdAt is known, also require the candidate to have been created at/after
9712
+ * it — otherwise a send resolves a stale session the live TUI is not showing.
9697
9713
  */
9698
9714
  async resolveSession(taskId, port) {
9699
9715
  const cached = this.sessionByTask.get(taskId);
9700
9716
  if (cached)
9701
9717
  return cached;
9718
+ const directory = this.directoryFor?.(taskId);
9719
+ const createdAfterMs = this.createdAfterFor?.(taskId);
9702
9720
  for (const path23 of ["/session?", "/api/session?"]) {
9703
9721
  let res;
9704
9722
  try {
@@ -9716,11 +9734,11 @@ var OpencodeHttpChannel = class {
9716
9734
  }
9717
9735
  if (!Array.isArray(sessions) || sessions.length === 0)
9718
9736
  continue;
9719
- const newest = sessions.reduce((a, b) => (b.time?.updated ?? 0) > (a.time?.updated ?? 0) ? b : a);
9720
- if (!newest?.id)
9737
+ const resolved = directory ? newestSessionInDirectory(sessions, directory, createdAfterMs) : sessions.reduce((a, b) => (b.time?.updated ?? 0) > (a.time?.updated ?? 0) ? b : a).id;
9738
+ if (!resolved)
9721
9739
  continue;
9722
- this.sessionByTask.set(taskId, newest.id);
9723
- return newest.id;
9740
+ this.sessionByTask.set(taskId, resolved);
9741
+ return resolved;
9724
9742
  }
9725
9743
  return void 0;
9726
9744
  }