@tensorlakeai/tensorlake 0.5.157 → 0.5.158

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.
@@ -402,7 +402,7 @@ var NativeWorkerClient = class {
402
402
  }
403
403
  };
404
404
  var runtimeKey = /* @__PURE__ */ Symbol.for(
405
- `tensorlake.native.worker.${false ? "source" : "0.5.157"}.v1`
405
+ `tensorlake.native.worker.${false ? "source" : "0.5.158"}.v1`
406
406
  );
407
407
  var runtimes = globalThis;
408
408
  function configureNativeWorker(workerPath) {
@@ -390,7 +390,7 @@ var NativeWorkerClient = class {
390
390
  }
391
391
  };
392
392
  var runtimeKey = /* @__PURE__ */ Symbol.for(
393
- `tensorlake.native.worker.${false ? "source" : "0.5.157"}.v1`
393
+ `tensorlake.native.worker.${false ? "source" : "0.5.158"}.v1`
394
394
  );
395
395
  var runtimes = globalThis;
396
396
  function configureNativeWorker(workerPath) {
@@ -51,7 +51,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
51
51
  var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
52
52
 
53
53
  // src/defaults.ts
54
- var SDK_VERSION = "0.5.157";
54
+ var SDK_VERSION = "0.5.158";
55
55
  var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
56
56
  var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
57
57
  var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -247,7 +247,7 @@ var NativeWorkerClient = class {
247
247
  }
248
248
  };
249
249
  var runtimeKey = /* @__PURE__ */ Symbol.for(
250
- `tensorlake.native.worker.${false ? "source" : "0.5.157"}.v1`
250
+ `tensorlake.native.worker.${false ? "source" : "0.5.158"}.v1`
251
251
  );
252
252
  var runtimes = globalThis;
253
253
  function configureNativeWorker(workerPath) {
@@ -10,7 +10,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
10
10
  var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
11
11
 
12
12
  // src/defaults.ts
13
- var SDK_VERSION = "0.5.157";
13
+ var SDK_VERSION = "0.5.158";
14
14
  var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
15
15
  var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
16
16
  var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -206,7 +206,7 @@ var NativeWorkerClient = class {
206
206
  }
207
207
  };
208
208
  var runtimeKey = /* @__PURE__ */ Symbol.for(
209
- `tensorlake.native.worker.${false ? "source" : "0.5.157"}.v1`
209
+ `tensorlake.native.worker.${false ? "source" : "0.5.158"}.v1`
210
210
  );
211
211
  var runtimes = globalThis;
