@hasna/conversations 0.2.40 → 0.2.42

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
@@ -14934,7 +14934,7 @@ var init_presence = __esm(() => {
14934
14934
  var require_package = __commonJS((exports, module) => {
14935
14935
  module.exports = {
14936
14936
  name: "@hasna/conversations",
14937
- version: "0.2.40",
14937
+ version: "0.2.42",
14938
14938
  description: "Real-time CLI messaging for AI agents",
14939
14939
  type: "module",
14940
14940
  bin: {
@@ -45615,16 +45615,24 @@ var init_projects2 = __esm(() => {
45615
45615
  });
45616
45616
 
45617
45617
  // src/mcp/channel.ts
45618
- function setSessionAgent(agentId) {
45618
+ function setSessionAgent(agentId, claudeSessionId) {
45619
45619
  sessionAgentId = agentId;
45620
+ if (claudeSessionId)
45621
+ sessionClaudeId = claudeSessionId;
45620
45622
  try {
45621
45623
  const { updateCachedAutoName: updateCachedAutoName2 } = (init_identity(), __toCommonJS(exports_identity));
45622
45624
  updateCachedAutoName2(agentId);
45623
45625
  } catch {}
45624
45626
  }
45627
+ function setClaudeSessionId(id) {
45628
+ sessionClaudeId = id;
45629
+ }
45625
45630
  function getSessionAgent() {
45626
45631
  return sessionAgentId || process.env.CONVERSATIONS_AGENT_ID || null;
45627
45632
  }
45633
+ function getClaudeSessionId() {
45634
+ return sessionClaudeId || process.env.CONVERSATIONS_SESSION_ID || null;
45635
+ }
45628
45636
  function registerChannelBridge(server) {
45629
45637
  server.server.registerCapabilities({
45630
45638
  experimental: { "claude/channel": {} }
@@ -45633,7 +45641,7 @@ function registerChannelBridge(server) {
45633
45641
  let lastSessionMsgId = 0;
45634
45642
  let pollTimer = null;
45635
45643
  function getSessionId() {
45636
- return process.env.CONVERSATIONS_SESSION_ID || null;
45644
+ return getClaudeSessionId();
45637
45645
  }
45638
45646
  function seedLastSeen() {
45639
45647
  const agent = getSessionAgent();
@@ -45655,15 +45663,12 @@ function registerChannelBridge(server) {
45655
45663
  markReadByIds([msg.id]);
45656
45664
  } catch {}
45657
45665
  }
45658
- const context = [
45659
- `From: ${msg.from_agent}`,
45660
- `Mode: ${isDirect ? "direct (auto-injected, auto-read)" : "dm (passive, check inbox)"}`,
45661
- `Message ID: ${msg.id}`,
45662
- msg.space ? `Space: ${msg.space}` : null,
45663
- msg.priority && msg.priority !== "normal" ? `Priority: ${msg.priority}` : null
45664
- ].filter(Boolean).join(" | ");
45665
- const enrichedContent = `[${context}]
45666
- ${msg.content}`;
45666
+ const senderSession = msg.session_id;
45667
+ const replyHint = `To reply, use conversations send_message with to="${msg.from_agent}". For direct session injection, use send_to_session with target_session_id from the sender's session.`;
45668
+ const enrichedContent = `${msg.content}
45669
+
45670
+ ---
45671
+ [Via Conversations from ${msg.from_agent} (msg #${msg.id}). ${replyHint}]`;
45667
45672
  server.server.notification({
45668
45673
  method: "notifications/claude/channel",
45669
45674
  params: {
@@ -45706,7 +45711,7 @@ ${msg.content}`;
45706
45711
  }
45707
45712
  setTimeout(() => startPolling2(), 2000);
45708
45713
  }
45709
- var POLL_INTERVAL_MS = 1000, sessionAgentId = null;
45714
+ var POLL_INTERVAL_MS = 1000, sessionAgentId = null, sessionClaudeId = null;
45710
45715
  var init_channel = __esm(() => {
45711
45716
  init_messages();
45712
45717
  });
@@ -45714,18 +45719,27 @@ var init_channel = __esm(() => {
45714
45719
  // src/mcp/tools/agents.ts
45715
45720
  function registerAgentTools(server, agentFocus, getAgentFocus) {
45716
45721
  server.registerTool("register_agent", {
45717
- description: "Register an agent with conflict detection. Returns AgentConflictError if another active session exists (active = heartbeat within last 30 min). Optional project_id locks agent to a project for the session.",
45722
+ description: "Register an agent. Just provide the name \u2014 session_id is auto-detected.",
45718
45723
  inputSchema: {
45719
- name: exports_external2.string(),
45720
- session_id: exports_external2.string(),
45724
+ name: exports_external2.string().optional().describe("Agent name"),
45725
+ agent_name: exports_external2.string().optional().describe("Agent name (alias)"),
45726
+ agent_id: exports_external2.string().optional().describe("Agent name (alias)"),
45727
+ session_id: exports_external2.string().optional().describe("Auto-detected from environment, do not set manually"),
45721
45728
  role: exports_external2.string().optional(),
45722
45729
  project_id: exports_external2.string().optional()
45723
45730
  }
45724
45731
  }, async (args) => {
45725
- const { name, session_id, role, project_id } = args;
45732
+ const { name: nameParam, agent_name, agent_id, session_id: manualSid, role, project_id } = args;
45733
+ const name = nameParam || agent_name || agent_id;
45734
+ if (!name)
45735
+ return { content: [{ type: "text", text: "Error: name is required" }], isError: true };
45736
+ const claudeSid = process.env.CONVERSATIONS_SESSION_ID || null;
45737
+ const session_id = manualSid || claudeSid || `${name}-${Date.now()}`;
45726
45738
  try {
45727
45739
  const result = registerAgent(name, session_id, role, project_id);
45728
45740
  setSessionAgent(name);
45741
+ if (claudeSid)
45742
+ setClaudeSessionId(claudeSid);
45729
45743
  return {
45730
45744
  content: [{ type: "text", text: JSON.stringify(result) }]
45731
45745
  };
@@ -45740,14 +45754,16 @@ function registerAgentTools(server, agentFocus, getAgentFocus) {
45740
45754
  }
45741
45755
  });
45742
45756
  server.registerTool("heartbeat", {
45743
- description: "Send presence heartbeat.",
45757
+ description: "Send presence heartbeat. Use 'from' or 'name' to set agent identity.",
45744
45758
  inputSchema: {
45745
- from: exports_external2.string().optional(),
45759
+ from: exports_external2.string().optional().describe("Agent name"),
45760
+ name: exports_external2.string().optional().describe("Agent name (alias for from)"),
45761
+ agent_name: exports_external2.string().optional().describe("Agent name (alias for from)"),
45746
45762
  status: exports_external2.string().optional()
45747
45763
  }
45748
45764
  }, async (args) => {
45749
- const { from: fromParam, status } = args;
45750
- const agent = resolveIdentity(fromParam);
45765
+ const { from: fromParam, name: nameParam, agent_name, status } = args;
45766
+ const agent = resolveIdentity(fromParam || nameParam || agent_name);
45751
45767
  heartbeat(agent, status);
45752
45768
  setSessionAgent(agent);
45753
45769
  return {
package/bin/mcp.js CHANGED
@@ -42459,16 +42459,25 @@ init_identity();
42459
42459
  // src/mcp/channel.ts
42460
42460
  var POLL_INTERVAL_MS = 1000;
42461
42461
  var sessionAgentId = null;
42462
- function setSessionAgent(agentId) {
42462
+ var sessionClaudeId = null;
42463
+ function setSessionAgent(agentId, claudeSessionId) {
42463
42464
  sessionAgentId = agentId;
42465
+ if (claudeSessionId)
42466
+ sessionClaudeId = claudeSessionId;
42464
42467
  try {
42465
42468
  const { updateCachedAutoName: updateCachedAutoName2 } = (init_identity(), __toCommonJS(exports_identity));
42466
42469
  updateCachedAutoName2(agentId);
42467
42470
  } catch {}
42468
42471
  }
42472
+ function setClaudeSessionId(id) {
42473
+ sessionClaudeId = id;
42474
+ }
42469
42475
  function getSessionAgent() {
42470
42476
  return sessionAgentId || process.env.CONVERSATIONS_AGENT_ID || null;
42471
42477
  }
42478
+ function getClaudeSessionId() {
42479
+ return sessionClaudeId || process.env.CONVERSATIONS_SESSION_ID || null;
42480
+ }
42472
42481
  function registerChannelBridge(server) {
42473
42482
  server.server.registerCapabilities({
42474
42483
  experimental: { "claude/channel": {} }
@@ -42477,7 +42486,7 @@ function registerChannelBridge(server) {
42477
42486
  let lastSessionMsgId = 0;
42478
42487
  let pollTimer = null;
42479
42488
  function getSessionId() {
42480
- return process.env.CONVERSATIONS_SESSION_ID || null;
42489
+ return getClaudeSessionId();
42481
42490
  }
42482
42491
  function seedLastSeen() {
42483
42492
  const agent = getSessionAgent();
@@ -42499,15 +42508,12 @@ function registerChannelBridge(server) {
42499
42508
  markReadByIds([msg.id]);
42500
42509
  } catch {}
42501
42510
  }
42502
- const context = [
42503
- `From: ${msg.from_agent}`,
42504
- `Mode: ${isDirect ? "direct (auto-injected, auto-read)" : "dm (passive, check inbox)"}`,
42505
- `Message ID: ${msg.id}`,
42506
- msg.space ? `Space: ${msg.space}` : null,
42507
- msg.priority && msg.priority !== "normal" ? `Priority: ${msg.priority}` : null
42508
- ].filter(Boolean).join(" | ");
42509
- const enrichedContent = `[${context}]
42510
- ${msg.content}`;
42511
+ const senderSession = msg.session_id;
42512
+ const replyHint = `To reply, use conversations send_message with to="${msg.from_agent}". For direct session injection, use send_to_session with target_session_id from the sender's session.`;
42513
+ const enrichedContent = `${msg.content}
42514
+
42515
+ ---
42516
+ [Via Conversations from ${msg.from_agent} (msg #${msg.id}). ${replyHint}]`;
42511
42517
  server.server.notification({
42512
42518
  method: "notifications/claude/channel",
42513
42519
  params: {
@@ -42554,18 +42560,27 @@ ${msg.content}`;
42554
42560
  // src/mcp/tools/agents.ts
42555
42561
  function registerAgentTools(server, agentFocus, getAgentFocus) {
42556
42562
  server.registerTool("register_agent", {
42557
- description: "Register an agent with conflict detection. Returns AgentConflictError if another active session exists (active = heartbeat within last 30 min). Optional project_id locks agent to a project for the session.",
42563
+ description: "Register an agent. Just provide the name \u2014 session_id is auto-detected.",
42558
42564
  inputSchema: {
42559
- name: exports_external.string(),
42560
- session_id: exports_external.string(),
42565
+ name: exports_external.string().optional().describe("Agent name"),
42566
+ agent_name: exports_external.string().optional().describe("Agent name (alias)"),
42567
+ agent_id: exports_external.string().optional().describe("Agent name (alias)"),
42568
+ session_id: exports_external.string().optional().describe("Auto-detected from environment, do not set manually"),
42561
42569
  role: exports_external.string().optional(),
42562
42570
  project_id: exports_external.string().optional()
42563
42571
  }
42564
42572
  }, async (args) => {
42565
- const { name, session_id, role, project_id } = args;
42573
+ const { name: nameParam, agent_name, agent_id, session_id: manualSid, role, project_id } = args;
42574
+ const name = nameParam || agent_name || agent_id;
42575
+ if (!name)
42576
+ return { content: [{ type: "text", text: "Error: name is required" }], isError: true };
42577
+ const claudeSid = process.env.CONVERSATIONS_SESSION_ID || null;
42578
+ const session_id = manualSid || claudeSid || `${name}-${Date.now()}`;
42566
42579
  try {
42567
42580
  const result = registerAgent(name, session_id, role, project_id);
42568
42581
  setSessionAgent(name);
42582
+ if (claudeSid)
42583
+ setClaudeSessionId(claudeSid);
42569
42584
  return {
42570
42585
  content: [{ type: "text", text: JSON.stringify(result) }]
42571
42586
  };
@@ -42580,14 +42595,16 @@ function registerAgentTools(server, agentFocus, getAgentFocus) {
42580
42595
  }
42581
42596
  });
42582
42597
  server.registerTool("heartbeat", {
42583
- description: "Send presence heartbeat.",
42598
+ description: "Send presence heartbeat. Use 'from' or 'name' to set agent identity.",
42584
42599
  inputSchema: {
42585
- from: exports_external.string().optional(),
42600
+ from: exports_external.string().optional().describe("Agent name"),
42601
+ name: exports_external.string().optional().describe("Agent name (alias for from)"),
42602
+ agent_name: exports_external.string().optional().describe("Agent name (alias for from)"),
42586
42603
  status: exports_external.string().optional()
42587
42604
  }
42588
42605
  }, async (args) => {
42589
- const { from: fromParam, status } = args;
42590
- const agent = resolveIdentity(fromParam);
42606
+ const { from: fromParam, name: nameParam, agent_name, status } = args;
42607
+ const agent = resolveIdentity(fromParam || nameParam || agent_name);
42591
42608
  heartbeat(agent, status);
42592
42609
  setSessionAgent(agent);
42593
42610
  return {
@@ -44443,7 +44460,7 @@ function registerTmuxTools(server) {
44443
44460
  // package.json
44444
44461
  var package_default = {
44445
44462
  name: "@hasna/conversations",
44446
- version: "0.2.40",
44463
+ version: "0.2.42",
44447
44464
  description: "Real-time CLI messaging for AI agents",
44448
44465
  type: "module",
44449
44466
  bin: {
@@ -16,6 +16,9 @@
16
16
  */
17
17
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
18
18
  /** Called by agent tools when register_agent or heartbeat fires */
19
- export declare function setSessionAgent(agentId: string): void;
19
+ export declare function setSessionAgent(agentId: string, claudeSessionId?: string): void;
20
+ /** Called by register_agent to store the claude session ID */
21
+ export declare function setClaudeSessionId(id: string): void;
20
22
  export declare function getSessionAgent(): string | null;
23
+ export declare function getClaudeSessionId(): string | null;
21
24
  export declare function registerChannelBridge(server: McpServer): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/conversations",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "description": "Real-time CLI messaging for AI agents",
5
5
  "type": "module",
6
6
  "bin": {