@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
@@ -620,8 +620,8 @@ async function runSessions(opts) {
620
620
  let tasks = opts.tasks;
621
621
  let versionId = opts.versionId;
622
622
  if (!tasks || !versionId) {
623
- const { openWorld: openWorld2 } = await Promise.resolve().then(() => (init_worlds(), worlds_exports));
624
- const world = await openWorld2(opts.world, options);
623
+ const { openWorld: openWorld2, openWorldVersion: openWorldVersion2 } = await Promise.resolve().then(() => (init_worlds(), worlds_exports));
624
+ const world = versionId ? await openWorldVersion2(opts.world.split("@", 1)[0], versionId, options) : await openWorld2(opts.world, options);
625
625
  tasks = tasks ?? world.tasks.map((t) => t.name);
626
626
  versionId = versionId ?? world.version.versionId;
627
627
  }
@@ -677,10 +677,12 @@ async function runSessions(opts) {
677
677
  })
678
678
  );
679
679
  const mean = results.reduce((sum, r) => sum + (r.reward ?? 0), 0) / (results.length || 1);
680
+ const failed = results.filter((r) => r.error).length;
680
681
  return {
681
682
  results: results.sort((a, b) => a.task.localeCompare(b.task)),
682
683
  mean,
683
- passed: opts.failUnder === void 0 ? true : mean >= opts.failUnder
684
+ failed,
685
+ passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
684
686
  };
685
687
  }
686
688
  var import_node_crypto, 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;
