| |
| |
| |
| |
|
|
| import type { InProcessTeammateTaskState } from '../tasks/InProcessTeammateTask/types.js' |
| import { isInProcessTeammateTask } from '../tasks/InProcessTeammateTask/types.js' |
| import type { LocalAgentTaskState } from '../tasks/LocalAgentTask/LocalAgentTask.js' |
| import type { AppState } from './AppStateStore.js' |
|
|
| |
| |
| |
| |
| |
| |
| |
| export function getViewedTeammateTask( |
| appState: Pick<AppState, 'viewingAgentTaskId' | 'tasks'>, |
| ): InProcessTeammateTaskState | undefined { |
| const { viewingAgentTaskId, tasks } = appState |
|
|
| |
| if (!viewingAgentTaskId) { |
| return undefined |
| } |
|
|
| |
| const task = tasks[viewingAgentTaskId] |
| if (!task) { |
| return undefined |
| } |
|
|
| |
| if (!isInProcessTeammateTask(task)) { |
| return undefined |
| } |
|
|
| return task |
| } |
|
|
| |
| |
| |
| |
| export type ActiveAgentForInput = |
| | { type: 'leader' } |
| | { type: 'viewed'; task: InProcessTeammateTaskState } |
| | { type: 'named_agent'; task: LocalAgentTaskState } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export function getActiveAgentForInput( |
| appState: AppState, |
| ): ActiveAgentForInput { |
| const viewedTask = getViewedTeammateTask(appState) |
| if (viewedTask) { |
| return { type: 'viewed', task: viewedTask } |
| } |
|
|
| const { viewingAgentTaskId, tasks } = appState |
| if (viewingAgentTaskId) { |
| const task = tasks[viewingAgentTaskId] |
| if (task?.type === 'local_agent') { |
| return { type: 'named_agent', task } |
| } |
| } |
|
|
| return { type: 'leader' } |
| } |
|
|