@withgateway/sdk 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cli.js +438 -81
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +439 -82
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/files/index.js +9 -5
  6. package/dist/files/index.js.map +1 -1
  7. package/dist/files/index.mjs +9 -5
  8. package/dist/files/index.mjs.map +1 -1
  9. package/dist/index.d.mts +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +21 -10
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +20 -10
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/traces/index.js +9 -5
  16. package/dist/traces/index.js.map +1 -1
  17. package/dist/traces/index.mjs +9 -5
  18. package/dist/traces/index.mjs.map +1 -1
  19. package/dist/tracing/index.js +1 -1
  20. package/dist/tracing/index.js.map +1 -1
  21. package/dist/tracing/index.mjs +1 -1
  22. package/dist/tracing/index.mjs.map +1 -1
  23. package/dist/worlds/index.d.mts +7 -1
  24. package/dist/worlds/index.d.ts +7 -1
  25. package/dist/worlds/index.js +19 -9
  26. package/dist/worlds/index.js.map +1 -1
  27. package/dist/worlds/index.mjs +19 -9
  28. package/dist/worlds/index.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/runtime/gatewaysdk/environment/schema/api.py +61 -3
  31. package/runtime/gatewaysdk/environment/schema/batch.py +5 -1
  32. package/runtime/gatewaysdk/environment/schema/connector.py +11 -0
  33. package/runtime/gatewaysdk/environment/schema/data.py +76 -2
  34. package/runtime/gatewaysdk/environment/schema/dependencies.py +11 -1
  35. package/runtime/gatewaysdk/environment/schema/host.py +8 -17
  36. package/runtime/gatewaysdk/environment/schema/local.py +105 -19
  37. package/runtime/gatewaysdk/environment/schema/mapping.py +13 -1
  38. package/runtime/gatewaysdk/environment/schema/platform.py +32 -5
  39. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +4 -1
  40. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +5 -5
  41. package/runtime/gatewaysdk/environment/schema/tools_world.py +5 -1
  42. package/runtime/gatewaysdk/environment/schema/validation.py +4 -3
  43. package/skills/benchmarks-getting-started/SKILL.md +4 -1
  44. package/skills/worlds-getting-started/SKILL.md +5 -5
