agent-tools.tsx


Overview

The agent-tools.tsx file provides React components and utility functions for managing and displaying "tools" and "agents" in a flow-based UI system. These components allow users to view, edit, add, and delete various tool and agent nodes within a graphical flow editor. The file integrates tightly with the system's global state store (useGraphStore), context (AgentInstanceContext), and various hooks to fetch and manipulate agent/tool data.

Key functionalities include:


Components and Functions

1. ToolCard

function ToolCard({
  children,
  className,
  ...props
}: PropsWithChildren & React.HTMLAttributes<HTMLLIElement>): JSX.Element

Description

ToolCard is a presentational component that renders a list item (<li>) with a consistent style for each tool or agent entry. It conditionally wraps the card with a tooltip if the tool type is Operator.Code, indicating no configuration is available.

Parameters

Returns

Usage Example

<ToolCard>
  <div>My Tool Name</div>
</ToolCard>

2. ActionButton

function ActionButton<T>({
  record,
  deleteRecord,
  edit,
}: ActionButtonProps<T>): JSX.Element

Description

Renders a pair of action icons (edit and delete) for a given record. It accepts generic type T for flexibility on what a "record" can be (tool name string or ID).

Parameters

Returns

Usage Example

<ActionButton
  record={"tool1"}
  deleteRecord={(tool) => console.log("Delete", tool)}
  edit={(e) => console.log("Edit", e)}
/>

3. AgentTools

function AgentTools(): JSX.Element

Description

Displays a section listing all tools and MCPs (multi-channel processors) associated with the current agent instance. Each tool/MCP is shown within a ToolCard with action buttons to edit or delete. It also provides a button wrapped in a popover to add new tools.

Internal Logic

Returns

Usage Example

<AgentTools />

4. Agents

function Agents({ node }: INextOperatorForm): JSX.Element

Description

Displays a list of downstream agent nodes connected to the given operator/node in the graph. Each downstream agent is shown in a ToolCard with edit and delete actions. Also provides a button to add a new agent node below the current node.

Parameters

Internal Logic

Returns

Usage Example

<Agents node={currentNode} />

Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram

classDiagram
    class ToolCard {
        +children: ReactNode
        +className?: string
        +props: HTMLLIElement attributes
        +render(): JSX.Element
    }

    class ActionButton~T~ {
        +record: T
        +deleteRecord(record: T): void
        +edit: MouseEventHandler
        +render(): JSX.Element
    }

    class AgentTools {
        +toolNames: string[]
        +mcpIds: string[]
        +handleEdit: MouseEventHandler
        +render(): JSX.Element
    }

    class Agents {
        +node: INextOperatorForm
        +handleEdit(nodeId: string): MouseEventHandler
        +render(): JSX.Element
    }

    ToolCard <|-- AgentTools : uses
    ToolCard <|-- Agents : uses
    ActionButton <|-- AgentTools : uses
    ActionButton <|-- Agents : uses

Summary

agent-tools.tsx is a key UI module for managing agent tools and downstream agents within a flow-based editor application. It provides reusable components with editing and deletion capabilities, tightly integrated with global graph state and domain-specific logic for tools and MCPs. The file emphasizes modularity, memoization, and consistent UI/UX, serving as a bridge between the graph data model and the user interface.


End of Documentation