@jsonstudio/llms 0.6.633 → 0.6.743

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.
Files changed (61) hide show
  1. package/dist/conversion/codecs/anthropic-openai-codec.js +0 -5
  2. package/dist/conversion/codecs/openai-openai-codec.js +0 -6
  3. package/dist/conversion/codecs/responses-openai-codec.js +1 -7
  4. package/dist/conversion/hub/node-support.js +5 -4
  5. package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +14 -1
  6. package/dist/conversion/hub/pipeline/hub-pipeline.js +82 -18
  7. package/dist/conversion/hub/pipeline/session-identifiers.js +132 -2
  8. package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +23 -19
  9. package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +47 -0
  10. package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +4 -2
  11. package/dist/conversion/hub/process/chat-process.js +2 -0
  12. package/dist/conversion/hub/response/provider-response.js +6 -1
  13. package/dist/conversion/hub/snapshot-recorder.js +8 -1
  14. package/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.js +0 -7
  15. package/dist/conversion/responses/responses-openai-bridge.js +47 -7
  16. package/dist/conversion/shared/compaction-detect.d.ts +2 -0
  17. package/dist/conversion/shared/compaction-detect.js +53 -0
  18. package/dist/conversion/shared/errors.d.ts +1 -1
  19. package/dist/conversion/shared/reasoning-tool-normalizer.js +7 -0
  20. package/dist/conversion/shared/snapshot-hooks.d.ts +2 -0
  21. package/dist/conversion/shared/snapshot-hooks.js +180 -4
  22. package/dist/conversion/shared/snapshot-utils.d.ts +4 -0
  23. package/dist/conversion/shared/snapshot-utils.js +4 -0
  24. package/dist/conversion/shared/tool-filter-pipeline.js +3 -9
  25. package/dist/conversion/shared/tool-governor.d.ts +2 -0
  26. package/dist/conversion/shared/tool-governor.js +101 -13
  27. package/dist/conversion/shared/tool-harvester.js +42 -2
  28. package/dist/filters/index.d.ts +0 -2
  29. package/dist/filters/index.js +0 -2
  30. package/dist/filters/special/request-tools-normalize.d.ts +11 -0
  31. package/dist/filters/special/request-tools-normalize.js +13 -50
  32. package/dist/filters/special/response-apply-patch-toon-decode.js +403 -82
  33. package/dist/filters/special/response-tool-arguments-toon-decode.js +6 -75
  34. package/dist/filters/utils/snapshot-writer.js +42 -4
  35. package/dist/guidance/index.js +8 -2
  36. package/dist/router/virtual-router/engine-health.js +0 -4
  37. package/dist/router/virtual-router/engine-selection.d.ts +2 -1
  38. package/dist/router/virtual-router/engine-selection.js +101 -9
  39. package/dist/router/virtual-router/engine.d.ts +5 -1
  40. package/dist/router/virtual-router/engine.js +188 -5
  41. package/dist/router/virtual-router/routing-instructions.d.ts +6 -0
  42. package/dist/router/virtual-router/routing-instructions.js +18 -3
  43. package/dist/router/virtual-router/sticky-session-store.d.ts +1 -0
  44. package/dist/router/virtual-router/sticky-session-store.js +36 -0
  45. package/dist/router/virtual-router/types.d.ts +22 -0
  46. package/dist/servertool/engine.js +335 -9
  47. package/dist/servertool/handlers/compaction-detect.d.ts +1 -0
  48. package/dist/servertool/handlers/compaction-detect.js +1 -0
  49. package/dist/servertool/handlers/gemini-empty-reply-continue.js +29 -5
  50. package/dist/servertool/handlers/iflow-model-error-retry.js +17 -0
  51. package/dist/servertool/handlers/stop-message-auto.js +199 -19
  52. package/dist/servertool/server-side-tools.d.ts +0 -1
  53. package/dist/servertool/server-side-tools.js +0 -1
  54. package/dist/servertool/types.d.ts +1 -0
  55. package/dist/tools/apply-patch-structured.js +52 -15
  56. package/dist/tools/tool-registry.js +537 -15
  57. package/dist/utils/toon.d.ts +4 -0
  58. package/dist/utils/toon.js +75 -0
  59. package/package.json +4 -2
  60. package/dist/test-output/virtual-router/results.json +0 -1
  61. package/dist/test-output/virtual-router/summary.json +0 -12
