import type { AiUsage } from '@takeshape/util';
import type { ModelMessage } from 'ai';
import type { FromSchema } from 'json-schema-to-ts';
export declare const shapeName = "TSAgentMessage";
export declare const schema: {
    readonly $id: "https://takeshape.io/schema/agent-message-payload";
    readonly type: "object";
    readonly properties: {
        readonly messageId: {
            readonly type: "string";
            readonly description: "ID of the message that was deferred";
        };
        readonly sessionId: {
            readonly type: "string";
            readonly description: "ID of the session this message belongs to";
        };
        readonly projectId: {
            readonly type: "string";
            readonly description: "Project ID of the project this message belongs to";
        };
        readonly schemaId: {
            readonly type: "string";
            readonly description: "Schema ID this message was created by";
        };
        readonly agentName: {
            readonly type: "string";
            readonly description: "Name of the agent this message was created by";
        };
        readonly args: {
            readonly type: "object";
        };
        readonly input: {
            readonly title: "TSAgentMessageInput";
            readonly description: "The input schema for agent messages.";
            readonly discriminator: {
                readonly propertyName: "type";
            };
            readonly oneOf: [{
                readonly title: "TSAgentMessageUnknownInput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "unknown";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentMessageStringInput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "string";
                    };
                    readonly content: {
                        readonly type: "string";
                    };
                };
                readonly required: ["type", "content"];
                readonly additionalProperties: false;
            }];
        };
        readonly output: {
            readonly title: "TSAgentMessageOutput";
            readonly description: "The output schema for agent messages.";
            readonly discriminator: {
                readonly propertyName: "type";
            };
            readonly oneOf: [{
                readonly title: "TSAgentGenerateStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "generate";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentGraphQLStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "graphql";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentChatStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "chat";
                    };
                    readonly data: {
                        readonly type: "object";
                        readonly properties: {
                            readonly content: {
                                readonly type: "string";
                            };
                            readonly artifact: {
                                readonly type: "object";
                            };
                            readonly references: {
                                readonly type: "array";
                                readonly items: {
                                    readonly type: "object";
                                    readonly properties: {
                                        readonly _tid: {
                                            readonly type: "string";
                                        };
                                    };
                                    readonly required: ["_tid"];
                                    readonly additionalProperties: false;
                                };
                            };
                        };
                        readonly required: ["content", "references"];
                        readonly additionalProperties: false;
                    };
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentUnknownStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "unknown";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }];
        };
        readonly error: {
            readonly type: "object";
            readonly properties: {
                readonly message: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly code: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: false;
        };
        readonly runMode: {
            readonly enum: ["BACKGROUND", "IMMEDIATE"];
            readonly description: "Indicates how the agent message was run";
        };
        readonly abortedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was aborted";
        };
        readonly sentAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was sent";
        };
        readonly startedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message started processing";
        };
        readonly finishedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message finished processing";
        };
        readonly span: {
            readonly type: "object";
            readonly description: "The span for the agent run associated with this message";
            readonly properties: {
                readonly traceId: {
                    readonly type: "string";
                };
                readonly spanId: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly createdAt: {
                    readonly type: "number";
                };
            };
            readonly required: ["traceId", "spanId", "name", "createdAt"];
            readonly additionalProperties: false;
        };
        readonly feedback: {
            readonly type: "object";
            readonly properties: {
                readonly name: {
                    readonly type: "string";
                    readonly description: "Name of the feedback, e.g., \"Quality\", \"Relevance\"";
                };
                readonly label: {
                    readonly type: "string";
                    readonly description: "String feedback for the agent message, e.g., \"helpful\", \"not helpful\". If a label is provided, a score must not be provided.";
                };
                readonly score: {
                    readonly type: "number";
                    readonly description: "Numeric feedback for the agent message, typically between 1 and 5. If a score is provided, a label must not be provided.";
                };
                readonly text: {
                    readonly type: "string";
                    readonly description: "Freeform text feedback for the agent message.";
                };
                readonly note: {
                    readonly type: "string";
                    readonly description: "Optional note for the feedback, e.g., \"This was helpful because...\"";
                };
                readonly updatedBy: {
                    readonly type: "string";
                    readonly description: "A string identifying the user who is adding the annotation, such as a name or email address.";
                };
                readonly createdAt: {
                    readonly type: "number";
                    readonly description: "Timestamp when the feedback was created";
                };
            };
            readonly additionalProperties: false;
            readonly required: ["name"];
        };
        readonly blocked: {
            readonly type: "boolean";
            readonly description: "If this message was blocked by a guardrail";
        };
        readonly usage: {
            readonly type: "array";
            readonly description: "Itemized token usage breakdown by service and model";
            readonly items: {
                readonly title: "TSAiUsageItem";
                readonly type: "object";
                readonly description: "Token usage breakdown for a single service and model";
                readonly properties: {
                    readonly service: {
                        readonly type: "string";
                        readonly description: "The AI service provider (e.g., \"openai\", \"anthropic\")";
                    };
                    readonly model: {
                        readonly type: "string";
                        readonly description: "The model identifier (e.g., \"gpt-4\", \"claude-3-opus\")";
                    };
                    readonly inputTokens: {
                        readonly type: "number";
                        readonly description: "Number of input/prompt tokens consumed";
                    };
                    readonly outputTokens: {
                        readonly type: "number";
                        readonly description: "Number of output/completion tokens generated";
                    };
                    readonly totalTokens: {
                        readonly type: "number";
                        readonly description: "Total tokens (input + output)";
                    };
                    readonly inputTokenDetails: {
                        readonly type: "object";
                        readonly description: "Detailed breakdown of input token usage";
                        readonly properties: {
                            readonly noCacheTokens: {
                                readonly type: "number";
                                readonly description: "Tokens not using cache";
                            };
                            readonly cacheReadTokens: {
                                readonly type: "number";
                                readonly description: "Tokens served from cache";
                            };
                            readonly cacheWriteTokens: {
                                readonly type: "number";
                                readonly description: "Tokens written to cache";
                            };
                        };
                    };
                    readonly outputTokenDetails: {
                        readonly type: "object";
                        readonly description: "Detailed breakdown of output token usage";
                        readonly properties: {
                            readonly textTokens: {
                                readonly type: "number";
                                readonly description: "Regular text output tokens";
                            };
                            readonly reasoningTokens: {
                                readonly type: "number";
                                readonly description: "Extended thinking tokens";
                            };
                        };
                    };
                    readonly guardrailUnits: {
                        readonly type: "number";
                        readonly description: "Number of guardrail units consumed";
                    };
                };
                readonly required: ["service", "model"];
                readonly additionalProperties: false;
            };
        };
    };
    readonly required: ["messageId", "sessionId", "agentName", "projectId", "schemaId", "runMode", "sentAt"];
    readonly additionalProperties: false;
};
export type AgentMessagePayload = FromSchema<typeof schema>;
export type AgentStateOutput = NonNullable<AgentMessagePayload['output']>;
export type AgentGenerateStateOutput = Extract<AgentMessagePayload['output'], {
    type: 'generate';
}>;
export type AgentGraphQLStateOutput = Extract<AgentMessagePayload['output'], {
    type: 'graphql';
}>;
export type AgentChatStateOutput = Extract<AgentMessagePayload['output'], {
    type: 'chat';
}>;
export type AgentUnknownStateOutput = Extract<AgentMessagePayload['output'], {
    type: 'unknown';
}>;
export declare const validate: import("ajv").ValidateFunction<{
    usage?: {
        inputTokens?: number | undefined;
        outputTokens?: number | undefined;
        totalTokens?: number | undefined;
        inputTokenDetails?: {
            [x: string]: unknown;
            noCacheTokens?: number | undefined;
            cacheReadTokens?: number | undefined;
            cacheWriteTokens?: number | undefined;
        } | undefined;
        outputTokenDetails?: {
            [x: string]: unknown;
            textTokens?: number | undefined;
            reasoningTokens?: number | undefined;
        } | undefined;
        guardrailUnits?: number | undefined;
        service: string;
        model: string;
    }[] | undefined;
    args?: {
        [x: string]: unknown;
    } | undefined;
    input?: {
        type: "unknown";
        data: unknown;
    } | {
        type: "string";
        content: string;
    } | undefined;
    output?: {
        type: "generate";
        data: unknown;
    } | {
        type: "graphql";
        data: unknown;
    } | {
        type: "chat";
        data: {
            artifact?: {
                [x: string]: unknown;
            } | undefined;
            content: string;
            references: {
                _tid: string;
            }[];
        };
    } | {
        type: "unknown";
        data: unknown;
    } | undefined;
    error?: {
        message?: string | undefined;
        name?: string | undefined;
        code?: string | undefined;
    } | undefined;
    abortedAt?: number | undefined;
    startedAt?: number | undefined;
    finishedAt?: number | undefined;
    span?: {
        createdAt: number;
        name: string;
        traceId: string;
        spanId: string;
    } | undefined;
    feedback?: {
        createdAt?: number | undefined;
        label?: string | undefined;
        score?: number | undefined;
        text?: string | undefined;
        note?: string | undefined;
        updatedBy?: string | undefined;
        name: string;
    } | undefined;
    blocked?: boolean | undefined;
    messageId: string;
    agentName: string;
    projectId: string;
    schemaId: string;
    sessionId: string;
    runMode: "BACKGROUND" | "IMMEDIATE";
    sentAt: number;
}>;
export type AgentChatStateExecuteResult = {
    input: string;
    output: AgentChatStateOutput;
    metadata: {
        agentHistoryUpdate: ModelMessage[] | null;
        usage: AiUsage;
        blocked: boolean;
    };
};
export type AgentGenerateStateExecuteResult = {
    input: string;
    output: AgentGenerateStateOutput;
    metadata: {
        /**
         * The conversation history after this state executed. Populated so run.ts can detect
         * yields (open tool-calls at the end) and save the snapshot needed to resume.
         * Non-null only when the state carries a history (e.g., resuming a yield, or state
         * has client tools that could yield).
         */
        agentHistoryUpdate: ModelMessage[] | null;
        usage: AiUsage;
        blocked: boolean;
    };
};
export type AgentGraphQLStateExecuteResult = {
    input: unknown;
    output: AgentGraphQLStateOutput;
};
export type AgentStateExecuteResult = AgentChatStateExecuteResult | AgentGenerateStateExecuteResult | AgentGraphQLStateExecuteResult;
export type AgentChatStateExecuteResultWithoutMetadata = Omit<AgentChatStateExecuteResult, 'metadata'>;
export type AgentGenerateStateExecuteResultWithoutMetadata = Omit<AgentGenerateStateExecuteResult, 'metadata'>;
export type AgentStateExecuteResultWithoutMetadata = AgentChatStateExecuteResultWithoutMetadata | AgentGenerateStateExecuteResultWithoutMetadata | AgentGraphQLStateExecuteResult;
export type AgentMessageShapePayload<Output = unknown> = Omit<AgentMessagePayload, 'output'> & {
    output: Output;
};
export declare const userSchema: {
    readonly properties: {
        readonly messageId: {
            readonly type: "string";
            readonly description: "ID of the message that was deferred";
        };
        readonly agentName: {
            readonly type: "string";
            readonly description: "Name of the agent this message was created by";
        };
        readonly args: {
            readonly type: "object";
        };
        readonly input: {
            readonly title: "TSAgentMessageInput";
            readonly description: "The input schema for agent messages.";
            readonly discriminator: {
                readonly propertyName: "type";
            };
            readonly oneOf: [{
                readonly title: "TSAgentMessageUnknownInput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "unknown";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentMessageStringInput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "string";
                    };
                    readonly content: {
                        readonly type: "string";
                    };
                };
                readonly required: ["type", "content"];
                readonly additionalProperties: false;
            }];
        };
        readonly output: {
            readonly title: "TSAgentMessageOutput";
            readonly description: "The output schema for agent messages.";
            readonly discriminator: {
                readonly propertyName: "type";
            };
            readonly oneOf: [{
                readonly title: "TSAgentGenerateStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "generate";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentGraphQLStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "graphql";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentChatStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "chat";
                    };
                    readonly data: {
                        readonly type: "object";
                        readonly properties: {
                            readonly content: {
                                readonly type: "string";
                            };
                            readonly artifact: {
                                readonly type: "object";
                            };
                            readonly references: {
                                readonly type: "array";
                                readonly items: {
                                    readonly type: "object";
                                    readonly properties: {
                                        readonly _tid: {
                                            readonly type: "string";
                                        };
                                    };
                                    readonly required: ["_tid"];
                                    readonly additionalProperties: false;
                                };
                            };
                        };
                        readonly required: ["content", "references"];
                        readonly additionalProperties: false;
                    };
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }, {
                readonly title: "TSAgentUnknownStateOutput";
                readonly type: "object";
                readonly properties: {
                    readonly type: {
                        readonly const: "unknown";
                    };
                    readonly data: {};
                };
                readonly required: ["type", "data"];
                readonly additionalProperties: false;
            }];
        };
        readonly error: {
            readonly type: "object";
            readonly properties: {
                readonly message: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly code: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: false;
        };
        readonly runMode: {
            readonly enum: ["BACKGROUND", "IMMEDIATE"];
            readonly description: "Indicates how the agent message was run";
        };
        readonly abortedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was aborted";
        };
        readonly sentAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was sent";
        };
        readonly startedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message started processing";
        };
        readonly finishedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message finished processing";
        };
        readonly span: {
            readonly type: "object";
            readonly description: "The span for the agent run associated with this message";
            readonly properties: {
                readonly traceId: {
                    readonly type: "string";
                };
                readonly spanId: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly createdAt: {
                    readonly type: "number";
                };
            };
            readonly required: ["traceId", "spanId", "name", "createdAt"];
            readonly additionalProperties: false;
        };
        readonly feedback: {
            readonly type: "object";
            readonly properties: {
                readonly name: {
                    readonly type: "string";
                    readonly description: "Name of the feedback, e.g., \"Quality\", \"Relevance\"";
                };
                readonly label: {
                    readonly type: "string";
                    readonly description: "String feedback for the agent message, e.g., \"helpful\", \"not helpful\". If a label is provided, a score must not be provided.";
                };
                readonly score: {
                    readonly type: "number";
                    readonly description: "Numeric feedback for the agent message, typically between 1 and 5. If a score is provided, a label must not be provided.";
                };
                readonly text: {
                    readonly type: "string";
                    readonly description: "Freeform text feedback for the agent message.";
                };
                readonly note: {
                    readonly type: "string";
                    readonly description: "Optional note for the feedback, e.g., \"This was helpful because...\"";
                };
                readonly updatedBy: {
                    readonly type: "string";
                    readonly description: "A string identifying the user who is adding the annotation, such as a name or email address.";
                };
                readonly createdAt: {
                    readonly type: "number";
                    readonly description: "Timestamp when the feedback was created";
                };
            };
            readonly additionalProperties: false;
            readonly required: ["name"];
        };
        readonly blocked: {
            readonly type: "boolean";
            readonly description: "If this message was blocked by a guardrail";
        };
        readonly usage: {
            readonly type: "array";
            readonly description: "Itemized token usage breakdown by service and model";
            readonly items: {
                readonly title: "TSAiUsageItem";
                readonly type: "object";
                readonly description: "Token usage breakdown for a single service and model";
                readonly properties: {
                    readonly service: {
                        readonly type: "string";
                        readonly description: "The AI service provider (e.g., \"openai\", \"anthropic\")";
                    };
                    readonly model: {
                        readonly type: "string";
                        readonly description: "The model identifier (e.g., \"gpt-4\", \"claude-3-opus\")";
                    };
                    readonly inputTokens: {
                        readonly type: "number";
                        readonly description: "Number of input/prompt tokens consumed";
                    };
                    readonly outputTokens: {
                        readonly type: "number";
                        readonly description: "Number of output/completion tokens generated";
                    };
                    readonly totalTokens: {
                        readonly type: "number";
                        readonly description: "Total tokens (input + output)";
                    };
                    readonly inputTokenDetails: {
                        readonly type: "object";
                        readonly description: "Detailed breakdown of input token usage";
                        readonly properties: {
                            readonly noCacheTokens: {
                                readonly type: "number";
                                readonly description: "Tokens not using cache";
                            };
                            readonly cacheReadTokens: {
                                readonly type: "number";
                                readonly description: "Tokens served from cache";
                            };
                            readonly cacheWriteTokens: {
                                readonly type: "number";
                                readonly description: "Tokens written to cache";
                            };
                        };
                    };
                    readonly outputTokenDetails: {
                        readonly type: "object";
                        readonly description: "Detailed breakdown of output token usage";
                        readonly properties: {
                            readonly textTokens: {
                                readonly type: "number";
                                readonly description: "Regular text output tokens";
                            };
                            readonly reasoningTokens: {
                                readonly type: "number";
                                readonly description: "Extended thinking tokens";
                            };
                        };
                    };
                    readonly guardrailUnits: {
                        readonly type: "number";
                        readonly description: "Number of guardrail units consumed";
                    };
                };
                readonly required: ["service", "model"];
                readonly additionalProperties: false;
            };
        };
    };
    readonly type: "object";
    readonly additionalProperties: false;
    readonly required: ["messageId", "sessionId", "agentName", "projectId", "schemaId", "runMode", "sentAt"];
    readonly title: "TSAgentMessage";
};
export declare const shapeSchema: {
    readonly properties: {
        readonly input: {
            readonly '@ref': "TSAgentMessageInput";
        };
        readonly output: {
            readonly '@ref': "TSAgentMessageOutput";
        };
        readonly usage: {
            readonly type: "array";
            readonly description: "Itemized token usage breakdown by service and model";
            readonly items: {
                readonly '@ref': "TSAiUsageItem";
            };
        };
        readonly messageId: {
            readonly type: "string";
            readonly description: "ID of the message that was deferred";
        };
        readonly agentName: {
            readonly type: "string";
            readonly description: "Name of the agent this message was created by";
        };
        readonly args: {
            readonly type: "object";
        };
        readonly error: {
            readonly type: "object";
            readonly properties: {
                readonly message: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly code: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: false;
        };
        readonly runMode: {
            readonly enum: ["BACKGROUND", "IMMEDIATE"];
            readonly description: "Indicates how the agent message was run";
        };
        readonly abortedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was aborted";
        };
        readonly sentAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message was sent";
        };
        readonly startedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message started processing";
        };
        readonly finishedAt: {
            readonly type: "number";
            readonly description: "Timestamp when the message finished processing";
        };
        readonly span: {
            readonly type: "object";
            readonly description: "The span for the agent run associated with this message";
            readonly properties: {
                readonly traceId: {
                    readonly type: "string";
                };
                readonly spanId: {
                    readonly type: "string";
                };
                readonly name: {
                    readonly type: "string";
                };
                readonly createdAt: {
                    readonly type: "number";
                };
            };
            readonly required: ["traceId", "spanId", "name", "createdAt"];
            readonly additionalProperties: false;
        };
        readonly feedback: {
            readonly type: "object";
            readonly properties: {
                readonly name: {
                    readonly type: "string";
                    readonly description: "Name of the feedback, e.g., \"Quality\", \"Relevance\"";
                };
                readonly label: {
                    readonly type: "string";
                    readonly description: "String feedback for the agent message, e.g., \"helpful\", \"not helpful\". If a label is provided, a score must not be provided.";
                };
                readonly score: {
                    readonly type: "number";
                    readonly description: "Numeric feedback for the agent message, typically between 1 and 5. If a score is provided, a label must not be provided.";
                };
                readonly text: {
                    readonly type: "string";
                    readonly description: "Freeform text feedback for the agent message.";
                };
                readonly note: {
                    readonly type: "string";
                    readonly description: "Optional note for the feedback, e.g., \"This was helpful because...\"";
                };
                readonly updatedBy: {
                    readonly type: "string";
                    readonly description: "A string identifying the user who is adding the annotation, such as a name or email address.";
                };
                readonly createdAt: {
                    readonly type: "number";
                    readonly description: "Timestamp when the feedback was created";
                };
            };
            readonly additionalProperties: false;
            readonly required: ["name"];
        };
        readonly blocked: {
            readonly type: "boolean";
            readonly description: "If this message was blocked by a guardrail";
        };
    };
    readonly type: "object";
    readonly additionalProperties: false;
    readonly required: ["messageId", "sessionId", "agentName", "projectId", "schemaId", "runMode", "sentAt"];
    readonly title: "TSAgentMessage";
};
