@rivus/agent-kit/testing
createMemoryPlatform, sessionAdapterConformance, hookDialectConformance, probeRecipeConformance — Node
Functions
createMemoryPlatform()
function createMemoryPlatform(options?: MemoryPlatformOptions): MemoryPlatform;An in-memory Platform for tests. Paths are normalized (//, ., .. and a trailing /); there are no special
files or symlinks, so followSymlinks changes nothing. list rejects for a missing path or a file; writing a file
creates its parent directories; removing a missing path resolves; rename follows POSIX (it replaces a file or an
empty directory, and needs the target's parent). Stored bytes are copied on the way in and out. process.run
runs a seeded program only while its file exists, refuses a .cmd or .bat file on Windows as Node does, honors
timeoutMs and signal, and passes the platform's env unless the run gives one. Errors carry Node's code
(ENOENT, EACCES, EEXIST, EISDIR, ENOTDIR, ENOTEMPTY, EINVAL), as the Node platform's do.
Parameters
options?
MemoryPlatformOptions
Returns
MemoryPlatform
hookDialectConformance()
function hookDialectConformance(
dialect: HookDialect,
fixtures: HookDialectFixtures,
options?: HookDialectConformanceOptions
): ConformanceCheck[];The checks every hook dialect must pass, independent of a test runner: wire each into the runner, for example
for (const { name, run } of hookDialectConformance(dialect, fixtures, hooks)) it(name, run). Samples are read through
readHookEvent with this dialect merged over the given hooks table, so sniffing to another agent works as in use.
Parameters
dialect
HookDialect
fixtures
options?
Returns
ConformanceCheck[]
oversizedSession()
function oversizedSession(line: string): string;A session file of more than 128 KB made by repeating one JSONL line.
Parameters
line
string
Returns
string
probeRecipeConformance()
function probeRecipeConformance(
recipe: ProbeRecipe,
samples?: ProbeRecipeSamples,
options?: ProbeRecipeConformanceOptions
): ConformanceCheck[];The checks every probe recipe must pass, independent of a test runner: wire each into the runner, for example
for (const { name, run } of probeRecipeConformance(recipe, samples)) it(name, run). samples adds the recipe's
own outputs; without them, the checks use outputs any version parser should read.
Parameters
recipe
samples?
options?
Returns
ConformanceCheck[]
sessionAdapterConformance()
function sessionAdapterConformance(adapter: SessionAdapter, fixtures: SessionAdapterFixtures): ConformanceCheck[];The checks every session adapter must pass, independent of a test runner: wire each into the runner, for example
for (const { name, run } of sessionAdapterConformance(adapter, fixtures)) it(name, run).
Parameters
adapter
fixtures
Returns
ConformanceCheck[]
Interfaces
ConformanceSession
One fixture session and what its files demonstrate.
Properties
capabilities
readonly capabilities: readonly Capability[];Capabilities this session demonstrates. compaction also requires at least one shadowed event.
files?
readonly files?: readonly string[];Every JSONL file of the session; defaults to [path].
path
readonly path: string;The session file discover must return.
recordKeys?
readonly recordKeys?: readonly string[];The records of a source with no lines to count, such as a SQLite database, as ${file}\0${line} keys. When
present, the record accounting checks these keys instead of reading the files.
records
readonly records: number;Non-blank lines across files. Ignored when recordKeys names the records.
sessionId?
readonly sessionId?: string;The session id, for a source that keeps several sessions in one file or database.
HookDialectConformanceOptions
Properties
providers?
readonly providers?: readonly Provider[];HookDialectFixtures
Properties
samples
readonly samples: readonly HookDialectSample[];At least one sample per event in dialect.events.
HookDialectSample
One scrubbed payload of an agent and the LifecycleEvent it must read as.
Properties
declaredAgent?
readonly declaredAgent?: string;The agent the hook was registered for; defaults to the dialect's agent. Sniffing may name another.
env?
readonly env?: Readonly<Record<string, string>>;The hook process's whole environment; defaults to empty.
expected
readonly expected: LifecycleEvent;name
readonly name: string;payload
readonly payload: unknown;ProbeRecipeConformanceOptions
Properties
providers?
readonly providers?: readonly Provider[];ProbeRecipeSamples
Outputs a recipe's parsers must read, with what they must read from each (undefined: not recognized).
Properties
auth?
readonly auth?: readonly object[];credentialFiles?
readonly credentialFiles?: readonly object[];Content of a credential file the recipe parses. path is the file as the recipe names it, with an agent home
written as its default under ~, such as ~/.codex/auth.json.
versions?
readonly versions?: readonly object[];SessionAdapterFixtures
Properties
oversized?
readonly oversized?: object;A root that lists file, a session larger than 128 KB, such as one built by oversizedSession. A source that
has no file ends, such as a database, leaves it undefined and skips the edge-budget check.
file
readonly file: string;root
readonly root: string;platform
readonly platform: SessionPlatform;root
readonly root: string;A root whose sessions are exactly sessions.
sessions
readonly sessions: readonly ConformanceSession[];