Skip to content

AI, HTTP & Tools

MethodSignatureDescription
g.http.makeHttpRequest(options) → Promise<HttpResponse>Make an HTTP request

HttpRequestOptions:

{
url: string // required
method?: string // "GET" (default), "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"
body?: string
headers?: Record<string, string>
timeout?: number // milliseconds
}

HttpResponse:

{
status: number
statusText: string
body: string
headers: Record<string, string>
}

Requires an LLM provider to be configured.

MethodSignatureDescription
g.llm.promptLocalLlm(model, prompt, options?) → Promise<string>Send a prompt to the configured LLM
g.llm.abortLocalLlm()Cancel an in-progress LLM request
g.llm.getLocalLlmModels() → Promise<OllamaModelInfo[]>List available models

OllamaOptions:

{
timeout?: number // milliseconds
image?: string // base64-encoded image for vision models
}

See Secrets for full details.

MethodSignatureDescription
g.secrets.getSecret(secretName) → Promise<string>Get a decrypted secret value

OcrOptions (for g.page.ocr):

{
x?: number
y?: number
width?: number
height?: number
lang?: string // default: "eng"
browserTabId?: string
}

MethodSignatureDescription
g.log(message) → voidWrite to the Console pane
g.wait(milliseconds?) → PromiseSleep for a duration
g.generateApiDocs(outputDirectory?) → stringGenerate scripting-api.d.ts

g.generateApiDocs() is an advanced TypeScript-only helper. For the full scripting support bundle, use Tools > Developer > Generate Scripting Support Files… to generate TypeScript definitions, Lua and Janet guides, workspace LLM instructions, and TypeScript authoring scaffold files.


Available when a script is invoked as a custom MCP tool.

PropertyTypeDescription
g.tool.argsany | nullParameters passed by the AI agent (null if not invoked as a tool)


These are top-level globals available in both JavaScript and Lua engines — not under g.*.

WHATWG URL API backed by System.Uri. In JS use new URL(...), in Lua use URL(...) (returns a table).

URL properties: href, origin, protocol, hostname, host, port, pathname, search, hash, username, password, searchParams

const url = new URL("https://example.com/path?q=hello&page=2");
const q = url.searchParams.get("q"); // "hello"
g.log(url.hostname); // "example.com"
g.log(url.pathname); // "/path"
// Relative URL resolution
const api = new URL("/api/data", "https://example.com");
g.log(api.href); // "https://example.com/api/data"

Base64 encode and decode (UTF-8).

const encoded = btoa("Hello, World!"); // "SGVsbG8sIFdvcmxkIQ=="
const decoded = atob(encoded); // "Hello, World!"

Generate a UUID v4 string.

const id = crypto.randomUUID(); // "3b241101-e2bb-4d7a-8613-e9a3fdc1e2b3"


Windows Speech Synthesis. Always available (not workspace-scoped).

MethodSignatureAsyncDescription
speak(text, options?) → PromiseYesSpeak text aloud
getVoices() → string[]NoList available voice names
stop()NoStop current speech

SpeakOptions:

{
voice?: string // e.g., "Microsoft David"
rate?: number // -10 to 10, default 0
}


The local Whisper STT engine allows scripts to listen for user voice commands or transcribe audio files. All processing happens locally on your CPU.

MethodSignatureAsyncDescription
listen(ms) → Promise<string>YesRecord audio from the selected microphone for a duration (in milliseconds) and return the transcribed text.
transcribeFile(path) → Promise<string>YesRead an existing .wav file from disk and return its transcribed text.
async function main() {
g.log("Listening for 5 seconds...");
try {
const text = await g.stt.listen(5000);
g.log("You said: " + text);
if (text.toLowerCase().includes("hello")) {
g.log("Hello to you too!");
}
} catch (e) {
g.log("STT Error: " + e.message);
}
}