@constal/sdk 6.10.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/publish/index.js CHANGED
@@ -563,47 +563,48 @@ var casTool = {
563
563
  };
564
564
 
565
565
  // packages/sdk/src/skills.ts
566
- async function required(workspace, skill, cmd, args, timeoutMs) {
567
- const result = timeoutMs === void 0 ? await workspace.exec({ cmd, args }) : await workspace.exec({ cmd, args, timeoutMs }, { timeoutMs });
568
- if (result.status !== "completed" || result.exitCode !== 0) {
569
- throw new Error(`Copying skill ${skill} into the workspace failed: ${cmd} ended ${result.status} with exit code ${result.exitCode}. ${result.stderrPreview}`);
566
+ async function required(sandbox, skill, cmd, args, timeoutMs) {
567
+ const result = timeoutMs === void 0 ? await sandbox.exec({ cmd, args }) : await sandbox.exec({ cmd, args, timeoutMs }, { timeoutMs });
568
+ if (result.state !== "exited" || result.exitCode !== 0) {
569
+ throw new Error(`Copying skill ${skill} into the sandbox failed: ${cmd} ended ${result.state} with exit code ${result.exitCode}. ${result.stderr}`);
570
570
  }
571
571
  }
572
- function skills(binding = "skills", sandbox = "sandbox") {
572
+ function skills(binding = "skills", pool = "sandbox") {
573
573
  const prefix = binding.replaceAll(/[.-]/gu, "_");
574
574
  const find = opTool(binding, "find", { name: `${prefix}_find` });
575
575
  const read = opTool(binding, "read", { name: `${prefix}_read` });
576
576
  const run = {
577
577
  name: `${prefix}_run`,
578
- version: "1",
579
- description: "Runs one command in the sandbox workspace with its working directory set to a copy of a skill's folder, which holds the skill's SKILL.md and every file it bundles. Returns the folder's path and the command's result: its status, exit code and output.",
580
- schema: { type: "object", required: ["skill", "cmd"], additionalProperties: false, properties: {
578
+ version: "2",
579
+ description: "Runs one command in a sandbox with its working directory set to a copy of a skill's folder, which holds the skill's SKILL.md and every file it bundles. Returns the folder's path and the command's result: its state, exit code and output.",
580
+ schema: { type: "object", required: ["skill", "sandbox", "cmd"], additionalProperties: false, properties: {
581
581
  skill: { type: "string", minLength: 1, description: "The skill's name." },
582
+ sandbox: { type: "string", minLength: 1, description: "The id of the running sandbox to run it in." },
582
583
  cmd: { type: "string", minLength: 1, description: "The program to run." },
583
584
  args: { type: "array", items: { type: "string" }, description: "The program's arguments." },
584
585
  env: { type: "object", additionalProperties: { type: "string" }, description: "Environment variables for the command." },
585
586
  stdin: { type: "string", description: "Text the command reads on its standard input." },
586
- timeoutMs: { type: "integer", minimum: 1, description: "How long each command may run, in milliseconds: the program, and each command that copies the skill's folder into the workspace." }
587
+ timeoutMs: { type: "integer", minimum: 1, description: "How long each command may run, in milliseconds: the program, and each command that copies the skill's folder into the sandbox." }
587
588
  } },
588
589
  maxEffect: "reconcilable",
589
- needs: [{ binding, kind: "skills", ops: ["bundle"] }, { binding: sandbox, kind: "sandbox-pool", ops: ["exec", "putFile"] }],
590
+ needs: [{ binding, kind: "skills", ops: ["bundle"] }, { binding: pool, kind: "sandbox-pool", ops: ["exec", "writeFile"] }],
590
591
  async run(args, ctx) {
591
592
  const { ref } = await ctx.invoke(ctx.resources[binding], "bundle", { skill: args.skill });
592
- const workspace = ctx.sandboxPool(ctx.resources[sandbox]).workspace();
593
+ const sandbox = ctx.sandboxPool(ctx.resources[pool]).sandbox(args.sandbox);
593
594
  const path2 = `/workspace/skills/${ref}`;
594
595
  const bound = args.timeoutMs === void 0 ? void 0 : { timeoutMs: args.timeoutMs };
595
- const present = await workspace.exec({ cmd: "test", args: ["-e", path2], ...bound }, bound);
596
- if (present.status !== "completed" || present.exitCode !== 0) {
596
+ const present = await sandbox.exec({ cmd: "test", args: ["-e", path2], ...bound }, bound);
597
+ if (present.state !== "exited" || present.exitCode !== 0) {
597
598
  const archive = `/workspace/.constal/imports/${ref}.tar.gz`;
598
599
  const staging = `/workspace/.constal/staging/${ref}`;
599
- await required(workspace, args.skill, "mkdir", ["-p", "--", "/workspace/.constal/imports", staging, "/workspace/skills"], args.timeoutMs);
600
- await workspace.putFile(archive, ref, bound && { invoke: bound });
601
- await required(workspace, args.skill, "tar", ["-xzf", archive, "-C", staging, "--no-same-owner", "--no-same-permissions"], args.timeoutMs);
602
- await required(workspace, args.skill, "mv", ["--", staging, path2], args.timeoutMs);
603
- await required(workspace, args.skill, "rm", ["-f", "--", archive], args.timeoutMs);
600
+ await required(sandbox, args.skill, "mkdir", ["-p", "--", "/workspace/.constal/imports", staging, "/workspace/skills"], args.timeoutMs);
601
+ await sandbox.writeFile(archive, { ref }, bound);
602
+ await required(sandbox, args.skill, "tar", ["-xzf", archive, "-C", staging, "--no-same-owner", "--no-same-permissions"], args.timeoutMs);
603
+ await required(sandbox, args.skill, "mv", ["--", staging, path2], args.timeoutMs);
604
+ await required(sandbox, args.skill, "rm", ["-f", "--", archive], args.timeoutMs);
604
605
  }
605
- const { skill: _skill, ...command } = args;
606
- return { path: path2, ...await workspace.exec({ ...command, cwd: path2 }, bound) };
606
+ const { skill: _skill, sandbox: _sandbox, ...command } = args;
607
+ return { path: path2, ...await sandbox.exec({ ...command, cwd: path2 }, bound) };
607
608
  }
608
609
  };
609
610
  return { [find.name]: find, [read.name]: read, [run.name]: run };
@@ -1420,16 +1421,6 @@ function normalizeSandboxNetworkPolicy(value, options = {}) {
1420
1421
  if (Object.keys(input).some((key) => key !== "mode" && key !== "domains")) throw new TypeError("sandbox network policy has unexpected fields");
1421
1422
  return { mode: "domain-allow", domains: normalizeDomains(input.domains) };
1422
1423
  }
1423
- if (input.mode === "managed-http") {
1424
- if (input.transport !== "bridge" && input.transport !== "proxy") throw new TypeError("sandbox managed HTTP transport is invalid");
1425
- if (typeof input.egress !== "string" || parseResourceName(input.egress).kind !== "service") throw new TypeError("sandbox managed HTTP egress must be a Service CRN");
1426
- if (input.transport === "bridge") {
1427
- if (Object.keys(input).some((key) => !["mode", "transport", "egress"].includes(key))) throw new TypeError("sandbox network policy has unexpected fields");
1428
- return { mode: "managed-http", transport: "bridge", egress: input.egress };
1429
- }
1430
- if (Object.keys(input).some((key) => !["mode", "transport", "egress", "domains"].includes(key))) throw new TypeError("sandbox network policy has unexpected fields");
1431
- return { mode: "managed-http", transport: "proxy", egress: input.egress, domains: normalizeDomains(input.domains) };
1432
- }
1433
1424
  throw new TypeError("sandbox network policy mode is invalid");
1434
1425
  }
1435
1426
 
@@ -2376,8 +2367,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2376
2367
  // packages/sdk/src/sandbox-policy-contract.ts
2377
2368
  var SANDBOX_CONTRACT_REF = {
2378
2369
  id: "constal.sandbox-pool",
2379
- version: "2",
2380
- hash: "89c34a8870f861811e6548d8388eddfc2d9b74e642fabeaf37c89f6d21df1c8e"
2370
+ version: "3",
2371
+ hash: "6d987430d15960a25d3642b13997286b2b83d84f86db1c826630310b318708f4"
2381
2372
  };
2382
2373
  var SANDBOX_CONTROLS_SCHEMA = {
2383
2374
  type: "object",
@@ -2386,15 +2377,11 @@ var SANDBOX_CONTROLS_SCHEMA = {
2386
2377
  command_timeout_ms: { type: "integer", minimum: 1 },
2387
2378
  cpu: { type: "number", exclusiveMinimum: 0 },
2388
2379
  disk_gib: { type: "number", minimum: 0 },
2389
- idle_stop_ms: { type: "integer", minimum: 1 },
2390
- max_concurrent_commands: { type: "integer", minimum: 1 },
2391
2380
  max_file_bytes: { type: "integer", minimum: 1 },
2392
2381
  memory_gib: { type: "number", exclusiveMinimum: 0 },
2393
2382
  network_cidrs: { type: "array", minItems: 1, items: { type: "string" } },
2394
2383
  network_domains: { type: "array", minItems: 1, items: { type: "string" } },
2395
- network_egress: { type: ["string", "null"] },
2396
- network_mode: { enum: ["block-all", "cidr-allow", "domain-allow", "managed-http", "unrestricted"] },
2397
- network_transport: { enum: [null, "bridge", "proxy"] },
2384
+ network_mode: { enum: ["block-all", "cidr-allow", "domain-allow", "unrestricted"] },
2398
2385
  permitted_paths: { type: "array", minItems: 1, items: { type: "string" } }
2399
2386
  }
2400
2387
  };
@@ -2446,7 +2433,7 @@ function sandboxControls(values) {
2446
2433
  return controls(SANDBOX_CONTRACT, values, sandboxSchema);
2447
2434
  }
2448
2435
  function sandboxLimit(input) {
2449
- return limit(SANDBOX_CONTRACT, ["commands", "compute_ms", "file_bytes", "requests"], input);
2436
+ return limit(SANDBOX_CONTRACT, ["commands", "requests"], input);
2450
2437
  }
2451
2438
  function modelControls(values, contract = MODEL_CONTRACT) {
2452
2439
  return controls(contract, values, modelSchema);
@@ -3492,271 +3479,37 @@ function chatParsed(value) {
3492
3479
  return source;
3493
3480
  }
3494
3481
 
3495
- // packages/sdk/src/container-image.ts
3496
- var REPOSITORY = /^[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*)*$/u;
3497
- var TAG = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/u;
3498
- var DIGEST = /^[a-z][a-z0-9+._-]*:[A-Za-z0-9=_-]+$/u;
3499
- var SHA256 = /^sha256:[a-f0-9]{64}$/u;
3500
- function containerImageReference(value) {
3501
- if (typeof value !== "string" || !value || /[\s?#\\]/u.test(value) || value.includes("://")) throw new TypeError("container image reference is invalid");
3502
- const components = value.split("@");
3503
- if (components.length > 2) throw new TypeError("container image reference is invalid");
3504
- let name = components[0];
3505
- const digest = components[1] ?? null;
3506
- if (digest !== null && (!DIGEST.test(digest) || digest.startsWith("sha256:") && !SHA256.test(digest))) {
3507
- throw new TypeError("container image digest is invalid");
3508
- }
3509
- const separator = name.lastIndexOf(":"), slash = name.lastIndexOf("/");
3510
- const tag = separator > slash ? name.slice(separator + 1) : null;
3511
- if (tag !== null) {
3512
- if (!TAG.test(tag)) throw new TypeError("container image tag is invalid");
3513
- name = name.slice(0, separator);
3514
- }
3515
- const parts = name.split("/"), explicit = parts.length > 1 && (/[.:]/u.test(parts[0]) || parts[0] === "localhost");
3516
- const registryInput = explicit ? parts.shift() : "docker.io";
3517
- let registryUrl;
3518
- try {
3519
- registryUrl = new URL(`https://${registryInput}`);
3520
- } catch {
3521
- throw new TypeError("container image registry is invalid");
3522
- }
3523
- if (registryUrl.username || registryUrl.password || registryUrl.pathname !== "/" || !registryUrl.hostname) throw new TypeError("container image registry is invalid");
3524
- const registry = registryUrl.host === "index.docker.io" ? "docker.io" : registryUrl.host;
3525
- if (registry === "docker.io" && parts.length === 1) parts.unshift("library");
3526
- const repository = parts.join("/");
3527
- if (!REPOSITORY.test(repository)) throw new TypeError("container image repository is invalid");
3528
- const selectedTag = tag ?? (digest === null ? "latest" : null);
3529
- return {
3530
- registry,
3531
- repository,
3532
- tag: selectedTag,
3533
- digest,
3534
- reference: `${registry}/${repository}${digest === null ? `:${selectedTag}` : `@${digest}`}`
3535
- };
3536
- }
3537
- function immutableContainerImageReference(value) {
3538
- const image = containerImageReference(value);
3539
- if (!image.digest || !SHA256.test(image.digest)) throw new TypeError("container image must be resolved to a SHA-256 digest");
3540
- return image;
3541
- }
3542
- function containerImageSource(value) {
3543
- const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3544
- const platform = source?.platform && typeof source.platform === "object" && !Array.isArray(source.platform) ? source.platform : null;
3545
- const image = typeof source?.reference === "string" ? immutableContainerImageReference(source.reference) : null;
3546
- if (!source || !image || source.digest !== image.digest || typeof source.mediaType !== "string" || !source.mediaType || !Number.isSafeInteger(source.bytes) || Number(source.bytes) < 1 || !platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && (typeof platform.variant !== "string" || !platform.variant)) {
3547
- throw new TypeError("container image source is invalid");
3548
- }
3549
- return structuredClone(source);
3550
- }
3551
- function containerImageSelection(value) {
3552
- const selection = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3553
- const platform = selection?.platform && typeof selection.platform === "object" && !Array.isArray(selection.platform) ? selection.platform : null;
3554
- const image = typeof selection?.reference === "string" ? immutableContainerImageReference(selection.reference) : null;
3555
- if (!selection || !image || !platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && (typeof platform.variant !== "string" || !platform.variant) || Object.keys(selection).some((key) => key !== "reference" && key !== "platform") || Object.keys(platform).some((key) => key !== "os" && key !== "architecture" && key !== "variant")) {
3556
- throw new TypeError("container image selection is invalid");
3557
- }
3558
- return { reference: image.reference, platform: structuredClone(platform) };
3559
- }
3560
- var OCI_MANIFEST = "application/vnd.oci.image.manifest.v1+json";
3561
- var OCI_INDEX = "application/vnd.oci.image.index.v1+json";
3562
- var DOCKER_MANIFEST = "application/vnd.docker.distribution.manifest.v2+json";
3563
- var DOCKER_INDEX = "application/vnd.docker.distribution.manifest.list.v2+json";
3564
- var ACCEPT = [OCI_MANIFEST, OCI_INDEX, DOCKER_MANIFEST, DOCKER_INDEX].join(", ");
3565
- var MANIFEST_BYTES = 4194304;
3566
- function object3(value) {
3567
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
3568
- }
3569
- async function manifest(image, reference, request, authorization) {
3570
- const response = await request({
3571
- url: `https://${image.registry}/v2/${image.repository}/manifests/${encodeURIComponent(reference)}`,
3572
- method: "GET",
3573
- headers: { accept: ACCEPT, ...authorization ? { authorization } : {} },
3574
- maximumBytes: MANIFEST_BYTES
3575
- });
3576
- if (response.status < 200 || response.status >= 300) throw Object.assign(new Error(`container registry manifest request returned ${response.status}`), { status: response.status });
3577
- if (response.body.byteLength === 0 || response.body.byteLength > MANIFEST_BYTES) throw new TypeError("container registry manifest size is invalid");
3578
- let value;
3579
- try {
3580
- value = object3(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body)));
3581
- } catch {
3582
- value = null;
3583
- }
3584
- if (!value || value.schemaVersion !== 2) throw new TypeError("container registry manifest is invalid");
3585
- const declared = typeof value.mediaType === "string" ? value.mediaType : response.headers["content-type"]?.split(";", 1)[0];
3586
- if (![OCI_MANIFEST, OCI_INDEX, DOCKER_MANIFEST, DOCKER_INDEX].includes(String(declared))) throw new TypeError("container registry manifest media type is unsupported");
3587
- const digest = `sha256:${await sha256Hex(response.body)}`;
3588
- const header = response.headers["docker-content-digest"];
3589
- if (header !== void 0 && header !== digest) throw new TypeError("container registry digest header differs from manifest bytes");
3590
- return { value, mediaType: declared, digest };
3591
- }
3592
- async function resolveContainerImageSource(reference, platform, request, authorization) {
3593
- const image = containerImageReference(reference);
3594
- if (!platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && !platform.variant) throw new TypeError("container image platform is invalid");
3595
- const requested = image.digest ?? image.tag;
3596
- let selected = await manifest(image, requested, request, authorization);
3597
- if (image.digest && selected.digest !== image.digest) throw new TypeError("container image digest does not match its manifest");
3598
- if (selected.mediaType === OCI_INDEX || selected.mediaType === DOCKER_INDEX) {
3599
- if (!Array.isArray(selected.value.manifests)) throw new TypeError("container image index has no manifests");
3600
- const matches = selected.value.manifests.filter((raw) => {
3601
- const item = object3(raw), target = object3(item?.platform);
3602
- return item && target && target.os === platform.os && target.architecture === platform.architecture && (platform.variant === void 0 ? target.variant === void 0 : target.variant === platform.variant);
3603
- }).map((item) => object3(item));
3604
- if (matches.length !== 1 || typeof matches[0].digest !== "string" || !SHA256.test(matches[0].digest)) {
3605
- throw new TypeError("container image index does not contain one exact requested platform");
3606
- }
3607
- selected = await manifest(image, matches[0].digest, request, authorization);
3608
- if (selected.digest !== matches[0].digest) throw new TypeError("container image platform descriptor differs from its manifest");
3609
- }
3610
- if (selected.mediaType !== OCI_MANIFEST && selected.mediaType !== DOCKER_MANIFEST) throw new TypeError("container image did not resolve to an image manifest");
3611
- const config = object3(selected.value.config), layers = selected.value.layers;
3612
- if (!config || !Number.isSafeInteger(config.size) || Number(config.size) < 0 || !Array.isArray(layers) || layers.some((layer) => !object3(layer) || !Number.isSafeInteger(object3(layer).size) || Number(object3(layer).size) < 0)) {
3613
- throw new TypeError("container image manifest descriptors are invalid");
3614
- }
3615
- const bytes = Number(config.size) + layers.reduce((sum, layer) => sum + Number(object3(layer).size), 0);
3616
- return containerImageSource({
3617
- reference: `${image.registry}/${image.repository}@${selected.digest}`,
3618
- digest: selected.digest,
3619
- mediaType: selected.mediaType,
3620
- bytes,
3621
- platform
3622
- });
3623
- }
3624
-
3625
- // packages/sdk/src/sandbox-egress.ts
3626
- function normalizeSandboxConnectionKeys(value) {
3627
- if (!Array.isArray(value)) throw new TypeError("sandbox connection keys must be an array");
3628
- return [...new Set(value.map((key) => scopedBindingKey(key)))].sort();
3629
- }
3630
- var SANDBOX_EGRESS_LIMITS = { rules: 64, labels: 16, labelValueLength: 256 };
3631
- var HEADER2 = /^[a-z0-9!#$%&'*+.^_`|~-]+$/u;
3632
- var RESERVED_HEADERS2 = /* @__PURE__ */ new Set([
3633
- "connection",
3634
- "content-length",
3635
- "host",
3636
- "keep-alive",
3637
- "proxy-connection",
3638
- "te",
3639
- "trailer",
3640
- "transfer-encoding",
3641
- "upgrade"
3642
- ]);
3643
- var LABEL = /^[a-z0-9][a-z0-9._-]{0,62}$/u;
3644
- function object4(value) {
3645
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
3646
- }
3647
- function sandboxEgressHostMatches(pattern, hostname) {
3648
- const host2 = hostname.toLowerCase().replace(/\.$/u, "");
3649
- return pattern.startsWith("*.") ? host2 === pattern.slice(2) || host2.endsWith(pattern.slice(1)) : host2 === pattern;
3650
- }
3651
- function host(value) {
3652
- const [normalized] = normalizeSandboxDomains([value]);
3653
- return normalized;
3654
- }
3655
- function presentation(present) {
3656
- const header = present.header === void 0 ? "authorization" : present.header;
3657
- if (typeof header !== "string" || !HEADER2.test(header.toLowerCase()) || RESERVED_HEADERS2.has(header.toLowerCase()) || header.toLowerCase().startsWith("x-constal-")) throw new TypeError("Credential destination header is invalid");
3658
- if (present.value !== void 0 && present.basic !== void 0) throw new TypeError("Credential destination takes value or basic, not both");
3659
- if (present.value !== void 0 && (typeof present.value !== "string" || /[\r\n\0]/u.test(present.value) || present.value.split("{value}").length !== 2)) throw new TypeError("Credential destination value must contain {value} exactly once");
3660
- const basic = present.basic === void 0 ? void 0 : object4(present.basic);
3661
- if (present.basic !== void 0 && (!basic || Object.keys(basic).some((key) => key !== "username") || basic.username !== void 0 && (typeof basic.username !== "string" || !basic.username || /[:\r\n\0]/u.test(basic.username)))) throw new TypeError("Credential destination basic auth is invalid");
3662
- if (present.field !== void 0 && (typeof present.field !== "string" || !present.field.startsWith("/") || SPACE_OR_CONTROL.test(present.field) || /~(?![01])/u.test(present.field))) throw new TypeError("Credential destination field must be a JSON Pointer");
3663
- if (present.code !== void 0 && present.code !== "totp") throw new TypeError("Credential destination code must be totp");
3664
- return {
3665
- header: header.toLowerCase(),
3666
- ...basic ? { basic: basic.username === void 0 ? {} : { username: basic.username } } : { value: present.value ?? "Bearer {value}" },
3667
- ...present.field !== void 0 ? { field: present.field } : {},
3668
- ...present.code !== void 0 ? { code: "totp" } : {}
3669
- };
3670
- }
3671
- var SPACE_OR_CONTROL = /[\s\u0000-\u001f\u007f]/u;
3672
- function path(raw) {
3673
- if (typeof raw !== "string" || !raw.startsWith("/") || /[%?#\\]/u.test(raw) || SPACE_OR_CONTROL.test(raw)) {
3674
- throw new TypeError("Credential destination path is invalid");
3675
- }
3676
- const prefix = raw.length > 1 && raw.endsWith("/") ? raw.slice(0, -1) : raw;
3677
- if (prefix.slice(1).split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
3678
- throw new TypeError("Credential destination path is invalid");
3679
- }
3680
- return prefix;
3681
- }
3682
- function normalizeCredentialDestinations(value) {
3683
- if (value === void 0) return [];
3684
- if (!Array.isArray(value)) throw new TypeError("Credential destinations are invalid");
3685
- const destinations = value.map((raw) => {
3686
- const destination = object4(raw);
3687
- const present = object4(destination?.present);
3688
- if (!destination || Object.keys(destination).some((key) => !["origin", "path", "present"].includes(key)) || typeof destination.origin !== "string" || !destination.origin.startsWith("https://") || !present || Object.keys(present).some((key) => !["header", "value", "basic", "field", "code"].includes(key))) {
3689
- throw new TypeError("Credential destination is invalid");
3690
- }
3691
- return {
3692
- origin: `https://${host(destination.origin.slice("https://".length))}`,
3693
- ...destination.path !== void 0 ? { path: path(destination.path) } : {},
3694
- present: presentation(present)
3695
- };
3696
- });
3697
- const headers = destinations.map((destination) => JSON.stringify([destination.origin, destination.path ?? null, destination.present.header]));
3698
- if (new Set(headers).size !== headers.length) throw new TypeError("Credential destinations of one origin and path name a header twice");
3699
- return destinations;
3700
- }
3701
- function normalizeSandboxEgressPolicy(value) {
3702
- const input = object4(value);
3703
- if (!input || Object.keys(input).some((key) => key !== "rules" && key !== "default") || !Array.isArray(input.rules) || input.rules.length > SANDBOX_EGRESS_LIMITS.rules || input.default !== void 0 && input.default !== "allow" && input.default !== "deny") {
3704
- throw new TypeError("sandbox egress policy is invalid");
3705
- }
3706
- const rules = input.rules.map((raw) => {
3707
- const rule = object4(raw);
3708
- if (!rule || Object.keys(rule).some((key) => key !== "action" && key !== "host") || rule.action !== "allow" && rule.action !== "deny") {
3709
- throw new TypeError("sandbox egress rule is invalid");
3710
- }
3711
- return { action: rule.action, host: host(rule.host) };
3712
- });
3713
- return { rules, default: input.default === "allow" ? "allow" : "deny" };
3714
- }
3715
- function sandboxEgressDecision(policy2, hostname) {
3716
- if (!policy2) return { allowed: true, rule: "pool" };
3717
- const index = policy2.rules.findIndex((rule) => sandboxEgressHostMatches(rule.host, hostname));
3718
- if (index < 0) return { allowed: policy2.default === "allow", rule: "sandbox:default" };
3719
- return { allowed: policy2.rules[index].action === "allow", rule: `sandbox:${index}` };
3720
- }
3721
- function normalizeSandboxLabels(value) {
3722
- if (value === void 0) return {};
3723
- const input = object4(value);
3724
- if (!input || Object.keys(input).length > SANDBOX_EGRESS_LIMITS.labels) throw new TypeError("sandbox labels are invalid");
3725
- const labels = {};
3726
- for (const [key, label] of Object.entries(input).sort(([left], [right]) => left.localeCompare(right))) {
3727
- if (!LABEL.test(key) || typeof label !== "string" || label.length > SANDBOX_EGRESS_LIMITS.labelValueLength || /[\u0000-\u001f\u007f]/u.test(label)) throw new TypeError("sandbox label is invalid");
3728
- labels[key] = label;
3729
- }
3730
- return labels;
3731
- }
3732
-
3733
3482
  // packages/sdk/src/sandbox-pool.ts
3734
- var WORKSPACE_ROOT = "/workspace";
3735
- function absoluteSandboxPath(value) {
3736
- const segments = [];
3737
- for (const segment of value.split("/")) {
3738
- if (!segment || segment === ".") continue;
3739
- if (segment === "..") segments.pop();
3740
- else segments.push(segment);
3741
- }
3742
- return `/${segments.join("/")}`;
3743
- }
3744
- function normalizeSandboxWorkspacePath(path2, cwd = WORKSPACE_ROOT) {
3745
- if (typeof path2 !== "string" || !path2 || typeof cwd !== "string" || !cwd || /[\u0000-\u001f\u007f]/u.test(path2) || /[\u0000-\u001f\u007f]/u.test(cwd)) {
3746
- throw new TypeError("sandbox workspace path is invalid");
3747
- }
3748
- const base = absoluteSandboxPath(cwd.startsWith("/") ? cwd : `${WORKSPACE_ROOT}/${cwd}`);
3749
- if (base !== WORKSPACE_ROOT && !base.startsWith(`${WORKSPACE_ROOT}/`)) {
3750
- throw new TypeError("sandbox working directory is outside /workspace");
3751
- }
3752
- const normalized = absoluteSandboxPath(path2.startsWith("/") ? path2 : `${base}/${path2}`);
3753
- if (normalized !== WORKSPACE_ROOT && !normalized.startsWith(`${WORKSPACE_ROOT}/`)) {
3754
- throw new TypeError("sandbox path is outside /workspace");
3755
- }
3756
- return normalized;
3483
+ var SANDBOX_POOL_OPERATIONS = [
3484
+ "create",
3485
+ "get",
3486
+ "start",
3487
+ "stop",
3488
+ "delete",
3489
+ "update",
3490
+ "exec",
3491
+ "execution",
3492
+ "cancel",
3493
+ "readFile",
3494
+ "writeFile",
3495
+ "deleteFile",
3496
+ "snapshot",
3497
+ "deleteSnapshot"
3498
+ ];
3499
+ var SANDBOX_PROVIDER_UNAVAILABLE = "ProviderUnavailable";
3500
+ var SANDBOX_PROVIDER_FAILURE_CLASSES = ["capacity", "rate_limited", "quota", "region", "outage"];
3501
+ function isFailureClass(value) {
3502
+ return typeof value === "string" && SANDBOX_PROVIDER_FAILURE_CLASSES.includes(value);
3503
+ }
3504
+ function sandboxProviderUnavailable(value) {
3505
+ const source = value && typeof value === "object" ? value : null;
3506
+ if (!source || source.code !== SANDBOX_PROVIDER_UNAVAILABLE && source.name !== SANDBOX_PROVIDER_UNAVAILABLE) return null;
3507
+ const cause = source.cause && typeof source.cause === "object" ? source.cause : null;
3508
+ const reason = isFailureClass(source.reason) ? source.reason : isFailureClass(cause?.code) ? cause.code : "outage";
3509
+ const retryAfterMs = typeof source.retryAfterMs === "number" && Number.isSafeInteger(source.retryAfterMs) && source.retryAfterMs >= 0 ? source.retryAfterMs : 0;
3510
+ const message2 = typeof source.message === "string" ? source.message : `sandbox provider is unavailable (${reason})`;
3511
+ return { code: SANDBOX_PROVIDER_UNAVAILABLE, reason, retryAfterMs, message: message2 };
3757
3512
  }
3758
- var SANDBOX_PROCESS_IO_OPERATIONS = ["process.status", "process.read", "process.write", "process.close"];
3759
- var SANDBOX_PROCESS_OPERATIONS = ["process.resolve", ...SANDBOX_PROCESS_IO_OPERATIONS, "process.stop"];
3760
3513
 
3761
3514
  // packages/sdk/src/training.ts
3762
3515
  var HASH4 = /^[a-f0-9]{64}$/u;
@@ -4320,6 +4073,114 @@ var MCP_CLIENT_CAPABILITY = {
4320
4073
  hash: "a694af71191432e75980dc73962d9239dc8ea324aff084f183a2f45603bd2267"
4321
4074
  };
4322
4075
 
4076
+ // packages/sdk/src/sandbox-egress.ts
4077
+ function normalizeSandboxConnectionKeys(value) {
4078
+ if (!Array.isArray(value)) throw new TypeError("sandbox connection keys must be an array");
4079
+ return [...new Set(value.map((key) => scopedBindingKey(key)))].sort();
4080
+ }
4081
+ var SANDBOX_EGRESS_LIMITS = { rules: 64, labels: 16, labelValueLength: 256 };
4082
+ var HEADER2 = /^[a-z0-9!#$%&'*+.^_`|~-]+$/u;
4083
+ var RESERVED_HEADERS2 = /* @__PURE__ */ new Set([
4084
+ "connection",
4085
+ "content-length",
4086
+ "host",
4087
+ "keep-alive",
4088
+ "proxy-connection",
4089
+ "te",
4090
+ "trailer",
4091
+ "transfer-encoding",
4092
+ "upgrade"
4093
+ ]);
4094
+ var LABEL = /^[a-z0-9][a-z0-9._-]{0,62}$/u;
4095
+ function object3(value) {
4096
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4097
+ }
4098
+ function sandboxEgressHostMatches(pattern, hostname) {
4099
+ const host2 = hostname.toLowerCase().replace(/\.$/u, "");
4100
+ return pattern.startsWith("*.") ? host2 === pattern.slice(2) || host2.endsWith(pattern.slice(1)) : host2 === pattern;
4101
+ }
4102
+ function host(value) {
4103
+ const [normalized] = normalizeSandboxDomains([value]);
4104
+ return normalized;
4105
+ }
4106
+ function presentation(present) {
4107
+ const header = present.header === void 0 ? "authorization" : present.header;
4108
+ if (typeof header !== "string" || !HEADER2.test(header.toLowerCase()) || RESERVED_HEADERS2.has(header.toLowerCase()) || header.toLowerCase().startsWith("x-constal-")) throw new TypeError("Credential destination header is invalid");
4109
+ if (present.value !== void 0 && present.basic !== void 0) throw new TypeError("Credential destination takes value or basic, not both");
4110
+ if (present.value !== void 0 && (typeof present.value !== "string" || /[\r\n\0]/u.test(present.value) || present.value.split("{value}").length !== 2)) throw new TypeError("Credential destination value must contain {value} exactly once");
4111
+ const basic = present.basic === void 0 ? void 0 : object3(present.basic);
4112
+ if (present.basic !== void 0 && (!basic || Object.keys(basic).some((key) => key !== "username") || basic.username !== void 0 && (typeof basic.username !== "string" || !basic.username || /[:\r\n\0]/u.test(basic.username)))) throw new TypeError("Credential destination basic auth is invalid");
4113
+ if (present.field !== void 0 && (typeof present.field !== "string" || !present.field.startsWith("/") || SPACE_OR_CONTROL.test(present.field) || /~(?![01])/u.test(present.field))) throw new TypeError("Credential destination field must be a JSON Pointer");
4114
+ if (present.code !== void 0 && present.code !== "totp") throw new TypeError("Credential destination code must be totp");
4115
+ return {
4116
+ header: header.toLowerCase(),
4117
+ ...basic ? { basic: basic.username === void 0 ? {} : { username: basic.username } } : { value: present.value ?? "Bearer {value}" },
4118
+ ...present.field !== void 0 ? { field: present.field } : {},
4119
+ ...present.code !== void 0 ? { code: "totp" } : {}
4120
+ };
4121
+ }
4122
+ var SPACE_OR_CONTROL = /[\s\u0000-\u001f\u007f]/u;
4123
+ function path(raw) {
4124
+ if (typeof raw !== "string" || !raw.startsWith("/") || /[%?#\\]/u.test(raw) || SPACE_OR_CONTROL.test(raw)) {
4125
+ throw new TypeError("Credential destination path is invalid");
4126
+ }
4127
+ const prefix = raw.length > 1 && raw.endsWith("/") ? raw.slice(0, -1) : raw;
4128
+ if (prefix.slice(1).split("/").some((segment) => segment === "" || segment === "." || segment === "..")) {
4129
+ throw new TypeError("Credential destination path is invalid");
4130
+ }
4131
+ return prefix;
4132
+ }
4133
+ function normalizeCredentialDestinations(value) {
4134
+ if (value === void 0) return [];
4135
+ if (!Array.isArray(value)) throw new TypeError("Credential destinations are invalid");
4136
+ const destinations = value.map((raw) => {
4137
+ const destination = object3(raw);
4138
+ const present = object3(destination?.present);
4139
+ if (!destination || Object.keys(destination).some((key) => !["origin", "path", "present"].includes(key)) || typeof destination.origin !== "string" || !destination.origin.startsWith("https://") || !present || Object.keys(present).some((key) => !["header", "value", "basic", "field", "code"].includes(key))) {
4140
+ throw new TypeError("Credential destination is invalid");
4141
+ }
4142
+ return {
4143
+ origin: `https://${host(destination.origin.slice("https://".length))}`,
4144
+ ...destination.path !== void 0 ? { path: path(destination.path) } : {},
4145
+ present: presentation(present)
4146
+ };
4147
+ });
4148
+ const headers = destinations.map((destination) => JSON.stringify([destination.origin, destination.path ?? null, destination.present.header]));
4149
+ if (new Set(headers).size !== headers.length) throw new TypeError("Credential destinations of one origin and path name a header twice");
4150
+ return destinations;
4151
+ }
4152
+ function normalizeSandboxEgressPolicy(value) {
4153
+ const input = object3(value);
4154
+ if (!input || Object.keys(input).some((key) => key !== "rules" && key !== "default") || !Array.isArray(input.rules) || input.rules.length > SANDBOX_EGRESS_LIMITS.rules || input.default !== void 0 && input.default !== "allow" && input.default !== "deny") {
4155
+ throw new TypeError("sandbox egress policy is invalid");
4156
+ }
4157
+ const rules = input.rules.map((raw) => {
4158
+ const rule = object3(raw);
4159
+ if (!rule || Object.keys(rule).some((key) => key !== "action" && key !== "host") || rule.action !== "allow" && rule.action !== "deny") {
4160
+ throw new TypeError("sandbox egress rule is invalid");
4161
+ }
4162
+ return { action: rule.action, host: host(rule.host) };
4163
+ });
4164
+ return { rules, default: input.default === "allow" ? "allow" : "deny" };
4165
+ }
4166
+ function sandboxEgressDecision(policy2, hostname) {
4167
+ if (!policy2) return { allowed: true, rule: "pool" };
4168
+ const index = policy2.rules.findIndex((rule) => sandboxEgressHostMatches(rule.host, hostname));
4169
+ if (index < 0) return { allowed: policy2.default === "allow", rule: "sandbox:default" };
4170
+ return { allowed: policy2.rules[index].action === "allow", rule: `sandbox:${index}` };
4171
+ }
4172
+ function normalizeSandboxLabels(value) {
4173
+ if (value === void 0) return {};
4174
+ const input = object3(value);
4175
+ if (!input || Object.keys(input).length > SANDBOX_EGRESS_LIMITS.labels) throw new TypeError("sandbox labels are invalid");
4176
+ const labels = {};
4177
+ for (const [key, label] of Object.entries(input).sort(([left], [right]) => left.localeCompare(right))) {
4178
+ if (!LABEL.test(key) || typeof label !== "string" || label.length > SANDBOX_EGRESS_LIMITS.labelValueLength || /[\u0000-\u001f\u007f]/u.test(label)) throw new TypeError("sandbox label is invalid");
4179
+ labels[key] = label;
4180
+ }
4181
+ return labels;
4182
+ }
4183
+
4323
4184
  // packages/sdk/src/credential-provider.ts
4324
4185
  function assertNonSecretConfigSchema(value, field2 = "config") {
4325
4186
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
@@ -4743,6 +4604,152 @@ function scoreLevel(answer2) {
4743
4604
  return Math.min(Object.keys(answer2.legend).length - 1, Math.max(0, Math.round(answer2.score)));
4744
4605
  }
4745
4606
 
4607
+ // packages/sdk/src/sandbox-door.ts
4608
+ var SANDBOX_DOOR_MAX_WAIT_MS = 25e3;
4609
+ var SANDBOX_DOOR_ERRORS = {
4610
+ Invalid: 400,
4611
+ AccountBalanceExceeded: 402,
4612
+ Forbidden: 403,
4613
+ NotFound: 404,
4614
+ AlreadyExists: 409,
4615
+ Conflict: 409,
4616
+ NotRunning: 409,
4617
+ Unsupported: 422,
4618
+ ProviderError: 502,
4619
+ [SANDBOX_PROVIDER_UNAVAILABLE]: 503,
4620
+ BillingAdmissionUnavailable: 503
4621
+ };
4622
+
4623
+ // packages/sdk/src/container-image.ts
4624
+ var REPOSITORY = /^[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:\.|_|__|-+)[a-z0-9]+)*)*$/u;
4625
+ var TAG = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/u;
4626
+ var DIGEST = /^[a-z][a-z0-9+._-]*:[A-Za-z0-9=_-]+$/u;
4627
+ var SHA256 = /^sha256:[a-f0-9]{64}$/u;
4628
+ function containerImageReference(value) {
4629
+ if (typeof value !== "string" || !value || /[\s?#\\]/u.test(value) || value.includes("://")) throw new TypeError("container image reference is invalid");
4630
+ const components = value.split("@");
4631
+ if (components.length > 2) throw new TypeError("container image reference is invalid");
4632
+ let name = components[0];
4633
+ const digest = components[1] ?? null;
4634
+ if (digest !== null && (!DIGEST.test(digest) || digest.startsWith("sha256:") && !SHA256.test(digest))) {
4635
+ throw new TypeError("container image digest is invalid");
4636
+ }
4637
+ const separator = name.lastIndexOf(":"), slash = name.lastIndexOf("/");
4638
+ const tag = separator > slash ? name.slice(separator + 1) : null;
4639
+ if (tag !== null) {
4640
+ if (!TAG.test(tag)) throw new TypeError("container image tag is invalid");
4641
+ name = name.slice(0, separator);
4642
+ }
4643
+ const parts = name.split("/"), explicit = parts.length > 1 && (/[.:]/u.test(parts[0]) || parts[0] === "localhost");
4644
+ const registryInput = explicit ? parts.shift() : "docker.io";
4645
+ let registryUrl;
4646
+ try {
4647
+ registryUrl = new URL(`https://${registryInput}`);
4648
+ } catch {
4649
+ throw new TypeError("container image registry is invalid");
4650
+ }
4651
+ if (registryUrl.username || registryUrl.password || registryUrl.pathname !== "/" || !registryUrl.hostname) throw new TypeError("container image registry is invalid");
4652
+ const registry = registryUrl.host === "index.docker.io" ? "docker.io" : registryUrl.host;
4653
+ if (registry === "docker.io" && parts.length === 1) parts.unshift("library");
4654
+ const repository = parts.join("/");
4655
+ if (!REPOSITORY.test(repository)) throw new TypeError("container image repository is invalid");
4656
+ const selectedTag = tag ?? (digest === null ? "latest" : null);
4657
+ return {
4658
+ registry,
4659
+ repository,
4660
+ tag: selectedTag,
4661
+ digest,
4662
+ reference: `${registry}/${repository}${digest === null ? `:${selectedTag}` : `@${digest}`}`
4663
+ };
4664
+ }
4665
+ function immutableContainerImageReference(value) {
4666
+ const image = containerImageReference(value);
4667
+ if (!image.digest || !SHA256.test(image.digest)) throw new TypeError("container image must be resolved to a SHA-256 digest");
4668
+ return image;
4669
+ }
4670
+ function containerImageSource(value) {
4671
+ const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
4672
+ const platform = source?.platform && typeof source.platform === "object" && !Array.isArray(source.platform) ? source.platform : null;
4673
+ const image = typeof source?.reference === "string" ? immutableContainerImageReference(source.reference) : null;
4674
+ if (!source || !image || source.digest !== image.digest || typeof source.mediaType !== "string" || !source.mediaType || !Number.isSafeInteger(source.bytes) || Number(source.bytes) < 1 || !platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && (typeof platform.variant !== "string" || !platform.variant)) {
4675
+ throw new TypeError("container image source is invalid");
4676
+ }
4677
+ return structuredClone(source);
4678
+ }
4679
+ function containerImageSelection(value) {
4680
+ const selection = value && typeof value === "object" && !Array.isArray(value) ? value : null;
4681
+ const platform = selection?.platform && typeof selection.platform === "object" && !Array.isArray(selection.platform) ? selection.platform : null;
4682
+ const image = typeof selection?.reference === "string" ? immutableContainerImageReference(selection.reference) : null;
4683
+ if (!selection || !image || !platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && (typeof platform.variant !== "string" || !platform.variant) || Object.keys(selection).some((key) => key !== "reference" && key !== "platform") || Object.keys(platform).some((key) => key !== "os" && key !== "architecture" && key !== "variant")) {
4684
+ throw new TypeError("container image selection is invalid");
4685
+ }
4686
+ return { reference: image.reference, platform: structuredClone(platform) };
4687
+ }
4688
+ var OCI_MANIFEST = "application/vnd.oci.image.manifest.v1+json";
4689
+ var OCI_INDEX = "application/vnd.oci.image.index.v1+json";
4690
+ var DOCKER_MANIFEST = "application/vnd.docker.distribution.manifest.v2+json";
4691
+ var DOCKER_INDEX = "application/vnd.docker.distribution.manifest.list.v2+json";
4692
+ var ACCEPT = [OCI_MANIFEST, OCI_INDEX, DOCKER_MANIFEST, DOCKER_INDEX].join(", ");
4693
+ var MANIFEST_BYTES = 4194304;
4694
+ function object4(value) {
4695
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4696
+ }
4697
+ async function manifest(image, reference, request, authorization) {
4698
+ const response = await request({
4699
+ url: `https://${image.registry}/v2/${image.repository}/manifests/${encodeURIComponent(reference)}`,
4700
+ method: "GET",
4701
+ headers: { accept: ACCEPT, ...authorization ? { authorization } : {} },
4702
+ maximumBytes: MANIFEST_BYTES
4703
+ });
4704
+ if (response.status < 200 || response.status >= 300) throw Object.assign(new Error(`container registry manifest request returned ${response.status}`), { status: response.status });
4705
+ if (response.body.byteLength === 0 || response.body.byteLength > MANIFEST_BYTES) throw new TypeError("container registry manifest size is invalid");
4706
+ let value;
4707
+ try {
4708
+ value = object4(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body)));
4709
+ } catch {
4710
+ value = null;
4711
+ }
4712
+ if (!value || value.schemaVersion !== 2) throw new TypeError("container registry manifest is invalid");
4713
+ const declared = typeof value.mediaType === "string" ? value.mediaType : response.headers["content-type"]?.split(";", 1)[0];
4714
+ if (![OCI_MANIFEST, OCI_INDEX, DOCKER_MANIFEST, DOCKER_INDEX].includes(String(declared))) throw new TypeError("container registry manifest media type is unsupported");
4715
+ const digest = `sha256:${await sha256Hex(response.body)}`;
4716
+ const header = response.headers["docker-content-digest"];
4717
+ if (header !== void 0 && header !== digest) throw new TypeError("container registry digest header differs from manifest bytes");
4718
+ return { value, mediaType: declared, digest };
4719
+ }
4720
+ async function resolveContainerImageSource(reference, platform, request, authorization) {
4721
+ const image = containerImageReference(reference);
4722
+ if (!platform || typeof platform.os !== "string" || !platform.os || typeof platform.architecture !== "string" || !platform.architecture || platform.variant !== void 0 && !platform.variant) throw new TypeError("container image platform is invalid");
4723
+ const requested = image.digest ?? image.tag;
4724
+ let selected = await manifest(image, requested, request, authorization);
4725
+ if (image.digest && selected.digest !== image.digest) throw new TypeError("container image digest does not match its manifest");
4726
+ if (selected.mediaType === OCI_INDEX || selected.mediaType === DOCKER_INDEX) {
4727
+ if (!Array.isArray(selected.value.manifests)) throw new TypeError("container image index has no manifests");
4728
+ const matches = selected.value.manifests.filter((raw) => {
4729
+ const item = object4(raw), target = object4(item?.platform);
4730
+ return item && target && target.os === platform.os && target.architecture === platform.architecture && (platform.variant === void 0 ? target.variant === void 0 : target.variant === platform.variant);
4731
+ }).map((item) => object4(item));
4732
+ if (matches.length !== 1 || typeof matches[0].digest !== "string" || !SHA256.test(matches[0].digest)) {
4733
+ throw new TypeError("container image index does not contain one exact requested platform");
4734
+ }
4735
+ selected = await manifest(image, matches[0].digest, request, authorization);
4736
+ if (selected.digest !== matches[0].digest) throw new TypeError("container image platform descriptor differs from its manifest");
4737
+ }
4738
+ if (selected.mediaType !== OCI_MANIFEST && selected.mediaType !== DOCKER_MANIFEST) throw new TypeError("container image did not resolve to an image manifest");
4739
+ const config = object4(selected.value.config), layers = selected.value.layers;
4740
+ if (!config || !Number.isSafeInteger(config.size) || Number(config.size) < 0 || !Array.isArray(layers) || layers.some((layer) => !object4(layer) || !Number.isSafeInteger(object4(layer).size) || Number(object4(layer).size) < 0)) {
4741
+ throw new TypeError("container image manifest descriptors are invalid");
4742
+ }
4743
+ const bytes = Number(config.size) + layers.reduce((sum, layer) => sum + Number(object4(layer).size), 0);
4744
+ return containerImageSource({
4745
+ reference: `${image.registry}/${image.repository}@${selected.digest}`,
4746
+ digest: selected.digest,
4747
+ mediaType: selected.mediaType,
4748
+ bytes,
4749
+ platform
4750
+ });
4751
+ }
4752
+
4746
4753
  // packages/sdk/src/mcp.ts
4747
4754
  var MCP_PROTOCOL_VERSION = "2025-06-18";
4748
4755
  function record11(value) {
@@ -5354,7 +5361,11 @@ export {
5354
5361
  ResourceInvalid,
5355
5362
  ResourceUnbound,
5356
5363
  RollbackTargetInvalid,
5364
+ SANDBOX_DOOR_MAX_WAIT_MS,
5357
5365
  SANDBOX_EGRESS_LIMITS,
5366
+ SANDBOX_POOL_OPERATIONS,
5367
+ SANDBOX_PROVIDER_FAILURE_CLASSES,
5368
+ SANDBOX_PROVIDER_UNAVAILABLE,
5358
5369
  SessionDeleted,
5359
5370
  SpawnCardinality,
5360
5371
  SwallowedYield,
@@ -5463,7 +5474,6 @@ export {
5463
5474
  normalizeSandboxEgressPolicy,
5464
5475
  normalizeSandboxLabels,
5465
5476
  normalizeSandboxNetworkPolicy,
5466
- normalizeSandboxWorkspacePath,
5467
5477
  noulDecision,
5468
5478
  opTool,
5469
5479
  opTools,
@@ -5490,6 +5500,7 @@ export {
5490
5500
  sandboxEgressDecision,
5491
5501
  sandboxEgressHostMatches,
5492
5502
  sandboxLimit,
5503
+ sandboxProviderUnavailable,
5493
5504
  scopedBindingKey,
5494
5505
  scopedCredentialRef,
5495
5506
  scopedResourceRef,