212
212
  function configureNativeWorker(workerPath) {
package/dist/index.cjs CHANGED
@@ -49,7 +49,7 @@ var init_defaults = __esm({
49
49
  "src/defaults.ts"() {
50
50
  "use strict";
51
51
  init_cjs_shims();
52
- SDK_VERSION = "0.5.157";
52
+ SDK_VERSION = "0.5.158";
53
53
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
54
54
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
55
55
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -512,7 +512,7 @@ var init_native_worker_client = __esm({
512
512
  }
513
513
  };
514
514
  runtimeKey = /* @__PURE__ */ Symbol.for(
515
- `tensorlake.native.worker.${false ? "source" : "0.5.157"}.v1`
515
+ `tensorlake.native.worker.${false ? "source" : "0.5.158"}.v1`
516
516
  );
517
517
  runtimes = globalThis;
518
518
  }
@@ -5475,10 +5475,9 @@ var init_client = __esm({
5475
5475
  /**
5476
5476
  * Create a sandbox, wait for it to reach `Running`, and return a connected handle.
5477
5477
  *
5478
- * This is `create({ wait: false })` followed by `PendingSandbox.ready()`
5479
- * polling every `pollInterval` seconds, with `requestTimeout` as the wait
5480
- * budget, in one call. The returned `Sandbox` auto-terminates when
5481
- * `terminate()` is called.
5478
+ * The create waits on the server, which answers as soon as the sandbox
5479
+ * runs, with `requestTimeout` as the wait budget. The returned `Sandbox`
5480
+ * auto-terminates when `terminate()` is called.
5482
5481
  *
5483
5482
  * **When the wait runs out the sandbox is not deleted.** A `SandboxPending`
5484
5483
  * is thrown with the sandbox id, and the sandbox keeps its place in the
@@ -5500,11 +5499,10 @@ var init_client = __esm({
5500
5499
  pool_id: options?.poolId
5501
5500
  });
5502
5501
  const requestedName = options?.poolId != null ? null : options?.name ?? null;
5503
- let sandboxId;
5504
- let traceId;
5505
5502
  const createStart = nowMs();
5503
+ let result;
5506
5504
  if (options?.poolId != null) {
5507
- const result = await requestClient.claim(options.poolId, {
5505
+ result = await requestClient.claim(options.poolId, {
5508
5506
  fileSystems: options.fileSystems
5509
5507
  });
5510
5508
  logSdkTiming("sandbox.create", "claim_response", createStart, {
@@ -5512,84 +5510,55 @@ var init_client = __esm({
5512
5510
  status: result.status,
5513
5511
  server_trace_id: result.traceId
5514
5512
  });
5515
- if (result.status === "running" /* RUNNING */) {
5516
- const explicitProxyUrl = options?.proxyUrl ?? explicitProxyUrlOverride() ?? void 0;
5517
- const selectedProxyUrl = await this.native.selectSandboxProxyUrl(
5518
- result.sandboxId,
5519
- result.sandboxUrl ?? null,
5520
- result.ingressEndpoint ?? null,
5521
- explicitProxyUrl ?? null
5522
- );
5523
- const sandbox2 = requestClient.connect(
5524
- result.sandboxId,
5525
- selectedProxyUrl,
5526
- result.routingHint,
5527
- requestTimeout,
5528
- explicitProxyUrl
5529
- );
5530
- sandbox2._setOwner(requestClient);
5531
- sandbox2.traceId = result.traceId;
5532
- sandbox2._setLifecycleIdentifier(result.sandboxId);
5533
- sandbox2._setName(result.name ?? requestedName);
5534
- logSdkTiming("sandbox.create", "complete", opStart, {
5535
- sandbox_id: result.sandboxId,
5536
- status: "running" /* RUNNING */,
5537
- server_trace_id: result.traceId
5538
- });
5539
- return sandbox2;
5540
- }
5541
- if (result.status === "suspended" /* SUSPENDED */ || result.status === "terminated" /* TERMINATED */ || result.status === "failed" /* FAILED */) {
5542
- throw startupFailure(result.sandboxId, result.status, {
5543
- errorDetails: result.errorDetails,
5544
- terminationReason: result.terminationReason ?? result.reason
5545
- });
5546
- }
5547
- sandboxId = result.sandboxId;
5548
- traceId = result.traceId;
5549
5513
  } else {
5550
- const pending = await requestClient.requestPending(options, {
5551
- ownsSandbox: true
5514
+ const body = _SandboxClient.buildCreateRequestBody({
5515
+ ...options,
5516
+ wait: void 0
5552
5517
  });
5518
+ result = await requestClient.tracedJson(
5519
+ () => requestClient.native.createSandboxAndWait(JSON.stringify(body)),
5520
+ "sandboxId"
5521
+ );
5553
5522
  logSdkTiming("sandbox.create", "create_response", createStart, {
5554
- sandbox_id: pending.sandboxId,
5555
- status: pending.state,
5556
- server_trace_id: pending.traceId
5523
+ sandbox_id: result.sandboxId,
5524
+ status: result.status,
5525
+ server_trace_id: result.traceId
5526
+ });
5527
+ }
5528
+ if (result.status === "running" /* RUNNING */) {
5529
+ const explicitProxyUrl = options?.proxyUrl ?? explicitProxyUrlOverride() ?? void 0;
5530
+ const selectedProxyUrl = await this.native.selectSandboxProxyUrl(
5531
+ result.sandboxId,
5532
+ result.sandboxUrl ?? null,
5533
+ result.ingressEndpoint ?? null,
5534
+ explicitProxyUrl ?? null
5535
+ );
5536
+ const sandbox2 = requestClient.connect(
5537
+ result.sandboxId,
5538
+ selectedProxyUrl,
5539
+ result.routingHint,
5540
+ requestTimeout,
5541
+ explicitProxyUrl
5542
+ );
5543
+ sandbox2._setOwner(requestClient);
5544
+ sandbox2.traceId = result.traceId;
5545
+ sandbox2._setLifecycleIdentifier(result.sandboxId);
5546
+ sandbox2._setName(result.name ?? requestedName);
5547
+ logSdkTiming("sandbox.create", "complete", opStart, {
5548
+ sandbox_id: result.sandboxId,
5549
+ status: "running" /* RUNNING */,
5550
+ server_trace_id: result.traceId
5551
+ });
5552
+ return sandbox2;
5553
+ }
5554
+ if (result.status === "suspended" /* SUSPENDED */ || result.status === "terminated" /* TERMINATED */ || result.status === "failed" /* FAILED */) {
5555
+ throw startupFailure(result.sandboxId, result.status, {
5556
+ errorDetails: result.errorDetails,
5557
+ terminationReason: result.terminationReason ?? result.reason
5557
5558
  });
5558
- sandboxId = pending.sandboxId;
5559
- traceId = pending.traceId;
5560
- if (pending.state === "running" /* RUNNING */) {
5561
- const explicitProxyUrl = options?.proxyUrl ?? explicitProxyUrlOverride() ?? void 0;
5562
- const selectedProxyUrl = await this.native.selectSandboxProxyUrl(
5563
- sandboxId,
5564
- pending.sandboxUrl ?? null,
5565
- pending.ingressEndpoint ?? null,
5566
- explicitProxyUrl ?? null
5567
- );
5568
- const sandbox2 = requestClient.connect(
5569
- sandboxId,
5570
- selectedProxyUrl,
5571
- pending.routingHint,
5572
- requestTimeout,
5573
- explicitProxyUrl
5574
- );
5575
- sandbox2._setOwner(requestClient);
5576
- sandbox2.traceId = traceId;
5577
- sandbox2._setLifecycleIdentifier(sandboxId);
5578
- sandbox2._setName(pending.name ?? requestedName);
5579
- logSdkTiming("sandbox.create", "complete", opStart, {
5580
- sandbox_id: sandboxId,
5581
- status: "running" /* RUNNING */,
5582
- server_trace_id: traceId
5583
- });
5584
- return sandbox2;
5585
- }
5586
- if (pending.state === "terminated" /* TERMINATED */ || pending.state === "failed" /* FAILED */) {
5587
- throw startupFailure(sandboxId, pending.state, {
5588
- errorDetails: pending.errorDetails,
5589
- terminationReason: pending.terminationReason ?? pending.reason
5590
- });
5591
- }
5592
5559
  }
5560
+ const sandboxId = result.sandboxId;
5561
+ const traceId = result.traceId;
5593
5562
  const remaining = Math.max(0, (deadline - Date.now()) / 1e3);
5594
5563
  const observed = await requestClient.waitForSandbox(
5595
5564
  sandboxId,