| 6158 | // ============================================================================ |
| 6159 | |
| 6160 | export function headerToSummary(h: SessionHeader): SessionSummary { |
| 6161 | const summary: SessionSummary = { |
| 6162 | id: h.id, |
| 6163 | cwd: h.cwd, |
| 6164 | ...(h.projectId !== undefined ? { projectId: h.projectId } : {}), |
| 6165 | name: h.name === 'New Session' ? DEFAULT_SESSION_NAME : h.name, |
| 6166 | isFlagged: h.isFlagged, |
| 6167 | isArchived: h.isArchived, |
| 6168 | labels: h.labels, |
| 6169 | hasUnread: h.hasUnread, |
| 6170 | status: h.status, |
| 6171 | ...(h.blockedReason ? { blockedReason: h.blockedReason } : {}), |
| 6172 | ...(h.statusUpdatedAt !== undefined ? { statusUpdatedAt: h.statusUpdatedAt } : {}), |
| 6173 | ...(h.parentSessionId ? { parentSessionId: h.parentSessionId } : {}), |
| 6174 | ...(h.branchOfTurnId ? { branchOfTurnId: h.branchOfTurnId } : {}), |
| 6175 | ...(h.subagentParent ? { subagentParent: h.subagentParent } : {}), |
| 6176 | ...(h.subagentRuntime |
| 6177 | ? { subagentRuntime: subagentSessionRuntimeSummary(h.subagentRuntime) } |
| 6178 | : {}), |
| 6179 | ...(h.subagentWorkspace ? { subagentWorkspace: h.subagentWorkspace } : {}), |
| 6180 | ...(h.revisionRootSessionId ? { revisionRootSessionId: h.revisionRootSessionId } : {}), |
| 6181 | ...(h.revisionParentSessionId ? { revisionParentSessionId: h.revisionParentSessionId } : {}), |
| 6182 | ...(h.revisionOfTurnId ? { revisionOfTurnId: h.revisionOfTurnId } : {}), |
| 6183 | ...(h.revisionIndex !== undefined ? { revisionIndex: h.revisionIndex } : {}), |
| 6184 | ...(h.revisionState ? { revisionState: h.revisionState } : {}), |
| 6185 | backend: h.backend, |
| 6186 | llmConnectionSlug: h.llmConnectionSlug, |
| 6187 | connectionLocked: h.connectionLocked, |
| 6188 | model: h.model, |
| 6189 | permissionMode: h.permissionMode ?? 'ask', |
| 6190 | collaborationMode: h.collaborationMode ?? 'agent', |
| 6191 | orchestrationMode: h.orchestrationMode ?? 'default', |
| 6192 | }; |
| 6193 | if (h.thinkingLevel !== undefined) summary.thinkingLevel = h.thinkingLevel; |
| 6194 | if (h.lastMessageAt !== undefined) { |
| 6195 | summary.lastMessageAt = h.lastMessageAt; |
| 6196 | } |
| 6197 | return summary; |
| 6198 | } |
| 6199 | |
| 6200 | function isNotFoundError(error: unknown): error is NodeJS.ErrnoException { |
| 6201 | return error instanceof Error && 'code' in error && error.code === 'ENOENT'; |