@lumerahq/ui 0.7.6 → 0.8.0-dev.0
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/RecordSheet-CI_6QC-a.js +38151 -0
- package/dist/{api-BrhR_Jjl.js → api-Da1IIWDG.js} +1 -1
- package/dist/{automations-XN4WPV_g.js → automations-BEBG7FqJ.js} +160 -26
- package/dist/components/agent-chat/AgentChat.d.ts +3 -0
- package/dist/components/agent-chat/AgentChat.d.ts.map +1 -0
- package/dist/components/agent-chat/index.d.ts +5 -0
- package/dist/components/agent-chat/index.d.ts.map +1 -0
- package/dist/components/agent-chat/lumera-agent-transport.d.ts +20 -0
- package/dist/components/agent-chat/lumera-agent-transport.d.ts.map +1 -0
- package/dist/components/agent-chat/types.d.ts +376 -0
- package/dist/components/agent-chat/types.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +8 -6
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/{formatters-Baj7FkeG.js → formatters-D4T821Dv.js} +2 -1
- package/dist/highlighted-body-OFNGDK62-38mi922Z.js +19 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +6 -5
- package/dist/hooks/use-agent-chat.d.ts +47 -0
- package/dist/hooks/use-agent-chat.d.ts.map +1 -0
- package/dist/index.js +51 -45
- package/dist/lib/bridge.d.ts +71 -5
- package/dist/lib/bridge.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +29 -26
- package/dist/logo.svg +15 -0
- package/dist/mermaid-GHXKKRXX-CdpO_nzu.js +4 -0
- package/dist/ui.css +254 -2
- package/dist/use-automation-run-rhYZZhj7.js +746 -0
- package/dist/{use-sql-table-B7C06_An.js → use-sql-table-1EiZ9qCa.js} +2 -2
- package/package.json +2 -1
- package/dist/RecordSheet-BvHHP8P4.js +0 -12241
- package/dist/logo.png +0 -0
- package/dist/lumera-logo.png +0 -0
- package/dist/use-automation-run-Cecvf4Aq.js +0 -134
package/dist/logo.png
DELETED
|
Binary file
|
package/dist/lumera-logo.png
DELETED
|
Binary file
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { useState, useRef, useEffect, useCallback } from "react";
|
|
3
|
-
import { k as ensureAutomationRun, h as createAutomationRun, d as cancelAutomationRun, c as automationStatuses, n as getAutomationRun } from "./automations-XN4WPV_g.js";
|
|
4
|
-
function useAutomationRun(options) {
|
|
5
|
-
const {
|
|
6
|
-
agentId,
|
|
7
|
-
inputs,
|
|
8
|
-
externalId,
|
|
9
|
-
autoStart = true,
|
|
10
|
-
pollIntervalMs = 2e3,
|
|
11
|
-
dedupeWithExternalId = true,
|
|
12
|
-
onComplete,
|
|
13
|
-
onCreated,
|
|
14
|
-
onUpdate
|
|
15
|
-
} = options;
|
|
16
|
-
const queryClient = useQueryClient();
|
|
17
|
-
const [currentRunId, setCurrentRunId] = useState(null);
|
|
18
|
-
const [errorV, setErrorV] = useState(null);
|
|
19
|
-
const startMutation = useMutation({
|
|
20
|
-
mutationFn: async () => {
|
|
21
|
-
setErrorV(null);
|
|
22
|
-
if (!agentId) throw new Error("agentId is required");
|
|
23
|
-
if (externalId && dedupeWithExternalId) {
|
|
24
|
-
return ensureAutomationRun({ agentId, inputs, externalId });
|
|
25
|
-
}
|
|
26
|
-
return createAutomationRun({ agentId, inputs, externalId });
|
|
27
|
-
},
|
|
28
|
-
onSuccess: (data) => {
|
|
29
|
-
setCurrentRunId(data.id);
|
|
30
|
-
queryClient.setQueryData(["automation-run", data.id], data);
|
|
31
|
-
onCreated?.(data);
|
|
32
|
-
onUpdate?.(data);
|
|
33
|
-
},
|
|
34
|
-
onError: (err) => {
|
|
35
|
-
setErrorV(err instanceof Error ? err.message : "Unable to start automation");
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const cancelMutation = useMutation({
|
|
39
|
-
mutationFn: async (runId) => {
|
|
40
|
-
return cancelAutomationRun(runId);
|
|
41
|
-
},
|
|
42
|
-
onSuccess: (data) => {
|
|
43
|
-
queryClient.setQueryData(["automation-run", data.id], data);
|
|
44
|
-
onUpdate?.(data);
|
|
45
|
-
},
|
|
46
|
-
onError: (err) => {
|
|
47
|
-
setErrorV(err instanceof Error ? err.message : "Unable to cancel automation");
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const {
|
|
51
|
-
data: run,
|
|
52
|
-
isError: isQueryError,
|
|
53
|
-
error: queryError,
|
|
54
|
-
refetch
|
|
55
|
-
} = useQuery({
|
|
56
|
-
queryKey: ["automation-run", currentRunId],
|
|
57
|
-
queryFn: async () => {
|
|
58
|
-
if (!currentRunId) return null;
|
|
59
|
-
return getAutomationRun(currentRunId);
|
|
60
|
-
},
|
|
61
|
-
enabled: !!currentRunId,
|
|
62
|
-
// Poll while active, stop when terminal
|
|
63
|
-
refetchInterval: (query) => {
|
|
64
|
-
const status = query.state.data?.status;
|
|
65
|
-
if (status && automationStatuses.TERMINAL_STATUSES.includes(status)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return pollIntervalMs;
|
|
69
|
-
},
|
|
70
|
-
// Immediately show data from setQueryData
|
|
71
|
-
initialData: void 0
|
|
72
|
-
});
|
|
73
|
-
const completedRunRef = useRef(null);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (run) {
|
|
76
|
-
onUpdate?.(run);
|
|
77
|
-
if (automationStatuses.TERMINAL_STATUSES.includes(run.status)) {
|
|
78
|
-
if (completedRunRef.current !== run.id) {
|
|
79
|
-
completedRunRef.current = run.id;
|
|
80
|
-
onComplete?.(run);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
if (completedRunRef.current === run.id) {
|
|
84
|
-
completedRunRef.current = null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, [run, onComplete, onUpdate]);
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (isQueryError && queryError) {
|
|
91
|
-
setErrorV(queryError instanceof Error ? queryError.message : "Failed to poll automation");
|
|
92
|
-
}
|
|
93
|
-
}, [isQueryError, queryError]);
|
|
94
|
-
const start = useCallback(async () => {
|
|
95
|
-
try {
|
|
96
|
-
const result = await startMutation.mutateAsync();
|
|
97
|
-
return result;
|
|
98
|
-
} catch {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}, [startMutation]);
|
|
102
|
-
const cancel = useCallback(async () => {
|
|
103
|
-
if (!currentRunId) return null;
|
|
104
|
-
try {
|
|
105
|
-
return await cancelMutation.mutateAsync(currentRunId);
|
|
106
|
-
} catch {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}, [cancelMutation, currentRunId]);
|
|
110
|
-
const refresh = useCallback(async () => {
|
|
111
|
-
if (!currentRunId) return start();
|
|
112
|
-
const result = await refetch();
|
|
113
|
-
return result.data ?? null;
|
|
114
|
-
}, [currentRunId, refetch, start]);
|
|
115
|
-
const autoStartedRef = useRef(false);
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
if (autoStart && !autoStartedRef.current && !currentRunId) {
|
|
118
|
-
autoStartedRef.current = true;
|
|
119
|
-
void start();
|
|
120
|
-
}
|
|
121
|
-
}, [autoStart, currentRunId, start]);
|
|
122
|
-
return {
|
|
123
|
-
run: run ?? null,
|
|
124
|
-
status: run?.status ?? "idle",
|
|
125
|
-
isLoading: startMutation.isPending || cancelMutation.isPending,
|
|
126
|
-
error: errorV,
|
|
127
|
-
start,
|
|
128
|
-
refresh,
|
|
129
|
-
cancel
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
export {
|
|
133
|
-
useAutomationRun as u
|
|
134
|
-
};
|