@coda-console/protocol 6.32.0 → 6.34.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 +15 -0
- package/README.md +4 -4
- package/docs/protocol.md +23 -0
- package/package.json +1 -1
- package/plugin.d.mts +59 -1
- package/schemas/plugin/agent-entrances.json +18 -0
- package/schemas/plugin/model-providers.json +7 -1
- package/schemas/protocol/v1/agent.json +14 -1
- package/workflow/moddle.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
|
|
4
4
|
|
|
5
|
+
## 6.34.0 — 2026-12-01
|
|
6
|
+
|
|
7
|
+
- 这是在 6.33.0(模型服务的 `scope` 与 `modelServices`)之上的次版本。依据 README「版本」一节:协议定义、清单的 `contributes` 键与流程方言属于内部面,只加可选的字段与键,升次版本;`stable/` 不动,旧记录(没有 `tiers`)一律照旧被接受。这是给 Coda API Level 31 用的:各台机器发布 Agent 记录时多带审批档位,Agent 选择器里选别台的 Agent、派子会话时按那台的档位选模式。
|
|
8
|
+
- `schemas/protocol/v1/agent.json`:`coda/agent@1` 的 spec 多了可选的 `tiers`(不进 `required`):对象或 `null`;对象的 `manual`、`auto`、`full` 各是哪个模式的 id(插件声明的档位各对应哪个模式;字符串,1–200 个字符,或 `null` 为没有这一档),`safe` 是安全模式的 id 数组,`default` 是 ACP 没报当前模式时相当于哪一档(`safe`、`manual`、`auto`、`full` 或 `null`),五个键都必填,不收别的键;提供它的插件没声明档位的为 `null`。这些 id 取自提供它的插件声明的档位,**不保证出现在这条记录的 `modes` 里**(`modes` 是 Agent 报上来的,目录没读到时为空);读它的一方用之前自己看它在不在 `modes` 里,包不替它校验。
|
|
9
|
+
- 清单 `contributes.agentEntrances`(接线入口;`schemas/plugin/agent-entrances.json`,后端按 `SCHEMAS['agent-entrances.json']` 取,作公开数据放在包里,**不**接进通用清单 `plugin.json`、不在 `TYPES` 里,同 `friendStreams`、`agents`:由登记这个键的 Coda 贡献点引用,用 `contributionProblem` 校验;`manifestProblem` 不查它):会话用别台的 Agent(会话和项目在这台,Agent 程序在那台)时,Coda 不起本机 Agent,而是起本机插件声明的入口,经 ACP 驱动它。每项 `{ command, via }`,`command` 是一行命令,`via` 是它靠目标机器上的哪种记录接过去(协议名,如 `relay/host@1`),同一种记录只写一项(`x-unique-by: ["via"]`),至多 16 项,不收别的键。入口不是 Agent:不出现在 Agent 列表里、不被探测、不发布。只校验形状。`ManifestContributions` 加可选的 `agentEntrances`。这个键暂不进稳定面。
|
|
10
|
+
- 流程方言:`coda:input` 类型 `agent` 的值(Agent 组合:`agent`,可选 `model`、`effort`、`mode`、`options`)多一个可选的 `agentTarget`:用别台的 Agent、会话在这台时,写那台 Agent 记录的 `coda://agents/<UUID>` 引用或 UUID,`agent` 仍写真 Agent 的 ID。`workflow/moddle.json` 里 `coda:input` 的说明同步;包里没有别处用 schema 穷举这组字段(设置的 `coda-agent` 格式只要求对象),所以没有别的 schema 要改。
|
|
11
|
+
- 文档:`docs/protocol.md`、README 的 `coda/agent@1` 字段表与 `agentEntrances` 同步;`test/protocol.test.mjs` 守住 `tiers` 的取值与拒收,`test/validate.test.mjs`、`test/types.test.mjs` 守住 `agentEntrances`。
|
|
12
|
+
|
|
13
|
+
## 6.33.0 — 2026-12-01
|
|
14
|
+
|
|
15
|
+
- 这是在 6.32.0 之上的次版本。依据 README「版本」一节:模块的 `coda` 对象与清单的 `contributes` 键属于内部面,只加可选的成员、类型与键,升次版本;`stable/` 不动,旧清单、旧插件一律照旧(`node scripts/stable-grows.mjs npm:latest` 通过)。为 Coda 的「去中心化空间模型路由」基座原语补齐协议:本机作用域的逻辑模型服务,以及查询全空间物理模型服务的模块接口。
|
|
16
|
+
- `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` 为别的值被拒绝。
|
|
17
|
+
- `./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 变了才触发刷新)。
|
|
18
|
+
- 文档:`docs/protocol.md` 在 `friendStreams` 之后写 `modelProviders` 的 `scope` 与 `coda.modelServices`;README 的类型清单同步。
|
|
19
|
+
|
|
5
20
|
## 6.32.0 — 2026-12-01
|
|
6
21
|
|
|
7
22
|
- 这是在 6.31.0 之上的次版本。依据 README「版本」一节:模块的 `coda` 对象与清单的 `contributes` 键属于内部面,只加可选的成员、类型与键,升次版本;`stable/` 不动,旧清单、旧插件一律照旧。对应 Coda 的 API Level 28(需求分支 `req/67644b48-4e15-47a4-a9a2-17235870c476`)。
|
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`、`friend-streams.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`、`agent-entrances.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`)、记录的流(`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
|
|
@@ -181,11 +181,11 @@ 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);`contributes.friendStreams` 声明本插件持有的记录里哪个种类的哪几条流也对绑定着的好友开放(它的 schema 是 `friend-streams.json`,不在通用清单里,由 Coda 的贡献点登记引用,同 `agents` 等;`manifestProblem` 不查它,`contributionProblem`
|
|
184
|
+
插件用 `contributes.protocols` 定义自己命名空间下的协议,用 `contributes.protocolImplementations` 声明实现哪些协议,用根上的 `uses` 申请别的协议的权限组(必需),用 `optionalUses` 声明可选用到的权限组(对应协议或提供方缺席时不阻止插件运行,可用性判定与鉴权由 Coda 宿主负责);`contributes.optionalProtocolImplementations` 列可选实现的协议(本机没有这个协议时插件照常运行、这一项不生效),`contributes.reservedAccordKinds` 声明只归本插件的 Accord 签名记录种类(命名空间须是插件 ID);`contributes.friendStreams` 声明本插件持有的记录里哪个种类的哪几条流也对绑定着的好友开放(它的 schema 是 `friend-streams.json`,不在通用清单里,由 Coda 的贡献点登记引用,同 `agents` 等;`manifestProblem` 不查它,`contributionProblem` 查,只校验形状);`contributes.agentEntrances` 声明接线入口(会话用别台的 Agent 时,Coda 起的是本机插件的这个入口,经 ACP 接到那台;每项 `{ command, via }`,`via` 是它靠目标机器上的哪种记录接过去;它的 schema 是 `agent-entrances.json`,同样不在通用清单里,只校验形状;入口不是 Agent,不出现在 Agent 列表里);前两个键协议包只校验形状与两条跨键规则(可选实现不与 `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`。
|
|
188
|
-
- **`coda/agent@1`**:Agent 资源,复数名 `agents`;spec 照 Coda 的 Agent 资源(`agent`、`title`、`plugin?`、`defaultModel`、`models`、`modes` 等),`plugin` 是提供 Agent 程序的插件、不是记录的 provider;status 为空对象;操作 `spawn`(`run: true`)开一个子会话。
|
|
188
|
+
- **`coda/agent@1`**:Agent 资源,复数名 `agents`;spec 照 Coda 的 Agent 资源(`agent`、`title`、`plugin?`、`defaultModel`、`models`、`modes`、可选的 `tiers` 等),`plugin` 是提供 Agent 程序的插件、不是记录的 provider;status 为空对象;操作 `spawn`(`run: true`)开一个子会话。
|
|
189
189
|
- **`coda/session@1`**:插件提供的外部会话。spec 是标题、容器和可选的环境引用;status 是 `head` 游标、参与者(可带头像 `avatar`)与 `post` 收不收语音(`accepts`);媒体与头像用指针 `{ owner, path, … }` 说内容在哪台后端的哪个地址,读的一方找 Coda 取,旧的 `service`、`path` 写法照收、将退役;操作 `read`(`safe`)与 `draft`(`idempotent`,将退役)是立即结果,`post` 开运行;流 `draft` 是输入框的击键流;撤回、编辑、表情是用 `about` 指向旧消息的新消息。
|
|
190
190
|
- **`coda/environment@1`**:插件提供的只读外部环境。spec 带 `actions`;操作 `list` 列目录、`read` 读文件(一次至多 1 MiB)。
|
|
191
191
|
- **`coda/resource@1`**:插件持有的一种资源类型在一台机器上的现状,复数名 `resource-types`;一条记录是一台机器上一个插件的一个资源类型,`key` 是类型 ID。spec 是 `{ type, title, resources, signIn? }`;status 是 `{}`;操作 `act`、`sign-in`、`install`。
|
package/docs/protocol.md
CHANGED
|
@@ -374,6 +374,28 @@ 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
|
+
|
|
390
|
+
`contributes.agentEntrances` 声明接线入口:会话可以用别台的 Agent(会话和项目在这台,Agent 程序在那台)。这种会话起进程时,Coda 不起本机 Agent,而是起本机插件声明的入口,像驱动本机 Agent 一样经 ACP 驱动它。入口不是 Agent:不出现在 Agent 列表里、不被探测、不发布。
|
|
391
|
+
|
|
392
|
+
```json
|
|
393
|
+
"agentEntrances": [{"command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/entrance.mjs\"", "via": "relay/host@1"}]
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
- 数组,至多 16 项,每项 `{ command, via }`,不收别的键。`command` 是一行命令(同其他贡献点的 `command`);`via` 是它靠目标机器上的哪种记录接过去,协议名「命名空间/名字@大版本」,同一种记录只写一项。
|
|
397
|
+
- 它的 schema 是 `schemas/plugin/agent-entrances.json`(`SCHEMAS['agent-entrances.json']`),不在通用清单 `plugin.json` 里(同 `agents`、`friendStreams` 等 Coda 自己的键):由登记这个键的 Coda 组件引用,用 `contributionProblem` 在整份清单里查;`manifestProblem` 对它不作判断。只校验形状,没有跨键规则:`via` 的协议在不在、入口怎么起由 Coda 宿主判定。
|
|
398
|
+
|
|
377
399
|
`contributes.records` 声明哪些种类的记录由命令给出,每种一项,至多 20 项:
|
|
378
400
|
|
|
379
401
|
```json
|
|
@@ -476,6 +498,7 @@ status:
|
|
|
476
498
|
| `defaultModel` | 不指定模型时用的模型 ID;读到目录前为空 |
|
|
477
499
|
| `models` | `[{ id, name?, shortName?, group?, efforts, options }]` |
|
|
478
500
|
| `modes` | `[{ id, name?, shortName? }]` |
|
|
501
|
+
| `tiers` | 权限档位,可选(旧记录没有):`{ manual, auto, full, safe, default }` 或 `null`。`manual`、`auto`、`full` 各是哪个模式的 id(插件声明的档位各对应哪个模式,`null` 为没有这一档),`safe` 是安全模式的 id 列表,`default` 是 ACP 没报当前模式时相当于哪一档(`safe`、`manual`、`auto`、`full` 或 `null`);五个键都必填,不收别的键;提供它的插件没声明档位的为 `null`。这些 id 取自提供它的插件声明的档位,**不保证出现在这条记录的 `modes` 里**(`modes` 是 Agent 报上来的,目录没读到时为空);读它的一方用之前自己看它在不在 `modes` 里 |
|
|
479
502
|
|
|
480
503
|
`models[].efforts` 是 `[{ id, name?, shortName? }]`;`models[].options` 是 `{ id, name?, shortName?, type: "boolean"|"select", choices? }`,`select` 带 `choices`,`boolean` 不带。status 是空对象。
|
|
481
504
|
|
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. */
|
|
@@ -479,7 +535,7 @@ export interface ViewInstance {
|
|
|
479
535
|
}
|
|
480
536
|
|
|
481
537
|
/**
|
|
482
|
-
* The keys of the manifest's `contributes` that are typed here
|
|
538
|
+
* The keys of the manifest's `contributes` that are typed here; the rest of the manifest has no type
|
|
483
539
|
* here yet. Their shape is checked by `schemas/plugin/`; whether a protocol is on this machine and who is refused is the host's.
|
|
484
540
|
*/
|
|
485
541
|
export interface ManifestContributions {
|
|
@@ -489,4 +545,6 @@ export interface ManifestContributions {
|
|
|
489
545
|
reservedAccordKinds?: string[];
|
|
490
546
|
/** 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
547
|
friendStreams?: { kind: string; streams: string[] }[];
|
|
548
|
+
/** Entrances for sessions that use another machine's Agent: `command` is the one-line command Coda starts here in place of an Agent, which speaks ACP; `via` is the kind of record (`namespace/name@major`) it goes through on the target machine, once each, up to 16. Not an Agent: not listed, not probed, not published. */
|
|
549
|
+
agentEntrances?: { command: string; via: string }[];
|
|
492
550
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/plugin/v2/agent-entrances.json",
|
|
4
|
+
"title": "contributes.agentEntrances:接线入口",
|
|
5
|
+
"description": "用别台 Agent 的会话经它接到那台:每项 { command, via },同一种记录只写一项,至多 16 项。入口讲 ACP,由会话代替 Agent 起;它不是 Agent,不出现在 Agent 列表里、不被探测、不发布",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"maxItems": 16,
|
|
8
|
+
"x-unique-by": ["via"],
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"command": {"$ref": "common.json#/$defs/command"},
|
|
13
|
+
"via": {"description": "它靠目标机器上的哪种记录接过去:协议名「命名空间/名字@大版本」,如 relay/host@1", "$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/name"}
|
|
14
|
+
},
|
|
15
|
+
"required": ["command", "via"],
|
|
16
|
+
"additionalProperties": false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -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"]
|
|
@@ -55,7 +55,20 @@
|
|
|
55
55
|
"additionalProperties": false
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"modes": {"type": "array", "description": "它的审批模式", "items": {"$ref": "#/$defs/level"}}
|
|
58
|
+
"modes": {"type": "array", "description": "它的审批模式", "items": {"$ref": "#/$defs/level"}},
|
|
59
|
+
"tiers": {
|
|
60
|
+
"type": ["object", "null"],
|
|
61
|
+
"description": "它的权限档位:manual、auto、full 各是哪个模式的 id(插件声明的档位各对应哪个模式,null 为没有这一档),safe 是安全模式的 id 列表,default 是 ACP 没报当前模式时相当于哪一档;提供它的插件没声明档位的为 null。这些 id 取自提供它的插件声明的档位,不保证出现在这条记录的 modes 里(modes 是 Agent 报上来的,目录没读到时为空);读它的一方用之前自己看它在不在 modes 里",
|
|
62
|
+
"properties": {
|
|
63
|
+
"manual": {"type": ["string", "null"], "minLength": 1, "maxLength": 200},
|
|
64
|
+
"auto": {"type": ["string", "null"], "minLength": 1, "maxLength": 200},
|
|
65
|
+
"full": {"type": ["string", "null"], "minLength": 1, "maxLength": 200},
|
|
66
|
+
"safe": {"type": "array", "items": {"type": "string", "minLength": 1, "maxLength": 200}},
|
|
67
|
+
"default": {"enum": ["safe", "manual", "auto", "full", null]}
|
|
68
|
+
},
|
|
69
|
+
"required": ["manual", "auto", "full", "safe", "default"],
|
|
70
|
+
"additionalProperties": false
|
|
71
|
+
}
|
|
59
72
|
},
|
|
60
73
|
"required": ["agent", "title", "defaultModel", "models", "modes"],
|
|
61
74
|
"additionalProperties": false
|
package/workflow/moddle.json
CHANGED
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
{
|
|
126
126
|
"name": "Input",
|
|
127
127
|
"superClass": ["Element"],
|
|
128
|
-
"description": "运行的一个输入:label 是表单上的名字,defaultFrom 是从会话发起、没给值时从哪里取(在 default 之前);type 为 agent 的值是一组 Agent 选择(agent,以及可选的 model、effort、mode、options)",
|
|
128
|
+
"description": "运行的一个输入:label 是表单上的名字,defaultFrom 是从会话发起、没给值时从哪里取(在 default 之前);type 为 agent 的值是一组 Agent 选择(agent,以及可选的 model、effort、mode、options、agentTarget;agentTarget 用别台的 Agent、会话在这台时写那台 Agent 记录的 coda://agents/<UUID> 引用或 UUID,agent 仍写真 Agent 的 ID)",
|
|
129
129
|
"properties": [
|
|
130
130
|
{"name": "name", "isAttr": true, "type": "String"},
|
|
131
131
|
{"name": "type", "isAttr": true, "type": "String"},
|