Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): 收窄凭据日志并隔离设置页版本状态
liugaowei422f6f2d0929
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/nodeRuntimeBroker.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/nodeRuntimeBroker.test.tsindex 0c24d3fb90..0ee983bcb6 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/nodeRuntimeBroker.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/nodeRuntimeBroker.test.ts@@ -1769,7 +1769,10 @@ describe('nodeRuntimeBroker · 意外死亡诊断(2026-07-26)', () => {expect(JSON.stringify(warn.mock.calls)).not.toContain('sk-secret-token-12345');});- it.each(['whole', 'split', 'truncated-log', 'partial-at-exit', 'after-stop', 'after-drain'] as const)(+ it.each([+ 'whole', 'split', 'truncated-log', 'partial-at-exit', 'after-stop', 'after-drain',+ 'partial-newline', 'partial-space', 'partial-single-chunk', 'ordinary-after-injection',+ ] as const)('OAuth stderr %s 在主日志及退出诊断中都不泄露令牌', async (scenario) => {const ghost = fakeGhost();ghost.manifest.network = { hosts: ['example.test'], secrets: [{@@ -1794,6 +1797,10 @@ describe('nodeRuntimeBroker · 意外死亡诊断(2026-07-26)', () => {const token = tokens[0];if (scenario === 'whole' || scenario === 'truncated-log') {child.stderr.write(`${scenario === 'truncated-log' ? 'x'.repeat(4050) : ''}Error: ${token} ${tokens[1]}\n`);+ } else if (scenario === 'partial-single-chunk') {+ child.stderr.write(`Error: ${token.slice(0, 18)}\n`);+ } else if (scenario === 'ordinary-after-injection') {+ child.stderr.write('ordinary diagnostic after receiving credentials\n');} else if (scenario === 'after-drain') {child.emit('exit', 1, null);// 不发 end,让生产的有界 drain 兜底先结算、清理令牌集合。@@ -1802,7 +1809,11 @@ describe('nodeRuntimeBroker · 意外死亡诊断(2026-07-26)', () => {} else {child.stderr.write(`Error: ${token.slice(0, 18)}`);if (scenario === 'after-stop') broker.stop('node-ghost');- if (scenario !== 'partial-at-exit') child.stderr.write(`${token.slice(18)} ${tokens[1]}\n`);+ if (scenario === 'partial-newline' || scenario === 'partial-space') {+ child.stderr.write(scenario === 'partial-newline' ? '\n' : ' ');+ } else if (scenario !== 'partial-at-exit') {+ child.stderr.write(`${token.slice(18)} ${tokens[1]}\n`);+ }}if (scenario !== 'after-drain') child.emit('exit', 1, null);child.stderr.end();@@ -1817,6 +1828,7 @@ describe('nodeRuntimeBroker · 意外死亡诊断(2026-07-26)', () => {expect(stderrText).not.toContain(secret);}expect(allOutput).not.toContain(token.slice(0, 18));+ expect(allOutput).not.toContain('ordinary diagnostic after receiving credentials');if (scenario !== 'after-stop' && scenario !== 'after-drain') expect(allOutput).toContain('[REDACTED]');} finally {broker.destroyAll();diff --git a/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts b/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.tsindex a4559ae1ea..3c03e7421f 100644--- a/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts+++ b/apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts@@ -317,8 +317,6 @@ interface WorkerEntry {stderrTotalChars: number;/** stderr 也可能把多字节字符切在两个 Buffer 之间,与 stdout 同理需流式解码。 */stderrDecoder: StringDecoder;- /** 尚可能属于令牌前缀的末段;不写日志或诊断缓存,排空时也不原样释放。 */- stderrRedactionPending: string;/** stdout 的 UTF-8 字节可能把一个汉字切在两个 chunk 之间,必须流式解码。 */stdoutDecoder: StringDecoder;stdoutBuffer: string;@@ -1410,7 +1408,6 @@ export class GhostNodeRuntimeBroker {}entry.pending.clear();entry.exposedSecretValues.clear();- entry.stderrRedactionPending = '';// PID 是启动期已经捕获的只读 fact;停止关键路径前不再调用诊断 getter/logger。const stopPid = entry.diagnosticPid;let sigtermKillReturned = false;@@ -1651,7 +1648,6 @@ export class GhostNodeRuntimeBroker {stderrSegments: [],stderrTotalChars: 0,stderrDecoder: new StringDecoder('utf8'),- stderrRedactionPending: '',stdoutDecoder: new StringDecoder('utf8'),stdoutBuffer: '',nextId: 1,@@ -2191,7 +2187,7 @@ export class GhostNodeRuntimeBroker {this.clearTimer(entry.exitDrain.timer);entry.exitDrain = null;// flush stderrDecoder 残留字节(多字节字符被切在最后一个 chunk 边界时)- const tail = this.redactStderrChunk(entry, entry.stderrDecoder.end(), true);+ const tail = this.redactStderrChunk(entry, entry.stderrDecoder.end());if (tail) {entry.stderrSegments.push({ text: tail, at: this.now() });entry.stderrTotalChars += tail.length;@@ -2273,22 +2269,11 @@ export class GhostNodeRuntimeBroker {return text;}- private redactStderrChunk(entry: WorkerEntry, chunk: string, flush = false): string {- const text = this.redactSecrets(entry, entry.stderrRedactionPending + chunk);- // 完整令牌先替换;可能跨 chunk 的前缀只留在内存,不能先写出再补救。- // 留存长度严格小于该进程已接收的最长凭据,不积累整行日志。- let pendingLength = 0;- for (const secret of entry.exposedSecretValues) {- for (let length = Math.min(secret.length - 1, text.length); length > pendingLength; length--) {- if (text.endsWith(secret.slice(0, length))) {- pendingLength = length;- break;- }- }- }- const end = text.length - pendingLength;- entry.stderrRedactionPending = flush ? '' : text.slice(end);- return text.slice(0, end) + (flush && pendingLength > 0 ? '[REDACTED]' : '');+ private redactStderrChunk(entry: WorkerEntry, chunk: string): string {+ // 接收过凭据的 Worker 可能打印截断、分块或编码后的令牌,字符串匹配+ // 无法保证安全。整个 stderr 不落日志/诊断缓存,仅保留输出发生的标记;+ // 未注入凭据的 Worker 保留原始诊断,RPC 返回结果不受影响。+ return chunk && entry.exposedSecretValues.size > 0 ? '[REDACTED]' : chunk;}private scheduleIdleStop(entry: WorkerEntry): void {diff --git a/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx b/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsxindex fc787d0910..29172d41ef 100644--- a/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx+++ b/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx@@ -343,7 +343,7 @@ export function GhostSettingsWebview({</div>{ghost.enabled ? (<SettingsWebviewBody- key={ownerKey}+ key={JSON.stringify([ownerKey, manifest.id, manifest.version])}ghost={ghost}appearance={appearance}dataOwnerId={dataOwnerId}diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsx b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsxindex 435f5e84ba..151778bbe4 100644--- a/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsx+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsx@@ -17,6 +17,7 @@ import { GhostSettingsWebview } from '../GhostSettingsWebview';import {__resetGhostSettingsHeightCacheForTest,loadGhostSettingsHeight,+ saveGhostSettingsHeight,} from '../ghostSettingsHeight';vi.mock('react-i18next', () => ({@@ -147,6 +148,28 @@ describe('GhostSettingsWebview layout ownership', () => {expect(ownerBHost?.style.height).toBe('160px');});+ it.each([+ ['version', false], ['version', true], ['id', false], ['id', true],+ ] as const)('resets guest state when %s changes in place (cached: %s)', async (field, cached) => {+ const { ghost, host, view, webview } = renderSettings(undefined, 432);+ await waitFor(() => expect(host.style.height).toBe('432px'));+ const updated = {+ ...ghost,+ manifest: { ...ghost.manifest, [field]: field === 'version' ? '2.0.0' : 'another-plugin' },+ };+ if (cached) {+ saveGhostSettingsHeight('owner-a', updated.manifest.id, updated.manifest.version, 240);+ }++ view.rerender(<GhostSettingsWebview ghost={updated} />);++ expect(webview.isConnected).toBe(false);+ expect(view.container.querySelector('webview')).not.toBe(webview);+ // 新 guest 尚未 dom-ready,首帧也不能复用旧组件的高度。+ expect(view.container.querySelector<HTMLElement>('[data-ghost-webview]')?.style.height)+ .toBe(cached ? '240px' : '160px');+ });+it('reopens a fresh guest with height-only spacing, without replaying or capturing old UI', async () => {vi.useFakeTimers();const legacyKey = 'ghostSettings.snapshot.v2.owner-a:example-settings-layout';