The best way to control Claude Code, Codex and more from any computer or phone

main
ts 26 lines 1.12 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as SqlClient from "effect/sql/SqlClient";
3
4 import { DEFERRED_COMMAND_MESSAGE_CONDITION } from "../../orchestration-v2/deferredCommandMessage.ts";
5
6 export default Effect.gen(function* () {
7 const sql = yield* SqlClient.SqlClient;
8
9 // A turn start finds these few rows of a long thread without reading the rest of its history.
10 // The reads in ProjectionStore.getTurnStartContext must spell the same predicates.
11 yield* sql.unsafe(`
12 CREATE INDEX IF NOT EXISTS orchestration_v2_projection_messages_deferred_command_idx
13 ON orchestration_v2_projection_messages(thread_id, created_at, message_id)
14 WHERE ${DEFERRED_COMMAND_MESSAGE_CONDITION}
15 `);
16 yield* sql`
17 CREATE INDEX IF NOT EXISTS orchestration_v2_projection_subagents_routable_idx
18 ON orchestration_v2_projection_subagents(thread_id, subagent_id)
19 WHERE origin = 'provider_native' AND status = 'completed'
20 `;
21 yield* sql`
22 CREATE INDEX IF NOT EXISTS orchestration_v2_projection_context_transfers_fork_idx
23 ON orchestration_v2_projection_context_transfers(target_thread_id)
24 WHERE type = 'fork'
25 `;
26 });