(cwd)
| 1160 | } |
| 1161 | |
| 1162 | export async function findLatestTaskThread(cwd) { |
| 1163 | const availability = getCodexAvailability(cwd); |
| 1164 | if (!availability.available) { |
| 1165 | throw new Error("Codex CLI is not installed or is missing required runtime support. Install it with `npm install -g @openai/codex`, then rerun `/codex:setup`."); |
| 1166 | } |
| 1167 | |
| 1168 | return withAppServer(cwd, async (client) => { |
| 1169 | const response = await client.request("thread/list", { |
| 1170 | cwd, |
| 1171 | limit: 20, |
| 1172 | sortKey: "updated_at", |
| 1173 | sourceKinds: ["appServer"], |
| 1174 | searchTerm: TASK_THREAD_PREFIX |
| 1175 | }); |
| 1176 | |
| 1177 | return ( |
| 1178 | response.data.find((thread) => typeof thread.name === "string" && thread.name.startsWith(TASK_THREAD_PREFIX)) ?? |
| 1179 | null |
| 1180 | ); |
| 1181 | }); |
| 1182 | } |
| 1183 | |
| 1184 | export function buildPersistentTaskThreadName(prompt) { |
| 1185 | return buildTaskThreadName(prompt); |
no test coverage detected