import type { SettleOutcome } from './agent-flow.ts'; /** The stop reason vocabulary `subagent/end` carries (`SubagentStopReason`). */ export type TeamStopReason = 'completed' | 'aborted' | 'error' | 'max-tokens' | 'refusal'; /** The structural service surface the ledger needs from `ctx.agentTeams`. */ export interface TeamRosterRead { /** * List the roster visible to one Team member. Service-level rows carry * `id` (the child `SessionId`) and `name` (the model-facing target the * spawning tool returned); the tool layer strips `id`, the service row * does not. */ listMembers(agent: unknown): unknown; } /** The minimum context surface needed to resolve the optional service (structural — tests pass a `Context`). */ export interface TeamServiceContext { get(name: string): unknown; } /** * True when `name` is one of the fixed Agent Teams carriers the dispatch gate * owns ({@link TEAM_DISPATCH_TOOLS}). The ledger uses the SAME map as the gate, * so the two channels cannot drift. * @param name - the tool name of the in-flight call. */ export declare function isTeamDispatchToolName(name: string): boolean; /** * Resolve the optional `ctx.agentTeams` service to its roster read. A missing * service, a non-object service, or a service without a callable * `listMembers` reports `undefined` — the documented "team packages absent" * state, never a throw. * @param ctx - the registrant/entry context (a structural `get` read). */ export declare function teamRosterOf(ctx: TeamServiceContext): TeamRosterRead | undefined; /** * True when the experimental Agent Teams service is mounted. This is the ONE * presence test the ledger uses: while it is false, team tools record nothing * at all (no dispatch row, no pairing entry, no catalog slot). * @param ctx - the registrant/entry context. */ export declare function teamServicePresent(ctx: TeamServiceContext): boolean; /** * The model-facing member NAME a successful `spawn_teammate` result names * (`{ member: { target } }` — the tool's `modelMember` projection). A missing, * non-string, or empty target yields `undefined` (never a fabricated name). * @param value - the tool result's `value` payload. */ export declare function memberNameOfSpawnResult(value: unknown): string | undefined; /** * Whether the `spawn_teammate` result itself proves the member is gone: the * upstream tool throws on creation failure and records a durable `failed` * row, so a returned `status: 'failed'` (the runtime-enriched * `TeamMemberView` field; the view has no `phase`) is the only * successful-return shape that does. The name stays permanently consumed * upstream; the ledger settles `error` instead of waiting for a turn that can * never run. * @param value - the tool result's `value` payload. */ export declare function memberFailedOfSpawnResult(value: unknown): boolean; /** * Resolve one teammate NAME to its child `SessionId` through the roster of the * carrying (Lead) agent. Contained: an absent service, an unreadable roster, * or a missing/duplicate name yields `undefined`. Names are unique per Team * upstream; the FIRST exact match is returned (a duplicate would be an * upstream contract violation, and never a second guess is made here). * @param roster - the resolved optional roster read. * @param agent - the exact live agent that carried the team call. * @param name - the model-facing member name. */ export declare function memberIdOfName(roster: TeamRosterRead | undefined, agent: unknown, name: string): string | undefined; /** * Map one `subagent/end` stop reason to the ledger's settle outcome. `aborted` * is an interruption (the member was stopped) and `refusal` a declined task — * both are `denied`, matching the jobs mapping (`killed → denied`); `error` * and a token-ceiling stop are `error`; only `completed` is `ok`. An * unrecognized reason yields `undefined` — the caller records an explicit * unresolved continuation rather than guessing an outcome. * @param stopReason - the terminal reason carried by the child settlement. */ export declare function settleOutcomeOfStopReason(stopReason: unknown): SettleOutcome | undefined;