@ai-setting/roy-agent-cli 1.5.81 → 1.5.82
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/roy-agent.js +127 -71
- package/dist/index.js +127 -71
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +2 -2
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7320,7 +7320,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7320
7320
|
var require_package = __commonJS((exports, module) => {
|
|
7321
7321
|
module.exports = {
|
|
7322
7322
|
name: "@ai-setting/roy-agent-cli",
|
|
7323
|
-
version: "1.5.
|
|
7323
|
+
version: "1.5.82",
|
|
7324
7324
|
type: "module",
|
|
7325
7325
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7326
7326
|
main: "./dist/index.js",
|
|
@@ -7347,7 +7347,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7347
7347
|
},
|
|
7348
7348
|
dependencies: {
|
|
7349
7349
|
"@ai-setting/roy-agent-coder-harness": "^1.5.48",
|
|
7350
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7350
|
+
"@ai-setting/roy-agent-core": "^1.5.81",
|
|
7351
7351
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
7352
7352
|
chalk: "^5.6.2",
|
|
7353
7353
|
commander: "^14.0.3",
|
|
@@ -8088,9 +8088,17 @@ class ContextHandlerService {
|
|
|
8088
8088
|
}
|
|
8089
8089
|
throw error;
|
|
8090
8090
|
}
|
|
8091
|
-
if (compactResult.newQuery) {
|
|
8092
|
-
query
|
|
8091
|
+
if (!compactResult.newQuery || compactResult.newQuery === query) {
|
|
8092
|
+
logger3.error("Compact succeeded but produced no new query, terminating to avoid silent retry loop", {
|
|
8093
|
+
compactCount,
|
|
8094
|
+
query
|
|
8095
|
+
});
|
|
8096
|
+
if (span) {
|
|
8097
|
+
span?.end(undefined, error);
|
|
8098
|
+
}
|
|
8099
|
+
throw error;
|
|
8093
8100
|
}
|
|
8101
|
+
query = compactResult.newQuery;
|
|
8094
8102
|
continue;
|
|
8095
8103
|
}
|
|
8096
8104
|
if (span) {
|
|
@@ -16988,6 +16996,7 @@ function renderNodesList(nodes) {
|
|
|
16988
16996
|
|
|
16989
16997
|
// src/commands/workflow/commands/list.ts
|
|
16990
16998
|
import chalk61 from "chalk";
|
|
16999
|
+
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
16991
17000
|
var WorkflowListCommand = {
|
|
16992
17001
|
command: "list",
|
|
16993
17002
|
describe: "列出所有已注册的 Workflow",
|
|
@@ -17047,29 +17056,44 @@ var WorkflowListCommand = {
|
|
|
17047
17056
|
output.error('WorkflowService not initialized. Please run "roy-agent workflow init" first.');
|
|
17048
17057
|
process.exit(1);
|
|
17049
17058
|
}
|
|
17050
|
-
const
|
|
17059
|
+
const tool = createWorkflowListTool(service);
|
|
17060
|
+
const result = await tool.execute({
|
|
17051
17061
|
tag: args.tag,
|
|
17052
|
-
taskId: args.taskId,
|
|
17053
17062
|
search: args.search,
|
|
17054
17063
|
limit: args.limit,
|
|
17055
17064
|
offset: args.offset
|
|
17056
|
-
});
|
|
17065
|
+
}, {});
|
|
17066
|
+
if (!result.success) {
|
|
17067
|
+
output.error(result.error || "Failed to list workflows");
|
|
17068
|
+
process.exit(1);
|
|
17069
|
+
}
|
|
17070
|
+
const data = JSON.parse(result.output);
|
|
17071
|
+
const workflows = data.workflows || [];
|
|
17057
17072
|
if (args.json) {
|
|
17058
17073
|
output.json({
|
|
17059
17074
|
workflows: workflows.map((w) => ({
|
|
17060
|
-
id: w.id,
|
|
17061
17075
|
name: w.name,
|
|
17062
17076
|
version: w.version,
|
|
17063
17077
|
description: w.description,
|
|
17064
17078
|
tags: w.tags,
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
updatedAt: w.updatedAt.toISOString()
|
|
17079
|
+
createdAt: w.created_at,
|
|
17080
|
+
updatedAt: w.created_at
|
|
17068
17081
|
})),
|
|
17069
|
-
total: workflows.length
|
|
17082
|
+
total: data.total || workflows.length
|
|
17070
17083
|
});
|
|
17071
17084
|
} else {
|
|
17072
|
-
|
|
17085
|
+
const renderWorkflows = workflows.map((w) => ({
|
|
17086
|
+
id: w.name,
|
|
17087
|
+
name: w.name,
|
|
17088
|
+
version: w.version,
|
|
17089
|
+
description: w.description,
|
|
17090
|
+
tags: w.tags || [],
|
|
17091
|
+
createdAt: w.created_at ? new Date(w.created_at) : new Date,
|
|
17092
|
+
updatedAt: w.created_at ? new Date(w.created_at) : new Date,
|
|
17093
|
+
definition: { nodes: [], config: {}, inputs: {} },
|
|
17094
|
+
metadata: {}
|
|
17095
|
+
}));
|
|
17096
|
+
output.log(renderWorkflowList(renderWorkflows));
|
|
17073
17097
|
output.log(chalk61.green(`
|
|
17074
17098
|
✅ 共 ${workflows.length} 个 Workflow`));
|
|
17075
17099
|
}
|
|
@@ -17756,7 +17780,12 @@ var WorkflowAddCommand = {
|
|
|
17756
17780
|
}).option("config", {
|
|
17757
17781
|
describe: "配置文件路径",
|
|
17758
17782
|
type: "string"
|
|
17759
|
-
})
|
|
17783
|
+
}).epilogue(`提示:
|
|
17784
|
+
- 模版变量建议不加空格: {{nodeId.field}} 即可,{{ nodeId.field }}(带空格)也能通过自动兼容
|
|
17785
|
+
- 输出节点请使用 echo tool 的 message 参数:
|
|
17786
|
+
tool: echo
|
|
17787
|
+
message: "{{nodeId.field}}"
|
|
17788
|
+
不要用 bash tool + command 输出多行内容(shell 会执行失败)。`),
|
|
17760
17789
|
async handler(args) {
|
|
17761
17790
|
const a = args;
|
|
17762
17791
|
const output = new OutputService;
|
|
@@ -17901,6 +17930,7 @@ Agent output:
|
|
|
17901
17930
|
|
|
17902
17931
|
// src/commands/workflow/commands/get.ts
|
|
17903
17932
|
import chalk63 from "chalk";
|
|
17933
|
+
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
17904
17934
|
var WorkflowGetCommand = {
|
|
17905
17935
|
command: "get <identifier>",
|
|
17906
17936
|
describe: "获取 Workflow 或 Run 详情",
|
|
@@ -17950,46 +17980,59 @@ var WorkflowGetCommand = {
|
|
|
17950
17980
|
process.exit(1);
|
|
17951
17981
|
}
|
|
17952
17982
|
const service = workflowComponent.getService();
|
|
17983
|
+
const tool = createWorkflowGetTool(service);
|
|
17953
17984
|
const isRunId = args.runId || args.identifier.startsWith("run_");
|
|
17954
17985
|
if (isRunId) {
|
|
17955
|
-
const
|
|
17956
|
-
if (!
|
|
17957
|
-
output.error(`Run not found: ${args.identifier}`);
|
|
17986
|
+
const result = await tool.execute({ run_id: args.identifier }, {});
|
|
17987
|
+
if (!result.success) {
|
|
17988
|
+
output.error(result.error || `Run not found: ${args.identifier}`);
|
|
17958
17989
|
process.exit(1);
|
|
17959
17990
|
}
|
|
17960
|
-
const
|
|
17991
|
+
const data = JSON.parse(result.output);
|
|
17961
17992
|
if (args.json) {
|
|
17962
17993
|
output.json({
|
|
17963
17994
|
run: {
|
|
17964
|
-
id:
|
|
17965
|
-
workflowId:
|
|
17966
|
-
status:
|
|
17967
|
-
input:
|
|
17968
|
-
startedAt:
|
|
17995
|
+
id: data.run_id,
|
|
17996
|
+
workflowId: data.workflow_id,
|
|
17997
|
+
status: data.status,
|
|
17998
|
+
input: data.input,
|
|
17999
|
+
startedAt: data.created_at
|
|
17969
18000
|
}
|
|
17970
18001
|
});
|
|
17971
18002
|
} else {
|
|
17972
18003
|
const run = {
|
|
17973
|
-
id:
|
|
17974
|
-
workflowId:
|
|
17975
|
-
workflowName:
|
|
17976
|
-
status:
|
|
17977
|
-
input:
|
|
17978
|
-
startedAt:
|
|
18004
|
+
id: data.run_id,
|
|
18005
|
+
workflowId: data.workflow_id || "",
|
|
18006
|
+
workflowName: data.workflow_name,
|
|
18007
|
+
status: data.status,
|
|
18008
|
+
input: data.input,
|
|
18009
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
17979
18010
|
debugMode: false
|
|
17980
18011
|
};
|
|
17981
18012
|
output.log(renderRunDetail(run));
|
|
17982
18013
|
}
|
|
17983
18014
|
} else {
|
|
17984
|
-
const
|
|
17985
|
-
if (!
|
|
17986
|
-
output.error(`Workflow not found: ${args.identifier}`);
|
|
18015
|
+
const result = await tool.execute({ name: args.identifier }, {});
|
|
18016
|
+
if (!result.success) {
|
|
18017
|
+
output.error(result.error || `Workflow not found: ${args.identifier}`);
|
|
17987
18018
|
process.exit(1);
|
|
17988
18019
|
}
|
|
18020
|
+
const data = JSON.parse(result.output);
|
|
18021
|
+
const workflow = {
|
|
18022
|
+
id: data.name,
|
|
18023
|
+
name: data.name,
|
|
18024
|
+
version: data.version,
|
|
18025
|
+
description: data.description,
|
|
18026
|
+
tags: data.tags || [],
|
|
18027
|
+
createdAt: data.created_at ? new Date(data.created_at) : new Date,
|
|
18028
|
+
updatedAt: data.updated_at ? new Date(data.updated_at) : new Date,
|
|
18029
|
+
definition: data.definition || { inputs: {}, nodes: [], config: {} },
|
|
18030
|
+
metadata: {}
|
|
18031
|
+
};
|
|
17989
18032
|
let sessionRuns = [];
|
|
17990
18033
|
if (args.includeRuns) {
|
|
17991
18034
|
sessionRuns = await service.listSessions({ limit: 5 });
|
|
17992
|
-
sessionRuns = sessionRuns.filter((r) => r.metadata.
|
|
18035
|
+
sessionRuns = sessionRuns.filter((r) => r.metadata.workflowName === workflow.name);
|
|
17993
18036
|
}
|
|
17994
18037
|
const runs = sessionRuns.map((r) => {
|
|
17995
18038
|
const m = r.metadata;
|
|
@@ -18005,7 +18048,7 @@ var WorkflowGetCommand = {
|
|
|
18005
18048
|
if (args.json) {
|
|
18006
18049
|
output.json({
|
|
18007
18050
|
workflow: {
|
|
18008
|
-
id: workflow.
|
|
18051
|
+
id: workflow.name,
|
|
18009
18052
|
name: workflow.name,
|
|
18010
18053
|
version: workflow.version,
|
|
18011
18054
|
description: workflow.description,
|
|
@@ -18026,8 +18069,13 @@ var WorkflowGetCommand = {
|
|
|
18026
18069
|
if (args.includeNodes) {
|
|
18027
18070
|
output.log(chalk63.bold(`
|
|
18028
18071
|
\uD83D\uDCCB All Nodes:`));
|
|
18029
|
-
output.log(renderNodesList(
|
|
18072
|
+
output.log(renderNodesList(data.nodes || []));
|
|
18030
18073
|
}
|
|
18074
|
+
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
18075
|
+
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
18076
|
+
output.log(chalk63.bold(`
|
|
18077
|
+
\uD83D\uDCC4 Definition (YAML):`));
|
|
18078
|
+
output.log(chalk63.gray(defYaml));
|
|
18031
18079
|
}
|
|
18032
18080
|
}
|
|
18033
18081
|
} catch (error) {
|
|
@@ -18188,6 +18236,7 @@ var import_yaml = __toESM(require_dist(), 1);
|
|
|
18188
18236
|
import chalk66 from "chalk";
|
|
18189
18237
|
import fs5 from "fs";
|
|
18190
18238
|
import path8 from "path";
|
|
18239
|
+
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18191
18240
|
import { getTracerProvider as getTracerProvider4, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
|
|
18192
18241
|
var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
18193
18242
|
const output = new OutputService;
|
|
@@ -18344,18 +18393,27 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18344
18393
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
|
|
18345
18394
|
}
|
|
18346
18395
|
} else {
|
|
18347
|
-
|
|
18348
|
-
const
|
|
18396
|
+
const tool = createRunWorkflowTool(service);
|
|
18397
|
+
const toolResult = await tool.execute({
|
|
18398
|
+
workflow_name: args.identifier,
|
|
18399
|
+
input: input || undefined,
|
|
18400
|
+
timeout: args.timeout
|
|
18401
|
+
}, {});
|
|
18402
|
+
if (!toolResult.success) {
|
|
18403
|
+
output.error(toolResult.error || `Failed to run workflow: ${args.identifier}`);
|
|
18404
|
+
process.exit(1);
|
|
18405
|
+
}
|
|
18406
|
+
const runData = toolResult.output;
|
|
18349
18407
|
output.log(renderRunResult({
|
|
18350
|
-
runId:
|
|
18351
|
-
status:
|
|
18352
|
-
output:
|
|
18353
|
-
error:
|
|
18354
|
-
durationMs:
|
|
18408
|
+
runId: runData.run_id,
|
|
18409
|
+
status: runData.status,
|
|
18410
|
+
output: runData.output,
|
|
18411
|
+
error: runData.error,
|
|
18412
|
+
durationMs: runData.duration_ms
|
|
18355
18413
|
}));
|
|
18356
|
-
if (
|
|
18414
|
+
if (runData.status === "paused") {
|
|
18357
18415
|
output.log(chalk66.gray(`
|
|
18358
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${
|
|
18416
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session-id ${runData.run_id} --input '<response>'" to resume`));
|
|
18359
18417
|
}
|
|
18360
18418
|
}
|
|
18361
18419
|
if (workflowSpan) {
|
|
@@ -18427,6 +18485,7 @@ var WorkflowRunCommand = {
|
|
|
18427
18485
|
|
|
18428
18486
|
// src/commands/workflow/commands/stop.ts
|
|
18429
18487
|
import chalk67 from "chalk";
|
|
18488
|
+
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18430
18489
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
18431
18490
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
18432
18491
|
const output = new OutputService;
|
|
@@ -18444,17 +18503,12 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
18444
18503
|
process.exit(1);
|
|
18445
18504
|
}
|
|
18446
18505
|
const service = workflowComponent.getService();
|
|
18447
|
-
const
|
|
18448
|
-
|
|
18449
|
-
|
|
18506
|
+
const tool = createWorkflowRunStopTool(service);
|
|
18507
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18508
|
+
if (!result.success) {
|
|
18509
|
+
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
18450
18510
|
process.exit(1);
|
|
18451
18511
|
}
|
|
18452
|
-
const metadata = session.metadata;
|
|
18453
|
-
if (!["running", "paused"].includes(metadata.status)) {
|
|
18454
|
-
output.error(`Cannot stop run in status: ${metadata.status}`);
|
|
18455
|
-
process.exit(1);
|
|
18456
|
-
}
|
|
18457
|
-
await service.stopRun(args.runId);
|
|
18458
18512
|
output.log(chalk67.red(`
|
|
18459
18513
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
18460
18514
|
} catch (error) {
|
|
@@ -18480,6 +18534,7 @@ var WorkflowStopCommand = {
|
|
|
18480
18534
|
|
|
18481
18535
|
// src/commands/workflow/commands/status.ts
|
|
18482
18536
|
import chalk68 from "chalk";
|
|
18537
|
+
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18483
18538
|
var WorkflowStatusCommand = {
|
|
18484
18539
|
command: "status <runId>",
|
|
18485
18540
|
describe: "查看 Workflow 运行状态",
|
|
@@ -18517,23 +18572,24 @@ var WorkflowStatusCommand = {
|
|
|
18517
18572
|
process.exit(1);
|
|
18518
18573
|
}
|
|
18519
18574
|
const service = workflowComponent.getService();
|
|
18575
|
+
const tool = createWorkflowRunStatusTool(service);
|
|
18520
18576
|
if (args.watch) {
|
|
18521
18577
|
let lastStatus = "";
|
|
18522
18578
|
while (true) {
|
|
18523
|
-
const
|
|
18524
|
-
if (!
|
|
18525
|
-
output.error(`Run not found: ${args.runId}`);
|
|
18579
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18580
|
+
if (!result.success) {
|
|
18581
|
+
output.error(result.error || `Run not found: ${args.runId}`);
|
|
18526
18582
|
process.exit(1);
|
|
18527
18583
|
}
|
|
18528
|
-
const
|
|
18529
|
-
const status =
|
|
18584
|
+
const data = JSON.parse(result.output);
|
|
18585
|
+
const status = data.status;
|
|
18530
18586
|
if (status !== lastStatus) {
|
|
18531
18587
|
const run = {
|
|
18532
|
-
id:
|
|
18533
|
-
workflowId:
|
|
18534
|
-
workflowName:
|
|
18588
|
+
id: data.run_id,
|
|
18589
|
+
workflowId: data.workflow_id || "",
|
|
18590
|
+
workflowName: data.workflow_name,
|
|
18535
18591
|
status,
|
|
18536
|
-
startedAt:
|
|
18592
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
18537
18593
|
debugMode: false
|
|
18538
18594
|
};
|
|
18539
18595
|
output.log(renderRunDetail(run));
|
|
@@ -18545,19 +18601,19 @@ var WorkflowStatusCommand = {
|
|
|
18545
18601
|
await new Promise((resolve) => setTimeout(resolve, args.interval));
|
|
18546
18602
|
}
|
|
18547
18603
|
} else {
|
|
18548
|
-
const
|
|
18549
|
-
if (!
|
|
18550
|
-
output.error(`Run not found: ${args.runId}`);
|
|
18604
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18605
|
+
if (!result.success) {
|
|
18606
|
+
output.error(result.error || `Run not found: ${args.runId}`);
|
|
18551
18607
|
process.exit(1);
|
|
18552
18608
|
}
|
|
18553
|
-
const
|
|
18554
|
-
const status =
|
|
18609
|
+
const data = JSON.parse(result.output);
|
|
18610
|
+
const status = data.status;
|
|
18555
18611
|
const run = {
|
|
18556
|
-
id:
|
|
18557
|
-
workflowId:
|
|
18558
|
-
workflowName:
|
|
18612
|
+
id: data.run_id,
|
|
18613
|
+
workflowId: data.workflow_id || "",
|
|
18614
|
+
workflowName: data.workflow_name,
|
|
18559
18615
|
status,
|
|
18560
|
-
startedAt:
|
|
18616
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
18561
18617
|
debugMode: false
|
|
18562
18618
|
};
|
|
18563
18619
|
output.log(renderRunDetail(run));
|
package/dist/index.js
CHANGED
|
@@ -7319,7 +7319,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7319
7319
|
var require_package = __commonJS((exports, module) => {
|
|
7320
7320
|
module.exports = {
|
|
7321
7321
|
name: "@ai-setting/roy-agent-cli",
|
|
7322
|
-
version: "1.5.
|
|
7322
|
+
version: "1.5.82",
|
|
7323
7323
|
type: "module",
|
|
7324
7324
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7325
7325
|
main: "./dist/index.js",
|
|
@@ -7346,7 +7346,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7346
7346
|
},
|
|
7347
7347
|
dependencies: {
|
|
7348
7348
|
"@ai-setting/roy-agent-coder-harness": "^1.5.48",
|
|
7349
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7349
|
+
"@ai-setting/roy-agent-core": "^1.5.81",
|
|
7350
7350
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
7351
7351
|
chalk: "^5.6.2",
|
|
7352
7352
|
commander: "^14.0.3",
|
|
@@ -8087,9 +8087,17 @@ class ContextHandlerService {
|
|
|
8087
8087
|
}
|
|
8088
8088
|
throw error;
|
|
8089
8089
|
}
|
|
8090
|
-
if (compactResult.newQuery) {
|
|
8091
|
-
query
|
|
8090
|
+
if (!compactResult.newQuery || compactResult.newQuery === query) {
|
|
8091
|
+
logger3.error("Compact succeeded but produced no new query, terminating to avoid silent retry loop", {
|
|
8092
|
+
compactCount,
|
|
8093
|
+
query
|
|
8094
|
+
});
|
|
8095
|
+
if (span) {
|
|
8096
|
+
span?.end(undefined, error);
|
|
8097
|
+
}
|
|
8098
|
+
throw error;
|
|
8092
8099
|
}
|
|
8100
|
+
query = compactResult.newQuery;
|
|
8093
8101
|
continue;
|
|
8094
8102
|
}
|
|
8095
8103
|
if (span) {
|
|
@@ -16987,6 +16995,7 @@ function renderNodesList(nodes) {
|
|
|
16987
16995
|
|
|
16988
16996
|
// src/commands/workflow/commands/list.ts
|
|
16989
16997
|
import chalk61 from "chalk";
|
|
16998
|
+
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
16990
16999
|
var WorkflowListCommand = {
|
|
16991
17000
|
command: "list",
|
|
16992
17001
|
describe: "列出所有已注册的 Workflow",
|
|
@@ -17046,29 +17055,44 @@ var WorkflowListCommand = {
|
|
|
17046
17055
|
output.error('WorkflowService not initialized. Please run "roy-agent workflow init" first.');
|
|
17047
17056
|
process.exit(1);
|
|
17048
17057
|
}
|
|
17049
|
-
const
|
|
17058
|
+
const tool = createWorkflowListTool(service);
|
|
17059
|
+
const result = await tool.execute({
|
|
17050
17060
|
tag: args.tag,
|
|
17051
|
-
taskId: args.taskId,
|
|
17052
17061
|
search: args.search,
|
|
17053
17062
|
limit: args.limit,
|
|
17054
17063
|
offset: args.offset
|
|
17055
|
-
});
|
|
17064
|
+
}, {});
|
|
17065
|
+
if (!result.success) {
|
|
17066
|
+
output.error(result.error || "Failed to list workflows");
|
|
17067
|
+
process.exit(1);
|
|
17068
|
+
}
|
|
17069
|
+
const data = JSON.parse(result.output);
|
|
17070
|
+
const workflows = data.workflows || [];
|
|
17056
17071
|
if (args.json) {
|
|
17057
17072
|
output.json({
|
|
17058
17073
|
workflows: workflows.map((w) => ({
|
|
17059
|
-
id: w.id,
|
|
17060
17074
|
name: w.name,
|
|
17061
17075
|
version: w.version,
|
|
17062
17076
|
description: w.description,
|
|
17063
17077
|
tags: w.tags,
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
updatedAt: w.updatedAt.toISOString()
|
|
17078
|
+
createdAt: w.created_at,
|
|
17079
|
+
updatedAt: w.created_at
|
|
17067
17080
|
})),
|
|
17068
|
-
total: workflows.length
|
|
17081
|
+
total: data.total || workflows.length
|
|
17069
17082
|
});
|
|
17070
17083
|
} else {
|
|
17071
|
-
|
|
17084
|
+
const renderWorkflows = workflows.map((w) => ({
|
|
17085
|
+
id: w.name,
|
|
17086
|
+
name: w.name,
|
|
17087
|
+
version: w.version,
|
|
17088
|
+
description: w.description,
|
|
17089
|
+
tags: w.tags || [],
|
|
17090
|
+
createdAt: w.created_at ? new Date(w.created_at) : new Date,
|
|
17091
|
+
updatedAt: w.created_at ? new Date(w.created_at) : new Date,
|
|
17092
|
+
definition: { nodes: [], config: {}, inputs: {} },
|
|
17093
|
+
metadata: {}
|
|
17094
|
+
}));
|
|
17095
|
+
output.log(renderWorkflowList(renderWorkflows));
|
|
17072
17096
|
output.log(chalk61.green(`
|
|
17073
17097
|
✅ 共 ${workflows.length} 个 Workflow`));
|
|
17074
17098
|
}
|
|
@@ -17755,7 +17779,12 @@ var WorkflowAddCommand = {
|
|
|
17755
17779
|
}).option("config", {
|
|
17756
17780
|
describe: "配置文件路径",
|
|
17757
17781
|
type: "string"
|
|
17758
|
-
})
|
|
17782
|
+
}).epilogue(`提示:
|
|
17783
|
+
- 模版变量建议不加空格: {{nodeId.field}} 即可,{{ nodeId.field }}(带空格)也能通过自动兼容
|
|
17784
|
+
- 输出节点请使用 echo tool 的 message 参数:
|
|
17785
|
+
tool: echo
|
|
17786
|
+
message: "{{nodeId.field}}"
|
|
17787
|
+
不要用 bash tool + command 输出多行内容(shell 会执行失败)。`),
|
|
17759
17788
|
async handler(args) {
|
|
17760
17789
|
const a = args;
|
|
17761
17790
|
const output = new OutputService;
|
|
@@ -17900,6 +17929,7 @@ Agent output:
|
|
|
17900
17929
|
|
|
17901
17930
|
// src/commands/workflow/commands/get.ts
|
|
17902
17931
|
import chalk63 from "chalk";
|
|
17932
|
+
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
17903
17933
|
var WorkflowGetCommand = {
|
|
17904
17934
|
command: "get <identifier>",
|
|
17905
17935
|
describe: "获取 Workflow 或 Run 详情",
|
|
@@ -17949,46 +17979,59 @@ var WorkflowGetCommand = {
|
|
|
17949
17979
|
process.exit(1);
|
|
17950
17980
|
}
|
|
17951
17981
|
const service = workflowComponent.getService();
|
|
17982
|
+
const tool = createWorkflowGetTool(service);
|
|
17952
17983
|
const isRunId = args.runId || args.identifier.startsWith("run_");
|
|
17953
17984
|
if (isRunId) {
|
|
17954
|
-
const
|
|
17955
|
-
if (!
|
|
17956
|
-
output.error(`Run not found: ${args.identifier}`);
|
|
17985
|
+
const result = await tool.execute({ run_id: args.identifier }, {});
|
|
17986
|
+
if (!result.success) {
|
|
17987
|
+
output.error(result.error || `Run not found: ${args.identifier}`);
|
|
17957
17988
|
process.exit(1);
|
|
17958
17989
|
}
|
|
17959
|
-
const
|
|
17990
|
+
const data = JSON.parse(result.output);
|
|
17960
17991
|
if (args.json) {
|
|
17961
17992
|
output.json({
|
|
17962
17993
|
run: {
|
|
17963
|
-
id:
|
|
17964
|
-
workflowId:
|
|
17965
|
-
status:
|
|
17966
|
-
input:
|
|
17967
|
-
startedAt:
|
|
17994
|
+
id: data.run_id,
|
|
17995
|
+
workflowId: data.workflow_id,
|
|
17996
|
+
status: data.status,
|
|
17997
|
+
input: data.input,
|
|
17998
|
+
startedAt: data.created_at
|
|
17968
17999
|
}
|
|
17969
18000
|
});
|
|
17970
18001
|
} else {
|
|
17971
18002
|
const run = {
|
|
17972
|
-
id:
|
|
17973
|
-
workflowId:
|
|
17974
|
-
workflowName:
|
|
17975
|
-
status:
|
|
17976
|
-
input:
|
|
17977
|
-
startedAt:
|
|
18003
|
+
id: data.run_id,
|
|
18004
|
+
workflowId: data.workflow_id || "",
|
|
18005
|
+
workflowName: data.workflow_name,
|
|
18006
|
+
status: data.status,
|
|
18007
|
+
input: data.input,
|
|
18008
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
17978
18009
|
debugMode: false
|
|
17979
18010
|
};
|
|
17980
18011
|
output.log(renderRunDetail(run));
|
|
17981
18012
|
}
|
|
17982
18013
|
} else {
|
|
17983
|
-
const
|
|
17984
|
-
if (!
|
|
17985
|
-
output.error(`Workflow not found: ${args.identifier}`);
|
|
18014
|
+
const result = await tool.execute({ name: args.identifier }, {});
|
|
18015
|
+
if (!result.success) {
|
|
18016
|
+
output.error(result.error || `Workflow not found: ${args.identifier}`);
|
|
17986
18017
|
process.exit(1);
|
|
17987
18018
|
}
|
|
18019
|
+
const data = JSON.parse(result.output);
|
|
18020
|
+
const workflow = {
|
|
18021
|
+
id: data.name,
|
|
18022
|
+
name: data.name,
|
|
18023
|
+
version: data.version,
|
|
18024
|
+
description: data.description,
|
|
18025
|
+
tags: data.tags || [],
|
|
18026
|
+
createdAt: data.created_at ? new Date(data.created_at) : new Date,
|
|
18027
|
+
updatedAt: data.updated_at ? new Date(data.updated_at) : new Date,
|
|
18028
|
+
definition: data.definition || { inputs: {}, nodes: [], config: {} },
|
|
18029
|
+
metadata: {}
|
|
18030
|
+
};
|
|
17988
18031
|
let sessionRuns = [];
|
|
17989
18032
|
if (args.includeRuns) {
|
|
17990
18033
|
sessionRuns = await service.listSessions({ limit: 5 });
|
|
17991
|
-
sessionRuns = sessionRuns.filter((r) => r.metadata.
|
|
18034
|
+
sessionRuns = sessionRuns.filter((r) => r.metadata.workflowName === workflow.name);
|
|
17992
18035
|
}
|
|
17993
18036
|
const runs = sessionRuns.map((r) => {
|
|
17994
18037
|
const m = r.metadata;
|
|
@@ -18004,7 +18047,7 @@ var WorkflowGetCommand = {
|
|
|
18004
18047
|
if (args.json) {
|
|
18005
18048
|
output.json({
|
|
18006
18049
|
workflow: {
|
|
18007
|
-
id: workflow.
|
|
18050
|
+
id: workflow.name,
|
|
18008
18051
|
name: workflow.name,
|
|
18009
18052
|
version: workflow.version,
|
|
18010
18053
|
description: workflow.description,
|
|
@@ -18025,8 +18068,13 @@ var WorkflowGetCommand = {
|
|
|
18025
18068
|
if (args.includeNodes) {
|
|
18026
18069
|
output.log(chalk63.bold(`
|
|
18027
18070
|
\uD83D\uDCCB All Nodes:`));
|
|
18028
|
-
output.log(renderNodesList(
|
|
18071
|
+
output.log(renderNodesList(data.nodes || []));
|
|
18029
18072
|
}
|
|
18073
|
+
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
18074
|
+
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
18075
|
+
output.log(chalk63.bold(`
|
|
18076
|
+
\uD83D\uDCC4 Definition (YAML):`));
|
|
18077
|
+
output.log(chalk63.gray(defYaml));
|
|
18030
18078
|
}
|
|
18031
18079
|
}
|
|
18032
18080
|
} catch (error) {
|
|
@@ -18187,6 +18235,7 @@ var import_yaml = __toESM(require_dist(), 1);
|
|
|
18187
18235
|
import chalk66 from "chalk";
|
|
18188
18236
|
import fs5 from "fs";
|
|
18189
18237
|
import path8 from "path";
|
|
18238
|
+
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18190
18239
|
import { getTracerProvider as getTracerProvider4, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
|
|
18191
18240
|
var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
18192
18241
|
const output = new OutputService;
|
|
@@ -18343,18 +18392,27 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18343
18392
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
|
|
18344
18393
|
}
|
|
18345
18394
|
} else {
|
|
18346
|
-
|
|
18347
|
-
const
|
|
18395
|
+
const tool = createRunWorkflowTool(service);
|
|
18396
|
+
const toolResult = await tool.execute({
|
|
18397
|
+
workflow_name: args.identifier,
|
|
18398
|
+
input: input || undefined,
|
|
18399
|
+
timeout: args.timeout
|
|
18400
|
+
}, {});
|
|
18401
|
+
if (!toolResult.success) {
|
|
18402
|
+
output.error(toolResult.error || `Failed to run workflow: ${args.identifier}`);
|
|
18403
|
+
process.exit(1);
|
|
18404
|
+
}
|
|
18405
|
+
const runData = toolResult.output;
|
|
18348
18406
|
output.log(renderRunResult({
|
|
18349
|
-
runId:
|
|
18350
|
-
status:
|
|
18351
|
-
output:
|
|
18352
|
-
error:
|
|
18353
|
-
durationMs:
|
|
18407
|
+
runId: runData.run_id,
|
|
18408
|
+
status: runData.status,
|
|
18409
|
+
output: runData.output,
|
|
18410
|
+
error: runData.error,
|
|
18411
|
+
durationMs: runData.duration_ms
|
|
18354
18412
|
}));
|
|
18355
|
-
if (
|
|
18413
|
+
if (runData.status === "paused") {
|
|
18356
18414
|
output.log(chalk66.gray(`
|
|
18357
|
-
\uD83D\uDCA1 Use "roy-agent workflow run ${
|
|
18415
|
+
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session-id ${runData.run_id} --input '<response>'" to resume`));
|
|
18358
18416
|
}
|
|
18359
18417
|
}
|
|
18360
18418
|
if (workflowSpan) {
|
|
@@ -18426,6 +18484,7 @@ var WorkflowRunCommand = {
|
|
|
18426
18484
|
|
|
18427
18485
|
// src/commands/workflow/commands/stop.ts
|
|
18428
18486
|
import chalk67 from "chalk";
|
|
18487
|
+
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18429
18488
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
18430
18489
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
18431
18490
|
const output = new OutputService;
|
|
@@ -18443,17 +18502,12 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
18443
18502
|
process.exit(1);
|
|
18444
18503
|
}
|
|
18445
18504
|
const service = workflowComponent.getService();
|
|
18446
|
-
const
|
|
18447
|
-
|
|
18448
|
-
|
|
18505
|
+
const tool = createWorkflowRunStopTool(service);
|
|
18506
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18507
|
+
if (!result.success) {
|
|
18508
|
+
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
18449
18509
|
process.exit(1);
|
|
18450
18510
|
}
|
|
18451
|
-
const metadata = session.metadata;
|
|
18452
|
-
if (!["running", "paused"].includes(metadata.status)) {
|
|
18453
|
-
output.error(`Cannot stop run in status: ${metadata.status}`);
|
|
18454
|
-
process.exit(1);
|
|
18455
|
-
}
|
|
18456
|
-
await service.stopRun(args.runId);
|
|
18457
18511
|
output.log(chalk67.red(`
|
|
18458
18512
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
18459
18513
|
} catch (error) {
|
|
@@ -18479,6 +18533,7 @@ var WorkflowStopCommand = {
|
|
|
18479
18533
|
|
|
18480
18534
|
// src/commands/workflow/commands/status.ts
|
|
18481
18535
|
import chalk68 from "chalk";
|
|
18536
|
+
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18482
18537
|
var WorkflowStatusCommand = {
|
|
18483
18538
|
command: "status <runId>",
|
|
18484
18539
|
describe: "查看 Workflow 运行状态",
|
|
@@ -18516,23 +18571,24 @@ var WorkflowStatusCommand = {
|
|
|
18516
18571
|
process.exit(1);
|
|
18517
18572
|
}
|
|
18518
18573
|
const service = workflowComponent.getService();
|
|
18574
|
+
const tool = createWorkflowRunStatusTool(service);
|
|
18519
18575
|
if (args.watch) {
|
|
18520
18576
|
let lastStatus = "";
|
|
18521
18577
|
while (true) {
|
|
18522
|
-
const
|
|
18523
|
-
if (!
|
|
18524
|
-
output.error(`Run not found: ${args.runId}`);
|
|
18578
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18579
|
+
if (!result.success) {
|
|
18580
|
+
output.error(result.error || `Run not found: ${args.runId}`);
|
|
18525
18581
|
process.exit(1);
|
|
18526
18582
|
}
|
|
18527
|
-
const
|
|
18528
|
-
const status =
|
|
18583
|
+
const data = JSON.parse(result.output);
|
|
18584
|
+
const status = data.status;
|
|
18529
18585
|
if (status !== lastStatus) {
|
|
18530
18586
|
const run = {
|
|
18531
|
-
id:
|
|
18532
|
-
workflowId:
|
|
18533
|
-
workflowName:
|
|
18587
|
+
id: data.run_id,
|
|
18588
|
+
workflowId: data.workflow_id || "",
|
|
18589
|
+
workflowName: data.workflow_name,
|
|
18534
18590
|
status,
|
|
18535
|
-
startedAt:
|
|
18591
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
18536
18592
|
debugMode: false
|
|
18537
18593
|
};
|
|
18538
18594
|
output.log(renderRunDetail(run));
|
|
@@ -18544,19 +18600,19 @@ var WorkflowStatusCommand = {
|
|
|
18544
18600
|
await new Promise((resolve) => setTimeout(resolve, args.interval));
|
|
18545
18601
|
}
|
|
18546
18602
|
} else {
|
|
18547
|
-
const
|
|
18548
|
-
if (!
|
|
18549
|
-
output.error(`Run not found: ${args.runId}`);
|
|
18603
|
+
const result = await tool.execute({ run_id: args.runId }, {});
|
|
18604
|
+
if (!result.success) {
|
|
18605
|
+
output.error(result.error || `Run not found: ${args.runId}`);
|
|
18550
18606
|
process.exit(1);
|
|
18551
18607
|
}
|
|
18552
|
-
const
|
|
18553
|
-
const status =
|
|
18608
|
+
const data = JSON.parse(result.output);
|
|
18609
|
+
const status = data.status;
|
|
18554
18610
|
const run = {
|
|
18555
|
-
id:
|
|
18556
|
-
workflowId:
|
|
18557
|
-
workflowName:
|
|
18611
|
+
id: data.run_id,
|
|
18612
|
+
workflowId: data.workflow_id || "",
|
|
18613
|
+
workflowName: data.workflow_name,
|
|
18558
18614
|
status,
|
|
18559
|
-
startedAt:
|
|
18615
|
+
startedAt: data.created_at ? new Date(data.created_at) : undefined,
|
|
18560
18616
|
debugMode: false
|
|
18561
18617
|
};
|
|
18562
18618
|
output.log(renderRunDetail(run));
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-setting/roy-agent-cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.82",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for roy-agent - Non-interactive command execution",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ai-setting/roy-agent-coder-harness": "^1.5.48",
|
|
30
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
30
|
+
"@ai-setting/roy-agent-core": "^1.5.81",
|
|
31
31
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
32
32
|
"chalk": "^5.6.2",
|
|
33
33
|
"commander": "^14.0.3",
|