(params: {
workspaceId: string;
workspaceSessionDir: string;
update: (file: SubagentReportArtifactsFile) => void;
})
| 219 | } |
| 220 | |
| 221 | export async function updateSubagentReportArtifactsFile(params: { |
| 222 | workspaceId: string; |
| 223 | workspaceSessionDir: string; |
| 224 | update: (file: SubagentReportArtifactsFile) => void; |
| 225 | }): Promise<SubagentReportArtifactsFile> { |
| 226 | return workspaceFileLocks.withLock(params.workspaceId, async () => { |
| 227 | const file = await readSubagentReportArtifactsFile(params.workspaceSessionDir); |
| 228 | params.update(file); |
| 229 | |
| 230 | try { |
| 231 | await fsPromises.mkdir(params.workspaceSessionDir, { recursive: true }); |
| 232 | const filePath = getSubagentReportArtifactsFilePath(params.workspaceSessionDir); |
| 233 | await writeFileAtomic(filePath, JSON.stringify(file, null, 2)); |
| 234 | } catch (error) { |
| 235 | log.error("Failed to write subagent report artifacts file", { error }); |
| 236 | } |
| 237 | |
| 238 | return file; |
| 239 | }); |
| 240 | } |
| 241 | |
| 242 | export async function upsertSubagentReportArtifact(params: { |
| 243 | /** Workspace id that owns the session dir we're writing into (used for file locking). */ |
no test coverage detected