synth-code 0.0.1__py3-none-macosx_15_0_arm64.whl

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 (110) hide show
  1. synth_code/__init__.py +0 -0
  2. synth_code/account.py +551 -0
  3. synth_code/account_http.py +86 -0
  4. synth_code/account_refusal.py +80 -0
  5. synth_code/accounting.py +148 -0
  6. synth_code/activity_grouping.py +149 -0
  7. synth_code/agent_panels.py +127 -0
  8. synth_code/approvals.py +397 -0
  9. synth_code/blobs.py +31 -0
  10. synth_code/cli.py +734 -0
  11. synth_code/client.py +413 -0
  12. synth_code/composer_delivery.py +139 -0
  13. synth_code/conversation.py +949 -0
  14. synth_code/daemon.py +34 -0
  15. synth_code/edition.py +306 -0
  16. synth_code/enrollment.py +304 -0
  17. synth_code/file_edit_facts.py +10 -0
  18. synth_code/freeze.py +234 -0
  19. synth_code/grant.py +59 -0
  20. synth_code/history.py +140 -0
  21. synth_code/history_generated.py +219 -0
  22. synth_code/history_wire.py +166 -0
  23. synth_code/image_input.py +109 -0
  24. synth_code/image_preview.py +105 -0
  25. synth_code/legacy_history.py +161 -0
  26. synth_code/live_turns.py +171 -0
  27. synth_code/model_picker.py +311 -0
  28. synth_code/native/manifest.json +1 -0
  29. synth_code/native/synth-code-runtime +0 -0
  30. synth_code/native.py +95 -0
  31. synth_code/oauth.py +284 -0
  32. synth_code/operator.py +116 -0
  33. synth_code/pack_source.py +65 -0
  34. synth_code/panel_request.py +291 -0
  35. synth_code/panels.py +40 -0
  36. synth_code/plugin_host.py +459 -0
  37. synth_code/protocol.py +35 -0
  38. synth_code/provider.py +313 -0
  39. synth_code/provider_fault.py +173 -0
  40. synth_code/provider_frames.py +571 -0
  41. synth_code/recommendation.py +324 -0
  42. synth_code/report.py +72 -0
  43. synth_code/research_events.py +44 -0
  44. synth_code/research_trace.py +449 -0
  45. synth_code/rex_view.py +58 -0
  46. synth_code/runtime_refusal.py +108 -0
  47. synth_code/schema/budgets.json +17 -0
  48. synth_code/schema/history-v2.json +1002 -0
  49. synth_code/session.py +291 -0
  50. synth_code/shoal.py +564 -0
  51. synth_code/side_panel.py +309 -0
  52. synth_code/skills.py +269 -0
  53. synth_code/slash.py +425 -0
  54. synth_code/source_view.py +135 -0
  55. synth_code/starter.json +13 -0
  56. synth_code/stdio.py +75 -0
  57. synth_code/stream.py +142 -0
  58. synth_code/subscriptions.py +267 -0
  59. synth_code/synth_authority.py +362 -0
  60. synth_code/synth_extra.py +32 -0
  61. synth_code/terminal.py +817 -0
  62. synth_code/terminal_journal.py +284 -0
  63. synth_code/terminal_layout.py +643 -0
  64. synth_code/terminal_surfaces.py +470 -0
  65. synth_code/terminal_viewport.py +125 -0
  66. synth_code/tool_render.py +86 -0
  67. synth_code/transcript_frames.py +212 -0
  68. synth_code/transcript_placement.py +63 -0
  69. synth_code/transcript_rows.py +456 -0
  70. synth_code/transport.py +243 -0
  71. synth_code/v001_history.py +468 -0
  72. synth_code/view.py +854 -0
  73. synth_code/views/__init__.py +93 -0
  74. synth_code/views/charts.py +196 -0
  75. synth_code/views/curses_adapter.py +116 -0
  76. synth_code/views/engine.py +170 -0
  77. synth_code/views/model.py +226 -0
  78. synth_code/views/primitives.py +270 -0
  79. synth_code/views/tiling.py +124 -0
  80. synth_code-0.0.1.dist-info/METADATA +50 -0
  81. synth_code-0.0.1.dist-info/RECORD +110 -0
  82. synth_code-0.0.1.dist-info/WHEEL +5 -0
  83. synth_code-0.0.1.dist-info/entry_points.txt +6 -0
  84. synth_code-0.0.1.dist-info/licenses/temper/LICENSE-APACHE +190 -0
  85. synth_code-0.0.1.dist-info/licenses/temper/LICENSE-MIT +21 -0
  86. synth_code-0.0.1.dist-info/licenses/temper/SOURCE.json +433 -0
  87. synth_code-0.0.1.dist-info/top_level.txt +2 -0
  88. synth_code_plugins/_sdk/__init__.py +19 -0
  89. synth_code_plugins/_sdk/callback_wire.py +240 -0
  90. synth_code_plugins/_sdk/callbacks.py +317 -0
  91. synth_code_plugins/_sdk/compliance.py +51 -0
  92. synth_code_plugins/_sdk/contracts.py +236 -0
  93. synth_code_plugins/_sdk/discovery.py +75 -0
  94. synth_code_plugins/_sdk/job_binding.py +71 -0
  95. synth_code_plugins/_sdk/lifecycle.py +50 -0
  96. synth_code_plugins/_sdk/lifecycle_generated.py +15 -0
  97. synth_code_plugins/_sdk/manifest.py +269 -0
  98. synth_code_plugins/_sdk/pack.py +332 -0
  99. synth_code_plugins/_sdk/push.py +98 -0
  100. synth_code_plugins/_sdk/records.py +26 -0
  101. synth_code_plugins/_sdk/registry.py +491 -0
  102. synth_code_plugins/_sdk/schemas.py +210 -0
  103. synth_code_plugins/_sdk/sources.py +230 -0
  104. synth_code_plugins/_sdk/surfaces.py +54 -0
  105. synth_code_plugins/_sdk/tools.py +172 -0
  106. synth_code_plugins/_sdk/worker_memory.py +49 -0
  107. synth_code_plugins/core/SKILL.md +6 -0
  108. synth_code_plugins/core/__init__.py +21 -0
  109. synth_code_plugins/core/plugin.toml +44 -0
  110. synth_code_plugins/core/source.py +18 -0
