@ai-agent-forge/plugin-subagent-delegate 0.85.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/README.md +41 -0
- package/agent-forge.json +11 -0
- package/dist/delegate.d.ts +275 -0
- package/dist/delegate.d.ts.map +1 -0
- package/dist/delegate.js +1376 -0
- package/dist/delegate.js.map +1 -0
- package/dist/entry.d.ts +28 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +101 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/multi-agent-tasks.d.ts +101 -0
- package/dist/multi-agent-tasks.d.ts.map +1 -0
- package/dist/multi-agent-tasks.js +178 -0
- package/dist/multi-agent-tasks.js.map +1 -0
- package/dist/remote-adapter.d.ts +11 -0
- package/dist/remote-adapter.d.ts.map +1 -0
- package/dist/remote-adapter.js +366 -0
- package/dist/remote-adapter.js.map +1 -0
- package/dist/runner-pool.d.ts +59 -0
- package/dist/runner-pool.d.ts.map +1 -0
- package/dist/runner-pool.js +330 -0
- package/dist/runner-pool.js.map +1 -0
- package/dist/runner-spawn.d.ts +23 -0
- package/dist/runner-spawn.d.ts.map +1 -0
- package/dist/runner-spawn.js +79 -0
- package/dist/runner-spawn.js.map +1 -0
- package/dist/self-invocation.d.ts +20 -0
- package/dist/self-invocation.d.ts.map +1 -0
- package/dist/self-invocation.js +13 -0
- package/dist/self-invocation.js.map +1 -0
- package/dist/shared-adapter.d.ts +29 -0
- package/dist/shared-adapter.d.ts.map +1 -0
- package/dist/shared-adapter.js +60 -0
- package/dist/shared-adapter.js.map +1 -0
- package/dist/subagent-runtime.d.ts +162 -0
- package/dist/subagent-runtime.d.ts.map +1 -0
- package/dist/subagent-runtime.js +849 -0
- package/dist/subagent-runtime.js.map +1 -0
- package/package.json +55 -0
- package/plugin.json +27 -0
|
@@ -0,0 +1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C1B,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC5B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,eAAe;oBAAE,SAAS;gBAC5E,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAC/B,kDAA8B;oBAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;oBACnC,IAAI,KAAK,IAAI,CAAC;wBAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;oBACvC,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;gBAC/D,CAAC;qBAAM,CAAC;oBACP,+EAA6D;oBAC7D,2DAAmC;oBACnC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;gBACD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpB,CAAC;YACD,wGAAgD;YAChD,qFAAiD;YACjD,IAAI,EAAE,CAAC;YACP,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAAA,CAChC;QACD,KAAK,CAAC,OAAO,GAAkB;YAC9B,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;QAAA,CACpD;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * 子代理运行时调度器(D-044,《子代理运行时设计》§4-§6)——插件级 `SubagentRuntime`:\n * 队列 / 准入 / 预算 / 终态 / 权限的唯一编排入口。\n *\n * - 只组合既有 primitive,不重建生命周期:`AgentTaskAdapter`\n * (../core/extensions/public-api.ts,裸执行 primitive,仅 admitted 之后调用)\n * 与 `createAgentTaskRegistry`(./multi-agent-tasks.ts,状态注册表 primitive,\n * 作为调度终态的投影写入,不作为第二权威;timed_out 经 checkDeadlines 原生直映,\n * 例外路径见 projectTerminalToRegistry,§4.3)。\n * - 生命周期:submit -> queued -> admitted -> allocated(此刻才 `adapter.create`,\n * 之前零 child session、零模型资源)-> running -> 终态。\n * - 预算执行点是调度器本身:submit 拒绝(prompt/metadata UTF-8 字节上限、队列深度),\n * settle 截断(maxMessages/maxResultBytes + `truncated` 标志)。registry 自建时显式传\n * Infinity 预算:并发与结果预算不得依赖 registry 缺省,也不能让 registry 成为第二准入权威。\n * - 终态不可覆盖:settle 先查终态守卫,迟到的 `host.run` 结算一律抑制;取消是幂等 fence,\n * running 取消走有界 drain,超时终态 `drain_timeout`(reasonCode `subagent_drain_timeout`)。\n * - 权限:`result(taskId, requester)` 仅在 owner 与 parentSessionId 均匹配时返回记录,\n * 不区分\"不存在\"与\"无权\";durable 回读走结构化校验,不做裸断言。persist 失败不吞终态:\n * 内存记录已捕获,persist 错误经 cancel()/drain() 的 reject 挂 cause 暴露。\n * - 父栅栏(§4.2):宿主注入 `parentSignal` getter,每次 admitted 时读取当前信号\n * (epoch 正确);信号已 aborted 的任务 admitted 即取消;abort 监听触发 cancelAll 语义。\n * - 确定性:deadline 由显式 `tick()` 推进(无隐藏定时器);drain 超时是对 `host.run`\n * promise 的定时 race(契约允许 \"clock 推进或 race\" 二选一,race 便于注入测试)。\n * 共享 globalAdmission 的跨实例推进同样由显式 `tick()`(或任意实例的 submit/settle)\n * 驱动,不引入轮询。\n * - `runner_lost` 为 pooled 切片保留值,本实现不产生;`outputArtifactRef` /\n * `messagesArtifactRef` 为 artifact 分页保留字段,本切片不产出。\n *\n * 迁自宿主 `src/plugins/subagent-runtime.ts`(D-075 S4 第三批);除 import 来源外\n * 逐字保持:公共契约(AgentTaskAdapter/JsonValue/durable 类型)改自 plugin-sdk。\n */\nimport { randomUUID } from \"node:crypto\";\nimport type {\n\tAgentTaskAdapter,\n\tAgentTaskHost,\n\tDurableArtifactRecordV1,\n\tDurableServiceV1,\n\tJsonValue,\n} from \"@agent-forge/plugin-sdk\";\nimport { AgentTaskError, type AgentTaskRegistryV1, createAgentTaskRegistry } from \"./multi-agent-tasks.ts\";\n\n/** 调度器权威状态(§4.3);其余词汇(DTO/registry/Operation)都是它的投影。 */\nexport type SubagentRuntimeStatus =\n\t| \"queued\"\n\t| \"admitted\"\n\t| \"running\"\n\t| \"succeeded\"\n\t| \"failed\"\n\t| \"cancelled\"\n\t| \"timed_out\"\n\t| \"drain_timeout\"\n\t// runner_lost 为 pooled 切片保留值:本切片无进程池,任何路径都不产生该状态。\n\t| \"runner_lost\";\n\nexport interface SubagentRuntimeLimitsV1 {\n\t/** 同时运行的最大子代理数(admission gate 容量)。默认 8。 */\n\tmaxConcurrentSubagents?: number;\n\t/** 等待准入的最大排队深度;超出即 submit 结构化失败。默认 200。 */\n\tmaxQueueDepth?: number;\n\t/** prompt 的 UTF-8 字节上限;submit 时拒绝。默认 65536。 */\n\tmaxPromptBytes?: number;\n\t/** metadata 经 JSON.stringify 后的 UTF-8 字节上限;submit 时拒绝。默认 16384。 */\n\tmaxMetadataBytes?: number;\n\t/** 终态消息快照的逐条累计字节上限;settle 时截断。默认 524288。 */\n\tmaxResultBytes?: number;\n\t/** 终态消息快照的最大条数;settle 时截断。默认 2000。 */\n\tmaxMessages?: number;\n\t/** 取消/drain 的有界等待时长;超时终态 drain_timeout。默认 30000。 */\n\tdrainTimeoutMs?: number;\n\t/**\n\t * 终态记录(`result()` 回读的权威存储)保留条数上限,默认 256。超出按落库顺序淘汰\n\t * 最旧记录(被淘汰的 taskId 回读为 undefined)——长会话高频委派不能无界增长。\n\t */\n\tmaxRetainedRecords?: number;\n}\n\nexport interface SubagentRuntimeSubmitRequestV1 {\n\tprompt: string;\n\tmetadata?: Record<string, unknown>;\n\t/** 相对 clock 的绝对时刻;已过期或运行中过期的任务由 tick() 推进为 timed_out。 */\n\tdeadlineAt?: number;\n}\n\n/** 并发准入槽位。多 root 共享全局上限时注入同一实例;缺省由 runtime 按 maxConcurrentSubagents 自建。 */\nexport interface SubagentAdmissionGateV1 {\n\t/** claim 一个槽位;容量满返回 \"limit\"(此时调用方不得再 release)。 */\n\ttryAcquire(): \"claimed\" | \"limit\";\n\trelease(): void;\n}\n\n/** 调度器自有终态信封(§4.4):有界、带归属三元组;持久化与回读都以它为准。 */\nexport interface SchedulerTaskRecordV1 {\n\treadonly schedulerVersion: 1;\n\treadonly taskId: string;\n\treadonly owner: string;\n\treadonly parentSessionId: string;\n\treadonly status: SubagentRuntimeStatus;\n\treadonly reasonCode?: string;\n\treadonly reason?: string;\n\t/** messages 按 maxMessages/maxResultBytes 截断时为 true。 */\n\treadonly truncated: boolean;\n\t/** 子会话自身的 sessionId(D-060 S1):可按它在会话目录(`sessions/_agents/`)定位 transcript。 */\n\treadonly sessionId: string;\n\t/** 已按预算截断的有界消息快照。 */\n\treadonly messages: readonly unknown[];\n\t/** artifact 分页保留字段:本切片不产出。 */\n\treadonly outputArtifactRef?: string;\n\treadonly messagesArtifactRef?: string;\n}\n\nexport interface SubagentTaskHandleV1 {\n\treadonly id: string;\n\tstatus(): SubagentRuntimeStatus;\n\t/** 任务级取消信号:cancel()、deadline fence 与父栅栏都会触发 abort。 */\n\treadonly signal: AbortSignal;\n\t/** 终态解析为调度记录;终态前挂起。 */\n\tresult(): Promise<SchedulerTaskRecordV1>;\n\t/** 幂等取消 fence:queued 直接终态;running abort 后有界 drain。返回等待至终态。 */\n\tcancel(reason?: string): Promise<void>;\n\t/** 等待执行体结束(timeoutMs 覆盖 drainTimeoutMs);超时终态 drain_timeout。 */\n\tdrain(options?: { timeoutMs?: number }): Promise<SchedulerTaskRecordV1>;\n}\n\nexport interface SubagentRuntimeOptionsV1 {\n\tadapter: AgentTaskAdapter;\n\towner: string;\n\tparentSessionId: string;\n\t/** 宿主注入的父取消信号 getter(§4.2);每次 admitted 时读取当前信号(epoch 正确)。 */\n\tparentSignal?: () => AbortSignal | undefined;\n\t/** 确定性时钟;缺省 `Date.now`。deadline 判定与 registry 时间戳使用。 */\n\tclock?: () => number;\n\tlimits?: SubagentRuntimeLimitsV1;\n\t/** 缺省自建(显式 Infinity 预算);多 root 共享状态投影时注入同一实例。 */\n\tregistry?: AgentTaskRegistryV1;\n\t/** 缺省按 maxConcurrentSubagents 自建;多 root 全局并发上限时注入同一实例。 */\n\tglobalAdmission?: SubagentAdmissionGateV1;\n\t/** 可选 durable 终态持久化(§4.4 replay 通道):终态以 `subagent-task:<taskId>` 落库。 */\n\tresults?: { readonly store: DurableServiceV1; readonly writerId: string };\n}\n\nexport interface SubagentRuntimeV1 {\n\t/**\n\t * 提交子代理任务。同步抛出契约(非 async 函数):预算超限/非法请求/queue full/\n\t * runtime 已 revoked 以同步 throw 结算,`promise.catch()` 接不到,必须 try/catch;\n\t * 成功路径返回已 resolve 的 Promise。\n\t */\n\tsubmit(request: SubagentRuntimeSubmitRequestV1): Promise<SubagentTaskHandleV1>;\n\t/**\n\t * 范围化回读:内存/durable 记录的 owner 与 parentSessionId 均匹配 requester 才返回;\n\t * 否则返回 undefined(不区分不存在与无权)。\n\t */\n\tresult(\n\t\ttaskId: string,\n\t\trequester: { readonly owner: string; readonly parentSessionId: string },\n\t): Promise<SchedulerTaskRecordV1 | undefined>;\n\t/**\n\t * 按子会话 id 找活跃任务(D-060 S4):owner 与 parentSessionId 均匹配 requester 才返回;\n\t * 返回taskId 与终态与否,供 steer 定位与 resume 的 busy 判定。\n\t */\n\tfindBySession(\n\t\tsessionId: string,\n\t\trequester: { readonly owner: string; readonly parentSessionId: string },\n\t): { readonly taskId: string; readonly settled: boolean } | undefined;\n\t/**\n\t * 对**运行中**的子会话投递一条有界引导消息(§5.1):复用会话自身的 steer 语义,\n\t * 不新增队列。已终态/尚无执行体/宿主不支持 steer 都以结构化错误拒绝。\n\t */\n\tsteer(\n\t\ttaskId: string,\n\t\ttext: string,\n\t\trequester: { readonly owner: string; readonly parentSessionId: string },\n\t): Promise<void>;\n\t/**\n\t * 有界等待某任务进入终态(D-060 S6 后台委派):范围化(owner+parent 匹配),\n\t * 超时返回 undefined(不区分未结算与不存在——先用 peek 区分)。\n\t */\n\twait(\n\t\ttaskId: string,\n\t\ttimeoutMs: number,\n\t\trequester: { readonly owner: string; readonly parentSessionId: string },\n\t): Promise<SchedulerTaskRecordV1 | undefined>;\n\t/**\n\t * 不等待的当前状态快照(D-060 S6 后台委派):范围化;未命中返回 undefined,\n\t * 未结算返回当前状态词汇,已结算 settled=true。\n\t */\n\tpeek(\n\t\ttaskId: string,\n\t\trequester: { readonly owner: string; readonly parentSessionId: string },\n\t): { readonly settled: boolean; readonly status: SubagentRuntimeStatus } | undefined;\n\tstats(): { readonly queued: number; readonly admitted: number; readonly running: number; readonly terminal: number };\n\tcancelAll(reason?: string): Promise<void>;\n\t/** 显式 deadline 推进;返回本次转 timed_out(running 侧为转入有界 drain)的 taskId。 */\n\ttick(): readonly string[];\n\tdispose(): Promise<void>;\n}\n\nexport type SubagentRuntimeErrorCodesV1 =\n\t| \"subagent_queue_full\"\n\t| \"subagent_prompt_too_large\"\n\t| \"subagent_metadata_too_large\"\n\t| \"subagent_invalid_request\"\n\t// 保留:按 id 定位任务未命中时的结构化错误码(当前读取面按契约返回 undefined)。\n\t| \"subagent_unknown_task\"\n\t| \"subagent_drain_timeout\"\n\t// S4 steer:目标非运行态(queued 未 admitted / 已终态 / 执行体已回收)或宿主会话无 steer 面。\n\t| \"subagent_not_running\"\n\t| \"subagent_steer_unsupported\";\n\nexport class SubagentRuntimeError extends Error {\n\treadonly code: SubagentRuntimeErrorCodesV1;\n\n\tconstructor(code: SubagentRuntimeErrorCodesV1, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SubagentRuntimeError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** 状态投影(§4.3):调度器权威状态 -> `AgentTaskStatus` DTO 词汇;不产生映射表之外的值。 */\nexport function toAgentTaskStatusProjection(\n\tstatus: SubagentRuntimeStatus,\n): \"created\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\" {\n\tswitch (status) {\n\t\tcase \"queued\":\n\t\tcase \"admitted\":\n\t\t\treturn \"created\";\n\t\tcase \"running\":\n\t\t\treturn \"running\";\n\t\tcase \"succeeded\":\n\t\t\treturn \"succeeded\";\n\t\tcase \"failed\":\n\t\t\treturn \"failed\";\n\t\tcase \"cancelled\":\n\t\t\treturn \"cancelled\";\n\t\tcase \"timed_out\":\n\t\tcase \"drain_timeout\":\n\t\tcase \"runner_lost\":\n\t\t\treturn \"failed\";\n\t}\n}\n\ninterface Deferred<T> {\n\treadonly promise: Promise<T>;\n\tresolve(value: T): void;\n}\n\nfunction createDeferred<T>(): Deferred<T> {\n\tlet resolve!: (value: T) => void;\n\tconst promise = new Promise<T>((res) => {\n\t\tresolve = res;\n\t});\n\treturn { promise, resolve };\n}\n\n/** 可取消的定时 deferred(wait 的超时臂);cancel 同时清定时器并立即 resolve。 */\nfunction sleepDeferred(ms: number): { readonly promise: Promise<void>; readonly cancel: () => void } {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tlet resolve!: () => void;\n\tconst promise = new Promise<void>((res) => {\n\t\tresolve = res;\n\t\ttimer = setTimeout(res, ms);\n\t});\n\treturn {\n\t\tpromise,\n\t\tcancel: () => {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\tresolve();\n\t\t},\n\t};\n}\n\nfunction createSlotGate(capacity: number): SubagentAdmissionGateV1 {\n\tlet held = 0;\n\treturn {\n\t\ttryAcquire() {\n\t\t\tif (held >= capacity) return \"limit\";\n\t\t\theld += 1;\n\t\t\treturn \"claimed\";\n\t\t},\n\t\trelease() {\n\t\t\theld -= 1;\n\t\t},\n\t};\n}\n\nconst textEncoder = new TextEncoder();\n\nfunction utf8ByteLength(value: string): number {\n\treturn textEncoder.encode(value).length;\n}\n\n/** JSON 序列化用于字节预算计算;不可序列化的值按空串计,不因预算计算抛错。 */\nfunction safeStringify(value: unknown): string {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\treturn serialized === undefined ? \"\" : serialized;\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nfunction errorText(error: unknown): string {\n\tif (error instanceof Error) return error.message;\n\tif (typeof error === \"string\") return error;\n\treturn safeStringify(error);\n}\n\n/**\n * settle 有界化:先按 maxMessages 截断条数,再逐条累计 UTF-8 字节、超出 maxResultBytes\n * 停止;任一截断发生即置 truncated(信封只持有有界快照,原文分页属后续 artifact 切片)。\n */\nfunction boundMessages(\n\tmessages: readonly unknown[],\n\tmaxMessages: number,\n\tmaxResultBytes: number,\n): { readonly messages: readonly unknown[]; readonly truncated: boolean } {\n\tlet truncated = false;\n\tlet selected = messages;\n\tif (selected.length > maxMessages) {\n\t\tselected = selected.slice(0, maxMessages);\n\t\ttruncated = true;\n\t}\n\tconst bounded: unknown[] = [];\n\tlet used = 0;\n\tfor (const message of selected) {\n\t\tconst size = utf8ByteLength(safeStringify(message));\n\t\tif (used + size > maxResultBytes) {\n\t\t\ttruncated = true;\n\t\t\tbreak;\n\t\t}\n\t\tused += size;\n\t\tbounded.push(message);\n\t}\n\treturn { messages: bounded, truncated };\n}\n\nconst RUNTIME_STATUSES: readonly SubagentRuntimeStatus[] = [\n\t\"queued\",\n\t\"admitted\",\n\t\"running\",\n\t\"succeeded\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"timed_out\",\n\t\"drain_timeout\",\n\t\"runner_lost\",\n];\n\nfunction isRuntimeStatus(value: string): value is SubagentRuntimeStatus {\n\treturn RUNTIME_STATUSES.includes(value as SubagentRuntimeStatus);\n}\n\n/**\n * 终态子集:`result()` 是**终态**回读契约,记录只在 settle 时落库,因此持久层里出现\n * 非终态状态(queued/admitted/running)只能是脏数据或别的写入者——按不合格处理,\n * 绝不把它当成\"任务已完成\"返回给调用方。\n */\nconst TERMINAL_RUNTIME_STATUSES: readonly SubagentRuntimeStatus[] = [\n\t\"succeeded\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"timed_out\",\n\t\"drain_timeout\",\n\t\"runner_lost\",\n];\n\nfunction isTerminalRuntimeStatus(value: SubagentRuntimeStatus): boolean {\n\treturn TERMINAL_RUNTIME_STATUSES.includes(value);\n}\n\n/**\n * durable 回读的结构化校验(不做裸断言):字段类型逐一核对后显式重建记录,\n * 不合格按 undefined 处理,与\"不存在/无权\"同型返回。\n */\nfunction parseSchedulerRecord(value: unknown): SchedulerTaskRecordV1 | undefined {\n\tif (typeof value !== \"object\" || value === null) return undefined;\n\tconst candidate = value as Record<string, unknown>;\n\tif (candidate.schedulerVersion !== 1) return undefined;\n\tconst taskId = candidate.taskId;\n\tif (typeof taskId !== \"string\" || taskId.length === 0) return undefined;\n\tconst owner = candidate.owner;\n\tif (typeof owner !== \"string\" || owner.length === 0) return undefined;\n\tconst parentSessionId = candidate.parentSessionId;\n\tif (typeof parentSessionId !== \"string\" || parentSessionId.length === 0) return undefined;\n\tconst status = candidate.status;\n\tif (typeof status !== \"string\" || !isRuntimeStatus(status) || !isTerminalRuntimeStatus(status)) return undefined;\n\tconst truncated = candidate.truncated;\n\tif (typeof truncated !== \"boolean\") return undefined;\n\tconst sessionId = candidate.sessionId;\n\tif (typeof sessionId !== \"string\" || sessionId.length === 0) return undefined;\n\tconst messages = candidate.messages;\n\tif (!Array.isArray(messages)) return undefined;\n\tconst reasonCode = candidate.reasonCode;\n\tif (reasonCode !== undefined && typeof reasonCode !== \"string\") return undefined;\n\tconst reason = candidate.reason;\n\tif (reason !== undefined && typeof reason !== \"string\") return undefined;\n\tconst outputArtifactRef = candidate.outputArtifactRef;\n\tif (outputArtifactRef !== undefined && typeof outputArtifactRef !== \"string\") return undefined;\n\tconst messagesArtifactRef = candidate.messagesArtifactRef;\n\tif (messagesArtifactRef !== undefined && typeof messagesArtifactRef !== \"string\") return undefined;\n\treturn {\n\t\tschedulerVersion: 1,\n\t\ttaskId,\n\t\towner,\n\t\tparentSessionId,\n\t\tstatus,\n\t\t...(reasonCode === undefined ? {} : { reasonCode }),\n\t\t...(reason === undefined ? {} : { reason }),\n\t\ttruncated,\n\t\tsessionId,\n\t\tmessages: Object.freeze([...messages]),\n\t\t...(outputArtifactRef === undefined ? {} : { outputArtifactRef }),\n\t\t...(messagesArtifactRef === undefined ? {} : { messagesArtifactRef }),\n\t};\n}\n\nfunction matchesRequester(\n\trecord: SchedulerTaskRecordV1,\n\trequester: { readonly owner: string; readonly parentSessionId: string },\n): boolean {\n\treturn record.owner === requester.owner && record.parentSessionId === requester.parentSessionId;\n}\n\ninterface RuntimeTaskEntry {\n\treadonly taskId: string;\n\treadonly request: SubagentRuntimeSubmitRequestV1;\n\treadonly deadlineAt: number | undefined;\n\t/** 任务级控制器在 submit 时创建(handle.signal 需要在排队期可用);它不是子会话分配。 */\n\treadonly controller: AbortController;\n\tstatus: SubagentRuntimeStatus;\n\t/** 当前持有的准入槽位;settle 时统一释放。 */\n\tgate: SubagentAdmissionGateV1 | undefined;\n\tsettled: boolean;\n\t/** 取消 fence:cancel()/deadline/父栅栏都会置位;首个置位者决定 pendingTerminal。 */\n\tcancelRequested: boolean;\n\tpendingTerminal: \"cancelled\" | \"timed_out\" | undefined;\n\tpendingReasonCode: string | undefined;\n\tcancelReason: string | undefined;\n\tdrainDriverStarted: boolean;\n\thost: AgentTaskHost | undefined;\n\t/** 子会话 id(D-060 S4):host 创建即捕获,供 steer/resume 按 sessionId 定位活跃任务。 */\n\trecordSessionId: string | undefined;\n\trunSettled: Deferred<void>;\n\tparentSignal: AbortSignal | undefined;\n\tparentListener: (() => void) | undefined;\n\tsettleDeferred: Deferred<SchedulerTaskRecordV1>;\n\tpersistDone: Deferred<void>;\n\tpersistFailed: boolean;\n\tpersistError: unknown;\n}\n\nexport function createSubagentRuntime(options: SubagentRuntimeOptionsV1): SubagentRuntimeV1 {\n\tconst clock = options.clock ?? (() => Date.now());\n\tconst limits = options.limits ?? {};\n\tconst maxConcurrentSubagents = limits.maxConcurrentSubagents ?? 8;\n\tconst maxQueueDepth = limits.maxQueueDepth ?? 200;\n\tconst maxPromptBytes = limits.maxPromptBytes ?? 65536;\n\tconst maxMetadataBytes = limits.maxMetadataBytes ?? 16384;\n\tconst maxResultBytes = limits.maxResultBytes ?? 524288;\n\tconst maxMessages = limits.maxMessages ?? 2000;\n\tconst drainTimeoutMs = limits.drainTimeoutMs ?? 30000;\n\tconst maxRetainedRecords = limits.maxRetainedRecords ?? 256;\n\tconst results = options.results;\n\t// registry 是状态投影 primitive,不是第二准入/预算权威:并发与结果预算由调度器\n\t// 自己的 gate 与 settle 截断执行,因此自建时显式传 Infinity(不依赖其缺省值)。\n\tconst registry =\n\t\toptions.registry ??\n\t\tcreateAgentTaskRegistry({\n\t\t\tnow: clock,\n\t\t\tmaxConcurrent: Number.POSITIVE_INFINITY,\n\t\t\tmaxResultBytes: Number.POSITIVE_INFINITY,\n\t\t});\n\tconst localAdmission = createSlotGate(maxConcurrentSubagents);\n\tconst admission = (): SubagentAdmissionGateV1 => options.globalAdmission ?? localAdmission;\n\n\tconst tasks = new Map<string, RuntimeTaskEntry>();\n\tconst records = new Map<string, SchedulerTaskRecordV1>();\n\tconst queue: RuntimeTaskEntry[] = [];\n\tlet seq = 0;\n\tlet disposed = false;\n\tlet pumping = false;\n\n\t// ---------------------------------------------------------------------------\n\t// 终态 settle:终态守卫 -> 有界消息 -> 信封 -> 释放 -> 投影 -> 持久化\n\t// ---------------------------------------------------------------------------\n\n\tfunction settleEntry(\n\t\tentry: RuntimeTaskEntry,\n\t\tstatus: SubagentRuntimeStatus,\n\t\treasonCode: string | undefined,\n\t\treason: string | undefined,\n\t): void {\n\t\t// 终态守卫:settle 一律先查此标志,迟到结算(迟到的 host.run 结算、重复 fence)抑制。\n\t\tif (entry.settled) return;\n\t\tentry.settled = true;\n\t\tconst bounded = entry.host\n\t\t\t? boundMessages(entry.host.session.getMessages(), maxMessages, maxResultBytes)\n\t\t\t: { messages: [] as unknown[], truncated: false };\n\t\t// 子会话身份(D-060 S1):优先取\"agent 会话自身的 id\"(池化下宿主可见的 id 是 wire 任务 id),\n\t\t// 退回宿主会话 id;两者都在终态前读取(settle 之后 host 被清空)。\n\t\tconst sessionId = entry.host?.session.getAgentSessionId?.() ?? entry.host?.session.getSessionId() ?? entry.taskId;\n\t\tconst record: SchedulerTaskRecordV1 = Object.freeze({\n\t\t\tschedulerVersion: 1 as const,\n\t\t\ttaskId: entry.taskId,\n\t\t\towner: options.owner,\n\t\t\tparentSessionId: options.parentSessionId,\n\t\t\tstatus,\n\t\t\t...(reasonCode === undefined ? {} : { reasonCode }),\n\t\t\t...(reason === undefined ? {} : { reason }),\n\t\t\ttruncated: bounded.truncated,\n\t\t\tsessionId,\n\t\t\tmessages: Object.freeze([...bounded.messages]),\n\t\t});\n\t\tentry.status = status;\n\t\trecords.set(entry.taskId, record);\n\t\t// 有界保留:Map 按插入序迭代,淘汰最旧的终态记录。\n\t\twhile (records.size > maxRetainedRecords) {\n\t\t\tconst oldest = records.keys().next();\n\t\t\tif (oldest.done === true) break;\n\t\t\trecords.delete(oldest.value);\n\t\t}\n\t\tif (entry.gate !== undefined) {\n\t\t\tconst gate = entry.gate;\n\t\t\tentry.gate = undefined;\n\t\t\tgate.release();\n\t\t}\n\t\tif (entry.parentSignal !== undefined && entry.parentListener !== undefined) {\n\t\t\tentry.parentSignal.removeEventListener(\"abort\", entry.parentListener);\n\t\t\tentry.parentSignal = undefined;\n\t\t\tentry.parentListener = undefined;\n\t\t}\n\t\tif (entry.host !== undefined) {\n\t\t\t// 终态后释放子会话(§5.2:cleanup 失败终态仍必须落库)——消息快照已在上方读取。\n\t\t\tconst host = entry.host;\n\t\t\tentry.host = undefined;\n\t\t\tvoid host.dispose().catch(() => {\n\t\t\t\t// dispose 失败不改变已落的调度终态,任务记录已捕获。\n\t\t\t});\n\t\t}\n\t\tentry.settleDeferred.resolve(record);\n\t\tprojectTerminalToRegistry(record);\n\t\tpersistRecord(entry, record);\n\t\t// 槽位已释放:FIFO 推进队列(pumping 守卫保证与进行中的准入循环互斥)。\n\t\tpump();\n\t}\n\n\tfunction projectTerminalToRegistry(record: SchedulerTaskRecordV1): void {\n\t\t// registry 抛 AgentTaskError(如 duplicate_terminal / unknown_task)不得让调度器\n\t\t// 崩溃,也不得覆盖调度终态:调度记录是权威,投影失败按忽略处理。\n\t\ttry {\n\t\t\tif (record.status === \"succeeded\") {\n\t\t\t\tregistry.complete(record.taskId, record.messages as unknown as JsonValue);\n\t\t\t} else if (record.status === \"cancelled\") {\n\t\t\t\tregistry.cancel(record.taskId, record.reason ?? \"cancelled\");\n\t\t\t} else if (record.status === \"timed_out\") {\n\t\t\t\t// §4.3:timed_out 直映 registry 原生 timed_out——正常路径下注入的 registry 已在\n\t\t\t\t// tick() 的 checkDeadlines 原生置 timed_out,此处不得再改写(会 duplicate_terminal);\n\t\t\t\t// 仅当仍未终态(过期降级创建等例外路径,原生 checkDeadlines 覆盖不到)才以\n\t\t\t\t// fail + reason \"deadline_passed\" 落投影。\n\t\t\t\tconst projected = registry.get(record.taskId);\n\t\t\t\tif (projected !== undefined && (projected.status === \"pending\" || projected.status === \"running\")) {\n\t\t\t\t\tregistry.fail(record.taskId, record.reason ?? record.reasonCode ?? \"deadline_passed\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tregistry.fail(record.taskId, record.reason ?? record.reasonCode ?? record.status);\n\t\t\t}\n\t\t} catch {\n\t\t\t// 投影失败不改变调度终态。\n\t\t}\n\t}\n\n\tfunction persistRecord(entry: RuntimeTaskEntry, record: SchedulerTaskRecordV1): void {\n\t\tif (results === undefined) {\n\t\t\tentry.persistDone.resolve();\n\t\t\treturn;\n\t\t}\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tawait results.store.persistArtifact({\n\t\t\t\t\twriterId: results.writerId,\n\t\t\t\t\tartifactId: `subagent-task:${entry.taskId}`,\n\t\t\t\t\tsessionId: options.parentSessionId,\n\t\t\t\t\tdata: record,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\t// persist 失败不吞任务终态:内存记录已捕获;错误挂 cause 经 cancel()/drain()\n\t\t\t\t// 的 reject 通道暴露(对齐 capability-runtime-guards 的 cause 模式)。\n\t\t\t\tentry.persistFailed = true;\n\t\t\t\tentry.persistError = error;\n\t\t\t} finally {\n\t\t\t\tentry.persistDone.resolve();\n\t\t\t}\n\t\t})();\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// 运行与取消\n\t// ---------------------------------------------------------------------------\n\n\tfunction startRun(entry: RuntimeTaskEntry, host: AgentTaskHost): void {\n\t\tconst runPromise = host.run(entry.request.prompt, entry.controller.signal);\n\t\tvoid runPromise.then(\n\t\t\t() => onRunSettled(entry, undefined),\n\t\t\t(error: unknown) => onRunSettled(entry, error),\n\t\t);\n\t}\n\n\t/**\n\t * adapter 抛出的结构化 `code` → 调度器 reasonCode。纪律:只接受保留前缀 `subagent_`\n\t * 与既有特例 `runner_lost`(映射为 `subagent_runner_lost`,D-044 §4.3)——记录里的\n\t * reasonCode 沿用调度器词汇表,不让第三方错误码污染 §4.3 的映射表。\n\t */\n\tfunction adapterReasonCode(error: unknown): string | undefined {\n\t\tif (typeof error !== \"object\" || error === null) return undefined;\n\t\tconst code = (error as { code?: unknown }).code;\n\t\tif (typeof code !== \"string\" || code.length === 0) return undefined;\n\t\tif (code === \"runner_lost\") return \"subagent_runner_lost\";\n\t\treturn code.startsWith(\"subagent_\") ? code : undefined;\n\t}\n\n\tfunction onRunSettled(entry: RuntimeTaskEntry, error: unknown): void {\n\t\tentry.runSettled.resolve();\n\t\tif (entry.settled) return; // 迟到结算:终态已落,抑制\n\t\tif (entry.cancelRequested) return; // fence 已落:由取消/drain 路径按 pendingTerminal 结算\n\t\tif (error !== undefined) {\n\t\t\t// failed 取原始错误 message(含字符串 throw 的原始文本);\n\t\t\t// adapter 可用结构化 code 声明原因(见 adapterReasonCode 的白名单纪律)。\n\t\t\tsettleEntry(entry, \"failed\", adapterReasonCode(error), errorText(error));\n\t\t\treturn;\n\t\t}\n\t\tsettleEntry(entry, \"succeeded\", undefined, undefined);\n\t}\n\n\t/**\n\t * 有界 drain:对 host.run promise 的定时 race(真实定时器,不依赖 scheduler clock;\n\t * 测试可用小 drainTimeoutMs 或 fake timers)。runSettled 已决时立即返回。\n\t */\n\tfunction raceDrain(entry: RuntimeTaskEntry, timeoutMs: number): Promise<\"settled\" | \"timeout\"> {\n\t\tlet settleOutcome!: (outcome: \"settled\" | \"timeout\") => void;\n\t\tconst outcomePromise = new Promise<\"settled\" | \"timeout\">((resolve) => {\n\t\t\tsettleOutcome = resolve;\n\t\t});\n\t\tconst timer = setTimeout(() => settleOutcome(\"timeout\"), timeoutMs);\n\t\tvoid entry.runSettled.promise.then(() => settleOutcome(\"settled\"));\n\t\tvoid outcomePromise.then(() => clearTimeout(timer));\n\t\treturn outcomePromise;\n\t}\n\n\t/** 每个任务至多一个 drain driver:首个启动者的预算生效,后续调用只共享其结果。 */\n\tfunction startDrainDriver(entry: RuntimeTaskEntry, timeoutMs: number): void {\n\t\tif (entry.drainDriverStarted) return;\n\t\tentry.drainDriverStarted = true;\n\t\tvoid (async () => {\n\t\t\tconst outcome = await raceDrain(entry, timeoutMs);\n\t\t\tif (entry.settled) return;\n\t\t\tif (outcome === \"timeout\") {\n\t\t\t\t// 执行体未在预算内结束:终态 drain_timeout(reasonCode subagent_drain_timeout),\n\t\t\t\t// 仍按 settle 路径保留现场消息快照,并尽力 abort + dispose 清理。\n\t\t\t\tentry.controller.abort(\"subagent drain timeout\");\n\t\t\t\tsettleEntry(entry, \"drain_timeout\", \"subagent_drain_timeout\", entry.cancelReason);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (entry.pendingTerminal !== undefined) {\n\t\t\t\tsettleEntry(entry, entry.pendingTerminal, entry.pendingReasonCode, entry.cancelReason);\n\t\t\t}\n\t\t\t// 无 fence 的 drain():in-time 结算已由 onRunSettled 自然完成。\n\t\t})();\n\t}\n\n\t/** 取消 fence(幂等):queued 直接出队终态;admitted 由分配路径结算;running 有界 drain。 */\n\tfunction cancelEntry(entry: RuntimeTaskEntry, reason: string | undefined): void {\n\t\tif (entry.settled || entry.cancelRequested) return;\n\t\tentry.cancelRequested = true;\n\t\tentry.pendingTerminal = \"cancelled\";\n\t\tentry.pendingReasonCode = undefined;\n\t\tentry.cancelReason = reason;\n\t\tentry.controller.abort(reason);\n\t\tapplyFence(entry);\n\t}\n\n\t/** deadline fence:终态方向为 timed_out(reasonCode deadline_passed)。 */\n\tfunction deadlineFence(entry: RuntimeTaskEntry): void {\n\t\tif (entry.settled || entry.cancelRequested) return;\n\t\tentry.cancelRequested = true;\n\t\tentry.pendingTerminal = \"timed_out\";\n\t\tentry.pendingReasonCode = \"deadline_passed\";\n\t\tentry.cancelReason = undefined;\n\t\tentry.controller.abort(\"deadline passed\");\n\t\tapplyFence(entry);\n\t}\n\n\tfunction applyFence(entry: RuntimeTaskEntry): void {\n\t\tswitch (entry.status) {\n\t\t\tcase \"queued\": {\n\t\t\t\tconst index = queue.indexOf(entry);\n\t\t\t\tif (index >= 0) queue.splice(index, 1);\n\t\t\t\tsettleEntry(entry, entry.pendingTerminal ?? \"cancelled\", entry.pendingReasonCode, entry.cancelReason);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"admitted\":\n\t\t\t\t// 分配进行中:admitEntry 在 create 结算后按 fence 终态(终态守卫保证只结算一次)。\n\t\t\t\treturn;\n\t\t\tcase \"running\":\n\t\t\t\tstartDrainDriver(entry, drainTimeoutMs);\n\t\t\t\treturn;\n\t\t\tdefault:\n\t\t\t\t// 已终态:fence 幂等 no-op(entry.settled 守卫已挡住重复进入)。\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// 准入(严格 FIFO)\n\t// ---------------------------------------------------------------------------\n\n\tfunction pump(): void {\n\t\tif (pumping) return;\n\t\tpumping = true;\n\t\tvoid admitNext();\n\t}\n\n\tasync function admitNext(): Promise<void> {\n\t\ttry {\n\t\t\twhile (queue.length > 0) {\n\t\t\t\tconst gate = admission();\n\t\t\t\tif (gate.tryAcquire() === \"limit\") break;\n\t\t\t\tconst entry = queue.shift();\n\t\t\t\tif (entry === undefined) {\n\t\t\t\t\tgate.release();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (entry.settled) {\n\t\t\t\t\tgate.release();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait admitEntry(entry, gate);\n\t\t\t}\n\t\t} finally {\n\t\t\tpumping = false;\n\t\t}\n\t}\n\n\tasync function admitEntry(entry: RuntimeTaskEntry, gate: SubagentAdmissionGateV1): Promise<void> {\n\t\tentry.status = \"admitted\";\n\t\tentry.gate = gate;\n\t\tbindParentSignal(entry);\n\t\tif (entry.cancelRequested) {\n\t\t\tsettleEntry(entry, entry.pendingTerminal ?? \"cancelled\", entry.pendingReasonCode, entry.cancelReason);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tregistry.start(entry.taskId);\n\t\t} catch (error) {\n\t\t\t// registry 抛 AgentTaskError 不得让调度器崩溃:包装为调度终态 failed。\n\t\t\tsettleEntry(entry, \"failed\", undefined, errorText(error));\n\t\t\treturn;\n\t\t}\n\t\t// 延迟分配(§4.1):只有 admitted 才 adapter.create;queued 任务零 child session。\n\t\tlet host: AgentTaskHost;\n\t\ttry {\n\t\t\thost = await options.adapter.create({\n\t\t\t\tprompt: entry.request.prompt,\n\t\t\t\t...(entry.request.metadata === undefined ? {} : { metadata: entry.request.metadata }),\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tsettleEntry(entry, \"failed\", adapterReasonCode(error), errorText(error));\n\t\t\treturn;\n\t\t}\n\t\tif (entry.cancelRequested) {\n\t\t\t// 分配期间 fence 落下:host 立即进入 settle(dispose)路径,不启动 run。\n\t\t\tentry.host = host;\n\t\t\tsettleEntry(entry, entry.pendingTerminal ?? \"cancelled\", entry.pendingReasonCode, entry.cancelReason);\n\t\t\treturn;\n\t\t}\n\t\tentry.host = host;\n\t\t// 子会话 id 即刻捕获(D-060 S4):steer/resume 需要在运行期按 sessionId 定位任务。\n\t\tentry.recordSessionId = host.session.getAgentSessionId?.() ?? host.session.getSessionId();\n\t\tentry.status = \"running\";\n\t\tstartRun(entry, host);\n\t}\n\n\t/** 父栅栏(§4.2):每次 admitted 读取当前信号(epoch 正确);已 aborted 立即按 fence 处理。 */\n\tfunction bindParentSignal(entry: RuntimeTaskEntry): void {\n\t\tconst signal = options.parentSignal?.();\n\t\tif (signal === undefined) return;\n\t\tif (signal.aborted) {\n\t\t\tentry.cancelRequested = true;\n\t\t\tentry.pendingTerminal = \"cancelled\";\n\t\t\tentry.pendingReasonCode = undefined;\n\t\t\tentry.cancelReason = \"parent signal aborted\";\n\t\t\treturn;\n\t\t}\n\t\tconst listener = (): void => {\n\t\t\t// 父栅栏级联(§5.2):cancel fence 全量子任务(queued 移除 + running 有界 drain)。\n\t\t\t// runtime 实例绑定单一 owner/parentSessionId,cancelAll 即该父的全部任务;\n\t\t\t// abort 之后以新 epoch 信号提交的任务不受本次级联影响。\n\t\t\tvoid cancelAllEntries(\"parent signal aborted\").catch(() => {\n\t\t\t\t// 无调用方的级联路径:persist 失败等收尾错误已在各任务 cancel()/drain() 的\n\t\t\t\t// reject 通道暴露,这里不能也不需要再抛。\n\t\t\t});\n\t\t};\n\t\tentry.parentSignal = signal;\n\t\tentry.parentListener = listener;\n\t\tsignal.addEventListener(\"abort\", listener, { once: true });\n\t}\n\n\t// ---------------------------------------------------------------------------\n\t// 公共 API\n\t// ---------------------------------------------------------------------------\n\n\tfunction handleOf(entry: RuntimeTaskEntry): SubagentTaskHandleV1 {\n\t\treturn {\n\t\t\tid: entry.taskId,\n\t\t\tstatus: () => entry.status,\n\t\t\tsignal: entry.controller.signal,\n\t\t\tresult: () => awaitTerminalRecord(entry),\n\t\t\tcancel: (reason?: string) => {\n\t\t\t\tcancelEntry(entry, reason);\n\t\t\t\treturn awaitTerminalVoid(entry);\n\t\t\t},\n\t\t\tdrain: (drainOptions?: { timeoutMs?: number }) => {\n\t\t\t\t// queued/admitted 尚无执行体可 drain:等待其自然终态;running 才挂有界预算。\n\t\t\t\tif (!entry.settled && entry.status === \"running\") {\n\t\t\t\t\tstartDrainDriver(entry, drainOptions?.timeoutMs ?? drainTimeoutMs);\n\t\t\t\t}\n\t\t\t\treturn awaitTerminalRecord(entry);\n\t\t\t},\n\t\t};\n\t}\n\n\tasync function awaitTerminalRecord(entry: RuntimeTaskEntry): Promise<SchedulerTaskRecordV1> {\n\t\tconst record = await entry.settleDeferred.promise;\n\t\tawait entry.persistDone.promise;\n\t\tif (entry.persistFailed) {\n\t\t\tthrow new Error(\"Subagent task result could not be persisted\", { cause: entry.persistError });\n\t\t}\n\t\treturn record;\n\t}\n\n\tasync function awaitTerminalVoid(entry: RuntimeTaskEntry): Promise<void> {\n\t\tawait entry.settleDeferred.promise;\n\t\tawait entry.persistDone.promise;\n\t\tif (entry.persistFailed) {\n\t\t\tthrow new Error(\"Subagent task result could not be persisted\", { cause: entry.persistError });\n\t\t}\n\t}\n\n\tasync function cancelAllEntries(reason: string | undefined): Promise<void> {\n\t\tconst pending = [...tasks.values()].filter((entry) => !entry.settled);\n\t\tfor (const entry of pending) cancelEntry(entry, reason);\n\t\tawait Promise.all(pending.map((entry) => awaitTerminalVoid(entry)));\n\t}\n\n\treturn {\n\t\tsubmit(request) {\n\t\t\tif (disposed) {\n\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\"subagent_invalid_request\",\n\t\t\t\t\t\"Subagent runtime has been disposed; submit is revoked\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (typeof request !== \"object\" || request === null || typeof request.prompt !== \"string\") {\n\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\"subagent_invalid_request\",\n\t\t\t\t\t\"Subagent submit request requires a string prompt\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (utf8ByteLength(request.prompt) > maxPromptBytes) {\n\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\"subagent_prompt_too_large\",\n\t\t\t\t\t`Prompt of ${utf8ByteLength(request.prompt)} UTF-8 bytes exceeds the ${maxPromptBytes}-byte limit`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (request.metadata !== undefined) {\n\t\t\t\tlet serialized: string;\n\t\t\t\ttry {\n\t\t\t\t\tserialized = JSON.stringify(request.metadata);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\t\"subagent_invalid_request\",\n\t\t\t\t\t\t\"Subagent submit metadata is not JSON-serializable\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (utf8ByteLength(serialized) > maxMetadataBytes) {\n\t\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\t\"subagent_metadata_too_large\",\n\t\t\t\t\t\t`Metadata of ${utf8ByteLength(serialized)} UTF-8 bytes exceeds the ${maxMetadataBytes}-byte limit`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (queue.length >= maxQueueDepth) {\n\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\"subagent_queue_full\",\n\t\t\t\t\t`Subagent queue depth ${queue.length} reached the ${maxQueueDepth}-entry limit`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tseq += 1;\n\t\t\tconst taskId = `subagent:${options.owner}:${seq}:${randomUUID().slice(0, 8)}`;\n\t\t\tconst deadlineAt = request.deadlineAt;\n\t\t\t// §4.3:deadline 优先写入 registry 投影(原生 checkDeadlines 可直映 timed_out)。\n\t\t\t// registry 对已过期 deadline fail fast(deadline_passed 类 AgentTaskError),此时\n\t\t\t// 降级为不带 deadline 的 createTask:过期任务由调度器 tick 结算,registry 投影\n\t\t\t// 走 fail + reason 的例外路径(projectTerminalToRegistry)。\n\t\t\ttry {\n\t\t\t\tregistry.createTask({\n\t\t\t\t\ttaskId,\n\t\t\t\t\tparentSessionId: options.parentSessionId,\n\t\t\t\t\t...(deadlineAt === undefined ? {} : { deadlineAt }),\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof AgentTaskError && error.code === \"deadline_passed\")) throw error;\n\t\t\t\tregistry.createTask({ taskId, parentSessionId: options.parentSessionId });\n\t\t\t}\n\t\t\tconst entry: RuntimeTaskEntry = {\n\t\t\t\ttaskId,\n\t\t\t\trequest,\n\t\t\t\tdeadlineAt,\n\t\t\t\tcontroller: new AbortController(),\n\t\t\t\tstatus: \"queued\",\n\t\t\t\tgate: undefined,\n\t\t\t\tsettled: false,\n\t\t\t\tcancelRequested: false,\n\t\t\t\tpendingTerminal: undefined,\n\t\t\t\tpendingReasonCode: undefined,\n\t\t\t\tcancelReason: undefined,\n\t\t\t\tdrainDriverStarted: false,\n\t\t\t\thost: undefined,\n\t\t\t\trecordSessionId: undefined,\n\t\t\t\trunSettled: createDeferred(),\n\t\t\t\tparentSignal: undefined,\n\t\t\t\tparentListener: undefined,\n\t\t\t\tsettleDeferred: createDeferred(),\n\t\t\t\tpersistDone: createDeferred(),\n\t\t\t\tpersistFailed: false,\n\t\t\t\tpersistError: undefined,\n\t\t\t};\n\t\t\ttasks.set(taskId, entry);\n\t\t\tqueue.push(entry);\n\t\t\tpump();\n\t\t\treturn Promise.resolve(handleOf(entry));\n\t\t},\n\t\tresult(taskId, requester) {\n\t\t\tconst cached = records.get(taskId);\n\t\t\tif (cached !== undefined) {\n\t\t\t\treturn Promise.resolve(matchesRequester(cached, requester) ? cached : undefined);\n\t\t\t}\n\t\t\tif (results === undefined) return Promise.resolve(undefined);\n\t\t\tlet loaded: DurableArtifactRecordV1 | undefined;\n\t\t\ttry {\n\t\t\t\tloaded = results.store.loadArtifact({ artifactId: `subagent-task:${taskId}` });\n\t\t\t} catch (error) {\n\t\t\t\t// 存储故障必须作为 **rejected promise** 冒泡:result 的签名是 Promise,\n\t\t\t\t// 同步抛出会让 `runtime.result(...).catch(...)` 直接崩在调用点。\n\t\t\t\treturn Promise.reject(error);\n\t\t\t}\n\t\t\tif (loaded === undefined) return Promise.resolve(undefined);\n\t\t\tconst record = parseSchedulerRecord(loaded.data);\n\t\t\tif (record === undefined || !matchesRequester(record, requester)) return Promise.resolve(undefined);\n\t\t\treturn Promise.resolve(record);\n\t\t},\n\t\tfindBySession(sessionId, requester) {\n\t\t\tif (requester.owner !== options.owner || requester.parentSessionId !== options.parentSessionId) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tfor (const entry of tasks.values()) {\n\t\t\t\tif (entry.recordSessionId !== sessionId) continue;\n\t\t\t\treturn { taskId: entry.taskId, settled: entry.settled };\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t\tasync steer(taskId, text, requester) {\n\t\t\tif (requester.owner !== options.owner || requester.parentSessionId !== options.parentSessionId) {\n\t\t\t\tthrow new SubagentRuntimeError(\"subagent_unknown_task\", `no task ${taskId} in this scheduler scope`);\n\t\t\t}\n\t\t\tconst entry = tasks.get(taskId);\n\t\t\tif (entry === undefined) {\n\t\t\t\tthrow new SubagentRuntimeError(\"subagent_unknown_task\", `no task ${taskId} in this scheduler scope`);\n\t\t\t}\n\t\t\tconst host = entry.settled ? undefined : entry.host;\n\t\t\tif (host === undefined) {\n\t\t\t\tthrow new SubagentRuntimeError(\"subagent_not_running\", `task ${taskId} is not running (queued or settled)`);\n\t\t\t}\n\t\t\tconst steerFn = host.session.steer;\n\t\t\tif (typeof steerFn !== \"function\") {\n\t\t\t\tthrow new SubagentRuntimeError(\n\t\t\t\t\t\"subagent_steer_unsupported\",\n\t\t\t\t\t`task ${taskId}'s host session exposes no steer`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait steerFn.call(host.session, text);\n\t\t},\n\t\tasync wait(taskId, timeoutMs, requester) {\n\t\t\tconst entry = tasks.get(taskId);\n\t\t\tif (\n\t\t\t\tentry === undefined ||\n\t\t\t\trequester.owner !== options.owner ||\n\t\t\t\trequester.parentSessionId !== options.parentSessionId\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (entry.settled) return records.get(taskId);\n\t\t\tconst boundedTimeout = Math.max(0, Math.min(timeoutMs, 120_000));\n\t\t\tconst timer = sleepDeferred(boundedTimeout);\n\t\t\tconst settled = Promise.race([entry.settleDeferred.promise, timer.promise]);\n\t\t\tawait settled.catch(() => {});\n\t\t\ttimer.cancel();\n\t\t\t// settle 后记录必已落(settleEntry 先 records.set 再 resolve settleDeferred)。\n\t\t\treturn entry.settled ? records.get(taskId) : undefined;\n\t\t},\n\t\tpeek(taskId, requester) {\n\t\t\tconst entry = tasks.get(taskId);\n\t\t\tif (\n\t\t\t\tentry === undefined ||\n\t\t\t\trequester.owner !== options.owner ||\n\t\t\t\trequester.parentSessionId !== options.parentSessionId\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn { settled: entry.settled, status: entry.status };\n\t\t},\n\t\tstats() {\n\t\t\tlet queued = 0;\n\t\t\tlet admitted = 0;\n\t\t\tlet running = 0;\n\t\t\tlet terminal = 0;\n\t\t\tfor (const entry of tasks.values()) {\n\t\t\t\tif (entry.status === \"queued\") queued += 1;\n\t\t\t\telse if (entry.status === \"admitted\") admitted += 1;\n\t\t\t\telse if (entry.status === \"running\") running += 1;\n\t\t\t\telse terminal += 1;\n\t\t\t}\n\t\t\treturn { queued, admitted, running, terminal };\n\t\t},\n\t\tasync cancelAll(reason?: string): Promise<void> {\n\t\t\tawait cancelAllEntries(reason);\n\t\t},\n\t\ttick() {\n\t\t\tconst now = clock();\n\t\t\t// §4.3:先推进注入 registry 的原生 deadline(running 任务原生直映 timed_out),\n\t\t\t// 再与调度器自身计算的过期任务取并集;原生先行保证后续调度终态投影不会把\n\t\t\t// 原生 timed_out 改写为 duplicate_terminal 失败。\n\t\t\tlet registryExpired: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tif (typeof registry.checkDeadlines === \"function\") registryExpired = registry.checkDeadlines();\n\t\t\t} catch {\n\t\t\t\t// 注入 registry 的原生推进失败不得让调度器崩溃:调度器自身计算仍会兜底。\n\t\t\t}\n\t\t\tconst expired = new Set<string>(registryExpired);\n\t\t\tfor (const entry of tasks.values()) {\n\t\t\t\tif (entry.deadlineAt !== undefined && !entry.settled && now >= entry.deadlineAt) {\n\t\t\t\t\texpired.add(entry.taskId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst converted: string[] = [];\n\t\t\tfor (const id of expired) {\n\t\t\t\tconst entry = tasks.get(id);\n\t\t\t\tif (entry === undefined || entry.settled || entry.cancelRequested) continue;\n\t\t\t\tif (entry.status === \"queued\") {\n\t\t\t\t\t// queued 过期:直接出队终态 timed_out。\n\t\t\t\t\tconst index = queue.indexOf(entry);\n\t\t\t\t\tif (index >= 0) queue.splice(index, 1);\n\t\t\t\t\tsettleEntry(entry, \"timed_out\", \"deadline_passed\", undefined);\n\t\t\t\t} else {\n\t\t\t\t\t// running/admitted 过期:走 cancel fence + 有界 drain,终态 timed_out\n\t\t\t\t\t//(drain 自身再超时则按 drain_timeout 收敛)。\n\t\t\t\t\tdeadlineFence(entry);\n\t\t\t\t}\n\t\t\t\tconverted.push(id);\n\t\t\t}\n\t\t\t// 共享 globalAdmission 时,其他实例的槽位释放无法回调本实例;与其他显式推进\n\t\t\t// 一致,由 tick()/submit/settle 的 pump 重试准入,不引入隐藏轮询。\n\t\t\tpump();\n\t\t\treturn Object.freeze(converted);\n\t\t},\n\t\tasync dispose(): Promise<void> {\n\t\t\tdisposed = true;\n\t\t\tawait cancelAllEntries(\"subagent runtime disposed\");\n\t\t},\n\t};\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-agent-forge/plugin-subagent-delegate",
|
|
3
|
+
"version": "0.85.0",
|
|
4
|
+
"description": "Subagent delegate capability plugin for Agent Forge (subagent_run delegation over the SubagentRuntime scheduler)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"agent-forge.json",
|
|
17
|
+
"plugin.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "shx rm -rf dist",
|
|
22
|
+
"build": "tsgo -p tsconfig.build.json",
|
|
23
|
+
"test": "vitest --run",
|
|
24
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"agent-forge",
|
|
28
|
+
"plugin",
|
|
29
|
+
"subagent-delegate"
|
|
30
|
+
],
|
|
31
|
+
"author": "Agent Forge contributors",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/agent-forge/agent-forge.git",
|
|
36
|
+
"directory": "plugins/subagent-delegate"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/agent-forge/agent-forge/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/agent-forge/agent-forge#readme",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.19.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@agent-forge/plugin-sdk": "^0.85.0",
|
|
47
|
+
"@agent-forge/protocol": "^0.85.0",
|
|
48
|
+
"typebox": "1.3.27"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@agent-forge/agent-forge": "^0.85.0",
|
|
52
|
+
"shx": "0.4.0",
|
|
53
|
+
"vitest": "4.1.9"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/plugin.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "agent-forge.plugin.subagent-delegate",
|
|
3
|
+
"version": "0.84.4",
|
|
4
|
+
"apiVersion": "1-draft",
|
|
5
|
+
"entry": "./dist/entry.js",
|
|
6
|
+
"hostVersion": ">=0.84.4",
|
|
7
|
+
"requiredCapabilities": ["session", "tools"],
|
|
8
|
+
"optionalCapabilities": ["agents"],
|
|
9
|
+
"provides": [{ "id": "subagent-delegate.agent-task", "version": 1, "kind": "service" }],
|
|
10
|
+
"config": {
|
|
11
|
+
"maxConcurrentSubagents": 8,
|
|
12
|
+
"maxQueueDepth": 200,
|
|
13
|
+
"maxPromptBytes": 65536,
|
|
14
|
+
"maxMetadataBytes": 16384,
|
|
15
|
+
"maxResultBytes": 524288,
|
|
16
|
+
"maxMessages": 2000,
|
|
17
|
+
"drainTimeoutMs": 30000,
|
|
18
|
+
"maxRetainedRecords": 256,
|
|
19
|
+
"maxTasksPerCall": 4,
|
|
20
|
+
"taskTimeoutMs": 300000,
|
|
21
|
+
"runnerMaxProcesses": 0,
|
|
22
|
+
"runnerMaxSessionsPerRunner": 8,
|
|
23
|
+
"runnerIdleTimeoutMs": 300000,
|
|
24
|
+
"runnerSweepIntervalMs": 60000,
|
|
25
|
+
"runnerEntryAuto": false
|
|
26
|
+
}
|
|
27
|
+
}
|