@coda-console/protocol 5.6.0 → 5.8.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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  按 semver。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
4
4
 
5
+ ## 5.8.0 — 2026-11-10
6
+
7
+ - `coda/session@1` 的 status 加可选的 `activity: { participant, text }`:参与者正在做什么,单行、至多 200 字符;停下时删掉,不是消息,不进 `read`,不推进 `head`。
8
+ - 新增记录的远端入口(`schemas/protocol/v1/remote-caller.json`):令牌只通往一条 `coda/session@1` 记录,支持绑定、`hello`、六个只读工具与白名单流程工单 `file_ticket`;调用以记录为 `parent`,结束结果按通知规则以 `self` `post` 回记录。旧 Agent 远端入口保留,随 grok-bot 0.4.0 退役。
9
+
10
+ ## 5.7.0 — 2026-11-10
11
+
12
+ - 插件提供的模型服务的接口(`contributes.modelProviders` 的 `api`,以及设置的 `modelApis` 可列的接口名)加 `openai-speech`:OpenAI 语音合成接口(`POST /v1/audio/speech`)。只加接口名,字段与语义不变。
13
+
5
14
  ## 5.6.0 — 2026-11-10
6
15
 
7
16
  - 流程种类 `develop`(开发流程):把一项改动从开工做到合进默认分支,结果交回发起它的会话;任何提交都能跑,不算部署类。设置选项的 `workflowKind` 也接受它。
@@ -427,6 +427,8 @@ Coda 封装的 Agent 会自己长出新能力:上游 Agent 升级、服务端
427
427
 
428
428
  ## 远端入口
429
429
 
430
+ 本节是 Agent 会话的旧入口,随所有机器上的 grok-bot 0.4.0 卸载一起退役;新的外部会话用[记录的远端入口](protocol.md#记录的远端入口)。
431
+
430
432
  绑定码与转交请求的形状分别见 [remote-code.json](../schemas/agent/remote-code.json)、[remote.json](../schemas/agent/remote.json)。
431
433
 
432
434
  有的 Agent 不在这台机器上干活:它是别处的一个 Bot(比如 Grok Bot,在它自己的云电脑上),会话里的适配器只是它的代言。
package/docs/protocol.md CHANGED
@@ -307,8 +307,12 @@ status:
307
307
  | `participants` | `[{ id, name, kind: "person"\|"agent"\|"bot", self?, avatar? }]`;`self: true` 是这个 Provider 登录的账号,即 Coda 的 Bot;`avatar` 见下 |
308
308
  | `state` | 可选,`active` 或 `unreachable` |
309
309
  | `reason` | 可选,状态说明 |
310
+ | `activity` | 可选,`{ participant, text }`:参与者正在做什么 |
310
311
  | `accepts` | 可选,`post` 除文字以外还收哪些媒体 part,见下 |
311
312
 
313
+ `activity.participant` 须是 `status.participants` 中某一项的 `id`;Provider 负责保证这个对应关系。`text` 是 1 到 200 个字符的单行文字(不含换行符),如「正在搜索代码」。
314
+ 像聊天软件的「正在输入」:Provider 不提供就不写,对方停下时删掉整个 `activity`。它不是消息,不进 `read`,不推进 `head`。
315
+
312
316
  `accepts` 是一个对象,键是媒体 part 的 `type`,值是这一类型的限制,没有限制就写 `{}`。本版本只有 `audio` 一个键,以后要收别的类型再加键:
313
317
 
314
318
  | 键 | 值 |
@@ -447,6 +451,68 @@ status:
447
451
  }
