pi-ccswitch-auto-switch 0.3.2 → 0.3.3
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/health.ts +6 -0
- package/index.ts +1 -1
- package/package.json +1 -1
package/health.ts
CHANGED
|
@@ -105,6 +105,8 @@ export class HealthStore {
|
|
|
105
105
|
private dirty = false
|
|
106
106
|
private replaceOnFlush = false
|
|
107
107
|
private resetModels = new Set<string>()
|
|
108
|
+
/** 合并磁盘状态后仍需强制清空的审查约束(session 边界) */
|
|
109
|
+
private clearContentPolicyOnFlush = false
|
|
108
110
|
|
|
109
111
|
constructor(dir = agentDir()) { this.dir = dir }
|
|
110
112
|
get file(): string { return join(this.dir, STATE_FILE) }
|
|
@@ -242,6 +244,7 @@ export class HealthStore {
|
|
|
242
244
|
*/
|
|
243
245
|
clearContentPolicyConstraints(): void {
|
|
244
246
|
this.state.contentPolicyFamilies = {}
|
|
247
|
+
this.clearContentPolicyOnFlush = true
|
|
245
248
|
this.touch()
|
|
246
249
|
}
|
|
247
250
|
|
|
@@ -270,6 +273,8 @@ export class HealthStore {
|
|
|
270
273
|
await this.withLock(async () => {
|
|
271
274
|
if (!this.replaceOnFlush) this.state = mergeState(await this.readDisk(), this.state)
|
|
272
275
|
for (const key of this.resetModels) delete this.state.models[key]
|
|
276
|
+
// 必须在 merge 之后再清空:磁盘上残留的旧 session 约束不能因合并而重新出现
|
|
277
|
+
if (this.clearContentPolicyOnFlush) this.state.contentPolicyFamilies = {}
|
|
273
278
|
await this.commit()
|
|
274
279
|
}).catch(() => {})
|
|
275
280
|
}
|
|
@@ -308,6 +313,7 @@ export class HealthStore {
|
|
|
308
313
|
this.dirty = false
|
|
309
314
|
this.replaceOnFlush = false
|
|
310
315
|
this.resetModels.clear()
|
|
316
|
+
this.clearContentPolicyOnFlush = false
|
|
311
317
|
}
|
|
312
318
|
private bucket(scope: HealthScope): Record<string, HealthRecord> {
|
|
313
319
|
return scope === 'model' ? this.state.models : scope === 'provider' ? this.state.providers : this.state.endpoints
|
package/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ const STREAM_IDLE_TIMEOUT = 120_000
|
|
|
8
8
|
const MAX_ATTEMPTS = 5
|
|
9
9
|
const ROUND_LIMIT = 8 * 60_000
|
|
10
10
|
const RPC_PROTOCOL_VERSION = 1
|
|
11
|
-
const EXTENSION_VERSION = '0.3.
|
|
11
|
+
const EXTENSION_VERSION = '0.3.3'
|
|
12
12
|
// 同端点(BaseURL 相同)连续失败达到该次数即隔离该端点,避免同一个平台的多个模型逐个试错耗尽本轮切换
|
|
13
13
|
const ENDPOINT_FAIL_THRESHOLD = 3
|
|
14
14
|
|