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.

1.1 KB
Raw Blame
export const REMOTE_ARTIFACT_INPUT_ENV = 'ORCA_REMOTE_ARTIFACT_INPUT'

export function sshArtifactSourceKey(targetId: string, sourceKey: string): string {
  return JSON.stringify(['ssh', targetId, sourceKey])
}

export type RemoteArtifactInput = {
  sourceKey: string
  fileName: string
  contentType?: 'text/html' | 'text/markdown'
}

export function normalizeRemoteArtifactInput(value: unknown): RemoteArtifactInput | null {
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
    return null
  }
  const input = value as Partial<RemoteArtifactInput>
  if (
    typeof input.sourceKey !== 'string' ||
    !input.sourceKey ||
    typeof input.fileName !== 'string' ||
    !input.fileName ||
    (input.contentType !== undefined && !['text/html', 'text/markdown'].includes(input.contentType))
  ) {
    return null
  }
  return input as RemoteArtifactInput
}

export function parseRemoteArtifactInput(value: string | undefined): RemoteArtifactInput | null {
  if (!value) {
    return null
  }
  try {
    return normalizeRemoteArtifactInput(JSON.parse(value))
  } catch {
    return null
  }
}