@@ -337,7 +337,7 @@ SDK: `openSession(slug, { task: spec })` (TS), `open_session(slug, spec)` (Pytho
337
337
  sessions open it by id and grades attribute to the task and its version:
338
338
 
339
339
  ```bash
340
- gateway worlds task create task.json --world x # version 1; --name overrides the spec's name
340
+ gateway worlds task create task.json --world x # version 1; --name overrides the spec's name; --replace: a taken name becomes its next version
341
341
  gateway worlds task list --world x --metadata externalUserId=u_42
342
342
  gateway worlds task show <TASK_ID> [--version 2] # spec + version history
343
343
  gateway worlds task validate <TASK_ID> # seed/grader entities against the pinned world's version
@@ -403,14 +403,14 @@ client is the agent. Dependency tools are `<alias>.<tool>`, each world grades on
403
403
  ```bash
404
404
  gateway worlds serve ./whatsapp --task escalate_locked_account --port 8080 # prints {task, prompt, tools, verifiers, worlds}
405
405
  curl -s localhost:8080/__session/task # + contracts: each tool's description and input schema
406
- curl -s -X POST localhost:8080/__session/call -d '{"tool":"slack.post_message","args":{...}}'
407
406
  gateway worlds call http://localhost:8080 list_conversations --state --grade # act from the CLI, read state, grade
408
407
  gateway worlds call http://localhost:8080 slack.list_channels --args '{...}' --close # end it; the serve process exits
409
408
  ```
410
409
 
411
- `GET /__session/{task,tools,state}`, `POST /__session/{call,grade,reset,seed,close}`. `--task`
412
- and `--scenario` belong to `serve`; `worlds call <url>` refuses them. A directory target
413
- (`worlds call ./x <tool>`) opens and closes its own session per call instead.
410
+ `GET /__session/{task,tools,state}`, `POST /__session/{call,grade,reset,seed,close}`; `--task` and
411
+ `--scenario` belong to `serve`. A directory target (`worlds call ./x <tool>`) opens and closes its
412
+ own session per call. A HOSTED session is not a served url (the World Host serves no `/__session/*`;
413
+ its `api.url` takes the session's bearer): act on it by id, `gateway worlds call <sessionId> <tool> --state --grade --close`.
414
414
 
415
415
  ## 7. Run and grade
416
416
 
@@ -581,7 +581,11 @@ class ToolsWorld:
581
581
  rows = args.get("rows")
582
582
  mode = args.get("mode", "append")
583
583
  if not isinstance(rows, dict):
584
- fail("host", "seed needs args.rows as {entity: [row, ...]}")
584
+ fail(
585
+ "host",
586
+ 'seed needs rows as {"rows": {entity: [row, ...]}, "mode": "append"|"replace"}; '
587
+ "a dependency's entity is named alias.entity",
588
+ )
585
589
  by_world: dict[int, tuple[World, dict[str, Any], str]] = {}
586
590
  for entity, entity_rows in rows.items():
587
591
  world, local = self._world_of(entity)
@@ -233,8 +233,8 @@ def equal(left: Any, right: Any) -> bool:
233
233
  def validate(schema: dict, value: Any, *, location: str = "", path: str = "") -> None:
234
234
  json_value(value, path)
235
235
 
236
- def error(code: str, message: str, keyword: str = "") -> NoReturn:
237
- fail(code, message, f"{location}/{keyword}" if keyword else location, path=path)
236
+ def error(code: str, message: str, keyword: str = "", **context: Any) -> NoReturn:
237
+ fail(code, message, f"{location}/{keyword}" if keyword else location, path=path, **context)
238
238
 
239
239
  expected = schema.get("type")
240
240
  types = expected if isinstance(expected, list) else [expected] if expected else []
@@ -275,7 +275,7 @@ def validate(schema: dict, value: Any, *, location: str = "", path: str = "") ->
275
275
  properties = schema.get("properties", {})
276
276
  for name in schema.get("required", []):
277
277
  if name not in value:
278
- error("required", f"Missing required property {name}", "required")
278
+ error("required", f"Missing required property {name}", "required", property=name)
279
279
  for name, item in value.items():
280
280
  if name in properties:
281
281
  validate(
@@ -289,6 +289,7 @@ def validate(schema: dict, value: Any, *, location: str = "", path: str = "") ->
289
289
  "additionalProperties",
290
290
  f"Unknown property {name}",
291
291
  "additionalProperties",
292
+ property=name,
292
293
  )
293
294
  elif isinstance(schema.get("additionalProperties"), dict):
294
295
  # A schema-valued additionalProperties types a map: every
@@ -244,12 +244,15 @@ crm-bench/
244
244
  Entities, tools and routes: `worlds-getting-started` §2 and `connector-schema-authoring`. Tasks:
245
245
 
246
246
  ```bash
247
+ gateway worlds schema verifier add ./crm-bench ticket_closed --entity crm_tickets --where "id = 'T-7' AND status = 'closed'"
247
248
  gateway worlds schema task add ./crm-bench close_ticket --prompt "Close ticket T-7 and note the reason." --verifier ticket_closed
248
249
  gateway worlds schema task add ./crm-bench escalate --prompt "..." --verifier state_present --world slack=state_present
249
250
  ```
250
251
 
251
252
  - `--prompt` is what the agent is told. `--verifier <name>` names `verifiers/<name>.sql`; it must
252
- exist. Each verifier becomes a key in `rewards`; `reward` is their mean.
253
+ exist — `schema verifier add <dir> <name> --entity <entity> [--where "<sql condition>"]` scaffolds
254
+ it (without `--where`, the `state_present` placeholder). Each verifier becomes a key in `rewards`;
255
+ `reward` is their mean.
253
256
  - A verifier is one SQL statement returning one number in 0..1 over the world's tables (entity
254
257
  names from `schema/world.json`): `SELECT CASE WHEN COUNT(*) > 0 THEN 1.0 ELSE 0.0 END FROM
255
258
  "crm_tickets" WHERE id = 'T-7' AND status = 'closed';`
@@ -337,7 +337,7 @@ SDK: `openSession(slug, { task: spec })` (TS), `open_session(slug, spec)` (Pytho
337
337
  sessions open it by id and grades attribute to the task and its version:
338
338
 
339
339
  ```bash
340
- gateway worlds task create task.json --world x # version 1; --name overrides the spec's name
340
+ gateway worlds task create task.json --world x # version 1; --name overrides the spec's name; --replace: a taken name becomes its next version
341
341
  gateway worlds task list --world x --metadata externalUserId=u_42
342
342
  gateway worlds task show <TASK_ID> [--version 2] # spec + version history
343
343
  gateway worlds task validate <TASK_ID> # seed/grader entities against the pinned world's version
@@ -403,14 +403,14 @@ client is the agent. Dependency tools are `<alias>.<tool>`, each world grades on
403
403
  ```bash
404
404
  gateway worlds serve ./whatsapp --task escalate_locked_account --port 8080 # prints {task, prompt, tools, verifiers, worlds}
405
405
  curl -s localhost:8080/__session/task # + contracts: each tool's description and input schema
406
- curl -s -X POST localhost:8080/__session/call -d '{"tool":"slack.post_message","args":{...}}'
407
406
  gateway worlds call http://localhost:8080 list_conversations --state --grade # act from the CLI, read state, grade
408
407
  gateway worlds call http://localhost:8080 slack.list_channels --args '{...}' --close # end it; the serve process exits
409
408
  ```
410
409
 
411
- `GET /__session/{task,tools,state}`, `POST /__session/{call,grade,reset,seed,close}`. `--task`
412
- and `--scenario` belong to `serve`; `worlds call <url>` refuses them. A directory target
413
- (`worlds call ./x <tool>`) opens and closes its own session per call instead.
410
+ `GET /__session/{task,tools,state}`, `POST /__session/{call,grade,reset,seed,close}`; `--task` and
411
+ `--scenario` belong to `serve`. A directory target (`worlds call ./x <tool>`) opens and closes its
412
+ own session per call. A HOSTED session is not a served url (the World Host serves no `/__session/*`;
413
+ its `api.url` takes the session's bearer): act on it by id, `gateway worlds call <sessionId> <tool> --state --grade --close`.
414
414
 
415
415
  ## 7. Run and grade
416
416