@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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/gateway@2.1.20 build /home/runner/work/agentic/agentic/packages/gateway
2
+ > @axiom-lattice/gateway@2.1.21 build /home/runner/work/agentic/agentic/packages/gateway
3
3
  > tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,13 +9,13 @@
9
9
  CLI Cleaning output folder
10
10
  CJS Build start
11
11
  ESM Build start
12
- ESM dist/index.mjs 59.42 KB
13
- ESM dist/index.mjs.map 129.40 KB
14
- ESM ⚡️ Build success in 154ms
15
- CJS dist/index.js 61.85 KB
16
- CJS dist/index.js.map 129.46 KB
17
- CJS ⚡️ Build success in 157ms
12
+ CJS dist/index.js 70.95 KB
13
+ CJS dist/index.js.map 160.39 KB
14
+ CJS ⚡️ Build success in 170ms
15
+ ESM dist/index.mjs 68.37 KB
16
+ ESM dist/index.mjs.map 160.33 KB
17
+ ESM ⚡️ Build success in 170ms
18
18
  DTS Build start
19
- DTS ⚡️ Build success in 7579ms
19
+ DTS ⚡️ Build success in 7886ms
20
20
  DTS dist/index.d.ts 3.72 KB
21
21
  DTS dist/index.d.mts 3.72 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @axiom-lattice/gateway
2
2
 
3
+ ## 2.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 773c03f: add skills
8
+ - Updated dependencies [773c03f]
9
+ - @axiom-lattice/protocols@2.1.10
10
+ - @axiom-lattice/core@2.1.16
11
+ - @axiom-lattice/queue-redis@1.0.9
12
+
3
13
  ## 2.1.20
4
14
 
5
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1339,6 +1339,311 @@ async function getHealth(request, reply) {
1339
1339
  }
1340
1340
  }
1341
1341
 
