@ai-setting/roy-agent-cli 1.5.86 → 1.5.88
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 +604 -369
- package/dist/index.js +606 -370
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +5 -1
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.88",
|
|
7324
7324
|
type: "module",
|
|
7325
7325
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7326
7326
|
main: "./dist/index.js",
|
|
@@ -7343,6 +7343,8 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7343
7343
|
scripts: {
|
|
7344
7344
|
build: "bunup",
|
|
7345
7345
|
clean: "rm -rf dist",
|
|
7346
|
+
lint: "eslint --max-warnings 0 src/",
|
|
7347
|
+
"lint:fix": "eslint --fix src/",
|
|
7346
7348
|
typecheck: "npx tsc --noEmit --skipLibCheck"
|
|
7347
7349
|
},
|
|
7348
7350
|
dependencies: {
|
|
@@ -7363,7 +7365,9 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7363
7365
|
devDependencies: {
|
|
7364
7366
|
"@types/node": "^20.10.0",
|
|
7365
7367
|
"@types/yargs": "^17.0.32",
|
|
7368
|
+
"@typescript-eslint/parser": "^8.62.1",
|
|
7366
7369
|
bunup: "^0.16.0",
|
|
7370
|
+
eslint: "^10.6.0",
|
|
7367
7371
|
typescript: "^5.3.0"
|
|
7368
7372
|
},
|
|
7369
7373
|
engines: {
|
|
@@ -7456,7 +7460,7 @@ import { globalHookManager } from "@ai-setting/roy-agent-core";
|
|
|
7456
7460
|
// src/services/output.service.ts
|
|
7457
7461
|
import chalk from "chalk";
|
|
7458
7462
|
|
|
7459
|
-
class
|
|
7463
|
+
class OutputService2 {
|
|
7460
7464
|
quiet = false;
|
|
7461
7465
|
jsonOutput = false;
|
|
7462
7466
|
noColor = false;
|
|
@@ -7546,7 +7550,7 @@ class EnvironmentService {
|
|
|
7546
7550
|
workflowComponent;
|
|
7547
7551
|
pluginComponent;
|
|
7548
7552
|
constructor(output) {
|
|
7549
|
-
this.output = output ?? new
|
|
7553
|
+
this.output = output ?? new OutputService2;
|
|
7550
7554
|
}
|
|
7551
7555
|
getEnvironment() {
|
|
7552
7556
|
return this.environment;
|
|
@@ -8420,7 +8424,7 @@ function createActCommand(externalEnvService) {
|
|
|
8420
8424
|
async handler(args) {
|
|
8421
8425
|
const quiet = args.quiet ?? true;
|
|
8422
8426
|
CliQuietModeService.getInstance().setQuiet(quiet);
|
|
8423
|
-
const output = new
|
|
8427
|
+
const output = new OutputService2;
|
|
8424
8428
|
output.configure({ quiet });
|
|
8425
8429
|
if (!args.message) {
|
|
8426
8430
|
output.error("请提供要执行的消息,使用方式:roy-agent act <消息>");
|
|
@@ -9275,6 +9279,130 @@ class InputHandler {
|
|
|
9275
9279
|
}
|
|
9276
9280
|
}
|
|
9277
9281
|
|
|
9282
|
+
// src/commands/interactive-event-sources.ts
|
|
9283
|
+
import { TracedAs as TracedAs4 } from "@ai-setting/roy-agent-core";
|
|
9284
|
+
async function startSingleEventSource(eventSourceComponent, output, eventSourceId) {
|
|
9285
|
+
return EventSourceStarter.instance.runSingle(eventSourceComponent, output, eventSourceId);
|
|
9286
|
+
}
|
|
9287
|
+
async function startEventSources(eventSourceIds, eventSourceComponent, output) {
|
|
9288
|
+
return EventSourceStarter.instance.run(eventSourceIds, eventSourceComponent, output);
|
|
9289
|
+
}
|
|
9290
|
+
|
|
9291
|
+
class EventSourceStarter {
|
|
9292
|
+
static instance = new EventSourceStarter;
|
|
9293
|
+
async run(eventSourceIds, eventSourceComponent, output) {
|
|
9294
|
+
return startEventSourcesImpl(eventSourceIds, eventSourceComponent, output);
|
|
9295
|
+
}
|
|
9296
|
+
async runSingle(eventSourceComponent, output, eventSourceId) {
|
|
9297
|
+
return startSingleEventSourceImpl(eventSourceComponent, output, eventSourceId);
|
|
9298
|
+
}
|
|
9299
|
+
}
|
|
9300
|
+
__legacyDecorateClassTS([
|
|
9301
|
+
TracedAs4("interactive.startEventSources", { recordParams: false, log: false }),
|
|
9302
|
+
__legacyMetadataTS("design:type", Function),
|
|
9303
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
9304
|
+
Array,
|
|
9305
|
+
typeof EventSourceComponentInterface === "undefined" ? Object : EventSourceComponentInterface,
|
|
9306
|
+
typeof OutputService === "undefined" ? Object : OutputService
|
|
9307
|
+
]),
|
|
9308
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
9309
|
+
], EventSourceStarter.prototype, "run", null);
|
|
9310
|
+
__legacyDecorateClassTS([
|
|
9311
|
+
TracedAs4("interactive.startSingleEventSource", { recordParams: false, log: false }),
|
|
9312
|
+
__legacyMetadataTS("design:type", Function),
|
|
9313
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
9314
|
+
typeof EventSourceComponentInterface === "undefined" ? Object : EventSourceComponentInterface,
|
|
9315
|
+
typeof OutputService === "undefined" ? Object : OutputService,
|
|
9316
|
+
String
|
|
9317
|
+
]),
|
|
9318
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
9319
|
+
], EventSourceStarter.prototype, "runSingle", null);
|
|
9320
|
+
async function startEventSourcesImpl(eventSourceIds, eventSourceComponent, output) {
|
|
9321
|
+
const results = [];
|
|
9322
|
+
if (!eventSourceIds || eventSourceIds.length === 0) {
|
|
9323
|
+
return { results, total: 0, successCount: 0, failedCount: 0 };
|
|
9324
|
+
}
|
|
9325
|
+
for (const id of eventSourceIds) {
|
|
9326
|
+
if (!id)
|
|
9327
|
+
continue;
|
|
9328
|
+
const result = await startSingleEventSource(eventSourceComponent, output, id);
|
|
9329
|
+
results.push(result);
|
|
9330
|
+
}
|
|
9331
|
+
const successCount = results.filter((r) => r.success).length;
|
|
9332
|
+
const failedCount = results.length - successCount;
|
|
9333
|
+
if (results.length > 1) {
|
|
9334
|
+
if (failedCount > 0) {
|
|
9335
|
+
output.info(`
|
|
9336
|
+
✅ 成功启动 ${successCount}/${results.length} 个事件源`);
|
|
9337
|
+
} else {
|
|
9338
|
+
output.success(`
|
|
9339
|
+
✅ 成功启动 ${successCount}/${results.length} 个事件源`);
|
|
9340
|
+
}
|
|
9341
|
+
}
|
|
9342
|
+
return { results, total: results.length, successCount, failedCount };
|
|
9343
|
+
}
|
|
9344
|
+
async function startSingleEventSourceImpl(eventSourceComponent, output, eventSourceId) {
|
|
9345
|
+
const sources = eventSourceComponent.list();
|
|
9346
|
+
const matchedSource = sources.find((s) => s.id === eventSourceId || s.id.startsWith(eventSourceId));
|
|
9347
|
+
if (!matchedSource) {
|
|
9348
|
+
output.error(`❌ 事件源不存在: ${eventSourceId}`);
|
|
9349
|
+
output.info(`可用的事件源:`);
|
|
9350
|
+
for (const s of sources) {
|
|
9351
|
+
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
9352
|
+
}
|
|
9353
|
+
return {
|
|
9354
|
+
id: eventSourceId,
|
|
9355
|
+
name: eventSourceId,
|
|
9356
|
+
success: false,
|
|
9357
|
+
status: "not_found",
|
|
9358
|
+
error: `EventSource not found: ${eventSourceId}`
|
|
9359
|
+
};
|
|
9360
|
+
}
|
|
9361
|
+
const actualId = matchedSource.id;
|
|
9362
|
+
const status = eventSourceComponent.getStatus(actualId);
|
|
9363
|
+
if (status === "running") {
|
|
9364
|
+
output.info(`\uD83D\uDCE1 事件源 ${matchedSource.name} 已在运行中`);
|
|
9365
|
+
return {
|
|
9366
|
+
id: actualId,
|
|
9367
|
+
name: matchedSource.name,
|
|
9368
|
+
success: true,
|
|
9369
|
+
status: "skipped"
|
|
9370
|
+
};
|
|
9371
|
+
}
|
|
9372
|
+
try {
|
|
9373
|
+
await eventSourceComponent.startSource(actualId);
|
|
9374
|
+
const verifyStatus = eventSourceComponent.getStatus(actualId);
|
|
9375
|
+
if (verifyStatus !== "running") {
|
|
9376
|
+
const errMsg = `启动后状态异常: ${verifyStatus}`;
|
|
9377
|
+
output.error(`❌ ${errMsg}`);
|
|
9378
|
+
return {
|
|
9379
|
+
id: actualId,
|
|
9380
|
+
name: matchedSource.name,
|
|
9381
|
+
success: false,
|
|
9382
|
+
status: "failed",
|
|
9383
|
+
error: errMsg
|
|
9384
|
+
};
|
|
9385
|
+
}
|
|
9386
|
+
output.success(`\uD83D\uDCE1 已启动事件源: ${matchedSource.name} (${verifyStatus})`);
|
|
9387
|
+
return {
|
|
9388
|
+
id: actualId,
|
|
9389
|
+
name: matchedSource.name,
|
|
9390
|
+
success: true,
|
|
9391
|
+
status: "started"
|
|
9392
|
+
};
|
|
9393
|
+
} catch (error) {
|
|
9394
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
9395
|
+
output.error(`❌ 启动事件源失败: ${matchedSource.name} - ${errMsg}`);
|
|
9396
|
+
return {
|
|
9397
|
+
id: actualId,
|
|
9398
|
+
name: matchedSource.name,
|
|
9399
|
+
success: false,
|
|
9400
|
+
status: "failed",
|
|
9401
|
+
error: errMsg
|
|
9402
|
+
};
|
|
9403
|
+
}
|
|
9404
|
+
}
|
|
9405
|
+
|
|
9278
9406
|
// src/commands/shared/ask-user-handler.ts
|
|
9279
9407
|
import * as readline from "readline";
|
|
9280
9408
|
import chalk3 from "chalk";
|
|
@@ -9815,8 +9943,9 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9815
9943
|
default: false
|
|
9816
9944
|
}).option("event-source", {
|
|
9817
9945
|
alias: "es",
|
|
9818
|
-
describe: "启动时一并启动的事件源 ID",
|
|
9819
|
-
type: "
|
|
9946
|
+
describe: "启动时一并启动的事件源 ID(可多次指定,支持 --es a --es b)",
|
|
9947
|
+
type: "array",
|
|
9948
|
+
string: true
|
|
9820
9949
|
}).option("plugin", {
|
|
9821
9950
|
alias: "p",
|
|
9822
9951
|
describe: "启用 plugin (tslsp, pylsp, mdlsp, lsp, code-check, reminder, memory, task-tag)",
|
|
@@ -9832,7 +9961,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9832
9961
|
}),
|
|
9833
9962
|
async handler(args) {
|
|
9834
9963
|
CliQuietModeService.getInstance().setQuiet(true);
|
|
9835
|
-
const output = new
|
|
9964
|
+
const output = new OutputService2;
|
|
9836
9965
|
const shouldDisposeEnvService = !externalEnvService;
|
|
9837
9966
|
const envService = externalEnvService ?? new EnvironmentService(output);
|
|
9838
9967
|
const CODER_HARNESS_PLUGINS = new Set([
|
|
@@ -10079,47 +10208,19 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10079
10208
|
}
|
|
10080
10209
|
});
|
|
10081
10210
|
const stopEventHandler = eventHandler.start();
|
|
10082
|
-
const
|
|
10083
|
-
|
|
10211
|
+
const rawEventSourceIds = args.eventSource;
|
|
10212
|
+
const eventSourceIds = Array.isArray(rawEventSourceIds) ? rawEventSourceIds.filter((s) => !!s) : rawEventSourceIds ? [rawEventSourceIds] : [];
|
|
10213
|
+
if (eventSourceIds.length > 0) {
|
|
10084
10214
|
const eventSourceComponent = env.getComponent("event-source");
|
|
10085
10215
|
if (!eventSourceComponent || typeof eventSourceComponent.startSource !== "function") {
|
|
10086
10216
|
output.error(`❌ 未找到事件源组件或 startSource 方法`);
|
|
10087
10217
|
output.info(`请确保 EventSourceComponent 已正确注册`);
|
|
10088
10218
|
process.exit(1);
|
|
10089
10219
|
}
|
|
10090
|
-
const
|
|
10091
|
-
|
|
10092
|
-
if (!matchedSource) {
|
|
10093
|
-
output.error(`❌ 事件源不存在: ${eventSourceId}`);
|
|
10094
|
-
output.info(`可用的事件源:`);
|
|
10095
|
-
for (const s of sources) {
|
|
10096
|
-
output.info(` - ${s.id}: ${s.name} (${s.type})`);
|
|
10097
|
-
}
|
|
10220
|
+
const summary = await startEventSources(eventSourceIds, eventSourceComponent, output);
|
|
10221
|
+
if (eventSourceIds.length === 1 && summary.failedCount > 0) {
|
|
10098
10222
|
process.exit(1);
|
|
10099
10223
|
}
|
|
10100
|
-
const actualId = matchedSource.id;
|
|
10101
|
-
const status = eventSourceComponent.getStatus(actualId);
|
|
10102
|
-
if (status === "running") {
|
|
10103
|
-
output.info(`\uD83D\uDCE1 事件源 ${matchedSource.name} 已在运行中`);
|
|
10104
|
-
} else {
|
|
10105
|
-
try {
|
|
10106
|
-
await eventSourceComponent.startSource(actualId);
|
|
10107
|
-
const verifyStatus = eventSourceComponent.getStatus(actualId);
|
|
10108
|
-
if (verifyStatus !== "running") {
|
|
10109
|
-
output.error(`❌ 事件源启动后状态异常: ${verifyStatus}`);
|
|
10110
|
-
output.info(`请检查日志确认后台进程是否正常运行`);
|
|
10111
|
-
process.exit(1);
|
|
10112
|
-
}
|
|
10113
|
-
output.success(`\uD83D\uDCE1 已启动事件源: ${matchedSource.name} (${verifyStatus})`);
|
|
10114
|
-
} catch (error) {
|
|
10115
|
-
output.error(`❌ 启动事件源失败: ${error}`);
|
|
10116
|
-
output.info(`常见问题:`);
|
|
10117
|
-
output.info(` - lark-cli 事件源:确保已安装并登录 lark-cli`);
|
|
10118
|
-
output.info(` - websocket 事件源:确保目标服务器可达`);
|
|
10119
|
-
output.info(` - timer 事件源:检查配置是否正确`);
|
|
10120
|
-
process.exit(1);
|
|
10121
|
-
}
|
|
10122
|
-
}
|
|
10123
10224
|
}
|
|
10124
10225
|
let sigintHandler;
|
|
10125
10226
|
sigintHandler = () => {
|
|
@@ -10182,7 +10283,7 @@ var ListCommand = {
|
|
|
10182
10283
|
if (isQuiet) {
|
|
10183
10284
|
CliQuietModeService.getInstance().setQuiet(true);
|
|
10184
10285
|
}
|
|
10185
|
-
const output = new
|
|
10286
|
+
const output = new OutputService2;
|
|
10186
10287
|
output.configure({ quiet: isQuiet });
|
|
10187
10288
|
const envService = new EnvironmentService(output);
|
|
10188
10289
|
try {
|
|
@@ -10219,6 +10320,8 @@ var ListCommand = {
|
|
|
10219
10320
|
const activeSessionId = sessionComponent.getActiveSessionId();
|
|
10220
10321
|
if (args.json) {
|
|
10221
10322
|
output.json({
|
|
10323
|
+
total: sessions.length,
|
|
10324
|
+
totalCount,
|
|
10222
10325
|
sessions: sessions.map((s) => {
|
|
10223
10326
|
const workflowMeta = s.metadata?.type === "workflow" ? s.metadata : null;
|
|
10224
10327
|
return {
|
|
@@ -10235,9 +10338,7 @@ var ListCommand = {
|
|
|
10235
10338
|
updatedAt: new Date(s.updatedAt).toISOString(),
|
|
10236
10339
|
isActive: s.id === activeSessionId
|
|
10237
10340
|
};
|
|
10238
|
-
})
|
|
10239
|
-
total: sessions.length,
|
|
10240
|
-
totalCount
|
|
10341
|
+
})
|
|
10241
10342
|
});
|
|
10242
10343
|
} else if (args.quiet || args.id) {
|
|
10243
10344
|
sessions.forEach((s) => output.log(s.id));
|
|
@@ -10311,7 +10412,7 @@ var GetCommand = {
|
|
|
10311
10412
|
}).option("messages", { type: "boolean", default: false }).option("checkpoints", { alias: "c", type: "boolean", default: false }).option("json", { alias: "j", type: "boolean", default: false }),
|
|
10312
10413
|
async handler(args) {
|
|
10313
10414
|
const a = args;
|
|
10314
|
-
const output = new
|
|
10415
|
+
const output = new OutputService2;
|
|
10315
10416
|
const envService = new EnvironmentService(output);
|
|
10316
10417
|
try {
|
|
10317
10418
|
await envService.create({ configPath: a.config });
|
|
@@ -10411,7 +10512,7 @@ var NewCommand = {
|
|
|
10411
10512
|
describe: "创建新会话",
|
|
10412
10513
|
builder: (yargs) => yargs.option("title", { alias: "t", type: "string" }).option("directory", { alias: "d", type: "string" }).option("active", { alias: "s", type: "boolean", default: false }).option("json", { type: "boolean", default: false }),
|
|
10413
10514
|
async handler(args) {
|
|
10414
|
-
const output = new
|
|
10515
|
+
const output = new OutputService2;
|
|
10415
10516
|
const envService = new EnvironmentService(output);
|
|
10416
10517
|
try {
|
|
10417
10518
|
await envService.create({ configPath: args.config });
|
|
@@ -10477,7 +10578,7 @@ var RenameCommand = {
|
|
|
10477
10578
|
}),
|
|
10478
10579
|
async handler(args) {
|
|
10479
10580
|
const a = args;
|
|
10480
|
-
const output = new
|
|
10581
|
+
const output = new OutputService2;
|
|
10481
10582
|
const envService = new EnvironmentService(output);
|
|
10482
10583
|
try {
|
|
10483
10584
|
await envService.create({ configPath: a.config });
|
|
@@ -10570,7 +10671,7 @@ var DeleteCommand = {
|
|
|
10570
10671
|
}),
|
|
10571
10672
|
async handler(args) {
|
|
10572
10673
|
const a = args;
|
|
10573
|
-
const output = new
|
|
10674
|
+
const output = new OutputService2;
|
|
10574
10675
|
const envService = new EnvironmentService(output);
|
|
10575
10676
|
try {
|
|
10576
10677
|
await envService.create({ configPath: a.config });
|
|
@@ -10717,7 +10818,7 @@ var MessagesCommand = {
|
|
|
10717
10818
|
}).option("limit", { alias: "n", type: "number", demandOption: true, describe: "返回消息数量" }).option("offset", { alias: "o", type: "number", demandOption: true, describe: "起始偏移量" }).option("reverse", { alias: "r", type: "boolean", default: false }).option("json", { alias: "j", type: "boolean", default: false }),
|
|
10718
10819
|
async handler(args) {
|
|
10719
10820
|
const a = args;
|
|
10720
|
-
const output = new
|
|
10821
|
+
const output = new OutputService2;
|
|
10721
10822
|
const envService = new EnvironmentService(output);
|
|
10722
10823
|
try {
|
|
10723
10824
|
await envService.create({ configPath: a.config });
|
|
@@ -10748,7 +10849,13 @@ var MessagesCommand = {
|
|
|
10748
10849
|
}
|
|
10749
10850
|
if (a.json) {
|
|
10750
10851
|
output.json({
|
|
10852
|
+
total: totalMessages,
|
|
10751
10853
|
sessionId: a.sessionId,
|
|
10854
|
+
pagination: {
|
|
10855
|
+
offset: a.offset,
|
|
10856
|
+
limit: a.limit,
|
|
10857
|
+
hasMore: a.offset + a.limit < totalMessages
|
|
10858
|
+
},
|
|
10752
10859
|
messages: messages.map((m) => ({
|
|
10753
10860
|
id: m.id,
|
|
10754
10861
|
role: m.role,
|
|
@@ -10756,13 +10863,7 @@ var MessagesCommand = {
|
|
|
10756
10863
|
parts: m.parts,
|
|
10757
10864
|
timestamp: new Date(m.timestamp).toISOString(),
|
|
10758
10865
|
isCheckpoint: m.metadata?.isCheckpoint
|
|
10759
|
-
}))
|
|
10760
|
-
total: totalMessages,
|
|
10761
|
-
pagination: {
|
|
10762
|
-
offset: a.offset,
|
|
10763
|
-
limit: a.limit,
|
|
10764
|
-
hasMore: a.offset + a.limit < totalMessages
|
|
10765
|
-
}
|
|
10866
|
+
}))
|
|
10766
10867
|
});
|
|
10767
10868
|
} else {
|
|
10768
10869
|
const checkpointStyle = (content) => {
|
|
@@ -10927,7 +11028,7 @@ var CompactCommand = {
|
|
|
10927
11028
|
}).option("process-key-points", { type: "string", description: "过程要点(逗号分隔)" }).option("current-state", { type: "string", description: "当前状态" }).option("next-steps", { type: "string", description: "后续待跟进(逗号分隔)" }).option("dry-run", { alias: "d", type: "boolean", default: false, description: "预览压缩效果" }).option("json", { alias: "j", type: "boolean", default: false }),
|
|
10928
11029
|
async handler(args) {
|
|
10929
11030
|
const a = args;
|
|
10930
|
-
const output = new
|
|
11031
|
+
const output = new OutputService2;
|
|
10931
11032
|
const envService = new EnvironmentService(output);
|
|
10932
11033
|
try {
|
|
10933
11034
|
await envService.create({ configPath: a.config });
|
|
@@ -11119,7 +11220,7 @@ var CheckpointsCommand = {
|
|
|
11119
11220
|
}).option("detail", { alias: "d", type: "boolean", default: false }).option("json", { alias: "j", type: "boolean", default: false }),
|
|
11120
11221
|
async handler(args) {
|
|
11121
11222
|
const a = args;
|
|
11122
|
-
const output = new
|
|
11223
|
+
const output = new OutputService2;
|
|
11123
11224
|
const envService = new EnvironmentService(output);
|
|
11124
11225
|
try {
|
|
11125
11226
|
await envService.create({ configPath: a.config });
|
|
@@ -11233,7 +11334,7 @@ var ActiveCommand = {
|
|
|
11233
11334
|
describe: "查看/设置当前活跃会话",
|
|
11234
11335
|
builder: (yargs) => yargs.option("clear", { type: "boolean", default: false }).option("json", { alias: "j", type: "boolean", default: false }),
|
|
11235
11336
|
async handler(args) {
|
|
11236
|
-
const output = new
|
|
11337
|
+
const output = new OutputService2;
|
|
11237
11338
|
const envService = new EnvironmentService(output);
|
|
11238
11339
|
try {
|
|
11239
11340
|
await envService.create({ configPath: args.config });
|
|
@@ -11312,7 +11413,7 @@ var AddMessageCommand = {
|
|
|
11312
11413
|
}).option("json", { alias: "j", type: "boolean", default: false }),
|
|
11313
11414
|
async handler(args) {
|
|
11314
11415
|
const a = args;
|
|
11315
|
-
const output = new
|
|
11416
|
+
const output = new OutputService2;
|
|
11316
11417
|
const envService = new EnvironmentService(output);
|
|
11317
11418
|
try {
|
|
11318
11419
|
await envService.create({ configPath: a.config });
|
|
@@ -11461,7 +11562,7 @@ var MockCommand = {
|
|
|
11461
11562
|
}).option("json", { alias: "j", type: "boolean", default: false }),
|
|
11462
11563
|
async handler(args) {
|
|
11463
11564
|
const a = args;
|
|
11464
|
-
const output = new
|
|
11565
|
+
const output = new OutputService2;
|
|
11465
11566
|
const envService = new EnvironmentService(output);
|
|
11466
11567
|
try {
|
|
11467
11568
|
await envService.create({ configPath: a.config });
|
|
@@ -11601,7 +11702,7 @@ var GrepCommand = {
|
|
|
11601
11702
|
if (isQuiet) {
|
|
11602
11703
|
CliQuietModeService.getInstance().setQuiet(true);
|
|
11603
11704
|
}
|
|
11604
|
-
const output = new
|
|
11705
|
+
const output = new OutputService2;
|
|
11605
11706
|
output.configure({ quiet: isQuiet });
|
|
11606
11707
|
const envService = new EnvironmentService(output);
|
|
11607
11708
|
try {
|
|
@@ -11750,6 +11851,35 @@ var SessionsCommand = {
|
|
|
11750
11851
|
|
|
11751
11852
|
// src/commands/tasks/list.ts
|
|
11752
11853
|
import chalk16 from "chalk";
|
|
11854
|
+
|
|
11855
|
+
// src/commands/tasks/_build-list-json.ts
|
|
11856
|
+
function buildListTasksJson(tasks, total, args, extras) {
|
|
11857
|
+
const projected = tasks.map((t) => ({
|
|
11858
|
+
id: t.id,
|
|
11859
|
+
title: t.title,
|
|
11860
|
+
status: t.status,
|
|
11861
|
+
priority: t.priority,
|
|
11862
|
+
type: t.type,
|
|
11863
|
+
progress: t.progress,
|
|
11864
|
+
current_status: t.current_status,
|
|
11865
|
+
project_path: t.project_path,
|
|
11866
|
+
context: t.context,
|
|
11867
|
+
createdAt: t.createdAt,
|
|
11868
|
+
updatedAt: t.updatedAt
|
|
11869
|
+
}));
|
|
11870
|
+
return {
|
|
11871
|
+
total,
|
|
11872
|
+
count: tasks.length,
|
|
11873
|
+
truncated: total > tasks.length,
|
|
11874
|
+
limit: args.limit,
|
|
11875
|
+
offset: args.offset,
|
|
11876
|
+
depth: args.depth,
|
|
11877
|
+
...extras ?? {},
|
|
11878
|
+
tasks: projected
|
|
11879
|
+
};
|
|
11880
|
+
}
|
|
11881
|
+
|
|
11882
|
+
// src/commands/tasks/list.ts
|
|
11753
11883
|
var ListCommand2 = {
|
|
11754
11884
|
command: "list",
|
|
11755
11885
|
aliases: ["ls"],
|
|
@@ -11777,7 +11907,7 @@ var ListCommand2 = {
|
|
|
11777
11907
|
description: "是否包含已归档任务(status=archived 的任务默认被排除)"
|
|
11778
11908
|
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
11779
11909
|
async handler(args) {
|
|
11780
|
-
const output = new
|
|
11910
|
+
const output = new OutputService2;
|
|
11781
11911
|
const envService = new EnvironmentService(output);
|
|
11782
11912
|
try {
|
|
11783
11913
|
await envService.create({ configPath: args.config });
|
|
@@ -11804,25 +11934,7 @@ var ListCommand2 = {
|
|
|
11804
11934
|
const tasks = listResult.tasks;
|
|
11805
11935
|
const total = listResult.total;
|
|
11806
11936
|
if (args.json) {
|
|
11807
|
-
output.json(
|
|
11808
|
-
tasks: tasks.map((t) => ({
|
|
11809
|
-
id: t.id,
|
|
11810
|
-
title: t.title,
|
|
11811
|
-
status: t.status,
|
|
11812
|
-
priority: t.priority,
|
|
11813
|
-
type: t.type,
|
|
11814
|
-
progress: t.progress,
|
|
11815
|
-
current_status: t.current_status,
|
|
11816
|
-
project_path: t.project_path,
|
|
11817
|
-
context: t.context,
|
|
11818
|
-
createdAt: t.createdAt,
|
|
11819
|
-
updatedAt: t.updatedAt
|
|
11820
|
-
})),
|
|
11821
|
-
total,
|
|
11822
|
-
count: tasks.length,
|
|
11823
|
-
limit: args.limit,
|
|
11824
|
-
offset: args.offset
|
|
11825
|
-
});
|
|
11937
|
+
output.json(buildListTasksJson(tasks, total, args));
|
|
11826
11938
|
} else if (args.quiet) {
|
|
11827
11939
|
tasks.forEach((t) => output.log(t.id.toString()));
|
|
11828
11940
|
} else {
|
|
@@ -11887,7 +11999,7 @@ var GetCommand2 = {
|
|
|
11887
11999
|
description: "包含操作记录"
|
|
11888
12000
|
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }),
|
|
11889
12001
|
async handler(args) {
|
|
11890
|
-
const output = new
|
|
12002
|
+
const output = new OutputService2;
|
|
11891
12003
|
const envService = new EnvironmentService(output);
|
|
11892
12004
|
try {
|
|
11893
12005
|
await envService.create({ configPath: args.config });
|
|
@@ -12014,7 +12126,7 @@ var CreateCommand = {
|
|
|
12014
12126
|
description: "任务上下文 (JSON 字符串)"
|
|
12015
12127
|
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }),
|
|
12016
12128
|
async handler(args) {
|
|
12017
|
-
const output = new
|
|
12129
|
+
const output = new OutputService2;
|
|
12018
12130
|
const envService = new EnvironmentService(output);
|
|
12019
12131
|
try {
|
|
12020
12132
|
await envService.create({ configPath: args.config });
|
|
@@ -12076,7 +12188,7 @@ var UpdateCommand = {
|
|
|
12076
12188
|
demandOption: true
|
|
12077
12189
|
}).option("title", { alias: "t", type: "string", description: "标题" }).option("description", { alias: "d", type: "string", description: "描述" }).option("status", { alias: "s", type: "string", choices: ["todo", "active", "completed", "paused", "cancelled"], description: "状态" }).option("priority", { alias: "p", type: "string", choices: ["low", "medium", "high"], description: "优先级" }).option("type", { type: "string", choices: ["normal", "cycle", "longterm"], description: "任务类型 (normal/cycle/longterm)" }).option("progress", { type: "number", min: 0, max: 100, description: "进度 (0-100)" }).option("current_status", { alias: "c", type: "string", description: "当前状态描述" }).option("project-path", { type: "string", description: "项目路径" }).option("context", { type: "string", description: "任务上下文 (JSON 字符串)" }).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }),
|
|
12078
12190
|
async handler(args) {
|
|
12079
|
-
const output = new
|
|
12191
|
+
const output = new OutputService2;
|
|
12080
12192
|
const envService = new EnvironmentService(output);
|
|
12081
12193
|
try {
|
|
12082
12194
|
await envService.create({ configPath: args.config });
|
|
@@ -12162,7 +12274,7 @@ var DeleteCommand2 = {
|
|
|
12162
12274
|
description: "强制删除,不确认"
|
|
12163
12275
|
}),
|
|
12164
12276
|
async handler(args) {
|
|
12165
|
-
const output = new
|
|
12277
|
+
const output = new OutputService2;
|
|
12166
12278
|
const envService = new EnvironmentService(output);
|
|
12167
12279
|
try {
|
|
12168
12280
|
await envService.create({ configPath: args.config });
|
|
@@ -12223,7 +12335,7 @@ var CompleteCommand = {
|
|
|
12223
12335
|
description: "Enable plugin (e.g., --plugin task-tag)"
|
|
12224
12336
|
}),
|
|
12225
12337
|
async handler(args) {
|
|
12226
|
-
const output = new
|
|
12338
|
+
const output = new OutputService2;
|
|
12227
12339
|
const envService = new EnvironmentService(output);
|
|
12228
12340
|
try {
|
|
12229
12341
|
await envService.create({
|
|
@@ -12297,7 +12409,7 @@ var OperationsCommand = {
|
|
|
12297
12409
|
}).option("limit", { alias: "n", type: "number", default: 20, description: "返回数量" }).option("offset", { type: "number", default: 0, description: "偏移量" }).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }),
|
|
12298
12410
|
async handler(args) {
|
|
12299
12411
|
const a = args;
|
|
12300
|
-
const output = new
|
|
12412
|
+
const output = new OutputService2;
|
|
12301
12413
|
const envService = new EnvironmentService(output);
|
|
12302
12414
|
try {
|
|
12303
12415
|
await envService.create({ configPath: a.config });
|
|
@@ -12325,9 +12437,9 @@ var OperationsCommand = {
|
|
|
12325
12437
|
const operations = await taskComponent.listOperations(listOptions);
|
|
12326
12438
|
if (a.json) {
|
|
12327
12439
|
output.json({
|
|
12440
|
+
count: operations.length,
|
|
12328
12441
|
task: { id: task.id, title: task.title },
|
|
12329
|
-
operations
|
|
12330
|
-
count: operations.length
|
|
12442
|
+
operations
|
|
12331
12443
|
});
|
|
12332
12444
|
} else {
|
|
12333
12445
|
output.log(chalk22.bold(`
|
|
@@ -12445,7 +12557,7 @@ var TreeCommand = {
|
|
|
12445
12557
|
description: "以 JSON 格式输出树形结构"
|
|
12446
12558
|
}),
|
|
12447
12559
|
async handler(args) {
|
|
12448
|
-
const output = new
|
|
12560
|
+
const output = new OutputService2;
|
|
12449
12561
|
const envService = new EnvironmentService(output);
|
|
12450
12562
|
try {
|
|
12451
12563
|
await envService.create({ configPath: args.config });
|
|
@@ -12548,7 +12660,7 @@ var SearchCommand = {
|
|
|
12548
12660
|
description: "是否包含已归档任务"
|
|
12549
12661
|
}).option("json", { alias: "j", type: "boolean", default: false, description: "JSON 输出" }).option("quiet", { alias: "q", type: "boolean", hidden: true }),
|
|
12550
12662
|
async handler(args) {
|
|
12551
|
-
const output = new
|
|
12663
|
+
const output = new OutputService2;
|
|
12552
12664
|
const envService = new EnvironmentService(output);
|
|
12553
12665
|
try {
|
|
12554
12666
|
await envService.create({ configPath: args.config });
|
|
@@ -12574,25 +12686,7 @@ var SearchCommand = {
|
|
|
12574
12686
|
const tasks = result.tasks;
|
|
12575
12687
|
const total = result.total;
|
|
12576
12688
|
if (args.json) {
|
|
12577
|
-
output.json({
|
|
12578
|
-
keywords: args.keywords,
|
|
12579
|
-
tasks: tasks.map((t) => ({
|
|
12580
|
-
id: t.id,
|
|
12581
|
-
title: t.title,
|
|
12582
|
-
status: t.status,
|
|
12583
|
-
priority: t.priority,
|
|
12584
|
-
type: t.type,
|
|
12585
|
-
progress: t.progress,
|
|
12586
|
-
parent_task_id: t.parent_task_id,
|
|
12587
|
-
project_path: t.project_path,
|
|
12588
|
-
createdAt: t.createdAt,
|
|
12589
|
-
updatedAt: t.updatedAt
|
|
12590
|
-
})),
|
|
12591
|
-
total,
|
|
12592
|
-
count: tasks.length,
|
|
12593
|
-
limit: args.limit,
|
|
12594
|
-
offset: args.offset
|
|
12595
|
-
});
|
|
12689
|
+
output.json(buildListTasksJson(tasks, total, { limit: args.limit, offset: args.offset }, { keywords: args.keywords }));
|
|
12596
12690
|
} else if (args.quiet) {
|
|
12597
12691
|
tasks.forEach((t) => output.log(t.id.toString()));
|
|
12598
12692
|
} else {
|
|
@@ -12900,7 +12994,7 @@ var ListCommand3 = {
|
|
|
12900
12994
|
}),
|
|
12901
12995
|
async handler(args) {
|
|
12902
12996
|
const a = args;
|
|
12903
|
-
const output = new
|
|
12997
|
+
const output = new OutputService2;
|
|
12904
12998
|
const envService = new EnvironmentService(output);
|
|
12905
12999
|
try {
|
|
12906
13000
|
await envService.create({ configPath: a.config });
|
|
@@ -12918,12 +13012,12 @@ var ListCommand3 = {
|
|
|
12918
13012
|
const filtered = a.source && a.source !== "all" ? skills.filter((s) => s.source === a.source) : skills;
|
|
12919
13013
|
if (a.json) {
|
|
12920
13014
|
output.json({
|
|
13015
|
+
count: filtered.length,
|
|
12921
13016
|
skills: filtered.map((s) => ({
|
|
12922
13017
|
name: s.name,
|
|
12923
13018
|
description: s.description,
|
|
12924
13019
|
source: s.source
|
|
12925
|
-
}))
|
|
12926
|
-
count: filtered.length
|
|
13020
|
+
}))
|
|
12927
13021
|
});
|
|
12928
13022
|
} else if (a.quiet) {
|
|
12929
13023
|
filtered.forEach((s) => output.log(s.name));
|
|
@@ -12989,7 +13083,7 @@ var GetCommand3 = {
|
|
|
12989
13083
|
description: "JSON 输出"
|
|
12990
13084
|
}),
|
|
12991
13085
|
async handler(args) {
|
|
12992
|
-
const output = new
|
|
13086
|
+
const output = new OutputService2;
|
|
12993
13087
|
const envService = new EnvironmentService(output);
|
|
12994
13088
|
try {
|
|
12995
13089
|
await envService.create({ configPath: args.config });
|
|
@@ -13059,7 +13153,7 @@ var SearchCommand2 = {
|
|
|
13059
13153
|
description: "简洁输出"
|
|
13060
13154
|
}),
|
|
13061
13155
|
async handler(args) {
|
|
13062
|
-
const output = new
|
|
13156
|
+
const output = new OutputService2;
|
|
13063
13157
|
const envService = new EnvironmentService(output);
|
|
13064
13158
|
try {
|
|
13065
13159
|
await envService.create({ configPath: args.config });
|
|
@@ -13082,14 +13176,14 @@ var SearchCommand2 = {
|
|
|
13082
13176
|
}
|
|
13083
13177
|
if (args.json) {
|
|
13084
13178
|
output.json({
|
|
13179
|
+
count: results.length,
|
|
13180
|
+
term: args.term,
|
|
13085
13181
|
results: results.map((s) => ({
|
|
13086
13182
|
name: s.name,
|
|
13087
13183
|
description: s.description,
|
|
13088
13184
|
source: s.source,
|
|
13089
13185
|
matchedIn: s.name.toLowerCase().includes(term) ? "name" : "description"
|
|
13090
|
-
}))
|
|
13091
|
-
count: results.length,
|
|
13092
|
-
term: args.term
|
|
13186
|
+
}))
|
|
13093
13187
|
});
|
|
13094
13188
|
} else if (args.quiet) {
|
|
13095
13189
|
results.forEach((s) => output.log(s.name));
|
|
@@ -13141,7 +13235,7 @@ var ReloadCommand = {
|
|
|
13141
13235
|
description: "配置文件路径"
|
|
13142
13236
|
}),
|
|
13143
13237
|
async handler(args) {
|
|
13144
|
-
const output = new
|
|
13238
|
+
const output = new OutputService2;
|
|
13145
13239
|
const envService = new EnvironmentService(output);
|
|
13146
13240
|
try {
|
|
13147
13241
|
await envService.create({ configPath: args.config });
|
|
@@ -13179,7 +13273,7 @@ var ShowConfigCommand = {
|
|
|
13179
13273
|
description: "配置文件路径"
|
|
13180
13274
|
}),
|
|
13181
13275
|
async handler(args) {
|
|
13182
|
-
const output = new
|
|
13276
|
+
const output = new OutputService2;
|
|
13183
13277
|
const envService = new EnvironmentService(output);
|
|
13184
13278
|
try {
|
|
13185
13279
|
await envService.create({ configPath: args.config });
|
|
@@ -13269,7 +13363,7 @@ var ListCommand4 = {
|
|
|
13269
13363
|
description: "简洁输出"
|
|
13270
13364
|
}),
|
|
13271
13365
|
async handler(args) {
|
|
13272
|
-
const output = new
|
|
13366
|
+
const output = new OutputService2;
|
|
13273
13367
|
const envService = new EnvironmentService(output);
|
|
13274
13368
|
try {
|
|
13275
13369
|
await envService.create({ configPath: args.config });
|
|
@@ -13296,6 +13390,7 @@ var ListCommand4 = {
|
|
|
13296
13390
|
}
|
|
13297
13391
|
if (args.json) {
|
|
13298
13392
|
output.json({
|
|
13393
|
+
count: agents.length,
|
|
13299
13394
|
agents: agents.map((a) => ({
|
|
13300
13395
|
name: a.name,
|
|
13301
13396
|
type: a.type,
|
|
@@ -13304,8 +13399,7 @@ var ListCommand4 = {
|
|
|
13304
13399
|
model: a.model,
|
|
13305
13400
|
systemPromptRef: a.systemPromptRef,
|
|
13306
13401
|
hasInlinePrompt: !!a.systemPrompt
|
|
13307
|
-
}))
|
|
13308
|
-
count: agents.length
|
|
13402
|
+
}))
|
|
13309
13403
|
});
|
|
13310
13404
|
} else if (args.quiet) {
|
|
13311
13405
|
agents.forEach((a) => output.log(a.name));
|
|
@@ -13378,7 +13472,7 @@ var GetCommand4 = {
|
|
|
13378
13472
|
description: "JSON 输出"
|
|
13379
13473
|
}),
|
|
13380
13474
|
async handler(args) {
|
|
13381
|
-
const output = new
|
|
13475
|
+
const output = new OutputService2;
|
|
13382
13476
|
const envService = new EnvironmentService(output);
|
|
13383
13477
|
try {
|
|
13384
13478
|
await envService.create({ configPath: args.config });
|
|
@@ -13548,7 +13642,7 @@ var AddCommand = {
|
|
|
13548
13642
|
description: "JSON 输出"
|
|
13549
13643
|
}),
|
|
13550
13644
|
async handler(args) {
|
|
13551
|
-
const output = new
|
|
13645
|
+
const output = new OutputService2;
|
|
13552
13646
|
const envService = new EnvironmentService(output);
|
|
13553
13647
|
try {
|
|
13554
13648
|
await envService.create({ configPath: args.config });
|
|
@@ -13624,7 +13718,7 @@ var DeleteCommand3 = {
|
|
|
13624
13718
|
description: "JSON 输出"
|
|
13625
13719
|
}),
|
|
13626
13720
|
async handler(args) {
|
|
13627
|
-
const output = new
|
|
13721
|
+
const output = new OutputService2;
|
|
13628
13722
|
const envService = new EnvironmentService(output);
|
|
13629
13723
|
try {
|
|
13630
13724
|
await envService.create({ configPath: args.config });
|
|
@@ -13680,7 +13774,7 @@ var ConfigDirCommand = {
|
|
|
13680
13774
|
description: "JSON 输出"
|
|
13681
13775
|
}),
|
|
13682
13776
|
async handler(args) {
|
|
13683
|
-
const output = new
|
|
13777
|
+
const output = new OutputService2;
|
|
13684
13778
|
const envService = new EnvironmentService(output);
|
|
13685
13779
|
try {
|
|
13686
13780
|
await envService.create({ configPath: args.config });
|
|
@@ -13747,7 +13841,7 @@ var ListCommand5 = {
|
|
|
13747
13841
|
description: "简洁输出"
|
|
13748
13842
|
}),
|
|
13749
13843
|
async handler(args) {
|
|
13750
|
-
const output = new
|
|
13844
|
+
const output = new OutputService2;
|
|
13751
13845
|
const envService = new EnvironmentService(output);
|
|
13752
13846
|
try {
|
|
13753
13847
|
await envService.create({ configPath: args.config });
|
|
@@ -13834,7 +13928,7 @@ var GetCommand5 = {
|
|
|
13834
13928
|
description: "变量替换,格式:key=value"
|
|
13835
13929
|
}),
|
|
13836
13930
|
async handler(args) {
|
|
13837
|
-
const output = new
|
|
13931
|
+
const output = new OutputService2;
|
|
13838
13932
|
const envService = new EnvironmentService(output);
|
|
13839
13933
|
try {
|
|
13840
13934
|
await envService.create({ configPath: args.config });
|
|
@@ -13923,7 +14017,7 @@ var AddCommand2 = {
|
|
|
13923
14017
|
description: "JSON 输出"
|
|
13924
14018
|
}),
|
|
13925
14019
|
async handler(args) {
|
|
13926
|
-
const output = new
|
|
14020
|
+
const output = new OutputService2;
|
|
13927
14021
|
const envService = new EnvironmentService(output);
|
|
13928
14022
|
try {
|
|
13929
14023
|
if (!args.file && !args.content) {
|
|
@@ -13975,7 +14069,7 @@ var ConfigDirCommand2 = {
|
|
|
13975
14069
|
description: "JSON 输出"
|
|
13976
14070
|
}),
|
|
13977
14071
|
async handler(args) {
|
|
13978
|
-
const output = new
|
|
14072
|
+
const output = new OutputService2;
|
|
13979
14073
|
const envService = new EnvironmentService(output);
|
|
13980
14074
|
try {
|
|
13981
14075
|
await envService.create({ configPath: args.config });
|
|
@@ -14070,7 +14164,7 @@ var CommandsListCommand = {
|
|
|
14070
14164
|
type: "string"
|
|
14071
14165
|
}),
|
|
14072
14166
|
async handler(args) {
|
|
14073
|
-
const output = new
|
|
14167
|
+
const output = new OutputService2;
|
|
14074
14168
|
const envService = new EnvironmentService(output);
|
|
14075
14169
|
try {
|
|
14076
14170
|
await envService.create({ configPath: args.config });
|
|
@@ -14153,7 +14247,7 @@ var CommandsAddCommand = {
|
|
|
14153
14247
|
type: "string"
|
|
14154
14248
|
}),
|
|
14155
14249
|
async handler(args) {
|
|
14156
|
-
const output = new
|
|
14250
|
+
const output = new OutputService2;
|
|
14157
14251
|
const envService = new EnvironmentService(output);
|
|
14158
14252
|
try {
|
|
14159
14253
|
await envService.create({ configPath: args.config });
|
|
@@ -14215,7 +14309,7 @@ var CommandsRemoveCommand = {
|
|
|
14215
14309
|
type: "string"
|
|
14216
14310
|
}),
|
|
14217
14311
|
async handler(args) {
|
|
14218
|
-
const output = new
|
|
14312
|
+
const output = new OutputService2;
|
|
14219
14313
|
const envService = new EnvironmentService(output);
|
|
14220
14314
|
try {
|
|
14221
14315
|
await envService.create({ configPath: args.config });
|
|
@@ -14312,7 +14406,7 @@ var CommandsInfoCommand = {
|
|
|
14312
14406
|
type: "string"
|
|
14313
14407
|
}),
|
|
14314
14408
|
async handler(args) {
|
|
14315
|
-
const output = new
|
|
14409
|
+
const output = new OutputService2;
|
|
14316
14410
|
const envService = new EnvironmentService(output);
|
|
14317
14411
|
try {
|
|
14318
14412
|
await envService.create({ configPath: args.config });
|
|
@@ -14373,7 +14467,7 @@ var CommandsDirsCommand = {
|
|
|
14373
14467
|
type: "string"
|
|
14374
14468
|
}),
|
|
14375
14469
|
async handler(args) {
|
|
14376
|
-
const output = new
|
|
14470
|
+
const output = new OutputService2;
|
|
14377
14471
|
const envService = new EnvironmentService(output);
|
|
14378
14472
|
try {
|
|
14379
14473
|
await envService.create({ configPath: args.config });
|
|
@@ -14688,7 +14782,7 @@ var ConfigListCommand = {
|
|
|
14688
14782
|
alias: "c"
|
|
14689
14783
|
}).example("roy-agent config list", "显示帮助信息").example("roy-agent config list tool", "查看 tool component 配置").example("roy-agent config list session", "查看 session component 配置").example("roy-agent config list all", "查看所有 components 概览").example("roy-agent config list tool --json", "JSON 格式输出").example("roy-agent config list tool --keys", "只显示配置键"),
|
|
14690
14784
|
async handler(args) {
|
|
14691
|
-
const output = new
|
|
14785
|
+
const output = new OutputService2;
|
|
14692
14786
|
const envService = new EnvironmentService(output);
|
|
14693
14787
|
try {
|
|
14694
14788
|
await envService.create({ configPath: args.config });
|
|
@@ -14980,7 +15074,7 @@ var ConfigExportCommand = {
|
|
|
14980
15074
|
alias: "c"
|
|
14981
15075
|
}).example("roy-agent config export agent --file agent-config.json", "导出 agent 配置").example("roy-agent config export session --file session-config.json", "导出 session 配置"),
|
|
14982
15076
|
async handler(args) {
|
|
14983
|
-
const output = new
|
|
15077
|
+
const output = new OutputService2;
|
|
14984
15078
|
const envService = new EnvironmentService(output);
|
|
14985
15079
|
try {
|
|
14986
15080
|
await envService.create({ configPath: args.config });
|
|
@@ -15048,7 +15142,7 @@ var ConfigImportCommand = {
|
|
|
15048
15142
|
alias: "c"
|
|
15049
15143
|
}).example("roy-agent config import session --file session-config.json", "导入 session 配置").example("roy-agent config import session --file session-config.json --dry-run", "预览变更").example("roy-agent config import session --file session-config.json --verbose", "显示详细信息"),
|
|
15050
15144
|
async handler(args) {
|
|
15051
|
-
const output = new
|
|
15145
|
+
const output = new OutputService2;
|
|
15052
15146
|
const envService = new EnvironmentService(output);
|
|
15053
15147
|
try {
|
|
15054
15148
|
await envService.create({ configPath: args.config });
|
|
@@ -15125,7 +15219,7 @@ var ListCommand6 = {
|
|
|
15125
15219
|
description: "简洁输出"
|
|
15126
15220
|
}),
|
|
15127
15221
|
async handler(args) {
|
|
15128
|
-
const output = new
|
|
15222
|
+
const output = new OutputService2;
|
|
15129
15223
|
const envService = new EnvironmentService(output);
|
|
15130
15224
|
try {
|
|
15131
15225
|
await envService.create({ configPath: args.config });
|
|
@@ -15223,7 +15317,7 @@ var ToolsCommand = {
|
|
|
15223
15317
|
description: "简洁输出"
|
|
15224
15318
|
}),
|
|
15225
15319
|
async handler(args) {
|
|
15226
|
-
const output = new
|
|
15320
|
+
const output = new OutputService2;
|
|
15227
15321
|
const envService = new EnvironmentService(output);
|
|
15228
15322
|
try {
|
|
15229
15323
|
await envService.create({ configPath: args.config });
|
|
@@ -15243,13 +15337,13 @@ var ToolsCommand = {
|
|
|
15243
15337
|
}
|
|
15244
15338
|
if (args.json) {
|
|
15245
15339
|
output.json({
|
|
15340
|
+
count: tools.length,
|
|
15246
15341
|
tools: tools.map((t) => ({
|
|
15247
15342
|
name: t.name,
|
|
15248
15343
|
description: t.description,
|
|
15249
15344
|
category: t.metadata?.category,
|
|
15250
15345
|
tags: t.metadata?.tags
|
|
15251
|
-
}))
|
|
15252
|
-
count: tools.length
|
|
15346
|
+
}))
|
|
15253
15347
|
});
|
|
15254
15348
|
} else if (args.quiet) {
|
|
15255
15349
|
tools.forEach((t) => output.log(t.name));
|
|
@@ -15295,7 +15389,7 @@ var ReloadCommand2 = {
|
|
|
15295
15389
|
describe: "重新加载 MCP 服务器",
|
|
15296
15390
|
builder: (yargs) => yargs,
|
|
15297
15391
|
async handler(args) {
|
|
15298
|
-
const output = new
|
|
15392
|
+
const output = new OutputService2;
|
|
15299
15393
|
const envService = new EnvironmentService(output);
|
|
15300
15394
|
try {
|
|
15301
15395
|
await envService.create({ configPath: args.config });
|
|
@@ -15359,7 +15453,7 @@ var ListCommand7 = {
|
|
|
15359
15453
|
description: "简洁输出(仅名称)"
|
|
15360
15454
|
}),
|
|
15361
15455
|
async handler(args) {
|
|
15362
|
-
const output = new
|
|
15456
|
+
const output = new OutputService2;
|
|
15363
15457
|
const envService = new EnvironmentService(output);
|
|
15364
15458
|
try {
|
|
15365
15459
|
await envService.create({ configPath: args.config });
|
|
@@ -15376,12 +15470,12 @@ var ListCommand7 = {
|
|
|
15376
15470
|
const tools = toolComponent.listTools();
|
|
15377
15471
|
if (args.json) {
|
|
15378
15472
|
output.json({
|
|
15473
|
+
count: tools.length,
|
|
15379
15474
|
tools: tools.map((t) => ({
|
|
15380
15475
|
name: t.name,
|
|
15381
15476
|
description: t.description,
|
|
15382
15477
|
category: t.metadata?.category
|
|
15383
|
-
}))
|
|
15384
|
-
count: tools.length
|
|
15478
|
+
}))
|
|
15385
15479
|
});
|
|
15386
15480
|
} else if (args.quiet) {
|
|
15387
15481
|
tools.forEach((t) => output.log(t.name));
|
|
@@ -15459,7 +15553,7 @@ var GetCommand6 = {
|
|
|
15459
15553
|
description: "JSON 输出"
|
|
15460
15554
|
}),
|
|
15461
15555
|
async handler(args) {
|
|
15462
|
-
const output = new
|
|
15556
|
+
const output = new OutputService2;
|
|
15463
15557
|
const envService = new EnvironmentService(output);
|
|
15464
15558
|
try {
|
|
15465
15559
|
await envService.create({ configPath: args.config });
|
|
@@ -15534,7 +15628,7 @@ var ExecToolCommand = {
|
|
|
15534
15628
|
}).strict(false);
|
|
15535
15629
|
},
|
|
15536
15630
|
async handler(args) {
|
|
15537
|
-
const output = new
|
|
15631
|
+
const output = new OutputService2;
|
|
15538
15632
|
const envService = new EnvironmentService(output);
|
|
15539
15633
|
const toolName = args.name;
|
|
15540
15634
|
try {
|
|
@@ -15767,7 +15861,7 @@ var RecordCommand = {
|
|
|
15767
15861
|
}),
|
|
15768
15862
|
async handler(args) {
|
|
15769
15863
|
const a = args;
|
|
15770
|
-
const output = new
|
|
15864
|
+
const output = new OutputService2;
|
|
15771
15865
|
const envService = new EnvironmentService(output);
|
|
15772
15866
|
try {
|
|
15773
15867
|
await envService.create({ configPath: a.config });
|
|
@@ -15848,7 +15942,7 @@ var RecallCommand = {
|
|
|
15848
15942
|
}),
|
|
15849
15943
|
async handler(args) {
|
|
15850
15944
|
const a = args;
|
|
15851
|
-
const output = new
|
|
15945
|
+
const output = new OutputService2;
|
|
15852
15946
|
const envService = new EnvironmentService(output);
|
|
15853
15947
|
try {
|
|
15854
15948
|
await envService.create({ configPath: a.config });
|
|
@@ -15949,7 +16043,7 @@ var EventSourceListCommand = {
|
|
|
15949
16043
|
default: false
|
|
15950
16044
|
}),
|
|
15951
16045
|
async handler(args) {
|
|
15952
|
-
const output = new
|
|
16046
|
+
const output = new OutputService2;
|
|
15953
16047
|
output.configure({ quiet: args.quiet });
|
|
15954
16048
|
const envService = new EnvironmentService(output);
|
|
15955
16049
|
try {
|
|
@@ -16051,10 +16145,13 @@ var EventSourceAddCommand = {
|
|
|
16051
16145
|
}).option("cron", {
|
|
16052
16146
|
describe: "Cron 表达式",
|
|
16053
16147
|
type: "string"
|
|
16148
|
+
}).option("prompt", {
|
|
16149
|
+
describe: "自定义 prompt 消息(timer 类型,替换默认 SelfReminder 内容)",
|
|
16150
|
+
type: "string"
|
|
16054
16151
|
}),
|
|
16055
16152
|
async handler(args) {
|
|
16056
16153
|
const a = args;
|
|
16057
|
-
const output = new
|
|
16154
|
+
const output = new OutputService2;
|
|
16058
16155
|
const envService = new EnvironmentService(output);
|
|
16059
16156
|
try {
|
|
16060
16157
|
await envService.create({ configPath: a.config });
|
|
@@ -16078,7 +16175,8 @@ var EventSourceAddCommand = {
|
|
|
16078
16175
|
command: a.command,
|
|
16079
16176
|
url: a.url,
|
|
16080
16177
|
interval: a.interval,
|
|
16081
|
-
cron: a.cron
|
|
16178
|
+
cron: a.cron,
|
|
16179
|
+
options: a.prompt ? { prompt: a.prompt } : undefined
|
|
16082
16180
|
};
|
|
16083
16181
|
esComponent.register(config);
|
|
16084
16182
|
output.success(chalk55.green(`事件源 '${a.name}' 添加成功!`));
|
|
@@ -16094,6 +16192,9 @@ var EventSourceAddCommand = {
|
|
|
16094
16192
|
if (a.interval) {
|
|
16095
16193
|
output.log(` Interval: ${chalk55.gray(`${a.interval}ms`)}`);
|
|
16096
16194
|
}
|
|
16195
|
+
if (a.prompt) {
|
|
16196
|
+
output.log(` Prompt: ${chalk55.gray(a.prompt.length > 60 ? a.prompt.slice(0, 60) + "..." : a.prompt)}`);
|
|
16197
|
+
}
|
|
16097
16198
|
output.log("");
|
|
16098
16199
|
output.log(chalk55.gray(`使用 'roy-agent eventsource start ${config.id.substring(0, 8)}' 启动它。`));
|
|
16099
16200
|
} finally {
|
|
@@ -16102,8 +16203,132 @@ var EventSourceAddCommand = {
|
|
|
16102
16203
|
}
|
|
16103
16204
|
};
|
|
16104
16205
|
|
|
16105
|
-
// src/commands/eventsource/
|
|
16206
|
+
// src/commands/eventsource/update.ts
|
|
16106
16207
|
import chalk56 from "chalk";
|
|
16208
|
+
function findSource(esComponent, id) {
|
|
16209
|
+
const sources = esComponent.list();
|
|
16210
|
+
const matched = sources.find((s) => s.id === id || s.id.startsWith(id));
|
|
16211
|
+
if (!matched)
|
|
16212
|
+
return null;
|
|
16213
|
+
return { source: matched, fullId: matched.id };
|
|
16214
|
+
}
|
|
16215
|
+
var EventSourceUpdateCommand = {
|
|
16216
|
+
command: "update <id>",
|
|
16217
|
+
describe: "更新事件源配置(部分更新,type 不可改)",
|
|
16218
|
+
builder: (yargs) => yargs.positional("id", {
|
|
16219
|
+
describe: "事件源 ID(支持前缀匹配)",
|
|
16220
|
+
type: "string",
|
|
16221
|
+
demandOption: true
|
|
16222
|
+
}).option("name", {
|
|
16223
|
+
describe: "事件源名称",
|
|
16224
|
+
type: "string"
|
|
16225
|
+
}).option("interval", {
|
|
16226
|
+
alias: "i",
|
|
16227
|
+
describe: "定时器间隔(毫秒)",
|
|
16228
|
+
type: "number"
|
|
16229
|
+
}).option("event-types", {
|
|
16230
|
+
alias: "e",
|
|
16231
|
+
describe: "事件类型过滤(逗号分隔)",
|
|
16232
|
+
type: "string"
|
|
16233
|
+
}).option("command", {
|
|
16234
|
+
alias: "c",
|
|
16235
|
+
describe: "执行的命令(lark-cli 类型)",
|
|
16236
|
+
type: "string"
|
|
16237
|
+
}).option("url", {
|
|
16238
|
+
alias: "u",
|
|
16239
|
+
describe: "WebSocket URL",
|
|
16240
|
+
type: "string"
|
|
16241
|
+
}).option("cron", {
|
|
16242
|
+
describe: "Cron 表达式",
|
|
16243
|
+
type: "string"
|
|
16244
|
+
}).option("prompt", {
|
|
16245
|
+
describe: "自定义 prompt 消息(timer 类型)",
|
|
16246
|
+
type: "string"
|
|
16247
|
+
}).option("enabled", {
|
|
16248
|
+
describe: "是否启用",
|
|
16249
|
+
type: "boolean"
|
|
16250
|
+
}),
|
|
16251
|
+
async handler(args) {
|
|
16252
|
+
const a = args;
|
|
16253
|
+
const output = new OutputService2;
|
|
16254
|
+
const envService = new EnvironmentService(output);
|
|
16255
|
+
try {
|
|
16256
|
+
await envService.create({ configPath: a.config });
|
|
16257
|
+
const env = envService.getEnvironment();
|
|
16258
|
+
if (!env) {
|
|
16259
|
+
output.error("Failed to create environment");
|
|
16260
|
+
process.exit(1);
|
|
16261
|
+
}
|
|
16262
|
+
const esComponent = env.getComponent("event-source");
|
|
16263
|
+
if (!esComponent) {
|
|
16264
|
+
output.error("EventSourceComponent not available");
|
|
16265
|
+
process.exit(1);
|
|
16266
|
+
}
|
|
16267
|
+
const match = findSource(esComponent, a.id);
|
|
16268
|
+
if (!match) {
|
|
16269
|
+
output.error(`❌ 事件源不存在: ${a.id}`);
|
|
16270
|
+
const all = esComponent.list();
|
|
16271
|
+
if (all.length > 0) {
|
|
16272
|
+
output.info("");
|
|
16273
|
+
output.info(chalk56.gray("可用的事件源:"));
|
|
16274
|
+
for (const s of all) {
|
|
16275
|
+
output.info(` - ${s.id.substring(0, 8)}: ${s.name} (${s.type})`);
|
|
16276
|
+
}
|
|
16277
|
+
}
|
|
16278
|
+
process.exit(1);
|
|
16279
|
+
}
|
|
16280
|
+
const partial = {};
|
|
16281
|
+
if (a.name !== undefined)
|
|
16282
|
+
partial.name = a.name;
|
|
16283
|
+
if (a.interval !== undefined)
|
|
16284
|
+
partial.interval = a.interval;
|
|
16285
|
+
if (a.eventTypes !== undefined) {
|
|
16286
|
+
partial.eventTypes = a.eventTypes.split(",").map((s) => s.trim()).filter(Boolean);
|
|
16287
|
+
}
|
|
16288
|
+
if (a.command !== undefined)
|
|
16289
|
+
partial.command = a.command;
|
|
16290
|
+
if (a.url !== undefined)
|
|
16291
|
+
partial.url = a.url;
|
|
16292
|
+
if (a.cron !== undefined)
|
|
16293
|
+
partial.cron = a.cron;
|
|
16294
|
+
if (a.enabled !== undefined)
|
|
16295
|
+
partial.enabled = a.enabled;
|
|
16296
|
+
if (a.prompt !== undefined) {
|
|
16297
|
+
const existingOptions = match.source.options ?? {};
|
|
16298
|
+
partial.options = { ...existingOptions, prompt: a.prompt };
|
|
16299
|
+
}
|
|
16300
|
+
if (Object.keys(partial).length === 0) {
|
|
16301
|
+
output.error("❌ 请至少提供一个要更新的字段(如 --interval, --prompt 等)");
|
|
16302
|
+
process.exit(1);
|
|
16303
|
+
}
|
|
16304
|
+
try {
|
|
16305
|
+
const result = await esComponent.update(match.fullId, partial);
|
|
16306
|
+
output.success(chalk56.green(`✅ 事件源已更新: ${match.source.name}`));
|
|
16307
|
+
output.log("");
|
|
16308
|
+
output.log(chalk56.bold("修改字段:"));
|
|
16309
|
+
const before = match.source;
|
|
16310
|
+
const after = result.updated;
|
|
16311
|
+
for (const field of result.fields) {
|
|
16312
|
+
const beforeVal = JSON.stringify(before[field] ?? before.options?.[field]);
|
|
16313
|
+
const afterVal = JSON.stringify(after[field] ?? after.options?.[field]);
|
|
16314
|
+
output.log(` ${chalk56.cyan(field)}: ${chalk56.gray(beforeVal)} ${chalk56.gray("→")} ${chalk56.green(afterVal)}`);
|
|
16315
|
+
}
|
|
16316
|
+
output.log("");
|
|
16317
|
+
if (result.wasRunning) {
|
|
16318
|
+
output.info(chalk56.yellow(`⚠️ 事件源在更新前正在运行,已自动停止。请使用 'roy-agent eventsource start ${match.fullId.substring(0, 8)}' 手动启动以应用新配置。`));
|
|
16319
|
+
}
|
|
16320
|
+
} catch (error) {
|
|
16321
|
+
output.error(`❌ 更新失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
16322
|
+
process.exit(1);
|
|
16323
|
+
}
|
|
16324
|
+
} finally {
|
|
16325
|
+
await envService.dispose();
|
|
16326
|
+
}
|
|
16327
|
+
}
|
|
16328
|
+
};
|
|
16329
|
+
|
|
16330
|
+
// src/commands/eventsource/remove.ts
|
|
16331
|
+
import chalk57 from "chalk";
|
|
16107
16332
|
var EventSourceRemoveCommand = {
|
|
16108
16333
|
command: "remove <id>",
|
|
16109
16334
|
aliases: ["rm"],
|
|
@@ -16119,7 +16344,7 @@ var EventSourceRemoveCommand = {
|
|
|
16119
16344
|
default: false
|
|
16120
16345
|
}),
|
|
16121
16346
|
async handler(args) {
|
|
16122
|
-
const output = new
|
|
16347
|
+
const output = new OutputService2;
|
|
16123
16348
|
const envService = new EnvironmentService(output);
|
|
16124
16349
|
try {
|
|
16125
16350
|
await envService.create({ configPath: args.config });
|
|
@@ -16142,7 +16367,7 @@ var EventSourceRemoveCommand = {
|
|
|
16142
16367
|
const status = esComponent.getStatus(matchedSource.id);
|
|
16143
16368
|
if (status === "running" && !args.force) {
|
|
16144
16369
|
output.error(`事件源正在运行中,请先停止: ${matchedSource.name} (${status})`);
|
|
16145
|
-
output.log(
|
|
16370
|
+
output.log(chalk57.gray(`使用 --force 强制移除或 'roy-agent eventsource stop ${matchedSource.id.substring(0, 8)}' 先停止`));
|
|
16146
16371
|
process.exit(1);
|
|
16147
16372
|
}
|
|
16148
16373
|
if (status === "running") {
|
|
@@ -16151,7 +16376,7 @@ var EventSourceRemoveCommand = {
|
|
|
16151
16376
|
}
|
|
16152
16377
|
const result = esComponent.unregister(matchedSource.id);
|
|
16153
16378
|
if (result) {
|
|
16154
|
-
output.success(
|
|
16379
|
+
output.success(chalk57.green(`事件源已移除: ${matchedSource.name}`));
|
|
16155
16380
|
} else {
|
|
16156
16381
|
output.error("移除失败");
|
|
16157
16382
|
process.exit(1);
|
|
@@ -16163,7 +16388,7 @@ var EventSourceRemoveCommand = {
|
|
|
16163
16388
|
};
|
|
16164
16389
|
|
|
16165
16390
|
// src/commands/eventsource/start.ts
|
|
16166
|
-
import
|
|
16391
|
+
import chalk58 from "chalk";
|
|
16167
16392
|
var EventSourceStartCommand = {
|
|
16168
16393
|
command: "start <id>",
|
|
16169
16394
|
describe: "启动指定的事件源",
|
|
@@ -16178,7 +16403,7 @@ var EventSourceStartCommand = {
|
|
|
16178
16403
|
default: false
|
|
16179
16404
|
}),
|
|
16180
16405
|
async handler(args) {
|
|
16181
|
-
const output = new
|
|
16406
|
+
const output = new OutputService2;
|
|
16182
16407
|
const envService = new EnvironmentService(output);
|
|
16183
16408
|
try {
|
|
16184
16409
|
await envService.create({ configPath: args.config });
|
|
@@ -16200,15 +16425,15 @@ var EventSourceStartCommand = {
|
|
|
16200
16425
|
}
|
|
16201
16426
|
const status = esComponent.getStatus(matchedSource.id);
|
|
16202
16427
|
if (status === "running") {
|
|
16203
|
-
output.log(
|
|
16428
|
+
output.log(chalk58.yellow(`事件源已在运行: ${matchedSource.name}`));
|
|
16204
16429
|
return;
|
|
16205
16430
|
}
|
|
16206
16431
|
output.info(`正在启动事件源 '${matchedSource.name}'...`);
|
|
16207
16432
|
try {
|
|
16208
16433
|
await esComponent.startSource(matchedSource.id);
|
|
16209
|
-
output.success(
|
|
16434
|
+
output.success(chalk58.green(`事件源已启动: ${matchedSource.name}`));
|
|
16210
16435
|
if (!args.background) {
|
|
16211
|
-
output.log(
|
|
16436
|
+
output.log(chalk58.gray("按 Ctrl+C 停止..."));
|
|
16212
16437
|
await new Promise((resolve) => {
|
|
16213
16438
|
const cleanup = () => {
|
|
16214
16439
|
process.removeListener("SIGINT", cleanup);
|
|
@@ -16230,7 +16455,7 @@ var EventSourceStartCommand = {
|
|
|
16230
16455
|
};
|
|
16231
16456
|
|
|
16232
16457
|
// src/commands/eventsource/stop.ts
|
|
16233
|
-
import
|
|
16458
|
+
import chalk59 from "chalk";
|
|
16234
16459
|
var EventSourceStopCommand = {
|
|
16235
16460
|
command: "stop <id>",
|
|
16236
16461
|
aliases: ["kill"],
|
|
@@ -16246,7 +16471,7 @@ var EventSourceStopCommand = {
|
|
|
16246
16471
|
default: false
|
|
16247
16472
|
}),
|
|
16248
16473
|
async handler(args) {
|
|
16249
|
-
const output = new
|
|
16474
|
+
const output = new OutputService2;
|
|
16250
16475
|
const envService = new EnvironmentService(output);
|
|
16251
16476
|
try {
|
|
16252
16477
|
await envService.create({ configPath: args.config });
|
|
@@ -16268,13 +16493,13 @@ var EventSourceStopCommand = {
|
|
|
16268
16493
|
}
|
|
16269
16494
|
const status = esComponent.getStatus(matchedSource.id);
|
|
16270
16495
|
if (status !== "running") {
|
|
16271
|
-
output.log(
|
|
16496
|
+
output.log(chalk59.yellow(`事件源未运行: ${matchedSource.name} (${status || "unknown"})`));
|
|
16272
16497
|
return;
|
|
16273
16498
|
}
|
|
16274
16499
|
output.info(`正在停止事件源 '${matchedSource.name}'...`);
|
|
16275
16500
|
try {
|
|
16276
16501
|
await esComponent.stopSource(matchedSource.id);
|
|
16277
|
-
output.success(
|
|
16502
|
+
output.success(chalk59.green(`事件源已停止: ${matchedSource.name}`));
|
|
16278
16503
|
} catch (error) {
|
|
16279
16504
|
output.error(`停止失败: ${error}`);
|
|
16280
16505
|
process.exit(1);
|
|
@@ -16286,14 +16511,14 @@ var EventSourceStopCommand = {
|
|
|
16286
16511
|
};
|
|
16287
16512
|
|
|
16288
16513
|
// src/commands/eventsource/status.ts
|
|
16289
|
-
import
|
|
16514
|
+
import chalk60 from "chalk";
|
|
16290
16515
|
var STATUS_COLORS = {
|
|
16291
|
-
created:
|
|
16292
|
-
starting:
|
|
16293
|
-
running:
|
|
16294
|
-
stopping:
|
|
16295
|
-
stopped:
|
|
16296
|
-
error:
|
|
16516
|
+
created: chalk60.gray,
|
|
16517
|
+
starting: chalk60.yellow,
|
|
16518
|
+
running: chalk60.green,
|
|
16519
|
+
stopping: chalk60.yellow,
|
|
16520
|
+
stopped: chalk60.gray,
|
|
16521
|
+
error: chalk60.red
|
|
16297
16522
|
};
|
|
16298
16523
|
var STATUS_ICONS = {
|
|
16299
16524
|
created: "○",
|
|
@@ -16325,7 +16550,7 @@ var EventSourceStatusCommand = {
|
|
|
16325
16550
|
default: false
|
|
16326
16551
|
}),
|
|
16327
16552
|
async handler(args) {
|
|
16328
|
-
const output = new
|
|
16553
|
+
const output = new OutputService2;
|
|
16329
16554
|
const envService = new EnvironmentService(output);
|
|
16330
16555
|
try {
|
|
16331
16556
|
await envService.create({ configPath: args.config });
|
|
@@ -16347,7 +16572,7 @@ var EventSourceStatusCommand = {
|
|
|
16347
16572
|
process.exit(1);
|
|
16348
16573
|
}
|
|
16349
16574
|
const status = esComponent.getStatus(matchedSource.id) || "unknown";
|
|
16350
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
16575
|
+
const statusColor = STATUS_COLORS[status] || chalk60.gray;
|
|
16351
16576
|
if (args.json) {
|
|
16352
16577
|
output.json({
|
|
16353
16578
|
id: matchedSource.id,
|
|
@@ -16364,31 +16589,31 @@ var EventSourceStatusCommand = {
|
|
|
16364
16589
|
});
|
|
16365
16590
|
return;
|
|
16366
16591
|
}
|
|
16367
|
-
output.log(
|
|
16592
|
+
output.log(chalk60.bold("事件源详情"));
|
|
16368
16593
|
output.log("─".repeat(50));
|
|
16369
|
-
output.log(` ID: ${
|
|
16370
|
-
output.log(` Name: ${
|
|
16371
|
-
output.log(` Type: ${
|
|
16594
|
+
output.log(` ID: ${chalk60.gray(matchedSource.id)}`);
|
|
16595
|
+
output.log(` Name: ${chalk60.cyan(matchedSource.name)}`);
|
|
16596
|
+
output.log(` Type: ${chalk60.cyan(matchedSource.type)}`);
|
|
16372
16597
|
output.log(` Status: ${statusColor(`${STATUS_ICONS[status]} ${STATUS_LABELS[status]}`)}`);
|
|
16373
|
-
output.log(` Enabled: ${matchedSource.enabled ?
|
|
16598
|
+
output.log(` Enabled: ${matchedSource.enabled ? chalk60.green("是") : chalk60.gray("否")}`);
|
|
16374
16599
|
if (matchedSource.eventTypes?.length) {
|
|
16375
|
-
output.log(` Events: ${
|
|
16600
|
+
output.log(` Events: ${chalk60.gray(matchedSource.eventTypes.join(", "))}`);
|
|
16376
16601
|
}
|
|
16377
16602
|
if (matchedSource.command) {
|
|
16378
|
-
output.log(` Command: ${
|
|
16603
|
+
output.log(` Command: ${chalk60.gray(matchedSource.command)}`);
|
|
16379
16604
|
}
|
|
16380
16605
|
if (matchedSource.interval) {
|
|
16381
|
-
output.log(` Interval: ${
|
|
16606
|
+
output.log(` Interval: ${chalk60.gray(`${matchedSource.interval}ms`)}`);
|
|
16382
16607
|
}
|
|
16383
16608
|
if (matchedSource.url) {
|
|
16384
|
-
output.log(` URL: ${
|
|
16609
|
+
output.log(` URL: ${chalk60.gray(matchedSource.url)}`);
|
|
16385
16610
|
}
|
|
16386
16611
|
output.log("");
|
|
16387
16612
|
return;
|
|
16388
16613
|
}
|
|
16389
16614
|
const sources = esComponent.list();
|
|
16390
16615
|
if (sources.length === 0) {
|
|
16391
|
-
output.log(
|
|
16616
|
+
output.log(chalk60.yellow("没有配置的事件源"));
|
|
16392
16617
|
return;
|
|
16393
16618
|
}
|
|
16394
16619
|
if (args.json) {
|
|
@@ -16402,21 +16627,21 @@ var EventSourceStatusCommand = {
|
|
|
16402
16627
|
output.json({ sources: sourcesWithStatus, count: sources.length });
|
|
16403
16628
|
return;
|
|
16404
16629
|
}
|
|
16405
|
-
output.log(
|
|
16630
|
+
output.log(chalk60.bold("事件源状态概览"));
|
|
16406
16631
|
output.log("─".repeat(60));
|
|
16407
16632
|
for (const source of sources) {
|
|
16408
16633
|
const status = esComponent.getStatus(source.id) || "unknown";
|
|
16409
|
-
const statusColor = STATUS_COLORS[status] ||
|
|
16634
|
+
const statusColor = STATUS_COLORS[status] || chalk60.gray;
|
|
16410
16635
|
const icon = STATUS_ICONS[status] || "?";
|
|
16411
16636
|
const label = STATUS_LABELS[status] || status;
|
|
16412
16637
|
output.log("");
|
|
16413
|
-
output.log(` ${
|
|
16638
|
+
output.log(` ${chalk60.cyan(source.name)} ${chalk60.gray(`(${source.type})`)}`);
|
|
16414
16639
|
output.log(` └─ Status: ${statusColor(`${icon} ${label}`)}`);
|
|
16415
|
-
output.log(` ID: ${
|
|
16640
|
+
output.log(` ID: ${chalk60.gray(source.id.substring(0, 8))}...`);
|
|
16416
16641
|
}
|
|
16417
16642
|
output.log("");
|
|
16418
16643
|
const runningCount = sources.filter((s) => esComponent.getStatus(s.id) === "running").length;
|
|
16419
|
-
output.log(
|
|
16644
|
+
output.log(chalk60.green(`✅ ${runningCount}/${sources.length} 运行中`));
|
|
16420
16645
|
} finally {
|
|
16421
16646
|
await envService.dispose();
|
|
16422
16647
|
}
|
|
@@ -16428,7 +16653,7 @@ var EventSourceCommand = {
|
|
|
16428
16653
|
command: "eventsource",
|
|
16429
16654
|
aliases: ["es", "event-source"],
|
|
16430
16655
|
describe: "事件源管理 - 添加、启动、停止各种事件源(lark-cli、timer、websocket)",
|
|
16431
|
-
builder: (yargs) => yargs.command(EventSourceListCommand).command(EventSourceAddCommand).command(EventSourceRemoveCommand).command(EventSourceStartCommand).command(EventSourceStopCommand).command(EventSourceStatusCommand).demandCommand().help(),
|
|
16656
|
+
builder: (yargs) => yargs.command(EventSourceListCommand).command(EventSourceAddCommand).command(EventSourceUpdateCommand).command(EventSourceRemoveCommand).command(EventSourceStartCommand).command(EventSourceStopCommand).command(EventSourceStatusCommand).demandCommand().help(),
|
|
16432
16657
|
handler: () => {}
|
|
16433
16658
|
};
|
|
16434
16659
|
|
|
@@ -16729,7 +16954,7 @@ var DebugCommand = {
|
|
|
16729
16954
|
};
|
|
16730
16955
|
|
|
16731
16956
|
// src/commands/workflow/renderers.ts
|
|
16732
|
-
import
|
|
16957
|
+
import chalk61 from "chalk";
|
|
16733
16958
|
function truncateVisual3(str, maxWidth) {
|
|
16734
16959
|
if (!str)
|
|
16735
16960
|
return "-";
|
|
@@ -16764,23 +16989,24 @@ function formatDuration(ms) {
|
|
|
16764
16989
|
function statusColor(status) {
|
|
16765
16990
|
switch (status) {
|
|
16766
16991
|
case "completed":
|
|
16767
|
-
return
|
|
16992
|
+
return chalk61.green;
|
|
16768
16993
|
case "running":
|
|
16769
16994
|
case "idle":
|
|
16770
|
-
return
|
|
16995
|
+
return chalk61.blue;
|
|
16771
16996
|
case "paused":
|
|
16772
|
-
return
|
|
16997
|
+
return chalk61.yellow;
|
|
16773
16998
|
case "failed":
|
|
16774
|
-
return
|
|
16999
|
+
return chalk61.red;
|
|
16775
17000
|
case "stopped":
|
|
16776
|
-
return
|
|
17001
|
+
return chalk61.gray;
|
|
16777
17002
|
default:
|
|
16778
|
-
return
|
|
17003
|
+
return chalk61.white;
|
|
16779
17004
|
}
|
|
16780
17005
|
}
|
|
16781
17006
|
function renderWorkflowList(workflows, options) {
|
|
16782
17007
|
if (options?.json) {
|
|
16783
17008
|
return JSON.stringify({
|
|
17009
|
+
total: workflows.length,
|
|
16784
17010
|
workflows: workflows.map((w) => ({
|
|
16785
17011
|
id: w.id,
|
|
16786
17012
|
name: w.name,
|
|
@@ -16789,12 +17015,11 @@ function renderWorkflowList(workflows, options) {
|
|
|
16789
17015
|
tags: w.tags,
|
|
16790
17016
|
createdAt: w.createdAt.toISOString(),
|
|
16791
17017
|
updatedAt: w.updatedAt.toISOString()
|
|
16792
|
-
}))
|
|
16793
|
-
total: workflows.length
|
|
17018
|
+
}))
|
|
16794
17019
|
}, null, 2);
|
|
16795
17020
|
}
|
|
16796
17021
|
if (workflows.length === 0) {
|
|
16797
|
-
return
|
|
17022
|
+
return chalk61.yellow("No workflows found");
|
|
16798
17023
|
}
|
|
16799
17024
|
const NAME_WIDTH = 30;
|
|
16800
17025
|
const VERSION_WIDTH = 10;
|
|
@@ -16802,10 +17027,10 @@ function renderWorkflowList(workflows, options) {
|
|
|
16802
17027
|
const UPDATED_WIDTH = 20;
|
|
16803
17028
|
const GAP = " ";
|
|
16804
17029
|
const headerLine = [
|
|
16805
|
-
|
|
16806
|
-
|
|
16807
|
-
|
|
16808
|
-
|
|
17030
|
+
chalk61.bold("NAME".padEnd(NAME_WIDTH)),
|
|
17031
|
+
chalk61.bold("VER".padEnd(VERSION_WIDTH)),
|
|
17032
|
+
chalk61.bold("TAGS".padEnd(TAGS_WIDTH)),
|
|
17033
|
+
chalk61.bold("UPDATED")
|
|
16809
17034
|
].join(GAP);
|
|
16810
17035
|
const sepLine = "─".repeat(NAME_WIDTH + VERSION_WIDTH + TAGS_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
16811
17036
|
const rows = workflows.map((w) => {
|
|
@@ -16820,18 +17045,18 @@ function renderWorkflowList(workflows, options) {
|
|
|
16820
17045
|
}
|
|
16821
17046
|
function renderWorkflowDetail(workflow, options) {
|
|
16822
17047
|
const lines = [];
|
|
16823
|
-
lines.push(
|
|
17048
|
+
lines.push(chalk61.bold(`
|
|
16824
17049
|
\uD83D\uDCCB Workflow Details
|
|
16825
17050
|
`));
|
|
16826
|
-
lines.push(` ${
|
|
16827
|
-
lines.push(` ${
|
|
16828
|
-
lines.push(` ${
|
|
16829
|
-
lines.push(` ${
|
|
16830
|
-
lines.push(` ${
|
|
16831
|
-
lines.push(` ${
|
|
16832
|
-
lines.push(` ${
|
|
17051
|
+
lines.push(` ${chalk61.cyan("ID:")} ${workflow.id}`);
|
|
17052
|
+
lines.push(` ${chalk61.cyan("Name:")} ${workflow.name}`);
|
|
17053
|
+
lines.push(` ${chalk61.cyan("Version:")} ${workflow.version}`);
|
|
17054
|
+
lines.push(` ${chalk61.cyan("Description:")} ${workflow.description || "-"}`);
|
|
17055
|
+
lines.push(` ${chalk61.cyan("Tags:")} ${workflow.tags.join(", ") || "-"}`);
|
|
17056
|
+
lines.push(` ${chalk61.cyan("Created:")} ${formatDate(workflow.createdAt)}`);
|
|
17057
|
+
lines.push(` ${chalk61.cyan("Updated:")} ${formatDate(workflow.updatedAt)}`);
|
|
16833
17058
|
const nodeCount = workflow.definition.nodes.length;
|
|
16834
|
-
lines.push(
|
|
17059
|
+
lines.push(chalk61.bold(`
|
|
16835
17060
|
\uD83D\uDCCA Nodes Summary
|
|
16836
17061
|
`));
|
|
16837
17062
|
lines.push(` Total: ${nodeCount} nodes`);
|
|
@@ -16843,7 +17068,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
16843
17068
|
lines.push(` - ${type}: ${count}`);
|
|
16844
17069
|
}
|
|
16845
17070
|
if (workflow.definition.config) {
|
|
16846
|
-
lines.push(
|
|
17071
|
+
lines.push(chalk61.bold(`
|
|
16847
17072
|
⚙️ Configuration
|
|
16848
17073
|
`));
|
|
16849
17074
|
if (workflow.definition.config.parallel_limit !== undefined) {
|
|
@@ -16857,7 +17082,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
16857
17082
|
}
|
|
16858
17083
|
}
|
|
16859
17084
|
if (options?.includeRuns && options.includeRuns.length > 0) {
|
|
16860
|
-
lines.push(
|
|
17085
|
+
lines.push(chalk61.bold(`
|
|
16861
17086
|
\uD83D\uDCDC Recent Runs
|
|
16862
17087
|
`));
|
|
16863
17088
|
lines.push(renderRunsList(options.includeRuns.slice(0, 5)));
|
|
@@ -16868,6 +17093,7 @@ function renderWorkflowDetail(workflow, options) {
|
|
|
16868
17093
|
function renderRunsList(runs, options) {
|
|
16869
17094
|
if (options?.json) {
|
|
16870
17095
|
return JSON.stringify({
|
|
17096
|
+
total: runs.length,
|
|
16871
17097
|
runs: runs.map((r) => ({
|
|
16872
17098
|
id: r.id,
|
|
16873
17099
|
workflowId: r.workflowId,
|
|
@@ -16876,12 +17102,11 @@ function renderRunsList(runs, options) {
|
|
|
16876
17102
|
completedAt: r.completedAt?.toISOString(),
|
|
16877
17103
|
durationMs: r.durationMs,
|
|
16878
17104
|
error: r.error
|
|
16879
|
-
}))
|
|
16880
|
-
total: runs.length
|
|
17105
|
+
}))
|
|
16881
17106
|
}, null, 2);
|
|
16882
17107
|
}
|
|
16883
17108
|
if (runs.length === 0) {
|
|
16884
|
-
return
|
|
17109
|
+
return chalk61.yellow("No runs found");
|
|
16885
17110
|
}
|
|
16886
17111
|
const ID_WIDTH = 20;
|
|
16887
17112
|
const STATUS_WIDTH = 12;
|
|
@@ -16889,10 +17114,10 @@ function renderRunsList(runs, options) {
|
|
|
16889
17114
|
const UPDATED_WIDTH = 20;
|
|
16890
17115
|
const GAP = " ";
|
|
16891
17116
|
const headerLine = [
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
17117
|
+
chalk61.bold("RUN ID".padEnd(ID_WIDTH)),
|
|
17118
|
+
chalk61.bold("STATUS".padEnd(STATUS_WIDTH)),
|
|
17119
|
+
chalk61.bold("DURATION".padEnd(DURATION_WIDTH)),
|
|
17120
|
+
chalk61.bold("STARTED")
|
|
16896
17121
|
].join(GAP);
|
|
16897
17122
|
const sepLine = "─".repeat(ID_WIDTH + STATUS_WIDTH + DURATION_WIDTH + UPDATED_WIDTH + GAP.length * 3);
|
|
16898
17123
|
const rows = runs.map((r) => {
|
|
@@ -16907,34 +17132,34 @@ function renderRunsList(runs, options) {
|
|
|
16907
17132
|
}
|
|
16908
17133
|
function renderRunDetail(run) {
|
|
16909
17134
|
const lines = [];
|
|
16910
|
-
lines.push(
|
|
17135
|
+
lines.push(chalk61.bold(`
|
|
16911
17136
|
\uD83C\uDFC3 Run Details
|
|
16912
17137
|
`));
|
|
16913
|
-
lines.push(` ${
|
|
16914
|
-
lines.push(` ${
|
|
16915
|
-
lines.push(` ${
|
|
16916
|
-
lines.push(` ${
|
|
17138
|
+
lines.push(` ${chalk61.cyan("Run ID:")} ${run.id}`);
|
|
17139
|
+
lines.push(` ${chalk61.cyan("Workflow:")} ${run.workflowId}`);
|
|
17140
|
+
lines.push(` ${chalk61.cyan("Status:")} ${statusColor(run.status)(run.status)}`);
|
|
17141
|
+
lines.push(` ${chalk61.cyan("Started:")} ${formatDate(run.startedAt)}`);
|
|
16917
17142
|
if (run.pausedAt) {
|
|
16918
|
-
lines.push(` ${
|
|
17143
|
+
lines.push(` ${chalk61.cyan("Paused:")} ${formatDate(run.pausedAt)}`);
|
|
16919
17144
|
}
|
|
16920
17145
|
if (run.resumedAt) {
|
|
16921
|
-
lines.push(` ${
|
|
17146
|
+
lines.push(` ${chalk61.cyan("Resumed:")} ${formatDate(run.resumedAt)}`);
|
|
16922
17147
|
}
|
|
16923
17148
|
if (run.stoppedAt) {
|
|
16924
|
-
lines.push(` ${
|
|
17149
|
+
lines.push(` ${chalk61.cyan("Stopped:")} ${formatDate(run.stoppedAt)}`);
|
|
16925
17150
|
}
|
|
16926
17151
|
if (run.completedAt) {
|
|
16927
|
-
lines.push(` ${
|
|
17152
|
+
lines.push(` ${chalk61.cyan("Completed:")} ${formatDate(run.completedAt)}`);
|
|
16928
17153
|
}
|
|
16929
|
-
lines.push(` ${
|
|
17154
|
+
lines.push(` ${chalk61.cyan("Duration:")} ${formatDuration(run.durationMs)}`);
|
|
16930
17155
|
if (run.error) {
|
|
16931
|
-
lines.push(
|
|
17156
|
+
lines.push(chalk61.bold(`
|
|
16932
17157
|
❌ Error
|
|
16933
17158
|
`));
|
|
16934
|
-
lines.push(` ${
|
|
17159
|
+
lines.push(` ${chalk61.red(run.error)}`);
|
|
16935
17160
|
}
|
|
16936
17161
|
if (run.output) {
|
|
16937
|
-
lines.push(
|
|
17162
|
+
lines.push(chalk61.bold(`
|
|
16938
17163
|
\uD83D\uDCE4 Output
|
|
16939
17164
|
`));
|
|
16940
17165
|
lines.push(" " + JSON.stringify(run.output, null, 2).split(`
|
|
@@ -16945,36 +17170,36 @@ function renderRunDetail(run) {
|
|
|
16945
17170
|
`);
|
|
16946
17171
|
}
|
|
16947
17172
|
function renderWorkflowAdded(workflow) {
|
|
16948
|
-
return
|
|
17173
|
+
return chalk61.green(`
|
|
16949
17174
|
✅ Workflow '${workflow.name}' added successfully
|
|
16950
17175
|
`) + ` ID: ${workflow.id}
|
|
16951
17176
|
` + ` Version: ${workflow.version}
|
|
16952
17177
|
`;
|
|
16953
17178
|
}
|
|
16954
17179
|
function renderWorkflowUpdated(workflow) {
|
|
16955
|
-
return
|
|
17180
|
+
return chalk61.green(`
|
|
16956
17181
|
✅ Workflow '${workflow.name}' updated successfully
|
|
16957
17182
|
`) + ` ID: ${workflow.id}
|
|
16958
17183
|
`;
|
|
16959
17184
|
}
|
|
16960
17185
|
function renderWorkflowDeleted(name) {
|
|
16961
|
-
return
|
|
17186
|
+
return chalk61.green(`
|
|
16962
17187
|
✅ Workflow '${name}' deleted successfully
|
|
16963
17188
|
`);
|
|
16964
17189
|
}
|
|
16965
17190
|
function renderRunResult(result) {
|
|
16966
17191
|
const lines = [];
|
|
16967
17192
|
if (result.status === "completed") {
|
|
16968
|
-
lines.push(
|
|
17193
|
+
lines.push(chalk61.green(`
|
|
16969
17194
|
✅ Workflow completed successfully`));
|
|
16970
17195
|
} else if (result.status === "failed") {
|
|
16971
|
-
lines.push(
|
|
17196
|
+
lines.push(chalk61.red(`
|
|
16972
17197
|
❌ Workflow failed`));
|
|
16973
17198
|
} else if (result.status === "stopped") {
|
|
16974
|
-
lines.push(
|
|
17199
|
+
lines.push(chalk61.yellow(`
|
|
16975
17200
|
⚠️ Workflow stopped`));
|
|
16976
17201
|
} else {
|
|
16977
|
-
lines.push(
|
|
17202
|
+
lines.push(chalk61.blue(`
|
|
16978
17203
|
\uD83D\uDD04 Workflow ${result.status}`));
|
|
16979
17204
|
}
|
|
16980
17205
|
lines.push(` Run ID: ${result.runId}`);
|
|
@@ -16982,11 +17207,11 @@ function renderRunResult(result) {
|
|
|
16982
17207
|
lines.push(` Duration: ${formatDuration(result.durationMs)}`);
|
|
16983
17208
|
}
|
|
16984
17209
|
if (result.error) {
|
|
16985
|
-
lines.push(
|
|
17210
|
+
lines.push(chalk61.red(`
|
|
16986
17211
|
Error: ${result.error}`));
|
|
16987
17212
|
}
|
|
16988
17213
|
if (result.output) {
|
|
16989
|
-
lines.push(
|
|
17214
|
+
lines.push(chalk61.bold(`
|
|
16990
17215
|
\uD83D\uDCE4 Output:`));
|
|
16991
17216
|
lines.push(JSON.stringify(result.output, null, 2));
|
|
16992
17217
|
}
|
|
@@ -17000,10 +17225,10 @@ function renderNodesList(nodes) {
|
|
|
17000
17225
|
const DEPS_WIDTH = 20;
|
|
17001
17226
|
const GAP = " ";
|
|
17002
17227
|
const headerLine = [
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17228
|
+
chalk61.bold("NODE ID".padEnd(ID_WIDTH)),
|
|
17229
|
+
chalk61.bold("TYPE".padEnd(TYPE_WIDTH)),
|
|
17230
|
+
chalk61.bold("NAME".padEnd(NAME_WIDTH)),
|
|
17231
|
+
chalk61.bold("DEPENDS ON")
|
|
17007
17232
|
].join(GAP);
|
|
17008
17233
|
const sepLine = "─".repeat(ID_WIDTH + TYPE_WIDTH + NAME_WIDTH + DEPS_WIDTH + GAP.length * 3);
|
|
17009
17234
|
const rows = nodes.map((n) => {
|
|
@@ -17018,8 +17243,21 @@ function renderNodesList(nodes) {
|
|
|
17018
17243
|
}
|
|
17019
17244
|
|
|
17020
17245
|
// src/commands/workflow/commands/list.ts
|
|
17021
|
-
import
|
|
17246
|
+
import chalk62 from "chalk";
|
|
17022
17247
|
import { createWorkflowListTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
17248
|
+
function buildListWorkflowsJson(workflows, total, args, availableTags) {
|
|
17249
|
+
const output = {
|
|
17250
|
+
total,
|
|
17251
|
+
count: workflows.length,
|
|
17252
|
+
truncated: total > workflows.length,
|
|
17253
|
+
limit: args.limit,
|
|
17254
|
+
offset: args.offset,
|
|
17255
|
+
page: args.page,
|
|
17256
|
+
...availableTags.length > 0 ? { available_tags: availableTags } : {},
|
|
17257
|
+
workflows
|
|
17258
|
+
};
|
|
17259
|
+
return output;
|
|
17260
|
+
}
|
|
17023
17261
|
var WorkflowListCommand = {
|
|
17024
17262
|
command: "list",
|
|
17025
17263
|
describe: "列出所有已注册的 Workflow",
|
|
@@ -17081,7 +17319,7 @@ var WorkflowListCommand = {
|
|
|
17081
17319
|
type: "string"
|
|
17082
17320
|
}),
|
|
17083
17321
|
async handler(args) {
|
|
17084
|
-
const output = new
|
|
17322
|
+
const output = new OutputService2;
|
|
17085
17323
|
const envService = new EnvironmentService(output);
|
|
17086
17324
|
try {
|
|
17087
17325
|
await envService.create({ configPath: args.config });
|
|
@@ -17124,22 +17362,19 @@ var WorkflowListCommand = {
|
|
|
17124
17362
|
const availableTags = data.available_tags || [];
|
|
17125
17363
|
const total = typeof data.total === "number" ? data.total : workflows.length;
|
|
17126
17364
|
if (args.json) {
|
|
17127
|
-
|
|
17128
|
-
|
|
17129
|
-
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
available_tags: availableTags,
|
|
17137
|
-
total,
|
|
17138
|
-
count: workflows.length,
|
|
17365
|
+
const projected = workflows.map((w) => ({
|
|
17366
|
+
name: w.name,
|
|
17367
|
+
version: w.version,
|
|
17368
|
+
description: w.description,
|
|
17369
|
+
tags: w.tags,
|
|
17370
|
+
createdAt: w.created_at,
|
|
17371
|
+
updatedAt: w.created_at
|
|
17372
|
+
}));
|
|
17373
|
+
output.json(buildListWorkflowsJson(projected, total, {
|
|
17139
17374
|
limit: pageSize,
|
|
17140
17375
|
offset: finalOffset,
|
|
17141
17376
|
page: page > 1 ? page : Math.floor(finalOffset / pageSize) + 1
|
|
17142
|
-
});
|
|
17377
|
+
}, availableTags));
|
|
17143
17378
|
} else {
|
|
17144
17379
|
const renderWorkflows = workflows.map((w) => ({
|
|
17145
17380
|
id: w.name,
|
|
@@ -17156,20 +17391,20 @@ var WorkflowListCommand = {
|
|
|
17156
17391
|
if (total > workflows.length) {
|
|
17157
17392
|
const start = finalOffset + 1;
|
|
17158
17393
|
const end = finalOffset + workflows.length;
|
|
17159
|
-
output.log(
|
|
17394
|
+
output.log(chalk62.green(`
|
|
17160
17395
|
✅ 显示 ${start}-${end} / 共 ${total} 个 Workflow`));
|
|
17161
17396
|
const totalPages = Math.ceil(total / pageSize);
|
|
17162
17397
|
const currentPage = Math.floor(finalOffset / pageSize) + 1;
|
|
17163
17398
|
if (totalPages > 1) {
|
|
17164
|
-
output.log(
|
|
17399
|
+
output.log(chalk62.cyan(`\uD83D\uDCC4 第 ${currentPage} / ${totalPages} 页`));
|
|
17165
17400
|
}
|
|
17166
17401
|
} else {
|
|
17167
|
-
output.log(
|
|
17402
|
+
output.log(chalk62.green(`
|
|
17168
17403
|
✅ 共 ${total} 个 Workflow`));
|
|
17169
17404
|
}
|
|
17170
17405
|
if (availableTags.length > 0) {
|
|
17171
17406
|
const tagsLine = availableTags.map((t) => `${t.name}(${t.count})`).join(", ");
|
|
17172
|
-
output.log(
|
|
17407
|
+
output.log(chalk62.cyan(`
|
|
17173
17408
|
\uD83C\uDFF7️ Available tags: ${tagsLine}`));
|
|
17174
17409
|
}
|
|
17175
17410
|
}
|
|
@@ -17772,7 +18007,7 @@ class WorkflowValidator {
|
|
|
17772
18007
|
}
|
|
17773
18008
|
|
|
17774
18009
|
// src/commands/workflow/commands/add.ts
|
|
17775
|
-
import
|
|
18010
|
+
import chalk63 from "chalk";
|
|
17776
18011
|
import fs3 from "fs";
|
|
17777
18012
|
import path6 from "path";
|
|
17778
18013
|
import { createWorkflowExtractorAgent } from "@ai-setting/roy-agent-core/env/task/plugins";
|
|
@@ -17865,7 +18100,7 @@ var WorkflowAddCommand = {
|
|
|
17865
18100
|
不要用 bash tool + command 输出多行内容(shell 会执行失败)。`),
|
|
17866
18101
|
async handler(args) {
|
|
17867
18102
|
const a = args;
|
|
17868
|
-
const output = new
|
|
18103
|
+
const output = new OutputService2;
|
|
17869
18104
|
const envService = new EnvironmentService(output);
|
|
17870
18105
|
try {
|
|
17871
18106
|
let parseTags = function(input) {
|
|
@@ -17915,7 +18150,7 @@ var WorkflowAddCommand = {
|
|
|
17915
18150
|
definition = await parseWorkflowContent(content, filePath);
|
|
17916
18151
|
workflowName = a.name || definition.name || path6.basename(filePath);
|
|
17917
18152
|
if (a.validate) {
|
|
17918
|
-
output.log(
|
|
18153
|
+
output.log(chalk63.blue("\uD83D\uDD0D Validating workflow..."));
|
|
17919
18154
|
const validator = new WorkflowValidator;
|
|
17920
18155
|
const result = validator.validate(definition);
|
|
17921
18156
|
if (!result.valid) {
|
|
@@ -17930,11 +18165,11 @@ var WorkflowAddCommand = {
|
|
|
17930
18165
|
});
|
|
17931
18166
|
process.exit(1);
|
|
17932
18167
|
}
|
|
17933
|
-
output.log(
|
|
18168
|
+
output.log(chalk63.green(`✅ Workflow validation passed
|
|
17934
18169
|
`));
|
|
17935
18170
|
}
|
|
17936
18171
|
} else if (a.desc) {
|
|
17937
|
-
output.log(
|
|
18172
|
+
output.log(chalk63.blue(`\uD83E\uDD16 Generating workflow from description...
|
|
17938
18173
|
`));
|
|
17939
18174
|
const agentComponent = env.getComponent("agent");
|
|
17940
18175
|
if (!agentComponent) {
|
|
@@ -17942,10 +18177,10 @@ var WorkflowAddCommand = {
|
|
|
17942
18177
|
process.exit(1);
|
|
17943
18178
|
}
|
|
17944
18179
|
if (!agentComponent.getAgent("workflow-extractor")) {
|
|
17945
|
-
output.log(
|
|
18180
|
+
output.log(chalk63.gray("Auto-registering workflow-extractor agent..."));
|
|
17946
18181
|
const extractorConfig = createWorkflowExtractorAgent();
|
|
17947
18182
|
agentComponent.registerAgent(extractorConfig.name, extractorConfig);
|
|
17948
|
-
output.log(
|
|
18183
|
+
output.log(chalk63.green(`✅ workflow-extractor agent registered
|
|
17949
18184
|
`));
|
|
17950
18185
|
}
|
|
17951
18186
|
const prompt = `## 任务
|
|
@@ -17959,20 +18194,20 @@ ${a.desc}
|
|
|
17959
18194
|
1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
|
|
17960
18195
|
2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
|
|
17961
18196
|
3. 验证通过后才输出最终 YAML`;
|
|
17962
|
-
output.log(
|
|
18197
|
+
output.log(chalk63.gray("Running workflow-extractor agent..."));
|
|
17963
18198
|
const result = await agentComponent.run("workflow-extractor", prompt);
|
|
17964
18199
|
const agentOutput = result.finalText || "";
|
|
17965
18200
|
definition = parseYamlFromAgentOutput(agentOutput);
|
|
17966
18201
|
if (definition === null) {
|
|
17967
18202
|
output.error("Failed to parse workflow from agent output");
|
|
17968
|
-
output.log(
|
|
18203
|
+
output.log(chalk63.gray(`
|
|
17969
18204
|
Agent output:
|
|
17970
18205
|
` + agentOutput.slice(0, 500)));
|
|
17971
18206
|
process.exit(1);
|
|
17972
18207
|
}
|
|
17973
18208
|
workflowName = a.name || definition.name;
|
|
17974
18209
|
if (a.validate) {
|
|
17975
|
-
output.log(
|
|
18210
|
+
output.log(chalk63.blue(`
|
|
17976
18211
|
\uD83D\uDD0D Validating generated workflow...`));
|
|
17977
18212
|
const validator = new WorkflowValidator;
|
|
17978
18213
|
const result2 = validator.validate(definition);
|
|
@@ -17986,16 +18221,16 @@ Agent output:
|
|
|
17986
18221
|
output.error(` Fix: ${error.fix}
|
|
17987
18222
|
`);
|
|
17988
18223
|
});
|
|
17989
|
-
output.log(
|
|
18224
|
+
output.log(chalk63.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
|
|
17990
18225
|
process.exit(1);
|
|
17991
18226
|
}
|
|
17992
|
-
output.log(
|
|
18227
|
+
output.log(chalk63.green(`✅ Generated workflow validation passed
|
|
17993
18228
|
`));
|
|
17994
18229
|
}
|
|
17995
18230
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
17996
|
-
output.log(
|
|
18231
|
+
output.log(chalk63.gray("--- Generated YAML ---"));
|
|
17997
18232
|
output.log(yaml.stringify(definition));
|
|
17998
|
-
output.log(
|
|
18233
|
+
output.log(chalk63.gray(`------------------------
|
|
17999
18234
|
`));
|
|
18000
18235
|
} else {
|
|
18001
18236
|
output.error("Please provide --file or --desc option");
|
|
@@ -18021,10 +18256,10 @@ Agent output:
|
|
|
18021
18256
|
force: a.force
|
|
18022
18257
|
});
|
|
18023
18258
|
output.log(renderWorkflowAdded(workflow));
|
|
18024
|
-
output.log(
|
|
18259
|
+
output.log(chalk63.bold(`
|
|
18025
18260
|
\uD83D\uDCCA Nodes Summary:`));
|
|
18026
18261
|
output.log(renderNodesList(definition.nodes));
|
|
18027
|
-
output.log(
|
|
18262
|
+
output.log(chalk63.green(`
|
|
18028
18263
|
✅ Workflow '${workflowName}' added successfully`));
|
|
18029
18264
|
} catch (error) {
|
|
18030
18265
|
if (error.message?.includes("already exists") && !a.force) {
|
|
@@ -18041,7 +18276,7 @@ Agent output:
|
|
|
18041
18276
|
};
|
|
18042
18277
|
|
|
18043
18278
|
// src/commands/workflow/commands/get.ts
|
|
18044
|
-
import
|
|
18279
|
+
import chalk64 from "chalk";
|
|
18045
18280
|
import { createWorkflowGetTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18046
18281
|
var WorkflowGetCommand = {
|
|
18047
18282
|
command: "get <identifier>",
|
|
@@ -18077,7 +18312,7 @@ var WorkflowGetCommand = {
|
|
|
18077
18312
|
type: "string"
|
|
18078
18313
|
}),
|
|
18079
18314
|
async handler(args) {
|
|
18080
|
-
const output = new
|
|
18315
|
+
const output = new OutputService2;
|
|
18081
18316
|
const envService = new EnvironmentService(output);
|
|
18082
18317
|
try {
|
|
18083
18318
|
await envService.create({ configPath: args.config });
|
|
@@ -18179,15 +18414,15 @@ var WorkflowGetCommand = {
|
|
|
18179
18414
|
} else {
|
|
18180
18415
|
output.log(renderWorkflowDetail(workflow, { includeRuns: runs }));
|
|
18181
18416
|
if (args.includeNodes) {
|
|
18182
|
-
output.log(
|
|
18417
|
+
output.log(chalk64.bold(`
|
|
18183
18418
|
\uD83D\uDCCB All Nodes:`));
|
|
18184
18419
|
output.log(renderNodesList(data.nodes || []));
|
|
18185
18420
|
}
|
|
18186
18421
|
const yaml = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
18187
18422
|
const defYaml = yaml.stringify(data.definition || {}, { indent: 2 });
|
|
18188
|
-
output.log(
|
|
18423
|
+
output.log(chalk64.bold(`
|
|
18189
18424
|
\uD83D\uDCC4 Definition (YAML):`));
|
|
18190
|
-
output.log(
|
|
18425
|
+
output.log(chalk64.gray(defYaml));
|
|
18191
18426
|
}
|
|
18192
18427
|
}
|
|
18193
18428
|
} catch (error) {
|
|
@@ -18200,7 +18435,7 @@ var WorkflowGetCommand = {
|
|
|
18200
18435
|
};
|
|
18201
18436
|
|
|
18202
18437
|
// src/commands/workflow/commands/update.ts
|
|
18203
|
-
import
|
|
18438
|
+
import chalk65 from "chalk";
|
|
18204
18439
|
import fs4 from "fs";
|
|
18205
18440
|
import path7 from "path";
|
|
18206
18441
|
import { parseWorkflowFile } from "@ai-setting/roy-agent-core/env/workflow/types";
|
|
@@ -18233,7 +18468,7 @@ var WorkflowUpdateCommand = {
|
|
|
18233
18468
|
}),
|
|
18234
18469
|
async handler(args) {
|
|
18235
18470
|
const a = args;
|
|
18236
|
-
const output = new
|
|
18471
|
+
const output = new OutputService2;
|
|
18237
18472
|
const envService = new EnvironmentService(output);
|
|
18238
18473
|
try {
|
|
18239
18474
|
await envService.create({ configPath: a.config });
|
|
@@ -18273,7 +18508,7 @@ var WorkflowUpdateCommand = {
|
|
|
18273
18508
|
const tags = a.tags ? a.tags.split(",").map((t) => t.trim()) : undefined;
|
|
18274
18509
|
const workflow = await service.updateWorkflow(a.name, updates, { tags });
|
|
18275
18510
|
output.log(renderWorkflowUpdated(workflow));
|
|
18276
|
-
output.log(
|
|
18511
|
+
output.log(chalk65.green(`
|
|
18277
18512
|
✅ Workflow '${a.name}' updated successfully`));
|
|
18278
18513
|
} catch (error) {
|
|
18279
18514
|
output.error(`Failed to update workflow: ${error}`);
|
|
@@ -18285,7 +18520,7 @@ var WorkflowUpdateCommand = {
|
|
|
18285
18520
|
};
|
|
18286
18521
|
|
|
18287
18522
|
// src/commands/workflow/commands/remove.ts
|
|
18288
|
-
import
|
|
18523
|
+
import chalk66 from "chalk";
|
|
18289
18524
|
var WorkflowRemoveCommand = {
|
|
18290
18525
|
command: "remove <name>",
|
|
18291
18526
|
describe: "删除 Workflow",
|
|
@@ -18303,7 +18538,7 @@ var WorkflowRemoveCommand = {
|
|
|
18303
18538
|
type: "string"
|
|
18304
18539
|
}),
|
|
18305
18540
|
async handler(args) {
|
|
18306
|
-
const output = new
|
|
18541
|
+
const output = new OutputService2;
|
|
18307
18542
|
const envService = new EnvironmentService(output);
|
|
18308
18543
|
try {
|
|
18309
18544
|
await envService.create({ configPath: args.config });
|
|
@@ -18324,8 +18559,8 @@ var WorkflowRemoveCommand = {
|
|
|
18324
18559
|
process.exit(1);
|
|
18325
18560
|
}
|
|
18326
18561
|
if (!args.force) {
|
|
18327
|
-
output.log(
|
|
18328
|
-
output.log(
|
|
18562
|
+
output.log(chalk66.yellow(`Are you sure you want to delete workflow '${args.name}'?`));
|
|
18563
|
+
output.log(chalk66.gray("Use --force to skip confirmation"));
|
|
18329
18564
|
process.exit(1);
|
|
18330
18565
|
}
|
|
18331
18566
|
const deleted = await service.deleteWorkflow(args.name);
|
|
@@ -18345,13 +18580,13 @@ var WorkflowRemoveCommand = {
|
|
|
18345
18580
|
|
|
18346
18581
|
// src/commands/workflow/commands/run.ts
|
|
18347
18582
|
var import_yaml = __toESM(require_dist(), 1);
|
|
18348
|
-
import
|
|
18583
|
+
import chalk67 from "chalk";
|
|
18349
18584
|
import fs5 from "fs";
|
|
18350
18585
|
import path8 from "path";
|
|
18351
18586
|
import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18352
18587
|
import { getTracerProvider as getTracerProvider4, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
|
|
18353
18588
|
var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
18354
|
-
const output = new
|
|
18589
|
+
const output = new OutputService2;
|
|
18355
18590
|
const envService = new EnvironmentService(output);
|
|
18356
18591
|
const traceparent = process.env.TRACEPARENT;
|
|
18357
18592
|
let traceId;
|
|
@@ -18419,7 +18654,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18419
18654
|
};
|
|
18420
18655
|
if (args.sessionId) {
|
|
18421
18656
|
const sessionId = args.sessionId.startsWith("workflow_") ? args.sessionId : `workflow_${args.sessionId}`;
|
|
18422
|
-
output.log(
|
|
18657
|
+
output.log(chalk67.blue(`\uD83D\uDD04 Resuming workflow from session: ${sessionId}`));
|
|
18423
18658
|
const sessionComponent = workflowComponent.sessionComponent;
|
|
18424
18659
|
if (!sessionComponent) {
|
|
18425
18660
|
output.error("SessionComponent not available");
|
|
@@ -18481,17 +18716,17 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18481
18716
|
definition = { ...definition, name: args.name };
|
|
18482
18717
|
}
|
|
18483
18718
|
const workflow = await service.createWorkflow(definition, { force: true });
|
|
18484
|
-
output.log(
|
|
18485
|
-
output.log(
|
|
18719
|
+
output.log(chalk67.blue(`\uD83D\uDCDD Registering workflow: ${registrationName}`));
|
|
18720
|
+
output.log(chalk67.green(`✅ Workflow registered: ${workflow.name} (${workflow.id})`));
|
|
18486
18721
|
if (args.registerOnly) {
|
|
18487
|
-
output.log(
|
|
18722
|
+
output.log(chalk67.gray("ℹ️ Use --register-only, skipping execution"));
|
|
18488
18723
|
if (workflowSpan) {
|
|
18489
18724
|
workflowSpan.end();
|
|
18490
18725
|
}
|
|
18491
18726
|
await envService.dispose();
|
|
18492
18727
|
process.exit(0);
|
|
18493
18728
|
}
|
|
18494
|
-
output.log(
|
|
18729
|
+
output.log(chalk67.blue(`\uD83D\uDE80 Running workflow: ${workflow.name}`));
|
|
18495
18730
|
const result = await service.runWorkflow(definition, input, runOptions);
|
|
18496
18731
|
output.log(renderRunResult({
|
|
18497
18732
|
runId: result.runId,
|
|
@@ -18501,7 +18736,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18501
18736
|
durationMs: result.durationMs
|
|
18502
18737
|
}));
|
|
18503
18738
|
if (result.status === "paused") {
|
|
18504
|
-
output.log(
|
|
18739
|
+
output.log(chalk67.gray(`
|
|
18505
18740
|
\uD83D\uDCA1 Use "roy-agent workflow run ${result.runId} --session-id ${result.runId} --input '<response>'" to resume`));
|
|
18506
18741
|
}
|
|
18507
18742
|
} else {
|
|
@@ -18524,7 +18759,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
18524
18759
|
durationMs: runData.duration_ms
|
|
18525
18760
|
}));
|
|
18526
18761
|
if (runData.status === "paused") {
|
|
18527
|
-
output.log(
|
|
18762
|
+
output.log(chalk67.gray(`
|
|
18528
18763
|
\uD83D\uDCA1 Use "roy-agent workflow run ${runData.run_id} --session-id ${runData.run_id} --input '<response>'" to resume`));
|
|
18529
18764
|
}
|
|
18530
18765
|
}
|
|
@@ -18596,11 +18831,11 @@ var WorkflowRunCommand = {
|
|
|
18596
18831
|
};
|
|
18597
18832
|
|
|
18598
18833
|
// src/commands/workflow/commands/stop.ts
|
|
18599
|
-
import
|
|
18834
|
+
import chalk68 from "chalk";
|
|
18600
18835
|
import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18601
18836
|
import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
|
|
18602
18837
|
var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
18603
|
-
const output = new
|
|
18838
|
+
const output = new OutputService2;
|
|
18604
18839
|
const envService = new EnvironmentService(output);
|
|
18605
18840
|
try {
|
|
18606
18841
|
await envService.create({ configPath: args.config });
|
|
@@ -18621,7 +18856,7 @@ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
|
|
|
18621
18856
|
output.error(result.error || `Failed to stop workflow: ${args.runId}`);
|
|
18622
18857
|
process.exit(1);
|
|
18623
18858
|
}
|
|
18624
|
-
output.log(
|
|
18859
|
+
output.log(chalk68.red(`
|
|
18625
18860
|
⏹️ Workflow stopped: ${args.runId}`));
|
|
18626
18861
|
} catch (error) {
|
|
18627
18862
|
output.error(`Failed to stop workflow: ${error}`);
|
|
@@ -18645,7 +18880,7 @@ var WorkflowStopCommand = {
|
|
|
18645
18880
|
};
|
|
18646
18881
|
|
|
18647
18882
|
// src/commands/workflow/commands/status.ts
|
|
18648
|
-
import
|
|
18883
|
+
import chalk69 from "chalk";
|
|
18649
18884
|
import { createWorkflowRunStatusTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
|
|
18650
18885
|
var WorkflowStatusCommand = {
|
|
18651
18886
|
command: "status <runId>",
|
|
@@ -18669,7 +18904,7 @@ var WorkflowStatusCommand = {
|
|
|
18669
18904
|
type: "string"
|
|
18670
18905
|
}),
|
|
18671
18906
|
async handler(args) {
|
|
18672
|
-
const output = new
|
|
18907
|
+
const output = new OutputService2;
|
|
18673
18908
|
const envService = new EnvironmentService(output);
|
|
18674
18909
|
try {
|
|
18675
18910
|
await envService.create({ configPath: args.config });
|
|
@@ -18738,7 +18973,7 @@ var WorkflowStatusCommand = {
|
|
|
18738
18973
|
stopped: "⏹️"
|
|
18739
18974
|
};
|
|
18740
18975
|
const emoji = statusEmoji[status] || "❓";
|
|
18741
|
-
output.log(
|
|
18976
|
+
output.log(chalk69.bold(`
|
|
18742
18977
|
${emoji} Status: ${status.toUpperCase()}`));
|
|
18743
18978
|
}
|
|
18744
18979
|
} catch (error) {
|
|
@@ -18751,7 +18986,7 @@ ${emoji} Status: ${status.toUpperCase()}`));
|
|
|
18751
18986
|
};
|
|
18752
18987
|
|
|
18753
18988
|
// src/commands/workflow/commands/nodes.ts
|
|
18754
|
-
import
|
|
18989
|
+
import chalk70 from "chalk";
|
|
18755
18990
|
var BUILT_IN_NODES = [
|
|
18756
18991
|
{
|
|
18757
18992
|
name: "ToolNode",
|
|
@@ -19088,7 +19323,7 @@ nodes:
|
|
|
19088
19323
|
];
|
|
19089
19324
|
function renderNodeTypesTable(nodes) {
|
|
19090
19325
|
const lines = [];
|
|
19091
|
-
lines.push(
|
|
19326
|
+
lines.push(chalk70.bold(`
|
|
19092
19327
|
\uD83D\uDCE6 Built-in Node Types
|
|
19093
19328
|
`));
|
|
19094
19329
|
lines.push("┌────────────┬────────────────────┬─────────────────────────────────────────────────────────────┐");
|
|
@@ -19106,29 +19341,29 @@ function renderNodeTypesTable(nodes) {
|
|
|
19106
19341
|
}
|
|
19107
19342
|
function renderNodeDetail(node) {
|
|
19108
19343
|
const lines = [];
|
|
19109
|
-
lines.push(
|
|
19344
|
+
lines.push(chalk70.bold(`
|
|
19110
19345
|
[${node.type}] ${node.name}`));
|
|
19111
|
-
lines.push(
|
|
19346
|
+
lines.push(chalk70.dim("─".repeat(60)) + `
|
|
19112
19347
|
`);
|
|
19113
|
-
lines.push(
|
|
19348
|
+
lines.push(chalk70.bold("Description:"));
|
|
19114
19349
|
lines.push(` ${node.description}
|
|
19115
19350
|
`);
|
|
19116
|
-
lines.push(
|
|
19351
|
+
lines.push(chalk70.bold("Configuration:"));
|
|
19117
19352
|
lines.push(' type: "' + node.type + '"');
|
|
19118
19353
|
lines.push(" config:");
|
|
19119
19354
|
for (const input of node.inputs) {
|
|
19120
|
-
const required = input.required ?
|
|
19355
|
+
const required = input.required ? chalk70.red("*") : " ";
|
|
19121
19356
|
lines.push(` ${input.name} (${input.type})${required}`);
|
|
19122
19357
|
lines.push(` ${input.description}`);
|
|
19123
19358
|
}
|
|
19124
19359
|
lines.push(`
|
|
19125
|
-
${
|
|
19360
|
+
${chalk70.bold("Output:")} ${node.output}`);
|
|
19126
19361
|
if (node.example) {
|
|
19127
|
-
lines.push(
|
|
19362
|
+
lines.push(chalk70.bold(`
|
|
19128
19363
|
Example:`));
|
|
19129
|
-
lines.push(
|
|
19364
|
+
lines.push(chalk70.gray("```yaml"));
|
|
19130
19365
|
lines.push(node.example);
|
|
19131
|
-
lines.push(
|
|
19366
|
+
lines.push(chalk70.gray("```"));
|
|
19132
19367
|
}
|
|
19133
19368
|
return lines.join(`
|
|
19134
19369
|
`);
|
|
@@ -19144,16 +19379,16 @@ var WorkflowNodesCommand = {
|
|
|
19144
19379
|
const nodeType = args.type?.toLowerCase();
|
|
19145
19380
|
if (!nodeType) {
|
|
19146
19381
|
console.log(renderNodeTypesTable(BUILT_IN_NODES));
|
|
19147
|
-
console.log(
|
|
19148
|
-
Use `) +
|
|
19149
|
-
console.log(
|
|
19382
|
+
console.log(chalk70.gray(`
|
|
19383
|
+
Use `) + chalk70.cyan("roy-agent workflow nodes <type>") + chalk70.gray(" for detailed information"));
|
|
19384
|
+
console.log(chalk70.gray("Available types: ") + chalk70.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
19150
19385
|
return;
|
|
19151
19386
|
}
|
|
19152
19387
|
const node = BUILT_IN_NODES.find((n) => n.type === nodeType);
|
|
19153
19388
|
if (!node) {
|
|
19154
|
-
console.log(
|
|
19389
|
+
console.log(chalk70.red(`
|
|
19155
19390
|
❌ Unknown node type: ${nodeType}`));
|
|
19156
|
-
console.log(
|
|
19391
|
+
console.log(chalk70.gray("Available types: ") + chalk70.yellow(BUILT_IN_NODES.map((n) => n.type).join(", ")));
|
|
19157
19392
|
process.exit(1);
|
|
19158
19393
|
}
|
|
19159
19394
|
console.log(renderNodeDetail(node));
|
|
@@ -19161,7 +19396,7 @@ Use `) + chalk69.cyan("roy-agent workflow nodes <type>") + chalk69.gray(" for de
|
|
|
19161
19396
|
};
|
|
19162
19397
|
|
|
19163
19398
|
// src/commands/workflow/commands/validate.ts
|
|
19164
|
-
import
|
|
19399
|
+
import chalk71 from "chalk";
|
|
19165
19400
|
import { readFileSync } from "fs";
|
|
19166
19401
|
async function parseWorkflowInput(input, yamlStr) {
|
|
19167
19402
|
const parseYaml = async (content) => {
|
|
@@ -19194,25 +19429,25 @@ function renderResult(result, options) {
|
|
|
19194
19429
|
return;
|
|
19195
19430
|
}
|
|
19196
19431
|
if (result.valid) {
|
|
19197
|
-
console.log(
|
|
19432
|
+
console.log(chalk71.green(`
|
|
19198
19433
|
✅ Workflow validation PASSED
|
|
19199
19434
|
`));
|
|
19200
|
-
console.log(
|
|
19435
|
+
console.log(chalk71.bold(`Workflow: ${result.workflowName}`));
|
|
19201
19436
|
console.log(`Nodes: ${result.nodeCount}`);
|
|
19202
19437
|
console.log(`
|
|
19203
19438
|
Valid nodes:`);
|
|
19204
|
-
console.log(
|
|
19439
|
+
console.log(chalk71.green(" ✓ All nodes passed validation"));
|
|
19205
19440
|
} else {
|
|
19206
|
-
console.log(
|
|
19441
|
+
console.log(chalk71.red(`
|
|
19207
19442
|
❌ Workflow validation FAILED (${result.errors.length} errors found)
|
|
19208
19443
|
`));
|
|
19209
19444
|
result.errors.forEach((error, index) => {
|
|
19210
|
-
console.log(
|
|
19211
|
-
console.log(` ${
|
|
19212
|
-
console.log(` ${
|
|
19213
|
-
console.log(` ${
|
|
19214
|
-
console.log(` ${
|
|
19215
|
-
console.log(` ${
|
|
19445
|
+
console.log(chalk71.red(`[Error ${index + 1}/${result.errors.length}]${error.nodeId ? ` Node "${error.nodeId}"` : ""}`));
|
|
19446
|
+
console.log(` ${chalk71.bold("Type:")} ${error.type}`);
|
|
19447
|
+
console.log(` ${chalk71.bold("Description:")} ${error.description}`);
|
|
19448
|
+
console.log(` ${chalk71.bold("Expected:")} ${error.expected}`);
|
|
19449
|
+
console.log(` ${chalk71.bold("Actual:")} ${error.actual}`);
|
|
19450
|
+
console.log(` ${chalk71.green("Fix:")} ${error.fix}`);
|
|
19216
19451
|
console.log();
|
|
19217
19452
|
});
|
|
19218
19453
|
}
|
|
@@ -19237,7 +19472,7 @@ var WorkflowValidateCommand = {
|
|
|
19237
19472
|
try {
|
|
19238
19473
|
const workflow = await parseWorkflowInput(options.input, options.yaml);
|
|
19239
19474
|
if (!workflow) {
|
|
19240
|
-
console.error(
|
|
19475
|
+
console.error(chalk71.red("Failed to parse workflow input"));
|
|
19241
19476
|
process.exit(1);
|
|
19242
19477
|
}
|
|
19243
19478
|
const validator = new WorkflowValidator;
|
|
@@ -19245,7 +19480,7 @@ var WorkflowValidateCommand = {
|
|
|
19245
19480
|
renderResult(result, options);
|
|
19246
19481
|
process.exit(result.valid ? 0 : 1);
|
|
19247
19482
|
} catch (error) {
|
|
19248
|
-
console.error(
|
|
19483
|
+
console.error(chalk71.red(`
|
|
19249
19484
|
Error: ${error.message}`));
|
|
19250
19485
|
process.exit(1);
|
|
19251
19486
|
}
|
|
@@ -19253,7 +19488,7 @@ Error: ${error.message}`));
|
|
|
19253
19488
|
};
|
|
19254
19489
|
|
|
19255
19490
|
// src/commands/workflow/commands/search.ts
|
|
19256
|
-
import
|
|
19491
|
+
import chalk72 from "chalk";
|
|
19257
19492
|
import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
|
|
19258
19493
|
var WorkflowSearchCommand = {
|
|
19259
19494
|
command: "search",
|
|
@@ -19313,7 +19548,7 @@ var WorkflowSearchCommand = {
|
|
|
19313
19548
|
}),
|
|
19314
19549
|
async handler(args) {
|
|
19315
19550
|
const a = args;
|
|
19316
|
-
const output = new
|
|
19551
|
+
const output = new OutputService2;
|
|
19317
19552
|
const envService = new EnvironmentService(output);
|
|
19318
19553
|
try {
|
|
19319
19554
|
await runWorkflowSearch({
|
|
@@ -19367,6 +19602,9 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
19367
19602
|
const availableTags = result.available_tags ?? [];
|
|
19368
19603
|
if (asJson) {
|
|
19369
19604
|
output.json({
|
|
19605
|
+
total: workflows.length,
|
|
19606
|
+
available_tags: availableTags,
|
|
19607
|
+
keyword,
|
|
19370
19608
|
workflows: workflows.map((w) => ({
|
|
19371
19609
|
name: w.name,
|
|
19372
19610
|
version: w.version,
|
|
@@ -19375,9 +19613,6 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
19375
19613
|
createdAt: w.createdAt,
|
|
19376
19614
|
updatedAt: w.updatedAt
|
|
19377
19615
|
})),
|
|
19378
|
-
available_tags: availableTags,
|
|
19379
|
-
total: workflows.length,
|
|
19380
|
-
keyword,
|
|
19381
19616
|
tags
|
|
19382
19617
|
});
|
|
19383
19618
|
return;
|
|
@@ -19410,22 +19645,22 @@ var _runWorkflowSearchImpl = async function(opts) {
|
|
|
19410
19645
|
metadata: {}
|
|
19411
19646
|
}));
|
|
19412
19647
|
if (renderWorkflows.length === 0) {
|
|
19413
|
-
output.log(
|
|
19414
|
-
output.log(
|
|
19415
|
-
output.log(
|
|
19648
|
+
output.log(chalk72.yellow("\uD83D\uDD0D No workflows matched the search criteria."));
|
|
19649
|
+
output.log(chalk72.gray(` keyword: ${keyword || "(none)"}`));
|
|
19650
|
+
output.log(chalk72.gray(` tags: ${tags && tags.length > 0 ? tags.join(", ") : "(none)"}`));
|
|
19416
19651
|
} else {
|
|
19417
|
-
output.log(
|
|
19652
|
+
output.log(chalk72.bold(`\uD83D\uDD0D Search results (${renderWorkflows.length}):`));
|
|
19418
19653
|
output.log(renderWorkflowList(renderWorkflows));
|
|
19419
|
-
output.log(
|
|
19654
|
+
output.log(chalk72.green(`
|
|
19420
19655
|
✅ Found ${renderWorkflows.length} workflow(s)`));
|
|
19421
19656
|
}
|
|
19422
19657
|
if (availableTags.length > 0) {
|
|
19423
19658
|
output.log("");
|
|
19424
|
-
output.log(
|
|
19659
|
+
output.log(chalk72.bold("\uD83D\uDCDA Available tags (sorted by usage_count):"));
|
|
19425
19660
|
for (const t of availableTags) {
|
|
19426
19661
|
const name = t.name ?? t.tag;
|
|
19427
19662
|
const count = t.count ?? t.usage_count;
|
|
19428
|
-
output.log(
|
|
19663
|
+
output.log(chalk72.gray(` - ${name} (${count})`));
|
|
19429
19664
|
}
|
|
19430
19665
|
}
|
|
19431
19666
|
};
|
|
@@ -19437,7 +19672,7 @@ var runWorkflowSearch = wrapFunction3(_runWorkflowSearchImpl, "workflow.cli.sear
|
|
|
19437
19672
|
|
|
19438
19673
|
// src/commands/workflow/commands/tag.ts
|
|
19439
19674
|
import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
|
|
19440
|
-
import
|
|
19675
|
+
import chalk73 from "chalk";
|
|
19441
19676
|
var WorkflowTagListCommand = {
|
|
19442
19677
|
command: "list",
|
|
19443
19678
|
describe: "List all workflow tags from the workflow_tags table (sorted by usage_count DESC by default). Use this BEFORE `workflow add` to discover existing tags and reuse them for semantic consistency.",
|
|
@@ -19464,7 +19699,7 @@ var WorkflowTagListCommand = {
|
|
|
19464
19699
|
}),
|
|
19465
19700
|
async handler(args) {
|
|
19466
19701
|
const a = args;
|
|
19467
|
-
const output = new
|
|
19702
|
+
const output = new OutputService2;
|
|
19468
19703
|
const envService = new EnvironmentService(output);
|
|
19469
19704
|
try {
|
|
19470
19705
|
await runWorkflowTagList({
|
|
@@ -19509,7 +19744,7 @@ var WorkflowTagGetCommand = {
|
|
|
19509
19744
|
}),
|
|
19510
19745
|
async handler(args) {
|
|
19511
19746
|
const a = args;
|
|
19512
|
-
const output = new
|
|
19747
|
+
const output = new OutputService2;
|
|
19513
19748
|
const envService = new EnvironmentService(output);
|
|
19514
19749
|
try {
|
|
19515
19750
|
await runWorkflowTagGet({
|
|
@@ -19552,23 +19787,23 @@ var _runWorkflowTagListImpl = async function(opts) {
|
|
|
19552
19787
|
});
|
|
19553
19788
|
if (opts.asJson) {
|
|
19554
19789
|
output.json({
|
|
19555
|
-
|
|
19556
|
-
|
|
19790
|
+
total: result.total,
|
|
19791
|
+
tags: result.tags
|
|
19557
19792
|
});
|
|
19558
19793
|
return;
|
|
19559
19794
|
}
|
|
19560
19795
|
if (result.tags.length === 0) {
|
|
19561
|
-
output.log(
|
|
19562
|
-
output.log(
|
|
19796
|
+
output.log(chalk73.yellow("\uD83C\uDFF7️ No tags in the workflow_tags table yet."));
|
|
19797
|
+
output.log(chalk73.gray(" Tags are created automatically when you run `workflow add --tags <name>`."));
|
|
19563
19798
|
return;
|
|
19564
19799
|
}
|
|
19565
|
-
output.log(
|
|
19566
|
-
output.log(
|
|
19800
|
+
output.log(chalk73.bold(`\uD83C\uDFF7️ Workflow tags (${result.total}):`));
|
|
19801
|
+
output.log(chalk73.gray(` ${padRight("NAME", 24)}${padRight("USAGE", 8)}${padRight("CREATED", 22)}`));
|
|
19567
19802
|
for (const t of result.tags) {
|
|
19568
19803
|
const line = ` ${padRight(t.name, 24)}${padRight(String(t.usage_count), 8)}${padRight(formatDate2(t.created_at), 22)}`;
|
|
19569
19804
|
output.log(line);
|
|
19570
19805
|
}
|
|
19571
|
-
output.log(
|
|
19806
|
+
output.log(chalk73.gray(`
|
|
19572
19807
|
\uD83D\uDCA1 Tip: when adding a new workflow, prefer tags from this list to ensure semantic consistency.`));
|
|
19573
19808
|
};
|
|
19574
19809
|
var _runWorkflowTagGetImpl = async function(opts) {
|
|
@@ -19595,7 +19830,7 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
19595
19830
|
output.json({ error: "Tag not found", name: opts.name });
|
|
19596
19831
|
} else {
|
|
19597
19832
|
output.error(`Tag "${opts.name}" not found in the workflow_tags table.`);
|
|
19598
|
-
output.log(
|
|
19833
|
+
output.log(chalk73.gray(`Tip: run \`roy-agent workflow tag list\` to see available tags.`));
|
|
19599
19834
|
}
|
|
19600
19835
|
process.exitCode = 1;
|
|
19601
19836
|
return;
|
|
@@ -19604,10 +19839,10 @@ var _runWorkflowTagGetImpl = async function(opts) {
|
|
|
19604
19839
|
output.json(tag);
|
|
19605
19840
|
return;
|
|
19606
19841
|
}
|
|
19607
|
-
output.log(
|
|
19608
|
-
output.log(
|
|
19609
|
-
output.log(
|
|
19610
|
-
output.log(
|
|
19842
|
+
output.log(chalk73.bold(`\uD83C\uDFF7️ Tag: ${tag.name}`));
|
|
19843
|
+
output.log(chalk73.gray(` usage_count: ${tag.usage_count}`));
|
|
19844
|
+
output.log(chalk73.gray(` created_at: ${tag.created_at}`));
|
|
19845
|
+
output.log(chalk73.gray(` updated_at: ${tag.updated_at}`));
|
|
19611
19846
|
};
|
|
19612
19847
|
async function callListTags(service, options) {
|
|
19613
19848
|
if (typeof service.listTags !== "function") {
|