/** * The `agent_teams_*` model-facing tools. * * The captain (the agent that created the team) orchestrates: members are * continuable subagents it spawns and wakes. Members share the same tools and * drive their own task state, mirroring the Claude Code AgentTeams flow: * create team → add members → create tasks with dependencies → claim/assign → * work → report → status → delete. * @module dsh-agent-teams/tools */ import type { Context } from '@deepseek-ai/cordis'; import type { Agent } from '@deepseek-ai/dsh-agent'; import { type TeamState, type TeamTask } from './types.ts'; export { steerCaptainReport } from './members.ts'; /** Resolved plugin config consumed by the tools. */ export interface ToolsConfig { /** State directory name under the captain's workspace. */ stateDir: string; /** Member subagent provider name. */ memberProvider: string; /** Optional member model override. */ memberModel?: string; /** Prompt injected into member personas and assignments. */ executionPrompt?: string; /** Plugin fallback route. */ fallback?: import('./profiles.ts').TeamModelFallbackConfig; /** Member delegation depth cap. */ memberMaxDepth?: number; /** Team size cap (members). */ maxMembers: number; /** Named team profiles from the active DSH profile. */ profiles: Record; } /** Browser/UI mutations allowed while a plan is waiting for approval. */ export type StagedPlanMutation = { action: 'update_member'; memberName: string; role?: string | null; provider: string; model: string; reasoningEffort?: string | null; executionPrompt?: string | null; } | { action: 'update_task'; taskId: string; subject: string; description?: string | null; assignee?: string | null; dependencies: string[]; } | { action: 'add_task'; subject: string; description?: string | null; assignee?: string | null; dependencies: string[]; } | { action: 'remove_task'; taskId: string; } | { action: 'remove_member'; memberName: string; }; /** Runtime bridge shared by model-facing tools and the Web staging surface. */ export interface AgentTeamsRuntime { isPendingMember(agent: Agent): boolean; updateStagedPlan(captain: Agent, teamId: string, mutation: StagedPlanMutation, signal?: AbortSignal): Promise; updateStagedPlanBatch(captain: Agent, teamId: string, mutations: readonly StagedPlanMutation[], signal?: AbortSignal): Promise; approveStagedTeam(captain: Agent, teamId: string, signal?: AbortSignal): Promise<{ teamId: string; members: number; tasks: number; }>; continueStagedPlanning(captain: Agent, teamId: string): Promise<{ teamId: string; alreadyWaiting: boolean; }>; discardStagedTeam(captain: Agent, teamId: string): Promise<{ teamId: string; }>; } export declare function haltTeamWork(input: { ctx: Context; stateRoot: string; teamId: string; captain: Agent; signal?: AbortSignal; }): Promise<{ teamName: string; cancelledTasks: number; alreadyHalted: boolean; }>; /** Web approval has no tool result in the captain's conversation. */ export declare function stagedPlanApprovedContext(teamName: string): string; /** Context queued after the human rejects a staged plan. */ export declare function stagedPlanDiscardContext(teamName: string): string; /** Model-facing continuation that turns the review UI back into a conversation. */ export declare function stagedPlanFeedbackContext(teamName: string): string; /** * Register every `agent_teams_*` tool into the shared tools registry. * @param ctx - the plugin context (injects `tools`). * @param config - resolved tool config. */ export declare function registerAgentTeamsTools(ctx: Context, config: ToolsConfig): AgentTeamsRuntime; export declare function applyQualityFollowUp(team: TeamState, closed: TeamTask): { created: TeamTask[]; escalated: boolean; };