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__ListFiles

List files and directories in the agent's workspace.

ParameterTypeRequiredDescription
pathstringNoDirectory path relative to workspace root. "/" or omitted for root. "memory/" for memory directory. "skills/" for skill files.

Output: { path, files: string[], directories: string[] }

Side effects: None. Read-only.

Behavior: Lists objects and common prefixes in R2 under the resolved path. For skills/ paths, results are merged from agent-level (agents/{agentId}/skills/) and global (skills/) locations, with agent files taking precedence for deduplication.


gsv__ReadFile

Read a file from the agent's workspace.

ParameterTypeRequiredDescription
pathstringYesFile path relative to workspace root. Examples: "SOUL.md", "memory/2024-01-15.md", "skills/summarize/SKILL.md".

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.

Side effects: None. Read-only.

Behavior: For skills/* paths, checks agent-local override at agents/{agentId}/skills/* first, then falls back to the global skills/* path. Returns an error if the file is not found.


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.