Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Learn more about the protocol itself at <https://agentclientprotocol.com>.
<!-- `$ printf 'go get github.com/coder/acp-go-sdk@v%s\n' "$(cat schema/version)"` as bash -->

```bash
go get github.com/coder/acp-go-sdk@v0.12.0
go get github.com/coder/acp-go-sdk@v0.12.2
```

## Get Started
Expand Down
45 changes: 31 additions & 14 deletions acp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ type agentFuncs struct {
AuthenticateFunc func(context.Context, AuthenticateRequest) (AuthenticateResponse, error)
PromptFunc func(context.Context, PromptRequest) (PromptResponse, error)
CancelFunc func(context.Context, CancelNotification) error
CloseSessionFunc func(context.Context, CloseSessionRequest) (CloseSessionResponse, error)
SetSessionModeFunc func(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error)
ListSessionsFunc func(context.Context, ListSessionsRequest) (ListSessionsResponse, error)
ResumeSessionFunc func(context.Context, ResumeSessionRequest) (ResumeSessionResponse, error)
SetSessionConfigOptionFunc func(context.Context, SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error)
// Unstable (schema/meta.unstable.json)
UnstableDidChangeDocumentFunc func(context.Context, UnstableDidChangeDocumentNotification) error
Expand All @@ -134,9 +136,7 @@ type agentFuncs struct {
UnstableDisableProvidersFunc func(context.Context, UnstableDisableProvidersRequest) (UnstableDisableProvidersResponse, error)
UnstableListProvidersFunc func(context.Context, UnstableListProvidersRequest) (UnstableListProvidersResponse, error)
UnstableSetProvidersFunc func(context.Context, UnstableSetProvidersRequest) (UnstableSetProvidersResponse, error)
UnstableCloseSessionFunc func(context.Context, UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error)
UnstableForkSessionFunc func(context.Context, UnstableForkSessionRequest) (UnstableForkSessionResponse, error)
UnstableResumeSessionFunc func(context.Context, UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error)
UnstableSetSessionModelFunc func(context.Context, UnstableSetSessionModelRequest) (UnstableSetSessionModelResponse, error)

HandleExtensionMethodFunc func(context.Context, string, json.RawMessage) (any, error)
Expand Down Expand Up @@ -191,6 +191,14 @@ func (a agentFuncs) Cancel(ctx context.Context, n CancelNotification) error {
return nil
}

// CloseSession implements Agent.
func (a agentFuncs) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) {
if a.CloseSessionFunc != nil {
return a.CloseSessionFunc(ctx, params)
}
return CloseSessionResponse{}, nil
}

// SetSessionMode implements Agent.
func (a agentFuncs) SetSessionMode(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error) {
if a.SetSessionModeFunc != nil {
Expand All @@ -215,12 +223,12 @@ func (a agentFuncs) ListSessions(ctx context.Context, params ListSessionsRequest
return ListSessionsResponse{}, nil
}

// UnstableResumeSession implements AgentExperimental.
func (a agentFuncs) UnstableResumeSession(ctx context.Context, params UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) {
if a.UnstableResumeSessionFunc != nil {
return a.UnstableResumeSessionFunc(ctx, params)
// ResumeSession implements Agent.
func (a agentFuncs) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) {
if a.ResumeSessionFunc != nil {
return a.ResumeSessionFunc(ctx, params)
}
return UnstableResumeSessionResponse{}, nil
return ResumeSessionResponse{}, nil
}

// SetSessionConfigOption implements Agent.
Expand Down Expand Up @@ -337,13 +345,6 @@ func (a agentFuncs) UnstableSetProviders(ctx context.Context, params UnstableSet
return UnstableSetProvidersResponse{}, nil
}

func (a agentFuncs) UnstableCloseSession(ctx context.Context, params UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) {
if a.UnstableCloseSessionFunc != nil {
return a.UnstableCloseSessionFunc(ctx, params)
}
return UnstableCloseSessionResponse{}, nil
}

func (a agentFuncs) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) {
if a.HandleExtensionMethodFunc != nil {
return a.HandleExtensionMethodFunc(ctx, method, params)
Expand All @@ -367,6 +368,10 @@ func (a *forkOnlyUnstableAgent) Cancel(context.Context, CancelNotification) erro
return nil
}

func (a *forkOnlyUnstableAgent) CloseSession(context.Context, CloseSessionRequest) (CloseSessionResponse, error) {
return CloseSessionResponse{}, nil
}

func (a *forkOnlyUnstableAgent) NewSession(context.Context, NewSessionRequest) (NewSessionResponse, error) {
return NewSessionResponse{}, nil
}
Expand All @@ -383,6 +388,10 @@ func (a *forkOnlyUnstableAgent) ListSessions(context.Context, ListSessionsReques
return ListSessionsResponse{}, nil
}

func (a *forkOnlyUnstableAgent) ResumeSession(context.Context, ResumeSessionRequest) (ResumeSessionResponse, error) {
return ResumeSessionResponse{}, nil
}

func (a *forkOnlyUnstableAgent) SetSessionConfigOption(context.Context, SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) {
return SetSessionConfigOptionResponse{}, nil
}
Expand Down Expand Up @@ -1244,6 +1253,10 @@ func (agentNoExtensions) Initialize(ctx context.Context, params InitializeReques

func (agentNoExtensions) Cancel(ctx context.Context, params CancelNotification) error { return nil }

func (agentNoExtensions) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) {
return CloseSessionResponse{}, nil
}

func (agentNoExtensions) NewSession(ctx context.Context, params NewSessionRequest) (NewSessionResponse, error) {
return NewSessionResponse{}, nil
}
Expand All @@ -1260,6 +1273,10 @@ func (agentNoExtensions) ListSessions(ctx context.Context, params ListSessionsRe
return ListSessionsResponse{}, nil
}

func (agentNoExtensions) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) {
return ResumeSessionResponse{}, nil
}

func (agentNoExtensions) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) {
return SetSessionConfigOptionResponse{}, nil
}
Expand Down
20 changes: 4 additions & 16 deletions agent_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions example/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func (a *exampleAgent) ListSessions(ctx context.Context, params acp.ListSessions
return acp.ListSessionsResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionList)
}

// UnstableResumeSession implements acp.AgentExperimental.
func (a *exampleAgent) UnstableResumeSession(ctx context.Context, params acp.UnstableResumeSessionRequest) (acp.UnstableResumeSessionResponse, error) {
return acp.UnstableResumeSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionResume)
// ResumeSession implements acp.Agent.
func (a *exampleAgent) ResumeSession(ctx context.Context, params acp.ResumeSessionRequest) (acp.ResumeSessionResponse, error) {
return acp.ResumeSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionResume)
}

