Skip to content
Musher Docs

TypeScript SDK Reference

Complete API reference for the @musher-dev/musher-sdk package. The SDK requires Node.js 20+ and has a single runtime dependency (zod).

Module-Level Functions

pull(ref: string, version?: string): Promise<Bundle>

Resolve, fetch, verify, and cache a bundle. Returns a Bundle with typed access to its contents. Uses the global configuration set via configure().

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

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

resolve(ref: string, version?: string): Promise<BundleResolveOutput>

Resolve a bundle reference to its manifest metadata without downloading asset content. Useful for inspecting versions, listing assets, or validating a reference.

configure(config: Partial<ClientConfig>): void

Set global SDK configuration. Affects all subsequent calls to pull() and resolve().

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

configure({
  apiKey: "mush_...",
  baseUrl: "https://api.musher.dev",
  cacheDir: "/custom/cache",
  manifestTtlSeconds: 3600,
});

getClient(): MusherClient

Get or create the global MusherClient instance.

MusherClient

Client class for custom configuration. Use this when you need multiple clients with different settings or want explicit control over the client lifecycle.

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

const client = new MusherClient({
  apiKey: "mush_...",
  baseUrl: "https://api.musher.dev",
});

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

Constructor: ClientConfig

FieldTypeDefaultDescription
apiKeystringAuto-discoveredAPI token (overrides credential discovery)
baseUrlstring"https://api.musher.dev"Registry base URL
cacheDirstringPlatform defaultLocal cache directory
manifestTtlSecondsnumber86400Manifest cache TTL in seconds (24 hours)
timeoutnumber60000HTTP request timeout in milliseconds
retriesnumber3Retry count for transient failures

Methods

MethodReturnsDescription
pull(ref, version?)Promise<Bundle>Resolve, fetch, verify, and cache a bundle
resolve(ref, version?)Promise<BundleResolveOutput>Resolve metadata without fetching content

cache property (CacheManager)

Access cache management operations via client.cache.

MethodReturnsDescription
list()Promise<CacheEntry[]>List all cached bundle entries
has(namespace, slug, version?)Promise<boolean>Check if a bundle is cached
remove(namespace, slug, version?)Promise<void>Remove a specific cached bundle
stats()Promise<CacheStats>Get aggregate cache statistics
invalidate(namespace, slug, version?)Promise<void>Mark entries as stale (forces re-fetch on next pull)
clean()Promise<void>Remove expired entries and garbage-collect unreferenced blobs
purge()Promise<void>Delete all cached data

Bundle

A resolved bundle with its fetched assets. Returned by pull() and client.pull().

Properties

PropertyTypeDescription
manifestBundleManifestBundle metadata including name, version, and asset list

Typed Accessors

MethodReturnsDescription
files()FileHandle[]All files in the bundle
file(logicalPath)FileHandle | undefinedSingle file by logical path
skills()SkillHandle[]All skills
skill(name)SkillHandleSingle skill by name (throws BundleAssetNotFoundError)
prompts()PromptHandle[]All prompts
prompt(name)PromptHandleSingle prompt by name (throws BundleAssetNotFoundError)
toolsets()ToolsetHandle[]All toolsets
toolset(name)ToolsetHandleSingle toolset by name (throws BundleAssetNotFoundError)
agentSpecs()AgentSpecHandle[]All agent specs
agentSpec(name)AgentSpecHandleSingle agent spec by name (throws BundleAssetNotFoundError)

Selection

select(filter) returns a Selection — a filtered view of the bundle with the same typed accessor methods.

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

const subset = bundle.select({
  skills: ["code-review"],
  prompts: ["system"],
});

for (const skill of subset.skills()) {
  console.log(skill.name);
}

Integrity and Lockfile

MethodReturnsDescription
verify()Promise<void>Re-verify SHA-256 checksums for all assets
writeLockfile(path?)Promise<void>Export metadata and hashes as a lockfile

Handle Types

FileHandle

