@withgateway/sdk 0.3.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +3005 -1401
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +2996 -1392
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/files/index.js +128 -37
  7. package/dist/files/index.js.map +1 -1
  8. package/dist/files/index.mjs +126 -35
  9. package/dist/files/index.mjs.map +1 -1
  10. package/dist/hooks/index.d.mts +1 -1
  11. package/dist/hooks/index.d.ts +1 -1
  12. package/dist/hooks/index.js +124 -11
  13. package/dist/hooks/index.js.map +1 -1
  14. package/dist/hooks/index.mjs +124 -11
  15. package/dist/hooks/index.mjs.map +1 -1
  16. package/dist/{index-C3UzD0G3.d.mts → index-CDPQBsU5.d.mts} +19 -3
  17. package/dist/{index-C3UzD0G3.d.ts → index-CDPQBsU5.d.ts} +19 -3
  18. package/dist/{index-mJhG3vZU.d.mts → index-Di9nNqOY.d.mts} +26 -3
  19. package/dist/{index-DUHmS74p.d.ts → index-LA-PMRJT.d.ts} +26 -3
  20. package/dist/index.d.mts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +1078 -260
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +1040 -251
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/replay/index.d.mts +1 -1
  27. package/dist/replay/index.d.ts +1 -1
  28. package/dist/replay/index.js.map +1 -1
  29. package/dist/replay/index.mjs.map +1 -1
  30. package/dist/traces/index.js +125 -34
  31. package/dist/traces/index.js.map +1 -1
  32. package/dist/traces/index.mjs +123 -32
  33. package/dist/traces/index.mjs.map +1 -1
  34. package/dist/tracing/index.d.mts +1 -1
  35. package/dist/tracing/index.d.ts +1 -1
  36. package/dist/tracing/index.js +7 -1
  37. package/dist/tracing/index.js.map +1 -1
  38. package/dist/tracing/index.mjs +7 -1
  39. package/dist/tracing/index.mjs.map +1 -1
  40. package/dist/worlds/index.d.mts +819 -438
  41. package/dist/worlds/index.d.ts +819 -438
  42. package/dist/worlds/index.js +912 -236
  43. package/dist/worlds/index.js.map +1 -1
  44. package/dist/worlds/index.mjs +908 -232
  45. package/dist/worlds/index.mjs.map +1 -1
  46. package/package.json +1 -1
  47. package/runtime/gatewaysdk/environment/_bundle.py +4 -6
  48. package/runtime/gatewaysdk/environment/_materialize.py +5 -25
  49. package/runtime/gatewaysdk/environment/_world.py +82 -66
  50. package/runtime/gatewaysdk/environment/backing.py +20 -24
  51. package/runtime/gatewaysdk/environment/core.py +1 -16
  52. package/runtime/gatewaysdk/environment/legacy_sqlite.py +14 -27
  53. package/runtime/gatewaysdk/environment/runtime.py +45 -2
  54. package/runtime/gatewaysdk/environment/schema/admission.py +174 -0
  55. package/runtime/gatewaysdk/environment/schema/api.py +198 -474
  56. package/runtime/gatewaysdk/environment/schema/assertions.py +458 -0
  57. package/runtime/gatewaysdk/environment/schema/batch.py +3 -3
  58. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
  59. package/runtime/gatewaysdk/environment/schema/cache_layout.py +5 -0
  60. package/runtime/gatewaysdk/environment/schema/call_capture.py +321 -0
  61. package/runtime/gatewaysdk/environment/schema/call_log.py +276 -18
  62. package/runtime/gatewaysdk/environment/schema/call_redaction.py +207 -19
  63. package/runtime/gatewaysdk/environment/schema/cast.py +15 -35
  64. package/runtime/gatewaysdk/environment/schema/compiler.py +4 -1
  65. package/runtime/gatewaysdk/environment/schema/conform.py +38 -35
  66. package/runtime/gatewaysdk/environment/schema/connector.py +94 -152
  67. package/runtime/gatewaysdk/environment/schema/connectors/confluence/connector.toml +1 -12
  68. package/runtime/gatewaysdk/environment/schema/connectors/custom/handlers.py +2 -1
  69. package/runtime/gatewaysdk/environment/schema/connectors/github/api/handlers.py +217 -58
  70. package/runtime/gatewaysdk/environment/schema/connectors/github/connector.toml +10 -19
  71. package/runtime/gatewaysdk/environment/schema/connectors/github/scenarios/default/seed/github_webhooks.json +10 -2
  72. package/runtime/gatewaysdk/environment/schema/connectors/github/tests/webhooks.json +47 -0
  73. package/runtime/gatewaysdk/environment/schema/connectors/github/world.json +21 -0
  74. package/runtime/gatewaysdk/environment/schema/connectors/jamf/api/handlers.py +185 -18
  75. package/runtime/gatewaysdk/environment/schema/connectors/jamf/connector.toml +29 -14
  76. package/runtime/gatewaysdk/environment/schema/connectors/jamf/provenance.json +43 -12
  77. package/runtime/gatewaysdk/environment/schema/connectors/jamf/scenarios/default/seed/jamf_webhooks.json +2 -2
  78. package/runtime/gatewaysdk/environment/schema/connectors/jamf/scope.toml +4 -17
  79. package/runtime/gatewaysdk/environment/schema/connectors/jamf/tests/webhooks.json +107 -0
  80. package/runtime/gatewaysdk/environment/schema/connectors/jamf/vendor-openapi.json +1 -1
  81. package/runtime/gatewaysdk/environment/schema/connectors/linear/api/handlers.py +85 -1
  82. package/runtime/gatewaysdk/environment/schema/connectors/linear/connector.toml +19 -31
  83. package/runtime/gatewaysdk/environment/schema/connectors/linear/provenance.json +18 -8
  84. package/runtime/gatewaysdk/environment/schema/connectors/linear/scenarios/default/seed/webhooks.json +19 -3
  85. package/runtime/gatewaysdk/environment/schema/connectors/linear/tests/test_webhooks.py +71 -0
  86. package/runtime/gatewaysdk/environment/schema/connectors/servicenow/connector.toml +2 -5
  87. package/runtime/gatewaysdk/environment/schema/cors.py +54 -0
  88. package/runtime/gatewaysdk/environment/schema/credentials.py +313 -8
  89. package/runtime/gatewaysdk/environment/schema/data.py +14 -13
  90. package/runtime/gatewaysdk/environment/schema/database/base.py +106 -165
  91. package/runtime/gatewaysdk/environment/schema/database/guard.py +45 -37
  92. package/runtime/gatewaysdk/environment/schema/database/reads.py +169 -0
  93. package/runtime/gatewaysdk/environment/schema/database/sqlite.py +57 -31
  94. package/runtime/gatewaysdk/environment/schema/declared_routes.py +210 -0
  95. package/runtime/gatewaysdk/environment/schema/door.py +899 -0
  96. package/runtime/gatewaysdk/environment/schema/envelope.py +86 -28
  97. package/runtime/gatewaysdk/environment/schema/grading.py +58 -86
  98. package/runtime/gatewaysdk/environment/schema/handler_errors.py +52 -5
  99. package/runtime/gatewaysdk/environment/schema/host.py +229 -1695
  100. package/runtime/gatewaysdk/environment/schema/host_control.py +144 -0
  101. package/runtime/gatewaysdk/environment/schema/host_handoff.py +370 -0
  102. package/runtime/gatewaysdk/environment/schema/host_loops.py +97 -0
  103. package/runtime/gatewaysdk/environment/schema/host_owners.py +121 -0
  104. package/runtime/gatewaysdk/environment/schema/host_proxy.py +111 -0
  105. package/runtime/gatewaysdk/environment/schema/host_requests.py +6 -0
  106. package/runtime/gatewaysdk/environment/schema/host_session.py +126 -0
  107. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +79 -21
  108. package/runtime/gatewaysdk/environment/schema/host_transfers.py +127 -0
  109. package/runtime/gatewaysdk/environment/schema/host_versions.py +242 -0
  110. package/runtime/gatewaysdk/environment/schema/host_workers.py +577 -0
  111. package/runtime/gatewaysdk/environment/schema/journal.py +438 -0
  112. package/runtime/gatewaysdk/environment/schema/ledger_spill.py +828 -0
  113. package/runtime/gatewaysdk/environment/schema/local.py +32 -116
  114. package/runtime/gatewaysdk/environment/schema/openapi_schemas.py +20 -5
  115. package/runtime/gatewaysdk/environment/schema/platform.py +29 -234
  116. package/runtime/gatewaysdk/environment/schema/request_body.py +238 -0
  117. package/runtime/gatewaysdk/environment/schema/request_ledger.py +958 -0
  118. package/runtime/gatewaysdk/environment/schema/route_bindings.py +25 -3
  119. package/runtime/gatewaysdk/environment/schema/route_miss.py +54 -0
  120. package/runtime/gatewaysdk/environment/schema/runtime.py +136 -176
  121. package/runtime/gatewaysdk/environment/schema/scaffold.py +2 -1
  122. package/runtime/gatewaysdk/environment/schema/session_files.py +133 -24
  123. package/runtime/gatewaysdk/environment/schema/session_move.py +275 -0
  124. package/runtime/gatewaysdk/environment/schema/skills/agents/connector-template-author.md +5 -1
  125. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +8 -9
  126. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/CONNECTORS.md +3 -3
  127. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +50 -28
  128. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +12 -8
  129. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +20 -22
  130. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +25 -25
  131. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
  132. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +71 -7
  133. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +182 -0
  134. package/runtime/gatewaysdk/environment/schema/snapshot.py +150 -30
  135. package/runtime/gatewaysdk/environment/schema/spill_files.py +228 -0
  136. package/runtime/gatewaysdk/environment/schema/tasks.py +229 -323
  137. package/runtime/gatewaysdk/environment/schema/tools_world.py +103 -203
  138. package/runtime/gatewaysdk/environment/schema/validation.py +69 -1
  139. package/runtime/gatewaysdk/environment/schema/verbs.py +38 -36
  140. package/runtime/gatewaysdk/environment/schema/webhooks.py +687 -0
  141. package/runtime/gatewaysdk/environment/schema/worker.py +6 -4
  142. package/runtime/gatewaysdk/environment/schema/workers.py +203 -39
  143. package/runtime/gatewaysdk/environment/schema/world_host.py +970 -0
  144. package/runtime/gatewaysdk/environment/schema/world_tests.py +83 -11
  145. package/runtime/gatewaysdk/environment/world.py +1 -1
  146. package/runtime/gatewaysdk/environment/world_session_contract.py +14 -0
  147. package/skills/agents/connector-template-author.md +5 -1
  148. package/skills/benchmarks-getting-started/SKILL.md +8 -9
  149. package/skills/connector-schema-authoring/CONNECTORS.md +3 -3
  150. package/skills/connector-schema-authoring/SKILL.md +50 -28
  151. package/skills/connector-schema-authoring/connector-worlds.md +282 -18
  152. package/skills/connector-schema-authoring/world-schema.md +7 -6
  153. package/skills/world-data-ingestion/ROWS.md +12 -8
  154. package/skills/world-data-ingestion/SKILL.md +20 -22
  155. package/skills/worlds-getting-started/SKILL.md +25 -25
  156. package/skills/worlds-getting-started/references/cli-mcp-map.md +24 -16
  157. package/skills/worlds-getting-started/references/gotchas.md +71 -7
  158. package/skills/worlds-getting-started/references/journal-checks.md +182 -0
