Loading repository data…
Loading repository data…
matakartal / repository
Agent-native, governed AI runtime for Rust, Python, and TypeScript — native providers, MCP, tools, routing, memory, budgets, audit, and containment.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Build provider-aware agents in Rust, Python, and TypeScript without reimplementing streaming, tools, policy, routing, budgets, audit, memory, or sessions in every language.
One core. Three SDKs. Four native providers. Four compatible endpoints. One policy boundary.
Quick start · CLI · Architecture · Governance · SDKs · Documentation
aikit-runtime keeps correctness-sensitive agent behavior in one Rust core and exposes it through
thin native bindings. Anthropic, OpenAI, Google, and DeepSeek retain their native wire formats,
while your application gets one canonical runtime contract.
| One runtime | Provider-native | Governed execution |
|---|---|---|
| Rust owns the agent loop; Python and Node call the same implementation. | Provider-specific reasoning, tool calls, citations, usage, and metadata stay intact. | Every side effect passes schema validation, hooks, permissions, budgets, and audit. |
| Typed developer experience | Agent primitives included | Production controls built in |
| Streaming text, structured objects, multimodal messages, typed errors, and cancellation. | Tools, subagents, parallel fan-out, councils, memory, sessions, routing, and retries. | Fail-closed containment, metadata-safe audit, cost limits, scoped tools, and explicit approvals. |
flowchart TB
subgraph Apps[Application code]
R[Rust]
P[Python]
N[TypeScript / Node.js]
end
R --> F[Rust facade: aikit]
P --> PY[PyO3 binding]
N --> JS[napi binding]
F --> CORE
PY --> CORE
JS --> CORE
subgraph CORE[aikit-runtime-core]
direction LR
MSG[Canonical messages<br/>streaming + objects]
LOOP[Agent loop<br/>tools + subagents]
GOV[Governance<br/>hooks + permissions]
OPS[Budgets + routing<br/>audit + state]
MSG --> LOOP --> GOV --> OPS
end
CORE --> A[Anthropic<br/>Messages]
CORE --> O[OpenAI<br/>Responses]
CORE --> G[Google<br/>Gemini]
CORE --> D[DeepSeek<br/>Chat Completions]
CORE --> C[Compatible endpoints<br/>OpenRouter · Groq · Mistral · xAI]
CORE --> HOST[Host callbacks]
CORE --> BUILTIN[Jailed built-in tools]
BUILTIN --> BOUNDARY[Seatbelt · Linux namespaces + seccomp<br/>Windows Job · hardened Docker]
The bindings translate host values and async callbacks at the edge. They do not duplicate policy, provider translation, or orchestration logic.
The repository includes a deterministic provider, so you can exercise the complete runtime with no API key and no network call.
git clone https://github.com/matakartal/aikit-runtime.git
cd aikit-runtime
cargo run -p aikit-runtime --example quickstart
Expected output:
Araç sonucunu aldım; görevi tamamladım.
The source-first CLI makes the runtime usable without writing an application. Its default model
is the deterministic, offline mock-1 provider:
cargo run -p aikit-cli -- run "Explain aikit in one sentence"
cargo run -p aikit-cli -- chat
cargo run -p aikit-cli -- providers
cargo run -p aikit-cli -- doctor
cargo run -p aikit-cli -- eval evals/smoke.json
Choose a configured provider explicitly only when you intend to make a network call:
XAI_API_KEY='...' cargo run -p aikit-cli -- run --model grok-4.5 "Say hello"
The CLI supports text, JSON, and JSONL output, stable exit codes, stdin prompts, canonical multi-turn history, secret-safe provider discovery, containment diagnostics, deterministic eval gates, and shell completion generation. See the CLI guide for the full contract.
use aikit::Agent;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let answer = Agent::new()
.generate_text("Say hello in Turkish", "mock-1", 128)
.await?;
println!("{}", answer.text);
Ok(())
}
Run it from this checkout:
cargo run -p aikit-runtime --example quickstart
Build the native binding once, then use the same core from Python:
python3 -m venv .venv
.venv/bin/pip install "maturin==1.14.1"
.venv/bin/maturin develop --manifest-path crates/aikit-py/Cargo.toml
import asyncio
import aikit
async def main() -> None:
agent = aikit.Agent.from_env({})
answer = await agent.generate_text("Say hello in Turkish")
print(answer["text"])
asyncio.run(main())
./scripts/build-node.sh
const { Agent } = require("./crates/aikit-node");
async function main() {
const agent = Agent.fromEnv({});
const answer = await agent.generateText("Say hello in Turkish");
console.log(answer.text);
}
main();
| Capability | What aikit provides |
|---|---|
| Streaming | Incremental text, reasoning, tool-call, tool-result, usage, and terminal events. |
| Structured output | JSON Schema plus async semantic validation, bounded repair, streaming attempts, Pydantic and Zod materialization. |
| Evaluation | Deterministic text, tool-trajectory, terminal-state, usage, turn, and model-attempt gates over the current invocation. |
| Canonical messages | Text, reasoning, tools, media, citations, usage, and provider-owned metadata without flattening. |
| Governance | Global allow / ask / deny, declarative JSON policy, async approval, lifecycle hooks, and authoritative denial. |
| Plan mode | Whole-approach HITL: the agent proposes a plan; a human approves, revises, or rejects before tools run. |
| Smart approval | Keyless risk scoring auto-allows low-risk ask calls and escalates the rest to a human. |
| Reliability rules | Declarative tool ordering, prerequisites, and use caps — separate from security permissions. |
| Off-prompt output | Large or sensitive tool results stored by reference so they do not fill the model context. |
| Guardrails | Deterministic secret/PII redaction, regex blocking, and fail-closed MCP safety-server interop. |
| Self-extension | Human-governed capability requests: the agent asks for a tool it lacks, a human decides, the grant is recorded — never a silent escalation. |
| Tool runtime | Host callbacks plus opt-in Read, Write, Edit, Glob, Grep, and contained Bash. |
| MCP | Bounded stdio and Streamable HTTP client with tools, resources, prompts, auth/session propagation, exact allow/deny visibility filters, and governed execution. |
| Routing | Explicit or automatic model selection from a caller-owned catalog with hard capability and cost gates. |
| Resilience | Typed failures, bounded retry, pre-stream fallback, cancellation, deadlines, and terminal outcomes. |
| Orchestration | Scoped subagents, ordered parallel fan-out, council synthesis, quorum, and shared budget accounting. |
| State | Namespaced memory, revisioned sessions, JSON/transactional SQLite persistence, canonical recording, and resume. |
| Compaction | Opt-in transcript bounding: keep the task anchor and recent tail within a token budget, preserving tool pairing. |
| Web and browser | HTTPS allowlisted fetch/search plus an existing-session WebDriver executor; browser registration requires an explicit assertion of caller-owned pre-request egress enforcement. |
| Observability | Typed audit lifecycle, metadata-only redaction by default, JSONL sinks, and an optional Rust OpenTelemetry bridge. |
Tool authorization happens immediately before the side effect—not in a prompt and not in a UI convention.
flowchart TD
START[Model emits tool call] --> SCHEMA[Compile and validate input schema]
SCHEMA -->|invalid| REJECT[Return typed error]
SCHEMA --> PRE[Run scoped PreTool hooks]
PRE -->|block| REJECT
PRE --> POLICY{Permission decision}
POLICY -->|deny| DENY[Authoritative denial<br/>executor is never called]
POLICY -->|ask| APPROVE{Host approval}
POLICY -->|allow| VALIDATE[Revalidate rewritten input]
APPROVE -->|deny| DENY
APPROVE -->|allow / rewrite| VALIDATE
VALIDATE --> EXEC[Execute exactly once]
EXEC --> POST[PostTool or failure hooks]
POST --> AUDIT[Record audit + usage + outcome]
AUDIT --> CONTINUE[Return result to model]
DENY --> CONTINUE
REJECT --> CONTINUE
A denied tool never reaches its callback. Approval and hook rewrites are schema-validated again before execution.
agent = aikit.Agent.from_env({})
async def lookup(payload: dict) -> str:
return f"price:{payload['symbol']}"
agent.add_tool(
"lookup",
"Look up one market symbol",
{
"type": "object",
"properties": {"symbol": {"type": "string"}},
"required": ["symbol"],
"additionalProperties": False,
},
lookup,
)
agent.set_permissions([
{"id": "approve-lookups", "effect": "ask", "tool": "lookup"},
])
async def approve(request: dict):
return "allow" if request["input"]["symbol"] == "AAPL" else "deny"
agent.can_use_tool(approve)
The same lifecycle exists in Rust and TypeScript; only the host callback syntax changes.
Rust also ships higher-level governance primitives that compose with the same engine:
// Declarative JSON → enforcing PermissionEngine
use aikit_core::PolicySpec;
let engine = PolicySpec::from_json(r#"{
"mode": "allow",
"deny": ["Bash(rm -rf *)"],
"ask": ["Bash(git push *)"],
"allow": ["Read(*)"]
}"#)?.build()?;
// Plan mode: review the whole approach before any tool runs
// cargo run -p aikit-runtime-core --example plan_mode
// Smart approval: auto-allow Low risk, escalate the rest
// cargo run -p aikit-runtime-core --example smart_approval
// Reliability: deploy only after test, at most once
// cargo run -p aikit-runtime-core --example reliability
See the feature reference for plan review, risk scoring, reliability rules, off-prompt tool output, and capability requests.
aikit uses native adapters rather than forcing every provider through one lossy compatibility
shape.
| Provider | Native API | Reasoning continuation | Structured output | Vision |
|---|---|---|---|---|
| Anthropic | Messages | Signed thinking replayed unchanged | Native JSON Schema constraint | Yes |
| OpenAI | Responses | Opaque reasoning item replayed unchanged | Strict JSON Schema | Yes |
Gemini generateContent | Thought signature retained on the exact function-call part | responseJsonSchema | Yes | |
| DeepSeek | Chat Completions | Full reasoning_content retained for tool continuation | JSON mode + validation and repair | No |
OpenRouter, Groq, Mistral, and xAI are supported through isolated OpenAI-compatible endpoints. They do not inherit native-provider fidelity claims automatically;