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

Function deriveBridgeKey

src/proxy.ts:1112–1119  ·  view source on GitHub ↗

Derive a key for active bridge lookup (tool-call continuations). Model-specific.

(modelId: string, messages: OpenAIMessage[])

Source from the content-addressed store, hash-verified

1110
1111/** Derive a key for active bridge lookup (tool-call continuations). Model-specific. */
1112function deriveBridgeKey(modelId: string, messages: OpenAIMessage[]): string {
1113 const firstUserMsg = messages.find((m) => m.role === "user");
1114 const firstUserText = firstUserMsg ? textContent(firstUserMsg.content) : "";
1115 return createHash("sha256")
1116 .update(`bridge:${modelId}:${firstUserText.slice(0, 200)}`)
1117 .digest("hex")
1118 .slice(0, 16);
1119}
1120
1121/** Derive a key for conversation state. Model-independent so context survives model switches. */
1122function deriveConversationKey(messages: OpenAIMessage[]): string {

Callers 1

handleChatCompletionFunction · 0.85

Calls 1

textContentFunction · 0.85

Tested by

no test coverage detected