@ai-agent-forge/plugin-subagent-delegate 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agent-forge.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "packageFormatVersion": 1,
3
3
  "id": "agent-forge.plugin.subagent-delegate",
4
- "pluginVersion": "0.87.0",
4
+ "pluginVersion": "0.88.0",
5
5
  "apiVersion": "1",
6
6
  "minHostVersion": "0.84.4",
7
7
  "platform": {
@@ -1,4 +1,4 @@
1
- import { type AgentTaskAdapter, type AgentTaskChildProfileV1, type CapabilityAPI, type DisposableRegistration, type SubagentCommunicationWiringV1 } from "@agent-forge/plugin-sdk";
1
+ import { type AgentTaskAdapter, type AgentTaskChildProfileV1, type CapabilityAPI, type DisposableRegistration, type LoggerAPI, type SessionAPI, type SubagentCommunicationWiringV1 } from "@agent-forge/plugin-sdk";
2
2
  import { type SubagentRunnerSpawnHandleV1 } from "./runner-pool.ts";
3
3
  import { type SubagentRuntimeLimitsV1, type SubagentRuntimeStatus } from "./subagent-runtime.ts";
4
4
  export declare const capabilityManifest: {
@@ -85,6 +85,10 @@ export type SubagentDelegateErrorCodesV1 = "subagent_invalid_input" | "subagent_
85
85
  | "subagent_depth_exceeded"
86
86
  /** 本会话累计创建的子代理达到每父级总量上限(提交侧执行)。 */
87
87
  | "subagent_child_quota"
88
+ /** 会话角色与当前可见磁盘角色撞名:磁盘角色是用户资产,会话不隐式改写其含义(改用其他 id)。 */
89
+ | "subagent_role_conflict"
90
+ /** 会话角色超过既有硬上限(16 个 / 菜单 ≤2000 字符,磁盘+会话合并计算):拒绝注册并提示精简。 */
91
+ | "subagent_role_quota"
88
92
  /** submit 同步拒绝且无结构化 code 时的本地兜底码(与投影 reasonCode 同名)。 */
89
93
  | "subagent_submit_rejected";
90
94
  export declare class SubagentDelegateError extends Error {
@@ -194,6 +198,100 @@ export interface SubagentRoleCatalogResolutionV1 {
194
198
  /** 未被关联、但用户文件非法的角色文件:只在被关联时才致命,这里记录用于诊断。 */
195
199
  readonly brokenUnassociated: readonly string[];
196
200
  }
201
+ /**
202
+ * 会话角色快照条目的 customType(跨插件契约,workflow 软校验按此字面量读取):
203
+ * data = `{ version: 1, roles: [...] }` **全量快照**、append-only;恢复时反向扫描
204
+ * 最近一条可解析快照(与 goal/plan/todo/workflow 的 loadState 同构)。压缩只影响
205
+ * LLM 上下文投影,`getBranchEntries` 始终返回完整分支,按分支重建因此压缩安全。
206
+ */
207
+ export declare const SESSION_ROLE_STATE_ENTRY: "subagent.roles.state";
208
+ /**
209
+ * 快照里的单个角色:与角色文件同构的**平铺定义** + id(文件形态的 id 来自文件名,
210
+ * 条目里必须自带)。收窄字段平铺为 model/thinkingLevel/tools/mode/systemPromptAppend,
211
+ * 载入内存时仍归一化为 `SubagentDelegateRoleV1`(profile 嵌套形态)。
212
+ */
213
+ export interface SubagentSessionRoleRecordV1 {
214
+ readonly id: string;
215
+ readonly description: string;
216
+ readonly instructions: string;
217
+ readonly model?: string;
218
+ readonly thinkingLevel?: string;
219
+ readonly tools?: readonly string[];
220
+ readonly mode?: "readonly" | "full-control";
221
+ readonly systemPromptAppend?: string;
222
+ readonly parentView?: boolean;
223
+ }
224
+ /** 会话角色快照条目 data 的形状(必须 JSON 可序列化)。 */
225
+ export interface SubagentSessionRolesStateV1 {
226
+ readonly version: 1;
227
+ readonly roles: readonly SubagentSessionRoleRecordV1[];
228
+ }
229
+ /** `subagent_role_list`(无 id)的摘要条目:来源 + 一句话说明 + 收窄面有无。 */
230
+ export interface SubagentRoleListEntryV1 {
231
+ readonly id: string;
232
+ readonly origin: "disk" | "session";
233
+ readonly description: string;
234
+ readonly hasProfile: boolean;
235
+ readonly hasParentView: boolean;
236
+ }
237
+ export interface SubagentRoleListResultV1 {
238
+ readonly roles: readonly SubagentRoleListEntryV1[];
239
+ }
240
+ /** `subagent_role_list({ id })` 的完整定义(含 instructions 与收窄字段,供读-改-写)。 */
241
+ export interface SubagentRoleDefinitionViewV1 extends SubagentSessionRoleRecordV1 {
242
+ readonly origin: "disk" | "session";
243
+ }
244
+ export interface SubagentRoleViewResultV1 {
245
+ readonly role: SubagentRoleDefinitionViewV1;
246
+ }
247
+ /** `subagent_role_set` 的结果:created/updated + 合并后全部可用角色 id(排序)。 */
248
+ export interface SubagentRoleSetResultV1 {
249
+ readonly id: string;
250
+ readonly status: "created" | "updated";
251
+ readonly roles: readonly string[];
252
+ }
253
+ /** `subagent_role_remove` 的结果:removed + 合并后全部可用角色 id(排序)。 */
254
+ export interface SubagentRoleRemoveResultV1 {
255
+ readonly id: string;
256
+ readonly status: "removed";
257
+ readonly roles: readonly string[];
258
+ }
259
+ /** 运行期角色 → 会话快照条目(平铺收窄字段,读-改-写与角色文件同构)。 */
260
+ export declare function toSessionRoleRecord(role: SubagentDelegateRoleV1): SubagentSessionRoleRecordV1;
261
+ /**
262
+ * 恢复水合(D-081):从 `getBranchEntries()` 反向扫描最近一条**可解析**的会话角色
263
+ * 快照。快照级损坏(非对象/版本不符/roles 非数组)→ warn 后继续向前找;快照合法但
264
+ * 个别角色非法(id 形状、字段/档案校验不过)→ 丢弃该角色并 warn、保留其余;全部
265
+ * 不可解析 → 空数组。损坏不阻断会话启动。
266
+ */
267
+ export declare function readSessionRoles(session: Pick<SessionAPI, "getBranchEntries"> | undefined, logger?: LoggerAPI): readonly SubagentDelegateRoleV1[];
268
+ /**
269
+ * 磁盘角色与会话角色的合并结果(装载期水合与注册期预算共用同一实现)。
270
+ *
271
+ * **数据与视图分离**:预算是**暴露**预算,不是数据删除——未被暴露的会话角色仍留在
272
+ * 会话文件里(后续任何一次 set/remove 重写全量快照都不会把它们抹掉),只是当前不进
273
+ * 可用集。监视语义 = 数据保留(sessionRoles)、视图收窄(roles)。
274
+ */
275
+ export interface SubagentSessionRoleMergeV1 {
276
+ /**
277
+ * 快照读取到的**全部**合法会话角色(快照顺序):含被磁盘遮蔽与超出暴露预算的项。
278
+ * 这是会话文件里的数据(持久化写它),不等于主代理当前可见的可用集。
279
+ */
280
+ readonly sessionRoles: ReadonlyMap<string, SubagentDelegateRoleV1>;
281
+ /** 可用集 = 可见磁盘角色 ∪ 通过暴露预算的会话角色(磁盘优先)——菜单/`role` 枚举只看它。 */
282
+ readonly roles: ReadonlyMap<string, SubagentDelegateRoleV1>;
283
+ /** 与可见磁盘角色撞名而被遮蔽的会话角色 id:保留在会话文件中,当前不暴露(诊断)。 */
284
+ readonly shadowedByDisk: readonly string[];
285
+ /** 超出 16 个 / 2000 字符**暴露**预算而未被暴露的会话角色 id:保留在会话文件中(诊断)。 */
286
+ readonly droppedForQuota: readonly string[];
287
+ }
288
+ /**
289
+ * 合并磁盘角色与会话角色(D-081):**磁盘优先**——撞名的会话角色不暴露并 warn(磁盘
290
+ * 角色是用户资产),但其数据仍留在会话文件里;水合按快照顺序把会话角色收进暴露预算
291
+ * (≤16 个、菜单 ≤2000 字符,磁盘+会话合并计算),超出部分不暴露并 warn——历史快照
292
+ * 可能因上限收紧或磁盘角色增加而超限,但不阻断会话启动,也不删除数据。
293
+ */
294
+ export declare function mergeSubagentRoles(diskRoles: ReadonlyMap<string, SubagentDelegateRoleV1>, sessionRoles: readonly SubagentDelegateRoleV1[], logger?: LoggerAPI): SubagentSessionRoleMergeV1;
197
295
  /**
198
296
  * 解析当前方案的角色目录(**全部来自磁盘**,无编译内定义)。装载期一次性完成,
199
297
  * 任何会让"配置了但没生效"的情况都显式失败: