Skip to content

@codesoul-co/hypha-inference / types

模块用法

用于声明并运行时校验契约。Types 模块公开 34 接口、7 类型。

从包入口导入

ts
import type {
  CompiledPrompt,
  InferenceBackend,
  InferenceBackendCapabilities,
  InferenceBackendRegistryEntry,
  InferenceBackendRequest,
  InferenceBackendResponse,
  InferenceCacheIssue,
  InferenceCachePolicy,
} from '@codesoul-co/hypha-inference';

// 完整导出列表见下方。

使用要点

  • 41 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。

公共导出

Symbol种类签名说明
CompiledPrompt接口interface CompiledPromptCompiled Prompt 接口,共包含 4 个公开字段或方法。
InferenceBackend接口interface InferenceBackendInference Backend 接口,共包含 5 个公开字段或方法。
InferenceBackendCapabilities接口interface InferenceBackendCapabilitiesInference Backend Capabilities 接口,共包含 6 个公开字段或方法。
InferenceBackendRegistryEntry接口interface InferenceBackendRegistryEntryInference Backend Registry Entry 接口,共包含 3 个公开字段或方法。
InferenceBackendRequest接口interface InferenceBackendRequestInference Backend Request 接口,共包含 14 个公开字段或方法。
InferenceBackendResponse接口interface InferenceBackendResponseInference Backend Response 接口,共包含 6 个公开字段或方法。
InferenceCacheIssue接口interface InferenceCacheIssueInference Cache Issue 接口,共包含 4 个公开字段或方法。
InferenceCachePolicy接口interface InferenceCachePolicyInference Cache Policy 接口,共包含 3 个公开字段或方法。
InferenceCacheScope接口interface InferenceCacheScopeInference Cache Scope 接口,共包含 3 个公开字段或方法。
InferenceCacheUsage接口interface InferenceCacheUsageInference Cache Usage 接口,共包含 11 个公开字段或方法。
InferenceGenerationOptions接口interface InferenceGenerationOptionsInference Generation Options 接口,共包含 9 个公开字段或方法。
InferenceManagerOptions接口interface InferenceManagerOptionsInference Manager Options 接口,共包含 8 个公开字段或方法。
InferenceProvider接口interface InferenceProviderInference Provider 接口,共包含 3 个公开字段或方法。
InferenceRequest接口interface InferenceRequestInference Request 接口,共包含 18 个公开字段或方法。
InferenceResponse接口interface InferenceResponseInference Response 接口,共包含 7 个公开字段或方法。
InferenceToolDescriptor接口interface InferenceToolDescriptorInference Tool Descriptor 接口,共包含 4 个公开字段或方法。
InferenceUsage接口interface InferenceUsageInference Usage 接口,共包含 3 个公开字段或方法。
KvCacheProvider接口interface KvCacheProviderKv Cache Provider 接口,共包含 3 个公开字段或方法。
KvCacheRef接口interface KvCacheRefKv Cache Ref 接口,共包含 7 个公开字段或方法。
KvCacheWritePolicy接口interface KvCacheWritePolicyKv Cache Write Policy 接口,共包含 3 个公开字段或方法。
PlasmodCacheMetadata接口interface PlasmodCacheMetadataPlasmod Cache Metadata 接口,共包含 10 个公开字段或方法。
PlasmodHotLayer接口interface PlasmodHotLayerPlasmod Hot Layer 接口,共包含 4 个公开字段或方法。
PlasmodHotLayerPrepareInput接口interface PlasmodHotLayerPrepareInputPlasmod Hot Layer Prepare Input 接口,共包含 12 个公开字段或方法。
PlasmodHotLayerPrepareResult接口interface PlasmodHotLayerPrepareResultPlasmod Hot Layer Prepare Result 接口,共包含 6 个公开字段或方法。
PlasmodReusePolicy接口interface PlasmodReusePolicyPlasmod Reuse Policy 接口,共包含 5 个公开字段或方法。
PlasmodSessionState接口interface PlasmodSessionStatePlasmod Session State 接口,共包含 10 个公开字段或方法。
PrefixCacheProvider接口interface PrefixCacheProviderPrefix Cache Provider 接口,共包含 3 个公开字段或方法。
PrefixCacheRef接口interface PrefixCacheRefPrefix Cache Ref 接口,共包含 6 个公开字段或方法。
PrefixSegment接口interface PrefixSegmentPrefix Segment 接口,共包含 9 个公开字段或方法。
PrefixSegmentationResult接口interface PrefixSegmentationResultPrefix Segmentation Result 接口,共包含 5 个公开字段或方法。
PrefixSegmenter接口interface PrefixSegmenterPrefix Segmenter 接口,共包含 1 个公开字段或方法。
PromptCompileInput接口interface PromptCompileInputPrompt Compile Input 接口,共包含 11 个公开字段或方法。
PromptCompiler接口interface PromptCompilerPrompt Compiler 接口,共包含 1 个公开字段或方法。
PromptMessage接口interface PromptMessagePrompt Message 接口,共包含 4 个公开字段或方法。
InferenceBackendKind类型type InferenceBackendKind = 'ollama' | 'sglang' | 'vllm' | 'llama.cpp' | 'openai-api'Inference Backend Kind 公共类型别名;完整类型表达式见声明。
InferenceCacheMissReason类型type InferenceCacheMissReason = 'missing' | 'expired' | 'not_configured' | 'error'Inference Cache Miss Reason 公共类型别名;完整类型表达式见声明。
KvCacheScope类型type KvCacheScope = 'run' | 'session' | 'workspace'Kv Cache Scope 公共类型别名;完整类型表达式见声明。
KvCacheWriteMode类型type KvCacheWriteMode = 'write_through' | 'write_if_missing' | 'refresh'Kv Cache Write Mode 公共类型别名;完整类型表达式见声明。
PrefixSegmentKind类型type PrefixSegmentKind = 'system' | 'developer' | 'context' | 'memory' | 'tool' | 'user' | 'assistant'Prefix Segment Kind 公共类型别名;完整类型表达式见声明。
PrefixSegmentScope类型type PrefixSegmentScope = 'global' | 'agent' | 'session' | 'run' | 'dynamic'Prefix Segment Scope 公共类型别名;完整类型表达式见声明。
PromptRole类型type PromptRole = 'system' | 'developer' | 'user' | 'assistant' | 'tool' | 'context' | 'memory'Prompt Role 公共类型别名;完整类型表达式见声明。

