OpenCode icon

OpenCode

Interact with OpenCode Server API for AI coding assistant sessions

Message → Run Shell

AI-generated

Summary

Execute a shell command in an OpenCode session and return the output.

Inputs

  • sessionMode — Choose how to handle sessions. Defaults to existing session; use temporary for a short-lived session that is deleted after execution.
  • sessionId (required) — Select a session for messaging. Required when sessionMode is 'existing'. Loads sessions from the OpenCode API.
  • tempSessionTitle — Title for temporary sessions. Shown when sessionMode is 'temporary'. Defaults to 'Temporary Chat Session'.
  • model — Select a model (optional). Uses default if not specified. Format: providerID::modelID.
  • simpleResponse — Whether to return only the shell output (true) or full metadata including session details (false). Defaults to false.
  • shellCommand (required) — The shell command to run. Default placeholder is 'ls -la'.
  • shellAgent (required) — Agent to use for executing the shell command. Selected from available agents via the OpenCode API.
  • options — Optional settings for the shell execution.

Output shape

object

If simpleResponse is true, returns only the shell output under the key specified by responseKey (default 'response'). If false, returns full metadata including messageId, sessionId, model, provider, tokens, cost, command, agent, wasTemporarySession, the shell output under responseKey, and the raw parts array from the API response.

Examples

Example 1: Run a simple shell command and get just the output.

sessionMode: existing, sessionId: , shellCommand: 'ls -la', simpleResponse: true

Example 2: Run a shell command in a new temporary session and get full metadata.

sessionMode: temporary, shellCommand: 'pwd', simpleResponse: false

Links

Discussion