qlogicagent 0.2.1 → 0.4.0

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 (226) hide show
  1. package/README.md +45 -45
  2. package/package.json +56 -42
  3. package/dist/agent/agent.d.ts +0 -43
  4. package/dist/agent/agent.js +0 -113
  5. package/dist/agent/tool-loop.d.ts +0 -64
  6. package/dist/agent/tool-loop.js +0 -575
  7. package/dist/agent/types.d.ts +0 -175
  8. package/dist/agent/types.js +0 -14
  9. package/dist/cli/main.d.ts +0 -11
  10. package/dist/cli/main.js +0 -23
  11. package/dist/cli/stdio-server.d.ts +0 -45
  12. package/dist/cli/stdio-server.js +0 -463
  13. package/dist/config/config.d.ts +0 -17
  14. package/dist/config/config.js +0 -21
  15. package/dist/contracts/hooks.d.ts +0 -120
  16. package/dist/contracts/hooks.js +0 -7
  17. package/dist/contracts/index.d.ts +0 -10
  18. package/dist/contracts/index.js +0 -10
  19. package/dist/contracts/planner.d.ts +0 -35
  20. package/dist/contracts/planner.js +0 -2
  21. package/dist/contracts/skill-candidate.d.ts +0 -63
  22. package/dist/contracts/skill-candidate.js +0 -195
  23. package/dist/contracts/todo.d.ts +0 -14
  24. package/dist/contracts/todo.js +0 -9
  25. package/dist/index.d.ts +0 -13
  26. package/dist/index.js +0 -15
  27. package/dist/llm/builtin-providers.d.ts +0 -10
  28. package/dist/llm/builtin-providers.js +0 -531
  29. package/dist/llm/index.d.ts +0 -15
  30. package/dist/llm/index.js +0 -14
  31. package/dist/llm/llm-client.d.ts +0 -43
  32. package/dist/llm/llm-client.js +0 -67
  33. package/dist/llm/model-catalog.d.ts +0 -53
  34. package/dist/llm/model-catalog.js +0 -191
  35. package/dist/llm/provider-def.d.ts +0 -59
  36. package/dist/llm/provider-def.js +0 -12
  37. package/dist/llm/provider-registry.d.ts +0 -54
  38. package/dist/llm/provider-registry.js +0 -147
  39. package/dist/llm/transport.d.ts +0 -62
  40. package/dist/llm/transport.js +0 -27
  41. package/dist/llm/transports/anthropic-messages.d.ts +0 -31
  42. package/dist/llm/transports/anthropic-messages.js +0 -293
  43. package/dist/llm/transports/openai-chat.d.ts +0 -36
  44. package/dist/llm/transports/openai-chat.js +0 -165
  45. package/dist/orchestration/agent-registry.d.ts +0 -41
  46. package/dist/orchestration/agent-registry.js +0 -116
  47. package/dist/orchestration/approval-aware-tool-plan.d.ts +0 -32
  48. package/dist/orchestration/approval-aware-tool-plan.js +0 -87
  49. package/dist/orchestration/context-compression.d.ts +0 -220
  50. package/dist/orchestration/context-compression.js +0 -583
  51. package/dist/orchestration/conversation-repair.d.ts +0 -61
  52. package/dist/orchestration/conversation-repair.js +0 -429
  53. package/dist/orchestration/curator-scheduler.d.ts +0 -119
  54. package/dist/orchestration/curator-scheduler.js +0 -135
  55. package/dist/orchestration/embedded-failover-policy.d.ts +0 -110
  56. package/dist/orchestration/embedded-failover-policy.js +0 -168
  57. package/dist/orchestration/error-classification.d.ts +0 -12
  58. package/dist/orchestration/error-classification.js +0 -77
  59. package/dist/orchestration/failover-classification.d.ts +0 -8
  60. package/dist/orchestration/failover-classification.js +0 -381
  61. package/dist/orchestration/failover-error.d.ts +0 -33
  62. package/dist/orchestration/failover-error.js +0 -198
  63. package/dist/orchestration/fork-subagent.d.ts +0 -100
  64. package/dist/orchestration/fork-subagent.js +0 -98
  65. package/dist/orchestration/index.d.ts +0 -120
  66. package/dist/orchestration/index.js +0 -267
  67. package/dist/orchestration/memory-flush-policy.d.ts +0 -57
  68. package/dist/orchestration/memory-flush-policy.js +0 -85
  69. package/dist/orchestration/memory-provider.d.ts +0 -14
  70. package/dist/orchestration/memory-provider.js +0 -2
  71. package/dist/orchestration/parallel-tool-calls.d.ts +0 -41
  72. package/dist/orchestration/parallel-tool-calls.js +0 -59
  73. package/dist/orchestration/prompt-cache-strategy.d.ts +0 -126
  74. package/dist/orchestration/prompt-cache-strategy.js +0 -228
  75. package/dist/orchestration/reactive-compact.d.ts +0 -73
  76. package/dist/orchestration/reactive-compact.js +0 -78
  77. package/dist/orchestration/retry-loop.d.ts +0 -22
  78. package/dist/orchestration/retry-loop.js +0 -24
  79. package/dist/orchestration/skill-candidate.d.ts +0 -52
  80. package/dist/orchestration/skill-candidate.js +0 -141
  81. package/dist/orchestration/skill-consolidation.d.ts +0 -123
  82. package/dist/orchestration/skill-consolidation.js +0 -220
  83. package/dist/orchestration/skill-improvement.d.ts +0 -59
  84. package/dist/orchestration/skill-improvement.js +0 -66
  85. package/dist/orchestration/skill-similarity.d.ts +0 -98
  86. package/dist/orchestration/skill-similarity.js +0 -131
  87. package/dist/orchestration/streaming-tool-executor.d.ts +0 -73
  88. package/dist/orchestration/streaming-tool-executor.js +0 -96
  89. package/dist/orchestration/team-orchestration.d.ts +0 -195
  90. package/dist/orchestration/team-orchestration.js +0 -369
  91. package/dist/orchestration/team-tool-loop-wiring.d.ts +0 -92
  92. package/dist/orchestration/team-tool-loop-wiring.js +0 -147
  93. package/dist/orchestration/tool-choice-policy.d.ts +0 -54
  94. package/dist/orchestration/tool-choice-policy.js +0 -164
  95. package/dist/orchestration/tool-loop-state.d.ts +0 -50
  96. package/dist/orchestration/tool-loop-state.js +0 -133
  97. package/dist/orchestration/tool-schema.d.ts +0 -39
  98. package/dist/orchestration/tool-schema.js +0 -297
  99. package/dist/orchestration/transcript-repair.d.ts +0 -42
  100. package/dist/orchestration/transcript-repair.js +0 -426
  101. package/dist/orchestration/turn-loop-guard.d.ts +0 -86
  102. package/dist/orchestration/turn-loop-guard.js +0 -92
  103. package/dist/orchestration/web-browser-policy.d.ts +0 -17
  104. package/dist/orchestration/web-browser-policy.js +0 -39
  105. package/dist/runtime/context-compression.d.ts +0 -61
  106. package/dist/runtime/context-compression.js +0 -274
  107. package/dist/runtime/hook-registry.d.ts +0 -12
  108. package/dist/runtime/hook-registry.js +0 -53
  109. package/dist/runtime/memory-hooks.d.ts +0 -23
  110. package/dist/runtime/memory-hooks.js +0 -65
  111. package/dist/runtime/tool-eligibility.d.ts +0 -59
  112. package/dist/runtime/tool-eligibility.js +0 -111
  113. package/dist/skills/index.d.ts +0 -108
  114. package/dist/skills/index.js +0 -82
  115. package/dist/skills/memory-extractor.d.ts +0 -64
  116. package/dist/skills/memory-extractor.js +0 -173
  117. package/dist/skills/memory-query-tool.d.ts +0 -43
  118. package/dist/skills/memory-query-tool.js +0 -127
  119. package/dist/skills/memory-store.d.ts +0 -66
  120. package/dist/skills/memory-store.js +0 -228
  121. package/dist/skills/memory-tool.d.ts +0 -67
  122. package/dist/skills/memory-tool.js +0 -192
  123. package/dist/skills/portable-tool.d.ts +0 -71
  124. package/dist/skills/portable-tool.js +0 -14
  125. package/dist/skills/qmemory-adapter.d.ts +0 -52
  126. package/dist/skills/qmemory-adapter.js +0 -165
  127. package/dist/skills/skill-frontmatter.d.ts +0 -19
  128. package/dist/skills/skill-frontmatter.js +0 -344
  129. package/dist/skills/skill-guard.d.ts +0 -23
  130. package/dist/skills/skill-guard.js +0 -229
  131. package/dist/skills/skill-loader.d.ts +0 -16
  132. package/dist/skills/skill-loader.js +0 -303
  133. package/dist/skills/skill-source.d.ts +0 -119
  134. package/dist/skills/skill-source.js +0 -126
  135. package/dist/skills/skill-types.d.ts +0 -199
  136. package/dist/skills/skill-types.js +0 -6
  137. package/dist/skills/think-tool.d.ts +0 -16
  138. package/dist/skills/think-tool.js +0 -59
  139. package/dist/skills/todo-tool.d.ts +0 -63
  140. package/dist/skills/todo-tool.js +0 -114
  141. package/dist/skills/tools/agent-tool.d.ts +0 -91
  142. package/dist/skills/tools/agent-tool.js +0 -142
  143. package/dist/skills/tools/apply-patch-tool.d.ts +0 -29
  144. package/dist/skills/tools/apply-patch-tool.js +0 -184
  145. package/dist/skills/tools/ask-user-tool.d.ts +0 -80
  146. package/dist/skills/tools/ask-user-tool.js +0 -121
  147. package/dist/skills/tools/brief-tool.d.ts +0 -74
  148. package/dist/skills/tools/brief-tool.js +0 -95
  149. package/dist/skills/tools/browser-tool.d.ts +0 -114
  150. package/dist/skills/tools/browser-tool.js +0 -155
  151. package/dist/skills/tools/checkpoint-tool.d.ts +0 -66
  152. package/dist/skills/tools/checkpoint-tool.js +0 -102
  153. package/dist/skills/tools/config-tool.d.ts +0 -63
  154. package/dist/skills/tools/config-tool.js +0 -143
  155. package/dist/skills/tools/cron-tool.d.ts +0 -116
  156. package/dist/skills/tools/cron-tool.js +0 -175
  157. package/dist/skills/tools/edit-tool.d.ts +0 -43
  158. package/dist/skills/tools/edit-tool.js +0 -70
  159. package/dist/skills/tools/exec-tool.d.ts +0 -102
  160. package/dist/skills/tools/exec-tool.js +0 -133
  161. package/dist/skills/tools/image-generate-tool.d.ts +0 -62
  162. package/dist/skills/tools/image-generate-tool.js +0 -67
  163. package/dist/skills/tools/instructions-tool.d.ts +0 -103
  164. package/dist/skills/tools/instructions-tool.js +0 -187
  165. package/dist/skills/tools/lsp-tool.d.ts +0 -153
  166. package/dist/skills/tools/lsp-tool.js +0 -227
  167. package/dist/skills/tools/mcp-client-types.d.ts +0 -269
  168. package/dist/skills/tools/mcp-client-types.js +0 -53
  169. package/dist/skills/tools/mcp-tool.d.ts +0 -249
  170. package/dist/skills/tools/mcp-tool.js +0 -503
  171. package/dist/skills/tools/memory-tool.d.ts +0 -74
  172. package/dist/skills/tools/memory-tool.js +0 -88
  173. package/dist/skills/tools/monitor-tool.d.ts +0 -113
  174. package/dist/skills/tools/monitor-tool.js +0 -131
  175. package/dist/skills/tools/music-generate-tool.d.ts +0 -55
  176. package/dist/skills/tools/music-generate-tool.js +0 -62
  177. package/dist/skills/tools/notify-tool.d.ts +0 -53
  178. package/dist/skills/tools/notify-tool.js +0 -62
  179. package/dist/skills/tools/patch-tool.d.ts +0 -45
  180. package/dist/skills/tools/patch-tool.js +0 -505
  181. package/dist/skills/tools/pdf-tool.d.ts +0 -66
  182. package/dist/skills/tools/pdf-tool.js +0 -88
  183. package/dist/skills/tools/plan-mode-tool.d.ts +0 -59
  184. package/dist/skills/tools/plan-mode-tool.js +0 -122
  185. package/dist/skills/tools/read-tool.d.ts +0 -51
  186. package/dist/skills/tools/read-tool.js +0 -84
  187. package/dist/skills/tools/repl-tool.d.ts +0 -70
  188. package/dist/skills/tools/repl-tool.js +0 -69
  189. package/dist/skills/tools/search-tool.d.ts +0 -112
  190. package/dist/skills/tools/search-tool.js +0 -225
  191. package/dist/skills/tools/send-message-tool.d.ts +0 -51
  192. package/dist/skills/tools/send-message-tool.js +0 -76
  193. package/dist/skills/tools/skill-list-tool.d.ts +0 -33
  194. package/dist/skills/tools/skill-list-tool.js +0 -54
  195. package/dist/skills/tools/skill-manage-tool.d.ts +0 -73
  196. package/dist/skills/tools/skill-manage-tool.js +0 -153
  197. package/dist/skills/tools/skill-view-tool.d.ts +0 -37
  198. package/dist/skills/tools/skill-view-tool.js +0 -72
  199. package/dist/skills/tools/sleep-tool.d.ts +0 -49
  200. package/dist/skills/tools/sleep-tool.js +0 -81
  201. package/dist/skills/tools/structured-output-tool.d.ts +0 -116
  202. package/dist/skills/tools/structured-output-tool.js +0 -176
  203. package/dist/skills/tools/task-tool.d.ts +0 -104
  204. package/dist/skills/tools/task-tool.js +0 -161
  205. package/dist/skills/tools/team-tool.d.ts +0 -89
  206. package/dist/skills/tools/team-tool.js +0 -105
  207. package/dist/skills/tools/tool-search-tool.d.ts +0 -51
  208. package/dist/skills/tools/tool-search-tool.js +0 -110
  209. package/dist/skills/tools/tts-tool.d.ts +0 -38
  210. package/dist/skills/tools/tts-tool.js +0 -45
  211. package/dist/skills/tools/video-edit-tool.d.ts +0 -69
  212. package/dist/skills/tools/video-edit-tool.js +0 -74
  213. package/dist/skills/tools/video-generate-tool.d.ts +0 -62
  214. package/dist/skills/tools/video-generate-tool.js +0 -66
  215. package/dist/skills/tools/video-merge-tool.d.ts +0 -105
  216. package/dist/skills/tools/video-merge-tool.js +0 -92
  217. package/dist/skills/tools/video-upscale-tool.d.ts +0 -45
  218. package/dist/skills/tools/video-upscale-tool.js +0 -52
  219. package/dist/skills/tools/web-fetch-tool.d.ts +0 -78
  220. package/dist/skills/tools/web-fetch-tool.js +0 -92
  221. package/dist/skills/tools/web-search-tool.d.ts +0 -57
  222. package/dist/skills/tools/web-search-tool.js +0 -86
  223. package/dist/skills/tools/worktree-tool.d.ts +0 -69
  224. package/dist/skills/tools/worktree-tool.js +0 -147
  225. package/dist/skills/tools/write-tool.d.ts +0 -45
  226. package/dist/skills/tools/write-tool.js +0 -81
