You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terminal-based authentication method.
The client runs the configured agent program as a separate interactive process for the user to authenticate via a TUI. Agents MUST advertise this method only when the client enabled its terminal authentication capability.
A zero exit status signals success; any other termination signals failure. The client MUST NOT pass this method to authenticate.
同节说明 AuthMethod 是判别联合,type 缺省视为 agent:
AuthMethod
Describes an available authentication method.
The type field acts as the discriminator in the serialized JSON form.
When no type is present, the method is treated as agent.
结论
挑选认证方法时只判
Id非空、完全不读Type,因此一旦 agent 广告了type: "terminal"的认证方法,我们会把它当普通方法塞进authenticate调用——而规范明确写着 client MUST NOT 这么做。这是一处 fail-open。证据链
1. 规范:终端认证方法禁止传给
authenticatev1 schema
## AuthMethodTerminal(/tmp/acp-v1-schema.md:1963)原文:同节说明
AuthMethod是判别联合,type缺省视为agent:2. 我们的选择逻辑不看
Typesrc/SalmonEgg.Presentation.Core/ViewModels/Chat/ChatAuthenticationCoordinator.cs:176-177:调用点
ChatAuthenticationCoordinator.cs:118-141——挑到就直接发authenticate,中间没有任何Type过滤:3.
Type字段本身是存在的——只是没人读src/SalmonEgg.Acp/Protocol/AuthMethodTypes.cs:25:序列化侧也已按规范处理缺省(
InitializeTypes.cs:1141):即:建模层做对了,消费层漏了判别。
4. 为什么现在还没炸:靠对端自律,不是靠我们
规范说 agent 只应在 client 广告了终端认证能力时才发 terminal 方法。我们的
ClientCapabilities没有auth字段(src/SalmonEgg.Acp/Protocol/InitializeTypes.cs:107-126仅fs/terminal/session),所以守规矩的 agent 不会发。但这构成 fail-open 而非 fail-closed:
AuthCapabilities.terminal默认false,缺省语义等价于「不支持」,因此不广告本身没错;影响
authenticate调用。最好的情况是 agent 回错误、用户看到一条无可操作性的失败提示;坏的情况是走进未定义行为。建议范围
两件事,可分两步做,第一步是止血:
GetPrimaryAuthMethod()增加判别——只接受Type为空或"agent"的方法。遇到terminal或未知非_前缀类型时,不得塞进authenticate,改为走「需要认证但当前无可用方法」分支(该分支已存在,见:121-127)并给出可操作提示。ClientCapabilities.auth.terminal广告、按AuthMethodTerminal的args/env在配置好的 agent 启动命令上追加参数并以交互式终端拉起、以退出码 0 判定成功。这一步依赖交互式终端承载能力,与 issue 中的_interaction/ 终端族现状有关联,宜单独评估。验证要求
type: "terminal"的假 agent:断言我们没有发出authenticate(断言线上报文,不只断言返回值)。type(如"_vendor_x"与"future_thing")的假 agent:同样不得发出authenticate。type(无该字段)仍按agent正常走通,避免修过头把正常路堵死。