@klein-kit/core
v0.2.0
Published
Protocol-native TypeScript clients for local coding agents: Codex App Server, Claude Agent SDK, OpenCode, Cursor, and Pi behind one unified session API.
Maintainers
Readme
@klein-kit/core
One TypeScript SDK for every local coding agent. Drives the coding agents already installed and logged in on the machine — Codex, Claude Code, OpenCode, Cursor, and Pi — through a single, protocol-native session API. No API keys, no cloud proxy: each adapter spawns the user's own binary and inherits the machine's existing auth. Zero runtime dependencies.
import { createAgent, detectProviders } from "@klein-kit/core";
console.log(await detectProviders()); // what's installed + logged in
const session = await createAgent({
provider: "codex",
permissionMode: "ask",
onPermissionRequest: async (req) => ({ behavior: "allow" }),
});
const turn = session.prompt("Fix the failing test in src/auth.ts");
for await (const event of turn) {
if (event.type === "message.delta") process.stdout.write(event.text);
}
const { text, usage, filesChanged } = await turn;- Protocol-native fidelity — checklists (a provider's plan or todo list, normalized to one
checklist.updatedevent), tool calls with live output, file diffs, permission requests, reasoning streams, token/context usage, all as typed events with the untouched native payload onevent.raw. Unclassifiable messages surface asunknownevents, never dropped. - Permissions — preset modes (
read-only/ask/accept-edits/full-auto) plus a callback carrying the full native request. - Sessions that survive restarts —
session.nativeSessionId+resumeSession()use each backend's own persistence. - Message queueing — prompting a busy session queues the turn; inspect and cancel via
queuedTurns/cancelQueued. - Capability matrix —
session.capabilitiestells you per provider what's native, emulated, or absent;session.raw()exposes the underlying protocol client.
Cross-agent orchestration (handoffs, reviewer loops, CI repair) lives in @klein-kit/orchestrate.
Full docs: github.com/yvescomputer/klein-kit · MIT © Yves Computer Company
