Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import type { WorkspaceSessionState } from './workspace-session-state-types'
import {
describeWorkspaceSessionError,
safeParseWorkspaceSession,
WORKSPACE_SESSION_UNVALIDATABLE
} from './workspace-session-schema'
import { collectSalvageDrops } from './zod-salvage'
export type SalvagedWorkspaceSession =
| { ok: true; value: WorkspaceSessionState; droppedPaths: string[]; droppedCount: number }
| { ok: false; error: string }
/** Remove undefined keys that would shadow caller defaults during object spread. */
function withoutSalvagedAwayFields(session: WorkspaceSessionState): WorkspaceSessionState {
return Object.fromEntries(
Object.entries(session).filter(([, value]) => value !== undefined)
) as WorkspaceSessionState
}
/** Validate a session, preserving valid entries and reporting bounded repair diagnostics. */
export function parseWorkspaceSessionSalvaging(raw: unknown): SalvagedWorkspaceSession {
const {
value: result,
droppedPaths,
droppedCount
} = collectSalvageDrops(() => safeParseWorkspaceSession(raw))
if (!result) {
return { ok: false, error: WORKSPACE_SESSION_UNVALIDATABLE }
}
if (!result.success) {
return { ok: false, error: describeWorkspaceSessionError(result.error) }
}
return { ok: true, value: withoutSalvagedAwayFields(result.data), droppedPaths, droppedCount }
}