The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as SqlClient from "effect/sql/SqlClient"; |
| 3 | |
| 4 | export default Effect.gen(function* () { |
| 5 | const sql = yield* SqlClient.SqlClient; |
| 6 | |
| 7 | // Command reads skip settled subagents by delivery state. Read from payload_json, that parsed |
| 8 | // every stored prompt; an added column sits after the payload's overflow pages, so the index |
| 9 | // must cover the whole filter. |
| 10 | yield* sql`ALTER TABLE orchestration_v2_projection_subagents ADD COLUMN completion_delivery_state TEXT`; |
| 11 | yield* sql` |
| 12 | UPDATE orchestration_v2_projection_subagents |
| 13 | SET completion_delivery_state = json_extract(payload_json, '$.completionDelivery.state') |
| 14 | WHERE json_type(payload_json, '$.completionDelivery') IS NOT NULL |
| 15 | `; |
| 16 | yield* sql` |
| 17 | CREATE INDEX orchestration_v2_projection_subagents_settled_idx |
| 18 | ON orchestration_v2_projection_subagents(thread_id, status, completion_delivery_state, run_id) |
| 19 | `; |
| 20 | }); |