| 1 | export function completionTypeForAcceptResult(eventType, acceptResult) { |
| 2 | if (eventType === 'discard') return acceptResult?.handled === true ? 'discarded' : 'error'; |
| 3 | if (acceptResult?.handled === true && acceptResult?.carbonize === true) return 'agent_done'; |
| 4 | if (acceptResult?.handled === true) return 'complete'; |
| 5 | if (acceptResult?.mode === 'error') return 'error'; |
| 6 | if (eventType === 'accept' && acceptResult?.previewMode === 'svelte-component') return 'error'; |
| 7 | return 'agent_done'; |
| 8 | } |
| 9 | |
| 10 | export function completionAckForAcceptResult(eventId, completionType, acceptResult) { |
| 11 | const ack = { ok: true, type: completionType }; |
| 12 | if (acceptResult?.handled === true && acceptResult?.carbonize === true) { |
| 13 | ack.final = false; |
| 14 | ack.requiresComplete = true; |
| 15 | ack.nextCommand = `live-complete.mjs --id ${eventId}`; |
| 16 | ack.message = 'Carbonize cleanup must be verified, then the session must be completed explicitly before polling again.'; |
| 17 | } |
| 18 | return ack; |
| 19 | } |
| 20 |