Skip to content

@codesoul-co/hypha-serving-cache / types

Using this module

Use the Types module for declaring and runtime-validating contracts. It exports 18 interfaces, 11 types.

Import from the package entrypoint

ts
import type {
  CachedLLMProviderOptions,
  CachedModelResponseProjection,
  CacheEntry,
  CacheLookupHit,
  CacheLookupMiss,
  CacheMetadata,
  CachePolicy,
  CacheScope,
} from '@codesoul-co/hypha-serving-cache';

// The complete export list is documented below.

Usage patterns

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

Public exports

SymbolKindSignatureDescription
CachedLLMProviderOptionsinterfaceinterface CachedLLMProviderOptionsCached LLM Provider Options interface with 8 public fields or methods.
CachedModelResponseProjectioninterfaceinterface CachedModelResponseProjectionCached Model Response Projection interface with 6 public fields or methods.
CacheEntryinterfaceinterface CacheEntryCache Entry interface with 8 public fields or methods.
CacheLookupHitinterfaceinterface CacheLookupHitCache Lookup Hit interface with 4 public fields or methods.
CacheLookupMissinterfaceinterface CacheLookupMissCache Lookup Miss interface with 3 public fields or methods.
CacheMetadatainterfaceinterface CacheMetadataCache Metadata interface with 12 public fields or methods.
CachePolicyinterfaceinterface CachePolicyCache Policy interface with 10 public fields or methods.
CacheScopeinterfaceinterface CacheScopeCache Scope interface with 5 public fields or methods.
CacheStoreinterfaceinterface CacheStoreCache Store interface with 8 public fields or methods.
CacheStoreHealthinterfaceinterface CacheStoreHealthCache Store Health interface with 3 public fields or methods.
CacheStoreStatsinterfaceinterface CacheStoreStatsCache Store Stats interface with 3 public fields or methods.
LLMCacheKeyInputinterfaceinterface LLMCacheKeyInputLLM Cache Key Input interface with 8 public fields or methods.
ModelRequestCacheControlinterfaceinterface ModelRequestCacheControlModel Request Cache Control interface with 2 public fields or methods.
PrefixCacheShapeObservationinterfaceinterface PrefixCacheShapeObservationPrefix Cache Shape Observation interface with 17 public fields or methods.
PromptPrefixBlockinterfaceinterface PromptPrefixBlock extends Required<Pick<PromptPrefixBlockInput, 'id' | 'type' | 'hash'>>Prompt Prefix Block interface with 11 public fields or methods.
PromptPrefixBlockInputinterfaceinterface PromptPrefixBlockInputPrompt Prefix Block Input interface with 11 public fields or methods.
PromptPrefixMetadatainterfaceinterface PromptPrefixMetadataPrompt Prefix Metadata interface with 7 public fields or methods.
ProviderPrefixCacheUsageinterfaceinterface ProviderPrefixCacheUsageProvider Prefix Cache Usage interface with 5 public fields or methods.
CacheFailureModetypetype CacheFailureMode = 'bypass' | 'strict'Public type alias for Cache Failure Mode; the declaration contains its complete type expression.
CacheLookupResulttypetype CacheLookupResult = CacheLookupHit<T> | CacheLookupMissPublic type alias for Cache Lookup Result; the declaration contains its complete type expression.
CacheModetypetype CacheMode = 'off' | 'read' | 'write' | 'readwrite'Public type alias for Cache Mode; the declaration contains its complete type expression.
CacheScopeRequirementtypetype CacheScopeRequirement = 'none' | 'user' | 'session'Public type alias for Cache Scope Requirement; the declaration contains its complete type expression.
CacheTypetypetype CacheType = 'exact' | 'prefix-metadata' | 'semantic'Public type alias for Cache Type; the declaration contains its complete type expression.
PrefixCacheChangeReasontypetype PrefixCacheChangeReason = 'first_request' | 'prefix_changed' | 'tool_schema_changed' | 'domain_pack_changed' | 'dynamic_suffix_changed' | 'unchanged'Public type alias for Prefix Cache Change Reason; the declaration contains its complete type expression.
PromptPrefixBlockTypetypetype PromptPrefixBlockType = 'system' | 'tool-schema' | 'project-context' | 'domain-pack' | 'memory' | 'prompt-template'Public type alias for Prompt Prefix Block Type; the declaration contains its complete type expression.
ServingCacheEventtypetype 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...Public type alias for Serving Cache Event; the declaration contains its complete type expression.
ServingCacheMissReasontypetype ServingCacheMissReason = 'not_found' | 'expired' | 'disabled' | 'streaming' | 'no_cache' | 'mode_off' | 'read_disabled' | 'scope_missing' | 'store_unavailable' | 'entry_oversized' | 'corrupt'Public type alias for Serving Cache Miss Reason; the declaration contains its complete type expression.
ServingCacheStoreKindtypetype ServingCacheStoreKind = 'off' | 'noop' | 'memory' | 'sqlite' | 'redis'Public type alias for Serving Cache Store Kind; the declaration contains its complete type expression.
ServingCacheTraceSinktypetype ServingCacheTraceSink = (event: ServingCacheEvent) => void | Promise<void>Public type alias for Serving Cache Trace Sink; the declaration contains its complete type expression.

