(entry: {
projectPath: string;
workspace: Pick<
WorkspaceConfigEntry,
"id" | "name" | "path" | "runtimeConfig" | "agentId" | "agentType" | "parentWorkspaceId"
>;
})
| 1676 | } |
| 1677 | |
| 1678 | private async isPlanLikeTaskWorkspace(entry: { |
| 1679 | projectPath: string; |
| 1680 | workspace: Pick< |
| 1681 | WorkspaceConfigEntry, |
| 1682 | "id" | "name" | "path" | "runtimeConfig" | "agentId" | "agentType" | "parentWorkspaceId" |
| 1683 | >; |
| 1684 | }): Promise<boolean> { |
| 1685 | assert(entry.projectPath.length > 0, "isPlanLikeTaskWorkspace: projectPath must be non-empty"); |
| 1686 | |
| 1687 | const agentIdCandidates = resolvePersistedAgentIdCandidates(entry.workspace); |
| 1688 | if (agentIdCandidates.length === 0) { |
| 1689 | return false; |
| 1690 | } |
| 1691 | |
| 1692 | const workspacePath = coerceNonEmptyString(entry.workspace.path); |
| 1693 | const workspaceName = coerceNonEmptyString(entry.workspace.name) ?? entry.workspace.id; |
| 1694 | const runtimeConfig = entry.workspace.runtimeConfig ?? DEFAULT_RUNTIME_CONFIG; |
| 1695 | if (!workspacePath || !workspaceName) { |
| 1696 | return agentIdCandidates.includes("plan"); |
| 1697 | } |
| 1698 | |
| 1699 | const cfg = this.config.loadConfigOrDefault(); |
| 1700 | const runtime = createRuntimeForWorkspace({ |
| 1701 | runtimeConfig, |
| 1702 | projectPath: entry.projectPath, |
| 1703 | name: workspaceName, |
| 1704 | }); |
| 1705 | const agentDiscoveryCandidates: Array<{ runtime: Runtime; workspacePath: string }> = [ |
| 1706 | { runtime, workspacePath }, |
| 1707 | ]; |
| 1708 | |
| 1709 | const parentEntry = entry.workspace.parentWorkspaceId |
| 1710 | ? findWorkspaceEntry(cfg, entry.workspace.parentWorkspaceId) |
| 1711 | : null; |
| 1712 | const parentWorkspaceName = coerceNonEmptyString(parentEntry?.workspace.name); |
| 1713 | if (parentEntry != null && parentWorkspaceName != null) { |
| 1714 | try { |
| 1715 | agentDiscoveryCandidates.push( |
| 1716 | createRuntimeContextForWorkspace({ |
| 1717 | runtimeConfig: parentEntry.workspace.runtimeConfig ?? runtimeConfig, |
| 1718 | projectPath: parentEntry.projectPath, |
| 1719 | name: parentWorkspaceName, |
| 1720 | namedWorkspacePath: coerceNonEmptyString(parentEntry.workspace.path), |
| 1721 | }) |
| 1722 | ); |
| 1723 | } catch (error: unknown) { |
| 1724 | log.debug("Failed to build parent task agent-discovery runtime", { |
| 1725 | workspaceId: entry.workspace.id, |
| 1726 | parentWorkspaceId: entry.workspace.parentWorkspaceId, |
| 1727 | error: error instanceof Error ? error.message : String(error), |
| 1728 | }); |
| 1729 | } |
| 1730 | } |
| 1731 | |
| 1732 | for (const agentId of agentIdCandidates) { |
| 1733 | let fallbackChain: Awaited<ReturnType<typeof resolveAgentInheritanceChain>> | undefined; |
| 1734 | let fallbackAgentId: string | undefined; |
| 1735 | for (const discovery of agentDiscoveryCandidates) { |
no test coverage detected