@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/dist/index.mjs CHANGED
@@ -1812,6 +1812,16 @@ async function getAllWorkflowRuns(request, reply) {
1812
1812
  if (!store) {
1813
1813
  return reply.status(404).send({ success: false, message: "No workflow tracking store configured" });
1814
1814
  }
1815
+ const nameMap = {};
1816
+ try {
1817
+ const asStoreLattice = getStoreLattice4("default", "assistant");
1818
+ const assistantStore = asStoreLattice.store;
1819
+ const assistants = await assistantStore.getAllAssistants(tenantId);
1820
+ for (const a of assistants) {
1821
+ nameMap[a.id] = a.name;
1822
+ }
1823
+ } catch {
1824
+ }
1815
1825
  let runs;
1816
1826
  if (assistantId) {
1817
1827
  runs = await store.getWorkflowRunsByAssistantId(tenantId, assistantId);
@@ -1821,10 +1831,22 @@ async function getAllWorkflowRuns(request, reply) {
1821
1831
  if (status) {
1822
1832
  runs = runs.filter((r) => r.status === status);
1823
1833
  }
1834
+ const enrichedRuns = await Promise.all(
1835
+ runs.map(async (run) => {
1836
+ try {
1837
+ const steps = await store.getRunSteps(run.id);
1838
+ const totalSteps = steps.length;
1839
+ const completedSteps = steps.filter((s) => s.status === "completed").length;
1840
+ return { ...run, totalSteps, completedSteps, assistantName: nameMap[run.assistantId] || run.assistantId };
1841
+ } catch {
1842
+ return { ...run, totalSteps: 0, completedSteps: 0, assistantName: nameMap[run.assistantId] || run.assistantId };
1843
+ }
1844
+ })
1845
+ );
1824
1846
  return {
1825
1847
  success: true,
1826
1848
  message: "Successfully retrieved workflow runs",
1827
- data: { records: runs, total: runs.length }
1849
+ data: { records: enrichedRuns, total: enrichedRuns.length }
1828
1850
  };
1829
1851
  } catch (error) {
1830
1852
  request.log.error(error, "Failed to get workflow runs");
@@ -1849,17 +1871,40 @@ async function getInboxItems(request, reply) {
1849
1871
  } catch {
1850
1872
  }
1851
1873
  const runs = await store.getWorkflowRunsByTenantId(tenantId);
1852
- const runningRuns = runs.filter((r) => r.status === "running");
1853
- if (runningRuns.length === 0) {
1854
- return { success: true, message: "No running workflows", data: { records: [] } };
1874
+ const pendingRuns = runs.filter((r) => r.status === "interrupted");
1875
+ if (pendingRuns.length === 0) {
1876
+ return { success: true, message: "No pending workflows", data: { records: [] } };
1855
1877
  }
1856
- const checkPromises = runningRuns.map(async (r) => {
1878
+ const checkPromises = pendingRuns.map(async (r) => {
1857
1879
  try {
1858
- const agent = agentInstanceManager4.getAgent({
1859
- assistant_id: r.assistantId,
1860
- thread_id: r.threadId,
1861
- tenant_id: r.tenantId
1862
- });
1880
+ const [steps, agent] = await Promise.all([
1881
+ store.getRunSteps(r.id).catch(() => []),
1882
+ (async () => {
1883
+ try {
1884
+ return agentInstanceManager4.getAgent({
1885
+ assistant_id: r.assistantId,
1886
+ thread_id: r.threadId,
1887
+ tenant_id: r.tenantId
1888
+ });
1889
+ } catch {
1890
+ return null;
1891
+ }
1892
+ })()
1893
+ ]);
1894
+ if (!agent) {
1895
+ return [{
1896
+ runId: r.id,
1897
+ assistantId: r.assistantId,
1898
+ assistantName: nameMap[r.assistantId] || r.assistantId,
1899
+ threadId: r.threadId,
1900
+ tenantId: r.tenantId,
1901
+ status: r.status,
1902
+ startedAt: r.startedAt,
1903
+ totalEdges: r.totalEdges,
1904
+ completedEdges: r.completedEdges,
1905
+ steps
1906
+ }];
1907
+ }
1863
1908
  const runStatus = await agent.getRunStatus();
1864
1909
  if (runStatus !== "interrupted") return [];
1865
1910
  const state = await agent.getCurrentState();
@@ -1872,9 +1917,11 @@ async function getInboxItems(request, reply) {
1872
1917
  tenantId: r.tenantId,
1873
1918
  interruptId: i.id,
1874
1919
  interruptValue: i.value,
1920
+ status: r.status,
1875
1921
  startedAt: r.startedAt,
1876
1922
  totalEdges: r.totalEdges,
1877
- completedEdges: r.completedEdges
1923
+ completedEdges: r.completedEdges,
1924
+ steps
1878
1925
  }));
1879
1926
  } catch (err) {
1880
1927
  request.log.warn({ runId: r.id, error: err.message }, "Agent check skipped");