(opts: {
session: TSession;
startingMode?: 'local' | 'remote';
logTag: string;
runLocal: LoopLauncher<TSession>;
runRemote: LoopLauncher<TSession>;
onSessionReady?: (session: TSession) => void;
})
| 4 | export type LoopLauncher<TSession> = (session: TSession) => Promise<'switch' | 'exit'>; |
| 5 | |
| 6 | export async function runLocalRemoteSession<TSession extends AgentSessionBase<any>>(opts: { |
| 7 | session: TSession; |
| 8 | startingMode?: 'local' | 'remote'; |
| 9 | logTag: string; |
| 10 | runLocal: LoopLauncher<TSession>; |
| 11 | runRemote: LoopLauncher<TSession>; |
| 12 | onSessionReady?: (session: TSession) => void; |
| 13 | }): Promise<void> { |
| 14 | if (opts.onSessionReady) { |
| 15 | opts.onSessionReady(opts.session); |
| 16 | } |
| 17 | |
| 18 | await runLocalRemoteLoop({ |
| 19 | session: opts.session, |
| 20 | startingMode: opts.startingMode, |
| 21 | logTag: opts.logTag, |
| 22 | runLocal: opts.runLocal, |
| 23 | runRemote: opts.runRemote |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | export async function runLocalRemoteLoop<TSession extends AgentSessionBase<any>>(opts: { |
| 28 | session: TSession; |
no test coverage detected