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
GenerateContentRequest
Properties
HttpErrorRespond
An HTTP error capture pasted whole: status + the wire error body.
Properties
ScriptedEntryStatus
One queued entry, beside whether it has already answered a call.
Properties
| Property | Type |
|---|---|
consumed | boolean |
entry | ScriptEntry |
ScriptEntry
Properties
| Property | Type | Description |
|---|---|---|
match? | ScriptMatcher | Absent ⇒ unconditional next-in-queue. |
respond | ScriptRespond | - |
ScriptingEntry
A script entry as authored: broker entries plus the HTTP-capture error form.
Properties
| Property | Type |
|---|---|
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
| Parameter | Type |
|---|---|
ai | AI |
Returns
clearScripts()
function clearScripts(ai: AI): void;
Empty the scripted engine’s entry queue. A later call matches nothing until entries are pushed again.
Parameters
| Parameter | Type |
|---|---|
ai | AI |
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
| Parameter | Type |
|---|---|
envelopes | WireResponse[] |
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
| Parameter | Type |
|---|---|
req | GenerateContentRequest |
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
| Parameter | Type |
|---|---|
ai | AI |
entries | ScriptingEntry[] |
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
| Parameter | Type |
|---|---|
ai | AI |
Returns
readonly ScriptedEntryStatus[]