Skip to content

@codesoul-co/hypha-memory / external-provider-operations

Using this module

Use the External provider operations module for binding external or local providers to Hypha ports. It exports 2 classes, 1 constant, 4 functions, 2 interfaces, 1 type.

Import from the package entrypoint

ts
import {
  InMemoryExternalProviderOperationStore,
  StructuredExternalProviderOperationStore,
  externalProviderOperationSchema,
  createExternalProviderOperation,
  externalProviderOperationId,
  fingerprintExternalOperationFailure,
  resolveExternalProviderOperationStore,
} from '@codesoul-co/hypha-memory';

import type {
  ExternalProviderOperation,
  ExternalProviderOperationStore,
  ExternalProviderOperationState,
} from '@codesoul-co/hypha-memory';

Usage patterns

  • Use the 3 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 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 4 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
  • The 1 constant/enum export provides stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
InMemoryExternalProviderOperationStoreclassnew InMemoryExternalProviderOperationStore(): InMemoryExternalProviderOperationStoreIn Memory External Provider Operation Store class with 6 public constructor or member entries; its exact declarations are listed below.
StructuredExternalProviderOperationStoreclassnew StructuredExternalProviderOperationStore(options: { store: StructuredStoreProvider; table?: string; }): StructuredExternalProviderOperationStoreStructured External Provider Operation Store class with 6 public constructor or member entries; its exact declarations are listed below.
externalProviderOperationSchemaconstantconst externalProviderOperationSchema: ZodType<ExternalProviderOperation, ZodTypeDef, ExternalProviderOperation>Runtime schema for External Provider Operation.
createExternalProviderOperationfunctioncreateExternalProviderOperation(input: Omit<ExternalProviderOperation, "id" | "scopeHash" | "attempts" | "createdAt" | "updatedAt"> & { now?: string; }): ExternalProviderOperationCreate External Provider Operation function with 1 public call signature; parameters and return types are listed below.
externalProviderOperationIdfunctionexternalProviderOperationId(providerId: string, operationId: string): stringExternal Provider Operation ID function with 1 public call signature; parameters and return types are listed below.
fingerprintExternalOperationFailurefunctionfingerprintExternalOperationFailure(error: NormalizedMemoryError): stringFingerprint External Operation Failure function with 1 public call signature; parameters and return types are listed below.
resolveExternalProviderOperationStorefunctionresolveExternalProviderOperationStore(store: ExternalProviderOperationStore | undefined, profile: "production" | "test" | "ephemeral"): ExternalProviderOperationStoreResolve External Provider Operation Store function with 1 public call signature; parameters and return types are listed below.
ExternalProviderOperationinterfaceinterface ExternalProviderOperationExternal Provider Operation interface with 19 public fields or methods.
ExternalProviderOperationStoreinterfaceinterface ExternalProviderOperationStoreExternal Provider Operation Store interface with 5 public fields or methods.
ExternalProviderOperationStatetypetype ExternalProviderOperationState = 'pending' | 'running' | 'reconcile_required' | 'succeeded' | 'failed' | 'cancelled' | 'dead_letter'Public type alias for External Provider Operation State; the declaration contains its complete type expression.

InMemoryExternalProviderOperationStore

In Memory External Provider Operation Store class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryExternalProviderOperationStore } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare class InMemoryExternalProviderOperationStore implements ExternalProviderOperationStore {
    readonly durability: "ephemeral";
    get(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>;
    claim(operation: ExternalProviderOperation): Promise<{
            operation: ExternalProviderOperation;
            created: boolean;
        }>;
    set(operation: ExternalProviderOperation): Promise<void>;
    listRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>;
}

Public members

MemberKindSignatureDescription
claimmethodclaim(operation: ExternalProviderOperation): Promise<{ operation: ExternalProviderOperation; created: boolean; }>Public method; parameters and return type are shown in the signature.
constructorconstructor(): InMemoryExternalProviderOperationStoreCreates an instance of this class.
durabilitypropertyreadonly durability: "ephemeral"Public property; its type, readonly modifier and optionality are shown in the signature.
getmethodget(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>Public method; parameters and return type are shown in the signature.
listRecoverablemethodlistRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>Public method; parameters and return type are shown in the signature.
setmethodset(operation: ExternalProviderOperation): Promise<void>Public method; parameters and return type are shown in the signature.

StructuredExternalProviderOperationStore

Structured External Provider Operation Store class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { StructuredExternalProviderOperationStore } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare class StructuredExternalProviderOperationStore implements ExternalProviderOperationStore {
    readonly durability: "durable";
    constructor(options: {
            store: StructuredStoreProvider;
            table?: string;
        });
    get(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>;
    claim(operation: ExternalProviderOperation): Promise<{
            operation: ExternalProviderOperation;
            created: boolean;
        }>;
    set(operation: ExternalProviderOperation): Promise<void>;
    listRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>;
}

Public members

MemberKindSignatureDescription
claimmethodclaim(operation: ExternalProviderOperation): Promise<{ operation: ExternalProviderOperation; created: boolean; }>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: { store: StructuredStoreProvider; table?: string; }): StructuredExternalProviderOperationStoreCreates an instance of this class.
durabilitypropertyreadonly durability: "durable"Public property; its type, readonly modifier and optionality are shown in the signature.
getmethodget(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>Public method; parameters and return type are shown in the signature.
listRecoverablemethodlistRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>Public method; parameters and return type are shown in the signature.
setmethodset(operation: ExternalProviderOperation): Promise<void>Public method; parameters and return type are shown in the signature.

externalProviderOperationSchema

Runtime schema for External Provider Operation.

  • Kind: constant
  • Import: import { externalProviderOperationSchema } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare const externalProviderOperationSchema: ZodType<ExternalProviderOperation, ZodTypeDef, ExternalProviderOperation>;

createExternalProviderOperation

Create External Provider Operation function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { createExternalProviderOperation } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare function createExternalProviderOperation(input: Omit<ExternalProviderOperation, 'id' | 'scopeHash' | 'attempts' | 'createdAt' | 'updatedAt'> & {
    now?: string;
}): ExternalProviderOperation;

Call signature

text
createExternalProviderOperation(input: Omit<ExternalProviderOperation, "id" | "scopeHash" | "attempts" | "createdAt" | "updatedAt"> & { now?: string; }): ExternalProviderOperation

Parameters

ParameterTypeRequiredDescription
inputOmit<ExternalProviderOperation, "id" | "attempts" | "createdAt" | "updatedAt" | "scopeHash"> & { now?: string; }YesRequired parameter; accepted values are defined by the type column.

Returns

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

externalProviderOperationId

External Provider Operation ID function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function externalProviderOperationId(providerId: string, operationId: string): string;

Call signature

text
externalProviderOperationId(providerId: string, operationId: string): string

Parameters

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

Returns

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

fingerprintExternalOperationFailure

Fingerprint External Operation Failure function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { fingerprintExternalOperationFailure } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare function fingerprintExternalOperationFailure(error: NormalizedMemoryError): string;

Call signature

text
fingerprintExternalOperationFailure(error: NormalizedMemoryError): string

Parameters

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

Returns

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

resolveExternalProviderOperationStore

Resolve External Provider Operation Store function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { resolveExternalProviderOperationStore } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export declare function resolveExternalProviderOperationStore(store: ExternalProviderOperationStore | undefined, profile: 'production' | 'test' | 'ephemeral'): ExternalProviderOperationStore;

Call signature

text
resolveExternalProviderOperationStore(store: ExternalProviderOperationStore | undefined, profile: "production" | "test" | "ephemeral"): ExternalProviderOperationStore

Parameters

ParameterTypeRequiredDescription
storeExternalProviderOperationStoreYesRequired parameter; accepted values are defined by the type column.
profile"ephemeral" | "production" | "test"YesRequired parameter; accepted values are defined by the type column.

Returns

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

ExternalProviderOperation

External Provider Operation interface with 19 public fields or methods.

  • Kind: interface
  • Import: import type { ExternalProviderOperation } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export interface ExternalProviderOperation {
    id: string;
    providerId: string;
    operationId: string;
    externalOperationId?: string;
    kind: 'mem0_event' | 'vertex_lro' | 'hindsight_operation' | 'unknown_write';
    state: ExternalProviderOperationState;
    scope: ManagedMemoryScope;
    scopeHash: string;
    profileRef: MemoryContractSpecRef;
    principal: {
        principalId: string;
        userId?: string;
    };
    attempts: number;
    deadlineAt?: string;
    nextAttemptAt?: string;
    cancellationRequestedAt?: string;
    failure?: NormalizedMemoryError;
    failureFingerprint?: string;
    createdAt: string;
    updatedAt: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
attemptspropertyattempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
cancellationRequestedAtpropertycancellationRequestedAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
deadlineAtpropertydeadlineAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
externalOperationIdpropertyexternalOperationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
failurepropertyfailure?: NormalizedMemoryErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
failureFingerprintpropertyfailureFingerprint?: 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.
kindpropertykind: "mem0_event" | "vertex_lro" | "hindsight_operation" | "unknown_write"Public 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.
nextAttemptAtpropertynextAttemptAt?: stringPublic 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.
principalpropertyprincipal: { principalId: string; userId?: string; }Public property; its type, readonly modifier and optionality are shown in the signature.
profileRefpropertyprofileRef: MemoryContractSpecRefPublic 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.
scopepropertyscope: ManagedMemoryScopePublic 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.
statepropertystate: ExternalProviderOperationStatePublic property; its type, readonly modifier and optionality are shown in the signature.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExternalProviderOperationStore

External Provider Operation Store interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ExternalProviderOperationStore } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export interface ExternalProviderOperationStore {
    readonly durability: 'ephemeral' | 'durable';
    get(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>;
    claim(operation: ExternalProviderOperation): Promise<{
        operation: ExternalProviderOperation;
        created: boolean;
    }>;
    set(operation: ExternalProviderOperation): Promise<void>;
    listRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>;
}

Contract members

MemberKindSignatureDescription
claimmethodclaim(operation: ExternalProviderOperation): Promise<{ operation: ExternalProviderOperation; created: boolean; }>Public method; parameters and return type are shown in the signature.
durabilitypropertyreadonly durability: "ephemeral" | "durable"Public property; its type, readonly modifier and optionality are shown in the signature.
getmethodget(providerId: string, operationId: string): Promise<ExternalProviderOperation | null>Public method; parameters and return type are shown in the signature.
listRecoverablemethodlistRecoverable(providerId?: string, now?: string): Promise<ExternalProviderOperation[]>Public method; parameters and return type are shown in the signature.
setmethodset(operation: ExternalProviderOperation): Promise<void>Public method; parameters and return type are shown in the signature.

ExternalProviderOperationState

Public type alias for External Provider Operation State; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ExternalProviderOperationState } from '@codesoul-co/hypha-memory';
  • Source module: external-provider-operations

Declaration

text
export type ExternalProviderOperationState = 'pending' | 'running' | 'reconcile_required' | 'succeeded' | 'failed' | 'cancelled' | 'dead_letter';