| 6 | import { AppError } from '../kernel/errors.ts'; |
| 7 | |
| 8 | function createTransport( |
| 9 | handler: (req: Omit<DaemonRequest, 'token'>) => Promise<DaemonResponse> | DaemonResponse, |
| 10 | ): { |
| 11 | calls: Array<Omit<DaemonRequest, 'token'>>; |
| 12 | config: AgentDeviceClientConfig; |
| 13 | transport: (req: Omit<DaemonRequest, 'token'>) => Promise<DaemonResponse>; |
| 14 | } { |
| 15 | const calls: Array<Omit<DaemonRequest, 'token'>> = []; |
| 16 | const config: AgentDeviceClientConfig = { |
| 17 | session: 'qa', |
| 18 | cwd: '/tmp/agent-device', |
| 19 | debug: true, |
| 20 | daemonBaseUrl: 'http://daemon.example.test', |
| 21 | daemonAuthToken: 'secret', |
| 22 | daemonTransport: 'http', |
| 23 | tenant: 'acme', |
| 24 | sessionIsolation: 'tenant', |
| 25 | runId: 'run-123', |
| 26 | leaseId: 'lease-123', |
| 27 | }; |
| 28 | return { |
| 29 | calls, |
| 30 | config, |
| 31 | transport: async (req) => { |
| 32 | calls.push(req); |
| 33 | return await handler(req); |
| 34 | }, |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | test('apps.open resolves session device identifiers from open response', async () => { |
| 39 | const setup = createTransport(async (req) => { |