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
Stabilize Windows non-model verification
wyt8694d88f369a
diff --git a/bin/bridge-skill-runner.cjs b/bin/bridge-skill-runner.cjsindex 45ff4068..332d28ce 100644--- a/bin/bridge-skill-runner.cjs+++ b/bin/bridge-skill-runner.cjs@@ -14,6 +14,7 @@ const DEFAULT_KILL_GRACE_MS = 5_000;const DEFAULT_SETTLE_MS = 6_000;const DEFAULT_SHUTDOWN_SETTLE_MS = 1_000;const OUTPUT_REF_RE = /^[a-f0-9]{32}$/;+const WINDOWS_OUTPUT_CLEANUP_DELAYS_MS = [0, 25, 75, 150, 300];function positiveInt(value, fallback) {return Number.isFinite(value) && value > 0 ? Math.max(1, Math.trunc(value)) : fallback;@@ -28,6 +29,10 @@ function assertSafeScriptBase(scriptBase) {}}+function wait(delayMs) {+ return new Promise((resolve) => setTimeout(resolve, delayMs));+}+function windowsSystem32Tool(name) {const root = process.env.SystemRoot || process.env.WINDIR || 'C:\\Windows';return path.win32.join(root, 'System32', name);@@ -203,6 +208,20 @@ function createBridgeSkillRunner(options) {}}+ async function removeOutputDirectory() {+ const delays = process.platform === 'win32' ? WINDOWS_OUTPUT_CLEANUP_DELAYS_MS : [0];+ for (const delayMs of delays) {+ if (delayMs > 0) await wait(delayMs);+ try {+ fs.rmSync(outputDir, { recursive: true, force: true });+ return;+ } catch (error) {+ if (error && error.code === 'ENOENT') return;+ if (!error || (error.code !== 'EPERM' && error.code !== 'EBUSY')) return;+ }+ }+ }+function streamPreview(outputRef, stream, spool) {try {const chunk = readUtf8Chunk(streamPath(outputRef, stream), 0, previewBytes);@@ -395,7 +414,8 @@ function createBridgeSkillRunner(options) {shuttingDown = true;const pending = Array.from(activeRuns);for (const entry of pending) entry.terminate();- shutdownPromise = Promise.allSettled(pending.map((entry) => entry.completion)).then(() => {});+ shutdownPromise = Promise.allSettled(pending.map((entry) => entry.completion))+ .then(removeOutputDirectory);return shutdownPromise;}diff --git a/bin/packaged-dependency-gate.cjs b/bin/packaged-dependency-gate.cjsindex 8eb6ee6e..9e67edf2 100644--- a/bin/packaged-dependency-gate.cjs+++ b/bin/packaged-dependency-gate.cjs@@ -40,16 +40,16 @@ function sameJson(left, right) {}function packageRootFromManifestPath(manifestPath) {- const normalized = String(manifestPath).replace(/^\/+/, '');+ const normalized = String(manifestPath).replace(/\\/g, '/').replace(/^\/+/, '');if (normalized === 'package.json') return '';if (!normalized.endsWith('/package.json')) return null;const packageRoot = normalized.slice(0, -'/package.json'.length);return PACKAGE_ROOT_PATTERN.test(packageRoot) ? packageRoot : null;}-function readAsarJson(appAsar, manifestPath) {+function readAsarJson(appAsar, archivePath, manifestPath) {try {- return JSON.parse(asar.extractFile(appAsar, manifestPath).toString('utf8'));+ return JSON.parse(asar.extractFile(appAsar, archivePath).toString('utf8'));} catch (err) {fail(`invalid ${manifestPath} in ${appAsar}: ${err.message}`);}@@ -69,13 +69,14 @@ function readPackagedManifests(appAsar) {const manifests = new Map();for (const entry of entries) {- const manifestPath = String(entry).replace(/^\/+/, '');+ const archivePath = String(entry).replace(/^[\\/]+/, '');+ const manifestPath = archivePath.replace(/\\/g, '/').replace(/^\/+/, '');const packageRoot = packageRootFromManifestPath(manifestPath);if (packageRoot === null) continue;if (manifests.has(packageRoot)) {fail(`duplicate package manifest root in app.asar: ${packageRoot || '(app root)'}`);}- const manifest = readAsarJson(appAsar, manifestPath);+ const manifest = readAsarJson(appAsar, archivePath, manifestPath);if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {fail(`package manifest is not an object: ${manifestPath}`);}diff --git a/scripts/analyze-context-gates.mjs b/scripts/analyze-context-gates.mjsindex 41ccbae4..2389d7d4 100644--- a/scripts/analyze-context-gates.mjs+++ b/scripts/analyze-context-gates.mjs@@ -36,6 +36,7 @@import fs from "node:fs";import path from "node:path";import os from "node:os";+import { fileURLToPath } from "node:url";/** Fixed gate messages: the extracted header message must EQUAL the key.* Substring matching is deliberately avoided — a future "context compaction@@ -532,5 +533,5 @@ function main() {}const invokedDirectly = process.argv[1]- && path.resolve(process.argv[1]) === new URL(import.meta.url).pathname;+ && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));if (invokedDirectly) main();diff --git a/src/main/features/file_indexer.ts b/src/main/features/file_indexer.tsindex 1403c388..dc8c31aa 100644--- a/src/main/features/file_indexer.ts+++ b/src/main/features/file_indexer.ts@@ -38,6 +38,7 @@import * as crypto from 'node:crypto';import * as fs from 'node:fs';import * as path from 'node:path';+import { finished } from 'node:stream/promises';import { userChatAttachmentsDir, userFileCacheDir, projectChatAttachmentsDir } from '../paths';import { listProjectIds } from '../util/project-layout';@@ -282,6 +283,16 @@ function hashUtf8Text(body: string): string {return `sha256:${crypto.createHash('sha256').update(body, 'utf8').digest('hex')}`;}+async function closeReadStream(stream: fs.ReadStream): Promise<void> {+ if (stream.closed) return;+ stream.destroy();+ try {+ await finished(stream);+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code !== 'ABORT_ERR') throw error;+ }+}+/** Count characters and hash decoded UTF-8 text without retaining a large* source. Hashing decoded text preserves the existing edit_file hash contract. */async function analyseUtf8File(absPath: string, sizeBytes: number): Promise<Utf8Analysis> {@@ -337,22 +348,26 @@ async function readUtf8CharSlice(let absoluteChar = 0;let startLine = 1;const stream = fs.createReadStream(absPath, { encoding: 'utf8' });- for await (const chunk of stream) {- const text = String(chunk);- const chunkStart = absoluteChar;- const chunkEnd = chunkStart + text.length;-- const prefixEnd = Math.max(0, Math.min(text.length, charStart - chunkStart));- for (let i = 0; i < prefixEnd; i++) {- if (text.charCodeAt(i) === 10) startLine++;- }+ try {+ for await (const chunk of stream) {+ const text = String(chunk);+ const chunkStart = absoluteChar;+ const chunkEnd = chunkStart + text.length;++ const prefixEnd = Math.max(0, Math.min(text.length, charStart - chunkStart));+ for (let i = 0; i < prefixEnd; i++) {+ if (text.charCodeAt(i) === 10) startLine++;+ }- const takeStart = Math.max(0, charStart - chunkStart);- const takeEnd = Math.min(text.length, charEnd - chunkStart);- if (takeEnd > takeStart) content.push(text.slice(takeStart, takeEnd));+ const takeStart = Math.max(0, charStart - chunkStart);+ const takeEnd = Math.min(text.length, charEnd - chunkStart);+ if (takeEnd > takeStart) content.push(text.slice(takeStart, takeEnd));- absoluteChar = chunkEnd;- if (absoluteChar >= charEnd) break;+ absoluteChar = chunkEnd;+ if (absoluteChar >= charEnd) break;+ }+ } finally {+ await closeReadStream(stream);}return { content: content.join(''), charStart, charEnd, startLine };@@ -406,34 +421,38 @@ async function readUtf8LineSlice(let charEnd: number | undefined;const stream = fs.createReadStream(absPath, { encoding: 'utf8' });- for await (const chunk of stream) {- const text = String(chunk);- const chunkStart = absoluteChar;- const chunkEnd = chunkStart + text.length;-- for (let searchFrom = 0; searchFrom < text.length;) {- const newline = text.indexOf('\n', searchFrom);- if (newline === -1) break;- const newlineChar = chunkStart + newline;- if (charStart !== undefined && currentLine === requestedEnd) {- charEnd = newlineChar;- break;+ try {+ for await (const chunk of stream) {+ const text = String(chunk);+ const chunkStart = absoluteChar;+ const chunkEnd = chunkStart + text.length;++ for (let searchFrom = 0; searchFrom < text.length;) {+ const newline = text.indexOf('\n', searchFrom);+ if (newline === -1) break;+ const newlineChar = chunkStart + newline;+ if (charStart !== undefined && currentLine === requestedEnd) {+ charEnd = newlineChar;+ break;+ }+ currentLine++;+ if (charStart === undefined && currentLine === requestedStart) {+ charStart = newlineChar + 1;+ }+ searchFrom = newline + 1;}- currentLine++;- if (charStart === undefined && currentLine === requestedStart) {- charStart = newlineChar + 1;++ if (charStart !== undefined) {+ const takeStart = Math.max(0, charStart - chunkStart);+ const takeEnd = Math.min(text.length, (charEnd ?? chunkEnd) - chunkStart);+ if (takeEnd > takeStart) content.push(text.slice(takeStart, takeEnd));}- searchFrom = newline + 1;- }- if (charStart !== undefined) {- const takeStart = Math.max(0, charStart - chunkStart);- const takeEnd = Math.min(text.length, (charEnd ?? chunkEnd) - chunkStart);- if (takeEnd > takeStart) content.push(text.slice(takeStart, takeEnd));+ absoluteChar = chunkEnd;+ if (charEnd !== undefined) break;}-- absoluteChar = chunkEnd;- if (charEnd !== undefined) break;+ } finally {+ await closeReadStream(stream);}if (charStart === undefined) {diff --git a/test/main/features/chats.test.ts b/test/main/features/chats.test.tsindex ac7dfa29..0b8830b9 100644--- a/test/main/features/chats.test.ts+++ b/test/main/features/chats.test.ts@@ -139,8 +139,12 @@ describe('chats › message history tombstones', () => {expect(page.history[1].text).toBe(`keep ${unversioned}`);expect(page.history[2].text).toMatch(/^\[poster\]\(chat-media:\/\/local\/.+\?v=\d+-\d+-14\)$/);expect(page.history[3].text).toBe(`keep [poster](${sandboxUrl})`);- expect(fs.readFileSync(historyFile, 'utf8')).toContain(``);- expect(fs.readFileSync(historyFile, 'utf8')).toContain(`[poster](${sandboxUrl})`);+ const persistedRows = fs.readFileSync(historyFile, 'utf8')+ .trimEnd()+ .split('\n')+ .map((line) => JSON.parse(line));+ expect(persistedRows[0].text).toBe(``);+ expect(persistedRows[2].text).toBe(`[poster](${sandboxUrl})`);});it('projects authorized legacy Codex output directives into produced-file footers', async () => {diff --git a/test/main/features/local_access_policy.test.ts b/test/main/features/local_access_policy.test.tsindex b6c4ae51..a2b5c55b 100644--- a/test/main/features/local_access_policy.test.ts+++ b/test/main/features/local_access_policy.test.ts@@ -5,6 +5,10 @@ import * as path from 'node:path';const UID = 'localaccesspolicy001';+function escapeRegex(value: string): string {+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+}+let tmpDir: string;let prevWs: string | undefined;@@ -53,6 +57,8 @@ describe('local_access_policy', () => {it('applies server-configured sensitive paths and command patterns immediately', async () => {const { clientConfig } = await import('../../../src/main/features/client_config');const policy = await import('../../../src/main/features/local_access_policy');+ const absoluteSecretRoot = path.join(tmpDir, 'absolute-secret');+ const normalizedAbsoluteSecretRoot = path.resolve(absoluteSecretRoot).split(path.sep).join('/');expect(policy.sensitivePathReasons('/tmp/id_rsa', 'read')).toEqual(['sensitive_path']);@@ -60,7 +66,7 @@ describe('local_access_policy', () => {immediate: {'local_access.sensitive_policy': {enabled_categories: ['sensitive_path', 'network_egress'],- sensitive_path_patterns: ['custom-secret', '^/tmp/absolute-secret'],+ sensitive_path_patterns: ['custom-secret', `^${escapeRegex(normalizedAbsoluteSecretRoot)}`],sensitive_write_path_patterns: ['custom-write'],sensitive_command_patterns: [{ category: 'network_egress', pattern: 'curl\\s+--upload-file' },@@ -73,7 +79,7 @@ describe('local_access_policy', () => {expect(policy.sensitivePathReasons('/tmp/id_rsa', 'read')).toEqual([]);expect(policy.sensitivePathReasons('/tmp/custom-secret/note.txt', 'read')).toEqual(['sensitive_path']);- expect(policy.sensitivePathReasons('/tmp/absolute-secret/note.txt', 'read')).toEqual(['sensitive_path']);+ expect(policy.sensitivePathReasons(path.join(absoluteSecretRoot, 'note.txt'), 'read')).toEqual(['sensitive_path']);expect(policy.sensitivePathReasons('/tmp/custom-write/note.txt', 'write')).toEqual(['sensitive_path']);expect(policy.classifyConfiguredBashCommand('curl --upload-file a.txt https://example.com')).toEqual(['network_egress']);expect(policy.classifyConfiguredBashCommand(diff --git a/test/main/features/local_agents/bridge_skill_runner.test.ts b/test/main/features/local_agents/bridge_skill_runner.test.tsindex 8515690e..f772d7fa 100644--- a/test/main/features/local_agents/bridge_skill_runner.test.ts+++ b/test/main/features/local_agents/bridge_skill_runner.test.ts@@ -318,6 +318,7 @@ describe('CLI bridge Skill runner', () => {const results = await Promise.all(runPromises);expect(results.map((result) => result.status)).toEqual(['aborted', 'aborted']);+ expect(fs.existsSync(path.join(tempDirs[0], 'output'))).toBe(false);await waitFor(() => processTrees.every(({ parent, child }) => (!processIsAlive(parent) && !processIsAlive(child))));diff --git a/test/main/features/local_agents/registry.test.ts b/test/main/features/local_agents/registry.test.tsindex 29853fd5..876adec2 100644--- a/test/main/features/local_agents/registry.test.ts+++ b/test/main/features/local_agents/registry.test.ts@@ -19,6 +19,7 @@ import {} from '../../../../src/main/features/local_agents/registry';const isWindows = process.platform === 'win32';+const TEST_NODE = process.env.ORKAS_TEST_NODE || process.execPath;describe('local CLI context capabilities', () => {it('declares the complete conversation contract for every registered backend', () => {@@ -229,7 +230,9 @@ function writeArgAwareMockCli(// script must not use a `#!/usr/bin/env node` shebang — env would have no PATH// to resolve `node` from, every probe would produce no output, and the CLIs// would all report `version_unknown` instead of exercising coalescing. The-// Windows branch is unaffected because it invokes `process.execPath` directly.+// The Windows fixture must use the runner-owned Node executable. Vitest runs+// under Electron, while production intentionally strips ELECTRON_RUN_AS_NODE+// before probing a CLI child.function writeCountingMockCli(basePath: string, logPath: string): string {if (isWindows) {const scriptPath = `${basePath}.js`;@@ -244,7 +247,7 @@ function writeCountingMockCli(basePath: string, logPath: string): string {const binPath = `${basePath}.cmd`;fs.writeFileSync(binPath,- `@echo off\r\n"${process.execPath}" "${scriptPath}" %*\r\n`,+ `@echo off\r\n"${TEST_NODE}" "${scriptPath}" %*\r\n`,);return binPath;}diff --git a/test/main/model/local-tools.test.ts b/test/main/model/local-tools.test.tsindex 7781fc1a..ef9f33b5 100644--- a/test/main/model/local-tools.test.ts+++ b/test/main/model/local-tools.test.ts@@ -1464,12 +1464,27 @@ describe('local-tools › bash sensitive approval modes (e2e)', () => {}});- it.each([- ['network download', 'workspace_approval', 'curl https://example.invalid/orkas-sensitive-case', 'network_egress'],- ['destructive Git rollback', 'workspace_approval', 'git reset --hard HEAD~1', 'destructive'],- ['security-boundary weakening', 'workspace_approval', 'NODE_TLS_REJECT_UNAUTHORIZED=0 npm view react version', 'priv_esc'],- ['external application launch', 'all_files_auto', 'open https://example.com', 'external_mutation'],- ] as const)(+ type SensitiveApprovalCase = readonly [+ string,+ 'workspace_approval' | 'all_files_auto',+ string,+ 'network_egress' | 'destructive' | 'priv_esc' | 'external_mutation',+ ];+ const sensitiveCommands: readonly SensitiveApprovalCase[] = process.platform === 'win32'+ ? [+ ['network download', 'workspace_approval', 'curl https://example.invalid/orkas-sensitive-case', 'network_egress'],+ ['destructive Git rollback', 'workspace_approval', 'git reset --hard HEAD~1', 'destructive'],+ ['security-boundary weakening', 'workspace_approval', 'curl.exe --insecure https://example.invalid/orkas-sensitive-case', 'priv_esc'],+ ['external application launch', 'all_files_auto', 'Start-Process https://example.invalid/orkas-sensitive-case', 'external_mutation'],+ ]+ : [+ ['network download', 'workspace_approval', 'curl https://example.invalid/orkas-sensitive-case', 'network_egress'],+ ['destructive Git rollback', 'workspace_approval', 'git reset --hard HEAD~1', 'destructive'],+ ['security-boundary weakening', 'workspace_approval', 'NODE_TLS_REJECT_UNAUTHORIZED=0 npm view react version', 'priv_esc'],+ ['external application launch', 'all_files_auto', 'open https://example.com', 'external_mutation'],+ ];++ it.each(sensitiveCommands)('denies %s before process start and preserves the execution sentinel',async (_label, mode, sensitiveCommand, expectedReason) => {const { lt, perm, bashPerms } = await loadWithBashPerms();@@ -1484,7 +1499,7 @@ describe('local-tools › bash sensitive approval modes (e2e)', () => {try {const bash = lt.createLocalTools(OPTS).find((item) => item.name === 'bash')!;const res = await bash.execute({- command: `${sensitiveCommand} && ${writeMarker}`,+ command: `${sensitiveCommand} ${process.platform === 'win32' ? ';' : '&&'} ${writeMarker}`,timeoutMs: 5000,}, makeCtx());expect(res.isError).toBe(true);diff --git a/test/main/util/packaged-dependency-gate.test.ts b/test/main/util/packaged-dependency-gate.test.tsindex cf72f190..2a2f5114 100644--- a/test/main/util/packaged-dependency-gate.test.ts+++ b/test/main/util/packaged-dependency-gate.test.ts@@ -222,6 +222,9 @@ describe('packaged-dependency-gate', () => {});it('recognizes only real node_modules package roots, not fixture package.json files', () => {+ expect(gate.packageRootFromManifestPath('\\package.json')).toBe('');+ expect(gate.packageRootFromManifestPath('\\node_modules\\@scope\\pkg\\package.json'))+ .toBe('node_modules/@scope/pkg');expect(gate.packageRootFromManifestPath('/node_modules/@scope/pkg/package.json')).toBe('node_modules/@scope/pkg');expect(gate.packageRootFromManifestPath('/node_modules/pkg/test/fixture/package.json')).toBeNull();