CachedLLMProviderOptions

Cached LLM Provider Options interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { CachedLLMProviderOptions } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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;
}

Contract members

MemberKindSignatureDescription
modelResolvermethodmodelResolver?(request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>): stringPublic method; parameters and return type are shown in the signature.
paramsResolvermethodparamsResolver?(request: ModelRequest): Record<string, unknown> | undefinedPublic method; parameters and return type are shown in the signature.
policypropertypolicy?: Partial<CachePolicy>Public property; its type, readonly modifier and optionality are shown in the signature.
promptBlocksResolvermethodpromptBlocksResolver?(request: ModelRequest): PromptPrefixBlockInput[] | undefinedPublic method; parameters and return type are shown in the signature.
providerResolvermethodproviderResolver?(request: ModelRequest, inner: ModelProvider<ModelRequest, ModelResponse>): stringPublic method; parameters and return type are shown in the signature.
responseIdFactorymethodresponseIdFactory?(request: ModelRequest, key: string): stringPublic method; parameters and return type are shown in the signature.
scopeResolvermethodscopeResolver?(request: ModelRequest): CacheScope | undefinedPublic method; parameters and return type are shown in the signature.
tracemethodtrace?(event: ServingCacheEvent): void | Promise<void>Public method; parameters and return type are shown in the signature.

CachedModelResponseProjection

Cached Model Response Projection interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { CachedModelResponseProjection } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CachedModelResponseProjection {
    schemaVersion: '1.0';
    providerId?: string;
    model?: string;
    content: ModelResponse['content'];
    toolCalls?: ModelResponse['toolCalls'];
    usage?: ModelResponse['usage'];
}

Contract members

MemberKindSignatureDescription
contentpropertycontent: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
modelpropertymodel?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
schemaVersionpropertyschemaVersion: "1.0"Public property; its type, readonly modifier and optionality are shown in the signature.
toolCallspropertytoolCalls?: import("/Users/erwin/Downloads/codespace/Hypha/packages/models/dist/index").NormalizedToolCall[]Public property; its type, readonly modifier and optionality are shown in the signature.
usagepropertyusage?: import("/Users/erwin/Downloads/codespace/Hypha/packages/models/dist/index").ModelUsagePublic property; its type, readonly modifier and optionality are shown in the signature.

CacheEntry

Cache Entry interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { CacheEntry } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheEntry<T = unknown> {
    schemaVersion?: '1.0';
    keyVersion?: '1';
    key: string;
    value: T;
    createdAt: number;
    expiresAt?: number;
    sizeBytes?: number;
    metadata?: CacheMetadata;
}

Contract members

MemberKindSignatureDescription
createdAtpropertycreatedAt: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
keypropertykey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
keyVersionpropertykeyVersion?: "1"Public property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: CacheMetadataPublic property; its type, readonly modifier and optionality are shown in the signature.
schemaVersionpropertyschemaVersion?: "1.0"Public property; its type, readonly modifier and optionality are shown in the signature.
sizeBytespropertysizeBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
valuepropertyvalue: TPublic property; its type, readonly modifier and optionality are shown in the signature.

CacheLookupHit

