@withgateway/sdk 0.3.3 → 0.6.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.
Files changed (158) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +3005 -1401
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +2996 -1392
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.js +128 -37
  7. package/dist/files/index.js.map +1 -1
  8. package/dist/files/index.mjs +126 -35
  9. package/dist/files/index.mjs.map +1 -1
  10. package/dist/hooks/index.d.mts +1 -1
  11. package/dist/hooks/index.d.ts +1 -1
  12. package/dist/hooks/index.js +124 -11
  13. package/dist/hooks/index.js.map +1 -1
  14. package/dist/hooks/index.mjs +124 -11
  15. package/dist/hooks/index.mjs.map +1 -1
  16. package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
  17. package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
  18. package/dist/{index-mJhG3vZU.d.mts → index-Di9nNqOY.d.mts} +26 -3
  19. package/dist/{index-DUHmS74p.d.ts → index-LA-PMRJT.d.ts} +26 -3
  20. package/dist/index.d.mts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +1078 -260
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +1040 -251
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/replay/index.d.mts +1 -1
  27. package/dist/replay/index.d.ts +1 -1
  28. package/dist/replay/index.js.map +1 -1
  29. package/dist/replay/index.mjs.map +1 -1
  30. package/dist/traces/index.js +125 -34
  31. package/dist/traces/index.js.map +1 -1
  32. package/dist/traces/index.mjs +123 -32
  33. package/dist/traces/index.mjs.map +1 -1
  34. package/dist/tracing/index.d.mts +1 -1
  35. package/dist/tracing/index.d.ts +1 -1
  36. package/dist/tracing/index.js +7 -1
  37. package/dist/tracing/index.js.map +1 -1
  38. package/dist/tracing/index.mjs +7 -1
  39. package/dist/tracing/index.mjs.map +1 -1
  40. package/dist/worlds/index.d.mts +819 -438
  41. package/dist/worlds/index.d.ts +819 -438
  42. package/dist/worlds/index.js +912 -236
  43. package/dist/worlds/index.js.map +1 -1
  44. package/dist/worlds/index.mjs +908 -232
  45. package/dist/worlds/index.mjs.map +1 -1
  46. package/package.json +1 -1
  47. package/runtime/gatewaysdk/environment/_bundle.py +4 -6
  48. package/runtime/gatewaysdk/environment/_materialize.py +5 -25
  49. package/runtime/gatewaysdk/environment/_world.py +82 -66
  50. package/runtime/gatewaysdk/environment/backing.py +20 -24
  51. package/runtime/gatewaysdk/environment/core.py +1 -16
  52. package/runtime/gatewaysdk/environment/legacy_sqlite.py +14 -27
  53. package/runtime/gatewaysdk/environment/runtime.py +45 -2
  54. package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
  55. package/runtime/gatewaysdk/environment/schema/api.py +198 -474
  56. package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
  57. package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
  58. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
  59. package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
  60. package/runtime/gatewaysdk/environment/schema/call_capture.py +321 -0
  61. package/runtime/gatewaysdk/environment/schema/call_log.py +276 -18
  62. package/runtime/gatewaysdk/environment/schema/call_redaction.py +207 -19
  63. package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
  64. package/runtime/gatewaysdk/environment/schema/compiler.py +4 -1
  65. package/runtime/gatewaysdk/environment/schema/conform.py +38 -35
  66. package/runtime/gatewaysdk/environment/schema/connector.py +94 -152
  67. package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
  68. package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +2 -1
  69. package/runtime/gatewaysdk/environment/schema/connectors/github/api/handlers.py +217 -58
  70. package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +10 -19
  71. package/runtime/gatewaysdk/environment/schema/connectors/github/scenarios/default/seed/github_webhooks.json +10 -2
  72. package/runtime/gatewaysdk/environment/schema/connectors/github/tests/webhooks.json +47 -0
  73. package/runtime/gatewaysdk/environment/schema/connectors/github/world.json +21 -0
  74. package/runtime/gatewaysdk/environment/schema/connectors/jamf/api/handlers.py +185 -18
  75. package/runtime/gatewaysdk/environment/schema/connectors/jamf/connector.toml +29 -14
  76. package/runtime/gatewaysdk/environment/schema/connectors/jamf/provenance.json +43 -12
  77. package/runtime/gatewaysdk/environment/schema/connectors/jamf/scenarios/default/seed/jamf_webhooks.json +2 -2
  78. package/runtime/gatewaysdk/environment/schema/connectors/jamf/scope.toml +4 -17
  79. package/runtime/gatewaysdk/environment/schema/connectors/jamf/tests/webhooks.json +107 -0
  80. package/runtime/gatewaysdk/environment/schema/connectors/jamf/vendor-openapi.json +1 -1
  81. package/runtime/gatewaysdk/environment/schema/connectors/linear/api/handlers.py +85 -1
  82. package/runtime/gatewaysdk/environment/schema/connectors/linear/connector.toml +19 -31
  83. package/runtime/gatewaysdk/environment/schema/connectors/linear/provenance.json +18 -8
  84. package/runtime/gatewaysdk/environment/schema/connectors/linear/scenarios/default/seed/webhooks.json +19 -3
  85. package/runtime/gatewaysdk/environment/schema/connectors/linear/tests/test_webhooks.py +71 -0
  86. package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
  87. package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
  88. package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
  89. package/runtime/gatewaysdk/environment/schema/data.py +14 -13
  90. package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
  91. package/runtime/gatewaysdk/environment/schema/database/guard.py +45 -37
  92. package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
  93. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +57 -31
  94. package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
  95. package/runtime/gatewaysdk/environment/schema/door.py +899 -0
  96. package/runtime/gatewaysdk/environment/schema/envelope.py +86 -28
  97. package/runtime/gatewaysdk/environment/schema/grading.py +58 -86
  98. package/runtime/gatewaysdk/environment/schema/handler_errors.py +52 -5
  99. package/runtime/gatewaysdk/environment/schema/host.py +229 -1695
  100. package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
  101. package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
  102. package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
  103. package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
  104. package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
  105. package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
  106. package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
  107. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
  108. package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
  109. package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
  110. package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
  111. package/runtime/gatewaysdk/environment/schema/journal.py +438 -0
  112. package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
  113. package/runtime/gatewaysdk/environment/schema/local.py +32 -116
  114. package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +20 -5
  115. package/runtime/gatewaysdk/environment/schema/platform.py +29 -234
  116. package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
  117. package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
  118. package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
  119. package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
  120. package/runtime/gatewaysdk/environment/schema/runtime.py +136 -176
  121. package/runtime/gatewaysdk/environment/schema/scaffold.py +2 -1
  122. package/runtime/gatewaysdk/environment/schema/session_files.py +133 -24
  123. package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
  124. package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
  125. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +8 -9
  126. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +3 -3
  127. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +50 -28
  128. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
  129. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +20 -22
  130. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +25 -25
  131. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
  132. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +71 -7
  133. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
  134. package/runtime/gatewaysdk/environment/schema/snapshot.py +150 -30
  135. package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
  136. package/runtime/gatewaysdk/environment/schema/tasks.py +229 -323
  137. package/runtime/gatewaysdk/environment/schema/tools_world.py +103 -203
  138. package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
  139. package/runtime/gatewaysdk/environment/schema/verbs.py +38 -36
  140. package/runtime/gatewaysdk/environment/schema/webhooks.py +687 -0
  141. package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
  142. package/runtime/gatewaysdk/environment/schema/workers.py +203 -39
  143. package/runtime/gatewaysdk/environment/schema/world_host.py +970 -0
  144. package/runtime/gatewaysdk/environment/schema/world_tests.py +83 -11
  145. package/runtime/gatewaysdk/environment/world.py +1 -1
  146. package/runtime/gatewaysdk/environment/world_session_contract.py +14 -0
  147. package/skills/agents/connector-template-author.md +5 -1
  148. package/skills/benchmarks-getting-started/SKILL.md +8 -9
  149. package/skills/connector-schema-authoring/CONNECTORS.md +3 -3
  150. package/skills/connector-schema-authoring/SKILL.md +50 -28
  151. package/skills/connector-schema-authoring/connector-worlds.md +282 -18
  152. package/skills/connector-schema-authoring/world-schema.md +7 -6
  153. package/skills/world-data-ingestion/ROWS.md +12 -8
  154. package/skills/world-data-ingestion/SKILL.md +20 -22
  155. package/skills/worlds-getting-started/SKILL.md +25 -25
  156. package/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
  157. package/skills/worlds-getting-started/references/gotchas.md +71 -7
  158. package/skills/worlds-getting-started/references/journal-checks.md +182 -0
package/dist/index.js CHANGED
@@ -494,7 +494,7 @@ function platformTimeoutMs(env = process.env) {
494
494
  if (Number.isInteger(value) && value > 0) return value;
495
495
  throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
496
496
  }
