Pyric
Navigate

API reference

pyric/ai/scripting

7 published symbols from pyric

Generated from the TypeScript declarations shipped at this import path.

Interfaces

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

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) => boolean;

Matcher: substring / regex against the last user turn text, or a predicate on the request.


ScriptRespond

type ScriptRespond = ScriptShorthand | RawEnvelope;

Functions

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


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