CompiledPrompt

Compiled Prompt 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { CompiledPrompt } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface CompiledPrompt {
    id: string;
    messages: PromptMessage[];
    text: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
messages属性messages: PromptMessage[]公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
text属性text: string公开属性;类型、只读和可选状态以签名列为准。

InferenceBackend

Inference Backend 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceBackend } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceBackend {
    id: string;
    kind: InferenceBackendKind;
    capabilities(): InferenceBackendCapabilities;
    infer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>;
    stream?(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>;
}

契约成员

成员种类签名说明
capabilities方法capabilities(): InferenceBackendCapabilities公开方法;参数与返回类型以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
infer方法infer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>公开方法;参数与返回类型以签名列为准。
kind属性kind: InferenceBackendKind公开属性;类型、只读和可选状态以签名列为准。
stream方法stream?(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>公开方法;参数与返回类型以签名列为准。

InferenceBackendCapabilities

Inference Backend Capabilities 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceBackendCapabilities } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceBackendCapabilities {
    streaming: boolean;
    chatCompletions: boolean;
    textCompletions: boolean;
    prefixCaching: boolean;
    kvCaching: boolean;
    cacheInvalidation: boolean;
}

契约成员

成员种类签名说明
cacheInvalidation属性cacheInvalidation: boolean公开属性;类型、只读和可选状态以签名列为准。
chatCompletions属性chatCompletions: boolean公开属性;类型、只读和可选状态以签名列为准。
kvCaching属性kvCaching: boolean公开属性;类型、只读和可选状态以签名列为准。
prefixCaching属性prefixCaching: boolean公开属性;类型、只读和可选状态以签名列为准。
streaming属性streaming: boolean公开属性;类型、只读和可选状态以签名列为准。
textCompletions属性textCompletions: boolean公开属性;类型、只读和可选状态以签名列为准。

InferenceBackendRegistryEntry

Inference Backend Registry Entry 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceBackendRegistryEntry } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceBackendRegistryEntry {
    id: string;
    backend: InferenceBackend;
    default?: boolean;
}

