Type alias AgencyStreamPart

AgencyStreamPart: {
    type: "text";
    text: string;
    agent?: string;
} | {
    type: "tool-call";
    toolName: string;
    args: unknown;
    agent?: string;
} | {
    type: "tool-result";
    toolName: string;
    result: unknown;
    agent?: string;
} | {
    type: "error";
    error: Error;
    agent?: string;
} | {
    type: "agent-start";
    agent: string;
    input: string;
} | {
    type: "agent-end";
    agent: string;
    output: string;
    durationMs: number;
} | {
    type: "agent-handoff";
    fromAgent: string;
    toAgent: string;
    reason: string;
} | {
    type: "strategy-override";
    original: string;
    chosen: string;
    reason: string;
} | {
    type: "emergent-forge";
    agentName: string;
    instructions: string;
    approved: boolean;
} | {
    type: "guardrail-result";
    agent: string;
    guardrailId: string;
    passed: boolean;
    action: string;
} | {
    type: "approval-requested";
    request: ApprovalRequest;
} | {
    type: "approval-decided";
    requestId: string;
    approved: boolean;
} | {
    type: "final-output";
    text: string;
    usage: {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
        costUSD?: number;
    };
    agentCalls: AgentCallRecord[];
    parsed?: unknown;
    durationMs: number;
} | {
    type: "permission-denied";
    agent: string;
    action: string;
    reason: string;
}

Discriminated union of all streaming events emitted by an agency() stream. A superset of the base StreamPart type — includes all text/tool events plus agency-level lifecycle events and the finalized post-processing snapshot.

text parts are low-latency raw stream chunks. The finalized approved answer is surfaced separately through the final-output part, AgencyStreamResult.text, and AgencyStreamResult.finalTextStream.

Type declaration

  • type: "text"
  • text: string
  • Optional agent?: string

Type declaration

  • type: "tool-call"
  • toolName: string
  • args: unknown
  • Optional agent?: string

Type declaration

  • type: "tool-result"
  • toolName: string
  • result: unknown
  • Optional agent?: string

Type declaration

  • type: "error"
  • error: Error
  • Optional agent?: string

Type declaration

  • type: "agent-start"
  • agent: string
  • input: string

Type declaration

  • type: "agent-end"
  • agent: string
  • output: string
  • durationMs: number

Type declaration

  • type: "agent-handoff"
  • fromAgent: string
  • toAgent: string
  • reason: string

Type declaration

  • type: "strategy-override"
  • original: string
  • chosen: string
  • reason: string

Type declaration

  • type: "emergent-forge"
  • agentName: string
  • instructions: string
  • approved: boolean

Type declaration

  • type: "guardrail-result"
  • agent: string
  • guardrailId: string
  • passed: boolean
  • action: string

Type declaration

Type declaration

  • type: "approval-decided"
  • requestId: string
  • approved: boolean

Type declaration

  • type: "final-output"
  • text: string
  • usage: {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
        costUSD?: number;
    }
    • promptTokens: number
    • completionTokens: number
    • totalTokens: number
    • Optional costUSD?: number
  • agentCalls: AgentCallRecord[]
  • Optional parsed?: unknown
  • durationMs: number

Type declaration

  • type: "permission-denied"
  • agent: string
  • action: string
  • reason: string