Expand description
AI-node execution support: exposing bound adapters to a model as callable tools, dispatching the model’s tool calls back to those adapters, and resolving image references for vision calls.
This is the in-node tool-use path - distinct from whole-flow agentic
generation. The model emits tool calls, AdapterToolDispatcher runs each
through the existing adapter (so the fs/shell sandboxes apply unchanged),
and the result is fed back to the model.
Structs§
- Adapter
Tool Dispatcher - Runs a model tool call by mapping
"{adapter}__{actionId}"back to an adapter action: it synthesizes a node from the model’s args (plus the AI node’s workspace asworkspaceRoot/cwd) and executes it through the bound adapter, so all existing sandboxing/policy applies. - Proposed
Edit - A single filesystem change the agent proposed during a turn, computed but
not applied. The IDE renders each as a diff (
before→after) the user accepts or rejects. - Staging
State - Net staged edits for one agent turn: the per-path result plus first-touch order, so the IDE shows one stable diff per file.
- Staging
Tool Dispatcher - Tool dispatcher for a coding-agent turn: filesystem mutations
(
fswrite-file/edit-file/delete-file) are staged into a buffer instead of written to disk, so the turn can be reviewed before it lands. Everything else -fsreads,glob/grep/list-dir, and everyshelltool - runs for real throughAdapterToolDispatcher. Aread-fileof a staged path is served from the overlay, so the model sees its own pending edits within the same turn. - Tool
Observer - Observes each model tool call so the dispatcher can emit an
ExecutionEvent::ToolCalljust before the tool runs - giving the UI live per-tool-call granularity during an AI node’s tool loop (the dispatcher otherwise emits nothing per call). Cheap to clone (anArc+ two ids).
Constants§
- DEFAULT_
TOOL_ ITERATIONS - Default cap on the in-node tool-use loop (how many times the model may call
tools before the run gives up). Overridable per node via
maxToolIters(ai_max_tool_iters).
Functions§
- ai_
expect - The node’s natural-language output expectation (
expectfield) for per-node AI evaluation (roadmap E1). When set, the generate path self-evaluates the output against it and fails the node - engaging the monitor/fix flow - if unmet.Nonewhen unset/blank. - ai_
labels - Classification labels (trimmed, non-empty) from the node’s
labelsarray. - ai_
max_ tool_ iters - Per-node cap on the in-node tool-use loop, read from the node’s
maxToolItersfield; falls back toDEFAULT_TOOL_ITERATIONS. Clamped to at least 1 so a0can’t silently disable tool use. - ai_
output_ schema - The structured-output JSON schema (raw text) from the node’s
outputSchemafield, used by the"structured"task. Stored as a string so it round-trips through the DSL; the model is prompted to produce JSON matching it.Nonewhen unset or blank. - ai_
reasoning - Per-request reasoning toggle from the node’s
thinkingflag. - ai_task
- The AI node’s dispatch task:
"generate"(default),"embedding", or"classify". The inspector stamps it from the bound model’s capability / whether labels are set. - ai_
tool_ adapters - Adapter names the node exposes to the model as tools (its
toolsarray). - build_
tool_ specs - Build model tool specs from the descriptors of the bound adapters. Each
adapter action becomes one tool
"{adapter}__{actionId}"; its required + optional fields become JSON-schema properties. - match_
label - Pick the label the model’s output best corresponds to: an exact (case-insensitive) match first, then a label contained in the output, else the first label as a safe default.
- parse_
json_ lenient - Best-effort parse of a model’s text into a JSON value: a direct parse first,
else the substring between the first
{and last}- tolerates markdown fences or surrounding prose a model adds around structured output. - resolve_
image_ ref - Resolve an image reference into something a multimodal API accepts: an
http(s)/data:URL passes through unchanged; a local path is read and encoded into adata:<mime>;base64,…URL (local inference servers can’t fetch arbitrary URLs). Returns an error string the caller surfaces. - resolve_
node_ images - Resolve the node’s
imageUrl(plus an optionalimagesarray) into ready-to-send references (URLs pass through; local paths becomedata:URLs). Empty when the node carries no images.
Type Aliases§
- Staged
Edits - Shared handle to a turn’s
StagingState.FlowApp::run_agent_turncreates one, the executor hands it to the dispatcher, and the caller reads the proposed edits back out after the run.