448
452
  ```
449
453
 
454
+ ### 记录的远端入口
455
+
456
+ 外部会话里的一位参与者(如跑在别处的 Grok Bot)以这条 `coda/session@1` 记录的身份调 Coda。令牌只通往这条记录,不是设备凭据,不能进入其他接口。
457
+ Coda 直接处理请求,不经 Agent 进程;调用信封的 `parent` 是 `{ kind: "coda/session@1", id: <记录 ID> }`,见[调用信封](#调用信封)。请求不能另指定调用方。
458
+ 形状见 [remote-caller.json](../schemas/protocol/v1/remote-caller.json):顶层校验调用正文,`$defs` 给出绑定、各方法结果及错误;`date-parse` 格式同旧入口,按 `Date.parse` 能否读出时间校验。
459
+
460
+ #### 绑定
461
+
462
+ Provider 为自己 provide 的记录向 Coda 申请一次性绑定码,只能为自己的记录申请,且须实现 `coda/session@1`。插件侧的 API 由 Coda 定义。
463
+ 回 `{ code, expiresAt, addresses }`:码 10 分钟有效,`expiresAt` 是到期时间;`addresses` 同旧入口,是这台后端在 tailnet 里的入口(`http://<节点地址>:8080`),不在 tailnet 时为空。
464
+ 远端以 `POST /v1/remote-caller/bind`、正文 `{ code }` 换得 `{ token, record }`,`record` 是记录 ID。无需凭据,每分钟最多 30 次,码成功兑换后失效。
465
+ 同一条记录再绑定,新令牌取代旧的;幂等请求归记录,不随令牌更换重置。
466
+
467
+ #### 调用
468
+
469
+ `POST /v1/remote-caller`,头 `Authorization: Bearer <token>`,正文 `{ method, params }`,成功回 `{ result }`。调用正文至多 256 KiB;绑定正文同旧入口至多 4 KiB,`code` 为 1 到 128 个字符。
470
+ `params` 是对象;只有 `hello` 可省略,等同 `{}`。
471
+
472
+ | method | params | result |
473
+ | --- | --- | --- |
474
+ | `hello` | `{}` | `{ record, machine, tools, workflows }`:记录 ID、所在机器 ID、可用的只读工具名数组、工单白名单 |
475
+ | `tool` | `{ name, arguments }` | 同名 MCP 工具的回答,原样放进 `result` |
476
+ | `file_ticket` | `{ workflow, project?, inputs, requestId }` | `{ run, reused? }`;`run` 为 `{ kind: "workflow-runs", id }`,按运行主键复用时带 `reused: true` |
477
+
478
+ `tool.name` 只收 `machines`、`machine_diagnostics`、`read_thread`、`read_tool_call`、`workflow_list`、`workflow_status`;`arguments` 是参数对象。
479
+ 参数与回答照 Coda 的同名 MCP 工具,见[搜索与 Agent 工具](https://github.com/coda-console/coda/blob/main/docs/peers.md#搜索与-agent-工具)和[流程文档](https://github.com/coda-console/coda/blob/main/docs/workflows.md),这里不复制它们的 schema。
480
+ `hello.tools` 只列本机可用的上述工具。查工单用 `workflow_status`,不另设方法。
481
+
482
+ 工单白名单是 `{ project, workflow }` 的列表,存在 Coda 侧、由用户给定;怎么配置由 Coda 定义,`hello.workflows` 返回这份列表,没有就返回 `[]`。
483
+ `project` 是这台机器上登记的目录 ID,`workflow` 是流程名。`file_ticket` 省略 `project` 时,按 `workflow` 在白名单里找唯一一项;没有匹配就拒绝,多项匹配就要求填写 `project`。
484
+ 写了 `project` 时须与白名单的目录 ID 精确匹配。`inputs` 是流程输入对象,按流程自己的输入契约校验。
485
+ Coda 以记录为 `parent`、`awaited: true` 发起流程;入口不额外出批准卡片,需要批准由流程决定。
486
+
487
+ `requestId` 是 1 到 200 个字符的不透明字符串,按调用方记录区分。同一记录、同一 `requestId`、同一内容重发,返回首次受理的同一结果,不重复开运行;换内容则报冲突。
488
+ 内容按受理时确定的 `project`、`workflow` 和 `inputs` 比较;省略项目的重试沿用首次受理的项目。重试仍须通过记录有效性和当前白名单检查。
489
+ 不同 `requestId` 报同一问题,由流程的[运行主键](https://github.com/coda-console/coda/blob/main/docs/workflows.md#运行主键)复用未结束的运行,回原运行和 `reused: true`;不改原运行的调用方,不接管它的结果通知。
490
+
491
+ #### 结果交付
492
+
493
+ 运行结束(成功或失败)时,照流程的[通知规则](https://github.com/coda-console/coda/blob/main/docs/workflows.md#通知)把结论交给调用方;取消不通知,第一版不推中途状态。
494
+ 调用方是 Coda 会话时,给它追加一条叫醒的消息;调用方是 `coda/session@1` 记录时,对这条记录调一次 `post`。这是同一条规则在两种会话上的交付。
495
+ 发送者照 `post` 的规定是 `self`,不冒充 Bot;输入的 `text` 是运行的结论:成功用结束事件的输出,没有声明输出时沿用流程通知的步骤输出;失败写失败的步骤和原因。
496
+ `post` 信封的 `requestId` 由运行 ID 与轮次派生,同一运行每轮只发一次,交付重试使用同一个值;不按每次提工单的 `requestId` 各发一条。
497
+
498
+ #### 拒绝
499
+
500
+ HTTP 错误正文是 `{ error: { code, message } }`,`message` 是给人看的原因,`code` 用下划线命名:
501
+
502
+ | HTTP | code | 原因 |
503
+ | --- | --- | --- |
504
+ | 400 | `invalid_input` | JSON、方法或参数不合契约;项目有歧义;流程输入不合法 |
505
+ | 401 | `unauthorized` | 调用令牌缺失、无效或已被新令牌取代 |
506
+ | 401 | `unauthorized` | 绑定码不存在、过期或已用过 |
507
+ | 403 | `forbidden` | 工具不在六个允许的名字中,或流程不在记录的白名单中 |
508
+ | 409 | `invalid_state` | 记录不存在、已删除,或它的 Provider 已不实现 `coda/session@1`;兑换绑定码时也检查 |
509
+ | 409 | `request_conflict` | 同一记录的 `requestId` 用了不同内容 |
510
+ | 413 | `invalid_input` | 正文超过对应入口的上限 |
511
+ | 429 | `rate_limited` | 绑定超过每分钟 30 次 |
512
+ | 503 | `unavailable` | 允许的工具暂不可用,或流程尚未受理就暂时无法发起 |
513
+
514
+ 不在允许列表的工具名回 403,其他正文校验错误回 400。工具自身的业务错误仍按 MCP 工具回答放在 `result` 里;已受理运行的失败经运行状态和结果交付报告,不改成 HTTP 错误。
515
+
450
516
  ## coda/environment@1
451
517
 
452
518
  插件提供的外部环境,比如别家 Agent 自带的云主机。本版本只读。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/protocol",
3
- "version": "5.6.0",
3
+ "version": "5.8.0",
4
4
  "description": "Coda 的协议:插件清单的类型(JSON Schema)、通用校验器、协议定义与调用信封、流程方言与 Agent 接入协议",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -11,8 +11,8 @@
11
11
  "id": {"$ref": "common.json#/$defs/id"},
12
12
  "title": {"$ref": "common.json#/$defs/line40"},
13
13
  "api": {
14
- "description": "接口:openai-completions、openai-responses、anthropic-messages",
15
- "enum": ["openai-completions", "openai-responses", "anthropic-messages"]
14
+ "description": "接口:openai-completions、openai-responses、anthropic-messages、openai-speech",
15
+ "enum": ["openai-completions", "openai-responses", "anthropic-messages", "openai-speech"]
16
16
  },
17
17
  "url": {
18
18
  "description": "一行地址,只能引用本插件的单值设置(${config:<设置名>},不能是密文)",
@@ -132,11 +132,11 @@
132
132
  "type": {"const": "string"},
133
133
  "format": {"const": "coda-model-provider"},
134
134
  "modelApis": {
135
- "description": "modelApis 是 1–10 个接口名,取 openai-completions、openai-responses、anthropic-messages",
135
+ "description": "modelApis 是 1–10 个接口名,取 openai-completions、openai-responses、anthropic-messages、openai-speech",
136
136
  "type": "array",
137
137
  "minItems": 1,
138
138
  "maxItems": 10,
139
- "items": {"enum": ["openai-completions", "openai-responses", "anthropic-messages"]}
139
+ "items": {"enum": ["openai-completions", "openai-responses", "anthropic-messages", "openai-speech"]}
140
140
  }
141
141
  },
142
142
  "required": ["type", "format"],
@@ -0,0 +1,336 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://coda.pub/schemas/protocol/v1/remote-caller.json",
4
+ "title": "记录的远端入口",
5
+ "description": "POST /v1/remote-caller 的正文;绑定、回答与错误见 $defs。记录归属、参与者、白名单、幂等与 HTTP 状态由 Coda 检查,见 docs/protocol.md「记录的远端入口」。",
6
+ "$defs": {
7
+ "id": {
8
+ "type": "string",
9
+ "minLength": 1,
10
+ "maxLength": 2048
11
+ },
12
+ "codeResult": {
13
+ "type": "object",
14
+ "properties": {
15
+ "code": {
16
+ "type": "string",
17
+ "minLength": 1,
18
+ "maxLength": 128
19
+ },
20
+ "expiresAt": {
21
+ "type": "string",
22
+ "format": "date-parse",
23
+ "description": "绑定码到期时间,申请后 10 分钟"
24
+ },
25
+ "addresses": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "string"
29
+ },
30
+ "description": "后端的 tailnet 入口;不在 tailnet 时为空"
31
+ }
32
+ },
33
+ "required": [
34
+ "code",
35
+ "expiresAt",
36
+ "addresses"
37
+ ],
38
+ "additionalProperties": false
39
+ },
40
+ "bindRequest": {
41
+ "type": "object",
42
+ "properties": {
43
+ "code": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "maxLength": 128
47
+ }
48
+ },
49
+ "required": [
50
+ "code"
51
+ ],
52
+ "additionalProperties": false
53
+ },
54
+ "bindResult": {
55
+ "type": "object",
56
+ "properties": {
57
+ "token": {
58
+ "type": "string",
59
+ "minLength": 1
60
+ },
61
+ "record": {
62
+ "$ref": "#/$defs/id"
63
+ }
64
+ },
65
+ "required": [
66
+ "token",
67
+ "record"
68
+ ],
69
+ "additionalProperties": false
70
+ },
71
+ "workflow": {
72
+ "type": "object",
73
+ "properties": {
74
+ "project": {
75
+ "$ref": "#/$defs/id"
76
+ },
77
+ "workflow": {
78
+ "type": "string",
79
+ "minLength": 1,
80
+ "maxLength": 200
81
+ }
82
+ },
83
+ "required": [
84
+ "project",
85
+ "workflow"
86
+ ],
87
+ "additionalProperties": false
88
+ },
89
+ "helloResult": {
90
+ "type": "object",
91
+ "properties": {
92
+ "record": {
93
+ "$ref": "#/$defs/id"
94
+ },
95
+ "machine": {
96
+ "$ref": "#/$defs/id"
97
+ },
98
+ "tools": {
99
+ "type": "array",
100
+ "items": {
101
+ "enum": [
102
+ "machines",
103
+ "machine_diagnostics",
104
+ "read_thread",
105
+ "read_tool_call",
106
+ "workflow_list",
107
+ "workflow_status"
108
+ ]
109
+ },
110
+ "uniqueItems": true
111
+ },
112
+ "workflows": {
113
+ "type": "array",
114
+ "items": {
115
+ "$ref": "#/$defs/workflow"
116
+ },
117
+ "uniqueItems": true
118
+ }
119
+ },
120
+ "required": [
121
+ "record",
122
+ "machine",
123
+ "tools",
124
+ "workflows"
125
+ ],
126
+ "additionalProperties": false
127
+ },
128
+ "helloRequest": {
129
+ "type": "object",
130
+ "properties": {
131
+ "method": {
132
+ "const": "hello"
133
+ },
134
+ "params": {
135
+ "type": "object",
136
+ "properties": {},
137
+ "required": [],
138
+ "additionalProperties": false
139
+ }
140
+ },
141
+ "required": [
142
+ "method"
143
+ ],
144
+ "additionalProperties": false
145
+ },
146
+ "toolRequest": {
147
+ "type": "object",
148
+ "properties": {
149
+ "method": {
150
+ "const": "tool"
151
+ },
152
+ "params": {
153
+ "type": "object",
154
+ "properties": {
155
+ "name": {
156
+ "enum": [
157
+ "machines",
158
+ "machine_diagnostics",
159
+ "read_thread",
160
+ "read_tool_call",
161
+ "workflow_list",
162
+ "workflow_status"
163
+ ]
164
+ },
165
+ "arguments": {
166
+ "type": "object",
167
+ "description": "参数同 Coda 的同名 MCP 工具"
168
+ }
169
+ },
170
+ "required": [
171
+ "name",
172
+ "arguments"
173
+ ],
174
+ "additionalProperties": false
175
+ }
176
+ },
177
+ "required": [
178
+ "method",
179
+ "params"
180
+ ],
181
+ "additionalProperties": false
182
+ },
183
+ "ticketRequest": {
184
+ "type": "object",
185
+ "properties": {
186
+ "method": {
187
+ "const": "file_ticket"
188
+ },
189
+ "params": {
190
+ "type": "object",
191
+ "properties": {
192
+ "workflow": {
193
+ "type": "string",
194
+ "minLength": 1,
195
+ "maxLength": 200
196
+ },
197
+ "project": {
198
+ "$ref": "#/$defs/id"
199
+ },
200
+ "inputs": {
201
+ "type": "object"
202
+ },
203
+ "requestId": {
204
+ "type": "string",
205
+ "minLength": 1,
206
+ "maxLength": 200
207
+ }
208
+ },
209
+ "required": [
210
+ "workflow",
211
+ "inputs",
212
+ "requestId"
213
+ ],
214
+ "additionalProperties": false
215
+ }
216
+ },
217
+ "required": [
218
+ "method",
219
+ "params"
220
+ ],
221
+ "additionalProperties": false
222
+ },
223
+ "ticketResult": {
224
+ "type": "object",
225
+ "properties": {
226
+ "run": {
227
+ "type": "object",
228
+ "properties": {
229
+ "kind": {
230
+ "const": "workflow-runs"
231
+ },
232
+ "id": {
233
+ "$ref": "#/$defs/id"
234
+ }
235
+ },
236
+ "required": [
237
+ "kind",
238
+ "id"
239
+ ],
240
+ "additionalProperties": false
241
+ },
242
+ "reused": {
243
+ "const": true
244
+ }
245
+ },
246
+ "required": [
247
+ "run"
248
+ ],
249
+ "additionalProperties": false
250
+ },
251
+ "toolResult": {
252
+ "description": "Coda 同名 MCP 工具的回答,不在本协议复制 schema"
253
+ },
254
+ "helloResponse": {
255
+ "type": "object",
256
+ "properties": {
257
+ "result": {
258
+ "$ref": "#/$defs/helloResult"
259
+ }
260
+ },
261
+ "required": [
262
+ "result"
263
+ ],
264
+ "additionalProperties": false
265
+ },
266
+ "toolResponse": {
267
+ "type": "object",
268
+ "properties": {
269
+ "result": {
270
+ "$ref": "#/$defs/toolResult"
271
+ }
272
+ },
273
+ "required": [
274
+ "result"
275
+ ],
276
+ "additionalProperties": false
277
+ },
278
+ "ticketResponse": {
279
+ "type": "object",
280
+ "properties": {
281
+ "result": {
282
+ "$ref": "#/$defs/ticketResult"
283
+ }
284
+ },
285
+ "required": [
286
+ "result"
287
+ ],
288
+ "additionalProperties": false
289
+ },
290
+ "error": {
291
+ "type": "object",
292
+ "properties": {
293
+ "error": {
294
+ "type": "object",
295
+ "properties": {
296
+ "code": {
297
+ "enum": [
298
+ "invalid_input",
299
+ "unauthorized",
300
+ "forbidden",
301
+ "invalid_state",
302
+ "request_conflict",
303
+ "rate_limited",
304
+ "unavailable"
305
+ ]
306
+ },
307
+ "message": {
308
+ "type": "string",
309
+ "minLength": 1
310
+ }
311
+ },
312
+ "required": [
313
+ "code",
314
+ "message"
315
+ ],
316
+ "additionalProperties": false
317
+ }
318
+ },
319
+ "required": [
320
+ "error"
321
+ ],
322
+ "additionalProperties": false
323
+ }
324
+ },
325
+ "oneOf": [
326
+ {
327
+ "$ref": "#/$defs/helloRequest"
328
+ },
329
+ {
330
+ "$ref": "#/$defs/toolRequest"
331
+ },
332
+ {
333
+ "$ref": "#/$defs/ticketRequest"
334
+ }
335
+ ]
336
+ }
@@ -60,6 +60,16 @@
60
60
  "additionalProperties": false
61
61
  }
62
62
  },
63
+ "activity": {
64
+ "type": "object",
65
+ "description": "参与者正在做什么;participant 须在 status.participants 中。Provider 不提供或对方停下时不写;不是消息,不进 read,不推进 head。",
66
+ "properties": {
67
+ "participant": {"type": "string", "minLength": 1, "maxLength": 2048},
68
+ "text": {"type": "string", "minLength": 1, "maxLength": 200, "not": {"pattern": "[\\r\\n\\u2028\\u2029]"}, "description": "一行给人看的活动说明,如正在搜索代码"}
69
+ },
70
+ "required": ["participant", "text"],
71
+ "additionalProperties": false
72
+ },
63
73
  "state": {"enum": ["active", "unreachable"]},
64
74
  "reason": {"type": "string", "maxLength": 4096, "description": "状态说明,可选"},
65
75
  "accepts": {