@ai-agent-forge/plugin-subagent-delegate 0.86.7 → 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.86.7",
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: {
@@ -77,18 +77,6 @@ export interface SubagentDelegateCapabilityOptions {
77
77
  */
78
78
  getTurnCorrelationId?: () => string | undefined;
79
79
  }
80
- /**
81
- * 通信面的方向开关(D-060 S4,**默认全关**):`api.config.communication` 里逐项显式
82
- * `true` 才开启。开启项只决定工具注册,作用域与有界性由宿主接线与信箱硬上限保证。
83
- */
84
- export interface SubagentCommunicationConfigV1 {
85
- /** 父→子:对已终态且已落盘的子会话按 sessionId 续跑(`subagent_resume`)。steer 的程序面不经此开关。 */
86
- readonly resume?: true;
87
- /** 子→父:有界上抛消息(`subagent_escalate`),落在父下一次工具结果,不抢占父。 */
88
- readonly escalate?: true;
89
- /** 子↔子:同父兄弟互发有界消息(`subagent_send`/`subagent_inbox`)。 */
90
- readonly sibling?: true;
91
- }
92
80
  /** 结构化错误码:调用形状错误、批上限错误与未知角色分开表达,便于调用方分支。 */
93
81
  export type SubagentDelegateErrorCodesV1 = "subagent_invalid_input" | "subagent_batch_too_large" | "subagent_unknown_role"
94
82
  /** 宿主未落地或无法自证档案收窄:宁可失败,也不让"只读评审者"变成一句空话。 */
@@ -97,6 +85,10 @@ export type SubagentDelegateErrorCodesV1 = "subagent_invalid_input" | "subagent_
97
85
  | "subagent_depth_exceeded"
98
86
  /** 本会话累计创建的子代理达到每父级总量上限(提交侧执行)。 */
99
87
  | "subagent_child_quota"
88
+ /** 会话角色与当前可见磁盘角色撞名:磁盘角色是用户资产,会话不隐式改写其含义(改用其他 id)。 */
89
+ | "subagent_role_conflict"
90
+ /** 会话角色超过既有硬上限(16 个 / 菜单 ≤2000 字符,磁盘+会话合并计算):拒绝注册并提示精简。 */
91
+ | "subagent_role_quota"
100
92
  /** submit 同步拒绝且无结构化 code 时的本地兜底码(与投影 reasonCode 同名)。 */
101
93
  | "subagent_submit_rejected";
102
94
  export declare class SubagentDelegateError extends Error {
@@ -129,6 +121,16 @@ export interface SubagentDelegateTaskProjectionV1 {
129
121
  * `subagent_result`),父回合不被打断;无积压时省略。
130
122
  */
131
123
  readonly escalations?: readonly string[];
124
+ /**
125
+ * 该子会话相关的兄弟消息流量摘录(D-060 裁决 14 父可见性):from/to 命中的最新
126
+ * 至多 8 条,每条 text 截 256 utf-8 字节;无流量时省略。审计日志在信箱侧,drain
127
+ * 后摘录仍可回读(历史摘录以信箱日志滚动窗口为界)。
128
+ */
129
+ readonly siblingTraffic?: readonly {
130
+ from: string;
131
+ to: string;
132
+ text: string;
133
+ }[];
132
134
  }
133
135
  export interface SubagentDelegateResultV1 {
134
136
  readonly tasks: readonly SubagentDelegateTaskProjectionV1[];
@@ -196,6 +198,100 @@ export interface SubagentRoleCatalogResolutionV1 {
196
198
  /** 未被关联、但用户文件非法的角色文件:只在被关联时才致命,这里记录用于诊断。 */
197
199
  readonly brokenUnassociated: readonly string[];
198
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;
199
295
  /**
200
296
  * 解析当前方案的角色目录(**全部来自磁盘**,无编译内定义)。装载期一次性完成,
201
297
  * 任何会让"配置了但没生效"的情况都显式失败:
@@ -255,6 +351,12 @@ export interface SubagentResultReadResultV1 {
255
351
  readonly messages?: readonly unknown[];
256
352
  /** 该子会话 escalate 上抛的有界消息(取后即清);无积压时省略。 */
257
353
  readonly escalations?: readonly string[];
354
+ /** 该子会话相关的兄弟流量摘录(只读不删;D-060 裁决 14);无流量时省略。 */
355
+ readonly siblingTraffic?: readonly {
356
+ from: string;
357
+ to: string;
358
+ text: string;
359
+ }[];
258
360
  /** taskId 已知但尚未结算(后台委派):稍后再取或带 waitMs 等待。 */
259
361
  readonly knownTask?: true;
260
362
  /** 未结算任务的当前调度器状态(queued/admitted/running)。 */