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.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
// Build SSH hook envelopes from parsed events/raw bodies; publication owns shedding and redelivery.
import type { AgentHookEventPayload } from '../shared/agent-hook-listener/listener-event'
import type { AgentHookRelayEnvelope, AgentHookSource } from '../shared/agent-hook-relay'
import { pickHostTurnEnd } from '../shared/agent-status-types'
// Why: cap metadata to prevent a misbehaving CLI growing the cache unboundedly.
const MAX_HOOK_META_LEN = 64
export function buildRelayHookEnvelope(
event: AgentHookEventPayload,
source: AgentHookSource,
env?: string,
version?: string,
options: { isReplay?: boolean } = {}
): AgentHookRelayEnvelope {
return {
source,
...(event.hostEvidenceObservedAt !== undefined
? { evidenceAgeMs: Math.max(0, Date.now() - event.hostEvidenceObservedAt) }
: {}),
agentPresence: event.agentPresence,
paneKey: event.paneKey,
...(event.hostTurnRevision ? { hostTurnRevision: event.hostTurnRevision } : {}),
...(event.launchToken ? { launchToken: event.launchToken } : {}),
tabId: event.tabId,
worktreeId: event.worktreeId,
connectionId: null,
hasExplicitPrompt: event.hasExplicitPrompt,
promptInteractionKey: event.promptInteractionKey,
hookEventName: event.hookEventName,
providerPromptId: event.providerPromptId,
grokPromptBoundary: event.grokPromptBoundary,
compactTrigger: event.compactTrigger,
toolUseId: event.toolUseId,
toolAgentId: event.toolAgentId,
teammateName: event.teammateName,
toolAgentType: event.toolAgentType,
claudeRunningNonAgentTask: event.claudeRunningNonAgentTask,
...(event.providerSession ? { providerSession: event.providerSession } : {}),
...(event.providerSessionOnly ? { providerSessionOnly: true } : {}),
isReplay: options.isReplay === true ? true : undefined,
...pickHostTurnEnd(event),
env,
version,
payload: event.payload
}
}
export function hookBodyEnv(body: unknown): string | undefined {
if (typeof body !== 'object' || body === null) {
return undefined
}
const v = (body as Record<string, unknown>).env
if (typeof v !== 'string' || v.length === 0 || v.length > MAX_HOOK_META_LEN) {
return undefined
}
return v
}
export function hookBodyVersion(body: unknown): string | undefined {
if (typeof body !== 'object' || body === null) {
return undefined
}
const v = (body as Record<string, unknown>).version
if (typeof v !== 'string' || v.length === 0 || v.length > MAX_HOOK_META_LEN) {
return undefined
}
return v
}