@@ -1,110 +0,0 @@
1
- export type EmbeddedPromptFailureAction<TThinkingLevel extends string = string, TFailoverReason extends string = string> = {
2
- kind: "retry-rotated";
3
- } | {
4
- kind: "retry-thinking";
5
- thinkLevel: TThinkingLevel;
6
- } | {
7
- kind: "throw-failover";
8
- reason: TFailoverReason | null;
9
- } | {
10
- kind: "unhandled";
11
- };
12
- export type EmbeddedAssistantFailureAction<TFailoverReason extends string = string> = {
13
- kind: "retry-rotated";
14
- } | {
15
- kind: "throw-failover";
16
- reason: TFailoverReason | null;
17
- } | {
18
- kind: "unhandled";
19
- };
20
- export type EmbeddedPromptErrorPolicyResolution<TThinkingLevel extends string = string, TFailoverReason extends string = string> = {
21
- kind: "noop";
22
- } | {
23
- kind: "return-error";
24
- errorKind: "role_ordering" | "image_size";
25
- text: string;
26
- message: string;
27
- } | {
28
- kind: "retry-rotated";
29
- } | {
30
- kind: "retry-thinking";
31
- thinkLevel: TThinkingLevel;
32
- } | {
33
- kind: "throw-failover";
34
- reason: TFailoverReason | null;
35
- } | {
36
- kind: "throw-original";
37
- };
38
- export declare function resolveRetryableFailureReason<TReason extends string = string>(params: {
39
- reason: TReason | null | undefined;
40
- nonRetryableReasons?: readonly TReason[];
41
- }): TReason | null;
42
- export declare function resolveAuthProfileFailoverReason<TFailoverReason extends string = string>(params: {
43
- allInCooldown: boolean;
44
- unavailableReason?: TFailoverReason | null;
45
- classifiedReason?: TFailoverReason | null;
46
- cooldownFallbackReason: TFailoverReason;
47
- defaultReason: TFailoverReason;
48
- }): TFailoverReason;
49
- export declare function resolveFallbackThinkingDecision<TThinkingLevel extends string = string>(params: {
50
- aborted: boolean;
51
- fallbackThinking?: TThinkingLevel;
52
- provider: string;
53
- modelId: string;
54
- }): {
55
- thinkLevel: TThinkingLevel;
56
- warningMessage: string;
57
- } | undefined;
58
- export declare function pickFallbackThinkingLevel<TThinkingLevel extends string = string>(params: {
59
- message?: string;
60
- attempted: Set<TThinkingLevel>;
61
- normalizeThinkLevel: (raw: string) => TThinkingLevel | undefined;
62
- offLevel?: TThinkingLevel;
63
- }): TThinkingLevel | undefined;
64
- export declare function shouldAttemptPromptFailureRotation<TFailoverReason extends string = string>(params: {
65
- promptFailoverFailure: boolean;
66
- promptFailoverReason: TFailoverReason | null;
67
- nonRotatableReasons?: readonly TFailoverReason[];
68
- }): boolean;
69
- export declare function shouldAttemptAssistantFailureRotation(params: {
70
- timedOut: boolean;
71
- timedOutDuringCompaction: boolean;
72
- failoverFailure: boolean;
73
- }): boolean;
74
- export declare function resolvePromptFailureActionDecision<TThinkingLevel extends string = string, TFailoverReason extends string = string>(params: {
75
- promptFailoverFailure: boolean;
76
- canRotate: boolean;
77
- fallbackThinking?: TThinkingLevel;
78
- fallbackConfigured: boolean;
79
- promptFailoverReason: TFailoverReason | null;
80
- }): EmbeddedPromptFailureAction<TThinkingLevel, TFailoverReason>;
81
- export declare function resolveAssistantFailureActionDecision<TFailoverReason extends string = string>(params: {
82
- timedOut: boolean;
83
- timedOutDuringCompaction: boolean;
84
- failoverFailure: boolean;
85
- canRotate: boolean;
86
- shouldThrowFailover: boolean;
87
- failoverReason: TFailoverReason | null;
88
- }): EmbeddedAssistantFailureAction<TFailoverReason>;
89
- export declare function resolvePromptErrorPolicy<TThinkingLevel extends string = string, TFailoverReason extends string = string>(params: {
90
- hasPromptError: boolean;
91
- aborted: boolean;
92
- errorText: string;
93
- roleAlternationError: boolean;
94
- imageSizeMaxMb?: number | null;
95
- promptFailureAction: EmbeddedPromptFailureAction<TThinkingLevel, TFailoverReason>;
96
- }): EmbeddedPromptErrorPolicyResolution<TThinkingLevel, TFailoverReason>;
97
- export declare function buildAssistantFailoverErrorDetails(params: {
98
- formattedAssistantErrorText?: string;
99
- assistantErrorMessage?: string;
100
- timedOut: boolean;
101
- rateLimitFailure: boolean;
102
- billingFailureMessage?: string;
103
- authFailure: boolean;
104
- failoverStatus?: number;
105
- timeoutDetectedFromMessage: boolean;
106
- timeoutStatus?: number;
107
- }): {
108
- message: string;
109
- status: number | undefined;
110
- };
@@ -1,168 +0,0 @@
1
- export function resolveRetryableFailureReason(params) {
2
- if (!params.reason) {
3
- return null;
4
- }
5
- if ((params.nonRetryableReasons ?? []).includes(params.reason)) {
6
- return null;
7
- }
8
- return params.reason;
9
- }
10
- export function resolveAuthProfileFailoverReason(params) {
11
- if (params.allInCooldown) {
12
- return params.unavailableReason ?? params.cooldownFallbackReason;
13
- }
14
- return params.classifiedReason ?? params.defaultReason;
15
- }
16
- export function resolveFallbackThinkingDecision(params) {
17
- if (params.aborted || !params.fallbackThinking) {
18
- return undefined;
19
- }
20
- return {
21
- thinkLevel: params.fallbackThinking,
22
- warningMessage: `unsupported thinking level for ${params.provider}/${params.modelId}; ` +
23
- `retrying with ${params.fallbackThinking}`,
24
- };
25
- }
26
- function extractSupportedThinkingValues(raw) {
27
- const match = raw.match(/supported values are:\s*([^\n.]+)/i) ??
28
- raw.match(/supported values:\s*([^\n.]+)/i);
29
- if (!match?.[1]) {
30
- return [];
31
- }
32
- const fragment = match[1];
33
- const quoted = Array.from(fragment.matchAll(/['"]([^'"]+)['"]/g)).map((entry) => entry[1]?.trim());
34
- if (quoted.length > 0) {
35
- return quoted.filter((entry) => Boolean(entry));
36
- }
37
- return fragment
38
- .split(/,|\band\b/gi)
39
- .map((entry) => entry.replace(/^[^a-zA-Z]+|[^a-zA-Z]+$/g, "").trim())
40
- .filter(Boolean);
41
- }
42
- export function pickFallbackThinkingLevel(params) {
43
- const raw = params.message?.trim();
44
- if (!raw) {
45
- return undefined;
46
- }
47
- const supported = extractSupportedThinkingValues(raw);
48
- if (supported.length === 0) {
49
- if (/not supported/i.test(raw) &&
50
- params.offLevel &&
51
- !params.attempted.has(params.offLevel)) {
52
- return params.offLevel;
53
- }
54
- return undefined;
55
- }
56
- for (const entry of supported) {
57
- const normalized = params.normalizeThinkLevel(entry);
58
- if (!normalized || params.attempted.has(normalized)) {
59
- continue;
60
- }
61
- return normalized;
62
- }
63
- return undefined;
64
- }
65
- export function shouldAttemptPromptFailureRotation(params) {
66
- if (!params.promptFailoverFailure) {
67
- return false;
68
- }
69
- return !(params.nonRotatableReasons ?? []).includes(params.promptFailoverReason);
70
- }
71
- export function shouldAttemptAssistantFailureRotation(params) {
72
- return params.failoverFailure || (params.timedOut && !params.timedOutDuringCompaction);
73
- }
74
- export function resolvePromptFailureActionDecision(params) {
75
- if (params.canRotate) {
76
- return { kind: "retry-rotated" };
77
- }
78
- if (params.fallbackThinking) {
79
- return {
80
- kind: "retry-thinking",
81
- thinkLevel: params.fallbackThinking,
82
- };
83
- }
84
- if (params.fallbackConfigured && params.promptFailoverFailure) {
85
- return {
86
- kind: "throw-failover",
87
- reason: params.promptFailoverReason,
88
- };
89
- }
90
- return { kind: "unhandled" };
91
- }
92
- export function resolveAssistantFailureActionDecision(params) {
93
- const shouldRotate = shouldAttemptAssistantFailureRotation({
94
- timedOut: params.timedOut,
95
- timedOutDuringCompaction: params.timedOutDuringCompaction,
96
- failoverFailure: params.failoverFailure,
97
- });
98
- if (!shouldRotate) {
99
- return { kind: "unhandled" };
100
- }
101
- if (params.canRotate) {
102
- return { kind: "retry-rotated" };
103
- }
104
- if (params.shouldThrowFailover) {
105
- return {
106
- kind: "throw-failover",
107
- reason: params.failoverReason,
108
- };
109
- }
110
- return { kind: "unhandled" };
111
- }
112
- export function resolvePromptErrorPolicy(params) {
113
- if (!params.hasPromptError || params.aborted) {
114
- return { kind: "noop" };
115
- }
116
- if (params.roleAlternationError) {
117
- return {
118
- kind: "return-error",
119
- errorKind: "role_ordering",
120
- text: "Message ordering conflict - please try again. " +
121
- "If this persists, use /new to start a fresh session.",
122
- message: params.errorText,
123
- };
124
- }
125
- if (typeof params.imageSizeMaxMb === "number" && Number.isFinite(params.imageSizeMaxMb)) {
126
- const maxBytesHint = ` (max ${params.imageSizeMaxMb}MB)`;
127
- return {
128
- kind: "return-error",
129
- errorKind: "image_size",
130
- text: `Image too large for the model${maxBytesHint}. ` +
131
- "Please compress or resize the image and try again.",
132
- message: params.errorText,
133
- };
134
- }
135
- if (params.promptFailureAction.kind === "retry-rotated") {
136
- return { kind: "retry-rotated" };
137
- }
138
- if (params.promptFailureAction.kind === "retry-thinking") {
139
- return {
140
- kind: "retry-thinking",
141
- thinkLevel: params.promptFailureAction.thinkLevel,
142
- };
143
- }
144
- if (params.promptFailureAction.kind === "throw-failover") {
145
- return {
146
- kind: "throw-failover",
147
- reason: params.promptFailureAction.reason,
148
- };
149
- }
150
- return { kind: "throw-original" };
151
- }
152
- export function buildAssistantFailoverErrorDetails(params) {
153
- const message = params.formattedAssistantErrorText ||
154
- params.assistantErrorMessage?.trim() ||
155
- (params.timedOut
156
- ? "LLM request timed out."
157
- : params.rateLimitFailure
158
- ? "LLM request rate limited."
159
- : params.billingFailureMessage
160
- ? params.billingFailureMessage
161
- : params.authFailure
162
- ? "LLM request unauthorized."
163
- : "LLM request failed.");
164
- return {
165
- message,
166
- status: params.failoverStatus ?? (params.timeoutDetectedFromMessage ? (params.timeoutStatus ?? 408) : undefined),
167
- };
168
- }
@@ -1,12 +0,0 @@
1
- import type { FailoverReason } from "./failover-classification.js";
2
- export type ErrorCategory = "RETRYABLE_TRANSIENT" | "RETRYABLE_DEGRADED" | "NON_RETRYABLE_AUTH" | "NON_RETRYABLE_CONTENT" | "NON_RETRYABLE_QUOTA" | "TOOL_EXECUTION_FAILED";
3
- export interface RetryStrategy {
4
- retryable: boolean;
5
- maxRetries: number;
6
- baseDelayMs: number;
7
- backoffMultiplier: number;
8
- switchProvider: boolean;
9
- }
10
- export declare function classifyError(status: number | undefined, message?: string): ErrorCategory;
11
- export declare function classifyErrorFromReason(reason: FailoverReason): ErrorCategory;
12
- export declare function getRetryStrategy(category: ErrorCategory): RetryStrategy;
@@ -1,77 +0,0 @@
1
- // ============================================================
2
- // Error classification — maps FailoverReason to high-level
3
- // retry categories for consumers that need a simple decision.
4
- // ============================================================
5
- import { classifyFailoverReason, classifyFailoverReasonFromHttpStatus, } from "./failover-classification.js";
6
- const FAILOVER_TO_CATEGORY = {
7
- timeout: "RETRYABLE_TRANSIENT",
8
- overloaded: "RETRYABLE_TRANSIENT",
9
- rate_limit: "RETRYABLE_DEGRADED",
10
- auth: "NON_RETRYABLE_AUTH",
11
- auth_permanent: "NON_RETRYABLE_AUTH",
12
- billing: "NON_RETRYABLE_QUOTA",
13
- format: "NON_RETRYABLE_CONTENT",
14
- model_not_found: "NON_RETRYABLE_CONTENT",
15
- session_expired: "NON_RETRYABLE_CONTENT",
16
- unknown: "RETRYABLE_TRANSIENT",
17
- };
18
- const RETRY_STRATEGIES = {
19
- RETRYABLE_TRANSIENT: {
20
- retryable: true,
21
- maxRetries: 3,
22
- baseDelayMs: 1000,
23
- backoffMultiplier: 2,
24
- switchProvider: true,
25
- },
26
- RETRYABLE_DEGRADED: {
27
- retryable: true,
28
- maxRetries: 2,
29
- baseDelayMs: 5000,
30
- backoffMultiplier: 3,
31
- switchProvider: true,
32
- },
33
- NON_RETRYABLE_AUTH: {
34
- retryable: false,
35
- maxRetries: 0,
36
- baseDelayMs: 0,
37
- backoffMultiplier: 1,
38
- switchProvider: true,
39
- },
40
- NON_RETRYABLE_CONTENT: {
41
- retryable: false,
42
- maxRetries: 0,
43
- baseDelayMs: 0,
44
- backoffMultiplier: 1,
45
- switchProvider: false,
46
- },
47
- NON_RETRYABLE_QUOTA: {
48
- retryable: false,
49
- maxRetries: 0,
50
- baseDelayMs: 0,
51
- backoffMultiplier: 1,
52
- switchProvider: true,
53
- },
54
- TOOL_EXECUTION_FAILED: {
55
- retryable: true,
56
- maxRetries: 1,
57
- baseDelayMs: 500,
58
- backoffMultiplier: 1,
59
- switchProvider: false,
60
- },
61
- };
62
- export function classifyError(status, message) {
63
- const reason = classifyFailoverReasonFromHttpStatus(status, message) ??
64
- (message ? classifyFailoverReason(message) : null);
65
- if (!reason) {
66
- return typeof status === "number" && status >= 400 && status < 500
67
- ? "NON_RETRYABLE_CONTENT"
68
- : "RETRYABLE_TRANSIENT";
69
- }
70
- return FAILOVER_TO_CATEGORY[reason];
71
- }
72
- export function classifyErrorFromReason(reason) {
73
- return FAILOVER_TO_CATEGORY[reason];
74
- }
75
- export function getRetryStrategy(category) {
76
- return RETRY_STRATEGIES[category];
77
- }
@@ -1,8 +0,0 @@
1
- export type FailoverReason = "auth" | "auth_permanent" | "format" | "rate_limit" | "overloaded" | "billing" | "timeout" | "model_not_found" | "session_expired" | "unknown";
2
- export declare function isTimeoutErrorMessage(raw: string): boolean;
3
- export declare function isCloudflareOrHtmlErrorPage(raw: string): boolean;
4
- export declare function isTransientHttpError(raw: string): boolean;
5
- export declare function classifyFailoverReasonFromHttpStatus(status: number | undefined, message?: string): FailoverReason | null;
6
- export declare function isModelNotFoundErrorMessage(raw: string): boolean;
7
- export declare function classifyFailoverReason(raw: string): FailoverReason | null;
8
- export declare function isFailoverErrorMessage(raw: string): boolean;