(input: RunLocalInput)
| 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. |
| 735 | export 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. |
| 787 | export async function runInteractiveMode( |
no test coverage detected