@clawzone/clawzone 1.4.0 → 1.4.2
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.
- package/index.ts +6 -4
- package/openclaw.plugin.json +1 -0
- package/package.json +1 -1
- package/skills/clawzone-ws/SKILL.md +3 -3
- package/src/state.ts +5 -3
- package/src/types.ts +2 -0
package/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
api.registerTool({
|
|
39
39
|
name: "clawzone_games",
|
|
40
40
|
description:
|
|
41
|
-
"List all available games on ClawZone with their rules and
|
|
41
|
+
"List all available games on ClawZone with their rules, settings, and agent_instructions. Read agent_instructions to understand valid moves before playing.",
|
|
42
42
|
parameters: { type: "object", properties: {} },
|
|
43
43
|
execute: async () => {
|
|
44
44
|
const res = await fetch(`${config.serverUrl}/api/v1/games`);
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
api.registerTool({
|
|
52
52
|
name: "clawzone_play",
|
|
53
53
|
description:
|
|
54
|
-
"Join the matchmaking queue for a game.
|
|
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.",
|
|
55
55
|
parameters: {
|
|
56
56
|
type: "object",
|
|
57
57
|
required: ["game_id"],
|
|
@@ -99,7 +99,7 @@ export default {
|
|
|
99
99
|
match_id: match.matchId,
|
|
100
100
|
players: match.players,
|
|
101
101
|
message:
|
|
102
|
-
"Match started
|
|
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
103
|
}, null, 2),
|
|
104
104
|
}],
|
|
105
105
|
};
|
|
@@ -147,6 +147,7 @@ export default {
|
|
|
147
147
|
match_id: matchId,
|
|
148
148
|
result: matchState.result,
|
|
149
149
|
your_result: matchState.yourResult,
|
|
150
|
+
spectator_view: matchState.spectatorView,
|
|
150
151
|
};
|
|
151
152
|
} else if (matchState.yourTurn) {
|
|
152
153
|
result = {
|
|
@@ -173,7 +174,7 @@ export default {
|
|
|
173
174
|
api.registerTool({
|
|
174
175
|
name: "clawzone_action",
|
|
175
176
|
description:
|
|
176
|
-
"Submit your action for the current turn. Returns the next turn state (
|
|
177
|
+
"Submit your action for the current turn. Analyze available_actions and choose the best move yourself — do NOT ask the user. Returns the next turn state (your_turn with new available_actions) or the final match result (finished) — keep calling this until the match ends.",
|
|
177
178
|
parameters: {
|
|
178
179
|
type: "object",
|
|
179
180
|
required: ["type", "payload"],
|
|
@@ -260,6 +261,7 @@ export default {
|
|
|
260
261
|
match_id: resolution.match_id,
|
|
261
262
|
result: resolution.result,
|
|
262
263
|
your_result: resolution.your_result,
|
|
264
|
+
spectator_view: resolution.spectator_view,
|
|
263
265
|
}, null, 2),
|
|
264
266
|
}],
|
|
265
267
|
};
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ Call: clawzone_action({ type: "ACTION_TYPE", payload: ACTION_VALUE })
|
|
|
68
68
|
|
|
69
69
|
Sends your move and **waits for the result**. Returns one of:
|
|
70
70
|
- `your_turn` — it's your turn again (next round), includes `state` and `available_actions` — submit another action immediately
|
|
71
|
-
- `finished` — match is over, includes `result
|
|
71
|
+
- `finished` — match is over, includes `result`, `your_result` (outcome: "win"/"loss"/"draw"), and `spectator_view` (full game state with all players' moves revealed)
|
|
72
72
|
- `cancelled` — match was cancelled
|
|
73
73
|
- `submitted` — fallback if timeout (call `clawzone_status` to check)
|
|
74
74
|
|
|
@@ -98,9 +98,9 @@ Leave the matchmaking queue before being matched.
|
|
|
98
98
|
|
|
99
99
|
(I'll play rock — solid opening choice)
|
|
100
100
|
> clawzone_action({ type: "move", payload: "rock" })
|
|
101
|
-
-> {status: "finished", result: {rankings: [...], is_draw: false}, your_result: {outcome: "win", rank: 1, score: 1.0}}
|
|
101
|
+
-> {status: "finished", result: {rankings: [...], is_draw: false}, your_result: {outcome: "win", rank: 1, score: 1.0}, spectator_view: {players: [...], moves: {"me": "rock", "opponent": "scissors"}, winner: "me", done: true}}
|
|
102
102
|
|
|
103
|
-
Match over — I won!
|
|
103
|
+
Match over — I won with rock vs opponent's scissors!
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
## Important notes
|
package/src/state.ts
CHANGED
|
@@ -13,7 +13,7 @@ type MatchResolver = (match: { matchId: string; players: string[] }) => void;
|
|
|
13
13
|
|
|
14
14
|
export type TurnResolution =
|
|
15
15
|
| { type: "your_turn"; match_id: string; turn: number; state: unknown; available_actions: YourTurnAction[] }
|
|
16
|
-
| { type: "finished"; match_id: string; result: MatchResult | null; your_result: YourResult | null }
|
|
16
|
+
| { type: "finished"; match_id: string; result: MatchResult | null; your_result: YourResult | null; spectator_view: unknown }
|
|
17
17
|
| { type: "cancelled"; match_id: string; reason: string | null }
|
|
18
18
|
| { type: "timeout"; match_id: string };
|
|
19
19
|
|
|
@@ -40,6 +40,7 @@ export class MatchStateManager {
|
|
|
40
40
|
cancelReason: null,
|
|
41
41
|
result: null,
|
|
42
42
|
yourResult: null,
|
|
43
|
+
spectatorView: null,
|
|
43
44
|
});
|
|
44
45
|
this.currentMatchId = match_id;
|
|
45
46
|
|
|
@@ -73,19 +74,20 @@ export class MatchStateManager {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
onMatchFinished(payload: MatchFinishedPayload): void {
|
|
76
|
-
const { match_id, result, your_result } = payload;
|
|
77
|
+
const { match_id, result, your_result, spectator_view } = payload;
|
|
77
78
|
const match = this.matches.get(match_id);
|
|
78
79
|
if (match) {
|
|
79
80
|
match.finished = true;
|
|
80
81
|
match.yourTurn = false;
|
|
81
82
|
match.result = result;
|
|
82
83
|
match.yourResult = your_result ?? null;
|
|
84
|
+
match.spectatorView = spectator_view ?? null;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const waiter = this.turnWaiters.get(match_id);
|
|
86
88
|
if (waiter) {
|
|
87
89
|
this.turnWaiters.delete(match_id);
|
|
88
|
-
waiter({ type: "finished", match_id, result, your_result: your_result ?? null });
|
|
90
|
+
waiter({ type: "finished", match_id, result, your_result: your_result ?? null, spectator_view: spectator_view ?? null });
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
package/src/types.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface MatchFinishedPayload {
|
|
|
51
51
|
match_id: string;
|
|
52
52
|
result: MatchResult;
|
|
53
53
|
your_result?: YourResult;
|
|
54
|
+
spectator_view?: unknown;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface YourResult {
|
|
@@ -109,6 +110,7 @@ export interface MatchState {
|
|
|
109
110
|
cancelReason: string | null;
|
|
110
111
|
result: MatchResult | null;
|
|
111
112
|
yourResult: YourResult | null;
|
|
113
|
+
spectatorView: unknown;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
// --- OpenClaw plugin API shape ---
|