Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu
SDKsAgent SDKTypeScript

@segmentstream/agent/evals

17 public exports from @segmentstream/agent/evals.

Public exports

Assertion

A value-level assertion produced by the builders in `eve/evals/expect` (e.g. `includes`, `equals`, `similarity`) and applied to an explicit value via `t.check(value, assertion)`. Boolean assertions score exactly 0 or 1. The chainable `gate`/`soft`/`atLeast` return a new assertion with the severity or threshold overridden.

interface Assertion {
    readonly name: string;
    readonly severity: AssertionSeverity;
    readonly threshold?: number;
    score(value: unknown): number | Promise<number>;
    evaluate?(value: unknown): AssertionEvaluation | Promise<AssertionEvaluation>;
    gate(threshold?: number): Assertion;
    soft(threshold?: number): Assertion;
    atLeast(threshold: number): Assertion;
}
EveEval

Validated eval consumed by the runner and reporters. The `id` is the path-derived slug attached by discovery (e.g. `evals/weather.eval.ts` → `"weather"`, `evals/runtime/multi-turn.eval.ts` → `"runtime/multi-turn"`). Files that default-export an array of evals derive `<file-id>/<zero-padded index>` ids (e.g. `"weather/0000"`).

type EveEval = EveEvalDefinition & {
    readonly id: string;
};
EveEvalConfig

Validated eval run configuration returned by `defineEvalConfig()`. The `_tag` literal brands the value so discovery can recognize it.

type EveEvalConfig<TContext = unknown> = EveEvalConfigInput<TContext> & {
    readonly _tag: "EveEvalConfig";
};
EveEvalContext

The context passed to `test(t)`. Creates independent sessions and carries run-level assertions, value-level assertions, and model-backed judges. Scoped assertions (`succeeded`, `calledTool`, …) record an entry evaluated after the test body; `check`, `require`, and `judge` evaluate explicit values.

interface EveEvalContext<TContext = unknown> extends EveEvalAssertions {
    readonly context: TContext;
    readonly abortSignal: AbortSignal;
    readonly target: EveEvalTargetHandle;
    log(message: string): void;
    sleep(ms?: number): Promise<void>;
    session(options?: EveEvalSessionOptions): Promise<EveEvalSession>;
    send(message: SendTurnInput["message"], options?: SendTurnOptions): Promise<EveEvalTurn>;
    check(value: unknown, assertion: Assertion): AssertionHandle;
    score(evaluation: ScoreInput): AssertionHandle;
    require<T>(value: T, assertion: Assertion): Promise<T>;
    skip(reason: string): never;
    readonly judge: JudgeContext;
}
EveEvalDefinition

Eval returned by `defineEval()`. Carries no `id` yet: discovery stamps the path-derived id at import time to produce a full {@link EveEval}. The `_tag` literal (`"EveEval"`) brands the value so discovery and the runner can recognize a defined eval.

type EveEvalDefinition<TContext = unknown> = EveEvalInput<TContext> & {
    readonly _tag: "EveEval";
};
TelegramEvalReceipt
interface TelegramEvalReceipt {
    readonly eventId: string;
    readonly provenance: "workspace_chat_history";
    readonly source: TelegramEvalReceiptTarget;
    readonly text: string | null;
    readonly files: ReadonlyArray<{
        readonly id: string;
        readonly type?: string;
    }>;
    readonly location?: {
        readonly latitude: number;
        readonly longitude: number;
    };
    readonly sessionId?: string;
    readonly turnId?: string;
}
TelegramEvalReceiptTarget

The sender's Telegram receipt in the receiving test bot's conversation. In private chats and basic groups Telegram assigns message IDs per account, so the receiver's own message ID and bot ID are required.

interface TelegramEvalReceiptTarget {
    readonly channel: string;
    readonly chatId: string;
    readonly receiverBotId?: string;
    readonly senderId: string;
    readonly messageId: string;
    readonly sentAt: string;
    readonly sender: "bot" | "human";
}
defineEval

