ppio-sandbox 1.0.1 → 1.0.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.
@@ -19,7 +19,7 @@ import {
19
19
  __spreadProps,
20
20
  __spreadValues,
21
21
  getSignature
22
- } from "./chunk-7OUSMPTE.mjs";
22
+ } from "./chunk-DTP6KHRO.mjs";
23
23
 
24
24
  // src/code-interpreter/messaging.ts
25
25
  async function extractError(res) {
@@ -1,5 +1,5 @@
1
- import { S as Sandbox$1, t as SandboxOpts$1, m as CommandResult } from './index-D9GCzBVP.mjs';
2
- export { A as ApiClient, b as AuthenticationError, H as CommandConnectOpts, l as CommandExitError, q as CommandHandle, G as CommandRequestOpts, J as CommandStartOpts, K as Commands, C as ConnectionConfig, a as ConnectionOpts, E as EntryInfo, F as FileType, h as Filesystem, j as FilesystemEvent, i as FilesystemEventType, I as InvalidArgumentError, L as Logger, N as NotEnoughSpaceError, d as NotFoundError, D as ProcessInfo, M as Pty, P as PtyOutput, R as RateLimitError, u as SandboxApiOpts, w as SandboxBetaCreateOpts, v as SandboxConnectOpts, e as SandboxError, r as SandboxInfo, z as SandboxListOpts, s as SandboxMetrics, x as SandboxMetricsOpts, B as SandboxPaginator, y as SandboxState, o as Stderr, n as Stdout, T as TemplateError, f as TimeoutError, U as Username, k as WatchHandle, W as WriteInfo, c as components, g as getSignature, p as paths } from './index-D9GCzBVP.mjs';
1
+ import { S as Sandbox$1, t as SandboxOpts$1, m as CommandResult } from './index-DVtYWWe-.mjs';
2
+ export { A as ApiClient, b as AuthenticationError, H as CommandConnectOpts, l as CommandExitError, q as CommandHandle, G as CommandRequestOpts, J as CommandStartOpts, K as Commands, C as ConnectionConfig, a as ConnectionOpts, E as EntryInfo, F as FileType, h as Filesystem, j as FilesystemEvent, i as FilesystemEventType, I as InvalidArgumentError, L as Logger, N as NotEnoughSpaceError, d as NotFoundError, D as ProcessInfo, M as Pty, P as PtyOutput, R as RateLimitError, u as SandboxApiOpts, w as SandboxBetaCreateOpts, v as SandboxConnectOpts, e as SandboxError, r as SandboxInfo, z as SandboxListOpts, s as SandboxMetrics, x as SandboxMetricsOpts, B as SandboxPaginator, y as SandboxState, o as Stderr, n as Stdout, T as TemplateError, f as TimeoutError, U as Username, k as WatchHandle, W as WriteInfo, c as components, g as getSignature, p as paths } from './index-DVtYWWe-.mjs';
3
3
  import 'openapi-fetch';
4
4
  import '@connectrpc/connect';
5
5
  import '@bufbuild/protobuf/codegenv2';
package/dist/desktop.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Sandbox$1, t as SandboxOpts$1, m as CommandResult } from './index-D9GCzBVP.js';
2
- export { A as ApiClient, b as AuthenticationError, H as CommandConnectOpts, l as CommandExitError, q as CommandHandle, G as CommandRequestOpts, J as CommandStartOpts, K as Commands, C as ConnectionConfig, a as ConnectionOpts, E as EntryInfo, F as FileType, h as Filesystem, j as FilesystemEvent, i as FilesystemEventType, I as InvalidArgumentError, L as Logger, N as NotEnoughSpaceError, d as NotFoundError, D as ProcessInfo, M as Pty, P as PtyOutput, R as RateLimitError, u as SandboxApiOpts, w as SandboxBetaCreateOpts, v as SandboxConnectOpts, e as SandboxError, r as SandboxInfo, z as SandboxListOpts, s as SandboxMetrics, x as SandboxMetricsOpts, B as SandboxPaginator, y as SandboxState, o as Stderr, n as Stdout, T as TemplateError, f as TimeoutError, U as Username, k as WatchHandle, W as WriteInfo, c as components, g as getSignature, p as paths } from './index-D9GCzBVP.js';
1
+ import { S as Sandbox$1, t as SandboxOpts$1, m as CommandResult } from './index-DVtYWWe-.js';
2
+ export { A as ApiClient, b as AuthenticationError, H as CommandConnectOpts, l as CommandExitError, q as CommandHandle, G as CommandRequestOpts, J as CommandStartOpts, K as Commands, C as ConnectionConfig, a as ConnectionOpts, E as EntryInfo, F as FileType, h as Filesystem, j as FilesystemEvent, i as FilesystemEventType, I as InvalidArgumentError, L as Logger, N as NotEnoughSpaceError, d as NotFoundError, D as ProcessInfo, M as Pty, P as PtyOutput, R as RateLimitError, u as SandboxApiOpts, w as SandboxBetaCreateOpts, v as SandboxConnectOpts, e as SandboxError, r as SandboxInfo, z as SandboxListOpts, s as SandboxMetrics, x as SandboxMetricsOpts, B as SandboxPaginator, y as SandboxState, o as Stderr, n as Stdout, T as TemplateError, f as TimeoutError, U as Username, k as WatchHandle, W as WriteInfo, c as components, g as getSignature, p as paths } from './index-DVtYWWe-.js';
3
3
  import 'openapi-fetch';
