feat(backend): add opencode ACP (Agent Client Protocol) client
Adds a minimal but real ACP stack for the opencode process: - pkg/config: process.args default ["acp"] (opencodeCommand still "opencode") - internal/process: NewManager(command, args) — exec.Command uses args - internal/acp (new): NDJSON transport + JSON-RPC client over the existing process stdio. Implements initialize / session/new / session/prompt / session/cancel. Serves fs/read_text_file and fs/write_text_file from the workspace's fs.FileSystem. terminal/* requests get MethodNotFound. - internal/service/acp_service: per-workspace Client + mutex; starts the process on first prompt; transparently re-init on restart. - internal/api/acp_handler: GET /acp/status, GET /acp/history, POST /acp/prompt, POST /acp/cancel. - internal/model/acp: API DTOs. - internal/acp/client_test: NDJSON split-lines, request/response correlation, notification dispatch, agent-initiated request handling (fs + terminal). Existing process WS endpoint and Shell subsystem are unchanged. Conversation: 019f354c-a51b-7ec3-83ad-c647e9b50b19
This commit is contained in:
@@ -37,7 +37,8 @@ type WorkspaceConfig struct {
|
||||
|
||||
// ProcessConfig holds OpenCode process settings.
|
||||
type ProcessConfig struct {
|
||||
OpenCodeCommand string `yaml:"opencodeCommand"`
|
||||
OpenCodeCommand string `yaml:"opencodeCommand"`
|
||||
Args []string `yaml:"args"`
|
||||
}
|
||||
|
||||
// ShellConfig holds interactive shell settings.
|
||||
@@ -93,7 +94,7 @@ func Default() Config {
|
||||
MaxHeaderBytes: 1 << 20, // 1 MiB
|
||||
},
|
||||
Workspace: WorkspaceConfig{Root: "./workspaces"},
|
||||
Process: ProcessConfig{OpenCodeCommand: "opencode"},
|
||||
Process: ProcessConfig{OpenCodeCommand: "opencode", Args: []string{"acp"}},
|
||||
Shell: ShellConfig{Command: "bash", Args: []string{"-i"}},
|
||||
File: FileConfig{MaxWriteBytes: 1 << 20},
|
||||
Gin: GinConfig{Mode: "release"},
|
||||
@@ -150,6 +151,9 @@ func applyRaw(cfg *Config, raw rawConfig) error {
|
||||
if raw.Process.OpenCodeCommand != "" {
|
||||
cfg.Process.OpenCodeCommand = raw.Process.OpenCodeCommand
|
||||
}
|
||||
if raw.Process.Args != nil {
|
||||
cfg.Process.Args = raw.Process.Args
|
||||
}
|
||||
cfg.Shell.Command = raw.Shell.Command
|
||||
cfg.Shell.Args = raw.Shell.Args
|
||||
if raw.File.MaxWriteBytes != 0 {
|
||||
@@ -211,6 +215,9 @@ func applyEnv(cfg *Config) error {
|
||||
if v := os.Getenv("CODESPACE_OPENCODE_COMMAND"); v != "" {
|
||||
cfg.Process.OpenCodeCommand = v
|
||||
}
|
||||
if v := os.Getenv("CODESPACE_OPENCODE_ARGS"); v != "" {
|
||||
cfg.Process.Args = strings.Split(v, ",")
|
||||
}
|
||||
if v := os.Getenv("CODESPACE_SHELL_COMMAND"); v != "" {
|
||||
cfg.Shell.Command = v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user