dsh-llm-fallbacks 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.
package/README.md CHANGED
@@ -52,14 +52,14 @@ No rule match → the built-in `inherit` → `rootChain`. `enabled` defaults to
52
52
 
53
53
  ### Verify
54
54
 
55
- Save and restart the session, then type `/fallbacks` — the read-only in-session diagnostics (origin, resolved role, chain, recent `fallbacks/switch` events, cooldown status). In a dsh-tui profile, `/fallbacks config` additionally reads back the composed configuration (the TUI has no settings page — config is file-only; see [docs/configuration.md](docs/configuration.md)).
55
+ Save and restart the session, then type `/fallbacks` — the read-only in-session diagnostics (origin, resolved role, chain, recent `fallbacks/switch` events, cooldown status). Sessions containing `fallbacks/switch` events load after a restart because the plugin registers the event type at startup (rc.6 runtime registration; an upstream registration surface is pending) — without the plugin installed, such sessions refuse to load again until the upstream surface lands (see the Features note below). In a dsh-tui profile, `/fallbacks config` additionally reads back the composed configuration (the TUI has no settings page — config is file-only; see [docs/configuration.md](docs/configuration.md)).
56
56
 
57
57
  ## Features
58
58
 
59
59
  - **Automatic fallback for root and subagents**: any agent switches down the chain to the next available provider/model on model failure — no manual model switching.
60
60
  - **Two-block config**: `rootChain` for the root agent; declared role entities (`roles.list`) referenced by `roles.rules` (or the built-in `inherit`).
61
61
  - **Cooldown and revert**: failed / switched-away models are not re-selected during cooldown; `revertPolicy: cooldown-expiry` returns to the primary model automatically.
62
- - **Visible behavior**: every switch appends a persisted `fallbacks/switch` session event (from/to/role/reason) with info-level logs — no silent model switching.
62
+ - **Visible behavior**: every switch appends a persisted `fallbacks/switch` session event (from/to/role/reason) with info-level logs — no silent model switching. The event type is registered with the harness at plugin startup (rc.6 runtime registration; an upstream registration surface is pending), so persisted events stay loadable across restarts while the plugin is installed.
63
63
  - **Safety valves**: `maxSwitchesPerStep` caps switches per step and `alwaysModeRetryCap` caps always-mode retries — chain loops cannot amplify latency.
64
64
  - **No-config no-op**: `enabled` defaults to off; with no chains configured the plugin behaves exactly like not being installed.
65
65
 
package/README.zh-CN.md CHANGED
@@ -52,14 +52,14 @@ fallbacks:
52
52
 
53
53
  ### 验证
54
54
 
55
- 保存并重启会话后,键入 `/fallbacks`——只读的会话内诊断(来源、解析角色、链、最近的 `fallbacks/switch` 事件、冷却状态)。在 dsh-tui profile 中,`/fallbacks config` 额外回读组合配置(TUI 无设置页——配置仅文件,见 [docs/configuration.md](docs/configuration.md))。
55
+ 保存并重启会话后,键入 `/fallbacks`——只读的会话内诊断(来源、解析角色、链、最近的 `fallbacks/switch` 事件、冷却状态)。含 `fallbacks/switch` 事件的会话能在重启后正常加载,是因为插件在启动时注册了该事件类型(rc.6 运行时注册;上游注册面待落地)——卸载插件后,含此类事件的会话将再次拒绝加载,直到上游注册面落地(见下方「能力一览」说明)。在 dsh-tui profile 中,`/fallbacks config` 额外回读组合配置(TUI 无设置页——配置仅文件,见 [docs/configuration.md](docs/configuration.md))。
56
56
 
57
57
  ## 能力一览
58
58
 
59
59
  - **root / subagent 自动降级**:任意 agent 在模型故障下按链切换到下一个可用 provider/model,无需手动换模型。
60
60
  - **两块制配置**:`rootChain` 管 root 代理;声明式角色实体(`roles.list`)供 `roles.rules` 引用(或内置 `inherit`)。
61
61
  - **冷却与回主**:被切离/失败的模型在冷却期内不再入选;`revertPolicy: cooldown-expiry` 冷却到期后自动回主模型。
62
- - **行为可见**:每次切换追加持久化会话事件 `fallbacks/switch`(from/to/role/reason),配合 info 级日志——无静默换模型。
62
+ - **行为可见**:每次切换追加持久化会话事件 `fallbacks/switch`(from/to/role/reason),配合 info 级日志——无静默换模型。插件在启动时把该事件类型注册进宿主(rc.6 运行时注册;上游注册面待落地),持久化事件在插件安装期间可跨重启加载。
63
63
  - **安全阀**:`maxSwitchesPerStep` 限制每 step 切换次数、`alwaysModeRetryCap` 限制 always 模式重试——链循环不会放大延迟。
64
64
  - **无配置回归(no-op)**:`enabled` 默认关闭;未配置任何链时行为与未安装插件完全一致。
65
65
 
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
3
+ import * as dshSession from "@deepseek-ai/dsh-session";
3
4
  import z from "@deepseek-ai/schemastery";
4
5
  import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
5
6
  //#region .build/host/selectors.js
@@ -1051,6 +1052,15 @@ function overrideConfig(seed, to) {
1051
1052
  }
1052
1053
  function apply(ctx, config = defaultFallbacksConfig) {
1053
1054
  const logger = ctx.logger("llm-fallbacks");
1055
+ const known = dshSession.KNOWN_SESSION_EVENT_TYPES;
1056
+ let sessionEventRegistered = false;
1057
+ if (known instanceof Set) try {
1058
+ known.add("fallbacks/switch");
1059
+ sessionEventRegistered = known.has("fallbacks/switch");
1060
+ } catch {
1061
+ sessionEventRegistered = false;
1062
+ }
1063
+ let sessionEventWarned = false;
1054
1064
  const entry = Config(config);
1055
1065
  const seeds = new FallbacksSeedManager(logger);
1056
1066
  const seedsSettingsUnavailable = "llm-fallbacks: seeds: settings service is unavailable — seed roles cannot be written";
@@ -1168,6 +1178,13 @@ function apply(ctx, config = defaultFallbacksConfig) {
1168
1178
  states.suppress(state, fromKey, until);
1169
1179
  states.recordFailure(state, fromKey);
1170
1180
  states.recordSwitch(state);
1181
+ if (!sessionEventRegistered) {
1182
+ if (!sessionEventWarned) {
1183
+ sessionEventWarned = true;
1184
+ logger.warn("llm-fallbacks: session event type \"fallbacks/switch\" is not registered with this harness — skipping the durable event (the switch itself is applied)");
1185
+ }
1186
+ return;
1187
+ }
1171
1188
  agent.session.append("fallbacks/switch", {
1172
1189
  turn,
1173
1190
  step,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dsh",
6
6
  "dsh-plugin"
7
7
  ],
8
- "version": "0.2.0",
8
+ "version": "0.2.1",
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -71,6 +71,7 @@
71
71
  "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6",
72
72
  "@deepseek-ai/dsh-commands": "^0.1.0-rc.6",
73
73
  "@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
74
+ "@deepseek-ai/dsh-session": "^0.1.0-rc.6",
74
75
  "@deepseek-ai/dsh-settings": "^0.1.0-rc.6",
75
76
  "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.6",
76
77
  "@deepseek-ai/dsh-typert-registry": "^0.1.0-rc.6",