Skip to content
RELKIT
Esc
↑↓navigate↵open⌘Jpreview
On this page

Local providers API

Generated public TypeScript reference for @relkit/providers-local.

For configuration and examples, read local providers.

Public imports

  • @relkit/providers-local — 217 exports

All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API’s inline sample, a maintained repository usage, or the shared module walkthrough.

API Kind Import from Example
AgentStateStore Type @relkit/providers-local Source example
applyRetry Value @relkit/providers-local Source example
assertActive Value @relkit/providers-local Module example
assertContainedPath Value @relkit/providers-local Module example
assertTime Value @relkit/providers-local Module example
byteLength Value @relkit/providers-local Module example
calculateRetryDelay Value @relkit/providers-local Source example
checkpoint Value @relkit/providers-local Module example
classifyFailure Value @relkit/providers-local Module example
clone Value @relkit/providers-local Module example
CompiledSchedule Type @relkit/providers-local Module example
compileSchedule Value @relkit/providers-local Source example
createAgentStateProviderFromStore Value @relkit/providers-local Source example
createEphemeralDelivery Value @relkit/providers-local Source example
createEventAdmin Value @relkit/providers-local Source example
createEventDelivery Value @relkit/providers-local Source example
createEventLog Value @relkit/providers-local Source example
createEventLogPaths Value @relkit/providers-local Module example
createEventRouter Value @relkit/providers-local Source example
createJobAdmin Value @relkit/providers-local Source example
createJobQueue Value @relkit/providers-local Source example
createJobStore Value @relkit/providers-local Source example
createLocalAgentStateProvider Value @relkit/providers-local Source example
createLocalBucketProvider Value @relkit/providers-local Module example
createLocalBucketProviderForTest Value @relkit/providers-local Source example
createLocalCacheInspector Value @relkit/providers-local Module example
createLocalCacheKey Value @relkit/providers-local Source example
createLocalCacheProvider Value @relkit/providers-local Source example
createLocalCacheProviderForTest Value @relkit/providers-local Source example
createLocalEventProvider Value @relkit/providers-local Source example
createLocalJobProvider Value @relkit/providers-local Source example
createLocalObservabilityProvider Value @relkit/providers-local Module example
createLocalRealtimeProvider Value @relkit/providers-local Source example
createRealtimeProviderFromStore Value @relkit/providers-local Module example
createScheduler Value @relkit/providers-local Source example
DEFAULT_BUCKET_PAGE_SIZE Value @relkit/providers-local Module example
DEFAULT_EPHEMERAL_CAPACITY Value @relkit/providers-local Module example
DurableEventDeliveryResult Type @relkit/providers-local Module example
emptyAgentState Value @relkit/providers-local Source example
emptyPartition Value @relkit/providers-local Module example
emptyRealtimeState Value @relkit/providers-local Source example
encodeBucketKey Value @relkit/providers-local Module example
encodedBytes Value @relkit/providers-local Module example
EPHEMERAL_DELIVERY_CAPABILITIES Value @relkit/providers-local Module example
EphemeralDelivery Type @relkit/providers-local Module example
EphemeralDeliveryResult Type @relkit/providers-local Module example
EphemeralDeliverySnapshot Type @relkit/providers-local Module example
EVENT_ADMIN_PROTOCOL Value @relkit/providers-local Module example
EVENT_ADMIN_VERSION Value @relkit/providers-local Module example
EVENT_DELIVERY_CAPABILITIES Value @relkit/providers-local Module example
EVENT_DELIVERY_VERSION Value @relkit/providers-local Module example
EVENT_LOG_VERSION Value @relkit/providers-local Module example
EventAdmin Type @relkit/providers-local Module example
EventAdminAction Type @relkit/providers-local Module example
EventAdminActionContract Type @relkit/providers-local Module example
EventAdminActionOutcome Type @relkit/providers-local Module example
EventAdminActionRecord Type @relkit/providers-local Module example
EventAdminActionRequest Type @relkit/providers-local Module example
EventAdminActionSink Type @relkit/providers-local Module example
EventAdminError Value @relkit/providers-local Module example
EventAdminMode Type @relkit/providers-local Module example
EventAdminOptions Type @relkit/providers-local Module example
EventAdminVersion Type @relkit/providers-local Module example
EventContract Type @relkit/providers-local Module example
EventContractInput Type @relkit/providers-local Module example
EventDeadLetterContract Type @relkit/providers-local Module example
EventDelivery Type @relkit/providers-local Module example
EventDeliveryBinding Type @relkit/providers-local Module example
EventDeliveryBoundary Type @relkit/providers-local Module example
EventDeliveryContract Type @relkit/providers-local Module example
EventDeliveryLedgerRecord Type @relkit/providers-local Module example
EventDeliveryOptions Type @relkit/providers-local Module example
EventDeliveryRecord Type @relkit/providers-local Module example
EventDeliveryResult Type @relkit/providers-local Module example
EventDeliverySnapshot Type @relkit/providers-local Module example
EventFanoutResult Type @relkit/providers-local Module example
EventLog Type @relkit/providers-local Module example
EventLogBoundary Type @relkit/providers-local Module example
EventLogInput Type @relkit/providers-local Module example
EventLogOptions Type @relkit/providers-local Module example
EventLogPaths Type @relkit/providers-local Module example
EventLogRecord Type @relkit/providers-local Module example
EventLogSnapshot Type @relkit/providers-local Module example
EventLogStateError Value @relkit/providers-local Module example
EventPublicationContract Type @relkit/providers-local Module example
EventQueryContract Type @relkit/providers-local Module example
EventQueryRequest Type @relkit/providers-local Module example
EventRetryRequest Type @relkit/providers-local Module example
EventRouter Type @relkit/providers-local Module example
EventRouterInput Type @relkit/providers-local Module example
EventRouterOptions Type @relkit/providers-local Module example
EventRouterRouteOptions Type @relkit/providers-local Module example
EventRouterSnapshot Type @relkit/providers-local Module example
EventRouterStateError Value @relkit/providers-local Module example
EventRouterTrigger Type @relkit/providers-local Module example
EventTriggerCapabilityContract Type @relkit/providers-local Module example
EventTriggerContract Type @relkit/providers-local Module example
EventTriggerSnapshot Type @relkit/providers-local Module example
EventVersioned Type @relkit/providers-local Module example
JOB_ADMIN_PROTOCOL Value @relkit/providers-local Module example
JOB_ADMIN_VERSION Value @relkit/providers-local Module example
JOB_QUEUE_STATES Value @relkit/providers-local Module example
JobActionContract Type @relkit/providers-local Module example
JobActionRequest Type @relkit/providers-local Module example
JobAdmin Type @relkit/providers-local Module example
JobAdminAction Type @relkit/providers-local Module example
JobAdminActionOutcome Type @relkit/providers-local Module example
JobAdminActionRecord Type @relkit/providers-local Module example
JobAdminActionSink Type @relkit/providers-local Module example
JobAdminError Value @relkit/providers-local Module example
JobAdminMode Type @relkit/providers-local Module example
JobAdminOptions Type @relkit/providers-local Module example
JobAdminVersion Type @relkit/providers-local Module example
JobCancelRequest Type @relkit/providers-local Module example
JobDeadLetterRequest Type @relkit/providers-local Module example
JobFailureKind Type @relkit/providers-local Module example
JobFailureMetadata Type @relkit/providers-local Module example
JobFailureOutcome Type @relkit/providers-local Module example
JobFailureRetry Type @relkit/providers-local Module example
JobIdempotencyDefinition Type @relkit/providers-local Source example
JobIdempotencyRecord Type @relkit/providers-local Module example
JobQueryContract Type @relkit/providers-local Module example
JobQueryRequest Type @relkit/providers-local Module example
JobQueue Type @relkit/providers-local Module example
JobQueueAcceptance Type @relkit/providers-local Module example
JobQueueAdminRetryOptions Type @relkit/providers-local Module example
JobQueueCounts Type @relkit/providers-local Module example
JobQueueEnqueue Type @relkit/providers-local Module example
JobQueueEntry Type @relkit/providers-local Module example
JobQueueLeaseOptions Type @relkit/providers-local Module example
JobQueueOptions Type @relkit/providers-local Module example
JobQueueState Type @relkit/providers-local Module example
JobQueueStateError Value @relkit/providers-local Module example
JobQueueTransitionOptions Type @relkit/providers-local Module example
JobRecord Type @relkit/providers-local Module example
JobRecordInput Type @relkit/providers-local Module example
JobRetryRequest Type @relkit/providers-local Module example
JobState Type @relkit/providers-local Module example
JobStatusContract Type @relkit/providers-local Module example
JobStore Type @relkit/providers-local Module example
JobStoreBoundary Type @relkit/providers-local Module example
JobStoreCheckpoint Type @relkit/providers-local Module example
JobStoreIndex Type @relkit/providers-local Module example
JobStoreOptions Type @relkit/providers-local Module example
JobStoreSnapshot Type @relkit/providers-local Module example
LOCAL_AGENT_STATE_VERSION Value @relkit/providers-local Module example
LOCAL_BUCKET_CAPABILITIES Value @relkit/providers-local Module example
LOCAL_BUCKET_RESERVED_PREFIXES Value @relkit/providers-local Module example
LOCAL_CACHE_CAPABILITIES Value @relkit/providers-local Module example
LOCAL_CACHE_DURABLE_CAPABILITIES Value @relkit/providers-local Module example
LOCAL_REALTIME_STATE_VERSION Value @relkit/providers-local Module example
LocalAgentState Type @relkit/providers-local Module example
LocalAgentStateProviderOptions Type @relkit/providers-local Module example
LocalBucketKeyError Value @relkit/providers-local Source example
LocalBucketListOptions Type @relkit/providers-local Module example
LocalBucketListPage Type @relkit/providers-local Module example
LocalBucketObjectMetadata Type @relkit/providers-local Module example
LocalBucketPaginationError Value @relkit/providers-local Module example
LocalBucketPolicy Type @relkit/providers-local Module example
LocalBucketPolicyError Value @relkit/providers-local Source example
LocalBucketProvider Type @relkit/providers-local Source example
LocalBucketProviderOptions Type @relkit/providers-local Source example
LocalBucketStateError Value @relkit/providers-local Module example
LocalBucketUnsupportedCapability Type @relkit/providers-local Module example
LocalCacheCapabilities Type @relkit/providers-local Module example
LocalCacheEvictionPolicy Type @relkit/providers-local Module example
LocalCacheKeyError Value @relkit/providers-local Module example
LocalCachePolicy Type @relkit/providers-local Module example
LocalCachePolicyError Value @relkit/providers-local Module example
LocalCacheProvider Type @relkit/providers-local Source example
LocalCacheProviderOptions Type @relkit/providers-local Module example
LocalCacheRead Type @relkit/providers-local Module example
LocalCacheSnapshot Type @relkit/providers-local Module example
LocalCacheStateError Value @relkit/providers-local Module example
LocalCacheStore Value @relkit/providers-local Module example
LocalCacheStoreEntry Type @relkit/providers-local Module example
LocalCacheStoreSnapshot Type @relkit/providers-local Module example
LocalCacheStoreState Type @relkit/providers-local Module example
LocalCacheValueError Value @relkit/providers-local Module example
LocalEventProvider Type @relkit/providers-local Module example
LocalJobProvider Type @relkit/providers-local Module example
LocalRealtimeError Value @relkit/providers-local Module example
LocalRealtimeProviderOptions Type @relkit/providers-local Module example
LocalRealtimeState Type @relkit/providers-local Source example
MAX_BUCKET_PAGE_SIZE Value @relkit/providers-local Module example
MISSING Value @relkit/providers-local Module example
MutableQueueState Type @relkit/providers-local Module example
normalizeBucketKey Value @relkit/providers-local Module example
normalizeBucketPrefix Value @relkit/providers-local Module example
normalizeCacheId Value @relkit/providers-local Module example
normalizePolicy Value @relkit/providers-local Module example
normalizeSchemaVersion Value @relkit/providers-local Module example
normalizeTtl Value @relkit/providers-local Module example
paginateKeys Value @relkit/providers-local Module example
partitionKey Value @relkit/providers-local Module example
planRetry Value @relkit/providers-local Source example
prunePartition Value @relkit/providers-local Module example
RandomSource Type @relkit/providers-local Module example
readClock Value @relkit/providers-local Module example
RealtimeStateStore Type @relkit/providers-local Module example
RetryClassification Type @relkit/providers-local Module example
RetryOptions Type @relkit/providers-local Module example
RetryPlan Type @relkit/providers-local Module example
RetryState Type @relkit/providers-local Module example
safeFailureMetadata Value @relkit/providers-local Module example
ScheduleEnqueue Type @relkit/providers-local Module example
ScheduleEnqueueContext Type @relkit/providers-local Module example
Scheduler Type @relkit/providers-local Source example
SchedulerClock Type @relkit/providers-local Module example
SchedulerOptions Type @relkit/providers-local Module example
SchedulerRegistration Type @relkit/providers-local Module example
ScheduleRun Type @relkit/providers-local Module example
ScheduleValidationError Value @relkit/providers-local Source example
scopeGap Value @relkit/providers-local Module example
serializeLocalCacheValue Value @relkit/providers-local Module example
StoredLocalBucketObject Type @relkit/providers-local Module example
transitions Value @relkit/providers-local Module example

provider.ts

Composes filesystem-backed agent-state operations and their Promise compatibility boundary.

LocalAgentStateProviderOptions

Signature

declare const LocalAgentStateProviderOptions: LocalAgentStateProviderOptions;

Source

LocalAgentStateService (class)

Local agent state operations with substitutable transactional storage.

Signature

declare class LocalAgentStateService

Source

agentStateLayer

Builds the live agent-state layer without starting background work.

Example

import { Effect } from "effect";
import { LocalAgentStateService, agentStateLayer } from "./provider.js";

const program = Effect.gen(function* () {
  const agents = yield* LocalAgentStateService;
  return yield* agents.getEpoch();
});
await Effect.runPromise(program.pipe(Effect.provide(agentStateLayer("/tmp/example-agents"))));

Signature

declare const agentStateLayer: (
  root: string,
  pollingMs?: number,
) => Layer.Layer<LocalAgentStateService, LocalOperationError, never>;

Source

createAgentStateProviderFromStore

Substitutes storage while preserving the same public agent-state operations.

Signature

declare const createAgentStateProviderFromStore: (
  store: ReturnType<typeof createAgentStateStore>,
  pollingMs?: number,
) => AgentStateProvider;

Source

createLocalAgentStateProvider

Creates the filesystem-backed agent-state compatibility provider.

Signature

declare const createLocalAgentStateProvider: (
  root: string,
  options?: LocalAgentStateProviderOptions,
) => AgentStateProvider;

Source

makeAgentStateService

Composes agent operations over a replaceable state store.

Signature

declare const makeAgentStateService: (
  store: AgentStateStoreEffects,
  pollingMs?: number,
) => AgentStateEffects;

Source

provider.types.ts

Defines the Effect operation contract and bounded polling options for local agent state.

AgentStateEffects (type alias)

Effect counterpart of the established public agent-state provider methods.

Signature

type AgentStateEffects = {
  readonly [K in keyof AgentStateProvider]: AgentStateProvider[K] extends (
    ...args: infer A
  ) => infer R
    ? (...args: A) => Effect.Effect<Awaited<R>, LocalOperationError>
    : AgentStateProvider[K];
};

Source

LocalAgentStateProviderOptions (interface)

Polling policy for observing updates from other agent-state processes.

Signature

export interface LocalAgentStateProviderOptions {
  readonly pollingMs?: number;
}

Source

state.ts

LOCAL_AGENT_STATE_VERSION

Signature

declare const LOCAL_AGENT_STATE_VERSION: 1;

Source

LocalAgentState

Signature

