Documentation
¶
Overview ¶
Package acptools contains tools built in to ACP like file IO and terminals
Index ¶
- type FilesystemTools
- type TermACPClient
- func (e *TermACPClient) CreateTerminal(ctx context.Context, params acp.CreateTerminalRequest) (acp.CreateTerminalResponse, error)
- func (e *TermACPClient) KillTerminal(ctx context.Context, params acp.KillTerminalRequest) (acp.KillTerminalResponse, error)
- func (e *TermACPClient) ReadTextFile(ctx context.Context, params acp.ReadTextFileRequest) (acp.ReadTextFileResponse, error)
- func (e *TermACPClient) ReleaseTerminal(ctx context.Context, params acp.ReleaseTerminalRequest) (acp.ReleaseTerminalResponse, error)
- func (e *TermACPClient) RequestPermission(ctx context.Context, params acp.RequestPermissionRequest) (acp.RequestPermissionResponse, error)
- func (e *TermACPClient) SessionUpdate(ctx context.Context, params acp.SessionNotification) error
- func (e *TermACPClient) TerminalOutput(ctx context.Context, params acp.TerminalOutputRequest) (acp.TerminalOutputResponse, error)
- func (e *TermACPClient) WaitForTerminalExit(ctx context.Context, params acp.WaitForTerminalExitRequest) (acp.WaitForTerminalExitResponse, error)
- func (e *TermACPClient) WriteTextFile(ctx context.Context, params acp.WriteTextFileRequest) (acp.WriteTextFileResponse, error)
- type TerminalTools
- func (e *TerminalTools) CreateTerminal(ctx context.Context, params acp.CreateTerminalRequest) (acp.CreateTerminalResponse, error)
- func (e *TerminalTools) KillTerminal(ctx context.Context, params acp.KillTerminalRequest) (acp.KillTerminalResponse, error)
- func (e *TerminalTools) ReleaseTerminal(ctx context.Context, params acp.ReleaseTerminalRequest) (acp.ReleaseTerminalResponse, error)
- func (e *TerminalTools) TerminalOutput(ctx context.Context, params acp.TerminalOutputRequest) (acp.TerminalOutputResponse, error)
- func (e *TerminalTools) WaitForTerminalExit(ctx context.Context, params acp.WaitForTerminalExitRequest) (acp.WaitForTerminalExitResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilesystemTools ¶
type FilesystemTools struct {
// contains filtered or unexported fields
}
FilesystemTools implements the ACP ReadTextFile and WriteTextFile endpoints. It is separate from TerminalTools to allow toggling local/remote execution separately.
func NewFilesystemTools ¶
func NewFilesystemTools(logger zerolog.Logger) *FilesystemTools
NewFilesystemTools returns a FilesystemTools instance that executes filesystem operations locally.
func (*FilesystemTools) ReadTextFile ¶
func (e *FilesystemTools) ReadTextFile( ctx context.Context, params acp.ReadTextFileRequest, ) (acp.ReadTextFileResponse, error)
ReadTextFile implements ReadTextFile by actually reading the file and returning results. This is opposed to the non-default behavior of passing the request to the ACP client to execute on the host.
func (*FilesystemTools) WriteTextFile ¶
func (e *FilesystemTools) WriteTextFile( ctx context.Context, params acp.WriteTextFileRequest, ) (acp.WriteTextFileResponse, error)
WriteTextFile implements WriteTextFile by actually writing the file and returning results. This is opposed to the non-default behavior of passing the request to the ACP client to execute on the host.
type TermACPClient ¶ added in v0.0.3
type TermACPClient struct {
// contains filtered or unexported fields
}
TermACPClient implements acp.Client against a local terminal: it prints session updates, prompts the user for permission decisions, and delegates file and terminal operations to acptools.
func NewTermACPClient ¶ added in v0.0.3
func NewTermACPClient() *TermACPClient
NewTermACPClient creates a terminal-backed ACP client. Session updates and permission prompts are rendered to os.Stdout, and permission selections are read from os.Stdin. File and terminal operations are backed by the built-in acptools implementations.
func (*TermACPClient) CreateTerminal ¶ added in v0.0.3
func (e *TermACPClient) CreateTerminal( ctx context.Context, params acp.CreateTerminalRequest, ) (acp.CreateTerminalResponse, error)
CreateTerminal delegates to the local terminal implementation.
func (*TermACPClient) KillTerminal ¶ added in v0.0.3
func (e *TermACPClient) KillTerminal( ctx context.Context, params acp.KillTerminalRequest, ) (acp.KillTerminalResponse, error)
KillTerminal implements acp.Client.
func (*TermACPClient) ReadTextFile ¶ added in v0.0.3
func (e *TermACPClient) ReadTextFile( ctx context.Context, params acp.ReadTextFileRequest, ) (acp.ReadTextFileResponse, error)
ReadTextFile delegates to the local filesystem implementation.
func (*TermACPClient) ReleaseTerminal ¶ added in v0.0.3
func (e *TermACPClient) ReleaseTerminal( ctx context.Context, params acp.ReleaseTerminalRequest, ) (acp.ReleaseTerminalResponse, error)
ReleaseTerminal delegates to the local terminal implementation.
func (*TermACPClient) RequestPermission ¶ added in v0.0.3
func (e *TermACPClient) RequestPermission( ctx context.Context, params acp.RequestPermissionRequest, ) (acp.RequestPermissionResponse, error)
RequestPermission prompts the user on the terminal to choose one of the provided permission options for a tool call. An invalid or empty selection (or a cancelled context) is reported as cancelled rather than erroring, so the agent can wind down the turn cleanly.
func (*TermACPClient) SessionUpdate ¶ added in v0.0.3
func (e *TermACPClient) SessionUpdate(ctx context.Context, params acp.SessionNotification) error
SessionUpdate renders a session update to the terminal. Only the update kinds relevant to a terminal client are rendered; the rest are ignored.
func (*TermACPClient) TerminalOutput ¶ added in v0.0.3
func (e *TermACPClient) TerminalOutput( ctx context.Context, params acp.TerminalOutputRequest, ) (acp.TerminalOutputResponse, error)
TerminalOutput delegates to the local terminal implementation.
func (*TermACPClient) WaitForTerminalExit ¶ added in v0.0.3
func (e *TermACPClient) WaitForTerminalExit( ctx context.Context, params acp.WaitForTerminalExitRequest, ) (acp.WaitForTerminalExitResponse, error)
WaitForTerminalExit delegates to the local terminal implementation.
func (*TermACPClient) WriteTextFile ¶ added in v0.0.3
func (e *TermACPClient) WriteTextFile( ctx context.Context, params acp.WriteTextFileRequest, ) (acp.WriteTextFileResponse, error)
WriteTextFile delegates to the local filesystem implementation.
type TerminalTools ¶
type TerminalTools struct {
// contains filtered or unexported fields
}
TerminalTools implements the terminal-related methods of acp.Client. It runs commands as real OS processes and tracks their output and exit status, keyed by a generated terminal ID.
func NewTerminalTools ¶
func NewTerminalTools(logger zerolog.Logger) *TerminalTools
NewTerminalTools constructs a TerminalTools with the given logger.
func (*TerminalTools) CreateTerminal ¶
func (e *TerminalTools) CreateTerminal( ctx context.Context, params acp.CreateTerminalRequest, ) (acp.CreateTerminalResponse, error)
CreateTerminal starts a new command process and returns a terminal ID that can be used to inspect its output and status.
func (*TerminalTools) KillTerminal ¶
func (e *TerminalTools) KillTerminal( ctx context.Context, params acp.KillTerminalRequest, ) (acp.KillTerminalResponse, error)
KillTerminal terminates the terminal's process without releasing the terminal; its output and exit status remain available afterwards.
func (*TerminalTools) ReleaseTerminal ¶
func (e *TerminalTools) ReleaseTerminal( ctx context.Context, params acp.ReleaseTerminalRequest, ) (acp.ReleaseTerminalResponse, error)
ReleaseTerminal frees the resources associated with a terminal, killing the underlying process if it is still running.
func (*TerminalTools) TerminalOutput ¶
func (e *TerminalTools) TerminalOutput( ctx context.Context, params acp.TerminalOutputRequest, ) (acp.TerminalOutputResponse, error)
TerminalOutput returns the output captured so far for a terminal along with its exit status, if the command has completed.
func (*TerminalTools) WaitForTerminalExit ¶
func (e *TerminalTools) WaitForTerminalExit( ctx context.Context, params acp.WaitForTerminalExitRequest, ) (acp.WaitForTerminalExitResponse, error)
WaitForTerminalExit blocks until the terminal's command exits (or the context is cancelled) and returns its exit status.