@@ -32,6 +32,7 @@ export class VirtualRouterEngine {
32
32
  saveAsync: saveRoutingInstructionStateAsync
33
33
  };
34
34
  routingInstructionState = new Map();
35
+ quotaView;
35
36
  constructor(deps) {
36
37
  if (deps?.healthStore) {
37
38
  this.healthStore = deps.healthStore;
@@ -39,6 +40,9 @@ export class VirtualRouterEngine {
39
40
  if (deps?.routingStateStore) {
40
41
  this.routingStateStore = deps.routingStateStore;
41
42
  }
43
+ if (deps?.quotaView) {
44
+ this.quotaView = deps.quotaView;
45
+ }
42
46
  }
43
47
  initialize(config) {
44
48
  this.validateConfig(config);
@@ -76,13 +80,121 @@ export class VirtualRouterEngine {
76
80
  stickyTarget: undefined
77
81
  };
78
82
  }
79
- const instructions = parseRoutingInstructions(request.messages);
83
+ const sessionScope = this.resolveSessionScope(metadata);
84
+ if (sessionScope) {
85
+ const sessionState = this.getRoutingInstructionState(sessionScope);
86
+ if (typeof sessionState.stopMessageText === 'string' ||
87
+ typeof sessionState.stopMessageMaxRepeats === 'number') {
88
+ routingState = {
89
+ ...routingState,
90
+ stopMessageText: sessionState.stopMessageText,
91
+ stopMessageMaxRepeats: sessionState.stopMessageMaxRepeats,
92
+ stopMessageUsed: sessionState.stopMessageUsed,
93
+ stopMessageUpdatedAt: sessionState.stopMessageUpdatedAt,
94
+ stopMessageLastUsedAt: sessionState.stopMessageLastUsedAt
95
+ };
96
+ }
97
+ }
98
+ const parsedInstructions = parseRoutingInstructions(request.messages);
99
+ let instructions = parsedInstructions;
100
+ if (sessionScope && parsedInstructions.length > 0) {
101
+ const sessionState = this.getRoutingInstructionState(sessionScope);
102
+ const hasStopMessageClear = parsedInstructions.some((entry) => entry.type === 'stopMessageClear');
103
+ const stopMessageSets = parsedInstructions.filter((entry) => entry.type === 'stopMessageSet');
104
+ if (!hasStopMessageClear && stopMessageSets.length > 0) {
105
+ const sessionText = typeof sessionState.stopMessageText === 'string' ? sessionState.stopMessageText.trim() : '';
106
+ const sessionMax = typeof sessionState.stopMessageMaxRepeats === 'number' && Number.isFinite(sessionState.stopMessageMaxRepeats)
107
+ ? Math.floor(sessionState.stopMessageMaxRepeats)
108
+ : undefined;
109
+ const allSame = stopMessageSets.every((entry) => {
110
+ const entryText = typeof entry.stopMessageText === 'string' ? entry.stopMessageText.trim() : '';
111
+ const entryMax = typeof entry.stopMessageMaxRepeats === 'number' && Number.isFinite(entry.stopMessageMaxRepeats)
112
+ ? Math.floor(entry.stopMessageMaxRepeats)
113
+ : undefined;
114
+ return Boolean(entryText) && entryText === sessionText && entryMax === sessionMax;
115
+ });
116
+ if (allSame) {
117
+ instructions = parsedInstructions.filter((entry) => entry.type !== 'stopMessageSet');
118
+ }
119
+ }
120
+ }
121
+ if (parsedInstructions.length > 0) {
122
+ request.messages = cleanMessagesFromRoutingInstructions(request.messages);
123
+ }
80
124
  if (instructions.length > 0) {
81
125
  routingState = applyRoutingInstructions(instructions, routingState);
82
126
  const effectiveKey = stickyKey || 'default';
83
127
  this.routingInstructionState.set(effectiveKey, routingState);
84
- request.messages = cleanMessagesFromRoutingInstructions(request.messages);
85
128
  this.persistRoutingInstructionState(effectiveKey, routingState);
129
+ // 对 stopMessage 指令补充一份基于 session/conversation 的持久化状态,
130
+ // 便于 server-side 工具通过 session:*/conversation:* scope 读取到相同配置。
131
+ if (sessionScope) {
132
+ const hasStopMessageSet = instructions.some((entry) => entry.type === 'stopMessageSet');
133
+ const hasStopMessageClear = instructions.some((entry) => entry.type === 'stopMessageClear');
134
+ if (hasStopMessageSet || hasStopMessageClear) {
135
+ const sessionState = this.getRoutingInstructionState(sessionScope);
136
+ let nextSessionState = {
137
+ ...sessionState
138
+ };
139
+ let shouldPersistSessionState = false;
140
+ if (hasStopMessageClear) {
141
+ nextSessionState.stopMessageText = undefined;
142
+ nextSessionState.stopMessageMaxRepeats = undefined;
143
+ nextSessionState.stopMessageUsed = undefined;
144
+ nextSessionState.stopMessageUpdatedAt = undefined;
145
+ nextSessionState.stopMessageLastUsedAt = undefined;
146
+ shouldPersistSessionState = true;
147
+ }
148
+ else if (hasStopMessageSet) {
149
+ const text = typeof routingState.stopMessageText === 'string' ? routingState.stopMessageText : '';
150
+ const maxRepeats = routingState.stopMessageMaxRepeats;
151
+ const sameText = typeof sessionState.stopMessageText === 'string' &&
152
+ sessionState.stopMessageText.trim() === text.trim();
153
+ const sameMax = typeof sessionState.stopMessageMaxRepeats === 'number' &&
154
+ typeof maxRepeats === 'number' &&
155
+ Math.floor(sessionState.stopMessageMaxRepeats) === Math.floor(maxRepeats);
156
+ const isSameInstruction = Boolean(text) && sameText && sameMax;
157
+ nextSessionState.stopMessageText = text || undefined;
158
+ nextSessionState.stopMessageMaxRepeats = maxRepeats;
159
+ if (!isSameInstruction) {
160
+ nextSessionState.stopMessageUsed = 0;
161
+ nextSessionState.stopMessageUpdatedAt =
162
+ typeof routingState.stopMessageUpdatedAt === 'number'
163
+ ? routingState.stopMessageUpdatedAt
164
+ : Date.now();
165
+ nextSessionState.stopMessageLastUsedAt = undefined;
166
+ shouldPersistSessionState = true;
167
+ }
168
+ }
169
+ if (shouldPersistSessionState) {
170
+ this.routingInstructionState.set(sessionScope, nextSessionState);
171
+ this.persistRoutingInstructionState(sessionScope, nextSessionState);
172
+ }
173
+ else {
174
+ nextSessionState = sessionState;
175
+ }
176
+ // 日志展示使用 session scope 的 stopMessage 状态,避免每次解析重复刷新时间/次数。
177
+ if (typeof nextSessionState.stopMessageText === 'string' ||
178
+ typeof nextSessionState.stopMessageMaxRepeats === 'number') {
179
+ routingState.stopMessageText = nextSessionState.stopMessageText;
180
+ routingState.stopMessageMaxRepeats = nextSessionState.stopMessageMaxRepeats;
181
+ routingState.stopMessageUsed = nextSessionState.stopMessageUsed;
182
+ routingState.stopMessageUpdatedAt = nextSessionState.stopMessageUpdatedAt;
183
+ routingState.stopMessageLastUsedAt = nextSessionState.stopMessageLastUsedAt;
184
+ }
185
+ }
186
+ }
187
+ }
188
+ if (instructions.length === 0 && sessionScope) {
189
+ const sessionState = this.getRoutingInstructionState(sessionScope);
190
+ if (typeof sessionState.stopMessageText === 'string' ||
191
+ typeof sessionState.stopMessageMaxRepeats === 'number') {
192
+ routingState.stopMessageText = sessionState.stopMessageText;
193
+ routingState.stopMessageMaxRepeats = sessionState.stopMessageMaxRepeats;
194
+ routingState.stopMessageUsed = sessionState.stopMessageUsed;
195
+ routingState.stopMessageUpdatedAt = sessionState.stopMessageUpdatedAt;
196
+ routingState.stopMessageLastUsedAt = sessionState.stopMessageLastUsedAt;
197
+ }
86
198
  }
87
199
  const routingMode = this.resolveRoutingMode([...metadataInstructions, ...instructions], routingState);
88
200
  const features = buildRoutingFeatures(request, metadata);
@@ -183,6 +295,44 @@ export class VirtualRouterEngine {
183
295
  }
184
296
  };
185
297
  }
