Agent Teams
English | 中文
Types shared by the experimental implicit-root Team domain, model tools, and host adapters. The Agent Teams Agent Note owns identity, mailbox, task, and shared-checkout decisions; this page records the literal durable forms from packages/experimental/agent-team/src/types.ts.
Identity and roster
TeamId is the root SessionId under a distinct brand. TeamTaskId is Team-local and monotonically allocated as task-<n>; TeamMessageId is globally random. A teammate's Session id remains its persistent identity, while name is an immutable model/UI label.
/** Whole durable value written on every teammate lifecycle change. */
interface TeamMemberSnapshot {
readonly id: SessionId
readonly name: string
readonly description: string
readonly provider: string
readonly context: 'fresh' | 'fork'
readonly phase: TeamMemberPhase
readonly error?: string
}Every member starts in provisioning and reaches exactly one terminal roster phase, active or failed. Runtime running/idle/inactive status is derived separately and never rewrites this record.
Durable mailbox
The Lead Session first stores the complete queued message. A target receipt is acknowledged only after its pending inbox item or recorded user message is durable, leaving queued-minus-delivered as the recovery mailbox.
/** One peer message retained until its target Session records it. */
interface TeamMessageSnapshot {
readonly id: TeamMessageId
readonly senderId: SessionId
readonly senderName: string
readonly targetId: SessionId
readonly delivery: 'quiet' | 'wakeup'
readonly content: ContentBlock[]
}The target Session keeps message identity and sender attribution on both the pending inbox item and the eventual user message. Folding that source across inbox and history is the target-side de-duplication key; the model-visible framing repeats the id and sender.
/** Source retained by the target Session for durable mailbox de-duplication. */
interface TeamMessageSource {
readonly kind: 'team-message'
readonly teamId: TeamId
readonly messageId: TeamMessageId
readonly senderId: SessionId
readonly senderName: string
}Shared task DAG
Every task event stores a complete snapshot. revision is the compare-and-set value and increments by one per mutation. blockedBy edges must name non-deleted tasks and keep the graph acyclic. writeScopes are normalized advisory path prefixes rather than locks.
/** Whole durable task snapshot; every mutation increments {@link revision}. */
interface TeamTaskSnapshot {
readonly id: TeamTaskId
readonly revision: number
readonly subject: string
readonly description: string
readonly status: TeamTaskStatus
readonly ownerId?: SessionId
readonly blockedBy: TeamTaskId[]
readonly writeScopes: string[]
}pending is unstarted or released, in_progress carries an owner, completed satisfies blockers, and deleted is a retained tombstone. Views add owner name, readiness, and write-scope overlap warnings without changing the durable snapshot.
Replay
foldTeam() replays one root Session into the roster, task board, and queued-minus-delivered mailbox that every Team operation reads. It selects records by TeamId, so events inherited by an ordinary fork retain the ancestor id and never enter the new root's state. Session event seq and time remain the ordering and timing record; Team snapshots do not duplicate them. Roster and task reads reach callers as views that add owner name, readiness, and write-scope warnings, while pending mail stays internal to delivery and recovery. The package README owns operation, authorization, recovery, and limit behavior.
Cordis API
Generated from source by scripts/gen-cordis-catalog.ts (verified fresh by pnpm run verify-cordis-catalog in doc-sync; regenerate with pnpm run gen-cordis-catalog) — the language sides differ only in locale-specific paired document paths. Signature blocks use a ts cordis-catalog fence and keep the original source JSDoc; dispatch modes are defined in the primer, and the framework-inherited ctx API lives in cordis-api/inherited.md.
ctx.agentTeams — TeamService
Agent Teams service backed by the exact live Lead Session log.
/**
* Resolve one exact live Agent's Team role.
* @param agent - exact live Agent used as the authority credential.
* @returns its root, Team identity, role, and model-facing name.
*/
membership(agent: Agent): TeamMembership
/**
* List the runtime-enriched roster visible to one Team member.
* @param agent - exact live Team member.
* @returns Lead and teammate rows in creation order.
*/
listMembers(agent: Agent): TeamMemberView[]
/**
* Create one named, continuable direct child of the Team Lead.
* @param caller - exact live Lead Agent.
* @param request - immutable name, description, prompt, context mode, provider, and cancellation.
* @returns the active roster row.
*/
async spawnTeammate(caller: Agent, request: SpawnTeammateRequest): Promise<SpawnTeammateResult>
/**
* Queue one durable peer message, then attempt immediate delivery.
* @param caller - exact live sending Team member.
* @param request - target name, content, scheduling mode, and pre-queue cancellation.
* @returns durable message identity and immediate-delivery observation.
*/
async sendMessage(caller: Agent, request: SendTeamMessageRequest): Promise<SendTeamMessageResult>
/**
* Create one unowned pending task in the Team Lead log.
* @param caller - exact live Team member creating the task.
* @param request - task text, blockers, and advisory write scopes.
* @returns the revision-one task view.
*/
async createTask(caller: Agent, request: CreateTeamTaskRequest): Promise<TeamTaskView>
/**
* Return one task, including a deleted tombstone.
* @param caller - exact live Team member reading the task.
* @param id - Team-local task identity.
* @returns the latest task value and derived readiness diagnostics.
*/
getTask(caller: Agent, id: TeamTaskId): TeamTaskView
/**
* List current non-deleted tasks in numeric creation order.
* @param caller - exact live Team member reading the board.
* @returns detached current task views.
*/
listTasks(caller: Agent): TeamTaskView[]
/**
* Compare-and-set one authorized task transition.
* @param caller - exact live Team member authorizing the mutation.
* @param request - task identity, expected revision, action, and action fields.
* @returns the committed next task revision.
*/
async updateTask(caller: Agent, request: UpdateTeamTaskRequest): Promise<TeamTaskView>
/**
* Wait for the next Team-domain or member-status change.
* @param caller - exact live Team member waiting for activity.
* @param timeoutMs - bounded wait duration from ten seconds through one hour.
* @param signal - caller cancellation for the wait only.
* @returns one observed change or a timeout result.
*/
async waitForChange(caller: Agent, timeoutMs: number, signal: AbortSignal): Promise<TeamWaitResult>
/**
* Interrupt one live teammate turn without clearing its pending inbox.
* @param caller - exact live Lead Agent.
* @param targetName - durable teammate name.
* @returns the target status sampled before cancellation.
*/
interrupt(caller: Agent, targetName: string): { previousStatus: 'running' | 'idle' | 'inactive' }
/**
* Resolve a caller without throwing, used by scoped-tool installation and observers.
* @param agent - candidate exact live Agent.
* @returns Team membership, or undefined for non-Team subagents and stale identities.
*/
tryMembership(agent: Agent): TeamMembership | undefinedTypes: Agent