@mzhub/cortex 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +0 -0
  2. package/dist/{BaseAdapter-WunbfD_n.d.ts → BaseAdapter-BcNZrPzG.d.ts} +1 -1
  3. package/dist/{BaseAdapter-Bjj4JG_S.d.mts → BaseAdapter-CH2Gg9xO.d.mts} +1 -1
  4. package/dist/BaseProvider-8dmLKPhr.d.mts +61 -0
  5. package/dist/BaseProvider-DgYEmkh_.d.ts +61 -0
  6. package/dist/adapters/index.d.mts +4 -4
  7. package/dist/adapters/index.d.ts +4 -4
  8. package/dist/adapters/index.js +9 -1
  9. package/dist/adapters/index.js.map +1 -1
  10. package/dist/adapters/index.mjs +9 -1
  11. package/dist/adapters/index.mjs.map +1 -1
  12. package/dist/{index-DnOyj7gs.d.ts → index-BHvGS1BY.d.mts} +14 -10
  13. package/dist/{index-C_w3EJQT.d.mts → index-CA79C0tz.d.ts} +14 -10
  14. package/dist/index.d.mts +16 -13
  15. package/dist/index.d.ts +16 -13
  16. package/dist/index.js +277 -135
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +277 -135
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/middleware/index.d.mts +4 -4
  21. package/dist/middleware/index.d.ts +4 -4
  22. package/dist/middleware/index.js +0 -0
  23. package/dist/middleware/index.js.map +1 -1
  24. package/dist/middleware/index.mjs +0 -0
  25. package/dist/middleware/index.mjs.map +1 -1
  26. package/dist/providers/index.d.mts +2 -2
  27. package/dist/providers/index.d.ts +2 -2
  28. package/dist/providers/index.js +72 -17
  29. package/dist/providers/index.js.map +1 -1
  30. package/dist/providers/index.mjs +72 -17
  31. package/dist/providers/index.mjs.map +1 -1
  32. package/dist/{types-DybcUhEZ.d.mts → types-DUn4u5hk.d.mts} +1 -1
  33. package/dist/{types-DybcUhEZ.d.ts → types-DUn4u5hk.d.ts} +1 -1
  34. package/logo.png +0 -0
  35. package/package.json +20 -19
  36. package/dist/BaseProvider-B8x1pJXP.d.mts +0 -34
  37. package/dist/BaseProvider-BIkJVjtg.d.ts +0 -34
@@ -1,6 +1,6 @@
1
- import { P as ProviderConfig, c as MemoryOSOptions, H as HydrateOptions, d as HydratedContext, E as ExtractionResult, F as FactFilter, M as MemoryFact, S as Session, C as ConversationExchange } from './types-DybcUhEZ.js';
2
- import { B as BaseAdapter } from './BaseAdapter-WunbfD_n.js';
3
- import { B as BaseProvider } from './BaseProvider-BIkJVjtg.js';
1
+ import { P as ProviderConfig, c as MemoryOSOptions, H as HydrateOptions, d as HydratedContext, E as ExtractionResult, F as FactFilter, M as MemoryFact, S as Session, C as ConversationExchange } from './types-DUn4u5hk.mjs';
2
+ import { B as BaseAdapter } from './BaseAdapter-CH2Gg9xO.mjs';
3
+ import { B as BaseProvider } from './BaseProvider-8dmLKPhr.mjs';
4
4
 
