From f33eaac466f00be4f9df78c01170eaa620188a9c Mon Sep 17 00:00:00 2001 From: pallaoro Date: Wed, 20 May 2026 10:30:55 +0200 Subject: [PATCH] Fix flow_run/flow_read/flow_publish ESM require error, bump to 1.2.2 src/plugin/index.ts used inline require("path") / require("fs") inside the file-path helpers (resolveFlowFile, versionsDir, listVersions, readVersion), introduced when flow_list/flow_read/flow_publish landed. The package is published as "type": "module" and tsc with NodeNext emits the require() calls verbatim into ESM output, so any tool path that hits a file: arg fails at runtime with "require is not defined". Inline flows (no file:) sidestep resolveFlowFile and worked, masking the bug. Replace the lazy CJS requires with top-level "node:fs" / "node:path" imports so the helpers work under ESM. --- openclaw.plugin.json | 2 +- package.json | 2 +- src/plugin/index.ts | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openclaw.plugin.json b/openclaw.plugin.json index 94151fa..f9aed58 100644 --- a/openclaw.plugin.json +++ b/openclaw.plugin.json @@ -2,7 +2,7 @@ "id": "clawflow", "name": "ClawFlow", "description": "The n8n for agents. Declarative, AI-native workflow engine — LLM-writable, Cloudflare-portable.", - "version": "1.2.1", + "version": "1.2.2", "skills": ["./skills/flow"], "contracts": { "tools": [ diff --git a/package.json b/package.json index b3a6727..b5051d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@clawnify/clawflow", - "version": "1.2.1", + "version": "1.2.2", "description": "The n8n for agents. A declarative, AI-native workflow format that agents can read, write, and run.", "type": "module", "main": "./dist/index.js", diff --git a/src/plugin/index.ts b/src/plugin/index.ts index e057eba..5e14a69 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -1,3 +1,6 @@ +import * as fs from "node:fs"; +import * as path from "node:path"; + import { FlowRunner, sendEvent } from "../core/runner.js"; import { startFlowServer } from "../core/serve.js"; @@ -156,7 +159,6 @@ function register(api: PluginApi) { /** Resolve a file param to an absolute path using workspace conventions. */ function resolveFlowFile(file: string): string { - const path = require("path") as typeof import("path"); const base = workspace; if (file.startsWith("/")) return file; if (file.includes("/")) return path.join(base, file); @@ -166,14 +168,12 @@ function register(api: PluginApi) { /** Get the versions directory for a flow name. */ function versionsDir(flowName: string): string { - const path = require("path") as typeof import("path"); const base = workspace; return path.join(base, ".clawflow", "versions", flowName); } /** List all published version numbers for a flow, sorted ascending. */ function listVersions(flowName: string): number[] { - const fs = require("fs") as typeof import("fs"); const dir = versionsDir(flowName); if (!fs.existsSync(dir)) return []; return fs.readdirSync(dir) @@ -184,8 +184,6 @@ function register(api: PluginApi) { /** Read a specific published version. Returns null if not found. */ function readVersion(flowName: string, version: number): FlowDefinition | null { - const fs = require("fs") as typeof import("fs"); - const path = require("path") as typeof import("path"); const file = path.join(versionsDir(flowName), `${version}.json`); if (!fs.existsSync(file)) return null; return JSON.parse(fs.readFileSync(file, "utf-8")) as FlowDefinition;