/** * Agent Team module — manages team state, output stream parsing, * and team lifecycle for multi-agent team mode. * * team.ts is an observer, not an orchestrator: it intercepts the Lead's * output stream to extract UI state (agent list, task board, activity feed) * while the Lead Claude process drives all planning/execution autonomously. */ export type { TeamConfig, AgentRole, TaskItem, TeamState, AgentTeammate, TeamAgentMessage, TeamFeedEntry, TeamStateSerialized, TeamSummaryInfo, AgentDef, AgentsDefMap, } from './team-types.js'; export { buildAgentsDef, buildLeadPrompt } from './team-templates.js'; export { getNextAgentColor, classifyRole, pickCharacter, deriveAgentDisplayName, deriveTaskTitle } from './team-naming.js'; export { serializeTeam, deserializeTeam, persistTeam, persistTeamDebounced, loadTeam, listTeams, deleteTeam, renameTeam, } from './team-persistence.js'; import type { TeamConfig, TeamState, AgentTeammate, TeamAgentMessage, TeamFeedEntry, SendFn, HandleChatFn, CancelExecutionFn, AddOutputObserverFn, RemoveOutputObserverFn, AddCloseObserverFn, RemoveCloseObserverFn } from './team-types.js'; export declare function setTeamSendFn(fn: SendFn): void; /** * Inject claude.ts dependencies to avoid circular imports. * Called once during agent startup from connection.ts. */ export declare function setTeamClaudeFns(fns: { handleChat: HandleChatFn; cancelExecution: CancelExecutionFn; addOutputObserver: AddOutputObserverFn; removeOutputObserver: RemoveOutputObserverFn; addCloseObserver: AddCloseObserverFn; removeCloseObserver: RemoveCloseObserverFn; /** @deprecated Alias for addOutputObserver */ setOutputObserver?: AddOutputObserverFn; /** @deprecated Alias for removeOutputObserver */ clearOutputObserver?: () => void; /** @deprecated Alias for addCloseObserver */ setCloseObserver?: AddCloseObserverFn; /** @deprecated Alias for removeCloseObserver */ clearCloseObserver?: () => void; }): void; export declare function getActiveTeam(): TeamState | null; /** * Create a new team. Returns the TeamState. * Does NOT start the Lead process — the caller (team lifecycle functions) does that. */ export declare function createTeamState(config: TeamConfig, conversationId: string, workDir: string): TeamState; /** * Clear the active team (used on dissolve/complete). */ export declare function clearActiveTeam(): void; /** * Register a subagent when Lead calls the Agent tool. */ export declare function registerSubagent(team: TeamState, toolUseId: string, input: { name?: string; description?: string; prompt?: string; }): AgentTeammate; /** * Link a subagent's task_started system message to its tool_use_id. */ export declare function linkSubagentTaskId(team: TeamState, toolUseId: string, taskId: string): AgentTeammate | null; /** * Find agent by toolUseId (parent_tool_use_id). */ export declare function findAgentByToolUseId(team: TeamState, toolUseId: string): AgentTeammate | null; /** * Find agent by agentTaskId (task_id from system.task_started). */ export declare function findAgentByTaskId(team: TeamState, agentTaskId: string): AgentTeammate | null; /** * Add a message to an agent's message list. */ export declare function addAgentMessage(agent: AgentTeammate, role: 'assistant' | 'tool' | 'user', fields: Partial>): TeamAgentMessage; /** * Add an entry to the team's activity feed. */ export declare function addFeedEntry(team: TeamState, agentId: string, type: TeamFeedEntry['type'], content: string): TeamFeedEntry; /** * Mark a task as done/failed. */ export declare function updateTaskStatus(team: TeamState, taskId: string, status: 'done' | 'failed'): import('./team-types.js').TaskItem | null; /** * Check if all subagent tasks are completed. */ export declare function allSubagentsDone(team: TeamState): boolean; /** * Wrapper for flushPendingPersists that passes activeTeam. */ export declare function flushPendingPersists(): void; /** * Output observer callback for the Lead's stdout stream. * Registered via setOutputObserver() when a team is active. * Returns true to suppress the message from normal web client forwarding. */ export declare function onLeadOutput(conversationId: string, msg: Record): boolean; /** * Close observer callback for the Lead's process exit. * Detects Lead crash (process exited without a result message) and dissolves the team. */ export declare function onLeadClose(conversationId: string, _exitCode: number | null, resultReceived: boolean): void; /** * Create and launch a team. Returns the TeamState. * Spawns the Lead Claude process with --agents flag and attaches the output observer. */ export declare function createTeam(config: TeamConfig, workDir: string): TeamState; /** * Dissolve (cancel) the active team. */ export declare function dissolveTeam(): void; /** * Called when the Lead's result message arrives (from onLeadOutput). * Marks the team as completed, persists state, and notifies clients. */ export declare function completeTeam(summary?: string): void;