bgAgentsJSON builds a `claude agents --json` array of LIVE entries (pid set) — one per session id (short id = first 8 chars).
(sids ...string)
| 44 | // bgAgentsJSON builds a `claude agents --json` array of LIVE entries |
| 45 | // (pid set) — one per session id (short id = first 8 chars). |
| 46 | func bgAgentsJSON(sids ...string) string { |
| 47 | var b strings.Builder |
| 48 | b.WriteString("[") |
| 49 | for i, sid := range sids { |
| 50 | if i > 0 { |
| 51 | b.WriteString(",") |
| 52 | } |
| 53 | short := sid |
| 54 | if len(short) >= 8 { |
| 55 | short = short[:8] |
| 56 | } |
| 57 | fmt.Fprintf(&b, |
| 58 | `{"pid":%d,"id":%q,"cwd":"/w","kind":"background","startedAt":1,"sessionId":%q,"name":"n","status":"busy","state":"working"}`, |
| 59 | 1000+i, short, sid) |
| 60 | } |
| 61 | b.WriteString("]") |
| 62 | return b.String() |
| 63 | } |
| 64 | |
| 65 | // bgAgentsJSONExited builds a registry entry for an exited session (no |
| 66 | // pid / status — `state` only), as `claude agents --json --all` reports a |
no test coverage detected