// Package handlers 实现 ACP method 的服务端处理器。 // // 每个 file 一个具体 method handler,对应 spec §5.5: // - server_fs_read.go fs/read_text_file // - server_fs_write.go fs/write_text_file // - server_permission.go session/request_permission(MVP 自动批/拒) // // client_*.go 是服务端 *发起* 请求的辅助 builder(initialize / session/new), // 不需要 Handle 接口,直接被 supervisor / relay 调用 NewClientInitializeRequest 等。 package handlers import ( "encoding/json" "github.com/google/uuid" ) // SessionContext 是 handler 可见的 session 上下文(dirent 化 acp.Session 的需要字段)。 // 避免 handlers 子包 import internal/acp 引发循环。 type SessionContext struct { SessionID uuid.UUID WorkspaceID uuid.UUID UserID uuid.UUID CwdPath string AgentSessionID *string // 可能 nil(handshake 未完成时不应触发 fs/* 但兜底) } // FsResult 是 fs/* method 处理后返回给 relay 的结果。要么 OK(带 result), // 要么 Err(带 jsonrpc 错误码)。 type FsResult struct { OK json.RawMessage Err *FsError } // FsError 是 jsonrpc 错误码(spec §5.4 定义 -32001 = path outside worktree)。 type FsError struct { Code int Message string } // FsHandler is the placeholder for fs/read_text_file + fs/write_text_file. // Fields and methods are added in Task D4. type FsHandler struct{} // PermissionHandler is the placeholder for session/request_permission. // Fields and methods are added in Task D5. type PermissionHandler struct{}