Skip to content

Class: PrefactorClient\<TMiddleware\>

Prefactor TypeScript SDK


Prefactor TypeScript SDK / @prefactor/core / PrefactorClient

Defined in: packages/core/src/client.ts:85

TMiddleware = MiddlewareLike

new PrefactorClient<TMiddleware>(core, middleware, provider): PrefactorClient<TMiddleware>

Defined in: packages/core/src/client.ts:97

Creates a Prefactor client bound to a runtime and provider middleware.

CoreRuntime

Initialized core runtime.

TMiddleware

Provider middleware returned by the integration.

PrefactorProvider<TMiddleware>

Provider used to construct the client.

PrefactorClient<TMiddleware>

getTracer(): Tracer

Defined in: packages/core/src/client.ts:112

Returns the runtime tracer used by this client.

Tracer

Active tracer instance.


getMiddleware(): TMiddleware

Defined in: packages/core/src/client.ts:121

Returns provider middleware created during initialization.

TMiddleware

Provider middleware object.


getTerminationMonitor(): TerminationMonitor

Defined in: packages/core/src/client.ts:125

TerminationMonitor


getAgentInstanceId(): string | null

Defined in: packages/core/src/client.ts:129

string | null


finishCurrentRun(): void

Defined in: packages/core/src/client.ts:141

Ends the current agent run and resets the termination monitor for the next run. Call this between runs in a long-running service loop.

Finishes the active agent instance (if any), resets the termination monitor so a fresh AbortSignal is available, and invokes the provider’s resetForNextRun hook to clear any per-run middleware state.

void


withSpan<T>(options, fn): Promise<T>

Defined in: packages/core/src/client.ts:160

Runs a function within a manually-created span.

T

ManualSpanOptions

Manual span options.

() => T | Promise<T>

Function executed inside the created span.

Promise<T>

Result of fn as a promise.


shutdown(): Promise<void>

Defined in: packages/core/src/client.ts:180

Flushes pending telemetry and releases the global singleton reference.

The global client reference is always cleared, even if shutdown fails.

Promise<void>

Promise that resolves when shutdown completes.