@axiom-lattice/gateway 2.1.68 → 2.1.70

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/gateway",
3
- "version": "2.1.68",
3
+ "version": "2.1.70",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -39,10 +39,10 @@
39
39
  "pg": "^8.11.0",
40
40
  "redis": "^5.0.1",
41
41
  "uuid": "^9.0.1",
42
- "@axiom-lattice/core": "2.1.60",
43
- "@axiom-lattice/pg-stores": "1.0.50",
44
- "@axiom-lattice/protocols": "2.1.31",
45
- "@axiom-lattice/queue-redis": "1.0.30"
42
+ "@axiom-lattice/core": "2.1.62",
43
+ "@axiom-lattice/pg-stores": "1.0.52",
44
+ "@axiom-lattice/protocols": "2.1.32",
45
+ "@axiom-lattice/queue-redis": "1.0.31"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/jest": "^29.5.14",
@@ -186,40 +186,43 @@ export async function getInboxItems(
186
186
  return { success: true, message: "No running workflows", data: { records: [] } };
187
187
  }
188
188
 
189
- const inboxItems: any[] = [];
190
- for (const r of runningRuns) {
189
+ // Parallelize agent checks across running workflows
190
+ const checkPromises = runningRuns.map(async (r) => {
191
191
  try {
192
192
  const agent = agentInstanceManager.getAgent({
193
193
  assistant_id: r.assistantId,
194
194
  thread_id: r.threadId,
195
195
  tenant_id: r.tenantId,
196
196
  });
197
- const runStatus = await agent.getRunStatus();
198
197
 
199
- if (runStatus !== "interrupted") continue;
198
+ const runStatus = await agent.getRunStatus();
199
+ if (runStatus !== "interrupted") return [];
200
200
 
201
201
  const state = await agent.getCurrentState();
202
+
202
203
  const interrupts = state.tasks
203
204
  ?.flatMap((t: any) => t.interrupts || []) || [];
204
205
 
205
- for (const i of interrupts) {
206
- inboxItems.push({
207
- runId: r.id,
208
- assistantId: r.assistantId,
209
- assistantName: nameMap[r.assistantId] || r.assistantId,
210
- threadId: r.threadId,
211
- tenantId: r.tenantId,
212
- interruptId: i.id,
213
- interruptValue: i.value,
214
- startedAt: r.startedAt,
215
- totalEdges: r.totalEdges,
216
- completedEdges: r.completedEdges,
217
- });
218
- }
219
- } catch {
220
- // agent unavailable, skip
206
+ return interrupts.map((i: any) => ({
207
+ runId: r.id,
208
+ assistantId: r.assistantId,
209
+ assistantName: nameMap[r.assistantId] || r.assistantId,
210
+ threadId: r.threadId,
211
+ tenantId: r.tenantId,
212
+ interruptId: i.id,
213
+ interruptValue: i.value,
214
+ startedAt: r.startedAt,
215
+ totalEdges: r.totalEdges,
216
+ completedEdges: r.completedEdges,
217
+ }));
218
+ } catch (err) {
219
+ request.log.warn({ runId: r.id, error: (err as Error).message }, "Agent check skipped");
220
+ return [];
221
221
  }
222
- }
222
+ });
223
+
224
+ const results = await Promise.all(checkPromises);
225
+ const inboxItems = results.flat();
223
226
 
224
227
  inboxItems.sort((a, b) =>
225
228
  new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()