@umituz/web-ai 1.0.8 → 1.0.10
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/{AIErrors-CSk4nvN1.d.ts → AIErrors-TuSFl--T.d.ts} +1 -1
- package/dist/{AIErrors-Dq9o95R_.d.cts → AIErrors-_IyXRWj1.d.cts} +1 -1
- package/dist/{cancellation-error-CpkPd67D.d.cts → cancellation-error-_39nYWwz.d.cts} +3 -3
- package/dist/{cancellation-error-Ci8fQhNF.d.ts → cancellation-error-hYcE9AS9.d.ts} +3 -3
- package/dist/chat/index.d.cts +4 -4
- package/dist/chat/index.d.ts +4 -4
- package/dist/{chat.service-BRtiA7H9.d.cts → chat.service-8MaW9pum.d.cts} +2 -2
- package/dist/{chat.service-Cqga2h1e.d.ts → chat.service-B4Isrckn.d.ts} +2 -2
- package/dist/content/index.d.cts +7 -7
- package/dist/content/index.d.ts +7 -7
- package/dist/core/index.cjs +90 -10
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +14 -27
- package/dist/core/index.d.ts +14 -27
- package/dist/core/index.js +86 -11
- package/dist/core/index.js.map +1 -1
- package/dist/{create-ai-DW7eHMBF.d.ts → create-ai-D-oEWzf9.d.ts} +3 -3
- package/dist/{create-ai-DeOpUgZ-.d.cts → create-ai-DRysRImc.d.cts} +3 -3
- package/dist/hooks/index.d.cts +9 -9
- package/dist/hooks/index.d.ts +9 -9
- package/dist/{index-Ca5o4gBK.d.ts → index-1e91KRYU.d.ts} +1 -1
- package/dist/{index-itgxPeLz.d.cts → index-Dv8gRzAu.d.cts} +1 -1
- package/dist/{index-DDzvTDg0.d.ts → index-OhvYUTXf.d.cts} +1 -2
- package/dist/{index-DDzvTDg0.d.cts → index-OhvYUTXf.d.ts} +1 -2
- package/dist/index.cjs +391 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +385 -13
- package/dist/index.js.map +1 -1
- package/dist/{provider.factory-CJuI08Xr.d.ts → provider.factory-B9RNUTYj.d.ts} +1 -1
- package/dist/{provider.factory-DG2CYFgh.d.cts → provider.factory-Ce6Een1G.d.cts} +1 -1
- package/dist/providers/index.cjs +381 -0
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +61 -11
- package/dist/providers/index.d.ts +61 -11
- package/dist/providers/index.js +380 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/{requestQueue-D-RCbxuR.d.ts → requestQueue-AP6n_bRH.d.ts} +4 -4
- package/dist/{requestQueue-O6f8VBl5.d.cts → requestQueue-D89wx91Q.d.cts} +4 -4
- package/dist/{request-deduplicator.util-NDo0_n1y.d.cts → tool-call-accumulator-C7KhaXZA.d.cts} +20 -1
- package/dist/{request-deduplicator.util-NDo0_n1y.d.ts → tool-call-accumulator-C7KhaXZA.d.ts} +20 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as TokenUsage, C as ChatMessage } from '../index-
|
|
2
|
-
export { F as FinishReason, G as GenerationResult, P as ProviderHealth, S as StructuredGeneration, a as StructuredTextRequest, T as TextRequest, b as TextTier } from '../index-
|
|
3
|
-
import { A as AIError, b as AIErrorType, a as AIErrorMetadata } from '../index-
|
|
4
|
-
export { T as TEXT_TIERS, c as TierModelMap, U as USER_FRIENDLY_ERROR_MESSAGES, i as isTextTier, m as mergeTierOverrides, r as resolveModel } from '../index-
|
|
5
|
-
import { b as RetryManager, c as RetryOptions, a as RequestQueue, R as RequestDeduplicator } from '../
|
|
6
|
-
export { Q as QueueOptions, r as requestDeduplicator, d as requestQueue, e as retryManager, w as withRetry } from '../
|
|
1
|
+
import { c as TokenUsage, C as ChatMessage } from '../index-OhvYUTXf.cjs';
|
|
2
|
+
export { F as FinishReason, G as GenerationResult, P as ProviderHealth, S as StructuredGeneration, a as StructuredTextRequest, T as TextRequest, b as TextTier } from '../index-OhvYUTXf.cjs';
|
|
3
|
+
import { A as AIError, b as AIErrorType, a as AIErrorMetadata } from '../index-Dv8gRzAu.cjs';
|
|
4
|
+
export { T as TEXT_TIERS, c as TierModelMap, U as USER_FRIENDLY_ERROR_MESSAGES, i as isTextTier, m as mergeTierOverrides, r as resolveModel } from '../index-Dv8gRzAu.cjs';
|
|
5
|
+
import { b as RetryManager, c as RetryOptions, a as RequestQueue, R as RequestDeduplicator } from '../tool-call-accumulator-C7KhaXZA.cjs';
|
|
6
|
+
export { A as AssistantToolCall, Q as QueueOptions, T as ToolCallAccumulator, W as WireToolCallDelta, r as requestDeduplicator, d as requestQueue, e as retryManager, w as withRetry } from '../tool-call-accumulator-C7KhaXZA.cjs';
|
|
7
7
|
export { C as CacheManager, a as CacheOptions, b as CacheStats, c as cacheManager } from '../cache-manager-Df9LLYGA.cjs';
|
|
8
8
|
|
|
9
9
|
type GroqErrorMetadata = AIErrorMetadata;
|
|
@@ -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
|
}
|
|
@@ -334,25 +340,6 @@ interface SseResponseOptions {
|
|
|
334
340
|
declare function defaultSseDeltaExtractor(payload: string): string | null;
|
|
335
341
|
declare function createSseResponse(openUpstream: () => Promise<ReadableStream<Uint8Array>>, options: SseResponseOptions): Response;
|
|
336
342
|
|
|
337
|
-
interface WireToolCallDelta {
|
|
338
|
-
readonly index?: number;
|
|
339
|
-
readonly id?: string;
|
|
340
|
-
readonly function?: {
|
|
341
|
-
readonly name?: string;
|
|
342
|
-
readonly arguments?: string;
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
interface AssistantToolCall {
|
|
346
|
-
readonly id: string;
|
|
347
|
-
readonly name: string;
|
|
348
|
-
readonly arguments: string;
|
|
349
|
-
}
|
|
350
|
-
declare class ToolCallAccumulator {
|
|
351
|
-
private readonly slots;
|
|
352
|
-
push(delta: WireToolCallDelta): void;
|
|
353
|
-
finish(): AssistantToolCall[];
|
|
354
|
-
}
|
|
355
|
-
|
|
356
343
|
type ContextRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
357
344
|
interface ContextMessage {
|
|
358
345
|
readonly role: ContextRole;
|
|
@@ -476,7 +463,7 @@ interface MemoryLike {
|
|
|
476
463
|
readonly pinned: boolean;
|
|
477
464
|
readonly updatedAt: Date | string | number;
|
|
478
465
|
}
|
|
479
|
-
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number): string[];
|
|
466
|
+
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number, capper?: (text: string, limit: number) => string): string[];
|
|
480
467
|
|
|
481
468
|
declare const RESEARCH_QUERY_MIN = 4;
|
|
482
469
|
declare const RESEARCH_QUERY_MAX = 400;
|
|
@@ -626,4 +613,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
626
613
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
627
614
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
628
615
|
|
|
629
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule,
|
|
616
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, 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, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, 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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as TokenUsage, C as ChatMessage } from '../index-
|
|
2
|
-
export { F as FinishReason, G as GenerationResult, P as ProviderHealth, S as StructuredGeneration, a as StructuredTextRequest, T as TextRequest, b as TextTier } from '../index-
|
|
3
|
-
import { A as AIError, b as AIErrorType, a as AIErrorMetadata } from '../index-
|
|
4
|
-
export { T as TEXT_TIERS, c as TierModelMap, U as USER_FRIENDLY_ERROR_MESSAGES, i as isTextTier, m as mergeTierOverrides, r as resolveModel } from '../index-
|
|
5
|
-
import { b as RetryManager, c as RetryOptions, a as RequestQueue, R as RequestDeduplicator } from '../
|
|
6
|
-
export { Q as QueueOptions, r as requestDeduplicator, d as requestQueue, e as retryManager, w as withRetry } from '../
|
|
1
|
+
import { c as TokenUsage, C as ChatMessage } from '../index-OhvYUTXf.js';
|
|
2
|
+
export { F as FinishReason, G as GenerationResult, P as ProviderHealth, S as StructuredGeneration, a as StructuredTextRequest, T as TextRequest, b as TextTier } from '../index-OhvYUTXf.js';
|
|
3
|
+
import { A as AIError, b as AIErrorType, a as AIErrorMetadata } from '../index-1e91KRYU.js';
|
|
4
|
+
export { T as TEXT_TIERS, c as TierModelMap, U as USER_FRIENDLY_ERROR_MESSAGES, i as isTextTier, m as mergeTierOverrides, r as resolveModel } from '../index-1e91KRYU.js';
|
|
5
|
+
import { b as RetryManager, c as RetryOptions, a as RequestQueue, R as RequestDeduplicator } from '../tool-call-accumulator-C7KhaXZA.js';
|
|
6
|
+
export { A as AssistantToolCall, Q as QueueOptions, T as ToolCallAccumulator, W as WireToolCallDelta, r as requestDeduplicator, d as requestQueue, e as retryManager, w as withRetry } from '../tool-call-accumulator-C7KhaXZA.js';
|
|
7
7
|
export { C as CacheManager, a as CacheOptions, b as CacheStats, c as cacheManager } from '../cache-manager-Df9LLYGA.js';
|
|
8
8
|
|
|
9
9
|
type GroqErrorMetadata = AIErrorMetadata;
|
|
@@ -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
|
}
|
|
@@ -334,25 +340,6 @@ interface SseResponseOptions {
|
|
|
334
340
|
declare function defaultSseDeltaExtractor(payload: string): string | null;
|
|
335
341
|
declare function createSseResponse(openUpstream: () => Promise<ReadableStream<Uint8Array>>, options: SseResponseOptions): Response;
|
|
336
342
|
|
|
337
|
-
interface WireToolCallDelta {
|
|
338
|
-
readonly index?: number;
|
|
339
|
-
readonly id?: string;
|
|
340
|
-
readonly function?: {
|
|
341
|
-
readonly name?: string;
|
|
342
|
-
readonly arguments?: string;
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
interface AssistantToolCall {
|
|
346
|
-
readonly id: string;
|
|
347
|
-
readonly name: string;
|
|
348
|
-
readonly arguments: string;
|
|
349
|
-
}
|
|
350
|
-
declare class ToolCallAccumulator {
|
|
351
|
-
private readonly slots;
|
|
352
|
-
push(delta: WireToolCallDelta): void;
|
|
353
|
-
finish(): AssistantToolCall[];
|
|
354
|
-
}
|
|
355
|
-
|
|
356
343
|
type ContextRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
357
344
|
interface ContextMessage {
|
|
358
345
|
readonly role: ContextRole;
|
|
@@ -476,7 +463,7 @@ interface MemoryLike {
|
|
|
476
463
|
readonly pinned: boolean;
|
|
477
464
|
readonly updatedAt: Date | string | number;
|
|
478
465
|
}
|
|
479
|
-
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number): string[];
|
|
466
|
+
declare function selectMemories(rows: readonly MemoryLike[], maxItems?: number, totalLimit?: number, capper?: (text: string, limit: number) => string): string[];
|
|
480
467
|
|
|
481
468
|
declare const RESEARCH_QUERY_MIN = 4;
|
|
482
469
|
declare const RESEARCH_QUERY_MAX = 400;
|
|
@@ -626,4 +613,4 @@ declare const DEFAULT_RETRY_MAX_DELAY_MS = 10000;
|
|
|
626
613
|
declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
627
614
|
declare const DEFAULT_RETRY_JITTER_FACTOR = 0.1;
|
|
628
615
|
|
|
629
|
-
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule,
|
|
616
|
+
export { AIError, type AIErrorBody, AIErrorMetadata, AIErrorType, type AccessCounted, type AccessTimestamped, type AgentContext, AiError, type AiErrorCode, type ApiKeyValidationRule, 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, type ToolSchema, type ToolValidationResult, type ToolValidatorFunction, type TrailingDelayParams, type UsageRecordData, type UsageRecordInput, type VectorCandidate, type VectorMatch, type WebSearchInput, type WebSearchResponse, type WebSearchResult, 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;
|
|
@@ -1367,17 +1444,19 @@ function buildSystemPrompt(input = {}) {
|
|
|
1367
1444
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
1368
1445
|
const identity = input.identity ?? DEFAULT_AI_IDENTITY;
|
|
1369
1446
|
const parts = [identity, `Current date: ${now.toISOString().slice(0, 10)}.`];
|
|
1447
|
+
const projectName = input.project?.name;
|
|
1370
1448
|
const projectInstructions = input.project?.instructions?.trim();
|
|
1371
|
-
if (projectInstructions) {
|
|
1449
|
+
if (projectName && projectInstructions) {
|
|
1372
1450
|
parts.push(
|
|
1373
|
-
`The user is working inside the project "${
|
|
1451
|
+
`The user is working inside the project "${projectName}". Follow these project instructions:
|
|
1374
1452
|
${projectInstructions}`
|
|
1375
1453
|
);
|
|
1376
1454
|
}
|
|
1455
|
+
const agentName = input.agent?.name;
|
|
1377
1456
|
const agentInstructions = input.agent?.instructions?.trim();
|
|
1378
|
-
if (agentInstructions) {
|
|
1457
|
+
if (agentName && agentInstructions) {
|
|
1379
1458
|
parts.push(
|
|
1380
|
-
`You are operating as the agent "${
|
|
1459
|
+
`You are operating as the agent "${agentName}". Follow these agent instructions:
|
|
1381
1460
|
${agentInstructions}`
|
|
1382
1461
|
);
|
|
1383
1462
|
}
|
|
@@ -1579,11 +1658,7 @@ function resolveTimestamp(value) {
|
|
|
1579
1658
|
const parsed = Date.parse(value);
|
|
1580
1659
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
1581
1660
|
}
|
|
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) {
|
|
1661
|
+
function selectMemories(rows, maxItems = MEMORY_MAX_ITEMS, totalLimit = MEMORY_TOTAL_LIMIT, capper = capText) {
|
|
1587
1662
|
const ordered = [...rows].sort((a, b) => {
|
|
1588
1663
|
if (a.pinned !== b.pinned) return a.pinned ? -1 : 1;
|
|
1589
1664
|
return resolveTimestamp(b.updatedAt) - resolveTimestamp(a.updatedAt);
|
|
@@ -1594,7 +1669,7 @@ function selectMemories(rows, maxItems = MEMORY_MAX_ITEMS, totalLimit = MEMORY_T
|
|
|
1594
1669
|
if (out.length >= maxItems || used >= totalLimit) break;
|
|
1595
1670
|
const content = row.content.trim();
|
|
1596
1671
|
if (content.length === 0) continue;
|
|
1597
|
-
const capped =
|
|
1672
|
+
const capped = capper(content, totalLimit - used);
|
|
1598
1673
|
out.push(capped);
|
|
1599
1674
|
used += capped.length;
|
|
1600
1675
|
}
|
|
@@ -1826,6 +1901,6 @@ function validateToolArgs(toolKey, args, schemas) {
|
|
|
1826
1901
|
return { ok: false, error: `Invalid schema definition for tool: ${toolKey}` };
|
|
1827
1902
|
}
|
|
1828
1903
|
|
|
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 };
|
|
1904
|
+
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
1905
|
//# sourceMappingURL=index.js.map
|
|
1831
1906
|
//# sourceMappingURL=index.js.map
|