@withgateway/sdk 0.3.0 → 0.3.3

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 (130) hide show
  1. package/README.md +6 -1
  2. package/dist/cli.js +3971 -2338
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +3950 -2318
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.d.mts +1 -1
  7. package/dist/files/index.d.ts +1 -1
  8. package/dist/files/index.js +214 -41
  9. package/dist/files/index.js.map +1 -1
  10. package/dist/files/index.mjs +206 -35
  11. package/dist/files/index.mjs.map +1 -1
  12. package/dist/{index-DAb-FCMg.d.ts → index-DUHmS74p.d.ts} +3 -13
  13. package/dist/{index-D6oi1TWE.d.mts → index-mJhG3vZU.d.mts} +3 -13
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.js +1456 -564
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +1433 -557
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/{media-CbcAfQvd.d.mts → media-BIApiPzS.d.mts} +21 -2
  21. package/dist/{media-CbcAfQvd.d.ts → media-BIApiPzS.d.ts} +21 -2
  22. package/dist/traces/index.d.mts +1 -1
  23. package/dist/traces/index.d.ts +1 -1
  24. package/dist/traces/index.js +211 -38
  25. package/dist/traces/index.js.map +1 -1
  26. package/dist/traces/index.mjs +203 -32
  27. package/dist/traces/index.mjs.map +1 -1
  28. package/dist/tracing/index.d.mts +2 -2
  29. package/dist/tracing/index.d.ts +2 -2
  30. package/dist/tracing/index.js +96 -21
  31. package/dist/tracing/index.js.map +1 -1
  32. package/dist/tracing/index.mjs +96 -21
  33. package/dist/tracing/index.mjs.map +1 -1
  34. package/dist/worlds/index.d.mts +300 -123
  35. package/dist/worlds/index.d.ts +300 -123
  36. package/dist/worlds/index.js +1385 -508
  37. package/dist/worlds/index.js.map +1 -1
  38. package/dist/worlds/index.mjs +1377 -501
  39. package/dist/worlds/index.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/runtime/gatewaysdk/environment/_bundle.py +2 -27
  42. package/runtime/gatewaysdk/environment/_materialize.py +49 -69
  43. package/runtime/gatewaysdk/environment/_world.py +122 -197
  44. package/runtime/gatewaysdk/environment/backing.py +137 -0
  45. package/runtime/gatewaysdk/environment/core.py +1 -1
  46. package/runtime/gatewaysdk/environment/legacy_sqlite.py +301 -0
  47. package/runtime/gatewaysdk/environment/reward_keys.py +25 -0
  48. package/runtime/gatewaysdk/environment/runtime.py +8 -13
  49. package/runtime/gatewaysdk/environment/schema/__init__.py +4 -4
  50. package/runtime/gatewaysdk/environment/schema/admin_routes.py +86 -0
  51. package/runtime/gatewaysdk/environment/schema/api.py +266 -515
  52. package/runtime/gatewaysdk/environment/schema/batch.py +42 -37
  53. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +17 -5
  54. package/runtime/gatewaysdk/environment/schema/call_log.py +291 -0
  55. package/runtime/gatewaysdk/environment/schema/call_redaction.py +344 -0
  56. package/runtime/gatewaysdk/environment/schema/cast.py +31 -4
  57. package/runtime/gatewaysdk/environment/schema/compiler.py +334 -158
  58. package/runtime/gatewaysdk/environment/schema/conform.py +8 -12
  59. package/runtime/gatewaysdk/environment/schema/connector.py +27 -62
  60. package/runtime/gatewaysdk/environment/schema/data.py +50 -207
  61. package/runtime/gatewaysdk/environment/schema/database/__init__.py +24 -0
  62. package/runtime/gatewaysdk/environment/schema/database/audit.py +121 -0
  63. package/runtime/gatewaysdk/environment/schema/database/base.py +995 -0
  64. package/runtime/gatewaysdk/environment/schema/database/budget.py +33 -0
  65. package/runtime/gatewaysdk/environment/schema/database/connections.py +101 -0
  66. package/runtime/gatewaysdk/environment/schema/database/engines.py +8 -0
  67. package/runtime/gatewaysdk/environment/schema/database/guard.py +208 -0
  68. package/runtime/gatewaysdk/environment/schema/database/ingest.py +154 -0
  69. package/runtime/gatewaysdk/environment/schema/database/matching.py +58 -0
  70. package/runtime/gatewaysdk/environment/schema/database/provenance.py +30 -0
  71. package/runtime/gatewaysdk/environment/schema/database/rows.py +53 -0
  72. package/runtime/gatewaysdk/environment/schema/database/runtime_rows.py +39 -0
  73. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +367 -0
  74. package/runtime/gatewaysdk/environment/schema/domain_migration.py +236 -0
  75. package/runtime/gatewaysdk/environment/schema/envelope.py +169 -0
  76. package/runtime/gatewaysdk/environment/schema/extract.py +6 -13
  77. package/runtime/gatewaysdk/environment/schema/grading.py +45 -30
  78. package/runtime/gatewaysdk/environment/schema/handler_errors.py +142 -12
  79. package/runtime/gatewaysdk/environment/schema/host.py +158 -250
  80. package/runtime/gatewaysdk/environment/schema/lanes.py +53 -0
  81. package/runtime/gatewaysdk/environment/schema/local.py +44 -71
  82. package/runtime/gatewaysdk/environment/schema/mapping.py +5 -25
  83. package/runtime/gatewaysdk/environment/schema/openapi_import.py +112 -73
  84. package/runtime/gatewaysdk/environment/schema/openapi_paging.py +147 -0
  85. package/runtime/gatewaysdk/environment/schema/openapi_payloads.py +288 -0
  86. package/runtime/gatewaysdk/environment/schema/openapi_routes.py +97 -102
  87. package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +113 -30
  88. package/runtime/gatewaysdk/environment/schema/platform.py +124 -178
  89. package/runtime/gatewaysdk/environment/schema/platform_import.py +2 -3
  90. package/runtime/gatewaysdk/environment/schema/platform_query.py +61 -5
  91. package/runtime/gatewaysdk/environment/schema/primary_key.py +61 -0
  92. package/runtime/gatewaysdk/environment/schema/proof.py +19 -12
  93. package/runtime/gatewaysdk/environment/schema/runtime.py +77 -160
  94. package/runtime/gatewaysdk/environment/schema/served_names.py +58 -0
  95. package/runtime/gatewaysdk/environment/schema/session_files.py +166 -0
  96. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +2 -2
  97. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +22 -14
  98. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +29 -3
  99. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +16 -16
  100. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +18 -18
  101. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +3 -2
  102. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +15 -0
  103. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +50 -21
  104. package/runtime/gatewaysdk/environment/schema/slack.py +4 -8
  105. package/runtime/gatewaysdk/environment/schema/snapshot.py +385 -129
  106. package/runtime/gatewaysdk/environment/schema/store_contract.py +8 -14
  107. package/runtime/gatewaysdk/environment/schema/tasks.py +140 -55
  108. package/runtime/gatewaysdk/environment/schema/tools_world.py +110 -87
  109. package/runtime/gatewaysdk/environment/schema/ui.py +24 -5
  110. package/runtime/gatewaysdk/environment/schema/ui_static/app.js +100 -130
  111. package/runtime/gatewaysdk/environment/schema/ui_static/index.html +1 -8
  112. package/runtime/gatewaysdk/environment/schema/validation.py +166 -40
  113. package/runtime/gatewaysdk/environment/schema/workers.py +142 -57
  114. package/runtime/gatewaysdk/environment/schema/world_sql.py +81 -0
  115. package/runtime/gatewaysdk/environment/schema/world_tests.py +71 -39
  116. package/runtime/gatewaysdk/environment/score.py +57 -0
  117. package/runtime/gatewaysdk/environment/secret_values.py +36 -0
  118. package/runtime/gatewaysdk/environment/world.py +42 -3
  119. package/runtime/gatewaysdk/environment/world_session_contract.py +32 -5
  120. package/skills/benchmarks-getting-started/SKILL.md +2 -2
  121. package/skills/connector-schema-authoring/SKILL.md +22 -14
  122. package/skills/connector-schema-authoring/connector-worlds.md +26 -10
  123. package/skills/connector-schema-authoring/world-schema.md +111 -51
  124. package/skills/world-data-ingestion/ROWS.md +29 -3
  125. package/skills/world-data-ingestion/SKILL.md +16 -16
  126. package/skills/worlds-getting-started/SKILL.md +18 -18
  127. package/skills/worlds-getting-started/references/cli-mcp-map.md +3 -2
  128. package/skills/worlds-getting-started/references/gotchas.md +15 -0
  129. package/skills/worlds-getting-started/references/openapi-import.md +50 -21
  130. package/runtime/gatewaysdk/environment/schema/store.py +0 -1013
