tensorlake 0.5.140 → 0.5.141
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.
- package/dist/applications/index.cjs +80 -55
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.js +80 -55
- package/dist/applications/index.js.map +1 -1
- package/dist/function-agent/main.cjs +1 -1
- package/dist/function-agent/main.js +1 -1
- package/dist/function-executor/main.cjs +2 -2
- package/dist/function-executor/main.js +2 -2
- package/dist/index.cjs +251 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -10
- package/dist/index.d.ts +77 -10
- package/dist/index.js +248 -131
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +80 -55
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +80 -55
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +7 -7
- package/runtime/function-executor/manifest.json +5 -5
- package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
- package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
- package/runtime/function-executor/package/package.json +1 -1
- package/runtime/typescript-function-runner/manifest.json +5 -5
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +20 -20
- package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/sandbox-image.js
CHANGED
|
@@ -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.
|
|
49
|
+
SDK_VERSION = "0.5.141";
|
|
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";
|
|
@@ -57,6 +57,56 @@ var init_defaults = __esm({
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
// src/models.ts
|
|
61
|
+
function snakeToCamel(str) {
|
|
62
|
+
return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
63
|
+
}
|
|
64
|
+
function parseTimestamp(v) {
|
|
65
|
+
if (v == null) return void 0;
|
|
66
|
+
if (v instanceof Date) return v;
|
|
67
|
+
if (typeof v === "string") {
|
|
68
|
+
const parsed = Date.parse(v);
|
|
69
|
+
return Number.isNaN(parsed) ? void 0 : new Date(parsed);
|
|
70
|
+
}
|
|
71
|
+
const ts = Number(v);
|
|
72
|
+
if (isNaN(ts)) return void 0;
|
|
73
|
+
if (ts > 1e15) return new Date(ts / 1e3);
|
|
74
|
+
if (ts > 1e12) return new Date(ts);
|
|
75
|
+
return new Date(ts * 1e3);
|
|
76
|
+
}
|
|
77
|
+
function fromSnakeKeys(obj, idField) {
|
|
78
|
+
if (Array.isArray(obj))
|
|
79
|
+
return obj.map((item) => fromSnakeKeys(item, idField));
|
|
80
|
+
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
81
|
+
const result = {};
|
|
82
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
83
|
+
let key;
|
|
84
|
+
if (k === "id" && idField) {
|
|
85
|
+
key = idField;
|
|
86
|
+
} else {
|
|
87
|
+
key = snakeToCamel(k);
|
|
88
|
+
}
|
|
89
|
+
if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
|
|
90
|
+
result[key] = parseTimestamp(v);
|
|
91
|
+
} else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
|
|
92
|
+
result[key] = fromSnakeKeys(v);
|
|
93
|
+
} else if (Array.isArray(v)) {
|
|
94
|
+
result[key] = v.map((item) => fromSnakeKeys(item));
|
|
95
|
+
} else {
|
|
96
|
+
result[key] = v === null ? void 0 : v;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
return obj;
|
|
102
|
+
}
|
|
103
|
+
var init_models = __esm({
|
|
104
|
+
"src/models.ts"() {
|
|
105
|
+
"use strict";
|
|
106
|
+
init_esm_shims();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
60
110
|
// src/errors.ts
|
|
61
111
|
function formatErrorDetails(errorDetails) {
|
|
62
112
|
if (errorDetails == null) return void 0;
|
|
@@ -79,7 +129,7 @@ function formatErrorDetails(errorDetails) {
|
|
|
79
129
|
}
|
|
80
130
|
return String(errorDetails);
|
|
81
131
|
}
|
|
82
|
-
var SandboxException, SandboxError, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError;
|
|
132
|
+
var SandboxException, SandboxError, SandboxResizeError, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError;
|
|
83
133
|
var init_errors = __esm({
|
|
84
134
|
"src/errors.ts"() {
|
|
85
135
|
"use strict";
|
|
@@ -100,6 +150,25 @@ var init_errors = __esm({
|
|
|
100
150
|
if (options?.sandboxId !== void 0) this.sandboxId = options.sandboxId;
|
|
101
151
|
}
|
|
102
152
|
};
|
|
153
|
+
SandboxResizeError = class extends SandboxError {
|
|
154
|
+
generation;
|
|
155
|
+
info;
|
|
156
|
+
constructor(payload) {
|
|
157
|
+
const resources = payload.info?.resources;
|
|
158
|
+
const allocation = resources ? `${resources.cpus} CPUs, ${resources.memoryMb} MiB memory, ${resources.diskMb} MiB disk` : "unavailable";
|
|
159
|
+
super(
|
|
160
|
+
`Sandbox ${payload.sandboxId} resize generation ${payload.generation}: ${payload.message}; last confirmed allocation: ${allocation}`,
|
|
161
|
+
{ reason: payload.reason, sandboxId: payload.sandboxId }
|
|
162
|
+
);
|
|
163
|
+
this.name = "SandboxResizeError";
|
|
164
|
+
this.generation = payload.generation;
|
|
165
|
+
this.info = payload.info ?? void 0;
|
|
166
|
+
}
|
|
167
|
+
/** Last confirmed allocation, if an observation was available. */
|
|
168
|
+
get confirmedResources() {
|
|
169
|
+
return this.info?.resources;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
103
172
|
SandboxConnectionError = class extends SandboxError {
|
|
104
173
|
constructor(message, options) {
|
|
105
174
|
super(`Connection error: ${message}`);
|
|
@@ -421,7 +490,7 @@ var init_native_worker_client = __esm({
|
|
|
421
490
|
}
|
|
422
491
|
};
|
|
423
492
|
runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
424
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
493
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.141"}.v1`
|
|
425
494
|
);
|
|
426
495
|
runtimes = globalThis;
|
|
427
496
|
}
|
|
@@ -454,6 +523,11 @@ function translateNativeError(error, context) {
|
|
|
454
523
|
return new SandboxError(String(error));
|
|
455
524
|
}
|
|
456
525
|
const { category, status, message } = payload;
|
|
526
|
+
if (category === "resize") {
|
|
527
|
+
return new SandboxResizeError(
|
|
528
|
+
fromSnakeKeys(JSON.parse(message), "sandboxId")
|
|
529
|
+
);
|
|
530
|
+
}
|
|
457
531
|
if (category === "connection") {
|
|
458
532
|
return new SandboxConnectionError(message, { cause: error });
|
|
459
533
|
}
|
|
@@ -544,6 +618,7 @@ var init_native_sandbox = __esm({
|
|
|
544
618
|
"src/native-sandbox.ts"() {
|
|
545
619
|
"use strict";
|
|
546
620
|
init_esm_shims();
|
|
621
|
+
init_models();
|
|
547
622
|
init_errors();
|
|
548
623
|
init_native_worker_client();
|
|
549
624
|
init_native_worker_protocol();
|
|
@@ -634,56 +709,6 @@ var init_native_cloud = __esm({
|
|
|
634
709
|
}
|
|
635
710
|
});
|
|
636
711
|
|
|
637
|
-
// src/models.ts
|
|
638
|
-
function snakeToCamel(str) {
|
|
639
|
-
return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
640
|
-
}
|
|
641
|
-
function parseTimestamp(v) {
|
|
642
|
-
if (v == null) return void 0;
|
|
643
|
-
if (v instanceof Date) return v;
|
|
644
|
-
if (typeof v === "string") {
|
|
645
|
-
const parsed = Date.parse(v);
|
|
646
|
-
return Number.isNaN(parsed) ? void 0 : new Date(parsed);
|
|
647
|
-
}
|
|
648
|
-
const ts = Number(v);
|
|
649
|
-
if (isNaN(ts)) return void 0;
|
|
650
|
-
if (ts > 1e15) return new Date(ts / 1e3);
|
|
651
|
-
if (ts > 1e12) return new Date(ts);
|
|
652
|
-
return new Date(ts * 1e3);
|
|
653
|
-
}
|
|
654
|
-
function fromSnakeKeys(obj, idField) {
|
|
655
|
-
if (Array.isArray(obj))
|
|
656
|
-
return obj.map((item) => fromSnakeKeys(item, idField));
|
|
657
|
-
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
658
|
-
const result = {};
|
|
659
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
660
|
-
let key;
|
|
661
|
-
if (k === "id" && idField) {
|
|
662
|
-
key = idField;
|
|
663
|
-
} else {
|
|
664
|
-
key = snakeToCamel(k);
|
|
665
|
-
}
|
|
666
|
-
if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
|
|
667
|
-
result[key] = parseTimestamp(v);
|
|
668
|
-
} else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
|
|
669
|
-
result[key] = fromSnakeKeys(v);
|
|
670
|
-
} else if (Array.isArray(v)) {
|
|
671
|
-
result[key] = v.map((item) => fromSnakeKeys(item));
|
|
672
|
-
} else {
|
|
673
|
-
result[key] = v === null ? void 0 : v;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
return result;
|
|
677
|
-
}
|
|
678
|
-
return obj;
|
|
679
|
-
}
|
|
680
|
-
var init_models = __esm({
|
|
681
|
-
"src/models.ts"() {
|
|
682
|
-
"use strict";
|
|
683
|
-
init_esm_shims();
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
|
|
687
712
|
// src/cloud-client.ts
|
|
688
713
|
import { nanoid } from "nanoid";
|
|
689
714
|
function secretFromMetadata(metadata) {
|
|
@@ -1850,7 +1875,7 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
1850
1875
|
const dockerfilePath = parsed.positionals[0];
|
|
1851
1876
|
if (!dockerfilePath) {
|
|
1852
1877
|
throw new Error(
|
|
1853
|
-
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory
|
|
1878
|
+
"Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
1854
1879
|
);
|
|
1855
1880
|
}
|
|
1856
1881
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|
|
@@ -1902,7 +1927,7 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
|
|
|
1902
1927
|
const imageReference = parsed.positionals[0];
|
|
1903
1928
|
if (!imageReference) {
|
|
1904
1929
|
throw new Error(
|
|
1905
|
-
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory
|
|
1930
|
+
"Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
|
|
1906
1931
|
);
|
|
1907
1932
|
}
|
|
1908
1933
|
const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
|