@@ -3,11 +3,15 @@ import { StackContextManager } from "@opentelemetry/sdk-trace-web";
33import { describe , expect , it , vi } from "vitest" ;
44import { JSONRPCRequestSchema } from "@browserbasehq/stagehand-protocol/json-rpc/schemas" ;
55import { StagehandMethods } from "@browserbasehq/stagehand-protocol/schema-registry" ;
6+ import { STAGEHAND_PROTOCOL_VERSION } from "@browserbasehq/stagehand-protocol/schemas" ;
67import { ChromeRuntimeClient } from "../clients/chromeRuntimeClient.ts" ;
78import { RPCClient } from "../clients/rpcClient.ts" ;
89import { createStagehandRuntime } from "../runtime.ts" ;
910import { RPCRouter } from "../rpcRouter.ts" ;
1011
12+ const [ protocolMajor , protocolMinor , protocolPatch ] =
13+ STAGEHAND_PROTOCOL_VERSION . split ( "." ) . map ( Number ) ;
14+
1115describe ( "worker RPCClient" , ( ) => {
1216 function createRuntime ( ) {
1317 return createStagehandRuntime (
@@ -315,10 +319,10 @@ describe("worker RPCClient", () => {
315319 } ) ;
316320
317321 it . each ( [
318- [ "1.0.9" , true , undefined ] ,
319- [ "1.1.0" , false , "protocol-server-too-old" ] ,
320- [ "2 .0.0" , false , "protocol-major-mismatch" ] ,
321- [ "1.0.0 -beta.1" , false , "protocol-prerelease-mismatch" ] ,
322+ [ ` ${ protocolMajor } . ${ protocolMinor } . ${ protocolPatch + 1 } ` , true , undefined ] ,
323+ [ ` ${ protocolMajor } . ${ protocolMinor + 1 } .0` , false , "protocol-server-too-old" ] ,
324+ [ ` ${ protocolMajor + 1 } .0.0` , false , "protocol-major-mismatch" ] ,
325+ [ ` ${ STAGEHAND_PROTOCOL_VERSION } -beta.1` , false , "protocol-prerelease-mismatch" ] ,
322326 ] as const ) (
323327 "negotiates client protocol %s through the stagehand.init wire handshake" ,
324328 async ( protocolVersion , compatible , reason ) => {
0 commit comments