298
+ getStopMessageState(metadata) {
299
+ const sessionScope = this.resolveSessionScope(metadata);
300
+ const sessionState = sessionScope ? this.getRoutingInstructionState(sessionScope) : null;
301
+ const stickyKey = this.resolveStickyKey(metadata);
302
+ const stickyState = stickyKey ? this.getRoutingInstructionState(stickyKey) : null;
303
+ const effectiveState = sessionState && typeof sessionState.stopMessageText === 'string' && sessionState.stopMessageText.trim()
304
+ ? sessionState
305
+ : stickyState;
306
+ if (!effectiveState) {
307
+ return null;
308
+ }
309
+ const text = typeof effectiveState.stopMessageText === 'string' ? effectiveState.stopMessageText.trim() : '';
310
+ const maxRepeats = typeof effectiveState.stopMessageMaxRepeats === 'number' &&
311
+ Number.isFinite(effectiveState.stopMessageMaxRepeats)
312
+ ? Math.max(1, Math.floor(effectiveState.stopMessageMaxRepeats))
313
+ : 0;
314
+ if (!text || maxRepeats <= 0) {
315
+ return null;
316
+ }
317
+ return {
318
+ stopMessageText: text,
319
+ stopMessageMaxRepeats: maxRepeats,
320
+ ...(typeof effectiveState.stopMessageSource === 'string' && effectiveState.stopMessageSource.trim()
321
+ ? { stopMessageSource: effectiveState.stopMessageSource.trim() }
322
+ : {}),
323
+ ...(typeof effectiveState.stopMessageUsed === 'number' && Number.isFinite(effectiveState.stopMessageUsed)
324
+ ? { stopMessageUsed: Math.max(0, Math.floor(effectiveState.stopMessageUsed)) }
325
+ : {}),
326
+ ...(typeof effectiveState.stopMessageUpdatedAt === 'number' &&
327
+ Number.isFinite(effectiveState.stopMessageUpdatedAt)
328
+ ? { stopMessageUpdatedAt: effectiveState.stopMessageUpdatedAt }
329
+ : {}),
330
+ ...(typeof effectiveState.stopMessageLastUsedAt === 'number' &&
331
+ Number.isFinite(effectiveState.stopMessageLastUsedAt)
332
+ ? { stopMessageLastUsedAt: effectiveState.stopMessageLastUsedAt }
333
+ : {})
334
+ };
335
+ }
186
336
  handleProviderFailure(event) {
187
337
  handleProviderFailureImpl(event, this.healthManager, this.providerHealthConfig(), (key, ttl) => this.markProviderCooldown(key, ttl));
188
338
  }
