@dsh-plus/lifeboat 0.2.17 → 0.2.19

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/lib/index.d.ts CHANGED
@@ -2,17 +2,17 @@ import z from "@deepseek-ai/schemastery";
2
2
  import { Context } from "@deepseek-ai/cordis";
3
3
  //#region src/config.d.ts
4
4
  /** 行级配置:全部有默认值,正常部署零配置。 */
5
- declare const Config: z<Schemastery.ObjectS<{
6
- enabled: z<boolean, boolean>;
7
- patchFile: z<string, string>;
8
- llmFallback: z<boolean, boolean>;
9
- alertCooldownMs: z<number, number>;
10
- }>, Schemastery.ObjectT<{
11
- enabled: z<boolean, boolean>;
12
- patchFile: z<string, string>;
13
- llmFallback: z<boolean, boolean>;
14
- alertCooldownMs: z<number, number>;
15
- }>>;
5
+ declare const Config: z<Schemastery.ObjectS<NoInfer<{
6
+ enabled: z<boolean, boolean, "defined">;
7
+ patchFile: z<string, string, "defined">;
8
+ llmFallback: z<boolean, boolean, "defined">;
9
+ alertCooldownMs: z<number, number, "defined">;
10
+ }>>, Schemastery.ObjectT<NoInfer<{
11
+ enabled: z<boolean, boolean, "defined">;
12
+ patchFile: z<string, string, "defined">;
13
+ llmFallback: z<boolean, boolean, "defined">;
14
+ alertCooldownMs: z<number, number, "defined">;
15
+ }>>, "plain">;
16
16
  type LifeboatConfig = Schemastery.TypeT<typeof Config>;
17
17
  //#endregion
18
18
  //#region src/index.d.ts
package/lib/index.js CHANGED
@@ -205,7 +205,7 @@ function installLlmFallback(ctx, deps, graceMs = BOOT_GRACE_MS) {
205
205
  if (ids.has(state.originalProvider)) await revert(state);
206
206
  return;
207
207
  }
208
- const def = ctx.settings.get(NS_AGENT_DEFAULT);
208
+ const def = ctx.settings.describe().find((row) => row.ns === NS_AGENT_DEFAULT)?.value;
209
209
  if (def?.provider === void 0 || def.model === void 0) return;
210
210
  if (ids.has(def.provider)) return;
211
211
  await activate(def.provider, def.model);
@@ -229,7 +229,7 @@ function installLlmFallback(ctx, deps, graceMs = BOOT_GRACE_MS) {
229
229
  "llm-pi-ai",
230
230
  RAW_NS_LLM_PI
231
231
  ]);
