MCPcopy Index your code
hub / github.com/anomalyco/opencode / runInteractiveLocalMode

Function runInteractiveLocalMode

packages/opencode/src/cli/cmd/run/runtime.ts:735–784  ·  view source on GitHub ↗
(input: RunLocalInput)

Source from the content-addressed store, hash-verified

733// Local in-process mode. Creates an SDK client backed by a direct fetch to
734// the in-process server, so no external HTTP server is needed.
735export async function runInteractiveLocalMode(input: RunLocalInput): Promise<void> {
736 const sdk = createOpencodeClient({
737 baseUrl: "http://opencode.internal",
738 fetch: input.fetch,
739 directory: input.directory,
740 })
741 let session: Promise<ResolvedSession> | undefined
742
743 return runInteractiveRuntime({
744 files: input.files,
745 initialInput: input.initialInput,
746 thinking: input.thinking,
747 backgroundSubagents: input.backgroundSubagents,
748 replay: input.replay,
749 replayLimit: input.replayLimit,
750 demo: input.demo,
751 resolveSession: () => {
752 if (session) {
753 return session
754 }
755
756 session = Promise.all([input.resolveAgent(), input.session(sdk)]).then(([agent, next]) => {
757 if (!next?.id) {
758 throw new Error("Session not found")
759 }
760
761 void input.share(sdk, next.id).catch(() => {})
762 return {
763 sessionID: next.id,
764 sessionTitle: next.title,
765 agent,
766 }
767 })
768 return session
769 },
770 createSession: createSessionResolver(input.createSession),
771 boot: async () => {
772 return {
773 sdk,
774 directory: input.directory,
775 sessionID: "",
776 sessionTitle: undefined,
777 resume: false,
778 agent: input.agent,
779 model: input.model,
780 variant: input.variant,
781 }
782 },
783 })
784}
785
786// Attach mode. Uses the caller-provided SDK client directly.
787export async function runInteractiveMode(

Callers 1

run.tsFile · 0.85

Calls 6

createOpencodeClientFunction · 0.90
runInteractiveRuntimeFunction · 0.85
createSessionResolverFunction · 0.85
allMethod · 0.45
sessionMethod · 0.45
shareMethod · 0.45

Tested by

no test coverage detected