declare const LocalAgentState: {
  readonly version: 1;
  readonly providerEpoch: string;
  readonly revision: number;
  readonly threads: {
    readonly [x: string]: {
      readonly thread: {
        readonly threadId: string;
        readonly agentId: string;
        readonly ownerScope: string;
        readonly status:
          | "idle"
          | "running"
          | "waiting"
          | "approval-interrupted"
          | "stopping"
          | "worker-interrupted";
        readonly revision: string;
        readonly createdAt: string;
        readonly updatedAt: string;
      };
      readonly runs: {
        readonly [x: string]: {
          readonly status:
            | "running"
            | "waiting"
            | "approval-interrupted"
            | "stopping"
            | "worker-interrupted"
            | "accepted"
            | "succeeded"
            | "failed"
            | "cancelled";
          readonly threadId: string;
          readonly runId: string;
          readonly owner: {
            readonly generationId: string;
            readonly publicFingerprint: string;
            readonly protocolVersion: number;
            readonly schemaVersion: number;
            readonly providerScope: string;
          };
          readonly operationId: OperationId;
          readonly inputDigest: string;
          readonly acceptedAt: string;
          readonly maxJournalBytes: number;
          readonly maxJournalRecordBytes: number;
          readonly terminalReserveBytes: number;
          readonly settledAt?: string;
          readonly outcome?: "worker-interrupted" | "succeeded" | "failed" | "cancelled";
        };
      };
      readonly messages: ReadonlyArray<{
        readonly createdAt: string;
        readonly role: "user" | "assistant" | "tool";
        readonly parts: ReadonlyArray<
          | {
              readonly kind: "text";
              readonly text: string;
              readonly partId: string;
              readonly state?: "streaming" | "complete";
            }
          | {
              readonly kind: "tool";
              readonly state:
                | "running"
                | "succeeded"
                | "failed"
                | "started"
                | "input-streaming"
                | "input-ready"
                | "approval-required"
                | "denied";
              readonly partId: string;
              readonly toolCallId: string;
              readonly toolId: string;
              readonly inputText?: string;
              readonly input?: unknown;
              readonly output?: unknown;
              readonly value?: unknown;
            }
          | {
              readonly partId: string;
              readonly kind: "progress";
              readonly value: unknown;
              readonly scope: "run";
            }
          | {
              readonly partId: string;
              readonly kind: "progress";
              readonly value: unknown;
              readonly scope: "tool";
              readonly toolCallId: string;
              readonly toolId: string;
            }
        >;
        readonly messageId: string;
        readonly runId?: string;
      }>;
      readonly approvals: ReadonlyArray<{
        readonly status: "cancelled" | "denied" | "open" | "approved";
        readonly runId: string;
        readonly approvalId: string;
        readonly interruptSetDigest: string;
        readonly publicRequest: unknown;
        readonly interruptSetSize?: number;
      }>;
      readonly journal: ReadonlyArray<{
        readonly recordId: string;
        readonly runId: string;
        readonly kind:
          "progress" | "message" | "approval" | "control" | "terminal" | "interruption" | "event";
        readonly publicValue: unknown;
        readonly checkpoint: {
          readonly applicationId: string;
          readonly environment: string;
          readonly profile: string;
          readonly providerEpoch: string;
          readonly threadId: string;
          readonly sequence: string;
        };
        readonly encodedBytes: number;
        readonly createdAt: string;
      }>;
      readonly sequence: number;
      readonly controls: {
        readonly [x: string]: {
          readonly sequence: number;
          readonly record: {
            readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
            readonly runId: string;
            readonly acceptedAt: string;
            readonly kind: "steer" | "follow-up" | "stop" | "approve";
            readonly controlId: OperationId;
            readonly semanticDigest: string;
            readonly effect: "not-started" | "confirmed" | "unknown";
            readonly settledAt?: string;
            readonly publicPayload?: unknown;
          };
          readonly publicPayload: unknown;
          readonly semanticDigest: string;
          readonly receipt: {
            readonly operationId: OperationId;
            readonly threadId: string;
            readonly runId: string;
            readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
            readonly effect: "not-started" | "confirmed" | "unknown";
            readonly duplicate: boolean;
          };
          readonly expiresAt: string;
          readonly downstreamOperationId?: string;
        };
      };
      readonly runClaims: {
        readonly [x: string]: {
          readonly runId: string;
          readonly claimId: string;
          readonly workerId: string;
          readonly generationId: string;
          readonly fence: number;
          readonly expiresAt: string;
        };
      };
      readonly controlClaims: {
        readonly [x: string]: {
          readonly controlId: OperationId;
          readonly claimId: string;
          readonly workerId: string;
          readonly generationId: string;
          readonly fence: number;
          readonly expiresAt: string;
        };
      };
      readonly scopeKey: string;
      readonly controlSequence: number;
      readonly nextFence: number;
      readonly waiting?: {
        readonly revision: string;
        readonly runId: string;
        readonly response: Json;
        readonly requests: ReadonlyArray<{
          readonly node: string;
          readonly response: Json;
          readonly value?: unknown;
        }>;
      };
      readonly activeRunId?: string;
      readonly snapshots?: {
        readonly [x: string]: {
          readonly createdAt: string;
          readonly messages: ReadonlyArray<{
            readonly createdAt: string;
            readonly role: "user" | "assistant" | "tool";
            readonly parts: ReadonlyArray<
              | {
                  readonly kind: "text";
                  readonly text: string;
                  readonly partId: string;
                  readonly state?: "streaming" | "complete";
                }
              | {
                  readonly kind: "tool";
                  readonly state:
                    | "running"
                    | "succeeded"
                    | "failed"
                    | "started"
                    | "input-streaming"
                    | "input-ready"
                    | "approval-required"
                    | "denied";
                  readonly partId: string;
                  readonly toolCallId: string;
                  readonly toolId: string;
                  readonly inputText?: string;
                  readonly input?: unknown;
                  readonly output?: unknown;
                  readonly value?: unknown;
                }
              | {
                  readonly partId: string;
                  readonly kind: "progress";
                  readonly value: unknown;
                  readonly scope: "run";
                }
              | {
                  readonly partId: string;
                  readonly kind: "progress";
                  readonly value: unknown;
                  readonly scope: "tool";
                  readonly toolCallId: string;
                  readonly toolId: string;
                }
            >;
            readonly messageId: string;
            readonly runId?: string;
          }>;
        };
      };
    };
  };
  readonly createReceipts: {
    readonly [x: string]: { readonly digest: string; readonly threadId: string };
  };
  readonly runReceipts: {
    readonly [x: string]: {
      readonly semanticDigest: string;
      readonly expiresAt: string;
      readonly value:
        | {
            readonly operationId: OperationId;
            readonly threadId: string;
            readonly runId: string;
            readonly status: "accepted";
            readonly duplicate: boolean;
          }
        | {
            readonly operationId: OperationId;
            readonly threadId: string;
            readonly runId: string;
            readonly status: "succeeded" | "failed" | "cancelled";
            readonly checkpoint: {
              readonly applicationId: string;
              readonly environment: string;
              readonly profile: string;
              readonly providerEpoch: string;
              readonly threadId: string;
              readonly sequence: string;
            };
            readonly duplicate: boolean;
          };
    };
  };
  readonly controlReceipts: {
    readonly [x: string]: {
      readonly semanticDigest: string;
      readonly expiresAt: string;
      readonly value: {
        readonly operationId: OperationId;
        readonly threadId: string;
        readonly runId: string;
        readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
        readonly effect: "not-started" | "confirmed" | "unknown";
        readonly duplicate: boolean;
      };
    };
  };
  readonly continuationReceipts: {
    readonly [x: string]: {
      readonly semanticDigest: string;
      readonly expiresAt: string;
      readonly value: {
        readonly threadId: string;
        readonly runId: string;
        readonly operationId: OperationId;
        readonly interruptSetDigest: string;
        readonly duplicate: boolean;
        readonly interruptedRunId: string;
        readonly waitingRevision?: string;
      };
    };
  };
};

Source

LocalAgentThread

Signature

declare const LocalAgentThread: {
  readonly thread: {
    readonly threadId: string;
    readonly agentId: string;
    readonly ownerScope: string;
    readonly status:
      "idle" | "running" | "waiting" | "approval-interrupted" | "stopping" | "worker-interrupted";
    readonly revision: string;
    readonly createdAt: string;
    readonly updatedAt: string;
  };
  readonly runs: {
    readonly [x: string]: {
      readonly status:
        | "running"
        | "waiting"
        | "approval-interrupted"
        | "stopping"
        | "worker-interrupted"
        | "accepted"
        | "succeeded"
        | "failed"
        | "cancelled";
      readonly threadId: string;
      readonly runId: string;
      readonly owner: {
        readonly generationId: string;
        readonly publicFingerprint: string;
        readonly protocolVersion: number;
        readonly schemaVersion: number;
        readonly providerScope: string;
      };
      readonly operationId: OperationId;
      readonly inputDigest: string;
      readonly acceptedAt: string;
      readonly maxJournalBytes: number;
      readonly maxJournalRecordBytes: number;
      readonly terminalReserveBytes: number;
      readonly settledAt?: string;
      readonly outcome?: "worker-interrupted" | "succeeded" | "failed" | "cancelled";
    };
  };
  readonly messages: ReadonlyArray<{
    readonly createdAt: string;
    readonly role: "user" | "assistant" | "tool";
    readonly parts: ReadonlyArray<
      | {
          readonly kind: "text";
          readonly text: string;
          readonly partId: string;
          readonly state?: "streaming" | "complete";
        }
      | {
          readonly kind: "tool";
          readonly state:
            | "running"
            | "succeeded"
            | "failed"
            | "started"
            | "input-streaming"
            | "input-ready"
            | "approval-required"
            | "denied";
          readonly partId: string;
          readonly toolCallId: string;
          readonly toolId: string;
          readonly inputText?: string;
          readonly input?: unknown;
          readonly output?: unknown;
          readonly value?: unknown;
        }
      | {
          readonly partId: string;
          readonly kind: "progress";
          readonly value: unknown;
          readonly scope: "run";
        }
      | {
          readonly partId: string;
          readonly kind: "progress";
          readonly value: unknown;
          readonly scope: "tool";
          readonly toolCallId: string;
          readonly toolId: string;
        }
    >;
    readonly messageId: string;
    readonly runId?: string;
  }>;
  readonly approvals: ReadonlyArray<{
    readonly status: "cancelled" | "denied" | "open" | "approved";
    readonly runId: string;
    readonly approvalId: string;
    readonly interruptSetDigest: string;
    readonly publicRequest: unknown;
    readonly interruptSetSize?: number;
  }>;
  readonly journal: ReadonlyArray<{
    readonly recordId: string;
    readonly runId: string;
    readonly kind:
      "progress" | "message" | "approval" | "control" | "terminal" | "interruption" | "event";
    readonly publicValue: unknown;
    readonly checkpoint: {
      readonly applicationId: string;
      readonly environment: string;
      readonly profile: string;
      readonly providerEpoch: string;
      readonly threadId: string;
      readonly sequence: string;
    };
    readonly encodedBytes: number;
    readonly createdAt: string;
  }>;
  readonly sequence: number;
  readonly controls: {
    readonly [x: string]: {
      readonly sequence: number;
      readonly record: {
        readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
        readonly runId: string;
        readonly acceptedAt: string;
        readonly kind: "steer" | "follow-up" | "stop" | "approve";
        readonly controlId: OperationId;
        readonly semanticDigest: string;
        readonly effect: "not-started" | "confirmed" | "unknown";
        readonly settledAt?: string;
        readonly publicPayload?: unknown;
      };
      readonly publicPayload: unknown;
      readonly semanticDigest: string;
      readonly receipt: {
        readonly operationId: OperationId;
        readonly threadId: string;
        readonly runId: string;
        readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
        readonly effect: "not-started" | "confirmed" | "unknown";
        readonly duplicate: boolean;
      };
      readonly expiresAt: string;
      readonly downstreamOperationId?: string;
    };
  };
  readonly runClaims: {
    readonly [x: string]: {
      readonly runId: string;
      readonly claimId: string;
      readonly workerId: string;
      readonly generationId: string;
      readonly fence: number;
      readonly expiresAt: string;
    };
  };
  readonly controlClaims: {
    readonly [x: string]: {
      readonly controlId: OperationId;
      readonly claimId: string;
      readonly workerId: string;
      readonly generationId: string;
      readonly fence: number;
      readonly expiresAt: string;
    };
  };
  readonly scopeKey: string;
  readonly controlSequence: number;
  readonly nextFence: number;
  readonly waiting?: {
    readonly revision: string;
    readonly runId: string;
    readonly response: Json;
    readonly requests: ReadonlyArray<{
      readonly node: string;
      readonly response: Json;
      readonly value?: unknown;
    }>;
  };
  readonly activeRunId?: string;
  readonly snapshots?: {
    readonly [x: string]: {
      readonly createdAt: string;
      readonly messages: ReadonlyArray<{
        readonly createdAt: string;
        readonly role: "user" | "assistant" | "tool";
        readonly parts: ReadonlyArray<
          | {
              readonly kind: "text";
              readonly text: string;
              readonly partId: string;
              readonly state?: "streaming" | "complete";
            }
          | {
              readonly kind: "tool";
              readonly state:
                | "running"
                | "succeeded"
                | "failed"
                | "started"
                | "input-streaming"
                | "input-ready"
                | "approval-required"
                | "denied";
              readonly partId: string;
              readonly toolCallId: string;
              readonly toolId: string;
              readonly inputText?: string;
              readonly input?: unknown;
              readonly output?: unknown;
              readonly value?: unknown;
            }
          | {
              readonly partId: string;
              readonly kind: "progress";
              readonly value: unknown;
              readonly scope: "run";
            }
          | {
              readonly partId: string;
              readonly kind: "progress";
              readonly value: unknown;
              readonly scope: "tool";
              readonly toolCallId: string;
              readonly toolId: string;
            }
        >;
        readonly messageId: string;
        readonly runId?: string;
      }>;
    };
  };
};

Source

LocalControl

Signature

declare const LocalControl: {
  readonly sequence: number;
  readonly record: {
    readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
    readonly runId: string;
    readonly acceptedAt: string;
    readonly kind: "steer" | "follow-up" | "stop" | "approve";
    readonly controlId: OperationId;
    readonly semanticDigest: string;
    readonly effect: "not-started" | "confirmed" | "unknown";
    readonly settledAt?: string;
    readonly publicPayload?: unknown;
  };
  readonly publicPayload: unknown;
  readonly semanticDigest: string;
  readonly receipt: {
    readonly operationId: OperationId;
    readonly threadId: string;
    readonly runId: string;
    readonly status: "accepted" | "cancelled" | "processing" | "applied" | "rejected";
    readonly effect: "not-started" | "confirmed" | "unknown";
    readonly duplicate: boolean;
  };
  readonly expiresAt: string;
  readonly downstreamOperationId?: string;
};

Source

LocalPinnedSnapshot

Signature

declare const LocalPinnedSnapshot: {
  readonly createdAt: string;
  readonly messages: ReadonlyArray<{
    readonly createdAt: string;
    readonly role: "user" | "assistant" | "tool";
    readonly parts: ReadonlyArray<
      | {
          readonly kind: "text";
          readonly text: string;
          readonly partId: string;
          readonly state?: "streaming" | "complete";
        }
      | {
          readonly kind: "tool";
          readonly state:
            | "running"
            | "succeeded"
            | "failed"
            | "started"
            | "input-streaming"
            | "input-ready"
            | "approval-required"
            | "denied";
          readonly partId: string;
          readonly toolCallId: string;
          readonly toolId: string;
          readonly inputText?: string;
          readonly input?: unknown;
          readonly output?: unknown;
          readonly value?: unknown;
        }
      | {
          readonly partId: string;
          readonly kind: "progress";
          readonly value: unknown;
          readonly scope: "run";
        }
      | {
          readonly partId: string;
          readonly kind: "progress";
          readonly value: unknown;
          readonly scope: "tool";
          readonly toolCallId: string;
          readonly toolId: string;
        }
    >;
    readonly messageId: string;
    readonly runId?: string;
  }>;
};

Source

LocalStoredRun

Signature

declare const LocalStoredRun: {
  readonly status:
    | "running"
    | "waiting"
    | "approval-interrupted"
    | "stopping"
    | "worker-interrupted"
    | "accepted"
    | "succeeded"
    | "failed"
    | "cancelled";
  readonly threadId: string;
  readonly runId: string;
  readonly owner: {
    readonly generationId: string;
    readonly publicFingerprint: string;
    readonly protocolVersion: number;
    readonly schemaVersion: number;
    readonly providerScope: string;
  };
  readonly operationId: OperationId;
  readonly inputDigest: string;
  readonly acceptedAt: string;
  readonly maxJournalBytes: number;
  readonly maxJournalRecordBytes: number;
  readonly terminalReserveBytes: number;
  readonly settledAt?: string;
  readonly outcome?: "worker-interrupted" | "succeeded" | "failed" | "cancelled";
};

Source

StoredReceipt

Signature

declare const StoredReceipt: StoredReceipt<Value>;

Source

emptyAgentState

Creates format-v1 state with a fresh provider epoch and empty domain indexes.

Signature

declare const emptyAgentState: () => LocalAgentState;

Source

state.types.ts

LocalAgentState (type alias)

Complete validated version-one agent-state snapshot.

Signature

type LocalAgentState = typeof AgentState.Type;

Source

LocalAgentThread (type alias)

Thread, runs, controls and retained content decoded before transitions.

Signature

type LocalAgentThread = typeof AgentThread.Type;

Source

LocalControl (type alias)

Control record with its receipt and downstream identity.

Signature

type LocalControl = typeof AgentControl.Type;

Source

LocalPinnedSnapshot (type alias)

Immutable pinned message view retained for paginated history.

Signature

type LocalPinnedSnapshot = typeof PinnedSnapshot.Type;

Source

LocalStoredRun (type alias)

Run metadata and journal limits decoded together.

Signature

type LocalStoredRun = typeof AgentRun.Type;

Source

StoredReceipt (interface)

Generic idempotency envelope used when selecting retained receipts.

Signature

export interface StoredReceipt<Value> {
  readonly semanticDigest: string;
  readonly expiresAt: string;
  readonly value: Value;
}

Source

storage.types.ts

AgentStateStore (interface)

Promise storage seam retained for existing provider adapters and fault injection.

Signature

export interface AgentStateStore {
  read(): Promise<LocalAgentState>;
  update<Value>(
    change: (state: LocalAgentState) => readonly [LocalAgentState, Value],
  ): Promise<Value>;
}

Source

AgentStateStoreEffects (type alias)

Effect storage contract used by agent-state operations.

Signature

type AgentStateStoreEffects = LocalStateStore<LocalAgentState>;

Source

buckets.types.ts

LocalBucketListOptions (interface)

Optional cursor and bounded page size for lexical key listing.

Signature

export interface LocalBucketListOptions {
  readonly cursor?: string;
  readonly limit?: number;
}

