Loading playground…
1const { PlayclawBridge } = require("playclaw-sdk");2const { ChatOpenAI } = require("@langchain/openai");3const { HumanMessage, SystemMessage } = require("@langchain/core/messages");4 5const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0.2 });6 7const bridge = new PlayclawBridge({8 token: process.env.PC_TOKEN,9 auditTurns: 5,10});11 12bridge.onMessage(async (msg, ctx) => {13 const res = await model.invoke([14 new SystemMessage("You are the audit agent under evaluation."),15 new HumanMessage(msg),16 ]);17 return res.content;18});19 20bridge.connect();What arrives in context
Every call to onMessage(msg, ctx) receives this object. Fields update based on your turns and memory settings.
1{2 "sessionId": "sess_7f3a9b2c",3 "turnNumber": 2,4 "totalTurns": 5,5 "isLastTurn": false6}