Files
UHD_Media_Tool/packages/contracts
rootandClaude Opus 5.5 459991421e feat(agent): Pi subagents via agent.spawn / agent.await
- agent_run gains depth / spawn_reason (0029); agent_run_event types
  subagent_spawned / subagent_event / subagent_completed
- agent.spawn (propose, medium, replay never): allowlist ⊆ parent, mode not
  above parent, budget carved from parent's remainder, idempotent per run+input;
  settings.pi.subagents {enabled, maxConcurrent, maxDepth} (subagentsEnabled kept as alias)
- child runs claim a concurrency slot under an advisory lock (waitForFact while
  queued); agent.await polls business tables without calling the model
- parent abort cascades to all descendants; parent runtime budget counts
  descendant usage; child events mirrored into the parent stream by parent seq
- authorize caps every child call by all ancestors' allowlists/kinds
- session page shows parent link, inherited info and the subagent tree
- e2e E11; runbook section on subagents

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-28 02:49:37 +08:00
..

@umt/contracts

所有 API、SSE 事件与能力(capability)输入输出的唯一定义(zod 4 schema + 推导出的 TS 类型)。web 与 server 共用,任何一端都不得手写重复 DTO;新增接口先在这里加 schema,再由 server 用 @hono/zod-openapi 生成 OpenAPI。

文件 内容
common.ts Id、Timestamp、DateOnly、JsonObject、游标分页、错误码、响应信封、ApiScope、ActorType
content.ts / identity.ts / assets.ts / sources.ts / policy.ts / execution.ts / agent.ts / ops.ts / organization.ts / instances.ts 每张表的 Row schema(camelCase、日期为 ISO 字符串)+ XxxCreate / XxxUpdate 输入
organization.ts 另含公开整理记录合同:PublicOrganizationRecord、OrganizationChangesQuery/Response(change_seq 游标)、OrganizeRequest
settings.ts GlobalSettings、DEFAULT_SETTINGS、GlobalSettingsUpdate、mergeSettings()
capability.ts / capabilities-io.ts CapabilityDescriptor、首批 14 个能力 ID 与目录、各能力 Input/Output schema、CAPABILITY_IO
events.ts SSE 信封、EventType、EVENT_PAYLOADS、TypedEvent 判别联合
files.ts 文件管理(/files/*)的请求/响应:根与条目、dryRun 计划(planId)、move/copy/organize/delete、回收站 TrashItem、identify/probe/scrape、download
auth.ts 登录、会话探测 SessionInfo、改密、TOTP(TotpStatus/TotpAction)、审计动作枚举
browser.ts BrowserProvider 合同:会话/标签/快照、快照脱敏类别 SnapshotRedactionKind
redact.ts 凭证脱敏的唯一键表与规则:SENSITIVE_KEY_PARTS、SENSITIVE_QUERY_PARAMS、isSensitiveKey、isSensitiveQueryParam、redactString、redactUrl(server logger、Agent 模型上下文、adapters 的 rss/browser 共用)
api.ts Api 端点表(method/path/scope/auth/params/query/body/response;auth:"session" 表示只接受管理员控制台会话)、buildPath()、listEndpoints()

约定:

  • Row schema 与 packages/db/src/types.ts 的列一一对应(test/db-sync.test.ts 校验);只在 DB 存在的列(密文、key_hash、change_xid)不对外。
  • 凭证类输入(credential、url、plaintext、apiKey)只写不回显。
  • schema 不用 .default() 做可部分更新对象的缺省(zod 4 在 partial 里仍会填默认值);缺省值放常量。