UNPKG

@promptbook/utils

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

100 lines (99 loc) 3.87 kB
import type { Tool as AgentKitTool } from '@openai/agents'; import type { ToolCallProgressUpdate } from '../../commitments/_common/toolRuntimeContext'; import type { ModelRequirements } from '../../types/ModelRequirements'; import type { ToolCall, ToolCallLogEntry, ToolCallState } from '../../types/ToolCall'; import type { OpenAiAgentKitExecutionToolsOptions } from './OpenAiAgentKitExecutionToolsOptions'; /** * Builds AgentKit tools and tracks their execution state. * * @private helper of `OpenAiAgentKitExecutionTools` */ export declare class OpenAiAgentKitExecutionToolsToolBuilder { private readonly context; private readonly agentKitToolResultsByCallId; private readonly agentKitToolSnapshotsByCallId; constructor(context: { readonly options: OpenAiAgentKitExecutionToolsOptions; readonly agentKitModelName: string; }); /** * Clears per-run tool state before a new AgentKit stream starts. */ clearRunState(): void; /** * Stores one latest tool-call snapshot keyed by AgentKit call id. */ storeToolSnapshot(callId: string | undefined, toolCall: ToolCall): void; /** * Returns one latest tool-call snapshot keyed by AgentKit call id. */ getToolSnapshot(callId: string | undefined): ToolCall | undefined; /** * Deletes one latest tool-call snapshot keyed by AgentKit call id. */ deleteToolSnapshot(callId: string | undefined): void; /** * Builds the tool list for AgentKit, including hosted file search when applicable. */ buildAgentKitTools(options: { readonly tools?: ModelRequirements['tools']; readonly vectorStoreId?: string; }): Array<AgentKitTool>; /** * Resolves the stored Promptbook tool result for one AgentKit tool call. */ resolveAgentKitToolOutputResult(callId: string | undefined, output: unknown): ToolCall['result']; /** * Creates one structured log entry for streamed tool-call updates. */ static createToolCallLogEntry(options: { readonly kind: string; readonly title: string; readonly message: string; readonly level?: ToolCallLogEntry['level']; readonly payload?: unknown; }): ToolCallLogEntry; /** * Appends one incremental progress update to the currently tracked tool-call snapshot. */ static applyToolCallProgressUpdate(toolCall: ToolCall, update: ToolCallProgressUpdate): ToolCall; /** * Resolves the final lifecycle state for one AgentKit tool call after execution ends. */ static resolveFinalToolCallState(options: { readonly currentState: ToolCallState | undefined; readonly errors: ReadonlyArray<unknown> | undefined; }): ToolCallState; /** * Returns true when one tool definition represents the dedicated DeepSearch capability. */ private isDeepSearchToolDefinition; /** * Normalizes Promptbook JSON-schema tool parameters for AgentKit function tools. */ private normalizeAgentKitToolParameters; /** * Creates the native Agent SDK tool used for `USE DEEPSEARCH`. */ private createDeepSearchAgentKitTool; /** * Creates instructions for the nested DeepSearch specialist agent. */ private createDeepSearchAgentInstructions; /** * Builds the nested DeepSearch prompt from structured tool arguments. */ private buildDeepSearchToolInput; /** * Resolves the configured script tools for tool execution. */ private resolveScriptTools; /** * Resolves the assistant-visible AgentKit tool response while preserving structured tool result data. */ private resolveAgentKitToolResponse; /** * Normalizes AgentKit tool outputs into a string for Promptbook tool call results. */ private formatAgentKitToolOutput; }