Cache Lookup Hit interface with 4 public fields or methods.

  • Kind: interface
  • Import: import type { CacheLookupHit } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheLookupHit<T = unknown> {
    hit: true;
    key: string;
    entry: CacheEntry<T>;
    ageMs: number;
}

Contract members

MemberKindSignatureDescription
ageMspropertyageMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
entrypropertyentry: CacheEntry<T>Public property; its type, readonly modifier and optionality are shown in the signature.
hitpropertyhit: truePublic property; its type, readonly modifier and optionality are shown in the signature.
keypropertykey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

CacheLookupMiss

Cache Lookup Miss interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { CacheLookupMiss } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheLookupMiss {
    hit: false;
    key: string;
    reason: 'not_found' | 'expired';
}

Contract members

MemberKindSignatureDescription
hitpropertyhit: falsePublic property; its type, readonly modifier and optionality are shown in the signature.
keypropertykey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: "not_found" | "expired"Public property; its type, readonly modifier and optionality are shown in the signature.

CacheMetadata

Cache Metadata interface with 12 public fields or methods.

  • Kind: interface
  • Import: import type { CacheMetadata } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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;
}

Contract members

MemberKindSignatureDescription
cacheTypepropertycacheType: CacheTypePublic property; its type, readonly modifier and optionality are shown in the signature.
classificationpropertyclassification?: "restricted" | "public" | "internal" | "confidential"Public property; its type, readonly modifier and optionality are shown in the signature.
hitCountpropertyhitCount?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
modelpropertymodel: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixMetadatapropertyprefixMetadata?: PromptPrefixMetadataPublic property; its type, readonly modifier and optionality are shown in the signature.
projectionTypepropertyprojectionType?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
promptHashpropertypromptHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerpropertyprovider: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestHashpropertyrequestHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope?: CacheScopePublic property; its type, readonly modifier and optionality are shown in the signature.
tagspropertytags?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
toolSchemaHashpropertytoolSchemaHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

CachePolicy

Cache Policy interface with 10 public fields or methods.

  • Kind: interface
  • Import: import type { CachePolicy } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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;
    };
}

Contract members

MemberKindSignatureDescription
circuitBreakerpropertycircuitBreaker?: { failureThreshold: number; resetTimeoutMs: number; }Public property; its type, readonly modifier and optionality are shown in the signature.
enabledpropertyenabled: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
failureModepropertyfailureMode?: CacheFailureModePublic property; its type, readonly modifier and optionality are shown in the signature.
maxEntryBytespropertymaxEntryBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
modepropertymode: CacheModePublic property; its type, readonly modifier and optionality are shown in the signature.
operationTimeoutMspropertyoperationTimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
respectNoCachepropertyrespectNoCache?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
scopeRequirementpropertyscopeRequirement?: CacheScopeRequirementPublic property; its type, readonly modifier and optionality are shown in the signature.
singleflightpropertysingleflight?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
ttlMspropertyttlMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

CacheScope

Cache Scope interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { CacheScope } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheScope {
    tenantId?: string;
    userId?: string;
    projectId?: string;
    sessionId?: string;
    domainPackId?: string;
}

Contract members

MemberKindSignatureDescription
domainPackIdpropertydomainPackId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
projectIdpropertyprojectId?: 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.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

CacheStore

Cache Store interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { CacheStore } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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>;
}

Contract members

MemberKindSignatureDescription
clearmethodclear?(): Promise<void>Public method; parameters and return type are shown in the signature.
closemethodclose?(): Promise<void>Public method; parameters and return type are shown in the signature.
deletemethoddelete(key: string): Promise<void>Public method; parameters and return type are shown in the signature.
getmethodget<TValue = T>(key: string): Promise<CacheEntry<TValue> | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth?(): Promise<CacheStoreHealth>Public method; parameters and return type are shown in the signature.
setmethodset<TValue = T>(key: string, entry: CacheEntry<TValue>): Promise<void>Public method; parameters and return type are shown in the signature.
statsmethodstats?(): Promise<CacheStoreStats>Public method; parameters and return type are shown in the signature.
touchmethodtouch?(key: string, timestamp: number): Promise<void>Public method; parameters and return type are shown in the signature.

