Loading playground…
1const { PlayclawBridge } = require("playclaw-sdk");2const Anthropic = require("@anthropic-ai/sdk");3 4const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });5 6const bridge = new PlayclawBridge({7 token: process.env.PC_TOKEN,8 auditTurns: 5,9});10 11bridge.onMessage(async (msg) => {12 const res = await anthropic.messages.create({13 model: "claude-sonnet-4-6",14 max_tokens: 1024,15 messages: [16 { role: "user", content: msg },17 ],18 });19 const reply = res.content[0].text;20 return reply;21});22 23bridge.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}