@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
@@ -53,10 +53,9 @@ A CSV/TSV is decided by its name and read as a stream (bounded memory at any siz
53
53
  `--delimiter <char>` splits the cells (one character, `\t` for a tab; default `,`, tab for a
54
54
  `.tsv`). The header row names the fields and **every cell is cast by the entity's schema
55
55
  type**: `integer`/`number` parse as numbers, `boolean` takes true/false/1/0, `array`/`object`
56
- parse as JSON, `string` stays text; an empty cell is null when the field admits null, left out
57
- when optional, refused when required. A cell that does not fit is a row-level refusal naming
58
- the field and the cell (`/taxi_trip/3: fare = "n/a" is not a number`). Same rule in both CLIs,
59
- pinned by `tests/conformance/csv_cast.json`. Without `--entity` a CSV is refused.
56
+ parse as JSON, `string` stays text; an empty cell is null when the field admits null, `""` for a required string, left out otherwise. A cell that does not fit stays text and the contract refuses its row as it refuses a JSON row:
57
+ every bad row named by entity, key and field (`taxi_trip {"id":3}.fare: Expected number`), all counted, each in `--report`.
58
+ Same rule in both CLIs, pinned by `tests/conformance/csv_cast.json`. Without `--entity` a CSV is refused.
60
59
 
61
60
  Rules:
62
61
 
@@ -110,7 +109,7 @@ gateway worlds data query <WORLD> users --where email=jo@acme.test --resolve #
110
109
  gateway worlds data sql <WORLD> 'SELECT id, name FROM users LIMIT 5' # read-only SQL, any engine
111
110
  ```
112
111
 
113
- `data sql` runs ONE read-only statement (joins, `GROUP BY`, counts) over a schema world's entity tables,
112
+ `data sql` runs ONE read-only statement (joins, `GROUP BY`, counts) over a schema world's entity tables (and `json_each` / `json_tree` over their JSON),
114
113
  whatever its database engine: a write, `ATTACH`, `PRAGMA` or a second statement is refused; at most 1000 rows
115
114
  (`--limit`). MCP twin: `sql_world_data({ slug, sql, limit? })`. A db/schema.sql world is a SQLite file: `sqlite3`.
116
115
 
@@ -156,10 +155,10 @@ JSONL chunks of `--chunk-bytes` (64 MiB default) or `--chunk-rows N`, uploads th
156
155
  `--parallel 4` at a time straight to the bucket, and completes the batch; the platform
157
156
  validates every row against the contract, applies the batch onto the world's data snapshot
158
157
  and, with `--publish now` (default), cuts a data-only version (no image rebuild) on your open edit session
159
- (`editSessionId`; only your credential reads it as `main` until `worlds edit close <slug>` or 60 idle minutes seal it). `--wait`
158
+ (`editSessionId`; only your credential's unpinned reads see it, and `slug@main`, runs and tasks keep the sealed `main`, until `worlds edit close <slug>` or 60 idle minutes seal it). `--wait`
160
159
  (default) polls to the end and prints the batch: `{batchId, state, rows, refusalCount,
161
160
  refusals[:200], entityCounts, versionId?, batchDigest?}`. `--no-wait` prints `{batchId,
162
- state}` and `gateway worlds data status <batchId>` reads it later. Exit codes: 0 applied or
161
+ state}` and `gateway worlds data status <batchId> [--report <file>]` reads it later. Exit codes: 0 applied or
163
162
  published, 2 refused (the report is written when `--report` is given: JSONL of refusal
164
163
  records, at most 10,000 then `{"truncated": true, "total": N}`), 1 error.
165
164
 
@@ -221,13 +220,11 @@ policy (`drop`, `hash` as `sha256:<hex>` of `<slug>:<value>`, `preserve` as a sa
221
220
  same-character-class hash for identifiers, `round`) unless `--no-redact`. Output is tagged
222
221
  JSONL; the summary `{"read", "rows", "unknownFields", "redacted"}` is on stderr.
223
222
 
224
- Platform agent (console): the same `import_world_data`, plus `sandboxPath` for a rows file
225
- already in the sandbox (any ROWS form above; `entity` for bare arrays/JSONL) instead of
226
- `rows` — build the file with code, then import; do not paste 4 MiB through `rows`.
227
- `run_gateway_cli({ command: "data show" | "data check" | "data import" | "data extract", args: ["/workspace/<world>", ...] })`
228
- is the local-directory form for a world you `load_world_to_sandbox`ed (same flags as above, no remote
229
- slugs); land the result with `ingest_to_world`. Capture pages are not rows: `get_connector_capture(downloadTo)` →
230
- `run_gateway_cli connector ingest` → `ingest_to_world`.
223
+ Platform agent (console): the same CLI, through `run_gateway_cli` in its sandbox. Build the rows
224
+ file with code, then `run_gateway_cli({ command: "data import", args: ["<slug>", "./rows.jsonl", "--dry-run"] })`
225
+ and again without `--dry-run`; a slug reaches the platform as the user, a `./dir` stays in the
226
+ sandbox. Capture pages are not rows: `get_connector_capture(downloadTo)` →
227
+ `run_gateway_cli connector ingest ./<world>` → `push ./<world>`.
231
228
 
232
229
  ### 2c. Turn tool calls into rows: pull, transform, ingest
233
230
 
@@ -285,7 +282,7 @@ what nests, what a write's `args` become, which call wins — in code you read t
285
282
  write. The worked CRM example (nested contacts/deals exploded out of an account read, a
286
283
  deal's nested account lifted, activity rows from `crm_log_activity` args keyed by the
287
284
  observation id, a deletion turned into an event row, latest call wins) is on
288
- `gateway_documentation/pages/worlds/data.mdx` in both languages; the fixtures live in
285
+ https://docs.surfacearea.ai/worlds/data in both languages; the fixtures live in
289
286
  `gatewaysdk/sdk/tests/environment/fixtures/crm/` (`records.jsonl`, `transform.py`,
290
287
  `transform.ts`, `ingest.toml`, `rows.json`).
291
288
 
@@ -363,13 +360,13 @@ operations route by name; `captureToolCalls(tools, sink)` records the calls). Py
363
360
  redact="off", dry_run=False)` and `ingest_tool_calls`; `capture_tool_calls`. Bridge:
364
361
  `ingest-calls {files, records, map?, redact?, dry_run?, mode?}` → the report + `projected`
365
362
  rows (+ `files` when the tree changed); transforms never run in the bridge. No MCP twin yet;
366
- the console agent has `run_gateway_cli data ingest` on a sandboxed directory.
363
+ the console agent runs the same `data ingest` through `run_gateway_cli`.
367
364
 
368
365
  ### 2d. Rows generated or downloaded inside a sandbox
369
366
 
370
367
  ```bash
371
368
  gateway worlds sandbox exec <id> 'curl -sSL https://example.test/trips.csv -o data/trips.csv' # or a script that writes rows
372
- gateway worlds sandbox import <id> data/trips.csv --entity taxi_trip [--delimiter ...] [--mode append|replace] [--dry-run]
369
+ gateway worlds sandbox import <id> data/trips.csv --entity taxi_trip [--delimiter ...] [--mode append|replace] [--dry-run] [--report refusals.jsonl]
373
370
  gateway worlds sandbox commit <id> -m "tools" # the SOURCE tree only; rows are not in a commit
374
371
  ```
375
372
 
@@ -378,8 +375,9 @@ sandbox (`POST /api/public/benchmark-containers/sandboxes/{id}/import`; the sand
378
375
  chunks it to JSONL in a scratch dir the platform reads and removes) and streams it through the
379
376
  same ledger as `data import <slug>`: contract, refusals with pointers, `--mode`, `--merge`,
380
377
  `--redact`, `--per-chunk`, `-m`. Prints `{versionId, entityCounts, rowCount}`, or `{batchId,
381
- state}` to poll with `data status`. A new-world sandbox commits once first. MCP:
382
- `import_world_sandbox_data({ sandboxId, path, entity?, mode? })`. `commit` never carries rows.
378
+ state}` to poll with `data status`. Refused rows exit 2: `{batchId, state: refused, refusalCount, refusals}` (all counted,
379
+ the first 200 inline); `--report` writes every refusal as JSONL, a `--per-chunk` import's and a polled batch's too. MCP:
380
+ `import_world_sandbox_data({ sandboxId, path, entity?, mode? })`. A new-world sandbox commits once first; `commit` never carries rows.
383
381
 
