MCPcopy Index your code
hub / github.com/tiann/hapi / opencodeLoop

Function opencodeLoop

cli/src/opencode/loop.ts:29–66  ·  view source on GitHub ↗
(opts: OpencodeLoopOptions)

Source from the content-addressed store, hash-verified

27}
28
29export async function opencodeLoop(opts: OpencodeLoopOptions): Promise<void> {
30 const logPath = logger.getLogPath();
31 const startedBy = opts.startedBy ?? 'terminal';
32 const startingMode = opts.startingMode ?? 'local';
33
34 const session = new OpencodeSession({
35 api: opts.api,
36 client: opts.session,
37 path: opts.path,
38 sessionId: opts.resumeSessionId ?? null,
39 logPath,
40 messageQueue: opts.messageQueue,
41 onModeChange: opts.onModeChange,
42 mode: startingMode,
43 startedBy,
44 startingMode,
45 permissionMode: opts.permissionMode ?? 'default',
46 modelReasoningEffort: opts.modelReasoningEffort
47 });
48
49 if (opts.resumeSessionId) {
50 session.onSessionFound(opts.resumeSessionId);
51 }
52
53 await runLocalRemoteSession({
54 session,
55 startingMode: opts.startingMode,
56 logTag: 'opencode-loop',
57 runLocal: (instance) => opencodeLocalLauncher(instance, {
58 hookServer: opts.hookServer,
59 hookUrl: opts.hookUrl
60 }),
61 runRemote: (instance) => opencodeRemoteLauncher(instance, {
62 onReasoningEffortRollback: opts.onReasoningEffortRollback
63 }),
64 onSessionReady: opts.onSessionReady
65 });
66}

Callers 1

runOpencodeFunction · 0.90

Calls 4

runLocalRemoteSessionFunction · 0.90
opencodeLocalLauncherFunction · 0.90
opencodeRemoteLauncherFunction · 0.90
getLogPathMethod · 0.80

Tested by

no test coverage detected