@1agents/dreammate-network 0.5.0 → 0.7.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/CHANGELOG.md ADDED
@@ -0,0 +1,176 @@
1
+ # Changelog
2
+
3
+ 本包是 L0 协议包:**只放跨仓共用的词汇,不放任何一方的行为。**
4
+ 改动前先读 [README.md](README.md) 里那条判断标准——是词汇进来,是行为出去。
5
+
6
+ 版本号两处必须同步:`package.json.version` 与 `typescript/types.ts` 的
7
+ `PROTOCOL_VERSION`(`test/schemas.test.js` 会钉住这一点)。
8
+
9
+ ## 0.7.0(未发布)
10
+
11
+ ### 唯一的 schema 变更:`DelegationSpec.mode` 改为可选可空
12
+
13
+ 两仓给完准话后的收敛结果:L0 **不强制每一方都有生命周期档位这个概念**。
14
+
15
+ - `schemas/delegation.schema.json`:`$defs.delegationSpec` **去掉 `required`**,
16
+ `mode` 从裸 `$ref` 改成 `anyOf: [{$ref}, {type:"null"}]`
17
+ - `typescript/types.ts`:`DelegationSpec.mode: LifecycleMode` → `mode?: LifecycleMode | null`
18
+
19
+ **为什么放宽**:没有档位概念的调用方若被迫填一个,要么谎报 `trial`(产出可能被静默丢弃),
20
+ 要么谎报 `formal`(平白背上审校要求)——**两种谎报都比缺省更糟**。
21
+ 要强制必填的一方在自己的类型边界上强制(dsh-superagent 已在它的委派授权边界上强制)。
22
+
23
+ **向后兼容**:放宽 `required` 不破坏现有生产方(他们照传 `mode` 一样合法),
24
+ 也不破坏已发布的 0.6.0 消费方。读模型 `DelegationMirror.lifecycle_mode`
25
+ 本来就是可选可空,现在写模型与它对称了。
26
+
27
+ 语义:`mode` 不声明或为 null = **调用方没有档位概念**,**不是 trial**。
28
+
29
+ ### 委派规格的语义落定(两仓确认)
30
+
31
+ - `mode` **不是执行参数**,它说的是产出资产处在哪个生命周期档位;
32
+ 由调用方记账,不进 `execution_submit`。
33
+ - `checks` / `outputs` 是**调用方声明的可选清单**(验收清单 / 交付清单);
34
+ 执行端没有同名结构化参数时,由调用方适配器透传进 `prompt`,
35
+ 或映射进执行端的自检清单 / 结果契约。
36
+ - 1acp 侧采纳可选的 `input.lifecycleMode` fail-closed 校验口(与 `input.roleId` 同层,
37
+ 类型复用 L0 的 `LifecycleMode`),并通过 `projectDelegationMirror({ lifecycleMode })`
38
+ 直出到 `DelegationMirror.lifecycle_mode`。**1acp 侧实现选择,L0 不强制。**
39
+
40
+ ### 文档更正
41
+
42
+ §13 原先写「1acp 用 ticket 的 `check` 类 proposal 表达检查项」——**不准确**:
43
+ `ticket.proposals` 里 `kind: 'check'` 的是**提议新增/修订角色检查规则**的演化提议,
44
+ 不是单次任务的检查清单;单次执行的检查项由角色包 `checklist.json` 在 `openTicket()`
45
+ 时注入 `Ticket.selfChecks`,再由 `applyChecks()` 验核。已按 1acp 的指正更正。
46
+
47
+ ### 新增两条门禁
48
+
49
+ - `$defs` 里的 example 也要真的合法(并断言「至少检查到一个」,防这条测试空跑)
50
+ - `DelegationSpec` 的字段**全是可选的**(钉住「L0 不强制每一方都有每个概念」)
51
+
52
+ ### 以下是 0.6.0 之后、随 0.7.0 一并发布的改动
53
+
54
+ #### 本仓自己校验自己的 example(补一个被证实的门禁漏洞)
55
+
56
+ 实测发现:`test/schemas.test.js` 只检查 example 的必填字段齐不齐,**不验证它是否真能
57
+ 通过自己的 schema**——把 `governance` 的 `example[0].kind` 改成枚举外的 `'robot'`,
58
+ 本仓测试仍然 17/17 全绿。而 example 是随包发布、且被 README 明确当作冒烟用例的,
59
+ 一个非法 example 会一路飘到三个仓的冒烟测试里。
60
+
61
+ - 新增 `test/schemas.validate.test.js`:用真正的 draft 2020-12 校验器(ajv + ajv-formats)
62
+ 验证每个 schema 能编译(跨文件 `$ref` 能解析)、每个 example 真的合法,
63
+ 并钉住几条必须被拒的反例(远端 10 态不许漏进 `ExecutionStatus`、
64
+ 镜像的 `status` 必须复用 L0 枚举、未知 `ActorKind` 被拒、可空字段真能收 null)
65
+ - `ajv` / `ajv-formats` 只是 **devDependency**:发布出去的包运行时依然零依赖
66
+ - `npm test` 现在跑两个文件:漂移探测 + 真实校验
67
+
68
+ ### 协议正文补两条消费方实际问出来的语义(不改 schema,不改类型)
69
+ - **`correlation: {}` 与「没有这个键」等价**:`MessageCorrelation` 的字段全部可选,
70
+ 空对象就是「没有关联上下文」。消费方要不要归一化是它自己的实现选择,但都该认这两者等价。
71
+ - **L0 只导出类型,不导出运行时枚举数组**:消费方拿值要自己写,但要**用类型钉住**
72
+ (`as const satisfies readonly SessionDeliveryMode[]`),否则 L0 将来加成员时
73
+ 消费方那份会静默漂移。这条是从 `1acp` 接入 `SessionDeliveryMode` 时暴露出来的。
74
+ - **`ActorRef` 故意不带 `via`**:那是路由信息(从哪个入口来),属于行为层,不是身份本身。
75
+ 需要表达"挂在哪个上下文上"请用消息层的 `MessageCorrelation`;要在自家仓里记就从自家仓记。
76
+ 同时提醒:L0 的 schema 是宽松的,多塞字段 ajv 会放行,**真正的把关是 TypeScript 类型**。
77
+ - **外部事件的分工写清楚了**(对着 `mcp-superagent` 的 `superagent_notify` 真实契约核过):
78
+ L0 `NotificationEvent` 只管「发生了什么」(source / event_id / event_type / summary /
79
+ occurred_at,`source+event_id` 是幂等键);`mode`/`at`/`team_id`/`fallback` 是服务端路由,
80
+ `task_id`/`trigger_id`/`reply_to` 是服务端自己的 id 命名空间。
81
+ **红线:服务端那个 `task_id` 不是 L0 的 `task_id`**,跨仓指向委派要用
82
+ `job_id` / `a2a_task_id`。`correlation` 等到真有两个仓需要时再加,不预留。
83
+ - **委派规格 ↔ 执行单的对应表写清楚了**(对着 `1acp` 的 `execution_submit` 真实形状核过,
84
+ 并经两仓确认):
85
+ `target_id`→`targetId`、`role_id`→`input.roleId` 直接对应;
86
+ **`mode` 不是执行参数**——它说的是产出资产的生命周期档位(能不能丢弃 /
87
+ 能不能跨档位复用 `job_id` / 要不要冻结 `RevisionRef`),由调用方记账,
88
+ 因此**在 `DelegationSpec` 里保持必填**;
89
+ **`checks` / `outputs` 是调用方声明的可选验收与交付清单**,执行端没有同名
90
+ 结构化参数时由调用方适配器透传进 `prompt` 或映射进自检清单 / 结果契约。
91
+ 顺带记下同名不同义的坑:1acp `resultContract` 里的 `deliveryMode` 是产物怎么落地,
92
+ 不是 L0 的 `SessionDeliveryMode`。
93
+ - **新增 §16「消费方怎么自检」**:一段可直接抄进消费方测试的片段,钉住 L0 对外承诺的
94
+ 几件事(装到的是发布版而非 file: link、版本与 `PROTOCOL_VERSION` 一致、
95
+ `a2a_task_id` 在而 `task_id` 不在、六态 `ExecutionStatus`、三类治理提案)。
96
+ 片段里的每条断言都对着真实 schema 机器验过一遍。
97
+
98
+ ### 发布流程 tag 驱动化
99
+
100
+ `publish.yml` 早就是「推 `v*` tag 自动 `npm publish`」,这次把它正式用起来:
101
+
102
+ - 新增 `scripts/release.mjs`:`release`(预检 → 打 tag → 推送 → 等 CI → 验证 npm)、
103
+ `tag`(幂等补 tag)、`check`(体检 npm 版本与 tag 是否一一对齐)
104
+ - `publish.yml` 新增幂等保护:版本已在 registry 上时**跳过发布而不是报错**——
105
+ 回填历史 tag、重跑失败的 run、误推重复 tag 都不会把流水线跑红
106
+ - 发布走 CI,带 **provenance** 签名;本地不再需要 npm token 参与发版
107
+
108
+ > 0.3.2 / 0.4.0 / 0.5.0 是早期在本地手动发的 npm(因此当时没有 tag)。
109
+ > 0.6.0 起恢复 tag 驱动。
110
+
111
+ ## 0.6.0 — Stage 0 协作词汇
112
+
113
+ 三方(`dsh-superagent` / `1acp` / `dreammate-network`)收敛后的第一版协作词汇。
114
+ **纯增量**:现有 schema 的既有字段一律未改,`Execution` / `SessionRef` /
115
+ `Service` / `NodeManifest` 的结构与语义不变。
116
+
117
+ ### 新增 schema
118
+
119
+ | 文件 | 根对象 | 内容 |
120
+ |---|---|---|
121
+ | `schemas/governance.schema.json` | `ActorRef` | `ActorKind` / `LifecycleMode` / `ReviewStatus` / `RevisionRef` / `RoleRef` / `GovernanceProposalKind` / `ProcessRequestKind` / `ProcessRequestOutcome` |
122
+ | `schemas/delegation.schema.json` | `DelegationMirror` | `DelegationSpec`(`$defs`) |
123
+ | `schemas/message.schema.json` | `SessionMessageEnvelope` | `SessionDeliveryMode` / `MessageCorrelation` / `NotificationEvent`(`$defs`) |
124
+
125
+ ### 既有 schema 的唯一改动
126
+
127
+ - `execution.schema.json`:`status` 枚举新增成员 **`canceled`**(被取消的终态,与
128
+ `failed` 并列——取消不是失败;拼写统一单 l)。
129
+
130
+ ### 枚举变更清单(消费方必须逐条核对)
131
+
132
+ | 枚举 | 变更 |
133
+ |---|---|
134
+ | `ExecutionStatus` | **新增成员** `canceled` |
135
+
136
+ 消费方义务:**对未知枚举成员必须有 default 分支**(见 [docs/protocol.md](docs/protocol.md) §14)。
137
+
138
+ ### 留在各自仓、不进 L0 的东西(防止下一个人把它们捡回来)
139
+
140
+ - 远端内部状态机(`submitted` / `working` / `input_required` / `rejected` / `unknown` 等 10 态)
141
+ - ticket 提案族(`ProposalKind` 的 `check|role|qa|locked`、`ProposalState`)
142
+ - Coach 动作名(`inspect` / `approve` / `reopen` / `stop_or_escalate`)——用
143
+ `Service.methods` + `MethodDescriptor` 声明发现
144
+ - 通知的路由参数(`mode: auto|direct|group` / `at` / `team_id` / `fallback`)
145
+ - 投递队列的合并算法、绑定表刷新策略、各 RPC 方法名、正文的渲染格式
146
+
147
+ ### 新增的四条硬规则(已写进 `test/schemas.test.js`)
148
+
149
+ - **委派词汇不进 `Execution`**:`delegation` / `lifecycle_mode` / `job_id` 等一律不许
150
+ 出现在 `Execution` 上——那是 `task_id` 事件的同款重演。
151
+ - **远端 `a2a_task_id` 与本地 `task_id` 彻底隔离**:两者不得出现在同一个对象里。
152
+ - **L0 不导出 `DeliveryMode`**:1acp 已有同名的 `DeliveryMode`(`artifacts` /
153
+ `workspace_git` / `workspace_files` / `none`,指产物怎么落地),与 L0 的投递语义
154
+ 同名不同义。L0 这边叫 `SessionDeliveryMode`(`queue` / `steer`)。
155
+ - **schema 与 types.ts 的 null 容忍度逐字段对齐**:可选且可为 null 的字段,
156
+ schema 里必须收 null——内联类型写 `["X","null"]`,用 `$ref` 时写
157
+ `anyOf: [{$ref}, {type:"null"}]`。裸 `$ref` 会悄悄丢掉 null。
158
+
159
+ ### 已知撞名与消费方映射
160
+
161
+ 见 [docs/protocol.md §15](docs/protocol.md) —— 1acp 与 dsh-superagent 的逐条对照表。
162
+ 已查实的:`AssetLifecycle` ≡ L0 `LifecycleMode`;`GovernanceProposalKind` 完全一致;
163
+ `LifecycleActor` ⊂ L0 `ActorKind`;1acp 的 `DeliveryMode` 与 dsh-superagent 的
164
+ `ActorRef` 均**同名不同义**,前者保留原名、后者用别名导入。
165
+
166
+ ### 消费方升级提示
167
+
168
+ npm 的 `^0.5.0` **不包含** 0.6.0(0.x 的 caret 是 minor 锁)。要用新词汇必须显式
169
+ 升到 `"@1agents/dreammate-network": "^0.6.0"`。同一 workspace 内不要同时存在两个
170
+ L0 版本,否则同名 enum 会出现两份。
171
+
172
+ ## 0.5.0
173
+
174
+ - Service 补齐 `methods` / `skills`,`capabilities` 标记 `@deprecated`
175
+ - Service 补齐 `execution` / `command` / `lifecycle`
176
+ - README 重写为 Capability Network 定位
package/README.md CHANGED
@@ -1,47 +1,125 @@
1
1
  # dreammate-network
