@hasna/conversations 0.1.21 → 0.1.22

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
@@ -2822,10 +2822,6 @@ function getProjectByName(name) {
2822
2822
  }
2823
2823
  function updateProject(id, updates) {
2824
2824
  const db2 = getDb();
2825
- const existing = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
2826
- if (!existing) {
2827
- throw new Error(`Project not found: ${id}`);
2828
- }
2829
2825
  const sets = [];
2830
2826
  const params = [];
2831
2827
  if (updates.name !== undefined) {
@@ -2861,10 +2857,15 @@ function updateProject(id, updates) {
2861
2857
  params.push(JSON.stringify(updates.settings));
2862
2858
  }
2863
2859
  if (sets.length === 0) {
2864
- return parseProject(existing);
2860
+ const row2 = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
2861
+ if (!row2)
2862
+ throw new Error(`Project not found: ${id}`);
2863
+ return parseProject(row2);
2865
2864
  }
2866
2865
  params.push(id);
2867
2866
  const row = db2.prepare(`UPDATE projects SET ${sets.join(", ")} WHERE id = ? RETURNING *`).get(...params);
2867
+ if (!row)
2868
+ throw new Error(`Project not found: ${id}`);
2868
2869
  return parseProject(row);
2869
2870
  }
2870
2871
  function deleteProject(id) {
@@ -3503,7 +3504,7 @@ var init_poll = __esm(() => {
3503
3504
  var require_package = __commonJS((exports, module) => {
3504
3505
  module.exports = {
3505
3506
  name: "@hasna/conversations",
3506
- version: "0.1.21",
3507
+ version: "0.1.22",
3507
3508
  description: "Real-time CLI messaging for AI agents",
3508
3509
  type: "module",
3509
3510
  bin: {
@@ -32493,7 +32494,7 @@ var init_mcp2 = __esm(() => {
32493
32494
  blocking
32494
32495
  });
32495
32496
  return {
32496
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
32497
+ content: [{ type: "text", text: JSON.stringify(msg) }]
32497
32498
  };
32498
32499
  });
32499
32500
  server.registerTool("read_messages", {
@@ -32510,7 +32511,7 @@ var init_mcp2 = __esm(() => {
32510
32511
  }, async (args) => {
32511
32512
  const messages = readMessages(args);
32512
32513
  return {
32513
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
32514
+ content: [{ type: "text", text: JSON.stringify(messages) }]
32514
32515
  };
32515
32516
  });
32516
32517
  server.registerTool("list_sessions", {
@@ -32522,7 +32523,7 @@ var init_mcp2 = __esm(() => {
32522
32523
  const { agent } = args;
32523
32524
  const sessions = listSessions(agent);
32524
32525
  return {
32525
- content: [{ type: "text", text: JSON.stringify(sessions, null, 2) }]
32526
+ content: [{ type: "text", text: JSON.stringify(sessions) }]
32526
32527
  };
32527
32528
  });
32528
32529
  server.registerTool("reply", {
@@ -32552,7 +32553,7 @@ var init_mcp2 = __esm(() => {
32552
32553
  space
32553
32554
  });
32554
32555
  return {
32555
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
32556
+ content: [{ type: "text", text: JSON.stringify(msg) }]
32556
32557
  };
32557
32558
  });
32558
32559
  server.registerTool("mark_read", {
@@ -32577,7 +32578,7 @@ var init_mcp2 = __esm(() => {
32577
32578
  };
32578
32579
  }
32579
32580
  return {
32580
- content: [{ type: "text", text: JSON.stringify({ marked_read: count }, null, 2) }]
32581
+ content: [{ type: "text", text: JSON.stringify({ marked_read: count }) }]
32581
32582
  };
32582
32583
  });
32583
32584
  server.registerTool("search_messages", {
@@ -32593,7 +32594,7 @@ var init_mcp2 = __esm(() => {
32593
32594
  const { query, space, from, to, limit } = args;
32594
32595
  const messages = searchMessages({ query, space, from, to, limit });
32595
32596
  return {
32596
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
32597
+ content: [{ type: "text", text: JSON.stringify(messages) }]
32597
32598
  };
32598
32599
  });
32599
32600
  server.registerTool("export_messages", {
@@ -32628,7 +32629,7 @@ var init_mcp2 = __esm(() => {
32628
32629
  try {
32629
32630
  const sp = createSpace(name, agent, { description, parent_id, project_id });
32630
32631
  return {
32631
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
32632
+ content: [{ type: "text", text: JSON.stringify(sp) }]
32632
32633
  };
32633
32634
  } catch (e) {
32634
32635
  if (e.message?.includes("UNIQUE constraint")) {
@@ -32664,7 +32665,7 @@ var init_mcp2 = __esm(() => {
32664
32665
  opts.include_archived = true;
32665
32666
  const spaces = listSpaces(opts);
32666
32667
  return {
32667
- content: [{ type: "text", text: JSON.stringify(spaces, null, 2) }]
32668
+ content: [{ type: "text", text: JSON.stringify(spaces) }]
32668
32669
  };
32669
32670
  });
32670
32671
  server.registerTool("send_to_space", {
@@ -32696,7 +32697,7 @@ var init_mcp2 = __esm(() => {
32696
32697
  blocking
32697
32698
  });
32698
32699
  return {
32699
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
32700
+ content: [{ type: "text", text: JSON.stringify(msg) }]
32700
32701
  };
32701
32702
  });
32702
32703
  server.registerTool("read_space", {
@@ -32710,7 +32711,7 @@ var init_mcp2 = __esm(() => {
32710
32711
  const { space, since, limit } = args;
32711
32712
  const messages = readMessages({ space, since, limit });
32712
32713
  return {
32713
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
32714
+ content: [{ type: "text", text: JSON.stringify(messages) }]
32714
32715
  };
32715
32716
  });
32716
32717
  server.registerTool("join_space", {
@@ -32730,7 +32731,7 @@ var init_mcp2 = __esm(() => {
32730
32731
  };
32731
32732
  }
32732
32733
  return {
32733
- content: [{ type: "text", text: JSON.stringify({ space, agent, joined: true }, null, 2) }]
32734
+ content: [{ type: "text", text: JSON.stringify({ space, agent, joined: true }) }]
32734
32735
  };
32735
32736
  });
32736
32737
  server.registerTool("leave_space", {
@@ -32744,7 +32745,7 @@ var init_mcp2 = __esm(() => {
32744
32745
  const agent = resolveIdentity(fromParam);
32745
32746
  const left = leaveSpace(space, agent);
32746
32747
  return {
32747
- content: [{ type: "text", text: JSON.stringify({ space, agent, left }, null, 2) }]
32748
+ content: [{ type: "text", text: JSON.stringify({ space, agent, left }) }]
32748
32749
  };
32749
32750
  });
32750
32751
  server.registerTool("update_space", {
@@ -32767,7 +32768,7 @@ var init_mcp2 = __esm(() => {
32767
32768
  try {
32768
32769
  const sp = updateSpace(name, updates);
32769
32770
  return {
32770
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
32771
+ content: [{ type: "text", text: JSON.stringify(sp) }]
32771
32772
  };
32772
32773
  } catch (e) {
32773
32774
  return {
@@ -32785,7 +32786,7 @@ var init_mcp2 = __esm(() => {
32785
32786
  try {
32786
32787
  const sp = archiveSpace(name);
32787
32788
  return {
32788
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
32789
+ content: [{ type: "text", text: JSON.stringify(sp) }]
32789
32790
  };
32790
32791
  } catch (e) {
32791
32792
  return {
@@ -32803,7 +32804,7 @@ var init_mcp2 = __esm(() => {
32803
32804
  try {
32804
32805
  const sp = unarchiveSpace(name);
32805
32806
  return {
32806
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
32807
+ content: [{ type: "text", text: JSON.stringify(sp) }]
32807
32808
  };
32808
32809
  } catch (e) {
32809
32810
  return {
@@ -32872,7 +32873,7 @@ var init_mcp2 = __esm(() => {
32872
32873
  settings: parsedSettings
32873
32874
  });
32874
32875
  return {
32875
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
32876
+ content: [{ type: "text", text: JSON.stringify(project) }]
32876
32877
  };
32877
32878
  } catch (e) {
32878
32879
  if (e.message?.includes("UNIQUE constraint")) {
@@ -32896,7 +32897,7 @@ var init_mcp2 = __esm(() => {
32896
32897
  const { status } = args;
32897
32898
  const projects = listProjects(status ? { status } : undefined);
32898
32899
  return {
32899
- content: [{ type: "text", text: JSON.stringify(projects, null, 2) }]
32900
+ content: [{ type: "text", text: JSON.stringify(projects) }]
32900
32901
  };
32901
32902
  });
32902
32903
  server.registerTool("get_project", {
@@ -32916,7 +32917,7 @@ var init_mcp2 = __esm(() => {
32916
32917
  };
32917
32918
  }
32918
32919
  return {
32919
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
32920
+ content: [{ type: "text", text: JSON.stringify(project) }]
32920
32921
  };
32921
32922
  });
32922
32923
  server.registerTool("update_project", {
@@ -32978,7 +32979,7 @@ var init_mcp2 = __esm(() => {
32978
32979
  try {
32979
32980
  const project = updateProject(id, updates);
32980
32981
  return {
32981
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
32982
+ content: [{ type: "text", text: JSON.stringify(project) }]
32982
32983
  };
32983
32984
  } catch (e) {
32984
32985
  return {
@@ -33002,7 +33003,7 @@ var init_mcp2 = __esm(() => {
33002
33003
  };
33003
33004
  }
33004
33005
  return {
33005
- content: [{ type: "text", text: JSON.stringify({ id, deleted: true }, null, 2) }]
33006
+ content: [{ type: "text", text: JSON.stringify({ id, deleted: true }) }]
33006
33007
  };
33007
33008
  } catch (e) {
33008
33009
  return {
@@ -33028,7 +33029,7 @@ var init_mcp2 = __esm(() => {
33028
33029
  };
33029
33030
  }
33030
33031
  return {
33031
- content: [{ type: "text", text: JSON.stringify({ deleted: true }, null, 2) }]
33032
+ content: [{ type: "text", text: JSON.stringify({ deleted: true }) }]
33032
33033
  };
33033
33034
  });
33034
33035
  server.registerTool("edit_message", {
@@ -33049,7 +33050,7 @@ var init_mcp2 = __esm(() => {
33049
33050
  };
33050
33051
  }
33051
33052
  return {
33052
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
33053
+ content: [{ type: "text", text: JSON.stringify(msg) }]
33053
33054
  };
33054
33055
  });
33055
33056
  server.registerTool("pin_message", {
@@ -33066,7 +33067,7 @@ var init_mcp2 = __esm(() => {
33066
33067
  };
33067
33068
  }
33068
33069
  return {
33069
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
33070
+ content: [{ type: "text", text: JSON.stringify(msg) }]
33070
33071
  };
33071
33072
  });
33072
33073
  server.registerTool("unpin_message", {
@@ -33083,7 +33084,7 @@ var init_mcp2 = __esm(() => {
33083
33084
  };
33084
33085
  }
33085
33086
  return {
33086
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
33087
+ content: [{ type: "text", text: JSON.stringify(msg) }]
33087
33088
  };
33088
33089
  });
33089
33090
  server.registerTool("get_pinned_messages", {
@@ -33097,7 +33098,7 @@ var init_mcp2 = __esm(() => {
33097
33098
  const { space, session_id, limit } = args;
33098
33099
  const messages = getPinnedMessages({ space, session_id, limit });
33099
33100
  return {
33100
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
33101
+ content: [{ type: "text", text: JSON.stringify(messages) }]
33101
33102
  };
33102
33103
  });
33103
33104
  server.registerTool("heartbeat", {
@@ -33111,7 +33112,7 @@ var init_mcp2 = __esm(() => {
33111
33112
  const agent = resolveIdentity(fromParam);
33112
33113
  heartbeat(agent, status);
33113
33114
  return {
33114
- content: [{ type: "text", text: JSON.stringify({ agent, status: status || "online", heartbeat: true }, null, 2) }]
33115
+ content: [{ type: "text", text: JSON.stringify({ agent, status: status || "online", heartbeat: true }) }]
33115
33116
  };
33116
33117
  });
33117
33118
  server.registerTool("list_agents", {
@@ -33123,7 +33124,7 @@ var init_mcp2 = __esm(() => {
33123
33124
  const { online_only } = args;
33124
33125
  const agents = listAgents({ online_only });
33125
33126
  return {
33126
- content: [{ type: "text", text: JSON.stringify(agents, null, 2) }]
33127
+ content: [{ type: "text", text: JSON.stringify(agents) }]
33127
33128
  };
33128
33129
  });
33129
33130
  server.registerTool("get_blockers", {
@@ -33136,7 +33137,7 @@ var init_mcp2 = __esm(() => {
33136
33137
  const agent = resolveIdentity(fromParam);
33137
33138
  const blockers = getUnreadBlockers(agent);
33138
33139
  return {
33139
- content: [{ type: "text", text: JSON.stringify(blockers, null, 2) }]
33140
+ content: [{ type: "text", text: JSON.stringify(blockers) }]
33140
33141
  };
33141
33142
  });
33142
33143
  server.registerTool("remove_agent", {
@@ -33157,7 +33158,7 @@ var init_mcp2 = __esm(() => {
33157
33158
  };
33158
33159
  }
33159
33160
  return {
33160
- content: [{ type: "text", text: JSON.stringify({ agent, removed: true }, null, 2) }]
33161
+ content: [{ type: "text", text: JSON.stringify({ agent, removed: true }) }]
33161
33162
  };
33162
33163
  });
33163
33164
  server.registerTool("rename_agent", {
@@ -33185,7 +33186,7 @@ var init_mcp2 = __esm(() => {
33185
33186
  };
33186
33187
  }
33187
33188
  return {
33188
- content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }, null, 2) }]
33189
+ content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }) }]
33189
33190
  };
33190
33191
  } catch (e) {
33191
33192
  return {
@@ -33320,6 +33321,33 @@ function securityHeaders(base) {
33320
33321
  }
33321
33322
  return headers;
33322
33323
  }
33324
+ function applyFields(data, fields) {
33325
+ if (!fields)
33326
+ return data;
33327
+ const keys = fields.split(",").map((s) => s.trim()).filter(Boolean);
33328
+ if (!keys.length)
33329
+ return data;
33330
+ if (Array.isArray(data)) {
33331
+ return data.map((item) => {
33332
+ if (item && typeof item === "object") {
33333
+ const out = {};
33334
+ for (const k of keys)
33335
+ if (k in item)
33336
+ out[k] = item[k];
33337
+ return out;
33338
+ }
33339
+ return item;
33340
+ });
33341
+ }
33342
+ if (data && typeof data === "object") {
33343
+ const out = {};
33344
+ for (const k of keys)
33345
+ if (k in data)
33346
+ out[k] = data[k];
33347
+ return out;
33348
+ }
33349
+ return data;
33350
+ }
33323
33351
  function jsonResponse(data, status = 200) {
33324
33352
  return new Response(JSON.stringify(data), {
33325
33353
  status,
@@ -33392,8 +33420,9 @@ function startDashboardServer(port = 0, host) {
33392
33420
  const space = url2.searchParams.get("space") || undefined;
33393
33421
  const from = url2.searchParams.get("from") || undefined;
33394
33422
  const to = url2.searchParams.get("to") || undefined;
33395
- const messages = readMessages({ session_id: session, space, from, to, limit, order: "desc" });
33396
- return jsonResponse(messages);
33423
+ const compact = url2.searchParams.get("compact") === "true";
33424
+ const messages = readMessages({ session_id: session, space, from, to, limit, order: "desc", compact });
33425
+ return jsonResponse(applyFields(messages, url2.searchParams.get("fields")));
33397
33426
  }
33398
33427
  if (path === "/api/messages" && req.method === "POST") {
33399
33428
  if (!isSameOrigin(req)) {
@@ -33538,7 +33567,7 @@ function startDashboardServer(port = 0, host) {
33538
33567
  }
33539
33568
  if (path === "/api/sessions") {
33540
33569
  const agent = url2.searchParams.get("agent") || undefined;
33541
- return jsonResponse(listSessions(agent));
33570
+ return jsonResponse(applyFields(listSessions(agent), url2.searchParams.get("fields")));
33542
33571
  }
33543
33572
  if (path === "/api/spaces" && req.method === "GET") {
33544
33573
  const projectId = url2.searchParams.get("project_id") || undefined;
@@ -33548,7 +33577,7 @@ function startDashboardServer(port = 0, host) {
33548
33577
  listOpts.project_id = projectId;
33549
33578
  if (includeArchived)
33550
33579
  listOpts.include_archived = true;
33551
- return jsonResponse(listSpaces(Object.keys(listOpts).length > 0 ? listOpts : undefined));
33580
+ return jsonResponse(applyFields(listSpaces(Object.keys(listOpts).length > 0 ? listOpts : undefined), url2.searchParams.get("fields")));
33552
33581
  }
33553
33582
  if (path === "/api/spaces" && req.method === "POST") {
33554
33583
  if (!isSameOrigin(req)) {
@@ -33627,7 +33656,7 @@ function startDashboardServer(port = 0, host) {
33627
33656
  }
33628
33657
  if (path === "/api/projects" && req.method === "GET") {
33629
33658
  const status = url2.searchParams.get("status");
33630
- return jsonResponse(listProjects(status ? { status } : undefined));
33659
+ return jsonResponse(applyFields(listProjects(status ? { status } : undefined), url2.searchParams.get("fields")));
33631
33660
  }
33632
33661
  if (path === "/api/projects" && req.method === "POST") {
33633
33662
  if (!isSameOrigin(req)) {
@@ -33697,7 +33726,7 @@ function startDashboardServer(port = 0, host) {
33697
33726
  if (path === "/api/agents" && req.method === "GET") {
33698
33727
  const onlineOnly = url2.searchParams.get("online_only") === "true";
33699
33728
  const agents = listAgents({ online_only: onlineOnly });
33700
- return jsonResponse(agents);
33729
+ return jsonResponse(applyFields(agents, url2.searchParams.get("fields")));
33701
33730
  }
33702
33731
  if (path === "/api/version" && req.method === "GET") {
33703
33732
  try {
package/bin/mcp.js CHANGED
@@ -29252,10 +29252,6 @@ function getProjectByName(name) {
29252
29252
  }
29253
29253
  function updateProject(id, updates) {
29254
29254
  const db2 = getDb();
29255
- const existing = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
29256
- if (!existing) {
29257
- throw new Error(`Project not found: ${id}`);
29258
- }
29259
29255
  const sets = [];
29260
29256
  const params = [];
29261
29257
  if (updates.name !== undefined) {
@@ -29291,10 +29287,15 @@ function updateProject(id, updates) {
29291
29287
  params.push(JSON.stringify(updates.settings));
29292
29288
  }
29293
29289
  if (sets.length === 0) {
29294
- return parseProject(existing);
29290
+ const row2 = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
29291
+ if (!row2)
29292
+ throw new Error(`Project not found: ${id}`);
29293
+ return parseProject(row2);
29295
29294
  }
29296
29295
  params.push(id);
29297
29296
  const row = db2.prepare(`UPDATE projects SET ${sets.join(", ")} WHERE id = ? RETURNING *`).get(...params);
29297
+ if (!row)
29298
+ throw new Error(`Project not found: ${id}`);
29298
29299
  return parseProject(row);
29299
29300
  }
29300
29301
  function deleteProject(id) {
@@ -29777,7 +29778,7 @@ function renameAgent(oldName, newName) {
29777
29778
  // package.json
29778
29779
  var package_default = {
29779
29780
  name: "@hasna/conversations",
29780
- version: "0.1.21",
29781
+ version: "0.1.22",
29781
29782
  description: "Real-time CLI messaging for AI agents",
29782
29783
  type: "module",
29783
29784
  bin: {
@@ -29879,7 +29880,7 @@ server.registerTool("send_message", {
29879
29880
  blocking
29880
29881
  });
29881
29882
  return {
29882
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
29883
+ content: [{ type: "text", text: JSON.stringify(msg) }]
29883
29884
  };
29884
29885
  });
29885
29886
  server.registerTool("read_messages", {
@@ -29896,7 +29897,7 @@ server.registerTool("read_messages", {
29896
29897
  }, async (args) => {
29897
29898
  const messages = readMessages(args);
29898
29899
  return {
29899
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
29900
+ content: [{ type: "text", text: JSON.stringify(messages) }]
29900
29901
  };
29901
29902
  });
29902
29903
  server.registerTool("list_sessions", {
@@ -29908,7 +29909,7 @@ server.registerTool("list_sessions", {
29908
29909
  const { agent } = args;
29909
29910
  const sessions = listSessions(agent);
29910
29911
  return {
29911
- content: [{ type: "text", text: JSON.stringify(sessions, null, 2) }]
29912
+ content: [{ type: "text", text: JSON.stringify(sessions) }]
29912
29913
  };
29913
29914
  });
29914
29915
  server.registerTool("reply", {
@@ -29938,7 +29939,7 @@ server.registerTool("reply", {
29938
29939
  space
29939
29940
  });
29940
29941
  return {
29941
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
29942
+ content: [{ type: "text", text: JSON.stringify(msg) }]
29942
29943
  };
29943
29944
  });
29944
29945
  server.registerTool("mark_read", {
@@ -29963,7 +29964,7 @@ server.registerTool("mark_read", {
29963
29964
  };
29964
29965
  }
29965
29966
  return {
29966
- content: [{ type: "text", text: JSON.stringify({ marked_read: count }, null, 2) }]
29967
+ content: [{ type: "text", text: JSON.stringify({ marked_read: count }) }]
29967
29968
  };
29968
29969
  });
29969
29970
  server.registerTool("search_messages", {
@@ -29979,7 +29980,7 @@ server.registerTool("search_messages", {
29979
29980
  const { query, space, from, to, limit } = args;
29980
29981
  const messages = searchMessages({ query, space, from, to, limit });
29981
29982
  return {
29982
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
29983
+ content: [{ type: "text", text: JSON.stringify(messages) }]
29983
29984
  };
29984
29985
  });
29985
29986
  server.registerTool("export_messages", {
@@ -30014,7 +30015,7 @@ server.registerTool("create_space", {
30014
30015
  try {
30015
30016
  const sp = createSpace(name, agent, { description, parent_id, project_id });
30016
30017
  return {
30017
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
30018
+ content: [{ type: "text", text: JSON.stringify(sp) }]
30018
30019
  };
30019
30020
  } catch (e) {
30020
30021
  if (e.message?.includes("UNIQUE constraint")) {
@@ -30050,7 +30051,7 @@ server.registerTool("list_spaces", {
30050
30051
  opts.include_archived = true;
30051
30052
  const spaces = listSpaces(opts);
30052
30053
  return {
30053
- content: [{ type: "text", text: JSON.stringify(spaces, null, 2) }]
30054
+ content: [{ type: "text", text: JSON.stringify(spaces) }]
30054
30055
  };
30055
30056
  });
30056
30057
  server.registerTool("send_to_space", {
@@ -30082,7 +30083,7 @@ server.registerTool("send_to_space", {
30082
30083
  blocking
30083
30084
  });
30084
30085
  return {
30085
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
30086
+ content: [{ type: "text", text: JSON.stringify(msg) }]
30086
30087
  };
30087
30088
  });
30088
30089
  server.registerTool("read_space", {
@@ -30096,7 +30097,7 @@ server.registerTool("read_space", {
30096
30097
  const { space, since, limit } = args;
30097
30098
  const messages = readMessages({ space, since, limit });
30098
30099
  return {
30099
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
30100
+ content: [{ type: "text", text: JSON.stringify(messages) }]
30100
30101
  };
30101
30102
  });
30102
30103
  server.registerTool("join_space", {
@@ -30116,7 +30117,7 @@ server.registerTool("join_space", {
30116
30117
  };
30117
30118
  }
30118
30119
  return {
30119
- content: [{ type: "text", text: JSON.stringify({ space, agent, joined: true }, null, 2) }]
30120
+ content: [{ type: "text", text: JSON.stringify({ space, agent, joined: true }) }]
30120
30121
  };
30121
30122
  });
30122
30123
  server.registerTool("leave_space", {
@@ -30130,7 +30131,7 @@ server.registerTool("leave_space", {
30130
30131
  const agent = resolveIdentity(fromParam);
30131
30132
  const left = leaveSpace(space, agent);
30132
30133
  return {
30133
- content: [{ type: "text", text: JSON.stringify({ space, agent, left }, null, 2) }]
30134
+ content: [{ type: "text", text: JSON.stringify({ space, agent, left }) }]
30134
30135
  };
30135
30136
  });
30136
30137
  server.registerTool("update_space", {
@@ -30153,7 +30154,7 @@ server.registerTool("update_space", {
30153
30154
  try {
30154
30155
  const sp = updateSpace(name, updates);
30155
30156
  return {
30156
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
30157
+ content: [{ type: "text", text: JSON.stringify(sp) }]
30157
30158
  };
30158
30159
  } catch (e) {
30159
30160
  return {
@@ -30171,7 +30172,7 @@ server.registerTool("archive_space", {
30171
30172
  try {
30172
30173
  const sp = archiveSpace(name);
30173
30174
  return {
30174
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
30175
+ content: [{ type: "text", text: JSON.stringify(sp) }]
30175
30176
  };
30176
30177
  } catch (e) {
30177
30178
  return {
@@ -30189,7 +30190,7 @@ server.registerTool("unarchive_space", {
30189
30190
  try {
30190
30191
  const sp = unarchiveSpace(name);
30191
30192
  return {
30192
- content: [{ type: "text", text: JSON.stringify(sp, null, 2) }]
30193
+ content: [{ type: "text", text: JSON.stringify(sp) }]
30193
30194
  };
30194
30195
  } catch (e) {
30195
30196
  return {
@@ -30258,7 +30259,7 @@ server.registerTool("create_project", {
30258
30259
  settings: parsedSettings
30259
30260
  });
30260
30261
  return {
30261
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
30262
+ content: [{ type: "text", text: JSON.stringify(project) }]
30262
30263
  };
30263
30264
  } catch (e) {
30264
30265
  if (e.message?.includes("UNIQUE constraint")) {
@@ -30282,7 +30283,7 @@ server.registerTool("list_projects", {
30282
30283
  const { status } = args;
30283
30284
  const projects = listProjects(status ? { status } : undefined);
30284
30285
  return {
30285
- content: [{ type: "text", text: JSON.stringify(projects, null, 2) }]
30286
+ content: [{ type: "text", text: JSON.stringify(projects) }]
30286
30287
  };
30287
30288
  });
30288
30289
  server.registerTool("get_project", {
@@ -30302,7 +30303,7 @@ server.registerTool("get_project", {
30302
30303
  };
30303
30304
  }
30304
30305
  return {
30305
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
30306
+ content: [{ type: "text", text: JSON.stringify(project) }]
30306
30307
  };
30307
30308
  });
30308
30309
  server.registerTool("update_project", {
@@ -30364,7 +30365,7 @@ server.registerTool("update_project", {
30364
30365
  try {
30365
30366
  const project = updateProject(id, updates);
30366
30367
  return {
30367
- content: [{ type: "text", text: JSON.stringify(project, null, 2) }]
30368
+ content: [{ type: "text", text: JSON.stringify(project) }]
30368
30369
  };
30369
30370
  } catch (e) {
30370
30371
  return {
@@ -30388,7 +30389,7 @@ server.registerTool("delete_project", {
30388
30389
  };
30389
30390
  }
30390
30391
  return {
30391
- content: [{ type: "text", text: JSON.stringify({ id, deleted: true }, null, 2) }]
30392
+ content: [{ type: "text", text: JSON.stringify({ id, deleted: true }) }]
30392
30393
  };
30393
30394
  } catch (e) {
30394
30395
  return {
@@ -30414,7 +30415,7 @@ server.registerTool("delete_message", {
30414
30415
  };
30415
30416
  }
30416
30417
  return {
30417
- content: [{ type: "text", text: JSON.stringify({ deleted: true }, null, 2) }]
30418
+ content: [{ type: "text", text: JSON.stringify({ deleted: true }) }]
30418
30419
  };
30419
30420
  });
30420
30421
  server.registerTool("edit_message", {
@@ -30435,7 +30436,7 @@ server.registerTool("edit_message", {
30435
30436
  };
30436
30437
  }
30437
30438
  return {
30438
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
30439
+ content: [{ type: "text", text: JSON.stringify(msg) }]
30439
30440
  };
30440
30441
  });
30441
30442
  server.registerTool("pin_message", {
@@ -30452,7 +30453,7 @@ server.registerTool("pin_message", {
30452
30453
  };
30453
30454
  }
30454
30455
  return {
30455
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
30456
+ content: [{ type: "text", text: JSON.stringify(msg) }]
30456
30457
  };
30457
30458
  });
30458
30459
  server.registerTool("unpin_message", {
@@ -30469,7 +30470,7 @@ server.registerTool("unpin_message", {
30469
30470
  };
30470
30471
  }
30471
30472
  return {
30472
- content: [{ type: "text", text: JSON.stringify(msg, null, 2) }]
30473
+ content: [{ type: "text", text: JSON.stringify(msg) }]
30473
30474
  };
30474
30475
  });
30475
30476
  server.registerTool("get_pinned_messages", {
@@ -30483,7 +30484,7 @@ server.registerTool("get_pinned_messages", {
30483
30484
  const { space, session_id, limit } = args;
30484
30485
  const messages = getPinnedMessages({ space, session_id, limit });
30485
30486
  return {
30486
- content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
30487
+ content: [{ type: "text", text: JSON.stringify(messages) }]
30487
30488
  };
30488
30489
  });
30489
30490
  server.registerTool("heartbeat", {
@@ -30497,7 +30498,7 @@ server.registerTool("heartbeat", {
30497
30498
  const agent = resolveIdentity(fromParam);
30498
30499
  heartbeat(agent, status);
30499
30500
  return {
30500
- content: [{ type: "text", text: JSON.stringify({ agent, status: status || "online", heartbeat: true }, null, 2) }]
30501
+ content: [{ type: "text", text: JSON.stringify({ agent, status: status || "online", heartbeat: true }) }]
30501
30502
  };
30502
30503
  });
30503
30504
  server.registerTool("list_agents", {
@@ -30509,7 +30510,7 @@ server.registerTool("list_agents", {
30509
30510
  const { online_only } = args;
30510
30511
  const agents = listAgents({ online_only });
30511
30512
  return {
30512
- content: [{ type: "text", text: JSON.stringify(agents, null, 2) }]
30513
+ content: [{ type: "text", text: JSON.stringify(agents) }]
30513
30514
  };
30514
30515
  });
30515
30516
  server.registerTool("get_blockers", {
@@ -30522,7 +30523,7 @@ server.registerTool("get_blockers", {
30522
30523
  const agent = resolveIdentity(fromParam);
30523
30524
  const blockers = getUnreadBlockers(agent);
30524
30525
  return {
30525
- content: [{ type: "text", text: JSON.stringify(blockers, null, 2) }]
30526
+ content: [{ type: "text", text: JSON.stringify(blockers) }]
30526
30527
  };
30527
30528
  });
30528
30529
  server.registerTool("remove_agent", {
@@ -30543,7 +30544,7 @@ server.registerTool("remove_agent", {
30543
30544
  };
30544
30545
  }
30545
30546
  return {
30546
- content: [{ type: "text", text: JSON.stringify({ agent, removed: true }, null, 2) }]
30547
+ content: [{ type: "text", text: JSON.stringify({ agent, removed: true }) }]
30547
30548
  };
30548
30549
  });
30549
30550
  server.registerTool("rename_agent", {
@@ -30571,7 +30572,7 @@ server.registerTool("rename_agent", {
30571
30572
  };
30572
30573
  }
30573
30574
  return {
30574
- content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }, null, 2) }]
30575
+ content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }) }]
30575
30576
  };
30576
30577
  } catch (e) {
30577
30578
  return {
package/dist/index.js CHANGED
@@ -2821,10 +2821,6 @@ function getProjectByName(name) {
2821
2821
  }
2822
2822
  function updateProject(id, updates) {
2823
2823
  const db2 = getDb();
2824
- const existing = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
2825
- if (!existing) {
2826
- throw new Error(`Project not found: ${id}`);
2827
- }
2828
2824
  const sets = [];
2829
2825
  const params = [];
2830
2826
  if (updates.name !== undefined) {
@@ -2860,10 +2856,15 @@ function updateProject(id, updates) {
2860
2856
  params.push(JSON.stringify(updates.settings));
2861
2857
  }
2862
2858
  if (sets.length === 0) {
2863
- return parseProject(existing);
2859
+ const row2 = db2.prepare("SELECT * FROM projects WHERE id = ?").get(id);
2860
+ if (!row2)
2861
+ throw new Error(`Project not found: ${id}`);
2862
+ return parseProject(row2);
2864
2863
  }
2865
2864
  params.push(id);
2866
2865
  const row = db2.prepare(`UPDATE projects SET ${sets.join(", ")} WHERE id = ? RETURNING *`).get(...params);
2866
+ if (!row)
2867
+ throw new Error(`Project not found: ${id}`);
2867
2868
  return parseProject(row);
2868
2869
  }
2869
2870
  function deleteProject(id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/conversations",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Real-time CLI messaging for AI agents",
5
5
  "type": "module",
6
6
  "bin": {