@buddy-works/sandbox-sdk 0.1.0-rc.1 → 0.1.0

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.mts CHANGED
@@ -1590,16 +1590,21 @@ declare class Sandbox {
1590
1590
  waitUntilStopped(pollIntervalMs?: number, maxWaitMs?: number): Promise<void>;
1591
1591
  /**
1592
1592
  * Start a stopped sandbox
1593
- * Waits until the sandbox reaches RUNNING state
1593
+ *
1594
+ * If the sandbox is already running, this method returns immediately.
1595
+ * Waits until the sandbox reaches RUNNING state.
1594
1596
  */
1595
1597
  start(): Promise<void>;
1596
1598
  /**
1597
1599
  * Stop a running sandbox
1598
- * Waits until the sandbox reaches STOPPED state
1600
+ *
1601
+ * If the sandbox is already stopped, this method returns immediately.
1602
+ * Waits until the sandbox reaches STOPPED state.
1599
1603
  */
1600
1604
  stop(): Promise<void>;
1601
1605
  /**
1602
1606
  * Restart the sandbox
1607
+ *
1603
1608
  * Waits until the sandbox reaches RUNNING state and setup is complete
1604
1609
  */
1605
1610
  restart(): Promise<void>;
package/dist/index.mjs CHANGED
@@ -1311,7 +1311,7 @@ const zAddSandboxByYamlData = z.object({
1311
1311
  //#endregion
1312
1312
  //#region package.json
1313
1313
  var name = "@buddy-works/sandbox-sdk";
1314
- var version = "0.1.0-rc.1";
1314
+ var version = "0.1.0";
1315
1315
 
1316
1316
  //#endregion
1317
1317
  //#region src/utils/environment.ts
@@ -2551,11 +2551,18 @@ var Sandbox = class Sandbox {
2551
2551
  }
2552
2552
  /**
2553
2553
  * Start a stopped sandbox
2554
- * Waits until the sandbox reaches RUNNING state
2554
+ *
2555
+ * If the sandbox is already running, this method returns immediately.
2556
+ * Waits until the sandbox reaches RUNNING state.
2555
2557
  */
2556
2558
  async start() {
2557
2559
  const sandboxId = this.initializedId;
2558
2560
  return withErrorHandler("Failed to start sandbox", async () => {
2561
+ await this.refresh();
2562
+ if (this.data.status === "RUNNING") {
2563
+ logger_default.debug(`Sandbox ${sandboxId} is already running.`);
2564
+ return;
2565
+ }
2559
2566
  logger_default.debug(`Starting sandbox ${sandboxId}...`);
2560
2567
  this.#sandboxData = await this.#client.startSandbox({ path: { sandbox_id: sandboxId } });
2561
2568
  await this.waitUntilRunning();
@@ -2564,11 +2571,18 @@ var Sandbox = class Sandbox {
2564
2571
  }
2565
2572
  /**
2566
2573
  * Stop a running sandbox
2567
- * Waits until the sandbox reaches STOPPED state
2574
+ *
2575
+ * If the sandbox is already stopped, this method returns immediately.
2576
+ * Waits until the sandbox reaches STOPPED state.
2568
2577
  */
2569
2578
  async stop() {
2570
2579
  const sandboxId = this.initializedId;
2571
2580
  return withErrorHandler("Failed to stop sandbox", async () => {
2581
+ await this.refresh();
2582
+ if (this.data.status === "STOPPED") {
2583
+ logger_default.debug(`Sandbox ${sandboxId} is already stopped.`);
2584
+ return;
2585
+ }
2572
2586
  logger_default.debug(`Stopping sandbox ${sandboxId}...`);
2573
2587
  this.#sandboxData = await this.#client.stopSandbox({ path: { sandbox_id: sandboxId } });
2574
2588
  await this.waitUntilStopped();
@@ -2577,6 +2591,7 @@ var Sandbox = class Sandbox {
2577
2591
  }
2578
2592
  /**
2579
2593
  * Restart the sandbox
2594
+ *
2580
2595
  * Waits until the sandbox reaches RUNNING state and setup is complete
2581
2596
  */
2582
2597
  async restart() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buddy-works/sandbox-sdk",
3
- "version": "0.1.0-rc.1",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for managing sandboxes through the Buddy API",
6
6
  "main": "./dist/index.mjs",