契约成员

成员种类签名说明
backend属性backend: InferenceBackend公开属性;类型、只读和可选状态以签名列为准。
default属性default?: boolean公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。

InferenceBackendRequest

Inference Backend Request 接口,共包含 14 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceBackendRequest } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceBackendRequest {
    runId: string;
    stepId: string;
    sessionId?: string;
    agentId?: string;
    modelAlias: string;
    compiledPrompt: CompiledPrompt;
    segmentation: PrefixSegmentationResult;
    prefixRefs: PrefixCacheRef[];
    kvCache?: KvCacheRef;
    resolvedKvCacheValue?: unknown;
    physicalKvCache?: unknown;
    options?: InferenceGenerationOptions;
    tools?: InferenceToolDescriptor[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
compiledPrompt属性compiledPrompt: CompiledPrompt公开属性;类型、只读和可选状态以签名列为准。
kvCache属性kvCache?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
options属性options?: InferenceGenerationOptions公开属性;类型、只读和可选状态以签名列为准。
physicalKvCache属性physicalKvCache?: unknown公开属性;类型、只读和可选状态以签名列为准。
prefixRefs属性prefixRefs: PrefixCacheRef[]公开属性;类型、只读和可选状态以签名列为准。
resolvedKvCacheValue属性resolvedKvCacheValue?: unknown公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
segmentation属性segmentation: PrefixSegmentationResult公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。
tools属性tools?: InferenceToolDescriptor[]公开属性;类型、只读和可选状态以签名列为准。

InferenceBackendResponse

Inference Backend Response 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceBackendResponse } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceBackendResponse<TOutput = unknown> {
    id: string;
    output: TOutput;
    usage?: InferenceUsage;
    physicalKvCache?: unknown;
    metadata?: Record<string, unknown>;
    raw?: unknown;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
output属性output: TOutput公开属性;类型、只读和可选状态以签名列为准。
physicalKvCache属性physicalKvCache?: unknown公开属性;类型、只读和可选状态以签名列为准。
raw属性raw?: unknown公开属性;类型、只读和可选状态以签名列为准。
usage属性usage?: InferenceUsage公开属性;类型、只读和可选状态以签名列为准。

InferenceCacheIssue

Inference Cache Issue 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceCacheIssue } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceCacheIssue {
    operation: 'prefix_read' | 'kv_read' | 'kv_write' | 'invalidate';
    code: string;
    message: string;
    bypassed: boolean;
}

契约成员

成员种类签名说明
bypassed属性bypassed: boolean公开属性;类型、只读和可选状态以签名列为准。
code属性code: string公开属性;类型、只读和可选状态以签名列为准。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。
operation属性operation: "prefix_read" | "kv_read" | "kv_write" | "invalidate"公开属性;类型、只读和可选状态以签名列为准。

InferenceCachePolicy

Inference Cache Policy 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceCachePolicy } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceCachePolicy {
    prefix?: PrefixCacheRef;
    kvCache?: KvCacheRef;
    writeKvCache?: KvCacheWritePolicy;
}

契约成员

成员种类签名说明
kvCache属性kvCache?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
prefix属性prefix?: PrefixCacheRef公开属性;类型、只读和可选状态以签名列为准。
writeKvCache属性writeKvCache?: KvCacheWritePolicy公开属性;类型、只读和可选状态以签名列为准。

InferenceCacheScope

Inference Cache Scope 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceCacheScope } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceCacheScope {
    tenantId?: string;
    userId: string;
    workspaceId?: string;
}

契约成员

成员种类签名说明
tenantId属性tenantId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId: string公开属性;类型、只读和可选状态以签名列为准。
workspaceId属性workspaceId?: string公开属性;类型、只读和可选状态以签名列为准。

InferenceCacheUsage

