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
Retain bounded Electron log file collection
wytbfb75cb82d65
diff --git a/test/e2e/fixtures/electron-log-files.cjs b/test/e2e/fixtures/electron-log-files.cjsindex 4a541870..e44ad933 100644--- a/test/e2e/fixtures/electron-log-files.cjs+++ b/test/e2e/fixtures/electron-log-files.cjs@@ -1,5 +1,6 @@-const { readdirSync, readFileSync } = require('node:fs');+const { readdirSync, openSync, readSync, closeSync } = require('node:fs');const path = require('node:path');+const { StringDecoder } = require('node:string_decoder');const MAX_LOG_BYTES = 2 * 1024 * 1024;function collectLogFiles(root) {@@ -21,14 +22,31 @@ function collectLogFiles(root) {continue;}if (!entry.isFile() || !entry.name.endsWith('.log')) continue;+ let descriptor;try {- const body = readFileSync(fullPath, 'utf8');- const available = MAX_LOG_BYTES - totalBytes;- const slice = body.slice(0, available);- chunks.push(`\n===== ${path.relative(root, fullPath)} =====\n${slice}`);- totalBytes += Buffer.byteLength(slice);+ const header = `\n===== ${path.relative(root, fullPath)} =====\n`;+ const available = MAX_LOG_BYTES - totalBytes - Buffer.byteLength(header);+ if (available <= 0) return;+ descriptor = openSync(fullPath, 'r');+ const buffer = Buffer.alloc(available);+ let length = 0;+ while (length < available) {+ const read = readSync(descriptor, buffer, length, available - length, null);+ if (!read) break;+ length += read;+ }+ // Keep complete UTF-8 characters. Invalid source bytes can expand to+ // replacement characters, so bound the encoded output as well.+ const body = new StringDecoder('utf8').write(buffer.subarray(0, length));+ const encoded = Buffer.from(body, 'utf8');+ const slice = new StringDecoder('utf8').write(encoded.subarray(0, available));+ const chunk = header + slice;+ chunks.push(chunk);+ totalBytes += Buffer.byteLength(chunk);} catch {// A log may be rotated while Electron is shutting down.+ } finally {+ if (descriptor !== undefined) closeSync(descriptor);}}};diff --git a/test/web/electron-e2e-log-files.test.ts b/test/web/electron-e2e-log-files.test.tsindex 381c8552..b98b3338 100644--- a/test/web/electron-e2e-log-files.test.ts+++ b/test/web/electron-e2e-log-files.test.ts@@ -32,3 +32,18 @@ it('handles fixtures that exit before creating a diagnostic directory', () => {roots.push(root);expect(collectLogFiles(root)).toBe('');});++it.each(['ascii', 'cjk', 'astral', 'invalid'])('bounds the complete UTF-8 artifact for %s logs', kind => {+ const root = mkdtempSync(path.join(tmpdir(), 'orkas-log-evidence-'));+ roots.push(root);+ const directory = path.join(root, 'workspace/logs');+ mkdirSync(directory, { recursive: true });+ const body = kind === 'invalid' ? Buffer.alloc(3 * 1024 * 1024, 0xff)+ : (kind === 'cjk' ? '中' : kind === 'astral' ? '😀' : 'a').repeat(3 * 1024 * 1024);+ writeFileSync(path.join(directory, 'current.log'), body);+ const logs = collectLogFiles(root);+ expect(logs).toContain('current.log');+ expect(Buffer.byteLength(logs, 'utf8')).toBeLessThanOrEqual(2 * 1024 * 1024);+ expect(Buffer.byteLength(logs, 'utf8')).toBeGreaterThan(1024 * 1024);+ if (kind !== 'invalid') expect(logs).not.toContain('\ufffd');+});