@tensorlakeai/tensorlake 0.5.154 → 0.5.156

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 (35) hide show
  1. package/dist/applications/index.cjs +131 -40
  2. package/dist/applications/index.cjs.map +1 -1
  3. package/dist/applications/index.d.cts +3 -3
  4. package/dist/applications/index.d.ts +3 -3
  5. package/dist/applications/index.js +131 -40
  6. package/dist/applications/index.js.map +1 -1
  7. package/dist/function-agent/main.cjs +1 -1
  8. package/dist/function-agent/main.js +1 -1
  9. package/dist/function-executor/main.cjs +2 -2
  10. package/dist/function-executor/main.js +2 -2
  11. package/dist/index.cjs +151 -47
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +25 -23
  14. package/dist/index.d.ts +25 -23
  15. package/dist/index.js +151 -47
  16. package/dist/index.js.map +1 -1
  17. package/dist/{remote-B3vn4tt1.d.cts → remote-CEs4GFGP.d.cts} +1 -1
  18. package/dist/{remote-DqBUuciu.d.ts → remote-DYBXCTNC.d.ts} +1 -1
  19. package/dist/{sandbox-image-BMiFlzAs.d.cts → sandbox-image-C2GTVnx3.d.cts} +99 -52
  20. package/dist/{sandbox-image-BMiFlzAs.d.ts → sandbox-image-C2GTVnx3.d.ts} +99 -52
  21. package/dist/sandbox-image.cjs +119 -30
  22. package/dist/sandbox-image.cjs.map +1 -1
  23. package/dist/sandbox-image.d.cts +1 -1
  24. package/dist/sandbox-image.d.ts +1 -1
  25. package/dist/sandbox-image.js +119 -30
  26. package/dist/sandbox-image.js.map +1 -1
  27. package/package.json +7 -7
  28. package/runtime/function-executor/manifest.json +5 -5
  29. package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
  30. package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
  31. package/runtime/function-executor/package/package.json +1 -1
  32. package/runtime/typescript-function-runner/manifest.json +5 -5
  33. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
  34. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
  35. package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as CloudClientOptions, A as ApplicationManifest, B as BinaryPayload, S as SandboxTemplate, a as ApplicationSummary, R as RequestInput, c as RequestMetadata, b as RequestOutput, d as SecretsList, e as Secret, N as NewSecret, U as UpsertSecretResponse, f as StartImageBuildRequest, g as BuildInfo, h as CreateApplicationBuildRequest, i as ApplicationBuildContext, j as ApplicationBuildResponse, k as BuildLogEntry, I as Image, l as CreateSandboxImageDeps, F as FileSystem } from './sandbox-image-BMiFlzAs.cjs';
2
- export { m as ApplicationBuildImageResult, n as CreateApplicationBuildImageRequest, o as CreateSandboxImageOptions, p as ImageBuildOperation, q as ImageBuildOperationType, q as ImageBuildOperationTypeValue, r as ImageOptions, s as ImportSandboxImageOptions, t as RequestErrorInfo, u as SandboxImageSource, v as SecretsPagination, w as createSandboxImage, x as deleteSandboxImage, y as dockerfileContent, z as findSandboxImageByName, D as importSandboxImage, E as listSandboxImages } from './sandbox-image-BMiFlzAs.cjs';
3
- export { v as APIClient, A as ApplicationCapability, a as ApplicationOptions, F as File, b as FunctionOptions, c as Future, H as Headers, d as HeadersInit, e as HttpBody, P as Parameter, g as RegisteredFunction, h as RemoteOptions, j as RequestContext, S as Schema, l as SimpleApplicationOptions, m as SimpleFunctionOptions, T as TailCall, r as registerApplication, o as registerFunction, p as remoteOptions, q as retries, s as runLocal, t as runRemote, u as schema } from './remote-B3vn4tt1.cjs';
1
+ import { C as CloudClientOptions, A as ApplicationManifest, B as BinaryPayload, S as SandboxTemplate, a as ApplicationSummary, R as RequestInput, c as RequestMetadata, b as RequestOutput, d as SecretsList, e as Secret, N as NewSecret, U as UpsertSecretResponse, f as StartImageBuildRequest, g as BuildInfo, h as CreateApplicationBuildRequest, i as ApplicationBuildContext, j as ApplicationBuildResponse, k as BuildLogEntry, I as Image, l as CreateSandboxImageDeps, F as FileSystem } from './sandbox-image-C2GTVnx3.cjs';
2
+ export { m as ApplicationBuildImageResult, n as CreateApplicationBuildImageRequest, o as CreateSandboxImageOptions, p as ImageBuildOperation, q as ImageBuildOperationType, q as ImageBuildOperationTypeValue, r as ImageOptions, s as ImportSandboxImageOptions, t as RequestErrorInfo, u as SandboxImageSource, v as SecretsPagination, w as createSandboxImage, x as deleteSandboxImage, y as dockerfileContent, z as findSandboxImageByName, D as importSandboxImage, E as listSandboxImages } from './sandbox-image-C2GTVnx3.cjs';
3
+ export { v as APIClient, A as ApplicationCapability, a as ApplicationOptions, F as File, b as FunctionOptions, c as Future, H as Headers, d as HeadersInit, e as HttpBody, P as Parameter, g as RegisteredFunction, h as RemoteOptions, j as RequestContext, S as Schema, l as SimpleApplicationOptions, m as SimpleFunctionOptions, T as TailCall, r as registerApplication, o as registerFunction, p as remoteOptions, q as retries, s as runLocal, t as runRemote, u as schema } from './remote-CEs4GFGP.cjs';
4
4
 
