@ai-setting/roy-agent-cli 1.7.21 → 1.7.31

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.
@@ -360,97 +360,6 @@ var init_markdown_renderer = __esm(() => {
360
360
  ], MarkdownRenderer.prototype, "push", null);
361
361
  });
362
362
 
363
- // src/services/stdout-batcher.ts
364
- function createStdoutBatcher(options = {}) {
365
- const flushIntervalMs = options.flushIntervalMs ?? 16;
366
- const maxBufferBytes = options.maxBufferBytes ?? 4096;
367
- const writeFn = options.writeFn ?? ((chunk) => {
368
- process.stdout.write(chunk);
369
- return true;
370
- });
371
- const onFlush = options.onFlush;
372
- let buffer = "";
373
- let queuedWrites = 0;
374
- let timer = null;
375
- let totalBatches = 0;
376
- let totalWrites = 0;
377
- let totalBytes = 0;
378
- let lastBatchWrites = 0;
379
- function performFlush() {
380
- if (buffer.length === 0)
381
- return;
382
- const chunk = buffer;
383
- buffer = "";
384
- lastBatchWrites = queuedWrites;
385
- queuedWrites = 0;
386
- totalBatches += 1;
387
- totalBytes += chunk.length;
388
- writeFn(chunk);
389
- if (onFlush) {
390
- onFlush({
391
- writesInLastBatch: lastBatchWrites,
392
- totalBatches,
393
- totalBytes
394
- });
395
- }
396
- }
397
- function scheduleFlush() {
398
- if (timer !== null)
399
- return;
400
- timer = setTimeout(() => {
401
- timer = null;
402
- performFlush();
403
- }, flushIntervalMs);
404
- }
405
- function maybeForceFlush() {
406
- if (buffer.length >= maxBufferBytes) {
407
- if (timer !== null) {
408
- clearTimeout(timer);
409
- timer = null;
410
- }
411
- performFlush();
412
- }
413
- }
414
- function write(chunk) {
415
- if (chunk.length === 0)
416
- return;
417
- buffer += chunk;
418
- queuedWrites += 1;
419
- totalWrites += 1;
420
- scheduleFlush();
421
- maybeForceFlush();
422
- }
423
- function flushNow() {
424
- if (timer !== null) {
425
- clearTimeout(timer);
426
- timer = null;
427
- }
428
- performFlush();
429
- }
430
- function cancel() {
431
- if (timer !== null) {
432
- clearTimeout(timer);
433
- timer = null;
434
- }
435
- buffer = "";
436
- queuedWrites = 0;
437
- }
438
- function getStats() {
439
- return {
440
- batches: totalBatches,
441
- queuedWrites: totalWrites,
442
- totalBytes,
443
- writesInLastBatch: lastBatchWrites
444
- };
445
- }
446
- return {
447
- write,
448
- flushNow,
449
- cancel,
450
- getStats
451
- };
452
- }
453
-
454
363
  // src/services/stream-output.service.ts
455
364
  var exports_stream_output_service = {};
