(sessionID: string)
| 196 | } |
| 197 | |
| 198 | export async function latestSnapshot(sessionID: string) { |
| 199 | const messages = await Session.messages({ sessionID }) |
| 200 | let snapshot: string | undefined |
| 201 | for (const message of messages) { |
| 202 | for (const part of message.parts) { |
| 203 | if (part.type === "step-finish" && part.snapshot) { |
| 204 | snapshot = part.snapshot |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | return snapshot |
| 209 | } |
| 210 | |
| 211 | export async function withWorktreeLock<T>(fn: () => Promise<T>) { |
| 212 | using _ = await Lock.write(LOCK_KEY) |