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.

725 B
Raw Blame
import { realpathSync } from 'node:fs'
import { pathToFileURL } from 'node:url'

// Use file URL conversion and realpath: hand-built URLs fail Windows, while symlinked argv differs from canonical import.meta.url and silently skips builders.
// Inject both seams so POSIX tests cover Windows and missing-path behavior.
export function isDirectInvocation(
  moduleUrl,
  scriptPath,
  { toFileUrl = pathToFileURL, realpath = realpathSync } = {}
) {
  if (!scriptPath) {
    return false
  }
  let resolved = scriptPath
  try {
    resolved = realpath(scriptPath)
  } catch {
    // A path that cannot be resolved cannot be this module; fall through to the literal compare.
  }
  return moduleUrl === toFileUrl(resolved).href
}