TypeScript SDK and developer documentation for building clients that drive Muse Code agent sessions over the Muse Session Protocol (MSP).
Read the docs: https://meta-models.github.io/muse-code-sdk
This fork adds an OpenAI-compatible host. The first-party provider path is replaced by a host that talks to any endpoint speaking
GET /models+POST /chat/completions— noendpoint_transport, noauth.json, no/muse-code/modelscatalog, nomuse/tbhbinary. It is verified end to end against Nebius Token Factory. See Run it on Nebius Token Factory below andintegrations/openai-compatible/.
npm install @muse-code/sdkRequires Node.js 20 or newer. The package has zero runtime dependencies and ships its own TypeScript declarations. Start with the quickstart.
The SDK is a Developer Preview: it is published pre-1.0 and carries no stability promise yet — minor releases may change APIs while the surface settles.
Nebius Token Factory serves an
OpenAI-compatible API, so the host in
integrations/openai-compatible/ drives it
directly — a base URL, a bearer key and a model id, nothing else.
There are three profiles, and they are only sets of defaults: nebius (hosted),
ollama (a local daemon on its default port, no key) and custom (anything else
that speaks the same API — you supply --base-url). Nothing downstream branches
on which is in use. Only the Nebius profile is verified end to end below.
Get a key from https://tokenfactory.nebius.com/, then:
export NEBIUS_API_KEY=...
node integrations/openai-compatible/bin/demo.mjsThe demo lists the models, spawns the host through MuseClient.spawn, streams a
turn, and runs a tool call through the approval round trip. Real output, against
zai-org/GLM-5.3-Flash:
provider Nebius Token Factory (profile: nebius)
base URL https://api.tokenfactory.nebius.com/v1
model zai-org/GLM-5.3-Flash
────────────────────────────────────────────────────────────────────────
[models] 31 models served; zai-org/GLM-5.3-Flash present: true
[handshake] msp-openai-host schema=1 durability=ephemeral
[session] 01a05958-8639-7ab4-aa38-4be7d3bd9eba
[turn] prompt: "In one sentence, what is a session protocol?"
A session protocol is a set of rules that governs how a communication
exchange between two parties is established, maintained, and terminated
so both sides reliably understand each other's messages.
terminal=completed reasoning=176ch tokens=73 out
[tools] prompt: "List the files in the repository root, then name the ones you'd read first."
approval asked: list_files /Users/me/muse-code-sdk -> allow_once
tool list_files({"path": "."}) -> completed
.github/ | .nojekyll | LICENSE | README.md
answer:
Files in the repository root: `.github/`, `.nojekyll`, `LICENSE`,
`README.md`, `clients/`, `integrations/`, `package-lock.json`,
`package.json`, `publish-anchor.json`, `schema/`, `scripts/`.
I'd read first: **README.md** (project overview and usage),
**package.json** (dependencies, scripts, and entry points), and
**publish-anchor.json** (looks like an unusual, high-signal config
for this repo).
terminal=completed toolCalls=1
────────────────────────────────────────────────────────────────────────
done — the SDK drove a real model with no first-party provider in the path.
Any model the account can reach works the same way:
node integrations/openai-compatible/bin/demo.mjs --model MiniMaxAI/MiniMax-M3The other two profiles take the same shape:
node integrations/openai-compatible/bin/demo.mjs --provider ollama
node integrations/openai-compatible/bin/demo.mjs --provider custom --base-url <url> --model <id>node --test --test-timeout=300000 "integrations/openai-compatible/test/*.test.mjs"28/28 pass on zai-org/GLM-5.3-Flash, and 28/28 on MiniMaxAI/MiniMax-M3:
ok 1 - configuration
ok 2 - tool sandbox
ok 3 - uuidv7
ok 4 - live provider
ok 5 - SDK end to end
ok 6 - turn/cancel
ok 7 - host isolation
# tests 28
# pass 28
# fail 0
The live tier covers provider reachability, a streamed turn whose concatenated
item/delta frames equal the committed item text byte for byte, an approved tool
call whose output reaches the model, a denied one, and a mid-turn cancel. The
live tests skip rather than fail when no API key is configured, so the suite
is safe in a credential-free checkout.
Full documentation — configuration, the protocol surface the host implements,
the read-only tool sandbox and the approval model — is in
integrations/openai-compatible/README.md.
main— the source of@muse-code/sdk, together with the protocol declarations, examples and fixtures it needs to build and test on its own.gh-pages— the built Muse Code Developer Docs: the wire-protocol reference, the SDK reference, and the guides and cookbook that go with them.
clients/sdk-ts/ @muse-code/sdk — the facade, its QA harness and test suite
clients/msp-ts/ @muse-code/msp — the generated MSP wire types
clients/sdk-quickstart/ the executable quickstart journey the docs render
clients/sdk-cookbook/ the executable cookbook recipes the docs render
schema/msp/ the committed protocol declarations, stable manifest and
recorded conformance transcripts the tests replay
integrations/openai-compatible/
the OpenAI-compatible MSP host this fork adds, plus its
demo and test suite
Requires Node.js 20 or newer (CI uses 22). From the repository root:
npm install # links the workspace packages; installs the pinned TypeScript
npm run build # tsc --build
npm test # builds, then runs the node:test suitesThe suite passes in a standalone checkout except for the arms in
clients/sdk-ts/test/muse-serve-child.test.ts and
clients/sdk-ts/test/spawn-handshake.test.ts, which spawn a real muse host
binary that is not part of this repository. Those fail by design without one —
anything else is a genuine failure, so please report it.
To typecheck the committed protocol declarations on their own:
scripts/check-msp-ts-typecheck.shReleased under the MIT License — see LICENSE.
publish-anchor.json names the exact upstream commit each copy came from, and
its repo_meta.hand_authored list is the authoritative record of which files
are not mirrored. Today that list is README.md, .nojekyll, LICENSE,
.github/ and publish-anchor.json itself.
Every other file is a verbatim copy from the producing repository. Nothing outside that list is hand-maintained, so an edit made to a mirrored file in this repository would be silently overwritten by the next publish. Corrections to mirrored files belong upstream.
This fork adds one directory of its own, integrations/openai-compatible/,
which is hand-maintained here and mirrors nothing. It is additive and
self-contained: no file under clients/ or schema/ was modified, and the SDK
is used exactly as published. That is deliberate — replacing the first-party
provider path in place would be undone by the next upstream publish.
The site is generated and published automatically. The gh-pages branch holds
the built site exactly as it is served; it is replaced wholesale on each
publish, so it carries no history worth reading and no hand edits survive
there.
Every published build is produced by one pipeline and validated before it is published: the reference pages are generated from the protocol schema and the SDK's own type information rather than hand-copied, the site is built offline and proven self-contained, and each build's provenance — the commit and schema fingerprint it was rendered from — is stamped on the site's front page.
The documentation is a Developer Preview, as the banner on every page says.
Issues are open, and reports and questions are welcome. Open an issue — there is a short form for bugs and one for questions. Bugs in the SDK, in the protocol declarations and in the documentation all belong here, as do questions about how to use any of it.
Issues are triaged into the team's internal tracker, and fixes are made upstream and land here on the next publish. We may reply on the issue when a fix ships rather than linking an internal change you would not be able to read.