You've already forked agentic-coding-workflow
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package handlers
|
|
|
|
// session/new method types (spec §5.4 + ACP v1 schema/v1/schema.json)。
|
|
//
|
|
// mcpServers 元素是 untagged union:
|
|
// - stdio:无 type 判别字段(v1 规定;带 type 会被部分 agent 忽略),
|
|
// name/command/args/env 全必填(空数组可)
|
|
// - http / sse:type 为 "http"/"sse" 判别符,name/url/headers 必填
|
|
//
|
|
// env / headers 均为 [{name,value}] 数组(非对象)。
|
|
|
|
type SessionNewParams struct {
|
|
Cwd string `json:"cwd"`
|
|
McpServers []any `json:"mcpServers"` // McpServerStdio | McpServerHTTP
|
|
}
|
|
|
|
type SessionNewResult struct {
|
|
SessionID string `json:"sessionId"`
|
|
}
|
|
|
|
// EnvVariable / HttpHeader 是 ACP wire 的 name-value 对。
|
|
type EnvVariable struct {
|
|
Name string `json:"name"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
type HttpHeader struct {
|
|
Name string `json:"name"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
// McpServerStdio 是 stdio 传输的 MCP server(基线,所有 agent 必须支持)。
|
|
type McpServerStdio struct {
|
|
Name string `json:"name"`
|
|
Command string `json:"command"`
|
|
Args []string `json:"args"`
|
|
Env []EnvVariable `json:"env"`
|
|
}
|
|
|
|
// McpServerHTTP 是 http / sse 传输的 MCP server。Type 必须为 "http" 或 "sse",
|
|
// 仅当 agent 在 initialize 中声明对应 mcpCapabilities 时才可下发。
|
|
type McpServerHTTP struct {
|
|
Type string `json:"type"`
|
|
Name string `json:"name"`
|
|
URL string `json:"url"`
|
|
Headers []HttpHeader `json:"headers"`
|
|
}
|
|
|
|
// BuildSessionNewParams returns standard session/new params.
|
|
// servers 为 nil 时发送空数组(mcpServers 是协议必填字段)。
|
|
func BuildSessionNewParams(cwd string, servers []any) SessionNewParams {
|
|
if servers == nil {
|
|
servers = []any{}
|
|
}
|
|
return SessionNewParams{Cwd: cwd, McpServers: servers}
|
|
}
|