@tensorlakeai/tensorlake 0.5.153 → 0.5.154
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 +131 -33
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.js +131 -33
- 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 +195 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -15
- package/dist/index.d.ts +70 -15
- package/dist/index.js +190 -61
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +129 -31
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +129 -31
- 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 +26 -26
- package/runtime/typescript-function-runner/package/package.json +7 -7
|
@@ -189,7 +189,24 @@ var init_native_binding = __esm({
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
+
// src/enum.ts
|
|
193
|
+
function enumValue(values, value) {
|
|
194
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
195
|
+
}
|
|
196
|
+
function withRaw(value, raw) {
|
|
197
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
198
|
+
}
|
|
199
|
+
var init_enum = __esm({
|
|
200
|
+
"src/enum.ts"() {
|
|
201
|
+
"use strict";
|
|
202
|
+
init_cjs_shims();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
192
206
|
// src/image-builds.ts
|
|
207
|
+
function isConfirmedCancellation(outcome) {
|
|
208
|
+
return outcome === "cancelled" /* CANCELLED */ || outcome === "already_cancelled" /* ALREADY_CANCELLED */ || outcome === "already_failed" /* ALREADY_FAILED */;
|
|
209
|
+
}
|
|
193
210
|
function camelize(key) {
|
|
194
211
|
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
195
212
|
}
|
|
@@ -207,48 +224,73 @@ function toImageBuildError(error) {
|
|
|
207
224
|
if (key === "category") continue;
|
|
208
225
|
details[camelize(key)] = value;
|
|
209
226
|
}
|
|
227
|
+
details.code = enumValue(ImageBuildErrorCode, details.code || "internal" /* INTERNAL */);
|
|
228
|
+
if ("activeKind" in details) details.activeKind = details.activeKind ? enumValue(ImageBuildKind, details.activeKind) : null;
|
|
229
|
+
if ("activeStatus" in details) details.activeStatus = details.activeStatus ? enumValue(ImageBuildStatus, details.activeStatus) : null;
|
|
230
|
+
if ("outcome" in details) details.outcome = details.outcome ? enumValue(ImageBuildCancellationOutcome, details.outcome) : null;
|
|
231
|
+
if ("info" in details) details.info = buildInfoOrNull(details.info);
|
|
210
232
|
const typed = details;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return new ImageBuildTimeoutError(typed);
|
|
222
|
-
case "interrupted":
|
|
223
|
-
return new ImageBuildInterruptedError(typed);
|
|
224
|
-
default:
|
|
225
|
-
return new ImageBuildError(typed);
|
|
226
|
-
}
|
|
233
|
+
const errors = {
|
|
234
|
+
not_found: ImageBuildNotFoundError,
|
|
235
|
+
image_build_in_progress: ImageBuildInProgressError,
|
|
236
|
+
failed: ImageBuildFailedError,
|
|
237
|
+
cancelled: ImageBuildCancelledError,
|
|
238
|
+
timeout: ImageBuildTimeoutError,
|
|
239
|
+
interrupted: ImageBuildInterruptedError
|
|
240
|
+
};
|
|
241
|
+
const ErrorClass = errors[typed.code] ?? ImageBuildError;
|
|
242
|
+
return withRaw(new ErrorClass(typed), payload);
|
|
227
243
|
}
|
|
228
244
|
function camelizeRecord(value) {
|
|
229
245
|
const out = {};
|
|
230
246
|
for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
|
|
231
247
|
return out;
|
|
232
248
|
}
|
|
233
|
-
function
|
|
249
|
+
function buildInfoOrNull(value) {
|
|
250
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
251
|
+
try {
|
|
252
|
+
return parseBuildInfo(value);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if (error instanceof ImageBuildError) return null;
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function decodeResponse(value) {
|
|
259
|
+
try {
|
|
260
|
+
const raw = typeof value === "string" ? JSON.parse(value) : value;
|
|
261
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new TypeError("expected a response object");
|
|
262
|
+
return raw;
|
|
263
|
+
} catch (error) {
|
|
264
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: `Invalid image-build response: ${String(error)}` }), { response: value });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function parseBuildInfo(value) {
|
|
268
|
+
const raw = decodeResponse(value);
|
|
269
|
+
if (raw.status == null) {
|
|
270
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build response: missing status" }), { response: value });
|
|
271
|
+
}
|
|
272
|
+
const attempt = raw.attempt_no ?? 0;
|
|
273
|
+
const attemptNo = Number(attempt);
|
|
274
|
+
if (typeof attempt !== "number" && typeof attempt !== "string" || typeof attempt === "string" && attempt.trim() === "" || !Number.isSafeInteger(attemptNo)) {
|
|
275
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build attempt_no" }), { response: value });
|
|
276
|
+
}
|
|
234
277
|
const camel = camelizeRecord(raw);
|
|
235
278
|
const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
|
|
236
|
-
return {
|
|
279
|
+
return withRaw({
|
|
237
280
|
buildId: String(raw.build_id ?? ""),
|
|
238
281
|
clientRequestId: camel.clientRequestId ?? null,
|
|
239
|
-
kind:
|
|
282
|
+
kind: raw.kind ? enumValue(ImageBuildKind, raw.kind) : null,
|
|
240
283
|
name: raw.name ?? null,
|
|
241
|
-
status:
|
|
242
|
-
phase: raw.phase
|
|
243
|
-
attemptNo
|
|
284
|
+
status: enumValue(ImageBuildStatus, raw.status),
|
|
285
|
+
phase: raw.phase ? enumValue(ImageBuildPhase, raw.phase) : null,
|
|
286
|
+
attemptNo,
|
|
244
287
|
builderSandboxId: camel.builderSandboxId ?? null,
|
|
245
288
|
error: raw.error ?? null,
|
|
246
289
|
result,
|
|
247
290
|
operationDeadlineMs: camel.operationDeadlineMs ?? null,
|
|
248
291
|
createdAtMs: camel.createdAtMs ?? null,
|
|
249
|
-
updatedAtMs: camel.updatedAtMs ?? null
|
|
250
|
-
|
|
251
|
-
};
|
|
292
|
+
updatedAtMs: camel.updatedAtMs ?? null
|
|
293
|
+
}, raw);
|
|
252
294
|
}
|
|
253
295
|
async function __runWithInterrupt(signal, run) {
|
|
254
296
|
const binding = __imageBuildInternals.loadNativeBinding();
|
|
@@ -272,16 +314,68 @@ async function __runWithInterrupt(signal, run) {
|
|
|
272
314
|
binding.releaseImageBuildInterrupt(interruptId);
|
|
273
315
|
}
|
|
274
316
|
}
|
|
275
|
-
var import_node_path2, import_node_os, import_node_fs, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
317
|
+
var import_node_path2, import_node_os, import_node_fs, ImageBuildStatus, ImageBuildPhase, ImageBuildKind, ImageBuildCancellationOutcome, ImageBuildErrorCode, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
|
|
276
318
|
var init_image_builds = __esm({
|
|
277
319
|
"src/image-builds.ts"() {
|
|
278
320
|
"use strict";
|
|
279
321
|
init_cjs_shims();
|
|
280
322
|
import_node_path2 = __toESM(require("path"), 1);
|
|
323
|
+
init_enum();
|
|
281
324
|
import_node_os = __toESM(require("os"), 1);
|
|
282
325
|
import_node_fs = require("fs");
|
|
283
326
|
init_image();
|
|
284
327
|
init_sandbox_image();
|
|
328
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
329
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
330
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
331
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
332
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
333
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
334
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
335
|
+
return ImageBuildStatus2;
|
|
336
|
+
})(ImageBuildStatus || {});
|
|
337
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
338
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
339
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
340
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
341
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
342
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
343
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
344
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
345
|
+
return ImageBuildPhase2;
|
|
346
|
+
})(ImageBuildPhase || {});
|
|
347
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
348
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
349
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
350
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
351
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
352
|
+
return ImageBuildKind2;
|
|
353
|
+
})(ImageBuildKind || {});
|
|
354
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
355
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
356
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
357
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
358
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
359
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
360
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
361
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
362
|
+
return ImageBuildCancellationOutcome2;
|
|
363
|
+
})(ImageBuildCancellationOutcome || {});
|
|
364
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
365
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
366
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
367
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
368
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
369
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
370
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
371
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
372
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
373
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
374
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
375
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
376
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
377
|
+
return ImageBuildErrorCode2;
|
|
378
|
+
})(ImageBuildErrorCode || {});
|
|
285
379
|
ImageBuildError = class extends Error {
|
|
286
380
|
code;
|
|
287
381
|
buildId;
|
|
@@ -291,7 +385,11 @@ var init_image_builds = __esm({
|
|
|
291
385
|
super(details.message);
|
|
292
386
|
this.name = "ImageBuildError";
|
|
293
387
|
this.code = details.code;
|
|
294
|
-
this.details = details;
|
|
388
|
+
this.details = { ...details };
|
|
389
|
+
withRaw(this, {});
|
|
390
|
+
if ("confirmed" in details) {
|
|
391
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
392
|
+
}
|
|
295
393
|
if (details.buildId) this.buildId = details.buildId;
|
|
296
394
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
297
395
|
}
|
|
@@ -323,7 +421,7 @@ var init_image_builds = __esm({
|
|
|
323
421
|
super(details);
|
|
324
422
|
this.name = "ImageBuildFailedError";
|
|
325
423
|
this.error = details.error ?? "no error recorded";
|
|
326
|
-
if (details.info) this.info =
|
|
424
|
+
if (details.info) this.info = details.info;
|
|
327
425
|
}
|
|
328
426
|
};
|
|
329
427
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -331,7 +429,7 @@ var init_image_builds = __esm({
|
|
|
331
429
|
constructor(details) {
|
|
332
430
|
super(details);
|
|
333
431
|
this.name = "ImageBuildCancelledError";
|
|
334
|
-
if (details.info) this.info =
|
|
432
|
+
if (details.info) this.info = details.info;
|
|
335
433
|
}
|
|
336
434
|
};
|
|
337
435
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -347,8 +445,8 @@ var init_image_builds = __esm({
|
|
|
347
445
|
constructor(details) {
|
|
348
446
|
super(details);
|
|
349
447
|
this.name = "ImageBuildInterruptedError";
|
|
350
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
351
|
-
this.confirmed = details.confirmed === true;
|
|
448
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
449
|
+
this.confirmed = this.details.confirmed === true;
|
|
352
450
|
if (details.result) this.result = details.result;
|
|
353
451
|
}
|
|
354
452
|
};
|
|
@@ -2437,7 +2535,7 @@ init_image();
|
|
|
2437
2535
|
|
|
2438
2536
|
// src/defaults.ts
|
|
2439
2537
|
init_cjs_shims();
|
|
2440
|
-
var SDK_VERSION = "0.5.
|
|
2538
|
+
var SDK_VERSION = "0.5.154";
|
|
2441
2539
|
var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
2442
2540
|
var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
2443
2541
|
var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -3245,7 +3343,7 @@ function createWorkerBinding(runtime) {
|
|
|
3245
3343
|
};
|
|
3246
3344
|
}
|
|
3247
3345
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
3248
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
3346
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
3249
3347
|
);
|
|
3250
3348
|
var runtimes = globalThis;
|
|
3251
3349
|
function workerBinding() {
|