2
2
 
3
- > DreamMate Network 的 **L0 协议包**:schema + types,零依赖,**不含业务逻辑**。
4
- > 版本 0.1.0 | 状态:草案
3
+ > DreamMate Network 的 **L0 协议包**:schema + TypeScript 类型,零运行时依赖,**不含业务逻辑**。
4
+ > 版本 **0.7.0**(未发布)| npm 上最新:**0.6.0** | 包名:`@1agents/dreammate-network`
5
+ >
6
+ > 这不是 Agent Network,是 Capability Network —— 让设备和软件向智能体公开自己的能力。
7
+ > **登记、发现、执行调用** 由 `@1agents/dreammate-node` 承担;本包只提供共用词汇。
5
8
 
6
9
  判断改动该不该进这个包,只看一条:
7
10
 
8
11
  > 它是所有 repo 都要共用的**词汇**,还是某一方的**行为**?
9
12
  > 是词汇 → 进来。是行为 → 出去。
10
13
 
14
+ ## 是什么
15
+
16
+ 七个 JSON Schema + 一份 TS 类型投影,把跨设备、跨语言、跨 Agent 运行时需要共识的所有对象写成公共语言:
17
+
18
+ | 概念 | 干什么 |
19
+ |---|---|
20
+ | **Node** | 在哪里执行;从 tailnet 取身份 |
21
+ | **Service** | Node 上的一组能力聚合;声明 `methods` / `skills` / `resources` / `access` |
22
+ | **Capability** | 能做什么(点分命名,如 `transcript.read`) |
23
+ | **Resource** | 拥有什么(声明 URI scheme,如 `recording://…`) |
24
+ | **Execution** | 现实中发生的一次工作行为 |
25
+ | **Session** | 这一次的工作上下文(`session://<node>/<runtime>/<session_id>`) |
26
+
27
+ v0.6.0 起另有一组**协作词汇**:谁在行动(`ActorRef`)、一次委派的状态(`DelegationMirror`)、
28
+ 跨会话消息的信封(`SessionMessageEnvelope`)。详见 [docs/protocol.md §13](docs/protocol.md)。
29
+
30
+ Graph 的边(`references` / `initiates` / `opens` / `delegates` / `produces` / `accesses`)由调用事件实时写入,不靠后台扫库猜 DAG。
31
+
11
32
  ## 内容
12
33
 
13
34
  ```
14
35
  dreammate-network/
15
- ├── schemas/ JSON Schema (draft 2020-12),唯一事实源
16
- │ ├── node.schema.json
17
- │ ├── service.schema.json
18
- │ ├── execution.schema.json
19
- │ └── session-ref.schema.json
20
- ├── typescript/types.ts 上述 schema 的 TS 投影,纯类型
21
- ├── docs/protocol.md 协议正文
36
+ ├── schemas/ JSON Schema (draft 2020-12),唯一事实源
37
+ │ ├── node.schema.json NodeManifest
38
+ │ ├── service.schema.json Service / AccessDescriptor / MethodDescriptor / SkillDescriptor
39
+ │ ├── execution.schema.json Execution
40
+ │ ├── session-ref.schema.json SessionRef(图的边)
41
+ │ ├── governance.schema.json ActorRef / LifecycleMode / ReviewStatus / RevisionRef / RoleRef / 治理枚举
42
+ │ ├── delegation.schema.json DelegationMirror / DelegationSpec
43
+ │ └── message.schema.json SessionMessageEnvelope / SessionDeliveryMode / NotificationEvent
44
+ ├── typescript/types.ts 上述 schema 的 TS 投影,与 schema 一一对应
45
+ ├── docs/protocol.md 协议正文(设计、约定、示例)
46
+ ├── CHANGELOG.md 每次改了什么(多个仓在消费,变更记录不能没有)
22
47
  └── package.json
23
48
  ```