Source

LocalBucketListPage (interface)

Immutable bucket key page with continuation metadata.

Signature

export interface LocalBucketListPage {
  readonly items: readonly string[];
  readonly nextCursor?: string;
}

Source

LocalBucketObjectMetadata (interface)

Verified content identity, size and optional application metadata.

Signature

export interface LocalBucketObjectMetadata extends BucketObjectMetadata {
  readonly contentHash: string;
}

Source

LocalBucketPolicy (interface)

Size, content-type and metadata limits enforced before bucket writes.

Signature

export interface LocalBucketPolicy {
  readonly maxObjectBytes?: number;
  readonly allowedContentTypes?: readonly string[];
}

Source

LocalBucketProvider (type alias)

Public Promise bucket contract plus local inspection and lifecycle operations.

Signature

type LocalBucketProvider = Omit<BucketProvider, "list"> & {
  readonly capabilities: Readonly<BucketCapabilities>;
  readonly root: string;
  readonly policy: Readonly<LocalBucketPolicy>;
  readonly list: {
    (prefix?: string): Promise<readonly string[]>;
    (prefix: string | undefined, options: LocalBucketListOptions): Promise<LocalBucketListPage>;
  };
  readonly listPage: (
    prefix?: string,
    options?: LocalBucketListOptions,
  ) => Promise<LocalBucketListPage>;
  readonly ready: () => Promise<void>;
  readonly close: () => Promise<void>;
  readonly inspector: {
    readonly list: (request: {
      readonly prefix?: string;
      readonly cursor?: string;
      readonly limit: number;
      readonly signal: AbortSignal;
    }) => Promise<{
      readonly items: readonly { readonly key: string; readonly metadata?: BucketObjectMetadata }[];
      readonly nextCursor?: string;
    }>;
    readonly preview: (request: {
      readonly key: string;
      readonly offset: number;
      readonly limit: number;
      readonly signal: AbortSignal;
    }) => Promise<
      | {
          readonly bytes: Uint8Array;
          readonly metadata: BucketObjectMetadata;
          readonly totalBytes: number;
        }
      | undefined
    >;
  };
};

Source

LocalBucketProviderOptions (interface)

Owned root, object policy and default pagination settings for a local bucket.

Signature

export interface LocalBucketProviderOptions extends LocalBucketPolicy {
  readonly root?: string;
  readonly stateRoot?: string;
  readonly policy?: LocalBucketPolicy;
  readonly pageSize?: number;
}

Source

LocalBucketUnsupportedCapability (type alias)

Bucket capability that the filesystem implementation explicitly does not provide.

Signature

type LocalBucketUnsupportedCapability = {
  readonly capability: BucketCapability;
  readonly operation: BucketOperation;
};

Source

StoredLocalBucketObject (type alias)

Versioned object envelope storing verified bytes as base64.

Signature

type StoredLocalBucketObject = typeof StoredBucketObject.Type;

Source

keys.ts

assertContainedPath

Rejects a resolved path that escapes the owned root.

Signature

declare const assertContainedPath: (root: string, candidate: string) => void;

Source

encodeBucketKey

Encodes a normalized key into a filesystem-safe object identity.

Signature

declare const encodeBucketKey: (key: string) => string;

Source

normalizeBucketKey

Validates an object key without normalizing away an attempted escape.

Signature

declare const normalizeBucketKey: (value: unknown) => string;

Source

normalizeBucketPrefix

Validates a list prefix while allowing the conventional trailing slash.

Signature

declare const normalizeBucketPrefix: (value: unknown) => string;

Source

pagination.ts

DEFAULT_BUCKET_PAGE_SIZE

Signature

declare const DEFAULT_BUCKET_PAGE_SIZE: 100;

Source

MAX_BUCKET_PAGE_SIZE

Signature

declare const MAX_BUCKET_PAGE_SIZE: 1000;

Source

paginateKeys

Returns a stable page of sorted keys using a prefix-bound cursor.

Signature

declare const paginateKeys: (
  keys: readonly string[],
  prefix: string,
  options: LocalBucketListOptions | undefined,
) => LocalBucketListPage;

Source

provider.ts

LocalBucketService (class)

Owns bucket admission, object IO and ordered inspection.

Signature

declare class LocalBucketService

Source

createLocalBucketProvider

Creates a filesystem bucket with the established Promise and overload contracts.

Signature

declare const createLocalBucketProvider: (
  optionsOrRoot: LocalBucketProviderOptions | string,
  policy?: LocalBucketPolicy,
) => LocalBucketProvider;

Source

createLocalBucketProviderForTest

The same constructor is deterministic when supplied an isolated temporary root.

Signature

declare const createLocalBucketProviderForTest: (
  optionsOrRoot: LocalBucketProviderOptions | string,
  policy?: LocalBucketPolicy,
) => LocalBucketProvider;

Source

localBucketLayer

Provides a bucket service and closes its admission gate with the scope.

Example

import { Effect } from "effect";
import { LocalBucketService, localBucketLayer } from "./provider.js";

const program = Effect.gen(function* () {
  const bucket = yield* LocalBucketService;
  yield* bucket.put("hello.txt", new TextEncoder().encode("hello"));
  return yield* bucket.head("hello.txt");
});
await Effect.runPromise(
  program.pipe(Effect.provide(localBucketLayer({ root: "/tmp/example-bucket" }))),
);

Signature

declare const localBucketLayer: (
  options: LocalBucketProviderOptions,
) => Layer.Layer<LocalBucketService, LocalOperationError, never>;

Source

makeLocalBucketService

Validates construction and creates one bucket lifecycle owner.

Signature

declare const makeLocalBucketService: (
  optionsOrRoot: string | LocalBucketProviderOptions,
  policy?: LocalBucketPolicy | undefined,
) => Effect.Effect<LocalBucketEffects, LocalOperationError, never>;

Source

types.ts

LOCAL_BUCKET_CAPABILITIES

Signature

declare const LOCAL_BUCKET_CAPABILITIES: Readonly<BucketCapabilities>;

Source

LOCAL_BUCKET_RESERVED_PREFIXES

Signature

declare const LOCAL_BUCKET_RESERVED_PREFIXES: ReadonlyArray<string>;

Source

LocalBucketKeyError (class)

Preserves the public local bucket key error identity and stable error code.

Signature

declare class LocalBucketKeyError {
  constructor();
}

Source

code (property)

Signature

readonly code: "RELKIT_BUCKET_KEY_INVALID"

Source

LocalBucketListOptions

Signature

declare const LocalBucketListOptions: LocalBucketListOptions;

Source

LocalBucketListPage

Signature

declare const LocalBucketListPage: LocalBucketListPage;

Source

LocalBucketObjectMetadata

Signature

declare const LocalBucketObjectMetadata: LocalBucketObjectMetadata;

Source

LocalBucketPaginationError (class)

Preserves the public local bucket pagination error identity and stable error code.

Signature

declare class LocalBucketPaginationError {
  constructor();
}

Source

code (property)

Signature

readonly code: "RELKIT_BUCKET_CURSOR_INVALID"

Source

LocalBucketPolicy

Signature

declare const LocalBucketPolicy: LocalBucketPolicy;

Source

LocalBucketPolicyError (class)

Preserves the public local bucket policy error identity and stable error code.

Signature

declare class LocalBucketPolicyError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_BUCKET_POLICY_INVALID"

Source

LocalBucketProvider

Signature

declare const LocalBucketProvider: LocalBucketProvider;

Source

LocalBucketProviderOptions

Signature

declare const LocalBucketProviderOptions: LocalBucketProviderOptions;

Source

LocalBucketStateError (class)

Preserves the public local bucket state error identity and stable error code.

Signature

declare class LocalBucketStateError {
  constructor(message = "Bucket state is invalid");
}

Source

code (property)

Signature

readonly code: "RELKIT_BUCKET_STATE_INVALID"

Source

LocalBucketUnsupportedCapability

Signature

declare const LocalBucketUnsupportedCapability: LocalBucketUnsupportedCapability;

Source

StoredLocalBucketObject

Signature

declare const StoredLocalBucketObject: {
  readonly version: 1;
  readonly metadata: { readonly [x: string]: string };
  readonly key: string;
  readonly size: number;
  readonly contentHash: string;
  readonly etag: string;
  readonly data: string;
  readonly contentType?: string;
};

Source

cache.types.ts

LocalCacheCapabilities (interface)

Truthful persistence, atomicity and capacity guarantees for the local cache.

Signature

export interface LocalCacheCapabilities extends CacheCapabilities {
  readonly persistence: "memory-only" | "restart-recovery";
  readonly singleFlight: "generation-local";
}

Source

LocalCacheEvictionPolicy (type alias)

Eviction policy supported by the bounded in-memory cache.

Signature

type LocalCacheEvictionPolicy = "lru";

Source

LocalCachePolicy (interface)

Normalized TTL, encoded-value and total-cache limits.

Signature

export interface LocalCachePolicy {
  readonly defaultTtlMs?: number;
  readonly maxTtlMs?: number;
  readonly maxEntries: number;
  readonly maxBytes: number;
  readonly evictionPolicy: LocalCacheEvictionPolicy;
}

Source

LocalCacheProvider (type alias)

Public cache operations and local lifecycle/inspection surface.

Signature

type LocalCacheProvider = Omit<CacheProvider, "capabilities"> & {
  readonly capabilities: Readonly<LocalCacheCapabilities>;
  readonly cacheId: string;
  readonly schemaVersion: string | number;
  readonly policy: Readonly<LocalCachePolicy>;
  readonly snapshot: () => LocalCacheSnapshot;
  readonly stateRoot?: string;
  readonly ready: () => Promise<void>;
  readonly close: () => Promise<void>;
  readonly get: (key: unknown, context?: CacheOperationContext) => Promise<unknown | undefined>;
  readonly set: (
    key: unknown,
    value: unknown,
    options?: CacheOperationOptions,
    context?: CacheOperationContext,
  ) => Promise<void>;
  readonly delete: (key: unknown, context?: CacheOperationContext) => Promise<void>;
  readonly has: (key: unknown, context?: CacheOperationContext) => Promise<boolean>;
  readonly getOrSet: (
    key: unknown,
    produce: () => unknown | Promise<unknown>,
    options?: CacheOperationOptions,
    context?: CacheOperationContext,
  ) => Promise<unknown>;
  readonly increment: (
    key: unknown,
    delta: number,
    options?: CacheOperationOptions,
    context?: CacheOperationContext,
  ) => Promise<number>;
  readonly inspector: {
    readonly scan: (request: {
      readonly search?: string;
      readonly cursor?: string;
      readonly limit: number;
      readonly signal: AbortSignal;
    }) => Promise<{ readonly items: readonly unknown[]; readonly nextCursor?: string }>;
    readonly value: (request: {
      readonly key: string;
      readonly limit: number;
      readonly signal: AbortSignal;
    }) => Promise<unknown | undefined>;
  };
};

Source

LocalCacheProviderOptions (interface)

Cache bounds, persistence, clock and safe observation hooks.

Signature

export interface LocalCacheProviderOptions {
  /** Provider-owned profile directory; enables atomic restart snapshots. */
  readonly stateRoot?: string;
  readonly cacheId?: string;
  readonly schemaVersion?: string | number;
  readonly defaultTtlMs?: number;
  readonly maxTtlMs?: number;
  readonly maxEntries?: number;
  readonly maxBytes?: number;
  readonly evictionPolicy?: LocalCacheEvictionPolicy;
  /** Injectable clock used for TTL and deadline checks. */
  readonly clock?: () => number;
  /** Alias for clock, kept for small deterministic test seams. */
  readonly now?: () => number;
  /** Receives safe counters only; keys and values are never included. */
  readonly onSnapshot?: (snapshot: LocalCacheSnapshot) => void;
}

Source

LocalCacheSnapshot (interface)

Safe cache counters and effective policy without keys or values.

Signature

export interface LocalCacheSnapshot {
  readonly version: 1;
  readonly cacheId: string;
  readonly schemaVersion: string | number;
  readonly entries: number;
  readonly bytes: number;
  readonly evictions: number;
  readonly hits: number;
  readonly misses: number;
  readonly inFlight: number;
}

Source

inspector.ts

createLocalCacheInspector

Projects bounded cache metadata and previews from the same byte-LRU store.

Signature

declare const createLocalCacheInspector: (
  store: LocalCacheStore,
  clock: () => number,
) => LocalCacheProvider["inspector"];

Source

keys.ts

createLocalCacheKey

Builds a deterministic namespace key without exposing the raw key to logs.

Signature

declare const createLocalCacheKey: (
  cacheId: string,
  schemaVersion: string | number,
  key: unknown,
) => string;

Source

normalizeCacheId

Validates the namespace used to isolate canonical cache keys.

Signature

declare const normalizeCacheId: (value: unknown) => string;

Source

normalizeSchemaVersion

Validates the cache schema namespace without changing its public representation.

Signature

declare const normalizeSchemaVersion: (value: unknown) => string | number;

Source

serializeLocalCacheValue

Serializes supported JSON values for byte accounting and cloning.

Signature

declare const serializeLocalCacheValue: (value: unknown) => string;

Source

policy.ts

assertActive

Rejects an aborted or expired operation before cache or bucket IO.

Signature

declare const assertActive: (
  context: CacheOperationContext | undefined,
  clock: () => number,
) => number;

Source

byteLength

Measures UTF-8 bytes for cache key and value capacity accounting.

Signature

declare const byteLength: (value: string) => number;

Source

clone

Copies cache values through their supported JSON representation.

Signature

declare const clone: (value: unknown) => unknown;

Source

normalizePolicy

Validates provider limits and normalizes effective policy defaults.

Signature

declare const normalizePolicy: (options: LocalCacheProviderOptions) => LocalCachePolicy;

Source

normalizeTtl

Resolves entry TTL against defaults and the maximum allowed lifetime.

Signature

declare const normalizeTtl: (value: unknown, policy: LocalCachePolicy) => number | undefined;

Source

readClock

Checks that the injected clock returns a usable finite timestamp.

Signature

declare const readClock: (clock: () => number) => number;

Source

provider.ts

LocalCacheService (class)

Cache state, producer admission and durable writes share one owner.

Signature

declare class LocalCacheService

Source

createLocalCacheProvider

Creates the existing Promise cache API over an Effect service.

Signature

declare const createLocalCacheProvider: (options?: LocalCacheProviderOptions) => LocalCacheProvider;

Source

localCacheLayer

Provides a cache and commits its final snapshot at scope exit.

Example

import { Effect } from "effect";
import { LocalCacheService, localCacheLayer } from "./provider.js";

const program = Effect.gen(function* () {
  const cache = yield* LocalCacheService;
  yield* cache.set("answer", 42);
  return yield* cache.get("answer");
});
await Effect.runPromise(program.pipe(Effect.provide(localCacheLayer())));

Signature

declare const localCacheLayer: (
  options?: LocalCacheProviderOptions,
) => Layer.Layer<LocalCacheService, LocalOperationError, never>;

Source

makeLocalCacheService

Acquires the cache’s indexes, serialization permit and producer coordination.

Signature

declare const makeLocalCacheService: (
  options?: LocalCacheProviderOptions,
) => Effect.Effect<LocalCacheEffects, LocalOperationError>;

Source

store.ts

LocalCacheRead

Signature

declare const LocalCacheRead: LocalCacheRead;

Source

LocalCacheStore (class)

Pure byte-bounded LRU state owned by LocalCacheService; callers supply clock values.

Signature

declare class LocalCacheStore { constructor(private readonly policy: LocalCachePolicy) }

Source

read (method)

Reads an entry, expires stale values, and updates recency and hit/miss counters.

Signature

declare const read: (key: string, now: number) => LocalCacheRead;

Source

write (method)

Replaces an entry and evicts least-recently-used values until both bounds hold.

Signature

declare const write: (
  key: string,
  value: unknown,
  bytes: number,
  expiresAt: number | undefined,
) => void;

Source

remove (method)

Removes one entry and adjusts encoded byte accounting; reports whether it existed.

Signature

declare const remove: (key: string) => boolean;

Source

purgeExpired (method)

Removes every expired entry without changing hit/miss counters.

Signature

declare const purgeExpired: (now: number) => void;

Source

snapshot (method)

Copies safe counters without exposing cached values or keys.

Signature

declare const snapshot: () => LocalCacheStoreSnapshot;

Source

exportState (method)

Copies all entries and recency counters for the owning service’s durable snapshot.

Signature

declare const exportState: () => LocalCacheStoreState;

Source

restore (method)

Validates snapshot entries, rebuilds accounting, and reapplies current policy limits.

Signature

declare const restore: (state: LocalCacheStoreState) => void;

Source

clear (method)

Releases all cached entries while preserving historical counters.

Signature

declare const clear: () => void;

Source

evict (method)

Evicts by recency using a bounded linear scan of the in-memory entries.

Signature

declare const evict: () => void;

Source

LocalCacheStoreEntry

Signature

declare const LocalCacheStoreEntry: LocalCacheStoreEntry;

Source

LocalCacheStoreSnapshot

Signature

declare const LocalCacheStoreSnapshot: LocalCacheStoreSnapshot;

Source

LocalCacheStoreState

Signature

declare const LocalCacheStoreState: LocalCacheStoreState;

Source

MISSING

Signature

declare const MISSING: unique symbol;

Source

store.types.ts

Entry (interface)

Mutable LRU entry with encoded-byte accounting and recency sequence.

