cueclaw 0.0.1 → 0.0.3
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/app-UJ4M3TPW.js +448 -0
- package/dist/chunk-D77G7ABJ.js +1051 -0
- package/dist/chunk-E7BP6DMO.js +10 -0
- package/dist/chunk-GMHDL4CG.js +250 -0
- package/dist/chunk-JRHM3Z4C.js +158 -0
- package/dist/chunk-K4PGB2DU.js +140 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +225 -0
- package/dist/config-HMHM7UAZ.js +12 -0
- package/dist/daemon-TWVEMRCU.js +308 -0
- package/dist/router-36O66FDW.js +10 -0
- package/dist/service-BHFOM6E2.js +153 -0
- package/dist/setup-QZUEJUIN.js +154 -0
- package/dist/telegram-BTTWEETO.js +120 -0
- package/dist/whatsapp-36XWDSJ5.js +92 -0
- package/package.json +49 -11
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import {
|
|
2
|
+
confirmPlan,
|
|
3
|
+
executeWorkflow,
|
|
4
|
+
generatePlan,
|
|
5
|
+
rejectPlan
|
|
6
|
+
} from "./chunk-D77G7ABJ.js";
|
|
7
|
+
import {
|
|
8
|
+
initDb,
|
|
9
|
+
listWorkflows
|
|
10
|
+
} from "./chunk-K4PGB2DU.js";
|
|
11
|
+
import {
|
|
12
|
+
loadConfig
|
|
13
|
+
} from "./chunk-JRHM3Z4C.js";
|
|
14
|
+
import {
|
|
15
|
+
logger
|
|
16
|
+
} from "./chunk-E7BP6DMO.js";
|
|
17
|
+
|
|
18
|
+
// src/tui/app.tsx
|
|
19
|
+
import { useReducer, useCallback } from "react";
|
|
20
|
+
import { Box as Box6, useInput as useInput3, useApp } from "ink";
|
|
21
|
+
import { ThemeProvider } from "@inkjs/ui";
|
|
22
|
+
|
|
23
|
+
// src/tui/theme.ts
|
|
24
|
+
import { extendTheme, defaultTheme } from "@inkjs/ui";
|
|
25
|
+
var cueclawTheme = extendTheme(defaultTheme, {
|
|
26
|
+
components: {
|
|
27
|
+
Banner: {
|
|
28
|
+
styles: {
|
|
29
|
+
logo: () => ({ color: "cyan" }),
|
|
30
|
+
tagline: () => ({ color: "gray", dimColor: true })
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
PlanView: {
|
|
34
|
+
styles: {
|
|
35
|
+
title: () => ({ color: "cyan", bold: true }),
|
|
36
|
+
stepPending: () => ({ color: "gray" }),
|
|
37
|
+
stepRunning: () => ({ color: "yellow" }),
|
|
38
|
+
stepDone: () => ({ color: "green" }),
|
|
39
|
+
stepFailed: () => ({ color: "red" }),
|
|
40
|
+
border: () => ({ borderColor: "gray" })
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
StatusDashboard: {
|
|
44
|
+
styles: {
|
|
45
|
+
executing: () => ({ color: "yellow" }),
|
|
46
|
+
completed: () => ({ color: "green" }),
|
|
47
|
+
failed: () => ({ color: "red" }),
|
|
48
|
+
paused: () => ({ color: "gray", dimColor: true })
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
Chat: {
|
|
52
|
+
styles: {
|
|
53
|
+
userMessage: () => ({ color: "white", bold: true }),
|
|
54
|
+
systemMessage: () => ({ color: "cyan" }),
|
|
55
|
+
prompt: () => ({ color: "green" })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// src/tui/banner.tsx
|
|
62
|
+
import { useEffect } from "react";
|
|
63
|
+
import { Box, Text } from "ink";
|
|
64
|
+
import { useComponentTheme } from "@inkjs/ui";
|
|
65
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
66
|
+
var LOGO = ` \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557
|
|
67
|
+
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551
|
|
68
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2557 \u2588\u2588\u2551
|
|
69
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2557\u2588\u2588\u2551
|
|
70
|
+
\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2554\u2588\u2588\u2588\u2554\u255D
|
|
71
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u255D\u255A\u2550\u2550\u255D`;
|
|
72
|
+
function Banner({ onComplete }) {
|
|
73
|
+
const { styles } = useComponentTheme("Banner");
|
|
74
|
+
const logoStyle = styles?.logo?.() ?? { color: "cyan" };
|
|
75
|
+
const taglineStyle = styles?.tagline?.() ?? { color: "gray", dimColor: true };
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const timer = setTimeout(onComplete, 1e3);
|
|
78
|
+
return () => clearTimeout(timer);
|
|
79
|
+
}, [onComplete]);
|
|
80
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", alignItems: "center", marginTop: 1, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(Text, { ...logoStyle, children: LOGO }),
|
|
82
|
+
/* @__PURE__ */ jsx(Text, { ...taglineStyle, children: "\n orchestrate your agents with natural language" })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/tui/chat.tsx
|
|
87
|
+
import { Box as Box2, Text as Text2 } from "ink";
|
|
88
|
+
import { TextInput, Spinner, useComponentTheme as useComponentTheme2 } from "@inkjs/ui";
|
|
89
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
90
|
+
function Chat({ messages, isGenerating, onSubmit }) {
|
|
91
|
+
const { styles } = useComponentTheme2("Chat");
|
|
92
|
+
const userStyle = styles?.userMessage?.() ?? { color: "white", bold: true };
|
|
93
|
+
const systemStyle = styles?.systemMessage?.() ?? { color: "cyan" };
|
|
94
|
+
const promptStyle = styles?.prompt?.() ?? { color: "green" };
|
|
95
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", flexGrow: 1, children: [
|
|
96
|
+
/* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", flexGrow: 1, paddingX: 1, children: [
|
|
97
|
+
messages.map((msg, i) => /* @__PURE__ */ jsx2(Box2, { marginBottom: 1, children: msg.role === "user" ? /* @__PURE__ */ jsxs2(Text2, { ...userStyle, children: [
|
|
98
|
+
"You: ",
|
|
99
|
+
msg.text
|
|
100
|
+
] }) : /* @__PURE__ */ jsxs2(Text2, { ...systemStyle, children: [
|
|
101
|
+
"CueClaw: ",
|
|
102
|
+
msg.text
|
|
103
|
+
] }) }, i)),
|
|
104
|
+
isGenerating && /* @__PURE__ */ jsx2(Box2, { children: /* @__PURE__ */ jsx2(Spinner, { label: "Generating plan..." }) })
|
|
105
|
+
] }),
|
|
106
|
+
!isGenerating && /* @__PURE__ */ jsxs2(Box2, { paddingX: 1, children: [
|
|
107
|
+
/* @__PURE__ */ jsx2(Text2, { ...promptStyle, children: "> " }),
|
|
108
|
+
/* @__PURE__ */ jsx2(
|
|
109
|
+
TextInput,
|
|
110
|
+
{
|
|
111
|
+
placeholder: "Describe your workflow...",
|
|
112
|
+
onSubmit: (value) => {
|
|
113
|
+
if (value.trim()) onSubmit(value.trim());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] })
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/tui/plan-view.tsx
|
|
122
|
+
import { Box as Box3, Text as Text3, useInput } from "ink";
|
|
123
|
+
import { useComponentTheme as useComponentTheme3 } from "@inkjs/ui";
|
|
124
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
125
|
+
function PlanView({ workflow, onConfirm, onModify, onCancel }) {
|
|
126
|
+
const { styles } = useComponentTheme3("PlanView");
|
|
127
|
+
const titleStyle = styles?.title?.() ?? { color: "cyan", bold: true };
|
|
128
|
+
const pendingStyle = styles?.stepPending?.() ?? { color: "gray" };
|
|
129
|
+
const borderStyle = styles?.border?.() ?? { borderColor: "gray" };
|
|
130
|
+
useInput((input) => {
|
|
131
|
+
if (input === "y" || input === "Y") onConfirm();
|
|
132
|
+
if (input === "m" || input === "M") onModify();
|
|
133
|
+
if (input === "n" || input === "N") onCancel();
|
|
134
|
+
});
|
|
135
|
+
const trigger = workflow.trigger;
|
|
136
|
+
const triggerLabel = trigger.type === "manual" ? "manual" : trigger.type === "cron" ? `cron (${trigger.expression})` : `poll (${trigger.interval_seconds}s)`;
|
|
137
|
+
const failureDesc = workflow.failure_policy.on_step_failure;
|
|
138
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingX: 1, borderStyle: "round", ...borderStyle, children: [
|
|
139
|
+
/* @__PURE__ */ jsxs3(Text3, { ...titleStyle, children: [
|
|
140
|
+
"Plan: ",
|
|
141
|
+
workflow.name
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
144
|
+
"Trigger: ",
|
|
145
|
+
triggerLabel
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx3(Text3, { children: "" }),
|
|
148
|
+
workflow.steps.map((step, i) => /* @__PURE__ */ jsx3(StepLine, { step, index: i + 1, style: pendingStyle }, step.id)),
|
|
149
|
+
/* @__PURE__ */ jsx3(Text3, { children: "" }),
|
|
150
|
+
/* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
151
|
+
"Failure policy: ",
|
|
152
|
+
failureDesc
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ jsx3(Text3, { children: "" }),
|
|
155
|
+
/* @__PURE__ */ jsxs3(Text3, { children: [
|
|
156
|
+
/* @__PURE__ */ jsx3(Text3, { color: "green", children: "[Y] Confirm" }),
|
|
157
|
+
" ",
|
|
158
|
+
/* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "[M] Modify" }),
|
|
159
|
+
" ",
|
|
160
|
+
/* @__PURE__ */ jsx3(Text3, { color: "red", children: "[N] Cancel" })
|
|
161
|
+
] })
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
function StepLine({ step, index, style }) {
|
|
165
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
166
|
+
/* @__PURE__ */ jsxs3(Text3, { ...style, children: [
|
|
167
|
+
index,
|
|
168
|
+
". ",
|
|
169
|
+
step.description
|
|
170
|
+
] }),
|
|
171
|
+
step.depends_on && step.depends_on.length > 0 && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
172
|
+
" \u2514\u2500 depends on: ",
|
|
173
|
+
step.depends_on.join(", ")
|
|
174
|
+
] })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/tui/status.tsx
|
|
179
|
+
import { useState } from "react";
|
|
180
|
+
import { Box as Box4, Text as Text4, useInput as useInput2 } from "ink";
|
|
181
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
182
|
+
function Status({ workflows, onSelect, onBack }) {
|
|
183
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
184
|
+
useInput2((input, key) => {
|
|
185
|
+
if (key.upArrow && selectedIndex > 0) setSelectedIndex(selectedIndex - 1);
|
|
186
|
+
if (key.downArrow && selectedIndex < workflows.length - 1) setSelectedIndex(selectedIndex + 1);
|
|
187
|
+
if (key.return && workflows.length > 0) onSelect(workflows[selectedIndex]);
|
|
188
|
+
if (key.escape || input === "q") onBack();
|
|
189
|
+
});
|
|
190
|
+
const phaseColor = (phase) => {
|
|
191
|
+
switch (phase) {
|
|
192
|
+
case "executing":
|
|
193
|
+
return "yellow";
|
|
194
|
+
case "active":
|
|
195
|
+
return "green";
|
|
196
|
+
case "completed":
|
|
197
|
+
return "green";
|
|
198
|
+
case "failed":
|
|
199
|
+
return "red";
|
|
200
|
+
case "paused":
|
|
201
|
+
return "gray";
|
|
202
|
+
default:
|
|
203
|
+
return "white";
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingX: 1, borderStyle: "round", borderColor: "gray", children: [
|
|
207
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, color: "cyan", children: "Workflows" }),
|
|
208
|
+
/* @__PURE__ */ jsx4(Text4, { children: "" }),
|
|
209
|
+
workflows.length === 0 ? /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "No workflows found. Type a description to create one." }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
210
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
211
|
+
/* @__PURE__ */ jsx4(Box4, { width: 14, children: /* @__PURE__ */ jsx4(Text4, { bold: true, children: "ID" }) }),
|
|
212
|
+
/* @__PURE__ */ jsx4(Box4, { width: 28, children: /* @__PURE__ */ jsx4(Text4, { bold: true, children: "Name" }) }),
|
|
213
|
+
/* @__PURE__ */ jsx4(Box4, { width: 14, children: /* @__PURE__ */ jsx4(Text4, { bold: true, children: "Phase" }) })
|
|
214
|
+
] }),
|
|
215
|
+
workflows.map((wf, i) => /* @__PURE__ */ jsx4(Box4, { children: /* @__PURE__ */ jsxs4(Text4, { inverse: i === selectedIndex, children: [
|
|
216
|
+
/* @__PURE__ */ jsx4(Text4, { children: wf.id.slice(0, 12).padEnd(14) }),
|
|
217
|
+
/* @__PURE__ */ jsx4(Text4, { children: wf.name.slice(0, 26).padEnd(28) }),
|
|
218
|
+
/* @__PURE__ */ jsx4(Text4, { color: phaseColor(wf.phase), children: wf.phase })
|
|
219
|
+
] }) }, wf.id))
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ jsx4(Text4, { children: "" }),
|
|
222
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "[Enter] View [Q] Back" })
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/tui/execution-view.tsx
|
|
227
|
+
import { Box as Box5, Text as Text5 } from "ink";
|
|
228
|
+
import { Spinner as Spinner2, useComponentTheme as useComponentTheme4 } from "@inkjs/ui";
|
|
229
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
230
|
+
function ExecutionView({ workflow, stepProgress, output }) {
|
|
231
|
+
const { styles } = useComponentTheme4("PlanView");
|
|
232
|
+
const titleStyle = styles?.title?.() ?? { color: "cyan", bold: true };
|
|
233
|
+
const isRunning = Array.from(stepProgress.values()).some((s) => s.status === "running");
|
|
234
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 1, children: [
|
|
235
|
+
/* @__PURE__ */ jsxs5(Box5, { justifyContent: "space-between", children: [
|
|
236
|
+
/* @__PURE__ */ jsxs5(Text5, { ...titleStyle, children: [
|
|
237
|
+
"Workflow: ",
|
|
238
|
+
workflow.name
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxs5(Text5, { dimColor: true, children: [
|
|
241
|
+
"Status: ",
|
|
242
|
+
isRunning ? "Running" : "Complete"
|
|
243
|
+
] })
|
|
244
|
+
] }),
|
|
245
|
+
/* @__PURE__ */ jsx5(Text5, { children: "" }),
|
|
246
|
+
/* @__PURE__ */ jsx5(Text5, { bold: true, children: "Steps:" }),
|
|
247
|
+
workflow.steps.map((step, i) => {
|
|
248
|
+
const progress = stepProgress.get(step.id);
|
|
249
|
+
const status = progress?.status ?? "pending";
|
|
250
|
+
const icon = statusIcon(status);
|
|
251
|
+
const durationText = progress?.duration ? ` (${formatDuration(progress.duration)})` : "";
|
|
252
|
+
return /* @__PURE__ */ jsxs5(Box5, { children: [
|
|
253
|
+
/* @__PURE__ */ jsxs5(Text5, { color: statusColor(status), children: [
|
|
254
|
+
icon,
|
|
255
|
+
" ",
|
|
256
|
+
i + 1,
|
|
257
|
+
". ",
|
|
258
|
+
step.description,
|
|
259
|
+
durationText
|
|
260
|
+
] }),
|
|
261
|
+
status === "running" && /* @__PURE__ */ jsx5(Spinner2, {})
|
|
262
|
+
] }, step.id);
|
|
263
|
+
}),
|
|
264
|
+
output.length > 0 && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, children: [
|
|
265
|
+
/* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "\u2500\u2500 Live Output \u2500\u2500" }),
|
|
266
|
+
output.slice(-10).map((line, i) => /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: line }, i))
|
|
267
|
+
] })
|
|
268
|
+
] });
|
|
269
|
+
}
|
|
270
|
+
function statusIcon(status) {
|
|
271
|
+
switch (status) {
|
|
272
|
+
case "succeeded":
|
|
273
|
+
return "\u2713";
|
|
274
|
+
case "running":
|
|
275
|
+
return "\u25CF";
|
|
276
|
+
case "failed":
|
|
277
|
+
return "\u2717";
|
|
278
|
+
case "skipped":
|
|
279
|
+
return "\u25CB";
|
|
280
|
+
default:
|
|
281
|
+
return " ";
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function statusColor(status) {
|
|
285
|
+
switch (status) {
|
|
286
|
+
case "succeeded":
|
|
287
|
+
return "green";
|
|
288
|
+
case "running":
|
|
289
|
+
return "yellow";
|
|
290
|
+
case "failed":
|
|
291
|
+
return "red";
|
|
292
|
+
case "skipped":
|
|
293
|
+
return "gray";
|
|
294
|
+
default:
|
|
295
|
+
return "gray";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function formatDuration(ms) {
|
|
299
|
+
if (ms < 1e3) return `${ms}ms`;
|
|
300
|
+
return `${Math.round(ms / 1e3)}s`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/tui/app.tsx
|
|
304
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
305
|
+
function appReducer(state, action) {
|
|
306
|
+
switch (action.type) {
|
|
307
|
+
case "SHOW_CHAT":
|
|
308
|
+
return { ...state, view: "chat" };
|
|
309
|
+
case "SHOW_PLAN":
|
|
310
|
+
return { ...state, view: "plan", workflow: action.workflow };
|
|
311
|
+
case "SHOW_DASHBOARD":
|
|
312
|
+
return { ...state, view: "dashboard", workflows: action.workflows };
|
|
313
|
+
case "SHOW_EXECUTION":
|
|
314
|
+
return { ...state, view: "execution", workflow: action.workflow, stepProgress: /* @__PURE__ */ new Map(), executionOutput: [] };
|
|
315
|
+
case "ADD_MESSAGE":
|
|
316
|
+
return { ...state, messages: [...state.messages, action.message] };
|
|
317
|
+
case "SET_GENERATING":
|
|
318
|
+
return { ...state, isGenerating: action.value };
|
|
319
|
+
case "UPDATE_STEP":
|
|
320
|
+
return { ...state, stepProgress: new Map(state.stepProgress).set(action.stepId, action.progress) };
|
|
321
|
+
case "ADD_OUTPUT":
|
|
322
|
+
return { ...state, executionOutput: [...state.executionOutput, action.line] };
|
|
323
|
+
default:
|
|
324
|
+
return state;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
var initialState = {
|
|
328
|
+
view: "banner",
|
|
329
|
+
messages: [],
|
|
330
|
+
workflow: null,
|
|
331
|
+
workflows: [],
|
|
332
|
+
isGenerating: false,
|
|
333
|
+
stepProgress: /* @__PURE__ */ new Map(),
|
|
334
|
+
executionOutput: []
|
|
335
|
+
};
|
|
336
|
+
function App({ noBanner, cwd }) {
|
|
337
|
+
const { exit } = useApp();
|
|
338
|
+
const config = loadConfig();
|
|
339
|
+
const db = initDb();
|
|
340
|
+
const [state, dispatch] = useReducer(appReducer, {
|
|
341
|
+
...initialState,
|
|
342
|
+
view: noBanner ? "chat" : "banner"
|
|
343
|
+
});
|
|
344
|
+
useInput3((input, key) => {
|
|
345
|
+
if (input === "d" && key.ctrl) {
|
|
346
|
+
const workflows = listWorkflows(db);
|
|
347
|
+
dispatch({ type: "SHOW_DASHBOARD", workflows });
|
|
348
|
+
}
|
|
349
|
+
if (input === "c" && key.ctrl) {
|
|
350
|
+
exit();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
const handleChatSubmit = useCallback(async (text) => {
|
|
354
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "user", text } });
|
|
355
|
+
dispatch({ type: "SET_GENERATING", value: true });
|
|
356
|
+
try {
|
|
357
|
+
const workflow = await generatePlan(text, config);
|
|
358
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: `Generated plan: "${workflow.name}"` } });
|
|
359
|
+
dispatch({ type: "SET_GENERATING", value: false });
|
|
360
|
+
dispatch({ type: "SHOW_PLAN", workflow });
|
|
361
|
+
} catch (err) {
|
|
362
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
363
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: `Error: ${msg}` } });
|
|
364
|
+
dispatch({ type: "SET_GENERATING", value: false });
|
|
365
|
+
logger.error({ err }, "Plan generation failed");
|
|
366
|
+
}
|
|
367
|
+
}, [config]);
|
|
368
|
+
const handleConfirm = useCallback(async () => {
|
|
369
|
+
if (!state.workflow) return;
|
|
370
|
+
const confirmed = confirmPlan(state.workflow);
|
|
371
|
+
dispatch({ type: "SHOW_EXECUTION", workflow: confirmed });
|
|
372
|
+
try {
|
|
373
|
+
await executeWorkflow({
|
|
374
|
+
workflow: confirmed,
|
|
375
|
+
triggerData: null,
|
|
376
|
+
db,
|
|
377
|
+
cwd,
|
|
378
|
+
onProgress: (stepId, msg) => {
|
|
379
|
+
dispatch({ type: "UPDATE_STEP", stepId, progress: { stepId, status: "running" } });
|
|
380
|
+
if (typeof msg === "string") {
|
|
381
|
+
dispatch({ type: "ADD_OUTPUT", line: msg });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: "Workflow execution completed." } });
|
|
386
|
+
} catch (err) {
|
|
387
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
388
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: `Execution failed: ${msg}` } });
|
|
389
|
+
logger.error({ err }, "Workflow execution failed");
|
|
390
|
+
}
|
|
391
|
+
}, [state.workflow, db, cwd]);
|
|
392
|
+
const handleModify = useCallback(() => {
|
|
393
|
+
dispatch({ type: "SHOW_CHAT" });
|
|
394
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: "Describe your modifications:" } });
|
|
395
|
+
}, []);
|
|
396
|
+
const handleCancel = useCallback(() => {
|
|
397
|
+
if (state.workflow) {
|
|
398
|
+
rejectPlan(state.workflow);
|
|
399
|
+
}
|
|
400
|
+
dispatch({ type: "SHOW_CHAT" });
|
|
401
|
+
dispatch({ type: "ADD_MESSAGE", message: { role: "system", text: "Plan cancelled." } });
|
|
402
|
+
}, [state.workflow]);
|
|
403
|
+
const handleDashboardSelect = useCallback((workflow) => {
|
|
404
|
+
dispatch({ type: "SHOW_EXECUTION", workflow });
|
|
405
|
+
}, []);
|
|
406
|
+
const handleDashboardBack = useCallback(() => {
|
|
407
|
+
dispatch({ type: "SHOW_CHAT" });
|
|
408
|
+
}, []);
|
|
409
|
+
return /* @__PURE__ */ jsx6(ThemeProvider, { theme: cueclawTheme, children: /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
410
|
+
state.view === "banner" && /* @__PURE__ */ jsx6(Banner, { onComplete: () => dispatch({ type: "SHOW_CHAT" }) }),
|
|
411
|
+
state.view === "chat" && /* @__PURE__ */ jsx6(
|
|
412
|
+
Chat,
|
|
413
|
+
{
|
|
414
|
+
messages: state.messages,
|
|
415
|
+
isGenerating: state.isGenerating,
|
|
416
|
+
onSubmit: handleChatSubmit
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
state.view === "plan" && state.workflow && /* @__PURE__ */ jsx6(
|
|
420
|
+
PlanView,
|
|
421
|
+
{
|
|
422
|
+
workflow: state.workflow,
|
|
423
|
+
onConfirm: handleConfirm,
|
|
424
|
+
onModify: handleModify,
|
|
425
|
+
onCancel: handleCancel
|
|
426
|
+
}
|
|
427
|
+
),
|
|
428
|
+
state.view === "dashboard" && /* @__PURE__ */ jsx6(
|
|
429
|
+
Status,
|
|
430
|
+
{
|
|
431
|
+
workflows: state.workflows,
|
|
432
|
+
onSelect: handleDashboardSelect,
|
|
433
|
+
onBack: handleDashboardBack
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
state.view === "execution" && state.workflow && /* @__PURE__ */ jsx6(
|
|
437
|
+
ExecutionView,
|
|
438
|
+
{
|
|
439
|
+
workflow: state.workflow,
|
|
440
|
+
stepProgress: state.stepProgress,
|
|
441
|
+
output: state.executionOutput
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
] }) });
|
|
445
|
+
}
|
|
446
|
+
export {
|
|
447
|
+
App
|
|
448
|
+
};
|