MCPcopy
hub / github.com/coder/mux / updateSubagentReportArtifactsFile

Function updateSubagentReportArtifactsFile

src/node/services/subagentReportArtifacts.ts:221–240  ·  view source on GitHub ↗
(params: {
  workspaceId: string;
  workspaceSessionDir: string;
  update: (file: SubagentReportArtifactsFile) => void;
})

Source from the content-addressed store, hash-verified

219}
220
221export 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
242export async function upsertSubagentReportArtifact(params: {
243 /** Workspace id that owns the session dir we're writing into (used for file locking). */

Calls 4

withLockMethod · 0.80
updateMethod · 0.65

Tested by

no test coverage detected