Skip to content

@codesoul-co/hypha-testing / replay

Using this module

Use the Replay module for using the public contracts and operations for this capability boundary. It exports 3 classes, 3 functions, 10 interfaces.

Import from the package entrypoint

ts
import {
  FileReplayFixtureStore,
  InMemoryReplayFixtureStore,
  ReplayEngine,
  diffStringSequences,
  normalizeEvents,
  projectReplay,
} from '@codesoul-co/hypha-testing';

import type {
  FileReplayFixtureStoreOptions,
  ReplayCaptureInput,
  ReplayEngineOptions,
  ReplayFixture,
  ReplayFixtureStore,
  ReplayProjection,
  ReplayResult,
  TraceDiff,
} from '@codesoul-co/hypha-testing';

// The complete export list is documented below.

Usage patterns

  • Use the 10 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 3 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 3 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
FileReplayFixtureStoreclassnew FileReplayFixtureStore(options: FileReplayFixtureStoreOptions): FileReplayFixtureStoreFile Replay Fixture Store class with 4 public constructor or member entries; its exact declarations are listed below.
InMemoryReplayFixtureStoreclassnew InMemoryReplayFixtureStore(): InMemoryReplayFixtureStoreIn Memory Replay Fixture Store class with 4 public constructor or member entries; its exact declarations are listed below.
ReplayEngineclassnew ReplayEngine(options?: ReplayEngineOptions): ReplayEngineReplay Engine class with 6 public constructor or member entries; its exact declarations are listed below.
diffStringSequencesfunctiondiffStringSequences(expected: string[], actual: string[]): TraceSequenceDiffDiff String Sequences function with 1 public call signature; parameters and return types are listed below.
normalizeEventsfunctionnormalizeEvents(events: FrameworkEvent[]): FrameworkEvent[]Normalize Events function with 1 public call signature; parameters and return types are listed below.
projectReplayfunctionprojectReplay(events: FrameworkEvent[]): ReplayProjectionProject Replay function with 1 public call signature; parameters and return types are listed below.
FileReplayFixtureStoreOptionsinterfaceinterface FileReplayFixtureStoreOptionsFile Replay Fixture Store Options interface with 2 public fields or methods.
ReplayCaptureInputinterfaceinterface ReplayCaptureInputReplay Capture Input interface with 7 public fields or methods.
ReplayEngineOptionsinterfaceinterface ReplayEngineOptionsReplay Engine Options interface with 8 public fields or methods.
ReplayFixtureinterfaceinterface ReplayFixtureReplay Fixture interface with 15 public fields or methods.
ReplayFixtureStoreinterfaceinterface ReplayFixtureStoreReplay Fixture Store interface with 3 public fields or methods.
ReplayProjectioninterfaceinterface ReplayProjectionReplay Projection interface with 9 public fields or methods.
ReplayResultinterfaceinterface ReplayResultReplay Result interface with 3 public fields or methods.
TraceDiffinterfaceinterface TraceDiffTrace Diff interface with 8 public fields or methods.
TraceSequenceDiffinterfaceinterface TraceSequenceDiffTrace Sequence Diff interface with 6 public fields or methods.
TraceValueDiffinterfaceinterface TraceValueDiffTrace Value Diff interface with 3 public fields or methods.

FileReplayFixtureStore

File Replay Fixture Store class with 4 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { FileReplayFixtureStore } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare class FileReplayFixtureStore implements ReplayFixtureStore {
    constructor(options: FileReplayFixtureStoreOptions);
    save(fixture: ReplayFixture): Promise<void>;
    get(id: string): Promise<ReplayFixture | null>;
    list(): Promise<ReplayFixture[]>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: FileReplayFixtureStoreOptions): FileReplayFixtureStoreCreates an instance of this class.
getmethodget(id: string): Promise<ReplayFixture | null>Public method; parameters and return type are shown in the signature.
listmethodlist(): Promise<ReplayFixture[]>Public method; parameters and return type are shown in the signature.
savemethodsave(fixture: ReplayFixture): Promise<void>Public method; parameters and return type are shown in the signature.

InMemoryReplayFixtureStore

In Memory Replay Fixture Store class with 4 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryReplayFixtureStore } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare class InMemoryReplayFixtureStore implements ReplayFixtureStore {
    save(fixture: ReplayFixture): Promise<void>;
    get(id: string): Promise<ReplayFixture | null>;
    list(): Promise<ReplayFixture[]>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): InMemoryReplayFixtureStoreCreates an instance of this class.
