@powerformer/refly-cli 0.1.6 → 0.1.8

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/dist/bin/refly.js CHANGED
@@ -989,8 +989,8 @@ var require_command = __commonJS({
989
989
  init_cjs_shims();
990
990
  var EventEmitter = require("events").EventEmitter;
991
991
  var childProcess2 = require("child_process");
992
- var path10 = require("path");
993
- var fs14 = require("fs");
992
+ var path11 = require("path");
993
+ var fs15 = require("fs");
994
994
  var process8 = require("process");
995
995
  var { Argument: Argument2, humanReadableArgName } = require_argument();
996
996
  var { CommanderError: CommanderError2 } = require_error();
@@ -1922,11 +1922,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1922
  let launchWithNode = false;
1923
1923
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1924
1924
  function findFile(baseDir, baseName) {
1925
- const localBin = path10.resolve(baseDir, baseName);
1926
- if (fs14.existsSync(localBin)) return localBin;
1927
- if (sourceExt.includes(path10.extname(baseName))) return void 0;
1925
+ const localBin = path11.resolve(baseDir, baseName);
1926
+ if (fs15.existsSync(localBin)) return localBin;
1927
+ if (sourceExt.includes(path11.extname(baseName))) return void 0;
1928
1928
  const foundExt = sourceExt.find(
1929
- (ext) => fs14.existsSync(`${localBin}${ext}`)
1929
+ (ext) => fs15.existsSync(`${localBin}${ext}`)
1930
1930
  );
1931
1931
  if (foundExt) return `${localBin}${foundExt}`;
1932
1932
  return void 0;
@@ -1938,21 +1938,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1938
1938
  if (this._scriptPath) {
1939
1939
  let resolvedScriptPath;
1940
1940
  try {
1941
- resolvedScriptPath = fs14.realpathSync(this._scriptPath);
1941
+ resolvedScriptPath = fs15.realpathSync(this._scriptPath);
1942
1942
  } catch (err) {
1943
1943
  resolvedScriptPath = this._scriptPath;
1944
1944
  }
1945
- executableDir = path10.resolve(
1946
- path10.dirname(resolvedScriptPath),
1945
+ executableDir = path11.resolve(
1946
+ path11.dirname(resolvedScriptPath),
1947
1947
  executableDir
1948
1948
  );
1949
1949
  }
1950
1950
  if (executableDir) {
1951
1951
  let localFile = findFile(executableDir, executableFile);
1952
1952
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1953
- const legacyName = path10.basename(
1953
+ const legacyName = path11.basename(
1954
1954
  this._scriptPath,
1955
- path10.extname(this._scriptPath)
1955
+ path11.extname(this._scriptPath)
1956
1956
  );
1957
1957
  if (legacyName !== this._name) {
1958
1958
  localFile = findFile(
@@ -1963,7 +1963,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1963
1963
  }
1964
1964
  executableFile = localFile || executableFile;
1965
1965
  }
1966
- launchWithNode = sourceExt.includes(path10.extname(executableFile));
1966
+ launchWithNode = sourceExt.includes(path11.extname(executableFile));
1967
1967
  let proc;
1968
1968
  if (process8.platform !== "win32") {
1969
1969
  if (launchWithNode) {
@@ -2803,7 +2803,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2803
2803
  * @return {Command}
2804
2804
  */
2805
2805
  nameFromFilename(filename) {
2806
- this._name = path10.basename(filename, path10.extname(filename));
2806
+ this._name = path11.basename(filename, path11.extname(filename));
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -2817,9 +2817,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2817
2817
  * @param {string} [path]
2818
2818
  * @return {(string|null|Command)}
2819
2819
  */
2820
- executableDir(path11) {
2821
- if (path11 === void 0) return this._executableDir;
2822
- this._executableDir = path11;
2820
+ executableDir(path12) {
2821
+ if (path12 === void 0) return this._executableDir;
2822
+ this._executableDir = path12;
2823
2823
  return this;
2824
2824
  }
2825
2825
  /**
@@ -4438,8 +4438,8 @@ var ErrorCodes = {
4438
4438
  };
4439
4439
 
4440
4440
  // src/bin/refly.ts
4441
- var fs13 = __toESM(require("fs"));
4442
- var path9 = __toESM(require("path"));
4441
+ var fs14 = __toESM(require("fs"));
4442
+ var path10 = __toESM(require("path"));
4443
4443
 
4444
4444
  // src/commands/init.ts
4445
4445
  init_cjs_shims();
@@ -4950,8 +4950,8 @@ function getErrorMap() {
4950
4950
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
4951
4951
  init_cjs_shims();
4952
4952
  var makeIssue = (params) => {
4953
- const { data, path: path10, errorMaps, issueData } = params;
4954
- const fullPath = [...path10, ...issueData.path || []];
4953
+ const { data, path: path11, errorMaps, issueData } = params;
4954
+ const fullPath = [...path11, ...issueData.path || []];
4955
4955
  const fullIssue = {
4956
4956
  ...issueData,
4957
4957
  path: fullPath
@@ -5071,11 +5071,11 @@ var errorUtil;
5071
5071
 
5072
5072
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
5073
5073
  var ParseInputLazyPath = class {
5074
- constructor(parent, value, path10, key) {
5074
+ constructor(parent, value, path11, key) {
5075
5075
  this._cachedPath = [];
5076
5076
  this.parent = parent;
5077
5077
  this.data = value;
5078
- this._path = path10;
5078
+ this._path = path11;
5079
5079
  this._key = key;
5080
5080
  }
5081
5081
  get path() {
@@ -9336,10 +9336,10 @@ var NetworkError = class extends CLIError {
9336
9336
  // src/api/client.ts
9337
9337
  init_logger();
9338
9338
  var DEFAULT_TIMEOUT = 3e4;
9339
- async function apiRequest(path10, options = {}) {
9339
+ async function apiRequest(path11, options = {}) {
9340
9340
  const { method = "GET", body, query, timeout = DEFAULT_TIMEOUT, requireAuth = true } = options;
9341
9341
  const endpoint = getApiEndpoint();
9342
- let url = `${endpoint}${path10}`;
9342
+ let url = `${endpoint}${path11}`;
9343
9343
  if (query && Object.keys(query).length > 0) {
9344
9344
  const params = new URLSearchParams(query);
9345
9345
  url = `${url}?${params.toString()}`;
@@ -9377,7 +9377,7 @@ async function apiRequest(path10, options = {}) {
9377
9377
  const controller = new AbortController();
9378
9378
  const timeoutId = setTimeout(() => controller.abort(), timeout);
9379
9379
  try {
9380
- logger.debug(`API Request: ${method} ${path10}`);
9380
+ logger.debug(`API Request: ${method} ${path11}`);
9381
9381
  const response = await fetch(url, {
9382
9382
  method,
9383
9383
  headers,
@@ -9467,10 +9467,10 @@ function mapAPIError(status, response) {
9467
9467
  }
9468
9468
  return new CLIError(errCode, errMsg);
9469
9469
  }
9470
- async function apiRequestStream(path10, options = {}) {
9470
+ async function apiRequestStream(path11, options = {}) {
9471
9471
  const { timeout = 3e5 } = options;
9472
9472
  const endpoint = getApiEndpoint();
9473
- const url = `${endpoint}${path10}`;
9473
+ const url = `${endpoint}${path11}`;
9474
9474
  const headers = {
9475
9475
  "User-Agent": "refly-cli/0.1.0"
9476
9476
  };
@@ -9501,7 +9501,7 @@ async function apiRequestStream(path10, options = {}) {
9501
9501
  const controller = new AbortController();
9502
9502
  const timeoutId = setTimeout(() => controller.abort(), timeout);
9503
9503
  try {
9504
- logger.debug(`API Stream Request: GET ${path10}`);
9504
+ logger.debug(`API Stream Request: GET ${path11}`);
9505
9505
  const response = await fetch(url, {
9506
9506
  method: "GET",
9507
9507
  headers,
@@ -10080,16 +10080,135 @@ var whoamiCommand = new Command("whoami").description("Show current authenticate
10080
10080
 
10081
10081
  // src/commands/upgrade.ts
10082
10082
  init_cjs_shims();
10083
- var upgradeCommand = new Command("upgrade").description("Reinstall or upgrade skill files").action(async () => {
10083
+ var import_node_child_process6 = require("child_process");
10084
+ var import_node_fs4 = __toESM(require("fs"));
10085
+ var import_node_path2 = __toESM(require("path"));
10086
+ init_logger();
10087
+ var PACKAGE_NAME = "@powerformer/refly-cli";
10088
+ function getCurrentVersion() {
10089
+ try {
10090
+ const pkgPath = import_node_path2.default.join(__dirname, "..", "..", "package.json");
10091
+ const pkgContent = import_node_fs4.default.readFileSync(pkgPath, { encoding: "utf-8" });
10092
+ const pkg = JSON.parse(pkgContent);
10093
+ return pkg.version;
10094
+ } catch {
10095
+ return "0.1.0";
10096
+ }
10097
+ }
10098
+ async function getLatestVersion() {
10099
+ try {
10100
+ const result = (0, import_node_child_process6.execSync)(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
10101
+ encoding: "utf-8",
10102
+ timeout: 1e4
10103
+ });
10104
+ return result.trim();
10105
+ } catch (error) {
10106
+ logger.debug("Failed to get latest version from npm:", error);
10107
+ return null;
10108
+ }
10109
+ }
10110
+ async function checkVersion() {
10111
+ const current = getCurrentVersion();
10112
+ const latest = await getLatestVersion();
10113
+ return {
10114
+ current,
10115
+ latest,
10116
+ updateAvailable: latest !== null && latest !== current
10117
+ };
10118
+ }
10119
+ function upgradeCli() {
10120
+ try {
10121
+ logger.info("Upgrading CLI via npm...");
10122
+ (0, import_node_child_process6.execSync)(`npm install -g ${PACKAGE_NAME}@latest`, {
10123
+ encoding: "utf-8",
10124
+ stdio: "pipe",
10125
+ timeout: 12e4
10126
+ // 2 minutes
10127
+ });
10128
+ return { success: true };
10129
+ } catch (error) {
10130
+ const message = error instanceof Error ? error.message : "Unknown error";
10131
+ logger.error("Failed to upgrade CLI:", message);
10132
+ return { success: false, error: message };
10133
+ }
10134
+ }
10135
+ var upgradeCommand = new Command("upgrade").description("Upgrade CLI to latest version and reinstall skill files").option("--check", "Only check for updates without installing").option("--skill-only", "Only reinstall skill files without upgrading CLI").option("--cli-only", "Only upgrade CLI without reinstalling skill files").action(async (options) => {
10084
10136
  try {
10085
- const beforeStatus = isSkillInstalled();
10086
- const result = installSkill();
10137
+ const { check, skillOnly, cliOnly } = options;
10138
+ const versionInfo = await checkVersion();
10139
+ if (check) {
10140
+ return ok("upgrade.check", {
10141
+ currentVersion: versionInfo.current,
10142
+ latestVersion: versionInfo.latest,
10143
+ updateAvailable: versionInfo.updateAvailable,
10144
+ message: versionInfo.updateAvailable ? `Update available: ${versionInfo.current} \u2192 ${versionInfo.latest}` : "Already on latest version"
10145
+ });
10146
+ }
10147
+ if (skillOnly) {
10148
+ const beforeStatus = isSkillInstalled();
10149
+ const result = installSkill();
10150
+ return ok("upgrade", {
10151
+ message: "Skill files updated successfully",
10152
+ cliUpgraded: false,
10153
+ skillUpdated: true,
10154
+ previousVersion: beforeStatus.currentVersion ?? null,
10155
+ newVersion: result.version,
10156
+ skillPath: result.skillPath,
10157
+ commandsInstalled: result.commandsInstalled
10158
+ });
10159
+ }
10160
+ let cliUpgraded = false;
10161
+ let cliError;
10162
+ if (!cliOnly) {
10163
+ print("upgrade.progress", {
10164
+ step: "checking",
10165
+ currentVersion: versionInfo.current,
10166
+ latestVersion: versionInfo.latest
10167
+ });
10168
+ }
10169
+ if (!skillOnly) {
10170
+ if (versionInfo.updateAvailable) {
10171
+ print("upgrade.progress", {
10172
+ step: "upgrading",
10173
+ from: versionInfo.current,
10174
+ to: versionInfo.latest
10175
+ });
10176
+ const upgradeResult = upgradeCli();
10177
+ cliUpgraded = upgradeResult.success;
10178
+ cliError = upgradeResult.error;
10179
+ if (!cliUpgraded) {
10180
+ return fail(ErrorCodes.INTERNAL_ERROR, "Failed to upgrade CLI", {
10181
+ hint: cliError || "Try running: npm install -g @powerformer/refly-cli@latest"
10182
+ });
10183
+ }
10184
+ } else {
10185
+ logger.info("CLI is already on latest version");
10186
+ }
10187
+ }
10188
+ let skillResult = null;
10189
+ if (!cliOnly) {
10190
+ skillResult = installSkill();
10191
+ }
10192
+ const newVersionInfo = await checkVersion();
10193
+ let message;
10194
+ if (cliUpgraded && skillResult) {
10195
+ message = "CLI and skill files updated successfully";
10196
+ } else if (cliUpgraded) {
10197
+ message = "CLI updated successfully";
10198
+ } else if (skillResult) {
10199
+ message = "Skill files updated (CLI already on latest version)";
10200
+ } else {
10201
+ message = "Already on latest version";
10202
+ }
10087
10203
  ok("upgrade", {
10088
- message: "Skill files upgraded successfully",
10089
- previousVersion: beforeStatus.currentVersion ?? null,
10090
- newVersion: result.version,
10091
- skillPath: result.skillPath,
10092
- commandsInstalled: result.commandsInstalled
10204
+ message,
10205
+ cliUpgraded,
10206
+ skillUpdated: !!skillResult,
10207
+ previousVersion: versionInfo.current,
10208
+ currentVersion: newVersionInfo.current,
10209
+ latestVersion: newVersionInfo.latest,
10210
+ skillPath: skillResult?.skillPath ?? null,
10211
+ commandsInstalled: skillResult?.commandsInstalled ?? false
10093
10212
  });
10094
10213
  } catch (error) {
10095
10214
  return fail(
@@ -10185,16 +10304,16 @@ configCommand.action(() => {
10185
10304
  };
10186
10305
  ok("config", safeConfig);
10187
10306
  });
10188
- function getNestedValue(obj, path10) {
10189
- return path10.split(".").reduce((current, key) => {
10307
+ function getNestedValue(obj, path11) {
10308
+ return path11.split(".").reduce((current, key) => {
10190
10309
  if (current && typeof current === "object" && key in current) {
10191
10310
  return current[key];
10192
10311
  }
10193
10312
  return void 0;
10194
10313
  }, obj);
10195
10314
  }
10196
- function setNestedValue(obj, path10, value) {
10197
- const keys = path10.split(".");
10315
+ function setNestedValue(obj, path11, value) {
10316
+ const keys = path11.split(".");
10198
10317
  const lastKey = keys.pop();
10199
10318
  let current = obj;
10200
10319
  for (const key of keys) {
@@ -10214,8 +10333,8 @@ init_cjs_shims();
10214
10333
 
10215
10334
  // src/builder/store.ts
10216
10335
  init_cjs_shims();
10217
- var fs10 = __toESM(require("fs"));
10218
- var path6 = __toESM(require("path"));
10336
+ var fs11 = __toESM(require("fs"));
10337
+ var path7 = __toESM(require("path"));
10219
10338
  var crypto2 = __toESM(require("crypto"));
10220
10339
  init_paths();
10221
10340
 
@@ -10292,21 +10411,21 @@ function createSession(name, description) {
10292
10411
  }
10293
10412
  function saveSession(session) {
10294
10413
  const sessionPath = getSessionPath(session.id);
10295
- const tempPath = path6.join(getBuilderDir(), `.session-${session.id}-${Date.now()}.tmp`);
10414
+ const tempPath = path7.join(getBuilderDir(), `.session-${session.id}-${Date.now()}.tmp`);
10296
10415
  session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
10297
10416
  const validated = BuilderSessionSchema.parse(session);
10298
- fs10.writeFileSync(tempPath, JSON.stringify(validated, null, 2), {
10417
+ fs11.writeFileSync(tempPath, JSON.stringify(validated, null, 2), {
10299
10418
  mode: 384
10300
10419
  });
10301
- fs10.renameSync(tempPath, sessionPath);
10420
+ fs11.renameSync(tempPath, sessionPath);
10302
10421
  }
10303
10422
  function loadSession(sessionId) {
10304
10423
  const sessionPath = getSessionPath(sessionId);
10305
10424
  try {
10306
- if (!fs10.existsSync(sessionPath)) {
10425
+ if (!fs11.existsSync(sessionPath)) {
10307
10426
  return null;
10308
10427
  }
10309
- const content = fs10.readFileSync(sessionPath, "utf-8");
10428
+ const content = fs11.readFileSync(sessionPath, "utf-8");
10310
10429
  const parsed = JSON.parse(content);
10311
10430
  return BuilderSessionSchema.parse(parsed);
10312
10431
  } catch {
@@ -10316,8 +10435,8 @@ function loadSession(sessionId) {
10316
10435
  function deleteSession(sessionId) {
10317
10436
  const sessionPath = getSessionPath(sessionId);
10318
10437
  try {
10319
- if (fs10.existsSync(sessionPath)) {
10320
- fs10.unlinkSync(sessionPath);
10438
+ if (fs11.existsSync(sessionPath)) {
10439
+ fs11.unlinkSync(sessionPath);
10321
10440
  }
10322
10441
  } catch {
10323
10442
  }
@@ -10326,22 +10445,22 @@ function setCurrent(sessionId) {
10326
10445
  const currentPath = getCurrentSessionPath();
10327
10446
  if (sessionId === null) {
10328
10447
  try {
10329
- if (fs10.existsSync(currentPath)) {
10330
- fs10.unlinkSync(currentPath);
10448
+ if (fs11.existsSync(currentPath)) {
10449
+ fs11.unlinkSync(currentPath);
10331
10450
  }
10332
10451
  } catch {
10333
10452
  }
10334
10453
  return;
10335
10454
  }
10336
- fs10.writeFileSync(currentPath, sessionId, { mode: 384 });
10455
+ fs11.writeFileSync(currentPath, sessionId, { mode: 384 });
10337
10456
  }
10338
10457
  function getCurrentSessionId() {
10339
10458
  const currentPath = getCurrentSessionPath();
10340
10459
  try {
10341
- if (!fs10.existsSync(currentPath)) {
10460
+ if (!fs11.existsSync(currentPath)) {
10342
10461
  return null;
10343
10462
  }
10344
- return fs10.readFileSync(currentPath, "utf-8").trim();
10463
+ return fs11.readFileSync(currentPath, "utf-8").trim();
10345
10464
  } catch {
10346
10465
  return null;
10347
10466
  }
@@ -11015,18 +11134,18 @@ function detectCycles(nodes) {
11015
11134
  }
11016
11135
  const visited = /* @__PURE__ */ new Set();
11017
11136
  const recursionStack = /* @__PURE__ */ new Set();
11018
- const path10 = [];
11137
+ const path11 = [];
11019
11138
  function dfs(nodeId) {
11020
11139
  if (recursionStack.has(nodeId)) {
11021
- const cycleStart = path10.indexOf(nodeId);
11022
- return [...path10.slice(cycleStart), nodeId];
11140
+ const cycleStart = path11.indexOf(nodeId);
11141
+ return [...path11.slice(cycleStart), nodeId];
11023
11142
  }
11024
11143
  if (visited.has(nodeId)) {
11025
11144
  return null;
11026
11145
  }
11027
11146
  visited.add(nodeId);
11028
11147
  recursionStack.add(nodeId);
11029
- path10.push(nodeId);
11148
+ path11.push(nodeId);
11030
11149
  const node = nodeMap.get(nodeId);
11031
11150
  if (node) {
11032
11151
  for (const depId of node.dependsOn) {
@@ -11036,7 +11155,7 @@ function detectCycles(nodes) {
11036
11155
  }
11037
11156
  }
11038
11157
  }
11039
- path10.pop();
11158
+ path11.pop();
11040
11159
  recursionStack.delete(nodeId);
11041
11160
  return null;
11042
11161
  }
@@ -11470,85 +11589,32 @@ var workflowDeleteCommand = new Command("delete").description("Delete a workflow
11470
11589
 
11471
11590
  // src/commands/workflow/run.ts
11472
11591
  init_cjs_shims();
11473
-
11474
- // src/commands/workflow/run-detail.ts
11475
- init_cjs_shims();
11476
- var workflowRunDetailCommand = new Command("detail").description("Get detailed workflow run information including all node results").argument("<runId>", "Workflow run ID").option("--no-tool-calls", "Exclude tool call summaries").option("--preview-length <length>", "Output preview length (default: 500)", "500").action(async (runId, options) => {
11592
+ var workflowRunCommand = new Command("run").description("Start a workflow execution").argument("<workflowId>", "Workflow ID to run").option("--input <json>", "Input variables as JSON", "{}").option("--from-node <nodeId>", "Start workflow execution from a specific node (Run From Here)").action(async (workflowId, options) => {
11477
11593
  try {
11478
- const params = new URLSearchParams();
11479
- if (options.toolCalls === false) {
11480
- params.set("includeToolCalls", "false");
11594
+ let input;
11595
+ try {
11596
+ input = JSON.parse(options.input);
11597
+ } catch {
11598
+ fail(ErrorCodes.INVALID_INPUT, "Invalid JSON in --input", {
11599
+ hint: "Ensure the input is valid JSON"
11600
+ });
11481
11601
  }
11482
- if (options.previewLength) {
11483
- params.set("outputPreviewLength", options.previewLength);
11602
+ const body = { input };
11603
+ if (options.fromNode) {
11604
+ body.startNodes = [options.fromNode];
11484
11605
  }
11485
- const queryString = params.toString();
11486
- const url = `/v1/cli/workflow/run/${runId}/detail${queryString ? `?${queryString}` : ""}`;
11487
- const result = await apiRequest(url);
11488
- ok("workflow.run.detail", {
11606
+ const result = await apiRequest(`/v1/cli/workflow/${workflowId}/run`, {
11607
+ method: "POST",
11608
+ body
11609
+ });
11610
+ ok("workflow.run", {
11611
+ message: options.fromNode ? `Workflow run started from node ${options.fromNode}` : "Workflow run started",
11489
11612
  runId: result.runId,
11490
11613
  workflowId: result.workflowId,
11491
- title: result.title,
11492
- status: result.status,
11493
- progress: {
11494
- total: result.totalNodes,
11495
- executed: result.executedNodes,
11496
- failed: result.failedNodes
11497
- },
11498
- timing: {
11499
- startedAt: result.startedAt,
11500
- finishedAt: result.finishedAt,
11501
- durationMs: result.durationMs
11502
- },
11503
- nodes: result.nodes,
11504
- errors: result.errors
11505
- });
11506
- } catch (error) {
11507
- if (error instanceof CLIError) {
11508
- fail(error.code, error.message, { details: error.details, hint: error.hint });
11509
- }
11510
- fail(
11511
- ErrorCodes.INTERNAL_ERROR,
11512
- error instanceof Error ? error.message : "Failed to get workflow run detail"
11513
- );
11514
- }
11515
- });
11516
-
11517
- // src/commands/workflow/run-node.ts
11518
- init_cjs_shims();
11519
- var workflowRunNodeCommand = new Command("node").description("Get detailed execution result for a specific node").argument("<runId>", "Workflow run ID").argument("<nodeId>", "Node ID").option("--include-messages", "Include AI conversation messages").option("--raw", "Disable output sanitization (show full tool outputs)").action(async (runId, nodeId, options) => {
11520
- try {
11521
- const params = new URLSearchParams();
11522
- if (options.includeMessages) {
11523
- params.set("includeMessages", "true");
11524
- }
11525
- if (options.raw) {
11526
- params.set("sanitizeForDisplay", "false");
11527
- }
11528
- const queryString = params.toString();
11529
- const url = `/v1/cli/workflow/run/${runId}/node/${nodeId}${queryString ? `?${queryString}` : ""}`;
11530
- const result = await apiRequest(url);
11531
- ok("workflow.node.result", {
11532
- nodeId: result.nodeId,
11533
- nodeExecutionId: result.nodeExecutionId,
11534
- nodeType: result.nodeType,
11535
- title: result.title,
11536
11614
  status: result.status,
11537
- timing: {
11538
- startTime: result.startTime,
11539
- endTime: result.endTime,
11540
- durationMs: result.durationMs
11541
- },
11542
- query: result.query,
11543
- originalQuery: result.originalQuery,
11544
- resultId: result.resultId,
11545
- resultVersion: result.resultVersion,
11546
- output: result.output,
11547
- tokenUsage: result.tokenUsage,
11548
- toolCallsCount: result.toolCalls?.length ?? 0,
11549
- toolCalls: result.toolCalls,
11550
- messages: result.messages,
11551
- error: result.error
11615
+ startNode: options.fromNode || void 0,
11616
+ createdAt: result.createdAt,
11617
+ nextStep: `Check status with \`refly workflow status ${workflowId}\``
11552
11618
  });
11553
11619
  } catch (error) {
11554
11620
  if (error instanceof CLIError) {
@@ -11556,92 +11622,42 @@ var workflowRunNodeCommand = new Command("node").description("Get detailed execu
11556
11622
  }
11557
11623
  fail(
11558
11624
  ErrorCodes.INTERNAL_ERROR,
11559
- error instanceof Error ? error.message : "Failed to get node result"
11625
+ error instanceof Error ? error.message : "Failed to run workflow"
11560
11626
  );
11561
11627
  }
11562
11628
  });
11563
11629
 
11564
- // src/commands/workflow/run-toolcalls.ts
11630
+ // src/commands/workflow/runs.ts
11565
11631
  init_cjs_shims();
11566
- var workflowRunToolcallsCommand = new Command("toolcalls").description("Get all tool calls for a workflow run").argument("<runId>", "Workflow run ID").option("--node-id <nodeId>", "Filter by node ID").option("--toolset-id <toolsetId>", "Filter by toolset ID").option("--tool-name <toolName>", "Filter by tool name").option("--status <status>", "Filter by status (executing, completed, failed)").option("--limit <limit>", "Maximum number of results (default: 100)", "100").option("--offset <offset>", "Pagination offset (default: 0)", "0").option("--raw", "Disable output sanitization (show full tool outputs)").action(async (runId, options) => {
11632
+ var workflowRunsCommand = new Command("runs").description("List workflow execution history").argument("<workflowId>", "Workflow ID").option("--limit <limit>", "Maximum number of runs to return (default: 20)", "20").option("--offset <offset>", "Pagination offset (default: 0)", "0").option("--status <status>", "Filter by status (init, executing, finish, failed)").action(async (workflowId, options) => {
11567
11633
  try {
11568
11634
  const params = new URLSearchParams();
11569
- if (options.nodeId) {
11570
- params.set("nodeId", options.nodeId);
11571
- }
11572
- if (options.toolsetId) {
11573
- params.set("toolsetId", options.toolsetId);
11574
- }
11575
- if (options.toolName) {
11576
- params.set("toolName", options.toolName);
11577
- }
11578
- if (options.status) {
11579
- params.set("status", options.status);
11580
- }
11581
11635
  if (options.limit) {
11582
11636
  params.set("limit", options.limit);
11583
11637
  }
11584
11638
  if (options.offset) {
11585
11639
  params.set("offset", options.offset);
11586
11640
  }
11587
- if (options.raw) {
11588
- params.set("sanitizeForDisplay", "false");
11641
+ if (options.status) {
11642
+ params.set("status", options.status);
11589
11643
  }
11590
11644
  const queryString = params.toString();
11591
- const url = `/v1/cli/workflow/run/${runId}/toolcalls${queryString ? `?${queryString}` : ""}`;
11645
+ const url = `/v1/cli/workflow/${workflowId}/runs${queryString ? `?${queryString}` : ""}`;
11592
11646
  const result = await apiRequest(url);
11593
- ok("workflow.toolcalls", {
11594
- runId: result.runId,
11595
- totalCount: result.totalCount,
11596
- toolCalls: result.toolCalls,
11597
- summary: {
11598
- byStatus: result.byStatus,
11599
- byToolset: result.byToolset,
11600
- byTool: result.byTool
11601
- }
11602
- });
11603
- } catch (error) {
11604
- if (error instanceof CLIError) {
11605
- fail(error.code, error.message, { details: error.details, hint: error.hint });
11606
- }
11607
- fail(
11608
- ErrorCodes.INTERNAL_ERROR,
11609
- error instanceof Error ? error.message : "Failed to get workflow tool calls"
11610
- );
11611
- }
11612
- });
11613
-
11614
- // src/commands/workflow/run.ts
11615
- var workflowRunCommand = new Command("run").description("Run workflows and get execution results").argument("[workflowId]", "Workflow ID to run").option("--input <json>", "Input variables as JSON", "{}").option("--from-node <nodeId>", "Start workflow execution from a specific node (Run From Here)").action(async (workflowId, options) => {
11616
- if (!workflowId) {
11617
- workflowRunCommand.help();
11618
- return;
11619
- }
11620
- try {
11621
- let input;
11622
- try {
11623
- input = JSON.parse(options.input);
11624
- } catch {
11625
- fail(ErrorCodes.INVALID_INPUT, "Invalid JSON in --input", {
11626
- hint: "Ensure the input is valid JSON"
11627
- });
11628
- }
11629
- const body = { input };
11630
- if (options.fromNode) {
11631
- body.startNodes = [options.fromNode];
11632
- }
11633
- const result = await apiRequest(`/v1/cli/workflow/${workflowId}/run`, {
11634
- method: "POST",
11635
- body
11636
- });
11637
- ok("workflow.run", {
11638
- message: options.fromNode ? `Workflow run started from node ${options.fromNode}` : "Workflow run started",
11639
- runId: result.runId,
11647
+ ok("workflow.runs", {
11640
11648
  workflowId: result.workflowId,
11641
- status: result.status,
11642
- startNode: options.fromNode || void 0,
11643
- createdAt: result.createdAt,
11644
- nextStep: `Check status with \`refly workflow status ${result.runId}\``
11649
+ total: result.total,
11650
+ hasActiveRun: result.hasActiveRun,
11651
+ activeRunId: result.activeRunId,
11652
+ runs: result.runs.map((run) => ({
11653
+ runId: run.runId,
11654
+ status: run.status,
11655
+ progress: `${run.executedNodes}/${run.totalNodes}`,
11656
+ failedNodes: run.failedNodes,
11657
+ startedAt: run.startedAt,
11658
+ finishedAt: run.finishedAt,
11659
+ durationMs: run.durationMs
11660
+ }))
11645
11661
  });
11646
11662
  } catch (error) {
11647
11663
  if (error instanceof CLIError) {
@@ -11649,24 +11665,21 @@ var workflowRunCommand = new Command("run").description("Run workflows and get e
11649
11665
  }
11650
11666
  fail(
11651
11667
  ErrorCodes.INTERNAL_ERROR,
11652
- error instanceof Error ? error.message : "Failed to run workflow"
11668
+ error instanceof Error ? error.message : "Failed to get workflow runs"
11653
11669
  );
11654
11670
  }
11655
11671
  });
11656
- workflowRunCommand.addCommand(workflowRunDetailCommand);
11657
- workflowRunCommand.addCommand(workflowRunNodeCommand);
11658
- workflowRunCommand.addCommand(workflowRunToolcallsCommand);
11659
11672
 
11660
11673
  // src/commands/workflow/abort.ts
11661
11674
  init_cjs_shims();
11662
- var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<runId>", "Run ID").action(async (runId) => {
11675
+ var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<workflowId>", "Workflow ID").action(async (workflowId) => {
11663
11676
  try {
11664
- await apiRequest(`/v1/cli/workflow/run/${runId}/abort`, {
11677
+ await apiRequest(`/v1/cli/workflow/${workflowId}/abort`, {
11665
11678
  method: "POST"
11666
11679
  });
11667
11680
  ok("workflow.abort", {
11668
11681
  message: "Workflow run aborted",
11669
- runId
11682
+ workflowId
11670
11683
  });
11671
11684
  } catch (error) {
11672
11685
  if (error instanceof CLIError) {
@@ -11723,7 +11736,7 @@ function generateSummary(changedNodes) {
11723
11736
  }
11724
11737
  return summaries.join("; ") || `${changedNodes.length} node(s) updated`;
11725
11738
  }
11726
- var workflowStatusCommand = new Command("status").description("Get detailed workflow execution status").argument("<runId>", "Workflow run ID").option("--watch", "Watch mode: continuously poll until completion").option("--interval <ms>", "Poll interval in ms (default: 2000)", "2000").option("--full", "In watch mode, output full status every time (not just changes)").action(async (runId, options) => {
11739
+ var workflowStatusCommand = new Command("status").description("Get detailed workflow execution status").argument("<workflowId>", "Workflow ID").option("--watch", "Watch mode: continuously poll until completion").option("--interval <ms>", "Poll interval in ms (default: 2000)", "2000").option("--full", "In watch mode, output full status every time (not just changes)").action(async (workflowId, options) => {
11727
11740
  try {
11728
11741
  const pollInterval = Number.parseInt(options.interval, 10);
11729
11742
  if (Number.isNaN(pollInterval) || pollInterval <= 0) {
@@ -11732,7 +11745,7 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
11732
11745
  });
11733
11746
  }
11734
11747
  const fetchStatus = async () => {
11735
- return await apiRequest(`/v1/cli/workflow/run/${runId}`);
11748
+ return await apiRequest(`/v1/cli/workflow/${workflowId}/status`);
11736
11749
  };
11737
11750
  if (options.watch) {
11738
11751
  let prevStatus = null;
@@ -11789,6 +11802,100 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
11789
11802
  }
11790
11803
  });
11791
11804
 
11805
+ // src/commands/workflow/detail.ts
11806
+ init_cjs_shims();
11807
+ var workflowDetailCommand = new Command("detail").description("Get detailed workflow execution information including all node results").argument("<workflowId>", "Workflow ID").option("--no-tool-calls", "Exclude tool call summaries").option("--preview-length <length>", "Output preview length (default: 500)", "500").action(async (workflowId, options) => {
11808
+ try {
11809
+ const params = new URLSearchParams();
11810
+ if (options.toolCalls === false) {
11811
+ params.set("includeToolCalls", "false");
11812
+ }
11813
+ if (options.previewLength) {
11814
+ params.set("outputPreviewLength", options.previewLength);
11815
+ }
11816
+ const queryString = params.toString();
11817
+ const url = `/v1/cli/workflow/${workflowId}/detail${queryString ? `?${queryString}` : ""}`;
11818
+ const result = await apiRequest(url);
11819
+ ok("workflow.detail", {
11820
+ runId: result.runId,
11821
+ workflowId: result.workflowId,
11822
+ title: result.title,
11823
+ status: result.status,
11824
+ progress: {
11825
+ total: result.totalNodes,
11826
+ executed: result.executedNodes,
11827
+ failed: result.failedNodes
11828
+ },
11829
+ timing: {
11830
+ startedAt: result.startedAt,
11831
+ finishedAt: result.finishedAt,
11832
+ durationMs: result.durationMs
11833
+ },
11834
+ nodes: result.nodes,
11835
+ errors: result.errors
11836
+ });
11837
+ } catch (error) {
11838
+ if (error instanceof CLIError) {
11839
+ fail(error.code, error.message, { details: error.details, hint: error.hint });
11840
+ }
11841
+ fail(
11842
+ ErrorCodes.INTERNAL_ERROR,
11843
+ error instanceof Error ? error.message : "Failed to get workflow detail"
11844
+ );
11845
+ }
11846
+ });
11847
+
11848
+ // src/commands/workflow/toolcalls.ts
11849
+ init_cjs_shims();
11850
+ var workflowToolcallsCommand = new Command("toolcalls").description("Get all tool calls for the current workflow execution").argument("<workflowId>", "Workflow ID").option("--node-id <nodeId>", "Filter by node ID").option("--toolset-id <toolsetId>", "Filter by toolset ID").option("--tool-name <toolName>", "Filter by tool name").option("--status <status>", "Filter by status (executing, completed, failed)").option("--limit <limit>", "Maximum number of results (default: 100)", "100").option("--offset <offset>", "Pagination offset (default: 0)", "0").option("--raw", "Disable output sanitization (show full tool outputs)").action(async (workflowId, options) => {
11851
+ try {
11852
+ const params = new URLSearchParams();
11853
+ if (options.nodeId) {
11854
+ params.set("nodeId", options.nodeId);
11855
+ }
11856
+ if (options.toolsetId) {
11857
+ params.set("toolsetId", options.toolsetId);
11858
+ }
11859
+ if (options.toolName) {
11860
+ params.set("toolName", options.toolName);
11861
+ }
11862
+ if (options.status) {
11863
+ params.set("status", options.status);
11864
+ }
11865
+ if (options.limit) {
11866
+ params.set("limit", options.limit);
11867
+ }
11868
+ if (options.offset) {
11869
+ params.set("offset", options.offset);
11870
+ }
11871
+ if (options.raw) {
11872
+ params.set("sanitizeForDisplay", "false");
11873
+ }
11874
+ const queryString = params.toString();
11875
+ const url = `/v1/cli/workflow/${workflowId}/toolcalls${queryString ? `?${queryString}` : ""}`;
11876
+ const result = await apiRequest(url);
11877
+ ok("workflow.toolcalls", {
11878
+ runId: result.runId,
11879
+ workflowId: result.workflowId,
11880
+ totalCount: result.totalCount,
11881
+ toolCalls: result.toolCalls,
11882
+ summary: {
11883
+ byStatus: result.byStatus,
11884
+ byToolset: result.byToolset,
11885
+ byTool: result.byTool
11886
+ }
11887
+ });
11888
+ } catch (error) {
11889
+ if (error instanceof CLIError) {
11890
+ fail(error.code, error.message, { details: error.details, hint: error.hint });
11891
+ }
11892
+ fail(
11893
+ ErrorCodes.INTERNAL_ERROR,
11894
+ error instanceof Error ? error.message : "Failed to get workflow tool calls"
11895
+ );
11896
+ }
11897
+ });
11898
+
11792
11899
  // src/commands/workflow/toolset-keys.ts
11793
11900
  init_cjs_shims();
11794
11901
  var workflowToolsetKeysCommand = new Command("toolset-keys").description("List available toolset inventory keys for use with --toolsets").option("--type <type>", 'Filter by toolset type (e.g., "regular", "external_oauth")').action(async (options) => {
@@ -11861,16 +11968,116 @@ var workflowLayoutCommand = new Command("layout").description("Auto-layout workf
11861
11968
  }
11862
11969
  });
11863
11970
 
11971
+ // src/commands/workflow/nodes.ts
11972
+ init_cjs_shims();
11973
+ var workflowNodesCommand = new Command("nodes").description("List all nodes in a workflow").argument("<workflowId>", "Workflow ID").option("--include-edges", "Include edge/connection information").option("--include-position", "Include node position coordinates").option("--include-metadata", "Include full node metadata").action(async (workflowId, options) => {
11974
+ try {
11975
+ const result = await apiRequest(`/v1/cli/workflow/${workflowId}`);
11976
+ const nodes = result.nodes.map((node) => {
11977
+ const output2 = {
11978
+ id: node.id,
11979
+ type: node.type,
11980
+ title: node.data?.title || node.data?.metadata?.title || void 0
11981
+ };
11982
+ if (options.includePosition && node.position) {
11983
+ output2.position = node.position;
11984
+ }
11985
+ if (options.includeMetadata && node.data?.metadata) {
11986
+ output2.metadata = node.data.metadata;
11987
+ }
11988
+ return output2;
11989
+ });
11990
+ const output = {
11991
+ workflowId: result.workflowId,
11992
+ workflowName: result.name,
11993
+ nodeCount: nodes.length,
11994
+ nodes
11995
+ };
11996
+ if (options.includeEdges && result.edges?.length) {
11997
+ output.edges = result.edges.map((edge) => ({
11998
+ id: edge.id,
11999
+ source: edge.source,
12000
+ target: edge.target,
12001
+ sourceHandle: edge.sourceHandle,
12002
+ targetHandle: edge.targetHandle
12003
+ }));
12004
+ output.edgeCount = result.edges.length;
12005
+ }
12006
+ ok("workflow.nodes", output);
12007
+ } catch (error) {
12008
+ if (error instanceof CLIError) {
12009
+ fail(error.code, error.message, { details: error.details, hint: error.hint });
12010
+ }
12011
+ fail(
12012
+ ErrorCodes.INTERNAL_ERROR,
12013
+ error instanceof Error ? error.message : "Failed to get workflow nodes"
12014
+ );
12015
+ }
12016
+ });
12017
+
12018
+ // src/commands/workflow/node-get.ts
12019
+ init_cjs_shims();
12020
+ var workflowNodeGetCommand = new Command("node").description("Get single node information from a workflow").argument("<workflowId>", "Workflow ID").argument("<nodeId>", "Node ID").option("--include-connections", "Include incoming and outgoing connections").action(async (workflowId, nodeId, options) => {
12021
+ try {
12022
+ const result = await apiRequest(`/v1/cli/workflow/${workflowId}`);
12023
+ const node = result.nodes.find((n) => n.id === nodeId);
12024
+ if (!node) {
12025
+ fail(ErrorCodes.NODE_NOT_FOUND, `Node ${nodeId} not found in workflow ${workflowId}`, {
12026
+ hint: `Use 'refly workflow nodes ${workflowId}' to list all nodes`
12027
+ });
12028
+ }
12029
+ const output = {
12030
+ workflowId: result.workflowId,
12031
+ workflowName: result.name,
12032
+ node: {
12033
+ id: node.id,
12034
+ type: node.type,
12035
+ title: node.data?.title || node.data?.metadata?.title || void 0,
12036
+ position: node.position,
12037
+ metadata: node.data?.metadata || {},
12038
+ data: node.data
12039
+ }
12040
+ };
12041
+ if (options.includeConnections && result.edges?.length) {
12042
+ const incoming = result.edges.filter((e) => e.target === nodeId).map((e) => ({
12043
+ from: e.source,
12044
+ sourceHandle: e.sourceHandle,
12045
+ targetHandle: e.targetHandle
12046
+ }));
12047
+ const outgoing = result.edges.filter((e) => e.source === nodeId).map((e) => ({
12048
+ to: e.target,
12049
+ sourceHandle: e.sourceHandle,
12050
+ targetHandle: e.targetHandle
12051
+ }));
12052
+ output.connections = {
12053
+ incoming,
12054
+ outgoing,
12055
+ incomingCount: incoming.length,
12056
+ outgoingCount: outgoing.length
12057
+ };
12058
+ }
12059
+ ok("workflow.node", output);
12060
+ } catch (error) {
12061
+ if (error instanceof CLIError) {
12062
+ fail(error.code, error.message, { details: error.details, hint: error.hint });
12063
+ }
12064
+ fail(
12065
+ ErrorCodes.INTERNAL_ERROR,
12066
+ error instanceof Error ? error.message : "Failed to get node information"
12067
+ );
12068
+ }
12069
+ });
12070
+
11864
12071
  // src/commands/workflow/index.ts
11865
- var workflowCommand = new Command("workflow").description("Manage and run workflows").addCommand(workflowCreateCommand).addCommand(workflowGenerateCommand).addCommand(workflowListCommand).addCommand(workflowGetCommand).addCommand(workflowEditCommand).addCommand(workflowDeleteCommand).addCommand(workflowRunCommand).addCommand(workflowAbortCommand).addCommand(workflowStatusCommand).addCommand(workflowToolsetKeysCommand).addCommand(workflowLayoutCommand);
12072
+ var workflowCommand = new Command("workflow").description("Manage and run workflows").addCommand(workflowCreateCommand).addCommand(workflowGenerateCommand).addCommand(workflowListCommand).addCommand(workflowGetCommand).addCommand(workflowEditCommand).addCommand(workflowDeleteCommand).addCommand(workflowRunCommand).addCommand(workflowRunsCommand).addCommand(workflowStatusCommand).addCommand(workflowDetailCommand).addCommand(workflowToolcallsCommand).addCommand(workflowAbortCommand).addCommand(workflowToolsetKeysCommand).addCommand(workflowLayoutCommand).addCommand(workflowNodesCommand).addCommand(workflowNodeGetCommand);
11866
12073
 
11867
12074
  // src/commands/node/index.ts
11868
12075
  init_cjs_shims();
11869
12076
 
11870
12077
  // src/commands/node/types.ts
11871
12078
  init_cjs_shims();
11872
- var fs11 = __toESM(require("fs"));
11873
- var path7 = __toESM(require("path"));
12079
+ var fs12 = __toESM(require("fs"));
12080
+ var path8 = __toESM(require("path"));
11874
12081
  init_paths();
11875
12082
  var CACHE_FILE = "node-types.json";
11876
12083
  var CACHE_TTL = 24 * 60 * 60 * 1e3;
@@ -11909,20 +12116,20 @@ var nodeTypesCommand = new Command("types").description("List available node typ
11909
12116
  }
11910
12117
  });
11911
12118
  function getCachePath() {
11912
- return path7.join(getCacheDir(), CACHE_FILE);
12119
+ return path8.join(getCacheDir(), CACHE_FILE);
11913
12120
  }
11914
12121
  function loadFromCache() {
11915
12122
  try {
11916
12123
  const cachePath = getCachePath();
11917
- if (!fs11.existsSync(cachePath)) {
12124
+ if (!fs12.existsSync(cachePath)) {
11918
12125
  return null;
11919
12126
  }
11920
- const stat = fs11.statSync(cachePath);
12127
+ const stat = fs12.statSync(cachePath);
11921
12128
  const age = Date.now() - stat.mtimeMs;
11922
12129
  if (age > CACHE_TTL) {
11923
12130
  return null;
11924
12131
  }
11925
- const content = fs11.readFileSync(cachePath, "utf-8");
12132
+ const content = fs12.readFileSync(cachePath, "utf-8");
11926
12133
  return JSON.parse(content);
11927
12134
  } catch {
11928
12135
  return null;
@@ -11932,7 +12139,7 @@ async function fetchAndCache() {
11932
12139
  const data = await apiRequest("/v1/cli/node/types");
11933
12140
  try {
11934
12141
  const cachePath = getCachePath();
11935
- fs11.writeFileSync(cachePath, JSON.stringify(data, null, 2));
12142
+ fs12.writeFileSync(cachePath, JSON.stringify(data, null, 2));
11936
12143
  } catch {
11937
12144
  }
11938
12145
  return data;
@@ -12078,8 +12285,35 @@ var nodeResultCommand = new Command("result").description("Get node execution re
12078
12285
  }
12079
12286
  });
12080
12287
 
12288
+ // src/commands/node/abort.ts
12289
+ init_cjs_shims();
12290
+ var nodeAbortCommand = new Command("abort").description("Abort a running node execution").argument("<resultId>", "Node result ID to abort").option("--version <number>", "Specific version to abort", Number.parseInt).action(async (resultId, options) => {
12291
+ try {
12292
+ const body = { resultId };
12293
+ if (options.version !== void 0) {
12294
+ body.version = options.version;
12295
+ }
12296
+ const result = await apiRequest("/v1/cli/action/abort", {
12297
+ method: "POST",
12298
+ body
12299
+ });
12300
+ ok("node.abort", {
12301
+ message: result.message,
12302
+ resultId: result.resultId
12303
+ });
12304
+ } catch (error) {
12305
+ if (error instanceof CLIError) {
12306
+ fail(error.code, error.message, { details: error.details, hint: error.hint });
12307
+ }
12308
+ fail(
12309
+ ErrorCodes.INTERNAL_ERROR,
12310
+ error instanceof Error ? error.message : "Failed to abort node execution"
12311
+ );
12312
+ }
12313
+ });
12314
+
12081
12315
  // src/commands/node/index.ts
12082
- var nodeCommand = new Command("node").description("Node operations: types, run, and execution results").addCommand(nodeTypesCommand).addCommand(nodeRunCommand).addCommand(nodeResultCommand);
12316
+ var nodeCommand = new Command("node").description("Node operations: types, run, abort, and execution results").addCommand(nodeTypesCommand).addCommand(nodeRunCommand).addCommand(nodeResultCommand).addCommand(nodeAbortCommand);
12083
12317
 
12084
12318
  // src/commands/tool/index.ts
12085
12319
  init_cjs_shims();
@@ -12243,16 +12477,16 @@ var fileGetCommand = new Command("get").description("Get file details").argument
12243
12477
 
12244
12478
  // src/commands/file/download.ts
12245
12479
  init_cjs_shims();
12246
- var fs12 = __toESM(require("fs"));
12247
- var path8 = __toESM(require("path"));
12480
+ var fs13 = __toESM(require("fs"));
12481
+ var path9 = __toESM(require("path"));
12248
12482
  var fileDownloadCommand = new Command("download").description("Download file to local filesystem").argument("<fileId>", "File ID").option("-o, --output <path>", "Output file path (defaults to original filename)").action(async (fileId, options) => {
12249
12483
  try {
12250
12484
  const { data, filename, contentType, size } = await apiRequestStream(
12251
12485
  `/v1/cli/drive/files/${fileId}/download`
12252
12486
  );
12253
12487
  const outputPath = options.output || filename || `${fileId}`;
12254
- const resolvedPath = path8.resolve(outputPath);
12255
- fs12.writeFileSync(resolvedPath, data);
12488
+ const resolvedPath = path9.resolve(outputPath);
12489
+ fs13.writeFileSync(resolvedPath, data);
12256
12490
  ok("file.download", {
12257
12491
  fileId,
12258
12492
  path: resolvedPath,
@@ -12277,8 +12511,8 @@ var fileCommand = new Command("file").description("Manage files and documents").
12277
12511
  // src/bin/refly.ts
12278
12512
  function getVersion() {
12279
12513
  try {
12280
- const pkgPath = path9.join(__dirname, "..", "..", "package.json");
12281
- const pkg = JSON.parse(fs13.readFileSync(pkgPath, "utf-8"));
12514
+ const pkgPath = path10.join(__dirname, "..", "..", "package.json");
12515
+ const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
12282
12516
  return pkg.version || "0.1.0";
12283
12517
  } catch {
12284
12518
  return "0.1.0";