// SetSessionConfigOption implements acp.Agent.
Expand Down Expand Up @@ -136,9 +136,9 @@ func (a *exampleAgent) UnstableSetProviders(ctx context.Context, params acp.Unst
return acp.UnstableSetProvidersResponse{}, acp.NewMethodNotFound(acp.AgentMethodProvidersSet)
}

// UnstableCloseSession implements acp.AgentExperimental.
func (a *exampleAgent) UnstableCloseSession(ctx context.Context, params acp.UnstableCloseSessionRequest) (acp.UnstableCloseSessionResponse, error) {
return acp.UnstableCloseSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionClose)
// CloseSession implements acp.Agent.
func (a *exampleAgent) CloseSession(ctx context.Context, params acp.CloseSessionRequest) (acp.CloseSessionResponse, error) {
return acp.CloseSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionClose)
}

// Implement acp.AgentConnAware to receive the connection after construction.
Expand Down
10 changes: 10 additions & 0 deletions example_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ func (a *agentExample) ListSessions(ctx context.Context, params ListSessionsRequ
return ListSessionsResponse{}, nil
}

// ResumeSession implements Agent.
func (a *agentExample) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) {
return ResumeSessionResponse{}, nil
}

// CloseSession implements Agent.
func (a *agentExample) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) {
return CloseSessionResponse{}, nil
}

// SetSessionConfigOption implements Agent.
func (a *agentExample) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) {
return SetSessionConfigOptionResponse{}, nil
Expand Down
2 changes: 2 additions & 0 deletions schema/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"authenticate": "authenticate",
"initialize": "initialize",
"session_cancel": "session/cancel",
"session_close": "session/close",
"session_list": "session/list",
"session_load": "session/load",
"session_new": "session/new",
"session_prompt": "session/prompt",
"session_resume": "session/resume",
"session_set_config_option": "session/set_config_option",
"session_set_mode": "session/set_mode"
},
Expand Down
Loading