Defines one eve eval. Each eval file is exactly one case: an imperative `test(t)` function that drives the agent (`t.session`, `t.send`, …) and asserts on what it produced (`t.succeeded()`, `t.check(...)`, `t.judge(...)`). Organize related evals with directory nesting under `evals/`, or default-export an array of evals to fan one file out over a dataset. Pass `defineEval<typeof config>(...)` with a type-only config import to infer the setup context available as `t.context`. A `judge` is optional: `t.judge(...)` assertions fall back to the `judge` declared in `evals.config.ts`, then the shared decision default. The judge model is used solely for scoring, never for the agent under test. Eval identity is derived from the `evals/<path>.eval.ts` file path by the discovery layer, so authoring `id` or `name` throws. Throws on invalid input: a missing `test` function, a removed legacy key (`input`/`run`/`checks`/`scores`/`expected`/`thresholds`/`parseOutput`/ `model`/`requires`), or a negative or non-finite `timeoutMs`.

function defineEval<TConfig extends EveEvalConfig = EveEvalConfig>(input: EveEvalInput<EveEvalConfigContext<TConfig>>): EveEvalDefinition<EveEvalConfigContext<TConfig>>;
defineEvalConfig

Defines the run-wide configuration shared by every eval, authored as the default export of `evals.config.ts` at the root of the `evals/` directory. Exactly one `evals.config.ts` is required. It supplies the optional default `judge` model for `t.judge(...)` assertions (so individual evals need not repeat it), run-level `reporters`, `maxConcurrency`, `timeoutMs`, and `repeat` defaults, optional run-wide `setup` and `teardown`, and credentials or a credential resolver in `targetAuth`. CLI flags (`--max-concurrency`, `--timeout`, `--repeat`) and per-eval values take precedence over the config defaults. Throws on invalid input: a non-positive or non-integer `maxConcurrency` or `repeat`, a negative or non-finite `timeoutMs`, non-array `reporters`, a non-function `setup` or `teardown`, or a `targetAuth` that is neither a resolver nor credentials with exactly one usable auth scheme.

function defineEvalConfig<TContext = undefined>(input: EveEvalConfigInput<TContext>): EveEvalConfig<TContext>;
equals

Passes when the value deep-equals `expected` (exact structural equality). A hard gate by default.

function equals(expected: unknown): Assertion;
evalParticipant

A separate preview-only member's client for one named participant in a hosted eval.

function evalParticipant(target: Pick<EveEvalContext["target"], "kind" | "url">, name: string): Client;
includes

Passes when the value (coerced to a string) contains a substring or matches a RegExp. A hard gate by default.

function includes(substring: string | RegExp): Assertion;
matches

Passes when the value validates against a Standard Schema (e.g. a Zod schema). A hard gate by default.

function matches(schema: StandardSchemaV1): Assertion;
satisfies

Passes when `predicate` returns true for the supplied value.

function satisfies<T = unknown>(predicate: (value: T) => boolean, label: string): Assertion;
similarity

Scores normalized character-level Levenshtein similarity between the value and `expected` (1 = identical, 0 = entirely different). Soft by default — tracked unless you set a bar with `.atLeast(...)`. Use it for fuzzy comparison when exact match is too strict but a judge model is overkill.

function similarity(expected: string): Assertion;
telegramEvalContentDigest

Content expected from a test bot's successful sendMessage, sendPhoto or sendLocation. Uses the same revision as the receiving Telegram channel. The separate receipt check selects the chat, bots and receiving message. File identity uses the stable Telegram ID shared by both bots.

function telegramEvalContentDigest(raw: unknown): string | undefined;
telegramEvalReceipt

Match a provider receipt against rows read by the runner through the staging ontology's authorized chat/history API under the run's pinned workspace and registered chat. This is an assertion for evals. A matching bot is still a bot; the result is neither an admission credential nor authority to start a turn. Unknown provenance, replacement, edits and ambiguous receipts fail closed.

function telegramEvalReceipt(target: TelegramEvalReceiptTarget, events: ReadonlyArray<unknown>): TelegramEvalReceipt | undefined;