(input: { runId: string; threadId?: string })
| 132 | // (rather than throwing synchronously from a Promise-typed method — a |
| 133 | // `.catch()` footgun) without an `await`-less async body. |
| 134 | open(input: { runId: string; threadId?: string }): Promise<RunRecord> { |
| 135 | const existing = this.runs.get(input.runId) |
| 136 | if (existing) return Promise.resolve({ ...existing.record }) |
| 137 | const now = this.now() |
| 138 | const record: RunRecord = { |
| 139 | runId: input.runId, |
| 140 | ...(input.threadId !== undefined ? { threadId: input.threadId } : {}), |
| 141 | status: 'running', |
| 142 | lastSeq: -1, |
| 143 | createdAt: now, |
| 144 | updatedAt: now, |
| 145 | } |
| 146 | this.runs.set(input.runId, { record, chunks: [], waiters: new Set() }) |
| 147 | return Promise.resolve({ ...record }) |
| 148 | } |
| 149 | |
| 150 | append(runId: string, chunk: StreamChunk): Promise<number> { |
| 151 | const state = this.runs.get(runId) |
no test coverage detected