MCPcopy Create free account
hub / github.com/backnotprop/plannotator / runEmbeddedPlanReview

Function runEmbeddedPlanReview

apps/opencode-plugin/embedded.ts:31–71  ·  view source on GitHub ↗
(
  input: EmbeddedPlanReviewInput,
)

Source from the content-addressed store, hash-verified

29}
30
31export 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
73export async function handleEmbeddedCommand(
74 command: string,

Callers

nothing calls this directly

Calls 5

loadPlanServerFunction · 0.85
startPlannotatorServerFunction · 0.85
handleServerReadyFunction · 0.85
stopMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected