@revealui/ai 0.1.2 → 0.2.0

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 (44) hide show
  1. package/README.md +3 -0
  2. package/dist/ingestion/pipeline.d.ts +2 -1
  3. package/dist/ingestion/pipeline.d.ts.map +1 -1
  4. package/dist/ingestion/pipeline.js +10 -5
  5. package/dist/llm/client.d.ts +12 -2
  6. package/dist/llm/client.d.ts.map +1 -1
  7. package/dist/llm/client.js +46 -6
  8. package/dist/llm/providers/anthropic.d.ts.map +1 -1
  9. package/dist/llm/providers/anthropic.js +17 -3
  10. package/dist/llm/providers/base.d.ts +28 -1
  11. package/dist/llm/providers/base.d.ts.map +1 -1
  12. package/dist/llm/providers/bitnet.d.ts +28 -0
  13. package/dist/llm/providers/bitnet.d.ts.map +1 -0
  14. package/dist/llm/providers/bitnet.js +36 -0
  15. package/dist/llm/providers/inference-snaps.d.ts +44 -0
  16. package/dist/llm/providers/inference-snaps.d.ts.map +1 -0
  17. package/dist/llm/providers/inference-snaps.js +65 -0
  18. package/dist/llm/providers/openai.d.ts.map +1 -1
  19. package/dist/llm/providers/openai.js +2 -0
  20. package/dist/llm/semantic-cache.d.ts.map +1 -1
  21. package/dist/llm/semantic-cache.js +13 -5
  22. package/dist/llm/server.d.ts +2 -0
  23. package/dist/llm/server.d.ts.map +1 -1
  24. package/dist/llm/server.js +2 -0
  25. package/dist/memory/persistence/crdt-persistence.d.ts.map +1 -1
  26. package/dist/memory/persistence/crdt-persistence.js +2 -1
  27. package/dist/memory/preferences/user-preferences-manager.d.ts.map +1 -1
  28. package/dist/memory/preferences/user-preferences-manager.js +10 -9
  29. package/dist/memory/stores/episodic-memory.d.ts.map +1 -1
  30. package/dist/memory/stores/episodic-memory.js +2 -1
  31. package/dist/memory/utils/index.d.ts +0 -1
  32. package/dist/memory/utils/index.d.ts.map +1 -1
  33. package/dist/memory/utils/index.js +0 -1
  34. package/dist/memory/vector/vector-memory-service.d.ts +3 -0
  35. package/dist/memory/vector/vector-memory-service.d.ts.map +1 -1
  36. package/dist/memory/vector/vector-memory-service.js +18 -5
  37. package/dist/skills/loader/github-loader.d.ts.map +1 -1
  38. package/dist/skills/loader/github-loader.js +27 -16
  39. package/dist/skills/loader/vercel-loader.d.ts.map +1 -1
  40. package/dist/skills/loader/vercel-loader.js +26 -16
  41. package/package.json +16 -9
  42. package/dist/memory/utils/logger.d.ts +0 -21
  43. package/dist/memory/utils/logger.d.ts.map +0 -1
  44. package/dist/memory/utils/logger.js +0 -62
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/llm/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAA;AAG3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/llm/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAA;AAG3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
@@ -9,7 +9,9 @@ export * from './client.js';
9
9
  // Export provider implementations
10
10
  export * from './providers/anthropic.js';
11
11
  export * from './providers/base.js';
12
+ export * from './providers/bitnet.js';
12
13
  export * from './providers/groq.js';
14
+ export * from './providers/inference-snaps.js';
13
15
  export * from './providers/ollama.js';
14
16
  export * from './providers/openai.js';
15
17
  export * from './providers/vultr.js';
@@ -1 +1 @@
1
- {"version":3,"file":"crdt-persistence.d.ts","s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AAM,EAAE,MAAM,GACb,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC;CAyBvF"}
@@ -5,7 +5,8 @@
5
5
  * Supports both state-based (JSONB) and operation-based (operations log) storage.
6
6
  */
7
7
  import { randomUUID } from 'node:crypto';
