Embedding

Embedding the kernel

The kernel is a single directory — api/src/core/ — with zero npm dependencies and zero imports outside itself (enforced by a purity gate in CI). Vendor it into any Node 24 project (native TypeScript, no build step).

1. Copy and implement

Copy api/src/core into your project, then implement the ports you need:

// 1. copy api/src/core → your project (e.g. ./agent-core)
// 2. implement the ports you need
const myTelemetry: TelemetrySource = {
  describe: () => ({ logsAvailable: false, metricsAvailable: true,
                     metricNames: ['checkout_error_rate'] }),
  queryMetrics: async (q) => /* call your time-series store */,
};

// 3. assemble and run const agent = createAgent({ llm: openaiProvider({ baseUrl, apiKey, model }), tools: [staticTools(...telemetryTools(myTelemetry))], store: inMemoryRunStore(), // or your own RunStore system: { role, environment, dataSources, outputFormat }, maxSteps: 12, }); for await (const ev of agent.run({ runId, input, mode: 'read-only' })) { … } ```

Ports you don't implement simply don't exist: a telemetry source without queryLogs produces no query_logs tool — there is no "configured but unavailable" state, and the system prompt reflects reality automatically.

The conclusion protocol

Every run must end through submit_findings — an enforced kernel tool. Text-only endings are nudged back. On submit, the kernel mechanically validates:

Consuming the result:

for await (const ev of agent.run({ runId, input })) {
  if (ev.type === 'findings') {
    // ev.findings.rootCauses[].evidence[] already verified by the kernel —
    // render it, gate automation on confidence, ship it to your audit system
  }
  if (ev.type === 'done') audit.write(ev.outcome.summary, ev.outcome.usage);
}

Run store

Persist trajectories with block-paired replay and terminal outcomes by implementing RunStore (appendTurn batched, appendOutcome, load). The PG implementation (platform/run-store-pg.ts) is a working reference: legacy-compatible audit columns plus structured blocks JSONB.