497
- var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep2, RetryPolicy, Attempt, PlatformTransport;
497
+ var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, FETCH_LIMIT, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep2, RetryPolicy, Attempt, PlatformTransport;
498
498
  var init_transport = __esm({
499
499
  "src/worlds/transport.ts"() {
500
500
  "use strict";
@@ -502,7 +502,13 @@ var init_transport = __esm({
502
502
  PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
503
503
  CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
504
504
  RETRY = "Retry; if it repeats, check the network between here and the platform.";
505
+ FETCH_LIMIT = {
506
+ reason: "Node's fetch stopped waiting after 300 s",
507
+ next: "The platform may still be running it: check what it changed before you retry."
508
+ };
505
509
  CAUSES = {
510
+ UND_ERR_HEADERS_TIMEOUT: FETCH_LIMIT,
511
+ UND_ERR_BODY_TIMEOUT: FETCH_LIMIT,
506
512
  ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
507
513
  ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
508
514
  EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
@@ -543,11 +549,11 @@ var init_transport = __esm({
543
549
  }
544
550
  };
545
551
  UnreachableError = class extends Error {
546
- constructor(host, method, route, failure) {
547
- super(`${method} ${route}: no answer from ${host}: ${failure.describe()}. ${failure.next}`);
552
+ constructor(host, method, route2, failure) {
553
+ super(`${method} ${route2}: no answer from ${host}: ${failure.describe()}. ${failure.next}`);
548
554
  this.host = host;
549
555
  this.method = method;
550
- this.route = route;
556
+ this.route = route2;
551
557
  this.failure = failure;
552
558
  this.name = "UnreachableError";
553
559
  }
@@ -617,16 +623,16 @@ var init_transport = __esm({
617
623
  budget(ownMs) {
618
624
  return Math.max(ownMs ?? 0, this.timeoutMs);
619
625
  }
620
- async send(method, route, body, opts = {}) {
626
+ async send(method, route2, body, opts = {}) {
621
627
  const timeoutMs = this.budget(opts.timeoutMs);
622
- return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route, body, timeoutMs));
628
+ return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route2, body, timeoutMs));
623
629
  }
624
- async once(method, route, body, timeoutMs) {
630
+ async once(method, route2, body, timeoutMs) {
625
631
  const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
626
632
  const controller = new AbortController();
627
633
  const timer = setTimeout(() => controller.abort(), timeoutMs);
628
634
  try {
629
- const res = await fetch(`${this.endpoint.host}${route}`, {
635
+ const res = await fetch(`${this.endpoint.host}${route2}`, {
630
636
  method,
631
637
  headers: {
632
638
  "content-type": "application/json",
@@ -639,7 +645,7 @@ var init_transport = __esm({
639
645
  return { status: res.status, ok: res.ok, text: await res.text() };
640
646
  } catch (error) {
641
647
  const cause = controller.signal.aborted ? TransportCause.timeout(timeoutMs) : TransportCause.of(error);
642
- throw new UnreachableError(this.endpoint.host, method, route, cause);
648
+ throw new UnreachableError(this.endpoint.host, method, route2, cause);
643
649
  } finally {
644
650
  clearTimeout(timer);
645
651
  }
@@ -802,6 +808,12 @@ var init_browserReconnect = __esm({
802
808
  });
803
809
 
804
810
  // src/worlds/browser.ts
811
+ function assertSessionAuthMode(value) {
812
+ if (SESSION_AUTH_MODES.includes(value)) return;
813
+ throw new Error(
814
+ `Unknown session auth: ${String(value)}; choose from ${SESSION_AUTH_MODES.join(", ")}`
815
+ );
816
+ }
805
817
  function assertBrowserTier(value) {
806
818
  if (BROWSER_TIERS.includes(value)) return;
807
819
  throw new Error(
@@ -838,6 +850,15 @@ function splitHash(url) {
838
850
  const h = url.indexOf("#");
839
851
  return h < 0 ? [url, ""] : [url.slice(0, h), url.slice(h)];
840
852
  }
853
+ function capabilityLabel(url) {
854
+ let host = "";
855
+ try {
856
+ host = url ? new URL(url).hostname : "";
857
+ } catch {
858
+ return null;
859
+ }
860
+ return CAPABILITY_HOST.exec(host)?.[1] ?? null;
861
+ }
841
862
  function redactActionArgs(action, args) {
842
863
  const secretField = action === "browser_type" && SECRET_KEY.test(String(args.selector ?? ""));
843
864
  const out = {};
@@ -897,7 +918,9 @@ async function openBrowser(surfaces, opts = {}) {
897
918
  };
898
919
  const scrubber = new SecretScrubber([
899
920
  surfaces.browser?.wsUrl,
900
- surfaces.ui?.token
921
+ surfaces.ui?.token,
922
+ capabilityLabel(surfaces.ui?.url),
923
+ capabilityLabel(surfaces.api?.url)
901
924
  ]);
902
925
  const reconnector = mode === "hosted" && surfaces.browser.protocol === "cdp" && opts.repair ? new BrowserReconnector(opts.repair, reattach, {
903
926
  scrub: (text2) => scrubber.scrub(text2)
@@ -962,13 +985,15 @@ function computerUseToolkit(browser, opts = {}) {
962
985
  specs
963
986
  };
964
987
  }
965
- var SURFACE_KINDS, BROWSER_TIERS, DEFAULT_VIEWPORT, SETTLE_TIMEOUT_MS, SETTLE_QUIET_MS, SETTLE_POLL_MS, EVENT_BATCH_SIZE, EVENT_FLUSH_INTERVAL_MS, EVENT_MAX_RETRIES, EVENT_SCREENSHOT_QUALITY, EVENT_MAX_STRING, SECRET_KEY, SECRET_VALUE, WorldSurfaceUnavailable, UI_TOKEN_QUERY, BrowserActionRecorder, WorldBrowser, COMPUTER_USE_SPECS, str;
988
+ var SURFACE_KINDS, PLATFORM_SESSION_HEADER, SESSION_AUTH_MODES, BROWSER_TIERS, DEFAULT_VIEWPORT, SETTLE_TIMEOUT_MS, SETTLE_QUIET_MS, SETTLE_POLL_MS, EVENT_BATCH_SIZE, EVENT_FLUSH_INTERVAL_MS, EVENT_MAX_RETRIES, EVENT_SCREENSHOT_QUALITY, EVENT_MAX_STRING, SECRET_KEY, SECRET_VALUE, WorldSurfaceUnavailable, UI_TOKEN_QUERY, CAPABILITY_HOST, BrowserActionRecorder, WorldBrowser, COMPUTER_USE_SPECS, str;
966
989
  var init_browser = __esm({
967
990
  "src/worlds/browser.ts"() {
968
991
  "use strict";
969
992
  init_session2();
970
993
  init_browserReconnect();
971
994
  SURFACE_KINDS = ["tools", "api", "ui", "browser"];
995
+ PLATFORM_SESSION_HEADER = "X-World-Session";
996
+ SESSION_AUTH_MODES = ["vendor", "open"];
972
997
  BROWSER_TIERS = ["standard", "premium"];
973
998
  DEFAULT_VIEWPORT = { width: 1280, height: 800 };
974
999
  SETTLE_TIMEOUT_MS = 5e3;
@@ -989,6 +1014,7 @@ var init_browser = __esm({
989
1014
  surface;
990
1015
  };
991
1016
  UI_TOKEN_QUERY = "token";
1017
+ CAPABILITY_HOST = /^o-[a-z0-9]+-([a-z2-7]{26})(?:-api)?\./;
992
1018
  BrowserActionRecorder = class {
993
1019
  constructor(post, agentId, opts = {}) {
994
1020
  this.post = post;
@@ -1081,7 +1107,10 @@ var init_browser = __esm({
1081
1107
  }
1082
1108
  };
1083
1109
  WorldBrowser = class {
1084
- constructor(page, ui, mode, teardown, viewport = DEFAULT_VIEWPORT, recorder = null, reconnector = null, scrubber = new SecretScrubber([ui?.token])) {
1110
+ constructor(page, ui, mode, teardown, viewport = DEFAULT_VIEWPORT, recorder = null, reconnector = null, scrubber = new SecretScrubber([
1111
+ ui?.token,
1112
+ capabilityLabel(ui?.url)
1113
+ ])) {
1085
1114
  this.ui = ui;
1086
1115
  this.mode = mode;
1087
1116
  this.teardown = teardown;
@@ -1218,7 +1247,15 @@ var init_browser = __esm({
1218
1247
  seq: recorder.nextSeq(),
1219
1248
  ts: (/* @__PURE__ */ new Date()).toISOString(),
1220
1249
  action,
1221
- args: redactActionArgs(action, args),
1250
+ args: redactActionArgs(
1251
+ action,
1252
+ Object.fromEntries(
1253
+ Object.entries(args).map(([key2, value]) => [
1254
+ key2,
1255
+ typeof value === "string" ? this.scrubber.scrub(value) : value
1256
+ ])
1257
+ )
1258
+ ),
1222
1259
  ok: failure === null,
1223
1260
  error,
1224
1261
  durationMs: Date.now() - started,
@@ -1234,8 +1271,8 @@ var init_browser = __esm({
1234
1271
  screenshot: null
1235
1272
  };
1236
1273
  try {
1237
- out.url = this.page.url();
1238
- out.title = await this.page.title();
1274
+ out.url = this.scrubber.scrub(this.page.url());
1275
+ out.title = this.scrubber.scrub(await this.page.title());
1239
1276
  const jpeg = await this.page.screenshot({
1240
1277
  type: "jpeg",
1241
1278
  quality: EVENT_SCREENSHOT_QUALITY
@@ -1870,11 +1907,11 @@ var init_media = __esm({
1870
1907
  status
1871
1908
  );
1872
1909
  }
1873
- async send(method, route, body) {
1874
- const reply = await this.transport.send(method, route, body);
1910
+ async send(method, route2, body) {
1911
+ const reply = await this.transport.send(method, route2, body);
1875
1912
  if (!reply.ok)
1876
1913
  throw new MediaUploadError(
1877
- `${method} ${route} -> ${reply.status}`,
1914
+ `${method} ${route2} -> ${reply.status}`,
1878
1915
  reply.status
1879
1916
  );
1880
1917
  return reply.text ? JSON.parse(reply.text) : {};
@@ -2227,7 +2264,7 @@ function click(button, count) {
2227
2264
  modifiers: modifierChord(raw.text)
2228
2265
  });
2229
2266
  }
2230
- var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
2267
+ var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, IMAGE_PARTS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
2231
2268
  var init_anthropic = __esm({
2232
2269
  "src/worlds/nativeComputer/anthropic.ts"() {
2233
2270
  "use strict";
@@ -2243,6 +2280,14 @@ var init_anthropic = __esm({
2243
2280
  left: [-1, 0],
2244
2281
  right: [1, 0]
2245
2282
  };
2283
+ IMAGE_PARTS = {
2284
+ 6: (data) => ({ type: "image-data", data, mediaType: "image/png" }),
2285
+ 7: (data) => ({
2286
+ type: "file",
2287
+ mediaType: "image/png",
2288
+ data: { type: "data", data }
2289
+ })
2290
+ };
2246
2291
  MEMBERS = {
2247
2292
  screenshot: () => new ComputerAction("screenshot"),
2248
2293
  zoom: (raw) => new ComputerAction("zoom", {
@@ -2352,15 +2397,17 @@ var init_anthropic = __esm({
2352
2397
  ];
2353
2398
  return [{ type: "text", text: result.text ?? "OK" }];
2354
2399
  }
2355
- /** For `anthropic.tools.computerToolset_20260801({ ...computer.aiSdk() })`
2356
- * (or `computer_20251124` with the legacy kind): `execute` runs one action
2357
- * and returns `{ type: "image", data }` or text; `toModelOutput` turns that
2358
- * into the tool result. Calls run one at a time, and once a call fails the
2400
+ /** For `anthropic.tools.computerToolset_20260801(computer.aiSdk({ version: 7 }))`
2401
+ * (AI SDK 7 only), or `computer_20251124` with the legacy kind (AI SDK 6
2402
+ * and 7): `execute` runs one action and returns `{ type: "image", data }` or
2403
+ * text; `toModelOutput` turns that into the tool result in the part shape
2404
+ * of `options.version`. Calls run one at a time, and once a call fails the
2359
2405
  * rest of that step's calls answer as not executed. */
2360
- aiSdk() {
2406
+ aiSdk(options = {}) {
2407
+ const imagePart = _AnthropicComputer.imagePart(options);
2361
2408
  let failedStep;
2362
- const execute = (input, options) => this.serial(async () => {
2363
- const step = options?.messages?.length;
2409
+ const execute = (input, options2) => this.serial(async () => {
2410
+ const step = options2?.messages?.length;
2364
2411
  if (step !== void 0 && step === failedStep)
2365
2412
  throw new Error(NOT_EXECUTED);
2366
2413
  try {
@@ -2372,7 +2419,7 @@ var init_anthropic = __esm({
2372
2419
  });
2373
2420
  return {
2374
2421
  execute,
2375
- toModelOutput: ({ output }) => _AnthropicComputer.aiSdkModelOutput(output)
2422
+ toModelOutput: ({ output }) => _AnthropicComputer.modelOutput(output, imagePart)
2376
2423
  };
2377
2424
  }
2378
2425
  static aiSdkOutput(result) {
@@ -2380,16 +2427,26 @@ var init_anthropic = __esm({
2380
2427
  return { type: "image", data: result.image.toString("base64") };
2381
2428
  return result.text ?? "OK";
2382
2429
  }
2383
- /** `image-data` is what AI SDK 6's Anthropic provider turns into an image
2384
- * block; AI SDK 7 still accepts it (and converts it to a `file` part). */
2385
- static aiSdkModelOutput(output) {
2430
+ /** A screenshot as the image part of AI SDK `options.version`:
2431
+ * `image-data` for 6 (the default), `file` with `{ type: "data", data }`
2432
+ * for 7. */
2433
+ static aiSdkModelOutput(output, options = {}) {
2434
+ return _AnthropicComputer.modelOutput(
2435
+ output,
2436
+ _AnthropicComputer.imagePart(options)
2437
+ );
2438
+ }
2439
+ static imagePart({
2440
+ version = 6
2441
+ }) {
2442
+ if (Object.hasOwn(IMAGE_PARTS, version)) return IMAGE_PARTS[version];
2443
+ throw new Error(
2444
+ `unsupported AI SDK version ${version}; choose ${Object.keys(IMAGE_PARTS).join(" or ")}`
2445
+ );
2446
+ }
2447
+ static modelOutput(output, imagePart) {
2386
2448
  if (typeof output === "string") return { type: "text", value: output };
2387
- return {
2388
- type: "content",
2389
- value: [
2390
- { type: "image-data", data: output.data, mediaType: "image/png" }
2391
- ]
2392
- };
2449
+ return { type: "content", value: [imagePart(output.data)] };
2393
2450
  }
2394
2451
  envelope(block, content, isError = false) {
2395
2452
  return {
@@ -2679,13 +2736,16 @@ function idleWarning(idleExpiresAt, now = /* @__PURE__ */ new Date()) {
2679
2736
  const minutes = Math.max(0, Math.floor(leftMs / 6e4));
2680
2737
  return `warning: session expires in ${minutes}m (idle TTL); call a tool to extend it or \`gateway worlds session pin\` to keep it`;
2681
2738
  }
2682
- var CALL_BODY_LIMIT_BYTES, CALL_BODY_LIMIT_LABEL, IDLE_WARNING_MINUTES, EXPLORATORY_TASK, EXPLORATORY_TASK_SOURCE, NO_GRADER_REASON, WorldCallTooLarge, stillStartingHint;
2739
+ var CALL_BODY_LIMIT_BYTES, CALL_BODY_LIMIT_LABEL, IDLE_WARNING_MINUTES, REQUEST_LOG_PAGE_MAX, REQUEST_BODY_CAPTURE_BYTES, REQUESTS_NOT_RECORDED, EXPLORATORY_TASK, EXPLORATORY_TASK_SOURCE, NO_GRADER_REASON, WorldCallTooLarge, stillStartingHint;
2683
2740
  var init_sessionContract = __esm({
2684
2741
  "src/worlds/sessionContract.ts"() {
2685
2742
  "use strict";
2686
2743
  CALL_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
2687
2744
  CALL_BODY_LIMIT_LABEL = "4mb";
2688
2745
  IDLE_WARNING_MINUTES = 5;
2746
+ REQUEST_LOG_PAGE_MAX = 200;
2747
+ REQUEST_BODY_CAPTURE_BYTES = 64 * 1024;
2748
+ REQUESTS_NOT_RECORDED = "requests_not_recorded";
2689
2749
  EXPLORATORY_TASK = Object.freeze({
2690
2750
  instruction: "exploratory session"
2691
2751
  });
@@ -2719,6 +2779,217 @@ var init_sessionContract = __esm({
2719
2779
  }
2720
2780
  });
2721
2781
 
2782
+ // src/worlds/toolSchema.ts
2783
+ function schemaFromSignature(spec) {
2784
+ if (spec.inputSchema)
2785
+ return {
2786
+ type: "function",
2787
+ function: {
2788
+ name: modelToolName(spec.name),
2789
+ description: spec.doc ?? spec.name,
2790
+ parameters: spec.inputSchema
2791
+ }
2792
+ };
2793
+ const inside = /\(([\s\S]*)\)\s*$/.exec(spec.signature.trim())?.[1] ?? "";
2794
+ const properties = {};
2795
+ const required2 = [];
2796
+ const params = [];
2797
+ let depth = 0;
2798
+ let current = "";
2799
+ for (const ch of inside) {
2800
+ if ("([{".includes(ch)) depth++;
2801
+ if (")]}".includes(ch)) depth--;
2802
+ if (ch === "," && depth === 0) {
2803
+ params.push(current);
2804
+ current = "";
2805
+ } else current += ch;
2806
+ }
2807
+ if (current.trim()) params.push(current);
2808
+ for (const raw of params) {
2809
+ const param = raw.trim();
2810
+ if (!param || param.startsWith("*") || param === "self") continue;
2811
+ const eq = param.indexOf("=");
2812
+ const name = (eq === -1 ? param : param.slice(0, eq)).split(":")[0].trim();
2813
+ if (!name) continue;
2814
+ if (eq === -1) {
2815
+ properties[name] = { type: "string" };
2816
+ required2.push(name);
2817
+ continue;
2818
+ }
2819
+ const value = param.slice(eq + 1).trim();
2820
+ if (/^-?\d+(\.\d+)?$/.test(value)) properties[name] = { type: "number" };
2821
+ else if (value === "True" || value === "False")
2822
+ properties[name] = { type: "boolean" };
2823
+ else properties[name] = { type: "string" };
2824
+ }
2825
+ return {
2826
+ type: "function",
2827
+ function: {
2828
+ name: modelToolName(spec.name),
2829
+ description: spec.doc ?? spec.name,
2830
+ parameters: { type: "object", properties, required: required2 }
2831
+ }
2832
+ };
2833
+ }
2834
+ var modelToolName;
2835
+ var init_toolSchema = __esm({
2836
+ "src/worlds/toolSchema.ts"() {
2837
+ "use strict";
2838
+ modelToolName = (name) => name.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 64) || "tool";
2839
+ }
2840
+ });
2841
+
2842
+ // src/worlds/requestLedger.ts
2843
+ function platformMessage(text2) {
2844
+ try {
2845
+ const { message } = JSON.parse(text2);
2846
+ return typeof message === "string" ? message : null;
2847
+ } catch {
2848
+ return null;
2849
+ }
2850
+ }
2851
+ var WORLD_REQUEST_VIAS, WorldRequestFilterError, NOT_RECORDED, WorldRequestsNotRecorded, STATUS, INSTANT, WORLDS, SESSIONS, Instant, WorldRequestQuery, WorldRequestLedger;
2852
+ var init_requestLedger = __esm({
2853
+ "src/worlds/requestLedger.ts"() {
2854
+ "use strict";
2855
+ init_worlds();
2856
+ init_sessionContract();
2857
+ WORLD_REQUEST_VIAS = ["api", "ui", "tool", "webhook"];
2858
+ WorldRequestFilterError = class extends Error {
2859
+ };
2860
+ NOT_RECORDED = "This session's engine records no requests; only hosted World Host sessions do.";
2861
+ WorldRequestsNotRecorded = class _WorldRequestsNotRecorded extends Error {
2862
+ static from(error) {
2863
+ if (!(error instanceof ApiError) || error.code !== REQUESTS_NOT_RECORDED) return error;
2864
+ return new _WorldRequestsNotRecorded(platformMessage(error.text) || NOT_RECORDED);
2865
+ }
2866
+ static async mapped(read) {
2867
+ try {
2868
+ return await read;
2869
+ } catch (error) {
2870
+ throw _WorldRequestsNotRecorded.from(error);
2871
+ }
2872
+ }
2873
+ };
2874
+ STATUS = /^(?:[1-5]\d\d|[1-5]xx)$/;
2875
+ INSTANT = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?)?$/;
2876
+ WORLDS = "/api/public/worlds";
2877
+ SESSIONS = "/api/public/world-sessions";
2878
+ Instant = class _Instant {
2879
+ static parse(flag, raw) {
2880
+ const match = INSTANT.exec(raw);
2881
+ const millis = match ? _Instant.fromParts(match) : null;
2882
+ if (millis === null)
2883
+ throw new WorldRequestFilterError(
2884
+ `--${flag} must be an ISO 8601 date or time (2026-10-05, 2026-10-05T14:30:00Z), not \`${raw}\`.`
2885
+ );
2886
+ return millis;
2887
+ }
2888
+ static fromParts(match) {
2889
+ const [year, month, day, hour, minute, second] = [1, 2, 3, 4, 5, 6].map((i) => Number(match[i] ?? 0));
2890
+ const offset = _Instant.offsetMinutes(match[8]);
2891
+ if (offset === null || year < 1 || hour > 23 || minute > 59 || second > 59) return null;
2892
+ const date = /* @__PURE__ */ new Date(0);
2893
+ date.setUTCFullYear(year, month - 1, day);
2894
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return null;
2895
+ date.setUTCHours(hour, minute, second, Number((match[7] ?? "").padEnd(3, "0")));
2896
+ const utc = date.getTime() - offset * 6e4;
2897
+ const utcYear = new Date(utc).getUTCFullYear();
2898
+ return utcYear < 1 || utcYear > 9999 ? null : utc;
2899
+ }
2900
+ static offsetMinutes(zone) {
2901
+ if (zone === void 0 || zone === "Z") return 0;
2902
+ const hours = Number(zone.slice(1, 3));
2903
+ const minutes = Number(zone.slice(4, 6));
2904
+ if (hours > 23 || minutes > 59) return null;
2905
+ return (zone.startsWith("-") ? -1 : 1) * (hours * 60 + minutes);
2906
+ }
2907
+ };
2908
+ WorldRequestQuery = class _WorldRequestQuery {
2909
+ constructor(entries) {
2910
+ this.entries = entries;
2911
+ }
2912
+ entries;
2913
+ static parse(filter = {}) {
2914
+ const via = _WorldRequestQuery.via(filter.via);
2915
+ const status = _WorldRequestQuery.status(filter.status);
2916
+ const since = filter.since === void 0 ? void 0 : Instant.parse("since", filter.since);
2917
+ const until = filter.until === void 0 ? void 0 : Instant.parse("until", filter.until);
2918
+ if (since !== void 0 && until !== void 0 && since > until)
2919
+ throw new WorldRequestFilterError("--since must not be after --until.");
2920
+ const values = [
2921
+ ["session", filter.session],
2922
+ ["version", filter.version],
2923
+ ["via", via],
2924
+ ["operation", filter.operation],
2925
+ ["status", status],
2926
+ ["since", since === void 0 ? void 0 : new Date(since).toISOString()],
2927
+ ["until", until === void 0 ? void 0 : new Date(until).toISOString()],
2928
+ ["limit", filter.limit === void 0 ? void 0 : String(filter.limit)],
2929
+ ["cursor", filter.cursor]
2930
+ ];
2931
+ return new _WorldRequestQuery(values.filter((entry) => entry[1] !== void 0));
2932
+ }
2933
+ static via(value) {
2934
+ if (value === void 0) return void 0;
2935
+ const lower = value.toLowerCase();
2936
+ if (WORLD_REQUEST_VIAS.includes(lower)) return lower;
2937
+ throw new WorldRequestFilterError(`--via must be one of ${WORLD_REQUEST_VIAS.join(", ")}, not \`${value}\`.`);
2938
+ }
2939
+ static status(value) {
2940
+ if (value === void 0) return void 0;
2941
+ const lower = value.toLowerCase();
2942
+ if (STATUS.test(lower)) return lower;
2943
+ throw new WorldRequestFilterError(`--status must be a code (200) or a class (2xx), not \`${value}\`.`);
2944
+ }
2945
+ get filtered() {
2946
+ return this.entries.some(([key2]) => key2 !== "limit");
2947
+ }
2948
+ params() {
2949
+ return this.entries.map(([key2, value]) => [key2, value]);
2950
+ }
2951
+ search() {
2952
+ return this.entries.length ? `?${new URLSearchParams(this.entries).toString()}` : "";
2953
+ }
2954
+ };
2955
+ WorldRequestLedger = class {
2956
+ constructor(options = {}) {
2957
+ this.options = options;
2958
+ }
2959
+ options;
2960
+ /** A page of the world's requests, newest first; `nextCursor` reads the page after it. Narrowed to a session
2961
+ * whose engine records none: `WorldRequestsNotRecorded`. */
2962
+ list(slug, query = WorldRequestQuery.parse()) {
2963
+ return WorldRequestsNotRecorded.mapped(
2964
+ apiRequest(
2965
+ this.options,
2966
+ "GET",
2967
+ `${WORLDS}/${encodeURIComponent(slug)}/requests${query.search()}`
2968
+ )
2969
+ );
2970
+ }
2971
+ /** One of the world's requests, with its headers and bodies. */
2972
+ get(slug, requestId) {
2973
+ return apiRequest(
2974
+ this.options,
2975
+ "GET",
2976
+ `${WORLDS}/${encodeURIComponent(slug)}/requests/${encodeURIComponent(requestId)}`
2977
+ );
2978
+ }
2979
+ /** A page of one session's requests, newest first; `WorldRequestsNotRecorded` when its engine records none. */
2980
+ forSession(sessionId, query = WorldRequestQuery.parse()) {
2981
+ return WorldRequestsNotRecorded.mapped(
2982
+ apiRequest(
2983
+ this.options,
2984
+ "GET",
2985
+ `${SESSIONS}/${encodeURIComponent(sessionId)}/requests${query.search()}`
2986
+ )
2987
+ );
2988
+ }
2989
+ };
2990
+ }
2991
+ });
2992
+
2722
2993
  // src/worlds/sessionReadiness.ts
2723
2994
  var READY_TIMEOUT_MS, READY_POLL_MS, sleep3, WorldSessionTimeout, WorldSessionCallError, WorldSessionOpenFailed, ENDED, SessionReadiness;
2724
2995
  var init_sessionReadiness = __esm({
@@ -3057,57 +3328,6 @@ __export(session_exports2, {
3057
3328
  schemaFromSignature: () => schemaFromSignature,
3058
3329
  taskLabel: () => taskLabel
3059
3330
  });
3060
- function schemaFromSignature(spec) {
3061
- if (spec.inputSchema)
3062
- return {
3063
- type: "function",
3064
- function: {
3065
- name: modelToolName(spec.name),
3066
- description: spec.doc ?? spec.name,
3067
- parameters: spec.inputSchema
3068
- }
3069
- };
3070
- const inside = /\(([\s\S]*)\)\s*$/.exec(spec.signature.trim())?.[1] ?? "";
3071
- const properties = {};
3072
- const required2 = [];
3073
- const params = [];
3074
- let depth = 0;
3075
- let current = "";
3076
- for (const ch of inside) {
3077
- if ("([{".includes(ch)) depth++;
3078
- if (")]}".includes(ch)) depth--;
3079
- if (ch === "," && depth === 0) {
3080
- params.push(current);
3081
- current = "";
3082
- } else current += ch;
3083
- }
3084
- if (current.trim()) params.push(current);
3085
- for (const raw of params) {
3086
- const param = raw.trim();
3087
- if (!param || param.startsWith("*") || param === "self") continue;
3088
- const eq = param.indexOf("=");
3089
- const name = (eq === -1 ? param : param.slice(0, eq)).split(":")[0].trim();
3090
- if (!name) continue;
3091
- if (eq === -1) {
3092
- properties[name] = { type: "string" };
3093
- required2.push(name);
3094
- continue;
3095
- }
3096
- const value = param.slice(eq + 1).trim();
3097
- if (/^-?\d+(\.\d+)?$/.test(value)) properties[name] = { type: "number" };
3098
- else if (value === "True" || value === "False")
3099
- properties[name] = { type: "boolean" };
3100
- else properties[name] = { type: "string" };
3101
- }
3102
- return {
3103
- type: "function",
3104
- function: {
3105
- name: modelToolName(spec.name),
3106
- description: spec.doc ?? spec.name,
3107
- parameters: { type: "object", properties, required: required2 }
3108
- }
3109
- };
3110
- }
3111
3331
  async function attachSession(sessionId, options = {}) {
3112
3332
  const state2 = await apiRequest(
3113
3333
  options,
@@ -3128,6 +3348,7 @@ async function openSession(slugOrRef, taskOrOpts = {}, positionalOpts = {}) {
3128
3348
  `Unknown world surfaces: ${unknown.join(", ")}; choose from ${SURFACE_KINDS.join(", ")}`
3129
3349
  );
3130
3350
  if (opts.browserTier !== void 0) assertBrowserTier(opts.browserTier);
3351
+ if (opts.auth !== void 0) assertSessionAuthMode(opts.auth);
3131
3352
  const at = slugOrRef.indexOf("@");
3132
3353
  const slug = at === -1 ? slugOrRef : slugOrRef.slice(0, at);
3133
3354
  const ref = at === -1 ? "" : slugOrRef.slice(at + 1);
@@ -3140,7 +3361,8 @@ async function openSession(slugOrRef, taskOrOpts = {}, positionalOpts = {}) {
3140
3361
  ...task === void 0 ? {} : { task },
3141
3362
  ...opts.reuseWarm === void 0 ? {} : { reuseWarm: opts.reuseWarm },
3142
3363
  ...opts.surfaces?.length ? { surfaces: opts.surfaces } : {},
3143
- ...opts.browserTier === void 0 ? {} : { browserTier: opts.browserTier }
3364
+ ...opts.browserTier === void 0 ? {} : { browserTier: opts.browserTier },
3365
+ ...opts.auth === void 0 ? {} : { auth: opts.auth }
3144
3366
  }
3145
3367
  );
3146
3368
  return new WorldSession(state2.sessionId, state2, options);
@@ -3221,7 +3443,7 @@ async function runSessions(opts) {
3221
3443
  passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
3222
3444
  };
3223
3445
  }
3224
- var import_node_crypto2, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep4, modelToolName, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
3446
+ var import_node_crypto2, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep4, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
3225
3447
  var init_session2 = __esm({
3226
3448
  "src/worlds/session.ts"() {
3227
3449
  "use strict";
@@ -3230,6 +3452,8 @@ var init_session2 = __esm({
3230
3452
  init_browser();
3231
3453
  init_nativeComputer();
3232
3454
  init_sessionContract();
3455
+ init_toolSchema();
3456
+ init_requestLedger();
3233
3457
  init_sessionReadiness();
3234
3458
  init_session();
3235
3459
  init_taskRef();
@@ -3243,7 +3467,6 @@ var init_session2 = __esm({
3243
3467
  JUDGED_GRADE_POLL_MS = 2e3;
3244
3468
  EXPORT_PAGE = 500;
3245
3469
  sleep4 = (ms) => new Promise((r) => setTimeout(r, ms));
3246
- modelToolName = (name) => name.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 64) || "tool";
3247
3470
  WorldSession = class {
3248
3471
  constructor(sessionId, current, options) {
3249
3472
  this.sessionId = sessionId;
@@ -3313,12 +3536,12 @@ var init_session2 = __esm({
3313
3536
  );
3314
3537
  return api2.url;
3315
3538
  }
3316
- /** Headers every request to `api()` needs. A World Host session gates its
3317
- * api surface on a per-session token; a pod or hosted twin answers with the
3318
- * world's own declared auth and this is `{}`. */
3539
+ /** Headers every request to `api()` needs: a World Host session's token in the
3540
+ * platform's `X-World-Session` header, which every world takes; `{}` for a pod
3541
+ * or hosted twin, which answers with the world's own declared auth. */
3319
3542
  async apiHeaders() {
3320
3543
  const { api: api2 } = await this.surfaces();
3321
- return api2?.token ? { Authorization: `Bearer ${api2.token}` } : {};
3544
+ return api2?.token ? { [PLATFORM_SESSION_HEADER]: api2.token } : {};
3322
3545
  }
3323
3546
  /** URL of the world's UI entry page for this session. */
3324
3547
  async ui() {
@@ -3389,11 +3612,28 @@ var init_session2 = __esm({
3389
3612
  }
3390
3613
  /** The session's latest platform state (one request, no waiting). */
3391
3614
  async status() {
3615
+ return this.refresh(
3616
+ await apiRequest(
3617
+ this.options,
3618
+ "GET",
3619
+ `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}`
3620
+ )
3621
+ );
3622
+ }
3623
+ /** The world started over under the same id, URLs and token, on what its pin (or `version`, which becomes
3624
+ * its pin) resolves to now: base data plus the task's seed. A grade then reads only the new world's requests. */
3625
+ async restart(opts = {}) {
3392
3626
  const fresh = await apiRequest(
3393
3627
  this.options,
3394
- "GET",
3395
- `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}`
3628
+ "POST",
3629
+ `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/restart`,
3630
+ opts.version ? { version: opts.version } : {}
3396
3631
  );
3632
+ this.refresh(fresh);
3633
+ return fresh;
3634
+ }
3635
+ // A status read carries neither the objective nor the open's notices; keep the ones we opened with.
3636
+ refresh(fresh) {
3397
3637
  this.current = {
3398
3638
  instruction: this.current.instruction,
3399
3639
  tools: this.current.tools,
@@ -3428,7 +3668,7 @@ var init_session2 = __esm({
3428
3668
  const { callId } = enqueued;
3429
3669
  const judged = enqueued.pending === true;
3430
3670
  const budgetMs = timeoutMs ?? (judged ? JUDGED_GRADE_TIMEOUT_MS : CALL_TIMEOUT_MS);
3431
- const pollMs2 = judged ? JUDGED_GRADE_POLL_MS : CALL_POLL_MS;
3671
+ const pollMs = judged ? JUDGED_GRADE_POLL_MS : CALL_POLL_MS;
3432
3672
  const deadline = Date.now() + budgetMs;
3433
3673
  for (; ; ) {
3434
3674
  const call = await apiRequest(
@@ -3444,7 +3684,7 @@ var init_session2 = __esm({
3444
3684
  throw new WorldSessionTimeout(
3445
3685
  judged ? `Grade ${callId} still ${call.state} after ${Math.round(budgetMs / 1e3)}s \u2014 the judge has not answered; the platform finalizes the call on its own, read it back with export().` : `Call ${callId} still ${call.state} after ${Math.round(budgetMs / 1e3)}s \u2014 the container may have died.`
3446
3686
  );
3447
- await sleep4(pollMs2);
3687
+ await sleep4(pollMs);
3448
3688
  }
3449
3689
  }
3450
3690
  /**
@@ -3537,19 +3777,31 @@ var init_session2 = __esm({
3537
3777
  async reset(opts = {}) {
3538
3778
  await this.exchange({ kind: "reset" }, opts.timeoutMs);
3539
3779
  }
3780
+ /** One page of the session's entries in its world's request ledger, newest
3781
+ * first and without bodies: at most `limit` after `cursor` (the last page's
3782
+ * `nextCursor`). Reading it records nothing in the session. */
3783
+ async requests(opts = {}) {
3784
+ return new WorldRequestLedger(this.options).forSession(
3785
+ this.sessionId,
3786
+ WorldRequestQuery.parse({ cursor: opts.cursor, limit: opts.limit ?? REQUEST_LOG_PAGE_MAX })
3787
+ );
3788
+ }
3789
+ page(route2, limit, cursor) {
3790
+ const query = new URLSearchParams({ limit: String(limit) });
3791
+ if (cursor) query.set("cursor", cursor);
3792
+ return apiRequest(
3793
+ this.options,
3794
+ "GET",
3795
+ `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/${route2}?${query.toString()}`
3796
+ );
3797
+ }
3540
3798
  /** The session's call log, oldest first: every tool call, seed, reset,
3541
3799
  * grade with its result — the record of the episode. */
3542
3800
  async export() {
3543
3801
  const calls = [];
3544
3802
  let cursor;
3545
3803
  do {
3546
- const params = new URLSearchParams({ limit: String(EXPORT_PAGE) });
3547
- if (cursor) params.set("cursor", cursor);
3548
- const page = await apiRequest(
3549
- this.options,
3550
- "GET",
3551
- `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/calls?${params.toString()}`
3552
- );
3804
+ const page = await this.page("calls", EXPORT_PAGE, cursor);
3553
3805
  for (const call of page.calls) {
3554
3806
  calls.push({
3555
3807
  seq: Number(call.seq),
@@ -3631,6 +3883,7 @@ var init_session2 = __esm({
3631
3883
  "reuseWarm",
3632
3884
  "surfaces",
3633
3885
  "browserTier",
3886
+ "auth",
3634
3887
  "options"
3635
3888
  ]);
3636
3889
  isOpenSessionOptions = (value) => typeof value === "object" && value !== null && Object.keys(value).every((key2) => OPEN_SESSION_OPTION_KEYS.has(key2));
@@ -3745,11 +3998,50 @@ var init_tasks = __esm({
3745
3998
  }
3746
3999
  });
3747
4000
 
4001
+ // src/worlds/taskGrades.ts
4002
+ var TASKS2, compact2, TaskGrades;
4003
+ var init_taskGrades = __esm({
4004
+ "src/worlds/taskGrades.ts"() {
4005
+ "use strict";
4006
+ init_worlds();
4007
+ TASKS2 = "/api/public/world-tasks";
4008
+ compact2 = (body) => Object.fromEntries(Object.entries(body).filter(([, v]) => v !== void 0));
4009
+ TaskGrades = class {
4010
+ constructor(options = {}) {
4011
+ this.options = options;
4012
+ }
4013
+ options;
4014
+ try(sessionId, target) {
4015
+ return apiRequest(
4016
+ this.options,
4017
+ "POST",
4018
+ `${TASKS2}/try`,
4019
+ compact2({ sessionId, ...target })
4020
+ );
4021
+ }
4022
+ regrade(taskId, scope = {}) {
4023
+ return apiRequest(
4024
+ this.options,
4025
+ "POST",
4026
+ `${TASKS2}/${encodeURIComponent(taskId)}/regrade`,
4027
+ compact2({ ...scope })
4028
+ );
4029
+ }
4030
+ };
4031
+ }
4032
+ });
4033
+
3748
4034
  // src/worlds/surfaceDescriptor.ts
3749
4035
  function surfaceDescriptor(s) {
3750
4036
  return {
3751
4037
  surfaces: surfaceKinds(s),
3752
- ...s.api ? { api: { url: s.api.url, ...s.api.token ? { token: s.api.token } : {} } } : {},
4038
+ ...s.api ? {
4039
+ api: {
4040
+ url: s.api.url,
4041
+ ...s.api.token ? { token: s.api.token } : {},
4042
+ ...s.api.auth ? { auth: s.api.auth } : {}
4043
+ }
4044
+ } : {},
3753
4045
  ...s.ui ? { ui: { url: s.ui.url, entry: uiEntryUrl(s.ui), apiPath: s.ui.apiPath ?? null } } : {},
3754
4046
  ...s.browser ? {
3755
4047
  browser: {
@@ -3799,8 +4091,7 @@ function fromResponse(answer, options) {
3799
4091
  sessions2[alias] = new WorldSession(state2.sessionId, state2, options);
3800
4092
  worlds[alias] = {
3801
4093
  slug: state2.slug,
3802
- ref: state2.ref,
3803
- private: state2.private ?? null
4094
+ ref: state2.ref
3804
4095
  };
3805
4096
  }
3806
4097
  return new TaskSessions(
@@ -3875,7 +4166,6 @@ async function attachTask(taskId, options = {}) {
3875
4166
  {
3876
4167
  slug: row.slug ?? "",
3877
4168
  ref: null,
3878
- private: null,
3879
4169
  versionId: row.versionId,
3880
4170
  sessionId: row.sessionId,
3881
4171
  ready: row.ready,
@@ -3905,7 +4195,7 @@ async function attachManifest(manifest, options = {}) {
3905
4195
  Object.fromEntries(
3906
4196
  Object.entries(manifest.sessions).map(([alias, entry]) => [
3907
4197
  alias,
3908
- { slug: entry.slug, ref: entry.ref, private: entry.private ?? null }
4198
+ { slug: entry.slug, ref: entry.ref }
3909
4199
  ])
3910
4200
  )
3911
4201
  );
@@ -3927,7 +4217,6 @@ var init_taskSessions = __esm({
3927
4217
  manifestSession = (s, state2, world) => ({
3928
4218
  slug: world.slug,
3929
4219
  ref: world.ref,
3930
- private: world.private,
3931
4220
  versionId: state2.versionId,
3932
4221
  sessionId: state2.sessionId,
3933
4222
  ready: state2.ready,
@@ -3984,7 +4273,7 @@ var init_taskSessions = __esm({
3984
4273
  /** This alias's world as recorded at open/attach — what a `TaskRun`
3985
4274
  * filing needs to name, without exposing the whole map. */
3986
4275
  worldRef(alias) {
3987
- return this.worlds[alias] ?? { slug: "", ref: null, private: null };
4276
+ return this.worlds[alias] ?? { slug: "", ref: null };
3988
4277
  }
3989
4278
  /** The aliases, in the spec's order. */
3990
4279
  get aliases() {
@@ -4309,16 +4598,12 @@ var init_taskRunOutcome = __esm({
4309
4598
  evaluationId;
4310
4599
  evaluationStatus = null;
4311
4600
  started = Date.now();
4312
- /** The run stopped short of a grade; the first reason stands. */
4313
4601
  stopped(error) {
4314
4602
  this.runError ??= messageOf(error).slice(0, 2e3);
4315
4603
  }
4316
4604
  agentRaised(error) {
4317
4605
  this.agentError = messageOf(error).slice(0, 2e3);
4318
4606
  }
4319
- /** Every reason the run failed, on one line: the evaluation's
4320
- * `metrics.error`. A run that never reached a grade has failed whatever
4321
- * its reasons say. */
4322
4607
  failure() {
4323
4608
  const reasons = [
4324
4609
  this.agentError === null ? null : `agent raised: ${this.agentError}`,
@@ -4414,6 +4699,7 @@ var init_taskRunOutcome = __esm({
4414
4699
  ])
4415
4700
  ),
4416
4701
  ungraded: this.grade?.ungraded ?? live.aliases,
4702
+ verifierVersion: live.taskVersion,
4417
4703
  traced: this.traced,
4418
4704
  runDir: this.runDir,
4419
4705
  ...this.agentError ? { agentError: this.agentError } : {},
@@ -4791,7 +5077,7 @@ var require_package = __commonJS({
4791
5077
  "package.json"(exports2, module2) {
4792
5078
  module2.exports = {
4793
5079
  name: "@withgateway/sdk",
4794
- version: "0.3.3",
5080
+ version: "0.6.0",
4795
5081
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
4796
5082
  main: "./dist/index.js",
4797
5083
  module: "./dist/index.mjs",
@@ -6070,51 +6356,195 @@ var init_setRun = __esm({
6070
6356
  });
6071
6357
 
6072
6358
  // src/worlds/requestLog.ts
6073
- var WorldRequestLog;
6359
+ function worldRequestsUnrecorded(counts) {
6360
+ const parts2 = UNRECORDED.map(([field2, one, many]) => [counted(counts[field2]), one, many]).filter(([count]) => count > 0).map(([count, one, many]) => (count === 1 ? one : many).replace("{n}", String(count)));
6361
+ return parts2.length > 0 ? `Not recorded: ${parts2.join(", ")}` : null;
6362
+ }
6363
+ function counted(value) {
6364
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
6365
+ }
6366
+ var UNRECORDED, WorldRequestLog;
6074
6367
  var init_requestLog = __esm({
6075
6368
  "src/worlds/requestLog.ts"() {
6076
6369
  "use strict";
6370
+ init_requestLedger();
6371
+ UNRECORDED = [
6372
+ ["lost", "{n} request", "{n} requests"],
6373
+ ["shed", "{n} request's headers and bodies", "{n} requests' headers and bodies"],
6374
+ ["hostsLost", "the requests {n} lost host held", "the requests {n} lost hosts held"]
6375
+ ];
6077
6376
  WorldRequestLog = class _WorldRequestLog {
6078
- constructor(requests) {
6377
+ constructor(requests, notRecorded = null, unrecorded = null) {
6079
6378
  this.requests = requests;
6379
+ this.notRecorded = notRecorded;
6380
+ this.unrecorded = unrecorded;
6080
6381
  }
6081
6382
  requests;
6082
- static async read(session) {
6083
- const state2 = await session.state();
6084
- const calls = state2?.calls;
6085
- if (!Array.isArray(calls)) return null;
6086
- return new _WorldRequestLog(calls.filter((c) => typeof c === "object" && c !== null));
6087
- }
6088
- /** How many older requests the world no longer keeps (its log is bounded): the gap
6089
- * before the first entry it still holds. */
6090
- get dropped() {
6091
- const first = Number(this.requests[0]?.seq) || 1;
6092
- return Math.max(0, first - 1);
6093
- }
6094
- /** Each request in the shape of a ledger line, `kind: "request"`, so one JSONL
6095
- * file holds both. */
6383
+ notRecorded;
6384
+ unrecorded;
6385
+ /** Every entry the ledger holds for the session, oldest first, and the line for what it did not record;
6386
+ * for a session the World Host did not serve, none, and `notRecorded` says why. */
6387
+ static async load(session) {
6388
+ try {
6389
+ return await _WorldRequestLog.pages(session);
6390
+ } catch (error) {
6391
+ const refused = WorldRequestsNotRecorded.from(error);
6392
+ if (!(refused instanceof WorldRequestsNotRecorded)) throw error;
6393
+ return new _WorldRequestLog([], refused.message);
6394
+ }
6395
+ }
6396
+ static async pages(session) {
6397
+ const requests = [];
6398
+ let cursor;
6399
+ for (; ; ) {
6400
+ const page = await session.requests(cursor ? { cursor } : {});
6401
+ requests.push(...page.requests);
6402
+ if (!page.nextCursor || page.requests.length === 0)
6403
+ return new _WorldRequestLog(requests.reverse(), null, worldRequestsUnrecorded(page));
6404
+ cursor = page.nextCursor;
6405
+ }
6406
+ }
6407
+ /** Each entry in the shape of a ledger line, `kind: "request"`, so one JSONL
6408
+ * file holds both: `args` what was asked, `result` what came back under the
6409
+ * entry's `requestId`. */
6096
6410
  asCalls() {
6097
6411
  return this.requests.map((r) => ({
6098
- seq: Number(r.seq) || 0,
6412
+ seq: r.seq,
6099
6413
  kind: "request",
6100
- tool: r.operation ?? null,
6414
+ tool: r.operation,
6101
6415
  args: {
6102
- method: r.method ?? null,
6103
- path: r.path ?? null,
6104
- args: r.args ?? null,
6105
- query: r.query ?? null,
6106
- body: r.body ?? null,
6107
- via: r.via ?? null
6416
+ method: r.method,
6417
+ path: r.path,
6418
+ query: r.query,
6419
+ via: r.via,
6420
+ contentType: r.request.contentType,
6421
+ bodyBytes: r.request.bodyBytes,
6422
+ truncated: r.request.truncated
6423
+ },
6424
+ result: {
6425
+ requestId: r.id,
6426
+ status: r.response.status,
6427
+ rows: r.rows,
6428
+ found: r.found,
6429
+ durationMs: r.durationMs,
6430
+ contentType: r.response.contentType,
6431
+ bodyBytes: r.response.bodyBytes,
6432
+ truncated: r.response.truncated
6108
6433
  },
6109
- result: { status: r.status ?? null, rows: r.rows ?? null, found: r.found ?? null },
6110
6434
  error: null,
6111
- completedAt: r.at ?? null
6435
+ completedAt: r.at
6112
6436
  }));
6113
6437
  }
6114
6438
  };
6115
6439
  }
6116
6440
  });
6117
6441
 
6442
+ // src/worlds/webhooks.ts
6443
+ async function listWebhooks(options, sessionId, page = {}) {
6444
+ const query = new URLSearchParams({
6445
+ after: String(page.after ?? 0),
6446
+ limit: String(page.limit ?? WORLD_WEBHOOK_PAGE_MAX),
6447
+ tail: String(page.tail ?? false)
6448
+ });
6449
+ if (page.epoch) query.set("epoch", page.epoch);
6450
+ return apiRequest(options, "GET", `${route(sessionId)}?${query.toString()}`);
6451
+ }
6452
+ var WORLD_WEBHOOK_PAGE_MAX, FORWARD_TIMEOUT_MS, ERROR_CHARS, route, WorldWebhookForwarder;
6453
+ var init_webhooks = __esm({
6454
+ "src/worlds/webhooks.ts"() {
6455
+ "use strict";
6456
+ init_worlds();
6457
+ WORLD_WEBHOOK_PAGE_MAX = 100;
6458
+ FORWARD_TIMEOUT_MS = 1e4;
6459
+ ERROR_CHARS = 500;
6460
+ route = (sessionId) => `/api/public/world-sessions/${encodeURIComponent(sessionId)}/webhooks`;
6461
+ WorldWebhookForwarder = class {
6462
+ constructor(options, sessionId, forwardTo, opts = {}) {
6463
+ this.options = options;
6464
+ this.sessionId = sessionId;
6465
+ this.forwardTo = forwardTo;
6466
+ this.send = opts.fetch ?? fetch;
6467
+ }
6468
+ options;
6469
+ sessionId;
6470
+ forwardTo;
6471
+ after = 0;
6472
+ epoch = null;
6473
+ answers = [];
6474
+ send;
6475
+ get cursor() {
6476
+ return this.after;
6477
+ }
6478
+ /** Where forwarding begins: the deliveries the session still holds (`replay`), or only those it sends from now. */
6479
+ async start(replay2) {
6480
+ if (replay2) return null;
6481
+ const page = await this.poll([], { tail: true, limit: 1 });
6482
+ this.follow(page);
6483
+ return page;
6484
+ }
6485
+ /** One poll: the answers held so far sent, the next page forwarded. A poll that fails keeps its answers for the next. */
6486
+ async round() {
6487
+ const page = await this.withAnswers((answers) => this.poll(answers));
6488
+ const forwarded = [];
6489
+ for (const delivery of page.deliveries) {
6490
+ const answer = await this.forward(delivery);
6491
+ this.answers.push(answer);
6492
+ forwarded.push({ delivery, answer });
6493
+ }
6494
+ this.follow(page);
6495
+ return { page, forwarded };
6496
+ }
6497
+ /** Sends the answers still held; the cursor stays, so a delivery this poll returns is forwarded by the next round. */
6498
+ async settle() {
6499
+ if (this.answers.length === 0) return 0;
6500
+ const page = await this.withAnswers((answers) => this.poll(answers, { limit: 1 }));
6501
+ return page.answered;
6502
+ }
6503
+ follow(page) {
6504
+ this.after = page.next;
6505
+ this.epoch = page.epoch;
6506
+ }
6507
+ async withAnswers(poll) {
6508
+ const answers = this.answers.splice(0, WORLD_WEBHOOK_PAGE_MAX);
6509
+ try {
6510
+ return await poll(answers);
6511
+ } catch (error) {
6512
+ this.answers.unshift(...answers);
6513
+ throw error;
6514
+ }
6515
+ }
6516
+ poll(answers, opts = {}) {
6517
+ return apiRequest(this.options, "POST", route(this.sessionId), {
6518
+ after: this.after,
6519
+ epoch: this.epoch,
6520
+ tail: opts.tail ?? false,
6521
+ limit: opts.limit ?? WORLD_WEBHOOK_PAGE_MAX,
6522
+ subscriptions: false,
6523
+ answers
6524
+ });
6525
+ }
6526
+ async forward(delivery) {
6527
+ const started = Date.now();
6528
+ try {
6529
+ const reply = await this.send(this.forwardTo, {
6530
+ method: "POST",
6531
+ headers: delivery.headers,
6532
+ body: delivery.payload,
6533
+ redirect: "manual",
6534
+ signal: AbortSignal.timeout(FORWARD_TIMEOUT_MS)
6535
+ });
6536
+ await reply.arrayBuffer().catch(() => void 0);
6537
+ if (reply.status < 100 || reply.status > 599) throw new Error("the receiver answered an invalid HTTP status");
6538
+ return { id: delivery.id, status: reply.status, durationMs: Date.now() - started, error: null };
6539
+ } catch (error) {
6540
+ const message = error instanceof Error ? error.message : String(error);
6541
+ return { id: delivery.id, status: 0, durationMs: Date.now() - started, error: message.slice(0, ERROR_CHARS) };
6542
+ }
6543
+ }
6544
+ };
6545
+ }
6546
+ });
6547
+
6118
6548
  // src/worlds/checkoutTarget.ts
6119
6549
  var fs2, path3, CheckoutRefusedError, NAMED_EDITS, CheckoutTarget;
6120
6550
  var init_checkoutTarget = __esm({
@@ -6799,7 +7229,8 @@ function checkoutIdentity(ref, resolved) {
6799
7229
  async function pull(slugRef, target, options = {}, opts = {}) {
6800
7230
  const at = slugRef.indexOf("@");
6801
7231
  const slug = at === -1 ? slugRef : slugRef.slice(0, at);
6802
- const ref = at === -1 ? "latest" : slugRef.slice(at + 1);
7232
+ const asked = at === -1 ? void 0 : slugRef.slice(at + 1);
7233
+ const ref = asked ?? "latest";
6803
7234
  const landing = CheckoutTarget.resolve(slug, target, {
6804
7235
  cwd: process.cwd(),
6805
7236
  force: opts.force ?? false,
@@ -6807,7 +7238,7 @@ async function pull(slugRef, target, options = {}, opts = {}) {
6807
7238
  });
6808
7239
  const details = await apiRequest(options, "POST", "/api/public/benchmark-containers/resolve-version", {
6809
7240
  slug,
6810
- ref
7241
+ ...asked ? { ref: asked } : {}
6811
7242
  });
6812
7243
  if (!details.downloadUrl) {
6813
7244
  throw new Error(`${slug}@${ref} resolved but has no uploaded bundle`);
@@ -6997,7 +7428,7 @@ async function validateWorld(dir, opts) {
6997
7428
  options,
6998
7429
  "POST",
6999
7430
  "/api/public/benchmark-containers/resolve-version",
7000
- { slug, ref: branch }
7431
+ { slug, ...branch === DEFAULT_BRANCH ? {} : { ref: branch } }
7001
7432
  );
7002
7433
  tipVersionId = tip.versionId ?? null;
7003
7434
  } catch {
@@ -7109,6 +7540,10 @@ function parseSlugRef(slugRef) {
7109
7540
  if (at === -1) return { slug: slugRef };
7110
7541
  return { slug: slugRef.slice(0, at), ref: slugRef.slice(at + 1) };
7111
7542
  }
7543
+ function nameGlob(pattern) {
7544
+ const literal = (part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
7545
+ return new RegExp(`^${pattern.split("*").map(literal).join(".*")}$`);
7546
+ }
7112
7547
  function rebaseConflicts(error) {
7113
7548
  if (!(error instanceof ApiError) || error.status !== 409) return null;
7114
7549
  let body;
@@ -7126,7 +7561,8 @@ function isConflictPath(value) {
7126
7561
  return typeof entry?.path === "string" && typeof entry.reason === "string";
7127
7562
  }
7128
7563
  function uncommittedPaths(error) {
7129
- if (!(error instanceof ApiError) || error.status !== 409 || error.code !== "sandbox_uncommitted") return null;
7564
+ if (!(error instanceof ApiError) || error.status !== 409 || error.code !== "sandbox_uncommitted")
7565
+ return null;
7130
7566
  let body;
7131
7567
  try {
7132
7568
  body = JSON.parse(error.text);
@@ -7137,6 +7573,53 @@ function uncommittedPaths(error) {
7137
7573
  if (!Array.isArray(uncommitted)) return null;
7138
7574
  return uncommitted.filter((p) => typeof p === "string");
7139
7575
  }
7576
+ function carriedWarnings(error) {
7577
+ const kept = typeof error === "object" && error !== null ? carried.get(error) ?? [] : [];
7578
+ const shown = error instanceof Error ? error.message : "";
7579
+ return unique([...kept, ...bodyWarnings(error)]).filter((warning) => !shown.includes(warning));
7580
+ }
7581
+ function carrying(error, warnings) {
7582
+ if (warnings.length > 0 && typeof error === "object" && error !== null)
7583
+ carried.set(error, unique([...carried.get(error) ?? [], ...warnings]));
7584
+ return error;
7585
+ }
7586
+ function unique(warnings) {
7587
+ return [...new Set(warnings)];
7588
+ }
7589
+ function bodyWarnings(error) {
7590
+ if (!(error instanceof ApiError)) return [];
7591
+ let body;
7592
+ try {
7593
+ body = JSON.parse(error.text);
7594
+ } catch {
7595
+ return [];
7596
+ }
7597
+ const warnings = body?.warnings;
7598
+ if (!Array.isArray(warnings)) return [];
7599
+ return warnings.filter((w) => typeof w === "string");
7600
+ }
7601
+ function deferredWarnings(error) {
7602
+ if (!(error instanceof ApiError) || error.status !== 409 || error.code !== "sandbox_exec_deferred") return null;
7603
+ return bodyWarnings(error);
7604
+ }
7605
+ function rowsRefusal(error) {
7606
+ if (!(error instanceof ApiError) || error.status !== 400 || error.code !== "rows_refused") return null;
7607
+ let body;
7608
+ try {
7609
+ body = JSON.parse(error.text);
7610
+ } catch {
7611
+ return null;
7612
+ }
7613
+ const { message, batchId, refusalCount, refusals, reportUrl } = body;
7614
+ if (typeof batchId !== "string" || typeof refusalCount !== "number" || !Array.isArray(refusals)) return null;
7615
+ return {
7616
+ message: typeof message === "string" ? message : "",
7617
+ batchId,
7618
+ refusalCount,
7619
+ refusals: refusals.filter((r) => typeof r === "object" && r !== null),
7620
+ reportUrl: typeof reportUrl === "string" ? reportUrl : null
7621
+ };
7622
+ }
7140
7623
  function listQuery(filter) {
7141
7624
  const params = new URLSearchParams();
7142
7625
  if (filter.status) params.set("status", filter.status);
@@ -7145,15 +7628,52 @@ function listQuery(filter) {
7145
7628
  const qs3 = params.toString();
7146
7629
  return qs3 ? `?${qs3}` : "";
7147
7630
  }
7148
- var isSandboxImportPending, sid, SANDBOXES, SANDBOX_REQUEST_TIMEOUT_MS, WorldSandboxClient;
7631
+ var import_node_crypto7, isSandboxCommitPending, isSandboxImportPending, sid, SANDBOXES, SANDBOX_REQUEST_TIMEOUT_MS, SANDBOX_WRITE_CHUNK_BYTES, SANDBOX_FILE_MAX_BYTES, SANDBOX_WRITE_SKIPPED, WriteTreeFilter, SANDBOX_EXEC_WAIT_MS, SANDBOX_EXEC_TIMEOUT_MAX_S, SANDBOX_EXEC_REPORT_MARGIN_MS, SANDBOX_EXEC_START_ATTEMPTS, carried, WorldSandboxClient;
7149
7632
  var init_sandbox = __esm({
7150
7633
  "src/worlds/sandbox.ts"() {
7151
7634
  "use strict";
7635
+ import_node_crypto7 = require("crypto");
7152
7636
  init_worlds();
7637
+ isSandboxCommitPending = (answer) => !("versionId" in answer);
7153
7638
  isSandboxImportPending = (answer) => !("versionId" in answer);
7154
7639
  sid = encodeURIComponent;
7155
7640
  SANDBOXES = "/api/public/benchmark-containers/sandboxes";
7156
- SANDBOX_REQUEST_TIMEOUT_MS = 66e4;
7641
+ SANDBOX_REQUEST_TIMEOUT_MS = 29e4;
7642
+ SANDBOX_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
7643
+ SANDBOX_FILE_MAX_BYTES = 256 * 1024 * 1024;
7644
+ SANDBOX_WRITE_SKIPPED = [
7645
+ ".git/",
7646
+ ".gateway/",
7647
+ "scratch/",
7648
+ ".scratch/",
7649
+ "__pycache__/",
7650
+ "*.pyc",
7651
+ ".pytest_cache/",
7652
+ ".mypy_cache/",
7653
+ ".ruff_cache/",
7654
+ "node_modules/",
7655
+ ".venv/",
7656
+ "venv/",
7657
+ ".DS_Store",
7658
+ "*.swp"
7659
+ ];
7660
+ WriteTreeFilter = class {
7661
+ directories = new Set(
7662
+ SANDBOX_WRITE_SKIPPED.filter((pattern) => pattern.endsWith("/")).map((pattern) => pattern.slice(0, -1))
7663
+ );
7664
+ files = SANDBOX_WRITE_SKIPPED.filter((pattern) => !pattern.endsWith("/")).map(nameGlob);
7665
+ skipsDirectory(name) {
7666
+ return this.directories.has(name);
7667
+ }
7668
+ skipsFile(name) {
7669
+ return this.files.some((glob) => glob.test(name));
7670
+ }
7671
+ };
7672
+ SANDBOX_EXEC_WAIT_MS = 4e4;
7673
+ SANDBOX_EXEC_TIMEOUT_MAX_S = 600;
7674
+ SANDBOX_EXEC_REPORT_MARGIN_MS = 35e3;
7675
+ SANDBOX_EXEC_START_ATTEMPTS = 3;
7676
+ carried = /* @__PURE__ */ new WeakMap();
7157
7677
  WorldSandboxClient = class {
7158
7678
  constructor(options = {}) {
7159
7679
  this.options = options;
@@ -7178,7 +7698,10 @@ var init_sandbox = __esm({
7178
7698
  }
7179
7699
  /** The project's sandboxes, newest first — how an agent finds one it left open. */
7180
7700
  async list(filter = {}) {
7181
- const res = await this.request("GET", `${SANDBOXES}${listQuery(filter)}`);
7701
+ const res = await this.request(
7702
+ "GET",
7703
+ `${SANDBOXES}${listQuery(filter)}`
7704
+ );
7182
7705
  return res.sandboxes;
7183
7706
  }
7184
7707
  async read(sandboxId, filePath) {
@@ -7186,16 +7709,72 @@ var init_sandbox = __esm({
7186
7709
  "GET",
7187
7710
  `${SANDBOXES}/${sid(sandboxId)}/file?path=${encodeURIComponent(filePath)}`
7188
7711
  );
7189
- return { path: res.path, size: res.size, bytes: Buffer.from(res.contentBase64, "base64") };
7712
+ return {
7713
+ path: res.path,
7714
+ size: res.size,
7715
+ bytes: Buffer.from(res.contentBase64, "base64")
7716
+ };
7190
7717
  }
7191
- write(sandboxId, filePath, bytes) {
7192
- return this.request("PUT", `${SANDBOXES}/${sid(sandboxId)}/file`, {
7193
- path: filePath,
7194
- contentBase64: bytes.toString("base64")
7195
- });
7718
+ /** A file past one chunk goes up in parts under one upload id; the platform lands it whole once the last part's
7719
+ * size and SHA-256 check out. */
7720
+ async write(sandboxId, filePath, bytes) {
7721
+ if (bytes.length <= SANDBOX_WRITE_CHUNK_BYTES)
7722
+ return this.putFile(sandboxId, { path: filePath, contentBase64: bytes.toString("base64") });
7723
+ const whole = { upload: (0, import_node_crypto7.randomUUID)(), size: bytes.length, sha256: (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex") };
7724
+ let answer = { path: filePath, received: 0 };
7725
+ for (let offset = 0; offset < bytes.length; offset += SANDBOX_WRITE_CHUNK_BYTES) {
7726
+ const part = bytes.subarray(offset, offset + SANDBOX_WRITE_CHUNK_BYTES);
7727
+ answer = await this.putFile(sandboxId, {
7728
+ path: filePath,
7729
+ contentBase64: part.toString("base64"),
7730
+ ...whole,
7731
+ offset,
7732
+ last: offset + part.length === bytes.length
7733
+ });
7734
+ }
7735
+ return answer;
7196
7736
  }
7197
- exec(sandboxId, input) {
7198
- return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/exec`, input);
7737
+ putFile(sandboxId, body) {
7738
+ return this.request("PUT", `${SANDBOXES}/${sid(sandboxId)}/file`, body);
7739
+ }
7740
+ /** Runs as a job on the platform: a command that outlasts one request is waited on again until its result. */
7741
+ async exec(sandboxId, input) {
7742
+ const budgetMs = (input.timeoutMs ?? SANDBOX_EXEC_TIMEOUT_MAX_S * 1e3) + SANDBOX_EXEC_REPORT_MARGIN_MS;
7743
+ let answer = await this.startExec(sandboxId, { ...input, waitMs: SANDBOX_EXEC_WAIT_MS });
7744
+ const deadline = Date.now() + budgetMs;
7745
+ const warnings = [...answer.warnings ?? []];
7746
+ try {
7747
+ while ("state" in answer) {
7748
+ if (Date.now() >= deadline)
7749
+ throw new Error(
7750
+ `exec ${answer.execId} in sandbox ${sandboxId} has not reported back within ${budgetMs / 1e3} s, past its timeout: the sandbox may have restarted. Check the sandbox's status, then run the command again.`
7751
+ );
7752
+ answer = await this.execStep(sandboxId, { execId: answer.execId, waitMs: SANDBOX_EXEC_WAIT_MS });
7753
+ warnings.push(...answer.warnings ?? []);
7754
+ }
7755
+ } catch (error) {
7756
+ throw carrying(error, warnings);
7757
+ }
7758
+ return { ...answer, warnings };
7759
+ }
7760
+ // A deferred start ran nothing (the platform was still getting the sandbox ready), so starting again is safe. What
7761
+ // getting ready found rides on the deferral alone (no later call reports it), so it is kept for the answer, or for
7762
+ // the error when a later attempt fails.
7763
+ async startExec(sandboxId, body) {
7764
+ const kept = [];
7765
+ for (let attempt = 1; ; attempt += 1) {
7766
+ try {
7767
+ const answer = await this.execStep(sandboxId, body);
7768
+ return { ...answer, warnings: unique([...kept, ...answer.warnings ?? []]) };
7769
+ } catch (error) {
7770
+ const warnings = deferredWarnings(error);
7771
+ if (warnings === null || attempt === SANDBOX_EXEC_START_ATTEMPTS) throw carrying(error, kept);
7772
+ kept.push(...warnings);
7773
+ }
7774
+ }
7775
+ }
7776
+ execStep(sandboxId, body) {
7777
+ return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/exec`, body);
7199
7778
  }
7200
7779
  check(sandboxId) {
7201
7780
  return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/check`, {});
@@ -7203,7 +7782,11 @@ var init_sandbox = __esm({
7203
7782
  /** With `rebase`, a moved base is replayed onto; a 409 then names the conflicting paths (`rebaseConflicts`). */
7204
7783
  commit(sandboxId, input) {
7205
7784
  const { rebase, ...rest } = input;
7206
- return this.request("POST", `${SANDBOXES}/${sid(sandboxId)}/commit`, rebase ? { ...rest, rebase: true } : rest);
7785
+ return this.request(
7786
+ "POST",
7787
+ `${SANDBOXES}/${sid(sandboxId)}/commit`,
7788
+ rebase ? { ...rest, rebase: true } : rest
7789
+ );
7207
7790
  }
7208
7791
  /**
7209
7792
  * A rows file already in the sandbox tree into the PLATFORM world the
@@ -7216,7 +7799,11 @@ var init_sandbox = __esm({
7216
7799
  }
7217
7800
  /** Uncommitted work is a 409 (`uncommittedPaths`) unless `force` discards it. */
7218
7801
  close(sandboxId, opts = {}) {
7219
- return this.request("DELETE", `${SANDBOXES}/${sid(sandboxId)}`, opts.force ? { force: true } : void 0);
7802
+ return this.request(
7803
+ "DELETE",
7804
+ `${SANDBOXES}/${sid(sandboxId)}`,
7805
+ opts.force ? { force: true } : void 0
7806
+ );
7220
7807
  }
7221
7808
  };
7222
7809
  }
@@ -7552,11 +8139,11 @@ function applyTransforms(value, chain) {
7552
8139
  for (const step of steps) out = step(out);
7553
8140
  return out;
7554
8141
  }
7555
- var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
8142
+ var import_node_crypto8, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
7556
8143
  var init_transforms = __esm({
7557
8144
  "src/worlds/transforms.ts"() {
7558
8145
  "use strict";
7559
- import_node_crypto7 = require("crypto");
8146
+ import_node_crypto8 = require("crypto");
7560
8147
  init_json();
7561
8148
  WHITESPACE = " \n\r\f\v";
7562
8149
  WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
@@ -7573,7 +8160,7 @@ var init_transforms = __esm({
7573
8160
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
7574
8161
  };
7575
8162
  stripPrefix = (prefix) => (value) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
7576
- hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
8163
+ hex = (algorithm, value) => (0, import_node_crypto8.createHash)(algorithm).update(value, "utf8").digest("hex");
7577
8164
  SIMPLE = {
7578
8165
  lower: (value) => value.toLowerCase(),
7579
8166
  upper: (value) => value.toUpperCase(),
@@ -7605,7 +8192,7 @@ function pyText(value) {
7605
8192
  return pyFloatRepr(value);
7606
8193
  }
7607
8194
  function hashForm(slug, plaintext) {
7608
- return "sha256:" + (0, import_node_crypto8.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
8195
+ return "sha256:" + (0, import_node_crypto9.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
7609
8196
  }
7610
8197
  function preserveForm(slug, plaintext) {
7611
8198
  const kind = typeof plaintext === "string" ? "str" : isInt(plaintext) ? "int" : "float";
@@ -7614,12 +8201,12 @@ function preserveForm(slug, plaintext) {
7614
8201
  }
7615
8202
  function shapeText(slug, text2, kind) {
7616
8203
  const seed = Buffer.from(`${slug}:${text2}`, "utf8");
7617
- let digest = (0, import_node_crypto8.createHash)("sha256").update(seed).digest();
8204
+ let digest = (0, import_node_crypto9.createHash)("sha256").update(seed).digest();
7618
8205
  let cursor = 0;
7619
8206
  const out = [];
7620
8207
  for (const char of text2) {
7621
8208
  if (cursor === digest.length) {
7622
- digest = (0, import_node_crypto8.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
8209
+ digest = (0, import_node_crypto9.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
7623
8210
  cursor = 0;
7624
8211
  }
7625
8212
  const byte = digest[cursor];
@@ -7656,11 +8243,11 @@ function storedForms(world, field2, plaintext, transform) {
7656
8243
  if (policy !== null) return [roundForm(plaintext, world.redact.round[field2])];
7657
8244
  return [plaintext];
7658
8245
  }
7659
- var import_node_crypto8, isInt;
8246
+ var import_node_crypto9, isInt;
7660
8247
  var init_redaction = __esm({
7661
8248
  "src/worlds/redaction.ts"() {
7662
8249
  "use strict";
7663
- import_node_crypto8 = require("crypto");
8250
+ import_node_crypto9 = require("crypto");
7664
8251
  init_json();
7665
8252
  init_transforms();
7666
8253
  isInt = (value) => typeof value === "number" && Number.isInteger(value);
@@ -7756,9 +8343,9 @@ var init_router = __esm({
7756
8343
  });
7757
8344
 
7758
8345
  // src/cli/config.ts
7759
- async function api(creds, method, route, body, init3 = {}) {
7760
- const reply = await new PlatformTransport(creds).send(method, route, body, init3);
7761
- if (!reply.ok) throw new ApiError2(reply.status, method, route, reply.text);
8346
+ async function api(creds, method, route2, body, init3 = {}) {
8347
+ const reply = await new PlatformTransport(creds).send(method, route2, body, init3);
8348
+ if (!reply.ok) throw new ApiError2(reply.status, method, route2, reply.text);
7762
8349
  return reply.text ? JSON.parse(reply.text) : {};
7763
8350
  }
7764
8351
  var fs6, os, path7, ApiError2;
@@ -7772,12 +8359,12 @@ var init_config = __esm({
7772
8359
  init_worlds();
7773
8360
  init_transport();
7774
8361
  ApiError2 = class extends CliError {
7775
- constructor(status, method, route, text2) {
7776
- const body = parseErrorBody(text2);
7777
- super(`${method} ${route} -> ${status}: ${body.detail}`, 1);
8362
+ constructor(status, method, route2, text2) {
8363
+ const body = parseErrorBody(text2, status);
8364
+ super(`${method} ${route2} -> ${status}: ${body.detail}`, 1);
7778
8365
  this.status = status;
7779
8366
  this.method = method;
7780
- this.route = route;
8367
+ this.route = route2;
7781
8368
  this.text = text2;
7782
8369
  this.code = body.code;
7783
8370
  }
@@ -7791,6 +8378,14 @@ var init_config = __esm({
7791
8378
  });
7792
8379
 
7793
8380
  // src/cli/runtime/local.ts
8381
+ function forwardedEnv() {
8382
+ return Object.fromEntries(
8383
+ FORWARDED_ENV.flatMap((name) => {
8384
+ const value = process.env[name];
8385
+ return value ? [[name, value]] : [];
8386
+ })
8387
+ );
8388
+ }
7794
8389
  function tailOf(output) {
7795
8390
  return output.length > DIAGNOSTIC_TAIL ? `\u2026${output.slice(-DIAGNOSTIC_TAIL)}` : output;
7796
8391
  }
@@ -7908,7 +8503,7 @@ async function localBridge(request, local, opts = {}) {
7908
8503
  PATH: process.env.PATH ?? "",
7909
8504
  HOME: process.env.HOME ?? "",
7910
8505
  TMPDIR: process.env.TMPDIR ?? "",
7911
- ...process.env.VIRTUAL_ENV ? { VIRTUAL_ENV: process.env.VIRTUAL_ENV } : {},
8506
+ ...forwardedEnv(),
7912
8507
  GATEWAY_RUNTIME_EXECUTE: "1"
7913
8508
  }
7914
8509
  }
@@ -7954,7 +8549,7 @@ async function localBridge(request, local, opts = {}) {
7954
8549
  child.stdin.end(input);
7955
8550
  });
7956
8551
  }
7957
- var import_node_child_process2, fs7, net, path8, MIN_PYTHON, MIN_PYTHON_LABEL, DIAGNOSTIC_TAIL, BRIDGE_BOOTSTRAP, pythonCache, pythonProbes, PYTHON_CANDIDATES, UV_FIND;
8552
+ var import_node_child_process2, fs7, net, path8, MIN_PYTHON, MIN_PYTHON_LABEL, DIAGNOSTIC_TAIL, FORWARDED_ENV, BRIDGE_BOOTSTRAP, pythonCache, pythonProbes, PYTHON_CANDIDATES, UV_FIND;
7958
8553
  var init_local = __esm({
7959
8554
  "src/cli/runtime/local.ts"() {
7960
8555
  "use strict";
@@ -7967,6 +8562,7 @@ var init_local = __esm({
7967
8562
  MIN_PYTHON = [3, 12];
7968
8563
  MIN_PYTHON_LABEL = MIN_PYTHON.join(".");
7969
8564
  DIAGNOSTIC_TAIL = 600;
8565
+ FORWARDED_ENV = ["VIRTUAL_ENV", "GATEWAY_SNAPSHOT_STORE"];
7970
8566
  BRIDGE_BOOTSTRAP = `import sys,runpy,types,os
7971
8567
  root=sys.argv[1]
7972
8568
  package=types.ModuleType('gatewaysdk')
@@ -8119,8 +8715,8 @@ async function runtime(creds, request, opts = {}) {
8119
8715
  throw new CliError(
8120
8716
  "This needs the schema runtime (the CLI bundles it) or platform credentials (`gateway auth login`). " + localRuntimeReason()
8121
8717
  );
8122
- const route = "/api/public/worlds/runtime";
8123
- const res = await new PlatformTransport(creds).send("POST", route, request, {
8718
+ const route2 = "/api/public/worlds/runtime";
8719
+ const res = await new PlatformTransport(creds).send("POST", route2, request, {
8124
8720
  timeoutMs: opts.timeoutMs ?? RUNTIME_TIMEOUT_MS
8125
8721
  });
8126
8722
  let payload = null;
@@ -8132,8 +8728,8 @@ async function runtime(creds, request, opts = {}) {
8132
8728
  const detail = detailFrom(payload);
8133
8729
  if (detail) throw new BridgeRejected(detail);
8134
8730
  if (!res.ok)
8135
- throw new CliError(`POST ${route} (${request.command}) -> ${res.status}: ${res.text.slice(0, 600)}`, 1);
8136
- if (payload === null) throw new CliError(`POST ${route} (${request.command}) returned non-JSON`, 1);
8731
+ throw new CliError(`POST ${route2} (${request.command}) -> ${res.status}: ${res.text.slice(0, 600)}`, 1);
8732
+ if (payload === null) throw new CliError(`POST ${route2} (${request.command}) returned non-JSON`, 1);
8137
8733
  return payload;
8138
8734
  }
8139
8735
  var fs8, path9, MAX_WORLD_FILES, RUNTIME_TIMEOUT_MS, SKIP_DIRS, BridgeRejected, YAML_NAME, YAML_NEEDS_PYYAML, YAML_NOT_ON_PLATFORM, RuntimeRoute;
@@ -8602,11 +9198,15 @@ function isSettled(status) {
8602
9198
  if (status.state !== "applied") return true;
8603
9199
  return status.dryRun === true || status.publish !== "now" || !status.snapshotId;
8604
9200
  }
9201
+ function worldDataPollMs() {
9202
+ const raw = Number(process.env.GATEWAY_WORLD_DATA_POLL_MS ?? 1e3);
9203
+ return Number.isFinite(raw) && raw >= 0 ? raw : 1e3;
9204
+ }
8605
9205
  function uploadHeadersFor(gz) {
8606
9206
  return {
8607
9207
  "content-type": "application/gzip",
8608
9208
  "content-length": String(gz.length),
8609
- "x-amz-checksum-sha256": (0, import_node_crypto9.createHash)("sha256").update(gz).digest("base64")
9209
+ "x-amz-checksum-sha256": (0, import_node_crypto10.createHash)("sha256").update(gz).digest("base64")
8610
9210
  };
8611
9211
  }
8612
9212
  async function forEachLimited(items, limit, fn) {
@@ -8644,6 +9244,8 @@ async function waitForBatch(client2, batchId, opts = {}) {
8644
9244
  last = phase;
8645
9245
  }
8646
9246
  if (isSettled(status)) return status;
9247
+ if (opts.deadlineMs !== void 0 && (opts.now ?? Date.now)() >= opts.deadlineMs)
9248
+ return status;
8647
9249
  await sleep5(delay);
8648
9250
  delay = Math.min(1e4, Math.round(delay * 1.5));
8649
9251
  }
@@ -8652,11 +9254,11 @@ function phaseLine(status) {
8652
9254
  const phase = status.progress?.phase;
8653
9255
  return phase ? `${status.state} (${phase})` : status.state;
8654
9256
  }
8655
- var import_node_crypto9, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
9257
+ var import_node_crypto10, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
8656
9258
  var init_batches = __esm({
8657
9259
  "src/cli/platform/worldData/batches.ts"() {
8658
9260
  "use strict";
8659
- import_node_crypto9 = require("crypto");
9261
+ import_node_crypto10 = require("crypto");
8660
9262
  fs11 = __toESM(require("fs"));
8661
9263
  init_config();
8662
9264
  init_router();
@@ -8695,11 +9297,6 @@ var init_batches = __esm({
8695
9297
  }
8696
9298
  );
8697
9299
  }
8698
- /**
8699
- * Stage a project-drive rows file as one chunk, on the platform: the server
8700
- * streams it out of drive storage into chunk storage and answers with the
8701
- * digest and gzipped size it derived. No bytes pass through this process.
8702
- */
8703
9300
  async stageDrive(batchId, chunk) {
8704
9301
  const staged = await api(this.creds, "POST", `${this.base}/batches/${batchId}/chunks`, {
8705
9302
  ordinal: chunk.ordinal,
@@ -8753,11 +9350,6 @@ var init_batches = __esm({
8753
9350
  message ? { message } : {}
8754
9351
  );
8755
9352
  }
8756
- /**
8757
- * PUT the gzipped chunk to its presigned URL with exactly the headers the
8758
- * URL was signed for (the platform's `uploadHeaders`; the same three when it
8759
- * sends none), with backoff on a dropped connection or a 5xx.
8760
- */
8761
9353
  async put(uploadUrl, gz, signed) {
8762
9354
  const headers = signed ?? uploadHeadersFor(gz);
8763
9355
  const delays = [500, 1500, 4e3];
@@ -8784,7 +9376,6 @@ var init_batches = __esm({
8784
9376
  await this.sleep(delays[attempt]);
8785
9377
  }
8786
9378
  }
8787
- /** Register, upload unless the server already holds the content, confirm. */
8788
9379
  async upload(batchId, chunk) {
8789
9380
  const registered = await this.register(batchId, chunk);
8790
9381
  if (!registered.uploaded) {
@@ -8850,12 +9441,12 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
8850
9441
  const gz = gzipDeterministic(raw, { name: chunkName(ordinal) });
8851
9442
  return {
8852
9443
  ordinal,
8853
- digest: (0, import_node_crypto10.createHash)("sha256").update(gz).digest("hex"),
9444
+ digest: (0, import_node_crypto11.createHash)("sha256").update(gz).digest("hex"),
8854
9445
  bytes: gz.length,
8855
9446
  rows,
8856
9447
  entity,
8857
9448
  rawBytes: raw.length,
8858
- contentSha256: (0, import_node_crypto10.createHash)("sha256").update(raw).digest("hex"),
9449
+ contentSha256: (0, import_node_crypto11.createHash)("sha256").update(raw).digest("hex"),
8859
9450
  firstRow,
8860
9451
  gz
8861
9452
  };
@@ -8895,11 +9486,11 @@ function crc32(data) {
8895
9486
  crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
8896
9487
  return (crc ^ 4294967295) >>> 0;
8897
9488
  }
8898
- var import_node_crypto10, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
9489
+ var import_node_crypto11, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
8899
9490
  var init_chunker = __esm({
8900
9491
  "src/cli/platform/worldData/chunker.ts"() {
8901
9492
  "use strict";
8902
- import_node_crypto10 = require("crypto");
9493
+ import_node_crypto11 = require("crypto");
8903
9494
  import_node_zlib3 = require("zlib");
8904
9495
  init_json();
8905
9496
  DEFAULT_CHUNK_BYTES = 64 * 1024 * 1024;
@@ -8925,22 +9516,33 @@ async function pushRows(creds, slug, rows, opts = {}) {
8925
9516
  publish: opts.publish ?? "now",
8926
9517
  ...opts.message ? { message: opts.message } : {}
8927
9518
  });
8928
- if (!opened.batchId) throw new Error("the platform opened no batch (no batchId in the answer)");
9519
+ if (!opened.batchId)
9520
+ throw new Error("the platform opened no batch (no batchId in the answer)");
8929
9521
  const tagged = (async function* () {
8930
9522
  for (const [entity, listed] of Object.entries(rows))
8931
9523
  for (let index2 = 0; index2 < listed.length; index2++)
8932
- yield { entity, row: parseJson(JSON.stringify(listed[index2])), where: `${entity}[${index2}]` };
9524
+ yield {
9525
+ entity,
9526
+ row: parseJson(JSON.stringify(listed[index2])),
9527
+ where: `${entity}[${index2}]`
9528
+ };
8933
9529
  })();
8934
- const chunks = buildChunks(tagged, { chunkBytes: opts.chunkBytes ?? DEFAULT_CHUNK_BYTES, chunkRows: null, entity: null });
8935
- await forEachLimited(chunks, Math.max(1, opts.parallel ?? 4), async (chunk) => {
8936
- await client2.upload(opened.batchId, chunk);
9530
+ const chunks = buildChunks(tagged, {
9531
+ chunkBytes: opts.chunkBytes ?? DEFAULT_CHUNK_BYTES,
9532
+ chunkRows: null,
9533
+ entity: null
8937
9534
  });
9535
+ await forEachLimited(
9536
+ chunks,
9537
+ Math.max(1, opts.parallel ?? 4),
9538
+ async (chunk) => {
9539
+ await client2.upload(opened.batchId, chunk);
9540
+ }
9541
+ );
8938
9542
  await client2.complete(opened.batchId);
8939
- return waitForBatch(client2, opened.batchId, { initialDelayMs: pollMs() });
8940
- }
8941
- function pollMs() {
8942
- const raw = Number(process.env.GATEWAY_WORLD_DATA_POLL_MS ?? 1e3);
8943
- return Number.isFinite(raw) && raw >= 0 ? raw : 1e3;
9543
+ return waitForBatch(client2, opened.batchId, {
9544
+ initialDelayMs: worldDataPollMs()
9545
+ });
8944
9546
  }
8945
9547
  var init_push = __esm({
8946
9548
  "src/cli/platform/worldData/push.ts"() {
@@ -9189,12 +9791,12 @@ var init_ingest = __esm({
9189
9791
  });
9190
9792
 
9191
9793
  // src/worlds/editSessions.ts
9192
- var WORLDS, WorldEditClient, TASK_EDITS, TaskEditClient;
9794
+ var WORLDS2, WorldEditClient, TASK_EDITS, TaskEditClient;
9193
9795
  var init_editSessions = __esm({
9194
9796
  "src/worlds/editSessions.ts"() {
9195
9797
  "use strict";
9196
9798
  init_worlds();
9197
- WORLDS = "/api/public/worlds";
9799
+ WORLDS2 = "/api/public/worlds";
9198
9800
  WorldEditClient = class {
9199
9801
  constructor(options = {}) {
9200
9802
  this.options = options;
@@ -9206,19 +9808,19 @@ var init_editSessions = __esm({
9206
9808
  if (query.status) qs3.set("status", query.status);
9207
9809
  if (query.limit !== void 0) qs3.set("limit", String(query.limit));
9208
9810
  const suffix = qs3.size ? `?${qs3.toString()}` : "";
9209
- return apiRequest(this.options, "GET", `${WORLDS}/${encodeURIComponent(slug)}/edits${suffix}`);
9811
+ return apiRequest(this.options, "GET", `${WORLDS2}/${encodeURIComponent(slug)}/edits${suffix}`);
9210
9812
  }
9211
9813
  /** Seal a session into a version on main (the credential's current one when `sessionId` is omitted). */
9212
9814
  close(slug, input = {}) {
9213
- return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/close`, input);
9815
+ return apiRequest(this.options, "POST", `${WORLDS2}/${encodeURIComponent(slug)}/edits/close`, input);
9214
9816
  }
9215
9817
  /** Drop the session's private branch without making a version. */
9216
9818
  discard(slug, input = {}) {
9217
- return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/discard`, input);
9819
+ return apiRequest(this.options, "POST", `${WORLDS2}/${encodeURIComponent(slug)}/edits/discard`, input);
9218
9820
  }
9219
9821
  /** Undo a sealed session (source and data) as a new sealed session. */
9220
9822
  rollback(slug, input) {
9221
- return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/rollback`, input);
9823
+ return apiRequest(this.options, "POST", `${WORLDS2}/${encodeURIComponent(slug)}/edits/rollback`, input);
9222
9824
  }
9223
9825
  };
9224
9826
  TASK_EDITS = "/api/public/world-task-edits";
@@ -9372,15 +9974,27 @@ __export(worlds_exports, {
9372
9974
  NativeComputer: () => NativeComputer,
9373
9975
  OpenAIComputer: () => OpenAIComputer,
9374
9976
  OpenAIPreviewComputer: () => OpenAIPreviewComputer,
9977
+ PLATFORM_SESSION_HEADER: () => PLATFORM_SESSION_HEADER,
9375
9978
  PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
9376
9979
  PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
9377
9980
  PendingSafetyChecks: () => PendingSafetyChecks,
9378
9981
  PlatformTransport: () => PlatformTransport,
9379
9982
  PushSlugConflict: () => PushSlugConflict,
9380
9983
  RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
9984
+ REQUESTS_NOT_RECORDED: () => REQUESTS_NOT_RECORDED,
9985
+ REQUEST_BODY_CAPTURE_BYTES: () => REQUEST_BODY_CAPTURE_BYTES,
9986
+ REQUEST_LOG_PAGE_MAX: () => REQUEST_LOG_PAGE_MAX,
9381
9987
  RetryPolicy: () => RetryPolicy,
9988
+ SANDBOX_EXEC_REPORT_MARGIN_MS: () => SANDBOX_EXEC_REPORT_MARGIN_MS,
9989
+ SANDBOX_EXEC_START_ATTEMPTS: () => SANDBOX_EXEC_START_ATTEMPTS,
9990
+ SANDBOX_EXEC_TIMEOUT_MAX_S: () => SANDBOX_EXEC_TIMEOUT_MAX_S,
9991
+ SANDBOX_EXEC_WAIT_MS: () => SANDBOX_EXEC_WAIT_MS,
9992
+ SANDBOX_FILE_MAX_BYTES: () => SANDBOX_FILE_MAX_BYTES,
9382
9993
  SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
9994
+ SANDBOX_WRITE_CHUNK_BYTES: () => SANDBOX_WRITE_CHUNK_BYTES,
9995
+ SANDBOX_WRITE_SKIPPED: () => SANDBOX_WRITE_SKIPPED,
9383
9996
  SECRET_KEY: () => SECRET_KEY,
9997
+ SESSION_AUTH_MODES: () => SESSION_AUTH_MODES,
9384
9998
  SESSION_STATES: () => SESSION_STATES,
9385
9999
  SPAN_PREFIX: () => SPAN_PREFIX,
9386
10000
  STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
@@ -9392,17 +10006,24 @@ __export(worlds_exports, {
9392
10006
  TOOL_CONTRACT_UNREAD: () => TOOL_CONTRACT_UNREAD,
9393
10007
  TRANSFORMS: () => TRANSFORMS,
9394
10008
  TaskEditClient: () => TaskEditClient,
10009
+ TaskGrades: () => TaskGrades,
9395
10010
  TaskRun: () => TaskRun,
9396
10011
  TaskSessions: () => TaskSessions,
9397
10012
  TransportCause: () => TransportCause,
9398
10013
  UnreachableError: () => UnreachableError,
9399
10014
  VERIFIER_REWARD_PREFIX: () => VERIFIER_REWARD_PREFIX,
9400
10015
  WHITESPACE: () => WHITESPACE,
10016
+ WORLD_REQUEST_VIAS: () => WORLD_REQUEST_VIAS,
10017
+ WORLD_WEBHOOK_PAGE_MAX: () => WORLD_WEBHOOK_PAGE_MAX,
9401
10018
  WorldBrowser: () => WorldBrowser,
9402
10019
  WorldCallTooLarge: () => WorldCallTooLarge,
9403
10020
  WorldEditClient: () => WorldEditClient,
9404
10021
  WorldNotice: () => WorldNotice,
10022
+ WorldRequestFilterError: () => WorldRequestFilterError,
10023
+ WorldRequestLedger: () => WorldRequestLedger,
9405
10024
  WorldRequestLog: () => WorldRequestLog,
10025
+ WorldRequestQuery: () => WorldRequestQuery,
10026
+ WorldRequestsNotRecorded: () => WorldRequestsNotRecorded,
9406
10027
  WorldSandboxClient: () => WorldSandboxClient,
9407
10028
  WorldSession: () => WorldSession,
9408
10029
  WorldSessionCallError: () => WorldSessionCallError,
@@ -9412,18 +10033,23 @@ __export(worlds_exports, {
9412
10033
  WorldSurfaceUnavailable: () => WorldSurfaceUnavailable,
9413
10034
  WorldTask: () => WorldTask,
9414
10035
  WorldToolsUnread: () => WorldToolsUnread,
10036
+ WorldWebhookForwarder: () => WorldWebhookForwarder,
10037
+ WriteTreeFilter: () => WriteTreeFilter,
9415
10038
  aggregateTaskGrade: () => aggregateTaskGrade,
9416
10039
  apiRequest: () => apiRequest,
9417
10040
  applyTransforms: () => applyTransforms,
9418
10041
  archiveMode: () => archiveMode,
9419
10042
  assertBrowserTier: () => assertBrowserTier,
10043
+ assertSessionAuthMode: () => assertSessionAuthMode,
9420
10044
  assertTaskRef: () => assertTaskRef,
9421
10045
  attachManifest: () => attachManifest,
9422
10046
  attachSession: () => attachSession,
9423
10047
  attachTask: () => attachTask,
9424
10048
  buildFileManifest: () => buildFileManifest,
9425
10049
  buildSourceTarball: () => buildSourceTarball,
10050
+ capabilityLabel: () => capabilityLabel,
9426
10051
  captureToolCalls: () => captureToolCalls,
10052
+ carriedWarnings: () => carriedWarnings,
9427
10053
  checkoutIdentity: () => checkoutIdentity,
9428
10054
  closeConnection: () => closeConnection,
9429
10055
  collectArchiveRelPaths: () => collectArchiveRelPaths,
@@ -9442,7 +10068,9 @@ __export(worlds_exports, {
9442
10068
  idleWarning: () => idleWarning,
9443
10069
  ingest: () => ingest,
9444
10070
  ingestToolCalls: () => ingestToolCalls,
10071
+ invalidFields: () => invalidFields,
9445
10072
  isBrowserGone: () => isBrowserGone,
10073
+ isSandboxCommitPending: () => isSandboxCommitPending,
9446
10074
  isSandboxImportPending: () => isSandboxImportPending,
9447
10075
  isTaskIdRef: () => isTaskIdRef,
9448
10076
  isTaskManifest: () => isTaskManifest,
@@ -9453,6 +10081,7 @@ __export(worlds_exports, {
9453
10081
  listSessions: () => listSessions,
9454
10082
  listTaskSessions: () => listTaskSessions,
9455
10083
  listTasks: () => listTasks,
10084
+ listWebhooks: () => listWebhooks,
9456
10085
  localTreeState: () => localTreeState,
9457
10086
  messageOf: () => messageOf,
9458
10087
  migrateProjectWorlds: () => migrateProjectWorlds,
@@ -9489,6 +10118,7 @@ __export(worlds_exports, {
9489
10118
  resolveBrowserMode: () => resolveBrowserMode,
9490
10119
  resolvePushSlug: () => resolvePushSlug,
9491
10120
  roundForm: () => roundForm,
10121
+ rowsRefusal: () => rowsRefusal,
9492
10122
  runSessions: () => runSessions,
9493
10123
  runSet: () => runSet,
9494
10124
  runTask: () => runTask,
@@ -9517,27 +10147,42 @@ __export(worlds_exports, {
9517
10147
  validateWorld: () => validateWorld,
9518
10148
  waitForRun: () => waitForRun,
9519
10149
  withoutUiToken: () => withoutUiToken,
10150
+ worldRequestsUnrecorded: () => worldRequestsUnrecorded,
9520
10151
  writeLocalMeta: () => writeLocalMeta
9521
10152
  });
9522
- function parseErrorBody(text2, limit = 600) {
9523
- const raw = { detail: text2.slice(0, limit), code: null };
10153
+ function edgeAnswer(text2, status) {
10154
+ if (status !== void 0 && status >= 500) return EDGE_ANSWERS[status] ?? EDGE_FAILURE;
10155
+ return /^\s*</.test(text2) ? EDGE_PAGE : null;
10156
+ }
10157
+ function parseErrorBody(text2, status) {
10158
+ const raw = { detail: text2.slice(0, DETAIL_LIMIT), code: null };
9524
10159
  let parsed;
9525
10160
  try {
9526
10161
  parsed = JSON.parse(text2);
9527
10162
  } catch {
9528
- return raw;
10163
+ return { detail: (edgeAnswer(text2, status) ?? text2).slice(0, DETAIL_LIMIT), code: null };
9529
10164
  }
9530
10165
  if (parsed === null || typeof parsed !== "object") return raw;
9531
- const { message, code } = parsed;
10166
+ const { message, code, error } = parsed;
9532
10167
  const stableCode = typeof code === "string" ? code : null;
9533
10168
  if (typeof message !== "string") return { ...raw, code: stableCode };
9534
- if (stableCode === null)
9535
- return { detail: message.slice(0, limit), code: null };
10169
+ const fields = invalidFields(error);
10170
+ const said = fields ? `${message}: ${fields}` : message;
10171
+ if (stableCode === null) return { detail: said.slice(0, DETAIL_LIMIT), code: null };
9536
10172
  return {
9537
- detail: `${message} (${stableCode})`.slice(0, limit),
10173
+ detail: `${said} (${stableCode})`.slice(0, DETAIL_LIMIT),
9538
10174
  code: stableCode
9539
10175
  };
9540
10176
  }
10177
+ function invalidFields(error) {
10178
+ const issues = Array.isArray(error) ? error : [];
10179
+ return issues.filter(
10180
+ (issue) => issue !== null && typeof issue === "object" && typeof issue.message === "string"
10181
+ ).map((issue) => {
10182
+ const path17 = Array.isArray(issue.path) ? issue.path.map(String).join(".") : "";
10183
+ return path17 ? `${path17}: ${issue.message}` : issue.message;
10184
+ }).join("; ");
10185
+ }
9541
10186
  async function apiRequest(options, method, path17, body, init3 = {}) {
9542
10187
  const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path17, body, init3);
9543
10188
  if (!reply.ok) throw new ApiError(reply.status, method, path17, reply.text);
@@ -9716,7 +10361,7 @@ async function resolveWorld(slugRef, slug, ref, pin, options) {
9716
10361
  }
9717
10362
  return world;
9718
10363
  }
9719
- var ApiError, WorldTask, WorldSet;
10364
+ var ApiError, DETAIL_LIMIT, EDGE_ANSWERS, EDGE_FAILURE, EDGE_PAGE, WorldTask, WorldSet;
9720
10365
  var init_worlds = __esm({
9721
10366
  "src/worlds/index.ts"() {
9722
10367
  "use strict";
@@ -9729,6 +10374,7 @@ var init_worlds = __esm({
9729
10374
  init_sessionContract();
9730
10375
  init_taskRef();
9731
10376
  init_tasks();
10377
+ init_taskGrades();
9732
10378
  init_taskSessions();
9733
10379
  init_taskRun();
9734
10380
  init_setRun();
@@ -9737,6 +10383,8 @@ var init_worlds = __esm({
9737
10383
  init_browser();
9738
10384
  init_surfaceDescriptor();
9739
10385
  init_requestLog();
10386
+ init_requestLedger();
10387
+ init_webhooks();
9740
10388
  init_browserReconnect();
9741
10389
  init_nativeComputer();
9742
10390
  init_hub();
@@ -9753,7 +10401,7 @@ var init_worlds = __esm({
9753
10401
  init_worldNotice();
9754
10402
  ApiError = class extends Error {
9755
10403
  constructor(status, method, path17, text2) {
9756
- const parsed = parseErrorBody(text2);
10404
+ const parsed = parseErrorBody(text2, status);
9757
10405
  super(`${method} ${path17} -> ${status}: ${parsed.detail}`);
9758
10406
  this.status = status;
9759
10407
  this.text = text2;
@@ -9764,6 +10412,14 @@ var init_worlds = __esm({
9764
10412
  text;
9765
10413
  code;
9766
10414
  };
10415
+ DETAIL_LIMIT = 600;
10416
+ EDGE_ANSWERS = {
10417
+ 502: "Bad Gateway from the load balancer in front of the platform, not the platform's answer: the web server dropped the connection or restarted mid-request. Retry; if it repeats, the platform is restarting or overloaded.",
10418
+ 503: "Service Unavailable from the load balancer in front of the platform, not the platform's answer: no web server was ready to take the request (a deploy or a restart). Retry in a minute.",
10419
+ 504: "Gateway Time-out from the load balancer in front of the platform, not the platform's answer: the request sent nothing back within the load balancer's idle timeout (60 s unless the deployment raises it: Helm ingress.idleTimeoutSeconds) and was cut there, though the platform may still be running it. Check what it changed before you retry."
10420
+ };
10421
+ EDGE_FAILURE = "The platform failed without its JSON error body: a proxy in front of it answered, or the server stopped before its error handler ran. Retry; if it repeats, report the request and the time.";
10422
+ EDGE_PAGE = "An HTML page answered instead of the platform's JSON: a proxy in front of the platform, or the configured host is not the platform.";
9767
10423
  WorldTask = class {
9768
10424
  constructor(world, name, variant) {
9769
10425
  this.world = world;
@@ -9799,12 +10455,7 @@ var init_worlds = __esm({
9799
10455
  }
9800
10456
  return hit;
9801
10457
  }
9802
- /**
9803
- * Open a LIVE session against one of this world's tasks — a bundled task's
9804
- * name or an inline `WorldTaskSpec`: the platform boots (or reuses) a warm
9805
- * container, and your agent calls its tools through the platform. See
9806
- * worlds/session.ts.
9807
- */
10458
+ /** Open a live session on a bundled task's name or an inline `WorldTaskSpec`; the platform boots or reuses a warm container. */
9808
10459
  async open(task, opts = {}) {
9809
10460
  const { openSession: openSession2 } = await Promise.resolve().then(() => (init_session2(), session_exports2));
9810
10461
  return openSession2(this.slug, {
@@ -9816,11 +10467,7 @@ var init_worlds = __esm({
9816
10467
  options: this.options
9817
10468
  });
9818
10469
  }
9819
- /**
9820
- * Start a HOSTED run of a run config against this world — the platform
9821
- * executes the (Python) world in parallel containers per the config's
9822
- * `parallelism` and files one graded run per model. Returns those runs.
9823
- */
10470
+ /** Start a hosted run of a run config on this version (or `opts.versionId`): one graded run per model, provenance detected unless given. */
9824
10471
  async dispatch(runConfigId, opts = {}) {
9825
10472
  const provenance = opts.provenance ?? detectProvenance();
9826
10473
  return apiRequest(
@@ -9902,6 +10549,7 @@ __export(src_exports, {
9902
10549
  NativeComputer: () => NativeComputer,
9903
10550
  OpenAIComputer: () => OpenAIComputer,
9904
10551
  OpenAIPreviewComputer: () => OpenAIPreviewComputer,
10552
+ PLATFORM_SESSION_HEADER: () => PLATFORM_SESSION_HEADER,
9905
10553
  PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
9906
10554
  PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
9907
10555
  PendingSafetyChecks: () => PendingSafetyChecks,
@@ -9912,6 +10560,9 @@ __export(src_exports, {
9912
10560
  PushSlugConflict: () => PushSlugConflict,
9913
10561
  RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
9914
10562
  REPLAY_ENVIRONMENT: () => REPLAY_ENVIRONMENT,
10563
+ REQUESTS_NOT_RECORDED: () => REQUESTS_NOT_RECORDED,
10564
+ REQUEST_BODY_CAPTURE_BYTES: () => REQUEST_BODY_CAPTURE_BYTES,
10565
+ REQUEST_LOG_PAGE_MAX: () => REQUEST_LOG_PAGE_MAX,
9915
10566
  ReplayCase: () => ReplayCase,
9916
10567
  ReplayCheck: () => ReplayCheck,
9917
10568
  ReplayError: () => ReplayError,
@@ -9919,8 +10570,16 @@ __export(src_exports, {
9919
10570
  ReplaySuite: () => ReplaySuite,
9920
10571
  ReplayTask: () => ReplayTask,
9921
10572
  RetryPolicy: () => RetryPolicy,
10573
+ SANDBOX_EXEC_REPORT_MARGIN_MS: () => SANDBOX_EXEC_REPORT_MARGIN_MS,
10574
+ SANDBOX_EXEC_START_ATTEMPTS: () => SANDBOX_EXEC_START_ATTEMPTS,
10575
+ SANDBOX_EXEC_TIMEOUT_MAX_S: () => SANDBOX_EXEC_TIMEOUT_MAX_S,
10576
+ SANDBOX_EXEC_WAIT_MS: () => SANDBOX_EXEC_WAIT_MS,
10577
+ SANDBOX_FILE_MAX_BYTES: () => SANDBOX_FILE_MAX_BYTES,
9922
10578
  SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
10579
+ SANDBOX_WRITE_CHUNK_BYTES: () => SANDBOX_WRITE_CHUNK_BYTES,
10580
+ SANDBOX_WRITE_SKIPPED: () => SANDBOX_WRITE_SKIPPED,
9923
10581
  SECRET_KEY: () => SECRET_KEY,
10582
+ SESSION_AUTH_MODES: () => SESSION_AUTH_MODES,
9924
10583
  SESSION_STATES: () => SESSION_STATES,
9925
10584
  SPAN_PREFIX: () => SPAN_PREFIX,
9926
10585
  STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
@@ -9940,6 +10599,7 @@ __export(src_exports, {
9940
10599
  TOOL_CONTRACT_UNREAD: () => TOOL_CONTRACT_UNREAD,
9941
10600
  TRANSFORMS: () => TRANSFORMS,
9942
10601
  TaskEditClient: () => TaskEditClient,
10602
+ TaskGrades: () => TaskGrades,
9943
10603
  TaskRun: () => TaskRun,
9944
10604
  TaskSessions: () => TaskSessions,
9945
10605
  ToolStubRegistry: () => ToolStubRegistry,
@@ -9950,11 +10610,17 @@ __export(src_exports, {
9950
10610
  UsersClient: () => UsersClient,
9951
10611
  VERIFIER_REWARD_PREFIX: () => VERIFIER_REWARD_PREFIX,
9952
10612
  WHITESPACE: () => WHITESPACE,
10613
+ WORLD_REQUEST_VIAS: () => WORLD_REQUEST_VIAS,
10614
+ WORLD_WEBHOOK_PAGE_MAX: () => WORLD_WEBHOOK_PAGE_MAX,
9953
10615
  WorldBrowser: () => WorldBrowser,
9954
10616
  WorldCallTooLarge: () => WorldCallTooLarge,
9955
10617
  WorldEditClient: () => WorldEditClient,
9956
10618
  WorldNotice: () => WorldNotice,
10619
+ WorldRequestFilterError: () => WorldRequestFilterError,
10620
+ WorldRequestLedger: () => WorldRequestLedger,
9957
10621
  WorldRequestLog: () => WorldRequestLog,
10622
+ WorldRequestQuery: () => WorldRequestQuery,
10623
+ WorldRequestsNotRecorded: () => WorldRequestsNotRecorded,
9958
10624
  WorldSandboxClient: () => WorldSandboxClient,
9959
10625
  WorldSession: () => WorldSession,
9960
10626
  WorldSessionCallError: () => WorldSessionCallError,
@@ -9964,6 +10630,8 @@ __export(src_exports, {
9964
10630
  WorldSurfaceUnavailable: () => WorldSurfaceUnavailable,
9965
10631
  WorldTask: () => WorldTask,
9966
10632
  WorldToolsUnread: () => WorldToolsUnread,
10633
+ WorldWebhookForwarder: () => WorldWebhookForwarder,
10634
+ WriteTreeFilter: () => WriteTreeFilter,
9967
10635
  addExperimentAttributes: () => addExperimentAttributes,
9968
10636
  aggregateTaskGrade: () => aggregateTaskGrade,
9969
10637
  apiRequest: () => apiRequest,
@@ -9971,6 +10639,7 @@ __export(src_exports, {
9971
10639
  archiveMode: () => archiveMode,
9972
10640
  assembleManifest: () => assembleManifest,
9973
10641
  assertBrowserTier: () => assertBrowserTier,
10642
+ assertSessionAuthMode: () => assertSessionAuthMode,
9974
10643
  assertTaskRef: () => assertTaskRef,
9975
10644
  assignVariant: () => assignVariant,
9976
10645
  attachManifest: () => attachManifest,
@@ -9980,7 +10649,9 @@ __export(src_exports, {
9980
10649
  buildFileManifest: () => buildFileManifest,
9981
10650
  buildSourceTarball: () => buildSourceTarball,
9982
10651
  canonicalJson: () => canonicalJson,
10652
+ capabilityLabel: () => capabilityLabel,
9983
10653
  captureToolCalls: () => captureToolCalls,
10654
+ carriedWarnings: () => carriedWarnings,
9984
10655
  checkoutIdentity: () => checkoutIdentity,
9985
10656
  clearExperimentContext: () => clearExperimentContext,
9986
10657
  closeConnection: () => closeConnection,
@@ -10016,7 +10687,9 @@ __export(src_exports, {
10016
10687
  idleWarning: () => idleWarning,
10017
10688
  ingest: () => ingest,
10018
10689
  ingestToolCalls: () => ingestToolCalls,
10690
+ invalidFields: () => invalidFields,
10019
10691
  isBrowserGone: () => isBrowserGone,
10692
+ isSandboxCommitPending: () => isSandboxCommitPending,
10020
10693
  isSandboxImportPending: () => isSandboxImportPending,
10021
10694
  isTaskIdRef: () => isTaskIdRef,
10022
10695
  isTaskManifest: () => isTaskManifest,
@@ -10027,6 +10700,7 @@ __export(src_exports, {
10027
10700
  listSessions: () => listSessions,
10028
10701
  listTaskSessions: () => listTaskSessions,
10029
10702
  listTasks: () => listTasks,
10703
+ listWebhooks: () => listWebhooks,
10030
10704
  loadSession: () => loadSession,
10031
10705
  localTreeState: () => localTreeState,
10032
10706
  memory: () => memory,
@@ -10073,6 +10747,7 @@ __export(src_exports, {
10073
10747
  resolvePushSlug: () => resolvePushSlug,
10074
10748
  resolveUserId: () => resolveUserId,
10075
10749
  roundForm: () => roundForm,
10750
+ rowsRefusal: () => rowsRefusal,
10076
10751
  runSessions: () => runSessions,
10077
10752
  runSet: () => runSet,
10078
10753
  runSuite: () => runSuite,
@@ -10112,6 +10787,7 @@ __export(src_exports, {
10112
10787
  validateWorld: () => validateWorld,
10113
10788
  waitForRun: () => waitForRun,
10114
10789
  withoutUiToken: () => withoutUiToken,
10790
+ worldRequestsUnrecorded: () => worldRequestsUnrecorded,
10115
10791
  writeLocalMeta: () => writeLocalMeta
10116
10792
  });
10117
10793
  module.exports = __toCommonJS(src_exports);
@@ -12534,7 +13210,7 @@ __export(files_exports, {
12534
13210
  uploadBytes: () => uploadBytes,
12535
13211
  uploadFile: () => uploadFile
12536
13212
  });
12537
- var import_node_crypto11 = require("crypto");
13213
+ var import_node_crypto12 = require("crypto");
12538
13214
  var fs13 = __toESM(require("fs"));
12539
13215
  var path13 = __toESM(require("path"));
12540
13216
  var import_node_stream = require("stream");
@@ -12600,7 +13276,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
12600
13276
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
12601
13277
  }
12602
13278
  async function sha256Base64(localPath) {
12603
- const hash = (0, import_node_crypto11.createHash)("sha256");
13279
+ const hash = (0, import_node_crypto12.createHash)("sha256");
12604
13280
  for await (const chunk of fs13.createReadStream(localPath)) hash.update(chunk);
12605
13281
  return hash.digest("base64");
12606
13282
  }
@@ -12685,7 +13361,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
12685
13361
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
12686
13362
  const target = drivePath(targetPath);
12687
13363
  const contentType = upload.contentType ?? contentTypeFor(target);
12688
- const sha2562 = (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("base64");
13364
+ const sha2562 = (0, import_node_crypto12.createHash)("sha256").update(bytes).digest("base64");
12689
13365
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256: sha2562, ...upload.overwrite ? { overwrite: true } : {} });
12690
13366
  try {
12691
13367
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256: sha2562 });
@@ -12938,10 +13614,10 @@ function swapValue(text2, needle, replacement) {
12938
13614
  }
12939
13615
 
12940
13616
  // src/hooks/standInDigits.ts
12941
- var import_node_crypto12 = require("crypto");
13617
+ var import_node_crypto13 = require("crypto");
12942
13618
  function standInDigits(realDigits, identityName) {
12943
13619
  if (!realDigits) return "";
12944
- const digest = (0, import_node_crypto12.createHash)("sha256").update(`${identityName}:${realDigits}`).digest("hex");
13620
+ const digest = (0, import_node_crypto13.createHash)("sha256").update(`${identityName}:${realDigits}`).digest("hex");
12945
13621
  let digits = "";
12946
13622
  for (let i = 0; i < realDigits.length; i++)
12947
13623
  digits += String(parseInt(digest[i % digest.length], 16) % 10);
@@ -12975,7 +13651,7 @@ var DeclaredStandIn = class _DeclaredStandIn {
12975
13651
  };
12976
13652
 
12977
13653
  // src/hooks/alias.ts
12978
- var import_node_crypto13 = require("crypto");
13654
+ var import_node_crypto14 = require("crypto");
12979
13655
  var GIVEN = [
12980
13656
  "John",
12981
13657
  "Mary",
@@ -13166,7 +13842,7 @@ function findKind(kind, text2) {
13166
13842
  return out;
13167
13843
  }
13168
13844
  function newRunKey() {
13169
- return (0, import_node_crypto13.randomBytes)(32).toString("hex");
13845
+ return (0, import_node_crypto14.randomBytes)(32).toString("hex");
13170
13846
  }
13171
13847
  function canonical(kind, value) {
13172
13848
  const text2 = String(value).normalize("NFKC").trim();
@@ -13223,7 +13899,7 @@ function explodeIp(text2) {
13223
13899
  return groups.map((g) => g.padStart(4, "0")).join(":") + zone;
13224
13900
  }
13225
13901
  function index(runKey, kind, value, salt = "") {
13226
- const digest = (0, import_node_crypto13.createHmac)("sha256", Buffer.from(runKey, "hex")).update(`${kind}:${value}:${salt}`, "utf8").digest();
13902
+ const digest = (0, import_node_crypto14.createHmac)("sha256", Buffer.from(runKey, "hex")).update(`${kind}:${value}:${salt}`, "utf8").digest();
13227
13903
  return digest.readBigUInt64BE(0);
13228
13904
  }
13229
13905
  var pick = (pool, n) => pool[Number(n % BigInt(pool.length))];
@@ -13757,7 +14433,7 @@ var AliasMap = class _AliasMap {
13757
14433
  const existing = this.aliases.get(key2);
13758
14434
  if (existing) return existing.display;
13759
14435
  if (this.aliasDigests.has(digest.toLowerCase())) return digest;
13760
- const standIn = "sha256:" + (0, import_node_crypto13.createHmac)("sha256", Buffer.from(this.runKey, "hex")).update(digest, "utf8").digest("hex");
14436
+ const standIn = "sha256:" + (0, import_node_crypto14.createHmac)("sha256", Buffer.from(this.runKey, "hex")).update(digest, "utf8").digest("hex");
13761
14437
  this.aliasDigests.add(standIn.toLowerCase());
13762
14438
  const alias = {
13763
14439
  kind: "digest",
@@ -13796,9 +14472,9 @@ var AliasMap = class _AliasMap {
13796
14472
  });
13797
14473
  if (alias.role === "private") {
13798
14474
  for (const slug of this.slugs) {
13799
- const standIn = "sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
14475
+ const standIn = "sha256:" + (0, import_node_crypto14.createHash)("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
13800
14476
  alias.variants.push([
13801
- "sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
14477
+ "sha256:" + (0, import_node_crypto14.createHash)("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
13802
14478
  standIn
13803
14479
  ]);
13804
14480
  this.aliasDigests.add(standIn.toLowerCase());
@@ -15815,6 +16491,120 @@ async function buildHandler(spec, aliases, opts) {
15815
16491
  // src/hooks/live.ts
15816
16492
  var fs16 = __toESM(require("fs"));
15817
16493
  var path15 = __toESM(require("path"));
16494
+
16495
+ // src/hooks/vendorAuth.ts
16496
+ var bearer = (auth, value) => ({
16497
+ headers: { authorization: `${prefixesOf(auth)[0]} ${value}` },
16498
+ query: []
16499
+ });
16500
+ var CARRIERS = /* @__PURE__ */ new Map([
16501
+ [
16502
+ "header",
16503
+ (auth, value) => ({
16504
+ headers: {
16505
+ [String(auth.name ?? "").trim().toLowerCase()]: value
16506
+ },
16507
+ query: []
16508
+ })
16509
+ ],
16510
+ ["bearer", bearer],
16511
+ [
16512
+ "basic",
16513
+ (auth, value) => ({
16514
+ headers: {
16515
+ authorization: `Basic ${Buffer.from(basicPair(auth, value)).toString("base64")}`
16516
+ },
16517
+ query: []
16518
+ })
16519
+ ],
16520
+ [
16521
+ "query",
16522
+ (auth, value) => ({
16523
+ headers: {},
16524
+ query: [[String(auth.name ?? "").trim(), value]]
16525
+ })
16526
+ ],
16527
+ ["oauth2", bearer],
16528
+ ["none", () => ({ headers: {}, query: [] })]
16529
+ ]);
16530
+ var AUTH_WORD = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/;
16531
+ var OWNERS = [
16532
+ ["client_id_env", ["oauth2"]],
16533
+ ["credential", ["basic"]],
16534
+ ["prefixes", ["bearer", "oauth2"]],
16535
+ ["scope", ["oauth2"]],
16536
+ ["token_url", ["oauth2"]],
16537
+ ["ttl_seconds", ["oauth2"]]
16538
+ ];
16539
+ var AUTH_MODES = ["vendor", "open"];
16540
+ var positiveSeconds = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1;
16541
+ var NAMED = /* @__PURE__ */ new Set(["header", "query"]);
16542
+ function prefixesOf(auth) {
16543
+ const words2 = auth.prefixes ?? ["Bearer"];
16544
+ const valid = Array.isArray(words2) && words2.length > 0 && words2.every((word) => typeof word === "string" && AUTH_WORD.test(word)) && new Set(words2.map((word) => word.toLowerCase())).size === words2.length;
16545
+ if (!valid)
16546
+ throw new Error(
16547
+ "auth.prefixes lists the distinct words the vendor takes before the key in Authorization"
16548
+ );
16549
+ return words2;
16550
+ }
16551
+ function basicHalf(auth) {
16552
+ const half = auth.credential ?? "user";
16553
+ if (half !== "user" && half !== "password")
16554
+ throw new Error(
16555
+ "auth.credential is the half of the Basic pair the key is: user or password"
16556
+ );
16557
+ return half;
16558
+ }
16559
+ function basicPair(auth, value) {
16560
+ if (value.includes(":")) return value;
16561
+ return basicHalf(auth) === "password" ? `:${value}` : `${value}:`;
16562
+ }
16563
+ var GRAMMAR = /* @__PURE__ */ new Map([
16564
+ ["bearer", prefixesOf],
16565
+ ["oauth2", prefixesOf],
16566
+ ["basic", basicHalf]
16567
+ ]);
16568
+ function authScheme(value) {
16569
+ if (value === void 0) throw new Error("Missing scheme");
16570
+ if (value === "open")
16571
+ throw new Error(
16572
+ 'auth.scheme is how the vendor takes its key; a world whose sessions ask for none is auth.mode = "open"'
16573
+ );
16574
+ if (typeof value !== "string" || !CARRIERS.has(value))
16575
+ throw new Error(
16576
+ `auth.scheme must be one of ${[...CARRIERS.keys()].join(", ")}`
16577
+ );
16578
+ return value;
16579
+ }
16580
+ function vendorAuth(auth) {
16581
+ const scheme = authScheme(auth.scheme);
16582
+ const stray = OWNERS.find(
16583
+ ([key2, owners]) => auth[key2] !== void 0 && !owners.includes(scheme)
16584
+ );
16585
+ if (stray)
16586
+ throw new Error(
16587
+ `${stray[0]} belongs to auth.scheme ${stray[1].join(" or ")}`
16588
+ );
16589
+ if (scheme === "none" && (auth.name ?? auth.secret_env) !== void 0)
16590
+ throw new Error("auth.scheme none takes no name or secret_env");
16591
+ if (NAMED.has(scheme) && auth.name === void 0)
16592
+ throw new Error("Missing name");
16593
+ if (auth.name !== void 0 && (typeof auth.name !== "string" || !auth.name.trim()))
16594
+ throw new Error("name must be a non-empty string");
16595
+ GRAMMAR.get(scheme)?.(auth);
16596
+ if (auth.mode !== void 0 && !AUTH_MODES.includes(auth.mode))
16597
+ throw new Error(`auth.mode is one of ${AUTH_MODES.join(", ")}`);
16598
+ if (auth.ttl_seconds !== void 0 && !positiveSeconds(auth.ttl_seconds))
16599
+ throw new Error("ttl_seconds is a positive whole number of seconds");
16600
+ return { ...auth, scheme };
16601
+ }
16602
+ function carryCredential(auth, value) {
16603
+ const checked = vendorAuth(auth);
16604
+ return CARRIERS.get(checked.scheme)(checked, value);
16605
+ }
16606
+
16607
+ // src/hooks/live.ts
15818
16608
  var USER_AGENT = "gateway-hooks/1 (+https://withgateway.ai)";
15819
16609
  var TAGS = /<(script|style)[^>]*>.*?<\/\1>/gis;
15820
16610
  var STRIP = /<[^>]+>/g;
@@ -16135,7 +16925,9 @@ var HttpTool = class _HttpTool {
16135
16925
  const okStatus = o.ok_status ?? [
16136
16926
  [200, 200]
16137
16927
  ];
16138
- if (!okStatus.some(([low, high]) => response.status >= low && response.status <= high)) {
16928
+ if (!okStatus.some(
16929
+ ([low, high]) => response.status >= low && response.status <= high
16930
+ )) {
16139
16931
  const expected = okStatus.map(([low, high]) => low === high ? String(low) : `${low}-${high}`).join(", ");
16140
16932
  throw new LiveToolError(
16141
16933
  `${this.spec.name}: ${url} answered HTTP ${response.status} (ok_status ${expected}): ${JSON.stringify(body.slice(0, 200))}`,
@@ -16186,7 +16978,8 @@ function readConnection(root) {
16186
16978
  if (!fs16.existsSync(file)) throw new Error(`no connector.toml at ${root}`);
16187
16979
  const raw = parseToml(fs16.readFileSync(file, "utf8"));
16188
16980
  const connector = raw.connector ?? {};
16189
- const auth = raw.auth ?? {};
16981
+ const auth = raw.auth ?? { scheme: "none" };
16982
+ const carrier = vendorAuth(auth);
16190
16983
  const operations = {};
16191
16984
  for (const op of raw.operations ?? []) {
16192
16985
  operations[op.name] = {
@@ -16200,8 +16993,8 @@ function readConnection(root) {
16200
16993
  return {
16201
16994
  slug: connector.slug ?? path15.basename(root),
16202
16995
  baseUrl: (connector.base_url ?? "").replace(/\/+$/, ""),
16203
- scheme: auth.scheme ?? "none",
16204
- ...typeof auth.name === "string" ? { authName: auth.name } : {},
16996
+ scheme: carrier.scheme,
16997
+ carrier,
16205
16998
  ...typeof auth.secret_env === "string" ? { secretEnv: auth.secret_env } : {},
16206
16999
  ...typeof auth.client_id_env === "string" ? { clientIdEnv: auth.client_id_env } : {},
16207
17000
  ...typeof auth.token_url === "string" ? { tokenUrl: auth.token_url } : {},
@@ -16313,13 +17106,9 @@ var ConnectorTool = class {
16313
17106
  };
16314
17107
  for (const [header, variable] of Object.entries(c.extraHeaders))
16315
17108
  headers[header] = this.env(variable, `the ${header} header`);
16316
- const secret = await this.credential();
16317
- if (c.scheme === "header") headers[c.authName ?? ""] = secret ?? "";
16318
- else if (c.scheme === "bearer" || c.scheme === "oauth2")
16319
- headers.authorization = `Bearer ${secret}`;
16320
- else if (c.scheme === "basic")
16321
- headers.authorization = "Basic " + Buffer.from(secret ?? "").toString("base64");
16322
- else if (c.scheme === "query") query.append(c.authName ?? "", secret ?? "");
17109
+ const carried2 = carryCredential(c.carrier, await this.credential() ?? "");
17110
+ Object.assign(headers, carried2.headers);
17111
+ for (const [key2, value] of carried2.query) query.append(key2, value);
16323
17112
  const url = c.baseUrl + pathText + (query.toString() ? `?${query.toString()}` : "");
16324
17113
  const response = await fetch(url, {
16325
17114
  method: this.operation.method,
@@ -16794,7 +17583,7 @@ var RedactionAudit = class _RedactionAudit {
16794
17583
  };
16795
17584
 
16796
17585
  // src/hooks/run.ts
16797
- var import_node_crypto14 = require("crypto");
17586
+ var import_node_crypto15 = require("crypto");
16798
17587
  var fs17 = __toESM(require("fs"));
16799
17588
  var path16 = __toESM(require("path"));
16800
17589
  var BLOCKING_EVENTS = [
@@ -16838,7 +17627,7 @@ var HookRun = class _HookRun {
16838
17627
  source;
16839
17628
  constructor(config, options) {
16840
17629
  this.config = config;
16841
- this.runId = options.runId ?? `run-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
17630
+ this.runId = options.runId ?? `run-${(0, import_node_crypto15.randomBytes)(6).toString("hex")}`;
16842
17631
  this.runKey = options.runKey ?? newRunKey();
16843
17632
  this.alias = new AliasMap(this.runKey, options.slugs ?? config.aliasSlugs, {
16844
17633
  publicLayerWins: config.aliasPublicLayerWins,
@@ -17846,6 +18635,7 @@ var tracing = {
17846
18635
  NativeComputer,
17847
18636
  OpenAIComputer,
17848
18637
  OpenAIPreviewComputer,
18638
+ PLATFORM_SESSION_HEADER,
17849
18639
  PLATFORM_TIMEOUT_DEFAULT_MS,
17850
18640
  PLATFORM_TIMEOUT_ENV,
17851
18641
  PendingSafetyChecks,
@@ -17856,6 +18646,9 @@ var tracing = {
17856
18646
  PushSlugConflict,
17857
18647
  RECOVER_BUDGET_MS,
17858
18648
  REPLAY_ENVIRONMENT,
18649
+ REQUESTS_NOT_RECORDED,
18650
+ REQUEST_BODY_CAPTURE_BYTES,
18651
+ REQUEST_LOG_PAGE_MAX,
17859
18652
  ReplayCase,
17860
18653
  ReplayCheck,
17861
18654
  ReplayError,
@@ -17863,8 +18656,16 @@ var tracing = {
17863
18656
  ReplaySuite,
17864
18657
  ReplayTask,
17865
18658
  RetryPolicy,
18659
+ SANDBOX_EXEC_REPORT_MARGIN_MS,
18660
+ SANDBOX_EXEC_START_ATTEMPTS,
18661
+ SANDBOX_EXEC_TIMEOUT_MAX_S,
18662
+ SANDBOX_EXEC_WAIT_MS,
18663
+ SANDBOX_FILE_MAX_BYTES,
17866
18664
  SANDBOX_REQUEST_TIMEOUT_MS,
18665
+ SANDBOX_WRITE_CHUNK_BYTES,
18666
+ SANDBOX_WRITE_SKIPPED,
17867
18667
  SECRET_KEY,
18668
+ SESSION_AUTH_MODES,
17868
18669
  SESSION_STATES,
17869
18670
  SPAN_PREFIX,
17870
18671
  STATUS_WAIT_CAP_SECONDS,
@@ -17884,6 +18685,7 @@ var tracing = {
17884
18685
  TOOL_CONTRACT_UNREAD,
17885
18686
  TRANSFORMS,
17886
18687
  TaskEditClient,
18688
+ TaskGrades,
17887
18689
  TaskRun,
17888
18690
  TaskSessions,
17889
18691
  ToolStubRegistry,
@@ -17894,11 +18696,17 @@ var tracing = {
17894
18696
  UsersClient,
17895
18697
  VERIFIER_REWARD_PREFIX,
17896
18698
  WHITESPACE,
18699
+ WORLD_REQUEST_VIAS,
18700
+ WORLD_WEBHOOK_PAGE_MAX,
17897
18701
  WorldBrowser,
17898
18702
  WorldCallTooLarge,
17899
18703
  WorldEditClient,
17900
18704
  WorldNotice,
18705
+ WorldRequestFilterError,
18706
+ WorldRequestLedger,
17901
18707
  WorldRequestLog,
18708
+ WorldRequestQuery,
18709
+ WorldRequestsNotRecorded,
17902
18710
  WorldSandboxClient,
17903
18711
  WorldSession,
17904
18712
  WorldSessionCallError,
@@ -17908,6 +18716,8 @@ var tracing = {
17908
18716
  WorldSurfaceUnavailable,
17909
18717
  WorldTask,
17910
18718
  WorldToolsUnread,
18719
+ WorldWebhookForwarder,
18720
+ WriteTreeFilter,
17911
18721
  addExperimentAttributes,
17912
18722
  aggregateTaskGrade,
17913
18723
  apiRequest,
@@ -17915,6 +18725,7 @@ var tracing = {
17915
18725
  archiveMode,
17916
18726
  assembleManifest,
17917
18727
  assertBrowserTier,
18728
+ assertSessionAuthMode,
17918
18729
  assertTaskRef,
17919
18730
  assignVariant,
17920
18731
  attachManifest,
@@ -17924,7 +18735,9 @@ var tracing = {
17924
18735
  buildFileManifest,
17925
18736
  buildSourceTarball,
17926
18737
  canonicalJson,
18738
+ capabilityLabel,
17927
18739
  captureToolCalls,
18740
+ carriedWarnings,
17928
18741
  checkoutIdentity,
17929
18742
  clearExperimentContext,
17930
18743
  closeConnection,
@@ -17960,7 +18773,9 @@ var tracing = {
17960
18773
  idleWarning,
17961
18774
  ingest,
17962
18775
  ingestToolCalls,
18776
+ invalidFields,
17963
18777
  isBrowserGone,
18778
+ isSandboxCommitPending,
17964
18779
  isSandboxImportPending,
17965
18780
  isTaskIdRef,
17966
18781
  isTaskManifest,
@@ -17971,6 +18786,7 @@ var tracing = {
17971
18786
  listSessions,
17972
18787
  listTaskSessions,
17973
18788
  listTasks,
18789
+ listWebhooks,
17974
18790
  loadSession,
17975
18791
  localTreeState,
17976
18792
  memory,
@@ -18017,6 +18833,7 @@ var tracing = {
18017
18833
  resolvePushSlug,
18018
18834
  resolveUserId,
18019
18835
  roundForm,
18836
+ rowsRefusal,
18020
18837
  runSessions,
18021
18838
  runSet,
18022
18839
  runSuite,
@@ -18056,6 +18873,7 @@ var tracing = {
18056
18873
  validateWorld,
18057
18874
  waitForRun,
18058
18875
  withoutUiToken,
18876
+ worldRequestsUnrecorded,
18059
18877
  writeLocalMeta
18060
18878
  });
18061
18879
  //# sourceMappingURL=index.js.map