commons-proxy 2.0.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/LICENSE +21 -0
- package/README.md +757 -0
- package/bin/cli.js +146 -0
- package/package.json +97 -0
- package/public/Complaint Details.pdf +0 -0
- package/public/Cyber Crime Portal.pdf +0 -0
- package/public/app.js +229 -0
- package/public/css/src/input.css +523 -0
- package/public/css/style.css +1 -0
- package/public/favicon.png +0 -0
- package/public/index.html +549 -0
- package/public/js/components/account-manager.js +356 -0
- package/public/js/components/add-account-modal.js +414 -0
- package/public/js/components/claude-config.js +420 -0
- package/public/js/components/dashboard/charts.js +605 -0
- package/public/js/components/dashboard/filters.js +362 -0
- package/public/js/components/dashboard/stats.js +110 -0
- package/public/js/components/dashboard.js +236 -0
- package/public/js/components/logs-viewer.js +100 -0
- package/public/js/components/models.js +36 -0
- package/public/js/components/server-config.js +349 -0
- package/public/js/config/constants.js +102 -0
- package/public/js/data-store.js +375 -0
- package/public/js/settings-store.js +58 -0
- package/public/js/store.js +99 -0
- package/public/js/translations/en.js +367 -0
- package/public/js/translations/id.js +412 -0
- package/public/js/translations/pt.js +308 -0
- package/public/js/translations/tr.js +358 -0
- package/public/js/translations/zh.js +373 -0
- package/public/js/utils/account-actions.js +189 -0
- package/public/js/utils/error-handler.js +96 -0
- package/public/js/utils/model-config.js +42 -0
- package/public/js/utils/ui-logger.js +143 -0
- package/public/js/utils/validators.js +77 -0
- package/public/js/utils.js +69 -0
- package/public/proxy-server-64.png +0 -0
- package/public/views/accounts.html +361 -0
- package/public/views/dashboard.html +484 -0
- package/public/views/logs.html +97 -0
- package/public/views/models.html +331 -0
- package/public/views/settings.html +1327 -0
- package/src/account-manager/credentials.js +378 -0
- package/src/account-manager/index.js +462 -0
- package/src/account-manager/onboarding.js +112 -0
- package/src/account-manager/rate-limits.js +369 -0
- package/src/account-manager/storage.js +160 -0
- package/src/account-manager/strategies/base-strategy.js +109 -0
- package/src/account-manager/strategies/hybrid-strategy.js +339 -0
- package/src/account-manager/strategies/index.js +79 -0
- package/src/account-manager/strategies/round-robin-strategy.js +76 -0
- package/src/account-manager/strategies/sticky-strategy.js +138 -0
- package/src/account-manager/strategies/trackers/health-tracker.js +162 -0
- package/src/account-manager/strategies/trackers/index.js +9 -0
- package/src/account-manager/strategies/trackers/quota-tracker.js +120 -0
- package/src/account-manager/strategies/trackers/token-bucket-tracker.js +155 -0
- package/src/auth/database.js +169 -0
- package/src/auth/oauth.js +548 -0
- package/src/auth/token-extractor.js +117 -0
- package/src/cli/accounts.js +648 -0
- package/src/cloudcode/index.js +29 -0
- package/src/cloudcode/message-handler.js +510 -0
- package/src/cloudcode/model-api.js +248 -0
- package/src/cloudcode/rate-limit-parser.js +235 -0
- package/src/cloudcode/request-builder.js +93 -0
- package/src/cloudcode/session-manager.js +47 -0
- package/src/cloudcode/sse-parser.js +121 -0
- package/src/cloudcode/sse-streamer.js +293 -0
- package/src/cloudcode/streaming-handler.js +615 -0
- package/src/config.js +125 -0
- package/src/constants.js +407 -0
- package/src/errors.js +242 -0
- package/src/fallback-config.js +29 -0
- package/src/format/content-converter.js +193 -0
- package/src/format/index.js +20 -0
- package/src/format/request-converter.js +255 -0
- package/src/format/response-converter.js +120 -0
- package/src/format/schema-sanitizer.js +673 -0
- package/src/format/signature-cache.js +88 -0
- package/src/format/thinking-utils.js +648 -0
- package/src/index.js +148 -0
- package/src/modules/usage-stats.js +205 -0
- package/src/providers/anthropic-provider.js +258 -0
- package/src/providers/base-provider.js +157 -0
- package/src/providers/cloudcode.js +94 -0
- package/src/providers/copilot.js +399 -0
- package/src/providers/github-provider.js +287 -0
- package/src/providers/google-provider.js +192 -0
- package/src/providers/index.js +211 -0
- package/src/providers/openai-compatible.js +265 -0
- package/src/providers/openai-provider.js +271 -0
- package/src/providers/openrouter-provider.js +325 -0
- package/src/providers/setup.js +83 -0
- package/src/server.js +870 -0
- package/src/utils/claude-config.js +245 -0
- package/src/utils/helpers.js +51 -0
- package/src/utils/logger.js +142 -0
- package/src/utils/native-module-helper.js +162 -0
- package/src/webui/index.js +1134 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature Cache
|
|
3
|
+
* In-memory cache for Gemini thoughtSignatures
|
|
4
|
+
*
|
|
5
|
+
* Gemini models require thoughtSignature on tool calls, but Claude Code
|
|
6
|
+
* strips non-standard fields. This cache stores signatures by tool_use_id
|
|
7
|
+
* so they can be restored in subsequent requests.
|
|
8
|
+
*
|
|
9
|
+
* Also caches thinking block signatures with model family for cross-model
|
|
10
|
+
* compatibility checking.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { GEMINI_SIGNATURE_CACHE_TTL_MS, MIN_SIGNATURE_LENGTH } from '../constants.js';
|
|
14
|
+
|
|
15
|
+
const signatureCache = new Map();
|
|
16
|
+
const thinkingSignatureCache = new Map();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Store a signature for a tool_use_id
|
|
20
|
+
* @param {string} toolUseId - The tool use ID
|
|
21
|
+
* @param {string} signature - The thoughtSignature to cache
|
|
22
|
+
*/
|
|
23
|
+
export function cacheSignature(toolUseId, signature) {
|
|
24
|
+
if (!toolUseId || !signature) return;
|
|
25
|
+
signatureCache.set(toolUseId, {
|
|
26
|
+
signature,
|
|
27
|
+
timestamp: Date.now()
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get a cached signature for a tool_use_id
|
|
33
|
+
* @param {string} toolUseId - The tool use ID
|
|
34
|
+
* @returns {string|null} The cached signature or null if not found/expired
|
|
35
|
+
*/
|
|
36
|
+
export function getCachedSignature(toolUseId) {
|
|
37
|
+
if (!toolUseId) return null;
|
|
38
|
+
const entry = signatureCache.get(toolUseId);
|
|
39
|
+
if (!entry) return null;
|
|
40
|
+
|
|
41
|
+
// Check TTL
|
|
42
|
+
if (Date.now() - entry.timestamp > GEMINI_SIGNATURE_CACHE_TTL_MS) {
|
|
43
|
+
signatureCache.delete(toolUseId);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return entry.signature;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Cache a thinking block signature with its model family
|
|
52
|
+
* @param {string} signature - The thinking signature to cache
|
|
53
|
+
* @param {string} modelFamily - The model family ('claude' or 'gemini')
|
|
54
|
+
*/
|
|
55
|
+
export function cacheThinkingSignature(signature, modelFamily) {
|
|
56
|
+
if (!signature || signature.length < MIN_SIGNATURE_LENGTH) return;
|
|
57
|
+
thinkingSignatureCache.set(signature, {
|
|
58
|
+
modelFamily,
|
|
59
|
+
timestamp: Date.now()
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get the cached model family for a thinking signature
|
|
65
|
+
* @param {string} signature - The signature to look up
|
|
66
|
+
* @returns {string|null} 'claude', 'gemini', or null if not found/expired
|
|
67
|
+
*/
|
|
68
|
+
export function getCachedSignatureFamily(signature) {
|
|
69
|
+
if (!signature) return null;
|
|
70
|
+
const entry = thinkingSignatureCache.get(signature);
|
|
71
|
+
if (!entry) return null;
|
|
72
|
+
|
|
73
|
+
// Check TTL
|
|
74
|
+
if (Date.now() - entry.timestamp > GEMINI_SIGNATURE_CACHE_TTL_MS) {
|
|
75
|
+
thinkingSignatureCache.delete(signature);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return entry.modelFamily;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Clear all entries from the thinking signature cache.
|
|
84
|
+
* Used for testing cold cache scenarios.
|
|
85
|
+
*/
|
|
86
|
+
export function clearThinkingSignatureCache() {
|
|
87
|
+
thinkingSignatureCache.clear();
|
|
88
|
+
}
|