@withgateway/sdk 0.2.9 → 0.3.1

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 (58) hide show
  1. package/README.md +5 -1
  2. package/dist/cli.js +3812 -1158
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +3796 -1142
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.d.mts +1 -0
  7. package/dist/files/index.d.ts +1 -0
  8. package/dist/files/index.js +1358 -21
  9. package/dist/files/index.js.map +1 -1
  10. package/dist/files/index.mjs +1356 -13
  11. package/dist/files/index.mjs.map +1 -1
  12. package/dist/{index-BO2SNSgy.d.ts → index-CBqbB_0J.d.ts} +95 -46
  13. package/dist/{index-Cz8Q6Keo.d.mts → index-D-AMnAMa.d.mts} +95 -46
  14. package/dist/index.d.mts +4 -3
  15. package/dist/index.d.ts +4 -3
  16. package/dist/index.js +1942 -177
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +1890 -146
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/media-CbcAfQvd.d.mts +83 -0
  21. package/dist/media-CbcAfQvd.d.ts +83 -0
  22. package/dist/traces/index.d.mts +1 -0
  23. package/dist/traces/index.d.ts +1 -0
  24. package/dist/traces/index.js +1355 -18
  25. package/dist/traces/index.js.map +1 -1
  26. package/dist/traces/index.mjs +1353 -10
  27. package/dist/traces/index.mjs.map +1 -1
  28. package/dist/tracing/index.d.mts +2 -1
  29. package/dist/tracing/index.d.ts +2 -1
  30. package/dist/tracing/index.js +550 -30
  31. package/dist/tracing/index.js.map +1 -1
  32. package/dist/tracing/index.mjs +539 -29
  33. package/dist/tracing/index.mjs.map +1 -1
  34. package/dist/worlds/index.d.mts +648 -80
  35. package/dist/worlds/index.d.ts +648 -80
  36. package/dist/worlds/index.js +1875 -145
  37. package/dist/worlds/index.js.map +1 -1
  38. package/dist/worlds/index.mjs +1861 -131
  39. package/dist/worlds/index.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/runtime/gatewaysdk/environment/schema/api.py +43 -62
  42. package/runtime/gatewaysdk/environment/schema/cast.py +31 -4
  43. package/runtime/gatewaysdk/environment/schema/grading.py +1 -5
  44. package/runtime/gatewaysdk/environment/schema/host.py +53 -90
  45. package/runtime/gatewaysdk/environment/schema/local.py +15 -7
  46. package/runtime/gatewaysdk/environment/schema/platform.py +1 -7
  47. package/runtime/gatewaysdk/environment/schema/runtime.py +9 -9
  48. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +3 -3
  49. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +2 -2
  50. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +13 -13
  51. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +2 -1
  52. package/runtime/gatewaysdk/environment/schema/tasks.py +25 -1
  53. package/skills/connector-schema-authoring/SKILL.md +3 -3
  54. package/skills/connector-schema-authoring/connector-worlds.md +12 -5
  55. package/skills/connector-schema-authoring/world-schema.md +8 -0
  56. package/skills/world-data-ingestion/SKILL.md +2 -2
  57. package/skills/worlds-getting-started/SKILL.md +13 -13
  58. package/skills/worlds-getting-started/references/cli-mcp-map.md +2 -1
package/dist/index.js CHANGED
@@ -756,7 +756,7 @@ function withoutUiToken(url) {
756
756
  const [beforeHash, hash] = splitHash(url);
757
757
  const q = beforeHash.indexOf("?");
758
758
  if (q < 0) return url;
759
- const kept = beforeHash.slice(q + 1).split("&").filter((pair2) => pair2 !== "" && pair2.split("=")[0] !== UI_TOKEN_QUERY);
759
+ const kept = beforeHash.slice(q + 1).split("&").filter((pair3) => pair3 !== "" && pair3.split("=")[0] !== UI_TOKEN_QUERY);
760
760
  return beforeHash.slice(0, q) + (kept.length ? `?${kept.join("&")}` : "") + hash;
761
761
  }
