mcpField
A
agent-ui

agent-ui

github.com/magentosh開発442 回インストール12 週間前に更新
リポジトリ

agent-ui について

Agent Componentは、Next.jsを使うアプリケーション向けのui.inference.sh製エージェントUIコンポーネントです。ファイルや画像のアップロードを設定でき、Inference SDKのプロキシルートを利用します。

主な機能

  1. 01shadcnコンポーネントとしてインストール
  2. 02Next.js向けAPIプロキシルートの設定
  3. 03エージェント名と設定の指定
  4. 04ファイルと画像のアップロード有効化

活用シーン

  1. 01Next.jsページへのエージェントUIの追加
  2. 02Inference SDK経由でのエージェントリクエストのルーティング
  3. 03ユーザーによるファイルや画像の添付

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/magentosh/superpowers --skill agent-ui

インストール後、Claude Code で/agent-uiを入力して読み込まれたか確認します。

詳細

belt CLI スキルをインストールする: npx skills add belt-sh/cli

エージェントコンポーネント

ui.inference.sh の機能が揃ったエージェントコンポーネントです。

エージェントコンポーネント

クイックスタート

# Install the agent component
npx shadcn@latest add https://ui.inference.sh/r/agent.json

# Add the SDK for the proxy route
npm install @inferencesh/sdk

セットアップ

1. API プロキシルート(Next.js)
// app/api/inference/proxy/route.ts
import { route } from '@inferencesh/sdk/proxy/nextjs';
export const { GET, POST, PUT } = route;
2. 環境変数
# .env.local
INFERENCE_API_KEY=inf_...
3. コンポーネントを使用する
import { Agent } from "@/registry/blocks/agent/agent"

export default function Page() {
  return (
    <Agent
      proxyUrl="/api/inference/proxy"
      agentConfig={{
        core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
        description: 'a helpful ai assistant',
        system_prompt: 'you are helpful.',
      }}
    />
  )
}

機能

機能説明
ランタイムを内蔵バックエンドロジックは不要です
ツールのライフサイクル保留中、進行状況、承認、結果
Human-in-the-loop承認フローを内蔵
ウィジェットエージェントの応答から宣言的な JSON UI を生成
ストリーミングトークンをリアルタイムでストリーミング
クライアント側ツールブラウザーで実行されるツール

クライアント側ツールの例

import { Agent } from "@/registry/blocks/agent/agent"
import { createScopedTools } from "./blocks/agent/lib/client-tools"

const formRef = useRef<HTMLFormElement>(null)
const scopedTools = createScopedTools(formRef)

<Agent
  proxyUrl="/api/inference/proxy"
  config={{
    core_app: { ref: 'openrouter/claude-haiku-45@0fkg6xwb' },
    tools: scopedTools,
    system_prompt: 'You can fill forms using scan_ui and fill_field tools.',
  }}
/>

Props

Prop型説明
proxyUrlstringAPI プロキシのエンドポイント
namestringエージェント名(任意)
configAgentConfigエージェントの設定
allowFilesbooleanファイルのアップロードを有効化
allowImagesboolean画像のアップロードを有効化

関連スキル

# Chat UI building blocks
npx skills add inference-sh/skills@chat-ui

# Declarative widgets from JSON
npx skills add inference-sh/skills@widgets-ui

# Tool lifecycle UI
npx skills add inference-sh/skills@tools-ui

ドキュメント

コンポーネントのドキュメント:ui.inference.sh/blocks/agent

コメント