pi-ccswitch-auto-switch 0.3.7 → 0.3.9
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/index.ts +21 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ const FIRST_RESPONSE_TIMEOUT = 90_000
|
|
|
12
12
|
const STREAM_IDLE_TIMEOUT = 120_000
|
|
13
13
|
const ROUND_LIMIT = 8 * 60_000
|
|
14
14
|
const RPC_PROTOCOL_VERSION = 1
|
|
15
|
-
const EXTENSION_VERSION = '0.3.
|
|
15
|
+
const EXTENSION_VERSION = '0.3.8'
|
|
16
16
|
// 同端点(BaseURL 相同)连续失败达到该次数即隔离该端点,避免同一个平台的多个模型逐个试错耗尽本轮切换
|
|
17
17
|
const ENDPOINT_FAIL_THRESHOLD = 3
|
|
18
18
|
|
|
@@ -422,7 +422,26 @@ export default function (pi: ExtensionAPI) {
|
|
|
422
422
|
}
|
|
423
423
|
await failover(ctx)
|
|
424
424
|
})
|
|
425
|
-
pi.on('model_select', (
|
|
425
|
+
pi.on('model_select', (event, ctx) => {
|
|
426
|
+
// 用户手动切换模型(TUI 模型选择器 / /model / 方向键循环)。让 ccs 跟随:
|
|
427
|
+
// 更新“当前模型”并重置本轮故障转移状态,否则 round.model 停留在上一轮使用的模型,
|
|
428
|
+
// 导致状态栏与后续 failover 都滞后于实际选择,直到下次 input 才偶尔纠正。
|
|
429
|
+
const selected = event?.model ?? ctx.model
|
|
430
|
+
if (selected && round) {
|
|
431
|
+
round.model = selected
|
|
432
|
+
round.tried = new Set()
|
|
433
|
+
round.attempts = 0
|
|
434
|
+
round.observation = undefined
|
|
435
|
+
round.watchdog = false
|
|
436
|
+
round.cleanRetry = false
|
|
437
|
+
round.avoidFamilies = undefined
|
|
438
|
+
round.endpointFails = undefined
|
|
439
|
+
// 仅当不在活跃输入轮(monitoring 由 input 事件设置)时才退回 idle;
|
|
440
|
+
// TUI 在流式/工具执行中禁止切模型,故 active 态下不会触发,此处仅为防御。
|
|
441
|
+
if (round.phase !== 'monitoring') round.phase = 'idle'
|
|
442
|
+
}
|
|
443
|
+
status(ctx)
|
|
444
|
+
})
|
|
426
445
|
|
|
427
446
|
pi.registerCommand('ccswitch', { description: '查看和管理 CCSwitch 自动故障转移健康状态', handler: async (args, ctx) => {
|
|
428
447
|
const [verb, target] = args.trim().split(/\s+/, 2)
|