@axiom-lattice/gateway 2.1.20 → 2.1.21
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +10 -0
- package/dist/index.js +345 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +334 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/skills.ts +474 -0
- package/src/routes/index.ts +61 -1
- package/src/schemas/index.ts +453 -0
package/dist/index.mjs
CHANGED
|
@@ -1319,6 +1319,311 @@ async function getHealth(request, reply) {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
1321
|
|
|
1322
|
+
// src/controllers/skills.ts
|
|
1323
|
+
import { getStoreLattice as getStoreLattice3 } from "@axiom-lattice/core";
|
|
1324
|
+
import { validateSkillName } from "@axiom-lattice/core";
|
|
1325
|
+
function serializeSkill(skill) {
|
|
1326
|
+
const serialized = {
|
|
1327
|
+
id: skill.id,
|
|
1328
|
+
name: skill.name,
|
|
1329
|
+
description: skill.description,
|
|
1330
|
+
license: skill.license,
|
|
1331
|
+
compatibility: skill.compatibility,
|
|
1332
|
+
metadata: skill.metadata || {},
|
|
1333
|
+
content: skill.content,
|
|
1334
|
+
subSkills: skill.subSkills,
|
|
1335
|
+
createdAt: skill.createdAt instanceof Date ? skill.createdAt.toISOString() : skill.createdAt ? new Date(skill.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1336
|
+
updatedAt: skill.updatedAt instanceof Date ? skill.updatedAt.toISOString() : skill.updatedAt ? new Date(skill.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
1337
|
+
};
|
|
1338
|
+
Object.keys(serialized).forEach((key) => {
|
|
1339
|
+
if (serialized[key] === void 0) {
|
|
1340
|
+
delete serialized[key];
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
return serialized;
|
|
1344
|
+
}
|
|
1345
|
+
async function getSkillList(request, reply) {
|
|
1346
|
+
try {
|
|
1347
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1348
|
+
const skillStore = storeLattice.store;
|
|
1349
|
+
const skills = await skillStore.getAllSkills();
|
|
1350
|
+
const serializedSkills = skills.map(serializeSkill);
|
|
1351
|
+
return {
|
|
1352
|
+
success: true,
|
|
1353
|
+
message: "Successfully retrieved skill list",
|
|
1354
|
+
data: {
|
|
1355
|
+
records: serializedSkills,
|
|
1356
|
+
total: serializedSkills.length
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
} catch (error) {
|
|
1360
|
+
return reply.status(500).send({
|
|
1361
|
+
success: false,
|
|
1362
|
+
message: `Failed to retrieve skills: ${error.message}`,
|
|
1363
|
+
data: {
|
|
1364
|
+
records: [],
|
|
1365
|
+
total: 0
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
async function getSkill(request, reply) {
|
|
1371
|
+
try {
|
|
1372
|
+
const { id } = request.params;
|
|
1373
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1374
|
+
const skillStore = storeLattice.store;
|
|
1375
|
+
const skill = await skillStore.getSkillById(id);
|
|
1376
|
+
if (!skill) {
|
|
1377
|
+
return reply.status(404).send({
|
|
1378
|
+
success: false,
|
|
1379
|
+
message: "Skill not found"
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
return {
|
|
1383
|
+
success: true,
|
|
1384
|
+
message: "Successfully retrieved skill",
|
|
1385
|
+
data: serializeSkill(skill)
|
|
1386
|
+
};
|
|
1387
|
+
} catch (error) {
|
|
1388
|
+
return reply.status(500).send({
|
|
1389
|
+
success: false,
|
|
1390
|
+
message: `Failed to retrieve skill: ${error.message}`
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
async function createSkill(request, reply) {
|
|
1395
|
+
try {
|
|
1396
|
+
const data = request.body;
|
|
1397
|
+
if (!data.name) {
|
|
1398
|
+
return reply.status(400).send({
|
|
1399
|
+
success: false,
|
|
1400
|
+
message: "name is required"
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
if (!data.description) {
|
|
1404
|
+
return reply.status(400).send({
|
|
1405
|
+
success: false,
|
|
1406
|
+
message: "description is required"
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
try {
|
|
1410
|
+
validateSkillName(data.name);
|
|
1411
|
+
} catch (error) {
|
|
1412
|
+
return reply.status(400).send({
|
|
1413
|
+
success: false,
|
|
1414
|
+
message: error.message || "Invalid skill name format"
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
const id = request.body.id || data.name;
|
|
1418
|
+
if (id !== data.name) {
|
|
1419
|
+
return reply.status(400).send({
|
|
1420
|
+
success: false,
|
|
1421
|
+
message: `id "${id}" must equal name "${data.name}" (name is used for path addressing)`
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1425
|
+
const skillStore = storeLattice.store;
|
|
1426
|
+
const exists = await skillStore.hasSkill(id);
|
|
1427
|
+
if (exists) {
|
|
1428
|
+
return reply.status(409).send({
|
|
1429
|
+
success: false,
|
|
1430
|
+
message: `Skill with id "${id}" already exists`
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
const newSkill = await skillStore.createSkill(id, data);
|
|
1434
|
+
return reply.status(201).send({
|
|
1435
|
+
success: true,
|
|
1436
|
+
message: "Successfully created skill",
|
|
1437
|
+
data: serializeSkill(newSkill)
|
|
1438
|
+
});
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
return reply.status(500).send({
|
|
1441
|
+
success: false,
|
|
1442
|
+
message: `Failed to create skill: ${error.message}`
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
async function updateSkill(request, reply) {
|
|
1447
|
+
try {
|
|
1448
|
+
const { id } = request.params;
|
|
1449
|
+
const updates = request.body;
|
|
1450
|
+
if (updates.name !== void 0) {
|
|
1451
|
+
try {
|
|
1452
|
+
validateSkillName(updates.name);
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
return reply.status(400).send({
|
|
1455
|
+
success: false,
|
|
1456
|
+
message: error.message || "Invalid skill name format"
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1461
|
+
const skillStore = storeLattice.store;
|
|
1462
|
+
const exists = await skillStore.hasSkill(id);
|
|
1463
|
+
if (!exists) {
|
|
1464
|
+
return reply.status(404).send({
|
|
1465
|
+
success: false,
|
|
1466
|
+
message: "Skill not found"
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
const updatedSkill = await skillStore.updateSkill(id, updates);
|
|
1470
|
+
if (!updatedSkill) {
|
|
1471
|
+
return reply.status(500).send({
|
|
1472
|
+
success: false,
|
|
1473
|
+
message: "Failed to update skill"
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
return {
|
|
1477
|
+
success: true,
|
|
1478
|
+
message: "Successfully updated skill",
|
|
1479
|
+
data: serializeSkill(updatedSkill)
|
|
1480
|
+
};
|
|
1481
|
+
} catch (error) {
|
|
1482
|
+
return reply.status(500).send({
|
|
1483
|
+
success: false,
|
|
1484
|
+
message: `Failed to update skill: ${error.message}`
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
async function deleteSkill(request, reply) {
|
|
1489
|
+
try {
|
|
1490
|
+
const { id } = request.params;
|
|
1491
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1492
|
+
const skillStore = storeLattice.store;
|
|
1493
|
+
const exists = await skillStore.hasSkill(id);
|
|
1494
|
+
if (!exists) {
|
|
1495
|
+
return reply.status(404).send({
|
|
1496
|
+
success: false,
|
|
1497
|
+
message: "Skill not found"
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
const deleted = await skillStore.deleteSkill(id);
|
|
1501
|
+
if (!deleted) {
|
|
1502
|
+
return reply.status(500).send({
|
|
1503
|
+
success: false,
|
|
1504
|
+
message: "Failed to delete skill"
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
return {
|
|
1508
|
+
success: true,
|
|
1509
|
+
message: "Successfully deleted skill"
|
|
1510
|
+
};
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
return reply.status(500).send({
|
|
1513
|
+
success: false,
|
|
1514
|
+
message: `Failed to delete skill: ${error.message}`
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
async function searchSkillsByMetadata(request, reply) {
|
|
1519
|
+
try {
|
|
1520
|
+
const { key, value } = request.query;
|
|
1521
|
+
if (!key || !value) {
|
|
1522
|
+
return reply.status(400).send({
|
|
1523
|
+
success: false,
|
|
1524
|
+
message: "key and value query parameters are required",
|
|
1525
|
+
data: {
|
|
1526
|
+
records: [],
|
|
1527
|
+
total: 0
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1532
|
+
const skillStore = storeLattice.store;
|
|
1533
|
+
const skills = await skillStore.searchByMetadata(key, value);
|
|
1534
|
+
const serializedSkills = skills.map(serializeSkill);
|
|
1535
|
+
return {
|
|
1536
|
+
success: true,
|
|
1537
|
+
message: "Successfully searched skills",
|
|
1538
|
+
data: {
|
|
1539
|
+
records: serializedSkills,
|
|
1540
|
+
total: serializedSkills.length
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
return reply.status(500).send({
|
|
1545
|
+
success: false,
|
|
1546
|
+
message: `Failed to search skills: ${error.message}`,
|
|
1547
|
+
data: {
|
|
1548
|
+
records: [],
|
|
1549
|
+
total: 0
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
async function filterSkillsByCompatibility(request, reply) {
|
|
1555
|
+
try {
|
|
1556
|
+
const { compatibility } = request.query;
|
|
1557
|
+
if (!compatibility) {
|
|
1558
|
+
return reply.status(400).send({
|
|
1559
|
+
success: false,
|
|
1560
|
+
message: "compatibility query parameter is required",
|
|
1561
|
+
data: {
|
|
1562
|
+
records: [],
|
|
1563
|
+
total: 0
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1568
|
+
const skillStore = storeLattice.store;
|
|
1569
|
+
const skills = await skillStore.filterByCompatibility(compatibility);
|
|
1570
|
+
const serializedSkills = skills.map(serializeSkill);
|
|
1571
|
+
return {
|
|
1572
|
+
success: true,
|
|
1573
|
+
message: "Successfully filtered skills",
|
|
1574
|
+
data: {
|
|
1575
|
+
records: serializedSkills,
|
|
1576
|
+
total: serializedSkills.length
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
} catch (error) {
|
|
1580
|
+
return reply.status(500).send({
|
|
1581
|
+
success: false,
|
|
1582
|
+
message: `Failed to filter skills: ${error.message}`,
|
|
1583
|
+
data: {
|
|
1584
|
+
records: [],
|
|
1585
|
+
total: 0
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
async function filterSkillsByLicense(request, reply) {
|
|
1591
|
+
try {
|
|
1592
|
+
const { license } = request.query;
|
|
1593
|
+
if (!license) {
|
|
1594
|
+
return reply.status(400).send({
|
|
1595
|
+
success: false,
|
|
1596
|
+
message: "license query parameter is required",
|
|
1597
|
+
data: {
|
|
1598
|
+
records: [],
|
|
1599
|
+
total: 0
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
const storeLattice = getStoreLattice3("default", "skill");
|
|
1604
|
+
const skillStore = storeLattice.store;
|
|
1605
|
+
const skills = await skillStore.filterByLicense(license);
|
|
1606
|
+
const serializedSkills = skills.map(serializeSkill);
|
|
1607
|
+
return {
|
|
1608
|
+
success: true,
|
|
1609
|
+
message: "Successfully filtered skills",
|
|
1610
|
+
data: {
|
|
1611
|
+
records: serializedSkills,
|
|
1612
|
+
total: serializedSkills.length
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
} catch (error) {
|
|
1616
|
+
return reply.status(500).send({
|
|
1617
|
+
success: false,
|
|
1618
|
+
message: `Failed to filter skills: ${error.message}`,
|
|
1619
|
+
data: {
|
|
1620
|
+
records: [],
|
|
1621
|
+
total: 0
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1322
1627
|
// src/schemas/index.ts
|
|
1323
1628
|
var getAllMemoryItemsSchema = {
|
|
1324
1629
|
description: "Get all memory items for an assistant thread",
|
|
@@ -1678,6 +1983,35 @@ var registerLatticeRoutes = (app2) => {
|
|
|
1678
1983
|
app2.post("/api/schedules/:taskId/cancel", cancelScheduledTask);
|
|
1679
1984
|
app2.post("/api/schedules/:taskId/pause", pauseScheduledTask);
|
|
1680
1985
|
app2.post("/api/schedules/:taskId/resume", resumeScheduledTask);
|
|
1986
|
+
app2.get("/api/skills", getSkillList);
|
|
1987
|
+
app2.get(
|
|
1988
|
+
"/api/skills/:id",
|
|
1989
|
+
getSkill
|
|
1990
|
+
);
|
|
1991
|
+
app2.post(
|
|
1992
|
+
"/api/skills",
|
|
1993
|
+
createSkill
|
|
1994
|
+
);
|
|
1995
|
+
app2.put(
|
|
1996
|
+
"/api/skills/:id",
|
|
1997
|
+
updateSkill
|
|
1998
|
+
);
|
|
1999
|
+
app2.delete(
|
|
2000
|
+
"/api/skills/:id",
|
|
2001
|
+
deleteSkill
|
|
2002
|
+
);
|
|
2003
|
+
app2.get(
|
|
2004
|
+
"/api/skills/search/metadata",
|
|
2005
|
+
searchSkillsByMetadata
|
|
2006
|
+
);
|
|
2007
|
+
app2.get(
|
|
2008
|
+
"/api/skills/filter/compatibility",
|
|
2009
|
+
filterSkillsByCompatibility
|
|
2010
|
+
);
|
|
2011
|
+
app2.get(
|
|
2012
|
+
"/api/skills/filter/license",
|
|
2013
|
+
filterSkillsByLicense
|
|
2014
|
+
);
|
|
1681
2015
|
};
|
|
1682
2016
|
|
|
1683
2017
|
// src/swagger.ts
|