CacheStoreHealth

Cache Store Health interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { CacheStoreHealth } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheStoreHealth {
    status: 'healthy' | 'degraded' | 'unavailable';
    checkedAt: string;
    details?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
checkedAtpropertycheckedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
detailspropertydetails?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "healthy" | "degraded" | "unavailable"Public property; its type, readonly modifier and optionality are shown in the signature.

CacheStoreStats

Cache Store Stats interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { CacheStoreStats } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface CacheStoreStats {
    entries: number;
    sizeBytes?: number;
    evictions?: number;
}

Contract members

MemberKindSignatureDescription
entriespropertyentries: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
evictionspropertyevictions?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sizeBytespropertysizeBytes?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

LLMCacheKeyInput

LLM Cache Key Input interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { LLMCacheKeyInput } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface LLMCacheKeyInput {
    provider: string;
    model: string;
    messages: unknown[];
    system?: string;
    tools?: unknown[];
    params?: Record<string, unknown>;
    cacheScope?: CacheScope;
    promptBlocks?: PromptPrefixBlockInput[];
}

Contract members

MemberKindSignatureDescription
cacheScopepropertycacheScope?: CacheScopePublic property; its type, readonly modifier and optionality are shown in the signature.
messagespropertymessages: unknown[]Public property; its type, readonly modifier and optionality are shown in the signature.
modelpropertymodel: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
paramspropertyparams?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
promptBlockspropertypromptBlocks?: PromptPrefixBlockInput[]Public property; its type, readonly modifier and optionality are shown in the signature.
providerpropertyprovider: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
systempropertysystem?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
toolspropertytools?: unknown[]Public property; its type, readonly modifier and optionality are shown in the signature.

ModelRequestCacheControl

Model Request Cache Control interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { ModelRequestCacheControl } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface ModelRequestCacheControl {
    mode?: CacheMode;
    noCache?: boolean;
}

Contract members

MemberKindSignatureDescription
modepropertymode?: CacheModePublic property; its type, readonly modifier and optionality are shown in the signature.
noCachepropertynoCache?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.

PrefixCacheShapeObservation

Prefix Cache Shape Observation interface with 17 public fields or methods.

  • Kind: interface
  • Import: import type { PrefixCacheShapeObservation } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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;
}

Contract members

MemberKindSignatureDescription
blockCountpropertyblockCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
changedReasonspropertychangedReasons: PrefixCacheChangeReason[]Public property; its type, readonly modifier and optionality are shown in the signature.
domainPackHashpropertydomainPackHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
dynamicSuffixChangedpropertydynamicSuffixChanged: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
dynamicSuffixHashpropertydynamicSuffixHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
modelpropertymodel: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixHashpropertyprefixHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixTokenEstimatepropertyprefixTokenEstimate?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
previousDomainPackHashpropertypreviousDomainPackHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
previousDynamicSuffixHashpropertypreviousDynamicSuffixHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
previousPrefixHashpropertypreviousPrefixHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
previousToolSchemaHashpropertypreviousToolSchemaHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerpropertyprovider: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestHashpropertyrequestHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope?: CacheScopePublic property; its type, readonly modifier and optionality are shown in the signature.
stablePrefixChangedpropertystablePrefixChanged: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
toolSchemaHashpropertytoolSchemaHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

PromptPrefixBlock

Prompt Prefix Block interface with 11 public fields or methods.

  • Kind: interface
  • Import: import type { PromptPrefixBlock } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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>;
}

Contract members

MemberKindSignatureDescription
contentpropertycontent?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
hashpropertyhash?: stringPublic 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.
orderpropertyorder?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stablepropertystable: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
templateIdpropertytemplateId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
templateVersionpropertytemplateVersion?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tokenEstimatepropertytokenEstimate?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: PromptPrefixBlockTypePublic property; its type, readonly modifier and optionality are shown in the signature.

PromptPrefixBlockInput

Prompt Prefix Block Input interface with 11 public fields or methods.

  • Kind: interface
  • Import: import type { PromptPrefixBlockInput } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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>;
}

Contract members