@@ -195,6 +345,12 @@ export class VirtualRouterEngine {
195
345
  // ignore persistence errors
196
346
  }
197
347
  }
348
+ // 当 Host 注入 quotaView 时,VirtualRouter 的入池/优先级决策应以 quota 为准;
349
+ // 此时不再在 engine-health 内部进行 429/backoff/series cooldown 等健康决策,
350
+ // 以避免与 daemon/quota-center 的长期熔断策略重复维护并导致日志噪声。
351
+ if (this.quotaView) {
352
+ return;
353
+ }
198
354
  // 配额恢复事件优先处理:一旦识别到 virtualRouterQuotaRecovery,
199
355
  // 直接清理健康状态/冷却 TTL,避免继续走常规错误映射逻辑。
200
356
  const handledByQuota = applyQuotaRecoveryImpl(event, this.healthManager, (key) => this.clearProviderCooldown(key), this.debug);
@@ -278,7 +434,8 @@ export class VirtualRouterEngine {
278
434
  contextAdvisor: this.contextAdvisor,
279
435
  loadBalancer: this.loadBalancer,
280
436
  isProviderCoolingDown: (key) => this.isProviderCoolingDown(key),
281
- resolveStickyKey: (m) => this.resolveStickyKey(m)
437
+ resolveStickyKey: (m) => this.resolveStickyKey(m),
438
+ quotaView: this.quotaView
282
439
  }, { routingState });
283
440
  }
