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