Inference Cache Usage 接口,共包含 11 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceCacheUsage } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceCacheUsage {
    prefixHit?: boolean;
    kvCacheHit?: boolean;
    servingCache?: Record<string, unknown>;
    prefixRef?: PrefixCacheRef;
    kvCacheRef?: KvCacheRef;
    kvCacheMissReason?: InferenceCacheMissReason;
    kvCacheWritten?: boolean;
    kvCacheWriteRef?: KvCacheRef;
    reusedTokens?: number;
    bypassed?: boolean;
    issues?: InferenceCacheIssue[];
}

契约成员

成员种类签名说明
bypassed属性bypassed?: boolean公开属性;类型、只读和可选状态以签名列为准。
issues属性issues?: InferenceCacheIssue[]公开属性;类型、只读和可选状态以签名列为准。
kvCacheHit属性kvCacheHit?: boolean公开属性;类型、只读和可选状态以签名列为准。
kvCacheMissReason属性kvCacheMissReason?: InferenceCacheMissReason公开属性;类型、只读和可选状态以签名列为准。
kvCacheRef属性kvCacheRef?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
kvCacheWriteRef属性kvCacheWriteRef?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
kvCacheWritten属性kvCacheWritten?: boolean公开属性;类型、只读和可选状态以签名列为准。
prefixHit属性prefixHit?: boolean公开属性;类型、只读和可选状态以签名列为准。
prefixRef属性prefixRef?: PrefixCacheRef公开属性;类型、只读和可选状态以签名列为准。
reusedTokens属性reusedTokens?: number公开属性;类型、只读和可选状态以签名列为准。
servingCache属性servingCache?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。

InferenceGenerationOptions

Inference Generation Options 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceGenerationOptions } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceGenerationOptions {
    temperature?: number;
    maxTokens?: number;
    topP?: number;
    topK?: number;
    stop?: string[];
    seed?: number;
    stream?: boolean;
    responseFormat?: 'text' | 'json_object' | {
        type: string;
        schema?: unknown;
    };
    extra?: Record<string, unknown>;
}

契约成员

成员种类签名说明
extra属性extra?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
maxTokens属性maxTokens?: number公开属性;类型、只读和可选状态以签名列为准。
responseFormat属性responseFormat?: "text" | "json_object" | { type: string; schema?: unknown; }公开属性;类型、只读和可选状态以签名列为准。
seed属性seed?: number公开属性;类型、只读和可选状态以签名列为准。
stop属性stop?: string[]公开属性;类型、只读和可选状态以签名列为准。
stream属性stream?: boolean公开属性;类型、只读和可选状态以签名列为准。
temperature属性temperature?: number公开属性;类型、只读和可选状态以签名列为准。
topK属性topK?: number公开属性;类型、只读和可选状态以签名列为准。
topP属性topP?: number公开属性;类型、只读和可选状态以签名列为准。

InferenceManagerOptions

Inference Manager Options 接口,共包含 8 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceManagerOptions } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceManagerOptions {
    prefixCache?: PrefixCacheProvider;
    kvCache?: KvCacheProvider;
    cacheFailureMode?: 'bypass' | 'strict';
    cacheOperationTimeoutMs?: number;
    providerRevision?: string;
    policyRevision?: string;
    specRevision?: string;
    onRecoveryFailure?: (failure: RecoveryFailure) => void | Promise<void>;
}

契约成员

成员种类签名说明
cacheFailureMode属性cacheFailureMode?: "strict" | "bypass"公开属性;类型、只读和可选状态以签名列为准。
cacheOperationTimeoutMs属性cacheOperationTimeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。
kvCache属性kvCache?: KvCacheProvider公开属性;类型、只读和可选状态以签名列为准。
onRecoveryFailure方法onRecoveryFailure?(failure: RecoveryFailure): void | Promise<void>公开方法;参数与返回类型以签名列为准。
policyRevision属性policyRevision?: string公开属性;类型、只读和可选状态以签名列为准。
prefixCache属性prefixCache?: PrefixCacheProvider公开属性;类型、只读和可选状态以签名列为准。
providerRevision属性providerRevision?: string公开属性;类型、只读和可选状态以签名列为准。
specRevision属性specRevision?: string公开属性;类型、只读和可选状态以签名列为准。

InferenceProvider

Inference Provider 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceProvider } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceProvider {
    id: string;
    infer(request: InferenceRequest): Promise<InferenceResponse>;
    stream?(request: InferenceRequest): AsyncIterable<InferenceResponse>;
}

