Phase 1: Refactor all 16 element component interfaces to use MCP SDK types
Replace ad-hoc local type definitions in element components with real
MCP SDK types and Inspector wrapper types from core/mcp/types.ts:
Schema-typed primitives:
- LogLevelBadge: LogLevel → LoggingLevel (SDK)
- TransportBadge: "stdio"|"http" → ServerType (core), add sse/streamable-http
- TaskStatusBadge: local TaskStatus → SDK TaskStatus (working/input_required/...)
- ServerStatusIndicator: inline union → ConnectionStatus (core), "failed"→"error"
MCP wrapper consumers:
- AnnotationBadge: label+variant → facet+value with SDK Role type
- CapabilityItem: name:string → capability:keyof ServerCapabilities|ClientCapabilities
- LogEntry: flat props → entry:{receivedAt:Date, params:LoggingMessageNotification["params"]}
- MessageBubble: flat props → message:SamplingMessage|PromptMessage
- ProgressDisplay: flat props → params:ProgressNotification["params"]
Composite-input elements:
- ContentViewer: type+content+mimeType → block:ContentBlock (SDK discriminated union)
- InlineError: message+details → error:{message,data?}
- ConnectionToggle: checked+loading+onChange → status:ConnectionStatus+onConnect/onDisconnect
Also updates all group/screen/view consumers to keep the build green,
and renames CSS variable --inspector-status-failed → --inspector-status-error.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f9a1aa4e3c
commit
2d4fca4fa6
2 changed files with 905 additions and 648 deletions
|
|
@ -23,20 +23,38 @@ type Story = StoryObj<typeof SamplingRequestPanel>;
|
|||
|
||||
export const SimpleRequest: Story = {
|
||||
args: {
|
||||
messages: [{ role: "user", content: "What is the capital of France?" }],
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "What is the capital of France?",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const WithModelHints: Story = {
|
||||
args: {
|
||||
messages: [{ role: "user", content: "Summarize this document for me." }],
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: { type: "text", text: "Summarize this document for me." },
|
||||
},
|
||||
],
|
||||
modelHints: ["claude-3-sonnet", "gpt-4"],
|
||||
},
|
||||
};
|
||||
|
||||
export const WithPriorities: Story = {
|
||||
args: {
|
||||
messages: [{ role: "user", content: "Translate this text to Spanish." }],
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: { type: "text", text: "Translate this text to Spanish." },
|
||||
},
|
||||
],
|
||||
modelHints: ["claude-3-sonnet"],
|
||||
costPriority: 0.3,
|
||||
speedPriority: 0.5,
|
||||
|
|
@ -47,8 +65,14 @@ export const WithPriorities: Story = {
|
|||
export const WithAllParams: Story = {
|
||||
args: {
|
||||
messages: [
|
||||
{ role: "user", content: "Write a haiku about programming." },
|
||||
{ role: "assistant", content: "Here is a haiku:" },
|
||||
{
|
||||
role: "user",
|
||||
content: { type: "text", text: "Write a haiku about programming." },
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: { type: "text", text: "Here is a haiku:" },
|
||||
},
|
||||
],
|
||||
maxTokens: 1024,
|
||||
stopSequences: ["\n\n", "END"],
|
||||
|
|
@ -60,7 +84,13 @@ export const WithAllParams: Story = {
|
|||
export const WithTools: Story = {
|
||||
args: {
|
||||
messages: [
|
||||
{ role: "user", content: "Look up the weather in San Francisco." },
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "Look up the weather in San Francisco.",
|
||||
},
|
||||
},
|
||||
],
|
||||
tools: [
|
||||
{
|
||||
|
|
@ -92,7 +122,12 @@ export const WithTools: Story = {
|
|||
|
||||
export const PrefilledResponse: Story = {
|
||||
args: {
|
||||
messages: [{ role: "user", content: "What is 2 + 2?" }],
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: { type: "text", text: "What is 2 + 2?" },
|
||||
},
|
||||
],
|
||||
responseText: "The answer is 4.",
|
||||
modelUsed: "claude-3-haiku",
|
||||
stopReason: "end_turn",
|
||||
|
|
|
|||
|
|
@ -11,14 +11,9 @@ import {
|
|||
Textarea,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import type { SamplingMessage } from "@modelcontextprotocol/sdk/types.js";
|
||||
import { MessageBubble } from "../../elements/MessageBubble/MessageBubble";
|
||||
|
||||
export interface SamplingMessage {
|
||||
role: string;
|
||||
content: string;
|
||||
imageContent?: { data: string; mimeType: string };
|
||||
}
|
||||
|
||||
export interface SamplingTool {
|
||||
name: string;
|
||||
description?: string;
|
||||
|
|
@ -115,13 +110,7 @@ export function SamplingRequestPanel({
|
|||
|
||||
<Title order={5}>Messages:</Title>
|
||||
{messages.map((message, index) => (
|
||||
<MessageBubble
|
||||
key={index}
|
||||
index={index}
|
||||
role={message.role as "user" | "assistant"}
|
||||
content={message.content}
|
||||
imageContent={message.imageContent}
|
||||
/>
|
||||
<MessageBubble key={index} index={index} message={message} />
|
||||
))}
|
||||
|
||||
{modelHints && modelHints.length > 0 && (
|
||||
|
|
|
|||
Loading…
Reference in a new issue