Skip to content

@codesoul-co/hypha-inference / reasoning

Using this module

Use the Reasoning module for using the public contracts and operations for this capability boundary. It exports 1 class, 6 interfaces, 6 types.

Import from the package entrypoint

ts
import {
  ReasoningOrchestrator,
} from '@codesoul-co/hypha-inference';

import type {
  ReasoningBudget,
  ReasoningOptions,
  ReasoningRequest,
  ThoughtEdge,
  ThoughtGraph,
  ThoughtNode,
  ReasoningAggregation,
  ReasoningMethod,
} from '@codesoul-co/hypha-inference';

// The complete export list is documented below.

Usage patterns

  • Use the 12 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 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
ReasoningOrchestratorclassnew ReasoningOrchestrator(provider: InferenceProvider, id?: string, registry?: ReasoningStrategyRegistry): ReasoningOrchestratorReasoning Orchestrator class with 5 public constructor or member entries; its exact declarations are listed below.
ReasoningBudgetinterfaceinterface ReasoningBudgetReasoning Budget interface with 3 public fields or methods.
ReasoningOptionsinterfaceinterface ReasoningOptionsReasoning Options interface with 14 public fields or methods.
ReasoningRequestinterfaceinterface ReasoningRequest extends InferenceRequest<TInput>Reasoning Request interface with 19 public fields or methods.
ThoughtEdgeinterfaceinterface ThoughtEdgeThought Edge interface with 3 public fields or methods.
ThoughtGraphinterfaceinterface ThoughtGraphThought Graph interface with 5 public fields or methods.
ThoughtNodeinterfaceinterface ThoughtNodeThought Node interface with 9 public fields or methods.
ReasoningAggregationtypetype ReasoningAggregation = 'first' | 'majority_vote' | 'score' | 'llm_judge'Public type alias for Reasoning Aggregation; the declaration contains its complete type expression.
ReasoningMethodtypetype ReasoningMethod = 'direct' | 'cot' | 'tot' | 'got' | 'self_consistency'Public type alias for Reasoning Method; the declaration contains its complete type expression.
ReasoningTraceEventtypetype ReasoningTraceEvent = { type: 'reasoning.strategy.started'; method: ReasoningMethod; strategyId?: string; requestId: string; } | { type: 'reasoning.node.generated'; method: ReasoningMethod; node: ThoughtNode; } | { type: 'reasoning.node.evaluated'; method: ReasoningMethod; node: ThoughtNode; } | { type: 'reasoning.node.selected'; method: ReasoningMethod; node: ThoughtNode; } | { type: 'reasoning.strategy.comp...Public type alias for Reasoning Trace Event; the declaration contains its complete type expression.
ReasoningTraceSinktypetype ReasoningTraceSink = (event: ReasoningTraceEvent) => Promise<void> | voidPublic type alias for Reasoning Trace Sink; the declaration contains its complete type expression.
ThoughtEdgeTypetypetype ThoughtEdgeType = 'expand' | 'merge' | 'refine' | 'criticize' | 'validate'Public type alias for Thought Edge Type; the declaration contains its complete type expression.
ThoughtNodeStatustypetype ThoughtNodeStatus = 'candidate' | 'evaluated' | 'selected' | 'rejected'Public type alias for Thought Node Status; the declaration contains its complete type expression.

ReasoningOrchestrator

Reasoning Orchestrator class with 5 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { ReasoningOrchestrator } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export declare class ReasoningOrchestrator implements InferenceProvider {
    readonly id: string;
    readonly registry: ReasoningStrategyRegistry;
    constructor(provider: InferenceProvider, id?: string, registry?: ReasoningStrategyRegistry);
    infer(request: ReasoningRequest): Promise<InferenceResponse>;
    stream(request: ReasoningRequest): AsyncIterable<InferenceResponse>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(provider: InferenceProvider, id?: string, registry?: ReasoningStrategyRegistry): ReasoningOrchestratorCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: ReasoningRequest): Promise<InferenceResponse>Public method; parameters and return type are shown in the signature.
registrypropertyreadonly registry: ReasoningStrategyRegistryPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: ReasoningRequest): AsyncIterable<InferenceResponse>Public method; parameters and return type are shown in the signature.

ReasoningBudget

Reasoning Budget interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ReasoningBudget } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ReasoningBudget {
    maxModelCalls?: number;
    maxNodes?: number;
    timeoutMs?: number;
}

Contract members

MemberKindSignatureDescription
maxModelCallspropertymaxModelCalls?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxNodespropertymaxNodes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
timeoutMspropertytimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

ReasoningOptions

Reasoning Options interface with 14 public fields or methods.

  • Kind: interface
  • Import: import type { ReasoningOptions } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ReasoningOptions {
    method: ReasoningMethod;
    strategyRef?: string;
    branches?: number;
    maxDepth?: number;
    beamWidth?: number;
    maxNodes?: number;
    revealReasoning?: boolean;
    aggregation?: ReasoningAggregation;
    evaluatorRef?: string;
    strategyVersion?: string;
    budget?: ReasoningBudget;
    evaluator?: (responses: InferenceResponse[]) => Promise<InferenceResponse>;
    scorer?: (response: InferenceResponse, node: ThoughtNode) => Promise<number> | number;
    trace?: ReasoningTraceSink;
}

Contract members

