Skip to main content

Class: default

Defined in: AgentStorage.ts:63

Main entry point for the Cleft SDK.

Coordinates all storage modules: wallet policy, checkpoint persistence, append-only logging, and ERC-8004 agent identity.

Use the public checkpoints and logs properties to interact with storage. Do not call _store() or _retrieve() directly — they are private primitives used internally by CheckpointStore and LogStore.

Properties

checkpoints

readonly checkpoints: CheckpointStore

Defined in: AgentStorage.ts:71

Versioned world-state checkpoint store.


identity

readonly identity: AgentIdentity

Defined in: AgentStorage.ts:67

ERC-8004 identity — source of truth for latestPieceCid.


logs

readonly logs: LogStore

Defined in: AgentStorage.ts:73

Append-only audit log store.


wallet

readonly wallet: AgentWallet

Defined in: AgentStorage.ts:69

Wallet policy wrapper — call assertSufficientFunds before expensive ops.

Methods

budget()

budget(): Promise<bigint>

Defined in: AgentStorage.ts:170

Returns the wallet balance in atto-USDFC.

Returns

Promise<bigint>


getLatestPieceCid()

getLatestPieceCid(): string

Defined in: AgentStorage.ts:203

Returns the latest checkpoint pieceCid, or null if no checkpoint exists. Delegates to identity.getLatestPieceCid() — the chain is the source of truth.

Returns

string


health()

health(): Promise<HealthReport>

Defined in: AgentStorage.ts:177

Returns an operational health summary for checkpoints, logs, and wallet.

Returns

Promise<HealthReport>


create()

static create(config): Promise<AgentStorage>

Defined in: AgentStorage.ts:93

Builds an AgentStorage instance from runtime config.

Initialisation order:

  1. Establish Synapse / Filecoin connection
  2. Bind store / retrieve Filecoin primitives as injectable closures
  3. Initialise AgentWallet with wallet policy
  4. Initialise AgentIdentity — registers on-chain (first run) or restores latestPieceCid from the ERC-8004 agent card (subsequent runs)
  5. Initialise CheckpointPolicy
  6. Initialise CheckpointStore with injected closures, identity, and policy
  7. Restore latestPieceCid into CheckpointStore from identity
  8. Initialise LogStore with injected store closure

Parameters

config

AgentStorageConfig

SDK configuration.

Returns

Promise<AgentStorage>

A fully wired AgentStorage instance, ready to use.