@zqagent/core 0.3.12 → 0.3.13

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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-BSciNywD.cjs';
2
- export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-BSciNywD.cjs';
1
+ import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-CMGdcSdp.cjs';
2
+ export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-CMGdcSdp.cjs';
3
3
  import { T as TokenUsage, M as Message, R as ReasoningEffort } from './types-BYyXWWPW.cjs';
4
4
  export { A as ATTACHMENT_DIR, d as AssistantTurn, e as AttachmentError, f as MAX_ATTACHMENTS, g as MAX_ATTACHMENT_BYTES, b as MessageAttachment, c as StoredAttachment, S as StreamChunk, h as ToolCall, a as ToolSchema, U as UPLOAD_DIR, W as WorkspaceFileRef, i as attachmentBytes, j as buildWorkspaceFileNotice, k as hasNonImageAttachments, n as normalizeAttachments, r as readStoredAttachment, s as saveAttachments, l as saveAttachmentsToWorkspace, m as splitByCapability, o as stripAttachments } from './types-BYyXWWPW.cjs';
5
5
  import { T as ToolRegistry } from './ToolRegistry-DouDvn9E.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-BU4R7q_0.js';
2
- export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-BU4R7q_0.js';
1
+ import { M as Mode, S as ShellPolicy, E as EngineHook, C as CompactionStartInfo, a as CompactionDoneInfo, b as EventType, c as EngineErrorInfo, P as ProviderClient, T as TurnEngine } from './TurnEngine-BZjUGic_.js';
2
+ export { A as ApprovalOutcome, d as Approver, e as CompactionTrigger, D as Decision, O as OpenAIProvider, f as PermissionEngine, g as PermissionRequest, h as ShellSandboxStatus, i as TurnEngineOpts, W as WsEvent } from './TurnEngine-BZjUGic_.js';
3
3
  import { T as TokenUsage, M as Message, R as ReasoningEffort } from './types-BYyXWWPW.js';
4
4
  export { A as ATTACHMENT_DIR, d as AssistantTurn, e as AttachmentError, f as MAX_ATTACHMENTS, g as MAX_ATTACHMENT_BYTES, b as MessageAttachment, c as StoredAttachment, S as StreamChunk, h as ToolCall, a as ToolSchema, U as UPLOAD_DIR, W as WorkspaceFileRef, i as attachmentBytes, j as buildWorkspaceFileNotice, k as hasNonImageAttachments, n as normalizeAttachments, r as readStoredAttachment, s as saveAttachments, l as saveAttachmentsToWorkspace, m as splitByCapability, o as stripAttachments } from './types-BYyXWWPW.js';
5
5
  import { T as ToolRegistry } from './ToolRegistry-Cy0fQxrb.js';
package/dist/index.js CHANGED
@@ -4502,9 +4502,30 @@ var ResponsesApiError = class extends Error {
4502
4502
  };
4503
4503
  var NO_AUTH_KEY = "not-needed";
4504
4504
  var degradedModes = /* @__PURE__ */ new Map();
4505
+ var DEGRADED_TTL_MS = 30 * 6e4;
4506
+ var DEGRADED_MAX = 500;
4505
4507
  function modeKey(baseURL, model) {
4506
4508
  return `${baseURL}::${model}`;
4507
4509
  }
4510
+ function isDegraded(baseURL, model) {
4511
+ const k = modeKey(baseURL, model);
4512
+ const hit = degradedModes.get(k);
4513
+ if (!hit) return false;
4514
+ if (Date.now() - hit.at > DEGRADED_TTL_MS) {
4515
+ degradedModes.delete(k);
4516
+ return false;
4517
+ }
4518
+ return true;
4519
+ }
4520
+ function markDegraded(baseURL, model) {
4521
+ degradedModes.delete(modeKey(baseURL, model));
4522
+ degradedModes.set(modeKey(baseURL, model), { at: Date.now() });
4523
+ while (degradedModes.size > DEGRADED_MAX) {
4524
+ const oldest = degradedModes.keys().next();
4525
+ if (oldest.done) break;
4526
+ degradedModes.delete(oldest.value);
4527
+ }
4528
+ }
4508
4529
  var OpenAIProvider = class {
4509
4530
  /** OpenAI SDK 客户端 */
4510
4531
  client;
@@ -4559,11 +4580,11 @@ var OpenAIProvider = class {
4559
4580
  */
4560
4581
  _resolveMode(model) {
4561
4582
  if (this._apiMode !== "auto") return this._apiMode;
4562
- return degradedModes.get(modeKey(this._baseURL, model)) ?? "responses";
4583
+ return isDegraded(this._baseURL, model) ? "chat" : "responses";
4563
4584
  }
4564
4585
  /** 记录「该端点+模型不支持 Responses」,后续同进程内的请求直走 Chat */
4565
4586
  _markChatMode(model) {
4566
- degradedModes.set(modeKey(this._baseURL, model), "chat");
4587
+ markDegraded(this._baseURL, model);
4567
4588
  }
4568
4589
  /**
4569
4590
  * Responses 失败的分类(决定「能不能改走 Chat Completions」以及要不要缓存降级)。