232
- ctx.root.on("settings/updated", (ns) => {
232
+ ctx.root.on("settings/document-updated", (ns) => {
233
233
  if (typeof ns === "string" && WATCHED_NS.has(ns)) run();
234
234
  });
235
235
  ctx.root.on("llm/adapters-updated", run);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-plus/lifeboat",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "dsh-plus service plugin: 故障救生艇——兄弟插件崩溃时自动隔离(写用户 patch 层禁用),llm-pi 缺席时把其配置临时翻译为官方 llm-pi-ai 路由,恢复后自动还原",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -31,22 +31,22 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "yaml": "^2.9.0",
34
- "@dsh-plus/shared": "0.1.21"
34
+ "@dsh-plus/shared": "0.1.23"
35
35
  },
36
36
  "peerDependencies": {
37
- "@deepseek-ai/cordis": "^4.0.2",
38
- "@deepseek-ai/dsh-home-paths": "^0.1.6-alpha.2",
39
- "@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
40
- "@deepseek-ai/dsh-settings": "^0.1.6-alpha.2",
41
- "@deepseek-ai/schemastery": "^3.18.2"
37
+ "@deepseek-ai/cordis": "^4.0.4",
38
+ "@deepseek-ai/dsh-home-paths": "^0.1.7-rc.1",
39
+ "@deepseek-ai/dsh-llm": "^0.1.7-rc.1",
40
+ "@deepseek-ai/dsh-settings": "^0.1.7-rc.1",
41
+ "@deepseek-ai/schemastery": "^3.18.4"
42
42
  },
43
43
  "devDependencies": {
44
- "@deepseek-ai/cordis": "4.0.2",
45
- "@deepseek-ai/dsh-home-paths": "0.1.6-alpha.2",
46
- "@deepseek-ai/dsh-host-webserver": "0.1.6-alpha.2",
47
- "@deepseek-ai/dsh-llm": "0.1.6-alpha.2",
48
- "@deepseek-ai/dsh-settings": "0.1.6-alpha.2",
49
- "@deepseek-ai/schemastery": "3.18.2",
44
+ "@deepseek-ai/cordis": "4.0.4",
45
+ "@deepseek-ai/dsh-home-paths": "0.1.7-rc.1",
46
+ "@deepseek-ai/dsh-host-webserver": "0.1.7-rc.1",
47
+ "@deepseek-ai/dsh-llm": "0.1.7-rc.1",
48
+ "@deepseek-ai/dsh-settings": "0.1.7-rc.1",
49
+ "@deepseek-ai/schemastery": "3.18.4",
50
50
  "@types/node": "26.4.0",
51
51
  "@types/react": "~18.3.31",
52
52
  "react": "^18.2.0"
@@ -15,7 +15,7 @@ import { readFile } from 'node:fs/promises'
15
15
  import type { Context } from '@deepseek-ai/cordis'
16
16
  import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
17
17
  import type {} from '@deepseek-ai/dsh-llm'
18
- import { SettingsConflictError, type SettingsProvider } from '@deepseek-ai/dsh-settings'
18
+ import { SettingsConflictError } from '@deepseek-ai/dsh-settings'
19
19
  import { parseDocument } from 'yaml'
20
20
 
21
21
  import type { FallbackStateT } from './config.ts'
@@ -224,7 +224,7 @@ export function installLlmFallback(
224
224
  graceMs: number = BOOT_GRACE_MS,
225
225
  ): void {
226
226
  const logger = ctx.logger('lifeboat')
227
- const settings = ctx.settings as SettingsProvider
227
+ const settings = ctx.settings
228
228
  const writes = settings as unknown as SettingsWrite
229
229
  const settingsFile = dshHomePath('settings.yaml')
230
230
  let inFlight: Promise<void> | undefined
@@ -246,9 +246,9 @@ export function installLlmFallback(
246
246
  const translated = translateProviders(providers)
247
247
  const fbProvider = `${provider}${FALLBACK_SUFFIX}`
248
248
  try {
249
- // 官方 llm-pi-ai 的 installSection 注册了 validate(assertServiceable),
250
- // 写时拒绝不适配的翻译结果;update 无 expectedRevision 本就无条件写,不做冲突
251
- // 重试——失败一律分类为「翻译失败」。
249
+ // 0.1.7 起写入校验经 internal/config waterfall(官方 llm-pi-ai 同款,
250
+ // 替代 0.1.6 installSection validate),落盘前拒绝不适配的翻译结果;
251
+ // update 无 expectedRevision 本就无条件写,不做冲突重试——失败一律分类为「翻译失败」。
252
252
  await writes.update(NS_PI_AI, { providers: translated })
253
253
  await writes.update(NS_AGENT_DEFAULT, { provider: fbProvider, model })
254
254
  } catch (error) {
@@ -303,7 +303,8 @@ export function installLlmFallback(
303
303
  if (ids.has(state.originalProvider)) await revert(state)
304
304
  return
305
305
  }
306
- const def = ctx.settings.get(NS_AGENT_DEFAULT) as
306
+ // 0.1.7 无 settings.get:describe() 直读本条目平面值(volatile 解包后视图)。
307
+ const def = ctx.settings.describe().find((row) => row.ns === NS_AGENT_DEFAULT)?.value as
307
308
  | { provider?: string; model?: string }
308
309
  | undefined
309
310
  if (def?.provider === undefined || def.model === undefined) return
@@ -340,10 +341,10 @@ export function installLlmFallback(
340
341
  ctx.events.on('ready', run)
341
342
  // 只响应与本判定相关的命名空间变化:journal 写自身命名空间,不过滤会自触发循环。
342
343
  const WATCHED_NS = new Set(['agent-default-model', 'llm-pi-ai', RAW_NS_LLM_PI])
343
- // settings/updated 由 @deepseek-ai/dsh-settings 声明(本文件已导入该包),
344
- // 参数类型是品牌化的 SettingsNamespace;监听器按 unknown 收,保留原有
345
- // typeof 字符串防御。
346
- ctx.root.on('settings/updated', (ns: unknown) => {
344
+ // settings/document-updated 由 @deepseek-ai/dsh-settings 声明(本文件已导入
345
+ // 该包),0.1.7 起载荷为 (ns, revision);监听器按 unknown 收,保留原有
346
+ // typeof 字符串防御。watched 过滤避免 journal 自写自触发循环。
347
+ ctx.root.on('settings/document-updated', (ns: unknown) => {
347
348
  if (typeof ns === 'string' && WATCHED_NS.has(ns)) run()
348
349
  })
349
350
  // 事件名已核对:0.1.2-alpha.2 的 dsh-llm 保留 'llm/adapters-updated'