getmethodget(id: string): Promise<ReplayFixture | null>Public method; parameters and return type are shown in the signature.
listmethodlist(): Promise<ReplayFixture[]>Public method; parameters and return type are shown in the signature.
savemethodsave(fixture: ReplayFixture): Promise<void>Public method; parameters and return type are shown in the signature.

ReplayEngine

Replay Engine class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { ReplayEngine } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare class ReplayEngine {
    constructor(options?: ReplayEngineOptions);
    capture(input: ReplayCaptureInput): Promise<ReplayFixture>;
    replay(fixture: ReplayFixture): ReplayResult;
    compare(expected: ReplayFixture, actual: ReplayFixture | FrameworkEvent[]): TraceDiff;
    getFixture(id: string): Promise<ReplayFixture | null>;
    listFixtures(): Promise<ReplayFixture[]>;
}

Public members

MemberKindSignatureDescription
capturemethodcapture(input: ReplayCaptureInput): Promise<ReplayFixture>Public method; parameters and return type are shown in the signature.
comparemethodcompare(expected: ReplayFixture, actual: ReplayFixture | FrameworkEvent[]): TraceDiffPublic method; parameters and return type are shown in the signature.
constructorconstructor(options?: ReplayEngineOptions): ReplayEngineCreates an instance of this class.
getFixturemethodgetFixture(id: string): Promise<ReplayFixture | null>Public method; parameters and return type are shown in the signature.
listFixturesmethodlistFixtures(): Promise<ReplayFixture[]>Public method; parameters and return type are shown in the signature.
replaymethodreplay(fixture: ReplayFixture): ReplayResultPublic method; parameters and return type are shown in the signature.

diffStringSequences

Diff String Sequences function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { diffStringSequences } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare function diffStringSequences(expected: string[], actual: string[]): TraceSequenceDiff;

Call signature

text
diffStringSequences(expected: string[], actual: string[]): TraceSequenceDiff

Parameters

ParameterTypeRequiredDescription
expectedstring[]YesRequired parameter; accepted values are defined by the type column.
actualstring[]YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: TraceSequenceDiff
  • Description: The return contract is defined by the type shown above.

normalizeEvents

Normalize Events function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { normalizeEvents } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare function normalizeEvents(events: FrameworkEvent[]): FrameworkEvent[];

Call signature

text
normalizeEvents(events: FrameworkEvent[]): FrameworkEvent[]

Parameters

ParameterTypeRequiredDescription
eventsFrameworkEvent<unknown>[]YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: FrameworkEvent<unknown>[]
  • Description: The return contract is defined by the type shown above.

projectReplay

Project Replay function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { projectReplay } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export declare function projectReplay(events: FrameworkEvent[]): ReplayProjection;

Call signature

text
projectReplay(events: FrameworkEvent[]): ReplayProjection

Parameters

ParameterTypeRequiredDescription
eventsFrameworkEvent<unknown>[]YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: ReplayProjection
  • Description: The return contract is defined by the type shown above.

FileReplayFixtureStoreOptions

File Replay Fixture Store Options interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { FileReplayFixtureStoreOptions } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface FileReplayFixtureStoreOptions {
    directory: string;
    extension?: string;
}

Contract members

MemberKindSignatureDescription
directorypropertydirectory: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
extensionpropertyextension?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ReplayCaptureInput

Replay Capture Input interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayCaptureInput } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayCaptureInput {
    id: string;
    version: string;
    runId: string;
    events?: FrameworkEvent[];
    replaySpec?: ReplaySpec;
    outputContract?: OutputContractSpec;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
eventspropertyevents?: FrameworkEvent<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
outputContractpropertyoutputContract?: OutputContractSpecPublic property; its type, readonly modifier and optionality are shown in the signature.
replaySpecpropertyreplaySpec?: ReplaySpecPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
versionpropertyversion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ReplayEngineOptions

Replay Engine Options interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayEngineOptions } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayEngineOptions {
    eventStore?: EventStore;
    fixtureStore?: ReplayFixtureStore;
    now?: () => string;
    trace?: TraceRecorder;
    sessionId?: string;
    workspaceId?: string;
    agentId?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
eventStorepropertyeventStore?: EventStorePublic property; its type, readonly modifier and optionality are shown in the signature.
fixtureStorepropertyfixtureStore?: ReplayFixtureStorePublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
sessionIdpropertysessionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tracepropertytrace?: TraceRecorderPublic property; its type, readonly modifier and optionality are shown in the signature.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ReplayFixture

Replay Fixture interface with 15 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayFixture } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayFixture {
    id: string;
    version: string;
    runId: string;
    createdAt: string;
    replaySpecRef?: SpecRef;
    events: FrameworkEvent[];
    eventTypes: string[];
    statePath: string[];
    finalOutput?: unknown;
    toolCalls: string[];
    modelCalls: string[];
    policyDecisions: string[];
    memoryReadSet: string[];
    outputContract?: OutputContractSpec;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
eventspropertyevents: FrameworkEvent<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
eventTypespropertyeventTypes: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
finalOutputpropertyfinalOutput?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryReadSetpropertymemoryReadSet: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
modelCallspropertymodelCalls: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
outputContractpropertyoutputContract?: OutputContractSpecPublic property; its type, readonly modifier and optionality are shown in the signature.
policyDecisionspropertypolicyDecisions: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
replaySpecRefpropertyreplaySpecRef?: SpecRefPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statePathpropertystatePath: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
toolCallspropertytoolCalls: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
versionpropertyversion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ReplayFixtureStore

Replay Fixture Store interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayFixtureStore } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayFixtureStore {
    save(fixture: ReplayFixture): Promise<void>;
    get(id: string): Promise<ReplayFixture | null>;
    list(): Promise<ReplayFixture[]>;
}

