Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

835 B
Raw Blame
import type { ActivityFrame } from './turnActivity.js'
export interface AgentEvent extends Record<string, unknown> {
  type: string
  payload: Record<string, unknown>
}

/** Add stable agent identity without removing the engine session id used by transcript events. */
export function correlateAgentEvent(
  event: AgentEvent,
  sessionId: string,
  agentId: string,
): AgentEvent & { agentId: string; dbSessionId: string } {
  return {
    ...event,
    agentId,
    dbSessionId: sessionId,
    payload: { ...event.payload, agentId, sessionId },
  }
}

export function turnHeartbeatFrame(
  sessionId: string,
  agentId: string,
  activity?: ActivityFrame,
): AgentEvent & { agentId: string; dbSessionId: string } {
  return correlateAgentEvent({ type: 'turn_heartbeat', payload: activity ? { activity } : {} }, sessionId, agentId)
}