( sandbox: SandboxInstance, orgId: string | undefined, userId: string, sessionId: string, options: StaleWorkspaceCleanupOptions )
| 215 | kilocodeOrganizationId: string | null | undefined, |
| 216 | userId: string, |
| 217 | worktreeId: CloudAgentWorktreeId |
| 218 | ): string { |
| 219 | const parsed = cloudAgentWorktreeIdSchema.safeParse(worktreeId); |
| 220 | if (!parsed.success) { |
| 221 | throw invalidSegment('worktree id'); |
| 222 | } |
| 223 | return `${getBaseWorkspacePath(kilocodeOrganizationId, userId)}/worktrees/${parsed.data}`; |
| 224 | } |
| 225 | |
| 226 | export function getSessionHomePath(sessionId: string): string { |
| 227 | return `${SESSION_HOME_ROOT}/${requireGeneratedIdPathSegment(sessionId, 'session id')}`; |
| 228 | } |
| 229 | |
| 230 | export function getKilocodeCliDir(sessionHome: string): string { |
| 231 | return `${sessionHome}/${CLI_DIR}`; |
| 232 | } |
| 233 | |
| 234 | export function getKilocodeLogsDir(sessionHome: string): string { |
| 235 | return `${sessionHome}/${CLI_LOGS_PATH}`; |
| 236 | } |
| 237 | |
| 238 | export function getKilocodeLogFilePath(sessionHome: string): string { |
| 239 | return `${getKilocodeLogsDir(sessionHome)}/cli.txt`; |
| 240 | } |
| 241 | |
| 242 | export function getWrapperLogFilePath(executionId: string): string { |
| 243 | return `/tmp/kilocode-wrapper-${executionId}.log`; |
| 244 | } |
| 245 | |
| 246 | export function getKilocodeTasksDir(sessionHome: string): string { |
| 247 | return `${sessionHome}/${CLI_GLOBAL_TASKS_PATH}`; |
| 248 | } |
| 249 | |
| 250 | export function getKilocodeGlobalDir(sessionHome: string): string { |
| 251 | return `${getKilocodeCliDir(sessionHome)}/global`; |
| 252 | } |
| 253 | |
| 254 | export type SessionPaths = { |
| 255 | workspacePath: string; |
| 256 | sessionHome: string; |
| 257 | }; |
| 258 | |
| 259 | export type StaleWorkspaceCleanupResult = { |
| 260 | cleaned: number; |
| 261 | skipped: number; |
| 262 | }; |
| 263 | |
| 264 | export type StaleWorkspaceCleanupOptions = { |
| 265 | inspectContainers: boolean; |
| 266 | }; |
| 267 | |
| 268 | export type WorkspaceAdmissionResult = { |
| 269 | availableMB: number; |
| 270 | thresholdMB: number; |
| 271 | cleanup: StaleWorkspaceCleanupResult; |
| 272 | }; |
| 273 | |
| 274 | function throwIfSandboxFilesystemUnusable(operation: string, error: unknown): void { |
no test coverage detected