@joshualelon/clawdbot-skill-flow 0.3.1 → 0.5.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.
@@ -9,6 +9,7 @@ import { promisify } from "node:util";
9
9
  import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
10
10
  import type { FlowMetadata } from "../types.js";
11
11
  import { FlowMetadataSchema } from "../validation.js";
12
+ import { getPluginConfig } from "../config.js";
12
13
 
13
14
  const lock = promisify(lockfile.lock);
14
15
  const unlock = promisify(lockfile.unlock);
@@ -17,6 +18,12 @@ const unlock = promisify(lockfile.unlock);
17
18
  * Get the flows directory path
18
19
  */
19
20
  function getFlowsDir(api: ClawdbotPluginApi): string {
21
+ const config = getPluginConfig();
22
+ if (config.flowsDir) {
23
+ // Expand ~ to home directory
24
+ const expandedPath = config.flowsDir.replace(/^~/, process.env.HOME || "~");
25
+ return path.resolve(expandedPath);
26
+ }
20
27
  const stateDir = api.runtime.state.resolveStateDir();
21
28
  return path.join(stateDir, "flows");
22
29
  }
@@ -7,17 +7,31 @@ import path from "node:path";
7
7
  import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
8
8
  import type { FlowSession, FlowMetadata } from "../types.js";
9
9
  import type { SkillFlowConfig } from "../config.js";
10
+ import { getPluginConfig } from "../config.js";
10
11
  import {
11
12
  loadStorageBackend,
12
13
  resolveFlowPath,
13
14
  } from "../engine/hooks-loader.js";
14
15
 
16
+ /**
17
+ * Get the flows directory path (same logic as flow-store.ts)
18
+ */
19
+ function getFlowsDir(api: ClawdbotPluginApi): string {
20
+ const config = getPluginConfig();
21
+ if (config.flowsDir) {
22
+ const expandedPath = config.flowsDir.replace(/^~/, process.env.HOME || "~");
23
+ return path.resolve(expandedPath);
24
+ }
25
+ const stateDir = api.runtime.state.resolveStateDir();
26
+ return path.join(stateDir, "flows");
27
+ }
28
+
15
29
  /**
16
30
  * Get history file path for a flow
17
31
  */
18
32
  function getHistoryPath(api: ClawdbotPluginApi, flowName: string): string {
19
- const stateDir = api.runtime.state.resolveStateDir();
20
- return path.join(stateDir, "flows", flowName, "history.jsonl");
33
+ const flowsDir = getFlowsDir(api);
34
+ return path.join(flowsDir, flowName, "history.jsonl");
21
35
  }
22
36
 
23
37
  /**
package/src/types.ts CHANGED
@@ -43,6 +43,8 @@ export interface FlowMetadata {
43
43
  backend?: string; // Path to custom storage backend
44
44
  builtin?: boolean; // Also write to JSONL (default: true)
45
45
  };
46
+ // Allow extra fields (e.g., job config)
47
+ [key: string]: unknown;
46
48
  }
47
49
 
48
50
  export interface FlowSession {
package/src/validation.ts CHANGED
@@ -58,6 +58,7 @@ const StorageSchema = z
58
58
  .optional();
59
59
 
60
60
  // Complete flow metadata schema
61
+ // Use .passthrough() to allow extra fields (e.g., job config)
61
62
  export const FlowMetadataSchema = z.object({
62
63
  name: z.string(),
63
64
  description: z.string(),
@@ -67,7 +68,7 @@ export const FlowMetadataSchema = z.object({
67
68
  triggers: TriggerSchema,
68
69
  hooks: z.string().optional(),
69
70
  storage: StorageSchema,
70
- });
71
+ }).passthrough();
71
72
 
72
73
  /**
73
74
  * Normalize button input to Button object