Skip to content
Musher Docs

TypeScript SDK

The Musher TypeScript SDK lets you pull bundles, resolve versions, verify integrity, and access typed assets from Node.js applications. Responses are validated with Zod schemas and all operations return typed handles.

Prerequisites

  • Node.js 20 or later
  • A Musher API key — create one in the Console

Installation

Install the package

bash
npm install @musher-dev/musher-sdk

Set your API key

bash
export MUSHER_API_KEY="msk_..."

Authentication

The SDK discovers credentials automatically, checking these sources in order:

  1. MUSHER_API_KEY environment variable
  2. OS keyring (musher/<host>)
  3. Credential file (~/.local/share/musher/credentials/<host>/api-key)
  4. Programmatic — pass a token directly

To pass a token programmatically:

typescript
import { MusherClient } from "@musher-dev/musher-sdk";

const client = new MusherClient({ apiKey: "msk_..." });

Pull Your First Bundle

The pull() function downloads a bundle from the registry and returns a Bundle object with typed access to its contents.

typescript
import { pull } from "@musher-dev/musher-sdk";

const bundle = await pull("acme/code-review-kit");

console.log(bundle.manifest.name);

for (const asset of bundle.manifest.assets) {
  console.log(`${asset.type}: ${asset.path}`);
}

Work with Typed Handles

Bundles provide typed handles for each asset category. Each handle gives you structured access to the asset content and metadata.

typescript
import { pull } from "@musher-dev/musher-sdk";

const bundle = await pull("acme/code-review-kit");

// Access skills
for (const skill of bundle.skills) {
  console.log(`Skill: ${skill.name}`);
  console.log(skill.content);
}

// Access prompts
for (const prompt of bundle.prompts) {
  console.log(`Prompt: ${prompt.name}`);
  console.log(prompt.content);
}

// Access all files
for (const file of bundle.files) {
  console.log(`${file.path} (${file.size} bytes)`);
}

Resolve Without Pulling

Use resolve() to inspect a bundle's metadata without downloading its full contents. This is useful for checking versions, listing assets, or validating a reference.

typescript
import { resolve } from "@musher-dev/musher-sdk";

const result = await resolve("acme/code-review-kit@^1.0");

console.log(`Resolved version: ${result.version}`);
console.log(`Asset count: ${result.assets.length}`);

Configuration

Use configure() to customize the registry URL, cache directory, or other settings. Configuration applies globally and affects all subsequent SDK calls.

typescript
import { configure } from "@musher-dev/musher-sdk";

configure({
  registryUrl: "https://registry.musher.dev",
  cacheDir: "/custom/cache",
});

For more control, create a MusherClient instance directly:

typescript
import { MusherClient } from "@musher-dev/musher-sdk";

const client = new MusherClient({
  apiKey: "msk_...",
  registryUrl: "https://registry.musher.dev",
});

const bundle = await client.pull("acme/code-review-kit");

Key Exports

ExportDescription
pull()Pull a bundle by reference
resolve()Resolve metadata without downloading
configure()Set global configuration (registry URL, cache, etc.)
getClient()Get or create the global client instance
MusherClientClient class for custom configuration
BundleLoaded bundle with typed asset access
BundleRefParsed bundle reference (publisher/name@version)
SelectionFilter and select specific assets from a bundle
SkillHandleTyped handle for skill assets
PromptHandleTyped handle for prompt assets
ToolsetHandleTyped handle for toolset assets
AgentSpecHandleTyped handle for agent spec assets
FileHandleTyped handle for generic file assets

Next Steps