@withgateway/sdk 0.2.5 → 0.2.6

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 (75) hide show
  1. package/dist/cli.js +3121 -1283
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +3185 -1347
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +9 -0
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +9 -0
  8. package/dist/files/index.mjs.map +1 -1
  9. package/dist/hooks/index.d.mts +1 -1
  10. package/dist/hooks/index.d.ts +1 -1
  11. package/dist/hooks/index.js +280 -8
  12. package/dist/hooks/index.js.map +1 -1
  13. package/dist/hooks/index.mjs +272 -8
  14. package/dist/hooks/index.mjs.map +1 -1
  15. package/dist/{index-1xnxt0Cc.d.ts → index-BO2SNSgy.d.ts} +12 -1
  16. package/dist/{index-B0R3IgsV.d.mts → index-BaKu5ZSU.d.mts} +124 -2
  17. package/dist/{index-B0R3IgsV.d.ts → index-BaKu5ZSU.d.ts} +124 -2
  18. package/dist/{index-C1wDEwH4.d.mts → index-Cz8Q6Keo.d.mts} +12 -1
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +726 -167
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +718 -167
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/traces/index.js +9 -0
  26. package/dist/traces/index.js.map +1 -1
  27. package/dist/traces/index.mjs +9 -0
  28. package/dist/traces/index.mjs.map +1 -1
  29. package/dist/tracing/index.d.mts +1 -1
  30. package/dist/tracing/index.d.ts +1 -1
  31. package/dist/tracing/index.js +97 -61
  32. package/dist/tracing/index.js.map +1 -1
  33. package/dist/tracing/index.mjs +97 -61
  34. package/dist/tracing/index.mjs.map +1 -1
  35. package/dist/worlds/index.d.mts +154 -4
  36. package/dist/worlds/index.d.ts +154 -4
  37. package/dist/worlds/index.js +348 -97
  38. package/dist/worlds/index.js.map +1 -1
  39. package/dist/worlds/index.mjs +348 -97
  40. package/dist/worlds/index.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/runtime/gatewaysdk/environment/_bundle.py +1 -1
  43. package/runtime/gatewaysdk/environment/_materialize.py +53 -9
  44. package/runtime/gatewaysdk/environment/_toml.py +13 -0
  45. package/runtime/gatewaysdk/environment/schema/api.py +3 -7
  46. package/runtime/gatewaysdk/environment/schema/batch.py +15 -11
  47. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +24 -0
  48. package/runtime/gatewaysdk/environment/schema/compiler.py +60 -28
  49. package/runtime/gatewaysdk/environment/schema/conform.py +1 -1
  50. package/runtime/gatewaysdk/environment/schema/connector.py +1 -1
  51. package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.ingest.toml +25 -0
  52. package/runtime/gatewaysdk/environment/schema/connectors/google-drive/readers/merge.toml +17 -0
  53. package/runtime/gatewaysdk/environment/schema/extract.py +1 -5
  54. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +1 -5
  55. package/runtime/gatewaysdk/environment/schema/mapping.py +1 -1
  56. package/runtime/gatewaysdk/environment/schema/platform.py +16 -4
  57. package/runtime/gatewaysdk/environment/schema/redaction.py +1 -1
  58. package/runtime/gatewaysdk/environment/schema/scaffold.py +9 -2
  59. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +67 -9
  60. package/runtime/gatewaysdk/environment/schema/skills/hooks-getting-started/SKILL.md +61 -2
  61. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +4 -1
  62. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +11 -11
  63. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
  64. package/runtime/gatewaysdk/environment/schema/snapshot.py +1 -5
  65. package/runtime/gatewaysdk/environment/schema/tools_world.py +1 -5
  66. package/runtime/gatewaysdk/environment/schema/ui.py +1 -5
  67. package/runtime/gatewaysdk/environment/schema/world_tests.py +1 -1
  68. package/runtime/gatewaysdk/environment/world.py +120 -4
  69. package/skills/benchmarks-getting-started/SKILL.md +67 -9
  70. package/skills/connector-schema-authoring/connector-worlds.md +8 -1
  71. package/skills/connector-schema-authoring/world-schema.md +1 -1
  72. package/skills/hooks-getting-started/SKILL.md +61 -2
  73. package/skills/world-data-ingestion/SKILL.md +4 -1
  74. package/skills/worlds-getting-started/SKILL.md +11 -11
  75. package/skills/worlds-getting-started/references/cli-mcp-map.md +17 -1
@@ -607,8 +607,8 @@ async function runSessions(opts) {
607
607
  let tasks = opts.tasks;
608
608
  let versionId = opts.versionId;
609
609
  if (!tasks || !versionId) {
610
- const { openWorld: openWorld2 } = await Promise.resolve().then(() => (init_worlds(), worlds_exports));
611
- const world = await openWorld2(opts.world, options);
610
+ const { openWorld: openWorld2, openWorldVersion: openWorldVersion2 } = await Promise.resolve().then(() => (init_worlds(), worlds_exports));
611
+ const world = versionId ? await openWorldVersion2(opts.world.split("@", 1)[0], versionId, options) : await openWorld2(opts.world, options);
612
612
  tasks = tasks ?? world.tasks.map((t) => t.name);
613
613
  versionId = versionId ?? world.version.versionId;
614
614
  }
@@ -664,10 +664,12 @@ async function runSessions(opts) {
664
664
  })
665
665
  );
666
666
  const mean = results.reduce((sum, r) => sum + (r.reward ?? 0), 0) / (results.length || 1);
667
+ const failed = results.filter((r) => r.error).length;
667
668
  return {
668
669
  results: results.sort((a, b) => a.task.localeCompare(b.task)),
669
670
  mean,
670
- passed: opts.failUnder === void 0 ? true : mean >= opts.failUnder
671
+ failed,
672
+ passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
671
673
  };
672
674
  }
673
675
  var isTaskIdRef, isTaskSpec, taskLabel, READY_TIMEOUT_MS, READY_POLL_MS, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep, modelToolName, WorldSessionTimeout, WorldSessionCallError, WorldSession;
