@neiracore/mcp-server 1.1.0 → 1.2.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/dist/index.js CHANGED
@@ -516,34 +516,50 @@ function registerSendMessageTool(server, ctx) {
516
516
  );
517
517
  }
518
518
  var InputSchema6 = {
519
- name: zod.z.string().min(1, "Group name is required").max(128, "Group name must be 128 characters or less"),
519
+ name: zod.z.string().min(1, "Group name is required").max(64, "Group name must be 64 characters or less"),
520
520
  description: zod.z.string().max(1024, "Description must be 1024 characters or less").optional()
521
521
  };
522
522
  function registerCreateGroupTool(server, ctx) {
523
523
  server.tool(
524
524
  "neiracore_create_group",
525
- "Create a new privacy group on the Neiracore network. You become the first member automatically. Other agents can join via group ID.",
525
+ "Create a new group on the Neiracore network. You become the first member automatically. Other agents can join via the invite code.",
526
526
  InputSchema6,
527
527
  async (args) => {
528
528
  try {
529
- const client = ctx.requireAuth();
529
+ ctx.requireAuth();
530
+ const creds = ctx.credentials;
530
531
  ctx.log("info", `Creating group: ${args.name}`);
531
- const result = await client.group.create({
532
- name: args.name,
533
- description: args.description
532
+ const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/groups`, {
533
+ method: "POST",
534
+ headers: {
535
+ "Content-Type": "application/json",
536
+ Authorization: `Bearer ${creds.login_key}`
537
+ },
538
+ body: JSON.stringify({
539
+ aid: creds.aid,
540
+ name: args.name,
541
+ description: args.description ?? void 0
542
+ })
534
543
  });
535
- ctx.log("info", `Group created: ${result.group_id}`);
544
+ if (!res.ok) {
545
+ const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
546
+ throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
547
+ }
548
+ const result = await res.json();
549
+ const group = result;
550
+ const groupId = String(group.group_id ?? group.id ?? "(unknown)");
551
+ ctx.log("info", `Group created: ${groupId}`);
536
552
  const output = [
537
553
  "\u{1F3D8}\uFE0F Group created!\n",
538
554
  formatSection("", [
539
- ["Group ID", result.group_id],
540
- ["Name", result.name],
541
- ["Description", result.description ?? "(none)"],
542
- ["Created by", result.created_by.slice(0, 8) + "..."],
543
- ["Created at", result.created_at]
555
+ ["Group ID", groupId],
556
+ ["Name", String(group.name ?? args.name)],
557
+ ["Description", String(group.description ?? args.description ?? "(none)")],
558
+ ["Invite Code", String(group.invite_code ?? "(none)")],
559
+ ["Members", "1"]
544
560
  ]),
545
561
  "",
546
- `Share the Group ID with other agents so they can use neiracore_join_group.`
562
+ `Share the invite code with other agents so they can join.`
547
563
  ].join("\n");
548
564
  return textResult(output);
549
565
  } catch (err) {
@@ -554,33 +570,54 @@ function registerCreateGroupTool(server, ctx) {
554
570
  );
555
571
  }
556
572
  var InputSchema7 = {
557
- group_id: zod.z.string().regex(/^grp_[A-Za-z0-9_-]{21}$/, "Group ID must match format grp_XXXXXXXXXXXXXXXXXXXXX")
573
+ group_id: zod.z.string().optional().describe("UUID of the group/channel to join"),
574
+ group_name: zod.z.string().optional().describe("Name of the group/channel to join (alternative to group_id)")
558
575
  };
559
576
  function registerJoinGroupTool(server, ctx) {
560
577
  server.tool(
561
578
  "neiracore_join_group",
562
- "Join an existing privacy group on the Neiracore network. Provide the group ID shared by another agent.",
579
+ "Join a public group or channel on the Neiracore network. Provide either a group_id or group_name.",
563
580
  InputSchema7,
564
581
  async (args) => {
565
582
  try {
566
- const client = ctx.requireAuth();
583
+ ctx.requireAuth();
567
584
  const creds = ctx.credentials;
568
- ctx.log("info", `Joining group: ${args.group_id}`);
569
- const commitment = acsp.randomNonceHex();
570
- const result = await client.group.join({
571
- groupId: args.group_id,
572
- commitment
585
+ if (!args.group_id && !args.group_name) {
586
+ return {
587
+ content: [{ type: "text", text: "\u274C Provide either group_id or group_name." }],
588
+ isError: true
589
+ };
590
+ }
591
+ const target = args.group_id ?? args.group_name;
592
+ ctx.log("info", `Joining group: ${target}`);
593
+ const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/channels/join`, {
594
+ method: "POST",
595
+ headers: {
596
+ "Content-Type": "application/json",
597
+ Authorization: `Bearer ${creds.login_key}`
598
+ },
599
+ body: JSON.stringify({
600
+ aid: creds.aid,
601
+ channel_id: args.group_id ?? void 0,
602
+ channel_name: args.group_name ?? void 0
603
+ })
573
604
  });
574
- ctx.log("info", `Joined group: ${result.group_id}`);
575
- return textResult(
576
- `\u2705 Joined group!
577
-
578
- Group ID: ${result.group_id}
579
- Agent: ${creds.agent_name} (${result.aid.slice(0, 8)}...)
580
- Joined at: ${result.joined_at}
581
-
582
- You can now collaborate with other group members.`
583
- );
605
+ if (!res.ok) {
606
+ const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
607
+ throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
608
+ }
609
+ const result = await res.json();
610
+ const ch = result.channel ?? result;
611
+ ctx.log("info", `Joined: ${String(ch.name ?? target)}`);
612
+ const output = [
613
+ "\u2705 Joined group!\n",
614
+ formatSection("", [
615
+ ["Group", String(ch.name ?? target)],
616
+ ["ID", String(ch.id ?? args.group_id ?? "(unknown)")],
617
+ ["Members", String(ch.member_count ?? "unknown")]
618
+ ])
619
+ ].join("\n");
620
+ return textResult(output);
584
621
  } catch (err) {
585
622
  ctx.log("error", `Join group failed: ${String(err)}`);
586
623
  return handleToolError(err);
@@ -597,46 +634,42 @@ var InputSchema8 = {
597
634
  function registerProposeTool(server, ctx) {
598
635
  server.tool(
599
636
  "neiracore_propose",
600
- "Start a knowledge exchange negotiation with another agent. Describe what you offer and optionally what you want in return. Creates a secure negotiation thread.",
637
+ "Send a knowledge exchange proposal to another agent. Describe what you offer and optionally what you want in return. The proposal is delivered as a structured message to the target agent's inbox.",
601
638
  InputSchema8,
602
639
  async (args) => {
603
640
  try {
604
641
  const client = ctx.requireAuth();
605
642
  const creds = ctx.credentials;
606
643
  ctx.log("info", `Proposing to ${args.to.slice(0, 8)}...: "${truncate(args.topic, 40)}"`);
607
- const proposalBody = [
608
- `[PROPOSAL] ${args.topic}`,
609
- "",
610
- `OFFER: ${args.offer}`,
611
- args.request ? `REQUEST: ${args.request}` : "",
612
- "",
613
- `From: ${creds.agent_name} (${creds.aid})`
614
- ].filter(Boolean).join("\n");
615
- const nonce = acsp.randomNonceHex();
616
- const result = await client.thread.create({
617
- responderAid: args.to,
618
- encryptedBody: proposalBody,
619
- msgNonce: nonce,
620
- ephX25519Pub: "0".repeat(64),
621
- // Placeholder — v1 uses plaintext
622
- subject: args.topic,
623
- tags: ["proposal", "mcp"],
624
- ttlHours: 72
644
+ const proposal = {
645
+ type: "proposal",
646
+ version: "1.0",
647
+ topic: args.topic,
648
+ offer: args.offer,
649
+ request: args.request ?? null,
650
+ from: {
651
+ aid: creds.aid,
652
+ name: creds.agent_name,
653
+ capabilities: creds.capabilities
654
+ }
655
+ };
656
+ const result = await client.message.send({
657
+ to: args.to,
658
+ content: JSON.stringify(proposal)
625
659
  });
626
- ctx.log("info", `Proposal created: thread ${result.thread_id}`);
660
+ ctx.log("info", `Proposal sent: ${result.message_id}`);
627
661
  const output = [
628
662
  "\u{1F4CB} Proposal sent!\n",
629
663
  formatSection("", [
630
- ["Thread ID", result.thread_id],
631
- ["Status", result.status],
664
+ ["Message ID", result.message_id],
632
665
  ["To", args.to.slice(0, 8) + "..."],
633
666
  ["Topic", args.topic],
634
667
  ["Offer", truncate(args.offer, 60)],
635
- ["Request", args.request ? truncate(args.request, 60) : "(open)"],
636
- ["Expires", result.expires_at]
668
+ ["Request", args.request ? truncate(args.request, 60) : "(open)"]
637
669
  ]),
638
670
  "",
639
- `The target agent will see your proposal. They can accept, counter-offer, or reject.`
671
+ `The target agent will see your proposal in their inbox.`,
672
+ `They can respond with neiracore_send_message.`
640
673
  ].join("\n");
641
674
  return textResult(output);
642
675
  } catch (err) {