Documentation
¶
Overview ¶
Package acp is the wire side of the Agent Client Protocol: JSON-RPC 2.0 messages, one per line, read from the client on standard input and written to it on standard output. What the messages mean is the caller's (cmd/kvit-coder/acp.go); this package only carries them.
Requests from the client are handled each on its own goroutine, so a session/cancel, or the answer to a question this side asked, is read while a prompt is still running. Responses and notifications are written whole, one at a time.
Index ¶
Constants ¶
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 )
The JSON-RPC error codes this side sends.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one connection to a client.
func (*Conn) Call ¶
Call sends a request and waits for its answer, which is decoded into result when that is not nil. It gives up when ctx is done.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error is a JSON-RPC error, sent as the answer to a request or received as one.
type Handler ¶
type Handler interface {
HandleRequest(ctx context.Context, method string, params json.RawMessage) (any, error)
HandleNotification(method string, params json.RawMessage)
}
Handler answers what the client sends. HandleRequest returns the result to send back, or an error; an *Error keeps its code and any other error is sent as an internal error with its text. HandleNotification has nothing to answer.