Signature

export interface Entry {
  readonly key: string;
  readonly value: unknown;
  readonly bytes: number;
  readonly expiresAt?: number;
  lastUsed: number;
}

Source

LocalCacheRead (interface)

Cache read result distinguishing absence from an expired value.

Signature

export interface LocalCacheRead {
  readonly value: unknown | typeof MISSING;
  readonly expired: boolean;
}

Source

LocalCacheStoreEntry (interface)

Serializable cache entry including expiration and recency metadata.

Signature

export interface LocalCacheStoreEntry {
  readonly key: string;
  readonly value: unknown;
  readonly bytes: number;
  readonly expiresAt?: number;
  readonly lastUsed: number;
}

Source

LocalCacheStoreSnapshot (interface)

Safe counters maintained by the pure LRU state.

Signature

export interface LocalCacheStoreSnapshot {
  readonly entries: number;
  readonly bytes: number;
  readonly evictions: number;
  readonly hits: number;
  readonly misses: number;
}

Source

LocalCacheStoreState (interface)

Complete cache snapshot used to restore counters and LRU ordering.

Signature

export interface LocalCacheStoreState extends Omit<LocalCacheStoreSnapshot, "entries"> {
  readonly sequence: number;
  readonly entries: readonly LocalCacheStoreEntry[];
}

Source

types.ts

LOCAL_CACHE_CAPABILITIES

Signature

declare const LOCAL_CACHE_CAPABILITIES: Readonly<{
  readonly increment: true;
  readonly persistence: "memory-only";
  readonly singleFlight: "generation-local";
}>;

Source

LOCAL_CACHE_DURABLE_CAPABILITIES

Signature

declare const LOCAL_CACHE_DURABLE_CAPABILITIES: Readonly<{
  readonly increment: true;
  readonly persistence: "restart-recovery";
  readonly singleFlight: "generation-local";
}>;

Source

LocalCacheCapabilities

Signature

declare const LocalCacheCapabilities: LocalCacheCapabilities;

Source

LocalCacheEvictionPolicy

Signature

declare const LocalCacheEvictionPolicy: "lru";

Source

LocalCacheKeyError (class)

Preserves the public local cache key error identity and stable error code.

Signature

declare class LocalCacheKeyError {
  constructor();
}

Source

code (property)

Signature

readonly code: "RELKIT_CACHE_KEY_INVALID"

Source

LocalCachePolicy

Signature

declare const LocalCachePolicy: LocalCachePolicy;

Source

LocalCachePolicyError (class)

Preserves the public local cache policy error identity and stable error code.

Signature

declare class LocalCachePolicyError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_CACHE_POLICY_INVALID"

Source

LocalCacheProvider

Signature

declare const LocalCacheProvider: LocalCacheProvider;

Source

LocalCacheProviderOptions

Signature

declare const LocalCacheProviderOptions: LocalCacheProviderOptions;

Source

LocalCacheSnapshot

Signature

declare const LocalCacheSnapshot: LocalCacheSnapshot;

Source

LocalCacheStateError (class)

Preserves the public local cache state error identity and stable error code.

Signature

declare class LocalCacheStateError {
  constructor(message = "Cache provider state is invalid");
}

Source

code (property)

Signature

readonly code: "RELKIT_CACHE_STATE_INVALID"

Source

LocalCacheValueError (class)

Preserves the public local cache value error identity and stable error code.

Signature

declare class LocalCacheValueError {
  constructor();
}

Source

code (property)

Signature

readonly code: "RELKIT_CACHE_VALUE_INVALID"

Source

admin-contracts.ts

EVENT_ADMIN_PROTOCOL

Signature

declare const EVENT_ADMIN_PROTOCOL: "relkit.events.admin";

Source

EVENT_ADMIN_VERSION

Signature

declare const EVENT_ADMIN_VERSION: 1;

Source

EventAdminAction

Signature

declare const EventAdminAction: "retry";

Source

EventAdminActionContract

Signature

declare const EventAdminActionContract: EventAdminActionContract;

Source

EventAdminActionOutcome

Signature

declare const EventAdminActionOutcome: EventAdminActionOutcome;

Source

EventAdminActionRecord

Signature

declare const EventAdminActionRecord: EventAdminActionRecord;

Source

EventAdminActionRequest

Signature

declare const EventAdminActionRequest: EventAdminActionRequest;

Source

EventAdminActionSink

Signature

declare const EventAdminActionSink: EventAdminActionSink;

Source

EventAdminMode

Signature

declare const EventAdminMode: EventAdminMode;

Source

EventAdminVersion

Signature

declare const EventAdminVersion: EventAdminVersion;

Source

EventContract

Signature

declare const EventContract: EventContract;

Source

EventContractInput

Signature

declare const EventContractInput: EventContractInput;

Source

EventDeadLetterContract

Signature

declare const EventDeadLetterContract: EventDeadLetterContract;

Source

EventDeliveryContract

Signature

declare const EventDeliveryContract: EventDeliveryContract;

Source

EventPublicationContract

Signature

declare const EventPublicationContract: EventPublicationContract;

Source

EventQueryContract

Signature

declare const EventQueryContract: EventQueryContract;

Source

EventQueryRequest

Signature

declare const EventQueryRequest: EventQueryRequest;

Source

EventRetryRequest

Signature

declare const EventRetryRequest: EventAdminActionRequest;

Source

EventTriggerCapabilityContract

Signature

declare const EventTriggerCapabilityContract: EventTriggerCapabilityContract;

Source

EventTriggerContract

Signature

declare const EventTriggerContract: EventTriggerContract;

Source

EventVersioned

Signature

declare const EventVersioned: EventVersioned;

Source

admin-contracts.types.ts

EventAdminAction (type alias)

Supported audited event administration action.

Signature

type EventAdminAction = "retry";

Source

EventAdminActionContract (interface)

Versioned mutation response containing status and audit record.

Signature

export interface EventAdminActionContract extends EventAdminVersion {
  readonly action: EventAdminAction;
  readonly status: EventDeliveryContract;
  readonly record: EventAdminActionRecord;
}

Source

EventAdminActionOutcome (type alias)

Whether an event administration action was applied or rejected.

Signature

type EventAdminActionOutcome = "applied" | "rejected";

Source

EventAdminActionRecord (interface)

Immutable audit record for an applied or rejected event mutation.

Signature

export interface EventAdminActionRecord extends EventAdminVersion {
  readonly actionId: string;
  readonly action: EventAdminAction;
  readonly deliveryId: string;
  readonly eventInstanceId?: string;
  readonly triggerId?: string;
  readonly mode: EventAdminMode;
  readonly outcome: EventAdminActionOutcome;
  readonly requestedAt: number;
  readonly fromState?: Exclude<JobQueueState, "accepted">;
  readonly toState?: Exclude<JobQueueState, "accepted">;
  readonly errorCode?: string;
  readonly reason?: string;
}

Source

EventAdminActionRequest (interface)

Event mutation request carrying delivery identity and optional audit reason.

Signature

export interface EventAdminActionRequest {
  readonly protocol?: typeof EVENT_ADMIN_PROTOCOL;
  readonly version?: typeof EVENT_ADMIN_VERSION;
  readonly deliveryId: string;
  readonly reason?: string;
}

Source

EventAdminActionSink (type alias)

Optional audit sink isolated from the event action outcome.

Signature

type EventAdminActionSink = (record: EventAdminActionRecord) => MaybePromise<void>;

Source

EventAdminMode (type alias)

Environment mode controlling event administration mutations.

Signature

type EventAdminMode = "development" | "test" | "production";

Source

EventAdminVersion (interface)

Protocol identity carried by event administration contracts.

Signature

export interface EventAdminVersion {
  readonly protocol: typeof EVENT_ADMIN_PROTOCOL;
  readonly version: typeof EVENT_ADMIN_VERSION;
}

Source

EventContract (interface)

Versioned declared event identity and schema metadata for inspection.

Signature

export interface EventContract extends EventVersioned, EventContractInput {}

Source

EventContractInput (interface)

The serializable event contract registered by the active graph.

Signature

export interface EventContractInput {
  readonly id: string;
  readonly version: number;
  readonly input: JsonValue;
  readonly sensitiveFields?: readonly string[];
  readonly source?: JsonValue;
}

Source

EventDeadLetterContract (interface)

Versioned dead-letter status with safe retry/failure metadata.

Signature

export interface EventDeadLetterContract extends EventDeliveryContract {
  readonly state: "dead-lettered";
  readonly failure: JobFailureMetadata;
}

Source

EventDeliveryContract (interface)

Safe delivery state shared by current and dead-lettered attempts.

Signature

export interface EventDeliveryContract extends EventVersioned {
  readonly cursor: number;
  readonly sequence: number;
  readonly deliveryId: string;
  readonly eventInstanceId: string;
  readonly eventId: string;
  readonly version: number;
  readonly triggerId: string;
  readonly state: Exclude<JobQueueState, "accepted">;
  readonly attempt: number;
  readonly duplicate: boolean;
  readonly timestamp: number;
  readonly leaseExpiresAt?: number;
  readonly failure?: JobFailureMetadata;
}

Source

EventPublicationContract (interface)

Safe publication metadata; payload data is intentionally not projected.

Signature

export interface EventPublicationContract extends EventVersioned {
  readonly sequence: number;
  readonly timestamp: number;
  readonly accepted: true;
  readonly instanceId: string;
  readonly eventId: string;
  readonly version: number;
  readonly occurredAt: string;
  readonly publishedAt: string;
  readonly key?: string;
  readonly correlationId?: string;
  readonly originRequestId?: string;
  readonly producerTraceId?: string;
  readonly attributes: Readonly<Record<string, string | number | boolean>>;
}

Source

EventQueryContract (interface)

Versioned bounded event, publication and delivery inspection response.

Signature

export interface EventQueryContract extends EventAdminVersion {
  readonly events: readonly EventContract[];
  readonly triggers: readonly EventTriggerContract[];
  readonly capabilities: readonly EventTriggerCapabilityContract[];
  readonly publications: readonly EventPublicationContract[];
  readonly items: readonly EventDeliveryContract[];
  readonly deliveries: readonly EventDeliveryContract[];
  readonly deadLetters: readonly EventDeadLetterContract[];
  readonly nextCursor?: string;
}

Source

EventQueryRequest (interface)

Event, trigger, state and pagination filters for local inspection.

Signature

export interface EventQueryRequest {
  readonly protocol?: typeof EVENT_ADMIN_PROTOCOL;
  readonly version?: typeof EVENT_ADMIN_VERSION;
  readonly eventId?: string;
  readonly eventVersion?: number;
  readonly triggerId?: string;
  readonly state?: Exclude<JobQueueState, "accepted">;
  readonly states?: readonly Exclude<JobQueueState, "accepted">[];
  readonly cursor?: string;
  readonly limit?: number;
}

Source

EventRetryRequest (type alias)

Dead-letter retry request preserving event admin protocol identity.

Signature

type EventRetryRequest = EventAdminActionRequest;

Source

EventTriggerCapabilityContract (interface)

Versioned truthful delivery capabilities for a registered trigger.

Signature

export interface EventTriggerCapabilityContract extends EventAdminVersion {
  readonly triggerId: string;
  readonly delivery: "ephemeral" | "durable";
  readonly persistence: "none" | "restart-recovery";
  readonly restartRecovery: boolean;
  readonly atLeastOnce: boolean;
  readonly exactlyOnce: false;
  readonly ordering: "unsupported";
  readonly orderedByKey: false;
}

Source

EventTriggerContract (interface)

Exact event and delivery metadata for one generated event trigger.

Signature

export interface EventTriggerContract extends EventAdminVersion {
  readonly id: string;
  readonly targetFunctionId?: string;
  readonly eventId: string;
  readonly eventVersion: number;
  readonly delivery: "ephemeral" | "durable";
  readonly profile?: string;
  readonly retry?: RetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
}

Source

EventVersioned (interface)

Protocol identity carried by public event inspection contracts.

Signature

export interface EventVersioned {
  readonly protocol: typeof EVENT_ADMIN_PROTOCOL;
  readonly protocolVersion: typeof EVENT_ADMIN_VERSION;
}

Source

admin-errors.ts

Preserves the public event admin error identity and stable error code.

EventAdminError (class)

Preserves the public event admin error identity and stable error code.

Signature

declare class EventAdminError { constructor(
    readonly code: string,
    message: string,
  ) }

Source

admin.ts

“./admin-contracts.js” (namespace export)

Re-exports all named exports from the “./admin-contracts.js” module.

Signature

export * from "./admin-contracts.js";

Source

EventAdmin

Signature

declare const EventAdmin: EventAdmin;

Source

EventAdminError

Signature

declare const EventAdminError: typeof EventAdminError;

Source

EventAdminOptions

Signature

declare const EventAdminOptions: EventAdminOptions;

Source

createEventAdmin

Exposes versioned event inspection and an audited local dead-letter retry.

Signature

declare const createEventAdmin: (router: EventRouter, options?: EventAdminOptions) => EventAdmin;

Source

admin.types.ts

EventAdmin (interface)

Versioned event inspection and audited dead-letter retry interface.

Signature

export interface EventAdmin {
  readonly protocol: typeof EVENT_ADMIN_PROTOCOL;
  readonly version: typeof EVENT_ADMIN_VERSION;
  readonly query: (request?: EventQueryRequest) => EventQueryContract;
  readonly retry: (request: string | EventAdminActionRequest) => Promise<EventAdminActionContract>;
  readonly actions: () => readonly EventAdminActionRecord[];
}

Source

EventAdminOptions (interface)

Event administration mode plus isolated audit and clock hooks.

Signature

export interface EventAdminOptions {
  readonly mode?: EventAdminMode;
  readonly environment?: EventAdminMode;
  readonly enabled?: boolean;
  readonly now?: () => number;
  readonly createActionId?: () => string;
  readonly onAction?: EventAdminActionSink;
}

Source

delivery-types.ts

EVENT_DELIVERY_CAPABILITIES

Signature

declare const EVENT_DELIVERY_CAPABILITIES: Readonly<{
  readonly persistence: "restart-recovery";
  readonly restartRecovery: true;
  readonly atLeastOnce: true;
  readonly exactlyOnce: false;
  readonly ordering: "unsupported";
  readonly orderedByKey: false;
}>;

Source

EventDelivery

Signature

declare const EventDelivery: EventDelivery;

Source

EventDeliveryBinding

Signature

declare const EventDeliveryBinding: EventDeliveryBinding;

Source

EventDeliveryBoundary

Signature

declare const EventDeliveryBoundary: EventDeliveryBoundary;

Source

EventDeliveryCapabilities

Signature

declare const EventDeliveryCapabilities: Readonly<{
  readonly persistence: "restart-recovery";
  readonly restartRecovery: true;
  readonly atLeastOnce: true;
  readonly exactlyOnce: false;
  readonly ordering: "unsupported";
  readonly orderedByKey: false;
}>;

Source

EventDeliveryInvocationOptions

Signature

declare const EventDeliveryInvocationOptions: EventDeliveryInvocationOptions;

Source

EventDeliveryLedgerRecord

Signature

declare const EventDeliveryLedgerRecord: EventDeliveryLedgerRecord;

Source

EventDeliveryOptions

Signature

declare const EventDeliveryOptions: EventDeliveryOptions;

Source

EventDeliveryResult

Signature

declare const EventDeliveryResult: EventDeliveryResult;

Source

EventDeliverySnapshot

Signature

declare const EventDeliverySnapshot: EventDeliverySnapshot;

Source

delivery.ts

EVENT_DELIVERY_CAPABILITIES

Signature

declare const EVENT_DELIVERY_CAPABILITIES: Readonly<{
  readonly persistence: "restart-recovery";
  readonly restartRecovery: true;
  readonly atLeastOnce: true;
  readonly exactlyOnce: false;
  readonly ordering: "unsupported";
  readonly orderedByKey: false;
}>;

Source

EventDelivery

Signature

declare const EventDelivery: EventDelivery;

Source

EventDeliveryBinding

Signature

declare const EventDeliveryBinding: EventDeliveryBinding;

Source

EventDeliveryBoundary

Signature

declare const EventDeliveryBoundary: EventDeliveryBoundary;

Source

EventDeliveryLedgerRecord

Signature

declare const EventDeliveryLedgerRecord: EventDeliveryLedgerRecord;

Source

EventDeliveryOptions

Signature

declare const EventDeliveryOptions: EventDeliveryOptions;

Source

EventDeliveryResult

Signature

declare const EventDeliveryResult: EventDeliveryResult;

Source

EventDeliverySnapshot

Signature

declare const EventDeliverySnapshot: EventDeliverySnapshot;

Source

LocalEventDeliveryService (class)

One trigger owns durable admission, retry transitions and handler concurrency.

Signature

declare class LocalEventDeliveryService

Source

createEventDelivery

Opens durable at-least-once delivery behind its existing Promise API.

Signature

declare const createEventDelivery: (
  root: string,
  binding: EventDeliveryBinding,
  options?: EventDeliveryOptions,
) => Promise<EventDelivery>;

Source

eventDeliveryLayer

Provides one trigger’s delivery service with scope-owned shutdown.

Signature

declare const eventDeliveryLayer: (
  root: string,
  binding: EventDeliveryBinding,
  options?: EventDeliveryOptions,
) => Layer.Layer<LocalEventDeliveryService, LocalOperationError, never>;

Source

makeEventDelivery

