import { ApplicationFailure, activityInfo, heartbeat as temporalHeartbeat, sleep as temporalSleep, Info } from "@temporalio/activity"; import { Logger } from "@temporalio/common"; export { activityInfo as functionInfo }; /** * FunctionFailure represents an application-specific failure in a function. * * @param message - The error message describing the failure * @param details - Optional additional details about the failure * @returns An ApplicationFailure instance */ export declare const FunctionFailure: typeof ApplicationFailure; /** * Log a message from within a function. */ export declare const log: Logger; /** * Send a heartbeat from a long-running function. * * @param details - Optional details to include with the heartbeat */ export declare const heartbeat: typeof temporalHeartbeat; /** * Pause the execution of a function for a specified duration. * * @param duration - The duration to sleep in milliseconds */ export declare const sleep: typeof temporalSleep; /** * Get information about the current workflow run. * * @returns An Info object containing details about the current workflow */ export declare function currentWorkflow(): Info; /** * Send an MCP-compliant progress information. * @param progress - Current progress value (must increase with each call) * @param total - Total progress value if known * @param message - Human-readable progress message * @returns True if the progress information was sent successfully, false otherwise * * @example * ```typescript * // Basic progress * mcpProgress(25, 100, "Loading data"); * ``` */ export declare function mcpProgress(progress: number, total?: number, message?: string): boolean; /** * Stream data to Restack Engine WebSocket API endpoint. * * This function streams data to the Restack Engine and returns a comprehensive result * with collected events, concatenated text, and metadata. It handles both simple text * extraction and full response aggregation in a single, robust implementation. * * @param apiAddress - The address of the Restack Engine API. * @param data - The streamed data from an OpenAI-compatible API or a JSON object. * @returns A promise that resolves with an object containing: * - events: Array of all collected events (raw chunks) * - text: Concatenated text content from delta events * - eventCount: Number of events collected * - finalResponse: Complete aggregated response (if available) * - responseId: Response ID if available * - usage: Usage statistics if available * - hasCompletion: Whether a completion event was received * * @example * ```typescript * import OpenAI from 'openai'; * * const client = new OpenAI(); * * // Stream a response * const stream = await client.responses.create({ * model: "gpt-4o", * input: "Hello, how are you?", * stream: true * }); * * // Stream to websocket and get comprehensive result * const result = await streamToWebsocket({ data: stream }); * * // Access the concatenated text * console.log(result.text); * * // Access the complete reconstructed response * if (result.finalResponse) { * console.log(`Complete response: ${JSON.stringify(result.finalResponse)}`); * } * * // Access metadata * console.log(`Response ID: ${result.responseId}`); * console.log(`Usage: ${JSON.stringify(result.usage)}`); * ``` */ export declare function streamToWebsocket({ apiAddress, data, }: { apiAddress?: string; data: any; }): Promise<{ events: any[]; text: string; eventCount: number; finalResponse?: any; responseId?: string; usage?: any; hasCompletion: boolean; }>;