@fieldwangai/agentflow 0.1.164 → 0.1.166

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.
@@ -1,4 +1,4 @@
1
- // Generated by scripts/build-agentflow-cli-skill-runtime.mjs for AgentFlow 0.1.162.
1
+ // Generated by scripts/build-agentflow-cli-skill-runtime.mjs for AgentFlow 0.1.166.
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1841,8 +1841,8 @@ var require_cli_table3 = __commonJS({
1841
1841
  });
1842
1842
 
1843
1843
  // bin/lib/workspace-flow-store.mjs
1844
- import fs7 from "fs";
1845
- import path8 from "path";
1844
+ import fs8 from "fs";
1845
+ import path9 from "path";
1846
1846
 
1847
1847
  // bin/lib/workspace-state.mjs
1848
1848
  var WORKSPACE_STATE_FILENAME = "workspace.state.json";
@@ -2033,8 +2033,8 @@ function isEmptyWorkspaceState(state) {
2033
2033
  }
2034
2034
 
2035
2035
  // bin/lib/flow-dsl/defs.mjs
2036
- import fs5 from "fs";
2037
- import path6 from "path";
2036
+ import fs6 from "fs";
2037
+ import path7 from "path";
2038
2038
 
2039
2039
  // bin/lib/paths.mjs
2040
2040
  import fs from "fs";
@@ -4810,8 +4810,8 @@ initI18n();
4810
4810
  var import_cli_table3 = __toESM(require_cli_table3(), 1);
4811
4811
 
4812
4812
  // bin/lib/marketplace.mjs
4813
- import fs4 from "fs";
4814
- import path5 from "path";
4813
+ import fs5 from "fs";
4814
+ import path6 from "path";
4815
4815
 
4816
4816
  // bin/lib/node-package-manifest.mjs
4817
4817
  import fs2 from "fs";
@@ -11952,10 +11952,105 @@ function writeNodePackageFiles(targetDir, files) {
11952
11952
  return { ok: true, totalBytes: checked.totalBytes };
11953
11953
  }
11954
11954
 
11955
+ // bin/lib/marketplace-usage.mjs
11956
+ import fs4 from "fs";
11957
+ import path5 from "path";
11958
+ var USAGE_DIRNAME = "usage";
11959
+ function usageRoot(workspaceRoot) {
11960
+ return path5.join(path5.resolve(workspaceRoot), path5.dirname(MARKETPLACE_PACKAGES_DIR), USAGE_DIRNAME);
11961
+ }
11962
+ function safeText(value, max2 = 240) {
11963
+ return String(value || "").trim().slice(0, max2);
11964
+ }
11965
+ function normalizeMarketplaceVisibility(value, fallback = "public") {
11966
+ const normalized = safeText(value, 20).toLowerCase();
11967
+ if (normalized === "private") return "private";
11968
+ if (normalized === "public") return "public";
11969
+ return fallback === "private" ? "private" : "public";
11970
+ }
11971
+ function marketplaceResourceKey(kind, id, version2) {
11972
+ return `${safeText(kind, 32)}:${safeText(id)}@${safeText(version2, 80)}`;
11973
+ }
11974
+ function readUsageEvents(workspaceRoot) {
11975
+ const dir = usageRoot(workspaceRoot);
11976
+ if (!fs4.existsSync(dir)) return [];
11977
+ const events = [];
11978
+ try {
11979
+ const files = fs4.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && /^\d{4}-\d{2}-\d{2}\.jsonl$/.test(entry.name)).map((entry) => path5.join(dir, entry.name)).sort();
11980
+ for (const filePath of files) {
11981
+ for (const line of fs4.readFileSync(filePath, "utf-8").split(/\r?\n/)) {
11982
+ if (!line.trim()) continue;
11983
+ try {
11984
+ const parsed = JSON.parse(line);
11985
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) events.push(parsed);
11986
+ } catch {
11987
+ }
11988
+ }
11989
+ }
11990
+ } catch {
11991
+ return [];
11992
+ }
11993
+ return events;
11994
+ }
11995
+ function marketplaceUsageStats(workspaceRoot) {
11996
+ const byResource = /* @__PURE__ */ new Map();
11997
+ const seenEvents = /* @__PURE__ */ new Set();
11998
+ for (const event of readUsageEvents(workspaceRoot)) {
11999
+ const eventId = safeText(event.eventId, 500);
12000
+ if (!eventId || seenEvents.has(eventId)) continue;
12001
+ seenEvents.add(eventId);
12002
+ const key = marketplaceResourceKey(event.kind, event.id, event.resourceVersion);
12003
+ if (!byResource.has(key)) {
12004
+ byResource.set(key, {
12005
+ useCount: 0,
12006
+ installCount: 0,
12007
+ uniqueUserCount: 0,
12008
+ lastUsedAt: "",
12009
+ _users: /* @__PURE__ */ new Set(),
12010
+ _actors: /* @__PURE__ */ new Map()
12011
+ });
12012
+ }
12013
+ const stats = byResource.get(key);
12014
+ const actorUserId = safeText(event.actorUserId, 160);
12015
+ if (actorUserId) stats._users.add(actorUserId);
12016
+ if (actorUserId && !stats._actors.has(actorUserId)) stats._actors.set(actorUserId, { useCount: 0, installCount: 0 });
12017
+ if (event.action === "use") {
12018
+ stats.useCount += 1;
12019
+ if (actorUserId) stats._actors.get(actorUserId).useCount += 1;
12020
+ const atIso = new Date(Number(event.at) || 0).toISOString();
12021
+ if (!stats.lastUsedAt || atIso > stats.lastUsedAt) stats.lastUsedAt = atIso;
12022
+ } else if (event.action === "install") {
12023
+ stats.installCount += 1;
12024
+ if (actorUserId) stats._actors.get(actorUserId).installCount += 1;
12025
+ }
12026
+ }
12027
+ for (const stats of byResource.values()) {
12028
+ stats.uniqueUserCount = stats._users.size;
12029
+ }
12030
+ return byResource;
12031
+ }
12032
+ function marketplaceStatsFor(statsByResource, kind, id, version2, ownerUserId = "") {
12033
+ const stats = statsByResource.get(marketplaceResourceKey(kind, id, version2));
12034
+ if (!stats) return {
12035
+ useCount: 0,
12036
+ installCount: 0,
12037
+ uniqueUserCount: 0,
12038
+ lastUsedAt: ""
12039
+ };
12040
+ const owner = safeText(ownerUserId, 160);
12041
+ const ownerStats = owner ? stats._actors.get(owner) : null;
12042
+ return {
12043
+ useCount: Math.max(0, stats.useCount - Number(ownerStats?.useCount || 0)),
12044
+ installCount: Math.max(0, stats.installCount - Number(ownerStats?.installCount || 0)),
12045
+ uniqueUserCount: Math.max(0, stats.uniqueUserCount - (owner && stats._users.has(owner) ? 1 : 0)),
12046
+ lastUsedAt: stats.lastUsedAt
12047
+ };
12048
+ }
12049
+
11955
12050
  // bin/lib/marketplace.mjs
