Skip to content
Open
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.13.5
go get github.com/coder/acp-go-sdk@v0.13.6
```

## Get Started
Expand Down
18 changes: 13 additions & 5 deletions acp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type agentFuncs struct {
UnstableDisableProviderFunc func(context.Context, UnstableDisableProviderRequest) (UnstableDisableProviderResponse, error)
UnstableListProvidersFunc func(context.Context, UnstableListProvidersRequest) (UnstableListProvidersResponse, error)
UnstableSetProviderFunc func(context.Context, UnstableSetProviderRequest) (UnstableSetProviderResponse, error)
UnstableDeleteSessionFunc func(context.Context, UnstableDeleteSessionRequest) (UnstableDeleteSessionResponse, error)
DeleteSessionFunc func(context.Context, DeleteSessionRequest) (DeleteSessionResponse, error)
UnstableForkSessionFunc func(context.Context, UnstableForkSessionRequest) (UnstableForkSessionResponse, error)

HandleExtensionMethodFunc func(context.Context, string, json.RawMessage) (any, error)
Expand Down Expand Up @@ -337,11 +337,11 @@ func (a agentFuncs) UnstableSetProvider(ctx context.Context, params UnstableSetP
return UnstableSetProviderResponse{}, nil
}

func (a agentFuncs) UnstableDeleteSession(ctx context.Context, params UnstableDeleteSessionRequest) (UnstableDeleteSessionResponse, error) {
if a.UnstableDeleteSessionFunc != nil {
return a.UnstableDeleteSessionFunc(ctx, params)
func (a agentFuncs) DeleteSession(ctx context.Context, params DeleteSessionRequest) (DeleteSessionResponse, error) {
if a.DeleteSessionFunc != nil {
return a.DeleteSessionFunc(ctx, params)
}
return UnstableDeleteSessionResponse{}, nil
return DeleteSessionResponse{}, nil
}

func (a agentFuncs) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) {
Expand Down Expand Up @@ -399,6 +399,10 @@ func (a *forkOnlyUnstableAgent) SetSessionConfigOption(context.Context, SetSessi
return SetSessionConfigOptionResponse{}, nil
}

func (a *forkOnlyUnstableAgent) DeleteSession(context.Context, DeleteSessionRequest) (DeleteSessionResponse, error) {
return DeleteSessionResponse{}, nil
}

func (a *forkOnlyUnstableAgent) UnstableForkSession(context.Context, UnstableForkSessionRequest) (UnstableForkSessionResponse, error) {
a.called = true
return UnstableForkSessionResponse{SessionId: "forked-session"}, nil
Expand Down Expand Up @@ -1264,6 +1268,10 @@ func (agentNoExtensions) CloseSession(ctx context.Context, params CloseSessionRe
return CloseSessionResponse{}, nil
}

func (agentNoExtensions) DeleteSession(ctx context.Context, params DeleteSessionRequest) (DeleteSessionResponse, error) {
return DeleteSessionResponse{}, nil
}

func (agentNoExtensions) NewSession(ctx context.Context, params NewSessionRequest) (NewSessionResponse, error) {
return NewSessionResponse{}, nil
}
Expand Down
10 changes: 2 additions & 8 deletions agent_gen.go

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

4 changes: 2 additions & 2 deletions client_gen.go

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

6 changes: 3 additions & 3 deletions example/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func (a *exampleAgent) UnstableSetProvider(ctx context.Context, params acp.Unsta
return acp.UnstableSetProviderResponse{}, acp.NewMethodNotFound(acp.AgentMethodProvidersSet)
}

// UnstableDeleteSession implements acp.AgentExperimental.
func (a *exampleAgent) UnstableDeleteSession(ctx context.Context, params acp.UnstableDeleteSessionRequest) (acp.UnstableDeleteSessionResponse, error) {
return acp.UnstableDeleteSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionDelete)
// DeleteSession implements acp.Agent.
func (a *exampleAgent) DeleteSession(ctx context.Context, params acp.DeleteSessionRequest) (acp.DeleteSessionResponse, error) {
return acp.DeleteSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionDelete)
}

// CloseSession implements acp.Agent.
Expand Down
5 changes: 5 additions & 0 deletions example_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (a *agentExample) CloseSession(ctx context.Context, params CloseSessionRequ
return CloseSessionResponse{}, nil
}

// DeleteSession implements Agent.
func (a *agentExample) DeleteSession(ctx context.Context, params DeleteSessionRequest) (DeleteSessionResponse, error) {
return DeleteSessionResponse{}, nil
}

// SetSessionConfigOption implements Agent.
func (a *agentExample) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) {
return SetSessionConfigOptionResponse{}, nil
Expand Down
1 change: 1 addition & 0 deletions schema/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"logout": "logout",
"session_cancel": "session/cancel",
"session_close": "session/close",
"session_delete": "session/delete",
"session_list": "session/list",
"session_load": "session/load",
"session_new": "session/new",
Expand Down
158 changes: 158 additions & 0 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@
],
"title": "ListSessionsResponse"
},
{
"allOf": [
{
"$ref": "#/$defs/DeleteSessionResponse"
}
],
"title": "DeleteSessionResponse"
},
{
"allOf": [
{
Expand Down Expand Up @@ -724,6 +732,15 @@
"description": "Lists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `sessionCapabilities.list` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support.",
"title": "ListSessionsRequest"
},
{
"allOf": [
{
"$ref": "#/$defs/DeleteSessionRequest"
}
],
"description": "Deletes an existing session from `session/list`.\n\nThis method is only available if the agent advertises the `sessionCapabilities.delete` capability.",
"title": "DeleteSessionRequest"
},
{
"allOf": [
{
Expand Down Expand Up @@ -1075,11 +1092,38 @@
}
],
"description": "A single item of content"
},
"messageId": {
"anyOf": [
{
"$ref": "#/$defs/MessageId"
},
{
"type": "null"
}
],
"description": "A unique identifier for the message this chunk belongs to.\n\nAll chunks belonging to the same message share the same `messageId`.\nA change in `messageId` indicates a new message has started."
}
},
"required": ["content"],
"type": "object"
},
"Cost": {
"description": "Cost information for a session.",
"properties": {
"amount": {
"description": "Total cumulative cost for session.",
"format": "double",
"type": "number"
},
"currency": {
"description": "ISO 4217 currency code (e.g., \"USD\", \"EUR\").",
"type": "string"
}
},
"required": ["amount", "currency"],
"type": "object"
},
"CreateTerminalRequest": {
"description": "Request to create a new terminal and execute a command.",
"properties": {
Expand Down Expand Up @@ -1168,6 +1212,41 @@
"required": ["currentModeId"],
"type": "object"
},
"DeleteSessionRequest": {
"description": "Request parameters for deleting an existing session from `session/list`.\n\nOnly available if the Agent supports the `sessionCapabilities.delete` capability.",
"properties": {
"_meta": {
"additionalProperties": true,
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"type": ["object", "null"]
},
"sessionId": {
"allOf": [
{
"$ref": "#/$defs/SessionId"
}
],
"description": "The ID of the session to delete."
}
},
"required": ["sessionId"],
"type": "object",
"x-method": "session/delete",
"x-side": "agent"
},
"DeleteSessionResponse": {
"description": "Response from deleting a session.",
"properties": {
"_meta": {
"additionalProperties": true,
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"type": ["object", "null"]
}
},
"type": "object",
"x-method": "session/delete",
"x-side": "agent"
},
"Diff": {
"description": "A diff representing file modifications.\n\nShows changes to files in a format suitable for display in the client UI.\n\nSee protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)",
"properties": {
Expand Down Expand Up @@ -1915,6 +1994,10 @@
"required": ["name", "command", "args", "env"],
"type": "object"
},
"MessageId": {
"description": "Unique identifier for a message within a session.",
"type": "string"
},
"NewSessionRequest": {
"description": "Request parameters for creating a new session.\n\nSee protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)",
"properties": {
Expand Down Expand Up @@ -2618,6 +2701,18 @@
"description": "Whether the agent supports `session/close`.",
"x-deserialize-default-on-error": true
},
"delete": {
"anyOf": [
{
"$ref": "#/$defs/SessionDeleteCapabilities"
},
{
"type": "null"
}
],
"description": "Whether the agent supports `session/delete`.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports deleting sessions from `session/list`.",
"x-deserialize-default-on-error": true
},
"list": {
"anyOf": [
{
Expand Down Expand Up @@ -2857,6 +2952,17 @@
"description": "Unique identifier for a session configuration option value.",
"type": "string"
},
"SessionDeleteCapabilities": {
"description": "Capabilities for the `session/delete` method.\n\nSupplying `{}` means the agent supports deleting sessions from `session/list`.",
"properties": {
"_meta": {
"additionalProperties": true,
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"type": ["object", "null"]
}
},
"type": "object"
},
"SessionId": {
"description": "A unique identifier for a conversation session between a client and agent.\n\nSessions maintain their own context, conversation history, and state,\nallowing multiple independent interactions with the same agent.\n\nSee protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)",
"type": "string"
Expand Down Expand Up @@ -3192,6 +3298,22 @@
},
"required": ["sessionUpdate"],
"type": "object"
},
{
"allOf": [
{
"$ref": "#/$defs/UsageUpdate"
}
],
"description": "Context window and cost update for the session.",
"properties": {
"sessionUpdate": {
"const": "usage_update",
"type": "string"
}
},
"required": ["sessionUpdate"],
"type": "object"
}
]
},
Expand Down Expand Up @@ -3785,6 +3907,42 @@
"required": ["hint"],
"type": "object"
},
"UsageUpdate": {
"description": "Context window and cost update for a session.",
"properties": {
"_meta": {
"additionalProperties": true,
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"type": ["object", "null"]
},
"cost": {
"anyOf": [
{
"$ref": "#/$defs/Cost"
},
{
"type": "null"
}
],
"description": "Cumulative session cost (optional).",
"x-deserialize-default-on-error": true
},
"size": {
"description": "Total context window size in tokens.",
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"used": {
"description": "Tokens currently in context.",
"format": "uint64",
"minimum": 0,
"type": "integer"
}
},
"required": ["used", "size"],
"type": "object"
},
"WaitForTerminalExitRequest": {
"description": "Request to wait for a terminal command to exit.",
"properties": {
Expand Down
Loading