@hasna/conversations 0.0.5 → 0.0.7
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/index.js +119 -4
- package/bin/mcp.js +5 -3
- package/dashboard/dist/assets/index-C5hQqoWV.js +163 -0
- package/dashboard/dist/assets/index-Dr54QXlJ.css +1 -0
- package/dashboard/dist/index.html +13 -0
- package/dist/index.js +4 -2
- package/dist/lib/channels.test.d.ts +1 -0
- package/dist/lib/db.test.d.ts +1 -0
- package/dist/lib/identity.test.d.ts +1 -0
- package/dist/lib/messages.test.d.ts +1 -0
- package/dist/lib/poll.test.d.ts +1 -0
- package/dist/lib/sessions.test.d.ts +1 -0
- package/dist/server/serve.d.ts +9 -0
- package/dist/server/serve.test.d.ts +1 -0
- package/package.json +3 -1
package/bin/index.js
CHANGED
|
@@ -1871,16 +1871,18 @@ var require_commander = __commonJS((exports) => {
|
|
|
1871
1871
|
// src/lib/db.ts
|
|
1872
1872
|
import { Database } from "bun:sqlite";
|
|
1873
1873
|
import { mkdirSync } from "fs";
|
|
1874
|
-
import { join } from "path";
|
|
1874
|
+
import { join, dirname } from "path";
|
|
1875
1875
|
import { homedir } from "os";
|
|
1876
1876
|
function getDbPath() {
|
|
1877
|
+
if (process.env.CONVERSATIONS_DB_PATH)
|
|
1878
|
+
return process.env.CONVERSATIONS_DB_PATH;
|
|
1877
1879
|
return join(homedir(), ".conversations", "messages.db");
|
|
1878
1880
|
}
|
|
1879
1881
|
function getDb() {
|
|
1880
1882
|
if (db)
|
|
1881
1883
|
return db;
|
|
1882
1884
|
const dbPath = getDbPath();
|
|
1883
|
-
mkdirSync(
|
|
1885
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
1884
1886
|
db = new Database(dbPath, { create: true });
|
|
1885
1887
|
db.exec("PRAGMA journal_mode = WAL");
|
|
1886
1888
|
db.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -31003,7 +31005,7 @@ var init_mcp2 = __esm(() => {
|
|
|
31003
31005
|
init_channels();
|
|
31004
31006
|
server = new McpServer({
|
|
31005
31007
|
name: "conversations",
|
|
31006
|
-
version: "0.0.
|
|
31008
|
+
version: "0.0.7"
|
|
31007
31009
|
});
|
|
31008
31010
|
server.registerTool("send_message", {
|
|
31009
31011
|
title: "Send Message",
|
|
@@ -31224,6 +31226,115 @@ var init_mcp2 = __esm(() => {
|
|
|
31224
31226
|
}
|
|
31225
31227
|
});
|
|
31226
31228
|
|
|
31229
|
+
// src/server/serve.ts
|
|
31230
|
+
var exports_serve = {};
|
|
31231
|
+
__export(exports_serve, {
|
|
31232
|
+
startDashboardServer: () => startDashboardServer
|
|
31233
|
+
});
|
|
31234
|
+
import { join as join2 } from "path";
|
|
31235
|
+
import { existsSync } from "fs";
|
|
31236
|
+
function jsonResponse(data, status = 200) {
|
|
31237
|
+
return new Response(JSON.stringify(data), {
|
|
31238
|
+
status,
|
|
31239
|
+
headers: { "Content-Type": "application/json" }
|
|
31240
|
+
});
|
|
31241
|
+
}
|
|
31242
|
+
function getStatus() {
|
|
31243
|
+
const db2 = getDb();
|
|
31244
|
+
const dbPath = getDbPath();
|
|
31245
|
+
const totalMessages = db2.prepare("SELECT COUNT(*) as count FROM messages").get().count;
|
|
31246
|
+
const totalSessions = db2.prepare("SELECT COUNT(DISTINCT session_id) as count FROM messages").get().count;
|
|
31247
|
+
const totalUnread = db2.prepare("SELECT COUNT(*) as count FROM messages WHERE read_at IS NULL").get().count;
|
|
31248
|
+
const totalChannels = db2.prepare("SELECT COUNT(*) as count FROM channels").get().count;
|
|
31249
|
+
return {
|
|
31250
|
+
db_path: dbPath,
|
|
31251
|
+
total_messages: totalMessages,
|
|
31252
|
+
total_sessions: totalSessions,
|
|
31253
|
+
total_channels: totalChannels,
|
|
31254
|
+
unread_messages: totalUnread
|
|
31255
|
+
};
|
|
31256
|
+
}
|
|
31257
|
+
function startDashboardServer(port = 3456) {
|
|
31258
|
+
const dashboardDist = join2(import.meta.dir, "../../dashboard/dist");
|
|
31259
|
+
const hasDist = existsSync(dashboardDist);
|
|
31260
|
+
const server2 = Bun.serve({
|
|
31261
|
+
port,
|
|
31262
|
+
async fetch(req) {
|
|
31263
|
+
const url2 = new URL(req.url);
|
|
31264
|
+
const path = url2.pathname;
|
|
31265
|
+
if (path === "/api/status") {
|
|
31266
|
+
return jsonResponse(getStatus());
|
|
31267
|
+
}
|
|
31268
|
+
if (path === "/api/messages" && req.method === "GET") {
|
|
31269
|
+
const limit = parseInt(url2.searchParams.get("limit") || "50");
|
|
31270
|
+
const session = url2.searchParams.get("session") || undefined;
|
|
31271
|
+
const channel = url2.searchParams.get("channel") || undefined;
|
|
31272
|
+
const from = url2.searchParams.get("from") || undefined;
|
|
31273
|
+
const to = url2.searchParams.get("to") || undefined;
|
|
31274
|
+
const messages = readMessages({ session_id: session, channel, from, to, limit });
|
|
31275
|
+
return jsonResponse(messages.reverse());
|
|
31276
|
+
}
|
|
31277
|
+
if (path === "/api/messages" && req.method === "POST") {
|
|
31278
|
+
try {
|
|
31279
|
+
const text = await req.text();
|
|
31280
|
+
const body = JSON.parse(text);
|
|
31281
|
+
const msg = sendMessage({
|
|
31282
|
+
from: body.from,
|
|
31283
|
+
to: body.to,
|
|
31284
|
+
content: body.content,
|
|
31285
|
+
channel: body.channel,
|
|
31286
|
+
priority: body.priority
|
|
31287
|
+
});
|
|
31288
|
+
return jsonResponse(msg);
|
|
31289
|
+
} catch (e) {
|
|
31290
|
+
return jsonResponse({ error: e.message }, 400);
|
|
31291
|
+
}
|
|
31292
|
+
}
|
|
31293
|
+
if (path === "/api/sessions") {
|
|
31294
|
+
const agent = url2.searchParams.get("agent") || undefined;
|
|
31295
|
+
return jsonResponse(listSessions(agent));
|
|
31296
|
+
}
|
|
31297
|
+
if (path === "/api/channels" && req.method === "GET") {
|
|
31298
|
+
return jsonResponse(listChannels());
|
|
31299
|
+
}
|
|
31300
|
+
if (path === "/api/channels" && req.method === "POST") {
|
|
31301
|
+
try {
|
|
31302
|
+
const text = await req.text();
|
|
31303
|
+
const body = JSON.parse(text);
|
|
31304
|
+
const ch = createChannel(body.name, body.created_by, body.description);
|
|
31305
|
+
return jsonResponse(ch);
|
|
31306
|
+
} catch (e) {
|
|
31307
|
+
return jsonResponse({ error: e.message }, 400);
|
|
31308
|
+
}
|
|
31309
|
+
}
|
|
31310
|
+
if (hasDist) {
|
|
31311
|
+
let filePath = join2(dashboardDist, path === "/" ? "index.html" : path);
|
|
31312
|
+
let file2 = Bun.file(filePath);
|
|
31313
|
+
if (await file2.exists())
|
|
31314
|
+
return new Response(file2);
|
|
31315
|
+
file2 = Bun.file(join2(dashboardDist, "index.html"));
|
|
31316
|
+
if (await file2.exists())
|
|
31317
|
+
return new Response(file2);
|
|
31318
|
+
}
|
|
31319
|
+
return new Response("Not Found", { status: 404 });
|
|
31320
|
+
}
|
|
31321
|
+
});
|
|
31322
|
+
console.log(`Dashboard running at http://localhost:${server2.port}`);
|
|
31323
|
+
return server2;
|
|
31324
|
+
}
|
|
31325
|
+
var isDirectRun2;
|
|
31326
|
+
var init_serve = __esm(() => {
|
|
31327
|
+
init_messages();
|
|
31328
|
+
init_sessions();
|
|
31329
|
+
init_channels();
|
|
31330
|
+
init_db();
|
|
31331
|
+
isDirectRun2 = import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith("serve.ts") || process.argv[1]?.endsWith("serve.js");
|
|
31332
|
+
if (isDirectRun2) {
|
|
31333
|
+
const port = parseInt(process.env.PORT || "3456");
|
|
31334
|
+
startDashboardServer(port);
|
|
31335
|
+
}
|
|
31336
|
+
});
|
|
31337
|
+
|
|
31227
31338
|
// node_modules/commander/esm.mjs
|
|
31228
31339
|
var import__ = __toESM(require_commander(), 1);
|
|
31229
31340
|
var {
|
|
@@ -32166,7 +32277,7 @@ function App({ agent }) {
|
|
|
32166
32277
|
|
|
32167
32278
|
// src/cli/index.tsx
|
|
32168
32279
|
var program2 = new Command;
|
|
32169
|
-
program2.name("conversations").description("Real-time CLI messaging for AI agents").version("0.0.
|
|
32280
|
+
program2.name("conversations").description("Real-time CLI messaging for AI agents").version("0.0.7");
|
|
32170
32281
|
program2.command("send").description("Send a message to an agent").argument("<message>", "Message content").requiredOption("--to <agent>", "Recipient agent ID").option("--from <agent>", "Sender agent ID").option("--session <id>", "Session ID (auto-generated if omitted)").option("--priority <level>", "Priority: low, normal, high, urgent", "normal").option("--working-dir <path>", "Working directory context").option("--repository <repo>", "Repository context").option("--branch <branch>", "Branch context").option("--metadata <json>", "JSON metadata string").option("--json", "Output as JSON").action((message, opts) => {
|
|
32171
32282
|
const from = resolveIdentity(opts.from);
|
|
32172
32283
|
const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
|
|
@@ -32432,6 +32543,10 @@ program2.command("mcp").description("Start MCP server").action(async () => {
|
|
|
32432
32543
|
const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp2(), exports_mcp));
|
|
32433
32544
|
await startMcpServer2();
|
|
32434
32545
|
});
|
|
32546
|
+
program2.command("dashboard").description("Start web dashboard").option("--port <port>", "Port to listen on", parseInt).action(async (opts) => {
|
|
32547
|
+
const { startDashboardServer: startDashboardServer2 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
|
|
32548
|
+
startDashboardServer2(opts.port || 3456);
|
|
32549
|
+
});
|
|
32435
32550
|
program2.action(() => {
|
|
32436
32551
|
const agent = resolveIdentity();
|
|
32437
32552
|
render(React8.createElement(App, { agent }));
|
package/bin/mcp.js
CHANGED
|
@@ -28319,17 +28319,19 @@ class StdioServerTransport {
|
|
|
28319
28319
|
// src/lib/db.ts
|
|
28320
28320
|
import { Database } from "bun:sqlite";
|
|
28321
28321
|
import { mkdirSync } from "fs";
|
|
28322
|
-
import { join } from "path";
|
|
28322
|
+
import { join, dirname } from "path";
|
|
28323
28323
|
import { homedir } from "os";
|
|
28324
28324
|
var db = null;
|
|
28325
28325
|
function getDbPath() {
|
|
28326
|
+
if (process.env.CONVERSATIONS_DB_PATH)
|
|
28327
|
+
return process.env.CONVERSATIONS_DB_PATH;
|
|
28326
28328
|
return join(homedir(), ".conversations", "messages.db");
|
|
28327
28329
|
}
|
|
28328
28330
|
function getDb() {
|
|
28329
28331
|
if (db)
|
|
28330
28332
|
return db;
|
|
28331
28333
|
const dbPath = getDbPath();
|
|
28332
|
-
mkdirSync(
|
|
28334
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
28333
28335
|
db = new Database(dbPath, { create: true });
|
|
28334
28336
|
db.exec("PRAGMA journal_mode = WAL");
|
|
28335
28337
|
db.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -28537,7 +28539,7 @@ function resolveIdentity(explicit) {
|
|
|
28537
28539
|
// src/mcp/index.ts
|
|
28538
28540
|
var server = new McpServer({
|
|
28539
28541
|
name: "conversations",
|
|
28540
|
-
version: "0.0.
|
|
28542
|
+
version: "0.0.7"
|
|
28541
28543
|
});
|
|
28542
28544
|
server.registerTool("send_message", {
|
|
28543
28545
|
title: "Send Message",
|