契约成员

成员种类签名说明
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
infer方法infer(request: InferenceRequest): Promise<InferenceResponse>公开方法;参数与返回类型以签名列为准。
stream方法stream?(request: InferenceRequest): AsyncIterable<InferenceResponse>公开方法;参数与返回类型以签名列为准。

InferenceRequest

Inference Request 接口,共包含 18 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceRequest } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceRequest<TInput = unknown> {
    runId: string;
    stepId: string;
    sessionId?: string;
    agentId?: string;
    modelAlias: string;
    providerId?: string;
    backendId?: string;
    input: TInput;
    options?: InferenceGenerationOptions;
    tools?: InferenceToolDescriptor[];
    cachePolicy?: InferenceCachePolicy;
    cacheScope?: InferenceCacheScope;
    prefix?: PrefixCacheRef;
    resolvedPrefixContent?: string;
    kvCache?: KvCacheRef;
    resolvedKvCacheValue?: unknown;
    trace?: boolean;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
backendId属性backendId?: string公开属性;类型、只读和可选状态以签名列为准。
cachePolicy属性cachePolicy?: InferenceCachePolicy公开属性;类型、只读和可选状态以签名列为准。
cacheScope属性cacheScope?: InferenceCacheScope公开属性;类型、只读和可选状态以签名列为准。
input属性input: TInput公开属性;类型、只读和可选状态以签名列为准。
kvCache属性kvCache?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
options属性options?: InferenceGenerationOptions公开属性;类型、只读和可选状态以签名列为准。
prefix属性prefix?: PrefixCacheRef公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId?: string公开属性;类型、只读和可选状态以签名列为准。
resolvedKvCacheValue属性resolvedKvCacheValue?: unknown公开属性;类型、只读和可选状态以签名列为准。
resolvedPrefixContent属性resolvedPrefixContent?: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。
tools属性tools?: InferenceToolDescriptor[]公开属性;类型、只读和可选状态以签名列为准。
trace属性trace?: boolean公开属性;类型、只读和可选状态以签名列为准。

InferenceResponse

Inference Response 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceResponse } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceResponse<TOutput = unknown> {
    id: string;
    output: TOutput;
    usage?: InferenceUsage;
    cache?: InferenceCacheUsage;
    nextKvCacheValue?: unknown;
    metadata?: Record<string, unknown>;
    raw?: unknown;
}

契约成员

成员种类签名说明
cache属性cache?: InferenceCacheUsage公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
nextKvCacheValue属性nextKvCacheValue?: unknown公开属性;类型、只读和可选状态以签名列为准。
output属性output: TOutput公开属性;类型、只读和可选状态以签名列为准。
raw属性raw?: unknown公开属性;类型、只读和可选状态以签名列为准。
usage属性usage?: InferenceUsage公开属性;类型、只读和可选状态以签名列为准。

InferenceToolDescriptor

Inference Tool Descriptor 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceToolDescriptor } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceToolDescriptor {
    id: string;
    name: string;
    description?: string;
    inputSchema: Record<string, unknown>;
}

契约成员

成员种类签名说明
description属性description?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
inputSchema属性inputSchema: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
name属性name: string公开属性;类型、只读和可选状态以签名列为准。

InferenceUsage

Inference Usage 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { InferenceUsage } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface InferenceUsage {
    inputTokens?: number;
    outputTokens?: number;
    totalTokens?: number;
}

契约成员

成员种类签名说明
inputTokens属性inputTokens?: number公开属性;类型、只读和可选状态以签名列为准。
outputTokens属性outputTokens?: number公开属性;类型、只读和可选状态以签名列为准。
totalTokens属性totalTokens?: number公开属性;类型、只读和可选状态以签名列为准。

KvCacheProvider

Kv Cache Provider 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { KvCacheProvider } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface KvCacheProvider {
    get(ref: KvCacheRef): Promise<unknown | null>;
    put(ref: KvCacheRef, value: unknown): Promise<void>;
    invalidate(ref: KvCacheRef, reason: string): Promise<void>;
}

契约成员

