acp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package acp implements an Agent Client Protocol (ACP) server for hawk, exposing the agent over newline-delimited JSON-RPC 2.0 on stdio so editors (e.g. Zed) can drive it. It mirrors the framing of internal/mcp and the session-driving pattern of internal/daemon.

Scope (first cut): the core agent-side methods (initialize, session/new, session/prompt, session/cancel), streamed session/update notifications, and client-routed tool approvals via session/request_permission. File reads/writes use hawk's local tools; client fs routing is intentionally out of scope.

Index

Constants

View Source
const ProtocolVersion = 1

ProtocolVersion is the ACP protocol version this server implements.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an ACP server bound to a single stdio peer.

func NewServer

func NewServer(factory SessionFactory) *Server

NewServer creates an ACP server that builds sessions via factory.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer) error

Serve runs the ACP server reading from r and writing to w. Each inbound request is dispatched on its own goroutine so the read loop stays free to receive responses to server-initiated requests (e.g. permission prompts) while a prompt is streaming.

func (*Server) ServeStdio

func (s *Server) ServeStdio(ctx context.Context) error

ServeStdio runs the server on stdin/stdout until ctx is cancelled or EOF.

type SessionFactory

type SessionFactory func() (*engine.Session, error)

SessionFactory creates a fresh, configured engine session for a new ACP session.

Jump to

Keyboard shortcuts

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