Recovers a trigger and composes its serialized admission and bounded execution.

Signature

declare const makeEventDelivery: (
  root: string,
  binding: EventDeliveryBinding,
  options?: EventDeliveryOptions | undefined,
) => Effect.Effect<EventDeliveryEffects, LocalOperationError, never>;

Source

delivery.types.ts

EventDelivery (interface)

Compatibility interface for accepting, executing and inspecting durable deliveries.

Signature

export interface EventDelivery {
  readonly triggerId: string;
  readonly capabilities: EventDeliveryCapabilities;
  readonly accept: (envelope: UnknownEventEnvelope) => Promise<EventDeliveryResult>;
  readonly deliver: (envelope: UnknownEventEnvelope) => Promise<EventDeliveryResult>;
  readonly runNext: (deliveryId?: string) => Promise<EventDeliveryResult | undefined>;
  readonly retry: (deliveryId: string) => Promise<EventDeliveryResult>;
  readonly drain: () => Promise<readonly EventDeliveryResult[]>;
  readonly recover: (now?: number) => Promise<readonly EventDeliveryLedgerRecord[]>;
  readonly snapshot: () => EventDeliverySnapshot;
  readonly close: () => Promise<void>;
}

Source

EventDeliveryBinding (interface)

Trigger identity and executable target for a durable delivery owner.

Signature

export interface EventDeliveryBinding {
  readonly id: string;
  readonly invoke: (
    envelope: UnknownEventEnvelope,
    options?: EventDeliveryInvocationOptions,
  ) => Promise<unknown>;
  readonly profile?: string;
  readonly retry?: RetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
}

Source

EventDeliveryBoundary (type alias)

Durable delivery commit milestones exposed to hooks.

Signature

type EventDeliveryBoundary = JobStoreBoundary | "handler-success-before-ack";

Source

EventDeliveryCapabilities (type alias)

Actual durability, restart, overflow and cancellation guarantees.

Signature

type EventDeliveryCapabilities = typeof EVENT_DELIVERY_CAPABILITIES;

Source

EventDeliveryInvocationOptions (interface)

Attempt metadata and cancellation supplied to a delivery target.

Signature

export interface EventDeliveryInvocationOptions {
  readonly attempt: number;
  readonly replayed: boolean;
  readonly timeoutMs?: number;
}

Source

EventDeliveryLedgerRecord (interface)

Persisted delivery envelope joined with its latest queue state.

Signature

export interface EventDeliveryLedgerRecord extends EventDeliveryRecord {
  readonly cursor: number;
  readonly state: EventDeliveryResult["state"];
  readonly attempt: number;
  readonly duplicate: boolean;
  readonly leaseOwner?: string;
  readonly leaseExpiresAt?: number;
  readonly failure?: JobFailureMetadata;
}

Source

EventDeliveryOptions (interface)

Backlog, concurrency, retry and durable-boundary configuration.

Signature

export interface EventDeliveryOptions {
  readonly now?: () => number;
  readonly random?: () => number;
  readonly ownerToken?: string;
  readonly leaseDurationMs?: number;
  readonly retry?: RetryPolicy;
  readonly concurrency?: number;
  readonly onBoundary?: (boundary: EventDeliveryBoundary) => void | Promise<void>;
}

Source

EventDeliveryResult (interface)

Delivery outcome including acceptance and actual persistence guarantees.

Signature

export interface EventDeliveryResult {
  readonly deliveryId: string;
  readonly triggerId: string;
  readonly eventInstanceId: string;
  readonly accepted: boolean;
  readonly persisted: boolean;
  readonly status: "queued" | "completed" | "failed";
  readonly state: "available" | "leased" | "delayed" | "completed" | "dead-lettered";
  readonly attempt: number;
  readonly duplicate: boolean;
  readonly value?: unknown;
  readonly error?: unknown;
  readonly failure?: JobFailureMetadata;
}

Source

EventDeliverySnapshot (interface)

Safe delivery counters and durable ledger inspection.

Signature

export interface EventDeliverySnapshot {
  readonly cursor: number;
  readonly records: readonly EventDeliveryRecord[];
  readonly ledger: readonly EventDeliveryLedgerRecord[];
  readonly counts: JobQueueCounts;
  readonly capabilities: typeof EVENT_DELIVERY_CAPABILITIES;
}

Source

ephemeral.ts

DEFAULT_EPHEMERAL_CAPACITY

Signature

declare const DEFAULT_EPHEMERAL_CAPACITY: 100;

Source

EPHEMERAL_DELIVERY_CAPABILITIES

Signature

declare const EPHEMERAL_DELIVERY_CAPABILITIES: Readonly<{
  readonly persistence: "none";
  readonly restartRecovery: false;
  readonly dropPolicy: "drop-newest";
}>;

Source

EphemeralDelivery

Signature

declare const EphemeralDelivery: EphemeralDelivery;

Source

EphemeralDeliveryEffects

Signature

declare const EphemeralDeliveryEffects: EphemeralDeliveryEffects;

Source

EphemeralDeliveryResult

Signature

declare const EphemeralDeliveryResult: EphemeralDeliveryResult;

Source

EphemeralDeliverySnapshot

Signature

declare const EphemeralDeliverySnapshot: EphemeralDeliverySnapshot;

Source

LocalEphemeralService (class)

Capacity, counters and native handler completion share one service owner.

Signature

declare class LocalEphemeralService

Source

createEphemeralDelivery

Constructs a transient delivery service behind the Promise boundary.

Signature

declare const createEphemeralDelivery: (
  invoke: (envelope: UnknownEventEnvelope) => Promise<unknown>,
  requestedCapacity?: number,
) => EphemeralDelivery;

Source

ephemeralDeliveryLayer

Supplies transient delivery and drains admitted handlers at scope exit.

Signature

declare const ephemeralDeliveryLayer: (
  invoke: (envelope: UnknownEventEnvelope) => Promise<unknown>,
  capacity?: number,
) => Layer.Layer<LocalEphemeralService, LocalOperationError, never>;

Source

makeEphemeralDelivery

Owns bounded admission and safe counters using Ref and Semaphore.

Signature

declare const makeEphemeralDelivery: (
  invoke: (envelope: UnknownEventEnvelope) => Promise<unknown>,
  capacity?: any,
) => Effect.Effect<EphemeralDeliveryEffects, LocalOperationError, never>;

Source

ephemeral.types.ts

EphemeralDelivery (interface)

Public transient delivery interface with explicit drain and synchronous counters.

Signature

export interface EphemeralDelivery {
  readonly deliver: (envelope: UnknownEventEnvelope) => Promise<EphemeralDeliveryResult>;
  readonly drain: () => Promise<void>;
  readonly snapshot: () => EphemeralDeliverySnapshot;
}

Source

EphemeralDeliveryEffects (interface)

Effect contract for bounded transient delivery without a hidden backlog.

Signature

export interface EphemeralDeliveryEffects {
  readonly deliver: (envelope: UnknownEventEnvelope) => Effect.Effect<EphemeralDeliveryResult>;
  readonly drain: () => Effect.Effect<void>;
  readonly snapshot: () => Effect.Effect<EphemeralDeliverySnapshot>;
}

Source

EphemeralDeliveryResult (interface)

Transient handler outcome with explicit nonpersistent capacity guarantees.

Signature

export interface EphemeralDeliveryResult {
  readonly accepted: boolean;
  readonly persisted: false;
  readonly status: "completed" | "failed" | "dropped";
  readonly capacity: number;
  readonly dropPolicy: "drop-newest";
  readonly restartRecovery: false;
  readonly value?: unknown;
  readonly error?: unknown;
  readonly dropReason?: "capacity";
}

Source

EphemeralDeliverySnapshot (interface)

Safe admission, completion, failure and overflow counters.

Signature

export interface EphemeralDeliverySnapshot {
  readonly capacity: number;
  readonly inFlight: number;
  readonly admitted: number;
  readonly completed: number;
  readonly failed: number;
  readonly dropped: number;
  readonly persistence: "none";
  readonly restartRecovery: false;
  readonly dropPolicy: "drop-newest";
}

Source

log.ts

EVENT_LOG_VERSION

Signature

declare const EVENT_LOG_VERSION: 1;

Source

EventLog

Signature

declare const EventLog: EventLog;

Source

EventLogBoundary

Signature

declare const EventLogBoundary: JobStoreBoundary;

Source

EventLogInput

Signature

declare const EventLogInput: EventLogInput;

Source

EventLogOptions

Signature

declare const EventLogOptions: EventLogOptions;

Source

EventLogPaths

Signature

declare const EventLogPaths: JobStorePaths;

Source

EventLogRecord

Signature

declare const EventLogRecord: EventLogRecord;

Source

EventLogSnapshot

Signature

declare const EventLogSnapshot: EventLogSnapshot;

Source

EventLogStateError (class)

Preserves the public event log state error identity and stable error code.

Signature

declare class EventLogStateError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_EVENT_LOG_STATE_INVALID"

Source

createEventLog

Opens the durable accepted-event log and repairs invalid records on startup.

Signature

declare const createEventLog: (
  requestedRoot: string,
  options?: EventLogOptions,
) => Promise<EventLog>;

Source

createEventLogPaths

Builds the stable event journal and metadata paths below the owned root.

Signature

declare const createEventLogPaths: (root: string) => EventLogPaths;

Source

log.types.ts

EventLog (interface)

Promise event log operations and synchronous recovered snapshot.

Signature

export interface EventLog {
  readonly root: string;
  readonly paths: EventLogPaths;
  readonly append: (envelope: EventLogInput) => Promise<EventLogRecord>;
  readonly snapshot: () => EventLogSnapshot;
  readonly close: () => Promise<void>;
}

Source

EventLogBoundary (type alias)

Durable event-log commit milestones exposed to hooks.

Signature

type EventLogBoundary = JobStoreBoundary;

Source

EventLogInput (type alias)

Event envelope input before journal sequence assignment.

Signature

type EventLogInput = UnknownEventEnvelope | EventPublishResult<string, number, unknown>;

Source

EventLogOptions (interface)

Event-log validation and durable commit hook configuration.

Signature

export interface EventLogOptions extends Pick<JobStoreOptions, "now" | "onBoundary"> {}

Source

EventLogPaths (type alias)

Owned paths for durable event records and derived metadata.

Signature

type EventLogPaths = ReturnType<typeof createJobStorePaths>;

Source

EventLogRecord (interface)

Accepted event envelope with its durable journal identity.

Signature

export interface EventLogRecord {
  readonly version: typeof EVENT_LOG_VERSION;
  readonly sequence: number;
  readonly kind: "accepted";
  readonly accepted: true;
  readonly timestamp: number;
  readonly envelope: UnknownEventEnvelope;
}

Source

EventLogSnapshot (interface)

Immutable persisted event records and recovery metadata.

Signature

export interface EventLogSnapshot {
  readonly records: readonly EventLogRecord[];
  readonly index: JobStoreIndex;
  readonly checkpoint: JobStoreCheckpoint;
}

Source

provider.ts

LocalEventEffects

Signature

declare const LocalEventEffects: LocalEventEffects;

Source

LocalEventProvider

Signature

declare const LocalEventProvider: LocalEventProvider;

Source

LocalEventService (class)

Publication and delivery orchestration for one local event provider.

Signature

declare class LocalEventService

Source

createLocalEventProvider

Acquires a scoped event provider behind its established Promise surface.

Signature

declare const createLocalEventProvider: (root: string) => Promise<LocalEventProvider>;

Source

localEventLayer

Supplies publication and its supervised delivery workers as one layer.

Example

import { Effect } from "effect";
import { LocalEventService, localEventLayer } from "./provider.js";

const program = Effect.gen(function* () {
  const events = yield* LocalEventService;
  yield* events.health();
});
await Effect.runPromise(program.pipe(Effect.provide(localEventLayer("/tmp/example-events"))));

Signature

declare const localEventLayer: (
  root: string,
) => Layer.Layer<LocalEventService, LocalOperationError, never>;

Source

makeLocalEventService

Owns log, router, worker fibers and background failure state.

Signature

declare const makeLocalEventService: (
  root: string,
) => Effect.Effect<LocalEventEffects, LocalOperationError, Scope.Scope>;

Source

provider.types.ts

LocalEventEffects (interface)

Effect event methods owned by the provider scope.

Signature

export interface LocalEventEffects {
  readonly query: (
    request?: EventQueryRequest,
  ) => Effect.Effect<EventQueryContract, LocalOperationError>;
  readonly registerContract: (contract: unknown) => Effect.Effect<void, LocalOperationError>;
  readonly registerTrigger: (
    binding: EventRouterTrigger,
  ) => Effect.Effect<void, LocalOperationError>;
  readonly publish: (
    payload: unknown,
    options: EventPublishOptions,
    context: EventOperationContext,
  ) => Effect.Effect<EventProviderResult, LocalOperationError>;
  readonly health: () => Effect.Effect<void, LocalOperationError>;
}

Source

LocalEventProvider (interface)

Public event registration, publication and explicit close operations.

Signature

export interface LocalEventProvider extends EventProvider {
  readonly registerContract: EventRouter["registerContract"];
  readonly registerTrigger: EventRouter["registerTrigger"];
  readonly query: (request?: EventQueryRequest) => Promise<EventQueryContract>;
  readonly close: () => Promise<void>;
}

Source

router-model.types.ts

EventDeliveryResult (interface)

Delivery outcome including acceptance and actual persistence guarantees.

Signature

export interface EventDeliveryResult {
  readonly triggerId: string;
  readonly delivery: "ephemeral" | "durable";
  readonly deliveryId?: string;
  readonly eventInstanceId?: string;
  readonly accepted: boolean;
  readonly persisted: boolean;
  readonly status: "queued" | "completed" | "failed" | "dropped";
  readonly state?: "available" | "leased" | "delayed" | "completed" | "dead-lettered";
  readonly attempt?: number;
  readonly duplicate?: boolean;
  readonly capacity?: number;
  readonly dropPolicy?: "drop-newest";
  readonly restartRecovery?: false;
  readonly dropReason?: "capacity";
  readonly value?: unknown;
  readonly error?: unknown;
  readonly failure?: unknown;
}

Source

EventFanoutResult (interface)

Publication result containing each matching trigger delivery outcome.

Signature

export interface EventFanoutResult {
  readonly event: UnknownEventEnvelope;
  readonly matchedTriggerIds: readonly string[];
  readonly deliveries: readonly EventDeliveryResult[];
}

Source

EventRouter (interface)

Compatibility router interface for registration, fanout, inspection and lifecycle.

Signature

export interface EventRouter {
  readonly root: string;
  readonly registerContract: (contract: unknown) => Promise<void>;
  readonly registerTrigger: (binding: EventRouterTrigger) => Promise<void>;
  readonly route: (
    event: EventRouterInput,
    options?: EventRouterRouteOptions,
  ) => Promise<EventFanoutResult>;
  readonly runNext: (triggerId?: string) => Promise<EventDeliveryResult | undefined>;
  readonly drain: () => Promise<readonly EventDeliveryResult[]>;
  readonly retry: (deliveryId: string) => Promise<EventDeliveryResult>;
  readonly snapshot: () => EventRouterSnapshot;
  readonly close: () => Promise<void>;
}

Source

EventRouterInput (type alias)

Publication input accepted as a log record or event envelope.

Signature

type EventRouterInput = EventLogRecord | EventLogInput;

Source

EventRouterOptions (interface)

Storage and delivery construction settings for the local router.

Signature

export interface EventRouterOptions {
  readonly onBoundary?: (
    boundary: EventDeliveryBoundary,
    triggerId: string,
  ) => void | Promise<void>;
  readonly now?: () => number;
  readonly random?: () => number;
  readonly ownerToken?: string;
  readonly leaseDurationMs?: number;
  readonly ephemeralCapacity?: number;
}

Source

EventRouterRouteOptions (interface)

Fanout options controlling immediate worker execution.

Signature

export interface EventRouterRouteOptions {
  readonly run?: boolean;
}

Source

EventRouterSnapshot (interface)

Immutable contracts, triggers, publications and delivery status inspection.

Signature

export interface EventRouterSnapshot {
  readonly records: readonly EventDeliveryRecord[];
  readonly contracts: readonly EventContractInput[];
  readonly triggers: readonly EventTriggerSnapshot[];
  readonly publications: readonly EventLogRecord[];
  readonly deliveries: readonly EventDeliveryLedgerRecord[];
}

Source

EventRouterTrigger (interface)

Declared trigger identity, event match and executable target binding.

Signature

export interface EventRouterTrigger {
  readonly id: string;
  readonly targetFunctionId?: string;
  readonly eventId: string;
  readonly eventVersion: number;
  readonly delivery: "ephemeral" | "durable";
  readonly profile?: string;
  readonly retry?: RetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
  readonly invoke: (
    envelope: UnknownEventEnvelope,
    options?: EventDeliveryInvocationOptions,
  ) => Promise<unknown>;
}

Source

EventTriggerSnapshot (interface)

Safe trigger configuration and runtime delivery counters.

Signature

export interface EventTriggerSnapshot {
  readonly ephemeral?: import("./ephemeral.js").EphemeralDeliverySnapshot;
  readonly id: string;
  readonly targetFunctionId?: string;
  readonly eventId: string;
  readonly eventVersion: number;
  readonly delivery: "ephemeral" | "durable";
  readonly profile?: string;
  readonly retry?: RetryPolicy;
  readonly concurrency?: number;
  readonly timeoutMs?: number;
}