@@ -16,6 +16,28 @@ var __esm = (fn, res, err) => function __init() {
16
16
  }
17
17
  };
18
18
 
19
+ // src/worlds/platformEndpoint.ts
20
+ function platformEndpoint(options) {
21
+ const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
22
+ const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
23
+ if (!publicKey || !secretKey) return null;
24
+ const host = options.host ?? process.env.GATEWAY_HOST ?? DEFAULT_HOST;
25
+ return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
26
+ }
27
+ function requirePlatformEndpoint(options) {
28
+ const endpoint = platformEndpoint(options);
29
+ if (!endpoint) throw new Error(GATEWAY_KEYS_MISSING);
30
+ return endpoint;
31
+ }
32
+ var DEFAULT_HOST, GATEWAY_KEYS_MISSING;
33
+ var init_platformEndpoint = __esm({
34
+ "src/worlds/platformEndpoint.ts"() {
35
+ "use strict";
36
+ DEFAULT_HOST = "https://withgateway.ai";
37
+ GATEWAY_KEYS_MISSING = "Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey).";
38
+ }
39
+ });
40
+
19
41
  // src/worlds/transport.ts
20
42
  function platformTimeoutMs(env = process.env) {
21
43
  const raw = env[PLATFORM_TIMEOUT_ENV];
@@ -24,7 +46,7 @@ function platformTimeoutMs(env = process.env) {
24
46
  if (Number.isInteger(value) && value > 0) return value;
25
47
  throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
26
48
  }
27
- var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, PlatformTransport;
49
+ var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
28
50
  var init_transport = __esm({
29
51
  "src/worlds/transport.ts"() {
30
52
  "use strict";
@@ -86,6 +108,56 @@ var init_transport = __esm({
86
108
  route;
87
109
  failure;
88
110
  };
111
+ sleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
112
+ RetryPolicy = class _RetryPolicy {
113
+ constructor(delaysMs, wait = sleep, budgetMs = Number.POSITIVE_INFINITY, now = Date.now) {
114
+ this.delaysMs = delaysMs;
115
+ this.wait = wait;
116
+ this.budgetMs = budgetMs;
117
+ this.now = now;
118
+ }
119
+ delaysMs;
120
+ wait;
121
+ budgetMs;
122
+ now;
123
+ static NONE = new _RetryPolicy([]);
124
+ /** A platform restart or a short edge outage: no wait starts that would end past five minutes, so a step ends
125
+ * within the budget plus one request timeout. */
126
+ static FILING = new _RetryPolicy([250, 500, 1e3, 2e3, 4e3, 8e3, 16e3, 3e4], sleep, 3e5);
127
+ static TRANSIENT_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
128
+ async run(attempt) {
129
+ const started = this.now();
130
+ for (let tries = 0; ; tries += 1) {
131
+ const outcome = await Attempt.of(attempt);
132
+ const delayMs = this.delaysMs[tries];
133
+ const spent = delayMs === void 0 || this.now() - started + delayMs >= this.budgetMs;
134
+ if (!outcome.transient || spent) return outcome.settle();
135
+ await this.wait(delayMs);
136
+ }
137
+ }
138
+ };
139
+ Attempt = class _Attempt {
140
+ constructor(reply, error, transient) {
141
+ this.reply = reply;
142
+ this.error = error;
143
+ this.transient = transient;
144
+ }
145
+ reply;
146
+ error;
147
+ transient;
148
+ static async of(attempt) {
149
+ try {
150
+ const reply = await attempt();
151
+ return new _Attempt(reply, null, RetryPolicy.TRANSIENT_STATUSES.has(reply.status));
152
+ } catch (error) {
153
+ return new _Attempt(null, error, error instanceof UnreachableError);
154
+ }
155
+ }
156
+ settle() {
157
+ if (this.reply) return this.reply;
158
+ throw this.error;
159
+ }
160
+ };
89
161
  PlatformTransport = class {
90
162
  constructor(endpoint, timeoutMs = platformTimeoutMs()) {
91
163
  this.endpoint = endpoint;
@@ -99,6 +171,9 @@ var init_transport = __esm({
99
171
  }
100
172
  async send(method, route, body, opts = {}) {
101
173
  const timeoutMs = this.budget(opts.timeoutMs);
174
+ return (opts.retry ?? RetryPolicy.NONE).run(() => this.once(method, route, body, timeoutMs));
175
+ }
176
+ async once(method, route, body, timeoutMs) {
102
177
  const payload = body === void 0 ? {} : { body: JSON.stringify(body) };
103
178
  const controller = new AbortController();
104
179
  const timer = setTimeout(() => controller.abort(), timeoutMs);
@@ -471,13 +546,13 @@ var init_screen = __esm({
471
546
  });
472
547
  }
473
548
  async drag(action) {
474
- const path8 = action.args.path ?? [];
475
- if (path8.length < 2) throw new Error("a drag needs at least two points");
549
+ const path9 = action.args.path ?? [];
550
+ if (path9.length < 2) throw new Error("a drag needs at least two points");
476
551
  return this.held(action.args.modifiers ?? [], async () => {
477
- await this.moveTo(path8[0]);
552
+ await this.moveTo(path9[0]);
478
553
  await this.page.mouse.down({ button: "left" });
479
554
  try {
480
- for (const point2 of path8.slice(1)) await this.moveTo(point2, DRAG_STEPS);
555
+ for (const point2 of path9.slice(1)) await this.moveTo(point2, DRAG_STEPS);
481
556
  } finally {
482
557
  await this.page.mouse.up({ button: "left" });
483
558
  }
@@ -568,7 +643,7 @@ var init_media = __esm({
568
643
  put;
569
644
  maxBytes;
570
645
  /** The uploader for `GATEWAY_HOST` / `GATEWAY_PUBLIC_KEY` /
571
- * `GATEWAY_SECRET_KEY` (the keys tracing exports with); null when any is unset. */
646
+ * `GATEWAY_SECRET_KEY` only; null when any is unset, so a run traced with a saved login uploads none. */
572
647
  static fromEnv(env = process.env) {
573
648
  const host = env.GATEWAY_HOST;
574
649
  const publicKey = env.GATEWAY_PUBLIC_KEY;
@@ -1436,6 +1511,15 @@ var init_sessionContract = __esm({
1436
1511
  }
1437
1512
  });
1438
1513
 
1514
+ // src/worlds/sessionReadiness.ts
1515
+ var READY_TIMEOUT_MS;
1516
+ var init_sessionReadiness = __esm({
1517
+ "src/worlds/sessionReadiness.ts"() {
1518
+ "use strict";
1519
+ READY_TIMEOUT_MS = 10 * 6e4;
1520
+ }
1521
+ });
1522
+
1439
1523
  // src/tracing/session.ts
1440
1524
  import { AsyncLocalStorage } from "async_hooks";
1441
1525
  var processStorage, currentSessionStorage, currentWorldSessionStorage;
@@ -1460,9 +1544,23 @@ var init_taskRef = __esm({
1460
1544
  }
1461
1545
  });
1462
1546
 
1547
+ // src/worlds/worldNotice.ts
1548
+ var init_worldNotice = __esm({
1549
+ "src/worlds/worldNotice.ts"() {
1550
+ "use strict";
1551
+ }
1552
+ });
1553
+
1554
+ // src/worlds/grade.ts
1555
+ var init_grade = __esm({
1556
+ "src/worlds/grade.ts"() {
1557
+ "use strict";
1558
+ }
1559
+ });
1560
+
1463
1561
  // src/worlds/session.ts
1464
1562
  import { randomUUID } from "crypto";
1465
- var READY_TIMEOUT_MS, CALL_TIMEOUT_MS, JUDGED_GRADE_TIMEOUT_MS;
1563
+ var CALL_TIMEOUT_MS, JUDGED_GRADE_TIMEOUT_MS;
1466
1564
  var init_session2 = __esm({
1467
1565
  "src/worlds/session.ts"() {
1468
1566
  "use strict";
@@ -1470,10 +1568,13 @@ var init_session2 = __esm({
1470
1568
  init_browser();
1471
1569
  init_nativeComputer();
1472
1570
  init_sessionContract();
1571
+ init_sessionReadiness();
1473
1572
  init_session();
1474
1573
  init_taskRef();
1574
+ init_worldNotice();
1575
+ init_grade();
1475
1576
  init_taskRef();
1476
- READY_TIMEOUT_MS = 10 * 6e4;
1577
+ init_sessionReadiness();
1477
1578
  CALL_TIMEOUT_MS = 3 * 6e4;
1478
1579
  JUDGED_GRADE_TIMEOUT_MS = 15 * 6e4;
1479
1580
  }
@@ -1495,12 +1596,22 @@ var init_tasks = __esm({
1495
1596
  }
1496
1597
  });
1497
1598
 
1599
+ // src/worlds/surfaceDescriptor.ts
1600
+ var init_surfaceDescriptor = __esm({
1601
+ "src/worlds/surfaceDescriptor.ts"() {
1602
+ "use strict";
1603
+ init_browser();
1604
+ }
1605
+ });
1606
+
1498
1607
  // src/worlds/taskSessions.ts
1499
1608
  var init_taskSessions = __esm({
1500
1609
  "src/worlds/taskSessions.ts"() {
1501
1610
  "use strict";
1502
1611
  init_worlds();
1503
1612
  init_browser();
1613
+ init_grade();
1614
+ init_surfaceDescriptor();
1504
1615
  init_session2();
1505
1616
  }
1506
1617
  });
@@ -1510,20 +1621,77 @@ var init_evals = __esm({
1510
1621
  "src/worlds/evals.ts"() {
1511
1622
  "use strict";
1512
1623
  init_worlds();
1624
+ init_transport();
1513
1625
  }
1514
1626
  });
1515
1627
 
1516
- // src/worlds/taskRun.ts
1517
- import { randomBytes } from "crypto";
1628
+ // src/worlds/runSignals.ts
1629
+ import { constants } from "os";
1630
+ var init_runSignals = __esm({
1631
+ "src/worlds/runSignals.ts"() {
1632
+ "use strict";
1633
+ }
1634
+ });
1635
+
1636
+ // src/worlds/taskRunDir.ts
1518
1637
  import * as fs from "fs";
1519
1638
  import * as path from "path";
1639
+ var init_taskRunDir = __esm({
1640
+ "src/worlds/taskRunDir.ts"() {
1641
+ "use strict";
1642
+ init_browser();
1643
+ }
1644
+ });
1645
+
1646
+ // src/worlds/taskRunOutcome.ts
1647
+ var init_taskRunOutcome = __esm({
1648
+ "src/worlds/taskRunOutcome.ts"() {
1649
+ "use strict";
1650
+ init_grade();
1651
+ init_taskSessions();
1652
+ }
1653
+ });
1654
+
1655
+ // src/tracing/prerequisites.ts
1656
+ var OPENTELEMETRY_PEERS, PINNED_PEERS;
1657
+ var init_prerequisites = __esm({
1658
+ "src/tracing/prerequisites.ts"() {
1659
+ "use strict";
1660
+ OPENTELEMETRY_PEERS = {
1661
+ "@opentelemetry/api": "1.9.0",
1662
+ "@opentelemetry/exporter-trace-otlp-http": "0.222.0",
1663
+ "@opentelemetry/resources": "2.11.0",
1664
+ "@opentelemetry/sdk-trace-base": "2.11.0",
1665
+ "@opentelemetry/sdk-trace-node": "2.11.0"
1666
+ };
1667
+ PINNED_PEERS = Object.entries(OPENTELEMETRY_PEERS).map(([name, version]) => `${name}@${version}`).join(" ");
1668
+ }
1669
+ });
1670
+
1671
+ // src/worlds/taskTracing.ts
1672
+ var init_taskTracing = __esm({
1673
+ "src/worlds/taskTracing.ts"() {
1674
+ "use strict";
1675
+ init_prerequisites();
1676
+ init_platformEndpoint();
1677
+ }
1678
+ });
1679
+
1680
+ // src/worlds/taskRun.ts
1681
+ import { randomBytes } from "crypto";
1682
+ import * as path2 from "path";
1520
1683
  var init_taskRun = __esm({
1521
1684
  "src/worlds/taskRun.ts"() {
1522
1685
  "use strict";
1523
1686
  init_browser();
1524
1687
  init_evals();
1688
+ init_runSignals();
1525
1689
  init_session2();
1526
1690
  init_taskSessions();
1691
+ init_taskRunDir();
1692
+ init_taskRunOutcome();
1693
+ init_taskTracing();
1694
+ init_worldNotice();
1527
1695
  }
1528
1696
  });
1529
1697
 
@@ -1541,13 +1709,21 @@ var init_setRun = __esm({
1541
1709
  "use strict";
1542
1710
  init_worlds();
1543
1711
  init_checkoutProvenance();
1712
+ init_runSignals();
1544
1713
  init_taskRun();
1545
1714
  }
1546
1715
  });
1547
1716
 
1717
+ // src/worlds/requestLog.ts
1718
+ var init_requestLog = __esm({
1719
+ "src/worlds/requestLog.ts"() {
1720
+ "use strict";
1721
+ }
1722
+ });
1723
+
1548
1724
  // src/worlds/checkoutTarget.ts
1549
1725
  import * as fs2 from "fs";
1550
- import * as path2 from "path";
1726
+ import * as path3 from "path";
1551
1727
  var init_checkoutTarget = __esm({
1552
1728
  "src/worlds/checkoutTarget.ts"() {
1553
1729
  "use strict";
@@ -1557,7 +1733,7 @@ var init_checkoutTarget = __esm({
1557
1733
  // src/worlds/worldDir.ts
1558
1734
  import { createHash as createHash2 } from "crypto";
1559
1735
  import * as fs3 from "fs";
1560
- import * as path3 from "path";
1736
+ import * as path4 from "path";
1561
1737
  var CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
1562
1738
  var init_worldDir = __esm({
1563
1739
  "src/worlds/worldDir.ts"() {
@@ -1570,7 +1746,7 @@ var init_worldDir = __esm({
1570
1746
 
1571
1747
  // src/worlds/tar.ts
1572
1748
  import * as fs4 from "fs";
1573
- import * as path4 from "path";
1749
+ import * as path5 from "path";
1574
1750
  import { gunzipSync } from "zlib";
1575
1751
  var init_tar = __esm({
1576
1752
  "src/worlds/tar.ts"() {
@@ -1582,7 +1758,7 @@ var init_tar = __esm({
1582
1758
  import { createHash as createHash3 } from "crypto";
1583
1759
  import { gzipSync } from "zlib";
1584
1760
  import * as fs5 from "fs";
1585
- import * as path5 from "path";
1761
+ import * as path6 from "path";
1586
1762
  var META_RELPATH;
1587
1763
  var init_hub = __esm({
1588
1764
  "src/worlds/hub.ts"() {
@@ -1591,7 +1767,7 @@ var init_hub = __esm({
1591
1767
  init_checkoutTarget();
1592
1768
  init_worldDir();
1593
1769
  init_tar();
1594
- META_RELPATH = path5.join(".gateway", ".env-metadata.json");
1770
+ META_RELPATH = path6.join(".gateway", ".env-metadata.json");
1595
1771
  }
1596
1772
  });
1597
1773
 
@@ -1697,11 +1873,12 @@ var init_migrate = __esm({
1697
1873
  // src/worlds/ingest.ts
1698
1874
  import * as fs6 from "fs";
1699
1875
  import * as os from "os";
1700
- import * as path6 from "path";
1876
+ import * as path7 from "path";
1701
1877
  var init_ingest = __esm({
1702
1878
  "src/worlds/ingest.ts"() {
1703
1879
  "use strict";
1704
1880
  init_worlds();
1881
+ init_platformEndpoint();
1705
1882
  }
1706
1883
  });
1707
1884
 
@@ -1722,17 +1899,6 @@ var init_dryRun = __esm({
1722
1899
  });
1723
1900
 
1724
1901
  // src/worlds/index.ts
1725
- function resolveEnv(options) {
1726
- const host = options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai";
1727
- const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
1728
- const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
1729
- if (!publicKey || !secretKey) {
1730
- throw new Error(
1731
- "Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey)."
1732
- );
1733
- }
1734
- return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
1735
- }
1736
1902
  function parseErrorBody(text, limit = 600) {
1737
1903
  const raw = { detail: text.slice(0, limit), code: null };
1738
1904
  let parsed;
@@ -1752,18 +1918,20 @@ function parseErrorBody(text, limit = 600) {
1752
1918
  code: stableCode
1753
1919
  };
1754
1920
  }
1755
- async function apiRequest(options, method, path8, body, init = {}) {
1756
- const reply = await new PlatformTransport(resolveEnv(options)).send(method, path8, body, init);
1757
- if (!reply.ok) throw new ApiError(reply.status, method, path8, reply.text);
1921
+ async function apiRequest(options, method, path9, body, init = {}) {
1922
+ const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path9, body, init);
1923
+ if (!reply.ok) throw new ApiError(reply.status, method, path9, reply.text);
1758
1924
  return JSON.parse(reply.text);
1759
1925
  }
1760
1926
  var ApiError;
1761
1927
  var init_worlds = __esm({
1762
1928
  "src/worlds/index.ts"() {
1763
1929
  "use strict";
1930
+ init_platformEndpoint();
1764
1931
  init_transport();
1765
1932
  init_transport();
1766
1933
  init_session2();
1934
+ init_grade();
1767
1935
  init_sessionList();
1768
1936
  init_sessionContract();
1769
1937
  init_taskRef();
@@ -1774,6 +1942,8 @@ var init_worlds = __esm({
1774
1942
  init_checkoutProvenance();
1775
1943
  init_evals();
1776
1944
  init_browser();
1945
+ init_surfaceDescriptor();
1946
+ init_requestLog();
1777
1947
  init_browserReconnect();
1778
1948
  init_nativeComputer();
1779
1949
  init_hub();
@@ -1787,10 +1957,11 @@ var init_worlds = __esm({
1787
1957
  init_sandbox();
1788
1958
  init_editSessions();
1789
1959
  init_dryRun();
1960
+ init_worldNotice();
1790
1961
  ApiError = class extends Error {
1791
- constructor(status, method, path8, text) {
1962
+ constructor(status, method, path9, text) {
1792
1963
  const parsed = parseErrorBody(text);
1793
- super(`${method} ${path8} -> ${status}: ${parsed.detail}`);
1964
+ super(`${method} ${path9} -> ${status}: ${parsed.detail}`);
1794
1965
  this.status = status;
1795
1966
  this.text = text;
1796
1967
  this.name = "ApiError";
@@ -1807,7 +1978,7 @@ var init_worlds = __esm({
1807
1978
  init_worlds();
1808
1979
  import { createHash as createHash6 } from "crypto";
1809
1980
  import * as fs7 from "fs";
1810
- import * as path7 from "path";
1981
+ import * as path8 from "path";
1811
1982
  import { Readable, Transform } from "stream";
1812
1983
  import { pipeline } from "stream/promises";
1813
1984
  var DRIVE_PREFIX = "drive:";
@@ -1858,7 +2029,7 @@ async function readFile(options = {}, filePath, limits = {}) {
1858
2029
  async function downloadFile(options = {}, filePath, outPath, onProgress) {
1859
2030
  const file = await getFile(options, filePath);
1860
2031
  const res = await openDownload(file.url);
1861
- fs7.mkdirSync(path7.dirname(path7.resolve(outPath)), { recursive: true });
2032
+ fs7.mkdirSync(path8.dirname(path8.resolve(outPath)), { recursive: true });
1862
2033
  const source = Readable.fromWeb(res.body);
1863
2034
  await pipeline(source, counting((n) => onProgress?.(n, file.sizeBytes)), fs7.createWriteStream(outPath));
1864
2035
  return { ...file, out: outPath };
@@ -1907,7 +2078,7 @@ var CONTENT_TYPES = {
1907
2078
  ".mp4": "video/mp4"
1908
2079
  };
1909
2080
  function contentTypeFor(name) {
1910
- return CONTENT_TYPES[path7.extname(name).toLowerCase()] ?? "application/octet-stream";
2081
+ return CONTENT_TYPES[path8.extname(name).toLowerCase()] ?? "application/octet-stream";
1911
2082
  }
1912
2083
  function counting(report) {
1913
2084
  let seen = 0;