@loops-adk/core 0.1.1 → 0.3.0

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.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: supervise-loop-run
3
+ description: Use when an agent needs to observe, monitor, or supervise a running loops job from another process: discover live runs, read a run's state and shape, stream its events, inspect the decisions it made (dispatch/completion/surfacing/revision), or decide whether to intervene. Load this when watching a long run or supervising several at once. Requires the run to have been started with `--supervise`.
4
+ ---
5
+
6
+ # Supervising a loop run
7
+
8
+ A run started with `loops run <file> --supervise` registers itself under `~/.loops/runs/<runId>/` and writes its live state, raw events (`events.jsonl`), and semantic decisions (`semantic.jsonl`) there as it goes. Another process reads those files with no daemon and no socket: the filesystem is the channel. Every command below is read-only; supervising never touches the run.
9
+
10
+ ```bash
11
+ loops run build.loop.ts --supervise # in one terminal (or backgrounded)
12
+ ```
13
+
14
+ ## The loop: list → status → tail → records → decide
15
+
16
+ **`loops list`** (alias `ls`) discovers runs. Each line is the runId, state (`running` / `dead` / a terminal status like `pass`/`fail`/`paused`), current iteration, age, and title. A run whose process is gone is marked `dead`.
17
+
18
+ **`loops status <runId>`** prints a point-in-time snapshot: terminal-or-live state, the loop's shape, the last gate verdict (which gate, met, confidence, reason), the last outcome, and token usage. Use this to answer where a run stands and whether it is healthy.
19
+
20
+ **`loops tail <runId>`** streams the raw event log live (Ctrl-C to stop). It ends on its own when the run reaches a terminal status or its process disappears. Use this to watch a turn unfold.
21
+
22
+ **`loops records <runId>`** is the **primary agent API**: the semantic decision stream, one line per meaningful thing the run decided. This is what an agent reads to reason about a run, not the raw `--json` event firehose. Five kinds:
23
+
24
+ | kind | meaning |
25
+ | --- | --- |
26
+ | `dispatch` | a job or dag-node started |
27
+ | `completion` | a job / loop / dag finished (carries the outcome status + summary) |
28
+ | `surfacing` | a review or kickback raised feedback (carries severity + reason) |
29
+ | `revision-emitted` | an outcome asked for another pass |
30
+ | `revision-routed` | that revision was routed to a target (accepted/rejected) |
31
+
32
+ Filter it down for a machine-readable slice:
33
+
34
+ ```bash
35
+ loops records <runId> --json # everything, as JSONL
36
+ loops records <runId> --kind completion # just what finished
37
+ loops records <runId> --kind revision # both revision kinds (emitted + routed)
38
+ loops records <runId> --path ship/implementation --json # only this subtree of the loop tree
39
+ loops records <runId> --kind surfacing --since 2026-07-01T09:00:00Z
40
+ loops records <runId> --last 20 # the most recent 20 matching records
41
+ ```
42
+
43
+ `--path` is a slash-separated prefix over the record's position in the loop tree. `--kind revision` is the convenience union of `revision-emitted` and `revision-routed`.
44
+
45
+ ## Deciding what to do next
46
+
47
+ Read `records` (and `status` for tokens/gate) to choose an action, since loops does not act for you:
48
+
49
+ - **Converged**: a top-level `completion` with `status: pass`. Done; nothing to do.
50
+ - **Stuck in review**: repeated `surfacing` / `revision-routed` on the same node with a `block`/`should-fix` severity and the iteration climbing toward its cap. The gate is doing its job or the worker cannot satisfy it; inspect the reason and decide whether to let it run, abort, or (if you drive the run) route different feedback.
51
+ - **Dead**: `list` shows `dead`, or `status` says the process is gone with no terminal outcome. The run crashed or was killed; investigate its last `completion`/event.
52
+ - **Budget-bound**: `status` shows tokens near the run's budget; expect a `paused` outcome next.
53
+
54
+ ## Build your own supervisor
55
+
56
+ The read side is on the public surface, so an agent supervising a fleet (killing the ones that drift, watching the ones mid-revision) reads the same files programmatically:
57
+
58
+ ```ts
59
+ import { listRuns, readRunStatus, runEventsPath, runSemanticRecordsPath } from '@loops-adk/core';
60
+ ```
61
+
62
+ `listRuns()` and `readRunStatus(runId)` mirror `list`/`status`; `runEventsPath`/`runSemanticRecordsPath` locate the two JSONL streams to read directly. `semanticRecordsFromEvent(event)` derives the semantic records from a raw event if you tail the event stream yourself.
63
+
64
+ To author or shape the run you are supervising, see `skills/author-loop/SKILL.md`; to compose the agent team inside it, see `skills/design-agent-team/SKILL.md`.