@bivy/bivy 0.15.0-staging.26 → 0.15.0-staging.27

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/server.js +18 -1
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -8075,6 +8075,12 @@ async function createSession(workspace = defaultWorkspace, sessionFile, opts = {
8075
8075
  * of the same session onto one promise fixes both.
8076
8076
  */
8077
8077
  const resumingSessions = new Map();
8078
+ // Keep an id index as well as the resolved runtime ref. A prompt can arrive
8079
+ // while session.open is still resolving and may not carry the session's path;
8080
+ // without this index it cannot discover the in-flight open from metadata and
8081
+ // is incorrectly reported as "Session not found". Both commands must join the
8082
+ // same resume operation by the identity the client actually supplied.
8083
+ const resumingSessionsById = new Map();
8078
8084
  /**
8079
8085
  * Resolve the session a client command targets, resuming it from durable
8080
8086
  * metadata when it isn't currently held in memory. A session survives being
@@ -8097,6 +8103,9 @@ async function resolveOrResumeSession(sessionId, sessionPath) {
8097
8103
  const open = openSessions.get(id);
8098
8104
  if (open)
8099
8105
  return open;
8106
+ const byId = resumingSessionsById.get(id);
8107
+ if (byId)
8108
+ return byId;
8100
8109
  const pathRef = typeof sessionPath === "string" && sessionPath.trim() ? sessionPath.trim() : undefined;
8101
8110
  const meta = metadata.getSession(id) ?? (pathRef ? metadata.getSession(pathRef) : undefined);
8102
8111
  // A run that only kept its terminal log has nothing to resume — it opens as a
@@ -8152,15 +8161,23 @@ async function resolveOrResumeSession(sessionId, sessionPath) {
8152
8161
  }
8153
8162
  }
8154
8163
  const inflight = resumingSessions.get(key);
8155
- if (inflight)
8164
+ if (inflight) {
8165
+ resumingSessionsById.set(id, inflight);
8156
8166
  return inflight;
8167
+ }
8157
8168
  const resume = createSession(defaultWorkspace, ref, { runtimeId, makeActive: false });
8158
8169
  resumingSessions.set(key, resume);
8170
+ resumingSessionsById.set(id, resume);
8159
8171
  try {
8160
8172
  return await resume;
8161
8173
  }
8162
8174
  finally {
8163
8175
  resumingSessions.delete(key);
8176
+ // Only delete our promise. A future implementation may replace an entry
8177
+ // after a failed resume, and must not have its newer attempt removed by an
8178
+ // older finally block.
8179
+ if (resumingSessionsById.get(id) === resume)
8180
+ resumingSessionsById.delete(id);
8164
8181
  }
8165
8182
  }
8166
8183
  // Enumerating a runtime's models needs a live session (the model registry lives
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.15.0-staging.26",
3
+ "version": "0.15.0-staging.27",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Run coding agents on machines you own. Open-source, self-hostable agent workspace.",