@codesoul-co/hypha-inference / reasoning
- Package index:
@codesoul-co/hypha-inference - Source:
packages/inference/src/reasoning.ts - Exports: 13
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
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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
ReasoningOrchestrator | class | new ReasoningOrchestrator(provider: InferenceProvider, id?: string, registry?: ReasoningStrategyRegistry): ReasoningOrchestrator | Reasoning Orchestrator class with 5 public constructor or member entries; its exact declarations are listed below. |
ReasoningBudget | interface | interface ReasoningBudget | Reasoning Budget interface with 3 public fields or methods. |
ReasoningOptions | interface | interface ReasoningOptions | Reasoning Options interface with 14 public fields or methods. |
ReasoningRequest | interface | interface ReasoningRequest extends InferenceRequest<TInput> | Reasoning Request interface with 19 public fields or methods. |
ThoughtEdge | interface | interface ThoughtEdge | Thought Edge interface with 3 public fields or methods. |
ThoughtGraph | interface | interface ThoughtGraph | Thought Graph interface with 5 public fields or methods. |
ThoughtNode | interface | interface ThoughtNode | Thought Node interface with 9 public fields or methods. |
ReasoningAggregation | type | type ReasoningAggregation = 'first' | 'majority_vote' | 'score' | 'llm_judge' | Public type alias for Reasoning Aggregation; the declaration contains its complete type expression. |
ReasoningMethod | type | type ReasoningMethod = 'direct' | 'cot' | 'tot' | 'got' | 'self_consistency' | Public type alias for Reasoning Method; the declaration contains its complete type expression. |
ReasoningTraceEvent | type | 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.comp... | Public type alias for Reasoning Trace Event; the declaration contains its complete type expression. |
ReasoningTraceSink | type | type ReasoningTraceSink = (event: ReasoningTraceEvent) => Promise<void> | void | Public type alias for Reasoning Trace Sink; the declaration contains its complete type expression. |
ThoughtEdgeType | type | type ThoughtEdgeType = 'expand' | 'merge' | 'refine' | 'criticize' | 'validate' | Public type alias for Thought Edge Type; the declaration contains its complete type expression. |
ThoughtNodeStatus | type | type 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
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
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (provider: InferenceProvider, id?: string, registry?: ReasoningStrategyRegistry): ReasoningOrchestrator | Creates an instance of this class. |
id | property | readonly id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
infer | method | infer(request: ReasoningRequest): Promise<InferenceResponse> | Public method; parameters and return type are shown in the signature. |
registry | property | readonly registry: ReasoningStrategyRegistry | Public property; its type, readonly modifier and optionality are shown in the signature. |
stream | method | stream(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
export interface ReasoningBudget {
maxModelCalls?: number;
maxNodes?: number;
timeoutMs?: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
maxModelCalls | property | maxModelCalls?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxNodes | property | maxNodes?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
timeoutMs | property | timeoutMs?: number | Public 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
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
| Member | Kind | Signature | Description |
|---|---|---|---|
aggregation | property | aggregation?: ReasoningAggregation | Public property; its type, readonly modifier and optionality are shown in the signature. |
beamWidth | property | beamWidth?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
branches | property | branches?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
budget | property | budget?: ReasoningBudget | Public property; its type, readonly modifier and optionality are shown in the signature. |
evaluator | method | evaluator?(responses: InferenceResponse[]): Promise<InferenceResponse> | Public method; parameters and return type are shown in the signature. |
evaluatorRef | property | evaluatorRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxDepth | property | maxDepth?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxNodes | property | maxNodes?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
method | property | method: ReasoningMethod | Public property; its type, readonly modifier and optionality are shown in the signature. |
revealReasoning | property | revealReasoning?: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
scorer | method | scorer?(response: InferenceResponse, node: ThoughtNode): Promise<number> | number | Public method; parameters and return type are shown in the signature. |
strategyRef | property | strategyRef?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
strategyVersion | property | strategyVersion?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
trace | method | trace?(event: ReasoningTraceEvent): Promise<void> | void | Public 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
export interface ReasoningRequest<TInput = unknown> extends InferenceRequest<TInput> {
reasoning?: ReasoningOptions;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
agentId | property | agentId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
backendId | property | backendId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
cachePolicy | property | cachePolicy?: InferenceCachePolicy | Public property; its type, readonly modifier and optionality are shown in the signature. |
cacheScope | property | cacheScope?: InferenceCacheScope | Public property; its type, readonly modifier and optionality are shown in the signature. |
input | property | input: TInput | Public property; its type, readonly modifier and optionality are shown in the signature. |
kvCache | property | kvCache?: KvCacheRef | 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. |
modelAlias | property | modelAlias: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
options | property | options?: InferenceGenerationOptions | Public property; its type, readonly modifier and optionality are shown in the signature. |
prefix | property | prefix?: PrefixCacheRef | Public property; its type, readonly modifier and optionality are shown in the signature. |
providerId | property | providerId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
reasoning | property | reasoning?: ReasoningOptions | Public property; its type, readonly modifier and optionality are shown in the signature. |
resolvedKvCacheValue | property | resolvedKvCacheValue?: unknown | Public property; its type, readonly modifier and optionality are shown in the signature. |
resolvedPrefixContent | property | resolvedPrefixContent?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
runId | property | runId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
sessionId | property | sessionId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stepId | property | stepId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
tools | property | tools?: InferenceToolDescriptor[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
trace | property | trace?: boolean | Public 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
export interface ThoughtEdge {
from: string;
to: string;
type: ThoughtEdgeType;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
from | property | from: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
to | property | to: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
type | property | type: ThoughtEdgeType | Public 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
export interface ThoughtGraph {
id: string;
method: Extract<ReasoningMethod, 'tot' | 'got'>;
nodes: ThoughtNode[];
edges: ThoughtEdge[];
selectedNodeId?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
edges | property | edges: ThoughtEdge[] | 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. |
method | property | method: "tot" | "got" | Public property; its type, readonly modifier and optionality are shown in the signature. |
nodes | property | nodes: ThoughtNode[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
selectedNodeId | property | selectedNodeId?: string | Public 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
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
| Member | Kind | Signature | Description |
|---|---|---|---|
branchIndex | property | branchIndex: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
depth | property | depth: number | 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. |
metadata | property | metadata?: Record<string, unknown> | Public property; its type, readonly modifier and optionality are shown in the signature. |
outputHash | property | outputHash?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
parentIds | property | parentIds: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
responseId | property | responseId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
score | property | score?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
status | property | status: ThoughtNodeStatus | Public 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
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
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
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
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
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
export type ThoughtNodeStatus = 'candidate' | 'evaluated' | 'selected' | 'rejected';