dsh-llm-fallbacks 0.6.10 → 0.6.12

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
@@ -7,7 +7,7 @@
7
7
  ![node](https://img.shields.io/badge/node-%3E%3D22-339933.svg)
8
8
  ![pnpm](https://img.shields.io/badge/pnpm-%3E%3D10-f69220.svg)
9
9
  ![dsh tui](https://img.shields.io/badge/dsh%20tui-compatible-4B32C3.svg)
10
- ![dsh](https://img.shields.io/badge/DSH-0.2.1--rc.2-4B32C3.svg)
10
+ ![dsh](https://img.shields.io/badge/DSH-0.2.1--rc.3-4B32C3.svg)
11
11
  [![dshfind](https://dshfind.com/api/badge/omdsh-dev/dsh-llm-fallbacks?lang=en)](https://dshfind.com/zh/plugins/omdsh-dev/dsh-llm-fallbacks?ref=badge)
12
12
 
13
13
  Automatic provider/model fallback chains for dsh (DeepSeek Harness): when an agent's LLM requests keep failing — retries exhausted, auth errors, quota exceeded, rate limiting (429) — the plugin switches provider/model along the fallback chain for the current role, and the current step/turn continues on the target model: tasks are not interrupted by model problems.
package/README.zh-CN.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ![node](https://img.shields.io/badge/node-%3E%3D22-339933.svg)
8
8
  ![pnpm](https://img.shields.io/badge/pnpm-%3E%3D10-f69220.svg)
9
9
  ![dsh tui](https://img.shields.io/badge/dsh%20tui-compatible-4B32C3.svg)
10
- ![dsh](https://img.shields.io/badge/DSH-0.2.1--rc.2-4B32C3.svg)
10
+ ![dsh](https://img.shields.io/badge/DSH-0.2.1--rc.3-4B32C3.svg)
11
11
  [![dshfind](https://dshfind.com/api/badge/omdsh-dev/dsh-llm-fallbacks?lang=zh)](https://dshfind.com/zh/plugins/omdsh-dev/dsh-llm-fallbacks?ref=badge)
12
12
 
13
13
  dsh(DeepSeek Harness)的自动模型降级插件:当 agent 的模型请求持续失败(重试耗尽、权限错误、配额超限、限流 429)时,插件按当前角色的 fallback 链切换 provider/model,当前 step/turn 在目标模型上继续——任务不会因模型问题中断。
package/dist/index.js CHANGED
@@ -3305,6 +3305,11 @@ function apply(ctx, config = defaultFallbacksConfig) {
3305
3305
  const states = new FallbackStateStore();
3306
3306
  stateStores.set(ctx, states);
3307
3307
  const dispatchInjected = new Set();
3308
+ const dispatchRoles = new Map();
3309
+ const rememberedRole = (agentId) => {
3310
+ const role = dispatchRoles.get(agentId);
3311
+ return role !== void 0 && roleIds.has(role.trim()) ? role : void 0;
3312
+ };
3308
3313
  const slotWinners = new Map();
3309
3314
  const lastKnownPolicySettings = new Map();
3310
3315
  async function decide(agent, turn, step, current, reason, state, failureCode) {
@@ -3313,7 +3318,7 @@ function apply(ctx, config = defaultFallbacksConfig) {
3313
3318
  states.syncStep(state, turn, step);
3314
3319
  if (state.stepFailures.switchCount >= config.maxSwitchesPerStep) return null;
3315
3320
  }
3316
- const role = resolveRole(agent, config.roles.rules, roleIds, logger.warn, servedRouteFor(agent, config));
3321
+ const role = rememberedRole(agent.id) ?? resolveRole(agent, config.roles.rules, roleIds, logger.warn, servedRouteFor(agent, config));
3317
3322
  const rootTail = agent.session?.header?.origin === "subagent" ? config.rootChain : resolveEffectiveChain(config, new Date(), config.tz ?? "Asia/Shanghai");
3318
3323
  const { all, wildcard } = resolveChainViews(config.roles.list, rootTail, role, current.provider, current.model, logger.warn);
3319
3324
  if (all.length === 0) return null;
@@ -3473,6 +3478,7 @@ function apply(ctx, config = defaultFallbacksConfig) {
3473
3478
  servedRoute: servedRouteFor(agent, config)
3474
3479
  });
3475
3480
  if (role !== "inherit") {
3481
+ dispatchRoles.set(agent.id, role);
3476
3482
  const { all, wildcard } = resolveChainViews(config.roles.list, config.rootChain, role, seed.provider, seed.model, logger.warn);
3477
3483
  let to;
3478
3484
  if (policy.state === "enabled") {
@@ -3529,6 +3535,7 @@ function apply(ctx, config = defaultFallbacksConfig) {
3529
3535
  ctx.on("agent/disposed", ({ agent }) => {
3530
3536
  states.delete(agent.id);
3531
3537
  dispatchInjected.delete(agent.id);
3538
+ dispatchRoles.delete(agent.id);
3532
3539
  slotWinners.delete(agent.id);
3533
3540
  blockedAttemptMap.delete(agent.id);
3534
3541
  chainHeadMap.delete(agent.id);
@@ -3553,6 +3560,7 @@ function apply(ctx, config = defaultFallbacksConfig) {
3553
3560
  ctx.effect(() => () => {
3554
3561
  states.clear();
3555
3562
  dispatchInjected.clear();
3563
+ dispatchRoles.clear();
3556
3564
  slotWinners.clear();
3557
3565
  blockedAttemptMap.clear();
3558
3566
  chainHeadMap.clear();
@@ -3564,7 +3572,7 @@ function apply(ctx, config = defaultFallbacksConfig) {
3564
3572
  const fallbacksCommandController = {
3565
3573
  getSnapshot(agent) {
3566
3574
  const config = source();
3567
- const role = resolveRole(agent, config.roles.rules, roleIds, logger.warn, servedRouteFor(agent, config));
3575
+ const role = rememberedRole(agent.id) ?? resolveRole(agent, config.roles.rules, roleIds, logger.warn, servedRouteFor(agent, config));
3568
3576
  const state = states.peek(agent.id);
3569
3577
  const recovery = config.recovery ?? "timer";
3570
3578
  if (state !== void 0 && recovery === "half-open") states.syncRecovery(state, Date.now(), recovery);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dsh",
6
6
  "dsh-plugin"
7
7
  ],
8
- "version": "0.6.10",
8
+ "version": "0.6.12",
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -65,29 +65,29 @@
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@deepseek-ai/cordis": "^4.0.5",
68
- "@deepseek-ai/dsh-agent": "^0.2.1-rc.2",
69
- "@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.2",
70
- "@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.2",
71
- "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.2",
72
- "@deepseek-ai/dsh-client-connection": "^0.2.1-rc.2",
73
- "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
74
- "@deepseek-ai/dsh-client-store": "^0.2.1-rc.2",
75
- "@deepseek-ai/dsh-client-ui-chat": "^0.2.1-rc.2",
76
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.2",
77
- "@deepseek-ai/dsh-client-ui-plugin-manager": "^0.2.1-rc.2",
78
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
79
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.2",
80
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
81
- "@deepseek-ai/dsh-commands": "^0.2.1-rc.2",
82
- "@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
83
- "@deepseek-ai/dsh-llm-retry": "^0.2.1-rc.2",
84
- "@deepseek-ai/dsh-session": "^0.2.1-rc.2",
85
- "@deepseek-ai/dsh-session-projection": "^0.2.1-rc.2",
86
- "@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
87
- "@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.2",
88
- "@deepseek-ai/dsh-tool-subagent": "^0.2.1-rc.2",
89
- "@deepseek-ai/dsh-typert-protocol": "^0.2.1-rc.2",
90
- "@deepseek-ai/dsh-typert-registry": "^0.2.1-rc.2",
68
+ "@deepseek-ai/dsh-agent": "^0.2.1-rc.3",
69
+ "@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.3",
70
+ "@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.3",
71
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.3",
72
+ "@deepseek-ai/dsh-client-connection": "^0.2.1-rc.3",
73
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
74
+ "@deepseek-ai/dsh-client-store": "^0.2.1-rc.3",
75
+ "@deepseek-ai/dsh-client-ui-chat": "^0.2.1-rc.3",
76
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.3",
77
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "^0.2.1-rc.3",
78
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.3",
79
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.3",
80
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.3",
81
+ "@deepseek-ai/dsh-commands": "^0.2.1-rc.3",
82
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.3",
83
+ "@deepseek-ai/dsh-llm-retry": "^0.2.1-rc.3",
84
+ "@deepseek-ai/dsh-session": "^0.2.1-rc.3",
85
+ "@deepseek-ai/dsh-session-projection": "^0.2.1-rc.3",
86
+ "@deepseek-ai/dsh-settings": "^0.2.1-rc.3",
87
+ "@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.3",
88
+ "@deepseek-ai/dsh-tool-subagent": "^0.2.1-rc.3",
89
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.1-rc.3",
90
+ "@deepseek-ai/dsh-typert-registry": "^0.2.1-rc.3",
91
91
  "@deepseek-ai/schemastery": "^3.18.5",
92
92
  "react": "^18.2.0"
93
93
  },