@umituz/web-ai 1.0.8 → 1.0.9
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/core/index.cjs +84 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +8 -2
- package/dist/core/index.d.ts +8 -2
- package/dist/core/index.js +80 -7
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +86 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +82 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -233,6 +233,12 @@ interface ChunkOptions {
|
|
|
233
233
|
}
|
|
234
234
|
declare function chunkText(text: string, options?: ChunkOptions): string[];
|
|
235
235
|
|
|
236
|
+
declare const TEXT_EXTRACT_PER_FILE_LIMIT = 24000;
|
|
237
|
+
declare const TEXT_EXTRACT_TOTAL_LIMIT = 48000;
|
|
238
|
+
declare function isTextLike(mimeType: string, name: string): boolean;
|
|
239
|
+
declare function extractText(bytes: Uint8Array): string;
|
|
240
|
+
declare function capText(text: string, limit: number): string;
|
|
241
|
+
|
|
236
242
|
interface AccessTimestamped {
|
|
237
243
|
readonly lastAccess: number;
|
|
238
244
|
}
|
|
@@ -476,7 +482,7 @@ interface MemoryLike {
|
|
|
476
482
|
readonly pinned: boolean;
|
|
477
483
|
readonly updatedAt: Date | string | number;
|
|
478
484
|
}
|
|
479
|
-
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number): string[];
|
|
485
|
+
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number, capper?: (text: string, limit: number) => string): string[];
|
|
480
486
|
|
|
481
487
|
declare const RESEARCH_QUERY_MIN = 4;
|
|
482
488
|
declare const RESEARCH_QUERY_MAX = 400;
|
|
@@ -626,4 +632,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
626
632
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
627
633
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
628
634
|
|
|
629
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, type AssistantToolCall, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, ChatMessage, type ChunkOptions, CompositeExecutor, type ContextBudget, type ContextMessage, type ContextRole, 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 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 ParsedSseEvent, type ProjectContext, type ProviderErrorShape, 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, STATUS_TO_CODE, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamCallbacks, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type SystemPromptInput, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, ToolCallAccumulator, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type WireToolCallDelta, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorMessage, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, estimateMessageTokens, estimateTokens, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs };
|
|
635
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, type AssistantToolCall, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, ChatMessage, type ChunkOptions, CompositeExecutor, type ContextBudget, type ContextMessage, type ContextRole, 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 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 ParsedSseEvent, type ProjectContext, type ProviderErrorShape, 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, STATUS_TO_CODE, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamCallbacks, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, ToolCallAccumulator, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type WireToolCallDelta, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorMessage, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, estimateMessageTokens, estimateTokens, 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, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -233,6 +233,12 @@ interface ChunkOptions {
|
|
|
233
233
|
}
|
|
234
234
|
declare function chunkText(text: string, options?: ChunkOptions): string[];
|
|
235
235
|
|
|
236
|
+
declare const TEXT_EXTRACT_PER_FILE_LIMIT = 24000;
|
|
237
|
+
declare const TEXT_EXTRACT_TOTAL_LIMIT = 48000;
|
|
238
|
+
declare function isTextLike(mimeType: string, name: string): boolean;
|
|
239
|
+
declare function extractText(bytes: Uint8Array): string;
|
|
240
|
+
declare function capText(text: string, limit: number): string;
|
|
241
|
+
|
|
236
242
|
interface AccessTimestamped {
|
|
237
243
|
readonly lastAccess: number;
|
|
238
244
|
}
|
|
@@ -476,7 +482,7 @@ interface MemoryLike {
|
|
|
476
482
|
readonly pinned: boolean;
|
|
477
483
|
readonly updatedAt: Date | string | number;
|
|
478
484
|
}
|
|
479
|
-
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number): string[];
|
|
485
|
+
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number, capper?: (text: string, limit: number) => string): string[];
|
|
480
486
|
|
|
481
487
|
declare const RESEARCH_QUERY_MIN = 4;
|
|
482
488
|
declare const RESEARCH_QUERY_MAX = 400;
|
|
@@ -626,4 +632,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
626
632
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
627
633
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
628
634
|
|
|
629
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, type AssistantToolCall, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, ChatMessage, type ChunkOptions, CompositeExecutor, type ContextBudget, type ContextMessage, type ContextRole, 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 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 ParsedSseEvent, type ProjectContext, type ProviderErrorShape, 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, STATUS_TO_CODE, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamCallbacks, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type SystemPromptInput, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, ToolCallAccumulator, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type WireToolCallDelta, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorMessage, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, estimateMessageTokens, estimateTokens, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTransientError, isValidApiKey, isWithinWindow, magnitude, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs };
|
|
635
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, type AssistantToolCall, CHUNK_MAX_CHARS, CHUNK_OVERLAP_CHARS, CHUNK_TEXT_LIMIT, CODE_MESSAGES, ChatMessage, type ChunkOptions, CompositeExecutor, type ContextBudget, type ContextMessage, type ContextRole, 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 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 ParsedSseEvent, type ProjectContext, type ProviderErrorShape, 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, STATUS_TO_CODE, SYSTEM_PROMPT_VERSION, type SearchTopic, type SseDeltaExtractor, type SseResponseOptions, type StreamCallbacks, type StreamEvent, type StreamingParserCallbacks, StreamingResponseParser, StructuredPromptBuilder, type SystemPromptInput, TEXT_EXTRACT_PER_FILE_LIMIT, TEXT_EXTRACT_TOTAL_LIMIT, TRANSIENT_ERROR_CODES, type TaskPlan, type TaskPolicy, type TaskState, ThrottleManager, type ThrottleOptions, TokenUsage, ToolCallAccumulator, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, type WireToolCallDelta, type ZodLikeIssue, type ZodLikeSchema, accumulateReport, aiErrorMessage, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, estimateMessageTokens, estimateTokens, 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, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs };
|
package/dist/core/index.js
CHANGED
|
@@ -1132,6 +1132,83 @@ ${paragraph}`;
|
|
|
1132
1132
|
return chunks.map((chunk) => chunk.length > maxChars ? chunk.slice(0, maxChars) : chunk).filter((chunk) => chunk.length > 0);
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
+
// src/core/parsers/text-extract.ts
|
|
1136
|
+
var TEXT_MIME_PREFIX = "text/";
|
|
1137
|
+
var TEXT_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
1138
|
+
"application/json",
|
|
1139
|
+
"application/xml",
|
|
1140
|
+
"application/yaml",
|
|
1141
|
+
"application/x-yaml",
|
|
1142
|
+
"application/javascript",
|
|
1143
|
+
"application/typescript",
|
|
1144
|
+
"application/x-sh",
|
|
1145
|
+
"application/sql",
|
|
1146
|
+
"text/csv"
|
|
1147
|
+
]);
|
|
1148
|
+
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1149
|
+
"txt",
|
|
1150
|
+
"md",
|
|
1151
|
+
"markdown",
|
|
1152
|
+
"csv",
|
|
1153
|
+
"tsv",
|
|
1154
|
+
"json",
|
|
1155
|
+
"xml",
|
|
1156
|
+
"yaml",
|
|
1157
|
+
"yml",
|
|
1158
|
+
"toml",
|
|
1159
|
+
"ini",
|
|
1160
|
+
"js",
|
|
1161
|
+
"mjs",
|
|
1162
|
+
"cjs",
|
|
1163
|
+
"ts",
|
|
1164
|
+
"tsx",
|
|
1165
|
+
"jsx",
|
|
1166
|
+
"py",
|
|
1167
|
+
"rb",
|
|
1168
|
+
"go",
|
|
1169
|
+
"rs",
|
|
1170
|
+
"java",
|
|
1171
|
+
"kt",
|
|
1172
|
+
"swift",
|
|
1173
|
+
"c",
|
|
1174
|
+
"h",
|
|
1175
|
+
"cpp",
|
|
1176
|
+
"hpp",
|
|
1177
|
+
"cs",
|
|
1178
|
+
"php",
|
|
1179
|
+
"sh",
|
|
1180
|
+
"bash",
|
|
1181
|
+
"zsh",
|
|
1182
|
+
"sql",
|
|
1183
|
+
"html",
|
|
1184
|
+
"css",
|
|
1185
|
+
"scss",
|
|
1186
|
+
"env"
|
|
1187
|
+
]);
|
|
1188
|
+
var TEXT_EXTRACT_PER_FILE_LIMIT = 24e3;
|
|
1189
|
+
var TEXT_EXTRACT_TOTAL_LIMIT = 48e3;
|
|
1190
|
+
function isTextLike(mimeType, name) {
|
|
1191
|
+
if (mimeType.startsWith(TEXT_MIME_PREFIX) || TEXT_MIME_TYPES.has(mimeType)) return true;
|
|
1192
|
+
const extension = name.split(".").pop()?.toLowerCase() ?? "";
|
|
1193
|
+
return TEXT_EXTENSIONS.has(extension);
|
|
1194
|
+
}
|
|
1195
|
+
function extractText(bytes) {
|
|
1196
|
+
let out = "";
|
|
1197
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
1198
|
+
const chunkSize = 65536;
|
|
1199
|
+
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
1200
|
+
out += decoder.decode(bytes.subarray(offset, Math.min(offset + chunkSize, bytes.length)), {
|
|
1201
|
+
stream: offset + chunkSize < bytes.length
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
return out.split("\0").join("");
|
|
1205
|
+
}
|
|
1206
|
+
function capText(text, limit) {
|
|
1207
|
+
if (text.length <= limit) return text;
|
|
1208
|
+
return `${text.slice(0, limit)}
|
|
1209
|
+
[truncated]`;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1135
1212
|
// src/core/calculations/random-base36-suffix.ts
|
|
1136
1213
|
var BASE_36_RADIX = 36;
|
|
1137
1214
|
var DECIMAL_OFFSET = 2;
|
|
@@ -1579,11 +1656,7 @@ function resolveTimestamp(value) {
|
|
|
1579
1656
|
const parsed = Date.parse(value);
|
|
1580
1657
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
1581
1658
|
}
|
|
1582
|
-
function
|
|
1583
|
-
if (str.length <= maxLength) return str;
|
|
1584
|
-
return str.slice(0, Math.max(maxLength, 0));
|
|
1585
|
-
}
|
|
1586
|
-
function selectMemories(rows, maxItems = MEMORY_MAX_ITEMS, totalLimit = MEMORY_TOTAL_LIMIT) {
|
|
1659
|
+
function selectMemories(rows, maxItems = MEMORY_MAX_ITEMS, totalLimit = MEMORY_TOTAL_LIMIT, capper = capText) {
|
|
1587
1660
|
const ordered = [...rows].sort((a, b) => {
|
|
1588
1661
|
if (a.pinned !== b.pinned) return a.pinned ? -1 : 1;
|
|
1589
1662
|
return resolveTimestamp(b.updatedAt) - resolveTimestamp(a.updatedAt);
|
|
@@ -1594,7 +1667,7 @@ function selectMemories(rows, maxItems = MEMORY_MAX_ITEMS, totalLimit = MEMORY_T
|
|
|
1594
1667
|
if (out.length >= maxItems || used >= totalLimit) break;
|
|
1595
1668
|
const content = row.content.trim();
|
|
1596
1669
|
if (content.length === 0) continue;
|
|
1597
|
-
const capped =
|
|
1670
|
+
const capped = capper(content, totalLimit - used);
|
|
1598
1671
|
out.push(capped);
|
|
1599
1672
|
used += capped.length;
|
|
1600
1673
|
}
|
|
@@ -1826,6 +1899,6 @@ function validateToolArgs(toolKey, args, schemas) {
|
|
|
1826
1899
|
return { ok: false, error: `Invalid schema definition for tool: ${toolKey}` };
|
|
1827
1900
|
}
|
|
1828
1901
|
|
|
1829
|
-
export { AIError, AIErrorType, 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, SYSTEM_PROMPT_VERSION, StreamingResponseParser, StructuredPromptBuilder, TEXT_TIERS, TRANSIENT_ERROR_CODES, ThrottleManager, ToolCallAccumulator, USER_FRIENDLY_ERROR_MESSAGES, accumulateReport, aiErrorMessage, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, cacheManager, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, estimateMessageTokens, estimateTokens, extractErrorMessageFromJsonBody, extractErrorMessageFromResponse, extractJsonArray, extractJsonCandidate, extractJsonFromCodeFence, extractJsonObject, extractSseDataPayload, failoverCandidate, findTopKSimilar, formatCost, formatErrorForLogging, formatSseEvent, generateRandomBase36Suffix, isAuthErrorType, isRetryableErrorType, isSseDataLine, isSseDoneMarker, isTextTier, isTransientError, isValidApiKey, isWithinWindow, magnitude, mergeTierOverrides, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, requestDeduplicator, requestQueue, resolveModel, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, retryManager, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs, withRetry };
|
|
1902
|
+
export { AIError, AIErrorType, 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, 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, asObjectArray, asRecord, asStringArray, asTrimmedOptionalString, batchEmbed, buildCacheKey, buildContext, buildHttpStatusFallback, buildResearchMessages, buildSystemPrompt, buildUsageData, cacheManager, calculateCacheHitRate, calculateExponentialBackoff, calculateTrailingDelay, canFailover, canStartTask, capText, chunkText, clampScore, classifyHttpStatus, computeCostMicros, cosineSimilarity, countChanges, createSseResponse, debounce, debounceManager, defaultSseDeltaExtractor, deriveSnippetTitle, describeAIErrorType, diffLines, dotProduct, errorFromStatus, errorFromUnknown, 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, magnitude, mergeTierOverrides, nextAttemptDelayMs, normalizeGenerationSettings, normalizeSources, normalizeSseChunk, oneOfCatalog, parseSseEvent, planTaskFailure, readSseResponse, repairCommonJsonDefects, replayFirst, requestDeduplicator, requestQueue, resolveModel, resolveUserFriendlyErrorMessage, resolveUserFriendlyMessage, retryManager, searchWeb, selectLeastRecentlyUsedKey, selectMemories, shouldCallOnLeadingEdge, splitMarkdown, splitSseLines, sseStreamResponse, throttle, throttleManager, validateApiKey, validateToolArgs, withRetry };
|
|
1830
1903
|
//# sourceMappingURL=index.js.map
|
|
1831
1904
|
//# sourceMappingURL=index.js.map
|