import type { ChatFinishReason } from "../../chat/protocol.js"; import type { ChatSystemMessage, ChatUiMessage, ChatUiMessageChunk, MessageMetadata } from "../../chat/types.js"; import type { AgentRuntimeMessage } from "../runtime/message-adapter.js"; import type { ConversationRunEvent } from "../conversation/run-events.js"; import type { RuntimeClientProfile } from "../runtime/client-profile.js"; import type { ToolExposureCheckpoint } from "../runtime/tool-exposure.js"; import type { RuntimeSkillDefinition } from "../runtime/skill-metadata.js"; import type { ResolvedSkillSelectorPolicy } from "../../skill/selector.js"; /** Public API contract for hosted chat runtime finish part. */ export type HostedChatRuntimeFinishPart = { type: "finish"; finishReason: ChatFinishReason; rawFinishReason?: string; totalUsage: { inputTokens?: number; outputTokens?: number; totalTokens?: number; reasoningTokens?: number; cachedInputTokens?: number; inputTokenDetails?: { noCacheTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; }; outputTokenDetails?: { textTokens?: number; reasoningTokens?: number; }; billableInputTokens?: number; billableOutputTokens?: number; costUsd?: number; providerInputCostUsd?: number; providerOutputCostUsd?: number; providerCostUsd?: number; veryfrontInputChargeUsd?: number; veryfrontOutputChargeUsd?: number; veryfrontChargeUsd?: number; veryfrontBilledUsd?: number; costCredits?: number; costSource?: "gateway" | "missing" | "partial"; billingMode?: "direct" | "deferred"; usageCaptureStatus?: "complete" | "partial" | "missing"; }; }; /** Event emitted for hosted chat runtime on finish. */ export type HostedChatRuntimeOnFinishEvent = { messages: Array>; isContinuation: boolean; responseMessage: ChatUiMessage; isAborted: boolean; finishReason: ChatFinishReason; }; /** Options accepted by hosted chat runtime to UI message stream. */ export type HostedChatRuntimeToUiMessageStreamOptions = { sendReasoning?: boolean; originalMessages?: Array>; generateMessageId?: () => string; onError?: (error: unknown) => string; onFinish?: (event: HostedChatRuntimeOnFinishEvent) => void | Promise; messageMetadata?: (input: { part: HostedChatRuntimeFinishPart; }) => TMessageMetadata | undefined; }; /** Input payload for hosted chat runtime stream. */ export type HostedChatRuntimeStreamInput = { messages: AgentRuntimeMessage[]; abortSignal: AbortSignal; }; /** Result returned from hosted chat runtime stream. */ export type HostedChatRuntimeStreamResult = { steps: PromiseLike; toUIMessageStream: (options?: HostedChatRuntimeToUiMessageStreamOptions) => AsyncIterable>; }; /** Public API contract for hosted chat runtime agent. */ export type HostedChatRuntimeAgent = { stream: (input: HostedChatRuntimeStreamInput) => Promise>; }; /** Result returned from hosted chat runtime creation. */ export type HostedChatRuntimeCreationResult = { runtimeKind: "framework"; agent: HostedChatRuntimeAgent; modelId: string; cleanup: () => Promise; }; /** Public API contract for hosted chat runtime project steering. */ export type HostedChatRuntimeProjectSteering = { agent: TRuntimeAgentDefinition; skillSelectorPolicy?: ResolvedSkillSelectorPolicy; environmentContext?: string; initialProjectInstructions?: string; initialSkills?: RuntimeSkillDefinition[]; }; /** Submitted form_input result carried across hosted runtime continuations. */ export type HostedSubmittedFormInputResult = { values: Record; inputRequestId: string; }; /** Runtime target kind carried by hosted project-agent runs. */ export type HostedChatRuntimeTargetKind = "main_branch" | "environment" | "preview_branch"; /** Options accepted by hosted chat runtime creation. */ export type HostedChatRuntimeCreationOptions = { projectId: string | null; projectSlug?: string; branchId?: string | null; runtimeTargetKind?: HostedChatRuntimeTargetKind | null; runtimeTargetEnvironmentId?: string | null; authToken: string; instructions: string | ChatSystemMessage[]; runId?: string; agentId?: string; model?: string; temperature?: number; maxSteps?: number; maxOutputTokens?: number; allowedTools?: string[]; /** * Tool names the agent configuration denied explicitly (`false` entries). * They must never be re-added by runtime-essential tool preservation. */ deniedTools?: string[]; /** * Integration tools the control plane resolved for this run. Verified before * it reaches here, and used only to widen the Veryfront API MCP allowlist. */ serverResolvedIntegrationToolNames?: readonly string[]; /** Provider-native selection kept separate from local and MCP tool bindings. */ allowedProviderTools?: string[]; /** * Marks `allowedTools` as config-derived (no request-level override): * skill runtime infrastructure is preserved for empty selectors and skill * delegation stays available for empty and non-empty configured sets. */ includeRuntimeEssentialToolsWhenEmpty?: boolean; allowDelegation?: boolean; thinking?: TThinkingConfig; conversationId?: string; parentRunId?: string; parentMessageId?: string; availableSkillIds?: string[]; skillSelectorPolicy?: ResolvedSkillSelectorPolicy; /** Per-run skill id -> discovered SKILL.md source path (owner-aware catalog). */ skillSourcePaths?: Readonly>; publishParentRunEvents?: (events: ConversationRunEvent[]) => Promise; clientProfile?: RuntimeClientProfile | null; liveProjectSteering?: HostedChatRuntimeProjectSteering; submittedFormInputResult?: HostedSubmittedFormInputResult; /** @internal Latest private checkpoint loaded from trusted run state. */ serverResolvedToolExposureCheckpoint?: ToolExposureCheckpoint; /** @internal Persists private checkpoint state outside model messages. */ persistToolExposureCheckpoint?: (checkpoint: ToolExposureCheckpoint) => void | Promise; /** @internal Fail closed when a trusted hosted durable run cannot persist exposure state. */ requireToolExposureCheckpointPersistence?: true; }; //# sourceMappingURL=chat-runtime-contract.d.ts.map