import * as smoltalk from "smoltalk"; import { UserContentInput } from "smoltalk"; import type { Run } from "./asyncContext.js"; import { type ProviderUsageKind } from "./invocationUsage.js"; import type { RetryConfig } from "./llmRetry.js"; import { armCallTimeout, runWithRetry } from "./llmDispatch.js"; import type { SourceLocationOpts } from "./state/checkpointStore.js"; import { dropNullDefaultedArgs } from "./toolInvocation.js"; import { MessageThread } from "./state/messageThread.js"; export type Tool = { name: string; description?: string; schema: any; }; /** Result of `_runPrompt`. Callback bodies cannot raise interrupts * (typechecker-enforced), so the result is always plain data — the LLM * hooks (onLLMCallStart, onLLMCallEnd) fire as side effects only. */ export type RunPromptResult = { messages: MessageThread; toolCalls: smoltalk.ToolCallJSON[]; /** Why this round ended, normalized by smoltalk across providers. */ stopReason?: smoltalk.StopReason; /** How the round was booked: a text model's completion, or a decision * model's answer. Set by `_runPrompt`; a direct-return path may omit it. */ usageKind?: ProviderUsageKind; }; /** Flatten a prompt (a string, or an array of text/attachment parts) to plain * text for consumers that require a string — e.g. memory recall and log * previews. Attachments are dropped. Statelog does NOT use this: it keeps the * structured prompt, redacted (see `redactMessagesForLog`). */ export declare function promptText(p: string | UserContentInput): string; /** Test-only surface for the pure tool-result-cap helpers. Not part of * the supported runtime API. */ /** For prompt.test.ts. */ export declare const _internal: { armCallTimeout: typeof armCallTimeout; runWithRetry: typeof runWithRetry; dropNullDefaultedArgs: typeof dropNullDefaultedArgs; }; type RunPromptArgs = { prompt: string | UserContentInput; messages: MessageThread; responseFormat?: any; /** Provider-shaped config (model/temperature/...). Retry fields may also * appear here when the Agency-source `llm()` codegen passes through a * user-written options object verbatim; they are extracted below and * stripped before the config is forwarded to the LLM client. Direct TS * callers (e.g. `agency.llm`) should use the dedicated `retryConfig` * parameter instead. */ clientConfig: Partial & RetryConfig & { tools?: any[]; }; /** Per-call resilience policy. Takes precedence over any retry fields * piggybacked on `clientConfig`. */ retryConfig?: RetryConfig; maxToolCallRounds?: number; removedTools?: string[]; /** The CALLING function's locals object, threaded in by the `llm()` codegen * as `destructiveSink: __activation` (the function's own `__self`, under * the name a block argument does not shadow). The codegen passes the whole * object, but * runPrompt only ever writes ONE key on it, `__destructiveRan`, so the type * narrows to exactly that field. When a tool does destructive work, * decision 8 sets `destructiveSink.__destructiveRan = true`, and the * caller's exit stamp reads it back. Passed by reference — the same * by-reference trick `removedTools` uses. Absent for direct TS callers * (e.g. `agency.llm`), so the mark is a no-op there. */ destructiveSink?: { __destructiveRan?: boolean; }; /** Zod schema for the saveDraft tool's `value` param, threaded by the * llm() codegen from the enclosing def's declared return type. * Consulted only when the tools array contains the stdlib saveDraft * (see intrinsicTools.ts). */ draftSchema?: unknown; checkpointInfo?: SourceLocationOpts; }; export declare function runPrompt(run: Run, args: RunPromptArgs): Promise; export {};