成员种类签名说明
get方法get(ref: KvCacheRef): Promise<unknown | null>公开方法;参数与返回类型以签名列为准。
invalidate方法invalidate(ref: KvCacheRef, reason: string): Promise<void>公开方法;参数与返回类型以签名列为准。
put方法put(ref: KvCacheRef, value: unknown): Promise<void>公开方法;参数与返回类型以签名列为准。

KvCacheRef

Kv Cache Ref 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { KvCacheRef } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface KvCacheRef {
    id: string;
    provider: string;
    modelAlias: string;
    scope: KvCacheScope;
    cacheScope?: InferenceCacheScope;
    expiresAt?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
cacheScope属性cacheScope?: InferenceCacheScope公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
provider属性provider: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: KvCacheScope公开属性;类型、只读和可选状态以签名列为准。

KvCacheWritePolicy

Kv Cache Write Policy 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { KvCacheWritePolicy } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface KvCacheWritePolicy {
    ref: KvCacheRef;
    value?: unknown;
    mode?: KvCacheWriteMode;
}

契约成员

成员种类签名说明
mode属性mode?: KvCacheWriteMode公开属性;类型、只读和可选状态以签名列为准。
ref属性ref: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
value属性value?: unknown公开属性;类型、只读和可选状态以签名列为准。

PlasmodCacheMetadata

Plasmod Cache Metadata 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodCacheMetadata } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodCacheMetadata {
    segmentId: string;
    contentHash: string;
    backendId: string;
    modelAlias: string;
    scope: PrefixSegmentScope;
    tokenCount?: number;
    reused: boolean;
    createdAt: string;
    updatedAt: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
backendId属性backendId: string公开属性;类型、只读和可选状态以签名列为准。
contentHash属性contentHash: string公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
reused属性reused: boolean公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: PrefixSegmentScope公开属性;类型、只读和可选状态以签名列为准。
segmentId属性segmentId: string公开属性;类型、只读和可选状态以签名列为准。
tokenCount属性tokenCount?: number公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt: string公开属性;类型、只读和可选状态以签名列为准。

PlasmodHotLayer

Plasmod Hot Layer 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodHotLayer } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodHotLayer {
    prepare(input: PlasmodHotLayerPrepareInput): Promise<PlasmodHotLayerPrepareResult>;
    invalidateSegment(segmentId: string, reason: string): Promise<void>;
    getSessionState(stateId: string): PlasmodSessionState | null;
    getCacheMetadata(segmentId: string): PlasmodCacheMetadata | null;
}

契约成员

成员种类签名说明
getCacheMetadata方法getCacheMetadata(segmentId: string): PlasmodCacheMetadata | null公开方法;参数与返回类型以签名列为准。
getSessionState方法getSessionState(stateId: string): PlasmodSessionState | null公开方法;参数与返回类型以签名列为准。
invalidateSegment方法invalidateSegment(segmentId: string, reason: string): Promise<void>公开方法;参数与返回类型以签名列为准。
prepare方法prepare(input: PlasmodHotLayerPrepareInput): Promise<PlasmodHotLayerPrepareResult>公开方法;参数与返回类型以签名列为准。

PlasmodHotLayerPrepareInput

