@1agents/dreammate-network 0.5.0 → 0.6.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,74 @@
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.6.0 — Stage 0 协作词汇
10
+
11
+ 三方(`dsh-superagent` / `1acp` / `dreammate-network`)收敛后的第一版协作词汇。
12
+ **纯增量**:现有 schema 的既有字段一律未改,`Execution` / `SessionRef` /
13
+ `Service` / `NodeManifest` 的结构与语义不变。
14
+
15
+ ### 新增 schema
16
+
17
+ | 文件 | 根对象 | 内容 |
18
+ |---|---|---|
19
+ | `schemas/governance.schema.json` | `ActorRef` | `ActorKind` / `LifecycleMode` / `ReviewStatus` / `RevisionRef` / `RoleRef` / `GovernanceProposalKind` / `ProcessRequestKind` / `ProcessRequestOutcome` |
20
+ | `schemas/delegation.schema.json` | `DelegationMirror` | `DelegationSpec`(`$defs`) |
21
+ | `schemas/message.schema.json` | `SessionMessageEnvelope` | `SessionDeliveryMode` / `MessageCorrelation` / `NotificationEvent`(`$defs`) |
22
+
23
+ ### 既有 schema 的唯一改动
24
+
25
+ - `execution.schema.json`:`status` 枚举新增成员 **`canceled`**(被取消的终态,与
26
+ `failed` 并列——取消不是失败;拼写统一单 l)。
27
+
28
+ ### 枚举变更清单(消费方必须逐条核对)
29
+
30
+ | 枚举 | 变更 |
31
+ |---|---|
32
+ | `ExecutionStatus` | **新增成员** `canceled` |
33
+
34
+ 消费方义务:**对未知枚举成员必须有 default 分支**(见 [docs/protocol.md](docs/protocol.md) §14)。
35
+
36
+ ### 留在各自仓、不进 L0 的东西(防止下一个人把它们捡回来)
37
+
38
+ - 远端内部状态机(`submitted` / `working` / `input_required` / `rejected` / `unknown` 等 10 态)
39
+ - ticket 提案族(`ProposalKind` 的 `check|role|qa|locked`、`ProposalState`)
40
+ - Coach 动作名(`inspect` / `approve` / `reopen` / `stop_or_escalate`)——用
41
+ `Service.methods` + `MethodDescriptor` 声明发现
42
+ - 通知的路由参数(`mode: auto|direct|group` / `at` / `team_id` / `fallback`)
43
+ - 投递队列的合并算法、绑定表刷新策略、各 RPC 方法名、正文的渲染格式
44
+
45
+ ### 新增的四条硬规则(已写进 `test/schemas.test.js`)
46
+
47
+ - **委派词汇不进 `Execution`**:`delegation` / `lifecycle_mode` / `job_id` 等一律不许
48
+ 出现在 `Execution` 上——那是 `task_id` 事件的同款重演。
49
+ - **远端 `a2a_task_id` 与本地 `task_id` 彻底隔离**:两者不得出现在同一个对象里。
50
+ - **L0 不导出 `DeliveryMode`**:1acp 已有同名的 `DeliveryMode`(`artifacts` /
51
+ `workspace_git` / `workspace_files` / `none`,指产物怎么落地),与 L0 的投递语义
52
+ 同名不同义。L0 这边叫 `SessionDeliveryMode`(`queue` / `steer`)。
53
+ - **schema 与 types.ts 的 null 容忍度逐字段对齐**:可选且可为 null 的字段,
54
+ schema 里必须收 null——内联类型写 `["X","null"]`,用 `$ref` 时写
55
+ `anyOf: [{$ref}, {type:"null"}]`。裸 `$ref` 会悄悄丢掉 null。
56
+
57
+ ### 已知撞名与消费方映射
58
+
59
+ 见 [docs/protocol.md §15](docs/protocol.md) —— 1acp 与 dsh-superagent 的逐条对照表。
60
+ 已查实的:`AssetLifecycle` ≡ L0 `LifecycleMode`;`GovernanceProposalKind` 完全一致;
61
+ `LifecycleActor` ⊂ L0 `ActorKind`;1acp 的 `DeliveryMode` 与 dsh-superagent 的
62
+ `ActorRef` 均**同名不同义**,前者保留原名、后者用别名导入。
63
+
64
+ ### 消费方升级提示
65
+
66
+ npm 的 `^0.5.0` **不包含** 0.6.0(0.x 的 caret 是 minor 锁)。要用新词汇必须显式
67
+ 升到 `"@1agents/dreammate-network": "^0.6.0"`。同一 workspace 内不要同时存在两个
68
+ L0 版本,否则同名 enum 会出现两份。
69
+
70
+ ## 0.5.0
71
+
72
+ - Service 补齐 `methods` / `skills`,`capabilities` 标记 `@deprecated`
73
+ - Service 补齐 `execution` / `command` / `lifecycle`
74
+ - README 重写为 Capability Network 定位
package/README.md CHANGED
@@ -1,47 +1,123 @@
1
1
  # dreammate-network
2
2
 
