@zhushanwen/pi-provider-live-sync 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.ts +8 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-provider-live-sync",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Keep the running pi process's model snapshot in sync with on-disk provider/model/credential config changes.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -29,14 +29,14 @@
29
29
  "skills/"
30
30
  ],
31
31
  "dependencies": {
32
- "@zhushanwen/pi-extension-logger": "0.6.1"
32
+ "@zhushanwen/pi-extension-logger": "0.6.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@vitest/coverage-v8": "^4.1.9",
36
36
  "vitest": "^4.1.8"
37
37
  },
38
38
  "peerDependencies": {
39
- "@earendil-works/pi-coding-agent": "^0.84.4"
39
+ "@earendil-works/pi-coding-agent": "^1.0.0"
40
40
  },
41
41
  "scripts": {
42
42
  "typecheck": "npx tsc --noEmit",
package/src/index.ts CHANGED
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * provider-live-sync —— 运行中 pi 进程的**模型快照实时同步**扩展。
3
3
  *
4
- * 问题(根因①):pi 0.84.4 的可用模型集合冻结在 **spawn 时刻**——`set_model` 从
5
- * `session.modelRuntime.getAvailableSnapshot()` 解析(`dist/modes/rpc/rpc-mode.js:367-375`),
6
- * 该快照建于 `ModelRuntime.create()` 的 refresh(`dist/core/model-runtime.js:63-100`),
4
+ * 问题(根因①):pi 1.0.0 的可用模型集合冻结在 **spawn 时刻**——`set_model` 从
5
+ * `session.modelRuntime.getAvailableSnapshot()` 解析(`dist/modes/rpc/rpc-mode.js`
6
+ * case "set_model"),
7
+ * 该快照建于 `ModelRuntime.create()` 的 refresh(`dist/core/model-runtime.js`
8
+ * create 内 ModelConfig.load + rebuildProviders),
7
9
  * 而 pi 自身**没有文件 watcher、没有 refresh RPC**。于是「会话开着 → 在设置页新增 provider/
8
10
  * 模型/凭据 → 直接切到新模型」会报 `Model not found`(缺凭据与缺模型同文案),只能重开会话。
9
11
  *
10
12
  * 解法:本扩展按固定周期读 `<agentDir>/models.json` 与 `<agentDir>/auth.json`,**内容变化**时
11
13
  * 调 pi 自己的 `ctx.modelRegistry.refresh({ allowNetwork: false })`——`ModelRuntime.refresh()`
12
14
  * 首行即 `ModelConfig.load(modelsPath)` **重读磁盘配置**,随后 `rebuildProviders()` 按新配置重组
13
- * (`dist/core/model-runtime.js:501-513`),因此新增/删除 provider、模型与凭据都会立即生效;
14
- * `allowNetwork:false` 走本地恢复相位并在任何凭据解析/入网前返回(pi-ai `dist/models.js:153-158`)
15
+ * (`dist/core/model-runtime.js` refresh),因此新增/删除 provider、模型与凭据都会立即生效;
16
+ * `allowNetwork:false` 走本地恢复相位并在任何凭据解析/入网前返回(pi-ai `dist/models.js`
17
+ * runProviderRefreshPhase)
15
18
  * ——**零网络请求**。
16
19
  *
17
20
  * 设计取舍(详见 docs 侧设计文档 §3.3 D3/D11/D12):