@dyyz1993/codenomad 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -149,7 +149,7 @@ export class BackgroundProcessManager {
|
|
|
149
149
|
}
|
|
150
150
|
async readOutput(workspaceId, processId, options) {
|
|
151
151
|
const outputPath = this.getOutputPath(workspaceId, processId);
|
|
152
|
-
if (!existsSync(outputPath)) {
|
|
152
|
+
if (!outputPath || !existsSync(outputPath)) {
|
|
153
153
|
return { id: processId, content: "", truncated: false, sizeBytes: 0 };
|
|
154
154
|
}
|
|
155
155
|
const stats = await fs.stat(outputPath);
|
|
@@ -184,7 +184,7 @@ export class BackgroundProcessManager {
|
|
|
184
184
|
}
|
|
185
185
|
async streamOutput(workspaceId, processId, reply) {
|
|
186
186
|
const outputPath = this.getOutputPath(workspaceId, processId);
|
|
187
|
-
if (!existsSync(outputPath)) {
|
|
187
|
+
if (!outputPath || !existsSync(outputPath)) {
|
|
188
188
|
reply.code(404).send({ error: "Output not found" });
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
@@ -356,6 +356,9 @@ export class BackgroundProcessManager {
|
|
|
356
356
|
}
|
|
357
357
|
async ensureProcessDir(workspaceId, processId) {
|
|
358
358
|
const root = await this.ensureWorkspaceDir(workspaceId);
|
|
359
|
+
if (!root) {
|
|
360
|
+
throw new Error("Workspace not found");
|
|
361
|
+
}
|
|
359
362
|
const processDir = path.join(root, processId);
|
|
360
363
|
await fs.mkdir(processDir, { recursive: true });
|
|
361
364
|
return processDir;
|
|
@@ -363,7 +366,7 @@ export class BackgroundProcessManager {
|
|
|
363
366
|
async ensureWorkspaceDir(workspaceId) {
|
|
364
367
|
const workspace = this.deps.workspaceManager.get(workspaceId);
|
|
365
368
|
if (!workspace) {
|
|
366
|
-
|
|
369
|
+
return null;
|
|
367
370
|
}
|
|
368
371
|
const root = path.join(workspace.path, ROOT_DIR, workspaceId);
|
|
369
372
|
await fs.mkdir(root, { recursive: true });
|
|
@@ -372,7 +375,7 @@ export class BackgroundProcessManager {
|
|
|
372
375
|
getOutputPath(workspaceId, processId) {
|
|
373
376
|
const workspace = this.deps.workspaceManager.get(workspaceId);
|
|
374
377
|
if (!workspace) {
|
|
375
|
-
|
|
378
|
+
return null;
|
|
376
379
|
}
|
|
377
380
|
return path.join(workspace.path, ROOT_DIR, workspaceId, processId, OUTPUT_FILE);
|
|
378
381
|
}
|
|
@@ -382,6 +385,8 @@ export class BackgroundProcessManager {
|
|
|
382
385
|
}
|
|
383
386
|
async readIndex(workspaceId) {
|
|
384
387
|
const indexPath = await this.getIndexPath(workspaceId);
|
|
388
|
+
if (!indexPath)
|
|
389
|
+
return [];
|
|
385
390
|
if (!existsSync(indexPath))
|
|
386
391
|
return [];
|
|
387
392
|
try {
|
|
@@ -411,13 +416,15 @@ export class BackgroundProcessManager {
|
|
|
411
416
|
}
|
|
412
417
|
async writeIndex(workspaceId, records) {
|
|
413
418
|
const indexPath = await this.getIndexPath(workspaceId);
|
|
419
|
+
if (!indexPath)
|
|
420
|
+
return;
|
|
414
421
|
await fs.mkdir(path.dirname(indexPath), { recursive: true });
|
|
415
422
|
await fs.writeFile(indexPath, JSON.stringify(records, null, 2));
|
|
416
423
|
}
|
|
417
424
|
async getIndexPath(workspaceId) {
|
|
418
425
|
const workspace = this.deps.workspaceManager.get(workspaceId);
|
|
419
426
|
if (!workspace) {
|
|
420
|
-
|
|
427
|
+
return null;
|
|
421
428
|
}
|
|
422
429
|
return path.join(workspace.path, ROOT_DIR, workspaceId, INDEX_FILE);
|
|
423
430
|
}
|
|
@@ -439,7 +446,7 @@ export class BackgroundProcessManager {
|
|
|
439
446
|
}
|
|
440
447
|
async getOutputSize(workspaceId, processId) {
|
|
441
448
|
const outputPath = this.getOutputPath(workspaceId, processId);
|
|
442
|
-
if (!existsSync(outputPath)) {
|
|
449
|
+
if (!outputPath || !existsSync(outputPath)) {
|
|
443
450
|
return 0;
|
|
444
451
|
}
|
|
445
452
|
try {
|
|
@@ -475,6 +482,11 @@ export class BackgroundProcessManager {
|
|
|
475
482
|
};
|
|
476
483
|
}
|
|
477
484
|
async finalizeRecord(workspaceId, record, completion) {
|
|
485
|
+
if (!this.deps.workspaceManager.get(workspaceId)) {
|
|
486
|
+
this.deps.logger.debug({ workspaceId, processId: record.id }, "Skipping finalizeRecord: workspace already removed");
|
|
487
|
+
this.running.delete(record.id);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
478
490
|
if (this.shouldSendCompletionPrompt(record, completion)) {
|
|
479
491
|
try {
|
|
480
492
|
await this.sendCompletionPrompt(workspaceId, record);
|