MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / main

Function main

crates/opencode-plugin/host/plugin-host.ts:659–707  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

657// ---------------------------------------------------------------------------
658
659async function main(): Promise<void> {
660 // Set stdin to raw binary mode
661 if (typeof process.stdin.setEncoding === "function") {
662 // Don't call setEncoding — we want raw bytes
663 }
664 process.stdin.resume();
665
666 while (true) {
667 let msg: JsonRpcRequest | null;
668 try {
669 msg = await readMessage();
670 } catch {
671 break; // stdin closed or parse error
672 }
673
674 if (msg === null) break; // EOF
675
676 const { id, method, params } = msg;
677
678 switch (method) {
679 case "initialize":
680 await handleInitialize(id, params as Parameters<typeof handleInitialize>[1]);
681 break;
682 case "hook.invoke":
683 await handleHookInvoke(id, params as Parameters<typeof handleHookInvoke>[1]);
684 break;
685 case "auth.authorize":
686 await handleAuthAuthorize(id, params as Parameters<typeof handleAuthAuthorize>[1]);
687 break;
688 case "auth.callback":
689 await handleAuthCallback(id, params as Parameters<typeof handleAuthCallback>[1]);
690 break;
691 case "auth.load":
692 await handleAuthLoad(id);
693 break;
694 case "auth.fetch":
695 await handleAuthFetch(id, params as Parameters<typeof handleAuthFetch>[1]);
696 break;
697 case "auth.fetch.stream":
698 await handleAuthFetchStream(id, params as Parameters<typeof handleAuthFetchStream>[1]);
699 break;
700 case "shutdown":
701 sendResult(id, {});
702 process.exit(0);
703 default:
704 sendError(id, -32601, `Unknown method: ${method}`);
705 }
706 }
707}
708
709main().catch((err) => {
710 process.stderr.write(`plugin-host fatal: ${err}\n`);

Callers 1

plugin-host.tsFile · 0.70

Calls 11

readMessageFunction · 0.85
handleInitializeFunction · 0.85
handleHookInvokeFunction · 0.85
handleAuthAuthorizeFunction · 0.85
handleAuthCallbackFunction · 0.85
handleAuthLoadFunction · 0.85
handleAuthFetchFunction · 0.85
handleAuthFetchStreamFunction · 0.85
sendResultFunction · 0.85
sendErrorFunction · 0.85
resumeMethod · 0.80

Tested by

no test coverage detected