@versini/sassysaint-common 4.0.1 → 4.0.4
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 +7 -1
- package/dist/index.js +50 -48
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -76,11 +76,17 @@ declare const POLICY_GRANTS: {
|
|
76
76
|
declare const CALLISTO_CHAT_ID_HEADER = "x-callisto-chat-id";
|
77
77
|
/**
|
78
78
|
* This function finds the provider associated with a given model name.
|
79
|
+
* It checks the model name against a list of approximate models for each provider.
|
79
80
|
*
|
80
81
|
* @param modelName - The model name to check.
|
81
82
|
* @returns The provider associated with the model name or null if not found.
|
82
83
|
*/
|
83
84
|
declare const findProvider: (modelName: string) => null | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_OPENAI | typeof PROVIDER_GOOGLE;
|
85
|
+
/**
|
86
|
+
* Sort capabilities are shared across client and server.
|
87
|
+
*/
|
88
|
+
declare const SORT_BY_TIMESTAMP = "timestamp";
|
89
|
+
declare const SORT_BY_TOKEN_USAGE = "tokenUsage";
|
84
90
|
|
85
91
|
/**
|
86
92
|
* TypeScript interfaces for Server-Mediated Encryption
|
@@ -280,4 +286,4 @@ declare namespace index {
|
|
280
286
|
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 };
|
281
287
|
}
|
282
288
|
|
283
|
-
export { ALL_MODELS, ALL_PROVIDERS, ALL_REASONING_MODELS, CALLISTO_CHAT_ID_HEADER, DEFAULT_PROVIDER, MODELS_PER_PROVIDER, MODEL_CLAUDE_HAIKU, MODEL_CLAUDE_SONNET, MODEL_GEMINI_FLASH, MODEL_GEMINI_PRO, MODEL_GPT4, MODEL_GPT4_MINI, MODEL_O4_MINI, MODEL_SONAR, MODEL_SONAR_PRO, PLAN_FREE, PLAN_PLUS, PLAN_PREMIUM, POLICY_GRANTS, PROVIDER_ANTHROPIC, PROVIDER_GOOGLE, PROVIDER_MEMORY, PROVIDER_OPENAI, PROVIDER_PERPLEXITY, PROVIDER_ROLE_MAP, PROVIDER_SUMMARY, ROLE_ASSISTANT, ROLE_HIDDEN, ROLE_INTERNAL, ROLE_SYSTEM, ROLE_USER, index as crypto, findProvider };
|
289
|
+
export { ALL_MODELS, ALL_PROVIDERS, ALL_REASONING_MODELS, CALLISTO_CHAT_ID_HEADER, DEFAULT_PROVIDER, MODELS_PER_PROVIDER, MODEL_CLAUDE_HAIKU, MODEL_CLAUDE_SONNET, MODEL_GEMINI_FLASH, MODEL_GEMINI_PRO, MODEL_GPT4, MODEL_GPT4_MINI, MODEL_O4_MINI, MODEL_SONAR, MODEL_SONAR_PRO, PLAN_FREE, PLAN_PLUS, PLAN_PREMIUM, POLICY_GRANTS, PROVIDER_ANTHROPIC, PROVIDER_GOOGLE, PROVIDER_MEMORY, 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, index as crypto, findProvider };
|
package/dist/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
const g = "system", s = "user", c = "assistant",
|
1
|
+
const g = "system", s = "user", c = "assistant", te = "hidden", re = "data", a = "OpenAI", i = "Anthropic", E = "Google", M = "Summary", m = "Memory", d = "Perplexity", ne = a, oe = [
|
2
2
|
a,
|
3
3
|
i,
|
4
|
-
|
5
|
-
], _ = "gpt-4.1", l = "gpt-4.1-nano", u = "o4-mini", f = "claude-3-5-haiku-20241022", p = "claude-sonnet-4-20250514", R = "gemini-2.5-flash", A = "gemini-2.5-pro", P = "sonar",
|
4
|
+
E
|
5
|
+
], _ = "gpt-4.1", l = "gpt-4.1-nano", u = "o4-mini", f = "claude-3-5-haiku-20241022", p = "claude-sonnet-4-20250514", R = "gemini-2.5-flash", A = "gemini-2.5-pro", P = "sonar", S = "sonar-pro", se = [
|
6
6
|
_,
|
7
7
|
l,
|
8
8
|
u,
|
@@ -11,8 +11,8 @@ const g = "system", s = "user", c = "assistant", ee = "hidden", te = "data", a =
|
|
11
11
|
R,
|
12
12
|
A,
|
13
13
|
P,
|
14
|
-
|
15
|
-
],
|
14
|
+
S
|
15
|
+
], ce = [
|
16
16
|
u,
|
17
17
|
p,
|
18
18
|
A
|
@@ -26,44 +26,44 @@ const g = "system", s = "user", c = "assistant", ee = "hidden", te = "data", a =
|
|
26
26
|
N,
|
27
27
|
v
|
28
28
|
],
|
29
|
-
[
|
29
|
+
[E]: [K],
|
30
30
|
[d]: [C]
|
31
|
-
},
|
31
|
+
}, ae = {
|
32
32
|
[a]: [l, _, u],
|
33
33
|
[i]: [f, p],
|
34
|
-
[
|
35
|
-
[d]: [P,
|
36
|
-
},
|
34
|
+
[E]: [R, A],
|
35
|
+
[d]: [P, S]
|
36
|
+
}, ie = {
|
37
37
|
[a]: [g, s, c],
|
38
38
|
[i]: [s, c],
|
39
39
|
[M]: [s, c],
|
40
40
|
[m]: [s, c],
|
41
|
-
[
|
41
|
+
[E]: [s, c],
|
42
42
|
[d]: [s, c]
|
43
|
-
}, k = "sassy:free", F = "sassy:plus", G = "sassy:advanced",
|
43
|
+
}, k = "sassy:free", F = "sassy:plus", G = "sassy:advanced", V = "sassy:advanced:reasoning", Ee = {
|
44
44
|
PLAN_FREE: k,
|
45
45
|
PLAN_PLUS: F,
|
46
46
|
PLAN_PREMIUM: G,
|
47
|
-
REASONING:
|
48
|
-
}, ye = "x-callisto-chat-id",
|
47
|
+
REASONING: V
|
48
|
+
}, ye = "x-callisto-chat-id", de = (r) => {
|
49
49
|
for (const [e, n] of Object.entries(
|
50
50
|
U
|
51
51
|
))
|
52
52
|
if (n.some((t) => r.startsWith(t)))
|
53
53
|
return e;
|
54
54
|
return null;
|
55
|
-
};
|
55
|
+
}, ue = "timestamp", pe = "tokenUsage";
|
56
56
|
class o extends Error {
|
57
57
|
constructor(e, n, t) {
|
58
58
|
super(e), this.code = n, this.originalError = t, this.name = "CryptoError";
|
59
59
|
}
|
60
60
|
}
|
61
|
-
const
|
61
|
+
const I = {
|
62
62
|
keySize: 4096,
|
63
63
|
debug: !1
|
64
64
|
};
|
65
|
-
async function
|
66
|
-
const e = { ...
|
65
|
+
async function Y(r = {}) {
|
66
|
+
const e = { ...I, ...r };
|
67
67
|
try {
|
68
68
|
const n = {
|
69
69
|
modulusLength: e.keySize,
|
@@ -114,7 +114,7 @@ async function x(r) {
|
|
114
114
|
);
|
115
115
|
}
|
116
116
|
}
|
117
|
-
async function
|
117
|
+
async function L(r) {
|
118
118
|
try {
|
119
119
|
const e = JSON.parse(r);
|
120
120
|
return await crypto.subtle.importKey(
|
@@ -136,9 +136,9 @@ async function D(r) {
|
|
136
136
|
);
|
137
137
|
}
|
138
138
|
}
|
139
|
-
async function
|
139
|
+
async function X(r, e, n) {
|
140
140
|
try {
|
141
|
-
const O = new TextEncoder().encode(r),
|
141
|
+
const O = new TextEncoder().encode(r), y = await crypto.subtle.encrypt(
|
142
142
|
{
|
143
143
|
name: "RSA-OAEP"
|
144
144
|
},
|
@@ -147,7 +147,7 @@ async function Y(r, e, n) {
|
|
147
147
|
);
|
148
148
|
return {
|
149
149
|
data: btoa(
|
150
|
-
String.fromCharCode(...new Uint8Array(
|
150
|
+
String.fromCharCode(...new Uint8Array(y))
|
151
151
|
),
|
152
152
|
algorithm: "RSA-OAEP",
|
153
153
|
keyId: n
|
@@ -164,7 +164,7 @@ async function H(r, e) {
|
|
164
164
|
try {
|
165
165
|
const n = Uint8Array.from(
|
166
166
|
atob(r.data),
|
167
|
-
(
|
167
|
+
(y) => y.charCodeAt(0)
|
168
168
|
), t = await crypto.subtle.decrypt(
|
169
169
|
{
|
170
170
|
name: "RSA-OAEP"
|
@@ -181,9 +181,9 @@ async function H(r, e) {
|
|
181
181
|
);
|
182
182
|
}
|
183
183
|
}
|
184
|
-
async function
|
184
|
+
async function $(r, e, n) {
|
185
185
|
try {
|
186
|
-
const t = await
|
186
|
+
const t = await L(
|
187
187
|
r.serverPublicKey
|
188
188
|
);
|
189
189
|
return {
|
@@ -201,10 +201,10 @@ async function X(r, e, n) {
|
|
201
201
|
);
|
202
202
|
}
|
203
203
|
}
|
204
|
-
function
|
204
|
+
function j(r) {
|
205
205
|
return !(!r || !r.clientKeyPair || !r.serverPublicKey);
|
206
206
|
}
|
207
|
-
function
|
207
|
+
function B() {
|
208
208
|
const r = Date.now().toString(36), e = new Uint8Array(8);
|
209
209
|
if (typeof window < "u" && window.crypto?.getRandomValues)
|
210
210
|
window.crypto.getRandomValues(e);
|
@@ -214,53 +214,53 @@ function j() {
|
|
214
214
|
const n = Array.from(e).map((t) => t.toString(36)).join("");
|
215
215
|
return `device_${r}_${n}`;
|
216
216
|
}
|
217
|
-
function
|
217
|
+
function D() {
|
218
218
|
return typeof window < "u" && typeof window.crypto < "u" && typeof window.crypto.subtle < "u";
|
219
219
|
}
|
220
220
|
function w() {
|
221
221
|
return typeof window < "u" && (window.isSecureContext || window.location.protocol === "https:");
|
222
222
|
}
|
223
223
|
function z() {
|
224
|
-
return
|
224
|
+
return D() && w();
|
225
225
|
}
|
226
|
-
function
|
226
|
+
function J(r) {
|
227
227
|
const e = new Uint8Array(r);
|
228
228
|
let n = "";
|
229
229
|
for (let t = 0; t < e.byteLength; t++)
|
230
230
|
n += String.fromCharCode(e[t]);
|
231
231
|
return btoa(n);
|
232
232
|
}
|
233
|
-
function
|
233
|
+
function W(r) {
|
234
234
|
const e = atob(r), n = new Uint8Array(e.length);
|
235
235
|
for (let t = 0; t < e.length; t++)
|
236
236
|
n[t] = e.charCodeAt(t);
|
237
237
|
return n.buffer;
|
238
238
|
}
|
239
|
-
function
|
239
|
+
function q(r) {
|
240
240
|
try {
|
241
241
|
return JSON.stringify(r);
|
242
242
|
} catch {
|
243
243
|
return String(r);
|
244
244
|
}
|
245
245
|
}
|
246
|
-
function
|
246
|
+
function Q(r) {
|
247
247
|
try {
|
248
248
|
return JSON.parse(r);
|
249
249
|
} catch {
|
250
250
|
return null;
|
251
251
|
}
|
252
252
|
}
|
253
|
-
function
|
253
|
+
function Z(r, ...e) {
|
254
254
|
typeof process < "u" && process.env && process.env.NODE_ENV === "development" && console.info(`🔐 [Crypto] ${r}`, ...e);
|
255
255
|
}
|
256
|
-
const
|
256
|
+
const Ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, CryptoError: o, DEFAULT_CRYPTO_CONFIG: I, arrayBufferToBase64: J, base64ToArrayBuffer: W, canUseEncryption: z, debugLog: Z, decryptFromServer: H, encryptForServer: X, establishCryptoSession: $, exportPublicKey: x, generateClientKeyPair: Y, generateDeviceId: B, importServerPublicKey: L, isCryptoSessionValid: j, isSecureContext: w, isWebCryptoSupported: D, safeParse: Q, safeStringify: q }, Symbol.toStringTag, { value: "Module" }));
|
257
257
|
export {
|
258
|
-
|
259
|
-
|
260
|
-
|
258
|
+
se as ALL_MODELS,
|
259
|
+
oe as ALL_PROVIDERS,
|
260
|
+
ce as ALL_REASONING_MODELS,
|
261
261
|
ye as CALLISTO_CHAT_ID_HEADER,
|
262
|
-
|
263
|
-
|
262
|
+
ne as DEFAULT_PROVIDER,
|
263
|
+
ae as MODELS_PER_PROVIDER,
|
264
264
|
f as MODEL_CLAUDE_HAIKU,
|
265
265
|
p as MODEL_CLAUDE_SONNET,
|
266
266
|
R as MODEL_GEMINI_FLASH,
|
@@ -269,23 +269,25 @@ export {
|
|
269
269
|
l as MODEL_GPT4_MINI,
|
270
270
|
u as MODEL_O4_MINI,
|
271
271
|
P as MODEL_SONAR,
|
272
|
-
|
272
|
+
S as MODEL_SONAR_PRO,
|
273
273
|
k as PLAN_FREE,
|
274
274
|
F as PLAN_PLUS,
|
275
275
|
G as PLAN_PREMIUM,
|
276
|
-
|
276
|
+
Ee as POLICY_GRANTS,
|
277
277
|
i as PROVIDER_ANTHROPIC,
|
278
|
-
|
278
|
+
E as PROVIDER_GOOGLE,
|
279
279
|
m as PROVIDER_MEMORY,
|
280
280
|
a as PROVIDER_OPENAI,
|
281
281
|
d as PROVIDER_PERPLEXITY,
|
282
|
-
|
282
|
+
ie as PROVIDER_ROLE_MAP,
|
283
283
|
M as PROVIDER_SUMMARY,
|
284
284
|
c as ROLE_ASSISTANT,
|
285
|
-
|
286
|
-
|
285
|
+
te as ROLE_HIDDEN,
|
286
|
+
re as ROLE_INTERNAL,
|
287
287
|
g as ROLE_SYSTEM,
|
288
288
|
s as ROLE_USER,
|
289
|
-
|
290
|
-
|
289
|
+
ue as SORT_BY_TIMESTAMP,
|
290
|
+
pe as SORT_BY_TOKEN_USAGE,
|
291
|
+
Ae as crypto,
|
292
|
+
de as findProvider
|
291
293
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@versini/sassysaint-common",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Arno Versini",
|
6
6
|
"publishConfig": {
|
@@ -30,5 +30,5 @@
|
|
30
30
|
"test:watch": "vitest",
|
31
31
|
"watch": "npm-run-all dev"
|
32
32
|
},
|
33
|
-
"gitHead": "
|
33
|
+
"gitHead": "6fbcb4192fea2a841710741760d6c3d6b91c63fa"
|
34
34
|
}
|