384
382
  ### 3. Verify on a live session
385
383
 
@@ -390,7 +388,7 @@ gateway worlds session open <slug> -t <scenario> --surface api # prints s
390
388
  gateway worlds session seed <SESSION_ID> rows.json # kind:"seed" call, waits for the result
391
389
  gateway worlds session seed <SESSION_ID> rows.json --redact refuse # same, refusing plaintext in a redacted field (apply hashes it first)
392
390
  gateway worlds session seed <SESSION_ID> rows.json --mode replace # swap the named entities
393
- curl -H "Authorization: Bearer $API_TOKEN" "$API_URL/<route>" # read it back (api.token from session open)
391
+ curl -H "X-World-Session: $API_TOKEN" "$API_URL/<route>" # read it back (api.token from session open)
394
392
  ```
395
393
 
396
394
  Prints `{sessionId, mode, result}`. MCP: `seed_world_session({ sessionId, rows, mode? })` waits
@@ -457,7 +455,7 @@ Sanitize before importing: hash or drop personal fields the world's `[redact]` p
457
455
  | refused, kind `api` (or `harbor`), naming the file to edit | the world is a generated bundle or a task suite | edit the named source, `bench push` again |
458
456
  | `version` missing from the result | a local directory was given | push with `gateway bench push <dir>` when ready |
459
457
  | `... is over what a world's source tree carries as data (4 MiB / 100000 rows ...)`; `data/initial.json would be N MiB with these rows, over the 4 MiB publication reads a source file whole`; `exceed the inline cap ... without the bundled runtime` | a directory import above the tree cap; or no `python3`, so the rows travel whole (5,000 / 4 MiB) | `worlds sandbox import` from a sandbox, `data import <slug>` with keys (never keys into the sandbox); install python3 |
460
- | `/<entity>/<i>: <field> = "<cell>" is not a number` (integer, boolean, array, object) | a CSV cell the field's schema type does not fit | fix the cell or the header; nothing was written |
458
+ | `<entity> {"<key>":…}.<field>: Expected number` (integer, boolean, array, object) on a CSV row | a cell the field's schema type does not fit: it stays text and the contract refuses its row | fix the cell or the header; `--report` lists every row; nothing was written |
461
459
  | exit 2, `state: refused` | the platform refused the batch; `--report` has every record | fix the rows named, `--resume` is not for this: run the import again |
462
460
  | `nothing to resume` / `only an open or uploading batch resumes` | no incomplete manifest, or the batch already ran | run the import without `--resume` |
463
461
  | `409 base_mismatch` from `/__world/seed` | the overlay named another snapshot digest than the pod is on | the runner posts the digest of the version's snapshot; a mismatch is a version mismatch, never reseed silently |
@@ -497,4 +495,4 @@ handler or route edit keeps the imported data while an entity, field or key edit
497
495
  - `connector-schema-authoring`: the data model the rows are checked against.
498
496
  - `documentation/features/world-data-ingestion.md`: what exists, the contract, code pointers.
499
497
  - `documentation/features/connector-worlds.md`: captures, ingest, serving the vendor's API.
500
- - Consumer page: `gateway_documentation/pages/worlds/data.mdx`.
498
+ - Consumer page: https://docs.surfacearea.ai/worlds/data.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: worlds-getting-started
3
- description: Starter guide for building worlds and environments on the platform, end to end, for an agent (Claude Code, Cursor, Codex). Use when starting a world from scratch, building a world or environment, mocking a vendor, importing a Swagger or OpenAPI spec into a world (schema init --from-openapi), choosing between a shipped template, a workspace connector, an OpenAPI document, a vendor API capture or a custom contract, provisioning worlds for tenants in one call (worlds create), publishing with bench push, opening a session, running and grading, or iterating with pull, fork, diff and edit sessions (worlds edit status/close/rollback: version control without PRs). Every CLI step names its MCP twin (list_connectors, publish_connector, create_world, init_world_from_connector, env_write_file, env_commit, import_world_data, run_evaluation and the rest) and where the result shows in the UI.
3
+ description: Starter guide for building worlds and environments on the platform, end to end, for an agent (Claude Code, Cursor, Codex). Use when starting a world from scratch, building a world or environment, mocking a vendor, importing a Swagger or OpenAPI spec into a world (schema init --from-openapi), choosing between a shipped template, a workspace connector, an OpenAPI document, a vendor API capture or a custom contract, provisioning worlds for tenants in one call (worlds create), publishing with bench push, opening a session, reading every request a world received (worlds requests), checks over those requests (journal checks on gateway_requests, calls, verify.py, SQL verifiers; task try before you save, task regrade of past runs), running and grading, or iterating with pull, fork, diff and edit sessions (worlds edit status/close/rollback: version control without PRs). Every CLI step names its MCP twin (list_connectors, publish_connector, create_world, init_world_from_connector, env_write_file, env_commit, import_world_data, run_evaluation and the rest) and where the result shows in the UI.
4
4
  ---
5
5
 
6
6
  # Worlds: getting started
@@ -17,7 +17,7 @@ The shortest correct path from nothing to a hosted world with data, a session, a
17
17
  CLI first; the MCP twin sits under each step for an agent that talks to the platform over MCP instead of a shell.
18
18
  Deeper references are linked by path, not repeated.
19
19
 
