Skip to content

Testing APIs

The @aml-jsx/sdk/testing entrypoint contains credential-free fixtures and provider contract helpers. Keeping them in a separate entrypoint prevents production imports from pulling test utilities into application code.

import {
DeterministicAgentProvider,
DeterministicSandboxProvider,
DeterministicWorkspaceProvider,
} from "@aml-jsx/sdk/testing"

Records immutable Agent requests and returns responses from an application-owned strategy without starting a model, executable, network connection, or other resource.

const provider = new DeterministicAgentProvider({
name: "review-fixture",
respond: (request, context, callIndex) => ({
text: `${callIndex}:${request.prompt}:${context.trace.runId}`,
}),
supportsSandbox: sandbox => sandbox.access === "read-only",
})
Member or optionContract
nameProvider name; defaults to deterministic and must be non-empty and normalized.
respondReceives the normalized request, execution context, and zero-based call index.
supportsSandboxDeclares fixture compatibility with an effective Sandbox session.
callsRecorded { request, context } values in provider execution order.
run()Rejects a pre-aborted signal, records the call, then invokes the configured response.

Records acquisition and release without creating infrastructure. Its default runtime returns successful deterministic command output and maintains an invocation-local in-memory filesystem plus Agent staging; constructor hooks can replace handle creation, exec, spawn, and release behavior.

MemberContract
acquisitionsRecorded SandboxAcquireRequest values in acquisition order.
releasesReleased lease IDs in release order.
exec hookControls deterministic command results.
spawn hookControls deterministic process streams, completion, and kill.
release hookObserves or fails cleanup without provisioning a real Sandbox.

Records Workspace acquisition, save, and release. It supplies a deterministic directory and enforces one active writer per Workspace ID, making conflict and cleanup behavior testable without durable storage.

Member or optionContract
acquisitionsRecorded WorkspaceAcquireRequest values.
savesSaved lease IDs in save order.
releasesReleased lease IDs in release order.
directoryFixed directory or function of request and acquisition index.
lifecycle hooksApplication-owned createHandle, save, and release hooks.

InMemoryWorkspaceStorageAdapter is a stateful storage spy for persistence and provider tests. It implements conditional writes, locking, reads, lists, deletes, and release entirely in memory.

  • operations records ordered storage operations.
  • keys(workspaceId) returns sorted stored object paths.
  • text(workspaceId, path) reads one object as text.
HelperPurpose
agentProviderConformance()Validates response shape and pre-cancelled execution behavior.
sandboxProviderConformance()Validates Sandbox lease/runtime shape and release behavior.
workspaceProviderConformance()Exercises acquisition, conflict, save, release, and failure behavior.
createAgentExecutionContext()Creates an immutable provider execution context for direct adapter tests.

The conformance helpers are test-runner independent and reject when a provider violates the checked contract. Sandbox conformance does not execute commands or filesystem operations, which remain provider-specific behavior tests. The helpers do not prove vendor credentials, executable installation, remote availability, image contents, or production security.

For complete Vitest examples and test-boundary guidance, see Testing AML workflows.