@tensorlakeai/tensorlake 0.5.159 → 0.5.161

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 +66 -2
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +145 -1
  16. package/dist/index.d.ts +145 -1
  17. package/dist/index.js +65 -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.161";
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.161"}.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,63 @@ 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
+ function nativeWindow(options) {
8905
+ const iso = (value) => value === void 0 ? null : value instanceof Date ? value.toISOString() : value;
8906
+ return [options?.last ?? null, iso(options?.fromDate), iso(options?.toDate)];
8907
+ }
8908
+ var UsageClient = class {
8909
+ native;
8910
+ constructor(options) {
8911
+ const apiKey = options?.apiKey ?? API_KEY;
8912
+ if (!apiKey) {
8913
+ throw new SandboxError("Missing TENSORLAKE_API_KEY credentials.");
8914
+ }
8915
+ const organizationId = options?.organizationId ?? process.env.TENSORLAKE_ORGANIZATION_ID;
8916
+ if (!organizationId) {
8917
+ throw new SandboxError(
8918
+ "An organization ID is required. Pass organizationId or set TENSORLAKE_ORGANIZATION_ID."
8919
+ );
8920
+ }
8921
+ const binding = loadNativeSandboxBinding();
8922
+ if (typeof binding.NativeUsageClient !== "function") {
8923
+ throw new SandboxError(
8924
+ "native binding does not export the usage client; rebuild with 'npm run build:native'"
8925
+ );
8926
+ }
8927
+ this.native = new binding.NativeUsageClient(
8928
+ options?.apiUrl ?? API_URL,
8929
+ apiKey,
8930
+ organizationId,
8931
+ `tensorlake-typescript-sdk/${SDK_VERSION}`,
8932
+ DEFAULT_HTTP_TIMEOUT_MS / 1e3
8933
+ );
8934
+ }
8935
+ close() {
8936
+ releaseNativeHandle(this.native);
8937
+ }
8938
+ /** Organization usage totals for the window. */
8939
+ async summary(options) {
8940
+ const { json } = await callNative(() => this.native.summary(...nativeWindow(options)));
8941
+ return JSON.parse(json);
8942
+ }
8943
+ /**
8944
+ * Usage and attributed cost of every sandbox that ran in the window.
8945
+ *
8946
+ * The server computes the attribution once and returns every sandbox in one
8947
+ * response.
8948
+ */
8949
+ async sandboxes(options) {
8950
+ const { json } = await callNative(() => this.native.sandboxes(...nativeWindow(options)));
8951
+ return JSON.parse(json);
8952
+ }
8953
+ };
8954
+
8892
8955
  // src/index.ts
8893
8956
  init_sandbox_image();
8894
8957
  init_image_builds();
@@ -10802,6 +10865,7 @@ init_models();
10802
10865
  TERMINATION_REASON_CANCELLED,
10803
10866
  TERMINATION_REASON_NO_CAPACITY,
10804
10867
  TcpTunnel,
10868
+ UsageClient,
10805
10869
  cancelImageBuild,
10806
10870
  createFileSystem,
10807
10871
  createSandboxImage,