Core
@inixiative/foundry-core is the engine. Primitives, zero
opinions, no external service deps. Every agent, every orchestration
pattern in Foundry is assembled from these pieces. Open-source, MIT,
usable on its own.
Context layers are independent token caches.
A layer is not a slice of one shared context window. It's a small token-capped cache with its own source, its own warm-up, and its own eviction. The harness assembles the layers a message needs, diffs against what's already hydrated, and injects only the delta. Same-hash layers are skipped.
Project conventions, architecture notes, ADRs. Warmed from Markdown.
Learned patterns the Warden has earned. Accumulates over time.
Threat model + hard stops. The Warden's guard mode consults it.
Module boundaries and dependency rules. Keeps layers from leaking.
Long-lived operator notes. Survives session resets.
Per-thread reconciled signal. Sole writer: the Librarian.
Layer definitions live in .foundry/settings.json. Each has
maxTokens, one or more sources, and an owner agent. Add a
layer; the Cartographer learns when to route it.
Primitives.
Everything in core is a small, composable piece. Assemble them into your
own harness, or use the opinionated one in @inixiative/foundry.
Ordered set of layers. Hashes for delta-aware hydration — identical slices skip re-injection.
A conversation unit wrapped with layers, middleware, and a trace. Many threads per harness.
The session substrate. Wraps Claude Code with flow stages: pre-message, dispatch, post-action.
Tiered dispatch pipeline. Retry, permissions, token-budget — all middleware, all composable.
Cross-agent messaging. Wardens emit, Librarian reconciles, Herald watches across threads.
Spans for every stage. Makes the flow inspectable in the viewer, not just readable in logs.
Per-agent budgets with hard and soft caps. Enforced at the middleware layer, not after the fact.
Provider-agnostic permission flags. Unattended, supervised, restricted, browser — one policy set.
Lifecycle hooks for cross-cutting concerns. Plan mode, pre-tool gates, post-action observers.
Every correction the operator makes, attributed and timestamped. Feedstock for the Oracle loop.
Use it on its own
import { Harness, ContextStack, ContextLayer, Thread } from "@inixiative/foundry-core";
const stack = new ContextStack([
new ContextLayer({ id: "docs", maxTokens: 2000, sources: [/* ... */] }),
]);
const harness = new Harness({ stack, provider: /* your LLMProvider */ });
const thread = harness.thread({ id: "t1" });
await thread.send("what's the coverage rule?"); Core has no external service deps. Bring your own provider, your own adapters, your own agents. If you want opinions, upgrade to @inixiative/foundry.
License
@inixiative/foundry-core is MIT. Use it however you want.