coding-tool-x 3.8.8 → 3.8.9
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/README.md +2 -2
- package/dist/web/assets/{AgentsDrawer-DRQuwi0m.js → AgentsDrawer-Cj5CJ4d9.js} +1 -1
- package/dist/web/assets/{Analytics-Cf5KwEdj.js → Analytics-1doS-8uC.js} +1 -1
- package/dist/web/assets/{AssetPathField-DyniM0pF.js → AssetPathField-C9TOPl7o.js} +1 -1
- package/dist/web/assets/{ChatHistoryDrawer-CrfS0KYV.js → ChatHistoryDrawer-BTmQ1aQr.js} +1 -1
- package/dist/web/assets/{CollapseItem-ClMsJuUu.js → CollapseItem-CwqJk3bE.js} +1 -1
- package/dist/web/assets/{CommandsDrawer-CzHelf56.js → CommandsDrawer-CaZWDI_G.js} +1 -1
- package/dist/web/assets/{ConfigExportDrawer-BEZ8wTby.js → ConfigExportDrawer-C3vSZEsS.js} +1 -1
- package/dist/web/assets/ConfigTemplates-gyERg9iC.js +1 -0
- package/dist/web/assets/{ConfigTemplatesDrawer-BqM32Im7.js → ConfigTemplatesDrawer-B17RqFi4.js} +1 -1
- package/dist/web/assets/{ConfigTemplatesPanel-lTdutC8H.js → ConfigTemplatesPanel-DKIC_FqG.js} +1 -1
- package/dist/web/assets/{FavoritesDrawer-DDyWUBJR.js → FavoritesDrawer-DaziQmBp.js} +1 -1
- package/dist/web/assets/{GatewayConvertDrawer-Rigtt_5J.js → GatewayConvertDrawer-OMgWUUSc.js} +1 -1
- package/dist/web/assets/{Home-tCSKmSHV.js → Home-DOSUTfrE.js} +1 -1
- package/dist/web/assets/{MarkdownEditor-BMMUufSc.js → MarkdownEditor-9TTwTS-U.js} +1 -1
- package/dist/web/assets/{McpDrawer-CmE-d7VW.js → McpDrawer-I8rl8lGH.js} +1 -1
- package/dist/web/assets/{McpFormDrawer-ByvS18od.js → McpFormDrawer-DEP3C7ut.js} +1 -1
- package/dist/web/assets/{PluginManager-C4kJlpVX.js → PluginManager-BuRcWuBj.js} +1 -1
- package/dist/web/assets/{PluginsDrawer-05R4k15x.js → PluginsDrawer-_zZENaQn.js} +1 -1
- package/dist/web/assets/{PluginsPanel-BCoEs7Og.js → PluginsPanel-Bs5qZ-TK.js} +1 -1
- package/dist/web/assets/ProjectList-BSxuL2td.js +1 -0
- package/dist/web/assets/ProjectList-VbIYSHbH.css +1 -0
- package/dist/web/assets/{PromptsDrawer-DnwBf_oW.js → PromptsDrawer-CoZ-ZtsY.js} +1 -1
- package/dist/web/assets/{RecentSessionsDrawer-B7d-38wH.js → RecentSessionsDrawer-B_17aJBG.js} +1 -1
- package/dist/web/assets/{SessionCard-BUgjHQwX.js → SessionCard-BL_x0d3t.js} +1 -1
- package/dist/web/assets/SessionList-DhRYZ6vl.js +1 -0
- package/dist/web/assets/{SettingsDrawer-BITzjQLl.js → SettingsDrawer-fYb0DU7X.js} +1 -1
- package/dist/web/assets/{SkillManager-D9jkNuRM.js → SkillManager-S698Hns8.js} +1 -1
- package/dist/web/assets/{SkillsDrawer-0Z4IefxC.js → SkillsDrawer-Ms4lPCow.js} +1 -1
- package/dist/web/assets/{SkillsPanel-BKIVOj7n.js → SkillsPanel-rqnqAOGL.js} +1 -1
- package/dist/web/assets/{SpeedTestDrawer-Bx1bYf5i.js → SpeedTestDrawer-Bbn38SfV.js} +1 -1
- package/dist/web/assets/{Upload-CzC4rGI4.js → Upload-CdyVHxCI.js} +1 -1
- package/dist/web/assets/{WorkspaceDrawer-eujtWpoq.js → WorkspaceDrawer-L7HJRc6u.js} +1 -1
- package/dist/web/assets/{WorkspaceManager-CQ-8Ej68.js → WorkspaceManager-DsoNg2z8.js} +1 -1
- package/dist/web/assets/{WorkspacePanel-Cql5qE2R.js → WorkspacePanel-Be8PVZah.js} +1 -1
- package/dist/web/assets/headers-B5JWGn3v.js +1 -0
- package/dist/web/assets/{index-Cnbe696C.css → index-3Lp6z8TQ.css} +1 -1
- package/dist/web/assets/index-BKlAWTH-.js +2 -0
- package/dist/web/assets/{sessions-DqlbocLJ.js → sessions-CC0j-KH_.js} +1 -1
- package/dist/web/assets/{useResponsiveDrawer-DZd5rNk5.js → useResponsiveDrawer-V_onl9NV.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/src/commands/daemon.js +27 -4
- package/src/platforms/channel-auth-registry.js +36 -6
- package/src/platforms/channel-auth-service.js +12 -2
- package/src/platforms/drivers/omp/prompts.js +58 -2
- package/src/platforms/drivers/omp/proxy-implementation.js +25 -1
- package/src/platforms/drivers/opencode/channels-implementation.js +25 -22
- package/src/platforms/drivers/opencode/channels.js +6 -1
- package/src/platforms/manifests/omp.json +2 -1
- package/src/platforms/manifests/opencode.json +28 -0
- package/src/platforms/native-oauth-adapters.js +318 -18
- package/src/platforms/oauth-credentials-service.js +344 -13
- package/src/server/index.js +35 -1
- package/dist/web/assets/ConfigTemplates-Crg3xWe5.js +0 -1
- package/dist/web/assets/ProjectList-BJt1OIaI.js +0 -1
- package/dist/web/assets/ProjectList-DG3yu8xZ.css +0 -1
- package/dist/web/assets/SessionList-B-bXZRFk.js +0 -1
- package/dist/web/assets/headers-BqDmkMjy.js +0 -1
- package/dist/web/assets/index-Cmmwj3Fx.js +0 -2
|
@@ -6,7 +6,9 @@ const {
|
|
|
6
6
|
inspectTool,
|
|
7
7
|
SUPPORTED_TOOLS,
|
|
8
8
|
fingerprintFor,
|
|
9
|
-
readAllNativeOAuth
|
|
9
|
+
readAllNativeOAuth,
|
|
10
|
+
updateCodexOAuthTokens,
|
|
11
|
+
applyOAuthCredential
|
|
10
12
|
} = require('./native-oauth-adapters');
|
|
11
13
|
const { maskToken } = require('../server/services/oauth-utils');
|
|
12
14
|
|
|
@@ -110,6 +112,7 @@ function sanitizeCredential(entry, defaultCredentialId) {
|
|
|
110
112
|
providerId: entry.providerId || '',
|
|
111
113
|
accountId: entry.accountId || '',
|
|
112
114
|
accountEmail: entry.accountEmail || '',
|
|
115
|
+
identityKey: entry.identityKey || '',
|
|
113
116
|
expiresAt: entry.expiresAt || null,
|
|
114
117
|
lastRefresh: entry.lastRefresh || null,
|
|
115
118
|
lastUsedAt: entry.lastUsedAt || null,
|
|
@@ -209,12 +212,34 @@ function extractSecrets(tool, metadata) {
|
|
|
209
212
|
importPayload: metadata.importPayload || null,
|
|
210
213
|
primaryToken: metadata.primaryToken || metadata.accessToken || ''
|
|
211
214
|
};
|
|
215
|
+
case 'opencode':
|
|
216
|
+
return {
|
|
217
|
+
providerId: metadata.providerId || '',
|
|
218
|
+
accessToken: metadata.accessToken || '',
|
|
219
|
+
idToken: metadata.idToken || '',
|
|
220
|
+
refreshToken: metadata.refreshToken || '',
|
|
221
|
+
expiresAt: metadata.expiresAt || null,
|
|
222
|
+
accountId: metadata.accountId || '',
|
|
223
|
+
accountEmail: metadata.accountEmail || '',
|
|
224
|
+
identityKey: metadata.identityKey || '',
|
|
225
|
+
primaryToken: metadata.primaryToken || metadata.accessToken || ''
|
|
226
|
+
};
|
|
212
227
|
default:
|
|
213
228
|
return { primaryToken: metadata.primaryToken || metadata.accessToken || '' };
|
|
214
229
|
}
|
|
215
230
|
}
|
|
216
231
|
|
|
217
232
|
function stableFingerprintValue(tool, metadata) {
|
|
233
|
+
// Codex account IDs remain stable while access tokens rotate.
|
|
234
|
+
if (tool === 'codex') {
|
|
235
|
+
return metadata.accountId
|
|
236
|
+
|| metadata.accountEmail
|
|
237
|
+
|| metadata.refreshToken
|
|
238
|
+
|| metadata.primaryToken
|
|
239
|
+
|| metadata.accessToken
|
|
240
|
+
|| '';
|
|
241
|
+
}
|
|
242
|
+
|
|
218
243
|
// 优先使用稳定标识符,避免 access token 轮换导致重复记录
|
|
219
244
|
const stableId = metadata.accountEmail
|
|
220
245
|
|| metadata.accountId
|
|
@@ -227,6 +252,9 @@ function stableFingerprintValue(tool, metadata) {
|
|
|
227
252
|
}
|
|
228
253
|
|
|
229
254
|
function resolveFingerprintValue(tool, metadata, options = {}) {
|
|
255
|
+
if (tool === 'codex') {
|
|
256
|
+
return stableFingerprintValue(tool, metadata);
|
|
257
|
+
}
|
|
230
258
|
if (options.fingerprintMode === 'primary-token') {
|
|
231
259
|
return metadata.primaryToken
|
|
232
260
|
|| metadata.accessToken
|
|
@@ -235,13 +263,28 @@ function resolveFingerprintValue(tool, metadata, options = {}) {
|
|
|
235
263
|
return stableFingerprintValue(tool, metadata);
|
|
236
264
|
}
|
|
237
265
|
|
|
266
|
+
function matchesCodexIdentity(entry = {}, metadata = {}) {
|
|
267
|
+
const entryAccountId = safeString(entry.accountId || entry.secrets?.accountId);
|
|
268
|
+
const metadataAccountId = safeString(metadata.accountId);
|
|
269
|
+
if (entryAccountId && metadataAccountId) {
|
|
270
|
+
return entryAccountId === metadataAccountId;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const entryEmail = safeString(entry.accountEmail);
|
|
274
|
+
const metadataEmail = safeString(metadata.accountEmail);
|
|
275
|
+
return Boolean(entryEmail && metadataEmail && entryEmail === metadataEmail);
|
|
276
|
+
}
|
|
277
|
+
|
|
238
278
|
function upsertCredential(tool, metadata, options = {}) {
|
|
239
279
|
const store = readStore();
|
|
240
280
|
const toolStore = getToolStore(store, tool);
|
|
241
281
|
const now = Date.now();
|
|
242
282
|
const primaryToken = metadata.primaryToken || metadata.accessToken || '';
|
|
243
283
|
const fingerprint = fingerprintFor(tool, resolveFingerprintValue(tool, metadata, options));
|
|
244
|
-
|
|
284
|
+
let existingIndex = toolStore.credentials.findIndex((item) => item.fingerprint === fingerprint);
|
|
285
|
+
if (existingIndex < 0 && tool === 'codex') {
|
|
286
|
+
existingIndex = toolStore.credentials.findIndex((item) => matchesCodexIdentity(item, metadata));
|
|
287
|
+
}
|
|
245
288
|
const existing = existingIndex >= 0 ? toolStore.credentials[existingIndex] : null;
|
|
246
289
|
|
|
247
290
|
const entry = {
|
|
@@ -267,7 +310,21 @@ function upsertCredential(tool, metadata, options = {}) {
|
|
|
267
310
|
toolStore.credentials.unshift(entry);
|
|
268
311
|
}
|
|
269
312
|
|
|
270
|
-
if (
|
|
313
|
+
if (tool === 'codex') {
|
|
314
|
+
const duplicateIds = new Set();
|
|
315
|
+
for (let index = toolStore.credentials.length - 1; index >= 0; index -= 1) {
|
|
316
|
+
const candidate = toolStore.credentials[index];
|
|
317
|
+
if (candidate.id === entry.id || !matchesCodexIdentity(candidate, metadata)) continue;
|
|
318
|
+
duplicateIds.add(candidate.id);
|
|
319
|
+
toolStore.credentials.splice(index, 1);
|
|
320
|
+
}
|
|
321
|
+
if (duplicateIds.has(toolStore.defaultCredentialId)) {
|
|
322
|
+
toolStore.defaultCredentialId = entry.id;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (!toolStore.defaultCredentialId
|
|
327
|
+
|| !toolStore.credentials.some((item) => item.id === toolStore.defaultCredentialId)) {
|
|
271
328
|
toolStore.defaultCredentialId = entry.id;
|
|
272
329
|
}
|
|
273
330
|
|
|
@@ -290,10 +347,13 @@ function syncLocalCredential(tool) {
|
|
|
290
347
|
throw new Error('当前本地未检测到可同步的 OAuth 凭证。');
|
|
291
348
|
}
|
|
292
349
|
|
|
293
|
-
const credentials = nativeCredentials.map((metadata) =>
|
|
294
|
-
source: 'synced-local'
|
|
295
|
-
|
|
296
|
-
|
|
350
|
+
const credentials = nativeCredentials.map((metadata) => {
|
|
351
|
+
const options = { source: 'synced-local' };
|
|
352
|
+
if (tool !== 'codex') {
|
|
353
|
+
options.fingerprintMode = 'primary-token';
|
|
354
|
+
}
|
|
355
|
+
return upsertCredential(tool, metadata, options);
|
|
356
|
+
});
|
|
297
357
|
|
|
298
358
|
return {
|
|
299
359
|
credential: credentials[0] || null,
|
|
@@ -302,6 +362,70 @@ function syncLocalCredential(tool) {
|
|
|
302
362
|
};
|
|
303
363
|
}
|
|
304
364
|
|
|
365
|
+
function restoreStoredOmpOAuthCredentials(channels = []) {
|
|
366
|
+
const oauthChannels = (Array.isArray(channels) ? channels : [])
|
|
367
|
+
.filter(channel => channel?.enabled !== false && channel?.authMode === 'oauth');
|
|
368
|
+
if (oauthChannels.length === 0) return { restored: [], warnings: [] };
|
|
369
|
+
|
|
370
|
+
const store = readStore();
|
|
371
|
+
const toolStore = getToolStore(store, 'omp');
|
|
372
|
+
const nativeCredentials = readAllNativeOAuth('omp');
|
|
373
|
+
const restored = [];
|
|
374
|
+
const warnings = [];
|
|
375
|
+
const seenCredentialIds = new Set();
|
|
376
|
+
|
|
377
|
+
for (const channel of oauthChannels) {
|
|
378
|
+
const ref = channel.authRef || {};
|
|
379
|
+
const stored = toolStore.credentials.find((entry) => {
|
|
380
|
+
if (ref.credentialId && entry.id === ref.credentialId) return true;
|
|
381
|
+
if (ref.providerId && entry.providerId !== ref.providerId) return false;
|
|
382
|
+
if (ref.accountId && entry.accountId === ref.accountId) return true;
|
|
383
|
+
if (ref.accountEmail && entry.accountEmail === ref.accountEmail) return true;
|
|
384
|
+
return !ref.credentialId && !ref.accountId && !ref.accountEmail && !ref.providerId;
|
|
385
|
+
});
|
|
386
|
+
if (!stored || seenCredentialIds.has(stored.id)) continue;
|
|
387
|
+
seenCredentialIds.add(stored.id);
|
|
388
|
+
|
|
389
|
+
const accessToken = stored.secrets?.accessToken || stored.secrets?.primaryToken || '';
|
|
390
|
+
if (!accessToken) {
|
|
391
|
+
warnings.push(`OMP OAuth credential ${stored.id} has no access token.`);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const expiresAt = Number(stored.expiresAt || stored.secrets?.expiresAt || 0);
|
|
395
|
+
if (expiresAt > 0 && expiresAt <= Date.now()) {
|
|
396
|
+
warnings.push(`OMP OAuth credential ${stored.id} is expired and was not restored.`);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const alreadyNative = nativeCredentials.some((native) => (
|
|
401
|
+
native.providerId === stored.providerId
|
|
402
|
+
&& ((!stored.accountId && !stored.accountEmail)
|
|
403
|
+
|| (stored.accountId && native.accountId === stored.accountId)
|
|
404
|
+
|| (stored.accountEmail && native.accountEmail === stored.accountEmail))
|
|
405
|
+
));
|
|
406
|
+
if (alreadyNative) continue;
|
|
407
|
+
|
|
408
|
+
try {
|
|
409
|
+
applyOAuthCredential('omp', {
|
|
410
|
+
providerId: stored.providerId || stored.secrets?.providerId,
|
|
411
|
+
credentialType: stored.secrets?.credentialType || 'oauth',
|
|
412
|
+
accessToken,
|
|
413
|
+
refreshToken: stored.secrets?.refreshToken || '',
|
|
414
|
+
expiresAt: expiresAt || null,
|
|
415
|
+
accountId: stored.accountId || stored.secrets?.accountId || '',
|
|
416
|
+
accountEmail: stored.accountEmail || stored.secrets?.accountEmail || '',
|
|
417
|
+
identityKey: stored.identityKey || stored.secrets?.identityKey || stored.accountId || '',
|
|
418
|
+
primaryToken: accessToken
|
|
419
|
+
});
|
|
420
|
+
restored.push(stored.id);
|
|
421
|
+
} catch (error) {
|
|
422
|
+
warnings.push(`OMP OAuth credential ${stored.id} restore failed: ${error.message}`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return { restored, warnings };
|
|
427
|
+
}
|
|
428
|
+
|
|
305
429
|
|
|
306
430
|
function findStoredCredential(tool, credentialId) {
|
|
307
431
|
const store = readStore();
|
|
@@ -359,6 +483,11 @@ function httpPost(url, body, headers = {}) {
|
|
|
359
483
|
});
|
|
360
484
|
}
|
|
361
485
|
|
|
486
|
+
const CODEX_OAUTH_CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
|
|
487
|
+
const CODEX_OAUTH_TOKEN_URL = 'https://auth.openai.com/oauth/token';
|
|
488
|
+
const CODEX_REFRESH_SKEW_MS = 60 * 1000;
|
|
489
|
+
const codexRefreshPromises = new Map();
|
|
490
|
+
|
|
362
491
|
function parseJsonBody(body) {
|
|
363
492
|
try {
|
|
364
493
|
return JSON.parse(body);
|
|
@@ -400,11 +529,21 @@ function extractCodexAccountId(...tokens) {
|
|
|
400
529
|
return '';
|
|
401
530
|
}
|
|
402
531
|
|
|
532
|
+
function isCodexOAuthProvider(providerId = '') {
|
|
533
|
+
const value = String(providerId || '').trim().toLowerCase();
|
|
534
|
+
return value === 'codex'
|
|
535
|
+
|| value === 'openai'
|
|
536
|
+
|| value.includes('openai-codex')
|
|
537
|
+
|| value.includes('codex');
|
|
538
|
+
}
|
|
539
|
+
|
|
403
540
|
async function fetchCodexUsage(accessToken, accountId = '') {
|
|
404
541
|
try {
|
|
405
542
|
const headers = {
|
|
406
543
|
'Authorization': `Bearer ${accessToken}`,
|
|
407
|
-
'User-Agent': 'codex-cli/0.1'
|
|
544
|
+
'User-Agent': 'codex-cli/0.1',
|
|
545
|
+
'Accept': 'application/json',
|
|
546
|
+
'originator': 'codex_cli_rs'
|
|
408
547
|
};
|
|
409
548
|
if (accountId) headers['ChatGPT-Account-Id'] = accountId;
|
|
410
549
|
const result = await httpGet('https://chatgpt.com/backend-api/wham/usage', headers);
|
|
@@ -415,6 +554,166 @@ async function fetchCodexUsage(accessToken, accountId = '') {
|
|
|
415
554
|
}
|
|
416
555
|
}
|
|
417
556
|
|
|
557
|
+
function isCodexCredential(tool, entry = {}) {
|
|
558
|
+
if (tool === 'codex') return true;
|
|
559
|
+
if (tool !== 'omp' && tool !== 'opencode') return false;
|
|
560
|
+
return isCodexOAuthProvider(entry.providerId || entry.secrets?.providerId);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function credentialExpiresAt(entry = {}) {
|
|
564
|
+
const explicit = Number(entry.expiresAt || entry.secrets?.expiresAt || 0);
|
|
565
|
+
if (Number.isFinite(explicit) && explicit > 0) return explicit;
|
|
566
|
+
const { decodeJwtPayload } = require('../server/services/oauth-utils');
|
|
567
|
+
for (const token of [entry.secrets?.accessToken, entry.secrets?.idToken]) {
|
|
568
|
+
const exp = Number(decodeJwtPayload(token)?.exp || 0);
|
|
569
|
+
if (Number.isFinite(exp) && exp > 0) return exp * 1000;
|
|
570
|
+
}
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
async function refreshCodexCredential(entry) {
|
|
575
|
+
const refreshToken = String(entry?.secrets?.refreshToken || '').trim();
|
|
576
|
+
if (!refreshToken) return { entry, refreshed: false, attempted: false };
|
|
577
|
+
const existing = codexRefreshPromises.get(entry.id);
|
|
578
|
+
if (existing) return existing;
|
|
579
|
+
|
|
580
|
+
const promise = (async () => {
|
|
581
|
+
const form = new URLSearchParams({
|
|
582
|
+
grant_type: 'refresh_token',
|
|
583
|
+
refresh_token: refreshToken,
|
|
584
|
+
client_id: CODEX_OAUTH_CLIENT_ID
|
|
585
|
+
}).toString();
|
|
586
|
+
const result = await httpPost(CODEX_OAUTH_TOKEN_URL, form, {
|
|
587
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
588
|
+
'Accept': 'application/json'
|
|
589
|
+
});
|
|
590
|
+
const payload = parseJsonBody(result.body) || {};
|
|
591
|
+
if (result.statusCode < 200 || result.statusCode >= 300 || !payload.access_token) {
|
|
592
|
+
return { entry, refreshed: false, attempted: true };
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const accessToken = String(payload.access_token).trim();
|
|
596
|
+
const nextRefreshToken = String(payload.refresh_token || refreshToken).trim();
|
|
597
|
+
const idToken = String(payload.id_token || entry.secrets.idToken || '').trim();
|
|
598
|
+
const accountId = extractCodexAccountId(idToken, accessToken)
|
|
599
|
+
|| entry.accountId
|
|
600
|
+
|| entry.secrets.accountId
|
|
601
|
+
|| '';
|
|
602
|
+
const expiresIn = Number(payload.expires_in || 0);
|
|
603
|
+
const expiresAt = expiresIn > 0
|
|
604
|
+
? Date.now() + expiresIn * 1000
|
|
605
|
+
: credentialExpiresAt({ secrets: { accessToken, idToken } });
|
|
606
|
+
const lastRefresh = new Date().toISOString();
|
|
607
|
+
|
|
608
|
+
const store = readStore();
|
|
609
|
+
const toolStore = getToolStore(store, entry.tool);
|
|
610
|
+
const stored = toolStore.credentials.find(item => item.id === entry.id);
|
|
611
|
+
if (!stored) return { entry, refreshed: false, attempted: true };
|
|
612
|
+
stored.accountId = accountId || stored.accountId || '';
|
|
613
|
+
stored.expiresAt = expiresAt || stored.expiresAt || null;
|
|
614
|
+
stored.updatedAt = Date.now();
|
|
615
|
+
stored.secrets = {
|
|
616
|
+
...stored.secrets,
|
|
617
|
+
accessToken,
|
|
618
|
+
refreshToken: nextRefreshToken,
|
|
619
|
+
idToken,
|
|
620
|
+
accountId: accountId || stored.secrets.accountId || '',
|
|
621
|
+
expiresAt: expiresAt || stored.secrets.expiresAt || null,
|
|
622
|
+
lastRefresh,
|
|
623
|
+
primaryToken: accessToken
|
|
624
|
+
};
|
|
625
|
+
writeStore(store);
|
|
626
|
+
|
|
627
|
+
if (entry.tool === 'codex' && typeof updateCodexOAuthTokens === 'function') {
|
|
628
|
+
try {
|
|
629
|
+
updateCodexOAuthTokens({
|
|
630
|
+
authMode: stored.secrets.authMode,
|
|
631
|
+
accessToken,
|
|
632
|
+
refreshToken: nextRefreshToken,
|
|
633
|
+
idToken,
|
|
634
|
+
accountId,
|
|
635
|
+
lastRefresh
|
|
636
|
+
});
|
|
637
|
+
} catch {
|
|
638
|
+
// The credential store is sufficient for quota lookup; native sync is best-effort.
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (entry.tool === 'omp' && typeof applyOAuthCredential === 'function') {
|
|
643
|
+
try {
|
|
644
|
+
applyOAuthCredential('omp', {
|
|
645
|
+
providerId: stored.providerId || stored.secrets.providerId,
|
|
646
|
+
credentialType: stored.secrets.credentialType || 'oauth',
|
|
647
|
+
accessToken,
|
|
648
|
+
refreshToken: nextRefreshToken,
|
|
649
|
+
expiresAt,
|
|
650
|
+
accountId,
|
|
651
|
+
accountEmail: stored.accountEmail || stored.secrets.accountEmail || '',
|
|
652
|
+
identityKey: stored.identityKey || stored.secrets.identityKey || accountId,
|
|
653
|
+
primaryToken: accessToken
|
|
654
|
+
});
|
|
655
|
+
} catch {
|
|
656
|
+
// Quota lookup can still use the refreshed app credential if native sync is unavailable.
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return { entry: stored, refreshed: true, attempted: true };
|
|
661
|
+
})().catch(() => ({ entry, refreshed: false, attempted: true }));
|
|
662
|
+
codexRefreshPromises.set(entry.id, promise);
|
|
663
|
+
try {
|
|
664
|
+
return await promise;
|
|
665
|
+
} finally {
|
|
666
|
+
codexRefreshPromises.delete(entry.id);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
async function ensureFreshCodexCredential(entry) {
|
|
671
|
+
const expiresAt = credentialExpiresAt(entry);
|
|
672
|
+
if (expiresAt && expiresAt - Date.now() > CODEX_REFRESH_SKEW_MS) {
|
|
673
|
+
return { entry, refreshed: false, attempted: false };
|
|
674
|
+
}
|
|
675
|
+
return refreshCodexCredential(entry);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
async function refreshNativeCodexOAuth() {
|
|
679
|
+
const native = readAllNativeOAuth('codex')[0];
|
|
680
|
+
if (!native) {
|
|
681
|
+
return { available: false, refreshed: false, synchronized: false };
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const synced = syncLocalCredential('codex');
|
|
685
|
+
const credentialId = synced.credential?.id;
|
|
686
|
+
if (!credentialId) {
|
|
687
|
+
return { available: true, refreshed: false, synchronized: false };
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
let entry = findStoredCredential('codex', credentialId);
|
|
691
|
+
const result = await ensureFreshCodexCredential(entry);
|
|
692
|
+
entry = result.entry || entry;
|
|
693
|
+
|
|
694
|
+
let synchronized = Boolean(result.refreshed);
|
|
695
|
+
if (!result.refreshed && !result.attempted && entry.secrets?.refreshToken) {
|
|
696
|
+
updateCodexOAuthTokens({
|
|
697
|
+
authMode: native.authMode,
|
|
698
|
+
accessToken: native.accessToken,
|
|
699
|
+
refreshToken: native.refreshToken,
|
|
700
|
+
idToken: native.idToken,
|
|
701
|
+
accountId: native.accountId,
|
|
702
|
+
lastRefresh: native.lastRefresh
|
|
703
|
+
});
|
|
704
|
+
synchronized = true;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return {
|
|
708
|
+
available: true,
|
|
709
|
+
refreshed: Boolean(result.refreshed),
|
|
710
|
+
refreshAttempted: Boolean(result.attempted),
|
|
711
|
+
refreshFailed: Boolean(result.attempted && !result.refreshed),
|
|
712
|
+
synchronized,
|
|
713
|
+
credentialId: entry.id
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
|
|
418
717
|
async function fetchGeminiUsage(accessToken) {
|
|
419
718
|
try {
|
|
420
719
|
const body = JSON.stringify({
|
|
@@ -586,9 +885,16 @@ function normalizeOAuthQuota(tool, raw) {
|
|
|
586
885
|
}
|
|
587
886
|
|
|
588
887
|
async function fetchCredentialUsage(tool, credentialId) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
888
|
+
let entry = findStoredCredential(tool, credentialId);
|
|
889
|
+
let secrets = entry.secrets || {};
|
|
890
|
+
let codexRefreshed = false;
|
|
891
|
+
if (isCodexCredential(tool, entry)) {
|
|
892
|
+
const refreshed = await ensureFreshCodexCredential(entry);
|
|
893
|
+
entry = refreshed.entry;
|
|
894
|
+
secrets = entry.secrets || {};
|
|
895
|
+
codexRefreshed = refreshed.refreshed;
|
|
896
|
+
}
|
|
897
|
+
let accessToken = secrets.accessToken || secrets.primaryToken || '';
|
|
592
898
|
if (!accessToken) return { error: '无有效 token' };
|
|
593
899
|
|
|
594
900
|
let response;
|
|
@@ -606,7 +912,7 @@ async function fetchCredentialUsage(tool, credentialId) {
|
|
|
606
912
|
response = await fetchGeminiUsage(accessToken);
|
|
607
913
|
break;
|
|
608
914
|
case 'omp': {
|
|
609
|
-
const providerId = entry.providerId || secrets.providerId || '';
|
|
915
|
+
const providerId = String(entry.providerId || secrets.providerId || '').toLowerCase();
|
|
610
916
|
response = providerId.includes('claude') || providerId.includes('anthropic')
|
|
611
917
|
? await fetchClaudeUsage(accessToken)
|
|
612
918
|
: providerId.includes('gemini') || providerId.includes('google')
|
|
@@ -614,11 +920,34 @@ async function fetchCredentialUsage(tool, credentialId) {
|
|
|
614
920
|
: await fetchCodexUsage(accessToken, extractCodexAccountId(accessToken) || entry.accountId || secrets.accountId);
|
|
615
921
|
break;
|
|
616
922
|
}
|
|
923
|
+
case 'opencode': {
|
|
924
|
+
const providerId = entry.providerId || secrets.providerId || '';
|
|
925
|
+
response = isCodexOAuthProvider(providerId)
|
|
926
|
+
? await fetchCodexUsage(accessToken, extractCodexAccountId(secrets.idToken, accessToken) || entry.accountId || secrets.accountId)
|
|
927
|
+
: { raw: null, provider: 'opencode', statusCode: 200 };
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
617
930
|
default:
|
|
618
931
|
return { quota: null, status: 'unsupported', error: `不支持的工具: ${tool}` };
|
|
619
932
|
}
|
|
620
933
|
if (response?.error) return { quota: null, status: 'unavailable', error: response.error };
|
|
621
934
|
if (response?.statusCode === 401 || response?.statusCode === 403) {
|
|
935
|
+
if (isCodexCredential(tool, entry) && !codexRefreshed) {
|
|
936
|
+
const refreshed = await refreshCodexCredential(entry);
|
|
937
|
+
if (refreshed.refreshed) {
|
|
938
|
+
entry = refreshed.entry;
|
|
939
|
+
secrets = entry.secrets || {};
|
|
940
|
+
accessToken = secrets.accessToken || secrets.primaryToken || '';
|
|
941
|
+
response = await fetchCodexUsage(
|
|
942
|
+
accessToken,
|
|
943
|
+
extractCodexAccountId(secrets.idToken, accessToken) || entry.accountId || secrets.accountId
|
|
944
|
+
);
|
|
945
|
+
if (response?.error) return { quota: null, status: 'unavailable', error: response.error };
|
|
946
|
+
if (response?.statusCode !== 401 && response?.statusCode !== 403) {
|
|
947
|
+
return normalizeOAuthQuota(tool, response?.raw);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
622
951
|
return { quota: null, status: 'unauthorized', error: '上游 OAuth 授权已失效' };
|
|
623
952
|
}
|
|
624
953
|
return normalizeOAuthQuota(tool, response?.raw);
|
|
@@ -627,9 +956,11 @@ async function fetchCredentialUsage(tool, credentialId) {
|
|
|
627
956
|
module.exports = {
|
|
628
957
|
SUPPORTED_TOOLS,
|
|
629
958
|
syncLocalCredential,
|
|
959
|
+
restoreStoredOmpOAuthCredentials,
|
|
630
960
|
normalizeOAuthQuota,
|
|
631
961
|
fetchCredentialUsage,
|
|
632
962
|
extractCodexAccountId,
|
|
633
963
|
normalizeResetAt,
|
|
634
|
-
normalizeWindow
|
|
964
|
+
normalizeWindow,
|
|
965
|
+
refreshNativeCodexOAuth
|
|
635
966
|
};
|
package/src/server/index.js
CHANGED
|
@@ -58,6 +58,30 @@ function traceStartupMemory(stage) {
|
|
|
58
58
|
})}`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
async function refreshNativeCodexOAuthOnStartup({ oauthService } = {}) {
|
|
62
|
+
try {
|
|
63
|
+
const service = oauthService || require('../platforms/oauth-credentials-service');
|
|
64
|
+
if (typeof service.refreshNativeCodexOAuth !== 'function') {
|
|
65
|
+
return { available: false, refreshed: false, synchronized: false };
|
|
66
|
+
}
|
|
67
|
+
const result = await service.refreshNativeCodexOAuth();
|
|
68
|
+
if (result?.refreshed) {
|
|
69
|
+
console.log('[Codex OAuth] Native OAuth token refreshed during startup');
|
|
70
|
+
} else if (result?.refreshFailed) {
|
|
71
|
+
console.warn('[Codex OAuth] 启动刷新失败,请运行 codex login 重新登录');
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.warn(`[Codex OAuth] 启动同步失败,保留本地凭证: ${error.message}`);
|
|
76
|
+
return {
|
|
77
|
+
available: false,
|
|
78
|
+
refreshed: false,
|
|
79
|
+
synchronized: false,
|
|
80
|
+
error: error.message
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
function printPortConflictHelp(port) {
|
|
62
86
|
console.log(chalk.yellow('\n[TIP] 解决方案:'));
|
|
63
87
|
console.log(chalk.gray(' 1. 运行 ctx 命令,选择"配置端口"修改端口'));
|
|
@@ -335,6 +359,7 @@ async function startServer(port, host = '127.0.0.1', options = {}) {
|
|
|
335
359
|
console.log(chalk.yellow(' [LOCK] 已启用 LAN 安全保护:远程写操作默认关闭'));
|
|
336
360
|
}
|
|
337
361
|
}
|
|
362
|
+
await refreshNativeCodexOAuthOnStartup();
|
|
338
363
|
// 自动恢复代理状态
|
|
339
364
|
try {
|
|
340
365
|
await autoRestoreProxies({ ...platformContext, config });
|
|
@@ -382,6 +407,10 @@ async function autoRestoreProxies({ registry, runtime, config, fsImpl = require(
|
|
|
382
407
|
try {
|
|
383
408
|
const result = await driver.restoreOnBoot({ config: resolvedConfig });
|
|
384
409
|
if (!result || result.status === 'ok') {
|
|
410
|
+
const warnings = result?.warnings || result?.data?.warnings || result?.result?.warnings || [];
|
|
411
|
+
warnings.forEach((warning) => {
|
|
412
|
+
console.log(chalk.yellow(`[WARN] ${platform.label || key}: ${warning}`));
|
|
413
|
+
});
|
|
385
414
|
const port = result?.port;
|
|
386
415
|
const suffix = port
|
|
387
416
|
? platform.proxyMode === 'managed'
|
|
@@ -464,5 +493,10 @@ async function performStartupHealthCheck({ config = loadConfig() } = {}) {
|
|
|
464
493
|
|
|
465
494
|
module.exports = {
|
|
466
495
|
startServer,
|
|
467
|
-
_test: {
|
|
496
|
+
_test: {
|
|
497
|
+
autoRestoreProxies,
|
|
498
|
+
performStartupHealthCheck,
|
|
499
|
+
traceStartupMemory,
|
|
500
|
+
refreshNativeCodexOAuthOnStartup
|
|
501
|
+
}
|
|
468
502
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./_plugin-vue_export-helper-BeLZJZij.js";import{O as a,W as t,et as s,mt as r,w as o}from"./vue-vendor-BqZbbXHA.js";import{O as i}from"./light-0eavxNvt.js";import{t as p}from"./ConfigTemplatesPanel-lTdutC8H.js";var m={class:"config-templates-page"},l=e({__name:"ConfigTemplates",setup:e=>(e,l)=>(t(),o("div",m,[a(r(i),{title:"配置模版管理",bordered:!1},{default:s(()=>[a(p,{"in-drawer":!1,"hide-back":!0})]),_:1})]))},[["__scopeId","data-v-a6c39fe5"]]);export{l as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,s as a,t}from"./_plugin-vue_export-helper-BeLZJZij.js";import{C as l,D as s,H as r,I as n,K as o,O as i,S as u,V as c,W as d,Z as p,_t as v,b as m,et as f,f as y,g as h,gt as g,i as j,m as _,mt as k,p as b,r as w,st as x,tt as P,w as C,x as z}from"./vue-vendor-BqZbbXHA.js";import{r as $,t as N}from"./platforms-DWXgmy2w.js";import{Pt as M,_ as I,a as A,q as T,r as D}from"./icons-DmFe4b5j.js";import{l as U}from"./light-0eavxNvt.js";import{n as q,t as K}from"./headers-BqDmkMjy.js";import{I as L,K as S,M as E,N as R,P as H,dt as O,ft as F,gt as V,mt as W,rt as Z}from"./index-Cmmwj3Fx.js";import{t as B}from"./clipboard-B46yyoz_.js";import{p as G,t as J}from"./sessions-D4yQtfKb.js";import{n as Q,t as X}from"./sessions-DqlbocLJ.js";import{n as Y,t as ee}from"./session-visibility-BAmxh3cK.js";var ae={class:"card-content"},te={class:"header-row"},le={class:"project-name"},se={class:"stats-row"},re=t({__name:"ProjectCard",props:{project:{type:Object,required:!0}},emits:["click","delete"],setup(t,{emit:r}){const n=t,o=r,c=x(!1);function p(){o("click")}function h(){o("delete",n.project)}const g=m(()=>n.project?.displayName||n.project?.name||""),j=m(()=>n.project?.path||n.project?.fullPath||n.project?.name||""),b=m(()=>n.project?.sessionCount||0),w=m(()=>n.project?.lastUsed),$=m(()=>{const e=["#18a058","#2080f0","#f0a020","#d03050","#9333ea","#06b6d4"];return e[(n.project?.name||"").split("").reduce((e,a)=>e+a.charCodeAt(0),0)%e.length]});function N(e){if(!e)return"";const a=new Date(e),t=new Date-a;return t<6e4?"刚刚":t<36e5?`${Math.floor(t/6e4)}分钟前`:t<864e5?`${Math.floor(t/36e5)}小时前`:t<6048e5?`${Math.floor(t/864e5)}天前`:a.toLocaleDateString("zh-CN")}return(t,r)=>(d(),C("div",{class:"project-card",onClick:p,onMouseenter:r[0]||(r[0]=e=>c.value=!0),onMouseleave:r[1]||(r[1]=e=>c.value=!1)},[z("div",ae,[z("div",te,[i(k(e),{size:"18",color:$.value},{default:f(()=>[i(k(T))]),_:1},8,["color"]),z("span",le,v(g.value),1),P(i(k(a),{text:"",type:"error",size:"tiny",class:"delete-btn",onClick:_(h,["stop"])},{icon:f(()=>[i(k(e),{size:"14"},{default:f(()=>[i(k(D))]),_:1})]),_:1},512),[[y,c.value]])]),i(k(H),{depth:"3",class:"project-path"},{default:f(()=>[s(v(j.value),1)]),_:1}),z("div",se,[i(k(W),{size:"tiny",bordered:!1,type:"success"},{default:f(()=>[s(v(b.value)+" 会话 ",1)]),_:1}),w.value?(d(),u(k(H),{key:0,depth:"3",class:"last-used"},{default:f(()=>[s(v(N(w.value)),1)]),_:1})):l("",!0)])])],32))}},[["__scopeId","data-v-3a18e66d"]]),ne={class:"project-list-container"},oe={class:"header"},ie={class:"header-text"},ue={key:0,class:"loading-container"},ce={key:1,class:"loading-container compact"},de={key:3,class:"projects-grid"},pe={class:"search-hint"},ve={style:{"margin-bottom":"16px"}},me={key:0,style:{"max-height":"60vh","overflow-y":"auto"}},fe={class:"search-result-header"},ye={class:"search-result-title"},he=t({__name:"ProjectList",setup(t){const y=j(),_=w(),P=X(),D=N(),ae=m(()=>$(_)),te=ae.value,le=x(""),se=x(1);let he=null;const ge=x([]),je=x(null),_e=x(!1),ke=x(""),be=x(null),we=x(!1),xe=x(null),Pe=x("workspace"),Ce=x(null),ze=[{label:"全工作区",value:"workspace"},{label:"当前项目",value:"current"},{label:"指定项目",value:"project"}],$e=m(()=>P.currentProject||ge.value[0]?.name||null),Ne=m(()=>{const e=ge.value.find(e=>e.name===$e.value);return e?.displayName||e?.name||$e.value||"未选择项目"}),Me=e=>e.map(e=>({label:e.displayName&&e.displayName!==e.name?`${e.displayName} (${e.name})`:e.name,value:e.name})),Ie=x([]);function Ae(e){return se.value=e,P.fetchProjects({page:e,limit:P.projectsPagination.limit,query:le.value})}function Te(e){const a=e.fullPath||e.name,t=e.sessionCount||0;E.warning({title:"删除项目",content:`确定要删除项目 "${a}" 吗?\n\n当前项目包含 ${t} 个会话,删除后所有会话数据将无法恢复!`,positiveText:"确定删除",negativeText:"取消",onPositiveClick:async()=>{try{await P.deleteProject(e.name),R.success("项目已删除")}catch(a){R.error("删除失败: "+a.message)}}})}async function De(){try{const a=(e=ae.value,D.get(e)?.command||e);if("manual"===(await B(a))?.method)return void R.warning("自动复制失败,已弹出手动复制框");R.success("基础启动命令已复制到剪贴板")}catch(a){R.error("复制失败: "+a.message)}var e}async function Ue(){if(!ke.value)return;let e=null;if("current"===Pe.value){if(e=$e.value,!e)return void R.warning("当前没有可搜索的项目")}else if("project"===Pe.value&&(e=Ce.value,!e))return void R.warning("请选择要搜索的项目");we.value=!0;try{const a=await G(ke.value,35,ae.value,{projectName:e,limit:35}),t=Y(Array.isArray(a?.sessions)?a.sessions:Array.isArray(a)?a:[]);be.value={...a&&"object"==typeof a&&!Array.isArray(a)?a:{},keyword:ke.value,sessions:t,totalMatches:t.reduce((e,a)=>e+(Number(a.matchCount)||0),0),scope:Pe.value,projectName:e}}catch(a){R.error("搜索失败: "+a.message)}finally{we.value=!1}}async function qe(e){const a=String(e||"").trim();if(a)try{const e=await Q(ae.value,{page:1,limit:50,query:a}),t=ee(e?.projects);Ie.value=Me(t)}catch(t){}else Ie.value=Me(ge.value)}function Ke(e,a){if(!a||!e)return e;const t=new RegExp(`(${a})`,"gi");return e.replace(t,'<mark style="background-color: #ffd700; padding: 2px 4px; border-radius: 2px; font-weight: 600;">$1</mark>')}function Le(e){(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),_e.value=!0,n(()=>{xe.value?.focus()}))}return p(ge,e=>{Ie.value=Me(e)},{immediate:!0}),p(()=>P.projects,e=>{ge.value=[...e]}),p(le,e=>{he&&clearTimeout(he),he=setTimeout(()=>{se.value=1,P.fetchProjects({page:1,limit:P.projectsPagination.limit,query:e}).catch(()=>{})},180)}),p(_e,e=>{e||(ke.value="",be.value=null,Pe.value="workspace",Ce.value=null)}),p(ae,e=>{se.value=1,P.setChannel(e),P.fetchProjects()},{immediate:!0}),c(()=>{document.addEventListener("keydown",Le)}),r(()=>{he&&clearTimeout(he),P.pauseProjectRefresh(te),document.removeEventListener("keydown",Le)}),(t,r)=>(d(),C("div",ne,[z("div",oe,[z("div",ie,[i(k(K),{style:{margin:"0"}},{default:f(()=>[...r[6]||(r[6]=[s("我的项目",-1)])]),_:1}),i(k(H),{depth:"3"},{default:f(()=>[s("选择一个项目查看会话(共 "+v(k(P).projectsPagination.total)+" 个)",1)]),_:1})]),i(k(S),null,{default:f(()=>[i(k(a),{type:"primary",size:"medium",onClick:De},{icon:f(()=>[i(k(e),null,{default:f(()=>[i(k(M))]),_:1})]),default:f(()=>[r[7]||(r[7]=s(" 新建项目 ",-1))]),_:1}),i(k(O),{value:le.value,"onUpdate:value":r[0]||(r[0]=e=>le.value=e),placeholder:"搜索项目...",clearable:"",class:"search-input"},{prefix:f(()=>[i(k(e),null,{default:f(()=>[i(k(I))]),_:1})]),_:1},8,["value"])]),_:1})]),z("div",{class:"content",ref_key:"contentEl",ref:je},[k(P).loading&&0===k(P).projects.length&&!k(P).projectsPending?(d(),C("div",ue,[i(k(L),{size:"large"},{description:f(()=>[...r[8]||(r[8]=[s(" 加载项目列表... ",-1)])]),_:1})])):k(P).projectsPending?(d(),C("div",ce,[i(k(L),{size:"small"},{description:f(()=>[...r[9]||(r[9]=[s(" 正在生成项目列表... ",-1)])]),_:1})])):k(P).error&&0===k(P).projects.length?(d(),u(k(F),{key:2,type:"error",title:"加载失败",style:{"margin-top":"20px"}},{default:f(()=>[s(v(k(P).error),1)]),_:1})):ge.value.length>0?(d(),C("div",de,[(d(!0),C(h,null,o(ge.value,e=>(d(),u(re,{key:e.name,project:e,onClick:a=>{return t=e.name,void y.push({name:"cli-sessions",params:{platform:ae.value,projectName:t}});var t},onDelete:Te},null,8,["project","onClick"]))),128))])):l("",!0),k(P).projectsPagination.total>k(P).projectsPagination.limit?(d(),u(k(q),{key:4,page:se.value,"onUpdate:page":[r[1]||(r[1]=e=>se.value=e),Ae],"page-count":Math.ceil(k(P).projectsPagination.total/k(P).projectsPagination.limit),"page-size":k(P).projectsPagination.limit,"show-quick-jumper":"",class:"list-pagination"},null,8,["page","page-count","page-size"])):l("",!0),k(P).loading||k(P).error||k(P).projectsPending||0!==k(P).projects.length?l("",!0):(d(),u(k(V),{key:5,description:le.value?"没有匹配的项目":"没有找到项目",style:{"margin-top":"60px"}},{icon:f(()=>[i(k(e),null,{default:f(()=>[i(k(T))]),_:1})]),_:1},8,["description"]))],512),z("div",pe,[i(k(H),{depth:"3",style:{"font-size":"12px"}},{default:f(()=>[...r[10]||(r[10]=[z("kbd",null,"Cmd",-1),s(" / ",-1),z("kbd",null,"Ctrl",-1),s(" + ",-1),z("kbd",null,"K",-1),s(" 全局搜索 ",-1)])]),_:1})]),i(k(U),{show:_e.value,"onUpdate:show":r[5]||(r[5]=e=>_e.value=e),preset:"card",title:"全局搜索",style:g([{width:"800px","max-width":"90vw"},{marginTop:"80px"}])},{default:f(()=>[z("div",ve,[i(k(O),{ref_key:"globalSearchInputRef",ref:xe,value:ke.value,"onUpdate:value":r[2]||(r[2]=e=>ke.value=e),placeholder:"搜索对话内容...",clearable:"",onKeyup:b(Ue,["enter"]),disabled:we.value},{prefix:f(()=>[i(k(e),null,{default:f(()=>[i(k(I))]),_:1})]),suffix:f(()=>[i(k(a),{text:"",onClick:Ue,disabled:!ke.value||we.value,loading:we.value},{default:f(()=>[...r[11]||(r[11]=[s(" 搜索 ",-1)])]),_:1},8,["disabled","loading"])]),_:1},8,["value","disabled"])]),i(k(S),{align:"center",style:{"margin-bottom":"16px"}},{default:f(()=>[i(k(H),{depth:"3"},{default:f(()=>[...r[12]||(r[12]=[s("搜索范围",-1)])]),_:1}),i(k(Z),{value:Pe.value,"onUpdate:value":r[3]||(r[3]=e=>Pe.value=e),size:"small",options:ze,style:{width:"130px"},disabled:we.value},null,8,["value","disabled"]),"project"===Pe.value?(d(),u(k(Z),{key:0,value:Ce.value,"onUpdate:value":r[4]||(r[4]=e=>Ce.value=e),size:"small",filterable:"",remote:"",clearable:"",placeholder:"选择项目",options:Ie.value,onSearch:qe,style:{"min-width":"240px"},disabled:we.value},null,8,["value","options","disabled"])):"current"===Pe.value&&$e.value?(d(),u(k(W),{key:1,size:"small",bordered:!1},{default:f(()=>[s(v(Ne.value),1)]),_:1})):l("",!0)]),_:1}),be.value?(d(),C("div",me,[i(k(F),{type:"info",style:{"margin-bottom":"16px"}},{default:f(()=>[s(' 关键词 "'+v(be.value.keyword)+'" 共找到 '+v(be.value.totalMatches)+" 处匹配 ",1)]),_:1}),(d(!0),C(h,null,o(be.value.sessions,t=>(d(),C("div",{key:`${t.channel||ae.value}-${t.projectName}-${t.projectFullPath||""}-${t.sessionId}`,class:"search-result-item"},[z("div",fe,[z("div",ye,[i(k(H),{strong:"",style:{"font-size":"15px","font-weight":"700"}},{default:f(()=>[s(v(t.projectDisplayName),1)]),_:2},1024),i(k(H),{depth:"2",style:{margin:"0 8px"}},{default:f(()=>[...r[13]||(r[13]=[s("·",-1)])]),_:1}),i(k(H),{strong:""},{default:f(()=>[s(v(t.alias?`${t.alias} (${t.sessionId.substring(0,8)})`:t.sessionId.substring(0,8)),1)]),_:2},1024),i(k(W),{size:"small",bordered:!1},{default:f(()=>[s(v(t.matchCount)+" 个匹配",1)]),_:2},1024)]),i(k(a),{size:"small",type:"primary",onClick:e=>async function(e,a,t=ae.value){try{const{copyResult:l}=await J(e,a,t||ae.value);"manual"===l?.method?R.warning("自动复制失败,已弹出手动复制框"):R.success("启动命令已复制到剪贴板"),_e.value=!1}catch(l){R.error("复制失败: "+l.message)}}(t.projectName,t.sessionId,t.channel)},{icon:f(()=>[i(k(e),null,{default:f(()=>[i(k(A))]),_:1})]),default:f(()=>[r[14]||(r[14]=s(" 使用对话 ",-1))]),_:1},8,["onClick"])]),(d(!0),C(h,null,o(t.matches,(e,a)=>(d(),C("div",{key:a,class:"search-match"},[i(k(W),{size:"tiny",type:"user"===e.role?"info":"success",bordered:!1},{default:f(()=>[s(v("user"===e.role?"用户":"助手"),1)]),_:2},1032,["type"]),i(k(H),{depth:"3",class:"search-match-text",innerHTML:Ke(e.context,be.value.keyword)},null,8,["innerHTML"])]))),128))]))),128)),0===be.value.sessions.length?(d(),u(k(V),{key:0,description:"没有找到匹配的内容"})):l("",!0)])):l("",!0)]),_:1},8,["show"])]))}},[["__scopeId","data-v-ae6b8c27"]]);export{he as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.project-card[data-v-3a18e66d]{cursor:pointer;border:1px solid var(--border-primary);background:var(--bg-primary);border-radius:8px;padding:12px 14px;transition:all .25s cubic-bezier(.4,0,.2,1);position:relative;overflow:hidden;box-shadow:0 1px 3px #0000000a}.project-card[data-v-3a18e66d]:before{content:"";opacity:0;background:linear-gradient(#18a058,#18a05866);width:3px;height:100%;transition:opacity .25s;position:absolute;top:0;left:0}.project-card[data-v-3a18e66d]:hover{border-color:#18a05866;transform:translateY(-3px);box-shadow:0 8px 20px #18a0581f,0 2px 6px #0000000f}.project-card[data-v-3a18e66d]:hover:before{opacity:1}.card-content[data-v-3a18e66d]{flex-direction:column;gap:6px;display:flex}.header-row[data-v-3a18e66d]{align-items:center;gap:8px;display:flex}.project-name[data-v-3a18e66d]{text-overflow:ellipsis;white-space:nowrap;color:var(--text-primary);letter-spacing:-.2px;flex:1;font-size:14px;font-weight:600;overflow:hidden}.delete-btn[data-v-3a18e66d]{opacity:.7;transition:opacity .2s;padding:2px!important}.delete-btn[data-v-3a18e66d]:hover{opacity:1}.project-path[data-v-3a18e66d]{text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:1.3;display:block;overflow:hidden}.stats-row[data-v-3a18e66d]{border-top:1px dashed var(--border-primary);justify-content:space-between;align-items:center;margin-top:4px;padding-top:8px;display:flex}.stats-row[data-v-3a18e66d] .n-tag{border-radius:4px;height:18px;padding:0 6px;font-size:11px;font-weight:600}.last-used[data-v-3a18e66d]{font-size:11px;font-weight:500}.project-list-container[data-v-ae6b8c27]{box-sizing:border-box;flex-direction:column;width:100%;height:100%;display:flex}.header[data-v-ae6b8c27]{background:var(--gradient-bg);border-bottom:1px solid var(--border-primary);flex-shrink:0;justify-content:space-between;align-items:flex-start;gap:24px;padding:24px 24px 20px;display:flex;position:relative}.header[data-v-ae6b8c27]:after{content:"";background:linear-gradient(90deg,#0000,#18a0581a,#0000);height:1px;position:absolute;bottom:0;left:0;right:0}.header-text[data-v-ae6b8c27]{flex:1}.header-text[data-v-ae6b8c27] .n-h2{background:linear-gradient(135deg,#1f2937 0%,#374151 100%);-webkit-text-fill-color:transparent;letter-spacing:-.5px;-webkit-background-clip:text;background-clip:text;font-size:26px;font-weight:700}[data-theme=dark] .header-text[data-v-ae6b8c27] .n-h2{background:linear-gradient(135deg,#f9fafb 0%,#d1d5db 100%);-webkit-text-fill-color:transparent;-webkit-background-clip:text;background-clip:text}.search-input[data-v-ae6b8c27]{flex-shrink:0;width:320px}.search-input[data-v-ae6b8c27] .n-input{background:var(--bg-primary);border:1px solid var(--border-primary);border-radius:10px;transition:all .2s}.search-input[data-v-ae6b8c27] .n-input:hover{border-color:var(--border-secondary);box-shadow:var(--shadow-sm)}.search-input[data-v-ae6b8c27] .n-input:focus-within{border-color:#18a058;box-shadow:0 0 0 3px #18a0581a}.content[data-v-ae6b8c27]{background:var(--gradient-bg);flex:1;padding:20px 24px 24px;overflow-y:auto}.loading-container[data-v-ae6b8c27]{justify-content:center;align-items:center;min-height:400px;display:flex}.loading-container.compact[data-v-ae6b8c27]{min-height:180px}.projects-grid[data-v-ae6b8c27]{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;display:grid}.list-pagination[data-v-ae6b8c27]{justify-content:center;margin:24px 0 8px}.ghost[data-v-ae6b8c27]{opacity:.4}.chosen[data-v-ae6b8c27]{transform:scale(1.05);cursor:move!important;box-shadow:0 8px 24px #0003!important}.drag[data-v-ae6b8c27]{opacity:.8;transform:rotate(2deg);box-shadow:0 12px 32px #00000040!important}.search-hint[data-v-ae6b8c27]{border:1px solid var(--border-primary);z-index:10;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);opacity:.8;background:#ffffffe6;border-radius:8px;padding:10px 14px;transition:all .2s;position:fixed;bottom:24px;left:24px;box-shadow:0 4px 12px #00000014}[data-theme=dark] .search-hint[data-v-ae6b8c27]{background:#1e293bf2;border:1px solid #47556999;box-shadow:0 4px 16px #0006}.search-hint[data-v-ae6b8c27]:hover{opacity:1;transform:translateY(-2px);box-shadow:0 6px 16px #0000001f}[data-theme=dark] .search-hint[data-v-ae6b8c27]:hover{box-shadow:0 6px 20px #00000080}.search-hint kbd[data-v-ae6b8c27]{color:var(--text-secondary);background:var(--bg-primary);border:1px solid var(--border-secondary);box-shadow:0 2px 0 var(--border-primary), 0 1px 3px #0000001a;border-radius:4px;padding:4px 8px;font-family:SF Mono,Monaco,monospace;font-size:12px;font-weight:600;line-height:1.4;display:inline-block}[data-theme=dark] .search-hint kbd[data-v-ae6b8c27]{color:#e2e8f0;background:#33415599;border:1px solid #475569cc;box-shadow:0 2px #1e293bcc,0 1px 4px #0006}.search-result-item[data-v-ae6b8c27]{border:1px solid var(--border-primary);background:var(--bg-elevated);border-radius:6px;margin-bottom:16px;padding:12px}.search-result-header[data-v-ae6b8c27]{justify-content:space-between;align-items:center;margin-bottom:8px;display:flex}.search-result-title[data-v-ae6b8c27]{align-items:center;gap:8px;display:flex}.search-match[data-v-ae6b8c27]{background:var(--bg-secondary);border-radius:4px;align-items:flex-start;gap:8px;margin-top:6px;padding:6px;display:flex}.search-match-text[data-v-ae6b8c27]{flex:1;line-height:1.6}
|