eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
41 lines (40 loc) • 1.98 kB
TypeScript
/**
* Shared instrumentation primitives used by both the channel projection
* builder (`#channel/instrumentation.ts`) and the harness telemetry
* builder (`#harness/instrumentation-runtime-context.ts`).
*
* Both layers resolve a user-authored projector callback into a plain
* record and reason about the same channel-kind vocabulary. Keeping that
* vocabulary and the defensive resolution shell in one place stops the
* two sites from drifting (e.g. the framework-kind set growing in one
* file but not the other).
*/
import { type Logger } from "#internal/logging.js";
import type { InstrumentationChannelKind } from "#public/channels/index.js";
/**
* Returns `true` when `kind` is a valid instrumentation channel kind: a
* framework kind (`"http"`, `"schedule"`, `"subagent"`) or a
* path-derived `channel:<name>` kind.
*/
export declare function isInstrumentationChannelKind(kind: string): kind is InstrumentationChannelKind;
/**
* Narrows a raw kind string to the public {@link InstrumentationChannelKind}
* union, falling back to `"unknown"` for anything unrecognized or absent.
*/
export declare function normalizeInstrumentationChannelKind(rawKind: string | undefined): InstrumentationChannelKind;
/**
* Invokes a user-authored instrumentation projector defensively.
*
* Returns the JSON object the projector produced. Returns `undefined`
* without warning for a no-op `undefined`, or with a warning when it threw,
* returned a `Promise`, returned an incorrect shape, or included values
* outside eve's JSON contract. Every rejection path is warning-only so
* instrumentation can never break the turn. Per-value shaping (for example
* reserved-key filtering) is left to the caller, since the channel and
* harness expose different value shapes.
*/
export declare function resolveInstrumentationProjection(input: {
readonly invoke: () => unknown;
readonly log: Logger;
readonly source: string;
}): Record<string, unknown> | undefined;