@hasna/conversations 0.0.5 → 0.0.6

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 CHANGED
@@ -31003,7 +31003,7 @@ var init_mcp2 = __esm(() => {
31003
31003
  init_channels();
31004
31004
  server = new McpServer({
31005
31005
  name: "conversations",
31006
- version: "0.0.5"
31006
+ version: "0.0.6"
31007
31007
  });
31008
31008
  server.registerTool("send_message", {
31009
31009
  title: "Send Message",
@@ -31224,6 +31224,115 @@ var init_mcp2 = __esm(() => {
31224
31224
  }
31225
31225
  });
31226
31226
 
31227
+ // src/server/serve.ts
31228
+ var exports_serve = {};
31229
+ __export(exports_serve, {
31230
+ startDashboardServer: () => startDashboardServer
31231
+ });
31232
+ import { join as join2 } from "path";
31233
+ import { existsSync } from "fs";
31234
+ function jsonResponse(data, status = 200) {
31235
+ return new Response(JSON.stringify(data), {
31236
+ status,
31237
+ headers: { "Content-Type": "application/json" }
31238
+ });
31239
+ }
31240
+ function getStatus() {
31241
+ const db2 = getDb();
31242
+ const dbPath = getDbPath();
31243
+ const totalMessages = db2.prepare("SELECT COUNT(*) as count FROM messages").get().count;
31244
+ const totalSessions = db2.prepare("SELECT COUNT(DISTINCT session_id) as count FROM messages").get().count;
31245
+ const totalUnread = db2.prepare("SELECT COUNT(*) as count FROM messages WHERE read_at IS NULL").get().count;
31246
+ const totalChannels = db2.prepare("SELECT COUNT(*) as count FROM channels").get().count;
31247
+ return {
31248
+ db_path: dbPath,
31249
+ total_messages: totalMessages,
31250
+ total_sessions: totalSessions,
31251
+ total_channels: totalChannels,
31252
+ unread_messages: totalUnread
31253
+ };
31254
+ }
31255
+ function startDashboardServer(port = 3456) {
31256
+ const dashboardDist = join2(import.meta.dir, "../../dashboard/dist");
31257
+ const hasDist = existsSync(dashboardDist);
31258
+ const server2 = Bun.serve({
31259
+ port,
31260
+ async fetch(req) {
31261
+ const url2 = new URL(req.url);
31262
+ const path = url2.pathname;
31263
+ if (path === "/api/status") {
31264
+ return jsonResponse(getStatus());
31265
+ }
31266
+ if (path === "/api/messages" && req.method === "GET") {
31267
+ const limit = parseInt(url2.searchParams.get("limit") || "50");
31268
+ const session = url2.searchParams.get("session") || undefined;
31269
+ const channel = url2.searchParams.get("channel") || undefined;
31270
+ const from = url2.searchParams.get("from") || undefined;
31271
+ const to = url2.searchParams.get("to") || undefined;
31272
+ const messages = readMessages({ session_id: session, channel, from, to, limit });
31273
+ return jsonResponse(messages.reverse());
31274
+ }
31275
+ if (path === "/api/messages" && req.method === "POST") {
31276
+ try {
31277
+ const text = await req.text();
31278
+ const body = JSON.parse(text);
31279
+ const msg = sendMessage({
31280
+ from: body.from,
31281
+ to: body.to,
31282
+ content: body.content,
31283
+ channel: body.channel,
31284
+ priority: body.priority
31285
+ });
31286
+ return jsonResponse(msg);
31287
+ } catch (e) {
31288
+ return jsonResponse({ error: e.message }, 400);
31289
+ }
31290
+ }
31291
+ if (path === "/api/sessions") {
31292
+ const agent = url2.searchParams.get("agent") || undefined;
31293
+ return jsonResponse(listSessions(agent));
31294
+ }
31295
+ if (path === "/api/channels" && req.method === "GET") {
31296
+ return jsonResponse(listChannels());
31297
+ }
31298
+ if (path === "/api/channels" && req.method === "POST") {
31299
+ try {
31300
+ const text = await req.text();
31301
+ const body = JSON.parse(text);
31302
+ const ch = createChannel(body.name, body.created_by, body.description);
31303
+ return jsonResponse(ch);
31304
+ } catch (e) {
31305
+ return jsonResponse({ error: e.message }, 400);
31306
+ }
31307
+ }
31308
+ if (hasDist) {
31309
+ let filePath = join2(dashboardDist, path === "/" ? "index.html" : path);
31310
+ let file2 = Bun.file(filePath);
31311
+ if (await file2.exists())
31312
+ return new Response(file2);
31313
+ file2 = Bun.file(join2(dashboardDist, "index.html"));
31314
+ if (await file2.exists())
31315
+ return new Response(file2);
31316
+ }
31317
+ return new Response("Not Found", { status: 404 });
31318
+ }
31319
+ });
31320
+ console.log(`Dashboard running at http://localhost:${server2.port}`);
31321
+ return server2;
31322
+ }
31323
+ var isDirectRun2;
31324
+ var init_serve = __esm(() => {
31325
+ init_messages();
31326
+ init_sessions();
31327
+ init_channels();
31328
+ init_db();
31329
+ isDirectRun2 = import.meta.url === `file://${process.argv[1]}` || process.argv[1]?.endsWith("serve.ts") || process.argv[1]?.endsWith("serve.js");
31330
+ if (isDirectRun2) {
31331
+ const port = parseInt(process.env.PORT || "3456");
31332
+ startDashboardServer(port);
31333
+ }
31334
+ });
31335
+
31227
31336
  // node_modules/commander/esm.mjs
31228
31337
  var import__ = __toESM(require_commander(), 1);
31229
31338
  var {
@@ -32166,7 +32275,7 @@ function App({ agent }) {
32166
32275
 
32167
32276
  // src/cli/index.tsx
32168
32277
  var program2 = new Command;
32169
- program2.name("conversations").description("Real-time CLI messaging for AI agents").version("0.0.5");
32278
+ program2.name("conversations").description("Real-time CLI messaging for AI agents").version("0.0.6");
32170
32279
  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
32280
  const from = resolveIdentity(opts.from);
32172
32281
  const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
@@ -32432,6 +32541,10 @@ program2.command("mcp").description("Start MCP server").action(async () => {
32432
32541
  const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp2(), exports_mcp));
32433
32542
  await startMcpServer2();
32434
32543
  });
32544
+ program2.command("dashboard").description("Start web dashboard").option("--port <port>", "Port to listen on", parseInt).action(async (opts) => {
32545
+ const { startDashboardServer: startDashboardServer2 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
32546
+ startDashboardServer2(opts.port || 3456);
32547
+ });
32435
32548
  program2.action(() => {
32436
32549
  const agent = resolveIdentity();
32437
32550
  render(React8.createElement(App, { agent }));
package/bin/mcp.js CHANGED
@@ -28537,7 +28537,7 @@ function resolveIdentity(explicit) {
28537
28537
  // src/mcp/index.ts
28538
28538
  var server = new McpServer({
28539
28539
  name: "conversations",
28540
- version: "0.0.5"
28540
+ version: "0.0.6"
28541
28541
  });
28542
28542
  server.registerTool("send_message", {
28543
28543
  title: "Send Message",