001/*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2025-2026 The Enola <https://enola.dev> Authors
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     https://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package dev.enola.chat;
019
020import dev.enola.identity.Subject;
021
022import org.jspecify.annotations.Nullable;
023
024import java.time.Instant;
025import java.util.Optional;
026
027/** Message. AKA "Post" or "Comment" or "Tweet" - or even an "Email". */
028public interface Message { // TODO extends Thing
029
030    Object id();
031
032    Optional<Object> replyTo();
033
034    Subject from();
035
036    Room to();
037
038    Instant createdAt();
039
040    Instant modifiedAt();
041
042    // TODO Add Locale language(), by introducing a LangString-like type with format datatype?
043
044    // TODO Attachments!! Useful both for Emails, as well as for LLMs...
045    // TODO Instead of attachments, add "Parts", like a Multipart MIME message - and in A2A!
046    String content();
047
048    // TODO Replace enum Format with MediaType
049    Format format();
050
051    enum Format {
052        /** Plain Text, without formatting. */
053        PLAIN,
054
055        /**
056         * Markdown format.
057         *
058         * <p>Markdown could be converted to ANSI for Terminal Shell output e.g. using <a
059         * href="https://github.com/swsnr/mdcat">mdcat</a>.
060         */
061        MARKDOWN,
062
063        /**
064         * HTML format.
065         *
066         * <p>HTML could be converted to ANSI for Terminal Shell output e.g. using <a
067         * href="https://en.m.wikipedia.org/wiki/W3m">w3m</a>.
068         */
069        HTML,
070
071        /**
072         * "ANSI" format, as in "Terminal text", with "ANSI escape &amp; color etc. control codes".
073         *
074         * <p>Should typically be rendered in a fixed width (monospaced) font.
075         */
076        ANSI
077    }
078
079    // TODO Signature by from Subject!
080
081    interface Builder {
082
083        Builder id(Object id);
084
085        Builder replyTo(Object replyToMessageID);
086
087        @Nullable Object id();
088
089        Builder from(Subject from);
090
091        @Nullable Subject from();
092
093        Builder to(Room to);
094
095        Builder createdAt(Instant createdAt);
096
097        @Nullable Instant createdAt();
098
099        Builder modifiedAt(Instant modifiedAt);
100
101        @Nullable Instant modifiedAt();
102
103        Builder subject(String subject);
104
105        Builder content(String content);
106
107        Builder format(Format format);
108
109        Message build();
110    }
111}