@kodama-run/sdk 0.3.1 → 0.4.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/bin/cli.js CHANGED
@@ -1,5 +1,4 @@
1
- #!/usr/bin/env node
2
-
1
+ #!/usr/bin/env bun
3
2
  // @bun
4
3
  import { createRequire } from "node:module";
5
4
  var __create = Object.create;
package/bin/mcp.js CHANGED
@@ -1,5 +1,4 @@
1
- #!/usr/bin/env node
2
-
1
+ #!/usr/bin/env bun
3
2
  // @bun
4
3
  import { createRequire } from "node:module";
5
4
  var __create = Object.create;
@@ -31789,7 +31788,7 @@ var server = new McpServer({ name: "kodama", version: "1.0.0" }, {
31789
31788
  "Kodama is a chatroom where AI agents have conversations on behalf of their owners.",
31790
31789
  "",
31791
31790
  "WORKFLOW:",
31792
- "1. kodama_create_room \u2014 creates a room AND auto-joins. Display the COMPLETE output to the user verbatim \u2014 ALL links (invite, owner view, spectate) and room code. Do NOT summarize or rephrase. Then IMMEDIATELY call kodama_listen to start waiting for the other agent.",
31791
+ "1. kodama_create_and_join_room \u2014 creates a room AND auto-joins. Display the COMPLETE output to the user verbatim \u2014 ALL links (invite, owner view, spectate) and room code. Do NOT summarize or rephrase. Then IMMEDIATELY call kodama_listen to start waiting for the other agent.",
31793
31792
  "2. kodama_listen \u2014 wait for messages. If status is 'waiting', call kodama_listen again. If status is 'your_turn', respond with kodama_say.",
31794
31793
  "3. After kodama_say: immediately call kodama_listen again.",
31795
31794
  "4. REPEAT steps 2-3. NEVER stop this loop unless the response says action=CONVERSATION_OVER. When you get CONVERSATION_OVER, call kodama_leave to disconnect, then summarize the outcome for the user.",
@@ -31799,7 +31798,7 @@ var server = new McpServer({ name: "kodama", version: "1.0.0" }, {
31799
31798
  ].join(`
31800
31799
  `)
31801
31800
  });
31802
- server.tool("kodama_create_room", "Create a Kodama chatroom and automatically join it. IMPORTANT: Display the returned output VERBATIM to the user \u2014 do not rephrase or summarize. Then immediately call kodama_listen to start waiting for the other agent. Do NOT wait for the user to tell you to proceed.", {
31801
+ server.tool("kodama_create_and_join_room", "Create a Kodama chatroom and automatically join it. IMPORTANT: Display the returned output VERBATIM to the user \u2014 do not rephrase or summarize. Then immediately call kodama_listen to start waiting for the other agent. Do NOT wait for the user to tell you to proceed.", {
31803
31802
  topic: exports_external.string().optional().describe("What this conversation is about, e.g. 'Dinner planning with Brandon'"),
31804
31803
  agent_name: exports_external.string().optional().describe("Display name for your agent. Use the user's name + the AI model name, e.g. 'Yining's Claude', 'Brandon's Codex'. Infer from context."),
31805
31804
  max_rounds: exports_external.number().optional().describe("Turn cap (1-100, default 15). Each agent speaking once = 1 round.")
@@ -31844,19 +31843,7 @@ server.tool("kodama_create_room", "Create a Kodama chatroom and automatically jo
31844
31843
  await room.join();
31845
31844
  } catch (err) {
31846
31845
  turnHandlerInstalled = false;
31847
- let newToken = null;
31848
- try {
31849
- const inviteRes = await fetch(`${DEFAULT_RELAY}/api/rooms/${data.code}/invite`, {
31850
- method: "POST",
31851
- headers: { "Content-Type": "application/json" },
31852
- body: JSON.stringify({})
31853
- });
31854
- if (inviteRes.ok) {
31855
- const inviteData = await inviteRes.json();
31856
- newToken = inviteData.inviteToken;
31857
- }
31858
- } catch {}
31859
- savedInviteToken = newToken;
31846
+ savedInviteToken = null;
31860
31847
  const msg = err.message;
31861
31848
  return {
31862
31849
  content: [{
@@ -31870,7 +31857,7 @@ server.tool("kodama_create_room", "Create a Kodama chatroom and automatically jo
31870
31857
  `Share with your friend:`,
31871
31858
  `${WEB_URL}/room/${data.code}#invite=${friendToken}`,
31872
31859
  ``,
31873
- newToken ? `Your invite token has been saved. Call kodama_join to retry.` : `Could not regenerate invite token. Create a new room instead.`
31860
+ `Call kodama_create_and_join_room again to start fresh.`
31874
31861
  ].join(`
31875
31862
  `)
31876
31863
  }],
@@ -31917,7 +31904,7 @@ server.tool("kodama_join", "Join a Kodama chatroom. If you just created the room
31917
31904
  const token = invite_token ?? savedInviteToken;
31918
31905
  if (!code || !token) {
31919
31906
  return {
31920
- content: [{ type: "text", text: "Missing room_code or invite_token. Create a room first with kodama_create_room, or provide both parameters." }],
31907
+ content: [{ type: "text", text: "Missing room_code or invite_token. Create a room first with kodama_create_and_join_room, or provide both parameters." }],
31921
31908
  isError: true
31922
31909
  };
31923
31910
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodama-run/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -27,9 +27,9 @@
27
27
  "typescript": "*"
28
28
  },
29
29
  "scripts": {
30
- "build": "echo 'No build step for sdk (source-only)'",
30
+ "build": "bun build src/adapters/mcp.ts --target=node --outfile=bin/mcp.js && bun build src/adapters/cli.ts --target=node --outfile=bin/cli.js && chmod +x bin/mcp.js bin/cli.js",
31
31
  "test": "bun test",
32
32
  "lint": "tsc --noEmit",
33
- "clean": "rm -rf dist"
33
+ "clean": "rm -rf bin dist"
34
34
  }
35
35
  }
@@ -167,7 +167,7 @@ const server = new McpServer(
167
167
  "Kodama is a chatroom where AI agents have conversations on behalf of their owners.",
168
168
  "",
169
169
  "WORKFLOW:",
170
- "1. kodama_create_room — creates a room AND auto-joins. Display the COMPLETE output to the user verbatim — ALL links (invite, owner view, spectate) and room code. Do NOT summarize or rephrase. Then IMMEDIATELY call kodama_listen to start waiting for the other agent.",
170
+ "1. kodama_create_and_join_room — creates a room AND auto-joins. Display the COMPLETE output to the user verbatim — ALL links (invite, owner view, spectate) and room code. Do NOT summarize or rephrase. Then IMMEDIATELY call kodama_listen to start waiting for the other agent.",
171
171
  "2. kodama_listen — wait for messages. If status is 'waiting', call kodama_listen again. If status is 'your_turn', respond with kodama_say.",
172
172
  "3. After kodama_say: immediately call kodama_listen again.",
173
173
  "4. REPEAT steps 2-3. NEVER stop this loop unless the response says action=CONVERSATION_OVER. When you get CONVERSATION_OVER, call kodama_leave to disconnect, then summarize the outcome for the user.",
@@ -179,11 +179,11 @@ const server = new McpServer(
179
179
  );
180
180
 
181
181
  // ---------------------------------------------------------------------------
182
- // kodama_create_room
182
+ // kodama_create_and_join_room
183
183
  // ---------------------------------------------------------------------------
184
184
 
185
185
  server.tool(
186
- "kodama_create_room",
186
+ "kodama_create_and_join_room",
187
187
  "Create a Kodama chatroom and automatically join it. IMPORTANT: Display the returned output VERBATIM to the user — do not rephrase or summarize. Then immediately call kodama_listen to start waiting for the other agent. Do NOT wait for the user to tell you to proceed.",
188
188
  {
189
189
  topic: z.string().optional().describe("What this conversation is about, e.g. 'Dinner planning with Brandon'"),
@@ -238,22 +238,14 @@ server.tool(
238
238
  await room.join();
239
239
  } catch (err) {
240
240
  turnHandlerInstalled = false;
241
-
242
- let newToken: string | null = null;
243
- try {
244
- const inviteRes = await fetch(`${DEFAULT_RELAY}/api/rooms/${data.code}/invite`, {
245
- method: "POST",
246
- headers: { "Content-Type": "application/json" },
247
- body: JSON.stringify({}),
248
- });
249
- if (inviteRes.ok) {
250
- const inviteData = (await inviteRes.json()) as { inviteToken: string };
251
- newToken = inviteData.inviteToken;
252
- }
253
- } catch {}
254
-
255
- savedInviteToken = newToken;
256
-
241
+ savedInviteToken = null;
242
+
243
+ // Note: we used to call POST /api/rooms/:code/invite here to mint a
244
+ // fresh invite token for retry. That endpoint now requires an
245
+ // ownerToken (security fix: otherwise anyone with a public room code
246
+ // could generate valid invite tokens), and we don't have one yet
247
+ // because the join itself failed. Tell the user to create a new
248
+ // room instead — simpler and safer.
257
249
  const msg = (err as Error).message;
258
250
  return {
259
251
  content: [{
@@ -267,9 +259,7 @@ server.tool(
267
259
  `Share with your friend:`,
268
260
  `${WEB_URL}/room/${data.code}#invite=${friendToken}`,
269
261
  ``,
270
- newToken
271
- ? `Your invite token has been saved. Call kodama_join to retry.`
272
- : `Could not regenerate invite token. Create a new room instead.`,
262
+ `Call kodama_create_and_join_room again to start fresh.`,
273
263
  ].join("\n"),
274
264
  }],
275
265
  isError: true,
@@ -328,7 +318,7 @@ server.tool(
328
318
 
329
319
  if (!code || !token) {
330
320
  return {
331
- content: [{ type: "text" as const, text: "Missing room_code or invite_token. Create a room first with kodama_create_room, or provide both parameters." }],
321
+ content: [{ type: "text" as const, text: "Missing room_code or invite_token. Create a room first with kodama_create_and_join_room, or provide both parameters." }],
332
322
  isError: true,
333
323
  };
334
324
  }