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

Function handleKvMessage

src/proxy.ts:910–935  ·  view source on GitHub ↗
(
  kvMsg: KvServerMessage,
  blobStore: Map<string, Uint8Array>,
  sendFrame: (data: Uint8Array) => void,
)

Source from the content-addressed store, hash-verified

908}
909
910function handleKvMessage(
911 kvMsg: KvServerMessage,
912 blobStore: Map<string, Uint8Array>,
913 sendFrame: (data: Uint8Array) => void,
914): void {
915 const kvCase = kvMsg.message.case;
916
917 if (kvCase === "getBlobArgs") {
918 const blobId = kvMsg.message.value.blobId;
919 const blobIdKey = Buffer.from(blobId).toString("hex");
920 const blobData = blobStore.get(blobIdKey);
921 sendKvResponse(
922 kvMsg, "getBlobResult",
923 create(GetBlobResultSchema, blobData ? { blobData } : {}),
924 sendFrame,
925 );
926 } else if (kvCase === "setBlobArgs") {
927 const { blobId, blobData } = kvMsg.message.value;
928 blobStore.set(Buffer.from(blobId).toString("hex"), blobData);
929 sendKvResponse(
930 kvMsg, "setBlobResult",
931 create(SetBlobResultSchema, {}),
932 sendFrame,
933 );
934 }
935}
936
937function handleExecMessage(
938 execMsg: ExecServerMessage,

Callers 1

processServerMessageFunction · 0.85

Calls 1

sendKvResponseFunction · 0.85

Tested by

no test coverage detected