All files / src/apps/user/pages/agents/setup/steps ReviewToolkitsStep.tsx

7.69% Statements 1/13
0% Branches 0/14
0% Functions 0/8
8.33% Lines 1/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108                          2x                                                                                                                                                                                            
import { ProposedToolkitInfo } from "@/objects/AgentSetup";
import { MCPServer } from "@/objects/MCPServer";
import { Toolkit } from "@/objects/Toolkit";
import { Hammer, Sparkles } from "lucide-react";
import React from "react";
import { SectionCard, ToggleRow } from "../primitives";
 
// Agents only ever integrate tools/MCP servers through an attached
// toolkit — never individually — so existingToolkits/proposedToolkits are
// the only togglable grants here. Existing-only by construction: unlike
// skills, a proposed toolkit never invents an MCP server (they carry live
// credentials only a human can safely configure). Built-in tools are not
// members — svc-ai binds its general set to every agent.
const ReviewToolkitsStep: React.FC<{
  existingToolkits: Toolkit[];
  proposedToolkits: ProposedToolkitInfo[];
  allMcpServers: MCPServer[];
  includedExistingToolkits: Set<string>;
  includedProposedToolkits: Set<number>;
  onToggleExistingToolkit: (id: string) => void;
  onToggleProposedToolkit: (index: number) => void;
}> = ({
  existingToolkits,
  proposedToolkits,
  allMcpServers,
  includedExistingToolkits,
  includedProposedToolkits,
  onToggleExistingToolkit,
  onToggleProposedToolkit,
}) => {
  const nothingSelected =
    existingToolkits.length === 0 && proposedToolkits.length === 0;
 
  const mcpNameById = new Map(allMcpServers.map((m) => [m.id, m.name]));
  const toolkitMemberNames = (toolkit: ProposedToolkitInfo): string[] =>
    toolkit.member_mcp_server_ids.map(
      (id) => mcpNameById.get(id) ?? `Unknown (${id})`,
    );
 
  return (
    <div className="space-y-4">
      {nothingSelected && (
        <div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 px-5 py-8 text-center">
          <Hammer className="size-5 text-gray-400 dark:text-gray-500 mx-auto mb-2" />
          <p className="text-sm text-gray-500 dark:text-gray-400">
            The AI didn't select or propose any toolkits for this use case.
            You can attach a toolkit after the agent is created.
          </p>
        </div>
      )}
 
      {existingToolkits.length > 0 && (
        <SectionCard
          icon={Hammer}
          title="Your existing toolkits"
          description="Bundles of MCP servers the AI recommends attaching as one unit — this is the only way this wizard grants an agent MCP server access. Built-in tools need no grant: every agent has them. Untick any you don't want."
        >
          <div className="space-y-2">
            {existingToolkits.map((toolkit) => {
              const memberCount = (toolkit.mcp_server_ids ?? []).length;
              return (
                <ToggleRow
                  key={toolkit.id}
                  title={toolkit.name}
                  subtitle={toolkit.description}
                  meta={`${memberCount} member${memberCount !== 1 ? "s" : ""}`}
                  selected={includedExistingToolkits.has(toolkit.id)}
                  accent="emerald"
                  onToggle={() => onToggleExistingToolkit(toolkit.id)}
                />
              );
            })}
          </div>
        </SectionCard>
      )}
 
      {proposedToolkits.length > 0 && (
        <SectionCard
          icon={Sparkles}
          title="New toolkits to create"
          description="Named collections grouping your existing tools/MCP servers below — this is the only way this wizard grants an agent tool or MCP server access. Auto-attached to this agent on creation."
        >
          <div className="space-y-2">
            {proposedToolkits.map((toolkit, index) => (
              <ToggleRow
                key={index}
                title={toolkit.name}
                subtitle={toolkit.description}
                meta={
                  <>
                    <Hammer className="size-3" />
                    {toolkitMemberNames(toolkit).join(", ")}
                  </>
                }
                selected={includedProposedToolkits.has(index)}
                accent="emerald"
                onToggle={() => onToggleProposedToolkit(index)}
              />
            ))}
          </div>
        </SectionCard>
      )}
    </div>
  );
};
 
export default ReviewToolkitsStep;