3
- > DreamMate Network 的 **L0 协议包**:schema + types,零依赖,**不含业务逻辑**。
4
- > 版本 0.1.0 | 状态:草案
3
+ > DreamMate Network 的 **L0 协议包**:schema + TypeScript 类型,零运行时依赖,**不含业务逻辑**。
4
+ > 版本 **0.6.0** | 状态:**已发布**(npm: `@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
+ };
92
+ ```
93
+
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
29
102
  ```
30
103
 
31
- Go / Swift 侧读同一份 `schemas/*.json`。详见 [`docs/protocol.md` §10](docs/protocol.md)。
104
+ 每个 schema 自带 `examples`,可以直接抽出来当冒烟用例跑。
32
105
 
33
- ## 三条不能破的规则
106
+ ## 不能破的规则
34
107
 
35
108
  | 规则 | 破了会怎样 |
36
109
  |------|-----------|
37
110
  | **Node ≠ Agent** | 无 Agent 的录音硬件就进不了网络 |
38
- | **Capability ≠ Resource** | 调度侧与检索侧路径缠在一起 |
111
+ | **Capability ≠ Resource** | 调度侧(`invoke`)与检索侧(`search` / `read`)路径缠在一起 |
39
112
  | **Execution 不含 `task_id`** | 体外循环(想到了直接干)变成非法状态 |
113
+ | **`protocol` 不写进数据模型** | 数据模型里不存在「MCP Capability / HTTP Capability」,传输方式只出现在 `access[]` |
114
+ | **委派词汇不进 `Execution`** | 把「怎么委派」塞回执行记录,就是 `task_id` 事件的同款重演 |
115
+ | **`a2a_task_id` ≠ `task_id`** | 远端的外部 id 与本地 Task 的 id 混用,跨仓关联会指向错误的任务 |
40
116
 
41
117
  ## 依赖规则
42
118
 
43
119
  ```
44
- L4 ──→ L3 ──→ L2 / L1 ──→ L0
120
+ L4 ─→ L3 ─→ L2 / L1 ─→ L0
45
121
 
46
122
  ✅ 任何层都可以 import L0
47
123
  ❌ L0 不 import 任何人
@@ -49,10 +125,109 @@ L4 ──→ L3 ──→ L2 / L1 ──→ L0
49
125
 
50
126
  一条实操检查:**如果 A 需要 `go.mod replace` 或 `file:../` 才能用 B,说明 A 和 B 没解耦。**
51
127
 
128
+ ## 三个约定端口
129
+
130
+ 发现是 pull 的(Control Plane 探测节点的 `/manifest`),所以「哪个服务在哪个端口」必须是公共词汇:
131
+
132
+ | 端口 | 服务 | 层 |
133
+ |---|---|---|
134
+ | **`36908`** | **`@1agents/dreammate-node`(node-agent,本机唯一入口)** | **基础设施** |
135
+ | `7777` | `session-registry`(session-reader) | L2 |
136
+ | `7778` | `data-service` | L2 |
137
+ | `7779` | `control-plane` | L3 |
138
+ | `7780+` | Resource Provider 等扩展 L2 服务 | L2 |
139
+
140
+ 详见 [`docs/protocol.md` §6](docs/protocol.md)。这是**默认值,不是强制**:服务可以跑在别的端口,代价是探测发现不了它,得由它自己 `POST /nodes/register` 告知。
141
+
142
+ ## 第一个 Service 例子
143
+
144
+ ```json
145
+ {
146
+ "id": "transcripts",
147
+ "methods": {
148
+ "read": {
149
+ "description": "读取一条转写记录",
150
+ "parameters": {
151
+ "type": "object",
152
+ "properties": { "id": { "type": "string" } },
153
+ "required": ["id"]
154
+ }
155
+ }
156
+ },
157
+ "skills": {
158
+ "new_meeting": {
159
+ "name": "new_meeting",
160
+ "description": "新会议录音到来后的标准处理流程",
161
+ "sop": "1. 等待 transcription 完成 …\n2. …",
162
+ "has_package": true
163
+ }
164
+ },
165
+ "resources": [{ "scheme": "transcript" }],
166
+ "access": [
167
+ { "protocol": "mcp", "tool": "transcript_read", "server": "transcripts" },
168
+ { "protocol": "http", "endpoint": "GET /transcripts/:id" },
169
+ { "protocol": "cli", "command": "tingqi transcript get" }
170
+ ],
171
+ "execution": "hybrid",
172
+ "command": "transcribe",
173
+ "port": 7777,
174
+ "reachability": "network"
175
+ }
176
+ ```
177
+
178
+ 要点:
179
+
180
+ - `methods` 是面向大模型 / RPC 的**结构化契约**(JSON Schema 入参 / 返回);`skills` 是面向大模型的 **Markdown SOP**,描述多步编排与避坑。
181
+ - `access[]` **有序**:靠前优先、靠后 fallback。同一 protocol 可重复出现(先给 MagicDNS 名,再给 tailnet IP,兜住 DNS 被 fake-ip 代理劫持的情况)。
182
+ - `reachability: localhost` 只描述服务自己怎么监听 —— 跨节点调用仍走 `node-agent` 的 `POST /services/:id/invoke`,由本机 agent 转发到回环 HTTP / CLI;远端智能体不需要直连服务端口。
183
+
184
+ ## 第一个 Execution 例子
185
+
186
+ ```json
187
+ {
188
+ "id": "exec-2026-09-22-001",
189
+ "type": "capability_invocation",
190
+ "created_at": "2026-09-22T10:15:00Z",
191
+ "started_at": "2026-09-22T10:15:00Z",
192
+ "finished_at": "2026-09-22T10:15:00.842Z",
193
+ "status": "completed",
194
+ "node_id": "scott-mac-01",
195
+ "service_id": "transcripts",
196
+ "capability": "transcript.read",
197
+ "resource_uri": "transcript://tingqi-01/abc123",
198
+ "initiated_by_session_id": "session://scott-mac/codex/01a0907c"
199
+ }
200
+ ```
201
+
202
+ 要点:
203
+
204
+ - **没有 `task_id`**。Task 是独立的 `0..N ↔ 0..N` 关联表(`TaskExecutionLink`)。
205
+ - `status` 多了一档 `waiting_for_user` —— 接手机之后必须新增的状态,向用户描述需要他在现实世界做什么。
206
+ - `type` 不止 `agent_execution`:`capability_invocation` / `device_job` / `resource_access` / `human_action` 都是一等公民。
207
+
208
+ ## 第一版明确不做
209
+
210
+ - ❌ 不写任何业务逻辑(本包只是公共语言)
211
+ - ❌ Capability 不带 provider / permission / availability 元数据
212
+ - ❌ 不做自动服务发现(节点手工配 control-plane)
213
+ - ❌ 不做 MCP→CLI→HTTP 自动 fallback 编排
214
+ - ❌ 不做 Capability 调度评分
215
+ - ❌ 不要求所有能力统一成 MCP
216
+ - ❌ 不存 `planned = true/false`(由四个时间事实推导)
217
+ - ❌ 不存任务状态字段、不推 `PlanningClass`
218
+
219
+ ## 版本
220
+
221
+ `PROTOCOL_VERSION = "0.6.0"`,与 `package.json` 同步。v0.x 期间 schema 仍可能破坏性变更,以设计册 06-实施路线图的 M1–M5 验收结果为准收敛。
222
+
223
+ v0.6.0 是**纯增量**:既有 schema 的字段与语义一律未改,只加了三块协作词汇,
224
+ 以及 `ExecutionStatus` 的一个新成员 `canceled`。变更明细见 [CHANGELOG.md](CHANGELOG.md),
225
+ 兼容规则见 [docs/protocol.md §14](docs/protocol.md)。
226
+
52
227
  ## 出处
53
228
 
54
229
  设计册是 1agents 工作区里的 `docs/architecture/dreammate-network/`(10 篇,不随本包发布)。
55
230
  本包对应其中迁移步骤 **S1**(09-仓库拆分与依赖边界 §8)。
56
231
 
57
232
  下一步是 **S2**(`modules/*` 上移)与 **S3**(session-reader 加 `1session serve` + `/manifest`)——
58
- S1–S3 就足够跑出 M1 + M2,不需要等全部拆完。
233
+ 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.6.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,146 @@ 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
+ export interface DelegationSpec {
390
+ mode: LifecycleMode;
391
+ target_id?: string | null;
392
+ role_id?: string | null;
393
+ checks?: string[] | null;
394
+ outputs?: string[] | null;
395
+ }
396
+ /**
397
+ * 一次委派的只读投影,挂在调用方关联侧。
398
+ *
399
+ * 两条硬规则:
400
+ *
401
+ * 1. **这不是 Execution**,别写进执行账本。
402
+ * 2. `a2a_task_id` 是远端的外部 id,与 {@link TaskExecutionLink.task_id}
403
+ * 是两回事,不得混用、不得放进同一个对象。
404
+ *
405
+ * `status` 直接复用 {@link ExecutionStatus} 的取值,不新造第二套状态词汇:
406
+ * 远端还在 queued / running / failed / canceled 而尚未进入审校阶段时,
407
+ * 由它表达;审校结论另看 `review_status`。
408
+ */
409
+ export interface DelegationMirror {
410
+ job_id: string;
411
+ attempt_id?: string | null;
412
+ a2a_task_id?: string | null;
413
+ session_id?: string | SessionURI | null;
414
+ target_id?: string | null;
415
+ role_id?: string | null;
416
+ lifecycle_mode?: LifecycleMode | null;
417
+ status?: ExecutionStatus | null;
418
+ result_revision?: string | null;
419
+ result_digest?: string | null;
420
+ review_status?: ReviewStatus | null;
421
+ pending_approval_id?: string | null;
422
+ pending_proposal_count?: number | null;
423
+ updated_at: string;
424
+ }
425
+ /**
426
+ * 投递方式。queue=排进对方当前的待发队列,等它忙完再消费;
427
+ * steer=插队,立刻打断。steer 不会被合并。
428
+ *
429
+ * 名字里带 Session 是刻意的:别的仓已经有一个 `DeliveryMode` 指的是
430
+ * 「产物怎么落地」(artifacts / workspace_git / workspace_files / none),
431
+ * 同名不同义比缺名字更危险。详见 docs/protocol.md §15。
432
+ */
433
+ export type SessionDeliveryMode = "queue" | "steer";
434
+ /**
435
+ * 这条消息挂在哪个上下文上。一个会话同时承载群聊、私聊与审批时,
436
+ * 靠它防止上下文串台。字段全是可选的:没有对应上下文就整个省略。
437
+ */
438
+ export interface MessageCorrelation {
439
+ ticket_id?: string | null;
440
+ team_id?: string | null;
441
+ job_id?: string | null;
442
+ /** 远端 A2A task id。**不透明外部 id**,与 {@link TaskExecutionLink.task_id} 无关。 */
443
+ a2a_task_id?: string | null;
444
+ pending_approval_id?: string | null;
445
+ }
446
+ /**
447
+ * 跨会话投递的结构化信封。`from_session_id` 让接收方知道是谁在跟它说话。
448
+ */
449
+ export interface SessionMessageEnvelope {
450
+ from_session_id: string;
451
+ delivery_mode?: SessionDeliveryMode | null;
452
+ summary?: string | null;
453
+ correlation?: MessageCorrelation | null;
454
+ }
455
+ /**
456
+ * 一次外部事件的公共信封。`source` + `event_id` 是幂等键:同一对值重复投递
457
+ * 只算一次。它只描述「发生了什么」,不描述「投给谁、怎么投」——路由是服务端的行为。
458
+ */
459
+ export interface NotificationEvent {
460
+ source: string;
461
+ event_id: string;
462
+ event_type?: string | null;
463
+ summary: string;
464
+ occurred_at?: string | null;
465
+ }
@@ -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.6.0";
16
16
  /* ------------------------------------------------------------------ *
17
17
  * 发现
18
18
  * ------------------------------------------------------------------ */
package/docs/protocol.md CHANGED
@@ -1,4 +1,4 @@
1
- # DreamMate Network Protocol v0.1.0
1
+ # DreamMate Network Protocol v0.6.0
2
2
 
3
3
  > L0 协议层。**零依赖,不含业务逻辑。**
4
4
  > 设计依据:1agents 工作区的 `docs/architecture/dreammate-network/`(10 篇设计册,不随本包发布)
@@ -7,6 +7,10 @@
7
7
  ## 1. 定位
8
8
 
9
9
  **DreamMate Network 不是 Agent Network,是 Capability Network。**
10
+ 它让设备和软件向智能体公开自己的能力,并提供统一的发现与调用入口。
11
+
12
+ 运行时入口是每台机器上的 `@1agents/dreammate-node`:负责**登记、发现、执行调用**。
13
+ 什么时候处理新录音、如何判断客户、如何生成跟进事项,仍由业务流程或智能体承担。
10
14
 
11
15
  - **Agent** 负责思考与编排
12
16
  - **设备 / 节点** 负责提供能力与数据
@@ -63,7 +67,7 @@ Execution
63
67
  | **Capability ≠ Resource** | 调度侧与检索侧路径缠在一起 |
64
68
  | **Execution 不含 task_id** | 体外循环(想到了直接干)变成非法状态 |
65
69
 
66
- ## 3. 四个 Schema
70
+ ## 3. 七个 Schema
67
71
 
68
72
  | 文件 | 对应类型 | 用在哪 |
69
73
  |------|----------|--------|
@@ -71,6 +75,9 @@ Execution
71
75
  | [`schemas/service.schema.json`](../schemas/service.schema.json) | `Service`、`AccessDescriptor` | 嵌在 Node Manifest 内 |
72
76
  | [`schemas/execution.schema.json`](../schemas/execution.schema.json) | `Execution` | `POST /executions`、`PATCH /executions/:id` |
73
77
  | [`schemas/session-ref.schema.json`](../schemas/session-ref.schema.json) | `SessionRef` | 跨机 Session 引用与图的边 |
78
+ | [`schemas/governance.schema.json`](../schemas/governance.schema.json) | `ActorRef`(+ 8 个 `$defs`) | 谁在行动、以什么模式、验收结论、角色引用 |
79
+ | [`schemas/delegation.schema.json`](../schemas/delegation.schema.json) | `DelegationMirror`(+ `DelegationSpec`) | 一次委派的只读投影 |
80
+ | [`schemas/message.schema.json`](../schemas/message.schema.json) | `SessionMessageEnvelope`(+ 3 个 `$defs`) | 跨会话投递与外部事件信封 |
74
81
 
75
82
  Schema 与 [`typescript/types.ts`](../typescript/types.ts) 一一对应,**改动必须同步两边**。
76
83
 
@@ -78,6 +85,22 @@ Schema 与 [`typescript/types.ts`](../typescript/types.ts) 一一对应,**改
78
85
  前者是 Control Plane 侧的存储关系(不在节点间传输),后者是从时间事实推导出的
79
86
  分类命名(协议不存储它,也不在 L0 实现推导)。
80
87
 
88
+ ### null 容忍度必须两边一致
89
+
90
+ 改 schema 就得同时改 `typescript/types.ts`,反之亦然。具体的硬约束:
91
+
92
+ | 字段形态 | schema 怎么写 | types.ts 怎么写 |
93
+ |---|---|---|
94
+ | 必填 | `"type": "X"` | `x: X` |
95
+ | 可选、可为 null | `"type": ["X", "null"]` | `x?: X \| null` |
96
+ | 可选、不接受 null | `"type": "X"` | `x?: X` |
97
+ | 可选、可为 null、**用 `$ref` 指向别处** | `"anyOf": [{ "$ref": … }, { "type": "null" }]` | `x?: X \| null` |
98
+
99
+ ⚠️ 最后一行最容易漏:**裸 `$ref` 只指向 `type: "string"` / `type: "object"`,
100
+ 不会带上 null**。数据库/JSON 行里带出来的是显式 null,不是「没这个字段」,
101
+ 消费方按类型合法传出 null 时校验就会报错。`test/schemas.test.js` 有一条
102
+ 逐字段门禁钉住这件事(硬规则七),新增 `$ref` 字段时请一并想清楚。
103
+
81
104
  ## 4. URI 方案
82
105
 
83
106
  ```
@@ -159,34 +182,42 @@ pull 要知道探哪儿,所以端口是公共词汇的一部分:
159
182
  ### 本机 node agent
160
183
 
161
184
  每台机器跑一个 `@1agents/dreammate-node`,固定监听 **36908**。它是这台机器
162
- 对网络的唯一入口:
185
+ 对网络的唯一入口:设备和软件向它登记能力,智能体通过它发现并调用。
163
186
 
164
187
  ```
165
- Control Plane / 任意节点
188
+ Control Plane / 任意节点 / 智能体
166
189
  │ 探 36908(每台机器只探一个端口)
167
190
  ▼
168
191
  node-agent :36908
169
- ├─ GET /manifest 本机聚合视图:节点身份 + 所有已报备的服务
192
+ ├─ GET /manifest 本机聚合视图:节点身份 + 已报备服务
170
193
  ├─ GET /health
171
- ├─ GET /services 各服务的存活与可达性
172
- └─ POST /services 服务报备(**仅接受 localhost**)
194
+ ├─ GET /nodes 本 tailnet 内的设备节点
195
+ ├─ GET /services 各服务的存活与可达性
196
+ ├─ POST /services 服务报备(**仅接受 localhost**)
197
+ ├─ POST /services/:id/invoke 统一调用(转发到本机 HTTP 或 CLI)
198
+ ├─ POST /capabilities/:name/invoke
199
+ ├─ POST /services/:id/start|stop 部分服务的启停
200
+ └─ GET /services/:id/skills/:name/archive
173
201
  ▲
174
202
  ┌───────────┴───────────┐ localhost 报备
175
203
  session-reader :7777 task-service :xxxx
176
204
  ```
177
205
 
178
- 这把 pull 探测的成本从「N 个节点 × M 个端口」降到「N × 1」。
206
+ 这把 pull 探测的成本从「N 个节点 × M 个端口」降到「N × 1」,
207
+ 并把「找到能力」和「执行调用」收成同一个入口。
179
208
 
180
209
  **报备是可选的。** 服务不报备也能工作,只是外部得靠约定端口才找得到它。
181
- 报备时必须声明**可达性**:
210
+ 报备时必须声明**可达性**——这描述的是服务自己怎么监听,不是「能不能被调用」:
182
211
 
183
212
  | `reachability` | 含义 |
184
213
  |---|---|
185
- | `localhost` | 只监听回环,外部节点发现得了但连不上 |
186
- | `network` | 监听 0.0.0.0 或 tailnet 地址,外部可直连 |
214
+ | `localhost` | 服务只监听回环,外部节点**不能直连其端口** |
215
+ | `network` | 服务监听 0.0.0.0 或 tailnet 地址,外部可直连 |
187
216
 
188
- agent 如实转述这个声明,**不做代理**。调用方看到 `localhost` 就知道这个能力
189
- 只对本机开放,不用白跑一趟。
217
+ agent 在 manifest 里如实转述这个声明。跨节点调用走 agent 自己的统一入口
218
+ (`POST /services/:id/invoke` 或 MCP `dreammate_invoke`):本机 agent 把请求
219
+ 转发到回环 HTTP 或本机命令,调用方不必直连服务端口。因此
220
+ `reachability: localhost` 的服务仍然可以被远端智能体使用。
190
221
 
191
222
  > ⚠️ `POST /services` 只接受来自回环的请求。否则网络上任何人都能往你的节点
192
223
  > 里塞一个假服务,把调用方引到别处去。
@@ -340,11 +371,18 @@ npx -p ajv-cli@5 -p ajv-formats@2 ajv validate --spec=draft2020 -c ajv-formats \
340
371
  # 否则 ajv 会报 unknown format "date-time"。
341
372
  npx -p ajv-cli@5 -p ajv-formats@2 ajv validate --spec=draft2020 -c ajv-formats \
342
373
  -s schemas/execution.schema.json -d your-execution.json
374
+
375
+ # DelegationMirror 跨文件 $ref 了 governance 的枚举与 execution 的 status,
376
+ # 两个都要用 -r 带进来,否则 ajv 会报 can't resolve reference。
377
+ npx -p ajv-cli@5 -p ajv-formats@2 ajv validate --spec=draft2020 -c ajv-formats \
378
+ -s schemas/delegation.schema.json \
379
+ -r schemas/governance.schema.json -r schemas/execution.schema.json \
380
+ -d your-mirror.json
343
381
  ```
344
382
 
345
383
  每个 schema 自带 `examples`,可以直接抽出来当冒烟用例跑。
346
384
 
347
- ## 11. 第一版明确不做
385
+ ## 11. 明确不做
348
386
 
349
387
  - ❌ 不写任何业务逻辑(本包只是公共语言)
350
388
  - ❌ Capability 不带 provider / permission / availability 元数据
@@ -353,8 +391,79 @@ npx -p ajv-cli@5 -p ajv-formats@2 ajv validate --spec=draft2020 -c ajv-formats \
353
391
  - ❌ 不做 Capability 调度评分
354
392
  - ❌ 不要求所有能力统一成 MCP
355
393
  - ❌ 不存 `planned = true/false`(由时间事实推导)
394
+ - ❌ 不收任何一方的**内部状态机**(远端的 `submitted`/`working`/`input_required` 等 10 态不进 L0)
395
+ - ❌ 不收 ticket 提案族(`ProposalKind` 的 `check|role|qa|locked`、`ProposalState`)
396
+ - ❌ 不收 Coach 动作名——用 `Service.methods` + `MethodDescriptor` 声明发现,不硬编码进数据模型
397
+ - ❌ 不收通知的路由参数(`mode: auto|direct|group` / `at` / `team_id` / `fallback`)
398
+ - ❌ 不收投递队列的合并算法、绑定表刷新策略、各 RPC 方法名、正文的渲染格式
399
+ - ❌ 不把委派词汇塞进 `Execution`
356
400
 
357
401
  ## 12. 版本
358
402
 
359
- `PROTOCOL_VERSION = "0.1.0"`。v0.x 期间 schema 可能破坏性变更,
403
+ `PROTOCOL_VERSION = "0.6.0"`,与 `package.json` 同步。v0.x 期间 schema 仍可能破坏性变更,
360
404
  以设计册 06-实施路线图的 M1–M5 验收结果为准收敛。
405
+
406
+ ## 13. Stage 0 协作词汇(v0.6.0)
407
+
408
+ v0.6.0 起,L0 除了六个核心对象,还多出三块**协作词汇**。它们回答的是
409
+ 「谁在做什么、这次委派到哪了、这条消息挂在哪个上下文上」。
410
+
411
+ | 块 | 根对象 | 里面有什么 |
412
+ |----|--------|-----------|
413
+ | 治理 | `ActorRef` | `ActorKind`、`LifecycleMode`、`ReviewStatus`、`RevisionRef`、`RoleRef`、`GovernanceProposalKind`、`ProcessRequestKind`、`ProcessRequestOutcome` |
414
+ | 委派 | `DelegationMirror` | 只读投影;`DelegationSpec` 在 `$defs` 里 |
415
+ | 消息 | `SessionMessageEnvelope` | `SessionDeliveryMode`、`MessageCorrelation`、`NotificationEvent` |
416
+
417
+ 三条要记住的边界:
418
+
419
+ 1. **`DelegationMirror` 不是 `Execution`。** 它是调用方侧的只读镜像,写不进执行账本。
420
+ `Execution` 也不长出 `delegation` / `lifecycle_mode` 这类字段——那是 `task_id`
421
+ 事件的同款重演。
422
+ 2. **`a2a_task_id` 是远端的外部 id**,和 `TaskExecutionLink.task_id` 是两回事,
423
+ 不得混用、不得同现于一个对象。
424
+ 3. **镜像的 `status` 直接复用 `ExecutionStatus`**,不新造第二套状态词汇。
425
+ 审校结论另看 `review_status`。
426
+
427
+ ## 14. 兼容规则
428
+
429
+ L0 是被多个仓同时消费的契约,改动前先看这一节。
430
+
431
+ | 改动 | 允许吗 | 代价 |
432
+ |------|-------|------|
433
+ | 新增 schema 文件 / 新增可选字段 / 新增独立类型 | ✅ | 版本递进 minor |
434
+ | 枚举新增成员 | ✅ 但必须公告 | CHANGELOG 写明「枚举名 + 新增成员」 |
435
+ | 删除字段 / 改语义 / 收紧 required / 改字段名 | ⚠️ 0.x 允许 | 必须同版本给迁移说明 |
436
+
437
+ 两条硬约束:
438
+
439
+ - **每次 schema 变更 = `PROTOCOL_VERSION` 递进 minor**,不允许只改 schema 不升版本。
440
+ - **消费方义务:对未知枚举成员必须有 default 分支。** 0.x 允许枚举新增成员,
441
+ 就是为了让消费方不用每次都跟着升级;前提是消费方别把未知成员当错误处理。
442
+
443
+ > ⚠️ npm 的 `^0.5.0` **不包含** 0.6.0(0.x 的 caret 是 minor 锁)。要用新词汇必须
444
+ > 显式升到 `"@1agents/dreammate-network": "^0.6.0"`。同一 workspace 内不要同时存在
445
+ > 两个 L0 版本,否则同名 enum 会出现两份。
446
+
447
+ ## 15. 消费方命名映射与已知撞名
448
+
449
+ v0.6.0 是多个仓同时升级的版本,撞名在所难免。这一节把**已经查实的**撞名列清楚,
450
+ 别名导入是消费方自己的事,协议不替谁改类型名。
451
+
452
+ ### 1acp(`packages/service/src`)
453
+
454
+ | 1acp 现有 | 与 L0 的关系 | 建议 |
455
+ |---|---|---|
456
+ | `AssetLifecycle`(`roles/asset-lifecycle.ts:25`,`trial`/`formal`) | **与 L0 `LifecycleMode` 完全一致** | 改用 L0 的 `LifecycleMode`,别再写第二份 |
457
+ | `LifecycleActor`(`asset-lifecycle.ts:27`,`person`/`coach`/`executor`) | L0 `ActorKind` 的**子集**(L0 多 `qa`/`host`/`application`) | 只要子集就保留原类型;要覆盖全域就改用 L0 |
458
+ | `GOVERNANCE_PROPOSAL_KINDS` / `GovernanceProposalKind`(`execution/ticket.ts:13-14`) | **与 L0 `GovernanceProposalKind` 完全一致** | 从 L0 派生,别再自己写一份 |
459
+ | `DeliveryMode`(`a2a/job-directory.ts:11`,`artifacts`/`workspace_git`/`workspace_files`/`none`) | **同名不同义**:那指的是「产物怎么落地」 | 保留原名不动。L0 这边已改名 `SessionDeliveryMode` 避开 |
460
+ | `session-delivery.ts:9` 的局部 `deliveryModeSchema`(`queue`/`steer`) | 与 L0 `SessionDeliveryMode` 一致 | 需要跨仓共享时改用 L0 的 |
461
+
462
+ ### dsh-superagent
463
+
464
+ | dsh-superagent 现有 | 与 L0 的关系 | 建议 |
465
+ |---|---|---|
466
+ | `src/core/model.ts` 的 `ActorRef { source, id }`(Source 域) | **同名不同义**:那是「来源」不是「行动者」 | 别名导入:`import type { ActorRef as GovernanceActorRef }` |
467
+
468
+ > 这一节是**迁移期的对照表**,不是长期契约。各仓都迁完之后就把它删掉。
469
+ > 新增消费方时,请把自己的撞名补进来——这一节的价值随参与者增加而增加。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agents/dreammate-network",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "DreamMate Network L0 协议包:schema + types,零运行时依赖,不含业务逻辑。",
5
5
  "keywords": [
6
6
  "dreammate",
@@ -29,7 +29,8 @@
29
29
  "dist",
30
30
  "schemas",
31
31
  "docs",
32
- "README.md"
32
+ "README.md",
33
+ "CHANGELOG.md"
33
34
  ],
34
35
  "sideEffects": false,
35
36
  "scripts": {
@@ -0,0 +1,158 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dreammate.work/schemas/delegation.schema.json",
4
+ "title": "DreamMate Delegation Mirror",
5
+ "description": "一次委派的只读投影(DelegationMirror)及其委派规格(DelegationSpec)。它是调用方侧的镜像,不是 Execution:现实中发生的那一次工作行为仍然是 Execution,这里只镜像对方回执里与跨仓相关的那几个事实。**不要**把 delegation / lifecycle_mode 塞进 Execution——那正是 task_id 事件的同款重演。a2a_task_id 是远端的外部 id,与 TaskExecutionLink.task_id 是两回事,不得混用。",
6
+ "type": "object",
7
+ "required": ["job_id", "updated_at"],
8
+ "properties": {
9
+ "job_id": {
10
+ "type": "string",
11
+ "minLength": 1,
12
+ "description": "这次委派在远端的作业 id。"
13
+ },
14
+ "attempt_id": {
15
+ "type": ["string", "null"],
16
+ "description": "作业下的某一次执行尝试。续派会产生新的 attempt,job 不变。"
17
+ },
18
+ "a2a_task_id": {
19
+ "type": ["string", "null"],
20
+ "description": "远端 A2A 协议自己的 task id。**不透明外部 id**:它不是本地 Task 的 id,也不参与 TaskExecutionLink 的关联。",
21
+ "examples": ["a2a-task-8f21c0"]
22
+ },
23
+ "session_id": {
24
+ "type": ["string", "null"],
25
+ "description": "被委派方这次工作的会话。可以是本地 session id,也可以是 session:// URI。",
26
+ "examples": ["session://scott-mac/codex/01a0907c"]
27
+ },
28
+ "target_id": {
29
+ "type": ["string", "null"],
30
+ "description": "被委派给谁(已登记的执行目标或角色)。"
31
+ },
32
+ "role_id": {
33
+ "type": ["string", "null"],
34
+ "description": "被委派方扮演的角色 id。",
35
+ "examples": ["pr-delivery"]
36
+ },
37
+ "lifecycle_mode": {
38
+ "anyOf": [
39
+ { "$ref": "https://dreammate.work/schemas/governance.schema.json#/$defs/lifecycleMode" },
40
+ { "type": "null" }
41
+ ],
42
+ "description": "这次委派的模式。显式 null 与省略等价——数据库/JSON 行里带出来的是 null,不是「没这个字段」。"
43
+ },
44
+ "status": {
45
+ "anyOf": [
46
+ { "$ref": "https://dreammate.work/schemas/execution.schema.json#/properties/status" },
47
+ { "type": "null" }
48
+ ],
49
+ "description": "粗粒度进展。直接复用 L0 既有的 ExecutionStatus 取值,不新造第二套状态词汇:远端还在 queued / running / failed / canceled 而尚未进入审校阶段时,由它表达。审校结论另看 review_status。"
50
+ },
51
+ "result_revision": {
52
+ "type": ["string", "null"],
53
+ "description": "当前产物的版本。与 result_digest 一起构成乐观锁。"
54
+ },
55
+ "result_digest": {
56
+ "type": ["string", "null"],
57
+ "description": "当前产物的内容摘要。",
58
+ "examples": ["sha256:9f2c1e..."]
59
+ },
60
+ "review_status": {
61
+ "anyOf": [
62
+ { "$ref": "https://dreammate.work/schemas/governance.schema.json#/$defs/reviewStatus" },
63
+ { "type": "null" }
64
+ ],
65
+ "description": "验收结论。还没进入审校阶段时为 null——它表达的是「还没审」,不是「审了但没结论」。"
66
+ },
67
+ "pending_approval_id": {
68
+ "type": ["string", "null"],
69
+ "description": "当前挂着的那个审批请求 id。有值表示在等人拍板,不是终态。"
70
+ },
71
+ "pending_proposal_count": {
72
+ "type": ["integer", "null"],
73
+ "minimum": 0,
74
+ "description": "还没裁决的提案条数。"
75
+ },
76
+ "updated_at": {
77
+ "type": "string",
78
+ "format": "date-time",
79
+ "description": "这份镜像的最后更新时间。"
80
+ }
81
+ },
82
+ "$defs": {
83
+ "delegationSpec": {
84
+ "type": "object",
85
+ "title": "Delegation Specification",
86
+ "description": "一次委派的规格:交给谁、以什么模式、要检查什么、产出什么。它描述「怎么委派」,不是 Execution 的一部分——不要把它塞进 Execution 的字段里。",
87
+ "required": ["mode"],
88
+ "properties": {
89
+ "mode": {
90
+ "$ref": "https://dreammate.work/schemas/governance.schema.json#/$defs/lifecycleMode"
91
+ },
92
+ "target_id": {
93
+ "type": ["string", "null"],
94
+ "description": "交给谁(已登记的执行目标或角色)。"
95
+ },
96
+ "role_id": {
97
+ "type": ["string", "null"],
98
+ "description": "要求对方扮演的角色 id。"
99
+ },
100
+ "checks": {
101
+ "type": ["array", "null"],
102
+ "items": { "type": "string" },
103
+ "description": "要求对方执行的检查项名称。具体怎么检查是各自仓的事。"
104
+ },
105
+ "outputs": {
106
+ "type": ["array", "null"],
107
+ "items": { "type": "string" },
108
+ "description": "要求对方交付的产物名称。"
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "examples": [
114
+ {
115
+ "job_id": "job-0ba07988",
116
+ "attempt_id": "attempt-1",
117
+ "a2a_task_id": "a2a-task-8f21c0",
118
+ "session_id": "session://scott-mac/codex/01a0907c",
119
+ "target_id": "legacy:dsh-superagent",
120
+ "role_id": "pr-delivery",
121
+ "lifecycle_mode": "formal",
122
+ "status": "running",
123
+ "result_revision": "rev-7",
124
+ "result_digest": "sha256:9f2c1e...",
125
+ "review_status": "pending",
126
+ "pending_approval_id": "approval-31",
127
+ "pending_proposal_count": 2,
128
+ "updated_at": "2026-11-28T10:01:00.230Z"
129
+ },
130
+ {
131
+ "job_id": "job-4213343b",
132
+ "attempt_id": null,
133
+ "a2a_task_id": null,
134
+ "lifecycle_mode": "trial",
135
+ "status": "completed",
136
+ "review_status": "accepted",
137
+ "pending_approval_id": null,
138
+ "pending_proposal_count": 0,
139
+ "updated_at": "2026-11-28T09:12:41.000Z"
140
+ },
141
+ {
142
+ "job_id": "job-7771c0de",
143
+ "attempt_id": null,
144
+ "a2a_task_id": null,
145
+ "session_id": null,
146
+ "target_id": null,
147
+ "role_id": null,
148
+ "lifecycle_mode": null,
149
+ "status": null,
150
+ "result_revision": null,
151
+ "result_digest": null,
152
+ "review_status": null,
153
+ "pending_approval_id": null,
154
+ "pending_proposal_count": null,
155
+ "updated_at": "2026-11-28T09:00:00.000Z"
156
+ }
157
+ ]
158
+ }
@@ -23,8 +23,8 @@
23
23
  "finished_at": { "type": ["string", "null"], "format": "date-time" },
24
24
  "status": {
25
25
  "type": "string",
26
- "enum": ["queued", "running", "waiting_for_user", "completed", "failed"],
27
- "description": "waiting_for_user 是手机接入后必须新增的一类状态:请求用户在现实世界做某个动作(确认日程、选联系人、授权 iOS 权限)。有了它,总管才能直接回答『3 个任务正在执行,1 个等待你确认』。"
26
+ "enum": ["queued", "running", "waiting_for_user", "completed", "failed", "canceled"],
27
+ "description": "waiting_for_user 是手机接入后必须新增的一类状态:请求用户在现实世界做某个动作(确认日程、选联系人、授权 iOS 权限)。有了它,总管才能直接回答『3 个任务正在执行,1 个等待你确认』。canceled 是被取消的终态(拼写单 l),与 failed 并列——取消不是失败。"
28
28
  },
29
29
  "requires_user_action": {
30
30
  "type": ["string", "null"],
@@ -0,0 +1,129 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dreammate.work/schemas/governance.schema.json",
4
+ "title": "DreamMate Actor Reference",
5
+ "description": "治理域的公共词汇:谁在行动(ActorRef)、以什么模式行动(LifecycleMode)、产物版本与验收结论(RevisionRef / ReviewStatus)、角色引用(RoleRef)、双钥匙高危提案的分类(GovernanceProposalKind)、过程审批的种类与结论(ProcessRequestKind / ProcessRequestOutcome)。这里只定义跨仓共用的分类词,不定义任何一方的流程:谁能裁决、要不要留证、状态怎么推进、提案怎么走完,都留在各自仓。",
6
+ "type": "object",
7
+ "required": ["kind"],
8
+ "properties": {
9
+ "kind": {
10
+ "$ref": "#/$defs/actorKind"
11
+ },
12
+ "id": {
13
+ "type": ["string", "null"],
14
+ "description": "行动者的稳定标识。人没有账号时也要给一个可区分的 id。",
15
+ "examples": ["scott", "coach-pm-01"]
16
+ },
17
+ "agent": {
18
+ "type": ["string", "null"],
19
+ "description": "行动者使用的 agent / 模型名。与 id 正交:同一个人可以换 agent。",
20
+ "examples": ["minimax-cn/MiniMax-M3.1-Flash"]
21
+ },
22
+ "session_id": {
23
+ "type": ["string", "null"],
24
+ "description": "行动者所在的会话。可以是本地 session id,也可以是 session:// URI。",
25
+ "examples": ["session://scott-mac/codex/01a0907c"]
26
+ }
27
+ },
28
+ "$defs": {
29
+ "actorKind": {
30
+ "type": "string",
31
+ "enum": ["person", "coach", "executor", "qa", "host", "application"],
32
+ "description": "行动者类别。person=真实的人,coach=负责给建议与把关的智能体,executor=实际干活的智能体,qa=独立复核方,host=宿主运行时,application=无智能体参与的应用。",
33
+ "examples": ["person", "coach", "executor"]
34
+ },
35
+ "lifecycleMode": {
36
+ "type": "string",
37
+ "enum": ["trial", "formal"],
38
+ "description": "这次工作处于什么模式。trial=试跑,产出可以丢弃、可以重来;formal=正式,产出要留痕、要被验收。它说的是这次工作的分量,与谁来干、用什么传输无关。",
39
+ "examples": ["trial", "formal"]
40
+ },
41
+ "reviewStatus": {
42
+ "type": "string",
43
+ "enum": ["pending", "accepted", "changes_requested"],
44
+ "description": "产物被验收的结论。changes_requested 是「已看过、但要求返工」——它和 rejected 不是一回事,前者还能继续改,后者是终态否定。",
45
+ "examples": ["pending", "accepted"]
46
+ },
47
+ "revisionRef": {
48
+ "type": "object",
49
+ "title": "Revision Reference",
50
+ "description": "产物的一次具体版本。revision 与 digest 一起构成乐观锁:拿着旧的 revision 去提交会被拒绝,避免覆盖掉别人刚交的新版本。",
51
+ "required": ["revision", "digest"],
52
+ "properties": {
53
+ "revision": {
54
+ "type": "string",
55
+ "minLength": 1,
56
+ "description": "版本标识,由产出方定义(如递增号或 revision id)。"
57
+ },
58
+ "digest": {
59
+ "type": "string",
60
+ "minLength": 1,
61
+ "description": "该版本内容的内容摘要(如 sha256)。",
62
+ "examples": ["sha256:9f2c1e..."]
63
+ }
64
+ }
65
+ },
66
+ "roleRef": {
67
+ "type": "object",
68
+ "title": "Role Reference",
69
+ "description": "对某个角色的引用。只给 id,不给角色的内容——角色的指令、检查项、评测集是各自仓的资产,不进协议。",
70
+ "required": ["id"],
71
+ "properties": {
72
+ "id": {
73
+ "type": "string",
74
+ "minLength": 1,
75
+ "description": "角色标识。",
76
+ "examples": ["pr-delivery", "ticket-reviewer"]
77
+ },
78
+ "name": {
79
+ "type": ["string", "null"],
80
+ "description": "人类可读名称,可省略。"
81
+ },
82
+ "session_id": {
83
+ "type": ["string", "null"],
84
+ "description": "该角色当前的会话引用,可省略。",
85
+ "examples": ["session://scott-mac/codex/01a0907c"]
86
+ }
87
+ }
88
+ },
89
+ "governanceProposalKind": {
90
+ "type": "string",
91
+ "enum": ["eval_change", "permission_escalation", "promote_formal"],
92
+ "description": "双钥匙高危提案的分类。这三类会改动评测、放宽权限、或把试跑升为正式,因此需要人逐条裁决。「谁批、怎么留证」是各自仓的规则,协议只认这三个分类词。",
93
+ "examples": ["eval_change", "promote_formal"]
94
+ },
95
+ "processRequestKind": {
96
+ "type": "string",
97
+ "enum": ["permission", "question", "plan"],
98
+ "description": "过程审批请求的种类。permission=要放行一次工具或权限使用,question=要人回答一个问题,plan=要人认可一份计划。",
99
+ "examples": ["permission", "plan"]
100
+ },
101
+ "processRequestOutcome": {
102
+ "type": "string",
103
+ "enum": ["approved", "rejected", "canceled", "accepted", "abandoned"],
104
+ "description": "过程审批请求的结论。approved=放行,rejected=拒绝,canceled=请求方自己撤销,accepted=人认可了内容,abandoned=挂起后无人处理。拼写统一单 l 的 canceled。",
105
+ "examples": ["approved", "canceled"]
106
+ }
107
+ },
108
+ "examples": [
109
+ {
110
+ "kind": "person",
111
+ "id": "scott"
112
+ },
113
+ {
114
+ "kind": "coach",
115
+ "id": "coach-pm-01",
116
+ "agent": "minimax-cn/MiniMax-M3.1-Flash",
117
+ "session_id": "session://scott-mac/codex/01a0907c"
118
+ },
119
+ {
120
+ "kind": "executor",
121
+ "id": "agent-worker-07",
122
+ "session_id": "session://scott-mac/claude/9c11ab02"
123
+ },
124
+ {
125
+ "kind": "application",
126
+ "id": "a2a-gateway"
127
+ }
128
+ ]
129
+ }
@@ -0,0 +1,135 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dreammate.work/schemas/message.schema.json",
4
+ "title": "DreamMate Session Message Envelope",
5
+ "description": "跨会话投递与外部事件的结构化信封(纯数据)。投递方式只出现在 delivery_mode,传输细节(HTTP/MCP、队列长度、合并算法、重试策略)不在这里;正文的渲染格式由发送方决定,协议只约定结构。信封里的 from_session_id 让接收方知道是谁在跟它说话。",
6
+ "type": "object",
7
+ "required": ["from_session_id"],
8
+ "properties": {
9
+ "from_session_id": {
10
+ "type": "string",
11
+ "minLength": 1,
12
+ "description": "发件方的会话 id。",
13
+ "examples": ["session-c8fde7a1-64c0-4943-ad40-b08bfbacefe9"]
14
+ },
15
+ "delivery_mode": {
16
+ "anyOf": [
17
+ { "$ref": "#/$defs/sessionDeliveryMode" },
18
+ { "type": "null" }
19
+ ],
20
+ "description": "投递方式。省略或为 null 时由接收方按默认处理。"
21
+ },
22
+ "summary": {
23
+ "type": ["string", "null"],
24
+ "description": "一句话摘要。给接收方(或接收方的界面)看,不是正文。",
25
+ "examples": ["dreammate-network L0 守门裁决回复:Stage 0 契约范围 / v0.6.0"]
26
+ },
27
+ "correlation": {
28
+ "anyOf": [
29
+ { "$ref": "#/$defs/correlation" },
30
+ { "type": "null" }
31
+ ],
32
+ "description": "这条消息挂着的上下文。没有对应上下文时为 null 或整个省略。"
33
+ }
34
+ },
35
+ "$defs": {
36
+ "sessionDeliveryMode": {
37
+ "type": "string",
38
+ "enum": ["queue", "steer"],
39
+ "description": "投递方式。queue=排进对方当前的待发队列,等它忙完再消费;steer=插队,立刻打断。steer 不会被合并。名字里带 Session 是为了避开别的仓已有的 `DeliveryMode`(那指的是产物怎么落地)——同名不同义比缺名字更危险。",
40
+ "examples": ["queue", "steer"]
41
+ },
42
+ "correlation": {
43
+ "type": "object",
44
+ "title": "Message Correlation",
45
+ "description": "这条消息挂在哪个上下文上。一个会话同时承载群聊、私聊与审批时,靠它防止上下文串台。字段全是可选的:没有对应上下文就整个省略。",
46
+ "properties": {
47
+ "ticket_id": {
48
+ "type": ["string", "null"],
49
+ "description": "关联的任务单 id。"
50
+ },
51
+ "team_id": {
52
+ "type": ["string", "null"],
53
+ "description": "关联的团队 id。"
54
+ },
55
+ "job_id": {
56
+ "type": ["string", "null"],
57
+ "description": "关联的作业 id。"
58
+ },
59
+ "a2a_task_id": {
60
+ "type": ["string", "null"],
61
+ "description": "关联的远端 A2A task id。**不透明外部 id**,与 TaskExecutionLink.task_id 无关。"
62
+ },
63
+ "pending_approval_id": {
64
+ "type": ["string", "null"],
65
+ "description": "关联的待审批请求 id。"
66
+ }
67
+ }
68
+ },
69
+ "notificationEvent": {
70
+ "type": "object",
71
+ "title": "Notification Event",
72
+ "description": "一次外部事件的公共信封。source + event_id 是幂等键:同一对值重复投递只算一次。它只描述「发生了什么」,不描述「投给谁、怎么投」——路由是服务端的行为。",
73
+ "required": ["source", "event_id", "summary"],
74
+ "properties": {
75
+ "source": {
76
+ "type": "string",
77
+ "minLength": 1,
78
+ "description": "事件来源标识。",
79
+ "examples": ["rsi-evolver", "dreammate-network"]
80
+ },
81
+ "event_id": {
82
+ "type": "string",
83
+ "minLength": 1,
84
+ "description": "来源侧的事件唯一 id,与 source 一起构成幂等键。",
85
+ "examples": ["brief-2026-11-28-01"]
86
+ },
87
+ "event_type": {
88
+ "type": ["string", "null"],
89
+ "description": "事件类型标识,可省略。"
90
+ },
91
+ "summary": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "description": "一句话说明这次事件。"
95
+ },
96
+ "occurred_at": {
97
+ "type": ["string", "null"],
98
+ "format": "date-time",
99
+ "description": "事件发生的时间,可省略。"
100
+ }
101
+ }
102
+ }
103
+ },
104
+ "examples": [
105
+ {
106
+ "from_session_id": "session-c8fde7a1-64c0-4943-ad40-b08bfbacefe9",
107
+ "delivery_mode": "queue",
108
+ "summary": "dreammate-network L0 守门裁决回复:Stage 0 契约范围 / v0.6.0",
109
+ "correlation": {
110
+ "ticket_id": "ticket-2041",
111
+ "job_id": "job-0ba07988",
112
+ "a2a_task_id": "a2a-task-8f21c0",
113
+ "pending_approval_id": null
114
+ }
115
+ },
116
+ {
117
+ "from_session_id": "session-267d01f9-3b1b-4652-a4bd-2f38dbdf9471",
118
+ "delivery_mode": "steer",
119
+ "summary": "四项拍板点已表态,等 dsh-superagent 同步",
120
+ "correlation": {
121
+ "ticket_id": null,
122
+ "team_id": null,
123
+ "job_id": null,
124
+ "a2a_task_id": null,
125
+ "pending_approval_id": "approval-31"
126
+ }
127
+ },
128
+ {
129
+ "from_session_id": "session-eafe2ed4-e78b-4ae3-a9e1-d649ff00ad43",
130
+ "delivery_mode": null,
131
+ "summary": null,
132
+ "correlation": null
133
+ }
134
+ ]
135
+ }
@@ -149,7 +149,7 @@
149
149
  "localhost",
150
150
  "network"
151
151
  ],
152
- "description": "这个 Service 能被谁连上。localhost=只监听回环,外部节点发现得了但连不上;network=监听 0.0.0.0 或 tailnet 地址,外部可直连。node agent 如实转述服务自己的声明,不做代理——调用方看到 localhost 就知道不用白跑一趟。省略时按 network 理解。"
152
+ "description": "服务自己怎么监听。localhost=只绑回环,外部不能直连其端口;network=监听 0.0.0.0 或 tailnet 地址,外部可直连。node agent 在 manifest 里如实转述。跨节点调用走 agent 的统一入口(POST /services/:id/invoke 或 MCP dreammate_invoke),由本机 agent 转发到回环 HTTP 或 CLI。省略时按 network 理解。"
153
153
  },
154
154
  "execution": {
155
155
  "type": "string",