@axiom-lattice/core 2.1.14 → 2.1.16

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.js CHANGED
@@ -37,21 +37,26 @@ __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,
43
+ FileSystemSkillStore: () => FileSystemSkillStore,
42
44
  GraphBuildOptions: () => import_protocols.GraphBuildOptions,
43
45
  InMemoryAssistantStore: () => InMemoryAssistantStore,
44
46
  InMemoryChunkBuffer: () => InMemoryChunkBuffer,
45
47
  InMemoryThreadStore: () => InMemoryThreadStore,
48
+ LoggerLatticeManager: () => LoggerLatticeManager,
46
49
  MemoryLatticeManager: () => MemoryLatticeManager,
47
50
  MemoryQueueClient: () => MemoryQueueClient,
48
51
  MemoryScheduleStorage: () => MemoryScheduleStorage,
49
52
  MemoryType: () => import_protocols2.MemoryType,
50
53
  ModelLatticeManager: () => ModelLatticeManager,
54
+ PinoLoggerClient: () => PinoLoggerClient,
51
55
  PostgresDatabase: () => PostgresDatabase,
52
56
  Protocols: () => Protocols,
53
57
  QueueLatticeManager: () => QueueLatticeManager,
54
58
  ScheduleLatticeManager: () => ScheduleLatticeManager,
59
+ SkillLatticeManager: () => SkillLatticeManager,
55
60
  SqlDatabaseManager: () => SqlDatabaseManager,
56
61
  StoreLatticeManager: () => StoreLatticeManager,
57
62
  ThreadStatus: () => ThreadStatus,
