Directories
¶
| Path | Synopsis |
|---|---|
|
Demonstrates opencodesdk.WithAddDirs — forwarding ACP's unstable `additionalDirectories` field to opencode.
|
Demonstrates opencodesdk.WithAddDirs — forwarding ACP's unstable `additionalDirectories` field to opencode. |
|
Demonstrates cancelling an in-flight opencode turn via [Session.Cancel].
|
Demonstrates cancelling an in-flight opencode turn via [Session.Cancel]. |
|
Example: per-session cost tracking via CostTracker, persisted to $XDG_DATA_HOME/opencode/sdk/session-costs/<id>.json.
|
Example: per-session cost tracking via CostTracker, persisted to $XDG_DATA_HOME/opencode/sdk/session-costs/<id>.json. |
|
Demonstrates routing opencodesdk's internal logs through a custom slog.Handler.
|
Demonstrates routing opencodesdk's internal logs through a custom slog.Handler. |
|
Demonstrates opencodesdk.WithTransport — injecting a custom Transport in place of the default `opencode acp` subprocess.
|
Demonstrates opencodesdk.WithTransport — injecting a custom Transport in place of the default `opencode acp` subprocess. |
|
Demonstrates WithEffort: opencode encodes reasoning depth as a `/<variant>` suffix on a model id (e.g.
|
Demonstrates WithEffort: opencode encodes reasoning depth as a `/<variant>` suffix on a model id (e.g. |
|
Example: a tool that asks the user to confirm a destructive action via MCP elicitation.
|
Example: a tool that asks the user to confirm a destructive action via MCP elicitation. |
|
Example elicitation_callback demonstrates the agent-initiated elicitation path: WithOnElicitation receives elicitation/create requests from the agent and returns an Accept / Decline / Cancel response.
|
Example elicitation_callback demonstrates the agent-initiated elicitation path: WithOnElicitation receives elicitation/create requests from the agent and returns an Accept / Decline / Cancel response. |
|
Demonstrates the typed errors opencodesdk surfaces and how to branch on them with errors.Is / errors.As.
|
Demonstrates the typed errors opencodesdk surfaces and how to branch on them with errors.Is / errors.As. |
|
Demonstrates WithMCPServers: attach an external MCP server to every new session.
|
Demonstrates WithMCPServers: attach an external MCP server to every new session. |
|
Demonstrates Client.ForkSession and Client.ResumeSession.
|
Demonstrates Client.ForkSession and Client.ResumeSession. |
|
Demonstrates WithOnFsWrite: intercept opencode's fs/write_text_file delegations and redirect them into an in-memory map rather than the real filesystem.
|
Demonstrates WithOnFsWrite: intercept opencode's fs/write_text_file delegations and redirect them into an in-memory map rather than the real filesystem. |
|
Example: WithHooks wires typed callbacks into opencode's session/update stream + lifecycle + permission path.
|
Example: WithHooks wires typed callbacks into opencode's session/update stream + lifecycle + permission path. |
|
Demonstrates Client.IterSessions — a cursor-paginated iterator over every opencode session in the configured cwd.
|
Demonstrates Client.IterSessions — a cursor-paginated iterator over every opencode session in the configured cwd. |
|
Demonstrates Client.LoadSession — rehydrate a previous opencode session by id.
|
Demonstrates Client.LoadSession — rehydrate a previous opencode session by id. |
|
Example: cap total session spend with WithMaxBudgetUSD.
|
Example: cap total session spend with WithMaxBudgetUSD. |
|
Demonstrates WithMaxTurns: a client-side cap on the number of assistant messages observed per session.
|
Demonstrates WithMaxTurns: a client-side cap on the number of assistant messages observed per session. |
|
Demonstrates opencode-specific model variant handling: OpencodeVariant, Session.CurrentVariant, and Client.UnstableSetModel.
|
Demonstrates opencode-specific model variant handling: OpencodeVariant, Session.CurrentVariant, and Client.UnstableSetModel. |
|
Demonstrates multimodal prompt input via the opencodesdk.QueryContent one-shot helper.
|
Demonstrates multimodal prompt input via the opencodesdk.QueryContent one-shot helper. |
|
Demonstrates running multiple opencode queries concurrently — each in its own subprocess + session — and aggregating the answers in Go.
|
Demonstrates running multiple opencode queries concurrently — each in its own subprocess + session — and aggregating the answers in Go. |
|
Demonstrates WithCanUseTool: a stdin-based permission prompt that asks the operator to approve each tool call interactively.
|
Demonstrates WithCanUseTool: a stdin-based permission prompt that asks the operator to approve each tool call interactively. |
|
Demonstrates a multi-step LLM pipeline with Go-side gating.
|
Demonstrates a multi-step LLM pipeline with Go-side gating. |
|
Demonstrates WithInitialMode(ModePlan).
|
Demonstrates WithInitialMode(ModePlan). |
|
Demonstrates opencodesdk.QueryStream for running a series of prompts against a single, long-lived opencode session and iterating results as they arrive.
|
Demonstrates opencodesdk.QueryStream for running a series of prompts against a single, long-lived opencode session and iterating results as they arrive. |
|
Demonstrates opencodesdk.QueryStreamContent — the iterator-backed multimodal variant of QueryStream.
|
Demonstrates opencodesdk.QueryStreamContent — the iterator-backed multimodal variant of QueryStream. |
|
Quick-start example for opencode-agent-sdk-go.
|
Quick-start example for opencode-agent-sdk-go. |
|
Example: ResilientQuery applies exponential backoff + jitter for retryable errors (rate limit, overload, transient connection).
|
Example: ResilientQuery applies exponential backoff + jitter for retryable errors (rate limit, overload, transient connection). |
|
Demonstrates Session.RunCommand: invoke one of opencode's slash commands (advertised via session/update's available_commands_update notification) as a prompt turn.
|
Demonstrates Session.RunCommand: invoke one of opencode's slash commands (advertised via session/update's available_commands_update notification) as a prompt turn. |
|
Demonstrates in-process tools exposed to opencode via the loopback HTTP MCP bridge built into the SDK.
|
Demonstrates in-process tools exposed to opencode via the loopback HTTP MCP bridge built into the SDK. |
|
Enumerates prior opencode sessions scoped to the working directory and prints their IDs and titles.
|
Enumerates prior opencode sessions scoped to the working directory and prints their IDs and titles. |
|
Demonstrates intra-session mutations: Session.SetModel and Session.SetMode.
|
Demonstrates intra-session mutations: Session.SetModel and Session.SetMode. |
|
Example: Session.SetConfigOption routes session/set_config_option for arbitrary config ids reported by opencode at session creation.
|
Example: Session.SetConfigOption routes session/set_config_option for arbitrary config ids reported by opencode at session creation. |
|
Demonstrates WithStderr for capturing opencode's stderr output.
|
Demonstrates WithStderr for capturing opencode's stderr output. |
|
Demonstrates Session.Subscribe — typed per-variant callbacks for session/update notifications.
|
Demonstrates Session.Subscribe — typed per-variant callbacks for session/update notifications. |
Click to show internal directories.
Click to hide internal directories.