@coda-console/protocol 6.31.0 → 6.32.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 +10 -0
- package/README.md +3 -3
- package/docs/protocol.md +10 -0
- package/package.json +1 -1
- package/plugin.d.mts +63 -7
- package/schemas/plugin/friend-streams.json +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.32.0 — 2026-12-01
|
|
6
|
+
|
|
7
|
+
- 这是在 6.31.0 之上的次版本。依据 README「版本」一节:模块的 `coda` 对象与清单的 `contributes` 键属于内部面,只加可选的成员、类型与键,升次版本;`stable/` 不动,旧清单、旧插件一律照旧。对应 Coda 的 API Level 28(需求分支 `req/67644b48-4e15-47a4-a9a2-17235870c476`)。
|
|
8
|
+
- `./types`(`plugin.d.mts`):`Coda` 新增 `openStream(record, name, options?)`(以插件的身份打开一条记录的流,本机的、空间里别台的、经 `coda/accord@1` 的流 `friend` 的好友的都行,回答 Web 标准的 `Response`)与 `spawnAgent(agent, { cwd, signal? })`(起这台机器上已装的 Agent 程序,回答 `Process`);新增导出 `OpenStreamOptions`(`method`、`suffix`、`search`、`headers`、`body`、`signal`)。
|
|
9
|
+
- `./types`:流处理函数的 `caller` 多了一种好友 `{ friend: { author, channel, scope } }`,只出现在对好友开放的流,不带 `machine`、`plugin`、`parent`。新增导出 `FriendCaller`、`ServiceCaller`(原 `StreamCaller` 的三种);`StreamCaller` 现为 `ServiceCaller | FriendCaller`,`StreamContext.caller` 是它,`ServeContext.caller`(`coda.serve`,好友到不了)改用 `ServiceCaller`,形状与原来相同。读 `StreamCaller` 的插件用 `'friend' in caller` 先分出好友(别的分支上没有 `friend`,直接写 `caller.friend` 编译不过)。
|
|
10
|
+
- `Coda.openStream` 与 `Coda.spawnAgent` 的注释写明权限口径(同 Coda 文档「用到的权限」):`openStream` 打开的协议是插件自己定义(`contributes.protocols`)或生效实现的,直接放行,Coda 自己维护、记录只在本机的协议(`coda/accord@1`、`coda/plugin@1` 等)除外;否则要在清单 `uses` 或 `optionalUses` 里写了含这条流的权限组,不在任何组里的流对插件不开放;向好友开流是 `coda/accord@1` 的 `friend-streams`。`spawnAgent` 的协议 `coda/plugin@1` 属于除外的那些,只看 `uses` 或 `optionalUses` 里有没有 `spawn-agent`。
|
|
11
|
+
- 清单 `contributes.friendStreams`(`schemas/plugin/friend-streams.json`,作公开数据放在包里,**不**接进通用清单 `plugin.json`、不在 `TYPES` 里,同 `agents`、`modelProviders`、`gitCredentials`、`repositories`:由登记这个键的 Coda 贡献点引用 `SCHEMAS['friend-streams.json']`,用 `contributionProblem` 校验;`manifestProblem` 不查它):每项 `{ kind, streams }`,`kind` 是协议名,同一种类只写一项,至多 100 项;`streams` 是 1 到 64 个不重复的流名;不收别的键。只校验形状,没有跨键规则。同一个键因此只有包里这一份 schema。`ManifestContributions` 加可选的 `friendStreams`。这个键暂不进稳定面。
|
|
12
|
+
- 文档:`docs/protocol.md` 在 `optionalProtocolImplementations`、`reservedAccordKinds` 之后写 `friendStreams`;README 的清单键与类型清单同步。
|
|
13
|
+
- 没有补的:权限组 `coda/accord@1` 的 `friend-streams`、`coda/plugin@1` 的 `spawn-agent` 与 `coda/accord@1` 的流 `friend`。这两个协议由 Coda 自己登记,定义不在本包里(本包没有它们的协议定义、权限组清单),所以这里不新开一类。
|
|
14
|
+
|
|
5
15
|
## 6.31.0 — 2026-11-30
|
|
6
16
|
|
|
7
17
|
- 这是在 6.30.0 之上的次版本。依据 README「版本」一节:Agent 接入协议是内部面,新增一条可选的扩展请求与一个能力声明升次版本;`stable/` 不动,清单 schema 没改,既有的 `_coda/wait`、`compact`、`_session/steering` 字段与语义不变,旧用法一律照旧。
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Coda 与插件之间的约定,Coda 和插件都引用它,独立演进:
|
|
4
4
|
|
|
5
|
-
- **插件清单的类型**(`schemas/plugin/`):插件目录 `package.json` 里 `contributes` 的每个键是一种类型,各有一份 JSON Schema(draft 2020-12,`$id` 为 `https://coda.pub/schemas/plugin/v2/<文件>`)。`plugin.json` 是整份清单,只列通用键(`configuration`、`services`、`setup`、`environment`、`path`、`views`、`protocols`、`protocolImplementations`、`optionalProtocolImplementations`、`reservedAccordKinds`、`records`);`setting.json` 是一项设置的声明。其余键由 Coda 的贡献点登记表声明:Coda 自己的(`agents`、`composerModes`、`modelProviders` 等)的 schema 仍放在这里作公开数据(如 `agents.json`、`composer-modes.json`),由登记它的 provider 引用;`contributes` 里只有 Coda 认得的键。
|
|
5
|
+
- **插件清单的类型**(`schemas/plugin/`):插件目录 `package.json` 里 `contributes` 的每个键是一种类型,各有一份 JSON Schema(draft 2020-12,`$id` 为 `https://coda.pub/schemas/plugin/v2/<文件>`)。`plugin.json` 是整份清单,只列通用键(`configuration`、`services`、`setup`、`environment`、`path`、`views`、`protocols`、`protocolImplementations`、`optionalProtocolImplementations`、`reservedAccordKinds`、`records`);`setting.json` 是一项设置的声明。其余键由 Coda 的贡献点登记表声明:Coda 自己的(`agents`、`composerModes`、`modelProviders` 等)的 schema 仍放在这里作公开数据(如 `agents.json`、`composer-modes.json`、`friend-streams.json`),由登记它的 provider 引用;`contributes` 里只有 Coda 认得的键。
|
|
6
6
|
- **通用校验器**(`validate.mjs`):用 Ajv 对清单做 schema 校验。JSON Schema 说不了的只用五个通用关键字(`x-unique-by`、`x-max-contains`、`x-ref`、`x-placeholders`、`x-file`,照 Kubernetes 的 `x-kubernetes-*`),每个在哪里写都是同一个意思,写法见文件开头。校验器不随功能变长:类型加字段就是改 schema。例外是清单级的两条跨字段约束:`manifestProblem` 在 schema 通过后还会检查,同一协议不能既是必需实现(`protocolImplementations`)又是可选实现(`optionalProtocolImplementations`),保留种类(`reservedAccordKinds`)的命名空间须等于插件 ID;只拿 `plugin.json` 校验,只查形状,这两条不在内。
|
|
7
7
|
- **协议定义与调用**(`schemas/protocol/`、`protocol.mjs`、`docs/protocol.md`):协议是 `命名空间/名字@大版本` + spec/status 的 JSON Schema + 操作;插件在 `contributes.protocols` 里定义自己命名空间下的协议,在 `contributes.protocolImplementations` 里声明实现哪些协议;定义可写 `streams` 声明记录流(读、写、原样 HTTP 三种形状,字节或帧),可写 `events` 声明事件(载荷格式与 `starts`、`ends`;只有事件的协议可以不写 `spec`、`status`、`operations`,`protocolHasRecords` 判断一份定义有没有记录),可写 `permissions` 把操作、流、事件与记录的读取分成权限组,插件在清单根的 `uses`(必需)或 `optionalUses`(可选)里按组申请。调用是 `{ record, operation, input, requestId, parent, awaited }`,回答是 `{ result }` 或 `{ run }`;`coda/run@1`、`coda/agent@1`、`coda/session@1`、`coda/environment@1`、`coda/card@1` 是五个核心协议。
|
|
8
8
|
- **流程方言**(`workflow/`):项目和插件的流程(`.coda/workflows/*.bpmn`,BPMN 2.0)在 Coda 的命名空间 `https://coda.pub/schema/bpmn/1.0` 里能写什么。`moddle.json` 是 `coda:` 属性与元素(bpmn-moddle 的描述格式),`values.json` 是每个值能写什么(每个 `coda:` 类型的属性组成的对象的 JSON Schema,一个元素里同种 `coda:` 元素成组的 schema),`actions.json` 是 `coda:action` 的各个动作和它们接受的参数,`dialect.json` 是 Coda 自己发的事件、步骤失败的错误码、表达式能读的运行变量和运行的输入能是哪些类型。`workflow.mjs` 用它们读一份流程:方言里没有的、值不合 schema 的都拒绝,说法是「位置:schema 对那里的说明」。值的 schema 用清单的那几个关键字,另加三个:`x-feel`(是 FEEL:「=」开头是表达式,否则文字里的 `{{ … }}` 是,按这份流程里的名字读得通)、`x-duration`(ISO 8601 时长,不为负)、`x-number`(文字换算成数字是个有限的数)。`structure.json` 声明流程结构规则,`structure.mjs` 负责跨节点检查。
|
|
@@ -127,7 +127,7 @@ optionsProblem([{ id: 'release', name: '发布正式版', default: false, inputs
|
|
|
127
127
|
|
|
128
128
|
## 插件的类型
|
|
129
129
|
|
|
130
|
-
`@coda-console/protocol/types`(`plugin.d.mts`)是插件模块的公开 TypeScript 类型:调用与处理(`Context`、`Handler`、`Caller`)、记录(`Ref`、`KeyRef`、`RecordValue`、`RecordFilter`、`RecordChange`)、页面(`ViewInstance`)和模块里的 `coda` 对象(`Coda`)等。它们属于内部面,随 Coda 的版本可能变。TypeScript 与 `// @ts-check` 的 JSDoc 都能解析(`moduleResolution` 为 `node16`、`nodenext` 或 `bundler`):
|
|
130
|
+
`@coda-console/protocol/types`(`plugin.d.mts`)是插件模块的公开 TypeScript 类型:调用与处理(`Context`、`Handler`、`Caller`)、记录(`Ref`、`KeyRef`、`RecordValue`、`RecordFilter`、`RecordChange`)、记录的流(`StreamCaller`、`FriendCaller`、`OpenStreamOptions`)、页面(`ViewInstance`)和模块里的 `coda` 对象(`Coda`)等。它们属于内部面,随 Coda 的版本可能变。TypeScript 与 `// @ts-check` 的 JSDoc 都能解析(`moduleResolution` 为 `node16`、`nodenext` 或 `bundler`):
|
|
131
131
|
|
|
132
132
|
```js
|
|
133
133
|
// @ts-check
|
|
@@ -181,7 +181,7 @@ agentValueProblem('review.json', review, '工具的审核');
|
|
|
181
181
|
## 协议定义与核心协议
|
|
182
182
|
|
|
183
183
|
从 3.0.0 起,协议是 `命名空间/名字@大版本` + 记录格式(spec、status 的 JSON Schema)+ 操作,见[协议正文](docs/protocol.md)。
|
|
184
|
-
插件用 `contributes.protocols` 定义自己命名空间下的协议,用 `contributes.protocolImplementations` 声明实现哪些协议,用根上的 `uses` 申请别的协议的权限组(必需),用 `optionalUses` 声明可选用到的权限组(对应协议或提供方缺席时不阻止插件运行,可用性判定与鉴权由 Coda 宿主负责);`contributes.optionalProtocolImplementations` 列可选实现的协议(本机没有这个协议时插件照常运行、这一项不生效),`contributes.reservedAccordKinds` 声明只归本插件的 Accord 签名记录种类(命名空间须是插件 ID
|
|
184
|
+
插件用 `contributes.protocols` 定义自己命名空间下的协议,用 `contributes.protocolImplementations` 声明实现哪些协议,用根上的 `uses` 申请别的协议的权限组(必需),用 `optionalUses` 声明可选用到的权限组(对应协议或提供方缺席时不阻止插件运行,可用性判定与鉴权由 Coda 宿主负责);`contributes.optionalProtocolImplementations` 列可选实现的协议(本机没有这个协议时插件照常运行、这一项不生效),`contributes.reservedAccordKinds` 声明只归本插件的 Accord 签名记录种类(命名空间须是插件 ID);`contributes.friendStreams` 声明本插件持有的记录里哪个种类的哪几条流也对绑定着的好友开放(它的 schema 是 `friend-streams.json`,不在通用清单里,由 Coda 的贡献点登记引用,同 `agents` 等;`manifestProblem` 不查它,`contributionProblem` 查,只校验形状);前两个键协议包只校验形状与两条跨键规则(可选实现不与 `protocolImplementations` 重复、保留种类的命名空间等于插件 ID),协议在不在、谁被拒绝由 Coda 宿主判定;
|
|
185
185
|
命名空间 `coda` 保留给核心协议。
|
|
186
186
|
|
|
187
187
|
- **`coda/run@1`**:被调用方自己的运行记录。spec 记录调用的记录、操作、输入、请求 ID、父引用和是否被等待;status 是 `working`、`input-required`、`completed`、`failed`、`canceled`,后三个是终态。`completed`/`failed` 必带 `result`,`failed` 的 `result` 约定为 `{ code, message }`(`code: "unknown"` 表示结局不明),`canceled` 可带取消前的话和留下的东西;另有可选的 `progress` 和等输入时的 `awaiting`。操作是 `cancel`。
|
package/docs/protocol.md
CHANGED
|
@@ -364,6 +364,16 @@ const body = writeFrames(frames, { heartbeatMs: 15000 });
|
|
|
364
364
|
|
|
365
365
|
这两个键协议包只校验形状与上面两条跨键规则;协议在不在、这一项生不生效、谁被拒绝由 Coda 宿主判定。
|
|
366
366
|
|
|
367
|
+
`contributes.friendStreams` 声明插件持有的记录里,哪个种类的哪几条流也对此刻绑定着的好友(空间之外、与本机互认的节点)开放:
|
|
368
|
+
|
|
369
|
+
```json
|
|
370
|
+
"friendStreams": [{"kind": "my-plugin/box@1", "streams": ["draft", "lines"]}]
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
- 数组,至多 100 项,每项 `{ kind, streams }`,不收别的键。`kind` 是协议名,同一种类只写一项;`streams` 是 1 到 64 个不重复的流名(格式同定义里 `streams` 的键)。不写就是都不开放。
|
|
374
|
+
- 它的 schema 是 `schemas/plugin/friend-streams.json`,不在通用清单 `plugin.json` 里(同 `agents`、`modelProviders` 等 Coda 自己的键):由登记这个键的 Coda 组件引用,用 `contributionProblem` 在整份清单里查;`manifestProblem` 对它不作判断。
|
|
375
|
+
- 这里只校验形状:没有跨键规则,`kind` 不要求写在 `protocolImplementations` 里,流在不在协议定义里也不在这里查。只对本插件持有的记录起作用、后端怎么放行好友、`ctx.caller.friend` 的内容,都由 Coda 宿主定;好友能不能用由流的处理函数自己判。
|
|
376
|
+
|
|
367
377
|
`contributes.records` 声明哪些种类的记录由命令给出,每种一项,至多 20 项:
|
|
368
378
|
|
|
369
379
|
```json
|
package/package.json
CHANGED
package/plugin.d.mts
CHANGED
|
@@ -69,7 +69,7 @@ export interface CallOptions {
|
|
|
69
69
|
* The page's opener (`device`, `name`, `local`) is relayed by the originating backend as well.
|
|
70
70
|
*
|
|
71
71
|
* Read where a call came from by value, not by whether a property exists. Since 6.25.0 `machine` and `plugin` may be on any
|
|
72
|
-
* branch of `Caller` and `StreamCaller`, so `'machine' in caller` and `'plugin' in caller` no longer tell the branches apart,
|
|
72
|
+
* branch of `Caller` and `StreamCaller` but a friend's (`FriendCaller`, which has neither), so `'machine' in caller` and `'plugin' in caller` no longer tell the branches apart,
|
|
73
73
|
* and TypeScript types the field as `string | undefined` after such a check. Tell this machine's own client (`local`), a
|
|
74
74
|
* device (`device`, and `role` of a `StreamCaller`) and a plugin by those fields and the values of `machine` and `plugin`.
|
|
75
75
|
* The two mean the same on every branch: `machine` is always the ID of the backend the call was made from, which the
|
|
@@ -136,18 +136,44 @@ export interface Context {
|
|
|
136
136
|
/** Its return value is the result; what it throws, the failure (`coda.error`, or anything else as `handler_error`). */
|
|
137
137
|
export type Handler = (input: Json, ctx: Context) => Json | Promise<Json>;
|
|
138
138
|
/**
|
|
139
|
-
* Who asks a service
|
|
140
|
-
*
|
|
139
|
+
* Who asks a service: this machine's own client or tools, a device, another backend of the space (the last hop, of one sent
|
|
140
|
+
* on), or a plugin (by its token, or from its page).
|
|
141
141
|
*/
|
|
142
|
-
export type
|
|
142
|
+
export type ServiceCaller = ({ local: true } | { device: string; role: 'client' | 'backend'; name?: string } | { plugin: string }) & CallerOrigin;
|
|
143
|
+
/**
|
|
144
|
+
* A friend (outside the space, bound to this machine now) who asks a stream the plugin has opened to friends
|
|
145
|
+
* (`contributes.friendStreams`). All three are of the binding the host matched the request to, never what the request says
|
|
146
|
+
* of itself.
|
|
147
|
+
*/
|
|
148
|
+
export interface FriendCaller {
|
|
149
|
+
friend: {
|
|
150
|
+
/** The author's public key the friend is bound as now (`ed25519:…`). */
|
|
151
|
+
author: string;
|
|
152
|
+
/** The channel's identity: `link:<link ID>` or `node:<node ID>`. */
|
|
153
|
+
channel: string;
|
|
154
|
+
/** The scope the binding was admitted in (`coda-space/…`, `coda-tailnet/…`, or the one given when the link was registered). */
|
|
155
|
+
scope: string;
|
|
156
|
+
};
|
|
157
|
+
/** A friend's call carries no `CallerOrigin`. */
|
|
158
|
+
machine?: never;
|
|
159
|
+
plugin?: never;
|
|
160
|
+
parent?: never;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Who asks a stream: any of those who ask a service, or a friend (`friend`), which only a stream the plugin has opened to
|
|
164
|
+
* friends is asked by. A friend is none of the others: there is no `local`, `device` or `plugin` on it, nor `machine` or
|
|
165
|
+
* `parent`. The host does not ask whether the friend may use the stream; the handler does, by `friend.author` as a rule.
|
|
166
|
+
*/
|
|
167
|
+
export type StreamCaller = ServiceCaller | FriendCaller;
|
|
143
168
|
/** What a handler of a service (`coda.serve`) is given beside its request. */
|
|
144
169
|
export interface ServeContext {
|
|
145
|
-
caller:
|
|
170
|
+
caller: ServiceCaller;
|
|
146
171
|
/** Goes off when the caller leaves before the answer is done; `request.signal` goes off with it. */
|
|
147
172
|
signal: AbortSignal;
|
|
148
173
|
}
|
|
149
174
|
/** What a handler of a record's stream (`coda.stream`) is given beside its request. */
|
|
150
|
-
export interface StreamContext extends ServeContext {
|
|
175
|
+
export interface StreamContext extends Omit<ServeContext, 'caller'> {
|
|
176
|
+
caller: StreamCaller;
|
|
151
177
|
/** The record the stream is of; with its `key` when it is this plugin's own. */
|
|
152
178
|
record: HandledRef;
|
|
153
179
|
/** Its parameters, from the query string, as the definition's `input` has them; none (`{}`) of an `http` stream. */
|
|
@@ -221,6 +247,22 @@ export interface Process {
|
|
|
221
247
|
kill(signal?: string): void;
|
|
222
248
|
}
|
|
223
249
|
|
|
250
|
+
/** How `openStream` asks a record's stream. */
|
|
251
|
+
export interface OpenStreamOptions {
|
|
252
|
+
/** `GET` or `POST`; by default `POST` with a `body`, else `GET`. */
|
|
253
|
+
method?: 'GET' | 'POST';
|
|
254
|
+
/** What is below the stream's path: none, or from its `/` on (an `http` stream's only); any other is refused, nothing sent. */
|
|
255
|
+
suffix?: string;
|
|
256
|
+
/** The query string: none, or from its `?` on: a `read` or `write` stream's parameters, an `http` stream's subprotocol's; any other is refused, nothing sent. */
|
|
257
|
+
search?: string;
|
|
258
|
+
/** Of these only those of content and negotiation are sent; with no `Content-Type`, the one the body's encoding gives (a form's boundary in it). */
|
|
259
|
+
headers?: Record<string, string>;
|
|
260
|
+
/** The request's body, as a `Response` takes one; sent as it is read. */
|
|
261
|
+
body?: BodyInit | null;
|
|
262
|
+
/** Gone off, whether waiting to be answered or reading the body, the stream ends with its reason. */
|
|
263
|
+
signal?: AbortSignal;
|
|
264
|
+
}
|
|
265
|
+
|
|
224
266
|
export interface Settings {
|
|
225
267
|
/** This plugin's own settings as they are now (secrets are not among them); asked each time. */
|
|
226
268
|
get(): Promise<Json>;
|
|
@@ -304,6 +346,8 @@ export interface Coda {
|
|
|
304
346
|
* effect if it never started, of `unknown` if it started and could not be registered (killed with its group at once).
|
|
305
347
|
*/
|
|
306
348
|
spawn(command: string, args?: string[], options?: SpawnOptions): Promise<Process>;
|
|
349
|
+
/** Starts an agent installed on this machine (manifest `uses` or `optionalUses`: `"coda/plugin@1": ["spawn-agent"]`; with neither it fails as `forbidden`, nothing started); the process has only its own plugin's environment and ends with this generation of the module. */
|
|
350
|
+
spawnAgent(agent: string, options: { cwd: string; signal?: AbortSignal }): Promise<Process>;
|
|
307
351
|
/**
|
|
308
352
|
* Serves the plugin's own bytes at `/v1/plugins/<plugin>/services/<id>/…`, any method a standard
|
|
309
353
|
* `Request` takes: all but `CONNECT`, `TRACE` and `TRACK`. Done once Coda has it; the handle's
|
|
@@ -316,6 +360,16 @@ export interface Coda {
|
|
|
316
360
|
* has; otherwise it throws at once. Done once Coda has it; `dispose()` as `serve`'s.
|
|
317
361
|
*/
|
|
318
362
|
stream(kind: string, name: string, handler: StreamHandler): Promise<{ dispose(): Promise<void> }>;
|
|
363
|
+
/**
|
|
364
|
+
* Opens a record's stream as this plugin, wherever the record is held (here, on another backend of the space, or, through
|
|
365
|
+
* `coda/accord@1`'s stream `friend`, on a friend's): the stream's own `Response`, its body as it comes. Allowed when the
|
|
366
|
+
* protocol is one the plugin defines (`contributes.protocols`) or implements in force here, but for those only this machine
|
|
367
|
+
* keeps (Coda's `coda/accord@1`, `coda/plugin@1`, …), which implementing does not make the plugin's; else only when a
|
|
368
|
+
* group of the protocol that has the stream is in the manifest's `uses` or `optionalUses` (a stream in no group is open
|
|
369
|
+
* to no plugin; a friend's, `coda/accord@1`'s `friend-streams`). A refusal before the first byte fails with a `CallError`, its `effects` as the one refusing said them; a body
|
|
370
|
+
* broken off midway errors as `interrupted`; `options.signal` gone off, with its reason.
|
|
371
|
+
*/
|
|
372
|
+
openStream(record: Ref, name: string, options?: OpenStreamOptions): Promise<Response>;
|
|
319
373
|
/** Frame streams: ndjson, one JSON object a line, a blank line a heartbeat. As `@coda-console/protocol/frames` has them. */
|
|
320
374
|
frames: Readonly<{
|
|
321
375
|
/** The frames of a body, heartbeats skipped; fails with `code` `truncated`, `too_large` (a line over `maxBytes`, by default 1 MiB) or `invalid`. */
|
|
@@ -425,7 +479,7 @@ export interface ViewInstance {
|
|
|
425
479
|
}
|
|
426
480
|
|
|
427
481
|
/**
|
|
428
|
-
* The keys of the manifest's `contributes` that are typed here: only these
|
|
482
|
+
* The keys of the manifest's `contributes` that are typed here: only these three so far, the rest of the manifest has no type
|
|
429
483
|
* here yet. Their shape is checked by `schemas/plugin/`; whether a protocol is on this machine and who is refused is the host's.
|
|
430
484
|
*/
|
|
431
485
|
export interface ManifestContributions {
|
|
@@ -433,4 +487,6 @@ export interface ManifestContributions {
|
|
|
433
487
|
optionalProtocolImplementations?: string[];
|
|
434
488
|
/** Accord signature record kinds (`namespace/name`, the namespace the plugin's own ID) that only this plugin may publish, revoke or read. */
|
|
435
489
|
reservedAccordKinds?: string[];
|
|
490
|
+
/** Which streams of the records this plugin holds are open to friends as well, a kind (`namespace/name@major`) once, up to 100; the handler decides which friend may use one (`ctx.caller.friend`). */
|
|
491
|
+
friendStreams?: { kind: string; streams: string[] }[];
|
|
436
492
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/plugin/v2/friend-streams.json",
|
|
4
|
+
"title": "contributes.friendStreams:对好友开放的记录的流",
|
|
5
|
+
"description": "插件持有的记录里,哪个种类的哪几条流也对此刻绑定着的好友(空间之外、与本机互认的节点)开放:数组,每项 { kind, streams },同一种类只写一项,至多 100 项;streams 是 1 到 64 个不重复的流名。不写就是都不开放。只对本插件持有的记录起作用;好友能不能用、能用到哪由流的处理函数自己判。协议、流在不在由 Coda 宿主判定,这里只管清单形状。",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"maxItems": 100,
|
|
8
|
+
"x-unique-by": ["kind"],
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"kind": {"description": "协议名「命名空间/名字@大版本」;同一种类只写一项", "$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/name"},
|
|
13
|
+
"streams": {
|
|
14
|
+
"description": "对好友开放的流名,1 到 64 个,不重复",
|
|
15
|
+
"type": "array",
|
|
16
|
+
"minItems": 1,
|
|
17
|
+
"maxItems": 64,
|
|
18
|
+
"uniqueItems": true,
|
|
19
|
+
"items": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/operationName"}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": ["kind", "streams"],
|
|
23
|
+
"additionalProperties": false
|
|
24
|
+
}
|
|
25
|
+
}
|