Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Keep private IPC failure text out of logs
BlueSkyID66602b08537efcb
diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.tsindex cae44e11..94217f8a 100644--- a/src/main/ipc/index.ts+++ b/src/main/ipc/index.ts@@ -99,7 +99,7 @@ import {findAutoTaskLocation,globalAutoTaskLocation,} from '../util/project-layout';-import { logErrorRef, logPathRef, maskId } from '../util/log-redact';+import { logErrorRef, logErrorSummary, logPathRef, maskId } from '../util/log-redact';import { chatMediaLocalPathFromUrl } from '../util/chat-media-url';import { captureDeliveredTaskIntervention } from '../util/task-intervention-events';import { macosTccSensitivePath } from '../util/macos-tcc';@@ -186,7 +186,7 @@ function logInvokeResultFailure(channel: string, result: Record<string, unknown>...(Number.isInteger(result.failed_count) ? { failed_count: result.failed_count } : {}),} : channel === 'contexts.attachToDraft' || channel === 'projects.files.attachToDraft'? { failure_stage: result.failure_stage, failure_kind: result.failure_kind }- : { error: typeof result.error === 'string' ? result.error : 'operation rejected' }),+ : { error: logErrorSummary(typeof result.error === 'string' ? result.error : 'operation rejected') }),...(suppressed > 0 ? { suppressed_count: suppressed } : {}),});}@@ -4259,7 +4259,7 @@ export function register(): void {? Number(rawCode.trim()): (typeof rawCode === 'string' && rawCode ? rawCode : normalized.code));const attachment = attachmentAddChannels.has(channel) ? attachmentFailureDiagnostic({ code, failure_kind: fileFailureKind(err) }) : null;- log.error(`invoke ${channel} failed`, attachment || { error: normalized.error, code });+ log.error(`invoke ${channel} failed`, attachment || { error: logErrorSummary(err), code });const out: {ok: false;error: string;@@ -4317,7 +4317,7 @@ export function register(): void {const normalized = normalizeAppError(err);log.warn('local file import request failed', {code: normalized.code,- error: normalized.error,+ error: logErrorSummary(err),});return { ok: false, error: normalized.error, code: normalized.code };}@@ -4358,7 +4358,7 @@ export function register(): void {out(ev);}} catch (err) {- log.error(`stream ${channel} failed`, { error: (err as Error)?.message || String(err) });+ log.error(`stream ${channel} failed`, { error: logErrorSummary(err) });out({ type: 'error', text: (err as Error).message || String(err) });} finally {activeStreams.delete(requestId);diff --git a/test/main/ipc/contexts-pick-upload.test.ts b/test/main/ipc/contexts-pick-upload.test.tsindex 95837a4d..d6b4ca95 100644--- a/test/main/ipc/contexts-pick-upload.test.ts+++ b/test/main/ipc/contexts-pick-upload.test.ts@@ -262,9 +262,13 @@ it.each([{}, { path: '' }])('refuses an empty Library deletion through the actuaok: result.ok,source: fs.existsSync(source) ? fs.readFileSync(source, 'utf8') : null,}).toEqual({ ok: false, source: '# Protected Library source' });+ expect(result.error).toBe('path required');expect(warnings).toHaveBeenCalledExactlyOnceWith('invoke returned failure', {- channel: 'contexts.delete', code: 'operation_rejected', error: 'path required',+ channel: 'contexts.delete', code: 'operation_rejected', error: expect.objectContaining({+ message_chars: 13, message_hash: 'd7c056fdbfce',+ }),});+ expect(JSON.stringify(warnings.mock.calls)).not.toContain('path required');const kb = await import('../../../src/main/features/kb_indexer');expect(kb.enqueue).not.toHaveBeenCalled();const recycle = await import('../../../src/main/features/recycle_bin');diff --git a/test/main/ipc/failure-log-privacy.test.ts b/test/main/ipc/failure-log-privacy.test.tsnew file mode 100644index 00000000..b79b8cb0--- /dev/null+++ b/test/main/ipc/failure-log-privacy.test.ts@@ -0,0 +1,114 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { trustedIpcSender } from '../../helpers/trusted-ipc-sender';+import { drainMainRuntimeForTest } from '../../helpers/drain-main-runtime';++const mocks = vi.hoisted(() => ({+ log: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },+}));+vi.mock('../../../src/main/logger', () => ({+ createLogger: () => mocks.log,+ logFromRenderer: vi.fn(),+}));+vi.mock('electron', () => ({+ app: { isPackaged: false },+ ipcMain: { handle: vi.fn(), on: vi.fn() },+ dialog: { showOpenDialog: vi.fn(async () => ({ canceled: true, filePaths: [] })) },+ BrowserWindow: { getAllWindows: vi.fn(() => []), getFocusedWindow: vi.fn(() => null) },+ shell: { openPath: vi.fn(), showItemInFolder: vi.fn() },+}));++let workspace: string;+let previousWorkspace: string | undefined;+let invoke: (event: any, request: unknown) => Promise<any>;+let importFiles: (event: any, request: unknown) => Promise<any>;+let startStream: (event: any, request: unknown) => Promise<void>;+const privateText = 'PrivateAgentLabel_private_prompt_fragment';++beforeEach(async () => {+ previousWorkspace = process.env.ORKAS_WORKSPACE_ROOT;+ workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'orkas-ipc-log-privacy-'));+ process.env.ORKAS_WORKSPACE_ROOT = workspace;+ vi.resetModules();+ vi.clearAllMocks();+ const users = await import('../../../src/main/features/users');+ users.activateUser('ipc-log-privacy-user');+ const { register } = await import('../../../src/main/ipc/index');+ const { ipcMain } = await import('electron');+ register();+ invoke = vi.mocked(ipcMain.handle).mock.calls.find(([name]) => name === 'orkas.invoke')![1];+ importFiles = vi.mocked(ipcMain.handle).mock.calls.find(([name]) => name === 'orkas.importLocalFiles')![1];+ startStream = vi.mocked(ipcMain.on).mock.calls.find(([name]) => name === 'orkas.streamStart')![1] as any;+ vi.clearAllMocks();+});+afterEach(async () => {+ await drainMainRuntimeForTest();+ vi.restoreAllMocks();+ if (previousWorkspace === undefined) delete process.env.ORKAS_WORKSPACE_ROOT;+ else process.env.ORKAS_WORKSPACE_ROOT = previousWorkspace;+ fs.rmSync(workspace, { recursive: true, force: true });+});++function expectPrivateFailureSummary(method: 'warn' | 'error', label: string) {+ const call = mocks.log[method].mock.calls.find(([message]) => message === label);+ expect(call).toBeDefined();+ expect(call![1].error).toMatchObject({+ message_chars: expect.any(Number), message_hash: expect.stringMatching(/^[a-f0-9]{12}$/),+ });+ expect(JSON.stringify(Object.values(mocks.log).flatMap(log => log.mock.calls)))+ .not.toContain(privateText);+}++describe('IPC failure log privacy and caller recovery', () => {+ it('keeps a duplicate-name reply intact while excluding the name from exception logs', async () => {+ const agents = await import('../../../src/main/features/agents');+ const error = Object.assign(new Error(`agent name "${privateText}" is already in use`), {+ code: 'E_AGENT_NAME_TAKEN',+ });+ vi.spyOn(agents, 'createCustomAgent').mockRejectedValueOnce(error);+ const result = await invoke({ sender: trustedIpcSender() }, {+ channel: 'agents.create', payload: { name: privateText },+ });+ expect(result).toMatchObject({ ok: false, code: 'E_AGENT_NAME_TAKEN', error: error.message });+ expectPrivateFailureSummary('error', 'invoke agents.create failed');+ });++ it('summarizes returned failures without changing their reply or blocking a later success', async () => {+ const failure = { ok: false, code: 'E_SERVER_UNAVAILABLE', error: privateText };+ const auth = await import('../../../src/main/features/auth');+ vi.spyOn(auth, 'getConfig').mockReturnValueOnce(failure as any).mockReturnValueOnce({ ready: true } as any);+ const event = { sender: trustedIpcSender() };+ expect(await invoke(event, { channel: 'auth.getConfig' })).toEqual(failure);+ expectPrivateFailureSummary('warn', 'invoke returned failure');+ expect(await invoke(event, { channel: 'auth.getConfig' })).toEqual({ ok: true, ready: true });+ expect(mocks.log.warn.mock.calls.filter(([message]) => message === 'invoke returned failure')).toHaveLength(1);+ });++ it('keeps a local import failure reply without putting its private text in logs', async () => {+ const users = await import('../../../src/main/features/users');+ vi.spyOn(users, 'getOrCreateSelfUser').mockRejectedValueOnce(new Error(privateText));+ expect(await importFiles({ sender: trustedIpcSender() }, {}))+ .toEqual({ ok: false, code: 'E_UNKNOWN', error: privateText });+ expectPrivateFailureSummary('warn', 'local file import request failed');+ });++ it('finishes a failed stream, preserves its error event and allows the same request id again', async () => {+ const users = await import('../../../src/main/features/users');+ vi.spyOn(users, 'getOrCreateSelfUser').mockRejectedValueOnce(new Error(privateText));+ const sender = Object.assign(trustedIpcSender(), { isDestroyed: () => false, send: vi.fn() });+ const request = { channel: 'agents.chat.sendStream', requestId: 'privacy-stream', payload: { id: 'privacy-agent', content: 'Hello' } };+ await startStream({ sender }, request);+ expect(sender.send.mock.calls).toEqual([+ ['stream:privacy-stream', { type: 'error', text: privateText }],+ ['stream:privacy-stream', { type: 'done' }],+ ]);+ expectPrivateFailureSummary('error', 'stream agents.chat.sendStream failed');+ sender.send.mockClear();+ const agents = await import('../../../src/main/features/agents');+ vi.spyOn(agents, 'streamSendToAgentEditChat').mockImplementationOnce(async function* () {});+ await startStream({ sender }, request);+ expect(sender.send.mock.calls).toEqual([['stream:privacy-stream', { type: 'done' }]]);+ });+});diff --git a/test/main/ipc/import-local-files.test.ts b/test/main/ipc/import-local-files.test.tsindex 15947661..5641f32b 100644--- a/test/main/ipc/import-local-files.test.ts+++ b/test/main/ipc/import-local-files.test.ts@@ -200,8 +200,8 @@ describe('add a user-selected local file to conversation attachments', () => {['pptx', 'presentation'], ['zip', 'archive'], ['mp4', 'video'],])('copies an unrecorded external %s file and reuses its pending attachment on repeat', async (ext, kind) => {// The two rejected reads/deletes of the original path are asserted below.- expectTestLog({ level: 'error', source: 'ipc', message: /^invoke produced\.readText failed \{ error: 'path is outside the user workspace'/ });- expectTestLog({ level: 'error', source: 'ipc', message: /^invoke workspace\.deletePath failed \{ error: 'path/ });+ expectTestLog({ level: 'error', source: 'ipc', message: /^invoke produced\.readText failed \{$/ });+ expectTestLog({ level: 'error', source: 'ipc', message: /^invoke workspace\.deletePath failed \{$/ });const fixtures: Record<string, Buffer> = {pdf: makeMinimalPdf(['Selected document']), docx: makeMinimalDocx({ paragraphs: ['Selected document'] }),xlsx: makeMinimalXlsx(), pptx: makeMinimalPptx(),@@ -216,8 +216,10 @@ describe('add a user-selected local file to conversation attachments', () => {await expect(invoke('conversations.attachments.import', { cid: CID, path: abs })).resolves.toMatchObject({ ok: true, reused: true, info: { name: result.info.name } });// Import copies bytes; it does not grant access to the original directory.- await expect(invoke('produced.readText', { cid: CID, path: abs })).resolves.toMatchObject({ ok: false });- await expect(invoke('workspace.deletePath', { cid: CID, path: abs })).resolves.toMatchObject({ ok: false });+ await expect(invoke('produced.readText', { cid: CID, path: abs }))+ .resolves.toMatchObject({ ok: false, error: 'path is outside the user workspace' });+ await expect(invoke('workspace.deletePath', { cid: CID, path: abs }))+ .resolves.toMatchObject({ ok: false, error: 'path is outside the user workspace' });expect(fs.readFileSync(abs)).toEqual(content);});@@ -375,9 +377,8 @@ describe('manual attachment import boundaries', () => {});it('reports missing and unsupported scheduled-task selections and allows a corrected retry', async () => {- // Both rejections are asserted with their error before the corrected retry.- expectTestLog({ level: 'error', source: 'ipc', message: /^invoke autoTasks\.attachments\.import failed \{ error: 'file not found'/ });- expectTestLog({ level: 'error', source: 'ipc', message: /^invoke autoTasks\.attachments\.import failed \{ error: 'unsupported/ });+ // The tap matches the content-free header; each error reply is asserted below.+ expectTestLog({ level: 'error', source: 'ipc', message: /^invoke autoTasks\.attachments\.import failed \{$/ });const taskId = 'at_12345678';const abs = sourceFile('brief.txt', 'restored source', 'downloads');const unsupported = sourceFile('program.exe', 'unsupported');diff --git a/test/main/ipc/model-config-auth.test.ts b/test/main/ipc/model-config-auth.test.tsindex ab692876..7dfccb75 100644--- a/test/main/ipc/model-config-auth.test.ts+++ b/test/main/ipc/model-config-auth.test.ts@@ -236,10 +236,10 @@ describe('ipc › model config auth lists', () => {expect(initial.modelsByProvider).toBeUndefined();expect(initial.providers).toEqual(expect.arrayContaining([expect.objectContaining({- id: 'doubao:doubao-seedream-5-0-lite-260128',+ id: 'doubao:doubao-seedream-5-0-flash-260915',provider: 'doubao',- model: 'doubao-seedream-5-0-lite-260128',- label: 'DouBao · Seedream 5.0 Lite',+ model: 'doubao-seedream-5-0-flash-260915',+ label: 'DouBao · Seedream 5.0 Flash',}),expect.objectContaining({id: 'doubao:doubao-seedream-5-0-pro-260628',diff --git a/test/main/ipc/retained-feature-parity.test.ts b/test/main/ipc/retained-feature-parity.test.tsindex a414dda1..b3a8c7f1 100644--- a/test/main/ipc/retained-feature-parity.test.ts+++ b/test/main/ipc/retained-feature-parity.test.ts@@ -113,9 +113,11 @@ describe('retained Agent memory and Office preview IPC', () => {it('reports unsupported legacy video credentials without exposing them as an active provider', async () => {const auth = await import('../../../src/main/features/auth');- auth.saveVideoProfiles([{ id: 'legacy', provider: 'doubao', model: 'doubao-seedance-2-0-260128', apiKey: 'legacy-private-key', label: 'Legacy', createdAt: 1 }]);+ auth.saveVideoProfiles([{ id: 'legacy', provider: 'retired-provider' as any, model: 'retired-model', apiKey: 'legacy-private-key', label: 'Legacy', createdAt: 1 }]);const result = await invoke('videoAuth.list', {});- expect(result.providers.map((provider: any) => provider.provider)).toEqual(['orkas-api']);+ const providers = result.providers.map((provider: any) => provider.provider);+ expect(providers).toEqual(expect.arrayContaining(['orkas-api', 'doubao', 'minimax', 'vidu', 'kling', 'google', 'runway']));+ expect(providers).not.toContain('retired-provider');expect(result.profiles).toEqual([expect.objectContaining({ id: 'legacy', available: false })]);expect(result.profiles[0]).not.toHaveProperty('apiKey');expect(auth.loadVideoProfiles()[0]?.apiKey).toBe('legacy-private-key');