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,226 @@
1
+ """Surface-neutral view inputs and rendered slot records."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from enum import StrEnum
7
+
8
+ __all__ = [
9
+ "Capture",
10
+ "Cursor",
11
+ "CursorBinding",
12
+ "Density",
13
+ "Extent",
14
+ "Health",
15
+ "Layout",
16
+ "Placement",
17
+ "RenderedSlot",
18
+ "Slot",
19
+ "SlotFault",
20
+ "Style",
21
+ "StyledLine",
22
+ "Tiling",
23
+ "ViewFrame",
24
+ "ViewMount",
25
+ "Viewport",
26
+ ]
27
+
28
+
29
+ class Slot(StrEnum):
30
+ INLINE = "transcript.inline"
31
+ COMPOSER_TOP = "composer.top"
32
+ RIGHT_TOP = "right.top"
33
+ RIGHT_BOTTOM = "right.bottom"
34
+ FOOTER = "footer"
35
+ REX_RIGHT = "rex.split[right]"
36
+ REX_BELOW = "rex.split[below]"
37
+
38
+
39
+ class Tiling(StrEnum):
40
+ BALANCED = "balanced"
41
+ COMPACT = "compact"
42
+ SUBAGENT_SWARM = "subagent-swarm"
43
+ HARBOR_EVAL = "harbor-eval"
44
+ HILLCLIMB_DASHBOARD = "hillclimb-dashboard"
45
+ REX_DUAL = "rex-dual"
46
+
47
+
48
+ class Density(StrEnum):
49
+ COMPACT = "compact"
50
+ STANDARD = "standard"
51
+ FULL = "full"
52
+
53
+
54
+ class Health(StrEnum):
55
+ CONNECTED = "connected"
56
+ STALE = "stale"
57
+ IN_DOUBT = "in_doubt"
58
+ UNAVAILABLE = "unavailable"
59
+ ERROR = "error"
60
+
61
+
62
+ class Style(StrEnum):
63
+ NORMAL = "normal"
64
+ MUTED = "muted"
65
+ HEADING = "brand"
66
+ WARNING = "approval"
67
+ ERROR = "error"
68
+ ADDED = "side"
69
+ REMOVED = "error"
70
+ SELECTED = "selection"
71
+
72
+
73
+ class SlotFault(StrEnum):
74
+ SOURCE_MISSING = "source_missing"
75
+ SOURCE_INVALID = "source_invalid"
76
+ VIEW_FAILED = "view_failed"
77
+
78
+
79
+ @dataclass(frozen=True, slots=True)
80
+ class StyledLine:
81
+ text: str
82
+ style: Style = Style.NORMAL
83
+ key: str | None = None
84
+
85
+
86
+ @dataclass(frozen=True, slots=True)
87
+ class Cursor:
88
+ channel: str
89
+ key: str
90
+
91
+
92
+ @dataclass(frozen=True, slots=True)
93
+ class CursorBinding:
94
+ channel: str
95
+
96
+
97
+ @dataclass(frozen=True, slots=True)
98
+ class ViewMount:
99
+ view_id: str
100
+ source_id: str
101
+ slot: Slot
102
+ density: Density = Density.FULL
103
+ consumes: CursorBinding | None = None
104
+ emits: CursorBinding | None = None
105
+
106
+
107
+ _MAX_MOUNTS = 32
108
+ _MAX_CURSORS = 64
109
+
110
+
111
+ @dataclass(frozen=True, slots=True)
112
+ class Layout:
113
+ revision: int
114
+ tiling: Tiling
115
+ mounts: tuple[ViewMount, ...]
116
+ cursors: tuple[Cursor, ...] = ()
117
+
118
+ def __post_init__(self) -> None:
119
+ if type(self.revision) is not int or self.revision < 0:
120
+ raise ValueError(f"layout revision must be a nonnegative integer, got {self.revision}")
121
+ if len(self.mounts) > _MAX_MOUNTS:
122
+ raise ValueError(f"layout has {len(self.mounts)} mounts, maximum {_MAX_MOUNTS}")
123
+ if len(self.cursors) > _MAX_CURSORS:
124
+ raise ValueError(f"layout has {len(self.cursors)} cursors, maximum {_MAX_CURSORS}")
125
+ channels = {cursor.channel for cursor in self.cursors}
126
+ if len(channels) != len(self.cursors):
127
+ raise ValueError("layout cursor channels must be unique")
128
+
129
+
130
+ @dataclass(frozen=True, slots=True)
131
+ class Extent:
132
+ columns: int
133
+ rows: int
134
+
135
+ def __post_init__(self) -> None:
136
+ if self.columns < 0 or self.rows < 0:
137
+ raise ValueError(f"extent must be nonnegative, got {self.columns}×{self.rows}")
138
+
139
+
140
+ @dataclass(frozen=True, slots=True)
141
+ class Viewport:
142
+ """Writable capacities supplied by the adapter, excluding composer and approvals.
143
+
144
+ Inline capacity counts only rows the transcript adapter can allocate to views.
145
+ Side slots share the screen's height, and Rex extents describe existing panes.
146
+ """
147
+
148
+ columns: int
149
+ rows: int
150
+ transcript_width: int
151
+ transcript_rows: int
152
+ composer_top_rows: int
153
+ footer_rows: int
154
+ right_width: int = 0
155
+ rex_right: Extent | None = None
156
+ rex_below: Extent | None = None
157
+ right_rows: int | None = None
158
+
159
+ def __post_init__(self) -> None:
160
+ columns = self.transcript_width + self.right_width
161
+ rows = self.transcript_rows + self.composer_top_rows + self.footer_rows
162
+ if (
163
+ min(
164
+ self.columns,
165
+ self.rows,
166
+ self.transcript_width,
167
+ self.right_width,
168
+ self.transcript_rows,
169
+ self.composer_top_rows,
170
+ self.footer_rows,
171
+ )
172
+ < 0
173
+ or columns > self.columns
174
+ or rows > self.rows
175
+ ):
176
+ raise ValueError(
177
+ f"view areas {columns}×{rows} exceed viewport {self.columns}×{self.rows} "
178
+ "or a dimension is negative"
179
+ )
180
+ if self.right_rows is not None and not 0 <= self.right_rows <= self.rows:
181
+ raise ValueError(f"side rows must be in 0..{self.rows}, got {self.right_rows}")
182
+
183
+
184
+ @dataclass(frozen=True, slots=True)
185
+ class Placement:
186
+ slot: Slot
187
+ row: int
188
+ columns: int
189
+ rows: int
190
+ density: Density
191
+
192
+
193
+ @dataclass(frozen=True, slots=True)
194
+ class Capture:
195
+ view_revision: int
196
+ source_seq: int | None
197
+ view_id: str
198
+ source_id: str
199
+
200
+
201
+ @dataclass(frozen=True, slots=True)
202
+ class RenderedSlot:
203
+ mount: ViewMount
204
+ placement: Placement
205
+ capture: Capture
206
+ lines: tuple[StyledLine, ...]
207
+ health: Health
208
+ fault: SlotFault | None = None
209
+ selectable_keys: tuple[str, ...] = ()
210
+
211
+ @property
212
+ def slot(self) -> Slot:
213
+ """The requested slot, which survives viewport degradation."""
214
+ return self.mount.slot
215
+
216
+ def select(self, key: str) -> Cursor | None:
217
+ if self.mount.emits is None or key not in self.selectable_keys:
218
+ return None
219
+ return Cursor(self.mount.emits.channel, key)
220
+
221
+
222
+ @dataclass(frozen=True, slots=True)
223
+ class ViewFrame:
224
+ revision: int
225
+ slots: tuple[RenderedSlot, ...]
226
+ hidden: tuple[ViewMount, ...]
@@ -0,0 +1,270 @@
1
+ """Pure renderers for the view engine's declarative primitives."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import math
6
+ from collections.abc import Iterator, Mapping
7
+ from dataclasses import dataclass
8
+ from enum import StrEnum
9
+ from itertools import islice
10
+
11
+ from ..view import fit_cells, render_char
12
+ from .charts import Heatmap, Scatter, Series, render_chart
13
+ from .model import Density, Health, Style, StyledLine
14
+
15
+ __all__ = [
16
+ "Card",
17
+ "Content",
18
+ "Diff",
19
+ "DiffKind",
20
+ "DiffLine",
21
+ "LogTail",
22
+ "Metric",
23
+ "Metrics",
24
+ "Pill",
25
+ "Progress",
26
+ "RenderContext",
27
+ "SourceSnapshot",
28
+ "Table",
29
+ "TableRow",
30
+ "render_content",
31
+ ]
32
+
33
+ Scalar = str | int | float | None
34
+
35
+ # Bound input work before formatting or sanitizing any plugin text.
36
+ TEXT_SCAN_LIMIT = 2048
37
+ UNKNOWN = "—"
38
+ _MAX_COLUMNS = 16
39
+ _MAX_TABLE_ROWS = 4096
40
+
41
+
42
+ @dataclass(frozen=True, slots=True)
43
+ class Pill:
44
+ label: str
45
+ status: str
46
+ details: tuple[Metric, ...] = ()
47
+
48
+
49
+ @dataclass(frozen=True, slots=True)
50
+ class Progress:
51
+ label: str
52
+ completed: int | None
53
+ total: int | None
54
+
55
+ def __post_init__(self) -> None:
56
+ for name, value in (("completed", self.completed), ("total", self.total)):
57
+ if value is not None and (type(value) is not int or not 0 <= value < 1 << 64):
58
+ raise ValueError(f"progress {name} must be absent or a u64")
59
+
60
+
61
+ @dataclass(frozen=True, slots=True)
62
+ class Metric:
63
+ label: str
64
+ value: Scalar
65
+ unit: str = ""
66
+
67
+
68
+ @dataclass(frozen=True, slots=True)
69
+ class Metrics:
70
+ items: tuple[Metric, ...]
71
+
72
+
73
+ @dataclass(frozen=True, slots=True)
74
+ class TableRow:
75
+ values: tuple[Scalar, ...]
76
+ key: str | None = None
77
+
78
+
79
+ @dataclass(frozen=True, slots=True)
80
+ class Table:
81
+ headers: tuple[str, ...]
82
+ rows: tuple[TableRow, ...]
83
+
84
+ def __post_init__(self) -> None:
85
+ if not 1 <= len(self.headers) <= _MAX_COLUMNS:
86
+ raise ValueError(f"table has {len(self.headers)} columns, expected 1..{_MAX_COLUMNS}")
87
+ if len(self.rows) > _MAX_TABLE_ROWS:
88
+ raise ValueError(f"table has {len(self.rows)} rows, maximum {_MAX_TABLE_ROWS}")
89
+ keys: set[str] = set()
90
+ for row in self.rows:
91
+ if len(row.values) != len(self.headers):
92
+ raise ValueError(
93
+ f"table row has {len(row.values)} cells, expected {len(self.headers)}"
94
+ )
95
+ if row.key is not None:
96
+ if row.key in keys:
97
+ raise ValueError("table row keys must be unique")
98
+ keys.add(row.key)
99
+
100
+
101
+ class DiffKind(StrEnum):
102
+ CONTEXT = " "
103
+ ADD = "+"
104
+ REMOVE = "-"
105
+
106
+
107
+ @dataclass(frozen=True, slots=True)
108
+ class DiffLine:
109
+ kind: DiffKind
110
+ text: str
111
+
112
+
113
+ @dataclass(frozen=True, slots=True)
114
+ class Diff:
115
+ title: str
116
+ lines: tuple[DiffLine, ...]
117
+
118
+
119
+ @dataclass(frozen=True, slots=True)
120
+ class LogTail:
121
+ lines: tuple[str, ...]
122
+
123
+
124
+ @dataclass(frozen=True, slots=True)
125
+ class Card:
126
+ title: str
127
+ body: tuple[str, ...] = ()
128
+
129
+
130
+ @dataclass(frozen=True, slots=True)
131
+ class Payload:
132
+ """A validated source record formatted by a pack-specific renderer."""
133
+
134
+ plugin: str
135
+ fact: Mapping[str, object]
136
+ live: Mapping[str, object]
137
+
138
+
139
+ Content = Payload | Pill | Progress | Metrics | Table | Diff | LogTail | Card | Series | Heatmap | Scatter
140
+
141
+
142
+ @dataclass(frozen=True, slots=True)
143
+ class SourceSnapshot:
144
+ """One already-delivered source state. The adapter owns push and resync."""
145
+
146
+ seq: int
147
+ content: Content | None
148
+ health: Health = Health.CONNECTED
149
+
150
+ def __post_init__(self) -> None:
151
+ if type(self.seq) is not int or self.seq < 0:
152
+ raise ValueError(f"source sequence must be a nonnegative integer, got {self.seq}")
153
+ if not isinstance(self.health, Health):
154
+ raise TypeError("source health must be a Health member")
155
+
156
+
157
+ @dataclass(frozen=True, slots=True)
158
+ class RenderContext:
159
+ density: Density
160
+ columns: int
161
+ rows: int
162
+ selected_key: str | None
163
+
164
+
165
+ def _scalar(value: Scalar) -> str:
166
+ if value is None:
167
+ return UNKNOWN
168
+ if isinstance(value, str):
169
+ return value[:TEXT_SCAN_LIMIT]
170
+ if type(value) is int and -(1 << 63) <= value < 1 << 64:
171
+ return str(value)
172
+ if type(value) is float and math.isfinite(value):
173
+ return str(value)
174
+ raise ValueError("expected a text, finite numeric, or absent measurement")
175
+
176
+
177
+ def _metric(metric: Metric) -> str:
178
+ label = metric.label[:TEXT_SCAN_LIMIT]
179
+ value = _scalar(metric.value)
180
+ unit = "" if metric.value is None else metric.unit[:TEXT_SCAN_LIMIT]
181
+ return f"{label} {value}{unit}"
182
+
183
+
184
+ def _progress(content: Progress, context: RenderContext) -> Iterator[StyledLine]:
185
+ completed, total = content.completed, content.total
186
+ label = content.label[:TEXT_SCAN_LIMIT]
187
+ counters = f"{_scalar(completed)}/{_scalar(total)}"
188
+ # Preserve values when the label is wider than the pane.
189
+ label = fit_cells(label, max(0, context.columns - len(counters) - 1))
190
+ yield StyledLine(f"{label} {counters}" if label else counters)
191
+ if context.density != Density.COMPACT and completed is not None and total:
192
+ width = min(24, context.columns)
193
+ filled = min(completed, total) * width // total
194
+ yield StyledLine("█" * filled + "░" * (width - filled), Style.HEADING)
195
+
196
+
197
+ def _table(content: Table, context: RenderContext) -> Iterator[StyledLine]:
198
+ if not content.rows:
199
+ yield StyledLine("No rows", Style.MUTED)
200
+ return
201
+ start = 0
202
+ if context.selected_key is not None:
203
+ for index, row in enumerate(content.rows):
204
+ if row.key == context.selected_key:
205
+ start = max(0, index - max(0, context.rows - 2))
206
+ break
207
+ if context.density == Density.COMPACT or context.rows == 1:
208
+ row = content.rows[start]
209
+ yield StyledLine(" · ".join(_scalar(value) for value in row.values), key=row.key)
210
+ return
211
+ min_column_width = 7
212
+ columns = min(len(content.headers), max(1, context.columns // min_column_width))
213
+ separator = " "
214
+ cell_width, extra = divmod(context.columns - (columns - 1) * len(separator), columns)
215
+ widths = tuple(cell_width + (index < extra) for index in range(columns))
216
+
217
+ def cells(values: tuple[Scalar, ...]) -> str:
218
+ cells = []
219
+ for width, value in zip(widths, values):
220
+ cell = fit_cells(_scalar(value), width)
221
+ # fit_cells can return a multicolumn grapheme or a combining sequence.
222
+ used = sum(render_char(char)[1] for char in cell)
223
+ cells.append(cell + " " * (width - used))
224
+ return separator.join(cells).rstrip()
225
+
226
+ yield StyledLine(cells(content.headers), Style.HEADING)
227
+ for row in content.rows[start : start + context.rows - 1]:
228
+ selected = context.selected_key is not None and row.key == context.selected_key
229
+ yield StyledLine(cells(row.values), Style.SELECTED if selected else Style.NORMAL, row.key)
230
+
231
+
232
+ def render_content(content: Content, context: RenderContext) -> Iterator[StyledLine]:
233
+ """Yield display lines as needed. The engine applies the final slot budget."""
234
+ match content:
235
+ case Pill(label, status, details):
236
+ yield StyledLine(
237
+ f"{label[:TEXT_SCAN_LIMIT]} · {status[:TEXT_SCAN_LIMIT]}", Style.HEADING
238
+ )
239
+ if context.density != Density.COMPACT:
240
+ yield from (StyledLine(_metric(item)) for item in islice(details, context.rows - 1))
241
+ case Progress():
242
+ yield from _progress(content, context)
243
+ case Metrics(items):
244
+ if context.density == Density.COMPACT:
245
+ yield StyledLine(" · ".join(_metric(item) for item in islice(items, 2)))
246
+ else:
247
+ yield from (StyledLine(_metric(item)) for item in islice(items, context.rows))
248
+ case Table():
249
+ yield from _table(content, context)
250
+ case Diff(title, lines):
251
+ yield StyledLine(title, Style.HEADING)
252
+ if context.density != Density.COMPACT:
253
+ styles = {
254
+ DiffKind.CONTEXT: Style.NORMAL,
255
+ DiffKind.ADD: Style.ADDED,
256
+ DiffKind.REMOVE: Style.REMOVED,
257
+ }
258
+ for line in islice(lines, context.rows - 1):
259
+ yield StyledLine(line.kind + line.text[:TEXT_SCAN_LIMIT], styles[line.kind])
260
+ case LogTail(lines):
261
+ for line in lines[-context.rows :]:
262
+ yield StyledLine(line)
263
+ case Card(title, body):
264
+ yield StyledLine(title, Style.HEADING)
265
+ if context.density != Density.COMPACT:
266
+ yield from (StyledLine(line) for line in islice(body, context.rows - 1))
267
+ case Series() | Heatmap() | Scatter():
268
+ yield from render_chart(content, context)
269
+ case _:
270
+ raise TypeError(f"unsupported view content: {type(content).__name__}")
@@ -0,0 +1,124 @@
1
+ """Deterministic routes from requested slots to writable surface regions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+
7
+ from .model import Density, Extent, Placement, Slot, Tiling, ViewMount, Viewport
8
+
9
+ __all__ = ["Router", "viewport_extents"]
10
+
11
+ WIDE_COLUMNS = 120
12
+ _MIN_SIDE_COLUMNS = 24
13
+ _MIN_STANDARD_COLUMNS = 28
14
+ _MIN_FULL_COLUMNS = 44
15
+ _DENSITY_ROWS = {
16
+ Density.COMPACT: 1,
17
+ Density.STANDARD: 4,
18
+ Density.FULL: 12,
19
+ }
20
+
21
+ _INLINE = (Slot.INLINE, Slot.COMPOSER_TOP, Slot.FOOTER)
22
+ _COMPOSER = (Slot.COMPOSER_TOP, Slot.INLINE, Slot.FOOTER)
23
+ _FOOTER = (Slot.FOOTER, Slot.COMPOSER_TOP, Slot.INLINE)
24
+ _RIGHT_TOP = (Slot.RIGHT_TOP, *_COMPOSER)
25
+ _RIGHT_BOTTOM = (Slot.RIGHT_BOTTOM, *_COMPOSER)
26
+ _REX_RIGHT = (Slot.REX_RIGHT, *_RIGHT_TOP)
27
+ _REX_BELOW = (Slot.REX_BELOW, *_RIGHT_BOTTOM)
28
+
29
+ _ROUTES = {
30
+ Slot.INLINE: _INLINE,
31
+ Slot.COMPOSER_TOP: _COMPOSER,
32
+ Slot.RIGHT_TOP: _RIGHT_TOP,
33
+ Slot.RIGHT_BOTTOM: _RIGHT_BOTTOM,
34
+ Slot.FOOTER: _FOOTER,
35
+ Slot.REX_RIGHT: _REX_RIGHT,
36
+ Slot.REX_BELOW: _REX_BELOW,
37
+ }
38
+
39
+ # Order matters when the adapter supplies existing Rex panes. Neither routing
40
+ # nor rendering opens one.
41
+ _PRESET_ROUTES = {
42
+ Tiling.SUBAGENT_SWARM: {Slot.RIGHT_TOP: _REX_RIGHT},
43
+ Tiling.HARBOR_EVAL: {Slot.RIGHT_TOP: (Slot.REX_BELOW, *_RIGHT_TOP)},
44
+ Tiling.HILLCLIMB_DASHBOARD: {
45
+ Slot.RIGHT_TOP: _REX_RIGHT,
46
+ Slot.RIGHT_BOTTOM: _REX_BELOW,
47
+ },
48
+ Tiling.REX_DUAL: {Slot.RIGHT_TOP: _REX_RIGHT, Slot.RIGHT_BOTTOM: _REX_BELOW},
49
+ }
50
+
51
+
52
+ def viewport_extents(viewport: Viewport) -> dict[Slot, Extent]:
53
+ width = viewport.transcript_width
54
+ extents = {
55
+ Slot.INLINE: Extent(width, viewport.transcript_rows),
56
+ Slot.COMPOSER_TOP: Extent(width, viewport.composer_top_rows),
57
+ Slot.FOOTER: Extent(width, viewport.footer_rows),
58
+ }
59
+ if viewport.right_width:
60
+ side_rows = viewport.rows if viewport.right_rows is None else viewport.right_rows
61
+ top_rows = (side_rows + 1) // 2
62
+ extents[Slot.RIGHT_TOP] = Extent(viewport.right_width, top_rows)
63
+ extents[Slot.RIGHT_BOTTOM] = Extent(viewport.right_width, side_rows - top_rows)
64
+ if viewport.rex_right is not None:
65
+ extents[Slot.REX_RIGHT] = viewport.rex_right
66
+ if viewport.rex_below is not None:
67
+ extents[Slot.REX_BELOW] = viewport.rex_below
68
+ return extents
69
+
70
+
71
+ def _density(tiling: Tiling, slot: Slot, extent: Extent, requested: Density) -> Density:
72
+ if tiling == Tiling.COMPACT or slot == Slot.FOOTER:
73
+ return Density.COMPACT
74
+ if extent.columns < _MIN_STANDARD_COLUMNS or extent.rows < 2:
75
+ return Density.COMPACT
76
+ if (
77
+ slot in (Slot.INLINE, Slot.COMPOSER_TOP)
78
+ or extent.columns < _MIN_FULL_COLUMNS
79
+ or extent.rows < 5
80
+ ):
81
+ return Density.STANDARD if requested == Density.FULL else requested
82
+ return requested
83
+
84
+
85
+ class Router:
86
+ """Owns only one frame's remaining row capacity."""
87
+
88
+ def __init__(self, tiling: Tiling, columns: int, extents: Mapping[Slot, Extent]) -> None:
89
+ self._tiling = tiling
90
+ self._extents = {
91
+ slot: extent
92
+ for slot, extent in extents.items()
93
+ if slot not in (Slot.RIGHT_TOP, Slot.RIGHT_BOTTOM)
94
+ or (columns >= WIDE_COLUMNS and extent.columns >= _MIN_SIDE_COLUMNS)
95
+ }
96
+ self._used: dict[Slot, int] = dict.fromkeys(self._extents, 0)
97
+
98
+ def plan(self, mounts: tuple[ViewMount, ...]) -> tuple[Placement | None, ...]:
99
+ """Reserve primary regions before placing views that must degrade."""
100
+ placements = [self._place(mount, fallback=False) for mount in mounts]
101
+ for index, mount in enumerate(mounts):
102
+ if placements[index] is None:
103
+ placements[index] = self._place(mount, fallback=True)
104
+ return tuple(placements)
105
+
106
+ def _place(self, mount: ViewMount, *, fallback: bool) -> Placement | None:
107
+ overrides = _PRESET_ROUTES.get(self._tiling, {})
108
+ for slot in overrides.get(mount.slot, _ROUTES[mount.slot]):
109
+ reflow = slot != mount.slot and slot in _COMPOSER
110
+ if fallback != reflow:
111
+ continue
112
+ extent = self._extents.get(slot)
113
+ if extent is None:
114
+ continue
115
+ used = self._used[slot]
116
+ available = extent.rows - used
117
+ if extent.columns == 0 or available == 0:
118
+ continue
119
+ requested = Density.COMPACT if fallback else mount.density
120
+ profile = _density(self._tiling, slot, Extent(extent.columns, available), requested)
121
+ rows = min(available, _DENSITY_ROWS[profile])
122
+ self._used[slot] += rows
123
+ return Placement(slot, used, extent.columns, rows, profile)
124
+ return None
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: synth-code
3
+ Version: 0.0.1
4
+ Summary: A terminal coding agent: Inkling works in your workspace, and every file change waits for your approval.
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: rich==15.0.0
8
+ Requires-Dist: markdown-it-py>=2.2.0
9
+ Requires-Dist: jsonschema==4.26.0
10
+ Requires-Dist: certifi>=2026.10.19
11
+ Requires-Dist: httpx==0.29.0
12
+ Requires-Dist: pydantic==2.14.4
13
+ Requires-Dist: synth-ai==0.44.2
14
+ Requires-Dist: mcp==1.30.0
15
+ Provides-Extra: synth
16
+
17
+ # Synth Code
18
+
19
+ Synth Code is a terminal coding agent. In 0.0.1 one agent, Inkling, works in your workspace: it reads files and proposes changes, and every change waits for your approval. Inkling is served by Synth, and you sign in with your Synth account.
20
+
21
+ ## Install
22
+
23
+ Synth Code needs Python 3.11 or later and [uv](https://docs.astral.sh/uv/). Wheels are published for macOS 15 or later on Apple Silicon and for Linux x86_64 with glibc 2.39 or later.
24
+
25
+ ```sh
26
+ uv tool install synth-code
27
+ ```
28
+
29
+ ## Sign in
30
+
31
+ ```sh
32
+ synth-code login --device --with-inkling --ceiling-micros 50000
33
+ ```
34
+
35
+ Finish the sign-in in your browser. `--ceiling-micros` caps what Inkling may spend under this sign-in, in millionths of a dollar. Inside the app, `/login synth` does the same.
36
+
37
+ ## Run
38
+
39
+ ```sh
40
+ synth-code --workspace "$PWD"
41
+ ```
42
+
43
+ Inkling works through four workspace tools: `read_file`, `count_bytes`, `create_file` and `replace_file`. It has no shell. When it proposes to create or replace a file, the turn pauses until you approve or deny the change. Approved changes are journaled, so reattaching shows the committed history without sending the turn again.
44
+
45
+ ## More
46
+
47
+ - [Install](https://github.com/synth-laboratories/synth-code/blob/main/docs/INSTALL.md)
48
+ - [Security](https://github.com/synth-laboratories/synth-code/blob/main/SECURITY.md)
49
+ - [Data and network](https://github.com/synth-laboratories/synth-code/blob/main/docs/NETWORK.md)
50
+ - [Changelog](https://github.com/synth-laboratories/synth-code/blob/main/CHANGELOG.md)