4
4
  import '@connectrpc/connect';
5
5
  import '@bufbuild/protobuf/codegenv2';
package/dist/desktop.js CHANGED
@@ -89,7 +89,7 @@ var import_openapi_fetch = __toESM(require("openapi-fetch"));
89
89
  var import_platform = __toESM(require("platform"));
90
90
 
91
91
  // package.json
92
- var version = "1.0.1";
92
+ var version = "1.0.2";
93
93
 
94
94
  // src/core/api/metadata.ts
95
95
  function getRuntime() {
@@ -1781,6 +1781,39 @@ var SandboxApi = class {
1781
1781
  }
1782
1782
  return true;
1783
1783
  }
1784
+ static async connectSandbox(sandboxId, opts) {
1785
+ var _a2, _b;
1786
+ const timeoutMs = (_a2 = opts == null ? void 0 : opts.timeoutMs) != null ? _a2 : DEFAULT_SANDBOX_TIMEOUT_MS;
1787
+ const config = new ConnectionConfig(opts);
1788
+ const client = new ApiClient(config);
1789
+ const res = await client.api.POST("/sandboxes/{sandboxID}/connect", {
1790
+ params: {
1791
+ path: {
1792
+ sandboxID: sandboxId
1793
+ }
1794
+ },
1795
+ body: {
1796
+ timeout: timeoutToSeconds(timeoutMs)
1797
+ },
1798
+ signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
1799
+ });
1800
+ if (((_b = res.error) == null ? void 0 : _b.code) === 404) {
1801
+ throw new NotFoundError(`Sandbox ${sandboxId} not found`);
1802
+ }
1803
+ const err = handleApiError(res);
1804
+ if (err) {
1805
+ throw err;
1806
+ }
1807
+ if (!res.data) {
1808
+ throw new Error("Sandbox not found");
1809
+ }
1810
+ return {
1811
+ sandboxId: `${res.data.sandboxID}-${res.data.clientID}`,
1812
+ envdVersion: res.data.envdVersion,
1813
+ envdAccessToken: res.data.envdAccessToken,
1814
+ sandboxDomain: void 0
1815
+ };
1816
+ }
1784
1817
  };
1785
1818
  var SandboxPaginator = class {
1786
1819
  constructor(opts) {
@@ -1985,23 +2018,10 @@ var Sandbox = class extends SandboxApi {
1985
2018
  * ```
1986
2019
  */
1987
2020
  static async connect(sandboxId, opts) {
1988
- try {
1989
- await SandboxApi.setTimeout(
1990
- sandboxId,
1991
- (opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
1992
- opts
1993
- );
1994
- } catch (e) {
1995
- if (e instanceof SandboxError) {
1996
- await SandboxApi.resumeSandbox(sandboxId, opts);
1997
- } else {
1998
- throw e;
1999
- }
2000
- }
2001
- const info = await SandboxApi.getFullInfo(sandboxId, opts);
2021
+ const info = await SandboxApi.connectSandbox(sandboxId, opts);
2002
2022
  const config = new ConnectionConfig(opts);
2003
2023
  return new this(__spreadValues({
2004
- sandboxId,
2024
+ sandboxId: info.sandboxId,
2005
2025
  sandboxDomain: info.sandboxDomain,
2006
2026
  envdAccessToken: info.envdAccessToken,
2007
2027
  envdVersion: info.envdVersion
@@ -2027,15 +2047,7 @@ var Sandbox = class extends SandboxApi {
2027
2047
  * ```
2028
2048
  */
2029
2049
  async connect(opts) {
2030
- try {
2031
- await SandboxApi.setTimeout(
2032
- this.sandboxId,
2033
- (opts == null ? void 0 : opts.timeoutMs) || DEFAULT_SANDBOX_TIMEOUT_MS,
2034
- opts
2035
- );
2036
- } catch (e) {
2037
- await SandboxApi.resumeSandbox(this.sandboxId, opts);
2038
- }
2050
+ await SandboxApi.connectSandbox(this.sandboxId, opts);
2039
2051
  return this;
2040
2052
  }
2041
2053
  /**