Navigate

API reference

pyric/ai/scripting

14 published symbols from pyric

Generated from the TypeScript declarations shipped at this import path.

Interfaces

AiEngineStatus

What a status read reports about the resolved engine: the mode it is running in, the model and upstream it answers through when it has one, and whether a key is configured. Never the key itself, its prefix, or its length.

Properties

PropertyType
engineEngineKind
keyPresentboolean
model?string
upstream?string

GenerateContentRequest

Properties

PropertyTypeDescription
contentsWireContent[]-
generationConfig?{ frequencyPenalty?: number; maxOutputTokens?: number; presencePenalty?: number; responseMimeType?: string; responseSchema?: Record<string, unknown>; stopSequences?: string[]; temperature?: number; thinkingConfig?: { includeThoughts?: boolean; thinkingBudget?: number; thinkingLevel?: string; }; topK?: number; topP?: number; }-
generationConfig.frequencyPenalty?number-
generationConfig.maxOutputTokens?number-
generationConfig.presencePenalty?number-
generationConfig.responseMimeType?string-
generationConfig.responseSchema?Record<string, unknown>-
generationConfig.stopSequences?string[]-
generationConfig.temperature?number-
generationConfig.thinkingConfig?{ includeThoughts?: boolean; thinkingBudget?: number; thinkingLevel?: string; }Gemini 2.5+ thinking-budget config; no OpenAI-compat equivalent (dropped by the openai engine).
generationConfig.thinkingConfig.includeThoughts?boolean-
generationConfig.thinkingConfig.thinkingBudget?number-
generationConfig.thinkingConfig.thinkingLevel?string-
generationConfig.topK?number-
generationConfig.topP?number-
systemInstruction?{ parts: WirePart[]; role?: string; }-
systemInstruction.partsWirePart[]-
systemInstruction.role?string-
toolConfig?{ functionCallingConfig?: { allowedFunctionNames?: string[]; mode?: "NONE" | "AUTO" | "ANY"; }; }-
toolConfig.functionCallingConfig?{ allowedFunctionNames?: string[]; mode?: "NONE" | "AUTO" | "ANY"; }-
toolConfig.functionCallingConfig.allowedFunctionNames?string[]-
toolConfig.functionCallingConfig.mode?"NONE" | "AUTO" | "ANY"-
tools?{ functionDeclarations?: { description?: string; name: string; parameters?: Record<string, unknown>; }[]; }[]-

HttpErrorRespond

An HTTP error capture pasted whole: status + the wire error body.

Properties

PropertyType
error{ body: { error: { code?: number; details?: Record<string, unknown>[]; message?: string; status?: string; }; }; httpStatus: number; }
error.body{ error: { code?: number; details?: Record<string, unknown>[]; message?: string; status?: string; }; }
error.body.error{ code?: number; details?: Record<string, unknown>[]; message?: string; status?: string; }
error.body.error.code?number
error.body.error.details?Record<string, unknown>[]
error.body.error.message?string
error.body.error.status?string
error.httpStatusnumber

ScriptedEntryStatus

One queued entry, beside whether it has already answered a call.

Properties

PropertyType
consumedboolean
entryScriptEntry

ScriptEntry

Properties

PropertyTypeDescription
match?ScriptMatcherAbsent ⇒ unconditional next-in-queue.
respondScriptRespond-

ScriptingEntry

A script entry as authored: broker entries plus the HTTP-capture error form.

Properties

PropertyType
match?ScriptMatcher
respond| HttpErrorRespond | ScriptRespond

Type Aliases

ScriptMatcher

type ScriptMatcher =
  | string
  | RegExp
  | (req: GenerateContentRequest, model?: string) => boolean;

Matcher: substring / regex against the last user turn text, or a predicate on the request. The predicate also receives the requested model, so a matcher can select on the model a call names as well as its text.


ScriptRespond

type ScriptRespond = ScriptShorthand | RawEnvelope;

Functions

aiStatus()

function aiStatus(ai: AI): AiEngineStatus;

The resolved answer engine’s mode, model, upstream, and whether a key is configured. Never the key itself. Works for whichever engine is configured, not only the scripted one, so a sandbox running the gemini production-passthrough engine still reports through this call; script, clearScripts, and scripts are what stay scoped to the scripted engine.

Parameters

ParameterType
aiAI

Returns

AiEngineStatus


clearScripts()

function clearScripts(ai: AI): void;

Empty the scripted engine’s entry queue. A later call matches nothing until entries are pushed again.

Parameters

ParameterType
aiAI

Returns

void


encodeSse()

function encodeSse(envelopes: WireResponse[]): string;

Encode complete response envelopes as the captured SSE framing bytes: every event is data: <complete JSON>, events separated by CRLF CRLF (ai-generate-stream-framing: allEventsDataPrefixed, separatorIsCrlfCrlf).

Parameters

ParameterType
envelopesWireResponse[]

Returns

string


lastUserText()

function lastUserText(req: GenerateContentRequest): string;

Text of the last user turn — what string/regex matchers run against. A function response turn rides under role user too (#1410); it carries a tool result, not a prompt, so it is skipped.

Parameters

ParameterType
reqGenerateContentRequest

Returns

string


script()

function script(ai: AI, entries: ScriptingEntry[]): void;

Append entries to the scripted engine behind a sandbox AI handle. Entries are consumed at most once, first unconsumed match wins, matcher-less entries are unconditional FIFO (broker semantics).

Parameters

ParameterType
aiAI
entriesScriptingEntry[]

Returns

void


scripts()

function scripts(ai: AI): readonly ScriptedEntryStatus[];

The scripted engine’s queued entries, each beside whether it has already answered a call.

Parameters

ParameterType
aiAI

Returns

readonly ScriptedEntryStatus[]