@axiom-lattice/gateway 2.1.69 → 2.1.71

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.69",
3
+ "version": "2.1.71",
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.61",
43
- "@axiom-lattice/pg-stores": "1.0.51",
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()
@@ -425,9 +428,16 @@ export async function replyInboxTask(
425
428
  tenant_id: tenantId,
426
429
  });
427
430
 
428
- // 3. 提交 resume 请求并确认没有报错
429
- // addMessage 会触发 streaming 执行,但不会等待完整 workflow 完成
431
+ // 3. 提交 resume 请求并强制启动执行
432
+ // 注意:interrupted 状态下 processing message 会阻止自动启动,需要先重置
430
433
  try {
434
+ // 先重置被中断的 processing message,使其可以被重新处理
435
+ const queueStore = (agent as any).getQueueStore?.() || (agent as any).queueStore;
436
+ if (queueStore?.resetProcessingToPending) {
437
+ await queueStore.resetProcessingToPending(run.threadId);
438
+ }
439
+
440
+ // 添加 resume 消息到队列
431
441
  await agent.addMessage({
432
442
  input: { message: "Clarification answers submitted" },
433
443
  command: {
@@ -438,8 +448,10 @@ export async function replyInboxTask(
438
448
  },
439
449
  },
440
450
  });
451
+
452
+ // 强制启动 queue processor
453
+ await agent.startQueueProcessorIfNeeded();
441
454
  } catch (error) {
442
- // resume 提交失败(如 thread 不在 interrupted 状态)
443
455
  return reply.status(400).send({
444
456
  success: false,
445
457
  message: "Failed to resume workflow",