Skip to main content

Wire types

interface WireRunResult {
  session_id: string;
  text: string;
  turns: number;
  tool_calls: number;
  usage: WireUsage;
  structured_output?: unknown;
  schema_warnings?: Array<{ provider: string; path: string; message: string }>;
}
interface WireUsage {
  input_tokens: number;
  output_tokens: number;
  total_tokens: number;
  cache_creation_tokens?: number;
  cache_read_tokens?: number;
}
interface WireEvent {
  session_id: string;
  event: Record<string, unknown>;
}
The sequence and contract_version fields have been removed — they were never sent by the server. The streaming API uses raw event dicts directly.
interface CapabilitiesResponse {
  contract_version: string;
  capabilities: CapabilityEntry[];
}

interface CapabilityEntry {
  id: string;
  description: string;
  status: string;  // "Available", "DisabledByPolicy", "NotCompiled", etc.
}

CapabilityChecker

Standalone helper for checking runtime capabilities:
import { MeerkatClient, CapabilityChecker } from "@meerkat/sdk";

const caps = await client.getCapabilities();
const checker = new CapabilityChecker(caps);

if (checker.has("comms")) {
  console.log("Comms is available");
}

checker.require("skills");  // throws CapabilityUnavailableError if unavailable

console.log(checker.available);  // ["sessions", "streaming", ...]
MethodDescription
has(capabilityId)Returns true if status is "Available"
require(capabilityId)Throws if capability not available
availableGetter returning all available capability IDs
IDDescription
sessionsSession lifecycle
streamingReal-time event streaming
structured_outputJSON schema structured output
hooksLifecycle hooks
builtinsBuilt-in tools
shellShell tool
commsInter-agent communication
sub_agentsSub-agent tools
memory_storeSemantic memory
session_storeSession persistence
session_compactionContext compaction
skillsSkill loading

SkillHelper

Convenience wrapper for invoking Meerkat skills:
import { MeerkatClient, SkillHelper } from "@meerkat/sdk";

const helper = new SkillHelper(client);

if (helper.isAvailable()) {
  const result = await helper.invoke(sessionId, "/shell-patterns", "How do I run a background job?");
  console.log(result.text);
}

const result = await helper.invokeNewSession(
  "/code-review",
  "Review this function",
  "claude-opus-4-6",
);
MethodDescription
isAvailable()Returns true if "skills" capability is available
requireSkills()Throws if skills not available
invoke(sessionId, skillRef, prompt)Invoke skill in existing session
invokeNewSession(skillRef, prompt, model?)Create session and invoke skill

Skills parameters

Both createSession() and startTurn() accept skill-related parameters:
// Preload skills into the system prompt at session creation
const result = await client.createSession({
  prompt: "Hello!",
  preload_skills: ["extraction/email", "formatting/markdown"],
});

// Inject skills for a specific turn
const result = await client.startTurn(sessionId, "Extract emails", {
  skill_references: ["extraction/email"],
});

Error handling

All errors extend MeerkatError:
import { MeerkatError, CapabilityUnavailableError } from "@meerkat/sdk";

try {
  await client.connect();
  const result = await client.createSession({ prompt: "Hello" });
} catch (err) {
  if (err instanceof CapabilityUnavailableError) {
    console.error("Missing capability:", err.message);
  } else if (err instanceof MeerkatError) {
    console.error(`[${err.code}]: ${err.message}`);
  }
} finally {
  await client.close();
}
ClassDescription
MeerkatErrorBase error with code, details, capabilityHint
CapabilityUnavailableErrorRequired capability not available
SessionNotFoundErrorSession ID does not exist
SkillNotFoundErrorSkill reference cannot be found

Version compatibility

import { CONTRACT_VERSION } from "@meerkat/sdk";
console.log(CONTRACT_VERSION);  // "0.1.0"
  • While major version is 0, minor versions must match exactly
  • Once 1.0.0 is reached, major versions must match (standard semver)

See also