```mermaid
sequenceDiagram
    participant Parent as Parent Process<br/>(StdioTransport)
    participant ParentServer as Parent<br/>JsonRpcServer
    participant ParentClient as Parent<br/>JsonRpcClient
    participant ChildProcess as Child Process<br/>(Deno)
    participant ChildTransport as Child<br/>BidirectionalTransport
    participant ChildServer as Child<br/>JsonRpcServer
    participant ChildClient as Child<br/>JsonRpcClient

    Note over Parent,ChildClient: 🚀 Initialization Phase
    Parent->>ChildProcess: spawn("process.ts")
    ChildProcess->>ChildTransport: new BidirectionalStdioTransport()
    ChildTransport->>ChildServer: registerMethod("ping", () => "pong")
    ChildTransport->>ChildServer: registerMethod("callParent", async fn)
    ChildTransport->>+ChildTransport: initialize()
    ChildTransport-->>-Parent: "Transport initialized" (stderr)

    Note over Parent,ChildClient: 🏓 Readiness Check (Internal)
    Parent->>ParentClient: request("ping")
    ParentClient->>ChildProcess: {"jsonrpc":"2.0","method":"ping","id":1}
    ChildProcess->>ChildTransport: stdin data
    ChildTransport->>ChildServer: processMessage(ping request)
    ChildServer->>ChildTransport: "pong" result
    ChildTransport->>ChildProcess: {"jsonrpc":"2.0","result":"pong","id":1}
    ChildProcess->>ParentClient: stdout response
    ParentClient->>Parent: resolve("pong")
    
    Note over Parent,ChildClient: ✅ Child Ready, Main Flow Begins

    Note over Parent,ChildClient: 🔄 Bidirectional RPC Demo
    Parent->>ParentClient: request("callParent")
    ParentClient->>ChildProcess: {"jsonrpc":"2.0","method":"callParent","id":2}
    
    Note over ChildProcess,ChildClient: Child receives request
    ChildProcess->>ChildTransport: stdin data
    ChildTransport->>ChildServer: processMessage(callParent request)
    
    Note over ChildServer,ChildClient: Child calls back to parent!
    ChildServer->>ChildClient: request("getTime")
    ChildClient->>ChildProcess: {"jsonrpc":"2.0","method":"getTime","id":1}
    ChildProcess->>ParentServer: stdout → parent stdin
    
    Note over Parent,ParentServer: Parent receives child's request
    Parent->>ParentServer: processMessage(getTime request)
    ParentServer->>ParentServer: execute getTime()<br/>📅 Log: "Child requested current time"
    ParentServer->>Parent: {"result": "2025-07-16T14:59:24.976Z"}
    Parent->>ChildProcess: {"jsonrpc":"2.0","result":{"result":"..."},"id":1}
    
    Note over ChildProcess,ChildClient: Child receives parent's response
    ChildProcess->>ChildTransport: stdin data
    ChildTransport->>ChildClient: handleIncomingMessage(getTime response)
    ChildClient->>ChildServer: resolve with parent's result
    
    Note over ChildServer,ChildClient: Child completes callParent method
    ChildServer->>ChildTransport: return formatted result
    ChildTransport->>ChildProcess: {"jsonrpc":"2.0","result":{"result":"Parent getTime returned: ..."},"id":2}
    ChildProcess->>ParentClient: stdout → parent stdout
    
    Note over Parent,ParentClient: Parent receives final result
    Parent->>ParentClient: handleIncomingMessage(callParent response)
    ParentClient->>Parent: resolve with final result
    Parent->>Parent: 🔄 Log: "Child callback result: ..."

    Note over Parent,ChildClient: 🎉 Bidirectional RPC Complete!
    Note right of Parent: Parent successfully called child method<br/>which called back to parent method<br/>and returned the combined result
```