tensorlake 0.4.46 → 0.4.47

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.
@@ -76,6 +76,7 @@ interface UpdateSandboxOptions {
76
76
  interface CreateSandboxResponse {
77
77
  sandboxId: string;
78
78
  status: SandboxStatus;
79
+ routingHint?: string;
79
80
  }
80
81
  interface SandboxInfo {
81
82
  sandboxId: string;
@@ -267,6 +268,7 @@ interface SandboxOptions {
267
268
  apiKey?: string;
268
269
  organizationId?: string;
269
270
  projectId?: string;
271
+ routingHint?: string;
270
272
  }
271
273
  interface CreateAndConnectOptions extends CreateSandboxOptions {
272
274
  poolId?: string;
@@ -76,6 +76,7 @@ interface UpdateSandboxOptions {
76
76
  interface CreateSandboxResponse {
77
77
  sandboxId: string;
78
78
  status: SandboxStatus;
79
+ routingHint?: string;
79
80
  }
80
81
  interface SandboxInfo {
81
82
  sandboxId: string;
@@ -267,6 +268,7 @@ interface SandboxOptions {
267
268
  apiKey?: string;
268
269
  organizationId?: string;
269
270
  projectId?: string;
271
+ routingHint?: string;
270
272
  }
271
273
  interface CreateAndConnectOptions extends CreateSandboxOptions {
272
274
  poolId?: string;
@@ -177,6 +177,9 @@ var HttpClient = class {
177
177
  if (options.hostHeader) {
178
178
  this.headers["Host"] = options.hostHeader;
179
179
  }
180
+ if (options.routingHint) {
181
+ this.headers["X-Tensorlake-Route-Hint"] = options.routingHint;
182
+ }
180
183
  }
181
184
  close() {
182
185
  this.abortController?.abort();
@@ -3071,7 +3074,8 @@ var Sandbox = class {
3071
3074
  apiKey: options.apiKey,
3072
3075
  organizationId: options.organizationId,
3073
3076
  projectId: options.projectId,
3074
- hostHeader
3077
+ hostHeader,
3078
+ routingHint: options.routingHint
3075
3079
  });
3076
3080
  }
3077
3081
  /** @internal Used by SandboxClient.createAndConnect to set ownership. */
@@ -3666,14 +3670,15 @@ var SandboxClient = class _SandboxClient {
3666
3670
  );
3667
3671
  }
3668
3672
  // --- Connect ---
3669
- connect(identifier, proxyUrl) {
3673
+ connect(identifier, proxyUrl, routingHint) {
3670
3674
  const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
3671
3675
  return new Sandbox({
3672
3676
  sandboxId: identifier,
3673
3677
  proxyUrl: resolvedProxy,
3674
3678
  apiKey: this.apiKey,
3675
3679
  organizationId: this.organizationId,
3676
- projectId: this.projectId
3680
+ projectId: this.projectId,
3681
+ routingHint
3677
3682
  });
3678
3683
  }
3679
3684
  async createAndConnect(options) {
@@ -3684,6 +3689,11 @@ var SandboxClient = class _SandboxClient {
3684
3689
  } else {
3685
3690
  result = await this.create(options);
3686
3691
  }
3692
+ if (result.status === "running" /* RUNNING */) {
3693
+ const sandbox = this.connect(result.sandboxId, options?.proxyUrl, result.routingHint);
3694
+ sandbox._setOwner(this);
3695
+ return sandbox;
3696
+ }
3687
3697
  const deadline = Date.now() + startupTimeout * 1e3;
3688
3698
  while (Date.now() < deadline) {
3689
3699
  const info = await this.get(result.sandboxId);