CMLabs · Psyclone AIOS

11. Services & Interfaces

How the outside world talks to a Psyclone system: services process external requests, interfaces bind them to network ports and protocols.

The model

Two elements cooperate to expose a Psyclone system on the network:

  • A service is the thing that handles external requests — PsyProbe's web handler and the console are services.
  • An interface is a network listener — a port with a protocol (HTTP, Telnet, Message, RAW; TCP by default, UDP with ip="UDP") — that forwards connections to a service.

Several interfaces can share one port: the protocol is auto-detected from the first bytes of a connection, and if nothing is detected within the timeout, the default="yes" interface is assumed.

Built-in services

Unless disabled, every system implicitly gets PsyProbe and the console, as if the spec contained:

<service name="PsyProbe" root="../html" />
<service name="Console" />
<interface name="PsyProbe" protocol="HTTP"   service="PsyProbe" />
<interface name="Console"  protocol="Telnet" service="Console" />

Disable either by pointing the protocol at no service:

<interface protocol="HTTP"   service="none" />
<interface protocol="Telnet" service="none" />

Custom services

A custom service is the system's front door for something outside it: a browser, a phone app, a sensor, another program. It is declared like a small module, and it owns the subscription declared inside it: its <post>s say what incoming data is posted as, and its <trigger>s say what is sent back out. There is no crank and no function. The service does the network work, so no module ever opens or manages a socket. An <interface> binds the service to a port and protocol.

Status. Shipped HTTP (file hosting, ingestion, request/reply), WebSocket, UDP and TCP Message services. Custom Telnet services are not wired yet, and instances is parsed but not acted on. Engine tests: test=httpservice, test=wsservice, test=udpservice.

Names, never raw types

An edge client never sets a message type. It names one of the service's posts, exactly as a module's postOutputMessage("Name", msg) does, and the service applies the type declared for that post. On the way out, every message carries the name of the service trigger that fired. The spec alone decides what enters the system, the client never needs the system's numeric type ids, and the type hierarchy can be reorganised without touching any client.

EntryDirectionMeaning
PsyPostclient → systemName of the service <post> to use. Optional when the service declares exactly one post. An unknown name is dropped. Any raw type the client set is overwritten.
PsyTriggersystem → clientName of the service <trigger> that matched the outgoing message.
PsyDeviceclient → systemOptional stable device id (UDP and Message). Keeps one identity when the device's address changes.
PsyServiceConnectionbothStamped on every incoming message (WebSocket connection or UDP peer). Keep it on a reply to send it back to that client; leave it out to send to every client of the service.
PsyPeerAddressclient → systemUDP only: the sender's current ip:port, for logging and diagnostics.
PsyServiceclient → systemName of the service the message came in through.
PsyServiceRequestIDbothHTTP request/reply only: correlates a reply with its waiting request. Echo it on the reply (a pass-through module keeps it automatically).

1. File hosting

A service with rootdir serves files, optionally under a URL prefix given by subdir. Paths cannot escape the root.

<service name="Site" rootdir="../site" subdir="files" />
<interface name="SiteIf" port="8080" protocol="HTTP" service="Site" />
<!-- http://host:8080/files/index.html  ->  ../site/index.html -->

For a web UI that sits next to PsyProbe (and can use the PsyProbe API), an <alias> in <psyprobe> is often simpler; see PsyProbe.

2. HTTP ingestion — post it, answer at once

A service with a <post> and no <trigger> is an ingestion service. Each request is posted and answered 200 immediately, so a sender never waits for the system to process its data. Use it for uploads, telemetry and webhooks.

<service name="Telemetry">
  <post name="Report" type="Device.Telemetry.Report" />
</service>
<interface name="TelemetryIf" port="8081" protocol="HTTP" service="Telemetry" />

<whiteboard name="Reports">
  <trigger name="In" type="Device.Telemetry.Report" />
</whiteboard>
$ curl "http://host:8081/report?battery=71&network=4g"
{ "errorcode":0, "text":"accepted" }

The request becomes a DataMessage with HTTP_OPERATION, REQUEST and URI entries, one string entry per header and per query parameter, and the body (form fields as entries; JSON, XML and text bodies as strings, other content types as binary data). With several posts declared, choose one with a PsyPost query parameter.

3. HTTP request/reply — post it, wait for the answer

A service with a <post> and a <trigger> is a request/reply service. The request is posted with a PsyServiceRequestID; the first trigger message that echoes that id (or, if none does, the oldest waiting request's) becomes the HTTP reply. No reply within the service's timeout (default 5000 ms) returns 504 Gateway Timeout instead of leaving the client hanging.

<service name="Ask" timeout="3000">
  <post name="Question" type="Web.Ask.Question" />
  <trigger name="Answer" type="Web.Ask.Answer" />
</service>
<interface name="AskIf" port="8082" protocol="HTTP" service="Ask" />

<module name="Answerer">
  <crank name="AnswerCrank" function="MyLib::Answer" />
  <trigger name="Q" type="Web.Ask.Question" />
  <post name="A" type="Web.Ask.Answer" />
</module>

The reply uses the same conventions as a catalog answering a query (/api/v2/systems/local/query): an optional ResultCode (an HTTP_* status id, default HTTP_OK), an optional MIMETYPE, and one content entry, JSON, XML, HTML, TEXT or BINARY. With none of those, the whole reply message is returned as JSON.

int8 Answer(PsyAPI* api) {
    const char* trigger;
    while (api->shouldContinue()) {
        DataMessage* q = api->waitForNewMessage(100, trigger);
        if (!q) continue;
        DataMessage* a = new DataMessage();
        int64 id = 0;
        if (q->getInt("PsyServiceRequestID", id))
            a->setInt("PsyServiceRequestID", id);      // correlate with the waiting request
        const char* text = q->getString("q");          // ?q=... from the URL
        a->setString("JSON", utils::StringFormat("{ \"answer\": \"%s\" }", text ? text : "").c_str());
        api->postOutputMessage("A", a);
    }
    return 0;
}
$ curl "http://host:8082/ask?q=hello"
{ "answer": "hello" }

4. Streams — WebSocket and UDP

For independent flows in both directions (a phone streaming audio up while playout, status and events come down) a service has posts and triggers but is not request/reply: anything coming in becomes a post, anything triggered is sent out. One service can be reached over WebSocket and UDP at the same time, and both can use the same port number as its HTTP interface:

<service name="Phone">
  <post name="AudioFrame"  type="Mimir.Audio.Frame" />
  <post name="DeviceEvent" type="Mimir.Device.Event" />
  <trigger name="Playout" type="Mimir.Playout.Chunk" />
  <trigger name="Status"  type="Mimir.Status.Line" />
</service>
<!-- WebSocket arrives as an HTTP upgrade, so it uses the HTTP interface -->
<interface name="PhoneTCP" port="18600" protocol="HTTP" service="Phone" />
<interface name="PhoneUDP" port="18600" ip="UDP" protocol="Message" service="Phone" />
  • WebSocket. HTTP and WebSocket share the interface; the upgrade is decided per connection. A binary frame that is a DataMessage is posted as it stands, keeping its timestamps, serials and tags (it still needs PsyPost). A text frame arrives as a Text entry, any other binary frame as a Content entry. Outgoing, a message with a Text entry goes out as a text frame; anything else goes out as the whole DataMessage in one binary frame.
  • UDP. Each datagram carries one DataMessage (under 64 KB) and becomes a post. Replies leave from the service's own port, which is what NAT and mobile networks let back through to a device. UDP has no connection, so the service keeps a peer per device: the key is PsyDevice if the client sends one, otherwise the source address. Every datagram refreshes the peer's address, so a phone that moves from Wi-Fi to 4G is followed and the next reply goes to its new address.
  • Packed frames. A client may send the packed wire form of a DataMessage (CMSDK DataMessage::toPacked(), Kotlin toPackedBytes()) over UDP, Message or a WebSocket binary frame: the same content in about a third of the bytes (a phone audio frame with 80 B of Opus: 637 B regular, 253 B packed). The service turns it back into a regular message, so modules see no difference, and answers that client in the packed form until it sends a regular message again.
  • Keepalive. A client may send a keepalive: a message with PsyKeepAlive (a sequence number) and PsyPost=PsyKeepAlive. The service refreshes the peer, so the device's address and the UDP path through NAT stay current. It then answers at once on the same connection, in the same form, with the sequence number, PsyKeepAliveReply=1, PsyPacked=1, PsyVersion and (from 2.3.2) PsyFeatures, a comma-separated list of what the service supports (keepalive,packed), and posts nothing into the system. The client libraries send keepalives to measure the round-trip time, to notice a dead connection and to find out that the service reads the packed form. An older Psyclone without this support drops the keepalive, because no post has that name, but still refreshes the peer.
  • Peers expire. A UDP peer that sends nothing for four leases is forgotten: it gets no more broadcast triggers until it sends again. The lease is <service lease="30000"> in milliseconds (so two minutes of silence). Expiry is off unless the spec sets lease: the default 0 keeps peers for ever, as before 2.3.2, so older UDP listeners that send no keepalive keep getting broadcasts. The client libraries send a keepalive every 15 s, which keeps a live client known. A TCP Message peer is removed when a send to it fails.
  • Routing out. A triggered message that carries PsyServiceConnection goes to that connection or peer only; without it, it goes to every WebSocket connection and UDP peer of the service. A module that simply passes an incoming message through keeps the entry, so replies go back where the request came from. A trigger that echoes the PsyServiceRequestID of an HTTP request still waiting answers that request instead, so one service can serve HTTP request/reply and streams side by side.

A browser client. A text frame cannot name a post, so it always uses the service's only post: give plain-text clients a single-post service, and use binary DataMessage frames when a client needs several posts.

<service name="Chat">
  <post name="Say" type="Chat.Say" />
  <trigger name="Heard" type="Chat.Heard" />
</service>
<interface name="ChatIf" port="8083" protocol="HTTP" service="Chat" />
const ws = new WebSocket("ws://host:8083/chat");
ws.onmessage = (e) => console.log("from system:", e.data);  // a Text entry comes back as text
ws.onopen = () => ws.send("hello");                          // posted as Chat.Say with Text="hello"

A UDP client using the CMSDK Python bindings:

import socket, cmsdk3
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
m = cmsdk3.DataMessage()
m.setString("PsyPost", "AudioFrame")   # the post's NAME, never a type
m.setString("PsyDevice", "phone-s25")  # stays the same across Wi-Fi/4G changes
m.setInt("Serial", 1)
sock.sendto(m.getBytes(), ("host", 18600))
reply = cmsdk3.DataMessage.fromBytes(sock.recvfrom(65536)[0])
print(reply.getString("PsyTrigger"))   # e.g. "Playout"

A Kotlin or Android client uses the CMSDK Kotlin codec (CMSDK/kotlin, package cmlabs.cmsdk), which writes the same bytes as the C++ library:

val m = DataMessage().setString("PsyPost", "AudioFrame").setString("PsyDevice", "phone-s25")
socket.send(DatagramPacket(m.toBytes(), m.toBytes().size, serverAddress, 18600))
val reply = DataMessage.fromBytes(packet.data, 0, packet.length)   // reply.getString("PsyTrigger")

The same from Kotlin or Android with the CMSDK Kotlin codec, in the packed form (this is how the Mimir phone app talks to its Link module):

val m = DataMessage().setString("PsyPost", "AudioFrame").setString("PsyDevice", "phone-s25")
    .setData("audio", opusFrame)
val bytes = m.toPackedBytes()                        // ~3x smaller than m.toBytes()
socket.send(DatagramPacket(bytes, bytes.size, InetSocketAddress(host, 18600)))
socket.receive(p)
val reply = DataMessage.fromBytes(p.data, 0, p.length)   // packed reply; fromBytes reads both forms
No loss recovery. Services deliver what arrives; CMSDK does not retransmit. TCP and WebSocket protect bytes only while a connection survives, and UDP datagrams can be lost or reordered. Numbering, acknowledgements and resending belong to modules (for example a link-layer module pair), which keeps them measurable and replayable like any other part of the system.

Protocol auto-detection on a shared port

Multiple interfaces can listen on the same port; each connection is sniffed and routed:

<interface name="MyWebInterface" node="Node0" port="1234" protocol="HTTP"
           service="MyWebService" timeout="3000" default="yes" />
<interface name="MyTelnet"  port="1234" protocol="Telnet"  service="MyTelnetService" />
<interface name="MyMsgLink" port="1234" protocol="Message" service="MyMsgService" />

After 3 seconds with no recognisable protocol, the default (here HTTP) interface takes the connection. Interface attributes: name (required), service (required), port (required), node, protocol, timeout, default, plus the SSL verification attributes allowselfsigned / cafile / capath (see the reference).

How clients connect

  • Browsers — hit the main port (default 10000) or a dedicated PsyProbe/HTTP interface: http://hostname:10000/.
  • Terminals — telnet to a Telnet interface for the console service.
  • Devices and apps — connect to a custom service: HTTP for uploads and request/reply, WebSocket or UDP for two-way streams (see above). They name posts and receive trigger names; they never see the system's types.
  • Programs — use a client library (below), or link CMSDK and send DataMessages to a Message interface (TCP or UDP) of a custom service, or run as an external-space component for full module semantics.

Client libraries (Kotlin/Java, Python)

Two small libraries do the client side of the conventions above for programs outside the system: they post messages by post name and hand you the messages each trigger sends by trigger name, over UDP, TCP Message (optionally TLS) or WebSocket, in the full or the packed DataMessage form. Neither needs CMSDK to be installed: each carries its own byte-exact DataMessage codec, tested against messages written by the C++ library.

  • Kotlin/Java (JVM 17+, Android 8+): com.cmlabs:psyclone-client, source in CMSDK/kotlin/client.
  • Python (3.8+, any OS, standard library only): pip install psyclone-client, source in CMSDK/python-client. Unlike cmsdk3, which runs Python cranks inside Psyclone, it is for separate programs.
# Python
from psyclone_client import PsycloneClient, DataMessage
psy = PsycloneClient.websocket("ws://host:18600/phone", device="py-1")   # or .udp(host, port), .tcp(host, port)
psy.on_trigger("Playout", lambda m: play(m.get_data("audio")))          # pushed by the system
psy.post("AudioFrame", DataMessage().set_data("audio", opus))           # into the system
answer = psy.request("Question", DataMessage().set_string("Text", "hi"), timeout=3)   # or None

// Kotlin
val psy = PsycloneClient.udp("host", 18600, device = "phone-1", options = PsycloneClient.Options().packed(true))
psy.onTrigger("Playout") { msg -> play(msg.getData("audio")) }
psy.post("AudioFrame", DataMessage().setData("audio", opus))

post() sets PsyPost (and PsyDevice when the client has a device id) and returns false while the pipe is down — nothing is queued, so reliability stays in the modules. request() adds PsyClientRequestID and waits for the reply that carries it back: the built-in Simple crank copies it; a responder that builds a new message must copy PsyClientRequestID and PsyServiceConnection from the request. TCP and WebSocket reconnect by themselves, with a growing, jittered delay. A UDP service learns a client's address from its first datagram. The Kotlin/Java library also has these, since 2.3.2:

  • a keepalive every 15 s;
  • the packed form chosen automatically, once the service shows it reads it;
  • dead connections detected and replaced;
  • stats(), with the round-trip time and counters for each connection.

Both libraries also have a small HTTP helper (PsycloneHttp) for request/reply over a service's HTTP interface. Their live tests use the Echo system in CMSDK/tools/client-test.xml.

Remote modules (2.3.2)

A remote module is a program on any machine, in any language with a DataMessage codec, that is a module of the system: its triggers fire it, it posts by post name, it retrieves from whiteboards and queries catalogs by the names in its spec, PsyProbe can stop and start it. It is the network, any-language version of type="external" modules (C++ on the same host, shared memory). It rides on a service: a <service> with a <modules> element is a module host, and each <module type="remote"> names its host. Inside the system the module is an ordinary component without a crank: what it posts comes from the module, so from="Asr" filters and whiteboard origins work as for a local module.

<service name="Modules">
  <modules auth="key" udp="no" lease="30000" takeover="device" maxretrieve="100"/>
</service>
<interface name="ModTCP" port="18700" protocol="Message" service="Modules" ssl="yes"/>
<interface name="ModWS"  port="18701" protocol="HTTP"    service="Modules" ssl="yes"/>

<!-- the spec is the whole contract: a process only attaches to it -->
<module name="Asr" type="remote" service="Modules">
  <trigger name="Audio" type="Mimir.Audio.Frame"/>
  <trigger name="Go" type="Psyclone.Ready"/>
  <post name="Text" type="Mimir.Asr.Text"/>
  <retrieve name="Recent" source="ConvWB" type="Mimir.Asr.Text" maxcount="10"/>
  <query name="Notes" source="NoteStore"/>
  <parameter name="Language" value="en-GB"/>
</module>

<modules> attributes:

  • auth: key (the default) — a PsyProbe 2 API key (PsyProbe, Accounts) whose account has the permission modules.attach.<Module> (or a pattern such as modules.attach.*; admins have it). The secret never travels: the process asks for a nonce (hello) and sends HMAC-SHA256(sha256hex(secret), "module|device|nonce"). token — a shared secret, token="..." (8 characters or more; use a %variable%). none — attaches only from the host's own machine.
  • udp="yes" allows module sessions over UDP. The session token then travels in clear: trusted networks only.
  • lease (ms, default 30000; 0 = never): a session the host hears nothing from for this long (frames and client keepalives count) goes offline. This is separate from the service's own lease for plain peers.
  • takeover: a second attach to a module that already has a session is allowed with the same PsyDevice or the old session as Resume (device, the default), from anyone authorised (any), or never (no: busy). The old connection is told (detached, Reason takeover).
  • maxretrieve (default 100): the most messages one remote retrieve returns.
  • buffer / bufferage (default 256 messages / 5000 ms; buffer="0" = off): the resume buffer of each session (below).
  • queue / queuebytes (default 1024 messages / 8 MB): each session's outbound queue (below).
  • allowdynamic="yes" lets processes create dynamic modules inside the <allow> policy; adhoc="yes" also lets declared modules make ad-hoc retrieves and queries (inside <allow>).
  • Limits: maxperconnection (8 modules on one connection), maxtriggers (64 per module), maxops (16 retrieves/queries in flight per module; more answer busy).

From the program's side (the client libraries above):

# Python
from psyclone_client import PsycloneClient, RemoteModule, Auth, DataMessage
psy = PsycloneClient.tcp("host", 18700, device="asr-box-1")
asr = RemoteModule.attach(psy, "Asr", Auth.key("psy_<id>_<secret>"))      # asr.posts, asr.triggers come from the server
asr.on_trigger("Audio", lambda m: asr.post("Text", DataMessage().set_string("Text", recognise(m))))
recent = asr.retrieve("Recent", max_count=5)                                # list of DataMessage
notes = asr.query("Notes", DataMessage().set_string("List", "1"))          # the catalog's reply
asr.on_stop(lambda reason: pause()); asr.on_start(lambda reason: resume())

// Kotlin
val asr = RemoteModule.attach(PsycloneClient.tcp("host", 18700, device = "asr-box-1"), "Asr", RemoteModule.Auth.key(apiKey))
asr.onTrigger("Audio") { msg -> asr.post("Text", DataMessage().setString("Text", recognise(msg))) }
val recent = asr.retrieve("Recent", maxCount = 5)

A refusal raises RemoteModuleError / RemoteModuleException with the host's status: denied (auth, session, a stopped module posting), unknown (no such module, post, retrieve or query), busy (already attached), timeout (no answer: an older Psyclone or a service without <modules>; a service without it answers unsupported at once), unsupported, failed. A module with a trigger on Psyclone.Ready gets it once, on its first attach (and again on a PsyProbe restart). When the connection comes back, or the host says the lease ran out, the libraries attach again by themselves and resume the session (below).

Dynamic modules

With <modules allowdynamic="yes"> a process may attach a name the spec does not declare and build its contract at run time. The host checks every request against <allow>; without one, a dynamic module may attach and do nothing else (default deny). Patterns are comma-separated, with * per level as in trigger types (Mimir.* covers Mimir.Audio and Mimir.Audio.Frame); several <allow> elements add up.

<service name="Modules">
  <modules auth="key" allowdynamic="yes">
    <!-- names: module names a process may create; subscribe: types it may trigger on; post: types it may post;
         retrieve: whiteboards; query: catalogs -->
    <allow names="Ext.*" subscribe="Mimir.*,Psyclone.Ready" post="Ext.*" retrieve="ConvWB" query="FileCat"/>
  </modules>
</service>
# Python
ext = RemoteModule.attach(psy, "Ext.Logger", Auth.key(api_key))     # ext.dynamic is True
ext.subscribe(Trigger("All", "Mimir.*").max_age(1000))               # a Mimir.* trigger: allowed
ext.declare_post("Note", "Ext.Logger.Note")
ext.post("Note", DataMessage().set_string("Text", "seen"))
rows = ext.retrieve_from("ConvWB", type="Mimir.Asr.*", max_count=20) # ad hoc, inside <allow retrieve>
ext.subscribe(Trigger("X", "Secret.Thing"))                         # RemoteModuleError: denied

// Kotlin
val ext = RemoteModule.attach(psy, "Ext.Logger", RemoteModule.Auth.key(apiKey))
ext.subscribe(RemoteModule.Trigger("All", "Mimir.*").maxAge(1000))
ext.declarePost("Note", "Ext.Logger.Note")
  • Triggers travel as the PsySpec's own <trigger> XML (name, type with wildcards, from, to, tag, maxage, delay, interval, <filter> children); the libraries' Trigger builders write it. The host keeps each module's desired set by trigger name and re-applies it whole, so re-sending a trigger changes nothing and an interval trigger never gets a second timer. One trigger per type; context triggers and <triggergroup> are not available over the wire yet.
  • Every type is checked before the host registers it, so a stranger cannot fill the type tables; from/to must name existing components; a post's type must be concrete (no *).
  • A key-auth attach still needs modules.attach.<Module> (e.g. modules.attach.Ext.*); the name must also be in <allow names> and must not be another component's.
  • declare adds posts, named retrieves and queries (only on allowed whiteboards and catalogs) and text parameters; Remove takes some away. describe returns the effective set (TriggerSpecs: the XML the engine has).
  • A declared module with <module type="remote" dynamic="yes"> may subscribe and declare too (inside <allow>); its spec triggers are the starting set (plain top-level triggers only).
  • When a dynamic module's session ends (detach, lease) its proxy's subscription is removed and the host posts Psyclone.RemoteModule.Detached after Offline. The next attach starts empty; the libraries send their desired set again by themselves.

Resume, ordering and flow control

  • Every trigger frame of a session carries PsySeq, strictly increasing (per session, whatever thread delivers it). A host thread per module does the network sends, so the engine only copies and queues: a slow or stuck process never holds up delivery to anyone else.
  • Each session has an outbound queue. When it is full the oldest non-guaranteed trigger message goes first, then the oldest one; replies and control frames are never dropped. The process is told with PsyOp=dropped (Count, FromSeq, Reason=queue, at most once a second); a UDP trigger message over 64 KB is dropped with Reason=size.
  • When the link drops (a failed send, a WebSocket close) the session waits for its lease (state pending) and the host keeps the last buffer trigger messages, each for bufferage ms. The process attaches again with Resume=<its session> and LastSeq=<the last PsySeq it got>: the reply says Resumed=1 (same PsySession), the host replays every buffered message with a higher PsySeq, and reports what it no longer had with dropped (Reason=buffer) before the replay. A Resume is the session's own credential, so it works with takeover="no" too. After the lease the session is gone: the attach is new (Resumed=0, PsySeq starts at 1). ack Seq=n lets the host forget what the process has (optional).
  • The libraries do all of this: they keep last_seq/lastSeq, resume after a reconnect, and call on_dropped/onDropped(count, fromSeq, reason).

Parameters, PsyProbe and system messages

  • A module's <parameter>s (and those a dynamic module declares) are in the attach reply (Parameters, one name=value per line). When PsyProbe changes one, the process gets PsyOp=parameter with Name and Value (on_parameter/onParameter); the process can set one with parameter (set_parameter/setParameter), checked against the parameter's type and range.
  • PsyProbe shows each remote module's session in the component inspector (kind declared/dynamic, state running/stopped/pending/offline, transport and peer, device, account, PsySeq, sent, dropped, buffered, queued, resumes, posts, refusals); the API has it as the module field of a component's stats and as GET /api/v2/systems/local/modules.
  • The host posts Psyclone.RemoteModule.Online (Reason attach, resume, takeover) on every attach and Psyclone.RemoteModule.Offline (detach, lease) when a session ends, from the module, with Module, Service and Reason.
  • Retrieves and queries run on host worker threads, never on the network receive thread.

Placement. A remote module, its host <service> and that service's interfaces must be on the same node: give the <module> the service's node="...". A remote module placed on a node without its host service fails the bake with that message. Modules on other nodes post to and trigger on it as on any component.

auth="none" is accepted from the host's own machine only (checked on every attach); interfaces listen on every address, so the log warns at start-up when a none host has an interface.

The protocol ("Remote Module Protocol 1")

Every frame is one DataMessage on the service's interface (TCP Message, WebSocket binary frames, UDP); no new framing. A program in another language implements the codec and these entries:

  • Control frames carry PsyPost=PsyModule (a reserved post name), PsyOp, PsyModule, a client-chosen PsyOpID and, after attach, PsySession. Ops: hello (reply: PsyNonce, PsyFeatures, PsyAuth), attach (PsyDevice, PsyAuthToken or PsyAuthKey=key id + PsyAuthNonce + PsyAuthProof, optional Resume + LastSeq, and for a changeable module optionally its desired set as Triggers/Posts/Retrieves/Queries/Parameters; reply: PsySession, Lease, Resumed, LastSeq, Buffer, BufferAge, Posts, Triggers (name=type,...), Retrieves, Queries, Contract (the <module> XML), Parameters, Dynamic, Changeable, PsyState), detach, describe, retrieve (Retrieve=name, optional MaxCount, MaxAge in ms, Start/End; or ad hoc: Source=whiteboard, Type, From, To, Key, KeyType), query (PsyQuery=name, or ad hoc Source=catalog; every entry not starting with Psy, such as Query or List, is passed to the catalog), subscribe (Triggers=<trigger> XML), unsubscribe (Names=a,b or *), declare (Posts, Retrieves, Queries, Parameters as <post>/<retrieve>/<query>/<parameter> XML; Remove=names), parameter (Name, Value), ack (Seq).
  • Replies echo PsyOpID and carry PsyOpReply=1 and PsyStatus (ok, denied, unknown, busy, invalid, timeout, failed, unsupported) plus PsyError. A retrieve sends one frame per message (the stored message with PsyResultIndex, PsyResultCount, PsyTypeName, PsyFromName), then the status frame with PsyResultCount; a query answers with the catalog's reply as the status frame. The frame with PsyStatus ends an operation.
  • Posts: PsyModule + PsySession + PsyPost=<the module's post>; the spec decides the type (a raw type is overwritten) and PsySession is removed before the message enters the system. A post is answered only when it fails or carries a PsyOpID.
  • Triggers: the triggering message with PsyTrigger, PsyModule, PsySeq (per session, from 1), PsyTypeName (dotted) and PsyFromName.
  • From the host: PsyOp=stop / start (PsyProbe component control; Reason stop, start, restart, shutdown), detached (Reason takeover, lease, shutdown), dropped (Count, FromSeq, Reason queue, buffer, size) and parameter (Name, Value). While stopped, triggers are dropped and posts refused. All frames of a session leave in order through its queue.
  • A module host's keepalive reply advertises PsyFeatures=keepalive,packed,modules/1. System messages: Psyclone.RemoteModule.Online, .Offline, .Detached (above).

A declared module's contract is the spec's: subscribe and declare answer unsupported unless it has dynamic="yes"; signal is not available yet. Remote modules answering queries, several processes per module name, HTTP long-poll, a JSON mode for browsers and UDP message signing are later options. The engine test is test=remotemodule (declared and dynamic parts).

Note. Administration-level detail — Telnet console usage, running PsyProbe on custom ports, securing interfaces with SSL certificates, and the <authentication> element (currently a parse-only stub) — lives in the System Guide.
Psyclone AIOS · CMLabs