Documentation
¶
Overview ¶
Package copilottest is a fake Copilot CLI server mode for tests: the JSON-RPC 2.0 server of `copilot --headless --stdio`, framed by Content-Length, in the shapes Copilot CLI 1.0.95 answers with (recorded against the real binary with no account) and copilot-sdk go/v1.0.19 names. It asks for the session's token at session.create, as the real one does, then plays a scripted turn per session.send, and lists its Models to session.model.list.
Index ¶
- type Conn
- func (c *Conn) Ask(method string, params map[string]any) map[string]any
- func (c *Conn) AskPermission(requestID string, request map[string]any) map[string]any
- func (c *Conn) AskToken(reason string) map[string]any
- func (c *Conn) Event(typ string, data any)
- func (c *Conn) ToolCall(callID, tool string) string
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is the server's side of one session, for a Turn to play on.
func (*Conn) AskPermission ¶
AskPermission sends a permission.requested event for request and waits for the driver's decision.
func (*Conn) AskToken ¶
AskToken asks the driver for a token, as Copilot CLI does (reason initial or refresh), and returns its answer: the result, or {"error": …}.
type Server ¶
type Server struct {
// CreateError fails session.create with this message, after the token
// callback (GitHub refusing the token, an organization's policy).
CreateError string
// Abort plays a session.abort on c after its answer; nil only answers it.
Abort func(c *Conn)
// Turn plays one session.send on c; nil answers "Hello." and goes idle.
Turn func(c *Conn, prompt string)
// Models is session.model.list's list, each entry a model as Copilot
// CLI lists it (copilot-sdk go/rpc/zrpc.go Model: id, name, billing,
// policy); nil lists none.
Models []map[string]any
// Stored are the session ids session.resume finds, as a COPILOT_HOME
// kept from an earlier process holds them; any other is "not found".
Stored []string
// ResumeError fails session.resume with this message whatever the id
// (an organization's policy).
ResumeError string
// Compact is session.history.compact's result; nil answers the method
// as unhandled, as a release that does not serve it would.
Compact map[string]any
// Resume is session.resume's params, as the driver sent them.
Resume map[string]any
// Create is session.create's params, as the driver sent them.
Create map[string]any
// Options is session.options.update's params.
Options map[string]any
// Tokens are the callback's answers (the token's result object, or
// the error), in order.
Tokens []map[string]any
// Decisions are the permission decisions the driver applied, by
// request id.
Decisions map[string]map[string]any
// Methods are the methods the driver called, in order.
Methods []string
// contains filtered or unexported fields
}
Server is one fake Copilot CLI process.
func (*Server) Resumed ¶
Resumed is session.resume's params, as the driver sent them; nil when it sent none.