@powerformer/refly-cli 0.1.7 → 0.1.9
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 +211 -222
- package/dist/bin/refly.js.map +1 -1
- package/package.json +1 -1
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
|
|
993
|
-
var
|
|
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 =
|
|
1926
|
-
if (
|
|
1927
|
-
if (sourceExt.includes(
|
|
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) =>
|
|
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 =
|
|
1941
|
+
resolvedScriptPath = fs15.realpathSync(this._scriptPath);
|
|
1942
1942
|
} catch (err) {
|
|
1943
1943
|
resolvedScriptPath = this._scriptPath;
|
|
1944
1944
|
}
|
|
1945
|
-
executableDir =
|
|
1946
|
-
|
|
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 =
|
|
1953
|
+
const legacyName = path11.basename(
|
|
1954
1954
|
this._scriptPath,
|
|
1955
|
-
|
|
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(
|
|
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 =
|
|
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(
|
|
2821
|
-
if (
|
|
2822
|
-
this._executableDir =
|
|
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
|
|
4442
|
-
var
|
|
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:
|
|
4954
|
-
const fullPath = [...
|
|
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,
|
|
5074
|
+
constructor(parent, value, path11, key) {
|
|
5075
5075
|
this._cachedPath = [];
|
|
5076
5076
|
this.parent = parent;
|
|
5077
5077
|
this.data = value;
|
|
5078
|
-
this._path =
|
|
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(
|
|
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}${
|
|
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} ${
|
|
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(
|
|
9470
|
+
async function apiRequestStream(path11, options = {}) {
|
|
9471
9471
|
const { timeout = 3e5 } = options;
|
|
9472
9472
|
const endpoint = getApiEndpoint();
|
|
9473
|
-
const url = `${endpoint}${
|
|
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 ${
|
|
9504
|
+
logger.debug(`API Stream Request: GET ${path11}`);
|
|
9505
9505
|
const response = await fetch(url, {
|
|
9506
9506
|
method: "GET",
|
|
9507
9507
|
headers,
|
|
@@ -10081,14 +10081,15 @@ var whoamiCommand = new Command("whoami").description("Show current authenticate
|
|
|
10081
10081
|
// src/commands/upgrade.ts
|
|
10082
10082
|
init_cjs_shims();
|
|
10083
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"));
|
|
10084
10086
|
init_logger();
|
|
10085
10087
|
var PACKAGE_NAME = "@powerformer/refly-cli";
|
|
10086
10088
|
function getCurrentVersion() {
|
|
10087
10089
|
try {
|
|
10088
|
-
const pkgPath =
|
|
10089
|
-
const
|
|
10090
|
-
|
|
10091
|
-
);
|
|
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);
|
|
10092
10093
|
return pkg.version;
|
|
10093
10094
|
} catch {
|
|
10094
10095
|
return "0.1.0";
|
|
@@ -10186,7 +10187,6 @@ var upgradeCommand = new Command("upgrade").description("Upgrade CLI to latest v
|
|
|
10186
10187
|
}
|
|
10187
10188
|
let skillResult = null;
|
|
10188
10189
|
if (!cliOnly) {
|
|
10189
|
-
const beforeStatus = isSkillInstalled();
|
|
10190
10190
|
skillResult = installSkill();
|
|
10191
10191
|
}
|
|
10192
10192
|
const newVersionInfo = await checkVersion();
|
|
@@ -10304,16 +10304,16 @@ configCommand.action(() => {
|
|
|
10304
10304
|
};
|
|
10305
10305
|
ok("config", safeConfig);
|
|
10306
10306
|
});
|
|
10307
|
-
function getNestedValue(obj,
|
|
10308
|
-
return
|
|
10307
|
+
function getNestedValue(obj, path11) {
|
|
10308
|
+
return path11.split(".").reduce((current, key) => {
|
|
10309
10309
|
if (current && typeof current === "object" && key in current) {
|
|
10310
10310
|
return current[key];
|
|
10311
10311
|
}
|
|
10312
10312
|
return void 0;
|
|
10313
10313
|
}, obj);
|
|
10314
10314
|
}
|
|
10315
|
-
function setNestedValue(obj,
|
|
10316
|
-
const keys =
|
|
10315
|
+
function setNestedValue(obj, path11, value) {
|
|
10316
|
+
const keys = path11.split(".");
|
|
10317
10317
|
const lastKey = keys.pop();
|
|
10318
10318
|
let current = obj;
|
|
10319
10319
|
for (const key of keys) {
|
|
@@ -10333,8 +10333,8 @@ init_cjs_shims();
|
|
|
10333
10333
|
|
|
10334
10334
|
// src/builder/store.ts
|
|
10335
10335
|
init_cjs_shims();
|
|
10336
|
-
var
|
|
10337
|
-
var
|
|
10336
|
+
var fs11 = __toESM(require("fs"));
|
|
10337
|
+
var path7 = __toESM(require("path"));
|
|
10338
10338
|
var crypto2 = __toESM(require("crypto"));
|
|
10339
10339
|
init_paths();
|
|
10340
10340
|
|
|
@@ -10411,21 +10411,21 @@ function createSession(name, description) {
|
|
|
10411
10411
|
}
|
|
10412
10412
|
function saveSession(session) {
|
|
10413
10413
|
const sessionPath = getSessionPath(session.id);
|
|
10414
|
-
const tempPath =
|
|
10414
|
+
const tempPath = path7.join(getBuilderDir(), `.session-${session.id}-${Date.now()}.tmp`);
|
|
10415
10415
|
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
10416
10416
|
const validated = BuilderSessionSchema.parse(session);
|
|
10417
|
-
|
|
10417
|
+
fs11.writeFileSync(tempPath, JSON.stringify(validated, null, 2), {
|
|
10418
10418
|
mode: 384
|
|
10419
10419
|
});
|
|
10420
|
-
|
|
10420
|
+
fs11.renameSync(tempPath, sessionPath);
|
|
10421
10421
|
}
|
|
10422
10422
|
function loadSession(sessionId) {
|
|
10423
10423
|
const sessionPath = getSessionPath(sessionId);
|
|
10424
10424
|
try {
|
|
10425
|
-
if (!
|
|
10425
|
+
if (!fs11.existsSync(sessionPath)) {
|
|
10426
10426
|
return null;
|
|
10427
10427
|
}
|
|
10428
|
-
const content =
|
|
10428
|
+
const content = fs11.readFileSync(sessionPath, "utf-8");
|
|
10429
10429
|
const parsed = JSON.parse(content);
|
|
10430
10430
|
return BuilderSessionSchema.parse(parsed);
|
|
10431
10431
|
} catch {
|
|
@@ -10435,8 +10435,8 @@ function loadSession(sessionId) {
|
|
|
10435
10435
|
function deleteSession(sessionId) {
|
|
10436
10436
|
const sessionPath = getSessionPath(sessionId);
|
|
10437
10437
|
try {
|
|
10438
|
-
if (
|
|
10439
|
-
|
|
10438
|
+
if (fs11.existsSync(sessionPath)) {
|
|
10439
|
+
fs11.unlinkSync(sessionPath);
|
|
10440
10440
|
}
|
|
10441
10441
|
} catch {
|
|
10442
10442
|
}
|
|
@@ -10445,22 +10445,22 @@ function setCurrent(sessionId) {
|
|
|
10445
10445
|
const currentPath = getCurrentSessionPath();
|
|
10446
10446
|
if (sessionId === null) {
|
|
10447
10447
|
try {
|
|
10448
|
-
if (
|
|
10449
|
-
|
|
10448
|
+
if (fs11.existsSync(currentPath)) {
|
|
10449
|
+
fs11.unlinkSync(currentPath);
|
|
10450
10450
|
}
|
|
10451
10451
|
} catch {
|
|
10452
10452
|
}
|
|
10453
10453
|
return;
|
|
10454
10454
|
}
|
|
10455
|
-
|
|
10455
|
+
fs11.writeFileSync(currentPath, sessionId, { mode: 384 });
|
|
10456
10456
|
}
|
|
10457
10457
|
function getCurrentSessionId() {
|
|
10458
10458
|
const currentPath = getCurrentSessionPath();
|
|
10459
10459
|
try {
|
|
10460
|
-
if (!
|
|
10460
|
+
if (!fs11.existsSync(currentPath)) {
|
|
10461
10461
|
return null;
|
|
10462
10462
|
}
|
|
10463
|
-
return
|
|
10463
|
+
return fs11.readFileSync(currentPath, "utf-8").trim();
|
|
10464
10464
|
} catch {
|
|
10465
10465
|
return null;
|
|
10466
10466
|
}
|
|
@@ -11134,18 +11134,18 @@ function detectCycles(nodes) {
|
|
|
11134
11134
|
}
|
|
11135
11135
|
const visited = /* @__PURE__ */ new Set();
|
|
11136
11136
|
const recursionStack = /* @__PURE__ */ new Set();
|
|
11137
|
-
const
|
|
11137
|
+
const path11 = [];
|
|
11138
11138
|
function dfs(nodeId) {
|
|
11139
11139
|
if (recursionStack.has(nodeId)) {
|
|
11140
|
-
const cycleStart =
|
|
11141
|
-
return [...
|
|
11140
|
+
const cycleStart = path11.indexOf(nodeId);
|
|
11141
|
+
return [...path11.slice(cycleStart), nodeId];
|
|
11142
11142
|
}
|
|
11143
11143
|
if (visited.has(nodeId)) {
|
|
11144
11144
|
return null;
|
|
11145
11145
|
}
|
|
11146
11146
|
visited.add(nodeId);
|
|
11147
11147
|
recursionStack.add(nodeId);
|
|
11148
|
-
|
|
11148
|
+
path11.push(nodeId);
|
|
11149
11149
|
const node = nodeMap.get(nodeId);
|
|
11150
11150
|
if (node) {
|
|
11151
11151
|
for (const depId of node.dependsOn) {
|
|
@@ -11155,7 +11155,7 @@ function detectCycles(nodes) {
|
|
|
11155
11155
|
}
|
|
11156
11156
|
}
|
|
11157
11157
|
}
|
|
11158
|
-
|
|
11158
|
+
path11.pop();
|
|
11159
11159
|
recursionStack.delete(nodeId);
|
|
11160
11160
|
return null;
|
|
11161
11161
|
}
|
|
@@ -11302,7 +11302,8 @@ var workflowCreateCommand = new Command("create").description("Create a workflow
|
|
|
11302
11302
|
try {
|
|
11303
11303
|
let spec;
|
|
11304
11304
|
try {
|
|
11305
|
-
|
|
11305
|
+
const parsed = JSON.parse(options.spec);
|
|
11306
|
+
spec = Array.isArray(parsed) ? { nodes: parsed } : parsed;
|
|
11306
11307
|
} catch {
|
|
11307
11308
|
fail(ErrorCodes.INVALID_INPUT, "Invalid JSON in --spec", {
|
|
11308
11309
|
hint: "Ensure the spec is valid JSON"
|
|
@@ -11589,85 +11590,32 @@ var workflowDeleteCommand = new Command("delete").description("Delete a workflow
|
|
|
11589
11590
|
|
|
11590
11591
|
// src/commands/workflow/run.ts
|
|
11591
11592
|
init_cjs_shims();
|
|
11592
|
-
|
|
11593
|
-
// src/commands/workflow/run-detail.ts
|
|
11594
|
-
init_cjs_shims();
|
|
11595
|
-
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) => {
|
|
11593
|
+
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) => {
|
|
11596
11594
|
try {
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11595
|
+
let input;
|
|
11596
|
+
try {
|
|
11597
|
+
input = JSON.parse(options.input);
|
|
11598
|
+
} catch {
|
|
11599
|
+
fail(ErrorCodes.INVALID_INPUT, "Invalid JSON in --input", {
|
|
11600
|
+
hint: "Ensure the input is valid JSON"
|
|
11601
|
+
});
|
|
11600
11602
|
}
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
+
const body = { input };
|
|
11604
|
+
if (options.fromNode) {
|
|
11605
|
+
body.startNodes = [options.fromNode];
|
|
11603
11606
|
}
|
|
11604
|
-
const
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11607
|
+
const result = await apiRequest(`/v1/cli/workflow/${workflowId}/run`, {
|
|
11608
|
+
method: "POST",
|
|
11609
|
+
body
|
|
11610
|
+
});
|
|
11611
|
+
ok("workflow.run", {
|
|
11612
|
+
message: options.fromNode ? `Workflow run started from node ${options.fromNode}` : "Workflow run started",
|
|
11608
11613
|
runId: result.runId,
|
|
11609
11614
|
workflowId: result.workflowId,
|
|
11610
|
-
title: result.title,
|
|
11611
11615
|
status: result.status,
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
failed: result.failedNodes
|
|
11616
|
-
},
|
|
11617
|
-
timing: {
|
|
11618
|
-
startedAt: result.startedAt,
|
|
11619
|
-
finishedAt: result.finishedAt,
|
|
11620
|
-
durationMs: result.durationMs
|
|
11621
|
-
},
|
|
11622
|
-
nodes: result.nodes,
|
|
11623
|
-
errors: result.errors
|
|
11624
|
-
});
|
|
11625
|
-
} catch (error) {
|
|
11626
|
-
if (error instanceof CLIError) {
|
|
11627
|
-
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
11628
|
-
}
|
|
11629
|
-
fail(
|
|
11630
|
-
ErrorCodes.INTERNAL_ERROR,
|
|
11631
|
-
error instanceof Error ? error.message : "Failed to get workflow run detail"
|
|
11632
|
-
);
|
|
11633
|
-
}
|
|
11634
|
-
});
|
|
11635
|
-
|
|
11636
|
-
// src/commands/workflow/run-node.ts
|
|
11637
|
-
init_cjs_shims();
|
|
11638
|
-
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) => {
|
|
11639
|
-
try {
|
|
11640
|
-
const params = new URLSearchParams();
|
|
11641
|
-
if (options.includeMessages) {
|
|
11642
|
-
params.set("includeMessages", "true");
|
|
11643
|
-
}
|
|
11644
|
-
if (options.raw) {
|
|
11645
|
-
params.set("sanitizeForDisplay", "false");
|
|
11646
|
-
}
|
|
11647
|
-
const queryString = params.toString();
|
|
11648
|
-
const url = `/v1/cli/workflow/run/${runId}/node/${nodeId}${queryString ? `?${queryString}` : ""}`;
|
|
11649
|
-
const result = await apiRequest(url);
|
|
11650
|
-
ok("workflow.node.result", {
|
|
11651
|
-
nodeId: result.nodeId,
|
|
11652
|
-
nodeExecutionId: result.nodeExecutionId,
|
|
11653
|
-
nodeType: result.nodeType,
|
|
11654
|
-
title: result.title,
|
|
11655
|
-
status: result.status,
|
|
11656
|
-
timing: {
|
|
11657
|
-
startTime: result.startTime,
|
|
11658
|
-
endTime: result.endTime,
|
|
11659
|
-
durationMs: result.durationMs
|
|
11660
|
-
},
|
|
11661
|
-
query: result.query,
|
|
11662
|
-
originalQuery: result.originalQuery,
|
|
11663
|
-
resultId: result.resultId,
|
|
11664
|
-
resultVersion: result.resultVersion,
|
|
11665
|
-
output: result.output,
|
|
11666
|
-
tokenUsage: result.tokenUsage,
|
|
11667
|
-
toolCallsCount: result.toolCalls?.length ?? 0,
|
|
11668
|
-
toolCalls: result.toolCalls,
|
|
11669
|
-
messages: result.messages,
|
|
11670
|
-
error: result.error
|
|
11616
|
+
startNode: options.fromNode || void 0,
|
|
11617
|
+
createdAt: result.createdAt,
|
|
11618
|
+
nextStep: `Check status with \`refly workflow status ${workflowId}\``
|
|
11671
11619
|
});
|
|
11672
11620
|
} catch (error) {
|
|
11673
11621
|
if (error instanceof CLIError) {
|
|
@@ -11675,92 +11623,42 @@ var workflowRunNodeCommand = new Command("node").description("Get detailed execu
|
|
|
11675
11623
|
}
|
|
11676
11624
|
fail(
|
|
11677
11625
|
ErrorCodes.INTERNAL_ERROR,
|
|
11678
|
-
error instanceof Error ? error.message : "Failed to
|
|
11626
|
+
error instanceof Error ? error.message : "Failed to run workflow"
|
|
11679
11627
|
);
|
|
11680
11628
|
}
|
|
11681
11629
|
});
|
|
11682
11630
|
|
|
11683
|
-
// src/commands/workflow/
|
|
11631
|
+
// src/commands/workflow/runs.ts
|
|
11684
11632
|
init_cjs_shims();
|
|
11685
|
-
var
|
|
11633
|
+
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) => {
|
|
11686
11634
|
try {
|
|
11687
11635
|
const params = new URLSearchParams();
|
|
11688
|
-
if (options.nodeId) {
|
|
11689
|
-
params.set("nodeId", options.nodeId);
|
|
11690
|
-
}
|
|
11691
|
-
if (options.toolsetId) {
|
|
11692
|
-
params.set("toolsetId", options.toolsetId);
|
|
11693
|
-
}
|
|
11694
|
-
if (options.toolName) {
|
|
11695
|
-
params.set("toolName", options.toolName);
|
|
11696
|
-
}
|
|
11697
|
-
if (options.status) {
|
|
11698
|
-
params.set("status", options.status);
|
|
11699
|
-
}
|
|
11700
11636
|
if (options.limit) {
|
|
11701
11637
|
params.set("limit", options.limit);
|
|
11702
11638
|
}
|
|
11703
11639
|
if (options.offset) {
|
|
11704
11640
|
params.set("offset", options.offset);
|
|
11705
11641
|
}
|
|
11706
|
-
if (options.
|
|
11707
|
-
params.set("
|
|
11642
|
+
if (options.status) {
|
|
11643
|
+
params.set("status", options.status);
|
|
11708
11644
|
}
|
|
11709
11645
|
const queryString = params.toString();
|
|
11710
|
-
const url = `/v1/cli/workflow
|
|
11646
|
+
const url = `/v1/cli/workflow/${workflowId}/runs${queryString ? `?${queryString}` : ""}`;
|
|
11711
11647
|
const result = await apiRequest(url);
|
|
11712
|
-
ok("workflow.
|
|
11713
|
-
runId: result.runId,
|
|
11714
|
-
totalCount: result.totalCount,
|
|
11715
|
-
toolCalls: result.toolCalls,
|
|
11716
|
-
summary: {
|
|
11717
|
-
byStatus: result.byStatus,
|
|
11718
|
-
byToolset: result.byToolset,
|
|
11719
|
-
byTool: result.byTool
|
|
11720
|
-
}
|
|
11721
|
-
});
|
|
11722
|
-
} catch (error) {
|
|
11723
|
-
if (error instanceof CLIError) {
|
|
11724
|
-
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
11725
|
-
}
|
|
11726
|
-
fail(
|
|
11727
|
-
ErrorCodes.INTERNAL_ERROR,
|
|
11728
|
-
error instanceof Error ? error.message : "Failed to get workflow tool calls"
|
|
11729
|
-
);
|
|
11730
|
-
}
|
|
11731
|
-
});
|
|
11732
|
-
|
|
11733
|
-
// src/commands/workflow/run.ts
|
|
11734
|
-
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) => {
|
|
11735
|
-
if (!workflowId) {
|
|
11736
|
-
workflowRunCommand.help();
|
|
11737
|
-
return;
|
|
11738
|
-
}
|
|
11739
|
-
try {
|
|
11740
|
-
let input;
|
|
11741
|
-
try {
|
|
11742
|
-
input = JSON.parse(options.input);
|
|
11743
|
-
} catch {
|
|
11744
|
-
fail(ErrorCodes.INVALID_INPUT, "Invalid JSON in --input", {
|
|
11745
|
-
hint: "Ensure the input is valid JSON"
|
|
11746
|
-
});
|
|
11747
|
-
}
|
|
11748
|
-
const body = { input };
|
|
11749
|
-
if (options.fromNode) {
|
|
11750
|
-
body.startNodes = [options.fromNode];
|
|
11751
|
-
}
|
|
11752
|
-
const result = await apiRequest(`/v1/cli/workflow/${workflowId}/run`, {
|
|
11753
|
-
method: "POST",
|
|
11754
|
-
body
|
|
11755
|
-
});
|
|
11756
|
-
ok("workflow.run", {
|
|
11757
|
-
message: options.fromNode ? `Workflow run started from node ${options.fromNode}` : "Workflow run started",
|
|
11758
|
-
runId: result.runId,
|
|
11648
|
+
ok("workflow.runs", {
|
|
11759
11649
|
workflowId: result.workflowId,
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11650
|
+
total: result.total,
|
|
11651
|
+
hasActiveRun: result.hasActiveRun,
|
|
11652
|
+
activeRunId: result.activeRunId,
|
|
11653
|
+
runs: result.runs.map((run) => ({
|
|
11654
|
+
runId: run.runId,
|
|
11655
|
+
status: run.status,
|
|
11656
|
+
progress: `${run.executedNodes}/${run.totalNodes}`,
|
|
11657
|
+
failedNodes: run.failedNodes,
|
|
11658
|
+
startedAt: run.startedAt,
|
|
11659
|
+
finishedAt: run.finishedAt,
|
|
11660
|
+
durationMs: run.durationMs
|
|
11661
|
+
}))
|
|
11764
11662
|
});
|
|
11765
11663
|
} catch (error) {
|
|
11766
11664
|
if (error instanceof CLIError) {
|
|
@@ -11768,24 +11666,21 @@ var workflowRunCommand = new Command("run").description("Run workflows and get e
|
|
|
11768
11666
|
}
|
|
11769
11667
|
fail(
|
|
11770
11668
|
ErrorCodes.INTERNAL_ERROR,
|
|
11771
|
-
error instanceof Error ? error.message : "Failed to
|
|
11669
|
+
error instanceof Error ? error.message : "Failed to get workflow runs"
|
|
11772
11670
|
);
|
|
11773
11671
|
}
|
|
11774
11672
|
});
|
|
11775
|
-
workflowRunCommand.addCommand(workflowRunDetailCommand);
|
|
11776
|
-
workflowRunCommand.addCommand(workflowRunNodeCommand);
|
|
11777
|
-
workflowRunCommand.addCommand(workflowRunToolcallsCommand);
|
|
11778
11673
|
|
|
11779
11674
|
// src/commands/workflow/abort.ts
|
|
11780
11675
|
init_cjs_shims();
|
|
11781
|
-
var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<
|
|
11676
|
+
var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<workflowId>", "Workflow ID").action(async (workflowId) => {
|
|
11782
11677
|
try {
|
|
11783
|
-
await apiRequest(`/v1/cli/workflow
|
|
11678
|
+
await apiRequest(`/v1/cli/workflow/${workflowId}/abort`, {
|
|
11784
11679
|
method: "POST"
|
|
11785
11680
|
});
|
|
11786
11681
|
ok("workflow.abort", {
|
|
11787
11682
|
message: "Workflow run aborted",
|
|
11788
|
-
|
|
11683
|
+
workflowId
|
|
11789
11684
|
});
|
|
11790
11685
|
} catch (error) {
|
|
11791
11686
|
if (error instanceof CLIError) {
|
|
@@ -11842,7 +11737,7 @@ function generateSummary(changedNodes) {
|
|
|
11842
11737
|
}
|
|
11843
11738
|
return summaries.join("; ") || `${changedNodes.length} node(s) updated`;
|
|
11844
11739
|
}
|
|
11845
|
-
var workflowStatusCommand = new Command("status").description("Get detailed workflow execution status").argument("<
|
|
11740
|
+
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) => {
|
|
11846
11741
|
try {
|
|
11847
11742
|
const pollInterval = Number.parseInt(options.interval, 10);
|
|
11848
11743
|
if (Number.isNaN(pollInterval) || pollInterval <= 0) {
|
|
@@ -11851,7 +11746,7 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
|
|
|
11851
11746
|
});
|
|
11852
11747
|
}
|
|
11853
11748
|
const fetchStatus = async () => {
|
|
11854
|
-
return await apiRequest(`/v1/cli/workflow
|
|
11749
|
+
return await apiRequest(`/v1/cli/workflow/${workflowId}/status`);
|
|
11855
11750
|
};
|
|
11856
11751
|
if (options.watch) {
|
|
11857
11752
|
let prevStatus = null;
|
|
@@ -11908,6 +11803,100 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
|
|
|
11908
11803
|
}
|
|
11909
11804
|
});
|
|
11910
11805
|
|
|
11806
|
+
// src/commands/workflow/detail.ts
|
|
11807
|
+
init_cjs_shims();
|
|
11808
|
+
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) => {
|
|
11809
|
+
try {
|
|
11810
|
+
const params = new URLSearchParams();
|
|
11811
|
+
if (options.toolCalls === false) {
|
|
11812
|
+
params.set("includeToolCalls", "false");
|
|
11813
|
+
}
|
|
11814
|
+
if (options.previewLength) {
|
|
11815
|
+
params.set("outputPreviewLength", options.previewLength);
|
|
11816
|
+
}
|
|
11817
|
+
const queryString = params.toString();
|
|
11818
|
+
const url = `/v1/cli/workflow/${workflowId}/detail${queryString ? `?${queryString}` : ""}`;
|
|
11819
|
+
const result = await apiRequest(url);
|
|
11820
|
+
ok("workflow.detail", {
|
|
11821
|
+
runId: result.runId,
|
|
11822
|
+
workflowId: result.workflowId,
|
|
11823
|
+
title: result.title,
|
|
11824
|
+
status: result.status,
|
|
11825
|
+
progress: {
|
|
11826
|
+
total: result.totalNodes,
|
|
11827
|
+
executed: result.executedNodes,
|
|
11828
|
+
failed: result.failedNodes
|
|
11829
|
+
},
|
|
11830
|
+
timing: {
|
|
11831
|
+
startedAt: result.startedAt,
|
|
11832
|
+
finishedAt: result.finishedAt,
|
|
11833
|
+
durationMs: result.durationMs
|
|
11834
|
+
},
|
|
11835
|
+
nodes: result.nodes,
|
|
11836
|
+
errors: result.errors
|
|
11837
|
+
});
|
|
11838
|
+
} catch (error) {
|
|
11839
|
+
if (error instanceof CLIError) {
|
|
11840
|
+
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
11841
|
+
}
|
|
11842
|
+
fail(
|
|
11843
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
11844
|
+
error instanceof Error ? error.message : "Failed to get workflow detail"
|
|
11845
|
+
);
|
|
11846
|
+
}
|
|
11847
|
+
});
|
|
11848
|
+
|
|
11849
|
+
// src/commands/workflow/toolcalls.ts
|
|
11850
|
+
init_cjs_shims();
|
|
11851
|
+
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) => {
|
|
11852
|
+
try {
|
|
11853
|
+
const params = new URLSearchParams();
|
|
11854
|
+
if (options.nodeId) {
|
|
11855
|
+
params.set("nodeId", options.nodeId);
|
|
11856
|
+
}
|
|
11857
|
+
if (options.toolsetId) {
|
|
11858
|
+
params.set("toolsetId", options.toolsetId);
|
|
11859
|
+
}
|
|
11860
|
+
if (options.toolName) {
|
|
11861
|
+
params.set("toolName", options.toolName);
|
|
11862
|
+
}
|
|
11863
|
+
if (options.status) {
|
|
11864
|
+
params.set("status", options.status);
|
|
11865
|
+
}
|
|
11866
|
+
if (options.limit) {
|
|
11867
|
+
params.set("limit", options.limit);
|
|
11868
|
+
}
|
|
11869
|
+
if (options.offset) {
|
|
11870
|
+
params.set("offset", options.offset);
|
|
11871
|
+
}
|
|
11872
|
+
if (options.raw) {
|
|
11873
|
+
params.set("sanitizeForDisplay", "false");
|
|
11874
|
+
}
|
|
11875
|
+
const queryString = params.toString();
|
|
11876
|
+
const url = `/v1/cli/workflow/${workflowId}/toolcalls${queryString ? `?${queryString}` : ""}`;
|
|
11877
|
+
const result = await apiRequest(url);
|
|
11878
|
+
ok("workflow.toolcalls", {
|
|
11879
|
+
runId: result.runId,
|
|
11880
|
+
workflowId: result.workflowId,
|
|
11881
|
+
totalCount: result.totalCount,
|
|
11882
|
+
toolCalls: result.toolCalls,
|
|
11883
|
+
summary: {
|
|
11884
|
+
byStatus: result.byStatus,
|
|
11885
|
+
byToolset: result.byToolset,
|
|
11886
|
+
byTool: result.byTool
|
|
11887
|
+
}
|
|
11888
|
+
});
|
|
11889
|
+
} catch (error) {
|
|
11890
|
+
if (error instanceof CLIError) {
|
|
11891
|
+
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
11892
|
+
}
|
|
11893
|
+
fail(
|
|
11894
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
11895
|
+
error instanceof Error ? error.message : "Failed to get workflow tool calls"
|
|
11896
|
+
);
|
|
11897
|
+
}
|
|
11898
|
+
});
|
|
11899
|
+
|
|
11911
11900
|
// src/commands/workflow/toolset-keys.ts
|
|
11912
11901
|
init_cjs_shims();
|
|
11913
11902
|
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) => {
|
|
@@ -12081,15 +12070,15 @@ var workflowNodeGetCommand = new Command("node").description("Get single node in
|
|
|
12081
12070
|
});
|
|
12082
12071
|
|
|
12083
12072
|
// src/commands/workflow/index.ts
|
|
12084
|
-
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(
|
|
12073
|
+
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);
|
|
12085
12074
|
|
|
12086
12075
|
// src/commands/node/index.ts
|
|
12087
12076
|
init_cjs_shims();
|
|
12088
12077
|
|
|
12089
12078
|
// src/commands/node/types.ts
|
|
12090
12079
|
init_cjs_shims();
|
|
12091
|
-
var
|
|
12092
|
-
var
|
|
12080
|
+
var fs12 = __toESM(require("fs"));
|
|
12081
|
+
var path8 = __toESM(require("path"));
|
|
12093
12082
|
init_paths();
|
|
12094
12083
|
var CACHE_FILE = "node-types.json";
|
|
12095
12084
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
@@ -12128,20 +12117,20 @@ var nodeTypesCommand = new Command("types").description("List available node typ
|
|
|
12128
12117
|
}
|
|
12129
12118
|
});
|
|
12130
12119
|
function getCachePath() {
|
|
12131
|
-
return
|
|
12120
|
+
return path8.join(getCacheDir(), CACHE_FILE);
|
|
12132
12121
|
}
|
|
12133
12122
|
function loadFromCache() {
|
|
12134
12123
|
try {
|
|
12135
12124
|
const cachePath = getCachePath();
|
|
12136
|
-
if (!
|
|
12125
|
+
if (!fs12.existsSync(cachePath)) {
|
|
12137
12126
|
return null;
|
|
12138
12127
|
}
|
|
12139
|
-
const stat =
|
|
12128
|
+
const stat = fs12.statSync(cachePath);
|
|
12140
12129
|
const age = Date.now() - stat.mtimeMs;
|
|
12141
12130
|
if (age > CACHE_TTL) {
|
|
12142
12131
|
return null;
|
|
12143
12132
|
}
|
|
12144
|
-
const content =
|
|
12133
|
+
const content = fs12.readFileSync(cachePath, "utf-8");
|
|
12145
12134
|
return JSON.parse(content);
|
|
12146
12135
|
} catch {
|
|
12147
12136
|
return null;
|
|
@@ -12151,7 +12140,7 @@ async function fetchAndCache() {
|
|
|
12151
12140
|
const data = await apiRequest("/v1/cli/node/types");
|
|
12152
12141
|
try {
|
|
12153
12142
|
const cachePath = getCachePath();
|
|
12154
|
-
|
|
12143
|
+
fs12.writeFileSync(cachePath, JSON.stringify(data, null, 2));
|
|
12155
12144
|
} catch {
|
|
12156
12145
|
}
|
|
12157
12146
|
return data;
|
|
@@ -12489,16 +12478,16 @@ var fileGetCommand = new Command("get").description("Get file details").argument
|
|
|
12489
12478
|
|
|
12490
12479
|
// src/commands/file/download.ts
|
|
12491
12480
|
init_cjs_shims();
|
|
12492
|
-
var
|
|
12493
|
-
var
|
|
12481
|
+
var fs13 = __toESM(require("fs"));
|
|
12482
|
+
var path9 = __toESM(require("path"));
|
|
12494
12483
|
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) => {
|
|
12495
12484
|
try {
|
|
12496
12485
|
const { data, filename, contentType, size } = await apiRequestStream(
|
|
12497
12486
|
`/v1/cli/drive/files/${fileId}/download`
|
|
12498
12487
|
);
|
|
12499
12488
|
const outputPath = options.output || filename || `${fileId}`;
|
|
12500
|
-
const resolvedPath =
|
|
12501
|
-
|
|
12489
|
+
const resolvedPath = path9.resolve(outputPath);
|
|
12490
|
+
fs13.writeFileSync(resolvedPath, data);
|
|
12502
12491
|
ok("file.download", {
|
|
12503
12492
|
fileId,
|
|
12504
12493
|
path: resolvedPath,
|
|
@@ -12523,8 +12512,8 @@ var fileCommand = new Command("file").description("Manage files and documents").
|
|
|
12523
12512
|
// src/bin/refly.ts
|
|
12524
12513
|
function getVersion() {
|
|
12525
12514
|
try {
|
|
12526
|
-
const pkgPath =
|
|
12527
|
-
const pkg = JSON.parse(
|
|
12515
|
+
const pkgPath = path10.join(__dirname, "..", "..", "package.json");
|
|
12516
|
+
const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
|
|
12528
12517
|
return pkg.version || "0.1.0";
|
|
12529
12518
|
} catch {
|
|
12530
12519
|
return "0.1.0";
|