@withgateway/sdk 0.6.0 → 0.9.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 (150) hide show
  1. package/dist/agents/index.d.mts +581 -0
  2. package/dist/agents/index.d.ts +581 -0
  3. package/dist/agents/index.js +1473 -0
  4. package/dist/agents/index.js.map +1 -0
  5. package/dist/agents/index.mjs +1424 -0
  6. package/dist/agents/index.mjs.map +1 -0
  7. package/dist/apiError-DHpfbmdx.d.mts +17 -0
  8. package/dist/apiError-DHpfbmdx.d.ts +17 -0
  9. package/dist/cli.js +11611 -6845
  10. package/dist/cli.js.map +1 -1
  11. package/dist/cli.mjs +10090 -5325
  12. package/dist/cli.mjs.map +1 -1
  13. package/dist/files/index.d.mts +3 -1
  14. package/dist/files/index.d.ts +3 -1
  15. package/dist/files/index.js +371 -102
  16. package/dist/files/index.js.map +1 -1
  17. package/dist/files/index.mjs +371 -102
  18. package/dist/files/index.mjs.map +1 -1
  19. package/dist/hooks/index.js +346 -136
  20. package/dist/hooks/index.js.map +1 -1
  21. package/dist/hooks/index.mjs +346 -136
  22. package/dist/hooks/index.mjs.map +1 -1
  23. package/dist/{index-LA-PMRJT.d.ts → index-DIN14Lhg.d.ts} +1 -1
  24. package/dist/{index-Di9nNqOY.d.mts → index-DuB-eQ0Z.d.mts} +1 -1
  25. package/dist/index.d.mts +7 -4
  26. package/dist/index.d.ts +7 -4
  27. package/dist/index.js +3177 -748
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +2987 -590
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/media-CQUC7TkS.d.mts +39 -0
  32. package/dist/media-DQnBloaX.d.ts +39 -0
  33. package/dist/traces/index.d.mts +3 -1
  34. package/dist/traces/index.d.ts +3 -1
  35. package/dist/traces/index.js +371 -102
  36. package/dist/traces/index.js.map +1 -1
  37. package/dist/traces/index.mjs +371 -102
  38. package/dist/traces/index.mjs.map +1 -1
  39. package/dist/tracing/index.d.mts +3 -2
  40. package/dist/tracing/index.d.ts +3 -2
  41. package/dist/tracing/index.js +257 -16
  42. package/dist/tracing/index.js.map +1 -1
  43. package/dist/tracing/index.mjs +257 -16
  44. package/dist/tracing/index.mjs.map +1 -1
  45. package/dist/transport-CpRe7zgd.d.mts +123 -0
  46. package/dist/transport-CpRe7zgd.d.ts +123 -0
  47. package/dist/worlds/index.d.mts +1986 -1746
  48. package/dist/worlds/index.d.ts +1986 -1746
  49. package/dist/worlds/index.js +1470 -290
  50. package/dist/worlds/index.js.map +1 -1
  51. package/dist/worlds/index.mjs +1465 -286
  52. package/dist/worlds/index.mjs.map +1 -1
  53. package/package.json +6 -1
  54. package/runtime/gatewaysdk/environment/bundle_manifest.py +531 -0
  55. package/runtime/gatewaysdk/environment/factory_documents.py +670 -0
  56. package/runtime/gatewaysdk/environment/factory_rules.py +973 -0
  57. package/runtime/gatewaysdk/environment/factory_shapes.py +253 -0
  58. package/runtime/gatewaysdk/environment/factory_spine.py +1155 -0
  59. package/runtime/gatewaysdk/environment/factory_spine_shapes.py +480 -0
  60. package/runtime/gatewaysdk/environment/schema/__main__.py +2 -2
  61. package/runtime/gatewaysdk/environment/schema/_slack_fidelity.py +8 -23
  62. package/runtime/gatewaysdk/environment/schema/admission.py +61 -59
  63. package/runtime/gatewaysdk/environment/schema/api.py +3 -4
  64. package/runtime/gatewaysdk/environment/schema/assertions.py +7 -1
  65. package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
  66. package/runtime/gatewaysdk/environment/schema/call_log.py +20 -0
  67. package/runtime/gatewaysdk/environment/schema/cast.py +133 -67
  68. package/runtime/gatewaysdk/environment/schema/compiler.py +16 -17
  69. package/runtime/gatewaysdk/environment/schema/database/base.py +2 -2
  70. package/runtime/gatewaysdk/environment/schema/handler_errors.py +58 -4
  71. package/runtime/gatewaysdk/environment/schema/host.py +94 -12
  72. package/runtime/gatewaysdk/environment/schema/host_browser.py +48 -0
  73. package/runtime/gatewaysdk/environment/schema/host_control.py +35 -2
  74. package/runtime/gatewaysdk/environment/schema/host_handoff.py +4 -1
  75. package/runtime/gatewaysdk/environment/schema/host_loops.py +27 -4
  76. package/runtime/gatewaysdk/environment/schema/host_metrics.py +69 -0
  77. package/runtime/gatewaysdk/environment/schema/host_requests.py +35 -0
  78. package/runtime/gatewaysdk/environment/schema/host_session.py +20 -2
  79. package/runtime/gatewaysdk/environment/schema/host_surfaces.py +6 -0
  80. package/runtime/gatewaysdk/environment/schema/host_versions.py +100 -19
  81. package/runtime/gatewaysdk/environment/schema/host_workers.py +172 -50
  82. package/runtime/gatewaysdk/environment/schema/ingest.py +12 -3
  83. package/runtime/gatewaysdk/environment/schema/journal.py +7 -2
  84. package/runtime/gatewaysdk/environment/schema/local.py +32 -7
  85. package/runtime/gatewaysdk/environment/schema/mapping.py +1 -1
  86. package/runtime/gatewaysdk/environment/schema/measured_tests.py +187 -0
  87. package/runtime/gatewaysdk/environment/schema/page_checks.py +123 -0
  88. package/runtime/gatewaysdk/environment/schema/platform.py +80 -270
  89. package/runtime/gatewaysdk/environment/schema/platform_query.py +4 -3
  90. package/runtime/gatewaysdk/environment/schema/platform_templates.py +420 -0
  91. package/runtime/gatewaysdk/environment/schema/process_memory.py +76 -0
  92. package/runtime/gatewaysdk/environment/schema/redaction.py +13 -0
  93. package/runtime/gatewaysdk/environment/schema/request_ledger.py +4 -1
  94. package/runtime/gatewaysdk/environment/schema/run_parameters.py +25 -0
  95. package/runtime/gatewaysdk/environment/schema/runtime.py +57 -5
  96. package/runtime/gatewaysdk/environment/schema/scaffold.py +386 -219
  97. package/runtime/gatewaysdk/environment/schema/session_files.py +13 -2
  98. package/runtime/gatewaysdk/environment/schema/shape_catalog.py +493 -0
  99. package/runtime/gatewaysdk/environment/schema/shape_declarations.py +219 -0
  100. package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
  101. package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +1 -1
  102. package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +2 -2
  103. package/runtime/gatewaysdk/environment/schema/skills/factory-orchestrator/SKILL.md +147 -0
  104. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +5 -1
  105. package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +8 -6
  106. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +9 -9
  107. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +33 -2
  108. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +6 -6
  109. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +17 -2
  110. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/new-world-sandbox.md +1 -1
  111. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/shape-catalog.md +59 -0
  112. package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/ui-map.md +3 -2
  113. package/runtime/gatewaysdk/environment/schema/slack.py +55 -10
  114. package/runtime/gatewaysdk/environment/schema/snapshot.py +28 -2
  115. package/runtime/gatewaysdk/environment/schema/tasks.py +25 -2
  116. package/runtime/gatewaysdk/environment/schema/template_record.py +131 -0
  117. package/runtime/gatewaysdk/environment/schema/tools_world.py +7 -5
  118. package/runtime/gatewaysdk/environment/schema/ui.py +54 -33
  119. package/runtime/gatewaysdk/environment/schema/ui_interactions.py +419 -0
  120. package/runtime/gatewaysdk/environment/schema/ui_recorder.js +895 -0
  121. package/runtime/gatewaysdk/environment/schema/ui_replay.py +366 -0
  122. package/runtime/gatewaysdk/environment/schema/ui_replay_record.LICENSE +25 -0
  123. package/runtime/gatewaysdk/environment/schema/ui_replay_record.js +109 -0
  124. package/runtime/gatewaysdk/environment/schema/validation.py +24 -1
  125. package/runtime/gatewaysdk/environment/schema/worker.py +12 -5
  126. package/runtime/gatewaysdk/environment/schema/worker_key.py +38 -0
  127. package/runtime/gatewaysdk/environment/schema/worker_peaks.py +38 -0
  128. package/runtime/gatewaysdk/environment/schema/worker_watch.py +50 -0
  129. package/runtime/gatewaysdk/environment/schema/workers.py +245 -69
  130. package/runtime/gatewaysdk/environment/schema/world_host.py +96 -73
  131. package/runtime/gatewaysdk/environment/schema/world_tests.py +3 -1
  132. package/runtime/gatewaysdk/environment/secret_values.py +1 -1
  133. package/runtime/gatewaysdk/environment/world.py +34 -43
  134. package/runtime/gatewaysdk/environment/world_session_contract.py +7 -34
  135. package/skills/benchmarks-getting-started/SKILL.md +1 -1
  136. package/skills/connector-schema-authoring/SKILL.md +2 -2
  137. package/skills/connector-schema-authoring/connector-worlds.md +3 -2
  138. package/skills/connector-schema-authoring/world-schema.md +36 -23
  139. package/skills/factory-orchestrator/SKILL.md +147 -0
  140. package/skills/world-data-ingestion/ROWS.md +5 -1
  141. package/skills/world-data-ingestion/SKILL.md +8 -6
  142. package/skills/worlds-getting-started/SKILL.md +9 -9
  143. package/skills/worlds-getting-started/references/cli-mcp-map.md +33 -2
  144. package/skills/worlds-getting-started/references/gotchas.md +6 -6
  145. package/skills/worlds-getting-started/references/journal-checks.md +17 -2
  146. package/skills/worlds-getting-started/references/new-world-sandbox.md +1 -1
  147. package/skills/worlds-getting-started/references/shape-catalog.md +59 -0
  148. package/skills/worlds-getting-started/references/ui-map.md +3 -2
  149. package/dist/media-BIApiPzS.d.mts +0 -102
  150. package/dist/media-BIApiPzS.d.ts +0 -102
