9e538d2809
二、门禁与唤醒(新插件 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,记录绑定机制、存量成员缺口与「成员自省不可全信」的
台架教训。
109 lines
5.6 KiB
JavaScript
109 lines
5.6 KiB
JavaScript
/**
|
|
* Cordis composition-entry Config for `subagent-roles`.
|
|
*
|
|
* Every knob is a plugin-row concern; per-role facts (route, tools, persona)
|
|
* live in the role FILES, never here. Defaults are the recommended values, so
|
|
* a deployment normally mounts the row with no config at all.
|
|
*/
|
|
import z from '@deepseek-ai/schemastery'
|
|
import { DEFAULT_CHILD_NAMES } from './trim.js'
|
|
import { PERSONA_VARIABLES } from './roles.js'
|
|
|
|
/** Schemastery schema for the row config. */
|
|
export const Config = z.object({
|
|
/** Model-facing delegation tool name (kept as `subagent_role` for compatibility). */
|
|
toolName: z.string().min(1).default('subagent_role'),
|
|
/** Subagent transport provider registered on `ctx.subagents`. */
|
|
subagentProvider: z.string().min(1).default('spawn'),
|
|
/** Background mode: one-shot waits for the result; continuable returns the durable child id. */
|
|
backgroundMode: z.union(['one-shot', 'continuable']).default('one-shot'),
|
|
/** Whether the tool exposes `run_in_background`. */
|
|
enableRunInBackground: z.boolean().default(true),
|
|
/**
|
|
* Optional numeric delegation-depth cap; omit for provider-managed. Note that
|
|
* `0` is accepted and means "no delegation at all": a child's depth starts at
|
|
* 1, so the core rejects every start with a depth error.
|
|
*/
|
|
maxDepth: z.union([z.natural().max(Number.MAX_SAFE_INTEGER), z.const('provider-managed')]),
|
|
/** Role id used when a call omits `role`. */
|
|
defaultRole: z.string(),
|
|
/** `compact` renders the role catalog section; `off` renders nothing. */
|
|
catalog: z.union(['compact', 'off']).default('compact'),
|
|
/** `main` advertises roles to top-level agents only; `all` includes subagents. */
|
|
catalogScope: z.union(['main', 'all']).default('main'),
|
|
/** Per-role description cap inside the catalog line. */
|
|
catalogDescriptionMaxLength: z.natural().min(16).default(160),
|
|
/** Project-root markers searched upward from the session cwd. */
|
|
projectRootMarkers: z.array(z.string()).default(['.git']),
|
|
/**
|
|
* How long a resolved project root is trusted before the tree is re-walked, in
|
|
* milliseconds. Bounded so a `git init` under a live session is noticed.
|
|
*/
|
|
projectRootTtlMs: z.natural().default(5000),
|
|
/** Harness home holding the global `roles/` directory. */
|
|
dshHome: z.string(),
|
|
/** Persona size guard, in bytes. */
|
|
maxBodyBytes: z.natural().min(1).default(65536),
|
|
/**
|
|
* Prompt variables a persona body may reference. Defaults to the three the
|
|
* agent loop registers (`cwd`, `model`, `provider`); extend this only when the
|
|
* deployment really registers more, because an unknown reference throws on
|
|
* EVERY turn of the child that uses it.
|
|
*/
|
|
personaVariables: z.array(z.string()).default([...PERSONA_VARIABLES]),
|
|
/** Honor the official `subagent-model-selection` authorized model list. */
|
|
respectModelSelection: z.boolean().default(true),
|
|
/** Unknown-filter-name posture: `drop` warns and continues, `error` refuses before starting. */
|
|
onMissingTool: z.union(['drop', 'error']).default('drop'),
|
|
/**
|
|
* Tool-call deadline for one foreground delegation, in milliseconds. Unset
|
|
* leaves the call unbounded; a background delegation returns immediately and is
|
|
* never subject to it.
|
|
*/
|
|
timeoutMs: z.natural().min(1),
|
|
/**
|
|
* Tool calls a child may make when its role file declares no `maxToolCalls`.
|
|
* `0` means unlimited, and stays the default on purpose: 2,277 files and 26k
|
|
* symbols do not define "a reasonable call count" the way a small project
|
|
* does, so the budget belongs in the role file rather than in a global number
|
|
* baked in here.
|
|
*/
|
|
defaultMaxToolCalls: z.natural().default(0),
|
|
/**
|
|
* Ceiling a role file may not exceed, so a project cannot open a budget to a
|
|
* meaningless size. `0` disables the ceiling — and deliberately does NOT clamp
|
|
* a `maxToolCalls: 0` "unlimited" declaration, which is a sentinel rather than
|
|
* a count.
|
|
*/
|
|
maxToolCallsHardCap: z.natural().default(0),
|
|
/** What happens when a child exhausts its tool-call budget; a role file may override. */
|
|
onToolCallBudget: z.union(['interrupt', 'wrap-up', 'off']).default('wrap-up'),
|
|
/** Extra tool calls `wrap-up` tolerates after injecting its wrap-up notice. */
|
|
graceToolCalls: z.natural().default(1),
|
|
/** Opt-in `subagent_roles` diagnostic tool. */
|
|
enableListTool: z.boolean().default(false),
|
|
/** Name of the diagnostic tool, so a second row can coexist with the first. */
|
|
listToolName: z.string().min(1).default('subagent_roles'),
|
|
/**
|
|
* Child-prompt trimming. Core registers most tool-guidance sections as plain
|
|
* text, so a child keeps paying for guidance whose tool the role's policy hid
|
|
* from it, plus the Web GUI, harness-checkout, and deliverable instructions it
|
|
* can never act on. `full` (the default) drops all of that: `tool:<name>`
|
|
* guidance for a registered tool the child cannot call, group guidance whose
|
|
* tools are all invisible there, and the named prompt parts below. `tools`
|
|
* keeps the named parts; `off` disables the listener. Only SUBAGENT
|
|
* assemblies are touched — a top-level agent's prompt is left exactly as
|
|
* composed.
|
|
*/
|
|
childPromptTrim: z.union(['off', 'tools', 'full']).default('full'),
|
|
/**
|
|
* Prompt parts `full` mode drops from a child prompt, matched against sections
|
|
* AND contexts (core registers `context:file-reference` as a section despite
|
|
* its name). Defaults are the four core parts registered without a scope
|
|
* guard; a renamed part simply stops being trimmed, which is the safe
|
|
* direction. Empty the list to keep them all — one deployment may want the
|
|
* harness-checkout line in its children.
|
|
*/
|
|
childPromptTrimNames: z.array(z.string()).default([...DEFAULT_CHILD_NAMES]),
|
|
})
|