1342
+ // src/controllers/skills.ts
1343
+ var import_core9 = require("@axiom-lattice/core");
1344
+ var import_core10 = require("@axiom-lattice/core");
1345
+ function serializeSkill(skill) {
1346
+ const serialized = {
1347
+ id: skill.id,
1348
+ name: skill.name,
1349
+ description: skill.description,
1350
+ license: skill.license,
1351
+ compatibility: skill.compatibility,
1352
+ metadata: skill.metadata || {},
1353
+ content: skill.content,
1354
+ subSkills: skill.subSkills,
1355
+ createdAt: skill.createdAt instanceof Date ? skill.createdAt.toISOString() : skill.createdAt ? new Date(skill.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
1356
+ updatedAt: skill.updatedAt instanceof Date ? skill.updatedAt.toISOString() : skill.updatedAt ? new Date(skill.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
1357
+ };
1358
+ Object.keys(serialized).forEach((key) => {
1359
+ if (serialized[key] === void 0) {
1360
+ delete serialized[key];
1361
+ }
1362
+ });
1363
+ return serialized;
1364
+ }
1365
+ async function getSkillList(request, reply) {
1366
+ try {
1367
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1368
+ const skillStore = storeLattice.store;
1369
+ const skills = await skillStore.getAllSkills();
1370
+ const serializedSkills = skills.map(serializeSkill);
1371
+ return {
1372
+ success: true,
1373
+ message: "Successfully retrieved skill list",
1374
+ data: {
1375
+ records: serializedSkills,
1376
+ total: serializedSkills.length
1377
+ }
1378
+ };
1379
+ } catch (error) {
1380
+ return reply.status(500).send({
1381
+ success: false,
1382
+ message: `Failed to retrieve skills: ${error.message}`,
1383
+ data: {
1384
+ records: [],
1385
+ total: 0
1386
+ }
1387
+ });
1388
+ }
1389
+ }
1390
+ async function getSkill(request, reply) {
1391
+ try {
1392
+ const { id } = request.params;
1393
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1394
+ const skillStore = storeLattice.store;
1395
+ const skill = await skillStore.getSkillById(id);
1396
+ if (!skill) {
1397
+ return reply.status(404).send({
1398
+ success: false,
1399
+ message: "Skill not found"
1400
+ });
1401
+ }
1402
+ return {
1403
+ success: true,
1404
+ message: "Successfully retrieved skill",
1405
+ data: serializeSkill(skill)
1406
+ };
1407
+ } catch (error) {
1408
+ return reply.status(500).send({
1409
+ success: false,
1410
+ message: `Failed to retrieve skill: ${error.message}`
1411
+ });
1412
+ }
1413
+ }
1414
+ async function createSkill(request, reply) {
1415
+ try {
1416
+ const data = request.body;
1417
+ if (!data.name) {
1418
+ return reply.status(400).send({
1419
+ success: false,
1420
+ message: "name is required"
1421
+ });
1422
+ }
1423
+ if (!data.description) {
1424
+ return reply.status(400).send({
1425
+ success: false,
1426
+ message: "description is required"
1427
+ });
1428
+ }
1429
+ try {
1430
+ (0, import_core10.validateSkillName)(data.name);
1431
+ } catch (error) {
1432
+ return reply.status(400).send({
1433
+ success: false,
1434
+ message: error.message || "Invalid skill name format"
1435
+ });
1436
+ }
1437
+ const id = request.body.id || data.name;
1438
+ if (id !== data.name) {
1439
+ return reply.status(400).send({
1440
+ success: false,
1441
+ message: `id "${id}" must equal name "${data.name}" (name is used for path addressing)`
1442
+ });
1443
+ }
1444
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1445
+ const skillStore = storeLattice.store;
1446
+ const exists = await skillStore.hasSkill(id);
1447
+ if (exists) {
1448
+ return reply.status(409).send({
1449
+ success: false,
1450
+ message: `Skill with id "${id}" already exists`
1451
+ });
1452
+ }
1453
+ const newSkill = await skillStore.createSkill(id, data);
1454
+ return reply.status(201).send({
1455
+ success: true,
1456
+ message: "Successfully created skill",
1457
+ data: serializeSkill(newSkill)
1458
+ });
1459
+ } catch (error) {
1460
+ return reply.status(500).send({
1461
+ success: false,
1462
+ message: `Failed to create skill: ${error.message}`
1463
+ });
1464
+ }
1465
+ }
1466
+ async function updateSkill(request, reply) {
1467
+ try {
1468
+ const { id } = request.params;
1469
+ const updates = request.body;
1470
+ if (updates.name !== void 0) {
1471
+ try {
1472
+ (0, import_core10.validateSkillName)(updates.name);
1473
+ } catch (error) {
1474
+ return reply.status(400).send({
1475
+ success: false,
1476
+ message: error.message || "Invalid skill name format"
1477
+ });
1478
+ }
1479
+ }
1480
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1481
+ const skillStore = storeLattice.store;
1482
+ const exists = await skillStore.hasSkill(id);
1483
+ if (!exists) {
1484
+ return reply.status(404).send({
1485
+ success: false,
1486
+ message: "Skill not found"
1487
+ });
1488
+ }
1489
+ const updatedSkill = await skillStore.updateSkill(id, updates);
1490
+ if (!updatedSkill) {
1491
+ return reply.status(500).send({
1492
+ success: false,
1493
+ message: "Failed to update skill"
1494
+ });
1495
+ }
1496
+ return {
1497
+ success: true,
1498
+ message: "Successfully updated skill",
1499
+ data: serializeSkill(updatedSkill)
1500
+ };
1501
+ } catch (error) {
1502
+ return reply.status(500).send({
1503
+ success: false,
1504
+ message: `Failed to update skill: ${error.message}`
1505
+ });
1506
+ }
1507
+ }
1508
+ async function deleteSkill(request, reply) {
1509
+ try {
1510
+ const { id } = request.params;
1511
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1512
+ const skillStore = storeLattice.store;
1513
+ const exists = await skillStore.hasSkill(id);
1514
+ if (!exists) {
1515
+ return reply.status(404).send({
1516
+ success: false,
1517
+ message: "Skill not found"
1518
+ });
1519
+ }
1520
+ const deleted = await skillStore.deleteSkill(id);
1521
+ if (!deleted) {
1522
+ return reply.status(500).send({
1523
+ success: false,
1524
+ message: "Failed to delete skill"
1525
+ });
1526
+ }
1527
+ return {
1528
+ success: true,
1529
+ message: "Successfully deleted skill"
1530
+ };
1531
+ } catch (error) {
1532
+ return reply.status(500).send({
1533
+ success: false,
1534
+ message: `Failed to delete skill: ${error.message}`
1535
+ });
1536
+ }
1537
+ }
1538
+ async function searchSkillsByMetadata(request, reply) {
1539
+ try {
1540
+ const { key, value } = request.query;
1541
+ if (!key || !value) {
1542
+ return reply.status(400).send({
1543
+ success: false,
1544
+ message: "key and value query parameters are required",
1545
+ data: {
1546
+ records: [],
1547
+ total: 0
1548
+ }
1549
+ });
1550
+ }
1551
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1552
+ const skillStore = storeLattice.store;
1553
+ const skills = await skillStore.searchByMetadata(key, value);
1554
+ const serializedSkills = skills.map(serializeSkill);
1555
+ return {
1556
+ success: true,
1557
+ message: "Successfully searched skills",
1558
+ data: {
1559
+ records: serializedSkills,
1560
+ total: serializedSkills.length
1561
+ }
1562
+ };
1563
+ } catch (error) {
1564
+ return reply.status(500).send({
1565
+ success: false,
1566
+ message: `Failed to search skills: ${error.message}`,
1567
+ data: {
1568
+ records: [],
1569
+ total: 0
1570
+ }
1571
+ });
1572
+ }
1573
+ }
1574
+ async function filterSkillsByCompatibility(request, reply) {
1575
+ try {
1576
+ const { compatibility } = request.query;
1577
+ if (!compatibility) {
1578
+ return reply.status(400).send({
1579
+ success: false,
1580
+ message: "compatibility query parameter is required",
1581
+ data: {
1582
+ records: [],
1583
+ total: 0
1584
+ }
1585
+ });
1586
+ }
1587
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1588
+ const skillStore = storeLattice.store;
1589
+ const skills = await skillStore.filterByCompatibility(compatibility);
1590
+ const serializedSkills = skills.map(serializeSkill);
1591
+ return {
1592
+ success: true,
1593
+ message: "Successfully filtered skills",
1594
+ data: {
1595
+ records: serializedSkills,
1596
+ total: serializedSkills.length
1597
+ }
1598
+ };
1599
+ } catch (error) {
1600
+ return reply.status(500).send({
1601
+ success: false,
1602
+ message: `Failed to filter skills: ${error.message}`,
1603
+ data: {
1604
+ records: [],
1605
+ total: 0
1606
+ }
1607
+ });
1608
+ }
1609
+ }
1610
+ async function filterSkillsByLicense(request, reply) {
1611
+ try {
1612
+ const { license } = request.query;
1613
+ if (!license) {
1614
+ return reply.status(400).send({
1615
+ success: false,
1616
+ message: "license query parameter is required",
1617
+ data: {
1618
+ records: [],
1619
+ total: 0
1620
+ }
1621
+ });
1622
+ }
1623
+ const storeLattice = (0, import_core9.getStoreLattice)("default", "skill");
1624
+ const skillStore = storeLattice.store;
1625
+ const skills = await skillStore.filterByLicense(license);
1626
+ const serializedSkills = skills.map(serializeSkill);
1627
+ return {
1628
+ success: true,
1629
+ message: "Successfully filtered skills",
1630
+ data: {
1631
+ records: serializedSkills,
1632
+ total: serializedSkills.length
1633
+ }
1634
+ };
1635
+ } catch (error) {
1636
+ return reply.status(500).send({
1637
+ success: false,
1638
+ message: `Failed to filter skills: ${error.message}`,
1639
+ data: {
1640
+ records: [],
1641
+ total: 0
1642
+ }
1643
+ });
1644
+ }
1645
+ }
1646
+
1342
1647
  // src/schemas/index.ts
1343
1648
  var getAllMemoryItemsSchema = {
1344
1649
  description: "Get all memory items for an assistant thread",
@@ -1698,6 +2003,35 @@ var registerLatticeRoutes = (app2) => {
1698
2003
  app2.post("/api/schedules/:taskId/cancel", cancelScheduledTask);
1699
2004
  app2.post("/api/schedules/:taskId/pause", pauseScheduledTask);
1700
2005
  app2.post("/api/schedules/:taskId/resume", resumeScheduledTask);
2006
+ app2.get("/api/skills", getSkillList);
2007
+ app2.get(
2008
+ "/api/skills/:id",
2009
+ getSkill
2010
+ );
2011
+ app2.post(
2012
+ "/api/skills",
2013
+ createSkill
2014
+ );
2015
+ app2.put(
2016
+ "/api/skills/:id",
2017
+ updateSkill
2018
+ );
2019
+ app2.delete(
2020
+ "/api/skills/:id",
2021
+ deleteSkill
2022
+ );
2023
+ app2.get(
2024
+ "/api/skills/search/metadata",
2025
+ searchSkillsByMetadata
2026
+ );
2027
+ app2.get(
2028
+ "/api/skills/filter/compatibility",
2029
+ filterSkillsByCompatibility
2030
+ );
2031
+ app2.get(
2032
+ "/api/skills/filter/license",
2033
+ filterSkillsByLicense
2034
+ );
1701
2035
  };
1702
2036
 
1703
2037
  // src/swagger.ts
@@ -1763,7 +2097,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
1763
2097
  };
1764
2098
 
1765
2099
  // src/services/agent_task_consumer.ts
1766
- var import_core9 = require("@axiom-lattice/core");
2100
+ var import_core11 = require("@axiom-lattice/core");
1767
2101
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
1768
2102
  const {
1769
2103
  assistant_id,
@@ -1827,7 +2161,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1827
2161
  }
1828
2162
  if (callback_event) {
1829
2163
  const state = await agent_state({ assistant_id, thread_id });
1830
- import_core9.eventBus.publish(callback_event, {
2164
+ import_core11.eventBus.publish(callback_event, {
1831
2165
  success: true,
1832
2166
  state,
1833
2167
  config: { assistant_id, thread_id, tenant_id }
@@ -1841,7 +2175,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1841
2175
  await response.text();
1842
2176
  if (callback_event) {
1843
2177
  const state = await agent_state({ assistant_id, thread_id });
1844
- import_core9.eventBus.publish(callback_event, {
2178
+ import_core11.eventBus.publish(callback_event, {
1845
2179
  success: true,
1846
2180
  state,
1847
2181
  config: { assistant_id, thread_id, tenant_id }
@@ -1868,7 +2202,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1868
2202
  return handleAgentTask(taskRequest, nextRetryCount);
1869
2203
  }
1870
2204
  if (callback_event) {
1871
- import_core9.eventBus.publish(callback_event, {
2205
+ import_core11.eventBus.publish(callback_event, {
1872
2206
  success: false,
1873
2207
  error: error instanceof Error ? error.message : String(error),
1874
2208
  config: { assistant_id, thread_id, tenant_id }
@@ -1906,7 +2240,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
1906
2240
  * 初始化事件监听和队列轮询
1907
2241
  */
1908
2242
  initialize() {
1909
- import_core9.eventBus.subscribe(import_core9.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
2243
+ import_core11.eventBus.subscribe(import_core11.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
1910
2244
  this.startPollingQueue();
1911
2245
  console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
1912
2246
  }
@@ -2025,7 +2359,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
2025
2359
  handleAgentTask(taskRequest).catch((error) => {
2026
2360
  console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
2027
2361
  if (taskRequest.callback_event) {
2028
- import_core9.eventBus.publish(taskRequest.callback_event, {
2362
+ import_core11.eventBus.publish(taskRequest.callback_event, {
2029
2363
  success: false,
2030
2364
  error: error instanceof Error ? error.message : String(error),
2031
2365
  config: {
@@ -2045,7 +2379,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
2045
2379
  var AgentTaskConsumer = _AgentTaskConsumer;
2046
2380
 
2047
2381
  // src/index.ts
2048
- var import_core10 = require("@axiom-lattice/core");
2382
+ var import_core12 = require("@axiom-lattice/core");
2049
2383
  var import_protocols2 = require("@axiom-lattice/protocols");
2050
2384
  process.on("unhandledRejection", (reason, promise) => {
2051
2385
  console.error("\u672A\u5904\u7406\u7684Promise\u62D2\u7EDD:", reason);
@@ -2060,11 +2394,11 @@ var DEFAULT_LOGGER_CONFIG = {
2060
2394
  var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
2061
2395
  var logger = loggerLattice.client;
2062
2396
  function initializeLogger(config) {
2063
- if (import_core10.loggerLatticeManager.hasLattice("default")) {
2064
- import_core10.loggerLatticeManager.removeLattice("default");
2397
+ if (import_core12.loggerLatticeManager.hasLattice("default")) {
2398
+ import_core12.loggerLatticeManager.removeLattice("default");
2065
2399
  }
2066
- (0, import_core10.registerLoggerLattice)("default", config);
2067
- return (0, import_core10.getLoggerLattice)("default");
2400
+ (0, import_core12.registerLoggerLattice)("default", config);
2401
+ return (0, import_core12.getLoggerLattice)("default");
2068
2402
  }
2069
2403
  var app = (0, import_fastify.default)({
2070
2404
  logger: false,