MCPcopy Create free account
hub / github.com/ephraimduncan/opencode-cursor / processServerMessage

Function processServerMessage

src/proxy.ts:838–870  ·  view source on GitHub ↗
(
  msg: AgentServerMessage,
  blobStore: Map<string, Uint8Array>,
  mcpTools: McpToolDefinition[],
  sendFrame: (data: Uint8Array) => void,
  state: StreamState,
  onText: (text: string, isThinking?: boolean) => void,
  onMcpExec: (exec: PendingExec) => void,
  onCheckpoint?: (checkpointBytes: Uint8Array) => void,
)

Source from the content-addressed store, hash-verified

836}
837
838function processServerMessage(
839 msg: AgentServerMessage,
840 blobStore: Map<string, Uint8Array>,
841 mcpTools: McpToolDefinition[],
842 sendFrame: (data: Uint8Array) => void,
843 state: StreamState,
844 onText: (text: string, isThinking?: boolean) => void,
845 onMcpExec: (exec: PendingExec) => void,
846 onCheckpoint?: (checkpointBytes: Uint8Array) => void,
847): void {
848 const msgCase = msg.message.case;
849
850 if (msgCase === "interactionUpdate") {
851 handleInteractionUpdate(msg.message.value, state, onText);
852 } else if (msgCase === "kvServerMessage") {
853 handleKvMessage(msg.message.value as KvServerMessage, blobStore, sendFrame);
854 } else if (msgCase === "execServerMessage") {
855 handleExecMessage(
856 msg.message.value as ExecServerMessage,
857 mcpTools,
858 sendFrame,
859 onMcpExec,
860 );
861 } else if (msgCase === "conversationCheckpointUpdate") {
862 const stateStructure = msg.message.value as ConversationStateStructure;
863 if (stateStructure.tokenDetails) {
864 state.totalTokens = stateStructure.tokenDetails.usedTokens;
865 }
866 if (onCheckpoint) {
867 onCheckpoint(toBinary(ConversationStateStructureSchema, stateStructure));
868 }
869 }
870}
871
872function handleInteractionUpdate(
873 update: any,

Callers 2

startFunction · 0.85
collectFullResponseFunction · 0.85

Calls 3

handleInteractionUpdateFunction · 0.85
handleKvMessageFunction · 0.85
handleExecMessageFunction · 0.85

Tested by

no test coverage detected