@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
87 lines (86 loc) • 3.75 kB
TypeScript
import type OpenAI from 'openai';
import type { ToolCallProgressUpdate } from '../../../commitments/_common/toolRuntimeContext';
import type { serializeError } from '../../../errors/utils/serializeError';
import type { ChatPromptResult } from '../../../execution/PromptResult';
import type { Usage } from '../../../execution/Usage';
import type { string_model_name } from '../../../types/string_model_name';
import type { string_date_iso8601 } from '../../../types/string_token';
import type { TODO_any } from '../../../utils/organization/TODO_any';
/**
* Type describing streamed tool call.
*/
type StreamedToolCall = NonNullable<ChatPromptResult['toolCalls']>[number];
/**
* Builds incremental chat progress updates, tool-call snapshots, and the final prompt result.
*
* @private helper of `callOpenAiCompatibleChatModel`
*/
export declare class OpenAiCompatibleChatProgressReporter {
/**
* Creates an empty usage accumulator for multi-turn chat requests.
*/
createEmptyUsage(): Usage;
/**
* Creates the initial pending snapshot for one chat tool call.
*/
createPendingToolCall(options: {
readonly toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall;
readonly functionName: string;
readonly functionArguments: TODO_any;
readonly calledAt: string_date_iso8601;
}): StreamedToolCall;
/**
* Appends one incremental progress update to the currently tracked tool-call snapshot.
*/
applyToolCallProgressUpdate(toolCall: StreamedToolCall, update: ToolCallProgressUpdate): StreamedToolCall;
/**
* Finalizes one chat tool-call snapshot after execution ends.
*/
createCompletedToolCall(options: {
readonly toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall;
readonly functionName: string;
readonly calledAt: string_date_iso8601;
readonly currentToolCallSnapshot: StreamedToolCall;
readonly toolResult: TODO_any;
readonly errors: Array<ReturnType<typeof serializeError>> | undefined;
}): StreamedToolCall;
/**
* Emits one chat progress chunk with shared timing, request metadata, and tool-call snapshots.
*/
emitProgress(options: {
readonly start: string_date_iso8601;
readonly complete?: string_date_iso8601;
readonly rawPromptContent: string;
readonly onProgress: (chunk: ChatPromptResult) => void;
readonly content: string;
readonly modelName: string;
readonly usage: Usage;
readonly rawRequest: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming;
readonly rawResponse: OpenAI.Chat.Completions.ChatCompletion;
readonly toolCalls?: ChatPromptResult['toolCalls'];
}): void;
/**
* Creates the final chat prompt result after the tool loop has finished.
*/
createChatPromptResult(options: {
readonly title: string;
readonly responseMessage: OpenAI.Chat.Completions.ChatCompletionMessage;
readonly rawPromptContent: string;
readonly rawRequest: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming;
readonly rawResponse: OpenAI.Chat.Completions.ChatCompletion;
readonly modelName: string_model_name;
readonly start: string_date_iso8601;
readonly complete: string_date_iso8601;
readonly usage: Usage;
readonly toolCalls: Array<StreamedToolCall>;
}): ChatPromptResult;
/**
* Creates one structured log entry for streamed tool-call updates.
*/
private createToolCallLogEntry;
/**
* Resolves the final lifecycle state for one tool call after execution ends.
*/
private resolveFinalToolCallState;
}
export {};