@decocms/sandbox-controller 0.8.2 → 0.8.3

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
@@ -3817,6 +3817,13 @@ declare class FreestyleSandboxProvider implements SandboxProvider {
3817
3817
  * VM anyway, only later.
3818
3818
  */
3819
3819
  releaseAfter(handle: string, graceMs: number): Promise<void>;
3820
+ /**
3821
+ * `renewTtl` cancels only this process's timer, so a turn that started
3822
+ * through another replica still has to be seen: the daemon's clock counts
3823
+ * its requests and streaming runs. A daemon that won't say is left to the
3824
+ * VM's idle timeout.
3825
+ */
3826
+ private pauseIfIdle;
3820
3827
  /** The VM's idle timeout already counts every request as activity. */
3821
3828
  renewTtl(handle: string): Promise<void>;
3822
3829
  /**
package/dist/index.js CHANGED
@@ -6759,7 +6759,7 @@ var Freestyle = class {
6759
6759
  // ../sandbox/package.json
6760
6760
  var package_default = {
6761
6761
  name: "@decocms/sandbox",
6762
- version: "1.85.2",
6762
+ version: "1.89.2",
6763
6763
  private: true,
6764
6764
  type: "module",
6765
6765
  description: "Sandbox runtime for isolated Studio tool execution",
@@ -7328,13 +7328,26 @@ running`).digest("hex").slice(0, 16)}`;
7328
7328
  this.cancelRelease(handle);
7329
7329
  const timer = setTimeout(() => {
7330
7330
  this.releaseTimers.delete(handle);
7331
- void this.find(handle).then((f) => f?.vm.pause()).catch(
7331
+ void this.pauseIfIdle(handle, graceMs).catch(
7332
7332
  (err) => console.warn(`[${LOG_LABEL2}] pause ${handle} failed: ${errMsg2(err)}`)
7333
7333
  );
7334
7334
  }, graceMs);
7335
7335
  timer.unref?.();
7336
7336
  this.releaseTimers.set(handle, timer);
7337
7337
  }
7338
+ /**
7339
+ * `renewTtl` cancels only this process's timer, so a turn that started
7340
+ * through another replica still has to be seen: the daemon's clock counts
7341
+ * its requests and streaming runs. A daemon that won't say is left to the
7342
+ * VM's idle timeout.
7343
+ */
7344
+ async pauseIfIdle(handle, graceMs) {
7345
+ const found = await this.find(handle);
7346
+ if (!found) return;
7347
+ const idleMs = await daemonIdleMs(found.daemon.url);
7348
+ if (idleMs === null || idleMs < graceMs) return;
7349
+ await found.vm.pause();
7350
+ }
7338
7351
  /** The VM's idle timeout already counts every request as activity. */
7339
7352
  async renewTtl(handle) {
7340
7353
  this.cancelRelease(handle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/sandbox-controller",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Runs Studio agent sandboxes on Kubernetes, and serves them to a remote Studio.",
5
5
  "repository": {
6
6
  "type": "git",