@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.
- package/dist/agents/index.d.mts +581 -0
- package/dist/agents/index.d.ts +581 -0
- package/dist/agents/index.js +1473 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/index.mjs +1424 -0
- package/dist/agents/index.mjs.map +1 -0
- package/dist/apiError-DHpfbmdx.d.mts +17 -0
- package/dist/apiError-DHpfbmdx.d.ts +17 -0
- package/dist/cli.js +11611 -6845
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +10090 -5325
- package/dist/cli.mjs.map +1 -1
- package/dist/files/index.d.mts +3 -1
- package/dist/files/index.d.ts +3 -1
- package/dist/files/index.js +371 -102
- package/dist/files/index.js.map +1 -1
- package/dist/files/index.mjs +371 -102
- package/dist/files/index.mjs.map +1 -1
- package/dist/hooks/index.js +346 -136
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +346 -136
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-LA-PMRJT.d.ts → index-DIN14Lhg.d.ts} +1 -1
- package/dist/{index-Di9nNqOY.d.mts → index-DuB-eQ0Z.d.mts} +1 -1
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +3177 -748
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2987 -590
- package/dist/index.mjs.map +1 -1
- package/dist/media-CQUC7TkS.d.mts +39 -0
- package/dist/media-DQnBloaX.d.ts +39 -0
- package/dist/traces/index.d.mts +3 -1
- package/dist/traces/index.d.ts +3 -1
- package/dist/traces/index.js +371 -102
- package/dist/traces/index.js.map +1 -1
- package/dist/traces/index.mjs +371 -102
- package/dist/traces/index.mjs.map +1 -1
- package/dist/tracing/index.d.mts +3 -2
- package/dist/tracing/index.d.ts +3 -2
- package/dist/tracing/index.js +257 -16
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +257 -16
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/transport-CpRe7zgd.d.mts +123 -0
- package/dist/transport-CpRe7zgd.d.ts +123 -0
- package/dist/worlds/index.d.mts +1986 -1746
- package/dist/worlds/index.d.ts +1986 -1746
- package/dist/worlds/index.js +1470 -290
- package/dist/worlds/index.js.map +1 -1
- package/dist/worlds/index.mjs +1465 -286
- package/dist/worlds/index.mjs.map +1 -1
- package/package.json +6 -1
- package/runtime/gatewaysdk/environment/bundle_manifest.py +531 -0
- package/runtime/gatewaysdk/environment/factory_documents.py +670 -0
- package/runtime/gatewaysdk/environment/factory_rules.py +973 -0
- package/runtime/gatewaysdk/environment/factory_shapes.py +253 -0
- package/runtime/gatewaysdk/environment/factory_spine.py +1155 -0
- package/runtime/gatewaysdk/environment/factory_spine_shapes.py +480 -0
- package/runtime/gatewaysdk/environment/schema/__main__.py +2 -2
- package/runtime/gatewaysdk/environment/schema/_slack_fidelity.py +8 -23
- package/runtime/gatewaysdk/environment/schema/admission.py +61 -59
- package/runtime/gatewaysdk/environment/schema/api.py +3 -4
- package/runtime/gatewaysdk/environment/schema/assertions.py +7 -1
- package/runtime/gatewaysdk/environment/schema/bundle_runtime.py +1 -0
- package/runtime/gatewaysdk/environment/schema/call_log.py +20 -0
- package/runtime/gatewaysdk/environment/schema/cast.py +133 -67
- package/runtime/gatewaysdk/environment/schema/compiler.py +16 -17
- package/runtime/gatewaysdk/environment/schema/database/base.py +2 -2
- package/runtime/gatewaysdk/environment/schema/handler_errors.py +58 -4
- package/runtime/gatewaysdk/environment/schema/host.py +94 -12
- package/runtime/gatewaysdk/environment/schema/host_browser.py +48 -0
- package/runtime/gatewaysdk/environment/schema/host_control.py +35 -2
- package/runtime/gatewaysdk/environment/schema/host_handoff.py +4 -1
- package/runtime/gatewaysdk/environment/schema/host_loops.py +27 -4
- package/runtime/gatewaysdk/environment/schema/host_metrics.py +69 -0
- package/runtime/gatewaysdk/environment/schema/host_requests.py +35 -0
- package/runtime/gatewaysdk/environment/schema/host_session.py +20 -2
- package/runtime/gatewaysdk/environment/schema/host_surfaces.py +6 -0
- package/runtime/gatewaysdk/environment/schema/host_versions.py +100 -19
- package/runtime/gatewaysdk/environment/schema/host_workers.py +172 -50
- package/runtime/gatewaysdk/environment/schema/ingest.py +12 -3
- package/runtime/gatewaysdk/environment/schema/journal.py +7 -2
- package/runtime/gatewaysdk/environment/schema/local.py +32 -7
- package/runtime/gatewaysdk/environment/schema/mapping.py +1 -1
- package/runtime/gatewaysdk/environment/schema/measured_tests.py +187 -0
- package/runtime/gatewaysdk/environment/schema/page_checks.py +123 -0
- package/runtime/gatewaysdk/environment/schema/platform.py +80 -270
- package/runtime/gatewaysdk/environment/schema/platform_query.py +4 -3
- package/runtime/gatewaysdk/environment/schema/platform_templates.py +420 -0
- package/runtime/gatewaysdk/environment/schema/process_memory.py +76 -0
- package/runtime/gatewaysdk/environment/schema/redaction.py +13 -0
- package/runtime/gatewaysdk/environment/schema/request_ledger.py +4 -1
- package/runtime/gatewaysdk/environment/schema/run_parameters.py +25 -0
- package/runtime/gatewaysdk/environment/schema/runtime.py +57 -5
- package/runtime/gatewaysdk/environment/schema/scaffold.py +386 -219
- package/runtime/gatewaysdk/environment/schema/session_files.py +13 -2
- package/runtime/gatewaysdk/environment/schema/shape_catalog.py +493 -0
- package/runtime/gatewaysdk/environment/schema/shape_declarations.py +219 -0
- package/runtime/gatewaysdk/environment/schema/skill.py +1 -0
- package/runtime/gatewaysdk/environment/schema/skills/benchmarks-getting-started/SKILL.md +1 -1
- package/runtime/gatewaysdk/environment/schema/skills/connector-schema-authoring/SKILL.md +2 -2
- package/runtime/gatewaysdk/environment/schema/skills/factory-orchestrator/SKILL.md +147 -0
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/ROWS.md +5 -1
- package/runtime/gatewaysdk/environment/schema/skills/world-data-ingestion/SKILL.md +8 -6
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/SKILL.md +9 -9
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/cli-mcp-map.md +33 -2
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/gotchas.md +6 -6
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/journal-checks.md +17 -2
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/new-world-sandbox.md +1 -1
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/shape-catalog.md +59 -0
- package/runtime/gatewaysdk/environment/schema/skills/worlds-getting-started/references/ui-map.md +3 -2
- package/runtime/gatewaysdk/environment/schema/slack.py +55 -10
- package/runtime/gatewaysdk/environment/schema/snapshot.py +28 -2
- package/runtime/gatewaysdk/environment/schema/tasks.py +25 -2
- package/runtime/gatewaysdk/environment/schema/template_record.py +131 -0
- package/runtime/gatewaysdk/environment/schema/tools_world.py +7 -5
- package/runtime/gatewaysdk/environment/schema/ui.py +54 -33
- package/runtime/gatewaysdk/environment/schema/ui_interactions.py +419 -0
- package/runtime/gatewaysdk/environment/schema/ui_recorder.js +895 -0
- package/runtime/gatewaysdk/environment/schema/ui_replay.py +366 -0
- package/runtime/gatewaysdk/environment/schema/ui_replay_record.LICENSE +25 -0
- package/runtime/gatewaysdk/environment/schema/ui_replay_record.js +109 -0
- package/runtime/gatewaysdk/environment/schema/validation.py +24 -1
- package/runtime/gatewaysdk/environment/schema/worker.py +12 -5
- package/runtime/gatewaysdk/environment/schema/worker_key.py +38 -0
- package/runtime/gatewaysdk/environment/schema/worker_peaks.py +38 -0
- package/runtime/gatewaysdk/environment/schema/worker_watch.py +50 -0
- package/runtime/gatewaysdk/environment/schema/workers.py +245 -69
- package/runtime/gatewaysdk/environment/schema/world_host.py +96 -73
- package/runtime/gatewaysdk/environment/schema/world_tests.py +3 -1
- package/runtime/gatewaysdk/environment/secret_values.py +1 -1
- package/runtime/gatewaysdk/environment/world.py +34 -43
- package/runtime/gatewaysdk/environment/world_session_contract.py +7 -34
- package/skills/benchmarks-getting-started/SKILL.md +1 -1
- package/skills/connector-schema-authoring/SKILL.md +2 -2
- package/skills/connector-schema-authoring/connector-worlds.md +3 -2
- package/skills/connector-schema-authoring/world-schema.md +36 -23
- package/skills/factory-orchestrator/SKILL.md +147 -0
- package/skills/world-data-ingestion/ROWS.md +5 -1
- package/skills/world-data-ingestion/SKILL.md +8 -6
- package/skills/worlds-getting-started/SKILL.md +9 -9
- package/skills/worlds-getting-started/references/cli-mcp-map.md +33 -2
- package/skills/worlds-getting-started/references/gotchas.md +6 -6
- package/skills/worlds-getting-started/references/journal-checks.md +17 -2
- package/skills/worlds-getting-started/references/new-world-sandbox.md +1 -1
- package/skills/worlds-getting-started/references/shape-catalog.md +59 -0
- package/skills/worlds-getting-started/references/ui-map.md +3 -2
- package/dist/media-BIApiPzS.d.mts +0 -102
- 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
|
-
|
|
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(
|
|
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 /
|
|
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)
|