24
49
 
25
- ## 用
50
+ `schemas/` 与 `typescript/types.ts` **必须同步修改**。types.ts 顶部导出
51
+ `PROTOCOL_VERSION`,与 `package.json` 版本号一致 —— 两个版本号会让人永远猜不准该看哪个。
52
+
53
+ ## 怎么用
54
+
55
+ **TypeScript**:
26
56
 
27
57
  ```ts
28
- import type { NodeManifest, Execution, SessionURI } from "dreammate-network";
58
+ import type {
59
+ NodeManifest,
60
+ Service,
61
+ MethodDescriptor,
62
+ Execution,
63
+ SessionURI,
64
+ } from "@1agents/dreammate-network";
65
+
66
+ const manifest: NodeManifest = {
67
+ node_id: "scott-mac-01",
68
+ name: "scott-mac",
69
+ type: "macos",
70
+ services: [
71
+ {
72
+ id: "transcripts",
73
+ methods: {
74
+ read: {
75
+ description: "读取一条转写记录",
76
+ parameters: {
77
+ type: "object",
78
+ properties: { id: { type: "string" } },
79
+ required: ["id"],
80
+ },
81
+ } satisfies MethodDescriptor,
82
+ },
83
+ access: [
84
+ { protocol: "mcp", tool: "transcript_read", server: "transcripts" },
85
+ { protocol: "http", endpoint: "GET /transcripts/:id" },
86
+ { protocol: "cli", command: "tingqi transcript get" },
87
+ ],
88
+ port: 7777,
89
+ },
90
+ ],
91
+ };
29
92
  ```
30
93
 
31
- Go / Swift 侧读同一份 `schemas/*.json`。详见 [`docs/protocol.md` §10](docs/protocol.md)。
94
+ **Go / Swift / 其他语言**:读同一份 `schemas/*.json`,手写或代码生成对应结构体。
95
+ schema 是唯一事实源。
96
+
97
+ **校验 manifest**(任意 JSON Schema draft 2020-12 校验器都行):
98
+
99
+ ```bash
100
+ npx -p ajv-cli@5 -p ajv-formats@2 ajv validate --spec=draft2020 -c ajv-formats \
101
+ -s schemas/node.schema.json -r schemas/service.schema.json -d your-manifest.json
102
+ ```
32
103
 
