@ganju/utils 0.0.8 → 0.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/channelDebounce.d.ts +11 -0
- package/dist/channelDebounce.d.ts.map +1 -1
- package/dist/channelDebounce.js +12 -1
- package/dist/chunking.d.ts +17 -3
- package/dist/chunking.d.ts.map +1 -1
- package/dist/chunking.js +125 -19
- package/dist/constants.d.ts +24 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +102 -16
- package/dist/index.d.ts +76 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/llmBaseUrl.d.ts +39 -0
- package/dist/llmBaseUrl.d.ts.map +1 -0
- package/dist/llmBaseUrl.js +65 -0
- package/dist/localizeZodIssue.d.ts.map +1 -1
- package/dist/localizeZodIssue.js +6 -0
- package/dist/resourceRerank.d.ts +20 -0
- package/dist/resourceRerank.d.ts.map +1 -0
- package/dist/resourceRerank.js +37 -0
- package/dist/schema.d.ts +41 -24
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +47 -8
- package/dist/syncableResource.d.ts +9 -0
- package/dist/syncableResource.d.ts.map +1 -0
- package/dist/syncableResource.js +31 -0
- package/dist/toolCatalog.d.ts +1 -1
- package/dist/toolCatalog.js +1 -1
- package/package.json +1 -1
- package/src/channelDebounce.ts +36 -0
- package/src/chunking.ts +166 -23
- package/src/constants.ts +114 -16
- package/src/index.ts +26 -1
- package/src/llmBaseUrl.ts +65 -0
- package/src/localizeZodIssue.ts +6 -0
- package/src/resourceRerank.ts +54 -0
- package/src/schema.ts +80 -11
- package/src/syncableResource.ts +48 -0
- package/src/toolCatalog.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,16 +14,18 @@ import type { CustomCodeTokenPayload } from './customCodeToken';
|
|
|
14
14
|
import type { ContainmentTokenPayload } from './containmentToken';
|
|
15
15
|
import type { OAuthProviderConfig } from './oauthProviders';
|
|
16
16
|
import type { ExposableResource } from './exposedResource';
|
|
17
|
+
import type { SyncableResource, ResourceSyncProvider } from './syncableResource';
|
|
17
18
|
import type { CustomCodeProject, ProjectPathIssue } from './customCodeProject';
|
|
18
19
|
import type { AttachmentResource, ResolvedAttachment, ResolveAttachmentResult } from './attachment';
|
|
19
20
|
import type { MintedAccessToken } from './accessToken';
|
|
20
21
|
import type { CatalogGroup, CatalogTool, CatalogToolDescriptor, ToolGroupKey, ToolKey } from './toolCatalog';
|
|
21
22
|
import type { Separator, ChunkMetadata, PreparedChunk } from './chunking';
|
|
23
|
+
import type { RerankAiBinding } from './resourceRerank';
|
|
22
24
|
import type { RateLimitRetryOptions } from './retry';
|
|
23
25
|
import type { QueueBatchLike, QueueMessageLike, ProcessQueueBatchHandlers } from './processQueueBatch';
|
|
24
26
|
import type { ExtractedDocument, ExtractedDocumentMetadata, ExtractedDocumentSource } from './extractedDocument';
|
|
25
27
|
import type { ChannelNotifier, ToolStatusEvent } from './channelNotifier';
|
|
26
|
-
import type { BufferedChannelMessage, ChannelBufferEnvelope, ChannelBufferFlush } from './channelDebounce';
|
|
28
|
+
import type { BufferedChannelMessage, BufferedChannelCommand, ChannelBufferEnvelope, ChannelBufferFlush } from './channelDebounce';
|
|
27
29
|
import type { Source, ResourceUrlContext, SourceButton } from './sources';
|
|
28
30
|
import { OAuthReauthRequiredError } from './oauth';
|
|
29
31
|
import type { RefreshOAuthTokenInput, RefreshedOAuthToken } from './oauth';
|
|
@@ -355,18 +357,6 @@ export declare const utils: {
|
|
|
355
357
|
organizationId: import("zod").ZodUUID;
|
|
356
358
|
}, import("zod/v4/core").$strip>;
|
|
357
359
|
ARTIFACT_CREATE_RESOURCE_VIEW: import("zod").ZodObject<{
|
|
358
|
-
content: import("zod").ZodOptional<import("zod").ZodString>;
|
|
359
|
-
type: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
360
|
-
static: "static";
|
|
361
|
-
template: "template";
|
|
362
|
-
}>>;
|
|
363
|
-
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
364
|
-
title: import("zod").ZodString;
|
|
365
|
-
uri: import("zod").ZodString;
|
|
366
|
-
crawlConfig: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
367
|
-
maxPages: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
368
|
-
maxDepth: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
369
|
-
}, import("zod/v4/core").$strip>>;
|
|
370
360
|
mimeType: import("zod").ZodEnum<{
|
|
371
361
|
"text/plain": "text/plain";
|
|
372
362
|
"text/csv": "text/csv";
|
|
@@ -407,6 +397,19 @@ export declare const utils: {
|
|
|
407
397
|
"application/x-perl": "application/x-perl";
|
|
408
398
|
"application/octet-stream": "application/octet-stream";
|
|
409
399
|
}>;
|
|
400
|
+
fileName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
401
|
+
content: import("zod").ZodOptional<import("zod").ZodString>;
|
|
402
|
+
type: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
403
|
+
static: "static";
|
|
404
|
+
template: "template";
|
|
405
|
+
}>>;
|
|
406
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
407
|
+
title: import("zod").ZodString;
|
|
408
|
+
uri: import("zod").ZodString;
|
|
409
|
+
crawlConfig: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
410
|
+
maxPages: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
411
|
+
maxDepth: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
412
|
+
}, import("zod/v4/core").$strip>>;
|
|
410
413
|
size: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
411
414
|
sourceType: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
412
415
|
FILE: "FILE";
|
|
@@ -417,7 +420,6 @@ export declare const utils: {
|
|
|
417
420
|
}>>;
|
|
418
421
|
encoding: import("zod").ZodOptional<import("zod").ZodString>;
|
|
419
422
|
fileKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
420
|
-
fileName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
421
423
|
annotations: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
422
424
|
audience: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
423
425
|
user: "user";
|
|
@@ -616,14 +618,6 @@ export declare const utils: {
|
|
|
616
618
|
organizationId: import("zod").ZodUUID;
|
|
617
619
|
}, import("zod/v4/core").$strip>;
|
|
618
620
|
ARTIFACT_UPDATE_RESOURCE_VIEW: import("zod").ZodObject<{
|
|
619
|
-
content: import("zod").ZodOptional<import("zod").ZodString>;
|
|
620
|
-
type: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
621
|
-
static: "static";
|
|
622
|
-
template: "template";
|
|
623
|
-
}>>;
|
|
624
|
-
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
625
|
-
title: import("zod").ZodString;
|
|
626
|
-
uri: import("zod").ZodString;
|
|
627
621
|
mimeType: import("zod").ZodEnum<{
|
|
628
622
|
"text/plain": "text/plain";
|
|
629
623
|
"text/csv": "text/csv";
|
|
@@ -664,6 +658,15 @@ export declare const utils: {
|
|
|
664
658
|
"application/x-perl": "application/x-perl";
|
|
665
659
|
"application/octet-stream": "application/octet-stream";
|
|
666
660
|
}>;
|
|
661
|
+
fileName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
662
|
+
content: import("zod").ZodOptional<import("zod").ZodString>;
|
|
663
|
+
type: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
664
|
+
static: "static";
|
|
665
|
+
template: "template";
|
|
666
|
+
}>>;
|
|
667
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
668
|
+
title: import("zod").ZodString;
|
|
669
|
+
uri: import("zod").ZodString;
|
|
667
670
|
size: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
668
671
|
sourceType: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
669
672
|
FILE: "FILE";
|
|
@@ -674,7 +677,6 @@ export declare const utils: {
|
|
|
674
677
|
}>>;
|
|
675
678
|
encoding: import("zod").ZodOptional<import("zod").ZodString>;
|
|
676
679
|
fileKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
677
|
-
fileName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
678
680
|
annotations: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
679
681
|
audience: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
680
682
|
user: "user";
|
|
@@ -830,8 +832,8 @@ export declare const utils: {
|
|
|
830
832
|
"openai-compatible": "openai-compatible";
|
|
831
833
|
}>;
|
|
832
834
|
apiKey: import("zod").ZodString;
|
|
833
|
-
model: import("zod").ZodString;
|
|
834
835
|
baseUrl: import("zod").ZodUnion<[import("zod").ZodOptional<import("zod").ZodURL>, import("zod").ZodLiteral<"">]>;
|
|
836
|
+
model: import("zod").ZodString;
|
|
835
837
|
systemPrompt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
836
838
|
}, import("zod/v4/core").$strip>;
|
|
837
839
|
ORGANIZATION_UPDATE_LLM: import("zod").ZodObject<{
|
|
@@ -861,8 +863,8 @@ export declare const utils: {
|
|
|
861
863
|
"openai-compatible": "openai-compatible";
|
|
862
864
|
}>>;
|
|
863
865
|
apiKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
864
|
-
model: import("zod").ZodOptional<import("zod").ZodString>;
|
|
865
866
|
baseUrl: import("zod").ZodNullable<import("zod").ZodUnion<[import("zod").ZodOptional<import("zod").ZodURL>, import("zod").ZodLiteral<"">]>>;
|
|
867
|
+
model: import("zod").ZodOptional<import("zod").ZodString>;
|
|
866
868
|
systemPrompt: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
867
869
|
}, import("zod/v4/core").$strip>;
|
|
868
870
|
ORGANIZATION_REMOVE_LLM: import("zod").ZodObject<{
|
|
@@ -981,6 +983,23 @@ export declare const utils: {
|
|
|
981
983
|
userId: import("zod").ZodUUID;
|
|
982
984
|
organizationId: import("zod").ZodUUID;
|
|
983
985
|
}, import("zod/v4/core").$strip>;
|
|
986
|
+
ARTIFACT_UPDATE_RESOURCE_SYNC_INTERVAL: import("zod").ZodObject<{
|
|
987
|
+
resourceId: import("zod").ZodUUID;
|
|
988
|
+
syncInterval: import("zod").ZodEnum<{
|
|
989
|
+
off: "off";
|
|
990
|
+
daily: "daily";
|
|
991
|
+
weekly: "weekly";
|
|
992
|
+
}>;
|
|
993
|
+
projectId: import("zod").ZodUUID;
|
|
994
|
+
userId: import("zod").ZodUUID;
|
|
995
|
+
organizationId: import("zod").ZodUUID;
|
|
996
|
+
}, import("zod/v4/core").$strip>;
|
|
997
|
+
ARTIFACT_SYNC_RESOURCE: import("zod").ZodObject<{
|
|
998
|
+
resourceId: import("zod").ZodUUID;
|
|
999
|
+
projectId: import("zod").ZodUUID;
|
|
1000
|
+
userId: import("zod").ZodUUID;
|
|
1001
|
+
organizationId: import("zod").ZodUUID;
|
|
1002
|
+
}, import("zod/v4/core").$strip>;
|
|
984
1003
|
HTTP_ENDPOINT_CONFIG: import("zod").ZodPipe<import("zod").ZodObject<{
|
|
985
1004
|
name: import("zod").ZodString;
|
|
986
1005
|
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -1813,6 +1832,7 @@ export declare const utils: {
|
|
|
1813
1832
|
PLAN_FEATURE_EMBEDDED_STORAGE: "embeddedStorage";
|
|
1814
1833
|
PLAN_FEATURE_MESSAGE: "message";
|
|
1815
1834
|
PLAN_FEATURE_TOOL_CALL: "toolCall";
|
|
1835
|
+
PLAN_FEATURE_RESOURCE_SYNC: "resourceSync";
|
|
1816
1836
|
PLAN_LIMIT_ERROR_CODE: string;
|
|
1817
1837
|
BILLING_METER_MESSAGES: string;
|
|
1818
1838
|
BILLING_METER_SHARED_MESSAGES: string;
|
|
@@ -2018,6 +2038,17 @@ export declare const utils: {
|
|
|
2018
2038
|
RESOURCE_SOURCE_TYPE_ONE_DRIVE_FOLDER: "ONE_DRIVE_FOLDER";
|
|
2019
2039
|
RESOURCE_SOURCE_TYPE_CUSTOM_CODE: "CUSTOM_CODE";
|
|
2020
2040
|
RESOURCE_SOURCE_TYPES: ("FILE" | "WEBSITE" | "GOOGLE_DRIVE_FOLDER" | "ONE_DRIVE_FOLDER" | "CUSTOM_CODE")[];
|
|
2041
|
+
RESOURCE_SYNC_INTERVAL_OFF: "off";
|
|
2042
|
+
RESOURCE_SYNC_INTERVAL_DAILY: "daily";
|
|
2043
|
+
RESOURCE_SYNC_INTERVAL_WEEKLY: "weekly";
|
|
2044
|
+
RESOURCE_SYNC_INTERVALS: readonly ["off", "daily", "weekly"];
|
|
2045
|
+
RESOURCE_SYNC_INTERVAL_DEFAULT: "weekly";
|
|
2046
|
+
RESOURCE_SYNC_INTERVAL_MS: {
|
|
2047
|
+
readonly daily: number;
|
|
2048
|
+
readonly weekly: number;
|
|
2049
|
+
};
|
|
2050
|
+
RESOURCE_SYNC_BATCH_SIZE: number;
|
|
2051
|
+
RESOURCE_SYNC_MANUAL_COOLDOWN_MS: number;
|
|
2021
2052
|
CRAWL_RENDERER_CHEERIO: "cheerio";
|
|
2022
2053
|
CRAWL_RENDERER_PLAYWRIGHT: "playwright";
|
|
2023
2054
|
CRAWL_RENDERERS: ("cheerio" | "playwright")[];
|
|
@@ -2071,6 +2102,9 @@ export declare const utils: {
|
|
|
2071
2102
|
model: string;
|
|
2072
2103
|
label: string;
|
|
2073
2104
|
}[];
|
|
2105
|
+
LLM_CATALOG_CUSTOM_KEY: string;
|
|
2106
|
+
LLM_BASE_URL_REQUIRED_MESSAGE: string;
|
|
2107
|
+
LLM_BASE_URL_INVALID_MESSAGE: string;
|
|
2074
2108
|
LLM_SYSTEM_DEFAULT: string;
|
|
2075
2109
|
MAX_TOOL_LOOPS: number;
|
|
2076
2110
|
CHANNEL_HISTORY_LIMIT: number;
|
|
@@ -2140,6 +2174,12 @@ export declare const utils: {
|
|
|
2140
2174
|
CHUNK_TARGET_CHARS: number;
|
|
2141
2175
|
CHUNK_OVERLAP_CHARS: number;
|
|
2142
2176
|
EMBED_BATCH_SIZE: number;
|
|
2177
|
+
RESOURCE_SEARCH_CANDIDATES: number;
|
|
2178
|
+
RESOURCE_SEARCH_RRF_K: number;
|
|
2179
|
+
RESOURCE_SEARCH_COMMON_TERM_DIVISOR: number;
|
|
2180
|
+
RESOURCE_SEARCH_COMMON_TERM_MIN: number;
|
|
2181
|
+
RESOURCE_SEARCH_RERANK_CANDIDATES: number;
|
|
2182
|
+
RESOURCE_SEARCH_RERANK_MODEL: string;
|
|
2143
2183
|
RESOURCE_HANDLER_SLEEP_AFTER: string;
|
|
2144
2184
|
DOCS_URL: string;
|
|
2145
2185
|
BASE64_DATA_URI_RE: RegExp;
|
|
@@ -2417,6 +2457,8 @@ export declare const utils: {
|
|
|
2417
2457
|
oauthProviders: Record<string, OAuthProviderConfig>;
|
|
2418
2458
|
resolveAttachment: (resource: AttachmentResource, readObject: (key: string) => Promise<ArrayBuffer | null>, verb?: "attach" | "upload") => Promise<ResolveAttachmentResult>;
|
|
2419
2459
|
isExposedResource: (resource: ExposableResource) => boolean;
|
|
2460
|
+
isSyncableResource: (resource: SyncableResource) => boolean;
|
|
2461
|
+
resourceSyncProvider: (resource: SyncableResource) => ResourceSyncProvider | null;
|
|
2420
2462
|
describeVendorError: (body: unknown, fallback: string) => string;
|
|
2421
2463
|
withDeadline: <T>(work: Promise<T>, ms: number) => Promise<T>;
|
|
2422
2464
|
isDeadlineError: (error: unknown) => boolean;
|
|
@@ -2428,6 +2470,9 @@ export declare const utils: {
|
|
|
2428
2470
|
projectPathIssue: (path: string, taken?: Iterable<string>) => ProjectPathIssue | null;
|
|
2429
2471
|
ipv4InPrivateRange: (host: string) => boolean;
|
|
2430
2472
|
isBlockedHost: (hostname: string) => boolean;
|
|
2473
|
+
requiresLlmBaseUrl: (provider?: string | null) => boolean;
|
|
2474
|
+
isAllowedLlmBaseUrl: (value: string) => boolean;
|
|
2475
|
+
llmBaseUrlIssue: (provider?: string | null, baseUrl?: string | null) => string | null;
|
|
2431
2476
|
validateMessageVariables: (messages: Array<{
|
|
2432
2477
|
role: string;
|
|
2433
2478
|
content: string;
|
|
@@ -2783,7 +2828,7 @@ export declare const utils: {
|
|
|
2783
2828
|
}, {
|
|
2784
2829
|
readonly key: "search-resources";
|
|
2785
2830
|
readonly title: "Search Resources";
|
|
2786
|
-
readonly description: "Find the resources most relevant to a question
|
|
2831
|
+
readonly description: "Find the resources most relevant to a question, by meaning and by exact keywords.";
|
|
2787
2832
|
readonly requiredScopes: null;
|
|
2788
2833
|
}, {
|
|
2789
2834
|
readonly key: "send-resource";
|
|
@@ -2873,9 +2918,12 @@ export declare const utils: {
|
|
|
2873
2918
|
prepareChunks: (header: string, documents: ExtractedDocument[] | null, fallbackContent: string | null, options?: {
|
|
2874
2919
|
targetChars?: number;
|
|
2875
2920
|
overlapChars?: number;
|
|
2921
|
+
mimeType?: string | null;
|
|
2922
|
+
fileName?: string | null;
|
|
2876
2923
|
}) => PreparedChunk[];
|
|
2877
2924
|
isEmbeddableMimeType: (mimeType: string) => boolean;
|
|
2878
2925
|
l2Normalize: (values: number[]) => number[];
|
|
2926
|
+
createResourceReranker: (source: EnvSource) => ((query: string, documents: string[]) => Promise<number[] | null>) | undefined;
|
|
2879
2927
|
sleep: (ms: number) => Promise<void>;
|
|
2880
2928
|
isRateLimitError: (err: unknown) => boolean;
|
|
2881
2929
|
withRateLimitRetry: <T>(fn: () => Promise<T>, options?: RateLimitRetryOptions) => Promise<T>;
|
|
@@ -2883,6 +2931,7 @@ export declare const utils: {
|
|
|
2883
2931
|
getToolStatusMessage: (toolName: string) => string | null;
|
|
2884
2932
|
resolveDebounceMs: (config: unknown) => number;
|
|
2885
2933
|
channelBufferKey: (channelId: string, externalConversationId: string, externalParticipantId: string) => string;
|
|
2934
|
+
batchCommand: (messages: BufferedChannelMessage[]) => BufferedChannelCommand | null;
|
|
2886
2935
|
joinBufferedMessages: (messages: Array<{
|
|
2887
2936
|
text: string;
|
|
2888
2937
|
}>) => string;
|
|
@@ -2910,5 +2959,5 @@ export declare const utils: {
|
|
|
2910
2959
|
PlanLimitError: typeof PlanLimitError;
|
|
2911
2960
|
isPlanLimitError: (error: unknown) => error is PlanLimitError;
|
|
2912
2961
|
};
|
|
2913
|
-
export type { MintedAccessToken, CustomCodeProject, ProjectPathIssue, CatalogGroup, CatalogTool, CatalogToolDescriptor, ToolGroupKey, ToolKey, CalendarConfigField, JsonSchema, SchemaViolation, MimeAttachment, MimeMessageInput, GmailOperation, GmailSendRequest, GmailSendResponse, OutlookOperation, OutlookSendRequest, OutlookSendResponse, SlackOperation, SlackSendRequest, SlackSendResponse, SlackSendRemoteResourceRequest, TelegramSendRequest, TelegramSendResponse, TelegramSendRemoteResourceRequest, DiscordSendRequest, DiscordSendResponse, DiscordSendRemoteResourceRequest, WhatsappSendRequest, WhatsappSendResponse, WhatsappSendRemoteResourceRequest, EnvSource, Separator, ChunkMetadata, PreparedChunk, ExtractedDocument, ExtractedDocumentMetadata, ExtractedDocumentSource, RateLimitRetryOptions, QueueBatchLike, QueueMessageLike, ProcessQueueBatchHandlers, ChannelNotifier, ToolStatusEvent, BufferedChannelMessage, ChannelBufferEnvelope, ChannelBufferFlush, Source, ResourceUrlContext, SourceButton, RefreshOAuthTokenInput, RefreshedOAuthToken, HttpEndpointToolConfig, McpProxyToolConfig, McpProxyDiscoveredTool, McpProxyDiscoveredResource, McpProxyDiscoveredPrompt, McpProxyDiscovery, CustomCodeToolConfig, CustomCodeToolManifest, CustomCodeManifest, CustomCodeSendFile, CustomCodeCreateResource, CustomCodeTokenPayload, ContainmentTokenPayload, OAuthProviderConfig, AttachmentResource, ResolvedAttachment, ResolveAttachmentResult, ExposableResource, PlanLimitDetails, PlanLimits };
|
|
2962
|
+
export type { MintedAccessToken, CustomCodeProject, ProjectPathIssue, CatalogGroup, CatalogTool, CatalogToolDescriptor, ToolGroupKey, ToolKey, CalendarConfigField, JsonSchema, SchemaViolation, MimeAttachment, MimeMessageInput, GmailOperation, GmailSendRequest, GmailSendResponse, OutlookOperation, OutlookSendRequest, OutlookSendResponse, SlackOperation, SlackSendRequest, SlackSendResponse, SlackSendRemoteResourceRequest, TelegramSendRequest, TelegramSendResponse, TelegramSendRemoteResourceRequest, DiscordSendRequest, DiscordSendResponse, DiscordSendRemoteResourceRequest, WhatsappSendRequest, WhatsappSendResponse, WhatsappSendRemoteResourceRequest, EnvSource, Separator, ChunkMetadata, PreparedChunk, ExtractedDocument, ExtractedDocumentMetadata, ExtractedDocumentSource, RateLimitRetryOptions, RerankAiBinding, QueueBatchLike, QueueMessageLike, ProcessQueueBatchHandlers, ChannelNotifier, ToolStatusEvent, BufferedChannelMessage, BufferedChannelCommand, ChannelBufferEnvelope, ChannelBufferFlush, Source, ResourceUrlContext, SourceButton, RefreshOAuthTokenInput, RefreshedOAuthToken, HttpEndpointToolConfig, McpProxyToolConfig, McpProxyDiscoveredTool, McpProxyDiscoveredResource, McpProxyDiscoveredPrompt, McpProxyDiscovery, CustomCodeToolConfig, CustomCodeToolManifest, CustomCodeManifest, CustomCodeSendFile, CustomCodeCreateResource, CustomCodeTokenPayload, ContainmentTokenPayload, OAuthProviderConfig, AttachmentResource, ResolvedAttachment, ResolveAttachmentResult, ExposableResource, SyncableResource, ResourceSyncProvider, PlanLimitDetails, PlanLimits };
|
|
2914
2963
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C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B,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,kBAAkB,EAClB,mBAAmB,EACnB,gCAAgC,EAChC,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,EACN,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACX,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,12 @@ const containmentToken_1 = require("./containmentToken");
|
|
|
22
22
|
const oauthProviders_1 = require("./oauthProviders");
|
|
23
23
|
const attachment_1 = require("./attachment");
|
|
24
24
|
const exposedResource_1 = require("./exposedResource");
|
|
25
|
+
const syncableResource_1 = require("./syncableResource");
|
|
25
26
|
const vendorError_1 = require("./vendorError");
|
|
26
27
|
const deadline_1 = require("./deadline");
|
|
27
28
|
const customCodeProject_1 = require("./customCodeProject");
|
|
28
29
|
const ssrf_1 = require("./ssrf");
|
|
30
|
+
const llmBaseUrl_1 = require("./llmBaseUrl");
|
|
29
31
|
const formatRelative_1 = require("./formatRelative");
|
|
30
32
|
const formatRelativeTime_1 = require("./formatRelativeTime");
|
|
31
33
|
const languageCookieDomain_1 = require("./languageCookieDomain");
|
|
@@ -40,6 +42,7 @@ const sanitize_1 = require("./sanitize");
|
|
|
40
42
|
const chunking_1 = require("./chunking");
|
|
41
43
|
const embeddable_1 = require("./embeddable");
|
|
42
44
|
const l2Normalize_1 = require("./l2Normalize");
|
|
45
|
+
const resourceRerank_1 = require("./resourceRerank");
|
|
43
46
|
const retry_1 = require("./retry");
|
|
44
47
|
const processQueueBatch_1 = require("./processQueueBatch");
|
|
45
48
|
const channelNotifier_1 = require("./channelNotifier");
|
|
@@ -99,6 +102,8 @@ exports.utils = {
|
|
|
99
102
|
oauthProviders: oauthProviders_1.oauthProviders,
|
|
100
103
|
resolveAttachment: attachment_1.resolveAttachment,
|
|
101
104
|
isExposedResource: exposedResource_1.isExposedResource,
|
|
105
|
+
isSyncableResource: syncableResource_1.isSyncableResource,
|
|
106
|
+
resourceSyncProvider: syncableResource_1.resourceSyncProvider,
|
|
102
107
|
describeVendorError: vendorError_1.describeVendorError,
|
|
103
108
|
withDeadline: deadline_1.withDeadline,
|
|
104
109
|
isDeadlineError: deadline_1.isDeadlineError,
|
|
@@ -110,6 +115,9 @@ exports.utils = {
|
|
|
110
115
|
projectPathIssue: customCodeProject_1.projectPathIssue,
|
|
111
116
|
ipv4InPrivateRange: ssrf_1.ipv4InPrivateRange,
|
|
112
117
|
isBlockedHost: ssrf_1.isBlockedHost,
|
|
118
|
+
requiresLlmBaseUrl: llmBaseUrl_1.requiresLlmBaseUrl,
|
|
119
|
+
isAllowedLlmBaseUrl: llmBaseUrl_1.isAllowedLlmBaseUrl,
|
|
120
|
+
llmBaseUrlIssue: llmBaseUrl_1.llmBaseUrlIssue,
|
|
113
121
|
validateMessageVariables: validateMessageVariables_1.validateMessageVariables,
|
|
114
122
|
formatRelative: formatRelative_1.formatRelative,
|
|
115
123
|
formatRelativeTime: formatRelativeTime_1.formatRelativeTime,
|
|
@@ -142,6 +150,7 @@ exports.utils = {
|
|
|
142
150
|
prepareChunks: chunking_1.prepareChunks,
|
|
143
151
|
isEmbeddableMimeType: embeddable_1.isEmbeddableMimeType,
|
|
144
152
|
l2Normalize: l2Normalize_1.l2Normalize,
|
|
153
|
+
createResourceReranker: resourceRerank_1.createResourceReranker,
|
|
145
154
|
sleep: retry_1.sleep,
|
|
146
155
|
isRateLimitError: retry_1.isRateLimitError,
|
|
147
156
|
withRateLimitRetry: retry_1.withRateLimitRetry,
|
|
@@ -149,6 +158,7 @@ exports.utils = {
|
|
|
149
158
|
getToolStatusMessage: channelNotifier_1.getToolStatusMessage,
|
|
150
159
|
resolveDebounceMs: channelDebounce_1.resolveDebounceMs,
|
|
151
160
|
channelBufferKey: channelDebounce_1.channelBufferKey,
|
|
161
|
+
batchCommand: channelDebounce_1.batchCommand,
|
|
152
162
|
joinBufferedMessages: channelDebounce_1.joinBufferedMessages,
|
|
153
163
|
isResourceSourceEnabled: sources_1.isResourceSourceEnabled,
|
|
154
164
|
isDownloadableSource: sources_1.isDownloadableSource,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules an `organization_llm.base_url` has to satisfy, in one place.
|
|
3
|
+
*
|
|
4
|
+
* Two write paths need them and neither can see the whole picture alone: the
|
|
5
|
+
* create schema validates a complete payload, while an update is a partial, so
|
|
6
|
+
* the provider may arrive in the request and the base URL may only exist on the
|
|
7
|
+
* stored row. Keeping the rules here means the two can't drift into disagreeing
|
|
8
|
+
* about what a valid row is — the same reason every other write in this package
|
|
9
|
+
* goes through a shared validator rather than an inline check.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Which providers need a base URL of their own.
|
|
13
|
+
*
|
|
14
|
+
* Every other provider has an endpoint baked into its SDK. `openai-compatible`
|
|
15
|
+
* has none: it is the escape hatch for services that merely speak the OpenAI
|
|
16
|
+
* protocol, so without a base URL the adapter would send the customer's key to
|
|
17
|
+
* `api.openai.com` and fail somewhere far from the form they typed it into.
|
|
18
|
+
*/
|
|
19
|
+
export declare const requiresLlmBaseUrl: (provider?: string | null) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a base URL is safe to send a request to.
|
|
22
|
+
*
|
|
23
|
+
* This is an outbound fetch target chosen by a customer, on a worker holding
|
|
24
|
+
* their decrypted API key, so it gets the same screening as every other
|
|
25
|
+
* caller-supplied URL: `https` only, because the key travels in a header, and
|
|
26
|
+
* no loopback, private or link-local host. The Workers runtime can't resolve
|
|
27
|
+
* DNS, so — as everywhere else `isBlockedHost` is used — this screens literal
|
|
28
|
+
* hosts and IPs and is not a defense against DNS rebinding.
|
|
29
|
+
*/
|
|
30
|
+
export declare const isAllowedLlmBaseUrl: (value: string) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Both rules against one provider/base-URL pair: the message to reject with, or
|
|
33
|
+
* `null` when the pair is acceptable. The messages are constants so
|
|
34
|
+
* `localizeZodIssue` can translate them, and both carry a word `matchStatus`
|
|
35
|
+
* recognises — the update path throws this as a plain Error rather than a
|
|
36
|
+
* ZodError, and an unrecognised message there answers 500 where it means 400.
|
|
37
|
+
*/
|
|
38
|
+
export declare const llmBaseUrlIssue: (provider?: string | null, baseUrl?: string | null) => string | null;
|
|
39
|
+
//# sourceMappingURL=llmBaseUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmBaseUrl.d.ts","sourceRoot":"","sources":["../src/llmBaseUrl.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,GAAG,IAAI,KAAG,OACP,CAAC;AAExD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG,OASnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,GAAG,IAAI,EACxB,UAAU,MAAM,GAAG,IAAI,KACtB,MAAM,GAAG,IAQX,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.llmBaseUrlIssue = exports.isAllowedLlmBaseUrl = exports.requiresLlmBaseUrl = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const ssrf_1 = require("./ssrf");
|
|
6
|
+
/**
|
|
7
|
+
* The rules an `organization_llm.base_url` has to satisfy, in one place.
|
|
8
|
+
*
|
|
9
|
+
* Two write paths need them and neither can see the whole picture alone: the
|
|
10
|
+
* create schema validates a complete payload, while an update is a partial, so
|
|
11
|
+
* the provider may arrive in the request and the base URL may only exist on the
|
|
12
|
+
* stored row. Keeping the rules here means the two can't drift into disagreeing
|
|
13
|
+
* about what a valid row is — the same reason every other write in this package
|
|
14
|
+
* goes through a shared validator rather than an inline check.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Which providers need a base URL of their own.
|
|
18
|
+
*
|
|
19
|
+
* Every other provider has an endpoint baked into its SDK. `openai-compatible`
|
|
20
|
+
* has none: it is the escape hatch for services that merely speak the OpenAI
|
|
21
|
+
* protocol, so without a base URL the adapter would send the customer's key to
|
|
22
|
+
* `api.openai.com` and fail somewhere far from the form they typed it into.
|
|
23
|
+
*/
|
|
24
|
+
const requiresLlmBaseUrl = (provider) => provider === constants_1.constants.LLM_PROVIDER_OPENAI_COMPATIBLE;
|
|
25
|
+
exports.requiresLlmBaseUrl = requiresLlmBaseUrl;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a base URL is safe to send a request to.
|
|
28
|
+
*
|
|
29
|
+
* This is an outbound fetch target chosen by a customer, on a worker holding
|
|
30
|
+
* their decrypted API key, so it gets the same screening as every other
|
|
31
|
+
* caller-supplied URL: `https` only, because the key travels in a header, and
|
|
32
|
+
* no loopback, private or link-local host. The Workers runtime can't resolve
|
|
33
|
+
* DNS, so — as everywhere else `isBlockedHost` is used — this screens literal
|
|
34
|
+
* hosts and IPs and is not a defense against DNS rebinding.
|
|
35
|
+
*/
|
|
36
|
+
const isAllowedLlmBaseUrl = (value) => {
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = new URL(value);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (parsed.protocol !== 'https:')
|
|
45
|
+
return false;
|
|
46
|
+
return !(0, ssrf_1.isBlockedHost)(parsed.hostname);
|
|
47
|
+
};
|
|
48
|
+
exports.isAllowedLlmBaseUrl = isAllowedLlmBaseUrl;
|
|
49
|
+
/**
|
|
50
|
+
* Both rules against one provider/base-URL pair: the message to reject with, or
|
|
51
|
+
* `null` when the pair is acceptable. The messages are constants so
|
|
52
|
+
* `localizeZodIssue` can translate them, and both carry a word `matchStatus`
|
|
53
|
+
* recognises — the update path throws this as a plain Error rather than a
|
|
54
|
+
* ZodError, and an unrecognised message there answers 500 where it means 400.
|
|
55
|
+
*/
|
|
56
|
+
const llmBaseUrlIssue = (provider, baseUrl) => {
|
|
57
|
+
if ((0, exports.requiresLlmBaseUrl)(provider) && !baseUrl) {
|
|
58
|
+
return constants_1.constants.LLM_BASE_URL_REQUIRED_MESSAGE;
|
|
59
|
+
}
|
|
60
|
+
if (baseUrl && !(0, exports.isAllowedLlmBaseUrl)(baseUrl)) {
|
|
61
|
+
return constants_1.constants.LLM_BASE_URL_INVALID_MESSAGE;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
exports.llmBaseUrlIssue = llmBaseUrlIssue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localizeZodIssue.d.ts","sourceRoot":"","sources":["../src/localizeZodIssue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"localizeZodIssue.d.ts","sourceRoot":"","sources":["../src/localizeZodIssue.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;CACtB;AAwDD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,GAAG,IAAI,KAAG,MAK3D,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,GAC3B,OAAO,YAAY,EACnB,UAAU,MAAM,KACf,MAmBF,CAAC"}
|
package/dist/localizeZodIssue.js
CHANGED
|
@@ -43,6 +43,12 @@ const CUSTOM_MESSAGES = {
|
|
|
43
43
|
},
|
|
44
44
|
[constants_1.constants.CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE]: {
|
|
45
45
|
es: `Los bytes del archivo superan el límite de ${constants_1.constants.CUSTOM_CODE_MAX_RESOURCE_FILE_BYTES / (1024 * 1024)}MB`
|
|
46
|
+
},
|
|
47
|
+
[constants_1.constants.LLM_BASE_URL_REQUIRED_MESSAGE]: {
|
|
48
|
+
es: 'Se requiere una URL base para un modelo compatible con OpenAI'
|
|
49
|
+
},
|
|
50
|
+
[constants_1.constants.LLM_BASE_URL_INVALID_MESSAGE]: {
|
|
51
|
+
es: 'La URL base debe ser una dirección https:// pública'
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
54
|
// Built once. `esLocale()` allocates its dictionaries on every call, and this
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EnvSource } from './getEnv';
|
|
2
|
+
export interface RerankAiBinding {
|
|
3
|
+
run(model: string, input: {
|
|
4
|
+
query: string;
|
|
5
|
+
contexts: Array<{
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
top_k?: number;
|
|
9
|
+
}): Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The cross-encoder second stage for resource search, or undefined when the
|
|
13
|
+
* Worker has no `AI` binding — local dev without Workers AI keeps plain fusion.
|
|
14
|
+
*
|
|
15
|
+
* Returns one score per document, in input order. A response that doesn't
|
|
16
|
+
* cover every document returns null, which keeps the fused order — a partial
|
|
17
|
+
* ranking would silently drop the chunks it left out.
|
|
18
|
+
*/
|
|
19
|
+
export declare const createResourceReranker: (source: EnvSource) => ((query: string, documents: string[]) => Promise<number[] | null>) | undefined;
|
|
20
|
+
//# sourceMappingURL=resourceRerank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceRerank.d.ts","sourceRoot":"","sources":["../src/resourceRerank.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,MAAM,WAAW,eAAe;IAC9B,GAAG,CACD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1E,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,SAAS,KAEf,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAClE,SAyBH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createResourceReranker = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
/**
|
|
6
|
+
* The cross-encoder second stage for resource search, or undefined when the
|
|
7
|
+
* Worker has no `AI` binding — local dev without Workers AI keeps plain fusion.
|
|
8
|
+
*
|
|
9
|
+
* Returns one score per document, in input order. A response that doesn't
|
|
10
|
+
* cover every document returns null, which keeps the fused order — a partial
|
|
11
|
+
* ranking would silently drop the chunks it left out.
|
|
12
|
+
*/
|
|
13
|
+
const createResourceReranker = (source) => {
|
|
14
|
+
const ai = source.env?.AI;
|
|
15
|
+
if (!ai)
|
|
16
|
+
return undefined;
|
|
17
|
+
return async (query, documents) => {
|
|
18
|
+
const result = (await ai.run(constants_1.constants.RESOURCE_SEARCH_RERANK_MODEL, {
|
|
19
|
+
query,
|
|
20
|
+
contexts: documents.map(text => ({ text })),
|
|
21
|
+
top_k: documents.length
|
|
22
|
+
}));
|
|
23
|
+
const scores = new Array(documents.length);
|
|
24
|
+
for (const item of result?.response ?? []) {
|
|
25
|
+
if (typeof item.id === 'number' &&
|
|
26
|
+
typeof item.score === 'number' &&
|
|
27
|
+
item.id >= 0 &&
|
|
28
|
+
item.id < documents.length) {
|
|
29
|
+
scores[item.id] = item.score;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (scores.some(score => score === undefined))
|
|
33
|
+
return null;
|
|
34
|
+
return scores;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.createResourceReranker = createResourceReranker;
|