Source

router-records.ts

EVENT_DELIVERY_VERSION

Signature

declare const EVENT_DELIVERY_VERSION: 1;

Source

EventDeliveryRecord

Signature

declare const EventDeliveryRecord: EventDeliveryRecord;

Source

EventRouterStateError (class)

Preserves the public event router state error identity and stable error code.

Signature

declare class EventRouterStateError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_EVENT_ROUTER_STATE_INVALID"

Source

appendDeliveryAcceptance

Appends delivery acceptance before acknowledging durable fanout.

Signature

declare const appendDeliveryAcceptance: (
  store: JobStore,
  envelope: UnknownEventEnvelope,
  triggerId: string,
) => Promise<void>;

Source

makeDeliveryId

Derives a stable identity from the publication and target trigger.

Signature

declare const makeDeliveryId: (eventInstanceId: string, triggerId: string) => string;

Source

normalizeDelivery

Validates the durable or ephemeral delivery mode.

Signature

declare const normalizeDelivery: (value: unknown) => "ephemeral" | "durable";

Source

normalizeEnvelope

Validates the envelope and copies its JSON payload and safe attributes.

Signature

declare const normalizeEnvelope: (input: unknown) => UnknownEventEnvelope;

Source

toDeliveryRecord

Projects a durable journal record into its delivery identity and envelope.

Signature

declare const toDeliveryRecord: (record: JobRecord) => EventDeliveryRecord;

Source

toJson

Copies an unknown value into canonical JSON for stable durable encoding.

Signature

declare const toJson: (value: DeliveryData) => JsonValue;

Source

validateDeliveryData

Rejects malformed delivery identities or envelopes during record replay.

Signature

declare const validateDeliveryData: (value: JsonValue) => void;

Source

router-records.types.ts

DeliveryData (interface)

Versioned persisted delivery identity and canonical envelope payload.

Signature

export interface DeliveryData {
  readonly version: typeof EVENT_DELIVERY_VERSION;
  readonly deliveryId: string;
  readonly eventInstanceId: string;
  readonly triggerId: string;
  readonly envelope: UnknownEventEnvelope;
}

Source

EventDeliveryRecord (interface)

Durable acceptance record connecting one publication and trigger.

Signature

export interface EventDeliveryRecord {
  readonly version: typeof EVENT_DELIVERY_VERSION;
  readonly sequence: number;
  readonly timestamp: number;
  readonly deliveryId: string;
  readonly eventInstanceId: string;
  readonly triggerId: string;
  readonly envelope: UnknownEventEnvelope;
}

Source

router.ts

EVENT_DELIVERY_VERSION

Signature

declare const EVENT_DELIVERY_VERSION: 1;

Source

EventDeliveryRecord

Signature

declare const EventDeliveryRecord: EventDeliveryRecord;

Source

EventDeliveryResult

Signature

declare const EventDeliveryResult: EventDeliveryResult;

Source

EventFanoutResult

Signature

declare const EventFanoutResult: EventFanoutResult;

Source

EventRouter

Signature

declare const EventRouter: EventRouter;

Source

EventRouterInput

Signature

declare const EventRouterInput: EventRouterInput;

Source

EventRouterOptions

Signature

declare const EventRouterOptions: EventRouterOptions;

Source

EventRouterRouteOptions

Signature

declare const EventRouterRouteOptions: EventRouterRouteOptions;

Source

EventRouterSnapshot

Signature

declare const EventRouterSnapshot: EventRouterSnapshot;

Source

EventRouterStateError

Signature

declare const EventRouterStateError: typeof EventRouterStateError;

Source

EventRouterTrigger

Signature

declare const EventRouterTrigger: EventRouterTrigger;

Source

EventTriggerSnapshot

Signature

declare const EventTriggerSnapshot: EventTriggerSnapshot;

Source

createEventRouter

Routes accepted envelopes to independently delivered exact-event triggers.

Signature

declare const createEventRouter: (
  requestedRoot: string,
  options?: EventRouterOptions,
) => Promise<EventRouter>;

Source

index.ts

“./agent-state/index.js” (namespace export)

Re-exports all named exports from the “./agent-state/index.js” module.

Signature

export * from "./agent-state/index.js";

Source

“./buckets/index.js” (namespace export)

Re-exports all named exports from the “./buckets/index.js” module.

Signature

export * from "./buckets/index.js";

Source

“./cache/index.js” (namespace export)

Re-exports all named exports from the “./cache/index.js” module.

Signature

export * from "./cache/index.js";

Source

“./events/admin.js” (namespace export)

Re-exports all named exports from the “./events/admin.js” module.

Signature

export * from "./events/admin.js";

Source

“./events/log.js” (namespace export)

Re-exports all named exports from the “./events/log.js” module.

Signature

export * from "./events/log.js";

Source

“./events/router.js” (namespace export)

Re-exports all named exports from the “./events/router.js” module.

Signature

export * from "./events/router.js";

Source

“./jobs/admin.js” (namespace export)

Re-exports all named exports from the “./jobs/admin.js” module.

Signature

export * from "./jobs/admin.js";

Source

“./jobs/queue-utils.js” (namespace export)

Re-exports all named exports from the “./jobs/queue-utils.js” module.

Signature

export * from "./jobs/queue-utils.js";

Source

“./jobs/queue.js” (namespace export)

Re-exports all named exports from the “./jobs/queue.js” module.

Signature

export * from "./jobs/queue.js";

Source

“./jobs/retry.js” (namespace export)

Re-exports all named exports from the “./jobs/retry.js” module.

Signature

export * from "./jobs/retry.js";

Source

“./realtime/index.js” (namespace export)

Re-exports all named exports from the “./realtime/index.js” module.

Signature

export * from "./realtime/index.js";

Source

“./runtime-capabilities.js” (namespace export)

Re-exports all named exports from the “./runtime-capabilities.js” module.

Signature

export * from "./runtime-capabilities.js";

Source

CompiledSchedule

Signature

declare const CompiledSchedule: CompiledSchedule;

Source

DEFAULT_EPHEMERAL_CAPACITY

Signature

declare const DEFAULT_EPHEMERAL_CAPACITY: 100;

Source

DurableEventDeliveryResult

Signature

declare const DurableEventDeliveryResult: EventDeliveryResult;

Source

EPHEMERAL_DELIVERY_CAPABILITIES

Signature

declare const EPHEMERAL_DELIVERY_CAPABILITIES: Readonly<{
  readonly persistence: "none";
  readonly restartRecovery: false;
  readonly dropPolicy: "drop-newest";
}>;

Source

EVENT_DELIVERY_CAPABILITIES

Signature

declare const EVENT_DELIVERY_CAPABILITIES: Readonly<{
  readonly persistence: "restart-recovery";
  readonly restartRecovery: true;
  readonly atLeastOnce: true;
  readonly exactlyOnce: false;
  readonly ordering: "unsupported";
  readonly orderedByKey: false;
}>;

Source

EphemeralDelivery

Signature

declare const EphemeralDelivery: EphemeralDelivery;

Source

EphemeralDeliveryResult

Signature

declare const EphemeralDeliveryResult: EphemeralDeliveryResult;

Source

EphemeralDeliverySnapshot

Signature

declare const EphemeralDeliverySnapshot: EphemeralDeliverySnapshot;

Source

EventDelivery

Signature

declare const EventDelivery: EventDelivery;

Source

EventDeliveryBinding

Signature

declare const EventDeliveryBinding: EventDeliveryBinding;

Source

EventDeliveryBoundary

Signature

declare const EventDeliveryBoundary: EventDeliveryBoundary;

Source

EventDeliveryLedgerRecord

Signature

declare const EventDeliveryLedgerRecord: EventDeliveryLedgerRecord;

Source

EventDeliveryOptions

Signature

declare const EventDeliveryOptions: EventDeliveryOptions;

Source

EventDeliverySnapshot

Signature

declare const EventDeliverySnapshot: EventDeliverySnapshot;

Source

JobRecord

Signature

declare const JobRecord: {
  readonly version: 1;
  readonly sequence: number;
  readonly instanceId: string;
  readonly kind: string;
  readonly timestamp: number;
  readonly data: Json;
};

Source

JobRecordInput

Signature

declare const JobRecordInput: JobRecordInput;

Source

JobStore

Signature

declare const JobStore: JobStore;

Source

JobStoreBoundary

Signature

declare const JobStoreBoundary: JobStoreBoundary;

Source

JobStoreCheckpoint

Signature

declare const JobStoreCheckpoint: {
  readonly version: 1;
  readonly commit: number;
  readonly sequence: number;
  readonly offset: number;
  readonly recordCount: number;
};

Source

JobStoreIndex

Signature

declare const JobStoreIndex: {
  readonly version: 1;
  readonly commit: number;
  readonly entries: {
    readonly [x: string]: { readonly sequence: number; readonly offset: number };
  };
};

Source

JobStoreOptions

Signature

declare const JobStoreOptions: JobStoreOptions;

Source

JobStoreSnapshot

Signature

declare const JobStoreSnapshot: JobStoreSnapshot;

Source

LocalEventProvider

Signature

declare const LocalEventProvider: LocalEventProvider;

Source

ScheduleEnqueue

Signature

declare const ScheduleEnqueue: ScheduleEnqueue;

Source

ScheduleEnqueueContext

Signature

declare const ScheduleEnqueueContext: ScheduleEnqueueContext;

Source

ScheduleRun

Signature

declare const ScheduleRun: ScheduleRun;

Source

ScheduleValidationError

Signature

declare const ScheduleValidationError: typeof ScheduleValidationError;

Source

Scheduler

Signature

declare const Scheduler: Scheduler;

Source

SchedulerClock

Signature

declare const SchedulerClock: SchedulerClock;

Source

SchedulerOptions

Signature

declare const SchedulerOptions: SchedulerOptions;

Source

SchedulerRegistration

Signature

declare const SchedulerRegistration: SchedulerRegistration;

Source

compileSchedule

Signature

declare const compileSchedule: (
  schedule: ScheduleDefinition,
  options?: { readonly currentDate?: Date },
) => CompiledSchedule;

Source

createEphemeralDelivery

Signature

declare const createEphemeralDelivery: (
  invoke: (envelope: UnknownEventEnvelope) => Promise<unknown>,
  requestedCapacity?: number,
) => EphemeralDelivery;

Source

createEventDelivery

Signature

declare const createEventDelivery: (
  root: string,
  binding: EventDeliveryBinding,
  options?: EventDeliveryOptions,
) => Promise<EventDelivery>;

Source

createJobStore

Signature

declare const createJobStore: (
  requestedRoot: string,
  options?: JobStoreOptions,
) => Promise<JobStore>;

Source

createLocalEventProvider

Signature

declare const createLocalEventProvider: (root: string) => Promise<LocalEventProvider>;

Source

createScheduler

Signature

declare const createScheduler: (options?: SchedulerOptions) => Scheduler;

Source

admin-contracts.ts

JOB_ADMIN_PROTOCOL

Signature

declare const JOB_ADMIN_PROTOCOL: "relkit.jobs.admin";

Source

JOB_ADMIN_VERSION

Signature

declare const JOB_ADMIN_VERSION: 1;

Source

JobActionContract

Signature

declare const JobActionContract: JobActionContract;

Source

JobActionRequest

Signature

declare const JobActionRequest: JobActionRequest;

Source

JobAdminAction

Signature

declare const JobAdminAction: JobAdminAction;

Source

JobAdminActionOutcome

Signature

declare const JobAdminActionOutcome: JobAdminActionOutcome;

Source

JobAdminActionRecord

Signature

declare const JobAdminActionRecord: JobAdminActionRecord;

Source

JobAdminActionSink

Signature

declare const JobAdminActionSink: JobAdminActionSink;

Source

JobAdminMode

Signature

declare const JobAdminMode: JobAdminMode;

Source

JobAdminVersion

Signature

declare const JobAdminVersion: JobAdminVersion;

Source

JobCancelRequest

Signature

declare const JobCancelRequest: JobActionRequest;

Source

JobDeadLetterRequest

Signature

declare const JobDeadLetterRequest: JobActionRequest;

Source

JobQueryContract

Signature

declare const JobQueryContract: JobQueryContract;

Source

JobQueryRequest

Signature

declare const JobQueryRequest: JobQueryRequest;

Source

JobRetryRequest

Signature

declare const JobRetryRequest: JobActionRequest;

Source

JobStatusContract

Signature

declare const JobStatusContract: JobStatusContract;

Source

admin-contracts.types.ts

JobActionContract (interface)

Versioned job mutation result including status and audit record.

Signature

export interface JobActionContract extends JobAdminVersion {
  readonly action: JobAdminAction;
  readonly status: JobStatusContract;
  readonly record: JobAdminActionRecord;
}

Source

JobActionRequest (interface)

Base job administration request with target identity and audit reason.

Signature

export interface JobActionRequest {
  readonly protocol?: typeof JOB_ADMIN_PROTOCOL;
  readonly version?: typeof JOB_ADMIN_VERSION;
  readonly instanceId: string;
  readonly reason?: string;
}

Source

JobAdminAction (type alias)

Supported audited queue administration action.

Signature

type JobAdminAction = "retry" | "cancel" | "dead-letter";

Source

JobAdminActionOutcome (type alias)

Whether an administration action was applied or rejected.

Signature

type JobAdminActionOutcome = "applied" | "rejected";

Source

JobAdminActionRecord (interface)

Immutable audit record retained for each applied or rejected job action.

Signature

export interface JobAdminActionRecord extends JobAdminVersion {
  readonly actionId: string;
  readonly action: JobAdminAction;
  readonly instanceId: string;
  readonly mode: JobAdminMode;
  readonly outcome: JobAdminActionOutcome;
  readonly requestedAt: number;
  readonly fromState?: JobQueueState;
  readonly toState?: JobQueueState;
  readonly errorCode?: string;
  readonly reason?: string;
}

Source

JobAdminActionSink (type alias)

Optional notification sink whose rejection cannot change the action outcome.

Signature

type JobAdminActionSink = (record: JobAdminActionRecord) => MaybePromise<void>;

Source

JobAdminMode (type alias)

Environment mode controlling local administration mutations.

Signature

type JobAdminMode = "development" | "test" | "production";

Source

JobAdminVersion (interface)

Protocol identity carried by job administration contracts.

Signature

export interface JobAdminVersion {
  readonly protocol: typeof JOB_ADMIN_PROTOCOL;
  readonly version: typeof JOB_ADMIN_VERSION;
}

Source

JobCancelRequest (type alias)

Job cancellation request with optional audit reason.

Signature

type JobCancelRequest = JobActionRequest;

Source

JobDeadLetterRequest (type alias)

Job dead-letter request with optional audit reason.

Signature

type JobDeadLetterRequest = JobActionRequest;

Source

JobQueryContract (interface)

Versioned bounded page of safe job status records.

Signature

export interface JobQueryContract extends JobAdminVersion {
  readonly items: readonly JobStatusContract[];
  readonly counts: JobQueueCounts;
  readonly nextCursor?: string;
}

Source

JobQueryRequest (interface)

Optional identity, state and pagination filters for job inspection.

Signature

export interface JobQueryRequest {
  readonly protocol?: typeof JOB_ADMIN_PROTOCOL;
  readonly version?: typeof JOB_ADMIN_VERSION;
  readonly instanceId?: string;
  readonly state?: JobQueueState;
  readonly states?: readonly JobQueueState[];
  readonly cursor?: string;
  readonly limit?: number;
}

Source

JobRetryRequest (type alias)

Job retry request with optional policy override.

Signature

type JobRetryRequest = JobActionRequest;

Source

JobStatusContract (interface)

Safe, versioned state returned to inspector consumers.

Signature

export interface JobStatusContract extends JobAdminVersion {
  readonly instanceId: string;
  readonly state: JobQueueState;
  readonly profile: string;
  readonly attempt: number;
  readonly acceptedAt: number;
  readonly order: number;
  readonly availableAt?: number;
  readonly leaseExpiresAt?: number;
  readonly idempotencyExpiresAt?: number;
  readonly failure?: JobFailureMetadata;
}

Source

admin-errors.ts

Preserves the public job admin error identity and stable error code.

JobAdminError (class)

Preserves the public job admin error identity and stable error code.

Signature

declare class JobAdminError { constructor(
    readonly code: string,
    message: string,
  ) }

Source

admin.ts

“./admin-contracts.js” (namespace export)

Re-exports all named exports from the “./admin-contracts.js” module.

Signature

export * from "./admin-contracts.js";

Source

JobAdmin

Signature

declare const JobAdmin: JobAdmin;

Source

JobAdminError

Signature

declare const JobAdminError: typeof JobAdminError;

Source

JobAdminOptions

Signature

declare const JobAdminOptions: JobAdminOptions;

Source

createJobAdmin

Exposes versioned local job inspection and explicitly audited mutations.

Signature

declare const createJobAdmin: (queue: JobQueue, options?: JobAdminOptions) => JobAdmin;

Source

admin.types.ts

JobAdmin (interface)

Versioned job inspection and audited development mutation interface.

Signature

export interface JobAdmin {
  readonly protocol: typeof JOB_ADMIN_PROTOCOL;
  readonly version: typeof JOB_ADMIN_VERSION;
  readonly status: (instanceId: string) => JobStatusContract | undefined;
  readonly query: (request?: JobQueryRequest) => JobQueryContract;
  readonly retry: (request: string | JobActionRequest) => Promise<JobActionContract>;
  readonly cancel: (request: string | JobActionRequest) => Promise<JobActionContract>;
  readonly deadLetter: (request: string | JobActionRequest) => Promise<JobActionContract>;
  readonly actions: () => readonly JobAdminActionRecord[];
}

