@miosa/sdk 2.0.6 → 2.0.7

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.d.ts CHANGED
@@ -7401,6 +7401,16 @@ declare class Sandbox {
7401
7401
  timeout?: number;
7402
7402
  stream?: boolean;
7403
7403
  }): Promise<boolean>;
7404
+ /**
7405
+ * Readiness answers from the server; `assertRunning` reads the local
7406
+ * snapshot. Leaving that snapshot behind meant a caller could await
7407
+ * `waitUntilReady()`, receive `true`, and have the very next call refused
7408
+ * for being "provisioning" — the sandbox was running the whole time, only
7409
+ * this object had not been told. Nothing here can fail the wait: readiness
7410
+ * has already answered, so a refresh that does not land is not the caller's
7411
+ * problem.
7412
+ */
7413
+ private adoptReadyState;
7404
7414
  /**
7405
7415
  * Returns `true` / `false` for terminal SSE events, or `null` if the
7406
7416
  * stream endpoint is unavailable (404 or transport error) so callers
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ var TokenRefreshFailedError = class extends MiosaError {
168
168
  };
169
169
 
170
170
  // src/version.ts
171
- var SDK_VERSION = "2.0.6";
171
+ var SDK_VERSION = "2.0.7";
172
172
  var SDK_USER_AGENT = `@miosa/sdk/${SDK_VERSION}`;
173
173
 
174
174
  // src/http.ts
@@ -9398,19 +9398,40 @@ var Sandbox = class _Sandbox {
9398
9398
  const stream = options.stream ?? true;
9399
9399
  if (stream) {
9400
9400
  const sseResult = await this.tryReadinessStream(timeout);
9401
- if (sseResult !== null) return sseResult;
9401
+ if (sseResult !== null) {
9402
+ if (sseResult) await this.adoptReadyState();
9403
+ return sseResult;
9404
+ }
9402
9405
  }
9403
9406
  const deadlineMs = Date.now() + timeout * 1e3;
9404
9407
  while (Date.now() < deadlineMs) {
9405
9408
  try {
9406
9409
  const data = await this.readiness();
9407
- if (data.ready === true || data.status === "ready") return true;
9410
+ if (data.ready === true || data.status === "ready") {
9411
+ await this.adoptReadyState();
9412
+ return true;
9413
+ }
9408
9414
  } catch {
9409
9415
  }
9410
9416
  await new Promise((resolve) => setTimeout(resolve, 10));
9411
9417
  }
9412
9418
  return false;
9413
9419
  }
9420
+ /**
9421
+ * Readiness answers from the server; `assertRunning` reads the local
9422
+ * snapshot. Leaving that snapshot behind meant a caller could await
9423
+ * `waitUntilReady()`, receive `true`, and have the very next call refused
9424
+ * for being "provisioning" — the sandbox was running the whole time, only
9425
+ * this object had not been told. Nothing here can fail the wait: readiness
9426
+ * has already answered, so a refresh that does not land is not the caller's
9427
+ * problem.
9428
+ */
9429
+ async adoptReadyState() {
9430
+ try {
9431
+ await this.refresh();
9432
+ } catch {
9433
+ }
9434
+ }
9414
9435
  /**
9415
9436
  * Returns `true` / `false` for terminal SSE events, or `null` if the
9416
9437
  * stream endpoint is unavailable (404 or transport error) so callers