@@ -15,11 +15,11 @@ from .database import WorldDatabase
15
15
  from .dependencies import Dependency
16
16
  from .grading import Grade, GraderError, TaskGrader
17
17
  from .journal import CallsView, WorldJournal
18
+ from .page_checks import PageCheck
18
19
  from .request_ledger import RequestOutbox
19
- from .webhooks import WebhookPoll
20
20
  from .served_names import ServedNames
21
21
  from .session_files import CALLS_JOURNAL, LEDGER_JOURNAL, SessionExport
22
- from .snapshot import SCENARIOS
22
+ from .snapshot import SCENARIO_GRADERS, SCENARIOS
23
23
  from .tasks import (
24
24
  TASK_DIR,
25
25
  TaskSpec,
@@ -30,7 +30,9 @@ from .tasks import (
30
30
  write_task_dir,
31
31
  )
32
32
  from .tools_world import DependencyWorld, ToolsWorld, ToolsWorldState, inline_task, served_with_dependencies
33
+ from .ui_interactions import UiRecorder
33
34
  from .validation import fail
35
+ from .webhooks import WebhookPoll
34
36
  from .workers import ConfinedVerifierSandbox
35
37
 
36
38
  if TYPE_CHECKING:
@@ -40,6 +42,8 @@ Restorer = Callable[[Callable[[SessionExport], None]], bool]
40
42
 
41
43
 
42
44
  class WorldRuntime(ABC):
45
+ takes_parameters = False
46
+
43
47
  def __init__(
44
48
  self,
45
49
  cached: CachedVersion,
@@ -49,8 +53,10 @@ class WorldRuntime(ABC):
49
53
  spec: TaskSpec | None,
50
54
  token: str | None,
51
55
  journaled: bool = False,
56
+ parameters: dict[str, str] | None = None,
52
57
  ) -> None:
53
58
  self.cached = cached
59
+ self.parameters = dict(parameters or {})
54
60
  self.session_dir = Path(session_dir)
55
61
  self.task = task
56
62
  self.task_spec = spec
@@ -71,6 +77,11 @@ class WorldRuntime(ABC):
71
77
  def authored_code(cls, cached: CachedVersion) -> str | None:
72
78
  """World-authored code ``cached`` runs, so only a version worker may open it; None when it runs none."""
73
79
 
80
+ @classmethod
81
+ @abstractmethod
82
+ def world_name(cls, cached: CachedVersion) -> str:
83
+ """The name ``cached`` gives its world, for what the host logs about it."""
84
+
74
85
  @classmethod
75
86
  def declared_dependencies(cls, cached: CachedVersion) -> dict[str, Dependency]:
76
87
  return {}
@@ -94,23 +105,38 @@ class WorldRuntime(ABC):
94
105
  token: str | None,
95
106
  dependencies: dict[str, DependencyWorld],
96
107
  restore: Restorer,
108
+ pages_vouched: bool,
97
109
  journaled: bool = False,
110
+ parameters: dict[str, str] | None = None,
98
111
  ) -> WorldRuntime:
99
112
  """``journaled`` keeps the calls on disk, so a version worker that dies leaves them to the next one."""
100
- runtime = cached.runtime_class(cached, session_dir, task=task, spec=spec, token=token, journaled=journaled)
113
+ if parameters and not cached.runtime_class.takes_parameters:
114
+ fail("host", f"version {cached.version_id} is an api bundle, which takes no runtime parameters")
115
+ runtime = cached.runtime_class(
116
+ cached, session_dir, task=task, spec=spec, token=token, journaled=journaled, parameters=parameters
117
+ )
101
118
  runtime._start(dependencies)
102
119
  try:
103
120
  if spec is not None:
104
121
  runtime._check_task_entities(spec)
122
+ runtime._check_page_checks(spec)
105
123
  write_task_dir(spec, runtime.session_dir)
106
124
  runtime._to_start()
107
125
  runtime.restored = restore(runtime.restore)
126
+ runtime._note_pages(pages_vouched)
108
127
  runtime._attach_app()
109
128
  except BaseException:
110
129
  runtime.close()
111
130
  raise
112
131
  return runtime
113
132
 
133
+ def _note_pages(self, vouched: bool) -> None:
134
+ """A first open notes that this host records the pages; a restore from an export no recording host took
135
+ notes that an earlier life may have gone unrecorded. A restore a recording host vouched for adds nothing."""
136
+ if self.cached.ui is None or (self.restored and vouched):
137
+ return
138
+ (UiRecorder.unrecorded if self.restored else UiRecorder.recording)(self.calls)
139
+
114
140
  def _attach_app(self) -> None:
115
141
  cached = self.cached
116
142
  if cached.spec is None:
@@ -142,6 +168,18 @@ class WorldRuntime(ABC):
142
168
  "/task",
143
169
  )
144
170
 
171
+ def _check_page_checks(self, spec: TaskSpec) -> None:
172
+ """A check on the page of a world that serves none could never be decided."""
173
+ named = [
174
+ check.get("id") or check["entity"] for check in spec.grader_checks() if PageCheck(check).names_the_page
175
+ ]
176
+ if named and self.cached.ui is None:
177
+ fail(
178
+ "task",
179
+ f"the task's checks {', '.join(named)} read the page, and this world serves none",
180
+ "/task/grader",
181
+ )
182
+
145
183
  @abstractmethod
146
184
  def _start(self, dependencies: dict[str, DependencyWorld]) -> None:
147
185
  """A failure here leaves nothing to close: :meth:`open` runs it outside its cleanup."""
@@ -329,6 +367,8 @@ class WorldRuntime(ABC):
329
367
 
330
368
 
331
369
  class TreeRuntime(WorldRuntime):
370
+ takes_parameters = True
371
+
332
372
  world: ToolsWorld
333
373
 
334
374
  @classmethod
@@ -340,6 +380,11 @@ class TreeRuntime(WorldRuntime):
340
380
  def authored_code(cls, cached: CachedVersion) -> str:
341
381
  return "schema world handlers"
342
382
 
383
+ @classmethod
384
+ def world_name(cls, cached: CachedVersion) -> str:
385
+ assert cached.tools is not None
386
+ return cached.tools.manifest.name
387
+
343
388
  @classmethod
344
389
  def declared_dependencies(cls, cached: CachedVersion) -> dict[str, Dependency]:
345
390
  assert cached.tools is not None
@@ -366,10 +411,13 @@ class TreeRuntime(WorldRuntime):
366
411
  allowed=self.allowed,
367
412
  dependencies=dependencies,
368
413
  calls=self.calls,
414
+ parameters=self.parameters,
369
415
  )
370
416
  return
371
417
  assert self.task is not None
372
- self.world = ToolsWorld(tools, self.session_dir, self.task, dependencies=dependencies, calls=self.calls)
418
+ self.world = ToolsWorld(
419
+ tools, self.session_dir, self.task, dependencies=dependencies, calls=self.calls, parameters=self.parameters
420
+ )
373
421
 
374
422
  def _app_state(self) -> ToolsWorldState:
375
423
  return ToolsWorldState(self.world, self.cached.tree)
@@ -484,6 +532,10 @@ class SnapshotRuntime(WorldRuntime):
484
532
  return None
485
533
  return f"api handlers module {cached.settings.handlers.name}"
486
534
 
535
+ @classmethod
536
+ def world_name(cls, cached: CachedVersion) -> str:
537
+ return cached.spec.slug if cached.spec is not None else cached.version_id
538
+
487
539
  @staticmethod
488
540
  def live_state(session_dir: Path) -> Path:
489
541
  return HostWorldState.live_state(session_dir)
@@ -558,7 +610,7 @@ class SnapshotRuntime(WorldRuntime):
558
610
  def _bundled_verifier(self) -> Path | None:
559
611
  assert self.task is not None
560
612
  scenario = scenario_dir(self.cached.bundle, self.cached.tree, self.task)
561
- return scenario / "checks" / "verify.py" if scenario else None
613
+ return scenario / SCENARIO_GRADERS / "verify.py" if scenario else None
562
614
 
563
615
  def call(self, tool: str, args: dict) -> dict:
564
616
  ServedNames.of((), self.cached.spec).refuse(tool)