MemberKindSignatureDescription
aggregationpropertyaggregation?: ReasoningAggregationPublic property; its type, readonly modifier and optionality are shown in the signature.
beamWidthpropertybeamWidth?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
branchespropertybranches?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
budgetpropertybudget?: ReasoningBudgetPublic property; its type, readonly modifier and optionality are shown in the signature.
evaluatormethodevaluator?(responses: InferenceResponse[]): Promise<InferenceResponse>Public method; parameters and return type are shown in the signature.
evaluatorRefpropertyevaluatorRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
maxDepthpropertymaxDepth?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxNodespropertymaxNodes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
methodpropertymethod: ReasoningMethodPublic property; its type, readonly modifier and optionality are shown in the signature.
revealReasoningpropertyrevealReasoning?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
scorermethodscorer?(response: InferenceResponse, node: ThoughtNode): Promise<number> | numberPublic method; parameters and return type are shown in the signature.
strategyRefpropertystrategyRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
strategyVersionpropertystrategyVersion?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tracemethodtrace?(event: ReasoningTraceEvent): Promise<void> | voidPublic method; parameters and return type are shown in the signature.

ReasoningRequest

Reasoning Request interface with 19 public fields or methods.

  • Kind: interface
  • Import: import type { ReasoningRequest } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ReasoningRequest<TInput = unknown> extends InferenceRequest<TInput> {
    reasoning?: ReasoningOptions;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
backendIdpropertybackendId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
cachePolicypropertycachePolicy?: InferenceCachePolicyPublic property; its type, readonly modifier and optionality are shown in the signature.
cacheScopepropertycacheScope?: InferenceCacheScopePublic property; its type, readonly modifier and optionality are shown in the signature.
inputpropertyinput: TInputPublic property; its type, readonly modifier and optionality are shown in the signature.
kvCachepropertykvCache?: KvCacheRefPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
modelAliaspropertymodelAlias: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
optionspropertyoptions?: InferenceGenerationOptionsPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixpropertyprefix?: PrefixCacheRefPublic 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.
reasoningpropertyreasoning?: ReasoningOptionsPublic property; its type, readonly modifier and optionality are shown in the signature.
resolvedKvCacheValuepropertyresolvedKvCacheValue?: unknownPublic property; its type, readonly modifier and optionality are shown in the signature.
resolvedPrefixContentpropertyresolvedPrefixContent?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stepIdpropertystepId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
toolspropertytools?: InferenceToolDescriptor[]Public property; its type, readonly modifier and optionality are shown in the signature.
tracepropertytrace?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

ThoughtEdge

Thought Edge interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ThoughtEdge } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ThoughtEdge {
    from: string;
    to: string;
    type: ThoughtEdgeType;
}

Contract members

MemberKindSignatureDescription
frompropertyfrom: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topropertyto: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: ThoughtEdgeTypePublic property; its type, readonly modifier and optionality are shown in the signature.

ThoughtGraph

Thought Graph interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ThoughtGraph } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ThoughtGraph {
    id: string;
    method: Extract<ReasoningMethod, 'tot' | 'got'>;
    nodes: ThoughtNode[];
    edges: ThoughtEdge[];
    selectedNodeId?: string;
}

Contract members

MemberKindSignatureDescription
edgespropertyedges: ThoughtEdge[]Public property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
methodpropertymethod: "tot" | "got"Public property; its type, readonly modifier and optionality are shown in the signature.
nodespropertynodes: ThoughtNode[]Public property; its type, readonly modifier and optionality are shown in the signature.
selectedNodeIdpropertyselectedNodeId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ThoughtNode

Thought Node interface with 9 public fields or methods.

  • Kind: interface
  • Import: import type { ThoughtNode } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export interface ThoughtNode {
    id: string;
    parentIds: string[];
    depth: number;
    branchIndex: number;
    status: ThoughtNodeStatus;
    score?: number;
    outputHash?: string;
    responseId?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
branchIndexpropertybranchIndex: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
depthpropertydepth: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
outputHashpropertyoutputHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
parentIdspropertyparentIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
responseIdpropertyresponseId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scorepropertyscore?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: ThoughtNodeStatusPublic property; its type, readonly modifier and optionality are shown in the signature.

ReasoningAggregation

Public type alias for Reasoning Aggregation; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ReasoningAggregation } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ReasoningAggregation = 'first' | 'majority_vote' | 'score' | 'llm_judge';

ReasoningMethod

Public type alias for Reasoning Method; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ReasoningMethod } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ReasoningMethod = 'direct' | 'cot' | 'tot' | 'got' | 'self_consistency';

ReasoningTraceEvent

Public type alias for Reasoning Trace Event; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ReasoningTraceEvent } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ReasoningTraceEvent = {
    type: 'reasoning.strategy.started';
    method: ReasoningMethod;
    strategyId?: string;
    requestId: string;
} | {
    type: 'reasoning.node.generated';
    method: ReasoningMethod;
    node: ThoughtNode;
} | {
    type: 'reasoning.node.evaluated';
    method: ReasoningMethod;
    node: ThoughtNode;
} | {
    type: 'reasoning.node.selected';
    method: ReasoningMethod;
    node: ThoughtNode;
} | {
    type: 'reasoning.strategy.completed';
    method: ReasoningMethod;
    strategyId?: string;
    requestId: string;
    modelCalls: number;
    nodeCount: number;
};

ReasoningTraceSink

Public type alias for Reasoning Trace Sink; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ReasoningTraceSink } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ReasoningTraceSink = (event: ReasoningTraceEvent) => Promise<void> | void;

ThoughtEdgeType

Public type alias for Thought Edge Type; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ThoughtEdgeType } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ThoughtEdgeType = 'expand' | 'merge' | 'refine' | 'criticize' | 'validate';

ThoughtNodeStatus

Public type alias for Thought Node Status; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ThoughtNodeStatus } from '@codesoul-co/hypha-inference';
  • Source module: reasoning

Declaration

text
export type ThoughtNodeStatus = 'candidate' | 'evaluated' | 'selected' | 'rejected';