001/*
002 * Copyright 2022-2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.soklet;
018
019import org.jspecify.annotations.NonNull;
020
021import javax.annotation.concurrent.Immutable;
022
023import static java.util.Objects.requireNonNull;
024
025/**
026 * Immutable MCP prompt message.
027 *
028 * @author <a href="https://www.revetkn.com">Mark Allen</a>
029 */
030@Immutable
031public record McpPromptMessage(
032                @NonNull McpPromptMessageRole role,
033                @NonNull McpTextContent content
034) {
035        public McpPromptMessage {
036                requireNonNull(role);
037                requireNonNull(content);
038        }
039
040        /**
041         * Creates a user-role prompt message from plain text.
042         *
043         * @param text the text content
044         * @return a user-role prompt message
045         */
046        @NonNull
047        public static McpPromptMessage fromUserText(@NonNull String text) {
048                requireNonNull(text);
049                return new McpPromptMessage(McpPromptMessageRole.USER, McpTextContent.fromText(text));
050        }
051
052        /**
053         * Creates an assistant-role prompt message from plain text.
054         *
055         * @param text the text content
056         * @return an assistant-role prompt message
057         */
058        @NonNull
059        public static McpPromptMessage fromAssistantText(@NonNull String text) {
060                requireNonNull(text);
061                return new McpPromptMessage(McpPromptMessageRole.ASSISTANT, McpTextContent.fromText(text));
062        }
063}