@@ -1948,7 +1950,7 @@ var require_package = __commonJS({
1948
1950
  "package.json"(exports, module) {
1949
1951
  module.exports = {
1950
1952
  name: "@withgateway/sdk",
1951
- version: "0.2.5",
1953
+ version: "0.2.6",
1952
1954
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
1953
1955
  main: "./dist/index.js",
1954
1956
  module: "./dist/index.mjs",
@@ -2684,7 +2686,7 @@ async function fileTaskRun(live, runId, model, report, grade, agentError, traced
2684
2686
  task: live.name ?? live.taskId ?? runId,
2685
2687
  rolloutIndex: 0,
2686
2688
  prompt: live.instruction,
2687
- completion: report,
2689
+ ...report === null ? {} : { completion: report },
2688
2690
  rewards: grade.rewards,
2689
2691
  info: {
2690
2692
  sessionId: runId,
@@ -2722,17 +2724,20 @@ async function fileTaskRun(live, runId, model, report, grade, agentError, traced
2722
2724
  return evaluationId;
2723
2725
  }
2724
2726
  function reportFromResult(result) {
2727
+ if (result === void 0 || result === null)
2728
+ return { report: null, extra: {} };
2725
2729
  if (typeof result === "string") return { report: result, extra: {} };
2726
- if (result && typeof result === "object") {
2727
- const { report, ...extra } = result;
2728
- return {
2729
- report: report === void 0 || report === null ? null : typeof report === "string" ? report : String(report),
2730
- extra
2731
- };
2732
- }
2733
- if (result !== void 0 && result !== null)
2734
- return { report: String(result), extra: {} };
2735
- return { report: null, extra: {} };
2730
+ if (typeof result !== "object" || Array.isArray(result))
2731
+ throw new Error(
2732
+ `agent returned ${describeValue(result)}; ${RESULT_CONTRACT}`
2733
+ );
2734
+ const { report, ...extra } = result;
2735
+ if (report === void 0 || report === null) return { report: null, extra };
2736
+ if (typeof report !== "string")
2737
+ throw new Error(
2738
+ `agent returned a report of type ${describeValue(report)}; ${RESULT_CONTRACT}`
2739
+ );
2740
+ return { report, extra };
2736
2741
  }
2737
2742
  async function runTask(ref, agent, opts) {
2738
2743
  const runId = `wtr-${randomBytes(6).toString("hex")}`;
@@ -2836,7 +2841,7 @@ async function runTask(ref, agent, opts) {
2836
2841
  }
2837
2842
  }
2838
2843
  }
2839
- var TaskRun;
2844
+ var TaskRun, describeValue, RESULT_CONTRACT;
2840
2845
  var init_taskRun = __esm({
2841
2846
  "src/worlds/taskRun.ts"() {
2842
2847
  "use strict";
@@ -2907,6 +2912,8 @@ var init_taskRun = __esm({
2907
2912
  Object.assign(this.notes, notes);
2908
2913
  }
2909
2914
  };
2915
+ describeValue = (value) => Array.isArray(value) ? "array" : value === null ? "null" : typeof value;
2916
+ RESULT_CONTRACT = "return a string report, an object {report?: string, ...} or nothing";
2910
2917
  }
2911
2918
  });
2912
2919
 
@@ -3060,16 +3067,21 @@ var init_worldDir = __esm({
3060
3067
  var hub_exports = {};
3061
3068
  __export(hub_exports, {
3062
3069
  DEFAULT_BRANCH: () => DEFAULT_BRANCH,
3070
+ PushSlugConflict: () => PushSlugConflict,
3071
+ archiveMode: () => archiveMode,
3072
+ buildFileManifest: () => buildFileManifest,
3063
3073
  buildSourceTarball: () => buildSourceTarball,
3064
3074
  collectArchiveRelPaths: () => collectArchiveRelPaths,
3065
3075
  computeContentHash: () => computeContentHash,
3066
3076
  createRef: () => createRef,
3077
+ extractBundle: () => extractBundle,
3067
3078
  localTreeState: () => localTreeState,
3068
3079
  propose: () => propose,
3069
3080
  pull: () => pull,
3070
3081
  push: () => push,
3071
3082
  pushSlug: () => pushSlug,
3072
3083
  readLocalMeta: () => readLocalMeta,
3084
+ resolvePushSlug: () => resolvePushSlug,
3073
3085
  snapshotTreeHashes: () => snapshotTreeHashes,
3074
3086
  writeLocalMeta: () => writeLocalMeta
3075
3087
  });
@@ -3091,12 +3103,18 @@ function computeContentHash(dir) {
3091
3103
  return WorldDir.open(dir).contentHash;
3092
3104
  }
3093
3105
  function octal(value, length) {
3094
- return Buffer.from(value.toString(8).padStart(length - 1, "0") + "\0", "ascii");
3106
+ return Buffer.from(
3107
+ value.toString(8).padStart(length - 1, "0") + "\0",
3108
+ "ascii"
3109
+ );
3095
3110
  }
3096
- function tarHeader(name, size) {
3111
+ function archiveMode(mode) {
3112
+ return (mode & 73) !== 0 ? EXEC_MODE : FILE_MODE;
3113
+ }
3114
+ function tarHeader(name, size, mode = FILE_MODE) {
3097
3115
  const header = Buffer.alloc(512);
3098
3116
  header.write(name, 0, 100, "utf-8");
3099
- octal(420, 8).copy(header, 100);
3117
+ octal(mode, 8).copy(header, 100);
3100
3118
  octal(0, 8).copy(header, 108);
3101
3119
  octal(0, 8).copy(header, 116);
3102
3120
  octal(size, 12).copy(header, 124);
@@ -3110,7 +3128,7 @@ function tarHeader(name, size) {
3110
3128
  header.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, "ascii");
3111
3129
  return header;
3112
3130
  }
3113
- function tarMember(name, payload) {
3131
+ function tarMember(name, payload, mode) {
3114
3132
  const parts = [];
3115
3133
  const nameBytes = Buffer.byteLength(name, "utf-8");
3116
3134
  if (nameBytes > 100) {
@@ -3124,9 +3142,9 @@ function tarMember(name, payload) {
3124
3142
  parts.push(lHeader, body);
3125
3143
  const pad2 = body.length % 512 === 0 ? 0 : 512 - body.length % 512;
3126
3144
  if (pad2) parts.push(Buffer.alloc(pad2));
3127
- parts.push(tarHeader(name.slice(0, 100), payload.length));
3145
+ parts.push(tarHeader(name.slice(0, 100), payload.length, mode));
3128
3146
  } else {
3129
- parts.push(tarHeader(name, payload.length));
3147
+ parts.push(tarHeader(name, payload.length, mode));
3130
3148
  }
3131
3149
  parts.push(payload);
3132
3150
  const pad = payload.length % 512 === 0 ? 0 : 512 - payload.length % 512;
@@ -3136,7 +3154,14 @@ function tarMember(name, payload) {
3136
3154
  function buildSourceTarball(dir) {
3137
3155
  const parts = [];
3138
3156
  for (const relPath of collectArchiveRelPaths(dir)) {
3139
- parts.push(...tarMember(relPath, fs3.readFileSync(path3.join(dir, relPath))));
3157
+ const abs = path3.join(dir, relPath);
3158
+ parts.push(
3159
+ ...tarMember(
3160
+ relPath,
3161
+ fs3.readFileSync(abs),
3162
+ archiveMode(fs3.statSync(abs).mode)
3163
+ )
3164
+ );
3140
3165
  }
3141
3166
  parts.push(Buffer.alloc(1024));
3142
3167
  return gzipSync(Buffer.concat(parts), { level: 9 });
@@ -3151,10 +3176,22 @@ function readLocalMeta(dir) {
3151
3176
  }
3152
3177
  }
3153
3178
  function pushSlug(dir, explicit) {
3154
- if (explicit) return explicit;
3179
+ return resolvePushSlug(dir, { explicit }).slug;
3180
+ }
3181
+ function resolvePushSlug(dir, opts = {}) {
3155
3182
  const meta = readLocalMeta(dir);
3156
- if (typeof meta?.slug === "string" && meta.slug) return meta.slug;
3157
- return readPyproject(dir).name ?? path3.basename(path3.resolve(dir));
3183
+ const tracked = typeof meta?.slug === "string" && meta.slug ? meta.slug : null;
3184
+ const declared = Object.entries({ ...opts.declared ?? {}, "pyproject.toml": readPyproject(dir).name }).filter((entry) => typeof entry[1] === "string" && entry[1] !== "").map(([source, slug]) => ({ source, slug }));
3185
+ const base = { tracked, declared, conflict: null };
3186
+ if (opts.explicit) return { ...base, slug: opts.explicit, source: "--slug" };
3187
+ if (tracked) {
3188
+ const minted = (d) => tracked.startsWith(d.slug) && MINTED_SUFFIX.test(tracked.slice(d.slug.length));
3189
+ const conflict = declared.find((d) => d.slug !== tracked && !minted(d)) ?? null;
3190
+ return { ...base, slug: tracked, source: ".gateway metadata", conflict };
3191
+ }
3192
+ const first = declared[0];
3193
+ if (first) return { ...base, slug: first.slug, source: first.source };
3194
+ return { ...base, slug: path3.basename(path3.resolve(dir)), source: "directory name" };
3158
3195
  }
3159
3196
  function writeLocalMeta(dir, meta) {
3160
3197
  fs3.mkdirSync(path3.join(dir, ".gateway"), { recursive: true });
@@ -3193,7 +3230,9 @@ function readPyproject(dir) {
3193
3230
  function readWorldContractVersion(dir) {
3194
3231
  const world = WorldDir.open(dir);
3195
3232
  try {
3196
- const parsed = JSON.parse(world.text(world.worldPath("schema/world.json")) ?? "");
3233
+ const parsed = JSON.parse(
3234
+ world.text(world.worldPath("schema/world.json")) ?? ""
3235
+ );
3197
3236
  const pkg = parsed["x-gateway"]?.package;
3198
3237
  if (pkg?.version) return { name: pkg.id, version: pkg.version };
3199
3238
  } catch {
@@ -3201,28 +3240,15 @@ function readWorldContractVersion(dir) {
3201
3240
  return {};
3202
3241
  }
3203
3242
  function buildFileManifest(dir) {
3204
- const entries = [];
3205
- const walk = (rel) => {
3206
- const abs = rel ? path3.join(dir, rel) : dir;
3207
- for (const entry of fs3.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
3208
- const childRel = rel ? `${rel}/${entry.name}` : entry.name;
3209
- if (entry.isDirectory()) {
3210
- if (!SKIP_DIRS.has(entry.name) && !entry.name.endsWith(".egg-info")) {
3211
- walk(childRel);
3212
- }
3213
- } else if (entry.isFile()) {
3214
- const payload = fs3.readFileSync(path3.join(dir, childRel));
3215
- entries.push({
3216
- path: childRel,
3217
- isDirectory: false,
3218
- size: payload.length,
3219
- sha256: createHash3("sha256").update(payload).digest("hex")
3220
- });
3221
- }
3222
- }
3223
- };
3224
- walk("");
3225
- return entries;
3243
+ return collectArchiveRelPaths(dir).map((relPath) => {
3244
+ const payload = fs3.readFileSync(path3.join(dir, relPath));
3245
+ return {
3246
+ path: relPath,
3247
+ isDirectory: false,
3248
+ size: payload.length,
3249
+ sha256: createHash3("sha256").update(payload).digest("hex")
3250
+ };
3251
+ });
3226
3252
  }
3227
3253
  async function putObject(url, data, shaB64) {
3228
3254
  const resp = await fetch(url, {
@@ -3234,22 +3260,30 @@ async function putObject(url, data, shaB64) {
3234
3260
  body: new Uint8Array(data)
3235
3261
  });
3236
3262
  if (!resp.ok) {
3237
- throw new Error(`object PUT -> ${resp.status}: ${(await resp.text()).slice(0, 300)}`);
3263
+ throw new Error(
3264
+ `object PUT -> ${resp.status}: ${(await resp.text()).slice(0, 300)}`
3265
+ );
3238
3266
  }
3239
3267
  }
3240
3268
  async function push(dir, opts = {}) {
3241
3269
  const options = opts.options ?? {};
3242
- if (!fs3.statSync(dir).isDirectory()) throw new Error(`Not a directory: ${dir}`);
3270
+ if (!fs3.statSync(dir).isDirectory())
3271
+ throw new Error(`Not a directory: ${dir}`);
3243
3272
  const localMeta = readLocalMeta(dir) ?? {};
3244
3273
  const branch = opts.branch ?? localMeta.branch ?? DEFAULT_BRANCH;
3245
3274
  const baseVersionId = opts.baseVersionId ?? localMeta.versionId ?? null;
3275
+ const fileManifest = buildFileManifest(dir);
3276
+ if (fileManifest.length === 0)
3277
+ throw new Error(
3278
+ `Nothing to push: ${dir} has no files the archive rules keep (a world root marker, README.md, pyproject.toml, *.py, or any file below a subdirectory).`
3279
+ );
3246
3280
  const contentHash = computeContentHash(dir);
3247
3281
  const pyproject = readPyproject(dir);
3248
3282
  const contractVersion = pyproject.version ? void 0 : readWorldContractVersion(dir).version;
3249
3283
  if (contractVersion) pyproject.version = contractVersion;
3250
3284
  const slug = opts.slug ?? localMeta.slug ?? pyproject.name ?? path3.basename(path3.resolve(dir));
3251
3285
  const metadata = {
3252
- name: opts.name ?? pyproject.name ?? slug,
3286
+ ...opts.name !== void 0 ? { name: opts.name } : {},
3253
3287
  ...opts.description !== void 0 ? { description: opts.description } : {},
3254
3288
  ...opts.tags !== void 0 ? { tags: opts.tags } : {},
3255
3289
  ...opts.visibility ? { visibility: opts.visibility } : {}
@@ -3269,7 +3303,7 @@ async function push(dir, opts = {}) {
3269
3303
  bundleSizeBytes: tarball.length,
3270
3304
  ...pyproject.version ? { semanticVersion: pyproject.version } : {},
3271
3305
  pyprojectMeta: pyproject,
3272
- fileManifest: buildFileManifest(dir),
3306
+ fileManifest,
3273
3307
  branch,
3274
3308
  baseVersionId,
3275
3309
  ...opts.force ? { force: true } : {},
@@ -3277,12 +3311,18 @@ async function push(dir, opts = {}) {
3277
3311
  ...opts.author ? { author: opts.author } : {},
3278
3312
  ...opts.imageRef ? { imageRef: opts.imageRef } : {}
3279
3313
  });
3280
- if (version.uploadUrl) await putObject(version.uploadUrl, tarball, bundleSha256);
3314
+ if (version.uploadUrl)
3315
+ await putObject(version.uploadUrl, tarball, bundleSha256);
3281
3316
  const final = await apiRequest(
3282
3317
  options,
3283
3318
  "POST",
3284
3319
  `/api/public/benchmark-containers/versions/${version.versionId}/finalize`,
3285
- { branch, baseVersionId, ...opts.force ? { force: true } : {}, ...metadata }
3320
+ {
3321
+ branch,
3322
+ baseVersionId,
3323
+ ...opts.force ? { force: true } : {},
3324
+ ...metadata
3325
+ }
3286
3326
  );
3287
3327
  writeLocalMeta(dir, {
3288
3328
  ...localMeta,
@@ -3315,7 +3355,14 @@ function extractBundle(bundle, dir) {
3315
3355
  offset += 512;
3316
3356
  if (header.every((b) => b === 0)) break;
3317
3357
  const rawName = header.subarray(0, 100).toString("utf-8").replace(/\0.*$/, "");
3318
- const size = parseInt(header.subarray(124, 136).toString("ascii").replace(/\0.*$/, "").trim(), 8) || 0;
3358
+ const size = parseInt(
3359
+ header.subarray(124, 136).toString("ascii").replace(/\0.*$/, "").trim(),
3360
+ 8
3361
+ ) || 0;
3362
+ const mode = parseInt(
3363
+ header.subarray(100, 108).toString("ascii").replace(/\0.*$/, "").trim(),
3364
+ 8
3365
+ ) || FILE_MODE;
3319
3366
  const typeflag = header.subarray(156, 157).toString("ascii");
3320
3367
  const body = tar.subarray(offset, offset + size);
3321
3368
  offset += size + (size % 512 === 0 ? 0 : 512 - size % 512);
@@ -3329,7 +3376,8 @@ function extractBundle(bundle, dir) {
3329
3376
  if (name.startsWith("/") || name.split("/").includes("..")) continue;
3330
3377
  const target = path3.join(dir, name);
3331
3378
  fs3.mkdirSync(path3.dirname(target), { recursive: true });
3332
- fs3.writeFileSync(target, body);
3379
+ fs3.writeFileSync(target, body, { mode: archiveMode(mode) });
3380
+ fs3.chmodSync(target, archiveMode(mode));
3333
3381
  written++;
3334
3382
  }
3335
3383
  return written;
@@ -3376,13 +3424,17 @@ async function pull(slugRef, target, options = {}) {
3376
3424
  async function propose(dir, opts) {
3377
3425
  const meta = readLocalMeta(dir);
3378
3426
  if (!meta?.slug || !meta.baseFiles) {
3379
- throw new Error("This dir has no pull/push base \u2014 run pull first, then edit, then propose.");
3427
+ throw new Error(
3428
+ "This dir has no pull/push base \u2014 run pull first, then edit, then propose."
3429
+ );
3380
3430
  }
3381
3431
  const state2 = localTreeState(dir);
3382
- if (state2.clean) throw new Error("Nothing to propose \u2014 the tree matches its base.");
3432
+ if (state2.clean)
3433
+ throw new Error("Nothing to propose \u2014 the tree matches its base.");
3383
3434
  const changes = state2.dirty.map((relPath) => {
3384
3435
  const abs = path3.join(dir, relPath);
3385
- if (!fs3.existsSync(abs)) return { path: relPath, action: "delete" };
3436
+ if (!fs3.existsSync(abs))
3437
+ return { path: relPath, action: "delete" };
3386
3438
  return {
3387
3439
  path: relPath,
3388
3440
  action: "write",
@@ -3412,7 +3464,7 @@ async function createRef(slug, name, kind, versionId, options = {}) {
3412
3464
  ...versionId ? { versionId } : {}
3413
3465
  });
3414
3466
  }
3415
- var DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, sha256b64;
3467
+ var DEFAULT_BRANCH, META_RELPATH, FILE_MODE, EXEC_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64;
3416
3468
  var init_hub = __esm({
3417
3469
  "src/worlds/hub.ts"() {
3418
3470
  "use strict";
@@ -3420,16 +3472,20 @@ var init_hub = __esm({
3420
3472
  init_worldDir();
3421
3473
  DEFAULT_BRANCH = "main";
3422
3474
  META_RELPATH = path3.join(".gateway", ".env-metadata.json");
3423
- SKIP_DIRS = /* @__PURE__ */ new Set([
3424
- ".git",
3425
- "__pycache__",
3426
- "node_modules",
3427
- ".venv",
3428
- ".mypy_cache",
3429
- "dist",
3430
- "build",
3431
- "outputs"
3432
- ]);
3475
+ FILE_MODE = 420;
3476
+ EXEC_MODE = 493;
3477
+ MINTED_SUFFIX = /^-\d+$/;
3478
+ PushSlugConflict = class extends Error {
3479
+ constructor(dir, tracked, declared) {
3480
+ super(
3481
+ `${dir} tracks slug \`${tracked}\` (${META_RELPATH}, from an earlier push) but its ${declared.source} says \`${declared.slug}\`. Nothing was pushed. Pass --slug ${declared.slug} to push there (and retrack the dir), --slug ${tracked} to keep pushing to \`${tracked}\`, or delete ${META_RELPATH} to forget the earlier push.`
3482
+ );
3483
+ this.dir = dir;
3484
+ this.tracked = tracked;
3485
+ this.declared = declared;
3486
+ this.name = "PushSlugConflict";
3487
+ }
3488
+ };
3433
3489
  sha256b64 = (data) => createHash3("sha256").update(data).digest("base64");
3434
3490
  }
3435
3491
  });
@@ -4141,11 +4197,20 @@ var init_router = __esm({
4141
4197
  import * as fs4 from "fs";
4142
4198
  import * as os from "os";
4143
4199
  import * as path4 from "path";
4200
+ function transportDetail(error, timeoutMs) {
4201
+ if (error instanceof Error && error.name === "AbortError") return `timed out after ${Math.round(timeoutMs / 1e3)}s`;
4202
+ const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
4203
+ const code = cause && "code" in cause && typeof cause.code === "string" ? `${cause.code}: ` : "";
4204
+ const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
4205
+ return `${code}${message}`;
4206
+ }
4144
4207
  async function api(creds, method, route, body, init2 = {}) {
4145
4208
  const controller = new AbortController();
4146
- const timer = setTimeout(() => controller.abort(), init2.timeoutMs ?? 12e4);
4209
+ const timeoutMs = init2.timeoutMs ?? 12e4;
4210
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
4211
+ let res;
4147
4212
  try {
4148
- const res = await fetch(`${creds.host}${route}`, {
4213
+ res = await fetch(`${creds.host}${route}`, {
4149
4214
  method,
4150
4215
  headers: {
4151
4216
  "content-type": "application/json",
@@ -4155,6 +4220,11 @@ async function api(creds, method, route, body, init2 = {}) {
4155
4220
  ...body === void 0 ? {} : { body: JSON.stringify(body) },
4156
4221
  signal: controller.signal
4157
4222
  });
4223
+ } catch (error) {
4224
+ clearTimeout(timer);
4225
+ throw new UnreachableError(creds.host, method, route, transportDetail(error, timeoutMs));
4226
+ }
4227
+ try {
4158
4228
  const text2 = await res.text();
4159
4229
  if (!res.ok) throw new ApiError(res.status, method, route, text2);
4160
4230
  return text2 ? JSON.parse(text2) : {};
@@ -4162,7 +4232,7 @@ async function api(creds, method, route, body, init2 = {}) {
4162
4232
  clearTimeout(timer);
4163
4233
  }
4164
4234
  }
4165
- var ApiError;
4235
+ var ApiError, UnreachableError;
4166
4236
  var init_config = __esm({
4167
4237
  "src/cli/config.ts"() {
4168
4238
  "use strict";
@@ -4176,6 +4246,15 @@ var init_config = __esm({
4176
4246
  this.text = text2;
4177
4247
  }
4178
4248
  };
4249
+ UnreachableError = class extends CliError {
4250
+ constructor(host, method, route, detail) {
4251
+ super(`${method} ${route}: no answer from ${host} (${detail}). Check the host and the network, then retry.`, 1);
4252
+ this.host = host;
4253
+ this.method = method;
4254
+ this.route = route;
4255
+ this.detail = detail;
4256
+ }
4257
+ };
4179
4258
  }
4180
4259
  });
4181
4260
 
@@ -4391,7 +4470,7 @@ function readWorldFiles(dir, opts = {}) {
4391
4470
  for (const entry of entries) {
4392
4471
  const childRel = rel ? `${rel}/${entry.name}` : entry.name;
4393
4472
  if (entry.isDirectory()) {
4394
- if (!SKIP_DIRS2.has(entry.name)) walk(childRel);
4473
+ if (!SKIP_DIRS.has(entry.name)) walk(childRel);
4395
4474
  } else if (entry.isFile()) {
4396
4475
  if (!opts.buildOutputs && isBuildOutput(childRel)) continue;
4397
4476
  out.push({
@@ -4434,7 +4513,7 @@ function pruneEmptyDirs(root) {
4434
4513
  for (const entry of fs6.readdirSync(abs, { withFileTypes: true })) {
4435
4514
  const child = path6.join(abs, entry.name);
4436
4515
  if (entry.isDirectory()) {
4437
- if (SKIP_DIRS2.has(entry.name)) {
4516
+ if (SKIP_DIRS.has(entry.name)) {
4438
4517
  empty = false;
4439
4518
  continue;
4440
4519
  }
@@ -4502,13 +4581,13 @@ async function runtime(creds, request, opts = {}) {
4502
4581
  clearTimeout(timer);
4503
4582
  }
4504
4583
  }
4505
- var SKIP_DIRS2, BUILD_OUTPUT, BridgeRejected;
4584
+ var SKIP_DIRS, BUILD_OUTPUT, BridgeRejected;
4506
4585
  var init_client = __esm({
4507
4586
  "src/cli/runtime/client.ts"() {
4508
4587
  "use strict";
4509
4588
  init_router();
4510
4589
  init_local();
4511
- SKIP_DIRS2 = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
4590
+ SKIP_DIRS = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
4512
4591
  BUILD_OUTPUT = /(^|\/)state\.(sqlite|json)$/;
4513
4592
  BridgeRejected = class extends CliError {
4514
4593
  constructor(detail) {
@@ -4928,7 +5007,12 @@ var init_batches = __esm({
4928
5007
  "use strict";
4929
5008
  init_config();
4930
5009
  init_router();
4931
- TERMINAL_STATES = /* @__PURE__ */ new Set(["applied", "refused", "published", "failed"]);
5010
+ TERMINAL_STATES = /* @__PURE__ */ new Set([
5011
+ "applied",
5012
+ "refused",
5013
+ "published",
5014
+ "failed"
5015
+ ]);
4932
5016
  sleepMs = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
4933
5017
  WorldDataApi = class {
4934
5018
  constructor(creds, slug, sleep2 = sleepMs) {
@@ -4942,22 +5026,61 @@ var init_batches = __esm({
4942
5026
  return api(this.creds, "POST", `${this.base}/batches`, body);
4943
5027
  }
4944
5028
  register(batchId, chunk) {
4945
- return api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks`, {
5029
+ return api(
5030
+ this.creds,
5031
+ "POST",
5032
+ `${this.base}/batches/${batchId}/chunks`,
5033
+ {
5034
+ ordinal: chunk.ordinal,
5035
+ digest: chunk.digest,
5036
+ bytes: chunk.bytes,
5037
+ rows: chunk.rows,
5038
+ ...chunk.entity ? { entity: chunk.entity } : {}
5039
+ }
5040
+ );
5041
+ }
5042
+ /**
5043
+ * Stage a project-drive rows file as one chunk, on the platform: the server
5044
+ * streams it out of drive storage into chunk storage and answers with the
5045
+ * digest and gzipped size it derived. No bytes pass through this process.
5046
+ */
5047
+ async stageDrive(batchId, chunk) {
5048
+ const staged = await api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks`, {
4946
5049
  ordinal: chunk.ordinal,
4947
- digest: chunk.digest,
4948
- bytes: chunk.bytes,
4949
- rows: chunk.rows,
5050
+ drive: chunk.path,
4950
5051
  ...chunk.entity ? { entity: chunk.entity } : {}
4951
5052
  });
5053
+ if (!staged.uploaded || !staged.digest || staged.bytes === void 0 || staged.rows === void 0)
5054
+ throw new CliError(
5055
+ `the server staged drive:${chunk.path} as chunk ${chunk.ordinal} without its digest, size and rows`,
5056
+ 1
5057
+ );
5058
+ return {
5059
+ ordinal: chunk.ordinal,
5060
+ digest: staged.digest,
5061
+ bytes: staged.bytes,
5062
+ rows: staged.rows,
5063
+ entity: chunk.entity,
5064
+ chunkId: staged.chunkId,
5065
+ uploaded: true
5066
+ };
4952
5067
  }
4953
5068
  markUploaded(batchId, chunkId) {
4954
- return api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks/${chunkId}/uploaded`);
5069
+ return api(
5070
+ this.creds,
5071
+ "POST",
5072
+ `${this.base}/batches/${batchId}/chunks/${chunkId}/uploaded`
5073
+ );
4955
5074
  }
4956
5075
  complete(batchId) {
4957
5076
  return api(this.creds, "POST", `${this.base}/batches/${batchId}/complete`);
4958
5077
  }
4959
5078
  get(batchId) {
4960
- return api(this.creds, "GET", `${this.base}/batches/${batchId}`);
5079
+ return api(
5080
+ this.creds,
5081
+ "GET",
5082
+ `${this.base}/batches/${batchId}`
5083
+ );
4961
5084
  }
4962
5085
  list(limit, cursor) {
4963
5086
  const params = new URLSearchParams();
@@ -4967,7 +5090,12 @@ var init_batches = __esm({
4967
5090
  return api(this.creds, "GET", `${this.base}/batches${q ? `?${q}` : ""}`);
4968
5091
  }
4969
5092
  publish(message) {
4970
- return api(this.creds, "POST", `${this.base}/publish`, message ? { message } : {});
5093
+ return api(
5094
+ this.creds,
5095
+ "POST",
5096
+ `${this.base}/publish`,
5097
+ message ? { message } : {}
5098
+ );
4971
5099
  }
4972
5100
  /**
4973
5101
  * PUT the gzipped chunk to its presigned URL with exactly the headers the
@@ -4979,11 +5107,23 @@ var init_batches = __esm({
4979
5107
  const delays = [500, 1500, 4e3];
4980
5108
  for (let attempt = 0; ; attempt++) {
4981
5109
  try {
4982
- const res = await fetch(uploadUrl, { method: "PUT", body: new Uint8Array(gz), headers });
5110
+ const res = await fetch(uploadUrl, {
5111
+ method: "PUT",
5112
+ body: new Uint8Array(gz),
5113
+ headers
5114
+ });
4983
5115
  if (res.ok) return;
4984
- if (res.status < 500 || attempt >= delays.length) throw new CliError(`chunk upload -> ${res.status}: ${(await res.text()).slice(0, 300)}`, 1);
5116
+ if (res.status < 500 || attempt >= delays.length)
5117
+ throw new CliError(
5118
+ `chunk upload -> ${res.status}: ${(await res.text()).slice(0, 300)}`,
5119
+ 1
5120
+ );
4985
5121
  } catch (error) {
4986
- if (error instanceof CliError || attempt >= delays.length) throw error instanceof CliError ? error : new CliError(`chunk upload failed: ${error.message}`, 1);
5122
+ if (error instanceof CliError || attempt >= delays.length)
5123
+ throw error instanceof CliError ? error : new CliError(
5124
+ `chunk upload failed: ${error.message}`,
5125
+ 1
5126
+ );
4987
5127
  }
4988
5128
  await this.sleep(delays[attempt]);
4989
5129
  }
@@ -4992,11 +5132,23 @@ var init_batches = __esm({
4992
5132
  async upload(batchId, chunk) {
4993
5133
  const registered = await this.register(batchId, chunk);
4994
5134
  if (!registered.uploaded) {
4995
- if (!registered.uploadUrl) throw new CliError(`the server registered chunk ${chunk.ordinal} without an upload URL`, 1);
5135
+ if (!registered.uploadUrl)
5136
+ throw new CliError(
5137
+ `the server registered chunk ${chunk.ordinal} without an upload URL`,
5138
+ 1
5139
+ );
4996
5140
  await this.put(registered.uploadUrl, chunk.gz, registered.uploadHeaders);
4997
5141
  await this.markUploaded(batchId, registered.chunkId);
4998
5142
  }
4999
- return { ordinal: chunk.ordinal, digest: chunk.digest, bytes: chunk.bytes, rows: chunk.rows, entity: chunk.entity, chunkId: registered.chunkId, uploaded: true };
5143
+ return {
5144
+ ordinal: chunk.ordinal,
5145
+ digest: chunk.digest,
5146
+ bytes: chunk.bytes,
5147
+ rows: chunk.rows,
5148
+ entity: chunk.entity,
5149
+ chunkId: registered.chunkId,
5150
+ uploaded: true
5151
+ };
5000
5152
  }
5001
5153
  };
5002
5154
  }
@@ -5012,14 +5164,20 @@ function chunkLine(row, declared) {
5012
5164
  tagged.set("row", row.row);
5013
5165
  return dumps(tagged) + "\n";
5014
5166
  }
5015
- async function* buildChunks(rows, plan) {
5167
+ async function* buildChunks(rows, plan, ordinalStart = 0) {
5016
5168
  let lines = [];
5017
5169
  let rawBytes = 0;
5018
- let ordinal = 0;
5170
+ let ordinal = ordinalStart;
5019
5171
  let seen = 0;
5020
5172
  const flush2 = () => {
5021
5173
  const raw = Buffer.concat(lines);
5022
- const built = finishChunk(ordinal++, raw, lines.length, plan.entity, seen - lines.length);
5174
+ const built = finishChunk(
5175
+ ordinal++,
5176
+ raw,
5177
+ lines.length,
5178
+ plan.entity,
5179
+ seen - lines.length
5180
+ );
5023
5181
  lines = [];
5024
5182
  rawBytes = 0;
5025
5183
  return built;
@@ -5051,7 +5209,18 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
5051
5209
  function gzipDeterministic(raw, opts = {}) {
5052
5210
  const level = opts.level ?? GZIP_LEVEL;
5053
5211
  const name = opts.name ? Buffer.concat([Buffer.from(opts.name, "latin1"), Buffer.from([0])]) : Buffer.alloc(0);
5054
- const header = Buffer.from([31, 139, 8, opts.name ? 8 : 0, 0, 0, 0, 0, level === 9 ? 2 : level === 1 ? 4 : 0, 255]);
5212
+ const header = Buffer.from([
5213
+ 31,
5214
+ 139,
5215
+ 8,
5216
+ opts.name ? 8 : 0,
5217
+ 0,
5218
+ 0,
5219
+ 0,
5220
+ 0,
5221
+ level === 9 ? 2 : level === 1 ? 4 : 0,
5222
+ 255
5223
+ ]);
5055
5224
  const body = deflateRawSync(raw, { level });
5056
5225
  const trailer = Buffer.alloc(8);
5057
5226
  trailer.writeUInt32LE(crc32(raw), 0);
@@ -5068,7 +5237,8 @@ function crc32(data) {
5068
5237
  }
5069
5238
  }
5070
5239
  let crc = 4294967295;
5071
- for (let i = 0; i < data.length; i++) crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
5240
+ for (let i = 0; i < data.length; i++)
5241
+ crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
5072
5242
  return (crc ^ 4294967295) >>> 0;
5073
5243
  }
5074
5244
  var DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
@@ -5367,6 +5537,58 @@ var init_ingest = __esm({
5367
5537
  }
5368
5538
  });
5369
5539
 
5540
+ // src/worlds/sandbox.ts
5541
+ function parseSlugRef(slugRef) {
5542
+ const at = slugRef.indexOf("@");
5543
+ if (at === -1) return { slug: slugRef };
5544
+ return { slug: slugRef.slice(0, at), ref: slugRef.slice(at + 1) };
5545
+ }
5546
+ var sid, WorldSandboxClient;
5547
+ var init_sandbox = __esm({
5548
+ "src/worlds/sandbox.ts"() {
5549
+ "use strict";
5550
+ init_worlds();
5551
+ sid = encodeURIComponent;
5552
+ WorldSandboxClient = class {
5553
+ constructor(options = {}) {
5554
+ this.options = options;
5555
+ }
5556
+ open(target) {
5557
+ return apiRequest(this.options, "POST", "/api/public/benchmark-containers/sandboxes", target);
5558
+ }
5559
+ status(sandboxId) {
5560
+ return apiRequest(this.options, "GET", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}`);
5561
+ }
5562
+ async read(sandboxId, filePath) {
5563
+ const res = await apiRequest(
5564
+ this.options,
5565
+ "GET",
5566
+ `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/file?path=${encodeURIComponent(filePath)}`
5567
+ );
5568
+ return { path: res.path, size: res.size, bytes: Buffer.from(res.contentBase64, "base64") };
5569
+ }
5570
+ write(sandboxId, filePath, bytes) {
5571
+ return apiRequest(this.options, "PUT", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/file`, {
5572
+ path: filePath,
5573
+ contentBase64: bytes.toString("base64")
5574
+ });
5575
+ }
5576
+ exec(sandboxId, input) {
5577
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/exec`, input);
5578
+ }
5579
+ check(sandboxId) {
5580
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/check`, {});
5581
+ }
5582
+ commit(sandboxId, input) {
5583
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/commit`, input);
5584
+ }
5585
+ close(sandboxId) {
5586
+ return apiRequest(this.options, "DELETE", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}`);
5587
+ }
5588
+ };
5589
+ }
5590
+ });
5591
+
5370
5592
  // src/worlds/index.ts
5371
5593
  var worlds_exports = {};
5372
5594
  __export(worlds_exports, {
@@ -5379,6 +5601,7 @@ __export(worlds_exports, {
5379
5601
  EVENT_FLUSH_INTERVAL_MS: () => EVENT_FLUSH_INTERVAL_MS,
5380
5602
  EVENT_MAX_RETRIES: () => EVENT_MAX_RETRIES,
5381
5603
  GatewayEvalsClient: () => GatewayEvalsClient,
5604
+ PushSlugConflict: () => PushSlugConflict,
5382
5605
  STRIP_PREFIX: () => STRIP_PREFIX,
5383
5606
  SURFACE_KINDS: () => SURFACE_KINDS,
5384
5607
  TRANSFORMS: () => TRANSFORMS,
@@ -5386,6 +5609,7 @@ __export(worlds_exports, {
5386
5609
  TaskSessions: () => TaskSessions,
5387
5610
  WHITESPACE: () => WHITESPACE,
5388
5611
  WorldBrowser: () => WorldBrowser,
5612
+ WorldSandboxClient: () => WorldSandboxClient,
5389
5613
  WorldSession: () => WorldSession,
5390
5614
  WorldSessionCallError: () => WorldSessionCallError,
5391
5615
  WorldSessionTimeout: () => WorldSessionTimeout,
@@ -5395,9 +5619,11 @@ __export(worlds_exports, {
5395
5619
  aggregateTaskGrade: () => aggregateTaskGrade,
5396
5620
  apiRequest: () => apiRequest,
5397
5621
  applyTransforms: () => applyTransforms,
5622
+ archiveMode: () => archiveMode,
5398
5623
  attachManifest: () => attachManifest,
5399
5624
  attachSession: () => attachSession,
5400
5625
  attachTask: () => attachTask,
5626
+ buildFileManifest: () => buildFileManifest,
5401
5627
  buildSourceTarball: () => buildSourceTarball,
5402
5628
  captureToolCalls: () => captureToolCalls,
5403
5629
  collectArchiveRelPaths: () => collectArchiveRelPaths,
@@ -5409,6 +5635,7 @@ __export(worlds_exports, {
5409
5635
  deleteTask: () => deleteTask,
5410
5636
  describeWorld: () => describeWorld,
5411
5637
  detectProvenance: () => detectProvenance,
5638
+ extractBundle: () => extractBundle,
5412
5639
  getRun: () => getRun,
5413
5640
  getTask: () => getTask,
5414
5641
  hashForm: () => hashForm,
@@ -5429,6 +5656,8 @@ __export(worlds_exports, {
5429
5656
  openSession: () => openSession,
5430
5657
  openTask: () => openTask,
5431
5658
  openWorld: () => openWorld,
5659
+ openWorldVersion: () => openWorldVersion,
5660
+ parseSlugRef: () => parseSlugRef,
5432
5661
  parseToolCallRecord: () => parseToolCallRecord,
5433
5662
  parseTransform: () => parseTransform,
5434
5663
  parseWorldTaskRefs: () => parseWorldTaskRefs,
@@ -5445,6 +5674,7 @@ __export(worlds_exports, {
5445
5674
  redactActionArgs: () => redactActionArgs,
5446
5675
  redactionOf: () => redactionOf,
5447
5676
  resolveBrowserMode: () => resolveBrowserMode,
5677
+ resolvePushSlug: () => resolvePushSlug,
5448
5678
  roundForm: () => roundForm,
5449
5679
  runSessions: () => runSessions,
5450
5680
  runTask: () => runTask,
@@ -5619,9 +5849,21 @@ async function openWorld(slugRef, options = {}) {
5619
5849
  const at = slugRef.indexOf("@");
5620
5850
  const slug = at === -1 ? slugRef : slugRef.slice(0, at);
5621
5851
  const ref = at === -1 ? null : slugRef.slice(at + 1);
5852
+ return resolveWorld(slugRef, slug, ref, ref ? { ref } : {}, options);
5853
+ }
5854
+ async function openWorldVersion(slug, versionId, options = {}) {
5855
+ return resolveWorld(
5856
+ `${slug}@${versionId}`,
5857
+ slug,
5858
+ null,
5859
+ { versionId },
5860
+ options
5861
+ );
5862
+ }
5863
+ async function resolveWorld(slugRef, slug, ref, pin, options) {
5622
5864
  const version = await apiRequest(options, "POST", "/api/public/benchmark-containers/resolve-version", {
5623
5865
  slug,
5624
- ...ref ? { ref } : {}
5866
+ ...pin
5625
5867
  });
5626
5868
  const world = new WorldSet(
5627
5869
  slugRef,
@@ -5659,6 +5901,7 @@ var init_worlds = __esm({
5659
5901
  init_query();
5660
5902
  init_migrate();
5661
5903
  init_ingest();
5904
+ init_sandbox();
5662
5905
  ApiError2 = class extends Error {
5663
5906
  constructor(status, method, path10, body) {
5664
5907
  super(`${method} ${path10} -> ${status}: ${body}`);
@@ -5741,6 +5984,7 @@ export {
5741
5984
  EVENT_FLUSH_INTERVAL_MS,
5742
5985
  EVENT_MAX_RETRIES,
5743
5986
  GatewayEvalsClient,
5987
+ PushSlugConflict,
5744
5988
  STRIP_PREFIX,
5745
5989
  SURFACE_KINDS,
5746
5990
  TRANSFORMS,
@@ -5748,6 +5992,7 @@ export {
5748
5992
  TaskSessions,
5749
5993
  WHITESPACE,
5750
5994
  WorldBrowser,
5995
+ WorldSandboxClient,
5751
5996
  WorldSession,
5752
5997
  WorldSessionCallError,
5753
5998
  WorldSessionTimeout,
@@ -5757,9 +6002,11 @@ export {
5757
6002
  aggregateTaskGrade,
5758
6003
  apiRequest,
5759
6004
  applyTransforms,
6005
+ archiveMode,
5760
6006
  attachManifest,
5761
6007
  attachSession,
5762
6008
  attachTask,
6009
+ buildFileManifest,
5763
6010
  buildSourceTarball,
5764
6011
  captureToolCalls,
5765
6012
  collectArchiveRelPaths,
@@ -5771,6 +6018,7 @@ export {
5771
6018
  deleteTask,
5772
6019
  describeWorld,
5773
6020
  detectProvenance,
6021
+ extractBundle,
5774
6022
  getRun,
5775
6023
  getTask,
5776
6024
  hashForm,
@@ -5791,6 +6039,8 @@ export {
5791
6039
  openSession,
5792
6040
  openTask,
5793
6041
  openWorld,
6042
+ openWorldVersion,
6043
+ parseSlugRef,
5794
6044
  parseToolCallRecord,
5795
6045
  parseTransform,
5796
6046
  parseWorldTaskRefs,
@@ -5807,6 +6057,7 @@ export {
5807
6057
  redactActionArgs,
5808
6058
  redactionOf,
5809
6059
  resolveBrowserMode,
6060
+ resolvePushSlug,
5810
6061
  roundForm,
5811
6062
  runSessions,
5812
6063
  runTask,