5
5
  /** An SDK result paired with its server-side W3C trace ID. */
6
6
  type Traced<T> = T & {
@@ -1693,19 +1693,21 @@ declare class CloudClient {
1693
1693
  upsertApplication(manifest: ApplicationManifest, codeZip: BinaryPayload, upgradeRunningRequests?: boolean): Promise<void>;
1694
1694
  deleteApplication(applicationName: string): Promise<void>;
1695
1695
  /**
1696
- * Delete a registered sandbox image by name or id through the merged
1697
- * catalog, with this client's credentials: an `image_` id or a name the
1698
- * Image Service knows deletes a CAS image, a `sandbox_template_` id or a
1699
- * name registered only in the platform registry deletes a legacy image.
1696
+ * Delete a registered CAS or legacy sandbox image by name or id through the
1697
+ * merged catalog, with this client's credentials: an `image_` id or a name
1698
+ * the CAS image registry knows deletes a CAS image, a `sandbox_template_` id
1699
+ * or a name registered only in the legacy image registry deletes a legacy
1700
+ * image.
1701
+ * A name is deleted from both the CAS and the legacy image registries.
1700
1702
  * Rejects when neither catalog knows the reference. The same semantics
1701
1703
  * and accepted differences as the module-level `deleteSandboxImage`.
1702
1704
  */
1703
1705
  deleteSandboxImage(imageName: string): Promise<void>;
1704
1706
  /**
1705
- * Look up a registered sandbox image by name or id through the merged
1706
- * catalog, with this client's credentials. Returns the image in the
1707
- * sandbox-template shape, or `null` when neither the Image Service nor the
1708
- * platform registry knows the reference. An explicit organization/project
1707
+ * Look up a registered CAS or legacy sandbox image by name or id through
1708
+ * the merged catalog, with this client's credentials. Returns the image in
1709
+ * the sandbox-template shape, or `null` when neither the CAS nor the legacy
1710
+ * image registry knows the reference. An explicit organization/project
1709
1711
  * scope (the client's, or the call's override) addresses that project's
1710
1712
  * routes directly, as before; without one the key's own scope applies.
1711
1713
  */
@@ -2041,18 +2043,18 @@ declare class RepositoryClient {
2041
2043
  }
2042
2044
 
2043
2045
  /**
2044
- * Image Service build operations for CAS sandbox images.
2046
+ * Build operations for CAS sandbox images.
2045
2047
  *
2046
- * A CAS (content-addressed streaming) image is built or imported by an Image
2047
- * Service *build operation*. This module exposes that operation directly:
2048
+ * A CAS (content-addressed streaming) image is built or imported by a *build
2049
+ * operation*. This module exposes that operation directly:
2048
2050
  * {@link startImageBuild} / {@link startImageImport} admit a build (and upload
2049
2051
  * and seal its context) and return an {@link ImageBuildHandle} without
2050
2052
  * waiting; {@link getImageBuild} looks a build up by id; the handle's
2051
2053
  * `refresh`, `wait` and `cancel` read, wait for and cancel it.
2052
2054
  *
2053
- * **CAS only.** Everything here addresses the Image Service. Legacy images
2054
- * (`createSandboxImage` without `cas`, `sandbox_template_` ids, `.tlsnap`
2055
- * snapshots) have no build operation: a `sandbox_template_` or `image_`
2055
+ * **CAS images only.** Everything here addresses a CAS image build. Legacy
2056
+ * images (`createSandboxImage` with `cas: false`, `sandbox_template_` ids,
2057
+ * `.tlsnap` snapshots) have no build operation: a `sandbox_template_` or `image_`
2056
2058
  * reference passed as a build id is refused locally, before any request, and
2057
2059
  * the legacy functions in `sandbox-image.ts` keep their own requests,
2058
2060
  * results, errors and interruption behavior.
@@ -2143,7 +2145,7 @@ interface ImageBuildErrorDetails {
2143
2145
  waitedSecs?: number | null;
2144
2146
  status?: number | null;
2145
2147
  }
2146
- /** An Image Service build operation failed. `code` is stable. */
2148
+ /** A CAS image build operation failed. `code` is stable. */
2147
2149
  declare class ImageBuildError extends Error {
2148
2150
  readonly code: ImageBuildErrorCode;
2149
2151
  readonly buildId?: string;
@@ -2199,14 +2201,14 @@ declare class ImageBuildInterruptedError extends ImageBuildError {
2199
2201
  constructor(details: ImageBuildErrorDetails);
2200
2202
  }
2201
2203
  /**
2202
- * The published image of a succeeded build, in the sandbox-template shape
2203
- * the merged catalog answers (derived by the core from the Image Service's
2204
- * trimmed record): one image representation for `findSandboxImageByName`,
2205
- * `listSandboxImages` and build results.
2204
+ * The published CAS image of a succeeded build, in the sandbox-template
2205
+ * shape the merged catalog answers (derived by the core from the CAS image
2206
+ * registry's trimmed record): one image representation for
2207
+ * `findSandboxImageByName`, `listSandboxImages` and build results.
2206
2208
  */
2207
2209
  type ImageBuildResult = SandboxTemplate;
2208
2210
  /**
2209
- * One build or import as the Image Service reports it (the twelve-field
2211
+ * One CAS image build or import as the service reports it (the twelve-field
2210
2212
  * `BuildInfo`; the service exposes no cleanup state, phase deadline,
2211
2213
  * content digest or upload capability on a build).
2212
2214
  */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as CloudClientOptions, A as ApplicationManifest, B as BinaryPayload, S as SandboxTemplate, a as ApplicationSummary, R as RequestInput, c as RequestMetadata, b as RequestOutput, d as SecretsList, e as Secret, N as NewSecret, U as UpsertSecretResponse, f as StartImageBuildRequest, g as BuildInfo, h as CreateApplicationBuildRequest, i as ApplicationBuildContext, j as ApplicationBuildResponse, k as BuildLogEntry, I as Image, l as CreateSandboxImageDeps, F as FileSystem } from './sandbox-image-BMiFlzAs.js';
2
- export { m as ApplicationBuildImageResult, n as CreateApplicationBuildImageRequest, o as CreateSandboxImageOptions, p as ImageBuildOperation, q as ImageBuildOperationType, q as ImageBuildOperationTypeValue, r as ImageOptions, s as ImportSandboxImageOptions, t as RequestErrorInfo, u as SandboxImageSource, v as SecretsPagination, w as createSandboxImage, x as deleteSandboxImage, y as dockerfileContent, z as findSandboxImageByName, D as importSandboxImage, E as listSandboxImages } from './sandbox-image-BMiFlzAs.js';
3
- export { v as APIClient, A as ApplicationCapability, a as ApplicationOptions, F as File, b as FunctionOptions, c as Future, H as Headers, d as HeadersInit, e as HttpBody, P as Parameter, g as RegisteredFunction, h as RemoteOptions, j as RequestContext, S as Schema, l as SimpleApplicationOptions, m as SimpleFunctionOptions, T as TailCall, r as registerApplication, o as registerFunction, p as remoteOptions, q as retries, s as runLocal, t as runRemote, u as schema } from './remote-DqBUuciu.js';
1
+ import { C as CloudClientOptions, A as ApplicationManifest, B as BinaryPayload, S as SandboxTemplate, a as ApplicationSummary, R as RequestInput, c as RequestMetadata, b as RequestOutput, d as SecretsList, e as Secret, N as NewSecret, U as UpsertSecretResponse, f as StartImageBuildRequest, g as BuildInfo, h as CreateApplicationBuildRequest, i as ApplicationBuildContext, j as ApplicationBuildResponse, k as BuildLogEntry, I as Image, l as CreateSandboxImageDeps, F as FileSystem } from './sandbox-image-C2GTVnx3.js';
2
+ export { m as ApplicationBuildImageResult, n as CreateApplicationBuildImageRequest, o as CreateSandboxImageOptions, p as ImageBuildOperation, q as ImageBuildOperationType, q as ImageBuildOperationTypeValue, r as ImageOptions, s as ImportSandboxImageOptions, t as RequestErrorInfo, u as SandboxImageSource, v as SecretsPagination, w as createSandboxImage, x as deleteSandboxImage, y as dockerfileContent, z as findSandboxImageByName, D as importSandboxImage, E as listSandboxImages } from './sandbox-image-C2GTVnx3.js';
3
+ export { v as APIClient, A as ApplicationCapability, a as ApplicationOptions, F as File, b as FunctionOptions, c as Future, H as Headers, d as HeadersInit, e as HttpBody, P as Parameter, g as RegisteredFunction, h as RemoteOptions, j as RequestContext, S as Schema, l as SimpleApplicationOptions, m as SimpleFunctionOptions, T as TailCall, r as registerApplication, o as registerFunction, p as remoteOptions, q as retries, s as runLocal, t as runRemote, u as schema } from './remote-DYBXCTNC.js';
4
4
 
5
5
  /** An SDK result paired with its server-side W3C trace ID. */
6
6
  type Traced<T> = T & {
@@ -1693,19 +1693,21 @@ declare class CloudClient {
1693
1693
  upsertApplication(manifest: ApplicationManifest, codeZip: BinaryPayload, upgradeRunningRequests?: boolean): Promise<void>;
1694
1694
  deleteApplication(applicationName: string): Promise<void>;
1695
1695
  /**
1696
- * Delete a registered sandbox image by name or id through the merged
1697
- * catalog, with this client's credentials: an `image_` id or a name the
1698
- * Image Service knows deletes a CAS image, a `sandbox_template_` id or a
1699
- * name registered only in the platform registry deletes a legacy image.
1696
+ * Delete a registered CAS or legacy sandbox image by name or id through the
1697
+ * merged catalog, with this client's credentials: an `image_` id or a name
1698
+ * the CAS image registry knows deletes a CAS image, a `sandbox_template_` id
1699
+ * or a name registered only in the legacy image registry deletes a legacy
1700
+ * image.
1701
+ * A name is deleted from both the CAS and the legacy image registries.
1700
1702
  * Rejects when neither catalog knows the reference. The same semantics
1701
1703
  * and accepted differences as the module-level `deleteSandboxImage`.
1702
1704
  */
1703
1705
  deleteSandboxImage(imageName: string): Promise<void>;
1704
1706
  /**
1705
- * Look up a registered sandbox image by name or id through the merged
1706
- * catalog, with this client's credentials. Returns the image in the
1707
- * sandbox-template shape, or `null` when neither the Image Service nor the
1708
- * platform registry knows the reference. An explicit organization/project
1707
+ * Look up a registered CAS or legacy sandbox image by name or id through
1708
+ * the merged catalog, with this client's credentials. Returns the image in
1709
+ * the sandbox-template shape, or `null` when neither the CAS nor the legacy
1710
+ * image registry knows the reference. An explicit organization/project
1709
1711
  * scope (the client's, or the call's override) addresses that project's
1710
1712
  * routes directly, as before; without one the key's own scope applies.
1711
1713
  */
@@ -2041,18 +2043,18 @@ declare class RepositoryClient {
2041
2043
  }
2042
2044
 
2043
2045
  /**
2044
- * Image Service build operations for CAS sandbox images.
2046
+ * Build operations for CAS sandbox images.
2045
2047
  *
2046
- * A CAS (content-addressed streaming) image is built or imported by an Image
2047
- * Service *build operation*. This module exposes that operation directly:
2048
+ * A CAS (content-addressed streaming) image is built or imported by a *build
2049
+ * operation*. This module exposes that operation directly:
2048
2050
  * {@link startImageBuild} / {@link startImageImport} admit a build (and upload
2049
2051
  * and seal its context) and return an {@link ImageBuildHandle} without
2050
2052
  * waiting; {@link getImageBuild} looks a build up by id; the handle's
2051
2053
  * `refresh`, `wait` and `cancel` read, wait for and cancel it.
2052
2054
  *
2053
- * **CAS only.** Everything here addresses the Image Service. Legacy images
2054
- * (`createSandboxImage` without `cas`, `sandbox_template_` ids, `.tlsnap`
2055
- * snapshots) have no build operation: a `sandbox_template_` or `image_`
2055
+ * **CAS images only.** Everything here addresses a CAS image build. Legacy
2056
+ * images (`createSandboxImage` with `cas: false`, `sandbox_template_` ids,
2057
+ * `.tlsnap` snapshots) have no build operation: a `sandbox_template_` or `image_`
2056
2058
  * reference passed as a build id is refused locally, before any request, and
2057
2059
  * the legacy functions in `sandbox-image.ts` keep their own requests,
2058
2060
  * results, errors and interruption behavior.
@@ -2143,7 +2145,7 @@ interface ImageBuildErrorDetails {
2143
2145
  waitedSecs?: number | null;
2144
2146
  status?: number | null;
2145
2147
  }
2146
- /** An Image Service build operation failed. `code` is stable. */
2148
+ /** A CAS image build operation failed. `code` is stable. */
2147
2149
  declare class ImageBuildError extends Error {
2148
2150
  readonly code: ImageBuildErrorCode;
2149
2151
  readonly buildId?: string;
@@ -2199,14 +2201,14 @@ declare class ImageBuildInterruptedError extends ImageBuildError {
2199
2201
  constructor(details: ImageBuildErrorDetails);
2200
2202
  }
2201
2203
  /**
2202
- * The published image of a succeeded build, in the sandbox-template shape
2203
- * the merged catalog answers (derived by the core from the Image Service's
2204
- * trimmed record): one image representation for `findSandboxImageByName`,
2205
- * `listSandboxImages` and build results.
2204
+ * The published CAS image of a succeeded build, in the sandbox-template
2205
+ * shape the merged catalog answers (derived by the core from the CAS image
2206
+ * registry's trimmed record): one image representation for
2207
+ * `findSandboxImageByName`, `listSandboxImages` and build results.
2206
2208
  */
2207
2209
  type ImageBuildResult = SandboxTemplate;
2208
2210
  /**
2209
- * One build or import as the Image Service reports it (the twelve-field
2211
+ * One CAS image build or import as the service reports it (the twelve-field
2210
2212
  * `BuildInfo`; the service exposes no cleanup state, phase deadline,
2211
2213
  * content digest or upload capability on a build).
2212
2214
  */
package/dist/index.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.154";
49
+ SDK_VERSION = "0.5.156";
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";
@@ -509,7 +509,7 @@ var init_native_worker_client = __esm({
509
509
  }
510
510
  };
511
511
  runtimeKey = /* @__PURE__ */ Symbol.for(
512
- `tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
512
+ `tensorlake.native.worker.${false ? "source" : "0.5.156"}.v1`
513
513
  );
514
514
  runtimes = globalThis;
515
515
  }
@@ -5716,10 +5716,11 @@ var init_image = __esm({
5716
5716
  });
5717
5717
  }
5718
5718
  /**
5719
- * Build this image as a sandbox template and register it.
5719
+ * Build this image and register it as a CAS sandbox image (the default) or,
5720
+ * with `cas: false`, a legacy sandbox image.
5720
5721
  *
5721
5722
  * Materializes the image in a build sandbox, snapshots the filesystem,
5722
- * and registers the snapshot as a named sandbox template.
5723
+ * and registers the snapshot under the image's name.
5723
5724
  */
5724
5725
  async build(options = {}) {
5725
5726
  const { createSandboxImage: createSandboxImage2 } = await Promise.resolve().then(() => (init_sandbox_image(), sandbox_image_exports));
@@ -6002,14 +6003,14 @@ function rejectLegacyReference(buildId) {
6002
6003
  if (buildId.startsWith("sandbox_template_")) {
6003
6004
  throw new ImageBuildError({
6004
6005
  code: "usage" /* USAGE */,
6005
- message: `'${buildId}' is a legacy sandbox template id; legacy images have no build operation to get, wait for or cancel`,
6006
+ message: `'${buildId}' is a legacy image id; legacy images have no build operation to get, wait for or cancel`,
6006
6007
  buildId
6007
6008
  });
6008
6009
  }
6009
6010
  if (buildId.startsWith("image_")) {
6010
6011
  throw new ImageBuildError({
6011
6012
  code: "usage" /* USAGE */,
6012
- message: `'${buildId}' is an image id, not a build id; look the image up with findSandboxImageByName or use the build id admission returned`,
6013
+ message: `'${buildId}' is a CAS image id, not a build id; look the CAS image up with findSandboxImageByName or use the build id admission returned`,
6013
6014
  buildId
6014
6015
  });
6015
6016
  }
@@ -6088,19 +6089,27 @@ async function startImageBuild(source, options = {}, deps = {}) {
6088
6089
  let text = dockerfileContent(source);
6089
6090
  if (!text.endsWith("\n")) text += "\n";
6090
6091
  dockerfileText = text;
6091
- name = options.registeredName ?? source.name;
6092
+ name = __imageBuildInternals.registeredImageName(
6093
+ options.registeredName ?? source.name,
6094
+ void 0,
6095
+ true
6096
+ );
6092
6097
  } else if (typeof source === "string") {
6093
6098
  const resolved = path3.resolve(source);
6094
6099
  if (!existsSync2(resolved)) throw new Error(`Dockerfile not found: ${source}`);
6095
6100
  dockerfilePath = resolved;
6096
- name = options.registeredName ?? __imageBuildInternals.defaultRegisteredName(resolved);
6101
+ name = __imageBuildInternals.registeredImageName(
6102
+ options.registeredName,
6103
+ __imageBuildInternals.defaultRegisteredName(resolved),
6104
+ true
6105
+ );
6097
6106
  } else {
6098
6107
  throw new TypeError(`source must be an Image or a Dockerfile path, got ${typeof source}`);
6099
6108
  }
6100
6109
  try {
6101
6110
  const credentials = credentialsFromEnv();
6102
6111
  const binding = __imageBuildInternals.loadNativeBinding();
6103
- emitter.emit({ type: "status", message: `Building image '${name}'...` });
6112
+ emitter.emit({ type: "status", message: `Building CAS image '${name}'...` });
6104
6113
  const json = await __runWithInterrupt(
6105
6114
  options.signal,
6106
6115
  (interruptId) => binding.startImageBuild(
@@ -6136,11 +6145,16 @@ async function startImageImport(imageReference, options = {}, deps = {}) {
6136
6145
  throw new Error("image reference to import must not be empty");
6137
6146
  }
6138
6147
  const reference = imageReference.trim();
6139
- const name = options.registeredName ?? __imageBuildInternals.defaultRegisteredNameFromImage(reference);
6148
+ const name = __imageBuildInternals.registeredImageName(
6149
+ options.registeredName,
6150
+ __imageBuildInternals.defaultRegisteredNameFromImage(reference),
6151
+ true,
6152
+ __imageBuildInternals.defaultImportedImageName
6153
+ );
6140
6154
  const emitter = makeEmitter({ emit: deps.emit ?? options.emit, verbose: options.verbose });
6141
6155
  const credentials = credentialsFromEnv();
6142
6156
  const binding = __imageBuildInternals.loadNativeBinding();
6143
- emitter.emit({ type: "status", message: `Importing image '${reference}' as '${name}'...` });
6157
+ emitter.emit({ type: "status", message: `Importing '${reference}' as CAS image '${name}'...` });
6144
6158
  const json = await __runWithInterrupt(
6145
6159
  options.signal,
6146
6160
  (interruptId) => binding.startImageImport(
@@ -6477,16 +6491,58 @@ function defaultRegisteredName(dockerfilePath) {
6477
6491
  const parsed = path4.parse(dockerfilePath);
6478
6492
  if (parsed.name.toLowerCase() === "dockerfile") {
6479
6493
  const parentName = path4.basename(path4.dirname(dockerfilePath)).trim();
6480
- return parentName || "sandbox-image";
6494
+ return parentName || DEFAULT_SANDBOX_IMAGE_NAME;
6481
6495
  }
6482
- return parsed.name || "sandbox-image";
6496
+ return parsed.name || DEFAULT_SANDBOX_IMAGE_NAME;
6497
+ }
6498
+ function registeredImageName(explicit, generated, cas, fallback = DEFAULT_SANDBOX_IMAGE_NAME) {
6499
+ if (explicit || generated === void 0) {
6500
+ const name = explicit ?? "";
6501
+ return cas ? canonicalCasImageName(name) : name;
6502
+ }
6503
+ return cas ? casImageNameFrom(generated, fallback) : generated;
6504
+ }
6505
+ function canonicalCasImageName(name) {
6506
+ return name.replace(/[A-Z]/g, (c) => c.toLowerCase());
6507
+ }
6508
+ function casImageNameFrom(raw, fallback) {
6509
+ const lowered = canonicalCasImageName(raw);
6510
+ if (isAddressableCasImageName(lowered)) {
6511
+ return lowered;
6512
+ }
6513
+ let name = "";
6514
+ for (const original of lowered) {
6515
+ const ch = /^[a-z0-9._-]$/.test(original) ? original : "-";
6516
+ const previous = name[name.length - 1];
6517
+ if (CAS_NAME_SEPARATORS.includes(ch) && previous !== void 0 && CAS_NAME_SEPARATORS.includes(previous)) {
6518
+ continue;
6519
+ }
6520
+ name += ch;
6521
+ }
6522
+ name = name.replace(/^[._-]+|[._-]+$/g, "").slice(0, MAX_CAS_IMAGE_NAME_LENGTH).replace(/[._-]+$/, "");
6523
+ return isAddressableCasImageName(name) ? name : fallback;
6524
+ }
6525
+ function isAddressableCasImageName(name) {
6526
+ if (name.length === 0 || name.length > MAX_CAS_IMAGE_NAME_LENGTH || RESERVED_IMAGE_NAME_PREFIXES.some((prefix) => name.startsWith(prefix)) || /^[0-9a-f]{64}$/.test(name)) {
6527
+ return false;
6528
+ }
6529
+ const colon = name.indexOf(":");
6530
+ const repository = colon === -1 ? name : name.slice(0, colon);
6531
+ if (!repository.split("/").every((component) => /^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(component))) {
6532
+ return false;
6533
+ }
6534
+ if (colon === -1) {
6535
+ return true;
6536
+ }
6537
+ const tag = name.slice(colon + 1);
6538
+ return tag.length > 0 && tag.length <= 128 && /^[a-z0-9._-]+$/.test(tag) && !tag.startsWith(".") && !tag.startsWith("-");
6483
6539
  }
6484
6540
  function defaultRegisteredNameFromImage(imageReference) {
6485
6541
  const withoutDigest = imageReference.split("@", 1)[0] ?? imageReference;
6486
6542
  const lastSegment = withoutDigest.split("/").pop() ?? withoutDigest;
6487
6543
  const colonIndex = lastSegment.lastIndexOf(":");
6488
6544
  const name = colonIndex > 0 && colonIndex < lastSegment.length - 1 ? lastSegment.slice(0, colonIndex) : lastSegment;
6489
- return name || "imported-image";
6545
+ return name || DEFAULT_IMPORTED_IMAGE_NAME;
6490
6546
  }
6491
6547
  function noopEmit(_event) {
6492
6548
  }
@@ -6589,7 +6645,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
6589
6645
  if (!text.endsWith("\n")) text += "\n";
6590
6646
  dockerfileText = text;
6591
6647
  nativeContextDir = resolvedContext;
6592
- effectiveName = options.registeredName ?? source.name;
6648
+ effectiveName = registeredImageName(
6649
+ options.registeredName ?? source.name,
6650
+ void 0,
6651
+ options.cas ?? true
6652
+ );
6593
6653
  } else if (typeof source === "string") {
6594
6654
  const resolvedPath = path4.resolve(source);
6595
6655
  if (!existsSync3(resolvedPath)) {
@@ -6598,7 +6658,11 @@ async function createSandboxImage(source, options = {}, deps = {}) {
6598
6658
  dockerfilePath = resolvedPath;
6599
6659
  dockerfileText = void 0;
6600
6660
  nativeContextDir = void 0;
6601
- effectiveName = options.registeredName ?? defaultRegisteredName(resolvedPath);
6661
+ effectiveName = registeredImageName(
6662
+ options.registeredName,
6663
+ defaultRegisteredName(resolvedPath),
6664
+ options.cas ?? true
6665
+ );
6602
6666
  } else {
6603
6667
  throw new TypeError(
6604
6668
  `source must be an Image or a Dockerfile path, got ${typeof source}`
@@ -6622,12 +6686,16 @@ async function createSandboxImage(source, options = {}, deps = {}) {
6622
6686
  deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
6623
6687
  );
6624
6688
  }
6625
- if (options.signal !== void 0 && !options.cas) {
6689
+ const cas = options.cas ?? true;
6690
+ if (options.signal !== void 0 && !cas) {
6626
6691
  throw new Error(
6627
- "signal is only supported for CAS image builds (cas: true); a legacy build has no Image Service build operation to cancel"
6692
+ "signal is not supported for legacy image builds (cas: false): a legacy image build has no build operation to cancel"
6628
6693
  );
6629
6694
  }
6630
- emit({ type: "status", message: `Building image '${effectiveName}'...` });
6695
+ emit({
6696
+ type: "status",
6697
+ message: `Building ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
6698
+ });
6631
6699
  const binding = loadNativeBinding();
6632
6700
  let emitError;
6633
6701
  const nativeOptions = {
@@ -6649,7 +6717,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
6649
6717
  dockerConfigJson: options.dockerConfigJson,
6650
6718
  dockerfileText,
6651
6719
  contextDir: nativeContextDir,
6652
- cas: options.cas ?? false,
6720
+ cas,
6653
6721
  buildArgs: options.buildArgs
6654
6722
  };
6655
6723
  const forward = (event) => {
@@ -6659,7 +6727,7 @@ async function createSandboxImage(source, options = {}, deps = {}) {
6659
6727
  emitError ??= error;
6660
6728
  }
6661
6729
  };
6662
- const resultJson = options.cas ? await __runWithInterrupt(
6730
+ const resultJson = cas ? await __runWithInterrupt(
6663
6731
  options.signal,
6664
6732
  (interruptId) => binding.buildSandboxImage(nativeOptions, forward, interruptId)
6665
6733
  ) : await binding.buildSandboxImage(nativeOptions, forward);
@@ -6690,7 +6758,12 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
6690
6758
  }
6691
6759
  const reference = imageReference.trim();
6692
6760
  const context = buildContextFromEnv();
6693
- const effectiveName = options.registeredName ?? defaultRegisteredNameFromImage(reference);
6761
+ const effectiveName = registeredImageName(
6762
+ options.registeredName,
6763
+ defaultRegisteredNameFromImage(reference),
6764
+ options.cas ?? true,
6765
+ DEFAULT_IMPORTED_IMAGE_NAME
6766
+ );
6694
6767
  if (effectiveName === DEFAULT_IMAGE_NAME2) {
6695
6768
  console.warn(
6696
6769
  `Importing sandbox image with the default name "${DEFAULT_IMAGE_NAME2}". Pass \`registeredName\` to avoid collisions with other default-named images in this project.`
@@ -6708,14 +6781,15 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
6708
6781
  deps._allowPat ? "Missing TENSORLAKE_API_KEY or TENSORLAKE_PAT credentials." : "Missing TENSORLAKE_API_KEY credentials."
6709
6782
  );
6710
6783
  }
6711
- if (options.signal !== void 0 && !options.cas) {
6784
+ const cas = options.cas ?? true;
6785
+ if (options.signal !== void 0 && !cas) {
6712
6786
  throw new Error(
6713
- "signal is only supported for CAS image imports (cas: true); a legacy import has no Image Service build operation to cancel"
6787
+ "signal is not supported for legacy image imports (cas: false): a legacy image import has no build operation to cancel"
6714
6788
  );
6715
6789
  }
6716
6790
  emit({
6717
6791
  type: "status",
6718
- message: `Importing image '${reference}' as '${effectiveName}'...`
6792
+ message: `Importing '${reference}' as ${cas ? "CAS" : "legacy"} image '${effectiveName}'...`
6719
6793
  });
6720
6794
  const binding = loadNativeBinding();
6721
6795
  let emitError;
@@ -6736,7 +6810,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
6736
6810
  userAgent: void 0,
6737
6811
  dockerCompat: options.dockerCompat ?? false,
6738
6812
  dockerConfigJson: options.dockerConfigJson,
6739
- cas: options.cas ?? false
6813
+ cas
6740
6814
  };
6741
6815
  const forward = (event) => {
6742
6816
  try {
@@ -6745,7 +6819,7 @@ async function importSandboxImage(imageReference, options = {}, deps = {}) {
6745
6819
  emitError ??= error;
6746
6820
  }
6747
6821
  };
6748
- const resultJson = options.cas ? await __runWithInterrupt(
6822
+ const resultJson = cas ? await __runWithInterrupt(
6749
6823
  options.signal,
6750
6824
  (interruptId) => binding.importSandboxImage(nativeOptions, forward, interruptId)
6751
6825
  ) : await binding.importSandboxImage(nativeOptions, forward);
@@ -6802,15 +6876,29 @@ async function deleteSandboxImage(imageName) {
6802
6876
  if (typeof imageName !== "string" || imageName.length === 0) {
6803
6877
  throw new TypeError("imageName must be a non-empty string");
6804
6878
  }
6805
- await loadNativeBinding().deleteSandboxImage(catalogOptionsFromEnv(), imageName);
6879
+ warnIncompleteLegacyCleanup(
6880
+ await loadNativeBinding().deleteSandboxImage(catalogOptionsFromEnv(), imageName)
6881
+ );
6806
6882
  }
6807
6883
  async function deleteSandboxImageWithCredentials(credentials, imageName) {
6808
6884
  if (typeof imageName !== "string" || imageName.length === 0) {
6809
6885
  throw new TypeError("imageName must be a non-empty string");
6810
6886
  }
6811
- await loadNativeBinding().deleteSandboxImage(
6812
- catalogOptionsFromCredentials(credentials),
6813
- imageName
6887
+ warnIncompleteLegacyCleanup(
6888
+ await loadNativeBinding().deleteSandboxImage(
6889
+ catalogOptionsFromCredentials(credentials),
6890
+ imageName
6891
+ )
6892
+ );
6893
+ }
6894
+ function warnIncompleteLegacyCleanup(failure) {
6895
+ if (failure == null) {
6896
+ return;
6897
+ }
6898
+ const legacyImageId = failure.legacyImageId ?? void 0;
6899
+ const label = legacyImageId ? ` (${legacyImageId})` : "";
6900
+ console.warn(
6901
+ `Deleted CAS image '${failure.legacyImageName}', but could not delete the legacy image of the same name${label}, which can no longer start sandboxes: ${failure.error}. Delete it with deleteSandboxImage("${legacyImageId ?? failure.legacyImageName}").`
6814
6902
  );
6815
6903
  }
6816
6904
  async function findSandboxImageByName(imageName) {
@@ -6854,13 +6942,14 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
6854
6942
  disk_mb: { type: "string" },
6855
6943
  builder_disk_mb: { type: "string" },
6856
6944
  docker_compat: { type: "boolean", default: false },
6857
- public: { type: "boolean", default: false }
6945
+ public: { type: "boolean", default: false },
6946
+ "no-cas": { type: "boolean", default: false }
6858
6947
  }
6859
6948
  });
6860
6949
  const dockerfilePath = parsed.positionals[0];
6861
6950
  if (!dockerfilePath) {
6862
6951
  throw new Error(
6863
- "Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
6952
+ "Usage: tensorlake-create-sandbox-image <dockerfile_path> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public] [--no-cas]"
6864
6953
  );
6865
6954
  }
6866
6955
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
@@ -6892,7 +6981,8 @@ async function runCreateSandboxImageCli(argv = process.argv.slice(2)) {
6892
6981
  diskMb,
6893
6982
  builderDiskMb,
6894
6983
  dockerCompat: parsed.values.docker_compat,
6895
- isPublic: parsed.values.public
6984
+ isPublic: parsed.values.public,
6985
+ cas: !parsed.values["no-cas"]
6896
6986
  },
6897
6987
  { emit: ndjsonStdoutEmit, _allowPat: true }
6898
6988
  );
@@ -6908,13 +6998,14 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
6908
6998
  disk_mb: { type: "string" },
6909
6999
  builder_disk_mb: { type: "string" },
6910
7000
  docker_compat: { type: "boolean", default: false },
6911
- public: { type: "boolean", default: false }
7001
+ public: { type: "boolean", default: false },
7002
+ "no-cas": { type: "boolean", default: false }
6912
7003
  }
6913
7004
  });
6914
7005
  const imageReference = parsed.positionals[0];
6915
7006
  if (!imageReference) {
6916
7007
  throw new Error(
6917
- "Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public]"
7008
+ "Usage: tensorlake-import-sandbox-image <image_reference> [--name NAME] [--cpus N] [--memory MiB] [--disk_mb MiB] [--builder_disk_mb MiB] [--docker_compat] [--public] [--no-cas]"
6918
7009
  );
6919
7010
  }
6920
7011
  const cpus = parsed.values.cpus != null ? Number(parsed.values.cpus) : void 0;
@@ -6946,12 +7037,13 @@ async function runImportSandboxImageCli(argv = process.argv.slice(2)) {
6946
7037
  diskMb,
6947
7038
  builderDiskMb,
6948
7039
  dockerCompat: parsed.values.docker_compat,
6949
- isPublic: parsed.values.public
7040
+ isPublic: parsed.values.public,
7041
+ cas: !parsed.values["no-cas"]
6950
7042
  },
6951
7043
  { emit: ndjsonStdoutEmit, _allowPat: true }
6952
7044
  );
