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.2 KB
Raw Blame
// Carry timed-out provider start steps so readers can name the stalled method and deadline.

export type AgentSessionRequestTimeout = {
  /** The provider's protocol method, e.g. `thread/start`; never its params. */
  method: string
  timeoutMs: number
}

// A protocol method name, not free text: the words show it as it is.
const METHOD_NAME = /^[A-Za-z][\w./-]{0,63}$/

/** A timeout as a reader meets it; undefined unless both fields are ones this build can show. */
export function readAgentSessionRequestTimeout(
  value: unknown
): AgentSessionRequestTimeout | undefined {
  if (typeof value !== 'object' || value === null || Array.isArray(value)) {
    return undefined
  }
  const record: Record<string, unknown> = { ...value }
  const { method, timeoutMs } = record
  return typeof method === 'string' &&
    METHOD_NAME.test(method) &&
    typeof timeoutMs === 'number' &&
    Number.isInteger(timeoutMs) &&
    timeoutMs > 0
    ? { method, timeoutMs }
    : undefined
}

/** Whole seconds, at least one, as the words say a deadline. */
export function requestTimeoutSeconds({ timeoutMs }: AgentSessionRequestTimeout): string {
  return String(Math.max(1, Math.round(timeoutMs / 1000)))
}