openclawsetup 2.8.11 → 2.8.12
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/bin/cli.mjs +68 -2
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -208,6 +208,28 @@ function safeFileRead(path) {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
function sanitizeAuthProfiles(raw) {
|
|
212
|
+
try {
|
|
213
|
+
const obj = JSON.parse(raw);
|
|
214
|
+
const redact = (o) => {
|
|
215
|
+
if (!o || typeof o !== 'object') return o;
|
|
216
|
+
const copy = Array.isArray(o) ? [...o] : { ...o };
|
|
217
|
+
for (const k of Object.keys(copy)) {
|
|
218
|
+
if (/^(key|token|access|refresh|apiKey)$/i.test(k) && typeof copy[k] === 'string') {
|
|
219
|
+
const v = copy[k];
|
|
220
|
+
copy[k] = v.length > 8 ? `${v.slice(0, 4)}...${v.slice(-4)}` : '<REDACTED>';
|
|
221
|
+
} else if (typeof copy[k] === 'object') {
|
|
222
|
+
copy[k] = redact(copy[k]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return copy;
|
|
226
|
+
};
|
|
227
|
+
return JSON.stringify(redact(obj), null, 2);
|
|
228
|
+
} catch {
|
|
229
|
+
return sanitizeText(raw);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
211
233
|
function runCmdCapture(cmd, timeout = 20000) {
|
|
212
234
|
const result = safeExec(cmd, { timeout });
|
|
213
235
|
if (result.ok) {
|
|
@@ -504,7 +526,7 @@ async function collectEvidencePackage(options = {}) {
|
|
|
504
526
|
const captures = {
|
|
505
527
|
doctor: runCmdCapture(`${cliName} doctor`, quick ? 20000 : 90000),
|
|
506
528
|
status: runCmdCapture(`${cliName} status`, 20000),
|
|
507
|
-
gatewayLogs: runCmdCapture(`${cliName}
|
|
529
|
+
gatewayLogs: runCmdCapture(`${cliName} logs --lines 80`, quick ? 20000 : 45000),
|
|
508
530
|
cliVersion: runCmdCapture(`${cliName} --version`, 15000),
|
|
509
531
|
npmListGlobalOpenclaw: runCmdCapture('npm ls -g openclaw --depth=0', 20000),
|
|
510
532
|
npmListGlobalClawdbot: runCmdCapture('npm ls -g clawdbot --depth=0', 20000),
|
|
@@ -528,16 +550,56 @@ async function collectEvidencePackage(options = {}) {
|
|
|
528
550
|
const configRaw = safeFileRead(snapshot.openclaw.configPath);
|
|
529
551
|
const safeConfigPreview = sanitizeText(truncateText(configRaw, 20000));
|
|
530
552
|
|
|
553
|
+
// Capture auth-profiles.json (critical for 401 debugging)
|
|
554
|
+
const configDir = snapshot.openclaw.configDir || '';
|
|
555
|
+
const authProfilesCandidates = configDir ? [
|
|
556
|
+
join(configDir, 'agents', 'main', 'agent', 'auth-profiles.json'),
|
|
557
|
+
join(configDir, 'agent', 'auth-profiles.json'),
|
|
558
|
+
] : [];
|
|
559
|
+
let authProfilesPath = '';
|
|
560
|
+
let authProfilesRaw = '';
|
|
561
|
+
for (const candidate of authProfilesCandidates) {
|
|
562
|
+
const content = safeFileRead(candidate);
|
|
563
|
+
if (content) {
|
|
564
|
+
authProfilesPath = candidate;
|
|
565
|
+
authProfilesRaw = content;
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
// Redact key values but preserve structure for debugging
|
|
570
|
+
const safeAuthProfiles = authProfilesRaw ? sanitizeAuthProfiles(authProfilesRaw) : '';
|
|
571
|
+
|
|
572
|
+
// Try to read Gateway log file directly
|
|
573
|
+
const logFileCandidates = configDir ? [
|
|
574
|
+
join(configDir, 'gateway.log'),
|
|
575
|
+
join(configDir, 'logs', 'gateway.log'),
|
|
576
|
+
join(configDir, 'agents', 'main', 'agent', 'gateway.log'),
|
|
577
|
+
] : [];
|
|
578
|
+
let gatewayLogContent = '';
|
|
579
|
+
for (const candidate of logFileCandidates) {
|
|
580
|
+
const content = safeFileRead(candidate);
|
|
581
|
+
if (content) {
|
|
582
|
+
// Take last 5000 chars
|
|
583
|
+
gatewayLogContent = sanitizeText(content.length > 5000 ? content.slice(-5000) : content);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
531
588
|
const summary = {
|
|
532
589
|
meta: {
|
|
533
590
|
generatedAt: new Date().toISOString(),
|
|
534
591
|
durationMs: Date.now() - startedAt,
|
|
535
592
|
quick,
|
|
536
|
-
evidenceVersion: '1.
|
|
593
|
+
evidenceVersion: '1.1.0',
|
|
537
594
|
},
|
|
538
595
|
snapshot,
|
|
539
596
|
tokenOptimizationPreview,
|
|
540
597
|
captures,
|
|
598
|
+
authProfiles: {
|
|
599
|
+
path: authProfilesPath || '(not found)',
|
|
600
|
+
content: safeAuthProfiles || '(empty or missing)',
|
|
601
|
+
},
|
|
602
|
+
gatewayLogFile: gatewayLogContent || '(not found)',
|
|
541
603
|
strongCheck: strongCheckResult
|
|
542
604
|
? {
|
|
543
605
|
issuesCount: strongCheckResult.issues?.length || 0,
|
|
@@ -550,6 +612,9 @@ async function collectEvidencePackage(options = {}) {
|
|
|
550
612
|
|
|
551
613
|
writeFileSync(join(evidenceDir, 'summary.json'), `${JSON.stringify(summary, null, 2)}\n`, 'utf8');
|
|
552
614
|
writeFileSync(join(evidenceDir, 'config.preview.json.txt'), `${safeConfigPreview || '<empty>'}\n`, 'utf8');
|
|
615
|
+
if (safeAuthProfiles) {
|
|
616
|
+
writeFileSync(join(evidenceDir, 'auth-profiles.preview.json.txt'), `${safeAuthProfiles}\n`, 'utf8');
|
|
617
|
+
}
|
|
553
618
|
|
|
554
619
|
const readme = [
|
|
555
620
|
'# OpenClaw 排障证据包',
|
|
@@ -561,6 +626,7 @@ async function collectEvidencePackage(options = {}) {
|
|
|
561
626
|
'## 文件说明',
|
|
562
627
|
'- summary.json: 机器可解析的完整诊断结果(已脱敏)',
|
|
563
628
|
'- config.preview.json.txt: 配置文件预览(已脱敏)',
|
|
629
|
+
'- auth-profiles.preview.json.txt: 认证配置预览(已脱敏,如存在)',
|
|
564
630
|
'',
|
|
565
631
|
'## 发给技术支持',
|
|
566
632
|
'请把整个证据包文件夹(或 zip)发给技术支持即可。',
|