Skip to content

Native Tools Reference (gsv__*)

Native tools are built into the Gateway and available to agents without a connected node. All native tool names are prefixed with gsv__. Tool names are case-sensitive.

Native tools are defined in gateway/src/agents/tools/. The constant prefix is "gsv__" (defined in gateway/src/agents/tools/constants.ts).

All native tools return a result object with the shape:

typescript
{ ok: boolean; result?: unknown; error?: string }

Workspace Tools

Workspace tools operate on the agent's R2 workspace at agents/{agentId}/. Paths are relative to the workspace root unless otherwise noted. Path traversal (..) is rejected. Virtual skills/ paths resolve agent-local overrides first, then fall back to global skills.

gsv__ReadFile

Read a file or list a directory in the agent's workspace.

ParameterTypeRequiredDescription
pathstringNoPath relative to workspace root. Omit or use "/" to list the root. Examples: "SOUL.md", "memory/", "skills/summarize/SKILL.md".

File output: { path, content: string, size: number, lastModified?: string }

For skills/* paths, the output additionally includes:

  • resolvedPath: The actual R2 key that was read.
  • resolvedSource: "agent" or "global", indicating which copy was found.

Directory output: { path, files: string[], directories: string[] }

Side effects: None. Read-only.

Behavior: If path is omitted, lists the workspace root. If path points to a file, returns its content. If path points to a directory (or a file is not found at that path but objects exist under it as a prefix), returns a directory listing. For skills/ paths, results are merged from agent-level and global locations, with agent files taking precedence for deduplication.


gsv__WriteFile

Write or create a file in the agent's workspace.

ParameterTypeRequiredDescription
pathstringYesFile path relative to workspace root.
contentstringYesContent to write.

Output: { path, size: number, written: true }

Side effects: Creates or overwrites the file in R2. Parent directories are created implicitly (R2 has no directory concept). Sets Content-Type based on file extension: .mdtext/markdown, .jsonapplication/json, .yaml/.ymltext/yaml, all others → text/plain.

Behavior: Writes to skills/* paths always create or update agent-local overrides under agents/{agentId}/skills/*.


gsv__EditFile

Edit a file by replacing exact text matches.

ParameterTypeRequiredDescription
pathstringYesFile path relative to workspace root.
oldStringstringYesExact text to find. Must not be empty.
newStringstringYesReplacement text.
replaceAllbooleanNoReplace all occurrences. Default false (requires oldString to match exactly once).

Output: { path, replacements: number, edited: true, resolvedSource?: string, resolvedPath?: string }

Side effects: Reads the file, performs the replacement, and writes the result back. For skills/* paths, reads from agent-local or global (with agent-local priority), but always writes the result to the agent-local path.

Error conditions:

  • oldString not found → error.
  • oldString found multiple times and replaceAll is not true → error with match count.

gsv__DeleteFile

Delete a file from the agent's workspace.

ParameterTypeRequiredDescription
pathstringYesFile path relative to workspace root.

Output: { path, deleted: true }

Side effects: Permanently deletes the R2 object. Checks for existence first; returns an error if the file is not found.


Gateway Tools

Tools for inspecting Gateway state and connected node information.

gsv__ConfigGet

Inspect the Gateway configuration.

ParameterTypeRequiredDescription
pathstringNoDotted path to a specific config value (e.g. "session.dmScope", "channels.whatsapp.allowFrom"). When omitted, returns the full config (with sensitive values masked).

Output (with path): { path, value }

Output (without path): { config: <masked config object> }

Side effects: None. Read-only.

Behavior: Requires Gateway context. Returns an error if the Gateway stub is unavailable.


gsv__LogsGet

Fetch recent log lines from a connected node.

ParameterTypeRequiredDescription
nodeIdstringNoNode ID to fetch logs from. Required when multiple nodes are connected. Auto-selects when exactly one node is connected.
linesnumberNoNumber of lines to return. Default 100, maximum 5000.

Output: Node log payload (structure determined by Gateway).

Side effects: None. Read-only.

Behavior: Requires Gateway context. Returns an error if the Gateway stub is unavailable.


Cron Tools

gsv__Cron

Manage scheduled cron jobs. This is a single tool with an action discriminator.

ParameterTypeRequiredDescription
actionstringYesAction to execute. One of: "status", "list", "add", "update", "remove", "run", "runs".
idstringNoJob ID. Required for "update", "remove", and "run" with mode: "force".
mode"due" | "force"NoRun mode for action: "run". "due" runs only due jobs. "force" runs a specific job immediately.
agentIdstringNoAgent filter for "list" and "status", or owner agent for "add".
includeDisabledbooleanNoWhether disabled jobs are included for action: "list".
limitnumberNoPagination limit for "list" and "runs".
offsetnumberNoPagination offset for "list" and "runs".
jobobjectNoJob create payload for action: "add". See Job Object below.
patchobjectNoJob patch payload for action: "update". Same fields as job, all optional.
jobIdstringNoJob ID filter for action: "runs".

Side effects: "add" creates a new job. "update" modifies an existing job. "remove" deletes a job. "run" triggers job execution.

Behavior: Requires Gateway context. Delegates to gateway.executeCronTool().

Job Object

Used as the job parameter for action: "add".

FieldTypeRequiredDescription
namestringYesHuman-readable job name.
scheduleobjectYesSchedule definition. See Schedule Object.
specobjectYesJob spec. See Spec Object.
agentIdstringNoAgent that owns the job. Default "main".
descriptionstringNoHuman-readable description.
enabledbooleanNoWhether the job is active. Default true.
deleteAfterRunbooleanNoDelete the job after a successful one-shot run.

Schedule Object

The schedule object requires a kind discriminator.

KindFieldsDescription
"at"at: stringOne-shot schedule. at supports ISO datetime strings, relative strings (e.g. "in 2 hours"), and "today"/"tomorrow" forms. Interpreted in user timezone when no timezone is specified.
"at"in: stringRelative one-shot shorthand (e.g. "in 30 minutes").
"every"everyMinutes?: number, everyHours?: number, everyDays?: number, anchor?: stringInterval schedule. Specify one duration field. anchor is an optional datetime string; if omitted, the interval starts from now.
"cron"expr: string, tz?: stringCron expression schedule. expr is a 5-field cron expression. tz is an IANA timezone (defaults to user timezone).

Spec Object

The spec object requires a mode discriminator.

ModeFieldsDescription
"systemEvent"text: stringInjects text into the agent's main session. The agent processes it in the existing conversation context. Response is delivered to the last active channel.
"task"message: string, deliver?: boolean, channel?: string, to?: string, model?: string, thinking?: string, timeoutSeconds?: number, bestEffortDeliver?: booleanRuns a full agent turn in an isolated session (clean conversation, no carry-over). Supports explicit delivery control.

Message Tools

gsv__Message

Send a message to a channel or user.

ParameterTypeRequiredDescription
textstringYesMessage text to send.
channelstringNoChannel to send to (e.g. "whatsapp", "discord"). Defaults to the user's current channel.
tostringNoPeer ID to send to (phone number, user ID, channel ID). Defaults to the user's current peer.
peerKind"dm" | "group" | "channel" | "thread"NoType of conversation. Defaults to the current peer kind, or "dm" if unknown.
accountIdstringNoAccount ID for multi-account channels. Defaults to the current account.
replyToIdstringNoMessage ID to reply to.

Output: Determined by Gateway executeMessageTool().

Side effects: Sends a message to an external channel via service binding RPC.

Behavior: When called without channel or to, sends to the last active channel and peer for the current session. Requires Gateway context.


Session Tools

gsv__SessionsList

List active sessions with metadata.

ParameterTypeRequiredDescription
limitnumberNoMaximum number of sessions to return. Default 20, maximum 100.
offsetnumberNoPagination offset. Default 0.
messageLimitnumberNoNumber of recent messages to include per session (0–20). Default 0 (none).

Output: Determined by Gateway executeSessionsListTool(). Contains session keys, labels, last activity times, and optionally recent messages.

Side effects: None. Read-only.

Behavior: Requires Gateway context.


gsv__SessionSend

Send a message into another session.

ParameterTypeRequiredDescription
sessionKeystringYesTarget session key (e.g. "main", "agent:helper:main").
messagestringYesMessage text to send.
waitSecondsnumberNoSeconds to wait for a reply. 0 is fire-and-forget. Default 30, maximum 120.

Output: Determined by Gateway executeSessionSendTool(). When waitSeconds > 0, includes the agent's reply.

Side effects: Injects a user message into the target session and triggers an agent turn.

Behavior: Requires Gateway context.


Transfer Tools

gsv__Transfer

Transfer a file between connected nodes and/or the R2 workspace. The tool stays pending until the transfer completes end-to-end.

ParameterTypeRequiredDescription
sourcestringYesSource endpoint. Format: {nodeId}:/path/to/file for a node filesystem path, or gsv:workspace/path for an R2 workspace path.
destinationstringYesDestination endpoint. Same format as source.

Output: { source, destination, bytesTransferred, mime? }

FieldTypeDescription
sourcestringEchoed source endpoint.
destinationstringEchoed destination endpoint.
bytesTransferrednumberTotal bytes transferred.
mimestringDetected MIME type of the transferred file (when available).

Side effects: Reads the file from the source endpoint and writes it to the destination endpoint. Creates parent directories on node destinations if needed.

Behavior: The Gateway orchestrates the transfer using one of three modes depending on the endpoint types:

ModeSourceDestinationDescription
Node-to-Node{nodeId}:/path{nodeId}:/pathBinary relay through the Gateway. Data flows as binary WebSocket frames from source node to Gateway to destination node.
Node-to-R2{nodeId}:/pathgsv:workspace/pathStreaming upload. Source node sends binary frames; Gateway streams into R2Bucket.put() via a TransformStream.
R2-to-Nodegsv:workspace/path{nodeId}:/pathStreaming download. Gateway reads from R2 and sends binary frames to the destination node.

Data transfer uses binary WebSocket frames (not JSON text frames). See the WebSocket Protocol Reference for the binary frame format.

Error conditions:

  • Source or destination endpoint is malformed.
  • Referenced node is not connected.
  • Source file does not exist or is not readable.
  • Destination write fails (permissions, disk full).
  • Transfer timeout.