Skip to content

@prefactor/core

Prefactor TypeScript SDK


Prefactor TypeScript SDK / @prefactor/core

Shared runtime, tracing primitives, and transport abstractions for Prefactor SDK adapters.

@prefactor/core is the foundation for Prefactor integrations. Use it when you want direct control over tracing lifecycle, transport behavior, and custom instrumentation in your app.

The package supports validated runtime configuration through createConfig, runtime initialization through createCore, manual instrumentation through withSpan and Tracer.startSpan, and graceful lifecycle handling with shutdown and registerShutdownHandler.

import { createConfig, createCore } from '@prefactor/core';
const config = createConfig({
transportType: 'http',
httpConfig: {
apiUrl: 'https://api.prefactor.ai',
apiToken: process.env.PREFACTOR_API_TOKEN!,
agentIdentifier: '1.0.0',
},
});
const core = createCore(config);
// core.tracer, core.agentManager, core.shutdown()
import { withSpan } from '@prefactor/core';
const result = await withSpan(
{
name: 'custom-operation',
spanType: 'app:task',
inputs: { jobId: 'job-123' },
},
async () => {
return { ok: true };
}
);