Files
STM32F4-Base/.dsh/plugins/dsh-plugin-subagent-roles/lib/route.js
T
wandering1 9e538d2809
CI / 静态门禁 (pre-commit) (push) Failing after 43s
CI / 主机侧单测 (MSVC) (push) Failing after 24s
feat(dsh): 门禁账本插件接入 + 角色绑定跨重启还原
二、门禁与唤醒(新插件 dsh-plugin-team-ledger 0.2.0)
宿主 Agent Teams 缺两块能力,补在独立仓
D:/Code/AI/dsh-plugin-team-ledger:

- 状态存放:<工作区>/.dsh/team/gate.jsonl 追加账本,记验收
  清单、实测证据、认领历史,跨重启存活;canonical JSON +
  fsync,坏尾行截断恢复。
- 唤醒模型:门禁推进后按事件计划唤醒下一责任人,借活体
  Lead 作 caller 走宿主 sendMessage;无定时器;30 分钟滑动
  窗口限 4 次防复活风暴。
- 验收独立性由机器强制:执行人/历史认领者不能 accept,
  checklist 逐项 passed=true 缺一不可。
- team_member_revive(Lead 专用):成员模型路由死亡后的
  复活通道——可换 provider/model,再经 subagents.sendMessage
  冷恢复唤醒,绕过宿主 roster 的 phase=active 门禁。

二、角色绑定跨重启还原(roles fork 0.5.2)
persona 与工具白名单只有运行中 agent 的内存态,宿主重启后
冷恢复的成员既无 persona 也无白名单——实测出现 doc-writer
成员带全量工具面(qq_*/ImageGen),属静默权限放大。改为
注入成功时持久化 childId -> {roleId, cwd} 到
~/.dsh/role-inject-bindings.json,并在 agent/created 时重放。
追加 team_member_rebind 补绑定,覆盖 0.5.2 之前已存在的成员。

三、配套
- .dsh/roles 八个角色白名单加入门禁工具;AGENTS.md 委派策略
  补门禁/复活/重绑三套操作口径。
- docs/环境与部署/子Agent角色自动注入实现说明.md 新增
  §5.1,记录绑定机制、存量成员缺口与「成员自省不可全信」的
  台架教训。
2026-11-16 00:42:51 +08:00

67 lines
3.0 KiB
JavaScript

/**
* Route resolution for one role delegation.
*
* The role FILE is the only route source (the tool exposes no per-call
* provider/model overrides). When the official `subagent-model-selection`
* section is enabled with an authorized list, a role route outside it is
* dropped so the child inherits the parent's model — never silently swapped
* for a different authorized route. The role's `reasoningEffort` rides only
* with an admitted route: it belongs to that model's vocabulary.
*/
/**
* Whether a provider/model pair is admitted by an authorized route list.
* An absent or empty list admits everything; with a list, only an exact pair
* is admitted (a partial route cannot be).
* @param route - `{ provider?, model? }`.
* @param allowedRoutes - the authorized list, if any.
* @returns whether the route is admitted.
*/
export function isRouteAllowed(route, allowedRoutes) {
if (allowedRoutes === undefined || allowedRoutes.length === 0) return true
if (route.provider === undefined || route.model === undefined) return false
return allowedRoutes.some((entry) => entry.provider === route.provider && entry.model === route.model)
}
/**
* Resolve the child's AgentOptions from one role.
*
* The role's `reasoningEffort` rides only with an admitted route OR when the
* role declares no route at all: an effort is part of the model vocabulary it
* was chosen for, so a route dropped by the authorized-list constraint takes
* its effort with it.
* @param input - the role and the authorized route list.
* @returns `{ agentOptions?, layer, warnings }`.
*/
export function resolveRoleRoute(input) {
const { role, allowedRoutes } = input
const warnings = []
const provider = role?.provider
const model = role?.model
let effort = role?.reasoningEffort
const routeDeclared = provider !== undefined || model !== undefined
let admitted = routeDeclared
if (routeDeclared && !isRouteAllowed({ provider, model }, allowedRoutes)) {
admitted = false
const described = provider !== undefined && model !== undefined ? `${provider}/${model}` : String(provider ?? model)
warnings.push(`subagent-roles: role "${role?.id ?? 'unknown'}" binds LLM route ${described} which is not in the authorized model list (subagent-model-selection.allowedModels); the route and its reasoning effort were dropped and the subagent inherits the parent model`)
effort = undefined
}
const agentOptions = {
...(admitted && provider !== undefined ? { provider } : {}),
...(admitted && model !== undefined ? { model } : {}),
...(effort !== undefined ? { reasoningEffort: effort } : {}),
}
const defined = Object.keys(agentOptions).length > 0
return {
...(defined ? { agentOptions } : {}),
layer: admitted && routeDeclared ? 'role' : 'inherit',
/**
* A route the role DID bind but the authorized list rejected. It must never
* be quietly replaced by a provider's own route defaults: the list said no.
*/
dropped: routeDeclared && !admitted,
warnings,
}
}