@kaitranntt/ccs 5.12.0 → 5.12.1-dev.1
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/VERSION +1 -1
- package/dist/cliproxy/auth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth-handler.js +42 -7
- package/dist/cliproxy/auth-handler.js.map +1 -1
- package/dist/management/doctor.d.ts +10 -0
- package/dist/management/doctor.d.ts.map +1 -1
- package/dist/management/doctor.js +104 -4
- package/dist/management/doctor.js.map +1 -1
- package/dist/management/environment-diagnostics.d.ts +69 -0
- package/dist/management/environment-diagnostics.d.ts.map +1 -0
- package/dist/management/environment-diagnostics.js +229 -0
- package/dist/management/environment-diagnostics.js.map +1 -0
- package/dist/management/oauth-port-diagnostics.d.ts +85 -0
- package/dist/management/oauth-port-diagnostics.d.ts.map +1 -0
- package/dist/management/oauth-port-diagnostics.js +189 -0
- package/dist/management/oauth-port-diagnostics.js.map +1 -0
- package/dist/ui/assets/accounts-B9xp2MbI.js +1 -0
- package/dist/ui/assets/analytics-BfjSH3d-.js +64 -0
- package/dist/ui/assets/api-DYr0Tx6Z.js +1 -0
- package/dist/ui/assets/cliproxy-BuB-MuAt.js +1 -0
- package/dist/ui/assets/dropdown-menu-iwA6PgQW.js +1 -0
- package/dist/ui/assets/{form-utils-qlCULW73.js → form-utils-CSa50xnO.js} +1 -1
- package/dist/ui/assets/health-ChYme1jV.js +1 -0
- package/dist/ui/assets/{icons-DOhZYYMX.js → icons-ByUiVGTN.js} +1 -1
- package/dist/ui/assets/index-ChihF1Y9.css +1 -0
- package/dist/ui/assets/index-P2CKOdyd.js +10 -0
- package/dist/ui/assets/{radix-ui-CBdrr74O.js → radix-ui-DAH8Vq_G.js} +2 -2
- package/dist/ui/assets/{react-vendor-B3ahKmcC.js → react-vendor-CjrBBxxX.js} +1 -1
- package/dist/ui/assets/settings-B2OdR7RO.js +1 -0
- package/dist/ui/assets/shared-ZSfv4HA6.js +1 -0
- package/dist/ui/assets/table-OTpVLgy9.js +1 -0
- package/dist/ui/assets/{tanstack-D9KW3ciX.js → tanstack-DAI1tKxf.js} +2 -2
- package/dist/ui/index.html +7 -7
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +2 -6
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/usage-disk-cache.d.ts +46 -0
- package/dist/web-server/usage-disk-cache.d.ts.map +1 -0
- package/dist/web-server/usage-disk-cache.js +158 -0
- package/dist/web-server/usage-disk-cache.js.map +1 -0
- package/dist/web-server/usage-routes.d.ts +11 -3
- package/dist/web-server/usage-routes.d.ts.map +1 -1
- package/dist/web-server/usage-routes.js +119 -8
- package/dist/web-server/usage-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-C5_mBoh5.js +0 -72
- package/dist/ui/assets/index-FXq1wR_S.css +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Environment Diagnostics Module
|
|
4
|
+
*
|
|
5
|
+
* Provides detailed environment detection diagnostics for troubleshooting
|
|
6
|
+
* OAuth authentication issues, particularly for Windows users experiencing
|
|
7
|
+
* false headless detection.
|
|
8
|
+
*
|
|
9
|
+
* Case study: Vietnamese Windows users reported "command hangs" because
|
|
10
|
+
* Windows terminal wrappers don't set isTTY correctly, triggering
|
|
11
|
+
* headless mode when browser should be available.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.formatEnvironmentDiagnostics = exports.shouldUseHeadlessAuth = exports.getEnvironmentDiagnostics = void 0;
|
|
15
|
+
/**
|
|
16
|
+
* Detect current shell from environment
|
|
17
|
+
*/
|
|
18
|
+
function detectShell() {
|
|
19
|
+
if (process.env.SHELL) {
|
|
20
|
+
return process.env.SHELL;
|
|
21
|
+
}
|
|
22
|
+
if (process.platform === 'win32') {
|
|
23
|
+
if (process.env.PSModulePath) {
|
|
24
|
+
return 'PowerShell';
|
|
25
|
+
}
|
|
26
|
+
if (process.env.COMSPEC) {
|
|
27
|
+
return process.env.COMSPEC;
|
|
28
|
+
}
|
|
29
|
+
return 'cmd.exe';
|
|
30
|
+
}
|
|
31
|
+
return 'unknown';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if running in SSH session
|
|
35
|
+
*/
|
|
36
|
+
function checkSshSession() {
|
|
37
|
+
if (process.env.SSH_TTY) {
|
|
38
|
+
return { isSsh: true, reason: 'SSH_TTY set' };
|
|
39
|
+
}
|
|
40
|
+
if (process.env.SSH_CLIENT) {
|
|
41
|
+
return { isSsh: true, reason: 'SSH_CLIENT set' };
|
|
42
|
+
}
|
|
43
|
+
if (process.env.SSH_CONNECTION) {
|
|
44
|
+
return { isSsh: true, reason: 'SSH_CONNECTION set' };
|
|
45
|
+
}
|
|
46
|
+
return { isSsh: false, reason: null };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check browser capability based on environment
|
|
50
|
+
*/
|
|
51
|
+
function assessBrowserCapability(platform, sshSession, display, windowsTerminal, vsCodeTerminal) {
|
|
52
|
+
// SSH session - no browser
|
|
53
|
+
if (sshSession) {
|
|
54
|
+
return { capability: 'unlikely', reason: 'SSH session detected' };
|
|
55
|
+
}
|
|
56
|
+
// Windows desktop - should always have browser
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
if (windowsTerminal || vsCodeTerminal) {
|
|
59
|
+
return { capability: 'available', reason: 'Windows desktop terminal' };
|
|
60
|
+
}
|
|
61
|
+
// Even plain cmd.exe on Windows desktop should have browser access
|
|
62
|
+
return { capability: 'available', reason: 'Windows desktop environment' };
|
|
63
|
+
}
|
|
64
|
+
// macOS - always has browser unless SSH
|
|
65
|
+
if (platform === 'darwin') {
|
|
66
|
+
return { capability: 'available', reason: 'macOS desktop environment' };
|
|
67
|
+
}
|
|
68
|
+
// Linux - depends on DISPLAY/WAYLAND
|
|
69
|
+
if (platform === 'linux') {
|
|
70
|
+
if (display) {
|
|
71
|
+
return { capability: 'available', reason: `Display available: ${display}` };
|
|
72
|
+
}
|
|
73
|
+
return { capability: 'unlikely', reason: 'No DISPLAY or WAYLAND_DISPLAY' };
|
|
74
|
+
}
|
|
75
|
+
return { capability: 'unknown', reason: 'Unknown platform' };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Determine if environment is headless (improved detection)
|
|
79
|
+
* Returns both result and reasons for transparency
|
|
80
|
+
*/
|
|
81
|
+
function detectHeadless() {
|
|
82
|
+
const reasons = [];
|
|
83
|
+
// SSH session
|
|
84
|
+
if (process.env.SSH_TTY || process.env.SSH_CLIENT || process.env.SSH_CONNECTION) {
|
|
85
|
+
reasons.push('SSH session detected');
|
|
86
|
+
return { isHeadless: true, reasons };
|
|
87
|
+
}
|
|
88
|
+
// Linux without display
|
|
89
|
+
if (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) {
|
|
90
|
+
reasons.push('Linux without DISPLAY/WAYLAND_DISPLAY');
|
|
91
|
+
return { isHeadless: true, reasons };
|
|
92
|
+
}
|
|
93
|
+
// Windows desktop - NEVER headless unless SSH (already checked above)
|
|
94
|
+
// This fixes false positive on Windows where isTTY is undefined
|
|
95
|
+
if (process.platform === 'win32') {
|
|
96
|
+
reasons.push('Windows desktop - browser available');
|
|
97
|
+
return { isHeadless: false, reasons };
|
|
98
|
+
}
|
|
99
|
+
// macOS - check for proper terminal
|
|
100
|
+
if (process.platform === 'darwin') {
|
|
101
|
+
if (!process.stdin.isTTY) {
|
|
102
|
+
reasons.push('Non-interactive stdin on macOS');
|
|
103
|
+
return { isHeadless: true, reasons };
|
|
104
|
+
}
|
|
105
|
+
reasons.push('macOS with TTY - browser available');
|
|
106
|
+
return { isHeadless: false, reasons };
|
|
107
|
+
}
|
|
108
|
+
// Linux with display - check TTY
|
|
109
|
+
if (process.platform === 'linux') {
|
|
110
|
+
if (!process.stdin.isTTY) {
|
|
111
|
+
reasons.push('Non-interactive stdin on Linux');
|
|
112
|
+
return { isHeadless: true, reasons };
|
|
113
|
+
}
|
|
114
|
+
reasons.push('Linux with display and TTY');
|
|
115
|
+
return { isHeadless: false, reasons };
|
|
116
|
+
}
|
|
117
|
+
// Default fallback
|
|
118
|
+
reasons.push('Default: assuming headless');
|
|
119
|
+
return { isHeadless: true, reasons };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get comprehensive environment diagnostics
|
|
123
|
+
*/
|
|
124
|
+
function getEnvironmentDiagnostics() {
|
|
125
|
+
const platform = process.platform;
|
|
126
|
+
const ssh = checkSshSession();
|
|
127
|
+
const display = process.platform === 'linux'
|
|
128
|
+
? process.env.DISPLAY || process.env.WAYLAND_DISPLAY || null
|
|
129
|
+
: null;
|
|
130
|
+
const windowsTerminal = !!process.env.WT_SESSION;
|
|
131
|
+
const vsCodeTerminal = !!(process.env.VSCODE_GIT_IPC_HANDLE ||
|
|
132
|
+
process.env.VSCODE_IPC_HOOK_CLI ||
|
|
133
|
+
process.env.TERM_PROGRAM === 'vscode');
|
|
134
|
+
const ciEnvironment = !!(process.env.CI ||
|
|
135
|
+
process.env.GITHUB_ACTIONS ||
|
|
136
|
+
process.env.GITLAB_CI ||
|
|
137
|
+
process.env.JENKINS_URL);
|
|
138
|
+
const browser = assessBrowserCapability(platform, ssh.isSsh, display, windowsTerminal, vsCodeTerminal);
|
|
139
|
+
const headless = detectHeadless();
|
|
140
|
+
// Platform display name
|
|
141
|
+
const platformNames = {
|
|
142
|
+
win32: 'Windows',
|
|
143
|
+
darwin: 'macOS',
|
|
144
|
+
linux: 'Linux',
|
|
145
|
+
freebsd: 'FreeBSD',
|
|
146
|
+
openbsd: 'OpenBSD',
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
platform,
|
|
150
|
+
platformName: platformNames[platform] || platform,
|
|
151
|
+
shell: detectShell(),
|
|
152
|
+
termProgram: process.env.TERM_PROGRAM || null,
|
|
153
|
+
sshSession: ssh.isSsh,
|
|
154
|
+
sshReason: ssh.reason,
|
|
155
|
+
ttyStatus: process.stdin.isTTY === undefined ? 'undefined' : process.stdin.isTTY,
|
|
156
|
+
stdoutTty: process.stdout.isTTY === undefined ? 'undefined' : process.stdout.isTTY,
|
|
157
|
+
display,
|
|
158
|
+
windowsTerminal,
|
|
159
|
+
vsCodeTerminal,
|
|
160
|
+
ciEnvironment,
|
|
161
|
+
detectedHeadless: headless.isHeadless,
|
|
162
|
+
headlessReasons: headless.reasons,
|
|
163
|
+
browserCapability: browser.capability,
|
|
164
|
+
browserReason: browser.reason,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
exports.getEnvironmentDiagnostics = getEnvironmentDiagnostics;
|
|
168
|
+
/**
|
|
169
|
+
* Check if environment should use headless OAuth flow
|
|
170
|
+
* Uses improved detection that avoids Windows false positives
|
|
171
|
+
*/
|
|
172
|
+
function shouldUseHeadlessAuth() {
|
|
173
|
+
return detectHeadless().isHeadless;
|
|
174
|
+
}
|
|
175
|
+
exports.shouldUseHeadlessAuth = shouldUseHeadlessAuth;
|
|
176
|
+
/**
|
|
177
|
+
* Format diagnostics for display
|
|
178
|
+
*/
|
|
179
|
+
function formatEnvironmentDiagnostics(diag) {
|
|
180
|
+
const lines = [];
|
|
181
|
+
// Platform
|
|
182
|
+
lines.push(`Platform ${diag.platformName} (${diag.platform})`);
|
|
183
|
+
// Shell
|
|
184
|
+
lines.push(`Shell ${diag.shell}`);
|
|
185
|
+
// Terminal
|
|
186
|
+
if (diag.termProgram) {
|
|
187
|
+
lines.push(`Terminal Program ${diag.termProgram}`);
|
|
188
|
+
}
|
|
189
|
+
if (diag.windowsTerminal) {
|
|
190
|
+
lines.push(`Windows Terminal Yes`);
|
|
191
|
+
}
|
|
192
|
+
if (diag.vsCodeTerminal) {
|
|
193
|
+
lines.push(`VS Code Terminal Yes`);
|
|
194
|
+
}
|
|
195
|
+
// SSH
|
|
196
|
+
lines.push(`SSH Session ${diag.sshSession ? `Yes (${diag.sshReason})` : 'No'}`);
|
|
197
|
+
// TTY
|
|
198
|
+
const ttyDisplay = diag.ttyStatus === 'undefined' ? 'undefined [!]' : diag.ttyStatus ? 'Yes' : 'No';
|
|
199
|
+
lines.push(`stdin TTY ${ttyDisplay}`);
|
|
200
|
+
// Display (Linux)
|
|
201
|
+
if (diag.platform === 'linux') {
|
|
202
|
+
lines.push(`Display ${diag.display || 'Not set'}`);
|
|
203
|
+
}
|
|
204
|
+
// CI
|
|
205
|
+
if (diag.ciEnvironment) {
|
|
206
|
+
lines.push(`CI Environment Yes`);
|
|
207
|
+
}
|
|
208
|
+
// Browser capability
|
|
209
|
+
const browserIcon = diag.browserCapability === 'available'
|
|
210
|
+
? '[OK]'
|
|
211
|
+
: diag.browserCapability === 'unlikely'
|
|
212
|
+
? '[!]'
|
|
213
|
+
: '[?]';
|
|
214
|
+
lines.push(`Browser Capability ${browserIcon} ${diag.browserReason}`);
|
|
215
|
+
// Headless detection result
|
|
216
|
+
const headlessIcon = diag.detectedHeadless ? '[!]' : '[OK]';
|
|
217
|
+
lines.push(`Headless Mode ${headlessIcon} ${diag.detectedHeadless ? 'Yes' : 'No'}`);
|
|
218
|
+
for (const reason of diag.headlessReasons) {
|
|
219
|
+
lines.push(` → ${reason}`);
|
|
220
|
+
}
|
|
221
|
+
return lines;
|
|
222
|
+
}
|
|
223
|
+
exports.formatEnvironmentDiagnostics = formatEnvironmentDiagnostics;
|
|
224
|
+
exports.default = {
|
|
225
|
+
getEnvironmentDiagnostics,
|
|
226
|
+
shouldUseHeadlessAuth,
|
|
227
|
+
formatEnvironmentDiagnostics,
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=environment-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-diagnostics.js","sourceRoot":"","sources":["../../src/management/environment-diagnostics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAwCH;;GAEG;AACH,SAAS,WAAW;IAClB,IAAI,OAAO,CAA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CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9F,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAvDD,oEAuDC;AAED,kBAAe;IACb,yBAAyB;IACzB,qBAAqB;IACrB,4BAA4B;CAC7B,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Port Diagnostics Module
|
|
3
|
+
*
|
|
4
|
+
* Pre-flight checks for OAuth callback ports to detect conflicts
|
|
5
|
+
* before users attempt authentication.
|
|
6
|
+
*
|
|
7
|
+
* OAuth flows require specific localhost ports for callbacks:
|
|
8
|
+
* - Gemini: 8085
|
|
9
|
+
* - Codex: 1455
|
|
10
|
+
* - Agy: 51121
|
|
11
|
+
* - Qwen: Device Code Flow (no port needed)
|
|
12
|
+
*/
|
|
13
|
+
import { PortProcess } from '../utils/port-utils';
|
|
14
|
+
import { CLIProxyProvider } from '../cliproxy/types';
|
|
15
|
+
/**
|
|
16
|
+
* OAuth callback ports for each provider
|
|
17
|
+
* Extracted from CLIProxyAPI source
|
|
18
|
+
*/
|
|
19
|
+
export declare const OAUTH_CALLBACK_PORTS: Record<CLIProxyProvider, number | null>;
|
|
20
|
+
/**
|
|
21
|
+
* OAuth flow types
|
|
22
|
+
*/
|
|
23
|
+
export type OAuthFlowType = 'authorization_code' | 'device_code';
|
|
24
|
+
/**
|
|
25
|
+
* OAuth flow type per provider
|
|
26
|
+
*/
|
|
27
|
+
export declare const OAUTH_FLOW_TYPES: Record<CLIProxyProvider, OAuthFlowType>;
|
|
28
|
+
/**
|
|
29
|
+
* Port diagnostic result
|
|
30
|
+
*/
|
|
31
|
+
export interface OAuthPortDiagnostic {
|
|
32
|
+
/** Provider name */
|
|
33
|
+
provider: CLIProxyProvider;
|
|
34
|
+
/** OAuth flow type */
|
|
35
|
+
flowType: OAuthFlowType;
|
|
36
|
+
/** Callback port (null for device code flow) */
|
|
37
|
+
port: number | null;
|
|
38
|
+
/** Port status */
|
|
39
|
+
status: 'free' | 'occupied' | 'cliproxy' | 'not_applicable';
|
|
40
|
+
/** Process occupying the port (if any) */
|
|
41
|
+
process: PortProcess | null;
|
|
42
|
+
/** Human-readable status message */
|
|
43
|
+
message: string;
|
|
44
|
+
/** Recommendation for fixing (if issue detected) */
|
|
45
|
+
recommendation: string | null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check OAuth port availability for a single provider
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkOAuthPort(provider: CLIProxyProvider): Promise<OAuthPortDiagnostic>;
|
|
51
|
+
/**
|
|
52
|
+
* Check OAuth ports for all providers
|
|
53
|
+
*/
|
|
54
|
+
export declare function checkAllOAuthPorts(): Promise<OAuthPortDiagnostic[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Check OAuth ports for providers that use Authorization Code flow only
|
|
57
|
+
*/
|
|
58
|
+
export declare function checkAuthCodePorts(): Promise<OAuthPortDiagnostic[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Get providers with port conflicts
|
|
61
|
+
*/
|
|
62
|
+
export declare function getPortConflicts(): Promise<OAuthPortDiagnostic[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Format OAuth port diagnostics for display
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatOAuthPortDiagnostics(diagnostics: OAuthPortDiagnostic[]): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Pre-flight check before OAuth - returns issues or empty array if OK
|
|
69
|
+
*/
|
|
70
|
+
export declare function preflightOAuthCheck(provider: CLIProxyProvider): Promise<{
|
|
71
|
+
ready: boolean;
|
|
72
|
+
issues: string[];
|
|
73
|
+
}>;
|
|
74
|
+
declare const _default: {
|
|
75
|
+
OAUTH_CALLBACK_PORTS: Record<CLIProxyProvider, number | null>;
|
|
76
|
+
OAUTH_FLOW_TYPES: Record<CLIProxyProvider, OAuthFlowType>;
|
|
77
|
+
checkOAuthPort: typeof checkOAuthPort;
|
|
78
|
+
checkAllOAuthPorts: typeof checkAllOAuthPorts;
|
|
79
|
+
checkAuthCodePorts: typeof checkAuthCodePorts;
|
|
80
|
+
getPortConflicts: typeof getPortConflicts;
|
|
81
|
+
formatOAuthPortDiagnostics: typeof formatOAuthPortDiagnostics;
|
|
82
|
+
preflightOAuthCheck: typeof preflightOAuthCheck;
|
|
83
|
+
};
|
|
84
|
+
export default _default;
|
|
85
|
+
//# sourceMappingURL=oauth-port-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-port-diagnostics.d.ts","sourceRoot":"","sources":["../../src/management/oauth-port-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAkB,WAAW,EAAqB,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAMxE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,aAAa,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAMpE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,sBAAsB;IACtB,QAAQ,EAAE,aAAa,CAAC;IACxB,gDAAgD;IAChD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,kBAAkB;IAClB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC;IAC5D,0CAA0C;IAC1C,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAuD7F;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAUzE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAUzE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAGvE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAkCvF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC7E,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAiBD;;;;;;;;;;;AAED,wBASE"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OAuth Port Diagnostics Module
|
|
4
|
+
*
|
|
5
|
+
* Pre-flight checks for OAuth callback ports to detect conflicts
|
|
6
|
+
* before users attempt authentication.
|
|
7
|
+
*
|
|
8
|
+
* OAuth flows require specific localhost ports for callbacks:
|
|
9
|
+
* - Gemini: 8085
|
|
10
|
+
* - Codex: 1455
|
|
11
|
+
* - Agy: 51121
|
|
12
|
+
* - Qwen: Device Code Flow (no port needed)
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.preflightOAuthCheck = exports.formatOAuthPortDiagnostics = exports.getPortConflicts = exports.checkAuthCodePorts = exports.checkAllOAuthPorts = exports.checkOAuthPort = exports.OAUTH_FLOW_TYPES = exports.OAUTH_CALLBACK_PORTS = void 0;
|
|
16
|
+
const port_utils_1 = require("../utils/port-utils");
|
|
17
|
+
/**
|
|
18
|
+
* OAuth callback ports for each provider
|
|
19
|
+
* Extracted from CLIProxyAPI source
|
|
20
|
+
*/
|
|
21
|
+
exports.OAUTH_CALLBACK_PORTS = {
|
|
22
|
+
gemini: 8085,
|
|
23
|
+
codex: 1455,
|
|
24
|
+
agy: 51121,
|
|
25
|
+
qwen: null, // Device Code Flow - no callback port
|
|
26
|
+
iflow: null, // Device Code Flow - no callback port
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* OAuth flow type per provider
|
|
30
|
+
*/
|
|
31
|
+
exports.OAUTH_FLOW_TYPES = {
|
|
32
|
+
gemini: 'authorization_code',
|
|
33
|
+
codex: 'authorization_code',
|
|
34
|
+
agy: 'authorization_code',
|
|
35
|
+
qwen: 'device_code',
|
|
36
|
+
iflow: 'device_code',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Check OAuth port availability for a single provider
|
|
40
|
+
*/
|
|
41
|
+
async function checkOAuthPort(provider) {
|
|
42
|
+
const port = exports.OAUTH_CALLBACK_PORTS[provider];
|
|
43
|
+
const flowType = exports.OAUTH_FLOW_TYPES[provider];
|
|
44
|
+
// Device code flow doesn't need callback port
|
|
45
|
+
if (port === null) {
|
|
46
|
+
return {
|
|
47
|
+
provider,
|
|
48
|
+
flowType,
|
|
49
|
+
port: null,
|
|
50
|
+
status: 'not_applicable',
|
|
51
|
+
process: null,
|
|
52
|
+
message: 'Uses Device Code Flow (no callback port needed)',
|
|
53
|
+
recommendation: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Check if port is in use
|
|
57
|
+
const portProcess = await (0, port_utils_1.getPortProcess)(port);
|
|
58
|
+
if (!portProcess) {
|
|
59
|
+
return {
|
|
60
|
+
provider,
|
|
61
|
+
flowType,
|
|
62
|
+
port,
|
|
63
|
+
status: 'free',
|
|
64
|
+
process: null,
|
|
65
|
+
message: `Port ${port} is available`,
|
|
66
|
+
recommendation: null,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Check if it's CLIProxy (expected if proxy is running)
|
|
70
|
+
if ((0, port_utils_1.isCLIProxyProcess)(portProcess)) {
|
|
71
|
+
return {
|
|
72
|
+
provider,
|
|
73
|
+
flowType,
|
|
74
|
+
port,
|
|
75
|
+
status: 'cliproxy',
|
|
76
|
+
process: portProcess,
|
|
77
|
+
message: `Port ${port} in use by CLIProxy (expected)`,
|
|
78
|
+
recommendation: null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Port is occupied by another process
|
|
82
|
+
return {
|
|
83
|
+
provider,
|
|
84
|
+
flowType,
|
|
85
|
+
port,
|
|
86
|
+
status: 'occupied',
|
|
87
|
+
process: portProcess,
|
|
88
|
+
message: `Port ${port} occupied by ${portProcess.processName}`,
|
|
89
|
+
recommendation: `Kill process: kill ${portProcess.pid} (or close ${portProcess.processName})`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.checkOAuthPort = checkOAuthPort;
|
|
93
|
+
/**
|
|
94
|
+
* Check OAuth ports for all providers
|
|
95
|
+
*/
|
|
96
|
+
async function checkAllOAuthPorts() {
|
|
97
|
+
const providers = ['gemini', 'codex', 'agy', 'qwen', 'iflow'];
|
|
98
|
+
const results = [];
|
|
99
|
+
for (const provider of providers) {
|
|
100
|
+
const diagnostic = await checkOAuthPort(provider);
|
|
101
|
+
results.push(diagnostic);
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
exports.checkAllOAuthPorts = checkAllOAuthPorts;
|
|
106
|
+
/**
|
|
107
|
+
* Check OAuth ports for providers that use Authorization Code flow only
|
|
108
|
+
*/
|
|
109
|
+
async function checkAuthCodePorts() {
|
|
110
|
+
const providers = ['gemini', 'codex', 'agy'];
|
|
111
|
+
const results = [];
|
|
112
|
+
for (const provider of providers) {
|
|
113
|
+
const diagnostic = await checkOAuthPort(provider);
|
|
114
|
+
results.push(diagnostic);
|
|
115
|
+
}
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
118
|
+
exports.checkAuthCodePorts = checkAuthCodePorts;
|
|
119
|
+
/**
|
|
120
|
+
* Get providers with port conflicts
|
|
121
|
+
*/
|
|
122
|
+
async function getPortConflicts() {
|
|
123
|
+
const allPorts = await checkAllOAuthPorts();
|
|
124
|
+
return allPorts.filter((d) => d.status === 'occupied');
|
|
125
|
+
}
|
|
126
|
+
exports.getPortConflicts = getPortConflicts;
|
|
127
|
+
/**
|
|
128
|
+
* Format OAuth port diagnostics for display
|
|
129
|
+
*/
|
|
130
|
+
function formatOAuthPortDiagnostics(diagnostics) {
|
|
131
|
+
const lines = [];
|
|
132
|
+
for (const diag of diagnostics) {
|
|
133
|
+
const providerName = diag.provider.charAt(0).toUpperCase() + diag.provider.slice(1);
|
|
134
|
+
const portStr = diag.port !== null ? `(${diag.port})` : '';
|
|
135
|
+
let statusIcon;
|
|
136
|
+
switch (diag.status) {
|
|
137
|
+
case 'free':
|
|
138
|
+
statusIcon = '[OK]';
|
|
139
|
+
break;
|
|
140
|
+
case 'cliproxy':
|
|
141
|
+
statusIcon = '[OK]';
|
|
142
|
+
break;
|
|
143
|
+
case 'occupied':
|
|
144
|
+
statusIcon = '[!]';
|
|
145
|
+
break;
|
|
146
|
+
case 'not_applicable':
|
|
147
|
+
statusIcon = '[i]';
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
statusIcon = '[?]';
|
|
151
|
+
}
|
|
152
|
+
const label = `${providerName} ${portStr}`.padEnd(20);
|
|
153
|
+
lines.push(`${statusIcon} ${label} ${diag.message}`);
|
|
154
|
+
if (diag.recommendation) {
|
|
155
|
+
lines.push(` → ${diag.recommendation}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return lines;
|
|
159
|
+
}
|
|
160
|
+
exports.formatOAuthPortDiagnostics = formatOAuthPortDiagnostics;
|
|
161
|
+
/**
|
|
162
|
+
* Pre-flight check before OAuth - returns issues or empty array if OK
|
|
163
|
+
*/
|
|
164
|
+
async function preflightOAuthCheck(provider) {
|
|
165
|
+
const diagnostic = await checkOAuthPort(provider);
|
|
166
|
+
const issues = [];
|
|
167
|
+
if (diagnostic.status === 'occupied' && diagnostic.process) {
|
|
168
|
+
issues.push(`OAuth callback port ${diagnostic.port} is blocked by ${diagnostic.process.processName} (PID ${diagnostic.process.pid})`);
|
|
169
|
+
if (diagnostic.recommendation) {
|
|
170
|
+
issues.push(`Fix: ${diagnostic.recommendation}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
ready: issues.length === 0,
|
|
175
|
+
issues,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
exports.preflightOAuthCheck = preflightOAuthCheck;
|
|
179
|
+
exports.default = {
|
|
180
|
+
OAUTH_CALLBACK_PORTS: exports.OAUTH_CALLBACK_PORTS,
|
|
181
|
+
OAUTH_FLOW_TYPES: exports.OAUTH_FLOW_TYPES,
|
|
182
|
+
checkOAuthPort,
|
|
183
|
+
checkAllOAuthPorts,
|
|
184
|
+
checkAuthCodePorts,
|
|
185
|
+
getPortConflicts,
|
|
186
|
+
formatOAuthPortDiagnostics,
|
|
187
|
+
preflightOAuthCheck,
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=oauth-port-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-port-diagnostics.js","sourceRoot":"","sources":["../../src/management/oauth-port-diagnostics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,oDAAqF;AAGrF;;;GAGG;AACU,QAAA,oBAAoB,GAA4C;IAC3E,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,IAAI,EAAE,sCAAsC;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,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,UAAU,CAAC,MAAM,KAAK,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,MAAM,CAAC,IAAI,CACT,uBAAuB,UAAU,CAAC,IAAI,kBAAkB,UAAU,CAAC,OAAO,CAAC,WAAW,SAAS,UAAU,CAAC,OAAO,CAAC,GAAG,GAAG,CACzH,CAAC;QACF,IAAI,UAAU,CAAC,cAAc,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,QAAQ,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC;AApBD,kDAoBC;AAED,kBAAe;IACb,oBAAoB,EAApB,4BAAoB;IACpB,gBAAgB,EAAhB,wBAAgB;IAChB,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,0BAA0B;IAC1B,mBAAmB;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-DAH8Vq_G.js";import{a as m,u as x,b as p,d as f,f as o,g as h}from"./tanstack-DAI1tKxf.js";import{T as g,a as j,b as l,c as y,d as b,e as N}from"./table-OTpVLgy9.js";import{z as d,t as i,B as w}from"./index-P2CKOdyd.js";import{h as C}from"./icons-ByUiVGTN.js";import"./react-vendor-CjrBBxxX.js";import"./form-utils-CSa50xnO.js";function v(){return m({queryKey:["accounts"],queryFn:()=>d.accounts.list()})}function D(){const n=x();return p({mutationFn:a=>d.accounts.setDefault(a),onSuccess:(a,c)=>{n.invalidateQueries({queryKey:["accounts"]}),i.success(`Default account set to "${c}"`)},onError:a=>{i.error(a.message)}})}function T({data:n,defaultAccount:a}){const c=D(),r=f({data:n,columns:[{accessorKey:"name",header:"Name",size:200,cell:({row:s})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:s.original.name}),s.original.name===a&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:"default"})]})},{accessorKey:"type",header:"Type",size:100,cell:({row:s})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:s.original.type||"oauth"})},{accessorKey:"created",header:"Created",size:150,cell:({row:s})=>{const t=new Date(s.original.created);return e.jsx("span",{className:"text-muted-foreground",children:t.toLocaleDateString()})}},{accessorKey:"last_used",header:"Last Used",size:150,cell:({row:s})=>{if(!s.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const t=new Date(s.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:t.toLocaleDateString()})}},{id:"actions",header:"Actions",size:100,cell:({row:s})=>{const t=s.original.name===a;return e.jsxs(w,{variant:t?"secondary":"default",size:"sm",className:"h-8 px-2 w-full",disabled:t||c.isPending,onClick:()=>c.mutate(s.original.name),children:[e.jsx(C,{className:`w-3 h-3 mr-1.5 ${t?"opacity-50":""}`}),t?"Active":"Set Default"]})}}],getCoreRowModel:h()});return n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:["No accounts found. Use ",e.jsx("code",{className:"text-sm bg-muted px-1 rounded",children:"ccs login"})," to add accounts."]}):e.jsx("div",{className:"border rounded-md",children:e.jsxs(g,{children:[e.jsx(j,{children:r.getHeaderGroups().map(s=>e.jsx(l,{children:s.headers.map(t=>{const u={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",actions:"w-[100px]"}[t.id]||"w-auto";return e.jsx(y,{className:u,children:t.isPlaceholder?null:o(t.column.columnDef.header,t.getContext())},t.id)})},s.id))}),e.jsx(b,{children:r.getRowModel().rows.map(s=>e.jsx(l,{children:s.getVisibleCells().map(t=>e.jsx(N,{children:o(t.column.columnDef.cell,t.getContext())},t.id))},s.id))})]})})}function q(){const{data:n,isLoading:a}=v();return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-8",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage multi-account Claude sessions (profiles.json)"})]})}),a?e.jsx("div",{className:"text-muted-foreground",children:"Loading accounts..."}):e.jsx(T,{data:n?.accounts||[],defaultAccount:n?.default??null}),e.jsx("div",{className:"text-sm text-muted-foreground border-t pt-4 mt-4",children:e.jsxs("p",{children:["Accounts are isolated Claude instances with separate sessions.",e.jsx("br",{}),"Use ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs auth create <name>"})," to add new accounts via CLI."]})})]})}export{q as AccountsPage};
|