@@ -46,7 +46,7 @@ function platformTimeoutMs(env = process.env) {
46
46
  if (Number.isInteger(value) && value > 0) return value;
47
47
  throw new Error(`${PLATFORM_TIMEOUT_ENV} must be a positive whole number of milliseconds, not \`${raw}\`.`);
48
48
  }
49
- var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
49
+ var PLATFORM_TIMEOUT_ENV, PLATFORM_TIMEOUT_DEFAULT_MS, CHECK_HOST, RETRY, FETCH_LIMIT, CAUSES, UNKNOWN_CAUSE, TransportCause, UnreachableError, sleep, RetryPolicy, Attempt, PlatformTransport;
50
50
  var init_transport = __esm({
51
51
  "src/worlds/transport.ts"() {
52
52
  "use strict";
@@ -54,7 +54,13 @@ var init_transport = __esm({
54
54
  PLATFORM_TIMEOUT_DEFAULT_MS = 12e4;
55
55
  CHECK_HOST = "Check GATEWAY_HOST (or --host) points at a running platform, then retry.";
56
56
  RETRY = "Retry; if it repeats, check the network between here and the platform.";
57
+ FETCH_LIMIT = {
58
+ reason: "Node's fetch stopped waiting after 300 s",
59
+ next: "The platform may still be running it: check what it changed before you retry."
60
+ };
57
61
  CAUSES = {
62
+ UND_ERR_HEADERS_TIMEOUT: FETCH_LIMIT,
63
+ UND_ERR_BODY_TIMEOUT: FETCH_LIMIT,
58
64
  ECONNREFUSED: { reason: "connection refused", next: CHECK_HOST },
59
65
  ENOTFOUND: { reason: "DNS lookup failed", next: CHECK_HOST },
60
66
  EAI_AGAIN: { reason: "DNS lookup failed", next: CHECK_HOST },
@@ -1061,7 +1067,7 @@ function click(button, count) {
1061
1067
  modifiers: modifierChord(raw.text)
1062
1068
  });
1063
1069
  }
1064
- var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
1070
+ var SCROLL_STEP_PX, NOT_EXECUTED, MAX_ERROR2, SCROLL_DIRECTIONS, IMAGE_PARTS, MEMBERS, AnthropicComputer, AnthropicComputer20251124;
1065
1071
  var init_anthropic = __esm({
1066
1072
  "src/worlds/nativeComputer/anthropic.ts"() {
1067
1073
  "use strict";
@@ -1077,6 +1083,14 @@ var init_anthropic = __esm({
1077
1083
  left: [-1, 0],
1078
1084
  right: [1, 0]
1079
1085
  };
1086
+ IMAGE_PARTS = {
1087
+ 6: (data) => ({ type: "image-data", data, mediaType: "image/png" }),
1088
+ 7: (data) => ({
1089
+ type: "file",
1090
+ mediaType: "image/png",
1091
+ data: { type: "data", data }
1092
+ })
1093
+ };
1080
1094
  MEMBERS = {
1081
1095
  screenshot: () => new ComputerAction("screenshot"),
1082
1096
  zoom: (raw) => new ComputerAction("zoom", {
@@ -1186,15 +1200,17 @@ var init_anthropic = __esm({
1186
1200
  ];
1187
1201
  return [{ type: "text", text: result.text ?? "OK" }];
1188
1202
  }
1189
- /** For `anthropic.tools.computerToolset_20260801({ ...computer.aiSdk() })`
1190
- * (or `computer_20251124` with the legacy kind): `execute` runs one action
1191
- * and returns `{ type: "image", data }` or text; `toModelOutput` turns that
1192
- * into the tool result. Calls run one at a time, and once a call fails the
1203
+ /** For `anthropic.tools.computerToolset_20260801(computer.aiSdk({ version: 7 }))`
1204
+ * (AI SDK 7 only), or `computer_20251124` with the legacy kind (AI SDK 6
1205
+ * and 7): `execute` runs one action and returns `{ type: "image", data }` or
1206
+ * text; `toModelOutput` turns that into the tool result in the part shape
1207
+ * of `options.version`. Calls run one at a time, and once a call fails the
1193
1208
  * rest of that step's calls answer as not executed. */
1194
- aiSdk() {
1209
+ aiSdk(options = {}) {
1210
+ const imagePart = _AnthropicComputer.imagePart(options);
1195
1211
  let failedStep;
1196
- const execute = (input, options) => this.serial(async () => {
1197
- const step = options?.messages?.length;
1212
+ const execute = (input, options2) => this.serial(async () => {
1213
+ const step = options2?.messages?.length;
1198
1214
  if (step !== void 0 && step === failedStep)
1199
1215
  throw new Error(NOT_EXECUTED);
1200
1216
  try {
@@ -1206,7 +1222,7 @@ var init_anthropic = __esm({
1206
1222
  });
1207
1223
  return {
1208
1224
  execute,
1209
- toModelOutput: ({ output }) => _AnthropicComputer.aiSdkModelOutput(output)
1225
+ toModelOutput: ({ output }) => _AnthropicComputer.modelOutput(output, imagePart)
1210
1226
  };
1211
1227
  }
1212
1228
  static aiSdkOutput(result) {
@@ -1214,16 +1230,26 @@ var init_anthropic = __esm({
1214
1230
  return { type: "image", data: result.image.toString("base64") };
1215
1231
  return result.text ?? "OK";
1216
1232
  }
1217
- /** `image-data` is what AI SDK 6's Anthropic provider turns into an image
1218
- * block; AI SDK 7 still accepts it (and converts it to a `file` part). */
1219
- static aiSdkModelOutput(output) {
1233
+ /** A screenshot as the image part of AI SDK `options.version`:
1234
+ * `image-data` for 6 (the default), `file` with `{ type: "data", data }`
1235
+ * for 7. */
1236
+ static aiSdkModelOutput(output, options = {}) {
1237
+ return _AnthropicComputer.modelOutput(
1238
+ output,
1239
+ _AnthropicComputer.imagePart(options)
1240
+ );
1241
+ }
1242
+ static imagePart({
1243
+ version = 6
1244
+ }) {
1245
+ if (Object.hasOwn(IMAGE_PARTS, version)) return IMAGE_PARTS[version];
1246
+ throw new Error(
1247
+ `unsupported AI SDK version ${version}; choose ${Object.keys(IMAGE_PARTS).join(" or ")}`
1248
+ );
1249
+ }
1250
+ static modelOutput(output, imagePart) {
1220
1251
  if (typeof output === "string") return { type: "text", value: output };
1221
- return {
1222
- type: "content",
1223
- value: [
1224
- { type: "image-data", data: output.data, mediaType: "image/png" }
1225
- ]
1226
- };
1252
+ return { type: "content", value: [imagePart(output.data)] };
1227
1253
  }
1228
1254
  envelope(block, content, isError = false) {
1229
1255
  return {
@@ -1500,17 +1526,34 @@ var init_nativeComputer = __esm({
1500
1526
  });
1501
1527
 
1502
1528
  // src/worlds/sessionContract.ts
1503
- var CALL_BODY_LIMIT_BYTES, EXPLORATORY_TASK;
1529
+ var CALL_BODY_LIMIT_BYTES, REQUEST_BODY_CAPTURE_BYTES, EXPLORATORY_TASK;
1504
1530
  var init_sessionContract = __esm({
1505
1531
  "src/worlds/sessionContract.ts"() {
1506
1532
  "use strict";
1507
1533
  CALL_BODY_LIMIT_BYTES = 4 * 1024 * 1024;
1534
+ REQUEST_BODY_CAPTURE_BYTES = 64 * 1024;
1508
1535
  EXPLORATORY_TASK = Object.freeze({
1509
1536
  instruction: "exploratory session"
1510
1537
  });
1511
1538
  }
1512
1539
  });
1513
1540
 
1541
+ // src/worlds/toolSchema.ts
1542
+ var init_toolSchema = __esm({
1543
+ "src/worlds/toolSchema.ts"() {
1544
+ "use strict";
1545
+ }
1546
+ });
1547
+
1548
+ // src/worlds/requestLedger.ts
1549
+ var init_requestLedger = __esm({
1550
+ "src/worlds/requestLedger.ts"() {
1551
+ "use strict";
1552
+ init_worlds();
1553
+ init_sessionContract();
1554
+ }
1555
+ });
1556
+
1514
1557
  // src/worlds/sessionReadiness.ts
1515
1558
  var READY_TIMEOUT_MS;
1516
1559
  var init_sessionReadiness = __esm({
@@ -1568,6 +1611,8 @@ var init_session2 = __esm({
1568
1611
  init_browser();
1569
1612
  init_nativeComputer();
1570
1613
  init_sessionContract();
1614
+ init_toolSchema();
1615
+ init_requestLedger();
1571
1616
  init_sessionReadiness();
1572
1617
  init_session();
1573
1618
  init_taskRef();
@@ -1596,6 +1641,14 @@ var init_tasks = __esm({
1596
1641
  }
1597
1642
  });
1598
1643
 
1644
+ // src/worlds/taskGrades.ts
1645
+ var init_taskGrades = __esm({
1646
+ "src/worlds/taskGrades.ts"() {
1647
+ "use strict";
1648
+ init_worlds();
1649
+ }
1650
+ });
1651
+
1599
1652
  // src/worlds/surfaceDescriptor.ts
1600
1653
  var init_surfaceDescriptor = __esm({
1601
1654
  "src/worlds/surfaceDescriptor.ts"() {
@@ -1718,6 +1771,15 @@ var init_setRun = __esm({
1718
1771
  var init_requestLog = __esm({
1719
1772
  "src/worlds/requestLog.ts"() {
1720
1773
  "use strict";
1774
+ init_requestLedger();
1775
+ }
1776
+ });
1777
+
1778
+ // src/worlds/webhooks.ts
1779
+ var init_webhooks = __esm({
1780
+ "src/worlds/webhooks.ts"() {
1781
+ "use strict";
1782
+ init_worlds();
1721
1783
  }
1722
1784
  });
1723
1785
 
@@ -1781,10 +1843,14 @@ var init_validate = __esm({
1781
1843
  });
1782
1844
 
1783
1845
  // src/worlds/sandbox.ts
1846
+ import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
1847
+ var SANDBOX_WRITE_CHUNK_BYTES, SANDBOX_FILE_MAX_BYTES;
1784
1848
  var init_sandbox = __esm({
1785
1849
  "src/worlds/sandbox.ts"() {
1786
1850
  "use strict";
1787
1851
  init_worlds();
1852
+ SANDBOX_WRITE_CHUNK_BYTES = 4 * 1024 * 1024;
1853
+ SANDBOX_FILE_MAX_BYTES = 256 * 1024 * 1024;
1788
1854
  }
1789
1855
  });
1790
1856
 
@@ -1805,7 +1871,7 @@ var init_json = __esm({
1805
1871
  });
1806
1872
 
1807
1873
  // src/worlds/transforms.ts
1808
- import { createHash as createHash4 } from "crypto";
1874
+ import { createHash as createHash5 } from "crypto";
1809
1875
  var WHITESPACE, WHITESPACE_EDGES, WHITESPACE_RUN, NOT_DIGIT, STRIP_PREFIX, trim, emailLocalPart, emailDomain, hex, SIMPLE, TRANSFORMS;
1810
1876
  var init_transforms = __esm({
1811
1877
  "src/worlds/transforms.ts"() {
@@ -1825,7 +1891,7 @@ var init_transforms = __esm({
1825
1891
  const at = value.lastIndexOf("@");
1826
1892
  return at === -1 ? "" : value.slice(at + 1).toLowerCase();
1827
1893
  };
1828
- hex = (algorithm, value) => createHash4(algorithm).update(value, "utf8").digest("hex");
1894
+ hex = (algorithm, value) => createHash5(algorithm).update(value, "utf8").digest("hex");
1829
1895
  SIMPLE = {
1830
1896
  lower: (value) => value.toLowerCase(),
1831
1897
  upper: (value) => value.toUpperCase(),
@@ -1845,7 +1911,7 @@ var init_transforms = __esm({
1845
1911
  });
1846
1912
 
1847
1913
  // src/worlds/redaction.ts
1848
- import { createHash as createHash5 } from "crypto";
1914
+ import { createHash as createHash6 } from "crypto";
1849
1915
  var init_redaction = __esm({
1850
1916
  "src/worlds/redaction.ts"() {
1851
1917
  "use strict";
@@ -1899,31 +1965,45 @@ var init_dryRun = __esm({
1899
1965
  });
1900
1966
 
1901
1967
  // src/worlds/index.ts
1902
- function parseErrorBody(text, limit = 600) {
1903
- const raw = { detail: text.slice(0, limit), code: null };
1968
+ function edgeAnswer(text, status) {
1969
+ if (status !== void 0 && status >= 500) return EDGE_ANSWERS[status] ?? EDGE_FAILURE;
1970
+ return /^\s*</.test(text) ? EDGE_PAGE : null;
1971
+ }
1972
+ function parseErrorBody(text, status) {
1973
+ const raw = { detail: text.slice(0, DETAIL_LIMIT), code: null };
1904
1974
  let parsed;
1905
1975
  try {
1906
1976
  parsed = JSON.parse(text);
1907
1977
  } catch {
1908
- return raw;
1978
+ return { detail: (edgeAnswer(text, status) ?? text).slice(0, DETAIL_LIMIT), code: null };
1909
1979
  }
1910
1980
  if (parsed === null || typeof parsed !== "object") return raw;
1911
- const { message, code } = parsed;
1981
+ const { message, code, error } = parsed;
1912
1982
  const stableCode = typeof code === "string" ? code : null;
1913
1983
  if (typeof message !== "string") return { ...raw, code: stableCode };
1914
- if (stableCode === null)
1915
- return { detail: message.slice(0, limit), code: null };
1984
+ const fields = invalidFields(error);
1985
+ const said = fields ? `${message}: ${fields}` : message;
1986
+ if (stableCode === null) return { detail: said.slice(0, DETAIL_LIMIT), code: null };
1916
1987
  return {
1917
- detail: `${message} (${stableCode})`.slice(0, limit),
1988
+ detail: `${said} (${stableCode})`.slice(0, DETAIL_LIMIT),
1918
1989
  code: stableCode
1919
1990
  };
1920
1991
  }
1992
+ function invalidFields(error) {
1993
+ const issues = Array.isArray(error) ? error : [];
1994
+ return issues.filter(
1995
+ (issue) => issue !== null && typeof issue === "object" && typeof issue.message === "string"
1996
+ ).map((issue) => {
1997
+ const path8 = Array.isArray(issue.path) ? issue.path.map(String).join(".") : "";
1998
+ return path8 ? `${path8}: ${issue.message}` : issue.message;
1999
+ }).join("; ");
2000
+ }
1921
2001
  async function apiRequest(options, method, path8, body, init = {}) {
1922
2002
  const reply = await new PlatformTransport(requirePlatformEndpoint(options)).send(method, path8, body, init);
1923
2003
  if (!reply.ok) throw new ApiError(reply.status, method, path8, reply.text);
1924
2004
  return JSON.parse(reply.text);
1925
2005
  }
1926
- var ApiError;
2006
+ var ApiError, DETAIL_LIMIT, EDGE_ANSWERS, EDGE_FAILURE, EDGE_PAGE;
1927
2007
  var init_worlds = __esm({
1928
2008
  "src/worlds/index.ts"() {
1929
2009
  "use strict";
@@ -1936,6 +2016,7 @@ var init_worlds = __esm({
1936
2016
  init_sessionContract();
1937
2017
  init_taskRef();
1938
2018
  init_tasks();
2019
+ init_taskGrades();
1939
2020
  init_taskSessions();
1940
2021
  init_taskRun();
1941
2022
  init_setRun();
@@ -1944,6 +2025,8 @@ var init_worlds = __esm({
1944
2025
  init_browser();
1945
2026
  init_surfaceDescriptor();
1946
2027
  init_requestLog();
2028
+ init_requestLedger();
2029
+ init_webhooks();
1947
2030
  init_browserReconnect();
1948
2031
  init_nativeComputer();
1949
2032
  init_hub();
@@ -1960,7 +2043,7 @@ var init_worlds = __esm({
1960
2043
  init_worldNotice();
1961
2044
  ApiError = class extends Error {
1962
2045
  constructor(status, method, path8, text) {
1963
- const parsed = parseErrorBody(text);
2046
+ const parsed = parseErrorBody(text, status);
1964
2047
  super(`${method} ${path8} -> ${status}: ${parsed.detail}`);
1965
2048
  this.status = status;
1966
2049
  this.text = text;
@@ -1971,6 +2054,14 @@ var init_worlds = __esm({
1971
2054
  text;
1972
2055
  code;
1973
2056
  };
2057
+ DETAIL_LIMIT = 600;
2058
+ EDGE_ANSWERS = {
2059
+ 502: "Bad Gateway from the load balancer in front of the platform, not the platform's answer: the web server dropped the connection or restarted mid-request. Retry; if it repeats, the platform is restarting or overloaded.",
2060
+ 503: "Service Unavailable from the load balancer in front of the platform, not the platform's answer: no web server was ready to take the request (a deploy or a restart). Retry in a minute.",
2061
+ 504: "Gateway Time-out from the load balancer in front of the platform, not the platform's answer: the request sent nothing back within the load balancer's idle timeout (60 s unless the deployment raises it: Helm ingress.idleTimeoutSeconds) and was cut there, though the platform may still be running it. Check what it changed before you retry."
2062
+ };
2063
+ EDGE_FAILURE = "The platform failed without its JSON error body: a proxy in front of it answered, or the server stopped before its error handler ran. Retry; if it repeats, report the request and the time.";
2064
+ EDGE_PAGE = "An HTML page answered instead of the platform's JSON: a proxy in front of the platform, or the configured host is not the platform.";
1974
2065
  }
1975
2066
  });
1976
2067