6280d52ec3ec41394fada891fa425dc519f48984
- Capabilities: all 14 registered (AO: inventory.query, download.plan/submit, organize.plan/execute,
policy.preview/apply; agent: task.inspect/retry/cancel); startup asserts count == 14.
Registry injects server-side authorize (automation_grant by action/scope/policy version/budget,
one-shot approval bound to plan id + payload hash + revision + expiry; model claims ignored;
automation switch), audit_event, server idempotency keys and a capability_invocation op ledger
(migration 0021) used for crash reconciliation. download.plan creates draft plans only;
download.submit promotes draft -> reserved after authorization.
- Agent session API: POST/GET /agent/runs, GET /agent/runs/{id} (events by seq, messages, report),
POST .../messages (wake), POST .../abort; automation-grants, approvals, capabilities invoke, tasks.
- runAgent task: Pi or fake provider from settings (apiKey via secrets), events persisted to
agent_run_event then published, resume + ledger reconciliation when pendingOperations > 0,
waits for goal-linked downloads/imports and reports from business tables (submitted != imported).
- Background triggers: decision.created -> bounded plan_only investigation (dedupe per decision);
decision.updated(resolved) -> resolveDecision executes chosen option.
- W2 closure: all OpenAPI routes registered in contracts api.ts (+ subset test); TMDB key from
settings secret_ref with env fallback; PUT /sites/{id}/credentials documented as alias of
/site-accounts; completion events documented as existing status events.
- e2e (real PG + OpenWorkflow + testkit mocks): RSS->library, agent delegation with grant/deny,
background continuation, worker kill -9 recovery (single qB add), auto investigation dedupe.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
UHD Media Tool
内部使用、Agent 自动化优先的媒体整理入库平台。需求基线见 media_automation_requirements_architecture_v0.7.md,v0.1 工程任务书见 docs/plan/00-first-version-plan.md。
快速启动
需要 Deno 2.9.7(锁定版本:curl -fsSL https://deno.land/install.sh | sh -s v2.9.7)和 Docker。不需要 Node.js / pnpm。
cp .env.example .env
deno task db:up # postgres:16-alpine,端口 55433
deno install # 按 deno.lock 安装依赖到 node_modules
deno task db:migrate
deno task dev # API http://localhost:4380 控制台 http://localhost:5180
提交前:deno task ci(typecheck:tsc 7.0.2 + deno check → biome → vitest → check:tokens → web 构建 + server 编译)。
生产/试运行:docker compose up -d --build(单容器 app + postgres,见 docs/runbook/dev.md)。
更多见 docs/runbook/dev.md。
仓库结构
| 路径 | 职责 |
|---|---|
apps/web |
React Router 7 SPA 控制台,沿用 uhd_web 设计系统 |
apps/server |
Hono API(/api/v1)+ SSE + worker 入口;业务按 src/modules/<area>/ 分模块(见 apps/server/README.md) |
packages/contracts |
zod schema:API/事件/能力的唯一定义 |
packages/db |
Kysely 客户端、表类型与迁移 |
packages/domain |
纯业务逻辑,无 IO |
packages/mapping |
domain ↔ contracts 取值与结构映射(只依赖 domain + contracts) |
packages/adapters |
qB / RSS / 站点 / TMDB / Emby / 文件系统适配 |
packages/tasks |
持久任务与 outbox |
packages/agent |
Pi 接入与能力注册桥接 |
packages/testkit |
mock 服务与测试夹具 |
docs/adr |
架构决策记录 |
docs/design |
设计系统规范 |
docs/runbook |
运行手册 |
config/ |
tsc 7 用的 tsconfig 基座(根目录不放 tsconfig.json,否则 deno check 丢 Deno 全局) |
docker/ |
容器入口脚本 |
spikes/ |
独立兼容性验证(不属于 workspace) |
技术选型:Deno 2.9.7(锁定)+ TypeScript 7.0.2 strict,deno.json workspace(nodeModulesDir: auto,npm 依赖版本统一登记在根 deno.json 的 imports,deno.lock 锁定)。前端 Vite 7 + React Router 7 由 Deno 执行。决策见 ADR-004(取代 ADR-001)。
Languages
TypeScript
97.9%
JavaScript
0.8%
CSS
0.5%
Python
0.5%
Shell
0.2%