@tensorlakeai/tensorlake 0.5.159 → 0.5.160

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.
Files changed (29) hide show
  1. package/dist/applications/index.cjs +7 -2
  2. package/dist/applications/index.cjs.map +1 -1
  3. package/dist/applications/index.js +7 -2
  4. package/dist/applications/index.js.map +1 -1
  5. package/dist/function-agent/main.cjs +1 -1
  6. package/dist/function-agent/main.cjs.map +1 -1
  7. package/dist/function-agent/main.js +1 -1
  8. package/dist/function-agent/main.js.map +1 -1
  9. package/dist/function-executor/main.cjs +2 -2
  10. package/dist/function-executor/main.cjs.map +1 -1
  11. package/dist/function-executor/main.js +2 -2
  12. package/dist/function-executor/main.js.map +1 -1
  13. package/dist/index.cjs +62 -2
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +136 -1
  16. package/dist/index.d.ts +136 -1
  17. package/dist/index.js +61 -2
  18. package/dist/index.js.map +1 -1
  19. package/package.json +7 -7
  20. package/runtime/function-executor/manifest.json +7 -7
  21. package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
  22. package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -1
  23. package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
  24. package/runtime/function-executor/package/package.json +1 -1
  25. package/runtime/typescript-function-runner/manifest.json +7 -7
  26. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
  27. package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -1
  28. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
  29. package/runtime/typescript-function-runner/package/package.json +7 -7
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.159";
52
+ SDK_VERSION = "0.5.160";
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";
@@ -333,6 +333,11 @@ function createWorkerBinding(runtime) {
333
333
  return runtime.handle("NativeRepositoryClient", args);
334
334
  }
335
335
  },
336
+ NativeUsageClient: class {
337
+ constructor(...args) {
338
+ return runtime.handle("NativeUsageClient", args);
339
+ }
340
+ },
336
341
  NativeTcpTunnel: class {
337
342
  constructor() {
338
343
  return runtime.handle("NativeTcpTunnel", []);
@@ -517,7 +522,7 @@ var init_native_worker_client = __esm({
517
522
  }
518
523
  };
519
524
  runtimeKey = /* @__PURE__ */ Symbol.for(
520
- `tensorlake.native.worker.${false ? "source" : "0.5.159"}.v1`
525
+ `tensorlake.native.worker.${false ? "source" : "0.5.160"}.v1`
521
526
  );
522
527
  runtimes = globalThis;
523
528
  }
@@ -7165,6 +7170,7 @@ __export(index_exports, {
7165
7170
  TERMINATION_REASON_CANCELLED: () => TERMINATION_REASON_CANCELLED,
7166
7171
  TERMINATION_REASON_NO_CAPACITY: () => TERMINATION_REASON_NO_CAPACITY,
7167
7172
  TcpTunnel: () => TcpTunnel,
7173
+ UsageClient: () => UsageClient,
7168
7174
  cancelImageBuild: () => cancelImageBuild,
7169
7175
  createFileSystem: () => createFileSystem,
7170
7176
  createSandboxImage: () => createSandboxImage,
@@ -8889,6 +8895,59 @@ function validateTimeoutMs2(timeoutMs) {
8889
8895
  }
8890
8896
  }
8891
8897
 
8898
+ // src/usage.ts
8899
+ init_cjs_shims();
8900
+ init_defaults();
8901
+ init_errors();
8902
+ init_native_sandbox();
8903
+ init_native_worker_client();
8904
+ var UsageClient = class {
8905
+ native;
8906
+ constructor(options) {
8907
+ const apiKey = options?.apiKey ?? API_KEY;
8908
+ if (!apiKey) {
8909
+ throw new SandboxError("Missing TENSORLAKE_API_KEY credentials.");
8910
+ }
8911
+ const organizationId = options?.organizationId ?? process.env.TENSORLAKE_ORGANIZATION_ID;
8912
+ if (!organizationId) {
8913
+ throw new SandboxError(
8914
+ "An organization ID is required. Pass organizationId or set TENSORLAKE_ORGANIZATION_ID."
8915
+ );
8916
+ }
8917
+ const binding = loadNativeSandboxBinding();
8918
+ if (typeof binding.NativeUsageClient !== "function") {
8919
+ throw new SandboxError(
8920
+ "native binding does not export the usage client; rebuild with 'npm run build:native'"
8921
+ );
8922
+ }
8923
+ this.native = new binding.NativeUsageClient(
8924
+ options?.apiUrl ?? API_URL,
8925
+ apiKey,
8926
+ organizationId,
8927
+ `tensorlake-typescript-sdk/${SDK_VERSION}`,
8928
+ DEFAULT_HTTP_TIMEOUT_MS / 1e3
8929
+ );
8930
+ }
8931
+ close() {
8932
+ releaseNativeHandle(this.native);
8933
+ }
8934
+ /** Organization usage totals for the window. */
8935
+ async summary(options) {
8936
+ const { json } = await callNative(() => this.native.summary(options?.last ?? null));
8937
+ return JSON.parse(json);
8938
+ }
8939
+ /**
8940
+ * Usage and attributed cost of every sandbox that ran in the window.
8941
+ *
8942
+ * The server computes the attribution once and returns every sandbox in one
8943
+ * response.
8944
+ */
8945
+ async sandboxes(options) {
8946
+ const { json } = await callNative(() => this.native.sandboxes(options?.last ?? null));
8947
+ return JSON.parse(json);
8948
+ }
8949
+ };
8950
+
8892
8951
  // src/index.ts
8893
8952
  init_sandbox_image();
8894
8953
  init_image_builds();
@@ -10802,6 +10861,7 @@ init_models();
10802
10861
  TERMINATION_REASON_CANCELLED,
10803
10862
  TERMINATION_REASON_NO_CAPACITY,
10804
10863
  TcpTunnel,
10864
+ UsageClient,
10805
10865
  cancelImageBuild,
10806
10866
  createFileSystem,
10807
10867
  createSandboxImage,