| 1 | import log from 'electron-log/main.js' |
| 2 | |
| 3 | export { |
| 4 | SHARED_PAGE_STYLES_END, |
| 5 | SHARED_PAGE_STYLES_START, |
| 6 | pageContentEndMarker, |
| 7 | pageContentStartMarker |
| 8 | } from '../../presentation/html/page-contract' |
| 9 | |
| 10 | export type ToolStreamConfig = { |
| 11 | writer?: (chunk: unknown) => void |
| 12 | } | null |
| 13 | |
| 14 | export interface DeckToolStatusPayload { |
| 15 | label: string |
| 16 | detail?: string |
| 17 | progress?: number |
| 18 | pageId?: string |
| 19 | agentName?: string |
| 20 | } |
| 21 | |
| 22 | export const emitToolStatus = ( |
| 23 | config: ToolStreamConfig | undefined, |
| 24 | payload: DeckToolStatusPayload |
| 25 | ): void => { |
| 26 | try { |
| 27 | config?.writer?.({ |
| 28 | type: 'deck_tool_status', |
| 29 | ...payload |
| 30 | }) |
| 31 | } catch (error) { |
| 32 | log.warn('[deepagent] failed to emit custom tool status', { |
| 33 | message: error instanceof Error ? error.message : String(error), |
| 34 | payload |
| 35 | }) |
| 36 | } |
| 37 | } |
| 38 |