ToolCall

A mapped union preserves each declared name's argument/result relationship. pending means decoded, finalized arguments awaiting execution, not partial streamed JSON. A session that shows argument fragments lists them apart as StreamingToolCall entries until they are finalized. parts holds a result's structured parts when the backend returned them, such as text and media parts; result or error then holds their text.

import type { ToolCall } from '@threadplane/angular/chat';

Declaration

export type ToolCall<TTools extends {
    [K in keyof TTools]: ToolContract;
} = Record<string, ToolContract>> = {
    [K in keyof TTools & string]: TTools[K] extends {
        readonly args: infer A;
        readonly result: infer R;
    } ? {
        readonly id: string;
        readonly name: K;
        readonly args: SnapshotValue<A>;
    } & ({
        readonly status: 'pending' | 'running';
    } | {
        readonly status: 'complete';
        readonly result: SnapshotValue<R>;
        readonly parts?: readonly PlainValue[];
    } | {
        readonly status: 'error';
        readonly error: string;
        readonly parts?: readonly PlainValue[];
    }) : never;
}[keyof TTools & string];

Type parameters

TTools
{ [K in keyof TTools]: ToolContract; } Default: Record<string, ToolContract>