11956
12051
  var COLLECTION_MANIFEST = "collection.yaml";
11957
12052
  function workspacePackageRoot(workspaceRoot) {
11958
- return path5.join(path5.resolve(workspaceRoot), MARKETPLACE_PACKAGES_DIR);
12053
+ return path6.join(path6.resolve(workspaceRoot), MARKETPLACE_PACKAGES_DIR);
11959
12054
  }
11960
12055
  function parseMarketplaceDefinitionId(definitionId) {
11961
12056
  const raw = String(definitionId || "").trim();
@@ -11969,18 +12064,18 @@ function parseMarketplaceDefinitionId(definitionId) {
11969
12064
  return { id: spec, version: null };
11970
12065
  }
11971
12066
  function readYamlObject(filePath) {
11972
- if (!fs4.existsSync(filePath)) return null;
12067
+ if (!fs5.existsSync(filePath)) return null;
11973
12068
  try {
11974
- const data2 = jsYaml.load(fs4.readFileSync(filePath, "utf-8"));
12069
+ const data2 = jsYaml.load(fs5.readFileSync(filePath, "utf-8"));
11975
12070
  return data2 && typeof data2 === "object" && !Array.isArray(data2) ? data2 : null;
11976
12071
  } catch {
11977
12072
  return null;
11978
12073
  }
11979
12074
  }
11980
12075
  function readJsonObject(filePath) {
11981
- if (!fs4.existsSync(filePath)) return null;
12076
+ if (!fs5.existsSync(filePath)) return null;
11982
12077
  try {
11983
- const data2 = JSON.parse(fs4.readFileSync(filePath, "utf-8"));
12078
+ const data2 = JSON.parse(fs5.readFileSync(filePath, "utf-8"));
11984
12079
  return data2 && typeof data2 === "object" && !Array.isArray(data2) ? data2 : null;
11985
12080
  } catch {
11986
12081
  return null;
@@ -12007,16 +12102,16 @@ function normalizeSlotList(value) {
12007
12102
  function readNodeManifestRaw(dir) {
12008
12103
  try {
12009
12104
  const manifest = readNodePackageManifest(dir, readYamlObject);
12010
- const metadata = readJsonObject(path5.join(dir, NODE_PACKAGE_METADATA_FILENAME));
12105
+ const metadata = readJsonObject(path6.join(dir, NODE_PACKAGE_METADATA_FILENAME));
12011
12106
  return manifest && metadata ? { ...manifest, ...metadata } : manifest;
12012
12107
  } catch (e) {
12013
- console.warn(`[agentflow] \u8282\u70B9\u5305 ${path5.basename(dir)} \u6E05\u5355\u65E0\u6548\uFF1A${e && e.message || e}`);
12108
+ console.warn(`[agentflow] \u8282\u70B9\u5305 ${path6.basename(dir)} \u6E05\u5355\u65E0\u6548\uFF1A${e && e.message || e}`);
12014
12109
  return null;
12015
12110
  }
12016
12111
  }
12017
12112
  function normalizeManifest(raw, packageDir, source = "workspace") {
12018
12113
  if (!raw || typeof raw !== "object") return null;
12019
- const id = raw.id != null ? String(raw.id).trim() : path5.basename(packageDir);
12114
+ const id = raw.id != null ? String(raw.id).trim() : path6.basename(packageDir);
12020
12115
  const version2 = raw.version != null ? String(raw.version).trim() : "";
12021
12116
  if (!id || !version2) return null;
12022
12117
  const runtime = raw.runtime && typeof raw.runtime === "object" ? raw.runtime : {};
@@ -12033,6 +12128,7 @@ function normalizeManifest(raw, packageDir, source = "workspace") {
12033
12128
  baseDefinitionId,
12034
12129
  displayName: raw.displayName != null ? String(raw.displayName) : raw.name != null ? String(raw.name) : id,
12035
12130
  description: raw.description != null ? String(raw.description) : "",
12131
+ visibility: normalizeMarketplaceVisibility(raw.visibility),
12036
12132
  input,
12037
12133
  output,
12038
12134
  runtime,
@@ -12058,55 +12154,60 @@ function canAccessMarketplaceOwner(ownerUserId, opts = {}) {
12058
12154
  }
12059
12155
  function canAccessMarketplaceNode(manifest, opts = {}) {
12060
12156
  if ((manifest?.source || "marketplace") !== "marketplace") return true;
12061
- return canAccessMarketplaceOwner(manifestOwnerUserId(manifest), opts);
12157
+ const ownerUserId = manifestOwnerUserId(manifest);
12158
+ if (!canAccessMarketplaceOwner(ownerUserId, opts)) return false;
12159
+ if (normalizeMarketplaceVisibility(manifest?.visibility) === "public") return true;
12160
+ const requestedUserId = String(opts.userId || "").trim();
12161
+ if (!requestedUserId) return true;
12162
+ return isAdminRequest(opts) || Boolean(ownerUserId) && ownerUserId === requestedUserId;
12062
12163
  }
12063
12164
  function sortVersionsDesc(versions) {
12064
12165
  return [...versions].sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
12065
12166
  }
12066
12167
  function listVersionDirs(baseDir) {
12067
- if (!fs4.existsSync(baseDir)) return [];
12068
- return fs4.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter(Boolean);
12168
+ if (!fs5.existsSync(baseDir)) return [];
12169
+ return fs5.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter(Boolean);
12069
12170
  }
12070
12171
  function isSafePathSegment(value) {
12071
12172
  const text = String(value || "").trim();
12072
- return Boolean(text) && !text.includes("\0") && !path5.isAbsolute(text) && !text.split(/[\\/]+/).includes("..");
12173
+ return Boolean(text) && !text.includes("\0") && !path6.isAbsolute(text) && !text.split(/[\\/]+/).includes("..");
12073
12174
  }
12074
12175
  function resolveWorkspaceNodePackageDir(workspaceRoot, id, version2) {
12075
12176
  if (!isSafePathSegment(id) || !isSafePathSegment(version2)) return null;
12076
- const base = path5.resolve(workspacePackageRoot(workspaceRoot), "nodes");
12077
- const target = path5.resolve(base, id, version2);
12078
- if (target !== base && !target.startsWith(base + path5.sep)) return null;
12177
+ const base = path6.resolve(workspacePackageRoot(workspaceRoot), "nodes");
12178
+ const target = path6.resolve(base, id, version2);
12179
+ if (target !== base && !target.startsWith(base + path6.sep)) return null;
12079
12180
  return target;
12080
12181
  }
12081
12182
  function collectFlowDirs(rootDir, source, archived = false) {
12082
12183
  const out = [];
12083
- if (!fs4.existsSync(rootDir)) return out;
12184
+ if (!fs5.existsSync(rootDir)) return out;
12084
12185
  let entries = [];
12085
12186
  try {
12086
- entries = fs4.readdirSync(rootDir, { withFileTypes: true });
12187
+ entries = fs5.readdirSync(rootDir, { withFileTypes: true });
12087
12188
  } catch {
12088
12189
  return out;
12089
12190
  }
12090
12191
  for (const entry of entries) {
12091
12192
  if (!entry.isDirectory() || entry.name === ARCHIVED_PIPELINES_DIR_NAME) continue;
12092
- const dir = path5.join(rootDir, entry.name);
12193
+ const dir = path6.join(rootDir, entry.name);
12093
12194
  if (!isFlowDir(dir)) continue;
12094
12195
  out.push({ flowId: entry.name, flowSource: source, archived, flowDir: dir });
12095
12196
  }
12096
12197
  return out;
12097
12198
  }
12098
12199
  function listWritableFlowDirs(workspaceRoot, opts = {}) {
12099
- const root = path5.resolve(workspaceRoot);
12200
+ const root = path6.resolve(workspaceRoot);
12100
12201
  const userRoot = getUserPipelinesRoot(opts.userId);
12101
- const wsRoot = path5.join(root, PIPELINES_DIR);
12102
- const legacyRoot = path5.join(root, LEGACY_PIPELINES_DIR);
12202
+ const wsRoot = path6.join(root, PIPELINES_DIR);
12203
+ const legacyRoot = path6.join(root, LEGACY_PIPELINES_DIR);
12103
12204
  return [
12104
12205
  ...collectFlowDirs(userRoot, "user", false),
12105
- ...collectFlowDirs(path5.join(userRoot, ARCHIVED_PIPELINES_DIR_NAME), "user", true),
12206
+ ...collectFlowDirs(path6.join(userRoot, ARCHIVED_PIPELINES_DIR_NAME), "user", true),
12106
12207
  ...collectFlowDirs(wsRoot, "workspace", false),
12107
- ...collectFlowDirs(path5.join(wsRoot, ARCHIVED_PIPELINES_DIR_NAME), "workspace", true),
12208
+ ...collectFlowDirs(path6.join(wsRoot, ARCHIVED_PIPELINES_DIR_NAME), "workspace", true),
12108
12209
  ...collectFlowDirs(legacyRoot, "workspace", false),
12109
- ...collectFlowDirs(path5.join(legacyRoot, ARCHIVED_PIPELINES_DIR_NAME), "workspace", true)
12210
+ ...collectFlowDirs(path6.join(legacyRoot, ARCHIVED_PIPELINES_DIR_NAME), "workspace", true)
12110
12211
  ];
12111
12212
  }
12112
12213
  function depMatchesNode(dep, id, version2) {
@@ -12126,7 +12227,7 @@ function listMarketplaceNodeUsages(workspaceRoot, id, version2, opts = {}) {
12126
12227
  const usages = [];
12127
12228
  if (!id || !version2) return usages;
12128
12229
  for (const flow of listWritableFlowDirs(workspaceRoot, opts)) {
12129
- const flowYamlPath = path5.join(flow.flowDir, "flow.yaml");
12230
+ const flowYamlPath = path6.join(flow.flowDir, "flow.yaml");
12130
12231
  const data2 = readYamlObject(flowYamlPath);
12131
12232
  if (!data2) continue;
12132
12233
  const hits = [];
@@ -12162,20 +12263,20 @@ function iterCollectionNodeDirs(workspaceRoot, collectionDeps2 = []) {
12162
12263
  const collectionId = typeof dep === "string" ? dep : dep && dep.id;
12163
12264
  const collectionVersion = typeof dep === "object" && dep ? dep.version : null;
12164
12265
  if (!collectionId) continue;
12165
- const collectionBase = path5.join(root, "collections", String(collectionId));
12266
+ const collectionBase = path6.join(root, "collections", String(collectionId));
12166
12267
  const versions = collectionVersion ? [String(collectionVersion)] : sortVersionsDesc(listVersionDirs(collectionBase));
12167
12268
  for (const version2 of versions) {
12168
- const nodesRoot = path5.join(collectionBase, version2, "nodes");
12169
- if (!fs4.existsSync(nodesRoot)) continue;
12170
- for (const entry of fs4.readdirSync(nodesRoot, { withFileTypes: true })) {
12269
+ const nodesRoot = path6.join(collectionBase, version2, "nodes");
12270
+ if (!fs5.existsSync(nodesRoot)) continue;
12271
+ for (const entry of fs5.readdirSync(nodesRoot, { withFileTypes: true })) {
12171
12272
  if (!entry.isDirectory()) continue;
12172
- const direct = path5.join(nodesRoot, entry.name);
12273
+ const direct = path6.join(nodesRoot, entry.name);
12173
12274
  if (isNodePackageDir(direct)) {
12174
12275
  out.push(direct);
12175
12276
  continue;
12176
12277
  }
12177
12278
  for (const nodeVersion of sortVersionsDesc(listVersionDirs(direct))) {
12178
- const versioned = path5.join(direct, nodeVersion);
12279
+ const versioned = path6.join(direct, nodeVersion);
12179
12280
  if (isNodePackageDir(versioned)) out.push(versioned);
12180
12281
  }
12181
12282
  }
@@ -12200,13 +12301,13 @@ function listMarketplaceNodes(workspaceRoot, flowData = null, opts = {}) {
12200
12301
  seen.add(key);
12201
12302
  out.push(manifest);
12202
12303
  };
12203
- const nodesRoot = path5.join(root, "nodes");
12204
- if (fs4.existsSync(nodesRoot)) {
12205
- for (const nodeEntry of fs4.readdirSync(nodesRoot, { withFileTypes: true })) {
12304
+ const nodesRoot = path6.join(root, "nodes");
12305
+ if (fs5.existsSync(nodesRoot)) {
12306
+ for (const nodeEntry of fs5.readdirSync(nodesRoot, { withFileTypes: true })) {
12206
12307
  if (!nodeEntry.isDirectory()) continue;
12207
- const nodeBase = path5.join(nodesRoot, nodeEntry.name);
12308
+ const nodeBase = path6.join(nodesRoot, nodeEntry.name);
12208
12309
  for (const version2 of listVersionDirs(nodeBase)) {
12209
- addManifest(path5.join(nodeBase, version2), "marketplace");
12310
+ addManifest(path6.join(nodeBase, version2), "marketplace");
12210
12311
  }
12211
12312
  }
12212
12313
  }
@@ -12217,6 +12318,7 @@ function listMarketplaceNodes(workspaceRoot, flowData = null, opts = {}) {
12217
12318
  }
12218
12319
  function listMarketplacePackages(workspaceRoot, opts = {}) {
12219
12320
  const root = workspacePackageRoot(workspaceRoot);
12321
+ const stats = marketplaceUsageStats(workspaceRoot);
12220
12322
  const nodes = listMarketplaceNodes(workspaceRoot, null, opts).map((n) => ({
12221
12323
  id: n.id,
12222
12324
  version: n.version,
@@ -12237,18 +12339,20 @@ function listMarketplacePackages(workspaceRoot, opts = {}) {
12237
12339
  installedAt: String(n.installedAt || ""),
12238
12340
  ownerUserId: n.ownerUserId || n.createdBy || "",
12239
12341
  createdBy: n.createdBy || n.ownerUserId || "",
12342
+ visibility: normalizeMarketplaceVisibility(n.visibility),
12240
12343
  packageDir: n.packageDir,
12241
- usage: listMarketplaceNodeUsages(workspaceRoot, n.id, n.version, opts)
12242
- }));
12344
+ usage: listMarketplaceNodeUsages(workspaceRoot, n.id, n.version, opts),
12345
+ ...marketplaceStatsFor(stats, "node", n.id, n.version, n.ownerUserId || n.createdBy || "")
12346
+ })).sort((a, b) => Number(b.useCount || 0) - Number(a.useCount || 0) || Number(b.installCount || 0) - Number(a.installCount || 0) || String(a.id).localeCompare(String(b.id)) || String(b.version).localeCompare(String(a.version), void 0, { numeric: true, sensitivity: "base" }));
12243
12347
  const collections = [];
12244
- const collectionsRoot = path5.join(root, "collections");
12245
- if (fs4.existsSync(collectionsRoot)) {
12246
- for (const entry of fs4.readdirSync(collectionsRoot, { withFileTypes: true })) {
12348
+ const collectionsRoot = path6.join(root, "collections");
12349
+ if (fs5.existsSync(collectionsRoot)) {
12350
+ for (const entry of fs5.readdirSync(collectionsRoot, { withFileTypes: true })) {
12247
12351
  if (!entry.isDirectory()) continue;
12248
- const base = path5.join(collectionsRoot, entry.name);
12352
+ const base = path6.join(collectionsRoot, entry.name);
12249
12353
  for (const version2 of listVersionDirs(base)) {
12250
- const dir = path5.join(base, version2);
12251
- const manifest = readYamlObject(path5.join(dir, COLLECTION_MANIFEST)) || {};
12354
+ const dir = path6.join(base, version2);
12355
+ const manifest = readYamlObject(path6.join(dir, COLLECTION_MANIFEST)) || {};
12252
12356
  collections.push({
12253
12357
  id: manifest.id || entry.name,
12254
12358
  version: manifest.version || version2,
@@ -12268,7 +12372,7 @@ function publishNodePackageArchive(workspaceRoot, archiveInput, opts = {}) {
12268
12372
  if (!manifest) return { ok: false, error: "Invalid node package manifest" };
12269
12373
  const dest = resolveWorkspaceNodePackageDir(workspaceRoot, manifest.id, manifest.version);
12270
12374
  if (!dest) return { ok: false, error: "Invalid marketplace node id or version" };
12271
- const existing = fs4.existsSync(dest) ? inspectNodePackageDirectory(dest) : null;
12375
+ const existing = fs5.existsSync(dest) ? inspectNodePackageDirectory(dest) : null;
12272
12376
  if (existing?.ok) {
12273
12377
  if (existing.contentSha256 !== inspected.contentSha256) {
12274
12378
  return { ok: false, conflict: true, error: `${manifest.id}@${manifest.version} \u5DF2\u5B58\u5728\u4E14\u5185\u5BB9\u4E0D\u540C\uFF0C\u8BF7\u63D0\u5347\u7248\u672C\u53F7` };
@@ -12285,17 +12389,18 @@ function publishNodePackageArchive(workspaceRoot, archiveInput, opts = {}) {
12285
12389
  fileList: inspected.fileList
12286
12390
  };
12287
12391
  }
12288
- const parent = path5.dirname(dest);
12289
- fs4.mkdirSync(parent, { recursive: true });
12290
- const staging = fs4.mkdtempSync(path5.join(parent, `.${manifest.version}.installing-`));
12392
+ const parent = path6.dirname(dest);
12393
+ fs5.mkdirSync(parent, { recursive: true });
12394
+ const staging = fs5.mkdtempSync(path6.join(parent, `.${manifest.version}.installing-`));
12291
12395
  const ownerUserId = String(opts.ownerUserId || opts.userId || "").trim();
12292
12396
  const installedFrom = String(opts.installedFrom || "").trim();
12293
12397
  const installedAt = String(opts.installedAt || "").trim();
12294
12398
  try {
12295
12399
  const written = writeNodePackageFiles(staging, inspected.files);
12296
12400
  if (!written.ok) return written;
12297
- fs4.writeFileSync(path5.join(staging, NODE_PACKAGE_METADATA_FILENAME), `${JSON.stringify({
12401
+ fs5.writeFileSync(path6.join(staging, NODE_PACKAGE_METADATA_FILENAME), `${JSON.stringify({
12298
12402
  ...ownerUserId ? { ownerUserId, createdBy: ownerUserId } : {},
12403
+ visibility: normalizeMarketplaceVisibility(opts.visibility),
12299
12404
  contentSha256: inspected.contentSha256,
12300
12405
  archiveSha256: inspected.archiveSha256,
12301
12406
  fileList: inspected.fileList,
@@ -12306,11 +12411,11 @@ function publishNodePackageArchive(workspaceRoot, archiveInput, opts = {}) {
12306
12411
  ...installedAt ? { installedAt } : {}
12307
12412
  }, null, 2)}
12308
12413
  `, "utf-8");
12309
- fs4.renameSync(staging, dest);
12414
+ fs5.renameSync(staging, dest);
12310
12415
  } catch (error) {
12311
12416
  return { ok: false, error: error?.message || String(error) };
12312
12417
  } finally {
12313
- if (fs4.existsSync(staging)) fs4.rmSync(staging, { recursive: true, force: true });
12418
+ if (fs5.existsSync(staging)) fs5.rmSync(staging, { recursive: true, force: true });
12314
12419
  }
12315
12420
  return {
12316
12421
  ok: true,
@@ -12478,10 +12583,10 @@ var isProvideDefinition2 = (id) => String(id || "").startsWith("provide_");
12478
12583
  var isControlSlot = (slot) => String(slot?.type) === "node" || CTRL_SLOTS.has(String(slot?.name));
12479
12584
  function loadDefinitions(dir) {
12480
12585
  const out = {};
12481
- if (!fs5.existsSync(dir)) return out;
12482
- for (const file of fs5.readdirSync(dir)) {
12586
+ if (!fs6.existsSync(dir)) return out;
12587
+ for (const file of fs6.readdirSync(dir)) {
12483
12588
  if (!file.endsWith(".md")) continue;
12484
- const meta = parseNodeFrontmatter(fs5.readFileSync(path6.join(dir, file), "utf-8"));
12589
+ const meta = parseNodeFrontmatter(fs6.readFileSync(path7.join(dir, file), "utf-8"));
12485
12590
  out[file.slice(0, -3)] = { input: meta.input, output: meta.output, runtime: meta.runtime };
12486
12591
  }
12487
12592
  return out;
@@ -13456,9 +13561,9 @@ function parseFlowSource(source, opts = {}) {
13456
13561
  unresolvedAt(d, `${id}: \u8282\u70B9\u58F0\u660E\u53F3\u8FB9\u5FC5\u987B\u662F\u4E00\u6B21\u8282\u70B9\u8C03\u7528`);
13457
13562
  continue;
13458
13563
  }
13459
- const path11 = apiCalleePath(init.callee);
13564
+ const path12 = apiCalleePath(init.callee);
13460
13565
  const args = [...init.arguments];
13461
- if (path11 === "flow.input") {
13566
+ if (path12 === "flow.input") {
13462
13567
  const name = stringOf(args[0]);
13463
13568
  const type2 = stringOf(args[1]) || "text";
13464
13569
  if (!name) unresolvedAt(init, `${id}: flow.input \u7684\u7B2C\u4E00\u4E2A\u53C2\u6570\u5FC5\u987B\u662F\u8F93\u5165\u540D`);
@@ -13479,7 +13584,7 @@ function parseFlowSource(source, opts = {}) {
13479
13584
  const first = args[0];
13480
13585
  const hasLabel = first && (first.type === "Literal" && typeof first.value === "string" || first.type === "TemplateLiteral");
13481
13586
  const label = hasLabel ? stringOf(args.shift()) : null;
13482
- if (path11 === "flow.subflow") {
13587
+ if (path12 === "flow.subflow") {
13483
13588
  const inputObject = args.shift();
13484
13589
  const sequence = args.shift();
13485
13590
  const outputObject = args.shift();
@@ -13515,7 +13620,7 @@ function parseFlowSource(source, opts = {}) {
13515
13620
  linkChain(null, items);
13516
13621
  continue;
13517
13622
  }
13518
- if (path11 === "flow.call") {
13623
+ if (path12 === "flow.call") {
13519
13624
  const ref2 = args.shift();
13520
13625
  const subflow = ref2?.type === "Identifier" ? subflowOf.get(ref2.name) : null;
13521
13626
  if (!subflow) unresolvedAt(ref2, `${id}: flow.call \u7B2C\u4E8C\u4E2A\u53C2\u6570\u5FC5\u987B\u5F15\u7528\u524D\u9762\u58F0\u660E\u7684 flow.subflow`);
@@ -13539,19 +13644,19 @@ function parseFlowSource(source, opts = {}) {
13539
13644
  readPins(id, "control_subflow_call", args[0]);
13540
13645
  continue;
13541
13646
  }
13542
- if (path11 === "flow" || path11 === "flow.schedule") {
13543
- const body = path11 === "flow.schedule" ? stringOf(args.shift()) : null;
13647
+ if (path12 === "flow" || path12 === "flow.schedule") {
13648
+ const body = path12 === "flow.schedule" ? stringOf(args.shift()) : null;
13544
13649
  runDecls.push({
13545
13650
  id,
13546
- definitionId: path11 === "flow.schedule" ? "workspace_scheduled_run" : "workspace_run",
13651
+ definitionId: path12 === "flow.schedule" ? "workspace_scheduled_run" : "workspace_run",
13547
13652
  items: itemsOf({ arguments: args }),
13548
13653
  label,
13549
13654
  body
13550
13655
  });
13551
13656
  continue;
13552
13657
  }
13553
- const pkg = packageOf.get(path11);
13554
- const definitionId = pkg ? pkg.baseDefinitionId || pkg.definitionId || `pkg:${pkg.specifier}` : definitionIdFromApi(path11);
13658
+ const pkg = packageOf.get(path12);
13659
+ const definitionId = pkg ? pkg.baseDefinitionId || pkg.definitionId || `pkg:${pkg.specifier}` : definitionIdFromApi(path12);
13555
13660
  nodes[id] = {
13556
13661
  definitionId,
13557
13662
  inputs: {},
@@ -13565,7 +13670,7 @@ function parseFlowSource(source, opts = {}) {
13565
13670
  if (label) nodes[id].label = label;
13566
13671
  if (pkg) {
13567
13672
  nodes[id].package = pkg.specifier;
13568
- nodes[id].packageBinding = path11;
13673
+ nodes[id].packageBinding = path12;
13569
13674
  if (pkg.input || pkg.output) {
13570
13675
  nodes[id].packageDef = { input: pkg.input || [], output: pkg.output || [] };
13571
13676
  }
@@ -13635,14 +13740,14 @@ function parseFlowSource(source, opts = {}) {
13635
13740
  continue;
13636
13741
  }
13637
13742
  if (decl?.type === "ExpressionStatement" && decl.expression.type === "CallExpression") {
13638
- const path11 = apiCalleePath(decl.expression.callee);
13639
- if (path11 === "flow.resume") {
13743
+ const path12 = apiCalleePath(decl.expression.callee);
13744
+ if (path12 === "flow.resume") {
13640
13745
  const [a, b] = decl.expression.arguments.map((x2) => x2.name);
13641
13746
  if (a && b) edges.push(`${a}|next|${b}|prev`);
13642
13747
  else unresolvedAt(decl, "flow.resume \u7684\u4E24\u4E2A\u53C2\u6570\u90FD\u5FC5\u987B\u662F\u8282\u70B9\u53D8\u91CF\u540D");
13643
13748
  continue;
13644
13749
  }
13645
- if (path11 === "flow.detached") {
13750
+ if (path12 === "flow.detached") {
13646
13751
  linkChain(null, itemsOf(decl.expression));
13647
13752
  continue;
13648
13753
  }
@@ -13739,8 +13844,8 @@ function flowFilesToGraph(input) {
13739
13844
  }
13740
13845
 
13741
13846
  // bin/lib/flow-dsl/packages.mjs
13742
- import fs6 from "fs";
13743
- import path7 from "path";
13847
+ import fs7 from "fs";
13848
+ import path8 from "path";
13744
13849
  function marketplaceDependenciesFromSource(source) {
13745
13850
  let ast;
13746
13851
  try {
@@ -13830,16 +13935,16 @@ function scanFlowLocalPackages(flowDir) {
13830
13935
  const bySpecifier = {};
13831
13936
  const byRef = {};
13832
13937
  const list2 = [];
13833
- const root = path7.join(String(flowDir || ""), "nodes");
13938
+ const root = path8.join(String(flowDir || ""), "nodes");
13834
13939
  let entries;
13835
13940
  try {
13836
- entries = fs6.readdirSync(root, { withFileTypes: true });
13941
+ entries = fs7.readdirSync(root, { withFileTypes: true });
13837
13942
  } catch {
13838
13943
  return { bySpecifier, byRef, list: list2 };
13839
13944
  }
13840
13945
  for (const entry of entries) {
13841
13946
  if (!entry.isDirectory()) continue;
13842
- const dir = path7.join(root, entry.name);
13947
+ const dir = path8.join(root, entry.name);
13843
13948
  if (!isNodePackageDir(dir)) continue;
13844
13949
  let manifest = null;
13845
13950
  try {
@@ -13943,9 +14048,9 @@ var WorkspaceFlowParseError = class extends Error {
13943
14048
  }
13944
14049
  };
13945
14050
  function readJsonFile(file, fallback) {
13946
- if (!fs7.existsSync(file)) return fallback;
14051
+ if (!fs8.existsSync(file)) return fallback;
13947
14052
  try {
13948
- const raw = fs7.readFileSync(file, "utf-8");
14053
+ const raw = fs8.readFileSync(file, "utf-8");
13949
14054
  if (!raw.trim()) return fallback;
13950
14055
  const parsed = JSON.parse(raw);
13951
14056
  return parsed && typeof parsed === "object" ? parsed : fallback;
@@ -13954,14 +14059,14 @@ function readJsonFile(file, fallback) {
13954
14059
  }
13955
14060
  }
13956
14061
  function writeTextAtomic(file, text) {
13957
- fs7.mkdirSync(path8.dirname(file), { recursive: true });
14062
+ fs8.mkdirSync(path9.dirname(file), { recursive: true });
13958
14063
  const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
13959
- fs7.writeFileSync(tmp, text, "utf-8");
13960
- fs7.renameSync(tmp, file);
14064
+ fs8.writeFileSync(tmp, text, "utf-8");
14065
+ fs8.renameSync(tmp, file);
13961
14066
  }
13962
14067
  function readTextOrNull(file) {
13963
14068
  try {
13964
- return fs7.readFileSync(file, "utf-8");
14069
+ return fs8.readFileSync(file, "utf-8");
13965
14070
  } catch {
13966
14071
  return null;
13967
14072
  }
@@ -13982,16 +14087,16 @@ function normalizeDesignShape(raw) {
13982
14087
  function collectExternalFiles(dir) {
13983
14088
  const files = {};
13984
14089
  for (const sub of EXTERNAL_DIRS) {
13985
- const abs = path8.join(dir, sub);
14090
+ const abs = path9.join(dir, sub);
13986
14091
  let entries;
13987
14092
  try {
13988
- entries = fs7.readdirSync(abs, { withFileTypes: true });
14093
+ entries = fs8.readdirSync(abs, { withFileTypes: true });
13989
14094
  } catch {
13990
14095
  continue;
13991
14096
  }
13992
14097
  for (const entry of entries) {
13993
14098
  if (!entry.isFile()) continue;
13994
- const text = readTextOrNull(path8.join(abs, entry.name));
14099
+ const text = readTextOrNull(path9.join(abs, entry.name));
13995
14100
  if (text !== null) files[`${sub}/${entry.name}`] = text;
13996
14101
  }
13997
14102
  }
@@ -14065,16 +14170,16 @@ function designFingerprint(graph) {
14065
14170
  });
14066
14171
  }
14067
14172
  function readWorkspaceDesign(flowDir, opts = {}) {
14068
- const dir = path8.resolve(flowDir);
14069
- const sourcePath = path8.join(dir, FLOW_SOURCE_FILENAME);
14173
+ const dir = path9.resolve(flowDir);
14174
+ const sourcePath = path9.join(dir, FLOW_SOURCE_FILENAME);
14070
14175
  const source = readTextOrNull(sourcePath);
14071
14176
  if (source !== null && source.trim()) {
14072
14177
  let graph;
14073
14178
  try {
14074
14179
  graph = flowFilesToGraph({
14075
14180
  source,
14076
- layout: readJsonFile(path8.join(dir, FLOW_LAYOUT_FILENAME), { nodes: {} }),
14077
- nodeMeta: readJsonFile(path8.join(dir, FLOW_NODES_FILENAME), { nodes: {} }),
14181
+ layout: readJsonFile(path9.join(dir, FLOW_LAYOUT_FILENAME), { nodes: {} }),
14182
+ nodeMeta: readJsonFile(path9.join(dir, FLOW_NODES_FILENAME), { nodes: {} }),
14078
14183
  files: collectExternalFiles(dir),
14079
14184
  // 和 lint 用同一份包扫描。不传的话 `import x from "./nodes/x"` 会读成一个
14080
14185
  // 槽位表为空的节点,控制边跟着串位——lint 绿灯、画布是错图。
@@ -14088,7 +14193,7 @@ function readWorkspaceDesign(flowDir, opts = {}) {
14088
14193
  }
14089
14194
  return { format: "dsl", path: sourcePath, graph: normalizeDesignShape(graph), source };
14090
14195
  }
14091
- const graphPath = path8.join(dir, WORKSPACE_GRAPH_FILENAME);
14196
+ const graphPath = path9.join(dir, WORKSPACE_GRAPH_FILENAME);
14092
14197
  const rawJson = readTextOrNull(graphPath);
14093
14198
  if (rawJson !== null && rawJson.trim()) {
14094
14199
  return { format: "json", path: graphPath, graph: normalizeDesignShape(JSON.parse(rawJson)), source: null };
@@ -14096,8 +14201,8 @@ function readWorkspaceDesign(flowDir, opts = {}) {
14096
14201
  return { format: "empty", path: sourcePath, graph: emptyDesignGraph(), source: null };
14097
14202
  }
14098
14203
  function resolveInsideDir(dir, rel) {
14099
- const abs = path8.resolve(dir, rel);
14100
- const prefix = dir.endsWith(path8.sep) ? dir : dir + path8.sep;
14204
+ const abs = path9.resolve(dir, rel);
14205
+ const prefix = dir.endsWith(path9.sep) ? dir : dir + path9.sep;
14101
14206
  return abs.startsWith(prefix) ? abs : null;
14102
14207
  }
14103
14208
  function pruneStaleExternals(dir, previous, keep) {
@@ -14107,9 +14212,9 @@ function pruneStaleExternals(dir, previous, keep) {
14107
14212
  if (typeof rel !== "string" || keep.has(rel)) continue;
14108
14213
  if (!EXTERNAL_DIRS.includes(rel.split("/")[0])) continue;
14109
14214
  const abs = resolveInsideDir(dir, rel);
14110
- if (!abs || !fs7.existsSync(abs)) continue;
14215
+ if (!abs || !fs8.existsSync(abs)) continue;
14111
14216
  try {
14112
- fs7.rmSync(abs, { force: true });
14217
+ fs8.rmSync(abs, { force: true });
14113
14218
  removed.push(rel);
14114
14219
  } catch {
14115
14220
  }
@@ -14132,13 +14237,13 @@ function stripDerivedPackageScripts(design, bindings) {
14132
14237
  return changed ? { ...design, instances } : design;
14133
14238
  }
14134
14239
  function writeWorkspaceDesign(flowDir, designGraph, opts = {}) {
14135
- const dir = path8.resolve(flowDir);
14136
- fs7.mkdirSync(dir, { recursive: true });
14240
+ const dir = path9.resolve(flowDir);
14241
+ fs8.mkdirSync(dir, { recursive: true });
14137
14242
  const design = normalizeDesignShape(designGraph);
14138
- const sourcePath = path8.join(dir, FLOW_SOURCE_FILENAME);
14139
- const layoutPath = path8.join(dir, FLOW_LAYOUT_FILENAME);
14140
- const nodesPath = path8.join(dir, FLOW_NODES_FILENAME);
14141
- const graphPath = path8.join(dir, WORKSPACE_GRAPH_FILENAME);
14243
+ const sourcePath = path9.join(dir, FLOW_SOURCE_FILENAME);
14244
+ const layoutPath = path9.join(dir, FLOW_LAYOUT_FILENAME);
14245
+ const nodesPath = path9.join(dir, FLOW_NODES_FILENAME);
14246
+ const graphPath = path9.join(dir, WORKSPACE_GRAPH_FILENAME);
14142
14247
  const packages = scanAvailableNodePackages(dir, opts.marketplaceRoot || "");
14143
14248
  const bindings = packageBindingsForGraph(design, packages);
14144
14249
  const written = stripDerivedPackageScripts(design, bindings);
@@ -14167,7 +14272,7 @@ function writeWorkspaceDesign(flowDir, designGraph, opts = {}) {
14167
14272
  }
14168
14273
  }
14169
14274
  if (degradedReason) {
14170
- for (const file of [sourcePath, layoutPath, nodesPath]) fs7.rmSync(file, { force: true });
14275
+ for (const file of [sourcePath, layoutPath, nodesPath]) fs8.rmSync(file, { force: true });
14171
14276
  writeTextAtomic(graphPath, `${JSON.stringify(design, null, 2)}
14172
14277
  `);
14173
14278
  return { format: "json", changed: true, degradedReason, externals: [], design };
@@ -14180,7 +14285,7 @@ function writeWorkspaceDesign(flowDir, designGraph, opts = {}) {
14180
14285
  const nodesText = `${JSON.stringify(nodeMeta, null, 2)}
14181
14286
  `;
14182
14287
  const wantNodesFile = Object.keys(generated.nodeMeta.nodes || {}).length > 0 || externals.length > 0;
14183
- const unchanged = readTextOrNull(sourcePath) === generated.source && readTextOrNull(layoutPath) === layoutText && readTextOrNull(nodesPath) === (wantNodesFile ? nodesText : null) && !fs7.existsSync(graphPath) && generated.files.every((f) => readTextOrNull(path8.join(dir, f.path)) === f.text);
14288
+ const unchanged = readTextOrNull(sourcePath) === generated.source && readTextOrNull(layoutPath) === layoutText && readTextOrNull(nodesPath) === (wantNodesFile ? nodesText : null) && !fs8.existsSync(graphPath) && generated.files.every((f) => readTextOrNull(path9.join(dir, f.path)) === f.text);
14184
14289
  if (unchanged) return { format: "dsl", changed: false, degradedReason: null, externals, design: persisted };
14185
14290
  const previousExternals = readJsonFile(nodesPath, {}).externals;
14186
14291
  for (const file of generated.files) {
@@ -14191,27 +14296,27 @@ function writeWorkspaceDesign(flowDir, designGraph, opts = {}) {
14191
14296
  writeTextAtomic(sourcePath, generated.source);
14192
14297
  writeTextAtomic(layoutPath, layoutText);
14193
14298
  if (wantNodesFile) writeTextAtomic(nodesPath, nodesText);
14194
- else fs7.rmSync(nodesPath, { force: true });
14299
+ else fs8.rmSync(nodesPath, { force: true });
14195
14300
  pruneStaleExternals(dir, previousExternals, new Set(externals));
14196
- fs7.rmSync(graphPath, { force: true });
14301
+ fs8.rmSync(graphPath, { force: true });
14197
14302
  return { format: "dsl", changed: true, degradedReason: null, externals, design: persisted };
14198
14303
  }
14199
14304
  function readWorkspaceStateFile(dir) {
14200
- const parsed = readJsonFile(path8.join(dir, WORKSPACE_STATE_FILENAME), null);
14305
+ const parsed = readJsonFile(path9.join(dir, WORKSPACE_STATE_FILENAME), null);
14201
14306
  return parsed && !Array.isArray(parsed) ? parsed : null;
14202
14307
  }
14203
14308
  function readWorkspaceGraphFiles(flowDir, opts = {}) {
14204
- const dir = path8.resolve(flowDir);
14309
+ const dir = path9.resolve(flowDir);
14205
14310
  const design = readWorkspaceDesign(dir, opts);
14206
14311
  if (design.format === "empty") return { ...design, graph: emptyDesignGraph() };
14207
14312
  return { ...design, graph: mergeWorkspaceState(design.graph, readWorkspaceStateFile(dir)) };
14208
14313
  }
14209
14314
  function writeWorkspaceGraphFiles(flowDir, graph, opts = {}) {
14210
- const dir = path8.resolve(flowDir);
14211
- fs7.mkdirSync(dir, { recursive: true });
14212
- const statePath = path8.join(dir, WORKSPACE_STATE_FILENAME);
14315
+ const dir = path9.resolve(flowDir);
14316
+ fs8.mkdirSync(dir, { recursive: true });
14317
+ const statePath = path9.join(dir, WORKSPACE_STATE_FILENAME);
14213
14318
  const { design, state } = splitWorkspaceGraph(graph);
14214
- if (isEmptyWorkspaceState(state)) fs7.rmSync(statePath, { force: true });
14319
+ if (isEmptyWorkspaceState(state)) fs8.rmSync(statePath, { force: true });
14215
14320
  else writeTextAtomic(statePath, `${JSON.stringify(state, null, 2)}
14216
14321
  `);
14217
14322
  const result = writeWorkspaceDesign(dir, design, opts);
@@ -14219,13 +14324,13 @@ function writeWorkspaceGraphFiles(flowDir, graph, opts = {}) {
14219
14324
  }
14220
14325
 
14221
14326
  // bin/lib/flow-dsl/cli.mjs
14222
- import fs9 from "fs";
14327
+ import fs10 from "fs";
14223
14328
  import os3 from "os";
14224
- import path10 from "path";
14329
+ import path11 from "path";
14225
14330
 
14226
14331
  // bin/lib/flow-dsl/lint.mjs
14227
- import fs8 from "fs";
14228
- import path9 from "path";
14332
+ import fs9 from "fs";
14333
+ import path10 from "path";
14229
14334
 
14230
14335
  // shared/slot-types.js
14231
14336
  var SLOT_TYPE_ALIASES = /* @__PURE__ */ new Map([
@@ -14320,9 +14425,9 @@ function walk(node, visit) {
14320
14425
  function lintFlowDir(flowDir, opts = {}) {
14321
14426
  const errors = [];
14322
14427
  const warnings = [];
14323
- const sourcePath = path9.join(flowDir, FLOW_SOURCE_FILENAME);
14324
- if (!fs8.existsSync(sourcePath)) return { errors: [`\u7F3A\u5C11 ${sourcePath}`], warnings };
14325
- const source = fs8.readFileSync(sourcePath, "utf-8");
14428
+ const sourcePath = path10.join(flowDir, FLOW_SOURCE_FILENAME);
14429
+ if (!fs9.existsSync(sourcePath)) return { errors: [`\u7F3A\u5C11 ${sourcePath}`], warnings };
14430
+ const source = fs9.readFileSync(sourcePath, "utf-8");
14326
14431
  let ast;
14327
14432
  try {
14328
14433
  ast = parse3(source, { ecmaVersion: 2022, sourceType: "module", locations: true });
@@ -14345,9 +14450,9 @@ function lintFlowDir(flowDir, opts = {}) {
14345
14450
  errors.push(`file() \u53C2\u6570\u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u5B57\u9762\u91CF @L${node.loc?.start.line}`);
14346
14451
  return;
14347
14452
  }
14348
- const abs = path9.join(flowDir, rel);
14349
- if (!fs8.existsSync(abs)) errors.push(`file(${JSON.stringify(rel)}) \u6307\u5411\u7684\u6587\u4EF6\u4E0D\u5B58\u5728`);
14350
- else files[rel] = fs8.readFileSync(abs, "utf-8");
14453
+ const abs = path10.join(flowDir, rel);
14454
+ if (!fs9.existsSync(abs)) errors.push(`file(${JSON.stringify(rel)}) \u6307\u5411\u7684\u6587\u4EF6\u4E0D\u5B58\u5728`);
14455
+ else files[rel] = fs9.readFileSync(abs, "utf-8");
14351
14456
  });
14352
14457
  const packages = scanAvailableNodePackages(flowDir, opts.workspaceRoot || "");
14353
14458
  const lookupDef = (definitionId) => DEFINITIONS[definitionId] ? definitionOf(definitionId) : null;
@@ -14804,11 +14909,11 @@ function applyWorkspaceAutoLayout(graph, options = {}) {
14804
14909
 
14805
14910
  // bin/lib/flow-dsl/cli.mjs
14806
14911
  function writeFileEnsuringDir(file, text) {
14807
- fs9.mkdirSync(path10.dirname(file), { recursive: true });
14808
- fs9.writeFileSync(file, text, "utf-8");
14912
+ fs10.mkdirSync(path11.dirname(file), { recursive: true });
14913
+ fs10.writeFileSync(file, text, "utf-8");
14809
14914
  }
14810
14915
  function layoutWorkspaceFlowDir(flowDir, { all = false, workspaceRoot = "" } = {}) {
14811
- const dir = path10.resolve(flowDir);
14916
+ const dir = path11.resolve(flowDir);
14812
14917
  const lint = lintWorkspaceFlowDir(dir, { workspaceRoot });
14813
14918
  if (lint.errors.length) {
14814
14919
  throw new Error(`lint \u672A\u901A\u8FC7\uFF0C\u62D2\u7EDD\u6392\u7248\uFF1A
@@ -14830,32 +14935,32 @@ function layoutWorkspaceFlowDir(flowDir, { all = false, workspaceRoot = "" } = {
14830
14935
  mode: all ? "all" : "missing",
14831
14936
  nodeCount: Object.keys(next.instances || {}).length,
14832
14937
  positioned,
14833
- layoutPath: path10.join(dir, FLOW_LAYOUT_FILENAME)
14938
+ layoutPath: path11.join(dir, FLOW_LAYOUT_FILENAME)
14834
14939
  };
14835
14940
  }
14836
14941
  function lintWorkspaceFlowDir(flowDir, opts = {}) {
14837
- const dir = path10.resolve(flowDir);
14838
- if (fs9.existsSync(path10.join(dir, FLOW_SOURCE_FILENAME))) {
14942
+ const dir = path11.resolve(flowDir);
14943
+ if (fs10.existsSync(path11.join(dir, FLOW_SOURCE_FILENAME))) {
14839
14944
  return { format: "dsl", ...lintFlowDir(dir, opts) };
14840
14945
  }
14841
14946
  const current2 = readWorkspaceGraphFiles(dir);
14842
14947
  if (current2.format === "empty") {
14843
14948
  return { format: "empty", errors: [], warnings: ["\u8FD9\u4E2A\u6D41\u7A0B\u8FD8\u6CA1\u6709 Workspace \u56FE"] };
14844
14949
  }
14845
- const staging = fs9.mkdtempSync(path10.join(os3.tmpdir(), "agentflow-lint-"));
14950
+ const staging = fs10.mkdtempSync(path11.join(os3.tmpdir(), "agentflow-lint-"));
14846
14951
  try {
14847
14952
  const out = graphToFlowFiles(current2.graph);
14848
- writeFileEnsuringDir(path10.join(staging, FLOW_SOURCE_FILENAME), out.source);
14849
- writeFileEnsuringDir(path10.join(staging, FLOW_LAYOUT_FILENAME), `${JSON.stringify(out.layout, null, 2)}
14953
+ writeFileEnsuringDir(path11.join(staging, FLOW_SOURCE_FILENAME), out.source);
14954
+ writeFileEnsuringDir(path11.join(staging, FLOW_LAYOUT_FILENAME), `${JSON.stringify(out.layout, null, 2)}
14850
14955
  `);
14851
- writeFileEnsuringDir(path10.join(staging, FLOW_NODES_FILENAME), `${JSON.stringify(out.nodeMeta, null, 2)}
14956
+ writeFileEnsuringDir(path11.join(staging, FLOW_NODES_FILENAME), `${JSON.stringify(out.nodeMeta, null, 2)}
14852
14957
  `);
14853
- for (const file of out.files) writeFileEnsuringDir(path10.join(staging, file.path), file.text);
14854
- const localNodes = path10.join(dir, "nodes");
14855
- if (fs9.existsSync(localNodes)) fs9.cpSync(localNodes, path10.join(staging, "nodes"), { recursive: true });
14958
+ for (const file of out.files) writeFileEnsuringDir(path11.join(staging, file.path), file.text);
14959
+ const localNodes = path11.join(dir, "nodes");
14960
+ if (fs10.existsSync(localNodes)) fs10.cpSync(localNodes, path11.join(staging, "nodes"), { recursive: true });
14856
14961
  return { format: "json", ...lintFlowDir(staging, opts) };
14857
14962
  } finally {
14858
- fs9.rmSync(staging, { recursive: true, force: true });
14963
+ fs10.rmSync(staging, { recursive: true, force: true });
14859
14964
  }
14860
14965
  }
14861
14966
  export {