Initial commit: Brainy - Multi-Dimensional AI Database

Open source vector database with HNSW indexing, graph relationships,
and metadata facets. Features CLI with professional augmentation registry
integration for discovering extensions and capabilities.
This commit is contained in:
David Snelling 2025-08-18 17:35:06 -07:00
commit f8c45f2d8d
448 changed files with 103294 additions and 0 deletions

370
dist/types/augmentations.d.ts vendored Normal file
View file

@ -0,0 +1,370 @@
/** Common types for the augmentation system */
/**
* Enum representing all types of augmentations available in the Brainy system.
*/
export declare enum AugmentationType {
SENSE = "sense",
CONDUIT = "conduit",
COGNITION = "cognition",
MEMORY = "memory",
PERCEPTION = "perception",
DIALOG = "dialog",
ACTIVATION = "activation",
WEBSOCKET = "webSocket"
}
export type WebSocketConnection = {
connectionId: string;
url: string;
status: 'connected' | 'disconnected' | 'error';
send?: (data: string | ArrayBufferLike | Blob | ArrayBufferView) => Promise<void>;
close?: () => Promise<void>;
_streamMessageHandler?: (event: {
data: unknown;
}) => void;
_messageHandlerWrapper?: (data: unknown) => void;
};
type DataCallback<T> = (data: T) => void;
export type AugmentationResponse<T> = {
success: boolean;
data: T;
error?: string;
};
/**
* Base interface for all Brainy augmentations.
* All augmentations must implement these core properties.
*/
export interface IAugmentation {
/** A unique identifier for the augmentation (e.g., "my-reasoner-v1") */
readonly name: string;
/** A human-readable description of the augmentation's purpose */
readonly description: string;
/** Whether this augmentation is enabled */
enabled: boolean;
/**
* Initializes the augmentation. This method is called when Brainy starts up.
* @returns A Promise that resolves when initialization is complete
*/
initialize(): Promise<void>;
shutDown(): Promise<void>;
getStatus(): Promise<'active' | 'inactive' | 'error'>;
[key: string]: any;
}
/**
* Interface for WebSocket support.
* Augmentations that implement this interface can communicate via WebSockets.
*/
export interface IWebSocketSupport extends IAugmentation {
/**
* Establishes a WebSocket connection.
* @param url The WebSocket server URL to connect to
* @param protocols Optional subprotocols
* @returns A Promise resolving to a connection handle or status
*/
connectWebSocket(url: string, protocols?: string | string[]): Promise<WebSocketConnection>;
/**
* Sends data through an established WebSocket connection.
* @param connectionId The identifier of the established connection
* @param data The data to send (will be serialized if not a string)
*/
sendWebSocketMessage(connectionId: string, data: unknown): Promise<void>;
/**
* Registers a callback for incoming WebSocket messages.
* @param connectionId The identifier of the established connection
* @param callback The function to call when a message is received
*/
onWebSocketMessage(connectionId: string, callback: DataCallback<unknown>): Promise<void>;
/**
* Removes a callback for incoming WebSocket messages.
* @param connectionId The identifier of the established connection
* @param callback The function to remove from the callbacks
*/
offWebSocketMessage(connectionId: string, callback: DataCallback<unknown>): Promise<void>;
/**
* Closes an established WebSocket connection.
* @param connectionId The identifier of the established connection
* @param code Optional close code
* @param reason Optional close reason
*/
closeWebSocket(connectionId: string, code?: number, reason?: string): Promise<void>;
}
export declare namespace BrainyAugmentations {
/**
* Interface for Senses augmentations.
* These augmentations ingest and process raw, unstructured data into nouns and verbs.
*/
interface ISenseAugmentation extends IAugmentation {
/**
* Processes raw input data into structured nouns and verbs.
* @param rawData The raw, unstructured data (e.g., text, image buffer, audio stream)
* @param dataType The type of raw data (e.g., 'text', 'image', 'audio')
* @param options Optional processing options (e.g., confidence thresholds, filters)
*/
processRawData(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
nouns: string[];
verbs: string[];
confidence?: number;
insights?: Array<{
type: string;
description: string;
confidence: number;
}>;
metadata?: Record<string, unknown>;
}>>;
/**
* Registers a listener for real-time data feeds.
* @param feedUrl The URL or identifier of the real-time feed
* @param callback A function to call with processed data
*/
listenToFeed(feedUrl: string, callback: DataCallback<{
nouns: string[];
verbs: string[];
confidence?: number;
}>): Promise<void>;
/**
* Analyzes data structure without processing (preview mode).
* @param rawData The raw data to analyze
* @param dataType The type of raw data
* @param options Optional analysis options
*/
analyzeStructure?(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
entityTypes: Array<{
type: string;
count: number;
confidence: number;
}>;
relationshipTypes: Array<{
type: string;
count: number;
confidence: number;
}>;
dataQuality: {
completeness: number;
consistency: number;
accuracy: number;
};
recommendations: string[];
}>>;
/**
* Validates data compatibility with current knowledge base.
* @param rawData The raw data to validate
* @param dataType The type of raw data
*/
validateCompatibility?(rawData: Buffer | string, dataType: string): Promise<AugmentationResponse<{
compatible: boolean;
issues: Array<{
type: string;
description: string;
severity: 'low' | 'medium' | 'high';
}>;
suggestions: string[];
}>>;
}
/**
* Interface for Conduits augmentations.
* These augmentations establish and manage high-bandwidth, dedicated channels for structured, programmatic two-way data exchange.
*/
interface IConduitAugmentation extends IAugmentation {
/**
* Establishes a connection for programmatic data exchange.
* @param targetSystemId The identifier of the external system to connect to
* @param config Configuration details for the connection (e.g., API keys, endpoints)
*/
establishConnection(targetSystemId: string, config: Record<string, unknown>): Promise<AugmentationResponse<WebSocketConnection>>;
/**
* Reads structured data directly from Brainy's knowledge graph.
* @param query A structured query (e.g., graph query language, object path)
* @param options Optional query options (e.g., depth, filters)
*/
readData(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
/**
* Writes or updates structured data directly into Brainy's knowledge graph.
* @param data The structured data to write/update
* @param options Optional write options (e.g., merge, overwrite)
*/
writeData(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
/**
* Monitors a specific data stream or event within Brainy for external systems.
* @param streamId The identifier of the data stream or event
* @param callback A function to call when new data/events occur
*/
monitorStream(streamId: string, callback: DataCallback<unknown>): Promise<void>;
}
/**
* Interface for Cognitions augmentations.
* These augmentations enable advanced reasoning, inference, and logical operations.
*/
interface ICognitionAugmentation extends IAugmentation {
/**
* Performs a reasoning operation based on current knowledge.
* @param query The specific reasoning task or question
* @param context Optional additional context for the reasoning
*/
reason(query: string, context?: Record<string, unknown>): AugmentationResponse<{
inference: string;
confidence: number;
}>;
/**
* Infers relationships or new facts from existing data.
* @param dataSubset A subset of data to infer from
*/
infer(dataSubset: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
/**
* Executes a logical operation or rule set.
* @param ruleId The identifier of the rule or logic to apply
* @param input Data to apply the logic to
*/
executeLogic(ruleId: string, input: Record<string, unknown>): AugmentationResponse<boolean>;
}
/**
* Interface for Memory augmentations.
* These augmentations provide storage capabilities for data in different formats (e.g., fileSystem, in-memory).
*/
interface IMemoryAugmentation extends IAugmentation {
/**
* Stores data in the memory system.
* @param key The unique identifier for the data
* @param data The data to store
* @param options Optional storage options (e.g., expiration, format)
*/
storeData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
/**
* Retrieves data from the memory system.
* @param key The unique identifier for the data
* @param options Optional retrieval options (e.g., format, version)
*/
retrieveData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
/**
* Updates existing data in the memory system.
* @param key The unique identifier for the data
* @param data The updated data
* @param options Optional update options (e.g., merge, overwrite)
*/
updateData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
/**
* Deletes data from the memory system.
* @param key The unique identifier for the data
* @param options Optional deletion options
*/
deleteData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
/**
* Lists available data keys in the memory system.
* @param pattern Optional pattern to filter keys (e.g., prefix, regex)
* @param options Optional listing options (e.g., limit, offset)
*/
listDataKeys(pattern?: string, options?: Record<string, unknown>): Promise<AugmentationResponse<string[]>>;
/**
* Searches for data in the memory system using vector similarity.
* @param query The query vector or data to search for
* @param k Number of results to return
* @param options Optional search options
*/
search(query: unknown, k?: number, options?: Record<string, unknown>): Promise<AugmentationResponse<Array<{
id: string;
score: number;
data: unknown;
}>>>;
}
/**
* Interface for Perceptions augmentations.
* These augmentations interpret, contextualize, and visualize identified nouns and verbs.
*/
interface IPerceptionAugmentation extends IAugmentation {
/**
* Interprets and contextualizes processed nouns and verbs.
* @param nouns The list of identified nouns
* @param verbs The list of identified verbs
* @param context Optional additional context for interpretation
*/
interpret(nouns: string[], verbs: string[], context?: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
/**
* Organizes and filters information.
* @param data The data to organize (e.g., interpreted perceptions)
* @param criteria Optional criteria for filtering/prioritization
*/
organize(data: Record<string, unknown>, criteria?: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
/**
* Generates a visualization based on the provided data.
* @param data The data to visualize (e.g., interpreted patterns)
* @param visualizationType The desired type of visualization (e.g., 'graph', 'chart')
*/
generateVisualization(data: Record<string, unknown>, visualizationType: string): AugmentationResponse<string | Buffer | Record<string, unknown>>;
}
/**
* Interface for Dialogs augmentations.
* These augmentations facilitate natural language understanding and generation for conversational interaction.
*/
interface IDialogAugmentation extends IAugmentation {
/**
* Processes a user's natural language input (query).
* @param naturalLanguageQuery The raw text query from the user
* @param sessionId An optional session ID for conversational context
*/
processUserInput(naturalLanguageQuery: string, sessionId?: string): AugmentationResponse<{
intent: string;
nouns: string[];
verbs: string[];
context: Record<string, unknown>;
}>;
/**
* Generates a natural language response based on Brainy's knowledge and interpreted input.
* @param interpretedInput The output from `processUserInput` or similar
* @param knowledgeContext Relevant knowledge retrieved from Brainy
* @param sessionId An optional session ID for conversational context
*/
generateResponse(interpretedInput: Record<string, unknown>, knowledgeContext: Record<string, unknown>, sessionId?: string): AugmentationResponse<string>;
/**
* Manages and updates conversational context.
* @param sessionId The session ID
* @param contextUpdate The data to update the context with
*/
manageContext(sessionId: string, contextUpdate: Record<string, unknown>): Promise<void>;
}
/**
* Interface for Activations augmentations.
* These augmentations dictate how Brainy initiates actions, responses, or data manipulations.
*/
interface IActivationAugmentation extends IAugmentation {
/**
* Triggers an action based on a processed command or internal state.
* @param actionName The name of the action to trigger
* @param parameters Optional parameters for the action
*/
triggerAction(actionName: string, parameters?: Record<string, unknown>): AugmentationResponse<unknown>;
/**
* Generates an expressive output or response from Brainy.
* @param knowledgeId The identifier of the knowledge to express
* @param format The desired output format (e.g., 'text', 'json')
*/
generateOutput(knowledgeId: string, format: string): AugmentationResponse<string | Record<string, unknown>>;
/**
* Interacts with an external system or API.
* @param systemId The identifier of the external system
* @param payload The data to send to the external system
*/
interactExternal(systemId: string, payload: Record<string, unknown>): AugmentationResponse<unknown>;
}
}
/** Direct exports of augmentation interfaces for easier imports */
export interface ISenseAugmentation extends BrainyAugmentations.ISenseAugmentation {
}
export interface IConduitAugmentation extends BrainyAugmentations.IConduitAugmentation {
}
export interface ICognitionAugmentation extends BrainyAugmentations.ICognitionAugmentation {
}
export interface IMemoryAugmentation extends BrainyAugmentations.IMemoryAugmentation {
}
export interface IPerceptionAugmentation extends BrainyAugmentations.IPerceptionAugmentation {
}
export interface IDialogAugmentation extends BrainyAugmentations.IDialogAugmentation {
}
export interface IActivationAugmentation extends BrainyAugmentations.IActivationAugmentation {
}
/** WebSocket-enabled augmentation interfaces */
export type IWebSocketSenseAugmentation = BrainyAugmentations.ISenseAugmentation & IWebSocketSupport;
export type IWebSocketConduitAugmentation = BrainyAugmentations.IConduitAugmentation & IWebSocketSupport;
export type IWebSocketCognitionAugmentation = BrainyAugmentations.ICognitionAugmentation & IWebSocketSupport;
export type IWebSocketMemoryAugmentation = BrainyAugmentations.IMemoryAugmentation & IWebSocketSupport;
export type IWebSocketPerceptionAugmentation = BrainyAugmentations.IPerceptionAugmentation & IWebSocketSupport;
export type IWebSocketDialogAugmentation = BrainyAugmentations.IDialogAugmentation & IWebSocketSupport;
export type IWebSocketActivationAugmentation = BrainyAugmentations.IActivationAugmentation & IWebSocketSupport;
export {};

16
dist/types/augmentations.js vendored Normal file
View file

@ -0,0 +1,16 @@
/** Common types for the augmentation system */
/**
* Enum representing all types of augmentations available in the Brainy system.
*/
export var AugmentationType;
(function (AugmentationType) {
AugmentationType["SENSE"] = "sense";
AugmentationType["CONDUIT"] = "conduit";
AugmentationType["COGNITION"] = "cognition";
AugmentationType["MEMORY"] = "memory";
AugmentationType["PERCEPTION"] = "perception";
AugmentationType["DIALOG"] = "dialog";
AugmentationType["ACTIVATION"] = "activation";
AugmentationType["WEBSOCKET"] = "webSocket";
})(AugmentationType || (AugmentationType = {}));
//# sourceMappingURL=augmentations.js.map

1
dist/types/augmentations.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"augmentations.js","sourceRoot":"","sources":["../../src/types/augmentations.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C;;GAEG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;IACzB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;IACzB,2CAAuB,CAAA;AACzB,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B"}

50
dist/types/brainyDataInterface.d.ts vendored Normal file
View file

@ -0,0 +1,50 @@
/**
* BrainyDataInterface
*
* This interface defines the methods from BrainyData that are used by serverSearchAugmentations.ts.
* It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
*/
import { Vector } from '../coreTypes.js';
export interface BrainyDataInterface<T = unknown> {
/**
* Initialize the database
*/
init(): Promise<void>;
/**
* Get a noun by ID
* @param id The ID of the noun to get
*/
get(id: string): Promise<unknown>;
/**
* Add a vector or data to the database
* @param vectorOrData Vector or data to add
* @param metadata Optional metadata to associate with the vector
* @returns The ID of the added vector
*/
add(vectorOrData: Vector | unknown, metadata?: T): Promise<string>;
/**
* Search for text in the database
* @param text The text to search for
* @param limit Maximum number of results to return
* @returns Search results
*/
searchText(text: string, limit?: number): Promise<unknown[]>;
/**
* Create a relationship between two entities
* @param sourceId The ID of the source entity
* @param targetId The ID of the target entity
* @param relationType The type of relationship
* @param metadata Optional metadata about the relationship
* @returns The ID of the created relationship
*/
relate(sourceId: string, targetId: string, relationType: string, metadata?: unknown): Promise<string>;
/**
* Find entities similar to a given entity ID
* @param id ID of the entity to find similar entities for
* @param options Additional options
* @returns Array of search results with similarity scores
*/
findSimilar(id: string, options?: {
limit?: number;
}): Promise<unknown[]>;
}

8
dist/types/brainyDataInterface.js vendored Normal file
View file

@ -0,0 +1,8 @@
/**
* BrainyDataInterface
*
* This interface defines the methods from BrainyData that are used by serverSearchAugmentations.ts.
* It's used to break the circular dependency between brainyData.ts and serverSearchAugmentations.ts.
*/
export {};
//# sourceMappingURL=brainyDataInterface.js.map

1
dist/types/brainyDataInterface.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"brainyDataInterface.js","sourceRoot":"","sources":["../../src/types/brainyDataInterface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}

197
dist/types/distributedTypes.d.ts vendored Normal file
View file

@ -0,0 +1,197 @@
/**
* Distributed types for Brainy
* Defines types for distributed operations across multiple instances
*/
export type InstanceRole = 'reader' | 'writer' | 'hybrid';
export type PartitionStrategy = 'hash' | 'semantic' | 'manual';
export interface DistributedConfig {
/**
* Enable distributed mode
* Can be boolean for auto-detection or specific configuration
*/
enabled?: boolean | 'auto';
/**
* Role of this instance in the distributed system
* - reader: Read-only access, optimized for queries
* - writer: Write-focused, handles data ingestion
* - hybrid: Can both read and write (requires coordination)
*/
role?: InstanceRole;
/**
* Unique identifier for this instance
* Auto-generated if not provided
*/
instanceId?: string;
/**
* Path to shared configuration file in S3
* Default: '_brainy/config.json'
*/
configPath?: string;
/**
* Heartbeat interval in milliseconds
* Default: 30000 (30 seconds)
*/
heartbeatInterval?: number;
/**
* Config check interval in milliseconds
* Default: 10000 (10 seconds)
*/
configCheckInterval?: number;
/**
* Instance timeout in milliseconds
* Instances not seen for this duration are considered dead
* Default: 60000 (60 seconds)
*/
instanceTimeout?: number;
}
export interface SharedConfig {
/**
* Configuration version for compatibility checking
*/
version: number;
/**
* Last update timestamp
*/
updated: string;
/**
* Global settings that must be consistent across all instances
*/
settings: {
/**
* Partitioning strategy
* - hash: Deterministic hash-based partitioning (recommended for multi-writer)
* - semantic: Group similar vectors (single writer only)
* - manual: Explicit partition assignment
*/
partitionStrategy: PartitionStrategy;
/**
* Number of partitions (for hash strategy)
*/
partitionCount: number;
/**
* Embedding model name (must be consistent)
*/
embeddingModel: string;
/**
* Vector dimensions
*/
dimensions: number;
/**
* Distance metric
*/
distanceMetric: 'cosine' | 'euclidean' | 'manhattan';
/**
* HNSW parameters (must be consistent for index compatibility)
*/
hnswParams?: {
M: number;
efConstruction: number;
maxElements?: number;
};
};
/**
* Active instances in the distributed system
*/
instances: {
[instanceId: string]: InstanceInfo;
};
/**
* Partition assignments (for manual strategy)
*/
partitionAssignments?: {
[instanceId: string]: string[];
};
}
export interface InstanceInfo {
/**
* Instance role
*/
role: InstanceRole;
/**
* Instance status
*/
status: 'active' | 'inactive' | 'unhealthy';
/**
* Last heartbeat timestamp
*/
lastHeartbeat: string;
/**
* Optional endpoint for health checks
*/
endpoint?: string;
/**
* Instance metrics
*/
metrics?: {
vectorCount?: number;
cacheHitRate?: number;
memoryUsage?: number;
cpuUsage?: number;
};
/**
* Assigned partitions (for manual assignment)
*/
assignedPartitions?: string[];
/**
* Preferred partitions (for affinity)
*/
preferredPartitions?: number[];
}
export interface DomainMetadata {
/**
* Domain identifier for logical data separation
*/
domain?: string;
/**
* Additional domain-specific metadata
*/
domainMetadata?: Record<string, any>;
}
export interface CacheStrategy {
/**
* Percentage of memory allocated to hot cache (0-1)
*/
hotCacheRatio: number;
/**
* Enable aggressive prefetching
*/
prefetchAggressive?: boolean;
/**
* Cache time-to-live in milliseconds
*/
ttl?: number;
/**
* Enable compression to trade CPU for memory
*/
compressionEnabled?: boolean;
/**
* Write buffer size for batching
*/
writeBufferSize?: number;
/**
* Enable write batching
*/
batchWrites?: boolean;
/**
* Adaptive caching based on workload
*/
adaptive?: boolean;
}
export interface OperationalMode {
/**
* Whether this mode can read
*/
canRead: boolean;
/**
* Whether this mode can write
*/
canWrite: boolean;
/**
* Whether this mode can delete
*/
canDelete: boolean;
/**
* Cache strategy for this mode
*/
cacheStrategy: CacheStrategy;
}

6
dist/types/distributedTypes.js vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* Distributed types for Brainy
* Defines types for distributed operations across multiple instances
*/
export {};
//# sourceMappingURL=distributedTypes.js.map

1
dist/types/distributedTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"distributedTypes.js","sourceRoot":"","sources":["../../src/types/distributedTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG"}

6
dist/types/fileSystemTypes.d.ts vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* Type declarations for the File System Access API
* Extends the FileSystemDirectoryHandle interface to include the [Symbol.asyncIterator] method
* and FileSystemHandle to include getFile() method for TypeScript compatibility
*/
export declare const fileSystemTypesLoaded = true;

8
dist/types/fileSystemTypes.js vendored Normal file
View file

@ -0,0 +1,8 @@
/**
* Type declarations for the File System Access API
* Extends the FileSystemDirectoryHandle interface to include the [Symbol.asyncIterator] method
* and FileSystemHandle to include getFile() method for TypeScript compatibility
*/
// Export something to make this a module
export const fileSystemTypesLoaded = true;
//# sourceMappingURL=fileSystemTypes.js.map

1
dist/types/fileSystemTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"fileSystemTypes.js","sourceRoot":"","sources":["../../src/types/fileSystemTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,yCAAyC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAA"}

385
dist/types/graphTypes.d.ts vendored Normal file
View file

@ -0,0 +1,385 @@
/**
* Graph Types - Standardized Noun and Verb Type System
*
* This module defines a comprehensive, standardized set of noun and verb types
* that can be used to model any kind of graph, semantic network, or data model.
*
* ## Purpose and Design Philosophy
*
* The type system is designed to be:
* - **Universal**: Capable of representing any domain or use case
* - **Hierarchical**: Organized into logical categories for easy navigation
* - **Extensible**: Additional metadata can be attached to any entity or relationship
* - **Semantic**: Types carry meaning that can be used for reasoning and inference
*
* ## Noun Types (Entities)
*
* Noun types represent entities in the graph and are organized into categories:
*
* ### Core Entity Types
* - **Person**: Human entities and individuals
* - **Organization**: Formal organizations, companies, institutions
* - **Location**: Geographic locations, places, addresses
* - **Thing**: Physical objects and tangible items
* - **Concept**: Abstract ideas, concepts, and intangible entities
* - **Event**: Occurrences with time and place dimensions
*
* ### Digital/Content Types
* - **Document**: Text-based files and documents
* - **Media**: Non-text media files (images, videos, audio)
* - **File**: Generic digital files
* - **Message**: Communication content
* - **Content**: Generic content that doesn't fit other categories
*
* ### Collection Types
* - **Collection**: Generic groupings of items
* - **Dataset**: Structured collections of data
*
* ### Business/Application Types
* - **Product**: Commercial products and offerings
* - **Service**: Services and offerings
* - **User**: User accounts and profiles
* - **Task**: Actions, todos, and workflow items
* - **Project**: Organized initiatives with goals and timelines
*
* ### Descriptive Types
* - **Process**: Workflows, procedures, and sequences
* - **State**: States, conditions, or statuses
* - **Role**: Roles, positions, or responsibilities
* - **Topic**: Subjects or themes
* - **Language**: Languages or linguistic entities
* - **Currency**: Currencies and monetary units
* - **Measurement**: Measurements, metrics, or quantities
*
* ## Verb Types (Relationships)
*
* Verb types represent relationships between entities and are organized into categories:
*
* ### Core Relationship Types
* - **RelatedTo**: Generic relationship (default fallback)
* - **Contains**: Containment relationship
* - **PartOf**: Part-whole relationship
* - **LocatedAt**: Spatial relationship
* - **References**: Reference or citation relationship
*
* ### Temporal/Causal Types
* - **Precedes/Succeeds**: Temporal sequence relationships
* - **Causes**: Causal relationships
* - **DependsOn**: Dependency relationships
* - **Requires**: Necessity relationships
*
* ### Creation/Transformation Types
* - **Creates**: Creation relationships
* - **Transforms**: Transformation relationships
* - **Becomes**: State change relationships
* - **Modifies**: Modification relationships
* - **Consumes**: Consumption relationships
*
* ### Ownership/Attribution Types
* - **Owns**: Ownership relationships
* - **AttributedTo**: Attribution or authorship
* - **CreatedBy**: Creation attribution
* - **BelongsTo**: Belonging relationships
*
* ### Social/Organizational Types
* - **MemberOf**: Membership or affiliation
* - **WorksWith**: Professional relationships
* - **FriendOf**: Friendship relationships
* - **Follows**: Following relationships
* - **Likes**: Liking relationships
* - **ReportsTo**: Reporting relationships
* - **Supervises**: Supervisory relationships
* - **Mentors**: Mentorship relationships
* - **Communicates**: Communication relationships
*
* ### Descriptive/Functional Types
* - **Describes**: Descriptive relationships
* - **Defines**: Definition relationships
* - **Categorizes**: Categorization relationships
* - **Measures**: Measurement relationships
* - **Evaluates**: Evaluation or assessment relationships
* - **Uses**: Utilization relationships
* - **Implements**: Implementation relationships
* - **Extends**: Extension relationships
*
* ## Usage with Additional Metadata
*
* While the type system provides a standardized vocabulary, additional metadata
* can be attached to any entity or relationship to capture domain-specific
* information:
*
* ```typescript
* const person: GraphNoun = {
* id: 'person-123',
* noun: NounType.Person,
* data: {
* name: 'John Doe',
* age: 30,
* profession: 'Engineer'
* }
* }
*
* const worksFor: GraphVerb = {
* id: 'verb-456',
* source: 'person-123',
* target: 'org-789',
* verb: VerbType.MemberOf,
* data: {
* role: 'Senior Engineer',
* startDate: '2020-01-01',
* department: 'Engineering'
* }
* }
* ```
*
* ## Modeling Different Graph Types
*
* This type system can model various graph structures:
*
* ### Knowledge Graphs
* Use Person, Organization, Location, Concept entities with semantic relationships
* like AttributedTo, LocatedAt, RelatedTo
*
* ### Social Networks
* Use Person, User entities with social relationships like FriendOf, Follows,
* WorksWith, Communicates
*
* ### Content Networks
* Use Document, Media, Content entities with relationships like References,
* CreatedBy, Contains, Categorizes
*
* ### Business Process Models
* Use Task, Process, Role entities with relationships like Precedes, Requires,
* DependsOn, Transforms
*
* ### Organizational Charts
* Use Person, Role, Organization entities with relationships like ReportsTo,
* Supervises, MemberOf
*
* The flexibility of this system allows it to represent any domain while
* maintaining semantic consistency and enabling powerful graph operations
* and reasoning capabilities.
*/
/**
* Represents a high-precision timestamp with seconds and nanoseconds
* Used for tracking creation and update times of graph elements
*/
interface Timestamp {
seconds: number;
nanoseconds: number;
}
/**
* Metadata about the creator/source of a graph noun
* Tracks which augmentation and model created the element
*/
interface CreatorMetadata {
augmentation: string;
version: string;
}
/**
* Base interface for nodes (nouns) in the graph
* Represents entities like people, places, things, etc.
*/
export interface GraphNoun {
id: string;
createdBy: CreatorMetadata;
noun: NounType;
createdAt: Timestamp;
updatedAt: Timestamp;
label?: string;
data?: Record<string, any>;
embeddedVerbs?: EmbeddedGraphVerb[];
embedding?: number[];
}
/**
* Base interface for verbs in the graph
* Represents relationships between nouns
*/
export interface GraphVerb {
id: string;
source: string;
target: string;
label?: string;
verb: VerbType;
createdAt: Timestamp;
updatedAt: Timestamp;
createdBy: CreatorMetadata;
data?: Record<string, any>;
embedding?: number[];
confidence?: number;
weight?: number;
}
/**
* Version of GraphVerb for embedded relationships
* Used when the source is implicit from the parent document
*/
export type EmbeddedGraphVerb = Omit<GraphVerb, 'source'>;
/**
* Represents a person entity in the graph
*/
export interface Person extends GraphNoun {
noun: typeof NounType.Person;
}
/**
* Represents a physical location in the graph
*/
export interface Location extends GraphNoun {
noun: typeof NounType.Location;
}
/**
* Represents a physical or virtual object in the graph
*/
export interface Thing extends GraphNoun {
noun: typeof NounType.Thing;
}
/**
* Represents an event or occurrence in the graph
*/
export interface Event extends GraphNoun {
noun: typeof NounType.Event;
}
/**
* Represents an abstract concept or idea in the graph
*/
export interface Concept extends GraphNoun {
noun: typeof NounType.Concept;
}
export interface Collection extends GraphNoun {
noun: typeof NounType.Collection;
}
export interface Organization extends GraphNoun {
noun: typeof NounType.Organization;
}
export interface Document extends GraphNoun {
noun: typeof NounType.Document;
}
export interface Media extends GraphNoun {
noun: typeof NounType.Media;
}
export interface File extends GraphNoun {
noun: typeof NounType.File;
}
export interface Message extends GraphNoun {
noun: typeof NounType.Message;
}
export interface Dataset extends GraphNoun {
noun: typeof NounType.Dataset;
}
export interface Product extends GraphNoun {
noun: typeof NounType.Product;
}
export interface Service extends GraphNoun {
noun: typeof NounType.Service;
}
export interface User extends GraphNoun {
noun: typeof NounType.User;
}
export interface Task extends GraphNoun {
noun: typeof NounType.Task;
}
export interface Project extends GraphNoun {
noun: typeof NounType.Project;
}
export interface Process extends GraphNoun {
noun: typeof NounType.Process;
}
export interface State extends GraphNoun {
noun: typeof NounType.State;
}
export interface Role extends GraphNoun {
noun: typeof NounType.Role;
}
export interface Topic extends GraphNoun {
noun: typeof NounType.Topic;
}
export interface Language extends GraphNoun {
noun: typeof NounType.Language;
}
export interface Currency extends GraphNoun {
noun: typeof NounType.Currency;
}
export interface Measurement extends GraphNoun {
noun: typeof NounType.Measurement;
}
/**
* Represents content (text, media, etc.) in the graph
*/
export interface Content extends GraphNoun {
noun: typeof NounType.Content;
}
/**
* Defines valid noun types for graph entities
* Used for categorizing different types of nodes
*/
export declare const NounType: {
readonly Person: "person";
readonly Organization: "organization";
readonly Location: "location";
readonly Thing: "thing";
readonly Concept: "concept";
readonly Event: "event";
readonly Document: "document";
readonly Media: "media";
readonly File: "file";
readonly Message: "message";
readonly Content: "content";
readonly Collection: "collection";
readonly Dataset: "dataset";
readonly Product: "product";
readonly Service: "service";
readonly User: "user";
readonly Task: "task";
readonly Project: "project";
readonly Process: "process";
readonly State: "state";
readonly Role: "role";
readonly Topic: "topic";
readonly Language: "language";
readonly Currency: "currency";
readonly Measurement: "measurement";
};
export type NounType = (typeof NounType)[keyof typeof NounType];
/**
* Defines valid verb types for relationships
* Used for categorizing different types of connections
*/
export declare const VerbType: {
readonly RelatedTo: "relatedTo";
readonly Contains: "contains";
readonly PartOf: "partOf";
readonly LocatedAt: "locatedAt";
readonly References: "references";
readonly Precedes: "precedes";
readonly Succeeds: "succeeds";
readonly Causes: "causes";
readonly DependsOn: "dependsOn";
readonly Requires: "requires";
readonly Creates: "creates";
readonly Transforms: "transforms";
readonly Becomes: "becomes";
readonly Modifies: "modifies";
readonly Consumes: "consumes";
readonly Owns: "owns";
readonly AttributedTo: "attributedTo";
readonly CreatedBy: "createdBy";
readonly BelongsTo: "belongsTo";
readonly MemberOf: "memberOf";
readonly WorksWith: "worksWith";
readonly FriendOf: "friendOf";
readonly Follows: "follows";
readonly Likes: "likes";
readonly ReportsTo: "reportsTo";
readonly Supervises: "supervises";
readonly Mentors: "mentors";
readonly Communicates: "communicates";
readonly Describes: "describes";
readonly Defines: "defines";
readonly Categorizes: "categorizes";
readonly Measures: "measures";
readonly Evaluates: "evaluates";
readonly Uses: "uses";
readonly Implements: "implements";
readonly Extends: "extends";
};
export type VerbType = (typeof VerbType)[keyof typeof VerbType];
export {};

247
dist/types/graphTypes.js vendored Normal file
View file

@ -0,0 +1,247 @@
/**
* Graph Types - Standardized Noun and Verb Type System
*
* This module defines a comprehensive, standardized set of noun and verb types
* that can be used to model any kind of graph, semantic network, or data model.
*
* ## Purpose and Design Philosophy
*
* The type system is designed to be:
* - **Universal**: Capable of representing any domain or use case
* - **Hierarchical**: Organized into logical categories for easy navigation
* - **Extensible**: Additional metadata can be attached to any entity or relationship
* - **Semantic**: Types carry meaning that can be used for reasoning and inference
*
* ## Noun Types (Entities)
*
* Noun types represent entities in the graph and are organized into categories:
*
* ### Core Entity Types
* - **Person**: Human entities and individuals
* - **Organization**: Formal organizations, companies, institutions
* - **Location**: Geographic locations, places, addresses
* - **Thing**: Physical objects and tangible items
* - **Concept**: Abstract ideas, concepts, and intangible entities
* - **Event**: Occurrences with time and place dimensions
*
* ### Digital/Content Types
* - **Document**: Text-based files and documents
* - **Media**: Non-text media files (images, videos, audio)
* - **File**: Generic digital files
* - **Message**: Communication content
* - **Content**: Generic content that doesn't fit other categories
*
* ### Collection Types
* - **Collection**: Generic groupings of items
* - **Dataset**: Structured collections of data
*
* ### Business/Application Types
* - **Product**: Commercial products and offerings
* - **Service**: Services and offerings
* - **User**: User accounts and profiles
* - **Task**: Actions, todos, and workflow items
* - **Project**: Organized initiatives with goals and timelines
*
* ### Descriptive Types
* - **Process**: Workflows, procedures, and sequences
* - **State**: States, conditions, or statuses
* - **Role**: Roles, positions, or responsibilities
* - **Topic**: Subjects or themes
* - **Language**: Languages or linguistic entities
* - **Currency**: Currencies and monetary units
* - **Measurement**: Measurements, metrics, or quantities
*
* ## Verb Types (Relationships)
*
* Verb types represent relationships between entities and are organized into categories:
*
* ### Core Relationship Types
* - **RelatedTo**: Generic relationship (default fallback)
* - **Contains**: Containment relationship
* - **PartOf**: Part-whole relationship
* - **LocatedAt**: Spatial relationship
* - **References**: Reference or citation relationship
*
* ### Temporal/Causal Types
* - **Precedes/Succeeds**: Temporal sequence relationships
* - **Causes**: Causal relationships
* - **DependsOn**: Dependency relationships
* - **Requires**: Necessity relationships
*
* ### Creation/Transformation Types
* - **Creates**: Creation relationships
* - **Transforms**: Transformation relationships
* - **Becomes**: State change relationships
* - **Modifies**: Modification relationships
* - **Consumes**: Consumption relationships
*
* ### Ownership/Attribution Types
* - **Owns**: Ownership relationships
* - **AttributedTo**: Attribution or authorship
* - **CreatedBy**: Creation attribution
* - **BelongsTo**: Belonging relationships
*
* ### Social/Organizational Types
* - **MemberOf**: Membership or affiliation
* - **WorksWith**: Professional relationships
* - **FriendOf**: Friendship relationships
* - **Follows**: Following relationships
* - **Likes**: Liking relationships
* - **ReportsTo**: Reporting relationships
* - **Supervises**: Supervisory relationships
* - **Mentors**: Mentorship relationships
* - **Communicates**: Communication relationships
*
* ### Descriptive/Functional Types
* - **Describes**: Descriptive relationships
* - **Defines**: Definition relationships
* - **Categorizes**: Categorization relationships
* - **Measures**: Measurement relationships
* - **Evaluates**: Evaluation or assessment relationships
* - **Uses**: Utilization relationships
* - **Implements**: Implementation relationships
* - **Extends**: Extension relationships
*
* ## Usage with Additional Metadata
*
* While the type system provides a standardized vocabulary, additional metadata
* can be attached to any entity or relationship to capture domain-specific
* information:
*
* ```typescript
* const person: GraphNoun = {
* id: 'person-123',
* noun: NounType.Person,
* data: {
* name: 'John Doe',
* age: 30,
* profession: 'Engineer'
* }
* }
*
* const worksFor: GraphVerb = {
* id: 'verb-456',
* source: 'person-123',
* target: 'org-789',
* verb: VerbType.MemberOf,
* data: {
* role: 'Senior Engineer',
* startDate: '2020-01-01',
* department: 'Engineering'
* }
* }
* ```
*
* ## Modeling Different Graph Types
*
* This type system can model various graph structures:
*
* ### Knowledge Graphs
* Use Person, Organization, Location, Concept entities with semantic relationships
* like AttributedTo, LocatedAt, RelatedTo
*
* ### Social Networks
* Use Person, User entities with social relationships like FriendOf, Follows,
* WorksWith, Communicates
*
* ### Content Networks
* Use Document, Media, Content entities with relationships like References,
* CreatedBy, Contains, Categorizes
*
* ### Business Process Models
* Use Task, Process, Role entities with relationships like Precedes, Requires,
* DependsOn, Transforms
*
* ### Organizational Charts
* Use Person, Role, Organization entities with relationships like ReportsTo,
* Supervises, MemberOf
*
* The flexibility of this system allows it to represent any domain while
* maintaining semantic consistency and enabling powerful graph operations
* and reasoning capabilities.
*/
/**
* Defines valid noun types for graph entities
* Used for categorizing different types of nodes
*/
export const NounType = {
// Core Entity Types
Person: 'person', // Human entities
Organization: 'organization', // Formal organizations (companies, institutions, etc.)
Location: 'location', // Geographic locations (merges previous Place and Location)
Thing: 'thing', // Physical objects
Concept: 'concept', // Abstract ideas, concepts, and intangible entities
Event: 'event', // Occurrences with time and place
// Digital/Content Types
Document: 'document', // Text-based files and documents (reports, articles, etc.)
Media: 'media', // Non-text media files (images, videos, audio)
File: 'file', // Generic digital files (merges aspects of Digital with file-specific focus)
Message: 'message', // Communication content (emails, chat messages, posts)
Content: 'content', // Generic content that doesn't fit other categories
// Collection Types
Collection: 'collection', // Generic grouping of items (merges Group, List, and Category)
Dataset: 'dataset', // Structured collections of data
// Business/Application Types
Product: 'product', // Commercial products and offerings
Service: 'service', // Services and offerings
User: 'user', // User accounts and profiles
Task: 'task', // Actions, todos, and workflow items
Project: 'project', // Organized initiatives with goals and timelines
// Descriptive Types
Process: 'process', // Workflows, procedures, and sequences
State: 'state', // States, conditions, or statuses
Role: 'role', // Roles, positions, or responsibilities
Topic: 'topic', // Subjects or themes
Language: 'language', // Languages or linguistic entities
Currency: 'currency', // Currencies and monetary units
Measurement: 'measurement' // Measurements, metrics, or quantities
};
/**
* Defines valid verb types for relationships
* Used for categorizing different types of connections
*/
export const VerbType = {
// Core Relationship Types
RelatedTo: 'relatedTo', // Generic relationship (default fallback)
Contains: 'contains', // Containment relationship (parent contains child)
PartOf: 'partOf', // Part-whole relationship (child is part of parent)
LocatedAt: 'locatedAt', // Spatial relationship
References: 'references', // Reference or citation relationship
// Temporal/Causal Types
Precedes: 'precedes', // Temporal sequence (comes before)
Succeeds: 'succeeds', // Temporal sequence (comes after)
Causes: 'causes', // Causal relationship (merges Influences and Causes)
DependsOn: 'dependsOn', // Dependency relationship
Requires: 'requires', // Necessity relationship (new)
// Creation/Transformation Types
Creates: 'creates', // Creation relationship (merges Created and Produces)
Transforms: 'transforms', // Transformation relationship
Becomes: 'becomes', // State change relationship
Modifies: 'modifies', // Modification relationship
Consumes: 'consumes', // Consumption relationship
// Ownership/Attribution Types
Owns: 'owns', // Ownership relationship (merges Controls and Owns)
AttributedTo: 'attributedTo', // Attribution or authorship
CreatedBy: 'createdBy', // Creation attribution (new, distinct from Creates)
BelongsTo: 'belongsTo', // Belonging relationship (new)
// Social/Organizational Types
MemberOf: 'memberOf', // Membership or affiliation
WorksWith: 'worksWith', // Professional relationship
FriendOf: 'friendOf', // Friendship relationship
Follows: 'follows', // Following relationship
Likes: 'likes', // Liking relationship
ReportsTo: 'reportsTo', // Reporting relationship
Supervises: 'supervises', // Supervisory relationship
Mentors: 'mentors', // Mentorship relationship
Communicates: 'communicates', // Communication relationship (merges Communicates and Collaborates)
// Descriptive/Functional Types
Describes: 'describes', // Descriptive relationship
Defines: 'defines', // Definition relationship
Categorizes: 'categorizes', // Categorization relationship
Measures: 'measures', // Measurement relationship
Evaluates: 'evaluates', // Evaluation or assessment relationship
Uses: 'uses', // Utilization relationship (new)
Implements: 'implements', // Implementation relationship
Extends: 'extends' // Extension relationship (merges Extends and Inherits)
};
//# sourceMappingURL=graphTypes.js.map

1
dist/types/graphTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"graphTypes.js","sourceRoot":"","sources":["../../src/types/graphTypes.ts"],"names":[],"mappings":"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"}

139
dist/types/mcpTypes.d.ts vendored Normal file
View file

@ -0,0 +1,139 @@
/**
* Model Control Protocol (MCP) Types
*
* This file defines the types and interfaces for the Model Control Protocol (MCP)
* implementation in Brainy. MCP allows external models to access Brainy data and
* use the augmentation pipeline as tools.
*/
/**
* MCP version information
*/
export declare const MCP_VERSION = "1.0.0";
/**
* MCP request types
*/
export declare enum MCPRequestType {
DATA_ACCESS = "data_access",
TOOL_EXECUTION = "tool_execution",
SYSTEM_INFO = "system_info",
AUTHENTICATION = "authentication"
}
/**
* Base interface for all MCP requests
*/
export interface MCPRequest {
/** The type of request */
type: MCPRequestType;
/** Request ID for tracking and correlation */
requestId: string;
/** API version */
version: string;
/** Authentication token (if required) */
authToken?: string;
}
/**
* Interface for data access requests
*/
export interface MCPDataAccessRequest extends MCPRequest {
type: MCPRequestType.DATA_ACCESS;
/** The data access operation to perform */
operation: 'get' | 'search' | 'add' | 'getRelationships';
/** Parameters for the operation */
parameters: Record<string, any>;
}
/**
* Interface for tool execution requests
*/
export interface MCPToolExecutionRequest extends MCPRequest {
type: MCPRequestType.TOOL_EXECUTION;
/** The name of the tool to execute */
toolName: string;
/** Parameters for the tool */
parameters: Record<string, any>;
}
/**
* Interface for system info requests
*/
export interface MCPSystemInfoRequest extends MCPRequest {
type: MCPRequestType.SYSTEM_INFO;
/** The type of information to retrieve */
infoType: 'status' | 'availableTools' | 'version';
}
/**
* Interface for authentication requests
*/
export interface MCPAuthenticationRequest extends MCPRequest {
type: MCPRequestType.AUTHENTICATION;
/** The authentication credentials */
credentials: {
apiKey?: string;
username?: string;
password?: string;
};
}
/**
* Base interface for all MCP responses
*/
export interface MCPResponse {
/** Whether the request was successful */
success: boolean;
/** The request ID from the original request */
requestId: string;
/** API version */
version: string;
/** Response data (if successful) */
data?: any;
/** Error information (if unsuccessful) */
error?: {
code: string;
message: string;
details?: any;
};
}
/**
* Interface for MCP tool definitions
*/
export interface MCPTool {
/** The name of the tool */
name: string;
/** A description of what the tool does */
description: string;
/** The parameters the tool accepts */
parameters: {
type: 'object';
properties: Record<string, {
type: string;
description: string;
enum?: string[];
required?: boolean;
}>;
required: string[];
};
}
/**
* Configuration options for MCP services
*/
export interface MCPServiceOptions {
/** Port for the WebSocket server */
wsPort?: number;
/** Port for the REST server */
restPort?: number;
/** Whether to enable authentication */
enableAuth?: boolean;
/** API keys for authentication */
apiKeys?: string[];
/** Rate limiting configuration */
rateLimit?: {
/** Maximum number of requests per window */
maxRequests: number;
/** Time window in milliseconds */
windowMs: number;
};
/** CORS configuration for REST API */
cors?: {
/** Allowed origins */
origin: string | string[];
/** Whether to allow credentials */
credentials: boolean;
};
}

22
dist/types/mcpTypes.js vendored Normal file
View file

@ -0,0 +1,22 @@
/**
* Model Control Protocol (MCP) Types
*
* This file defines the types and interfaces for the Model Control Protocol (MCP)
* implementation in Brainy. MCP allows external models to access Brainy data and
* use the augmentation pipeline as tools.
*/
/**
* MCP version information
*/
export const MCP_VERSION = '1.0.0';
/**
* MCP request types
*/
export var MCPRequestType;
(function (MCPRequestType) {
MCPRequestType["DATA_ACCESS"] = "data_access";
MCPRequestType["TOOL_EXECUTION"] = "tool_execution";
MCPRequestType["SYSTEM_INFO"] = "system_info";
MCPRequestType["AUTHENTICATION"] = "authentication";
})(MCPRequestType || (MCPRequestType = {}));
//# sourceMappingURL=mcpTypes.js.map

1
dist/types/mcpTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"mcpTypes.js","sourceRoot":"","sources":["../../src/types/mcpTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,6CAA2B,CAAA;IAC3B,mDAAiC,CAAA;IACjC,6CAA2B,CAAA;IAC3B,mDAAiC,CAAA;AACnC,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}

111
dist/types/paginationTypes.d.ts vendored Normal file
View file

@ -0,0 +1,111 @@
/**
* Types for pagination and filtering in data retrieval operations
*/
/**
* Pagination options for data retrieval
*/
export interface PaginationOptions {
/**
* The number of items to skip (for offset-based pagination)
*/
offset?: number;
/**
* The maximum number of items to return
*/
limit?: number;
/**
* Token for cursor-based pagination (for continuing from a previous page)
*/
cursor?: string;
}
/**
* Filter options for noun retrieval
*/
export interface NounFilterOptions {
/**
* Filter by noun type
*/
nounType?: string | string[];
/**
* Filter by service
*/
service?: string | string[];
/**
* Filter by metadata fields (key-value pairs)
*/
metadata?: Record<string, any>;
/**
* Filter by creation date range
*/
createdAt?: {
from?: Date | number;
to?: Date | number;
};
/**
* Filter by update date range
*/
updatedAt?: {
from?: Date | number;
to?: Date | number;
};
}
/**
* Filter options for verb retrieval
*/
export interface VerbFilterOptions {
/**
* Filter by verb type
*/
verbType?: string | string[];
/**
* Filter by source noun ID
*/
sourceId?: string | string[];
/**
* Filter by target noun ID
*/
targetId?: string | string[];
/**
* Filter by service
*/
service?: string | string[];
/**
* Filter by metadata fields (key-value pairs)
*/
metadata?: Record<string, any>;
/**
* Filter by creation date range
*/
createdAt?: {
from?: Date | number;
to?: Date | number;
};
/**
* Filter by update date range
*/
updatedAt?: {
from?: Date | number;
to?: Date | number;
};
}
/**
* Result of a paginated query
*/
export interface PaginatedResult<T> {
/**
* The items for the current page
*/
items: T[];
/**
* The total number of items matching the query (may be estimated)
*/
totalCount?: number;
/**
* Whether there are more items available
*/
hasMore: boolean;
/**
* Cursor for fetching the next page (for cursor-based pagination)
*/
nextCursor?: string;
}

5
dist/types/paginationTypes.js vendored Normal file
View file

@ -0,0 +1,5 @@
/**
* Types for pagination and filtering in data retrieval operations
*/
export {};
//# sourceMappingURL=paginationTypes.js.map

1
dist/types/paginationTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"paginationTypes.js","sourceRoot":"","sources":["../../src/types/paginationTypes.ts"],"names":[],"mappings":"AAAA;;GAEG"}

26
dist/types/pipelineTypes.d.ts vendored Normal file
View file

@ -0,0 +1,26 @@
/**
* Pipeline Types
*
* This module provides shared types for the pipeline system to avoid circular dependencies.
*/
import { BrainyAugmentations, IWebSocketSupport, IAugmentation } from './augmentations.js';
/**
* Type definitions for the augmentation registry
*/
export type AugmentationRegistry = {
sense: BrainyAugmentations.ISenseAugmentation[];
conduit: BrainyAugmentations.IConduitAugmentation[];
cognition: BrainyAugmentations.ICognitionAugmentation[];
memory: BrainyAugmentations.IMemoryAugmentation[];
perception: BrainyAugmentations.IPerceptionAugmentation[];
dialog: BrainyAugmentations.IDialogAugmentation[];
activation: BrainyAugmentations.IActivationAugmentation[];
webSocket: IWebSocketSupport[];
};
/**
* Interface for the Pipeline class
* This is used to break circular dependencies between pipeline.ts and augmentationRegistry.ts
*/
export interface IPipeline {
register<T extends IAugmentation>(augmentation: T): IPipeline;
}

7
dist/types/pipelineTypes.js vendored Normal file
View file

@ -0,0 +1,7 @@
/**
* Pipeline Types
*
* This module provides shared types for the pipeline system to avoid circular dependencies.
*/
export {};
//# sourceMappingURL=pipelineTypes.js.map

1
dist/types/pipelineTypes.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"pipelineTypes.js","sourceRoot":"","sources":["../../src/types/pipelineTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}