@joshualelon/clawdbot-skill-flow 0.2.2 → 0.3.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/index.ts
CHANGED
|
@@ -29,9 +29,9 @@ const plugin = {
|
|
|
29
29
|
// Initialize session store with config
|
|
30
30
|
initSessionStore(config);
|
|
31
31
|
|
|
32
|
-
// Register commands
|
|
32
|
+
// Register commands (use underscores per Telegram requirements)
|
|
33
33
|
api.registerCommand({
|
|
34
|
-
name: "
|
|
34
|
+
name: "flow_start",
|
|
35
35
|
description: "Start a workflow",
|
|
36
36
|
acceptsArgs: true,
|
|
37
37
|
requireAuth: true,
|
|
@@ -39,7 +39,7 @@ const plugin = {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
api.registerCommand({
|
|
42
|
-
name: "
|
|
42
|
+
name: "flow_step",
|
|
43
43
|
description: "Handle flow step transition (internal)",
|
|
44
44
|
acceptsArgs: true,
|
|
45
45
|
requireAuth: true,
|
|
@@ -47,7 +47,7 @@ const plugin = {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
api.registerCommand({
|
|
50
|
-
name: "
|
|
50
|
+
name: "flow_create",
|
|
51
51
|
description: "Create a new flow from JSON",
|
|
52
52
|
acceptsArgs: true,
|
|
53
53
|
requireAuth: true,
|
|
@@ -55,7 +55,7 @@ const plugin = {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
api.registerCommand({
|
|
58
|
-
name: "
|
|
58
|
+
name: "flow_list",
|
|
59
59
|
description: "List all available flows",
|
|
60
60
|
acceptsArgs: false,
|
|
61
61
|
requireAuth: true,
|
|
@@ -63,7 +63,7 @@ const plugin = {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
api.registerCommand({
|
|
66
|
-
name: "
|
|
66
|
+
name: "flow_delete",
|
|
67
67
|
description: "Delete a flow",
|
|
68
68
|
acceptsArgs: true,
|
|
69
69
|
requireAuth: true,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /flow_create command - Create a new flow
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
@@ -13,7 +13,7 @@ export function createFlowCreateCommand(api: ClawdbotPluginApi) {
|
|
|
13
13
|
|
|
14
14
|
if (!input) {
|
|
15
15
|
return {
|
|
16
|
-
text: "Usage: /
|
|
16
|
+
text: "Usage: /flow_create import <json>\n\nExample:\n/flow_create import {...}",
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ export function createFlowCreateCommand(api: ClawdbotPluginApi) {
|
|
|
22
22
|
|
|
23
23
|
if (!importMatch) {
|
|
24
24
|
return {
|
|
25
|
-
text: "Currently only 'import' mode is supported.\n\nUsage: /
|
|
25
|
+
text: "Currently only 'import' mode is supported.\n\nUsage: /flow_create import <json>",
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -46,7 +46,7 @@ export function createFlowCreateCommand(api: ClawdbotPluginApi) {
|
|
|
46
46
|
api.logger.info(`Created flow "${flow.name}"`);
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
|
-
text: `✅ Flow "${flow.name}" created successfully!\n\nStart it with: /
|
|
49
|
+
text: `✅ Flow "${flow.name}" created successfully!\n\nStart it with: /flow_start ${flow.name}`,
|
|
50
50
|
};
|
|
51
51
|
} catch (error) {
|
|
52
52
|
if (error instanceof SyntaxError) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /flow_delete command - Delete a flow
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
@@ -11,7 +11,7 @@ export function createFlowDeleteCommand(api: ClawdbotPluginApi) {
|
|
|
11
11
|
|
|
12
12
|
if (!flowName) {
|
|
13
13
|
return {
|
|
14
|
-
text: "Usage: /
|
|
14
|
+
text: "Usage: /flow_delete <flow-name>\n\nExample: /flow_delete pushups",
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ export function createFlowDeleteCommand(api: ClawdbotPluginApi) {
|
|
|
20
20
|
|
|
21
21
|
if (!flow) {
|
|
22
22
|
return {
|
|
23
|
-
text: `Flow "${flowName}" not found.\n\nUse /
|
|
23
|
+
text: `Flow "${flowName}" not found.\n\nUse /flow_list to see available flows.`,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /flow_list command - List all available flows
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
@@ -11,7 +11,7 @@ export function createFlowListCommand(api: ClawdbotPluginApi) {
|
|
|
11
11
|
|
|
12
12
|
if (flows.length === 0) {
|
|
13
13
|
return {
|
|
14
|
-
text: "No flows found.\n\nCreate one with: /
|
|
14
|
+
text: "No flows found.\n\nCreate one with: /flow_create import {...}",
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -25,7 +25,7 @@ export function createFlowListCommand(api: ClawdbotPluginApi) {
|
|
|
25
25
|
message += ` 🕒 Cron: ${flow.triggers.cron}\n`;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
message += ` Start: /
|
|
28
|
+
message += ` Start: /flow_start ${flow.name}\n\n`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return { text: message };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /flow_start command - Start a flow
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
6
|
-
import { loadFlow } from "../state/flow-store.js";
|
|
6
|
+
import { loadFlow, listFlows } from "../state/flow-store.js";
|
|
7
7
|
import { createSession, getSessionKey } from "../state/session-store.js";
|
|
8
8
|
import { startFlow } from "../engine/executor.js";
|
|
9
9
|
|
|
@@ -15,10 +15,36 @@ export function createFlowStartCommand(api: ClawdbotPluginApi) {
|
|
|
15
15
|
}) => {
|
|
16
16
|
const flowName = args.args?.trim();
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// Show flow selection buttons when no flow name provided (Telegram)
|
|
19
19
|
if (!flowName) {
|
|
20
|
+
const flows = await listFlows(api);
|
|
21
|
+
|
|
22
|
+
if (flows.length === 0) {
|
|
23
|
+
return {
|
|
24
|
+
text: "No flows available.\n\nCreate one with /flow_create",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Show buttons on Telegram, text list on other channels
|
|
29
|
+
if (args.channel === "telegram") {
|
|
30
|
+
const buttons = flows.map((flow) => [
|
|
31
|
+
{
|
|
32
|
+
text: `${flow.name}${flow.description ? ` - ${flow.description}` : ""}`,
|
|
33
|
+
callback_data: `/flow_start ${flow.name}`,
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
text: "Choose a flow to start:",
|
|
39
|
+
channelData: {
|
|
40
|
+
telegram: { buttons },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Fallback for non-Telegram channels
|
|
20
46
|
return {
|
|
21
|
-
text: "Usage: /
|
|
47
|
+
text: "Usage: /flow_start <flow-name>\n\nExample: /flow_start pushups\n\nUse /flow_list to see available flows.",
|
|
22
48
|
};
|
|
23
49
|
}
|
|
24
50
|
|
|
@@ -27,7 +53,7 @@ export function createFlowStartCommand(api: ClawdbotPluginApi) {
|
|
|
27
53
|
|
|
28
54
|
if (!flow) {
|
|
29
55
|
return {
|
|
30
|
-
text: `Flow "${flowName}" not found.\n\nUse /
|
|
56
|
+
text: `Flow "${flowName}" not found.\n\nUse /flow_list to see available flows.`,
|
|
31
57
|
};
|
|
32
58
|
}
|
|
33
59
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /
|
|
2
|
+
* /flow_step command - Handle flow step transitions (called via Telegram callbacks)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
@@ -92,7 +92,7 @@ export function createFlowStepCommand(api: ClawdbotPluginApi) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
return {
|
|
95
|
-
text: `Session expired or not found.\n\nUse /
|
|
95
|
+
text: `Session expired or not found.\n\nUse /flow_start ${flowName} to restart the flow.`,
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
|
package/src/engine/renderer.ts
CHANGED
|
@@ -55,7 +55,7 @@ function renderTelegram(
|
|
|
55
55
|
for (let i = 0; i < buttons.length; i += 2) {
|
|
56
56
|
const row = buttons.slice(i, i + 2).map((btn) => ({
|
|
57
57
|
text: btn.text,
|
|
58
|
-
callback_data: `/
|
|
58
|
+
callback_data: `/flow_step ${flowName} ${step.id}:${btn.value}`,
|
|
59
59
|
}));
|
|
60
60
|
keyboard.push(row);
|
|
61
61
|
}
|
|
@@ -64,7 +64,7 @@ function renderTelegram(
|
|
|
64
64
|
keyboard = buttons.map((btn) => [
|
|
65
65
|
{
|
|
66
66
|
text: btn.text,
|
|
67
|
-
callback_data: `/
|
|
67
|
+
callback_data: `/flow_step ${flowName} ${step.id}:${btn.value}`,
|
|
68
68
|
},
|
|
69
69
|
]);
|
|
70
70
|
}
|