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.
- synth_code/__init__.py +0 -0
- synth_code/account.py +551 -0
- synth_code/account_http.py +86 -0
- synth_code/account_refusal.py +80 -0
- synth_code/accounting.py +148 -0
- synth_code/activity_grouping.py +149 -0
- synth_code/agent_panels.py +127 -0
- synth_code/approvals.py +397 -0
- synth_code/blobs.py +31 -0
- synth_code/cli.py +734 -0
- synth_code/client.py +413 -0
- synth_code/composer_delivery.py +139 -0
- synth_code/conversation.py +949 -0
- synth_code/daemon.py +34 -0
- synth_code/edition.py +306 -0
- synth_code/enrollment.py +304 -0
- synth_code/file_edit_facts.py +10 -0
- synth_code/freeze.py +234 -0
- synth_code/grant.py +59 -0
- synth_code/history.py +140 -0
- synth_code/history_generated.py +219 -0
- synth_code/history_wire.py +166 -0
- synth_code/image_input.py +109 -0
- synth_code/image_preview.py +105 -0
- synth_code/legacy_history.py +161 -0
- synth_code/live_turns.py +171 -0
- synth_code/model_picker.py +311 -0
- synth_code/native/manifest.json +1 -0
- synth_code/native/synth-code-runtime +0 -0
- synth_code/native.py +95 -0
- synth_code/oauth.py +284 -0
- synth_code/operator.py +116 -0
- synth_code/pack_source.py +65 -0
- synth_code/panel_request.py +291 -0
- synth_code/panels.py +40 -0
- synth_code/plugin_host.py +459 -0
- synth_code/protocol.py +35 -0
- synth_code/provider.py +313 -0
- synth_code/provider_fault.py +173 -0
- synth_code/provider_frames.py +571 -0
- synth_code/recommendation.py +324 -0
- synth_code/report.py +72 -0
- synth_code/research_events.py +44 -0
- synth_code/research_trace.py +449 -0
- synth_code/rex_view.py +58 -0
- synth_code/runtime_refusal.py +108 -0
- synth_code/schema/budgets.json +17 -0
- synth_code/schema/history-v2.json +1002 -0
- synth_code/session.py +291 -0
- synth_code/shoal.py +564 -0
- synth_code/side_panel.py +309 -0
- synth_code/skills.py +269 -0
- synth_code/slash.py +425 -0
- synth_code/source_view.py +135 -0
- synth_code/starter.json +13 -0
- synth_code/stdio.py +75 -0
- synth_code/stream.py +142 -0
- synth_code/subscriptions.py +267 -0
- synth_code/synth_authority.py +362 -0
- synth_code/synth_extra.py +32 -0
- synth_code/terminal.py +817 -0
- synth_code/terminal_journal.py +284 -0
- synth_code/terminal_layout.py +643 -0
- synth_code/terminal_surfaces.py +470 -0
- synth_code/terminal_viewport.py +125 -0
- synth_code/tool_render.py +86 -0
- synth_code/transcript_frames.py +212 -0
- synth_code/transcript_placement.py +63 -0
- synth_code/transcript_rows.py +456 -0
- synth_code/transport.py +243 -0
- synth_code/v001_history.py +468 -0
- synth_code/view.py +854 -0
- synth_code/views/__init__.py +93 -0
- synth_code/views/charts.py +196 -0
- synth_code/views/curses_adapter.py +116 -0
- synth_code/views/engine.py +170 -0
- synth_code/views/model.py +226 -0
- synth_code/views/primitives.py +270 -0
- synth_code/views/tiling.py +124 -0
- synth_code-0.0.1.dist-info/METADATA +50 -0
- synth_code-0.0.1.dist-info/RECORD +110 -0
- synth_code-0.0.1.dist-info/WHEEL +5 -0
- synth_code-0.0.1.dist-info/entry_points.txt +6 -0
- synth_code-0.0.1.dist-info/licenses/temper/LICENSE-APACHE +190 -0
- synth_code-0.0.1.dist-info/licenses/temper/LICENSE-MIT +21 -0
- synth_code-0.0.1.dist-info/licenses/temper/SOURCE.json +433 -0
- synth_code-0.0.1.dist-info/top_level.txt +2 -0
- synth_code_plugins/_sdk/__init__.py +19 -0
- synth_code_plugins/_sdk/callback_wire.py +240 -0
- synth_code_plugins/_sdk/callbacks.py +317 -0
- synth_code_plugins/_sdk/compliance.py +51 -0
- synth_code_plugins/_sdk/contracts.py +236 -0
- synth_code_plugins/_sdk/discovery.py +75 -0
- synth_code_plugins/_sdk/job_binding.py +71 -0
- synth_code_plugins/_sdk/lifecycle.py +50 -0
- synth_code_plugins/_sdk/lifecycle_generated.py +15 -0
- synth_code_plugins/_sdk/manifest.py +269 -0
- synth_code_plugins/_sdk/pack.py +332 -0
- synth_code_plugins/_sdk/push.py +98 -0
- synth_code_plugins/_sdk/records.py +26 -0
- synth_code_plugins/_sdk/registry.py +491 -0
- synth_code_plugins/_sdk/schemas.py +210 -0
- synth_code_plugins/_sdk/sources.py +230 -0
- synth_code_plugins/_sdk/surfaces.py +54 -0
- synth_code_plugins/_sdk/tools.py +172 -0
- synth_code_plugins/_sdk/worker_memory.py +49 -0
- synth_code_plugins/core/SKILL.md +6 -0
- synth_code_plugins/core/__init__.py +21 -0
- synth_code_plugins/core/plugin.toml +44 -0
- synth_code_plugins/core/source.py +18 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"""Typed transcript frames and contiguous byte streams for the terminal.
|
|
2
|
+
|
|
3
|
+
See docs/engine-v2/02-spec.md §4.2–4.3.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from collections.abc import Mapping
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from enum import StrEnum
|
|
11
|
+
|
|
12
|
+
from .transcript_placement import StreamAnchors
|
|
13
|
+
|
|
14
|
+
__all__ = ["LiveTranscript", "MessageCompleted", "MessagePhase", "ToolKind", "ToolOutcome"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class MessagePhase(StrEnum):
|
|
18
|
+
COMMENTARY = "commentary"
|
|
19
|
+
FINAL = "final"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ToolKind(StrEnum):
|
|
23
|
+
COMMAND = "command"
|
|
24
|
+
READ = "read"
|
|
25
|
+
SEARCH = "search"
|
|
26
|
+
LIST = "list"
|
|
27
|
+
PATCH = "patch"
|
|
28
|
+
MCP = "mcp"
|
|
29
|
+
WEB = "web"
|
|
30
|
+
AGENT = "agent"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ToolOutcome(StrEnum):
|
|
34
|
+
COMPLETED = "completed"
|
|
35
|
+
FAILED = "failed"
|
|
36
|
+
DECLINED = "declined"
|
|
37
|
+
CANCELLED = "cancelled"
|
|
38
|
+
INCOMPLETE = "incomplete"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(frozen=True, slots=True)
|
|
42
|
+
class MessageCompleted:
|
|
43
|
+
message_id: str
|
|
44
|
+
index: int
|
|
45
|
+
phase: MessagePhase
|
|
46
|
+
text: str
|
|
47
|
+
stream_final: bool
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def decode(cls, payload: Mapping[str, object]) -> MessageCompleted:
|
|
51
|
+
index = payload["index"]
|
|
52
|
+
stream_final = payload["stream_final"]
|
|
53
|
+
if type(stream_final) is not bool:
|
|
54
|
+
raise TypeError("Invalid message stream_final flag")
|
|
55
|
+
if type(index) is not int or index < 0:
|
|
56
|
+
raise ValueError("Invalid message index")
|
|
57
|
+
return cls(
|
|
58
|
+
_text(payload, "message_id"),
|
|
59
|
+
index,
|
|
60
|
+
MessagePhase(_text(payload, "phase")),
|
|
61
|
+
_text(payload, "text"),
|
|
62
|
+
stream_final,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(slots=True)
|
|
67
|
+
class PendingText:
|
|
68
|
+
after: int
|
|
69
|
+
phase: MessagePhase | None
|
|
70
|
+
order: int
|
|
71
|
+
parts: list[str] = field(default_factory=list)
|
|
72
|
+
offset: int = 0
|
|
73
|
+
# Journal sequence each part arrived after, so a stream that keeps growing past a
|
|
74
|
+
# committed row (a steer, a tool call) is drawn on both sides of it.
|
|
75
|
+
part_after: list[int] = field(default_factory=list)
|
|
76
|
+
|
|
77
|
+
def append(self, offset: int, text: str, after: int) -> bool:
|
|
78
|
+
if self.offset != offset:
|
|
79
|
+
return False
|
|
80
|
+
self.parts.append(text)
|
|
81
|
+
self.part_after.append(after)
|
|
82
|
+
self.offset += len(text.encode("utf-8"))
|
|
83
|
+
return True
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class LiveTranscript:
|
|
87
|
+
"""Discard speculative text on gaps and keep durable receipts authoritative."""
|
|
88
|
+
|
|
89
|
+
def __init__(self) -> None:
|
|
90
|
+
self._order = 0
|
|
91
|
+
self._snapshots: dict[str, tuple[int, int]] = {}
|
|
92
|
+
self._sealed: dict[str, set[tuple[str, str]]] = {}
|
|
93
|
+
self.messages: dict[tuple[str, str], PendingText] = {}
|
|
94
|
+
self.reasoning: dict[tuple[str, str], PendingText] = {}
|
|
95
|
+
self.tools: dict[tuple[str, str], PendingText] = {}
|
|
96
|
+
# Not cleared by reset: a projection rebuilt later must place messages the same way.
|
|
97
|
+
self.stream_anchors = StreamAnchors()
|
|
98
|
+
|
|
99
|
+
def reset(self) -> None:
|
|
100
|
+
self._order = 0
|
|
101
|
+
self._snapshots.clear()
|
|
102
|
+
self.messages.clear()
|
|
103
|
+
self.reasoning.clear()
|
|
104
|
+
self.tools.clear()
|
|
105
|
+
|
|
106
|
+
def observe(self, frame: Mapping[str, object], after: int) -> None:
|
|
107
|
+
self._order += 1
|
|
108
|
+
kind = frame["kind"]
|
|
109
|
+
if kind == "turn.live_snapshot":
|
|
110
|
+
self._snapshot(frame, after)
|
|
111
|
+
return
|
|
112
|
+
self._observe_delta(frame, after)
|
|
113
|
+
|
|
114
|
+
def _observe_delta(self, frame: Mapping[str, object], after: int) -> None:
|
|
115
|
+
match frame["kind"]:
|
|
116
|
+
case "message.delta":
|
|
117
|
+
key = (_text(frame, "turn"), _text(frame, "message_id"))
|
|
118
|
+
phase = MessagePhase(_text(frame, "phase"))
|
|
119
|
+
if ("message", key[1]) not in self._sealed.get(key[0], ()):
|
|
120
|
+
self._append(
|
|
121
|
+
self.messages, key, after, phase, frame["offset"], _text(frame, "text")
|
|
122
|
+
)
|
|
123
|
+
case "reasoning.delta":
|
|
124
|
+
key = (_text(frame, "turn"), _text(frame, "item"))
|
|
125
|
+
if ("reasoning", key[1]) not in self._sealed.get(key[0], ()):
|
|
126
|
+
self._append(
|
|
127
|
+
self.reasoning, key, after, None, frame["offset"], _text(frame, "text")
|
|
128
|
+
)
|
|
129
|
+
case "tool.output":
|
|
130
|
+
key = (_text(frame, "turn"), _text(frame, "tool_id"))
|
|
131
|
+
if ("tool", key[1]) not in self._sealed.get(key[0], ()):
|
|
132
|
+
self._append(
|
|
133
|
+
self.tools, key, after, None, frame["offset"], _text(frame, "chunk")
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
def _append(self, streams, key, after, phase, offset, text) -> None:
|
|
137
|
+
if type(offset) is not int or offset < 0:
|
|
138
|
+
raise ValueError("Invalid live UTF-8 offset")
|
|
139
|
+
if not text:
|
|
140
|
+
return
|
|
141
|
+
pending = streams.get(key)
|
|
142
|
+
if pending is None:
|
|
143
|
+
if offset != 0:
|
|
144
|
+
return
|
|
145
|
+
pending = PendingText(after, phase, self._order)
|
|
146
|
+
streams[key] = pending
|
|
147
|
+
if pending.phase != phase or not pending.append(offset, text, after):
|
|
148
|
+
# A subscriber can attach after offset zero. Only a complete durable
|
|
149
|
+
# receipt can fill the gap and provide the message or tool body.
|
|
150
|
+
streams.pop(key)
|
|
151
|
+
|
|
152
|
+
def _snapshot(self, frame, after: int) -> None:
|
|
153
|
+
turn = _text(frame, "turn")
|
|
154
|
+
sequence, part, final = frame["sequence"], frame["part"], frame["final"]
|
|
155
|
+
if (
|
|
156
|
+
type(sequence) is not int
|
|
157
|
+
or type(part) is not int
|
|
158
|
+
or part < 0
|
|
159
|
+
or type(final) is not bool
|
|
160
|
+
):
|
|
161
|
+
raise ValueError("Invalid active turn snapshot header")
|
|
162
|
+
if part == 0:
|
|
163
|
+
self._discard_turn(turn)
|
|
164
|
+
self._snapshots[turn] = (sequence, 0)
|
|
165
|
+
if self._snapshots.get(turn) != (sequence, part):
|
|
166
|
+
raise ValueError(f"Discontinuous active snapshot for turn {turn}")
|
|
167
|
+
for stream in frame["streams"]:
|
|
168
|
+
if stream["kind"] not in {"message.delta", "reasoning.delta", "tool.output"}:
|
|
169
|
+
raise ValueError(f"Invalid active stream for turn {turn}")
|
|
170
|
+
self._order += 1
|
|
171
|
+
self._observe_delta({**stream, "turn": turn}, after)
|
|
172
|
+
if final:
|
|
173
|
+
del self._snapshots[turn]
|
|
174
|
+
else:
|
|
175
|
+
self._snapshots[turn] = (sequence, part + 1)
|
|
176
|
+
|
|
177
|
+
def visible(self, turn: str) -> bool:
|
|
178
|
+
return turn not in self._snapshots
|
|
179
|
+
|
|
180
|
+
def _discard_turn(self, turn: str) -> None:
|
|
181
|
+
for streams in (self.messages, self.reasoning, self.tools):
|
|
182
|
+
for key in tuple(streams):
|
|
183
|
+
if key[0] == turn:
|
|
184
|
+
del streams[key]
|
|
185
|
+
|
|
186
|
+
def commit(self, event) -> None:
|
|
187
|
+
kind = event["kind"]
|
|
188
|
+
if kind not in {"message.completed", "reasoning.summary", "tool.finished", "turn.finished"}:
|
|
189
|
+
return
|
|
190
|
+
turn, payload = event["turn"], event["payload"]
|
|
191
|
+
if kind == "turn.finished":
|
|
192
|
+
self._discard_turn(turn)
|
|
193
|
+
self._snapshots.pop(turn, None)
|
|
194
|
+
self._sealed.pop(turn, None)
|
|
195
|
+
return
|
|
196
|
+
stream_kind, identity, streams = {
|
|
197
|
+
"message.completed": ("message", "message_id", self.messages),
|
|
198
|
+
"reasoning.summary": ("reasoning", "item", self.reasoning),
|
|
199
|
+
"tool.finished": ("tool", "tool_id", self.tools),
|
|
200
|
+
}[kind]
|
|
201
|
+
key = payload[identity]
|
|
202
|
+
pending = streams.pop((turn, key), None)
|
|
203
|
+
if pending is not None and kind == "message.completed":
|
|
204
|
+
self.stream_anchors.record(turn, key, pending.after)
|
|
205
|
+
self._sealed.setdefault(turn, set()).add((stream_kind, key))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _text(fields: Mapping[str, object], name: str) -> str:
|
|
209
|
+
value = fields[name]
|
|
210
|
+
if not isinstance(value, str):
|
|
211
|
+
raise TypeError(f"Invalid transcript field {name}")
|
|
212
|
+
return value
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Where a completed message sits among the transcript blocks committed around it.
|
|
2
|
+
|
|
3
|
+
A message streamed live is drawn where its first chunk arrived. When it completes
|
|
4
|
+
after later rows (a steer, a tool call), it keeps that place. History replay has no
|
|
5
|
+
stream, so the message sits at its `message.completed` sequence.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"NotStreamed", "StreamAnchor", "StreamAnchors", "StreamedAfter",
|
|
14
|
+
"committed_key", "live_key", "message_key",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True, slots=True)
|
|
19
|
+
class StreamedAfter:
|
|
20
|
+
"""The message's live stream started right after journal event `sequence`."""
|
|
21
|
+
|
|
22
|
+
sequence: int
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True, slots=True)
|
|
26
|
+
class NotStreamed:
|
|
27
|
+
"""No live stream was seen: history replay, or a stream dropped on a gap."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
StreamAnchor = StreamedAfter | NotStreamed
|
|
31
|
+
_NOT_STREAMED = NotStreamed()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class StreamAnchors:
|
|
35
|
+
"""Stream starts of committed messages, kept for the session so rebuilds agree."""
|
|
36
|
+
|
|
37
|
+
def __init__(self) -> None:
|
|
38
|
+
self._starts: dict[tuple[str, str], StreamedAfter] = {}
|
|
39
|
+
|
|
40
|
+
def record(self, turn: str, message_id: str, after: int) -> None:
|
|
41
|
+
self._starts[(turn, message_id)] = StreamedAfter(after)
|
|
42
|
+
|
|
43
|
+
def anchor(self, turn: str, message_id: str) -> StreamAnchor:
|
|
44
|
+
return self._starts.get((turn, message_id), _NOT_STREAMED)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Placement keys are ascending integers: a committed block at seq S has key 2S; a
|
|
48
|
+
# message whose stream started after seq A has key 2A+1, between A and A+1.
|
|
49
|
+
def committed_key(sequence: int) -> int:
|
|
50
|
+
return 2 * sequence
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def message_key(anchor: StreamAnchor, sequence: int) -> int:
|
|
54
|
+
match anchor:
|
|
55
|
+
case StreamedAfter(sequence=after) if after < sequence:
|
|
56
|
+
return 2 * after + 1
|
|
57
|
+
case _:
|
|
58
|
+
return committed_key(sequence)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def live_key(after: int) -> int:
|
|
62
|
+
"""Live text that arrived after seq `after` follows every block placed at or before it."""
|
|
63
|
+
return 2 * after + 1
|