6953
7045
  }
6954
- var cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, __imageBuildInternals;
7046
+ var cachedNativeBinding, cachedNativeBindingError, DEFAULT_IMAGE_NAME2, DEFAULT_SANDBOX_IMAGE_NAME, DEFAULT_IMPORTED_IMAGE_NAME, CAS_NAME_SEPARATORS, RESERVED_IMAGE_NAME_PREFIXES, MAX_CAS_IMAGE_NAME_LENGTH, __imageBuildInternals;
6955
7047
  var init_sandbox_image = __esm({
6956
7048
  "src/sandbox-image.ts"() {
6957
7049
  "use strict";
@@ -6960,6 +7052,11 @@ var init_sandbox_image = __esm({
6960
7052
  init_native_binding();
6961
7053
  init_image_builds();
6962
7054
  DEFAULT_IMAGE_NAME2 = "default";
7055
+ DEFAULT_SANDBOX_IMAGE_NAME = "sandbox-image";
7056
+ DEFAULT_IMPORTED_IMAGE_NAME = "imported-image";
7057
+ CAS_NAME_SEPARATORS = "._-";
7058
+ RESERVED_IMAGE_NAME_PREFIXES = ["sandbox_template_", "image_", "cas-v1:"];
7059
+ MAX_CAS_IMAGE_NAME_LENGTH = 255;
6963
7060
  __imageBuildInternals = {
6964
7061
  loadNativeBinding: () => loadNativeBinding(),
6965
7062
  buildContextFromEnv: () => buildContextFromEnv(),
@@ -6968,7 +7065,12 @@ var init_sandbox_image = __esm({
6968
7065
  eventToEmitDict: (event) => eventToEmitDict(event),
6969
7066
  imageRequiresContext: (image) => imageRequiresContext(image),
6970
7067
  defaultRegisteredName: (dockerfilePath) => defaultRegisteredName(dockerfilePath),
6971
- defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference)
7068
+ defaultRegisteredNameFromImage: (reference) => defaultRegisteredNameFromImage(reference),
7069
+ registeredImageName: (explicit, generated, cas, fallback) => registeredImageName(explicit, generated, cas, fallback),
7070
+ casImageNameFrom: (raw, fallback) => casImageNameFrom(raw, fallback),
7071
+ canonicalCasImageName: (name) => canonicalCasImageName(name),
7072
+ isAddressableCasImageName: (name) => isAddressableCasImageName(name),
7073
+ defaultImportedImageName: DEFAULT_IMPORTED_IMAGE_NAME
6972
7074
  };
6973
7075
  }
6974
7076
  });
@@ -7135,10 +7237,12 @@ var CloudClient = class _CloudClient {
7135
7237
  );
7136
7238
  }
7137
7239
  /**
7138
- * Delete a registered sandbox image by name or id through the merged
7139
- * catalog, with this client's credentials: an `image_` id or a name the
7140
- * Image Service knows deletes a CAS image, a `sandbox_template_` id or a
7141
- * name registered only in the platform registry deletes a legacy image.
7240
+ * Delete a registered CAS or legacy sandbox image by name or id through the
7241
+ * merged catalog, with this client's credentials: an `image_` id or a name
7242
+ * the CAS image registry knows deletes a CAS image, a `sandbox_template_` id
7243
+ * or a name registered only in the legacy image registry deletes a legacy
7244
+ * image.
7245
+ * A name is deleted from both the CAS and the legacy image registries.
7142
7246
  * Rejects when neither catalog knows the reference. The same semantics
7143
7247
  * and accepted differences as the module-level `deleteSandboxImage`.
7144
7248
  */
@@ -7146,10 +7250,10 @@ var CloudClient = class _CloudClient {
7146
7250
  await deleteSandboxImageWithCredentials(this.catalogCredentials(), imageName);
7147
7251
  }
7148
7252
  /**
7149
- * Look up a registered sandbox image by name or id through the merged
7150
- * catalog, with this client's credentials. Returns the image in the
7151
- * sandbox-template shape, or `null` when neither the Image Service nor the
7152
- * platform registry knows the reference. An explicit organization/project
7253
+ * Look up a registered CAS or legacy sandbox image by name or id through
7254
+ * the merged catalog, with this client's credentials. Returns the image in
7255
+ * the sandbox-template shape, or `null` when neither the CAS nor the legacy
7256
+ * image registry knows the reference. An explicit organization/project
7153
7257
  * scope (the client's, or the call's override) addresses that project's
7154
7258
  * routes directly, as before; without one the key's own scope applies.
7155
7259
  */