The core package

Core

@inixiative/foundry-core is the engine package inside the main Foundry repo. Primitives, zero opinions, no external service deps. The workshop is assembled from these pieces.

The hero primitive

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. Foundry assembles the layers a message needs, diffs against what's already hydrated, and injects only the delta. Same-hash layers are skipped.

docs

Project conventions, architecture notes, ADRs. Warmed from Markdown.

convention

Learned patterns the Warden has earned. Accumulates over time.

security

Threat model + hard stops. The Warden's guard mode consults it.

architecture

Module boundaries and dependency rules. Keeps layers from leaking.

memory

Long-lived operator notes. Survives session resets.

thread-state

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.

The rest of the engine

Primitives.

Everything in core is a small, composable piece. Assemble them yourself, or use the opinionated workshop in the main @inixiative/foundry package.

ContextStack

Ordered set of layers. Hashes for delta-aware hydration — identical slices skip re-injection.

Thread

A conversation unit wrapped with layers, middleware, and a trace. Many threads per workshop.

Harness

The internal session substrate. Publicly, Foundry packages this into the workshop around your agent.

MiddlewareChain

Tiered dispatch pipeline. Retry, permissions, token-budget — all middleware, all composable.

SignalBus

Cross-agent messaging. Wardens emit, Librarian reconciles, Herald watches across threads.

Trace

Spans for every stage. Makes the flow inspectable in the viewer, not just readable in logs.

TokenTracker

Per-agent budgets with hard and soft caps. Enforced at the middleware layer, not after the fact.

CapabilityGate

Provider-agnostic permission flags. Unattended, supervised, restricted, browser — one policy set.

HookRegistry

Lifecycle hooks for cross-cutting concerns. Plan mode, pre-tool gates, post-action observers.

InterventionLog

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 the full workshop, use @inixiative/foundry.

License

The core package is MIT and lives inside the main Foundry repository.