@jsonstudio/rcc 0.89.683 → 0.89.873
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/build-info.js +2 -2
- package/dist/cli.js +164 -116
- package/dist/cli.js.map +1 -1
- package/dist/client/anthropic/anthropic-protocol-client.js +42 -1
- package/dist/client/anthropic/anthropic-protocol-client.js.map +1 -1
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js +4 -1
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
- package/dist/commands/camoufox-backfill.d.ts +2 -0
- package/dist/commands/camoufox-backfill.js +33 -0
- package/dist/commands/camoufox-backfill.js.map +1 -0
- package/dist/commands/camoufox-fp.d.ts +2 -0
- package/dist/commands/camoufox-fp.js +86 -0
- package/dist/commands/camoufox-fp.js.map +1 -0
- package/dist/commands/oauth.d.ts +2 -0
- package/dist/commands/oauth.js +170 -0
- package/dist/commands/oauth.js.map +1 -0
- package/dist/commands/provider-update.js +439 -2
- package/dist/commands/provider-update.js.map +1 -1
- package/dist/commands/quota-status.d.ts +2 -0
- package/dist/commands/quota-status.js +80 -0
- package/dist/commands/quota-status.js.map +1 -0
- package/dist/commands/token-daemon.js +12 -1
- package/dist/commands/token-daemon.js.map +1 -1
- package/dist/config/provider-v2-loader.d.ts +16 -0
- package/dist/config/provider-v2-loader.js +84 -0
- package/dist/config/provider-v2-loader.js.map +1 -0
- package/dist/config/routecodex-config-loader.js +27 -4
- package/dist/config/routecodex-config-loader.js.map +1 -1
- package/dist/config/system-prompts/codex-cli.txt +1 -0
- package/dist/config/virtual-router-builder.d.ts +9 -0
- package/dist/config/virtual-router-builder.js +34 -0
- package/dist/config/virtual-router-builder.js.map +1 -0
- package/dist/config/virtual-router-types.d.ts +25 -0
- package/dist/config/virtual-router-types.js +30 -0
- package/dist/config/virtual-router-types.js.map +1 -0
- package/dist/manager/index.d.ts +10 -0
- package/dist/manager/index.js +27 -0
- package/dist/manager/index.js.map +1 -0
- package/dist/manager/modules/health/index.d.ts +22 -0
- package/dist/manager/modules/health/index.js +82 -0
- package/dist/manager/modules/health/index.js.map +1 -0
- package/dist/manager/modules/quota/index.d.ts +57 -0
- package/dist/manager/modules/quota/index.js +426 -0
- package/dist/manager/modules/quota/index.js.map +1 -0
- package/dist/manager/modules/routing/index.d.ts +17 -0
- package/dist/manager/modules/routing/index.js +61 -0
- package/dist/manager/modules/routing/index.js.map +1 -0
- package/dist/manager/modules/token/index.d.ts +10 -0
- package/dist/manager/modules/token/index.js +58 -0
- package/dist/manager/modules/token/index.js.map +1 -0
- package/dist/manager/storage/base-store.d.ts +6 -0
- package/dist/manager/storage/base-store.js +2 -0
- package/dist/manager/storage/base-store.js.map +1 -0
- package/dist/manager/storage/file-store.d.ts +25 -0
- package/dist/manager/storage/file-store.js +117 -0
- package/dist/manager/storage/file-store.js.map +1 -0
- package/dist/manager/types.d.ts +9 -0
- package/dist/manager/types.js +2 -0
- package/dist/manager/types.js.map +1 -0
- package/dist/message-center/index.d.ts +5 -0
- package/dist/message-center/index.js +6 -0
- package/dist/message-center/index.js.map +1 -0
- package/dist/message-center/message-center.d.ts +93 -0
- package/dist/message-center/message-center.js +189 -0
- package/dist/message-center/message-center.js.map +1 -0
- package/dist/providers/auth/antigravity-userinfo-helper.d.ts +2 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js +102 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -1
- package/dist/providers/auth/iflow-cookie-auth.d.ts +27 -0
- package/dist/providers/auth/iflow-cookie-auth.js +209 -0
- package/dist/providers/auth/iflow-cookie-auth.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle.js +29 -22
- package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
- package/dist/providers/auth/token-scanner/index.js +16 -1
- package/dist/providers/auth/token-scanner/index.js.map +1 -1
- package/dist/providers/core/config/camoufox-launcher.d.ts +16 -0
- package/dist/providers/core/config/camoufox-launcher.js +314 -0
- package/dist/providers/core/config/camoufox-launcher.js.map +1 -0
- package/dist/providers/core/config/oauth-flows.d.ts +9 -0
- package/dist/providers/core/config/oauth-flows.js +50 -19
- package/dist/providers/core/config/oauth-flows.js.map +1 -1
- package/dist/providers/core/config/provider-oauth-configs.d.ts +6 -0
- package/dist/providers/core/config/provider-oauth-configs.js +12 -0
- package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
- package/dist/providers/core/config/service-profiles.js +26 -3
- package/dist/providers/core/config/service-profiles.js.map +1 -1
- package/dist/providers/core/runtime/antigravity-quota-client.d.ts +10 -0
- package/dist/providers/core/runtime/antigravity-quota-client.js +88 -0
- package/dist/providers/core/runtime/antigravity-quota-client.js.map +1 -0
- package/dist/providers/core/runtime/base-provider.d.ts +2 -1
- package/dist/providers/core/runtime/base-provider.js +93 -34
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-http-provider.js +42 -10
- package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.js +24 -0
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
- package/dist/providers/core/runtime/http-transport-provider.d.ts +0 -3
- package/dist/providers/core/runtime/http-transport-provider.js +32 -136
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/provider-error-classifier.js +18 -10
- package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -1
- package/dist/providers/core/runtime/rate-limit-manager.d.ts +6 -0
- package/dist/providers/core/runtime/rate-limit-manager.js +23 -0
- package/dist/providers/core/runtime/rate-limit-manager.js.map +1 -1
- package/dist/providers/core/strategies/oauth-auth-code-flow.d.ts +1 -0
- package/dist/providers/core/strategies/oauth-auth-code-flow.js +3 -2
- package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
- package/dist/providers/core/strategies/oauth-device-flow.d.ts +1 -0
- package/dist/providers/core/strategies/oauth-device-flow.js +3 -2
- package/dist/providers/core/strategies/oauth-device-flow.js.map +1 -1
- package/dist/providers/core/strategies/oauth-hybrid-flow.d.ts +1 -0
- package/dist/providers/core/strategies/oauth-hybrid-flow.js +3 -2
- package/dist/providers/core/strategies/oauth-hybrid-flow.js.map +1 -1
- package/dist/providers/core/utils/http-client.js +43 -1
- package/dist/providers/core/utils/http-client.js.map +1 -1
- package/dist/providers/mock/mock-provider-runtime.js +4 -4
- package/dist/providers/mock/mock-provider-runtime.js.map +1 -1
- package/dist/providers/profile/provider-profile-loader.js +13 -1
- package/dist/providers/profile/provider-profile-loader.js.map +1 -1
- package/dist/providers/profile/provider-profile.d.ts +5 -0
- package/dist/scripts/camoufox/gen-fingerprint-env.py +171 -0
- package/dist/scripts/camoufox/launch-auth.mjs +617 -0
- package/dist/server/runtime/http-server/executor-provider.d.ts +1 -0
- package/dist/server/runtime/http-server/executor-provider.js +26 -0
- package/dist/server/runtime/http-server/executor-provider.js.map +1 -1
- package/dist/server/runtime/http-server/executor-response.d.ts +16 -0
- package/dist/server/runtime/http-server/executor-response.js +164 -0
- package/dist/server/runtime/http-server/executor-response.js.map +1 -0
- package/dist/server/runtime/http-server/index.d.ts +1 -0
- package/dist/server/runtime/http-server/index.js +88 -53
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.js +5 -19
- package/dist/server/runtime/http-server/request-executor.js.map +1 -1
- package/dist/server/runtime/http-server/routes.d.ts +2 -0
- package/dist/server/runtime/http-server/routes.js +33 -1
- package/dist/server/runtime/http-server/routes.js.map +1 -1
- package/dist/server/runtime/http-server/types.d.ts +1 -0
- package/dist/server/utils/client-connection-state.d.ts +8 -0
- package/dist/server/utils/client-connection-state.js +52 -0
- package/dist/server/utils/client-connection-state.js.map +1 -0
- package/dist/server/utils/request-id-manager.js +21 -3
- package/dist/server/utils/request-id-manager.js.map +1 -1
- package/dist/token-daemon/history-store.d.ts +2 -0
- package/dist/token-daemon/history-store.js +6 -2
- package/dist/token-daemon/history-store.js.map +1 -1
- package/dist/token-daemon/index.js +36 -5
- package/dist/token-daemon/index.js.map +1 -1
- package/dist/token-daemon/leader-lock.d.ts +11 -0
- package/dist/token-daemon/leader-lock.js +79 -0
- package/dist/token-daemon/leader-lock.js.map +1 -0
- package/dist/token-daemon/message-bus-integrator.d.ts +98 -0
- package/dist/token-daemon/message-bus-integrator.js +144 -0
- package/dist/token-daemon/message-bus-integrator.js.map +1 -0
- package/dist/token-daemon/provider-registry.d.ts +22 -0
- package/dist/token-daemon/provider-registry.js +201 -0
- package/dist/token-daemon/provider-registry.js.map +1 -0
- package/dist/token-daemon/token-daemon.d.ts +8 -0
- package/dist/token-daemon/token-daemon.js +196 -11
- package/dist/token-daemon/token-daemon.js.map +1 -1
- package/dist/token-portal/local-token-portal.d.ts +1 -0
- package/dist/token-portal/local-token-portal.js +18 -0
- package/dist/token-portal/local-token-portal.js.map +1 -1
- package/dist/token-portal/render.js +1 -0
- package/dist/token-portal/render.js.map +1 -1
- package/dist/tools/error-log.d.ts +31 -0
- package/dist/tools/error-log.js +117 -0
- package/dist/tools/error-log.js.map +1 -0
- package/dist/tools/stats-request-events.d.ts +2 -0
- package/dist/tools/stats-request-events.js +16 -0
- package/dist/tools/stats-request-events.js.map +1 -0
- package/dist/tools/stats-usage.d.ts +31 -0
- package/dist/tools/stats-usage.js +206 -0
- package/dist/tools/stats-usage.js.map +1 -0
- package/package.json +8 -4
- package/scripts/analyze-codex-error-failures.mjs +109 -0
- package/scripts/camoufox/gen-fingerprint-env.py +171 -0
- package/scripts/camoufox/launch-auth.mjs +617 -0
- package/scripts/classify-codex-samples.mjs +251 -0
- package/scripts/cleanup-codex-error-samples.mjs +88 -0
- package/scripts/compare-codex-rccx.mjs +268 -0
- package/scripts/copy-compat-assets.mjs +18 -0
- package/scripts/install-release.sh +1 -1
- package/scripts/local-replay-openai-response.mjs +1 -2
- package/scripts/pack-mode.mjs +16 -6
- package/scripts/replay-codex-sample.mjs +24 -2
- package/scripts/responses-compare-server.mjs +119 -0
- package/scripts/verify-apply-patch.mjs +28 -17
- package/scripts/verify-codex-error-samples.mjs +99 -0
- package/scripts/verify-e2e-toolcall.mjs +19 -4
- package/scripts/virtual-router-shadow-v2-real.mjs +143 -0
- package/scripts/virtual-router-shadow-v2.mjs +122 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
const STATS_DIR = path.join(os.homedir(), '.routecodex', 'stats');
|
|
5
|
+
const REQUEST_EVENTS_FILE = path.join(STATS_DIR, 'request-events.log');
|
|
6
|
+
function createEmptyBucket() {
|
|
7
|
+
return {
|
|
8
|
+
requestCount: 0,
|
|
9
|
+
successCount: 0,
|
|
10
|
+
errorCount: 0,
|
|
11
|
+
latencyMs: { sum: 0, min: Number.POSITIVE_INFINITY, max: 0 },
|
|
12
|
+
tokens: { prompt: 0, completion: 0, total: 0 }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createEmptyDailyUsage() {
|
|
16
|
+
return {
|
|
17
|
+
byProviderKey: {},
|
|
18
|
+
byRoute: {},
|
|
19
|
+
byPool: {},
|
|
20
|
+
byEndpoint: {}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function applyEventToBucket(bucket, ev) {
|
|
24
|
+
bucket.requestCount += 1;
|
|
25
|
+
if (ev.success) {
|
|
26
|
+
bucket.successCount += 1;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
bucket.errorCount += 1;
|
|
30
|
+
}
|
|
31
|
+
if (typeof ev.latencyMs === 'number' && Number.isFinite(ev.latencyMs) && ev.latencyMs >= 0) {
|
|
32
|
+
bucket.latencyMs.sum += ev.latencyMs;
|
|
33
|
+
if (ev.latencyMs < bucket.latencyMs.min) {
|
|
34
|
+
bucket.latencyMs.min = ev.latencyMs;
|
|
35
|
+
}
|
|
36
|
+
if (ev.latencyMs > bucket.latencyMs.max) {
|
|
37
|
+
bucket.latencyMs.max = ev.latencyMs;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (typeof ev.promptTokens === 'number' && Number.isFinite(ev.promptTokens) && ev.promptTokens > 0) {
|
|
41
|
+
bucket.tokens.prompt += ev.promptTokens;
|
|
42
|
+
}
|
|
43
|
+
if (typeof ev.completionTokens === 'number' &&
|
|
44
|
+
Number.isFinite(ev.completionTokens) &&
|
|
45
|
+
ev.completionTokens > 0) {
|
|
46
|
+
bucket.tokens.completion += ev.completionTokens;
|
|
47
|
+
}
|
|
48
|
+
if (typeof ev.totalTokens === 'number' && Number.isFinite(ev.totalTokens) && ev.totalTokens > 0) {
|
|
49
|
+
bucket.tokens.total += ev.totalTokens;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const derived = (typeof ev.promptTokens === 'number' && Number.isFinite(ev.promptTokens) && ev.promptTokens > 0
|
|
53
|
+
? ev.promptTokens
|
|
54
|
+
: 0) +
|
|
55
|
+
(typeof ev.completionTokens === 'number' &&
|
|
56
|
+
Number.isFinite(ev.completionTokens) &&
|
|
57
|
+
ev.completionTokens > 0
|
|
58
|
+
? ev.completionTokens
|
|
59
|
+
: 0);
|
|
60
|
+
bucket.tokens.total += derived;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function ensureDailyBucket(map, key) {
|
|
64
|
+
if (!map[key]) {
|
|
65
|
+
map[key] = createEmptyDailyUsage();
|
|
66
|
+
}
|
|
67
|
+
return map[key];
|
|
68
|
+
}
|
|
69
|
+
function formatDayKey(timestamp) {
|
|
70
|
+
const d = new Date(timestamp);
|
|
71
|
+
const year = d.getFullYear();
|
|
72
|
+
const month = `${d.getMonth() + 1}`.padStart(2, '0');
|
|
73
|
+
const day = `${d.getDate()}`.padStart(2, '0');
|
|
74
|
+
return `${year}-${month}-${day}`;
|
|
75
|
+
}
|
|
76
|
+
function formatWeekKey(timestamp) {
|
|
77
|
+
const d = new Date(timestamp);
|
|
78
|
+
const onejan = new Date(d.getFullYear(), 0, 1);
|
|
79
|
+
const dayMs = 24 * 60 * 60 * 1000;
|
|
80
|
+
const dayOfYear = Math.floor((d.getTime() - onejan.getTime()) / dayMs) + 1;
|
|
81
|
+
const week = Math.ceil(dayOfYear / 7);
|
|
82
|
+
const year = d.getFullYear();
|
|
83
|
+
const weekStr = `${week}`.padStart(2, '0');
|
|
84
|
+
return `${year}-W${weekStr}`;
|
|
85
|
+
}
|
|
86
|
+
export async function loadUsageTimeSeries(query) {
|
|
87
|
+
const result = { days: {}, weeks: {} };
|
|
88
|
+
let content;
|
|
89
|
+
try {
|
|
90
|
+
content = await fs.readFile(REQUEST_EVENTS_FILE, 'utf8');
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
if (!content) {
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
const lines = content.split('\n');
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
const trimmed = line.trim();
|
|
101
|
+
if (!trimmed) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
let ev = null;
|
|
105
|
+
try {
|
|
106
|
+
const parsed = JSON.parse(trimmed);
|
|
107
|
+
if (parsed && typeof parsed === 'object' && typeof parsed.timestamp === 'number') {
|
|
108
|
+
ev = parsed;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (!ev) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const ts = ev.timestamp;
|
|
118
|
+
if (typeof ts !== 'number' || !Number.isFinite(ts)) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (query.fromMs && ts < query.fromMs) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (query.toMs && ts > query.toMs) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const dayKey = formatDayKey(ts);
|
|
128
|
+
const weekKey = formatWeekKey(ts);
|
|
129
|
+
const dayBucket = ensureDailyBucket(result.days, dayKey);
|
|
130
|
+
const providerKey = ev.providerKey || 'unknown';
|
|
131
|
+
const routeKey = ev.routeName || 'unknown';
|
|
132
|
+
const poolKey = ev.poolId || 'default';
|
|
133
|
+
const endpointKey = ev.entryEndpoint || 'unknown';
|
|
134
|
+
if (!dayBucket.byProviderKey[providerKey]) {
|
|
135
|
+
dayBucket.byProviderKey[providerKey] = createEmptyBucket();
|
|
136
|
+
}
|
|
137
|
+
applyEventToBucket(dayBucket.byProviderKey[providerKey], ev);
|
|
138
|
+
if (!dayBucket.byRoute[routeKey]) {
|
|
139
|
+
dayBucket.byRoute[routeKey] = createEmptyBucket();
|
|
140
|
+
}
|
|
141
|
+
applyEventToBucket(dayBucket.byRoute[routeKey], ev);
|
|
142
|
+
if (!dayBucket.byPool[poolKey]) {
|
|
143
|
+
dayBucket.byPool[poolKey] = createEmptyBucket();
|
|
144
|
+
}
|
|
145
|
+
applyEventToBucket(dayBucket.byPool[poolKey], ev);
|
|
146
|
+
if (!dayBucket.byEndpoint[endpointKey]) {
|
|
147
|
+
dayBucket.byEndpoint[endpointKey] = createEmptyBucket();
|
|
148
|
+
}
|
|
149
|
+
applyEventToBucket(dayBucket.byEndpoint[endpointKey], ev);
|
|
150
|
+
const weekBucket = ensureDailyBucket(result.weeks, weekKey);
|
|
151
|
+
if (!weekBucket.byProviderKey[providerKey]) {
|
|
152
|
+
weekBucket.byProviderKey[providerKey] = createEmptyBucket();
|
|
153
|
+
}
|
|
154
|
+
applyEventToBucket(weekBucket.byProviderKey[providerKey], ev);
|
|
155
|
+
if (!weekBucket.byRoute[routeKey]) {
|
|
156
|
+
weekBucket.byRoute[routeKey] = createEmptyBucket();
|
|
157
|
+
}
|
|
158
|
+
applyEventToBucket(weekBucket.byRoute[routeKey], ev);
|
|
159
|
+
if (!weekBucket.byPool[poolKey]) {
|
|
160
|
+
weekBucket.byPool[poolKey] = createEmptyBucket();
|
|
161
|
+
}
|
|
162
|
+
applyEventToBucket(weekBucket.byPool[poolKey], ev);
|
|
163
|
+
if (!weekBucket.byEndpoint[endpointKey]) {
|
|
164
|
+
weekBucket.byEndpoint[endpointKey] = createEmptyBucket();
|
|
165
|
+
}
|
|
166
|
+
applyEventToBucket(weekBucket.byEndpoint[endpointKey], ev);
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
export function summarizeUsage(timeSeries, period, group) {
|
|
171
|
+
const summary = {};
|
|
172
|
+
const source = period === 'day' ? timeSeries.days : period === 'week' ? timeSeries.weeks : timeSeries.days;
|
|
173
|
+
const pickGroup = (daily) => {
|
|
174
|
+
if (group === 'provider')
|
|
175
|
+
return daily.byProviderKey;
|
|
176
|
+
if (group === 'route')
|
|
177
|
+
return daily.byRoute;
|
|
178
|
+
if (group === 'pool')
|
|
179
|
+
return daily.byPool;
|
|
180
|
+
return daily.byEndpoint;
|
|
181
|
+
};
|
|
182
|
+
for (const daily of Object.values(source)) {
|
|
183
|
+
const map = pickGroup(daily);
|
|
184
|
+
for (const [key, bucket] of Object.entries(map)) {
|
|
185
|
+
if (!summary[key]) {
|
|
186
|
+
summary[key] = createEmptyBucket();
|
|
187
|
+
}
|
|
188
|
+
const target = summary[key];
|
|
189
|
+
target.requestCount += bucket.requestCount;
|
|
190
|
+
target.successCount += bucket.successCount;
|
|
191
|
+
target.errorCount += bucket.errorCount;
|
|
192
|
+
target.latencyMs.sum += bucket.latencyMs.sum;
|
|
193
|
+
if (bucket.latencyMs.min < target.latencyMs.min) {
|
|
194
|
+
target.latencyMs.min = bucket.latencyMs.min;
|
|
195
|
+
}
|
|
196
|
+
if (bucket.latencyMs.max > target.latencyMs.max) {
|
|
197
|
+
target.latencyMs.max = bucket.latencyMs.max;
|
|
198
|
+
}
|
|
199
|
+
target.tokens.prompt += bucket.tokens.prompt;
|
|
200
|
+
target.tokens.completion += bucket.tokens.completion;
|
|
201
|
+
target.tokens.total += bucket.tokens.total;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return summary;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=stats-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats-usage.js","sourceRoot":"","sources":["../../src/tools/stats-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AAClE,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AA2BvE,SAAS,iBAAiB;IACxB,OAAO;QACL,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,CAAC;QACb,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,EAAE;QAC5D,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KAC/C,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB;IAC5B,OAAO;QACL,aAAa,EAAE,EAAE;QACjB,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,EAAE;KACf,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAmB,EAAE,EAAsB;IACrE,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACf,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,O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AM,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;YACrD,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonstudio/rcc",
|
|
3
|
-
"version": "0.89.
|
|
3
|
+
"version": "0.89.873",
|
|
4
4
|
"description": "Multi-provider OpenAI proxy server with anthropic/responses/chat support (release)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "npm run llmswitch:ensure && node scripts/build-core.mjs && node scripts/vendor-core.mjs && npm run clean && node scripts/gen-build-info.mjs && tsc && node scripts/copy-compat-assets.mjs && node scripts/copy-modules-config.mjs",
|
|
31
|
-
"build:dev": "BUILD_MODE=dev npm run build && npm run verify:e2e-toolcall && npm run verify:apply-patch && npm run test:routing-instructions && npm run install:global",
|
|
31
|
+
"build:dev": "BUILD_MODE=dev npm run build && npm run verify:e2e-toolcall && npm run verify:apply-patch && npm run test:routing-instructions && npm run install:global && npm run mock:regressions && npm run verify:errorsamples",
|
|
32
32
|
"build:min": "npm run llmswitch:ensure && node scripts/build-core.mjs && node scripts/vendor-core.mjs && npm run clean && node scripts/gen-build-info.mjs && tsc && node scripts/copy-compat-assets.mjs && node scripts/copy-modules-config.mjs",
|
|
33
33
|
"prepack": "echo skip-prepack",
|
|
34
34
|
"postbuild": "chmod +x dist/cli.js || true",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"prepare": "",
|
|
55
55
|
"postinstall": "chmod +x dist/cli.js || true",
|
|
56
56
|
"verify:apply-patch": "node scripts/verify-apply-patch.mjs",
|
|
57
|
+
"verify:errorsamples": "node scripts/verify-codex-error-samples.mjs",
|
|
57
58
|
"install:global": "./scripts/install-global.sh",
|
|
58
59
|
"install:release": "./scripts/install-release.sh",
|
|
59
60
|
"audit:tool-text": "node scripts/audit-tool-text.mjs",
|
|
@@ -116,17 +117,19 @@
|
|
|
116
117
|
"test:v2:protocol": "node tests/v2/dist/protocol-conversion-test.js",
|
|
117
118
|
"test:comprehensive": "node scripts/v2-consistency/comprehensive-consistency-test.mjs",
|
|
118
119
|
"test:golden": "node scripts/tests/golden-provider-cycle.mjs",
|
|
120
|
+
"test:sharedmodule": "npm run jest:run -- tests/sharedmodule/*.spec.ts",
|
|
119
121
|
"sync:ci-goldens": "node scripts/tools/sync-ci-goldens.mjs",
|
|
120
122
|
"mock:extract": "node scripts/mock-provider/extract.mjs",
|
|
121
123
|
"mock:validate": "node scripts/mock-provider/validate.mjs",
|
|
122
124
|
"mock:regressions": "node scripts/mock-provider/run-regressions.mjs",
|
|
123
125
|
"mock:clean": "node scripts/mock-provider/clean.mjs",
|
|
124
126
|
"publish:rcc": "node scripts/publish-rcc.mjs",
|
|
125
|
-
"build:rccx": "npm run build:min && node scripts/pack-mode.mjs --name @jsonstudio/rccx --bin rccx"
|
|
127
|
+
"build:rccx": "npm run build:min && node scripts/pack-mode.mjs --name @jsonstudio/rccx --bin rccx",
|
|
128
|
+
"compare:codex:rccx": "node scripts/compare-codex-rccx.mjs"
|
|
126
129
|
},
|
|
127
130
|
"dependencies": {
|
|
128
131
|
"@anthropic-ai/sdk": "^0.65.0",
|
|
129
|
-
"@jsonstudio/llms": "^0.6.
|
|
132
|
+
"@jsonstudio/llms": "^0.6.568",
|
|
130
133
|
"@jsonstudio/rcc": "^0.89.555",
|
|
131
134
|
"@lmstudio/sdk": "^1.5.0",
|
|
132
135
|
"@radix-ui/react-switch": "^1.2.6",
|
|
@@ -145,6 +148,7 @@
|
|
|
145
148
|
"open": "^9.1.0",
|
|
146
149
|
"openai": "^5.23.0",
|
|
147
150
|
"ora": "^9.0.0",
|
|
151
|
+
"playwright-core": "^1.49.0",
|
|
148
152
|
"rcc-basemodule": "^0.2.7",
|
|
149
153
|
"rcc-debugcenter": "^0.1.6",
|
|
150
154
|
"rcc-errorhandling": "^1.0.10",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Analyze failures in ~/.routecodex/codex-samples to understand
|
|
5
|
+
* which error patterns出现频率最高,以及哪些适合作为“可修复”样本。
|
|
6
|
+
*
|
|
7
|
+
* 当前只做静态统计,不修改任何样本:
|
|
8
|
+
* - 扫描 openai-responses 下所有 *.json;
|
|
9
|
+
* - 抓取以下错误字符串:
|
|
10
|
+
* - "apply_patch verification failed"
|
|
11
|
+
* - "failed to parse exec_command arguments"
|
|
12
|
+
* - "Instructions are not valid"
|
|
13
|
+
* - 输出每种模式的命中次数和示例文件列表。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import fs from 'node:fs/promises';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import os from 'node:os';
|
|
19
|
+
|
|
20
|
+
const HOME = os.homedir();
|
|
21
|
+
const RESPONSES_DIR = path.join(HOME, '.routecodex', 'codex-samples', 'openai-responses');
|
|
22
|
+
|
|
23
|
+
const PATTERNS = [
|
|
24
|
+
'apply_patch verification failed',
|
|
25
|
+
'failed to parse exec_command arguments',
|
|
26
|
+
'Instructions are not valid'
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
async function fileExists(p) {
|
|
30
|
+
try {
|
|
31
|
+
await fs.access(p);
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function listJsonFiles(root) {
|
|
39
|
+
const entries = await fs.readdir(root);
|
|
40
|
+
return entries
|
|
41
|
+
.filter((name) => name.toLowerCase().endsWith('.json'))
|
|
42
|
+
.map((name) => path.join(root, name));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function analyzeFile(filePath) {
|
|
46
|
+
const text = await fs.readFile(filePath, 'utf-8');
|
|
47
|
+
const hits = [];
|
|
48
|
+
for (const key of PATTERNS) {
|
|
49
|
+
if (text.includes(key)) {
|
|
50
|
+
hits.push(key);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { filePath, hits };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function main() {
|
|
57
|
+
if (!(await fileExists(RESPONSES_DIR))) {
|
|
58
|
+
console.error('[analyze-codex-error-failures] no codex-samples at', RESPONSES_DIR);
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const files = await listJsonFiles(RESPONSES_DIR);
|
|
63
|
+
if (!files.length) {
|
|
64
|
+
console.log('[analyze-codex-error-failures] no JSON files under', RESPONSES_DIR);
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log(`[analyze-codex-error-failures] scanning ${files.length} file(s) under ${RESPONSES_DIR}`);
|
|
69
|
+
|
|
70
|
+
const summary = new Map();
|
|
71
|
+
for (const p of PATTERNS) {
|
|
72
|
+
summary.set(p, { count: 0, files: [] });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
let res;
|
|
77
|
+
try {
|
|
78
|
+
res = await analyzeFile(file);
|
|
79
|
+
} catch {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (!res.hits.length) continue;
|
|
83
|
+
for (const key of res.hits) {
|
|
84
|
+
const entry = summary.get(key);
|
|
85
|
+
if (!entry) continue;
|
|
86
|
+
entry.count += 1;
|
|
87
|
+
if (entry.files.length < 10) {
|
|
88
|
+
entry.files.push(path.basename(file));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const key of PATTERNS) {
|
|
94
|
+
const { count, files } = summary.get(key);
|
|
95
|
+
console.log(`\n=== Pattern: "${key}" ===`);
|
|
96
|
+
console.log(`count: ${count}`);
|
|
97
|
+
if (files.length) {
|
|
98
|
+
console.log('examples:');
|
|
99
|
+
for (const f of files) {
|
|
100
|
+
console.log(` - ${f}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main().catch((error) => {
|
|
107
|
+
console.error('[analyze-codex-error-failures] failed:', error);
|
|
108
|
+
process.exit(99);
|
|
109
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Generate and persist a Camoufox fingerprint env config for a given profile.
|
|
4
|
+
|
|
5
|
+
This script is invoked by RouteCodex to create a stable, per-profile
|
|
6
|
+
fingerprint configuration using Camoufox's own launch_options helper.
|
|
7
|
+
|
|
8
|
+
Behavior:
|
|
9
|
+
- Uses camoufox.utils.launch_options with:
|
|
10
|
+
- geoip=True (so region / timezone come from geoip)
|
|
11
|
+
- os=<policy> (windows / macos / linux / random / list)
|
|
12
|
+
- Computes the delta between the current environment and the env
|
|
13
|
+
returned in launch_options, and persists only that diff.
|
|
14
|
+
- Writes JSON to <output_dir>/<profile_id>.json of the form:
|
|
15
|
+
{ "env": { "KEY": "VALUE", ... } }
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import argparse
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
import sys
|
|
25
|
+
from typing import Dict, Any, List
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def parse_args() -> argparse.Namespace:
|
|
29
|
+
parser = argparse.ArgumentParser(description="Generate Camoufox fingerprint env for a profile.")
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
"--profile-id",
|
|
32
|
+
required=True,
|
|
33
|
+
help="Logical profile identifier (e.g. rc-gemini.geetasamodgeetasamoda).",
|
|
34
|
+
)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--os",
|
|
37
|
+
dest="os_name",
|
|
38
|
+
default=None,
|
|
39
|
+
help="Camoufox OS policy: windows | macos | linux | random | comma list.",
|
|
40
|
+
)
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"--output-dir",
|
|
43
|
+
required=True,
|
|
44
|
+
help="Directory to store the generated fingerprint JSON file.",
|
|
45
|
+
)
|
|
46
|
+
return parser.parse_args()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def ensure_output_dir(path_str: str) -> Path:
|
|
50
|
+
path = Path(os.path.expanduser(path_str)).resolve()
|
|
51
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
52
|
+
return path
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _force_us_region(env: Dict[str, str]) -> None:
|
|
56
|
+
"""
|
|
57
|
+
Override timezone / locale / geo fields in CAMOU_CONFIG_* to point to a US
|
|
58
|
+
region while keeping all other fingerprint details (canvas, fonts, UA shape, etc.)
|
|
59
|
+
intact.
|
|
60
|
+
"""
|
|
61
|
+
parts: List[str] = []
|
|
62
|
+
for key in sorted(env.keys()):
|
|
63
|
+
if key.startswith("CAMOU_CONFIG_"):
|
|
64
|
+
value = env.get(key)
|
|
65
|
+
if isinstance(value, str):
|
|
66
|
+
parts.append(value)
|
|
67
|
+
|
|
68
|
+
if not parts:
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
blob = "".join(parts)
|
|
72
|
+
try:
|
|
73
|
+
cfg = json.loads(blob)
|
|
74
|
+
except Exception:
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
# Force US timezone / locale / geo (single region for all accounts)
|
|
78
|
+
cfg["timezone"] = "America/Los_Angeles"
|
|
79
|
+
cfg["locale:language"] = cfg.get("locale:language", "en")
|
|
80
|
+
cfg["locale:region"] = "US"
|
|
81
|
+
cfg.setdefault("locale:script", "Latn")
|
|
82
|
+
cfg["geolocation:latitude"] = 37.7749
|
|
83
|
+
cfg["geolocation:longitude"] = -122.4194
|
|
84
|
+
|
|
85
|
+
payload = json.dumps(cfg, ensure_ascii=False, separators=(",", ":"))
|
|
86
|
+
|
|
87
|
+
# Replace any existing CAMOU_CONFIG_* entries with a single updated chunk.
|
|
88
|
+
for key in list(env.keys()):
|
|
89
|
+
if key.startswith("CAMOU_CONFIG_"):
|
|
90
|
+
env.pop(key, None)
|
|
91
|
+
env["CAMOU_CONFIG_1"] = payload
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def generate_env_delta(os_name: str | None) -> Dict[str, str]:
|
|
95
|
+
"""
|
|
96
|
+
Call camoufox.utils.launch_options and compute the delta env vars.
|
|
97
|
+
|
|
98
|
+
We only keep keys whose values differ from the original os.environ,
|
|
99
|
+
so that RouteCodex can safely merge them into its own process.env.
|
|
100
|
+
"""
|
|
101
|
+
try:
|
|
102
|
+
from camoufox.utils import launch_options # type: ignore
|
|
103
|
+
except Exception as exc:
|
|
104
|
+
print(f"[gen-fingerprint-env] Failed to import camoufox.utils.launch_options: {exc}", file=sys.stderr)
|
|
105
|
+
sys.exit(1)
|
|
106
|
+
|
|
107
|
+
# Snapshot original environment
|
|
108
|
+
original_env = dict(os.environ)
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
opts: Dict[str, Any] = launch_options(
|
|
112
|
+
os=os_name,
|
|
113
|
+
geoip=True,
|
|
114
|
+
headless=False,
|
|
115
|
+
window=(1440, 900),
|
|
116
|
+
)
|
|
117
|
+
except Exception as exc:
|
|
118
|
+
print(f"[gen-fingerprint-env] launch_options() failed: {exc}", file=sys.stderr)
|
|
119
|
+
sys.exit(1)
|
|
120
|
+
|
|
121
|
+
env = opts.get("env") or {}
|
|
122
|
+
if not isinstance(env, dict):
|
|
123
|
+
print("[gen-fingerprint-env] launch_options() returned invalid env payload", file=sys.stderr)
|
|
124
|
+
sys.exit(1)
|
|
125
|
+
|
|
126
|
+
# Normalize region/timezone/geo to a fixed US profile so that all accounts
|
|
127
|
+
# share the same region while still having distinct device fingerprints.
|
|
128
|
+
try:
|
|
129
|
+
_force_us_region(env)
|
|
130
|
+
except Exception as exc:
|
|
131
|
+
print(f"[gen-fingerprint-env] failed to force US region: {exc}", file=sys.stderr)
|
|
132
|
+
|
|
133
|
+
delta: Dict[str, str] = {}
|
|
134
|
+
for key, value in env.items():
|
|
135
|
+
try:
|
|
136
|
+
value_str = str(value)
|
|
137
|
+
except Exception:
|
|
138
|
+
continue
|
|
139
|
+
if original_env.get(key) != value_str:
|
|
140
|
+
delta[key] = value_str
|
|
141
|
+
return delta
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def write_fingerprint_file(profile_id: str, output_dir: Path, env_delta: Dict[str, str]) -> Path:
|
|
145
|
+
output_path = output_dir / f"{profile_id}.json"
|
|
146
|
+
tmp_path = output_path.with_suffix(output_path.suffix + ".tmp")
|
|
147
|
+
payload = {"env": env_delta}
|
|
148
|
+
|
|
149
|
+
with tmp_path.open("w", encoding="utf-8") as f:
|
|
150
|
+
json.dump(payload, f, ensure_ascii=False, separators=(",", ":"))
|
|
151
|
+
|
|
152
|
+
tmp_path.replace(output_path)
|
|
153
|
+
return output_path
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def main() -> None:
|
|
157
|
+
args = parse_args()
|
|
158
|
+
profile_id: str = args.profile_id.strip()
|
|
159
|
+
if not profile_id:
|
|
160
|
+
print("[gen-fingerprint-env] Missing profile id", file=sys.stderr)
|
|
161
|
+
sys.exit(1)
|
|
162
|
+
|
|
163
|
+
output_dir = ensure_output_dir(args.output_dir)
|
|
164
|
+
env_delta = generate_env_delta(args.os_name)
|
|
165
|
+
path = write_fingerprint_file(profile_id, output_dir, env_delta)
|
|
166
|
+
# Print the absolute path for callers that care.
|
|
167
|
+
print(str(path))
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|