284
441
  incrementRouteStat(routeName, providerKey) {
@@ -327,8 +484,34 @@ export class VirtualRouterEngine {
327
484
  }
328
485
  getRoutingInstructionState(stickyKey) {
329
486
  const key = stickyKey || 'default';
330
- if (this.routingInstructionState.has(key)) {
331
- return this.routingInstructionState.get(key);
487
+ const existing = this.routingInstructionState.get(key);
488
+ // 对 session:/conversation: 作用域,在每次读取时尝试从磁盘刷新 stopMessage 相关字段,
489
+ // 确保 servertool(如 stop_message_auto)通过 sticky-session-store 更新的使用次数
490
+ // 能在 VirtualRouter 日志中实时反映出来。
491
+ if (existing && (key.startsWith('session:') || key.startsWith('conversation:'))) {
492
+ try {
493
+ const persisted = loadRoutingInstructionStateSync(key);
494
+ if (persisted) {
495
+ // 以持久化状态为准(包括清空后的 undefined),避免 stopMessage 状态“卡死”在内存中。
496
+ existing.stopMessageText = persisted.stopMessageText;
497
+ existing.stopMessageMaxRepeats = persisted.stopMessageMaxRepeats;
498
+ existing.stopMessageUsed = persisted.stopMessageUsed;
499
+ existing.stopMessageUpdatedAt = persisted.stopMessageUpdatedAt;
500
+ existing.stopMessageLastUsedAt = persisted.stopMessageLastUsedAt;
501
+ }
502
+ else {
503
+ // 文件被删除或无法解析时,将内存中的 stopMessage 状态一并清空。
504
+ existing.stopMessageText = undefined;
505
+ existing.stopMessageMaxRepeats = undefined;
506
+ existing.stopMessageUsed = undefined;
507
+ existing.stopMessageUpdatedAt = undefined;
508
+ existing.stopMessageLastUsedAt = undefined;
509
+ }
510
+ }
511
+ catch {
512
+ // 刷新失败不影响原有内存状态
513
+ }
514
+ return existing;
332
515
  }
333
516
  let initial = null;
334
517
  // 仅对 session:/conversation: 作用域的 key 尝试从磁盘恢复持久化状态
@@ -28,6 +28,12 @@ export interface RoutingInstructionState {
28
28
  disabledProviders: Set<string>;
29
29
  disabledKeys: Map<string, Set<string | number>>;
30
30
  disabledModels: Map<string, Set<string>>;
31
+ /**
32
+ * Source of the current stopMessage configuration.
33
+ * - 'explicit':由用户通过 <** stopMessage:"..." **> 指令显式设置
34
+ * - 'auto':由系统基于空响应/错误自动推导(例如 Gemini 空回复)
35
+ */
36
+ stopMessageSource?: string;
31
37
  stopMessageText?: string;
32
38
  stopMessageMaxRepeats?: number;
33
39
  stopMessageUsed?: number;
@@ -398,11 +398,19 @@ export function applyRoutingInstructions(instructions, currentState) {
398
398
  ? Math.floor(instruction.stopMessageMaxRepeats)
399
399
  : 0;
400
400
  if (text && maxRepeats > 0) {
401
+ const sameText = typeof newState.stopMessageText === 'string' &&
402
+ newState.stopMessageText.trim() === text;
403
+ const sameMax = typeof newState.stopMessageMaxRepeats === 'number' &&
404
+ Math.floor(newState.stopMessageMaxRepeats) === maxRepeats;
405
+ const isSameInstruction = sameText && sameMax;
401
406
  newState.stopMessageText = text;
402
407
  newState.stopMessageMaxRepeats = maxRepeats;
403
- newState.stopMessageUsed = 0;
404
- newState.stopMessageUpdatedAt = Date.now();
405
- newState.stopMessageLastUsedAt = undefined;
408
+ newState.stopMessageSource = 'explicit';
409
+ if (!isSameInstruction) {
410
+ newState.stopMessageUsed = 0;
411
+ newState.stopMessageUpdatedAt = Date.now();
412
+ newState.stopMessageLastUsedAt = undefined;
413
+ }
406
414
  }
407
415
  break;
408
416
  }
@@ -410,6 +418,7 @@ export function applyRoutingInstructions(instructions, currentState) {
410
418
  newState.stopMessageText = undefined;
411
419
  newState.stopMessageMaxRepeats = undefined;
412
420
  newState.stopMessageUsed = undefined;
421
+ newState.stopMessageSource = undefined;
413
422
  newState.stopMessageUpdatedAt = undefined;
414
423
  newState.stopMessageLastUsedAt = undefined;
415
424
  break;
@@ -453,6 +462,9 @@ export function serializeRoutingInstructionState(state) {
453
462
  provider,
454
463
  models: Array.from(models)
455
464
  })),
465
+ ...(typeof state.stopMessageSource === 'string' && state.stopMessageSource.trim()
466
+ ? { stopMessageSource: state.stopMessageSource }
467
+ : {}),
456
468
  ...(typeof state.stopMessageText === 'string' && state.stopMessageText.trim()
457
469
  ? { stopMessageText: state.stopMessageText }
458
470
  : {}),
@@ -508,6 +520,9 @@ export function deserializeRoutingInstructionState(data) {
508
520
  }
509
521
  }
510
522
  }
523
+ if (typeof data.stopMessageSource === 'string' && data.stopMessageSource.trim()) {
524
+ state.stopMessageSource = data.stopMessageSource.trim();
525
+ }
511
526
  if (typeof data.stopMessageText === 'string' && data.stopMessageText.trim()) {
512
527
  state.stopMessageText = data.stopMessageText;
513
528
  }
@@ -1,3 +1,4 @@
1
1
  import type { RoutingInstructionState } from './routing-instructions.js';
2
2
  export declare function loadRoutingInstructionStateSync(key: string | undefined): RoutingInstructionState | null;
3
3
  export declare function saveRoutingInstructionStateAsync(key: string | undefined, state: RoutingInstructionState | null): void;
4
+ export declare function saveRoutingInstructionStateSync(key: string | undefined, state: RoutingInstructionState | null): void;
@@ -108,3 +108,39 @@ export function saveRoutingInstructionStateAsync(key, state) {
108
108
  // ignore sync write failures
109
109
  }
110
110
  }
