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
Initialize public storage before loading TypeScript Main
wyt5916fd84a202
diff --git a/bootstrap.cjs b/bootstrap.cjsindex f43ef736..253ff207 100644--- a/bootstrap.cjs+++ b/bootstrap.cjs@@ -79,6 +79,10 @@ function configureWindowsVcRuntimePath() {configureWindowsVcRuntimePath();configurePackagedEsbuildBinary();+// Establish storage before any TypeScript import can snapshot paths.ts.+// Main's transitive imports must not depend on their source order for this.+require('./src/main/install-data-root.cjs');+require('tsx/cjs');require('./src/main/util/native-esm-loader.js').registerNativeEsmLoader();require('tsx/esm/api').register();diff --git a/test/main/bootstrap-entry.test.ts b/test/main/bootstrap-entry.test.tsindex dfae0b69..6568de58 100644--- a/test/main/bootstrap-entry.test.ts+++ b/test/main/bootstrap-entry.test.ts@@ -42,6 +42,54 @@ afterEach(() => {});describe('desktop bootstrap entry', () => {+ it.each([+ { platform: 'darwin', defaultApp: true, override: false },+ { platform: 'linux', defaultApp: true, override: false },+ { platform: 'darwin', defaultApp: false, override: false },+ { platform: 'win32', defaultApp: true, override: true },+ ])('initializes storage before TypeScript or Main can read paths: %j', (scenario) => {+ const expected = scenario.override ? path.join(root, 'override') : path.join(root, '.orkas', 'data');+ const env: Record<string, string> = scenario.override ? { ORKAS_WORKSPACE_ROOT: expected } : {};+ const runtime = { platform: scenario.platform, defaultApp: scenario.defaultApp, env, argv: [], versions: {} };+ const events: string[] = [];+ const bootstrap = fs.readFileSync(path.join(root, 'bootstrap.cjs'), 'utf8');+ runInNewContext(bootstrap, {+ __dirname: root, process: runtime,+ require(name: string) {+ if (name === 'node:fs') return fs;+ if (name === 'node:path') return path;+ if (name === './src/main/install-data-root.cjs') {+ const module = { exports: {} };+ runInNewContext(fs.readFileSync(path.resolve('src/main/install-data-root.cjs'), 'utf8'), {+ module, exports: module.exports, process: runtime,+ require(dependency: string) {+ if (dependency === 'node:fs') return fs;+ if (dependency === 'node:path') return path;+ if (dependency === 'node:os') return { homedir: () => root };+ if (dependency === 'node:child_process') return { execFileSync() { throw new Error('Unexpected host probe'); } };+ if (dependency === './util/migrate-source-data-root.cjs') return { migrateSourceDataRoot() {} };+ throw new Error(`Unexpected install-root import: ${dependency}`);+ },+ });+ return module.exports;+ }+ if (name === 'tsx/cjs' || name === './src/main') {+ // Both TypeScript loaders and newly added Main imports may read paths+ // immediately. No test setup workspace override may hide a cold boot.+ expect(env.ORKAS_WORKSPACE_ROOT).toBe(expected);+ if (!scenario.override) expect(fs.statSync(expected).isDirectory()).toBe(true);+ events.push(name);+ return {};+ }+ if (name === 'tsx/esm/api') return { register() {} };+ if (name === './src/main/util/native-esm-loader.js') return { registerNativeEsmLoader() {} };+ throw new Error(`Unexpected bootstrap import: ${name}`);+ },+ });+ expect(events).toEqual(['tsx/cjs', './src/main']);+ if (scenario.override) expect(fs.existsSync(path.join(root, '.orkas'))).toBe(false);+ });+it.each([{ platform: 'darwin', defaultApp: true, hide: '1', accessory: true },{ platform: 'darwin', defaultApp: true, hide: '0', accessory: false },@@ -60,6 +108,7 @@ describe('desktop bootstrap entry', () => {if (name === 'node:fs') return fs;if (name === 'node:path') return path;if (name === 'electron') return { app: { setActivationPolicy: (policy: string) => events.push(policy) } };+ if (name === './src/main/install-data-root.cjs') return {};if (name === 'tsx/cjs') return {};if (name === 'tsx/esm/api') return { register() {} };if (name === './src/main/util/native-esm-loader.js') return { registerNativeEsmLoader() {} };diff --git a/test/main/native-esm-loader.test.ts b/test/main/native-esm-loader.test.tsindex ca77704c..120e89f9 100644--- a/test/main/native-esm-loader.test.ts+++ b/test/main/native-esm-loader.test.ts@@ -16,6 +16,7 @@ beforeEach(() => {fs.mkdirSync(path.join(root, 'bin'), { recursive: true });fs.copyFileSync(path.join(project, 'bootstrap.cjs'), path.join(root, 'bootstrap.cjs'));const helper = path.join(project, 'src/main/util/native-esm-loader.js');+ fs.copyFileSync(path.join(project, 'src/main/install-data-root.cjs'), path.join(root, 'src/main/install-data-root.cjs'));fs.mkdirSync(path.join(root, 'src/main/util'));if (fs.existsSync(helper)) fs.copyFileSync(helper, path.join(root, 'src/main/util/native-esm-loader.js'));fs.writeFileSync(path.join(dependency, 'package.json'), JSON.stringify({ name: 'fixture', type: 'module', exports: './index.mjs' }));