UNPKG

@promptbook/documents

Version:

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

69 lines (68 loc) 2.69 kB
import type { CreateAgentModelRequirementsOptions } from '../book-2.0/agent-source/CreateAgentModelRequirementsOptions'; import type { ScriptExecutionTools } from '../execution/ScriptExecutionTools'; import type { string_model_name } from '../types/string_model_name'; import type { BookNodeAgentSourceOptions } from './BookNodeAgentSource'; /** * Options for constructing one `LiteAgent`. * * `LiteAgent` is intentionally smaller than the CLI harnesses. It runs the Book through the * OpenAI Agents SDK directly, while keeping Promptbook tool definitions and hosted knowledge * whenever those features fit inside the lighter runtime. * * @public exported from `@promptbook/node` */ export type LiteAgentOptions = BookNodeAgentSourceOptions & { readonly apiKey?: string; readonly baseURL?: string; readonly createAgentModelRequirementsOptions?: CreateAgentModelRequirementsOptions; readonly isVerbose?: boolean; readonly maxRequestsPerMinute?: number; readonly modelName?: string_model_name; readonly organization?: string; readonly project?: string; readonly scriptExecutionTools?: ScriptExecutionTools | ReadonlyArray<ScriptExecutionTools>; readonly userId?: string; }; /** * Per-run options for `LiteAgent`. * * @public exported from `@promptbook/node` */ export type LiteAgentRunOptions = { readonly context?: string; readonly signal?: AbortSignal; }; /** * Lightweight Node.js wrapper around the OpenAI Agents SDK for Promptbook Books. * * This path is intentionally simpler than `ptbk agent exec`: it prepares one SDK agent in-process * and reuses it across calls, which keeps JavaScript integration small while still honoring the * compiled Promptbook system message, prompt suffix, tools, and hosted knowledge when supported. * * @public exported from `@promptbook/node` */ export declare class LiteAgent { private readonly options; private preparedAgentPromise; constructor(options: LiteAgentOptions); /** * Runs one user message through the prepared OpenAI Agents SDK agent. * * @param message - User message sent to the agent. * @param options - Optional context and cancellation signal. * @returns Final text returned by the SDK agent. */ run(message: string, options?: LiteAgentRunOptions): Promise<string>; /** * Lazily prepares and caches the underlying OpenAI Agents SDK runtime. * * @private internal utility of `LiteAgent` */ private prepareAgent; /** * Builds the in-process OpenAI Agents SDK runtime from the Book source. * * @private internal utility of `LiteAgent` */ private createPreparedAgent; }