(cwd, { threadId, turnId })
| 958 | } |
| 959 | |
| 960 | export async function interruptAppServerTurn(cwd, { threadId, turnId }) { |
| 961 | if (!threadId || !turnId) { |
| 962 | return { |
| 963 | attempted: false, |
| 964 | interrupted: false, |
| 965 | transport: null, |
| 966 | detail: "missing threadId or turnId" |
| 967 | }; |
| 968 | } |
| 969 | |
| 970 | const availability = getCodexAvailability(cwd); |
| 971 | if (!availability.available) { |
| 972 | return { |
| 973 | attempted: false, |
| 974 | interrupted: false, |
| 975 | transport: null, |
| 976 | detail: availability.detail |
| 977 | }; |
| 978 | } |
| 979 | |
| 980 | let client = null; |
| 981 | try { |
| 982 | client = await CodexAppServerClient.connect(cwd, { reuseExistingBroker: true }); |
| 983 | await client.request("turn/interrupt", { threadId, turnId }); |
| 984 | return { |
| 985 | attempted: true, |
| 986 | interrupted: true, |
| 987 | transport: client.transport, |
| 988 | detail: `Interrupted ${turnId} on ${threadId}.` |
| 989 | }; |
| 990 | } catch (error) { |
| 991 | return { |
| 992 | attempted: true, |
| 993 | interrupted: false, |
| 994 | transport: client?.transport ?? null, |
| 995 | detail: error instanceof Error ? error.message : String(error) |
| 996 | }; |
| 997 | } finally { |
| 998 | await client?.close().catch(() => {}); |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | export async function runAppServerReview(cwd, options = {}) { |
| 1003 | const availability = getCodexAvailability(cwd); |
no test coverage detected