mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 10:08:13 +00:00
* fix(orcad): orca serve owns its Claude and Codex accounts again (#28962) orcad never wired account services, so every accounts.* RPC failed once orca serve moved onto orcad. Build the same account services the desktop builds (now in provider-account-services.ts), made Electron-free, and install them in orcad except on a WSL host, whose desktop owns its accounts. * test(orcad): keep account-services test off the real userData when XDG_CONFIG_HOME is set * fix(orcad): structured Codex chats and session discovery follow this host's managed accounts Create orcad's account services before the runtime so its structured Codex launch/read resolvers and catalog-probe prep are constructor deps, as on the desktop. A client-sent account home still wins, and a WSL host keeps them unset so the desktop-pushed CODEX_HOME applies. AI Vault session discovery now includes this host's managed Codex homes. * fix(orcad): automatic Codex resumes follow the account home their session was recorded in Share the desktop's resume launch prep as a factory and wire it into orcad's PTY registration and AI Vault resume, so a pane restored after an account switch resumes from its origin home. A client-sent account home keeps resuming from itself. --------- Co-authored-by: Neil <neil@stably.ai>
117 lines
3.7 KiB
JavaScript
117 lines
3.7 KiB
JavaScript
import { build } from 'esbuild'
|
|
import { createHash } from 'node:crypto'
|
|
import { readFileSync } from 'node:fs'
|
|
import { basename, dirname, join } from 'node:path'
|
|
import { ORCAD_SERVER_ENTRY_FILENAME } from '../../src/shared/orcad-artifacts.ts'
|
|
|
|
const root = join(import.meta.dirname, '..', '..')
|
|
|
|
export const ORCAD_ENTRY_POINT = 'src/main/orcad/main.ts'
|
|
export const ORCAD_LAUNCHER_ENTRY_POINT = 'src/main/orcad/launcher.ts'
|
|
export const ORCAD_CHILD_ENTRY_POINTS = {
|
|
watcher: 'src/main/ipc/parcel-watcher-process-entry.ts',
|
|
daemon: 'src/main/daemon/daemon-entry.ts',
|
|
writer: 'src/main/persistence/profile-state/profile-state-writer-worker-entry.ts',
|
|
backup: 'src/main/persistence/profile-state/profile-state-backup-worker-entry.ts',
|
|
foreignSqliteReader: 'src/main/foreign-sqlite-readers/foreign-sqlite-reader-entry.ts',
|
|
portScanCommandWorker: 'src/main/ports/port-scan-command-worker-entry.ts',
|
|
sessionScanner: 'src/main/ai-vault/session-scanner-service-entry.ts',
|
|
workerThreadChildProcess:
|
|
'src/main/worker-thread-child-process/worker-thread-child-process-entry.ts',
|
|
claudeProfileSetup: 'src/main/claude-accounts/claude-profile-setup-worker-entry.ts'
|
|
}
|
|
|
|
/** Each child ships flat beside orcad.js under its source basename; the runtime resolvers look there. */
|
|
export function orcadChildOutputFilename(entryPoint) {
|
|
return basename(entryPoint).replace(/\.ts$/, '.js')
|
|
}
|
|
|
|
export const ORCAD_EXTERNAL_MODULES = ['electron', 'node-pty', '@parcel/watcher', 'fsevents']
|
|
|
|
// Bundled ESM resolves from the deployed bundle, like CommonJS __filename.
|
|
export const ORCAD_COMMONJS_MODULE_OPTIONS = {
|
|
banner: {
|
|
js: 'var __orcadModuleUrl = require("node:url").pathToFileURL(__filename).href;'
|
|
},
|
|
define: { 'import.meta.url': '__orcadModuleUrl' },
|
|
logOverride: { 'empty-import-meta': 'error' }
|
|
}
|
|
|
|
// Native binaries are staged separately from every JavaScript entry.
|
|
export const externalNativeAddons = {
|
|
name: 'external-native-addons',
|
|
setup(pluginBuild) {
|
|
pluginBuild.onResolve({ filter: /\.node$/ }, (args) => ({ path: args.path, external: true }))
|
|
}
|
|
}
|
|
|
|
// The UMD build's relative dynamic requires cannot be bundled.
|
|
const jsoncParserEsm = {
|
|
name: 'jsonc-parser-esm',
|
|
setup(pluginBuild) {
|
|
pluginBuild.onResolve({ filter: /^jsonc-parser$/ }, () => ({
|
|
path: join(root, 'node_modules', 'jsonc-parser', 'lib', 'esm', 'main.js')
|
|
}))
|
|
}
|
|
}
|
|
|
|
export function buildOrcadEntry(outfile) {
|
|
return build({
|
|
...ORCAD_COMMONJS_MODULE_OPTIONS,
|
|
entryPoints: [join(root, ORCAD_ENTRY_POINT)],
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node18',
|
|
format: 'cjs',
|
|
outfile,
|
|
external: ORCAD_EXTERNAL_MODULES,
|
|
plugins: [jsoncParserEsm, externalNativeAddons],
|
|
metafile: true,
|
|
minify: true,
|
|
sourcemap: false,
|
|
define: {
|
|
...ORCAD_COMMONJS_MODULE_OPTIONS.define,
|
|
'process.env.NODE_ENV': '"production"'
|
|
},
|
|
logLevel: 'error'
|
|
})
|
|
}
|
|
|
|
export function buildOrcadCli(outfile) {
|
|
return build({
|
|
entryPoints: [join(root, 'src/cli/index.ts')],
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node18',
|
|
format: 'cjs',
|
|
outfile,
|
|
metafile: true,
|
|
minify: true,
|
|
sourcemap: false,
|
|
logLevel: 'error'
|
|
})
|
|
}
|
|
|
|
export function buildOrcadLauncher(outfile) {
|
|
const serverSha256 = createHash('sha256')
|
|
.update(readFileSync(join(dirname(outfile), ORCAD_SERVER_ENTRY_FILENAME)))
|
|
.digest('hex')
|
|
return build({
|
|
...ORCAD_COMMONJS_MODULE_OPTIONS,
|
|
entryPoints: [join(root, ORCAD_LAUNCHER_ENTRY_POINT)],
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node18',
|
|
format: 'cjs',
|
|
outfile,
|
|
metafile: true,
|
|
minify: true,
|
|
sourcemap: false,
|
|
define: {
|
|
...ORCAD_COMMONJS_MODULE_OPTIONS.define,
|
|
ORCAD_SERVER_SHA256: JSON.stringify(serverSha256)
|
|
},
|
|
logLevel: 'error'
|
|
})
|
|
}
|