Skip to content

@codesoul-co/hypha-core / contracts/sandbox-provider

Using this module

Use the Sandbox provider module for declaring and runtime-validating contracts. It exports 6 interfaces, 3 types.

Import from the package entrypoint

ts
import type {
  SandboxCapabilityDerivationInput,
  SandboxCapabilityNegotiationRequest,
  SandboxCapabilityNegotiationResult,
  SandboxCapabilityRequirement,
  SandboxProvider,
  SandboxProviderFactory,
  SandboxCapabilityName,
  SandboxProviderSelection,
} from '@codesoul-co/hypha-core';

// The complete export list is documented below.

Usage patterns

  • Use the 9 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.

Public exports

SymbolKindSignatureDescription
SandboxCapabilityDerivationInputinterfaceinterface SandboxCapabilityDerivationInputSandbox Capability Derivation Input interface with 3 public fields or methods.
SandboxCapabilityNegotiationRequestinterfaceinterface SandboxCapabilityNegotiationRequestSandbox Capability Negotiation Request interface with 4 public fields or methods.
SandboxCapabilityNegotiationResultinterfaceinterface SandboxCapabilityNegotiationResultSandbox Capability Negotiation Result interface with 6 public fields or methods.
SandboxCapabilityRequirementinterfaceinterface SandboxCapabilityRequirementSandbox Capability Requirement interface with 3 public fields or methods.
SandboxProviderinterfaceinterface SandboxProviderSandbox Provider interface with 11 public fields or methods.
SandboxProviderFactoryinterfaceinterface SandboxProviderFactoryComposition-root contract for constructing a configured SandboxProvider. Concrete adapters own their options; core only knows the provider type and stable id.
SandboxCapabilityNametypetype SandboxCapabilityName = keyof SandboxProviderCapabilitiesPublic type alias for Sandbox Capability Name; the declaration contains its complete type expression.
SandboxProviderSelectiontypetype SandboxProviderSelection = Pick<ExecutionEnvironmentSpec, 'provider' | 'providerRef'>Public type alias for Sandbox Provider Selection; the declaration contains its complete type expression.
SandboxProviderTypetypetype SandboxProviderType = ExecutionEnvironmentSpec['provider']Public type alias for Sandbox Provider Type; the declaration contains its complete type expression.

SandboxCapabilityDerivationInput

Sandbox Capability Derivation Input interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { SandboxCapabilityDerivationInput } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export interface SandboxCapabilityDerivationInput {
    environment: ExecutionEnvironmentSpec;
    command?: Pick<CommandExecutionRequest, 'snapshotBefore' | 'snapshotAfter' | 'snapshotOnFailure'>;
    additionalRequirements?: SandboxCapabilityRequirement[];
}

Contract members

MemberKindSignatureDescription
additionalRequirementspropertyadditionalRequirements?: SandboxCapabilityRequirement[]Public property; its type, readonly modifier and optionality are shown in the signature.
commandpropertycommand?: Pick<CommandExecutionRequest, "snapshotBefore" | "snapshotAfter" | "snapshotOnFailure">Public property; its type, readonly modifier and optionality are shown in the signature.
environmentpropertyenvironment: ExecutionEnvironmentSpecPublic property; its type, readonly modifier and optionality are shown in the signature.

SandboxCapabilityNegotiationRequest

