openrois-adapter-mmdagent-ex 0.1.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ """The OpenRoIS adapter process for MMDAgent-EX: settings, engine and command."""
2
+
3
+ from openrois_adapter_mmdagent_ex.cli import MMDAgentExConfig, build_engine, load_config, main
4
+
5
+ __all__ = ["MMDAgentExConfig", "build_engine", "load_config", "main"]
@@ -0,0 +1,4 @@
1
+ from openrois_adapter_mmdagent_ex.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,195 @@
1
+ """The ``openrois-adapter-mmdagent-ex`` command: one MMDAgent-EX behind an OpenRoIS gateway.
2
+
3
+ The adapter builds an ``Engine`` with the three components of one MMDAgent-EX
4
+ virtual avatar, shares one connection to MMDAgent-EX's Plugin_Remote server between them,
5
+ and serves the engine to a gateway with ``WsClient``::
6
+
7
+ openrois-adapter-mmdagent-ex --config adapter.yaml
8
+
9
+ The components are ``<engine id>/system_information``, ``<engine id>/speech_synthesis``
10
+ and ``<engine id>/reaction``. ``robot_address`` is where MMDAgent-EX listens,
11
+ ``host:port``. While MMDAgent-EX does not answer, the components report ERROR, and the
12
+ adapter connects again once it is back.
13
+
14
+ The settings come from the engine's adapter loader: the defaults of ``MMDAgentExConfig``,
15
+ then ``adapter.yaml`` (named by ``--config`` or ``OPENROIS_ADAPTER_CONFIG``), then the
16
+ ``OPENROIS_ADAPTER_*`` environment variables, then the flags. The environment and the
17
+ flags set only the gateway URL, the engine id, the address of MMDAgent-EX and the log
18
+ level. Everything else comes from the file.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import logging
24
+ import os
25
+ import sys
26
+ from collections.abc import Mapping, Sequence
27
+ from typing import Literal
28
+
29
+ from openrois.engine import Engine, WsClient
30
+ from openrois.engine.config import AdapterConfig, ConfigError, load_adapter_config
31
+ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
32
+
33
+ from openrois_adapter_mmdagent_ex.components import (
34
+ MMDAgentExConnection,
35
+ MMDAgentExReaction,
36
+ MMDAgentExSpeechSynthesis,
37
+ MMDAgentExSystemInformation,
38
+ Motion,
39
+ )
40
+
41
+ logger = logging.getLogger("openrois_adapter_mmdagent_ex")
42
+
43
+ DESCRIPTION = "Serve one MMDAgent-EX virtual avatar to an OpenRoIS gateway."
44
+
45
+ #: Where MMDAgent-EX listens unless the settings say otherwise.
46
+ DEFAULT_ADDRESS = "127.0.0.1:50001"
47
+
48
+
49
+ class _Section(BaseModel):
50
+ model_config = ConfigDict(extra="forbid", frozen=True)
51
+
52
+
53
+ class ConnectionSettings(_Section):
54
+ """How the adapter reaches MMDAgent-EX."""
55
+
56
+ retry: float = Field(default=3.0, gt=0, description="Seconds between two attempts.")
57
+ start_timeout: float = Field(
58
+ default=10.0,
59
+ gt=0,
60
+ description="Seconds a start waits for MMDAgent-EX to begin a speech or a motion.",
61
+ )
62
+
63
+
64
+ class SpeechSettings(_Section):
65
+ """The SpeechSynthesis component."""
66
+
67
+ voices: dict[str, str] = Field(
68
+ default={
69
+ "mei_voice_normal": "ja",
70
+ "mei_voice_happy": "ja",
71
+ "slt_voice_normal": "en",
72
+ "slt_voice_fast": "en",
73
+ },
74
+ min_length=1,
75
+ description="The voice names of the content, each with its ISO 639-1 language.",
76
+ )
77
+
78
+
79
+ class MotionSettings(_Section):
80
+ """One reaction: a motion file of the content."""
81
+
82
+ file: str = Field(min_length=1, description="The .vmd file, relative to the content.")
83
+ mode: Literal["PART", "FULL"] = Field(
84
+ default="PART", description="PART moves only the bones the file has keys for."
85
+ )
86
+
87
+
88
+ class ReactionSettings(_Section):
89
+ """The Reaction component."""
90
+
91
+ motions: dict[str, MotionSettings] = Field(
92
+ default={
93
+ "bow": MotionSettings(file="motions/action/ojigi.vmd", mode="FULL"),
94
+ "smile": MotionSettings(file="gene/motion/03_smile.vmd"),
95
+ },
96
+ min_length=1,
97
+ description="The reactions by name. The first is the default.",
98
+ )
99
+
100
+
101
+ class MMDAgentExConfig(AdapterConfig):
102
+ """The settings of one MMDAgent-EX adapter, one section per component.
103
+
104
+ ``robot_address`` is where MMDAgent-EX's Plugin_Remote server listens, ``host:port``.
105
+ ``model`` is the model alias of the virtual avatar in the content, ``0`` in the Example.
106
+ """
107
+
108
+ engine_id: str = "mmdagent-ex"
109
+ robot_address: str | None = DEFAULT_ADDRESS
110
+ model: str = Field(default="0", min_length=1, description="The model alias.")
111
+ connection: ConnectionSettings = ConnectionSettings()
112
+ speech_synthesis: SpeechSettings = SpeechSettings()
113
+ reaction: ReactionSettings = ReactionSettings()
114
+
115
+ @field_validator("model")
116
+ @classmethod
117
+ def _one_field(cls, value: str) -> str:
118
+ if "|" in value or any(c.isspace() for c in value):
119
+ raise ValueError("must not contain '|' or spaces")
120
+ return value
121
+
122
+ @model_validator(mode="after")
123
+ def _address(self) -> MMDAgentExConfig:
124
+ self.host_and_port()
125
+ return self
126
+
127
+ def host_and_port(self) -> tuple[str, int]:
128
+ """The host and the port of ``robot_address``.
129
+
130
+ Raises:
131
+ ValueError: The address is not ``host:port`` with a port from 1 to 65535.
132
+ """
133
+ address = self.robot_address or DEFAULT_ADDRESS
134
+ host, sep, port = address.rpartition(":")
135
+ if not sep or not host or not port.isdigit() or not 1 <= int(port) <= 65535:
136
+ raise ValueError(f"robot_address must be host:port, such as {DEFAULT_ADDRESS}")
137
+ return host.strip("[]"), int(port)
138
+
139
+
140
+ def build_engine(config: MMDAgentExConfig) -> Engine:
141
+ """The engine of one MMDAgent-EX, with its three components on one connection."""
142
+ host, port = config.host_and_port()
143
+ connection = MMDAgentExConnection(host, port, retry=config.connection.retry)
144
+ timeout = config.connection.start_timeout
145
+ engine = Engine(config.engine_id)
146
+ engine.add_component("system_information", MMDAgentExSystemInformation(connection))
147
+ engine.add_component(
148
+ "speech_synthesis",
149
+ MMDAgentExSpeechSynthesis(
150
+ connection, config.model, config.speech_synthesis.voices, start_timeout=timeout
151
+ ),
152
+ )
153
+ engine.add_component(
154
+ "reaction",
155
+ MMDAgentExReaction(
156
+ connection,
157
+ config.model,
158
+ {
159
+ name: Motion(file=motion.file, mode=motion.mode)
160
+ for name, motion in config.reaction.motions.items()
161
+ },
162
+ start_timeout=timeout,
163
+ ),
164
+ )
165
+ return engine
166
+
167
+
168
+ def load_config(
169
+ argv: Sequence[str] | None = None, environ: Mapping[str, str] | None = None
170
+ ) -> MMDAgentExConfig:
171
+ """The settings, from the defaults, adapter.yaml, the environment and the flags.
172
+
173
+ Raises:
174
+ ConfigError: The file cannot be read or a setting is invalid.
175
+ SystemExit: For an unknown flag or ``--help``.
176
+ """
177
+ return load_adapter_config(
178
+ MMDAgentExConfig,
179
+ argv,
180
+ os.environ if environ is None else environ,
181
+ description=DESCRIPTION,
182
+ )
183
+
184
+
185
+ def main(argv: Sequence[str] | None = None) -> None:
186
+ """Load the settings and serve the gateway until Ctrl+C."""
187
+ try:
188
+ config = load_config(argv)
189
+ except ConfigError as exc:
190
+ print(exc, file=sys.stderr)
191
+ sys.exit(2)
192
+ logging.basicConfig(
193
+ level=config.log_level.upper(), format="%(asctime)s %(levelname)s %(name)s: %(message)s"
194
+ )
195
+ WsClient(build_engine(config), config.gateway_url).run()
@@ -0,0 +1,44 @@
1
+ """OpenRoIS components for an MMDAgent-EX virtual avatar.
2
+
3
+ Canonical RoIS components that drive a virtual avatar in a running MMDAgent-EX through its
4
+ Plugin_Remote TCP server. Each one is a ``Component`` of ``openrois-components-core``:
5
+
6
+ - ``MMDAgentExSystemInformation``: the status of the engine.
7
+ - ``MMDAgentExSpeechSynthesis``: a text spoken with a voice of the content, with lip sync.
8
+ - ``MMDAgentExReaction``: a motion of the content, played once.
9
+
10
+ The components of one MMDAgent-EX share one ``MMDAgentExConnection``::
11
+
12
+ connection = MMDAgentExConnection("127.0.0.1", 50001)
13
+ engine = Engine("mmdagent")
14
+ engine.add_component("speech_synthesis", MMDAgentExSpeechSynthesis(
15
+ connection, model="0", voices={"mei_voice_normal": "ja"}))
16
+ """
17
+
18
+ from openrois_adapter_mmdagent_ex.components.connection import (
19
+ Listener,
20
+ MMDAgentExConnection,
21
+ message_field,
22
+ )
23
+ from openrois_adapter_mmdagent_ex.components.reaction import (
24
+ MOTION_ALIAS,
25
+ MMDAgentExReaction,
26
+ Motion,
27
+ )
28
+ from openrois_adapter_mmdagent_ex.components.speech_synthesis import (
29
+ DEFAULT_CHARACTER,
30
+ MMDAgentExSpeechSynthesis,
31
+ )
32
+ from openrois_adapter_mmdagent_ex.components.system_information import MMDAgentExSystemInformation
33
+
34
+ __all__ = [
35
+ "DEFAULT_CHARACTER",
36
+ "MOTION_ALIAS",
37
+ "Listener",
38
+ "MMDAgentExConnection",
39
+ "MMDAgentExReaction",
40
+ "MMDAgentExSpeechSynthesis",
41
+ "MMDAgentExSystemInformation",
42
+ "Motion",
43
+ "message_field",
44
+ ]
@@ -0,0 +1,96 @@
1
+ """What SpeechSynthesis and Reaction share: one MMDAgent-EX action from start to end.
2
+
3
+ Both components start an action with one message, learn that MMDAgent-EX began it from
4
+ one event, wait for the event that ends it, and cut it off with another message. A
5
+ ``start`` that ``stop`` or a new ``start`` cancels sends the stopping message, unless
6
+ ``stop`` already did, and waits a moment for the end event, so the next action never
7
+ reads the end of the previous one.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import asyncio
13
+ import contextlib
14
+ from dataclasses import dataclass
15
+
16
+ from openrois.components.core import CommandFailed
17
+ from openrois.interfaces.service import CompletedStatus
18
+
19
+ from openrois_adapter_mmdagent_ex.components.connection import Listener, MMDAgentExConnection
20
+
21
+ #: How long a cut-off action waits for MMDAgent-EX to confirm the end, in seconds.
22
+ HALT_TIMEOUT = 2.0
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class Action:
27
+ """The messages of one action in MMDAgent-EX."""
28
+
29
+ start: str
30
+ started: str
31
+ ended: str
32
+ halt: str
33
+ #: What to tell the client when ``started`` does not come.
34
+ hint: str
35
+
36
+
37
+ class ActionRunner:
38
+ """Runs one action at a time on one connection."""
39
+
40
+ def __init__(self, connection: MMDAgentExConnection, start_timeout: float) -> None:
41
+ self._connection = connection
42
+ self._start_timeout = start_timeout
43
+ self._current: Action | None = None
44
+ self._halted = False
45
+
46
+ async def run(self, action: Action) -> None:
47
+ """Send the action and wait for its end.
48
+
49
+ Raises:
50
+ CommandFailed: MMDAgent-EX is not connected, did not start the action in
51
+ time, or the connection was lost meanwhile.
52
+ """
53
+ with self._connection.listen() as listener:
54
+ self._current, self._halted = action, False
55
+ ended = False
56
+ try:
57
+ await self._connection.send(action.start)
58
+ try:
59
+ async with asyncio.timeout(self._start_timeout):
60
+ await listener.wait_for(action.started)
61
+ except TimeoutError:
62
+ raise CommandFailed(
63
+ CompletedStatus.ERROR,
64
+ f"MMDAgent-EX did not start within {self._start_timeout:g} s. "
65
+ + action.hint,
66
+ ) from None
67
+ await listener.wait_for(action.ended)
68
+ ended = True
69
+ except ConnectionError as exc:
70
+ ended = True
71
+ raise CommandFailed(CompletedStatus.ERROR, str(exc)) from exc
72
+ except asyncio.CancelledError:
73
+ if not ended:
74
+ await asyncio.shield(self._halt(action, listener))
75
+ raise
76
+ finally:
77
+ self._current = None
78
+
79
+ async def halt(self) -> None:
80
+ """Cut off the running action. The stop handler calls it before the engine
81
+ cancels the start."""
82
+ action = self._current
83
+ if action is None or self._halted:
84
+ return
85
+ self._halted = True
86
+ with contextlib.suppress(ConnectionError):
87
+ await self._connection.send(action.halt)
88
+
89
+ async def _halt(self, action: Action, listener: Listener) -> None:
90
+ if not self._halted:
91
+ self._halted = True
92
+ with contextlib.suppress(ConnectionError):
93
+ await self._connection.send(action.halt)
94
+ with contextlib.suppress(TimeoutError, ConnectionError):
95
+ async with asyncio.timeout(HALT_TIMEOUT):
96
+ await listener.wait_for(action.ended)
@@ -0,0 +1,197 @@
1
+ """The connection of the MMDAgent-EX components to one running MMDAgent-EX.
2
+
3
+ MMDAgent-EX serves its message bus over TCP through Plugin_Remote, with these lines in
4
+ the content's .mdf::
5
+
6
+ Plugin_Remote_EnableServer=true
7
+ Plugin_Remote_ListenPort=50001
8
+
9
+ Each line the adapter sends becomes a message inside MMDAgent-EX, and every message on
10
+ MMDAgent-EX's bus comes back as a line, so the components see the events of what they
11
+ asked for, such as ``SYNTH_EVENT_STOP|0`` after ``SYNTH_START|0|...``.
12
+
13
+ The components of one MMDAgent-EX share one ``MMDAgentExConnection``, a ``Resource`` the
14
+ engine opens before the first of them connects. It keeps trying to reach MMDAgent-EX
15
+ every ``retry`` seconds, so the adapter and MMDAgent-EX start in any order. While it is
16
+ not connected it raises ERROR, which every component that uses it reports, and it clears
17
+ the error once MMDAgent-EX answers.
18
+
19
+ A component that waits for an event opens a ``Listener`` with ``listen()`` before it
20
+ sends its message, and reads the lines that arrive after that in their order. A lost
21
+ connection ends every wait with ``ConnectionError``.
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ import asyncio
27
+ import contextlib
28
+ import logging
29
+ from collections.abc import Iterator
30
+
31
+ from openrois.components.core import Resource
32
+ from openrois.interfaces.common import ComponentStatus
33
+
34
+ logger = logging.getLogger(__name__)
35
+
36
+ #: The longest line read from MMDAgent-EX, in bytes. Longer lines end the connection.
37
+ LINE_LIMIT = 1024 * 1024
38
+
39
+
40
+ def message_field(text: str) -> str:
41
+ """Text made safe for one field of a message: no field separator, no line break.
42
+
43
+ MMDAgent-EX separates the fields of a message with ``|`` and messages with a line
44
+ break, so both become spaces.
45
+ """
46
+ return " ".join(text.replace("|", " ").split())
47
+
48
+
49
+ class Listener:
50
+ """The lines MMDAgent-EX sends after the listener opened, in their order."""
51
+
52
+ def __init__(self) -> None:
53
+ self._queue: asyncio.Queue[str | BaseException] = asyncio.Queue()
54
+
55
+ def put(self, item: str | BaseException) -> None:
56
+ self._queue.put_nowait(item)
57
+
58
+ async def get(self) -> str:
59
+ """The next line.
60
+
61
+ Raises:
62
+ ConnectionError: The connection to MMDAgent-EX was lost meanwhile.
63
+ """
64
+ item = await self._queue.get()
65
+ if isinstance(item, BaseException):
66
+ raise item
67
+ return item
68
+
69
+ async def wait_for(self, *messages: str) -> str:
70
+ """Skip lines until one of ``messages`` arrives, and return it.
71
+
72
+ Raises:
73
+ ConnectionError: The connection to MMDAgent-EX was lost meanwhile.
74
+ """
75
+ while True:
76
+ line = await self.get()
77
+ if line in messages:
78
+ return line
79
+
80
+
81
+ class MMDAgentExConnection(Resource):
82
+ """One TCP connection to the Plugin_Remote server of one MMDAgent-EX.
83
+
84
+ Args:
85
+ host: The host MMDAgent-EX runs on.
86
+ port: ``Plugin_Remote_ListenPort`` of the content.
87
+ retry: Seconds between two attempts to reach MMDAgent-EX.
88
+ """
89
+
90
+ def __init__(self, host: str = "127.0.0.1", port: int = 50001, *, retry: float = 3.0) -> None:
91
+ self.host = host
92
+ self.port = port
93
+ self.retry = retry
94
+ self._writer: asyncio.StreamWriter | None = None
95
+ self._listeners: set[Listener] = set()
96
+ self._task: asyncio.Task[None] | None = None
97
+ self._connected = asyncio.Event()
98
+
99
+ @property
100
+ def address(self) -> str:
101
+ return f"{self.host}:{self.port}"
102
+
103
+ @property
104
+ def is_connected(self) -> bool:
105
+ return self._writer is not None
106
+
107
+ async def open(self) -> None:
108
+ self.raise_status(ComponentStatus.ERROR, f"Not connected to MMDAgent-EX at {self.address}")
109
+ self._task = asyncio.create_task(self._run(), name=f"mmdagent-ex {self.address}")
110
+
111
+ async def close(self) -> None:
112
+ task, self._task = self._task, None
113
+ if task is not None:
114
+ task.cancel()
115
+ with contextlib.suppress(asyncio.CancelledError):
116
+ await task
117
+
118
+ async def wait_connected(self, timeout: float | None = None) -> None:
119
+ """Wait until the connection is up. For tests and start-up scripts."""
120
+ async with asyncio.timeout(timeout):
121
+ await self._connected.wait()
122
+
123
+ async def send(self, message: str) -> None:
124
+ """Send one message to MMDAgent-EX.
125
+
126
+ Raises:
127
+ ConnectionError: MMDAgent-EX is not connected.
128
+ ValueError: The message holds a line break.
129
+ """
130
+ if "\n" in message or "\r" in message:
131
+ raise ValueError("A message to MMDAgent-EX must be one line")
132
+ writer = self._writer
133
+ if writer is None:
134
+ raise ConnectionError(f"Not connected to MMDAgent-EX at {self.address}")
135
+ logger.debug("-> %s", message)
136
+ writer.write(message.encode("utf-8") + b"\n")
137
+ await writer.drain()
138
+
139
+ @contextlib.contextmanager
140
+ def listen(self) -> Iterator[Listener]:
141
+ """A listener for the lines that arrive while the block runs."""
142
+ listener = Listener()
143
+ self._listeners.add(listener)
144
+ try:
145
+ yield listener
146
+ finally:
147
+ self._listeners.discard(listener)
148
+
149
+ # -- Internals ---------------------------------------------------------------------
150
+
151
+ async def _run(self) -> None:
152
+ reported = False
153
+ while True:
154
+ try:
155
+ reader, writer = await asyncio.open_connection(
156
+ self.host, self.port, limit=LINE_LIMIT
157
+ )
158
+ except OSError as exc:
159
+ if not reported:
160
+ logger.warning(
161
+ "No MMDAgent-EX at %s (%s). Trying again every %.1f s",
162
+ self.address,
163
+ exc.strerror or exc,
164
+ self.retry,
165
+ )
166
+ reported = True
167
+ await asyncio.sleep(self.retry)
168
+ continue
169
+ reported = False
170
+ logger.info("Connected to MMDAgent-EX at %s", self.address)
171
+ self._writer = writer
172
+ self._connected.set()
173
+ self.clear_status()
174
+ reason = "MMDAgent-EX closed the connection"
175
+ try:
176
+ while line := await reader.readline():
177
+ self._dispatch(line.decode("utf-8", errors="replace").rstrip("\r\n"))
178
+ except (OSError, ValueError) as exc:
179
+ reason = f"The connection to MMDAgent-EX failed: {exc}"
180
+ finally:
181
+ self._writer = None
182
+ self._connected.clear()
183
+ writer.close()
184
+ with contextlib.suppress(Exception):
185
+ await writer.wait_closed()
186
+ for listener in self._listeners:
187
+ listener.put(ConnectionError(reason))
188
+ logger.warning("%s. Trying again every %.1f s", reason, self.retry)
189
+ self.raise_status(ComponentStatus.ERROR, f"{reason} ({self.address})")
190
+ await asyncio.sleep(self.retry)
191
+
192
+ def _dispatch(self, line: str) -> None:
193
+ if not line:
194
+ return
195
+ logger.debug("<- %s", line)
196
+ for listener in self._listeners:
197
+ listener.put(line)
@@ -0,0 +1,113 @@
1
+ """Reaction for an MMDAgent-EX virtual avatar.
2
+
3
+ ``reaction_ref`` names a reaction of the settings, each a motion file (.vmd) of the
4
+ content. ``start`` plays it once on the virtual avatar and ends when it ends: it sends
5
+ ``MOTION_ADD|<model>|openrois_reaction|<file>|<PART or FULL>|ONCE`` and completes OK on
6
+ ``MOTION_EVENT_DELETE|<model>|openrois_reaction``, which MMDAgent-EX sends when a motion
7
+ played once is over. ``stop``, or a new ``start``, ends it with
8
+ ``MOTION_DELETE|<model>|openrois_reaction``, and the start ends with ABORT.
9
+
10
+ The reaction plays on top of what the content's script plays, such as a looping idle
11
+ motion: a PART motion moves only the bones it has keys for. MMDAgent-EX reads the file
12
+ relative to the content's folder.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from collections.abc import Mapping
18
+ from dataclasses import dataclass
19
+ from typing import Any, Literal
20
+
21
+ from openrois.components.core import CommandFailed, Component, command, component, query
22
+ from openrois.interfaces.components import REACTION_PROFILE
23
+ from openrois.interfaces.service import CompletedStatus
24
+
25
+ from openrois_adapter_mmdagent_ex.components._command import Action, ActionRunner
26
+ from openrois_adapter_mmdagent_ex.components.connection import MMDAgentExConnection, message_field
27
+
28
+ #: The motion alias of the reaction in MMDAgent-EX.
29
+ MOTION_ALIAS = "openrois_reaction"
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class Motion:
34
+ """One reaction: a motion file of the content, and how it plays.
35
+
36
+ ``PART`` moves only the bones the file has keys for, over the virtual avatar's other
37
+ motions. ``FULL`` moves every bone.
38
+ """
39
+
40
+ file: str
41
+ mode: Literal["PART", "FULL"] = "PART"
42
+
43
+
44
+ @component(REACTION_PROFILE)
45
+ class MMDAgentExReaction(Component):
46
+ """Reaction of one MMDAgent-EX virtual avatar: motions played once.
47
+
48
+ Args:
49
+ connection: The connection to MMDAgent-EX, shared with the other components.
50
+ model: The model alias of the virtual avatar in the content, ``0`` in the Example.
51
+ motions: The reactions by name, in order. The first is the default.
52
+ start_timeout: How long a start waits for MMDAgent-EX to begin the motion.
53
+ """
54
+
55
+ def __init__(
56
+ self,
57
+ connection: MMDAgentExConnection,
58
+ model: str,
59
+ motions: Mapping[str, Motion],
60
+ *,
61
+ start_timeout: float = 10.0,
62
+ ) -> None:
63
+ if not motions:
64
+ raise ValueError("Reaction needs at least one motion")
65
+ self._connection = self.uses(connection)
66
+ self._model = model
67
+ self._motions = dict(motions)
68
+ self._runner = ActionRunner(connection, start_timeout)
69
+ default = next(iter(self._motions))
70
+ profile = type(self).rois_profile()
71
+ profile = profile.model_copy(
72
+ update={
73
+ "parameter_profiles": [
74
+ p.model_copy(update={"default_value": default})
75
+ if p.name == "reaction_ref"
76
+ else p
77
+ for p in profile.parameter_profiles
78
+ ]
79
+ }
80
+ )
81
+ vars(self)["rois_profile"] = lambda: profile
82
+
83
+ @query("available_reactions")
84
+ async def available_reactions(self) -> dict[str, object]:
85
+ return {"available_reactions": list(self._motions)}
86
+
87
+ @command("set_parameter")
88
+ async def check(self, values: Mapping[str, Any]) -> None:
89
+ reaction = values.get("reaction_ref")
90
+ if reaction is not None and str(reaction) not in self._motions:
91
+ raise ValueError(f"No reaction is named {reaction!r}. See available_reactions")
92
+
93
+ @command("start")
94
+ async def start(self) -> None:
95
+ name = str(self.parameters.get("reaction_ref", next(iter(self._motions))))
96
+ motion = self._motions.get(name)
97
+ if motion is None:
98
+ raise CommandFailed(CompletedStatus.ERROR, f"No reaction is named {name!r}")
99
+ file = message_field(motion.file)
100
+ model = self._model
101
+ await self._runner.run(
102
+ Action(
103
+ start=f"MOTION_ADD|{model}|{MOTION_ALIAS}|{file}|{motion.mode}|ONCE",
104
+ started=f"MOTION_EVENT_ADD|{model}|{MOTION_ALIAS}",
105
+ ended=f"MOTION_EVENT_DELETE|{model}|{MOTION_ALIAS}",
106
+ halt=f"MOTION_DELETE|{model}|{MOTION_ALIAS}",
107
+ hint=f"Is {file!r} a motion file of the content, and {model!r} its model?",
108
+ )
109
+ )
110
+
111
+ @command("stop")
112
+ async def stop(self) -> None:
113
+ await self._runner.halt()
@@ -0,0 +1,134 @@
1
+ """SpeechSynthesis for an MMDAgent-EX virtual avatar.
2
+
3
+ ``start`` speaks ``speech_text`` with the voice ``character`` and ends when the voice
4
+ ends: it sends ``SYNTH_START|<model>|<voice>|<text>`` and completes OK on
5
+ ``SYNTH_EVENT_STOP|<model>``. The virtual avatar moves its lips to the voice, as MMDAgent-EX
6
+ does for every speech. ``ssml_text`` is spoken as its plain text when ``speech_text`` is
7
+ empty. ``stop``, or a new ``start``, cuts the voice off with ``SYNTH_STOP|<model>``, and
8
+ the start ends with ABORT.
9
+
10
+ The voices are the voice names of the content, defined in its .ojt file for Open JTalk
11
+ (Japanese, such as ``mei_voice_normal``) and its .fph file for FLite+HTS_Engine
12
+ (English, such as ``slt_voice_normal``). The adapter cannot ask MMDAgent-EX for them, so
13
+ they come from the settings, each with its language. ``character`` ``default`` is the
14
+ first voice of ``language``. ``volume`` is stored but not applied: MMDAgent-EX has no
15
+ volume per speech.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import re
21
+ from collections.abc import Mapping
22
+ from typing import Any
23
+
24
+ from openrois.components.core import CommandFailed, Component, command, component, query
25
+ from openrois.interfaces.components import SPEECH_SYNTHESIS_PROFILE
26
+ from openrois.interfaces.profiles import HRIComponentProfile
27
+ from openrois.interfaces.service import CompletedStatus
28
+
29
+ from openrois_adapter_mmdagent_ex.components._command import Action, ActionRunner
30
+ from openrois_adapter_mmdagent_ex.components.connection import MMDAgentExConnection, message_field
31
+
32
+ #: The ``character`` value that stands for the first voice of the language.
33
+ DEFAULT_CHARACTER = "default"
34
+
35
+
36
+ def _with_defaults(profile: HRIComponentProfile, **defaults: str) -> HRIComponentProfile:
37
+ return profile.model_copy(
38
+ update={
39
+ "parameter_profiles": [
40
+ p.model_copy(update={"default_value": defaults[p.name]})
41
+ if p.name in defaults
42
+ else p
43
+ for p in profile.parameter_profiles
44
+ ]
45
+ }
46
+ )
47
+
48
+
49
+ @component(SPEECH_SYNTHESIS_PROFILE)
50
+ class MMDAgentExSpeechSynthesis(Component):
51
+ """SpeechSynthesis of one MMDAgent-EX virtual avatar, with lip sync.
52
+
53
+ Args:
54
+ connection: The connection to MMDAgent-EX, shared with the other components.
55
+ model: The model alias of the virtual avatar in the content, ``0`` in the Example.
56
+ voices: The voice names of the content, each with its ISO 639-1 language, in
57
+ order of preference.
58
+ start_timeout: How long a start waits for MMDAgent-EX to begin speaking.
59
+ """
60
+
61
+ def __init__(
62
+ self,
63
+ connection: MMDAgentExConnection,
64
+ model: str,
65
+ voices: Mapping[str, str],
66
+ *,
67
+ start_timeout: float = 10.0,
68
+ ) -> None:
69
+ if not voices:
70
+ raise ValueError("SpeechSynthesis needs at least one voice")
71
+ self._connection = self.uses(connection)
72
+ self._model = model
73
+ self._voices = dict(voices)
74
+ self._runner = ActionRunner(connection, start_timeout)
75
+ # The engine reads the profile from the component, so this instance serves the
76
+ # language of its first voice as the default.
77
+ first_language = next(iter(self._voices.values()))
78
+ profile = _with_defaults(type(self).rois_profile(), language=first_language)
79
+ vars(self)["rois_profile"] = lambda: profile
80
+
81
+ @query("synthesizable_languages")
82
+ async def synthesizable_languages(self) -> dict[str, object]:
83
+ return {"languages": sorted(set(self._voices.values()))}
84
+
85
+ @query("available_voices")
86
+ async def available_voices(self) -> dict[str, object]:
87
+ return {"characters": list(self._voices)}
88
+
89
+ @command("set_parameter")
90
+ async def check(self, values: Mapping[str, Any]) -> None:
91
+ language = values.get("language")
92
+ if language is not None and language not in self._voices.values():
93
+ raise ValueError(f"No voice speaks {language!r}. See synthesizable_languages")
94
+ character = values.get("character")
95
+ if character is not None and character not in (DEFAULT_CHARACTER, *self._voices):
96
+ raise ValueError(f"No voice is named {character!r}. See available_voices")
97
+
98
+ @command("start")
99
+ async def start(self) -> None:
100
+ text = self._text()
101
+ if not text:
102
+ raise CommandFailed(CompletedStatus.ERROR, "speech_text is empty")
103
+ voice = self._voice()
104
+ await self._runner.run(
105
+ Action(
106
+ start=f'SYNTH_START|{self._model}|{voice}|"{text}"',
107
+ started=f"SYNTH_EVENT_START|{self._model}",
108
+ ended=f"SYNTH_EVENT_STOP|{self._model}",
109
+ halt=f"SYNTH_STOP|{self._model}",
110
+ hint=f"Is {voice!r} a voice of the content, and {self._model!r} its model?",
111
+ )
112
+ )
113
+
114
+ @command("stop")
115
+ async def stop(self) -> None:
116
+ await self._runner.halt()
117
+
118
+ def _voice(self) -> str:
119
+ character = str(self.parameters.get("character", DEFAULT_CHARACTER))
120
+ if character != DEFAULT_CHARACTER:
121
+ return character
122
+ language = self.parameters.get("language")
123
+ for voice, voice_language in self._voices.items():
124
+ if voice_language == language:
125
+ return voice
126
+ return next(iter(self._voices))
127
+
128
+ def _text(self) -> str:
129
+ """The text to speak, in one message field: speech_text, or ssml_text's text."""
130
+ text = str(self.parameters.get("speech_text", ""))
131
+ if not text.strip():
132
+ text = re.sub(r"<[^>]*>", " ", str(self.parameters.get("ssml_text", "")))
133
+ # The text goes in double quotes, so that MMDAgent-EX keeps its spaces.
134
+ return message_field(text).replace('"', "'")
@@ -0,0 +1,37 @@
1
+ """SystemInformation for MMDAgent-EX.
2
+
3
+ ``engine_status`` reports the status of the engine that hosts the component, and when
4
+ the component connected. A virtual avatar has no place in a room, so the component
5
+ does not serve ``robot_position``. While MMDAgent-EX is not connected, this component
6
+ reports ERROR like the others, and the engine refuses its queries.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from datetime import UTC, datetime
12
+
13
+ from openrois.components.core import Component, component, query
14
+ from openrois.interfaces.components import SYSTEM_INFORMATION_PROFILE
15
+
16
+ from openrois_adapter_mmdagent_ex.components.connection import MMDAgentExConnection
17
+
18
+
19
+ @component(SYSTEM_INFORMATION_PROFILE)
20
+ class MMDAgentExSystemInformation(Component):
21
+ """SystemInformation of one MMDAgent-EX.
22
+
23
+ Args:
24
+ connection: The connection to MMDAgent-EX, shared with the other components.
25
+ """
26
+
27
+ def __init__(self, connection: MMDAgentExConnection) -> None:
28
+ self._connection = self.uses(connection)
29
+ self._started = datetime.now(UTC)
30
+
31
+ async def connect(self) -> None:
32
+ self._started = datetime.now(UTC)
33
+
34
+ @query("engine_status")
35
+ async def engine_status(self) -> dict[str, object]:
36
+ """The status of the engine, and when the component connected."""
37
+ return {"operable_time": self._started, "status": self.engine_state()}
File without changes
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.5
2
+ Name: openrois-adapter-mmdagent-ex
3
+ Version: 0.1.0.dev1
4
+ Summary: OpenRoIS adapter for MMDAgent-EX: RoIS components for a virtual avatar
5
+ Project-URL: Homepage, https://openrois.org
6
+ Project-URL: Repository, https://github.com/openrois/openrois-adapter-mmdagent-ex
7
+ Project-URL: Issues, https://github.com/openrois/openrois-adapter-mmdagent-ex/issues
8
+ Author: Coarobo GK, OpenRoIS Community
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: openrois-components-core<0.2,>=0.1.0
14
+ Requires-Dist: openrois-engine<0.2,>=0.1.0
15
+ Requires-Dist: openrois-interfaces<0.2,>=0.1.0
16
+ Requires-Dist: pydantic>=2.10
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest-asyncio>=1.0; extra == 'dev'
19
+ Requires-Dist: pytest>=8.4; extra == 'dev'
20
+ Requires-Dist: ruff>=0.4; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # OpenRoIS Adapter for MMDAgent-EX
24
+
25
+ The [OpenRoIS](https://openrois.org) adapter for [MMDAgent-EX](https://mmdagent-ex.dev/).
26
+ It serves canonical RoIS components for a virtual avatar in a running MMDAgent-EX, so that
27
+ a service application makes the virtual avatar speak and react through an OpenRoIS gateway
28
+ with the standard RoIS interfaces, as it would a physical robot.
29
+
30
+ > [!WARNING]
31
+ > The adapter is in very early development (0.1.0.dev1, pre-alpha). The settings, the
32
+ > behaviour and the API may change at any time before 0.1.0.
33
+
34
+ [![CI](https://github.com/openrois/openrois-adapter-mmdagent-ex/actions/workflows/ci.yml/badge.svg)](https://github.com/openrois/openrois-adapter-mmdagent-ex/actions/workflows/ci.yml)
35
+ [![OMG RoIS 2.0](https://img.shields.io/badge/OMG%20RoIS-2.0-0070C0)](https://www.omg.org/spec/RoIS/2.0)
36
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-2E5C8A)](LICENSE)
37
+
38
+ ## Installation
39
+
40
+ ### Prerequisites
41
+
42
+ - [MMDAgent-EX](https://mmdagent-ex.dev/docs/build/), on Windows, macOS or Linux, with a
43
+ content such as the [Example content](https://github.com/mmdagent-ex/example).
44
+ - Python 3.12 or later.
45
+ - An [OpenRoIS gateway](https://pypi.org/project/openrois-gateway/).
46
+
47
+ ### Install the Adapter
48
+
49
+ From a clone of this repository, in a virtual environment:
50
+
51
+ ```bash
52
+ pip install -e . openrois-gateway
53
+ ```
54
+
55
+ ### Prepare the Content
56
+
57
+ The adapter talks to MMDAgent-EX through
58
+ [Plugin_Remote](https://mmdagent-ex.dev/docs/remote-tcpip/) over TCP. Turn it on in the
59
+ content's `.mdf`:
60
+
61
+ ```
62
+ Plugin_Remote_EnableServer=true
63
+ Plugin_Remote_ListenPort=50001
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ > [!CAUTION]
69
+ > On Linux, MMDAgent-EX currently exits when any Plugin_Remote client disconnects, so
70
+ > stopping or restarting the adapter stops MMDAgent-EX too. Start MMDAgent-EX again after
71
+ > the adapter.
72
+
73
+ Copy [`adapter.example.yaml`](adapter.example.yaml) to `adapter.yaml` and edit it for your
74
+ content. Then start the gateway, MMDAgent-EX with your content, and the adapter, in any
75
+ order:
76
+
77
+ ```bash
78
+ openrois-gateway
79
+ openrois-adapter-mmdagent-ex --config adapter.yaml
80
+ ```
81
+
82
+ A service application, or the
83
+ [OpenRoIS Inspector](https://github.com/openrois/openrois/tree/main/apps/inspector),
84
+ then reaches the virtual avatar through the gateway at `ws://127.0.0.1:8765`.
85
+
86
+ ### How It Talks to MMDAgent-EX
87
+
88
+ The adapter sends [messages](https://mmdagent-ex.dev/docs/messages/) such as
89
+ `SYNTH_START` and `MOTION_ADD` to MMDAgent-EX and waits for the events that answer them.
90
+ The three components share one connection, report ERROR while MMDAgent-EX does not
91
+ answer, and reconnect on their own.
92
+
93
+ > [!IMPORTANT]
94
+ > Keep the content's `.fst` free of dialogue logic that speaks on its own, or it competes
95
+ > with the OpenRoIS application for the virtual avatar.
96
+
97
+ ### Components
98
+
99
+ The adapter serves one virtual avatar under its engine id, `mmdagent-ex` by default.
100
+
101
+ | Component | Ref | In MMDAgent-EX |
102
+ |-----------|-----|----------------|
103
+ | SystemInformation | `mmdagent-ex/system_information` | `engine_status` |
104
+ | SpeechSynthesis | `mmdagent-ex/speech_synthesis` | `start` speaks `speech_text` with the voice `character`, with lip sync, until the speech ends. `language` picks the first voice of a language. `available_voices` and `synthesizable_languages` list the voices of the settings |
105
+ | Reaction | `mmdagent-ex/reaction` | `start` plays the motion named by `reaction_ref` once, until it ends. `available_reactions` lists the motions of the settings |
106
+
107
+ SpeechSynthesis and Reaction are actuation components: one application binds each at a
108
+ time. `stop`, or a new `start`, cuts the speech or the motion off, and the start ends
109
+ with ABORT. A voice or a motion file that the content does not have gets no answer from
110
+ MMDAgent-EX, so that start ends with ERROR after `connection.start_timeout` seconds.
111
+
112
+ > [!NOTE]
113
+ > MMDAgent-EX has no volume per speech, so SpeechSynthesis stores `volume` but does not
114
+ > apply it. A virtual avatar has no place in a room, so SystemInformation does not serve
115
+ > `robot_position`. An application builds its interface from the profile, which lists
116
+ > only what is served.
117
+
118
+ ### Configuration
119
+
120
+ The settings come from a YAML file named by `--config` or `OPENROIS_ADAPTER_CONFIG`.
121
+ [`adapter.example.yaml`](adapter.example.yaml) holds every setting, with values that fit
122
+ the Example content: copy it to `adapter.yaml`, which git ignores. The
123
+ `OPENROIS_ADAPTER_*` environment variables and the flags `--gateway-url`, `--engine-id`,
124
+ `--robot-address` and `--log-level` override the four common settings.
125
+
126
+ | Setting | Default | Meaning |
127
+ |---------|---------|---------|
128
+ | `gateway_url` | `ws://127.0.0.1:8765` | The gateway to connect to |
129
+ | `engine_id` | `mmdagent-ex` | The first part of every component ref |
130
+ | `robot_address` | `127.0.0.1:50001` | Where MMDAgent-EX's Plugin_Remote listens, `host:port` |
131
+ | `log_level` | `info` | `debug` logs every message to and from MMDAgent-EX |
132
+ | `model` | `0` | The model alias of the virtual avatar in the content's `.fst` |
133
+ | `connection.retry` | `3.0` | Seconds between two attempts to reach MMDAgent-EX |
134
+ | `connection.start_timeout` | `10.0` | Seconds a start waits for MMDAgent-EX to begin |
135
+ | `speech_synthesis.voices` | the Example's `mei_voice_*` and `slt_voice_*` | Voice names of the content (`.ojt`, `.fph`), each with its language |
136
+ | `reaction.motions` | `bow`, `smile` | Reactions by name: a `file` relative to the content, and `mode` `PART` or `FULL` |
137
+
138
+ ## Support
139
+
140
+ Report a bug or ask a question in the
141
+ [issues](https://github.com/openrois/openrois-adapter-mmdagent-ex/issues). For OpenRoIS
142
+ itself, see [openrois.org](https://openrois.org).
143
+
144
+ ## Roadmap
145
+
146
+ - A fix upstream for the disconnect crash of Plugin_Remote on Linux.
147
+ - A first alpha, 0.1.0a1, on PyPI.
148
+ - More RoIS components for a virtual avatar, such as gestures and facial expressions.
149
+
150
+ ## Contributing
151
+
152
+ Contributions are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) covers the license of
153
+ contributions, the checks to run and the tests against a real MMDAgent-EX.
154
+
155
+ ## License
156
+
157
+ Copyright 2026 Coarobo GK and the OpenRoIS Community. Licensed under the
158
+ [Apache License, Version 2.0](LICENSE); the attribution is in [NOTICE](NOTICE).
159
+
160
+ ## Project Status
161
+
162
+ Pre-alpha. The components pass their tests against a real MMDAgent-EX with the Example
163
+ content on Linux; Windows and macOS are not tried yet. That run confirmed how MMDAgent-EX
164
+ answers speeches and motions, including that a voice or a motion file the content lacks
165
+ gets no answer at all.
166
+
167
+ Still to check: that an English text in double quotes keeps its spaces when spoken, and
168
+ that MMDAgent-EX keeps serving the adapter after another Plugin_Remote client leaves.
@@ -0,0 +1,16 @@
1
+ openrois_adapter_mmdagent_ex/__init__.py,sha256=4GZlm8Q10_Pdp398gA6anJFdvJydDj3eMqpH1ZaME_Y,249
2
+ openrois_adapter_mmdagent_ex/__main__.py,sha256=vUcEVWIbel-viN3uQxxJw254Za0lUACniLfMy0cdrV0,89
3
+ openrois_adapter_mmdagent_ex/cli.py,sha256=HsQTb-BBk53u2uxISedHLM3kWqDHLfj1EPOYRgujs0c,6893
4
+ openrois_adapter_mmdagent_ex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ openrois_adapter_mmdagent_ex/components/__init__.py,sha256=OlgTPzFu2DeU7mTjjVzPhidj59coyitY5cvVF7ReZCo,1465
6
+ openrois_adapter_mmdagent_ex/components/_command.py,sha256=C4IEQpPmSzbTBaO4zjqF0K3F28Q9JRIdwXOAVyinJsk,3598
7
+ openrois_adapter_mmdagent_ex/components/connection.py,sha256=CajvoDusoS2bj10hi-t73Du0Itd4_AXlO9gu6yfHljc,7264
8
+ openrois_adapter_mmdagent_ex/components/reaction.py,sha256=gSUvfBwBXkxQXKOZqzQYinRmLs-2n5R_uEvJMqx9HaI,4479
9
+ openrois_adapter_mmdagent_ex/components/speech_synthesis.py,sha256=cmy4uR_cNon_7DPNEIByyBmHHA7ZO1l1mj2w8XN93cE,5750
10
+ openrois_adapter_mmdagent_ex/components/system_information.py,sha256=MMYjoaRUdHYj1_T1NWv2G-Es2LuzCSKuxjLp-LGhxdM,1370
11
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/METADATA,sha256=sxs-8mfKbrDadZbSjRSFVZ7gWQPTrAzQ8psUAV_xfbc,7514
12
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
13
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/entry_points.txt,sha256=iNLG3idkkVzKZ9v-nyxH5uOdkzlUAMwN0dHQsgi97C4,87
14
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
15
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/licenses/NOTICE,sha256=jW3Dkc4uGdKvFwhMLzHMz-85XjNcDfFUIEQG4840DN4,357
16
+ openrois_adapter_mmdagent_ex-0.1.0.dev1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ openrois-adapter-mmdagent-ex = openrois_adapter_mmdagent_ex.cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ OpenRoIS
2
+ Copyright 2026 Coarobo GK and the OpenRoIS Community
3
+
4
+ OpenRoIS is developed by Coarobo GK (https://coarobo.com/)
5
+ and the OpenRoIS Community (https://openrois.org/).
6
+
7
+ OpenRoIS is a trademark of Coarobo GK.
8
+
9
+ This adapter drives MMDAgent-EX (https://mmdagent-ex.dev/), a separate project under
10
+ its own license. It contains none of MMDAgent-EX's code.