( input: EmbeddedPlanReviewInput, )
| 29 | } |
| 30 | |
| 31 | export async function runEmbeddedPlanReview( |
| 32 | input: EmbeddedPlanReviewInput, |
| 33 | ): Promise<EmbeddedPlanReviewResult> { |
| 34 | const { startPlannotatorServer, handleServerReady } = await loadPlanServer(); |
| 35 | const server = await startPlannotatorServer({ |
| 36 | plan: input.planContent, |
| 37 | origin: "opencode", |
| 38 | sharingEnabled: input.sharingEnabled, |
| 39 | shareBaseUrl: input.shareBaseUrl, |
| 40 | pasteApiUrl: input.pasteApiUrl, |
| 41 | htmlContent: input.htmlContent, |
| 42 | opencodeClient: input.client, |
| 43 | onReady: async (url, isRemote, port) => { |
| 44 | await handleServerReady(url, isRemote, port); |
| 45 | input.logReady(url, isRemote, port); |
| 46 | }, |
| 47 | }); |
| 48 | |
| 49 | const timeoutMs = input.timeoutSeconds === null ? null : input.timeoutSeconds * 1000; |
| 50 | const result = timeoutMs === null |
| 51 | ? await server.waitForDecision() |
| 52 | : await new Promise<Awaited<ReturnType<typeof server.waitForDecision>>>((resolve) => { |
| 53 | const timeoutId = setTimeout( |
| 54 | () => |
| 55 | resolve({ |
| 56 | approved: false, |
| 57 | feedback: `[Plannotator] No response within ${input.timeoutSeconds} seconds. Port released automatically. Please call submit_plan again.`, |
| 58 | }), |
| 59 | timeoutMs, |
| 60 | ); |
| 61 | |
| 62 | server.waitForDecision().then((decision) => { |
| 63 | clearTimeout(timeoutId); |
| 64 | resolve(decision); |
| 65 | }); |
| 66 | }); |
| 67 | |
| 68 | await Bun.sleep(1500); |
| 69 | server.stop(); |
| 70 | return result; |
| 71 | } |
| 72 | |
| 73 | export async function handleEmbeddedCommand( |
| 74 | command: string, |
nothing calls this directly
no test coverage detected