@withgateway/sdk 0.3.1 → 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 (129) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +2880 -2032
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +2982 -2135
  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 +180 -41
  9. package/dist/files/index.js.map +1 -1
  10. package/dist/files/index.mjs +172 -35
  11. package/dist/files/index.mjs.map +1 -1
  12. package/dist/{index-CBqbB_0J.d.ts → index-DUHmS74p.d.ts} +1 -1
  13. package/dist/{index-D-AMnAMa.d.mts → index-mJhG3vZU.d.mts} +1 -1
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.js +1309 -540
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +1287 -532
  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 +177 -38
  25. package/dist/traces/index.js.map +1 -1
  26. package/dist/traces/index.mjs +169 -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 +69 -13
  31. package/dist/tracing/index.js.map +1 -1
  32. package/dist/tracing/index.mjs +69 -13
  33. package/dist/tracing/index.mjs.map +1 -1
  34. package/dist/worlds/index.d.mts +249 -120
  35. package/dist/worlds/index.d.ts +249 -120
  36. package/dist/worlds/index.js +1240 -484
  37. package/dist/worlds/index.js.map +1 -1
  38. package/dist/worlds/index.mjs +1231 -476
  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 -514
  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/compiler.py +334 -158
  57. package/runtime/gatewaysdk/environment/schema/conform.py +8 -12
  58. package/runtime/gatewaysdk/environment/schema/connector.py +27 -62
  59. package/runtime/gatewaysdk/environment/schema/data.py +50 -207
  60. package/runtime/gatewaysdk/environment/schema/database/__init__.py +24 -0
  61. package/runtime/gatewaysdk/environment/schema/database/audit.py +121 -0
  62. package/runtime/gatewaysdk/environment/schema/database/base.py +995 -0
  63. package/runtime/gatewaysdk/environment/schema/database/budget.py +33 -0
  64. package/runtime/gatewaysdk/environment/schema/database/connections.py +101 -0
  65. package/runtime/gatewaysdk/environment/schema/database/engines.py +8 -0
  66. package/runtime/gatewaysdk/environment/schema/database/guard.py +208 -0
  67. package/runtime/gatewaysdk/environment/schema/database/ingest.py +154 -0
  68. package/runtime/gatewaysdk/environment/schema/database/matching.py +58 -0
  69. package/runtime/gatewaysdk/environment/schema/database/provenance.py +30 -0
  70. package/runtime/gatewaysdk/environment/schema/database/rows.py +53 -0
  71. package/runtime/gatewaysdk/environment/schema/database/runtime_rows.py +39 -0
  72. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +367 -0
  73. package/runtime/gatewaysdk/environment/schema/domain_migration.py +236 -0
  74. package/runtime/gatewaysdk/environment/schema/envelope.py +169 -0
  75. package/runtime/gatewaysdk/environment/schema/extract.py +6 -13
  76. package/runtime/gatewaysdk/environment/schema/grading.py +45 -30
  77. package/runtime/gatewaysdk/environment/schema/handler_errors.py +142 -12
  78. package/runtime/gatewaysdk/environment/schema/host.py +158 -250
  79. package/runtime/gatewaysdk/environment/schema/lanes.py +53 -0
  80. package/runtime/gatewaysdk/environment/schema/local.py +44 -71
  81. package/runtime/gatewaysdk/environment/schema/mapping.py +5 -25
  82. package/runtime/gatewaysdk/environment/schema/openapi_import.py +112 -73
  83. package/runtime/gatewaysdk/environment/schema/openapi_paging.py +147 -0
  84. package/runtime/gatewaysdk/environment/schema/openapi_payloads.py +288 -0
  85. package/runtime/gatewaysdk/environment/schema/openapi_routes.py +97 -102
  86. package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +113 -30
  87. package/runtime/gatewaysdk/environment/schema/platform.py +123 -171
  88. package/runtime/gatewaysdk/environment/schema/platform_import.py +2 -3
  89. package/runtime/gatewaysdk/environment/schema/platform_query.py +61 -5
  90. package/runtime/gatewaysdk/environment/schema/primary_key.py +61 -0
  91. package/runtime/gatewaysdk/environment/schema/proof.py +19 -12
  92. package/runtime/gatewaysdk/environment/schema/runtime.py +77 -160
  93. package/runtime/gatewaysdk/environment/schema/served_names.py +58 -0
  94. package/runtime/gatewaysdk/environment/schema/session_files.py +166 -0
  95. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +2 -2
  96. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +19 -11
  97. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +29 -3
  98. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +14 -14
  99. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +12 -12
  100. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +3 -2
  101. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +15 -0
  102. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/openapi-import.md +50 -21
  103. package/runtime/gatewaysdk/environment/schema/slack.py +4 -8
  104. package/runtime/gatewaysdk/environment/schema/snapshot.py +385 -129
  105. package/runtime/gatewaysdk/environment/schema/store_contract.py +8 -14
  106. package/runtime/gatewaysdk/environment/schema/tasks.py +140 -55
  107. package/runtime/gatewaysdk/environment/schema/tools_world.py +110 -87
  108. package/runtime/gatewaysdk/environment/schema/ui.py +24 -5
  109. package/runtime/gatewaysdk/environment/schema/ui_static/app.js +100 -130
  110. package/runtime/gatewaysdk/environment/schema/ui_static/index.html +1 -8
  111. package/runtime/gatewaysdk/environment/schema/validation.py +166 -40
  112. package/runtime/gatewaysdk/environment/schema/workers.py +142 -57
  113. package/runtime/gatewaysdk/environment/schema/world_sql.py +81 -0
  114. package/runtime/gatewaysdk/environment/schema/world_tests.py +71 -39
  115. package/runtime/gatewaysdk/environment/score.py +57 -0
  116. package/runtime/gatewaysdk/environment/secret_values.py +36 -0
  117. package/runtime/gatewaysdk/environment/world.py +42 -3
  118. package/runtime/gatewaysdk/environment/world_session_contract.py +32 -5
  119. package/skills/benchmarks-getting-started/SKILL.md +2 -2
  120. package/skills/connector-schema-authoring/SKILL.md +19 -11
  121. package/skills/connector-schema-authoring/connector-worlds.md +13 -4
  122. package/skills/connector-schema-authoring/world-schema.md +103 -51
  123. package/skills/world-data-ingestion/ROWS.md +29 -3
  124. package/skills/world-data-ingestion/SKILL.md +14 -14
  125. package/skills/worlds-getting-started/SKILL.md +12 -12
  126. package/skills/worlds-getting-started/references/cli-mcp-map.md +3 -2
  127. package/skills/worlds-getting-started/references/gotchas.md +15 -0
  128. package/skills/worlds-getting-started/references/openapi-import.md +50 -21
  129. 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((resolve3) => setTimeout(resolve3, 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 path7 = action.args.path ?? [];
475
- if (path7.length < 2) throw new Error("a drag needs at least two points");
549
+ const path8 = action.args.path ?? [];
550
+ if (path8.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(path7[0]);
552
+ await this.moveTo(path8[0]);
478
553
  await this.page.mouse.down({ button: "left" });
479
554
  try {
480
- for (const point2 of path7.slice(1)) await this.moveTo(point2, DRAG_STEPS);
555
+ for (const point2 of path8.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
  }
@@ -1509,6 +1610,7 @@ var init_taskSessions = __esm({
1509
1610
  "use strict";
1510
1611
  init_worlds();
1511
1612
  init_browser();
1613
+ init_grade();
1512
1614
  init_surfaceDescriptor();
1513
1615
  init_session2();
1514
1616
  }
@@ -1519,13 +1621,50 @@ var init_evals = __esm({
1519
1621
  "src/worlds/evals.ts"() {
1520
1622
  "use strict";
1521
1623
  init_worlds();
1624
+ init_transport();
1625
+ }
1626
+ });
1627
+
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
1637
+ import * as fs from "fs";
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();
1522
1652
  }
1523
1653
  });
1524
1654
 
1525
1655
  // src/tracing/prerequisites.ts
1656
+ var OPENTELEMETRY_PEERS, PINNED_PEERS;
1526
1657
  var init_prerequisites = __esm({
1527
1658
  "src/tracing/prerequisites.ts"() {
1528
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(" ");
1529
1668
  }
1530
1669
  });
1531
1670
 
@@ -1534,21 +1673,25 @@ var init_taskTracing = __esm({
1534
1673
  "src/worlds/taskTracing.ts"() {
1535
1674
  "use strict";
1536
1675
  init_prerequisites();
1676
+ init_platformEndpoint();
1537
1677
  }
1538
1678
  });
1539
1679
 
1540
1680
  // src/worlds/taskRun.ts
1541
1681
  import { randomBytes } from "crypto";
1542
- import * as fs from "fs";
1543
- import * as path from "path";
1682
+ import * as path2 from "path";
1544
1683
  var init_taskRun = __esm({
1545
1684
  "src/worlds/taskRun.ts"() {
1546
1685
  "use strict";
1547
1686
  init_browser();
1548
1687
  init_evals();
1688
+ init_runSignals();
1549
1689
  init_session2();
1550
1690
  init_taskSessions();
1691
+ init_taskRunDir();
1692
+ init_taskRunOutcome();
1551
1693
  init_taskTracing();
1694
+ init_worldNotice();
1552
1695
  }
1553
1696
  });
1554
1697
 
@@ -1566,6 +1709,7 @@ var init_setRun = __esm({
1566
1709
  "use strict";
1567
1710
  init_worlds();
1568
1711
  init_checkoutProvenance();
1712
+ init_runSignals();
1569
1713
  init_taskRun();
1570
1714
  }
1571
1715
  });
@@ -1579,7 +1723,7 @@ var init_requestLog = __esm({
1579
1723
 
1580
1724
  // src/worlds/checkoutTarget.ts
1581
1725
  import * as fs2 from "fs";
1582
- import * as path2 from "path";
1726
+ import * as path3 from "path";
1583
1727
  var init_checkoutTarget = __esm({
1584
1728
  "src/worlds/checkoutTarget.ts"() {
1585
1729
  "use strict";
@@ -1589,7 +1733,7 @@ var init_checkoutTarget = __esm({
1589
1733
  // src/worlds/worldDir.ts
1590
1734
  import { createHash as createHash2 } from "crypto";
1591
1735
  import * as fs3 from "fs";
1592
- import * as path3 from "path";
1736
+ import * as path4 from "path";
1593
1737
  var CONNECTOR_SPEC, WORLD_SCHEMA_MARKERS, WORLD_ROOT_MARKERS;
1594
1738
  var init_worldDir = __esm({
1595
1739
  "src/worlds/worldDir.ts"() {
@@ -1602,7 +1746,7 @@ var init_worldDir = __esm({
1602
1746
 
1603
1747
  // src/worlds/tar.ts
1604
1748
  import * as fs4 from "fs";
1605
- import * as path4 from "path";
1749
+ import * as path5 from "path";
1606
1750
  import { gunzipSync } from "zlib";
1607
1751
  var init_tar = __esm({
1608
1752
  "src/worlds/tar.ts"() {
@@ -1614,7 +1758,7 @@ var init_tar = __esm({
1614
1758
  import { createHash as createHash3 } from "crypto";
1615
1759
  import { gzipSync } from "zlib";
1616
1760
  import * as fs5 from "fs";
1617
- import * as path5 from "path";
1761
+ import * as path6 from "path";
1618
1762
  var META_RELPATH;
1619
1763
  var init_hub = __esm({
1620
1764
  "src/worlds/hub.ts"() {
@@ -1623,7 +1767,7 @@ var init_hub = __esm({
1623
1767
  init_checkoutTarget();
1624
1768
  init_worldDir();
1625
1769
  init_tar();
1626
- META_RELPATH = path5.join(".gateway", ".env-metadata.json");
1770
+ META_RELPATH = path6.join(".gateway", ".env-metadata.json");
1627
1771
  }
1628
1772
  });
1629
1773
 
@@ -1729,11 +1873,12 @@ var init_migrate = __esm({
1729
1873
  // src/worlds/ingest.ts
1730
1874
  import * as fs6 from "fs";
1731
1875
  import * as os from "os";
1732
- import * as path6 from "path";
1876
+ import * as path7 from "path";
1733
1877
  var init_ingest = __esm({
1734
1878
  "src/worlds/ingest.ts"() {
1735
1879
  "use strict";
1736
1880
  init_worlds();
1881
+ init_platformEndpoint();
1737
1882
  }
1738
1883
  });
1739
1884
 
@@ -1754,17 +1899,6 @@ var init_dryRun = __esm({
1754
1899
  });
1755
1900
 
1756
1901
  // src/worlds/index.ts
1757
- function resolveEnv(options) {
1758
- const host = options.host ?? process.env.GATEWAY_HOST ?? "https://withgateway.ai";
1759
- const publicKey = options.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
1760
- const secretKey = options.secretKey ?? process.env.GATEWAY_SECRET_KEY;
1761
- if (!publicKey || !secretKey) {
1762
- throw new Error(
1763
- "Gateway keys missing: set GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY (or pass publicKey/secretKey)."
1764
- );
1765
- }
1766
- return { host: host.replace(/\/+$/, ""), publicKey, secretKey };
1767
- }
1768
1902
  function parseErrorBody(text, limit = 600) {
1769
1903
  const raw = { detail: text.slice(0, limit), code: null };
1770
1904
  let parsed;
@@ -1784,18 +1918,20 @@ function parseErrorBody(text, limit = 600) {
1784
1918
  code: stableCode
1785
1919
  };
1786
1920
  }
1787
- async function apiRequest(options, method, path7, body, init = {}) {
1788
- const reply = await new PlatformTransport(resolveEnv(options)).send(method, path7, body, init);
1789
- if (!reply.ok) throw new ApiError(reply.status, method, path7, reply.text);
1921
+ async function apiRequest(options, method, path8, body, init = {}) {
1922
+ const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path8, body, init);
1923
+ if (!reply.ok) throw new ApiError(reply.status, method, path8, reply.text);
1790
1924
  return JSON.parse(reply.text);
1791
1925
  }
1792
1926
  var ApiError;
1793
1927
  var init_worlds = __esm({
1794
1928
  "src/worlds/index.ts"() {
1795
1929
  "use strict";
1930
+ init_platformEndpoint();
1796
1931
  init_transport();
1797
1932
  init_transport();
1798
1933
  init_session2();
1934
+ init_grade();
1799
1935
  init_sessionList();
1800
1936
  init_sessionContract();
1801
1937
  init_taskRef();
@@ -1821,10 +1957,11 @@ var init_worlds = __esm({
1821
1957
  init_sandbox();
1822
1958
  init_editSessions();
1823
1959
  init_dryRun();
1960
+ init_worldNotice();
1824
1961
  ApiError = class extends Error {
1825
- constructor(status, method, path7, text) {
1962
+ constructor(status, method, path8, text) {
1826
1963
  const parsed = parseErrorBody(text);
1827
- super(`${method} ${path7} -> ${status}: ${parsed.detail}`);
1964
+ super(`${method} ${path8} -> ${status}: ${parsed.detail}`);
1828
1965
  this.status = status;
1829
1966
  this.text = text;
1830
1967
  this.name = "ApiError";