opencode

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolExecuteAfter

ToolExecuteAfter decodes both halves of a tool.execute.after frame.

func ToolExecuteBefore

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"`
	Extra     map[string]json.RawMessage `json:"-"`
}

InitializeInput is the startup frame payload carrying OpenCode server info for the optional HTTP client (permission replies via POST /session/:id/permissions/:permissionID, context injection via session.prompt with noReply).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL