Binary RPC client and wire types shared by apps and ollmfilesd.
The OLLMrpc namespace is the client library for talking to ollmfilesd over a Unix socket (or stdio/TCP), and for calling HTTPS JSON APIs with the same Request / Response shape. Client owns the channel. Request carries method, a typed CallParam on param, and optional result_type. Bin serializes Bin.Serializable GObjects on the wire. Transport is the daemon listen/connection side. Live is opt-in live GObject handles (ref, unref, subscribe).
OLLMrpc.Daemon.rpc_register();
OLLMfilesd.DaemonParams.rpc_register();
var rpc = new OLLMrpc.Client(
GLib.Path.build_filename(
GLib.Environment.get_user_data_dir(), "ollmchat"),
"ollmfilesd.pid",
"ollmfilesd.sock"
);
if (!yield rpc.connect(new OLLMrpc.Request() {
method = "RPC-Daemon.hello",
param = new OLLMfilesd.DaemonParams() {
protocol = 1,
client = "my-app"
}
}, new OLLMrpc.ClientBoot())) {
GLib.error("%s", rpc.connect_error);
}
var resp = yield rpc.call(new OLLMrpc.Request() {
method = "RPC-ProjectManager.load_projects_from_db",
param = new OLLMfilesd.ProjectParams()
});
OLLMhf.rpc_register();
var rpc = new OLLMrpc.Client("", "", "https://huggingface.co");
yield rpc.connect(new OLLMrpc.Request());
var resp = yield rpc.call(new OLLMrpc.Request() {
method = "/api/models",
param = new OLLMhf.Param.Search() {
search = "llama",
filter = "gguf",
limit = 10
},
result_type = typeof(OLLMhf.ModelArray)
});
2. Params: use a CallParam subclass on Request.param, not raw maps
3. Results: set result_type when the HTTP path should decode to a GType
4. Errors: check Response.error after every call
5. Bin round-trips: see Bin and docs/bin-rpc-protocol.md