agent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package agent provides the ACP agent implementation for GitLab Duo.

Index

Constants

View Source
const AgentName = "gitlab-duo-acp"

AgentName is the name of this agent.

Variables

View Source
var (
	// ErrSessionNotFound is returned when a session ID doesn't exist.
	ErrSessionNotFound = errors.New("session not found")

	// ErrPathOutsideWorkspace is returned when a file path is outside the workspace.
	ErrPathOutsideWorkspace = errors.New("path is outside workspace")

	// ErrFileSystemNotSupported is returned when the client doesn't support file system operations.
	ErrFileSystemNotSupported = errors.New("client does not support file system operations")

	// ErrTextNotFound is returned when the text to replace is not found in the file.
	ErrTextNotFound = errors.New("the specified text was not found in the file")

	// ErrAmbiguousMatch is returned when the text to replace appears multiple times.
	ErrAmbiguousMatch = errors.New("text appears multiple times; provide more context to make the match unique")
)

Functions

This section is empty.

Types

type ACPConnection added in v0.1.0

type ACPConnection interface {
	SessionUpdate(ctx context.Context, params acp.SessionNotification) error
	ReadTextFile(ctx context.Context, params acp.ReadTextFileRequest) (acp.ReadTextFileResponse, error)
	WriteTextFile(ctx context.Context, params acp.WriteTextFileRequest) (acp.WriteTextFileResponse, error)
}

ACPConnection defines the ACP client methods used by the agent. This interface enables testing without a real ACP connection.

type ActionResponder added in v0.1.0

type ActionResponder interface {
	SendActionResponse(requestID, response, errMsg string) error
}

ActionResponder sends action responses back to the Duo Workflow Service. This interface enables testing without a real WebSocket connection.

type Agent

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

Agent implements the acp.Agent interface for GitLab Duo.

func New

func New(logger *slog.Logger, duoClient *duo.Client, version string) *Agent

New creates a new GitLab Duo ACP agent.

func (*Agent) Authenticate

func (a *Agent) Authenticate(ctx context.Context, params acp.AuthenticateRequest) (acp.AuthenticateResponse, error)

Authenticate implements acp.Agent. Stub implementation for now.

func (*Agent) Cancel

func (a *Agent) Cancel(ctx context.Context, params acp.CancelNotification) error

Cancel implements acp.Agent. It cancels an ongoing operation in a session while keeping the session valid for subsequent prompts. The workflow is preserved so future messages can continue the conversation.

func (*Agent) Initialize

func (a *Agent) Initialize(ctx context.Context, params acp.InitializeRequest) (acp.InitializeResponse, error)

Initialize implements acp.Agent. It returns the agent's capabilities and protocol version.

func (*Agent) NewSession

func (a *Agent) NewSession(ctx context.Context, params acp.NewSessionRequest) (acp.NewSessionResponse, error)

NewSession implements acp.Agent. It creates a new chat session and returns its ID.

func (*Agent) Prompt

func (a *Agent) Prompt(ctx context.Context, params acp.PromptRequest) (acp.PromptResponse, error)

Prompt implements acp.Agent. It handles user prompts by connecting to the Duo Workflow Service and streaming responses back to the client.

func (*Agent) SetAgentConnection

func (a *Agent) SetAgentConnection(conn *acp.AgentSideConnection)

SetAgentConnection implements acp.AgentConnAware. It receives the connection after construction so the agent can send updates.

func (*Agent) SetSessionMode

func (a *Agent) SetSessionMode(ctx context.Context, params acp.SetSessionModeRequest) (acp.SetSessionModeResponse, error)

SetSessionMode implements acp.Agent. Stub implementation for now.

Jump to

Keyboard shortcuts

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