Plasmod Hot Layer Prepare Input 接口,共包含 12 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodHotLayerPrepareInput } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodHotLayerPrepareInput {
    runId: string;
    stepId: string;
    sessionId?: string;
    agentId?: string;
    modelAlias: string;
    backendId: string;
    cacheScope?: InferenceCacheScope;
    segmentation: PrefixSegmentationResult;
    kvCache?: KvCacheRef;
    resolvedKvCacheValue?: unknown;
    reusePolicy?: PlasmodReusePolicy;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
backendId属性backendId: string公开属性;类型、只读和可选状态以签名列为准。
cacheScope属性cacheScope?: InferenceCacheScope公开属性;类型、只读和可选状态以签名列为准。
kvCache属性kvCache?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
resolvedKvCacheValue属性resolvedKvCacheValue?: unknown公开属性;类型、只读和可选状态以签名列为准。
reusePolicy属性reusePolicy?: PlasmodReusePolicy公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
segmentation属性segmentation: PrefixSegmentationResult公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。

PlasmodHotLayerPrepareResult

Plasmod Hot Layer Prepare Result 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodHotLayerPrepareResult } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodHotLayerPrepareResult {
    prefixRefs: PrefixCacheRef[];
    kvCacheRef?: KvCacheRef;
    physicalKvCache?: unknown;
    reusedSegmentIds: string[];
    invalidatedSegmentIds: string[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
invalidatedSegmentIds属性invalidatedSegmentIds: string[]公开属性;类型、只读和可选状态以签名列为准。
kvCacheRef属性kvCacheRef?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
physicalKvCache属性physicalKvCache?: unknown公开属性;类型、只读和可选状态以签名列为准。
prefixRefs属性prefixRefs: PrefixCacheRef[]公开属性;类型、只读和可选状态以签名列为准。
reusedSegmentIds属性reusedSegmentIds: string[]公开属性;类型、只读和可选状态以签名列为准。

PlasmodReusePolicy

Plasmod Reuse Policy 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodReusePolicy } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodReusePolicy {
    allowCrossSession?: boolean;
    allowCrossAgent?: boolean;
    minTokenCount?: number;
    requireExactHash?: boolean;
    maxPrefixRefs?: number;
}

契约成员

成员种类签名说明
allowCrossAgent属性allowCrossAgent?: boolean公开属性;类型、只读和可选状态以签名列为准。
allowCrossSession属性allowCrossSession?: boolean公开属性;类型、只读和可选状态以签名列为准。
maxPrefixRefs属性maxPrefixRefs?: number公开属性;类型、只读和可选状态以签名列为准。
minTokenCount属性minTokenCount?: number公开属性;类型、只读和可选状态以签名列为准。
requireExactHash属性requireExactHash?: boolean公开属性;类型、只读和可选状态以签名列为准。

PlasmodSessionState

Plasmod Session State 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PlasmodSessionState } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PlasmodSessionState {
    id: string;
    sessionId?: string;
    runId: string;
    agentId?: string;
    modelAlias: string;
    backendId: string;
    prefixRefs: PrefixCacheRef[];
    kvCacheRef?: KvCacheRef;
    updatedAt: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
backendId属性backendId: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
kvCacheRef属性kvCacheRef?: KvCacheRef公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
prefixRefs属性prefixRefs: PrefixCacheRef[]公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt: string公开属性;类型、只读和可选状态以签名列为准。

PrefixCacheProvider

Prefix Cache Provider 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PrefixCacheProvider } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PrefixCacheProvider {
    get(ref: PrefixCacheRef): Promise<string | null>;
    put(ref: PrefixCacheRef, content: string): Promise<void>;
    invalidate(ref: PrefixCacheRef, reason: string): Promise<void>;
}

契约成员

成员种类签名说明
get方法get(ref: PrefixCacheRef): Promise<string | null>公开方法;参数与返回类型以签名列为准。
invalidate方法invalidate(ref: PrefixCacheRef, reason: string): Promise<void>公开方法;参数与返回类型以签名列为准。
put方法put(ref: PrefixCacheRef, content: string): Promise<void>公开方法;参数与返回类型以签名列为准。

PrefixCacheRef

Prefix Cache Ref 接口,共包含 6 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PrefixCacheRef } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PrefixCacheRef {
    id: string;
    version: string;
    contentHash: string;
    tokenCount?: number;
    cacheScope?: InferenceCacheScope;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
cacheScope属性cacheScope?: InferenceCacheScope公开属性;类型、只读和可选状态以签名列为准。
contentHash属性contentHash: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
tokenCount属性tokenCount?: number公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。

PrefixSegment

Prefix Segment 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PrefixSegment } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PrefixSegment {
    id: string;
    kind: PrefixSegmentKind;
    scope: PrefixSegmentScope;
    content: string;
    contentHash: string;
    tokenCount?: number;
    cacheable: boolean;
    dependencies?: string[];
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
cacheable属性cacheable: boolean公开属性;类型、只读和可选状态以签名列为准。
content属性content: string公开属性;类型、只读和可选状态以签名列为准。
contentHash属性contentHash: string公开属性;类型、只读和可选状态以签名列为准。
dependencies属性dependencies?: string[]公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: PrefixSegmentKind公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: PrefixSegmentScope公开属性;类型、只读和可选状态以签名列为准。
tokenCount属性tokenCount?: number公开属性;类型、只读和可选状态以签名列为准。

PrefixSegmentationResult

Prefix Segmentation Result 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PrefixSegmentationResult } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PrefixSegmentationResult {
    compiled: CompiledPrompt;
    segments: PrefixSegment[];
    stablePrefix: string;
    dynamicPrompt: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
compiled属性compiled: CompiledPrompt公开属性;类型、只读和可选状态以签名列为准。
dynamicPrompt属性dynamicPrompt: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
segments属性segments: PrefixSegment[]公开属性;类型、只读和可选状态以签名列为准。
stablePrefix属性stablePrefix: string公开属性;类型、只读和可选状态以签名列为准。

PrefixSegmenter

Prefix Segmenter 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PrefixSegmenter } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PrefixSegmenter {
    segment(prompt: CompiledPrompt): Promise<PrefixSegmentationResult>;
}