Contract members

MemberKindSignatureDescription
getmethodget(id: string): Promise<ReplayFixture | null>Public method; parameters and return type are shown in the signature.
listmethodlist(): Promise<ReplayFixture[]>Public method; parameters and return type are shown in the signature.
savemethodsave(fixture: ReplayFixture): Promise<void>Public method; parameters and return type are shown in the signature.

ReplayProjection

Replay Projection interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayProjection } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayProjection {
    runId: string;
    events: FrameworkEvent[];
    eventTypes: string[];
    statePath: string[];
    finalOutput?: unknown;
    toolCalls: string[];
    policyDecisions: string[];
    memoryReadSet: string[];
    modelCalls: string[];
}

Contract members

MemberKindSignatureDescription
eventspropertyevents: FrameworkEvent<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
eventTypespropertyeventTypes: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
finalOutputpropertyfinalOutput?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryReadSetpropertymemoryReadSet: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
modelCallspropertymodelCalls: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
policyDecisionspropertypolicyDecisions: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statePathpropertystatePath: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
toolCallspropertytoolCalls: string[]Public property; its type, readonly modifier and optionality are shown in the signature.

ReplayResult

Replay Result interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ReplayResult } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface ReplayResult {
    fixtureId: string;
    runId: string;
    projection: ReplayProjection;
}

Contract members

MemberKindSignatureDescription
fixtureIdpropertyfixtureId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
projectionpropertyprojection: ReplayProjectionPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

TraceDiff

Trace Diff interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { TraceDiff } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface TraceDiff {
    passed: boolean;
    eventTypes: TraceSequenceDiff;
    statePath: TraceSequenceDiff;
    toolCalls: TraceSequenceDiff;
    modelCalls: TraceSequenceDiff;
    policyDecisions: TraceSequenceDiff;
    memoryReadSet: TraceSequenceDiff;
    output: TraceValueDiff;
}

Contract members

MemberKindSignatureDescription
eventTypespropertyeventTypes: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryReadSetpropertymemoryReadSet: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
modelCallspropertymodelCalls: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
outputpropertyoutput: TraceValueDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
passedpropertypassed: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
policyDecisionspropertypolicyDecisions: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
statePathpropertystatePath: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.
toolCallspropertytoolCalls: TraceSequenceDiffPublic property; its type, readonly modifier and optionality are shown in the signature.

TraceSequenceDiff

Trace Sequence Diff interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { TraceSequenceDiff } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface TraceSequenceDiff {
    passed: boolean;
    expected: string[];
    actual: string[];
    missing: string[];
    extra: string[];
    mismatches: Array<{
        index: number;
        expected?: string;
        actual?: string;
    }>;
}

Contract members

MemberKindSignatureDescription
actualpropertyactual: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
expectedpropertyexpected: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
extrapropertyextra: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
mismatchespropertymismatches: { index: number; expected?: string; actual?: string; }[]Public property; its type, readonly modifier and optionality are shown in the signature.
missingpropertymissing: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
passedpropertypassed: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

TraceValueDiff

Trace Value Diff interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { TraceValueDiff } from '@codesoul-co/hypha-testing';
  • Source module: replay

Declaration

text
export interface TraceValueDiff {
    passed: boolean;
    expected?: unknown;
    actual?: unknown;
}

Contract members

MemberKindSignatureDescription
actualpropertyactual?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedpropertyexpected?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
passedpropertypassed: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.