• 简体中文
  • 插件数据模型

    当前 schema 恰好包含 23 张插件表。它们把代码身份、用户授权、设备执行和耐久投递分开,避免一个关注点的变化静默改变另一个关注点。

    目录与发布

    一行代表什么关键字段与状态主要使用方
    plugin稳定插件身份,不是某个版本plugin_key、发布者、展示信息、可见性、修订;owner_user_id 为空表示系统目录,否则是用户私有插件目录同步、私有插件创建、目录 API
    plugin_package_blob按内容摘要寻址的上传包对象摘要、大小、对象存储 key;staging / available / gc_candidate / deleted;最大 64 MiB包摄入、release 创建、垃圾回收
    plugin_release带来源与信任证据的不可变版本Manifest 与摘要;compiled_builtin / package_blobbundled / catalog / git / localtrusted_first_party / approved_catalog / private_untrustedavailable / quarantined / revoked目录导入、安装、生命周期、授权解析
    plugin_release_capabilityRelease 声明的一项能力能力类型/key、严格配置 JSON 与摘要、声明权限、顺序连接配置、权限、工具目录、runtime 选择、健康检查

    plugin_package_blob 是服务端发布存储,不是 Runner 的渠道隔离运行包缓存。Installation 会钉住一个 release,不会因为目录出现新版本而静默改变。

    安装与授权

    一行代表什么关键字段与状态主要使用方
    plugin_installation用户选择的一个插件 release用户、plugin key、release、revision;installing / disabled / enabling / enabled / disabling / repair_required / uninstalling / uninstalled安装 API、生命周期 Worker、全部授权读取
    plugin_installation_operation幂等异步生命周期命令install / update / enable / disable / repair / uninstallpending / running / succeeded / failed / cancelled;attempt、错误码、诊断API 预留、生命周期队列/Worker、UI 轮询
    plugin_connectionInstallation 的 provider 身份或本地 profileProvider/mode/region、principal、resource scope、device、credential version、默认选择;pending / authorizing / ready / reauthentication_required / unavailable_device / failed / revoked / deletingOAuth 或设备 profile 配置、readiness、工具选择、Channel
    plugin_secret服务端所有的加密 credential 信封Secret kind/version、key id、AAD、nonce、ciphertext;active / replaced / revoked仅 server-side OAuth 或 credential connector
    plugin_permission当前或被替代的一版权限策略可选 capability 范围、policy v1、revision、digest、supersedes_id权限 UI、readiness、工具、effect、Runner authority
    plugin_oauth_attempt一次短期 OAuth state 与 PKCE 交换State 哈希、加密 verifier;pending / consuming / succeeded / failed / expiredOAuth begin/callback;终态必须清除 verifier 加密字段

    Device-local 飞书与 GitHub 凭据不得使用 plugin_secret。它们的 plugin_connection.device_id 必须存在,credential_id 保持为空,操作 secret 留在指定 Desktop 的系统安全存储。

    Permission document 使用追加式 revision。它可以覆盖整个 installation(capability_id 为空),也可以限定一项 capability。Policy 字段是闭合的:

    • data_readsdevice_accessinbound_eventsallowdeny
    • local_reversiblepromptallowdeny
    • external_writespromptdeny,不允许无条件 allow

    设备与运行时

    一行代表什么关键字段与状态主要使用方
    plugin_device_enrollmentDesktop 的长期密码学身份和当前租约Ed25519 公钥/指纹、channel、platform/version、catalog digest、lease_generation、到期时间;pending / active / offline / fenced / revokedDesktop 登记/续租、设备桥、生命周期、授权检查
    plugin_device_action指定设备上的一次短期交互任务authorize_local_profile / configure_local_secret / select_local_plugin_directory;无 secret 的规范请求;pending / claimed / awaiting_local_confirmation / completed / cancelled / expired / failedWeb/API 创建,Desktop 领取、确认、签名完成
    plugin_runtime_instance一个长期配置的 Agent Runtime 实例Installation/release/capability/device/profile、config、协议/provider 版本;pending / ready / incompatible / unavailable / revokedCodex、Claude、OpenClaw、Hermes profile 配置与选择
    plugin_runtime_sessionChat Session 到一次 runtime 执行的绑定直接 plugin_authority_digest、workspace authority、runtime/device generation、provider session、epoch 和事件水位;starting / running / waiting_input / waiting_approval / cancelling / recovering / cancelled / completed / failed / lost / closedRuntime 调度、恢复、重连、事件摄入
    plugin_runtime_eventRuntime Session 中一条不可变哈希链事件Epoch/sequence、previous/event/payload/projection digest、provider 事件身份、投影时间Runner 摄入与规范投影;持久化后才推进 ACK

    Enrollment 是长期身份,lease 是短期在线证明。正常重连复用原 enrollment;撤销会推进 generation 并 fence 旧连接与请求。

    plugin_runtime_instance 只用于 agent_runtime。飞书、GitHub 等 local_provider 通常依赖 ready connection 和 Runner provider activator,不应人为创建 runtime instance。

    副作用与入站投递

    一行代表什么关键字段与状态主要使用方
    plugin_effect_intent一次潜在外部写操作的不可变授权信封钉住 installation/release/capability/tool/connection/permission/device/runtime/workspace、参数、目标、幂等与摘要;只有 state/evidence/receipt/revision 可变Effect 准备、审批、dispatch、reconcile
    plugin_inbound_event一条已认证、去重、规范化的 provider 入站事件Provider/connection/delivery key、有界 raw body 与摘要、规范事件与摘要、route/session;received / normalizing / normalized / routed / unrouted / failed飞书 Channel 与声明式入站流程;规范化、路由、清理
    plugin_inbound_outbox把规范入站事件事务性发布为耐久产品事实Target、规范 payload/digest、重试时间、耐久记录;pending / publishing / published / failed入站 admission 与发布;绝不是 provider 离线队列
    plugin_channel_route外部会话身份到 SciLaxy Session 的映射Connection、规范外部身份/digest、Session;active / disabled / deletedChannel 绑定与入站路由
    plugin_channel_outbox一个 Turn 的待发 Channel 效果钉住授权 revision/device generation/effect/target/payload/idempotency;pending / dispatching / delivered / failed_before_dispatch / uncertainTurn 结算与本地 provider dispatch
    plugin_webhook_endpoint绑定精确本地授权的 GitHub 公网 ingressInstallation/connection revision、device generation、release/authority digest;token 只存摘要,verifier 加密;active / revokedWebhook 配置与公开 handler
    plugin_github_webhook_deliveryGitHub delivery 去重、领取、本地持久化 ACK 证据Delivery id、payload digest、claim lease、本地 receipt digest;dispatching / acknowledgedGitHub handler 与在线设备 relay;不保存原始 provider body
    plugin_audit_event一条追加式、已脱敏插件审计事实Actor/entity/action/outcome、revisions、request/trace/effect/provider、受限 metadata生命周期、设备、连接、effect、webhook、活动 UI

    Effect 使用闭合状态机:

    prepared -> awaiting_approval -> approved -> dispatching
                                      |             +-> succeeded
                                      |             +-> failed_before_dispatch
                                      |             +-> uncertain -> reconciled_succeeded
                                      |                           -> reconciled_failed
                                      +-> denied

    Dispatch 前还可能进入 expiredstalecancelled_before_dispatchfailed_before_dispatch 可以安全重试;uncertain 可能已经跨过 provider 边界,必须先对账。

    关系总览

    flowchart LR
      Plugin[plugin] --> Release[plugin_release]
      Release --> Capability[plugin_release_capability]
      Release --> Install[plugin_installation]
      Install --> Operation[plugin_installation_operation]
      Install --> Connection[plugin_connection]
      Install --> Permission[plugin_permission]
      Device[plugin_device_enrollment] --> Action[plugin_device_action]
      Action --> Connection
      Connection --> Runtime[plugin_runtime_instance]
      Runtime --> RuntimeSession[plugin_runtime_session]
      RuntimeSession --> RuntimeEvent[plugin_runtime_event]
      Install --> Effect[plugin_effect_intent]
      Connection --> Route[plugin_channel_route]
      Route --> Inbound[plugin_inbound_event]
      Inbound --> InboundOutbox[plugin_inbound_outbox]
      Effect --> ChannelOutbox[plugin_channel_outbox]
      Connection --> Webhook[plugin_webhook_endpoint]
      Webhook --> Delivery[plugin_github_webhook_delivery]

    图中省略了证据引用。Effect 和 Channel outbox 还会钉住 permission/connection revision、release/config/tool digest 与 device generation,确保审批 A 不会以授权 B 执行。

    已删除的 Session 表

    迁移 00093_remove_session_plugin_authority.sql 删除了:

    • plugin_session_snapshot
    • plugin_session_capability
    • agent_plugin_binding
    • Session 的 plugin_snapshot_id 字段

    当前工具可见性从已启用账户安装、默认连接和当前权限解析。Runtime Session、effect 与 Channel dispatch 各自冻结直接授权。不要增加兼容读取或重新创建旧 snapshot 模型。