契约成员

成员种类签名说明
segment方法segment(prompt: CompiledPrompt): Promise<PrefixSegmentationResult>公开方法;参数与返回类型以签名列为准。

PromptCompileInput

Prompt Compile Input 接口,共包含 11 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PromptCompileInput } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PromptCompileInput<TInput = unknown> {
    runId: string;
    stepId: string;
    sessionId?: string;
    agentId?: string;
    modelAlias: string;
    instructions?: string;
    messages?: PromptMessage[];
    input: TInput;
    context?: Record<string, unknown>;
    resolvedPrefixContent?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
agentId属性agentId?: string公开属性;类型、只读和可选状态以签名列为准。
context属性context?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
input属性input: TInput公开属性;类型、只读和可选状态以签名列为准。
instructions属性instructions?: string公开属性;类型、只读和可选状态以签名列为准。
messages属性messages?: PromptMessage[]公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
modelAlias属性modelAlias: string公开属性;类型、只读和可选状态以签名列为准。
resolvedPrefixContent属性resolvedPrefixContent?: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
sessionId属性sessionId?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId: string公开属性;类型、只读和可选状态以签名列为准。

PromptCompiler

Prompt Compiler 接口,共包含 1 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PromptCompiler } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PromptCompiler {
    compile<TInput = unknown>(input: PromptCompileInput<TInput>): Promise<CompiledPrompt>;
}

契约成员

成员种类签名说明
compile方法compile<TInput = unknown>(input: PromptCompileInput<TInput>): Promise<CompiledPrompt>公开方法;参数与返回类型以签名列为准。

PromptMessage

Prompt Message 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { PromptMessage } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export interface PromptMessage {
    role: PromptRole;
    content: string;
    name?: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
content属性content: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
name属性name?: string公开属性;类型、只读和可选状态以签名列为准。
role属性role: PromptRole公开属性;类型、只读和可选状态以签名列为准。

InferenceBackendKind

Inference Backend Kind 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { InferenceBackendKind } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type InferenceBackendKind = 'ollama' | 'sglang' | 'vllm' | 'llama.cpp' | 'openai-api';

InferenceCacheMissReason

Inference Cache Miss Reason 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { InferenceCacheMissReason } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type InferenceCacheMissReason = 'missing' | 'expired' | 'not_configured' | 'error';

KvCacheScope

Kv Cache Scope 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { KvCacheScope } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type KvCacheScope = 'run' | 'session' | 'workspace';

KvCacheWriteMode

Kv Cache Write Mode 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { KvCacheWriteMode } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type KvCacheWriteMode = 'write_through' | 'write_if_missing' | 'refresh';

PrefixSegmentKind

Prefix Segment Kind 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { PrefixSegmentKind } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type PrefixSegmentKind = 'system' | 'developer' | 'context' | 'memory' | 'tool' | 'user' | 'assistant';

PrefixSegmentScope

Prefix Segment Scope 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { PrefixSegmentScope } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type PrefixSegmentScope = 'global' | 'agent' | 'session' | 'run' | 'dynamic';

PromptRole

Prompt Role 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { PromptRole } from '@codesoul-co/hypha-inference';
  • 源码模块: types

声明

text
export type PromptRole = 'system' | 'developer' | 'user' | 'assistant' | 'tool' | 'context' | 'memory';