Source

JobAdminOptions (interface)

Local administration mode and isolated audit/clock hooks.

Signature

export interface JobAdminOptions {
  readonly mode?: JobAdminMode;
  readonly environment?: JobAdminMode;
  readonly enabled?: boolean;
  readonly now?: () => number;
  readonly createActionId?: () => string;
  readonly onAction?: JobAdminActionSink;
}

Source

queue-utils.ts

JOB_QUEUE_STATES

Signature

declare const JOB_QUEUE_STATES: readonly [
  "accepted",
  "available",
  "leased",
  "delayed",
  "completed",
  "dead-lettered",
];

Source

JobFailureKind

Signature

declare const JobFailureKind: JobFailureKind;

Source

JobFailureMetadata

Signature

declare const JobFailureMetadata: JobFailureMetadata;

Source

JobFailureOutcome

Signature

declare const JobFailureOutcome: JobFailureOutcome;

Source

JobFailureRetry

Signature

declare const JobFailureRetry: JobFailureRetry;

Source

JobIdempotencyDefinition

Signature

declare const JobIdempotencyDefinition: JobIdempotencyDefinition;

Source

JobIdempotencyRecord

Signature

declare const JobIdempotencyRecord: JobIdempotencyRecord;

Source

JobQueue

Signature

declare const JobQueue: JobQueue;

Source

JobQueueAcceptance

Signature

declare const JobQueueAcceptance: JobQueueAcceptance;

Source

JobQueueAdminRetryOptions

Signature

declare const JobQueueAdminRetryOptions: JobQueueAdminRetryOptions;

Source

JobQueueCounts

Signature

declare const JobQueueCounts: Readonly<
  Record<"accepted" | "completed" | "available" | "leased" | "delayed" | "dead-lettered", number>
>;

Source

JobQueueEnqueue

Signature

declare const JobQueueEnqueue: JobQueueEnqueue;

Source

JobQueueEntry

Signature

declare const JobQueueEntry: JobQueueEntry;

Source

JobQueueLeaseOptions

Signature

declare const JobQueueLeaseOptions: JobQueueLeaseOptions;

Source

JobQueueOptions

Signature

declare const JobQueueOptions: JobQueueOptions;

Source

JobQueueState

Signature

declare const JobQueueState:
  "accepted" | "completed" | "available" | "leased" | "delayed" | "dead-lettered";

Source

JobQueueStateError (class)

Preserves the public job queue state error identity and stable error code.

Signature

declare class JobQueueStateError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_JOB_QUEUE_STATE_INVALID"

Source

JobQueueTransitionOptions

Signature

declare const JobQueueTransitionOptions: JobQueueTransitionOptions;

Source

JobState

Signature

declare const JobState:
  "accepted" | "completed" | "available" | "leased" | "delayed" | "dead-lettered";

Source

MutableQueueState

Signature

declare const MutableQueueState: MutableQueueState;

Source

assertTime

Rejects times outside the nonnegative safe millisecond range.

Signature

declare const assertTime: (value: number, label: string) => void;

Source

transitions

Signature

declare const transitions: Readonly<
  Record<
    "accepted" | "completed" | "available" | "leased" | "delayed" | "dead-lettered",
    ReadonlyArray<"accepted" | "completed" | "available" | "leased" | "delayed" | "dead-lettered">
  >
>;

Source

queue-utils.types.ts

JobFailureKind (type alias)

Public classification of a failed queue attempt.

Signature

type JobFailureKind = "application" | "provider" | "cancellation" | "timeout" | "defect";

Source

JobFailureMetadata (interface)

Public, JSON-safe failure data retained with a delayed or dead-lettered job.

Signature

export interface JobFailureMetadata {
  readonly kind: JobFailureKind;
  readonly outcome: JobFailureOutcome;
  readonly code: string;
  readonly message: string;
  readonly data?: JsonValue;
  readonly status?: number;
  readonly retry?: JobFailureRetry;
  readonly afterMs?: number;
}

Source

JobFailureOutcome (type alias)

Public terminal or retry outcome of a failed queue attempt.

Signature

type JobFailureOutcome = "declared-error" | "provider-failure" | "cancelled" | "timeout" | "defect";

Source

JobFailureRetry (type alias)

Retry hint retained in safe failure metadata.

Signature

type JobFailureRetry = "never" | "later";

Source

JobIdempotencyDefinition (interface)

Caller deduplication identity and retention policy for a queue acceptance.

Signature

export interface JobIdempotencyDefinition {
  readonly key: string;
  readonly retentionMs: number;
}

Source

JobIdempotencyRecord (interface)

Persisted acceptance identity and expiry used for deduplication.

Signature

export interface JobIdempotencyRecord {
  readonly key: string;
  readonly expiresAt: number;
}

Source

JobQueue (interface)

Promise mutation and synchronous inspection contract for one durable queue.

Signature

export interface JobQueue {
  readonly ownerToken: string;
  readonly ready: () => Promise<void>;
  readonly enqueue: (input: JobQueueEnqueue) => Promise<JobQueueAcceptance>;
  readonly acquire: (
    instanceId?: string,
    options?: JobQueueLeaseOptions,
  ) => Promise<JobQueueEntry | undefined>;
  readonly renew: (instanceId: string, options?: JobQueueLeaseOptions) => Promise<JobQueueEntry>;
  readonly transition: (
    instanceId: string,
    state: JobQueueState,
    options?: JobQueueTransitionOptions,
  ) => Promise<JobQueueEntry>;
  /** Requeues one dead letter as a fresh attempt without widening normal transitions. */
  readonly adminRetry: (
    instanceId: string,
    options?: JobQueueAdminRetryOptions,
  ) => Promise<JobQueueEntry>;
  /** Moves one eligible nonterminal entry to a dead letter with safe metadata. */
  readonly adminDeadLetter: (
    instanceId: string,
    failure: JobFailureMetadata,
  ) => Promise<JobQueueEntry>;
  readonly recover: (now?: number) => Promise<readonly JobQueueEntry[]>;
  readonly expire: (now?: number) => Promise<readonly JobQueueEntry[]>;
  readonly selectAvailable: (limit?: number, now?: number) => readonly JobQueueEntry[];
  readonly get: (instanceId: string) => JobQueueEntry | undefined;
  readonly counts: () => JobQueueCounts;
  readonly snapshot: () => readonly JobQueueEntry[];
}

Source

JobQueueAcceptance (interface)

Durable acceptance information returned by queue admission.

Signature

export interface JobQueueAcceptance extends JobQueueEntry {
  readonly accepted: true;
  readonly duplicate: boolean;
  readonly idempotencyKey?: string;
  readonly idempotencyExpiresAt?: number;
}

Source

JobQueueAdminRetryOptions (interface)

Administrative retry preconditions and next-availability settings.

Signature

export interface JobQueueAdminRetryOptions {
  readonly availableAt?: number;
}

Source

JobQueueCounts (type alias)

Entry counts grouped by durable queue lifecycle state.

Signature

type JobQueueCounts = Readonly<Record<JobQueueState, number>>;

Source

JobQueueEnqueue (interface)

Input required to accept a job into the local durable queue.

Signature

export interface JobQueueEnqueue {
  readonly input: JsonValue;
  readonly profile?: string;
  readonly instanceId?: string;
  readonly acceptedAt?: number;
  readonly idempotency?: JobIdempotencyDefinition;
  readonly propagation?: TracePropagation;
}

Source

JobQueueEntry (interface)

Durable queue state including acceptance, lease, retry and failure metadata.

Signature

export interface JobQueueEntry {
  readonly instanceId: string;
  readonly state: JobQueueState;
  readonly input: JsonValue;
  readonly profile: string;
  readonly attempt: number;
  readonly acceptedAt: number;
  readonly order: number;
  readonly availableAt?: number;
  readonly leaseOwner?: string;
  readonly leaseExpiresAt?: number;
  readonly idempotency?: JobIdempotencyRecord;
  readonly failure?: JobFailureMetadata;
  readonly propagation?: TracePropagation;
}

Source

JobQueueLeaseOptions (interface)

Caller ownership and duration settings for acquiring a lease.

Signature

export interface JobQueueLeaseOptions {
  readonly leaseDurationMs?: number;
  readonly leaseExpiresAt?: number;
}

Source

JobQueueOptions (interface)

Clock, persistence and policy options for a local queue.

Signature

export interface JobQueueOptions {
  readonly now?: () => number;
  readonly createInstanceId?: () => string;
  readonly ownerToken?: string;
  readonly leaseDurationMs?: number;
  readonly idempotency?: JobIdempotencyDefinition;
}

Source

JobQueueState (type alias)

Persisted lifecycle states supported by the local durable queue.

Signature

type JobQueueState = (typeof JOB_QUEUE_STATES)[number];

Source

JobQueueTransitionOptions (interface)

Expected state, ownership and metadata for a durable transition.

Signature

export interface JobQueueTransitionOptions extends JobQueueLeaseOptions {
  readonly expectedState?: JobQueueState;
  readonly attempt?: number;
  readonly availableAt?: number;
  readonly leaseOwner?: string;
  readonly failure?: JobFailureMetadata;
}

Source

JobState (type alias)

Compatibility alias for the durable queue lifecycle state.

Signature

type JobState = JobQueueState;

Source

MutableQueueState (interface)

In-memory queue index and next acceptance order owned by serialized mutations.

Signature

export interface MutableQueueState {
  readonly entries: Map<string, JobQueueEntry>;
  nextOrder: number;
}

Source

queue.ts

“./queue-utils.js” (namespace export)

Re-exports all named exports from the “./queue-utils.js” module.

Signature

export * from "./queue-utils.js";

Source

JOB_QUEUE_STATES

Signature

declare const JOB_QUEUE_STATES: readonly [
  "accepted",
  "available",
  "leased",
  "delayed",
  "completed",
  "dead-lettered",
];

Source

JobQueueStateError

Signature

declare const JobQueueStateError: typeof JobQueueStateError;

Source

createJobQueue

Provides durable queue state plus process-owned leases.

Signature

declare const createJobQueue: (store: JobStore, options?: JobQueueOptions) => JobQueue;

Source

retry.ts

RandomSource

Signature

declare const RandomSource: RandomSource;

Source

RetryClassification

Signature

declare const RetryClassification: RetryClassification;

Source

RetryOptions

Signature

declare const RetryOptions: RetryOptions;

Source

RetryPlan

Signature

declare const RetryPlan: RetryPlan;

Source

RetryState

Signature

declare const RetryState: RetryState;

Source

applyRetry

Applies one leased attempt’s retry/dead-letter outcome durably.

Signature

declare const applyRetry: (
  queue: Pick<JobQueue, "get" | "transition">,
  instanceId: string,
  policy: RetryPolicy,
  failure: unknown,
  options?: RetryOptions,
) => Promise<JobQueueEntry>;

Source

calculateRetryDelay

Calculates a bounded, integer delay for a one-based completed attempt.

Signature

declare const calculateRetryDelay: (
  policy: RetryPolicy,
  attempt: number,
  random?: RandomSource,
) => number;

Source

classifyFailure

Uses the declared error policy; non-declared failures are not retried.

Signature

declare const classifyFailure: (value: unknown) => RetryClassification;

Source

planRetry

Combines normalized failure classification, attempt limits and retry jitter into a retry plan.

Signature

declare const planRetry: (
  policy: RetryPolicy,
  attempt: number,
  failure: unknown,
  options?: Pick<RetryOptions, "random">,
) => RetryPlan;

Source

safeFailureMetadata

Copies the public failure envelope so persisted metadata cannot retain arbitrary error objects.

Signature

declare const safeFailureMetadata: (value: unknown) => JobFailureMetadata;

Source

retry.types.ts

RandomSource (type alias)

Replaceable source of values in [0, 1) for deterministic jitter.

Signature

type RandomSource = () => number;

Source

RetryClassification (type alias)

Whether the normalized failure permits another attempt.

Signature

type RetryClassification = "retryable" | "non-retryable";

Source

RetryOptions (interface)

Clock, jitter and transition options for applying retry policy.

Signature

export interface RetryOptions {
  readonly now?: () => number;
  readonly random?: RandomSource;
}

Source

RetryPlan (interface)

Validated retry classification, delay and safe failure metadata.

Signature

export interface RetryPlan {
  readonly classification: RetryClassification;
  readonly state: RetryState;
  readonly attempt: number;
  readonly delayMs: number;
  readonly failure: JobFailureMetadata;
}

Source

RetryState (type alias)

Durable queue outcome selected by retry policy.

Signature

type RetryState = "delayed" | "dead-lettered";

Source

schedule-definition.ts

ScheduleValidationError (class)

Preserves the public schedule validation error identity and stable error code.

Signature

declare class ScheduleValidationError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_SCHEDULE_INVALID"

Source

compileSchedule

Validates a static schedule and hides the cron parser behind native dates.

Signature

declare const compileSchedule: (
  schedule: ScheduleDefinition,
  options?: { readonly currentDate?: Date },
) => CompiledSchedule;

Source

isRecord

Checks for a non-null, non-array object before inspecting unknown fields.

Signature

declare const isRecord: (value: unknown) => value is Record<string, any>;

Source

parseNext

Computes the next cron occurrence within the configured timezone.

Signature

declare const parseNext: (cron: string, timezone: string, currentDate: Date) => Date;

Source

requiredText

Rejects missing or blank schedule identifiers.

Signature

declare const requiredText: (value: unknown, name: string) => string;

Source

validDate

Rejects invalid clock dates before scheduling work.

Signature

declare const validDate: (value: Date, name: string) => Date;

Source

scheduler.ts

CompiledSchedule

Signature

declare const CompiledSchedule: CompiledSchedule;

Source

LocalSchedulerService (class)

Owns schedule registrations, next-fire positions and active overlap counters.

Signature

declare class LocalSchedulerService

Source

ScheduleEnqueue

Signature

declare const ScheduleEnqueue: ScheduleEnqueue;

Source

ScheduleEnqueueContext

Signature

declare const ScheduleEnqueueContext: ScheduleEnqueueContext;

Source

ScheduleRun

Signature

declare const ScheduleRun: ScheduleRun;

Source

ScheduleValidationError

Signature

declare const ScheduleValidationError: typeof ScheduleValidationError;

Source

Scheduler

Signature

declare const Scheduler: Scheduler;

Source

SchedulerClock

Signature

declare const SchedulerClock: SchedulerClock;

Source

SchedulerOptions

Signature

declare const SchedulerOptions: SchedulerOptions;

Source

SchedulerRegistration

Signature

declare const SchedulerRegistration: SchedulerRegistration;

Source

compileSchedule

Signature

declare const compileSchedule: (
  schedule: ScheduleDefinition,
  options?: { readonly currentDate?: Date },
) => CompiledSchedule;

Source

createScheduler

Runs due schedules against an injected clock without owning or calling handlers.

Signature

declare const createScheduler: (options?: SchedulerOptions) => Scheduler;

Source

makeSchedulerService

Creates lazy registration, inspection and due-work operations over one owned state.

Signature

declare const makeSchedulerService: (
  options?: SchedulerOptions | undefined,
) => Effect.Effect<SchedulerEffects, LocalOperationError, never>;

Source

schedulerLayer

Provides an explicitly driven scheduler without starting an automatic timer.

Example

import { Effect } from "effect";
import { LocalSchedulerService, schedulerLayer } from "./scheduler.js";

const program = Effect.gen(function* () {
  const scheduler = yield* LocalSchedulerService;
  return yield* scheduler.runDue();
});
await Effect.runPromise(program.pipe(Effect.provide(schedulerLayer())));

Signature

declare const schedulerLayer: (
  options?: SchedulerOptions,
) => Layer.Layer<LocalSchedulerService, LocalOperationError, never>;

Source

scheduler.types.ts

CompiledSchedule (interface)

Validated cron schedule with its normalized timezone and identity.

Signature

export interface CompiledSchedule {
  readonly id: string;
  readonly cron: string;
  readonly timezone: string;
  readonly input: JsonValue;
  readonly overlap: ScheduleOverlap;
  readonly nextFireAt: Date;
  readonly nextFire: (currentDate: Date) => Date;
}

Source

ScheduleEnqueue (type alias)

The scheduler only emits work through the common job enqueue/invocation seam.

Signature

type ScheduleEnqueue = (input: JsonValue, context: ScheduleEnqueueContext) => MaybePromise<unknown>;

Source

ScheduleEnqueueContext (interface)

Occurrence identity and time supplied when enqueueing scheduled work.

Signature

export interface ScheduleEnqueueContext {
  readonly scheduleId: string;
  readonly fireAt: Date;
}

Source

ScheduleRun (interface)

Result of processing one due schedule occurrence.

Signature

export interface ScheduleRun {
  readonly scheduleId: string;
  readonly fireAt: Date;
  readonly status: "enqueued" | "skipped";
  readonly result?: unknown;
}

Source

ScheduleState (interface)

Registered schedule and its current next-fire/overlap bookkeeping.

Signature

export interface ScheduleState {
  readonly compiled: CompiledSchedule;
  readonly enqueue: ScheduleEnqueue;
  nextFireAt: number;
  active: number;
}

