@neiracore/mcp-server 1.1.0 → 1.2.0

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,49 @@ 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.group ?? result;
550
+ ctx.log("info", `Group created: ${String(group.id ?? "unknown")}`);
536
551
  const output = [
537
552
  "\u{1F3D8}\uFE0F Group created!\n",
538
553
  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]
554
+ ["Group ID", String(group.id ?? "(unknown)")],
555
+ ["Name", String(group.name ?? args.name)],
556
+ ["Description", String(group.description ?? args.description ?? "(none)")],
557
+ ["Invite Code", String(group.invite_code ?? result.invite_code ?? "(none)")],
558
+ ["Members", String(group.member_count ?? 1)]
544
559
  ]),
545
560
  "",
546
- `Share the Group ID with other agents so they can use neiracore_join_group.`
561
+ `Share the invite code with other agents so they can join.`
547
562
  ].join("\n");
548
563
  return textResult(output);
549
564
  } catch (err) {
@@ -554,33 +569,54 @@ function registerCreateGroupTool(server, ctx) {
554
569
  );
555
570
  }
556
571
  var InputSchema7 = {
557
- group_id: zod.z.string().regex(/^grp_[A-Za-z0-9_-]{21}$/, "Group ID must match format grp_XXXXXXXXXXXXXXXXXXXXX")
572
+ group_id: zod.z.string().optional().describe("UUID of the group/channel to join"),
573
+ group_name: zod.z.string().optional().describe("Name of the group/channel to join (alternative to group_id)")
558
574
  };
559
575
  function registerJoinGroupTool(server, ctx) {
560
576
  server.tool(
561
577
  "neiracore_join_group",
562
- "Join an existing privacy group on the Neiracore network. Provide the group ID shared by another agent.",
578
+ "Join a public group or channel on the Neiracore network. Provide either a group_id or group_name.",
563
579
  InputSchema7,
564
580
  async (args) => {
565
581
  try {
566
- const client = ctx.requireAuth();
582
+ ctx.requireAuth();
567
583
  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
584
+ if (!args.group_id && !args.group_name) {
585
+ return {
586
+ content: [{ type: "text", text: "\u274C Provide either group_id or group_name." }],
587
+ isError: true
588
+ };
589
+ }
590
+ const target = args.group_id ?? args.group_name;
591
+ ctx.log("info", `Joining group: ${target}`);
592
+ const res = await fetch(`${ctx.getBaseUrl()}/api/acsp/channels/join`, {
593
+ method: "POST",
594
+ headers: {
595
+ "Content-Type": "application/json",
596
+ Authorization: `Bearer ${creds.login_key}`
597
+ },
598
+ body: JSON.stringify({
599
+ aid: creds.aid,
600
+ channel_id: args.group_id ?? void 0,
601
+ channel_name: args.group_name ?? void 0
602
+ })
573
603
  });
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
- );
604
+ if (!res.ok) {
605
+ const errBody = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
606
+ throw new Error(errBody.message ?? errBody.error ?? `HTTP ${res.status}`);
607
+ }
608
+ const result = await res.json();
609
+ const ch = result.channel ?? result;
610
+ ctx.log("info", `Joined group: ${String(ch.name ?? target)}`);
611
+ const output = [
612
+ "\u2705 Joined group!\n",
613
+ formatSection("", [
614
+ ["Group", String(ch.name ?? target)],
615
+ ["ID", String(ch.id ?? args.group_id ?? "(unknown)")],
616
+ ["Members", String(ch.member_count ?? "unknown")]
617
+ ])
618
+ ].join("\n");
619
+ return textResult(output);
584
620
  } catch (err) {
585
621
  ctx.log("error", `Join group failed: ${String(err)}`);
586
622
  return handleToolError(err);
@@ -597,46 +633,42 @@ var InputSchema8 = {
597
633
  function registerProposeTool(server, ctx) {
598
634
  server.tool(
599
635
  "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.",
636
+ "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
637
  InputSchema8,
602
638
  async (args) => {
603
639
  try {
604
640
  const client = ctx.requireAuth();
605
641
  const creds = ctx.credentials;
606
642
  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
643
+ const proposal = {
644
+ type: "proposal",
645
+ version: "1.0",
646
+ topic: args.topic,
647
+ offer: args.offer,
648
+ request: args.request ?? null,
649
+ from: {
650
+ aid: creds.aid,
651
+ name: creds.agent_name,
652
+ capabilities: creds.capabilities
653
+ }
654
+ };
655
+ const result = await client.message.send({
656
+ to: args.to,
657
+ content: JSON.stringify(proposal)
625
658
  });
626
- ctx.log("info", `Proposal created: thread ${result.thread_id}`);
659
+ ctx.log("info", `Proposal sent: ${result.message_id}`);
627
660
  const output = [
628
661
  "\u{1F4CB} Proposal sent!\n",
629
662
  formatSection("", [
630
- ["Thread ID", result.thread_id],
631
- ["Status", result.status],
663
+ ["Message ID", result.message_id],
632
664
  ["To", args.to.slice(0, 8) + "..."],
633
665
  ["Topic", args.topic],
634
666
  ["Offer", truncate(args.offer, 60)],
635
- ["Request", args.request ? truncate(args.request, 60) : "(open)"],
636
- ["Expires", result.expires_at]
667
+ ["Request", args.request ? truncate(args.request, 60) : "(open)"]
637
668
  ]),
638
669
  "",
639
- `The target agent will see your proposal. They can accept, counter-offer, or reject.`
670
+ `The target agent will see your proposal in their inbox.`,
671
+ `They can respond with neiracore_send_message.`
640
672
  ].join("\n");
641
673
  return textResult(output);
642
674
  } catch (err) {