@powerformer/refly-cli 0.1.7 → 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 +209 -221
- 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
|
}
|
|
@@ -11589,85 +11589,32 @@ var workflowDeleteCommand = new Command("delete").description("Delete a workflow
|
|
|
11589
11589
|
|
|
11590
11590
|
// src/commands/workflow/run.ts
|
|
11591
11591
|
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) => {
|
|
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) => {
|
|
11596
11593
|
try {
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
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
|
+
});
|
|
11600
11601
|
}
|
|
11601
|
-
|
|
11602
|
-
|
|
11602
|
+
const body = { input };
|
|
11603
|
+
if (options.fromNode) {
|
|
11604
|
+
body.startNodes = [options.fromNode];
|
|
11603
11605
|
}
|
|
11604
|
-
const
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
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",
|
|
11608
11612
|
runId: result.runId,
|
|
11609
11613
|
workflowId: result.workflowId,
|
|
11610
|
-
title: result.title,
|
|
11611
11614
|
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
|
|
11615
|
+
startNode: options.fromNode || void 0,
|
|
11616
|
+
createdAt: result.createdAt,
|
|
11617
|
+
nextStep: `Check status with \`refly workflow status ${workflowId}\``
|
|
11671
11618
|
});
|
|
11672
11619
|
} catch (error) {
|
|
11673
11620
|
if (error instanceof CLIError) {
|
|
@@ -11675,92 +11622,42 @@ var workflowRunNodeCommand = new Command("node").description("Get detailed execu
|
|
|
11675
11622
|
}
|
|
11676
11623
|
fail(
|
|
11677
11624
|
ErrorCodes.INTERNAL_ERROR,
|
|
11678
|
-
error instanceof Error ? error.message : "Failed to
|
|
11625
|
+
error instanceof Error ? error.message : "Failed to run workflow"
|
|
11679
11626
|
);
|
|
11680
11627
|
}
|
|
11681
11628
|
});
|
|
11682
11629
|
|
|
11683
|
-
// src/commands/workflow/
|
|
11630
|
+
// src/commands/workflow/runs.ts
|
|
11684
11631
|
init_cjs_shims();
|
|
11685
|
-
var
|
|
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) => {
|
|
11686
11633
|
try {
|
|
11687
11634
|
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
11635
|
if (options.limit) {
|
|
11701
11636
|
params.set("limit", options.limit);
|
|
11702
11637
|
}
|
|
11703
11638
|
if (options.offset) {
|
|
11704
11639
|
params.set("offset", options.offset);
|
|
11705
11640
|
}
|
|
11706
|
-
if (options.
|
|
11707
|
-
params.set("
|
|
11641
|
+
if (options.status) {
|
|
11642
|
+
params.set("status", options.status);
|
|
11708
11643
|
}
|
|
11709
11644
|
const queryString = params.toString();
|
|
11710
|
-
const url = `/v1/cli/workflow
|
|
11645
|
+
const url = `/v1/cli/workflow/${workflowId}/runs${queryString ? `?${queryString}` : ""}`;
|
|
11711
11646
|
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,
|
|
11647
|
+
ok("workflow.runs", {
|
|
11759
11648
|
workflowId: result.workflowId,
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
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
|
+
}))
|
|
11764
11661
|
});
|
|
11765
11662
|
} catch (error) {
|
|
11766
11663
|
if (error instanceof CLIError) {
|
|
@@ -11768,24 +11665,21 @@ var workflowRunCommand = new Command("run").description("Run workflows and get e
|
|
|
11768
11665
|
}
|
|
11769
11666
|
fail(
|
|
11770
11667
|
ErrorCodes.INTERNAL_ERROR,
|
|
11771
|
-
error instanceof Error ? error.message : "Failed to
|
|
11668
|
+
error instanceof Error ? error.message : "Failed to get workflow runs"
|
|
11772
11669
|
);
|
|
11773
11670
|
}
|
|
11774
11671
|
});
|
|
11775
|
-
workflowRunCommand.addCommand(workflowRunDetailCommand);
|
|
11776
|
-
workflowRunCommand.addCommand(workflowRunNodeCommand);
|
|
11777
|
-
workflowRunCommand.addCommand(workflowRunToolcallsCommand);
|
|
11778
11672
|
|
|
11779
11673
|
// src/commands/workflow/abort.ts
|
|
11780
11674
|
init_cjs_shims();
|
|
11781
|
-
var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<
|
|
11675
|
+
var workflowAbortCommand = new Command("abort").description("Abort a running workflow").argument("<workflowId>", "Workflow ID").action(async (workflowId) => {
|
|
11782
11676
|
try {
|
|
11783
|
-
await apiRequest(`/v1/cli/workflow
|
|
11677
|
+
await apiRequest(`/v1/cli/workflow/${workflowId}/abort`, {
|
|
11784
11678
|
method: "POST"
|
|
11785
11679
|
});
|
|
11786
11680
|
ok("workflow.abort", {
|
|
11787
11681
|
message: "Workflow run aborted",
|
|
11788
|
-
|
|
11682
|
+
workflowId
|
|
11789
11683
|
});
|
|
11790
11684
|
} catch (error) {
|
|
11791
11685
|
if (error instanceof CLIError) {
|
|
@@ -11842,7 +11736,7 @@ function generateSummary(changedNodes) {
|
|
|
11842
11736
|
}
|
|
11843
11737
|
return summaries.join("; ") || `${changedNodes.length} node(s) updated`;
|
|
11844
11738
|
}
|
|
11845
|
-
var workflowStatusCommand = new Command("status").description("Get detailed workflow execution status").argument("<
|
|
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) => {
|
|
11846
11740
|
try {
|
|
11847
11741
|
const pollInterval = Number.parseInt(options.interval, 10);
|
|
11848
11742
|
if (Number.isNaN(pollInterval) || pollInterval <= 0) {
|
|
@@ -11851,7 +11745,7 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
|
|
|
11851
11745
|
});
|
|
11852
11746
|
}
|
|
11853
11747
|
const fetchStatus = async () => {
|
|
11854
|
-
return await apiRequest(`/v1/cli/workflow
|
|
11748
|
+
return await apiRequest(`/v1/cli/workflow/${workflowId}/status`);
|
|
11855
11749
|
};
|
|
11856
11750
|
if (options.watch) {
|
|
11857
11751
|
let prevStatus = null;
|
|
@@ -11908,6 +11802,100 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
|
|
|
11908
11802
|
}
|
|
11909
11803
|
});
|
|
11910
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
|
+
|
|
11911
11899
|
// src/commands/workflow/toolset-keys.ts
|
|
11912
11900
|
init_cjs_shims();
|
|
11913
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) => {
|
|
@@ -12081,15 +12069,15 @@ var workflowNodeGetCommand = new Command("node").description("Get single node in
|
|
|
12081
12069
|
});
|
|
12082
12070
|
|
|
12083
12071
|
// 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(
|
|
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);
|
|
12085
12073
|
|
|
12086
12074
|
// src/commands/node/index.ts
|
|
12087
12075
|
init_cjs_shims();
|
|
12088
12076
|
|
|
12089
12077
|
// src/commands/node/types.ts
|
|
12090
12078
|
init_cjs_shims();
|
|
12091
|
-
var
|
|
12092
|
-
var
|
|
12079
|
+
var fs12 = __toESM(require("fs"));
|
|
12080
|
+
var path8 = __toESM(require("path"));
|
|
12093
12081
|
init_paths();
|
|
12094
12082
|
var CACHE_FILE = "node-types.json";
|
|
12095
12083
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
@@ -12128,20 +12116,20 @@ var nodeTypesCommand = new Command("types").description("List available node typ
|
|
|
12128
12116
|
}
|
|
12129
12117
|
});
|
|
12130
12118
|
function getCachePath() {
|
|
12131
|
-
return
|
|
12119
|
+
return path8.join(getCacheDir(), CACHE_FILE);
|
|
12132
12120
|
}
|
|
12133
12121
|
function loadFromCache() {
|
|
12134
12122
|
try {
|
|
12135
12123
|
const cachePath = getCachePath();
|
|
12136
|
-
if (!
|
|
12124
|
+
if (!fs12.existsSync(cachePath)) {
|
|
12137
12125
|
return null;
|
|
12138
12126
|
}
|
|
12139
|
-
const stat =
|
|
12127
|
+
const stat = fs12.statSync(cachePath);
|
|
12140
12128
|
const age = Date.now() - stat.mtimeMs;
|
|
12141
12129
|
if (age > CACHE_TTL) {
|
|
12142
12130
|
return null;
|
|
12143
12131
|
}
|
|
12144
|
-
const content =
|
|
12132
|
+
const content = fs12.readFileSync(cachePath, "utf-8");
|
|
12145
12133
|
return JSON.parse(content);
|
|
12146
12134
|
} catch {
|
|
12147
12135
|
return null;
|
|
@@ -12151,7 +12139,7 @@ async function fetchAndCache() {
|
|
|
12151
12139
|
const data = await apiRequest("/v1/cli/node/types");
|
|
12152
12140
|
try {
|
|
12153
12141
|
const cachePath = getCachePath();
|
|
12154
|
-
|
|
12142
|
+
fs12.writeFileSync(cachePath, JSON.stringify(data, null, 2));
|
|
12155
12143
|
} catch {
|
|
12156
12144
|
}
|
|
12157
12145
|
return data;
|
|
@@ -12489,16 +12477,16 @@ var fileGetCommand = new Command("get").description("Get file details").argument
|
|
|
12489
12477
|
|
|
12490
12478
|
// src/commands/file/download.ts
|
|
12491
12479
|
init_cjs_shims();
|
|
12492
|
-
var
|
|
12493
|
-
var
|
|
12480
|
+
var fs13 = __toESM(require("fs"));
|
|
12481
|
+
var path9 = __toESM(require("path"));
|
|
12494
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) => {
|
|
12495
12483
|
try {
|
|
12496
12484
|
const { data, filename, contentType, size } = await apiRequestStream(
|
|
12497
12485
|
`/v1/cli/drive/files/${fileId}/download`
|
|
12498
12486
|
);
|
|
12499
12487
|
const outputPath = options.output || filename || `${fileId}`;
|
|
12500
|
-
const resolvedPath =
|
|
12501
|
-
|
|
12488
|
+
const resolvedPath = path9.resolve(outputPath);
|
|
12489
|
+
fs13.writeFileSync(resolvedPath, data);
|
|
12502
12490
|
ok("file.download", {
|
|
12503
12491
|
fileId,
|
|
12504
12492
|
path: resolvedPath,
|
|
@@ -12523,8 +12511,8 @@ var fileCommand = new Command("file").description("Manage files and documents").
|
|
|
12523
12511
|
// src/bin/refly.ts
|
|
12524
12512
|
function getVersion() {
|
|
12525
12513
|
try {
|
|
12526
|
-
const pkgPath =
|
|
12527
|
-
const pkg = JSON.parse(
|
|
12514
|
+
const pkgPath = path10.join(__dirname, "..", "..", "package.json");
|
|
12515
|
+
const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
|
|
12528
12516
|
return pkg.version || "0.1.0";
|
|
12529
12517
|
} catch {
|
|
12530
12518
|
return "0.1.0";
|