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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ version: README.md schema/meta.json schema/schema.json
echo $(ACP_VERSION) > $@

schema/meta.json: schema/version
curl -o $@ --fail -L https://raw.githubusercontent.com/agentclientprotocol/agent-client-protocol/refs/tags/v$(ACP_VERSION)/schema/meta.json
curl -o $@ --fail -L https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/meta.json

schema/schema.json: schema/version
curl -o $@ --fail -L https://raw.githubusercontent.com/agentclientprotocol/agent-client-protocol/refs/tags/v$(ACP_VERSION)/schema/schema.json
curl -o $@ --fail -L https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/schema.json

README.md: schema/version
@command -v $(MDSH) >/dev/null || { echo "mdsh not found; run 'nix develop' or install it." 1>&2; exit 1; }
Expand Down
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/[email protected].5
go get github.com/coder/[email protected].9
```

## Get Started
Expand Down
52 changes: 44 additions & 8 deletions cmd/generate/internal/emit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ func WriteTypesJen(outDir string, schema *load.Schema, meta *load.Meta) error {
case ir.BindAgentExperimental:
target = &agentExperimentalMethods
}
if desc := methodDescription(schema, mi); desc != "" {
*target = append(*target, Comment(util.SanitizeComment(desc)))
}
if mi.Notif != "" {
name := ir.DispatchMethodNameForNotification(k, mi.Notif)
*target = append(*target, Id(name).Params(Id("ctx").Qual("context", "Context"), Id("params").Id(mi.Notif)).Error())
Expand Down Expand Up @@ -276,6 +279,9 @@ func WriteTypesJen(outDir string, schema *load.Schema, meta *load.Meta) error {
case ir.BindClientTerminal:
target = &clientTerminal
}
if desc := methodDescription(schema, mi); desc != "" {
*target = append(*target, Comment(util.SanitizeComment(desc)))
}
if mi.Notif != "" {
name := ir.DispatchMethodNameForNotification(k, mi.Notif)
*target = append(*target, Id(name).Params(Id("ctx").Qual("context", "Context"), Id("params").Id(mi.Notif)).Error())
Expand Down Expand Up @@ -359,6 +365,23 @@ func emitValidateJen(f *File, name string, def *load.Definition) {
}
}

func methodDescription(schema *load.Schema, mi *ir.MethodInfo) string {
if mi == nil || mi.DocsIgnored {
return ""
}
// Prefer notification descriptions when present, otherwise fall back to request/response types.
ordered := []string{mi.Notif, mi.Req, mi.Resp}
for _, name := range ordered {
if name == "" {
continue
}
if def := schema.Defs[name]; def != nil && def.Description != "" {
return def.Description
}
}
return ""
}

// Type mapping helpers (unchanged behavior vs original)
func primitiveJenType(t string) Code {
switch t {
Expand Down Expand Up @@ -523,13 +546,14 @@ func jenTypeForOptional(d *load.Definition) Code {
// (title: UnstructuredCommandInput) with a required 'hint' field.
func emitUnion(f *File, name string, defs []*load.Definition, exactlyOne bool) {
type variantInfo struct {
fieldName string
typeName string
required []string
isObject bool
discValue string
constPairs [][2]string
isNull bool
fieldName string
typeName string
required []string
isObject bool
discValue string
constPairs [][2]string
isNull bool
description string
}
variants := []variantInfo{}
discKey := ""
Expand Down Expand Up @@ -630,11 +654,23 @@ func emitUnion(f *File, name string, defs []*load.Definition, exactlyOne bool) {
f.Type().Id(tname).Struct(st...)
f.Line()
}
variants = append(variants, variantInfo{fieldName: fieldName, typeName: tname, required: v.Required, isObject: isObj, discValue: dv, constPairs: consts, isNull: isNull})
variants = append(variants, variantInfo{
fieldName: fieldName,
typeName: tname,
required: v.Required,
isObject: isObj,
discValue: dv,
constPairs: consts,
isNull: isNull,
description: v.Description,
})
}
// wrapper
st := []Code{}
for _, vi := range variants {
if vi.description != "" {
st = append(st, Comment(util.SanitizeComment(vi.description)))
}
st = append(st, Id(vi.fieldName).Op("*").Id(vi.typeName).Tag(map[string]string{"json": "-"}))
}
f.Type().Id(name).Struct(st...)
Expand Down
21 changes: 21 additions & 0 deletions schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
"anyOf": [
{
"$ref": "#/$defs/SessionNotification",
"description": "Handles session update notifications from the agent.\n\nThis is a notification endpoint (no response expected) that receives\nreal-time updates about session progress, including message chunks,\ntool calls, and execution plans.\n\nNote: Clients SHOULD continue accepting tool call updates even after\nsending a `session/cancel` notification, as the agent may send final\nupdates before responding with the cancelled stop reason.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)",
"title": "SessionNotification"
},
{
"description": "Handles extension notifications from the agent.\n\nAllows the Agent to send an arbitrary notification that is not part of the ACP spec.\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"title": "ExtNotification"
}
],
Expand All @@ -48,37 +50,46 @@
"anyOf": [
{
"$ref": "#/$defs/WriteTextFileRequest",
"description": "Writes content to a text file in the client's file system.\n\nOnly available if the client advertises the `fs.writeTextFile` capability.\nAllows the agent to create or modify files within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)",
"title": "WriteTextFileRequest"
},
{
"$ref": "#/$defs/ReadTextFileRequest",
"description": "Reads content from a text file in the client's file system.\n\nOnly available if the client advertises the `fs.readTextFile` capability.\nAllows the agent to access file contents within the client's environment.\n\nSee protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)",
"title": "ReadTextFileRequest"
},
{
"$ref": "#/$defs/RequestPermissionRequest",
"description": "Requests permission from the user for a tool call operation.\n\nCalled by the agent when it needs user authorization before executing\na potentially sensitive operation. The client should present the options\nto the user and return their decision.\n\nIf the client cancels the prompt turn via `session/cancel`, it MUST\nrespond to this request with `RequestPermissionOutcome::Cancelled`.\n\nSee protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)",
"title": "RequestPermissionRequest"
},
{
"$ref": "#/$defs/CreateTerminalRequest",
"description": "Executes a command in a new terminal\n\nOnly available if the `terminal` Client capability is set to `true`.\n\nReturns a `TerminalId` that can be used with other terminal methods\nto get the current output, wait for exit, and kill the command.\n\nThe `TerminalId` can also be used to embed the terminal in a tool call\nby using the `ToolCallContent::Terminal` variant.\n\nThe Agent is responsible for releasing the terminal by using the `terminal/release`\nmethod.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)",
"title": "CreateTerminalRequest"
},
{
"$ref": "#/$defs/TerminalOutputRequest",
"description": "Gets the terminal output and exit status\n\nReturns the current content in the terminal without waiting for the command to exit.\nIf the command has already exited, the exit status is included.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)",
"title": "TerminalOutputRequest"
},
{
"$ref": "#/$defs/ReleaseTerminalRequest",
"description": "Releases a terminal\n\nThe command is killed if it hasn't exited yet. Use `terminal/wait_for_exit`\nto wait for the command to exit before releasing the terminal.\n\nAfter release, the `TerminalId` can no longer be used with other `terminal/*` methods,\nbut tool calls that already contain it, continue to display its output.\n\nThe `terminal/kill` method can be used to terminate the command without releasing\nthe terminal, allowing the Agent to call `terminal/output` and other methods.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)",
"title": "ReleaseTerminalRequest"
},
{
"$ref": "#/$defs/WaitForTerminalExitRequest",
"description": "Waits for the terminal command to exit and return its exit status\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)",
"title": "WaitForTerminalExitRequest"
},
{
"$ref": "#/$defs/KillTerminalCommandRequest",
"description": "Kills the terminal command without releasing the terminal\n\nWhile `terminal/release` will also kill the command, this method will keep\nthe `TerminalId` valid so it can be used with other methods.\n\nThis method can be helpful when implementing command timeouts which terminate\nthe command as soon as elapsed, and then get the final output so it can be sent\nto the model.\n\nNote: `terminal/release` when `TerminalId` is no longer needed.\n\nSee protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)",
"title": "KillTerminalCommandRequest"
},
{
"description": "Handles extension method requests from the agent.\n\nAllows the Agent to send an arbitrary request that is not part of the ACP spec.\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"title": "ExtMethodRequest"
}
],
Expand Down Expand Up @@ -330,9 +341,11 @@
"anyOf": [
{
"$ref": "#/$defs/CancelNotification",
"description": "Cancels ongoing operations for a session.\n\nThis is a notification sent by the client to cancel an ongoing prompt turn.\n\nUpon receiving this notification, the Agent SHOULD:\n- Stop all language model requests as soon as possible\n- Abort all tool call invocations in progress\n- Send any pending `session/update` notifications\n- Respond to the original `session/prompt` request with `StopReason::Cancelled`\n\nSee protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)",
"title": "CancelNotification"
},
{
"description": "Handles extension notifications from the client.\n\nExtension notifications provide a way to send one-way messages for custom functionality\nwhile maintaining protocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"title": "ExtNotification"
}
],
Expand All @@ -343,33 +356,41 @@
"anyOf": [
{
"$ref": "#/$defs/InitializeRequest",
"description": "Establishes the connection with a client and negotiates protocol capabilities.\n\nThis method is called once at the beginning of the connection to:\n- Negotiate the protocol version to use\n- Exchange capability information between client and agent\n- Determine available authentication methods\n\nThe agent should respond with its supported protocol version and capabilities.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)",
"title": "InitializeRequest"
},
{
"$ref": "#/$defs/AuthenticateRequest",
"description": "Authenticates the client using the specified authentication method.\n\nCalled when the agent requires authentication before allowing session creation.\nThe client provides the authentication method ID that was advertised during initialization.\n\nAfter successful authentication, the client can proceed to create sessions with\n`new_session` without receiving an `auth_required` error.\n\nSee protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)",
"title": "AuthenticateRequest"
},
{
"$ref": "#/$defs/NewSessionRequest",
"description": "Creates a new conversation session with the agent.\n\nSessions represent independent conversation contexts with their own history and state.\n\nThe agent should:\n- Create a new session context\n- Connect to any specified MCP servers\n- Return a unique session ID for future requests\n\nMay return an `auth_required` error if the agent requires authentication.\n\nSee protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)",
"title": "NewSessionRequest"
},
{
"$ref": "#/$defs/LoadSessionRequest",
"description": "Loads an existing session to resume a previous conversation.\n\nThis method is only available if the agent advertises the `loadSession` capability.\n\nThe agent should:\n- Restore the session context and conversation history\n- Connect to the specified MCP servers\n- Stream the entire conversation history back to the client via notifications\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)",
"title": "LoadSessionRequest"
},
{
"$ref": "#/$defs/SetSessionModeRequest",
"description": "Sets the current mode for a session.\n\nAllows switching between different agent modes (e.g., \"ask\", \"architect\", \"code\")\nthat affect system prompts, tool availability, and permission behaviors.\n\nThe mode must be one of the modes advertised in `availableModes` during session\ncreation or loading. Agents may also change modes autonomously and notify the\nclient via `current_mode_update` notifications.\n\nThis method can be called at any time during a session, whether the Agent is\nidle or actively generating a response.\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)",
"title": "SetSessionModeRequest"
},
{
"$ref": "#/$defs/PromptRequest",
"description": "Processes a user prompt within a session.\n\nThis method handles the whole lifecycle of a prompt:\n- Receives user messages with optional context (files, images, etc.)\n- Processes the prompt using language models\n- Reports language model content and tool calls to the Clients\n- Requests permission to run tools\n- Executes any requested tool calls\n- Returns when the turn is complete with a stop reason\n\nSee protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)",
"title": "PromptRequest"
},
{
"$ref": "#/$defs/SetSessionModelRequest",
"description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSelect a model for a given session.",
"title": "SetSessionModelRequest"
},
{
"description": "Handles extension method requests from the client.\n\nExtension methods provide a way to add custom functionality while maintaining\nprotocol compatibility.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"title": "ExtMethodRequest"
}
],
Expand Down
2 changes: 1 addition & 1 deletion schema/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.5
0.4.9
Loading