Skip to content

@codesoul-co/hypha-memory / memory-events

Using this module

Use the Memory events module for creating, recording, or reading Event contracts. It exports 2 functions, 3 interfaces, 1 type.

Import from the package entrypoint

ts
import {
  memoryEventIdempotencyKey,
  sanitizeMemoryEventPayload,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryEventContext,
  MemoryEventPayloadBase,
  MemoryEventPublisher,
  MemoryEventType,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 4 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 2 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
memoryEventIdempotencyKeyfunctionmemoryEventIdempotencyKey(type: MemoryEventType, payload: MemoryEventPayloadBase): stringMemory Event Idempotency Key function with 1 public call signature; parameters and return types are listed below.
sanitizeMemoryEventPayloadfunctionsanitizeMemoryEventPayload(payload: MemoryEventPayloadBase): MemoryEventPayloadBaseSanitize Memory Event Payload function with 1 public call signature; parameters and return types are listed below.
MemoryEventContextinterfaceinterface MemoryEventContextMemory Event Context interface with 7 public fields or methods.
MemoryEventPayloadBaseinterfaceinterface MemoryEventPayloadBaseMemory Event Payload Base interface with 12 public fields or methods.
MemoryEventPublisherinterfaceinterface MemoryEventPublisherMemory Event Publisher interface with 1 public fields or methods.
MemoryEventTypetypetype MemoryEventType = Extract<FrameworkEventType, memory.${string} | context.${string}>Public type alias for Memory Event Type; the declaration contains its complete type expression.

memoryEventIdempotencyKey

Memory Event Idempotency Key function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { memoryEventIdempotencyKey } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export declare function memoryEventIdempotencyKey(type: MemoryEventType, payload: MemoryEventPayloadBase): string;

Call signature

text
memoryEventIdempotencyKey(type: MemoryEventType, payload: MemoryEventPayloadBase): string

Parameters

ParameterTypeRequiredDescription
typeMemoryEventTypeYesRequired parameter; accepted values are defined by the type column.
payloadMemoryEventPayloadBaseYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

sanitizeMemoryEventPayload

Sanitize Memory Event Payload function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { sanitizeMemoryEventPayload } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export declare function sanitizeMemoryEventPayload(payload: MemoryEventPayloadBase): MemoryEventPayloadBase;

Call signature

text
sanitizeMemoryEventPayload(payload: MemoryEventPayloadBase): MemoryEventPayloadBase

Parameters

ParameterTypeRequiredDescription
payloadMemoryEventPayloadBaseYesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: MemoryEventPayloadBase
  • Description: The return contract is defined by the type shown above.

MemoryEventContext

Memory Event Context interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryEventContext } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export interface MemoryEventContext {
    userId: string;
    tenantId?: string;
    runId: string;
    sessionId?: string;
    workspaceId?: string;
    stepId?: string;
    agentId?: string;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stepIdpropertystepId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
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.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryEventPayloadBase

Memory Event Payload Base interface with 12 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryEventPayloadBase } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export interface MemoryEventPayloadBase {
    operationId: string;
    profileId?: string;
    profileRevision?: string;
    providerId?: string;
    scopeHash: string;
    memoryId?: string;
    memoryVersionId?: string;
    itemCount?: number;
    latencyMs?: number;
    status?: string;
    error?: NormalizedMemoryError;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
errorpropertyerror?: NormalizedMemoryErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
itemCountpropertyitemCount?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
latencyMspropertylatencyMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryIdpropertymemoryId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
memoryVersionIdpropertymemoryVersionId?: 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.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
profileIdpropertyprofileId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
profileRevisionpropertyprofileRevision?: 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.
scopeHashpropertyscopeHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MemoryEventPublisher

Memory Event Publisher interface with 1 public fields or methods.

  • Kind: interface
  • Import: import type { MemoryEventPublisher } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export interface MemoryEventPublisher {
    publish(type: MemoryEventType, payload: MemoryEventPayloadBase, context: MemoryEventContext): Promise<string>;
}

Contract members

MemberKindSignatureDescription
publishmethodpublish(type: MemoryEventType, payload: MemoryEventPayloadBase, context: MemoryEventContext): Promise<string>Public method; parameters and return type are shown in the signature.

MemoryEventType

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

  • Kind: type
  • Import: import type { MemoryEventType } from '@codesoul-co/hypha-memory';
  • Source module: memory-events

Declaration

text
export type MemoryEventType = Extract<FrameworkEventType, `memory.${string}` | `context.${string}`>;