@@ -71,6 +76,7 @@ __export(index_exports, {
71
76
  getChunkBuffer: () => getChunkBuffer,
72
77
  getEmbeddingsClient: () => getEmbeddingsClient,
73
78
  getEmbeddingsLattice: () => getEmbeddingsLattice,
79
+ getLoggerLattice: () => getLoggerLattice,
74
80
  getModelLattice: () => getModelLattice,
75
81
  getNextCronTime: () => getNextCronTime,
76
82
  getQueueLattice: () => getQueueLattice,
@@ -83,6 +89,8 @@ __export(index_exports, {
83
89
  getVectorStoreLattice: () => getVectorStoreLattice,
84
90
  hasChunkBuffer: () => hasChunkBuffer,
85
91
  isValidCronExpression: () => isValidCronExpression,
92
+ isValidSkillName: () => isValidSkillName,
93
+ loggerLatticeManager: () => loggerLatticeManager,
86
94
  modelLatticeManager: () => modelLatticeManager,
87
95
  parseCronExpression: () => parseCronExpression,
88
96
  queueLatticeManager: () => queueLatticeManager,
@@ -91,6 +99,7 @@ __export(index_exports, {
91
99
  registerCheckpointSaver: () => registerCheckpointSaver,
92
100
  registerChunkBuffer: () => registerChunkBuffer,
93
101
  registerEmbeddingsLattice: () => registerEmbeddingsLattice,
102
+ registerLoggerLattice: () => registerLoggerLattice,
94
103
  registerModelLattice: () => registerModelLattice,
95
104
  registerQueueLattice: () => registerQueueLattice,
96
105
  registerScheduleLattice: () => registerScheduleLattice,
@@ -98,10 +107,12 @@ __export(index_exports, {
98
107
  registerToolLattice: () => registerToolLattice,
99
108
  registerVectorStoreLattice: () => registerVectorStoreLattice,
100
109
  scheduleLatticeManager: () => scheduleLatticeManager,
110
+ skillLatticeManager: () => skillLatticeManager,
101
111
  sqlDatabaseManager: () => sqlDatabaseManager,
102
112
  storeLatticeManager: () => storeLatticeManager,
103
113
  toolLatticeManager: () => toolLatticeManager,
104
114
  validateAgentInput: () => validateAgentInput,
115
+ validateSkillName: () => validateSkillName,
105
116
  validateToolInput: () => validateToolInput,
106
117
  vectorStoreLatticeManager: () => vectorStoreLatticeManager
107
118
  });
@@ -1225,6 +1236,878 @@ ${trimmedQuery}
1225
1236
  }
1226
1237
  );
1227
1238
 
1239
+ // src/tool_lattice/load_skills/index.ts
1240
+ var import_zod7 = __toESM(require("zod"));
1241
+
1242
+ // src/store_lattice/InMemoryThreadStore.ts
1243
+ var InMemoryThreadStore = class {
1244
+ constructor() {
1245
+ // Map<assistantId, Map<threadId, Thread>>
1246
+ this.threads = /* @__PURE__ */ new Map();
1247
+ }
1248
+ /**
1249
+ * Get all threads for a specific assistant
1250
+ */
1251
+ async getThreadsByAssistantId(assistantId) {
1252
+ const assistantThreads = this.threads.get(assistantId);
1253
+ if (!assistantThreads) {
1254
+ return [];
1255
+ }
1256
+ return Array.from(assistantThreads.values());
1257
+ }
1258
+ /**
1259
+ * Get a thread by ID for a specific assistant
1260
+ */
1261
+ async getThreadById(assistantId, threadId) {
1262
+ const assistantThreads = this.threads.get(assistantId);
1263
+ if (!assistantThreads) {
1264
+ return void 0;
1265
+ }
1266
+ return assistantThreads.get(threadId);
1267
+ }
1268
+ /**
1269
+ * Create a new thread for an assistant
1270
+ */
1271
+ async createThread(assistantId, threadId, data) {
1272
+ const now = /* @__PURE__ */ new Date();
1273
+ const thread = {
1274
+ id: threadId,
1275
+ assistantId,
1276
+ metadata: data.metadata || {},
1277
+ createdAt: now,
1278
+ updatedAt: now
1279
+ };
1280
+ if (!this.threads.has(assistantId)) {
1281
+ this.threads.set(assistantId, /* @__PURE__ */ new Map());
1282
+ }
1283
+ const assistantThreads = this.threads.get(assistantId);
1284
+ assistantThreads.set(threadId, thread);
1285
+ return thread;
1286
+ }
1287
+ /**
1288
+ * Update an existing thread
1289
+ */
1290
+ async updateThread(assistantId, threadId, updates) {
1291
+ const assistantThreads = this.threads.get(assistantId);
1292
+ if (!assistantThreads) {
1293
+ return null;
1294
+ }
1295
+ const existing = assistantThreads.get(threadId);
1296
+ if (!existing) {
1297
+ return null;
1298
+ }
1299
+ const updated = {
1300
+ ...existing,
1301
+ metadata: {
1302
+ ...existing.metadata,
1303
+ ...updates.metadata || {}
1304
+ },
1305
+ updatedAt: /* @__PURE__ */ new Date()
1306
+ };
1307
+ assistantThreads.set(threadId, updated);
1308
+ return updated;
1309
+ }
1310
+ /**
1311
+ * Delete a thread by ID
1312
+ */
1313
+ async deleteThread(assistantId, threadId) {
1314
+ const assistantThreads = this.threads.get(assistantId);
1315
+ if (!assistantThreads) {
1316
+ return false;
1317
+ }
1318
+ return assistantThreads.delete(threadId);
1319
+ }
1320
+ /**
1321
+ * Check if thread exists
1322
+ */
1323
+ async hasThread(assistantId, threadId) {
1324
+ const assistantThreads = this.threads.get(assistantId);
1325
+ if (!assistantThreads) {
1326
+ return false;
1327
+ }
1328
+ return assistantThreads.has(threadId);
1329
+ }
1330
+ /**
1331
+ * Clear all threads (useful for testing)
1332
+ */
1333
+ clear() {
1334
+ this.threads.clear();
1335
+ }
1336
+ /**
1337
+ * Get all threads for all assistants (useful for debugging)
1338
+ */
1339
+ getAllThreads() {
1340
+ const allThreads = [];
1341
+ for (const assistantThreads of this.threads.values()) {
1342
+ allThreads.push(...Array.from(assistantThreads.values()));
1343
+ }
1344
+ return allThreads;
1345
+ }
1346
+ };
1347
+
1348
+ // src/store_lattice/InMemoryAssistantStore.ts
1349
+ var InMemoryAssistantStore = class {
1350
+ constructor() {
1351
+ this.assistants = /* @__PURE__ */ new Map();
1352
+ }
1353
+ /**
1354
+ * Get all assistants
1355
+ */
1356
+ async getAllAssistants() {
1357
+ return Array.from(this.assistants.values());
1358
+ }
1359
+ /**
1360
+ * Get assistant by ID
1361
+ */
1362
+ async getAssistantById(id) {
1363
+ return this.assistants.get(id) || null;
1364
+ }
1365
+ /**
1366
+ * Create a new assistant
1367
+ */
1368
+ async createAssistant(id, data) {
1369
+ const now = /* @__PURE__ */ new Date();
1370
+ const assistant = {
1371
+ id,
1372
+ name: data.name,
1373
+ description: data.description,
1374
+ graphDefinition: data.graphDefinition,
1375
+ createdAt: now,
1376
+ updatedAt: now
1377
+ };
1378
+ this.assistants.set(id, assistant);
1379
+ return assistant;
1380
+ }
1381
+ /**
1382
+ * Update an existing assistant
1383
+ */
1384
+ async updateAssistant(id, updates) {
1385
+ const existing = this.assistants.get(id);
1386
+ if (!existing) {
1387
+ return null;
1388
+ }
1389
+ const updated = {
1390
+ ...existing,
1391
+ ...updates,
1392
+ updatedAt: /* @__PURE__ */ new Date()
1393
+ };
1394
+ this.assistants.set(id, updated);
1395
+ return updated;
1396
+ }
1397
+ /**
1398
+ * Delete an assistant by ID
1399
+ */
1400
+ async deleteAssistant(id) {
1401
+ return this.assistants.delete(id);
1402
+ }
1403
+ /**
1404
+ * Check if assistant exists
1405
+ */
1406
+ async hasAssistant(id) {
1407
+ return this.assistants.has(id);
1408
+ }
1409
+ /**
1410
+ * Clear all assistants (useful for testing)
1411
+ */
1412
+ clear() {
1413
+ this.assistants.clear();
1414
+ }
1415
+ };
1416
+
1417
+ // src/store_lattice/FileSystemSkillStore.ts
1418
+ var fs = __toESM(require("fs/promises"));
1419
+ var path = __toESM(require("path"));
1420
+
1421
+ // src/skill_lattice/skillNameValidator.ts
1422
+ var SKILL_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
1423
+ var MIN_LENGTH = 1;
1424
+ var MAX_LENGTH = 64;
1425
+ function isValidSkillName(name) {
1426
+ if (!name || typeof name !== "string") {
1427
+ return false;
1428
+ }
1429
+ if (name.length < MIN_LENGTH || name.length > MAX_LENGTH) {
1430
+ return false;
1431
+ }
1432
+ return SKILL_NAME_REGEX.test(name);
1433
+ }
1434
+ function validateSkillName(name) {
1435
+ if (!name || typeof name !== "string") {
1436
+ throw new Error("Skill name is required and must be a string");
1437
+ }
1438
+ if (name.length < MIN_LENGTH || name.length > MAX_LENGTH) {
1439
+ throw new Error(
1440
+ `Skill name must be between ${MIN_LENGTH} and ${MAX_LENGTH} characters`
1441
+ );
1442
+ }
1443
+ if (!SKILL_NAME_REGEX.test(name)) {
1444
+ throw new Error(
1445
+ "Skill name must be lowercase alphanumeric with single hyphen separators, not start or end with -, and not contain consecutive --. Pattern: ^[a-z0-9]+(-[a-z0-9]+)*$"
1446
+ );
1447
+ }
1448
+ }
1449
+
1450
+ // src/store_lattice/FileSystemSkillStore.ts
1451
+ function parseFrontmatter(content) {
1452
+ const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
1453
+ const match = content.match(frontmatterRegex);
1454
+ if (!match) {
1455
+ console.warn("[parseFrontmatter] No frontmatter match found in content");
1456
+ return { frontmatter: {}, body: content };
1457
+ }
1458
+ const frontmatterText = match[1];
1459
+ const body = match[2] || "";
1460
+ const frontmatter = {};
1461
+ const lines = frontmatterText.split("\n");
1462
+ let currentKey = null;
1463
+ let metadataIndent = 0;
1464
+ for (let i = 0; i < lines.length; i++) {
1465
+ const line = lines[i];
1466
+ const trimmed = line.trim();
1467
+ if (!trimmed || trimmed.startsWith("#")) {
1468
+ continue;
1469
+ }
1470
+ const indentMatch = line.match(/^(\s*)/);
1471
+ const indent = indentMatch ? indentMatch[1].length : 0;
1472
+ if (currentKey === "metadata" && indent > metadataIndent) {
1473
+ const colonIndex2 = trimmed.indexOf(":");
1474
+ if (colonIndex2 !== -1) {
1475
+ const key2 = trimmed.substring(0, colonIndex2).trim();
1476
+ let value2 = trimmed.substring(colonIndex2 + 1).trim();
1477
+ if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
1478
+ value2 = value2.slice(1, -1);
1479
+ }
1480
+ if (!frontmatter.metadata) {
1481
+ frontmatter.metadata = {};
1482
+ }
1483
+ frontmatter.metadata[key2] = value2;
1484
+ }
1485
+ continue;
1486
+ }
1487
+ if (currentKey === "subSkills" && indent > metadataIndent) {
1488
+ if (trimmed.startsWith("-")) {
1489
+ let value2 = trimmed.substring(1).trim();
1490
+ if (value2.startsWith('"') && value2.endsWith('"') || value2.startsWith("'") && value2.endsWith("'")) {
1491
+ value2 = value2.slice(1, -1);
1492
+ }
1493
+ if (!frontmatter.subSkills) {
1494
+ frontmatter.subSkills = [];
1495
+ }
1496
+ frontmatter.subSkills.push(value2);
1497
+ }
1498
+ continue;
1499
+ }
1500
+ if ((currentKey === "metadata" || currentKey === "subSkills") && indent <= metadataIndent) {
1501
+ currentKey = null;
1502
+ metadataIndent = 0;
1503
+ }
1504
+ const colonIndex = trimmed.indexOf(":");
1505
+ if (colonIndex === -1) {
1506
+ continue;
1507
+ }
1508
+ const key = trimmed.substring(0, colonIndex).trim();
1509
+ let value = trimmed.substring(colonIndex + 1).trim();
1510
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
1511
+ value = value.slice(1, -1);
1512
+ }
1513
+ if (key === "metadata") {
1514
+ if (value === "" || value === "{}") {
1515
+ if (i + 1 < lines.length) {
1516
+ const nextLine = lines[i + 1];
1517
+ const nextIndent = nextLine.match(/^(\s*)/)?.[1].length || 0;
1518
+ if (nextIndent > indent) {
1519
+ currentKey = "metadata";
1520
+ metadataIndent = indent;
1521
+ frontmatter.metadata = {};
1522
+ continue;
1523
+ }
1524
+ }
1525
+ frontmatter[key] = {};
1526
+ } else if (value.startsWith("{")) {
1527
+ try {
1528
+ frontmatter[key] = JSON.parse(value);
1529
+ } catch {
1530
+ frontmatter[key] = {};
1531
+ }
1532
+ } else {
1533
+ frontmatter[key] = {};
1534
+ }
1535
+ } else if (key === "subSkills") {
1536
+ if (value === "" || value === "[]") {
1537
+ if (i + 1 < lines.length) {
1538
+ const nextLine = lines[i + 1];
1539
+ const nextIndent = nextLine.match(/^(\s*)/)?.[1].length || 0;
1540
+ if (nextIndent > indent && nextLine.trim().startsWith("-")) {
1541
+ currentKey = "subSkills";
1542
+ metadataIndent = indent;
1543
+ frontmatter.subSkills = [];
1544
+ continue;
1545
+ }
1546
+ }
1547
+ frontmatter[key] = [];
1548
+ } else if (value.startsWith("[")) {
1549
+ try {
1550
+ frontmatter[key] = JSON.parse(value);
1551
+ } catch {
1552
+ frontmatter[key] = [];
1553
+ }
1554
+ } else {
1555
+ frontmatter[key] = [];
1556
+ }
1557
+ } else {
1558
+ frontmatter[key] = value;
1559
+ }
1560
+ }
1561
+ return { frontmatter, body };
1562
+ }
1563
+ function generateFrontmatter(data) {
1564
+ const lines = ["---"];
1565
+ lines.push(`name: ${data.name}`);
1566
+ lines.push(`description: ${data.description}`);
1567
+ if (data.license) {
1568
+ lines.push(`license: ${data.license}`);
1569
+ }
1570
+ if (data.compatibility) {
1571
+ lines.push(`compatibility: ${data.compatibility}`);
1572
+ }
1573
+ if (data.metadata && Object.keys(data.metadata).length > 0) {
1574
+ lines.push("metadata:");
1575
+ for (const [key, value] of Object.entries(data.metadata)) {
1576
+ lines.push(` ${key}: ${value}`);
1577
+ }
1578
+ }
1579
+ if (data.subSkills && data.subSkills.length > 0) {
1580
+ lines.push("subSkills:");
1581
+ for (const subSkill of data.subSkills) {
1582
+ lines.push(` - ${subSkill}`);
1583
+ }
1584
+ }
1585
+ lines.push("---");
1586
+ return lines.join("\n");
1587
+ }
1588
+ var FileSystemSkillStore = class {
1589
+ constructor(options = {}) {
1590
+ const defaultPath = "lattice_store/skills";
1591
+ const providedPath = options.rootDir || defaultPath;
1592
+ if (path.isAbsolute(providedPath)) {
1593
+ this.rootDir = providedPath;
1594
+ } else {
1595
+ this.rootDir = path.resolve(process.cwd(), providedPath);
1596
+ }
1597
+ this.ensureDirectoryExists().catch((error) => {
1598
+ console.error("Failed to initialize FileSystemSkillStore:", error);
1599
+ });
1600
+ }
1601
+ /**
1602
+ * Ensure the root directory exists
1603
+ */
1604
+ async ensureDirectoryExists() {
1605
+ try {
1606
+ await fs.access(this.rootDir);
1607
+ } catch {
1608
+ await fs.mkdir(this.rootDir, { recursive: true });
1609
+ }
1610
+ }
1611
+ /**
1612
+ * Get directory path for a skill name
1613
+ * Name is used as the directory name, and SKILL.md is the fixed filename
1614
+ */
1615
+ getSkillDirectoryPath(name) {
1616
+ if (name.includes("..") || name.includes("/") || name.includes("\\")) {
1617
+ throw new Error(`Invalid skill name: ${name} (contains invalid characters)`);
1618
+ }
1619
+ return path.join(this.rootDir, name);
1620
+ }
1621
+ /**
1622
+ * Get file path for a skill name
1623
+ * File is always named SKILL.md inside the name directory
1624
+ */
1625
+ getSkillFilePath(name) {
1626
+ return path.join(this.getSkillDirectoryPath(name), "SKILL.md");
1627
+ }
1628
+ /**
1629
+ * Read skill from file
1630
+ * Uses name as the directory name and reads SKILL.md from it
1631
+ */
1632
+ async readSkillFile(name) {
1633
+ await this.ensureDirectoryExists();
1634
+ const filePath = this.getSkillFilePath(name);
1635
+ try {
1636
+ const content = await fs.readFile(filePath, "utf-8");
1637
+ const { frontmatter, body } = parseFrontmatter(content);
1638
+ if (!frontmatter.name || !frontmatter.description) {
1639
+ console.warn(
1640
+ `Skill file ${name} parsed frontmatter:`,
1641
+ JSON.stringify(frontmatter, null, 2)
1642
+ );
1643
+ console.warn(`Raw frontmatter text (first 200 chars):`, content.substring(0, 200));
1644
+ }
1645
+ const stats = await fs.stat(filePath);
1646
+ if (!frontmatter.name || !frontmatter.description) {
1647
+ throw new Error(
1648
+ `Invalid skill file ${name}: missing required fields (name or description). Frontmatter: ${JSON.stringify(frontmatter)}`
1649
+ );
1650
+ }
1651
+ if (frontmatter.name !== name) {
1652
+ throw new Error(
1653
+ `Skill name mismatch: directory name is "${name}" but frontmatter name is "${frontmatter.name}"`
1654
+ );
1655
+ }
1656
+ return {
1657
+ id: name,
1658
+ // id equals name (name is used for path addressing)
1659
+ name: frontmatter.name,
1660
+ description: frontmatter.description,
1661
+ license: frontmatter.license,
1662
+ compatibility: frontmatter.compatibility,
1663
+ metadata: frontmatter.metadata || {},
1664
+ content: body.trim() || void 0,
1665
+ subSkills: Array.isArray(frontmatter.subSkills) ? frontmatter.subSkills : void 0,
1666
+ createdAt: stats.birthtime,
1667
+ updatedAt: stats.mtime
1668
+ };
1669
+ } catch (error) {
1670
+ if (error.code === "ENOENT") {
1671
+ console.warn(`Skill file not found: ${filePath}`);
1672
+ return null;
1673
+ }
1674
+ const errorMessage = error instanceof Error ? error.message : String(error);
1675
+ throw new Error(`Failed to read skill file ${filePath}: ${errorMessage}`);
1676
+ }
1677
+ }
1678
+ /**
1679
+ * Write skill to file
1680
+ * Creates directory with name and writes SKILL.md inside it
1681
+ */
1682
+ async writeSkillFile(skill) {
1683
+ await this.ensureDirectoryExists();
1684
+ const skillName = skill.name;
1685
+ const skillDir = this.getSkillDirectoryPath(skillName);
1686
+ const filePath = this.getSkillFilePath(skillName);
1687
+ try {
1688
+ await fs.mkdir(skillDir, { recursive: true });
1689
+ } catch (error) {
1690
+ }
1691
+ const frontmatter = generateFrontmatter({
1692
+ name: skillName,
1693
+ description: skill.description,
1694
+ license: skill.license,
1695
+ compatibility: skill.compatibility,
1696
+ metadata: skill.metadata,
1697
+ subSkills: skill.subSkills
1698
+ });
1699
+ const body = skill.content || "";
1700
+ const content = body ? `${frontmatter}
1701
+ ${body}` : `${frontmatter}
1702
+ `;
1703
+ await fs.writeFile(filePath, content, "utf-8");
1704
+ }
1705
+ /**
1706
+ * Get all skills
1707
+ */
1708
+ async getAllSkills() {
1709
+ await this.ensureDirectoryExists();
1710
+ try {
1711
+ const entries = await fs.readdir(this.rootDir, { withFileTypes: true });
1712
+ const skills = [];
1713
+ for (const entry of entries) {
1714
+ if (entry.isDirectory()) {
1715
+ const skillName = entry.name;
1716
+ try {
1717
+ const skill = await this.readSkillFile(skillName);
1718
+ if (skill) {
1719
+ skills.push(skill);
1720
+ } else {
1721
+ console.warn(
1722
+ `Failed to load skill "${skillName}": readSkillFile returned null`
1723
+ );
1724
+ }
1725
+ } catch (error) {
1726
+ console.error(
1727
+ `Error loading skill "${skillName}" from ${this.getSkillFilePath(skillName)}:`,
1728
+ error instanceof Error ? error.message : String(error)
1729
+ );
1730
+ }
1731
+ }
1732
+ }
1733
+ return skills.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
1734
+ } catch (error) {
1735
+ if (error.code === "ENOENT") {
1736
+ console.warn(
1737
+ `Skills directory not found: ${this.rootDir}`
1738
+ );
1739
+ return [];
1740
+ }
1741
+ throw error;
1742
+ }
1743
+ }
1744
+ /**
1745
+ * Get skill by ID
1746
+ * ID should equal name (name is used for path addressing)
1747
+ */
1748
+ async getSkillById(id) {
1749
+ return this.readSkillFile(id);
1750
+ }
1751
+ /**
1752
+ * Create a new skill
1753
+ * id should equal name (name is used for path addressing)
1754
+ */
1755
+ async createSkill(id, data) {
1756
+ await this.ensureDirectoryExists();
1757
+ validateSkillName(data.name);
1758
+ if (id !== data.name) {
1759
+ throw new Error(
1760
+ `Skill id "${id}" must equal name "${data.name}" (name is used for path addressing)`
1761
+ );
1762
+ }
1763
+ const existing = await this.getSkillById(id);
1764
+ if (existing) {
1765
+ return this.updateSkill(id, data);
1766
+ }
1767
+ const now = /* @__PURE__ */ new Date();
1768
+ const skill = {
1769
+ id: data.name,
1770
+ // id equals name
1771
+ name: data.name,
1772
+ description: data.description,
1773
+ license: data.license,
1774
+ compatibility: data.compatibility,
1775
+ metadata: data.metadata || {},
1776
+ content: data.content,
1777
+ subSkills: data.subSkills,
1778
+ createdAt: now,
1779
+ updatedAt: now
1780
+ };
1781
+ await this.writeSkillFile(skill);
1782
+ return skill;
1783
+ }
1784
+ /**
1785
+ * Update an existing skill
1786
+ */
1787
+ async updateSkill(id, updates) {
1788
+ const skill = await this.readSkillFile(id);
1789
+ if (!skill) {
1790
+ return null;
1791
+ }
1792
+ if (updates.name !== void 0) {
1793
+ validateSkillName(updates.name);
1794
+ if (updates.name !== skill.name) {
1795
+ const oldDir = this.getSkillDirectoryPath(skill.name);
1796
+ const newDir = this.getSkillDirectoryPath(updates.name);
1797
+ try {
1798
+ await fs.rename(oldDir, newDir);
1799
+ } catch (error) {
1800
+ throw new Error(
1801
+ `Failed to rename skill directory from "${skill.name}" to "${updates.name}": ${error instanceof Error ? error.message : String(error)}`
1802
+ );
1803
+ }
1804
+ }
1805
+ }
1806
+ const updatedSkill = {
1807
+ ...skill,
1808
+ name: updates.name ?? skill.name,
1809
+ id: updates.name ?? skill.id,
1810
+ // id equals name
1811
+ description: updates.description ?? skill.description,
1812
+ license: updates.license ?? skill.license,
1813
+ compatibility: updates.compatibility ?? skill.compatibility,
1814
+ metadata: updates.metadata ?? skill.metadata,
1815
+ content: updates.content !== void 0 ? updates.content : skill.content,
1816
+ subSkills: updates.subSkills !== void 0 ? updates.subSkills : skill.subSkills,
1817
+ updatedAt: /* @__PURE__ */ new Date()
1818
+ };
1819
+ await this.writeSkillFile(updatedSkill);
1820
+ return updatedSkill;
1821
+ }
1822
+ /**
1823
+ * Delete a skill by ID
1824
+ * Deletes the entire directory (name is the directory name)
1825
+ */
1826
+ async deleteSkill(id) {
1827
+ await this.ensureDirectoryExists();
1828
+ const skillDir = this.getSkillDirectoryPath(id);
1829
+ try {
1830
+ await fs.rm(skillDir, { recursive: true, force: true });
1831
+ return true;
1832
+ } catch (error) {
1833
+ if (error.code === "ENOENT") {
1834
+ return false;
1835
+ }
1836
+ throw error;
1837
+ }
1838
+ }
1839
+ /**
1840
+ * Check if skill exists
1841
+ */
1842
+ async hasSkill(id) {
1843
+ const skill = await this.getSkillById(id);
1844
+ return skill !== null;
1845
+ }
1846
+ /**
1847
+ * Search skills by metadata
1848
+ */
1849
+ async searchByMetadata(metadataKey, metadataValue) {
1850
+ const allSkills = await this.getAllSkills();
1851
+ return allSkills.filter((skill) => {
1852
+ return skill.metadata && skill.metadata[metadataKey] === metadataValue;
1853
+ });
1854
+ }
1855
+ /**
1856
+ * Filter skills by compatibility
1857
+ */
1858
+ async filterByCompatibility(compatibility) {
1859
+ const allSkills = await this.getAllSkills();
1860
+ return allSkills.filter((skill) => {
1861
+ return skill.compatibility === compatibility;
1862
+ });
1863
+ }
1864
+ /**
1865
+ * Filter skills by license
1866
+ */
1867
+ async filterByLicense(license) {
1868
+ const allSkills = await this.getAllSkills();
1869
+ return allSkills.filter((skill) => {
1870
+ return skill.license === license;
1871
+ });
1872
+ }
1873
+ /**
1874
+ * Get sub-skills of a parent skill
1875
+ */
1876
+ async getSubSkills(parentSkillName) {
1877
+ const parentSkill = await this.getSkillById(parentSkillName);
1878
+ if (!parentSkill || !parentSkill.subSkills || parentSkill.subSkills.length === 0) {
1879
+ return [];
1880
+ }
1881
+ const subSkills = [];
1882
+ for (const subSkillName of parentSkill.subSkills) {
1883
+ const subSkill = await this.getSkillById(subSkillName);
1884
+ if (subSkill) {
1885
+ subSkills.push(subSkill);
1886
+ }
1887
+ }
1888
+ return subSkills;
1889
+ }
1890
+ };
1891
+
1892
+ // src/store_lattice/StoreLatticeManager.ts
1893
+ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager {
1894
+ /**
1895
+ * Get StoreLatticeManager singleton instance
1896
+ */
1897
+ static getInstance() {
1898
+ if (!_StoreLatticeManager._instance) {
1899
+ _StoreLatticeManager._instance = new _StoreLatticeManager();
1900
+ }
1901
+ return _StoreLatticeManager._instance;
1902
+ }
1903
+ /**
1904
+ * Get Lattice type prefix
1905
+ */
1906
+ getLatticeType() {
1907
+ return "stores";
1908
+ }
1909
+ /**
1910
+ * Generate composite key from key and type
1911
+ * @param key Lattice key name
1912
+ * @param type Store type
1913
+ * @returns Composite key string
1914
+ */
1915
+ getCompositeKey(key, type) {
1916
+ return `${key}:${type}`;
1917
+ }
1918
+ /**
1919
+ * Register store Lattice with type safety
1920
+ * Uses composite key (key + type) as unique identifier
1921
+ * @param key Lattice key name
1922
+ * @param type Store type (e.g., "thread")
1923
+ * @param store Store implementation instance matching the type
1924
+ */
1925
+ registerLattice(key, type, store) {
1926
+ const storeLattice = {
1927
+ key,
1928
+ type,
1929
+ store
1930
+ };
1931
+ const compositeKey = this.getCompositeKey(key, type);
1932
+ this.register(compositeKey, storeLattice);
1933
+ }
1934
+ /**
1935
+ * Get StoreLattice with type safety
1936
+ * Uses composite key (key + type) to retrieve the store
1937
+ * @param key Lattice key name
1938
+ * @param type Expected store type for type checking
1939
+ * @returns StoreLattice with typed store
1940
+ */
1941
+ getStoreLattice(key, type) {
1942
+ const compositeKey = this.getCompositeKey(key, type);
1943
+ const storeLattice = this.get(compositeKey);
1944
+ if (!storeLattice) {
1945
+ throw new Error(`StoreLattice ${key}:${type} not found`);
1946
+ }
1947
+ if (storeLattice.type !== type) {
1948
+ throw new Error(
1949
+ `StoreLattice ${key}:${type} has type "${storeLattice.type}", expected "${type}"`
1950
+ );
1951
+ }
1952
+ return storeLattice;
1953
+ }
1954
+ /**
1955
+ * Get StoreLattice without type checking (for backward compatibility)
1956
+ * @param key Lattice key name
1957
+ * @param type Store type
1958
+ * @returns StoreLattice (type may be unknown)
1959
+ */
1960
+ getStoreLatticeUnsafe(key, type) {
1961
+ const compositeKey = this.getCompositeKey(key, type);
1962
+ const storeLattice = this.get(compositeKey);
1963
+ if (!storeLattice) {
1964
+ throw new Error(`StoreLattice ${key}:${type} not found`);
1965
+ }
1966
+ return storeLattice;
1967
+ }
1968
+ /**
1969
+ * Get all Lattices
1970
+ */
1971
+ getAllLattices() {
1972
+ return this.getAll();
1973
+ }
1974
+ /**
1975
+ * Check if Lattice exists
1976
+ * Uses composite key (key + type) to check existence
1977
+ * @param key Lattice key name
1978
+ * @param type Store type
1979
+ */
1980
+ hasLattice(key, type) {
1981
+ const compositeKey = this.getCompositeKey(key, type);
1982
+ return this.has(compositeKey);
1983
+ }
1984
+ /**
1985
+ * Remove Lattice
1986
+ * Uses composite key (key + type) to remove the store
1987
+ * @param key Lattice key name
1988
+ * @param type Store type
1989
+ */
1990
+ removeLattice(key, type) {
1991
+ const compositeKey = this.getCompositeKey(key, type);
1992
+ return this.remove(compositeKey);
1993
+ }
1994
+ /**
1995
+ * Clear all Lattices
1996
+ */
1997
+ clearLattices() {
1998
+ this.clear();
1999
+ }
2000
+ /**
2001
+ * Get Lattice count
2002
+ */
2003
+ getLatticeCount() {
2004
+ return this.count();
2005
+ }
2006
+ /**
2007
+ * Get Lattice key list
2008
+ */
2009
+ getLatticeKeys() {
2010
+ return this.keys();
2011
+ }
2012
+ };
2013
+ var storeLatticeManager = StoreLatticeManager.getInstance();
2014
+ var registerStoreLattice = (key, type, store) => storeLatticeManager.registerLattice(key, type, store);
2015
+ var getStoreLattice = (key, type) => storeLatticeManager.getStoreLattice(key, type);
2016
+ var defaultThreadStore = new InMemoryThreadStore();
2017
+ var defaultAssistantStore = new InMemoryAssistantStore();
2018
+ var defaultSkillStore = new FileSystemSkillStore();
2019
+ storeLatticeManager.registerLattice("default", "thread", defaultThreadStore);
2020
+ storeLatticeManager.registerLattice(
2021
+ "default",
2022
+ "assistant",
2023
+ defaultAssistantStore
2024
+ );
2025
+ storeLatticeManager.registerLattice("default", "skill", defaultSkillStore);
2026
+
2027
+ // src/tool_lattice/load_skills/index.ts
2028
+ var LOAD_SKILLS_DESCRIPTION = `Load all available skills and return their metadata (name, description, license, compatibility, metadata, and subSkills) without the content. This tool returns skill information including hierarchical relationships (subSkills). Use this to discover what skills are available and their structure. Skills can have sub-skills, creating a tree structure for organizing capabilities.`;
2029
+ registerToolLattice(
2030
+ "load_skills",
2031
+ {
2032
+ name: "load_skills",
2033
+ description: LOAD_SKILLS_DESCRIPTION,
2034
+ needUserApprove: false,
2035
+ schema: import_zod7.default.object({})
2036
+ },
2037
+ async () => {
2038
+ try {
2039
+ const storeLattice = getStoreLattice("default", "skill");
2040
+ const skillStore = storeLattice.store;
2041
+ const skills = await skillStore.getAllSkills();
2042
+ const skillsMeta = skills.map((skill) => ({
2043
+ name: skill.name,
2044
+ description: skill.description,
2045
+ license: skill.license,
2046
+ compatibility: skill.compatibility,
2047
+ metadata: skill.metadata,
2048
+ subSkills: skill.subSkills
2049
+ }));
2050
+ return JSON.stringify(skillsMeta, null, 2);
2051
+ } catch (error) {
2052
+ return `Error loading skills: ${error instanceof Error ? error.message : String(error)}`;
2053
+ }
2054
+ }
2055
+ );
2056
+
2057
+ // src/tool_lattice/load_skill_content/index.ts
2058
+ var import_zod8 = __toESM(require("zod"));
2059
+ var LOAD_SKILL_CONTENT_DESCRIPTION = `Load a specific skill's content by name and return its full content including markdown body. This tool returns the complete skill content including frontmatter and markdown body. If the skill has sub-skills defined, they will be listed in the frontmatter. Use this tool to get the complete skill content for a skill that you want to use.`;
2060
+ registerToolLattice(
2061
+ "load_skill_content",
2062
+ {
2063
+ name: "load_skill_content",
2064
+ description: LOAD_SKILL_CONTENT_DESCRIPTION,
2065
+ needUserApprove: false,
2066
+ schema: import_zod8.default.object({
2067
+ skill_name: import_zod8.default.string().describe("The name of the skill to load")
2068
+ })
2069
+ },
2070
+ async (input) => {
2071
+ try {
2072
+ const storeLattice = getStoreLattice("default", "skill");
2073
+ const skillStore = storeLattice.store;
2074
+ const skill = await skillStore.getSkillById(input.skill_name);
2075
+ if (!skill) {
2076
+ const allSkills = await skillStore.getAllSkills();
2077
+ const availableSkills = allSkills.map((s) => s.name).join(", ");
2078
+ return `Skill "${input.skill_name}" not found. Available skills: ${availableSkills}`;
2079
+ }
2080
+ const frontmatter = ["---"];
2081
+ frontmatter.push(`name: ${skill.name}`);
2082
+ frontmatter.push(`description: ${skill.description}`);
2083
+ if (skill.license) {
2084
+ frontmatter.push(`license: ${skill.license}`);
2085
+ }
2086
+ if (skill.compatibility) {
2087
+ frontmatter.push(`compatibility: ${skill.compatibility}`);
2088
+ }
2089
+ if (skill.metadata && Object.keys(skill.metadata).length > 0) {
2090
+ frontmatter.push("metadata:");
2091
+ for (const [key, value] of Object.entries(skill.metadata)) {
2092
+ frontmatter.push(` ${key}: ${value}`);
2093
+ }
2094
+ }
2095
+ if (skill.subSkills && skill.subSkills.length > 0) {
2096
+ frontmatter.push("subSkills:");
2097
+ for (const subSkill of skill.subSkills) {
2098
+ frontmatter.push(` - ${subSkill}`);
2099
+ }
2100
+ }
2101
+ frontmatter.push("---");
2102
+ const content = skill.content || "";
2103
+ return `${frontmatter.join("\n")}
2104
+ ${content}`;
2105
+ } catch (error) {
2106
+ return `Error loading skill content: ${error instanceof Error ? error.message : String(error)}`;
2107
+ }
2108
+ }
2109
+ );
2110
+
1228
2111
  // src/agent_lattice/types.ts
1229
2112
  var import_protocols = require("@axiom-lattice/protocols");
1230
2113
 
@@ -1309,7 +2192,7 @@ var memory = new import_langgraph2.MemorySaver();
1309
2192
  registerCheckpointSaver("default", memory);
1310
2193
 
1311
2194
  // src/agent_lattice/builders/state.ts
1312
- var import_zod7 = require("@langchain/langgraph/zod");
2195
+ var import_zod9 = require("@langchain/langgraph/zod");
1313
2196
  var import_langgraph3 = require("@langchain/langgraph");
1314
2197
  var createReactAgentSchema = (schema) => {
1315
2198
  return schema ? import_langgraph3.MessagesZodState.extend(schema.shape) : void 0;
@@ -1343,13 +2226,13 @@ var ReActAgentGraphBuilder = class {
1343
2226
  };
1344
2227
 
1345
2228
  // src/deep_agent_new/agent.ts
1346
- var import_langchain6 = require("langchain");
2229
+ var import_langchain7 = require("langchain");
1347
2230
 
1348
2231
  // src/deep_agent_new/middleware/fs.ts
1349
2232
  var import_langchain2 = require("langchain");
1350
2233
  var import_langgraph4 = require("@langchain/langgraph");
1351
2234
  var import_v3 = require("zod/v3");
1352
- var import_zod8 = require("@langchain/langgraph/zod");
2235
+ var import_zod10 = require("@langchain/langgraph/zod");
1353
2236
 
1354
2237
  // src/deep_agent_new/backends/utils.ts
1355
2238
  var import_micromatch = __toESM(require("micromatch"));
@@ -1452,8 +2335,8 @@ function performStringReplacement(content, oldString, newString, replaceAll) {
1452
2335
  const newContent = content.split(oldString).join(newString);
1453
2336
  return [newContent, occurrences];
1454
2337
  }
1455
- function validatePath(path) {
1456
- const pathStr = path || "/";
2338
+ function validatePath(path2) {
2339
+ const pathStr = path2 || "/";
1457
2340
  if (!pathStr || pathStr.trim() === "") {
1458
2341
  throw new Error("Path cannot be empty");
1459
2342
  }
@@ -1463,10 +2346,10 @@ function validatePath(path) {
1463
2346
  }
1464
2347
  return normalized;
1465
2348
  }
1466
- function globSearchFiles(files, pattern, path = "/") {
2349
+ function globSearchFiles(files, pattern, path2 = "/") {
1467
2350
  let normalizedPath;
1468
2351
  try {
1469
- normalizedPath = validatePath(path);
2352
+ normalizedPath = validatePath(path2);
1470
2353
  } catch {
1471
2354
  return "No files found";
1472
2355
  }
@@ -1497,7 +2380,7 @@ function globSearchFiles(files, pattern, path = "/") {
1497
2380
  }
1498
2381
  return matches.map(([fp]) => fp).join("\n");
1499
2382
  }
1500
- function grepMatchesFromFiles(files, pattern, path = null, glob = null) {
2383
+ function grepMatchesFromFiles(files, pattern, path2 = null, glob = null) {
1501
2384
  let regex;
1502
2385
  try {
1503
2386
  regex = new RegExp(pattern);
@@ -1506,7 +2389,7 @@ function grepMatchesFromFiles(files, pattern, path = null, glob = null) {
1506
2389
  }
1507
2390
  let normalizedPath;
1508
2391
  try {
1509
- normalizedPath = validatePath(path);
2392
+ normalizedPath = validatePath(path2);
1510
2393
  } catch {
1511
2394
  return [];
1512
2395
  }
@@ -1551,11 +2434,11 @@ var StateBackend = class {
1551
2434
  * @returns List of FileInfo objects for files and directories directly in the directory.
1552
2435
  * Directories have a trailing / in their path and is_dir=true.
1553
2436
  */
1554
- lsInfo(path) {
2437
+ lsInfo(path2) {
1555
2438
  const files = this.getFiles();
1556
2439
  const infos = [];
1557
2440
  const subdirs = /* @__PURE__ */ new Set();
1558
- const normalizedPath = path.endsWith("/") ? path : path + "/";
2441
+ const normalizedPath = path2.endsWith("/") ? path2 : path2 + "/";
1559
2442
  for (const [k, fd] of Object.entries(files)) {
1560
2443
  if (!k.startsWith(normalizedPath)) {
1561
2444
  continue;
@@ -1661,16 +2544,16 @@ var StateBackend = class {
1661
2544
  /**
1662
2545
  * Structured search results or error string for invalid input.
1663
2546
  */
1664
- grepRaw(pattern, path = "/", glob = null) {
2547
+ grepRaw(pattern, path2 = "/", glob = null) {
1665
2548
  const files = this.getFiles();
1666
- return grepMatchesFromFiles(files, pattern, path, glob);
2549
+ return grepMatchesFromFiles(files, pattern, path2, glob);
1667
2550
  }
1668
2551
  /**
1669
2552
  * Structured glob matching returning FileInfo objects.
1670
2553
  */
1671
- globInfo(pattern, path = "/") {
2554
+ globInfo(pattern, path2 = "/") {
1672
2555
  const files = this.getFiles();
1673
- const result = globSearchFiles(files, pattern, path);
2556
+ const result = globSearchFiles(files, pattern, path2);
1674
2557
  if (result === "No files found") {
1675
2558
  return [];
1676
2559
  }
@@ -1717,7 +2600,7 @@ function fileDataReducer(left, right) {
1717
2600
  return result;
1718
2601
  }
1719
2602
  var FilesystemStateSchema = import_v3.z.object({
1720
- files: (0, import_zod8.withLangGraph)(
2603
+ files: (0, import_zod10.withLangGraph)(
1721
2604
  import_v3.z.record(import_v3.z.string(), FileDataSchema).default({}),
1722
2605
  {
1723
2606
  reducer: {
@@ -1756,10 +2639,10 @@ function createLsTool(backend, options) {
1756
2639
  store: config.store
1757
2640
  };
1758
2641
  const resolvedBackend = getBackend(backend, stateAndStore);
1759
- const path = input.path || "/";
1760
- const infos = await resolvedBackend.lsInfo(path);
2642
+ const path2 = input.path || "/";
2643
+ const infos = await resolvedBackend.lsInfo(path2);
1761
2644
  if (infos.length === 0) {
1762
- return `No files found in ${path}`;
2645
+ return `No files found in ${path2}`;
1763
2646
  }
1764
2647
  const lines = [];
1765
2648
  for (const info of infos) {
@@ -1894,8 +2777,8 @@ function createGlobTool(backend, options) {
1894
2777
  store: config.store
1895
2778
  };
1896
2779
  const resolvedBackend = getBackend(backend, stateAndStore);
1897
- const { pattern, path = "/" } = input;
1898
- const infos = await resolvedBackend.globInfo(pattern, path);
2780
+ const { pattern, path: path2 = "/" } = input;
2781
+ const infos = await resolvedBackend.globInfo(pattern, path2);
1899
2782
  if (infos.length === 0) {
1900
2783
  return `No files found matching pattern '${pattern}'`;
1901
2784
  }
@@ -1920,8 +2803,8 @@ function createGrepTool(backend, options) {
1920
2803
  store: config.store
1921
2804
  };
1922
2805
  const resolvedBackend = getBackend(backend, stateAndStore);
1923
- const { pattern, path = "/", glob = null } = input;
1924
- const result = await resolvedBackend.grepRaw(pattern, path, glob);
2806
+ const { pattern, path: path2 = "/", glob = null } = input;
2807
+ const result = await resolvedBackend.grepRaw(pattern, path2, glob);
1925
2808
  if (typeof result === "string") {
1926
2809
  return result;
1927
2810
  }
@@ -2336,12 +3219,12 @@ var AgentManager = class _AgentManager {
2336
3219
  return _AgentManager.instance;
2337
3220
  }
2338
3221
  callAgentInQueue(queue, return_agent_state) {
2339
- return new Promise((resolve, reject) => {
3222
+ return new Promise((resolve2, reject) => {
2340
3223
  const callback_event = `${queue.assistant_id}::${queue.thread_id}`;
2341
3224
  if (return_agent_state) {
2342
3225
  event_bus_default.subscribeOnce(callback_event, (data) => {
2343
3226
  if (data.success) {
2344
- resolve(data.state);
3227
+ resolve2(data.state);
2345
3228
  } else {
2346
3229
  reject(data.error);
2347
3230
  }
@@ -2356,7 +3239,7 @@ var AgentManager = class _AgentManager {
2356
3239
  },
2357
3240
  true
2358
3241
  );
2359
- !return_agent_state && resolve({ callback_event_id: callback_event, success: true });
3242
+ !return_agent_state && resolve2({ callback_event_id: callback_event, success: true });
2360
3243
  } catch (error) {
2361
3244
  !return_agent_state && reject({
2362
3245
  callback_event_id: callback_event,
@@ -2840,7 +3723,7 @@ var SUPPORTS_NOFOLLOW = fsSync.constants.O_NOFOLLOW !== void 0;
2840
3723
 
2841
3724
  // src/deep_agent_new/middleware/todos.ts
2842
3725
  var import_langgraph8 = require("@langchain/langgraph");
2843
- var import_zod9 = require("zod");
3726
+ var import_zod11 = require("zod");
2844
3727
  var import_langchain5 = require("langchain");
2845
3728
  var WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
2846
3729
  It also helps the user understand the progress of the task and overall progress of their requests.
@@ -3068,12 +3951,12 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
3068
3951
  ## Important To-Do List Usage Notes to Remember
3069
3952
  - The \`write_todos\` tool should never be called multiple times in parallel.
3070
3953
  - Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.`;
3071
- var TodoStatus = import_zod9.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
3072
- var TodoSchema = import_zod9.z.object({
3073
- content: import_zod9.z.string().describe("Content of the todo item"),
3954
+ var TodoStatus = import_zod11.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
3955
+ var TodoSchema = import_zod11.z.object({
3956
+ content: import_zod11.z.string().describe("Content of the todo item"),
3074
3957
  status: TodoStatus
3075
3958
  });
3076
- var stateSchema = import_zod9.z.object({ todos: import_zod9.z.array(TodoSchema).default([]) });
3959
+ var stateSchema = import_zod11.z.object({ todos: import_zod11.z.array(TodoSchema).default([]) });
3077
3960
  function todoListMiddleware(options) {
3078
3961
  const writeTodos = (0, import_langchain5.tool)(
3079
3962
  ({ todos }, config) => {
@@ -3092,8 +3975,8 @@ function todoListMiddleware(options) {
3092
3975
  {
3093
3976
  name: "write_todos",
3094
3977
  description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
3095
- schema: import_zod9.z.object({
3096
- todos: import_zod9.z.array(TodoSchema).describe("List of todo items to update")
3978
+ schema: import_zod11.z.object({
3979
+ todos: import_zod11.z.array(TodoSchema).describe("List of todo items to update")
3097
3980
  })
3098
3981
  }
3099
3982
  );
@@ -3110,6 +3993,56 @@ function todoListMiddleware(options) {
3110
3993
  });
3111
3994
  }
3112
3995
 
3996
+ // src/middlewares/skillMiddleware.ts
3997
+ var import_langchain6 = require("langchain");
3998
+ var DEFAULT_HEADING = "## Available Skills";
3999
+ var DEFAULT_EXTRA_NOTE = "Use the load_skill tool when you need detailed information about handling a specific type of request.";
4000
+ function createSkillMiddleware(params = {}) {
4001
+ const {
4002
+ skillCategories,
4003
+ loadSkillTool = getToolClient("load_skill_content"),
4004
+ heading = DEFAULT_HEADING,
4005
+ extraNote = DEFAULT_EXTRA_NOTE
4006
+ } = params;
4007
+ let latestSkills = [];
4008
+ return (0, import_langchain6.createMiddleware)({
4009
+ name: "skillMiddleware",
4010
+ tools: [loadSkillTool],
4011
+ // Fetch the latest skills from the Skill Lattice before the agent runs
4012
+ beforeAgent: async () => {
4013
+ try {
4014
+ if (skillCategories && skillCategories.length > 0) {
4015
+ const storeLattice = getStoreLattice("default", "skill");
4016
+ const skillStore = storeLattice?.store;
4017
+ const skillLatticePromises = skillCategories.map(
4018
+ (category) => skillStore.searchByMetadata("category", category)
4019
+ );
4020
+ const skillLatticesArrays = await Promise.all(skillLatticePromises);
4021
+ latestSkills = skillLatticesArrays.flat().filter((skill) => skill !== void 0);
4022
+ }
4023
+ } catch (error) {
4024
+ console.error("Error fetching skills:", error);
4025
+ }
4026
+ },
4027
+ wrapModelCall: (request, handler) => {
4028
+ const skillsPrompt = latestSkills.map((skill) => `- **${skill.name}**: ${skill.description}`).join("\n");
4029
+ const skillsAddendum = `
4030
+
4031
+ ${heading}
4032
+
4033
+ ${skillsPrompt}
4034
+
4035
+ ${extraNote}`;
4036
+ const existingSystemPrompt = request.systemPrompt ?? "";
4037
+ const newSystemPrompt = existingSystemPrompt.length > 0 ? `${existingSystemPrompt}${skillsAddendum}` : skillsAddendum.trimStart();
4038
+ return handler({
4039
+ ...request,
4040
+ systemPrompt: newSystemPrompt
4041
+ });
4042
+ }
4043
+ });
4044
+ }
4045
+
3113
4046
  // src/deep_agent_new/agent.ts
3114
4047
  var BASE_PROMPT = `In order to complete the objective that the user asks of you, you have access to a number of standard tools.`;
3115
4048
  function createDeepAgent(params = {}) {
@@ -3125,7 +4058,8 @@ function createDeepAgent(params = {}) {
3125
4058
  store,
3126
4059
  backend,
3127
4060
  interruptOn,
3128
- name
4061
+ name,
4062
+ skillCategories
3129
4063
  } = params;
3130
4064
  const finalSystemPrompt = systemPrompt ? `${systemPrompt}
3131
4065
 
@@ -3148,13 +4082,13 @@ ${BASE_PROMPT}` : BASE_PROMPT;
3148
4082
  backend: filesystemBackend
3149
4083
  }),
3150
4084
  // Subagent middleware: Automatic conversation summarization when token limits are approached
3151
- (0, import_langchain6.summarizationMiddleware)({
4085
+ (0, import_langchain7.summarizationMiddleware)({
3152
4086
  model,
3153
4087
  trigger: { tokens: 17e4 },
3154
4088
  keep: { messages: 6 }
3155
4089
  }),
3156
4090
  // Subagent middleware: Anthropic prompt caching for improved performance
3157
- (0, import_langchain6.anthropicPromptCachingMiddleware)({
4091
+ (0, import_langchain7.anthropicPromptCachingMiddleware)({
3158
4092
  unsupportedModelBehavior: "ignore"
3159
4093
  }),
3160
4094
  // Subagent middleware: Patches tool calls for compatibility
@@ -3165,23 +4099,24 @@ ${BASE_PROMPT}` : BASE_PROMPT;
3165
4099
  generalPurposeAgent: false
3166
4100
  }),
3167
4101
  // Automatically summarizes conversation history when token limits are approached
3168
- (0, import_langchain6.summarizationMiddleware)({
4102
+ (0, import_langchain7.summarizationMiddleware)({
3169
4103
  model,
3170
4104
  trigger: { tokens: 17e4 },
3171
4105
  keep: { messages: 6 }
3172
4106
  }),
3173
4107
  // Enables Anthropic prompt caching for improved performance and reduced costs
3174
- (0, import_langchain6.anthropicPromptCachingMiddleware)({
4108
+ (0, import_langchain7.anthropicPromptCachingMiddleware)({
3175
4109
  unsupportedModelBehavior: "ignore"
3176
4110
  }),
3177
4111
  // Patches tool calls to ensure compatibility across different model providers
3178
- createPatchToolCallsMiddleware()
4112
+ createPatchToolCallsMiddleware(),
4113
+ createSkillMiddleware({ skillCategories })
3179
4114
  ];
3180
4115
  if (interruptOn) {
3181
- middleware.push((0, import_langchain6.humanInTheLoopMiddleware)({ interruptOn }));
4116
+ middleware.push((0, import_langchain7.humanInTheLoopMiddleware)({ interruptOn }));
3182
4117
  }
3183
4118
  middleware.push(...customMiddleware);
3184
- return (0, import_langchain6.createAgent)({
4119
+ return (0, import_langchain7.createAgent)({
3185
4120
  model,
3186
4121
  systemPrompt: finalSystemPrompt,
3187
4122
  tools,
@@ -3232,7 +4167,8 @@ var DeepAgentGraphBuilder = class {
3232
4167
  contextSchema: params.stateSchema,
3233
4168
  systemPrompt: params.prompt,
3234
4169
  subagents,
3235
- checkpointer: getCheckpointSaver("default")
4170
+ checkpointer: getCheckpointSaver("default"),
4171
+ skillCategories: params.skillCategories
3236
4172
  });
3237
4173
  return deepAgent;
3238
4174
  }
@@ -3303,6 +4239,7 @@ var AgentParamsBuilder = class {
3303
4239
  * @returns Agent build parameters
3304
4240
  */
3305
4241
  buildParams(agentLattice, options) {
4242
+ const skillCategories = (0, import_protocols4.isDeepAgentConfig)(agentLattice.config) ? agentLattice.config.skillCategories : void 0;
3306
4243
  const toolKeys = options?.overrideTools || (0, import_protocols4.getToolsFromConfig)(agentLattice.config);
3307
4244
  const tools = toolKeys.map((toolKey) => {
3308
4245
  const toolLattice = toolLatticeManager.getToolLattice(toolKey);
@@ -3344,7 +4281,8 @@ var AgentParamsBuilder = class {
3344
4281
  model,
3345
4282
  subAgents: [...subAgents, ...internalSubAgents],
3346
4283
  prompt: agentLattice.config.prompt,
3347
- stateSchema: agentLattice.config.schema
4284
+ stateSchema: agentLattice.config.schema,
4285
+ skillCategories
3348
4286
  };
3349
4287
  }
3350
4288
  };
@@ -3695,9 +4633,9 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
3695
4633
  next: (chunk) => {
3696
4634
  queue.push(chunk);
3697
4635
  if (resolveNext) {
3698
- const resolve = resolveNext;
4636
+ const resolve2 = resolveNext;
3699
4637
  resolveNext = null;
3700
- resolve();
4638
+ resolve2();
3701
4639
  }
3702
4640
  },
3703
4641
  error: (err) => {
@@ -3707,17 +4645,17 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
3707
4645
  errorNext = null;
3708
4646
  reject(err);
3709
4647
  } else if (resolveNext) {
3710
- const resolve = resolveNext;
4648
+ const resolve2 = resolveNext;
3711
4649
  resolveNext = null;
3712
- resolve();
4650
+ resolve2();
3713
4651
  }
3714
4652
  },
3715
4653
  complete: () => {
3716
4654
  isCompleted = true;
3717
4655
  if (resolveNext) {
3718
- const resolve = resolveNext;
4656
+ const resolve2 = resolveNext;
3719
4657
  resolveNext = null;
3720
- resolve();
4658
+ resolve2();
3721
4659
  }
3722
4660
  }
3723
4661
  });
@@ -3729,8 +4667,8 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
3729
4667
  }
3730
4668
  if (queue.length === 0) {
3731
4669
  if (isCompleted) break;
3732
- await new Promise((resolve, reject) => {
3733
- resolveNext = resolve;
4670
+ await new Promise((resolve2, reject) => {
4671
+ resolveNext = resolve2;
3734
4672
  errorNext = reject;
3735
4673
  });
3736
4674
  }
@@ -4755,7 +5693,90 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
4755
5693
  if (!scheduleLattice) {
4756
5694
  throw new Error(`ScheduleLattice ${key} not found`);
4757
5695
  }
4758
- return scheduleLattice;
5696
+ return scheduleLattice;
5697
+ }
5698
+ /**
5699
+ * Get all Lattices
5700
+ */
5701
+ getAllLattices() {
5702
+ return this.getAll();
5703
+ }
5704
+ /**
5705
+ * Check if Lattice exists
5706
+ * @param key Lattice key name
5707
+ */
5708
+ hasLattice(key) {
5709
+ return this.has(key);
5710
+ }
5711
+ /**
5712
+ * Remove Lattice
5713
+ * @param key Lattice key name
5714
+ */
5715
+ removeLattice(key) {
5716
+ return this.remove(key);
5717
+ }
5718
+ /**
5719
+ * Clear all Lattices
5720
+ */
5721
+ clearLattices() {
5722
+ this.clear();
5723
+ }
5724
+ /**
5725
+ * Get Lattice count
5726
+ */
5727
+ getLatticeCount() {
5728
+ return this.count();
5729
+ }
5730
+ /**
5731
+ * Get Lattice key list
5732
+ */
5733
+ getLatticeKeys() {
5734
+ return this.keys();
5735
+ }
5736
+ };
5737
+ var scheduleLatticeManager = ScheduleLatticeManager.getInstance();
5738
+ var registerScheduleLattice = (key, config, client) => scheduleLatticeManager.registerLattice(key, config, client);
5739
+ var getScheduleLattice = (key) => scheduleLatticeManager.getScheduleLattice(key);
5740
+
5741
+ // src/embeddings_lattice/EmbeddingsLatticeManager.ts
5742
+ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatticeManager {
5743
+ /**
5744
+ * Get EmbeddingsLatticeManager singleton instance
5745
+ */
5746
+ static getInstance() {
5747
+ if (!_EmbeddingsLatticeManager._instance) {
5748
+ _EmbeddingsLatticeManager._instance = new _EmbeddingsLatticeManager();
5749
+ }
5750
+ return _EmbeddingsLatticeManager._instance;
5751
+ }
5752
+ /**
5753
+ * Get Lattice type prefix
5754
+ */
5755
+ getLatticeType() {
5756
+ return "embeddings";
5757
+ }
5758
+ /**
5759
+ * Register embeddings Lattice
5760
+ * @param key Lattice key name
5761
+ * @param embeddings Embeddings instance
5762
+ */
5763
+ registerLattice(key, embeddings) {
5764
+ const embeddingsLattice = {
5765
+ key,
5766
+ client: embeddings
5767
+ };
5768
+ this.register(key, embeddingsLattice);
5769
+ }
5770
+ /**
5771
+ * Get EmbeddingsLattice
5772
+ * @param key Lattice key name
5773
+ */
5774
+ getEmbeddingsLattice(key) {
5775
+ const embeddingsLattice = this.get(key);
5776
+ if (!embeddingsLattice) {
5777
+ throw new Error(`EmbeddingsLattice ${key} not found`);
5778
+ }
5779
+ return embeddingsLattice;
4759
5780
  }
4760
5781
  /**
4761
5782
  * Get all Lattices
@@ -4795,261 +5816,383 @@ var ScheduleLatticeManager = class _ScheduleLatticeManager extends BaseLatticeMa
4795
5816
  getLatticeKeys() {
4796
5817
  return this.keys();
4797
5818
  }
4798
- };
4799
- var scheduleLatticeManager = ScheduleLatticeManager.getInstance();
4800
- var registerScheduleLattice = (key, config, client) => scheduleLatticeManager.registerLattice(key, config, client);
4801
- var getScheduleLattice = (key) => scheduleLatticeManager.getScheduleLattice(key);
4802
-
4803
- // src/store_lattice/InMemoryThreadStore.ts
4804
- var InMemoryThreadStore = class {
4805
- constructor() {
4806
- // Map<assistantId, Map<threadId, Thread>>
4807
- this.threads = /* @__PURE__ */ new Map();
4808
- }
4809
5819
  /**
4810
- * Get all threads for a specific assistant
5820
+ * Get embeddings client
5821
+ * @param key Lattice key name
4811
5822
  */
4812
- async getThreadsByAssistantId(assistantId) {
4813
- const assistantThreads = this.threads.get(assistantId);
4814
- if (!assistantThreads) {
4815
- return [];
4816
- }
4817
- return Array.from(assistantThreads.values());
5823
+ getEmbeddingsClient(key) {
5824
+ const embeddingsLattice = this.getEmbeddingsLattice(key);
5825
+ return embeddingsLattice.client;
4818
5826
  }
5827
+ };
5828
+ var embeddingsLatticeManager = EmbeddingsLatticeManager.getInstance();
5829
+ var registerEmbeddingsLattice = (key, embeddings) => embeddingsLatticeManager.registerLattice(key, embeddings);
5830
+ var getEmbeddingsLattice = (key) => embeddingsLatticeManager.getEmbeddingsLattice(key);
5831
+ var getEmbeddingsClient = (key) => embeddingsLatticeManager.getEmbeddingsClient(key);
5832
+
5833
+ // src/vectorstore_lattice/VectorStoreLatticeManager.ts
5834
+ var VectorStoreLatticeManager = class _VectorStoreLatticeManager extends BaseLatticeManager {
4819
5835
  /**
4820
- * Get a thread by ID for a specific assistant
5836
+ * Get VectorStoreLatticeManager singleton instance
4821
5837
  */
4822
- async getThreadById(assistantId, threadId) {
4823
- const assistantThreads = this.threads.get(assistantId);
4824
- if (!assistantThreads) {
4825
- return void 0;
5838
+ static getInstance() {
5839
+ if (!_VectorStoreLatticeManager._instance) {
5840
+ _VectorStoreLatticeManager._instance = new _VectorStoreLatticeManager();
4826
5841
  }
4827
- return assistantThreads.get(threadId);
5842
+ return _VectorStoreLatticeManager._instance;
4828
5843
  }
4829
5844
  /**
4830
- * Create a new thread for an assistant
5845
+ * Get Lattice type prefix
4831
5846
  */
4832
- async createThread(assistantId, threadId, data) {
4833
- const now = /* @__PURE__ */ new Date();
4834
- const thread = {
4835
- id: threadId,
4836
- assistantId,
4837
- metadata: data.metadata || {},
4838
- createdAt: now,
4839
- updatedAt: now
4840
- };
4841
- if (!this.threads.has(assistantId)) {
4842
- this.threads.set(assistantId, /* @__PURE__ */ new Map());
4843
- }
4844
- const assistantThreads = this.threads.get(assistantId);
4845
- assistantThreads.set(threadId, thread);
4846
- return thread;
5847
+ getLatticeType() {
5848
+ return "vectorstores";
4847
5849
  }
4848
5850
  /**
4849
- * Update an existing thread
5851
+ * Register vector store Lattice
5852
+ * @param key Lattice key name
5853
+ * @param vectorStore VectorStore instance
4850
5854
  */
4851
- async updateThread(assistantId, threadId, updates) {
4852
- const assistantThreads = this.threads.get(assistantId);
4853
- if (!assistantThreads) {
4854
- return null;
4855
- }
4856
- const existing = assistantThreads.get(threadId);
4857
- if (!existing) {
4858
- return null;
4859
- }
4860
- const updated = {
4861
- ...existing,
4862
- metadata: {
4863
- ...existing.metadata,
4864
- ...updates.metadata || {}
4865
- },
4866
- updatedAt: /* @__PURE__ */ new Date()
5855
+ registerLattice(key, vectorStore) {
5856
+ const vectorStoreLattice = {
5857
+ key,
5858
+ client: vectorStore
4867
5859
  };
4868
- assistantThreads.set(threadId, updated);
4869
- return updated;
5860
+ this.register(key, vectorStoreLattice);
4870
5861
  }
4871
5862
  /**
4872
- * Delete a thread by ID
5863
+ * Get VectorStoreLattice
5864
+ * @param key Lattice key name
4873
5865
  */
4874
- async deleteThread(assistantId, threadId) {
4875
- const assistantThreads = this.threads.get(assistantId);
4876
- if (!assistantThreads) {
4877
- return false;
5866
+ getVectorStoreLattice(key) {
5867
+ const vectorStoreLattice = this.get(key);
5868
+ if (!vectorStoreLattice) {
5869
+ throw new Error(`VectorStoreLattice ${key} not found`);
4878
5870
  }
4879
- return assistantThreads.delete(threadId);
5871
+ return vectorStoreLattice;
4880
5872
  }
4881
5873
  /**
4882
- * Check if thread exists
5874
+ * Get all Lattices
4883
5875
  */
4884
- async hasThread(assistantId, threadId) {
4885
- const assistantThreads = this.threads.get(assistantId);
4886
- if (!assistantThreads) {
4887
- return false;
4888
- }
4889
- return assistantThreads.has(threadId);
5876
+ getAllLattices() {
5877
+ return this.getAll();
4890
5878
  }
4891
5879
  /**
4892
- * Clear all threads (useful for testing)
5880
+ * Check if Lattice exists
5881
+ * @param key Lattice key name
4893
5882
  */
4894
- clear() {
4895
- this.threads.clear();
5883
+ hasLattice(key) {
5884
+ return this.has(key);
4896
5885
  }
4897
5886
  /**
4898
- * Get all threads for all assistants (useful for debugging)
5887
+ * Remove Lattice
5888
+ * @param key Lattice key name
4899
5889
  */
4900
- getAllThreads() {
4901
- const allThreads = [];
4902
- for (const assistantThreads of this.threads.values()) {
4903
- allThreads.push(...Array.from(assistantThreads.values()));
4904
- }
4905
- return allThreads;
4906
- }
4907
- };
4908
-
4909
- // src/store_lattice/InMemoryAssistantStore.ts
4910
- var InMemoryAssistantStore = class {
4911
- constructor() {
4912
- this.assistants = /* @__PURE__ */ new Map();
5890
+ removeLattice(key) {
5891
+ return this.remove(key);
4913
5892
  }
4914
5893
  /**
4915
- * Get all assistants
5894
+ * Clear all Lattices
4916
5895
  */
4917
- async getAllAssistants() {
4918
- return Array.from(this.assistants.values());
5896
+ clearLattices() {
5897
+ this.clear();
4919
5898
  }
4920
5899
  /**
4921
- * Get assistant by ID
5900
+ * Get Lattice count
4922
5901
  */
4923
- async getAssistantById(id) {
4924
- return this.assistants.get(id) || null;
5902
+ getLatticeCount() {
5903
+ return this.count();
4925
5904
  }
4926
5905
  /**
4927
- * Create a new assistant
5906
+ * Get Lattice key list
4928
5907
  */
4929
- async createAssistant(id, data) {
4930
- const now = /* @__PURE__ */ new Date();
4931
- const assistant = {
4932
- id,
4933
- name: data.name,
4934
- description: data.description,
4935
- graphDefinition: data.graphDefinition,
4936
- createdAt: now,
4937
- updatedAt: now
4938
- };
4939
- this.assistants.set(id, assistant);
4940
- return assistant;
5908
+ getLatticeKeys() {
5909
+ return this.keys();
4941
5910
  }
4942
5911
  /**
4943
- * Update an existing assistant
5912
+ * Get vector store client
5913
+ * @param key Lattice key name
4944
5914
  */
4945
- async updateAssistant(id, updates) {
4946
- const existing = this.assistants.get(id);
4947
- if (!existing) {
4948
- return null;
4949
- }
4950
- const updated = {
4951
- ...existing,
4952
- ...updates,
4953
- updatedAt: /* @__PURE__ */ new Date()
5915
+ getVectorStoreClient(key) {
5916
+ const vectorStoreLattice = this.getVectorStoreLattice(key);
5917
+ return vectorStoreLattice.client;
5918
+ }
5919
+ };
5920
+ var vectorStoreLatticeManager = VectorStoreLatticeManager.getInstance();
5921
+ var registerVectorStoreLattice = (key, vectorStore) => vectorStoreLatticeManager.registerLattice(key, vectorStore);
5922
+ var getVectorStoreLattice = (key) => vectorStoreLatticeManager.getVectorStoreLattice(key);
5923
+ var getVectorStoreClient = (key) => vectorStoreLatticeManager.getVectorStoreClient(key);
5924
+
5925
+ // src/logger_lattice/LoggerLatticeManager.ts
5926
+ var import_protocols8 = require("@axiom-lattice/protocols");
5927
+
5928
+ // src/logger_lattice/PinoLoggerClient.ts
5929
+ var import_pino = __toESM(require("pino"));
5930
+ var import_pino_pretty = require("pino-pretty");
5931
+ var import_pino_roll = require("pino-roll");
5932
+ var PinoLoggerClient = class _PinoLoggerClient {
5933
+ constructor(config) {
5934
+ this.config = config;
5935
+ this.context = config.context || {};
5936
+ const loggerConfig = {
5937
+ // Custom timestamp format
5938
+ timestamp: () => `,"@timestamp":"${(/* @__PURE__ */ new Date()).toISOString()}"`,
5939
+ // Base metadata
5940
+ base: {
5941
+ "@version": "1",
5942
+ app_name: "lattice",
5943
+ service_name: config.serviceName || "lattice-service",
5944
+ thread_name: "main",
5945
+ logger_name: config.loggerName || config.name || "lattice-logger"
5946
+ },
5947
+ formatters: {
5948
+ level: (label, number) => {
5949
+ return {
5950
+ level: label.toUpperCase(),
5951
+ level_value: number * 1e3
5952
+ };
5953
+ }
5954
+ }
4954
5955
  };
4955
- this.assistants.set(id, updated);
4956
- return updated;
5956
+ const useFileLogging = this.shouldUseFileLogging(config);
5957
+ const fileOptions = this.getFileOptions(config);
5958
+ if (useFileLogging && fileOptions) {
5959
+ try {
5960
+ this.pinoLogger = (0, import_pino.default)(
5961
+ loggerConfig,
5962
+ import_pino.default.transport({
5963
+ target: "pino-roll",
5964
+ options: {
5965
+ file: fileOptions.file || "./logs/app",
5966
+ frequency: fileOptions.frequency || "daily",
5967
+ mkdir: fileOptions.mkdir !== false,
5968
+ // Default to true
5969
+ size: fileOptions.size,
5970
+ maxFiles: fileOptions.maxFiles
5971
+ }
5972
+ })
5973
+ );
5974
+ } catch (error) {
5975
+ console.error(
5976
+ "Failed to initialize pino-roll logger, falling back to console",
5977
+ error
5978
+ );
5979
+ this.pinoLogger = (0, import_pino.default)({
5980
+ ...loggerConfig,
5981
+ transport: {
5982
+ target: "pino-pretty",
5983
+ options: {
5984
+ colorize: true
5985
+ }
5986
+ }
5987
+ });
5988
+ }
5989
+ } else {
5990
+ this.pinoLogger = (0, import_pino.default)({
5991
+ ...loggerConfig,
5992
+ transport: {
5993
+ target: "pino-pretty",
5994
+ options: {
5995
+ colorize: true
5996
+ }
5997
+ }
5998
+ });
5999
+ }
4957
6000
  }
4958
6001
  /**
4959
- * Delete an assistant by ID
6002
+ * Determine if file logging should be used
4960
6003
  */
4961
- async deleteAssistant(id) {
4962
- return this.assistants.delete(id);
6004
+ shouldUseFileLogging(config) {
6005
+ const hasFileConfig = config.file !== void 0;
6006
+ const isProduction = process.env.NODE_ENV === "production";
6007
+ return hasFileConfig || isProduction;
4963
6008
  }
4964
6009
  /**
4965
- * Check if assistant exists
6010
+ * Get file options from config
4966
6011
  */
4967
- async hasAssistant(id) {
4968
- return this.assistants.has(id);
6012
+ getFileOptions(config) {
6013
+ if (!config.file) {
6014
+ if (process.env.NODE_ENV === "production") {
6015
+ return {
6016
+ file: "./logs/app",
6017
+ frequency: "daily",
6018
+ mkdir: true
6019
+ };
6020
+ }
6021
+ return null;
6022
+ }
6023
+ if (typeof config.file === "string") {
6024
+ return {
6025
+ file: config.file,
6026
+ frequency: "daily",
6027
+ mkdir: true
6028
+ };
6029
+ }
6030
+ return config.file;
4969
6031
  }
4970
6032
  /**
4971
- * Clear all assistants (useful for testing)
6033
+ * Get contextual logger with merged context
4972
6034
  */
4973
- clear() {
4974
- this.assistants.clear();
6035
+ getContextualLogger(additionalContext) {
6036
+ const contextObj = {
6037
+ "x-user-id": this.context["x-user-id"] || "",
6038
+ "x-tenant-id": this.context["x-tenant-id"] || "",
6039
+ "x-request-id": this.context["x-request-id"] || "",
6040
+ "x-thread-id": this.context["x-thread-id"] || "",
6041
+ service_name: this.config.serviceName || "lattice-service",
6042
+ logger_name: this.config.loggerName || this.config.name || "lattice-logger",
6043
+ ...additionalContext
6044
+ };
6045
+ return this.pinoLogger.child(contextObj);
6046
+ }
6047
+ info(msg, obj) {
6048
+ this.getContextualLogger(obj).info(msg);
6049
+ }
6050
+ error(msg, obj) {
6051
+ this.getContextualLogger(obj).error(msg);
6052
+ }
6053
+ warn(msg, obj) {
6054
+ this.getContextualLogger(obj).warn(msg);
6055
+ }
6056
+ debug(msg, obj) {
6057
+ this.getContextualLogger(obj).debug(msg);
6058
+ }
6059
+ updateContext(context) {
6060
+ this.context = {
6061
+ ...this.context,
6062
+ ...context
6063
+ };
6064
+ }
6065
+ child(options) {
6066
+ return new _PinoLoggerClient({
6067
+ ...this.config,
6068
+ ...options,
6069
+ context: {
6070
+ ...this.context,
6071
+ ...options.context
6072
+ }
6073
+ });
6074
+ }
6075
+ };
6076
+
6077
+ // src/logger_lattice/ConsoleLoggerClient.ts
6078
+ var ConsoleLoggerClient = class _ConsoleLoggerClient {
6079
+ constructor(config) {
6080
+ this.config = config;
6081
+ this.context = config.context || {};
6082
+ }
6083
+ formatMessage(level, msg, obj) {
6084
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
6085
+ const contextStr = Object.keys(this.context).length > 0 ? ` [${JSON.stringify(this.context)}]` : "";
6086
+ const objStr = obj ? ` ${JSON.stringify(obj)}` : "";
6087
+ return `[${timestamp}] [${level}]${contextStr} ${msg}${objStr}`;
6088
+ }
6089
+ info(msg, obj) {
6090
+ console.log(this.formatMessage("INFO", msg, obj));
6091
+ }
6092
+ error(msg, obj) {
6093
+ console.error(this.formatMessage("ERROR", msg, obj));
6094
+ }
6095
+ warn(msg, obj) {
6096
+ console.warn(this.formatMessage("WARN", msg, obj));
6097
+ }
6098
+ debug(msg, obj) {
6099
+ console.debug(this.formatMessage("DEBUG", msg, obj));
6100
+ }
6101
+ updateContext(context) {
6102
+ this.context = {
6103
+ ...this.context,
6104
+ ...context
6105
+ };
6106
+ }
6107
+ child(options) {
6108
+ const childClient = new _ConsoleLoggerClient({
6109
+ ...this.config,
6110
+ ...options,
6111
+ context: {
6112
+ ...this.context,
6113
+ ...options.context
6114
+ }
6115
+ });
6116
+ return childClient;
4975
6117
  }
4976
6118
  };
4977
6119
 
4978
- // src/store_lattice/StoreLatticeManager.ts
4979
- var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager {
6120
+ // src/logger_lattice/LoggerLatticeManager.ts
6121
+ var LoggerLatticeManager = class _LoggerLatticeManager extends BaseLatticeManager {
4980
6122
  /**
4981
- * Get StoreLatticeManager singleton instance
6123
+ * Get LoggerLatticeManager singleton instance
4982
6124
  */
4983
6125
  static getInstance() {
4984
- if (!_StoreLatticeManager._instance) {
4985
- _StoreLatticeManager._instance = new _StoreLatticeManager();
6126
+ if (!_LoggerLatticeManager._instance) {
6127
+ _LoggerLatticeManager._instance = new _LoggerLatticeManager();
4986
6128
  }
4987
- return _StoreLatticeManager._instance;
6129
+ return _LoggerLatticeManager._instance;
4988
6130
  }
4989
6131
  /**
4990
6132
  * Get Lattice type prefix
4991
6133
  */
4992
6134
  getLatticeType() {
4993
- return "stores";
4994
- }
4995
- /**
4996
- * Generate composite key from key and type
4997
- * @param key Lattice key name
4998
- * @param type Store type
4999
- * @returns Composite key string
5000
- */
5001
- getCompositeKey(key, type) {
5002
- return `${key}:${type}`;
6135
+ return "loggers";
5003
6136
  }
5004
6137
  /**
5005
- * Register store Lattice with type safety
5006
- * Uses composite key (key + type) as unique identifier
6138
+ * Register logger Lattice
5007
6139
  * @param key Lattice key name
5008
- * @param type Store type (e.g., "thread")
5009
- * @param store Store implementation instance matching the type
6140
+ * @param config Logger configuration
6141
+ * @param client Optional logger client. If not provided, will create based on config type.
5010
6142
  */
5011
- registerLattice(key, type, store) {
5012
- const storeLattice = {
6143
+ registerLattice(key, config, client) {
6144
+ let loggerClient;
6145
+ if (client) {
6146
+ loggerClient = client;
6147
+ } else {
6148
+ if (config.type === import_protocols8.LoggerType.PINO) {
6149
+ loggerClient = new PinoLoggerClient(config);
6150
+ } else if (config.type === import_protocols8.LoggerType.CONSOLE) {
6151
+ loggerClient = new ConsoleLoggerClient(config);
6152
+ } else if (config.type === import_protocols8.LoggerType.CUSTOM) {
6153
+ throw new Error(
6154
+ `Custom logger client must be provided. Please pass the client to registerLattice.`
6155
+ );
6156
+ } else {
6157
+ loggerClient = new PinoLoggerClient(config);
6158
+ }
6159
+ }
6160
+ const loggerLattice = {
5013
6161
  key,
5014
- type,
5015
- store
6162
+ config,
6163
+ client: loggerClient,
6164
+ // Logger operations
6165
+ info: (msg, obj) => {
6166
+ loggerClient.info(msg, obj);
6167
+ },
6168
+ error: (msg, obj) => {
6169
+ loggerClient.error(msg, obj);
6170
+ },
6171
+ warn: (msg, obj) => {
6172
+ loggerClient.warn(msg, obj);
6173
+ },
6174
+ debug: (msg, obj) => {
6175
+ loggerClient.debug(msg, obj);
6176
+ },
6177
+ updateContext: loggerClient.updateContext ? (context) => {
6178
+ loggerClient.updateContext(context);
6179
+ } : void 0,
6180
+ child: loggerClient.child ? (options) => {
6181
+ return loggerClient.child(options);
6182
+ } : void 0
5016
6183
  };
5017
- const compositeKey = this.getCompositeKey(key, type);
5018
- this.register(compositeKey, storeLattice);
5019
- }
5020
- /**
5021
- * Get StoreLattice with type safety
5022
- * Uses composite key (key + type) to retrieve the store
5023
- * @param key Lattice key name
5024
- * @param type Expected store type for type checking
5025
- * @returns StoreLattice with typed store
5026
- */
5027
- getStoreLattice(key, type) {
5028
- const compositeKey = this.getCompositeKey(key, type);
5029
- const storeLattice = this.get(compositeKey);
5030
- if (!storeLattice) {
5031
- throw new Error(`StoreLattice ${key}:${type} not found`);
5032
- }
5033
- if (storeLattice.type !== type) {
5034
- throw new Error(
5035
- `StoreLattice ${key}:${type} has type "${storeLattice.type}", expected "${type}"`
5036
- );
5037
- }
5038
- return storeLattice;
6184
+ this.register(key, loggerLattice);
5039
6185
  }
5040
6186
  /**
5041
- * Get StoreLattice without type checking (for backward compatibility)
6187
+ * Get LoggerLattice
5042
6188
  * @param key Lattice key name
5043
- * @param type Store type
5044
- * @returns StoreLattice (type may be unknown)
5045
6189
  */
5046
- getStoreLatticeUnsafe(key, type) {
5047
- const compositeKey = this.getCompositeKey(key, type);
5048
- const storeLattice = this.get(compositeKey);
5049
- if (!storeLattice) {
5050
- throw new Error(`StoreLattice ${key}:${type} not found`);
6190
+ getLoggerLattice(key) {
6191
+ const loggerLattice = this.get(key);
6192
+ if (!loggerLattice) {
6193
+ throw new Error(`LoggerLattice ${key} not found`);
5051
6194
  }
5052
- return storeLattice;
6195
+ return loggerLattice;
5053
6196
  }
5054
6197
  /**
5055
6198
  * Get all Lattices
@@ -5059,23 +6202,17 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
5059
6202
  }
5060
6203
  /**
5061
6204
  * Check if Lattice exists
5062
- * Uses composite key (key + type) to check existence
5063
6205
  * @param key Lattice key name
5064
- * @param type Store type
5065
6206
  */
5066
- hasLattice(key, type) {
5067
- const compositeKey = this.getCompositeKey(key, type);
5068
- return this.has(compositeKey);
6207
+ hasLattice(key) {
6208
+ return this.has(key);
5069
6209
  }
5070
6210
  /**
5071
6211
  * Remove Lattice
5072
- * Uses composite key (key + type) to remove the store
5073
6212
  * @param key Lattice key name
5074
- * @param type Store type
5075
6213
  */
5076
- removeLattice(key, type) {
5077
- const compositeKey = this.getCompositeKey(key, type);
5078
- return this.remove(compositeKey);
6214
+ removeLattice(key) {
6215
+ return this.remove(key);
5079
6216
  }
5080
6217
  /**
5081
6218
  * Clear all Lattices
@@ -5096,63 +6233,151 @@ var StoreLatticeManager = class _StoreLatticeManager extends BaseLatticeManager
5096
6233
  return this.keys();
5097
6234
  }
5098
6235
  };
5099
- var storeLatticeManager = StoreLatticeManager.getInstance();
5100
- var registerStoreLattice = (key, type, store) => storeLatticeManager.registerLattice(key, type, store);
5101
- var getStoreLattice = (key, type) => storeLatticeManager.getStoreLattice(key, type);
5102
- var defaultThreadStore = new InMemoryThreadStore();
5103
- var defaultAssistantStore = new InMemoryAssistantStore();
5104
- storeLatticeManager.registerLattice("default", "thread", defaultThreadStore);
5105
- storeLatticeManager.registerLattice(
5106
- "default",
5107
- "assistant",
5108
- defaultAssistantStore
5109
- );
6236
+ var loggerLatticeManager = LoggerLatticeManager.getInstance();
6237
+ var registerLoggerLattice = (key, config, client) => loggerLatticeManager.registerLattice(key, config, client);
6238
+ var getLoggerLattice = (key) => loggerLatticeManager.getLoggerLattice(key);
5110
6239
 
5111
- // src/embeddings_lattice/EmbeddingsLatticeManager.ts
5112
- var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatticeManager {
6240
+ // src/skill_lattice/SkillLatticeManager.ts
6241
+ var SkillLatticeManager = class _SkillLatticeManager extends BaseLatticeManager {
5113
6242
  /**
5114
- * Get EmbeddingsLatticeManager singleton instance
6243
+ * Get SkillLatticeManager singleton instance
5115
6244
  */
5116
6245
  static getInstance() {
5117
- if (!_EmbeddingsLatticeManager._instance) {
5118
- _EmbeddingsLatticeManager._instance = new _EmbeddingsLatticeManager();
6246
+ if (!_SkillLatticeManager._instance) {
6247
+ _SkillLatticeManager._instance = new _SkillLatticeManager();
5119
6248
  }
5120
- return _EmbeddingsLatticeManager._instance;
6249
+ return _SkillLatticeManager._instance;
5121
6250
  }
5122
6251
  /**
5123
6252
  * Get Lattice type prefix
5124
6253
  */
5125
6254
  getLatticeType() {
5126
- return "embeddings";
6255
+ return "skills";
5127
6256
  }
5128
6257
  /**
5129
- * Register embeddings Lattice
6258
+ * Configure store for persistence
6259
+ * @param storeKey Store key name registered in StoreLatticeManager
6260
+ */
6261
+ configureStore(storeKey) {
6262
+ this.storeKey = storeKey;
6263
+ }
6264
+ /**
6265
+ * Get configured store
6266
+ * @returns SkillStore instance if configured, null otherwise
6267
+ */
6268
+ getStore() {
6269
+ if (!this.storeKey) {
6270
+ return null;
6271
+ }
6272
+ try {
6273
+ const storeLattice = storeLatticeManager.getStoreLattice(
6274
+ this.storeKey,
6275
+ "skill"
6276
+ );
6277
+ return storeLattice.store;
6278
+ } catch {
6279
+ return null;
6280
+ }
6281
+ }
6282
+ /**
6283
+ * Inject store into client if client supports it
6284
+ * @param client Skill client instance
6285
+ * @param store Store instance to inject
6286
+ */
6287
+ injectStoreIntoClient(client, store) {
6288
+ if (!client || typeof client !== "object") {
6289
+ return;
6290
+ }
6291
+ if (typeof client.setStore === "function") {
6292
+ client.setStore(store);
6293
+ }
6294
+ client.store = store;
6295
+ }
6296
+ /**
6297
+ * Register a skill Lattice
5130
6298
  * @param key Lattice key name
5131
- * @param embeddings Embeddings instance
6299
+ * @param config Skill configuration
6300
+ * @param client Optional skill client implementation
5132
6301
  */
5133
- registerLattice(key, embeddings) {
5134
- const embeddingsLattice = {
6302
+ async registerLattice(key, config, client) {
6303
+ if (!config.name) {
6304
+ throw new Error("Skill name is required");
6305
+ }
6306
+ if (!config.description) {
6307
+ throw new Error("Skill description is required");
6308
+ }
6309
+ validateSkillName(config.name);
6310
+ if (key !== config.name) {
6311
+ throw new Error(
6312
+ `Skill key "${key}" must equal name "${config.name}" (name is used for path addressing)`
6313
+ );
6314
+ }
6315
+ const store = this.getStore();
6316
+ if (client && store) {
6317
+ this.injectStoreIntoClient(client, store);
6318
+ }
6319
+ const skillLattice = {
5135
6320
  key,
5136
- client: embeddings
6321
+ config,
6322
+ client: client ?? null
5137
6323
  };
5138
- this.register(key, embeddingsLattice);
6324
+ this.register(key, skillLattice);
6325
+ if (store) {
6326
+ try {
6327
+ await store.createSkill(key, {
6328
+ name: config.name,
6329
+ description: config.description,
6330
+ license: config.license,
6331
+ compatibility: config.compatibility,
6332
+ metadata: config.metadata,
6333
+ content: config.content,
6334
+ subSkills: config.subSkills
6335
+ });
6336
+ } catch (error) {
6337
+ console.warn(
6338
+ `Failed to persist skill ${key} to store:`,
6339
+ error instanceof Error ? error.message : String(error)
6340
+ );
6341
+ }
6342
+ }
5139
6343
  }
5140
6344
  /**
5141
- * Get EmbeddingsLattice
6345
+ * Get skill Lattice by key
5142
6346
  * @param key Lattice key name
5143
6347
  */
5144
- getEmbeddingsLattice(key) {
5145
- const embeddingsLattice = this.get(key);
5146
- if (!embeddingsLattice) {
5147
- throw new Error(`EmbeddingsLattice ${key} not found`);
5148
- }
5149
- return embeddingsLattice;
6348
+ getSkillLattice(key) {
6349
+ return this.get(key);
5150
6350
  }
5151
6351
  /**
5152
- * Get all Lattices
6352
+ * Get all skill Lattices from store
6353
+ * Always reads from the configured store and merges with in-memory clients
5153
6354
  */
5154
- getAllLattices() {
5155
- return this.getAll();
6355
+ async getAllLattices() {
6356
+ const store = this.getStore();
6357
+ if (!store) {
6358
+ return this.getAll();
6359
+ }
6360
+ const skills = await store.getAllSkills();
6361
+ return skills.map((skill) => {
6362
+ const memoryLattice = this.get(skill.id);
6363
+ const client = memoryLattice?.client || null;
6364
+ if (client && store) {
6365
+ this.injectStoreIntoClient(client, store);
6366
+ }
6367
+ return {
6368
+ key: skill.id,
6369
+ config: {
6370
+ name: skill.name,
6371
+ description: skill.description,
6372
+ license: skill.license,
6373
+ compatibility: skill.compatibility,
6374
+ metadata: skill.metadata,
6375
+ content: skill.content,
6376
+ subSkills: skill.subSkills
6377
+ },
6378
+ client
6379
+ };
6380
+ });
5156
6381
  }
5157
6382
  /**
5158
6383
  * Check if Lattice exists
@@ -5165,8 +6390,22 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
5165
6390
  * Remove Lattice
5166
6391
  * @param key Lattice key name
5167
6392
  */
5168
- removeLattice(key) {
5169
- return this.remove(key);
6393
+ async removeLattice(key) {
6394
+ const removed = this.remove(key);
6395
+ if (removed) {
6396
+ const store = this.getStore();
6397
+ if (store) {
6398
+ try {
6399
+ await store.deleteSkill(key);
6400
+ } catch (error) {
6401
+ console.warn(
6402
+ `Failed to remove skill ${key} from store:`,
6403
+ error instanceof Error ? error.message : String(error)
6404
+ );
6405
+ }
6406
+ }
6407
+ }
6408
+ return removed;
5170
6409
  }
5171
6410
  /**
5172
6411
  * Clear all Lattices
@@ -5181,116 +6420,139 @@ var EmbeddingsLatticeManager = class _EmbeddingsLatticeManager extends BaseLatti
5181
6420
  return this.count();
5182
6421
  }
5183
6422
  /**
5184
- * Get Lattice key list
6423
+ * Get Lattice key name list
5185
6424
  */
5186
6425
  getLatticeKeys() {
5187
6426
  return this.keys();
5188
6427
  }
5189
6428
  /**
5190
- * Get embeddings client
6429
+ * Get skill configuration
5191
6430
  * @param key Lattice key name
5192
6431
  */
5193
- getEmbeddingsClient(key) {
5194
- const embeddingsLattice = this.getEmbeddingsLattice(key);
5195
- return embeddingsLattice.client;
5196
- }
5197
- };
5198
- var embeddingsLatticeManager = EmbeddingsLatticeManager.getInstance();
5199
- var registerEmbeddingsLattice = (key, embeddings) => embeddingsLatticeManager.registerLattice(key, embeddings);
5200
- var getEmbeddingsLattice = (key) => embeddingsLatticeManager.getEmbeddingsLattice(key);
5201
- var getEmbeddingsClient = (key) => embeddingsLatticeManager.getEmbeddingsClient(key);
5202
-
5203
- // src/vectorstore_lattice/VectorStoreLatticeManager.ts
5204
- var VectorStoreLatticeManager = class _VectorStoreLatticeManager extends BaseLatticeManager {
5205
- /**
5206
- * Get VectorStoreLatticeManager singleton instance
5207
- */
5208
- static getInstance() {
5209
- if (!_VectorStoreLatticeManager._instance) {
5210
- _VectorStoreLatticeManager._instance = new _VectorStoreLatticeManager();
6432
+ getSkillConfig(key) {
6433
+ const skillLattice = this.getSkillLattice(key);
6434
+ if (!skillLattice) {
6435
+ throw new Error(`SkillLattice ${key} not found`);
5211
6436
  }
5212
- return _VectorStoreLatticeManager._instance;
5213
- }
5214
- /**
5215
- * Get Lattice type prefix
5216
- */
5217
- getLatticeType() {
5218
- return "vectorstores";
6437
+ return skillLattice.config;
5219
6438
  }
5220
6439
  /**
5221
- * Register vector store Lattice
5222
- * @param key Lattice key name
5223
- * @param vectorStore VectorStore instance
5224
- */
5225
- registerLattice(key, vectorStore) {
5226
- const vectorStoreLattice = {
5227
- key,
5228
- client: vectorStore
5229
- };
5230
- this.register(key, vectorStoreLattice);
5231
- }
5232
- /**
5233
- * Get VectorStoreLattice
6440
+ * Get skill client
6441
+ * Ensures client has store access if store is configured
5234
6442
  * @param key Lattice key name
5235
6443
  */
5236
- getVectorStoreLattice(key) {
5237
- const vectorStoreLattice = this.get(key);
5238
- if (!vectorStoreLattice) {
5239
- throw new Error(`VectorStoreLattice ${key} not found`);
6444
+ getSkillClient(key) {
6445
+ const skillLattice = this.getSkillLattice(key);
6446
+ if (!skillLattice) {
6447
+ throw new Error(`SkillLattice ${key} not found`);
5240
6448
  }
5241
- return vectorStoreLattice;
5242
- }
5243
- /**
5244
- * Get all Lattices
5245
- */
5246
- getAllLattices() {
5247
- return this.getAll();
6449
+ const client = skillLattice.client;
6450
+ if (!client) {
6451
+ return null;
6452
+ }
6453
+ const store = this.getStore();
6454
+ if (store && client) {
6455
+ this.injectStoreIntoClient(client, store);
6456
+ }
6457
+ return client;
5248
6458
  }
5249
6459
  /**
5250
- * Check if Lattice exists
5251
- * @param key Lattice key name
6460
+ * Get all skill configurations from store
6461
+ * Always reads from the configured store, not from memory
5252
6462
  */
5253
- hasLattice(key) {
5254
- return this.has(key);
6463
+ async getAllSkillConfigs() {
6464
+ const lattices = await this.getAllLattices();
6465
+ return lattices.map((lattice) => lattice.config);
5255
6466
  }
5256
6467
  /**
5257
- * Remove Lattice
5258
- * @param key Lattice key name
6468
+ * Search skills by metadata
6469
+ * @param metadataKey Metadata key to search for
6470
+ * @param metadataValue Metadata value to match
5259
6471
  */
5260
- removeLattice(key) {
5261
- return this.remove(key);
6472
+ async searchByMetadata(metadataKey, metadataValue) {
6473
+ const lattices = await this.getAllLattices();
6474
+ return lattices.filter((lattice) => {
6475
+ return lattice.config.metadata && lattice.config.metadata[metadataKey] === metadataValue;
6476
+ });
5262
6477
  }
5263
6478
  /**
5264
- * Clear all Lattices
6479
+ * Filter skills by compatibility
6480
+ * @param compatibility Compatibility string to filter by
5265
6481
  */
5266
- clearLattices() {
5267
- this.clear();
6482
+ async filterByCompatibility(compatibility) {
6483
+ const lattices = await this.getAllLattices();
6484
+ return lattices.filter((lattice) => {
6485
+ return lattice.config.compatibility === compatibility;
6486
+ });
5268
6487
  }
5269
6488
  /**
5270
- * Get Lattice count
6489
+ * Filter skills by license
6490
+ * @param license License string to filter by
5271
6491
  */
5272
- getLatticeCount() {
5273
- return this.count();
6492
+ async filterByLicense(license) {
6493
+ const lattices = await this.getAllLattices();
6494
+ return lattices.filter((lattice) => {
6495
+ return lattice.config.license === license;
6496
+ });
5274
6497
  }
5275
6498
  /**
5276
- * Get Lattice key list
5277
- */
5278
- getLatticeKeys() {
5279
- return this.keys();
6499
+ * Load skills from configured store
6500
+ * This method loads all skills from the store and registers them in memory
6501
+ */
6502
+ async loadFromStore() {
6503
+ const store = this.getStore();
6504
+ if (!store) {
6505
+ throw new Error("No store configured. Call configureStore() first.");
6506
+ }
6507
+ const skills = await store.getAllSkills();
6508
+ for (const skill of skills) {
6509
+ const skillLattice = {
6510
+ key: skill.id,
6511
+ config: {
6512
+ name: skill.name,
6513
+ description: skill.description,
6514
+ license: skill.license,
6515
+ compatibility: skill.compatibility,
6516
+ metadata: skill.metadata,
6517
+ content: skill.content,
6518
+ subSkills: skill.subSkills
6519
+ },
6520
+ client: null
6521
+ };
6522
+ this.register(skill.id, skillLattice);
6523
+ }
5280
6524
  }
5281
6525
  /**
5282
- * Get vector store client
5283
- * @param key Lattice key name
6526
+ * Update skill in store
6527
+ * @param key Skill key
6528
+ * @param updates Partial skill data to update
5284
6529
  */
5285
- getVectorStoreClient(key) {
5286
- const vectorStoreLattice = this.getVectorStoreLattice(key);
5287
- return vectorStoreLattice.client;
6530
+ async updateSkillInStore(key, updates) {
6531
+ const store = this.getStore();
6532
+ if (!store) {
6533
+ throw new Error("No store configured. Call configureStore() first.");
6534
+ }
6535
+ const skillLattice = this.getSkillLattice(key);
6536
+ if (!skillLattice) {
6537
+ throw new Error(`SkillLattice ${key} not found`);
6538
+ }
6539
+ const updatedConfig = {
6540
+ ...skillLattice.config,
6541
+ ...updates
6542
+ };
6543
+ skillLattice.config = updatedConfig;
6544
+ await store.updateSkill(key, {
6545
+ name: updatedConfig.name,
6546
+ description: updatedConfig.description,
6547
+ license: updatedConfig.license,
6548
+ compatibility: updatedConfig.compatibility,
6549
+ metadata: updatedConfig.metadata,
6550
+ content: updatedConfig.content,
6551
+ subSkills: updatedConfig.subSkills
6552
+ });
5288
6553
  }
5289
6554
  };
5290
- var vectorStoreLatticeManager = VectorStoreLatticeManager.getInstance();
5291
- var registerVectorStoreLattice = (key, vectorStore) => vectorStoreLatticeManager.registerLattice(key, vectorStore);
5292
- var getVectorStoreLattice = (key) => vectorStoreLatticeManager.getVectorStoreLattice(key);
5293
- var getVectorStoreClient = (key) => vectorStoreLatticeManager.getVectorStoreClient(key);
6555
+ var skillLatticeManager = SkillLatticeManager.getInstance();
5294
6556
 
5295
6557
  // src/index.ts
5296
6558
  var Protocols = __toESM(require("@axiom-lattice/protocols"));
@@ -5303,21 +6565,26 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
5303
6565
  AgentType,
5304
6566
  ChunkBuffer,
5305
6567
  ChunkBufferLatticeManager,
6568
+ ConsoleLoggerClient,
5306
6569
  DefaultScheduleClient,
5307
6570
  EmbeddingsLatticeManager,
6571
+ FileSystemSkillStore,
5308
6572
  GraphBuildOptions,
5309
6573
  InMemoryAssistantStore,
5310
6574
  InMemoryChunkBuffer,
5311
6575
  InMemoryThreadStore,
6576
+ LoggerLatticeManager,
5312
6577
  MemoryLatticeManager,
5313
6578
  MemoryQueueClient,
5314
6579
  MemoryScheduleStorage,
5315
6580
  MemoryType,
5316
6581
  ModelLatticeManager,
6582
+ PinoLoggerClient,
5317
6583
  PostgresDatabase,
5318
6584
  Protocols,
5319
6585
  QueueLatticeManager,
5320
6586
  ScheduleLatticeManager,
6587
+ SkillLatticeManager,
5321
6588
  SqlDatabaseManager,
5322
6589
  StoreLatticeManager,
5323
6590
  ThreadStatus,
@@ -5337,6 +6604,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
5337
6604
  getChunkBuffer,
5338
6605
  getEmbeddingsClient,
5339
6606
  getEmbeddingsLattice,
6607
+ getLoggerLattice,
5340
6608
  getModelLattice,
5341
6609
  getNextCronTime,
5342
6610
  getQueueLattice,
@@ -5349,6 +6617,8 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
5349
6617
  getVectorStoreLattice,
5350
6618
  hasChunkBuffer,
5351
6619
  isValidCronExpression,
6620
+ isValidSkillName,
6621
+ loggerLatticeManager,
5352
6622
  modelLatticeManager,
5353
6623
  parseCronExpression,
5354
6624
  queueLatticeManager,
@@ -5357,6 +6627,7 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
5357
6627
  registerCheckpointSaver,
5358
6628
  registerChunkBuffer,
5359
6629
  registerEmbeddingsLattice,
6630
+ registerLoggerLattice,
5360
6631
  registerModelLattice,
5361
6632
  registerQueueLattice,
5362
6633
  registerScheduleLattice,
@@ -5364,10 +6635,12 @@ var Protocols = __toESM(require("@axiom-lattice/protocols"));
5364
6635
  registerToolLattice,
5365
6636
  registerVectorStoreLattice,
5366
6637
  scheduleLatticeManager,
6638
+ skillLatticeManager,
5367
6639
  sqlDatabaseManager,
5368
6640
  storeLatticeManager,
5369
6641
  toolLatticeManager,
5370
6642
  validateAgentInput,
6643
+ validateSkillName,
5371
6644
  validateToolInput,
5372
6645
  vectorStoreLatticeManager
5373
6646
  });