larkcc 0.12.3 → 0.12.5

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
@@ -6868,7 +6868,7 @@ var init_logger = __esm({
6868
6868
  "src/logger.ts"() {
6869
6869
  "use strict";
6870
6870
  init_source();
6871
- ts = () => source_default.gray((/* @__PURE__ */ new Date()).toLocaleTimeString());
6871
+ ts = () => source_default.blue((/* @__PURE__ */ new Date()).toLocaleTimeString());
6872
6872
  logger = {
6873
6873
  info: (msg) => console.log(`${ts()} ${source_default.cyan("\u2139")} ${msg}`),
6874
6874
  success: (msg) => console.log(`${ts()} ${source_default.green("\u2705")} ${msg}`),
@@ -135860,6 +135860,160 @@ var init_sanitize = __esm({
135860
135860
  }
135861
135861
  });
135862
135862
 
135863
+ // src/format/duration.ts
135864
+ function formatDuration(seconds) {
135865
+ if (seconds < 60) return `${seconds.toFixed(1)}s`;
135866
+ const minutes = Math.floor(seconds / 60);
135867
+ const remainSec = Math.round(seconds % 60);
135868
+ return `${minutes}m ${remainSec}s`;
135869
+ }
135870
+ function formatReasoningDuration(ms) {
135871
+ return formatDuration(ms / 1e3);
135872
+ }
135873
+ function buildThinkingPanel(options) {
135874
+ const truncatedThinking = options.thinking.length > THINKING_OVERFLOW_TRUNCATE ? truncateSafely(options.thinking, THINKING_OVERFLOW_TRUNCATE, "\n...") : options.thinking;
135875
+ const durLabel = options.reasoningElapsedMs ? ` ${formatReasoningDuration(options.reasoningElapsedMs)}` : "";
135876
+ return [
135877
+ {
135878
+ tag: "collapsible_panel",
135879
+ expanded: false,
135880
+ background_color: "wathet",
135881
+ header: {
135882
+ title: {
135883
+ tag: "markdown",
135884
+ content: `\u{1F4AD} Thought${durLabel}`,
135885
+ i18n_content: {
135886
+ zh_cn: `\u{1F4AD} \u601D\u8003${durLabel}`,
135887
+ en_us: `\u{1F4AD} Thought${durLabel}`
135888
+ }
135889
+ },
135890
+ vertical_align: "center",
135891
+ icon: {
135892
+ tag: "standard_icon",
135893
+ token: "down-small-ccm_outlined",
135894
+ size: "16px 16px"
135895
+ },
135896
+ icon_position: "follow_text",
135897
+ icon_expanded_angle: -180
135898
+ },
135899
+ border: { color: "grey", corner_radius: "5px" },
135900
+ vertical_spacing: "8px",
135901
+ padding: "8px 8px 8px 8px",
135902
+ elements: [
135903
+ {
135904
+ tag: "markdown",
135905
+ content: truncatedThinking,
135906
+ text_size: "notation"
135907
+ }
135908
+ ]
135909
+ },
135910
+ { tag: "hr" }
135911
+ ];
135912
+ }
135913
+ function detectLangFromPath(filePath) {
135914
+ const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
135915
+ return EXT_LANG_MAP[ext] ?? "";
135916
+ }
135917
+ function formatToolContent(toolName, detail, result) {
135918
+ if (toolName === "Read") {
135919
+ const lang = detectLangFromPath(detail);
135920
+ return "```" + lang + "\n" + result + "\n```";
135921
+ }
135922
+ if (toolName === "Bash") {
135923
+ return "```bash\n" + result + "\n```";
135924
+ }
135925
+ return result;
135926
+ }
135927
+ function buildToolResultPanel(entry) {
135928
+ const raw = entry.resultPreview.length > TOOL_RESULT_TRUNCATE ? truncateSafely(entry.resultPreview, TOOL_RESULT_TRUNCATE, "\n...") : entry.resultPreview;
135929
+ const content = formatToolContent(entry.toolName, entry.detail, raw);
135930
+ const headerTitle = entry.detail ? `**${entry.label}** \`${entry.detail}\`` : entry.label;
135931
+ return {
135932
+ tag: "collapsible_panel",
135933
+ expanded: false,
135934
+ background_color: "grey",
135935
+ header: {
135936
+ title: {
135937
+ tag: "markdown",
135938
+ content: headerTitle
135939
+ },
135940
+ vertical_align: "center",
135941
+ icon: {
135942
+ tag: "standard_icon",
135943
+ token: "down-small-ccm_outlined",
135944
+ size: "16px 16px"
135945
+ },
135946
+ icon_position: "right",
135947
+ icon_expanded_angle: -180
135948
+ },
135949
+ border: { color: "grey", corner_radius: "5px" },
135950
+ vertical_spacing: "8px",
135951
+ padding: "8px 8px 8px 8px",
135952
+ elements: [
135953
+ {
135954
+ tag: "markdown",
135955
+ content,
135956
+ text_size: "notation"
135957
+ }
135958
+ ]
135959
+ };
135960
+ }
135961
+ function buildToolPanels(results) {
135962
+ if (results.length === 0) return [];
135963
+ return results.map((r2) => buildToolResultPanel(r2));
135964
+ }
135965
+ var THINKING_OVERFLOW_TRUNCATE, TOOL_RESULT_TRUNCATE, STREAMING_TRUNCATE, TASK_SUMMARY_TRUNCATE, EXT_LANG_MAP;
135966
+ var init_duration = __esm({
135967
+ "src/format/duration.ts"() {
135968
+ "use strict";
135969
+ init_card_optimize();
135970
+ THINKING_OVERFLOW_TRUNCATE = 3e3;
135971
+ TOOL_RESULT_TRUNCATE = 2e3;
135972
+ STREAMING_TRUNCATE = 4e3;
135973
+ TASK_SUMMARY_TRUNCATE = 3e3;
135974
+ EXT_LANG_MAP = {
135975
+ ts: "typescript",
135976
+ tsx: "typescript",
135977
+ js: "javascript",
135978
+ jsx: "javascript",
135979
+ mjs: "javascript",
135980
+ py: "python",
135981
+ go: "go",
135982
+ rs: "rust",
135983
+ java: "java",
135984
+ json: "json",
135985
+ yaml: "yaml",
135986
+ yml: "yaml",
135987
+ md: "markdown",
135988
+ html: "html",
135989
+ htm: "html",
135990
+ css: "css",
135991
+ sql: "sql",
135992
+ sh: "bash",
135993
+ bash: "bash",
135994
+ zsh: "bash",
135995
+ xml: "xml",
135996
+ toml: "toml",
135997
+ ini: "ini",
135998
+ c: "c",
135999
+ h: "c",
136000
+ cpp: "cpp",
136001
+ cc: "cpp",
136002
+ cxx: "cpp",
136003
+ hpp: "cpp",
136004
+ rb: "ruby",
136005
+ php: "php",
136006
+ swift: "swift",
136007
+ kt: "kotlin",
136008
+ kts: "kotlin",
136009
+ dart: "dart",
136010
+ dockerfile: "dockerfile",
136011
+ makefile: "makefile",
136012
+ diff: "diff"
136013
+ };
136014
+ }
136015
+ });
136016
+
135863
136017
  // src/format/card.ts
135864
136018
  function buildHeader(options) {
135865
136019
  const header = {
@@ -135886,19 +136040,50 @@ function buildHeader(options) {
135886
136040
  }
135887
136041
  return header;
135888
136042
  }
135889
- function buildFooterMarkdown(stats) {
135890
- const parts = [];
136043
+ function buildStatsTags(stats) {
136044
+ const tags = [];
136045
+ if (stats.model) tags.push({ text: stats.model, color: "blue" });
136046
+ const totalTokens = (stats.inputTokens ?? 0) + (stats.outputTokens ?? 0);
136047
+ if (totalTokens > 0) tags.push({ text: `${totalTokens.toLocaleString()} tokens`, color: "turquoise" });
136048
+ if (stats.duration != null) tags.push({ text: formatDuration(stats.duration), color: "orange" });
136049
+ return tags;
136050
+ }
136051
+ function buildFooterElement(stats) {
136052
+ const columns = [];
135891
136053
  if (stats.inputTokens != null) {
135892
- parts.push(`\u{1F4E5} ${stats.inputTokens.toLocaleString()}`);
136054
+ columns.push({
136055
+ tag: "column",
136056
+ width: "weighted",
136057
+ weight: 1,
136058
+ vertical_align: "center",
136059
+ elements: [{ tag: "markdown", content: `<font color='grey'>\u{1F4E5} ${stats.inputTokens.toLocaleString()}</font>`, text_size: "notation" }]
136060
+ });
135893
136061
  }
135894
136062
  if (stats.outputTokens != null) {
135895
- parts.push(`\u{1F4E4} ${stats.outputTokens.toLocaleString()}`);
136063
+ columns.push({
136064
+ tag: "column",
136065
+ width: "weighted",
136066
+ weight: 1,
136067
+ vertical_align: "center",
136068
+ elements: [{ tag: "markdown", content: `<font color='grey'>\u{1F4E4} ${stats.outputTokens.toLocaleString()}</font>`, text_size: "notation" }]
136069
+ });
135896
136070
  }
135897
136071
  if (stats.toolCount != null && stats.toolCount > 0) {
135898
- parts.push(`\u{1F527} ${stats.toolCount}`);
136072
+ columns.push({
136073
+ tag: "column",
136074
+ width: "weighted",
136075
+ weight: 1,
136076
+ vertical_align: "center",
136077
+ elements: [{ tag: "markdown", content: `<font color='grey'>\u{1F527} ${stats.toolCount}</font>`, text_size: "notation" }]
136078
+ });
135899
136079
  }
135900
- if (parts.length === 0) return null;
135901
- return `<font color='grey'>${parts.join(" \xB7 ")}</font>`;
136080
+ if (columns.length === 0) return null;
136081
+ return {
136082
+ tag: "column_set",
136083
+ flex_mode: "none",
136084
+ background_style: "default",
136085
+ columns
136086
+ };
135902
136087
  }
135903
136088
  function buildStatusCard(options) {
135904
136089
  const header = buildHeader({
@@ -135929,6 +136114,7 @@ var init_card = __esm({
135929
136114
  "src/format/card.ts"() {
135930
136115
  "use strict";
135931
136116
  init_sanitize();
136117
+ init_duration();
135932
136118
  DEFAULT_ICON_TOKEN = "larkcommunity_colorful";
135933
136119
  }
135934
136120
  });
@@ -136859,158 +137045,6 @@ var init_format = __esm({
136859
137045
  }
136860
137046
  });
136861
137047
 
136862
- // src/format/duration.ts
136863
- function formatDuration(seconds) {
136864
- if (seconds < 60) return `${seconds.toFixed(1)}s`;
136865
- const minutes = Math.floor(seconds / 60);
136866
- const remainSec = Math.round(seconds % 60);
136867
- return `${minutes}m ${remainSec}s`;
136868
- }
136869
- function formatReasoningDuration(ms) {
136870
- return formatDuration(ms / 1e3);
136871
- }
136872
- function buildThinkingPanel(options) {
136873
- const truncatedThinking = options.thinking.length > THINKING_OVERFLOW_TRUNCATE ? truncateSafely(options.thinking, THINKING_OVERFLOW_TRUNCATE, "\n...") : options.thinking;
136874
- const durLabel = options.reasoningElapsedMs ? ` ${formatReasoningDuration(options.reasoningElapsedMs)}` : "";
136875
- return [
136876
- {
136877
- tag: "collapsible_panel",
136878
- expanded: false,
136879
- background_color: "wathet",
136880
- header: {
136881
- title: {
136882
- tag: "markdown",
136883
- content: `\u{1F4AD} Thought${durLabel}`,
136884
- i18n_content: {
136885
- zh_cn: `\u{1F4AD} \u601D\u8003${durLabel}`,
136886
- en_us: `\u{1F4AD} Thought${durLabel}`
136887
- }
136888
- },
136889
- vertical_align: "center",
136890
- icon: {
136891
- tag: "standard_icon",
136892
- token: "down-small-ccm_outlined",
136893
- size: "16px 16px"
136894
- },
136895
- icon_position: "follow_text",
136896
- icon_expanded_angle: -180
136897
- },
136898
- border: { color: "grey", corner_radius: "5px" },
136899
- vertical_spacing: "8px",
136900
- padding: "8px 8px 8px 8px",
136901
- elements: [
136902
- {
136903
- tag: "markdown",
136904
- content: truncatedThinking,
136905
- text_size: "notation"
136906
- }
136907
- ]
136908
- },
136909
- { tag: "hr" }
136910
- ];
136911
- }
136912
- function detectLangFromPath(filePath) {
136913
- const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
136914
- return EXT_LANG_MAP[ext] ?? "";
136915
- }
136916
- function formatToolContent(toolName, detail, result) {
136917
- if (toolName === "Read") {
136918
- const lang = detectLangFromPath(detail);
136919
- return "```" + lang + "\n" + result + "\n```";
136920
- }
136921
- if (toolName === "Bash") {
136922
- return "```bash\n" + result + "\n```";
136923
- }
136924
- return result;
136925
- }
136926
- function buildToolResultPanel(entry) {
136927
- const raw = entry.resultPreview.length > TOOL_RESULT_TRUNCATE ? truncateSafely(entry.resultPreview, TOOL_RESULT_TRUNCATE, "\n...") : entry.resultPreview;
136928
- const content = formatToolContent(entry.toolName, entry.detail, raw);
136929
- const headerTitle = entry.detail ? `${entry.label} \u2014 ${entry.detail}` : entry.label;
136930
- return {
136931
- tag: "collapsible_panel",
136932
- expanded: false,
136933
- background_color: "grey",
136934
- header: {
136935
- title: {
136936
- tag: "plain_text",
136937
- content: headerTitle
136938
- },
136939
- vertical_align: "center",
136940
- icon: {
136941
- tag: "standard_icon",
136942
- token: "down-small-ccm_outlined",
136943
- size: "16px 16px"
136944
- },
136945
- icon_position: "right",
136946
- icon_expanded_angle: -180
136947
- },
136948
- border: { color: "grey", corner_radius: "5px" },
136949
- vertical_spacing: "8px",
136950
- padding: "8px 8px 8px 8px",
136951
- elements: [
136952
- {
136953
- tag: "markdown",
136954
- content,
136955
- text_size: "notation"
136956
- }
136957
- ]
136958
- };
136959
- }
136960
- function buildToolPanels(results) {
136961
- if (results.length === 0) return [];
136962
- return results.map((r2) => buildToolResultPanel(r2));
136963
- }
136964
- var THINKING_OVERFLOW_TRUNCATE, TOOL_RESULT_TRUNCATE, EXT_LANG_MAP;
136965
- var init_duration = __esm({
136966
- "src/format/duration.ts"() {
136967
- "use strict";
136968
- init_card_optimize();
136969
- THINKING_OVERFLOW_TRUNCATE = 3e3;
136970
- TOOL_RESULT_TRUNCATE = 2e3;
136971
- EXT_LANG_MAP = {
136972
- ts: "typescript",
136973
- tsx: "typescript",
136974
- js: "javascript",
136975
- jsx: "javascript",
136976
- mjs: "javascript",
136977
- py: "python",
136978
- go: "go",
136979
- rs: "rust",
136980
- java: "java",
136981
- json: "json",
136982
- yaml: "yaml",
136983
- yml: "yaml",
136984
- md: "markdown",
136985
- html: "html",
136986
- htm: "html",
136987
- css: "css",
136988
- sql: "sql",
136989
- sh: "bash",
136990
- bash: "bash",
136991
- zsh: "bash",
136992
- xml: "xml",
136993
- toml: "toml",
136994
- ini: "ini",
136995
- c: "c",
136996
- h: "c",
136997
- cpp: "cpp",
136998
- cc: "cpp",
136999
- cxx: "cpp",
137000
- hpp: "cpp",
137001
- rb: "ruby",
137002
- php: "php",
137003
- swift: "swift",
137004
- kt: "kotlin",
137005
- kts: "kotlin",
137006
- dart: "dart",
137007
- dockerfile: "dockerfile",
137008
- makefile: "makefile",
137009
- diff: "diff"
137010
- };
137011
- }
137012
- });
137013
-
137014
137048
  // src/feishu/document.ts
137015
137049
  import * as fs3 from "fs";
137016
137050
  import * as path2 from "path";
@@ -137510,19 +137544,14 @@ async function replyWithDocument(client, chatId, rootMsgId, markdown, context, o
137510
137544
  \u26A0\uFE0F ${docWarnings.join("\uFF1B")}`;
137511
137545
  }
137512
137546
  const elements = [{ tag: "markdown", content: replyMsg }];
137513
- const footer = buildFooterMarkdown({
137547
+ const footer = buildFooterElement({
137514
137548
  inputTokens: stats?.inputTokens,
137515
137549
  outputTokens: stats?.outputTokens,
137516
137550
  toolCount: stats?.toolCount
137517
137551
  });
137518
137552
  if (footer) {
137519
- elements.push({ tag: "hr" }, { tag: "markdown", content: footer, text_size: "notation" });
137553
+ elements.push({ tag: "hr" }, footer);
137520
137554
  }
137521
- const tags = [];
137522
- if (stats?.model) tags.push({ text: stats.model, color: "blue" });
137523
- const totalTokens = (stats?.inputTokens ?? 0) + (stats?.outputTokens ?? 0);
137524
- if (totalTokens > 0) tags.push({ text: `${totalTokens.toLocaleString()} tokens`, color: "turquoise" });
137525
- if (stats?.duration != null) tags.push({ text: formatDuration(stats.duration), color: "orange" });
137526
137555
  const docCard = {
137527
137556
  schema: "2.0",
137528
137557
  config: { wide_screen_mode: true },
@@ -137531,7 +137560,7 @@ async function replyWithDocument(client, chatId, rootMsgId, markdown, context, o
137531
137560
  subtitle: "\u5185\u5BB9\u5DF2\u5199\u5165\u4E91\u6587\u6863",
137532
137561
  template: "green",
137533
137562
  iconImgKey: options?.headerIconImgKey,
137534
- tags
137563
+ tags: buildStatsTags(stats ?? {})
137535
137564
  }),
137536
137565
  body: { elements }
137537
137566
  };
@@ -137666,7 +137695,6 @@ var init_message = __esm({
137666
137695
  init_format();
137667
137696
  init_duration();
137668
137697
  init_card();
137669
- init_duration();
137670
137698
  init_client();
137671
137699
  init_document2();
137672
137700
  CHUNK_SIZE = 2800;
@@ -137797,35 +137825,57 @@ var init_download = __esm({
137797
137825
  function fmtDur(sec) {
137798
137826
  return sec < 60 ? `${sec.toFixed(0)}s` : `${Math.floor(sec / 60)}m ${Math.round(sec % 60)}s`;
137799
137827
  }
137828
+ function formatToolSequence(toolsUsed, isTerminal) {
137829
+ if (toolsUsed.length === 0) return "";
137830
+ if (!isTerminal) {
137831
+ return toolsUsed.map((t) => TOOL_DISPLAY[t] ?? `\u{1F527} ${t}`).join(" \u2192 ");
137832
+ }
137833
+ const merged = [];
137834
+ let current = toolsUsed[0];
137835
+ let count = 1;
137836
+ for (let i2 = 1; i2 < toolsUsed.length; i2++) {
137837
+ if (toolsUsed[i2] === current) {
137838
+ count++;
137839
+ } else {
137840
+ const label = TOOL_DISPLAY[current] ?? `\u{1F527} ${current}`;
137841
+ merged.push(count > 1 ? `${label} \xD7${count}` : label);
137842
+ current = toolsUsed[i2];
137843
+ count = 1;
137844
+ }
137845
+ }
137846
+ const lastLabel = TOOL_DISPLAY[current] ?? `\u{1F527} ${current}`;
137847
+ merged.push(count > 1 ? `${lastLabel} \xD7${count}` : lastLabel);
137848
+ return merged.join(" \u2192 ");
137849
+ }
137800
137850
  function buildTaskPanelCard(options) {
137801
- const { description, status, summary, lastToolName, elapsedSeconds, tokens, headerIconImgKey } = options;
137851
+ const { description, status, summary, lastToolName, toolsUsed, elapsedSeconds, tokens, headerIconImgKey } = options;
137802
137852
  const st = STATUS_TEMPLATE[status];
137853
+ const isTerminal = status !== "running";
137803
137854
  const elements = [];
137804
137855
  const statusParts = [`**${st.icon} ${st.label}**`];
137805
- if (lastToolName && status === "running") statusParts.push(`Tool: \`${lastToolName}\``);
137856
+ if (lastToolName && status === "running") statusParts.push(`\`${lastToolName}\``);
137806
137857
  elements.push({ tag: "markdown", content: statusParts.join(" \xB7 ") });
137807
- const hasContent = summary && summary !== "Done" && summary !== "Aborted";
137808
- if (hasContent) {
137809
- elements.push({ tag: "markdown", content: summary.length > 3e3 ? summary.slice(0, 3e3) + "..." : summary });
137858
+ if (toolsUsed && toolsUsed.length > 0) {
137859
+ elements.push({ tag: "markdown", content: formatToolSequence(toolsUsed, isTerminal), text_size: "notation" });
137860
+ }
137861
+ if (summary && summary !== "Done" && summary !== "Aborted") {
137862
+ elements.push({ tag: "markdown", content: summary.length > TASK_SUMMARY_TRUNCATE ? summary.slice(0, TASK_SUMMARY_TRUNCATE) + "..." : summary });
137810
137863
  } else if (status === "running") {
137811
137864
  elements.push({ tag: "markdown", content: "Processing..." });
137812
137865
  }
137813
- const footerParts = [];
137814
- if (elapsedSeconds != null) footerParts.push(`\u23F1 ${fmtDur(elapsedSeconds)}`);
137815
- if (status !== "running" && tokens != null) footerParts.push(`\u{1FA99} ${tokens.toLocaleString()} tokens`);
137816
- if (footerParts.length > 0) {
137817
- elements.push({ tag: "markdown", content: `<font color='grey'>${footerParts.join(" \xB7 ")}</font>` });
137818
- }
137819
- const icon = headerIconImgKey ? { tag: "custom_icon", img_key: headerIconImgKey } : { tag: "standard_icon", token: "larkcommunity_colorful" };
137866
+ const tags = [];
137867
+ if (elapsedSeconds != null) tags.push({ text: fmtDur(elapsedSeconds), color: "turquoise" });
137868
+ if (isTerminal && tokens != null) tags.push({ text: `${tokens.toLocaleString()} tokens`, color: "blue" });
137820
137869
  return {
137821
137870
  schema: "2.0",
137822
137871
  config: { wide_screen_mode: true },
137823
- header: {
137824
- title: { tag: "plain_text", content: "\u{1F916} Sub Agent" },
137825
- subtitle: { tag: "plain_text", content: description },
137872
+ header: buildHeader({
137873
+ title: description,
137874
+ subtitle: "\u{1F916} Sub Agent",
137826
137875
  template: st.color,
137827
- icon
137828
- },
137876
+ iconImgKey: headerIconImgKey,
137877
+ tags
137878
+ }),
137829
137879
  body: { elements }
137830
137880
  };
137831
137881
  }
@@ -137844,16 +137894,27 @@ async function updateTaskCard(client, msgId, options) {
137844
137894
  data: { content: JSON.stringify(card) }
137845
137895
  });
137846
137896
  }
137847
- var STATUS_TEMPLATE;
137897
+ var STATUS_TEMPLATE, TOOL_DISPLAY;
137848
137898
  var init_task_panel = __esm({
137849
137899
  "src/feishu/task-panel.ts"() {
137850
137900
  "use strict";
137901
+ init_card();
137902
+ init_duration();
137851
137903
  STATUS_TEMPLATE = {
137852
137904
  running: { color: "turquoise", icon: "\u{1F504}", label: "Running" },
137853
137905
  completed: { color: "green", icon: "\u2705", label: "Completed" },
137854
137906
  failed: { color: "red", icon: "\u274C", label: "Failed" },
137855
137907
  stopped: { color: "grey", icon: "\u23F9", label: "Stopped" }
137856
137908
  };
137909
+ TOOL_DISPLAY = {
137910
+ Read: "\u{1F4C2} Read",
137911
+ Write: "\u{1F4DD} Write",
137912
+ Edit: "\u270F\uFE0F Edit",
137913
+ Bash: "\u26A1 Bash",
137914
+ Glob: "\u{1F4C2} Glob",
137915
+ Grep: "\u{1F50D} Grep",
137916
+ LS: "\u{1F4C1} LS"
137917
+ };
137857
137918
  }
137858
137919
  });
137859
137920
 
@@ -137933,7 +137994,7 @@ var VERSION3;
137933
137994
  var init_version = __esm({
137934
137995
  "src/version.ts"() {
137935
137996
  "use strict";
137936
- VERSION3 = "0.12.3";
137997
+ VERSION3 = "0.12.5";
137937
137998
  }
137938
137999
  });
137939
138000
 
@@ -154693,12 +154754,13 @@ var init_streaming = __esm({
154693
154754
  "src/streaming.ts"() {
154694
154755
  "use strict";
154695
154756
  init_card_optimize();
154757
+ init_duration();
154696
154758
  init_thinking();
154697
154759
  init_feishu();
154698
154760
  LONG_GAP_MS = 2e3;
154699
154761
  GAP_CHECK_INTERVAL = 500;
154700
154762
  HEARTBEAT_MS = 15e3;
154701
- TRUNCATE_LIMIT = 4e3;
154763
+ TRUNCATE_LIMIT = STREAMING_TRUNCATE;
154702
154764
  FlushController = class {
154703
154765
  minIntervalMs;
154704
154766
  onFlush;
@@ -154979,7 +155041,7 @@ var init_cardkit = __esm({
154979
155041
  init_feishu();
154980
155042
  init_streaming();
154981
155043
  init_format();
154982
- TRUNCATE_LIMIT2 = 4e3;
155044
+ TRUNCATE_LIMIT2 = STREAMING_TRUNCATE;
154983
155045
  CardKitApiError = class extends Error {
154984
155046
  code;
154985
155047
  constructor(code, msg, context) {
@@ -155410,14 +155472,13 @@ ${displayContent}`;
155410
155472
  element_id: this.streamElementId
155411
155473
  }
155412
155474
  ];
155413
- const footer = buildFooterMarkdown({
155475
+ const footer = buildFooterElement({
155414
155476
  inputTokens: stats?.inputTokens,
155415
155477
  outputTokens: stats?.outputTokens,
155416
- toolCount: stats?.toolCount,
155417
- duration: stats?.duration
155478
+ toolCount: stats?.toolCount
155418
155479
  });
155419
155480
  if (footer) {
155420
- elements.push({ tag: "hr" }, { tag: "markdown", content: footer, text_size: "notation" });
155481
+ elements.push({ tag: "hr" }, footer);
155421
155482
  }
155422
155483
  const cardJson = {
155423
155484
  schema: "2.0",
@@ -155428,23 +155489,12 @@ ${displayContent}`;
155428
155489
  body: { elements }
155429
155490
  };
155430
155491
  if (this.cardTitle) {
155431
- const tags = [];
155432
- if (stats?.model) {
155433
- tags.push({ text: stats.model, color: "blue" });
155434
- }
155435
- const totalTokens = (stats?.inputTokens ?? 0) + (stats?.outputTokens ?? 0);
155436
- if (totalTokens > 0) {
155437
- tags.push({ text: `${totalTokens.toLocaleString()} tokens`, color: "turquoise" });
155438
- }
155439
- if (stats?.duration != null) {
155440
- tags.push({ text: formatDuration(stats.duration), color: "orange" });
155441
- }
155442
155492
  cardJson.header = buildHeader({
155443
155493
  title: this.cardTitle,
155444
155494
  subtitle: "\u5BF9\u8BDD\u5B8C\u6210",
155445
155495
  template: "green",
155446
155496
  iconImgKey: this.headerIconImgKey,
155447
- tags
155497
+ tags: buildStatsTags(stats ?? {})
155448
155498
  });
155449
155499
  }
155450
155500
  return cardJson;
@@ -155494,7 +155544,8 @@ var init_task_panel2 = __esm({
155494
155544
  msgId,
155495
155545
  description: event.description,
155496
155546
  status: "running",
155497
- startTime: Date.now()
155547
+ startTime: Date.now(),
155548
+ toolsUsed: []
155498
155549
  });
155499
155550
  logger.dim(`[task-panel] started: ${event.description.slice(0, 40)}`);
155500
155551
  } catch (err) {
@@ -155506,7 +155557,12 @@ var init_task_panel2 = __esm({
155506
155557
  const task = this.tasks.get(event.task_id);
155507
155558
  if (!task || task.status !== "running") return;
155508
155559
  if (event.summary) task.summary = event.summary;
155509
- if (event.last_tool_name) task.lastToolName = event.last_tool_name;
155560
+ if (event.last_tool_name) {
155561
+ task.lastToolName = event.last_tool_name;
155562
+ if (task.toolsUsed[task.toolsUsed.length - 1] !== event.last_tool_name) {
155563
+ task.toolsUsed.push(event.last_tool_name);
155564
+ }
155565
+ }
155510
155566
  if (event.usage) {
155511
155567
  task.tokens = event.usage.total_tokens;
155512
155568
  }
@@ -155516,6 +155572,7 @@ var init_task_panel2 = __esm({
155516
155572
  status: "running",
155517
155573
  summary: task.summary,
155518
155574
  lastToolName: task.lastToolName,
155575
+ toolsUsed: task.toolsUsed,
155519
155576
  elapsedSeconds: (Date.now() - task.startTime) / 1e3,
155520
155577
  tokens: task.tokens,
155521
155578
  headerIconImgKey: this.headerIconImgKey
@@ -155537,6 +155594,7 @@ var init_task_panel2 = __esm({
155537
155594
  description: task.description,
155538
155595
  status: event.status,
155539
155596
  summary: event.summary,
155597
+ toolsUsed: task.toolsUsed,
155540
155598
  elapsedSeconds,
155541
155599
  tokens: task.tokens,
155542
155600
  headerIconImgKey: this.headerIconImgKey
@@ -155556,6 +155614,7 @@ var init_task_panel2 = __esm({
155556
155614
  description: task.description,
155557
155615
  status: "stopped",
155558
155616
  summary: task.summary ?? "Aborted",
155617
+ toolsUsed: task.toolsUsed,
155559
155618
  elapsedSeconds: (Date.now() - task.startTime) / 1e3,
155560
155619
  tokens: task.tokens
155561
155620
  });
@@ -155574,6 +155633,7 @@ var init_task_panel2 = __esm({
155574
155633
  description: task.description,
155575
155634
  status: "completed",
155576
155635
  summary: task.summary ?? "Done",
155636
+ toolsUsed: task.toolsUsed,
155577
155637
  elapsedSeconds: (Date.now() - task.startTime) / 1e3,
155578
155638
  tokens: task.tokens
155579
155639
  });
@@ -155614,9 +155674,6 @@ function formatInput(name, input) {
155614
155674
  if (name === "Glob") return String(input.pattern ?? "");
155615
155675
  return JSON.stringify(input).slice(0, 100);
155616
155676
  }
155617
- function truncate(str2, len) {
155618
- return str2.length > len ? str2.slice(0, len) + "..." : str2;
155619
- }
155620
155677
  function buildReplyContext(config2, profile2, cwd2, chatId, rootMsgId) {
155621
155678
  return {
155622
155679
  profile: profile2 ?? "default",
@@ -155774,13 +155831,13 @@ async function runAgent(prompt2, cwd2, config2, client, chatId, rootMsgId, image
155774
155831
  await cardkitCtrl?.clearStatus();
155775
155832
  const raw = typeof block.content === "string" ? block.content : JSON.stringify(block.content ?? "");
155776
155833
  const toolEntry = cardkitToolResults.find((t) => t.id === block.tool_use_id);
155777
- if (toolEntry) toolEntry.resultPreview = truncate(raw, 500);
155834
+ if (toolEntry) toolEntry.resultPreview = raw;
155778
155835
  break;
155779
155836
  }
155780
155837
  const toolInfo = toolMsgMap.get(block.tool_use_id);
155781
155838
  if (toolInfo) {
155782
155839
  const raw = typeof block.content === "string" ? block.content : JSON.stringify(block.content ?? "");
155783
- await updateToolCard(client, toolInfo.msgId, toolInfo.label, toolInfo.detail, truncate(raw, 500));
155840
+ await updateToolCard(client, toolInfo.msgId, toolInfo.label, toolInfo.detail, raw.length > TOOL_RESULT_TRUNCATE ? truncateSafely(raw, TOOL_RESULT_TRUNCATE) : raw);
155784
155841
  }
155785
155842
  }
155786
155843
  }
@@ -155910,6 +155967,7 @@ var init_agent = __esm({
155910
155967
  init_guide();
155911
155968
  init_thinking();
155912
155969
  init_duration();
155970
+ init_card_optimize();
155913
155971
  init_image_resolver();
155914
155972
  init_streaming();
155915
155973
  init_cardkit();