npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kognai/sdk

v0.7.0

Published

Programmatic SDK for the Kognai sovereign runtime — embed agents in your own apps

Readme

@kognai/sdk

Programmatic SDK for the Kognai sovereign runtime. Embed agents directly in your Node app — no shelling out to npx. Same primitives as @kognai/run, exposed as functions.

npm install @kognai/sdk
import { runAgent } from '@kognai/sdk';

const result = await runAgent({
  agent: 'coder',
  task: 'write a python hello world',
});

console.log(result.reply);          // "print(\"Hello, World!\")"
console.log(result.llmUsed);        // "ollama/qwen3:4b" (or fallback)
console.log(result.charterSource);  // "vault" | "fallback" | "skipped"
console.log(result.durationMs);     // 1234

What you get

  • runAgent(opts) — high-level: load vault + agent, build system prompt (Charter first), call LLM, optionally append to MEMORY.md, return result.
  • loadVault(dir) / loadAgent(dir, name) / listAgents(dir) — pure file-system readers.
  • buildSystemPrompt(boot, agent) — assemble the system prompt the way @kognai/run does it.
  • callLLM(llm, messages) — provider router with auto-fallback.
  • callOllama / callAnthropic — raw provider calls.
  • appendMemoryTurn(...) — append a structured turn record to MEMORY.md.
  • stripCoderFormatting(text) — strip FILE: <path> markers + code fences from a coder agent's reply.

Options

interface RunAgentOptions {
  vault?: string;          // default: './.kognai'
  agent: string;           // required — "coder", "agents/coder", etc.
  task: string;            // required — what the user is asking
  llm?: string;            // override agent.yaml's llm
  remember?: boolean;      // append turn to MEMORY.md (default: false)
  stripFormatting?: boolean; // strip FILE:/fences (default: true)
  injectCharter?: boolean; // inject Five Laws as first prompt block (default: true)
  signal?: AbortSignal;    // for cancellation
}

Auto-fallback

If the agent declares llm: ollama/qwen3:4b but Ollama isn't reachable AND ANTHROPIC_API_KEY is set, the call transparently falls back to anthropic/claude-haiku-4-5-20251001. The result tells you what was actually used:

const r = await runAgent({ agent: 'coder', task: 'hi' });
if (r.llmUsed.startsWith('anthropic/')) console.log('cloud fallback fired');

Lower-level use

import {
  loadVault, loadAgent, buildSystemPrompt, callLLM, stripCoderFormatting
} from '@kognai/sdk';

const boot = loadVault('./.kognai');
const agent = loadAgent('./.kognai', 'analyst');
const sys = buildSystemPrompt(boot, agent, { includeCharter: true });
const { reply, llmUsed } = await callLLM(agent.llm, [
  { role: 'system', content: sys },
  { role: 'user',   content: 'analyse this dataset...' },
]);
console.log(stripCoderFormatting(reply));

Errors

All errors thrown by the SDK have a code field for switching:

try {
  await runAgent({ agent: 'nonexistent', task: 'hi' });
} catch (e) {
  if ((e as any).code === 'AGENT_NOT_FOUND') { /* show agent list */ }
}

Codes: VAULT_NOT_FOUND, AGENT_NOT_FOUND, AGENT_PROMPT_MISSING, NO_LLM_KEY, OLLAMA_UNREACHABLE, OLLAMA_HTTP, ANTHROPIC_HTTP, UNKNOWN_PROVIDER.

Zero dependencies

Raw fs + http/https. No axios, no @anthropic-ai/sdk, no js-yaml, no dotenv. The SDK is ~600 lines of TypeScript total.

Relationship to other @kognai packages

| Package | Use | |---|---| | @kognai/init | npx @kognai/init — scaffold a vault | | @kognai/new | npx @kognai/new <name> — scaffold an agent | | @kognai/run | npx @kognai/run <agent> — CLI to run an agent | | @kognai/sdk | import { runAgent } from '@kognai/sdk' — programmatic API |

The CLI tools (init, new, run) are for end users on their own machines. The SDK is for developers embedding Kognai into their own apps.

License

MIT