@axiom-lattice/gateway 2.1.90 → 2.1.92

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.90",
3
+ "version": "2.1.92",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -40,11 +40,11 @@
40
40
  "redis": "^5.0.1",
41
41
  "uuid": "^9.0.1",
42
42
  "zod": "3.25.76",
43
- "@axiom-lattice/agent-eval": "2.1.72",
44
- "@axiom-lattice/core": "2.1.78",
45
- "@axiom-lattice/pg-stores": "1.0.69",
46
- "@axiom-lattice/protocols": "2.1.40",
47
- "@axiom-lattice/queue-redis": "1.0.39"
43
+ "@axiom-lattice/agent-eval": "2.1.74",
44
+ "@axiom-lattice/core": "2.1.80",
45
+ "@axiom-lattice/pg-stores": "1.0.71",
46
+ "@axiom-lattice/protocols": "2.1.42",
47
+ "@axiom-lattice/queue-redis": "1.0.41"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/jest": "^29.5.14",
@@ -126,7 +126,7 @@ export async function getAllWorkflowDefinitions(
126
126
  export async function getAllWorkflowRuns(
127
127
  request: FastifyRequest<{ Querystring: { assistantId?: string; status?: string } }>,
128
128
  reply: FastifyReply
129
- ): Promise<ApiResponse<{ records: WorkflowRun[]; total: number }>> {
129
+ ): Promise<ApiResponse<{ records: any[]; total: number }>> {
130
130
  const tenantId = getTenantId(request);
131
131
  const { assistantId, status } = request.query;
132
132
 
@@ -136,6 +136,19 @@ export async function getAllWorkflowRuns(
136
136
  return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
137
137
  }
138
138
 
139
+ // Resolve assistant names
140
+ const nameMap: Record<string, string> = {};
141
+ try {
142
+ const asStoreLattice = getStoreLattice("default", "assistant");
143
+ const assistantStore = asStoreLattice.store;
144
+ const assistants = await assistantStore.getAllAssistants(tenantId);
145
+ for (const a of assistants) {
146
+ nameMap[a.id] = a.name;
147
+ }
148
+ } catch {
149
+ // names unavailable, will fall back to ID
150
+ }
151
+
139
152
  let runs: WorkflowRun[];
140
153
  if (assistantId) {
141
154
  runs = await store.getWorkflowRunsByAssistantId(tenantId, assistantId);
@@ -147,10 +160,24 @@ export async function getAllWorkflowRuns(
147
160
  runs = runs.filter(r => r.status === status);
148
161
  }
149
162
 
163
+ // Enrich runs with step counts (more accurate than edge-based counts for branching workflows)
164
+ const enrichedRuns = await Promise.all(
165
+ runs.map(async (run) => {
166
+ try {
167
+ const steps = await store.getRunSteps(run.id);
168
+ const totalSteps = steps.length;
169
+ const completedSteps = steps.filter(s => s.status === 'completed').length;
170
+ return { ...run, totalSteps, completedSteps, assistantName: nameMap[run.assistantId] || run.assistantId };
171
+ } catch {
172
+ return { ...run, totalSteps: 0, completedSteps: 0, assistantName: nameMap[run.assistantId] || run.assistantId };
173
+ }
174
+ })
175
+ );
176
+
150
177
  return {
151
178
  success: true,
152
179
  message: "Successfully retrieved workflow runs",
153
- data: { records: runs, total: runs.length },
180
+ data: { records: enrichedRuns, total: enrichedRuns.length },
154
181
  };
155
182
  } catch (error) {
156
183
  request.log.error(error, "Failed to get workflow runs");
@@ -185,25 +212,49 @@ export async function getInboxItems(
185
212
  }
186
213
 
187
214
  const runs = await store.getWorkflowRunsByTenantId(tenantId);
188
- const runningRuns = runs.filter(r => r.status === "running");
189
- if (runningRuns.length === 0) {
190
- return { success: true, message: "No running workflows", data: { records: [] } };
215
+ const pendingRuns = runs.filter(r => r.status === "interrupted");
216
+ if (pendingRuns.length === 0) {
217
+ return { success: true, message: "No pending workflows", data: { records: [] } };
191
218
  }
192
219
 
193
- // Parallelize agent checks across running workflows
194
- const checkPromises = runningRuns.map(async (r) => {
220
+ // Parallelize agent checks across interrupted workflows
221
+ const checkPromises = pendingRuns.map(async (r) => {
195
222
  try {
196
- const agent = agentInstanceManager.getAgent({
197
- assistant_id: r.assistantId,
198
- thread_id: r.threadId,
199
- tenant_id: r.tenantId,
200
- });
223
+ const [steps, agent] = await Promise.all([
224
+ store.getRunSteps(r.id).catch(() => []),
225
+ (async () => {
226
+ try {
227
+ return agentInstanceManager.getAgent({
228
+ assistant_id: r.assistantId,
229
+ thread_id: r.threadId,
230
+ tenant_id: r.tenantId,
231
+ });
232
+ } catch {
233
+ return null;
234
+ }
235
+ })(),
236
+ ]);
237
+
238
+ if (!agent) {
239
+ // Agent not available — still return raw item so UI knows a human step exists
240
+ return [{
241
+ runId: r.id,
242
+ assistantId: r.assistantId,
243
+ assistantName: nameMap[r.assistantId] || r.assistantId,
244
+ threadId: r.threadId,
245
+ tenantId: r.tenantId,
246
+ status: r.status,
247
+ startedAt: r.startedAt,
248
+ totalEdges: r.totalEdges,
249
+ completedEdges: r.completedEdges,
250
+ steps,
251
+ }];
252
+ }
201
253
 
202
254
  const runStatus = await agent.getRunStatus();
203
255
  if (runStatus !== "interrupted") return [];
204
256
 
205
257
  const state = await agent.getCurrentState();
206
-
207
258
  const interrupts = state.tasks
208
259
  ?.flatMap((t: any) => t.interrupts || []) || [];
209
260
 
@@ -215,9 +266,11 @@ export async function getInboxItems(
215
266
  tenantId: r.tenantId,
216
267
  interruptId: i.id,
217
268
  interruptValue: i.value,
269
+ status: r.status,
218
270
  startedAt: r.startedAt,
219
271
  totalEdges: r.totalEdges,
220
272
  completedEdges: r.completedEdges,
273
+ steps,
221
274
  }));
222
275
  } catch (err) {
223
276
  request.log.warn({ runId: r.id, error: (err as Error).message }, "Agent check skipped");