feat(operations): מסך "סוכנים פעילים" + ניהול ריצות (live-runs/log/cancel) (G12/X15, #119) #185

Merged
chaim merged 1 commits from worktree-agent-live-ops into main 2026-06-11 13:28:05 +00:00
Owner

מה ולמה

פאנל חדש ב-/operations → "סוכנים פעילים" שמראה אילו סוכני Paperclip עובדים כעת (רצים+בתור), הפלט החי שלהם, ושליטה מבוקרת: עצירת ריצה ואיפוס session.

סוגר נקודה-עיוורת אמיתית: drain מונע-סוכן (למשל ריקון תור ההלכות ע"י ה-CEO heartbeat) הוא לא שירות pm2 ולא קשור-לתיק, ולכן לא מופיע כתהליך ניתן-לשליטה ב-/operations (רק המונה זז); והפלט הגולמי נגיש היום רק ב-Paperclip UI.

מקור-נתונים — Paperclip heartbeat-runs API (אומת חי מול localhost:3100)

Endpoint שימוש
GET /api/companies/{cid}/live-runs רצים+בתור (agentName/status/issue/outputSilence)
GET /api/heartbeat-runs/{id}/log NDJSON של פלט הסוכן
GET /api/heartbeat-runs/{id}/events timeline
POST /api/heartbeat-runs/{id}/cancel עצירה מבוקרת (לא kill)
POST /api/agents/{id}/runtime-state/reset-session איפוס session תקוע

שינויים

Backend (דרך השער בלבד):

  • web/paperclip_client.py (shell): list_live_runs / get_run_log / get_run_events / cancel_run / reset_agent_session
  • web/agent_platform_port.py: re-export pc_list_live_runs / pc_get_run_log / pc_get_run_events / pc_cancel_run / pc_reset_agent_session
  • web/app.py: GET /api/operations/agents (אגרגציה CMP+CMPA, עמיד לכשל-חברה) + …/runs/{id}/log + …/runs/{id}/events + POST …/runs/{id}/cancel + POST …/agents/{id}/reset-session

Frontend:

  • פאנל "סוכנים פעילים" ב-/operations (polling 4s) + dialog ללוג חי (פרסור NDJSON→טקסט קריא) + כפתורי עצור/אפס
  • hooks ב-operations.ts

Invariants (פרוטוקול כתיבת-קוד)

  • מקיים G12 / INV-PORT1 (שער-הפלטפורמה): כל המגע החדש עם Paperclip עובר דרך agent_platform_port.py בלבד. scripts/leak_guard.py עובר (seam שלם). אסור kill ישיר על process_pid — עוקף את השער + את ה-watchdog/checkpoint.
  • נוגע X6 (UI↔API): endpoints חדשים; npm run api:types יורץ אחרי deploy (נשען על openapi.json החי).

בטיחות

cancel על דריינר ההלכות בטוח — החילוץ checkpointed per-chunk + resumable + self-heal לשורות processing; עצירה מאבדת לכל היותר chunk אחד.

בדיקות

  • python -m py_compile ✓ (שלושת קבצי ה-backend)
  • scripts/leak_guard.py ✓ (G12 שלם)
  • tsc --noEmit ✓ · eslint על הקבצים שנגעו ✓
  • live-runs/log/events אומתו חי מול Paperclip

TaskMaster: legal-ai #119

🤖 Generated with Claude Code

## מה ולמה פאנל חדש ב-**/operations → "סוכנים פעילים"** שמראה אילו סוכני Paperclip עובדים כעת (רצים+בתור), הפלט החי שלהם, ושליטה מבוקרת: **עצירת ריצה** ו**איפוס session**. סוגר נקודה-עיוורת אמיתית: drain מונע-סוכן (למשל ריקון תור ההלכות ע"י ה-CEO heartbeat) הוא לא שירות pm2 ולא קשור-לתיק, ולכן **לא** מופיע כתהליך ניתן-לשליטה ב-/operations (רק המונה זז); והפלט הגולמי נגיש היום רק ב-Paperclip UI. ## מקור-נתונים — Paperclip heartbeat-runs API (אומת חי מול localhost:3100) | Endpoint | שימוש | |----------|-------| | `GET /api/companies/{cid}/live-runs` | רצים+בתור (agentName/status/issue/outputSilence) | | `GET /api/heartbeat-runs/{id}/log` | NDJSON של פלט הסוכן | | `GET /api/heartbeat-runs/{id}/events` | timeline | | `POST /api/heartbeat-runs/{id}/cancel` | עצירה מבוקרת (לא kill) | | `POST /api/agents/{id}/runtime-state/reset-session` | איפוס session תקוע | ## שינויים **Backend (דרך השער בלבד):** - `web/paperclip_client.py` (shell): `list_live_runs` / `get_run_log` / `get_run_events` / `cancel_run` / `reset_agent_session` - `web/agent_platform_port.py`: re-export `pc_list_live_runs` / `pc_get_run_log` / `pc_get_run_events` / `pc_cancel_run` / `pc_reset_agent_session` - `web/app.py`: `GET /api/operations/agents` (אגרגציה CMP+CMPA, עמיד לכשל-חברה) + `…/runs/{id}/log` + `…/runs/{id}/events` + `POST …/runs/{id}/cancel` + `POST …/agents/{id}/reset-session` **Frontend:** - פאנל "סוכנים פעילים" ב-`/operations` (polling 4s) + dialog ללוג חי (פרסור NDJSON→טקסט קריא) + כפתורי עצור/אפס - hooks ב-`operations.ts` ## Invariants (פרוטוקול כתיבת-קוד) - **מקיים G12 / INV-PORT1 (שער-הפלטפורמה):** כל המגע החדש עם Paperclip עובר דרך `agent_platform_port.py` בלבד. `scripts/leak_guard.py` עובר (seam שלם). **אסור** kill ישיר על `process_pid` — עוקף את השער + את ה-watchdog/checkpoint. - **נוגע X6 (UI↔API):** endpoints חדשים; `npm run api:types` יורץ אחרי deploy (נשען על `openapi.json` החי). ## בטיחות `cancel` על דריינר ההלכות בטוח — החילוץ checkpointed per-chunk + resumable + self-heal לשורות `processing`; עצירה מאבדת לכל היותר chunk אחד. ## בדיקות - `python -m py_compile` ✓ (שלושת קבצי ה-backend) - `scripts/leak_guard.py` ✓ (G12 שלם) - `tsc --noEmit` ✓ · eslint על הקבצים שנגעו ✓ - live-runs/log/events אומתו חי מול Paperclip TaskMaster: legal-ai #119 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-11 13:27:30 +00:00
feat(operations): מסך "סוכנים פעילים" + ניהול ריצות (live-runs/log/cancel) (G12/X15, #119)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 6s
2f094b8d84
פאנל ב-/operations שמראה אילו סוכני Paperclip עובדים כעת (רצים+בתור), הפלט החי
שלהם, ושליטה מבוקרת: עצירת ריצה, איפוס session. סוגר את הנקודה-העיוורת שבה drain
מונע-סוכן (למשל ריקון תור הלכות ע"י ה-CEO heartbeat) עוקף את בקרת /operations
שמכירה רק שירותי pm2, והפלט הגולמי נגיש רק ב-Paperclip UI.

מקור-נתונים: Paperclip heartbeat-runs API (אומת חי):
  GET  /api/companies/{cid}/live-runs        — רצים+בתור (agentName/status/issue/outputSilence)
  GET  /api/heartbeat-runs/{id}/log          — NDJSON של פלט הסוכן
  GET  /api/heartbeat-runs/{id}/events        — timeline
  POST /api/heartbeat-runs/{id}/cancel        — עצירה מבוקרת (לא kill — מכבד watchdog+checkpoint)
  POST /api/agents/{id}/runtime-state/reset-session

ארכיטקטורה (G12/INV-PORT1): כל המגע החדש עם Paperclip דרך השער בלבד —
web/paperclip_client.py (shell) → re-export ב-web/agent_platform_port.py →
web/app.py צורך מהשער. leak_guard.py עובר (seam שלם). אסור kill ישיר על
process_pid (עוקף את השער).

Backend:
- paperclip_client: list_live_runs / get_run_log / get_run_events / cancel_run / reset_agent_session
- agent_platform_port: re-export pc_list_live_runs / pc_get_run_log / pc_get_run_events / pc_cancel_run / pc_reset_agent_session
- app.py: GET /api/operations/agents (אגרגציה CMP+CMPA, עמיד לכשל-חברה),
  GET .../runs/{id}/log, GET .../runs/{id}/events, POST .../runs/{id}/cancel,
  POST .../agents/{id}/reset-session

Frontend: פאנל "סוכנים פעילים" ב-/operations (polling 4s) + dialog ללוג חי
(פרסור NDJSON→טקסט קריא) + כפתורי עצור/אפס. הוספת hooks ל-operations.ts.

בטיחות: cancel על דריינר הלכות בטוח — חילוץ checkpointed per-chunk + resumable
+ self-heal לשורות processing.

Invariants: מקיים G12/INV-PORT1 (שער-הפלטפורמה). נוגע X6 (UI↔API).
api:types יורץ אחרי deploy (openapi.json חי).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 07ca76cd87 into main 2026-06-11 13:28:05 +00:00
chaim deleted branch worktree-agent-live-ops 2026-06-11 13:28:05 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#185