@gui-chat-plugin/go 0.1.1 → 0.2.0

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/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index.cjs");exports.SYSTEM_PROMPT=e.SYSTEM_PROMPT;exports.TOOL_DEFINITION=e.TOOL_DEFINITION;exports.TOOL_NAME=e.TOOL_NAME;exports.executeGo=e.executeGo;exports.playGo=e.playGo;exports.pluginCore=e.pluginCore;exports.samples=e.samples;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./samples--VS-ghv5.cjs`);exports.SYSTEM_PROMPT=e.a,exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.executeGo=e.n,exports.playGo=e.i,exports.pluginCore=e.r,exports.samples=e.t;
package/dist/core.js CHANGED
@@ -1,10 +1,2 @@
1
- import { SYSTEM_PROMPT as o, TOOL_DEFINITION as T, TOOL_NAME as p, executeGo as l, playGo as r, pluginCore as E, samples as I } from "./index.js";
2
- export {
3
- o as SYSTEM_PROMPT,
4
- T as TOOL_DEFINITION,
5
- p as TOOL_NAME,
6
- l as executeGo,
7
- r as playGo,
8
- E as pluginCore,
9
- I as samples
10
- };
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./samples-CUD_StDT.js";
2
+ export { e as SYSTEM_PROMPT, r as TOOL_DEFINITION, a as TOOL_NAME, n as executeGo, t as playGo, i as pluginCore, o as samples };
package/dist/index.cjs CHANGED
@@ -1,6 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P="playGo",A={type:"function",name:P,description:"Play the game of Go (Baduk/Weiqi) with the user on a 9x9 board. You can start a new game, make moves, or pass turns. The game ends after two consecutive passes.",parameters:{type:"object",properties:{action:{type:"string",enum:["new_game","move","pass"],description:"The action to perform: start a new game, make a move, or pass the turn"},col:{type:"number",description:"Column position for the move (0-8, required for 'move' action). The user will tell you the column by specifying A to J (skipping I)",minimum:0,maximum:8},row:{type:"number",description:"Row position for the move (0-8, required for 'move' action). The user will tell you the row by specifying 1 to 9",minimum:0,maximum:8},board:{type:"array",description:"Current 9x9 board state (required for 'move' and 'pass' actions)",items:{type:"array",items:{type:"string",enum:[".","B","W"]}}},currentSide:{type:"string",enum:["B","W"],description:"Current player's side (required for 'move' and 'pass' actions)"},playerNames:{type:"object",description:"Player assignments (required for 'move' and 'pass' actions)",properties:{B:{type:"string",enum:["user","computer"]},W:{type:"string",enum:["user","computer"]}},required:["B","W"]},capturedStones:{type:"object",description:"Count of captured stones for each player (required for 'move' and 'pass' actions)",properties:{B:{type:"number",description:"Number of stones captured by Black"},W:{type:"number",description:"Number of stones captured by White"}},required:["B","W"]},consecutivePasses:{type:"number",description:"Number of consecutive passes (required for 'pass' action, 0-2)",minimum:0,maximum:2},firstPlayer:{type:"string",enum:["user","computer"],description:"Optional: Which player should play as Black (goes first) for 'new_game' action. If not specified, will be chosen randomly."}},required:["action"],additionalProperties:!1}},N=`You can play Go (Baduk/Weiqi) with users on a 9x9 board. When a user wants to play:
2
- 1. Start a new game with the "new_game" action
3
- 2. For moves, the user specifies column (A-J, skipping I) and row (1-9)
4
- 3. Use the "move" action with the current board state
5
- 4. The game ends after two consecutive passes`,l=9,v=[[-1,0],[1,0],[0,-1],[0,1]];function x(){const n=[];for(let e=0;e<l;e++)n[e]=new Array(l).fill(".");return n}function b(n){return n.map(e=>[...e])}function g(n,e){return n>=0&&n<l&&e>=0&&e<l}function w(n){return n==="B"?"W":"B"}function W(n,e,r,t){const o=n[e][r];if(o===".")return[];const s=[],a=[{row:e,col:r}];for(;a.length>0;){const i=a.pop(),c=i.row,u=i.col;if(!(!g(c,u)||t[c][u]||n[c][u]!==o)){t[c][u]=!0,s.push({row:c,col:u});for(const[m,p]of v)a.push({row:c+m,col:u+p})}}return s}function k(n,e){for(const{row:r,col:t}of e)for(const[o,s]of v){const a=r+o,i=t+s;if(g(a,i)&&n[a][i]===".")return!0}return!1}function C(n,e){const r=b(n),t=Array(l).fill(null).map(()=>Array(l).fill(!1));let o=0;for(let s=0;s<l;s++)for(let a=0;a<l;a++)if(r[s][a]===e&&!t[s][a]){const i=W(r,s,a,t);if(!k(r,i))for(const{row:c,col:u}of i)r[c][u]=".",o++}return{board:r,capturedCount:o}}function M(n,e,r,t){if(n[e][r]!==".")return!1;const o=b(n);o[e][r]=t;const s=w(t),{board:a}=C(o,s),i=Array(l).fill(null).map(()=>Array(l).fill(!1)),c=W(a,e,r,i);return k(a,c)}function $(n,e,r,t){const o=b(n);o[e][r]=t;const s=w(t),{board:a,capturedCount:i}=C(o,s);return{newBoard:a,capturedCount:i}}function y(n){let e=0,r=0,t=0;for(let o=0;o<l;o++)for(let s=0;s<l;s++){const a=n[o][s];a==="B"?e++:a==="W"?r++:t++}return{B:e,W:r,empty:t}}function D(n){const e=Array(l).fill(null).map(()=>Array(l).fill(!1));let r=0,t=0;for(let o=0;o<l;o++)for(let s=0;s<l;s++)if(n[o][s]==="."&&!e[o][s]){const a=[],i=[{row:o,col:s}],c=new Set;for(;i.length>0;){const u=i.pop(),m=u.row,p=u.col;if(!(!g(m,p)||e[m][p]))if(n[m][p]==="."){e[m][p]=!0,a.push({row:m,col:p});for(const[d,f]of v)i.push({row:m+d,col:p+f})}else c.add(n[m][p])}if(c.size===1){const u=Array.from(c)[0];u==="B"?r+=a.length:u==="W"&&(t+=a.length)}}return{B:r,W:t}}function R(n,e){const r=y(n),t=D(n),o=r.B+t.B+e.W,s=r.W+t.W+e.B;return o>s?"B":s>o?"W":"draw"}function I(n){if(n.action==="new_game"){const{playerNames:d}=n,f=x(),h=y(f);return{board:f,currentSide:"B",playerNames:d,capturedStones:{B:0,W:0},counts:h,isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:"new_game"}}}if(n.action==="pass"){const{board:d,currentSide:f,playerNames:h,capturedStones:S,consecutivePasses:G}=n,O=w(f),q=y(d),B=G+1,T=B>=2,E=T?R(d,S):null;return{board:d,currentSide:O,playerNames:h,capturedStones:S,counts:q,isTerminal:T,winner:E,consecutivePasses:B,lastAction:{type:"pass"}}}const{row:e,col:r,board:t,currentSide:o,playerNames:s,capturedStones:a}=n;if(!M(t,e,r,o)){const d=y(t);return{board:t,currentSide:o,playerNames:s,capturedStones:a,counts:d,isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:"pass"},error:`Invalid move: (${e}, ${r}) is not a legal move for ${o}. The position must be empty and the move must not be suicide.`}}const{newBoard:i,capturedCount:c}=$(t,e,r,o),u=w(o),m=y(i),p={...a};return c>0&&(p[o]+=c),{board:i,currentSide:u,playerNames:s,capturedStones:p,counts:m,isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:"move",row:e,col:r,captured:c}}}const _=async(n,e)=>{try{let r;if(e.action==="new_game"){let i;e.firstPlayer?i=e.firstPlayer:i=Math.random()<.5?"computer":"user",r={action:"new_game",playerNames:{B:i,W:i==="user"?"computer":"user"}}}else if(e.action==="move"){if(typeof e.row!="number"||typeof e.col!="number"||!e.board||!e.currentSide||!e.playerNames||!e.capturedStones)throw new Error("Move action requires row, col, board, currentSide, playerNames, and capturedStones parameters");r={action:"move",row:e.row,col:e.col,board:e.board,currentSide:e.currentSide,playerNames:e.playerNames,capturedStones:e.capturedStones}}else if(e.action==="pass"){if(!e.board||!e.currentSide||!e.playerNames||!e.capturedStones||typeof e.consecutivePasses!="number")throw new Error("Pass action requires board, currentSide, playerNames, capturedStones, and consecutivePasses parameters");r={action:"pass",board:e.board,currentSide:e.currentSide,playerNames:e.playerNames,capturedStones:e.capturedStones,consecutivePasses:e.consecutivePasses}}else throw new Error(`Unknown action: ${e.action}`);const t=I(r);if(t.error){const c=t.playerNames[t.currentSide]==="computer"?"Invalid move attempted. You must make a valid move. Choose an empty intersection where placing a stone would not result in immediate capture (suicide rule).":"Invalid move attempted. Tell the user they must make a valid move. The position must be empty and the move must not be suicide. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).";return{message:t.error,jsonData:t,instructions:c,updating:!0}}let o="";if(t.lastAction.type==="new_game")o="Started a new Go game on a 9x9 board! Black (●) goes first.";else if(t.lastAction.type==="move"){const i=t.lastAction.captured>0?` and captured ${t.lastAction.captured} stone${t.lastAction.captured>1?"s":""}`:"";o=`Played at (${t.lastAction.row}, ${t.lastAction.col})${i}.`}else t.lastAction.type==="pass"&&(o="Passed the turn.",t.consecutivePasses===1&&(o+=" One more pass will end the game."));t.isTerminal&&(t.winner==="draw"?o+=" Game over - it's a draw!":t.winner&&(o+=` Game over - ${t.winner==="B"?"Black":"White"} wins!`));const s=t.playerNames[t.currentSide]==="computer",a=t.isTerminal?"The game is over. Announce the game result with final scores.":s?"The game state has been updated. It is your turn (you = AI assistant, computer). Make your move or pass.":"The game state has been updated. Tell the user to make a move or pass. Do not describe the state of the game. The user is able to see it. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).";return{message:o,jsonData:t,instructions:a,instructionsRequired:t.isTerminal||s,updating:e.action!=="new_game"}}catch(r){return console.error(`ERR: exception
6
- Go game error`,r),{message:`Go game error: ${r instanceof Error?r.message:"Unknown error"}`,instructions:"Acknowledge that there was an error with the Go game and suggest trying again."}}},j={toolDefinition:A,execute:_,generatingMessage:"Processing Go move...",isEnabled:()=>!0,systemPrompt:N},L=[{name:"New Game (User First)",args:{action:"new_game",firstPlayer:"user"}},{name:"New Game (Computer First)",args:{action:"new_game",firstPlayer:"computer"}}];exports.SYSTEM_PROMPT=N;exports.TOOL_DEFINITION=A;exports.TOOL_NAME=P;exports.executeGo=_;exports.playGo=I;exports.pluginCore=j;exports.samples=L;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./samples--VS-ghv5.cjs`);exports.SYSTEM_PROMPT=e.a,exports.TOOL_DEFINITION=e.o,exports.TOOL_NAME=e.s,exports.executeGo=e.n,exports.playGo=e.i,exports.pluginCore=e.r,exports.samples=e.t;
package/dist/index.js CHANGED
@@ -1,374 +1,2 @@
1
- const G = "playGo", _ = {
2
- type: "function",
3
- name: G,
4
- description: "Play the game of Go (Baduk/Weiqi) with the user on a 9x9 board. You can start a new game, make moves, or pass turns. The game ends after two consecutive passes.",
5
- parameters: {
6
- type: "object",
7
- properties: {
8
- action: {
9
- type: "string",
10
- enum: ["new_game", "move", "pass"],
11
- description: "The action to perform: start a new game, make a move, or pass the turn"
12
- },
13
- col: {
14
- type: "number",
15
- description: "Column position for the move (0-8, required for 'move' action). The user will tell you the column by specifying A to J (skipping I)",
16
- minimum: 0,
17
- maximum: 8
18
- },
19
- row: {
20
- type: "number",
21
- description: "Row position for the move (0-8, required for 'move' action). The user will tell you the row by specifying 1 to 9",
22
- minimum: 0,
23
- maximum: 8
24
- },
25
- board: {
26
- type: "array",
27
- description: "Current 9x9 board state (required for 'move' and 'pass' actions)",
28
- items: {
29
- type: "array",
30
- items: {
31
- type: "string",
32
- enum: [".", "B", "W"]
33
- }
34
- }
35
- },
36
- currentSide: {
37
- type: "string",
38
- enum: ["B", "W"],
39
- description: "Current player's side (required for 'move' and 'pass' actions)"
40
- },
41
- playerNames: {
42
- type: "object",
43
- description: "Player assignments (required for 'move' and 'pass' actions)",
44
- properties: {
45
- B: {
46
- type: "string",
47
- enum: ["user", "computer"]
48
- },
49
- W: {
50
- type: "string",
51
- enum: ["user", "computer"]
52
- }
53
- },
54
- required: ["B", "W"]
55
- },
56
- capturedStones: {
57
- type: "object",
58
- description: "Count of captured stones for each player (required for 'move' and 'pass' actions)",
59
- properties: {
60
- B: {
61
- type: "number",
62
- description: "Number of stones captured by Black"
63
- },
64
- W: {
65
- type: "number",
66
- description: "Number of stones captured by White"
67
- }
68
- },
69
- required: ["B", "W"]
70
- },
71
- consecutivePasses: {
72
- type: "number",
73
- description: "Number of consecutive passes (required for 'pass' action, 0-2)",
74
- minimum: 0,
75
- maximum: 2
76
- },
77
- firstPlayer: {
78
- type: "string",
79
- enum: ["user", "computer"],
80
- description: "Optional: Which player should play as Black (goes first) for 'new_game' action. If not specified, will be chosen randomly."
81
- }
82
- },
83
- required: ["action"],
84
- additionalProperties: !1
85
- }
86
- }, q = `You can play Go (Baduk/Weiqi) with users on a 9x9 board. When a user wants to play:
87
- 1. Start a new game with the "new_game" action
88
- 2. For moves, the user specifies column (A-J, skipping I) and row (1-9)
89
- 3. Use the "move" action with the current board state
90
- 4. The game ends after two consecutive passes`, l = 9, v = [
91
- [-1, 0],
92
- // up
93
- [1, 0],
94
- // down
95
- [0, -1],
96
- // left
97
- [0, 1]
98
- // right
99
- ];
100
- function x() {
101
- const n = [];
102
- for (let e = 0; e < l; e++)
103
- n[e] = new Array(l).fill(".");
104
- return n;
105
- }
106
- function b(n) {
107
- return n.map((e) => [...e]);
108
- }
109
- function g(n, e) {
110
- return n >= 0 && n < l && e >= 0 && e < l;
111
- }
112
- function w(n) {
113
- return n === "B" ? "W" : "B";
114
- }
115
- function A(n, e, r, t) {
116
- const o = n[e][r];
117
- if (o === ".") return [];
118
- const s = [], a = [{ row: e, col: r }];
119
- for (; a.length > 0; ) {
120
- const i = a.pop(), c = i.row, u = i.col;
121
- if (!(!g(c, u) || t[c][u] || n[c][u] !== o)) {
122
- t[c][u] = !0, s.push({ row: c, col: u });
123
- for (const [m, p] of v)
124
- a.push({ row: c + m, col: u + p });
125
- }
126
- }
127
- return s;
128
- }
129
- function P(n, e) {
130
- for (const { row: r, col: t } of e)
131
- for (const [o, s] of v) {
132
- const a = r + o, i = t + s;
133
- if (g(a, i) && n[a][i] === ".")
134
- return !0;
135
- }
136
- return !1;
137
- }
138
- function N(n, e) {
139
- const r = b(n), t = Array(l).fill(null).map(() => Array(l).fill(!1));
140
- let o = 0;
141
- for (let s = 0; s < l; s++)
142
- for (let a = 0; a < l; a++)
143
- if (r[s][a] === e && !t[s][a]) {
144
- const i = A(r, s, a, t);
145
- if (!P(r, i))
146
- for (const { row: c, col: u } of i)
147
- r[c][u] = ".", o++;
148
- }
149
- return { board: r, capturedCount: o };
150
- }
151
- function E(n, e, r, t) {
152
- if (n[e][r] !== ".")
153
- return !1;
154
- const o = b(n);
155
- o[e][r] = t;
156
- const s = w(t), { board: a } = N(
157
- o,
158
- s
159
- ), i = Array(l).fill(null).map(() => Array(l).fill(!1)), c = A(a, e, r, i);
160
- return P(a, c);
161
- }
162
- function O(n, e, r, t) {
163
- const o = b(n);
164
- o[e][r] = t;
165
- const s = w(t), { board: a, capturedCount: i } = N(
166
- o,
167
- s
168
- );
169
- return { newBoard: a, capturedCount: i };
170
- }
171
- function y(n) {
172
- let e = 0, r = 0, t = 0;
173
- for (let o = 0; o < l; o++)
174
- for (let s = 0; s < l; s++) {
175
- const a = n[o][s];
176
- a === "B" ? e++ : a === "W" ? r++ : t++;
177
- }
178
- return { B: e, W: r, empty: t };
179
- }
180
- function $(n) {
181
- const e = Array(l).fill(null).map(() => Array(l).fill(!1));
182
- let r = 0, t = 0;
183
- for (let o = 0; o < l; o++)
184
- for (let s = 0; s < l; s++)
185
- if (n[o][s] === "." && !e[o][s]) {
186
- const a = [], i = [{ row: o, col: s }], c = /* @__PURE__ */ new Set();
187
- for (; i.length > 0; ) {
188
- const u = i.pop(), m = u.row, p = u.col;
189
- if (!(!g(m, p) || e[m][p]))
190
- if (n[m][p] === ".") {
191
- e[m][p] = !0, a.push({ row: m, col: p });
192
- for (const [d, f] of v)
193
- i.push({ row: m + d, col: p + f });
194
- } else
195
- c.add(n[m][p]);
196
- }
197
- if (c.size === 1) {
198
- const u = Array.from(c)[0];
199
- u === "B" ? r += a.length : u === "W" && (t += a.length);
200
- }
201
- }
202
- return { B: r, W: t };
203
- }
204
- function M(n, e) {
205
- const r = y(n), t = $(n), o = r.B + t.B + e.W, s = r.W + t.W + e.B;
206
- return o > s ? "B" : s > o ? "W" : "draw";
207
- }
208
- function D(n) {
209
- if (n.action === "new_game") {
210
- const { playerNames: d } = n, f = x(), h = y(f);
211
- return {
212
- board: f,
213
- currentSide: "B",
214
- playerNames: d,
215
- capturedStones: { B: 0, W: 0 },
216
- counts: h,
217
- isTerminal: !1,
218
- winner: null,
219
- consecutivePasses: 0,
220
- lastAction: { type: "new_game" }
221
- };
222
- }
223
- if (n.action === "pass") {
224
- const {
225
- board: d,
226
- currentSide: f,
227
- playerNames: h,
228
- capturedStones: S,
229
- consecutivePasses: W
230
- } = n, k = w(f), C = y(d), B = W + 1, T = B >= 2, I = T ? M(d, S) : null;
231
- return {
232
- board: d,
233
- currentSide: k,
234
- playerNames: h,
235
- capturedStones: S,
236
- counts: C,
237
- isTerminal: T,
238
- winner: I,
239
- consecutivePasses: B,
240
- lastAction: { type: "pass" }
241
- };
242
- }
243
- const { row: e, col: r, board: t, currentSide: o, playerNames: s, capturedStones: a } = n;
244
- if (!E(t, e, r, o)) {
245
- const d = y(t);
246
- return {
247
- board: t,
248
- currentSide: o,
249
- playerNames: s,
250
- capturedStones: a,
251
- counts: d,
252
- isTerminal: !1,
253
- winner: null,
254
- consecutivePasses: 0,
255
- lastAction: { type: "pass" },
256
- error: `Invalid move: (${e}, ${r}) is not a legal move for ${o}. The position must be empty and the move must not be suicide.`
257
- };
258
- }
259
- const { newBoard: i, capturedCount: c } = O(t, e, r, o), u = w(o), m = y(i), p = { ...a };
260
- return c > 0 && (p[o] += c), {
261
- board: i,
262
- currentSide: u,
263
- playerNames: s,
264
- capturedStones: p,
265
- counts: m,
266
- isTerminal: !1,
267
- winner: null,
268
- consecutivePasses: 0,
269
- // Reset on actual move
270
- lastAction: { type: "move", row: e, col: r, captured: c }
271
- };
272
- }
273
- const R = async (n, e) => {
274
- try {
275
- let r;
276
- if (e.action === "new_game") {
277
- let i;
278
- e.firstPlayer ? i = e.firstPlayer : i = Math.random() < 0.5 ? "computer" : "user", r = {
279
- action: "new_game",
280
- playerNames: { B: i, W: i === "user" ? "computer" : "user" }
281
- };
282
- } else if (e.action === "move") {
283
- if (typeof e.row != "number" || typeof e.col != "number" || !e.board || !e.currentSide || !e.playerNames || !e.capturedStones)
284
- throw new Error(
285
- "Move action requires row, col, board, currentSide, playerNames, and capturedStones parameters"
286
- );
287
- r = {
288
- action: "move",
289
- row: e.row,
290
- col: e.col,
291
- board: e.board,
292
- currentSide: e.currentSide,
293
- playerNames: e.playerNames,
294
- capturedStones: e.capturedStones
295
- };
296
- } else if (e.action === "pass") {
297
- if (!e.board || !e.currentSide || !e.playerNames || !e.capturedStones || typeof e.consecutivePasses != "number")
298
- throw new Error(
299
- "Pass action requires board, currentSide, playerNames, capturedStones, and consecutivePasses parameters"
300
- );
301
- r = {
302
- action: "pass",
303
- board: e.board,
304
- currentSide: e.currentSide,
305
- playerNames: e.playerNames,
306
- capturedStones: e.capturedStones,
307
- consecutivePasses: e.consecutivePasses
308
- };
309
- } else
310
- throw new Error(`Unknown action: ${e.action}`);
311
- const t = D(r);
312
- if (t.error) {
313
- const c = t.playerNames[t.currentSide] === "computer" ? "Invalid move attempted. You must make a valid move. Choose an empty intersection where placing a stone would not result in immediate capture (suicide rule)." : "Invalid move attempted. Tell the user they must make a valid move. The position must be empty and the move must not be suicide. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).";
314
- return {
315
- message: t.error,
316
- jsonData: t,
317
- instructions: c,
318
- updating: !0
319
- };
320
- }
321
- let o = "";
322
- if (t.lastAction.type === "new_game")
323
- o = "Started a new Go game on a 9x9 board! Black (●) goes first.";
324
- else if (t.lastAction.type === "move") {
325
- const i = t.lastAction.captured > 0 ? ` and captured ${t.lastAction.captured} stone${t.lastAction.captured > 1 ? "s" : ""}` : "";
326
- o = `Played at (${t.lastAction.row}, ${t.lastAction.col})${i}.`;
327
- } else t.lastAction.type === "pass" && (o = "Passed the turn.", t.consecutivePasses === 1 && (o += " One more pass will end the game."));
328
- t.isTerminal && (t.winner === "draw" ? o += " Game over - it's a draw!" : t.winner && (o += ` Game over - ${t.winner === "B" ? "Black" : "White"} wins!`));
329
- const s = t.playerNames[t.currentSide] === "computer", a = t.isTerminal ? "The game is over. Announce the game result with final scores." : s ? "The game state has been updated. It is your turn (you = AI assistant, computer). Make your move or pass." : "The game state has been updated. Tell the user to make a move or pass. Do not describe the state of the game. The user is able to see it. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).";
330
- return {
331
- message: o,
332
- jsonData: t,
333
- instructions: a,
334
- instructionsRequired: t.isTerminal || s,
335
- updating: e.action !== "new_game"
336
- };
337
- } catch (r) {
338
- return console.error(`ERR: exception
339
- Go game error`, r), {
340
- message: `Go game error: ${r instanceof Error ? r.message : "Unknown error"}`,
341
- instructions: "Acknowledge that there was an error with the Go game and suggest trying again."
342
- };
343
- }
344
- }, j = {
345
- toolDefinition: _,
346
- execute: R,
347
- generatingMessage: "Processing Go move...",
348
- isEnabled: () => !0,
349
- systemPrompt: q
350
- }, F = [
351
- {
352
- name: "New Game (User First)",
353
- args: {
354
- action: "new_game",
355
- firstPlayer: "user"
356
- }
357
- },
358
- {
359
- name: "New Game (Computer First)",
360
- args: {
361
- action: "new_game",
362
- firstPlayer: "computer"
363
- }
364
- }
365
- ];
366
- export {
367
- q as SYSTEM_PROMPT,
368
- _ as TOOL_DEFINITION,
369
- G as TOOL_NAME,
370
- R as executeGo,
371
- D as playGo,
372
- j as pluginCore,
373
- F as samples
374
- };
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./samples-CUD_StDT.js";
2
+ export { e as SYSTEM_PROMPT, r as TOOL_DEFINITION, a as TOOL_NAME, n as executeGo, t as playGo, i as pluginCore, o as samples };
@@ -0,0 +1,6 @@
1
+ var e=`playGo`,t={type:`function`,name:e,description:`Play the game of Go (Baduk/Weiqi) with the user on a 9x9 board. You can start a new game, make moves, or pass turns. The game ends after two consecutive passes.`,parameters:{type:`object`,properties:{action:{type:`string`,enum:[`new_game`,`move`,`pass`],description:`The action to perform: start a new game, make a move, or pass the turn`},col:{type:`number`,description:`Column position for the move (0-8, required for 'move' action). The user will tell you the column by specifying A to J (skipping I)`,minimum:0,maximum:8},row:{type:`number`,description:`Row position for the move (0-8, required for 'move' action). The user will tell you the row by specifying 1 to 9`,minimum:0,maximum:8},board:{type:`array`,description:`Current 9x9 board state (required for 'move' and 'pass' actions)`,items:{type:`array`,items:{type:`string`,enum:[`.`,`B`,`W`]}}},currentSide:{type:`string`,enum:[`B`,`W`],description:`Current player's side (required for 'move' and 'pass' actions)`},playerNames:{type:`object`,description:`Player assignments (required for 'move' and 'pass' actions)`,properties:{B:{type:`string`,enum:[`user`,`computer`]},W:{type:`string`,enum:[`user`,`computer`]}},required:[`B`,`W`]},capturedStones:{type:`object`,description:`Count of captured stones for each player (required for 'move' and 'pass' actions)`,properties:{B:{type:`number`,description:`Number of stones captured by Black`},W:{type:`number`,description:`Number of stones captured by White`}},required:[`B`,`W`]},consecutivePasses:{type:`number`,description:`Number of consecutive passes (required for 'pass' action, 0-2)`,minimum:0,maximum:2},firstPlayer:{type:`string`,enum:[`user`,`computer`],description:`Optional: Which player should play as Black (goes first) for 'new_game' action. If not specified, will be chosen randomly.`}},required:[`action`],additionalProperties:!1}},n=`You can play Go (Baduk/Weiqi) with users on a 9x9 board. When a user wants to play:
2
+ 1. Start a new game with the "new_game" action
3
+ 2. For moves, the user specifies column (A-J, skipping I) and row (1-9)
4
+ 3. Use the "move" action with the current board state
5
+ 4. The game ends after two consecutive passes`,r=9,i=[[-1,0],[1,0],[0,-1],[0,1]];function a(){let e=[];for(let t=0;t<r;t++)e[t]=Array(r).fill(`.`);return e}function o(e){return e.map(e=>[...e])}function s(e,t){return e>=0&&e<r&&t>=0&&t<r}function c(e){return e===`B`?`W`:`B`}function l(e,t,n,r){let a=e[t][n];if(a===`.`)return[];let o=[],c=[{row:t,col:n}];for(;c.length>0;){let t=c.pop(),n=t.row,l=t.col;if(!(!s(n,l)||r[n][l]||e[n][l]!==a)){r[n][l]=!0,o.push({row:n,col:l});for(let[e,t]of i)c.push({row:n+e,col:l+t})}}return o}function u(e,t){for(let{row:n,col:r}of t)for(let[t,a]of i){let i=n+t,o=r+a;if(s(i,o)&&e[i][o]===`.`)return!0}return!1}function d(e,t){let n=o(e),i=Array(r).fill(null).map(()=>Array(r).fill(!1)),a=0;for(let e=0;e<r;e++)for(let o=0;o<r;o++)if(n[e][o]===t&&!i[e][o]){let t=l(n,e,o,i);if(!u(n,t))for(let{row:e,col:r}of t)n[e][r]=`.`,a++}return{board:n,capturedCount:a}}function f(e,t,n,i){if(e[t][n]!==`.`)return!1;let a=o(e);a[t][n]=i;let{board:s}=d(a,c(i));return u(s,l(s,t,n,Array(r).fill(null).map(()=>Array(r).fill(!1))))}function p(e,t,n,r){let i=o(e);i[t][n]=r;let{board:a,capturedCount:s}=d(i,c(r));return{newBoard:a,capturedCount:s}}function m(e){let t=0,n=0,i=0;for(let a=0;a<r;a++)for(let o=0;o<r;o++){let r=e[a][o];r===`B`?t++:r===`W`?n++:i++}return{B:t,W:n,empty:i}}function h(e){let t=Array(r).fill(null).map(()=>Array(r).fill(!1)),n=0,a=0;for(let o=0;o<r;o++)for(let c=0;c<r;c++)if(e[o][c]===`.`&&!t[o][c]){let r=[],l=[{row:o,col:c}],u=new Set;for(;l.length>0;){let n=l.pop(),a=n.row,o=n.col;if(!(!s(a,o)||t[a][o]))if(e[a][o]===`.`){t[a][o]=!0,r.push({row:a,col:o});for(let[e,t]of i)l.push({row:a+e,col:o+t})}else u.add(e[a][o])}if(u.size===1){let e=Array.from(u)[0];e===`B`?n+=r.length:e===`W`&&(a+=r.length)}}return{B:n,W:a}}function g(e,t){let n=m(e),r=h(e),i=n.B+r.B+t.W,a=n.W+r.W+t.B;return i>a?`B`:a>i?`W`:`draw`}function _(e){if(e.action===`new_game`){let{playerNames:t}=e,n=a();return{board:n,currentSide:`B`,playerNames:t,capturedStones:{B:0,W:0},counts:m(n),isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:`new_game`}}}if(e.action===`pass`){let{board:t,currentSide:n,playerNames:r,capturedStones:i,consecutivePasses:a}=e,o=c(n),s=m(t),l=a+1,u=l>=2;return{board:t,currentSide:o,playerNames:r,capturedStones:i,counts:s,isTerminal:u,winner:u?g(t,i):null,consecutivePasses:l,lastAction:{type:`pass`}}}let{row:t,col:n,board:r,currentSide:i,playerNames:o,capturedStones:s}=e;if(!f(r,t,n,i))return{board:r,currentSide:i,playerNames:o,capturedStones:s,counts:m(r),isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:`pass`},error:`Invalid move: (${t}, ${n}) is not a legal move for ${i}. The position must be empty and the move must not be suicide.`};let{newBoard:l,capturedCount:u}=p(r,t,n,i),d=c(i),h=m(l),_={...s};return u>0&&(_[i]+=u),{board:l,currentSide:d,playerNames:o,capturedStones:_,counts:h,isTerminal:!1,winner:null,consecutivePasses:0,lastAction:{type:`move`,row:t,col:n,captured:u}}}var v=async(e,t)=>{try{let e;if(t.action===`new_game`){let n;n=t.firstPlayer?t.firstPlayer:Math.random()<.5?`computer`:`user`,e={action:`new_game`,playerNames:{B:n,W:n===`user`?`computer`:`user`}}}else if(t.action===`move`){if(typeof t.row!=`number`||typeof t.col!=`number`||!t.board||!t.currentSide||!t.playerNames||!t.capturedStones)throw Error(`Move action requires row, col, board, currentSide, playerNames, and capturedStones parameters`);e={action:`move`,row:t.row,col:t.col,board:t.board,currentSide:t.currentSide,playerNames:t.playerNames,capturedStones:t.capturedStones}}else if(t.action===`pass`){if(!t.board||!t.currentSide||!t.playerNames||!t.capturedStones||typeof t.consecutivePasses!=`number`)throw Error(`Pass action requires board, currentSide, playerNames, capturedStones, and consecutivePasses parameters`);e={action:`pass`,board:t.board,currentSide:t.currentSide,playerNames:t.playerNames,capturedStones:t.capturedStones,consecutivePasses:t.consecutivePasses}}else throw Error(`Unknown action: ${t.action}`);let n=_(e);if(n.error){let e=n.playerNames[n.currentSide]===`computer`?`Invalid move attempted. You must make a valid move. Choose an empty intersection where placing a stone would not result in immediate capture (suicide rule).`:`Invalid move attempted. Tell the user they must make a valid move. The position must be empty and the move must not be suicide. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).`;return{message:n.error,jsonData:n,instructions:e,updating:!0}}let r=``;if(n.lastAction.type===`new_game`)r=`Started a new Go game on a 9x9 board! Black (●) goes first.`;else if(n.lastAction.type===`move`){let e=n.lastAction.captured>0?` and captured ${n.lastAction.captured} stone${n.lastAction.captured>1?`s`:``}`:``;r=`Played at (${n.lastAction.row}, ${n.lastAction.col})${e}.`}else n.lastAction.type===`pass`&&(r=`Passed the turn.`,n.consecutivePasses===1&&(r+=` One more pass will end the game.`));n.isTerminal&&(n.winner===`draw`?r+=` Game over - it's a draw!`:n.winner&&(r+=` Game over - ${n.winner===`B`?`Black`:`White`} wins!`));let i=n.playerNames[n.currentSide]===`computer`,a=n.isTerminal?`The game is over. Announce the game result with final scores.`:i?`The game state has been updated. It is your turn (you = AI assistant, computer). Make your move or pass.`:`The game state has been updated. Tell the user to make a move or pass. Do not describe the state of the game. The user is able to see it. The user will tell you the move by specifying column (A to J, skipping I) and row (1 to 9).`;return{message:r,jsonData:n,instructions:a,instructionsRequired:n.isTerminal||i,updating:t.action!==`new_game`}}catch(e){return console.error(`ERR: exception
6
+ Go game error`,e),{message:`Go game error: ${e instanceof Error?e.message:`Unknown error`}`,instructions:`Acknowledge that there was an error with the Go game and suggest trying again.`}}},y={toolDefinition:t,execute:v,generatingMessage:`Processing Go move...`,isEnabled:()=>!0,systemPrompt:n},b=[{name:`New Game (User First)`,args:{action:`new_game`,firstPlayer:`user`}},{name:`New Game (Computer First)`,args:{action:`new_game`,firstPlayer:`computer`}}];Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}});