33
- ## 三条不能破的规则
104
+ 每个 schema 自带 `examples`,可以直接抽出来当冒烟用例跑——而且这些 example 是**被校验过的**:
105
+ 本仓的 `npm test` 会用真正的 draft 2020-12 校验器(ajv,仅 devDependency)验证每个 example
106
+ 都能通过自己的 schema,并检查跨文件 `$ref` 能解析。示例不是"示意",是能跑的冒烟用例。
107
+
108
+ ## 不能破的规则
34
109
 
35
110
  | 规则 | 破了会怎样 |
36
111
  |------|-----------|
37
112
  | **Node ≠ Agent** | 无 Agent 的录音硬件就进不了网络 |
38
- | **Capability ≠ Resource** | 调度侧与检索侧路径缠在一起 |
113
+ | **Capability ≠ Resource** | 调度侧(`invoke`)与检索侧(`search` / `read`)路径缠在一起 |
39
114
  | **Execution 不含 `task_id`** | 体外循环(想到了直接干)变成非法状态 |
115
+ | **`protocol` 不写进数据模型** | 数据模型里不存在「MCP Capability / HTTP Capability」,传输方式只出现在 `access[]` |
116
+ | **委派词汇不进 `Execution`** | 把「怎么委派」塞回执行记录,就是 `task_id` 事件的同款重演 |
117
+ | **`a2a_task_id` ≠ `task_id`** | 远端的外部 id 与本地 Task 的 id 混用,跨仓关联会指向错误的任务 |
40
118
 
41
119
  ## 依赖规则
42
120
 
