(state: FakeState)
| 38 | } |
| 39 | |
| 40 | function makeBridge(state: FakeState): ICoreProcessService { |
| 41 | const rpc: Partial<CoreRPC> = { |
| 42 | listSessions: async () => state.sessions, |
| 43 | getBackground: async (p: { sessionId: string; agentId: string; activeOnly?: boolean }) => |
| 44 | state.tasksBySession.get(p.sessionId) ?? [], |
| 45 | getBackgroundOutput: async (p: { sessionId: string; agentId: string; taskId: string; tail?: number }) => { |
| 46 | const output = state.outputByTaskId.get(p.taskId); |
| 47 | if (output === undefined) return ''; |
| 48 | if (p.tail !== undefined && output.length > p.tail) { |
| 49 | return output.slice(-p.tail); |
| 50 | } |
| 51 | return output; |
| 52 | }, |
| 53 | stopBackground: async ( |
| 54 | p: StopBackgroundPayload & { sessionId: string; agentId: string }, |
| 55 | ) => { |
| 56 | state.stopCalls.push(p); |
| 57 | }, |
| 58 | }; |
| 59 | return { |
| 60 | rpc: rpc as CoreRPC, |
| 61 | ready: async () => undefined, |
| 62 | dispose: () => undefined, |
| 63 | _serviceBrand: undefined, |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | function session(id: string): SessionSummary { |
| 68 | return { |
no test coverage detected