@joshualelon/clawdbot-skill-flow 2.3.3 → 2.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joshualelon/clawdbot-skill-flow",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "type": "module",
5
5
  "description": "Multi-step workflow orchestration plugin for Clawdbot",
6
6
  "keywords": [
@@ -96,14 +96,30 @@ async function executeStepActions(
96
96
  );
97
97
 
98
98
  // Inject result into session
99
- if (result && typeof result === "object" && varName in result) {
100
- const value = (result as Record<string, unknown>)[varName];
101
- if (typeof value === "string" || typeof value === "number") {
99
+ if (result !== null && result !== undefined) {
100
+ if (typeof result === "object") {
101
+ // If result is an object, inject all its fields as separate variables
102
+ const resultObj = result as Record<string, unknown>;
103
+ for (const [key, value] of Object.entries(resultObj)) {
104
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
105
+ modifiedSession = {
106
+ ...modifiedSession,
107
+ variables: {
108
+ ...modifiedSession.variables,
109
+ [key]: value,
110
+ },
111
+ };
112
+ }
113
+ }
114
+ // Update context for next actions
115
+ context.variables = modifiedSession.variables;
116
+ } else if (typeof result === "string" || typeof result === "number" || typeof result === "boolean") {
117
+ // If result is a primitive, inject it under varName
102
118
  modifiedSession = {
103
119
  ...modifiedSession,
104
120
  variables: {
105
121
  ...modifiedSession.variables,
106
- [varName]: value,
122
+ [varName]: result,
107
123
  },
108
124
  };
109
125
  // Update context for next actions
@@ -192,18 +208,29 @@ async function executeStepActions(
192
208
  modifiedSession,
193
209
  enhancedApi
194
210
  );
195
- if (result && typeof result === "object") {
196
- if (varName in result) {
197
- const value = result[varName];
198
- if (typeof value === "string" || typeof value === "number") {
199
- modifiedSession = {
200
- ...modifiedSession,
201
- variables: {
202
- ...modifiedSession.variables,
203
- [varName]: value,
204
- },
205
- };
211
+ if (result !== null && result !== undefined) {
212
+ if (typeof result === "object") {
213
+ // If result is an object, inject all its fields as separate variables
214
+ for (const [key, value] of Object.entries(result)) {
215
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
216
+ modifiedSession = {
217
+ ...modifiedSession,
218
+ variables: {
219
+ ...modifiedSession.variables,
220
+ [key]: value,
221
+ },
222
+ };
223
+ }
206
224
  }
225
+ } else if (typeof result === "string" || typeof result === "number" || typeof result === "boolean") {
226
+ // If result is a primitive, inject it under varName
227
+ modifiedSession = {
228
+ ...modifiedSession,
229
+ variables: {
230
+ ...modifiedSession.variables,
231
+ [varName]: result,
232
+ },
233
+ };
207
234
  }
208
235
  }
209
236
  }
@@ -339,7 +366,7 @@ export async function processStep(
339
366
  ): Promise<{
340
367
  reply: ReplyPayload;
341
368
  complete: boolean;
342
- updatedVariables: Record<string, string | number>;
369
+ updatedVariables: Record<string, string | number | boolean>;
343
370
  }> {
344
371
  // Load action registry for declarative actions
345
372
  let actionRegistry: ActionRegistry | null = null;
@@ -446,7 +473,7 @@ export async function processStep(
446
473
  */
447
474
  function generateCompletionMessage(
448
475
  flow: FlowMetadata,
449
- variables: Record<string, string | number>
476
+ variables: Record<string, string | number | boolean>
450
477
  ): string {
451
478
  let message = `✅ Flow "${flow.name}" completed!\n\n`;
452
479
 
@@ -17,7 +17,7 @@ import { normalizeButton } from "../validation.js";
17
17
  */
18
18
  function interpolateVariables(
19
19
  text: string,
20
- variables: Record<string, string | number>
20
+ variables: Record<string, string | number | boolean>
21
21
  ): string {
22
22
  return text.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
23
23
  const value = variables[varName];
@@ -31,7 +31,7 @@ function interpolateVariables(
31
31
  function renderTelegram(
32
32
  flowName: string,
33
33
  step: FlowStep,
34
- variables: Record<string, string | number>
34
+ variables: Record<string, string | number | boolean>
35
35
  ): ReplyPayload {
36
36
  const message = interpolateVariables(step.message, variables);
37
37
 
@@ -83,7 +83,7 @@ function renderTelegram(
83
83
  */
84
84
  function renderFallback(
85
85
  step: FlowStep,
86
- variables: Record<string, string | number>
86
+ variables: Record<string, string | number | boolean>
87
87
  ): ReplyPayload {
88
88
  const message = interpolateVariables(step.message, variables);
89
89
 
@@ -30,7 +30,7 @@ import { createInterpolationContext, interpolateConfig } from "./interpolation.j
30
30
  */
31
31
  function evaluateCondition(
32
32
  condition: FlowStep["condition"],
33
- variables: Record<string, string | number>
33
+ variables: Record<string, string | number | boolean>
34
34
  ): boolean {
35
35
  if (!condition) {
36
36
  return false;
@@ -75,7 +75,7 @@ function evaluateCondition(
75
75
  function findNextStep(
76
76
  step: FlowStep,
77
77
  value: string | number,
78
- variables: Record<string, string | number>
78
+ variables: Record<string, string | number | boolean>
79
79
  ): string | undefined {
80
80
  // 1. Check button-specific next
81
81
  if (step.buttons && step.buttons.length > 0) {
package/src/types.ts CHANGED
@@ -106,14 +106,14 @@ export interface FlowSession {
106
106
  currentStepId: string;
107
107
  senderId: string;
108
108
  channel: string;
109
- variables: Record<string, string | number>;
109
+ variables: Record<string, string | number | boolean>;
110
110
  startedAt: number;
111
111
  lastActivityAt: number;
112
112
  }
113
113
 
114
114
  export interface TransitionResult {
115
115
  nextStepId?: string;
116
- variables: Record<string, string | number>;
116
+ variables: Record<string, string | number | boolean>;
117
117
  complete: boolean;
118
118
  error?: string;
119
119
  message?: string;