43
121
  ```
44
- L4 ──→ L3 ──→ L2 / L1 ──→ L0
122
+ L4 ─→ L3 ─→ L2 / L1 ─→ L0
45
123
 
46
124
  ✅ 任何层都可以 import L0
47
125
  ❌ L0 不 import 任何人
@@ -49,10 +127,137 @@ L4 ──→ L3 ──→ L2 / L1 ──→ L0
49
127
 
50
128
  一条实操检查:**如果 A 需要 `go.mod replace` 或 `file:../` 才能用 B,说明 A 和 B 没解耦。**
51
129
 
130
+ ## 三个约定端口
131
+
132
+ 发现是 pull 的(Control Plane 探测节点的 `/manifest`),所以「哪个服务在哪个端口」必须是公共词汇:
133
+
134
+ | 端口 | 服务 | 层 |
135
+ |---|---|---|
136
+ | **`36908`** | **`@1agents/dreammate-node`(node-agent,本机唯一入口)** | **基础设施** |
137
+ | `7777` | `session-registry`(session-reader) | L2 |
138
+ | `7778` | `data-service` | L2 |
139
+ | `7779` | `control-plane` | L3 |
140
+ | `7780+` | Resource Provider 等扩展 L2 服务 | L2 |
141
+
142
+ 详见 [`docs/protocol.md` §6](docs/protocol.md)。这是**默认值,不是强制**:服务可以跑在别的端口,代价是探测发现不了它,得由它自己 `POST /nodes/register` 告知。
143
+
144
+ ## 第一个 Service 例子
145
+
146
+ ```json
147
+ {
148
+ "id": "transcripts",
149
+ "methods": {
150
+ "read": {
151
+ "description": "读取一条转写记录",
152
+ "parameters": {
153
+ "type": "object",
154
+ "properties": { "id": { "type": "string" } },
155
+ "required": ["id"]
156
+ }
157
+ }
158
+ },
159
+ "skills": {
160
+ "new_meeting": {
161
+ "name": "new_meeting",
162
+ "description": "新会议录音到来后的标准处理流程",
163
+ "sop": "1. 等待 transcription 完成 …\n2. …",
164
+ "has_package": true
165
+ }
166
+ },
167
+ "resources": [{ "scheme": "transcript" }],
168
+ "access": [
169
+ { "protocol": "mcp", "tool": "transcript_read", "server": "transcripts" },
170
+ { "protocol": "http", "endpoint": "GET /transcripts/:id" },
171
+ { "protocol": "cli", "command": "tingqi transcript get" }
172
+ ],
173
+ "execution": "hybrid",
174
+ "command": "transcribe",
175
+ "port": 7777,
176
+ "reachability": "network"
177
+ }
178
+ ```
179
+
180
+ 要点:
181
+
182
+ - `methods` 是面向大模型 / RPC 的**结构化契约**(JSON Schema 入参 / 返回);`skills` 是面向大模型的 **Markdown SOP**,描述多步编排与避坑。
183
+ - `access[]` **有序**:靠前优先、靠后 fallback。同一 protocol 可重复出现(先给 MagicDNS 名,再给 tailnet IP,兜住 DNS 被 fake-ip 代理劫持的情况)。
184
+ - `reachability: localhost` 只描述服务自己怎么监听 —— 跨节点调用仍走 `node-agent` 的 `POST /services/:id/invoke`,由本机 agent 转发到回环 HTTP / CLI;远端智能体不需要直连服务端口。
185
+
186
+ ## 第一个 Execution 例子
187
+
188
+ ```json
189
+ {
190
+ "id": "exec-2026-09-22-001",
191
+ "type": "capability_invocation",
192
+ "created_at": "2026-09-22T10:15:00Z",
193
+ "started_at": "2026-09-22T10:15:00Z",
194
+ "finished_at": "2026-09-22T10:15:00.842Z",
195
+ "status": "completed",
196
+ "node_id": "scott-mac-01",
197
+ "service_id": "transcripts",
198
+ "capability": "transcript.read",
199
+ "resource_uri": "transcript://tingqi-01/abc123",
200
+ "initiated_by_session_id": "session://scott-mac/codex/01a0907c"
201
+ }
202
+ ```
203
+
204
+ 要点:
205
+
206
+ - **没有 `task_id`**。Task 是独立的 `0..N ↔ 0..N` 关联表(`TaskExecutionLink`)。
207
+ - `status` 多了一档 `waiting_for_user` —— 接手机之后必须新增的状态,向用户描述需要他在现实世界做什么。
208
+ - `type` 不止 `agent_execution`:`capability_invocation` / `device_job` / `resource_access` / `human_action` 都是一等公民。
209
+
210
+ ## 第一版明确不做
211
+
212
+ - ❌ 不写任何业务逻辑(本包只是公共语言)
213
+ - ❌ Capability 不带 provider / permission / availability 元数据
214
+ - ❌ 不做自动服务发现(节点手工配 control-plane)
215
+ - ❌ 不做 MCP→CLI→HTTP 自动 fallback 编排
216
+ - ❌ 不做 Capability 调度评分
217
+ - ❌ 不要求所有能力统一成 MCP
218
+ - ❌ 不存 `planned = true/false`(由四个时间事实推导)
219
+ - ❌ 不存任务状态字段、不推 `PlanningClass`
220
+
221
+ ## 发布流程
222
+
223
+ **tag 就是发布事件。** `.github/workflows/publish.yml` 在「推 `v*` tag」时自动
224
+ `npm publish`(带 provenance 签名),并强制校验 tag 上的版本号 == `package.json`
225
+ 的版本号——对不上直接失败。
226
+
227
+ 于是发版就只有一个动作,**tag 与 npm 由它同时产生,天然不会漂**:
228
+
229
+ ```
230
+ bump 版本号(PR 评审) → 合进 main → npm run release
231
+ ├─ 打并推 v0.7.0 tag
232
+ └─ CI 自动 npm publish 0.7.0
233
+ ```
234
+
235
+ ```bash
236
+ npm run release # 预检 → 打 tag → 推送 → 等 CI 发布 → 验证 npm 上真的可见
237
+ npm run release:tag # 只补 tag(幂等:已有就跳过)
238
+ npm run release:check # 体检:npm 已发布版本 与 git tag 是否一一对齐
239
+ ```
240
+
241
+ `npm run release` 的预检会挡住这些情况:版本号两处不一致(`package.json` 与
242
+ `PROTOCOL_VERSION`)、工作区有未提交的改动、不在 `main` 或没跟 `origin` 同步、
243
+ typecheck / test 不过、该版本已经发过、tag 已存在。
244
+
245
+ > 发布走 CI,仓库里需要配好 `NPM_TOKEN` secret。流水线另有**幂等保护**:
246
+ > 版本已在 registry 上时跳过发布而不是报错——回填历史 tag、重跑失败的 run、
247
+ > 误推重复 tag,都不会把流水线跑红。
248
+
249
+ ## 版本
250
+
251
+ `PROTOCOL_VERSION = "0.7.0"`,与 `package.json` 同步。v0.x 期间 schema 仍可能破坏性变更,以设计册 06-实施路线图的 M1–M5 验收结果为准收敛。
252
+
253
+ v0.6.0 是**纯增量**:既有 schema 的字段与语义一律未改,只加了三块协作词汇,
254
+ 以及 `ExecutionStatus` 的一个新成员 `canceled`。变更明细见 [CHANGELOG.md](CHANGELOG.md),
255
+ 兼容规则见 [docs/protocol.md §14](docs/protocol.md)。
256
+
52
257
  ## 出处
53
258
 
54
259
  设计册是 1agents 工作区里的 `docs/architecture/dreammate-network/`(10 篇,不随本包发布)。
55
260
  本包对应其中迁移步骤 **S1**(09-仓库拆分与依赖边界 §8)。
56
261
 
57
262
  下一步是 **S2**(`modules/*` 上移)与 **S3**(session-reader 加 `1session serve` + `/manifest`)——
58
- S1–S3 就足够跑出 M1 + M2,不需要等全部拆完。
263
+ S1–S3 就足够跑出 M1 + M2,不需要等全部拆完。
@@ -12,7 +12,7 @@
12
12
  * 协议版本,与本包的 package.json 版本保持一致——两个版本号会让人永远猜不准
13
13
  * 该看哪个。服务在 `manifest.metadata.protocol_version` 里报告它遵循的版本。
14
14
  */
15
- export declare const PROTOCOL_VERSION = "0.5.0";
15
+ export declare const PROTOCOL_VERSION = "0.7.0";
16
16
  /** `session://<node>/<runtime>/<session_id>` */
17
17
  export type SessionURI = `session://${string}/${string}/${string}`;
18
18
  /** 资源寻址,如 `recording://tingqi-01/abc`、`speaker://tingqi-001/speaker-23` */
