ci / vet-and-test (pull_request) Successful in 41s
Why: N1 increment three host side - plugin agent assets must reject hooks/mcp/permissionMode declarations (WP1 acceptance), and squad members need the kernel ask port wired to the HITL card (WP4). Evidence: go vet clean; go test ./... 29 packages ok, including new agent-asset tests (banned keys located to the field, unknown keys, missing id) and the V2 asset suite. Nested pins at native c5b9dca (PR #18) and squad fc9620e (PR #17). Impact: plugins agents/ assets now parse via parseAgentAsset (strict JSON with banned-key rejection); PermissionAskOf exported and takes any host with the optional method; app.go wires cfg.PermissionAsk for the squad path. Legacy behavior unchanged when nothing registers the port. Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md WP1/WP4
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package plugins
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
core "agent-system-core"
|
|
)
|
|
|
|
// agentBannedKeys 是插件代理声明禁带的键:钩子、MCP 与权限模式归宿主与
|
|
// 基座,插件画像只能声明身份与工具面(N1 WP1 验收条款)。
|
|
var agentBannedKeys = map[string]bool{
|
|
"hooks": true,
|
|
"mcp": true,
|
|
"permissionMode": true,
|
|
}
|
|
|
|
// parseAgentAsset 解析 agents/ 资产:禁带键定位到字段、未知键拒绝、
|
|
// id 必填。任一违规由调用方整批拒绝该插件(fail-closed)。
|
|
func parseAgentAsset(raw []byte) (core.PluginAgentDecl, error) {
|
|
var probe map[string]json.RawMessage
|
|
if err := json.Unmarshal(raw, &probe); err != nil {
|
|
return core.PluginAgentDecl{}, fmt.Errorf("agent json: %w", err)
|
|
}
|
|
for key := range probe {
|
|
if agentBannedKeys[key] {
|
|
return core.PluginAgentDecl{}, fmt.Errorf("插件代理不得声明 %s", key)
|
|
}
|
|
}
|
|
dec := json.NewDecoder(bytes.NewReader(raw))
|
|
dec.DisallowUnknownFields()
|
|
var item core.PluginAgentDecl
|
|
if err := dec.Decode(&item); err != nil {
|
|
return core.PluginAgentDecl{}, fmt.Errorf("agent json: %w", err)
|
|
}
|
|
if item.ID == "" {
|
|
return core.PluginAgentDecl{}, fmt.Errorf("agent missing id")
|
|
}
|
|
return item, nil
|
|
}
|