@versini/sassysaint-common 4.14.1 → 4.16.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +487 -428
  2. package/dist/index.js +1 -177
  3. package/package.json +12 -8
package/dist/index.d.ts CHANGED
@@ -1,428 +1,487 @@
1
- /**
2
- * List of available roles.
3
- */
4
- declare const ROLE_SYSTEM = "system";
5
- declare const ROLE_USER = "user";
6
- declare const ROLE_ASSISTANT = "assistant";
7
- declare const ROLE_HIDDEN = "hidden";
8
- declare const ROLE_INTERNAL = "data";
9
- /**
10
- * List of available providers.
11
- */
12
- declare const PROVIDER_OPENAI = "OpenAI";
13
- declare const PROVIDER_ANTHROPIC = "Anthropic";
14
- declare const PROVIDER_GOOGLE = "Google";
15
- declare const PROVIDER_SUMMARY = "Summary";
16
- declare const PROVIDER_MEMORY = "Memory";
17
- declare const PROVIDER_PERPLEXITY = "Perplexity";
18
- declare const PROVIDER_MISTRAL = "Mistral";
19
- declare const DEFAULT_PROVIDER = "OpenAI";
20
- declare const ALL_PROVIDERS: readonly ["OpenAI", "Anthropic", "Google"];
21
- /**
22
- * List of available models TODAY.
23
- */
24
- declare const MODEL_GPT5 = "gpt-5";
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";
28
- declare const MODEL_CLAUDE_HAIKU = "claude-haiku-4-5-20251001";
29
- declare const MODEL_CLAUDE_SONNET = "claude-sonnet-4-5-20250929";
30
- declare const MODEL_GEMINI_FLASH = "gemini-2.5-flash";
31
- declare const MODEL_GEMINI_PRO = "gemini-2.5-pro";
32
- declare const MODEL_SONAR = "sonar";
33
- declare const MODEL_SONAR_PRO = "sonar-pro";
34
- declare const MODEL_DEV = "mistralai/mistral-small-3.2-24b-instruct:free";
35
- declare const MODEL_MEMORY_INFERENCE = "gpt-4o-mini";
36
- declare const MODEL_EMBEDDING_TEXT = "text-embedding-3-small";
37
- /**
38
- * Maps model constants to user-friendly display names. Used by client UI to
39
- * show readable model names in plan descriptions and settings.
40
- */
41
- declare const MODEL_DISPLAY_NAMES: Record<string, string>;
42
- /**
43
- * List of all models available TODAY. This is used by the client to display the
44
- * list of models.
45
- */
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"];
47
- declare const ALL_REASONING_MODELS: string[];
48
- /**
49
- * List of models available according to the providers.
50
- */
51
- declare const MODELS_PER_PROVIDER: {
52
- readonly OpenAI: readonly ["gpt-4.1-nano", "gpt-5", "gpt-5-mini", "gpt-5-nano"];
53
- readonly Anthropic: readonly ["claude-haiku-4-5-20251001", "claude-sonnet-4-5-20250929"];
54
- readonly Google: readonly ["gemini-2.5-flash", "gemini-2.5-pro"];
55
- readonly Perplexity: readonly ["sonar", "sonar-pro"];
56
- };
57
- /**
58
- * List of roles available according to the provider.
59
- */
60
- declare const PROVIDER_ROLE_MAP: {
61
- OpenAI: string[];
62
- Anthropic: string[];
63
- Summary: string[];
64
- Memory: string[];
65
- Google: string[];
66
- Perplexity: string[];
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-haiku-4", "claude-3"];
75
- readonly OpenAI: readonly ["gpt-", "o3", "o4"];
76
- readonly Google: readonly ["gemini"];
77
- readonly Perplexity: readonly ["sonar"];
78
- };
79
- /**
80
- * Header string for Diggidy Chat Id. Used to identify the chat in the server
81
- * when there is a client abort.
82
- */
83
- declare const DIGGIDY_CHAT_ID_HEADER = "x-diggidy-chat-id";
84
- /**
85
- * Sort capabilities are shared across client and server.
86
- */
87
- declare const SORT_BY_TIMESTAMP = "timestamp";
88
- declare const SORT_BY_TOKEN_USAGE = "tokenUsage";
89
- /**
90
- * Name of the application.
91
- */
92
- declare const APPLICATION_NAME = "Diggidy";
93
- /**
94
- * List of all plans available.
95
- */
96
- declare const PLAN_BASIC = "sassy:basic";
97
- declare const PLAN_PLUS = "sassy:plus";
98
- declare const PLAN_PREMIUM = "sassy:advanced";
99
- /**
100
- * Capability constants (single source of truth for string ids).
101
- * NOTE: these map 1:1 to tool names in ALL_TOOLS from @sassysaint/tools
102
- * therefore each tools needs to import this file to name its tool correctly.
103
- */
104
- declare const CAPABILITIES: {
105
- readonly TOOL: {
106
- readonly DATETIME: "getDateTime";
107
- readonly IMAGES: "getImages";
108
- readonly POLLUTION: "getAirPollution";
109
- readonly WEATHER: "getWeather";
110
- readonly URLCONTENTPARSER: "getUrlContent";
111
- readonly MEMORIES: "getUserMemories";
112
- readonly HUMANIZE: "humanize";
113
- readonly WEBSEARCH: "getWebSearch";
114
- readonly GITREPOSITORY: "getGitRepoDetails";
115
- readonly HOTELS: "getHotelDetails";
116
- };
117
- readonly ADDON: {
118
- readonly ATTACHMENTS: "addon:attachments";
119
- readonly REASONING: "addon:reasoning";
120
- readonly CODEINTERPRETER: "addon:codeinterpreter";
121
- };
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>;
181
- /**
182
- * Groups allowed models by their respective providers. This function is used to
183
- * create nested menu structures in the UI where users can select specific
184
- * models within each provider category.
185
- *
186
- * The function analyzes the given array of model names and organizes them into
187
- * a map where keys are provider names and values are arrays of models available
188
- * for that provider. Only models that exist in the MODELS_PER_PROVIDER mapping
189
- * are included.
190
- *
191
- * @param models - Array of model names available to the user (e.g., from
192
- * allowedModels in policy configuration).
193
- * @returns Map where keys are provider names (PROVIDER_OPENAI,
194
- * PROVIDER_ANTHROPIC, PROVIDER_GOOGLE) and values are arrays of model names
195
- * available for that provider. Returns empty map if no models are provided.
196
- *
197
- * @example
198
- * ```ts
199
- * // User has multiple models per provider:
200
- * getModelsGroupedByProvider([MODEL_GPT5, MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU]);
201
- * // Returns: Map {
202
- * // "OpenAI" => ["gpt-5", "gpt-5-mini"],
203
- * // "Anthropic" => ["claude-haiku-4-5-20251001"]
204
- * // }
205
- *
206
- * // Single model per provider:
207
- * getModelsGroupedByProvider([MODEL_GPT5, MODEL_CLAUDE_HAIKU]);
208
- * // Returns: Map {
209
- * // "OpenAI" => ["gpt-5"],
210
- * // "Anthropic" => ["claude-haiku-4-5-20251001"]
211
- * // }
212
- *
213
- * // Empty models array:
214
- * getModelsGroupedByProvider([]);
215
- * // Returns: Map {}
216
- * ```
217
- *
218
- */
219
- declare const getModelsGroupedByProvider: (models: string[]) => Map<string, string[]>;
220
- /**
221
- * Checks if the user has multiple models available for at least one provider.
222
- * This function is used to determine if the nested model selection feature
223
- * should be available to the user.
224
- *
225
- * The function groups models by provider and checks if any provider has more
226
- * than one model. This enables the UI to conditionally show the nested model
227
- * selection toggle only to users who would benefit from it.
228
- *
229
- * @param models - Array of model names available to the user (e.g., from
230
- * allowedModels in policy configuration).
231
- * @returns True if at least one provider has multiple models available, false
232
- * otherwise.
233
- *
234
- * @example
235
- * ```ts
236
- * // Premium plan with multiple models per provider:
237
- * hasMultipleModelsPerProvider([MODEL_GPT5, MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU]);
238
- * // Returns: true (OpenAI has 2 models)
239
- *
240
- * // Plus plan with one model per provider:
241
- * hasMultipleModelsPerProvider([MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU, MODEL_GEMINI_FLASH]);
242
- * // Returns: false (each provider has only 1 model)
243
- *
244
- * // Basic plan with single model:
245
- * hasMultipleModelsPerProvider([MODEL_GPT5_NANO]);
246
- * // Returns: false
247
- * ```
248
- *
249
- */
250
- declare const hasMultipleModelsPerProvider: (models: string[]) => boolean;
251
- /**
252
- * Validates if a selected model is allowed for the user based on their current
253
- * plan's allowed models. This function is used to prevent users from using
254
- * models they selected under a previous (higher) plan after downgrading.
255
- *
256
- * The function checks if the model exists in the user's allowedModels array.
257
- * Returns false if the model is undefined, null, or not in the allowed list.
258
- *
259
- * @param selectedModel - The model the user has selected (may be null/undefined
260
- * if no selection was made).
261
- * @param allowedModels - Array of model names the user is entitled to use based
262
- * on their current plan.
263
- * @returns True if the selected model is in the allowed models list, false
264
- * otherwise.
265
- *
266
- * @example
267
- * ```ts
268
- * // User downgrades from Premium to Plus:
269
- * const selectedModel = "gpt-4o"; // Was selected when user had Premium
270
- * const allowedModels = ["gpt-4o-mini"]; // Plus plan only has mini model
271
- * isModelAllowedForPlan(selectedModel, allowedModels); // Returns: false
272
- *
273
- * // Model is still allowed:
274
- * isModelAllowedForPlan("gpt-4o-mini", ["gpt-4o-mini", "claude-haiku"]);
275
- * // Returns: true
276
- *
277
- * // No model selected:
278
- * isModelAllowedForPlan(undefined, ["gpt-4o-mini"]);
279
- * // Returns: false
280
- * ```
281
- *
282
- */
283
- declare const isModelAllowedForPlan: (selectedModel: string | undefined | null, allowedModels: string[]) => boolean;
284
- /**
285
- * Input type for capability checks. Can be a single capability string or an
286
- * array of capability strings for checking multiple capabilities at once.
287
- */
288
- type CapabilityInput = string | readonly string[];
289
- /**
290
- * Configuration options for the isEntitled function to control how capability
291
- * checks are evaluated.
292
- */
293
- interface IsEntitledOptions {
294
- /**
295
- * When true, grants entitlement if ANY of the required capabilities match
296
- * (logical OR). When false (default), requires ALL capabilities to match
297
- * (logical AND).
298
- */
299
- any?: boolean;
300
- /**
301
- * Pre-computed capability Set for performance optimization. If provided, skips
302
- * building a new Set from the capabilities array.
303
- */
304
- set?: Set<string>;
305
- }
306
- /**
307
- * Represents the shape of an entitlement state object, used for checking
308
- * capability loading status. This interface is intentionally flexible to work
309
- * with various entitlement state implementations across client and server.
310
- */
311
- interface EntitlementStateLike {
312
- /**
313
- * Array of capability strings granted to the user.
314
- */
315
- capabilities?: string[];
316
- /**
317
- * Version number of the entitlement state for cache invalidation.
318
- */
319
- version?: number;
320
- /**
321
- * Current status of the entitlement (e.g., "active", "expired").
322
- */
323
- status?: string;
324
- }
325
- /**
326
- * Checks whether an entitlement state object has been successfully loaded and
327
- * contains valid capability data. This function verifies the state is defined
328
- * and has a capabilities array (even if empty).
329
- *
330
- * Use this function before performing capability checks to ensure the
331
- * entitlement data is available and initialized properly.
332
- *
333
- * @param state - The entitlement state object to check, which may be null or
334
- * undefined during initial loading.
335
- * @returns True if the state is loaded and contains a capabilities array,
336
- * false otherwise.
337
- *
338
- * @example
339
- * ```ts
340
- * const entitlementState = await fetchEntitlements();
341
- * if (isEntitlementLoaded(entitlementState)) {
342
- * // Safe to check capabilities
343
- * const hasFeature = isEntitled(entitlementState.capabilities, "premium");
344
- * }
345
- * ```
346
- *
347
- */
348
- declare function isEntitlementLoaded(state: EntitlementStateLike | null | undefined): boolean;
349
- /**
350
- * Converts an array of capability strings into a Set for efficient lookup
351
- * operations. Returns null if the input is null, undefined, or not an array.
352
- *
353
- * Using a Set for capability checks provides O(1) lookup performance compared
354
- * to O(n) for array includes, which is beneficial when checking multiple
355
- * capabilities or performing frequent checks.
356
- *
357
- * @param capabilities - Array of capability strings to convert, or null/
358
- * undefined.
359
- * @returns A Set containing the capability strings, or null if input is
360
- * invalid.
361
- *
362
- * @example
363
- * ```ts
364
- * const caps = ["read:posts", "write:posts", "admin"];
365
- * const capSet = toCapabilitySet(caps);
366
- * // capSet.has("read:posts") is now O(1) instead of O(n)
367
- *
368
- * toCapabilitySet(null); // Returns null
369
- * toCapabilitySet(undefined); // Returns null
370
- * ```
371
- *
372
- */
373
- declare function toCapabilitySet(capabilities: string[] | undefined | null): Set<string> | null;
374
- /**
375
- * Checks whether a user has the required capability or capabilities based on
376
- * their entitlement. This function is used throughout the application to
377
- * control access to features based on subscription plans or permission levels.
378
- *
379
- * The function supports multiple modes of operation:
380
- * - Single capability check: Pass a string to check one capability
381
- * - Multiple capability check (AND): Pass an array to require ALL capabilities
382
- * - Multiple capability check (OR): Pass an array with options.any=true to
383
- * require ANY capability
384
- * - Performance optimization: Pass a pre-computed Set via options.set
385
- *
386
- * An empty requirements array or empty string always returns true, treating it
387
- * as "no specific entitlement required".
388
- *
389
- * @param capabilitiesOrSet - User's capabilities as an array, a Set, or null/
390
- * undefined if not loaded.
391
- * @param required - The capability or capabilities to check. Can be a single
392
- * string or an array of strings.
393
- * @param options - Optional configuration for the check behavior (any mode, pre-
394
- * computed Set).
395
- * @returns True if the user has the required capability/capabilities according
396
- * to the specified logic, false otherwise.
397
- *
398
- * @example
399
- * ```ts
400
- * const userCaps = ["read:posts", "write:posts"];
401
- *
402
- * // Single capability check:
403
- * isEntitled(userCaps, "read:posts"); // true
404
- * isEntitled(userCaps, "admin"); // false
405
- *
406
- * // Multiple capabilities (AND - all required):
407
- * isEntitled(userCaps, ["read:posts", "write:posts"]); // true
408
- * isEntitled(userCaps, ["read:posts", "admin"]); // false
409
- *
410
- * // Multiple capabilities (OR - any required):
411
- * isEntitled(userCaps, ["admin", "read:posts"], { any: true }); // true
412
- * isEntitled(userCaps, ["admin", "super:user"], { any: true }); // false
413
- *
414
- * // Performance optimization with pre-computed Set:
415
- * const capSet = toCapabilitySet(userCaps);
416
- * isEntitled(capSet, "read:posts"); // true (faster lookup)
417
- *
418
- * // Edge cases:
419
- * isEntitled(userCaps, ""); // true (no requirement)
420
- * isEntitled(userCaps, []); // true (no requirement)
421
- * isEntitled(null, "read:posts"); // false (no capabilities)
422
- * isEntitled([], "read:posts"); // false (empty capabilities)
423
- * ```
424
- *
425
- */
426
- declare function isEntitled(capabilitiesOrSet: string[] | Set<string> | null | undefined, required: CapabilityInput, options?: IsEntitledOptions): boolean;
427
-
428
- 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, getModelsGroupedByProvider, getProvidersFromModels, hasMultipleModelsPerProvider, isEntitled, isEntitlementLoaded, isModelAllowedForPlan, toCapabilitySet };
1
+ /**
2
+ * List of all models available TODAY. This is used by the client to display the
3
+ * list of models.
4
+ */
5
+ export declare const ALL_MODELS: readonly ["gpt-5", "gpt-5-mini", "gpt-5-nano", "claude-haiku-4-5", "claude-sonnet-4-5", "gemini-2.5-flash", "gemini-2.5-pro"];
6
+
7
+ export declare const ALL_PROVIDERS: readonly ["OpenAI", "Anthropic", "Google"];
8
+
9
+ export declare const ALL_REASONING_MODELS: string[];
10
+
11
+ /**
12
+ * Name of the application.
13
+ */
14
+ export declare const APPLICATION_NAME = "Diggidy";
15
+
16
+ /**
17
+ * Mapping of AI providers to their approximate model name prefixes. This
18
+ * enables provider identification from model names even when exact model
19
+ * versions change over time.
20
+ */
21
+ export declare const APPROXIMATE_MODELS_PER_PROVIDER: {
22
+ readonly Anthropic: readonly ["claude-sonnet-4", "claude-haiku-4", "claude-3"];
23
+ readonly OpenAI: readonly ["gpt-", "o3", "o4"];
24
+ readonly Google: readonly ["gemini"];
25
+ readonly Perplexity: readonly ["sonar"];
26
+ };
27
+
28
+ /**
29
+ * Capability constants (single source of truth for string ids).
30
+ * NOTE: these map 1:1 to tool names in ALL_TOOLS from @sassysaint/tools
31
+ * therefore each tools needs to import this file to name its tool correctly.
32
+ */
33
+ export declare const CAPABILITIES: {
34
+ readonly TOOL: {
35
+ readonly DATETIME: "getDateTime";
36
+ readonly IMAGES: "getImages";
37
+ readonly POLLUTION: "getAirPollution";
38
+ readonly WEATHER: "getWeather";
39
+ readonly URLCONTENTPARSER: "getUrlContent";
40
+ readonly MEMORIES: "getUserMemories";
41
+ readonly HUMANIZE: "humanize";
42
+ readonly WEBSEARCH: "getWebSearch";
43
+ readonly GITREPOSITORY: "getGitRepoDetails";
44
+ readonly HOTELS: "getHotelDetails";
45
+ };
46
+ readonly ADDON: {
47
+ readonly ATTACHMENTS: "addon:attachments";
48
+ readonly REASONING: "addon:reasoning";
49
+ readonly CODEINTERPRETER: "addon:codeinterpreter";
50
+ };
51
+ };
52
+
53
+ /**
54
+ * Input type for capability checks. Can be a single capability string or an
55
+ * array of capability strings for checking multiple capabilities at once.
56
+ */
57
+ export declare type CapabilityInput = string | readonly string[];
58
+
59
+ export declare const DEFAULT_PROVIDER = "OpenAI";
60
+
61
+ /**
62
+ * Header string for Diggidy Chat Id. Used to identify the chat in the server
63
+ * when there is a client abort.
64
+ */
65
+ export declare const DIGGIDY_CHAT_ID_HEADER = "x-diggidy-chat-id";
66
+
67
+ /**
68
+ * Represents the shape of an entitlement state object, used for checking
69
+ * capability loading status. This interface is intentionally flexible to work
70
+ * with various entitlement state implementations across client and server.
71
+ */
72
+ export declare interface EntitlementStateLike {
73
+ /**
74
+ * Array of capability strings granted to the user.
75
+ */
76
+ capabilities?: string[];
77
+ /**
78
+ * Version number of the entitlement state for cache invalidation.
79
+ */
80
+ version?: number;
81
+ /**
82
+ * Current status of the entitlement (e.g., "active", "expired").
83
+ */
84
+ status?: string;
85
+ }
86
+
87
+ /**
88
+ * Identifies the AI provider associated with a given model name by matching
89
+ * against known model prefixes. This function provides backward compatibility
90
+ * for older model naming schemes while correctly identifying the provider.
91
+ *
92
+ * The function iterates through approximate model prefixes for each provider
93
+ * and returns the first matching provider. This approach handles cases where
94
+ * model version numbers change but the provider remains the same.
95
+ *
96
+ * @param modelName - The full model name to identify (e.g.,
97
+ * "claude-3-5-sonnet-20241022").
98
+ * @returns The provider constant (PROVIDER_ANTHROPIC, PROVIDER_OPENAI, or
99
+ * PROVIDER_GOOGLE) if a match is found, or null if no provider matches.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * findProvider("claude-3-5-sonnet-latest"); // Returns PROVIDER_ANTHROPIC
104
+ * findProvider("gpt-4-turbo"); // Returns PROVIDER_OPENAI
105
+ * findProvider("gemini-1.5-pro"); // Returns PROVIDER_GOOGLE
106
+ * findProvider("unknown-model"); // Returns null
107
+ * ```
108
+ *
109
+ */
110
+ export declare const findProvider: (modelName: string) => null | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_OPENAI | typeof PROVIDER_GOOGLE;
111
+
112
+ /**
113
+ * Groups allowed models by their respective providers. This function is used to
114
+ * create nested menu structures in the UI where users can select specific
115
+ * models within each provider category.
116
+ *
117
+ * The function analyzes the given array of model names and organizes them into
118
+ * a map where keys are provider names and values are arrays of models available
119
+ * for that provider. Only models that exist in the MODELS_PER_PROVIDER mapping
120
+ * are included.
121
+ *
122
+ * @param models - Array of model names available to the user (e.g., from
123
+ * allowedModels in policy configuration).
124
+ * @returns Map where keys are provider names (PROVIDER_OPENAI,
125
+ * PROVIDER_ANTHROPIC, PROVIDER_GOOGLE) and values are arrays of model names
126
+ * available for that provider. Returns empty map if no models are provided.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * // User has multiple models per provider:
131
+ * getModelsGroupedByProvider([MODEL_GPT5, MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU]);
132
+ * // Returns: Map {
133
+ * // "OpenAI" => ["gpt-5", "gpt-5-mini"],
134
+ * // "Anthropic" => ["claude-haiku-4-5"]
135
+ * // }
136
+ *
137
+ * // Single model per provider:
138
+ * getModelsGroupedByProvider([MODEL_GPT5, MODEL_CLAUDE_HAIKU]);
139
+ * // Returns: Map {
140
+ * // "OpenAI" => ["gpt-5"],
141
+ * // "Anthropic" => ["claude-haiku-4-5"]
142
+ * // }
143
+ *
144
+ * // Empty models array:
145
+ * getModelsGroupedByProvider([]);
146
+ * // Returns: Map {}
147
+ * ```
148
+ *
149
+ */
150
+ export declare const getModelsGroupedByProvider: (models: string[]) => Map<string, string[]>;
151
+
152
+ /**
153
+ * Derives the list of available AI providers from a given array of model names.
154
+ * This function enables automatic filtering of provider options in the UI based
155
+ * on which models are available in a user's subscription plan.
156
+ *
157
+ * The function cross-references each model against the MODELS_PER_PROVIDER
158
+ * mapping to determine which providers should be available. Results are
159
+ * returned in a consistent order matching ALL_PROVIDERS to ensure UI stability.
160
+ *
161
+ * @param models - Array of model names available to the user (e.g., from
162
+ * allowedModels in policy configuration).
163
+ * @returns Array of provider constants (PROVIDER_OPENAI, PROVIDER_ANTHROPIC,
164
+ * PROVIDER_GOOGLE) that have at least one available model. Returns empty
165
+ * array if no models are provided.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * // User's plan includes GPT and Claude models:
170
+ * getProvidersFromModels([MODEL_GPT4_NANO, MODEL_CLAUDE_HAIKU]);
171
+ * // Returns: [PROVIDER_OPENAI, PROVIDER_ANTHROPIC]
172
+ *
173
+ * // Gemini models removed from plan:
174
+ * getProvidersFromModels([MODEL_GPT4_NANO, MODEL_CLAUDE_HAIKU]);
175
+ * // Returns: [PROVIDER_OPENAI, PROVIDER_ANTHROPIC]
176
+ * // (PROVIDER_GOOGLE is excluded)
177
+ *
178
+ * // Empty models array:
179
+ * getProvidersFromModels([]);
180
+ * // Returns: []
181
+ * ```
182
+ *
183
+ */
184
+ export declare const getProvidersFromModels: (models: string[]) => Array<typeof PROVIDER_OPENAI | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_GOOGLE>;
185
+
186
+ /**
187
+ * Checks if the user has multiple models available for at least one provider.
188
+ * This function is used to determine if the nested model selection feature
189
+ * should be available to the user.
190
+ *
191
+ * The function groups models by provider and checks if any provider has more
192
+ * than one model. This enables the UI to conditionally show the nested model
193
+ * selection toggle only to users who would benefit from it.
194
+ *
195
+ * @param models - Array of model names available to the user (e.g., from
196
+ * allowedModels in policy configuration).
197
+ * @returns True if at least one provider has multiple models available, false
198
+ * otherwise.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * // Premium plan with multiple models per provider:
203
+ * hasMultipleModelsPerProvider([MODEL_GPT5, MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU]);
204
+ * // Returns: true (OpenAI has 2 models)
205
+ *
206
+ * // Plus plan with one model per provider:
207
+ * hasMultipleModelsPerProvider([MODEL_GPT5_MINI, MODEL_CLAUDE_HAIKU, MODEL_GEMINI_FLASH]);
208
+ * // Returns: false (each provider has only 1 model)
209
+ *
210
+ * // Basic plan with single model:
211
+ * hasMultipleModelsPerProvider([MODEL_GPT5_NANO]);
212
+ * // Returns: false
213
+ * ```
214
+ *
215
+ */
216
+ export declare const hasMultipleModelsPerProvider: (models: string[]) => boolean;
217
+
218
+ /**
219
+ * Checks whether a user has the required capability or capabilities based on
220
+ * their entitlement. This function is used throughout the application to
221
+ * control access to features based on subscription plans or permission levels.
222
+ *
223
+ * The function supports multiple modes of operation:
224
+ * - Single capability check: Pass a string to check one capability
225
+ * - Multiple capability check (AND): Pass an array to require ALL capabilities
226
+ * - Multiple capability check (OR): Pass an array with options.any=true to
227
+ * require ANY capability
228
+ * - Performance optimization: Pass a pre-computed Set via options.set
229
+ *
230
+ * An empty requirements array or empty string always returns true, treating it
231
+ * as "no specific entitlement required".
232
+ *
233
+ * @param capabilitiesOrSet - User's capabilities as an array, a Set, or null/
234
+ * undefined if not loaded.
235
+ * @param required - The capability or capabilities to check. Can be a single
236
+ * string or an array of strings.
237
+ * @param options - Optional configuration for the check behavior (any mode, pre-
238
+ * computed Set).
239
+ * @returns True if the user has the required capability/capabilities according
240
+ * to the specified logic, false otherwise.
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * const userCaps = ["read:posts", "write:posts"];
245
+ *
246
+ * // Single capability check:
247
+ * isEntitled(userCaps, "read:posts"); // true
248
+ * isEntitled(userCaps, "admin"); // false
249
+ *
250
+ * // Multiple capabilities (AND - all required):
251
+ * isEntitled(userCaps, ["read:posts", "write:posts"]); // true
252
+ * isEntitled(userCaps, ["read:posts", "admin"]); // false
253
+ *
254
+ * // Multiple capabilities (OR - any required):
255
+ * isEntitled(userCaps, ["admin", "read:posts"], { any: true }); // true
256
+ * isEntitled(userCaps, ["admin", "super:user"], { any: true }); // false
257
+ *
258
+ * // Performance optimization with pre-computed Set:
259
+ * const capSet = toCapabilitySet(userCaps);
260
+ * isEntitled(capSet, "read:posts"); // true (faster lookup)
261
+ *
262
+ * // Edge cases:
263
+ * isEntitled(userCaps, ""); // true (no requirement)
264
+ * isEntitled(userCaps, []); // true (no requirement)
265
+ * isEntitled(null, "read:posts"); // false (no capabilities)
266
+ * isEntitled([], "read:posts"); // false (empty capabilities)
267
+ * ```
268
+ *
269
+ */
270
+ export declare function isEntitled(capabilitiesOrSet: string[] | Set<string> | null | undefined, required: CapabilityInput, options?: IsEntitledOptions): boolean;
271
+
272
+ /**
273
+ * Configuration options for the isEntitled function to control how capability
274
+ * checks are evaluated.
275
+ */
276
+ export declare interface IsEntitledOptions {
277
+ /**
278
+ * When true, grants entitlement if ANY of the required capabilities match
279
+ * (logical OR). When false (default), requires ALL capabilities to match
280
+ * (logical AND).
281
+ */
282
+ any?: boolean;
283
+ /**
284
+ * Pre-computed capability Set for performance optimization. If provided, skips
285
+ * building a new Set from the capabilities array.
286
+ */
287
+ set?: Set<string>;
288
+ }
289
+
290
+ /**
291
+ * Checks whether an entitlement state object has been successfully loaded and
292
+ * contains valid capability data. This function verifies the state is defined
293
+ * and has a capabilities array (even if empty).
294
+ *
295
+ * Use this function before performing capability checks to ensure the
296
+ * entitlement data is available and initialized properly.
297
+ *
298
+ * @param state - The entitlement state object to check, which may be null or
299
+ * undefined during initial loading.
300
+ * @returns True if the state is loaded and contains a capabilities array,
301
+ * false otherwise.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * const entitlementState = await fetchEntitlements();
306
+ * if (isEntitlementLoaded(entitlementState)) {
307
+ * // Safe to check capabilities
308
+ * const hasFeature = isEntitled(entitlementState.capabilities, "premium");
309
+ * }
310
+ * ```
311
+ *
312
+ */
313
+ export declare function isEntitlementLoaded(state: EntitlementStateLike | null | undefined): boolean;
314
+
315
+ /**
316
+ * Validates if a selected model is allowed for the user based on their current
317
+ * plan's allowed models. This function is used to prevent users from using
318
+ * models they selected under a previous (higher) plan after downgrading.
319
+ *
320
+ * The function checks if the model exists in the user's allowedModels array.
321
+ * Returns false if the model is undefined, null, or not in the allowed list.
322
+ *
323
+ * @param selectedModel - The model the user has selected (may be null/undefined
324
+ * if no selection was made).
325
+ * @param allowedModels - Array of model names the user is entitled to use based
326
+ * on their current plan.
327
+ * @returns True if the selected model is in the allowed models list, false
328
+ * otherwise.
329
+ *
330
+ * @example
331
+ * ```ts
332
+ * // User downgrades from Premium to Plus:
333
+ * const selectedModel = "gpt-4o"; // Was selected when user had Premium
334
+ * const allowedModels = ["gpt-4o-mini"]; // Plus plan only has mini model
335
+ * isModelAllowedForPlan(selectedModel, allowedModels); // Returns: false
336
+ *
337
+ * // Model is still allowed:
338
+ * isModelAllowedForPlan("gpt-4o-mini", ["gpt-4o-mini", "claude-haiku"]);
339
+ * // Returns: true
340
+ *
341
+ * // No model selected:
342
+ * isModelAllowedForPlan(undefined, ["gpt-4o-mini"]);
343
+ * // Returns: false
344
+ * ```
345
+ *
346
+ */
347
+ export declare const isModelAllowedForPlan: (selectedModel: string | undefined | null, allowedModels: string[]) => boolean;
348
+
349
+ export declare const MODEL_CLAUDE_HAIKU = "claude-haiku-4-5";
350
+
351
+ export declare const MODEL_CLAUDE_SONNET = "claude-sonnet-4-5";
352
+
353
+ export declare const MODEL_DEV = "mistralai/mistral-small-3.2-24b-instruct:free";
354
+
355
+ /**
356
+ * Maps model constants to user-friendly display names. Used by client UI to
357
+ * show readable model names in plan descriptions and settings.
358
+ */
359
+ export declare const MODEL_DISPLAY_NAMES: Record<string, string>;
360
+
361
+ export declare const MODEL_EMBEDDING_TEXT = "text-embedding-3-small";
362
+
363
+ export declare const MODEL_GEMINI_FLASH = "gemini-2.5-flash";
364
+
365
+ export declare const MODEL_GEMINI_PRO = "gemini-2.5-pro";
366
+
367
+ export declare const MODEL_GPT4_NANO = "gpt-4.1-nano";
368
+
369
+ /**
370
+ * List of available models TODAY.
371
+ */
372
+ export declare const MODEL_GPT5 = "gpt-5";
373
+
374
+ export declare const MODEL_GPT5_MINI = "gpt-5-mini";
375
+
376
+ export declare const MODEL_GPT5_NANO = "gpt-5-nano";
377
+
378
+ export declare const MODEL_MEMORY_INFERENCE = "gpt-4o-mini";
379
+
380
+ export declare const MODEL_SONAR = "sonar";
381
+
382
+ export declare const MODEL_SONAR_PRO = "sonar-pro";
383
+
384
+ /**
385
+ * List of models available according to the providers.
386
+ */
387
+ export declare const MODELS_PER_PROVIDER: {
388
+ readonly OpenAI: readonly ["gpt-4.1-nano", "gpt-5", "gpt-5-mini", "gpt-5-nano"];
389
+ readonly Anthropic: readonly ["claude-haiku-4-5", "claude-sonnet-4-5"];
390
+ readonly Google: readonly ["gemini-2.5-flash", "gemini-2.5-pro"];
391
+ readonly Perplexity: readonly ["sonar", "sonar-pro"];
392
+ };
393
+
394
+ /**
395
+ * List of all plans available.
396
+ */
397
+ export declare const PLAN_BASIC = "sassy:basic";
398
+
399
+ export declare const PLAN_PLUS = "sassy:plus";
400
+
401
+ export declare const PLAN_PREMIUM = "sassy:advanced";
402
+
403
+ export declare const PROVIDER_ANTHROPIC = "Anthropic";
404
+
405
+ export declare const PROVIDER_GOOGLE = "Google";
406
+
407
+ export declare const PROVIDER_MEMORY = "Memory";
408
+
409
+ export declare const PROVIDER_MISTRAL = "Mistral";
410
+
411
+ /**
412
+ * List of available providers.
413
+ */
414
+ export declare const PROVIDER_OPENAI = "OpenAI";
415
+
416
+ export declare const PROVIDER_PERPLEXITY = "Perplexity";
417
+
418
+ /**
419
+ * List of roles available according to the provider.
420
+ */
421
+ export declare const PROVIDER_ROLE_MAP: {
422
+ OpenAI: string[];
423
+ Anthropic: string[];
424
+ Summary: string[];
425
+ Memory: string[];
426
+ Google: string[];
427
+ Perplexity: string[];
428
+ };
429
+
430
+ export declare const PROVIDER_SUMMARY = "Summary";
431
+
432
+ export declare const ROLE_ASSISTANT = "assistant";
433
+
434
+ export declare const ROLE_HIDDEN = "hidden";
435
+
436
+ export declare const ROLE_INTERNAL = "data";
437
+
438
+ /**
439
+ * List of available roles.
440
+ */
441
+ export declare const ROLE_SYSTEM = "system";
442
+
443
+ export declare const ROLE_USER = "user";
444
+
445
+ /**
446
+ * Sort capabilities are shared across client and server.
447
+ */
448
+ export declare const SORT_BY_TIMESTAMP = "timestamp";
449
+
450
+ export declare const SORT_BY_TOKEN_USAGE = "tokenUsage";
451
+
452
+ /**
453
+ * Theme constants used across client and server.
454
+ */
455
+ export declare const THEME_STANDARD = "standard";
456
+
457
+ export declare const THEME_SUBTLE = "subtle";
458
+
459
+ export declare type ThemeMode = typeof THEME_STANDARD | typeof THEME_SUBTLE;
460
+
461
+ /**
462
+ * Converts an array of capability strings into a Set for efficient lookup
463
+ * operations. Returns null if the input is null, undefined, or not an array.
464
+ *
465
+ * Using a Set for capability checks provides O(1) lookup performance compared
466
+ * to O(n) for array includes, which is beneficial when checking multiple
467
+ * capabilities or performing frequent checks.
468
+ *
469
+ * @param capabilities - Array of capability strings to convert, or null/
470
+ * undefined.
471
+ * @returns A Set containing the capability strings, or null if input is
472
+ * invalid.
473
+ *
474
+ * @example
475
+ * ```ts
476
+ * const caps = ["read:posts", "write:posts", "admin"];
477
+ * const capSet = toCapabilitySet(caps);
478
+ * // capSet.has("read:posts") is now O(1) instead of O(n)
479
+ *
480
+ * toCapabilitySet(null); // Returns null
481
+ * toCapabilitySet(undefined); // Returns null
482
+ * ```
483
+ *
484
+ */
485
+ export declare function toCapabilitySet(capabilities: string[] | undefined | null): Set<string> | null;
486
+
487
+ export { }
package/dist/index.js CHANGED
@@ -1,177 +1 @@
1
- const S = "system", e = "user", E = "assistant", Y = "hidden", b = "data", r = "OpenAI", O = "Anthropic", c = "Google", d = "Summary", g = "Memory", I = "Perplexity", B = "Mistral", F = r, f = [
2
- r,
3
- O,
4
- c
5
- ], _ = "gpt-5", A = "gpt-5-mini", a = "gpt-5-nano", T = "gpt-4.1-nano", D = "claude-haiku-4-5-20251001", R = "claude-sonnet-4-5-20250929", L = "gemini-2.5-flash", P = "gemini-2.5-pro", l = "sonar", u = "sonar-pro", k = "mistralai/mistral-small-3.2-24b-instruct:free", W = "gpt-4o-mini", x = "text-embedding-3-small", j = {
6
- [_]: "GPT-5",
7
- [A]: "GPT-5 Mini",
8
- [a]: "GPT-5 Nano",
9
- [T]: "GPT-4.1 Nano",
10
- [D]: "Claude Haiku 4.5",
11
- [R]: "Claude Sonnet 4.5",
12
- [L]: "Gemini 2.5 Flash",
13
- [P]: "Gemini 2.5 Pro",
14
- [l]: "Sonar",
15
- [u]: "Sonar Pro"
16
- }, K = [
17
- _,
18
- A,
19
- a,
20
- D,
21
- R,
22
- L,
23
- P
24
- ], w = [
25
- _,
26
- A,
27
- a,
28
- R,
29
- P
30
- ], N = {
31
- [r]: [
32
- T,
33
- _,
34
- A,
35
- a
36
- ],
37
- [O]: [D, R],
38
- [c]: [L, P],
39
- [I]: [l, u]
40
- }, z = {
41
- [r]: [S, e, E],
42
- [O]: [e, E],
43
- [d]: [e, E],
44
- [g]: [e, E],
45
- [c]: [e, E],
46
- [I]: [e, E]
47
- }, p = "claude-sonnet-4", G = "claude-haiku-4", m = "claude-3", h = "gpt-", y = "o3", C = "o4", U = "gemini", v = "sonar", H = {
48
- [O]: [
49
- p,
50
- G,
51
- m
52
- ],
53
- [r]: [
54
- h,
55
- y,
56
- C
57
- ],
58
- [c]: [U],
59
- [I]: [v]
60
- }, Z = "x-diggidy-chat-id", J = "timestamp", Q = "tokenUsage", $ = "Diggidy", q = "sassy:basic", tt = "sassy:plus", nt = "sassy:advanced", ot = {
61
- TOOL: {
62
- DATETIME: "getDateTime",
63
- IMAGES: "getImages",
64
- POLLUTION: "getAirPollution",
65
- WEATHER: "getWeather",
66
- URLCONTENTPARSER: "getUrlContent",
67
- MEMORIES: "getUserMemories",
68
- HUMANIZE: "humanize",
69
- WEBSEARCH: "getWebSearch",
70
- GITREPOSITORY: "getGitRepoDetails",
71
- HOTELS: "getHotelDetails"
72
- },
73
- ADDON: {
74
- ATTACHMENTS: "addon:attachments",
75
- REASONING: "addon:reasoning",
76
- CODEINTERPRETER: "addon:codeinterpreter"
77
- }
78
- }, st = (t) => {
79
- for (const [n, s] of Object.entries(
80
- H
81
- ))
82
- if (s.some((o) => t.startsWith(o)))
83
- return n;
84
- return null;
85
- }, et = (t) => {
86
- if (!t || t.length === 0)
87
- return [];
88
- const n = /* @__PURE__ */ new Set();
89
- for (const s of t)
90
- for (const [o, i] of Object.entries(
91
- N
92
- ))
93
- i.includes(s) && (o === r || o === O || o === c) && n.add(o);
94
- return f.filter((s) => n.has(s));
95
- }, V = (t) => {
96
- const n = /* @__PURE__ */ new Map();
97
- if (!t || t.length === 0)
98
- return n;
99
- for (const s of t)
100
- for (const [o, i] of Object.entries(
101
- N
102
- ))
103
- if (i.includes(s)) {
104
- n.has(o) || n.set(o, []), n.get(o)?.push(s);
105
- break;
106
- }
107
- return n;
108
- }, Et = (t) => {
109
- const n = V(t);
110
- for (const s of n.values())
111
- if (s.length > 1)
112
- return !0;
113
- return !1;
114
- }, rt = (t, n) => !t || !n || n.length === 0 ? !1 : n.includes(t);
115
- function Ot(t) {
116
- return !!t && Array.isArray(t.capabilities) && t.capabilities.length >= 0;
117
- }
118
- function X(t) {
119
- return t ? new Set(t) : null;
120
- }
121
- function ct(t, n, s) {
122
- if (!n || Array.isArray(n) && n.length === 0)
123
- return !0;
124
- const o = t instanceof Set ? t : X(t);
125
- return !o || o.size === 0 ? !1 : typeof n == "string" ? o.has(n) : s?.any === !0 ? n.some((M) => o.has(M)) : n.every((M) => o.has(M));
126
- }
127
- export {
128
- K as ALL_MODELS,
129
- f as ALL_PROVIDERS,
130
- w as ALL_REASONING_MODELS,
131
- $ as APPLICATION_NAME,
132
- H as APPROXIMATE_MODELS_PER_PROVIDER,
133
- ot as CAPABILITIES,
134
- F as DEFAULT_PROVIDER,
135
- Z as DIGGIDY_CHAT_ID_HEADER,
136
- N as MODELS_PER_PROVIDER,
137
- D as MODEL_CLAUDE_HAIKU,
138
- R as MODEL_CLAUDE_SONNET,
139
- k as MODEL_DEV,
140
- j as MODEL_DISPLAY_NAMES,
141
- x as MODEL_EMBEDDING_TEXT,
142
- L as MODEL_GEMINI_FLASH,
143
- P as MODEL_GEMINI_PRO,
144
- T as MODEL_GPT4_NANO,
145
- _ as MODEL_GPT5,
146
- A as MODEL_GPT5_MINI,
147
- a as MODEL_GPT5_NANO,
148
- W as MODEL_MEMORY_INFERENCE,
149
- l as MODEL_SONAR,
150
- u as MODEL_SONAR_PRO,
151
- q as PLAN_BASIC,
152
- tt as PLAN_PLUS,
153
- nt as PLAN_PREMIUM,
154
- O as PROVIDER_ANTHROPIC,
155
- c as PROVIDER_GOOGLE,
156
- g as PROVIDER_MEMORY,
157
- B as PROVIDER_MISTRAL,
158
- r as PROVIDER_OPENAI,
159
- I as PROVIDER_PERPLEXITY,
160
- z as PROVIDER_ROLE_MAP,
161
- d as PROVIDER_SUMMARY,
162
- E as ROLE_ASSISTANT,
163
- Y as ROLE_HIDDEN,
164
- b as ROLE_INTERNAL,
165
- S as ROLE_SYSTEM,
166
- e as ROLE_USER,
167
- J as SORT_BY_TIMESTAMP,
168
- Q as SORT_BY_TOKEN_USAGE,
169
- st as findProvider,
170
- V as getModelsGroupedByProvider,
171
- et as getProvidersFromModels,
172
- Et as hasMultipleModelsPerProvider,
173
- ct as isEntitled,
174
- Ot as isEntitlementLoaded,
175
- rt as isModelAllowedForPlan,
176
- X as toCapabilitySet
177
- };
1
+ let e="user",_="assistant",t="OpenAI",E="Anthropic",a="Google",r="Summary",s="Perplexity",n="Mistral",O=[t,E,a],i="gpt-5",o="gpt-5-mini",R="gpt-5-nano",l="gpt-4.1-nano",A="claude-haiku-4-5",I="claude-sonnet-4-5",M="gemini-2.5-flash",D="gemini-2.5-pro",L="sonar",P="sonar-pro",T="mistralai/mistral-small-3.2-24b-instruct:free",S="gpt-4o-mini",p="text-embedding-3-small",d={[i]:"GPT-5",[o]:"GPT-5 Mini",[R]:"GPT-5 Nano",[l]:"GPT-4.1 Nano",[A]:"Claude Haiku 4.5",[I]:"Claude Sonnet 4.5",[M]:"Gemini 2.5 Flash",[D]:"Gemini 2.5 Pro",[L]:"Sonar",[P]:"Sonar Pro"},N=[i,o,R,A,I,M,D],u=[i,o,R,I,D],g={[t]:[l,i,o,R],[E]:[A,I],[a]:[M,D],[s]:[L,P]},c={[t]:["system",e,_],[E]:[e,_],[r]:[e,_],Memory:[e,_],[a]:[e,_],[s]:[e,_]},G={[E]:["claude-sonnet-4","claude-haiku-4","claude-3"],[t]:["gpt-","o3","o4"],[a]:["gemini"],[s]:["sonar"]},m="x-diggidy-chat-id",f="timestamp",h="tokenUsage",b="Diggidy",y="sassy:basic",U="sassy:plus",H="sassy:advanced",V={TOOL:{DATETIME:"getDateTime",IMAGES:"getImages",POLLUTION:"getAirPollution",WEATHER:"getWeather",URLCONTENTPARSER:"getUrlContent",MEMORIES:"getUserMemories",HUMANIZE:"humanize",WEBSEARCH:"getWebSearch",GITREPOSITORY:"getGitRepoDetails",HOTELS:"getHotelDetails"},ADDON:{ATTACHMENTS:"addon:attachments",REASONING:"addon:reasoning",CODEINTERPRETER:"addon:codeinterpreter"}},k="standard",C=e=>{for(let[_,t]of Object.entries(G))if(t.some(_=>e.startsWith(_)))return _;return null},w=e=>{if(!e||0===e.length)return[];let _=new Set;for(let t of e)for(let[e,a]of Object.entries(g))a.includes(t)&&("OpenAI"===e||e===E||"Google"===e)&&_.add(e);return O.filter(e=>_.has(e))},x=e=>{let _=new Map;if(!e||0===e.length)return _;for(let t of e)for(let[e,E]of Object.entries(g))if(E.includes(t)){_.has(e)||_.set(e,[]),_.get(e)?.push(t);break}return _},Y=e=>{for(let _ of x(e).values())if(_.length>1)return!0;return!1},B=(e,_)=>!!e&&!!_&&0!==_.length&&_.includes(e);function v(e){return!!e&&Array.isArray(e.capabilities)&&e.capabilities.length>=0}function F(e){return e?new Set(e):null}function W(e,_,t){if(!_||Array.isArray(_)&&0===_.length)return!0;let E=e instanceof Set?e:F(e);return!!E&&0!==E.size&&("string"==typeof _?E.has(_):t?.any===!0?_.some(e=>E.has(e)):_.every(e=>E.has(e)))}var j="OpenAI",X="gpt-5",z="sonar",K="Google",Z="Memory",q="OpenAI",J="hidden",Q="data",$="system",ee="user",e_="subtle";export{N as ALL_MODELS,O as ALL_PROVIDERS,u as ALL_REASONING_MODELS,b as APPLICATION_NAME,G as APPROXIMATE_MODELS_PER_PROVIDER,V as CAPABILITIES,m as DIGGIDY_CHAT_ID_HEADER,g as MODELS_PER_PROVIDER,A as MODEL_CLAUDE_HAIKU,I as MODEL_CLAUDE_SONNET,T as MODEL_DEV,d as MODEL_DISPLAY_NAMES,p as MODEL_EMBEDDING_TEXT,M as MODEL_GEMINI_FLASH,D as MODEL_GEMINI_PRO,l as MODEL_GPT4_NANO,o as MODEL_GPT5_MINI,R as MODEL_GPT5_NANO,S as MODEL_MEMORY_INFERENCE,P as MODEL_SONAR_PRO,y as PLAN_BASIC,U as PLAN_PLUS,H as PLAN_PREMIUM,E as PROVIDER_ANTHROPIC,n as PROVIDER_MISTRAL,s as PROVIDER_PERPLEXITY,c as PROVIDER_ROLE_MAP,r as PROVIDER_SUMMARY,_ as ROLE_ASSISTANT,f as SORT_BY_TIMESTAMP,h as SORT_BY_TOKEN_USAGE,k as THEME_STANDARD,C as findProvider,x as getModelsGroupedByProvider,w as getProvidersFromModels,Y as hasMultipleModelsPerProvider,W as isEntitled,v as isEntitlementLoaded,B as isModelAllowedForPlan,F as toCapabilitySet,j as DEFAULT_PROVIDER,X as MODEL_GPT5,z as MODEL_SONAR,K as PROVIDER_GOOGLE,Z as PROVIDER_MEMORY,q as PROVIDER_OPENAI,J as ROLE_HIDDEN,Q as ROLE_INTERNAL,$ as ROLE_SYSTEM,ee as ROLE_USER,e_ as THEME_SUBTLE};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/sassysaint-common",
3
- "version": "4.14.1",
3
+ "version": "4.16.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -15,14 +15,14 @@
15
15
  "scripts": {
16
16
  "build:check": "tsc",
17
17
  "build:common": "npm-run-all build",
18
- "build:js": "vite build",
19
- "build:types": "tsup",
20
- "build": "npm-run-all --serial clean build:check build:js build:types",
18
+ "build:js": "rslib build",
19
+ "build:types": "echo 'Types now built with rslib'",
20
+ "build": "npm-run-all --serial clean build:check build:js",
21
21
  "clean": "rimraf dist tmp",
22
22
  "comments:fix": "comments \"src/**/*.ts*\" --merge-line-comments",
23
- "dev:js": "vite build --watch --mode development",
24
- "dev:types": "tsup --watch src",
25
- "dev": "npm-run-all --parallel dev:js dev:types",
23
+ "dev:js": "rslib build --watch",
24
+ "dev:types": "echo 'Types now watched with rslib'",
25
+ "dev": "rslib build --watch",
26
26
  "fix": "npm-run-all lint:fix comments:fix",
27
27
  "lint": "biome lint src",
28
28
  "lint:fix": "biome check src --write --no-errors-on-unmatched",
@@ -32,5 +32,9 @@
32
32
  "test:watch": "vitest",
33
33
  "watch": "npm-run-all dev"
34
34
  },
35
- "gitHead": "7e32500820075709b3e4d55ec008492513e67a1f"
35
+ "devDependencies": {
36
+ "@microsoft/api-extractor": "7.53.3",
37
+ "@rslib/core": "0.17.0"
38
+ },
39
+ "gitHead": "5468cd47f99f2c96e1d242830c5d4dfe96ae20bc"
36
40
  }