Sandbox Capability Negotiation Request interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { SandboxCapabilityNegotiationRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export interface SandboxCapabilityNegotiationRequest {
    providerId: string;
    capabilities: SandboxProviderCapabilities;
    requirements: SandboxCapabilityRequirement[];
    evaluatedAt: string;
}

Contract members

MemberKindSignatureDescription
capabilitiespropertycapabilities: SandboxProviderCapabilitiesPublic property; its type, readonly modifier and optionality are shown in the signature.
evaluatedAtpropertyevaluatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requirementspropertyrequirements: SandboxCapabilityRequirement[]Public property; its type, readonly modifier and optionality are shown in the signature.

SandboxCapabilityNegotiationResult

Sandbox Capability Negotiation Result interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { SandboxCapabilityNegotiationResult } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export interface SandboxCapabilityNegotiationResult {
    providerId: string;
    compatible: boolean;
    capabilities: SandboxProviderCapabilities;
    requirements: SandboxCapabilityRequirement[];
    missingCapabilities: SandboxCapabilityName[];
    evaluatedAt: string;
}

Contract members

MemberKindSignatureDescription
capabilitiespropertycapabilities: SandboxProviderCapabilitiesPublic property; its type, readonly modifier and optionality are shown in the signature.
compatiblepropertycompatible: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
evaluatedAtpropertyevaluatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
missingCapabilitiespropertymissingCapabilities: (keyof SandboxProviderCapabilities)[]Public property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requirementspropertyrequirements: SandboxCapabilityRequirement[]Public property; its type, readonly modifier and optionality are shown in the signature.

SandboxCapabilityRequirement

Sandbox Capability Requirement interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { SandboxCapabilityRequirement } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export interface SandboxCapabilityRequirement {
    capability: SandboxCapabilityName;
    source: 'environment' | 'command' | 'policy' | 'runtime';
    reason: string;
}

Contract members

MemberKindSignatureDescription
capabilitypropertycapability: keyof SandboxProviderCapabilitiesPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource: "policy" | "environment" | "command" | "runtime"Public property; its type, readonly modifier and optionality are shown in the signature.

SandboxProvider

Sandbox Provider interface with 11 public fields or methods.

Declaration

text
export interface SandboxProvider {
    readonly id: string;
    capabilities(): Promise<SandboxProviderCapabilities>;
    create(request: SandboxCreateRequest): Promise<SandboxRecord>;
    start(request: SandboxStartRequest): Promise<SandboxRecord>;
    execute(request: CommandExecutionRequest): Promise<CommandExecutionResult>;
    cancel(request: ExecutionCancelRequest): Promise<void>;
    terminate(request: SandboxTerminateRequest): Promise<void>;
    status(request: SandboxStatusRequest): Promise<SandboxRecord | null>;
    cleanup(request: SandboxCleanupRequest): Promise<void>;
    health(): Promise<ProviderHealth>;
    close?(): Promise<void>;
}

Contract members

MemberKindSignatureDescription
cancelmethodcancel(request: ExecutionCancelRequest): Promise<void>Public method; parameters and return type are shown in the signature.
capabilitiesmethodcapabilities(): Promise<SandboxProviderCapabilities>Public method; parameters and return type are shown in the signature.
cleanupmethodcleanup(request: SandboxCleanupRequest): Promise<void>Public method; parameters and return type are shown in the signature.
closemethodclose?(): Promise<void>Public method; parameters and return type are shown in the signature.
createmethodcreate(request: SandboxCreateRequest): Promise<SandboxRecord>Public method; parameters and return type are shown in the signature.
executemethodexecute(request: CommandExecutionRequest): Promise<CommandExecutionResult>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
startmethodstart(request: SandboxStartRequest): Promise<SandboxRecord>Public method; parameters and return type are shown in the signature.
statusmethodstatus(request: SandboxStatusRequest): Promise<SandboxRecord | null>Public method; parameters and return type are shown in the signature.
terminatemethodterminate(request: SandboxTerminateRequest): Promise<void>Public method; parameters and return type are shown in the signature.

SandboxProviderFactory

Composition-root contract for constructing a configured SandboxProvider. Concrete adapters own their options; core only knows the provider type and stable id.

  • Kind: interface
  • Import: import type { SandboxProviderFactory } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export interface SandboxProviderFactory {
    readonly providerType: SandboxProviderType;
    readonly providerId: string;
    create(): SandboxProvider | Promise<SandboxProvider>;
}

Contract members

MemberKindSignatureDescription
createmethodcreate(): SandboxProvider | Promise<SandboxProvider>Public method; parameters and return type are shown in the signature.
providerIdpropertyreadonly providerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerTypepropertyreadonly providerType: "mock" | "local_process" | "docker" | "remote_sandbox" | "custom"Public property; its type, readonly modifier and optionality are shown in the signature.

SandboxCapabilityName

Public type alias for Sandbox Capability Name; the declaration contains its complete type expression.

Declaration

text
export type SandboxCapabilityName = keyof SandboxProviderCapabilities;

SandboxProviderSelection

Public type alias for Sandbox Provider Selection; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { SandboxProviderSelection } from '@codesoul-co/hypha-core';
  • Source module: contracts/sandbox-provider

Declaration

text
export type SandboxProviderSelection = Pick<ExecutionEnvironmentSpec, 'provider' | 'providerRef'>;

SandboxProviderType

Public type alias for Sandbox Provider Type; the declaration contains its complete type expression.

Declaration

text
export type SandboxProviderType = ExecutionEnvironmentSpec['provider'];