Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

998 B
Raw Blame
import { join } from 'node:path'
import { runProcessSync } from '@orca/process-host'
import { windowsProcessTreeAddonDefect } from './windows-process-tree-gyp-rebuild.mjs'

const root = join(import.meta.dirname, '../..')

function checkPreparedRuntime() {
  return runProcessSync({
    program: process.execPath,
    args: [join(root, 'config/scripts/ensure-native-runtime.mjs'), '--check-only'],
    cwd: root,
    timeoutMs: 30_000
  })
}

export function canReusePreparedAddon({
  enabled = false,
  arch,
  addonPath,
  sourceRepaired,
  hostArch = process.arch,
  platform = process.platform,
  checkRuntime = checkPreparedRuntime
}) {
  if (!enabled || sourceRepaired !== false || platform !== 'win32' || arch !== hostArch) {
    return false
  }
  try {
    if (windowsProcessTreeAddonDefect(addonPath, arch) !== null) {
      return false
    }
    const result = checkRuntime()
    return result.code === 0 && !result.timedOut && !result.outputTruncated
  } catch {
    return false
  }
}