{"version":3,"file":"sessionRailModel.cjs","names":["splitHostId","COORDINATOR_SESSION_PROVENANCE","WORKFLOW_STEP_SESSION_PROVENANCE","sessionStatusClock","sessionStatusLine","defaultHostId","personaInitials","VOICE_ORCHESTRATOR_SESSION_PROVENANCE","summaryValueEqual"],"sources":["../../../src/web/lib/sessionRailModel.ts"],"sourcesContent":["import {\n  COORDINATOR_SESSION_PROVENANCE,\n  VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n  WORKFLOW_STEP_SESSION_PROVENANCE,\n} from '@agimon-ai/po-core/hubChannel';\nimport type {\n  SessionSetupActionContribution,\n  WebPluginSessionOption,\n  WebTemplateRail,\n  WebTemplateRailPendingSetup,\n  WebTemplateRailSession,\n  WebTemplateRailWorkspace,\n} from '@agimon-ai/po-core/web';\n\nimport type { SessionSummary, WorkspaceSummary } from '../../types/hub';\nimport { defaultHostId, splitHostId } from './hostIdentity';\nimport {\n  personaInitials,\n  sessionStatusClock,\n  sessionStatusLine,\n  summaryValueEqual,\n  type AttachPhase,\n  type StatusLineInput,\n} from './sessionSummary';\n\n/** Sessions recorded without a workspace are grouped under this id. */\nexport const LEGACY_WORKSPACE_ID = 'legacy-workspace';\n\n/** One home target per computer, not one global coordinator flag for a merged rail. */\nexport function coordinatorHostTargets(\n  workspaces: readonly WebTemplateRailWorkspace[],\n  defaultHost: string | undefined,\n  labels: Readonly<Record<string, string>>,\n): NonNullable<WebTemplateRail['coordinatorHosts']> {\n  return [...new Set([defaultHost, ...workspaces.map((workspace) => splitHostId(workspace.id)?.hostId)])].map(\n    (hostId) => ({\n      ...(hostId === undefined ? {} : { hostId }),\n      label: hostId === undefined ? 'This computer' : (labels[hostId] ?? `Computer ${hostId.slice(0, 8)}`),\n      coordinated: workspaces.some(\n        (workspace) =>\n          workspace.kind === 'session' &&\n          splitHostId(workspace.id)?.hostId === hostId &&\n          workspace.sessions.some((session) => session.coordinator),\n      ),\n    }),\n  );\n}\n\n/** Why a new bot in this workspace, or in Home without one, cannot act as coordinator; undefined when it can. */\nexport function botCoordinatorBlocked(\n  target: { workspaceId?: string; hostId?: string },\n  workspacesById: Readonly<Record<string, WorkspaceSummary>>,\n  summaries: readonly SessionSummary[],\n): string | undefined {\n  const workspace = target.workspaceId === undefined ? undefined : workspacesById[target.workspaceId];\n  if (workspace?.sandbox !== undefined) return 'Sandboxed workspaces cannot have a coordinator.';\n  const taken = summaries.some((summary) => {\n    if (summary.sessionProvenance !== COORDINATOR_SESSION_PROVENANCE || summary.workspaceId === undefined) return false;\n    if (target.workspaceId !== undefined) return summary.workspaceId === target.workspaceId;\n    return (\n      workspacesById[summary.workspaceId]?.kind === 'session' &&\n      splitHostId(summary.workspaceId)?.hostId === target.hostId\n    );\n  });\n  if (!taken) return undefined;\n  return workspace ? `${workspaceName(workspace)} already has a coordinator.` : 'Home already has a coordinator.';\n}\n\n/**\n * The rail order the 1-9 shortcuts index. A workflow step comes and goes with its step, so it takes\n * no digit and never shifts the digits of the sessions around it.\n */\nexport function railShortcutOrder(\n  order: readonly string[],\n  byId: Readonly<Record<string, { summary: Pick<SessionSummary, 'sessionProvenance'> }>>,\n): string[] {\n  return order.filter((id) => byId[id]?.summary.sessionProvenance !== WORKFLOW_STEP_SESSION_PROVENANCE);\n}\n\nexport interface RailSessionInput {\n  summary: SessionSummary;\n  attach: AttachPhase;\n  canInteract?: boolean;\n}\n\n/** A restart the rail asked for: in flight, or failed with a reason. */\nexport interface RailRestartState {\n  restarting: boolean;\n  error?: string;\n}\n\nexport interface SessionRailModelInput {\n  /** Rail order across every workspace; positions become the 1-9 ordinals. */\n  order: readonly string[];\n  byId: Readonly<Record<string, RailSessionInput>>;\n  activeId: string | null;\n  workspaceOrder: readonly string[];\n  workspacesById: Readonly<Record<string, WorkspaceSummary>>;\n  /** Sessions rendered under a parent, each mapped to the row it renders under. */\n  nested: ReadonlyMap<string, string>;\n  /** When the status copy is read; a card's `clock` keeps it current after that. */\n  now: number;\n  restarts: Readonly<Record<string, RailRestartState>>;\n  /** Loaded profile avatars by session id. */\n  avatarUrls: Readonly<Record<string, string>>;\n}\n\nexport function workspaceName(workspace: Pick<WorkspaceSummary, 'root' | 'name'>): string {\n  if (workspace.name) return workspace.name;\n  const trimmed = workspace.root.replace(/\\/+$/u, '');\n  return trimmed.slice(trimmed.lastIndexOf('/') + 1) || workspace.root;\n}\n\ntype PendingSetup = NonNullable<SessionSummary['pendingSetups']>[number];\n\n/** The installed package that claims a pending setup, from the session setup action fills' data. */\nexport function sessionSetupActionFor(\n  contributions: readonly unknown[],\n  setup: PendingSetup,\n): SessionSetupActionContribution | undefined {\n  for (const data of contributions) {\n    const action = data as Partial<SessionSetupActionContribution> | undefined;\n    if (typeof action?.claims !== 'function' || typeof action.remove !== 'function') continue;\n    try {\n      if (action.claims(setup)) return action as SessionSetupActionContribution;\n    } catch {\n      // A package whose claim check throws does not own the setup.\n    }\n  }\n  return undefined;\n}\n\n/** The status and recovery copy for a setup-only child reservation. */\nexport function pendingSetupView(setup: PendingSetup): WebTemplateRailPendingSetup {\n  const setupType =\n    setup.setupKind === 'existing-directory'\n      ? 'conversation directory'\n      : setup.setupKind === 'managed-worktree'\n        ? 'automatic worktree'\n        : 'conversation';\n  const status =\n    setup.status === 'failed'\n      ? `${setupType} setup failed`\n      : setup.status === 'interrupted'\n        ? `${setupType} setup interrupted`\n        : `${setupType} provisioning`;\n  const recovery =\n    setup.setupKind === undefined && setup.cwd !== undefined\n      ? 'This existing setup has no verified provider. Inspect its ownership in Po before retrying.'\n      : setup.errorCode === 'SESSION_UNAVAILABLE'\n        ? 'The existing session is unavailable. Inspect or resume it in Po before retrying the conversation.'\n        : setup.status === 'interrupted'\n          ? 'Retry the authenticated conversation to resume this setup. The same setup will be reused.'\n          : setup.setupKind === 'existing-directory'\n            ? 'Inspect the selected directory, then retry the authenticated conversation. The same setup will be reused.'\n            : 'Resolve the Git setup, then retry the authenticated conversation. The same setup will be reused.';\n  const needsRecovery = setup.status === 'failed' || setup.status === 'interrupted';\n  return {\n    id: setup.id,\n    name: setup.name,\n    status,\n    failed: setup.status === 'failed',\n    ...(needsRecovery ? { recovery } : {}),\n  };\n}\n\n/** One session's status copy and clock as its card shows them, for a surface that reads only that session. */\nexport function railSessionStatus(\n  { summary, attach }: RailSessionInput,\n  now: number,\n): Pick<WebTemplateRailSession, 'status' | 'clock'> {\n  const statusInput: StatusLineInput = {\n    attach,\n    backgroundWorkActive: summary.backgroundWorkActive,\n    phase: summary.phase,\n    phaseSince: summary.phaseSince,\n    awaitingInput: summary.awaitingInput,\n    everPrompted: summary.everPrompted,\n    lastSettledAt: summary.lastSettledAt,\n    dormant: summary.dormant,\n    ...(summary.activity === undefined ? {} : { activity: summary.activity }),\n    ...(summary.pendingApprovalCount === undefined ? {} : { pendingApprovals: summary.pendingApprovalCount }),\n  };\n  const clock = sessionStatusClock(statusInput);\n  return { status: sessionStatusLine(statusInput, now), ...(clock === undefined ? {} : { clock }) };\n}\n\n/**\n * Live sessions on one computer (`hostId`, undefined for the page's own, which is the default host when the page has\n * only a remote one) but `excludeId`, in rail order: the sessions a global server method of that computer can reach.\n */\nexport function liveSessionOptions(\n  sessions: { order: readonly string[]; byId: Readonly<Record<string, RailSessionInput>> },\n  workspaces: Readonly<Record<string, WorkspaceSummary>>,\n  excludeId: string | null,\n  hostId: string | undefined,\n  now: number,\n): WebPluginSessionOption[] {\n  const host = hostId ?? defaultHostId();\n  return sessions.order.flatMap((id) => {\n    const meta = sessions.byId[id];\n    if (id === excludeId || meta === undefined || meta.summary.dormant || splitHostId(id)?.hostId !== host) return [];\n    const { summary } = meta;\n    const workspace = summary.workspaceId === undefined ? undefined : workspaces[summary.workspaceId];\n    const status = railSessionStatus(meta, now).status;\n    return [\n      {\n        id,\n        name: summary.name,\n        detail:\n          workspace?.kind === 'session' || workspace === undefined ? status : `${workspaceName(workspace)} · ${status}`,\n        state: summary.awaitingInput ? 'waiting' : summary.phase === 'idle' ? 'idle' : 'running',\n        ...(summary.workspaceId === undefined ? {} : { workspaceId: summary.workspaceId }),\n      },\n    ];\n  });\n}\n\n/**\n * What the Activity face holds for the person: each pending approval, plus background work\n * that needs them (such as a failed workflow) while the agent itself is idle.\n */\nexport function activityWaitingCount(summary: SessionSummary | undefined): number {\n  if (summary === undefined) return 0;\n  const attention = summary.activity?.attention === true && summary.phase === 'idle' && summary.dormant !== true;\n  return (summary.pendingApprovalCount ?? 0) + (attention ? 1 : 0);\n}\n\n/** Everything waiting on the person in one session: the Activity count plus an open question. */\nexport function sessionWaitingCount(summary: SessionSummary): number {\n  return activityWaitingCount(summary) + (summary.awaitingInput ? 1 : 0);\n}\n\nfunction sessionView(\n  id: string,\n  ordinal: number,\n  input: SessionRailModelInput,\n  workspaceEligible = false,\n): WebTemplateRailSession {\n  const entry = input.byId[id]!;\n  const { summary, attach } = entry;\n  const restart = input.restarts[id];\n  const restarting = restart?.restarting === true;\n  const live = railSessionStatus(entry, input.now);\n  const status = restarting ? 'restarting…' : live.status;\n  const clock = restarting ? undefined : live.clock;\n  const parentId = input.nested.get(id);\n  const nested = parentId !== undefined;\n  const profile = summary.profile;\n  const label = profile === undefined ? undefined : (profile.displayName ?? profile.name);\n  const avatarUrl = input.avatarUrls[id];\n  const waiting = attach === 'refused' || restarting ? 0 : sessionWaitingCount(summary);\n  const lastActivityAt = Date.parse(summary.updatedAt);\n  const move = sessionMoveTarget(summary, input.workspacesById, input.workspaceOrder);\n  return {\n    id,\n    name: summary.name,\n    canInteract: entry.canInteract === true,\n    ...(move === undefined ? {} : { move }),\n    ordinal,\n    active: id === input.activeId,\n    nested,\n    ...(parentId === undefined ? {} : { parentId }),\n    ...(nested && summary.sessionProvenance !== undefined ? { provenance: summary.sessionProvenance } : {}),\n    ...(summary.sessionProvenance === COORDINATOR_SESSION_PROVENANCE ? { coordinator: true } : {}),\n    coordinatorEligible:\n      workspaceEligible &&\n      !nested &&\n      summary.parentSessionId === undefined &&\n      (summary.sessionProvenance === undefined || summary.sessionProvenance === COORDINATOR_SESSION_PROVENANCE),\n    status,\n    ...(clock === undefined ? {} : { clock }),\n    // The same priority the status copy uses: a refusal outranks the question,\n    // and a restarting card is describing the restart, not the run it ended.\n    awaitingInput: waiting > 0,\n    ...(waiting > 0 ? { waitingCount: waiting } : {}),\n    ...(Number.isNaN(lastActivityAt) ? {} : { lastActivityAt }),\n    restarting,\n    restartBlocked: summary.dormant !== true && summary.phase !== undefined && summary.phase !== 'idle',\n    ...(restart?.error === undefined ? {} : { error: restart.error }),\n    ...(summary.git === undefined ? {} : { git: { branch: summary.git.branch, dirty: summary.git.dirty } }),\n    ...(summary.groups === undefined || summary.groups.length === 0 ? {} : { groups: summary.groups }),\n    ...(profile === undefined || label === undefined\n      ? {}\n      : {\n          profile: {\n            name: profile.name,\n            label,\n            initials: personaInitials(label),\n            ...(avatarUrl === undefined ? {} : { avatarUrl }),\n          },\n        }),\n    pendingSetups: (summary.pendingSetups ?? []).map(pendingSetupView),\n  };\n}\n\n/** Headerless session scopes first, ordinary workspaces in host order, and legacy sessions last. */\nexport function buildRailWorkspaces(input: SessionRailModelInput): WebTemplateRailWorkspace[] {\n  const ordinals = new Map(railShortcutOrder(input.order, input.byId).map((id, index) => [id, index + 1]));\n  const grouped = new Set<string>();\n  const workspaces: WebTemplateRailWorkspace[] = [];\n  for (const workspaceId of input.workspaceOrder) {\n    const workspace = input.workspacesById[workspaceId];\n    if (workspace === undefined) continue;\n    const ids = input.order.filter((id) => input.byId[id]?.summary.workspaceId === workspaceId);\n    if (workspace.kind === 'session' && ids.length === 0) continue;\n    if (\n      !ids.length &&\n      Object.values(input.byId).some(\n        ({ summary }) =>\n          summary.workspaceId === workspaceId && summary.sessionProvenance === VOICE_ORCHESTRATOR_SESSION_PROVENANCE,\n      )\n    )\n      continue;\n    for (const id of ids) grouped.add(id);\n    workspaces.push({\n      id: workspaceId,\n      ...(workspace.kind === undefined ? {} : { kind: workspace.kind }),\n      name: workspaceName(workspace),\n      root: workspace.root,\n      available: workspace.available !== false,\n      legacy: false,\n      ...(workspace.sandbox === undefined ? {} : { sandboxed: true }),\n      canAddCoordinator:\n        workspace.kind !== 'session' &&\n        workspace.available !== false &&\n        workspace.sandbox === undefined &&\n        !Object.values(input.byId).some(\n          ({ summary }) =>\n            summary.workspaceId === workspaceId && summary.sessionProvenance === COORDINATOR_SESSION_PROVENANCE,\n        ),\n      sessions: ids.map((id) =>\n        sessionView(\n          id,\n          ordinals.get(id) ?? 0,\n          input,\n          workspace.sandbox === undefined && (workspace.kind === 'session' || workspace.available !== false),\n        ),\n      ),\n    });\n  }\n  workspaces.sort((left, right) => Number(right.kind === 'session') - Number(left.kind === 'session'));\n  const legacy = input.order.filter((id) => !grouped.has(id) && input.byId[id] !== undefined);\n  if (legacy.length > 0) {\n    const root = input.byId[legacy[0]!]!.summary.cwd;\n    workspaces.push({\n      id: LEGACY_WORKSPACE_ID,\n      name: workspaceName({ root }),\n      root,\n      available: false,\n      legacy: true,\n      canAddCoordinator: false,\n      sessions: legacy.map((id) => sessionView(id, ordinals.get(id) ?? 0, input)),\n    });\n  }\n  return workspaces;\n}\n\n/**\n * `next` with every session and workspace from `previous` whose content did not\n * change kept as the same object, so a memoized card renders again only when\n * its own session moved rather than on every push to any session.\n */\nexport function reuseRailWorkspaces(\n  previous: readonly WebTemplateRailWorkspace[],\n  next: readonly WebTemplateRailWorkspace[],\n): WebTemplateRailWorkspace[] {\n  const previousSessions = new Map(\n    previous.flatMap(({ sessions }) => sessions.map((session) => [session.id, session])),\n  );\n  const previousWorkspaces = new Map(previous.map((workspace) => [workspace.id, workspace]));\n  return next.map((workspace) => {\n    const sessions = workspace.sessions.map((session) => {\n      const before = previousSessions.get(session.id);\n      return before !== undefined && summaryValueEqual(before, session) ? before : session;\n    });\n    const before = previousWorkspaces.get(workspace.id);\n    const unchanged =\n      before !== undefined &&\n      before.sessions.length === sessions.length &&\n      sessions.every((session, index) => session === before.sessions[index]) &&\n      summaryValueEqual({ ...before, sessions: [] }, { ...workspace, sessions: [] });\n    return unchanged ? before : { ...workspace, sessions };\n  });\n}\n\n/** Shared web/native destination policy. The server remains the authority at submission. */\nexport function sessionMoveTarget(\n  summary: SessionSummary,\n  workspacesById: Readonly<Record<string, WorkspaceSummary>>,\n  workspaceOrder: readonly string[],\n): WebTemplateRailSession['move'] {\n  const source = summary.workspaceId === undefined ? undefined : workspacesById[summary.workspaceId];\n  return source === undefined || source.sandbox !== undefined || source.available === false\n    ? undefined\n    : {\n        workspaceName: workspaceName(source),\n        blocked: summary.dormant !== true && summary.phase !== 'idle',\n        destinations: workspaceOrder.flatMap((workspaceId) => {\n          const workspace = workspacesById[workspaceId];\n          return workspace &&\n            workspaceId !== source.id &&\n            workspace.kind !== 'session' &&\n            workspace.available !== false &&\n            workspace.sandbox === undefined &&\n            splitHostId(workspaceId)?.hostId === splitHostId(summary.id)?.hostId\n            ? [{ id: workspaceId, name: workspaceName(workspace), root: workspace.root }]\n            : [];\n        }),\n      };\n}\n"],"mappings":";;;;;AA0BA,MAAa,sBAAsB;;AAGnC,SAAgB,uBACd,YACA,aACA,QACkD;CAClD,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,aAAa,GAAG,WAAW,KAAK,cAAcA,qBAAAA,YAAY,UAAU,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KACrG,YAAY;EACX,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC,OAAO,WAAW,KAAA,IAAY,kBAAmB,OAAO,WAAW,YAAY,OAAO,MAAM,GAAG,CAAC;EAChG,aAAa,WAAW,MACrB,cACC,UAAU,SAAS,aACnBA,qBAAAA,YAAY,UAAU,EAAE,CAAC,EAAE,WAAW,UACtC,UAAU,SAAS,MAAM,YAAY,QAAQ,WAAW,CAC5D;CACF,EACF;AACF;;AAGA,SAAgB,sBACd,QACA,gBACA,WACoB;CACpB,MAAM,YAAY,OAAO,gBAAgB,KAAA,IAAY,KAAA,IAAY,eAAe,OAAO;CACvF,IAAI,WAAW,YAAY,KAAA,GAAW,OA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