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.

888 B
Raw Blame
import { parse, stringify } from 'devalue'

const reducers = {
  Error: (value) =>
    value instanceof Error && {
      name: value.name,
      message: value.message,
      stack: value.stack,
      cause: value.cause
    }
}

const revivers = {
  Error: ({ name, message, stack, cause }) => {
    const error = new Error(message, cause === undefined ? undefined : { cause })
    error.name = name
    error.stack = stack
    return error
  }
}

// Preserves RegExp filters, cyclic test results, and Errors (e.g. a failed module fetch) across Bun/Node's JSON-only IPC.
export function encodeNodeRuntimeMessage(value) {
  return stringify(value, reducers)
}

// Why pass non-strings through: tests that fake a parent with process.emit('message') reach this listener too.
export function decodeNodeRuntimeMessage(text) {
  return typeof text === 'string' ? parse(text, revivers) : text
}