MemberKindSignatureDescription
contentpropertycontent?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
hashpropertyhash?: stringPublic 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.
orderpropertyorder?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stablepropertystable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
templateIdpropertytemplateId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
templateVersionpropertytemplateVersion?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
tokenEstimatepropertytokenEstimate?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: PromptPrefixBlockTypePublic property; its type, readonly modifier and optionality are shown in the signature.

PromptPrefixMetadata

Prompt Prefix Metadata interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { PromptPrefixMetadata } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface PromptPrefixMetadata {
    prefixHash: string;
    prefixTokenEstimate?: number;
    dynamicSuffixHash?: string;
    requestHash?: string;
    toolSchemaHash?: string;
    domainPackHash?: string;
    blocks: PromptPrefixBlock[];
}

Contract members

MemberKindSignatureDescription
blockspropertyblocks: PromptPrefixBlock[]Public property; its type, readonly modifier and optionality are shown in the signature.
domainPackHashpropertydomainPackHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
dynamicSuffixHashpropertydynamicSuffixHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixHashpropertyprefixHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
prefixTokenEstimatepropertyprefixTokenEstimate?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
requestHashpropertyrequestHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
toolSchemaHashpropertytoolSchemaHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ProviderPrefixCacheUsage

Provider Prefix Cache Usage interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ProviderPrefixCacheUsage } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export interface ProviderPrefixCacheUsage {
    source: 'provider-usage' | 'hypha-serving-cache' | 'unknown';
    inputTokens?: number;
    hitTokens?: number;
    missTokens?: number;
    hitRate?: number;
}

Contract members

MemberKindSignatureDescription
hitRatepropertyhitRate?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
hitTokenspropertyhitTokens?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
inputTokenspropertyinputTokens?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
missTokenspropertymissTokens?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sourcepropertysource: "unknown" | "provider-usage" | "hypha-serving-cache"Public property; its type, readonly modifier and optionality are shown in the signature.

CacheFailureMode

Public type alias for Cache Failure Mode; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { CacheFailureMode } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type CacheFailureMode = 'bypass' | 'strict';

CacheLookupResult

Public type alias for Cache Lookup Result; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { CacheLookupResult } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type CacheLookupResult<T = unknown> = CacheLookupHit<T> | CacheLookupMiss;

CacheMode

Public type alias for Cache Mode; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { CacheMode } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type CacheMode = 'off' | 'read' | 'write' | 'readwrite';

CacheScopeRequirement

Public type alias for Cache Scope Requirement; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { CacheScopeRequirement } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type CacheScopeRequirement = 'none' | 'user' | 'session';

CacheType

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

  • Kind: type
  • Import: import type { CacheType } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type CacheType = 'exact' | 'prefix-metadata' | 'semantic';

PrefixCacheChangeReason

Public type alias for Prefix Cache Change Reason; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { PrefixCacheChangeReason } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type PrefixCacheChangeReason = 'first_request' | 'prefix_changed' | 'tool_schema_changed' | 'domain_pack_changed' | 'dynamic_suffix_changed' | 'unchanged';

PromptPrefixBlockType

Public type alias for Prompt Prefix Block Type; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { PromptPrefixBlockType } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type PromptPrefixBlockType = 'system' | 'tool-schema' | 'project-context' | 'domain-pack' | 'memory' | 'prompt-template';

ServingCacheEvent

Public type alias for Serving Cache Event; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ServingCacheEvent } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
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

Public type alias for Serving Cache Miss Reason; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ServingCacheMissReason } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type ServingCacheMissReason = 'not_found' | 'expired' | 'disabled' | 'streaming' | 'no_cache' | 'mode_off' | 'read_disabled' | 'scope_missing' | 'store_unavailable' | 'entry_oversized' | 'corrupt';

ServingCacheStoreKind

Public type alias for Serving Cache Store Kind; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ServingCacheStoreKind } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type ServingCacheStoreKind = 'off' | 'noop' | 'memory' | 'sqlite' | 'redis';

ServingCacheTraceSink

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

  • Kind: type
  • Import: import type { ServingCacheTraceSink } from '@codesoul-co/hypha-serving-cache';
  • Source module: types

Declaration

text
export type ServingCacheTraceSink = (event: ServingCacheEvent) => void | Promise<void>;