Documentation
¶
Overview ¶
Package acptest drives ACP in tests as an editor does: a session client and agent, a server on a real HTTP listener, and a client on a WebSocket that reads the frames in order and answers the agent's requests.
Index ¶
- func Error(t *testing.T, resp map[string]any) map[string]any
- func Listen(t *testing.T, srv *server.Server) string
- func Message(t *testing.T, resp map[string]any) string
- func Result(t *testing.T, resp map[string]any) map[string]any
- func Server(r *Runtime, wire server.ProtocolWireStore) *server.Server
- func SessionID(t *testing.T, resp map[string]any) string
- func StopReason(resp map[string]any) string
- func Updates(frames []map[string]any) []map[string]any
- type Client
- func (c *Client) Call(method, params string) map[string]any
- func (c *Client) Close()
- func (c *Client) Frame() map[string]any
- func (c *Client) NewSession(cwd string) string
- func (c *Client) Prompt(sid, blocks string) int
- func (c *Client) Request(method, params string) int
- func (c *Client) Say(sid, text string) (map[string]any, []map[string]any)
- func (c *Client) Send(body string)
- func (c *Client) Until(id int, answer func(req map[string]any) any) (map[string]any, []map[string]any)
- func (c *Client) Use(t *testing.T) *Client
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Message ¶
Message is the message of an error response; a response with no error fails the test.
func Server ¶
func Server(r *Runtime, wire server.ProtocolWireStore) *server.Server
Server is an anonymous ACP server for r, with its wire state in wire (nil: in memory).
func StopReason ¶
StopReason is the stopReason a prompt's response ends with; "" when it is an error.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an ACP client on one WebSocket.
func (*Client) Close ¶
func (c *Client) Close()
Close closes the socket, as an editor that quits does.
func (*Client) NewSession ¶
NewSession makes a session in cwd and returns its id.
func (*Client) Prompt ¶
Prompt sends blocks (a JSON array of content blocks) to session sid and returns the request id.
func (*Client) Say ¶
Say sends text to session sid and returns how the turn ended and the frames before.
func (*Client) Until ¶
func (c *Client) Until(id int, answer func(req map[string]any) any) (map[string]any, []map[string]any)
Until reads frames until the response to id, answering each request the agent makes with answer, and returns that response and the frames before it. A request with no answer fails the test.
type Runtime ¶
type Runtime struct {
Client session.Client
Agent tacklr.AgentOptions
Workspace bool
}
Runtime is the session client and agent an ACP request runs against. Workspace says the sessions have a workspace, so clients may bind to it.
func NewRuntime ¶
NewRuntime runs spec on the live Temporal stack, with no workspace. A nil spec.Model takes model, else a model that sends nothing; the window and system prompt get test defaults.