(
parentWorkspaceId: string,
childWorkspaceId: string,
onComplete: OnPatchGenerationComplete
)
| 477 | } |
| 478 | |
| 479 | private async generate( |
| 480 | parentWorkspaceId: string, |
| 481 | childWorkspaceId: string, |
| 482 | onComplete: OnPatchGenerationComplete |
| 483 | ): Promise<void> { |
| 484 | assert(parentWorkspaceId.length > 0, "generate: parentWorkspaceId must be non-empty"); |
| 485 | assert(childWorkspaceId.length > 0, "generate: childWorkspaceId must be non-empty"); |
| 486 | |
| 487 | const parentSessionDir = this.config.getSessionDir(parentWorkspaceId); |
| 488 | |
| 489 | const updateArtifact = async ( |
| 490 | updater: Parameters<typeof upsertSubagentGitPatchArtifact>[0]["updater"] |
| 491 | ): Promise<SubagentGitPatchArtifact> => { |
| 492 | return await upsertSubagentGitPatchArtifact({ |
| 493 | workspaceId: parentWorkspaceId, |
| 494 | workspaceSessionDir: parentSessionDir, |
| 495 | childTaskId: childWorkspaceId, |
| 496 | updater, |
| 497 | }); |
| 498 | }; |
| 499 | |
| 500 | const nowMs = Date.now(); |
| 501 | |
| 502 | try { |
| 503 | const cfg = this.config.loadConfigOrDefault(); |
| 504 | const entry = findWorkspaceEntry(cfg, childWorkspaceId); |
| 505 | |
| 506 | if (!entry) { |
| 507 | await updateArtifact((existing) => |
| 508 | failPendingProjectArtifacts({ |
| 509 | artifact: |
| 510 | existing ?? |
| 511 | buildPendingPatchArtifact({ |
| 512 | childTaskId: childWorkspaceId, |
| 513 | parentWorkspaceId, |
| 514 | createdAtMs: nowMs, |
| 515 | updatedAtMs: nowMs, |
| 516 | projectArtifacts: [], |
| 517 | }), |
| 518 | error: "Task workspace not found in config.", |
| 519 | updatedAtMs: nowMs, |
| 520 | }) |
| 521 | ); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | const ws = entry.workspace; |
| 526 | |
| 527 | const workspacePath = coerceNonEmptyString(ws.path); |
| 528 | if (!workspacePath) { |
| 529 | await updateArtifact((existing) => |
| 530 | failPendingProjectArtifacts({ |
| 531 | artifact: |
| 532 | existing ?? |
| 533 | buildPendingPatchArtifact({ |
| 534 | childTaskId: childWorkspaceId, |
| 535 | parentWorkspaceId, |
| 536 | createdAtMs: nowMs, |
no test coverage detected