@@ -166,8 +166,10 @@ export interface Service {
166
166
  resources?: ResourceDescriptor[];
167
167
  access?: AccessDescriptor[];
168
168
  /**
169
- * 只监听回环的服务,外部节点发现得了但连不上。node agent 如实转述这个
170
- * 声明而**不做代理**——调用方看到 `localhost` 就知道不用白跑一趟。
169
+ * 服务自己怎么监听。`localhost` = 只绑回环,外部不能直连其端口;
170
+ * `network` = 可被外部直连。node agent 在 manifest 里如实转述。
171
+ * 跨节点调用走 agent 的统一入口(`POST /services/:id/invoke` 或
172
+ * MCP `dreammate_invoke`),由本机 agent 转发到回环 HTTP 或 CLI。
171
173
  */
172
174
  reachability?: Reachability;
173
175
  /** 实际监听端口。纯 CLI 模式可省略。不必等于 {@link DEFAULT_PORTS} 里的默认值。 */
@@ -214,8 +216,11 @@ export type ExecutionType =
214
216
  * `waiting_for_user` 是接入手机后必须新增的一类状态:请求用户在现实世界
215
217
  * 做某个动作(确认日程、选联系人、授权 iOS 权限)。有了它,总管才能直接
216
218
  * 回答「3 个任务正在执行,1 个等待你确认」。
219
+ *
220
+ * `canceled` 是被取消的终态,与 `failed` 并列:**取消不是失败**。
221
+ * 拼写统一单 l(`canceled`),别与历史落盘的 `cancelled` 混用。
217
222
  */
218
- export type ExecutionStatus = "queued" | "running" | "waiting_for_user" | "completed" | "failed";
223
+ export type ExecutionStatus = "queued" | "running" | "waiting_for_user" | "completed" | "failed" | "canceled";
219
224
  /**
220
225
  * 现实中实际发生的一次工作行为。
221
226
  *
@@ -315,3 +320,154 @@ export type PlanningClass =
315
320
  | "retrospective"
316
321
  /** 完全体外:没有任何 task edge */
317
322
  | "out_of_plan";
323
+ /**
324
+ * 行动者类别。person=真实的人,coach=负责给建议与把关的智能体,
325
+ * executor=实际干活的智能体,qa=独立复核方,host=宿主运行时,
326
+ * application=无智能体参与的应用。
327
+ */
328
+ export type ActorKind = "person" | "coach" | "executor" | "qa" | "host" | "application";
329
+ /**
330
+ * 谁在行动。
331
+ *
332
+ * 与 {@link Execution} 正交:一次 Execution 可以由人发起、由 agent 执行,
333
+ * 也可能两者都有。`id` / `agent` / `session_id` 都可空——不是每个行动者
334
+ * 都有账号、会话或模型。
335
+ */
336
+ export interface ActorRef {
337
+ kind: ActorKind;
338
+ id?: string | null;
339
+ agent?: string | null;
340
+ session_id?: string | SessionURI | null;
341
+ }
342
+ /**
343
+ * 这次工作处于什么模式。trial=试跑,产出可以丢弃、可以重来;
344
+ * formal=正式,产出要留痕、要被验收。
345
+ *
346
+ * 与谁来干、用什么传输无关——所以它叫 lifecycle_mode,不叫 a2a_mode。
347
+ */
348
+ export type LifecycleMode = "trial" | "formal";
349
+ /**
350
+ * 产物被验收的结论。`changes_requested` 是「已看过、但要求返工」,
351
+ * 它和 `rejected` 不是一回事:前者还能继续改,后者是终态否定。
352
+ */
353
+ export type ReviewStatus = "pending" | "accepted" | "changes_requested";
354
+ /**
355
+ * 产物的一次具体版本。revision 与 digest 一起构成乐观锁:
356
+ * 拿着旧的 revision 去提交会被拒绝,避免覆盖掉别人刚交的新版本。
357
+ */
358
+ export interface RevisionRef {
359
+ revision: string;
360
+ digest: string;
361
+ }
362
+ /**
363
+ * 对某个角色的引用。只给 id,不给角色的内容——角色的指令、检查项、
364
+ * 评测集是各自仓的资产,不进协议。
365
+ */
366
+ export interface RoleRef {
367
+ id: string;
368
+ name?: string | null;
369
+ session_id?: string | SessionURI | null;
370
+ }
371
+ /**
372
+ * 双钥匙高危提案的分类。这三类会改动评测、放宽权限、或把试跑升为正式,
373
+ * 因此需要人逐条裁决。「谁批、怎么留证」是各自仓的规则,协议只认这三个分类词。
374
+ */
375
+ export type GovernanceProposalKind = "eval_change" | "permission_escalation" | "promote_formal";
376
+ /** 过程审批请求的种类:permission=要放行一次权限使用,question=要人回答问题,plan=要人认可计划。 */
377
+ export type ProcessRequestKind = "permission" | "question" | "plan";
378
+ /**
379
+ * 过程审批请求的结论。approved=放行,rejected=拒绝,canceled=请求方自己撤销,
380
+ * accepted=人认可了内容,abandoned=挂起后无人处理。拼写统一单 l 的 canceled。
381
+ */
382
+ export type ProcessRequestOutcome = "approved" | "rejected" | "canceled" | "accepted" | "abandoned";
383
+ /**
384
+ * 一次委派的规格:交给谁、产出算不算数、要检查什么、产出什么。
385
+ *
386
+ * 描述「怎么委派」,**不要**把它塞进 Execution 的字段里——那正是
387
+ * `task_id` 事件的同款重演。
388
+ *
389
+ * 字段全是可选的:规格描述的是「请求方怎么说这次委派」,
390
+ * L0 不强制每一方都有每个概念。
391
+ *
392
+ * - `mode` 不声明或为 null = **调用方没有档位概念**(不是 trial)。
393
+ * 要强制必填的一方在自己的类型边界上强制。
394
+ * - `checks` / `outputs` 是调用方声明的清单;执行端没有同名结构化参数时,
395
+ * 由调用方适配器透传进执行 prompt,或映射进执行端的自检清单 / 结果契约。
396
+ */
397
+ export interface DelegationSpec {
398
+ mode?: LifecycleMode | null;
399
+ target_id?: string | null;
400
+ role_id?: string | null;
401
+ checks?: string[] | null;
402
+ outputs?: string[] | null;
403
+ }
404
+ /**
405
+ * 一次委派的只读投影,挂在调用方关联侧。
406
+ *
407
+ * 两条硬规则:
408
+ *
409
+ * 1. **这不是 Execution**,别写进执行账本。
410
+ * 2. `a2a_task_id` 是远端的外部 id,与 {@link TaskExecutionLink.task_id}
411
+ * 是两回事,不得混用、不得放进同一个对象。
412
+ *
413
+ * `status` 直接复用 {@link ExecutionStatus} 的取值,不新造第二套状态词汇:
414
+ * 远端还在 queued / running / failed / canceled 而尚未进入审校阶段时,
415
+ * 由它表达;审校结论另看 `review_status`。
416
+ */
417
+ export interface DelegationMirror {
418
+ job_id: string;
419
+ attempt_id?: string | null;
420
+ a2a_task_id?: string | null;
421
+ session_id?: string | SessionURI | null;
422
+ target_id?: string | null;
423
+ role_id?: string | null;
424
+ lifecycle_mode?: LifecycleMode | null;
425
+ status?: ExecutionStatus | null;
426
+ result_revision?: string | null;
427
+ result_digest?: string | null;
428
+ review_status?: ReviewStatus | null;
429
+ pending_approval_id?: string | null;
430
+ pending_proposal_count?: number | null;
431
+ updated_at: string;
432
+ }
433
+ /**
434
+ * 投递方式。queue=排进对方当前的待发队列,等它忙完再消费;
435
+ * steer=插队,立刻打断。steer 不会被合并。
436
+ *
437
+ * 名字里带 Session 是刻意的:别的仓已经有一个 `DeliveryMode` 指的是
438
+ * 「产物怎么落地」(artifacts / workspace_git / workspace_files / none),
439
+ * 同名不同义比缺名字更危险。详见 docs/protocol.md §15。
440
+ */
441
+ export type SessionDeliveryMode = "queue" | "steer";
442
+ /**
443
+ * 这条消息挂在哪个上下文上。一个会话同时承载群聊、私聊与审批时,
444
+ * 靠它防止上下文串台。字段全是可选的:没有对应上下文就整个省略。
445
+ */
446
+ export interface MessageCorrelation {
447
+ ticket_id?: string | null;
448
+ team_id?: string | null;
449
+ job_id?: string | null;
450
+ /** 远端 A2A task id。**不透明外部 id**,与 {@link TaskExecutionLink.task_id} 无关。 */
451
+ a2a_task_id?: string | null;
452
+ pending_approval_id?: string | null;
453
+ }
454
+ /**
455
+ * 跨会话投递的结构化信封。`from_session_id` 让接收方知道是谁在跟它说话。
456
+ */
457
+ export interface SessionMessageEnvelope {
458
+ from_session_id: string;
459
+ delivery_mode?: SessionDeliveryMode | null;
460
+ summary?: string | null;
461
+ correlation?: MessageCorrelation | null;
462
+ }
463
+ /**
464
+ * 一次外部事件的公共信封。`source` + `event_id` 是幂等键:同一对值重复投递
465
+ * 只算一次。它只描述「发生了什么」,不描述「投给谁、怎么投」——路由是服务端的行为。
466
+ */
467
+ export interface NotificationEvent {
468
+ source: string;
469
+ event_id: string;
470
+ event_type?: string | null;
471
+ summary: string;
472
+ occurred_at?: string | null;
473
+ }
@@ -12,7 +12,7 @@
12
12
  * 协议版本,与本包的 package.json 版本保持一致——两个版本号会让人永远猜不准
13
13
  * 该看哪个。服务在 `manifest.metadata.protocol_version` 里报告它遵循的版本。
14
14
  */
15
- export const PROTOCOL_VERSION = "0.5.0";
15
+ export const PROTOCOL_VERSION = "0.7.0";
16
16
  /* ------------------------------------------------------------------ *
17
17
  * 发现
18
18
  * ------------------------------------------------------------------ */