@@ -1962,7 +1964,7 @@ var require_package = __commonJS({
1962
1964
  "package.json"(exports2, module2) {
1963
1965
  module2.exports = {
1964
1966
  name: "@withgateway/sdk",
1965
- version: "0.2.5",
1967
+ version: "0.2.6",
1966
1968
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
1967
1969
  main: "./dist/index.js",
1968
1970
  module: "./dist/index.mjs",
@@ -2695,7 +2697,7 @@ async function fileTaskRun(live, runId, model, report, grade, agentError, traced
2695
2697
  task: live.name ?? live.taskId ?? runId,
2696
2698
  rolloutIndex: 0,
2697
2699
  prompt: live.instruction,
2698
- completion: report,
2700
+ ...report === null ? {} : { completion: report },
2699
2701
  rewards: grade.rewards,
2700
2702
  info: {
2701
2703
  sessionId: runId,
@@ -2733,17 +2735,20 @@ async function fileTaskRun(live, runId, model, report, grade, agentError, traced
2733
2735
  return evaluationId;
2734
2736
  }
2735
2737
  function reportFromResult(result) {
2738
+ if (result === void 0 || result === null)
2739
+ return { report: null, extra: {} };
2736
2740
  if (typeof result === "string") return { report: result, extra: {} };
2737
- if (result && typeof result === "object") {
2738
- const { report, ...extra } = result;
2739
- return {
2740
- report: report === void 0 || report === null ? null : typeof report === "string" ? report : String(report),
2741
- extra
2742
- };
2743
- }
2744
- if (result !== void 0 && result !== null)
2745
- return { report: String(result), extra: {} };
2746
- return { report: null, extra: {} };
2741
+ if (typeof result !== "object" || Array.isArray(result))
2742
+ throw new Error(
2743
+ `agent returned ${describeValue(result)}; ${RESULT_CONTRACT}`
2744
+ );
2745
+ const { report, ...extra } = result;
2746
+ if (report === void 0 || report === null) return { report: null, extra };
2747
+ if (typeof report !== "string")
2748
+ throw new Error(
2749
+ `agent returned a report of type ${describeValue(report)}; ${RESULT_CONTRACT}`
2750
+ );
2751
+ return { report, extra };
2747
2752
  }
2748
2753
  async function runTask(ref, agent, opts) {
2749
2754
  const runId = `wtr-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
@@ -2847,7 +2852,7 @@ async function runTask(ref, agent, opts) {
2847
2852
  }
2848
2853
  }
2849
2854
  }
2850
- var import_node_crypto3, fs, path, TaskRun;
2855
+ var import_node_crypto3, fs, path, TaskRun, describeValue, RESULT_CONTRACT;
2851
2856
  var init_taskRun = __esm({
2852
2857
  "src/worlds/taskRun.ts"() {
2853
2858
  "use strict";
@@ -2921,6 +2926,8 @@ var init_taskRun = __esm({
2921
2926
  Object.assign(this.notes, notes);
2922
2927
  }
2923
2928
  };
2929
+ describeValue = (value) => Array.isArray(value) ? "array" : value === null ? "null" : typeof value;
2930
+ RESULT_CONTRACT = "return a string report, an object {report?: string, ...} or nothing";
2924
2931
  }
2925
2932
  });
2926
2933
 
@@ -3074,16 +3081,21 @@ var init_worldDir = __esm({
3074
3081
  var hub_exports = {};
3075
3082
  __export(hub_exports, {
3076
3083
  DEFAULT_BRANCH: () => DEFAULT_BRANCH,
3084
+ PushSlugConflict: () => PushSlugConflict,
3085
+ archiveMode: () => archiveMode,
3086
+ buildFileManifest: () => buildFileManifest,
3077
3087
  buildSourceTarball: () => buildSourceTarball,
3078
3088
  collectArchiveRelPaths: () => collectArchiveRelPaths,
3079
3089
  computeContentHash: () => computeContentHash,
3080
3090
  createRef: () => createRef,
3091
+ extractBundle: () => extractBundle,
3081
3092
  localTreeState: () => localTreeState,
3082
3093
  propose: () => propose,
3083
3094
  pull: () => pull,
3084
3095
  push: () => push,
3085
3096
  pushSlug: () => pushSlug,
3086
3097
  readLocalMeta: () => readLocalMeta,
3098
+ resolvePushSlug: () => resolvePushSlug,
3087
3099
  snapshotTreeHashes: () => snapshotTreeHashes,
3088
3100
  writeLocalMeta: () => writeLocalMeta
3089
3101
  });
@@ -3101,12 +3113,18 @@ function computeContentHash(dir) {
3101
3113
  return WorldDir.open(dir).contentHash;
3102
3114
  }
3103
3115
  function octal(value, length) {
3104
- return Buffer.from(value.toString(8).padStart(length - 1, "0") + "\0", "ascii");
3116
+ return Buffer.from(
3117
+ value.toString(8).padStart(length - 1, "0") + "\0",
3118
+ "ascii"
3119
+ );
3105
3120
  }
3106
- function tarHeader(name, size) {
3121
+ function archiveMode(mode) {
3122
+ return (mode & 73) !== 0 ? EXEC_MODE : FILE_MODE;
3123
+ }
3124
+ function tarHeader(name, size, mode = FILE_MODE) {
3107
3125
  const header = Buffer.alloc(512);
3108
3126
  header.write(name, 0, 100, "utf-8");
3109
- octal(420, 8).copy(header, 100);
3127
+ octal(mode, 8).copy(header, 100);
3110
3128
  octal(0, 8).copy(header, 108);
3111
3129
  octal(0, 8).copy(header, 116);
3112
3130
  octal(size, 12).copy(header, 124);
@@ -3120,7 +3138,7 @@ function tarHeader(name, size) {
3120
3138
  header.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, "ascii");
3121
3139
  return header;
3122
3140
  }
3123
- function tarMember(name, payload) {
3141
+ function tarMember(name, payload, mode) {
3124
3142
  const parts = [];
3125
3143
  const nameBytes = Buffer.byteLength(name, "utf-8");
3126
3144
  if (nameBytes > 100) {
@@ -3134,9 +3152,9 @@ function tarMember(name, payload) {
3134
3152
  parts.push(lHeader, body);
3135
3153
  const pad2 = body.length % 512 === 0 ? 0 : 512 - body.length % 512;
3136
3154
  if (pad2) parts.push(Buffer.alloc(pad2));
3137
- parts.push(tarHeader(name.slice(0, 100), payload.length));
3155
+ parts.push(tarHeader(name.slice(0, 100), payload.length, mode));
3138
3156
  } else {
3139
- parts.push(tarHeader(name, payload.length));
3157
+ parts.push(tarHeader(name, payload.length, mode));
3140
3158
  }
3141
3159
  parts.push(payload);
3142
3160
  const pad = payload.length % 512 === 0 ? 0 : 512 - payload.length % 512;
@@ -3146,7 +3164,14 @@ function tarMember(name, payload) {
3146
3164
  function buildSourceTarball(dir) {
3147
3165
  const parts = [];
3148
3166
  for (const relPath of collectArchiveRelPaths(dir)) {
3149
- parts.push(...tarMember(relPath, fs3.readFileSync(path3.join(dir, relPath))));
3167
+ const abs = path3.join(dir, relPath);
3168
+ parts.push(
3169
+ ...tarMember(
3170
+ relPath,
3171
+ fs3.readFileSync(abs),
3172
+ archiveMode(fs3.statSync(abs).mode)
3173
+ )
3174
+ );
3150
3175
  }
3151
3176
  parts.push(Buffer.alloc(1024));
3152
3177
  return (0, import_node_zlib.gzipSync)(Buffer.concat(parts), { level: 9 });
@@ -3161,10 +3186,22 @@ function readLocalMeta(dir) {
3161
3186
  }
3162
3187
  }
3163
3188
  function pushSlug(dir, explicit) {
3164
- if (explicit) return explicit;
3189
+ return resolvePushSlug(dir, { explicit }).slug;
3190
+ }
3191
+ function resolvePushSlug(dir, opts = {}) {
3165
3192
  const meta = readLocalMeta(dir);
3166
- if (typeof meta?.slug === "string" && meta.slug) return meta.slug;
3167
- return readPyproject(dir).name ?? path3.basename(path3.resolve(dir));
3193
+ const tracked = typeof meta?.slug === "string" && meta.slug ? meta.slug : null;
3194
+ const declared = Object.entries({ ...opts.declared ?? {}, "pyproject.toml": readPyproject(dir).name }).filter((entry) => typeof entry[1] === "string" && entry[1] !== "").map(([source, slug]) => ({ source, slug }));
3195
+ const base = { tracked, declared, conflict: null };
3196
+ if (opts.explicit) return { ...base, slug: opts.explicit, source: "--slug" };
3197
+ if (tracked) {
3198
+ const minted = (d) => tracked.startsWith(d.slug) && MINTED_SUFFIX.test(tracked.slice(d.slug.length));
3199
+ const conflict = declared.find((d) => d.slug !== tracked && !minted(d)) ?? null;
3200
+ return { ...base, slug: tracked, source: ".gateway metadata", conflict };
3201
+ }
3202
+ const first = declared[0];
3203
+ if (first) return { ...base, slug: first.slug, source: first.source };
3204
+ return { ...base, slug: path3.basename(path3.resolve(dir)), source: "directory name" };
3168
3205
  }
3169
3206
  function writeLocalMeta(dir, meta) {
3170
3207
  fs3.mkdirSync(path3.join(dir, ".gateway"), { recursive: true });
@@ -3203,7 +3240,9 @@ function readPyproject(dir) {
3203
3240
  function readWorldContractVersion(dir) {
3204
3241
  const world = WorldDir.open(dir);
3205
3242
  try {
3206
- const parsed = JSON.parse(world.text(world.worldPath("schema/world.json")) ?? "");
3243
+ const parsed = JSON.parse(
3244
+ world.text(world.worldPath("schema/world.json")) ?? ""
3245
+ );
3207
3246
  const pkg = parsed["x-gateway"]?.package;
3208
3247
  if (pkg?.version) return { name: pkg.id, version: pkg.version };
3209
3248
  } catch {
@@ -3211,28 +3250,15 @@ function readWorldContractVersion(dir) {
3211
3250
  return {};
3212
3251
  }
3213
3252
  function buildFileManifest(dir) {
3214
- const entries = [];
3215
- const walk = (rel) => {
3216
- const abs = rel ? path3.join(dir, rel) : dir;
3217
- for (const entry of fs3.readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
3218
- const childRel = rel ? `${rel}/${entry.name}` : entry.name;
3219
- if (entry.isDirectory()) {
3220
- if (!SKIP_DIRS.has(entry.name) && !entry.name.endsWith(".egg-info")) {
3221
- walk(childRel);
3222
- }
3223
- } else if (entry.isFile()) {
3224
- const payload = fs3.readFileSync(path3.join(dir, childRel));
3225
- entries.push({
3226
- path: childRel,
3227
- isDirectory: false,
3228
- size: payload.length,
3229
- sha256: (0, import_node_crypto5.createHash)("sha256").update(payload).digest("hex")
3230
- });
3231
- }
3232
- }
3233
- };
3234
- walk("");
3235
- return entries;
3253
+ return collectArchiveRelPaths(dir).map((relPath) => {
3254
+ const payload = fs3.readFileSync(path3.join(dir, relPath));
3255
+ return {
3256
+ path: relPath,
3257
+ isDirectory: false,
3258
+ size: payload.length,
3259
+ sha256: (0, import_node_crypto5.createHash)("sha256").update(payload).digest("hex")
3260
+ };
3261
+ });
3236
3262
  }
3237
3263
  async function putObject(url, data, shaB64) {
3238
3264
  const resp = await fetch(url, {
@@ -3244,22 +3270,30 @@ async function putObject(url, data, shaB64) {
3244
3270
  body: new Uint8Array(data)
3245
3271
  });
3246
3272
  if (!resp.ok) {
3247
- throw new Error(`object PUT -> ${resp.status}: ${(await resp.text()).slice(0, 300)}`);
3273
+ throw new Error(
3274
+ `object PUT -> ${resp.status}: ${(await resp.text()).slice(0, 300)}`
3275
+ );
3248
3276
  }
3249
3277
  }
3250
3278
  async function push(dir, opts = {}) {
3251
3279
  const options = opts.options ?? {};
3252
- if (!fs3.statSync(dir).isDirectory()) throw new Error(`Not a directory: ${dir}`);
3280
+ if (!fs3.statSync(dir).isDirectory())
3281
+ throw new Error(`Not a directory: ${dir}`);
3253
3282
  const localMeta = readLocalMeta(dir) ?? {};
3254
3283
  const branch = opts.branch ?? localMeta.branch ?? DEFAULT_BRANCH;
3255
3284
  const baseVersionId = opts.baseVersionId ?? localMeta.versionId ?? null;
3285
+ const fileManifest = buildFileManifest(dir);
3286
+ if (fileManifest.length === 0)
3287
+ throw new Error(
3288
+ `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).`
3289
+ );
3256
3290
  const contentHash = computeContentHash(dir);
3257
3291
  const pyproject = readPyproject(dir);
3258
3292
  const contractVersion = pyproject.version ? void 0 : readWorldContractVersion(dir).version;
3259
3293
  if (contractVersion) pyproject.version = contractVersion;
3260
3294
  const slug = opts.slug ?? localMeta.slug ?? pyproject.name ?? path3.basename(path3.resolve(dir));
3261
3295
  const metadata = {
3262
- name: opts.name ?? pyproject.name ?? slug,
3296
+ ...opts.name !== void 0 ? { name: opts.name } : {},
3263
3297
  ...opts.description !== void 0 ? { description: opts.description } : {},
3264
3298
  ...opts.tags !== void 0 ? { tags: opts.tags } : {},
3265
3299
  ...opts.visibility ? { visibility: opts.visibility } : {}
@@ -3279,7 +3313,7 @@ async function push(dir, opts = {}) {
3279
3313
  bundleSizeBytes: tarball.length,
3280
3314
  ...pyproject.version ? { semanticVersion: pyproject.version } : {},
3281
3315
  pyprojectMeta: pyproject,
3282
- fileManifest: buildFileManifest(dir),
3316
+ fileManifest,
3283
3317
  branch,
3284
3318
  baseVersionId,
3285
3319
  ...opts.force ? { force: true } : {},
@@ -3287,12 +3321,18 @@ async function push(dir, opts = {}) {
3287
3321
  ...opts.author ? { author: opts.author } : {},
3288
3322
  ...opts.imageRef ? { imageRef: opts.imageRef } : {}
3289
3323
  });
3290
- if (version.uploadUrl) await putObject(version.uploadUrl, tarball, bundleSha256);
3324
+ if (version.uploadUrl)
3325
+ await putObject(version.uploadUrl, tarball, bundleSha256);
3291
3326
  const final = await apiRequest(
3292
3327
  options,
3293
3328
  "POST",
3294
3329
  `/api/public/benchmark-containers/versions/${version.versionId}/finalize`,
3295
- { branch, baseVersionId, ...opts.force ? { force: true } : {}, ...metadata }
3330
+ {
3331
+ branch,
3332
+ baseVersionId,
3333
+ ...opts.force ? { force: true } : {},
3334
+ ...metadata
3335
+ }
3296
3336
  );
3297
3337
  writeLocalMeta(dir, {
3298
3338
  ...localMeta,
@@ -3325,7 +3365,14 @@ function extractBundle(bundle, dir) {
3325
3365
  offset += 512;
3326
3366
  if (header.every((b) => b === 0)) break;
3327
3367
  const rawName = header.subarray(0, 100).toString("utf-8").replace(/\0.*$/, "");
3328
- const size = parseInt(header.subarray(124, 136).toString("ascii").replace(/\0.*$/, "").trim(), 8) || 0;
3368
+ const size = parseInt(
3369
+ header.subarray(124, 136).toString("ascii").replace(/\0.*$/, "").trim(),
3370
+ 8
3371
+ ) || 0;
3372
+ const mode = parseInt(
3373
+ header.subarray(100, 108).toString("ascii").replace(/\0.*$/, "").trim(),
3374
+ 8
3375
+ ) || FILE_MODE;
3329
3376
  const typeflag = header.subarray(156, 157).toString("ascii");
3330
3377
  const body = tar.subarray(offset, offset + size);
3331
3378
  offset += size + (size % 512 === 0 ? 0 : 512 - size % 512);
@@ -3339,7 +3386,8 @@ function extractBundle(bundle, dir) {
3339
3386
  if (name.startsWith("/") || name.split("/").includes("..")) continue;
3340
3387
  const target = path3.join(dir, name);
3341
3388
  fs3.mkdirSync(path3.dirname(target), { recursive: true });
3342
- fs3.writeFileSync(target, body);
3389
+ fs3.writeFileSync(target, body, { mode: archiveMode(mode) });
3390
+ fs3.chmodSync(target, archiveMode(mode));
3343
3391
  written++;
3344
3392
  }
3345
3393
  return written;
@@ -3386,13 +3434,17 @@ async function pull(slugRef, target, options = {}) {
3386
3434
  async function propose(dir, opts) {
3387
3435
  const meta = readLocalMeta(dir);
3388
3436
  if (!meta?.slug || !meta.baseFiles) {
3389
- throw new Error("This dir has no pull/push base \u2014 run pull first, then edit, then propose.");
3437
+ throw new Error(
3438
+ "This dir has no pull/push base \u2014 run pull first, then edit, then propose."
3439
+ );
3390
3440
  }
3391
3441
  const state2 = localTreeState(dir);
3392
- if (state2.clean) throw new Error("Nothing to propose \u2014 the tree matches its base.");
3442
+ if (state2.clean)
3443
+ throw new Error("Nothing to propose \u2014 the tree matches its base.");
3393
3444
  const changes = state2.dirty.map((relPath) => {
3394
3445
  const abs = path3.join(dir, relPath);
3395
- if (!fs3.existsSync(abs)) return { path: relPath, action: "delete" };
3446
+ if (!fs3.existsSync(abs))
3447
+ return { path: relPath, action: "delete" };
3396
3448
  return {
3397
3449
  path: relPath,
3398
3450
  action: "write",
@@ -3422,7 +3474,7 @@ async function createRef(slug, name, kind, versionId, options = {}) {
3422
3474
  ...versionId ? { versionId } : {}
3423
3475
  });
3424
3476
  }
3425
- var import_node_crypto5, import_node_zlib, fs3, path3, DEFAULT_BRANCH, META_RELPATH, SKIP_DIRS, sha256b64;
3477
+ var import_node_crypto5, import_node_zlib, fs3, path3, DEFAULT_BRANCH, META_RELPATH, FILE_MODE, EXEC_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64;
3426
3478
  var init_hub = __esm({
3427
3479
  "src/worlds/hub.ts"() {
3428
3480
  "use strict";
@@ -3434,16 +3486,20 @@ var init_hub = __esm({
3434
3486
  init_worldDir();
3435
3487
  DEFAULT_BRANCH = "main";
3436
3488
  META_RELPATH = path3.join(".gateway", ".env-metadata.json");
3437
- SKIP_DIRS = /* @__PURE__ */ new Set([
3438
- ".git",
3439
- "__pycache__",
3440
- "node_modules",
3441
- ".venv",
3442
- ".mypy_cache",
3443
- "dist",
3444
- "build",
3445
- "outputs"
3446
- ]);
3489
+ FILE_MODE = 420;
3490
+ EXEC_MODE = 493;
3491
+ MINTED_SUFFIX = /^-\d+$/;
3492
+ PushSlugConflict = class extends Error {
3493
+ constructor(dir, tracked, declared) {
3494
+ super(
3495
+ `${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.`
3496
+ );
3497
+ this.dir = dir;
3498
+ this.tracked = tracked;
3499
+ this.declared = declared;
3500
+ this.name = "PushSlugConflict";
3501
+ }
3502
+ };
3447
3503
  sha256b64 = (data) => (0, import_node_crypto5.createHash)("sha256").update(data).digest("base64");
3448
3504
  }
3449
3505
  });
@@ -4152,11 +4208,20 @@ var init_router = __esm({
4152
4208
  });
4153
4209
 
4154
4210
  // src/cli/config.ts
4211
+ function transportDetail(error, timeoutMs) {
4212
+ if (error instanceof Error && error.name === "AbortError") return `timed out after ${Math.round(timeoutMs / 1e3)}s`;
4213
+ const cause = error instanceof Error && error.cause instanceof Error ? error.cause : void 0;
4214
+ const code = cause && "code" in cause && typeof cause.code === "string" ? `${cause.code}: ` : "";
4215
+ const message = cause?.message ?? (error instanceof Error ? error.message : String(error));
4216
+ return `${code}${message}`;
4217
+ }
4155
4218
  async function api(creds, method, route, body, init2 = {}) {
4156
4219
  const controller = new AbortController();
4157
- const timer = setTimeout(() => controller.abort(), init2.timeoutMs ?? 12e4);
4220
+ const timeoutMs = init2.timeoutMs ?? 12e4;
4221
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
4222
+ let res;
4158
4223
  try {
4159
- const res = await fetch(`${creds.host}${route}`, {
4224
+ res = await fetch(`${creds.host}${route}`, {
4160
4225
  method,
4161
4226
  headers: {
4162
4227
  "content-type": "application/json",
@@ -4166,6 +4231,11 @@ async function api(creds, method, route, body, init2 = {}) {
4166
4231
  ...body === void 0 ? {} : { body: JSON.stringify(body) },
4167
4232
  signal: controller.signal
4168
4233
  });
4234
+ } catch (error) {
4235
+ clearTimeout(timer);
4236
+ throw new UnreachableError(creds.host, method, route, transportDetail(error, timeoutMs));
4237
+ }
4238
+ try {
4169
4239
  const text2 = await res.text();
4170
4240
  if (!res.ok) throw new ApiError(res.status, method, route, text2);
4171
4241
  return text2 ? JSON.parse(text2) : {};
@@ -4173,7 +4243,7 @@ async function api(creds, method, route, body, init2 = {}) {
4173
4243
  clearTimeout(timer);
4174
4244
  }
4175
4245
  }
4176
- var fs4, os, path4, ApiError;
4246
+ var fs4, os, path4, ApiError, UnreachableError;
4177
4247
  var init_config = __esm({
4178
4248
  "src/cli/config.ts"() {
4179
4249
  "use strict";
@@ -4190,6 +4260,15 @@ var init_config = __esm({
4190
4260
  this.text = text2;
4191
4261
  }
4192
4262
  };
4263
+ UnreachableError = class extends CliError {
4264
+ constructor(host, method, route, detail) {
4265
+ super(`${method} ${route}: no answer from ${host} (${detail}). Check the host and the network, then retry.`, 1);
4266
+ this.host = host;
4267
+ this.method = method;
4268
+ this.route = route;
4269
+ this.detail = detail;
4270
+ }
4271
+ };
4193
4272
  }
4194
4273
  });
4195
4274
 
@@ -4403,7 +4482,7 @@ function readWorldFiles(dir, opts = {}) {
4403
4482
  for (const entry of entries) {
4404
4483
  const childRel = rel ? `${rel}/${entry.name}` : entry.name;
4405
4484
  if (entry.isDirectory()) {
4406
- if (!SKIP_DIRS2.has(entry.name)) walk(childRel);
4485
+ if (!SKIP_DIRS.has(entry.name)) walk(childRel);
4407
4486
  } else if (entry.isFile()) {
4408
4487
  if (!opts.buildOutputs && isBuildOutput(childRel)) continue;
4409
4488
  out.push({
@@ -4446,7 +4525,7 @@ function pruneEmptyDirs(root) {
4446
4525
  for (const entry of fs6.readdirSync(abs, { withFileTypes: true })) {
4447
4526
  const child = path6.join(abs, entry.name);
4448
4527
  if (entry.isDirectory()) {
4449
- if (SKIP_DIRS2.has(entry.name)) {
4528
+ if (SKIP_DIRS.has(entry.name)) {
4450
4529
  empty = false;
4451
4530
  continue;
4452
4531
  }
@@ -4514,7 +4593,7 @@ async function runtime(creds, request, opts = {}) {
4514
4593
  clearTimeout(timer);
4515
4594
  }
4516
4595
  }
4517
- var fs6, path6, SKIP_DIRS2, BUILD_OUTPUT, BridgeRejected;
4596
+ var fs6, path6, SKIP_DIRS, BUILD_OUTPUT, BridgeRejected;
4518
4597
  var init_client = __esm({
4519
4598
  "src/cli/runtime/client.ts"() {
4520
4599
  "use strict";
@@ -4522,7 +4601,7 @@ var init_client = __esm({
4522
4601
  path6 = __toESM(require("path"));
4523
4602
  init_router();
4524
4603
  init_local();
4525
- SKIP_DIRS2 = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
4604
+ SKIP_DIRS = /* @__PURE__ */ new Set(["__pycache__", ".git", "node_modules", ".gateway"]);
4526
4605
  BUILD_OUTPUT = /(^|\/)state\.(sqlite|json)$/;
4527
4606
  BridgeRejected = class extends CliError {
4528
4607
  constructor(detail) {
@@ -4943,7 +5022,12 @@ var init_batches = __esm({
4943
5022
  fs9 = __toESM(require("fs"));
4944
5023
  init_config();
4945
5024
  init_router();
4946
- TERMINAL_STATES = /* @__PURE__ */ new Set(["applied", "refused", "published", "failed"]);
5025
+ TERMINAL_STATES = /* @__PURE__ */ new Set([
5026
+ "applied",
5027
+ "refused",
5028
+ "published",
5029
+ "failed"
5030
+ ]);
4947
5031
  sleepMs = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
4948
5032
  WorldDataApi = class {
4949
5033
  constructor(creds, slug, sleep2 = sleepMs) {
@@ -4957,22 +5041,61 @@ var init_batches = __esm({
4957
5041
  return api(this.creds, "POST", `${this.base}/batches`, body);
4958
5042
  }
4959
5043
  register(batchId, chunk) {
4960
- return api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks`, {
5044
+ return api(
5045
+ this.creds,
5046
+ "POST",
5047
+ `${this.base}/batches/${batchId}/chunks`,
5048
+ {
5049
+ ordinal: chunk.ordinal,
5050
+ digest: chunk.digest,
5051
+ bytes: chunk.bytes,
5052
+ rows: chunk.rows,
5053
+ ...chunk.entity ? { entity: chunk.entity } : {}
5054
+ }
5055
+ );
5056
+ }
5057
+ /**
5058
+ * Stage a project-drive rows file as one chunk, on the platform: the server
5059
+ * streams it out of drive storage into chunk storage and answers with the
5060
+ * digest and gzipped size it derived. No bytes pass through this process.
5061
+ */
5062
+ async stageDrive(batchId, chunk) {
5063
+ const staged = await api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks`, {
4961
5064
  ordinal: chunk.ordinal,
4962
- digest: chunk.digest,
4963
- bytes: chunk.bytes,
4964
- rows: chunk.rows,
5065
+ drive: chunk.path,
4965
5066
  ...chunk.entity ? { entity: chunk.entity } : {}
4966
5067
  });
5068
+ if (!staged.uploaded || !staged.digest || staged.bytes === void 0 || staged.rows === void 0)
5069
+ throw new CliError(
5070
+ `the server staged drive:${chunk.path} as chunk ${chunk.ordinal} without its digest, size and rows`,
5071
+ 1
5072
+ );
5073
+ return {
5074
+ ordinal: chunk.ordinal,
5075
+ digest: staged.digest,
5076
+ bytes: staged.bytes,
5077
+ rows: staged.rows,
5078
+ entity: chunk.entity,
5079
+ chunkId: staged.chunkId,
5080
+ uploaded: true
5081
+ };
4967
5082
  }
4968
5083
  markUploaded(batchId, chunkId) {
4969
- return api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks/${chunkId}/uploaded`);
5084
+ return api(
5085
+ this.creds,
5086
+ "POST",
5087
+ `${this.base}/batches/${batchId}/chunks/${chunkId}/uploaded`
5088
+ );
4970
5089
  }
4971
5090
  complete(batchId) {
4972
5091
  return api(this.creds, "POST", `${this.base}/batches/${batchId}/complete`);
4973
5092
  }
4974
5093
  get(batchId) {
4975
- return api(this.creds, "GET", `${this.base}/batches/${batchId}`);
5094
+ return api(
5095
+ this.creds,
5096
+ "GET",
5097
+ `${this.base}/batches/${batchId}`
5098
+ );
4976
5099
  }
4977
5100
  list(limit, cursor) {
4978
5101
  const params = new URLSearchParams();
@@ -4982,7 +5105,12 @@ var init_batches = __esm({
4982
5105
  return api(this.creds, "GET", `${this.base}/batches${q ? `?${q}` : ""}`);
4983
5106
  }
4984
5107
  publish(message) {
4985
- return api(this.creds, "POST", `${this.base}/publish`, message ? { message } : {});
5108
+ return api(
5109
+ this.creds,
5110
+ "POST",
5111
+ `${this.base}/publish`,
5112
+ message ? { message } : {}
5113
+ );
4986
5114
  }
4987
5115
  /**
4988
5116
  * PUT the gzipped chunk to its presigned URL with exactly the headers the
@@ -4994,11 +5122,23 @@ var init_batches = __esm({
4994
5122
  const delays = [500, 1500, 4e3];
4995
5123
  for (let attempt = 0; ; attempt++) {
4996
5124
  try {
4997
- const res = await fetch(uploadUrl, { method: "PUT", body: new Uint8Array(gz), headers });
5125
+ const res = await fetch(uploadUrl, {
5126
+ method: "PUT",
5127
+ body: new Uint8Array(gz),
5128
+ headers
5129
+ });
4998
5130
  if (res.ok) return;
4999
- if (res.status < 500 || attempt >= delays.length) throw new CliError(`chunk upload -> ${res.status}: ${(await res.text()).slice(0, 300)}`, 1);
5131
+ if (res.status < 500 || attempt >= delays.length)
5132
+ throw new CliError(
5133
+ `chunk upload -> ${res.status}: ${(await res.text()).slice(0, 300)}`,
5134
+ 1
5135
+ );
5000
5136
  } catch (error) {
5001
- if (error instanceof CliError || attempt >= delays.length) throw error instanceof CliError ? error : new CliError(`chunk upload failed: ${error.message}`, 1);
5137
+ if (error instanceof CliError || attempt >= delays.length)
5138
+ throw error instanceof CliError ? error : new CliError(
5139
+ `chunk upload failed: ${error.message}`,
5140
+ 1
5141
+ );
5002
5142
  }
5003
5143
  await this.sleep(delays[attempt]);
5004
5144
  }
@@ -5007,11 +5147,23 @@ var init_batches = __esm({
5007
5147
  async upload(batchId, chunk) {
5008
5148
  const registered = await this.register(batchId, chunk);
5009
5149
  if (!registered.uploaded) {
5010
- if (!registered.uploadUrl) throw new CliError(`the server registered chunk ${chunk.ordinal} without an upload URL`, 1);
5150
+ if (!registered.uploadUrl)
5151
+ throw new CliError(
5152
+ `the server registered chunk ${chunk.ordinal} without an upload URL`,
5153
+ 1
5154
+ );
5011
5155
  await this.put(registered.uploadUrl, chunk.gz, registered.uploadHeaders);
5012
5156
  await this.markUploaded(batchId, registered.chunkId);
5013
5157
  }
5014
- return { ordinal: chunk.ordinal, digest: chunk.digest, bytes: chunk.bytes, rows: chunk.rows, entity: chunk.entity, chunkId: registered.chunkId, uploaded: true };
5158
+ return {
5159
+ ordinal: chunk.ordinal,
5160
+ digest: chunk.digest,
5161
+ bytes: chunk.bytes,
5162
+ rows: chunk.rows,
5163
+ entity: chunk.entity,
5164
+ chunkId: registered.chunkId,
5165
+ uploaded: true
5166
+ };
5015
5167
  }
5016
5168
  };
5017
5169
  }
@@ -5025,14 +5177,20 @@ function chunkLine(row, declared) {
5025
5177
  tagged.set("row", row.row);
5026
5178
  return dumps(tagged) + "\n";
5027
5179
  }
5028
- async function* buildChunks(rows, plan) {
5180
+ async function* buildChunks(rows, plan, ordinalStart = 0) {
5029
5181
  let lines = [];
5030
5182
  let rawBytes = 0;
5031
- let ordinal = 0;
5183
+ let ordinal = ordinalStart;
5032
5184
  let seen = 0;
5033
5185
  const flush2 = () => {
5034
5186
  const raw = Buffer.concat(lines);
5035
- const built = finishChunk(ordinal++, raw, lines.length, plan.entity, seen - lines.length);
5187
+ const built = finishChunk(
5188
+ ordinal++,
5189
+ raw,
5190
+ lines.length,
5191
+ plan.entity,
5192
+ seen - lines.length
5193
+ );
5036
5194
  lines = [];
5037
5195
  rawBytes = 0;
5038
5196
  return built;
@@ -5064,7 +5222,18 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
5064
5222
  function gzipDeterministic(raw, opts = {}) {
5065
5223
  const level = opts.level ?? GZIP_LEVEL;
5066
5224
  const name = opts.name ? Buffer.concat([Buffer.from(opts.name, "latin1"), Buffer.from([0])]) : Buffer.alloc(0);
5067
- const header = Buffer.from([31, 139, 8, opts.name ? 8 : 0, 0, 0, 0, 0, level === 9 ? 2 : level === 1 ? 4 : 0, 255]);
5225
+ const header = Buffer.from([
5226
+ 31,
5227
+ 139,
5228
+ 8,
5229
+ opts.name ? 8 : 0,
5230
+ 0,
5231
+ 0,
5232
+ 0,
5233
+ 0,
5234
+ level === 9 ? 2 : level === 1 ? 4 : 0,
5235
+ 255
5236
+ ]);
5068
5237
  const body = (0, import_node_zlib2.deflateRawSync)(raw, { level });
5069
5238
  const trailer = Buffer.alloc(8);
5070
5239
  trailer.writeUInt32LE(crc32(raw), 0);
@@ -5081,7 +5250,8 @@ function crc32(data) {
5081
5250
  }
5082
5251
  }
5083
5252
  let crc = 4294967295;
5084
- for (let i = 0; i < data.length; i++) crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
5253
+ for (let i = 0; i < data.length; i++)
5254
+ crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
5085
5255
  return (crc ^ 4294967295) >>> 0;
5086
5256
  }
5087
5257
  var import_node_crypto9, import_node_zlib2, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
@@ -5382,6 +5552,58 @@ var init_ingest = __esm({
5382
5552
  }
5383
5553
  });
5384
5554
 
5555
+ // src/worlds/sandbox.ts
5556
+ function parseSlugRef(slugRef) {
5557
+ const at = slugRef.indexOf("@");
5558
+ if (at === -1) return { slug: slugRef };
5559
+ return { slug: slugRef.slice(0, at), ref: slugRef.slice(at + 1) };
5560
+ }
5561
+ var sid, WorldSandboxClient;
5562
+ var init_sandbox = __esm({
5563
+ "src/worlds/sandbox.ts"() {
5564
+ "use strict";
5565
+ init_worlds();
5566
+ sid = encodeURIComponent;
5567
+ WorldSandboxClient = class {
5568
+ constructor(options = {}) {
5569
+ this.options = options;
5570
+ }
5571
+ open(target) {
5572
+ return apiRequest(this.options, "POST", "/api/public/benchmark-containers/sandboxes", target);
5573
+ }
5574
+ status(sandboxId) {
5575
+ return apiRequest(this.options, "GET", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}`);
5576
+ }
5577
+ async read(sandboxId, filePath) {
5578
+ const res = await apiRequest(
5579
+ this.options,
5580
+ "GET",
5581
+ `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/file?path=${encodeURIComponent(filePath)}`
5582
+ );
5583
+ return { path: res.path, size: res.size, bytes: Buffer.from(res.contentBase64, "base64") };
5584
+ }
5585
+ write(sandboxId, filePath, bytes) {
5586
+ return apiRequest(this.options, "PUT", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/file`, {
5587
+ path: filePath,
5588
+ contentBase64: bytes.toString("base64")
5589
+ });
5590
+ }
5591
+ exec(sandboxId, input) {
5592
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/exec`, input);
5593
+ }
5594
+ check(sandboxId) {
5595
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/check`, {});
5596
+ }
5597
+ commit(sandboxId, input) {
5598
+ return apiRequest(this.options, "POST", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}/commit`, input);
5599
+ }
5600
+ close(sandboxId) {
5601
+ return apiRequest(this.options, "DELETE", `/api/public/benchmark-containers/sandboxes/${sid(sandboxId)}`);
5602
+ }
5603
+ };
5604
+ }
5605
+ });
5606
+
5385
5607
  // src/worlds/index.ts
5386
5608
  var worlds_exports = {};
5387
5609
  __export(worlds_exports, {
@@ -5394,6 +5616,7 @@ __export(worlds_exports, {
5394
5616
  EVENT_FLUSH_INTERVAL_MS: () => EVENT_FLUSH_INTERVAL_MS,
5395
5617
  EVENT_MAX_RETRIES: () => EVENT_MAX_RETRIES,
5396
5618
  GatewayEvalsClient: () => GatewayEvalsClient,
5619
+ PushSlugConflict: () => PushSlugConflict,
5397
5620
  STRIP_PREFIX: () => STRIP_PREFIX,
5398
5621
  SURFACE_KINDS: () => SURFACE_KINDS,
5399
5622
  TRANSFORMS: () => TRANSFORMS,
@@ -5401,6 +5624,7 @@ __export(worlds_exports, {
5401
5624
  TaskSessions: () => TaskSessions,
5402
5625
  WHITESPACE: () => WHITESPACE,
5403
5626
  WorldBrowser: () => WorldBrowser,
5627
+ WorldSandboxClient: () => WorldSandboxClient,
5404
5628
  WorldSession: () => WorldSession,
5405
5629
  WorldSessionCallError: () => WorldSessionCallError,
5406
5630
  WorldSessionTimeout: () => WorldSessionTimeout,
@@ -5410,9 +5634,11 @@ __export(worlds_exports, {
5410
5634
  aggregateTaskGrade: () => aggregateTaskGrade,
5411
5635
  apiRequest: () => apiRequest,
5412
5636
  applyTransforms: () => applyTransforms,
5637
+ archiveMode: () => archiveMode,
5413
5638
  attachManifest: () => attachManifest,
5414
5639
  attachSession: () => attachSession,
5415
5640
  attachTask: () => attachTask,
5641
+ buildFileManifest: () => buildFileManifest,
5416
5642
  buildSourceTarball: () => buildSourceTarball,
5417
5643
  captureToolCalls: () => captureToolCalls,
5418
5644
  collectArchiveRelPaths: () => collectArchiveRelPaths,
@@ -5424,6 +5650,7 @@ __export(worlds_exports, {
5424
5650
  deleteTask: () => deleteTask,
5425
5651
  describeWorld: () => describeWorld,
5426
5652
  detectProvenance: () => detectProvenance,
5653
+ extractBundle: () => extractBundle,
5427
5654
  getRun: () => getRun,
5428
5655
  getTask: () => getTask,
5429
5656
  hashForm: () => hashForm,
@@ -5444,6 +5671,8 @@ __export(worlds_exports, {
5444
5671
  openSession: () => openSession,
5445
5672
  openTask: () => openTask,
5446
5673
  openWorld: () => openWorld,
5674
+ openWorldVersion: () => openWorldVersion,
5675
+ parseSlugRef: () => parseSlugRef,
5447
5676
  parseToolCallRecord: () => parseToolCallRecord,
5448
5677
  parseTransform: () => parseTransform,
5449
5678
  parseWorldTaskRefs: () => parseWorldTaskRefs,
@@ -5460,6 +5689,7 @@ __export(worlds_exports, {
5460
5689
  redactActionArgs: () => redactActionArgs,
5461
5690
  redactionOf: () => redactionOf,
5462
5691
  resolveBrowserMode: () => resolveBrowserMode,
5692
+ resolvePushSlug: () => resolvePushSlug,
5463
5693
  roundForm: () => roundForm,
5464
5694
  runSessions: () => runSessions,
5465
5695
  runTask: () => runTask,
@@ -5635,9 +5865,21 @@ async function openWorld(slugRef, options = {}) {
5635
5865
  const at = slugRef.indexOf("@");
5636
5866
  const slug = at === -1 ? slugRef : slugRef.slice(0, at);
5637
5867
  const ref = at === -1 ? null : slugRef.slice(at + 1);
5868
+ return resolveWorld(slugRef, slug, ref, ref ? { ref } : {}, options);
5869
+ }
5870
+ async function openWorldVersion(slug, versionId, options = {}) {
5871
+ return resolveWorld(
5872
+ `${slug}@${versionId}`,
5873
+ slug,
5874
+ null,
5875
+ { versionId },
5876
+ options
5877
+ );
5878
+ }
5879
+ async function resolveWorld(slugRef, slug, ref, pin, options) {
5638
5880
  const version = await apiRequest(options, "POST", "/api/public/benchmark-containers/resolve-version", {
5639
5881
  slug,
5640
- ...ref ? { ref } : {}
5882
+ ...pin
5641
5883
  });
5642
5884
  const world = new WorldSet(
5643
5885
  slugRef,
@@ -5675,6 +5917,7 @@ var init_worlds = __esm({
5675
5917
  init_query();
5676
5918
  init_migrate();
5677
5919
  init_ingest();
5920
+ init_sandbox();
5678
5921
  ApiError2 = class extends Error {
5679
5922
  constructor(status, method, path10, body) {
5680
5923
  super(`${method} ${path10} -> ${status}: ${body}`);
@@ -5758,6 +6001,7 @@ init_worlds();
5758
6001
  EVENT_FLUSH_INTERVAL_MS,
5759
6002
  EVENT_MAX_RETRIES,
5760
6003
  GatewayEvalsClient,
6004
+ PushSlugConflict,
5761
6005
  STRIP_PREFIX,
5762
6006
  SURFACE_KINDS,
5763
6007
  TRANSFORMS,
@@ -5765,6 +6009,7 @@ init_worlds();
5765
6009
  TaskSessions,
5766
6010
  WHITESPACE,
5767
6011
  WorldBrowser,
6012
+ WorldSandboxClient,
5768
6013
  WorldSession,
5769
6014
  WorldSessionCallError,
5770
6015
  WorldSessionTimeout,
@@ -5774,9 +6019,11 @@ init_worlds();
5774
6019
  aggregateTaskGrade,
5775
6020
  apiRequest,
5776
6021
  applyTransforms,
6022
+ archiveMode,
5777
6023
  attachManifest,
5778
6024
  attachSession,
5779
6025
  attachTask,
6026
+ buildFileManifest,
5780
6027
  buildSourceTarball,
5781
6028
  captureToolCalls,
5782
6029
  collectArchiveRelPaths,
@@ -5788,6 +6035,7 @@ init_worlds();
5788
6035
  deleteTask,
5789
6036
  describeWorld,
5790
6037
  detectProvenance,
6038
+ extractBundle,
5791
6039
  getRun,
5792
6040
  getTask,
5793
6041
  hashForm,
@@ -5808,6 +6056,8 @@ init_worlds();
5808
6056
  openSession,
5809
6057
  openTask,
5810
6058
  openWorld,
6059
+ openWorldVersion,
6060
+ parseSlugRef,
5811
6061
  parseToolCallRecord,
5812
6062
  parseTransform,
5813
6063
  parseWorldTaskRefs,
@@ -5824,6 +6074,7 @@ init_worlds();
5824
6074
  redactActionArgs,
5825
6075
  redactionOf,
5826
6076
  resolveBrowserMode,
6077
+ resolvePushSlug,
5827
6078
  roundForm,
5828
6079
  runSessions,
5829
6080
  runTask,