FauxModel
A scripted model for tests and examples. It is a real effect/ai LanguageModel, so generation takes the same path as
with a provider: each request takes the next scripted response and streams it in token-sized deltas.
import { FauxModel, Harness } from "@effective-harness/core"
const faux = FauxModel.make()faux.setResponses([ FauxModel.response([FauxModel.toolCall("read", { path: "a.txt" })], { stopReason: "toolUse" }), FauxModel.response("Done.")])const HarnessLive = Harness.layer({ models: faux.models })Since v0.0.0
Content (type alias)
Section titled “Content (type alias)”A content block of a scripted answer.
Signature
type Content = TextContent | ThinkingContent | ToolCallSince v0.0.0
Faux (interface)
Section titled “Faux (interface)”Signature
export interface Faux { /** Replace the script. */ readonly setResponses: (steps: ReadonlyArray<Step>) => void readonly appendResponses: (steps: ReadonlyArray<Step>) => void readonly pendingResponses: () => number /** Requests answered so far. */ readonly callCount: () => number /** Status checks of deferred answers so far. */ readonly deferredFetchCount: () => number /** Handles of the deferred answers cancelled so far. */ readonly cancelledDeferred: () => ReadonlyArray<DeferredHandle> /** One catalog model per definition; all share the script. */ readonly models: ReadonlyArray<CatalogModel>}Since v0.0.0
ModelDefinition (interface)
Section titled “ModelDefinition (interface)”Signature
export interface ModelDefinition { readonly id: string readonly contextWindow?: number readonly maxTokens?: number}Since v0.0.0
Options (interface)
Section titled “Options (interface)”Signature
export interface Options { readonly provider?: string readonly models?: ReadonlyArray<ModelDefinition> /** Streaming speed; absent streams at once. */ readonly tokensPerSecond?: number /** Tokens per delta (a token is 4 characters). Default 3 to 5. */ readonly tokenSize?: { readonly min?: number; readonly max?: number } /** * Deferred responses: a request that asks for one (`stream.deferred`) takes the next step but answers with a handle; * a fetch answers it after `pendingFetches` checks that are still pending (default 0). */ readonly deferred?: { readonly pendingFetches?: number; readonly pollAfterMs?: number }}Since v0.0.0
Request (interface)
Section titled “Request (interface)”What a scripted step sees: the request as effect/ai built it.
Signature
export interface Request { readonly prompt: Prompt.Prompt /** Names of the tools offered. */ readonly tools: ReadonlyArray<string> readonly modelId: string /** Requests answered so far, this one included. */ readonly callCount: number}Since v0.0.0
Response (interface)
Section titled “Response (interface)”A scripted answer.
Signature
export interface Response { readonly content: ReadonlyArray<Content> /** Default `"stop"`. `"error"` fails the request with `errorMessage`. */ readonly stopReason?: "stop" | "length" | "toolUse" | "error" readonly errorMessage?: string /** Whether an error is worth retrying, like a rate limit. Default `false`. */ readonly retryable?: boolean}Since v0.0.0
Step (type alias)
Section titled “Step (type alias)”A response, or a function of the request; it may suspend, for example until a test lets it continue.
Signature
type Step = Response | ((request: Request) => Response | Effect.Effect<Response>)Since v0.0.0
A scripted model.
Signature
declare const make: (options?: Options) => FauxSince v0.0.0
messageText
Section titled “messageText”The text of a prompt message, its tool calls and results rendered like pi’s faux model.
Signature
declare const messageText: (message: Prompt.Message) => stringSince v0.0.0
response
Section titled “response”A scripted answer from text or blocks.
Signature
declare const response: ( content: string | Content | ReadonlyArray<Content>, options?: Omit<Response, "content">) => ResponseSince v0.0.0
A text block.
Signature
declare const text: (value: string) => TextContentSince v0.0.0
thinking
Section titled “thinking”A thinking block.
Signature
declare const thinking: (value: string) => ThinkingContentSince v0.0.0
toolCall
Section titled “toolCall”A tool call; the ID defaults to a fresh one.
Signature
declare const toolCall: ( name: string, args: { readonly [key: string]: Json }, options?: { readonly id?: string }) => ToolCallSince v0.0.0