code-coordinator 0.5.414__py3-none-any.whl → 0.5.415__py3-none-any.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-coordinator
3
- Version: 0.5.414
3
+ Version: 0.5.415
4
4
  Summary: Coordinate Claude Code workers across multiple machines and repos.
5
5
  Author-email: John Donaghy <johnfdonaghy@gmail.com>
6
6
  License-Expression: LicenseRef-FSL-1.1-MIT
@@ -1,4 +1,4 @@
1
- code_coordinator-0.5.414.dist-info/licenses/LICENSE,sha256=851BVZZwf_pEv2ydSlMmcZrwnwSS5YJ98wdLze7lyL8,4212
1
+ code_coordinator-0.5.415.dist-info/licenses/LICENSE,sha256=851BVZZwf_pEv2ydSlMmcZrwnwSS5YJ98wdLze7lyL8,4212
2
2
  coord/__init__.py,sha256=3FN2qrrxtW87xSsSD557YcMwHLDahnFK8LvqQI7Wlf4,9783
3
3
  coord/_board_mapping.py,sha256=5FTW-8Dg5SzHvszdFj9MuAirpe2KmRqgipZWBAhgUJI,11627
4
4
  coord/acceptance.py,sha256=oAec-wQbrcR5PPfI9NW8JJYipfQ9-3EDpmMmxrP3pQM,90211
@@ -173,9 +173,9 @@ coord/commands/terminal.py,sha256=62dgo7Te3lwQe8oVzPVpjkWdgGS0oOhpCpXINRcboHA,13
173
173
  coord/commands/test_gate.py,sha256=Novp_WYVIbwQvhleifwM80cXSZUmcyuVmUTO6qv1c-k,39555
174
174
  coord/commands/tui.py,sha256=GX4LsgMk08itlURCgkOKqWgjnv38uIfFSWM3xrz9T_A,18193
175
175
  coord/dashboard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
176
- coord/dashboard/fixture.py,sha256=NIz7912fZiRe7Ixe8dN0L5e2N9onxYncuQZ2GkOxou8,30470
176
+ coord/dashboard/fixture.py,sha256=EX8p0m004lM0cZyQJR1n8-EG-ETEpUB8l0BdBnRQwE8,31519
177
177
  coord/dashboard/index.html,sha256=XzipoURZAP46Tggas-pSMq8Fb1ETX9TyAJy2ItNVigc,31463
178
- coord/dashboard/server.py,sha256=5xZYyatM2v9ViiGl9hNwGc13GOBlgLZcyCFjX5Pq6TE,244334
178
+ coord/dashboard/server.py,sha256=NKAM-wKDPRH_45RvZnxzwHA30BFZWQrP_k4kAlJ10k0,253861
179
179
  coord/dashboard/terminal.py,sha256=wR5rfWQCZ0yO5bXCkqa0t-a1g5YAQ-20LC6icZdGWHM,14647
180
180
  coord/deploy/README.md,sha256=DG_q36KeW0LQ32ElU11wjfjULO7xGUoiPIFEGPW41k0,1391
181
181
  coord/deploy/coord-agent.service,sha256=GSo_2iqCx4zv4-85LGnaINsu-BdPHpG64I8xfULKcUk,6392
@@ -267,8 +267,8 @@ coord/skills/review-verdict-recovery/SKILL.md,sha256=Grg8GWkJLK20ct2YiigbTFfNOki
267
267
  coord/skills/tui-quadraui-workflow/SKILL.md,sha256=4hUZza9wSSnPhf0eRAOh2r_MQZxK2pXYO5g-kxmJq-U,3832
268
268
  coord/skills/update-issue/SKILL.md,sha256=VrPinEmLZrCSNDrnz96hQomyO403o5c4i0RdsnUnWA0,3642
269
269
  coord/templates/deploy-cloudflare.node.yml,sha256=icsTiWn2ziQJnpZODhhFKYlnqjt2xAXsbwlQufdxhuM,2078
