Documentation
¶
Overview ¶
Package opencode provides typed views over the NDJSON frames the generated agenthooks OpenCode shim plugin proxies from OpenCode's in-process plugin hooks (DESIGN.md §8). Event.Raw for OpenCode events is the verbatim frame: {seq, hook, input, output}.
Index ¶
- func ToolExecuteAfter(e *agenthooks.Event) (*ToolExecuteBeforeInput, *ToolExecuteAfterOutput, bool)
- func ToolExecuteBefore(e *agenthooks.Event) (*ToolExecuteBeforeInput, *ToolExecuteBeforeOutput, bool)
- type Frame
- type InitializeInput
- type MCPServerConfig
- type PermissionAskedInput
- type Reply
- type ToolExecuteAfterOutput
- type ToolExecuteBeforeInput
- type ToolExecuteBeforeOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToolExecuteAfter ¶
func ToolExecuteAfter(e *agenthooks.Event) (*ToolExecuteBeforeInput, *ToolExecuteAfterOutput, bool)
ToolExecuteAfter decodes both halves of a tool.execute.after frame.
func ToolExecuteBefore ¶
func ToolExecuteBefore(e *agenthooks.Event) (*ToolExecuteBeforeInput, *ToolExecuteBeforeOutput, bool)
ToolExecuteBefore decodes both halves of a tool.execute.before frame.
Types ¶
type Frame ¶
type Frame struct {
Seq int64 `json:"seq"`
Hook string `json:"hook"`
Input json.RawMessage `json:"input"`
Output json.RawMessage `json:"output"`
Extra map[string]json.RawMessage `json:"-"`
}
Frame is the shim wire request. Output is the mutable object OpenCode passes to plugin hooks; replies merge into it (Object.assign, arrays replaced wholesale).
func DecodeFrame ¶
func DecodeFrame(e *agenthooks.Event) (*Frame, bool)
DecodeFrame returns the verbatim frame behind an OpenCode event.
type InitializeInput ¶
type InitializeInput struct {
ServerURL string `json:"serverUrl"`
Directory string `json:"directory"`
Worktree string `json:"worktree"`
MCP map[string]MCPServerConfig `json:"mcp"`
Extra map[string]json.RawMessage `json:"-"`
}
InitializeInput is the shim's lazy initialization payload carrying OpenCode server info and its resolved MCP inventory for the optional HTTP client (permission replies via POST /session/:id/permissions/:permissionID, context injection via session.prompt with noReply).
type MCPServerConfig ¶ added in v0.3.0
type MCPServerConfig struct {
Type string `json:"type"`
Command []string `json:"command"`
URL string `json:"url"`
Enabled *bool `json:"enabled"`
Extra map[string]json.RawMessage `json:"-"`
}
MCPServerConfig is the sanitized active MCP inventory sent by the shim.
type PermissionAskedInput ¶
type PermissionAskedInput struct {
SessionID string `json:"sessionID"`
PermissionID string `json:"permissionID"`
Type string `json:"type"`
Title string `json:"title"`
Extra map[string]json.RawMessage `json:"-"`
}
PermissionAskedInput mirrors the permission.asked event payload. The typed plugin hook is dead upstream (quirk #18); replies go over HTTP.
func PermissionAsked ¶
func PermissionAsked(e *agenthooks.Event) (*PermissionAskedInput, bool)
PermissionAsked decodes a permission.asked frame's input.
type Reply ¶
type Reply struct {
Seq int64 `json:"seq"`
Output map[string]any `json:"output,omitempty"`
Error string `json:"error,omitempty"`
}
Reply is the shim wire response. Error re-throws in the plugin to keep block-the-tool behavior.
type ToolExecuteAfterOutput ¶
type ToolExecuteAfterOutput struct {
Title string `json:"title"`
Output json.RawMessage `json:"output"`
Metadata json.RawMessage `json:"metadata"`
Extra map[string]json.RawMessage `json:"-"`
}
ToolExecuteAfterOutput is the mutable output half of tool.execute.after.
type ToolExecuteBeforeInput ¶
type ToolExecuteBeforeInput struct {
SessionID string `json:"sessionID"`
CallID string `json:"callID"`
Tool string `json:"tool"`
Extra map[string]json.RawMessage `json:"-"`
}
ToolExecuteBeforeInput is the input half of tool.execute.before.
type ToolExecuteBeforeOutput ¶
type ToolExecuteBeforeOutput struct {
Args json.RawMessage `json:"args"`
Extra map[string]json.RawMessage `json:"-"`
}
ToolExecuteBeforeOutput is the mutable output half of tool.execute.before.