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
50 changes: 50 additions & 0 deletions cmd/root/acp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package root

import (
"log/slog"
"os"

acpsdk "github.com/coder/acp-go-sdk"
"github.com/spf13/cobra"

"github.com/docker/cagent/pkg/acp"
"github.com/docker/cagent/pkg/telemetry"
)

// NewACPCmd creates a new acp command
func NewACPCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "acp <agent-file>",
Short: "Start an ACP (Agent Client Protocol) server",
Long: `Start an ACP server that exposes the agent via the Agent Client Protocol`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
telemetry.TrackCommand("acp", args)
return runACP(cmd, args)
},
}

addGatewayFlags(cmd)
addRuntimeConfigFlags(cmd)

return cmd
}

func runACP(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
agentFilename := args[0]

slog.Debug("Starting ACP server", "agent_file", agentFilename, "debug_mode", debugMode)

acpAgent := acp.NewAgent(agentFilename, runConfig)
conn := acpsdk.NewAgentSideConnection(acpAgent, os.Stdout, os.Stdin)
conn.SetLogger(slog.Default())
acpAgent.SetAgentConnection(conn)
defer acpAgent.Stop(ctx)

slog.Debug("acp started, waiting for conn")

<-conn.Done()

return nil
}
1 change: 1 addition & 0 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func NewRootCmd() *cobra.Command {
cmd.AddCommand(NewExecCmd())
cmd.AddCommand(NewNewCmd())
cmd.AddCommand(NewAPICmd())
cmd.AddCommand(NewACPCmd())
cmd.AddCommand(NewEvalCmd())
cmd.AddCommand(NewPushCmd())
cmd.AddCommand(NewPullCmd())
Expand Down
3 changes: 3 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ $ cagent exec config.yaml --yolo # Run the agent once and auto-accept a
$ cagent api config.yaml
$ cagent api config.yaml --listen :8080

# ACP Server (Agent Client Protocol via stdio)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here we could add a brief mention of what its for, and a link to https://agentclientprotocol.com/overview/introduction?

$ cagent acp config.yaml # Start ACP server on stdio

# Other commands
$ cagent new # Initialize new project
$ cagent new --model openai/gpt-5-mini --max-tokens 32000 # Override max tokens during generation
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/charmbracelet/bubbletea/v2 v2.0.0-beta.4.0.20250930175933-4cafc092c5e7
github.com/charmbracelet/glamour/v2 v2.0.0-20250811143442-a27abb32f018
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250917201909-41ff0bf215ea
github.com/coder/acp-go-sdk v0.4.9
github.com/dop251/goja v0.0.0-20251008123653-cf18d89f3cf6
github.com/fatih/color v1.18.0
github.com/goccy/go-yaml v1.18.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/coder/acp-go-sdk v0.4.9 h1:F4sKT2up4sMqNYt6yt2L9g4MaE09VPgt3eRqDFnoY5k=
github.com/coder/acp-go-sdk v0.4.9/go.mod h1:yKzM/3R9uELp4+nBAwwtkS0aN1FOFjo11CNPy37yFko=
github.com/containerd/stargz-snapshotter/estargz v0.17.0 h1:+TyQIsR/zSFI1Rm31EQBwpAA1ovYgIKHy7kctL3sLcE=
github.com/containerd/stargz-snapshotter/estargz v0.17.0/go.mod h1:s06tWAiJcXQo9/8AReBCIo/QxcXFZ2n4qfsRnpl71SM=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
Expand Down
Loading
Loading