@clawzone/clawzone 1.4.5 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +27 -22
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -38,12 +38,22 @@ export default {
38
38
  api.registerTool({
39
39
  name: "clawzone_games",
40
40
  description:
41
- "List all available games on ClawZone with their rules, settings, and agent_instructions. Read agent_instructions to understand valid moves before playing.",
41
+ "List available games on ClawZone with rules and agent_instructions. Call once per session.",
42
42
  parameters: { type: "object", properties: {} },
43
43
  execute: async () => {
44
44
  const res = await fetch(`${config.serverUrl}/api/v1/games`);
45
45
  const data = await res.json();
46
- return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
46
+ // Filter to essential fields to reduce context size
47
+ const games = Array.isArray(data) ? data : (data.games ?? data);
48
+ const filtered = (Array.isArray(games) ? games : []).map((g: Record<string, unknown>) => ({
49
+ id: g.id,
50
+ name: g.name,
51
+ description: g.description,
52
+ agent_instructions: g.agent_instructions,
53
+ min_players: g.min_players,
54
+ max_players: g.max_players,
55
+ }));
56
+ return { content: [{ type: "text", text: JSON.stringify(filtered) }] };
47
57
  },
48
58
  });
49
59
 
@@ -51,7 +61,7 @@ export default {
51
61
  api.registerTool({
52
62
  name: "clawzone_play",
53
63
  description:
54
- "Join the matchmaking queue for a game and wait for an opponent (up to 120s). After matching, call clawzone_status for your first turn, then clawzone_action to play. YOU are the AI player — make your own strategic decisions, do NOT ask the user which move to make.",
64
+ "Join the matchmaking queue and wait for an opponent (up to 120s). After matching, call clawzone_status then clawzone_action to play.",
55
65
  parameters: {
56
66
  type: "object",
57
67
  required: ["game_id"],
@@ -77,7 +87,7 @@ export default {
77
87
 
78
88
  if (!joinRes.ok) {
79
89
  const errText = await joinRes.text();
80
- return { content: [{ type: "text", text: JSON.stringify({ error: errText }) }] };
90
+ return { content: [{ type: "text", text: `{"error":${JSON.stringify(errText)}}` }] };
81
91
  }
82
92
 
83
93
  // Wait for match_created event from WebSocket
@@ -87,7 +97,7 @@ export default {
87
97
  );
88
98
  if (!match) {
89
99
  return {
90
- content: [{ type: "text", text: JSON.stringify({ error: "Matchmaking timed out after 120 seconds" }) }],
100
+ content: [{ type: "text", text: '{"error":"Matchmaking timed out after 120 seconds"}' }],
91
101
  };
92
102
  }
93
103
 
@@ -98,9 +108,7 @@ export default {
98
108
  status: "matched",
99
109
  match_id: match.matchId,
100
110
  players: match.players,
101
- message:
102
- "Match started! Call clawzone_status to see your turn, then clawzone_action to play. YOU choose the moves — play to win, do not ask the user.",
103
- }, null, 2),
111
+ }),
104
112
  }],
105
113
  };
106
114
  },
@@ -166,7 +174,7 @@ export default {
166
174
  };
167
175
  }
168
176
 
169
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
177
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
170
178
  },
171
179
  });
172
180
 
@@ -174,7 +182,7 @@ export default {
174
182
  api.registerTool({
175
183
  name: "clawzone_action",
176
184
  description:
177
- "Submit your action for the current turn. Analyze available_actions and choose the best move yourself — do NOT ask the user. Waits up to 60s for opponent. Returns: your_turn (next round), finished (match over), cancelled, or waiting_for_opponent (opponent slow — set up a cron to poll clawzone_status every 15s, then go idle).",
185
+ "Submit your action for the current turn. Waits up to 60s for opponent. Returns: your_turn, finished, cancelled, or waiting_for_opponent.",
178
186
  parameters: {
179
187
  type: "object",
180
188
  required: ["type", "payload"],
@@ -258,7 +266,7 @@ export default {
258
266
  turn: currentMatch.turn,
259
267
  state: currentMatch.agentView,
260
268
  available_actions: currentMatch.availableActions,
261
- }, null, 2),
269
+ }),
262
270
  }],
263
271
  };
264
272
  }
@@ -270,7 +278,7 @@ export default {
270
278
  status: "cancelled",
271
279
  match_id: matchId,
272
280
  reason: currentMatch.cancelReason,
273
- }, null, 2),
281
+ }),
274
282
  }],
275
283
  };
276
284
  }
@@ -284,7 +292,7 @@ export default {
284
292
  result: currentMatch.result,
285
293
  your_result: currentMatch.yourResult,
286
294
  spectator_view: currentMatch.spectatorView,
287
- }, null, 2),
295
+ }),
288
296
  }],
289
297
  };
290
298
  }
@@ -307,7 +315,7 @@ export default {
307
315
  turn: resolution.turn,
308
316
  state: resolution.state,
309
317
  available_actions: resolution.available_actions,
310
- }, null, 2),
318
+ }),
311
319
  }],
312
320
  };
313
321
  }
@@ -322,7 +330,7 @@ export default {
322
330
  result: resolution.result,
323
331
  your_result: resolution.your_result,
324
332
  spectator_view: resolution.spectator_view,
325
- }, null, 2),
333
+ }),
326
334
  }],
327
335
  };
328
336
  }
@@ -335,23 +343,20 @@ export default {
335
343
  status: "cancelled",
336
344
  match_id: resolution.match_id,
337
345
  reason: resolution.reason,
338
- }, null, 2),
346
+ }),
339
347
  }],
340
348
  };
341
349
  }
342
350
 
343
351
  // Opponent didn't respond within 60s — instruct agent to set up cron polling.
344
- // Background WS keeps accumulating state, so clawzone_status will be fresh.
345
352
  return {
346
353
  content: [{
347
354
  type: "text",
348
355
  text: JSON.stringify({
349
356
  status: "waiting_for_opponent",
350
357
  match_id: matchId,
351
- action_submitted: { type: params.type, payload: params.payload },
352
- message: "Action sent but opponent hasn't played within 60s. Set up a cron to poll clawzone_status every 15s and go idle. The background WebSocket connection is still listening — clawzone_status will reflect the latest state instantly when the opponent plays.",
353
- cron_hint: `openclaw cron add --name "clawzone-turn-${matchId}" --every "15s" --session main --wake now --system-event "CLAWZONE_TURN_POLL match_id=${matchId} — Call clawzone_status. If your_turn: delete this cron, call clawzone_action. If finished: delete cron, report result. If waiting: go idle."`,
354
- }, null, 2),
358
+ cron_hint: `openclaw cron add --name "clawzone-turn-${matchId}" --every "15s" --session main --wake now --system-event "CLAWZONE_TURN_POLL match_id=${matchId}"`,
359
+ }),
355
360
  }],
356
361
  };
357
362
  },
@@ -385,7 +390,7 @@ export default {
385
390
  const result = res.ok
386
391
  ? { status: "left_queue" }
387
392
  : { error: await res.text() };
388
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
393
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
389
394
  },
390
395
  });
391
396
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawzone/clawzone",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "OpenClaw plugin for ClawZone — real-time competitive AI gaming via WebSocket",
5
5
  "main": "index.ts",
6
6
  "openclaw": {