270
- code_coordinator-0.5.414.dist-info/METADATA,sha256=H5tixXWDCLrONVDhfnBizWO2Wgd2KCaqv-cLF1AyukM,27178
271
- code_coordinator-0.5.414.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
272
- code_coordinator-0.5.414.dist-info/entry_points.txt,sha256=o-Hq8pvG7ReGePvN_4iOKjLNqiq-MJ43HbPurqjNPZo,41
273
- code_coordinator-0.5.414.dist-info/top_level.txt,sha256=w5sTrXesTCebhXyYv2qufOZGo0PoD1Lxgn0Q3MAXjh4,6
274
- code_coordinator-0.5.414.dist-info/RECORD,,
270
+ code_coordinator-0.5.415.dist-info/METADATA,sha256=e9HaJgQkUUQSHo7vwPQY3H_l-Oc34DkBKm2pRl87KQk,27178
271
+ code_coordinator-0.5.415.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
272
+ code_coordinator-0.5.415.dist-info/entry_points.txt,sha256=o-Hq8pvG7ReGePvN_4iOKjLNqiq-MJ43HbPurqjNPZo,41
273
+ code_coordinator-0.5.415.dist-info/top_level.txt,sha256=w5sTrXesTCebhXyYv2qufOZGo0PoD1Lxgn0Q3MAXjh4,6
274
+ code_coordinator-0.5.415.dist-info/RECORD,,
@@ -48,6 +48,7 @@ Fixture schema (every key optional except ``board``)::
48
48
  "report_results": {"issue-activity": {...coord.reports.ReportResult.to_dict()...}},
49
49
  "review_findings": {"rev-1": {"verdict": "approve", "body": "..."}},
50
50
  "diffs": {"work-1": "diff --git ..."},
51
+ "logs": {"work-1": "{\"type\": \"turn\", ...}\n{\"type\": \"tool\", ...}\n"},
51
52
  "chat_reply": "canned /api/chat response text",
52
53
  "events": [ {"after": 0.25, "type": "board_updated", "data": {}} ],
53
54
  "autoplay_events": false, # play the script at startup too (default: no)
@@ -213,6 +214,10 @@ class FixtureServer:
213
214
  report_results_raw: dict = field(default_factory=dict)
214
215
  review_findings_raw: dict = field(default_factory=dict)
215
216
  diffs: dict = field(default_factory=dict)
217
+ #: #3195: seeded NDJSON log text backing `GET /api/assignment/{id}/log`,
218
+ #: keyed by assignment id — see `log()`. One canned string per id, same
219
+ #: convention as `diffs` above.
220
+ logs: dict = field(default_factory=dict)
216
221
  chat_reply: str = "fixture mode: the coordinator assistant is not wired up."
217
222
  events: list[ScriptedEvent] = field(default_factory=list)
218
223
  autoplay_events: bool = False
@@ -372,6 +377,15 @@ class FixtureServer:
372
377
  def diff(self, assignment_id: str) -> str:
373
378
  return self.diffs.get(assignment_id, "")
374
379
 
380
+ def log(self, assignment_id: str) -> str:
381
+ """Seeded NDJSON log text for *assignment_id* (#3195), or ``""`` if
382
+ unseeded — same one-canned-string-per-id shape as :meth:`diff`. A
383
+ fixture that wants a partial-then-resumed stream seeds the FULL
384
+ text here; `api_assignment_log`'s fixture branch slices it at the
385
+ client's requested `since` offset itself, exactly like the live
386
+ agent-proxy path does with the real file's bytes."""
387
+ return self.logs.get(assignment_id, "")
388
+
375
389
  def config(self, fallback: Config | None = None) -> Config:
376
390
  """Resolve the Config the seeded server runs with.
377
391
 
@@ -606,6 +620,10 @@ def parse_fixture(raw: Any, *, path: Path | None = None) -> FixtureServer:
606
620
  if not all(isinstance(v, str) for v in diffs.values()):
607
621
  raise FixtureError("fixture 'diffs' values must be strings")
608
622
 
623
+ logs = _as_dict(raw.get("logs"), "logs")
624
+ if not all(isinstance(v, str) for v in logs.values()):
625
+ raise FixtureError("fixture 'logs' values must be strings")
626
+
609
627
  report_catalogue_raw = raw.get("report_catalogue")
610
628
  if report_catalogue_raw is not None and not isinstance(report_catalogue_raw, dict):
611
629
  raise FixtureError(
@@ -646,6 +664,7 @@ def parse_fixture(raw: Any, *, path: Path | None = None) -> FixtureServer:
646
664
  report_results_raw=report_results_raw,
647
665
  review_findings_raw=_as_dict(raw.get("review_findings"), "review_findings"),
648
666
  diffs=diffs,
667
+ logs=logs,
649
668
  events=_parse_events(raw.get("events")),
650
669
  autoplay_events=bool(raw.get("autoplay_events", False)),
651
670
  now=now,
coord/dashboard/server.py CHANGED
@@ -45,6 +45,7 @@ from coord.events import (
45
45
  EventSource,
46
46
  build_events_route,
47
47
  )
48
+ from coord.events import _format_log_event as _format_agent_log_sse_event
48
49
  from coord.board_schema import BoardDriveQueueEntry
49
50
  from coord.board_service import read_board, write_board
50
51
  from coord.drive_queue import (
@@ -684,6 +685,55 @@ def _fetch_agent_status(host: str, port: int = AGENT_PORT, timeout: float = 5.0)
684
685
  return None
685
686
 
686
687
 
688
+ # #3195: GET /api/assignment/{id}/log proxy tuning — the same defaults the
689
+ # agent's own /stream/{id} (coord/events.py's stream_assignment_log) uses for
690
+ # its poll cadence and keepalive, so a live leg feels the same whether the
691
+ # TUI talks to the agent directly or coord-web talks to it through here.
692
+ _LOG_PROXY_POLL_INTERVAL_S = 1.0
693
+ _LOG_PROXY_KEEPALIVE_S = 15.0
694
+ # After this many consecutive network failures reaching the owning agent,
695
+ # give up and tell the client rather than polling forever — an agent that's
696
+ # down for maintenance must not turn into an SSE stream that hangs open with
697
+ # no signal.
698
+ _LOG_PROXY_MAX_CONSECUTIVE_ERRORS = 5
699
+ _LOG_PROXY_SSE_HEADERS = {
700
+ "Cache-Control": "no-cache, no-transform",
701
+ "X-Accel-Buffering": "no",
702
+ "Connection": "keep-alive",
703
+ }
704
+
705
+
706
+ def _fetch_agent_log(
707
+ host: str,
708
+ assignment_id: str,
709
+ since: int,
710
+ port: int = AGENT_PORT,
711
+ timeout: float = 10.0,
712
+ ) -> tuple[int, bytes, dict]:
713
+ """Synchronous ``GET /logs/{id}?since=N`` against an agent — safe to call
714
+ from a thread executor (#3195).
715
+
716
+ Returns ``(status_code, body, headers)``. ``status_code`` is ``0`` for a
717
+ network-level failure (agent host unreachable) — distinct from an actual
718
+ HTTP status the agent returned — so the SSE proxy loop above can tell
719
+ "the agent said no" from "we couldn't even ask it" and retry the latter
720
+ a bounded number of times instead of surfacing it as a hard 404.
721
+ """
722
+ try:
723
+ resp = httpx.get(
724
+ f"http://{host}:{port}/logs/{assignment_id}",
725
+ params={"since": since} if since else None,
726
+ timeout=timeout,
727
+ )
728
+ return (
729
+ resp.status_code,
730
+ resp.content,
731
+ {k.lower(): v for k, v in resp.headers.items()},
732
+ )
733
+ except httpx.HTTPError:
734
+ return 0, b"", {}
735
+
736
+
687
737
  async def _poll_once(
688
738
  config: Config,
689
739
  event_source: EventSource,
@@ -1781,6 +1831,50 @@ def openapi_spec() -> dict:
1781
1831
  },
1782
1832
  }
1783
1833
  },
1834
+ "/api/assignment/{id}/log": {
1835
+ "get": {
1836
+ "summary": (
1837
+ "#3195: stream an assignment's turn-by-turn NDJSON log "
1838
+ "(SSE), proxied from the owning agent's GET /logs/{id}"
1839
+ ),
1840
+ "description": (
1841
+ "The dashboard already knows which machine owns an "
1842
+ "assignment (board state) — the caller never passes "
1843
+ "one. Streams `text/event-stream`: `event: log` frames "
1844
+ "carry the agent's NDJSON log bytes verbatim (never "
1845
+ "reparsed here — a second parser here would drift from "
1846
+ "the TUI's own turn-by-turn rendering), a final "
1847
+ "`event: end` frame closes the stream once the "
1848
+ "assignment reaches a terminal status, and "
1849
+ "`event: error` reports an agent-side failure. The "
1850
+ "`id:` on each frame is a byte offset usable as "
1851
+ "`Last-Event-ID` (or a `?since=` query param) to "
1852
+ "resume a dropped connection. A finished assignment "
1853
+ "still gets its whole log back, as the first frame."
1854
+ ),
1855
+ "parameters": [
1856
+ _dashboard_path_param("id", "assignment id"),
1857
+ {
1858
+ "name": "since",
1859
+ "in": "query",
1860
+ "required": False,
1861
+ "schema": {"type": "integer"},
1862
+ "description": (
1863
+ "byte offset to resume from — same cursor as "
1864
+ "Last-Event-ID"
1865
+ ),
1866
+ },
1867
+ ],
1868
+ "responses": {
1869
+ "200": {"description": "text/event-stream"},
1870
+ "404": {
1871
+ "description": (
1872
+ "Unknown assignment, or no machine recorded for it"
1873
+ )
1874
+ },
1875
+ },
1876
+ }
1877
+ },
1784
1878
  "/api/chat": {
1785
1879
  "post": {
1786
1880
  "summary": "Stream a chat reply about current board state (SSE)",
@@ -3649,6 +3743,122 @@ def build_app(
3649
3743
  except RuntimeError as e:
3650
3744
  return JSONResponse({"error": str(e)}, status_code=500)
3651
3745
 
3746
+ async def api_assignment_log(request: Request) -> Response:
3747
+ """GET /api/assignment/{id}/log — #3195: coord-web has no route that
3748
+ reaches an assignment's turn-by-turn log; only the owning agent
3749
+ server does (``GET /logs/{id}``, ``coord/agent_app.py`` — the same
3750
+ seam ``coord log <id> --machine NAME`` reads). This resolves the
3751
+ owning machine from board state (the caller never passes one) and
3752
+ streams the agent's response back as SSE, polling with a byte-offset
3753
+ cursor — the same mechanism the agent's own ``/stream/{id}``
3754
+ (``coord.events.stream_assignment_log``) uses to tail a local file,
3755
+ just polling over HTTP instead of reading bytes off disk directly.
3756
+
3757
+ Parses nothing: each ``event: log`` frame carries the agent's NDJSON
3758
+ log bytes verbatim, via the SAME ``_format_log_event`` framing the
3759
+ agent's own stream uses (imported as ``_format_agent_log_sse_event``)
3760
+ — one answer for "how is a log chunk framed as SSE", not a second
3761
+ implementation that could drift from it. A finished assignment still
3762
+ gets its whole log back, as the very first frame (offset 0 reads the
3763
+ complete file).
3764
+ """
3765
+ assignment_id = request.path_params["id"]
3766
+ board = _read_board()
3767
+ assignment = board.find_by_id(assignment_id)
3768
+ if assignment is None:
3769
+ return JSONResponse({"error": "assignment not found"}, status_code=404)
3770
+
3771
+ since_raw = (
3772
+ request.headers.get("last-event-id")
3773
+ or request.query_params.get("since")
3774
+ or "0"
3775
+ )
3776
+ try:
3777
+ start_offset = max(0, int(since_raw))
3778
+ except ValueError:
3779
+ start_offset = 0
3780
+
3781
+ if _fixture is not None:
3782
+ # Seeded log text — never reach a real agent in fixture mode.
3783
+ text = _fixture.log(assignment_id)
3784
+ body_bytes = text.encode("utf-8")
3785
+
3786
+ async def canned():
3787
+ yield b"retry: 2000\n\n"
3788
+ if start_offset < len(body_bytes):
3789
+ yield _format_agent_log_sse_event(
3790
+ len(body_bytes),
3791
+ body_bytes[start_offset:].decode("utf-8", errors="replace"),
3792
+ )
3793
+ yield f"id: {len(body_bytes)}\nevent: end\ndata: {{}}\n\n".encode("utf-8")
3794
+
3795
+ return StreamingResponse(
3796
+ canned(), media_type="text/event-stream", headers=_LOG_PROXY_SSE_HEADERS
3797
+ )
3798
+
3799
+ machine = next(
3800
+ (m for m in config.machines if m.name == assignment.machine_name), None
3801
+ )
3802
+ if machine is None:
3803
+ return JSONResponse(
3804
+ {"error": f"no machine recorded for assignment {assignment_id!r}"},
3805
+ status_code=404,
3806
+ )
3807
+ host = machine.host
3808
+
3809
+ async def stream():
3810
+ offset = start_offset
3811
+ yield b"retry: 2000\n\n"
3812
+ loop = asyncio.get_running_loop()
3813
+ last_yield = time.monotonic()
3814
+ consecutive_errors = 0
3815
+ while True:
3816
+ if await request.is_disconnected():
3817
+ return
3818
+ status_code, body, headers = await loop.run_in_executor(
3819
+ None, _fetch_agent_log, host, assignment_id, offset
3820
+ )
3821
+ if status_code == 404:
3822
+ yield (
3823
+ f"id: {offset}\nevent: error\ndata: "
3824
+ f"{json.dumps({'error': 'no log file for this assignment'})}\n\n"
3825
+ ).encode("utf-8")
3826
+ return
3827
+ if status_code != 200:
3828
+ # Covers both a real non-200 from the agent and the `0`
3829
+ # sentinel `_fetch_agent_log` returns for a network
3830
+ # failure — bounded retries either way, then a clean
3831
+ # error frame instead of a stream that hangs forever.
3832
+ consecutive_errors += 1
3833
+ if consecutive_errors > _LOG_PROXY_MAX_CONSECUTIVE_ERRORS:
3834
+ yield (
3835
+ f"id: {offset}\nevent: error\ndata: "
3836
+ f"{json.dumps({'error': f'agent unreachable (last status {status_code})'})}\n\n"
3837
+ ).encode("utf-8")
3838
+ return
3839
+ await asyncio.sleep(_LOG_PROXY_POLL_INTERVAL_S)
3840
+ continue
3841
+ consecutive_errors = 0
3842
+ if body:
3843
+ offset += len(body)
3844
+ yield _format_agent_log_sse_event(
3845
+ offset, body.decode("utf-8", errors="replace")
3846
+ )
3847
+ last_yield = time.monotonic()
3848
+ continue
3849
+ agent_status = headers.get("x-coord-log-status", "")
3850
+ if agent_status not in ("running", "pending", ""):
3851
+ yield f"id: {offset}\nevent: end\ndata: {{}}\n\n".encode("utf-8")
3852
+ return
3853
+ if time.monotonic() - last_yield >= _LOG_PROXY_KEEPALIVE_S:
3854
+ yield b": keepalive\n\n"
3855
+ last_yield = time.monotonic()
3856
+ await asyncio.sleep(_LOG_PROXY_POLL_INTERVAL_S)
3857
+
3858
+ return StreamingResponse(
3859
+ stream(), media_type="text/event-stream", headers=_LOG_PROXY_SSE_HEADERS
3860
+ )
3861
+
3652
3862
  async def api_pipeline(request: Request) -> JSONResponse:
3653
3863
  """GET /api/pipeline — return PipelineView for every type='work' assignment.
3654
3864
 
@@ -5170,6 +5380,7 @@ def build_app(
5170
5380
  Route("/api/approve", api_approve, methods=["POST"]),
5171
5381
  Route("/api/reject", api_reject, methods=["POST"]),
5172
5382
  Route("/api/diff/{id}", api_diff, methods=["GET"]),
5383
+ Route("/api/assignment/{id}/log", api_assignment_log, methods=["GET"]),
5173
5384
  Route("/api/chat", api_chat, methods=["POST"]),
5174
5385
  Route("/api/pipeline", api_pipeline, methods=["GET"]),
5175
5386
  Route(