762
762
  function splitHash(url) {
@@ -891,7 +891,7 @@ var SURFACE_KINDS, BROWSER_TIERS, DEFAULT_VIEWPORT, SETTLE_TIMEOUT_MS, SETTLE_QU
891
891
  var init_browser = __esm({
892
892
  "src/worlds/browser.ts"() {
893
893
  "use strict";
894
- init_session();
894
+ init_session2();
895
895
  init_browserReconnect();
896
896
  SURFACE_KINDS = ["tools", "api", "ui", "browser"];
897
897
  BROWSER_TIERS = ["standard", "premium"];
@@ -1037,6 +1037,10 @@ var init_browser = __esm({
1037
1037
  get agentId() {
1038
1038
  return this.recorder?.agentId ?? null;
1039
1039
  }
1040
+ /** `text` with this session's credentials (UI token, browser address) removed. */
1041
+ scrub(text2) {
1042
+ return this.scrubber.scrub(text2);
1043
+ }
1040
1044
  watchNetwork(page) {
1041
1045
  page.on("request", () => {
1042
1046
  this.inflight += 1;
@@ -1323,6 +1327,1269 @@ var init_browser = __esm({
1323
1327
  }
1324
1328
  });
1325
1329
 
1330
+ // src/worlds/nativeComputer/actions.ts
1331
+ function toNumber(value) {
1332
+ if (typeof value !== "number" || !Number.isFinite(value))
1333
+ throw new Error(`not a number: ${JSON.stringify(value) ?? String(value)}`);
1334
+ return value;
1335
+ }
1336
+ function toInt(value) {
1337
+ return Math.trunc(toNumber(value));
1338
+ }
1339
+ var ACTION_NAMES, SECRET_TEXT, BOUNDS, ComputerAction;
1340
+ var init_actions = __esm({
1341
+ "src/worlds/nativeComputer/actions.ts"() {
1342
+ "use strict";
1343
+ ACTION_NAMES = [
1344
+ "screenshot",
1345
+ "zoom",
1346
+ "click",
1347
+ "move",
1348
+ "mouse_down",
1349
+ "mouse_up",
1350
+ "drag",
1351
+ "scroll",
1352
+ "type",
1353
+ "key",
1354
+ "hold_key",
1355
+ "wait",
1356
+ "cursor_position",
1357
+ "history"
1358
+ ];
1359
+ SECRET_TEXT = "[redacted]";
1360
+ BOUNDS = {
1361
+ seconds: [0, 300],
1362
+ repeat: [1, 100],
1363
+ count: [1, 3],
1364
+ dx: [-1e4, 1e4],
1365
+ dy: [-1e4, 1e4]
1366
+ };
1367
+ ComputerAction = class {
1368
+ constructor(name, args = {}) {
1369
+ this.name = name;
1370
+ this.args = args;
1371
+ if (!ACTION_NAMES.includes(name))
1372
+ throw new Error(`unknown computer action: ${name}`);
1373
+ for (const [key2, [low, high]] of Object.entries(BOUNDS)) {
1374
+ const value = args[key2];
1375
+ if (value !== void 0 && !(Number(value) >= low && Number(value) <= high))
1376
+ throw new Error(
1377
+ `${name} ${key2} must be between ${low} and ${high}, got ${String(value)}`
1378
+ );
1379
+ }
1380
+ }
1381
+ name;
1382
+ args;
1383
+ /** Flat arguments for the browser timeline and the trace: lists become
1384
+ * `"x,y"` strings, and typed text is withheld when it went into a
1385
+ * credential field. */
1386
+ recordArgs(secretText) {
1387
+ const out = {};
1388
+ for (const [key2, value] of Object.entries(this.args))
1389
+ out[key2] = Array.isArray(value) ? value.flat().join(",") : value;
1390
+ if (secretText && "text" in out) out.text = SECRET_TEXT;
1391
+ return out;
1392
+ }
1393
+ };
1394
+ }
1395
+ });
1396
+
1397
+ // src/worlds/nativeComputer/display.ts
1398
+ var FIT_STEP, Display;
1399
+ var init_display = __esm({
1400
+ "src/worlds/nativeComputer/display.ts"() {
1401
+ "use strict";
1402
+ FIT_STEP = 0.98;
1403
+ Display = class _Display {
1404
+ constructor(width, height, viewportWidth, viewportHeight) {
1405
+ this.width = width;
1406
+ this.height = height;
1407
+ this.viewportWidth = viewportWidth;
1408
+ this.viewportHeight = viewportHeight;
1409
+ }
1410
+ width;
1411
+ height;
1412
+ viewportWidth;
1413
+ viewportHeight;
1414
+ /** `size` when the caller names one; otherwise the largest downscale of the
1415
+ * viewport (at most 1:1) that `fits` the provider's limits. */
1416
+ static forViewport(viewport, size, fits = () => true) {
1417
+ const { width, height } = viewport;
1418
+ if (size) return _Display.sized(size[0], size[1], width, height);
1419
+ let scale = 1;
1420
+ while (!fits(Math.round(width * scale), Math.round(height * scale)))
1421
+ scale *= FIT_STEP;
1422
+ return new _Display(
1423
+ Math.round(width * scale),
1424
+ Math.round(height * scale),
1425
+ width,
1426
+ height
1427
+ );
1428
+ }
1429
+ /** A caller's display keeps the viewport's shape: screenshots are scaled
1430
+ * uniformly, so another aspect ratio would map clicks off the image. */
1431
+ static sized(width, height, viewportWidth, viewportHeight) {
1432
+ if (width <= 0 || height <= 0)
1433
+ throw new Error(`display ${width}x${height} must be positive`);
1434
+ const sameShape = width * viewportHeight / viewportWidth;
1435
+ if (Math.abs(sameShape - height) > 1)
1436
+ throw new Error(
1437
+ `display ${width}x${height} must keep the viewport's aspect ratio (${viewportWidth}x${viewportHeight}); try ${width}x${Math.round(sameShape)}`
1438
+ );
1439
+ return new _Display(width, height, viewportWidth, viewportHeight);
1440
+ }
1441
+ get scaled() {
1442
+ return this.width !== this.viewportWidth || this.height !== this.viewportHeight;
1443
+ }
1444
+ get scale() {
1445
+ return Math.min(
1446
+ this.width / this.viewportWidth,
1447
+ this.height / this.viewportHeight
1448
+ );
1449
+ }
1450
+ toPage(x, y) {
1451
+ return [
1452
+ x * this.viewportWidth / this.width,
1453
+ y * this.viewportHeight / this.height
1454
+ ];
1455
+ }
1456
+ };
1457
+ }
1458
+ });
1459
+
1460
+ // src/worlds/nativeComputer/screen.ts
1461
+ function pngWidth(png) {
1462
+ if (png.length < 24 || !png.subarray(0, 8).equals(PNG_SIGNATURE)) return null;
1463
+ return png.readUInt32BE(16);
1464
+ }
1465
+ function isNativePage(page) {
1466
+ const candidate = page;
1467
+ const mouse = candidate?.mouse;
1468
+ return typeof candidate?.context === "function" && NATIVE_METHODS.every((m) => typeof mouse?.[m] === "function");
1469
+ }
1470
+ var FOCUSED_FIELD_JS, SECRET_FOCUS, DRAG_STEPS, PNG_SIGNATURE, NATIVE_METHODS, Screen;
1471
+ var init_screen = __esm({
1472
+ "src/worlds/nativeComputer/screen.ts"() {
1473
+ "use strict";
1474
+ init_browser();
1475
+ FOCUSED_FIELD_JS = "(() => { let e = document.activeElement; const inner = (el) => (el.shadowRoot && el.shadowRoot.activeElement) || (el.contentDocument && el.contentDocument.activeElement); while (e && inner(e)) e = inner(e); if (!e) return ''; if (e.tagName === 'IFRAME' || e.tagName === 'FRAME') return 'frame'; if (!(e.tagName === 'INPUT' || e.tagName === 'TEXTAREA' || e.isContentEditable)) return 'opaque'; return [e.type, e.name, e.id, e.getAttribute('autocomplete')].filter(Boolean).join(' '); })()";
1476
+ SECRET_FOCUS = ["password", "frame", "opaque"];
1477
+ DRAG_STEPS = 5;
1478
+ PNG_SIGNATURE = Buffer.from([
1479
+ 137,
1480
+ 80,
1481
+ 78,
1482
+ 71,
1483
+ 13,
1484
+ 10,
1485
+ 26,
1486
+ 10
1487
+ ]);
1488
+ NATIVE_METHODS = ["move", "click", "down", "up", "wheel"];
1489
+ Screen = class {
1490
+ constructor(browser, display) {
1491
+ this.browser = browser;
1492
+ this.display = display;
1493
+ }
1494
+ browser;
1495
+ display;
1496
+ cursor = [0, 0];
1497
+ pixelRatio = 1;
1498
+ handlers = {
1499
+ screenshot: async () => ({ image: await this.screenshot() }),
1500
+ zoom: (a) => this.zoom(a),
1501
+ click: (a) => this.click(a),
1502
+ move: (a) => this.held(a.args.modifiers ?? [], () => this.moveTo(this.point(a))),
1503
+ mouse_down: async (a) => {
1504
+ await this.page.mouse.down({ button: a.args.button ?? "left" });
1505
+ return {};
1506
+ },
1507
+ mouse_up: async (a) => {
1508
+ await this.page.mouse.up({ button: a.args.button ?? "left" });
1509
+ return {};
1510
+ },
1511
+ drag: (a) => this.drag(a),
1512
+ scroll: (a) => this.scroll(a),
1513
+ type: async (a) => {
1514
+ await this.page.keyboard.type(a.args.text ?? "");
1515
+ return {};
1516
+ },
1517
+ key: (a) => this.key(a),
1518
+ hold_key: (a) => this.held(
1519
+ a.args.keys ?? [],
1520
+ () => this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3)
1521
+ ),
1522
+ wait: async (a) => {
1523
+ await this.page.waitForTimeout((a.args.seconds ?? 0) * 1e3);
1524
+ return {};
1525
+ },
1526
+ cursor_position: async () => ({
1527
+ text: `X=${this.cursor[0]}, Y=${this.cursor[1]}`
1528
+ }),
1529
+ history: async (a) => {
1530
+ const navigate = {
1531
+ back: () => this.page.goBack(),
1532
+ forward: () => this.page.goForward()
1533
+ };
1534
+ await navigate[a.args.direction ?? "back"]();
1535
+ return {};
1536
+ }
1537
+ };
1538
+ /** The live page (a new object after a reconnect), as pixel-level Playwright. */
1539
+ get page() {
1540
+ const page = this.browser.page;
1541
+ if (!isNativePage(page))
1542
+ throw new Error(
1543
+ "native computer use needs a Playwright page (mouse.move/click/down/up/wheel, context())"
1544
+ );
1545
+ return page;
1546
+ }
1547
+ run(action) {
1548
+ return this.handlers[action.name](action);
1549
+ }
1550
+ /** A PNG of the viewport at the model's display size. */
1551
+ async screenshot() {
1552
+ if (!this.display.scaled) return this.page.screenshot({ type: "png" });
1553
+ const { viewportWidth: width, viewportHeight: height } = this.display;
1554
+ return this.capture({ x: 0, y: 0, width, height }, this.display.scale);
1555
+ }
1556
+ /** Whether keystrokes go to a credential field (a password input, or one
1557
+ * named like a token, key or PIN), looking through shadow roots and
1558
+ * same-origin frames. An unreadable page, a cross-origin frame or a focus
1559
+ * that is not a text field (a closed shadow root's host) counts as one. */
1560
+ async focusedFieldIsSecret() {
1561
+ let described;
1562
+ try {
1563
+ described = String(await this.page.evaluate(FOCUSED_FIELD_JS) ?? "");
1564
+ } catch {
1565
+ return true;
1566
+ }
1567
+ return SECRET_FOCUS.some((prefix) => described.startsWith(prefix)) || SECRET_KEY.test(described);
1568
+ }
1569
+ /** CDP renders a clip at the page's device pixel ratio as well as its
1570
+ * `scale` (a Retina host doubles it), so a capture of the wrong width
1571
+ * measures that ratio and is taken once more, corrected. */
1572
+ async capture(clip, scale) {
1573
+ const wanted = Math.round(clip.width * scale);
1574
+ const png = await this.cdpCapture(clip, scale / this.pixelRatio);
1575
+ const width = pngWidth(png);
1576
+ if (width === null || Math.abs(width - wanted) <= 1) return png;
1577
+ this.pixelRatio *= width / wanted;
1578
+ return this.cdpCapture(clip, scale / this.pixelRatio);
1579
+ }
1580
+ async cdpCapture(clip, scale) {
1581
+ const page = this.page;
1582
+ const session = await page.context().newCDPSession(page);
1583
+ try {
1584
+ const shot = await session.send("Page.captureScreenshot", {
1585
+ format: "png",
1586
+ clip: { ...clip, scale }
1587
+ });
1588
+ return Buffer.from(shot.data, "base64");
1589
+ } finally {
1590
+ await session.detach();
1591
+ }
1592
+ }
1593
+ point(action) {
1594
+ const { x, y } = action.args;
1595
+ return x === void 0 || y === void 0 ? this.cursor : [x, y];
1596
+ }
1597
+ async moveTo(point2, steps = 1) {
1598
+ const [x, y] = this.display.toPage(point2[0], point2[1]);
1599
+ await this.page.mouse.move(x, y, { steps });
1600
+ this.cursor = point2;
1601
+ }
1602
+ async held(modifiers, fn) {
1603
+ for (const key2 of modifiers) await this.page.keyboard.down(key2);
1604
+ try {
1605
+ await fn();
1606
+ } finally {
1607
+ for (const key2 of [...modifiers].reverse())
1608
+ await this.page.keyboard.up(key2);
1609
+ }
1610
+ return {};
1611
+ }
1612
+ async zoom(action) {
1613
+ const [x0, y0, x1, y1] = action.args.region ?? [0, 0, 0, 0];
1614
+ const [left, top] = this.display.toPage(x0, y0);
1615
+ const [right, bottom] = this.display.toPage(x1, y1);
1616
+ if (right <= left || bottom <= top)
1617
+ throw new Error("zoom region must have x1 > x0 and y1 > y0");
1618
+ const width = right - left;
1619
+ const height = bottom - top;
1620
+ const scale = Math.min(
1621
+ this.display.width / width,
1622
+ this.display.height / height
1623
+ );
1624
+ return {
1625
+ image: await this.capture({ x: left, y: top, width, height }, scale)
1626
+ };
1627
+ }
1628
+ async click(action) {
1629
+ const point2 = this.point(action);
1630
+ return this.held(action.args.modifiers ?? [], async () => {
1631
+ await this.moveTo(point2);
1632
+ const [x, y] = this.display.toPage(point2[0], point2[1]);
1633
+ await this.page.mouse.click(x, y, {
1634
+ button: action.args.button ?? "left",
1635
+ clickCount: action.args.count ?? 1
1636
+ });
1637
+ });
1638
+ }
1639
+ async drag(action) {
1640
+ const path16 = action.args.path ?? [];
1641
+ if (path16.length < 2) throw new Error("a drag needs at least two points");
1642
+ return this.held(action.args.modifiers ?? [], async () => {
1643
+ await this.moveTo(path16[0]);
1644
+ await this.page.mouse.down({ button: "left" });
1645
+ try {
1646
+ for (const point2 of path16.slice(1)) await this.moveTo(point2, DRAG_STEPS);
1647
+ } finally {
1648
+ await this.page.mouse.up({ button: "left" });
1649
+ }
1650
+ });
1651
+ }
1652
+ async scroll(action) {
1653
+ await this.moveTo(this.point(action));
1654
+ const scale = this.display.scale;
1655
+ return this.held(
1656
+ action.args.modifiers ?? [],
1657
+ () => this.page.mouse.wheel(
1658
+ (action.args.dx ?? 0) / scale,
1659
+ (action.args.dy ?? 0) / scale
1660
+ )
1661
+ );
1662
+ }
1663
+ async key(action) {
1664
+ const combo = (action.args.keys ?? []).join("+");
1665
+ for (let i = 0; i < (action.args.repeat ?? 1); i += 1)
1666
+ await this.page.keyboard.press(combo);
1667
+ return {};
1668
+ }
1669
+ };
1670
+ }
1671
+ });
1672
+
1673
+ // src/tracing/media.ts
1674
+ async function putBytes(url, data, headers) {
1675
+ const controller = new AbortController();
1676
+ const timer = setTimeout(() => controller.abort(), PUT_TIMEOUT_MS);
1677
+ try {
1678
+ const res = await fetch(url, {
1679
+ method: "PUT",
1680
+ body: new Uint8Array(data),
1681
+ headers,
1682
+ signal: controller.signal
1683
+ });
1684
+ return {
1685
+ status: res.status,
1686
+ error: res.ok ? null : (await res.text()).slice(0, MAX_UPLOAD_ERROR)
1687
+ };
1688
+ } catch (error) {
1689
+ return {
1690
+ status: NETWORK_FAILURE_STATUS,
1691
+ error: error instanceof Error ? error.name : "Error"
1692
+ };
1693
+ } finally {
1694
+ clearTimeout(timer);
1695
+ }
1696
+ }
1697
+ var import_node_crypto, MEDIA_PATH, MAX_MEDIA_BYTES, PUT_TIMEOUT_MS, MAX_UPLOAD_ERROR, NETWORK_FAILURE_STATUS, MediaUploadError, MediaReference, MediaUploader;
1698
+ var init_media = __esm({
1699
+ "src/tracing/media.ts"() {
1700
+ "use strict";
1701
+ import_node_crypto = require("crypto");
1702
+ init_transport();
1703
+ MEDIA_PATH = "/api/public/media";
1704
+ MAX_MEDIA_BYTES = 5 * 1024 * 1024;
1705
+ PUT_TIMEOUT_MS = 3e4;
1706
+ MAX_UPLOAD_ERROR = 500;
1707
+ NETWORK_FAILURE_STATUS = 599;
1708
+ MediaUploadError = class extends Error {
1709
+ constructor(message, status) {
1710
+ super(message);
1711
+ this.status = status;
1712
+ this.name = "MediaUploadError";
1713
+ }
1714
+ status;
1715
+ };
1716
+ MediaReference = class {
1717
+ constructor(mediaId, contentType) {
1718
+ this.mediaId = mediaId;
1719
+ this.contentType = contentType;
1720
+ }
1721
+ mediaId;
1722
+ contentType;
1723
+ toString() {
1724
+ return `@@@langfuseMedia:type=${this.contentType}|id=${this.mediaId}|source=bytes@@@`;
1725
+ }
1726
+ };
1727
+ MediaUploader = class _MediaUploader {
1728
+ constructor(transport, put = putBytes, maxBytes = MAX_MEDIA_BYTES) {
1729
+ this.transport = transport;
1730
+ this.put = put;
1731
+ this.maxBytes = maxBytes;
1732
+ }
1733
+ transport;
1734
+ put;
1735
+ maxBytes;
1736
+ /** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
1737
+ * `GATEWAY_SECRET_KEY` (the keys tracing exports with); null when any is unset. */
1738
+ static fromEnv(env = process.env) {
1739
+ const host = env.GATEWAY_HOST;
1740
+ const publicKey = env.GATEWAY_PUBLIC_KEY;
1741
+ const secretKey = env.GATEWAY_SECRET_KEY;
1742
+ if (!host || !publicKey || !secretKey) return null;
1743
+ return new _MediaUploader(
1744
+ new PlatformTransport({
1745
+ host: host.replace(/\/$/, ""),
1746
+ publicKey,
1747
+ secretKey
1748
+ })
1749
+ );
1750
+ }
1751
+ /** Store `data` linked to the trace (and observation) and return its reference. */
1752
+ async upload(data, link) {
1753
+ if (data.length > this.maxBytes)
1754
+ throw new MediaUploadError(
1755
+ `media is ${data.length} bytes, over the ${this.maxBytes}-byte cap`
1756
+ );
1757
+ const sha256Hash = (0, import_node_crypto.createHash)("sha256").update(data).digest("base64");
1758
+ const answer = await this.send("POST", MEDIA_PATH, {
1759
+ traceId: link.traceId,
1760
+ observationId: link.observationId,
1761
+ contentType: link.contentType,
1762
+ contentLength: data.length,
1763
+ sha256Hash,
1764
+ field: link.field
1765
+ });
1766
+ if (typeof answer.mediaId !== "string" || !answer.mediaId)
1767
+ throw new MediaUploadError(
1768
+ "POST /api/public/media answered without a mediaId"
1769
+ );
1770
+ const reference = new MediaReference(answer.mediaId, link.contentType);
1771
+ if (answer.uploadUrl)
1772
+ await this.store(reference, answer.uploadUrl, data, sha256Hash);
1773
+ return reference;
1774
+ }
1775
+ async store(reference, url, data, sha256Hash) {
1776
+ const started = Date.now();
1777
+ const { status, error } = await this.put(url, data, {
1778
+ "Content-Type": reference.contentType,
1779
+ "x-amz-checksum-sha256": sha256Hash,
1780
+ "x-ms-blob-type": "BlockBlob"
1781
+ });
1782
+ await this.send(
1783
+ "PATCH",
1784
+ `${MEDIA_PATH}/${encodeURIComponent(reference.mediaId)}`,
1785
+ {
1786
+ uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
1787
+ uploadHttpStatus: status,
1788
+ uploadHttpError: error,
1789
+ uploadTimeMs: Date.now() - started
1790
+ }
1791
+ );
1792
+ if (status < 200 || status >= 300)
1793
+ throw new MediaUploadError(
1794
+ `media storage refused the upload (HTTP ${status})`,
1795
+ status
1796
+ );
1797
+ }
1798
+ async send(method, route, body) {
1799
+ const reply = await this.transport.send(method, route, body);
1800
+ if (!reply.ok)
1801
+ throw new MediaUploadError(
1802
+ `${method} ${route} -> ${reply.status}`,
1803
+ reply.status
1804
+ );
1805
+ return reply.text ? JSON.parse(reply.text) : {};
1806
+ }
1807
+ };
1808
+ }
1809
+ });
1810
+
1811
+ // src/worlds/nativeComputer/trace.ts
1812
+ function loadOtelApi() {
1813
+ if (otelApi !== void 0) return otelApi;
1814
+ try {
1815
+ otelApi = require("@opentelemetry/api");
1816
+ } catch {
1817
+ otelApi = null;
1818
+ }
1819
+ return otelApi;
1820
+ }
1821
+ function errorText(error) {
1822
+ return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
1823
+ }
1824
+ function errorName(error) {
1825
+ return error instanceof Error ? error.name : "Error";
1826
+ }
1827
+ var SPAN_PREFIX, MAX_UPLOAD_FAILURES, TRACER_NAME, MAX_ERROR, otelApi, ActionTracer;
1828
+ var init_trace = __esm({
1829
+ "src/worlds/nativeComputer/trace.ts"() {
1830
+ "use strict";
1831
+ init_media();
1832
+ SPAN_PREFIX = "computer.";
1833
+ MAX_UPLOAD_FAILURES = 3;
1834
+ TRACER_NAME = "@withgateway/sdk";
1835
+ MAX_ERROR = 1e3;
1836
+ ActionTracer = class _ActionTracer {
1837
+ constructor(media, warn3 = (m) => console.warn(m)) {
1838
+ this.media = media;
1839
+ this.warn = warn3;
1840
+ }
1841
+ media;
1842
+ warn;
1843
+ failures = 0;
1844
+ warned = false;
1845
+ static fromEnv() {
1846
+ return new _ActionTracer(MediaUploader.fromEnv());
1847
+ }
1848
+ /** `args` are already redacted. A failure's status goes through `scrub`:
1849
+ * browser errors quote the session's ws URL and UI token. */
1850
+ async span(action, args, run, capture, scrub) {
1851
+ const otel = loadOtelApi();
1852
+ if (!otel) return run();
1853
+ const { SpanStatusCode: SpanStatusCode3, trace: trace5 } = otel;
1854
+ const attributes = {
1855
+ "gateway.observation.type": "tool",
1856
+ "tool.name": SPAN_PREFIX + action.name,
1857
+ "gateway.observation.input": JSON.stringify({
1858
+ action: action.name,
1859
+ ...args
1860
+ })
1861
+ };
1862
+ return trace5.getTracer(TRACER_NAME).startActiveSpan(
1863
+ SPAN_PREFIX + action.name,
1864
+ { attributes },
1865
+ async (span) => {
1866
+ try {
1867
+ const result = await run();
1868
+ await this.finish(span, result, capture);
1869
+ span.setStatus({ code: SpanStatusCode3.OK });
1870
+ return result;
1871
+ } catch (error) {
1872
+ span.setStatus({
1873
+ code: SpanStatusCode3.ERROR,
1874
+ message: scrub(errorText(error)).slice(0, MAX_ERROR)
1875
+ });
1876
+ throw error;
1877
+ } finally {
1878
+ span.end();
1879
+ }
1880
+ }
1881
+ );
1882
+ }
1883
+ async finish(span, result, capture) {
1884
+ if (!span.isRecording()) return;
1885
+ const output = {
1886
+ screenshot: await this.screenshot(span, result, capture)
1887
+ };
1888
+ if (result.text !== void 0) output.text = result.text;
1889
+ span.setAttribute("gateway.observation.output", JSON.stringify(output));
1890
+ }
1891
+ async screenshot(span, result, capture) {
1892
+ let png;
1893
+ try {
1894
+ png = result.image ?? await capture();
1895
+ } catch (error) {
1896
+ return `[screenshot unavailable: ${errorName(error)}]`;
1897
+ }
1898
+ return this.reference(png, span);
1899
+ }
1900
+ async reference(png, span) {
1901
+ if (!this.media)
1902
+ return "[screenshot not uploaded: GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY unset]";
1903
+ if (this.failures >= MAX_UPLOAD_FAILURES)
1904
+ return "[screenshot not uploaded: uploads disabled after repeated failures]";
1905
+ const { traceId, spanId } = span.spanContext();
1906
+ try {
1907
+ const reference = await this.media.upload(png, {
1908
+ contentType: "image/png",
1909
+ traceId,
1910
+ observationId: spanId,
1911
+ field: "output"
1912
+ });
1913
+ this.failures = 0;
1914
+ return reference.toString();
1915
+ } catch (error) {
1916
+ return this.failed(error);
1917
+ }
1918
+ }
1919
+ failed(error) {
1920
+ this.failures += 1;
1921
+ if (!this.warned) {
1922
+ this.warned = true;
1923
+ this.warn(
1924
+ `native computer: screenshot upload failed (${errorName(error)}: ${error instanceof Error ? error.message : String(error)}); spans keep going without it`
1925
+ );
1926
+ }
1927
+ return `[screenshot not uploaded: ${errorName(error)}]`;
1928
+ }
1929
+ };
1930
+ }
1931
+ });
1932
+
1933
+ // src/worlds/nativeComputer/base.ts
1934
+ function readField(item, ...names) {
1935
+ const record = item ?? {};
1936
+ return names.map((name) => record[name]).find((value) => value !== void 0 && value !== null);
1937
+ }
1938
+ var REPLAYABLE, SETTLING, EVENT_PREFIX, NativeComputer;
1939
+ var init_base = __esm({
1940
+ "src/worlds/nativeComputer/base.ts"() {
1941
+ "use strict";
1942
+ init_browser();
1943
+ init_actions();
1944
+ init_display();
1945
+ init_screen();
1946
+ init_trace();
1947
+ REPLAYABLE = /* @__PURE__ */ new Set(["screenshot", "zoom", "cursor_position", "wait"]);
1948
+ SETTLING = /* @__PURE__ */ new Set(["click", "mouse_up", "drag", "key", "history"]);
1949
+ EVENT_PREFIX = "computer_";
1950
+ NativeComputer = class _NativeComputer {
1951
+ constructor(browser, options = {}) {
1952
+ this.browser = browser;
1953
+ const kind = this.constructor;
1954
+ this.display = Display.forViewport(
1955
+ browser.viewport,
1956
+ options.display,
1957
+ (w, h) => kind.fits(w, h)
1958
+ );
1959
+ this.screen = new Screen(browser, this.display);
1960
+ this.tracer = options.tracer ?? ActionTracer.fromEnv();
1961
+ }
1962
+ browser;
1963
+ static kinds = /* @__PURE__ */ new Map();
1964
+ display;
1965
+ screen;
1966
+ tracer;
1967
+ queue = Promise.resolve();
1968
+ static register(provider, kind) {
1969
+ _NativeComputer.kinds.set(provider, kind);
1970
+ }
1971
+ static get providers() {
1972
+ return [..._NativeComputer.kinds.keys()].sort();
1973
+ }
1974
+ static forProvider(provider, browser, options = {}) {
1975
+ const Kind = _NativeComputer.kinds.get(provider);
1976
+ if (!Kind)
1977
+ throw new Error(
1978
+ `unknown computer-use provider '${provider}'; choose from ${_NativeComputer.providers.join(", ")}`
1979
+ );
1980
+ return new Kind(browser, options);
1981
+ }
1982
+ /** Whether a screenshot of this size is within the provider's limits. */
1983
+ static fits(_width, _height) {
1984
+ return true;
1985
+ }
1986
+ /** Run one provider-shaped action (an OpenAI action object, or an Anthropic
1987
+ * `{ action: "left_click", ... }` input) and return what it produced: the
1988
+ * door for any agent framework that hands actions over one at a time. */
1989
+ executeAction(raw) {
1990
+ return this.perform(this.parse(raw));
1991
+ }
1992
+ /** Run one action on the page: reported on the session's browser timeline
1993
+ * and, when tracing is on, as a span with the screen after. */
1994
+ async perform(action) {
1995
+ const secret = action.name === "type" && await this.screen.focusedFieldIsSecret();
1996
+ const event = EVENT_PREFIX + action.name;
1997
+ const args = redactActionArgs(event, action.recordArgs(secret));
1998
+ return this.tracer.span(
1999
+ action,
2000
+ args,
2001
+ () => this.browser.act(
2002
+ event,
2003
+ args,
2004
+ () => this.runOnScreen(action),
2005
+ this.onLoss(action)
2006
+ ),
2007
+ () => this.screen.screenshot(),
2008
+ (text2) => this.browser.scrub(text2)
2009
+ );
2010
+ }
2011
+ async performAll(actions) {
2012
+ const results = [];
2013
+ for (const action of actions) results.push(await this.perform(action));
2014
+ return results;
2015
+ }
2016
+ /** The screen as the model sees it, as a traced `screenshot` action. */
2017
+ async screenshot() {
2018
+ return (await this.perform(new ComputerAction("screenshot"))).image ?? Buffer.alloc(0);
2019
+ }
2020
+ /** Run `fn` after every earlier call made through here: the AI SDK starts a
2021
+ * step's tool calls concurrently, but one screen takes one action at a time. */
2022
+ serial(fn) {
2023
+ const next = this.queue.then(fn, fn);
2024
+ this.queue = next.catch(() => void 0);
2025
+ return next;
2026
+ }
2027
+ async runOnScreen(action) {
2028
+ const result = await this.screen.run(action);
2029
+ if (SETTLING.has(action.name)) await this.browser.settle();
2030
+ return result;
2031
+ }
2032
+ onLoss(action) {
2033
+ return REPLAYABLE.has(action.name) ? "retry" : "report";
2034
+ }
2035
+ };
2036
+ }
2037
+ });
2038
+
2039
+ // src/worlds/nativeComputer/keys.ts
2040
+ function playwrightKey(token) {
2041
+ return KEY_NAMES[token.toLowerCase()] ?? token;
2042
+ }
2043
+ function letterOrName(key2) {
2044
+ return /^[a-zA-Z]$/.test(key2) ? key2.toLowerCase() : playwrightKey(key2);
2045
+ }
2046
+ function modifierChord(text2) {
2047
+ return typeof text2 === "string" && text2 ? [...KeyChord.fromXdotool(text2).keys] : [];
2048
+ }
2049
+ function modifierKeys(keys) {
2050
+ return Array.isArray(keys) && keys.length > 0 ? [...KeyChord.fromKeys(keys.map(String)).keys] : [];
2051
+ }
2052
+ var F_KEYS, KEY_NAMES, KeyChord;
2053
+ var init_keys = __esm({
2054
+ "src/worlds/nativeComputer/keys.ts"() {
2055
+ "use strict";
2056
+ F_KEYS = Object.fromEntries(
2057
+ Array.from({ length: 12 }, (_, i) => [`f${i + 1}`, `F${i + 1}`])
2058
+ );
2059
+ KEY_NAMES = {
2060
+ return: "Enter",
2061
+ enter: "Enter",
2062
+ kp_enter: "Enter",
2063
+ esc: "Escape",
2064
+ escape: "Escape",
2065
+ tab: "Tab",
2066
+ space: "Space",
2067
+ backspace: "Backspace",
2068
+ delete: "Delete",
2069
+ del: "Delete",
2070
+ insert: "Insert",
2071
+ home: "Home",
2072
+ end: "End",
2073
+ pageup: "PageUp",
2074
+ page_up: "PageUp",
2075
+ prior: "PageUp",
2076
+ pagedown: "PageDown",
2077
+ page_down: "PageDown",
2078
+ next: "PageDown",
2079
+ up: "ArrowUp",
2080
+ arrowup: "ArrowUp",
2081
+ down: "ArrowDown",
2082
+ arrowdown: "ArrowDown",
2083
+ left: "ArrowLeft",
2084
+ arrowleft: "ArrowLeft",
2085
+ right: "ArrowRight",
2086
+ arrowright: "ArrowRight",
2087
+ ctrl: "Control",
2088
+ control: "Control",
2089
+ shift: "Shift",
2090
+ alt: "Alt",
2091
+ option: "Alt",
2092
+ super: "Meta",
2093
+ meta: "Meta",
2094
+ cmd: "Meta",
2095
+ command: "Meta",
2096
+ win: "Meta",
2097
+ capslock: "CapsLock",
2098
+ caps_lock: "CapsLock",
2099
+ plus: "+",
2100
+ minus: "-",
2101
+ ...F_KEYS
2102
+ };
2103
+ KeyChord = class _KeyChord {
2104
+ constructor(keys) {
2105
+ this.keys = keys;
2106
+ if (keys.length === 0)
2107
+ throw new Error("a key action needs at least one key");
2108
+ }
2109
+ keys;
2110
+ /** `ctrl+shift+t` / `Return`: Anthropic's vocabulary, case kept. */
2111
+ static fromXdotool(text2) {
2112
+ return new _KeyChord(
2113
+ text2.trim().split("+").filter(Boolean).map(playwrightKey)
2114
+ );
2115
+ }
2116
+ /** `["CTRL", "A"]`: OpenAI's vocabulary. A lone letter is the unshifted key. */
2117
+ static fromKeys(keys) {
2118
+ return new _KeyChord(keys.map(letterOrName));
2119
+ }
2120
+ /** What `page.keyboard.press` takes: `Control+a`. */
2121
+ get combo() {
2122
+ return this.keys.join("+");
2123
+ }
2124
+ };
2125
+ }
2126
+ });
2127
+
2128
+ // src/worlds/nativeComputer/anthropic.ts
2129
+ function required(raw, key2) {
2130
+ const value = raw[key2];
2131
+ if (value === void 0 || value === null)
2132
+ throw new Error(`${String(raw.action)} needs ${key2}`);
2133
+ return value;
2134
+ }
2135
+ function pair(raw, key2) {
2136
+ const value = required(raw, key2);
2137
+ return [toInt(value[0]), toInt(value[1])];
2138
+ }
2139
+ function point(raw) {
2140
+ if (raw.coordinate === void 0 || raw.coordinate === null) return {};
2141
+ const [x, y] = pair(raw, "coordinate");
2142
+ return { x, y };
2143
+ }
2144
+ function chord(raw) {
2145
+ return [...KeyChord.fromXdotool(String(required(raw, "text"))).keys];
2146
+ }
2147
+ function click(button, count) {
2148
+ return (raw) => new ComputerAction("click", {
2149
+ ...point(raw),
2150
+ button,
2151
+ count,
2152
+ modifiers: modifierChord(raw.text)
2153
+ });
2154
+ }
2155
+ var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
2156
+ var init_anthropic = __esm({
2157
+ "src/worlds/nativeComputer/anthropic.ts"() {
2158
+ "use strict";
2159
+ init_actions();
2160
+ init_base();
2161
+ init_keys();
2162
+ SCROLL_STEP_PX = 100;
2163
+ NOT_EXECUTED = "Not executed: an earlier computer action in this turn failed.";
2164
+ MAX_ERROR2 = 1e3;
2165
+ SCROLL_DIRECTIONS = {
2166
+ up: [0, -1],
2167
+ down: [0, 1],
2168
+ left: [-1, 0],
2169
+ right: [1, 0]
2170
+ };
2171
+ MEMBERS = {
2172
+ screenshot: () => new ComputerAction("screenshot"),
2173
+ zoom: (raw) => new ComputerAction("zoom", {
2174
+ region: required(raw, "region").map(toInt)
2175
+ }),
2176
+ left_click: click("left", 1),
2177
+ right_click: click("right", 1),
2178
+ middle_click: click("middle", 1),
2179
+ double_click: click("left", 2),
2180
+ triple_click: click("left", 3),
2181
+ left_click_drag: (raw) => new ComputerAction("drag", {
2182
+ path: [pair(raw, "start_coordinate"), pair(raw, "coordinate")],
2183
+ modifiers: modifierChord(raw.text)
2184
+ }),
2185
+ mouse_move: (raw) => {
2186
+ const [x, y] = pair(raw, "coordinate");
2187
+ return new ComputerAction("move", { x, y });
2188
+ },
2189
+ left_mouse_down: () => new ComputerAction("mouse_down", { button: "left" }),
2190
+ left_mouse_up: () => new ComputerAction("mouse_up", { button: "left" }),
2191
+ cursor_position: () => new ComputerAction("cursor_position"),
2192
+ scroll: (raw) => {
2193
+ const direction = String(raw.scroll_direction ?? "down");
2194
+ if (!Object.hasOwn(SCROLL_DIRECTIONS, direction))
2195
+ throw new Error(
2196
+ `scroll_direction must be one of ${Object.keys(SCROLL_DIRECTIONS).join(", ")}`
2197
+ );
2198
+ const [dx, dy] = SCROLL_DIRECTIONS[direction];
2199
+ const amount = toInt(raw.scroll_amount ?? 1) * SCROLL_STEP_PX;
2200
+ return new ComputerAction("scroll", {
2201
+ ...point(raw),
2202
+ dx: dx * amount,
2203
+ dy: dy * amount,
2204
+ modifiers: modifierChord(raw.text)
2205
+ });
2206
+ },
2207
+ type: (raw) => new ComputerAction("type", { text: String(required(raw, "text")) }),
2208
+ key: (raw) => new ComputerAction("key", {
2209
+ keys: chord(raw),
2210
+ repeat: toInt(raw.repeat ?? 1)
2211
+ }),
2212
+ hold_key: (raw) => new ComputerAction("hold_key", {
2213
+ keys: chord(raw),
2214
+ seconds: toNumber(required(raw, "duration"))
2215
+ }),
2216
+ wait: (raw) => new ComputerAction("wait", { seconds: toNumber(raw.duration ?? 1) })
2217
+ };
2218
+ AnthropicComputer = class _AnthropicComputer extends NativeComputer {
2219
+ static TOOL_TYPE = "computer_toolset_20260801";
2220
+ static TOOLSET = "computer";
2221
+ static BETA = null;
2222
+ static MAX_LONG_EDGE = 2576;
2223
+ static MAX_VISUAL_TOKENS = 4784;
2224
+ static PATCH_PX = 28;
2225
+ static fits(width, height) {
2226
+ const tokens = Math.ceil(width / this.PATCH_PX) * Math.ceil(height / this.PATCH_PX);
2227
+ return Math.max(width, height) <= this.MAX_LONG_EDGE && tokens <= this.MAX_VISUAL_TOKENS;
2228
+ }
2229
+ tool() {
2230
+ return { type: _AnthropicComputer.TOOL_TYPE };
2231
+ }
2232
+ /** Whether a content block is a call to this computer. */
2233
+ owns(block) {
2234
+ return readField(block, "type") === "tool_use" && readField(block, "toolset_name") === _AnthropicComputer.TOOLSET;
2235
+ }
2236
+ member(block) {
2237
+ return [
2238
+ String(readField(block, "name")),
2239
+ { ...readField(block, "input") ?? {} }
2240
+ ];
2241
+ }
2242
+ parse(raw) {
2243
+ const name = String(readField(raw, "action"));
2244
+ const parser = Object.hasOwn(MEMBERS, name) ? MEMBERS[name] : void 0;
2245
+ if (!parser) throw new Error(`unknown computer action: ${name}`);
2246
+ return parser(raw);
2247
+ }
2248
+ /** Run every computer `tool_use` in a response's content, in order, and
2249
+ * return one `tool_result` per block. Other blocks are skipped. */
2250
+ async execute(content) {
2251
+ const results = [];
2252
+ let failed = false;
2253
+ for (const block of content) {
2254
+ if (!this.owns(block)) continue;
2255
+ if (failed) {
2256
+ results.push(this.envelope(block, NOT_EXECUTED, true));
2257
+ continue;
2258
+ }
2259
+ const [result, blockFailed] = await this.runBlock(block);
2260
+ results.push(result);
2261
+ failed = blockFailed;
2262
+ }
2263
+ return results;
2264
+ }
2265
+ /** The content an `ActionResult` goes back to the model as. */
2266
+ static content(result) {
2267
+ if (result.image)
2268
+ return [
2269
+ {
2270
+ type: "image",
2271
+ source: {
2272
+ type: "base64",
2273
+ media_type: "image/png",
2274
+ data: result.image.toString("base64")
2275
+ }
2276
+ }
2277
+ ];
2278
+ return [{ type: "text", text: result.text ?? "OK" }];
2279
+ }
2280
+ /** For `anthropic.tools.computerToolset_20260801({ ...computer.aiSdk() })`
2281
+ * (or `computer_20251124` with the legacy kind): `execute` runs one action
2282
+ * and returns `{ type: "image", data }` or text; `toModelOutput` turns that
2283
+ * into the tool result. Calls run one at a time, and once a call fails the
2284
+ * rest of that step's calls answer as not executed. */
2285
+ aiSdk() {
2286
+ let failedStep;
2287
+ const execute = (input, options) => this.serial(async () => {
2288
+ const step = options?.messages?.length;
2289
+ if (step !== void 0 && step === failedStep)
2290
+ throw new Error(NOT_EXECUTED);
2291
+ try {
2292
+ return _AnthropicComputer.aiSdkOutput(await this.executeAction(input));
2293
+ } catch (error) {
2294
+ failedStep = step;
2295
+ throw error instanceof Error ? new Error(this.browser.scrub(error.message)) : error;
2296
+ }
2297
+ });
2298
+ return {
2299
+ execute,
2300
+ toModelOutput: ({ output }) => _AnthropicComputer.aiSdkModelOutput(output)
2301
+ };
2302
+ }
2303
+ static aiSdkOutput(result) {
2304
+ if (result.image)
2305
+ return { type: "image", data: result.image.toString("base64") };
2306
+ return result.text ?? "OK";
2307
+ }
2308
+ /** `image-data` is what AI SDK 6's Anthropic provider turns into an image
2309
+ * block; AI SDK 7 still accepts it (and converts it to a `file` part). */
2310
+ static aiSdkModelOutput(output) {
2311
+ if (typeof output === "string") return { type: "text", value: output };
2312
+ return {
2313
+ type: "content",
2314
+ value: [
2315
+ { type: "image-data", data: output.data, mediaType: "image/png" }
2316
+ ]
2317
+ };
2318
+ }
2319
+ envelope(block, content, isError = false) {
2320
+ return {
2321
+ type: "tool_result",
2322
+ tool_use_id: String(readField(block, "id")),
2323
+ toolset_name: _AnthropicComputer.TOOLSET,
2324
+ content,
2325
+ ...isError ? { is_error: true } : {}
2326
+ };
2327
+ }
2328
+ async runBlock(block) {
2329
+ const [name, payload] = this.member(block);
2330
+ try {
2331
+ const result = await this.executeAction({ ...payload, action: name });
2332
+ return [this.envelope(block, _AnthropicComputer.content(result)), false];
2333
+ } catch (error) {
2334
+ const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
2335
+ return [
2336
+ this.envelope(
2337
+ block,
2338
+ this.browser.scrub(`Error: ${detail}`).slice(0, MAX_ERROR2),
2339
+ true
2340
+ ),
2341
+ true
2342
+ ];
2343
+ }
2344
+ }
2345
+ };
2346
+ AnthropicComputer20251124 = class _AnthropicComputer20251124 extends AnthropicComputer {
2347
+ static TOOL_TYPE = "computer_20251124";
2348
+ static BETA = "computer-use-2025-11-24";
2349
+ static MAX_LONG_EDGE = 1568;
2350
+ static MAX_PIXELS = 115e4;
2351
+ static fits(width, height) {
2352
+ return Math.max(width, height) <= this.MAX_LONG_EDGE && width * height <= this.MAX_PIXELS;
2353
+ }
2354
+ tool() {
2355
+ return {
2356
+ type: _AnthropicComputer20251124.TOOL_TYPE,
2357
+ name: AnthropicComputer.TOOLSET,
2358
+ display_width_px: this.display.width,
2359
+ display_height_px: this.display.height,
2360
+ enable_zoom: true
2361
+ };
2362
+ }
2363
+ owns(block) {
2364
+ return readField(block, "type") === "tool_use" && readField(block, "name") === AnthropicComputer.TOOLSET;
2365
+ }
2366
+ member(block) {
2367
+ const { action, ...payload } = readField(block, "input") ?? {};
2368
+ return [String(action ?? ""), payload];
2369
+ }
2370
+ envelope(block, content, isError = false) {
2371
+ const { toolset_name: _dropped, ...rest } = super.envelope(
2372
+ block,
2373
+ content,
2374
+ isError
2375
+ );
2376
+ return rest;
2377
+ }
2378
+ };
2379
+ NativeComputer.register("anthropic", AnthropicComputer);
2380
+ NativeComputer.register(
2381
+ "anthropic-computer-20251124",
2382
+ AnthropicComputer20251124
2383
+ );
2384
+ }
2385
+ });
2386
+
2387
+ // src/worlds/nativeComputer/openai.ts
2388
+ function safetyCheck(raw) {
2389
+ const check = { id: String(readField(raw, "id") ?? "") };
2390
+ const code = readField(raw, "code");
2391
+ const message = readField(raw, "message");
2392
+ if (code !== void 0) check.code = String(code);
2393
+ if (message !== void 0) check.message = String(message);
2394
+ return check;
2395
+ }
2396
+ function dataUrl(png) {
2397
+ return `data:image/png;base64,${png.toString("base64")}`;
2398
+ }
2399
+ function xy(raw) {
2400
+ return {
2401
+ x: toInt(readField(raw, "x") ?? 0),
2402
+ y: toInt(readField(raw, "y") ?? 0)
2403
+ };
2404
+ }
2405
+ function held(raw) {
2406
+ return modifierKeys(readField(raw, "keys"));
2407
+ }
2408
+ var WAIT_SECONDS, BUTTONS, HISTORY_BUTTONS, PendingSafetyChecks, ACTIONS, OpenAIComputer, OpenAIPreviewComputer;
2409
+ var init_openai = __esm({
2410
+ "src/worlds/nativeComputer/openai.ts"() {
2411
+ "use strict";
2412
+ init_actions();
2413
+ init_base();
2414
+ init_keys();
2415
+ WAIT_SECONDS = 1;
2416
+ BUTTONS = {
2417
+ left: "left",
2418
+ right: "right",
2419
+ wheel: "middle",
2420
+ middle: "middle"
2421
+ };
2422
+ HISTORY_BUTTONS = /* @__PURE__ */ new Set(["back", "forward"]);
2423
+ PendingSafetyChecks = class extends Error {
2424
+ constructor(callId, checks) {
2425
+ const listed = checks.map((c) => `${c.code ?? "check"}: ${c.message ?? ""}`.trim()).join("; ");
2426
+ super(
2427
+ `computer_call ${callId} needs ${checks.length} safety check(s) acknowledged: ${listed}`
2428
+ );
2429
+ this.callId = callId;
2430
+ this.checks = checks;
2431
+ this.name = "PendingSafetyChecks";
2432
+ }
2433
+ callId;
2434
+ checks;
2435
+ };
2436
+ ACTIONS = {
2437
+ click: (raw) => {
2438
+ const button = String(readField(raw, "button") ?? "left");
2439
+ if (HISTORY_BUTTONS.has(button))
2440
+ return new ComputerAction("history", {
2441
+ direction: button
2442
+ });
2443
+ if (!Object.hasOwn(BUTTONS, button))
2444
+ throw new Error(`unknown mouse button: ${button}`);
2445
+ return new ComputerAction("click", {
2446
+ ...xy(raw),
2447
+ button: BUTTONS[button],
2448
+ count: 1,
2449
+ modifiers: held(raw)
2450
+ });
2451
+ },
2452
+ double_click: (raw) => new ComputerAction("click", {
2453
+ ...xy(raw),
2454
+ button: "left",
2455
+ count: 2,
2456
+ modifiers: held(raw)
2457
+ }),
2458
+ drag: (raw) => new ComputerAction("drag", {
2459
+ path: (readField(raw, "path") ?? []).map(
2460
+ (p) => [toInt(readField(p, "x")), toInt(readField(p, "y"))]
2461
+ ),
2462
+ modifiers: held(raw)
2463
+ }),
2464
+ keypress: (raw) => new ComputerAction("key", {
2465
+ keys: [
2466
+ ...KeyChord.fromKeys(readField(raw, "keys") ?? []).keys
2467
+ ],
2468
+ repeat: 1
2469
+ }),
2470
+ move: (raw) => new ComputerAction("move", { ...xy(raw), modifiers: held(raw) }),
2471
+ scroll: (raw) => new ComputerAction("scroll", {
2472
+ ...xy(raw),
2473
+ dx: toInt(readField(raw, "scroll_x", "scrollX") ?? 0),
2474
+ dy: toInt(readField(raw, "scroll_y", "scrollY") ?? 0),
2475
+ modifiers: held(raw)
2476
+ }),
2477
+ type: (raw) => new ComputerAction("type", { text: String(readField(raw, "text") ?? "") }),
2478
+ wait: () => new ComputerAction("wait", { seconds: WAIT_SECONDS }),
2479
+ screenshot: () => new ComputerAction("screenshot")
2480
+ };
2481
+ OpenAIComputer = class _OpenAIComputer extends NativeComputer {
2482
+ tool() {
2483
+ return { type: "computer" };
2484
+ }
2485
+ owns(item) {
2486
+ return readField(item, "type") === "computer_call";
2487
+ }
2488
+ parse(raw) {
2489
+ const kind = String(readField(raw, "type"));
2490
+ const parser = Object.hasOwn(ACTIONS, kind) ? ACTIONS[kind] : void 0;
2491
+ if (!parser) throw new Error(`unknown computer action: ${kind}`);
2492
+ return parser(raw);
2493
+ }
2494
+ static actionsOf(call) {
2495
+ const batch = readField(call, "actions");
2496
+ if (Array.isArray(batch)) return batch;
2497
+ const single = readField(call, "action");
2498
+ return single === void 0 ? [] : [single];
2499
+ }
2500
+ /** Run a `computer_call`'s actions and return its `computer_call_output`.
2501
+ * Throws `PendingSafetyChecks` (before anything runs) while a check the
2502
+ * model raised is not in `acknowledged`. */
2503
+ async execute(call, acknowledged = []) {
2504
+ const callId = String(readField(call, "call_id", "callId"));
2505
+ const checks = (readField(
2506
+ call,
2507
+ "pending_safety_checks",
2508
+ "pendingSafetyChecks"
2509
+ ) ?? []).map(safetyCheck);
2510
+ const png = await this.runCall(
2511
+ callId,
2512
+ _OpenAIComputer.actionsOf(call),
2513
+ checks,
2514
+ acknowledged
2515
+ );
2516
+ return {
2517
+ type: "computer_call_output",
2518
+ call_id: callId,
2519
+ output: {
2520
+ type: "computer_screenshot",
2521
+ image_url: dataUrl(png),
2522
+ detail: "original"
2523
+ },
2524
+ ...checks.length > 0 ? { acknowledged_safety_checks: checks } : {}
2525
+ };
2526
+ }
2527
+ /** For `openai.tools.computer({ ...computer.aiSdk() })`: `execute` runs a
2528
+ * call's `actions` and returns the screenshot output. A call with pending
2529
+ * safety checks asks for approval first (`needsApproval`), so the AI SDK's
2530
+ * approval flow puts them in front of a person; once approved, `execute`
2531
+ * acknowledges them. */
2532
+ aiSdk() {
2533
+ return {
2534
+ needsApproval: (input) => (input.pendingSafetyChecks ?? []).length > 0,
2535
+ execute: (input) => this.serial(async () => {
2536
+ const checks = (input.pendingSafetyChecks ?? []).map(safetyCheck);
2537
+ const png = await this.runCall(
2538
+ "ai-sdk",
2539
+ input.actions ?? [],
2540
+ checks,
2541
+ checks
2542
+ );
2543
+ return {
2544
+ output: { type: "computer_screenshot", imageUrl: dataUrl(png) },
2545
+ ...checks.length > 0 ? { acknowledgedSafetyChecks: checks } : {}
2546
+ };
2547
+ })
2548
+ };
2549
+ }
2550
+ /** The batch's actions, run after the safety checks clear; the screen after them. */
2551
+ async runCall(callId, rawActions, checks, acknowledged) {
2552
+ const cleared = new Set(acknowledged.map((c) => safetyCheck(c).id));
2553
+ const waiting = checks.filter((c) => !c.id || !cleared.has(c.id));
2554
+ if (waiting.length > 0) throw new PendingSafetyChecks(callId, waiting);
2555
+ const actions = rawActions.map((raw) => this.parse(raw));
2556
+ const results = await this.performAll(actions);
2557
+ const last = actions.at(-1);
2558
+ if (last?.name === "screenshot")
2559
+ return results.at(-1)?.image ?? Buffer.alloc(0);
2560
+ return this.screenshot();
2561
+ }
2562
+ };
2563
+ OpenAIPreviewComputer = class extends OpenAIComputer {
2564
+ tool() {
2565
+ return {
2566
+ type: "computer_use_preview",
2567
+ display_width: this.display.width,
2568
+ display_height: this.display.height,
2569
+ environment: "browser"
2570
+ };
2571
+ }
2572
+ };
2573
+ NativeComputer.register("openai", OpenAIComputer);
2574
+ NativeComputer.register("openai-preview", OpenAIPreviewComputer);
2575
+ }
2576
+ });
2577
+
2578
+ // src/worlds/nativeComputer/index.ts
2579
+ var init_nativeComputer = __esm({
2580
+ "src/worlds/nativeComputer/index.ts"() {
2581
+ "use strict";
2582
+ init_actions();
2583
+ init_base();
2584
+ init_display();
2585
+ init_keys();
2586
+ init_screen();
2587
+ init_trace();
2588
+ init_anthropic();
2589
+ init_openai();
2590
+ }
2591
+ });
2592
+
1326
2593
  // src/worlds/sessionContract.ts
1327
2594
  function serializeCallBody(body) {
1328
2595
  const text2 = JSON.stringify(body);
@@ -1359,18 +2626,87 @@ var init_sessionContract = __esm({
1359
2626
  this.limit = limit;
1360
2627
  this.name = "WorldCallTooLarge";
1361
2628
  }
1362
- size;
1363
- limitBytes;
1364
- limit;
1365
- code = "payload_too_large";
1366
- /** The structured refusal the CLIs print. */
1367
- toJSON() {
1368
- return {
1369
- status: "error",
1370
- code: this.code,
1371
- limit: this.limit,
1372
- size: this.size
1373
- };
2629
+ size;
2630
+ limitBytes;
2631
+ limit;
2632
+ code = "payload_too_large";
2633
+ /** The structured refusal the CLIs print. */
2634
+ toJSON() {
2635
+ return {
2636
+ status: "error",
2637
+ code: this.code,
2638
+ limit: this.limit,
2639
+ size: this.size
2640
+ };
2641
+ }
2642
+ };
2643
+ }
2644
+ });
2645
+
2646
+ // src/tracing/session.ts
2647
+ var session_exports = {};
2648
+ __export(session_exports, {
2649
+ SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
2650
+ SessionSpanProcessor: () => SessionSpanProcessor,
2651
+ WORLD_SESSION_ID_ATTRIBUTE: () => WORLD_SESSION_ID_ATTRIBUTE,
2652
+ getAmbientSessionId: () => getAmbientSessionId,
2653
+ getCurrentWorldSessionId: () => getCurrentWorldSessionId,
2654
+ withSession: () => withSession,
2655
+ withWorldSession: () => withWorldSession
2656
+ });
2657
+ function getAmbientSessionId() {
2658
+ return currentSessionStorage.getStore();
2659
+ }
2660
+ function getCurrentWorldSessionId() {
2661
+ return currentWorldSessionStorage.getStore();
2662
+ }
2663
+ function runIn(storage, value, fn) {
2664
+ return new Promise((resolve11, reject) => {
2665
+ storage.run(value, () => {
2666
+ Promise.resolve().then(fn).then(resolve11, reject);
2667
+ });
2668
+ });
2669
+ }
2670
+ function withSession(sessionId, fn) {
2671
+ return runIn(currentSessionStorage, sessionId, fn);
2672
+ }
2673
+ function withWorldSession(worldSessionId, fn) {
2674
+ return runIn(
2675
+ currentWorldSessionStorage,
2676
+ worldSessionId,
2677
+ () => withSession(worldSessionId, fn)
2678
+ );
2679
+ }
2680
+ var import_async_hooks2, SESSION_ID_ATTRIBUTE, WORLD_SESSION_ID_ATTRIBUTE, processStorage, currentSessionStorage, currentWorldSessionStorage, SessionSpanProcessor;
2681
+ var init_session = __esm({
2682
+ "src/tracing/session.ts"() {
2683
+ "use strict";
2684
+ import_async_hooks2 = require("async_hooks");
2685
+ SESSION_ID_ATTRIBUTE = "gateway.session.id";
2686
+ WORLD_SESSION_ID_ATTRIBUTE = "gateway.trace.metadata.world_session_id";
2687
+ processStorage = (name) => {
2688
+ const key2 = /* @__PURE__ */ Symbol.for(`@withgateway/sdk/${name}`);
2689
+ const slots = globalThis;
2690
+ slots[key2] ??= new import_async_hooks2.AsyncLocalStorage();
2691
+ return slots[key2];
2692
+ };
2693
+ currentSessionStorage = processStorage("session-storage");
2694
+ currentWorldSessionStorage = processStorage("world-session-storage");
2695
+ SessionSpanProcessor = class {
2696
+ onStart(span, _parentContext) {
2697
+ const worldSessionId = getCurrentWorldSessionId();
2698
+ if (worldSessionId)
2699
+ span.setAttribute(WORLD_SESSION_ID_ATTRIBUTE, worldSessionId);
2700
+ const sessionId = getAmbientSessionId();
2701
+ if (!sessionId || span.attributes?.[SESSION_ID_ATTRIBUTE] !== void 0)
2702
+ return;
2703
+ span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
2704
+ }
2705
+ onEnd(_span) {
2706
+ }
2707
+ async shutdown() {
2708
+ }
2709
+ async forceFlush() {
1374
2710
  }
1375
2711
  };
1376
2712
  }
@@ -1400,8 +2736,8 @@ var init_taskRef = __esm({
1400
2736
  });
1401
2737
 
1402
2738
  // src/worlds/session.ts
1403
- var session_exports = {};
1404
- __export(session_exports, {
2739
+ var session_exports2 = {};
2740
+ __export(session_exports2, {
1405
2741
  WorldSession: () => WorldSession,
1406
2742
  WorldSessionCallError: () => WorldSessionCallError,
1407
2743
  WorldSessionTimeout: () => WorldSessionTimeout,
@@ -1454,7 +2790,7 @@ function schemaFromSignature(spec) {
1454
2790
  };
1455
2791
  const inside = /\(([\s\S]*)\)\s*$/.exec(spec.signature.trim())?.[1] ?? "";
1456
2792
  const properties = {};
1457
- const required = [];
2793
+ const required2 = [];
1458
2794
  const params = [];
1459
2795
  let depth = 0;
1460
2796
  let current = "";
@@ -1475,7 +2811,7 @@ function schemaFromSignature(spec) {
1475
2811
  if (!name) continue;
1476
2812
  if (eq === -1) {
1477
2813
  properties[name] = { type: "string" };
1478
- required.push(name);
2814
+ required2.push(name);
1479
2815
  continue;
1480
2816
  }
1481
2817
  const value = param.slice(eq + 1).trim();
@@ -1489,7 +2825,7 @@ function schemaFromSignature(spec) {
1489
2825
  function: {
1490
2826
  name: modelToolName(spec.name),
1491
2827
  description: spec.doc ?? spec.name,
1492
- parameters: { type: "object", properties, required }
2828
+ parameters: { type: "object", properties, required: required2 }
1493
2829
  }
1494
2830
  };
1495
2831
  }
@@ -1558,13 +2894,16 @@ async function runSessions(opts) {
1558
2894
  task = taskLabel(taskRef, session.taskInfo);
1559
2895
  await session.ready();
1560
2896
  const toolkit = await session.toolkit();
1561
- await opts.agent({
1562
- session,
1563
- toolkit,
1564
- instruction: session.instruction ?? (isTaskSpec(taskRef) ? taskRef.instruction : task),
1565
- task,
1566
- taskRef
1567
- });
2897
+ const live = session;
2898
+ await live.withTraceContext(
2899
+ () => opts.agent({
2900
+ session: live,
2901
+ toolkit,
2902
+ instruction: live.instruction ?? (isTaskSpec(taskRef) ? taskRef.instruction : task),
2903
+ task,
2904
+ taskRef
2905
+ })
2906
+ );
1568
2907
  const graded = await session.grade();
1569
2908
  const result = {
1570
2909
  task,
@@ -1601,14 +2940,16 @@ async function runSessions(opts) {
1601
2940
  passed: failed === 0 && (opts.failUnder === void 0 || mean >= opts.failUnder)
1602
2941
  };
1603
2942
  }
1604
- var import_node_crypto, READY_TIMEOUT_MS, READY_POLL_MS, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep2, modelToolName, WorldSessionTimeout, WorldSessionCallError, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
1605
- var init_session = __esm({
2943
+ var import_node_crypto2, READY_TIMEOUT_MS, READY_POLL_MS, CALL_TIMEOUT_MS, CALL_POLL_MS, JUDGED_GRADE_TIMEOUT_MS, JUDGED_GRADE_POLL_MS, EXPORT_PAGE, sleep2, modelToolName, WorldSessionTimeout, WorldSessionCallError, WorldSession, OPEN_SESSION_OPTION_KEYS, isOpenSessionOptions;
2944
+ var init_session2 = __esm({
1606
2945
  "src/worlds/session.ts"() {
1607
2946
  "use strict";
1608
- import_node_crypto = require("crypto");
2947
+ import_node_crypto2 = require("crypto");
1609
2948
  init_worlds();
1610
2949
  init_browser();
2950
+ init_nativeComputer();
1611
2951
  init_sessionContract();
2952
+ init_session();
1612
2953
  init_taskRef();
1613
2954
  init_taskRef();
1614
2955
  READY_TIMEOUT_MS = 10 * 6e4;
@@ -1742,7 +3083,7 @@ var init_session = __esm({
1742
3083
  /** The reporter `browser()` uses; exposed for a page you drive yourself. */
1743
3084
  browserRecorder(agentId) {
1744
3085
  const path16 = `/api/public/world-sessions/${encodeURIComponent(this.sessionId)}/browser-events`;
1745
- const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0, import_node_crypto.randomUUID)().replace(/-/g, "").slice(0, 8)}`;
3086
+ const id = agentId ?? process.env.GATEWAY_AGENT_ID ?? `agent-${(0, import_node_crypto2.randomUUID)().replace(/-/g, "").slice(0, 8)}`;
1746
3087
  return new BrowserActionRecorder(
1747
3088
  async (events) => {
1748
3089
  await apiRequest(this.options, "POST", path16, { events });
@@ -1762,6 +3103,12 @@ var init_session = __esm({
1762
3103
  computerUseTools(browser) {
1763
3104
  return computerUseToolkit(browser);
1764
3105
  }
3106
+ /** The browser as a provider's own pixel-based computer-use tool: `anthropic`
3107
+ * (`computer_toolset_20260801`), `openai` (Responses `computer`),
3108
+ * `anthropic-computer-20251124` or `openai-preview`. See `nativeComputer/`. */
3109
+ nativeComputer(browser, provider = "anthropic", options = {}) {
3110
+ return NativeComputer.forProvider(provider, browser, options);
3111
+ }
1765
3112
  /** The session's latest platform state (one request, no waiting). */
1766
3113
  async status() {
1767
3114
  const fresh = await apiRequest(
@@ -1996,6 +3343,21 @@ var init_session = __esm({
1996
3343
  { keepWarm: opts.keepWarm ?? false }
1997
3344
  );
1998
3345
  }
3346
+ /**
3347
+ * Run `fn` as work inside this session: spans it records take `sessionId`
3348
+ * as their session id and carry `world_session_id` trace metadata, so the
3349
+ * agent's traces land in the same session as the platform's traces of this
3350
+ * session's tool calls. A `withSession()` block inside still wins for the
3351
+ * session id. No effect before `tracing.init()`. `runSessions` wraps each
3352
+ * agent call in it.
3353
+ *
3354
+ * ```typescript
3355
+ * await session.withTraceContext(() => myAgent(toolkit, session.instruction));
3356
+ * ```
3357
+ */
3358
+ withTraceContext(fn) {
3359
+ return withWorldSession(this.sessionId, fn);
3360
+ }
1999
3361
  };
2000
3362
  OPEN_SESSION_OPTION_KEYS = /* @__PURE__ */ new Set([
2001
3363
  "task",
@@ -2117,6 +3479,28 @@ var init_tasks = __esm({
2117
3479
  }
2118
3480
  });
2119
3481
 
3482
+ // src/worlds/surfaceDescriptor.ts
3483
+ function surfaceDescriptor(s) {
3484
+ return {
3485
+ surfaces: surfaceKinds(s),
3486
+ ...s.api ? { api: { url: s.api.url, ...s.api.token ? { token: s.api.token } : {} } } : {},
3487
+ ...s.ui ? { ui: { url: s.ui.url, entry: uiEntryUrl(s.ui), apiPath: s.ui.apiPath ?? null } } : {},
3488
+ ...s.browser ? {
3489
+ browser: {
3490
+ wsUrl: s.browser.wsUrl,
3491
+ viewport: s.browser.viewport,
3492
+ ...s.browser.tier ? { tier: s.browser.tier } : {}
3493
+ }
3494
+ } : {}
3495
+ };
3496
+ }
3497
+ var init_surfaceDescriptor = __esm({
3498
+ "src/worlds/surfaceDescriptor.ts"() {
3499
+ "use strict";
3500
+ init_browser();
3501
+ }
3502
+ });
3503
+
2120
3504
  // src/worlds/taskSessions.ts
2121
3505
  function aggregateTaskGrade(worlds) {
2122
3506
  const rewards = {};
@@ -2145,7 +3529,11 @@ function fromResponse(answer, options) {
2145
3529
  const worlds = {};
2146
3530
  for (const [alias, state2] of Object.entries(answer.sessions)) {
2147
3531
  sessions2[alias] = new WorldSession(state2.sessionId, state2, options);
2148
- worlds[alias] = { slug: state2.slug, ref: state2.ref };
3532
+ worlds[alias] = {
3533
+ slug: state2.slug,
3534
+ ref: state2.ref,
3535
+ private: state2.private ?? null
3536
+ };
2149
3537
  }
2150
3538
  return new TaskSessions(
2151
3539
  answer.taskId,
@@ -2219,6 +3607,7 @@ async function attachTask(taskId, options = {}) {
2219
3607
  {
2220
3608
  slug: row.slug ?? "",
2221
3609
  ref: null,
3610
+ private: null,
2222
3611
  versionId: row.versionId,
2223
3612
  sessionId: row.sessionId,
2224
3613
  ready: row.ready,
@@ -2248,7 +3637,7 @@ async function attachManifest(manifest, options = {}) {
2248
3637
  Object.fromEntries(
2249
3638
  Object.entries(manifest.sessions).map(([alias, entry]) => [
2250
3639
  alias,
2251
- { slug: entry.slug, ref: entry.ref }
3640
+ { slug: entry.slug, ref: entry.ref, private: entry.private ?? null }
2252
3641
  ])
2253
3642
  )
2254
3643
  );
@@ -2262,28 +3651,19 @@ var init_taskSessions = __esm({
2262
3651
  "use strict";
2263
3652
  init_worlds();
2264
3653
  init_browser();
2265
- init_session();
3654
+ init_surfaceDescriptor();
3655
+ init_session2();
2266
3656
  TASK_SESSIONS = "/api/public/world-task-sessions";
2267
3657
  VERIFIER_REWARD_PREFIX = "x.";
2268
3658
  manifestSession = (s, state2, world) => ({
2269
3659
  slug: world.slug,
2270
3660
  ref: world.ref,
3661
+ private: world.private,
2271
3662
  versionId: state2.versionId,
2272
3663
  sessionId: state2.sessionId,
2273
3664
  ready: state2.ready,
2274
3665
  state: state2.state,
2275
- surfaces: surfaceKinds(s),
2276
- ...s.api ? {
2277
- api: { url: s.api.url, ...s.api.token ? { token: s.api.token } : {} }
2278
- } : {},
2279
- ...s.ui ? {
2280
- ui: {
2281
- url: s.ui.url,
2282
- entry: uiEntryUrl(s.ui),
2283
- apiPath: s.ui.apiPath ?? null
2284
- }
2285
- } : {},
2286
- ...s.browser ? { browser: { wsUrl: s.browser.wsUrl, viewport: s.browser.viewport } } : {}
3666
+ ...surfaceDescriptor(s)
2287
3667
  });
2288
3668
  TaskSessions = class {
2289
3669
  constructor(taskId, taskVersion, name, instruction, sessions2, worlds, hash = null) {
@@ -2302,10 +3682,10 @@ var init_taskSessions = __esm({
2302
3682
  sessions;
2303
3683
  worlds;
2304
3684
  hash;
2305
- /** This alias's `{slug, ref}` as recorded at open/attach — the world a
2306
- * `TaskRun` filing needs to name, without exposing the whole map. */
3685
+ /** This alias's world as recorded at open/attach — what a `TaskRun`
3686
+ * filing needs to name, without exposing the whole map. */
2307
3687
  worldRef(alias) {
2308
- return this.worlds[alias] ?? { slug: "", ref: null };
3688
+ return this.worlds[alias] ?? { slug: "", ref: null, private: null };
2309
3689
  }
2310
3690
  /** The aliases, in the spec's order. */
2311
3691
  get aliases() {
@@ -2462,6 +3842,49 @@ var init_evals = __esm({
2462
3842
  }
2463
3843
  });
2464
3844
 
3845
+ // src/tracing/prerequisites.ts
3846
+ function getEnv(key2) {
3847
+ const value = process.env[key2];
3848
+ return value ? value : void 0;
3849
+ }
3850
+ function isGatewayConfigured() {
3851
+ return !!(getEnv(GATEWAY_ENV.HOST) && getEnv(GATEWAY_ENV.PUBLIC_KEY) && getEnv(GATEWAY_ENV.SECRET_KEY));
3852
+ }
3853
+ var GATEWAY_ENV, OPENTELEMETRY_PEERS, MODULE_NOT_FOUND, OpenTelemetryMissing;
3854
+ var init_prerequisites = __esm({
3855
+ "src/tracing/prerequisites.ts"() {
3856
+ "use strict";
3857
+ GATEWAY_ENV = {
3858
+ HOST: "GATEWAY_HOST",
3859
+ PUBLIC_KEY: "GATEWAY_PUBLIC_KEY",
3860
+ SECRET_KEY: "GATEWAY_SECRET_KEY",
3861
+ ENDPOINT: "GATEWAY_OTLP_ENDPOINT"
3862
+ };
3863
+ OPENTELEMETRY_PEERS = [
3864
+ "@opentelemetry/api",
3865
+ "@opentelemetry/exporter-trace-otlp-http",
3866
+ "@opentelemetry/resources",
3867
+ "@opentelemetry/sdk-trace-base",
3868
+ "@opentelemetry/sdk-trace-node"
3869
+ ];
3870
+ MODULE_NOT_FOUND = /* @__PURE__ */ new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
3871
+ OpenTelemetryMissing = class _OpenTelemetryMissing extends Error {
3872
+ constructor() {
3873
+ super(
3874
+ `OpenTelemetry packages not found. Install them with:
3875
+ npm install ${OPENTELEMETRY_PEERS.join(" ")}`
3876
+ );
3877
+ this.name = "OpenTelemetryMissing";
3878
+ }
3879
+ static explains(error) {
3880
+ if (error instanceof _OpenTelemetryMissing) return true;
3881
+ const { code, message } = error ?? {};
3882
+ return MODULE_NOT_FOUND.has(String(code)) && String(message).includes("@opentelemetry/");
3883
+ }
3884
+ };
3885
+ }
3886
+ });
3887
+
2465
3888
  // src/tracing/identity.ts
2466
3889
  function resolveUserId() {
2467
3890
  const contextual = currentUserStorage.getStore();
@@ -2508,15 +3931,15 @@ function debugLog(message, ...args) {
2508
3931
  console.debug(`[gatewaysdk.tracing] ${message}`, ...args);
2509
3932
  }
2510
3933
  }
2511
- var import_async_hooks2, import_api2, USER_ID_ATTRIBUTE, currentUserStorage, IdentitySpanProcessor;
3934
+ var import_async_hooks3, import_api2, USER_ID_ATTRIBUTE, currentUserStorage, IdentitySpanProcessor;
2512
3935
  var init_identity = __esm({
2513
3936
  "src/tracing/identity.ts"() {
2514
3937
  "use strict";
2515
- import_async_hooks2 = require("async_hooks");
3938
+ import_async_hooks3 = require("async_hooks");
2516
3939
  import_api2 = require("@opentelemetry/api");
2517
3940
  init_users();
2518
3941
  USER_ID_ATTRIBUTE = "gateway.user.id";
2519
- currentUserStorage = new import_async_hooks2.AsyncLocalStorage();
3942
+ currentUserStorage = new import_async_hooks3.AsyncLocalStorage();
2520
3943
  IdentitySpanProcessor = class {
2521
3944
  onStart(span, _parentContext) {
2522
3945
  const userId = resolveUserId();
@@ -2534,43 +3957,224 @@ var init_identity = __esm({
2534
3957
  }
2535
3958
  });
2536
3959
 
2537
- // src/tracing/session.ts
2538
- var session_exports2 = {};
2539
- __export(session_exports2, {
2540
- SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
2541
- SessionSpanProcessor: () => SessionSpanProcessor,
2542
- getAmbientSessionId: () => getAmbientSessionId,
2543
- withSession: () => withSession
2544
- });
2545
- function getAmbientSessionId() {
2546
- return currentSessionStorage.getStore();
3960
+ // src/tracing/secrets.ts
3961
+ function jsonOrUndefined(text2) {
3962
+ let parsed;
3963
+ try {
3964
+ parsed = JSON.parse(text2);
3965
+ } catch {
3966
+ return void 0;
3967
+ }
3968
+ if (typeof parsed === "string") return parsed;
3969
+ return parsed !== null && typeof parsed === "object" ? parsed : void 0;
2547
3970
  }
2548
- function withSession(sessionId, fn) {
2549
- return new Promise((resolve11, reject) => {
2550
- currentSessionStorage.run(sessionId, () => {
2551
- Promise.resolve().then(fn).then(resolve11, reject);
2552
- });
3971
+ function encodings(value) {
3972
+ return [value, percentEncoded(value), JSON.stringify(value).slice(1, -1)];
3973
+ }
3974
+ function percentEncoded(value) {
3975
+ try {
3976
+ return encodeURIComponent(value);
3977
+ } catch {
3978
+ return value;
3979
+ }
3980
+ }
3981
+ function union(sets) {
3982
+ return new Set(sets.flatMap((set) => [...set]));
3983
+ }
3984
+ function leaves(value) {
3985
+ if (typeof value === "string") {
3986
+ return [...value].length >= MIN_SECRET_LENGTH ? /* @__PURE__ */ new Set([value]) : /* @__PURE__ */ new Set();
3987
+ }
3988
+ if (Array.isArray(value)) return union(value.map(leaves));
3989
+ if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
3990
+ return union(Object.values(value).map(leaves));
3991
+ }
3992
+ function sameAttributes(before, after) {
3993
+ const keys = Object.keys(before);
3994
+ if (keys.length !== Object.keys(after).length) return false;
3995
+ return keys.every(
3996
+ (key2) => before[key2] === after[key2] || sameArray(before[key2], after[key2])
3997
+ );
3998
+ }
3999
+ function sameArray(before, after) {
4000
+ if (!Array.isArray(before) || !Array.isArray(after)) return false;
4001
+ return before.length === after.length && before.every((item, i) => item === after[i]);
4002
+ }
4003
+ function scrubbedRead(reads, property) {
4004
+ return typeof property === "string" && property in reads ? reads[property] : void 0;
4005
+ }
4006
+ function viewOf(span, reads) {
4007
+ const view = new Proxy(span, {
4008
+ get(target, property) {
4009
+ const read = scrubbedRead(reads, property);
4010
+ if (read) return read();
4011
+ const value = Reflect.get(target, property, target);
4012
+ if (typeof value !== "function") return value;
4013
+ return (...args) => {
4014
+ const result = value.apply(target, args);
4015
+ return result === target ? view : result;
4016
+ };
4017
+ },
4018
+ getOwnPropertyDescriptor(target, property) {
4019
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
4020
+ const read = scrubbedRead(reads, property);
4021
+ if (!read || !descriptor || !("value" in descriptor)) return descriptor;
4022
+ return { ...descriptor, value: read() };
4023
+ }
2553
4024
  });
4025
+ return view;
2554
4026
  }
2555
- var import_async_hooks3, SESSION_ID_ATTRIBUTE, currentSessionStorage, SessionSpanProcessor;
2556
- var init_session2 = __esm({
2557
- "src/tracing/session.ts"() {
4027
+ var SECRET_KEYS, REDACTED2, MIN_SECRET_LENGTH, SpanSecrets, SPAN_SECRETS, SecretRedactingSpanProcessor;
4028
+ var init_secrets = __esm({
4029
+ "src/tracing/secrets.ts"() {
2558
4030
  "use strict";
2559
- import_async_hooks3 = require("async_hooks");
2560
- SESSION_ID_ATTRIBUTE = "gateway.session.id";
2561
- currentSessionStorage = new import_async_hooks3.AsyncLocalStorage();
2562
- SessionSpanProcessor = class {
2563
- onStart(span, _parentContext) {
2564
- const sessionId = getAmbientSessionId();
2565
- if (sessionId) {
2566
- span.setAttribute(SESSION_ID_ATTRIBUTE, sessionId);
4031
+ SECRET_KEYS = /* @__PURE__ */ new Set([
4032
+ "authorization_token",
4033
+ "authorizationToken"
4034
+ ]);
4035
+ REDACTED2 = "[redacted: holds a credential]";
4036
+ MIN_SECRET_LENGTH = 8;
4037
+ SpanSecrets = class {
4038
+ constructor(keys = SECRET_KEYS) {
4039
+ this.keys = keys;
4040
+ }
4041
+ keys;
4042
+ isSecret(key2) {
4043
+ return this.keys.has(key2);
4044
+ }
4045
+ drops(attribute) {
4046
+ return this.mentions(attribute);
4047
+ }
4048
+ strip(value) {
4049
+ if (typeof value === "string") return this.stripNested(value);
4050
+ if (Array.isArray(value)) return value.map((item) => this.strip(item));
4051
+ if (value === null || typeof value !== "object") return value;
4052
+ return Object.fromEntries(
4053
+ Object.entries(value).filter(([key2]) => !this.isSecret(key2)).map(([key2, item]) => [key2, this.strip(item)])
4054
+ );
4055
+ }
4056
+ scrubAttribute(value) {
4057
+ try {
4058
+ return this.scrubbedValue(value);
4059
+ } catch {
4060
+ return Array.isArray(value) ? [REDACTED2] : REDACTED2;
2567
4061
  }
2568
4062
  }
2569
- onEnd(_span) {
4063
+ scrubbedValue(value) {
4064
+ if (typeof value === "string") return this.scrubbedText(value);
4065
+ if (!Array.isArray(value)) return value;
4066
+ const results = value.map(
4067
+ (item) => typeof item === "string" ? this.cleaned(item) : { text: item, removed: /* @__PURE__ */ new Set() }
4068
+ );
4069
+ const removed = new Set(results.flatMap((r) => [...r.removed]));
4070
+ const scrubbed = results.map((r) => r.text);
4071
+ const withheld = scrubbed.some(
4072
+ (item) => typeof item === "string" && this.carries(item, removed)
4073
+ );
4074
+ return withheld ? [REDACTED2] : scrubbed;
2570
4075
  }
2571
- async shutdown() {
4076
+ scrubAttributes(attributes) {
4077
+ return Object.fromEntries(
4078
+ Object.entries(attributes).filter(([key2]) => !this.drops(key2)).map(([key2, value]) => [key2, this.scrubAttribute(value)])
4079
+ );
2572
4080
  }
2573
- async forceFlush() {
4081
+ mentions(text2) {
4082
+ return [...this.keys].some((key2) => text2.includes(key2));
4083
+ }
4084
+ scrubbedText(text2) {
4085
+ const { text: cleaned, removed } = this.cleaned(text2);
4086
+ return this.carries(cleaned, removed) ? REDACTED2 : cleaned;
4087
+ }
4088
+ cleaned(text2) {
4089
+ if (!this.mentions(text2)) return { text: text2, removed: /* @__PURE__ */ new Set() };
4090
+ const parsed = jsonOrUndefined(text2);
4091
+ if (parsed === void 0) return { text: REDACTED2, removed: /* @__PURE__ */ new Set() };
4092
+ return {
4093
+ text: JSON.stringify(this.strip(parsed)),
4094
+ removed: this.removed(parsed)
4095
+ };
4096
+ }
4097
+ carries(text2, removed) {
4098
+ if (text2 === REDACTED2 || this.mentions(text2)) return true;
4099
+ return [...removed].some(
4100
+ (value) => encodings(value).some((form) => text2.includes(form))
4101
+ );
4102
+ }
4103
+ removed(value) {
4104
+ if (typeof value === "string") {
4105
+ const nested = this.mentions(value) ? jsonOrUndefined(value) : void 0;
4106
+ return nested === void 0 ? /* @__PURE__ */ new Set() : this.removed(nested);
4107
+ }
4108
+ if (Array.isArray(value)) return union(value.map((v) => this.removed(v)));
4109
+ if (value === null || typeof value !== "object") return /* @__PURE__ */ new Set();
4110
+ return union(
4111
+ Object.entries(value).map(
4112
+ ([key2, item]) => this.isSecret(key2) ? leaves(item) : this.removed(item)
4113
+ )
4114
+ );
4115
+ }
4116
+ stripNested(text2) {
4117
+ if (!this.mentions(text2)) return text2;
4118
+ const parsed = jsonOrUndefined(text2);
4119
+ if (parsed === void 0) return text2;
4120
+ return JSON.stringify(this.strip(parsed));
4121
+ }
4122
+ };
4123
+ SPAN_SECRETS = new SpanSecrets();
4124
+ SecretRedactingSpanProcessor = class {
4125
+ constructor(inner, secrets = SPAN_SECRETS) {
4126
+ this.inner = inner;
4127
+ this.secrets = secrets;
4128
+ }
4129
+ inner;
4130
+ secrets;
4131
+ views = /* @__PURE__ */ new WeakMap();
4132
+ onStart(span, parentContext) {
4133
+ this.inner.onStart(this.viewFor(span), parentContext);
4134
+ }
4135
+ onEnd(span) {
4136
+ const view = this.viewFor(span);
4137
+ try {
4138
+ void [view.attributes, view.events, view.status];
4139
+ } catch (error) {
4140
+ console.warn(
4141
+ `[gatewaysdk.tracing] Dropped span "${span.name}": could not redact it: ${error?.name}`
4142
+ );
4143
+ return;
4144
+ }
4145
+ this.inner.onEnd(view);
4146
+ }
4147
+ viewFor(span) {
4148
+ const known = this.views.get(span);
4149
+ if (known) return known;
4150
+ const view = viewOf(span, {
4151
+ attributes: () => this.scrubbedAttributes(span.attributes),
4152
+ events: () => span.events.map((event) => this.scrubbedEvent(event)),
4153
+ status: () => this.scrubbedStatus(span.status)
4154
+ });
4155
+ this.views.set(span, view);
4156
+ return view;
4157
+ }
4158
+ forceFlush() {
4159
+ return this.inner.forceFlush();
4160
+ }
4161
+ shutdown() {
4162
+ return this.inner.shutdown();
4163
+ }
4164
+ scrubbedAttributes(attributes) {
4165
+ const clean = this.secrets.scrubAttributes(attributes);
4166
+ return sameAttributes(attributes, clean) ? attributes : clean;
4167
+ }
4168
+ scrubbedStatus(status) {
4169
+ if (!status.message) return status;
4170
+ const message = this.secrets.scrubAttribute(status.message);
4171
+ return message === status.message ? status : { ...status, message };
4172
+ }
4173
+ scrubbedEvent(event) {
4174
+ if (!event.attributes) return event;
4175
+ const attributes = this.scrubbedAttributes(event.attributes);
4176
+ if (attributes === event.attributes) return event;
4177
+ return { ...event, attributes };
2574
4178
  }
2575
4179
  };
2576
4180
  }
@@ -2581,7 +4185,7 @@ var require_package = __commonJS({
2581
4185
  "package.json"(exports2, module2) {
2582
4186
  module2.exports = {
2583
4187
  name: "@withgateway/sdk",
2584
- version: "0.2.9",
4188
+ version: "0.3.1",
2585
4189
  description: "Gateway SDK for TypeScript - A/B experiments, tracing, and observability",
2586
4190
  main: "./dist/index.js",
2587
4191
  module: "./dist/index.mjs",
@@ -2792,7 +4396,7 @@ function canonicalJson(value) {
2792
4396
  return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
2793
4397
  }
2794
4398
  function sha256(text2) {
2795
- return `sha256:${(0, import_node_crypto2.createHash)("sha256").update(text2).digest("hex")}`;
4399
+ return `sha256:${(0, import_node_crypto3.createHash)("sha256").update(text2).digest("hex")}`;
2796
4400
  }
2797
4401
  function captureSource() {
2798
4402
  const stack = new Error().stack?.split("\n") ?? [];
@@ -3052,11 +4656,11 @@ async function registerBuild(params) {
3052
4656
  );
3053
4657
  }
3054
4658
  }
3055
- var import_node_crypto2, registeredTools, registeredPrompts, registeredSkills, registeredArtifacts, activeBuilds, reRegisterTimer, RE_REGISTER_DEBOUNCE_MS;
4659
+ var import_node_crypto3, registeredTools, registeredPrompts, registeredSkills, registeredArtifacts, activeBuilds, reRegisterTimer, RE_REGISTER_DEBOUNCE_MS;
3056
4660
  var init_build = __esm({
3057
4661
  "src/build/index.ts"() {
3058
4662
  "use strict";
3059
- import_node_crypto2 = require("crypto");
4663
+ import_node_crypto3 = require("crypto");
3060
4664
  registeredTools = /* @__PURE__ */ new Map();
3061
4665
  registeredPrompts = /* @__PURE__ */ new Map();
3062
4666
  registeredSkills = /* @__PURE__ */ new Map();
@@ -3077,10 +4681,6 @@ __export(init_exports, {
3077
4681
  isInitialized: () => isInitialized,
3078
4682
  shutdown: () => shutdown2
3079
4683
  });
3080
- function getEnv(key2) {
3081
- const value = process.env[key2];
3082
- return value ? value : void 0;
3083
- }
3084
4684
  function log(message, ...args) {
3085
4685
  if (state.debug) {
3086
4686
  console.log(`[gatewaysdk.tracing] ${message}`, ...args);
@@ -3090,10 +4690,10 @@ function warn(message, ...args) {
3090
4690
  console.warn(`[gatewaysdk.tracing] ${message}`, ...args);
3091
4691
  }
3092
4692
  function buildProvider(config, logFn) {
3093
- const host = config.host ?? getEnv(ENV_VARS.HOST);
3094
- const publicKey = config.publicKey ?? getEnv(ENV_VARS.PUBLIC_KEY);
3095
- const secretKey = config.secretKey ?? getEnv(ENV_VARS.SECRET_KEY);
3096
- const endpoint = config.endpoint ?? getEnv(ENV_VARS.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${DEFAULT_OTLP_PATH}` : void 0);
4693
+ const host = config.host ?? getEnv(GATEWAY_ENV.HOST);
4694
+ const publicKey = config.publicKey ?? getEnv(GATEWAY_ENV.PUBLIC_KEY);
4695
+ const secretKey = config.secretKey ?? getEnv(GATEWAY_ENV.SECRET_KEY);
4696
+ const endpoint = config.endpoint ?? getEnv(GATEWAY_ENV.ENDPOINT) ?? (host ? `${host.replace(/\/$/, "")}${DEFAULT_OTLP_PATH}` : void 0);
3097
4697
  const missing = [];
3098
4698
  if (!host) missing.push("host (or GATEWAY_HOST env var)");
3099
4699
  if (!publicKey) missing.push("publicKey (or GATEWAY_PUBLIC_KEY env var)");
@@ -3130,9 +4730,7 @@ function buildProvider(config, logFn) {
3130
4730
  ATTR_SERVICE_NAME = "service.name";
3131
4731
  }
3132
4732
  } catch {
3133
- throw new Error(
3134
- "OpenTelemetry packages not found. Install them with:\nnpm install @opentelemetry/sdk-trace-node @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources"
3135
- );
4733
+ throw new OpenTelemetryMissing();
3136
4734
  }
3137
4735
  const resourceAttrs = {
3138
4736
  [ATTR_SERVICE_NAME]: config.serviceName ?? "gatewaysdk-tracing"
@@ -3188,7 +4786,7 @@ function buildProvider(config, logFn) {
3188
4786
  const spanProcessors = [];
3189
4787
  if (config.customSpanProcessors) {
3190
4788
  for (const sp of config.customSpanProcessors) {
3191
- spanProcessors.push(sp);
4789
+ spanProcessors.push(new SecretRedactingSpanProcessor(sp));
3192
4790
  logFn(
3193
4791
  "Added custom span processor: %s",
3194
4792
  sp.constructor?.name ?? "unknown"
@@ -3207,7 +4805,11 @@ function buildProvider(config, logFn) {
3207
4805
  if (config.batch?.maxExportBatchSize) {
3208
4806
  batchConfig.maxExportBatchSize = config.batch.maxExportBatchSize;
3209
4807
  }
3210
- spanProcessors.push(new BatchSpanProcessor(exporter, batchConfig));
4808
+ spanProcessors.push(
4809
+ new SecretRedactingSpanProcessor(
4810
+ new BatchSpanProcessor(exporter, batchConfig)
4811
+ )
4812
+ );
3211
4813
  let provider = new NodeTracerProvider({
3212
4814
  resource: createResource(resourceAttrs)
3213
4815
  });
@@ -3334,26 +4936,17 @@ async function shutdown2() {
3334
4936
  function isInitialized() {
3335
4937
  return state.initialized;
3336
4938
  }
3337
- function isGatewayConfigured() {
3338
- const host = getEnv(ENV_VARS.HOST);
3339
- const publicKey = getEnv(ENV_VARS.PUBLIC_KEY);
3340
- const secretKey = getEnv(ENV_VARS.SECRET_KEY);
3341
- return !!(host && publicKey && secretKey);
3342
- }
3343
- var ENV_VARS, DEFAULT_OTLP_PATH, state;
4939
+ var DEFAULT_OTLP_PATH, state;
3344
4940
  var init_init = __esm({
3345
4941
  "src/tracing/init.ts"() {
3346
4942
  "use strict";
3347
4943
  init_identity();
3348
- init_session2();
4944
+ init_secrets();
4945
+ init_session();
3349
4946
  init_scores();
3350
4947
  init_build();
3351
- ENV_VARS = {
3352
- HOST: "GATEWAY_HOST",
3353
- PUBLIC_KEY: "GATEWAY_PUBLIC_KEY",
3354
- SECRET_KEY: "GATEWAY_SECRET_KEY",
3355
- ENDPOINT: "GATEWAY_OTLP_ENDPOINT"
3356
- };
4948
+ init_prerequisites();
4949
+ init_prerequisites();
3357
4950
  DEFAULT_OTLP_PATH = "/api/public/otel/v1/traces";
3358
4951
  state = {
3359
4952
  initialized: false,
@@ -3362,6 +4955,45 @@ var init_init = __esm({
3362
4955
  }
3363
4956
  });
3364
4957
 
4958
+ // src/worlds/taskTracing.ts
4959
+ var TaskTracing;
4960
+ var init_taskTracing = __esm({
4961
+ "src/worlds/taskTracing.ts"() {
4962
+ "use strict";
4963
+ init_prerequisites();
4964
+ TaskTracing = class _TaskTracing {
4965
+ constructor(load = () => Promise.resolve().then(() => (init_init(), init_exports))) {
4966
+ this.load = load;
4967
+ }
4968
+ load;
4969
+ static warned = false;
4970
+ async start(requested) {
4971
+ if (!requested || !isGatewayConfigured()) return false;
4972
+ try {
4973
+ (await this.load()).init();
4974
+ return true;
4975
+ } catch (error) {
4976
+ _TaskTracing.warnOnce(error);
4977
+ return false;
4978
+ }
4979
+ }
4980
+ static warnOnce(error) {
4981
+ if (_TaskTracing.warned) return;
4982
+ _TaskTracing.warned = true;
4983
+ console.warn(
4984
+ `[gatewaysdk.tracing] Task runs in this process are not traced. ${_TaskTracing.reason(error)}
4985
+ Pass --no-trace (trace: false) to run untraced without this warning.`
4986
+ );
4987
+ }
4988
+ static reason(error) {
4989
+ if (OpenTelemetryMissing.explains(error))
4990
+ return new OpenTelemetryMissing().message;
4991
+ return error instanceof Error ? error.message : String(error);
4992
+ }
4993
+ };
4994
+ }
4995
+ });
4996
+
3365
4997
  // src/worlds/taskRun.ts
3366
4998
  function worldRef(live, alias) {
3367
4999
  const { slug, ref } = live.worldRef(alias);
@@ -3460,7 +5092,7 @@ function reportFromResult(result) {
3460
5092
  return { report, extra };
3461
5093
  }
3462
5094
  async function runTask(ref, agent, opts) {
3463
- const runId = `wtr-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
5095
+ const runId = `wtr-${(0, import_node_crypto4.randomBytes)(6).toString("hex")}`;
3464
5096
  const outDir = opts.outDir ?? "runs";
3465
5097
  const runDir = path.join(outDir, runId);
3466
5098
  fs.mkdirSync(runDir, { recursive: true });
@@ -3474,18 +5106,7 @@ async function runTask(ref, agent, opts) {
3474
5106
  const started = Date.now();
3475
5107
  try {
3476
5108
  await live.ready();
3477
- let traced = false;
3478
- if (opts.trace !== false) {
3479
- try {
3480
- const { isGatewayConfigured: isGatewayConfigured2, init: init3 } = await Promise.resolve().then(() => (init_init(), init_exports));
3481
- if (isGatewayConfigured2()) {
3482
- init3();
3483
- traced = true;
3484
- }
3485
- } catch {
3486
- traced = false;
3487
- }
3488
- }
5109
+ const traced = await new TaskTracing().start(opts.trace !== false);
3489
5110
  const taskRun = new TaskRun(
3490
5111
  runId,
3491
5112
  live.instruction ?? "",
@@ -3498,7 +5119,7 @@ async function runTask(ref, agent, opts) {
3498
5119
  let extra = {};
3499
5120
  try {
3500
5121
  const invoke = () => agent(taskRun);
3501
- const result = traced ? await (await Promise.resolve().then(() => (init_session2(), session_exports2))).withSession(runId, invoke) : await invoke();
5122
+ const result = traced ? await (await Promise.resolve().then(() => (init_session(), session_exports))).withSession(runId, invoke) : await invoke();
3502
5123
  ({ report, extra } = reportFromResult(result));
3503
5124
  } catch (error) {
3504
5125
  const message = (error instanceof Error ? error.message : String(error)) || "Unknown error";
@@ -3565,17 +5186,18 @@ async function runTask(ref, agent, opts) {
3565
5186
  }
3566
5187
  }
3567
5188
  }
3568
- var import_node_crypto3, fs, path, TaskRun, describeValue, RESULT_CONTRACT;
5189
+ var import_node_crypto4, fs, path, TaskRun, describeValue, RESULT_CONTRACT;
3569
5190
  var init_taskRun = __esm({
3570
5191
  "src/worlds/taskRun.ts"() {
3571
5192
  "use strict";
3572
- import_node_crypto3 = require("crypto");
5193
+ import_node_crypto4 = require("crypto");
3573
5194
  fs = __toESM(require("fs"));
3574
5195
  path = __toESM(require("path"));
3575
5196
  init_browser();
3576
5197
  init_evals();
3577
- init_session();
5198
+ init_session2();
3578
5199
  init_taskSessions();
5200
+ init_taskTracing();
3579
5201
  TaskRun = class {
3580
5202
  constructor(runId, instruction, model, sessions2, manifest) {
3581
5203
  this.runId = runId;
@@ -3779,6 +5401,52 @@ var init_setRun = __esm({
3779
5401
  }
3780
5402
  });
3781
5403
 
5404
+ // src/worlds/requestLog.ts
5405
+ var WorldRequestLog;
5406
+ var init_requestLog = __esm({
5407
+ "src/worlds/requestLog.ts"() {
5408
+ "use strict";
5409
+ WorldRequestLog = class _WorldRequestLog {
5410
+ constructor(requests) {
5411
+ this.requests = requests;
5412
+ }
5413
+ requests;
5414
+ static async read(session) {
5415
+ const state2 = await session.state();
5416
+ const calls = state2?.calls;
5417
+ if (!Array.isArray(calls)) return null;
5418
+ return new _WorldRequestLog(calls.filter((c) => typeof c === "object" && c !== null));
5419
+ }
5420
+ /** How many older requests the world no longer keeps (its log is bounded): the gap
5421
+ * before the first entry it still holds. */
5422
+ get dropped() {
5423
+ const first = Number(this.requests[0]?.seq) || 1;
5424
+ return Math.max(0, first - 1);
5425
+ }
5426
+ /** Each request in the shape of a ledger line, `kind: "request"`, so one JSONL
5427
+ * file holds both. */
5428
+ asCalls() {
5429
+ return this.requests.map((r) => ({
5430
+ seq: Number(r.seq) || 0,
5431
+ kind: "request",
5432
+ tool: r.operation ?? null,
5433
+ args: {
5434
+ method: r.method ?? null,
5435
+ path: r.path ?? null,
5436
+ args: r.args ?? null,
5437
+ query: r.query ?? null,
5438
+ body: r.body ?? null,
5439
+ via: r.via ?? null
5440
+ },
5441
+ result: { status: r.status ?? null, rows: r.rows ?? null, found: r.found ?? null },
5442
+ error: null,
5443
+ completedAt: r.at ?? null
5444
+ }));
5445
+ }
5446
+ };
5447
+ }
5448
+ });
5449
+
3782
5450
  // src/worlds/checkoutTarget.ts
3783
5451
  var fs2, path2, CheckoutRefusedError, NAMED_EDITS, CheckoutTarget;
3784
5452
  var init_checkoutTarget = __esm({
@@ -3883,11 +5551,11 @@ var init_checkoutTarget = __esm({
3883
5551
  });
3884
5552
 
3885
5553
  // src/worlds/worldDir.ts
3886
- var import_node_crypto4, fs3, path3, WORLD_MANIFEST, API_BUNDLE_MANIFEST, BUNDLED_WORLD_PREFIX, CONNECTOR_SPEC, PYPROJECT, BENCHMARK_CONFIG, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS, BROAD_ROOT_MARKERS, SKIPPED_DIRS, V1_DEP, V1_IMPORT, V1_TASKSET, HARBOR_TASK, skippedDir, byCodePoint, WorldDir;
5554
+ var import_node_crypto5, fs3, path3, WORLD_MANIFEST, API_BUNDLE_MANIFEST, BUNDLED_WORLD_PREFIX, CONNECTOR_SPEC, PYPROJECT, BENCHMARK_CONFIG, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS, BROAD_ROOT_MARKERS, SKIPPED_DIRS, V1_DEP, V1_IMPORT, V1_TASKSET, HARBOR_TASK, skippedDir, byCodePoint, WorldDir;
3887
5555
  var init_worldDir = __esm({
3888
5556
  "src/worlds/worldDir.ts"() {
3889
5557
  "use strict";
3890
- import_node_crypto4 = require("crypto");
5558
+ import_node_crypto5 = require("crypto");
3891
5559
  fs3 = __toESM(require("fs"));
3892
5560
  path3 = __toESM(require("path"));
3893
5561
  WORLD_MANIFEST = "gateway-env.toml";
@@ -3993,7 +5661,7 @@ var init_worldDir = __esm({
3993
5661
  * sorted order: the version's identity, byte-compatible with
3994
5662
  * `_archive.compute_content_hash` and Prime Intellect. */
3995
5663
  get contentHash() {
3996
- const hasher = (0, import_node_crypto4.createHash)("sha256");
5664
+ const hasher = (0, import_node_crypto5.createHash)("sha256");
3997
5665
  for (const rel of this.archivePaths) {
3998
5666
  hasher.update(Buffer.from(`file:${rel}`, "utf-8"));
3999
5667
  hasher.update(fs3.readFileSync(path3.join(this.dir, rel)));
@@ -4297,7 +5965,7 @@ function writeLocalMeta(dir, meta) {
4297
5965
  function snapshotTreeHashes(dir) {
4298
5966
  const out = {};
4299
5967
  for (const relPath of collectArchiveRelPaths(dir)) {
4300
- out[relPath] = (0, import_node_crypto5.createHash)("sha256").update(fs5.readFileSync(path5.join(dir, relPath))).digest("hex");
5968
+ out[relPath] = (0, import_node_crypto6.createHash)("sha256").update(fs5.readFileSync(path5.join(dir, relPath))).digest("hex");
4301
5969
  }
4302
5970
  return out;
4303
5971
  }
@@ -4343,7 +6011,7 @@ function buildFileManifest(dir) {
4343
6011
  path: relPath,
4344
6012
  isDirectory: false,
4345
6013
  size: payload.length,
4346
- sha256: (0, import_node_crypto5.createHash)("sha256").update(payload).digest("hex")
6014
+ sha256: (0, import_node_crypto6.createHash)("sha256").update(payload).digest("hex")
4347
6015
  };
4348
6016
  });
4349
6017
  }
@@ -4542,11 +6210,11 @@ async function createRef(slug, name, kind, versionId, options = {}) {
4542
6210
  ...versionId ? { versionId } : {}
4543
6211
  });
4544
6212
  }
4545
- var import_node_crypto5, import_node_zlib2, fs5, path5, DEFAULT_BRANCH, META_RELPATH, FILE_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64, DetachedPushError;
6213
+ var import_node_crypto6, import_node_zlib2, fs5, path5, DEFAULT_BRANCH, META_RELPATH, FILE_MODE, MINTED_SUFFIX, PushSlugConflict, sha256b64, DetachedPushError;
4546
6214
  var init_hub = __esm({
4547
6215
  "src/worlds/hub.ts"() {
4548
6216
  "use strict";
4549
- import_node_crypto5 = require("crypto");
6217
+ import_node_crypto6 = require("crypto");
4550
6218
  import_node_zlib2 = require("zlib");
4551
6219
  fs5 = __toESM(require("fs"));
4552
6220
  path5 = __toESM(require("path"));
@@ -4572,7 +6240,7 @@ var init_hub = __esm({
4572
6240
  tracked;
4573
6241
  declared;
4574
6242
  };
4575
- sha256b64 = (data) => (0, import_node_crypto5.createHash)("sha256").update(data).digest("base64");
6243
+ sha256b64 = (data) => (0, import_node_crypto6.createHash)("sha256").update(data).digest("base64");
4576
6244
  DetachedPushError = class extends Error {
4577
6245
  constructor(dir, tag) {
4578
6246
  super(
@@ -5216,11 +6884,11 @@ function applyTransforms(value, chain) {
5216
6884
  for (const step of steps) out = step(out);
5217
6885
  return out;
5218
6886
  }
5219
- var import_node_crypto6, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
6887
+ var import_node_crypto7, WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, stripPrefix, hex, SIMPLE, TRANSFORMS, text;
5220
6888
  var init_transforms = __esm({
5221
6889
  "src/worlds/transforms.ts"() {
5222
6890
  "use strict";
5223
- import_node_crypto6 = require("crypto");
6891
+ import_node_crypto7 = require("crypto");
5224
6892
  init_json();
5225
6893
  WHITESPACE = " \n\r\f\v";
5226
6894
  WHITESPACE_EDGES = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
@@ -5237,7 +6905,7 @@ var init_transforms = __esm({
5237
6905
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
5238
6906
  };
5239
6907
  stripPrefix = (prefix) => (value) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
5240
- hex = (algorithm, value) => (0, import_node_crypto6.createHash)(algorithm).update(value, "utf8").digest("hex");
6908
+ hex = (algorithm, value) => (0, import_node_crypto7.createHash)(algorithm).update(value, "utf8").digest("hex");
5241
6909
  SIMPLE = {
5242
6910
  lower: (value) => value.toLowerCase(),
5243
6911
  upper: (value) => value.toUpperCase(),
@@ -5269,7 +6937,7 @@ function pyText(value) {
5269
6937
  return pyFloatRepr(value);
5270
6938
  }
5271
6939
  function hashForm(slug, plaintext) {
5272
- return "sha256:" + (0, import_node_crypto7.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
6940
+ return "sha256:" + (0, import_node_crypto8.createHash)("sha256").update(`${slug}:${pyText(plaintext)}`, "utf8").digest("hex");
5273
6941
  }
5274
6942
  function preserveForm(slug, plaintext) {
5275
6943
  const kind = typeof plaintext === "string" ? "str" : isInt(plaintext) ? "int" : "float";
@@ -5278,12 +6946,12 @@ function preserveForm(slug, plaintext) {
5278
6946
  }
5279
6947
  function shapeText(slug, text2, kind) {
5280
6948
  const seed = Buffer.from(`${slug}:${text2}`, "utf8");
5281
- let digest = (0, import_node_crypto7.createHash)("sha256").update(seed).digest();
6949
+ let digest = (0, import_node_crypto8.createHash)("sha256").update(seed).digest();
5282
6950
  let cursor = 0;
5283
6951
  const out = [];
5284
6952
  for (const char of text2) {
5285
6953
  if (cursor === digest.length) {
5286
- digest = (0, import_node_crypto7.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
6954
+ digest = (0, import_node_crypto8.createHash)("sha256").update(Buffer.concat([digest, seed])).digest();
5287
6955
  cursor = 0;
5288
6956
  }
5289
6957
  const byte = digest[cursor];
@@ -5320,11 +6988,11 @@ function storedForms(world, field2, plaintext, transform) {
5320
6988
  if (policy !== null) return [roundForm(plaintext, world.redact.round[field2])];
5321
6989
  return [plaintext];
5322
6990
  }
5323
- var import_node_crypto7, isInt;
6991
+ var import_node_crypto8, isInt;
5324
6992
  var init_redaction = __esm({
5325
6993
  "src/worlds/redaction.ts"() {
5326
6994
  "use strict";
5327
- import_node_crypto7 = require("crypto");
6995
+ import_node_crypto8 = require("crypto");
5328
6996
  init_json();
5329
6997
  init_transforms();
5330
6998
  isInt = (value) => typeof value === "number" && Number.isInteger(value);
@@ -5608,7 +7276,7 @@ async function localBridge(request, local, opts = {}) {
5608
7276
  child.stdin.end(input);
5609
7277
  });
5610
7278
  }
5611
- var import_node_child_process2, fs7, net, path7, MIN_PYTHON, DIAGNOSTIC_TAIL, BRIDGE_BOOTSTRAP, pythonCache, pythonProbes, PYTHON_CANDIDATES, UV_FIND;
7279
+ var import_node_child_process2, fs7, net, path7, MIN_PYTHON, MIN_PYTHON_LABEL, DIAGNOSTIC_TAIL, BRIDGE_BOOTSTRAP, pythonCache, pythonProbes, PYTHON_CANDIDATES, UV_FIND;
5612
7280
  var init_local = __esm({
5613
7281
  "src/cli/runtime/local.ts"() {
5614
7282
  "use strict";
@@ -5619,6 +7287,7 @@ var init_local = __esm({
5619
7287
  init_router();
5620
7288
  init_config();
5621
7289
  MIN_PYTHON = [3, 12];
7290
+ MIN_PYTHON_LABEL = MIN_PYTHON.join(".");
5622
7291
  DIAGNOSTIC_TAIL = 600;
5623
7292
  BRIDGE_BOOTSTRAP = `import sys,runpy,types,os
5624
7293
  root=sys.argv[1]
@@ -6193,7 +7862,7 @@ function uploadHeadersFor(gz) {
6193
7862
  return {
6194
7863
  "content-type": "application/gzip",
6195
7864
  "content-length": String(gz.length),
6196
- "x-amz-checksum-sha256": (0, import_node_crypto8.createHash)("sha256").update(gz).digest("base64")
7865
+ "x-amz-checksum-sha256": (0, import_node_crypto9.createHash)("sha256").update(gz).digest("base64")
6197
7866
  };
6198
7867
  }
6199
7868
  async function forEachLimited(items, limit, fn) {
@@ -6239,11 +7908,11 @@ function phaseLine(status) {
6239
7908
  const phase = status.progress?.phase;
6240
7909
  return phase ? `${status.state} (${phase})` : status.state;
6241
7910
  }
6242
- var import_node_crypto8, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
7911
+ var import_node_crypto9, fs11, TERMINAL_STATES, sleepMs, WorldDataApi;
6243
7912
  var init_batches = __esm({
6244
7913
  "src/cli/platform/worldData/batches.ts"() {
6245
7914
  "use strict";
6246
- import_node_crypto8 = require("crypto");
7915
+ import_node_crypto9 = require("crypto");
6247
7916
  fs11 = __toESM(require("fs"));
6248
7917
  init_config();
6249
7918
  init_router();
@@ -6437,12 +8106,12 @@ function finishChunk(ordinal, raw, rows, entity, firstRow = 0) {
6437
8106
  const gz = gzipDeterministic(raw, { name: chunkName(ordinal) });
6438
8107
  return {
6439
8108
  ordinal,
6440
- digest: (0, import_node_crypto9.createHash)("sha256").update(gz).digest("hex"),
8109
+ digest: (0, import_node_crypto10.createHash)("sha256").update(gz).digest("hex"),
6441
8110
  bytes: gz.length,
6442
8111
  rows,
6443
8112
  entity,
6444
8113
  rawBytes: raw.length,
6445
- contentSha256: (0, import_node_crypto9.createHash)("sha256").update(raw).digest("hex"),
8114
+ contentSha256: (0, import_node_crypto10.createHash)("sha256").update(raw).digest("hex"),
6446
8115
  firstRow,
6447
8116
  gz
6448
8117
  };
@@ -6482,11 +8151,11 @@ function crc32(data) {
6482
8151
  crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
6483
8152
  return (crc ^ 4294967295) >>> 0;
6484
8153
  }
6485
- var import_node_crypto9, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
8154
+ var import_node_crypto10, import_node_zlib3, DEFAULT_CHUNK_BYTES, GZIP_LEVEL, chunkName, table;
6486
8155
  var init_chunker = __esm({
6487
8156
  "src/cli/platform/worldData/chunker.ts"() {
6488
8157
  "use strict";
6489
- import_node_crypto9 = require("crypto");
8158
+ import_node_crypto10 = require("crypto");
6490
8159
  import_node_zlib3 = require("zlib");
6491
8160
  init_json();
6492
8161
  DEFAULT_CHUNK_BYTES = 64 * 1024 * 1024;
@@ -6781,7 +8450,7 @@ var init_ingest = __esm({
6781
8450
  });
6782
8451
 
6783
8452
  // src/worlds/editSessions.ts
6784
- var WORLDS, WorldEditClient;
8453
+ var WORLDS, WorldEditClient, TASK_EDITS, TaskEditClient;
6785
8454
  var init_editSessions = __esm({
6786
8455
  "src/worlds/editSessions.ts"() {
6787
8456
  "use strict";
@@ -6813,6 +8482,22 @@ var init_editSessions = __esm({
6813
8482
  return apiRequest(this.options, "POST", `${WORLDS}/${encodeURIComponent(slug)}/edits/rollback`, input);
6814
8483
  }
6815
8484
  };
8485
+ TASK_EDITS = "/api/public/world-task-edits";
8486
+ TaskEditClient = class {
8487
+ constructor(options = {}) {
8488
+ this.options = options;
8489
+ }
8490
+ options;
8491
+ status(task) {
8492
+ return apiRequest(this.options, "POST", `${TASK_EDITS}/status`, { task });
8493
+ }
8494
+ close(task, input = {}) {
8495
+ return apiRequest(this.options, "POST", `${TASK_EDITS}/close`, { task, ...input });
8496
+ }
8497
+ rollback(task, input) {
8498
+ return apiRequest(this.options, "POST", `${TASK_EDITS}/rollback`, { task, ...input });
8499
+ }
8500
+ };
6816
8501
  }
6817
8502
  });
6818
8503
 
@@ -6908,6 +8593,10 @@ var init_dryRun = __esm({
6908
8593
  // src/worlds/index.ts
6909
8594
  var worlds_exports = {};
6910
8595
  __export(worlds_exports, {
8596
+ ACTION_NAMES: () => ACTION_NAMES,
8597
+ ActionTracer: () => ActionTracer,
8598
+ AnthropicComputer: () => AnthropicComputer,
8599
+ AnthropicComputer20251124: () => AnthropicComputer20251124,
6911
8600
  ApiError: () => ApiError,
6912
8601
  BROWSER_GONE_PATTERNS: () => BROWSER_GONE_PATTERNS,
6913
8602
  BROWSER_TIERS: () => BROWSER_TIERS,
@@ -6919,11 +8608,13 @@ __export(worlds_exports, {
6919
8608
  CALL_BODY_LIMIT_LABEL: () => CALL_BODY_LIMIT_LABEL,
6920
8609
  COMPUTER_USE_SPECS: () => COMPUTER_USE_SPECS,
6921
8610
  CheckoutProvenance: () => CheckoutProvenance,
8611
+ ComputerAction: () => ComputerAction,
6922
8612
  DEFAULT_BRANCH: () => DEFAULT_BRANCH,
6923
8613
  DEFAULT_VIEWPORT: () => DEFAULT_VIEWPORT,
6924
8614
  DRY_RUN_AGENT: () => DRY_RUN_AGENT,
6925
8615
  DRY_RUN_KIND: () => DRY_RUN_KIND,
6926
8616
  DetachedPushError: () => DetachedPushError,
8617
+ Display: () => Display,
6927
8618
  DryRunOutcome: () => DryRunOutcome,
6928
8619
  EVENT_BATCH_SIZE: () => EVENT_BATCH_SIZE,
6929
8620
  EVENT_FLUSH_INTERVAL_MS: () => EVENT_FLUSH_INTERVAL_MS,
@@ -6933,19 +8624,30 @@ __export(worlds_exports, {
6933
8624
  GatewayEvalsClient: () => GatewayEvalsClient,
6934
8625
  HostedDryRunClient: () => HostedDryRunClient,
6935
8626
  IDLE_WARNING_MINUTES: () => IDLE_WARNING_MINUTES,
8627
+ KEY_NAMES: () => KEY_NAMES,
8628
+ KeyChord: () => KeyChord,
8629
+ NOT_EXECUTED: () => NOT_EXECUTED,
6936
8630
  NO_GRADER_REASON: () => NO_GRADER_REASON,
8631
+ NativeComputer: () => NativeComputer,
8632
+ OpenAIComputer: () => OpenAIComputer,
8633
+ OpenAIPreviewComputer: () => OpenAIPreviewComputer,
6937
8634
  PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
6938
8635
  PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
8636
+ PendingSafetyChecks: () => PendingSafetyChecks,
6939
8637
  PlatformTransport: () => PlatformTransport,
6940
8638
  PushSlugConflict: () => PushSlugConflict,
6941
8639
  RECOVER_BUDGET_MS: () => RECOVER_BUDGET_MS,
6942
8640
  SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
8641
+ SECRET_KEY: () => SECRET_KEY,
6943
8642
  SESSION_STATES: () => SESSION_STATES,
8643
+ SPAN_PREFIX: () => SPAN_PREFIX,
6944
8644
  STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
6945
8645
  STRIP_PREFIX: () => STRIP_PREFIX,
6946
8646
  SURFACE_KINDS: () => SURFACE_KINDS,
8647
+ Screen: () => Screen,
6947
8648
  SecretScrubber: () => SecretScrubber,
6948
8649
  TRANSFORMS: () => TRANSFORMS,
8650
+ TaskEditClient: () => TaskEditClient,
6949
8651
  TaskRun: () => TaskRun,
6950
8652
  TaskSessions: () => TaskSessions,
6951
8653
  TransportCause: () => TransportCause,
@@ -6955,6 +8657,7 @@ __export(worlds_exports, {
6955
8657
  WorldBrowser: () => WorldBrowser,
6956
8658
  WorldCallTooLarge: () => WorldCallTooLarge,
6957
8659
  WorldEditClient: () => WorldEditClient,
8660
+ WorldRequestLog: () => WorldRequestLog,
6958
8661
  WorldSandboxClient: () => WorldSandboxClient,
6959
8662
  WorldSession: () => WorldSession,
6960
8663
  WorldSessionCallError: () => WorldSessionCallError,
@@ -7018,6 +8721,7 @@ __export(worlds_exports, {
7018
8721
  parseTransform: () => parseTransform,
7019
8722
  parseWorldTaskRefs: () => parseWorldTaskRefs,
7020
8723
  platformTimeoutMs: () => platformTimeoutMs,
8724
+ playwrightKey: () => playwrightKey,
7021
8725
  preserveForm: () => preserveForm,
7022
8726
  propose: () => propose,
7023
8727
  pull: () => pull,
@@ -7027,6 +8731,7 @@ __export(worlds_exports, {
7027
8731
  pyText: () => pyText,
7028
8732
  queryRows: () => queryRows,
7029
8733
  queryRowsSearch: () => queryRowsSearch,
8734
+ readField: () => readField,
7030
8735
  readLocalMeta: () => readLocalMeta,
7031
8736
  readToolCallRecords: () => readToolCallRecords,
7032
8737
  rebaseConflicts: () => rebaseConflicts,
@@ -7046,6 +8751,7 @@ __export(worlds_exports, {
7046
8751
  shapeText: () => shapeText,
7047
8752
  snapshotTreeHashes: () => snapshotTreeHashes,
7048
8753
  storedForms: () => storedForms,
8754
+ surfaceDescriptor: () => surfaceDescriptor,
7049
8755
  surfaceKinds: () => surfaceKinds,
7050
8756
  taskLabel: () => taskLabel,
7051
8757
  toolCallRecordsIn: () => toolCallRecordsIn,
@@ -7276,7 +8982,7 @@ var init_worlds = __esm({
7276
8982
  "use strict";
7277
8983
  init_transport();
7278
8984
  init_transport();
7279
- init_session();
8985
+ init_session2();
7280
8986
  init_sessionList();
7281
8987
  init_sessionContract();
7282
8988
  init_taskRef();
@@ -7287,7 +8993,10 @@ var init_worlds = __esm({
7287
8993
  init_checkoutProvenance();
7288
8994
  init_evals();
7289
8995
  init_browser();
8996
+ init_surfaceDescriptor();
8997
+ init_requestLog();
7290
8998
  init_browserReconnect();
8999
+ init_nativeComputer();
7291
9000
  init_hub();
7292
9001
  init_validate();
7293
9002
  init_describe();
@@ -7354,7 +9063,7 @@ var init_worlds = __esm({
7354
9063
  * worlds/session.ts.
7355
9064
  */
7356
9065
  async open(task, opts = {}) {
7357
- const { openSession: openSession2 } = await Promise.resolve().then(() => (init_session(), session_exports));
9066
+ const { openSession: openSession2 } = await Promise.resolve().then(() => (init_session2(), session_exports2));
7358
9067
  return openSession2(this.slug, {
7359
9068
  task,
7360
9069
  versionId: this.version.versionId,
@@ -7390,7 +9099,11 @@ var init_worlds = __esm({
7390
9099
  // src/index.ts
7391
9100
  var src_exports = {};
7392
9101
  __export(src_exports, {
9102
+ ACTION_NAMES: () => ACTION_NAMES,
7393
9103
  AGENT_ID_KEY: () => AGENT_ID_KEY,
9104
+ ActionTracer: () => ActionTracer,
9105
+ AnthropicComputer: () => AnthropicComputer,
9106
+ AnthropicComputer20251124: () => AnthropicComputer20251124,
7394
9107
  ApiError: () => ApiError,
7395
9108
  BROWSER_GONE_PATTERNS: () => BROWSER_GONE_PATTERNS,
7396
9109
  BROWSER_TIERS: () => BROWSER_TIERS,
@@ -7402,12 +9115,14 @@ __export(src_exports, {
7402
9115
  CALL_BODY_LIMIT_LABEL: () => CALL_BODY_LIMIT_LABEL,
7403
9116
  COMPUTER_USE_SPECS: () => COMPUTER_USE_SPECS,
7404
9117
  CheckoutProvenance: () => CheckoutProvenance,
9118
+ ComputerAction: () => ComputerAction,
7405
9119
  DEFAULT_BRANCH: () => DEFAULT_BRANCH,
7406
9120
  DEFAULT_TIMEOUT_SECONDS: () => DEFAULT_TIMEOUT_SECONDS,
7407
9121
  DEFAULT_VIEWPORT: () => DEFAULT_VIEWPORT,
7408
9122
  DRY_RUN_AGENT: () => DRY_RUN_AGENT,
7409
9123
  DRY_RUN_KIND: () => DRY_RUN_KIND,
7410
9124
  DetachedPushError: () => DetachedPushError,
9125
+ Display: () => Display,
7411
9126
  DriftError: () => DriftError,
7412
9127
  DryRunOutcome: () => DryRunOutcome,
7413
9128
  ENV_GATEWAY_HOST: () => ENV_GATEWAY_HOST,
@@ -7435,9 +9150,16 @@ __export(src_exports, {
7435
9150
  GatewayToolBlockedError: () => GatewayToolBlockedError,
7436
9151
  HostedDryRunClient: () => HostedDryRunClient,
7437
9152
  IDLE_WARNING_MINUTES: () => IDLE_WARNING_MINUTES,
9153
+ KEY_NAMES: () => KEY_NAMES,
9154
+ KeyChord: () => KeyChord,
9155
+ NOT_EXECUTED: () => NOT_EXECUTED,
7438
9156
  NO_GRADER_REASON: () => NO_GRADER_REASON,
9157
+ NativeComputer: () => NativeComputer,
9158
+ OpenAIComputer: () => OpenAIComputer,
9159
+ OpenAIPreviewComputer: () => OpenAIPreviewComputer,
7439
9160
  PLATFORM_TIMEOUT_DEFAULT_MS: () => PLATFORM_TIMEOUT_DEFAULT_MS,
7440
9161
  PLATFORM_TIMEOUT_ENV: () => PLATFORM_TIMEOUT_ENV,
9162
+ PendingSafetyChecks: () => PendingSafetyChecks,
7441
9163
  Persona: () => Persona,
7442
9164
  PersonaError: () => PersonaError,
7443
9165
  PersonasClient: () => PersonasClient,
@@ -7452,7 +9174,9 @@ __export(src_exports, {
7452
9174
  ReplaySuite: () => ReplaySuite,
7453
9175
  ReplayTask: () => ReplayTask,
7454
9176
  SANDBOX_REQUEST_TIMEOUT_MS: () => SANDBOX_REQUEST_TIMEOUT_MS,
9177
+ SECRET_KEY: () => SECRET_KEY,
7455
9178
  SESSION_STATES: () => SESSION_STATES,
9179
+ SPAN_PREFIX: () => SPAN_PREFIX,
7456
9180
  STATUS_WAIT_CAP_SECONDS: () => STATUS_WAIT_CAP_SECONDS,
7457
9181
  STRIP_PREFIX: () => STRIP_PREFIX,
7458
9182
  SUCCESS_METRIC_NAME_KEY: () => SUCCESS_METRIC_NAME_KEY,
@@ -7460,12 +9184,14 @@ __export(src_exports, {
7460
9184
  SURFACE_KINDS: () => SURFACE_KINDS,
7461
9185
  ScoreError: () => ScoreError,
7462
9186
  ScoresClient: () => ScoresClient,
9187
+ Screen: () => Screen,
7463
9188
  SecretScrubber: () => SecretScrubber,
7464
9189
  SessionLoadError: () => SessionLoadError,
7465
9190
  SessionRecording: () => SessionRecording,
7466
9191
  SessionTrace: () => SessionTrace,
7467
9192
  StubMissError: () => StubMissError,
7468
9193
  TRANSFORMS: () => TRANSFORMS,
9194
+ TaskEditClient: () => TaskEditClient,
7469
9195
  TaskRun: () => TaskRun,
7470
9196
  TaskSessions: () => TaskSessions,
7471
9197
  ToolStubRegistry: () => ToolStubRegistry,
@@ -7479,6 +9205,7 @@ __export(src_exports, {
7479
9205
  WorldBrowser: () => WorldBrowser,
7480
9206
  WorldCallTooLarge: () => WorldCallTooLarge,
7481
9207
  WorldEditClient: () => WorldEditClient,
9208
+ WorldRequestLog: () => WorldRequestLog,
7482
9209
  WorldSandboxClient: () => WorldSandboxClient,
7483
9210
  WorldSession: () => WorldSession,
7484
9211
  WorldSessionCallError: () => WorldSessionCallError,
@@ -7567,6 +9294,7 @@ __export(src_exports, {
7567
9294
  parseWorldTaskRefs: () => parseWorldTaskRefs,
7568
9295
  personas: () => personas,
7569
9296
  platformTimeoutMs: () => platformTimeoutMs,
9297
+ playwrightKey: () => playwrightKey,
7570
9298
  preserveForm: () => preserveForm,
7571
9299
  propose: () => propose,
7572
9300
  pull: () => pull,
@@ -7576,6 +9304,7 @@ __export(src_exports, {
7576
9304
  pyText: () => pyText,
7577
9305
  queryRows: () => queryRows,
7578
9306
  queryRowsSearch: () => queryRowsSearch,
9307
+ readField: () => readField,
7579
9308
  readLocalMeta: () => readLocalMeta,
7580
9309
  readToolCallRecords: () => readToolCallRecords,
7581
9310
  rebaseConflicts: () => rebaseConflicts,
@@ -7610,6 +9339,7 @@ __export(src_exports, {
7610
9339
  storedForms: () => storedForms,
7611
9340
  success: () => success,
7612
9341
  suite: () => suite,
9342
+ surfaceDescriptor: () => surfaceDescriptor,
7613
9343
  surfaceKinds: () => surfaceKinds,
7614
9344
  taskLabel: () => taskLabel,
7615
9345
  toolCallRecordsIn: () => toolCallRecordsIn,
@@ -10022,7 +11752,7 @@ var gateway = {
10022
11752
  init_users();
10023
11753
  init_scores();
10024
11754
  init_worlds();
10025
- init_session();
11755
+ init_session2();
10026
11756
 
10027
11757
  // src/files/index.ts
10028
11758
  var files_exports = {};
@@ -10048,7 +11778,7 @@ __export(files_exports, {
10048
11778
  uploadBytes: () => uploadBytes,
10049
11779
  uploadFile: () => uploadFile
10050
11780
  });
10051
- var import_node_crypto10 = require("crypto");
11781
+ var import_node_crypto11 = require("crypto");
10052
11782
  var fs13 = __toESM(require("fs"));
10053
11783
  var path12 = __toESM(require("path"));
10054
11784
  var import_node_stream = require("stream");
@@ -10114,7 +11844,7 @@ async function confirmUpload(options = {}, fileId, ok = true) {
10114
11844
  return apiRequest(options, "POST", `${BASE}/confirm`, { fileId, ok });
10115
11845
  }
10116
11846
  async function sha256Base64(localPath) {
10117
- const hash = (0, import_node_crypto10.createHash)("sha256");
11847
+ const hash = (0, import_node_crypto11.createHash)("sha256");
10118
11848
  for await (const chunk of fs13.createReadStream(localPath)) hash.update(chunk);
10119
11849
  return hash.digest("base64");
10120
11850
  }
@@ -10199,7 +11929,7 @@ async function uploadBytes(options = {}, bytes, targetPath, upload = {}) {
10199
11929
  if (!bytes.length) throw new Error("nothing to upload: the content is empty");
10200
11930
  const target = drivePath(targetPath);
10201
11931
  const contentType = upload.contentType ?? contentTypeFor(target);
10202
- const sha2562 = (0, import_node_crypto10.createHash)("sha256").update(bytes).digest("base64");
11932
+ const sha2562 = (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("base64");
10203
11933
  const granted = await requestUpload(options, { path: target, contentLength: bytes.length, contentType, sha256: sha2562, ...upload.overwrite ? { overwrite: true } : {} });
10204
11934
  try {
10205
11935
  await putPresigned(granted.uploadUrl, new Uint8Array(bytes), { contentType, contentLength: bytes.length, sha256: sha2562 });
@@ -10452,10 +12182,10 @@ function swapValue(text2, needle, replacement) {
10452
12182
  }
10453
12183
 
10454
12184
  // src/hooks/standInDigits.ts
10455
- var import_node_crypto11 = require("crypto");
12185
+ var import_node_crypto12 = require("crypto");
10456
12186
  function standInDigits(realDigits, identityName) {
10457
12187
  if (!realDigits) return "";
10458
- const digest = (0, import_node_crypto11.createHash)("sha256").update(`${identityName}:${realDigits}`).digest("hex");
12188
+ const digest = (0, import_node_crypto12.createHash)("sha256").update(`${identityName}:${realDigits}`).digest("hex");
10459
12189
  let digits = "";
10460
12190
  for (let i = 0; i < realDigits.length; i++)
10461
12191
  digits += String(parseInt(digest[i % digest.length], 16) % 10);
@@ -10489,7 +12219,7 @@ var DeclaredStandIn = class _DeclaredStandIn {
10489
12219
  };
10490
12220
 
10491
12221
  // src/hooks/alias.ts
10492
- var import_node_crypto12 = require("crypto");
12222
+ var import_node_crypto13 = require("crypto");
10493
12223
  var GIVEN = [
10494
12224
  "John",
10495
12225
  "Mary",
@@ -10680,7 +12410,7 @@ function findKind(kind, text2) {
10680
12410
  return out;
10681
12411
  }
10682
12412
  function newRunKey() {
10683
- return (0, import_node_crypto12.randomBytes)(32).toString("hex");
12413
+ return (0, import_node_crypto13.randomBytes)(32).toString("hex");
10684
12414
  }
10685
12415
  function canonical(kind, value) {
10686
12416
  const text2 = String(value).normalize("NFKC").trim();
@@ -10737,7 +12467,7 @@ function explodeIp(text2) {
10737
12467
  return groups.map((g) => g.padStart(4, "0")).join(":") + zone;
10738
12468
  }
10739
12469
  function index(runKey, kind, value, salt = "") {
10740
- const digest = (0, import_node_crypto12.createHmac)("sha256", Buffer.from(runKey, "hex")).update(`${kind}:${value}:${salt}`, "utf8").digest();
12470
+ const digest = (0, import_node_crypto13.createHmac)("sha256", Buffer.from(runKey, "hex")).update(`${kind}:${value}:${salt}`, "utf8").digest();
10741
12471
  return digest.readBigUInt64BE(0);
10742
12472
  }
10743
12473
  var pick = (pool, n) => pool[Number(n % BigInt(pool.length))];
@@ -10761,7 +12491,7 @@ function nameParts(name) {
10761
12491
  function format(template, parts2) {
10762
12492
  return template.replace(/\{(\w+)\}/g, (_, key2) => parts2[key2] ?? "").trim();
10763
12493
  }
10764
- var pair = (real, fake, template) => [
12494
+ var pair2 = (real, fake, template) => [
10765
12495
  format(template, real),
10766
12496
  format(template, fake)
10767
12497
  ];
@@ -10821,7 +12551,7 @@ function namePairs(real, fake) {
10821
12551
  const out = [[real, fake]];
10822
12552
  if (realParts.given && realParts.surname) {
10823
12553
  for (const template of NAME_FORMS) {
10824
- const p = pair(realParts, fakeParts, template);
12554
+ const p = pair2(realParts, fakeParts, template);
10825
12555
  if (p[0].length > 2 && !p[0].includes("{")) out.push(p);
10826
12556
  }
10827
12557
  }
@@ -10859,7 +12589,7 @@ function emailPairs(real, fake) {
10859
12589
  };
10860
12590
  const out = [[real, fake]];
10861
12591
  for (const template of EMAIL_FORMS) {
10862
- const p = pair(realParts, fakeParts, template);
12592
+ const p = pair2(realParts, fakeParts, template);
10863
12593
  if (p[0].length > 2) out.push(p);
10864
12594
  }
10865
12595
  return dedupe(out);
@@ -11271,7 +13001,7 @@ var AliasMap = class _AliasMap {
11271
13001
  const existing = this.aliases.get(key2);
11272
13002
  if (existing) return existing.display;
11273
13003
  if (this.aliasDigests.has(digest.toLowerCase())) return digest;
11274
- const standIn = "sha256:" + (0, import_node_crypto12.createHmac)("sha256", Buffer.from(this.runKey, "hex")).update(digest, "utf8").digest("hex");
13004
+ const standIn = "sha256:" + (0, import_node_crypto13.createHmac)("sha256", Buffer.from(this.runKey, "hex")).update(digest, "utf8").digest("hex");
11275
13005
  this.aliasDigests.add(standIn.toLowerCase());
11276
13006
  const alias = {
11277
13007
  kind: "digest",
@@ -11310,9 +13040,9 @@ var AliasMap = class _AliasMap {
11310
13040
  });
11311
13041
  if (alias.role === "private") {
11312
13042
  for (const slug of this.slugs) {
11313
- const standIn = "sha256:" + (0, import_node_crypto12.createHash)("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
13043
+ const standIn = "sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${canonical(alias.kind, alias.display)}`, "utf8").digest("hex");
11314
13044
  alias.variants.push([
11315
- "sha256:" + (0, import_node_crypto12.createHash)("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
13045
+ "sha256:" + (0, import_node_crypto13.createHash)("sha256").update(`${slug}:${alias.canonical}`, "utf8").digest("hex"),
11316
13046
  standIn
11317
13047
  ]);
11318
13048
  this.aliasDigests.add(standIn.toLowerCase());
@@ -12127,7 +13857,7 @@ function inputSchema(shorthand, position) {
12127
13857
  `${position}.input: expected a table of field = "type"`
12128
13858
  );
12129
13859
  const properties = {};
12130
- const required = [];
13860
+ const required2 = [];
12131
13861
  for (const [name, raw] of Object.entries(shorthand)) {
12132
13862
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
12133
13863
  throw new HookConfigError(
@@ -12161,9 +13891,9 @@ function inputSchema(shorthand, position) {
12161
13891
  `${position}.input.${name}: expected "type" or a schema table`
12162
13892
  );
12163
13893
  properties[name] = schema;
12164
- if (!optional) required.push(name);
13894
+ if (!optional) required2.push(name);
12165
13895
  }
12166
- return { type: "object", properties, required };
13896
+ return { type: "object", properties, required: required2 };
12167
13897
  }
12168
13898
  function placeholders(value) {
12169
13899
  if (typeof value === "string")
@@ -14308,7 +16038,7 @@ var RedactionAudit = class _RedactionAudit {
14308
16038
  };
14309
16039
 
14310
16040
  // src/hooks/run.ts
14311
- var import_node_crypto13 = require("crypto");
16041
+ var import_node_crypto14 = require("crypto");
14312
16042
  var fs17 = __toESM(require("fs"));
14313
16043
  var path15 = __toESM(require("path"));
14314
16044
  var BLOCKING_EVENTS = [
@@ -14352,7 +16082,7 @@ var HookRun = class _HookRun {
14352
16082
  source;
14353
16083
  constructor(config, options) {
14354
16084
  this.config = config;
14355
- this.runId = options.runId ?? `run-${(0, import_node_crypto13.randomBytes)(6).toString("hex")}`;
16085
+ this.runId = options.runId ?? `run-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
14356
16086
  this.runKey = options.runKey ?? newRunKey();
14357
16087
  this.alias = new AliasMap(this.runKey, options.slugs ?? config.aliasSlugs, {
14358
16088
  publicLayerWins: config.aliasPublicLayerWins,
@@ -14987,11 +16717,20 @@ init_identity();
14987
16717
  var tracing_exports = {};
14988
16718
  __export(tracing_exports, {
14989
16719
  IdentitySpanProcessor: () => IdentitySpanProcessor,
16720
+ MAX_MEDIA_BYTES: () => MAX_MEDIA_BYTES,
16721
+ MediaReference: () => MediaReference,
16722
+ MediaUploadError: () => MediaUploadError,
16723
+ MediaUploader: () => MediaUploader,
16724
+ SECRET_KEYS: () => SECRET_KEYS,
14990
16725
  SESSION_ID_ATTRIBUTE: () => SESSION_ID_ATTRIBUTE,
16726
+ SecretRedactingSpanProcessor: () => SecretRedactingSpanProcessor,
14991
16727
  SessionSpanProcessor: () => SessionSpanProcessor,
16728
+ SpanSecrets: () => SpanSecrets,
14992
16729
  USER_ID_ATTRIBUTE: () => USER_ID_ATTRIBUTE,
16730
+ WORLD_SESSION_ID_ATTRIBUTE: () => WORLD_SESSION_ID_ATTRIBUTE,
14993
16731
  flush: () => flush,
14994
16732
  getAmbientSessionId: () => getAmbientSessionId,
16733
+ getCurrentWorldSessionId: () => getCurrentWorldSessionId,
14995
16734
  identify: () => identify,
14996
16735
  init: () => init2,
14997
16736
  initIsolated: () => initIsolated,
@@ -15004,11 +16743,13 @@ __export(tracing_exports, {
15004
16743
  resetAmbientUser: () => resetAmbientUser,
15005
16744
  resolveUserId: () => resolveUserId,
15006
16745
  shutdown: () => shutdown2,
15007
- withSession: () => withSession
16746
+ withSession: () => withSession,
16747
+ withWorldSession: () => withWorldSession
15008
16748
  });
15009
16749
  init_init();
15010
16750
  init_identity();
15011
- init_session2();
16751
+ init_session();
16752
+ init_secrets();
15012
16753
 
15013
16754
  // src/tracing/observe.ts
15014
16755
  var import_api3 = require("@opentelemetry/api");
@@ -15267,6 +17008,9 @@ async function* observeClaude(stream, options) {
15267
17008
  }
15268
17009
  }
15269
17010
 
17011
+ // src/tracing/index.ts
17012
+ init_media();
17013
+
15270
17014
  // src/index.ts
15271
17015
  var tracing = {
15272
17016
  ...tracing_exports,
@@ -15286,7 +17030,11 @@ var tracing = {
15286
17030
  };
15287
17031
  // Annotate the CommonJS export names for ESM import in node:
15288
17032
  0 && (module.exports = {
17033
+ ACTION_NAMES,
15289
17034
  AGENT_ID_KEY,
17035
+ ActionTracer,
17036
+ AnthropicComputer,
17037
+ AnthropicComputer20251124,
15290
17038
  ApiError,
15291
17039
  BROWSER_GONE_PATTERNS,
15292
17040
  BROWSER_TIERS,
@@ -15298,12 +17046,14 @@ var tracing = {
15298
17046
  CALL_BODY_LIMIT_LABEL,
15299
17047
  COMPUTER_USE_SPECS,
15300
17048
  CheckoutProvenance,
17049
+ ComputerAction,
15301
17050
  DEFAULT_BRANCH,
15302
17051
  DEFAULT_TIMEOUT_SECONDS,
15303
17052
  DEFAULT_VIEWPORT,
15304
17053
  DRY_RUN_AGENT,
15305
17054
  DRY_RUN_KIND,
15306
17055
  DetachedPushError,
17056
+ Display,
15307
17057
  DriftError,
15308
17058
  DryRunOutcome,
15309
17059
  ENV_GATEWAY_HOST,
@@ -15331,9 +17081,16 @@ var tracing = {
15331
17081
  GatewayToolBlockedError,
15332
17082
  HostedDryRunClient,
15333
17083
  IDLE_WARNING_MINUTES,
17084
+ KEY_NAMES,
17085
+ KeyChord,
17086
+ NOT_EXECUTED,
15334
17087
  NO_GRADER_REASON,
17088
+ NativeComputer,
17089
+ OpenAIComputer,
17090
+ OpenAIPreviewComputer,
15335
17091
  PLATFORM_TIMEOUT_DEFAULT_MS,
15336
17092
  PLATFORM_TIMEOUT_ENV,
17093
+ PendingSafetyChecks,
15337
17094
  Persona,
15338
17095
  PersonaError,
15339
17096
  PersonasClient,
@@ -15348,7 +17105,9 @@ var tracing = {
15348
17105
  ReplaySuite,
15349
17106
  ReplayTask,
15350
17107
  SANDBOX_REQUEST_TIMEOUT_MS,
17108
+ SECRET_KEY,
15351
17109
  SESSION_STATES,
17110
+ SPAN_PREFIX,
15352
17111
  STATUS_WAIT_CAP_SECONDS,
15353
17112
  STRIP_PREFIX,
15354
17113
  SUCCESS_METRIC_NAME_KEY,
@@ -15356,12 +17115,14 @@ var tracing = {
15356
17115
  SURFACE_KINDS,
15357
17116
  ScoreError,
15358
17117
  ScoresClient,
17118
+ Screen,
15359
17119
  SecretScrubber,
15360
17120
  SessionLoadError,
15361
17121
  SessionRecording,
15362
17122
  SessionTrace,
15363
17123
  StubMissError,
15364
17124
  TRANSFORMS,
17125
+ TaskEditClient,
15365
17126
  TaskRun,
15366
17127
  TaskSessions,
15367
17128
  ToolStubRegistry,
@@ -15375,6 +17136,7 @@ var tracing = {
15375
17136
  WorldBrowser,
15376
17137
  WorldCallTooLarge,
15377
17138
  WorldEditClient,
17139
+ WorldRequestLog,
15378
17140
  WorldSandboxClient,
15379
17141
  WorldSession,
15380
17142
  WorldSessionCallError,
@@ -15463,6 +17225,7 @@ var tracing = {
15463
17225
  parseWorldTaskRefs,
15464
17226
  personas,
15465
17227
  platformTimeoutMs,
17228
+ playwrightKey,
15466
17229
  preserveForm,
15467
17230
  propose,
15468
17231
  pull,
@@ -15472,6 +17235,7 @@ var tracing = {
15472
17235
  pyText,
15473
17236
  queryRows,
15474
17237
  queryRowsSearch,
17238
+ readField,
15475
17239
  readLocalMeta,
15476
17240
  readToolCallRecords,
15477
17241
  rebaseConflicts,
@@ -15506,6 +17270,7 @@ var tracing = {
15506
17270
  storedForms,
15507
17271
  success,
15508
17272
  suite,
17273
+ surfaceDescriptor,
15509
17274
  surfaceKinds,
15510
17275
  taskLabel,
15511
17276
  toolCallRecordsIn,