@tensorlakeai/tensorlake 0.5.151 → 0.5.153

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 (42) hide show
  1. package/README.md +8 -0
  2. package/dist/applications/index.cjs +3510 -3384
  3. package/dist/applications/index.cjs.map +1 -1
  4. package/dist/applications/index.d.cts +3 -3
  5. package/dist/applications/index.d.ts +3 -3
  6. package/dist/applications/index.js +3286 -3160
  7. package/dist/applications/index.js.map +1 -1
  8. package/dist/function-agent/main.cjs +1 -1
  9. package/dist/function-agent/main.cjs.map +1 -1
  10. package/dist/function-agent/main.js +1 -1
  11. package/dist/function-agent/main.js.map +1 -1
  12. package/dist/function-executor/main.cjs +2 -2
  13. package/dist/function-executor/main.cjs.map +1 -1
  14. package/dist/function-executor/main.js +2 -2
  15. package/dist/function-executor/main.js.map +1 -1
  16. package/dist/index.cjs +1424 -1079
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +313 -27
  19. package/dist/index.d.ts +313 -27
  20. package/dist/index.js +1401 -1069
  21. package/dist/index.js.map +1 -1
  22. package/dist/{remote-CC48cvYP.d.cts → remote-B3vn4tt1.d.cts} +1 -1
  23. package/dist/{remote-BbSrvgUn.d.ts → remote-DqBUuciu.d.ts} +1 -1
  24. package/dist/{sandbox-image-CAK_K7ND.d.cts → sandbox-image-BMiFlzAs.d.cts} +168 -13
  25. package/dist/{sandbox-image-CAK_K7ND.d.ts → sandbox-image-BMiFlzAs.d.ts} +168 -13
  26. package/dist/sandbox-image.cjs +339 -1295
  27. package/dist/sandbox-image.cjs.map +1 -1
  28. package/dist/sandbox-image.d.cts +1 -1
  29. package/dist/sandbox-image.d.ts +1 -1
  30. package/dist/sandbox-image.js +338 -1294
  31. package/dist/sandbox-image.js.map +1 -1
  32. package/package.json +8 -7
  33. package/runtime/function-executor/manifest.json +7 -7
  34. package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
  35. package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -1
  36. package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
  37. package/runtime/function-executor/package/package.json +1 -1
  38. package/runtime/typescript-function-runner/manifest.json +7 -7
  39. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
  40. package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -1
  41. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
  42. package/runtime/typescript-function-runner/package/package.json +7 -7
@@ -43,1179 +43,6 @@ var init_cjs_shims = __esm({
43
43
  }
44
44
  });
45
45
 