5
5
  interface MemoryOSConfig {
6
6
  /** LLM provider configuration or instance */
@@ -21,12 +21,12 @@ interface MemoryOSConfig {
21
21
  *
22
22
  * @example
23
23
  * ```typescript
24
- * import { MemoryOS } from 'mem-ts';
25
- * import { JSONFileAdapter } from 'mem-ts/adapters';
24
+ * import { MemoryOS } from 'cortex';
25
+ * import { JSONFileAdapter } from 'cortex/adapters';
26
26
  *
27
27
  * const memory = new MemoryOS({
28
28
  * llm: { provider: 'openai', apiKey: 'sk-...', model: 'gpt-4o-mini' },
29
- * adapter: new JSONFileAdapter({ path: './.mem-ts' })
29
+ * adapter: new JSONFileAdapter({ path: './.cortex' })
30
30
  * });
31
31
  *
32
32
  * // Before LLM call - get context
@@ -45,6 +45,10 @@ declare class MemoryOS {
45
45
  private initialized;
46
46
  private activeSessions;
47
47
  constructor(config: MemoryOSConfig);
48
+ /**
49
+ * Validate configuration at construction time for fail-fast behavior
50
+ */
51
+ private validateConfig;
48
52
  /**
49
53
  * Initialize the memory system (connects to storage, etc.)
50
54
  */
@@ -223,8 +227,8 @@ declare global {
223
227
  * @example
224
228
  * ```typescript
225
229
  * import express from 'express';
226
- * import { MemoryOS } from 'mem-ts';
227
- * import { createMemoryMiddleware } from 'mem-ts/middleware';
230
+ * import { MemoryOS } from 'cortex';
231
+ * import { createMemoryMiddleware } from 'cortex/middleware';
228
232
  *
229
233
  * const app = express();
230
234
  * const memory = new MemoryOS({ ... });
@@ -263,7 +267,7 @@ declare function digestAfterResponse(memory: MemoryOS, userId: string, userMessa
263
267
  * @example
264
268
  * ```typescript
265
269
  * // pages/api/chat.ts or app/api/chat/route.ts
266
- * import { withMemory } from 'mem-ts/middleware';
270
+ * import { withMemory } from 'cortex/middleware';
267
271
  *
268
272
  * export const POST = withMemory(memory, async (req, context) => {
269
273
  * const { message } = await req.json();
@@ -286,4 +290,4 @@ declare function withMemory<T extends {
286
290
  }) => string | undefined;
287
291
  }): (req: T) => Promise<Response>;
288
292
 
289
- export { MemoryOS as M, type NextFunction as N, type MemoryOSConfig as a, type MemoryMiddlewareOptions as b, createMemoryMiddleware as c, digestAfterResponse as d, type MiddlewareRequest as e, type MiddlewareResponse as f, withMemory as w };
293
+ export { type MemoryMiddlewareOptions as M, type NextFunction as N, MemoryOS as a, type MemoryOSConfig as b, createMemoryMiddleware as c, digestAfterResponse as d, type MiddlewareRequest as e, type MiddlewareResponse as f, withMemory as w };
@@ -1,6 +1,6 @@
1
- import { P as ProviderConfig, c as MemoryOSOptions, H as HydrateOptions, d as HydratedContext, E as ExtractionResult, F as FactFilter, M as MemoryFact, S as Session, C as ConversationExchange } from './types-DybcUhEZ.mjs';
2
- import { B as BaseAdapter } from './BaseAdapter-Bjj4JG_S.mjs';
3
- import { B as BaseProvider } from './BaseProvider-B8x1pJXP.mjs';
1
+ import { P as ProviderConfig, c as MemoryOSOptions, H as HydrateOptions, d as HydratedContext, E as ExtractionResult, F as FactFilter, M as MemoryFact, S as Session, C as ConversationExchange } from './types-DUn4u5hk.js';
2
+ import { B as BaseAdapter } from './BaseAdapter-BcNZrPzG.js';
3
+ import { B as BaseProvider } from './BaseProvider-DgYEmkh_.js';
4
4
 
5
5
  interface MemoryOSConfig {
6
6
  /** LLM provider configuration or instance */
@@ -21,12 +21,12 @@ interface MemoryOSConfig {
21
21
  *
22
22
  * @example
23
23
  * ```typescript
24
- * import { MemoryOS } from 'mem-ts';
25
- * import { JSONFileAdapter } from 'mem-ts/adapters';
24
+ * import { MemoryOS } from 'cortex';
25
+ * import { JSONFileAdapter } from 'cortex/adapters';
26
26
  *
27
27
  * const memory = new MemoryOS({
28
28
  * llm: { provider: 'openai', apiKey: 'sk-...', model: 'gpt-4o-mini' },
29
- * adapter: new JSONFileAdapter({ path: './.mem-ts' })
29
+ * adapter: new JSONFileAdapter({ path: './.cortex' })
30
30
  * });
31
31
  *
32
32
  * // Before LLM call - get context
@@ -45,6 +45,10 @@ declare class MemoryOS {
45
45
  private initialized;
46
46
  private activeSessions;
47
47
  constructor(config: MemoryOSConfig);
48
+ /**
49
+ * Validate configuration at construction time for fail-fast behavior
50
+ */
51
+ private validateConfig;
48
52
  /**
49
53
  * Initialize the memory system (connects to storage, etc.)
50
54
  */
@@ -223,8 +227,8 @@ declare global {
223
227
  * @example
224
228
  * ```typescript
225
229
  * import express from 'express';
226
- * import { MemoryOS } from 'mem-ts';
227
- * import { createMemoryMiddleware } from 'mem-ts/middleware';
230
+ * import { MemoryOS } from 'cortex';
231
+ * import { createMemoryMiddleware } from 'cortex/middleware';
228
232
  *
229
233
  * const app = express();
230
234
  * const memory = new MemoryOS({ ... });
@@ -263,7 +267,7 @@ declare function digestAfterResponse(memory: MemoryOS, userId: string, userMessa
263
267
  * @example
264
268
  * ```typescript
265
269
  * // pages/api/chat.ts or app/api/chat/route.ts
266
- * import { withMemory } from 'mem-ts/middleware';
270
+ * import { withMemory } from 'cortex/middleware';
267
271
  *
268
272
  * export const POST = withMemory(memory, async (req, context) => {
269
273
  * const { message } = await req.json();
@@ -286,4 +290,4 @@ declare function withMemory<T extends {
286
290
  }) => string | undefined;
287
291
  }): (req: T) => Promise<Response>;
288
292
 
289
- export { MemoryOS as M, type NextFunction as N, type MemoryOSConfig as a, type MemoryMiddlewareOptions as b, createMemoryMiddleware as c, digestAfterResponse as d, type MiddlewareRequest as e, type MiddlewareResponse as f, withMemory as w };
293
+ export { type MemoryMiddlewareOptions as M, type NextFunction as N, MemoryOS as a, type MemoryOSConfig as b, createMemoryMiddleware as c, digestAfterResponse as d, type MiddlewareRequest as e, type MiddlewareResponse as f, withMemory as w };
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- export { b as MemoryMiddlewareOptions, M as MemoryOS, a as MemoryOSConfig, c as createMemoryMiddleware, d as digestAfterResponse, w as withMemory } from './index-C_w3EJQT.mjs';
2
- import { f as MemoryOperation, M as MemoryFact, E as ExtractionResult, H as HydrateOptions, d as HydratedContext, S as Session, F as FactFilter, C as ConversationExchange } from './types-DybcUhEZ.mjs';
3
- export { a as CompletionOptions, b as CompletionResult, h as MemoryOSEvents, c as MemoryOSOptions, g as Message, P as ProviderConfig, e as ProviderName } from './types-DybcUhEZ.mjs';
4
- import { B as BaseAdapter } from './BaseAdapter-Bjj4JG_S.mjs';
1
+ export { M as MemoryMiddlewareOptions, a as MemoryOS, b as MemoryOSConfig, c as createMemoryMiddleware, d as digestAfterResponse, w as withMemory } from './index-BHvGS1BY.mjs';
2
+ import { f as MemoryOperation, M as MemoryFact, E as ExtractionResult, H as HydrateOptions, d as HydratedContext, S as Session, F as FactFilter, C as ConversationExchange } from './types-DUn4u5hk.mjs';
3
+ export { a as CompletionOptions, b as CompletionResult, g as MemoryOSEvents, c as MemoryOSOptions, h as Message, P as ProviderConfig, e as ProviderName } from './types-DUn4u5hk.mjs';
4
+ import { B as BaseAdapter } from './BaseAdapter-CH2Gg9xO.mjs';
5
5
  export { InMemoryAdapter, JSONFileAdapter, JSONFileAdapterConfig, MongoDBAdapter, MongoDBAdapterConfig, PostgresAdapter, PostgresAdapterConfig, UpstashRedisAdapter, UpstashRedisAdapterConfig } from './adapters/index.mjs';
6
6
  export { AnthropicProvider, CerebrasProvider, GeminiProvider, GroqProvider, OpenAIProvider, createProvider, getAvailableProviders } from './providers/index.mjs';
7
- import { B as BaseProvider } from './BaseProvider-B8x1pJXP.mjs';
7
+ import { B as BaseProvider } from './BaseProvider-8dmLKPhr.mjs';
8
8
 
9
9
  interface ConflictResolutionResult {
10
10
  /** Operations to apply after conflict resolution */
@@ -40,6 +40,8 @@ interface ExtractorWorkerConfig {
40
40
  minConfidence?: number;
41
41
  /** Conflict resolution strategy */
42
42
  conflictStrategy?: ConflictStrategy;
43
+ /** Maximum operations per extraction (default: 10, prevents memory bombs) */
44
+ maxOperationsPerExtraction?: number;
43
45
  /** Enable debug logging */
44
46
  debug?: boolean;
45
47
  }
@@ -52,6 +54,7 @@ declare class ExtractorWorker {
52
54
  private adapter;
53
55
  private conflictResolver;
54
56
  private minConfidence;
57
+ private maxOperationsPerExtraction;
55
58
  private debug;
56
59
  private queue;
57
60
  private processing;
@@ -210,7 +213,7 @@ declare class SemanticCache {
210
213
  }
211
214
 
212
215
  /**
213
- * Token economics utilities for mem-ts.
216
+ * Token economics utilities for cortex.
214
217
  * Provides token estimation, compression, and analytics.
215
218
  */
216
219
  /**
@@ -396,7 +399,7 @@ declare class MemoryEventEmitter {
396
399
  }
397
400
 
398
401
  /**
399
- * Security utilities for mem-ts.
402
+ * Security utilities for cortex.
400
403
  * Protects against prompt injection and data poisoning.
401
404
  */
402
405
  interface SecurityConfig {
@@ -450,7 +453,7 @@ declare function wrapContextSafely(context: string): string;
450
453
  declare function sanitizeForStorage(text: string): string;
451
454
 
452
455
  /**
453
- * Budget management for mem-ts.
456
+ * Budget management for cortex.
454
457
  * Prevents runaway costs from infinite loops or abuse.
455
458
  */
456
459
  interface BudgetConfig {
@@ -527,7 +530,7 @@ declare class BudgetManager {
527
530
  }
528
531
 
529
532
  /**
530
- * Memory decay utilities for mem-ts.
533
+ * Memory decay utilities for cortex.
531
534
  * Prevents the "stalker effect" by forgetting irrelevant facts over time.
532
535
  */
533
536
 
@@ -602,7 +605,7 @@ declare class DecayManager {
602
605
  }
603
606
 
604
607
  /**
605
- * Auto-summarization manager for mem-ts.
608
+ * Auto-summarization manager for cortex.
606
609
  * Triggers conversation summarization after a threshold of messages.
607
610
  */
608
611
 
@@ -714,7 +717,7 @@ declare class TieredAdapter extends BaseAdapter {
714
717
  }
715
718
 
716
719
  /**
717
- * Embeddings support for mem-ts.
720
+ * Embeddings support for cortex.
718
721
  * Provides vector embeddings for semantic search.
719
722
  */
720
723
  interface EmbeddingConfig {
@@ -1125,7 +1128,7 @@ declare class PredictiveEngine {
1125
1128
  * - Ephemeral conversation buffer
1126
1129
  * - Auto-flushed after extraction
1127
1130
  *
1128
- * This is an OPTIONAL wrapper - you can use mem-ts without HMM.
1131
+ * This is an OPTIONAL wrapper - you can use cortex without HMM.
1129
1132
  */
1130
1133
 
1131
1134
  type MemoryLevel = "raw_log" | "fact" | "pattern" | "core_belief";
@@ -1142,7 +1145,7 @@ interface HierarchicalConfig {
1142
1145
  debug?: boolean;
1143
1146
  }
1144
1147
  /**
1145
- * Hierarchical Memory Manager - Optional HMM mode for mem-ts
1148
+ * Hierarchical Memory Manager - Optional HMM mode for cortex
1146
1149
  */
1147
1150
  declare class HierarchicalMemory {
1148
1151
  private adapter;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { b as MemoryMiddlewareOptions, M as MemoryOS, a as MemoryOSConfig, c as createMemoryMiddleware, d as digestAfterResponse, w as withMemory } from './index-DnOyj7gs.js';
2
- import { f as MemoryOperation, M as MemoryFact, E as ExtractionResult, H as HydrateOptions, d as HydratedContext, S as Session, F as FactFilter, C as ConversationExchange } from './types-DybcUhEZ.js';
3
- export { a as CompletionOptions, b as CompletionResult, h as MemoryOSEvents, c as MemoryOSOptions, g as Message, P as ProviderConfig, e as ProviderName } from './types-DybcUhEZ.js';
4
- import { B as BaseAdapter } from './BaseAdapter-WunbfD_n.js';
1
+ export { M as MemoryMiddlewareOptions, a as MemoryOS, b as MemoryOSConfig, c as createMemoryMiddleware, d as digestAfterResponse, w as withMemory } from './index-CA79C0tz.js';
2
+ import { f as MemoryOperation, M as MemoryFact, E as ExtractionResult, H as HydrateOptions, d as HydratedContext, S as Session, F as FactFilter, C as ConversationExchange } from './types-DUn4u5hk.js';
3
+ export { a as CompletionOptions, b as CompletionResult, g as MemoryOSEvents, c as MemoryOSOptions, h as Message, P as ProviderConfig, e as ProviderName } from './types-DUn4u5hk.js';
4
+ import { B as BaseAdapter } from './BaseAdapter-BcNZrPzG.js';
5
5
  export { InMemoryAdapter, JSONFileAdapter, JSONFileAdapterConfig, MongoDBAdapter, MongoDBAdapterConfig, PostgresAdapter, PostgresAdapterConfig, UpstashRedisAdapter, UpstashRedisAdapterConfig } from './adapters/index.js';
6
6
  export { AnthropicProvider, CerebrasProvider, GeminiProvider, GroqProvider, OpenAIProvider, createProvider, getAvailableProviders } from './providers/index.js';
7
- import { B as BaseProvider } from './BaseProvider-BIkJVjtg.js';
7
+ import { B as BaseProvider } from './BaseProvider-DgYEmkh_.js';
8
8
 
9
9
  interface ConflictResolutionResult {
10
10
  /** Operations to apply after conflict resolution */
@@ -40,6 +40,8 @@ interface ExtractorWorkerConfig {
40
40
  minConfidence?: number;
41
41
  /** Conflict resolution strategy */
42
42
  conflictStrategy?: ConflictStrategy;
43
+ /** Maximum operations per extraction (default: 10, prevents memory bombs) */
44
+ maxOperationsPerExtraction?: number;
43
45
  /** Enable debug logging */
44
46
  debug?: boolean;
45
47
  }
@@ -52,6 +54,7 @@ declare class ExtractorWorker {
52
54
  private adapter;
53
55
  private conflictResolver;
54
56
  private minConfidence;
57
+ private maxOperationsPerExtraction;
55
58
  private debug;
56
59
  private queue;
57
60
  private processing;
@@ -210,7 +213,7 @@ declare class SemanticCache {
210
213
  }
211
214
 
212
215
  /**
213
- * Token economics utilities for mem-ts.
216
+ * Token economics utilities for cortex.
214
217
  * Provides token estimation, compression, and analytics.
215
218
  */
216
219
  /**
@@ -396,7 +399,7 @@ declare class MemoryEventEmitter {
396
399
  }
397
400
 
398
401
  /**
399
- * Security utilities for mem-ts.
402
+ * Security utilities for cortex.
400
403
  * Protects against prompt injection and data poisoning.
401
404
  */
402
405
  interface SecurityConfig {
@@ -450,7 +453,7 @@ declare function wrapContextSafely(context: string): string;
450
453
  declare function sanitizeForStorage(text: string): string;
451
454
 
452
455
  /**
453
- * Budget management for mem-ts.
456
+ * Budget management for cortex.
454
457
  * Prevents runaway costs from infinite loops or abuse.
455
458
  */
456
459
  interface BudgetConfig {
@@ -527,7 +530,7 @@ declare class BudgetManager {
527
530
  }
528
531
 
529
532
  /**
530
- * Memory decay utilities for mem-ts.
533
+ * Memory decay utilities for cortex.
531
534
  * Prevents the "stalker effect" by forgetting irrelevant facts over time.
532
535
  */
533
536
 
@@ -602,7 +605,7 @@ declare class DecayManager {
602
605
  }
603
606
 
604
607
  /**
605
- * Auto-summarization manager for mem-ts.
608
+ * Auto-summarization manager for cortex.
606
609
  * Triggers conversation summarization after a threshold of messages.
607
610
  */
608
611
 
@@ -714,7 +717,7 @@ declare class TieredAdapter extends BaseAdapter {
714
717
  }
715
718
 
716
719
  /**
717
- * Embeddings support for mem-ts.
720
+ * Embeddings support for cortex.
718
721
  * Provides vector embeddings for semantic search.
719
722
  */
720
723
  interface EmbeddingConfig {
@@ -1125,7 +1128,7 @@ declare class PredictiveEngine {
1125
1128
  * - Ephemeral conversation buffer
1126
1129
  * - Auto-flushed after extraction
1127
1130
  *
1128
- * This is an OPTIONAL wrapper - you can use mem-ts without HMM.
1131
+ * This is an OPTIONAL wrapper - you can use cortex without HMM.
1129
1132
  */
1130
1133
 
1131
1134
  type MemoryLevel = "raw_log" | "fact" | "pattern" | "core_belief";
@@ -1142,7 +1145,7 @@ interface HierarchicalConfig {
1142
1145
  debug?: boolean;
1143
1146
  }
1144
1147
  /**
1145
- * Hierarchical Memory Manager - Optional HMM mode for mem-ts
1148
+ * Hierarchical Memory Manager - Optional HMM mode for cortex
1146
1149
  */
1147
1150
  declare class HierarchicalMemory {
1148
1151
  private adapter;