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