tensorlake 0.5.126 → 0.5.127

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.
@@ -46,7 +46,7 @@ var init_defaults = __esm({
46
46
  "src/defaults.ts"() {
47
47
  "use strict";
48
48
  init_esm_shims();
49
- SDK_VERSION = "0.5.126";
49
+ SDK_VERSION = "0.5.127";
50
50
  API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
51
51
  API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
52
52
  NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
@@ -3630,9 +3630,11 @@ init_cloud_client();
3630
3630
 
3631
3631
  // src/filesystem.ts
3632
3632
  init_esm_shims();
3633
- init_defaults();
3634
- import { execFile } from "child_process";
3635
3633
  import { randomBytes } from "crypto";
3634
+
3635
+ // src/mount-cli.ts
3636
+ init_esm_shims();
3637
+ import { execFile } from "child_process";
3636
3638
  import { accessSync, constants } from "fs";
3637
3639
  import { homedir } from "os";
3638
3640
  import { join } from "path";
@@ -3716,14 +3718,71 @@ var ReadOnlyMountNotSupportedError = class extends MountError {
3716
3718
  }
3717
3719
  };
3718
3720
  var CliNotFoundError = class extends MountError {
3719
- constructor(detail) {
3721
+ constructor(detail, command = "fs") {
3720
3722
  super(
3721
- `Mount operations require the Tensorlake CLI (\`tl\`) with \`tl fs\` support: ${detail}. Install or upgrade it with: curl -fsSL https://tensorlake.ai/install.sh | sh`
3723
+ `Mount operations require the Tensorlake CLI (\`tl\`) with \`tl ${command}\` support: ${detail}. Install or upgrade it with: curl -fsSL https://tensorlake.ai/install.sh | sh`
3722
3724
  );
3723
3725
  this.name = "CliNotFoundError";
3724
3726
  }
3725
3727
  };
3726
3728
 
3729
+ // src/mount-cli.ts
3730
+ var execFileAsync = promisify(execFile);
3731
+ var MountCli = class {
3732
+ constructor(command, envOverrides) {
3733
+ this.command = command;
3734
+ this.envOverrides = envOverrides;
3735
+ }
3736
+ binary = null;
3737
+ async findCli() {
3738
+ const candidates = [];
3739
+ if (process.env.TENSORLAKE_CLI) candidates.push(process.env.TENSORLAKE_CLI);
3740
+ candidates.push("tl");
3741
+ const installed = join(homedir(), ".tensorlake", "bin", "tl");
3742
+ try {
3743
+ accessSync(installed, constants.F_OK);
3744
+ candidates.push(installed);
3745
+ } catch {
3746
+ }
3747
+ const support = this.command === "git" ? "git mount" : "fs";
3748
+ const probe = this.command === "git" ? ["git", "mount", "--help"] : ["fs", "--help"];
3749
+ let unsupported = null;
3750
+ for (const candidate of candidates) {
3751
+ try {
3752
+ await execFileAsync(candidate, probe, { timeout: 15e3 });
3753
+ return candidate;
3754
+ } catch (error) {
3755
+ if (error.code !== "ENOENT") unsupported = candidate;
3756
+ }
3757
+ }
3758
+ throw new CliNotFoundError(
3759
+ unsupported ? `\`tl\` at ${unsupported} does not support \`tl ${support}\` (upgrade required)` : "`tl` was not found on PATH",
3760
+ support
3761
+ );
3762
+ }
3763
+ async run(args, timeoutMs = 3e5) {
3764
+ if (this.binary === null) this.binary = await this.findCli();
3765
+ try {
3766
+ const { stdout } = await execFileAsync(this.binary, [this.command, ...args], {
3767
+ timeout: timeoutMs,
3768
+ env: { ...process.env, ...this.envOverrides },
3769
+ maxBuffer: 16 * 1024 * 1024
3770
+ });
3771
+ return stdout;
3772
+ } catch (error) {
3773
+ const failure = error;
3774
+ if (failure.killed) {
3775
+ throw new MountError(`\`tl ${this.command} ${args[0]}\` timed out after ${timeoutMs}ms`);
3776
+ }
3777
+ const detail = (failure.stderr || failure.stdout || String(error)).trim();
3778
+ throw new MountError(`\`tl ${this.command} ${args.join(" ")}\` failed: ${detail}`);
3779
+ }
3780
+ }
3781
+ };
3782
+
3783
+ // src/filesystem.ts
3784
+ init_defaults();
3785
+
3727
3786
  // src/native-sandbox.ts
3728
3787
  init_esm_shims();
3729
3788
  init_errors();
@@ -3947,7 +4006,7 @@ function createWorkerBinding(runtime) {
3947
4006
  };
3948
4007
  }
3949
4008
  var runtimeKey = /* @__PURE__ */ Symbol.for(
3950
- `tensorlake.native.worker.${false ? "source" : "0.5.126"}.v1`
4009
+ `tensorlake.native.worker.${false ? "source" : "0.5.127"}.v1`
3951
4010
  );
3952
4011
  var runtimes = globalThis;
3953
4012
  function workerBinding() {
@@ -3964,7 +4023,6 @@ function loadNativeSandboxBinding() {
3964
4023
 
3965
4024
  // src/filesystem.ts
3966
4025
  init_sandbox_image();
3967
- var execFileAsync = promisify(execFile);
3968
4026
  var FILESYSTEM_REPO_KIND = "filesystem";
3969
4027
  function translateNativeError(error, notFound) {
3970
4028
  const message = error instanceof Error ? error.message : String(error);
@@ -3996,58 +4054,9 @@ async function callNative(fn, notFound) {
3996
4054
  throw translateNativeError(error, notFound);
3997
4055
  }
3998
4056
  }
3999
- var FsCli = class {
4000
- binary = null;
4001
- envOverrides;
4057
+ var FsCli = class extends MountCli {
4002
4058
  constructor(envOverrides) {
4003
- this.envOverrides = envOverrides;
4004
- }
4005
- async findCli() {
4006
- const candidates = [];
4007
- if (process.env.TENSORLAKE_CLI) {
4008
- candidates.push(process.env.TENSORLAKE_CLI);
4009
- }
4010
- candidates.push("tl");
4011
- const installed = join(homedir(), ".tensorlake", "bin", "tl");
4012
- try {
4013
- accessSync(installed, constants.F_OK);
4014
- candidates.push(installed);
4015
- } catch {
4016
- }
4017
- let unsupported = null;
4018
- for (const candidate of candidates) {
4019
- try {
4020
- await execFileAsync(candidate, ["fs", "--help"], { timeout: 15e3 });
4021
- return candidate;
4022
- } catch (error) {
4023
- if (error.code !== "ENOENT") {
4024
- unsupported = candidate;
4025
- }
4026
- }
4027
- }
4028
- throw new CliNotFoundError(
4029
- unsupported ? `\`tl\` at ${unsupported} does not support \`tl fs\` (upgrade required)` : "`tl` was not found on PATH"
4030
- );
4031
- }
4032
- async run(args, timeoutMs = 3e5) {
4033
- if (this.binary === null) {
4034
- this.binary = await this.findCli();
4035
- }
4036
- try {
4037
- const { stdout } = await execFileAsync(this.binary, ["fs", ...args], {
4038
- timeout: timeoutMs,
4039
- env: { ...process.env, ...this.envOverrides },
4040
- maxBuffer: 16 * 1024 * 1024
4041
- });
4042
- return stdout;
4043
- } catch (error) {
4044
- const failure = error;
4045
- if (failure.killed) {
4046
- throw new MountError(`\`tl fs ${args[0]}\` timed out after ${timeoutMs}ms`);
4047
- }
4048
- const detail = (failure.stderr || failure.stdout || String(error)).trim();
4049
- throw new MountError(`\`tl fs ${args.join(" ")}\` failed: ${detail}`);
4050
- }
4059
+ super("fs", envOverrides);
4051
4060
  }
4052
4061
  // Flags always precede a `--` end-of-options separator so caller-supplied
4053
4062
  // names/paths can never be parsed as CLI flags (e.g. a path literally