MemberTypeDescription
.pathstringOriginal path from the manifest
.logicalPathstringLogical path within the bundle
.mediaTypestring | undefinedMIME type, if known
.sizenumberFile size in bytes
.digeststringSHA-256 content digest
.text()stringDecode content as UTF-8 text
.bytes()Uint8ArrayRaw content bytes
.stream()ReadableStreamStream content

SkillHandle

MemberTypeDescription
.namestringSkill name
.contentstringSKILL.md text content
.descriptionstringSkill description (from frontmatter)
.files()FileHandle[]All files within this skill
.file(relativePath)FileHandle | undefinedSingle file within the skill by relative path

PromptHandle

MemberTypeDescription
.namestringPrompt name
.contentstringPrompt text content

ToolsetHandle

MemberTypeDescription
.namestringToolset name
.contentstringToolset content (typically JSON)

AgentSpecHandle

MemberTypeDescription
.namestringAgent spec name
.contentstringAgent spec content (typically JSON)

Adapter Functions

Export bundle content into formats for Claude, OpenAI, and VS Code. These functions are imported directly from the SDK.

FunctionDescription
exportClaudePlugin(bundle)Export skills as a Claude Desktop plugin directory
installClaudeSkills(bundle)Install skills to .claude/skills/
exportOpenAILocalSkill(bundle)Export a skill as an OpenAI-compatible local file
exportOpenAIInlineSkill(bundle)Export a skill as base64-encoded inline content
installVSCodeSkills(bundle)Install skills to .agents/skills/ for VS Code
typescript
import { pull, exportClaudePlugin, installVSCodeSkills } from "@musher-dev/musher-sdk";

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

// Export as Claude plugin
await exportClaudePlugin(bundle);

// Install skills for VS Code
await installVSCodeSkills(bundle);

Selection

A Selection is a filtered view of a Bundle. It has the same typed accessor methods (skills(), prompts(), etc.) but only returns assets matching the filter.

typescript
const selection = bundle.select({
  skills: ["code-review", "security-scan"],
  prompts: ["review-template"],
});

// Only the selected assets are returned
for (const skill of selection.skills()) {
  console.log(skill.name);
}

Cache Types

CacheEntry

FieldTypeDescription
namespacestringBundle namespace
slugstringBundle slug
versionstringSemver version string
freshbooleanWhether the entry is within its TTL

CacheStats

FieldTypeDescription
entryCountnumberTotal number of cached entries
freshCountnumberNumber of entries within their TTL
staleCountnumberNumber of expired entries
blobCountnumberNumber of content-addressable blobs on disk
blobSizeBytesnumberTotal blob size in bytes

Errors

All errors inherit from MusherError.

ErrorWhen
MusherErrorBase class for all SDK errors
ApiErrorAPI returned an error (carries ProblemDetail)
AuthenticationErrorInvalid or missing credentials
NotFoundErrorBundle or version does not exist
ForbiddenErrorValid credentials but insufficient permissions
ValidationErrorRequest failed server-side validation
RateLimitErrorToo many requests
NetworkErrorConnection or DNS resolution failure
TimeoutErrorRequest exceeded configured timeout
CacheErrorFailed to read or write local cache
IntegrityErrorSHA-256 checksum mismatch
SchemaErrorAPI response failed Zod schema validation
BundleAssetNotFoundErrorRequested asset does not exist in bundle

Enums

AssetType

"agent_definition", "skill", "tool_config", "prompt", "config", "other"

BundleVisibility

"private", "public"

BundleVersionState

"published", "yanked"

BundleRef

Parsed bundle reference. Supports three formats:

  • namespace/slug — resolves to latest version
  • namespace/slug:version — specific version or semver range
  • namespace/slug@sha256:digest — pinned by content digest
FieldTypeDescription
namespacestringOrganization or user namespace
slugstringBundle slug
versionstring | undefinedSemver version or range
digeststring | undefinedContent digest for pinning