@orqo/foundationmodels-client
v1.0.0
Published
JSON-RPC client over Unix socket for Apple Foundation Models Swift daemon.
Maintainers
Readme
@orqo/foundationmodels-client
JSON-RPC client over Unix socket for Apple Foundation Models Swift daemon.
Install
pnpm add @orqo/foundationmodels-clientUsage
This package is consumed internally by @orqo/foundationmodels-runtime. Direct use is only needed when building a custom transport layer or communicating with the daemon outside the standard runtime.
import { FoundationModelsDaemonClient } from "@orqo/foundationmodels-client";
// Connect to the daemon via the default Unix socket path.
const client = new FoundationModelsDaemonClient();
// Check daemon health.
const health = await client.health();
// Check model availability.
const avail = await client.availability();
// Send a generation request.
const response = await client.respond({
sessionId: "my-session",
input: [{ type: "text", text: "Summarize this document." }],
});
console.log(response.output);
// Stream a response.
for await (const event of client.stream({ sessionId: "my-session", input: [] })) {
if (event.type === "text_delta") process.stdout.write(event.delta);
}
// Close the connection when done.
await client.close();The socket path defaults to ~/Library/Application Support/FoundationModelsJS/runtime/foundationmodels.sock. Configure it via new FoundationModelsDaemonClient({ socketPath: "/custom/path.sock" }).
Most applications should depend on @orqo/foundationmodels rather than this package directly.