456
365
  __export(exports_stream_output_service, {
@@ -461,26 +370,14 @@ __export(exports_stream_output_service, {
461
370
  COLORS: () => COLORS
462
371
  });
463
372
  import chalk2 from "chalk";
464
- import {
465
- createLogger as createLogger2,
466
- TracedAs as TracedAs2,
467
- wrapFunction
468
- } from "@ai-setting/roy-agent-core";
469
- function isStdoutBatchEnabled() {
470
- const v = process.env.ROY_AGENT_BATCH_STDOUT;
471
- if (v === undefined)
472
- return true;
473
- if (v === "0" || v === "false" || v === "no")
474
- return false;
475
- return true;
476
- }
373
+ import { createLogger as createLogger2, TracedAs as TracedAs2 } from "@ai-setting/roy-agent-core";
477
374
  function resetStreamAbort() {
478
375
  streamAbortSignal.aborted = false;
479
376
  }
480
377
  function abortStream() {
481
378
  streamAbortSignal.aborted = true;
482
379
  }
483
- var logger2, COLORS, emitBatchFlushSpanImpl = (stats) => {}, emitBatchFlushSpan, emitSilentModeSkippedSpanImpl = (textLength) => {}, emitSilentModeSkippedSpan, streamAbortSignal, StreamOutputService;
380
+ var logger2, COLORS, streamAbortSignal, StreamOutputService;
484
381
  var init_stream_output_service = __esm(() => {
485
382
  init_markdown_renderer();
486
383
  logger2 = createLogger2("stream-output");
@@ -500,28 +397,6 @@ var init_stream_output_service = __esm(() => {
500
397
  error: chalk2.red,
501
398
  progress: chalk2.dim
502
399
  };
503
- emitBatchFlushSpan = wrapFunction(emitBatchFlushSpanImpl, "cli.stream-output.writeStdout-batched", {
504
- recordParams: true,
505
- recordResult: false,
506
- log: false,
507
- paramFilter: (args) => {
508
- const s = args[0] ?? {};
509
- return {
510
- writesInLastBatch: s.writesInLastBatch ?? 0,
511
- totalBatches: s.batches ?? 0,
512
- totalBytes: s.totalBytes ?? 0
513
- };
514
- }
515
- });
516
- emitSilentModeSkippedSpan = wrapFunction(emitSilentModeSkippedSpanImpl, "stream-output.silent-mode-skipped", {
517
- recordParams: true,
518
- recordResult: false,
519
- log: false,
520
- paramFilter: (args) => ({
521
- "text.length": typeof args[0] === "number" ? args[0] : 0,
522
- reason: "silent=true (Ink mode)"
523
- })
524
- });
525
400
  streamAbortSignal = {
526
401
  aborted: false
527
402
  };
@@ -540,7 +415,6 @@ var init_stream_output_service = __esm(() => {
540
415
  reasoningClosedByText = false;
541
416
  chunkCallback = undefined;
542
417
  silent = false;
543
- stdoutBatcher = null;
544
418
  constructor(options = {}) {
545
419
  this.options = options;
546
420
  this.silent = options.silent ?? false;
@@ -565,33 +439,9 @@ var init_stream_output_service = __esm(() => {
565
439
  }
566
440
  }
567
441
  writeStdout(text) {
568
- if (this.silent) {
569
- emitSilentModeSkippedSpan(text.length);
570
- return;
571
- }
572
- if (!isStdoutBatchEnabled()) {
573
- process.stdout.write(text);
442
+ if (this.silent)
574
443
  return;
575
- }
576
- if (this.stdoutBatcher === null) {
577
- this.stdoutBatcher = createStdoutBatcher({
578
- flushIntervalMs: 16,
579
- onFlush: (stats) => {
580
- emitBatchFlushSpan(stats);
581
- }
582
- });
583
- }
584
- this.stdoutBatcher.write(text);
585
- }
586
- flushStdout() {
587
- if (this.stdoutBatcher !== null) {
588
- this.stdoutBatcher.flushNow();
589
- }
590
- }
591
- cancelStdout() {
592
- if (this.stdoutBatcher !== null) {
593
- this.stdoutBatcher.cancel();
594
- }
444
+ process.stdout.write(text);
595
445
  }
596
446
  logStdout(message) {
597
447
  if (this.silent)
@@ -836,60 +686,8 @@ ${COLORS.system("[已中断]")}
836
686
  this.reasoningStarted = false;
837
687
  this.reasoningClosedByText = false;
838
688
  this.thinkingPrinted = false;
839
- this.flushStdout();
840
689
  }
841
690
  };
842
- __legacyDecorateClassTS([
843
- TracedAs2("cli.stream-output.writeStdout", {
844
- recordParams: true,
845
- recordResult: false,
846
- log: false,
847
- paramFilter: (args) => ({
848
- "text.length": typeof args[0] === "string" ? args[0].length : 0,
849
- "text.head": typeof args[0] === "string" ? args[0].slice(0, 32) : "",
850
- "text.tail": typeof args[0] === "string" ? args[0].slice(-32) : "",
851
- "batch.enabled": isStdoutBatchEnabled() ? 1 : 0
852
- })
853
- }),
854
- __legacyMetadataTS("design:type", Function),
855
- __legacyMetadataTS("design:paramtypes", [
856
- String
857
- ]),
858
- __legacyMetadataTS("design:returntype", undefined)
859
- ], StreamOutputService.prototype, "writeStdout", null);
860
- __legacyDecorateClassTS([
861
- TracedAs2("stream.handle-event", {
862
- recordParams: true,
863
- recordResult: false,
864
- paramFilter: (args) => {
865
- const e = args[0] ?? {};
866
- const payload = e.payload ?? {};
867
- return {
868
- "event.type": e.type ?? "unknown",
869
- "event.payload.kind": payload && typeof payload === "object" ? Object.keys(payload).join(",") : ""
870
- };
871
- }
872
- }),
873
- __legacyMetadataTS("design:type", Function),
874
- __legacyMetadataTS("design:paramtypes", [
875
- typeof EnvEvent === "undefined" ? Object : EnvEvent
876
- ]),
877
- __legacyMetadataTS("design:returntype", undefined)
878
- ], StreamOutputService.prototype, "handleEvent", null);
879
- __legacyDecorateClassTS([
880
- TracedAs2("stream.handle-start", {
881
- recordParams: true,
882
- recordResult: false,
883
- paramFilter: (args) => ({
884
- model: args[0]?.metadata?.model ?? ""
885
- })
886
- }),
887
- __legacyMetadataTS("design:type", Function),
888
- __legacyMetadataTS("design:paramtypes", [
889
- Object
890
- ]),
891
- __legacyMetadataTS("design:returntype", undefined)
892
- ], StreamOutputService.prototype, "handleStart", null);
893
691
  __legacyDecorateClassTS([
894
692
  TracedAs2("stream.handle-text", {
895
693
  recordParams: true,
@@ -905,102 +703,6 @@ ${COLORS.system("[已中断]")}
905
703
  ]),
906
704
  __legacyMetadataTS("design:returntype", undefined)
907
705
  ], StreamOutputService.prototype, "handleText", null);
908
- __legacyDecorateClassTS([
909
- TracedAs2("stream.handle-reasoning", {
910
- recordParams: true,
911
- recordResult: false,
912
- paramFilter: (args) => ({
913
- "delta.length": args[0]?.delta?.length ?? 0,
914
- "content.length": args[0]?.content?.length ?? 0,
915
- phase: args[0]?.phase ?? ""
916
- })
917
- }),
918
- __legacyMetadataTS("design:type", Function),
919
- __legacyMetadataTS("design:paramtypes", [
920
- Object
921
- ]),
922
- __legacyMetadataTS("design:returntype", undefined)
923
- ], StreamOutputService.prototype, "handleReasoning", null);
924
- __legacyDecorateClassTS([
925
- TracedAs2("stream.handle-tool-call", {
926
- recordParams: true,
927
- recordResult: false,
928
- log: true,
929
- paramFilter: (args) => {
930
- const p = args[0] ?? {};
931
- return {
932
- "tool.name": p.name ?? "unknown",
933
- "tool.id": p.id ?? "",
934
- "tool.args.keys": p.arguments ? Object.keys(p.arguments).join(",") : ""
935
- };
936
- }
937
- }),
938
- __legacyMetadataTS("design:type", Function),
939
- __legacyMetadataTS("design:paramtypes", [
940
- Object
941
- ]),
942
- __legacyMetadataTS("design:returntype", undefined)
943
- ], StreamOutputService.prototype, "handleToolCall", null);
944
- __legacyDecorateClassTS([
945
- TracedAs2("stream.handle-tool-result", {
946
- recordParams: true,
947
- recordResult: false,
948
- log: true,
949
- paramFilter: (args) => {
950
- const p = args[0] ?? {};
951
- const result = p.result?.output ?? p.result?.error;
952
- return {
953
- "tool.name": p.name ?? "unknown",
954
- "tool.result.kind": result !== undefined ? typeof result : "none",
955
- "tool.result.preview": typeof result === "string" ? result.substring(0, 80) : typeof result === "object" && result !== null ? JSON.stringify(result).substring(0, 80) : ""
956
- };
957
- }
958
- }),
959
- __legacyMetadataTS("design:type", Function),
960
- __legacyMetadataTS("design:paramtypes", [
961
- Object
962
- ]),
963
- __legacyMetadataTS("design:returntype", undefined)
964
- ], StreamOutputService.prototype, "handleToolResult", null);
965
- __legacyDecorateClassTS([
966
- TracedAs2("stream.handle-tool-error", {
967
- recordParams: true,
968
- recordResult: false,
969
- log: true,
970
- paramFilter: (args) => {
971
- const p = args[0] ?? {};
972
- return {
973
- "tool.name": p.toolName ?? "unknown",
974
- "tool.error.preview": typeof p.error === "string" ? p.error.substring(0, 120) : ""
975
- };
976
- }
977
- }),
978
- __legacyMetadataTS("design:type", Function),
979
- __legacyMetadataTS("design:paramtypes", [
980
- Object
981
- ]),
982
- __legacyMetadataTS("design:returntype", undefined)
983
- ], StreamOutputService.prototype, "handleToolError", null);
984
- __legacyDecorateClassTS([
985
- TracedAs2("stream.handle-completed", {
986
- recordParams: true,
987
- recordResult: false,
988
- paramFilter: (args) => {
989
- const meta = args[0]?.metadata;
990
- return {
991
- model: meta?.model ?? "",
992
- "usage.promptTokens": meta?.usage?.promptTokens ?? 0,
993
- "usage.completionTokens": meta?.usage?.completionTokens ?? 0,
994
- "usage.totalTokens": meta?.usage?.totalTokens ?? 0
995
- };
996
- }
997
- }),
998
- __legacyMetadataTS("design:type", Function),
999
- __legacyMetadataTS("design:paramtypes", [
1000
- Object
1001
- ]),
1002
- __legacyMetadataTS("design:returntype", undefined)
1003
- ], StreamOutputService.prototype, "handleCompleted", null);
1004
706
  });
1005
707
 
1006
708
  // src/commands/ui/mascot/glasses-girl.ts
@@ -1389,7 +1091,6 @@ var init_slash_command_popup = __esm(() => {
1389
1091
  // src/render/markdown.ts
1390
1092
  import { Marked } from "marked";
1391
1093
  import { highlight } from "cli-highlight";
1392
- import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
1393
1094
  function setMarkdownEnabled(enabled) {
1394
1095
  markdownEnabled = enabled;
1395
1096
  }
@@ -1632,50 +1333,7 @@ function wrapLine(line, width) {
1632
1333
  return out.join(`
1633
1334
  `);
1634
1335
  }
1635
- function cacheLookup(key) {
1636
- for (let i = 0;i < renderCache.length; i++) {
1637
- if (renderCache[i].key === key) {
1638
- const entry = renderCache[i];
1639
- if (i > 0) {
1640
- renderCache.splice(i, 1);
1641
- renderCache.unshift(entry);
1642
- }
1643
- return entry.value;
1644
- }
1645
- }
1646
- return;
1647
- }
1648
- function cacheInsert(key, value, text, width) {
1649
- if (renderCache.length >= MAX_CACHE_ENTRIES) {
1650
- renderCache.pop();
1651
- }
1652
- renderCache.unshift({ key, value, text, width });
1653
- renderCacheStats.size = renderCache.length;
1654
- }
1655
- function findPrefixCacheEntry(text, width) {
1656
- let best;
1657
- let bestLen = -1;
1658
- for (let i = 0;i < renderCache.length; i++) {
1659
- const e = renderCache[i];
1660
- if (e.width !== width)
1661
- continue;
1662
- if (e.text.length === 0)
1663
- continue;
1664
- if (text.startsWith(e.text) && e.text.length > bestLen) {
1665
- best = e;
1666
- bestLen = e.text.length;
1667
- }
1668
- }
1669
- return best;
1670
- }
1671
- function isSuffixSafeToLexIndependently(suffix) {
1672
- if (suffix.length === 0)
1673
- return true;
1674
- if (suffix.charCodeAt(0) !== 10)
1675
- return true;
1676
- return false;
1677
- }
1678
- function renderMarkdownImpl(text, options = {}) {
1336
+ function renderMarkdown(text, options = {}) {
1679
1337
  const width = options.width ?? 80;
1680
1338
  if (!markdownEnabled) {
1681
1339
  return wrapLine(text, width);
@@ -1683,28 +1341,6 @@ function renderMarkdownImpl(text, options = {}) {
1683
1341
  if (!text || text.trim() === "") {
1684
1342
  return "";
1685
1343
  }
1686
- const key = text + "\x00" + width;
1687
- const cached = cacheLookup(key);
1688
- if (cached !== undefined) {
1689
- renderCacheStats.hits++;
1690
- renderCacheStats.cachedHits++;
1691
- return cached;
1692
- }
1693
- const prefixEntry = findPrefixCacheEntry(text, width);
1694
- if (prefixEntry !== undefined) {
1695
- const suffix = text.slice(prefixEntry.text.length);
1696
- if (isSuffixSafeToLexIndependently(suffix)) {
1697
- const suffixRender = renderMarkdownImpl(suffix, { width });
1698
- const combined = prefixEntry.value + suffixRender;
1699
- cacheInsert(key, combined, text, width);
1700
- renderCacheStats.hits++;
1701
- renderCacheStats.prefixHits++;
1702
- renderCacheStats.partialParses++;
1703
- return combined;
1704
- }
1705
- }
1706
- renderCacheStats.misses++;
1707
- renderCacheStats.partialParses++;
1708
1344
  let tokens;
1709
1345
  try {
1710
1346
  tokens = marked.lexer(text);
@@ -1718,11 +1354,9 @@ function renderMarkdownImpl(text, options = {}) {
1718
1354
  lines.push(block);
1719
1355
  }
1720
1356
  }
1721
- const result = lines.join(`
1357
+ return lines.join(`
1722
1358
 
1723
1359
  `);
1724
- cacheInsert(key, result, text, width);
1725
- return result;
1726
1360
  }
1727
1361
  function truncateForTerminal(text, maxLines) {
1728
1362
  if (maxLines <= 0) {
@@ -1818,7 +1452,7 @@ function tailTruncateToRows(line, rows, width) {
1818
1452
  const tail = segments.join("");
1819
1453
  return tail + ANSI2.reset;
1820
1454
  }
1821
- var ANSI2, DEFAULT_THEME, markdownEnabled = true, marked, MAX_CACHE_ENTRIES = 32, renderCache, renderCacheStats, renderMarkdown, ANSI_CSI_RE;
1455
+ var ANSI2, DEFAULT_THEME, markdownEnabled = true, marked, ANSI_CSI_RE;
1822
1456
  var init_markdown = __esm(() => {
1823
1457
  ANSI2 = {
1824
1458
  reset: "\x1B[0m",
@@ -1860,32 +1494,6 @@ var init_markdown = __esm(() => {
1860
1494
  breaks: false,
1861
1495
  pedantic: false
1862
1496
  });
1863
- renderCache = [];
1864
- renderCacheStats = {
1865
- hits: 0,
1866
- prefixHits: 0,
1867
- misses: 0,
1868
- partialParses: 0,
1869
- cachedHits: 0,
1870
- size: 0
1871
- };
1872
- renderMarkdown = wrapFunction2(renderMarkdownImpl, "markdown.render", {
1873
- recordParams: true,
1874
- recordResult: true,
1875
- paramFilter: (args) => ({
1876
- "input.length": typeof args[0] === "string" ? args[0].length : 0,
1877
- "options.width": typeof args[1]?.width === "number" ? args[1].width : 0
1878
- }),
1879
- resultFilter: (result) => ({
1880
- "output.length": typeof result === "string" ? result.length : 0,
1881
- "cache.hits": renderCacheStats.hits,
1882
- "cache.prefixHits": renderCacheStats.prefixHits,
1883
- "cache.misses": renderCacheStats.misses,
1884
- "cache.partialParses": renderCacheStats.partialParses,
1885
- "cache.size": renderCacheStats.size
1886
- }),
1887
- log: false
1888
- });
1889
1497
  ANSI_CSI_RE = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
1890
1498
  });
1891
1499
 
@@ -9853,7 +9461,7 @@ class CliQuietModeService {
9853
9461
  // package.json
9854
9462
  var package_default = {
9855
9463
  name: "@ai-setting/roy-agent-cli",
9856
- version: "1.7.21",
9464
+ version: "1.7.31",
9857
9465
  type: "module",
9858
9466
  description: "CLI for roy-agent - Non-interactive command execution",
9859
9467
  main: "./dist/index.js",
@@ -11008,21 +10616,6 @@ function finalizeActStdout(args) {
11008
10616
  output.log(result);
11009
10617
  }
11010
10618
 
11011
- // src/commands/shared/debug-trace.ts
11012
- function printTraceIdAfterResponse(traceId, options) {
11013
- const enabled = typeof options === "boolean" ? options : options.enabled;
11014
- if (!enabled)
11015
- return;
11016
- const writer = typeof options === "object" && options.write ? options.write : (chunk) => process.stderr.write(chunk);
11017
- writer(`[Trace] ${traceId}
11018
- `);
11019
- if (typeof options === "object" && typeof options.tuiSink === "function") {
11020
- try {
11021
- options.tuiSink(traceId);
11022
- } catch (_tuiErr) {}
11023
- }
11024
- }
11025
-
11026
10619
  // src/commands/act.ts
11027
10620
  function detectWorkspaceRoot(cwd = process.cwd(), runGit = execFileSync) {
11028
10621
  try {
@@ -11090,10 +10683,6 @@ function createActCommand(externalEnvService) {
11090
10683
  describe: "附加图片到消息(可多次传入;支持本地路径 / http(s) URL / data:base64)",
11091
10684
  type: "array",
11092
10685
  string: true
11093
- }).option("debug-on", {
11094
- describe: "调试模式:响应结束后输出 [Trace] <traceId>(stderr),便于追踪调用 trace",
11095
- type: "boolean",
11096
- default: false
11097
10686
  }),
11098
10687
  async handler(args) {
11099
10688
  const quiet = args.quiet ?? true;
@@ -11330,6 +10919,9 @@ function createActCommand(externalEnvService) {
11330
10919
  }
11331
10920
  });
11332
10921
  const traceId = rootSpan.spanContext.traceId;
10922
+ if (!quiet) {
10923
+ output.info(`[Trace] ${traceId}`);
10924
+ }
11333
10925
  provider.setGlobalContext(rootSpan.spanContext);
11334
10926
  const contextHandler = new ContextHandlerService(env, sessionComponent, { maxRetries: 1, autoCompact: true });
11335
10927
  const context = {
@@ -11364,7 +10956,6 @@ function createActCommand(externalEnvService) {
11364
10956
  streamService,
11365
10957
  output
11366
10958
  });
11367
- printTraceIdAfterResponse(traceId, args.debugOn ?? false);
11368
10959
  if (!quiet) {
11369
10960
  if (isWorkflowPausedActResult(result)) {
11370
10961
  output.warn("工作流已暂停,等待用户输入(见上方 resume 提示)");
@@ -11683,35 +11274,6 @@ class QueryExecutor {
11683
11274
  }
11684
11275
  }
11685
11276
  }
11686
- __legacyDecorateClassTS([
11687
- TracedAs4("cli.query-executor.setChunkCallback", {
11688
- recordParams: true,
11689
- recordResult: false,
11690
- log: true,
11691
- paramFilter: (args) => ({
11692
- "cb.isFunction": typeof args[0] === "function"
11693
- })
11694
- }),
11695
- __legacyMetadataTS("design:type", Function),
11696
- __legacyMetadataTS("design:paramtypes", [
11697
- typeof StreamChunkCallback === "undefined" ? Object : StreamChunkCallback
11698
- ]),
11699
- __legacyMetadataTS("design:returntype", undefined)
11700
- ], QueryExecutor.prototype, "setChunkCallback", null);
11701
- __legacyDecorateClassTS([
11702
- TracedAs4("cli.query-executor.handleEvent", {
11703
- recordParams: true,
11704
- recordResult: false,
11705
- paramFilter: (args) => ({
11706
- "event.type": args[0]?.type ?? "unknown"
11707
- })
11708
- }),
11709
- __legacyMetadataTS("design:type", Function),
11710
- __legacyMetadataTS("design:paramtypes", [
11711
- Object
11712
- ]),
11713
- __legacyMetadataTS("design:returntype", undefined)
11714
- ], QueryExecutor.prototype, "handleEvent", null);
11715
11277
  __legacyDecorateClassTS([
11716
11278
  TracedAs4("cli.query-executor.execute", { recordParams: true, log: true }),
11717
11279
  __legacyMetadataTS("design:type", Function),
@@ -11936,10 +11498,12 @@ subSessionId: ${payload.subSessionId}`;
11936
11498
  }
11937
11499
  formatWithEvent(event) {
11938
11500
  const triggerSessionId = extractTriggerSessionId(event);
11501
+ const chatId = extractChatId(event);
11939
11502
  return {
11940
11503
  message: this.format(event),
11941
11504
  envEvent: event,
11942
- triggerSessionId
11505
+ triggerSessionId,
11506
+ chatId
11943
11507
  };
11944
11508
  }
11945
11509
  }
@@ -11950,6 +11514,18 @@ function extractTriggerSessionId(event) {
11950
11514
  }
11951
11515
  return;
11952
11516
  }
11517
+ function extractChatId(event) {
11518
+ const metaChannel = event?.metadata?.replyChannel;
11519
+ if (metaChannel?.chatId && typeof metaChannel.chatId === "string" && metaChannel.chatId.length > 0) {
11520
+ return metaChannel.chatId;
11521
+ }
11522
+ const payload = event?.payload;
11523
+ const payloadChannel = payload?.replyChannel;
11524
+ if (payloadChannel?.chatId && typeof payloadChannel.chatId === "string" && payloadChannel.chatId.length > 0) {
11525
+ return payloadChannel.chatId;
11526
+ }
11527
+ return;
11528
+ }
11953
11529
 
11954
11530
  // src/commands/shared/event-handler.ts
11955
11531
  import { TracedAs as TracedAs5 } from "@ai-setting/roy-agent-core";
@@ -11967,6 +11543,7 @@ class EventHandler {
11967
11543
  unsubscribe = null;
11968
11544
  sessionComponent = null;
11969
11545
  activeEventSessionId = null;
11546
+ activeEventSessionChatId = null;
11970
11547
  constructor(options) {
11971
11548
  this.env = options.env;
11972
11549
  this.eventTypes = options.eventTypes;
@@ -12070,8 +11647,27 @@ class EventHandler {
12070
11647
  async ensureActiveSession() {
12071
11648
  if (!this.sessionComponent)
12072
11649
  return null;
12073
- if (this.activeEventSessionId)
12074
- return this.activeEventSessionId;
11650
+ const queueChatId = this.queue.map((item) => item.chatId).find((id) => !!id);
11651
+ if (this.activeEventSessionId) {
11652
+ const isChatSwitch = this.activeEventSessionChatId !== null && queueChatId !== undefined && this.activeEventSessionChatId !== queueChatId;
11653
+ if (!isChatSwitch) {
11654
+ return this.activeEventSessionId;
11655
+ }
11656
+ this.activeEventSessionId = null;
11657
+ this.activeEventSessionChatId = null;
11658
+ }
11659
+ if (queueChatId) {
11660
+ const chatSessionId = await this.ensureChatSession(queueChatId);
11661
+ if (chatSessionId) {
11662
+ if (this.isStopped) {
11663
+ return null;
11664
+ }
11665
+ this.activeEventSessionId = chatSessionId;
11666
+ this.activeEventSessionChatId = queueChatId;
11667
+ return chatSessionId;
11668
+ }
11669
+ console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${queueChatId}), ` + `falling back to trigger_session_id path`);
11670
+ }
12075
11671
  const triggerSessionId = this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
12076
11672
  if (triggerSessionId) {
12077
11673
  try {
@@ -12106,6 +11702,45 @@ class EventHandler {
12106
11702
  }
12107
11703
  return this.createNewEventSession();
12108
11704
  }
11705
+ async ensureChatSession(chatId) {
11706
+ if (!this.sessionComponent)
11707
+ return null;
11708
+ try {
11709
+ const existing = await this.sessionComponent.list({
11710
+ filter: { metadata: { chatId, type: "lark-chat" } },
11711
+ limit: 1
11712
+ });
11713
+ if (existing.length > 0) {
11714
+ return existing[0].id;
11715
+ }
11716
+ } catch (error) {
11717
+ console.error(`[EventHandler] Failed to list chat-keyed sessions (chatId=${chatId}):`, error);
11718
+ }
11719
+ try {
11720
+ const created = await this.sessionComponent.create({
11721
+ id: chatId,
11722
+ title: `Lark Chat ${chatId}`,
11723
+ metadata: {
11724
+ chatId,
11725
+ type: "lark-chat"
11726
+ }
11727
+ });
11728
+ if (this.isStopped) {
11729
+ return null;
11730
+ }
11731
+ return created.id;
11732
+ } catch (createErr) {
11733
+ console.warn(`[EventHandler] Failed to create chat-keyed session (chatId=${chatId}), ` + `trying get(): ${String(createErr)}`);
11734
+ try {
11735
+ const fallback = await this.sessionComponent.get(chatId);
11736
+ if (fallback)
11737
+ return fallback.id;
11738
+ } catch (getErr) {
11739
+ console.error(`[EventHandler] get() fallback also failed (chatId=${chatId}):`, getErr);
11740
+ }
11741
+ return null;
11742
+ }
11743
+ }
12109
11744
  async createNewEventSession() {
12110
11745
  try {
12111
11746
  const session = await this.sessionComponent.create({
@@ -12125,6 +11760,7 @@ class EventHandler {
12125
11760
  }
12126
11761
  clearActiveSession() {
12127
11762
  this.activeEventSessionId = null;
11763
+ this.activeEventSessionChatId = null;
12128
11764
  }
12129
11765
  getActiveEventSessionId() {
12130
11766
  return this.activeEventSessionId;
@@ -12138,16 +11774,6 @@ class EventHandler {
12138
11774
  return new Promise((resolve) => setTimeout(resolve, ms));
12139
11775
  }
12140
11776
  }
12141
- __legacyDecorateClassTS([
12142
- TracedAs5("cli.event-handler.start", {
12143
- recordParams: false,
12144
- recordResult: false,
12145
- log: true
12146
- }),
12147
- __legacyMetadataTS("design:type", Function),
12148
- __legacyMetadataTS("design:paramtypes", []),
12149
- __legacyMetadataTS("design:returntype", Function)
12150
- ], EventHandler.prototype, "start", null);
12151
11777
  __legacyDecorateClassTS([
12152
11778
  TracedAs5("cli.event-handler.handleEvent", { recordParams: true }),
12153
11779
  __legacyMetadataTS("design:type", Function),
@@ -12157,15 +11783,19 @@ __legacyDecorateClassTS([
12157
11783
  __legacyMetadataTS("design:returntype", undefined)
12158
11784
  ], EventHandler.prototype, "handleEvent", null);
12159
11785
  __legacyDecorateClassTS([
12160
- TracedAs5("cli.event-handler.processQueue", {
12161
- recordParams: false,
12162
- recordResult: false,
12163
- log: true
12164
- }),
11786
+ TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
12165
11787
  __legacyMetadataTS("design:type", Function),
12166
11788
  __legacyMetadataTS("design:paramtypes", []),
12167
11789
  __legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
12168
- ], EventHandler.prototype, "processQueue", null);
11790
+ ], EventHandler.prototype, "ensureActiveSession", null);
11791
+ __legacyDecorateClassTS([
11792
+ TracedAs5("cli.event-handler.ensureChatSession", { recordParams: true }),
11793
+ __legacyMetadataTS("design:type", Function),
11794
+ __legacyMetadataTS("design:paramtypes", [
11795
+ String
11796
+ ]),
11797
+ __legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
11798
+ ], EventHandler.prototype, "ensureChatSession", null);
12169
11799
 
12170
11800
  // src/commands/shared/esc-active-descendant.ts
12171
11801
  function hasActiveDescendants(env, parentSessionId) {
@@ -13112,23 +12742,8 @@ ${COLORS.system("[没有正在执行的请求]")}`);
13112
12742
  onSubmit: async (input) => {
13113
12743
  this.isExecuting = true;
13114
12744
  inkApiRef?.setMode("executing");
13115
- const inkTracerProvider = getTracerProvider3();
13116
- const inkTracer = inkTracerProvider.getTracer("roy-tracer");
13117
- const inkExistingContext = inkTracerProvider.getGlobalContext();
13118
- let inkRootSpan;
13119
- let inkTurnTraceId;
13120
- if (inkExistingContext) {
13121
- inkRootSpan = inkTracer.startSpan("interactive.execute", {
13122
- parent: inkExistingContext
13123
- });
13124
- inkTurnTraceId = inkExistingContext.traceId;
13125
- } else {
13126
- inkRootSpan = inkTracer.startSpan("interactive.execute");
13127
- inkTurnTraceId = inkRootSpan.spanContext.traceId;
13128
- inkTracerProvider.setGlobalContext(inkRootSpan.spanContext);
13129
- }
13130
12745
  try {
13131
- await this.options.onExecute(input, inkTurnTraceId, undefined);
12746
+ await this.options.onExecute(input);
13132
12747
  inkApiRef?.setMode("ready");
13133
12748
  if (this.options.onAfterExecute) {
13134
12749
  try {
@@ -13143,26 +12758,6 @@ ${COLORS.system("[没有正在执行的请求]")}`);
13143
12758
  inkApiRef?.appendMessage({ role: "system", content: `[Error] ${msg}` });
13144
12759
  throw err;
13145
12760
  } finally {
13146
- try {
13147
- printTraceIdAfterResponse(inkTurnTraceId, {
13148
- enabled: this.options.debugOn ?? false,
13149
- tuiSink: (traceId) => {
13150
- inkApiRef?.appendMessage({
13151
- role: "system",
13152
- content: `\uD83D\uDD0D [Trace] ${traceId}`
13153
- });
13154
- }
13155
- });
13156
- } catch (traceErr) {
13157
- logger5.warn("printTraceIdAfterResponse failed (ink path)", {
13158
- error: String(traceErr)
13159
- });
13160
- }
13161
- try {
13162
- inkRootSpan.end();
13163
- } catch (spanErr) {
13164
- logger5.warn("inkRootSpan.end failed", { error: String(spanErr) });
13165
- }
13166
12761
  this.isExecuting = false;
13167
12762
  }
13168
12763
  },
@@ -13432,6 +13027,7 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
13432
13027
  traceId = rootSpan.spanContext.traceId;
13433
13028
  provider.setGlobalContext(rootSpan.spanContext);
13434
13029
  }
13030
+ console.log(`${COLORS.system("[Trace] " + traceId)}`);
13435
13031
  console.log(`${COLORS.progress("[thinking...]")}`);
13436
13032
  try {
13437
13033
  await this.options.onExecute(message, traceId, agentContext);
@@ -13454,7 +13050,6 @@ ${COLORS.error("❌ 执行失败: " + error)}
13454
13050
  }
13455
13051
  } finally {
13456
13052
  rootSpan.end();
13457
- printTraceIdAfterResponse(traceId, this.options.debugOn ?? false);
13458
13053
  if (existingContext) {
13459
13054
  provider.setGlobalContext(existingContext);
13460
13055
  } else {
@@ -13795,10 +13390,6 @@ function createInteractiveCommand(externalEnvService) {
13795
13390
  describe: "Default agent 名字(默认 Roy,可被覆盖)",
13796
13391
  type: "string",
13797
13392
  default: "Roy"
13798
- }).option("debug-on", {
13799
- describe: "调试模式:每次 turn 结束后输出 [Trace] <traceId>(stderr),便于追踪调用 trace",
13800
- type: "boolean",
13801
- default: false
13802
13393
  }),
13803
13394
  async handler(args) {
13804
13395
  CliQuietModeService.getInstance().setQuiet(true);
@@ -13965,7 +13556,6 @@ function createInteractiveCommand(externalEnvService) {
13965
13556
  model: args.model,
13966
13557
  version: getPackageVersion(),
13967
13558
  useInk,
13968
- debugOn: args.debugOn ?? false,
13969
13559
  onExecute: async (message, traceId, agentContext) => {
13970
13560
  resetStreamAbort();
13971
13561
  const preloadedPrompts = eventSourceSystemPrompts;
@@ -14140,16 +13730,15 @@ function createInteractiveCommand(externalEnvService) {
14140
13730
  var InteractiveCommand = createInteractiveCommand();
14141
13731
 
14142
13732
  // src/commands/run.ts
14143
- import React8 from "react";
13733
+ import React6 from "react";
14144
13734
  import { render } from "ink";
14145
13735
 
14146
13736
  // src/RunTui.tsx
14147
- import { useState as useState6, useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7, useMemo as useMemo3 } from "react";
14148
- import { Box as Box7, Text as Text9, useApp as useApp2 } from "ink";
13737
+ import { useState as useState6, useCallback as useCallback4, useRef as useRef2, useEffect as useEffect5 } from "react";
13738
+ import { Box as Box6, Text as Text8, useApp as useApp2 } from "ink";
14149
13739
 
14150
13740
  // src/tui/App.tsx
14151
13741
  init_Markdown();
14152
- import React4, { useEffect as useEffect4, useRef as useRef2 } from "react";
14153
13742
  import { Box as Box4, Static as Static2, Text as Text6 } from "ink";
14154
13743
 
14155
13744
  // src/tui/Spinner.tsx
@@ -14188,45 +13777,12 @@ var Spinner = ({
14188
13777
  // src/tui/App.tsx
14189
13778
  init_StatusBar();
14190
13779
  init_theme();
14191
- import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
14192
13780
  import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
14193
13781
  var ROLE_PREFIX = {
14194
13782
  user: "\uD83D\uDC64 You",
14195
13783
  assistant: "\uD83E\uDD16 Agent",
14196
13784
  tool: "\uD83D\uDD27 Tool"
14197
13785
  };
14198
- var emitAppRenderSpanImpl = (snapshot) => {};
14199
- var emitAppRenderSpan = wrapFunction3(emitAppRenderSpanImpl, "tui.app.render", {
14200
- recordParams: true,
14201
- recordResult: false,
14202
- log: true,
14203
- paramFilter: (args) => {
14204
- const s = args[0] ?? {};
14205
- return {
14206
- renderCount: s.renderCount ?? 0,
14207
- historyLength: s.historyLength ?? 0,
14208
- status: s.status ?? "unknown"
14209
- };
14210
- }
14211
- });
14212
- var emitRenderScheduledSpanImpl = (parentRenderCount) => {};
14213
- var emitRenderScheduledSpan = wrapFunction3(emitRenderScheduledSpanImpl, "tui.app.render-scheduled", {
14214
- recordParams: true,
14215
- recordResult: false,
14216
- log: false,
14217
- paramFilter: (args) => ({
14218
- parentRenderCount: args[0] ?? 0
14219
- })
14220
- });
14221
- var emitRenderThrottledSpanImpl = (parentRenderCount) => {};
14222
- var emitRenderThrottledSpan = wrapFunction3(emitRenderThrottledSpanImpl, "tui.app.render-throttled", {
14223
- recordParams: true,
14224
- recordResult: false,
14225
- log: false,
14226
- paramFilter: (args) => ({
14227
- parentRenderCount: args[0] ?? 0
14228
- })
14229
- });
14230
13786
  var RoleLabel = ({ role }) => {
14231
13787
  const theme = getTheme();
14232
13788
  const roleColor = role === "user" ? theme.user : role === "assistant" ? theme.assistant : theme.tool;
@@ -14294,18 +13850,10 @@ var App = ({
14294
13850
  status,
14295
13851
  model,
14296
13852
  workdir,
13853
+ streamingText,
14297
13854
  tokenCount
14298
13855
  }) => {
14299
13856
  const theme = getTheme();
14300
- const renderCountRef = useRef2(0);
14301
- renderCountRef.current += 1;
14302
- useEffect4(() => {
14303
- emitAppRenderSpan({
14304
- renderCount: renderCountRef.current,
14305
- historyLength: history.length,
14306
- status
14307
- });
14308
- });
14309
13857
  return /* @__PURE__ */ jsxDEV6(Box4, {
14310
13858
  flexDirection: "column",
14311
13859
  minHeight: 20,
@@ -14339,7 +13887,21 @@ var App = ({
14339
13887
  label: "Agent is thinking..."
14340
13888
  }, undefined, false, undefined, this)
14341
13889
  }, undefined, false, undefined, this) : null,
14342
- status === "streaming" ? /* @__PURE__ */ jsxDEV6(Box4, {
13890
+ status === "streaming" && streamingText ? /* @__PURE__ */ jsxDEV6(Box4, {
13891
+ flexDirection: "column",
13892
+ marginBottom: 1,
13893
+ children: [
13894
+ /* @__PURE__ */ jsxDEV6(RoleLabel, {
13895
+ role: "assistant"
13896
+ }, undefined, false, undefined, this),
13897
+ /* @__PURE__ */ jsxDEV6(Box4, {
13898
+ marginLeft: 2,
13899
+ children: /* @__PURE__ */ jsxDEV6(Markdown, {
13900
+ text: streamingText
13901
+ }, undefined, false, undefined, this)
13902
+ }, undefined, false, undefined, this)
13903
+ ]
13904
+ }, undefined, true, undefined, this) : status === "streaming" ? /* @__PURE__ */ jsxDEV6(Box4, {
14343
13905
  marginBottom: 1,
14344
13906
  children: /* @__PURE__ */ jsxDEV6(Spinner, {
14345
13907
  label: "Generating response..."
@@ -14356,144 +13918,15 @@ var App = ({
14356
13918
  ]
14357
13919
  }, undefined, true, undefined, this);
14358
13920
  };
14359
- function areAppPropsEqual(prev, next) {
14360
- if (prev.status !== next.status)
14361
- return false;
14362
- if (prev.model !== next.model)
14363
- return false;
14364
- if (prev.workdir !== next.workdir)
14365
- return false;
14366
- if (prev.tokenCount !== next.tokenCount)
14367
- return false;
14368
- if (prev.history !== next.history)
14369
- return false;
14370
- return true;
14371
- }
14372
- var parentRenderCountRef = { current: 0 };
14373
- var AppThrottledImpl = (props) => {
14374
- parentRenderCountRef.current += 1;
14375
- emitRenderScheduledSpan(parentRenderCountRef.current);
14376
- return /* @__PURE__ */ jsxDEV6(App, {
14377
- ...props
14378
- }, undefined, false, undefined, this);
14379
- };
14380
- var AppThrottled = React4.memo(AppThrottledImpl, areAppPropsEqual);
14381
- AppThrottled.displayName = "App(throttled)";
14382
- var lastMemoResult = null;
14383
- var instrumentedAreEqual = (prev, next) => {
14384
- const equal = areAppPropsEqual(prev, next);
14385
- if (equal && lastMemoResult !== true) {
14386
- emitRenderThrottledSpan(parentRenderCountRef.current);
14387
- }
14388
- lastMemoResult = equal;
14389
- return equal;
14390
- };
14391
- var AppMemo = React4.memo(AppThrottledImpl, instrumentedAreEqual);
14392
- AppMemo.displayName = "App(memo-throttled)";
14393
- // src/tui/StreamingOverlay.tsx
14394
- init_Markdown();
14395
- import { useEffect as useEffect5, useRef as useRef3 } from "react";
14396
- import { Box as Box5, Text as Text7 } from "ink";
14397
- import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
14398
- import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
14399
- var emitOverlayRenderSpanImpl = (snapshot) => {};
14400
- var emitOverlayRenderSpan = wrapFunction4(emitOverlayRenderSpanImpl, "streaming-overlay.render", {
14401
- recordParams: true,
14402
- recordResult: false,
14403
- log: false,
14404
- paramFilter: (args) => {
14405
- const s = args[0] ?? {};
14406
- return {
14407
- renderCount: s.renderCount ?? 0,
14408
- streamingTextLength: s.streamingTextLength ?? 0,
14409
- status: s.status ?? "unknown"
14410
- };
14411
- }
14412
- });
14413
- var emitOverlayMarkdownSpanImpl = (snapshot) => {};
14414
- var emitOverlayMarkdownSpan = wrapFunction4(emitOverlayMarkdownSpanImpl, "streaming-overlay.markdown-render", {
14415
- recordParams: true,
14416
- recordResult: false,
14417
- log: false,
14418
- paramFilter: (args) => {
14419
- const s = args[0] ?? {};
14420
- return {
14421
- inputLength: s.inputLength ?? 0,
14422
- renderCount: s.renderCount ?? 0
14423
- };
14424
- }
14425
- });
14426
- var StreamingOverlay = ({
14427
- streamingText,
14428
- status,
14429
- markdownEnabled: markdownEnabled2,
14430
- width
14431
- }) => {
14432
- const renderCountRef = useRef3(0);
14433
- renderCountRef.current += 1;
14434
- useEffect5(() => {
14435
- emitOverlayRenderSpan({
14436
- renderCount: renderCountRef.current,
14437
- streamingTextLength: streamingText.length,
14438
- status
14439
- });
14440
- });
14441
- if (status === "thinking") {
14442
- return /* @__PURE__ */ jsxDEV7(Box5, {
14443
- marginBottom: 1,
14444
- children: /* @__PURE__ */ jsxDEV7(Text7, {
14445
- dimColor: true,
14446
- children: "\uD83E\uDD14 thinking..."
14447
- }, undefined, false, undefined, this)
14448
- }, undefined, false, undefined, this);
14449
- }
14450
- if (status === "idle") {
14451
- return null;
14452
- }
14453
- if (!streamingText) {
14454
- return /* @__PURE__ */ jsxDEV7(Box5, {
14455
- marginBottom: 1,
14456
- children: /* @__PURE__ */ jsxDEV7(Text7, {
14457
- dimColor: true,
14458
- children: "⏳ generating response..."
14459
- }, undefined, false, undefined, this)
14460
- }, undefined, false, undefined, this);
14461
- }
14462
- const effectiveWidth = width ?? process.stdout.columns ?? 80;
14463
- emitOverlayMarkdownSpan({
14464
- inputLength: streamingText.length,
14465
- renderCount: renderCountRef.current
14466
- });
14467
- return /* @__PURE__ */ jsxDEV7(Box5, {
14468
- flexDirection: "column",
14469
- marginBottom: 1,
14470
- children: [
14471
- /* @__PURE__ */ jsxDEV7(Text7, {
14472
- bold: true,
14473
- color: "cyan",
14474
- children: "\uD83E\uDD16 Agent"
14475
- }, undefined, false, undefined, this),
14476
- /* @__PURE__ */ jsxDEV7(Box5, {
14477
- marginLeft: 2,
14478
- children: markdownEnabled2 ? /* @__PURE__ */ jsxDEV7(Markdown, {
14479
- text: streamingText,
14480
- width: effectiveWidth
14481
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV7(Text7, {
14482
- children: streamingText
14483
- }, undefined, false, undefined, this)
14484
- }, undefined, false, undefined, this)
14485
- ]
14486
- }, undefined, true, undefined, this);
14487
- };
14488
13921
 
14489
13922
  // src/tui/index.ts
14490
13923
  init_Markdown();
14491
13924
  init_StatusBar();
14492
13925
 
14493
13926
  // src/tui/TextInput.tsx
14494
- import { useEffect as useEffect6, useState as useState4 } from "react";
14495
- import { Box as Box6, Text as Text8, useInput as useInput3 } from "ink";
14496
- import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
13927
+ import { useEffect as useEffect4, useState as useState4 } from "react";
13928
+ import { Box as Box5, Text as Text7, useInput as useInput3 } from "ink";
13929
+ import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
14497
13930
  var TextInput = ({
14498
13931
  label,
14499
13932
  prefix,
@@ -14505,7 +13938,7 @@ var TextInput = ({
14505
13938
  const [value, setValue] = useState4("");
14506
13939
  const [historyIndex, setHistoryIndex] = useState4(-1);
14507
13940
  const [draft, setDraft] = useState4("");
14508
- useEffect6(() => {
13941
+ useEffect4(() => {
14509
13942
  setHistoryIndex(-1);
14510
13943
  }, [history.length]);
14511
13944
  useInput3((input, key) => {
@@ -14559,9 +13992,9 @@ var TextInput = ({
14559
13992
  setValue((v) => v + input);
14560
13993
  }
14561
13994
  });
14562
- return /* @__PURE__ */ jsxDEV8(Box6, {
13995
+ return /* @__PURE__ */ jsxDEV7(Box5, {
14563
13996
  children: [
14564
- /* @__PURE__ */ jsxDEV8(Text8, {
13997
+ /* @__PURE__ */ jsxDEV7(Text7, {
14565
13998
  bold: true,
14566
13999
  color: "green",
14567
14000
  children: [
@@ -14569,21 +14002,21 @@ var TextInput = ({
14569
14002
  " "
14570
14003
  ]
14571
14004
  }, undefined, true, undefined, this),
14572
- /* @__PURE__ */ jsxDEV8(Text8, {
14005
+ /* @__PURE__ */ jsxDEV7(Text7, {
14573
14006
  bold: true,
14574
14007
  children: [
14575
14008
  label,
14576
14009
  ": "
14577
14010
  ]
14578
14011
  }, undefined, true, undefined, this),
14579
- /* @__PURE__ */ jsxDEV8(Text8, {
14012
+ /* @__PURE__ */ jsxDEV7(Text7, {
14580
14013
  children: value
14581
14014
  }, undefined, false, undefined, this),
14582
- !value && placeholder ? /* @__PURE__ */ jsxDEV8(Text8, {
14015
+ !value && placeholder ? /* @__PURE__ */ jsxDEV7(Text7, {
14583
14016
  dimColor: true,
14584
14017
  children: placeholder
14585
14018
  }, undefined, false, undefined, this) : null,
14586
- historyIndex !== -1 ? /* @__PURE__ */ jsxDEV8(Text8, {
14019
+ historyIndex !== -1 ? /* @__PURE__ */ jsxDEV7(Text7, {
14587
14020
  dimColor: true,
14588
14021
  children: " (history)"
14589
14022
  }, undefined, false, undefined, this) : null
@@ -14596,98 +14029,36 @@ init_theme();
14596
14029
  init_welcome_card2();
14597
14030
 
14598
14031
  // src/tui/use-streaming-accumulator.ts
14599
- import { useCallback as useCallback3, useRef as useRef4, useState as useState5 } from "react";
14600
- import { wrapFunction as wrapFunction5 } from "@ai-setting/roy-agent-core";
14032
+ import { useCallback as useCallback3, useState as useState5 } from "react";
14601
14033
  function useStreamingAccumulator() {
14602
14034
  const [status, setStatus] = useState5("idle");
14603
14035
  const [streamingText, setStreamingText] = useState5("");
14604
- const appendCountRef = useRef4(0);
14605
- const pendingBufferRef = useRef4("");
14606
- const flushScheduledRef = useRef4(false);
14607
- const flushBuffer = useCallback3(() => {
14608
- flushScheduledRef.current = false;
14609
- const buf = pendingBufferRef.current;
14610
- if (buf.length === 0)
14611
- return;
14612
- pendingBufferRef.current = "";
14613
- setStreamingText((prev) => prev + buf);
14614
- }, []);
14615
- const lastStatusRef = useRef4("idle");
14616
- const startImpl = useCallback3(() => {
14036
+ const start = useCallback3(() => {
14617
14037
  setStreamingText("");
14618
14038
  setStatus("thinking");
14619
- lastStatusRef.current = "thinking";
14620
- appendCountRef.current = 0;
14621
14039
  }, []);
14622
- const appendImpl = useCallback3((chunk) => {
14623
- pendingBufferRef.current += chunk;
14624
- if (!flushScheduledRef.current) {
14625
- flushScheduledRef.current = true;
14626
- queueMicrotask(flushBuffer);
14627
- }
14628
- if (lastStatusRef.current !== "streaming") {
14629
- setStatus("streaming");
14630
- lastStatusRef.current = "streaming";
14631
- }
14632
- appendCountRef.current += 1;
14633
- }, [flushBuffer]);
14634
- const finishImpl = useCallback3(() => {
14635
- if (pendingBufferRef.current.length > 0) {
14636
- flushBuffer();
14637
- }
14040
+ const append = useCallback3((chunk) => {
14041
+ setStatus("streaming");
14042
+ setStreamingText((prev) => prev + chunk);
14043
+ }, []);
14044
+ const finish = useCallback3(() => {
14045
+ setStatus("idle");
14638
14046
  let snapshot = "";
14639
14047
  setStreamingText((prev) => {
14640
14048
  snapshot = prev;
14641
14049
  return "";
14642
14050
  });
14643
- setStatus("idle");
14644
- lastStatusRef.current = "idle";
14645
14051
  return snapshot;
14646
- }, [flushBuffer]);
14647
- const failImpl = useCallback3((_err) => {
14648
- if (pendingBufferRef.current.length > 0) {
14649
- flushBuffer();
14650
- }
14052
+ }, []);
14053
+ const fail = useCallback3((_err) => {
14054
+ setStatus("idle");
14651
14055
  let snapshot = "";
14652
14056
  setStreamingText((prev) => {
14653
14057
  snapshot = prev;
14654
14058
  return "";
14655
14059
  });
14656
- setStatus("idle");
14657
- lastStatusRef.current = "idle";
14658
14060
  return snapshot;
14659
- }, [flushBuffer]);
14660
- const start = wrapFunction5(startImpl, "streaming.start", {
14661
- recordParams: false,
14662
- recordResult: false,
14663
- log: true
14664
- });
14665
- const append = wrapFunction5(appendImpl, "streaming.append", {
14666
- recordParams: true,
14667
- recordResult: false,
14668
- log: true,
14669
- paramFilter: (args) => ({
14670
- "chunk.length": typeof args[0] === "string" ? args[0].length : 0,
14671
- "chunk.head": typeof args[0] === "string" ? args[0].slice(0, 32) : "",
14672
- "chunk.tail": typeof args[0] === "string" ? args[0].slice(-32) : ""
14673
- })
14674
- });
14675
- const finish = wrapFunction5(finishImpl, "streaming.finish", {
14676
- recordParams: false,
14677
- recordResult: true,
14678
- log: true,
14679
- resultFilter: (result) => ({
14680
- "snapshot.length": typeof result === "string" ? result.length : 0
14681
- })
14682
- });
14683
- const fail = wrapFunction5(failImpl, "streaming.fail", {
14684
- recordParams: true,
14685
- recordResult: false,
14686
- log: true,
14687
- paramFilter: (args) => ({
14688
- "err.message": args[0] instanceof Error ? args[0].message : String(args[0])
14689
- })
14690
- });
14061
+ }, []);
14691
14062
  return { status, streamingText, start, append, finish, fail };
14692
14063
  }
14693
14064
 
@@ -14767,8 +14138,7 @@ function dispatchSlashCommand(raw, ctx) {
14767
14138
  }
14768
14139
 
14769
14140
  // src/RunTui.tsx
14770
- import { wrapFunction as wrapFunction6 } from "@ai-setting/roy-agent-core";
14771
- import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
14141
+ import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
14772
14142
  var RunScreen = ({
14773
14143
  handleQuery,
14774
14144
  streamHandleQuery,
@@ -14786,17 +14156,17 @@ var RunScreen = ({
14786
14156
  const stream = useStreamingAccumulator();
14787
14157
  const status = stream.status;
14788
14158
  const { exit } = useApp2();
14789
- const userTurnCountRef = useRef5(0);
14790
- const assistantTurnCountRef = useRef5(0);
14791
- const isProcessingRef = useRef5(0);
14792
- const executeQueryRef = useRef5(null);
14793
- const historyIdRef = useRef5(0);
14159
+ const userTurnCountRef = useRef2(0);
14160
+ const assistantTurnCountRef = useRef2(0);
14161
+ const isProcessingRef = useRef2(0);
14162
+ const executeQueryRef = useRef2(null);
14163
+ const historyIdRef = useRef2(0);
14794
14164
  const width = process.stdout.columns ?? 80;
14795
14165
  const doExit = useCallback4(() => {
14796
14166
  onExit?.();
14797
14167
  exit();
14798
14168
  }, [onExit, exit]);
14799
- const executeQueryImpl = useCallback4(async (message) => {
14169
+ const executeQuery = useCallback4(async (message) => {
14800
14170
  isProcessingRef.current += 1;
14801
14171
  stream.start();
14802
14172
  try {
@@ -14828,24 +14198,13 @@ var RunScreen = ({
14828
14198
  isProcessingRef.current -= 1;
14829
14199
  }
14830
14200
  }, [handleQuery, markdownEnabled2, maxLines, stream, streamHandleQuery, width]);
14831
- const executeQuery = useMemo3(() => wrapFunction6(executeQueryImpl, "tui.run-tui.executeQuery", {
14832
- recordParams: true,
14833
- recordResult: false,
14834
- log: true,
14835
- paramFilter: (args) => ({
14836
- "message.length": typeof args[0] === "string" ? args[0].length : 0,
14837
- "message.head": typeof args[0] === "string" ? args[0].slice(0, 60) : "",
14838
- "isProcessingRef.before": (isProcessingRef.current ?? 0) + 1,
14839
- streaming: !!streamHandleQuery
14840
- })
14841
- }), [executeQueryImpl, streamHandleQuery]);
14842
- useEffect7(() => {
14201
+ useEffect5(() => {
14843
14202
  executeQueryRef.current = executeQuery;
14844
14203
  }, [executeQuery]);
14845
- useEffect7(() => {
14204
+ useEffect5(() => {
14846
14205
  if (!onRegisterHandlers)
14847
14206
  return;
14848
- const handleNotificationImpl = async (message, _envEvent) => {
14207
+ const handleNotification = async (message, _envEvent) => {
14849
14208
  const notifId = `h${++historyIdRef.current}`;
14850
14209
  setHistory((h) => [
14851
14210
  ...h,
@@ -14855,31 +14214,10 @@ var RunScreen = ({
14855
14214
  await executeQueryRef.current(message);
14856
14215
  }
14857
14216
  };
14858
- const handleNotification = wrapFunction6(handleNotificationImpl, "tui.run-tui.handleNotification", {
14859
- recordParams: true,
14860
- recordResult: false,
14861
- log: true,
14862
- paramFilter: (args) => ({
14863
- "message.length": typeof args[0] === "string" ? args[0].length : 0,
14864
- "message.head": typeof args[0] === "string" ? args[0].slice(0, 60) : "",
14865
- isProcessingRef: isProcessingRef.current ?? 0
14866
- })
14867
- });
14868
14217
  const isIdle = () => {
14869
14218
  return isProcessingRef.current === 0;
14870
14219
  };
14871
- const appendTraceId = (traceId) => {
14872
- const traceIdItemId = `h${++historyIdRef.current}`;
14873
- setHistory((h) => [
14874
- ...h,
14875
- { role: "tool", content: `\uD83D\uDD0D [Trace] ${traceId}`, id: traceIdItemId }
14876
- ]);
14877
- };
14878
- onRegisterHandlers({
14879
- onNotification: handleNotification,
14880
- isIdle,
14881
- appendTraceId
14882
- });
14220
+ onRegisterHandlers({ onNotification: handleNotification, isIdle });
14883
14221
  }, [onRegisterHandlers]);
14884
14222
  const handleSubmit = useCallback4(async (raw) => {
14885
14223
  const trimmed = raw.trim();
@@ -14967,24 +14305,19 @@ var RunScreen = ({
14967
14305
  const handleCancel = useCallback4(() => {
14968
14306
  doExit();
14969
14307
  }, [doExit]);
14970
- return /* @__PURE__ */ jsxDEV9(Box7, {
14308
+ return /* @__PURE__ */ jsxDEV8(Box6, {
14971
14309
  flexDirection: "column",
14972
14310
  children: [
14973
- /* @__PURE__ */ jsxDEV9(AppMemo, {
14311
+ /* @__PURE__ */ jsxDEV8(App, {
14974
14312
  history,
14975
14313
  status,
14976
14314
  model,
14977
- workdir
14315
+ workdir,
14316
+ streamingText: stream.streamingText
14978
14317
  }, undefined, false, undefined, this),
14979
- status !== "idle" ? /* @__PURE__ */ jsxDEV9(StreamingOverlay, {
14980
- streamingText: stream.streamingText,
14981
- status,
14982
- markdownEnabled: markdownEnabled2,
14983
- width
14984
- }, undefined, false, undefined, this) : null,
14985
- status === "idle" ? /* @__PURE__ */ jsxDEV9(Box7, {
14318
+ status === "idle" ? /* @__PURE__ */ jsxDEV8(Box6, {
14986
14319
  marginTop: 1,
14987
- children: /* @__PURE__ */ jsxDEV9(TextInput, {
14320
+ children: /* @__PURE__ */ jsxDEV8(TextInput, {
14988
14321
  label: "You",
14989
14322
  prefix: "\uD83D\uDC64",
14990
14323
  placeholder: 'Type a message, "/help", or "exit"',
@@ -14993,9 +14326,9 @@ var RunScreen = ({
14993
14326
  history: userHistory
14994
14327
  }, undefined, false, undefined, this)
14995
14328
  }, undefined, false, undefined, this) : null,
14996
- errorMessage ? /* @__PURE__ */ jsxDEV9(Box7, {
14329
+ errorMessage ? /* @__PURE__ */ jsxDEV8(Box6, {
14997
14330
  marginTop: 1,
14998
- children: /* @__PURE__ */ jsxDEV9(Text9, {
14331
+ children: /* @__PURE__ */ jsxDEV8(Text8, {
14999
14332
  color: "red",
15000
14333
  children: [
15001
14334
  "⚠ ",
@@ -15093,11 +14426,7 @@ async function shutdownRunSteps(deps) {
15093
14426
  }
15094
14427
 
15095
14428
  // src/commands/run.ts
15096
- import {
15097
- wrapFunction as wrapFunction7,
15098
- getTracerProvider as getTracerProvider4
15099
- } from "@ai-setting/roy-agent-core";
15100
- async function loadHandleQueryImpl(options, hooks) {
14429
+ async function loadHandleQuery(options, hooks) {
15101
14430
  const quiet = CliQuietModeService.getInstance().isQuiet();
15102
14431
  const output = new OutputService2;
15103
14432
  output.configure({ quiet });
@@ -15162,7 +14491,7 @@ async function loadHandleQueryImpl(options, hooks) {
15162
14491
  }
15163
14492
  const llmComponent = envService.getLLM();
15164
14493
  queryExecutor.initStreamOutput(llmComponent ?? null);
15165
- const handleQueryImpl = async (message) => {
14494
+ const handleQuery = async (message) => {
15166
14495
  const mergedContext = {
15167
14496
  ...agentContext,
15168
14497
  model: options.model,
@@ -15179,14 +14508,6 @@ async function loadHandleQueryImpl(options, hooks) {
15179
14508
  }, undefined, mergedContext);
15180
14509
  return String(result ?? "");
15181
14510
  };
15182
- const handleQuery = wrapFunction7(handleQueryImpl, "cli.run.handleQuery", {
15183
- recordParams: true,
15184
- recordResult: false,
15185
- log: true,
15186
- paramFilter: (args) => ({
15187
- "message.length": typeof args[0] === "string" ? args[0].length : 0
15188
- })
15189
- });
15190
14511
  const taskEventHandler = new TaskEventHandler({
15191
14512
  env,
15192
14513
  enabled: true
@@ -15218,80 +14539,17 @@ async function loadHandleQueryImpl(options, hooks) {
15218
14539
  sessionManager
15219
14540
  };
15220
14541
  }
15221
- var loadHandleQuery = wrapFunction7(loadHandleQueryImpl, "cli.run.loadHandleQuery", {
15222
- recordParams: true,
15223
- recordResult: false,
15224
- log: true,
15225
- paramFilter: (args) => {
15226
- const opts = args[0] ?? {};
15227
- return {
15228
- "options.model": opts.model ?? "",
15229
- "options.workdir": opts.workdir ?? "",
15230
- "options.session": opts.session ?? "",
15231
- "options.eventSource": Array.isArray(opts.eventSource) ? opts.eventSource.join(",") : opts.eventSource ?? "",
15232
- "has.onNotification": !!args[1]?.onNotification
15233
- };
15234
- }
15235
- });
15236
- function createStreamHandleQuery(queryExecutor, sessionId, options, agentContext, eventSourceSystemPrompt, onTraceId) {
15237
- const innerStreamHandler = async (message, onChunk) => {
15238
- const onChunkInstrumented = wrapFunction7((chunk) => {
15239
- onChunk(chunk);
15240
- }, "cli.run.chunkCallbackImpl.onChunk-called", {
15241
- recordParams: true,
15242
- recordResult: false,
15243
- log: false,
15244
- paramFilter: (args) => ({
15245
- "chunk.length": typeof args[0] === "string" ? args[0].length : 0,
15246
- "chunk.head": typeof args[0] === "string" ? args[0].slice(0, 32) : ""
15247
- })
15248
- });
15249
- const chunkCallbackImpl = (event) => {
14542
+ function createStreamHandleQuery(queryExecutor, sessionId, options, agentContext, eventSourceSystemPrompt) {
14543
+ return async (message, onChunk) => {
14544
+ queryExecutor.setChunkCallback((event) => {
15250
14545
  if (event.type === "llm.text") {
15251
14546
  if (event.delta) {
15252
- onChunkInstrumented(event.delta);
14547
+ onChunk(event.delta);
15253
14548
  } else if (event.content) {
15254
- onChunkInstrumented(event.content);
14549
+ onChunk(event.content);
15255
14550
  }
15256
- return;
15257
- }
15258
- if (event.type === "tool.call") {
15259
- const toolName = event.toolName || "unknown";
15260
- const toolId = event.toolId || "";
15261
- onChunkInstrumented(`
15262
- \uD83D\uDD27 tool: ${toolName} (${toolId})
15263
- `);
15264
- return;
15265
- }
15266
- if (event.type === "tool.result") {
15267
- onChunkInstrumented(`
15268
- ✓ done
15269
- `);
15270
- return;
15271
- }
15272
- if (event.type === "tool.error") {
15273
- const msg = event.toolError || "error";
15274
- onChunkInstrumented(`
15275
- ✗ ${msg}
15276
- `);
15277
- return;
15278
- }
15279
- };
15280
- queryExecutor.setChunkCallback(wrapFunction7(chunkCallbackImpl, "cli.run.chunkCallback", {
15281
- recordParams: true,
15282
- recordResult: false,
15283
- log: true,
15284
- paramFilter: (args) => {
15285
- const e = args[0] ?? {};
15286
- return {
15287
- "event.type": e.type ?? "unknown",
15288
- "event.delta.length": typeof e.delta === "string" ? e.delta.length : 0,
15289
- "event.content.length": typeof e.content === "string" ? e.content.length : 0,
15290
- "event.toolName": e.toolName ?? "",
15291
- "event.toolId": e.toolId ?? ""
15292
- };
15293
14551
  }
15294
- }));
14552
+ });
15295
14553
  const mergedContext = {
15296
14554
  ...agentContext,
15297
14555
  model: options.model,
@@ -15301,37 +14559,13 @@ function createStreamHandleQuery(queryExecutor, sessionId, options, agentContext
15301
14559
  defaultAgentName: options.defaultAgentName
15302
14560
  }
15303
14561
  };
15304
- const turnSpan = getTracerProvider4().getTracer("roy-tracer").startSpan("cli.run.turn");
15305
- const turnTraceId = turnSpan.spanContext.traceId;
15306
- let result;
15307
- try {
15308
- result = await queryExecutor.execute(message, sessionId, {
15309
- showReasoning: options.reasoning ?? true,
15310
- showToolCalls: options.toolCalls ?? true,
15311
- showToolResults: options.toolResults ?? false
15312
- }, undefined, mergedContext);
15313
- turnSpan.end(result);
15314
- } catch (error) {
15315
- turnSpan.setAttribute("error", String(error));
15316
- turnSpan.end(undefined, error instanceof Error ? error : new Error(String(error)));
15317
- throw error;
15318
- } finally {
15319
- try {
15320
- onTraceId?.(turnTraceId);
15321
- } catch (cbErr) {
15322
- console.warn(`[Trace] sink failed: ${cbErr instanceof Error ? cbErr.message : String(cbErr)}`);
15323
- }
15324
- }
14562
+ const result = await queryExecutor.execute(message, sessionId, {
14563
+ showReasoning: options.reasoning ?? true,
14564
+ showToolCalls: options.toolCalls ?? true,
14565
+ showToolResults: options.toolResults ?? false
14566
+ }, undefined, mergedContext);
15325
14567
  return String(result ?? "");
15326
14568
  };
15327
- return wrapFunction7(innerStreamHandler, "cli.run.createStreamHandleQuery", {
15328
- recordParams: true,
15329
- recordResult: false,
15330
- log: true,
15331
- paramFilter: (args) => ({
15332
- "message.length": typeof args[0] === "string" ? args[0].length : 0
15333
- })
15334
- });
15335
14569
  }
15336
14570
  function createRunCommand() {
15337
14571
  return {
@@ -15404,10 +14638,6 @@ function createRunCommand() {
15404
14638
  type: "string",
15405
14639
  describe: "Default agent 名字(默认 Roy,可被覆盖)",
15406
14640
  default: "Roy"
15407
- }).option("debug-on", {
15408
- type: "boolean",
15409
- describe: "调试模式:每次 turn 结束后输出 [Trace] <traceId>(stderr),便于追踪调用 trace",
15410
- default: false
15411
14641
  }),
15412
14642
  handler: async (argv) => {
15413
14643
  if (argv.markdown === false) {
@@ -15449,17 +14679,10 @@ function createRunCommand() {
15449
14679
  logger: undefined
15450
14680
  });
15451
14681
  });
15452
- const debugOn = argv.debugOn ?? false;
15453
- let appendTraceIdTui;
15454
- const streamHandleQuery = createStreamHandleQuery(queryExecutor, sessionId, argv, agentContext, eventSourceSystemPrompt, (traceId) => {
15455
- printTraceIdAfterResponse(traceId, {
15456
- enabled: debugOn,
15457
- tuiSink: appendTraceIdTui
15458
- });
15459
- });
14682
+ const streamHandleQuery = createStreamHandleQuery(queryExecutor, sessionId, argv, agentContext, eventSourceSystemPrompt);
15460
14683
  const stopEventHandler = eventHandler.start();
15461
14684
  const stopTaskEventHandler = taskEventHandler.start();
15462
- const { waitUntilExit } = render(React8.createElement(RunTui_default, {
14685
+ const { waitUntilExit } = render(React6.createElement(RunTui_default, {
15463
14686
  handleQuery,
15464
14687
  streamHandleQuery,
15465
14688
  model: argv.model,
@@ -15469,7 +14692,6 @@ function createRunCommand() {
15469
14692
  onRegisterHandlers: (handlers) => {
15470
14693
  runState.onNotification = handlers.onNotification;
15471
14694
  runState.isIdle = handlers.isIdle;
15472
- appendTraceIdTui = handlers.appendTraceId;
15473
14695
  },
15474
14696
  onExit: () => {}
15475
14697
  }), { exitOnCtrlC: true });
@@ -15497,14 +14719,14 @@ function createRunCommand() {
15497
14719
  var RunCommand = createRunCommand();
15498
14720
 
15499
14721
  // src/commands/chat.ts
15500
- import React10 from "react";
14722
+ import React8 from "react";
15501
14723
  import { render as render2 } from "ink";
15502
14724
 
15503
14725
  // src/ChatTui.tsx
15504
- import { useEffect as useEffect8, useRef as useRef6, useState as useState7 } from "react";
15505
- import { Box as Box8, useApp as useApp3 } from "ink";
14726
+ import { useEffect as useEffect6, useRef as useRef3, useState as useState7 } from "react";
14727
+ import { Box as Box7, useApp as useApp3 } from "ink";
15506
14728
  init_markdown();
15507
- import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
14729
+ import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
15508
14730
  var ChatScreen = ({
15509
14731
  handleQuery,
15510
14732
  streamHandleQuery,
@@ -15517,11 +14739,11 @@ var ChatScreen = ({
15517
14739
  const [history, setHistory] = useState7([
15518
14740
  { role: "user", content: message, id: "h-init-1" }
15519
14741
  ]);
15520
- const historyIdRef = useRef6(1);
14742
+ const historyIdRef = useRef3(1);
15521
14743
  const stream = useStreamingAccumulator();
15522
14744
  const { exit } = useApp3();
15523
14745
  const width = process.stdout.columns ?? 80;
15524
- useEffect8(() => {
14746
+ useEffect6(() => {
15525
14747
  let cancelled = false;
15526
14748
  stream.start();
15527
14749
  (async () => {
@@ -15560,23 +14782,16 @@ var ChatScreen = ({
15560
14782
  cancelled = true;
15561
14783
  };
15562
14784
  }, [handleQuery, streamHandleQuery, message, maxLines, markdownEnabled2, exit, width, stream]);
15563
- return /* @__PURE__ */ jsxDEV10(Box8, {
14785
+ return /* @__PURE__ */ jsxDEV9(Box7, {
15564
14786
  flexDirection: "column",
15565
- children: [
15566
- /* @__PURE__ */ jsxDEV10(AppMemo, {
15567
- history,
15568
- status: stream.status,
15569
- model,
15570
- workdir
15571
- }, undefined, false, undefined, this),
15572
- stream.status !== "idle" ? /* @__PURE__ */ jsxDEV10(StreamingOverlay, {
15573
- streamingText: stream.streamingText,
15574
- status: stream.status,
15575
- markdownEnabled: markdownEnabled2,
15576
- width
15577
- }, undefined, false, undefined, this) : null
15578
- ]
15579
- }, undefined, true, undefined, this);
14787
+ children: /* @__PURE__ */ jsxDEV9(App, {
14788
+ history,
14789
+ status: stream.status,
14790
+ model,
14791
+ workdir,
14792
+ streamingText: stream.streamingText
14793
+ }, undefined, false, undefined, this)
14794
+ }, undefined, false, undefined, this);
15580
14795
  };
15581
14796
  var ChatTui_default = ChatScreen;
15582
14797
 
@@ -15655,7 +14870,7 @@ function createChatCommand() {
15655
14870
  }
15656
14871
  const maxLines = Number.parseInt(argv.maxLines ?? "500", 10);
15657
14872
  const handleQuery = await loadHandleQuery2(argv);
15658
- const { waitUntilExit } = render2(React10.createElement(ChatTui_default, {
14873
+ const { waitUntilExit } = render2(React8.createElement(ChatTui_default, {
15659
14874
  handleQuery,
15660
14875
  message: argv.message,
15661
14876
  model: argv.model,
@@ -25026,9 +24241,9 @@ import chalk73 from "chalk";
25026
24241
  import fs5 from "fs";
25027
24242
  import path8 from "path";
25028
24243
  import { createRunWorkflowTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
25029
- import { getTracerProvider as getTracerProvider5, propagation, wrapFunction as wrapFunction8 } from "@ai-setting/roy-agent-core";
24244
+ import { getTracerProvider as getTracerProvider4, propagation, wrapFunction } from "@ai-setting/roy-agent-core";
25030
24245
  import { isValidSessionId } from "@ai-setting/roy-agent-core/env/session";
25031
- var runWorkflow = wrapFunction8(async function runWorkflowImpl(args) {
24246
+ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
25032
24247
  const output = new OutputService2;
25033
24248
  const envService = new EnvironmentService(output);
25034
24249
  const traceparent = process.env.TRACEPARENT;
@@ -25048,7 +24263,7 @@ var runWorkflow = wrapFunction8(async function runWorkflowImpl(args) {
25048
24263
  output.info(`[OTel Trace] TRACEPARENT=${traceparent || "none"}, traceId=${traceId}, parentSpanId=${parentSpanId}`);
25049
24264
  let workflowSpan = undefined;
25050
24265
  try {
25051
- const provider = getTracerProvider5();
24266
+ const provider = getTracerProvider4();
25052
24267
  await provider.initialize();
25053
24268
  const tracer = provider.getTracer("roy-tracer");
25054
24269
  const restoredContext = tracer.getCurrentContext();
@@ -25305,8 +24520,8 @@ var WorkflowRunCommand = {
25305
24520
  // src/commands/workflow/commands/stop.ts
25306
24521
  import chalk74 from "chalk";
25307
24522
  import { createWorkflowRunStopTool } from "@ai-setting/roy-agent-core/env/workflow/tools";
25308
- import { wrapFunction as wrapFunction9 } from "@ai-setting/roy-agent-core";
25309
- var stopWorkflow = wrapFunction9(async function stopWorkflowImpl(args) {
24523
+ import { wrapFunction as wrapFunction2 } from "@ai-setting/roy-agent-core";
24524
+ var stopWorkflow = wrapFunction2(async function stopWorkflowImpl(args) {
25310
24525
  const output = new OutputService2;
25311
24526
  const envService = new EnvironmentService(output);
25312
24527
  try {
@@ -25961,7 +25176,7 @@ Error: ${error.message}`));
25961
25176
 
25962
25177
  // src/commands/workflow/commands/search.ts
25963
25178
  import chalk78 from "chalk";
25964
- import { wrapFunction as wrapFunction10 } from "@ai-setting/roy-agent-core";
25179
+ import { wrapFunction as wrapFunction3 } from "@ai-setting/roy-agent-core";
25965
25180
  var WorkflowSearchCommand = {
25966
25181
  command: "search",
25967
25182
  describe: "Search workflows by keyword and/or tags (multiple tags use AND filter). v2: returns available_tags.",
@@ -26136,14 +25351,14 @@ var _runWorkflowSearchImpl = async function(opts) {
26136
25351
  }
26137
25352
  }
26138
25353
  };
26139
- var runWorkflowSearch = wrapFunction10(_runWorkflowSearchImpl, "workflow.cli.search", {
25354
+ var runWorkflowSearch = wrapFunction3(_runWorkflowSearchImpl, "workflow.cli.search", {
26140
25355
  recordParams: true,
26141
25356
  recordResult: false,
26142
25357
  log: false
26143
25358
  });
26144
25359
 
26145
25360
  // src/commands/workflow/commands/tag.ts
26146
- import { wrapFunction as wrapFunction11 } from "@ai-setting/roy-agent-core";
25361
+ import { wrapFunction as wrapFunction4 } from "@ai-setting/roy-agent-core";
26147
25362
  import chalk79 from "chalk";
26148
25363
  var WorkflowTagListCommand = {
26149
25364
  command: "list",
@@ -26343,12 +25558,12 @@ function formatDate2(iso) {
26343
25558
  return iso;
26344
25559
  }
26345
25560
  }
26346
- var runWorkflowTagList = wrapFunction11(_runWorkflowTagListImpl, "workflow.cli.tag.list", {
25561
+ var runWorkflowTagList = wrapFunction4(_runWorkflowTagListImpl, "workflow.cli.tag.list", {
26347
25562
  recordParams: true,
26348
25563
  recordResult: false,
26349
25564
  log: false
26350
25565
  });
26351
- var runWorkflowTagGet = wrapFunction11(_runWorkflowTagGetImpl, "workflow.cli.tag.get", {
25566
+ var runWorkflowTagGet = wrapFunction4(_runWorkflowTagGetImpl, "workflow.cli.tag.get", {
26352
25567
  recordParams: true,
26353
25568
  recordResult: false,
26354
25569
  log: false