@@ -0,0 +1,459 @@
1
+ """Translate bounded gateway surface projections into the shared view engine."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterable, Mapping, Sequence
6
+ from dataclasses import dataclass, field
7
+ from itertools import islice
8
+ from typing import Any
9
+
10
+ from synth_code_plugins._sdk.contracts import JsonObject
11
+ from synth_code_plugins._sdk.pack import Pack
12
+ from synth_code_plugins._sdk.schemas import SchemaCatalog
13
+ from synth_code_plugins._sdk.tools import PackLoadError
14
+ from synth_code_plugins._sdk.tools import packs as bundled_packs
15
+
16
+ from .transcript_rows import RowOverlay
17
+ from .views import (
18
+ Cursor,
19
+ CursorBinding,
20
+ Density,
21
+ Extent,
22
+ Health,
23
+ Layout,
24
+ RenderContext,
25
+ Slot,
26
+ SourceSnapshot,
27
+ Tiling,
28
+ ViewEngine,
29
+ ViewFrame,
30
+ ViewMount,
31
+ )
32
+ from .views.primitives import Payload, render_content
33
+
34
+ # The native layout bounds mounts and authored pins independently of receipt pins.
35
+ _MAX_SOURCES = 32 + 32 + 32
36
+ _MAX_MOUNTS = 32
37
+ _MAX_PINS = 128
38
+ _MAX_RECEIPT_PINS = 32
39
+ _MAX_PACKS = 16
40
+
41
+
42
+ def _object(value: object) -> dict[str, Any]:
43
+ if not isinstance(value, dict):
44
+ raise TypeError("Expected a surface object")
45
+ return value
46
+
47
+
48
+ def _identity(value: object) -> str:
49
+ if not isinstance(value, str) or not 0 < len(value) <= 128:
50
+ raise ValueError("Invalid surface identity")
51
+ return value
52
+
53
+
54
+ def _tool_identity(value: object) -> str:
55
+ if not isinstance(value, str) or not 0 < len(value.encode()) <= 256:
56
+ raise ValueError("Invalid tool pin identity")
57
+ return value
58
+
59
+
60
+ def _sequence(value: object) -> int:
61
+ if type(value) is not int or value < 0:
62
+ raise ValueError("Invalid surface sequence")
63
+ return value
64
+
65
+
66
+ def _binding(value: object) -> CursorBinding | None:
67
+ return (
68
+ None if value is None else CursorBinding(_identity(_object(value)["channel"]))
69
+ )
70
+
71
+
72
+ @dataclass(slots=True)
73
+ class Source:
74
+ pack: Pack
75
+ catalog: SchemaCatalog
76
+ schema: str
77
+ max_payload_bytes: int
78
+ sequence: int = 0
79
+ fact_sequence: int = 0
80
+ health: Health = Health.UNAVAILABLE
81
+ fact: JsonObject = field(default_factory=dict)
82
+ live: JsonObject = field(default_factory=dict)
83
+ revision: int | None = None
84
+ tail: str = ""
85
+ next_offset: int = 0
86
+
87
+ def validate(self, identity: str, payload: object) -> JsonObject:
88
+ data = _object(payload)
89
+ self.catalog.encode(self.schema, identity, data, self.max_payload_bytes)
90
+ return data
91
+
92
+ def retain(self, value: str, offset: int) -> None:
93
+ self.tail = value.encode("utf-8")[-4096:].decode("utf-8", "ignore")
94
+ self.next_offset = offset
95
+
96
+ def reset_live(self) -> None:
97
+ self.health = Health.STALE if self.fact else Health.UNAVAILABLE
98
+ self.live = {}
99
+ self.revision = None
100
+ self.tail = ""
101
+ self.next_offset = 0
102
+
103
+ def snapshot(self) -> SourceSnapshot:
104
+ live = self.live
105
+ if self.tail:
106
+ live = live | {"logs": self.tail.splitlines()[-32:]}
107
+ return SourceSnapshot(
108
+ self.sequence, Payload(self.pack.manifest.id, self.fact, live), self.health
109
+ )
110
+
111
+
112
+ @dataclass(frozen=True, slots=True)
113
+ class PinPositions:
114
+ """Map rows through the inline pills inserted after visible tool anchors."""
115
+
116
+ inserted: tuple[tuple[int, int], ...] = ()
117
+
118
+ def base_row(self, visible_row: int) -> tuple[int, int]:
119
+ shift = 0
120
+ for anchor, count in self.inserted:
121
+ if visible_row <= anchor + shift:
122
+ break
123
+ if visible_row <= anchor + shift + count:
124
+ return anchor, visible_row - anchor - shift
125
+ shift += count
126
+ return visible_row - shift, 0
127
+
128
+ def visible_row(self, base_row: int, pill: int = 0) -> int:
129
+ shift = 0
130
+ for anchor, count in self.inserted:
131
+ if anchor == base_row:
132
+ return base_row + shift + min(pill, count)
133
+ if anchor > base_row:
134
+ break
135
+ shift += count
136
+ return base_row + shift
137
+
138
+
139
+ class SurfaceHost:
140
+ """Consumes subscriptions without querying the journal or owning any layout state."""
141
+
142
+ def __init__(
143
+ self, packs: Iterable[Pack] | None = None, *, run: str | None = None
144
+ ) -> None:
145
+ self.run = run
146
+ self.failures: list[PackLoadError] = []
147
+ self.packs = (
148
+ bundled_packs(failed=self.failures)
149
+ if packs is None
150
+ else {pack.manifest.id: pack for pack in islice(packs, _MAX_PACKS)}
151
+ )
152
+ self._renderers = {
153
+ view.id: self._render(pack, view.id)
154
+ for pack in self.packs.values()
155
+ for view in pack.manifest.views
156
+ }
157
+ self.engine = ViewEngine(self._renderers)
158
+ self.sources: dict[str, Source] = {}
159
+ self.layout = Layout(0, Tiling.BALANCED, ())
160
+ self.mount_ids: dict[str, ViewMount] = {}
161
+ self.focus: str | None = None
162
+ self.approval_pending = False
163
+ self.pins: tuple[tuple[str | None, str, str, str], ...] = ()
164
+ self._receipt_pins: dict[tuple[str, str], tuple[str, str, str, str]] = {}
165
+ self.generation = 0
166
+ self.activity_groups: tuple[dict[str, Any], ...] = ()
167
+
168
+ @staticmethod
169
+ def _render(pack: Pack, view_id: str):
170
+ def render(content: Payload, context: RenderContext):
171
+ if content.plugin != pack.manifest.id:
172
+ raise ValueError("Mounted view belongs to a different pack")
173
+ return render_content(
174
+ pack.present(view_id, content.fact, content.live, context.selected_key),
175
+ context,
176
+ )
177
+
178
+ return render
179
+
180
+ def set_layout(self, value: object) -> None:
181
+ state = _object(value)
182
+ revision = _sequence(state["revision"])
183
+ if revision < self.layout.revision:
184
+ return
185
+ layout = _object(state["layout"])
186
+ mounts: dict[str, ViewMount] = {}
187
+ for raw in islice(layout["mounts"], _MAX_MOUNTS):
188
+ mount = _object(raw)
189
+ mounts[_identity(mount["id"])] = ViewMount(
190
+ _identity(mount["view_id"]),
191
+ _identity(mount["source_id"]),
192
+ Slot(mount["slot"]),
193
+ Density(mount["density"]),
194
+ consumes=_binding(mount.get("consumes")),
195
+ emits=_binding(mount.get("emits")),
196
+ )
197
+ cursors = tuple(
198
+ Cursor(_identity(channel), _identity(key))
199
+ for channel, key in islice(_object(layout["cursors"]).items(), 64)
200
+ )
201
+ pins = tuple(
202
+ (
203
+ pin.get("turn"),
204
+ _tool_identity(pin["tool_id"]),
205
+ _identity(pin["source_id"]),
206
+ _identity(pin["view_id"]),
207
+ )
208
+ for pin in map(
209
+ _object, islice(layout.get("pins", state.get("pins", ())), _MAX_PINS)
210
+ )
211
+ if self.run is None or pin.get("run") == self.run
212
+ )
213
+ self.activity_groups = tuple(
214
+ item
215
+ for item in map(_object, islice(layout.get("activity_groups", ()), 32))
216
+ if self.run is None or item.get("run", self.run) == self.run
217
+ )
218
+ self.layout = Layout(
219
+ revision, Tiling(layout["tiling"]), tuple(mounts.values()), cursors
220
+ )
221
+ self.mount_ids = mounts
222
+ self.pins = pins
223
+ focus = _object(state.get("effective_focus", layout["focus"]))
224
+ self.approval_pending = focus.get("kind") == "approval"
225
+ self.focus = focus.get("mount") if focus.get("kind") == "mount" else None
226
+ self.generation += 1
227
+
228
+ def pin_bindings(self) -> tuple[tuple[str | None, str, str, str], ...]:
229
+ return tuple(dict.fromkeys((*self.pins, *self._receipt_pins.values())))
230
+
231
+ def seed_receipt_pins(self, pins) -> None:
232
+ self._receipt_pins.clear()
233
+ for pin in islice(pins, _MAX_RECEIPT_PINS):
234
+ self._receipt_pin(_identity(pin["turn"]), _tool_identity(pin["tool_id"]), pin)
235
+ self.generation += 1
236
+
237
+ def _receipt_pin(self, turn: str, tool: str, pin: dict[str, Any]) -> None:
238
+ identity = (turn, tool)
239
+ previous = self._receipt_pins.get(identity)
240
+ binding = (turn, tool, _identity(pin["source_id"]), _identity(pin["view_id"]))
241
+ if previous == binding:
242
+ return
243
+ if previous is not None:
244
+ raise ValueError("Committed tool pin changed")
245
+ self._receipt_pins[identity] = binding
246
+ if len(self._receipt_pins) > _MAX_RECEIPT_PINS:
247
+ del self._receipt_pins[next(iter(self._receipt_pins))]
248
+ self.generation += 1
249
+
250
+ def registration(self, payload: dict[str, Any]) -> Source | None:
251
+ identity = _identity(payload["source"])
252
+ pack = self.packs.get(payload["plugin"])
253
+ if pack is None:
254
+ return None
255
+ if identity in self.sources:
256
+ return self.sources[identity]
257
+ expected = next(
258
+ (
259
+ spec
260
+ for spec in pack.manifest.sources
261
+ if (spec.dialect, spec.dialect_version, spec.schema_ref)
262
+ == (
263
+ payload["dialect"],
264
+ payload["dialect_version"],
265
+ payload["schema_ref"],
266
+ )
267
+ ),
268
+ None,
269
+ )
270
+ if expected is None:
271
+ return None
272
+ if len(self.sources) >= _MAX_SOURCES:
273
+ retained = {mount.source_id for mount in self.layout.mounts}
274
+ retained.update(source for _, _, source, _ in self.pin_bindings())
275
+ evict = next((known for known in self.sources if known not in retained), None)
276
+ if evict is None:
277
+ return None
278
+ del self.sources[evict]
279
+ source = Source(
280
+ pack,
281
+ SchemaCatalog(pack.manifest.id, pack.schemas),
282
+ expected.schema_ref,
283
+ expected.bounds.max_payload_bytes,
284
+ )
285
+ if payload.get("transport") == "journal":
286
+ source.health = Health.CONNECTED
287
+ self.sources[identity] = source
288
+ return source
289
+
290
+ def snapshot(self, value: object) -> None:
291
+ result = _object(value)
292
+ registration = _object(result["registration"])
293
+ source = self.registration(registration)
294
+ if source is None:
295
+ return
296
+ identity = registration["source"]
297
+ # A pushed change can arrive while the snapshot request is in flight.
298
+ # Monotonic stream revisions ensure old snapshots cannot overwrite it.
299
+ live = _object(result["live"])
300
+ try:
301
+ latest_fact = _object(result.get("facts", {})).get("state")
302
+ if (
303
+ latest_fact is not None
304
+ and _sequence(latest_fact["seq"]) >= source.fact_sequence
305
+ ):
306
+ source.fact = source.validate(identity, latest_fact["fact"]["payload"])
307
+ source.fact_sequence = latest_fact["seq"]
308
+ source.sequence = max(source.sequence, source.fact_sequence)
309
+ status = _object(live["streams"]).get("status")
310
+ if status is not None:
311
+ self._latest(source, identity, _object(status))
312
+ logs = _object(live["streams"]).get("logs")
313
+ if (
314
+ logs is not None
315
+ and _sequence(logs["next_offset"]) >= source.next_offset
316
+ ):
317
+ source.retain(logs["tail"], logs["next_offset"])
318
+ source.health = Health(live["health"])
319
+ except (KeyError, TypeError, ValueError):
320
+ source.health = Health.ERROR
321
+ self.generation += 1
322
+
323
+ def event(self, event: dict[str, Any]) -> None:
324
+ kind = event["kind"]
325
+ if kind == "tool.finished" and (pin := event["payload"].get("pin")) is not None:
326
+ self._receipt_pin(_identity(event["turn"]), _tool_identity(event["payload"]["tool_id"]), _object(pin))
327
+ if kind not in {"source.registered", "source.fact"}:
328
+ return
329
+ self._source_event(kind, _object(event["payload"]), _sequence(event["seq"]))
330
+
331
+ def live(self, body: dict[str, Any]) -> None:
332
+ kind = body.get("kind")
333
+ if kind in {"source.health", "source.frame"}:
334
+ self._source_event(kind, body, 0)
335
+
336
+ def _source_event(self, kind: str, body: dict[str, Any], sequence: int) -> None:
337
+ identity = body.get("source")
338
+ if not isinstance(identity, str):
339
+ return
340
+ source = self.sources.get(identity)
341
+ try:
342
+ if kind == "source.registered":
343
+ source = self.registration(body)
344
+ elif source is not None:
345
+ if kind == "source.fact" and sequence > source.fact_sequence:
346
+ source.fact = source.validate(identity, body["payload"])
347
+ source.fact_sequence = sequence
348
+ elif kind == "source.fact":
349
+ return
350
+ elif kind == "source.health":
351
+ source.health = Health(body["state"])
352
+ else:
353
+ self._frame(source, identity, _object(body["frame"]))
354
+ if source is not None:
355
+ source.sequence = max(source.sequence + 1, sequence)
356
+ except (KeyError, TypeError, ValueError):
357
+ if source is not None:
358
+ source.health = Health.ERROR
359
+ self.generation += 1
360
+
361
+ @staticmethod
362
+ def _latest(source: Source, identity: str, frame: dict[str, Any]) -> None:
363
+ revision = _sequence(frame["revision"])
364
+ if source.revision is None or revision > source.revision:
365
+ source.live = source.validate(identity, frame["payload"])
366
+ source.revision = revision
367
+
368
+ def _frame(self, source: Source, identity: str, frame: dict[str, Any]) -> None:
369
+ if frame.get("mode") == "latest_value":
370
+ self._latest(source, identity, frame)
371
+ elif frame.get("mode") == "offset_append":
372
+ offset = _sequence(frame["offset"])
373
+ text = frame["payload"]
374
+ if not isinstance(text, str):
375
+ raise ValueError("Invalid source log chunk")
376
+ next_offset = offset + len(text.encode("utf-8"))
377
+ if offset == source.next_offset:
378
+ source.retain(source.tail + text, next_offset)
379
+ elif next_offset > source.next_offset:
380
+ source.health = Health.STALE
381
+
382
+ def disconnected(self) -> None:
383
+ for source in self.sources.values():
384
+ source.reset_live()
385
+ self.generation += 1
386
+
387
+ def render(self, columns: int, regions: dict[Slot, Extent]) -> ViewFrame:
388
+ return self.engine.render_regions(
389
+ self.layout,
390
+ self._inputs(self.layout.mounts),
391
+ columns=columns,
392
+ regions=regions,
393
+ )
394
+
395
+ def single(
396
+ self,
397
+ view: str,
398
+ source: str,
399
+ columns: int,
400
+ rows: int,
401
+ *,
402
+ compact: bool = False,
403
+ consumes: CursorBinding | None = None,
404
+ cursors: tuple[Cursor, ...] | None = None,
405
+ ):
406
+ slot = Slot.INLINE if compact else Slot.REX_RIGHT
407
+ mount = ViewMount(
408
+ view, source, slot, Density.COMPACT if compact else Density.FULL, consumes
409
+ )
410
+ layout = Layout(
411
+ self.layout.revision,
412
+ self.layout.tiling,
413
+ (mount,),
414
+ self.layout.cursors if cursors is None else cursors,
415
+ )
416
+ frame = self.engine.render_regions(
417
+ layout,
418
+ self._inputs((mount,)),
419
+ columns=columns,
420
+ regions={slot: Extent(columns, rows)},
421
+ )
422
+ return frame.slots[0].lines if frame.slots else ()
423
+
424
+ def _inputs(self, mounts: tuple[ViewMount, ...]) -> dict[str, SourceSnapshot]:
425
+ result: dict[str, SourceSnapshot] = {}
426
+ for mount in mounts:
427
+ source = self.sources.get(mount.source_id)
428
+ if source is not None and any(
429
+ view.id == mount.view_id for view in source.pack.manifest.views
430
+ ):
431
+ result[mount.source_id] = source.snapshot()
432
+ return result
433
+
434
+ def pin_rows(
435
+ self, rows: Sequence, anchors: Mapping, width: int, group_rows: dict[str, int]
436
+ ) -> tuple[Sequence, dict[str, int], PinPositions]:
437
+ pins = self.pin_bindings()
438
+ if not pins or not anchors:
439
+ return rows, group_rows, PinPositions()
440
+ positions: dict[int, list] = {}
441
+ for turn, tool, source, view in pins:
442
+ index = anchors.get((turn, tool))
443
+ if index is not None:
444
+ positions.setdefault(index, []).extend(
445
+ (line.style.value, " " + line.text)
446
+ for line in self.single(
447
+ view, source, max(1, width - 4), 1, compact=True
448
+ )
449
+ )
450
+ pin_positions = PinPositions(tuple(
451
+ (anchor, len(pills)) for anchor, pills in sorted(positions.items()) if pills
452
+ ))
453
+ group_rows = {group: pin_positions.visible_row(index) for group, index in group_rows.items()}
454
+ additions = [
455
+ (index + 1, (index, slot), pill)
456
+ for index, pills in positions.items()
457
+ for slot, pill in enumerate(pills)
458
+ ]
459
+ return RowOverlay(rows, (), additions), group_rows, pin_positions
synth_code/protocol.py ADDED
@@ -0,0 +1,35 @@
1
+ """Paged event fields, including persisted v2 attribution during journal cutover."""
2
+
3
+ from typing import Any, Literal, NotRequired, TypedDict
4
+
5
+
6
+ class Event(TypedDict):
7
+ version: int
8
+ run: str
9
+ seq: int
10
+ kind: str
11
+ cause: int
12
+ payload: dict[str, Any]
13
+ event_id: NotRequired[str]
14
+ at: NotRequired[str | None]
15
+ actor: NotRequired[str | None]
16
+ turn: NotRequired[str | None]
17
+ profile: NotRequired[str | None]
18
+ operation: NotRequired[str | None]
19
+ schema: NotRequired[Literal["synth-code.v2"]]
20
+ id: NotRequired[str]
21
+ kind_version: NotRequired[int]
22
+ committed_at: NotRequired[str]
23
+ actor_ref: NotRequired[dict[str, str]]
24
+ subject: NotRequired[dict[str, str]]
25
+ cause_ref: NotRequired[dict[str, str]]
26
+
27
+
28
+ class Batch(TypedDict):
29
+ version: int
30
+ run: str
31
+ after: int
32
+ cursor: int
33
+ head: int
34
+ terminal: bool
35
+ events: list[Event]