@versini/sassysaint-common 4.12.1 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +203 -279
- package/dist/index.js +125 -314
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ declare const ALL_PROVIDERS: readonly ["OpenAI", "Anthropic", "Google"];
|
|
|
22
22
|
* List of available models TODAY.
|
|
23
23
|
*/
|
|
24
24
|
declare const MODEL_GPT5 = "gpt-5";
|
|
25
|
-
declare const
|
|
25
|
+
declare const MODEL_GPT5_MINI = "gpt-5-mini";
|
|
26
|
+
declare const MODEL_GPT5_NANO = "gpt-5-nano";
|
|
27
|
+
declare const MODEL_GPT4_NANO = "gpt-4.1-nano";
|
|
26
28
|
declare const MODEL_CLAUDE_HAIKU = "claude-haiku-4-5-20251001";
|
|
27
29
|
declare const MODEL_CLAUDE_SONNET = "claude-sonnet-4-5-20250929";
|
|
28
30
|
declare const MODEL_GEMINI_FLASH = "gemini-2.5-flash";
|
|
@@ -33,22 +35,21 @@ declare const MODEL_DEV = "mistralai/mistral-small-3.2-24b-instruct:free";
|
|
|
33
35
|
declare const MODEL_MEMORY_INFERENCE = "gpt-4o-mini";
|
|
34
36
|
declare const MODEL_EMBEDDING_TEXT = "text-embedding-3-small";
|
|
35
37
|
/**
|
|
36
|
-
* Maps model constants to user-friendly display names.
|
|
37
|
-
*
|
|
38
|
-
* settings.
|
|
38
|
+
* Maps model constants to user-friendly display names. Used by client UI to
|
|
39
|
+
* show readable model names in plan descriptions and settings.
|
|
39
40
|
*/
|
|
40
41
|
declare const MODEL_DISPLAY_NAMES: Record<string, string>;
|
|
41
42
|
/**
|
|
42
|
-
* List of all models available TODAY.
|
|
43
|
-
*
|
|
43
|
+
* List of all models available TODAY. This is used by the client to display the
|
|
44
|
+
* list of models.
|
|
44
45
|
*/
|
|
45
|
-
declare const ALL_MODELS: readonly ["gpt-5", "gpt-
|
|
46
|
+
declare const ALL_MODELS: readonly ["gpt-5", "gpt-5-mini", "gpt-5-nano", "claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929", "gemini-2.5-flash", "gemini-2.5-pro"];
|
|
46
47
|
declare const ALL_REASONING_MODELS: string[];
|
|
47
48
|
/**
|
|
48
49
|
* List of models available according to the providers.
|
|
49
50
|
*/
|
|
50
51
|
declare const MODELS_PER_PROVIDER: {
|
|
51
|
-
readonly OpenAI: readonly ["gpt-4.1-nano", "gpt-5"];
|
|
52
|
+
readonly OpenAI: readonly ["gpt-4.1-nano", "gpt-5", "gpt-5-mini", "gpt-5-nano"];
|
|
52
53
|
readonly Anthropic: readonly ["claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929"];
|
|
53
54
|
readonly Google: readonly ["gemini-2.5-flash", "gemini-2.5-pro"];
|
|
54
55
|
readonly Perplexity: readonly ["sonar", "sonar-pro"];
|
|
@@ -64,38 +65,22 @@ declare const PROVIDER_ROLE_MAP: {
|
|
|
64
65
|
Google: string[];
|
|
65
66
|
Perplexity: string[];
|
|
66
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Mapping of AI providers to their approximate model name prefixes. This
|
|
70
|
+
* enables provider identification from model names even when exact model
|
|
71
|
+
* versions change over time.
|
|
72
|
+
*/
|
|
73
|
+
declare const APPROXIMATE_MODELS_PER_PROVIDER: {
|
|
74
|
+
readonly Anthropic: readonly ["claude-sonnet-4", "claude-3"];
|
|
75
|
+
readonly OpenAI: readonly ["gpt-", "o3", "o4"];
|
|
76
|
+
readonly Google: readonly ["gemini"];
|
|
77
|
+
readonly Perplexity: readonly ["sonar"];
|
|
78
|
+
};
|
|
67
79
|
/**
|
|
68
80
|
* Header string for Diggidy Chat Id. Used to identify the chat in the server
|
|
69
81
|
* when there is a client abort.
|
|
70
82
|
*/
|
|
71
83
|
declare const DIGGIDY_CHAT_ID_HEADER = "x-diggidy-chat-id";
|
|
72
|
-
/**
|
|
73
|
-
* This function finds the provider associated with a given model name. It
|
|
74
|
-
* checks the model name against a list of approximate models for each provider.
|
|
75
|
-
*
|
|
76
|
-
* @param modelName - The model name to check.
|
|
77
|
-
* @returns The provider associated with the model name or null if not found.
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
declare const findProvider: (modelName: string) => null | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_OPENAI | typeof PROVIDER_GOOGLE;
|
|
81
|
-
/**
|
|
82
|
-
* Derives the list of available providers from a given list of models.
|
|
83
|
-
* This allows the client to automatically filter provider options based on
|
|
84
|
-
* which models are available in a user's plan.
|
|
85
|
-
*
|
|
86
|
-
* @param models - Array of model names (e.g., from allowedModels in policies).
|
|
87
|
-
* @returns Array of provider names that have at least one model available.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* // If plan only has GPT and Claude models:
|
|
91
|
-
* getProvidersFromModels([MODEL_GPT4_MINI, MODEL_CLAUDE_HAIKU])
|
|
92
|
-
* // returns: [PROVIDER_OPENAI, PROVIDER_ANTHROPIC]
|
|
93
|
-
*
|
|
94
|
-
* // If Gemini models are removed from plan:
|
|
95
|
-
* getProvidersFromModels([MODEL_GPT4_MINI, MODEL_CLAUDE_HAIKU])
|
|
96
|
-
* // Google provider will not be in the result
|
|
97
|
-
*/
|
|
98
|
-
declare const getProvidersFromModels: (models: string[]) => Array<typeof PROVIDER_OPENAI | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_GOOGLE>;
|
|
99
84
|
/**
|
|
100
85
|
* Sort capabilities are shared across client and server.
|
|
101
86
|
*/
|
|
@@ -105,245 +90,6 @@ declare const SORT_BY_TOKEN_USAGE = "tokenUsage";
|
|
|
105
90
|
* Name of the application.
|
|
106
91
|
*/
|
|
107
92
|
declare const APPLICATION_NAME = "Diggidy";
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* TypeScript interfaces for Server-Mediated Encryption.
|
|
111
|
-
*/
|
|
112
|
-
/**
|
|
113
|
-
* RSA key pair stored in memory for the current session.
|
|
114
|
-
*/
|
|
115
|
-
interface ClientCryptoKeyPair {
|
|
116
|
-
publicKey: CryptoKey;
|
|
117
|
-
privateKey: CryptoKey;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Serializable format for public key exchange with server.
|
|
121
|
-
*/
|
|
122
|
-
interface SerializablePublicKey {
|
|
123
|
-
/**
|
|
124
|
-
* Public key in JSON Web Key format.
|
|
125
|
-
*/
|
|
126
|
-
jwk: JsonWebKey;
|
|
127
|
-
/**
|
|
128
|
-
* Key type identifier.
|
|
129
|
-
*/
|
|
130
|
-
kty: "RSA";
|
|
131
|
-
/**
|
|
132
|
-
* Algorithm identifier.
|
|
133
|
-
*/
|
|
134
|
-
alg: "RSA-OAEP-256";
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Response from server's key exchange mutation.
|
|
138
|
-
*/
|
|
139
|
-
interface KeyExchangeResponse {
|
|
140
|
-
/**
|
|
141
|
-
* Server's public key in JWK format.
|
|
142
|
-
*/
|
|
143
|
-
serverPublicKey: string;
|
|
144
|
-
/**
|
|
145
|
-
* Server's key identifier for rotation tracking.
|
|
146
|
-
*/
|
|
147
|
-
keyId: string;
|
|
148
|
-
/**
|
|
149
|
-
* List of supported encryption algorithms.
|
|
150
|
-
*/
|
|
151
|
-
supportedAlgorithms: string[];
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Client crypto session state stored in memory.
|
|
155
|
-
*/
|
|
156
|
-
interface CryptoSession {
|
|
157
|
-
/**
|
|
158
|
-
* Client's RSA key pair.
|
|
159
|
-
*/
|
|
160
|
-
clientKeyPair: ClientCryptoKeyPair;
|
|
161
|
-
/**
|
|
162
|
-
* Server's public key for encryption.
|
|
163
|
-
*/
|
|
164
|
-
serverPublicKey: CryptoKey;
|
|
165
|
-
/**
|
|
166
|
-
* Unique device/session identifier.
|
|
167
|
-
*/
|
|
168
|
-
deviceId: string;
|
|
169
|
-
/**
|
|
170
|
-
* Server's key identifier.
|
|
171
|
-
*/
|
|
172
|
-
serverKeyId: string;
|
|
173
|
-
/**
|
|
174
|
-
* When this session was established.
|
|
175
|
-
*/
|
|
176
|
-
establishedAt: Date;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Encrypted message format for transport.
|
|
180
|
-
*/
|
|
181
|
-
interface EncryptedMessage {
|
|
182
|
-
/**
|
|
183
|
-
* Base64-encoded encrypted data.
|
|
184
|
-
*/
|
|
185
|
-
data: string;
|
|
186
|
-
/**
|
|
187
|
-
* Algorithm used for encryption.
|
|
188
|
-
*/
|
|
189
|
-
algorithm: "RSA-OAEP";
|
|
190
|
-
/**
|
|
191
|
-
* Key ID used for encryption.
|
|
192
|
-
*/
|
|
193
|
-
keyId: string;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Parameters for RSA key generation.
|
|
197
|
-
*/
|
|
198
|
-
interface RSAKeyGenParams {
|
|
199
|
-
/**
|
|
200
|
-
* RSA modulus length in bits.
|
|
201
|
-
*/
|
|
202
|
-
modulusLength: 2048 | 4096;
|
|
203
|
-
/**
|
|
204
|
-
* Public exponent.
|
|
205
|
-
*/
|
|
206
|
-
publicExponent: Uint8Array;
|
|
207
|
-
/**
|
|
208
|
-
* Hash algorithm for OAEP.
|
|
209
|
-
*/
|
|
210
|
-
hash: "SHA-256";
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Error types for crypto operations.
|
|
214
|
-
*/
|
|
215
|
-
declare class CryptoError extends Error {
|
|
216
|
-
readonly code: "KEY_GENERATION_FAILED" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "KEY_IMPORT_FAILED" | "INVALID_KEY_FORMAT";
|
|
217
|
-
readonly originalError?: Error | undefined;
|
|
218
|
-
constructor(message: string, code: "KEY_GENERATION_FAILED" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "KEY_IMPORT_FAILED" | "INVALID_KEY_FORMAT", originalError?: Error | undefined);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Configuration options for crypto operations.
|
|
222
|
-
*/
|
|
223
|
-
interface CryptoConfig {
|
|
224
|
-
/**
|
|
225
|
-
* RSA key size in bits.
|
|
226
|
-
*/
|
|
227
|
-
keySize: 2048 | 4096;
|
|
228
|
-
/**
|
|
229
|
-
* Enable debug logging.
|
|
230
|
-
*/
|
|
231
|
-
debug: boolean;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Default crypto configuration.
|
|
235
|
-
*/
|
|
236
|
-
declare const DEFAULT_CRYPTO_CONFIG: CryptoConfig;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Generate a new RSA key pair for the current session.
|
|
240
|
-
*/
|
|
241
|
-
declare function generateClientKeyPair(config?: Partial<CryptoConfig>): Promise<ClientCryptoKeyPair>;
|
|
242
|
-
/**
|
|
243
|
-
* Export public key to serializable format for server exchange.
|
|
244
|
-
*/
|
|
245
|
-
declare function exportPublicKey(publicKey: CryptoKey): Promise<SerializablePublicKey>;
|
|
246
|
-
/**
|
|
247
|
-
* Import server's public key from JWK format.
|
|
248
|
-
*/
|
|
249
|
-
declare function importServerPublicKey(serverPublicKeyJWK: string): Promise<CryptoKey>;
|
|
250
|
-
/**
|
|
251
|
-
* Encrypt message for transmission to server.
|
|
252
|
-
*/
|
|
253
|
-
declare function encryptForServer(message: string, serverPublicKey: CryptoKey, serverKeyId: string): Promise<EncryptedMessage>;
|
|
254
|
-
/**
|
|
255
|
-
* Decrypt message received from server.
|
|
256
|
-
*/
|
|
257
|
-
declare function decryptFromServer(encryptedMessage: EncryptedMessage, clientPrivateKey: CryptoKey): Promise<string>;
|
|
258
|
-
/**
|
|
259
|
-
* Create a complete crypto session with key exchange.
|
|
260
|
-
*/
|
|
261
|
-
declare function establishCryptoSession(keyExchangeResponse: KeyExchangeResponse, clientKeyPair: ClientCryptoKeyPair, deviceId: string): Promise<CryptoSession>;
|
|
262
|
-
/**
|
|
263
|
-
* Validate that a crypto session is still valid.
|
|
264
|
-
*/
|
|
265
|
-
declare function isCryptoSessionValid(session: CryptoSession): boolean;
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Utility functions for crypto operations.
|
|
269
|
-
*/
|
|
270
|
-
/**
|
|
271
|
-
* Generate a unique device ID for this session.
|
|
272
|
-
*/
|
|
273
|
-
declare function generateDeviceId(): string;
|
|
274
|
-
/**
|
|
275
|
-
* Check if the current environment supports Web Crypto API.
|
|
276
|
-
*/
|
|
277
|
-
declare function isWebCryptoSupported(): boolean;
|
|
278
|
-
/**
|
|
279
|
-
* Validate that we're in a secure context (required for Web Crypto API).
|
|
280
|
-
*/
|
|
281
|
-
declare function isSecureContext(): boolean;
|
|
282
|
-
/**
|
|
283
|
-
* Check if encryption is available in the current environment.
|
|
284
|
-
*/
|
|
285
|
-
declare function canUseEncryption(): boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Convert ArrayBuffer to base64 string.
|
|
288
|
-
*/
|
|
289
|
-
declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|
|
290
|
-
/**
|
|
291
|
-
* Convert base64 string to ArrayBuffer.
|
|
292
|
-
*/
|
|
293
|
-
declare function base64ToArrayBuffer(base64: string): ArrayBuffer;
|
|
294
|
-
/**
|
|
295
|
-
* Safely stringify JSON with error handling.
|
|
296
|
-
*/
|
|
297
|
-
declare function safeStringify(obj: unknown): string;
|
|
298
|
-
/**
|
|
299
|
-
* Safely parse JSON with error handling.
|
|
300
|
-
*/
|
|
301
|
-
declare function safeParse<T = unknown>(json: string): T | null;
|
|
302
|
-
/**
|
|
303
|
-
* Debug logger for crypto operations (only in development).
|
|
304
|
-
*
|
|
305
|
-
* ⚠️ SECURITY WARNING: Never log sensitive data such as:
|
|
306
|
-
* - Private or public key objects
|
|
307
|
-
* - Encrypted or decrypted data
|
|
308
|
-
* - Raw cryptographic material
|
|
309
|
-
* - Device IDs or session identifiers
|
|
310
|
-
*
|
|
311
|
-
* Only log non-sensitive metadata like algorithms, key sizes, operation status,
|
|
312
|
-
* etc.
|
|
313
|
-
*
|
|
314
|
-
*/
|
|
315
|
-
declare function debugLog(message: string, ...args: unknown[]): void;
|
|
316
|
-
|
|
317
|
-
type index_ClientCryptoKeyPair = ClientCryptoKeyPair;
|
|
318
|
-
type index_CryptoConfig = CryptoConfig;
|
|
319
|
-
type index_CryptoError = CryptoError;
|
|
320
|
-
declare const index_CryptoError: typeof CryptoError;
|
|
321
|
-
type index_CryptoSession = CryptoSession;
|
|
322
|
-
declare const index_DEFAULT_CRYPTO_CONFIG: typeof DEFAULT_CRYPTO_CONFIG;
|
|
323
|
-
type index_EncryptedMessage = EncryptedMessage;
|
|
324
|
-
type index_KeyExchangeResponse = KeyExchangeResponse;
|
|
325
|
-
type index_RSAKeyGenParams = RSAKeyGenParams;
|
|
326
|
-
type index_SerializablePublicKey = SerializablePublicKey;
|
|
327
|
-
declare const index_arrayBufferToBase64: typeof arrayBufferToBase64;
|
|
328
|
-
declare const index_base64ToArrayBuffer: typeof base64ToArrayBuffer;
|
|
329
|
-
declare const index_canUseEncryption: typeof canUseEncryption;
|
|
330
|
-
declare const index_debugLog: typeof debugLog;
|
|
331
|
-
declare const index_decryptFromServer: typeof decryptFromServer;
|
|
332
|
-
declare const index_encryptForServer: typeof encryptForServer;
|
|
333
|
-
declare const index_establishCryptoSession: typeof establishCryptoSession;
|
|
334
|
-
declare const index_exportPublicKey: typeof exportPublicKey;
|
|
335
|
-
declare const index_generateClientKeyPair: typeof generateClientKeyPair;
|
|
336
|
-
declare const index_generateDeviceId: typeof generateDeviceId;
|
|
337
|
-
declare const index_importServerPublicKey: typeof importServerPublicKey;
|
|
338
|
-
declare const index_isCryptoSessionValid: typeof isCryptoSessionValid;
|
|
339
|
-
declare const index_isSecureContext: typeof isSecureContext;
|
|
340
|
-
declare const index_isWebCryptoSupported: typeof isWebCryptoSupported;
|
|
341
|
-
declare const index_safeParse: typeof safeParse;
|
|
342
|
-
declare const index_safeStringify: typeof safeStringify;
|
|
343
|
-
declare namespace index {
|
|
344
|
-
export { type index_ClientCryptoKeyPair as ClientCryptoKeyPair, type index_CryptoConfig as CryptoConfig, index_CryptoError as CryptoError, type index_CryptoSession as CryptoSession, index_DEFAULT_CRYPTO_CONFIG as DEFAULT_CRYPTO_CONFIG, type index_EncryptedMessage as EncryptedMessage, type index_KeyExchangeResponse as KeyExchangeResponse, type index_RSAKeyGenParams as RSAKeyGenParams, type index_SerializablePublicKey as SerializablePublicKey, index_arrayBufferToBase64 as arrayBufferToBase64, index_base64ToArrayBuffer as base64ToArrayBuffer, index_canUseEncryption as canUseEncryption, index_debugLog as debugLog, index_decryptFromServer as decryptFromServer, index_encryptForServer as encryptForServer, index_establishCryptoSession as establishCryptoSession, index_exportPublicKey as exportPublicKey, index_generateClientKeyPair as generateClientKeyPair, index_generateDeviceId as generateDeviceId, index_importServerPublicKey as importServerPublicKey, index_isCryptoSessionValid as isCryptoSessionValid, index_isSecureContext as isSecureContext, index_isWebCryptoSupported as isWebCryptoSupported, index_safeParse as safeParse, index_safeStringify as safeStringify };
|
|
345
|
-
}
|
|
346
|
-
|
|
347
93
|
/**
|
|
348
94
|
* List of all plans available.
|
|
349
95
|
*/
|
|
@@ -374,28 +120,206 @@ declare const CAPABILITIES: {
|
|
|
374
120
|
readonly CODEINTERPRETER: "addon:codeinterpreter";
|
|
375
121
|
};
|
|
376
122
|
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Identifies the AI provider associated with a given model name by matching
|
|
126
|
+
* against known model prefixes. This function provides backward compatibility
|
|
127
|
+
* for older model naming schemes while correctly identifying the provider.
|
|
128
|
+
*
|
|
129
|
+
* The function iterates through approximate model prefixes for each provider
|
|
130
|
+
* and returns the first matching provider. This approach handles cases where
|
|
131
|
+
* model version numbers change but the provider remains the same.
|
|
132
|
+
*
|
|
133
|
+
* @param modelName - The full model name to identify (e.g.,
|
|
134
|
+
* "claude-3-5-sonnet-20241022").
|
|
135
|
+
* @returns The provider constant (PROVIDER_ANTHROPIC, PROVIDER_OPENAI, or
|
|
136
|
+
* PROVIDER_GOOGLE) if a match is found, or null if no provider matches.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* findProvider("claude-3-5-sonnet-latest"); // Returns PROVIDER_ANTHROPIC
|
|
141
|
+
* findProvider("gpt-4-turbo"); // Returns PROVIDER_OPENAI
|
|
142
|
+
* findProvider("gemini-1.5-pro"); // Returns PROVIDER_GOOGLE
|
|
143
|
+
* findProvider("unknown-model"); // Returns null
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
declare const findProvider: (modelName: string) => null | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_OPENAI | typeof PROVIDER_GOOGLE;
|
|
148
|
+
/**
|
|
149
|
+
* Derives the list of available AI providers from a given array of model names.
|
|
150
|
+
* This function enables automatic filtering of provider options in the UI based
|
|
151
|
+
* on which models are available in a user's subscription plan.
|
|
152
|
+
*
|
|
153
|
+
* The function cross-references each model against the MODELS_PER_PROVIDER
|
|
154
|
+
* mapping to determine which providers should be available. Results are
|
|
155
|
+
* returned in a consistent order matching ALL_PROVIDERS to ensure UI stability.
|
|
156
|
+
*
|
|
157
|
+
* @param models - Array of model names available to the user (e.g., from
|
|
158
|
+
* allowedModels in policy configuration).
|
|
159
|
+
* @returns Array of provider constants (PROVIDER_OPENAI, PROVIDER_ANTHROPIC,
|
|
160
|
+
* PROVIDER_GOOGLE) that have at least one available model. Returns empty
|
|
161
|
+
* array if no models are provided.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* // User's plan includes GPT and Claude models:
|
|
166
|
+
* getProvidersFromModels([MODEL_GPT4_NANO, MODEL_CLAUDE_HAIKU]);
|
|
167
|
+
* // Returns: [PROVIDER_OPENAI, PROVIDER_ANTHROPIC]
|
|
168
|
+
*
|
|
169
|
+
* // Gemini models removed from plan:
|
|
170
|
+
* getProvidersFromModels([MODEL_GPT4_NANO, MODEL_CLAUDE_HAIKU]);
|
|
171
|
+
* // Returns: [PROVIDER_OPENAI, PROVIDER_ANTHROPIC]
|
|
172
|
+
* // (PROVIDER_GOOGLE is excluded)
|
|
173
|
+
*
|
|
174
|
+
* // Empty models array:
|
|
175
|
+
* getProvidersFromModels([]);
|
|
176
|
+
* // Returns: []
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
*/
|
|
180
|
+
declare const getProvidersFromModels: (models: string[]) => Array<typeof PROVIDER_OPENAI | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_GOOGLE>;
|
|
377
181
|
/**
|
|
378
|
-
*
|
|
182
|
+
* Input type for capability checks. Can be a single capability string or an
|
|
183
|
+
* array of capability strings for checking multiple capabilities at once.
|
|
379
184
|
*/
|
|
380
185
|
type CapabilityInput = string | readonly string[];
|
|
186
|
+
/**
|
|
187
|
+
* Configuration options for the isEntitled function to control how capability
|
|
188
|
+
* checks are evaluated.
|
|
189
|
+
*/
|
|
381
190
|
interface IsEntitledOptions {
|
|
382
191
|
/**
|
|
383
|
-
*
|
|
384
|
-
* ALL
|
|
192
|
+
* When true, grants entitlement if ANY of the required capabilities match
|
|
193
|
+
* (logical OR). When false (default), requires ALL capabilities to match
|
|
194
|
+
* (logical AND).
|
|
385
195
|
*/
|
|
386
196
|
any?: boolean;
|
|
387
197
|
/**
|
|
388
|
-
* Pre-
|
|
198
|
+
* Pre-computed capability Set for performance optimization. If provided, skips
|
|
199
|
+
* building a new Set from the capabilities array.
|
|
389
200
|
*/
|
|
390
201
|
set?: Set<string>;
|
|
391
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Represents the shape of an entitlement state object, used for checking
|
|
205
|
+
* capability loading status. This interface is intentionally flexible to work
|
|
206
|
+
* with various entitlement state implementations across client and server.
|
|
207
|
+
*/
|
|
392
208
|
interface EntitlementStateLike {
|
|
209
|
+
/**
|
|
210
|
+
* Array of capability strings granted to the user.
|
|
211
|
+
*/
|
|
393
212
|
capabilities?: string[];
|
|
213
|
+
/**
|
|
214
|
+
* Version number of the entitlement state for cache invalidation.
|
|
215
|
+
*/
|
|
394
216
|
version?: number;
|
|
217
|
+
/**
|
|
218
|
+
* Current status of the entitlement (e.g., "active", "expired").
|
|
219
|
+
*/
|
|
395
220
|
status?: string;
|
|
396
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Checks whether an entitlement state object has been successfully loaded and
|
|
224
|
+
* contains valid capability data. This function verifies the state is defined
|
|
225
|
+
* and has a capabilities array (even if empty).
|
|
226
|
+
*
|
|
227
|
+
* Use this function before performing capability checks to ensure the
|
|
228
|
+
* entitlement data is available and initialized properly.
|
|
229
|
+
*
|
|
230
|
+
* @param state - The entitlement state object to check, which may be null or
|
|
231
|
+
* undefined during initial loading.
|
|
232
|
+
* @returns True if the state is loaded and contains a capabilities array,
|
|
233
|
+
* false otherwise.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const entitlementState = await fetchEntitlements();
|
|
238
|
+
* if (isEntitlementLoaded(entitlementState)) {
|
|
239
|
+
* // Safe to check capabilities
|
|
240
|
+
* const hasFeature = isEntitled(entitlementState.capabilities, "premium");
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
*/
|
|
397
245
|
declare function isEntitlementLoaded(state: EntitlementStateLike | null | undefined): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Converts an array of capability strings into a Set for efficient lookup
|
|
248
|
+
* operations. Returns null if the input is null, undefined, or not an array.
|
|
249
|
+
*
|
|
250
|
+
* Using a Set for capability checks provides O(1) lookup performance compared
|
|
251
|
+
* to O(n) for array includes, which is beneficial when checking multiple
|
|
252
|
+
* capabilities or performing frequent checks.
|
|
253
|
+
*
|
|
254
|
+
* @param capabilities - Array of capability strings to convert, or null/
|
|
255
|
+
* undefined.
|
|
256
|
+
* @returns A Set containing the capability strings, or null if input is
|
|
257
|
+
* invalid.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* const caps = ["read:posts", "write:posts", "admin"];
|
|
262
|
+
* const capSet = toCapabilitySet(caps);
|
|
263
|
+
* // capSet.has("read:posts") is now O(1) instead of O(n)
|
|
264
|
+
*
|
|
265
|
+
* toCapabilitySet(null); // Returns null
|
|
266
|
+
* toCapabilitySet(undefined); // Returns null
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
*/
|
|
398
270
|
declare function toCapabilitySet(capabilities: string[] | undefined | null): Set<string> | null;
|
|
271
|
+
/**
|
|
272
|
+
* Checks whether a user has the required capability or capabilities based on
|
|
273
|
+
* their entitlement. This function is used throughout the application to
|
|
274
|
+
* control access to features based on subscription plans or permission levels.
|
|
275
|
+
*
|
|
276
|
+
* The function supports multiple modes of operation:
|
|
277
|
+
* - Single capability check: Pass a string to check one capability
|
|
278
|
+
* - Multiple capability check (AND): Pass an array to require ALL capabilities
|
|
279
|
+
* - Multiple capability check (OR): Pass an array with options.any=true to
|
|
280
|
+
* require ANY capability
|
|
281
|
+
* - Performance optimization: Pass a pre-computed Set via options.set
|
|
282
|
+
*
|
|
283
|
+
* An empty requirements array or empty string always returns true, treating it
|
|
284
|
+
* as "no specific entitlement required".
|
|
285
|
+
*
|
|
286
|
+
* @param capabilitiesOrSet - User's capabilities as an array, a Set, or null/
|
|
287
|
+
* undefined if not loaded.
|
|
288
|
+
* @param required - The capability or capabilities to check. Can be a single
|
|
289
|
+
* string or an array of strings.
|
|
290
|
+
* @param options - Optional configuration for the check behavior (any mode, pre-
|
|
291
|
+
* computed Set).
|
|
292
|
+
* @returns True if the user has the required capability/capabilities according
|
|
293
|
+
* to the specified logic, false otherwise.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const userCaps = ["read:posts", "write:posts"];
|
|
298
|
+
*
|
|
299
|
+
* // Single capability check:
|
|
300
|
+
* isEntitled(userCaps, "read:posts"); // true
|
|
301
|
+
* isEntitled(userCaps, "admin"); // false
|
|
302
|
+
*
|
|
303
|
+
* // Multiple capabilities (AND - all required):
|
|
304
|
+
* isEntitled(userCaps, ["read:posts", "write:posts"]); // true
|
|
305
|
+
* isEntitled(userCaps, ["read:posts", "admin"]); // false
|
|
306
|
+
*
|
|
307
|
+
* // Multiple capabilities (OR - any required):
|
|
308
|
+
* isEntitled(userCaps, ["admin", "read:posts"], { any: true }); // true
|
|
309
|
+
* isEntitled(userCaps, ["admin", "super:user"], { any: true }); // false
|
|
310
|
+
*
|
|
311
|
+
* // Performance optimization with pre-computed Set:
|
|
312
|
+
* const capSet = toCapabilitySet(userCaps);
|
|
313
|
+
* isEntitled(capSet, "read:posts"); // true (faster lookup)
|
|
314
|
+
*
|
|
315
|
+
* // Edge cases:
|
|
316
|
+
* isEntitled(userCaps, ""); // true (no requirement)
|
|
317
|
+
* isEntitled(userCaps, []); // true (no requirement)
|
|
318
|
+
* isEntitled(null, "read:posts"); // false (no capabilities)
|
|
319
|
+
* isEntitled([], "read:posts"); // false (empty capabilities)
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
*/
|
|
399
323
|
declare function isEntitled(capabilitiesOrSet: string[] | Set<string> | null | undefined, required: CapabilityInput, options?: IsEntitledOptions): boolean;
|
|
400
324
|
|
|
401
|
-
export { ALL_MODELS, ALL_PROVIDERS, ALL_REASONING_MODELS, APPLICATION_NAME, CAPABILITIES, type CapabilityInput, DEFAULT_PROVIDER, DIGGIDY_CHAT_ID_HEADER, type EntitlementStateLike, type IsEntitledOptions, MODELS_PER_PROVIDER, MODEL_CLAUDE_HAIKU, MODEL_CLAUDE_SONNET, MODEL_DEV, MODEL_DISPLAY_NAMES, MODEL_EMBEDDING_TEXT, MODEL_GEMINI_FLASH, MODEL_GEMINI_PRO,
|
|
325
|
+
export { ALL_MODELS, ALL_PROVIDERS, ALL_REASONING_MODELS, APPLICATION_NAME, APPROXIMATE_MODELS_PER_PROVIDER, CAPABILITIES, type CapabilityInput, DEFAULT_PROVIDER, DIGGIDY_CHAT_ID_HEADER, type EntitlementStateLike, type IsEntitledOptions, MODELS_PER_PROVIDER, MODEL_CLAUDE_HAIKU, MODEL_CLAUDE_SONNET, MODEL_DEV, MODEL_DISPLAY_NAMES, MODEL_EMBEDDING_TEXT, MODEL_GEMINI_FLASH, MODEL_GEMINI_PRO, MODEL_GPT4_NANO, MODEL_GPT5, MODEL_GPT5_MINI, MODEL_GPT5_NANO, MODEL_MEMORY_INFERENCE, MODEL_SONAR, MODEL_SONAR_PRO, PLAN_BASIC, PLAN_PLUS, PLAN_PREMIUM, PROVIDER_ANTHROPIC, PROVIDER_GOOGLE, PROVIDER_MEMORY, PROVIDER_MISTRAL, PROVIDER_OPENAI, PROVIDER_PERPLEXITY, PROVIDER_ROLE_MAP, PROVIDER_SUMMARY, ROLE_ASSISTANT, ROLE_HIDDEN, ROLE_INTERNAL, ROLE_SYSTEM, ROLE_USER, SORT_BY_TIMESTAMP, SORT_BY_TOKEN_USAGE, findProvider, getProvidersFromModels, isEntitled, isEntitlementLoaded, toCapabilitySet };
|
package/dist/index.js
CHANGED
|
@@ -1,270 +1,62 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
y,
|
|
4
|
-
d
|
|
5
|
-
], u = "gpt-5", p = "gpt-4.1-nano", f = "claude-haiku-4-5-20251001", A = "claude-sonnet-4-5-20250929", _ = "gemini-2.5-flash", l = "gemini-2.5-pro", R = "sonar", P = "sonar-pro", re = "mistralai/mistral-small-3.2-24b-instruct:free", oe = "gpt-4o-mini", se = "text-embedding-3-small", ae = {
|
|
6
|
-
[u]: "GPT-5",
|
|
7
|
-
[p]: "GPT-4.1 Nano",
|
|
8
|
-
[f]: "Claude Haiku 4.5",
|
|
9
|
-
[A]: "Claude Sonnet 4.5",
|
|
10
|
-
[_]: "Gemini 2.5 Flash",
|
|
11
|
-
[l]: "Gemini 2.5 Pro",
|
|
12
|
-
[R]: "Sonar",
|
|
13
|
-
[P]: "Sonar Pro"
|
|
14
|
-
}, ie = [
|
|
15
|
-
u,
|
|
16
|
-
p,
|
|
17
|
-
f,
|
|
18
|
-
A,
|
|
1
|
+
const l = "system", E = "user", e = "assistant", X = "hidden", Y = "data", O = "OpenAI", _ = "Anthropic", c = "Google", d = "Summary", g = "Memory", M = "Perplexity", v = "Mistral", b = O, m = [
|
|
2
|
+
O,
|
|
19
3
|
_,
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
|
|
4
|
+
c
|
|
5
|
+
], A = "gpt-5", R = "gpt-5-mini", r = "gpt-5-nano", T = "gpt-4.1-nano", I = "claude-haiku-4-5-20251001", i = "claude-sonnet-4-5-20250929", D = "gemini-2.5-flash", a = "gemini-2.5-pro", S = "sonar", N = "sonar-pro", B = "mistralai/mistral-small-3.2-24b-instruct:free", F = "gpt-4o-mini", W = "text-embedding-3-small", x = {
|
|
6
|
+
[A]: "GPT-5",
|
|
7
|
+
[R]: "GPT-5 Mini",
|
|
8
|
+
[r]: "GPT-5 Nano",
|
|
9
|
+
[T]: "GPT-4.1 Nano",
|
|
10
|
+
[I]: "Claude Haiku 4.5",
|
|
11
|
+
[i]: "Claude Sonnet 4.5",
|
|
12
|
+
[D]: "Gemini 2.5 Flash",
|
|
13
|
+
[a]: "Gemini 2.5 Pro",
|
|
14
|
+
[S]: "Sonar",
|
|
15
|
+
[N]: "Sonar Pro"
|
|
16
|
+
}, k = [
|
|
23
17
|
A,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
R,
|
|
19
|
+
r,
|
|
20
|
+
I,
|
|
21
|
+
i,
|
|
22
|
+
D,
|
|
23
|
+
a
|
|
24
|
+
], j = [
|
|
25
|
+
A,
|
|
26
|
+
R,
|
|
27
|
+
r,
|
|
28
|
+
i,
|
|
29
|
+
a
|
|
30
|
+
], u = {
|
|
31
|
+
[O]: [
|
|
32
|
+
T,
|
|
33
|
+
A,
|
|
34
|
+
R,
|
|
35
|
+
r
|
|
29
36
|
],
|
|
30
|
-
[
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
[_]: [I, i],
|
|
38
|
+
[c]: [D, a],
|
|
39
|
+
[M]: [S, N]
|
|
40
|
+
}, w = {
|
|
41
|
+
[O]: [l, E, e],
|
|
42
|
+
[_]: [E, e],
|
|
43
|
+
[d]: [E, e],
|
|
44
|
+
[g]: [E, e],
|
|
45
|
+
[c]: [E, e],
|
|
46
|
+
[M]: [E, e]
|
|
47
|
+
}, G = "claude-sonnet-4", f = "claude-3", p = "gpt-", y = "o3", h = "o4", C = "gemini", U = "sonar", H = {
|
|
48
|
+
[_]: [
|
|
49
|
+
G,
|
|
50
|
+
f
|
|
34
51
|
],
|
|
35
|
-
[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
},
|
|
43
|
-
[c]: [L, a, i],
|
|
44
|
-
[y]: [a, i],
|
|
45
|
-
[M]: [a, i],
|
|
46
|
-
[T]: [a, i],
|
|
47
|
-
[d]: [a, i],
|
|
48
|
-
[O]: [a, i]
|
|
49
|
-
}, ye = "x-diggidy-chat-id", de = (n) => {
|
|
50
|
-
for (const [e, r] of Object.entries(
|
|
51
|
-
K
|
|
52
|
-
))
|
|
53
|
-
if (r.some((t) => n.startsWith(t)))
|
|
54
|
-
return e;
|
|
55
|
-
return null;
|
|
56
|
-
}, ue = (n) => {
|
|
57
|
-
if (!n || n.length === 0)
|
|
58
|
-
return [];
|
|
59
|
-
const e = /* @__PURE__ */ new Set();
|
|
60
|
-
for (const r of n)
|
|
61
|
-
for (const [t, E] of Object.entries(
|
|
62
|
-
k
|
|
63
|
-
))
|
|
64
|
-
E.includes(r) && (t === c || t === y || t === d) && e.add(t);
|
|
65
|
-
return m.filter((r) => e.has(r));
|
|
66
|
-
}, Ae = "timestamp", le = "tokenUsage", Oe = "Diggidy";
|
|
67
|
-
class s extends Error {
|
|
68
|
-
constructor(e, r, t) {
|
|
69
|
-
super(e), this.code = r, this.originalError = t, this.name = "CryptoError";
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const S = {
|
|
73
|
-
keySize: 4096,
|
|
74
|
-
debug: !1
|
|
75
|
-
};
|
|
76
|
-
async function G(n = {}) {
|
|
77
|
-
const e = { ...S, ...n };
|
|
78
|
-
try {
|
|
79
|
-
const r = {
|
|
80
|
-
modulusLength: e.keySize,
|
|
81
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
82
|
-
// 65537
|
|
83
|
-
hash: "SHA-256"
|
|
84
|
-
}, t = await crypto.subtle.generateKey(
|
|
85
|
-
{
|
|
86
|
-
name: "RSA-OAEP",
|
|
87
|
-
...r
|
|
88
|
-
},
|
|
89
|
-
!0,
|
|
90
|
-
// extractable for public key export
|
|
91
|
-
["encrypt", "decrypt"]
|
|
92
|
-
);
|
|
93
|
-
return e.debug && console.info("🔐 Generated RSA key pair:", {
|
|
94
|
-
keySize: e.keySize,
|
|
95
|
-
algorithm: "RSA-OAEP",
|
|
96
|
-
hash: "SHA-256",
|
|
97
|
-
publicKeyType: t.publicKey.type,
|
|
98
|
-
privateKeyType: t.privateKey.type,
|
|
99
|
-
publicKeyUsages: t.publicKey.usages,
|
|
100
|
-
privateKeyUsages: t.privateKey.usages
|
|
101
|
-
}), {
|
|
102
|
-
publicKey: t.publicKey,
|
|
103
|
-
privateKey: t.privateKey
|
|
104
|
-
};
|
|
105
|
-
} catch (r) {
|
|
106
|
-
throw new s(
|
|
107
|
-
`Failed to generate RSA key pair: ${r instanceof Error ? r.message : "Unknown error"}`,
|
|
108
|
-
"KEY_GENERATION_FAILED",
|
|
109
|
-
r instanceof Error ? r : void 0
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
async function F(n) {
|
|
114
|
-
try {
|
|
115
|
-
return {
|
|
116
|
-
jwk: await crypto.subtle.exportKey("jwk", n),
|
|
117
|
-
kty: "RSA",
|
|
118
|
-
alg: "RSA-OAEP-256"
|
|
119
|
-
};
|
|
120
|
-
} catch (e) {
|
|
121
|
-
throw new s(
|
|
122
|
-
`Failed to export public key: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
123
|
-
"KEY_IMPORT_FAILED",
|
|
124
|
-
e instanceof Error ? e : void 0
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function I(n) {
|
|
129
|
-
try {
|
|
130
|
-
const e = JSON.parse(n);
|
|
131
|
-
return await crypto.subtle.importKey(
|
|
132
|
-
"jwk",
|
|
133
|
-
e,
|
|
134
|
-
{
|
|
135
|
-
name: "RSA-OAEP",
|
|
136
|
-
hash: "SHA-256"
|
|
137
|
-
},
|
|
138
|
-
!1,
|
|
139
|
-
// not extractable
|
|
140
|
-
["encrypt"]
|
|
141
|
-
);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
throw new s(
|
|
144
|
-
`Failed to import server public key: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
145
|
-
"KEY_IMPORT_FAILED",
|
|
146
|
-
e instanceof Error ? e : void 0
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async function V(n, e, r) {
|
|
151
|
-
try {
|
|
152
|
-
const E = new TextEncoder().encode(n), o = await crypto.subtle.encrypt(
|
|
153
|
-
{
|
|
154
|
-
name: "RSA-OAEP"
|
|
155
|
-
},
|
|
156
|
-
e,
|
|
157
|
-
E
|
|
158
|
-
);
|
|
159
|
-
return {
|
|
160
|
-
data: btoa(
|
|
161
|
-
String.fromCharCode(...new Uint8Array(o))
|
|
162
|
-
),
|
|
163
|
-
algorithm: "RSA-OAEP",
|
|
164
|
-
keyId: r
|
|
165
|
-
};
|
|
166
|
-
} catch (t) {
|
|
167
|
-
throw new s(
|
|
168
|
-
`Failed to encrypt message for server: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
169
|
-
"ENCRYPTION_FAILED",
|
|
170
|
-
t instanceof Error ? t : void 0
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
async function Y(n, e) {
|
|
175
|
-
try {
|
|
176
|
-
const r = Uint8Array.from(
|
|
177
|
-
atob(n.data),
|
|
178
|
-
(o) => o.charCodeAt(0)
|
|
179
|
-
), t = await crypto.subtle.decrypt(
|
|
180
|
-
{
|
|
181
|
-
name: "RSA-OAEP"
|
|
182
|
-
},
|
|
183
|
-
e,
|
|
184
|
-
r
|
|
185
|
-
);
|
|
186
|
-
return new TextDecoder().decode(t);
|
|
187
|
-
} catch (r) {
|
|
188
|
-
throw new s(
|
|
189
|
-
`Failed to decrypt message from server: ${r instanceof Error ? r.message : "Unknown error"}`,
|
|
190
|
-
"DECRYPTION_FAILED",
|
|
191
|
-
r instanceof Error ? r : void 0
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async function H(n, e, r) {
|
|
196
|
-
try {
|
|
197
|
-
const t = await I(
|
|
198
|
-
n.serverPublicKey
|
|
199
|
-
);
|
|
200
|
-
return {
|
|
201
|
-
clientKeyPair: e,
|
|
202
|
-
serverPublicKey: t,
|
|
203
|
-
deviceId: r,
|
|
204
|
-
serverKeyId: n.keyId,
|
|
205
|
-
establishedAt: /* @__PURE__ */ new Date()
|
|
206
|
-
};
|
|
207
|
-
} catch (t) {
|
|
208
|
-
throw new s(
|
|
209
|
-
`Failed to establish crypto session: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
210
|
-
"KEY_IMPORT_FAILED",
|
|
211
|
-
t instanceof Error ? t : void 0
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function x(n) {
|
|
216
|
-
return !(!n || !n.clientKeyPair || !n.serverPublicKey);
|
|
217
|
-
}
|
|
218
|
-
function B() {
|
|
219
|
-
const n = Date.now().toString(36), e = new Uint8Array(8);
|
|
220
|
-
if (typeof window < "u" && window.crypto?.getRandomValues)
|
|
221
|
-
window.crypto.getRandomValues(e);
|
|
222
|
-
else
|
|
223
|
-
for (let t = 0; t < e.length; t++)
|
|
224
|
-
e[t] = Math.floor(Math.random() * 256);
|
|
225
|
-
const r = Array.from(e).map((t) => t.toString(36)).join("");
|
|
226
|
-
return `device_${n}_${r}`;
|
|
227
|
-
}
|
|
228
|
-
function D() {
|
|
229
|
-
return typeof window < "u" && typeof window.crypto < "u" && typeof window.crypto.subtle < "u";
|
|
230
|
-
}
|
|
231
|
-
function g() {
|
|
232
|
-
return typeof window < "u" && (window.isSecureContext || window.location.protocol === "https:");
|
|
233
|
-
}
|
|
234
|
-
function X() {
|
|
235
|
-
return D() && g();
|
|
236
|
-
}
|
|
237
|
-
function j(n) {
|
|
238
|
-
const e = new Uint8Array(n);
|
|
239
|
-
let r = "";
|
|
240
|
-
for (let t = 0; t < e.byteLength; t++)
|
|
241
|
-
r += String.fromCharCode(e[t]);
|
|
242
|
-
return btoa(r);
|
|
243
|
-
}
|
|
244
|
-
function $(n) {
|
|
245
|
-
const e = atob(n), r = new Uint8Array(e.length);
|
|
246
|
-
for (let t = 0; t < e.length; t++)
|
|
247
|
-
r[t] = e.charCodeAt(t);
|
|
248
|
-
return r.buffer;
|
|
249
|
-
}
|
|
250
|
-
function z(n) {
|
|
251
|
-
try {
|
|
252
|
-
return JSON.stringify(n);
|
|
253
|
-
} catch {
|
|
254
|
-
return String(n);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function W(n) {
|
|
258
|
-
try {
|
|
259
|
-
return JSON.parse(n);
|
|
260
|
-
} catch {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function J(n, ...e) {
|
|
265
|
-
typeof process < "u" && process.env && process.env.NODE_ENV === "development" && console.info(`🔐 [Crypto] ${n}`, ...e);
|
|
266
|
-
}
|
|
267
|
-
const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, CryptoError: s, DEFAULT_CRYPTO_CONFIG: S, arrayBufferToBase64: j, base64ToArrayBuffer: $, canUseEncryption: X, debugLog: J, decryptFromServer: Y, encryptForServer: V, establishCryptoSession: H, exportPublicKey: F, generateClientKeyPair: G, generateDeviceId: B, importServerPublicKey: I, isCryptoSessionValid: x, isSecureContext: g, isWebCryptoSupported: D, safeParse: W, safeStringify: z }, Symbol.toStringTag, { value: "Module" })), fe = "sassy:basic", _e = "sassy:plus", Re = "sassy:advanced", Pe = {
|
|
52
|
+
[O]: [
|
|
53
|
+
p,
|
|
54
|
+
y,
|
|
55
|
+
h
|
|
56
|
+
],
|
|
57
|
+
[c]: [C],
|
|
58
|
+
[M]: [U]
|
|
59
|
+
}, z = "x-diggidy-chat-id", K = "timestamp", Z = "tokenUsage", J = "Diggidy", Q = "sassy:basic", $ = "sassy:plus", q = "sassy:advanced", tt = {
|
|
268
60
|
TOOL: {
|
|
269
61
|
DATETIME: "getDateTime",
|
|
270
62
|
IMAGES: "getImages",
|
|
@@ -282,62 +74,81 @@ const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
282
74
|
REASONING: "addon:reasoning",
|
|
283
75
|
CODEINTERPRETER: "addon:codeinterpreter"
|
|
284
76
|
}
|
|
77
|
+
}, nt = (t) => {
|
|
78
|
+
for (const [n, s] of Object.entries(
|
|
79
|
+
H
|
|
80
|
+
))
|
|
81
|
+
if (s.some((o) => t.startsWith(o)))
|
|
82
|
+
return n;
|
|
83
|
+
return null;
|
|
84
|
+
}, ot = (t) => {
|
|
85
|
+
if (!t || t.length === 0)
|
|
86
|
+
return [];
|
|
87
|
+
const n = /* @__PURE__ */ new Set();
|
|
88
|
+
for (const s of t)
|
|
89
|
+
for (const [o, L] of Object.entries(
|
|
90
|
+
u
|
|
91
|
+
))
|
|
92
|
+
L.includes(s) && (o === O || o === _ || o === c) && n.add(o);
|
|
93
|
+
return m.filter((s) => n.has(s));
|
|
285
94
|
};
|
|
286
|
-
function
|
|
287
|
-
return !!
|
|
95
|
+
function st(t) {
|
|
96
|
+
return !!t && Array.isArray(t.capabilities) && t.capabilities.length >= 0;
|
|
288
97
|
}
|
|
289
|
-
function
|
|
290
|
-
return
|
|
98
|
+
function V(t) {
|
|
99
|
+
return t ? new Set(t) : null;
|
|
291
100
|
}
|
|
292
|
-
function
|
|
293
|
-
if (!
|
|
101
|
+
function Et(t, n, s) {
|
|
102
|
+
if (!n || Array.isArray(n) && n.length === 0)
|
|
294
103
|
return !0;
|
|
295
|
-
const
|
|
296
|
-
return !
|
|
104
|
+
const o = t instanceof Set ? t : V(t);
|
|
105
|
+
return !o || o.size === 0 ? !1 : typeof n == "string" ? o.has(n) : s?.any === !0 ? n.some((P) => o.has(P)) : n.every((P) => o.has(P));
|
|
297
106
|
}
|
|
298
107
|
export {
|
|
299
|
-
|
|
108
|
+
k as ALL_MODELS,
|
|
300
109
|
m as ALL_PROVIDERS,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
R as
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
c as
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
110
|
+
j as ALL_REASONING_MODELS,
|
|
111
|
+
J as APPLICATION_NAME,
|
|
112
|
+
H as APPROXIMATE_MODELS_PER_PROVIDER,
|
|
113
|
+
tt as CAPABILITIES,
|
|
114
|
+
b as DEFAULT_PROVIDER,
|
|
115
|
+
z as DIGGIDY_CHAT_ID_HEADER,
|
|
116
|
+
u as MODELS_PER_PROVIDER,
|
|
117
|
+
I as MODEL_CLAUDE_HAIKU,
|
|
118
|
+
i as MODEL_CLAUDE_SONNET,
|
|
119
|
+
B as MODEL_DEV,
|
|
120
|
+
x as MODEL_DISPLAY_NAMES,
|
|
121
|
+
W as MODEL_EMBEDDING_TEXT,
|
|
122
|
+
D as MODEL_GEMINI_FLASH,
|
|
123
|
+
a as MODEL_GEMINI_PRO,
|
|
124
|
+
T as MODEL_GPT4_NANO,
|
|
125
|
+
A as MODEL_GPT5,
|
|
126
|
+
R as MODEL_GPT5_MINI,
|
|
127
|
+
r as MODEL_GPT5_NANO,
|
|
128
|
+
F as MODEL_MEMORY_INFERENCE,
|
|
129
|
+
S as MODEL_SONAR,
|
|
130
|
+
N as MODEL_SONAR_PRO,
|
|
131
|
+
Q as PLAN_BASIC,
|
|
132
|
+
$ as PLAN_PLUS,
|
|
133
|
+
q as PLAN_PREMIUM,
|
|
134
|
+
_ as PROVIDER_ANTHROPIC,
|
|
135
|
+
c as PROVIDER_GOOGLE,
|
|
136
|
+
g as PROVIDER_MEMORY,
|
|
137
|
+
v as PROVIDER_MISTRAL,
|
|
138
|
+
O as PROVIDER_OPENAI,
|
|
139
|
+
M as PROVIDER_PERPLEXITY,
|
|
140
|
+
w as PROVIDER_ROLE_MAP,
|
|
141
|
+
d as PROVIDER_SUMMARY,
|
|
142
|
+
e as ROLE_ASSISTANT,
|
|
143
|
+
X as ROLE_HIDDEN,
|
|
144
|
+
Y as ROLE_INTERNAL,
|
|
145
|
+
l as ROLE_SYSTEM,
|
|
146
|
+
E as ROLE_USER,
|
|
147
|
+
K as SORT_BY_TIMESTAMP,
|
|
148
|
+
Z as SORT_BY_TOKEN_USAGE,
|
|
149
|
+
nt as findProvider,
|
|
150
|
+
ot as getProvidersFromModels,
|
|
151
|
+
Et as isEntitled,
|
|
152
|
+
st as isEntitlementLoaded,
|
|
153
|
+
V as toCapabilitySet
|
|
343
154
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/sassysaint-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"test:watch": "vitest",
|
|
33
33
|
"watch": "npm-run-all dev"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "89572beafadc51e691166d4334c4ce4d1002f682"
|
|
36
36
|
}
|