gizai:agent/code
The agent's code mode: one tool call runs a JavaScript program the model wrote, which calls the thread's other tools as async functions (tools.NAME(input)) and returns one value. Many reads and joins cost the model one round instead of one each, which is what lets a small model finish a long job. The console runs the code with code/runner.js on the VM (vm/, no JIT), isolated from the machine (no file outside its folder, no network, no new machine code) and under memory, CPU and time limits. Each tool call comes back over the runner's pipes and runs here under the one Policy (the caller's).
import * as Code from "gizai:agent/code";Types
Engine
type Engine = { sys: System; cli: string; toolchain: Vec<string>; vm: string; home: string; }Where code runs: the host's CLI and the toolchain environment it builds with (apps.giz Fleet), the package's sources (the VM entry package) and a folder of the host's own to keep the built runner in.
sys:gizlang_system.Systemcli:stringtoolchain:Vec<string>vm:stringhome:string
Ran
type Ran = { ok: bool; value: string; log: string; calls: i64; }How a run ended: its value as JSON, or why it failed; what it printed; how many tool calls it made.
ok:boolvalue:stringlog:stringcalls:i64
Call
type Call = (name: string, input: string) => AnswerA tool the code called, by name with its input as JSON text: whether it succeeded and what it said.
Answer
type Answer = { ok: bool; text: string; }A tool's answer: whether it succeeded and its text.
ok:booltext:string
Functions
warm
function warm(e: Engine): voidBuilds the runner ahead of the first run (the host starts it): the first build of the VM takes minutes on a host whose build store lacks its units, longer than a turn waits. It builds again even when the runner is there: its name does not say which VM it holds, and a deploy that changes the VM restarts the host (cached units: seconds).
Effects: fail, read, write, io.
run
function run(e: Engine, code: string, call: Call): RanRuns code with its tool calls answered by call: its value, log and call count, or why it did not run.
Effects: fail, read, write, console, io.
Constants
MOST_MS
const MOST_MS = 120000One run's whole time, its tool calls included.
MOST_CALLS
const MOST_CALLS = 100The most tool calls one run makes.
MOST_CODE
const MOST_CODE = 20000The most characters of code, of its value and of what it printed.