@@ -45,99 +45,12 @@ function parseOptions(argv: readonly string[]): ProducerOptions {
4545 } ;
4646}
4747
48- async function createFixturePlugin ( root : string ) {
49- const pluginDir = path . join ( root , FIXTURE_PLUGIN_ID ) ;
50- const bridgeCallsPath = path . join ( root , "bridge-calls.jsonl" ) ;
51- const toolResultsPath = path . join ( root , "tool-results.jsonl" ) ;
52- await fs . mkdir ( pluginDir , { recursive : true } ) ;
53- await fs . writeFile (
54- path . join ( pluginDir , "openclaw.plugin.json" ) ,
55- `${ JSON . stringify (
56- {
57- id : FIXTURE_PLUGIN_ID ,
58- activation : { onStartup : true } ,
59- configSchema : { type : "object" , additionalProperties : false , properties : { } } ,
60- } ,
61- null ,
62- 2 ,
63- ) } \n`,
64- "utf8" ,
65- ) ;
66- await fs . writeFile (
67- path . join ( pluginDir , "index.js" ) ,
68- `const fs = require("node:fs");
69-
70- const append = (file, value) => fs.appendFileSync(file, JSON.stringify(value) + "\\n");
71- module.exports = {
72- id: ${ JSON . stringify ( FIXTURE_PLUGIN_ID ) } ,
73- register(api) {
74- api.registerRealtimeVoiceProvider({
75- id: ${ JSON . stringify ( FIXTURE_REALTIME_PROVIDER_ID ) } ,
76- label: "QA Voice Call Realtime",
77- isConfigured: () => true,
78- createBrowserSession() {
79- throw new Error("Voice Call fixture is bridge-only");
80- },
81- createBridge(request) {
82- append(process.env.OPENCLAW_QA_VOICE_BRIDGE_CALLS_PATH, {
83- instructions: request.instructions,
84- tools: request.tools?.map((tool) => tool.name) ?? [],
85- });
86- let connected = false;
87- return {
88- supportsToolResultContinuation: true,
89- async connect() {
90- connected = true;
91- request.onReady?.();
92- request.onTranscript?.("user", "Caller partial transcript context", false);
93- setTimeout(() => {
94- request.onToolCall?.({
95- itemId: "qa-consult-item",
96- callId: "qa-consult-call",
97- name: "openclaw_agent_consult",
98- args: {
99- question: "Use the embedded agent context to identify the caller request.",
100- context: "Realtime provider context marker: VOICE-CONSULT-42",
101- },
102- });
103- }, 10);
104- },
105- sendAudio() {},
106- setMediaTimestamp() {},
107- submitToolResult(callId, result, options) {
108- append(process.env.OPENCLAW_QA_VOICE_TOOL_RESULTS_PATH, { callId, result, options });
109- },
110- acknowledgeMark() {},
111- close() { connected = false; },
112- isConnected() { return connected; },
113- triggerGreeting() {},
114- };
115- },
116- });
117- api.registerGatewayMethod("qa.voiceCall.streamSession", async ({ params, respond }) => {
118- const runtime = globalThis[Symbol.for("openclaw.voice-call.runtime")];
119- const callId = typeof params?.callId === "string" ? params.callId : "";
120- const call = runtime?.manager?.getCall?.(callId);
121- const issue = runtime?.manager?.streamSessionIssuer;
122- if (!runtime || !call || typeof issue !== "function" || !call.providerCallId) {
123- respond(false, undefined, { code: "UNAVAILABLE", message: "Voice Call runtime stream issuer unavailable" });
124- return;
125- }
126- const session = issue({
127- providerName: "twilio",
128- callId,
129- from: call.from,
130- to: call.to,
131- direction: call.direction,
132- });
133- respond(true, { ...session, providerCallId: call.providerCallId, webhookUrl: runtime.webhookUrl });
134- });
135- },
136- };
137- ` ,
138- "utf8" ,
139- ) ;
140- return { bridgeCallsPath, pluginDir, toolResultsPath } ;
48+ function createFixturePlugin ( repoRoot : string , outputRoot : string ) {
49+ return {
50+ pluginDir : path . join ( repoRoot , "test/e2e/qa-lab/runtime/fixtures/voice-call-runtime-plugin" ) ,
51+ bridgeCallsPath : path . join ( outputRoot , "bridge-calls.jsonl" ) ,
52+ toolResultsPath : path . join ( outputRoot , "tool-results.jsonl" ) ,
53+ } ;
14154}
14255
14356function withVoiceCallConfig ( params : {
@@ -255,7 +168,7 @@ async function openRealtimeMediaStream(params: {
255168
256169async function runVoiceCallProof ( options : ProducerOptions ) : Promise < string > {
257170 const fixtureRoot = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-voice-call-gateway-" ) ) ;
258- const fixture = await createFixturePlugin ( fixtureRoot ) ;
171+ const fixture = createFixturePlugin ( options . repoRoot , fixtureRoot ) ;
259172 const mock = await startQaMockOpenAiServer ( ) ;
260173 const servePort = await getFreePort ( ) ;
261174 let gateway : Awaited < ReturnType < typeof startQaGatewayChild > > | undefined ;
0 commit comments