@returns {TurnCaptureState}
(threadId, options = {})
| 301 | |
| 302 | /** @returns {TurnCaptureState} */ |
| 303 | function createTurnCaptureState(threadId, options = {}) { |
| 304 | let resolveCompletion; |
| 305 | let rejectCompletion; |
| 306 | const completion = new Promise((resolve, reject) => { |
| 307 | resolveCompletion = resolve; |
| 308 | rejectCompletion = reject; |
| 309 | }); |
| 310 | |
| 311 | return { |
| 312 | threadId, |
| 313 | rootThreadId: threadId, |
| 314 | threadIds: new Set([threadId]), |
| 315 | threadTurnIds: new Map(), |
| 316 | threadLabels: new Map(), |
| 317 | turnId: null, |
| 318 | bufferedNotifications: [], |
| 319 | completion, |
| 320 | resolveCompletion, |
| 321 | rejectCompletion, |
| 322 | finalTurn: null, |
| 323 | completed: false, |
| 324 | finalAnswerSeen: false, |
| 325 | pendingCollaborations: new Set(), |
| 326 | activeSubagentTurns: new Set(), |
| 327 | completionTimer: null, |
| 328 | lastAgentMessage: "", |
| 329 | reviewText: "", |
| 330 | reasoningSummary: [], |
| 331 | error: null, |
| 332 | messages: [], |
| 333 | fileChanges: [], |
| 334 | commandExecutions: [], |
| 335 | onProgress: options.onProgress ?? null |
| 336 | }; |
| 337 | } |
| 338 | |
| 339 | function clearCompletionTimer(state) { |
| 340 | if (state.completionTimer) { |