(params: {
session: SessionState;
sessionName: string;
outPath?: string;
outputPlacement: ScreenshotOutputPlacement;
dispatchContext: DaemonCommandContext;
})
| 16 | export type ScreenshotOutputPlacement = 'positional' | 'out' | 'default'; |
| 17 | |
| 18 | export async function dispatchScreenshotViaRuntime(params: { |
| 19 | session: SessionState; |
| 20 | sessionName: string; |
| 21 | outPath?: string; |
| 22 | outputPlacement: ScreenshotOutputPlacement; |
| 23 | dispatchContext: DaemonCommandContext; |
| 24 | }): Promise<Record<string, unknown>> { |
| 25 | const { session, sessionName, outPath, outputPlacement, dispatchContext } = params; |
| 26 | const runtime = createAgentDevice({ |
| 27 | backend: createDispatchScreenshotBackend({ session, outputPlacement, dispatchContext }), |
| 28 | artifacts: createDaemonScreenshotArtifactAdapter(), |
| 29 | sessions: createDaemonRuntimeSessionStore({ |
| 30 | sessionName, |
| 31 | getSession: () => session, |
| 32 | recordOptions: { includeSnapshot: false }, |
| 33 | setRecord: () => {}, |
| 34 | }), |
| 35 | policy: localCommandPolicy(), |
| 36 | }); |
| 37 | |
| 38 | return await runtime.capture.screenshot({ |
| 39 | session: sessionName, |
| 40 | requestId: dispatchContext.requestId, |
| 41 | appBundleId: session.appBundleId, |
| 42 | ...screenshotOptionsFromFlags(dispatchContext), |
| 43 | surface: session.surface, |
| 44 | ...(outPath ? { out: { kind: 'path', path: outPath } } : {}), |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | function createDispatchScreenshotBackend(params: { |
| 49 | session: SessionState; |
no test coverage detected