@codesoul-co/hypha-serving-cache / types
模块用法
用于声明并运行时校验契约。Types 模块公开 18 接口、11 类型。
从包入口导入
import type {
CachedLLMProviderOptions,
CachedModelResponseProjection,
CacheEntry,
CacheLookupHit,
CacheLookupMiss,
CacheMetadata,
CachePolicy,
CacheScope,
} from '@codesoul-co/hypha-serving-cache';
// 完整导出列表见下方。使用要点
- 29 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用
import type,运行时不应依赖它们。
公共导出
| Symbol | 种类 | 签名 | 说明 |
|---|---|---|---|
CachedLLMProviderOptions | 接口 | interface CachedLLMProviderOptions | Cached LLM Provider Options 接口,共包含 8 个公开字段或方法。 |
CachedModelResponseProjection | 接口 | interface CachedModelResponseProjection | Cached Model Response Projection 接口,共包含 6 个公开字段或方法。 |
CacheEntry | 接口 | interface CacheEntry | Cache Entry 接口,共包含 8 个公开字段或方法。 |
CacheLookupHit | 接口 | interface CacheLookupHit | Cache Lookup Hit 接口,共包含 4 个公开字段或方法。 |
CacheLookupMiss | 接口 | interface CacheLookupMiss | Cache Lookup Miss 接口,共包含 3 个公开字段或方法。 |
CacheMetadata | 接口 | interface CacheMetadata | Cache Metadata 接口,共包含 12 个公开字段或方法。 |
CachePolicy | 接口 | interface CachePolicy | Cache Policy 接口,共包含 10 个公开字段或方法。 |
CacheScope | 接口 | interface CacheScope | Cache Scope 接口,共包含 5 个公开字段或方法。 |
CacheStore | 接口 | interface CacheStore | Cache Store 接口,共包含 8 个公开字段或方法。 |
CacheStoreHealth | 接口 | interface CacheStoreHealth | Cache Store Health 接口,共包含 3 个公开字段或方法。 |
CacheStoreStats | 接口 | interface CacheStoreStats | Cache Store Stats 接口,共包含 3 个公开字段或方法。 |
LLMCacheKeyInput | 接口 | interface LLMCacheKeyInput | LLM Cache Key Input 接口,共包含 8 个公开字段或方法。 |
ModelRequestCacheControl | 接口 | interface ModelRequestCacheControl | Model Request Cache Control 接口,共包含 2 个公开字段或方法。 |
PrefixCacheShapeObservation | 接口 | interface PrefixCacheShapeObservation | Prefix Cache Shape Observation 接口,共包含 17 个公开字段或方法。 |
PromptPrefixBlock | 接口 | interface PromptPrefixBlock extends Required<Pick<PromptPrefixBlockInput, 'id' | 'type' | 'hash'>> | Prompt Prefix Block 接口,共包含 11 个公开字段或方法。 |
PromptPrefixBlockInput | 接口 | interface PromptPrefixBlockInput | Prompt Prefix Block Input 接口,共包含 11 个公开字段或方法。 |
PromptPrefixMetadata | 接口 | interface PromptPrefixMetadata | Prompt Prefix Metadata 接口,共包含 7 个公开字段或方法。 |
ProviderPrefixCacheUsage | 接口 | interface ProviderPrefixCacheUsage | Provider Prefix Cache Usage 接口,共包含 5 个公开字段或方法。 |
CacheFailureMode | 类型 | type CacheFailureMode = 'bypass' | 'strict' | Cache Failure Mode 公共类型别名;完整类型表达式见声明。 |
CacheLookupResult | 类型 | type CacheLookupResult = CacheLookupHit<T> | CacheLookupMiss | Cache Lookup Result 公共类型别名;完整类型表达式见声明。 |
CacheMode | 类型 | type CacheMode = 'off' | 'read' | 'write' | 'readwrite' | Cache Mode 公共类型别名;完整类型表达式见声明。 |
CacheScopeRequirement | 类型 | type CacheScopeRequirement = 'none' | 'user' | 'session' | Cache Scope Requirement 公共类型别名;完整类型表达式见声明。 |
CacheType | 类型 | type CacheType = 'exact' | 'prefix-metadata' | 'semantic' | Cache Type 公共类型别名;完整类型表达式见声明。 |
PrefixCacheChangeReason | 类型 | type PrefixCacheChangeReason = 'first_request' | 'prefix_changed' | 'tool_schema_changed' | 'domain_pack_changed' | 'dynamic_suffix_changed' | 'unchanged' | Prefix Cache Change Reason 公共类型别名;完整类型表达式见声明。 |
PromptPrefixBlockType | 类型 | type PromptPrefixBlockType = 'system' | 'tool-schema' | 'project-context' | 'domain-pack' | 'memory' | 'prompt-template' | Prompt Prefix Block Type 公共类型别名;完整类型表达式见声明。 |
ServingCacheEvent | 类型 | type ServingCacheEvent = { type: 'llm.cache.lookup'; key: string; provider: string; model: string; scope?: CacheScope; prefixCache?: PrefixCacheShapeObservation; runId?: string; stepId?: string; } | { type: 'llm.cache.hit'; key: string; ageMs: number; provider: string; model: string; scope?: CacheScope; prefixCache?: PrefixCacheShapeObservation; runId?: string; stepId?: string; } | { type: 'llm.cache.miss'; key: s... | Serving Cache Event 公共类型别名;完整类型表达式见声明。 |
ServingCacheMissReason | 类型 | type ServingCacheMissReason = 'not_found' | 'expired' | 'disabled' | 'streaming' | 'no_cache' | 'mode_off' | 'read_disabled' | 'scope_missing' | 'store_unavailable' | 'entry_oversized' | 'corrupt' | Serving Cache Miss Reason 公共类型别名;完整类型表达式见声明。 |
ServingCacheStoreKind | 类型 | type ServingCacheStoreKind = 'off' | 'noop' | 'memory' | 'sqlite' | 'redis' | Serving Cache Store Kind 公共类型别名;完整类型表达式见声明。 |
ServingCacheTraceSink | 类型 | type ServingCacheTraceSink = (event: ServingCacheEvent) => void | Promise<void> | Serving Cache Trace Sink 公共类型别名;完整类型表达式见声明。 |
CachedLLMProviderOptions
Cached LLM Provider Options 接口,共包含 8 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CachedLLMProviderOptions } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CachedLLMProviderOptions {
policy?: Partial<CachePolicy>;
trace?: ServingCacheTraceSink;
providerResolver?: (request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>) => string;
modelResolver?: (request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>) => string;
scopeResolver?: (request: ModelRequest) => CacheScope | undefined;
paramsResolver?: (request: ModelRequest) => Record<string, unknown> | undefined;
promptBlocksResolver?: (request: ModelRequest) => PromptPrefixBlockInput[] | undefined;
responseIdFactory?: (request: ModelRequest, key: string) => string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
modelResolver | 方法 | modelResolver?(request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>): string | 公开方法;参数与返回类型以签名列为准。 |
paramsResolver | 方法 | paramsResolver?(request: ModelRequest): Record<string, unknown> | undefined | 公开方法;参数与返回类型以签名列为准。 |
policy | 属性 | policy?: Partial<CachePolicy> | 公开属性;类型、只读和可选状态以签名列为准。 |
promptBlocksResolver | 方法 | promptBlocksResolver?(request: ModelRequest): PromptPrefixBlockInput[] | undefined | 公开方法;参数与返回类型以签名列为准。 |
providerResolver | 方法 | providerResolver?(request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>): string | 公开方法;参数与返回类型以签名列为准。 |
responseIdFactory | 方法 | responseIdFactory?(request: ModelRequest, key: string): string | 公开方法;参数与返回类型以签名列为准。 |
scopeResolver | 方法 | scopeResolver?(request: ModelRequest): CacheScope | undefined | 公开方法;参数与返回类型以签名列为准。 |
trace | 方法 | trace?(event: ServingCacheEvent): void | Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
CachedModelResponseProjection
Cached Model Response Projection 接口,共包含 6 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CachedModelResponseProjection } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CachedModelResponseProjection {
schemaVersion: '1.0';
providerId?: string;
model?: string;
content: ModelResponse['content'];
toolCalls?: ModelResponse['toolCalls'];
usage?: ModelResponse['usage'];
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
content | 属性 | content: string | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
providerId | 属性 | providerId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
schemaVersion | 属性 | schemaVersion: "1.0" | 公开属性;类型、只读和可选状态以签名列为准。 |
toolCalls | 属性 | toolCalls?: import("/Users/erwin/Downloads/codespace/Hypha/packages/models/dist/index").NormalizedToolCall[] | 公开属性;类型、只读和可选状态以签名列为准。 |
usage | 属性 | usage?: import("/Users/erwin/Downloads/codespace/Hypha/packages/models/dist/index").ModelUsage | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheEntry
Cache Entry 接口,共包含 8 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheEntry } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheEntry<T = unknown> {
schemaVersion?: '1.0';
keyVersion?: '1';
key: string;
value: T;
createdAt: number;
expiresAt?: number;
sizeBytes?: number;
metadata?: CacheMetadata;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
createdAt | 属性 | createdAt: number | 公开属性;类型、只读和可选状态以签名列为准。 |
expiresAt | 属性 | expiresAt?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
key | 属性 | key: string | 公开属性;类型、只读和可选状态以签名列为准。 |
keyVersion | 属性 | keyVersion?: "1" | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: CacheMetadata | 公开属性;类型、只读和可选状态以签名列为准。 |
schemaVersion | 属性 | schemaVersion?: "1.0" | 公开属性;类型、只读和可选状态以签名列为准。 |
sizeBytes | 属性 | sizeBytes?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
value | 属性 | value: T | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheLookupHit
Cache Lookup Hit 接口,共包含 4 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheLookupHit } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheLookupHit<T = unknown> {
hit: true;
key: string;
entry: CacheEntry<T>;
ageMs: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
ageMs | 属性 | ageMs: number | 公开属性;类型、只读和可选状态以签名列为准。 |
entry | 属性 | entry: CacheEntry<T> | 公开属性;类型、只读和可选状态以签名列为准。 |
hit | 属性 | hit: true | 公开属性;类型、只读和可选状态以签名列为准。 |
key | 属性 | key: string | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheLookupMiss
Cache Lookup Miss 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheLookupMiss } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheLookupMiss {
hit: false;
key: string;
reason: 'not_found' | 'expired';
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
hit | 属性 | hit: false | 公开属性;类型、只读和可选状态以签名列为准。 |
key | 属性 | key: string | 公开属性;类型、只读和可选状态以签名列为准。 |
reason | 属性 | reason: "not_found" | "expired" | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheMetadata
Cache Metadata 接口,共包含 12 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheMetadata } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheMetadata {
provider: string;
model: string;
cacheType: CacheType;
promptHash?: string;
toolSchemaHash?: string;
requestHash?: string;
hitCount?: number;
tags?: string[];
scope?: CacheScope;
projectionType?: string;
classification?: 'public' | 'internal' | 'confidential' | 'restricted';
prefixMetadata?: PromptPrefixMetadata;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
cacheType | 属性 | cacheType: CacheType | 公开属性;类型、只读和可选状态以签名列为准。 |
classification | 属性 | classification?: "restricted" | "public" | "internal" | "confidential" | 公开属性;类型、只读和可选状态以签名列为准。 |
hitCount | 属性 | hitCount?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model: string | 公开属性;类型、只读和可选状态以签名列为准。 |
prefixMetadata | 属性 | prefixMetadata?: PromptPrefixMetadata | 公开属性;类型、只读和可选状态以签名列为准。 |
projectionType | 属性 | projectionType?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
promptHash | 属性 | promptHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
provider | 属性 | provider: string | 公开属性;类型、只读和可选状态以签名列为准。 |
requestHash | 属性 | requestHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
scope | 属性 | scope?: CacheScope | 公开属性;类型、只读和可选状态以签名列为准。 |
tags | 属性 | tags?: string[] | 公开属性;类型、只读和可选状态以签名列为准。 |
toolSchemaHash | 属性 | toolSchemaHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
CachePolicy
Cache Policy 接口,共包含 10 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CachePolicy } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CachePolicy {
enabled: boolean;
mode: CacheMode;
ttlMs?: number;
respectNoCache?: boolean;
failureMode?: CacheFailureMode;
scopeRequirement?: CacheScopeRequirement;
operationTimeoutMs?: number;
singleflight?: boolean;
maxEntryBytes?: number;
circuitBreaker?: {
failureThreshold: number;
resetTimeoutMs: number;
};
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
circuitBreaker | 属性 | circuitBreaker?: { failureThreshold: number; resetTimeoutMs: number; } | 公开属性;类型、只读和可选状态以签名列为准。 |
enabled | 属性 | enabled: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
failureMode | 属性 | failureMode?: CacheFailureMode | 公开属性;类型、只读和可选状态以签名列为准。 |
maxEntryBytes | 属性 | maxEntryBytes?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
mode | 属性 | mode: CacheMode | 公开属性;类型、只读和可选状态以签名列为准。 |
operationTimeoutMs | 属性 | operationTimeoutMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
respectNoCache | 属性 | respectNoCache?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
scopeRequirement | 属性 | scopeRequirement?: CacheScopeRequirement | 公开属性;类型、只读和可选状态以签名列为准。 |
singleflight | 属性 | singleflight?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
ttlMs | 属性 | ttlMs?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheScope
Cache Scope 接口,共包含 5 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheScope } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheScope {
tenantId?: string;
userId?: string;
projectId?: string;
sessionId?: string;
domainPackId?: string;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
domainPackId | 属性 | domainPackId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
projectId | 属性 | projectId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
sessionId | 属性 | sessionId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tenantId | 属性 | tenantId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
userId | 属性 | userId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheStore
Cache Store 接口,共包含 8 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheStore } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheStore<T = unknown> {
get<TValue = T>(key: string): Promise<CacheEntry<TValue> | null>;
set<TValue = T>(key: string, entry: CacheEntry<TValue>): Promise<void>;
delete(key: string): Promise<void>;
clear?(): Promise<void>;
touch?(key: string, timestamp: number): Promise<void>;
stats?(): Promise<CacheStoreStats>;
health?(): Promise<CacheStoreHealth>;
close?(): Promise<void>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
clear | 方法 | clear?(): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
close | 方法 | close?(): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
delete | 方法 | delete(key: string): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
get | 方法 | get<TValue = T>(key: string): Promise<CacheEntry<TValue> | null> | 公开方法;参数与返回类型以签名列为准。 |
health | 方法 | health?(): Promise<CacheStoreHealth> | 公开方法;参数与返回类型以签名列为准。 |
set | 方法 | set<TValue = T>(key: string, entry: CacheEntry<TValue>): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
stats | 方法 | stats?(): Promise<CacheStoreStats> | 公开方法;参数与返回类型以签名列为准。 |
touch | 方法 | touch?(key: string, timestamp: number): Promise<void> | 公开方法;参数与返回类型以签名列为准。 |
CacheStoreHealth
Cache Store Health 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheStoreHealth } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheStoreHealth {
status: 'healthy' | 'degraded' | 'unavailable';
checkedAt: string;
details?: Record<string, unknown>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
checkedAt | 属性 | checkedAt: string | 公开属性;类型、只读和可选状态以签名列为准。 |
details | 属性 | details?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
status | 属性 | status: "healthy" | "degraded" | "unavailable" | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheStoreStats
Cache Store Stats 接口,共包含 3 个公开字段或方法。
- 种类: 接口
- 导入:
import type { CacheStoreStats } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface CacheStoreStats {
entries: number;
sizeBytes?: number;
evictions?: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
entries | 属性 | entries: number | 公开属性;类型、只读和可选状态以签名列为准。 |
evictions | 属性 | evictions?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
sizeBytes | 属性 | sizeBytes?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
LLMCacheKeyInput
LLM Cache Key Input 接口,共包含 8 个公开字段或方法。
- 种类: 接口
- 导入:
import type { LLMCacheKeyInput } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface LLMCacheKeyInput {
provider: string;
model: string;
messages: unknown[];
system?: string;
tools?: unknown[];
params?: Record<string, unknown>;
cacheScope?: CacheScope;
promptBlocks?: PromptPrefixBlockInput[];
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
cacheScope | 属性 | cacheScope?: CacheScope | 公开属性;类型、只读和可选状态以签名列为准。 |
messages | 属性 | messages: unknown[] | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model: string | 公开属性;类型、只读和可选状态以签名列为准。 |
params | 属性 | params?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
promptBlocks | 属性 | promptBlocks?: PromptPrefixBlockInput[] | 公开属性;类型、只读和可选状态以签名列为准。 |
provider | 属性 | provider: string | 公开属性;类型、只读和可选状态以签名列为准。 |
system | 属性 | system?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tools | 属性 | tools?: unknown[] | 公开属性;类型、只读和可选状态以签名列为准。 |
ModelRequestCacheControl
Model Request Cache Control 接口,共包含 2 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ModelRequestCacheControl } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface ModelRequestCacheControl {
mode?: CacheMode;
noCache?: boolean;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
mode | 属性 | mode?: CacheMode | 公开属性;类型、只读和可选状态以签名列为准。 |
noCache | 属性 | noCache?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
PrefixCacheShapeObservation
Prefix Cache Shape Observation 接口,共包含 17 个公开字段或方法。
- 种类: 接口
- 导入:
import type { PrefixCacheShapeObservation } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface PrefixCacheShapeObservation {
provider: string;
model: string;
prefixHash: string;
previousPrefixHash?: string;
toolSchemaHash?: string;
previousToolSchemaHash?: string;
domainPackHash?: string;
previousDomainPackHash?: string;
dynamicSuffixHash?: string;
previousDynamicSuffixHash?: string;
requestHash?: string;
prefixTokenEstimate?: number;
blockCount: number;
stablePrefixChanged: boolean;
dynamicSuffixChanged: boolean;
changedReasons: PrefixCacheChangeReason[];
scope?: CacheScope;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
blockCount | 属性 | blockCount: number | 公开属性;类型、只读和可选状态以签名列为准。 |
changedReasons | 属性 | changedReasons: PrefixCacheChangeReason[] | 公开属性;类型、只读和可选状态以签名列为准。 |
domainPackHash | 属性 | domainPackHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
dynamicSuffixChanged | 属性 | dynamicSuffixChanged: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
dynamicSuffixHash | 属性 | dynamicSuffixHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
model | 属性 | model: string | 公开属性;类型、只读和可选状态以签名列为准。 |
prefixHash | 属性 | prefixHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
prefixTokenEstimate | 属性 | prefixTokenEstimate?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
previousDomainPackHash | 属性 | previousDomainPackHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
previousDynamicSuffixHash | 属性 | previousDynamicSuffixHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
previousPrefixHash | 属性 | previousPrefixHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
previousToolSchemaHash | 属性 | previousToolSchemaHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
provider | 属性 | provider: string | 公开属性;类型、只读和可选状态以签名列为准。 |
requestHash | 属性 | requestHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
scope | 属性 | scope?: CacheScope | 公开属性;类型、只读和可选状态以签名列为准。 |
stablePrefixChanged | 属性 | stablePrefixChanged: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
toolSchemaHash | 属性 | toolSchemaHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
PromptPrefixBlock
Prompt Prefix Block 接口,共包含 11 个公开字段或方法。
- 种类: 接口
- 导入:
import type { PromptPrefixBlock } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface PromptPrefixBlock extends Required<Pick<PromptPrefixBlockInput, 'id' | 'type' | 'hash'>> {
stable: boolean;
content?: string;
tokenEstimate?: number;
order?: number;
source?: string;
templateId?: string;
templateVersion?: string;
metadata?: Record<string, unknown>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
content | 属性 | content?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
hash | 属性 | hash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
id | 属性 | id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
order | 属性 | order?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
source | 属性 | source?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
stable | 属性 | stable: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
templateId | 属性 | templateId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
templateVersion | 属性 | templateVersion?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tokenEstimate | 属性 | tokenEstimate?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
type | 属性 | type: PromptPrefixBlockType | 公开属性;类型、只读和可选状态以签名列为准。 |
PromptPrefixBlockInput
Prompt Prefix Block Input 接口,共包含 11 个公开字段或方法。
- 种类: 接口
- 导入:
import type { PromptPrefixBlockInput } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface PromptPrefixBlockInput {
id: string;
type: PromptPrefixBlockType;
stable?: boolean;
hash?: string;
content?: string;
tokenEstimate?: number;
order?: number;
source?: string;
templateId?: string;
templateVersion?: string;
metadata?: Record<string, unknown>;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
content | 属性 | content?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
hash | 属性 | hash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
id | 属性 | id: string | 公开属性;类型、只读和可选状态以签名列为准。 |
metadata | 属性 | metadata?: Record<string, unknown> | 公开属性;类型、只读和可选状态以签名列为准。 |
order | 属性 | order?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
source | 属性 | source?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
stable | 属性 | stable?: boolean | 公开属性;类型、只读和可选状态以签名列为准。 |
templateId | 属性 | templateId?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
templateVersion | 属性 | templateVersion?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
tokenEstimate | 属性 | tokenEstimate?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
type | 属性 | type: PromptPrefixBlockType | 公开属性;类型、只读和可选状态以签名列为准。 |
PromptPrefixMetadata
Prompt Prefix Metadata 接口,共包含 7 个公开字段或方法。
- 种类: 接口
- 导入:
import type { PromptPrefixMetadata } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface PromptPrefixMetadata {
prefixHash: string;
prefixTokenEstimate?: number;
dynamicSuffixHash?: string;
requestHash?: string;
toolSchemaHash?: string;
domainPackHash?: string;
blocks: PromptPrefixBlock[];
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
blocks | 属性 | blocks: PromptPrefixBlock[] | 公开属性;类型、只读和可选状态以签名列为准。 |
domainPackHash | 属性 | domainPackHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
dynamicSuffixHash | 属性 | dynamicSuffixHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
prefixHash | 属性 | prefixHash: string | 公开属性;类型、只读和可选状态以签名列为准。 |
prefixTokenEstimate | 属性 | prefixTokenEstimate?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
requestHash | 属性 | requestHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
toolSchemaHash | 属性 | toolSchemaHash?: string | 公开属性;类型、只读和可选状态以签名列为准。 |
ProviderPrefixCacheUsage
Provider Prefix Cache Usage 接口,共包含 5 个公开字段或方法。
- 种类: 接口
- 导入:
import type { ProviderPrefixCacheUsage } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export interface ProviderPrefixCacheUsage {
source: 'provider-usage' | 'hypha-serving-cache' | 'unknown';
inputTokens?: number;
hitTokens?: number;
missTokens?: number;
hitRate?: number;
}契约成员
| 成员 | 种类 | 签名 | 说明 |
|---|---|---|---|
hitRate | 属性 | hitRate?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
hitTokens | 属性 | hitTokens?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
inputTokens | 属性 | inputTokens?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
missTokens | 属性 | missTokens?: number | 公开属性;类型、只读和可选状态以签名列为准。 |
source | 属性 | source: "unknown" | "provider-usage" | "hypha-serving-cache" | 公开属性;类型、只读和可选状态以签名列为准。 |
CacheFailureMode
Cache Failure Mode 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { CacheFailureMode } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type CacheFailureMode = 'bypass' | 'strict';CacheLookupResult
Cache Lookup Result 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { CacheLookupResult } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type CacheLookupResult<T = unknown> = CacheLookupHit<T> | CacheLookupMiss;CacheMode
Cache Mode 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { CacheMode } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type CacheMode = 'off' | 'read' | 'write' | 'readwrite';CacheScopeRequirement
Cache Scope Requirement 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { CacheScopeRequirement } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type CacheScopeRequirement = 'none' | 'user' | 'session';CacheType
Cache Type 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { CacheType } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type CacheType = 'exact' | 'prefix-metadata' | 'semantic';PrefixCacheChangeReason
Prefix Cache Change Reason 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { PrefixCacheChangeReason } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type PrefixCacheChangeReason = 'first_request' | 'prefix_changed' | 'tool_schema_changed' | 'domain_pack_changed' | 'dynamic_suffix_changed' | 'unchanged';PromptPrefixBlockType
Prompt Prefix Block Type 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { PromptPrefixBlockType } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type PromptPrefixBlockType = 'system' | 'tool-schema' | 'project-context' | 'domain-pack' | 'memory' | 'prompt-template';ServingCacheEvent
Serving Cache Event 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ServingCacheEvent } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type ServingCacheEvent = {
type: 'llm.cache.lookup';
key: string;
provider: string;
model: string;
scope?: CacheScope;
prefixCache?: PrefixCacheShapeObservation;
runId?: string;
stepId?: string;
} | {
type: 'llm.cache.hit';
key: string;
ageMs: number;
provider: string;
model: string;
scope?: CacheScope;
prefixCache?: PrefixCacheShapeObservation;
runId?: string;
stepId?: string;
} | {
type: 'llm.cache.miss';
key: string;
reason: ServingCacheMissReason;
provider: string;
model: string;
scope?: CacheScope;
prefixCache?: PrefixCacheShapeObservation;
runId?: string;
stepId?: string;
} | {
type: 'llm.cache.write';
key: string;
ttlMs?: number;
provider: string;
model: string;
scope?: CacheScope;
prefixMetadata?: PromptPrefixMetadata;
prefixCache?: PrefixCacheShapeObservation;
providerPrefixCache?: ProviderPrefixCacheUsage;
runId?: string;
stepId?: string;
} | {
type: 'llm.cache.bypass';
reason: ServingCacheMissReason;
operation?: 'lookup' | 'write' | 'delete' | 'trace';
code?: string;
key?: string;
provider?: string;
model?: string;
scope?: CacheScope;
runId?: string;
stepId?: string;
};ServingCacheMissReason
Serving Cache Miss Reason 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ServingCacheMissReason } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type ServingCacheMissReason = 'not_found' | 'expired' | 'disabled' | 'streaming' | 'no_cache' | 'mode_off' | 'read_disabled' | 'scope_missing' | 'store_unavailable' | 'entry_oversized' | 'corrupt';ServingCacheStoreKind
Serving Cache Store Kind 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ServingCacheStoreKind } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type ServingCacheStoreKind = 'off' | 'noop' | 'memory' | 'sqlite' | 'redis';ServingCacheTraceSink
Serving Cache Trace Sink 公共类型别名;完整类型表达式见声明。
- 种类: 类型
- 导入:
import type { ServingCacheTraceSink } from '@codesoul-co/hypha-serving-cache'; - 源码模块:
types
声明
export type ServingCacheTraceSink = (event: ServingCacheEvent) => void | Promise<void>;