@umituz/web-ai 1.3.0 → 1.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.
- package/README.md +6 -0
- package/dist/core/index.cjs +46 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +18 -1
- package/dist/core/index.d.ts +18 -1
- package/dist/core/index.js +44 -1
- package/dist/core/index.js.map +1 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +52 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +13 -0
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +6 -1
- package/dist/providers/index.d.ts +6 -1
- package/dist/providers/index.js +13 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -81,6 +81,13 @@ declare const AI_ERROR_STATUS: {
|
|
|
81
81
|
* have the code, not an AiError instance. */
|
|
82
82
|
declare function aiErrorStatus(code: AiErrorCode): number;
|
|
83
83
|
|
|
84
|
+
interface AiFailure {
|
|
85
|
+
readonly code: AiErrorCode;
|
|
86
|
+
readonly status: number;
|
|
87
|
+
readonly message: string;
|
|
88
|
+
}
|
|
89
|
+
declare function aiFailureOf(error: unknown): AiFailure;
|
|
90
|
+
|
|
84
91
|
interface IRequestExecutor<TArgs extends unknown[], TResult> {
|
|
85
92
|
execute(fn: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>;
|
|
86
93
|
}
|
|
@@ -201,6 +208,16 @@ interface DeriveTitleOptions {
|
|
|
201
208
|
*/
|
|
202
209
|
declare function deriveConversationTitle(content: string, options?: DeriveTitleOptions): string;
|
|
203
210
|
|
|
211
|
+
interface AllowanceWindowOptions {
|
|
212
|
+
readonly limit: number;
|
|
213
|
+
readonly windowMs?: number;
|
|
214
|
+
}
|
|
215
|
+
interface AllowanceWindow {
|
|
216
|
+
allow(key: string, now?: number): boolean;
|
|
217
|
+
}
|
|
218
|
+
declare const DEFAULT_ALLOWANCE_WINDOW_MS = 3600000;
|
|
219
|
+
declare function createAllowanceWindow(options: AllowanceWindowOptions): AllowanceWindow;
|
|
220
|
+
|
|
204
221
|
declare function isSseDataLine(line: string): boolean;
|
|
205
222
|
declare function extractSseDataPayload(line: string): string;
|
|
206
223
|
declare function isSseDoneMarker(payload: string): boolean;
|
|
@@ -663,4 +680,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
663
680
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
664
681
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
665
682
|
|
|
666
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, AI_ERROR_STATUS, type AccessCounted, type AccessTimestamped, type AgentContext, AiErrorCode, type ApiKeyValidationRule, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, ChatMessage, type ChunkOptions, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, type DebounceOptions, DedupeExecutor, type DedupeExecutorOptions, type DeriveTitleOptions, type DiffChangeCount, type DiffLine, type EmbeddingsBatchAdapter, type ErrorClassificationRule, type ExponentialBackoffParams, type FailoverErrorLike, type FetchLike, GENERATION_BOUNDS, type GenerationSettings, GroqError, type GroqErrorMetadata, AIErrorType as GroqErrorType, type HttpStatusClassificationRule, type IRequestExecutor, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, type LeadingEdgeParams, type LoggedError, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, type MarkdownSegment, type MemoryLike, type ModelPricing, type ModelWithProvider, type NormalizedSseChunk, type ProjectContext, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, type ResearchSource, type ResearchStreamEvent, RetryExecutor, RetryManager, RetryOptions, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type StuckTaskPlan, type StuckTaskState, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type UsageSeriesDayRow, type UsageSeriesMessageRow, type UsageSeriesPoint, type UsageTrendPoint, type UsageWindowTotals, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorStatus, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorRatePct, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, planStuckRecovery, planTaskFailure, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs };
|
|
683
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, AI_ERROR_STATUS, type AccessCounted, type AccessTimestamped, type AgentContext, AiErrorCode, type AiFailure, type AllowanceWindow, type AllowanceWindowOptions, type ApiKeyValidationRule, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, ChatMessage, type ChunkOptions, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_ALLOWANCE_WINDOW_MS, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, type DebounceOptions, DedupeExecutor, type DedupeExecutorOptions, type DeriveTitleOptions, type DiffChangeCount, type DiffLine, type EmbeddingsBatchAdapter, type ErrorClassificationRule, type ExponentialBackoffParams, type FailoverErrorLike, type FetchLike, GENERATION_BOUNDS, type GenerationSettings, GroqError, type GroqErrorMetadata, AIErrorType as GroqErrorType, type HttpStatusClassificationRule, type IRequestExecutor, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, type LeadingEdgeParams, type LoggedError, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, type MarkdownSegment, type MemoryLike, type ModelPricing, type ModelWithProvider, type NormalizedSseChunk, type ProjectContext, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, type ResearchSource, type ResearchStreamEvent, RetryExecutor, RetryManager, RetryOptions, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type StuckTaskPlan, type StuckTaskState, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type UsageSeriesDayRow, type UsageSeriesMessageRow, type UsageSeriesPoint, type UsageTrendPoint, type UsageWindowTotals, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorStatus, aiFailureOf, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createAllowanceWindow, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorRatePct, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, planStuckRecovery, planTaskFailure, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -81,6 +81,13 @@ declare const AI_ERROR_STATUS: {
|
|
|
81
81
|
* have the code, not an AiError instance. */
|
|
82
82
|
declare function aiErrorStatus(code: AiErrorCode): number;
|
|
83
83
|
|
|
84
|
+
interface AiFailure {
|
|
85
|
+
readonly code: AiErrorCode;
|
|
86
|
+
readonly status: number;
|
|
87
|
+
readonly message: string;
|
|
88
|
+
}
|
|
89
|
+
declare function aiFailureOf(error: unknown): AiFailure;
|
|
90
|
+
|
|
84
91
|
interface IRequestExecutor<TArgs extends unknown[], TResult> {
|
|
85
92
|
execute(fn: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>;
|
|
86
93
|
}
|
|
@@ -201,6 +208,16 @@ interface DeriveTitleOptions {
|
|
|
201
208
|
*/
|
|
202
209
|
declare function deriveConversationTitle(content: string, options?: DeriveTitleOptions): string;
|
|
203
210
|
|
|
211
|
+
interface AllowanceWindowOptions {
|
|
212
|
+
readonly limit: number;
|
|
213
|
+
readonly windowMs?: number;
|
|
214
|
+
}
|
|
215
|
+
interface AllowanceWindow {
|
|
216
|
+
allow(key: string, now?: number): boolean;
|
|
217
|
+
}
|
|
218
|
+
declare const DEFAULT_ALLOWANCE_WINDOW_MS = 3600000;
|
|
219
|
+
declare function createAllowanceWindow(options: AllowanceWindowOptions): AllowanceWindow;
|
|
220
|
+
|
|
204
221
|
declare function isSseDataLine(line: string): boolean;
|
|
205
222
|
declare function extractSseDataPayload(line: string): string;
|
|
206
223
|
declare function isSseDoneMarker(payload: string): boolean;
|
|
@@ -663,4 +680,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
663
680
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
664
681
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
665
682
|
|
|
666
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, AI_ERROR_STATUS, type AccessCounted, type AccessTimestamped, type AgentContext, AiErrorCode, type ApiKeyValidationRule, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, ChatMessage, type ChunkOptions, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, type DebounceOptions, DedupeExecutor, type DedupeExecutorOptions, type DeriveTitleOptions, type DiffChangeCount, type DiffLine, type EmbeddingsBatchAdapter, type ErrorClassificationRule, type ExponentialBackoffParams, type FailoverErrorLike, type FetchLike, GENERATION_BOUNDS, type GenerationSettings, GroqError, type GroqErrorMetadata, AIErrorType as GroqErrorType, type HttpStatusClassificationRule, type IRequestExecutor, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, type LeadingEdgeParams, type LoggedError, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, type MarkdownSegment, type MemoryLike, type ModelPricing, type ModelWithProvider, type NormalizedSseChunk, type ProjectContext, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, type ResearchSource, type ResearchStreamEvent, RetryExecutor, RetryManager, RetryOptions, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type StuckTaskPlan, type StuckTaskState, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type UsageSeriesDayRow, type UsageSeriesMessageRow, type UsageSeriesPoint, type UsageTrendPoint, type UsageWindowTotals, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorStatus, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorRatePct, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, planStuckRecovery, planTaskFailure, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs };
|
|
683
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, AI_ERROR_STATUS, type AccessCounted, type AccessTimestamped, type AgentContext, AiErrorCode, type AiFailure, type AllowanceWindow, type AllowanceWindowOptions, type ApiKeyValidationRule, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, ChatMessage, type ChunkOptions, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_ALLOWANCE_WINDOW_MS, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, type DebounceOptions, DedupeExecutor, type DedupeExecutorOptions, type DeriveTitleOptions, type DiffChangeCount, type DiffLine, type EmbeddingsBatchAdapter, type ErrorClassificationRule, type ExponentialBackoffParams, type FailoverErrorLike, type FetchLike, GENERATION_BOUNDS, type GenerationSettings, GroqError, type GroqErrorMetadata, AIErrorType as GroqErrorType, type HttpStatusClassificationRule, type IRequestExecutor, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, type LeadingEdgeParams, type LoggedError, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, type MarkdownSegment, type MemoryLike, type ModelPricing, type ModelWithProvider, type NormalizedSseChunk, type ProjectContext, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, type ResearchSource, type ResearchStreamEvent, RetryExecutor, RetryManager, RetryOptions, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type StuckTaskPlan, type StuckTaskState, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type UsageSeriesDayRow, type UsageSeriesMessageRow, type UsageSeriesPoint, type UsageTrendPoint, type UsageWindowTotals, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorStatus, aiFailureOf, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createAllowanceWindow, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorRatePct, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, planStuckRecovery, planTaskFailure, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs };
|
package/dist/core/index.js
CHANGED
|
@@ -320,6 +320,31 @@ function aiErrorStatus(code) {
|
|
|
320
320
|
return AI_ERROR_STATUS[code];
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
// src/core/errors/ai-failure.ts
|
|
324
|
+
var TYPE_TO_CODE = {
|
|
325
|
+
["INVALID_API_KEY" /* INVALID_API_KEY */]: "invalid_key",
|
|
326
|
+
["MISSING_CONFIG" /* MISSING_CONFIG */]: "missing_key",
|
|
327
|
+
["NETWORK_ERROR" /* NETWORK_ERROR */]: "network",
|
|
328
|
+
["ABORT_ERROR" /* ABORT_ERROR */]: "timeout",
|
|
329
|
+
["RATE_LIMIT_ERROR" /* RATE_LIMIT_ERROR */]: "rate_limited",
|
|
330
|
+
["SERVER_ERROR" /* SERVER_ERROR */]: "upstream_error",
|
|
331
|
+
["CLIENT_ERROR" /* CLIENT_ERROR */]: "invalid_request",
|
|
332
|
+
["UNKNOWN_ERROR" /* UNKNOWN_ERROR */]: "upstream_error"
|
|
333
|
+
};
|
|
334
|
+
function aiFailureOf(error) {
|
|
335
|
+
if (error instanceof AiError) {
|
|
336
|
+
return { code: error.code, status: AI_ERROR_STATUS[error.code], message: error.userMessage };
|
|
337
|
+
}
|
|
338
|
+
if (error instanceof AIError) {
|
|
339
|
+
const code = TYPE_TO_CODE[error.type];
|
|
340
|
+
return { code, status: AI_ERROR_STATUS[code], message: CODE_MESSAGES[code] };
|
|
341
|
+
}
|
|
342
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
343
|
+
return { code: "timeout", status: AI_ERROR_STATUS.timeout, message: CODE_MESSAGES.timeout };
|
|
344
|
+
}
|
|
345
|
+
return { code: "upstream_error", status: AI_ERROR_STATUS.upstream_error, message: CODE_MESSAGES.upstream_error };
|
|
346
|
+
}
|
|
347
|
+
|
|
323
348
|
// src/core/executor/retry-executor.strategy.ts
|
|
324
349
|
var RetryExecutor = class {
|
|
325
350
|
constructor(retryManager2, options) {
|
|
@@ -933,6 +958,24 @@ function deriveConversationTitle(content, options = {}) {
|
|
|
933
958
|
return cleaned.length > maxChars ? `${cleaned.slice(0, maxChars).trimEnd()}\u2026` : cleaned;
|
|
934
959
|
}
|
|
935
960
|
|
|
961
|
+
// src/core/utils/allowance-window.ts
|
|
962
|
+
var DEFAULT_ALLOWANCE_WINDOW_MS = 36e5;
|
|
963
|
+
function createAllowanceWindow(options) {
|
|
964
|
+
const windowMs = options.windowMs ?? DEFAULT_ALLOWANCE_WINDOW_MS;
|
|
965
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
966
|
+
return {
|
|
967
|
+
allow(key, now = Date.now()) {
|
|
968
|
+
const bucket = buckets.get(key);
|
|
969
|
+
if (bucket === void 0 || now - bucket.windowStart >= windowMs) {
|
|
970
|
+
buckets.set(key, { windowStart: now, count: 1 });
|
|
971
|
+
return true;
|
|
972
|
+
}
|
|
973
|
+
bucket.count += 1;
|
|
974
|
+
return bucket.count <= options.limit;
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
|
|
936
979
|
// src/core/constants/protocol.constants.ts
|
|
937
980
|
var SSE_PREFIX = "data: ";
|
|
938
981
|
var SSE_DONE_MARKER = "[DONE]";
|
|
@@ -2095,6 +2138,6 @@ function createRemoteChatClient(options) {
|
|
|
2095
2138
|
};
|
|
2096
2139
|
}
|
|
2097
2140
|
|
|
2098
|
-
export { AIError, AIErrorType, AI_ERROR_STATUS, AiError, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, CacheManager, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, DedupeExecutor, GENERATION_BOUNDS, GroqError, AIErrorType as GroqErrorType, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, RetryExecutor, RetryManager, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STATUS_TO_CODE, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, StreamingResponseParser, StructuredPromptBuilder, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TEXT_TIERS, TRANSIENT_ERROR_CODES, ThrottleManager, ToolCallAccumulator, USER_FRIENDLY_ERROR_MESSAGES, accumulateReport, aiErrorMessage, aiErrorStatus, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, cacheManager, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createRemoteChatClient, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, errorRatePct, estimateMessageTokens, estimateTokens, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTextTier, isTransientError, isValidApiKey, isWithinWindow, iterateSseData, iterateSseJson, magnitude, mergeTierOverrides, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planStuckRecovery, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, requestDeduplicator, requestQueue, resolveModel, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, retryManager, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs, withRetry };
|
|
2141
|
+
export { AIError, AIErrorType, AI_ERROR_STATUS, AiError, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, CacheManager, CompositeExecutor, DEFAULT_AI_IDENTITY, DEFAULT_ALLOWANCE_WINDOW_MS, DEFAULT_API_KEY_RULE, DEFAULT_EMBED_BATCH_SIZE, DEFAULT_ERROR_CLASSIFICATION_RULE, DEFAULT_GENERATION, DEFAULT_HTTP_STATUS_RULE, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY_MS, DEFAULT_RETRY_JITTER_FACTOR, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_TASK_POLICIES, DebounceManager, DedupeExecutor, GENERATION_BOUNDS, GroqError, AIErrorType as GroqErrorType, JSON_CODE_BLOCK_PATTERN, JSON_OBJECT_PATTERN, JsonResponseParser, MEMORY_MAX_ITEMS, MEMORY_TOTAL_LIMIT, MICROS_PER_UNIT, QueueExecutor, RESEARCH_MAX_OUTPUT_TOKENS, RESEARCH_QUERY_MAX, RESEARCH_QUERY_MIN, RESEARCH_REPORT_MIN_CHARS, RESEARCH_SNIPPET_MAX_CHARS, RESEARCH_TEMPERATURE, RequestDeduplicator, RequestQueue, RetryExecutor, RetryManager, SEARCH_MAX_RESULTS, SSE_BRIDGE_EVENTS, SSE_DONE_MARKER, SSE_PREFIX, STATUS_TO_CODE, STUCK_TASK_THRESHOLD_MS, SYSTEM_PROMPT_VERSION, StreamingResponseParser, StructuredPromptBuilder, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TEXT_TIERS, TRANSIENT_ERROR_CODES, ThrottleManager, ToolCallAccumulator, USER_FRIENDLY_ERROR_MESSAGES, accumulateReport, aiErrorMessage, aiErrorStatus, aiFailureOf, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageDailySeries, buildUsageData, cacheManager, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createAllowanceWindow, createRemoteChatClient, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveConversationTitle, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, errorRatePct, estimateMessageTokens, estimateTokens, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, extractText, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextLike, isTextTier, isTransientError, isValidApiKey, isWithinWindow, iterateSseData, iterateSseJson, magnitude, mergeTierOverrides, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planStuckRecovery, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, requestDeduplicator, requestQueue, resolveModel, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, retryManager, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, usageTrendOf, usageWindowTotals, validateApiKey, validateToolArgs, withRetry };
|
|
2099
2142
|
//# sourceMappingURL=index.js.map
|
|
2100
2143
|
//# sourceMappingURL=index.js.map
|