cueclaw 0.1.2 → 0.1.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/README.md +202 -20
- package/dist/app-JK3HBFKZ.js +3279 -0
- package/dist/{chunk-RSKXBXSJ.js → chunk-25KI643G.js} +16 -1
- package/dist/{chunk-PZZ6FBGB.js → chunk-CXBDJQJJ.js} +4 -3
- package/dist/chunk-HDUFGPCI.js +729 -0
- package/dist/{chunk-G43R5ASK.js → chunk-JJUF2AJ5.js} +20 -1
- package/dist/chunk-KBLMQZ3P.js +116 -0
- package/dist/{chunk-SEYPA5M2.js → chunk-X3WNTN5V.js} +147 -39
- package/dist/{chunk-WE5J7GMR.js → chunk-ZOFGQYXX.js} +36 -11
- package/dist/cli.js +123 -89
- package/dist/{config-6NWFKNLW.js → config-D5A5TNLZ.js} +4 -1
- package/dist/daemon-4DVXPT4O.js +28 -0
- package/dist/{executor-LS3Y4DO5.js → executor-TMY6MGVY.js} +5 -4
- package/dist/logger-HKMIMPCE.js +18 -0
- package/dist/{planner-UU4T5IEN.js → planner-MJ3XBCWH.js} +3 -3
- package/dist/{service-VTUYSAAZ.js → service-AP5GEITC.js} +4 -3
- package/dist/{setup-NWBKTQCO.js → setup-U2YKLOK6.js} +7 -2
- package/dist/{telegram-EFPHL4HC.js → telegram-FH5O4F3K.js} +25 -2
- package/dist/{whatsapp-HFMOFSFI.js → whatsapp-RLNSXSFI.js} +10 -2
- package/package.json +1 -1
- package/dist/app-LWDIWH7K.js +0 -1953
- package/dist/chunk-FAT2VKMJ.js +0 -232
- package/dist/chunk-IB6TU7TP.js +0 -310
- package/dist/chunk-QBOYMF4A.js +0 -42
- package/dist/daemon-WOR4GE5C.js +0 -96
- package/dist/logger-HD23RPWS.js +0 -12
- package/dist/router-ID6RN5AT.js +0 -14
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
loadSecrets
|
|
4
|
-
} from "./chunk-ZCK3IFLC.js";
|
|
5
2
|
import {
|
|
6
3
|
deleteWorkflow,
|
|
7
4
|
getStepRunsByRunId,
|
|
@@ -11,17 +8,21 @@ import {
|
|
|
11
8
|
insertWorkflow,
|
|
12
9
|
listWorkflows,
|
|
13
10
|
updateWorkflowPhase
|
|
14
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JJUF2AJ5.js";
|
|
15
12
|
import {
|
|
16
13
|
createDefaultConfig,
|
|
17
14
|
cueclawHome,
|
|
18
15
|
ensureCueclawHome,
|
|
19
16
|
loadConfig
|
|
20
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-25KI643G.js";
|
|
21
18
|
import "./chunk-BVQG3WYO.js";
|
|
22
19
|
import {
|
|
20
|
+
loadSecrets
|
|
21
|
+
} from "./chunk-ZCK3IFLC.js";
|
|
22
|
+
import {
|
|
23
|
+
initLogger,
|
|
23
24
|
logger
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-KBLMQZ3P.js";
|
|
25
26
|
|
|
26
27
|
// src/cli.ts
|
|
27
28
|
import { Command } from "commander";
|
|
@@ -102,6 +103,7 @@ configCmd.command("set").argument("<key>", "Config key (dot notation, e.g. claud
|
|
|
102
103
|
}
|
|
103
104
|
target[parts[parts.length - 1]] = parsed;
|
|
104
105
|
writeFileSync(configPath, stringifyYaml(doc), "utf-8");
|
|
106
|
+
logger.info({ key, value: parsed }, "Config value updated");
|
|
105
107
|
console.log(`Set ${key} = ${JSON.stringify(parsed)}`);
|
|
106
108
|
}
|
|
107
109
|
} catch (err) {
|
|
@@ -112,8 +114,9 @@ configCmd.command("set").argument("<key>", "Config key (dot notation, e.g. claud
|
|
|
112
114
|
program.command("new").description("Create a new workflow from a natural language description").argument("<description>", "Workflow description in natural language").action(async (description) => {
|
|
113
115
|
try {
|
|
114
116
|
const config = loadConfig();
|
|
115
|
-
const { generatePlan, confirmPlan } = await import("./planner-
|
|
116
|
-
const { executeWorkflow } = await import("./executor-
|
|
117
|
+
const { generatePlan, confirmPlan } = await import("./planner-MJ3XBCWH.js");
|
|
118
|
+
const { executeWorkflow } = await import("./executor-TMY6MGVY.js");
|
|
119
|
+
logger.info({ description: description.slice(0, 100) }, "Starting plan generation");
|
|
117
120
|
console.log("Planning workflow...");
|
|
118
121
|
const workflow = await generatePlan(description, config);
|
|
119
122
|
console.log(`
|
|
@@ -130,6 +133,7 @@ Workflow: ${workflow.name}`);
|
|
|
130
133
|
});
|
|
131
134
|
rl.close();
|
|
132
135
|
if (answer.toLowerCase() !== "y") {
|
|
136
|
+
logger.info({ workflowId: workflow.id }, "User cancelled workflow confirmation");
|
|
133
137
|
console.log("Cancelled.");
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
@@ -138,7 +142,9 @@ Workflow: ${workflow.name}`);
|
|
|
138
142
|
insertWorkflow(db, workflow);
|
|
139
143
|
const confirmed = confirmPlan(workflow);
|
|
140
144
|
updateWorkflowPhase(db, confirmed.id, confirmed.phase);
|
|
145
|
+
logger.info({ workflowId: confirmed.id, phase: confirmed.phase }, "Workflow confirmed");
|
|
141
146
|
if (confirmed.phase === "executing") {
|
|
147
|
+
logger.info({ workflowId: confirmed.id }, "Starting workflow execution");
|
|
142
148
|
console.log("\nExecuting workflow...");
|
|
143
149
|
const result = await executeWorkflow({
|
|
144
150
|
workflow: confirmed,
|
|
@@ -149,6 +155,7 @@ Workflow: ${workflow.name}`);
|
|
|
149
155
|
if (msg?.status) console.log(` [${stepId}] ${msg.status}`);
|
|
150
156
|
}
|
|
151
157
|
});
|
|
158
|
+
logger.info({ workflowId: confirmed.id, runId: result.runId, status: result.status }, "Workflow execution finished");
|
|
152
159
|
console.log(`
|
|
153
160
|
Workflow ${result.status}. Run ID: ${result.runId}`);
|
|
154
161
|
} else {
|
|
@@ -200,6 +207,7 @@ program.command("status").argument("[workflow-id]", "Workflow ID").description("
|
|
|
200
207
|
}
|
|
201
208
|
const wf = getWorkflow(db, workflowId);
|
|
202
209
|
if (!wf) {
|
|
210
|
+
logger.warn({ workflowId }, "Status check: workflow not found");
|
|
203
211
|
console.error(`Workflow not found: ${workflowId}`);
|
|
204
212
|
db.close();
|
|
205
213
|
process.exit(1);
|
|
@@ -246,16 +254,19 @@ program.command("pause").argument("<workflow-id>", "Workflow ID").description("P
|
|
|
246
254
|
const db = initDb();
|
|
247
255
|
const wf = getWorkflow(db, workflowId);
|
|
248
256
|
if (!wf) {
|
|
257
|
+
logger.warn({ workflowId }, "Pause failed: workflow not found");
|
|
249
258
|
console.error(`Workflow not found: ${workflowId}`);
|
|
250
259
|
db.close();
|
|
251
260
|
process.exit(1);
|
|
252
261
|
}
|
|
253
262
|
if (wf.phase !== "active") {
|
|
263
|
+
logger.warn({ workflowId, phase: wf.phase }, "Pause failed: invalid phase");
|
|
254
264
|
console.error(`Cannot pause workflow in phase "${wf.phase}" (must be "active")`);
|
|
255
265
|
db.close();
|
|
256
266
|
process.exit(1);
|
|
257
267
|
}
|
|
258
268
|
updateWorkflowPhase(db, workflowId, "paused");
|
|
269
|
+
logger.info({ workflowId }, "Workflow paused");
|
|
259
270
|
console.log(`Paused workflow "${wf.name}" (${workflowId})`);
|
|
260
271
|
db.close();
|
|
261
272
|
} catch (err) {
|
|
@@ -269,19 +280,22 @@ program.command("resume").argument("<workflow-id>", "Workflow ID").description("
|
|
|
269
280
|
const db = initDb();
|
|
270
281
|
const wf = getWorkflow(db, workflowId);
|
|
271
282
|
if (!wf) {
|
|
283
|
+
logger.warn({ workflowId }, "Resume failed: workflow not found");
|
|
272
284
|
console.error(`Workflow not found: ${workflowId}`);
|
|
273
285
|
db.close();
|
|
274
286
|
process.exit(1);
|
|
275
287
|
}
|
|
276
288
|
if (wf.phase !== "paused") {
|
|
289
|
+
logger.warn({ workflowId, phase: wf.phase }, "Resume failed: invalid phase");
|
|
277
290
|
console.error(`Cannot resume workflow in phase "${wf.phase}" (must be "paused")`);
|
|
278
291
|
db.close();
|
|
279
292
|
process.exit(1);
|
|
280
293
|
}
|
|
281
294
|
if (wf.trigger.type === "manual") {
|
|
282
295
|
updateWorkflowPhase(db, workflowId, "executing");
|
|
296
|
+
logger.info({ workflowId }, "Resuming workflow execution");
|
|
283
297
|
console.log(`Executing workflow "${wf.name}"...`);
|
|
284
|
-
const { executeWorkflow } = await import("./executor-
|
|
298
|
+
const { executeWorkflow } = await import("./executor-TMY6MGVY.js");
|
|
285
299
|
const result = await executeWorkflow({
|
|
286
300
|
workflow: { ...wf, phase: "executing" },
|
|
287
301
|
triggerData: null,
|
|
@@ -291,9 +305,11 @@ program.command("resume").argument("<workflow-id>", "Workflow ID").description("
|
|
|
291
305
|
if (msg?.status) console.log(` [${stepId}] ${msg.status}`);
|
|
292
306
|
}
|
|
293
307
|
});
|
|
308
|
+
logger.info({ workflowId, runId: result.runId, status: result.status }, "Resume execution finished");
|
|
294
309
|
console.log(`Workflow ${result.status}. Run ID: ${result.runId}`);
|
|
295
310
|
} else {
|
|
296
311
|
updateWorkflowPhase(db, workflowId, "active");
|
|
312
|
+
logger.info({ workflowId }, "Workflow resumed (trigger-based)");
|
|
297
313
|
console.log(`Resumed workflow "${wf.name}" (${workflowId})`);
|
|
298
314
|
}
|
|
299
315
|
db.close();
|
|
@@ -308,11 +324,13 @@ program.command("delete").argument("<workflow-id>", "Workflow ID").description("
|
|
|
308
324
|
const db = initDb();
|
|
309
325
|
const wf = getWorkflow(db, workflowId);
|
|
310
326
|
if (!wf) {
|
|
327
|
+
logger.warn({ workflowId }, "Delete failed: workflow not found");
|
|
311
328
|
console.error(`Workflow not found: ${workflowId}`);
|
|
312
329
|
db.close();
|
|
313
330
|
process.exit(1);
|
|
314
331
|
}
|
|
315
332
|
if (wf.phase === "executing") {
|
|
333
|
+
logger.warn({ workflowId }, "Delete failed: workflow is executing");
|
|
316
334
|
console.error(`Cannot delete workflow while it is executing`);
|
|
317
335
|
db.close();
|
|
318
336
|
process.exit(1);
|
|
@@ -323,11 +341,13 @@ program.command("delete").argument("<workflow-id>", "Workflow ID").description("
|
|
|
323
341
|
});
|
|
324
342
|
rl.close();
|
|
325
343
|
if (answer.toLowerCase() !== "y") {
|
|
344
|
+
logger.info({ workflowId }, "User cancelled workflow deletion");
|
|
326
345
|
console.log("Cancelled.");
|
|
327
346
|
db.close();
|
|
328
347
|
return;
|
|
329
348
|
}
|
|
330
349
|
deleteWorkflow(db, workflowId);
|
|
350
|
+
logger.info({ workflowId }, "Workflow deleted");
|
|
331
351
|
console.log(`Deleted workflow "${wf.name}" (${workflowId})`);
|
|
332
352
|
db.close();
|
|
333
353
|
} catch (err) {
|
|
@@ -336,82 +356,127 @@ program.command("delete").argument("<workflow-id>", "Workflow ID").description("
|
|
|
336
356
|
}
|
|
337
357
|
});
|
|
338
358
|
var daemonCmd = program.command("daemon").description("Manage background daemon");
|
|
339
|
-
daemonCmd.command("start").option("--
|
|
340
|
-
if (opts.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
daemonCmd.command("start").option("--foreground", "Run in foreground (for system services)").description("Start the daemon (runs in background by default)").action(async (opts) => {
|
|
360
|
+
if (opts.foreground) {
|
|
361
|
+
try {
|
|
362
|
+
const { startDaemon } = await import("./daemon-4DVXPT4O.js");
|
|
363
|
+
await startDaemon();
|
|
364
|
+
} catch (err) {
|
|
365
|
+
logger.error({ err }, "Daemon failed");
|
|
366
|
+
process.exit(1);
|
|
367
|
+
}
|
|
348
368
|
return;
|
|
349
369
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
} catch (err) {
|
|
354
|
-
logger.error({ err }, "Daemon failed");
|
|
355
|
-
process.exit(1);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
daemonCmd.command("stop").description("Stop the daemon").action(async () => {
|
|
359
|
-
const { getServiceStatus, stopService } = await import("./service-VTUYSAAZ.js");
|
|
360
|
-
const status = getServiceStatus();
|
|
361
|
-
if (status !== "running") {
|
|
362
|
-
console.log("Daemon is not running.");
|
|
370
|
+
const { isDaemonRunning, spawnDaemonProcess } = await import("./daemon-4DVXPT4O.js");
|
|
371
|
+
if (isDaemonRunning()) {
|
|
372
|
+
console.log("Daemon is already running.");
|
|
363
373
|
return;
|
|
364
374
|
}
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
|
|
375
|
+
const pid = spawnDaemonProcess();
|
|
376
|
+
if (pid) {
|
|
377
|
+
logger.info({ pid }, "Daemon detached in background");
|
|
378
|
+
console.log(`Daemon started in background (PID ${pid})`);
|
|
368
379
|
} else {
|
|
369
|
-
console.log(
|
|
380
|
+
console.log("Failed to start daemon.");
|
|
370
381
|
process.exit(1);
|
|
371
382
|
}
|
|
372
383
|
});
|
|
373
|
-
daemonCmd.command("
|
|
374
|
-
const {
|
|
384
|
+
daemonCmd.command("stop").description("Stop the daemon").action(async () => {
|
|
385
|
+
const { readPidFile, isProcessAlive, removePidFile } = await import("./daemon-4DVXPT4O.js");
|
|
386
|
+
const pid = readPidFile();
|
|
387
|
+
if (pid && isProcessAlive(pid)) {
|
|
388
|
+
process.kill(pid, "SIGTERM");
|
|
389
|
+
removePidFile();
|
|
390
|
+
logger.info({ pid }, "Daemon stopped via PID file");
|
|
391
|
+
console.log(`Daemon stopped (PID ${pid}).`);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const { getServiceStatus, stopService } = await import("./service-AP5GEITC.js");
|
|
375
395
|
const status = getServiceStatus();
|
|
376
396
|
if (status === "running") {
|
|
377
397
|
const result = stopService();
|
|
378
|
-
if (
|
|
398
|
+
if (result.success) {
|
|
399
|
+
logger.info("Daemon stopped via system service");
|
|
400
|
+
console.log("Daemon stopped.");
|
|
401
|
+
} else {
|
|
402
|
+
logger.error({ error: result.error }, "Failed to stop daemon");
|
|
379
403
|
console.log(`Failed to stop daemon: ${result.error}`);
|
|
380
404
|
process.exit(1);
|
|
381
405
|
}
|
|
382
|
-
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (pid) removePidFile();
|
|
409
|
+
console.log("Daemon is not running.");
|
|
410
|
+
});
|
|
411
|
+
daemonCmd.command("restart").description("Restart the daemon").action(async () => {
|
|
412
|
+
const { readPidFile, isProcessAlive, removePidFile } = await import("./daemon-4DVXPT4O.js");
|
|
413
|
+
const pid = readPidFile();
|
|
414
|
+
if (pid && isProcessAlive(pid)) {
|
|
415
|
+
process.kill(pid, "SIGTERM");
|
|
416
|
+
removePidFile();
|
|
417
|
+
console.log(`Stopped daemon (PID ${pid}).`);
|
|
418
|
+
} else {
|
|
419
|
+
const { getServiceStatus, stopService } = await import("./service-AP5GEITC.js");
|
|
420
|
+
if (getServiceStatus() === "running") {
|
|
421
|
+
const result = stopService();
|
|
422
|
+
if (!result.success) {
|
|
423
|
+
console.log(`Failed to stop daemon: ${result.error}`);
|
|
424
|
+
process.exit(1);
|
|
425
|
+
}
|
|
426
|
+
console.log("Stopped system service daemon.");
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const { spawnDaemonProcess } = await import("./daemon-4DVXPT4O.js");
|
|
430
|
+
const newPid = spawnDaemonProcess();
|
|
431
|
+
if (newPid) {
|
|
432
|
+
console.log(`Daemon restarted in background (PID ${newPid})`);
|
|
433
|
+
} else {
|
|
434
|
+
console.log("Failed to restart daemon.");
|
|
435
|
+
process.exit(1);
|
|
383
436
|
}
|
|
384
|
-
const { startDaemon } = await import("./daemon-WOR4GE5C.js");
|
|
385
|
-
await startDaemon();
|
|
386
437
|
});
|
|
387
438
|
daemonCmd.command("install").description("Install system service").action(async () => {
|
|
388
|
-
const { installService } = await import("./service-
|
|
439
|
+
const { installService } = await import("./service-AP5GEITC.js");
|
|
389
440
|
const result = installService();
|
|
390
441
|
if (result.success) {
|
|
442
|
+
logger.info("System service installed");
|
|
391
443
|
console.log("Service installed successfully.");
|
|
392
444
|
} else {
|
|
445
|
+
logger.error({ error: result.error }, "Service install failed");
|
|
393
446
|
console.log(`Install failed: ${result.error}`);
|
|
394
447
|
process.exit(1);
|
|
395
448
|
}
|
|
396
449
|
});
|
|
397
450
|
daemonCmd.command("uninstall").description("Remove system service").action(async () => {
|
|
398
|
-
const { uninstallService } = await import("./service-
|
|
451
|
+
const { uninstallService } = await import("./service-AP5GEITC.js");
|
|
399
452
|
const result = uninstallService();
|
|
400
453
|
if (result.success) {
|
|
454
|
+
logger.info("System service uninstalled");
|
|
401
455
|
console.log("Service uninstalled successfully.");
|
|
402
456
|
} else {
|
|
457
|
+
logger.error({ error: result.error }, "Service uninstall failed");
|
|
403
458
|
console.log(`Uninstall failed: ${result.error}`);
|
|
404
459
|
process.exit(1);
|
|
405
460
|
}
|
|
406
461
|
});
|
|
407
462
|
daemonCmd.command("status").description("View daemon status").action(async () => {
|
|
408
|
-
const {
|
|
463
|
+
const { readPidFile, isProcessAlive } = await import("./daemon-4DVXPT4O.js");
|
|
464
|
+
const pid = readPidFile();
|
|
465
|
+
if (pid && isProcessAlive(pid)) {
|
|
466
|
+
console.log(`Daemon status: running (PID ${pid})`);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
const { getServiceStatus } = await import("./service-AP5GEITC.js");
|
|
409
470
|
const status = getServiceStatus();
|
|
410
|
-
|
|
471
|
+
if (status === "running") {
|
|
472
|
+
console.log(`Daemon status: running (system service)`);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
console.log("Daemon status: stopped");
|
|
411
476
|
});
|
|
412
477
|
daemonCmd.command("logs").description("View daemon logs").action(async () => {
|
|
413
478
|
const { join } = await import("path");
|
|
414
|
-
const { cueclawHome: cueclawHome2 } = await import("./config-
|
|
479
|
+
const { cueclawHome: cueclawHome2 } = await import("./config-D5A5TNLZ.js");
|
|
415
480
|
const logPath = join(cueclawHome2(), "logs", "daemon.log");
|
|
416
481
|
const { existsSync } = await import("fs");
|
|
417
482
|
if (!existsSync(logPath)) {
|
|
@@ -422,42 +487,6 @@ daemonCmd.command("logs").description("View daemon logs").action(async () => {
|
|
|
422
487
|
spawn("tail", ["-f", logPath], { stdio: "inherit" });
|
|
423
488
|
});
|
|
424
489
|
var botCmd = program.command("bot").description("Manage bot channels");
|
|
425
|
-
botCmd.command("start").description("Start all configured bot channels").action(async () => {
|
|
426
|
-
try {
|
|
427
|
-
const config = loadConfig();
|
|
428
|
-
const db = initDb();
|
|
429
|
-
const { MessageRouter } = await import("./router-ID6RN5AT.js");
|
|
430
|
-
const router = new MessageRouter(db, config, process.cwd());
|
|
431
|
-
if (config.whatsapp?.enabled) {
|
|
432
|
-
const { WhatsAppChannel } = await import("./whatsapp-HFMOFSFI.js");
|
|
433
|
-
const wa = new WhatsAppChannel(
|
|
434
|
-
config.whatsapp.auth_dir ?? `${process.env["HOME"]}/.cueclaw/auth/whatsapp`,
|
|
435
|
-
config.whatsapp.allowed_jids ?? [],
|
|
436
|
-
(jid, msg) => router.handleInbound("whatsapp", jid, msg)
|
|
437
|
-
);
|
|
438
|
-
router.registerChannel(wa);
|
|
439
|
-
await wa.connect();
|
|
440
|
-
logger.info("WhatsApp channel started");
|
|
441
|
-
}
|
|
442
|
-
if (config.telegram?.enabled) {
|
|
443
|
-
const { TelegramChannel } = await import("./telegram-EFPHL4HC.js");
|
|
444
|
-
const tg = new TelegramChannel(
|
|
445
|
-
config.telegram.token,
|
|
446
|
-
config.telegram.allowed_users ?? [],
|
|
447
|
-
(jid, msg) => router.handleInbound("telegram", jid, msg)
|
|
448
|
-
);
|
|
449
|
-
router.registerChannel(tg);
|
|
450
|
-
await tg.connect();
|
|
451
|
-
tg.onCallback((wfId, action, chatId) => router.handleCallbackAction("telegram", chatId, wfId, action));
|
|
452
|
-
logger.info("Telegram channel started");
|
|
453
|
-
}
|
|
454
|
-
router.start();
|
|
455
|
-
console.log("Bot channels started. Press Ctrl+C to stop.");
|
|
456
|
-
} catch (err) {
|
|
457
|
-
logger.error({ err }, "Failed to start bot channels");
|
|
458
|
-
process.exit(1);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
490
|
botCmd.command("status").description("View channel connection status").action(() => {
|
|
462
491
|
const config = loadConfig();
|
|
463
492
|
console.log(`WhatsApp: ${config.whatsapp?.enabled ? "enabled" : "disabled"}`);
|
|
@@ -466,7 +495,7 @@ botCmd.command("status").description("View channel connection status").action(()
|
|
|
466
495
|
program.command("setup").description("First-run setup: validate Docker, build container, smoke test").action(async () => {
|
|
467
496
|
try {
|
|
468
497
|
const config = loadConfig();
|
|
469
|
-
const { runSetup } = await import("./setup-
|
|
498
|
+
const { runSetup } = await import("./setup-U2YKLOK6.js");
|
|
470
499
|
await runSetup(config, process.cwd());
|
|
471
500
|
} catch (err) {
|
|
472
501
|
logger.error({ err }, "Setup failed");
|
|
@@ -475,12 +504,12 @@ program.command("setup").description("First-run setup: validate Docker, build co
|
|
|
475
504
|
});
|
|
476
505
|
program.command("tui").description("Start interactive TUI").option("--skip-onboarding", "Skip first-run onboarding wizard").action(async (opts) => {
|
|
477
506
|
try {
|
|
478
|
-
const { enableTuiLogging } = await import("./logger-
|
|
507
|
+
const { enableTuiLogging } = await import("./logger-HKMIMPCE.js");
|
|
479
508
|
enableTuiLogging();
|
|
480
509
|
const React = await import("react");
|
|
481
510
|
const { render } = await import("ink");
|
|
482
|
-
const { App } = await import("./app-
|
|
483
|
-
render(React.createElement(App, { cwd: process.cwd(), skipOnboarding: opts.skipOnboarding }));
|
|
511
|
+
const { App } = await import("./app-JK3HBFKZ.js");
|
|
512
|
+
render(React.createElement(App, { cwd: process.cwd(), skipOnboarding: opts.skipOnboarding }), { exitOnCtrlC: false });
|
|
484
513
|
} catch (err) {
|
|
485
514
|
logger.error({ err }, "Failed to start TUI");
|
|
486
515
|
process.exit(1);
|
|
@@ -489,12 +518,12 @@ program.command("tui").description("Start interactive TUI").option("--skip-onboa
|
|
|
489
518
|
program.option("--skip-onboarding", "Skip first-run onboarding wizard").action(async (_opts, cmd) => {
|
|
490
519
|
const skipOnboarding = cmd.opts().skipOnboarding;
|
|
491
520
|
try {
|
|
492
|
-
const { enableTuiLogging } = await import("./logger-
|
|
521
|
+
const { enableTuiLogging } = await import("./logger-HKMIMPCE.js");
|
|
493
522
|
enableTuiLogging();
|
|
494
523
|
const React = await import("react");
|
|
495
524
|
const { render } = await import("ink");
|
|
496
|
-
const { App } = await import("./app-
|
|
497
|
-
render(React.createElement(App, { cwd: process.cwd(), skipOnboarding }));
|
|
525
|
+
const { App } = await import("./app-JK3HBFKZ.js");
|
|
526
|
+
render(React.createElement(App, { cwd: process.cwd(), skipOnboarding }), { exitOnCtrlC: false });
|
|
498
527
|
} catch (err) {
|
|
499
528
|
logger.error({ err }, "Failed to start TUI");
|
|
500
529
|
process.exit(1);
|
|
@@ -503,4 +532,9 @@ program.option("--skip-onboarding", "Skip first-run onboarding wizard").action(a
|
|
|
503
532
|
loadSecrets();
|
|
504
533
|
ensureCueclawHome();
|
|
505
534
|
createDefaultConfig();
|
|
535
|
+
try {
|
|
536
|
+
const config = loadConfig();
|
|
537
|
+
initLogger({ level: config.logging?.level, dir: config.logging?.dir });
|
|
538
|
+
} catch {
|
|
539
|
+
}
|
|
506
540
|
program.parse();
|
|
@@ -2,17 +2,20 @@ import {
|
|
|
2
2
|
createDefaultConfig,
|
|
3
3
|
cueclawHome,
|
|
4
4
|
ensureCueclawHome,
|
|
5
|
+
getDefaultImage,
|
|
5
6
|
loadConfig,
|
|
6
7
|
loadExistingConfig,
|
|
7
8
|
needsOnboarding,
|
|
8
9
|
validateConfig,
|
|
9
10
|
writeConfig
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-25KI643G.js";
|
|
11
12
|
import "./chunk-BVQG3WYO.js";
|
|
13
|
+
import "./chunk-ZCK3IFLC.js";
|
|
12
14
|
export {
|
|
13
15
|
createDefaultConfig,
|
|
14
16
|
cueclawHome,
|
|
15
17
|
ensureCueclawHome,
|
|
18
|
+
getDefaultImage,
|
|
16
19
|
loadConfig,
|
|
17
20
|
loadExistingConfig,
|
|
18
21
|
needsOnboarding,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
daemonPidPath,
|
|
3
|
+
isDaemonRunning,
|
|
4
|
+
isProcessAlive,
|
|
5
|
+
readPidFile,
|
|
6
|
+
removePidFile,
|
|
7
|
+
spawnDaemonProcess,
|
|
8
|
+
startDaemon,
|
|
9
|
+
writePidFile
|
|
10
|
+
} from "./chunk-HDUFGPCI.js";
|
|
11
|
+
import "./chunk-ZOFGQYXX.js";
|
|
12
|
+
import "./chunk-DVQFSFIZ.js";
|
|
13
|
+
import "./chunk-X3WNTN5V.js";
|
|
14
|
+
import "./chunk-JJUF2AJ5.js";
|
|
15
|
+
import "./chunk-25KI643G.js";
|
|
16
|
+
import "./chunk-BVQG3WYO.js";
|
|
17
|
+
import "./chunk-ZCK3IFLC.js";
|
|
18
|
+
import "./chunk-KBLMQZ3P.js";
|
|
19
|
+
export {
|
|
20
|
+
daemonPidPath,
|
|
21
|
+
isDaemonRunning,
|
|
22
|
+
isProcessAlive,
|
|
23
|
+
readPidFile,
|
|
24
|
+
removePidFile,
|
|
25
|
+
spawnDaemonProcess,
|
|
26
|
+
startDaemon,
|
|
27
|
+
writePidFile
|
|
28
|
+
};
|
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
executeWorkflow,
|
|
3
3
|
resolveInputs,
|
|
4
4
|
resolveValue
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-X3WNTN5V.js";
|
|
6
|
+
import "./chunk-JJUF2AJ5.js";
|
|
7
|
+
import "./chunk-25KI643G.js";
|
|
8
8
|
import "./chunk-BVQG3WYO.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-ZCK3IFLC.js";
|
|
10
|
+
import "./chunk-KBLMQZ3P.js";
|
|
10
11
|
export {
|
|
11
12
|
executeWorkflow,
|
|
12
13
|
resolveInputs,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChildLogger,
|
|
3
|
+
createExecutionLogger,
|
|
4
|
+
enableTuiLogging,
|
|
5
|
+
initLogger,
|
|
6
|
+
logger,
|
|
7
|
+
onLogLine,
|
|
8
|
+
resetLogger
|
|
9
|
+
} from "./chunk-KBLMQZ3P.js";
|
|
10
|
+
export {
|
|
11
|
+
createChildLogger,
|
|
12
|
+
createExecutionLogger,
|
|
13
|
+
enableTuiLogging,
|
|
14
|
+
initLogger,
|
|
15
|
+
logger,
|
|
16
|
+
onLogLine,
|
|
17
|
+
resetLogger
|
|
18
|
+
};
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
plannerTool,
|
|
10
10
|
rejectPlan,
|
|
11
11
|
setSecretTool
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZOFGQYXX.js";
|
|
13
13
|
import "./chunk-DVQFSFIZ.js";
|
|
14
|
-
import "./chunk-ZCK3IFLC.js";
|
|
15
14
|
import "./chunk-BVQG3WYO.js";
|
|
16
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-ZCK3IFLC.js";
|
|
16
|
+
import "./chunk-KBLMQZ3P.js";
|
|
17
17
|
export {
|
|
18
18
|
PlannerOutputSchema,
|
|
19
19
|
askQuestionTool,
|
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
installService,
|
|
4
4
|
stopService,
|
|
5
5
|
uninstallService
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-CXBDJQJJ.js";
|
|
7
|
+
import "./chunk-25KI643G.js";
|
|
8
8
|
import "./chunk-BVQG3WYO.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-ZCK3IFLC.js";
|
|
10
|
+
import "./chunk-KBLMQZ3P.js";
|
|
10
11
|
export {
|
|
11
12
|
getServiceStatus,
|
|
12
13
|
installService,
|
|
@@ -3,9 +3,14 @@ import {
|
|
|
3
3
|
validateAuth
|
|
4
4
|
} from "./chunk-KRNAXOQ4.js";
|
|
5
5
|
import "./chunk-DVQFSFIZ.js";
|
|
6
|
+
import {
|
|
7
|
+
getDefaultImage
|
|
8
|
+
} from "./chunk-25KI643G.js";
|
|
9
|
+
import "./chunk-BVQG3WYO.js";
|
|
10
|
+
import "./chunk-ZCK3IFLC.js";
|
|
6
11
|
import {
|
|
7
12
|
logger
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KBLMQZ3P.js";
|
|
9
14
|
|
|
10
15
|
// src/setup-container.ts
|
|
11
16
|
import { execFileSync } from "child_process";
|
|
@@ -92,7 +97,7 @@ async function runSetup(config, projectRoot) {
|
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
94
99
|
console.log(" API key: valid");
|
|
95
|
-
const imageName = config.container?.image ??
|
|
100
|
+
const imageName = config.container?.image ?? getDefaultImage();
|
|
96
101
|
if (!checkContainerImage(imageName)) {
|
|
97
102
|
console.log("\nBuilding container image...");
|
|
98
103
|
const build = buildContainer(projectRoot);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KBLMQZ3P.js";
|
|
4
4
|
|
|
5
5
|
// src/channels/telegram.ts
|
|
6
6
|
import { Bot, InlineKeyboard } from "grammy";
|
|
@@ -21,6 +21,23 @@ var TelegramChannel = class {
|
|
|
21
21
|
this.callbackHandler = handler;
|
|
22
22
|
}
|
|
23
23
|
async connect() {
|
|
24
|
+
this.bot.command("start", async (ctx) => {
|
|
25
|
+
const jid = String(ctx.chat.id);
|
|
26
|
+
if (!this.isAllowed(jid)) return;
|
|
27
|
+
await ctx.reply(
|
|
28
|
+
[
|
|
29
|
+
"\u{1F44B} Hi! I'm CueClaw \u2014 your workflow automation assistant.",
|
|
30
|
+
"",
|
|
31
|
+
"Tell me what you want to automate in plain language, and I'll turn it into a structured workflow with steps, triggers, and scheduling.",
|
|
32
|
+
"",
|
|
33
|
+
"For example:",
|
|
34
|
+
'\u2022 "Every morning at 9am, check Hacker News for top AI posts and summarize them"',
|
|
35
|
+
'\u2022 "Monitor my GitHub repo for new issues and notify me"',
|
|
36
|
+
"",
|
|
37
|
+
"Just type your request and I'll help you set it up!"
|
|
38
|
+
].join("\n")
|
|
39
|
+
);
|
|
40
|
+
});
|
|
24
41
|
this.bot.on("message:text", (ctx) => {
|
|
25
42
|
const jid = String(ctx.chat.id);
|
|
26
43
|
if (!this.isAllowed(jid)) return;
|
|
@@ -52,9 +69,15 @@ var TelegramChannel = class {
|
|
|
52
69
|
}
|
|
53
70
|
async sendMessage(jid, text) {
|
|
54
71
|
const chunks = chunkMessage(text);
|
|
72
|
+
let lastMessageId = "";
|
|
55
73
|
for (const chunk of chunks) {
|
|
56
|
-
await this.bot.api.sendMessage(Number(jid), chunk);
|
|
74
|
+
const sent = await this.bot.api.sendMessage(Number(jid), chunk);
|
|
75
|
+
lastMessageId = String(sent.message_id);
|
|
57
76
|
}
|
|
77
|
+
return lastMessageId;
|
|
78
|
+
}
|
|
79
|
+
async editMessage(jid, messageId, text) {
|
|
80
|
+
await this.bot.api.editMessageText(Number(jid), Number(messageId), text);
|
|
58
81
|
}
|
|
59
82
|
async sendConfirmation(jid, workflow) {
|
|
60
83
|
const steps = workflow.steps.map((s, i) => `${i + 1}. ${s.description}`).join("\n");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KBLMQZ3P.js";
|
|
4
4
|
|
|
5
5
|
// src/channels/whatsapp.ts
|
|
6
6
|
var WhatsAppChannel = class {
|
|
@@ -57,7 +57,15 @@ var WhatsAppChannel = class {
|
|
|
57
57
|
}
|
|
58
58
|
async sendMessage(jid, text) {
|
|
59
59
|
if (!this.sock) throw new Error("WhatsApp not connected");
|
|
60
|
-
await this.sock.sendMessage(jid, { text });
|
|
60
|
+
const sent = await this.sock.sendMessage(jid, { text });
|
|
61
|
+
return sent?.key?.id ?? "";
|
|
62
|
+
}
|
|
63
|
+
async editMessage(jid, messageId, text) {
|
|
64
|
+
if (!this.sock) throw new Error("WhatsApp not connected");
|
|
65
|
+
await this.sock.sendMessage(jid, {
|
|
66
|
+
text,
|
|
67
|
+
edit: { remoteJid: jid, id: messageId, fromMe: true }
|
|
68
|
+
});
|
|
61
69
|
}
|
|
62
70
|
async sendConfirmation(jid, workflow) {
|
|
63
71
|
const steps = workflow.steps.map((s, i) => `${i + 1}. ${s.description}`).join("\n");
|