(hooks: RenderSessionHooks)
| 31 | } |
| 32 | |
| 33 | function createBaseRenderSession(hooks: RenderSessionHooks): RenderSession { |
| 34 | const attachments: ImageAttachment[] = []; |
| 35 | let structuredOutput: StructuredToolOutput | undefined; |
| 36 | let nextSteps: NextStep[] = []; |
| 37 | let nextStepsRuntime: 'cli' | 'daemon' | 'mcp' | undefined; |
| 38 | |
| 39 | return { |
| 40 | emit(fragment: AnyFragment): void { |
| 41 | hooks.onEmit?.(fragment); |
| 42 | }, |
| 43 | |
| 44 | attach(image: ImageAttachment): void { |
| 45 | attachments.push(image); |
| 46 | }, |
| 47 | |
| 48 | setStructuredOutput(output: StructuredToolOutput): void { |
| 49 | structuredOutput = output; |
| 50 | hooks.onSetStructuredOutput?.(output); |
| 51 | }, |
| 52 | |
| 53 | getStructuredOutput(): StructuredToolOutput | undefined { |
| 54 | return structuredOutput; |
| 55 | }, |
| 56 | |
| 57 | setNextSteps(steps: NextStep[], runtime: 'cli' | 'daemon' | 'mcp'): void { |
| 58 | nextSteps = [...steps]; |
| 59 | nextStepsRuntime = runtime; |
| 60 | hooks.onSetNextSteps?.(steps, runtime); |
| 61 | }, |
| 62 | |
| 63 | getNextSteps(): readonly NextStep[] { |
| 64 | return nextSteps; |
| 65 | }, |
| 66 | |
| 67 | getNextStepsRuntime(): 'cli' | 'daemon' | 'mcp' | undefined { |
| 68 | return nextStepsRuntime; |
| 69 | }, |
| 70 | |
| 71 | getAttachments(): readonly ImageAttachment[] { |
| 72 | return attachments; |
| 73 | }, |
| 74 | |
| 75 | isError(): boolean { |
| 76 | return structuredOutput?.result.didError === true; |
| 77 | }, |
| 78 | |
| 79 | finalize(): string { |
| 80 | return hooks.finalize({ |
| 81 | items: [], |
| 82 | structuredOutput, |
| 83 | nextSteps, |
| 84 | nextStepsRuntime, |
| 85 | }); |
| 86 | }, |
| 87 | }; |
| 88 | } |
| 89 | |
| 90 | function createRenderHooks( |
no outgoing calls
no test coverage detected