@coda-console/protocol 6.32.0 → 6.33.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 +7 -0
- package/README.md +1 -1
- package/docs/protocol.md +13 -0
- package/package.json +1 -1
- package/plugin.d.mts +56 -0
- package/schemas/plugin/model-providers.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.33.0 — 2026-12-01
|
|
6
|
+
|
|
7
|
+
- 这是在 6.32.0 之上的次版本。依据 README「版本」一节:模块的 `coda` 对象与清单的 `contributes` 键属于内部面,只加可选的成员、类型与键,升次版本;`stable/` 不动,旧清单、旧插件一律照旧(`node scripts/stable-grows.mjs npm:latest` 通过)。为 Coda 的「去中心化空间模型路由」基座原语补齐协议:本机作用域的逻辑模型服务,以及查询全空间物理模型服务的模块接口。
|
|
8
|
+
- `schemas/plugin/model-providers.json`:每项新增可选的 `scope`(`space` 或 `local`,省略即 `space`)。`space` 是发布为空间里这台机器的物理模型服务;`local` 只在本机作为不带机器哈希的稳定名逻辑入口提供,不进空间目录、不跨机交付,其本机回环地址可在运行时经 `coda.modelServices.registerLocal()` 登记。`url` 不再无条件必填:`scope` 省略或为 `space` 时仍必填(行为与原来一致,错误说「缺 url:scope 省略或为 space 时 url 必填」),`scope` 为 `local` 时可写可不写;用 `if/then/else` 写成(`required` 只剩 `id`、`title`、`api`)。`key` 不受 `scope` 限制,只在 description 里说明 `local` 入口通常不配 `key`。`scope` 为别的值被拒绝。
|
|
9
|
+
- `./types`(`plugin.d.mts`):`Coda` 新增 Trial 成员 `modelServices`:`listPhysical(options?: { api?: ModelServiceApi })`(只列 `scope` 为 `space` 的物理模型服务,不含 `local`)、`registerLocal(id, { url, revision? })`(登记本插件声明的 `scope: "local"` 模型服务的运行时本机地址与模型目录 revision,回答 `LocalModelServiceHandle`)、`onPhysicalChanged(fn)`(物理模型服务列表变化时回调,回答 `Disposable`)。新增导出 `ModelServiceApi`、`PhysicalModelService`(`kind`、`id`、`name`、`owner`、`location`、`ref`、`title`、`url`、`path`、`stamp`、`local`、`offline`、`heardAt`)、`LocalModelServiceHandle`(继承 `Disposable`;`id`、`api`、`name`、`service` 只读,`update({ url?, revision? })`,仅地址或 revision 变了才触发刷新)。
|
|
10
|
+
- 文档:`docs/protocol.md` 在 `friendStreams` 之后写 `modelProviders` 的 `scope` 与 `coda.modelServices`;README 的类型清单同步。
|
|
11
|
+
|
|
5
12
|
## 6.32.0 — 2026-12-01
|
|
6
13
|
|
|
7
14
|
- 这是在 6.31.0 之上的次版本。依据 README「版本」一节:模块的 `coda` 对象与清单的 `contributes` 键属于内部面,只加可选的成员、类型与键,升次版本;`stable/` 不动,旧清单、旧插件一律照旧。对应 Coda 的 API Level 28(需求分支 `req/67644b48-4e15-47a4-a9a2-17235870c476`)。
|
package/README.md
CHANGED
|
@@ -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`)、记录的流(`StreamCaller`、`FriendCaller`、`OpenStreamOptions`)、页面(`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`)、模型服务(`ModelServiceApi`、`PhysicalModelService`、`LocalModelServiceHandle`)、页面(`ViewInstance`)和模块里的 `coda` 对象(`Coda`)等。它们属于内部面,随 Coda 的版本可能变。TypeScript 与 `// @ts-check` 的 JSDoc 都能解析(`moduleResolution` 为 `node16`、`nodenext` 或 `bundler`):
|
|
131
131
|
|
|
132
132
|
```js
|
|
133
133
|
// @ts-check
|
package/docs/protocol.md
CHANGED
|
@@ -374,6 +374,19 @@ const body = writeFrames(frames, { heartbeatMs: 15000 });
|
|
|
374
374
|
- 它的 schema 是 `schemas/plugin/friend-streams.json`,不在通用清单 `plugin.json` 里(同 `agents`、`modelProviders` 等 Coda 自己的键):由登记这个键的 Coda 组件引用,用 `contributionProblem` 在整份清单里查;`manifestProblem` 对它不作判断。
|
|
375
375
|
- 这里只校验形状:没有跨键规则,`kind` 不要求写在 `protocolImplementations` 里,流在不在协议定义里也不在这里查。只对本插件持有的记录起作用、后端怎么放行好友、`ctx.caller.friend` 的内容,都由 Coda 宿主定;好友能不能用由流的处理函数自己判。
|
|
376
376
|
|
|
377
|
+
`contributes.modelProviders` 声明插件提供的模型服务(`schemas/plugin/model-providers.json`,不在通用清单 `plugin.json` 里,由登记这个键的 Coda 组件引用),6.33.0 起每项可写 `scope`:
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
"modelProviders": [
|
|
381
|
+
{"id": "main", "title": "主力模型", "api": "openai-completions", "url": "${config:kit.url}", "key": "${config:kit.key}"},
|
|
382
|
+
{"id": "router", "title": "模型路由", "api": "openai-completions", "scope": "local"}
|
|
383
|
+
]
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
- `scope` 是 `space` 或 `local`,省略即 `space`。`space`:发布为空间里这台机器的物理模型服务,`url` 必填,与 6.32.0 及以前完全一致。`local`:只在本机作为不带机器哈希的稳定名逻辑入口提供,不进空间目录、不跨机交付;`url` 可以不写,模块运行时用 `coda.modelServices.registerLocal(id, { url, revision? })` 登记本机的回环地址与模型目录 revision;写了就是静态地址。
|
|
387
|
+
- `key` 不受 `scope` 限制;`local` 入口通常不配 `key`。其余键与形状不变。
|
|
388
|
+
- 模块里的 `coda.modelServices`(Trial):`listPhysical({ api? })` 列空间里全部物理模型服务(只含 `scope` 为 `space` 的,绝不含 `local`),`registerLocal` 登记本插件的 `local` 入口,`onPhysicalChanged` 在列表变化时回调;类型见 `PhysicalModelService`、`LocalModelServiceHandle`。
|
|
389
|
+
|
|
377
390
|
`contributes.records` 声明哪些种类的记录由命令给出,每种一项,至多 20 项:
|
|
378
391
|
|
|
379
392
|
```json
|
package/package.json
CHANGED
package/plugin.d.mts
CHANGED
|
@@ -440,6 +440,62 @@ export interface Coda {
|
|
|
440
440
|
tell(session: string, text: string): Promise<{ told: boolean }>;
|
|
441
441
|
/** Trial. Runs an installed plugin's environment setup again, asked as this plugin. */
|
|
442
442
|
pluginSetup: Readonly<{ retry(plugin: string): Promise<Json> }>;
|
|
443
|
+
/**
|
|
444
|
+
* Trial. Model services of the space. `listPhysical` lists the physical ones (`scope: "space"` in a plugin's
|
|
445
|
+
* `contributes.modelProviders`, or omitted), of every machine of the space, as this machine reaches them; never a `scope: "local"` one.
|
|
446
|
+
* `registerLocal` gives the address a `scope: "local"` provider the plugin declares runs at on this machine (a loopback one, which stands for the
|
|
447
|
+
* manifest's `url` if it has none) and the revision of its model catalog. `onPhysicalChanged` calls back when the list changes.
|
|
448
|
+
*/
|
|
449
|
+
modelServices: Readonly<{
|
|
450
|
+
listPhysical(options?: { api?: ModelServiceApi }): Promise<PhysicalModelService[]>;
|
|
451
|
+
registerLocal(id: string, entry: { url: string; revision?: string }): LocalModelServiceHandle;
|
|
452
|
+
onPhysicalChanged(fn: () => void): Disposable;
|
|
453
|
+
}>;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** The interfaces a model service speaks, as `contributes.modelProviders[].api` has them. */
|
|
457
|
+
export type ModelServiceApi = 'openai-completions' | 'openai-responses' | 'anthropic-messages' | 'openai-speech';
|
|
458
|
+
|
|
459
|
+
/** A physical model service of the space (`scope: "space"`): one a machine of the space publishes, as this machine reaches it. */
|
|
460
|
+
export interface PhysicalModelService {
|
|
461
|
+
kind: ModelServiceApi;
|
|
462
|
+
/** The physical resource's UUID. */
|
|
463
|
+
id: string;
|
|
464
|
+
/** The full setting name, `models/s-…`. */
|
|
465
|
+
name: string;
|
|
466
|
+
/** The ID of the backend that holds it. */
|
|
467
|
+
owner: string;
|
|
468
|
+
/** The display name of the machine it is on. */
|
|
469
|
+
location: string;
|
|
470
|
+
/** `<plugin>/<id>`: the plugin that provides it and its ID in that plugin's `contributes.modelProviders`. */
|
|
471
|
+
ref: string;
|
|
472
|
+
/** Its display title. */
|
|
473
|
+
title: string;
|
|
474
|
+
/** The base URL of this machine's own proxy to it; callable at once with a placeholder credential. */
|
|
475
|
+
url: string;
|
|
476
|
+
/** The prefix of the paths a client asks, such as `/v1`, or `""`. */
|
|
477
|
+
path: string;
|
|
478
|
+
/** The model catalog's cache stamp. */
|
|
479
|
+
stamp: string;
|
|
480
|
+
/** Whether it is on this machine. */
|
|
481
|
+
local: boolean;
|
|
482
|
+
/** Whether its holder is offline now (a hint). */
|
|
483
|
+
offline: boolean;
|
|
484
|
+
/** When its holder was last heard from (ms since the epoch); `null` when it is on this machine or not known. */
|
|
485
|
+
heardAt: number | null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** What `modelServices.registerLocal` gives back: the handle of one local model service; `dispose()` withdraws it. */
|
|
489
|
+
export interface LocalModelServiceHandle extends Disposable {
|
|
490
|
+
/** The provider's ID in the manifest. */
|
|
491
|
+
readonly id: string;
|
|
492
|
+
readonly api: ModelServiceApi;
|
|
493
|
+
/** The same on every machine: the stable setting name, `models/l-…`. */
|
|
494
|
+
readonly name: string;
|
|
495
|
+
/** This machine's usage identity of it, `coda://<api>/<uuid>`, for what folds usage by service (a token ranking, say). */
|
|
496
|
+
readonly service: string;
|
|
497
|
+
/** Changes the address it runs at, or its model catalog's `revision`; a refresh follows only when one of the two differs from what it was. */
|
|
498
|
+
update(entry: { url?: string; revision?: string }): void;
|
|
443
499
|
}
|
|
444
500
|
|
|
445
501
|
/** The record or draft a protocol hands a contributor, without who created it: its `spec` and `status` are objects the protocol's schemas describe. */
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"description": "接口:openai-completions、openai-responses、anthropic-messages、openai-speech",
|
|
15
15
|
"enum": ["openai-completions", "openai-responses", "anthropic-messages", "openai-speech"]
|
|
16
16
|
},
|
|
17
|
+
"scope": {
|
|
18
|
+
"description": "scope 是 space(省略即 space)或 local:space 是发布为空间里这台机器的物理模型服务,url 必填;local 只在本机作为不带机器哈希的稳定名逻辑入口提供,不进空间目录、不跨机交付,url 可以不写,运行时经 coda.modelServices.registerLocal() 登记本机回环地址;local 入口通常不配 key",
|
|
19
|
+
"enum": ["space", "local"]
|
|
20
|
+
},
|
|
17
21
|
"url": {
|
|
18
22
|
"description": "一行地址,只能引用本插件的单值设置(${config:<设置名>},不能是密文)",
|
|
19
23
|
"type": "string",
|
|
@@ -32,7 +36,9 @@
|
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
|
-
"required": ["id", "title", "api"
|
|
39
|
+
"required": ["id", "title", "api"],
|
|
40
|
+
"if": {"properties": {"scope": {"const": "local"}}, "required": ["scope"]},
|
|
41
|
+
"else": {"description": "scope 省略或为 space 时 url 必填", "required": ["url"]},
|
|
36
42
|
"additionalProperties": false
|
|
37
43
|
},
|
|
38
44
|
"x-unique-by": ["id"]
|