@team-agent/installer 0.2.2 → 0.2.4

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 (49) hide show
  1. package/package.json +1 -1
  2. package/schemas/team.schema.json +6 -0
  3. package/src/team_agent/abnormal_track.py +253 -0
  4. package/src/team_agent/approvals/runtime_prompts.py +1 -1
  5. package/src/team_agent/cli/commands.py +104 -3
  6. package/src/team_agent/cli/parser.py +10 -1
  7. package/src/team_agent/compiler.py +1 -1
  8. package/src/team_agent/coordinator/lifecycle.py +23 -2
  9. package/src/team_agent/diagnose/orphan_cleanup.py +199 -28
  10. package/src/team_agent/display/__init__.py +31 -0
  11. package/src/team_agent/display/adaptive.py +425 -0
  12. package/src/team_agent/display/backend.py +46 -0
  13. package/src/team_agent/display/close.py +6 -0
  14. package/src/team_agent/display/rebuild.py +102 -0
  15. package/src/team_agent/display/tiling.py +156 -0
  16. package/src/team_agent/display/worker_window.py +4 -0
  17. package/src/team_agent/display/workspace.py +36 -127
  18. package/src/team_agent/idle_predicate.py +200 -0
  19. package/src/team_agent/idle_takeover.py +59 -0
  20. package/src/team_agent/idle_takeover_wiring.py +111 -0
  21. package/src/team_agent/launch/core.py +14 -4
  22. package/src/team_agent/leader/__init__.py +444 -61
  23. package/src/team_agent/lifecycle/operations.py +1 -0
  24. package/src/team_agent/lifecycle/start.py +1 -1
  25. package/src/team_agent/message_store/core.py +38 -11
  26. package/src/team_agent/message_store/leader_notification_log.py +47 -26
  27. package/src/team_agent/message_store/schema.py +8 -2
  28. package/src/team_agent/messaging/delivery.py +336 -1
  29. package/src/team_agent/messaging/leader.py +13 -4
  30. package/src/team_agent/messaging/leader_api_errors.py +216 -0
  31. package/src/team_agent/messaging/leader_panes.py +294 -0
  32. package/src/team_agent/messaging/scheduler.py +12 -0
  33. package/src/team_agent/messaging/send.py +54 -26
  34. package/src/team_agent/messaging/tmux_io.py +202 -33
  35. package/src/team_agent/messaging/tmux_prompt.py +87 -0
  36. package/src/team_agent/messaging/trust_auto_answer.py +52 -0
  37. package/src/team_agent/provider_state/README.md +78 -0
  38. package/src/team_agent/provider_state/__init__.py +86 -0
  39. package/src/team_agent/provider_state/claude.py +86 -0
  40. package/src/team_agent/provider_state/codex.py +84 -0
  41. package/src/team_agent/provider_state/common.py +207 -0
  42. package/src/team_agent/provider_state/registry.py +118 -0
  43. package/src/team_agent/restart/orchestration.py +215 -12
  44. package/src/team_agent/runtime.py +65 -15
  45. package/src/team_agent/sessions/capture.py +65 -15
  46. package/src/team_agent/spec.py +63 -3
  47. package/src/team_agent/status/queries.py +32 -1
  48. package/src/team_agent/wake.py +58 -0
  49. package/src/team_agent/watch/__init__.py +145 -0
