DeepSeek Harness 源码教程
DEEPSEEK HARNESS · OFFLINE TUTORIAL

07 · Capability Seam

Definition / Provider / Consumer / Policy

1. Capability Seam 的三角色

         Definition
        (interface)
        /        \
       /          \
Provider          Consumer
  HOW               USE

Definition 说“能力是什么”;Provider 决定“怎么实现”;Consumer 只使用接口,不关心具体实现。

2. 文件系统是最佳案例

┌───────────────────────────┐
│ Model-facing Tools        │
│ read / write / edit       │
└──────────────┬────────────┘
               │
          fs/* events
               │
┌──────────────▼────────────┐
│ Policy                    │
│ observation / read-first  │
│ version guard             │
└──────────────┬────────────┘
               │
┌──────────────▼────────────┐
│ Provider Contract         │
│ ctx.fs                    │
└──────────────┬────────────┘
               │
       ┌───────┼─────────┐
       ▼       ▼         ▼
     local   sandbox    remote

3. Policy 为什么不应该塞进 Provider

“先读后写”是 Agent policy,不是文件系统接口天然具备的属性。Policy 与 mechanism 分离后,卸掉 policy 插件并不会破坏底层 provider 或工具契约。

Mechanism:能不能做。
Policy:在当前规则下允不允许这样做。

4. 远程执行为什么自然

原来:
ctx.fs = local
ctx.subprocess = local

切换后:
ctx.fs = remote
ctx.subprocess = remote

如果 Shell、Terminal、LSP、File Tools 都消费 Seam,它们就不需要到处写 if (remote)

5. 三种 Event Domain

事件域含义例子
Session Eventsreload 后仍要存在的 durable factsuser/message、tool/result、turn/start
Agent Eventslive execution lifecycle / interceptionagent/pre-step、agent/request
Capability Events能力自己的 policy / interceptiontools/*、fs/*

6. 九问法

  1. 它是 Definition、Provider、Consumer 还是 Policy?
  2. 它注册哪个 ctx.xxx
  3. 它 inject 哪些 Service?
  4. 它监听或 dispatch 哪些 event?
  5. 这些 event 是 emit / serial / parallel / waterfall 哪一种?
  6. 它产生 live state 还是 durable state?
  7. 卸载时什么 effect 被撤销?
  8. 它是 global 还是 agent-scoped?
  9. 替换 provider 后,哪些 consumer 应完全不用改?