cueclaw 0.0.3 → 0.1.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/app-DIUXV4XR.js +1953 -0
- package/dist/chunk-BVQG3WYO.js +29 -0
- package/dist/chunk-DVQFSFIZ.js +14 -0
- package/dist/{chunk-GMHDL4CG.js → chunk-F3EQAFH4.js} +59 -5
- package/dist/{chunk-K4PGB2DU.js → chunk-G43R5ASK.js} +46 -2
- package/dist/chunk-KRNAXOQ4.js +46 -0
- package/dist/{service-BHFOM6E2.js → chunk-PZZ6FBGB.js} +25 -7
- package/dist/chunk-QBOYMF4A.js +42 -0
- package/dist/chunk-RSKXBXSJ.js +247 -0
- package/dist/{chunk-D77G7ABJ.js → chunk-SEYPA5M2.js} +36 -318
- package/dist/{daemon-TWVEMRCU.js → chunk-W274JWEK.js} +3 -82
- package/dist/chunk-WE5J7GMR.js +409 -0
- package/dist/chunk-ZCK3IFLC.js +59 -0
- package/dist/cli.js +300 -46
- package/dist/config-6NWFKNLW.js +21 -0
- package/dist/daemon-R3LU23PR.js +95 -0
- package/dist/env-2ZIW4OD7.js +16 -0
- package/dist/executor-LS3Y4DO5.js +14 -0
- package/dist/logger-HD23RPWS.js +12 -0
- package/dist/planner-UU4T5IEN.js +28 -0
- package/dist/router-KEZ3YQXC.js +14 -0
- package/dist/service-VTUYSAAZ.js +15 -0
- package/dist/{setup-QZUEJUIN.js → setup-NWBKTQCO.js} +11 -45
- package/dist/{telegram-BTTWEETO.js → telegram-P6DBJ7WZ.js} +2 -2
- package/dist/{whatsapp-36XWDSJ5.js → whatsapp-HFMOFSFI.js} +1 -1
- package/package.json +4 -1
- package/dist/app-UJ4M3TPW.js +0 -448
- package/dist/chunk-E7BP6DMO.js +0 -10
- package/dist/chunk-JRHM3Z4C.js +0 -158
- package/dist/config-HMHM7UAZ.js +0 -12
- package/dist/router-36O66FDW.js +0 -10
|
@@ -1,53 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkEnvironment,
|
|
3
|
+
validateAuth
|
|
4
|
+
} from "./chunk-KRNAXOQ4.js";
|
|
5
|
+
import "./chunk-DVQFSFIZ.js";
|
|
1
6
|
import {
|
|
2
7
|
logger
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
|
|
5
|
-
// src/setup-environment.ts
|
|
6
|
-
import { execFileSync } from "child_process";
|
|
7
|
-
function checkEnvironment() {
|
|
8
|
-
const nodeVersion = process.version;
|
|
9
|
-
let docker = false;
|
|
10
|
-
let dockerVersion;
|
|
11
|
-
let dockerRunning = false;
|
|
12
|
-
try {
|
|
13
|
-
const version = execFileSync("docker", ["--version"], { encoding: "utf-8" }).trim();
|
|
14
|
-
docker = true;
|
|
15
|
-
dockerVersion = version;
|
|
16
|
-
} catch {
|
|
17
|
-
}
|
|
18
|
-
if (docker) {
|
|
19
|
-
try {
|
|
20
|
-
execFileSync("docker", ["info"], { encoding: "utf-8", stdio: "pipe" });
|
|
21
|
-
dockerRunning = true;
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return { docker, dockerVersion, dockerRunning, nodeVersion };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/setup-auth.ts
|
|
29
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
30
|
-
async function validateAuth(config) {
|
|
31
|
-
try {
|
|
32
|
-
const client = new Anthropic({ apiKey: config.claude.api_key });
|
|
33
|
-
await client.messages.create({
|
|
34
|
-
model: "claude-haiku-4-5-20251001",
|
|
35
|
-
max_tokens: 10,
|
|
36
|
-
messages: [{ role: "user", content: "ping" }]
|
|
37
|
-
});
|
|
38
|
-
return { valid: true };
|
|
39
|
-
} catch (err) {
|
|
40
|
-
return { valid: false, error: err instanceof Error ? err.message : String(err) };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
8
|
+
} from "./chunk-QBOYMF4A.js";
|
|
43
9
|
|
|
44
10
|
// src/setup-container.ts
|
|
45
|
-
import { execFileSync
|
|
11
|
+
import { execFileSync } from "child_process";
|
|
46
12
|
import { join } from "path";
|
|
47
13
|
function buildContainer(projectRoot) {
|
|
48
14
|
const buildScript = join(projectRoot, "container", "build.sh");
|
|
49
15
|
try {
|
|
50
|
-
|
|
16
|
+
execFileSync("bash", [buildScript], {
|
|
51
17
|
encoding: "utf-8",
|
|
52
18
|
stdio: "inherit",
|
|
53
19
|
cwd: join(projectRoot, "container")
|
|
@@ -59,7 +25,7 @@ function buildContainer(projectRoot) {
|
|
|
59
25
|
}
|
|
60
26
|
function checkContainerImage(imageName) {
|
|
61
27
|
try {
|
|
62
|
-
const result =
|
|
28
|
+
const result = execFileSync("docker", ["image", "inspect", imageName], {
|
|
63
29
|
encoding: "utf-8",
|
|
64
30
|
stdio: "pipe"
|
|
65
31
|
});
|
|
@@ -70,10 +36,10 @@ function checkContainerImage(imageName) {
|
|
|
70
36
|
}
|
|
71
37
|
|
|
72
38
|
// src/setup-verify.ts
|
|
73
|
-
import { execFileSync as
|
|
39
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
74
40
|
function runSmokeTest(imageName) {
|
|
75
41
|
try {
|
|
76
|
-
const result =
|
|
42
|
+
const result = execFileSync2("docker", [
|
|
77
43
|
"run",
|
|
78
44
|
"--rm",
|
|
79
45
|
"--network",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QBOYMF4A.js";
|
|
4
4
|
|
|
5
5
|
// src/channels/telegram.ts
|
|
6
6
|
import { Bot, InlineKeyboard } from "grammy";
|
|
@@ -42,7 +42,7 @@ var TelegramChannel = class {
|
|
|
42
42
|
this.bot.catch((err) => {
|
|
43
43
|
logger.error({ err: err.error }, "Telegram bot error");
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
this.bot.start();
|
|
46
46
|
this.connected = true;
|
|
47
47
|
logger.info("Telegram bot connected");
|
|
48
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cueclaw",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Orchestrate agent workflows with natural language. Natural language in, executable DAG out.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"commit-msg": "pnpm commitlint --edit $1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.56",
|
|
47
48
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
48
49
|
"@inkjs/ui": "^2.0.0",
|
|
49
50
|
"@whiskeysockets/baileys": "7.0.0-rc.9",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"pino": "^10.3.1",
|
|
60
61
|
"pino-pretty": "^13.1.3",
|
|
61
62
|
"react": "18",
|
|
63
|
+
"string-width": "^8.2.0",
|
|
62
64
|
"yaml": "^2.8.2",
|
|
63
65
|
"zod": "^4.3.6"
|
|
64
66
|
},
|
|
@@ -72,6 +74,7 @@
|
|
|
72
74
|
"@types/react": "^19.2.14",
|
|
73
75
|
"@vitest/coverage-v8": "^4.0.18",
|
|
74
76
|
"eslint": "^10.0.2",
|
|
77
|
+
"ink-testing-library": "^4.0.0",
|
|
75
78
|
"simple-git-hooks": "^2.13.1",
|
|
76
79
|
"tsup": "^8.5.1",
|
|
77
80
|
"tsx": "^4.21.0",
|
package/dist/app-UJ4M3TPW.js
DELETED
|
@@ -1,448 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-E7BP6DMO.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/logger.ts
|
|
2
|
-
import pino from "pino";
|
|
3
|
-
var logger = pino({
|
|
4
|
-
level: process.env["LOG_LEVEL"] ?? "info",
|
|
5
|
-
transport: process.env["NODE_ENV"] === "production" ? void 0 : { target: "pino-pretty", options: { colorize: true } }
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
logger
|
|
10
|
-
};
|