@@ -0,0 +1,86 @@
1
+ """Claude transcript reader — the ONLY Claude-specific turn-state knowledge.
2
+
3
+ Translates Claude transcript JSONL records into normalized lifecycle facts.
4
+ Real markers (see turn-state-markers-evidence.md):
5
+ - assistant message.stop_reason == "tool_use" -> open turn (working)
6
+ - assistant message.stop_reason == "end_turn" -> turn complete (idle)
7
+ - user text == "[Request interrupted by user]" -> interrupted
8
+ - user tool_result is_error == true -> structured tool error
9
+ - system subtype == "api_error" and level=="error" -> provider api error
10
+ Trailing metadata records (stop_hook_summary / turn_duration / last-prompt /
11
+ ai-title / permission-mode / ...) are ignored for the turn verdict.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from typing import Any
17
+
18
+ from team_agent.provider_state import common
19
+
20
+ _INTERRUPT_TEXT = "[Request interrupted by user]"
21
+
22
+
23
+ def extract_facts(records: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
24
+ facts: list[dict[str, Any]] = []
25
+ diagnostics: list[dict[str, Any]] = []
26
+ for record in records:
27
+ rtype = record.get("type")
28
+ message = record.get("message")
29
+ if rtype == "assistant" and isinstance(message, dict):
30
+ stop_reason = message.get("stop_reason")
31
+ turn_id = record.get("requestId") or record.get("uuid")
32
+ if stop_reason == "end_turn":
33
+ facts.append({"kind": common.TURN_COMPLETE, "turn_id": turn_id, "reason": "end_turn"})
34
+ elif stop_reason == "tool_use":
35
+ facts.append({"kind": common.TURN_OPEN, "turn_id": turn_id, "reason": "tool_use"})
36
+ elif stop_reason == "stop_sequence":
37
+ facts.append({"kind": common.TURN_COMPLETE, "turn_id": turn_id, "reason": "stop_sequence"})
38
+ # other/missing stop_reason on assistant is treated as an open turn fragment
39
+ elif stop_reason is None and isinstance(message.get("content"), list):
40
+ facts.append({"kind": common.TURN_OPEN, "turn_id": turn_id, "reason": "assistant_in_flight"})
41
+ elif rtype == "user" and isinstance(message, dict):
42
+ content = message.get("content")
43
+ if _content_has_interrupt(content):
44
+ facts.append({"kind": common.INTERRUPTED, "turn_id": record.get("uuid"), "reason": "user_interrupt"})
45
+ elif _content_has_tool_error(content):
46
+ facts.append({
47
+ "kind": common.ERROR,
48
+ # the turn being retried/affected, stable across records (C8 dedup)
49
+ "turn_id": record.get("parentUuid") or record.get("uuid"),
50
+ "reason": "tool_result_is_error",
51
+ "signature": "tool_result_is_error",
52
+ "raw": record,
53
+ })
54
+ elif rtype == "system" and record.get("subtype") == "api_error" and record.get("level") == "error":
55
+ facts.append({
56
+ "kind": common.ERROR,
57
+ # api_error retries within a session dedup on (signature, session) (C8)
58
+ "turn_id": record.get("sessionId") or record.get("parentUuid") or record.get("uuid"),
59
+ "reason": "api_error",
60
+ "signature": "api_error",
61
+ "raw": record,
62
+ })
63
+ # everything else (metadata, snapshots, titles) is ignored for the verdict
64
+ return facts, diagnostics
65
+
66
+
67
+ def classify(session_log_text: str, *, process: Any = None) -> dict[str, Any]:
68
+ return common.classify_with_reader(extract_facts, session_log_text, process=process)
69
+
70
+
71
+ def _content_has_interrupt(content: Any) -> bool:
72
+ if not isinstance(content, list):
73
+ return False
74
+ for item in content:
75
+ if isinstance(item, dict) and item.get("type") == "text" and item.get("text") == _INTERRUPT_TEXT:
76
+ return True
77
+ return False
78
+
79
+
80
+ def _content_has_tool_error(content: Any) -> bool:
81
+ if not isinstance(content, list):
82
+ return False
83
+ for item in content:
84
+ if isinstance(item, dict) and item.get("type") == "tool_result" and item.get("is_error") is True:
85
+ return True
86
+ return False
@@ -0,0 +1,84 @@
1
+ """Codex rollout reader — the ONLY Codex-specific turn-state knowledge.
2
+
3
+ Translates Codex rollout JSONL (and app-server jsonrpc) records into normalized
4
+ lifecycle facts. Real markers (see turn-state-markers-evidence.md):
5
+ - event_msg payload.type == "task_started" -> open turn (working)
6
+ - event_msg payload.type == "task_complete" -> turn complete (idle)
7
+ - event_msg payload.type == "turn_aborted" reason=="interrupted" -> interrupted
8
+ App-server schema-derived markers:
9
+ - method "turn/completed" params.turn.status == "failed" -> failed/error
10
+ - method ".../requestApproval" -> approval block
11
+ Telemetry (token_count, agent_message, patch_apply_end, ...) is not a close.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from typing import Any
17
+
18
+ from team_agent.provider_state import common
19
+
20
+
21
+ def extract_facts(records: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
22
+ facts: list[dict[str, Any]] = []
23
+ diagnostics: list[dict[str, Any]] = []
24
+ for record in records:
25
+ rtype = record.get("type")
26
+ payload = record.get("payload") if isinstance(record.get("payload"), dict) else None
27
+ if rtype == "event_msg" and payload is not None:
28
+ ptype = payload.get("type")
29
+ turn_id = payload.get("turn_id")
30
+ if ptype == "task_started":
31
+ facts.append({"kind": common.TURN_OPEN, "turn_id": turn_id, "reason": "task_started"})
32
+ elif ptype == "task_complete":
33
+ facts.append({"kind": common.TURN_COMPLETE, "turn_id": turn_id, "reason": "task_complete"})
34
+ elif ptype == "turn_aborted" and payload.get("reason") == "interrupted":
35
+ facts.append({"kind": common.INTERRUPTED, "turn_id": turn_id, "reason": "interrupted"})
36
+ elif ptype == "turn_aborted":
37
+ facts.append({"kind": common.INTERRUPTED, "turn_id": turn_id, "reason": str(payload.get("reason") or "aborted")})
38
+ elif _is_app_server(record):
39
+ fact = _app_server_fact(record)
40
+ if fact is not None:
41
+ facts.append(fact)
42
+ # response_item (assistant/user messages), token_count, etc. are not verdicts
43
+ return facts, diagnostics
44
+
45
+
46
+ def classify(session_log_text: str, *, process: Any = None) -> dict[str, Any]:
47
+ return common.classify_with_reader(extract_facts, session_log_text, process=process)
48
+
49
+
50
+ def _is_app_server(record: dict[str, Any]) -> bool:
51
+ return record.get("jsonrpc") == "2.0" and isinstance(record.get("method"), str)
52
+
53
+
54
+ def _app_server_fact(record: dict[str, Any]) -> dict[str, Any] | None:
55
+ method = str(record.get("method") or "")
56
+ params = record.get("params") if isinstance(record.get("params"), dict) else {}
57
+ if method == "turn/completed":
58
+ turn = params.get("turn") if isinstance(params.get("turn"), dict) else {}
59
+ status = turn.get("status")
60
+ turn_id = turn.get("id")
61
+ if status == "failed":
62
+ return {
63
+ "kind": common.FAILED,
64
+ "turn_id": turn_id,
65
+ "reason": "turn_failed",
66
+ "signature": "turn_failed",
67
+ "raw": record,
68
+ }
69
+ if status == "completed":
70
+ return {"kind": common.TURN_COMPLETE, "turn_id": turn_id, "reason": "completed"}
71
+ if status == "interrupted":
72
+ return {"kind": common.INTERRUPTED, "turn_id": turn_id, "reason": "interrupted"}
73
+ if status == "inProgress":
74
+ return {"kind": common.TURN_OPEN, "turn_id": turn_id, "reason": "in_progress"}
75
+ return None
76
+ if method.endswith("requestApproval"):
77
+ return {
78
+ "kind": common.APPROVAL,
79
+ "turn_id": params.get("turnId") or params.get("turn_id"),
80
+ "reason": "approval_required",
81
+ "signature": "approval_required",
82
+ "raw": record,
83
+ }
84
+ return None
@@ -0,0 +1,207 @@
1
+ """Shared, provider-neutral plumbing for the turn-state readers.
2
+
3
+ The per-provider readers (claude.py, codex.py) only translate their own record
4
+ shapes into a normalized list of lifecycle facts; everything else — JSONL
5
+ tail parsing, metadata filtering wiring, the verdict decision, and the
6
+ process-identity liveness guard — lives here so it is written once.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ from typing import Any, Callable
13
+
14
+ # Normalized lifecycle fact kinds emitted by every reader.
15
+ TURN_OPEN = "turn_open"
16
+ TURN_COMPLETE = "turn_complete"
17
+ INTERRUPTED = "interrupted"
18
+ FAILED = "failed"
19
+ APPROVAL = "approval"
20
+ ERROR = "error" # non-closing structured error (e.g. transient api retry / tool is_error)
21
+
22
+ _CLOSING = {TURN_COMPLETE, INTERRUPTED, FAILED}
23
+
24
+
25
+ def parse_jsonl(text: str) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
26
+ """Parse JSONL text into (records, parse_diagnostics).
27
+
28
+ Lines that are blank are skipped. Lines that are not valid JSON objects are
29
+ collected as diagnostics rather than raising — the caller decides whether a
30
+ populated diagnostics list with zero usable records means ``unknown``.
31
+ """
32
+ records: list[dict[str, Any]] = []
33
+ diagnostics: list[dict[str, Any]] = []
34
+ for lineno, raw in enumerate(text.splitlines(), start=1):
35
+ line = raw.strip()
36
+ if not line:
37
+ continue
38
+ try:
39
+ obj = json.loads(line)
40
+ except (ValueError, TypeError):
41
+ diagnostics.append({"kind": "json_decode_error", "line": lineno})
42
+ continue
43
+ if not isinstance(obj, dict):
44
+ diagnostics.append({"kind": "non_object_record", "line": lineno})
45
+ continue
46
+ records.append(obj)
47
+ return records, diagnostics
48
+
49
+
50
+ def decide_state(
51
+ facts: list[dict[str, Any]],
52
+ *,
53
+ process: Any = None,
54
+ parse_diagnostics: list[dict[str, Any]] | None = None,
55
+ had_records: bool,
56
+ extra_diagnostics: list[dict[str, Any]] | None = None,
57
+ ) -> dict[str, Any]:
58
+ """Turn a normalized fact stream into the public classify result.
59
+
60
+ Verdict = the LAST lifecycle fact, not the last physical record. An open
61
+ turn (a ``turn_open`` not yet closed) is a positive "still working" fact
62
+ that survives arbitrary file silence (Gap 32 C14); the only thing that can
63
+ demote it is a failed process-identity guard (Gap 32 C4).
64
+ """
65
+ diagnostics = list(parse_diagnostics or []) + list(extra_diagnostics or [])
66
+
67
+ lifecycle = [f for f in facts if f.get("kind") in (_CLOSING | {TURN_OPEN, APPROVAL})]
68
+ if not lifecycle:
69
+ # No turn-lifecycle fact at all. If the input was unreadable/empty or a
70
+ # changed format with no recognizable records, fail safe to unknown (C5).
71
+ reason = "no_turn_lifecycle_fact"
72
+ if not had_records:
73
+ reason = "unreadable_or_empty"
74
+ elif diagnostics:
75
+ reason = "unrecognized_format"
76
+ return _result("unknown", None, reason, "session_file", [], diagnostics)
77
+
78
+ last = lifecycle[-1]
79
+ kind = last.get("kind")
80
+ turn_id = last.get("turn_id")
81
+ reason = str(last.get("reason") or kind)
82
+
83
+ if kind == TURN_COMPLETE:
84
+ return _result("idle", turn_id, reason or "turn_complete", "session_file", [], diagnostics)
85
+ if kind == INTERRUPTED:
86
+ return _result("idle_interrupted", turn_id, reason or "interrupted", "session_file", ["interrupted"], diagnostics)
87
+ if kind == FAILED:
88
+ return _result("abnormal", turn_id, reason or "turn_failed", "session_file", ["turn_failed"], diagnostics)
89
+ if kind == APPROVAL:
90
+ return _result("blocked_on_human", turn_id, reason or "approval_required", "session_file", ["awaiting_approval"], diagnostics)
91
+
92
+ # kind == TURN_OPEN with no later close → open turn. To declare "working" we
93
+ # must POSITIVELY confirm the recorded process is still alive (C4 fail-safe);
94
+ # missing/partial identity cannot be optimistically read as working.
95
+ verdict, live_reason, live_diag = process_liveness(process)
96
+ if live_diag:
97
+ diagnostics = diagnostics + [live_diag]
98
+ if verdict == "alive":
99
+ return _result("working", turn_id, "open_turn", "session_file", [], diagnostics)
100
+ if verdict == "dead":
101
+ return _result("abnormal", turn_id, "crashed_mid_turn", "process_guard", ["crashed_mid_turn", live_reason], diagnostics)
102
+ # unverifiable: cannot confirm alive → fail safe to unknown, never working.
103
+ return _result("unknown", turn_id, "process_identity_unverified", "process_guard", ["process_identity_unverified", live_reason], diagnostics)
104
+
105
+
106
+ _STRONG_IDENTITY_FIELDS = ("start_time", "cmdline", "create_time")
107
+
108
+
109
+ def process_liveness(process: Any) -> tuple[str, str, dict[str, Any] | None]:
110
+ """Process-identity liveness guard (Gap 32 C4) — three-valued.
111
+
112
+ Returns (verdict, reason, diagnostic) where verdict is one of:
113
+ - ``"alive"`` — positively confirmed the same process is running
114
+ - ``"dead"`` — confirmed replaced/exited (identity mismatch or flag)
115
+ - ``"unverifiable"`` — identity missing/partial; CANNOT be read as working
116
+
117
+ Identity, not bare PID: aliveness must be affirmatively confirmed by a strong
118
+ identity field (start_time / cmdline / create_time) present and equal in BOTH
119
+ the recorded and the current snapshot. Missing/partial info is fail-safe
120
+ unverifiable, never optimistically "alive".
121
+
122
+ Accepted ``process`` shapes (any one):
123
+ - None / non-dict → unverifiable
124
+ - {"alive"|"running": bool} → explicit
125
+ - {"identity_match": bool} → explicit identity verdict
126
+ - {"expected"|"recorded": {...}, "current"|"observed": {...}}
127
+ """
128
+ if process is None or not isinstance(process, dict):
129
+ return "unverifiable", "process_identity_missing", {"kind": "process_identity_unverified"}
130
+ if process.get("alive") is False or process.get("running") is False:
131
+ return "dead", "process_not_running", {"kind": "process_dead", "detail": "not_running"}
132
+ if process.get("identity_match") is False:
133
+ return "dead", "process_identity_mismatch", {"kind": "process_identity_mismatch"}
134
+ if process.get("alive") is True or process.get("running") is True or process.get("identity_match") is True:
135
+ return "alive", "process_alive", None
136
+ recorded = process.get("recorded") if isinstance(process.get("recorded"), dict) else process.get("expected")
137
+ current = process.get("current") if isinstance(process.get("current"), dict) else process.get("observed")
138
+ if not (isinstance(recorded, dict) and isinstance(current, dict)):
139
+ return "unverifiable", "process_identity_partial", {"kind": "process_identity_unverified"}
140
+ if current.get("alive") is False or current.get("running") is False:
141
+ return "dead", "process_not_running", {"kind": "process_dead", "detail": "current_not_running"}
142
+ # Any shared strong identity field that DIFFERS = confirmed replacement.
143
+ for key in _STRONG_IDENTITY_FIELDS:
144
+ if key in recorded and key in current and recorded.get(key) != current.get(key):
145
+ return "dead", f"process_identity_mismatch:{key}", {
146
+ "kind": "process_identity_mismatch",
147
+ "field": key,
148
+ "recorded": recorded.get(key),
149
+ "current": current.get(key),
150
+ }
151
+ # Require at least one strong identity field present+equal in BOTH, with no
152
+ # recorded strong field missing from current (else we cannot confirm).
153
+ recorded_strong = [k for k in _STRONG_IDENTITY_FIELDS if k in recorded]
154
+ confirmed = [k for k in recorded_strong if k in current and recorded.get(k) == current.get(k)]
155
+ missing = [k for k in recorded_strong if k not in current]
156
+ if confirmed and not missing:
157
+ return "alive", "process_identity_match", None
158
+ return "unverifiable", "process_identity_partial", {
159
+ "kind": "process_identity_unverified",
160
+ "recorded_strong": recorded_strong,
161
+ "confirmed": confirmed,
162
+ "missing": missing,
163
+ }
164
+
165
+
166
+ def process_is_live(process: Any) -> tuple[bool, str, dict[str, Any] | None]:
167
+ """Boolean wrapper used by conservative callers (e.g. whole-team-gone): a
168
+ process is treated as live unless it is CONFIRMED dead. Unverifiable counts
169
+ as live here so we never falsely declare the team gone."""
170
+ verdict, reason, diag = process_liveness(process)
171
+ return (verdict != "dead"), reason, diag
172
+
173
+
174
+ def _result(
175
+ state: str,
176
+ turn_id: str | None,
177
+ reason: str,
178
+ source: str,
179
+ annotations: list[str],
180
+ diagnostics: list[dict[str, Any]],
181
+ ) -> dict[str, Any]:
182
+ return {
183
+ "state": state,
184
+ "turn_id": turn_id,
185
+ "reason": reason,
186
+ "source": source,
187
+ "annotations": list(annotations),
188
+ "diagnostics": list(diagnostics),
189
+ }
190
+
191
+
192
+ def classify_with_reader(
193
+ extract_facts: Callable[[list[dict[str, Any]]], tuple[list[dict[str, Any]], list[dict[str, Any]]]],
194
+ session_log_text: str,
195
+ *,
196
+ process: Any = None,
197
+ ) -> dict[str, Any]:
198
+ """Run a provider reader's fact extractor through the shared pipeline."""
199
+ records, parse_diag = parse_jsonl(session_log_text or "")
200
+ facts, extra_diag = extract_facts(records)
201
+ return decide_state(
202
+ facts,
203
+ process=process,
204
+ parse_diagnostics=parse_diag,
205
+ had_records=bool(records),
206
+ extra_diagnostics=extra_diag,
207
+ )
@@ -0,0 +1,118 @@
1
+ """Per-CLI idle/turn-state registry — PURE INFRA DATA (Gap 32 C7).
2
+
3
+ This module is data only: session-file locations, turn-lifecycle marker
4
+ descriptions, and per-CLI error white/black lists. It carries no predicate,
5
+ abnormal, or wake logic. Adding a new provider is one entry here plus one
6
+ reader module under ``provider_state/``; the neutral layers never change.
7
+
8
+ The registry is shipped with the runtime as infra data — it is NOT
9
+ user-mandatory configuration and is never loaded from a workspace.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Any
15
+
16
+ # Each entry is consumed by the matching provider reader. The neutral
17
+ # idle_predicate / abnormal_track / wake modules never read provider names.
18
+ _PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
19
+ "claude": {
20
+ "kind": "claude",
21
+ "reader_module": "team_agent.provider_state.claude",
22
+ "source": "infra",
23
+ "file_location": {
24
+ "root": "~/.claude/projects",
25
+ "layout": "<cwd-slug>/<session_id>.jsonl",
26
+ "format": "transcript-jsonl",
27
+ },
28
+ "event_types": {
29
+ "turn_open": "assistant message.stop_reason == tool_use",
30
+ "turn_complete": "assistant message.stop_reason == end_turn",
31
+ "interrupted": "user text == [Request interrupted by user]",
32
+ "tool_error": "user tool_result is_error == true",
33
+ "api_error": "system subtype == api_error and level == error",
34
+ },
35
+ "metadata_ignore": [
36
+ "stop_hook_summary",
37
+ "turn_duration",
38
+ "last-prompt",
39
+ "ai-title",
40
+ "permission-mode",
41
+ "file-history-snapshot",
42
+ "queue-operation",
43
+ ],
44
+ "error_whitelist": [],
45
+ "error_blacklist": [
46
+ "api_error",
47
+ "rate limit",
48
+ "overloaded",
49
+ "traceback",
50
+ "panic",
51
+ ],
52
+ "error_lists": {
53
+ "whitelist": [],
54
+ "blacklist": ["api_error", "rate limit", "overloaded", "traceback", "panic"],
55
+ },
56
+ },
57
+ "codex": {
58
+ "kind": "codex",
59
+ "reader_module": "team_agent.provider_state.codex",
60
+ "source": "infra",
61
+ "file_location": {
62
+ "root": "~/.codex/sessions",
63
+ "layout": "<YYYY>/<MM>/<DD>/rollout-<stamp>-<session_id>.jsonl",
64
+ "format": "rollout-jsonl",
65
+ },
66
+ "event_types": {
67
+ "turn_open": "event_msg payload.type == task_started",
68
+ "turn_complete": "event_msg payload.type == task_complete",
69
+ "interrupted": "event_msg payload.type == turn_aborted and reason == interrupted",
70
+ "failed": "app-server turn.status == failed",
71
+ "approval": "app-server method endswith requestApproval",
72
+ },
73
+ "metadata_ignore": [
74
+ "token_count",
75
+ "agent_message",
76
+ "context_compacted",
77
+ "mcp_tool_call_end",
78
+ "patch_apply_end",
79
+ "web_search_end",
80
+ "thread_goal_updated",
81
+ ],
82
+ "error_whitelist": [],
83
+ "error_blacklist": [
84
+ "failed",
85
+ "api error",
86
+ "rate limit",
87
+ "overloaded",
88
+ "traceback",
89
+ "panic",
90
+ ],
91
+ "error_lists": {
92
+ "whitelist": [],
93
+ "blacklist": ["failed", "api error", "rate limit", "overloaded", "traceback", "panic"],
94
+ },
95
+ },
96
+ }
97
+
98
+
99
+ def get_provider_registry(provider: str | None = None) -> Any:
100
+ """Return the infra registry.
101
+
102
+ With no argument, returns a copy of the whole per-CLI registry mapping.
103
+ With a provider name, returns that provider's entry (or ``None``).
104
+ """
105
+ if provider is None:
106
+ return {name: _copy_entry(entry) for name, entry in _PROVIDER_REGISTRY.items()}
107
+ entry = _PROVIDER_REGISTRY.get(provider)
108
+ return _copy_entry(entry) if entry is not None else None
109
+
110
+
111
+ def supported_providers() -> list[str]:
112
+ return sorted(_PROVIDER_REGISTRY)
113
+
114
+
115
+ def _copy_entry(entry: dict[str, Any]) -> dict[str, Any]:
116
+ import copy
117
+
118
+ return copy.deepcopy(entry)