@kodama-run/sdk 0.2.1 → 0.3.1
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 +2973 -3
- package/bin/mcp.js +3121 -5
- package/package.json +1 -1
- package/src/adapters/mcp.ts +2 -2
- package/src/room.ts +9 -3
package/package.json
CHANGED
package/src/adapters/mcp.ts
CHANGED
|
@@ -44,8 +44,8 @@ let sayResolve: ((response: { content: string; done?: boolean }) => void) | null
|
|
|
44
44
|
/** Whisper guidance from the user. */
|
|
45
45
|
const whispers: string[] = [];
|
|
46
46
|
|
|
47
|
-
const DEFAULT_RELAY = process.env.KODAMA_RELAY ?? "
|
|
48
|
-
const WEB_URL = process.env.KODAMA_WEB ?? "
|
|
47
|
+
const DEFAULT_RELAY = process.env.KODAMA_RELAY ?? "https://kodamarelay-production.up.railway.app";
|
|
48
|
+
const WEB_URL = process.env.KODAMA_WEB ?? "https://kodama.run";
|
|
49
49
|
const LISTEN_TIMEOUT_MS = 5_000;
|
|
50
50
|
|
|
51
51
|
// ---------------------------------------------------------------------------
|
package/src/room.ts
CHANGED
|
@@ -9,6 +9,12 @@ import { createAgentCard } from "@kodama-run/shared";
|
|
|
9
9
|
import { KodamaCrypto } from "./crypto.ts";
|
|
10
10
|
import { PermissionChecker } from "./permissions.ts";
|
|
11
11
|
|
|
12
|
+
// Use ws package for Node <22 compatibility, native WebSocket otherwise
|
|
13
|
+
// @ts-ignore - dynamic require for Node compat
|
|
14
|
+
const WS: typeof WebSocket = typeof globalThis.WebSocket !== "undefined"
|
|
15
|
+
? globalThis.WebSocket
|
|
16
|
+
: (() => { try { return require("ws"); } catch { return null; } })();
|
|
17
|
+
|
|
12
18
|
// ---------------------------------------------------------------------------
|
|
13
19
|
// Types
|
|
14
20
|
// ---------------------------------------------------------------------------
|
|
@@ -139,7 +145,7 @@ export class Kodama {
|
|
|
139
145
|
*/
|
|
140
146
|
leave(): void {
|
|
141
147
|
this.closed = true;
|
|
142
|
-
if (this.ws && this.ws.readyState ===
|
|
148
|
+
if (this.ws && this.ws.readyState === WS.OPEN) {
|
|
143
149
|
this.ws.send(JSON.stringify({ action: "leave" }));
|
|
144
150
|
this.ws.close();
|
|
145
151
|
}
|
|
@@ -172,7 +178,7 @@ export class Kodama {
|
|
|
172
178
|
// -----------------------------------------------------------------------
|
|
173
179
|
|
|
174
180
|
private connect(): void {
|
|
175
|
-
const ws = new
|
|
181
|
+
const ws = new WS(this.relayUrl) as unknown as WebSocket;
|
|
176
182
|
this.ws = ws;
|
|
177
183
|
|
|
178
184
|
ws.addEventListener("open", () => {
|
|
@@ -343,7 +349,7 @@ export class Kodama {
|
|
|
343
349
|
// Filter response through permissions
|
|
344
350
|
const filtered = this.permissions.filterMessage(content);
|
|
345
351
|
|
|
346
|
-
if (this.ws && this.ws.readyState ===
|
|
352
|
+
if (this.ws && this.ws.readyState === WS.OPEN) {
|
|
347
353
|
this.ws.send(
|
|
348
354
|
JSON.stringify({
|
|
349
355
|
action: "message",
|