@vincentbanana/bananacli 0.5.0 → 0.6.1

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.
@@ -876,6 +876,7 @@ export async function startUiServer(options) {
876
876
  todos: session.todos,
877
877
  };
878
878
  const started = Date.now();
879
+ const toolStartedAt = new Map();
879
880
  let result;
880
881
  try {
881
882
  result = await runTurn({
@@ -892,15 +893,24 @@ export async function startUiServer(options) {
892
893
  recordChange: (path, beforeContent) => recorder.record(path, beforeContent),
893
894
  onText: (chunk) => send('text', { chunk }),
894
895
  onReasoning: (chunk) => send('reasoning', { chunk }),
895
- onToolStart: (name, input) => send('tool_start', { name, detail: summarizeInput(input) }),
896
- onToolEnd: (name, toolResult) => send('tool_end', {
897
- name,
898
- ok: toolResult.ok,
899
- display: toolResult.display ?? '',
900
- error: toolResult.ok ? '' : toolResult.content.slice(0, 400),
901
- // 详情面板用:命令输出 / 搜索结果等,最多 8KB
902
- detail: toolResult.content.slice(0, 8000),
903
- }),
896
+ onStep: (step) => send('step', { step }),
897
+ onToolStart: (name, input) => {
898
+ toolStartedAt.set(name, Date.now());
899
+ send('tool_start', { name, detail: summarizeInput(input) });
900
+ },
901
+ onToolEnd: (name, toolResult) => {
902
+ const began = toolStartedAt.get(name);
903
+ toolStartedAt.delete(name);
904
+ send('tool_end', {
905
+ name,
906
+ ok: toolResult.ok,
907
+ ms: began ? Date.now() - began : undefined,
908
+ display: toolResult.display ?? '',
909
+ error: toolResult.ok ? '' : toolResult.content.slice(0, 400),
910
+ // 详情面板用:命令输出 / 搜索结果等,最多 8KB
911
+ detail: toolResult.content.slice(0, 8000),
912
+ });
913
+ },
904
914
  onNotice: (message) => send('status', { message }),
905
915
  onCompact: () => send('status', { message: '已压缩历史对话' }),
906
916
  onRetry: (info) => send('status', { message: `网络重试 ${info.attempt}:${info.reason}` }),