createJevDevtools(options)#
Create one independent adapter for a Node process whose lifecycle you own.
// server/jev.ts — Node only
import { createJevDevtools } from "jev-devtools/server";
export const inspector = createJevDevtools({
enabled: process.env.NODE_ENV === "development",
origin: "http://localhost:3000", // Must match the browser URL exactly.
});
export const jev = inspector.createClient({
apiKey: process.env.TYPESAFE_API_KEY,
});Create an independent Node server adapter. Share it between your HTTP endpoints and instrumented clients.
createJevDevtools(options)- enabled
- Opt into server capture and inspector endpoints. Defaults to false; disabling capture does not stop inference.
- origin
- The exact browser origin, including scheme, hostname, and port.
- endpoint
- The inspector URL path. Defaults to /api/jev-devtools; must match the browser component.
- limit
- Maximum retained request traces across sessions. Defaults to 50; clamped to 1–200.
- redact
- Transform the captured copy before storage or streaming. Does not change SDK inputs or application values.
- authorize
- Your application access check. Required for an enabled non-loopback origin.
- getSession
- Derive a trusted recording scope from the request. Defaults to the shared local scope.
Opt into server capture and inspector endpoints. Defaults to false; disabling capture does not stop inference.
enabledThe exact browser origin, including scheme, hostname, and port.
originCreate an instrumented TypeSafe client. Captures systemOne calls when recording is enabled; otherwise returns an ordinary SDK client. Keep credentials on the server.
adapter.createClient(options, metadata?)- label
- Optional capture label. Defaults to Jev request.
- source
- Capture label: sample or live. Defaults to live. This does not switch transports or prevent inference.
API reference: createJevDevtools() · adapter.createClient()
Example walkthrough: the adapter enables inspection only in development and checks requests against the browser's origin. createClient() wraps the SDK client so its requests use the same recording history as the inspector routes. The key stays in this server module.
Return interface#
| Method | Return type | Description |
|---|---|---|
createJevDevtools(options) |
Adapter |
Independent adapter with routing, client, session, observer, and cleanup methods. |
Options#
| Option | Default | Purpose |
|---|---|---|
origin |
Required | Exact browser origin, including port. |
enabled |
false |
Enable capture and inspector endpoints. |
endpoint |
/api/jev-devtools |
Absolute path, without query or fragment. |
limit |
50 |
Maximum retained request traces, clamped to 1–200. |
redact(path, value) |
None | Transform captured values before storing or streaming. |
authorize(request) |
None | Synchronous or async application access check. Required for enabled non-loopback origins. |
getSession(request) |
Shared local scope |
Synchronous or async server-derived scope; a nonempty string of at most 200 characters. |
These form JevDevtoolsServerOptions; limit and redact also form the exported CaptureOptions type.
createClient(options, metadata?)#
Accepts the TypeSafe SDK's constructor options and returns an instrumented SDK client. Metadata is { label?: string, source?: 'sample' | 'live' }, exported as ClientMetadata. Defaults are Jev request and live.
const client = inspector.createClient(
{ apiKey: process.env.TYPESAFE_API_KEY },
{ label: "Support triage", source: "live" },
);Optional capture label. Defaults to Jev request.
labelCapture label: sample or live. Defaults to live. This does not switch transports or prevent inference.
sourceAPI reference: adapter.createClient()
Example walkthrough: the SDK options contain the server-side key. The metadata labels captures as “Support triage” and live. The returned client is the one your application should use for systemOne() calls.
Return interface#
| Value | Type | Description |
|---|---|---|
client |
TypeSafeClient |
Instrumented SDK client when enabled; ordinary SDK client when disabled. |
Changing source only labels captures; it does not turn live inference into a sample transport. With recording disabled, this method returns an ordinary SDK client. Only systemOne calls on the instrumented client are captured.
HTTP adapters#
| Method | Use when |
|---|---|
middleware(req, res, next) |
Your Node application uses Express/Connect-style middleware. Mount at root; unrelated paths call next. |
handle(request) |
Your framework supplies a Web Request with the actual public URL. Returns a Web Response. |
handleNodeRoute(request) |
A Node framework such as Next reconstructs internal request URLs. Checks Host, normalizes URL, then applies regular access checks. |
Return interfaces#
| Method | Return type | Description |
|---|---|---|
middleware |
Promise<void> |
Handles the Node response or continues through next(). |
handle |
Promise<Response> |
Web response containing configuration, events, clear results, or HTTP errors. |
handleNodeRoute |
Promise<Response> |
Same response contract after Host validation and URL normalization. |
Route the base path and all subpaths to the same adapter. The browser uses configuration, SSE events, flow events, and DELETE /clear. The package handles that protocol for you; see the stream protocol if building another viewer.
getJevDevtools(key, createOptions)#
import { getJevDevtools } from "jev-devtools/server";
const inspector = getJevDevtools("my-app", () => ({
enabled: process.env.NODE_ENV === "development",
origin: "http://localhost:3000",
}));Reuse an adapter for a stable key in the same Node realm. The options factory runs once per key; restart after configuration changes. Different processes do not share history.
getJevDevtools(key, createOptions)- key
- A stable, nonempty application key.
- createOptions
- Return the server options, including enabled and origin.
API reference: getJevDevtools() · createJevDevtools()
Example walkthrough: "my-app" identifies the shared adapter. The factory supplies options only on the first lookup, so module reloads reuse the same capture history.
Return interface#
| Value | Type | Description |
|---|---|---|
inspector |
Adapter |
Existing adapter for this key, or a newly created one. |
Returns the same adapter for a stable, nonempty key in the same Node realm. The options factory runs once per key. Restart after configuration changes. Different keys have separate histories; different processes do not share histories.
run(request, callback)#
Select the request's server-derived recording scope while the callback runs. Use it for inference handlers when getSession is customized:
return inspector.run(request, () => jev.systemOne(input));Run application code in the request's server-derived recording scope. Needed when getSession is customized. Authenticate the application action separately.
adapter.run(request, callback)API reference: adapter.run()
Example walkthrough: the adapter derives a session from request, then executes jev.systemOne(input) within that session. Its promise resolves to the SDK result; the wrapper does not replace it with recorder data.
Return interface#
| Value | Type | Description |
|---|---|---|
inspector.run(...) |
Promise<T> |
Resolves to the callback's value, or rejects with its error. |
Here request and input come from your application handler. Authenticate that handler separately: run scopes capture but does not authorize the application action.
dispose() and startFlow()#
dispose() disables the adapter and closes active streams. For shared adapters, it also releases the key. Use it at shutdown, not after each request.
startFlow(definition, run) implements the exported FlowObserver contract. Normally pass the adapter as devtools to a flow's run(); there is no need to invoke observer methods directly.
| Method | Return type | Description |
|---|---|---|
dispose() |
void |
No return data; disables the adapter and closes streams. |
startFlow(definition, run) |
{ update, request } | undefined |
Per-run observer hooks, or no hooks when recording is skipped. |