Replace ad hoc local types with SDK schema types across the Sampling and Elicitation group components. - SamplingRequestPanel: accept `request: CreateMessageRequestParams` + `draftResult: CreateMessageResult` instead of 16 flat props; derive messages, model preferences, and parameters from the request object; drop `tools`/`toolChoice` (not in MCP 2025-11-25 CreateMessageRequest) - InlineSamplingRequest: accept `request: CreateMessageRequestParams`; derive messagePreview and modelHints from the request - ElicitationFormPanel: accept `request: ElicitRequest['params']` + `serverName`; pass requestedSchema directly to SchemaForm - ElicitationUrlPanel: rename `elicitationId` to `requestId` - InlineElicitationRequest: accept `request: ElicitRequest['params']`; discriminate form vs URL mode on request shape instead of `mode` prop - PendingClientRequests: unchanged (children-based wrapper) - Delete local `SamplingTool` type - Update all stories with real SDK type fixtures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
87 lines
1.7 KiB
TypeScript
87 lines
1.7 KiB
TypeScript
import {
|
|
Alert,
|
|
Button,
|
|
Code,
|
|
Divider,
|
|
Group,
|
|
Loader,
|
|
Stack,
|
|
Text,
|
|
} from "@mantine/core";
|
|
|
|
export interface ElicitationUrlPanelProps {
|
|
message: string;
|
|
url: string;
|
|
requestId: string;
|
|
isWaiting: boolean;
|
|
onCopyUrl: () => void;
|
|
onOpenInBrowser: () => void;
|
|
onCancel: () => void;
|
|
}
|
|
|
|
const ItalicMessage = Text.withProps({
|
|
size: "md",
|
|
fs: "italic",
|
|
});
|
|
|
|
const WrappingCode = Code.withProps({
|
|
block: true,
|
|
variant: "wrapping",
|
|
});
|
|
|
|
const HintText = Text.withProps({
|
|
size: "sm",
|
|
c: "dimmed",
|
|
});
|
|
|
|
const MetaText = Text.withProps({
|
|
size: "xs",
|
|
c: "dimmed",
|
|
});
|
|
|
|
function formatRequestId(id: string): string {
|
|
return `Request ID: ${id}`;
|
|
}
|
|
|
|
export function ElicitationUrlPanel({
|
|
message,
|
|
url,
|
|
requestId,
|
|
isWaiting,
|
|
onCopyUrl,
|
|
onOpenInBrowser,
|
|
onCancel,
|
|
}: ElicitationUrlPanelProps) {
|
|
return (
|
|
<Stack gap="md">
|
|
<ItalicMessage>{message}</ItalicMessage>
|
|
<Divider />
|
|
<Text size="sm">The server is requesting you visit:</Text>
|
|
<WrappingCode>{url}</WrappingCode>
|
|
<Group>
|
|
<Button variant="light" onClick={onCopyUrl}>
|
|
Copy URL
|
|
</Button>
|
|
<Button variant="light" onClick={onOpenInBrowser}>
|
|
Open in Browser
|
|
</Button>
|
|
</Group>
|
|
<Divider />
|
|
{isWaiting && (
|
|
<Group>
|
|
<Loader size="sm" />
|
|
<HintText>Waiting for completion...</HintText>
|
|
</Group>
|
|
)}
|
|
<MetaText>{formatRequestId(requestId)}</MetaText>
|
|
<Alert color="yellow" title="Warning">
|
|
This will open an external URL. Verify the domain before proceeding.
|
|
</Alert>
|
|
<Group justify="flex-end">
|
|
<Button variant="light" onClick={onCancel}>
|
|
Cancel
|
|
</Button>
|
|
</Group>
|
|
</Stack>
|
|
);
|
|
}
|