mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-15 23:24:03 -06:00
eb417bc672
Preserve inbound-audio context for message-tool TTS across embedded reply runs, CLI MCP loopback, and queued follow-up paths. Thanks @ai-hpc. Co-authored-by: ai-hpc <mail.speedy.hpc@hotmail.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
type McpLoopbackRuntime = {
|
|
port: number;
|
|
ownerToken: string;
|
|
nonOwnerToken: string;
|
|
};
|
|
|
|
let activeRuntime: McpLoopbackRuntime | undefined;
|
|
|
|
export function getActiveMcpLoopbackRuntime(): McpLoopbackRuntime | undefined {
|
|
return activeRuntime ? { ...activeRuntime } : undefined;
|
|
}
|
|
|
|
export function setActiveMcpLoopbackRuntime(runtime: McpLoopbackRuntime): void {
|
|
activeRuntime = { ...runtime };
|
|
}
|
|
|
|
export function resolveMcpLoopbackBearerToken(
|
|
runtime: McpLoopbackRuntime,
|
|
senderIsOwner: boolean,
|
|
): string {
|
|
return senderIsOwner ? runtime.ownerToken : runtime.nonOwnerToken;
|
|
}
|
|
|
|
export function clearActiveMcpLoopbackRuntimeByOwnerToken(ownerToken: string): void {
|
|
if (activeRuntime?.ownerToken === ownerToken) {
|
|
activeRuntime = undefined;
|
|
}
|
|
}
|
|
|
|
export function createMcpLoopbackServerConfig(port: number) {
|
|
return {
|
|
mcpServers: {
|
|
openclaw: {
|
|
type: "http",
|
|
url: `http://127.0.0.1:${port}/mcp`,
|
|
headers: {
|
|
Authorization: "Bearer ${OPENCLAW_MCP_TOKEN}",
|
|
"x-session-key": "${OPENCLAW_MCP_SESSION_KEY}",
|
|
"x-openclaw-agent-id": "${OPENCLAW_MCP_AGENT_ID}",
|
|
"x-openclaw-account-id": "${OPENCLAW_MCP_ACCOUNT_ID}",
|
|
"x-openclaw-message-channel": "${OPENCLAW_MCP_MESSAGE_CHANNEL}",
|
|
"x-openclaw-current-channel-id": "${OPENCLAW_MCP_CURRENT_CHANNEL_ID}",
|
|
"x-openclaw-current-thread-ts": "${OPENCLAW_MCP_CURRENT_THREAD_TS}",
|
|
"x-openclaw-current-message-id": "${OPENCLAW_MCP_CURRENT_MESSAGE_ID}",
|
|
"x-openclaw-current-inbound-audio": "${OPENCLAW_MCP_CURRENT_INBOUND_AUDIO}",
|
|
"x-openclaw-inbound-event-kind": "${OPENCLAW_MCP_INBOUND_EVENT_KIND}",
|
|
"x-openclaw-source-reply-delivery-mode": "${OPENCLAW_MCP_SOURCE_REPLY_DELIVERY_MODE}",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|