@codesoul-co/hypha-testing / mock-execution-provider
- Package index:
@codesoul-co/hypha-testing - Source:
packages/testing/src/mock-execution-provider.ts - Exports: 4
Using this module
Use the Mock execution provider module for binding external or local providers to Hypha ports. It exports 2 classes, 2 interfaces.
Import from the package entrypoint
ts
import {
MockExecutionProvider,
MockExecutionProviderError,
} from '@codesoul-co/hypha-testing';
import type {
MockExecutionBehavior,
MockExecutionProviderOptions,
} from '@codesoul-co/hypha-testing';Usage patterns
- Use the 2 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 2 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
MockExecutionProvider | class | new MockExecutionProvider(options?: MockExecutionProviderOptions): MockExecutionProvider | Deterministic, in-memory SandboxProvider for contract tests, replay fixtures, and failure injection. It never starts a process or mutates a real Workspace. |
MockExecutionProviderError | class | new MockExecutionProviderError(normalizedError: NormalizedExecutionError): MockExecutionProviderError | Mock Execution Provider Error class with 9 public constructor or member entries; its exact declarations are listed below. |
MockExecutionBehavior | interface | interface MockExecutionBehavior | Mock Execution Behavior interface with 17 public fields or methods. |
MockExecutionProviderOptions | interface | interface MockExecutionProviderOptions | Mock Execution Provider Options interface with 8 public fields or methods. |
MockExecutionProvider
Deterministic, in-memory SandboxProvider for contract tests, replay fixtures, and failure injection. It never starts a process or mutates a real Workspace.
- Kind: class
- Import:
import { MockExecutionProvider } from '@codesoul-co/hypha-testing'; - Source module:
mock-execution-provider
Declaration
text
export declare class MockExecutionProvider implements SandboxProvider {
readonly id: string;
constructor(options?: MockExecutionProviderOptions);
enqueue(behavior: MockExecutionBehavior): void;
setHealth(health: ProviderHealth): void;
capabilities(): Promise<SandboxProviderCapabilities>;
create(input: SandboxCreateRequest): Promise<SandboxRecord>;
start(input: SandboxStartRequest): Promise<SandboxRecord>;
execute(input: CommandExecutionRequest): Promise<CommandExecutionResult>;
cancel(input: ExecutionCancelRequest): Promise<void>;
terminate(input: SandboxTerminateRequest): Promise<void>;
status(input: SandboxStatusRequest): Promise<SandboxRecord | null>;
cleanup(input: SandboxCleanupRequest): Promise<void>;
health(): Promise<ProviderHealth>;
close(): Promise<void>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
cancel | method | cancel(input: ExecutionCancelRequest): Promise<void> | Public method; parameters and return type are shown in the signature. |
capabilities | method | capabilities(): Promise<SandboxProviderCapabilities> | Public method; parameters and return type are shown in the signature. |
cleanup | method | cleanup(input: SandboxCleanupRequest): Promise<void> | Public method; parameters and return type are shown in the signature. |
close | method | close(): Promise<void> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (options?: MockExecutionProviderOptions): MockExecutionProvider | Creates an instance of this class. |
create | method | create(input: SandboxCreateRequest): Promise<SandboxRecord> | Public method; parameters and return type are shown in the signature. |
enqueue | method | enqueue(behavior: MockExecutionBehavior): void | Public method; parameters and return type are shown in the signature. |
execute | method | execute(input: CommandExecutionRequest): Promise<CommandExecutionResult> | Public method; parameters and return type are shown in the signature. |
health | method | health(): Promise<ProviderHealth> | Public method; parameters and return type are shown in the signature. |
id | property | readonly id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
setHealth | method | setHealth(health: ProviderHealth): void | Public method; parameters and return type are shown in the signature. |
start | method | start(input: SandboxStartRequest): Promise<SandboxRecord> | Public method; parameters and return type are shown in the signature. |
status | method | status(input: SandboxStatusRequest): Promise<SandboxRecord | null> | Public method; parameters and return type are shown in the signature. |
terminate | method | terminate(input: SandboxTerminateRequest): Promise<void> | Public method; parameters and return type are shown in the signature. |
MockExecutionProviderError
Mock Execution Provider Error class with 9 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { MockExecutionProviderError } from '@codesoul-co/hypha-testing'; - Source module:
mock-execution-provider
Declaration
text
export declare class MockExecutionProviderError extends Error {
readonly normalizedError: NormalizedExecutionError;
constructor(normalizedError: NormalizedExecutionError);
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
cause | property | cause?: unknown | Public property; its type, readonly modifier and optionality are shown in the signature. |
constructor | constructor | (normalizedError: NormalizedExecutionError): MockExecutionProviderError | Creates an instance of this class. |
message | property | message: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
name | property | name: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
normalizedError | property | readonly normalizedError: NormalizedExecutionError | Public property; its type, readonly modifier and optionality are shown in the signature. |
stack | property | stack?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
static captureStackTrace | method | static captureStackTrace(targetObject: object, constructorOpt?: Function): void | Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called. js const myObject = {}; Error.captureStackTrace(myObject); myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}. The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance: js function a() { b(); } function b() { c(); } function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error; } a(); |
static prepareStackTrace | method | static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any | Public method; parameters and return type are shown in the signature. |
static stackTraceLimit | property | static stackTraceLimit: number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. |
MockExecutionBehavior
Mock Execution Behavior interface with 17 public fields or methods.
- Kind: interface
- Import:
import type { MockExecutionBehavior } from '@codesoul-co/hypha-testing'; - Source module:
mock-execution-provider
Declaration
text
export interface MockExecutionBehavior {
delayMs?: number;
status?: Extract<CommandExecutionStatus, 'completed' | 'failed' | 'timed_out' | 'oom_killed' | 'resource_exceeded' | 'quarantined'>;
exitCode?: number | null;
signal?: string;
stdout?: string;
stderr?: string;
stdoutTruncated?: boolean;
stderrTruncated?: boolean;
stdoutArtifactRef?: string;
stderrArtifactRef?: string;
changedFiles?: FileMutation[];
generatedArtifactRefs?: string[];
snapshotBeforeRef?: string;
snapshotAfterRef?: string;
resourceUsage?: ExecutionResourceUsage;
error?: NormalizedExecutionError;
metadata?: Record<string, unknown>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
changedFiles | property | changedFiles?: FileMutation[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
delayMs | property | delayMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
error | property | error?: NormalizedExecutionError | Public property; its type, readonly modifier and optionality are shown in the signature. |
exitCode | property | exitCode?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
generatedArtifactRefs | property | generatedArtifactRefs?: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
metadata | property | metadata?: Record<string, unknown> | Public property; its type, readonly modifier and optionality are shown in the signature. |
resourceUsage | property | resourceUsage?: ExecutionResourceUsage | Public property; its type, readonly modifier and optionality are shown in the signature. |
signal | property | signal?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
snapshotAfterRef | property | snapshotAfterRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
snapshotBeforeRef | property | snapshotBeforeRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
status | property | status?: "completed" | "failed" | "timed_out" | "oom_killed" | "resource_exceeded" | "quarantined" | Public property; its type, readonly modifier and optionality are shown in the signature. |
stderr | property | stderr?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stderrArtifactRef | property | stderrArtifactRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stderrTruncated | property | stderrTruncated?: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
stdout | property | stdout?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stdoutArtifactRef | property | stdoutArtifactRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stdoutTruncated | property | stdoutTruncated?: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
MockExecutionProviderOptions
Mock Execution Provider Options interface with 8 public fields or methods.
- Kind: interface
- Import:
import type { MockExecutionProviderOptions } from '@codesoul-co/hypha-testing'; - Source module:
mock-execution-provider
Declaration
text
export interface MockExecutionProviderOptions {
id?: string;
now?: () => string;
sandboxId?: (request: SandboxCreateRequest) => string;
executionId?: (request: CommandExecutionRequest) => string;
capabilities?: Partial<SandboxProviderCapabilities>;
health?: ProviderHealth;
behaviors?: MockExecutionBehavior[];
defaultBehavior?: MockExecutionBehavior;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
behaviors | property | behaviors?: MockExecutionBehavior[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
capabilities | property | capabilities?: Partial<SandboxProviderCapabilities> | Public property; its type, readonly modifier and optionality are shown in the signature. |
defaultBehavior | property | defaultBehavior?: MockExecutionBehavior | Public property; its type, readonly modifier and optionality are shown in the signature. |
executionId | method | executionId?(request: CommandExecutionRequest): string | Public method; parameters and return type are shown in the signature. |
health | property | health?: ProviderHealth | Public property; its type, readonly modifier and optionality are shown in the signature. |
id | property | id?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
sandboxId | method | sandboxId?(request: SandboxCreateRequest): string | Public method; parameters and return type are shown in the signature. |
