@axiom-lattice/core 2.1.14 → 2.1.15
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.
- package/dist/index.d.mts +130 -2
- package/dist/index.d.ts +130 -2
- package/dist/index.js +327 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +323 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -37,17 +37,20 @@ __export(index_exports, {
|
|
|
37
37
|
AgentType: () => import_protocols.AgentType,
|
|
38
38
|
ChunkBuffer: () => ChunkBuffer,
|
|
39
39
|
ChunkBufferLatticeManager: () => ChunkBufferLatticeManager,
|
|
40
|
+
ConsoleLoggerClient: () => ConsoleLoggerClient,
|
|
40
41
|
DefaultScheduleClient: () => DefaultScheduleClient,
|
|
41
42
|
EmbeddingsLatticeManager: () => EmbeddingsLatticeManager,
|
|
42
43
|
GraphBuildOptions: () => import_protocols.GraphBuildOptions,
|
|
43
44
|
InMemoryAssistantStore: () => InMemoryAssistantStore,
|
|
44
45
|
InMemoryChunkBuffer: () => InMemoryChunkBuffer,
|
|
45
46
|
InMemoryThreadStore: () => InMemoryThreadStore,
|
|
47
|
+
LoggerLatticeManager: () => LoggerLatticeManager,
|
|
46
48
|
MemoryLatticeManager: () => MemoryLatticeManager,
|
|
47
49
|
MemoryQueueClient: () => MemoryQueueClient,
|
|
48
50
|
MemoryScheduleStorage: () => MemoryScheduleStorage,
|
|
49
51
|
MemoryType: () => import_protocols2.MemoryType,
|
|
50
52
|
ModelLatticeManager: () => ModelLatticeManager,
|
|
53
|
+
PinoLoggerClient: () => PinoLoggerClient,
|
|
51
54
|
PostgresDatabase: () => PostgresDatabase,
|
|
52
55
|
Protocols: () => Protocols,
|
|
53
56
|
QueueLatticeManager: () => QueueLatticeManager,
|
|
@@ -71,6 +74,7 @@ __export(index_exports, {
|
|
|
71
74
|
getChunkBuffer: () => getChunkBuffer,
|
|
72
75
|
getEmbeddingsClient: () => getEmbeddingsClient,
|
|
73
76
|
getEmbeddingsLattice: () => getEmbeddingsLattice,
|
|
77
|
+
getLoggerLattice: () => getLoggerLattice,
|
|
74
78
|
getModelLattice: () => getModelLattice,
|
|
75
79
|
getNextCronTime: () => getNextCronTime,
|
|
76
80
|
getQueueLattice: () => getQueueLattice,
|
|
@@ -83,6 +87,7 @@ __export(index_exports, {
|
|
|
83
87
|
getVectorStoreLattice: () => getVectorStoreLattice,
|
|
84
88
|
hasChunkBuffer: () => hasChunkBuffer,
|
|
85
89
|
isValidCronExpression: () => isValidCronExpression,
|
|
90
|
+
loggerLatticeManager: () => loggerLatticeManager,
|
|
86
91
|
modelLatticeManager: () => modelLatticeManager,
|
|
87
92
|
parseCronExpression: () => parseCronExpression,
|
|
88
93
|
queueLatticeManager: () => queueLatticeManager,
|
|
@@ -91,6 +96,7 @@ __export(index_exports, {
|
|
|
91
96
|
registerCheckpointSaver: () => registerCheckpointSaver,
|
|
92
97
|
registerChunkBuffer: () => registerChunkBuffer,
|
|
93
98
|
registerEmbeddingsLattice: () => registerEmbeddingsLattice,
|
|
99
|
+
registerLoggerLattice: () => registerLoggerLattice,
|
|
94
100
|
registerModelLattice: () => registerModelLattice,
|
|
95
101
|
registerQueueLattice: () => registerQueueLattice,
|
|
96
102
|
registerScheduleLattice: () => registerScheduleLattice,
|
|
@@ -5292,6 +5298,321 @@ var registerVectorStoreLattice = (key, vectorStore) => vectorStoreLatticeManager
|
|
|
5292
5298
|
var getVectorStoreLattice = (key) => vectorStoreLatticeManager.getVectorStoreLattice(key);
|
|
5293
5299
|
var getVectorStoreClient = (key) => vectorStoreLatticeManager.getVectorStoreClient(key);
|
|
5294
5300
|
|
|
5301
|
+
// src/logger_lattice/LoggerLatticeManager.ts
|
|
5302
|
+
var import_protocols8 = require("@axiom-lattice/protocols");
|
|
5303
|
+
|
|
5304
|
+
// src/logger_lattice/PinoLoggerClient.ts
|
|
5305
|
+
var import_pino = __toESM(require("pino"));
|
|
5306
|
+
var import_pino_pretty = require("pino-pretty");
|
|
5307
|
+
var import_pino_roll = require("pino-roll");
|
|
5308
|
+
var PinoLoggerClient = class _PinoLoggerClient {
|
|
5309
|
+
constructor(config) {
|
|
5310
|
+
this.config = config;
|
|
5311
|
+
this.context = config.context || {};
|
|
5312
|
+
const loggerConfig = {
|
|
5313
|
+
// Custom timestamp format
|
|
5314
|
+
timestamp: () => `,"@timestamp":"${(/* @__PURE__ */ new Date()).toISOString()}"`,
|
|
5315
|
+
// Base metadata
|
|
5316
|
+
base: {
|
|
5317
|
+
"@version": "1",
|
|
5318
|
+
app_name: "lattice",
|
|
5319
|
+
service_name: config.serviceName || "lattice-service",
|
|
5320
|
+
thread_name: "main",
|
|
5321
|
+
logger_name: config.loggerName || config.name || "lattice-logger"
|
|
5322
|
+
},
|
|
5323
|
+
formatters: {
|
|
5324
|
+
level: (label, number) => {
|
|
5325
|
+
return {
|
|
5326
|
+
level: label.toUpperCase(),
|
|
5327
|
+
level_value: number * 1e3
|
|
5328
|
+
};
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
};
|
|
5332
|
+
const useFileLogging = this.shouldUseFileLogging(config);
|
|
5333
|
+
const fileOptions = this.getFileOptions(config);
|
|
5334
|
+
if (useFileLogging && fileOptions) {
|
|
5335
|
+
try {
|
|
5336
|
+
this.pinoLogger = (0, import_pino.default)(
|
|
5337
|
+
loggerConfig,
|
|
5338
|
+
import_pino.default.transport({
|
|
5339
|
+
target: "pino-roll",
|
|
5340
|
+
options: {
|
|
5341
|
+
file: fileOptions.file || "./logs/app",
|
|
5342
|
+
frequency: fileOptions.frequency || "daily",
|
|
5343
|
+
mkdir: fileOptions.mkdir !== false,
|
|
5344
|
+
// Default to true
|
|
5345
|
+
size: fileOptions.size,
|
|
5346
|
+
maxFiles: fileOptions.maxFiles
|
|
5347
|
+
}
|
|
5348
|
+
})
|
|
5349
|
+
);
|
|
5350
|
+
} catch (error) {
|
|
5351
|
+
console.error(
|
|
5352
|
+
"Failed to initialize pino-roll logger, falling back to console",
|
|
5353
|
+
error
|
|
5354
|
+
);
|
|
5355
|
+
this.pinoLogger = (0, import_pino.default)({
|
|
5356
|
+
...loggerConfig,
|
|
5357
|
+
transport: {
|
|
5358
|
+
target: "pino-pretty",
|
|
5359
|
+
options: {
|
|
5360
|
+
colorize: true
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
});
|
|
5364
|
+
}
|
|
5365
|
+
} else {
|
|
5366
|
+
this.pinoLogger = (0, import_pino.default)({
|
|
5367
|
+
...loggerConfig,
|
|
5368
|
+
transport: {
|
|
5369
|
+
target: "pino-pretty",
|
|
5370
|
+
options: {
|
|
5371
|
+
colorize: true
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
});
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
/**
|
|
5378
|
+
* Determine if file logging should be used
|
|
5379
|
+
*/
|
|
5380
|
+
shouldUseFileLogging(config) {
|
|
5381
|
+
const hasFileConfig = config.file !== void 0;
|
|
5382
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
5383
|
+
return hasFileConfig || isProduction;
|
|
5384
|
+
}
|
|
5385
|
+
/**
|
|
5386
|
+
* Get file options from config
|
|
5387
|
+
*/
|
|
5388
|
+
getFileOptions(config) {
|
|
5389
|
+
if (!config.file) {
|
|
5390
|
+
if (process.env.NODE_ENV === "production") {
|
|
5391
|
+
return {
|
|
5392
|
+
file: "./logs/app",
|
|
5393
|
+
frequency: "daily",
|
|
5394
|
+
mkdir: true
|
|
5395
|
+
};
|
|
5396
|
+
}
|
|
5397
|
+
return null;
|
|
5398
|
+
}
|
|
5399
|
+
if (typeof config.file === "string") {
|
|
5400
|
+
return {
|
|
5401
|
+
file: config.file,
|
|
5402
|
+
frequency: "daily",
|
|
5403
|
+
mkdir: true
|
|
5404
|
+
};
|
|
5405
|
+
}
|
|
5406
|
+
return config.file;
|
|
5407
|
+
}
|
|
5408
|
+
/**
|
|
5409
|
+
* Get contextual logger with merged context
|
|
5410
|
+
*/
|
|
5411
|
+
getContextualLogger(additionalContext) {
|
|
5412
|
+
const contextObj = {
|
|
5413
|
+
"x-user-id": this.context["x-user-id"] || "",
|
|
5414
|
+
"x-tenant-id": this.context["x-tenant-id"] || "",
|
|
5415
|
+
"x-request-id": this.context["x-request-id"] || "",
|
|
5416
|
+
"x-thread-id": this.context["x-thread-id"] || "",
|
|
5417
|
+
service_name: this.config.serviceName || "lattice-service",
|
|
5418
|
+
logger_name: this.config.loggerName || this.config.name || "lattice-logger",
|
|
5419
|
+
...additionalContext
|
|
5420
|
+
};
|
|
5421
|
+
return this.pinoLogger.child(contextObj);
|
|
5422
|
+
}
|
|
5423
|
+
info(msg, obj) {
|
|
5424
|
+
this.getContextualLogger(obj).info(msg);
|
|
5425
|
+
}
|
|
5426
|
+
error(msg, obj) {
|
|
5427
|
+
this.getContextualLogger(obj).error(msg);
|
|
5428
|
+
}
|
|
5429
|
+
warn(msg, obj) {
|
|
5430
|
+
this.getContextualLogger(obj).warn(msg);
|
|
5431
|
+
}
|
|
5432
|
+
debug(msg, obj) {
|
|
5433
|
+
this.getContextualLogger(obj).debug(msg);
|
|
5434
|
+
}
|
|
5435
|
+
updateContext(context) {
|
|
5436
|
+
this.context = {
|
|
5437
|
+
...this.context,
|
|
5438
|
+
...context
|
|
5439
|
+
};
|
|
5440
|
+
}
|
|
5441
|
+
child(options) {
|
|
5442
|
+
return new _PinoLoggerClient({
|
|
5443
|
+
...this.config,
|
|
5444
|
+
...options,
|
|
5445
|
+
context: {
|
|
5446
|
+
...this.context,
|
|
5447
|
+
...options.context
|
|
5448
|
+
}
|
|
5449
|
+
});
|
|
5450
|
+
}
|
|
5451
|
+
};
|
|
5452
|
+
|
|
5453
|
+
// src/logger_lattice/ConsoleLoggerClient.ts
|
|
5454
|
+
var ConsoleLoggerClient = class _ConsoleLoggerClient {
|
|
5455
|
+
constructor(config) {
|
|
5456
|
+
this.config = config;
|
|
5457
|
+
this.context = config.context || {};
|
|
5458
|
+
}
|
|
5459
|
+
formatMessage(level, msg, obj) {
|
|
5460
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
5461
|
+
const contextStr = Object.keys(this.context).length > 0 ? ` [${JSON.stringify(this.context)}]` : "";
|
|
5462
|
+
const objStr = obj ? ` ${JSON.stringify(obj)}` : "";
|
|
5463
|
+
return `[${timestamp}] [${level}]${contextStr} ${msg}${objStr}`;
|
|
5464
|
+
}
|
|
5465
|
+
info(msg, obj) {
|
|
5466
|
+
console.log(this.formatMessage("INFO", msg, obj));
|
|
5467
|
+
}
|
|
5468
|
+
error(msg, obj) {
|
|
5469
|
+
console.error(this.formatMessage("ERROR", msg, obj));
|
|
5470
|
+
}
|
|
5471
|
+
warn(msg, obj) {
|
|
5472
|
+
console.warn(this.formatMessage("WARN", msg, obj));
|
|
5473
|
+
}
|
|
5474
|
+
debug(msg, obj) {
|
|
5475
|
+
console.debug(this.formatMessage("DEBUG", msg, obj));
|
|
5476
|
+
}
|
|
5477
|
+
updateContext(context) {
|
|
5478
|
+
this.context = {
|
|
5479
|
+
...this.context,
|
|
5480
|
+
...context
|
|
5481
|
+
};
|
|
5482
|
+
}
|
|
5483
|
+
child(options) {
|
|
5484
|
+
const childClient = new _ConsoleLoggerClient({
|
|
5485
|
+
...this.config,
|
|
5486
|
+
...options,
|
|
5487
|
+
context: {
|
|
5488
|
+
...this.context,
|
|
5489
|
+
...options.context
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
5492
|
+
return childClient;
|
|
5493
|
+
}
|
|
5494
|
+
};
|
|
5495
|
+
|
|
5496
|
+
// src/logger_lattice/LoggerLatticeManager.ts
|
|
5497
|
+
var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManager {
|
|
5498
|
+
/**
|
|
5499
|
+
* Get LoggerLatticeManager singleton instance
|
|
5500
|
+
*/
|
|
5501
|
+
static getInstance() {
|
|
5502
|
+
if (!_LoggerLatticeManager._instance) {
|
|
5503
|
+
_LoggerLatticeManager._instance = new _LoggerLatticeManager();
|
|
5504
|
+
}
|
|
5505
|
+
return _LoggerLatticeManager._instance;
|
|
5506
|
+
}
|
|
5507
|
+
/**
|
|
5508
|
+
* Get Lattice type prefix
|
|
5509
|
+
*/
|
|
5510
|
+
getLatticeType() {
|
|
5511
|
+
return "loggers";
|
|
5512
|
+
}
|
|
5513
|
+
/**
|
|
5514
|
+
* Register logger Lattice
|
|
5515
|
+
* @param key Lattice key name
|
|
5516
|
+
* @param config Logger configuration
|
|
5517
|
+
* @param client Optional logger client. If not provided, will create based on config type.
|
|
5518
|
+
*/
|
|
5519
|
+
registerLattice(key, config, client) {
|
|
5520
|
+
let loggerClient;
|
|
5521
|
+
if (client) {
|
|
5522
|
+
loggerClient = client;
|
|
5523
|
+
} else {
|
|
5524
|
+
if (config.type === import_protocols8.LoggerType.PINO) {
|
|
5525
|
+
loggerClient = new PinoLoggerClient(config);
|
|
5526
|
+
} else if (config.type === import_protocols8.LoggerType.CONSOLE) {
|
|
5527
|
+
loggerClient = new ConsoleLoggerClient(config);
|
|
5528
|
+
} else if (config.type === import_protocols8.LoggerType.CUSTOM) {
|
|
5529
|
+
throw new Error(
|
|
5530
|
+
`Custom logger client must be provided. Please pass the client to registerLattice.`
|
|
5531
|
+
);
|
|
5532
|
+
} else {
|
|
5533
|
+
loggerClient = new PinoLoggerClient(config);
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
const loggerLattice = {
|
|
5537
|
+
key,
|
|
5538
|
+
config,
|
|
5539
|
+
client: loggerClient,
|
|
5540
|
+
// Logger operations
|
|
5541
|
+
info: (msg, obj) => {
|
|
5542
|
+
loggerClient.info(msg, obj);
|
|
5543
|
+
},
|
|
5544
|
+
error: (msg, obj) => {
|
|
5545
|
+
loggerClient.error(msg, obj);
|
|
5546
|
+
},
|
|
5547
|
+
warn: (msg, obj) => {
|
|
5548
|
+
loggerClient.warn(msg, obj);
|
|
5549
|
+
},
|
|
5550
|
+
debug: (msg, obj) => {
|
|
5551
|
+
loggerClient.debug(msg, obj);
|
|
5552
|
+
},
|
|
5553
|
+
updateContext: loggerClient.updateContext ? (context) => {
|
|
5554
|
+
loggerClient.updateContext(context);
|
|
5555
|
+
} : void 0,
|
|
5556
|
+
child: loggerClient.child ? (options) => {
|
|
5557
|
+
return loggerClient.child(options);
|
|
5558
|
+
} : void 0
|
|
5559
|
+
};
|
|
5560
|
+
this.register(key, loggerLattice);
|
|
5561
|
+
}
|
|
5562
|
+
/**
|
|
5563
|
+
* Get LoggerLattice
|
|
5564
|
+
* @param key Lattice key name
|
|
5565
|
+
*/
|
|
5566
|
+
getLoggerLattice(key) {
|
|
5567
|
+
const loggerLattice = this.get(key);
|
|
5568
|
+
if (!loggerLattice) {
|
|
5569
|
+
throw new Error(`LoggerLattice ${key} not found`);
|
|
5570
|
+
}
|
|
5571
|
+
return loggerLattice;
|
|
5572
|
+
}
|
|
5573
|
+
/**
|
|
5574
|
+
* Get all Lattices
|
|
5575
|
+
*/
|
|
5576
|
+
getAllLattices() {
|
|
5577
|
+
return this.getAll();
|
|
5578
|
+
}
|
|
5579
|
+
/**
|
|
5580
|
+
* Check if Lattice exists
|
|
5581
|
+
* @param key Lattice key name
|
|
5582
|
+
*/
|
|
5583
|
+
hasLattice(key) {
|
|
5584
|
+
return this.has(key);
|
|
5585
|
+
}
|
|
5586
|
+
/**
|
|
5587
|
+
* Remove Lattice
|
|
5588
|
+
* @param key Lattice key name
|
|
5589
|
+
*/
|
|
5590
|
+
removeLattice(key) {
|
|
5591
|
+
return this.remove(key);
|
|
5592
|
+
}
|
|
5593
|
+
/**
|
|
5594
|
+
* Clear all Lattices
|
|
5595
|
+
*/
|
|
5596
|
+
clearLattices() {
|
|
5597
|
+
this.clear();
|
|
5598
|
+
}
|
|
5599
|
+
/**
|
|
5600
|
+
* Get Lattice count
|
|
5601
|
+
*/
|
|
5602
|
+
getLatticeCount() {
|
|
5603
|
+
return this.count();
|
|
5604
|
+
}
|
|
5605
|
+
/**
|
|
5606
|
+
* Get Lattice key list
|
|
5607
|
+
*/
|
|
5608
|
+
getLatticeKeys() {
|
|
5609
|
+
return this.keys();
|
|
5610
|
+
}
|
|
5611
|
+
};
|
|
5612
|
+
var loggerLatticeManager = LoggerLatticeManager.getInstance();
|
|
5613
|
+
var registerLoggerLattice = (key, config, client) => loggerLatticeManager.registerLattice(key, config, client);
|
|
5614
|
+
var getLoggerLattice = (key) => loggerLatticeManager.getLoggerLattice(key);
|
|
5615
|
+
|
|
5295
5616
|
// src/index.ts
|
|
5296
5617
|
var Protocols = __toESM(require("@axiom-lattice/protocols"));
|
|
5297
5618
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -5303,17 +5624,20 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
|
|
|
5303
5624
|
AgentType,
|
|
5304
5625
|
ChunkBuffer,
|
|
5305
5626
|
ChunkBufferLatticeManager,
|
|
5627
|
+
ConsoleLoggerClient,
|
|
5306
5628
|
DefaultScheduleClient,
|
|
5307
5629
|
EmbeddingsLatticeManager,
|
|
5308
5630
|
GraphBuildOptions,
|
|
5309
5631
|
InMemoryAssistantStore,
|
|
5310
5632
|
InMemoryChunkBuffer,
|
|
5311
5633
|
InMemoryThreadStore,
|
|
5634
|
+
LoggerLatticeManager,
|
|
5312
5635
|
MemoryLatticeManager,
|
|
5313
5636
|
MemoryQueueClient,
|
|
5314
5637
|
MemoryScheduleStorage,
|
|
5315
5638
|
MemoryType,
|
|
5316
5639
|
ModelLatticeManager,
|
|
5640
|
+
PinoLoggerClient,
|
|
5317
5641
|
PostgresDatabase,
|
|
5318
5642
|
Protocols,
|
|
5319
5643
|
QueueLatticeManager,
|
|
@@ -5337,6 +5661,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
|
|
|
5337
5661
|
getChunkBuffer,
|
|
5338
5662
|
getEmbeddingsClient,
|
|
5339
5663
|
getEmbeddingsLattice,
|
|
5664
|
+
getLoggerLattice,
|
|
5340
5665
|
getModelLattice,
|
|
5341
5666
|
getNextCronTime,
|
|
5342
5667
|
getQueueLattice,
|
|
@@ -5349,6 +5674,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
|
|
|
5349
5674
|
getVectorStoreLattice,
|
|
5350
5675
|
hasChunkBuffer,
|
|
5351
5676
|
isValidCronExpression,
|
|
5677
|
+
loggerLatticeManager,
|
|
5352
5678
|
modelLatticeManager,
|
|
5353
5679
|
parseCronExpression,
|
|
5354
5680
|
queueLatticeManager,
|
|
@@ -5357,6 +5683,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
|
|
|
5357
5683
|
registerCheckpointSaver,
|
|
5358
5684
|
registerChunkBuffer,
|
|
5359
5685
|
registerEmbeddingsLattice,
|
|
5686
|
+
registerLoggerLattice,
|
|
5360
5687
|
registerModelLattice,
|
|
5361
5688
|
registerQueueLattice,
|
|
5362
5689
|
registerScheduleLattice,
|