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,80 @@
1
+ """The typed CLI refusal for a Synth sign-in or account authority failure.
2
+
3
+ ``AuthorityRefused`` (the sign-in authority) and ``AdapterError`` (the account and
4
+ inference HTTP authorities) reach the CLI directly or wrapped (``account.lifecycle``
5
+ re-raises them as ``RuntimeError`` with the refusal as ``__cause__``). This module finds
6
+ the refusal in the exception chain and renders one ``{"error": {...}}`` object with the
7
+ code, service, stage, upstream status, cause and next action. It never carries token
8
+ values: ``AuthorityRefused.cause`` and ``AdapterError.code`` are token-free by contract.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import TypedDict
14
+
15
+ from .account_http import AdapterError
16
+ from .provider_fault import Code, exception_fault
17
+ from .synth_authority import AuthorityRefusal, AuthorityRefused
18
+
19
+ __all__ = ["AccountRefusalPayload", "account_refusal"]
20
+
21
+ SERVICE = "synth-account"
22
+ LOGIN_HINT = "Your Synth sign-in has expired or cannot be used; run `synth-code login --device` to sign in again"
23
+ _HINTS = {
24
+ Code.SIGNED_OUT: LOGIN_HINT,
25
+ Code.ACCESS_DENIED: "Your Synth account is not authorized for this; check the signed-in account with `synth-code account` or sign in again with `synth-code login --device`",
26
+ Code.QUOTA: "Your Synth allowance or balance is exhausted; check `synth-code account`",
27
+ Code.PROVIDER_UNAVAILABLE: "The Synth account service is unreachable; check the network and retry",
28
+ }
29
+ # Authority refusals whose next action is not signing in again.
30
+ _AUTHORITY_HINTS = {
31
+ AuthorityRefusal.CREDENTIAL_FILE_PERMISSIONS: "The Synth credential file is readable by other users; restrict it with `chmod 600 ~/.config/synth/credentials.json`",
32
+ AuthorityRefusal.TOKEN_REFRESH_UNAVAILABLE: "The Synth sign-in service is unreachable; check the network and retry",
33
+ }
34
+ _DEFAULT_HINT = "The Synth account service refused the request; retry, or sign in again with `synth-code login --device`"
35
+
36
+
37
+ class AccountRefusalPayload(TypedDict):
38
+ code: str
39
+ service: str
40
+ stage: str
41
+ upstream_status: int | None
42
+ cause: str
43
+ hint: str
44
+
45
+
46
+ def _chain(error: BaseException):
47
+ seen: set[int] = set()
48
+ current: BaseException | None = error
49
+ while current is not None and id(current) not in seen:
50
+ seen.add(id(current))
51
+ yield current
52
+ current = current.__cause__ or current.__context__
53
+
54
+
55
+ def account_refusal(error: BaseException) -> AccountRefusalPayload | None:
56
+ """The typed refusal for a sign-in/account failure in ``error``'s chain, else ``None``."""
57
+ chain = list(_chain(error))
58
+ adapter = next((e for e in chain if isinstance(e, AdapterError)), None)
59
+ authority = next((e for e in chain if isinstance(e, AuthorityRefused)), None)
60
+ if adapter is None and authority is None:
61
+ return None
62
+ if adapter is not None:
63
+ code = adapter.code
64
+ hint = _HINTS.get(exception_fault(adapter).code, _DEFAULT_HINT)
65
+ else:
66
+ code = f"customer_credential_unavailable:{authority.code.value}"
67
+ hint = LOGIN_HINT
68
+ if authority is not None:
69
+ hint = _AUTHORITY_HINTS.get(authority.code, hint)
70
+ stage, status, cause = authority.stage, authority.status, f"{authority.code.value}: {authority.cause}"
71
+ else:
72
+ stage, status, cause = "account_authority", adapter.kind.status, adapter.code
73
+ return {
74
+ "code": code,
75
+ "service": SERVICE,
76
+ "stage": stage,
77
+ "upstream_status": status,
78
+ "cause": cause,
79
+ "hint": hint,
80
+ }
@@ -0,0 +1,148 @@
1
+ """Typed Core accounting identities carried on an Inkling turn receipt.
2
+
3
+ Production Shoal does not send a Core usage-record id or a funding source on
4
+ `/v1/responses`. A bare `null` cannot say whether the service reported "none"
5
+ or never reported at all, so each field is either REPORTED with a value or
6
+ UNREPORTED with a typed reason. `shoal_receipt_id` stays the receipt key.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from collections.abc import Mapping
12
+ from dataclasses import dataclass
13
+ from enum import StrEnum
14
+
15
+ __all__ = [
16
+ "AccountingField",
17
+ "AccountingFieldStatus",
18
+ "AccountingInvalid",
19
+ "AccountingName",
20
+ "UnreportedReason",
21
+ "from_envelope",
22
+ "from_receipt",
23
+ "receipt_accounting",
24
+ ]
25
+
26
+
27
+ class AccountingFieldStatus(StrEnum):
28
+ REPORTED = "reported"
29
+ UNREPORTED = "unreported"
30
+
31
+
32
+ class UnreportedReason(StrEnum):
33
+ # The Shoal envelope carried no value for this field (production today).
34
+ NOT_REPORTED_BY_SHOAL = "not_reported_by_shoal"
35
+ # Shoal sent the key with a non-string or empty value; nothing was stored.
36
+ INVALID_FROM_SHOAL = "invalid_from_shoal"
37
+ # A receipt written before this marker existed recorded `null`.
38
+ LEGACY_RECEIPT_NULL = "legacy_receipt_null"
39
+
40
+
41
+ class AccountingName(StrEnum):
42
+ """Receipt key under `accounting`, and the flat Shoal/legacy key it came from."""
43
+
44
+ USAGE_RECORD = "usage_record"
45
+ FUNDING_SOURCE = "funding_source"
46
+
47
+ @property
48
+ def source_key(self) -> str:
49
+ return "usage_record_id" if self is AccountingName.USAGE_RECORD else "funding_source"
50
+
51
+
52
+ class AccountingInvalid(ValueError):
53
+ """A persisted accounting marker is not a shape this client wrote."""
54
+
55
+ def __init__(self, name: AccountingName, cause: str) -> None:
56
+ self.name = name
57
+ self.cause = cause
58
+ super().__init__(f"accounting.{name}: {cause}")
59
+
60
+
61
+ @dataclass(frozen=True, slots=True)
62
+ class AccountingField:
63
+ status: AccountingFieldStatus
64
+ value: str | None = None
65
+ reason: UnreportedReason | None = None
66
+ # For INVALID_FROM_SHOAL only: the JSON type Shoal sent, never the value.
67
+ observed_type: str | None = None
68
+
69
+ def __post_init__(self) -> None:
70
+ reported = self.status is AccountingFieldStatus.REPORTED
71
+ if reported != (self.value is not None) or reported == (self.reason is not None):
72
+ raise ValueError("REPORTED carries a value only; UNREPORTED carries a reason only")
73
+ if self.observed_type is not None and self.reason is not UnreportedReason.INVALID_FROM_SHOAL:
74
+ raise ValueError("observed_type is only recorded for invalid Shoal values")
75
+
76
+ @classmethod
77
+ def reported(cls, value: str) -> AccountingField:
78
+ return cls(AccountingFieldStatus.REPORTED, value=value)
79
+
80
+ @classmethod
81
+ def unreported(cls, reason: UnreportedReason, observed_type: str | None = None) -> AccountingField:
82
+ return cls(AccountingFieldStatus.UNREPORTED, reason=reason, observed_type=observed_type)
83
+
84
+ def to_json(self) -> dict[str, str]:
85
+ if self.status is AccountingFieldStatus.REPORTED:
86
+ return {"status": self.status.value, "value": self.value}
87
+ marker = {"status": self.status.value, "reason": self.reason.value}
88
+ if self.observed_type is not None:
89
+ marker["observed_type"] = self.observed_type
90
+ return marker
91
+
92
+
93
+ def _json_type(value: object) -> str:
94
+ match value:
95
+ case bool():
96
+ return "boolean"
97
+ case int() | float():
98
+ return "number"
99
+ case str():
100
+ return "string"
101
+ case list():
102
+ return "array"
103
+ case dict():
104
+ return "object"
105
+ return type(value).__name__
106
+
107
+
108
+ def from_envelope(envelope: Mapping[str, object], name: AccountingName) -> AccountingField:
109
+ """Read one field from a Shoal response envelope without coercing it."""
110
+ if name.source_key not in envelope or envelope[name.source_key] is None:
111
+ return AccountingField.unreported(UnreportedReason.NOT_REPORTED_BY_SHOAL)
112
+ value = envelope[name.source_key]
113
+ if isinstance(value, str) and value:
114
+ return AccountingField.reported(value)
115
+ return AccountingField.unreported(UnreportedReason.INVALID_FROM_SHOAL, _json_type(value))
116
+
117
+
118
+ def receipt_accounting(envelope: Mapping[str, object]) -> dict[str, dict[str, str]]:
119
+ return {name.value: from_envelope(envelope, name).to_json() for name in AccountingName}
120
+
121
+
122
+ def from_receipt(receipt: Mapping[str, object], name: AccountingName) -> AccountingField:
123
+ """Read one field from a persisted turn receipt, new marker or legacy flat key."""
124
+ accounting = receipt.get("accounting")
125
+ if accounting is None:
126
+ legacy = receipt.get(name.source_key)
127
+ if legacy is None:
128
+ return AccountingField.unreported(UnreportedReason.LEGACY_RECEIPT_NULL)
129
+ if isinstance(legacy, str) and legacy:
130
+ return AccountingField.reported(legacy)
131
+ raise AccountingInvalid(name, f"legacy {name.source_key} is {_json_type(legacy)}, not a non-empty string")
132
+ if not isinstance(accounting, Mapping) or not isinstance(marker := accounting.get(name.value), Mapping):
133
+ raise AccountingInvalid(name, "marker missing or not an object")
134
+ try:
135
+ status = AccountingFieldStatus(marker.get("status"))
136
+ if status is AccountingFieldStatus.REPORTED:
137
+ value = marker.get("value")
138
+ if not isinstance(value, str) or not value:
139
+ raise AccountingInvalid(name, "reported value is not a non-empty string")
140
+ return AccountingField.reported(value)
141
+ observed = marker.get("observed_type")
142
+ if observed is not None and not isinstance(observed, str):
143
+ raise AccountingInvalid(name, "observed_type is not a string")
144
+ return AccountingField.unreported(UnreportedReason(marker.get("reason")), observed)
145
+ except AccountingInvalid:
146
+ raise
147
+ except ValueError as error:
148
+ raise AccountingInvalid(name, str(error)) from error
@@ -0,0 +1,149 @@
1
+ """Optional terminal presentation of routine activity beneath an explicit tool anchor."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping, Sequence
6
+ from dataclasses import dataclass
7
+
8
+ from .transcript_frames import ToolKind
9
+ from .view import fit_cells
10
+
11
+ __all__ = ["ActivityGroup", "ToolAnchor", "ToolRows", "group_activity"]
12
+
13
+
14
+ @dataclass(frozen=True, slots=True)
15
+ class ToolAnchor:
16
+ run: str
17
+ turn: str
18
+ tool_id: str
19
+
20
+
21
+ @dataclass(frozen=True, slots=True)
22
+ class ActivityGroup:
23
+ group_id: str
24
+ expanded: bool
25
+ anchor: ToolAnchor | None = None
26
+ include_descendants: bool = False
27
+ selected: tuple[ToolAnchor, ...] = ()
28
+
29
+ @classmethod
30
+ def decode(cls, data: Mapping[str, object]) -> ActivityGroup:
31
+ group_id, run, turn = (_identity(data[field]) for field in ("group_id", "run", "turn"))
32
+ expanded = data["expanded"]
33
+ if type(expanded) is not bool:
34
+ raise TypeError("Invalid activity group expansion flag")
35
+ selection = data.get("tool_ids", [])
36
+ if not isinstance(selection, list):
37
+ raise TypeError("Invalid activity group tool selection")
38
+ if selection:
39
+ if not 2 <= len(selection) <= 32 or "tool_id" in data or "include_descendants" in data:
40
+ raise ValueError("Explicit activity group requires 2–32 selected tools")
41
+ tools = tuple(_identity(tool) for tool in selection)
42
+ if len(tools) != len(set(tools)):
43
+ raise ValueError("Activity group tool selection must be unique")
44
+ return cls(
45
+ group_id, expanded, selected=tuple(ToolAnchor(run, turn, tool) for tool in tools)
46
+ )
47
+ descendants = data["include_descendants"]
48
+ if type(descendants) is not bool:
49
+ raise TypeError("Invalid activity group descendants flag")
50
+ return cls(
51
+ group_id, expanded, ToolAnchor(run, turn, _identity(data["tool_id"])), descendants
52
+ )
53
+
54
+
55
+ def _identity(value: object) -> str:
56
+ if not isinstance(value, str):
57
+ raise TypeError("Invalid activity group identifier")
58
+ if not value or len(value) > 128:
59
+ raise ValueError("Invalid activity group identifier length")
60
+ return value
61
+
62
+
63
+ @dataclass(frozen=True, slots=True)
64
+ class ToolRows:
65
+ anchor: ToolAnchor
66
+ parent: ToolAnchor | None
67
+ kind: ToolKind
68
+ handled: bool
69
+ start: int
70
+ stop: int
71
+
72
+ @property
73
+ def routine(self) -> bool:
74
+ return self.handled and self.kind in {
75
+ ToolKind.COMMAND,
76
+ ToolKind.READ,
77
+ ToolKind.SEARCH,
78
+ ToolKind.LIST,
79
+ }
80
+
81
+
82
+ def group_activity(rows, tools: Sequence[ToolRows], groups: Sequence[ActivityGroup], width: int):
83
+ """Plan the sparse row edits for the tools reachable from the active groups."""
84
+ by_anchor = {tool.anchor: tool for tool in tools}
85
+ scopes = {}
86
+ for group in groups:
87
+ if group.anchor in by_anchor:
88
+ scopes.setdefault(group.anchor, group)
89
+
90
+ claimed = set(scopes)
91
+ entries_by_group = []
92
+ for group in groups:
93
+ if not group.selected:
94
+ continue
95
+ selected = []
96
+ for anchor in group.selected:
97
+ tool = by_anchor.get(anchor)
98
+ if tool is not None and tool.routine and anchor not in claimed:
99
+ claimed.add(anchor)
100
+ selected.append(tool)
101
+ if selected:
102
+ first = min(tool.start for tool in selected)
103
+ entries_by_group.append((group, first, True, selected))
104
+
105
+ members = {anchor: [] for anchor in scopes}
106
+ for tool in tools:
107
+ if not tool.routine or tool.anchor in claimed:
108
+ continue
109
+ owner = _owner(tool, by_anchor, scopes)
110
+ if owner is not None:
111
+ members[owner].append(tool)
112
+ for anchor, entries in members.items():
113
+ if entries:
114
+ entries_by_group.append((scopes[anchor], by_anchor[anchor].stop - 1, False, entries))
115
+
116
+ hidden = []
117
+ summaries = {}
118
+ for group, position, before, entries in entries_by_group:
119
+ count = len(entries)
120
+ noun = "tool" if count == 1 else "tools"
121
+ label = f" {count} completed {noun} · {'expanded' if group.expanded else 'collapsed'}"
122
+ summaries[position, before] = group.group_id, fit_cells(label, width)
123
+ if not group.expanded:
124
+ for tool in entries:
125
+ start = tool.start
126
+ if start > 0 and rows[start - 1][0] == "blank":
127
+ start -= 1
128
+ hidden.append((start, tool.stop))
129
+
130
+ insertions = [
131
+ (position if before else position + 1, group_id, ("muted", text))
132
+ for (position, before), (group_id, text) in sorted(summaries.items())
133
+ ]
134
+ return hidden, insertions
135
+
136
+
137
+ def _owner(tool: ToolRows, by_anchor, scopes) -> ToolAnchor | None:
138
+ parent = tool.parent
139
+ # Tool edges are explicit. The number of tool blocks bounds even corrupt cycles.
140
+ for depth in range(len(by_anchor)):
141
+ if parent is None or parent.run != tool.anchor.run:
142
+ return None
143
+ if (group := scopes.get(parent)) is not None and (depth == 0 or group.include_descendants):
144
+ return parent
145
+ ancestor = by_anchor.get(parent)
146
+ if ancestor is None or ancestor.anchor == tool.anchor:
147
+ return None
148
+ parent = ancestor.parent
149
+ return None
@@ -0,0 +1,127 @@
1
+ """Agent panels for the terminal: the subagents pack's panels, or a single-agent panel.
2
+
3
+ The subagents pack supplies the side-agent and subagent panels through the
4
+ ``synth_code.agent_panel`` entry-point group. The public edition is single-agent and
5
+ ships without that pack, so the panel is resolved lazily: when the pack is absent, or
6
+ the runtime announces the public edition, the terminal gets ``SingleAgentPanels``.
7
+ The pack's presence is read with ``find_spec`` so a real failure inside a shipped pack
8
+ (or stale entry-point metadata) still raises instead of silently degrading.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from collections.abc import Callable
14
+ from functools import cache
15
+ from importlib.util import find_spec
16
+ from typing import Any, Protocol
17
+
18
+ from .edition import Edition, side_agents_available
19
+
20
+ __all__ = [
21
+ "SUBAGENTS_PACK",
22
+ "AgentPanelView",
23
+ "SingleAgentPanels",
24
+ "agent_panels",
25
+ "subagent_snapshot",
26
+ ]
27
+
28
+ SUBAGENTS_PACK = "synth_code_plugins.subagents"
29
+ _ENTRY_GROUP = "synth_code.agent_panel"
30
+
31
+
32
+ class AgentPanelView(Protocol):
33
+ """The panel surface the terminal, journal, layout and viewport use."""
34
+
35
+ seen: dict[str, int]
36
+ agents: dict[str, Any]
37
+ group: str | None
38
+ selected: str | None
39
+ focused: bool
40
+ detail: bool
41
+ offset: int
42
+
43
+ def observe(self, event: dict) -> None: ...
44
+ def observe_live(self, frame: dict) -> None: ...
45
+ def open(self, group: str | None, *, finding: bool = False) -> None: ...
46
+ def move(self, step: int) -> None: ...
47
+ def enter(self) -> None: ...
48
+ def back(self) -> None: ...
49
+ def unread(self, key: str) -> bool: ...
50
+ def rows(self, events, width: int, capacity: int, advisor_model: str = "") -> list: ...
51
+ def title(self) -> str: ...
52
+ def subagent_summary(self) -> str: ...
53
+
54
+
55
+ class SingleAgentPanels:
56
+ """The panel of a single-agent session: no side agents, no subagents, never opens.
57
+
58
+ Opening a group leaves the panel closed, so F2/F3, ``/sidebar`` and panel requests
59
+ from a runtime that predates the edition field are inert rather than failing.
60
+ Unread findings already recorded in the saved view are kept as they were.
61
+ """
62
+
63
+ def __init__(self, seen: dict[str, int]) -> None:
64
+ self.seen = seen
65
+ self.agents: dict[str, Any] = {}
66
+ self.group: str | None = None
67
+ self.selected: str | None = None
68
+ self.focused = False
69
+ self.detail = False
70
+ self.offset = 0
71
+
72
+ def observe(self, event: dict) -> None:
73
+ return None
74
+
75
+ def observe_live(self, frame: dict) -> None:
76
+ return None
77
+
78
+ def open(self, group: str | None, *, finding: bool = False) -> None:
79
+ self.group, self.selected, self.focused, self.detail, self.offset = (
80
+ None, None, False, False, 0,
81
+ )
82
+
83
+ def move(self, step: int) -> None:
84
+ return None
85
+
86
+ def enter(self) -> None:
87
+ return None
88
+
89
+ def back(self) -> None:
90
+ self.open(None)
91
+
92
+ def unread(self, key: str) -> bool:
93
+ return False
94
+
95
+ def rows(self, events, width: int, capacity: int, advisor_model: str = "") -> list:
96
+ return [("muted", "This edition runs a single agent")]
97
+
98
+ def title(self) -> str:
99
+ return "Agent"
100
+
101
+ def subagent_summary(self) -> str:
102
+ return ""
103
+
104
+
105
+ def subagents_shipped() -> bool:
106
+ return find_spec(SUBAGENTS_PACK) is not None
107
+
108
+
109
+ @cache
110
+ def _pack_entries() -> dict[str, Callable[..., Any]]:
111
+ from synth_code_plugins._sdk.discovery import bundled_entries
112
+
113
+ return {entry.name: entry.load() for entry in bundled_entries(_ENTRY_GROUP)}
114
+
115
+
116
+ def agent_panels(seen: dict[str, int], edition: Edition) -> AgentPanelView:
117
+ """Build the terminal's agent panel for this edition and build."""
118
+ if side_agents_available(edition) and subagents_shipped():
119
+ return _pack_entries()["panel"](seen)
120
+ return SingleAgentPanels(seen)
121
+
122
+
123
+ def subagent_snapshot(active_nodes: dict) -> dict:
124
+ """Bounded subagent status for turn context; empty when the pack is not shipped."""
125
+ if not subagents_shipped():
126
+ return {}
127
+ return _pack_entries()["status"](active_nodes)