111
+ export function saveRoutingInstructionStateSync(key, state) {
112
+ if (!isPersistentKey(key)) {
113
+ return;
114
+ }
115
+ const dir = resolveSessionDir();
116
+ const filename = keyToFilename(key);
117
+ if (!dir || !filename) {
118
+ return;
119
+ }
120
+ const filepath = path.join(dir, filename);
121
+ if (!state) {
122
+ try {
123
+ fs.unlinkSync(filepath);
124
+ }
125
+ catch {
126
+ // ignore unlink failures
127
+ }
128
+ return;
129
+ }
130
+ const payload = {
131
+ version: 1,
132
+ state: serializeRoutingInstructionState(state)
133
+ };
134
+ try {
135
+ fs.mkdirSync(dir, { recursive: true });
136
+ }
137
+ catch {
138
+ // ignore mkdir errors
139
+ }
140
+ try {
141
+ fs.writeFileSync(filepath, JSON.stringify(payload), { encoding: 'utf8' });
142
+ }
143
+ catch {
144
+ // ignore sync write failures
145
+ }
146
+ }
@@ -297,6 +297,19 @@ export interface RoutingDiagnostics {
297
297
  poolId?: string;
298
298
  confidence: number;
299
299
  }
300
+ export interface StopMessageStateSnapshot {
301
+ stopMessageText: string;
302
+ stopMessageMaxRepeats: number;
303
+ /**
304
+ * stopMessage 来源:
305
+ * - 'explicit':来自用户显式指令
306
+ * - 'auto':系统基于空响应/错误自动推导
307
+ */
308
+ stopMessageSource?: string;
309
+ stopMessageUsed?: number;
310
+ stopMessageUpdatedAt?: number;
311
+ stopMessageLastUsedAt?: number;
312
+ }
300
313
  export interface RoutingStatusSnapshot {
301
314
  routes: Record<string, {
302
315
  providers: string[];
@@ -373,3 +386,12 @@ export interface VirtualRouterHealthStore {
373
386
  */
374
387
  recordProviderError?(event: ProviderErrorEvent): void;
375
388
  }
389
+ export interface ProviderQuotaViewEntry {
390
+ providerKey: string;
391
+ inPool: boolean;
392
+ reason?: string;
393
+ priorityTier?: number;
394
+ cooldownUntil?: number | null;
395
+ blacklistUntil?: number | null;
396
+ }
397
+ export type ProviderQuotaView = (providerKey: string) => ProviderQuotaViewEntry | null;