8
- import { agentContexts, and, crdtOperations, eq, gte } from '@revealui/db/schema';
8
+ import { and, eq, gte } from 'drizzle-orm';
9
+ import { agentContexts, crdtOperations } from '@revealui/db/schema';
9
10
  import { findAgentContextById } from '../utils/sql-helpers.js';
10
11
  // =============================================================================
11
12
  // CRDT Persistence
@@ -1 +1 @@
1
- {"version":3,"file":"user-preferences-manager.d.ts","sourceRoot":"","sources":["../../../src/memory/preferences/user-preferences-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAgB3E;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,EAAE,CAAU;IACpB,OAAO,CAAC,MAAM,CAAoC;IAElD;;;;;;OAMG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ;IAcxD;;;;OAIG;IACH,cAAc,IAAI,eAAe;IAIjC;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAsB1D;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;IAUlD;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAgBnC;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAiChD;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB;IAM5D;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiF3B;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6E3B;;;;OAIG;IACH,MAAM,IAAI,eAAe,CAAC,eAAe,CAAC;IAI1C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,QAAQ,GACX,sBAAsB;IAMzB;;;;OAIG;IACH,KAAK,IAAI,sBAAsB;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
1
+ {"version":3,"file":"user-preferences-manager.d.ts","sourceRoot":"","sources":["../../../src/memory/preferences/user-preferences-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAgB3E;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,EAAE,CAAU;IACpB,OAAO,CAAC,MAAM,CAAiD;IAE/D;;;;;;OAMG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ;IAcxD;;;;OAIG;IACH,cAAc,IAAI,eAAe;IAIjC;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAsB1D;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;IAUlD;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAgBnC;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAiChD;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB;IAM5D;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAoF3B;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgF3B;;;;OAIG;IACH,MAAM,IAAI,eAAe,CAAC,eAAe,CAAC;IAI1C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,QAAQ,GACX,sBAAsB;IAMzB;;;;OAIG;IACH,KAAK,IAAI,sBAAsB;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
@@ -5,11 +5,12 @@
5
5
  * from multiple devices. Uses LWWRegister for last-writer-wins semantics.
6
6
  */
7
7
  import { UserPreferencesSchema } from '@revealui/contracts/entities';
8
- import { eq, users } from '@revealui/db/schema';
8
+ import { eq } from 'drizzle-orm';
9
+ import { users } from '@revealui/db/schema';
9
10
  import { LWWRegister } from '../crdt/lww-register.js';
10
11
  import { DatabaseConnectionError, DatabaseConstraintError, DatabaseOperationError, NotFoundError, ValidationError, } from '../errors/index.js';
11
12
  import { deepClone } from '../utils/deep-clone.js';
12
- import { createLogger } from '../utils/logger.js';
13
+ import { createLogger } from '@revealui/core/observability/logger';
13
14
  import { findUserById } from '../utils/sql-helpers.js';
14
15
  // =============================================================================
15
16
  // User Preferences Manager
@@ -36,7 +37,7 @@ export class UserPreferencesManager {
36
37
  userId;
37
38
  nodeId;
38
39
  db;
39
- logger = createLogger('[UserPreferences]');
40
+ logger = createLogger({ component: 'UserPreferences' });
40
41
  /**
41
42
  * Creates a new UserPreferencesManager.
42
43
  *
@@ -217,18 +218,18 @@ export class UserPreferencesManager {
217
218
  errorMessage.includes('timeout') ||
218
219
  errorMessage.includes('econnrefused') ||
219
220
  errorMessage.includes('connect econnrefused')) {
220
- this.logger.error(`Database connection error loading preferences for user ${this.userId}:`, error);
221
+ this.logger.error(`Database connection error loading preferences for user ${this.userId}`, error);
221
222
  throw new DatabaseConnectionError('Failed to load user preferences', error);
222
223
  }
223
224
  if (errorMessage.includes('violates') ||
224
225
  errorMessage.includes('constraint') ||
225
226
  errorMessage.includes('foreign key')) {
226
- this.logger.error(`Database constraint error loading preferences for user ${this.userId}:`, error);
227
+ this.logger.error(`Database constraint error loading preferences for user ${this.userId}`, error);
227
228
  throw new DatabaseConstraintError('Failed to load user preferences', error);
228
229
  }
229
230
  }
230
231
  // Generic database operation error
231
- this.logger.error(`Failed to load preferences for user ${this.userId}:`, error);
232
+ this.logger.error(`Failed to load preferences for user ${this.userId}`, error instanceof Error ? error : new Error(String(error)));
232
233
  throw new DatabaseOperationError('Failed to load user preferences', error instanceof Error ? error : new Error(String(error)));
233
234
  }
234
235
  }
@@ -281,19 +282,19 @@ export class UserPreferencesManager {
281
282
  errorMessage.includes('timeout') ||
282
283
  errorMessage.includes('econnrefused') ||
283
284
  errorMessage.includes('connect econnrefused')) {
284
- this.logger.error(`Database connection error saving preferences for user ${this.userId}:`, error);
285
+ this.logger.error(`Database connection error saving preferences for user ${this.userId}`, error);
285
286
  throw new DatabaseConnectionError('Failed to save user preferences', error);
286
287
  }
287
288
  if (errorMessage.includes('violates') ||
288
289
  errorMessage.includes('constraint') ||
289
290
  errorMessage.includes('foreign key') ||
290
291
  errorMessage.includes('duplicate')) {
291
- this.logger.error(`Database constraint error saving preferences for user ${this.userId}:`, error);
292
+ this.logger.error(`Database constraint error saving preferences for user ${this.userId}`, error);
292
293
  throw new DatabaseConstraintError('Failed to save user preferences', error);
293
294
  }
294
295
  }
295
296
  // Generic database operation error
296
- this.logger.error(`Failed to save preferences for user ${this.userId}:`, error);
297
+ this.logger.error(`Failed to save preferences for user ${this.userId}`, error instanceof Error ? error : new Error(String(error)));
297
298
  throw new DatabaseOperationError('Failed to save user preferences', error instanceof Error ? error : new Error(String(error)));
298
299
  }
299
300
  }
@@ -1 +1 @@
1
- {"version":3,"file":"episodic-memory.d.ts","sourceRoot":"","sources":["../../../src/memory/stores/episodic-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAMlG,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC3B,aAAa,EAAE,aAAa,CAAA;CAC7B;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,aAAa,CAAW;IAChC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;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3B;;;;OAIG;IACH,MAAM,IAAI,kBAAkB;IAS5B;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,kBAAkB,EACxB,EAAE,EAAE,QAAQ,EACZ,WAAW,CAAC,EAAE,eAAe,GAC5B,cAAc;IAOjB;;;;OAIG;IACH,KAAK,IAAI,cAAc;IAIvB;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
@@ -266,10 +266,11 @@ export class EpisodicMemory {
266
266
  // Return memories sorted by similarity
267
267
  return results.map((r) => r.memory);
268
268
  }
269
- catch (_error) {
269
+ catch (error) {
270
270
  // Embedding generation failed (e.g. embedding service unavailable).
271
271
  // Return empty results — do NOT fall back to getAll(), which would dump the
272
272
  // entire memory store into agent context regardless of relevance.
273
+ void (error instanceof Error ? error.message : String(error)); // Semantic search failed — return empty results
273
274
  return [];
274
275
  }
275
276
  }
@@ -2,7 +2,6 @@
2
2
  * Utility functions
3
3
  */
4
4
  export { deepClone } from './deep-clone.js';
5
- export { createLogger, defaultLogger, type Logger } from './logger.js';
6
5
  export { findAgentContextById, findAgentMemoriesByUserId, findAgentMemoryById, findNodeIdMappingByEntity, findNodeIdMappingByHash, findUserById, } from './sql-helpers.js';
7
6
  export { estimateObjectSize, hasCircularReference, validateContext, validateContextKey, validateContextSize, validateContextValue, validateObjectDepth, } from './validation.js';
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,YAAY,GACb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,YAAY,GACb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA"}
@@ -2,6 +2,5 @@
2
2
  * Utility functions
3
3
  */
4
4
  export { deepClone } from './deep-clone.js';
5
- export { createLogger, defaultLogger } from './logger.js';
6
5
  export { findAgentContextById, findAgentMemoriesByUserId, findAgentMemoryById, findNodeIdMappingByEntity, findNodeIdMappingByHash, findUserById, } from './sql-helpers.js';
7
6
  export { estimateObjectSize, hasCircularReference, validateContext, validateContextKey, validateContextSize, validateContextValue, validateObjectDepth, } from './validation.js';
@@ -30,11 +30,14 @@ export interface VectorSearchResult {
30
30
  */
31
31
  export declare class VectorMemoryService {
32
32
  private _db;
33
+ private _restDb;
33
34
  /**
34
35
  * Lazy-load database client to avoid connection initialization at module import time.
35
36
  * This allows the module to be imported in test environments without triggering database connections.
36
37
  */
37
38
  private get db();
39
+ /** Lazy-load REST client for cross-DB reference validation. */
40
+ private get restDb();
38
41
  /**
39
42
  * Search for similar memories using vector similarity.
40
43
  *
@@ -1 +1 @@
1
- {"version":3,"file":"vector-memory-service.d.ts","sourceRoot":"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IAAI,CAAC;CA8CvD"}
1
+ {"version":3,"file":"vector-memory-service.d.ts","sourceRoot":"","sources":["../../../src/memory/vector/vector-memory-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAM7D,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,GAAG,CAAkD;IAC7D,OAAO,CAAC,OAAO,CAAgD;IAE/D;;;OAGG;IACH,OAAO,KAAK,EAAE,GAKb;IAED,+DAA+D;IAC/D,OAAO,KAAK,MAAM,GAKjB;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,aAAa,CACjB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA2GhC;;;;;OAKG;IACG,MAAM,CACV,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG;QAC7D,EAAE,CAAC,EAAE,MAAM,CAAA;KACZ,GACA,OAAO,CAAC,WAAW,CAAC;IA4EvB;;;;;;OAMG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,GACtD,OAAO,CAAC,WAAW,CAAC;IAyEvB;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK1C;;;;;OAKG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CA8CvD"}
@@ -12,7 +12,8 @@
12
12
  * const memories = await service.searchSimilar(embedding, { siteId: 'site-123', limit: 10 })
13
13
  * ```
14
14
  */
15
- import { getVectorClient } from '@revealui/db/client';
15
+ import { getRestClient, getVectorClient } from '@revealui/db/client';
16
+ import { safeVectorInsert } from '@revealui/db/validation';
16
17
  import { agentMemories } from '@revealui/db/schema/vector';
17
18
  import { and, eq, sql } from 'drizzle-orm';
18
19
  /**
@@ -20,6 +21,7 @@ import { and, eq, sql } from 'drizzle-orm';
20
21
  */
21
22
  export class VectorMemoryService {
22
23
  _db = null;
24
+ _restDb = null;
23
25
  /**
24
26
  * Lazy-load database client to avoid connection initialization at module import time.
25
27
  * This allows the module to be imported in test environments without triggering database connections.
@@ -30,6 +32,13 @@ export class VectorMemoryService {
30
32
  }
31
33
  return this._db;
32
34
  }
35
+ /** Lazy-load REST client for cross-DB reference validation. */
36
+ get restDb() {
37
+ if (!this._restDb) {
38
+ this._restDb = getRestClient();
39
+ }
40
+ return this._restDb;
41
+ }
33
42
  /**
34
43
  * Search for similar memories using vector similarity.
35
44
  *
@@ -146,12 +155,16 @@ export class VectorMemoryService {
146
155
  * @returns Created memory with generated id and timestamps
147
156
  */
148
157
  async create(memory) {
149
- const id = memory.id || `mem-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
158
+ const id = memory.id || crypto.randomUUID();
150
159
  const now = new Date();
151
160
  // Pass embedding vector directly - Drizzle's vector type will handle conversion
152
161
  // The vector custom type has toDriver() that converts number[] to string format
153
162
  const embeddingVector = memory.embedding?.vector || null;
154
- const result = await this.db
163
+ const siteId = memory.metadata?.siteId;
164
+ if (!siteId) {
165
+ throw new Error('siteId is required to create an agent memory');
166
+ }
167
+ const result = await safeVectorInsert(this.restDb, async () => this.db
155
168
  .insert(agentMemories)
156
169
  .values({
157
170
  id,
@@ -167,12 +180,12 @@ export class VectorMemoryService {
167
180
  verified: memory.verified,
168
181
  verifiedBy: null, // Can be set via update
169
182
  verifiedAt: null,
170
- siteId: memory.metadata?.siteId || null,
183
+ siteId,
171
184
  agentId: memory.metadata?.custom?.agentId || null,
172
185
  createdAt: now,
173
186
  expiresAt: memory.metadata?.expiresAt ? new Date(memory.metadata.expiresAt) : null,
174
187
  })
175
- .returning();
188
+ .returning(), { siteId: siteId ?? undefined });
176
189
  const row = result[0];
177
190
  if (!row) {
178
191
  throw new Error('Failed to create memory');
@@ -1 +1 @@
1
- {"version":3,"file":"github-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/github-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CA+B9D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;IAEjB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAA;IAEzB,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAA;IAEvB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM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,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAS5B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAY3E"}
@@ -3,12 +3,19 @@
3
3
  *
4
4
  * Install skills from GitHub repositories.
5
5
  */
6
- import { exec } from 'node:child_process';
6
+ import { execFile } from 'node:child_process';
7
7
  import * as fs from 'node:fs';
8
8
  import * as path from 'node:path';
9
9
  import { promisify } from 'node:util';
10
10
  import { parseSkillMd } from '../parser/index.js';
11
- const execAsync = promisify(exec);
11
+ const execFileAsync = promisify(execFile);
12
+ /** Validate shell-unsafe characters in git arguments (R4-C1 fix) */
13
+ const SAFE_GIT_ARG = /^[a-zA-Z0-9._\-/]+$/;
14
+ function validateGitArg(value, name) {
15
+ if (!SAFE_GIT_ARG.test(value)) {
16
+ throw new Error(`Invalid ${name}: "${value}". Only alphanumeric, dots, hyphens, underscores, and slashes allowed.`);
17
+ }
18
+ }
12
19
  /**
13
20
  * Parse a GitHub source string into components.
14
21
  *
@@ -109,19 +116,17 @@ export async function loadFromGitHub(source, options) {
109
116
  * Perform a sparse checkout for a specific path.
110
117
  */
111
118
  async function sparseClone(repoUrl, targetPath, subPath, ref) {
112
- // Create a temp directory for the sparse checkout
119
+ validateGitArg(subPath, 'subPath');
120
+ if (ref)
121
+ validateGitArg(ref, 'ref');
113
122
  const tempDir = `${targetPath}.tmp`;
114
123
  try {
115
- // Initialize sparse checkout
116
- await execAsync(`git clone --depth 1 --filter=blob:none --sparse ${repoUrl} ${tempDir}`);
117
- // Configure sparse checkout
118
- await execAsync(`git -C ${tempDir} sparse-checkout set ${subPath}`);
119
- // Checkout specific ref if provided
124
+ await execFileAsync('git', ['clone', '--depth', '1', '--filter=blob:none', '--sparse', repoUrl, tempDir]);
125
+ await execFileAsync('git', ['-C', tempDir, 'sparse-checkout', 'set', subPath]);
120
126
  if (ref) {
121
- await execAsync(`git -C ${tempDir} fetch --depth 1 origin ${ref}`);
122
- await execAsync(`git -C ${tempDir} checkout ${ref}`);
127
+ await execFileAsync('git', ['-C', tempDir, 'fetch', '--depth', '1', 'origin', ref]);
128
+ await execFileAsync('git', ['-C', tempDir, 'checkout', ref]);
123
129
  }
124
- // Move the skill directory to target
125
130
  const sourcePath = path.join(tempDir, subPath);
126
131
  if (!fs.existsSync(sourcePath)) {
127
132
  throw new Error(`Path "${subPath}" not found in repository`);
@@ -129,7 +134,6 @@ async function sparseClone(repoUrl, targetPath, subPath, ref) {
129
134
  fs.renameSync(sourcePath, targetPath);
130
135
  }
131
136
  finally {
132
- // Clean up temp directory
133
137
  if (fs.existsSync(tempDir)) {
134
138
  fs.rmSync(tempDir, { recursive: true });
135
139
  }
@@ -139,8 +143,14 @@ async function sparseClone(repoUrl, targetPath, subPath, ref) {
139
143
  * Perform a full shallow clone.
140
144
  */
141
145
  async function fullClone(repoUrl, targetPath, ref) {
142
- const refArg = ref ? `--branch ${ref}` : '';
143
- await execAsync(`git clone --depth 1 ${refArg} ${repoUrl} ${targetPath}`);
146
+ if (ref)
147
+ validateGitArg(ref, 'ref');
148
+ const args = ['clone', '--depth', '1'];
149
+ if (ref) {
150
+ args.push('--branch', ref);
151
+ }
152
+ args.push(repoUrl, targetPath);
153
+ await execFileAsync('git', args);
144
154
  // Remove .git directory to save space
145
155
  const gitDir = path.join(targetPath, '.git');
146
156
  if (fs.existsSync(gitDir)) {
@@ -165,9 +175,10 @@ export async function updateFromGitHub(skillName, registry) {
165
175
  export async function validateGitHubSource(source) {
166
176
  try {
167
177
  const parsed = parseGitHubSource(source);
178
+ validateGitArg(parsed.owner, 'owner');
179
+ validateGitArg(parsed.repo, 'repo');
168
180
  const repoUrl = `https://github.com/${parsed.owner}/${parsed.repo}.git`;
169
- // Use git ls-remote to check if repo exists
170
- await execAsync(`git ls-remote --exit-code ${repoUrl} HEAD`);
181
+ await execFileAsync('git', ['ls-remote', '--exit-code', repoUrl, 'HEAD']);
171
182
  return true;
172
183
  }
173
184
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"vercel-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/vercel-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAA;AAK1B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;IAEjB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAA;IAEzB,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAA;IAEvB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,KAAK,CAAC,CA8EhB;AAsKD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAyCrB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,KAAK,CAAC,CAwBhB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO7D"}
1
+ {"version":3,"file":"vercel-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/vercel-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAA;AAc1B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;IAEjB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAA;IAEzB,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAA;IAEvB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,KAAK,CAAC,CA8EhB;AAwKD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAyCrB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,KAAK,CAAC,CAwBhB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO7D"}
@@ -4,14 +4,21 @@
4
4
  * Bridge layer to load skills from the Vercel Skills ecosystem (skills.sh)
5
5
  * and convert them to RevealUI's format.
6
6
  */
7
- import { exec } from 'node:child_process';
7
+ import { execFile } from 'node:child_process';
8
8
  import * as fs from 'node:fs';
9
9
  import * as path from 'node:path';
10
10
  import { promisify } from 'node:util';
11
11
  import { logger } from '@revealui/core/observability/logger';
12
12
  import { parseSkillMd } from '../parser/index.js';
13
13
  import { parseVercelSource } from './vercel-types.js';
14
- const execAsync = promisify(exec);
14
+ const execFileAsync = promisify(execFile);
15
+ /** Validate shell-unsafe characters in git arguments (R4-C1 fix) */
16
+ const SAFE_GIT_ARG = /^[a-zA-Z0-9._\-/]+$/;
17
+ function validateGitArg(value, name) {
18
+ if (!SAFE_GIT_ARG.test(value)) {
19
+ throw new Error(`Invalid ${name}: "${value}". Only alphanumeric, dots, hyphens, underscores, and slashes allowed.`);
20
+ }
21
+ }
15
22
  /**
16
23
  * Load a skill from the Vercel Skills ecosystem.
17
24
  *
@@ -115,9 +122,8 @@ async function installViaVercelCli(source, options) {
115
122
  if (options.ref) {
116
123
  args.push('--ref', options.ref);
117
124
  }
118
- const command = `npx ${args.join(' ')}`;
119
125
  try {
120
- const { stdout, stderr } = await execAsync(command, {
126
+ const { stdout, stderr } = await execFileAsync('npx', args, {
121
127
  cwd: options.dir,
122
128
  timeout: 60000, // 60 second timeout
123
129
  });
@@ -191,18 +197,17 @@ async function fallbackGitClone(source, targetPath) {
191
197
  * Perform a sparse checkout for a specific path.
192
198
  */
193
199
  async function sparseClone(repoUrl, targetPath, subPath, ref) {
200
+ validateGitArg(subPath, 'subPath');
201
+ if (ref)
202
+ validateGitArg(ref, 'ref');
194
203
  const tempDir = `${targetPath}.tmp`;
195
204
  try {
196
- // Initialize sparse checkout
197
- await execAsync(`git clone --depth 1 --filter=blob:none --sparse ${repoUrl} ${tempDir}`);
198
- // Configure sparse checkout
199
- await execAsync(`git -C ${tempDir} sparse-checkout set ${subPath}`);
200
- // Checkout specific ref if provided
205
+ await execFileAsync('git', ['clone', '--depth', '1', '--filter=blob:none', '--sparse', repoUrl, tempDir]);
206
+ await execFileAsync('git', ['-C', tempDir, 'sparse-checkout', 'set', subPath]);
201
207
  if (ref) {
202
- await execAsync(`git -C ${tempDir} fetch --depth 1 origin ${ref}`);
203
- await execAsync(`git -C ${tempDir} checkout ${ref}`);
208
+ await execFileAsync('git', ['-C', tempDir, 'fetch', '--depth', '1', 'origin', ref]);
209
+ await execFileAsync('git', ['-C', tempDir, 'checkout', ref]);
204
210
  }
205
- // Move the skill directory to target
206
211
  const sourcePath = path.join(tempDir, subPath);
207
212
  if (!fs.existsSync(sourcePath)) {
208
213
  throw new Error(`Path "${subPath}" not found in repository`);
@@ -210,7 +215,6 @@ async function sparseClone(repoUrl, targetPath, subPath, ref) {
210
215
  fs.renameSync(sourcePath, targetPath);
211
216
  }
212
217
  finally {
213
- // Clean up temp directory
214
218
  if (fs.existsSync(tempDir)) {
215
219
  fs.rmSync(tempDir, { recursive: true });
216
220
  }
@@ -220,8 +224,14 @@ async function sparseClone(repoUrl, targetPath, subPath, ref) {
220
224
  * Perform a full shallow clone.
221
225
  */
222
226
  async function fullClone(repoUrl, targetPath, ref) {
223
- const refArg = ref ? `--branch ${ref}` : '';
224
- await execAsync(`git clone --depth 1 ${refArg} ${repoUrl} ${targetPath}`);
227
+ if (ref)
228
+ validateGitArg(ref, 'ref');
229
+ const args = ['clone', '--depth', '1'];
230
+ if (ref) {
231
+ args.push('--branch', ref);
232
+ }
233
+ args.push(repoUrl, targetPath);
234
+ await execFileAsync('git', args);
225
235
  // Remove .git directory to save space
226
236
  const gitDir = path.join(targetPath, '.git');
227
237
  if (fs.existsSync(gitDir)) {
@@ -304,7 +314,7 @@ export async function updateVercelSkill(skillName, registry) {
304
314
  */
305
315
  export async function isVercelCliAvailable() {
306
316
  try {
307
- await execAsync('npx skills --version', { timeout: 5000 });
317
+ await execFileAsync('npx', ['skills', '--version'], { timeout: 5000 });
308
318
  return true;
309
319
  }
310
320
  catch {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@revealui/ai",
3
- "version": "0.1.2",
4
- "description": "AI system for RevealUI - memory, LLM, orchestration, and tools",
3
+ "version": "0.2.0",
4
+ "description": "[Pro] AI system for RevealUI - memory, LLM, orchestration, and tools",
5
5
  "keywords": [
6
6
  "agent",
7
7
  "ai",
@@ -16,13 +16,18 @@
16
16
  "tools",
17
17
  "vector-search"
18
18
  ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/RevealUIStudio/revealui.git",
22
+ "directory": "packages/ai"
23
+ },
19
24
  "license": "SEE LICENSE IN ../../LICENSE.commercial",
20
25
  "dependencies": {
21
26
  "lru-cache": "^11.2.5",
22
27
  "zod": "^4.3.5",
23
- "@revealui/contracts": "1.0.0",
24
- "@revealui/core": "0.2.0",
25
- "@revealui/db": "^0.2.0"
28
+ "@revealui/db": "0.3.0",
29
+ "@revealui/core": "0.3.0",
30
+ "@revealui/contracts": "1.3.0"
26
31
  },
27
32
  "devDependencies": {
28
33
  "@testing-library/react": "^16.3.2",
@@ -116,24 +121,26 @@
116
121
  "files": [
117
122
  "dist"
118
123
  ],
124
+ "funding": {
125
+ "type": "commercial",
126
+ "url": "https://revealui.com/pro"
127
+ },
119
128
  "main": "./dist/index.js",
120
129
  "module": "./dist/index.js",
121
130
  "peerDependencies": {
122
131
  "drizzle-orm": "^0.45.1",
123
132
  "react": "^18.0.0 || ^19.0.0"
124
133
  },
125
- "type": "module",
126
- "types": "./dist/index.d.ts",
127
134
  "publishConfig": {
128
- "registry": "https://registry.npmjs.org",
129
135
  "access": "public"
130
136
  },
137
+ "type": "module",
138
+ "types": "./dist/index.d.ts",
131
139
  "scripts": {
132
140
  "build": "tsc",
133
141
  "clean": "rm -rf dist",
134
142
  "dev": "tsc --watch",
135
143
  "lint": "biome check .",
136
- "lint:eslint": "eslint .",
137
144
  "test": "vitest run",
138
145
  "test:coverage": "vitest run --coverage",
139
146
  "test:integration": "vitest run --root . --config vitest.integration.config.ts",
@@ -1,21 +0,0 @@
1
- /**
2
- * Simple Logger Utility
3
- *
4
- * Provides a minimal logging interface that can be easily replaced
5
- * with a proper logging service later. Respects environment and log levels.
6
- */
7
- export interface Logger {
8
- info: (...args: unknown[]) => void;
9
- warn: (...args: unknown[]) => void;
10
- error: (...args: unknown[]) => void;
11
- debug: (...args: unknown[]) => void;
12
- }
13
- /**
14
- * Creates a logger instance with optional prefix
15
- */
16
- export declare function createLogger(prefix?: string): Logger;
17
- /**
18
- * Default logger instance
19
- */
20
- export declare const defaultLogger: Logger;
21
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/memory/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CACpC;AA0DD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAqC,CAAA"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Simple Logger Utility
3
- *
4
- * Provides a minimal logging interface that can be easily replaced
5
- * with a proper logging service later. Respects environment and log levels.
6
- */
7
- /**
8
- * Environment-aware logger implementation
9
- * Only logs when appropriate for the environment and log level
10
- */
11
- class SimpleLogger {
12
- prefix;
13
- minLevel;
14
- isProduction;
15
- constructor(prefix = '[Memory]') {
16
- this.prefix = prefix;
17
- this.isProduction = process.env.NODE_ENV === 'production';
18
- this.minLevel = process.env.LOG_LEVEL || (this.isProduction ? 'warn' : 'debug');
19
- }
20
- shouldLog(level) {
21
- // Never log debug or info in production
22
- if (this.isProduction && (level === 'debug' || level === 'info')) {
23
- return false;
24
- }
25
- const levels = ['debug', 'info', 'warn', 'error'];
26
- return levels.indexOf(level) >= levels.indexOf(this.minLevel);
27
- }
28
- info(...args) {
29
- // Info logs are never shown in production
30
- if (process.env.NODE_ENV !== 'production') {
31
- console.log(this.prefix, ...args);
32
- }
33
- // In production: complete no-op
34
- }
35
- warn(...args) {
36
- // Warning logs are never shown in production
37
- if (process.env.NODE_ENV !== 'production') {
38
- console.warn(this.prefix, ...args);
39
- }
40
- // In production: complete no-op
41
- }
42
- error(...args) {
43
- if (this.shouldLog('error')) {
44
- console.error(this.prefix, ...args);
45
- }
46
- }
47
- debug(...args) {
48
- if (process.env.NODE_ENV !== 'production') {
49
- console.debug(this.prefix, ...args);
50
- }
51
- }
52
- }
53
- /**
54
- * Creates a logger instance with optional prefix
55
- */
56
- export function createLogger(prefix) {
57
- return new SimpleLogger(prefix);
58
- }
59
- /**
60
- * Default logger instance
61
- */
62
- export const defaultLogger = new SimpleLogger('[Memory]');