Source

Scheduler (interface)

Explicitly driven scheduler with registration, due-work execution and inspection.

Signature

export interface Scheduler {
  readonly register: (schedule: ScheduleDefinition, enqueue: ScheduleEnqueue) => CompiledSchedule;
  readonly nextFire: (scheduleId: string) => Date | undefined;
  readonly runDue: (currentDate?: Date | number) => Promise<readonly ScheduleRun[]>;
  readonly tick: (currentDate?: Date | number) => Promise<readonly ScheduleRun[]>;
}

Source

SchedulerClock (interface)

Replaceable clock used by scheduler calculations.

Signature

export interface SchedulerClock {
  readonly now: () => Date | number;
}

Source

SchedulerEffects (type alias)

Lazy scheduler operations shared by live composition and deterministic test substitutes.

Signature

type SchedulerEffects = {
  readonly [K in keyof Scheduler]: Scheduler[K] extends (...args: infer A) => infer R
    ? (...args: A) => Effect.Effect<Awaited<R>, LocalOperationError>
    : never;
};

Source

SchedulerOptions (interface)

Clock and scheduling behavior supplied by the local scheduler owner.

Signature

export interface SchedulerOptions {
  readonly clock?: SchedulerClock;
  readonly now?: () => Date | number;
  readonly schedules?: readonly SchedulerRegistration[];
}

Source

SchedulerRegistration (interface)

Schedule declaration paired with its enqueue callback.

Signature

export interface SchedulerRegistration {
  readonly schedule: ScheduleDefinition;
  readonly enqueue: ScheduleEnqueue;
}

Source

store.ts

JobIndexEntry

Signature

declare const JobIndexEntry: { readonly sequence: number; readonly offset: number };

Source

JobRecord

Signature

declare const JobRecord: {
  readonly version: 1;
  readonly sequence: number;
  readonly instanceId: string;
  readonly kind: string;
  readonly timestamp: number;
  readonly data: Json;
};

Source

JobRecordInput

Signature

declare const JobRecordInput: JobRecordInput;

Source

JobStore

Signature

declare const JobStore: JobStore;

Source

JobStoreBoundary

Signature

declare const JobStoreBoundary: JobStoreBoundary;

Source

JobStoreCheckpoint

Signature

declare const JobStoreCheckpoint: {
  readonly version: 1;
  readonly commit: number;
  readonly sequence: number;
  readonly offset: number;
  readonly recordCount: number;
};

Source

JobStoreEffects

Signature

declare const JobStoreEffects: JobStoreEffects;

Source

JobStoreIndex

Signature

declare const JobStoreIndex: {
  readonly version: 1;
  readonly commit: number;
  readonly entries: {
    readonly [x: string]: { readonly sequence: number; readonly offset: number };
  };
};

Source

JobStoreOptions

Signature

declare const JobStoreOptions: JobStoreOptions;

Source

JobStoreSnapshot

Signature

declare const JobStoreSnapshot: JobStoreSnapshot;

Source

JobStoreStateError (class)

Preserves the public job store state error identity and stable error code.

Signature

declare class JobStoreStateError {
  constructor(message: string);
}

Source

code (property)

Signature

readonly code: "RELKIT_JOB_STORE_STATE_INVALID"

Source

LocalJobStoreService (class)

A durable journal whose serialization and lifecycle have one owner.

Signature

declare class LocalJobStoreService

Source

STORE_VERSION

Signature

declare const STORE_VERSION: 1;

Source

createJobStore

Opens the journal through the established Promise interface.

Signature

declare const createJobStore: (
  requestedRoot: string,
  options?: JobStoreOptions,
) => Promise<JobStore>;

Source

jobStoreLayer

Supplies and closes a durable journal through a scope-owned layer.

Example

import { Effect } from "effect";
import { LocalJobStoreService, jobStoreLayer } from "./store.js";

const program = Effect.gen(function* () {
  const journal = yield* LocalJobStoreService;
  return yield* journal.snapshot();
});
await Effect.runPromise(program.pipe(Effect.provide(jobStoreLayer("/tmp/example-journal"))));

Signature

declare const jobStoreLayer: (
  root: string,
  options?: JobStoreOptions,
) => Layer.Layer<LocalJobStoreService, LocalOperationError, never>;

Source

makeJobStore

Recovers a journal before exposing serialized append operations.

Signature

declare const makeJobStore: (
  requestedRoot: string,
  options?: JobStoreOptions | undefined,
) => Effect.Effect<JobStoreEffects, LocalOperationError, never>;

Source

store.types.ts

JobIndexEntry (type alias)

Latest record sequence and byte offset for one job instance.

Signature

type JobIndexEntry = typeof JobIndexEntrySchema.Type;

Source

JobRecord (type alias)

Versioned durable journal record with ordered sequence and timestamp.

Signature

type JobRecord = typeof JobRecordSchema.Type;

Source

JobRecordInput (interface)

Canonical JSON record input before sequence and timestamp assignment.

Signature

export interface JobRecordInput {
  readonly instanceId: string;
  readonly kind: string;
  readonly data: JsonValue;
  readonly timestamp?: number;
}

Source

JobStore (interface)

Compatibility journal interface with durable append and explicit close.

Signature

export interface JobStore {
  readonly root: string;
  readonly paths: Readonly<ReturnType<typeof createJobStorePaths>>;
  readonly append: (input: JobRecordInput) => Promise<JobRecord>;
  readonly snapshot: () => JobStoreSnapshot;
  readonly close: () => Promise<void>;
}

Source

JobStoreBoundary (type alias)

Durable commit milestones available to fault-injection and observation hooks.

Signature

type JobStoreBoundary = "record-fsynced" | "index-committed" | "checkpoint-committed";

Source

JobStoreCheckpoint (type alias)

Committed sequence, record count and byte offset used for recovery.

Signature

type JobStoreCheckpoint = typeof JobCheckpointSchema.Type;

Source

JobStoreEffects (interface)

Effect operations for a durable journal and its committed snapshot.

Signature

export interface JobStoreEffects {
  readonly root: string;
  readonly paths: JobStore["paths"];
  readonly append: (input: JobRecordInput) => Effect.Effect<JobRecord, LocalOperationError>;
  readonly snapshot: () => Effect.Effect<JobStoreSnapshot>;
  readonly close: () => Effect.Effect<void>;
}

Source

JobStoreIndex (type alias)

Versioned index rebuilt from the durable journal.

Signature

type JobStoreIndex = typeof JobIndexSchema.Type;

Source

JobStoreOptions (interface)

Clock, record validation and durable-boundary hooks for journal ownership.

Signature

export interface JobStoreOptions {
  readonly now?: () => number;
  /** Test-only failure seam; an error rejects append before acknowledgement. */
  readonly onBoundary?: (boundary: JobStoreBoundary) => void | Promise<void>;
  /** Optional semantic guard used by durable stores layered on this record format. */
  readonly validateData?: (data: JsonValue) => void;
}

Source

JobStoreSnapshot (interface)

Immutable recovered records, index and checkpoint.

Signature

export interface JobStoreSnapshot {
  readonly records: readonly JobRecord[];
  readonly index: JobStoreIndex;
  readonly checkpoint: JobStoreCheckpoint;
}

Source

common.ts

LocalRealtimeError (class)

Preserves the public local realtime error identity and stable error code.

Signature

declare class LocalRealtimeError { constructor(
    readonly code: string,
    message: string,
  ) }

Source

checkpoint

Builds the current journal checkpoint from the persisted sequence.

Signature

declare const checkpoint: (
  scope: RealtimeScope,
  state: LocalRealtimeState,
  sequence: number,
  historyStart: number,
  expiresAt: string,
) => ChannelCheckpoint;

Source

emptyPartition

Creates an empty retained event and presence partition.

Signature

declare const emptyPartition: (sequence: number) => StoredRealtimePartition;

Source

encodedBytes

Measures canonical JSON bytes for admission limits.

Signature

declare const encodedBytes: (value: unknown) => number;

Source

partitionKey

Encodes the channel and scope into a stable realtime partition key.

Signature

declare const partitionKey: (scope: RealtimeScope) => string;

Source

prunePartition

Removes expired events and enforces retention bounds without renumbering sequences.

Signature

declare const prunePartition: (
  partition: StoredRealtimePartition,
  now: number,
) => StoredRealtimePartition;

Source

scopeGap

Constructs a replay gap describing the requested checkpoint and current scope.

Signature

declare const scopeGap: (
  expected: RealtimeScope,
  actual: ChannelCheckpoint,
  providerEpoch: string,
) => "foreign" | "policy" | "session" | "provider-reset" | undefined;

Source

provider.ts

LocalRealtimeProviderOptions

Signature

declare const LocalRealtimeProviderOptions: LocalRealtimeProviderOptions;

Source

LocalRealtimeService (class)

Realtime operations sharing one persisted-state transaction owner.

Signature

declare class LocalRealtimeService

Source

createLocalRealtimeProvider

Provides realtime operations using filesystem-shared state.

Signature

declare const createLocalRealtimeProvider: (
  root: string,
  options?: LocalRealtimeProviderOptions,
) => RealtimeProvider;

Source

createRealtimeProviderFromStore

Substitutes an existing Promise storage adapter at the compatibility edge.

Signature

declare const createRealtimeProviderFromStore: (
  store: RealtimeStateStore,
  pollingMs?: number,
) => RealtimeProvider;

Source

makeRealtimeService

Composes realtime behavior over an Effect transaction interface.

Signature

declare const makeRealtimeService: (
  store: RealtimeStateStoreEffects,
  pollingMs?: number,
) => RealtimeEffects;

Source

realtimeLayer

Builds one live realtime service through a substitutable layer.

Example

import { Effect } from "effect";
import { LocalRealtimeService, realtimeLayer } from "./provider.js";

const program = Effect.gen(function* () {
  const realtime = yield* LocalRealtimeService;
  return yield* realtime.getEpoch();
});
await Effect.runPromise(program.pipe(Effect.provide(realtimeLayer("/tmp/example-realtime"))));

Signature

declare const realtimeLayer: (
  root: string,
  pollingMs?: number,
) => Layer.Layer<LocalRealtimeService, LocalOperationError, never>;

Source

provider.types.ts

LocalRealtimeProviderOptions (interface)

Polling configuration for filesystem-shared realtime observations.

Signature

export interface LocalRealtimeProviderOptions {
  readonly pollingMs?: number;
}

Source

RealtimeEffects (type alias)

Effect methods corresponding to the established realtime provider surface.

Signature

type RealtimeEffects = {
  readonly [K in Exclude<keyof RealtimeProvider, "capabilities">]: RealtimeProvider[K] extends (
    ...args: infer A
  ) => infer R
    ? (...args: A) => Effect.Effect<Awaited<R>, LocalOperationError>
    : never;
};

Source

state.ts

LOCAL_REALTIME_STATE_VERSION

Signature

declare const LOCAL_REALTIME_STATE_VERSION: 2;

Source

LocalRealtimeState

Signature

declare const LocalRealtimeState: {
  readonly version: 2;
  readonly providerEpoch: string;
  readonly sequence: number;
  readonly revision: number;
  readonly retainedBytes: number;
  readonly partitions: {
    readonly [x: string]: {
      readonly historyStart: number;
      readonly events: ReadonlyArray<{
        readonly sequence: number;
        readonly eventId: string;
        readonly event: string;
        readonly payload: unknown;
        readonly encodedBytes: number;
        readonly createdAt: string;
        readonly expiresAt: string;
      }>;
      readonly presence: ReadonlyArray<{
        readonly expiresAt: string;
        readonly leaseId: string;
        readonly connectionId: string;
        readonly opaqueMemberId?: string;
        readonly memberInfo?: unknown;
      }>;
    };
  };
  readonly receipts: {
    readonly [x: string]: {
      readonly semanticDigest: string;
      readonly expiresAt: string;
      readonly receipt: {
        readonly accepted: true;
        readonly profile: string;
        readonly providerEpoch: string;
        readonly checkpoint: {
          readonly applicationId: string;
          readonly environment: string;
          readonly profile: string;
          readonly providerEpoch: string;
          readonly sequence: string;
          readonly expiresAt: string;
          readonly historyStart: string;
          readonly channelId: string;
          readonly partition: string;
          readonly policyEpoch: string;
          readonly identityScope: string;
          readonly sessionEpoch: string;
          readonly tenantScope?: string;
        };
        readonly duplicate: boolean;
        readonly eventId: string;
        readonly operationId?: OperationId;
      };
    };
  };
};

Source

StoredAppendReceipt

Signature

declare const StoredAppendReceipt: {
  readonly semanticDigest: string;
  readonly expiresAt: string;
  readonly receipt: {
    readonly accepted: true;
    readonly profile: string;
    readonly providerEpoch: string;
    readonly checkpoint: {
      readonly applicationId: string;
      readonly environment: string;
      readonly profile: string;
      readonly providerEpoch: string;
      readonly sequence: string;
      readonly expiresAt: string;
      readonly historyStart: string;
      readonly channelId: string;
      readonly partition: string;
      readonly policyEpoch: string;
      readonly identityScope: string;
      readonly sessionEpoch: string;
      readonly tenantScope?: string;
    };
    readonly duplicate: boolean;
    readonly eventId: string;
    readonly operationId?: OperationId;
  };
};

Source

StoredPresenceLease

Signature

declare const StoredPresenceLease: {
  readonly expiresAt: string;
  readonly leaseId: string;
  readonly connectionId: string;
  readonly opaqueMemberId?: string;
  readonly memberInfo?: unknown;
};

Source

StoredRealtimeEvent

Signature

declare const StoredRealtimeEvent: {
  readonly sequence: number;
  readonly eventId: string;
  readonly event: string;
  readonly payload: unknown;
  readonly encodedBytes: number;
  readonly createdAt: string;
  readonly expiresAt: string;
};

Source

StoredRealtimePartition

Signature

declare const StoredRealtimePartition: {
  readonly historyStart: number;
  readonly events: ReadonlyArray<{
    readonly sequence: number;
    readonly eventId: string;
    readonly event: string;
    readonly payload: unknown;
    readonly encodedBytes: number;
    readonly createdAt: string;
    readonly expiresAt: string;
  }>;
  readonly presence: ReadonlyArray<{
    readonly expiresAt: string;
    readonly leaseId: string;
    readonly connectionId: string;
    readonly opaqueMemberId?: string;
    readonly memberInfo?: unknown;
  }>;
};

Source

emptyRealtimeState

Creates format-v1 realtime state with an epoch and empty partition/receipt indexes.

Signature

declare const emptyRealtimeState: (epoch?: string) => LocalRealtimeState;

Source

state.types.ts

LocalRealtimeState (type alias)

Complete validated version-two realtime snapshot.

Signature

type LocalRealtimeState = typeof RealtimeState.Type;

Source

StoredAppendReceipt (type alias)

Idempotent append acknowledgement with semantic digest and expiry.

Signature

type StoredAppendReceipt = typeof AppendReceipt.Type;

Source

StoredPresenceLease (type alias)

Connection lease decoded before expiry and capacity decisions.

Signature

type StoredPresenceLease = typeof PresenceLease.Type;

Source

StoredRealtimeEvent (type alias)

Stored ordered event whose application payload remains opaque.

Signature

type StoredRealtimeEvent = typeof RealtimeEvent.Type;

Source

StoredRealtimePartition (type alias)

Atomic partition history and presence representation.

Signature

type StoredRealtimePartition = typeof RealtimePartition.Type;

Source

storage.types.ts

RealtimeStateStore (interface)

Existing Promise transaction seam for third-party storage adapters.

Signature

export interface RealtimeStateStore {
  readonly read: () => Promise<LocalRealtimeState>;
  readonly update: <Value>(
    change: (state: LocalRealtimeState) => {
      readonly state: LocalRealtimeState;
      readonly value: Value;
    },
  ) => Promise<Value>;
}

Source

RealtimeStateStoreEffects (interface)

Effect operations sharing one transactional initialization and lock owner.

Signature

export interface RealtimeStateStoreEffects {
  readonly read: () => Effect.Effect<LocalRealtimeState, LocalOperationError>;
  readonly update: <Value>(
    change: (state: LocalRealtimeState) => {
      readonly state: LocalRealtimeState;
      readonly value: Value;
    },
  ) => Effect.Effect<Value, LocalOperationError>;
}

Source

runtime-capabilities.ts

LocalJobProvider

Signature

declare const LocalJobProvider: LocalJobProvider;

Source

createLocalJobProvider

Creates a profile-owned durable queue provider through its established synchronous constructor.

Signature

declare const createLocalJobProvider: {
  (root: string, profile: string): LocalJobProvider;
  (root: string, profile: string, executionModel: "task"): JobsAdapterRuntime;
};

Source

createLocalObservabilityProvider

Creates an isolated synchronous JSON collector without recursively observing sink writes.

Signature

declare const createLocalObservabilityProvider: () => Readonly<{
  collect: (record: JsonValue) => void;
  emit: (record: JsonValue) => void;
  read: () => readonly JsonValue[];
}>;

Source

runtime-capabilities.types.ts

LocalJobProvider (interface)

Public local native-job adapter with worker and lifecycle capabilities.

Signature

export interface LocalJobProvider {
  readonly createQueue: (context: {
    readonly jobId: string;
    readonly idempotency?: JobIdempotencyDefinition;
  }) => Promise<JobQueue>;
  readonly close: () => Promise<void>;
}

Source