46
- // src/defaults.ts
47
- var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TIMEOUT_MS, MAX_RETRIES, RETRY_BACKOFF_MS;
48
- var init_defaults = __esm({
49
- "src/defaults.ts"() {
50
- "use strict";
51
- init_cjs_shims();
52
- SDK_VERSION = "0.5.151";
53
- API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
54
- API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
55
- NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
56
- SANDBOX_PROXY_URL = process.env.TENSORLAKE_SANDBOX_PROXY_URL ?? "https://sandbox.tensorlake.ai";
57
- DEFAULT_HTTP_TIMEOUT_MS = 3e5;
58
- MAX_RETRIES = 3;
59
- RETRY_BACKOFF_MS = 500;
60
- }
61
- });
62
-
63
- // src/models.ts
64
- function snakeToCamel(str) {
65
- return str.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
66
- }
67
- function parseTimestamp(v) {
68
- if (v == null) return void 0;
69
- if (v instanceof Date) return v;
70
- if (typeof v === "string") {
71
- const parsed = Date.parse(v);
72
- return Number.isNaN(parsed) ? void 0 : new Date(parsed);
73
- }
74
- const ts = Number(v);
75
- if (isNaN(ts)) return void 0;
76
- if (ts > 1e15) return new Date(ts / 1e3);
77
- if (ts > 1e12) return new Date(ts);
78
- return new Date(ts * 1e3);
79
- }
80
- function fromSnakeKeys(obj, idField) {
81
- if (Array.isArray(obj))
82
- return obj.map((item) => fromSnakeKeys(item, idField));
83
- if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
84
- const result = {};
85
- for (const [k, v] of Object.entries(obj)) {
86
- let key;
87
- if (k === "id" && idField) {
88
- key = idField;
89
- } else {
90
- key = snakeToCamel(k);
91
- }
92
- if (key.endsWith("At") || key === "timestamp" || key === "startedAt" || key === "endedAt") {
93
- result[key] = parseTimestamp(v);
94
- } else if (typeof v === "object" && v !== null && !Array.isArray(v)) {
95
- result[key] = fromSnakeKeys(v);
96
- } else if (Array.isArray(v)) {
97
- result[key] = v.map((item) => fromSnakeKeys(item));
98
- } else {
99
- result[key] = v === null ? void 0 : v;
100
- }
101
- }
102
- return result;
103
- }
104
- return obj;
105
- }
106
- var CommandExitReason;
107
- var init_models = __esm({
108
- "src/models.ts"() {
109
- "use strict";
110
- init_cjs_shims();
111
- CommandExitReason = /* @__PURE__ */ ((CommandExitReason2) => {
112
- CommandExitReason2["EXITED"] = "exited";
113
- CommandExitReason2["SIGNALED"] = "signaled";
114
- CommandExitReason2["OOM_KILLED"] = "oom_killed";
115
- CommandExitReason2["TIMED_OUT"] = "timed_out";
116
- return CommandExitReason2;
117
- })(CommandExitReason || {});
118
- }
119
- });
120
-
121
- // src/errors.ts
122
- function formatErrorDetails(errorDetails) {
123
- if (errorDetails == null) return void 0;
124
- if (typeof errorDetails === "string") {
125
- const detail = errorDetails.trim();
126
- return detail || void 0;
127
- }
128
- if (Array.isArray(errorDetails)) {
129
- const parts = errorDetails.map((item) => formatErrorDetails(item)).filter((item) => Boolean(item));
130
- return parts.length > 0 ? parts.join("; ") : JSON.stringify(errorDetails);
131
- }
132
- if (typeof errorDetails === "object") {
133
- for (const key of ["message", "detail", "error", "reason"]) {
134
- const value = errorDetails[key];
135
- if (typeof value === "string" && value.trim()) {
136
- return value.trim();
137
- }
138
- }
139
- return JSON.stringify(errorDetails);
140
- }
141
- return String(errorDetails);
142
- }
143
- var SandboxException, SandboxError, SandboxResizeError, SandboxConnectionError, SandboxNotFoundError, PoolNotFoundError, PoolInUseError, RemoteAPIError;
144
- var init_errors = __esm({
145
- "src/errors.ts"() {
146
- "use strict";
147
- init_cjs_shims();
148
- SandboxException = class extends Error {
149
- constructor(message) {
150
- super(message);
151
- this.name = "SandboxException";
152
- }
153
- };
154
- SandboxError = class extends SandboxException {
155
- reason;
156
- sandboxId;
157
- constructor(message, options) {
158
- super(message);
159
- this.name = "SandboxError";
160
- if (options?.reason !== void 0) this.reason = options.reason;
161
- if (options?.sandboxId !== void 0) this.sandboxId = options.sandboxId;
162
- }
163
- };
164
- SandboxResizeError = class extends SandboxError {
165
- generation;
166
- info;
167
- constructor(payload) {
168
- const resources = payload.info?.resources;
169
- const allocation = resources ? `${resources.cpus} CPUs, ${resources.memoryMb} MiB memory, ${resources.diskMb} MiB disk` : "unavailable";
170
- super(
171
- `Sandbox ${payload.sandboxId} resize generation ${payload.generation}: ${payload.message}; last confirmed allocation: ${allocation}`,
172
- { reason: payload.reason, sandboxId: payload.sandboxId }
173
- );
174
- this.name = "SandboxResizeError";
175
- this.generation = payload.generation;
176
- this.info = payload.info ?? void 0;
177
- }
178
- /** Last confirmed allocation, if an observation was available. */
179
- get confirmedResources() {
180
- return this.info?.resources;
181
- }
182
- };
183
- SandboxConnectionError = class extends SandboxError {
184
- constructor(message, options) {
185
- super(`Connection error: ${message}`);
186
- this.name = "SandboxConnectionError";
187
- if (options?.cause !== void 0) this.cause = options.cause;
188
- }
189
- };
190
- SandboxNotFoundError = class extends SandboxError {
191
- constructor(sandboxId) {
192
- super(`Sandbox not found: ${sandboxId}`, { sandboxId });
193
- this.name = "SandboxNotFoundError";
194
- }
195
- };
196
- PoolNotFoundError = class extends SandboxError {
197
- poolId;
198
- constructor(poolId) {
199
- super(`Sandbox pool not found: ${poolId}`);
200
- this.name = "PoolNotFoundError";
201
- this.poolId = poolId;
202
- }
203
- };
204
- PoolInUseError = class extends SandboxError {
205
- poolId;
206
- constructor(poolId, message) {
207
- const base = `Cannot delete pool ${poolId}: pool is in use`;
208
- super(message ? `${base} - ${message}` : base);
209
- this.name = "PoolInUseError";
210
- this.poolId = poolId;
211
- }
212
- };
213
- RemoteAPIError = class extends SandboxError {
214
- statusCode;
215
- /** Original response body, retained for compatibility and diagnostics. */
216
- responseMessage;
217
- errorDetails;
218
- constructor(statusCode, message) {
219
- let failure;
220
- try {
221
- const payload = JSON.parse(message);
222
- if (payload && typeof payload === "object" && !Array.isArray(payload)) {
223
- const record = payload;
224
- if (typeof record.sandbox_id === "string" && record.sandbox_id.trim() && (record.status === "failed" || record.status === "terminated"))
225
- failure = record;
226
- }
227
- } catch {
228
- }
229
- const sandboxId = failure?.sandbox_id;
230
- const rawReason = failure?.reason ?? failure?.termination_reason;
231
- const reason = typeof rawReason === "string" ? rawReason : void 0;
232
- const errorDetails = failure?.error_details;
233
- let displayMessage = message;
234
- if (failure) {
235
- displayMessage = `Sandbox ${sandboxId} ${failure.status}`;
236
- if (reason) displayMessage += ` (${reason})`;
237
- const detail = formatErrorDetails(errorDetails);
238
- if (detail) displayMessage += `: ${detail}`;
239
- if (!reason && !detail) displayMessage = message;
240
- }
241
- super(`API error (status ${statusCode}): ${displayMessage}`, {
242
- reason,
243
- sandboxId
244
- });
245
- this.errorDetails = errorDetails;
246
- this.name = "RemoteAPIError";
247
- this.statusCode = statusCode;
248
- this.responseMessage = message;
249
- }
250
- };
251
- }
252
- });
253
-
254
- // src/native-worker-protocol.ts
255
- var cancelNativeCall, closeNativeHandle;
256
- var init_native_worker_protocol = __esm({
257
- "src/native-worker-protocol.ts"() {
258
- "use strict";
259
- init_cjs_shims();
260
- cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1");
261
- closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
262
- }
263
- });
264
-
265
- // src/url.ts
266
- function trimTrailingSlashes(url) {
267
- return url.endsWith("/") ? url.slice(0, -1) : url;
268
- }
269
- function resolveProxyTarget(proxyUrl, sandboxId) {
270
- try {
271
- const parsed = new URL(proxyUrl);
272
- const host = parsed.hostname;
273
- if (host === "localhost" || host === "127.0.0.1") {
274
- return {
275
- baseUrl: trimTrailingSlashes(proxyUrl),
276
- hostHeader: `${sandboxId}.local`,
277
- sandboxIdHeader: void 0
278
- };
279
- }
280
- const port = parsed.port ? `:${parsed.port}` : "";
281
- return {
282
- baseUrl: `${parsed.protocol}//${host}${port}`,
283
- hostHeader: void 0,
284
- sandboxIdHeader: sandboxId
285
- };
286
- } catch {
287
- return {
288
- baseUrl: `${trimTrailingSlashes(proxyUrl)}/${sandboxId}`,
289
- hostHeader: void 0,
290
- sandboxIdHeader: void 0
291
- };
292
- }
293
- }
294
- var init_url = __esm({
295
- "src/url.ts"() {
296
- "use strict";
297
- init_cjs_shims();
298
- init_defaults();
299
- }
300
- });
301
-
302
- // src/native-worker-client.ts
303
- function createWorkerBinding(runtime) {
304
- return {
305
- NativeCloudClient: class {
306
- constructor(...args) {
307
- return runtime.handle("NativeCloudClient", args);
308
- }
309
- },
310
- NativeSandboxClient: class {
311
- constructor(...args) {
312
- return runtime.handle("NativeSandboxClient", args);
313
- }
314
- },
315
- NativeSandboxProxyClient: class {
316
- constructor(...args) {
317
- return runtime.handle("NativeSandboxProxyClient", args);
318
- }
319
- },
320
- NativeRepositoryClient: class {
321
- constructor(...args) {
322
- return runtime.handle("NativeRepositoryClient", args);
323
- }
324
- },
325
- validateManagedName: (name) => runtime.call(void 0, "validateManagedName", [name])
326
- };
327
- }
328
- function workerBinding() {
329
- return createWorkerBinding(
330
- runtimes[runtimeKey] ??= new NativeWorkerClient()
331
- );
332
- }
333
- function releaseNativeHandle(handle) {
334
- handle?.[closeNativeHandle]?.();
335
- }
336
- var import_node_module, import_node_worker_threads, NativeWorkerClient, runtimeKey, runtimes;
337
- var init_native_worker_client = __esm({
338
- "src/native-worker-client.ts"() {
339
- "use strict";
340
- init_cjs_shims();
341
- import_node_module = require("module");
342
- import_node_worker_threads = require("worker_threads");
343
- init_native_worker_protocol();
344
- init_url();
345
- NativeWorkerClient = class {
346
- constructor(workerPath = () => (0, import_node_module.createRequire)(importMetaUrl).resolve(
347
- "@tensorlakeai/tensorlake/internal/native-worker"
348
- )) {
349
- this.workerPath = workerPath;
350
- }
351
- worker;
352
- nextId = 1;
353
- registered = /* @__PURE__ */ new Set();
354
- pending = /* @__PURE__ */ new Map();
355
- finalizers = new FinalizationRegistry(
356
- (id) => this.release(id)
357
- );
358
- handle(kind, args, parent) {
359
- const handle = { id: this.nextId++, kind, args, parent };
360
- this.finalizers.register(handle, handle.id);
361
- let closed = false;
362
- return new Proxy(
363
- {},
364
- {
365
- get: (_target, method) => {
366
- if (method === "then") return void 0;
367
- if (method === closeNativeHandle)
368
- return () => {
369
- closed = true;
370
- this.release(handle.id);
371
- };
372
- if (method === "connectProxy")
373
- return (...proxyArgs) => {
374
- if (closed) throw new Error("Tensorlake native client is closed");
375
- return this.handle("NativeSandboxProxyClient", proxyArgs, handle);
376
- };
377
- if (method === "baseUrl")
378
- return () => resolveProxyTarget(String(args[0]), String(args[1])).baseUrl;
379
- if (typeof method !== "string") return void 0;
380
- return (...callArgs) => {
381
- if (closed)
382
- return Promise.reject(
383
- new Error("Tensorlake native client is closed")
384
- );
385
- const emit = typeof callArgs.at(-1) === "function" ? callArgs.pop() : void 0;
386
- return this.call(handle, method, callArgs, emit);
387
- };
388
- }
389
- }
390
- );
391
- }
392
- call(handle, method, args, emit) {
393
- const id = this.nextId++;
394
- let worker;
395
- const promise = new Promise((resolve, reject) => {
396
- try {
397
- worker = this.getWorker();
398
- this.pending.set(id, { resolve, reject, emit, handle });
399
- worker.ref();
400
- if (handle) this.register(handle, worker);
401
- this.send(worker, {
402
- type: "call",
403
- id,
404
- handleId: handle?.id,
405
- method,
406
- args,
407
- stream: !!emit
408
- });
409
- } catch (error) {
410
- this.pending.delete(id);
411
- this.unrefIfIdle();
412
- reject(error);
413
- }
414
- });
415
- promise[cancelNativeCall] = () => {
416
- const pending = this.pending.get(id);
417
- if (pending && worker) {
418
- pending.emit = void 0;
419
- this.send(worker, { type: "cancel", id });
420
- }
421
- };
422
- return promise;
423
- }
424
- getWorker() {
425
- if (this.worker) return this.worker;
426
- const worker = new import_node_worker_threads.Worker(this.workerPath(), {
427
- // The bundled worker needs no application loaders or telemetry preloads.
428
- // NODE_OPTIONS is parsed independently of execArgv by Node.
429
- execArgv: [],
430
- env: { ...process.env, NODE_OPTIONS: "" },
431
- name: "tensorlake-native"
432
- });
433
- this.worker = worker;
434
- worker.on("message", (message) => {
435
- const pending = this.pending.get(message.id);
436
- if (!pending || this.worker !== worker) return;
437
- if (message.type === "event") {
438
- Promise.resolve().then(() => pending.emit?.(message.value)).then(
439
- () => {
440
- if (this.worker === worker)
441
- this.send(worker, { type: "ack", id: message.id });
442
- },
443
- (error) => {
444
- this.send(worker, { type: "cancel", id: message.id });
445
- pending.reject(error);
446
- }
447
- );
448
- return;
449
- }
450
- this.pending.delete(message.id);
451
- if (message.type === "error") {
452
- const error = new Error(message.error.message);
453
- error.name = message.error.name;
454
- error.stack = message.error.stack ?? error.stack;
455
- pending.reject(error);
456
- } else {
457
- pending.resolve(message.value);
458
- }
459
- this.unrefIfIdle();
460
- });
461
- const fail = (error) => {
462
- if (this.worker !== worker) return;
463
- this.worker = void 0;
464
- this.registered.clear();
465
- for (const pending of this.pending.values()) pending.reject(error);
466
- this.pending.clear();
467
- void worker.terminate();
468
- };
469
- worker.on("error", fail);
470
- worker.on("messageerror", fail);
471
- worker.on(
472
- "exit",
473
- (code) => fail(
474
- new Error(
475
- `Tensorlake native worker exited (${code}); in-flight operations were not retried`
476
- )
477
- )
478
- );
479
- worker.unref();
480
- return worker;
481
- }
482
- register(handle, worker) {
483
- if (this.registered.has(handle.id)) return;
484
- if (handle.parent) this.register(handle.parent, worker);
485
- this.send(worker, {
486
- type: "create",
487
- handle: { id: handle.id, kind: handle.kind, args: handle.args },
488
- parentId: handle.parent?.id
489
- });
490
- this.registered.add(handle.id);
491
- }
492
- release(handleId) {
493
- if (this.worker && this.registered.delete(handleId))
494
- this.send(this.worker, { type: "release", handleId });
495
- }
496
- send(worker, message) {
497
- worker.postMessage(message);
498
- }
499
- unrefIfIdle() {
500
- if (this.pending.size === 0) this.worker?.unref();
501
- }
502
- };
503
- runtimeKey = /* @__PURE__ */ Symbol.for(
504
- `tensorlake.native.worker.${false ? "source" : "0.5.151"}.v1`
505
- );
506
- runtimes = globalThis;
507
- }
508
- });
509
-
510
- // src/native-sandbox.ts
511
- function loadNativeSandboxBinding() {
512
- return cachedBinding ??= workerBinding();
513
- }
514
- function parseNativeError(error) {
515
- const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
516
- if (!message) return null;
517
- try {
518
- const parsed = JSON.parse(message);
519
- if (parsed && typeof parsed.category === "string") {
520
- return {
521
- category: parsed.category,
522
- status: typeof parsed.status === "number" ? parsed.status : null,
523
- message: typeof parsed.message === "string" ? parsed.message : message
524
- };
525
- }
526
- } catch {
527
- }
528
- return null;
529
- }
530
- function translateNativeError(error, context) {
531
- const payload = parseNativeError(error);
532
- if (!payload) {
533
- if (error instanceof Error) return error;
534
- return new SandboxError(String(error));
535
- }
536
- const { category, status, message } = payload;
537
- if (category === "resize") {
538
- return new SandboxResizeError(
539
- fromSnakeKeys(JSON.parse(message), "sandboxId")
540
- );
541
- }
542
- if (category === "connection") {
543
- return new SandboxConnectionError(message, { cause: error });
544
- }
545
- if (status === 404) {
546
- if (context?.notFoundKind === "pool" && context.poolId) {
547
- return new PoolNotFoundError(context.poolId);
548
- }
549
- if (context?.notFoundKind === "sandbox" && context.sandboxId) {
550
- return new SandboxNotFoundError(context.sandboxId);
551
- }
552
- return new RemoteAPIError(404, message);
553
- }
554
- if (status === 409 && context?.poolId) {
555
- return new PoolInUseError(context.poolId, message);
556
- }
557
- if (typeof status === "number") {
558
- return new RemoteAPIError(status, message);
559
- }
560
- return new SandboxError(message);
561
- }
562
- async function callNative(fn, context) {
563
- try {
564
- return await fn();
565
- } catch (error) {
566
- throw translateNativeError(error, context);
567
- }
568
- }
569
- async function* nativeEventStream(start, context, signal) {
570
- if (signal?.aborted) return;
571
- const queue = [];
572
- let wake;
573
- let finished = false;
574
- let stopped = false;
575
- let failure;
576
- const notify = () => {
577
- const resolve = wake;
578
- wake = void 0;
579
- resolve?.();
580
- };
581
- const emit = (value) => {
582
- if (stopped) return Promise.resolve();
583
- return new Promise((consumed) => {
584
- queue.push({ value, consumed });
585
- notify();
586
- });
587
- };
588
- let call;
589
- const onAbort = () => {
590
- stopped = true;
591
- call?.[cancelNativeCall]?.();
592
- notify();
593
- };
594
- signal?.addEventListener("abort", onAbort, { once: true });
595
- try {
596
- call = start(emit);
597
- void call.catch((error) => {
598
- failure = error;
599
- }).finally(() => {
600
- finished = true;
601
- notify();
602
- });
603
- while (!stopped) {
604
- const event = queue.shift();
605
- if (event) {
606
- try {
607
- yield JSON.parse(event.value);
608
- } finally {
609
- event.consumed();
610
- }
611
- } else if (finished) {
612
- break;
613
- } else {
614
- await new Promise((resolve) => {
615
- wake = resolve;
616
- });
617
- }
618
- }
619
- if (!stopped && failure !== void 0) throw translateNativeError(failure, context);
620
- } finally {
621
- stopped = true;
622
- signal?.removeEventListener("abort", onAbort);
623
- call?.[cancelNativeCall]?.();
624
- for (const event of queue) event.consumed();
625
- }
626
- }
627
- var cachedBinding, KNOWN_EXIT_REASONS;
628
- var init_native_sandbox = __esm({
629
- "src/native-sandbox.ts"() {
630
- "use strict";
631
- init_cjs_shims();
632
- init_models();
633
- init_errors();
634
- init_native_worker_client();
635
- init_native_worker_protocol();
636
- KNOWN_EXIT_REASONS = new Set(Object.values(CommandExitReason));
637
- }
638
- });
639
-
640
- // src/native-cloud.ts
641
- async function serializeRequest(method, path3, options) {
642
- const headers = { ...options?.headers };
643
- let body = options?.body;
644
- if (options?.json !== void 0) {
645
- body = JSON.stringify(options.json);
646
- if (!Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) {
647
- headers["Content-Type"] = "application/json";
648
- }
649
- }
650
- const request = {
651
- method,
652
- path: path3,
653
- headersJson: JSON.stringify(headers),
654
- statusOnlyCodes: [...options?.statusOnlyCodes ?? []]
655
- };
656
- if (body instanceof FormData) {
657
- request.parts = [];
658
- for (const [name, value] of body.entries()) {
659
- request.parts.push(typeof value === "string" ? { name, data: Buffer.from(value) } : { name, data: Buffer.from(await value.arrayBuffer()), filename: value.name, contentType: value.type || "application/octet-stream" });
660
- }
661
- } else if (body !== void 0) {
662
- if (body instanceof Blob) request.body = Buffer.from(await body.arrayBuffer());
663
- else if (typeof body === "string") request.body = Buffer.from(body);
664
- else if (body instanceof ArrayBuffer) request.body = Buffer.from(new Uint8Array(body));
665
- else request.body = Buffer.from(body);
666
- }
667
- return request;
668
- }
669
- var NativeCloudTransport;
670
- var init_native_cloud = __esm({
671
- "src/native-cloud.ts"() {
672
- "use strict";
673
- init_cjs_shims();
674
- init_native_sandbox();
675
- init_native_worker_client();
676
- NativeCloudTransport = class {
677
- constructor(options) {
678
- this.options = options;
679
- if (!Number.isSafeInteger(options.maxRetries) || options.maxRetries < 0 || options.maxRetries > 4294967295) {
680
- throw new RangeError("maxRetries must be a non-negative 32-bit integer");
681
- }
682
- if (!Number.isFinite(options.retryBackoffMs) || options.retryBackoffMs < 0) {
683
- throw new RangeError("retryBackoffMs must be a non-negative finite number");
684
- }
685
- }
686
- native;
687
- closed = false;
688
- client() {
689
- if (this.closed) throw new Error("Tensorlake native client is closed");
690
- if (this.native) return this.native;
691
- const ctor = loadNativeSandboxBinding().NativeCloudClient;
692
- if (!ctor) throw new Error("Native binding does not export NativeCloudClient; rebuild with 'npm run build:native'");
693
- return this.native = new ctor(JSON.stringify(this.options));
694
- }
695
- close() {
696
- this.closed = true;
697
- releaseNativeHandle(this.native ?? null);
698
- this.native = void 0;
699
- }
700
- async requestResponse(method, path3, options) {
701
- const request = await serializeRequest(method, path3, options);
702
- const raw = await callNative(() => this.client().request(request));
703
- const response = new Response(
704
- [204, 205, 304].includes(raw.status) ? null : Uint8Array.from(raw.data).buffer,
705
- { status: raw.status, headers: JSON.parse(raw.headersJson) }
706
- );
707
- return Object.assign(response, { traceId: raw.traceId });
708
- }
709
- async requestJson(method, path3) {
710
- const response = await this.requestResponse(method, path3);
711
- const text = await response.text();
712
- const value = text ? JSON.parse(text) : null;
713
- return Object.assign(value ?? {}, { traceId: response.traceId });
714
- }
715
- async *stream(method, path3, signal) {
716
- if (signal?.aborted) return;
717
- const request = await serializeRequest(method, path3, { headers: { Accept: "text/event-stream" } });
718
- yield* nativeEventStream((emit) => this.client().stream(request, emit), void 0, signal);
719
- }
720
- };
721
- }
722
- });
723
-
724
- // src/cloud-client.ts
725
- function secretFromMetadata(metadata) {
726
- return {
727
- id: metadata.id,
728
- name: metadata.name,
729
- createdAt: new Date(metadata.created_at_ms)
730
- };
731
- }
732
- function applicationAllowsUnauthenticatedRequests(manifest) {
733
- return Array.isArray(manifest.allow) && manifest.allow.includes(UNAUTHENTICATED_REQUESTS);
734
- }
735
- function publicEndpointIdFromManifest(manifest) {
736
- for (const key of ["public_endpoint_id", "publicEndpointId"]) {
737
- const value = manifest[key];
738
- if (typeof value === "string" && value.length > 0) {
739
- return value;
740
- }
741
- }
742
- return void 0;
743
- }
744
- function generatePublicEndpointId() {
745
- return `endpoint_${(0, import_nanoid.nanoid)()}`;
746
- }
747
- function createApplicationBuildForm(request, imageContexts) {
748
- const contextsByPartName = /* @__PURE__ */ new Map();
749
- for (const context of imageContexts) {
750
- if (contextsByPartName.has(context.contextTarPartName)) {
751
- throw new Error(
752
- `duplicate image context part name '${context.contextTarPartName}'`
753
- );
754
- }
755
- contextsByPartName.set(context.contextTarPartName, context);
756
- }
757
- const form = new FormData();
758
- form.append(
759
- "app_version",
760
- new Blob([JSON.stringify(request)], { type: "application/json" }),
761
- "app_version"
762
- );
763
- for (const image of request.images) {
764
- const context = contextsByPartName.get(image.contextTarPartName);
765
- if (!context) {
766
- throw new Error(
767
- `missing image context for part '${image.contextTarPartName}'`
768
- );
769
- }
770
- form.append(
771
- image.contextTarPartName,
772
- new Blob([toBlobPart(context.contextTarGz)]),
773
- `${image.contextTarPartName}.tar.gz`
774
- );
775
- }
776
- for (const context of imageContexts) {
777
- if (!request.images.some((image) => image.contextTarPartName === context.contextTarPartName)) {
778
- throw new Error(
779
- `unexpected image context for part '${context.contextTarPartName}'`
780
- );
781
- }
782
- }
783
- return form;
784
- }
785
- function trimTrailingSlashes2(value) {
786
- return value.endsWith("/") ? value.slice(0, -1) : value;
787
- }
788
- function nextRequestPath(next) {
789
- const schemeIndex = next.indexOf("://");
790
- if (schemeIndex !== -1) {
791
- const afterScheme = next.slice(schemeIndex + 3);
792
- const slashIndex = afterScheme.indexOf("/");
793
- return slashIndex === -1 ? "/" : afterScheme.slice(slashIndex);
794
- }
795
- return next.startsWith("/") ? next : `/${next}`;
796
- }
797
- function toBlobPart(data) {
798
- if (typeof data === "string" || data instanceof Blob) {
799
- return data;
800
- }
801
- if (data instanceof Uint8Array) {
802
- return Uint8Array.from(data).buffer;
803
- }
804
- return data;
805
- }
806
- function toRequestBody(data) {
807
- return toBlobPart(data);
808
- }
809
- async function parseJsonResponse(response) {
810
- const text = await response.text();
811
- if (!text) {
812
- return void 0;
813
- }
814
- return JSON.parse(text);
815
- }
816
- var import_nanoid, CloudClient, UNAUTHENTICATED_REQUESTS;
817
- var init_cloud_client = __esm({
818
- "src/cloud-client.ts"() {
819
- "use strict";
820
- init_cjs_shims();
821
- import_nanoid = require("nanoid");
822
- init_defaults();
823
- init_native_cloud();
824
- init_models();
825
- CloudClient = class _CloudClient {
826
- transport;
827
- organizationId;
828
- projectId;
829
- namespace;
830
- constructor(options) {
831
- this.organizationId = options?.organizationId;
832
- this.projectId = options?.projectId;
833
- this.namespace = options?.namespace ?? NAMESPACE;
834
- this.transport = new NativeCloudTransport({
835
- baseUrl: options?.apiUrl ?? API_URL,
836
- apiKey: options?.apiKey ?? API_KEY,
837
- organizationId: this.organizationId,
838
- projectId: this.projectId,
839
- maxRetries: options?.maxRetries ?? MAX_RETRIES,
840
- retryBackoffMs: options?.retryBackoffMs ?? RETRY_BACKOFF_MS,
841
- timeoutMs: DEFAULT_HTTP_TIMEOUT_MS,
842
- userAgent: `tensorlake-typescript-sdk/${SDK_VERSION}`
843
- });
844
- }
845
- static forCloud(options) {
846
- return new _CloudClient(options);
847
- }
848
- close() {
849
- this.transport.close();
850
- }
851
- async upsertApplication(manifest, codeZip, upgradeRunningRequests = false) {
852
- const applicationManifest = { ...manifest };
853
- let publicEndpointId = publicEndpointIdFromManifest(applicationManifest);
854
- if (applicationAllowsUnauthenticatedRequests(applicationManifest) && publicEndpointId === void 0) {
855
- const applicationName = applicationManifest.name;
856
- if (typeof applicationName === "string" && applicationName.length > 0) {
857
- publicEndpointId = await this.existingApplicationPublicEndpointId(applicationName);
858
- }
859
- publicEndpointId ??= generatePublicEndpointId();
860
- }
861
- if (publicEndpointId !== void 0) {
862
- applicationManifest.public_endpoint_id = publicEndpointId;
863
- delete applicationManifest.publicEndpointId;
864
- }
865
- const form = new FormData();
866
- form.append(
867
- "code",
868
- new Blob([toBlobPart(codeZip)], { type: "application/zip" }),
869
- "code.zip"
870
- );
871
- form.append("code_content_type", "application/zip");
872
- form.append("application", JSON.stringify(applicationManifest));
873
- form.append(
874
- "upgrade_requests_to_latest_code",
875
- String(upgradeRunningRequests)
876
- );
877
- await this.transport.requestResponse("POST", this.namespacePath("applications"), {
878
- body: form
879
- });
880
- }
881
- async deleteApplication(applicationName) {
882
- await this.transport.requestResponse(
883
- "DELETE",
884
- this.namespacePath(`applications/${encodeURIComponent(applicationName)}`)
885
- );
886
- }
887
- async deleteSandboxImage(imageName) {
888
- await this.transport.requestResponse(
889
- "DELETE",
890
- this.namespacePath(`sandbox-images/${encodeURIComponent(imageName)}`)
891
- );
892
- }
893
- /**
894
- * Look up a registered sandbox image (template) by its registered name.
895
- *
896
- * Returns the template, or `null` when no image with that name exists.
897
- * API-key clients may omit organization/project IDs and use the
898
- * token-scoped Platform API route directly. Explicit scope remains
899
- * available for PAT callers.
900
- */
901
- async findSandboxImageByName(imageName, options) {
902
- const base = this.platformProjectPath(
903
- "sandbox-templates",
904
- options?.organizationId,
905
- options?.projectId
906
- );
907
- const response = await this.transport.requestResponse(
908
- "GET",
909
- `${base}/by-name/${encodeURIComponent(imageName)}`,
910
- { statusOnlyCodes: /* @__PURE__ */ new Set([404]) }
911
- );
912
- if (response.status === 404) {
913
- return null;
914
- }
915
- const raw = await parseJsonResponse(response);
916
- return fromSnakeKeys(raw);
917
- }
918
- /**
919
- * List all registered sandbox images (templates), following pagination to
920
- * the end. API-key clients may omit organization/project IDs and use the
921
- * token-scoped Platform API route directly.
922
- */
923
- async listSandboxImages(options) {
924
- const base = this.platformProjectPath(
925
- "sandbox-templates",
926
- options?.organizationId,
927
- options?.projectId
928
- );
929
- let path3 = `${base}?pageSize=100`;
930
- const templates = [];
931
- while (path3 !== null) {
932
- const page = await this.transport.requestJson(
933
- "GET",
934
- path3
935
- );
936
- for (const item of page.items ?? []) {
937
- templates.push(fromSnakeKeys(item));
938
- }
939
- const next = page.pagination?.next;
940
- path3 = next ? nextRequestPath(next) : null;
941
- }
942
- return templates;
943
- }
944
- async applications() {
945
- const raw = await this.transport.requestJson(
946
- "GET",
947
- this.namespacePath("applications")
948
- );
949
- return (raw.applications ?? []).map(
950
- (application) => fromSnakeKeys(application)
951
- );
952
- }
953
- async applicationManifest(applicationName) {
954
- const raw = await this.transport.requestJson(
955
- "GET",
956
- this.namespacePath(`applications/${encodeURIComponent(applicationName)}`)
957
- );
958
- return fromSnakeKeys(raw);
959
- }
960
- async runRequest(applicationName, inputs = []) {
961
- const path3 = this.namespacePath(
962
- `applications/${encodeURIComponent(applicationName)}`
963
- );
964
- const response = inputs.length === 0 ? await this.transport.requestResponse("POST", path3, {
965
- body: new Uint8Array(),
966
- headers: { Accept: "application/json" }
967
- }) : inputs.length === 1 && inputs[0].name === "0" ? await this.transport.requestResponse("POST", path3, {
968
- body: toRequestBody(inputs[0].data),
969
- headers: {
970
- Accept: "application/json",
971
- "Content-Type": inputs[0].contentType
972
- }
973
- }) : await this.runMultipartRequest(path3, inputs);
974
- const body = await parseJsonResponse(response);
975
- const requestId = body?.request_id;
976
- if (!requestId) {
977
- throw new Error("missing request_id in run request response body");
978
- }
979
- return requestId;
980
- }
981
- async waitOnRequestCompletion(applicationName, requestId) {
982
- const stream = this.transport.stream(
983
- "GET",
984
- this.namespacePath(
985
- `applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}/progress`
986
- )
987
- );
988
- for await (const event of stream) {
989
- if (Object.prototype.hasOwnProperty.call(event, "RequestFinished")) {
990
- return;
991
- }
992
- }
993
- throw new Error("progress stream ended before request completion");
994
- }
995
- async requestMetadata(applicationName, requestId) {
996
- const raw = await this.transport.requestJson(
997
- "GET",
998
- this.namespacePath(
999
- `applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}`
1000
- )
1001
- );
1002
- return fromSnakeKeys(raw);
1003
- }
1004
- async requestOutput(applicationName, requestId) {
1005
- const response = await this.transport.requestResponse(
1006
- "GET",
1007
- this.namespacePath(
1008
- `applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}/output`
1009
- )
1010
- );
1011
- const serializedValue = new Uint8Array(await response.arrayBuffer());
1012
- const contentType = response.headers.get("content-type") ?? "";
1013
- return {
1014
- serializedValue,
1015
- contentType
1016
- };
1017
- }
1018
- async listSecrets(options) {
1019
- const base = this.secretCollectionPath(
1020
- options?.organizationId,
1021
- options?.projectId
1022
- );
1023
- const raw = await this.transport.requestJson("GET", base);
1024
- const pageSize = Math.max(0, options?.pageSize ?? 100);
1025
- return Object.assign(
1026
- {
1027
- items: raw.slice(0, pageSize).map(secretFromMetadata),
1028
- pagination: { total: raw.length }
1029
- },
1030
- { traceId: raw.traceId }
1031
- );
1032
- }
1033
- async getSecret(secretId, options) {
1034
- const base = this.secretCollectionPath(
1035
- options?.organizationId,
1036
- options?.projectId
1037
- );
1038
- const raw = await this.transport.requestJson(
1039
- "GET",
1040
- `${base}/${encodeURIComponent(secretId)}`
1041
- );
1042
- return Object.assign(secretFromMetadata(raw), { traceId: raw.traceId });
1043
- }
1044
- async upsertSecrets(secrets, options) {
1045
- const base = this.secretCollectionPath(
1046
- options?.organizationId,
1047
- options?.projectId
1048
- );
1049
- if (Array.isArray(secrets)) {
1050
- const results = [];
1051
- for (const secret of secrets) {
1052
- results.push(await this.upsertSecret(base, secret));
1053
- }
1054
- return results;
1055
- }
1056
- return this.upsertSecret(base, secrets);
1057
- }
1058
- async deleteSecret(secretId, options) {
1059
- const base = this.secretCollectionPath(
1060
- options?.organizationId,
1061
- options?.projectId
1062
- );
1063
- await this.transport.requestResponse(
1064
- "DELETE",
1065
- `${base}/${encodeURIComponent(secretId)}`
1066
- );
1067
- }
1068
- async upsertSecret(base, secret) {
1069
- let response = await this.transport.requestResponse("POST", base, {
1070
- json: secret,
1071
- headers: { "Idempotency-Key": (0, import_nanoid.nanoid)() },
1072
- statusOnlyCodes: /* @__PURE__ */ new Set([409])
1073
- });
1074
- if (response.status === 409) {
1075
- const prefix = base.slice(0, -"/secrets".length);
1076
- const existing = await this.transport.requestJson(
1077
- "GET",
1078
- `${prefix}/secret-names/${encodeURIComponent(secret.name)}`
1079
- );
1080
- response = await this.transport.requestResponse(
1081
- "POST",
1082
- `${base}/${encodeURIComponent(existing.id)}/versions`,
1083
- {
1084
- json: { value: secret.value },
1085
- headers: { "Idempotency-Key": (0, import_nanoid.nanoid)() }
1086
- }
1087
- );
1088
- }
1089
- const metadata = await parseJsonResponse(response);
1090
- return Object.assign(secretFromMetadata(metadata), {
1091
- traceId: response.traceId
1092
- });
1093
- }
1094
- async startImageBuild(buildServicePath, request) {
1095
- const form = new FormData();
1096
- form.append("graph_name", request.applicationName);
1097
- form.append("graph_version", request.applicationVersion);
1098
- form.append("graph_function_name", request.functionName);
1099
- form.append("image_name", request.imageName);
1100
- form.append("image_id", request.imageId);
1101
- form.append(
1102
- "context",
1103
- new Blob([toBlobPart(request.buildContext)]),
1104
- "context.tar.gz"
1105
- );
1106
- const response = await this.transport.requestResponse(
1107
- "PUT",
1108
- `${trimTrailingSlashes2(buildServicePath)}/builds`,
1109
- { body: form }
1110
- );
1111
- const raw = await parseJsonResponse(response);
1112
- return fromSnakeKeys(raw);
1113
- }
1114
- async createApplicationBuild(buildServicePath, request, imageContexts) {
1115
- const form = createApplicationBuildForm(request, imageContexts);
1116
- const response = await this.transport.requestResponse(
1117
- "POST",
1118
- trimTrailingSlashes2(buildServicePath),
1119
- { body: form }
1120
- );
1121
- const raw = await parseJsonResponse(response);
1122
- return fromSnakeKeys(raw);
1123
- }
1124
- async applicationBuildInfo(buildServicePath, applicationBuildId) {
1125
- const raw = await this.transport.requestJson(
1126
- "GET",
1127
- `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
1128
- );
1129
- return fromSnakeKeys(raw);
1130
- }
1131
- async cancelApplicationBuild(buildServicePath, applicationBuildId) {
1132
- const raw = await this.transport.requestJson(
1133
- "POST",
1134
- `${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
1135
- );
1136
- return fromSnakeKeys(raw);
1137
- }
1138
- async buildInfo(buildServicePath, buildId) {
1139
- const raw = await this.transport.requestJson(
1140
- "GET",
1141
- `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
1142
- );
1143
- return fromSnakeKeys(raw);
1144
- }
1145
- async cancelBuild(buildServicePath, buildId) {
1146
- await this.transport.requestResponse(
1147
- "POST",
1148
- `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
1149
- );
1150
- }
1151
- async *streamBuildLogs(buildServicePath, buildId, signal) {
1152
- const stream = this.transport.stream(
1153
- "GET",
1154
- `${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
1155
- signal
1156
- );
1157
- for await (const event of stream) {
1158
- yield fromSnakeKeys(event);
1159
- }
1160
- }
1161
- async runMultipartRequest(path3, inputs) {
1162
- const form = new FormData();
1163
- for (const input of inputs) {
1164
- form.append(
1165
- input.name,
1166
- new Blob([toBlobPart(input.data)], { type: input.contentType }),
1167
- input.name
1168
- );
1169
- }
1170
- return this.transport.requestResponse("POST", path3, {
1171
- body: form,
1172
- headers: { Accept: "application/json" }
1173
- });
1174
- }
1175
- namespacePath(subpath) {
1176
- return `/v1/namespaces/${encodeURIComponent(this.namespace)}/${subpath.replace(/^\/+/, "")}`;
1177
- }
1178
- async existingApplicationPublicEndpointId(applicationName) {
1179
- const response = await this.transport.requestResponse(
1180
- "GET",
1181
- this.namespacePath(`applications/${encodeURIComponent(applicationName)}`),
1182
- { statusOnlyCodes: /* @__PURE__ */ new Set([404]) }
1183
- );
1184
- if (response.status === 404) {
1185
- return void 0;
1186
- }
1187
- const application = await parseJsonResponse(response);
1188
- return publicEndpointIdFromManifest(application);
1189
- }
1190
- platformProjectPath(resource, organizationId, projectId) {
1191
- const resolvedOrganizationId = organizationId ?? this.organizationId;
1192
- const resolvedProjectId = projectId ?? this.projectId;
1193
- if (!resolvedOrganizationId && !resolvedProjectId) {
1194
- return `/platform/v1/${resource}`;
1195
- }
1196
- if (!resolvedOrganizationId || !resolvedProjectId) {
1197
- throw new Error(
1198
- "organizationId and projectId must be provided together"
1199
- );
1200
- }
1201
- return `/platform/v1/organizations/${encodeURIComponent(resolvedOrganizationId)}/projects/${encodeURIComponent(resolvedProjectId)}/${resource}`;
1202
- }
1203
- secretCollectionPath(organizationId, projectId) {
1204
- const resolvedOrganizationId = organizationId ?? this.organizationId;
1205
- const resolvedProjectId = projectId ?? this.projectId;
1206
- if (!resolvedOrganizationId && !resolvedProjectId) {
1207
- return this.namespacePath("secrets");
1208
- }
1209
- if (!resolvedOrganizationId || !resolvedProjectId) {
1210
- throw new Error("organizationId and projectId must be provided together");
1211
- }
1212
- return this.namespacePath("secrets");
1213
- }
1214
- };
1215
- UNAUTHENTICATED_REQUESTS = "unauthenticated_requests";
1216
- }
1217
- });
1218
-
1219
46
  // src/image.ts
1220
47
  function cloneOperation(op) {
1221
48
  return {
@@ -1447,7 +274,7 @@ function nativePackageName(platform = process.platform, arch = process.arch, opt
1447
274
  function loadNative() {
1448
275
  const target = nativeTargetId();
1449
276
  const bindingPath = nativeBindingPath();
1450
- const require2 = (0, import_node_module2.createRequire)(importMetaUrl);
277
+ const require2 = (0, import_node_module.createRequire)(importMetaUrl);
1451
278
  if (fs.existsSync(bindingPath)) return require2(bindingPath);
1452
279
  const packageName = nativePackageName();
1453
280
  if (!packageName) {
@@ -1466,14 +293,14 @@ function loadNative() {
1466
293
  }
1467
294
  return require2(packageEntry);
1468
295
  }
1469
- var import_libc, fs, import_node_module2, import_node_path, import_node_url, NATIVE_PACKAGES, cachedLinuxLibc;
296
+ var import_libc, fs, import_node_module, import_node_path, import_node_url, NATIVE_PACKAGES, cachedLinuxLibc;
1470
297
  var init_native_binding = __esm({
1471
298
  "src/native-binding.ts"() {
1472
299
  "use strict";
1473
300
  init_cjs_shims();
1474
301
  import_libc = __toESM(require_libc(), 1);
1475
302
  fs = __toESM(require("fs"), 1);
1476
- import_node_module2 = require("module");
303
+ import_node_module = require("module");
1477
304
  import_node_path = __toESM(require("path"), 1);
1478
305
  import_node_url = require("url");
1479
306
  NATIVE_PACKAGES = {
@@ -1487,16 +314,186 @@ var init_native_binding = __esm({
1487
314
  }
1488
315
  });
1489
316
 
317
+ // src/image-builds.ts
318
+ function camelize(key) {
319
+ return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
320
+ }
321
+ function toImageBuildError(error) {
322
+ if (!(error instanceof Error)) return error;
323
+ let payload;
324
+ try {
325
+ payload = JSON.parse(error.message);
326
+ } catch {
327
+ return error;
328
+ }
329
+ if (!payload || payload.category !== "image_build") return error;
330
+ const details = {};
331
+ for (const [key, value] of Object.entries(payload)) {
332
+ if (key === "category") continue;
333
+ details[camelize(key)] = value;
334
+ }
335
+ const typed = details;
336
+ switch (typed.code) {
337
+ case "not_found":
338
+ return new ImageBuildNotFoundError(typed);
339
+ case "image_build_in_progress":
340
+ return new ImageBuildInProgressError(typed);
341
+ case "failed":
342
+ return new ImageBuildFailedError(typed);
343
+ case "cancelled":
344
+ return new ImageBuildCancelledError(typed);
345
+ case "timeout":
346
+ return new ImageBuildTimeoutError(typed);
347
+ case "interrupted":
348
+ return new ImageBuildInterruptedError(typed);
349
+ default:
350
+ return new ImageBuildError(typed);
351
+ }
352
+ }
353
+ function camelizeRecord(value) {
354
+ const out = {};
355
+ for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
356
+ return out;
357
+ }
358
+ function parseBuildInfo(raw) {
359
+ const camel = camelizeRecord(raw);
360
+ const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
361
+ return {
362
+ buildId: String(raw.build_id ?? ""),
363
+ clientRequestId: camel.clientRequestId ?? null,
364
+ kind: String(raw.kind ?? ""),
365
+ name: raw.name ?? null,
366
+ status: String(raw.status ?? ""),
367
+ phase: raw.phase ?? null,
368
+ attemptNo: Number(raw.attempt_no ?? 0),
369
+ builderSandboxId: camel.builderSandboxId ?? null,
370
+ error: raw.error ?? null,
371
+ result,
372
+ operationDeadlineMs: camel.operationDeadlineMs ?? null,
373
+ createdAtMs: camel.createdAtMs ?? null,
374
+ updatedAtMs: camel.updatedAtMs ?? null,
375
+ raw
376
+ };
377
+ }
378
+ async function __runWithInterrupt(signal, run) {
379
+ const binding = __imageBuildInternals.loadNativeBinding();
380
+ if (signal === void 0) {
381
+ try {
382
+ return await run(void 0);
383
+ } catch (error) {
384
+ throw toImageBuildError(error);
385
+ }
386
+ }
387
+ const interruptId = binding.createImageBuildInterrupt();
388
+ const onAbort = () => binding.triggerImageBuildInterrupt(interruptId);
389
+ if (signal.aborted) onAbort();
390
+ else signal.addEventListener("abort", onAbort, { once: true });
391
+ try {
392
+ return await run(interruptId);
393
+ } catch (error) {
394
+ throw toImageBuildError(error);
395
+ } finally {
396
+ signal.removeEventListener("abort", onAbort);
397
+ binding.releaseImageBuildInterrupt(interruptId);
398
+ }
399
+ }
400
+ var import_node_path2, import_node_os, import_node_fs, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError;
401
+ var init_image_builds = __esm({
402
+ "src/image-builds.ts"() {
403
+ "use strict";
404
+ init_cjs_shims();
405
+ import_node_path2 = __toESM(require("path"), 1);
406
+ import_node_os = __toESM(require("os"), 1);
407
+ import_node_fs = require("fs");
408
+ init_image();
409
+ init_sandbox_image();
410
+ ImageBuildError = class extends Error {
411
+ code;
412
+ buildId;
413
+ clientRequestId;
414
+ details;
415
+ constructor(details) {
416
+ super(details.message);
417
+ this.name = "ImageBuildError";
418
+ this.code = details.code;
419
+ this.details = details;
420
+ if (details.buildId) this.buildId = details.buildId;
421
+ if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
422
+ }
423
+ };
424
+ ImageBuildNotFoundError = class extends ImageBuildError {
425
+ constructor(details) {
426
+ super(details);
427
+ this.name = "ImageBuildNotFoundError";
428
+ }
429
+ };
430
+ ImageBuildInProgressError = class extends ImageBuildError {
431
+ imageName;
432
+ activeBuildId;
433
+ activeKind;
434
+ activeStatus;
435
+ constructor(details) {
436
+ super(details);
437
+ this.name = "ImageBuildInProgressError";
438
+ if (details.imageName) this.imageName = details.imageName;
439
+ if (details.activeBuildId) this.activeBuildId = details.activeBuildId;
440
+ if (details.activeKind) this.activeKind = details.activeKind;
441
+ if (details.activeStatus) this.activeStatus = details.activeStatus;
442
+ }
443
+ };
444
+ ImageBuildFailedError = class extends ImageBuildError {
445
+ error;
446
+ info;
447
+ constructor(details) {
448
+ super(details);
449
+ this.name = "ImageBuildFailedError";
450
+ this.error = details.error ?? "no error recorded";
451
+ if (details.info) this.info = parseBuildInfo(details.info);
452
+ }
453
+ };
454
+ ImageBuildCancelledError = class extends ImageBuildError {
455
+ info;
456
+ constructor(details) {
457
+ super(details);
458
+ this.name = "ImageBuildCancelledError";
459
+ if (details.info) this.info = parseBuildInfo(details.info);
460
+ }
461
+ };
462
+ ImageBuildTimeoutError = class extends ImageBuildError {
463
+ constructor(details) {
464
+ super(details);
465
+ this.name = "ImageBuildTimeoutError";
466
+ }
467
+ };
468
+ ImageBuildInterruptedError = class extends ImageBuildError {
469
+ outcome;
470
+ confirmed;
471
+ result;
472
+ constructor(details) {
473
+ super(details);
474
+ this.name = "ImageBuildInterruptedError";
475
+ this.outcome = details.outcome ?? "unconfirmed";
476
+ this.confirmed = details.confirmed === true;
477
+ if (details.result) this.result = details.result;
478
+ }
479
+ };
480
+ }
481
+ });
482
+
1490
483
  // src/sandbox-image.ts
1491
484
  var sandbox_image_exports = {};
1492
485
  __export(sandbox_image_exports, {
486
+ __imageBuildInternals: () => __imageBuildInternals,
1493
487
  __setNativeBindingForTest: () => __setNativeBindingForTest,
1494
488
  buildContextFromEnv: () => buildContextFromEnv,
1495
489
  createSandboxImage: () => createSandboxImage,
1496
490
  deleteSandboxImage: () => deleteSandboxImage,
491
+ deleteSandboxImageWithCredentials: () => deleteSandboxImageWithCredentials,
1497
492
  findSandboxImageByName: () => findSandboxImageByName,
493
+ findSandboxImageByNameWithCredentials: () => findSandboxImageByNameWithCredentials,
1498
494
  importSandboxImage: () => importSandboxImage,
1499
495
  listSandboxImages: () => listSandboxImages,
496
+ listSandboxImagesWithCredentials: () => listSandboxImagesWithCredentials,
1500
497
  runCreateSandboxImageCli: () => runCreateSandboxImageCli,
1501
498
  runImportSandboxImageCli: () => runImportSandboxImageCli
1502
499
  });
@@ -1533,9 +530,9 @@ function buildContextFromEnv() {
1533
530
  };
1534
531
  }
1535
532
  function defaultRegisteredName(dockerfilePath) {
1536
- const parsed = import_node_path2.default.parse(dockerfilePath);
533
+ const parsed = import_node_path3.default.parse(dockerfilePath);
1537
534
  if (parsed.name.toLowerCase() === "dockerfile") {
1538
- const parentName = import_node_path2.default.basename(import_node_path2.default.dirname(dockerfilePath)).trim();
535
+ const parentName = import_node_path3.default.basename(import_node_path3.default.dirname(dockerfilePath)).trim();
1539
536
  return parentName || "sandbox-image";
1540
537
  }
1541
538
  return parsed.name || "sandbox-image";
@@ -1571,6 +568,15 @@ function eventToEmitDict(event) {
1571
568
  message: event.message
1572
569
  };
1573
570
  if (event.stream != null) out.stream = event.stream;
571
+ if (event.buildId != null) out.build_id = event.buildId;
572
+ if (event.clientRequestId !== void 0 && event.eventType !== "status") {
573
+ out.client_request_id = event.clientRequestId;
574
+ }
575
+ if (event.status != null) out.status = event.status;
576
+ if (event.phase !== void 0 && event.eventType.startsWith("build_")) out.phase = event.phase;
577
+ if (event.attempt != null) out.attempt = event.attempt;
578
+ if (event.outcome != null) out.outcome = event.outcome;
579
+ if (event.confirmed != null) out.confirmed = event.confirmed;
1574
580
  return out;
1575
581
  }
1576
582
  function runOpMountsContext(op) {
@@ -1625,24 +631,24 @@ async function createSandboxImage(source, options = {}, deps = {}) {
1625
631
  }
1626
632
  let resolvedContext;
1627
633
  if (options.contextDir != null) {
1628
- resolvedContext = import_node_path2.default.resolve(options.contextDir);
634
+ resolvedContext = import_node_path3.default.resolve(options.contextDir);
1629
635
  } else if (imageRequiresContext(source)) {
1630
636
  throw new Error(
1631
637
  "This image reads files from the host (via COPY/ADD or a RUN bind mount), so it needs a build context. Pass `contextDir` pointing at the directory that contains those sources; they resolve relative to it, like `docker build <contextDir>`."
1632
638
  );
1633
639
  } else {
1634
- tempContextDir = (0, import_node_fs.mkdtempSync)(import_node_path2.default.join(import_node_os.default.tmpdir(), "tl-build-context-"));
640
+ tempContextDir = (0, import_node_fs2.mkdtempSync)(import_node_path3.default.join(import_node_os2.default.tmpdir(), "tl-build-context-"));
1635
641
  resolvedContext = tempContextDir;
1636
642
  }
1637
- dockerfilePath = import_node_path2.default.join(resolvedContext, "Dockerfile");
643
+ dockerfilePath = import_node_path3.default.join(resolvedContext, "Dockerfile");
1638
644
  let text = dockerfileContent(source);
1639
645
  if (!text.endsWith("\n")) text += "\n";
1640
646
  dockerfileText = text;
1641
647
  nativeContextDir = resolvedContext;
1642
648
  effectiveName = options.registeredName ?? source.name;
1643
649
  } else if (typeof source === "string") {
1644
- const resolvedPath = import_node_path2.default.resolve(source);
1645
- if (!(0, import_node_fs.existsSync)(resolvedPath)) {
650
+ const resolvedPath = import_node_path3.default.resolve(source);
651
+ if (!(0, import_node_fs2.existsSync)(resolvedPath)) {
1646
652
  throw new Error(`Dockerfile not found: ${source}`);
1647
653
  }
1648
654
  dockerfilePath = resolvedPath;
@@ -1672,38 +678,47 @@ async function createSandboxImage(source, options = {}, deps = {}) {
1672
678
  deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
1673
679
  );
1674
680
  }
681
+ if (options.signal !== void 0 && !options.cas) {
682
+ throw new Error(
683
+ "signal is only supported for CAS image builds (cas: true); a legacy build has no Image Service build operation to cancel"
684
+ );
685
+ }
1675
686
  emit({ type: "status", message: `Building image '${effectiveName}'...` });
1676
687
  const binding = loadNativeBinding();
1677
688
  let emitError;
1678
- const resultJson = await binding.buildSandboxImage(
1679
- {
1680
- apiUrl: context.apiUrl,
1681
- bearerToken,
1682
- dockerfilePath,
1683
- registeredName: effectiveName,
1684
- diskMb: options.diskMb,
1685
- builderDiskMb: options.builderDiskMb,
1686
- cpus: options.cpus,
1687
- memoryMb: options.memoryMb,
1688
- isPublic: options.isPublic ?? false,
1689
- organizationId: usePat ? context.organizationId : void 0,
1690
- projectId: usePat ? context.projectId : void 0,
1691
- namespace: context.namespace,
1692
- useScopeHeaders: usePat,
1693
- userAgent: void 0,
1694
- dockerCompat: options.dockerCompat ?? false,
1695
- dockerConfigJson: options.dockerConfigJson,
1696
- dockerfileText,
1697
- contextDir: nativeContextDir
1698
- },
1699
- (event) => {
1700
- try {
1701
- emit(eventToEmitDict(event));
1702
- } catch (error) {
1703
- emitError ??= error;
1704
- }
689
+ const nativeOptions = {
690
+ apiUrl: context.apiUrl,
691
+ bearerToken,
692
+ dockerfilePath,
693
+ registeredName: effectiveName,
694
+ diskMb: options.diskMb,
695
+ builderDiskMb: options.builderDiskMb,
696
+ cpus: options.cpus,
697
+ memoryMb: options.memoryMb,
698
+ isPublic: options.isPublic ?? false,
699
+ organizationId: usePat ? context.organizationId : void 0,
700
+ projectId: usePat ? context.projectId : void 0,
701
+ namespace: context.namespace,
702
+ useScopeHeaders: usePat,
703
+ userAgent: void 0,
704
+ dockerCompat: options.dockerCompat ?? false,
705
+ dockerConfigJson: options.dockerConfigJson,
706
+ dockerfileText,
707
+ contextDir: nativeContextDir,
708
+ cas: options.cas ?? false,
709
+ buildArgs: options.buildArgs
710
+ };
711
+ const forward = (event) => {
712
+ try {
713
+ emit(eventToEmitDict(event));
714
+ } catch (error) {
715
+ emitError ??= error;
1705
716
  }
1706
- );
717
+ };
718
+ const resultJson = options.cas ? await __runWithInterrupt(
719
+ options.signal,
720
+ (interruptId) => binding.buildSandboxImage(nativeOptions, forward, interruptId)
721
+ ) : await binding.buildSandboxImage(nativeOptions, forward);
1707
722
  if (emitError != null) {
1708
723
  throw emitError;
1709
724
  }
@@ -1720,7 +735,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
1720
735
  return result;
1721
736
  } finally {
1722
737
  if (tempContextDir != null) {
1723
- (0, import_node_fs.rmSync)(tempContextDir, { recursive: true, force: true });
738
+ (0, import_node_fs2.rmSync)(tempContextDir, { recursive: true, force: true });
1724
739
  }
1725
740
  }
1726
741
  }
@@ -1749,39 +764,47 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
1749
764
  deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
1750
765
  );
1751
766
  }
767
+ if (options.signal !== void 0 && !options.cas) {
768
+ throw new Error(
769
+ "signal is only supported for CAS image imports (cas: true); a legacy import has no Image Service build operation to cancel"
770
+ );
771
+ }
1752
772
  emit({
1753
773
  type: "status",
1754
774
  message: `Importing image '${reference}' as '${effectiveName}'...`
1755
775
  });
1756
776
  const binding = loadNativeBinding();
1757
777
  let emitError;
1758
- const resultJson = await binding.importSandboxImage(
1759
- {
1760
- apiUrl: context.apiUrl,
1761
- bearerToken,
1762
- imageReference: reference,
1763
- registeredName: effectiveName,
1764
- diskMb: options.diskMb,
1765
- builderDiskMb: options.builderDiskMb,
1766
- cpus: options.cpus,
1767
- memoryMb: options.memoryMb,
1768
- isPublic: options.isPublic ?? false,
1769
- organizationId: usePat ? context.organizationId : void 0,
1770
- projectId: usePat ? context.projectId : void 0,
1771
- namespace: context.namespace,
1772
- useScopeHeaders: usePat,
1773
- userAgent: void 0,
1774
- dockerCompat: options.dockerCompat ?? false,
1775
- dockerConfigJson: options.dockerConfigJson
1776
- },
1777
- (event) => {
1778
- try {
1779
- emit(eventToEmitDict(event));
1780
- } catch (error) {
1781
- emitError ??= error;
1782
- }
778
+ const nativeOptions = {
779
+ apiUrl: context.apiUrl,
780
+ bearerToken,
781
+ imageReference: reference,
782
+ registeredName: effectiveName,
783
+ diskMb: options.diskMb,
784
+ builderDiskMb: options.builderDiskMb,
785
+ cpus: options.cpus,
786
+ memoryMb: options.memoryMb,
787
+ isPublic: options.isPublic ?? false,
788
+ organizationId: usePat ? context.organizationId : void 0,
789
+ projectId: usePat ? context.projectId : void 0,
790
+ namespace: context.namespace,
791
+ useScopeHeaders: usePat,
792
+ userAgent: void 0,
793
+ dockerCompat: options.dockerCompat ?? false,
794
+ dockerConfigJson: options.dockerConfigJson,
795
+ cas: options.cas ?? false
796
+ };
797
+ const forward = (event) => {
798
+ try {
799
+ emit(eventToEmitDict(event));
800
+ } catch (error) {
801
+ emitError ??= error;
1783
802
  }
1784
- );
803
+ };
804
+ const resultJson = options.cas ? await __runWithInterrupt(
805
+ options.signal,
806
+ (interruptId) => binding.importSandboxImage(nativeOptions, forward, interruptId)
807
+ ) : await binding.importSandboxImage(nativeOptions, forward);
1785
808
  if (emitError != null) {
1786
809
  throw emitError;
1787
810
  }
@@ -1797,10 +820,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
1797
820
  emit({ type: "done" });
1798
821
  return result;
1799
822
  }
1800
- async function deleteSandboxImage(imageName) {
1801
- if (typeof imageName !== "string" || imageName.length === 0) {
1802
- throw new TypeError("imageName must be a non-empty string");
1803
- }
823
+ function catalogOptionsFromEnv() {
1804
824
  const context = buildContextFromEnv();
1805
825
  const bearerToken = context.apiKey;
1806
826
  if (!bearerToken) {
@@ -1811,63 +831,73 @@ async function deleteSandboxImage(imageName) {
1811
831
  }
1812
832
  throw new Error("Missing TENSORLAKE_API_KEY credentials.");
1813
833
  }
1814
- const client = new CloudClient({
1815
- apiUrl: context.apiUrl,
1816
- apiKey: bearerToken,
1817
- namespace: context.namespace
1818
- });
1819
- try {
1820
- await client.deleteSandboxImage(imageName);
1821
- } finally {
1822
- client.close();
1823
- }
834
+ return { apiUrl: context.apiUrl, bearerToken, useScopeHeaders: false };
1824
835
  }
1825
- async function findSandboxImageByName(imageName) {
1826
- if (typeof imageName !== "string" || imageName.length === 0) {
1827
- throw new TypeError("imageName must be a non-empty string");
1828
- }
836
+ function catalogOptionsFromCredentials(credentials) {
1829
837
  const context = buildContextFromEnv();
1830
- const bearerToken = context.apiKey;
838
+ const bearerToken = credentials.apiKey ?? context.apiKey;
1831
839
  if (!bearerToken) {
1832
- if (context.personalAccessToken) {
1833
- throw new Error(
1834
- "Sandbox image SDKs require TENSORLAKE_API_KEY. Personal access tokens are CLI-only."
1835
- );
1836
- }
1837
840
  throw new Error("Missing TENSORLAKE_API_KEY credentials.");
1838
841
  }
1839
- const client = new CloudClient({
1840
- apiUrl: context.apiUrl,
1841
- apiKey: bearerToken,
1842
- namespace: context.namespace
1843
- });
1844
- try {
1845
- return await client.findSandboxImageByName(imageName);
1846
- } finally {
1847
- client.close();
842
+ const { organizationId, projectId } = credentials;
843
+ if (organizationId === void 0 !== (projectId === void 0)) {
844
+ throw new TypeError("organizationId and projectId must be given together");
1848
845
  }
846
+ return {
847
+ apiUrl: credentials.apiUrl ?? context.apiUrl,
848
+ bearerToken,
849
+ organizationId,
850
+ projectId,
851
+ useScopeHeaders: organizationId !== void 0
852
+ };
1849
853
  }
1850
- async function listSandboxImages() {
1851
- const context = buildContextFromEnv();
1852
- const bearerToken = context.apiKey;
1853
- if (!bearerToken) {
1854
- if (context.personalAccessToken) {
1855
- throw new Error(
1856
- "Sandbox image SDKs require TENSORLAKE_API_KEY. Personal access tokens are CLI-only."
1857
- );
1858
- }
1859
- throw new Error("Missing TENSORLAKE_API_KEY credentials.");
854
+ function parseTemplate(json) {
855
+ return JSON.parse(json);
856
+ }
857
+ async function deleteSandboxImage(imageName) {
858
+ if (typeof imageName !== "string" || imageName.length === 0) {
859
+ throw new TypeError("imageName must be a non-empty string");
1860
860
  }
1861
- const client = new CloudClient({
1862
- apiUrl: context.apiUrl,
1863
- apiKey: bearerToken,
1864
- namespace: context.namespace
1865
- });
1866
- try {
1867
- return await client.listSandboxImages();
1868
- } finally {
1869
- client.close();
861
+ await loadNativeBinding().deleteSandboxImage(catalogOptionsFromEnv(), imageName);
862
+ }
863
+ async function deleteSandboxImageWithCredentials(credentials, imageName) {
864
+ if (typeof imageName !== "string" || imageName.length === 0) {
865
+ throw new TypeError("imageName must be a non-empty string");
1870
866
  }
867
+ await loadNativeBinding().deleteSandboxImage(
868
+ catalogOptionsFromCredentials(credentials),
869
+ imageName
870
+ );
871
+ }
872
+ async function findSandboxImageByName(imageName) {
873
+ if (typeof imageName !== "string" || imageName.length === 0) {
874
+ throw new TypeError("imageName must be a non-empty string");
875
+ }
876
+ const json = await loadNativeBinding().findSandboxImage(
877
+ catalogOptionsFromEnv(),
878
+ imageName
879
+ );
880
+ return json == null ? null : parseTemplate(json);
881
+ }
882
+ async function findSandboxImageByNameWithCredentials(credentials, imageName) {
883
+ if (typeof imageName !== "string" || imageName.length === 0) {
884
+ throw new TypeError("imageName must be a non-empty string");
885
+ }
886
+ const json = await loadNativeBinding().findSandboxImage(
887
+ catalogOptionsFromCredentials(credentials),
888
+ imageName
889
+ );
890
+ return json == null ? null : parseTemplate(json);
891
+ }
892
+ async function listSandboxImages() {
893
+ const json = await loadNativeBinding().listSandboxImages(catalogOptionsFromEnv());
894
+ return JSON.parse(json);
895
+ }
896
+ async function listSandboxImagesWithCredentials(credentials) {
897
+ const json = await loadNativeBinding().listSandboxImages(
898
+ catalogOptionsFromCredentials(credentials)
899
+ );
900
+ return JSON.parse(json);
1871
901
  }
1872
902
  async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
1873
903
  const parsed = (0, import_node_util.parseArgs)({
@@ -1977,30 +1007,44 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
1977
1007
  { emit: ndjsonStdoutEmit, _allowPat: true }
1978
1008
  );
1979
1009
  }
1980
- var import_node_path2, import_node_os, import_node_fs, import_node_util, cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2;
1010
+ var import_node_path3, import_node_os2, import_node_fs2, import_node_util, cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, __imageBuildInternals;
1981
1011
  var init_sandbox_image = __esm({
1982
1012
  "src/sandbox-image.ts"() {
1983
1013
  init_cjs_shims();
1984
- import_node_path2 = __toESM(require("path"), 1);
1985
- import_node_os = __toESM(require("os"), 1);
1986
- import_node_fs = require("fs");
1014
+ import_node_path3 = __toESM(require("path"), 1);
1015
+ import_node_os2 = __toESM(require("os"), 1);
1016
+ import_node_fs2 = require("fs");
1987
1017
  import_node_util = require("util");
1988
- init_cloud_client();
1989
1018
  init_image();
1990
1019
  init_native_binding();
1020
+ init_image_builds();
1991
1021
  DEFAULT_IMAGE_NAME2 = "default";
1022
+ __imageBuildInternals = {
1023
+ loadNativeBinding: () => loadNativeBinding(),
1024
+ buildContextFromEnv: () => buildContextFromEnv(),
1025
+ stderrEmit: (event) => stderrEmit(event),
1026
+ noopEmit: (event) => noopEmit(event),
1027
+ eventToEmitDict: (event) => eventToEmitDict(event),
1028
+ imageRequiresContext: (image) => imageRequiresContext(image),
1029
+ defaultRegisteredName: (dockerfilePath) => defaultRegisteredName(dockerfilePath),
1030
+ defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference)
1031
+ };
1992
1032
  }
1993
1033
  });
1994
1034
  init_sandbox_image();
1995
1035
  // Annotate the CommonJS export names for ESM import in node:
1996
1036
  0 && (module.exports = {
1037
+ __imageBuildInternals,
1997
1038
  __setNativeBindingForTest,
1998
1039
  buildContextFromEnv,
1999
1040
  createSandboxImage,
2000
1041
  deleteSandboxImage,
1042
+ deleteSandboxImageWithCredentials,
2001
1043
  findSandboxImageByName,
1044
+ findSandboxImageByNameWithCredentials,
2002
1045
  importSandboxImage,
2003
1046
  listSandboxImages,
1047
+ listSandboxImagesWithCredentials,
2004
1048
  runCreateSandboxImageCli,
2005
1049
  runImportSandboxImageCli
2006
1050
  });