20
- Vocabulary (from `gateway_documentation/pages/glossary.mdx`): **world** (the sealed replica), **scenario** (a task in
20
+ Vocabulary (from https://docs.surfacearea.ai/glossary): **world** (the sealed replica), **scenario** (a task in
21
21
  it), **rollout** (one attempt), **run** (a filed set of rollouts), **eval** (the grade), **gate** (the bar).
22
22
  Identifiers keep the old words: `environment`, `container`, `task set`, `bench`.
23
23
 
@@ -155,7 +155,7 @@ environment; land them with `env_commit({ containerId, changeReason })` (one ver
155
155
  Tool handlers (`tools/*.py`) reach the world's rows through `from gateway_env import store`. It has
156
156
  exactly these methods; `gateway worlds schema check .` refuses any other `store.<name>` at file:line
157
157
  with this list, and a hosted call into such a handler answers 400 `{error: "handler", detail, handler}`
158
- (an `AttributeError`/`TypeError`/`NameError` is the author's bug; anything else a handler raises is a
158
+ (an `AttributeError`/`TypeError`/`NameError` is the author's bug; `raise Refusal(404, body)` (imported from `gateway_env` at module top) answers that 4xx and body; anything else a handler raises is a
159
159
  500 `{error: "engine", detail, handler}`; never a bare exception string).
160
160
 
161
161
  - `get(entity: str, key: dict) -> dict | None` — one row by primary key, or `None`.
@@ -192,7 +192,7 @@ gateway worlds describe ./x # entities, keys, re
192
192
  gateway worlds data show ./x # kind + entity counts
193
193
  gateway worlds data query ./x users --where email=jo@acme.test --resolve # the rows you mean; plaintext into a hashed field
194
194
  gateway worlds data import ./x rows.json # rows file: {entity: [rows]} | JSONL | .csv/.tsv --entity (cells cast by the schema; --delimiter)
195
- gateway files fetch https://example.test/rows.csv --to imports/rows.csv --header "Authorization: Bearer {{secret:API_KEY}}" # the platform fetches; the secret never leaves it
195
+ gateway files fetch https://example.test/rows.csv --to imports/rows.csv --header "Authorization: Bearer {{secret:API_KEY}}" # the platform fetches; the secret goes only to origins it lists (gateway secret origins API_KEY https://example.test)
196
196
  gateway worlds connector capture ./x --op <name> --arg k=v # from the real vendor, redacted
197
197
  gateway worlds connector ingest ./x # captures -> data/initial.json; `--dry-run --report` checks only, nothing written
198
198
  gateway worlds data calls pull calls.jsonl --from traces --session <id> # an agent's real calls, raw; prints records per tool + result shapes
@@ -220,8 +220,7 @@ gateway worlds connector publish ./x --slug x -m "first cut" # the template as
220
220
 
221
221
  `bench push` makes the version sessions and runs address (`slug@version`). `connector publish` saves the contract
222
222
  (never `data/`, `captures/`, `db/`) so anyone in the org can `schema init --connector workspace:x`. The world's
223
- `tests/`, `tasks.json`, `verifiers/` and `openapi/` travel with the connector into every world initialized from it
224
- (they used to be left behind, so the new world had no suite to run). Both, for a world you expect to rebuild.
223
+ `tests/`, `tasks.json`, `verifiers/` and `openapi/` travel with the connector into every world initialized from it. Both, for a world you expect to rebuild.
225
224
 
226
225
  MCP: `publish_connector({ slug, files, message? })` is the template write path. `init_world_from_connector({ slug, name })`
227
226
  makes the world under a PAT session; under an API key it returns the initialized files plus the publish steps
@@ -319,9 +318,10 @@ gateway worlds session open x --task-file task.json --surface api # the sessio
319
318
  gateway worlds session status <SESSION_ID> # poll until ready
320
319
  gateway worlds session seed <SESSION_ID> rows.json # rows into this session only
321
320
  gateway worlds session state <SESSION_ID> # every entity's rows, the dump a grader reads
322
- gateway worlds session reset <SESSION_ID> # back to the snapshot (+ the task's seed)
321
+ gateway worlds session reset <SESSION_ID> # back to the snapshot (+ the task's seed); `session restart <SESSION_ID> [--version <pin>]` does it on what its pin (x@ref; unpinned = newest you may read) points to NOW, same id, URLs + token, running or closed; a grade then reads only the requests after its session.restart ledger entry
323
322
  gateway worlds session grade <SESSION_ID> [--timeout S] # {reward, rewards, raw}; exploratory → {reward: null, reason: "no grader"}
324
- gateway worlds session export <SESSION_ID> --out calls.jsonl [--requests] # the platform's ledger; --requests (live session, one state call) adds the world's own request log, kind "request" with via
323
+ gateway worlds session export <SESSION_ID> --out calls.jsonl [--requests] # the platform's ledger; --requests adds the session's entries from the world's request ledger (kind "request": via, status, sizes; bodies by result.requestId), live or closed
324
+ gateway worlds requests x [--session <SESSION_ID>] [--via api|ui|tool|webhook] [--status 4xx] [--since 2026-10-05] [--json] # every request the world received (every session, version and door), newest first, kept for its life; reading records nothing; `requests show x <REQUEST_ID> [--out f]` adds headers + bodies, `session requests <SESSION_ID>` lists one session's (exit 3: its engine records no requests, only World Host sessions do)
325
325
  gateway worlds data ingest x calls.jsonl --transform shape.py # the calls back in as rows, shaped by your code or --map ingest.toml (world-data-ingestion §2c)
326
326
  gateway worlds session close <SESSION_ID> # a closed session reopens by id, same URLs + token, from its last checkpoint: gateway worlds session reopen <SESSION_ID>
327
327
  ```
@@ -344,7 +344,7 @@ verifiers) is refused `world_kind_retired`; one on an api bundle opens and lists
344
344
  `instruction` is what the agent is told; `seed` (`{mode?, rows}`, the live-seed contract) is laid on the clone and re-applied by `reset`;
345
345
  `grader` is `assertions` (`entity`, `where`, `exists|absent|count|all|any`, `field op value`; each check's `id` becomes a `rewards` key;
346
346
  `entity: "calls"` reads the call log — `operation`, `args`, `selectors`, `status`, `rows`, `found`, and `via`: `ui` from the page's `api_path`,
347
- `api` from the api origin, `tool` for a declared tool's call; a credential-named or secret-shaped field reads `[redacted]`; `rows`/`found` are null where the answer declares no rows, a request too large to keep names what it lacks in `withheld`, and a check grades whenever the calls it can read decide it, ungraded only where those could change the result), `{kind: "python", source, timeoutSeconds?}` (a `verify.py` body; it reads the state as JSON on stdin — `{"<entity>": {"<primary key>": row}, "calls": [...], "report": "<the agent's report>"}`, a verifier's entities as `<alias>.<entity>` — and prints ONE flat JSON object as the last line of stdout, `reward` plus a number from 0 to 1 per check — `true`/`false` read as 1/0, `null` or a string as ungraded, no `reward` leaves the task ungraded, and a nested object or array (a `rewards` map included), a number outside 0..1 or NaN/Infinity fails the grade by key and value; it must exit 0 within `timeoutSeconds`, default and most 30, or the grade fails with the reason) or `{kind: "rubric", rubric, criteria?, model?}`
347
+ `api` from the api origin, `tool` for a declared tool's call; a credential-named or secret-shaped field reads `[redacted]`; `rows`/`found` are null where the answer declares no rows, a request too large to keep names what it lacks in `withheld`, and a check grades whenever the calls it can read decide it, ungraded only where those could change the result; on a World Host session `calls` is read from the session's journal, every door and no bound, and `entity: "gateway_requests"` matches every request its world received — `operation`, `method`, `path`, `query.<k>`, `response.status`, `request.body.<path>`, `response.body.<path>`, with `before`/`after` to order them — failing closed, with the reason, where a journal missing requests cannot decide a check: `references/journal-checks.md`), `{kind: "python", source, timeoutSeconds?, readsJournal?, acceptsIncompleteJournal?}` (a `verify.py` body; it reads the state as JSON on stdin — `{"<entity>": {"<primary key>": row}, "calls": [...], "report": "<the agent's report>"}`, a verifier's entities as `<alias>.<entity>` — and prints ONE flat JSON object as the last line of stdout, `reward` plus a number from 0 to 1 per check — `true`/`false` read as 1/0, `null` or a string as ungraded, no `reward` leaves the task ungraded, and a nested object or array (a `rewards` map included), a number outside 0..1 or NaN/Infinity fails the grade by key and value; it must exit 0 within `timeoutSeconds`, default and most 30, or the grade fails with the reason) or `{kind: "rubric", rubric, criteria?, model?}`
348
348
  (an LLM judge over end state + call log, graded on the platform: `grade` answers pending until
349
349
  the worker finalizes it); `tools: [names]` narrows the operations the session may call to
350
350
  exactly those (a name the world does not serve is a 400); `metadata` rides the session. At most one of
@@ -366,21 +366,20 @@ gateway worlds task update <TASK_ID> --spec task2.json # a changed spec is
366
366
  gateway worlds session open x --task-id <TASK_ID> [--task-version 1] --surface api
367
367
  gateway worlds session task save <SESSION_ID> --name acme-q3 # promote a session's inline task into a stored one
368
368
  gateway worlds task delete <TASK_ID>
369
+ gateway worlds task try task.json --session <SESSION_ID> # a spec (or <TASK_ID>) graded on a stored World Host session, each check with the requests it matched; saves nothing
370
+ gateway worlds task regrade <TASK_ID> [--run <EVAL_ID>|--all-runs|--session <ID>] [--version N] # past runs graded again in place, no agent; default the latest run
369
371
  ```
370
372
 
371
- SDK: `createTask / listTasks / getTask / updateTask / validateTask / deleteTask`,
372
- `openSession(slug, { task: { id, version? } })`, `session.saveTask(name)` (TS);
373
- `create_task` … `delete_task`, `open_session(slug, {"id": …})`, `session.save_task(name)`
374
- (Python). MCP: `create_world_task`, `update_world_task`, `list_world_tasks`, `get_world_task`,
375
- `validate_world_task`, `delete_world_task`, `save_world_session_task`. The world's Scenarios
376
- tab lists the tasks pinned to it under a `world` kind chip.
373
+ SDK: `createTask / listTasks / getTask / updateTask / validateTask / deleteTask`, `openSession(slug, { task: { id, version? } })`, `session.saveTask(name)`, `new TaskGrades().try / regrade` (TS);
374
+ `create_task` … `delete_task`, `open_session(slug, {"id": …})`, `session.save_task(name)`, `TaskGrades().try_task / regrade` (Python). MCP: `create_world_task`, `update_world_task`, `list_world_tasks`, `get_world_task`,
375
+ `validate_world_task`, `delete_world_task`, `save_world_session_task`, `try_world_task`, `regrade_world_task`. The world's Scenarios tab lists the tasks pinned to it under a `world` kind chip.
377
376
 
378
377
  **Stored tasks as a hosted eval.** A run config dispatches EITHER the bundle's scenarios
379
378
  (`--tasks`) OR stored tasks (`--world-tasks`), never both:
380
379
 
381
380
  ```bash
382
381
  gateway bench run-configs create --name nightly --models openai/gpt-5-mini --world-tasks <TASK_ID>,<OTHER_ID>@2
383
- gateway bench dispatch <RUN_CONFIG_ID> # each stored task is a sample; rubric tasks are refused at dispatch
382
+ gateway bench dispatch <RUN_CONFIG_ID> # each stored task is a sample; rubric tasks and tasks whose checks read calls or requests are refused at dispatch
384
383
  ```
385
384
 
386
385
  `<id>` runs the task's current version at dispatch time, `<id>@N` that version forever. SDK:
@@ -395,10 +394,10 @@ answers 503. That is a cold start, not a fault, until about twenty minutes have
395
394
  `status` print `idleExpiresAt` (null once pinned) + `pinned`; `status` warns under 5 minutes. A call
396
395
  body over 4mb is refused client-side: `{status: "error", code: "payload_too_large"}`, exit 2.
397
396
 
398
- The world's API honours the vendor's auth scheme and accepts the session's own api token (bearer or
399
- the vendor's header); `worlds serve` accepts the `--api-key` pin (default `conform`).
397
+ The world's API mirrors the vendor's auth as `[auth]` declares it: the session's api token after an `Authorization` word the vendor takes, in its header, as its Basic user or password, its query key, a token the world's `[auth.login]` minted, or an
398
+ `[auth.downloads]` link; your own tooling sends it in `X-World-Session` (the SDKs' `apiHeaders`) or as a bearer, on every world. No auth for an eval: `session open --auth open` (or `mode = "open"` under `[auth]`) prints `api.auth: open` and a capability URL that needs no credential. `worlds serve` takes the `--api-key` pin (default `conform`) the vendor's ways alone (connector-worlds.md, "The door").
400
399
 
401
- MCP: `seed_world_session`, `export_world_session`, `save_world_session_task`; open/call/close are CLI or REST only.
400
+ MCP: `seed_world_session`, `export_world_session`, `save_world_session_task`, `list_world_requests`, `get_world_request`; open/call/close are CLI or REST only.
402
401
  Find what you opened: `gateway worlds session list` (every state; the live ones are `--state RUNNING` and `--state IDLE`) / `sandbox list`; `session pin <id>` stops the reaper.
403
402
 
404
403
  ## Test the world (not the agent)
@@ -433,7 +432,7 @@ gateway worlds call http://localhost:8080 slack.list_channels --args '{...}' --c
433
432
  `GET /__session/{task,tools,state}`, `POST /__session/{call,grade,reset,seed,close}`; `--task` and
434
433
  `--scenario` belong to `serve`. A directory target (`worlds call ./x <tool>`) opens and closes its
435
434
  own session per call. A HOSTED session is not a served url (the World Host serves no `/__session/*`;
436
- its `api.url` takes the session's bearer): act on it by id, `gateway worlds call <sessionId> <tool> --state --grade --close`.
435
+ its `api.url` takes the session's token): act on it by id, `gateway worlds call <sessionId> <tool> --state --grade --close`.
437
436
 
438
437
  ## 7. Run and grade
439
438
 
@@ -463,18 +462,18 @@ MCP: `run_evaluation({ models | runConfigId, versionId?, numExamples?, rolloutsP
463
462
  ```bash
464
463
  gateway bench pull x # reconstruct the head version's tree; `bench status ./x` = branch, base, local edits
465
464
  gateway bench fork x --into x-experiment # a new container sharing content; `bench diff <base> <head>` per-file, `bench log x` versions
466
- gateway worlds edit status x # your open EDIT SESSION: every push / sandbox commit / data import after the first version lands there; only this credential reads it as main
465
+ gateway worlds edit status x # your open EDIT SESSION: every push / sandbox commit / data import after the first version lands there; only your unpinned reads see it (no @ref: describe x, session open x, pull x, test x); x@main, version pins, runs and tasks get SEALED versions only
467
466
  gateway worlds edit close x -m "why" # seal it: main moves to the session's tip for everyone; each version stays in `log`, `edit rollback` undoes the whole session (60 idle minutes seal it too). `edit list x` = history, `edit discard x` drops it unseen
468
467
  gateway worlds edit rollback x <sessionId> # undo a sealed session (source + data together) as a new sealed session; --force when later sessions would go too
469
- gateway worlds task edit close <task> -m "why" # a change across a TASK's worlds: seal them all in ONE step or none (`task edit status <task>` first: your unsealed worlds, only you see them; `task edit rollback <task> --group <groupId>` undoes the group)
470
- gateway worlds sandbox open x@main # no local checkout: write|exec|check|commit|close <id> edit the tree server-side; `bench sandbox` is the same set
468
+ gateway worlds task edit close <task> -m "why" # a change across a TASK's worlds: seal them all in ONE step or none (`task edit status <task>` first: your unsealed worlds, which every `task up` and run skips until sealed; `task edit rollback <task> --group <groupId>` undoes the group)
469
+ gateway worlds sandbox open x # no local checkout (no @ref: your open edit's tip, else main; x@main is the sealed main): write|exec|check|commit|close <id> edit the tree server-side; `bench sandbox` is the same set
471
470
  gateway worlds sandbox exec <id> 'gateway worlds schema entity add . tickets --fields id:string,title:string -k id && gateway worlds schema compile . && gateway worlds data import . rows.json && gateway worlds schema check . && gateway worlds test .'
472
471
  gateway worlds sandbox open --new y --from custom # a world that does not exist yet (no base); its first `commit` creates it — references/new-world-sandbox.md
473
472
  gateway worlds sandbox import <id> data/trips.csv --entity trip # rows a sandbox made or curl'ed → the PLATFORM world, read by the platform; `commit` carries the source tree only
474
473
  ```
475
474
 
476
475
  The sandbox carries the platform's `gateway` CLI and `sqlite3` on PATH: `exec` runs `worlds
477
- schema|data|test|serve|call …` on the working copy with nothing on your machine; on a world whose data is a hosted snapshot, a tool, handler or route edit compiles and keeps that data, an entity or key edit is refused (`references/gotchas.md`). `open` prints
476
+ schema|data|test|serve|call …` on the working copy with nothing on your machine; on a world whose data is a hosted snapshot, `data show|sql`, `test` and `call` read its rows (laid beside the tree before each `exec`), a tool, handler, route, new entity or optional field compiles and keeps that data, any other domain edit is refused (`references/gotchas.md`). `open` prints
478
477
  `cli: {version, digest}`, or `cli: null` plus the reason under `warnings`. Remote verbs (`push`, `run`,
479
478
  `session open`) stop inside the sandbox by design: it holds no platform credential, and never write one
480
479
  into its tree — `check`/`commit` hold back scratch, credential-shaped files (`.env`, `.gateway-env`, `*.env`,
@@ -489,6 +488,7 @@ MCP: `list_world_edits({ slug })`, `close_world_edit`, `discard_world_edit`, `ro
489
488
  - `references/ui-map.md`: every route, per thing (connector page, world tabs, Worlds › Map, sessions, tests, stored tasks).
490
489
  - `references/cli-mcp-map.md`: every CLI step with its MCP twin, the steps that have none, and how the platform (console) agent reaches the same surface (`run_gateway_cli`, `spawn_subagent`).
491
490
  - `references/gotchas.md`: offline vs platform scaffolding, `bench push` vs `worlds create`, the World Host as the only engine, sharing, seeds, `max_tokens`, secret preflight, `secret set` upsert.
491
+ - `references/journal-checks.md`: checks over the requests a session's world received (declarative, `verify.py`, SQL), fail-closed reasons, `task try` and `task regrade`.
492
492
 
493
493
  ## Related
494
494
 
@@ -497,4 +497,4 @@ MCP: `list_world_edits({ slug })`, `close_world_edit`, `discard_world_edit`, `ro
497
497
  - `documentation/features/connector-worlds.md` (`connector.toml`, capture, conform, serving), `workspace-connectors.md`
498
498
  (the connector object, sharing, MCP surface), `world-schema.md` (the `gateway-world/1` contract and store API);
499
499
  the first and last ship with the npm package (`gateway worlds skill connector-schema-authoring --install .`).
500
- - Consumer pages: `gateway_documentation/pages/worlds/{getting-started,sessions,data,custom-connections,slack}.mdx`.
500
+ - Consumer pages (docs.surfacearea.ai): `worlds/getting-started`, `worlds/sessions`, `worlds/data`, `worlds/custom-connections`, `worlds/slack`.
@@ -21,13 +21,18 @@ Reference for `worlds-getting-started`: every CLI step and its MCP twin, then ho
21
21
  | `worlds session open [-t\|--task-id\|--task-file]` (none: exploratory) / `status` / `call` / `close` / `list` / `pin` | none on the public MCP server — CLI or REST only (`/api/public/world-sessions[/{id}[/calls]]`; the open answers `idleExpiresAt` + `pinned`) |
22
22
  | `worlds session seed` | `seed_world_session` |
23
23
  | `worlds session export` | `export_world_session` |
24
+ | `worlds requests [list] <slug> [--session <id>] [--version <ref>] [--via api\|ui\|tool\|webhook] [--operation <name>] [--status 200\|2xx\|4xx\|5xx] [--since <time>] [--until <time>] [--limit N] [--cursor <c>] [--json]` | `list_world_requests({ slug, sessionId?, versionId?, via?, operation?, status?, since?, until?, cursor?, limit? })` (`GET /api/public/worlds/{slug}/requests`): every request the world received, from every session, version and door (`via` api, ui, tool, webhook), newest first, a page of at most 200 with `nextCursor`; metadata only (method, path, query, status, rows, found, duration, each body's size and `truncated`). The world keeps them for its life under the project's retention setting, and reading records nothing in any session's ledger. `--since`/`--until` take an ISO 8601 date or time (no zone is UTC); a bad filter is exit 2 before any request. UI: the world's Requests view, the session page's activity feed |
25
+ | `worlds requests show <slug> <requestId> [--json] [--out <file>]` | `get_world_request({ slug, requestId })` (`GET /api/public/worlds/{slug}/requests/{requestId}`): the request's headers (credentials `[redacted]`) and the first 64 KB of each body as text (`null` for a body that is not text; `bodyBytes` is the full size, `truncated` says it was cut); `--out` writes the whole entry as JSON. MCP only: the console agent's `get_world_request` is a different tool (it polls a world build) |
26
+ | `worlds session requests <sessionId>` (the list's filters but `--session`/`--version`) | `list_world_requests({ slug, sessionId })` (the CLI reads `GET /api/public/world-sessions/{id}/requests`, the world's list for one session; both MCP tools call the platform's `WorldRequestLedger` directly). A session whose engine is not the World Host records no requests: the route answers 409 `requests_not_recorded`, the CLI prints its one line and exits 3, and `session export --requests` notes the same line on stderr and writes the call log. `worlds requests <slug> --session <id>` and `list_world_requests({ slug, sessionId })` answer such a session the same way: 409, exit 3, the tool's error naming the engine |
27
+ | `worlds session webhooks <sessionId> [--json]` · `worlds session listen <sessionId> --forward-to <url> [--once] [--replay] [--interval-ms N] [--json]` | — (TypeScript CLI only). `webhooks` reads `GET /api/public/world-sessions/{id}/webhooks` (read key): the subscriptions the world's `[webhooks]` finds and how many deliveries each was sent, never a secret. `listen` polls `POST` the same route (secret key) and replays each delivery to `--forward-to` with its signed headers and exact body, then sends the receiver's status back, kept in the request ledger as `via: webhook` (`query.answer`), once per delivery; only deliveries sent from now unless `--replay`. A session on another engine: 409 `webhooks_not_served`, exit 1 |
24
28
  | `worlds session reopen <id>` | — (no MCP twin; `POST /api/public/world-sessions/{id}/reopen`: a closed session back under the same id, URLs and token from its last checkpoint, answering what `status` answers; 409 `session_not_closed` / `session_no_checkpoint` / `session_reopen_in_progress` / `session_version_unavailable`) |
25
- | `worlds data calls pull` / `worlds data ingest [--transform\|--map]` | — (no MCP twin yet; `run_gateway_cli data ingest` on a sandboxed directory) |
29
+ | `worlds session restart <id> [--version <pin>]` | `restart_world_session` (`POST /api/public/world-sessions/{id}/restart` `{version?}`: a running or closed session's world started over on its pin's current version, or `version`, which becomes the pin, under the same id, URLs and token; base data plus the task's seed. The route and the CLI answer what `status` answers plus `restart: {previousVersionId, versionId, pin, boundarySeq, boundaryAt}`; the MCP tool answers the `restart` block with `sessionId`. A request the old world received has an `at` before `boundaryAt`, and a grade reads only those after it. 409 `session_not_restartable` / `session_version_unavailable` / `session_reopen_in_progress` / `no_open_door`; 503 when the new world did not open) |
30
+ | `worlds data calls pull` / `worlds data ingest [--transform\|--map]` | — (no MCP twin yet; the platform agent runs it through `run_gateway_cli`) |
26
31
  | `files upload <local>... [--to]` | `request_file_upload` + `confirm_file_upload` (`upload_file` for ≤25 MB inline) |
27
32
  | `files list [path]` / `files get <path>` / `files download\|cat <path>` | `list_files` / `get_file` (a presigned URL; the CLI streams it) |
28
33
  | `files delete` / `files move` / `files mkdir` | `delete_file` / `move_file` / `create_folder` |
29
- | `files fetch <url> --to <path> [--header "Name: value"]...` | `download_url_to_drive` (`POST /api/public/files/fetch`; the platform fetches, nothing passes through the caller's machine; a header value may name a project secret as `{{secret:NAME}}`, expanded on the platform and never returned; `--local` fetches from the caller's machine instead, without secrets) |
30
- | `worlds sandbox import <id> <path-in-sandbox> [--entity] [--mode]` | `import_world_sandbox_data` (`POST /api/public/benchmark-containers/sandboxes/{id}/import`; the platform reads the file from the sandbox tree into the platform world — the sandbox never holds credentials; `commit` versions the source tree only) |
34
+ | `files fetch <url> --to <path> [--header "Name: value"]...` | `download_url_to_drive` (`POST /api/public/files/fetch`; the platform fetches, nothing passes through the caller's machine; a header value may name a project secret as `{{secret:NAME}}`, expanded on the platform, never returned, and sent only to the origins that secret lists (`secret set --allowed-origin`, `secret origins NAME <origin>...`; a redirect elsewhere is refused); `--local` fetches from the caller's machine instead, without secrets) |
35
+ | `worlds sandbox import <id> <path-in-sandbox> [--entity] [--mode] [--report <file>]` | `import_world_sandbox_data` (`POST /api/public/benchmark-containers/sandboxes/{id}/import`; the platform reads the file from the sandbox tree into the platform world — the sandbox never holds credentials; `commit` versions the source tree only) |
31
36
  | `files connectors list\|sync <id>` | `list_file_connectors` / `sync_file_connector` (`GET\|POST /api/public/files/connectors[/sync]`) |
32
37
  | `traces list\|get\|export [--observations]` | `get_trace`, `get_observations` (`GET /api/public/traces[/{id}]`, `/observations`) |
33
38
  | `traces sessions list\|get [--io]` | `get_session` (`GET /api/public/sessions[/{id}?includeIO=true]`) |
@@ -36,9 +41,9 @@ Reference for `worlds-getting-started`: every CLI step and its MCP twin, then ho
36
41
  | `environment run` / `worlds run` | `run_evaluation` |
37
42
  | `environment link-task-set` / `create-task` | `create_task_set`, `create_task`, `link_task_set` |
38
43
  | `bench diff` / `propose` | `env_diff`, `env_propose` (proposals are the legacy PR-style door; edit sessions below are the version-control loop) |
39
- | `worlds\|bench edit status\|list\|close\|discard\|rollback <slug>` | `list_world_edits({ slug, status?, limit? })`, `close_world_edit({ slug, sessionId?, force?, message? })`, `discard_world_edit`, `rollback_world_edit({ slug, sessionId, force?, message? })` (`GET /api/public/worlds/{slug}/edits`, `POST …/edits/close\|discard\|rollback`). After a world's first version every push, sandbox commit, data import, agent `env_commit` and UI save lands on the credential's open edit session — a private `edit/<id>` branch only that credential reads as `main` (`describe`, `pull`, `log`, `session open`, `sandbox open`); the write's JSON carries `editSessionId` + a hint. `close`, or 60 minutes without an edit, seals the session: the shared `main` moves to its tip (every version stays in `log`; the session is the rollback unit); a `main` that moved meanwhile is rebased when the paths differ, else the session parks as `conflict` (`close --force` takes its content). `rollback` restores source + data snapshot from before a sealed session as a new sealed session (`--force` when later sessions would be undone too). UI: world › History › Edit sessions |
40
- | `worlds task edit status\|close\|rollback <task>` (task id, spec file with `worlds`, or `task up` manifest) | `get_task_edit({ task })`, `close_task_edit({ task, requireAll?, force?, message? })`, `rollback_task_edit({ task, groupId, force?, message? })` (`POST /api/public/world-task-edits/status\|close\|rollback`). The same edit sessions across every world a task names: `status` shows each world's unsealed edits (open and `parked` in conflict) and what closing would do (`fast-forward`, `rebase`, `conflict`) — your own `task up` opens them at your tip (`private: true`), everyone else still gets shared `main`; `close` seals every world in ONE transaction (a conflict, a missing world, a ref other than `main` or a parked session anywhere seals nothing, and the 409 names every world's problem; worlds with no edit are skipped unless `--require-all`), and the sessions share a `groupId`; `rollback --group` restores every world together to the `main` the group replaced, refused when anything reached a world's `main` after the group (a later session or a write outside sessions) unless `--force` |
41
- | `worlds\|bench sandbox open\|status\|read\|write\|exec\|check\|commit\|close` | `open_world_sandbox`, `get_world_sandbox`, `read_world_sandbox_file`, `write_world_sandbox_file` (base64), `exec_in_world_sandbox`, `check_world_sandbox`, `commit_world_sandbox`, `close_world_sandbox({ sandboxId, force? })` (`/api/public/benchmark-containers/sandboxes[/{id}[/file\|exec\|check\|commit]]`; `close` with uncommitted work is a 409 `sandbox_uncommitted` naming the paths, nothing closed, unless `force: true` / `--force`; a sandbox whose machine was replaced gets its tree back (latest snapshot, or the base) and the next verb answers 409 `sandbox_recreated` once — look at the tree, redo lost edits, retry; 503 `sandbox_restore_failed` means retry; 409 `sandbox_tree_missing` means the world root was deleted, so close and reopen; the source tree only — no data snapshot, nothing on the caller's disk; `commit` lands on the recorded base; `commit --rebase` sends `rebase: true` and replays onto a branch head that moved, a 409 naming each conflicting path). `open` reports `cli: {version, digest}` — the platform's own `gateway` CLI and a `sqlite3` are on PATH inside `exec`, so `gateway worlds schema entity add\|verifier add\|task add\|compile\|check .`, `gateway worlds data import\|show\|query\|sql .`, `gateway worlds test .`, `gateway worlds serve . --port 8080 & sleep 2; gateway worlds call http://localhost:8080 <tool> …` (one `exec`; a served world lives only as long as that command) and `sqlite3 db/state.sqlite "…"` run on the working copy; remote verbs (push, run, session open) stop in the sandbox by design — `check`/`commit` from your machine. `cli: null` + `warnings[]` means the image cannot host the runtime (python3 < 3.12 or node < 18); plain shell still runs |
44
+ | `worlds\|bench edit status\|list\|close\|discard\|rollback <slug>` | `list_world_edits({ slug, status?, limit? })`, `close_world_edit({ slug, sessionId?, force?, message? })`, `discard_world_edit`, `rollback_world_edit({ slug, sessionId, force?, message? })` (`GET /api/public/worlds/{slug}/edits`, `POST …/edits/close\|discard\|rollback`). After a world's first version every push, sandbox commit, data import, agent `env_commit` and UI save lands on the credential's open edit session — a private `edit/<id>` branch only that credential's unpinned reads see (no `@ref`, no version: `describe`, `pull`, `log`, `session open`, `sandbox open`, `test`); `slug@main`/`@latest`, an exact version pin, every run, task and stored pin resolve to sealed versions only (an unsealed version id answers only its own author); the write's JSON carries `editSessionId` + a hint. `close`, or 60 minutes without an edit, seals the session: the shared `main` moves to its tip (every version stays in `log`; the session is the rollback unit); a `main` that moved meanwhile is rebased when the paths differ, else the session parks as `conflict` (`close --force` takes its content). `rollback` restores source + data snapshot from before a sealed session as a new sealed session (`--force` when later sessions would be undone too). UI: world › History › Edit sessions |
45
+ | `worlds task edit status\|close\|rollback <task>` (task id, spec file with `worlds`, or `task up` manifest) | `get_task_edit({ task })`, `close_task_edit({ task, requireAll?, force?, message? })`, `rollback_task_edit({ task, groupId, force?, message? })` (`POST /api/public/world-task-edits/status\|close\|rollback`). The same edit sessions across every world a task names: `status` shows each world's unsealed edits (open and `parked` in conflict) and what closing would do (`fast-forward`, `rebase`, `conflict`) — every `task up`, run config and schedule, yours included, keeps the sealed `main` until the close; `close` seals every world in ONE transaction (a conflict, a missing world, a ref other than `main` or a parked session anywhere seals nothing, and the 409 names every world's problem; worlds with no edit are skipped unless `--require-all`), and the sessions share a `groupId`; `rollback --group` restores every world together to the `main` the group replaced, refused when anything reached a world's `main` after the group (a later session or a write outside sessions) unless `--force` |
46
+ | `worlds\|bench sandbox open\|status\|read\|write\|exec\|check\|commit\|close` | `open_world_sandbox`, `get_world_sandbox`, `read_world_sandbox_file`, `write_world_sandbox_file` (base64), `exec_in_world_sandbox`, `check_world_sandbox`, `commit_world_sandbox`, `close_world_sandbox({ sandboxId, force? })` (`/api/public/benchmark-containers/sandboxes[/{id}[/file\|exec\|check\|commit]]`; `close` with uncommitted work is a 409 `sandbox_uncommitted` naming the paths, nothing closed, unless `force: true` / `--force`; a sandbox whose machine was replaced gets its tree back (latest snapshot, or the base) and the next verb answers 409 `sandbox_recreated` once — look at the tree, redo lost edits, retry; 503 `sandbox_restore_failed` means retry; 503 `sandbox_unresponsive` / `sandbox_unavailable` / `sandbox_replacing` mean nothing changed: call again after `retryAfterSeconds` (a sandbox silent for 5 minutes is then replaced from its latest snapshot and answers 409 `sandbox_recreated`); 409 `sandbox_tree_missing` means the world root was deleted, so close and reopen; the source tree only — no data snapshot, nothing on the caller's disk; `commit` lands on the recorded base; `commit --rebase` sends `rebase: true` and replays onto a branch head that moved, a 409 naming each conflicting path). `open` reports `cli: {version, digest}` — the platform's own `gateway` CLI and a `sqlite3` are on PATH inside `exec`, so `gateway worlds schema entity add\|verifier add\|task add\|compile\|check .`, `gateway worlds data import\|show\|query\|sql .`, `gateway worlds test .`, `gateway worlds serve . --port 8080 & sleep 2; gateway worlds call http://localhost:8080 <tool> …` (one `exec`; a served world lives only as long as that command) and `sqlite3 db/state.sqlite "…"` run on the working copy; remote verbs (push, run, session open) stop in the sandbox by design — `check`/`commit` from your machine. `cli: null` + `warnings[]` means the image cannot host the runtime (python3 < 3.12 or node < 18); plain shell still runs |
42
47
  | `worlds\|bench sandbox open --new <slug> --from custom\|<template>` | `open_world_sandbox({ new, from })` (same route, body `{new, from}`; a world that does not exist yet — `baseVersionId`/`containerId`/`baseContentHash` null, `branch: main`, `pendingSlug`; `custom` = the `schema init` scaffold, else a shipped template (`GET /api/public/worlds/templates`; unknown → 400 naming the list); taken slug → 409 `world_exists`, never renamed; `check_world_sandbox` runs the first commit's gate; the first `commit_world_sandbox` creates the world on `main` through the `worlds create --from <dir>` door, later commits land on the new base; the same staged CLI runs on the scaffold) |
43
48
  | `worlds skill <name>` / `worlds connector skill` | `get_connector_authoring_skill`, `guide` |
44
49
  | `worlds connector capture --remote` / poll + download | `start_connector_capture`, `get_connector_capture` (platform agent only) |
@@ -50,8 +55,9 @@ before it makes a request.
50
55
 
51
56
  | Door | Limit | Over it |
52
57
  |---|---|---|
53
- | `sandbox write`, `write_world_sandbox_file`, `env_write_file`, `propose_task_fix` | 256 KB per file | refused, naming the limit; rows → `worlds data import <slug> <file>`; a big source file → `gateway files upload`, then fetch it inside the sandbox with `sandbox exec`; the whole tree → `bench push` |
54
- | `sandbox exec --timeout`, `exec_in_world_sandbox timeoutMs` | default 60 s, at most 600 s | refused, not clamped |
58
+ | `sandbox write` | 256 MB per file (past 4 MB the CLIs send it in parts, checked by size and SHA-256 before it lands); `--from <dir>` writes every file under it but `.git/`, `.gateway/` and scratch (`node_modules/`, `__pycache__/`, `*.pyc`, ...), and says what it skipped | refused before any request, naming the limit; generate bigger data in the sandbox (`sandbox exec`) and load it with `sandbox import` |
59
+ | `write_world_sandbox_file`, `env_write_file`, `propose_task_fix` | 256 KB per call | refused, naming the limit; a bigger file → `sandbox write`; rows → `worlds data import <slug> <file>`; the whole tree → `bench push` |
60
+ | `sandbox exec --timeout`, `exec_in_world_sandbox timeoutMs` | default 60 s, at most 600 s | refused, not clamped; a start gets the sandbox ready, then waits for the command until 40 s have passed in all, and a command not done by then answers `running` with an `execId` (the CLIs wait again by themselves; `exec_in_world_sandbox` takes `execId` to wait); a timeout returns what it printed; a start whose getting ready took over 45 s is a 409 `sandbox_exec_deferred` with nothing started, its `warnings` saying what getting ready found (the CLIs start again and print them; what getting ready did is kept, a snapshot lay that failed too, so the next start is quick); a job whose runner died is a 409 `sandbox_exec_lost`, and a runner the sandbox cannot prepare a 503 `sandbox_exec_start_failed` (nothing started) |
55
61
  | Sandbox tree at `check`/`commit`, `bench push` unpacked | 128 MB of source, 2000 files | refused, naming the limit, before a byte is read; move data to `worlds data import`, delete scratch files or list them in `.gatewayignore` |
56
62
  | Sandbox tree at `check`/`commit`: credential-shaped files (`.env`, `*.pem`, `id_rsa`, `credentials.json`…; `.env.example` stays), symlinks, sockets/devices | held back, never in the version | listed under `ignored`, each named in `warnings` (path only); use `bench secrets set` for a key the world needs |
57
63
  | `worlds data query` / `data sql` / `data show` on a stored version | none beyond the version's own caps | the platform opens the version's tree and snapshot in a prepared directory it owns; no size travels through the request |
@@ -61,11 +67,13 @@ before it makes a request.
61
67
 
62
68
  ## The platform agent
63
69
 
64
- The platform (console) agent has every MCP tool in this table as an agent tool of the
65
- same name, plus `run_gateway_cli` for the *local* CLI rows (`schema init|templates|compile|check|describe|api-bundle`,
66
- `connector validate|conform|ingest|skill`, `data show|import|check|extract`, `skill`) inside its sandbox
67
- — structured `{ command, args }` with this CLI's exact flags (the TypeScript `gateway`, run as
68
- `node /tmp/gateway-cli/cli.js worlds …`), paths under `/workspace`, no remote flags, no platform
69
- credentials — and `spawn_subagent` / `wait_for_subagent` to hand one world or connector
70
- each to a tool-restricted child. Everything that writes to the platform goes through the
71
- MCP-twin tools, gated by capabilities and the session's autonomy settings.
70
+ The platform (console) agent edits worlds with this CLI, through `run_gateway_cli` in its
71
+ sandbox: structured `{ command, args }` with the CLI's exact flags (the TypeScript `gateway`,
72
+ run as `node /tmp/gateway-cli/cli.js worlds …`), paths under `/workspace`. A `./dir` runs in
73
+ the sandbox; a slug (`list`, `describe`, `create`, `pull`, `push`, `data …`, `test`, `session …`,
74
+ `requests …`, `edit …`, `connector list|pull|publish|clone`) reaches the platform as the user,
75
+ through a key minted for that one call, valid only on the routes that verb calls and deleted
76
+ when the call ends. A read verb needs read access, a write verb world-write access; `create`
77
+ and `session open` also need the session's `provisionWorlds` (or `confirm: true`),
78
+ `connector publish|clone` its `allowConnectorWrites`. `spawn_subagent` / `wait_for_subagent` hand one world or connector each to a
79
+ tool-restricted child.
@@ -4,16 +4,19 @@ The things that bite once and never again, moved out of `SKILL.md` to keep it un
4
4
 
5
5
  - A shipped template (`schema init ./x --connector salesforce`) scaffolds offline through the
6
6
  bundled runtime: no host, no keys, no config file read. Only `--connector workspace:<slug>`
7
- needs the platform — without `gateway auth login` or the `GATEWAY_*` keys (the agent's
8
- local-only `run_gateway_cli` included) `schema init` refuses it and names `--host`,
7
+ needs the platform — without `gateway auth login` or the `GATEWAY_*` keys (the platform
8
+ agent's `run_gateway_cli` included: its local commands carry no key) `schema init` refuses it and names `--host`,
9
9
  `GATEWAY_HOST` and the login command. No `python3 >= 3.12`? A shipped template scaffolds
10
10
  on the platform instead, so there it does need a host.
11
- - `bench push` (the TS CLI) on a world with `connector.toml` still packages an api-kind bundle
12
- on the way up; `worlds create --from ./x` stores the tree as it is, and `worlds migrate`
13
- turns a pushed bundle back into the tree. Either way, edit the schema world, not the bundle.
11
+ - `bench push` and `worlds create --from ./x` store the tree as it is; nothing is repackaged into
12
+ an api-kind bundle on the way up. `worlds migrate` turns a bundle pushed before that back into
13
+ the tree. Either way, edit the schema world, not a bundle.
14
14
  - The World Host is the engine for every world, `[dependencies]` included (it opens each linked
15
15
  world beside the root); a session never falls back to a slower engine, and a deployment
16
16
  without a host refuses the open by name.
17
+ - A `[dependencies]` pin never resolves to an open edit, yours included: `@main` is the sealed
18
+ `main`, and a hash, semver or version id must name a sealed version. Seal the linked world's
19
+ edit (`gateway worlds edit close <slug>`) before you push the world that links it.
17
20
  - Sharing is publish + clone, never a live reference; later edits reach a clone only on re-clone.
18
21
  - Never commit `captures/`; never merge a customer's world as an SDK template.
19
22
  - A seed (scenario overlay or runner admin endpoint) is the whole state, not an increment.
@@ -21,20 +24,53 @@ The things that bite once and never again, moved out of `SKILL.md` to keep it un
21
24
  - A platform request that never gets an answer fails in one line: the request, the host, the cause
22
25
  (`connection refused`, `DNS lookup failed`, `timed out after 120s`) and the next step, exit 1. Each
23
26
  request waits `GATEWAY_TIMEOUT_MS` (default 120000); polls (session ready, grades) are many short
24
- requests, so a long wait is never cut by it, and sandbox requests always allow 660 s.
27
+ requests, so a long wait is never cut by it; a sandbox `exec` waits in 40 s requests until its
28
+ command ends, and other sandbox requests (and MCP tool calls through either proxy) wait 290 s,
29
+ under Node's 300 s fetch limit, on both twins. An edge answer that is not the platform's JSON (an
30
+ HTML 502/503/504 from a load balancer) is named, never printed.
31
+ - A version that holds dot or root files and was committed, by any door but a directory push, before
32
+ the platform hashed every stored file carries a content hash over its archive files only. Deleting
33
+ its only dot or root file (a `.gatewayignore`, say) and changing nothing else is refused, naming the
34
+ version and the files: commit the deletion with another change, or put the file back. An unchanged
35
+ tree on such a version commits the same files under the new hash, and `check` and `commit` say so,
36
+ unless those files are ones a sandbox never commits (scratch such as `__pycache__/`, or `.env`):
37
+ then an untouched sandbox is refused until it carries another change.
25
38
 
26
39
  - A world that declares an environment secret (`environment_secret_name` in `release/manifest.json`, or `${NAME:?}` in a task's `docker-compose.yaml`) is refused at `session open`
27
40
  with 400 `missing_env_secrets` naming `gateway bench secrets set --env <slug> --key <NAME>` before
28
41
  anything is provisioned — the same preflight a run dispatch applies; set the secret, then open.
29
42
  - `gateway secret set NAME` is an upsert: the same name again rotates the value and answers
30
43
  `updated: true`; `bench secrets set` does the same for a benchmark's environment.
44
+ - A project secret is sent in a `files fetch` header only to the https origins it lists
45
+ (`gateway secret set NAME --allowed-origin https://host`, or `gateway secret origins NAME <origin>...`
46
+ without the value); one with none is refused by name, and so is a redirect to an unlisted origin.
31
47
  - Imported data survives every edit that cannot touch a stored row. After `gateway worlds data import
32
48
  <slug>` the world's tree carries `db/snapshot.json` (the hosted snapshot) and not the rows; in
33
49
  `worlds sandbox open <slug>@main`, adding a tool, a handler, a route, a test or a documentation
34
50
  file then `schema compile .` and `schema check .` pass and the commit keeps the snapshot, no
35
51
  re-import, and `gateway bench fork <slug>` takes the data with it. Adding an entity or a field
36
52
  that is not required (or another `domain_version`) carries the data too: `sandbox check` says
37
- the commit migrates the snapshot, and `sandbox commit` migrates it and re-pins the tree.
53
+ the commit migrates the snapshot, and `sandbox commit` migrates it as a job and re-pins the tree:
54
+ the CLI follows the batch (each phase on stderr, up to `--wait` seconds) and prints the new
55
+ version, or exits 1 naming the refusal (`storage`, `timeout`, `checkout_cap`, `refused`,
56
+ `base_moved`); MCP `commit_world_sandbox` answers `{batchId}` to poll with `get_data_batch` when the
57
+ job outlasts its wait. While the batch runs, `commit` and `import` are refused
58
+ (`sandbox_commit_pending`); once it lands a sandbox used in the last 15 minutes takes the version
59
+ at once when none of the files it rewrites changed since the commit, else its next `commit`,
60
+ `import` or `exec` takes it and says what it found (`commit` and `import` say it on a refusal
61
+ too; `close` takes it silently), and `sandbox check` shows it first without writing anything. A `sandbox import` stands the sandbox on the data version it published, so
62
+ the next commit needs no `--rebase`; when another door moved `main`, `sandbox check` says
63
+ `baseMoved` and `--rebase` carries the edit and the imported rows onto the tip. A `--rebase` whose
64
+ base sits on an edit session still open, still closing, or stopped in conflict is
65
+ refused (`rebase_unrelated`) naming the session and what to do: close an open one (`edit close
66
+ <slug> --session <id>`), wait for one that is closing, and land one in conflict over `main`
67
+ (`edit close <slug> --session <id> --force`) or drop it (`edit discard <slug> --session <id>`);
68
+ then `--rebase` again. `worlds push` from a pulled tree keeps the snapshot for the edits that cannot touch a row, and refuses a domain
69
+ change, naming the sandbox: make that one there. No file is
70
+ deleted by hand: compile drops the `db/state.*` the tree's own data files built, which the pin
71
+ replaces, and check never refuses them. In the sandbox `data show|sql`, `worlds test` and
72
+ `worlds call` read the hosted rows, which the platform lays beside the tree (never in it) before
73
+ each `exec`, after taking a batch that landed; `exec`'s warnings say when it could not.
38
74
  Removing, retyping or requiring a field, or changing a key, a relationship or a description, is
39
75
  refused, naming what changed: keep it as it was, or remove `db/snapshot.json` and import every
40
76
  row again. `check` reports
@@ -43,3 +79,31 @@ The things that bite once and never again, moved out of `SKILL.md` to keep it un
43
79
  `check` and is first refused at that open: open a session on the version after a handler edit.
44
80
  Compile from a fresh `sandbox open` rather than copying in artifacts compiled
45
81
  elsewhere: the pin proves its data's domain from the `schema/lock.json` it started with.
82
+
83
+ ## Transcribing a vendor spec by hand
84
+
85
+ Met building an AgentMail world from its OpenAPI document (2026-10-10).
86
+
87
+ - An entity's payload must be a closed object. A vendor `$def` without `additionalProperties:
88
+ false` is refused by `schema entity add` (`An entity payload must be a closed object`): close
89
+ every object def that declares `properties`, and leave map types (a schema-valued
90
+ `additionalProperties`, such as `metadata` or `headers`) as they are.
91
+ - A primary key must be a direct `string` or `integer` property. A vendor id wrapped in a named
92
+ alias (`"inbox_id": {"$ref": "#/$defs/InboxId"}`, where `InboxId` is a string) is refused
93
+ (`Primary key field … must be a string or integer property`): inline scalar aliases (the
94
+ target's schema, the property's own `description` kept) before `entity add`.
95
+ - A vendor refusal (not found, validation) is `raise Refusal(404, body)`, imported from `gateway_env`
96
+ at module top: tools and routes answer that status and body, unchecked against the tool's
97
+ `output`. Anything else raised is the world's bug: `AttributeError`, `TypeError`, `NameError`
98
+ answer 400 `handler`, the rest 500 `engine`.
99
+ - Arrays and nested objects are not SQL columns: they live in the row's `payload` JSON. Read them with
100
+ `json_extract(payload, '$.labels')`, or expand them with `json_each(payload, '$.labels')` in verifier
101
+ SQL and `worlds data sql`.
102
+ - Routes and tools can share one engine. The tools loader puts the world root on `sys.path` and
103
+ skips `tools/_*.py` as handler modules, so logic in `tools/_engine.py` is imported as `from
104
+ tools._engine import Engine` by `tools/handlers.py`. `api/handlers.py` is loaded by path with no
105
+ `sys.path` entry: insert the world root first (`sys.path.insert(0,
106
+ str(Path(__file__).resolve().parent.parent))`). Give the engine a small port (`rows`, `get`,
107
+ `insert`, `update`, `delete`, `now`, `uuid`) with one adapter over `ctx` and one over `store`.
108
+
109
+ - **A vendor that notifies needs `[webhooks]`, not just a subscriptions entity.** Rows written by `POST /webhooks` send nothing on their own. Declare `[webhooks]` in `connector.toml` (the subscriptions entity, its url/events/secret/enabled/scope fields, `signing = "svix"|"github"|"linear"|"stripe"|"hmac-sha256"|"none"`), then send from the write: `ctx.deliver(event_type, body, scope={...})` in a route handler, `gateway_env.webhooks.deliver(...)` in a tool. Each matching subscription gets one signed delivery, kept only when the call commits and recorded in the request ledger as `via: webhook` with the event type as `operation` (`worlds requests <slug> --via webhook`; checks read `gateway_requests`; a receiver's answer is a separate `<event>.answer` entry, so it never inflates a count of the event). To receive them on your machine: `gateway worlds session listen <id> --forward-to http://localhost:3000/webhooks` (signed as the vendor signs; the receiver's status lands in the ledger); `gateway worlds session webhooks <id>` lists the subscriptions. For receivers on the internet, a project admin turns on Settings → General → World webhooks and the platform posts each delivery itself (https 443, public addresses only). Spec: `documentation/features/connector-worlds.md` → Webhooks.