@axiom-lattice/gateway 2.1.17 → 2.1.19

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.17 build /home/runner/work/agentic/agentic/packages/gateway
2
+ > @axiom-lattice/gateway@2.1.19 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 55.49 KB
13
- ESM dist/index.mjs.map 119.35 KB
14
- ESM ⚡️ Build success in 105ms
15
- CJS dist/index.js 57.99 KB
16
- CJS dist/index.js.map 119.45 KB
17
- CJS ⚡️ Build success in 107ms
12
+ ESM dist/index.mjs 61.30 KB
13
+ ESM dist/index.mjs.map 132.19 KB
14
+ ESM ⚡️ Build success in 147ms
15
+ CJS dist/index.js 63.84 KB
16
+ CJS dist/index.js.map 132.29 KB
17
+ CJS ⚡️ Build success in 148ms
18
18
  DTS Build start
19
- DTS ⚡️ Build success in 7551ms
19
+ DTS ⚡️ Build success in 7807ms
20
20
  DTS dist/index.d.ts 3.32 KB
21
21
  DTS dist/index.d.mts 3.32 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @axiom-lattice/gateway
2
2
 
3
+ ## 2.1.19
4
+
5
+ ### Patch Changes
6
+
7
+ - d43ea0b: add schedule task
8
+ - Updated dependencies [d43ea0b]
9
+ - @axiom-lattice/protocols@2.1.8
10
+ - @axiom-lattice/core@2.1.14
11
+ - @axiom-lattice/queue-redis@1.0.7
12
+
13
+ ## 2.1.18
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [e26be9a]
18
+ - @axiom-lattice/protocols@2.1.7
19
+ - @axiom-lattice/core@2.1.13
20
+ - @axiom-lattice/queue-redis@1.0.6
21
+
3
22
  ## 2.1.17
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -62,13 +62,15 @@ async function agent_invoke({
62
62
  command,
63
63
  run_id
64
64
  }) {
65
- const runnable_agent = (0, import_core.getAgentClient)(assistant_id);
65
+ const agentLattice = (0, import_core.getAgentLattice)(assistant_id);
66
+ const runnable_agent = agentLattice?.client;
66
67
  const { message, ...rest } = input;
67
68
  const humanMessage = new import_messages.HumanMessage(message || "");
68
69
  const messages = [humanMessage];
69
70
  if (!runnable_agent) {
70
71
  throw new Error(`Agent ${assistant_id} not found`);
71
72
  }
73
+ const runConfig = agentLattice?.config?.runConfig || {};
72
74
  const result = await runnable_agent.invoke(
73
75
  command ? new import_langgraph.Command(command) : { ...rest, messages, "x-tenant-id": tenant_id },
74
76
  {
@@ -77,7 +79,9 @@ async function agent_invoke({
77
79
  run_id: run_id || (0, import_uuid.v4)(),
78
80
  "x-tenant-id": tenant_id,
79
81
  "x-request-id": run_id,
80
- "x-thread-id": thread_id
82
+ "x-thread-id": thread_id,
83
+ runConfig
84
+ // Inject runConfig for tools to access
81
85
  },
82
86
  recursionLimit: 200
83
87
  }
@@ -100,6 +104,7 @@ async function agent_stream({
100
104
  run_id
101
105
  }) {
102
106
  const runnable_agent = (0, import_core.getAgentClient)(assistant_id);
107
+ const agentLattice = (0, import_core.getAgentLattice)(assistant_id);
103
108
  const { message, ...rest } = input;
104
109
  let messages = [];
105
110
  if (!command) {
@@ -107,6 +112,7 @@ async function agent_stream({
107
112
  messages = [humanMessage];
108
113
  }
109
114
  const chunkBuffer = getOrCreateChunkBuffer();
115
+ const runConfig = agentLattice?.config?.runConfig || {};
110
116
  try {
111
117
  if (!runnable_agent) {
112
118
  throw new Error(`Agent ${assistant_id} not found`);
@@ -123,7 +129,9 @@ async function agent_stream({
123
129
  run_id: run_id || (0, import_uuid.v4)(),
124
130
  "x-tenant-id": tenant_id,
125
131
  "x-request-id": run_id,
126
- "x-thread-id": thread_id
132
+ "x-thread-id": thread_id,
133
+ runConfig
134
+ // Inject runConfig for tools to access
127
135
  },
128
136
  streamMode: ["updates", "messages"],
129
137
  subgraphs: false,
@@ -823,6 +831,201 @@ async function deleteThread(request, reply) {
823
831
  };
824
832
  }
825
833
 
834
+ // src/controllers/schedules.ts
835
+ var import_core6 = require("@axiom-lattice/core");
836
+ function getScheduleLattice() {
837
+ const keys = import_core6.scheduleLatticeManager.getLatticeKeys();
838
+ if (keys.length === 0) {
839
+ return null;
840
+ }
841
+ if (import_core6.scheduleLatticeManager.hasLattice("default")) {
842
+ return import_core6.scheduleLatticeManager.getScheduleLattice("default");
843
+ }
844
+ return import_core6.scheduleLatticeManager.getScheduleLattice(keys[0]);
845
+ }
846
+ async function getThreadSchedules(request, reply) {
847
+ const { assistantId, threadId } = request.params;
848
+ const { status, limit, offset } = request.query;
849
+ try {
850
+ const scheduleLattice = getScheduleLattice();
851
+ if (!scheduleLattice) {
852
+ return {
853
+ success: true,
854
+ message: "No schedule lattice configured",
855
+ data: {
856
+ records: [],
857
+ total: 0
858
+ }
859
+ };
860
+ }
861
+ const storage = scheduleLattice.client.getStorage();
862
+ if (!storage) {
863
+ return {
864
+ success: true,
865
+ message: "No schedule storage configured",
866
+ data: {
867
+ records: [],
868
+ total: 0
869
+ }
870
+ };
871
+ }
872
+ const filters = {
873
+ threadId,
874
+ assistantId
875
+ };
876
+ if (status) {
877
+ filters.status = status;
878
+ }
879
+ if (limit) {
880
+ filters.limit = parseInt(limit, 10);
881
+ }
882
+ if (offset) {
883
+ filters.offset = parseInt(offset, 10);
884
+ }
885
+ const tasks = await storage.getAllTasks(filters);
886
+ const total = await storage.countTasks({
887
+ threadId,
888
+ assistantId,
889
+ status
890
+ });
891
+ return {
892
+ success: true,
893
+ message: "Successfully retrieved scheduled tasks",
894
+ data: {
895
+ records: tasks,
896
+ total
897
+ }
898
+ };
899
+ } catch (error) {
900
+ request.log.error(error, "Failed to get thread schedules");
901
+ return reply.status(500).send({
902
+ success: false,
903
+ message: "Failed to retrieve scheduled tasks",
904
+ data: {
905
+ records: [],
906
+ total: 0
907
+ }
908
+ });
909
+ }
910
+ }
911
+ async function getScheduledTask(request, reply) {
912
+ const { taskId } = request.params;
913
+ try {
914
+ const scheduleLattice = getScheduleLattice();
915
+ if (!scheduleLattice) {
916
+ return reply.status(404).send({
917
+ success: false,
918
+ message: "No schedule lattice configured"
919
+ });
920
+ }
921
+ const task = await scheduleLattice.client.getTask(taskId);
922
+ if (!task) {
923
+ return reply.status(404).send({
924
+ success: false,
925
+ message: "Scheduled task not found"
926
+ });
927
+ }
928
+ return {
929
+ success: true,
930
+ message: "Successfully retrieved scheduled task",
931
+ data: task
932
+ };
933
+ } catch (error) {
934
+ request.log.error(error, "Failed to get scheduled task");
935
+ return reply.status(500).send({
936
+ success: false,
937
+ message: "Failed to retrieve scheduled task"
938
+ });
939
+ }
940
+ }
941
+ async function cancelScheduledTask(request, reply) {
942
+ const { taskId } = request.params;
943
+ try {
944
+ const scheduleLattice = getScheduleLattice();
945
+ if (!scheduleLattice) {
946
+ return reply.status(404).send({
947
+ success: false,
948
+ message: "No schedule lattice configured"
949
+ });
950
+ }
951
+ const result = await scheduleLattice.client.cancel(taskId);
952
+ if (!result) {
953
+ return reply.status(404).send({
954
+ success: false,
955
+ message: "Scheduled task not found or already cancelled"
956
+ });
957
+ }
958
+ return {
959
+ success: true,
960
+ message: "Successfully cancelled scheduled task"
961
+ };
962
+ } catch (error) {
963
+ request.log.error(error, "Failed to cancel scheduled task");
964
+ return reply.status(500).send({
965
+ success: false,
966
+ message: "Failed to cancel scheduled task"
967
+ });
968
+ }
969
+ }
970
+ async function pauseScheduledTask(request, reply) {
971
+ const { taskId } = request.params;
972
+ try {
973
+ const scheduleLattice = getScheduleLattice();
974
+ if (!scheduleLattice) {
975
+ return reply.status(404).send({
976
+ success: false,
977
+ message: "No schedule lattice configured"
978
+ });
979
+ }
980
+ const result = await scheduleLattice.client.pause(taskId);
981
+ if (!result) {
982
+ return reply.status(404).send({
983
+ success: false,
984
+ message: "Scheduled task not found or cannot be paused"
985
+ });
986
+ }
987
+ return {
988
+ success: true,
989
+ message: "Successfully paused scheduled task"
990
+ };
991
+ } catch (error) {
992
+ request.log.error(error, "Failed to pause scheduled task");
993
+ return reply.status(500).send({
994
+ success: false,
995
+ message: "Failed to pause scheduled task"
996
+ });
997
+ }
998
+ }
999
+ async function resumeScheduledTask(request, reply) {
1000
+ const { taskId } = request.params;
1001
+ try {
1002
+ const scheduleLattice = getScheduleLattice();
1003
+ if (!scheduleLattice) {
1004
+ return reply.status(404).send({
1005
+ success: false,
1006
+ message: "No schedule lattice configured"
1007
+ });
1008
+ }
1009
+ const result = await scheduleLattice.client.resume(taskId);
1010
+ if (!result) {
1011
+ return reply.status(404).send({
1012
+ success: false,
1013
+ message: "Scheduled task not found or cannot be resumed"
1014
+ });
1015
+ }
1016
+ return {
1017
+ success: true,
1018
+ message: "Successfully resumed scheduled task"
1019
+ };
1020
+ } catch (error) {
1021
+ request.log.error(error, "Failed to resume scheduled task");
1022
+ return reply.status(500).send({
1023
+ success: false,
1024
+ message: "Failed to resume scheduled task"
1025
+ });
1026
+ }
1027
+ }
1028
+
826
1029
  // src/config.ts
827
1030
  var ConfigService = class {
828
1031
  constructor() {
@@ -896,7 +1099,7 @@ var ConfigService = class {
896
1099
  var configService = new ConfigService();
897
1100
 
898
1101
  // src/services/queue_service.ts
899
- var import_core6 = require("@axiom-lattice/core");
1102
+ var import_core7 = require("@axiom-lattice/core");
900
1103
  var import_protocols = require("@axiom-lattice/protocols");
901
1104
  var import_queue_redis = require("@axiom-lattice/queue-redis");
902
1105
  var DEFAULT_QUEUE_KEY = "default";
@@ -915,8 +1118,8 @@ var setQueueServiceType = (type) => {
915
1118
  redisPassword: process.env.REDIS_PASSWORD
916
1119
  } : void 0
917
1120
  };
918
- if (import_core6.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
919
- import_core6.queueLatticeManager.removeLattice(DEFAULT_QUEUE_KEY);
1121
+ if (import_core7.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
1122
+ import_core7.queueLatticeManager.removeLattice(DEFAULT_QUEUE_KEY);
920
1123
  }
921
1124
  let client;
922
1125
  if (type === "redis") {
@@ -925,13 +1128,13 @@ var setQueueServiceType = (type) => {
925
1128
  redisPassword: process.env.REDIS_PASSWORD
926
1129
  });
927
1130
  }
928
- (0, import_core6.registerQueueLattice)(DEFAULT_QUEUE_KEY, config, client);
1131
+ (0, import_core7.registerQueueLattice)(DEFAULT_QUEUE_KEY, config, client);
929
1132
  };
930
1133
  var getQueueService = () => {
931
- if (!import_core6.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
1134
+ if (!import_core7.queueLatticeManager.hasLattice(DEFAULT_QUEUE_KEY)) {
932
1135
  setQueueServiceType(queueServiceType);
933
1136
  }
934
- return (0, import_core6.getQueueLattice)(DEFAULT_QUEUE_KEY);
1137
+ return (0, import_core7.getQueueLattice)(DEFAULT_QUEUE_KEY);
935
1138
  };
936
1139
  var popAgentTaskFromQueue = async () => {
937
1140
  const queue = getQueueService();
@@ -1012,10 +1215,10 @@ async function getConfig(request, reply) {
1012
1215
  }
1013
1216
 
1014
1217
  // src/controllers/models.ts
1015
- var import_core7 = require("@axiom-lattice/core");
1218
+ var import_core8 = require("@axiom-lattice/core");
1016
1219
  async function getModels(request, reply) {
1017
1220
  try {
1018
- const allLattices = import_core7.modelLatticeManager.getAllLattices();
1221
+ const allLattices = import_core8.modelLatticeManager.getAllLattices();
1019
1222
  const models = allLattices.map((lattice) => {
1020
1223
  const config = lattice.client.config || {};
1021
1224
  return {
@@ -1065,8 +1268,8 @@ async function updateModels(request, reply) {
1065
1268
  continue;
1066
1269
  }
1067
1270
  try {
1068
- if (import_core7.modelLatticeManager.hasLattice(modelConfig.key)) {
1069
- import_core7.modelLatticeManager.removeLattice(modelConfig.key);
1271
+ if (import_core8.modelLatticeManager.hasLattice(modelConfig.key)) {
1272
+ import_core8.modelLatticeManager.removeLattice(modelConfig.key);
1070
1273
  }
1071
1274
  const llmConfig = {
1072
1275
  provider: modelConfig.provider,
@@ -1079,7 +1282,7 @@ async function updateModels(request, reply) {
1079
1282
  timeout: modelConfig.timeout,
1080
1283
  maxRetries: modelConfig.maxRetries
1081
1284
  };
1082
- (0, import_core7.registerModelLattice)(modelConfig.key, llmConfig);
1285
+ (0, import_core8.registerModelLattice)(modelConfig.key, llmConfig);
1083
1286
  registeredModels.push(modelConfig.key);
1084
1287
  } catch (error) {
1085
1288
  errors.push(
@@ -1487,6 +1690,14 @@ var registerLatticeRoutes = (app2) => {
1487
1690
  { schema: getHealthSchema },
1488
1691
  getHealth
1489
1692
  );
1693
+ app2.get(
1694
+ "/api/assistants/:assistantId/threads/:threadId/schedules",
1695
+ getThreadSchedules
1696
+ );
1697
+ app2.get("/api/schedules/:taskId", getScheduledTask);
1698
+ app2.post("/api/schedules/:taskId/cancel", cancelScheduledTask);
1699
+ app2.post("/api/schedules/:taskId/pause", pauseScheduledTask);
1700
+ app2.post("/api/schedules/:taskId/resume", resumeScheduledTask);
1490
1701
  };
1491
1702
 
1492
1703
  // src/logger/Logger.ts
@@ -1690,7 +1901,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
1690
1901
  };
1691
1902
 
1692
1903
  // src/services/agent_task_consumer.ts
1693
- var import_core8 = require("@axiom-lattice/core");
1904
+ var import_core9 = require("@axiom-lattice/core");
1694
1905
  var handleAgentTask = async (taskRequest, retryCount = 0) => {
1695
1906
  const {
1696
1907
  assistant_id,
@@ -1754,7 +1965,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1754
1965
  }
1755
1966
  if (callback_event) {
1756
1967
  const state = await agent_state({ assistant_id, thread_id });
1757
- import_core8.eventBus.publish(callback_event, {
1968
+ import_core9.eventBus.publish(callback_event, {
1758
1969
  success: true,
1759
1970
  state,
1760
1971
  config: { assistant_id, thread_id, tenant_id }
@@ -1768,7 +1979,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1768
1979
  await response.text();
1769
1980
  if (callback_event) {
1770
1981
  const state = await agent_state({ assistant_id, thread_id });
1771
- import_core8.eventBus.publish(callback_event, {
1982
+ import_core9.eventBus.publish(callback_event, {
1772
1983
  success: true,
1773
1984
  state,
1774
1985
  config: { assistant_id, thread_id, tenant_id }
@@ -1795,7 +2006,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
1795
2006
  return handleAgentTask(taskRequest, nextRetryCount);
1796
2007
  }
1797
2008
  if (callback_event) {
1798
- import_core8.eventBus.publish(callback_event, {
2009
+ import_core9.eventBus.publish(callback_event, {
1799
2010
  success: false,
1800
2011
  error: error instanceof Error ? error.message : String(error),
1801
2012
  config: { assistant_id, thread_id, tenant_id }
@@ -1833,7 +2044,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
1833
2044
  * 初始化事件监听和队列轮询
1834
2045
  */
1835
2046
  initialize() {
1836
- import_core8.eventBus.subscribe(import_core8.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
2047
+ import_core9.eventBus.subscribe(import_core9.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
1837
2048
  this.startPollingQueue();
1838
2049
  console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
1839
2050
  }
@@ -1952,7 +2163,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
1952
2163
  handleAgentTask(taskRequest).catch((error) => {
1953
2164
  console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
1954
2165
  if (taskRequest.callback_event) {
1955
- import_core8.eventBus.publish(taskRequest.callback_event, {
2166
+ import_core9.eventBus.publish(taskRequest.callback_event, {
1956
2167
  success: false,
1957
2168
  error: error instanceof Error ? error.message : String(error),
1958
2169
  config: {