@xynehq/jaf
Version:
Juspay Agent Framework - A purely functional agent framework with immutable state and composable tools
62 lines • 2.3 kB
TypeScript
/**
* JAF ADK Layer - Artifact Storage System
*
* Provides persistent key-value storage for agent conversations
* with support for multiple storage backends
*/
import { Session } from '../types.js';
export interface ArtifactMetadata {
created: Date;
lastModified: Date;
contentType?: string;
size?: number;
tags?: string[];
}
export interface Artifact<T = unknown> {
key: string;
value: T;
metadata: ArtifactMetadata;
}
export interface ArtifactStorage {
get: <T = unknown>(sessionId: string, key: string) => Promise<Artifact<T> | null>;
set: <T = unknown>(sessionId: string, key: string, value: T, metadata?: Partial<ArtifactMetadata>) => Promise<Artifact<T>>;
delete: (sessionId: string, key: string) => Promise<boolean>;
list: (sessionId: string) => Promise<Artifact[]>;
clear: (sessionId: string) => Promise<void>;
exists: (sessionId: string, key: string) => Promise<boolean>;
}
export interface ArtifactStorageConfig {
type: 'memory' | 'redis' | 'postgres' | 's3' | 'gcs';
config?: Record<string, unknown>;
maxSize?: number;
ttl?: number;
}
export declare const createMemoryArtifactStorage: (config?: {
maxSize?: number;
ttl?: number;
}) => ArtifactStorage;
export declare const createRedisArtifactStorage: (config: {
host: string;
port: number;
password?: string;
database?: number;
keyPrefix?: string;
maxSize?: number;
ttl?: number;
}) => ArtifactStorage;
export declare const createPostgresArtifactStorage: (config: {
connectionString: string;
tableName?: string;
maxSize?: number;
ttl?: number;
}) => ArtifactStorage;
/**
* Helper functions to integrate artifacts with sessions
*/
export declare const getSessionArtifact: <T = unknown>(session: Session, key: string) => T | null;
export declare const setSessionArtifact: <T = unknown>(session: Session, key: string, value: T) => Session;
export declare const deleteSessionArtifact: (session: Session, key: string) => Session;
export declare const clearSessionArtifacts: (session: Session) => Session;
export declare const listSessionArtifacts: (session: Session) => string[];
export declare const createArtifactStorage: (config: ArtifactStorageConfig) => ArtifactStorage;
//# sourceMappingURL=index.d.ts.map